diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 943666936a..71cac4630b 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -1270,4 +1270,6 @@ with (obj_p_fleet){ } } +loyaty_countdowns(); + }); \ No newline at end of file diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index a3e972f9d4..37314438ab 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -24,7 +24,6 @@ try_and_report_loop("player alarm 1",function(){ else if (action="move") or (action="crusade1") or (action="crusade2") or (action="crusade3"){ - var i; set_fleet_location("Warp"); @@ -64,8 +63,10 @@ try_and_report_loop("player alarm 1",function(){ var ret=instance_nearest(x,y,obj_star); action_x=ret.x; action_y=ret.y; - action="crusade3";action_eta=floor(point_distance(x,y,ret.x,ret.y)/128)+1; - alarm[4]=1;instance_activate_object(obj_star); + action="crusade3"; + action_eta=floor(point_distance(x,y,ret.x,ret.y)/128)+1; + alarm[4]=1; + instance_activate_object(obj_star); } if (action_eta=0) and (action="crusade3"){ // Popup here diff --git a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml index a0fc693213..7c5c882ec7 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -99,6 +99,7 @@ function scr_enemy_ai_d() { if (result="imperial") then scr_event_log("",alert_text); remove_planet_problem(i, "succession"); } + if (has_problem_planet_and_time(i, "recon", 0)>-1){ var alert_text="Inquisition Mission Failed: Investigate "; alert_text+=string(name)+" "+scr_roman(i)+"."; @@ -108,34 +109,10 @@ function scr_enemy_ai_d() { remove_planet_problem(i, "recon"); } - if (has_problem_planet_and_time(i, "great_crusade", 0)>-1){ - var flet,cont,dir;cont=0; - flet=instance_nearest(x,y,obj_p_fleet); - - if (flet.action="") then cont=1; - if (cont=1) and (point_distance(x,y,flet.x,flet.y)<40) then cont=2; - - if (cont=2){ - flet.action="crusade1"; - dir=point_direction(room_width/2,room_height/2,x,y); - flet.action_x=x+lengthdir_x(2000,dir); - flet.action_y=y+lengthdir_y(2000,dir); - // flet.action_eta=floor(random(8))+12; - flet.action_eta=floor(random(8))+2; - flet.alarm[4]=1; - scr_alert("green","crusade","Fleet embarks upon Crusade.",x,y); - scr_event_log("","Fleet embarks upon Crusade."); - } - if (cont=1) or (cont=0){ - // hit loyalty here - obj_controller.disposition[2]-=5; - obj_controller.disposition[4]-=10; - scr_alert("red","crusade","No ships designated for Crusade.",x,y); - scr_loyalty("Refusing to Crusade","+"); - scr_event_log("red","No ships designated for Crusade."); - if (obj_controller.penitent=1) then obj_controller.penitent_current=0; - } - remove_planet_problem(i, "great_crusade"); + var _great_crusade = has_problem_planet_and_time(i, "great_crusade", 0); + + if (_great_crusade>-1){ + init_crusade_mission(i, _great_crusade); } var raider_planet_slot = has_problem_planet_with_time(i,"mech_raider"); diff --git a/scripts/scr_event_log/scr_event_log.gml b/scripts/scr_event_log/scr_event_log.gml index 925b72e425..96a5713c80 100644 --- a/scripts/scr_event_log/scr_event_log.gml +++ b/scripts/scr_event_log/scr_event_log.gml @@ -1,7 +1,7 @@ function scr_event_log(event_colour, event_text, target = "none") { if (instance_exists(obj_event_log)){ - var yf;yf=""; + var yf=""; if (obj_controller.year_fraction<10) then yf="00"+string(obj_controller.year_fraction); if (obj_controller.year_fraction>=10) and (obj_controller.year_fraction<100) then yf="0"+string(obj_controller.year_fraction); if (obj_controller.year_fraction>=100) then yf=string(obj_controller.year_fraction); @@ -17,3 +17,13 @@ function scr_event_log(event_colour, event_text, target = "none") { } } + +function alert_and_event(event_colour, event_text, target=-1){ + if (instance_exists(target)){ + scr_event_log(event_colour, event_text, target.name); + scr_alert(event_colour, event_text, target.x, target.y); + } else { + scr_event_log(event_colour, event_text); + scr_alert(event_colour, event_text); + } +} diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 3e522d0130..3f1b7f2a34 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -143,6 +143,7 @@ function set_fleet_movement(fastest_route = true){ action = ""; + static minimum_eta = 1; if (action==""){ turns_static = 0; var sys, mine, fleet; @@ -170,15 +171,17 @@ function set_fleet_movement(fastest_route = true){ sys=instance_nearest(action_x,action_y,obj_star); mine=instance_nearest(x,y,obj_star); - - var eta = calculate_fleet_eta(x,y,action_x,action_y,action_spd,instance_exists(sys),is_orbiting(),warp_able); + var _travel_to_star = point_distance(sys.x, sys.y, action_x,action_y < 20); + var eta = calculate_fleet_eta(x,y,action_x,action_y,action_spd,is_orbiting(),_travel_to_star,warp_able); action_eta = eta; if (action_eta<=0) or (owner != eFACTION.Inquisition){ action_eta=eta; if (owner = eFACTION.Inquisition) and (action_eta<2) and (string_count("_her",trade_goods)=0) then action_eta=2; } - if (owner != eFACTION.Eldar && mine.storm) then action_eta+=10000; + if (owner != eFACTION.Eldar && mine.storm){ + action_eta+=10000; + } // action_x=sys.x; // action_y=sys.y; @@ -186,7 +189,6 @@ function set_fleet_movement(fastest_route = true){ action="move"; if (minimum_eta>action_eta) and (minimum_eta>0) then action_eta=minimum_eta; - minimum_eta=0; } } } diff --git a/scripts/scr_loyalty/scr_loyalty.gml b/scripts/scr_loyalty/scr_loyalty.gml index c16c6d34b6..64c5e048f8 100644 --- a/scripts/scr_loyalty/scr_loyalty.gml +++ b/scripts/scr_loyalty/scr_loyalty.gml @@ -1,57 +1,169 @@ -function scr_loyalty(argument0, argument1) { - // argument0 = name - // argument1 = todo +global.loyalty_effects = { + "Xeno Associate" : { + hit : 0.09, + }, + "Lack of Apothecary" :{ + hit : 0.075, + }, + "Upset Machine Spirits":{ + hit : 0.075, + }, + "Undevout":{ + hit : 0.075, + }, + "Xeno Trade":{ + hit : 0.05, + }, + "Non-Codex Size":{ + hit : 0.06, + }, + "Irreverance for His Servants":{ + hit : 0.005, + }, + "Mutant Gene-Seed":{ + hit : 0.01, + }, + "Heretical Homeworld":{ + hit : 0.07, + }, + "Avoiding Inspections":{ + hit : 5, + time : 200, + incremental : true, + }, + "Lost Standard" : { + hit : 5, + time : 99999, + incremental : false, + }, + "Refusing to Crusade":{ + hit : 20, + time : 600, + incremental : false, + }, + "Crossing the Inquisition":{ + hit : 40, + time : 99999, + }, + "Use of Sorcery":{ + hit : 40, + time : 99999, + }, +} + +function loyalty_penalty(loyalty_reason){ + var _reasons = global.loyalty_effects; + var _existing = array_get_index(obj_controller.loyal); + if (struct_exists(loyalty_effects, loyalty_reason)){ + var _penalty_data = loyalty_effects[$ loyalty_reason]; + if (struct_exists(_penalty_data, "hit")){ + if (_existing == -1){ + with (obj_controller){ + array_push(loyal,loyalty_reason); + array_push(loyal_num,_penalty_data.hit ); + + } + } else { + loyal_num[_existing] += _penalty_data.hit; + } + } + } +} + +function loyalty_countdowns(){ + for (var i=0;i0){ + obj_controller.loyal_time[i]--; + if (is_array(obj_controller.loyal_num[i])){ + var loyal_nums = obj_controller.loyal_num[i]; + if (loyal_nums[1]++>=loyal_nums[0]){ + obj_controller.loyalty+=loyal_nums[2]; + obj_controller.loyal_num[i]=[loyal_nums[0],0, loyal_nums[2]]; + } else { + obj_controller.loyal_num[i]=loyal_nums; + } + } + if (obj_controller.loyal_time[i] == 0){ + obj_controller.loyal_num = 0; + } + } + } +} +function loyalty_tooltip_string(){ + var tx=0,ty=0,tool1="",tool2="",plu=""; + + var lines=0; + for(var d=0; d<=20; d++){ + if (is_array(loyal_num[d])){ + + } + else if (loyal_num[d]>1) and (lines=0){ + tool1+=string(loyal[d])+": -"+string(loyal_num[d])+"#"; + tool2+=string(loyal[d])+": #"; + lines++; + } + } + + if (tool1="") then tool1="Loyalty"; + + if (tool1!=""){ + tooltip_draw(tool1); + } +} +function scr_loyalty(loaylty_effect, loyalty_value) { + // loaylty_effect = name + // loyalty_value = todo // This adds the crime to the chapter history - if (argument1="+"){ - var i, noplus;i=0;noplus=0; + if (loyalty_value="+"){ + var i=0, noplus=0; - repeat(30){ - i+=1;noplus=0; + for (var i=0;i=50) and (one=0) and (string_count("|SC|",obj_controller.useful_info)=1){obj_controller.disposition[4]=20;one=1;} if (obj_controller.disposition[4]<50) and (string_count("|SC|",obj_controller.useful_info)=1) and (obj_controller.disposition[4]>10) and (one=0){obj_controller.disposition[4]=0;one=2;} - if (string_count("|SC|",obj_controller.useful_info)>1){obj_controller.disposition[4]=0;one=2;} + if (string_count("|SC|",obj_controller.useful_info)>1){ + obj_controller.disposition[4]=0; + one=2; + } if (obj_controller.loyalty<=0) and (one<2) then one=2; - if (one=1) then with(obj_controller){scr_audience(4,"sorcery1",0,"",0,0);} - if (one>=2) and (obj_controller.penitent=0){repeat(2){obj_controller.useful_info+="|SC|";}scr_audience(4,"loyalty_zero",0,"",0,0);} - if (one>=2) and (obj_controller.penitent=1){repeat(2){obj_controller.useful_info+="|SC|";}obj_controller.alarm[8]=1;} + if (one=1) then with(obj_controller){ + scr_audience(4,"sorcery1",0,"",0,0); + } + if (one>=2) and (obj_controller.penitent=0){ + repeat(2){ + obj_controller.useful_info+="|SC|"; + } + scr_audience(4,"loyalty_zero",0,"",0,0); + } + if (one>=2) and (obj_controller.penitent=1){ + repeat(2){ + obj_controller.useful_info+="|SC|"; + } + obj_controller.alarm[8]=1; + } - exit;exit; + exit; + exit; } if (noplus=0) then obj_controller.loyal_num[i]+=amount; diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 5a6eb473d7..fb9800bc65 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -84,6 +84,35 @@ function scr_new_governor_mission(planet){ } } +function init_crusade_mission(targ_planet, problem_index){ + var cont,dir;cont=0; + var flet=instance_nearest(x,y,obj_p_fleet); + + if (flet.action="") then cont=1; + if (cont=1) and (point_distance(x,y,flet.x,flet.y)<40) then cont=2; + + if (cont=2){ + flet.action=""; + dir=point_direction(room_width/2,room_height/2,x,y); + flet.action_x=x+lengthdir_x(2000,dir); + flet.action_y=y+lengthdir_y(2000,dir); + // flet.action_eta=floor(random(8))+12; + with (flet){ + set_fleet_movement(false); + action="crusade1"; + } + alert_and_event("green","Fleet embarks upon Crusade.", self.id); + } + if (cont=1) or (cont=0){ + // hit loyalty here + obj_controller.disposition[2]-=5; + obj_controller.disposition[4]-=10; + alert_and_event("red","No ships designated for Crusade.", self.id); + scr_loyalty("Refusing to Crusade","+"); + if (obj_controller.penitent=1) then obj_controller.penitent_current=0; + } + remove_planet_problem(targ_planet, "great_crusade"); +} function init_garrison_mission(planet, star, mission_slot){ var problems_data = star.p_problem_other_data[planet] diff --git a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml index 9776792e36..c0f0c2e721 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -498,6 +498,19 @@ function set_fleet_location(location){ obj_ini.ship_location[temp] = location; } } + for (var co=0;co1) and (lines=0){ - tool1+=string(loyal[d])+": -"+string(loyal_num[d])+"#"; - tool2+=string(loyal[d])+": #"; - lines++; - } - if (loyal_num[d]>1) and (lines>0){ - tool1+=string(loyal[d])+": -"+string(loyal_num[d])+"#"; - tool2+=string(loyal[d])+": #"; - lines++; - } - } - - if (tool1="") then tool1="Loyalty"; - - if (tool1!=""){ - tooltip_draw(tool1); - } + loyalty_tooltip_string(); } // Stored Gene-Seed tooltip