diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 9190e9d69..c3f3f69a5 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -749,6 +749,7 @@ {"id":{"name":"DiploCommonComponents","path":"scripts/DiploCommonComponents/DiploCommonComponents.yy",},}, {"id":{"name":"draw_line_dashed","path":"scripts/draw_line_dashed/draw_line_dashed.yy",},}, {"id":{"name":"draw_set_blend_mode","path":"scripts/draw_set_blend_mode/draw_set_blend_mode.yy",},}, + {"id":{"name":"ds_map_helpers","path":"scripts/ds_map_helpers/ds_map_helpers.yy",},}, {"id":{"name":"exp_and_exp_growth","path":"scripts/exp_and_exp_growth/exp_and_exp_growth.yy",},}, {"id":{"name":"explode_script","path":"scripts/explode_script/explode_script.yy",},}, {"id":{"name":"instance_create","path":"scripts/instance_create/instance_create.yy",},}, @@ -836,6 +837,7 @@ {"id":{"name":"scr_flavor","path":"scripts/scr_flavor/scr_flavor.yy",},}, {"id":{"name":"scr_flavor2","path":"scripts/scr_flavor2/scr_flavor2.yy",},}, {"id":{"name":"scr_fleet_advisor","path":"scripts/scr_fleet_advisor/scr_fleet_advisor.yy",},}, + {"id":{"name":"scr_fleet_events","path":"scripts/scr_fleet_events/scr_fleet_events.yy",},}, {"id":{"name":"scr_fleet_functions","path":"scripts/scr_fleet_functions/scr_fleet_functions.yy",},}, {"id":{"name":"scr_forge_world_functions","path":"scripts/scr_forge_world_functions/scr_forge_world_functions.yy",},}, {"id":{"name":"scr_garrison","path":"scripts/scr_garrison/scr_garrison.yy",},}, @@ -845,6 +847,7 @@ {"id":{"name":"scr_get_item_names","path":"scripts/scr_get_item_names/scr_get_item_names.yy",},}, {"id":{"name":"scr_gift_items","path":"scripts/scr_gift_items/scr_gift_items.yy",},}, {"id":{"name":"scr_gov_disp","path":"scripts/scr_gov_disp/scr_gov_disp.yy",},}, + {"id":{"name":"scr_governors","path":"scripts/scr_governors/scr_governors.yy",},}, {"id":{"name":"scr_ground_ai_helpers","path":"scripts/scr_ground_ai_helpers/scr_ground_ai_helpers.yy",},}, {"id":{"name":"scr_has_adv","path":"scripts/scr_has_adv/scr_has_adv.yy",},}, {"id":{"name":"scr_has_disadv","path":"scripts/scr_has_disadv/scr_has_disadv.yy",},}, @@ -881,6 +884,7 @@ {"id":{"name":"scr_marine_struct","path":"scripts/scr_marine_struct/scr_marine_struct.yy",},}, {"id":{"name":"scr_master_loc","path":"scripts/scr_master_loc/scr_master_loc.yy",},}, {"id":{"name":"scr_max_marine","path":"scripts/scr_max_marine/scr_max_marine.yy",},}, + {"id":{"name":"scr_mechanicus_fleet_functions","path":"scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.yy",},}, {"id":{"name":"scr_mechanicus_missions","path":"scripts/scr_mechanicus_missions/scr_mechanicus_missions.yy",},}, {"id":{"name":"scr_mission_eta","path":"scripts/scr_mission_eta/scr_mission_eta.yy",},}, {"id":{"name":"scr_mission_functions","path":"scripts/scr_mission_functions/scr_mission_functions.yy",},}, @@ -949,6 +953,7 @@ {"id":{"name":"scr_system_spawn_functions","path":"scripts/scr_system_spawn_functions/scr_system_spawn_functions.yy",},}, {"id":{"name":"scr_Table","path":"scripts/scr_Table/scr_Table.yy",},}, {"id":{"name":"scr_target","path":"scripts/scr_target/scr_target.yy",},}, + {"id":{"name":"scr_tau_fleet_functions","path":"scripts/scr_tau_fleet_functions/scr_tau_fleet_functions.yy",},}, {"id":{"name":"scr_text_hit","path":"scripts/scr_text_hit/scr_text_hit.yy",},}, {"id":{"name":"scr_thought","path":"scripts/scr_thought/scr_thought.yy",},}, {"id":{"name":"scr_tooltip_draw","path":"scripts/scr_tooltip_draw/scr_tooltip_draw.yy",},}, diff --git a/objects/obj_controller/Alarm_1.gml b/objects/obj_controller/Alarm_1.gml index 099b0c8cc..3a1034afc 100644 --- a/objects/obj_controller/Alarm_1.gml +++ b/objects/obj_controller/Alarm_1.gml @@ -462,13 +462,13 @@ if (did) { } orkz += 3; n = array_length(_non_xenos_chaos); + _non_xenos_chaos = array_shuffle(_non_xenos_chaos); for (var j = 0; j < orkz && j < n; j++) { - _current_system = array_random_element(_non_xenos_chaos); + _current_system = array_pop(_non_xenos_chaos); _current_system.planet[1] = 1; _current_system.p_owner[1] = 90; _current_system.owner = 90; - array_delete(_non_xenos_chaos, i, 1); } } diff --git a/objects/obj_controller/Alarm_6.gml b/objects/obj_controller/Alarm_6.gml index 0525b03bd..d8ca0bc0f 100644 --- a/objects/obj_controller/Alarm_6.gml +++ b/objects/obj_controller/Alarm_6.gml @@ -6,11 +6,12 @@ if ((menu == 1) && (managing > 0)) { // vehicle types var rhi = 0, pre = 0, lrad = 0, lspi = 0, whi = 0, unit; // non chapter units - otha = 0; - - var manz = 0, vanz = 0, stahp = 0; - sel_promoting = 1; - for (var f = 0; f < array_length(display_unit); f++) { + otha=0; + + var manz=0,vanz=0,stahp=0; + sel_promoting=1; + var _roles = active_roles(); + for(var f=0; f 0)) { } // sets up count for the marines - if (man[f] == "man") { - manz += 1; - if (unit.role() == obj_ini.role[100][5]) { - cap += 1; - } else if (unit.role() == obj_ini.role[100][15]) { - apo += 1; - } else if (unit.role() == obj_ini.role[100][14]) { - chap += 1; - } else if (unit.role() == obj_ini.role[100][17]) { - lib += 1; - } else if (unit.role() == obj_ini.role[100][16]) { - tech += 1; - } else if (unit.role() == obj_ini.role[100][6]) { - drea += 1; - } else if (unit.role() == $"Venerable {obj_ini.role[100][6]}") { - vdrea += 1; - } else if (unit.role() == obj_ini.role[100][11]) { - bear += 1; - } else if (unit.role() == obj_ini.role[100][8]) { - tct += 1; - } else if (unit.role() == obj_ini.role[100][10]) { - assa += 1; - } else if (unit.role() == obj_ini.role[100][9]) { - dev += 1; - } else if (unit.role() == obj_ini.role[100][12]) { - sco += 1; - } else if (unit.role() == obj_ini.role[100][2]) { - hon += 1; - } else if (unit.role() == obj_ini.role[100][3]) { - ve += 1; - } else if (unit.role() == obj_ini.role[100][4]) { - ter += 1; - } else if (unit.role() == obj_ini.role[100][18]) { - sgt++; - } else if (unit.role() == obj_ini.role[100][19]) { - vet_sgt++; - } else if (unit.role() == "Codiciery") { - codi += 1; - } else if (unit.role() == "Lexicanum") { - lexi += 1; - } else if (unit.role() == obj_ini.role[100][eROLE.ANCIENT]) { - champ += 1; - } + if (man[f]=="man"){ + manz+=1; + if (unit.role()==_roles[5]) { cap+=1;} + else if (unit.role()==_roles[15]) { apo+=1;} + else if (unit.role()==_roles[14]) { chap+=1;} + else if (unit.role()==_roles[17]) { lib+=1;} + else if (unit.role()==_roles[16]) { tech+=1;} + else if (unit.role()==_roles[6]) { drea+=1;} + else if (unit.role()==$"Venerable {_roles[6]}"){ vdrea+=1;} + else if (unit.role()==_roles[11]) { bear+=1;} + else if (unit.role()==_roles[8]) { tct+=1;} + else if (unit.role()==_roles[10]) { assa+=1;} + else if (unit.role()==_roles[9]) { dev+=1;} + else if (unit.role()==_roles[12]) { sco+=1;} + else if (unit.role()==_roles[2]) { hon+=1;} + else if (unit.role()==_roles[3]) { ve+=1;} + else if (unit.role()==_roles[4]) { ter+=1;} + else if (unit.role()==_roles[18]) { sgt++;} + else if (unit.role()==_roles[19]) { vet_sgt++;} + else if (unit.role()=="Codiciery") { codi+=1;} + else if (unit.role()=="Lexicanum") { lexi+=1;} + else if (unit.role()==_roles[eROLE.ANCIENT]) { champ+=1;} } // sets up count for the vehicles // TODO This needs to be extended to accomodate the selection text like the man ones @@ -100,26 +80,25 @@ if ((menu == 1) && (managing > 0)) { selecting_dudes = ""; // Infantry text - if (cap > 0) { - selecting_dudes += string(cap) + " " + string(obj_ini.role[100][5]); - if (cap > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (chap > 0) { - selecting_dudes += string(chap) + " " + string(obj_ini.role[100][14]); - if (chap > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (champ > 0) { - selecting_dudes += $"{champ} {obj_ini.role[100][eROLE.ANCIENT]}"; - if (chap > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; + if (cap>0){ + selecting_dudes+=string(cap)+" "+string(_roles[5]); + if (cap>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (chap>0){ + selecting_dudes+=string(chap)+" "+string(_roles[14]); + if (chap>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (champ>0){ + selecting_dudes+=$"{champ} {_roles[eROLE.ANCIENT]}"; + if (chap>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (apo>0){ + selecting_dudes+=string(apo)+" "+string(_roles[15]); + if (apo>1) then selecting_dudes+="s"; + selecting_dudes+=", "; } if (apo > 0) { selecting_dudes += string(apo) + " " + string(obj_ini.role[100][15]); @@ -142,26 +121,20 @@ if ((menu == 1) && (managing > 0)) { } selecting_dudes += ", "; } - if (lexi > 0) { - selecting_dudes += string(lexi) + " Lexicanum"; - if (lexi > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; + if (bear>0){ + selecting_dudes+=string(bear)+" "+string(_roles[11]); + if (bear>1) then selecting_dudes+="s"; + selecting_dudes+=", "; } - if (bear > 0) { - selecting_dudes += string(bear) + " " + string(obj_ini.role[100][11]); - if (bear > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; + if (hon>0){ + selecting_dudes+=string(hon)+" "+string(_roles[2]); + if (hon>1) then selecting_dudes+="s"; + selecting_dudes+=", "; } - if (hon > 0) { - selecting_dudes += string(hon) + " " + string(obj_ini.role[100][2]); - if (hon > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; + if (tech>0){ + selecting_dudes+=string(tech)+" "+string(_roles[16]); + if (tech>1) then selecting_dudes+="s"; + selecting_dudes+=", "; } if (tech > 0) { selecting_dudes += string(tech) + " " + string(obj_ini.role[100][16]); @@ -170,69 +143,46 @@ if ((menu == 1) && (managing > 0)) { } selecting_dudes += ", "; } - if (ter > 0) { - selecting_dudes += string(ter) + " Terminator"; - if (ter > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (ve > 0) { - selecting_dudes += string(ve) + " " + string(obj_ini.role[100][3]); - if (ve > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (tct > 0) { - selecting_dudes += string(tct) + " " + string(obj_ini.role[100][8]); - if (tct > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (dev > 0) { - selecting_dudes += string(dev) + " " + string(obj_ini.role[100][9]); - if (dev > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (assa > 0) { - selecting_dudes += string(assa) + " " + string(obj_ini.role[100][eROLE.ASSAULT]); - if (sgt > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (sco > 0) { - selecting_dudes += string(sco) + " " + string(obj_ini.role[100][12]); - if (sco > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (drea > 0) { - selecting_dudes += string(drea) + " " + string(obj_ini.role[100][6]); - if (drea > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (sgt > 0) { - selecting_dudes += string(sgt) + " " + string(obj_ini.role[100][18]); - if (sgt > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } - if (vet_sgt > 0) { - selecting_dudes += string(vet_sgt) + " " + string(obj_ini.role[100][19]); - if (vet_sgt > 1) { - selecting_dudes += "s"; - } - selecting_dudes += ", "; - } + if (ve>0){ + selecting_dudes+=string(ve)+" "+string(_roles[3]); + if (ve>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (tct>0){ + selecting_dudes+=string(tct)+" "+string(_roles[8]); + if (tct>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (dev>0){ + selecting_dudes+=string(dev)+" "+string(_roles[9]); + if (dev>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (assa>0){ + selecting_dudes+=string(assa)+" "+string(_roles[eROLE.ASSAULT]); + if (sgt>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (sco>0){ + selecting_dudes+=string(sco)+" "+string(_roles[12]); + if (sco>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (drea>0){ + selecting_dudes+=string(drea)+" "+string(_roles[6]); + if (drea>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (sgt>0){ + selecting_dudes+=string(sgt)+" "+string(_roles[18]); + if (sgt>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } + if (vet_sgt>0){ + selecting_dudes+=string(vet_sgt)+" "+string(_roles[19]); + if (vet_sgt>1) then selecting_dudes+="s"; + selecting_dudes+=", "; + } // Vehicle text if (lrad > 0) { selecting_dudes += string(lrad) + " Land Raider"; diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 77387a68d..c549ebc5e 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -1,29 +1,65 @@ -owner = 0; -capital_number = 0; -frigate_number = 0; -escort_number = 0; -guardsmen = 0; -home_x = 0; -home_y = 0; -selected = 0; -ret = 0; -hurt = 0; -orbiting = 0; -rep = 3; -minimum_eta = 2; + +owner=0; +capital_number=0; +frigate_number=0; +escort_number=0; +guardsmen=0; +home_x=x; +home_y=y; +selected=0; +ret=0; +hurt=0; +orbiting=0; +rep=3; +minimum_eta=2; turns_static = 0; navy = 0; guardsmen_ratio = 0; guardsmen_unloaded = 0; complex_route = []; warp_able = false; -ii_check = floor(random(5)) + 1; -etah = 0; -safe = 0; +ii_check = floor(random(5))+1; +etah=0; +safe=0; last_turn_check = 0; +uid = scr_uuid_generate(); + +events = []; + +add_event = function(event){ + event.fleet_uid = uid; + array_push(events, event); +} + +check_events = function(){ + for (var i=array_length(events)-1;i>=0;i--){ + var _event = events[i]; + + _event.turn_sequence(); + + if (_event.state == "destroy"){ + array_delete(events,i,1); + } + + } +} + +check_events_destructions = function(){ + for (var i=array_length(events)-1;i>=0;i--){ + var _event = events[i]; + + _event.destroy_sequence(); + + array_delete(events,i,1); + } +} +last_turn_check = 0 +last_turn_image_check = -1; //TODO set up special save method for faction specific fleet variables inquisitor = -1; +set_movement = method(self,set_fleet_movement); + cargo_data = {}; image_xscale = 1.25; @@ -108,12 +144,9 @@ serialize = function() { copy_serializable_fields(object_fleet, save_data, excluded_from_save); return save_data; -}; -deserialize = function(save_data) { - var exclusions = [ - "id", - "cargo_data" - ]; // skip automatic setting of certain vars, handle explicitly later +} +deserialize = function(save_data){ + var exclusions = ["id","cargo_data","events"]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting var all_names = struct_get_names(save_data); @@ -140,7 +173,18 @@ deserialize = function(save_data) { } } - if (save_data.orbiting != 0 && action == "") { + if (struct_exists(save_data, "events")){ + for (var i=0;i 0) { if ((mouse_x >= __view_get(e__VW.XView, 0) + 529) && (mouse_y >= __view_get(e__VW.YView, 0) + 234) && (mouse_x < __view_get(e__VW.XView, 0) + 611) && (mouse_y < __view_get(e__VW.YView, 0) + 249)) { @@ -95,7 +95,9 @@ switch (owner) { draw_icon = true; _has_warboss = true; } + break; } +var _reset = false; var fleet_descript = ""; if ((within == 1) || (selected > 0)) { @@ -208,5 +210,7 @@ if (instance_exists(target)) { draw_set_alpha(1); } +pop_draw_return_values(); + /* */ /* */ diff --git a/objects/obj_star/Alarm_1.gml b/objects/obj_star/Alarm_1.gml index 0e57d05e7..83981ddfd 100644 --- a/objects/obj_star/Alarm_1.gml +++ b/objects/obj_star/Alarm_1.gml @@ -3,7 +3,16 @@ // If getting to max pop is very rare, it will be awful to recruit from // some planets may be better or worse than others depending on their max pop. // TODO refactor and improve logic -for (var i = 1; i <= 4; i++) { +system_garrison = [0]; +system_sabatours = [0]; +system_datas = [0]; +for (var i = 1; i <= planets; i++) { + p_governor[i] = new GovernorProfile(); + array_push(system_garrison, new GarrisonForce(p_operatives[i], false)); + array_push(system_sabatours, new GarrisonForce(p_operatives[i], false, "sabotage")); + array_push(system_datas, new PlanetData(i, self)); +} +for (var i = 1; i <= planets; i++) { p_population[i] = 0; // 10B switch (p_type[i]) { case "Lava": diff --git a/objects/obj_star/Alarm_3.gml b/objects/obj_star/Alarm_3.gml index a8451f5cf..940e902bd 100644 --- a/objects/obj_star/Alarm_3.gml +++ b/objects/obj_star/Alarm_3.gml @@ -53,8 +53,8 @@ try { } if (struct_exists(_data, "planet")) { obj_controller.selecting_planet = _data.planet; - if (obj_controller.selecting_planet > 0 && obj_controller.selecting_planet < 5) { - obj_star_select.garrison = new GarrisonForce(p_operatives[obj_controller.selecting_planet]); + if (obj_controller.selecting_planet > 0 && _data.planet < 5) { + obj_star_select.garrison = system_garrison.update(p_operatives[_data.planet]); } } obj_controller.selection_data = false; diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 56899f58f..09cb47abb 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -63,8 +63,8 @@ p_heresy = array_create(_planet_array_size, 0); p_hurssy = array_create(_planet_array_size, 0); p_hurssy_time = array_create(_planet_array_size, 0); p_heresy_secret = array_create(_planet_array_size, 0); -p_raided = array_create(_planet_array_size, 0); -p_governor = array_create(_planet_array_size, ""); +p_raided = array_create(_planet_array_size, false); +p_governor = array_create(_planet_array_size, false); p_operatives = array_create_advanced(_planet_array_size, []); p_feature = array_create_advanced(_planet_array_size, []); p_upgrades = array_create_advanced(_planet_array_size, []); @@ -73,6 +73,15 @@ p_problem = array_create_advanced(_planet_array_size, array_create(8, "")); p_problem_other_data = array_create_advanced(_planet_array_size, array_create_advanced(8, {})); p_timer = array_create_advanced(_planet_array_size, array_create(8, -1)); + +system_datas = array_create(8, 0); +system_garrison = array_create(8, 0); +system_sabatours = array_create(8, 0) + +add_feature = function(planet, feature){ + array_push(p_feature[planet], feature); +} + system_player_ground_forces = 0; garrison = false; @@ -143,6 +152,10 @@ serialize = function() { save_data.system_sabatours = object_star.system_sabatours; } + if (struct_exists(object_star, "p_governor")) { + save_data.p_governor = object_star.p_governor; + } + var excluded_from_save = [ "temp", "serialize", @@ -224,6 +237,12 @@ function deserialize(save_data) { if (struct_exists(save_data, "system_garrison")) { variable_struct_set(self, "system_garrison", save_data.system_garrison); } + + if (struct_exists(save_data, "p_governor")) { + variable_struct_set(self, "p_governor", save_data.p_governor); + } + + } #endregion diff --git a/objects/obj_star/Draw_0.gml b/objects/obj_star/Draw_0.gml index 7bc5721dd..57f5a0537 100644 --- a/objects/obj_star/Draw_0.gml +++ b/objects/obj_star/Draw_0.gml @@ -1,33 +1,42 @@ // Draws the system name and color codes it based on ownership -if ((p_type[1] == "Craftworld") && (obj_controller.known[eFACTION.ELDAR] == 0)) { +add_draw_return_values(); +if (p_type[1]="Craftworld") and (obj_controller.known[eFACTION.ELDAR]=0){ draw_set_alpha(0); draw_set_color(255); draw_circle(old_x, old_y, 5, 0); draw_set_alpha(1); + pop_draw_return_values(); exit; } var show = name; -if (global.cheat_debug == true) { - show = string(name) + "#" + string(p_problem[1][1]) + ":" + string(p_timer[1][1]) + "#" + string(p_problem[1][2]) + ":" + string(p_timer[1][2]) + "#" + string(p_problem[1][3]) + ":" + string(p_timer[1][3]); +if (global.cheat_debug){ + show = $"{name}"; + for (var i=1;i<=planets;i++){ + for (p=0;p 0) { - draw_sprite_ext(spr_warp_storm, storm_image, x, y, 0.75 * scale, 0.75 * scale, 0, c_white, 1); +if (storm>0){ + draw_sprite_ext(spr_warp_storm,storm_image,x,y,0.75*scale,0.75*scale,0,c_white,1); } //ad hoc way of determining whether stuff is in view or not...needs work @@ -51,40 +60,41 @@ if (global.load == -1 && (obj_controller.zoomed || in_camera_view(star_box_shape _reset = true; } - if (ds_map_exists(global.star_sprites, name)) { - var _old_sprite = ds_map_find_value(global.star_sprites, name); - if (sprite_exists(_old_sprite)) { - if (_reset) { - sprite_delete(_old_sprite); - } - } else { - _reset = true; - } - if (_reset) { - ds_map_delete(global.star_sprites, name); + if (ds_map_exists(global.star_sprites, name)){ + if (_reset){ + ds_map_delete_sprite(global.star_sprites, name); } } else { _reset = true; } - if (_reset) { - star_tag_surface = surface_create(256, 128); - var xx = 64; - var yy = 0; + + if (_reset){ + var star_tag_surface = surface_create(256, 128); + var xx=64; + var yy=0; surface_set_target(star_tag_surface); - var panel_width = string_width(name) + 60; - if (owner != eFACTION.PLAYER) { + + var _name_width = string_width(name); + + var _panel_width = _name_width + 60; + + var _panel_center = xx-(_panel_width/2); + + var _panel_y = yy + 30; + + if (owner != eFACTION.PLAYER ){ var _faction_index = owner; var faction_colour = global.star_name_colors[_faction_index]; - draw_sprite_general(spr_p_name_bg, 0, 0, 0, string_width(name) + 60, 32, xx - (panel_width / 2), yy + 30, 1, 1, 0, faction_colour, faction_colour, faction_colour, faction_colour, 1); - draw_sprite_ext(spr_faction_icons, _faction_index, xx + (panel_width / 2) - 30, yy + 25, 0.60, 0.60, 0, c_white, 1); + draw_sprite_general(spr_p_name_bg, 0, 0, 0, _panel_width, 32, _panel_center, _panel_y, 1, 1, 0, faction_colour, faction_colour, faction_colour, faction_colour, 1); + draw_sprite_ext(spr_faction_icons,_faction_index,xx+(_panel_width/2)-30,yy+25, 0.60, 0.60, 0, c_white, 1); } else { scr_shader_initialize(); var main_color = make_colour_from_array(obj_controller.body_colour_replace); var right_pauldron = make_colour_from_array(obj_controller.pauldron_colour_replace); - draw_sprite_general(spr_p_name_bg, 0, 0, 0, string_width(name) + 60, 32, xx - (panel_width / 2), yy + 30, 1, 1, 0, main_color, main_color, right_pauldron, right_pauldron, 1); + draw_sprite_general(spr_p_name_bg, 0, 0, 0, _panel_width, 32, _panel_center, _panel_y, 1, 1, 0, main_color, main_color, right_pauldron, right_pauldron, 1); var faction_sprite = global.chapter_icon.sprite; if (sprite_exists(faction_sprite)) { - draw_sprite_ext(faction_sprite, 0, xx + (panel_width / 2) - 30, yy + 30, 0.2, 0.2, 0, c_white, 1); + draw_sprite_ext(faction_sprite, 0, xx + (_panel_width / 2) - 30, yy + 30, 0.2, 0.2, 0, c_white, 1); } else { LOGGER.error($"{global.chapter_icon.name} chapter icon not found in any icon directory. Chapter icon will not render."); } @@ -103,3 +113,7 @@ if (global.load == -1 && (obj_controller.zoomed || in_camera_view(star_box_shape draw_sprite_ext(_sprite, 0, x - (64 * scale), y, scale, scale, 1, c_white, 1); } draw_set_valign(fa_top); + +pop_draw_return_values(); + + diff --git a/objects/obj_star_select/Draw_64.gml b/objects/obj_star_select/Draw_64.gml index c7ad7b310..3edf52706 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -1,148 +1,150 @@ -if (instances_exist_any([obj_bomb_select, obj_drop_select, obj_popup])) { - exit; -} -if (obj_controller.zoomed == 1) { - exit; -} -if (!instance_exists(target)) { - exit; -} -if (obj_controller.menu == 60) { + + +if (instances_exist_any([obj_bomb_select, obj_drop_select, obj_popup])){ exit; } +if (obj_controller.zoomed=1) then exit; +if (!instance_exists(target)) then exit; +if (obj_controller.menu=60) then exit; + add_draw_return_values(); draw_set_font(fnt_40k_14b); draw_set_halign(fa_center); draw_set_valign(fa_top); draw_set_color(0); -var temp1 = 0; -var xx = __view_get(e__VW.XView, 0) + 0; -var yy = __view_get(e__VW.YView, 0) + 0; -if (loading == 1) { - xx = xx; - yy = yy; -} else if (loading == 1) { - var temp1, dist; - dist = 999; - obj_controller.selecting_planet = 0; - button1 = ""; - button2 = ""; - button3 = ""; - button4 = ""; - - if (instance_exists(target)) { - if (target.space_hulk == 1) { +try{ +var temp1=0; +var xx = 0; +var yy = 0; +if (loading=1){ + xx=xx; + yy=yy; +} else if (loading==1){ + var temp1, dist; + dist=999; + + obj_controller.selecting_planet=0; + button1=""; + button2=""; + button3=""; + button4=""; + + if (instance_exists(target)){ + if (target.space_hulk==1){ pop_draw_return_values(); exit; } } } -if (obj_controller.selecting_planet > target.planets) { +if (obj_controller.selecting_planet>target.planets){ obj_controller.selecting_planet = 0; } -var click_accepted = (!obj_controller.menu) && (!obj_controller.zoomed) && (!instance_exists(obj_bomb_select)) && (!instance_exists(obj_drop_select)); +var click_accepted = (!obj_controller.menu) and (!obj_controller.zoomed) and (!instance_exists(obj_bomb_select)) and (!instance_exists(obj_drop_select)); if (click_accepted && (!debug || !debug_slate.entered())) { - if (mouse_button_clicked(, 0)) { - var closes = 0, sta1 = 0, sta2 = 0; + if (mouse_button_clicked(, 0)){ + var closes=0,sta1=0,sta2=0; var mouse_consts = return_mouse_consts(); - sta1 = instance_nearest(mouse_consts[0], mouse_consts[1], obj_star); - sta2 = point_distance(mouse_consts[0], mouse_consts[1], sta1.x, sta1.y); - closes = true; - if (sta2 > 15) { - if (scr_hit(27, 165, 300, 165 + 294)) { - closes = false; - } else if (obj_controller.selecting_planet > 0) { + sta1=instance_nearest(mouse_consts[0],mouse_consts[1],obj_star); + sta2=point_distance(mouse_consts[0],mouse_consts[1],sta1.x,sta1.y); + closes=true; + if (sta2>15){ + if (scr_hit( + 27, + 165, + 300, + 165+294) + ){ + closes=false + } else if (obj_controller.selecting_planet>0){ closes = !main_data_slate.entered(); - if (closes) { - if (is_struct(garrison) || population) { - closes = !garrison_data_slate.entered(); + if (closes){ + if (is_struct(garrison) || population){ + closes = !garrison_data_slate.entered(); } } - - if (!is_string(feature)) { - if (feature.main_slate.entered()) { - closes = false; + + if (!is_string(feature)){ + if (feature.main_slate.entered()){ + closes=false; } } } var shutter_button; - var shutters = [ - shutter_1, - shutter_2, - shutter_3, - shutter_4 - ]; - for (var i = 0; i < 4; i++) { + var shutters = [shutter_1, shutter_2, shutter_3, shutter_4]; + for (var i=0; i<4;i++){ shutter_button = shutters[i]; - if (shutter_button.hit()) { - closes = false; + if (shutter_button.hit()){ + closes=false; break; } } - if (closes) { - cooldown = 0; - obj_controller.sel_system_x = 0; - obj_controller.sel_system_y = 0; - obj_controller.selecting_planet = 0; - obj_controller.popup = 0; + if (closes){ + cooldown=0; + obj_controller.sel_system_x=0; + obj_controller.sel_system_y=0; + obj_controller.selecting_planet=0; + obj_controller.popup=0; instance_destroy(); } } } } -if ((target.craftworld == 0) && (target.space_hulk == 0)) { - draw_sprite(spr_star_screen, target.planets, 27, 165); -} -if (target.craftworld == 1) { - draw_sprite(spr_star_screen, 5, 27, 165); -} -if (target.space_hulk == 1) { - draw_sprite(spr_star_screen, 6, 27, 165); -} -if ((target.craftworld == 0) && (target.space_hulk == 0)) { - draw_sprite_ext(target.sprite_index, target.image_index, 77, 287, 1.25, 1.25, 0, c_white, 1); +var _standard_star = !target.craftworld && !target.space_hulk; + +if (_standard_star){ + draw_sprite(spr_star_screen,target.planets,27,165); + draw_sprite_ext(target.sprite_index,target.image_index,77,287,1.25,1.25,0,c_white,1); +}else if (target.craftworld){ + draw_sprite(spr_star_screen,5,27,165); +} else if(target.space_hulk){ + draw_sprite_ext(target.sprite_index,target.image_index,77,287,1.25,1.25,0,c_white,1); } var _screen_height = sprite_get_height(spr_star_screen); var _screen_width = sprite_get_width(spr_star_screen); -draw_sprite_ext(spr_servo_left_arm, 0, 27 + _screen_width, 165 + _screen_height / 3, 2, 2, 0, c_white, 1); -draw_sprite_ext(spr_servo_right_arm, 0, 27, 165 + _screen_height / 3, 2, 2, 0, c_white, 1); -draw_sprite_ext(spr_servo_skull_head, 0, 27 + _screen_width / 2, 165, 2, 2, 0, c_white, 1); +//TODO bottle these into a constructor for re-use +draw_sprite_ext(spr_servo_left_arm, 0,27+_screen_width,165+_screen_height/3, 2, 2, 0, c_white, 1); +draw_sprite_ext(spr_servo_right_arm, 0,27,165+_screen_height/3, 2, 2, 0, c_white, 1); +draw_sprite_ext(spr_servo_skull_head, 0,27+_screen_width/2,165, 2, 2, 0, c_white, 1); -var system_string = target.name + " System"; -if (target.owner != 1) { - draw_set_color(0); -} -if (target.owner == eFACTION.PLAYER) { - draw_set_color(c_blue); -} -if ((target.craftworld == 0) && (target.space_hulk == 0)) { - draw_text_transformed(184, 180, system_string, 1, 1, 0); -} +var system_string = $"{target.name} System"; -if ((target.craftworld == 0) && (target.space_hulk == 0)) { +draw_set_color(target.owner == eFACTION.PLAYER ? c_blue : 0); + +if (_standard_star){ + draw_text_transformed(184,180,system_string,1,1,0); draw_set_color(global.star_name_colors[target.owner]); - draw_text_transformed(184, 180, system_string, 1, 1, 0); + draw_text_transformed(184,180,system_string,1,1,0); } -if (global.cheat_debug && obj_controller.selecting_planet && !loading) { + +if (global.cheat_debug && obj_controller.selecting_planet && !loading){ draw_planet_debug_options(); } -if (obj_controller.menu == 0 && !debug) { - if (manage_units_button.draw(has_player_forces)) { - var _viewer = obj_controller.location_viewer; + +if (obj_controller.menu == 0 && !debug){ + if (manage_units_button.draw(has_player_forces)){ + var _viewer = obj_controller.location_viewer _viewer.update_garrison_log(); var _unit_dispersement = _viewer.garrison_log; var _sys_name = target.name; - if (struct_exists(_unit_dispersement, target.name)) { - group_selection(_unit_dispersement[$ _sys_name].units, {purpose: $"{target.name} Management", purpose_code: "manage", number: 0, system: target.id, feature: "none", planet: 0, selections: []}); + if (struct_exists(_unit_dispersement, target.name)){ + group_selection(_unit_dispersement[$ _sys_name].units,{ + purpose:$"{target.name} Management", + purpose_code : "manage", + number:0, + system:target.id, + feature:"none", + planet : 0, + selections : [] + }); instance_destroy(); pop_draw_return_values(); exit; @@ -150,275 +152,249 @@ if (obj_controller.menu == 0 && !debug) { } } -if (loading != 0) { + +if (loading!=0){ draw_set_font(fnt_40k_14); draw_set_color(CM_GREEN_COLOR); - draw_text(184, 202, string_hash_to_newline("Select Destination")); + draw_text(184,202, + "Select Destination"); } + //the draw and click on planets logic -if (!debug) { +if (!debug){ planet_selection_action(); } draw_set_font(fnt_40k_14b); -if (obj_controller.selecting_planet != 0) { - if (p_data.planet != obj_controller.selecting_planet) { - delete p_data; +if (obj_controller.selecting_planet!=0){ + if (p_data.planet != obj_controller.selecting_planet){ p_data = new PlanetData(obj_controller.selecting_planet, target); + target.system_datas[obj_controller.selecting_planet] = p_data; } - // Buttons that are available - if (!buttons_selected) { - if ((obj_controller.faction_status[eFACTION.IMPERIUM] != "War" && p_data.current_owner > 5) || (obj_controller.faction_status[eFACTION.IMPERIUM] == "War" && p_data.at_war(0, 1, 1) && p_data.player_disposition <= 50)) { - var is_enemy = true; +// Buttons that are available + if (!buttons_selected){ + if (obj_controller.faction_status[eFACTION.IMPERIUM] != "War" && p_data.current_owner > 5) || (obj_controller.faction_status[eFACTION.IMPERIUM] == "War" && p_data.at_war(0, 1, 1) && p_data.player_disposition <= 50) { + var is_enemy=true; } else { - var is_enemy = false; + var is_enemy=false; } - if (p_data.planet > 0) { - if (target.present_fleet[1] == 0) /* and (target.p_type[obj_controller.selecting_planet]!="Dead")*/ { - if (p_data.player_forces > 0) { - if (is_enemy) { - button1 = "Attack"; - button2 = "Purge"; + if (p_data.planet>0){ + if (target.present_fleet[1]=0)/* and (target.p_type[obj_controller.selecting_planet]!="Dead")*/{ + if (p_data.player_forces>0){ + if (is_enemy){ + button1="Attack"; + if (p_data.population){ + button2="Purge"; + } } } } - if (target.present_fleet[1] > 0) /* and (target.p_type[obj_controller.selecting_planet]!="Dead")*/ { + if (target.present_fleet[1]>0)/* and (target.p_type[obj_controller.selecting_planet]!="Dead")*/{ if (is_enemy) { - button1 = "Attack"; - button2 = "Raid"; - button3 = "Bombard"; - } else { - button1 = "Attack"; - button2 = "Raid"; - button3 = "Purge"; + button1="Attack"; + button2="Raid"; + button3="Bombard"; } - - if (torpedo > 0) { - var pfleet = instance_nearest(x, y, obj_p_fleet); - if (instance_exists(pfleet) && (point_distance(pfleet.x, pfleet.y, target.x, target.y) <= 40) && (pfleet.action == "")) { - if ((pfleet.capital_number + pfleet.frigate_number > 0) && (button4 == "")) { - button4 = "Cyclonic Torpedo"; - } + else { + button1="Attack"; + button2="Raid"; + if (p_data.population){ + button2="Purge"; + } + } + + if (torpedo>0){ + var pfleet=instance_nearest(x,y,obj_p_fleet); + if (instance_exists(pfleet)) and (point_distance(pfleet.x,pfleet.y,target.x,target.y)<=40) and (pfleet.action=""){ + if (pfleet.capital_number+pfleet.frigate_number>0) and (button4="") then button4="Cyclonic Torpedo"; } } + } } var planet_upgrades = target.p_upgrades[obj_controller.selecting_planet]; - if (((p_data.planet_type == "Dead") || (array_length(p_data.upgrades) > 0)) && ((target.present_fleet[1] > 0) || (target.p_player[obj_controller.selecting_planet] > 0))) { - if ((array_length(p_data.features) == 0) || (array_length(planet_upgrades) > 0)) { + if (((p_data.planet_type=="Dead") or (array_length(p_data.upgrades)>0)) and ((target.present_fleet[1]>0) or (target.p_player[obj_controller.selecting_planet]>0))){ + if (array_length(p_data.features)==0) or (array_length(planet_upgrades)>0){ + chock = !p_data.xenos_and_heretics(); - if (chock == 1) { - if (p_data.has_upgrade(eP_FEATURES.SECRET_BASE)) { - button1 = "Base"; - } else if (p_data.has_upgrade(eP_FEATURES.ARSENAL)) { - button1 = "Arsenal"; - } else if (p_data.has_upgrade(eP_FEATURES.GENE_VAULT)) { - button1 = "Gene-Vault"; - } else if (array_length(p_data.upgrades) == 0) { - button1 = "Build"; + if (chock==1){ + if (p_data.has_upgrade(eP_FEATURES.SECRET_BASE)){ + button1="Base"; + }else if (p_data.has_upgrade(eP_FEATURES.ARSENAL)){ + button1="Arsenal"; + }else if (p_data.has_upgrade(eP_FEATURES.GENE_VAULT)){ + button1="Gene-Vault"; + }else if (array_length(p_data.upgrades)==0){ + button1="Build"; } - if (array_contains(["Build", "Gene-Vault", "Arsenal", "Base"], button1)) { - button2 = ""; - button3 = ""; - button4 = ""; - button5 = ""; + if (array_contains(["Build","Gene-Vault","Arsenal","Base"],button1)){ + button2=""; + button3=""; + button4=""; + button5=""; } } } } - - if (obj_controller.recruiting_worlds_bought > 0 && !p_data.at_war()) { - if (!p_data.has_feature(eP_FEATURES.RECRUITING_WORLD) && p_data.planet_type != "Dead" && !target.space_hulk) { - button4 = "+Recruiting"; + + if (obj_controller.recruiting_worlds_bought>0 && !p_data.at_war()){ + if (!p_data.has_feature(eP_FEATURES.RECRUITING_WORLD) && p_data.planet_type != "Dead" && !target.space_hulk){ + button4="+Recruiting"; } } - if (target.space_hulk) { - if (target.present_fleet[1] > 0) { - button1 = "Raid"; - button2 = "Bombard"; - button3 = ""; - button4 = ""; + if (target.space_hulk){ + if (target.present_fleet[1]>0){ + button1="Raid"; + button2="Bombard"; + button3=""; + button4=""; } } - buttons_selected = true; + buttons_selected=true; } - main_data_slate.inside_method = function() { + main_data_slate.inside_method = function(){ p_data.planet_info_screen(); - }; - var slate_draw_scale = 420 / 850; - if (feature != "") { - if (is_struct(feature)) { - feature.draw_planet_features(344 + main_data_slate.width - 4, 165); - if (feature.remove) { - feature = ""; - } else if (feature.destroy) { + } + var slate_draw_scale = 420/850; + if (feature!=""){ + if (is_struct(feature)){ + feature.draw_planet_features(344+main_data_slate.width-4,165) + if (feature.remove){ + feature=""; + }else if (feature.destroy){ feature = ""; instance_destroy(); pop_draw_return_values(); exit; } } - } else if (garrison != "" && !population) { - if (garrison.garrison_force) { + }else if (garrison!="" && !population){ + if (garrison.garrison_force){ draw_set_font(fnt_40k_14); - if (!garrison.garrison_leader) { - garrison.find_leader(); + if (!garrison.garrison_leader){ + garrison.find_leader() garrison.garrison_disposition_change(target, obj_controller.selecting_planet, true); - garrison_data_slate.sub_title = $"Garrison Leader {garrison.garrison_leader.name_role()}"; + garrison_data_slate.sub_title = $"Garrison Leader {garrison.garrison_leader.name_role()}" garrison_data_slate.body_text = garrison.garrison_report(); } - garrison_data_slate.inside_method = function() { - garrison_data_slate.title = "Garrison Report"; + garrison_data_slate.inside_method=function(){ + garrison_data_slate.title = "Garrison Report" draw_set_color(c_gray); var xx = garrison_data_slate.XX; var yy = garrison_data_slate.YY; var cur_planet = obj_controller.selecting_planet; - var half_way = yy + garrison_data_slate.height / 2; + var half_way = yy+garrison_data_slate.height/2; draw_set_halign(fa_left); - draw_line(xx + 10, half_way, garrison_data_slate.width - 10, half_way); - var defence_data = determine_pdf_defence(target.p_pdf[cur_planet], garrison, target.p_fortified[cur_planet]); + draw_line(xx+10, half_way, garrison_data_slate.width-10, half_way); + var defence_data = determine_pdf_defence(target.p_pdf[cur_planet], garrison,target.p_fortified[cur_planet]); var defence_string = $"Planetary Defence : {defence_data[0]}"; - draw_text(xx + 20, half_way, defence_string); - if (scr_hit(xx + 20, half_way + 10, xx + 20 + string_width(defence_string), half_way + 10 + 20)) { + draw_text(xx+20, half_way, defence_string); + if (scr_hit(xx+20, half_way+10, xx+20+string_width(defence_string), half_way+10+20)){ tooltip_draw(defence_data[1], 400); } - if (garrison.dispo_change != "none") { - if (garrison.dispo_change > 55) { - draw_text(xx + 20, half_way + 30, $"Garrison Disposition Effect : Positive"); - } else if (garrison.dispo_change > 44) { - draw_text(xx + 20, half_way + 30, $"Garrison Disposition Effect : Neutral"); - } else { - draw_text(xx + 20, half_way + 30, $"Garrison Disposition Effect : Negative"); - } - } - }; - garrison_data_slate.draw(340 + main_data_slate.width, 160, 0.6, 0.6); - } - } else if (population) { - garrison_data_slate.title = "Population Report"; - garrison_data_slate.inside_method = function() { - draw_set_color(c_gray); - var xx = garrison_data_slate.XX; - var yy = garrison_data_slate.YY; - var cur_planet = obj_controller.selecting_planet; - var half_way = garrison_data_slate.height / 2; - var spacing_x = 100; - var spacing_y = 65; - draw_set_halign(fa_left); - if (!target.space_hulk) { - if ((obj_controller.faction_status[eFACTION.IMPERIUM] != "War" && p_data.current_owner <= 5) || (obj_controller.faction_status[eFACTION.IMPERIUM] == "War")) { - colonist_button.update({x1: xx + 35, y1: half_way}); - colonist_button.draw(array_length(potential_donors)); - - recruiting_button.update({x1: xx + (spacing_x * 2) + 15, y1: half_way}); - recruiting_button.draw(true); - if (p_data.has_feature(eP_FEATURES.RECRUITING_WORLD)) { - var _recruit_world = p_data.get_features(eP_FEATURES.RECRUITING_WORLD)[0]; - if ((_recruit_world.recruit_type == 0) && (obj_controller.faction_status[p_data.current_owner] != "War" && obj_controller.faction_status[p_data.current_owner] != "Antagonism" || p_data.player_disposition >= 50)) { - draw_text(xx + (spacing_x * 3) + 35, half_way - 20, "Open: Voluntery"); - } else if (_recruit_world.recruit_type == 0 && p_data.player_disposition <= 50) { - draw_text(xx + (spacing_x * 3) + 35, half_way - 20, "Covert: Voluntery"); - } else { - draw_text(xx + (spacing_x * 3) + 35, half_way - 20, "Abduct"); - } - recruitment_type_button.update({x1: xx + (spacing_x * 3) + 35, y1: half_way}); - recruitment_type_button.draw(true); - - draw_text(xx + (spacing_x * 3) - 15, half_way + spacing_y - 20, $"Req:{_recruit_world.recruit_cost * 2}"); - if (_recruit_world.recruit_cost > 0) { - recruitment_costdown_button.update({x1: xx + (spacing_x * 2) + 35, y1: half_way + spacing_y}); - recruitment_costdown_button.draw(true); - } - if (_recruit_world.recruit_cost < 5) { - recruitment_costup_button.update({x1: xx + (spacing_x * 3) + 35, y1: half_way + spacing_y}); - recruitment_costup_button.draw(true); - } + if (garrison.dispo_change!="none"){ + if (garrison.dispo_change>55){ + draw_text(xx+20, half_way+30, $"Garrison Disposition Effect : Positive"); + } else if (garrison.dispo_change>44){ + draw_text(xx+20, half_way+30, $"Garrison Disposition Effect : Neutral"); + } else{ + draw_text(xx+20, half_way+30, $"Garrison Disposition Effect : Negative"); } } } - }; - garrison_data_slate.draw(344 + main_data_slate.width - 4, 160, 0.6, 0.6); - } - if (obj_controller.selecting_planet > 0) { - main_data_slate.draw(344, 160, slate_draw_scale, slate_draw_scale + 0.1); - } - var current_button = ""; - var shutter_x = main_data_slate.XX - 165; - var shutter_y = 296 + 165; - if (!debug) { - if (shutter_1.draw_shutter(shutter_x, shutter_y, button1, 0.5, true)) { - current_button = button1; - } - if (shutter_2.draw_shutter(shutter_x, shutter_y + 47, button2, 0.5, true)) { - current_button = button2; - } - if (shutter_3.draw_shutter(shutter_x, shutter_y + (47 * 2), button3, 0.5, true)) { - current_button = button3; - } - if (shutter_4.draw_shutter(shutter_x, shutter_y + (47 * 3), button4, 0.5, true)) { - current_button = button4; + garrison_data_slate.draw(340+main_data_slate.width, 160, 0.6, 0.6); + + } + } else if (population){ + garrison_data_slate.title = "Population Report"; + garrison_data_slate.inside_method = function(){ + p_data.draw_planet_population_controls(); } + garrison_data_slate.draw(344+main_data_slate.width-4, 160, 0.6, 0.6); + } + if (obj_controller.selecting_planet>0){ + main_data_slate.draw(344,160, slate_draw_scale, slate_draw_scale+0.1); } - if (current_button != "") { - if (array_contains(["Build", "Base", "Arsenal", "Gene-Vault"], current_button)) { - var building = instance_create(x, y, obj_temp_build); - building.target = target; - building.planet = obj_controller.selecting_planet; - if (p_data.has_upgrade(eP_FEATURES.SECRET_BASE)) { - building.lair = 1; - } - if (p_data.has_upgrade(eP_FEATURES.ARSENAL)) { - building.arsenal = 1; - } - if (p_data.has_upgrade(eP_FEATURES.GENE_VAULT)) { - building.gene_vault = 1; - } - obj_controller.temp[104] = string(scr_master_loc()); - obj_controller.menu = 60; - with (obj_star_select) { + var current_button=""; + var shutter_x = main_data_slate.XX-165; + var shutter_y = 296+165; + if (!debug){ + if (shutter_1.draw_shutter(shutter_x, shutter_y, button1, 0.5, true)) then current_button=button1; + if (shutter_2.draw_shutter(shutter_x, shutter_y+47, button2,0.5, true))then current_button=button2; + if (shutter_3.draw_shutter(shutter_x, shutter_y+(47*2), button3,0.5, true))then current_button=button3; + if (shutter_4.draw_shutter(shutter_x, shutter_y+(47*3), button4,0.5, true))then current_button=button4; + } + if (current_button!=""){ + if (array_contains(["Build","Base","Arsenal","Gene-Vault"],current_button)){ + var building=instance_create(x,y,obj_temp_build); + building.target=target; + building.planet=obj_controller.selecting_planet; + building.lair = p_data.has_upgrade(eP_FEATURES.SECRET_BASE); + if (p_data.has_upgrade(eP_FEATURES.ARSENAL)) then building.arsenal=1; + if (p_data.has_upgrade(eP_FEATURES.GENE_VAULT)) then building.gene_vault=1; + obj_controller.temp[104]=string(scr_master_loc()); + obj_controller.menu=60; + with(obj_star_select){ instance_destroy(); } - } else if (current_button == "Raid" && instance_nearest(x, y, obj_p_fleet).acted <= 1) { - instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, planet_number: obj_controller.selecting_planet, sh_target: instance_nearest(x, y, obj_p_fleet), purge: 0}); - } else if (current_button == "Attack") { + }else if (current_button=="Raid" && instance_nearest(x,y,obj_p_fleet).acted<=1){ + instance_create_layer(x, y, layer_get_all()[0], obj_drop_select,{ + p_target:target, + planet_number : obj_controller.selecting_planet, + sh_target:instance_nearest(x,y,obj_p_fleet), + purge:0, + }); + + }else if (current_button=="Attack"){ var _allow_attack = true; - var _targ = !target.present_fleet[1] ? -50 : instance_nearest(x, y, obj_p_fleet); - if (instance_exists(_targ)) { - if (_targ.acted >= 2) { + var _targ = !target.present_fleet[1] ? -50 : instance_nearest(x,y,obj_p_fleet); + if (instance_exists(_targ)){ + if (_targ.acted>=2){ _allow_attack = false; } } - if (_allow_attack) { - instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, planet_number: obj_controller.selecting_planet, attack: true, sh_target: _targ, purge: 0}); - } - } else if (current_button == "Purge") { + if (_allow_attack){ + instance_create_layer(x, y, layer_get_all()[0], obj_drop_select,{ + p_target:target, + planet_number : obj_controller.selecting_planet, + attack :true, + sh_target : _targ, + purge:0, + }); + } + + }else if (current_button=="Purge"){ var _allow_attack = true; - var _targ = !target.present_fleet[1] ? -50 : instance_nearest(x, y, obj_p_fleet); - if (instance_exists(_targ)) { - if (_targ.acted >= 2) { + var _targ = !target.present_fleet[1] ? -50 : instance_nearest(x,y,obj_p_fleet); + if (instance_exists(_targ)){ + if (_targ.acted>=2){ _allow_attack = false; } } - if (_allow_attack) { - instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, purge: 1, planet_number: obj_controller.selecting_planet, sh_target: _targ}); + if (_allow_attack){ + instance_create_layer(x, y, layer_get_all()[0], obj_drop_select,{ + p_target:target, + purge:1, + planet_number : obj_controller.selecting_planet, + sh_target : _targ, + }); } - } else if (current_button == "Bombard") { - instance_create(x, y, obj_bomb_select); - if (instance_exists(obj_bomb_select)) { - obj_bomb_select.p_target = target; - obj_bomb_select.sh_target = instance_nearest(x, y, obj_p_fleet); + + }else if (current_button=="Bombard"){ + instance_create(x,y,obj_bomb_select); + if (instance_exists(obj_bomb_select)){ + obj_bomb_select.p_target=target; + obj_bomb_select.sh_target=instance_nearest(x,y,obj_p_fleet); obj_bomb_select.p_data = p_data; - if (instance_nearest(x, y, obj_p_fleet).acted > 0) { - with (obj_bomb_select) { - instance_destroy(); - } + if (instance_nearest(x,y,obj_p_fleet).acted>0) then with(obj_bomb_select){ + instance_destroy(); } } - } else if (current_button == "+Recruiting") { + }else if (current_button=="+Recruiting"){ if (obj_controller.recruiting_worlds_bought > 0 && p_data.current_owner <= 5 && !p_data.at_war()) { if (!p_data.has_feature(eP_FEATURES.RECRUITING_WORLD)) { if (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") { @@ -446,50 +422,54 @@ if (obj_controller.selecting_planet != 0) { // 135 ; popup? } } - } else if (current_button == "Cyclonic Torpedo") { + }else if (current_button=="Cyclonic Torpedo"){ scr_destroy_planet(2); } - } + } } -if (target != 0) { - if ((player_fleet > 0) && (imperial_fleet + mechanicus_fleet + inquisitor_fleet + eldar_fleet + ork_fleet + tau_fleet + heretic_fleet > 0)) { + +if (target!=0){ + if (player_fleet>0) and (imperial_fleet+mechanicus_fleet+inquisitor_fleet+eldar_fleet+ork_fleet+tau_fleet+heretic_fleet>0){ draw_set_color(0); draw_set_alpha(0.75); - draw_rectangle(37, 413, 270, 452, 0); + draw_rectangle(37,413,270,452,0); draw_set_alpha(1); - + /*draw_set_color(CM_GREEN_COLOR);draw_rectangle(40,247,253,273,1);*/ - + + draw_set_halign(fa_left); - + + draw_set_color(0); draw_set_font(fnt_40k_14b); - draw_text(37, 413, "Select Fleet Combat"); - + draw_text(37,413,"Select Fleet Combat"); + draw_set_color(CM_GREEN_COLOR); draw_set_font(fnt_40k_14b); - draw_text(37.5, 413.5, "Select Fleet Combat"); - - var i, x3, y3; - i = 0; + draw_text(37.5,413.5,"Select Fleet Combat"); + // x3=46;y3=252; - x3 = 49; - y3 = 441; - - repeat (7) { - i += 1; - if (en_fleet[i] > 0) { + var x3=49,y3=441; + + for (var i=1;i<=7;i++){ + if (en_fleet[i]>0){ // draw_sprite_ext(spr_force_icon,en_fleet[i],x3,y3,0.5,0.5,0,c_white,1); - scr_image("ui/force", en_fleet[i], x3 - 16, y3 - 16, 32, 32); - x3 += 64; + scr_image("ui/force",en_fleet[i],x3-16,y3-16,32,32); + x3+=64; } } } } pop_draw_return_values(); +}catch(_exception){ + handle_exception(_exception); + instance_destroy(); +} /* */ + /* */ diff --git a/scripts/__init_global/__init_global.gml b/scripts/__init_global/__init_global.gml index ea1d2ee51..9377550d7 100644 --- a/scripts/__init_global/__init_global.gml +++ b/scripts/__init_global/__init_global.gml @@ -51,5 +51,6 @@ function __init_global() { global.ui_click_lock = false; global.name_generator = new NameGenerator(); global.star_sprites = ds_map_create(); + global.en_fleet_sprites = ds_map_create(); global.base_component_surface = -1; } diff --git a/scripts/ds_map_helpers/ds_map_helpers.gml b/scripts/ds_map_helpers/ds_map_helpers.gml new file mode 100644 index 000000000..50b22b203 --- /dev/null +++ b/scripts/ds_map_helpers/ds_map_helpers.gml @@ -0,0 +1,21 @@ +function empty_ds_map(ds_map_inst){ + var _temp =[]; + ds_map_values_to_array(ds_map_inst,_temp); + + for (var i=0;i -1000 && system.p_owner[planet] != eFACTION.PLAYER) { - // Personal Rule code be doing some interesting things - system.dispo[planet] = -100; // TODO LOW DISPOSITION_REVAMP // Consider revamping the disposition system - } else if (system.dispo[planet] > 100) { - system.dispo[planet] = 100; - } - // +function PlanetData(planet, system) constructor{ +// static large_pop_conversion = 1000000000; - self.planet = planet; self.system = system; - x = system.x; - y = system.y; - player_disposition = system.dispo[planet]; - planet_type = system.p_type[planet]; - operatives = system.p_operatives[planet]; - function add_operatives(new_ops) { + + static refresh_data = function(){ + features = system.p_feature[planet]; + current_owner = system.p_owner[planet]; + origional_owner = system.p_first[planet]; + population = system.p_population[planet]; + max_population = system.p_max_population[planet]; + large_population = system.p_large[planet]; + secondary_population = system.p_pop[planet]; + is_craftworld = system.craftworld; + is_hulk = system.space_hulk; + x = system.x; + y = system.y; + player_disposition = system.dispo[planet]; + planet_type = system.p_type[planet]; + operatives = system.p_operatives[planet]; + pdf = system.p_pdf[planet]; + fortification_level = system.p_fortified[planet]; + star_station = system.p_station[planet]; + pdf_loss_reduction = 0; + + // Whether or not player forces are on the planet + player_forces = system.p_player[planet]; + + defence_lasers = system.p_lasers[planet]; + defence_silos = system.p_silo[planet]; + ground_defences = system.p_defenses[planet]; + upgrades = system.p_upgrades[planet]; + // v how much of a problem they are from 1-5 + planet_forces = array_create(14, 0); + guardsmen = system.p_guardsmen[planet]; + pdf = system.p_pdf[planet]; + + try{ + planet_forces[eFACTION.PLAYER] = player_forces; + + planet_forces[eFACTION.IMPERIUM] = guardsmen; + + planet_forces[eFACTION.ECCLESIARCHY] = system.p_sisters[planet]; + planet_forces[eFACTION.ELDAR] = system.p_eldar[planet]; + planet_forces[eFACTION.ORK] = system.p_orks[planet]; + planet_forces[eFACTION.TAU] = system.p_tau[planet]; + planet_forces[eFACTION.TYRANIDS] = system.p_tyranids[planet]; + planet_forces[eFACTION.CHAOS] = system.p_chaos[planet]+ system.p_demons[planet]; + planet_forces[eFACTION.HERETICS] = system.p_traitors[planet]; + + planet_forces[eFACTION.NECRONS] = system.p_necrons[planet]; + }catch(_exception){ + handle_exception(_exception); + } + + fortification_level = system.p_fortified[planet]; + + is_heretic = system.p_hurssy[planet]; + + heretic_timer = system.p_hurssy_time[planet]; + + secret_corruption = system.p_heresy_secret[planet]; + + corruption = system.p_heresy[planet]; + + population_influences = system.p_influence[planet]; + + raided_this_turn = system.p_raided[planet]; + // + governor = system.p_governor[planet]; + + problems = system.p_problem[planet]; + problems_data = system.p_problem_other_data[planet]; + problem_timers = system.p_timer[planet]; + + deamons = system.p_demons[planet]; + chaos_forces = system.p_chaos[planet]; + + requests_help = system.p_halp[planet]; + + //safeguards // TODO LOW DEBUG_LOGGING // Log when tripped somewhere + //disposition + if (system.dispo[planet] < -100 && system.dispo[planet] > -1000 && system.p_owner[planet] != eFACTION.PLAYER ) { // Personal Rule code be doing some interesting things + system.dispo[planet] = -100; // TODO LOW DISPOSITION_REVAMP // Consider revamping the disposition system + } else if (system.dispo[planet] > 100) { + system.dispo[planet] = 100; + } + + garrisons = system.system_garrison[planet]; + sabatours = system.system_sabatours[planet]; + system.system_datas[planet] = self; + + // current planet heresy + if (population == 0) { + system.p_heresy[planet] = 0; + system.p_heresy_secret[planet] = 0; + for (var i = 0; i < array_length(system.p_influence[planet]); ++i) { + system.p_influence[planet][i] = 0; + } + } + } + + refresh_data(); + + static new_governor = function(){ + + p_governor[planet] = new GovernorProfile(); + governor = p_governor[planet]; + return governor; + } + + static total_corruption = function(){ + return secret_corruption + corruption; + } + + static edit_player_forces = function(val){ + system.p_player[planet]+=val; + player_forces = system.p_player[planet]; + } + + static add_operatives = function(new_ops){ array_push(system.p_operatives[planet], new_ops); operatives = system.p_operatives[planet]; } - features = system.p_feature[planet]; - current_owner = system.p_owner[planet]; - origional_owner = system.p_first[planet]; - population = system.p_population[planet]; - max_population = system.p_max_population[planet]; - large_population = system.p_large[planet]; - secondary_population = system.p_pop[planet]; - is_craftworld = system.craftworld; - is_hulk = system.space_hulk; - - static set_player_disposition = function(new_dispo) { + + + static set_player_disposition = function(new_dispo){ player_disposition = new_dispo; system.dispo[planet] = player_disposition; - }; + } - static owner_faction_disposition = function() { + static collect_planet_group = function(group=SPECIALISTS_STANDARD,opposite=false,search_conditions = {companies:"all"}){ + return(collect_role_group(group,[system.name,planet],opposite,search_conditions)) + } + + static owner_faction_disposition = function(){ return obj_controller.disposition[current_owner]; - }; + } - static set_population = function(new_population) { + static set_population = function(new_population){ population = new_population; system.p_population[planet] = population; - }; + } - static edit_population = function(edit_val) { + static edit_population = function(edit_val){ population = population + edit_val >= 0 ? population + edit_val : 0; system.p_population[planet] = population; - }; + } //assumes a large pop figure and changes down if small pop planet - static population_small_conversion = function(pop_value) { - if (!large_population) { + static population_small_conversion = function(pop_value){ + if (!large_population){ pop_value *= large_pop_conversion; } return pop_value; - }; - - static population_large_conversion = function(pop_value) { - if (large_population) { + } + static population_large_conversion = function(pop_value){ + if (large_population){ pop_value /= large_pop_conversion; } return pop_value; - }; + } + + static end_turn_population_growth = function(){ + if ((population < max_population) && (planet_type != "Dead") && (planet_type != "Craftworld") && (current_owner <= 5) && (planet_forces[eFACTION.HERETICS] == 0) && (planet_forces[eFACTION.TAU] == 0) && (planet_forces[eFACTION.ORK] == 0) && (planet_forces[eFACTION.NECRONS] == 0) && (planet_forces[eFACTION.TYRANIDS] == 0)) { + if (!large_population) { + set_population(round(population * 1.0008)); + } else if (large_population == 1) { + edit_population(choose(0, 0.01)); + } + } + } - static send_colony_ship = function(target, targ_planet, type) { + static alter_influence = function(faction,value){ + adjust_influence(eFACTION.TYRANIDS, -1, planet,system); + population_influences = system.p_influence[planet]; + } + + static send_colony_ship = function(target, targ_planet, type){ new_colony_fleet(system, planet, target, targ_planet, type); - }; + } - static set_new_owner = function(new_owner) { + static set_new_owner = function(new_owner){ system.p_owner[planet] = new_owner; current_owner = new_owner; - }; - - static return_to_first_owner = function(allow_player = false) { - if (!allow_player && origional_owner == eFACTION.PLAYER) { + } + static return_to_first_owner = function(allow_player = false){ + if (!allow_player && origional_owner == eFACTION.PLAYER){ set_new_owner(eFACTION.IMPERIUM); } else { set_new_owner(origional_owner); } - }; + } - static add_disposition = function(alteration) { - var _new_dispo = clamp(player_disposition + alteration, 0, 100); + static add_disposition = function(alteration){ + var _new_dispo = clamp(player_disposition+alteration, 0, 100); player_disposition = _new_dispo; system.dispo[planet] = player_disposition; - }; - static display_population = function() { - if (large_population) { + } + + static display_population = function(){ + if (large_population){ return $"{population} B"; } else { return $"{scr_display_number(population)}"; } - }; + } - static owner_status = function() { + static owner_status = function(){ return obj_controller.faction_status[current_owner]; - }; + } - static at_war = function(imperium = 1, antagonism = 0, war = 1) { - var _at_war = false; + static at_war = function(imperium=1, antagonism=0, war=1){ + var _at_war = false if (imperium) { - if (current_owner > 5) { - _at_war = true; - } + if (current_owner>5) then _at_war=true; } if (antagonism) { - if (owner_status() == "Antagonism") { - _at_war = true; - } + if (owner_status()=="Antagonism") then _at_war=true; } if (war) { - if (owner_status() == "War") { - _at_war = true; - } + if (owner_status()=="War") then _at_war=true; } return _at_war; - }; - - guardsmen = system.p_guardsmen[planet]; + } - static edit_guardsmen = function(edit_val) { + static edit_guardsmen = function(edit_val){ system.p_guardsmen[planet] = max(0, system.p_guardsmen[planet] + edit_val); guardsmen = system.p_guardsmen[planet]; - }; + } - pdf = system.p_pdf[planet]; - fortification_level = system.p_fortified[planet]; + static edit_pdf = function(edit_val){ + system.p_pdf[planet] = max(0, system.p_pdf[planet] + edit_val); + pdf = system.p_pdf[planet]; + } - static alter_fortification = function(alteration) { + static alter_fortification = function(alteration){ system.p_fortified[planet] += alteration; fortification_level = system.p_fortified[planet]; - }; + } - static recruit_pdf = function(percentage_pop) { - var new_pdf = population * (percentage_pop / 100); - edit_population(new_pdf * -1); - if (large_population) { + static recruit_pdf = function(percentage_pop){ + var new_pdf = population * (percentage_pop/100); + edit_population(new_pdf*-1); + if (large_population){ new_pdf *= large_pop_conversion; } pdf += new_pdf; system.p_pdf[planet] = pdf; return new_pdf; - }; - - star_station = system.p_station[planet]; - pdf_loss_reduction = 0; - - // Whether or not player forces are on the planet - player_forces = system.p_player[planet]; - - static edit_player_forces = function(val) { - system.p_player[planet] += val; - player_forces = system.p_player[planet]; - }; - - defence_lasers = system.p_lasers[planet]; - defence_silos = system.p_silo[planet]; - ground_defences = system.p_defenses[planet]; - upgrades = system.p_upgrades[planet]; - // v how much of a problem they are from 1-5 - planet_forces = array_create(14, 0); - - try { - planet_forces[1] = player_forces; - - planet_forces[2] = guardsmen; - - planet_forces[5] = system.p_sisters[planet]; - planet_forces[6] = system.p_eldar[planet]; - planet_forces[7] = system.p_orks[planet]; - planet_forces[8] = system.p_tau[planet]; - planet_forces[9] = system.p_tyranids[planet]; - planet_forces[10] = system.p_traitors[planet]; - planet_forces[11] = system.p_chaos[planet] + system.p_demons[planet]; - - planet_forces[13] = system.p_necrons[planet]; - } catch (_exception) { - handle_exception(_exception); } - static add_forces = function(faction, val) { - var _new_val = planet_forces[faction] + val; - return edit_forces(faction, _new_val); - }; + static add_forces = function(faction, val){ + var _new_val = planet_forces[faction]+val; + return edit_forces(faction,_new_val); + } - static edit_forces = function(faction, val) { - planet_forces[faction] = clamp(val, 0, 12); + static edit_forces = function(faction, val){ + planet_forces[faction] = clamp(val,0,12); var _new_val = planet_forces[faction]; - switch (faction) { + switch (faction){ case eFACTION.ORK: system.p_orks[planet] = _new_val; break; @@ -224,22 +295,25 @@ function PlanetData(planet, system) constructor { break; case eFACTION.ECCLESIARCHY: system.p_sisters[planet] = _new_val; - break; + break; } - return _new_val; - }; + return _new_val + + } + - static assasinate_governor = function(assaination_type, discovery_modifier) { + + static assasinate_governor = function(assaination_type, discovery_modifier){ var randa = roll_dice_chapter(1, 100, "high"); var randa2 = roll_dice(1, 100); //type 1 is install a sympathectic else it's a straight serf installation - if (assaination_type == 1) { + if (assaination_type == 1){ var _discovery_rate = 10; - set_player_disposition(70 + floor(random_range(5, 15)) + 1); - var _text = $"Many of the successors for {name()} are removed or otherwise made indisposed. Your chapter ensures that the new Planetary Governor is sympathetic to your plight and more than willing to heed your advice. A powerful new ally may be in the making."; - scr_event_log("", $"Planetary Governor of {name()} assassinated. A more suitable Governor is installed."); + set_player_disposition(70 + irandom_range(75, 90)); + var _text = $"Many of the successors for {name()} are removed or otherwise made indisposed. Your chapter ensures that the new Planetary Governor is sympathetic to your plight and more than willing to heed your advice. A powerful new ally may be in the making."; + scr_event_log("", $"Planetary Governor of {name()} assassinated. A more suitable Governor is installed."); } else { var _discovery_rate = 25; if (origional_owner != 3) { @@ -251,321 +325,323 @@ function PlanetData(planet, system) constructor { } if (randa2 <= (_discovery_rate * discovery_modifier)) { - if (assaination_type == 1) { + if (assaination_type == 1){ var _duration = ((choose(1, 2, 3, 4, 5, 6) + choose(1, 2, 3, 4, 5, 6)) * 6) + choose(-3, -2, -1, 0, 1, 2, 3); } else { var _duration = (choose(1, 2) * 6) + choose(-3, -2, -1, 0, 1, 2, 3); } - add_event({duration: _duration, e_id: "governor_assassination", variant: assaination_type, system: system.name, planet: planet}); + add_event({ + duration : _duration, + e_id : "governor_assassination", + variant : assaination_type, + system : system.name, + planet : planet, + }); } return _text; - }; - - static grow_ork_forces = function() { + } + static grow_ork_forces = function(){ var contin = 0; - var rando = roll_dice(1, 100); // This part handles the spreading - // if (rando<30){ + var _rando = roll_dice(1,100);// This part handles the spreading + // if (_rando<30){ var _non_deads = planets_without_type("dead", system); var _has_warboss = has_feature(eP_FEATURES.ORKWARBOSS); var _has_stronghold = has_feature(eP_FEATURES.ORKSTRONGHOLD); var _build_ships = false; - if (_has_stronghold) { + if (_has_stronghold){ var _stronghold = get_features(eP_FEATURES.ORKSTRONGHOLD)[0]; } - if (_has_warboss) { + if (_has_warboss){ var _warboss = get_features(eP_FEATURES.ORKWARBOSS)[0]; _warboss.turns_static++; } - if (array_length(_non_deads) > 0 && rando > 40) { + var _roll_num = 100; + if (_has_stronghold){ + _roll_num -= (_has_stronghold + 1) * 3; + } + var _ork_growth = roll_dice_chapter(1, 100, "high"); + success = false; // This part handles the increasing in numbers + + var _ork_growth_threshold = 13; + + if (_has_warboss){ + _ork_growth_threshold *= 2; + } + + var _orks = planet_forces[eFACTION.ORK]; + if ((current_owner == eFACTION.ORK) && (_orks < 5) && (planet_forces[eFACTION.HERETICS] == 0) && (player_forces <= 0 || !is_garrison_force)) { + if ((_orks> 0) && (_ork_growth <= _ork_growth_threshold)) { + if (sabotage_force) { + if (irandom(3) < 2) { + scr_event_log("green", $"sabotage force on {name()} disrupts ork forces", name); + } else { + add_forces(eFACTION.ORK,1); + } + } else { + add_forces(eFACTION.ORK,1); + } + } + } + + if (array_length(_non_deads)>0 && _rando>40){ var _ork_spread_planet = array_random_element(_non_deads); - var _orks = planet_forces[eFACTION.ORK]; + var _orks = planet_forces[eFACTION.ORK] var _ork_target = system.p_orks[_ork_spread_planet]; - var _spread_orks = current_owner == eFACTION.ORK && ((pdf + guardsmen + planet_forces[8] + planet_forces[10] + planet_forces[1]) == 0); - if (_spread_orks) { + var _spread_orks = (current_owner==eFACTION.ORK && ((pdf + guardsmen + planet_forces[8] + planet_forces[10]+planet_forces[1]) == 0 )); + if (_spread_orks){ // determine maximum Ork presence on the source planet var _ork_max = planet_forces[eFACTION.ORK]; - if (_ork_max < 5 && _ork_target < 2) { - system.p_orks[_ork_spread_planet]++; - } - if (_orks > 4 && _ork_target < 3) { + if (_ork_max<5 && _ork_target<2) then system.p_orks[_ork_spread_planet]++; + if (_orks>4 && _ork_target<3){ system.p_orks[_ork_spread_planet]++; - if (_ork_target < 3) { + if (_ork_target<3){ system.p_orks[_ork_spread_planet]++; add_forces(eFACTION.ORK, -1); } } + } } - contin = 0; - rando = roll_dice(1, 100); // This part handles the ship building - if ((population > 0 && pdf == 0 && guardsmen == 0 && planet_forces[10] == 0) && (planet_forces[eFACTION.TAU] == 0)) { - if (!large_population) { - set_population(population * 0.97); - } else { + contin=0; + _rando=roll_dice(1,100);// This part handles the ship building + if (population>0 && pdf==0 && guardsmen==0 && planet_forces[10]==0) and (planet_forces[eFACTION.TAU]==0){ + if (!large_population){ + set_population(population*0.97); + }else { edit_population(-0.01); } - } - - var enemies_present = false; - with (system) { - for (var n = 0; n < array_length(_non_deads); n++) { + + }; + + var enemies_present=false; + with (system){ + for (var n=0;n= 1) && ((p_pdf[plan] > 0) || (p_guardsmen[plan] > 0) || (p_traitors[plan] > 0) || (p_tau[plan] > 0))) { - enemies_present = true; + if (planets>=1) and ((p_pdf[plan]>0) or (p_guardsmen[plan]>0) or (p_traitors[plan]>0) or (p_tau[plan]>0)){ + enemies_present=true; } } } - if (_has_warboss && !_has_stronghold) { - rando = roll_dice_chapter(1, 100, "low"); - if (rando < 30) { + if (_has_warboss && !_has_stronghold){ + _rando=roll_dice_chapter(1,100, "low"); + if (_rando<30){ add_feature(eP_FEATURES.ORKSTRONGHOLD); } } else { - if (_has_stronghold) { + if (_has_stronghold){ growth = 0.01; - if (_has_warboss) { + if (_has_warboss){ growth *= 2; } - if (_stronghold.tier < planet_forces[eFACTION.ORK]) { + if (_stronghold.tier 0) { - rando -= 10; - } // Empire bonus, was 15 before - + if (obj_controller.known[eFACTION.ORK]>0) then _rando-=10;// Empire bonus, was 15 before + // Check for industrial facilities - var fleet_buildable = (planet_type != "Dead" && planet_type != "Lava") || _has_warboss || _has_stronghold; - if (fleet_buildable && planet_forces[eFACTION.ORK] >= 4) { - // Used to not have Ice either + var fleet_buildable = ((planet_type!="Dead" && planet_type!="Lava") || _has_warboss || _has_stronghold); + if (fleet_buildable && planet_forces[eFACTION.ORK]>=4){// Used to not have Ice either - if (instance_exists(obj_p_fleet)) { - var ppp = instance_nearest(x, y, obj_p_fleet); - if ((point_distance(x, y, ppp.x, ppp.y) < 50) && (ppp.action == "")) { + if (instance_exists(obj_p_fleet)){ + var ppp=instance_nearest(x,y,obj_p_fleet); + if (point_distance(x,y,ppp.x,ppp.y)<50) and (ppp.action=""){ exit; - } + }; } - if (planet_type == "Forge") { - rando -= 80; - } else if (planet_type == "Hive" || planet_type == "Temperate") { - rando -= 30; - } else if (planet_type == "Agri") { - rando -= 10; + if (planet_type == "Forge"){ + _rando-=80; + } else if (planet_type == "Hive" || planet_type == "Temperate"){ + _rando-=30; + }else if (planet_type == "Agri"){ + _rando-=10; } - var _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); - if (_ork_fleet == "none") { - if (rando <= 20) { - new_ork_fleet(x, y); + var _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); + if (_ork_fleet=="none"){ + if (_rando<=20){ + new_ork_fleet(x,y); } } else { + _build_ships = true; - } - } + + } + } } - if (_build_ships) { + if (_build_ships){ var _pdata = self; - with (_ork_fleet) { - // Increase ship number for this object? - var rando = irandom(101); - if (obj_controller.known[eFACTION.ORK] > 0) { - rando -= 10; - } + with (_ork_fleet){ + // Increase ship number for this object? + var _rando=irandom(101); + if (obj_controller.known[eFACTION.ORK]>0) then _rando-=10; var _planet_type = _pdata.planet_type; - if (_planet_type == "Forge") { - rando -= 20; - } else if (_planet_type == "Hive") { - rando -= 10; - } else if (_planet_type == "Shrine" || _planet_type == "Temperate") { - rando -= 5; + if (_planet_type=="Forge"){ + _rando-=20; + } else if (_planet_type=="Hive"){ + _rando-=10; + }else if (_planet_type=="Shrine" || _planet_type=="Temperate"){ + _rando-=5; } - if (rando <= 15) { - // was 25 - rando = choose(1, 1, 1, 1, 1, 1, 1, 2, 2, 2); - var _big_stronghold = false; - if (_has_stronghold) { - if (_stronghold.tier >= 2) { + if (_rando<=15){// was 25 + _rando=choose(1,1,1,1,1,1,1,2,2,2); + var _big_stronghold = false + if (_has_stronghold){ + if (_stronghold.tier>=2){ _big_stronghold = true; } } - if (_planet_type == "Forge" || _big_stronghold || _has_warboss) { - if (!irandom(10)) { - rando = 3; + if (_planet_type=="Forge" || _big_stronghold || _has_warboss){ + if (!irandom(10)){ + _rando = 3; } - } else if (_has_stronghold || _planet_type == "Hive") { - if (!irandom(30)) { - rando = 3; + }else if (_has_stronghold || _planet_type=="Hive"){ + if (!irandom(30)){ + _rando = 3; } } - if (capital_number <= 0) { - rando = 3; + if (capital_number<=0){ + _rando = 3; } - switch (rando) { + switch(_rando){ case 3: - capital_number += 1; + capital_number+=1; break; case 2: - frigate_number += 1; + frigate_number+=1; break; case 1: - escort_number += 1; + escort_number+=1; break; + } } - var ii = 0; - ii += capital_number; - ii += round((frigate_number / 2)); - ii += round((escort_number / 4)); - if (ii <= 1) { - ii = 1; - } - image_index = ii; + var ii=round(standard_fleet_strength_calc()); + if (ii<=1) then ii=1; + image_index=ii; //if big enough flee bugger off to new star - if (image_index >= 5) { + if (image_index>=5){ instance_deactivate_object(_pdata.system); - with (obj_star) { - if (is_dead_star()) { + with(obj_star){ + if (is_dead_star()){ instance_deactivate_object(id); } else { - if (owner == eFACTION.ORK || array_contains(p_owner, eFACTION.ORK)) { + if (owner == eFACTION.ORK || array_contains(p_owner, eFACTION.ORK)){ instance_deactivate_object(id); - } + } } } - var new_wagh_star = instance_nearest(x, y, obj_star); - if (instance_exists(new_wagh_star)) { - action_x = new_wagh_star.x; - action_y = new_wagh_star.y; + var new_wagh_star = instance_nearest(x,y,obj_star); + if (instance_exists(new_wagh_star)){ + action_x=new_wagh_star.x; + action_y=new_wagh_star.y; action = ""; set_fleet_movement(); } + } instance_activate_object(obj_star); } } - if (_has_warboss) { - rando = roll_dice(1, 100) + 10; + if (_has_warboss){ + _rando=roll_dice(1,100)+10; var _ork_fleet = scr_orbiting_fleet(eFACTION.ORK, system); - if (_ork_fleet != "none" && rando < _warboss.turns_static) { + if (_ork_fleet!="none" && _rando < _warboss.turns_static){ _warboss.turns_static = 0; _ork_fleet.cargo_data.ork_warboss = _warboss; delete_feature(eP_FEATURES.ORKWARBOSS); - if (!_warboss.player_hidden || !irandom(5)) { - scr_alert("red", "ork", $"{_warboss.name} departs {name()} as his waaagh gains momentum", 0, 0); + if (!_warboss.player_hidden || !irandom(5)){ + scr_alert("red","ork",$"{_warboss.name} departs {name()} as his waaagh gains momentum",0,0); } } } - }; - - deamons = system.p_demons[planet]; - chaos_forces = system.p_chaos[planet]; - - requests_help = system.p_halp[planet]; - - // current planet heresy - if (population == 0) { - system.p_heresy[planet] = 0; - system.p_heresy_secret[planet] = 0; - for (var i = 0; i < array_length(system.p_influence[planet]); ++i) { - system.p_influence[planet][i] = 0; - } + } - corruption = system.p_heresy[planet]; - - static alter_corruption = function(value) { + static alter_corruption = function(value){ alter_planet_corruption(value, planet, system); corruption = system.p_heresy[planet]; - }; - - is_heretic = system.p_hurssy[planet]; - - heretic_timer = system.p_hurssy_time[planet]; - - secret_corruption = system.p_heresy_secret[planet]; - - population_influences = system.p_influence[planet]; - - raided_this_turn = system.p_raided[planet]; - // - governor = system.p_governor[planet]; + } - problems = system.p_problem[planet]; - problems_data = system.p_problem_other_data[planet]; - problem_timers = system.p_timer[planet]; + static set_corruption = function(value){ + system.p_heresy[planet] = value; + corruption = system.p_heresy[planet]; + } - static has_problem = function(problem) { + static has_problem = function(problem){ has_problem_planet(planet, problem, system); - }; - - static remove_problem = function(problem) { - remove_planet_problem(planet, problem, system); - }; + } - static find_problem = function(problem) { + static remove_problem = function(problem){ + remove_planet_problem(planet ,problem,system) + } + static find_problem = function(problem){ return find_problem_planet(planet, problem, system); - }; + } - static add_problem = function(problem, timer, other_data = {}) { - return add_new_problem(planet, problem, timer, system, other_data); - }; + static add_problem = function(problem, timer, other_data={}){ + return add_new_problem(planet, problem, timer,system, other_data); + } - static name = function() { - var _name = ""; - _name = planet_numeral_name(planet, system); + static name = function(){ + var _name=""; + + _name = planet_numeral_name(planet, system); return _name; - }; + } - static xenos_and_heretics = function() { + static xenos_and_heretics = function(){ var xh_force = 0; - for (var i = 5; i < array_length(planet_forces); i++) { + for (var i=5;i 0){ + if (_priests.number == _techmarines.number){ + text = "Without any technical staff wholly loyal to the chapter the Tech Priests Quickly set to Work sequestering any valuable resources for the Omnissiah."; + text += "By the time you have begun working in earnest your forces become aware that the Tech Priests have already catalogued any and all items of interest and begun transmitting their findings to the mechanicus."; + text += "\n\nThere is nothing that can easily be done"; + scr_popup("Mars Control", text, "mechanicus"); + } else { + text = "After Unloading Marines too site it becomes clear there is discontent among the group.\n"; + text = "A contingent of the force comprised of Techpriests are unhappy with the decision too take all of the items aboard the chapter ships without cataloguing the information for their Forge Worlds.\n"; + scr_popup("Conflict of Interest", text, ) + } + } + } + + + } + + + static recover_starship = function(techs){ try { var engineer_count = array_length(techs); - if (has_feature(eP_FEATURES.STARSHIP) && engineer_count > 0) { + if (has_feature(eP_FEATURES.STARSHIP) && engineer_count>0){ //TODO allow total tech point usage here var _starship = get_features(eP_FEATURES.STARSHIP)[0]; var _engineer_score_start = _starship.engineer_score; - if (_starship.engineer_score < 2000) { - for (var v = 0; v < engineer_count; v++) { - _starship.engineer_score += techs[v].technology / 2; + if (_starship.engineer_score<2000){ + for (var v=0;v 0 && _starship.funds_spent < _target_spend) { - scr_alert("green", "owner", $"{_requisition_spend} Requision spent on Ancient Ship repairs in materials and outfitting (outfitting {(_starship.funds_spent / _target_spend) * 100}%)", system.x, system.y); + var _maxr=floor(obj_controller.requisition/50); + var _requisition_spend=min(_maxr*50,array_length(techs)*50,_target_spend-_starship.funds_spent); + obj_controller.requisition-=_requisition_spend; + _starship.funds_spent+=_requisition_spend; + + if (_requisition_spend>0 && _starship.funds_spent<_target_spend){ + scr_alert("green","owner",$"{_requisition_spend} Requisition spent on Ancient Ship repairs in materials and outfitting (outfitting {(_starship.funds_spent/_target_spend)*100}%)",system.x,system.y); } - if (_starship.funds_spent >= _target_spend && _starship.engineer_score >= 2000) { - // u2=tar; + if (_starship.funds_spent>=_target_spend && _starship.engineer_score>=2000){// u2=tar; //TODO refactor into general new ship logic delete_feature(eP_FEATURES.STARSHIP); - - var locy = $"{name()}"; - - var flit = instance_create(system.x, system.y, obj_p_fleet); - + + var locy=$"{name()}"; + + var flit=instance_create(system.x,system.y,obj_p_fleet); + var _slaughter = new_player_ship("Gloriana", system.name, "Slaughtersong"); add_ship_to_fleet(_slaughter, flit); flit.oribiting = system.id; - - scr_popup($"Ancient Ship Restored", $"The ancient ship within the ruins of {locy} has been fully repaired. It is determined to be a Gloriana Class vessel and is bristling with golden age weaponry and armour. Your {string(obj_ini.role[100][16])}s are excited; the Slaughtersong is ready for it's maiden voyage, at your command.", "", ""); + + scr_popup($"Ancient Ship Restored",$"The ancient ship within the ruins of {locy} has been fully repaired. It is determined to be a Gloriana Class vessel and is bristling with golden age weaponry and armour. Your {string(obj_ini.role[100][16])}s are excited; the Slaughtersong is ready for it's maiden voyage, at your command.","",""); } - } - } catch (_exception) { + } + }catch (_exception){ handle_exception(_exception); } - }; + } - static guard_score_calc = function() { + static guard_score_calc = function(){ guard_score = 0; - if (guardsmen < 500 && guardsmen > 0) { + if (guardsmen < 500 && guardsmen>0) { guard_score = 0.1; } else if (guardsmen >= 100000000) { guard_score = 7; @@ -669,382 +787,361 @@ function PlanetData(planet, system) constructor { } return guard_score; - }; + } + + static continue_to_planet_battle = function(stop){ - static continue_to_planet_battle = function(stop) { var _nids_real = planet_forces[eFACTION.TYRANIDS]; var _nids_score = _nids_real < 4 ? 0 : _nids_real; - var _nid_diff = _nids_score - _nids_real; + var _nid_diff = _nids_score-_nids_real; - if ((chaos_forces == 6.1) && (_nids_real > 0)) { - tyranids_score = _nids_real; - } + if (chaos_forces==6.1) and (_nids_real>0) then tyranids_score=_nids_real; - if (current_owner == eFACTION.TAU) { + if (current_owner == eFACTION.TAU){ stop = (xenos_and_heretics() + _nid_diff + player_forces + planet_forces[eFACTION.ECCLESIARCHY]) <= 0; } - - if (stop) { - if ((planet_forces[eFACTION.ORK] > 0) && (planet_forces[eFACTION.ECCLESIARCHY] > 0)) { - stop = 0; - } + + if (stop){ + if (planet_forces[eFACTION.ORK]>0) and (planet_forces[eFACTION.ECCLESIARCHY]>0) then stop=0; } - var imperium_forces = (guardsmen > 0) || (pdf > 0) || (planet_forces[eFACTION.ECCLESIARCHY] > 0); + var imperium_forces = ((guardsmen>0) or (pdf>0) or (planet_forces[eFACTION.ECCLESIARCHY]>0)); - if (stop) { - if (planet_forces[eFACTION.NECRONS] >= 5 || planet_forces[eFACTION.TYRANIDS] >= 5 && imperium_forces) { - stop = 0; - } + if (stop){ + if (planet_forces[eFACTION.NECRONS]>=5 || planet_forces[eFACTION.TYRANIDS]>=5 && imperium_forces) then stop=0; } + //tau fight imperial - if (stop) { - if (current_owner == eFACTION.TAU) { - if (((guardsmen > 0) || (planet_forces[eFACTION.ECCLESIARCHY] > 0)) && ((pdf > 0) || (planet_forces[eFACTION.TAU] > 0))) { - stop = 0; - } + if (stop){ + if (current_owner = eFACTION.TAU){ + if ((guardsmen>0) or (planet_forces[eFACTION.ECCLESIARCHY]>0)) and ((pdf>0) or (planet_forces[eFACTION.TAU]>0)) then stop=0; } + } - + // Attack heretics whenever possible, even player controlled ones - if (stop) { - if ((player_forces + pdf > 0) && (guardsmen > 0) && (obj_controller.faction_status[2] == "War")) { - stop = 0; - } + if (stop){ + if (player_forces+pdf>0) and (guardsmen>0) and (obj_controller.faction_status[2]="War") then stop=0; } - if (stop) { - if ((player_forces + pdf > 0) && (planet_forces[eFACTION.ECCLESIARCHY] > 0) && (obj_controller.faction_status[5] == "War")) { - stop = 0; - } + if (stop){ + if (player_forces+pdf>0) and (planet_forces[eFACTION.ECCLESIARCHY]>0) and (obj_controller.faction_status[5]="War") then stop=0; } return stop; - }; + } - static pdf_will_support_player = function() { - if (current_owner == eFACTION.TAU) { + static pdf_will_support_player = function(){ + if (current_owner== eFACTION.TAU){ return false; } - if (has_feature(eP_FEATURES.GENE_STEALER_CULT) && current_owner == eFACTION.TYRANIDS) { + if (has_feature(eP_FEATURES.GENE_STEALER_CULT) && current_owner==eFACTION.TYRANIDS){ return false; } - if ((current_owner == 1 || obj_controller.faction_status[2] != "War") && pdf) { + if ((current_owner=1 || obj_controller.faction_status[2]!="War") && pdf){ return true; } return false; - }; + } - static guard_attack_matrix = function() { + static guard_attack_matrix = function(){ var guard_attack = ""; // if (p_eldar[planet]>0) and (p_owner[planet]!=6) then guard_attack="eldar"; //if (planet_forces[eFACTION.TAU] + planet_forces[eFACTION.ORK] + planet_forces[eFACTION.HERETICS]+ planet_forces[eFACTION.CHAOS]) - if (planet_forces[eFACTION.TAU] > 0) { - guard_attack = "tau"; - } - if (planet_forces[eFACTION.ORK] > 0) { - guard_attack = "ork"; - } - if (planet_forces[eFACTION.HERETICS] > 0) { - // Always goes after traitors first, unless - guard_attack = "traitors"; - if ((planet_forces[eFACTION.HERETICS] <= 1 && planet_forces[eFACTION.TAU] >= 4) && (current_owner != 8)) { - guard_attack = "tau"; - } - } - if (planet_forces[eFACTION.CHAOS] > 0) { - guard_attack = "csm"; - } - if ((pdf > 0) && (current_owner == eFACTION.TAU)) { - guard_attack = "pdf"; + if (planet_forces[eFACTION.TAU]>0) then guard_attack="tau"; + if (planet_forces[eFACTION.ORK]>0) then guard_attack="ork"; + if (planet_forces[eFACTION.HERETICS]>0){ + // Always goes after traitors first, unless + guard_attack="traitors"; + if (planet_forces[eFACTION.HERETICS]<=1 && planet_forces[eFACTION.TAU]>=4) and (current_owner!=8) then guard_attack="tau"; } + if (planet_forces[eFACTION.CHAOS]>0) then guard_attack="csm"; + if (pdf>0) and (current_owner=eFACTION.TAU) then guard_attack="pdf"; - if (current_owner == eFACTION.PLAYER) { - if (pdf > 0 && obj_controller.faction_status[2] == "War") { - guard_attack = "pdf"; - } - } - if ((planet_forces[eFACTION.TYRANIDS] <= 1) && (planet_forces[eFACTION.ORK] >= 4)) { - guard_attack = "ork"; + if (current_owner = eFACTION.PLAYER){ + if (pdf>0 && obj_controller.faction_status[2]=="War") then guard_attack="pdf"; } + if (planet_forces[eFACTION.TYRANIDS]<=1) and (planet_forces[eFACTION.ORK]>=4) then guard_attack="ork"; // if (p_tyranids[planet]>0) and (guard_attack="") then guard_attack="tyranids"; - if (planet_forces[eFACTION.TYRANIDS] >= 4) { - guard_attack = "tyranids"; - } else if (planet_forces[eFACTION.TYRANIDS] > 0) { - if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + if (planet_forces[eFACTION.TYRANIDS]>=4){ + guard_attack="tyranids"; + }else if (planet_forces[eFACTION.TYRANIDS]>0){ + if (has_feature(eP_FEATURES.GENE_STEALER_CULT)){ var _hidden_cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0].hiding; - if (!_hidden_cult) { - guard_attack = "tyranids"; - } else if (population_influences[eFACTION.TYRANIDS] >= 50) { - guard_attack = "pdf"; + if (!_hidden_cult){ + guard_attack="tyranids"; + }else if (population_influences[eFACTION.TYRANIDS]>=50){ + guard_attack="pdf"; } } else { - guard_attack = "tyranids"; + guard_attack="tyranids"; } - } else if (population_influences[eFACTION.TYRANIDS] >= 50) { - guard_attack = "pdf"; - } + } else if (population_influences[eFACTION.TYRANIDS]>=50){ + guard_attack="pdf"; + } + + return guard_attack; + } - return guard_attack; - }; - static pdf_attack_matrix = function() { - var _no_notable_traitors = planet_forces[eFACTION.HERETICS] <= 1; + static pdf_attack_matrix = function(){ + var _no_notable_traitors = planet_forces[eFACTION.HERETICS]<=1; var _pdf_attack = ""; - if (planet_forces[eFACTION.TYRANIDS] >= 4 && !has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + if (planet_forces[eFACTION.TYRANIDS]>=4 && !has_feature(eP_FEATURES.GENE_STEALER_CULT)){ _pdf_attack = "tyranids"; } - if (_no_notable_traitors && _pdf_attack == "") { - if (planet_forces[eFACTION.ORK] >= 4) { - _pdf_attack = "ork"; - } else if (planet_forces[eFACTION.TAU] >= 4 && current_owner != 8) { - _pdf_attack = "tau"; + if (_no_notable_traitors && _pdf_attack=="") { + if ((planet_forces[eFACTION.ORK]>=4)){ + _pdf_attack="ork"; + } else if (planet_forces[eFACTION.TAU]>=4 && current_owner!=8){ + _pdf_attack="tau"; } - } - if (guardsmen && _pdf_attack == "") { - if (obj_controller.faction_status[2] == "War") { - if (pdf_will_support_player()) { - _pdf_attack = "guard"; + } + if (guardsmen && _pdf_attack==""){ + if (obj_controller.faction_status[2]=="War"){ + if (pdf_will_support_player()){ + _pdf_attack="guard"; } - } else if (current_owner == eFACTION.TAU) { - _pdf_attack = "guard"; - } else if (has_feature(eP_FEATURES.GENE_STEALER_CULT) && population_influences[eFACTION.TYRANIDS] >= 50) { - _pdf_attack = "guard"; + } else if (current_owner == eFACTION.TAU){ + _pdf_attack="guard"; + }else if (has_feature(eP_FEATURES.GENE_STEALER_CULT) && population_influences[eFACTION.TYRANIDS]>=50){ + _pdf_attack="guard"; } } - if (_pdf_attack == "") { - if (planet_forces[eFACTION.CHAOS] > 0) { - _pdf_attack = "csm"; - } else if (planet_forces[eFACTION.HERETICS] > 0) { - _pdf_attack = "traitors"; - } else if (planet_forces[eFACTION.ORK] > 0) { - _pdf_attack = "ork"; - } else if ((planet_forces[eFACTION.TAU] > 0) && (current_owner != eFACTION.TAU)) { - _pdf_attack = "tau"; + if (_pdf_attack==""){ + if (planet_forces[eFACTION.CHAOS]>0){ + _pdf_attack="csm"; + } else if (planet_forces[eFACTION.HERETICS]>0){ + _pdf_attack="traitors"; + } else if ((planet_forces[eFACTION.ORK]>0)){ + _pdf_attack="ork"; + } else if (planet_forces[eFACTION.TAU]>0) and (current_owner!=eFACTION.TAU){ + _pdf_attack="tau"; } } // Always goes after traitors first, unless - return _pdf_attack; - }; + return _pdf_attack; + } - static pdf_loss_reduction_calc = function() { - pdf_loss_reduction = fortification_level * 0.001; - if (pdf_will_support_player()) { - pdf_loss_reduction += garrison.viable_garrison * 0.0005; + static pdf_loss_reduction_calc = function(){ + pdf_loss_reduction = fortification_level*0.001; + if (pdf_will_support_player()){ + pdf_loss_reduction+=garrisons.viable_garrison*0.0005; } return pdf_loss_reduction; - }; + } - static pdf_defence_loss_to_orks = function() { - var active_garrison = pdf_will_support_player() && garrison.viable_garrison > 0; - if ((planet_forces[eFACTION.ORK] >= 4) && (pdf >= 30000)) { - pdf = floor(pdf * min(0.95, 0.55 + pdf_loss_reduction)); - } else if (planet_forces[eFACTION.ORK] >= 4 && pdf < 30000 && pdf >= 10000) { - pdf = active_garrison ? pdf * 0.4 : 0; - } else if ((planet_forces[eFACTION.ORK] >= 3) && (pdf < 10000)) { - pdf = active_garrison ? pdf * 0.4 : 0; - } else if (planet_forces[eFACTION.ORK] < 3 && pdf > 30000) { - pdf = floor(pdf * min(0.95, 0.7 + pdf_loss_reduction)); + static pdf_defence_loss_to_orks = function(){ + var active_garrison = pdf_will_support_player() && garrisons.viable_garrison>0; + if (planet_forces[eFACTION.ORK]>=4) and (pdf>=30000){ + pdf=floor(pdf*(min(0.95, 0.55+pdf_loss_reduction))); + } + else if (planet_forces[eFACTION.ORK]>=4 && pdf<30000 && pdf>=10000){ + pdf=active_garrison?pdf*0.4:0; } - if ((planet_forces[eFACTION.ORK] >= 2) && (pdf < 2000)) { - pdf = 0; + else if (planet_forces[eFACTION.ORK]>=3) and (pdf<10000){ + pdf=active_garrison?pdf*0.4:0; } - if ((planet_forces[eFACTION.ORK] >= 1) && (pdf < 200)) { - pdf = 0; + else if (planet_forces[eFACTION.ORK]<3 && pdf>30000){ + pdf=floor(pdf*(min(0.95, 0.7+pdf_loss_reduction))); } + if (planet_forces[eFACTION.ORK]>=2) and (pdf<2000){ pdf=0;} + if (planet_forces[eFACTION.ORK]>=1) and (pdf<200){ pdf=0;} system.p_pdf[planet] = pdf; - }; + } + - static planet_info_screen = function() { - if (!instance_exists(obj_star_select)) { + static planet_info_screen = function(){ + if (!instance_exists(obj_star_select)){ exit; } - var improve = 0; - var xx = 15; - var yy = 25; - var current_planet = planet; - var nm = scr_roman(current_planet), temp1 = 0; + var improve=0 + var xx=15; + var yy=25; + var current_planet=planet; + var temp1=0; draw_set_halign(fa_center); draw_set_valign(fa_top); draw_set_font(fnt_40k_14); - + var _xenos_and_heretics = xenos_and_heretics(); - if ((current_owner <= 5) && (!_xenos_and_heretics)) { - if (planet_forces[eFACTION.PLAYER] > 0 || system.present_fleet[1] > 0) { - if (fortification_level < 5) { - improve = 1; - } + if (current_owner<=5) and (!_xenos_and_heretics){ + if (planet_forces[eFACTION.PLAYER]>0||system.present_fleet[1]>0){ + if (fortification_level<5) then improve=1; } } - + // Draw disposition here - var yyy = 0; + var yyy=0; var _succession = has_problem("succession"); - if ((player_disposition >= 0 && current_owner <= 5 && population > 0) && (_succession == 0)) { - var wack = 0; + if ((player_disposition>=0 && current_owner<=5 && population>0)) and (_succession=0){ + var wack=0; draw_set_color(c_blue); - draw_rectangle(xx + 349, yy + 175, xx + 349 + (min(100, player_disposition) * 3.68), yy + 192, 0); + draw_rectangle(xx+349,yy+175,xx+349+(min(100,player_disposition)*3.68),yy+192,0); } draw_set_color(c_gray); - draw_rectangle(xx + 349, yy + 175, xx + 717, yy + 192, 1); + draw_rectangle(xx+349,yy+175,xx+717,yy+192,1); draw_set_color(c_white); - if (!_succession) { - if ((player_disposition >= 0) && (origional_owner <= 5) && (current_owner <= 5) && (population > 0)) { - draw_text(xx + 534, yy + 176, "Disposition: " + string(min(100, player_disposition)) + "/100"); + + if (!_succession){ + if (player_disposition>=0) and (origional_owner<=5) and (current_owner<=5) and (population>0){ + draw_text(xx+534,yy+176,"Disposition: "+string(min(100,player_disposition))+"/100"); } - if ((player_disposition > -30) && (player_disposition < 0) && (current_owner <= 5) && (population > 0)) { - draw_text(xx + 534, yy + 176, "Disposition: ???/100"); + if (player_disposition>-30) and (player_disposition<0) and (current_owner<=5) and (population>0){ + draw_text(xx+534,yy+176,"Disposition: ???/100"); } - if (((player_disposition >= 0) && (origional_owner <= 5) && (current_owner > 5)) || (population <= 0)) { - draw_text(xx + 534, yy + 176, "-------------"); + if ((player_disposition>=0) and (origional_owner<=5) and (current_owner>5)) or (population<=0){ + draw_text(xx+534,yy+176,"-------------"); } - if (player_disposition <= -3000) { - draw_text(xx + 534, yy + 176, "Disposition: N/A"); - } - } else if (_succession) { - draw_text(xx + 534, yy + 176, "War of _Succession"); + if (player_disposition<=-3000) then draw_text(xx+534,yy+176,"Disposition: N/A"); + } else if (_succession){ + draw_text(xx+534,yy+176,"War of _Succession"); } draw_set_color(c_gray); // End draw disposition draw_set_color(c_gray); - draw_rectangle(xx + 349, yy + 193, xx + 717, yy + 210, 0); - var bar_width = 717 - 349; - var bar_start_point = xx + 349; - var bar_percent_length = bar_width / 100; + draw_rectangle(xx+349,yy+193,xx+717,yy+210,0); + var bar_width = 717-349; + var bar_start_point = xx+349; + var bar_percent_length = (bar_width/100); var current_bar_percent = 0; - var hidden_cult = false; - if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - hidden_cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0].hiding; - } - - for (var i = 1; i < 13; i++) { - if (population_influences[i] > 0) { + var _hidden_cult = false; + if (has_feature(eP_FEATURES.GENE_STEALER_CULT)){ + _hidden_cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0].hiding; + } + + for (var i=1;i<13;i++){ + if (population_influences[i]>0){ draw_set_color(global.star_name_colors[i]); - if (hidden_cult) { + if (_hidden_cult && i == eFACTION.TYRANIDS){ draw_set_color(global.star_name_colors[eFACTION.IMPERIUM]); } - var current_start = bar_start_point + (current_bar_percent * bar_percent_length); - draw_rectangle(current_start, yy + 193, current_start + (bar_percent_length * population_influences[i]), yy + 210, 0); - current_bar_percent += population_influences[i]; + var current_start = bar_start_point+(current_bar_percent*bar_percent_length) + draw_rectangle(current_start,yy+193,current_start+(bar_percent_length*population_influences[i]),yy+210,0); + current_bar_percent+=population_influences[i]; } draw_set_color(c_gray); } - draw_set_color(c_white); - draw_text(xx + 534, yy + 194, "Population Influence"); - yy += 20; + draw_set_color(c_white); + draw_text(xx+534,yy+194,"Population Influence"); + yy+=20; draw_set_font(fnt_40k_14b); draw_set_halign(fa_left); - if (!is_craftworld && !is_hulk) { - draw_text(xx + 480, yy + 196, $"{system.name} {nm} ({planet_type})"); + if (!is_craftworld && !is_hulk){ + draw_text(xx+480,yy+196,$"{name()} ({planet_type})"); } - if (is_craftworld) { - draw_text(xx + 480, yy + 196, string(system.name) + " (Craftworld)"); + else if (is_craftworld){ + draw_text(xx+480,yy+196,$"{system.name} (Craftworld)"); + } else if (is_hulk){ + draw_text(xx+480,yy+196,"Space Hulk"); } // if (is_craftworld=0) and (is_hulk=0) then draw_text(xx+534,yy+214,string(planet_type)+" World"); // if (is_craftworld=1) then draw_text(xx+594,yy+214,"Craftworld"); - if (is_hulk) { - draw_text(xx + 480, yy + 196, "Space Hulk"); - } - + // draw_sprite(spr_planet_splash,temp1,xx+349,yy+194); - scr_image("ui/planet", scr_planet_image_numbers(planet_type), xx + 349, yy + 194, 128, 128); - draw_rectangle(xx + 349, yy + 194, xx + 477, yy + 322, 1); + scr_image("ui/planet",scr_planet_image_numbers(planet_type),xx+349,yy+194,128,128); + draw_rectangle(xx+349,yy+194,xx+477,yy+322,1); draw_set_font(fnt_40k_14); - + var pop_string = $"Population: {display_population()}"; + var _button_manager = obj_star_select.button_manager; - _button_manager.update({label: pop_string, tooltip: "population data toggle with 'P'", keystroke: press_exclusive(ord("P")), x1: xx + 480, y1: yy + 217, w: 200, h: 22}); + _button_manager.update({ + label:pop_string, + tooltip : "population data toggle with 'P'", + keystroke : press_exclusive(ord("P")), + x1 : xx+480, + y1 : yy+217, + w : 200, + h : 22 + }); _button_manager.update_loc(); - if (_button_manager.draw()) { + if (_button_manager.draw()){ obj_star_select.population = !obj_star_select.population; - if (obj_star_select.population) { - obj_star_select.potential_donors = find_population_doners(system.id); + if (obj_star_select.population){ + obj_star_select.potential_donors = find_population_donors(system.id); } } - if ((is_craftworld == 0) && (is_hulk == 0)) { - var y7 = 240, temp3 = string(scr_display_number(guardsmen)); - if (guardsmen > 0) { - draw_text(xx + 480, yy + y7, $"Imperial Guard: {temp3}"); - y7 += 20; + + if (is_craftworld=0) and (is_hulk=0){ + var y7=240,_guard_force=string(scr_display_number(guardsmen)); + if (guardsmen>0){ + draw_text(xx+480,yy+y7,$"Imperial Guard: {_guard_force}"); + y7+=20; } - var temp4 = string(scr_display_number(pdf)); - if (current_owner != 8) { - draw_text(xx + 480, yy + y7, $"Defense Force: {temp4}"); + var _pdf_force =string(scr_display_number(pdf)); + if (current_owner!=8){ + draw_text(xx+480,yy+y7,$"Defense Force: {_pdf_force}"); } - if (current_owner == 8) { - draw_text(xx + 480, yy + y7, $"Gue'Vesa Force: {temp4}"); + if (current_owner=8){ + draw_text(xx+480,yy+y7,$"Gue'Vesa Force: {_pdf_force}"); } } - - var temp5 = ""; - - if (!is_hulk) { - if (improve == 1) { + + var temp5=""; + + + if (!is_hulk){ + if (improve){ draw_set_color(c_green); - draw_rectangle(xx + 481, yy + 280, xx + 716, yy + 298, 0); - draw_sprite(spr_requisition, 0, xx + 657, yy + 283); - - var improve_cost = 1500, yep = 0, o = 0; - - if (scr_has_adv("Siege Masters")) { - improve_cost = 1100; + draw_rectangle(xx+481,yy+280,xx+716,yy+298,0); + draw_sprite(spr_requisition,0,xx+657,yy+283); + + + var improve_cost=1500,yep=0,o=0; + + if (scr_has_adv("Siege Masters")){ + improve_cost=1100; } - - draw_text_glow(xx + 671, yy + 281, improve_cost, 16291875, 0); - - if (scr_hit(xx + 481, yy + 282, xx + 716, yy + 300)) { + + draw_text_glow(xx+671, yy+281,improve_cost,16291875,0); + + if (scr_hit(xx+481,yy+282,xx+716,yy+300)){ draw_set_color(0); draw_set_alpha(0.2); - draw_rectangle(xx + 481, yy + 280, xx + 716, yy + 298, 0); - if (mouse_button_clicked() && (obj_controller.requisition >= improve_cost)) { - obj_controller.requisition -= improve_cost; + draw_rectangle(xx+481,yy+280,xx+716,yy+298,0); + if (mouse_button_clicked() && obj_controller.requisition >= improve_cost){ + obj_controller.requisition-=improve_cost; alter_fortification(1); - - if ((player_disposition > 0) && (player_disposition <= 100)) { - add_disposition(9 - fortification_level); + + if (player_disposition>0) and (player_disposition<=100){ + add_disposition(9-fortification_level); } } + } draw_set_alpha(1); draw_set_color(0); } - var forti_string = [ - "None", - "Sparse", - "Light", - "Moderate", - "Heavy", - "Major", - "Extreme" - ]; + var forti_string = ["None", "Sparse","Light","Moderate","Heavy","Major","Extreme"]; var planet_forti = $"Defenses: {forti_string[fortification_level]}"; - draw_text(xx + 480, yy + 280, planet_forti); + draw_text(xx+480,yy+280,planet_forti); } - + draw_set_color(c_gray); - - if (is_hulk == 1) { - temp5 = "Integrity: " + string(floor(fortification_level * 20)) + "%"; - draw_text(xx + 480, yy + 280, temp5); + + if (is_hulk=1){ + temp5="Integrity: "+string(floor(fortification_level*20))+"%"; + draw_text(xx+480,yy+280,temp5); } - - var temp6 = "???"; - var target_planet_heresy = corruption; + + var temp6="???"; + var target_planet_heresy=corruption; if (target_planet_heresy < 0) { - temp6 = "DEBUG: Heresy below 0!"; + temp6 = "DEBUG: Heresy below 0!" } else if (target_planet_heresy <= 10) { temp6 = "None"; } else if (target_planet_heresy <= 30) { @@ -1060,46 +1157,23 @@ function PlanetData(planet, system) constructor { } else if (target_planet_heresy > 100) { temp6 = "DEBUG: Heresy above 100!"; } else { - temp6 = "DEBUG: Heresy somehow unknown value!"; + temp6 = "DEBUG: Heresy somehow unknown value!" } - draw_text(xx + 480, yy + 300, $"Corruption: {temp6}"); - + draw_text(xx+480,yy+300,$"Corruption: {temp6}"); + + draw_set_font(fnt_40k_14b); - draw_text(xx + 349, yy + 326, "Planetary Presence"); - draw_text(xx + 535, yy + 326, "Planetary Features"); + draw_text(xx+349,yy+326,"Planetary Presence"); + draw_text(xx+535,yy+326,"Planetary Features"); draw_set_font(fnt_40k_14); - + + var presence_text = ""; - var faction_names = [ - "Adeptas", - "Orks", - "Tau", - "Tyranids", - "Chaos", - "Traitors", - "Daemons", - "Necrons" - ]; - var faction_ids = [ - "p_sisters", - "p_orks", - "p_tau", - "p_tyranids", - "p_traitors", - "p_chaos", - "p_demons", - "p_necrons" - ]; - var blurbs = [ - "Minima", - "Parvus", - "Moderatus", - "Significus", - "Enormicus", - "Extremis" - ]; - + var faction_names = ["Adeptas", "Orks", "Tau", "Tyranids", "Chaos", "Traitors", "Daemons", "Necrons"]; + var faction_ids = ["p_sisters", "p_orks", "p_tau", "p_tyranids", "p_traitors", "p_chaos", "p_demons", "p_necrons"]; + var blurbs = ["Minima", "Parvus", "Moderatus", "Significus", "Enormicus", "Extremis"]; + for (var t = 0; t < array_length(faction_names); t++) { var faction = faction_names[t]; var faction_id = faction_ids[t]; @@ -1122,24 +1196,21 @@ function PlanetData(planet, system) constructor { } } - draw_text(xx + 349, yy + 346, string_hash_to_newline(string(presence_text))); + draw_text(xx+349,yy+346,string_hash_to_newline(string(presence_text))); + + + var to_show=0,temp9="";t=-1; - var to_show = 0, temp9 = ""; - t = -1; - var fit = array_create(11, ""); + //TODO makeeverything below calculated once and OOP + var fit = array_create(11, ""); var planet_displays = [], i; var feat_count, _cur_feature; var feat_count = array_length(features); var upgrade_count = array_length(upgrades); - var size = [ - "", - "Small", - "", - "Large" - ]; - if (feat_count > 0) { - for (i = 0; i < feat_count; i++) { + var size = ["", "Small", "", "Large"]; + if ( feat_count > 0){ + for (i =0; i < feat_count ;i++){ var cur_feature = features[i]; try { if (cur_feature.planet_display != 0) { @@ -1159,34 +1230,32 @@ function PlanetData(planet, system) constructor { array_push(planet_displays, [size_string, forge]); } } - } + } } catch (_exception) { LOGGER.error(cur_feature); handle_exception(_exception); } } } - if (upgrade_count > 0) { - for (i = 0; i < upgrade_count; i++) { + if (upgrade_count>0){ + for (i =0; i < upgrade_count ;i++){ var _upgrade = upgrades[i]; - if (_upgrade.f_type == eP_FEATURES.SECRET_BASE) { - if (_upgrade.forge > 0) { + if (_upgrade.f_type == eP_FEATURES.SECRET_BASE){ + if (_upgrade.forge>0){ var forge = _upgrade.forge_data; - var size_string = $"{size[forge.size]} Chapter Forge"; + var size_string= $"{size[forge.size]} Chapter Forge" array_push(planet_displays, [size_string, forge]); } } } } - for (i = 0; i < array_length(problems); i++) { - if (problems[i] == "") { - continue; - } - var problem_data = problems_data[i]; - if (struct_exists(problem_data, "stage")) { - if (problem_data.stage == "preliminary") { - var mission_string = $"{problem_data.applicant} Audience"; + for (i=0;i 0) { - var current_planet = planet; + if (planet>0){ + var current_planet=planet; draw_set_color(c_black); draw_set_halign(fa_center); - + /*if (obj_controller.recruiting_worlds_bought>0) and (system.p_owner[planet]<=5) and (obj_controller.faction_status[system.p_owner[planet]]!="War"){ if (string_count("Recr",system.p_feature[planet])=0){ button4="+Recruiting"; } }*/ - + /*if (origional_owner=1){ if (mouse_x>=xx+363) and (mouse_y>=yy+194) and (mouse_x0){ @@ -1238,83 +1305,141 @@ function PlanetData(planet, system) constructor { } } }*/ + } + } + + static draw_planet_population_controls = function(){ + draw_set_color(c_gray); + var _gar_slate = obj_star_select.garrison_data_slate; + var xx = _gar_slate.XX; + var yy = _gar_slate.YY; + var _half_way = _gar_slate.height/2; + var spacing_x = 100 + var spacing_y = 65 + draw_set_halign(fa_left); + if (!target.space_hulk) { + if (obj_controller.faction_status[eFACTION.IMPERIUM] != "War" && current_owner <= 5) || (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") { + colonist_button.update({ + x1:xx+35, + y1:_half_way, + }); + colonist_button.draw(array_length(potential_donors)); + + recruiting_button.update({ + x1:xx+(spacing_x*2)+15, + y1:_half_way, + allow_click : true, + }); + recruiting_button.draw(); + if (has_feature(eP_FEATURES.RECRUITING_WORLD)) { + var _recruit_world = get_features(eP_FEATURES.RECRUITING_WORLD)[0]; + if (_recruit_world.recruit_type == 0) && (obj_controller.faction_status[current_owner] != "War" && obj_controller.faction_status[p_data.current_owner] != "Antagonism" || p_data.player_disposition >= 50) { + draw_text(xx+(spacing_x*3)+35, _half_way-20, "Open: Voluntery"); + } else if (_recruit_world.recruit_type == 0 && player_disposition <= 50) { + draw_text(xx+(spacing_x*3)+35, _half_way-20, "Covert: Voluntery"); + } else { + draw_text(xx+(spacing_x*3)+35, _half_way-20, "Abduct"); + } + recruitment_type_button.update({ + x1:xx+(spacing_x*3)+35, + y1:_half_way, + allow_click : true, + }); + recruitment_type_button.draw(true); + + draw_text(xx+(spacing_x*3)-15, _half_way+(spacing_y)-20, $"Req:{_recruit_world.recruit_cost * 2}"); + if (_recruit_world.recruit_cost > 0) { + recruitment_costdown_button.update({ + x1:xx+(spacing_x*2)+35, + y1:_half_way+(spacing_y), + allow_click : true, + }); + recruitment_costdown_button.draw(true); + } + if (_recruit_world.recruit_cost < 5) { + recruitment_costup_button.update({ + x1:xx+(spacing_x*3)+35, + y1:_half_way+(spacing_y), + allow_click : true, + }); + recruitment_costup_button.draw(true); + } + } + } } - }; + } - static suffer_navy_bombard = function(strength) { + static suffer_navy_bombard = function(strength){ + + var kill = 0; // Eh heh heh - if (planet_forces[eFACTION.TYRANIDS] > 0) { - strength = strength > 2 ? 2 : 0; - system.p_tyranids[planet] -= 2; - } else if (planet_forces[eFACTION.ORK] > 0) { - if (strength > 2) { - strength = 2; - } - if (strength < 1) { - strength = 0; - } - system.p_orks[planet] -= 2; - } else if ((current_owner == eFACTION.TAU) && (planet_forces[eFACTION.TAU] > 0)) { - strength = strength > 2 ? 2 : 0; - system.p_tau[planet] -= 2; - - kill = large_population ? strength * 0.15 : strength * 15000000; - } else if ((current_owner == 8) && (pdf > 0)) { - system.p_pdf[planet] -= strength * (irandom_range(49, 51) * 100000); - if (pdf < 0) { - system.p_pdf[planet] = 0; - } - - kill = large_population ? strength * 0.15 : strength * 15000000; - } else if (current_owner == 10) { - strength = strength > 2 ? 2 : 0; - - if (system.p_chaos[planet] > 0) { - system.p_chaos[planet] = max(0, system.p_traitors[planet] - 1); - } else if (system.p_traitors[planet] > 0) { - system.p_traitors[planet] = max(0, system.p_traitors[planet] - 2); + if (planet_forces[eFACTION.TYRANIDS]>0){ + strength = strength>2 ? 2 : 0; + system.p_tyranids[planet]-=2; + } + else if (planet_forces[eFACTION.ORK]>0){ + if (strength>2) then strength=2; + if (strength<1) then strength=0; + system.p_orks[planet]-=2; + } + else if (current_owner=eFACTION.TAU) and (planet_forces[eFACTION.TAU]>0){ + strength = strength>2 ? 2 : 0; + system.p_tau[planet]-=2; + + kill = large_population ? strength*0.15 : strength*15000000 + } + else if (current_owner=8) and (pdf>0){ + + edit_pdf(-strength*(irandom_range(49, 51) * 100000)); + + kill = large_population ? strength*0.15 : strength*15000000 + } + else if (current_owner=10){ + + strength = strength>2 ? 2 : 0; + + if (system.p_chaos[planet]>0){ + system.p_chaos[planet]=max(0,system.p_traitors[planet]-1); + } else if (system.p_traitors[planet]>0){ + system.p_traitors[planet]=max(0,system.p_traitors[planet]-2); } kill = strength * population_small_conversion(0.15); - if (system.p_heresy[planet] > 0) { - system.p_heresy[planet] = max(0, system.p_heresy[planet] - 5); - } + if (system.p_heresy[planet]>0) then system.p_heresy[planet]=max(0,system.p_heresy[planet]-5); } var _pop_percentage_kill = population > 0 ? (kill / population) * 100 : 0; - edit_population(kill * -1); - if (system.p_pdf[planet] < 0) { - system.p_pdf[planet] = 0; - } - if (population_influences[eFACTION.TYRANIDS] > 3) { - var _max_influence_reduction = min(_pop_percentage_kill, population_influences[eFACTION.TYRANIDS] - 3); - adjust_influence(eFACTION.TYRANIDS, -_max_influence_reduction, planet, system); - if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - if (population_influences[eFACTION.TYRANIDS] < 20) { + edit_population(kill*-1); + + if (population_influences[eFACTION.TYRANIDS] > 3){ + var _max_influence_reduction = min(_pop_percentage_kill,population_influences[eFACTION.TYRANIDS]-3); + alter_influence(eFACTION.TYRANIDS,-_max_influence_reduction); + if (has_feature(eP_FEATURES.GENE_STEALER_CULT)){ + if (population_influences[eFACTION.TYRANIDS]<20){ delete_feature(eP_FEATURES.GENE_STEALER_CULT); } } } - - if ((population + pdf <= 0) && (current_owner == 1) && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War")) { - if (!has_feature(eP_FEATURES.MONASTERY)) { - current_owner = 2; + + if (population + pdf<=0) and (current_owner=1) and (obj_controller.faction_status[eFACTION.IMPERIUM]="War"){ + if (!has_feature(eP_FEATURES.MONASTERY)){ + set_new_owner(eFACTION.IMPERIUM); add_disposition(-50); } - } - }; + } + } - static create_planet_garrison = function() { + static create_planet_garrison = function(){ var company_data = obj_controller.company_data; var _squad_id = company_data.company_squads[company_data.cur_squad]; var current_squad = fetch_squad(_squad_id); current_squad.set_location(system.name, 0, planet); var _mission = obj_star_select.mission; - current_squad.assignment = { - type: _mission, - location: system.name, - ident: planet, + current_squad.assignment={ + type:_mission, + location:system.name, + ident:planet, }; var operation_data = { type: "squad", @@ -1323,74 +1448,591 @@ function PlanetData(planet, system) constructor { task_time: 0, }; add_operatives(operation_data); - system.garrison = true; + system.garrisons = true; - //if there was an outstanding mission to provide the given garrison + //if there was an outstanding mission to provide the given garrisons var garrison_request = find_problem("provide_garrison"); - if (garrison_request > -1) { + if (garrison_request>-1){ init_garrison_mission(planet, system, garrison_request); } instance_destroy(obj_star_select); - }; + } + - static planet_selection_logic = function() { + static planet_selection_logic = function(){ var planet_is_allies = scr_is_planet_owned_by_allies(system, planet); - var garrison_issue = !planet_is_allies || pdf <= 0; - var _mission = variable_instance_exists(obj_star_select, "mission") ? obj_star_select.mission : ""; + var garrison_issue = (!planet_is_allies || pdf<=0); + var _mission = variable_instance_exists(obj_star_select,"mission") ? obj_star_select.mission : ""; - var _loading = obj_star_select.loading; + var _loading = obj_star_select.loading; var garrison_assignment = obj_controller.view_squad && _loading; - if (garrison_assignment && (garrison_issue && _mission == "garrison")) { + if (garrison_assignment && (garrison_issue && _mission=="garrisons")){ planet_draw = c_red; - tooltip_draw("Can't garrison on non-friendly planet or planet with no friendly PDF", 150); + tooltip_draw("Can't garrisons on non-friendly planet or planet with no friendly PDF", 150); } - if (mouse_check_button_pressed(mb_left)) { - if (garrison_assignment) { - if (!(garrison_issue && _mission == "garrison")) { + if (mouse_check_button_pressed(mb_left)){ + if (garrison_assignment){ + if (!(garrison_issue && _mission=="garrisons")){ create_planet_garrison(); exit; } - } else if (!_loading) { - garrison = new GarrisonForce(operatives); - system.garrison = garrison.garrison_force; - feature = ""; - buttons_selected = false; - } else if (_loading && planet > 0) { - obj_controller.unload = planet; - obj_controller.return_object = system; - obj_controller.return_size = obj_controller.man_size; - edit_player_forces(obj_controller.man_size); - + } else if (!_loading){ + garrisons.update(operatives); + system.garrisons = garrisons.garrison_force; + feature=""; + buttons_selected=false; + } else if (_loading && planet >0){ + + obj_controller.unload=planet; + obj_controller.return_object=system; + obj_controller.return_size=obj_controller.man_size; + edit_player_forces(obj_controller.man_size) + // 135 ; SPECIAL PLANET CRAP HERE - + // Recon Stuff - if (has_problem("recon")) { - var arti = instance_create(system.x, system.y, obj_temp7); // Unloading / artifact crap + if (has_problem("recon")){ + var arti=instance_create(system.x,system.y,obj_temp7);// Unloading / artifact crap - arti.num = planet; - arti.alarm[0] = 1; - arti.loc = obj_controller.selecting_location; - arti.managing = obj_controller.managing; - arti.type = "recon"; + arti.num=planet; + arti.alarm[0]=1; + arti.loc=obj_controller.selecting_location; + arti.managing=obj_controller.managing; + arti.type="recon"; - with (arti) { - setup_planet_mission_group(); + with (arti){ + setup_planet_mission_group() } } - if (!instance_exists(obj_ground_mission)) { + if (!instance_exists(obj_ground_mission)){ check_for_artifact_grab_mission(); - } - if (!instance_exists(obj_ground_mission)) { check_for_stc_grab_mission(); - } - // Ancient Ruins - if (!instance_exists(obj_ground_mission)) { - scr_check_for_ruins_exploration(); - } + scr_check_for_ruins_exploration(); + } instance_destroy(obj_star_select); exit; + } + + } + } + + static end_of_turn_population_influence_and_enemy_growth = function(){ + + sabotage_force = sabatours.garrison_force; + total_garrison = garrisons.total_garrison; + is_garrison_force = garrisons.garrison_force; + + // Orks grow in number + + end_turn_population_growth(); + + // increasing necrons + if (array_length(features) != 0) { + var has_awake_tomb = false, + nfleet = 0; + if (awake_tomb_world(features) == 1) { + has_awake_tomb = true; + } + if (has_awake_tomb) { + if (planet_forces[eFACTION.NECRONS] < 3) { + planet_forces[eFACTION.NECRONS] += 2; + } else if (planet_forces[eFACTION.NECRONS] < 6) { + planet_forces[eFACTION.NECRONS] += 1; + } + } + if (sabotage_force && irandom(2) < 2) { + planet_forces[eFACTION.NECRONS]--; + scr_event_log("green", $"sabotage force on {name()} disrupts necron forces", name); + } + + if (has_awake_tomb) { + // Necron fleets, woooo + //necrons kill populatin + if ((population > 0) && (player_forces + pdf + guardsmen + planet_forces[eFACTION.TYRANIDS] == 0)) { + population = population * 0.75; + if ((large_population == 0) && (population <= 5000)) { + population = 0; + } + } + + var fleet_spawn_chance = roll_dice_chapter(1, 100, "high"); + onceh = 0; + + if (fleet_spawn_chance <= 15) { + if (system.present_fleet[eFACTION.NECRONS] > 0) { + //if necron fleet + necron_fleet = instance_nearest(x, y, obj_en_fleet); + + if (necron_fleet.owner == eFACTION.NECRONS) { + if (necron_fleet.escort_number < necron_fleet.capital_number * 1.5) { + necron_fleet.escort_number += 2; + } else if (necron_fleet.frigate_number < necron_fleet.capital_number * 3) { + necron_fleet.frigate_number += 1; + } else { + necron_fleet.capital_number += 1; + } + } + } else if (system.present_fleet[eFACTION.NECRONS] == 0) { + necron_fleet = instance_create(x, y, obj_en_fleet); + necron_fleet.owner = eFACTION.NECRONS; + necron_fleet.capital_number = 1; + necron_fleet.sprite_index = spr_fleet_necron; + necron_fleet.image_speed = 0; + necron_fleet.image_index = 1; + system.present_fleet[eFACTION.NECRONS] += 1; + } + var enemy_fleets = 0; + with(necron_fleet) { + if (owner == eFACTION.NECRONS) { + var ii = 0; + ii += capital_number; + ii += round((frigate_number / 2)); + ii += round((escort_number / 4)); + if (ii <= 1) { + ii = 1; + } // image_index=max(8,round(ii)); + + if ((ii >= 7) && (capital_number > 1)) { + for (var fleet_n = 1; fleet_n <= 10; fleet_n++) { + if (orbiting.present_fleet[fleet_n] > 0) { + enemy_fleets++; + } + } + } + } + } + if (enemy_fleets > 0) { + var necron_fleet2; + necron_fleet2 = instance_create(x, y, obj_en_fleet); + necron_fleet2.owner = eFACTION.NECRONS; + necron_fleet2.sprite_index = spr_fleet_necron; + // necron_fleet2.image_index=0; + necron_fleet.image_speed = 0; + necron_fleet2.capital_number = 1; + necron_fleet2.frigate_number = round(necron_fleet.frigate_number / 2); + necron_fleet2.escort_number = round(necron_fleet.escort_number / 2); + system.present_fleet[eFACTION.NECRONS] += 1; + + necron_fleet.capital_number -= 1; + necron_fleet.frigate_number -= necron_fleet2.frigate_number; + necron_fleet.escort_number -= necron_fleet2.escort_number; + var nearest_planet_coords = [0, 0]; + var found_near_planet = false; + with(obj_star) { + if (present_fleet[eFACTION.NECRONS] == 0) { + if (!array_contains(p_type, "Dead")) { + for (var plan = 1; plan <= planets; plan++) { + if (p_owner[plan] <= 5) { + found_near_planet = true; + nearest_planet_coords = [x, y]; + break; + } + } + } + } + } + + if (found_near_planet) { + var tgt1, tgt2; + + necron_fleet2.action_x = nearest_planet_coords[0]; + necron_fleet2.action_y = nearest_planet_coords[1]; + with (necron_fleet2){ + set_fleet_movement(); + } + } + } + } } } - }; + + end_turn_heretics_and_corruption_growth(); + + end_turn_genestealer_cults(); + + + // Spread influence on controlled sector + if ((planet_type != "Space Hulk") && (planet_type != "Dead")) { + if ((corruption < 70 && current_owner == 10)) { + if (current_owner == 10){ + alter_corruption(2); + } + + } + if (current_owner == eFACTION.TAU && population_influences[eFACTION.TYRANIDS]<70){ + var _influ_chance = roll_dice(1,100); + if (_influ_chance <= 5 && population_influences[eFACTION.TYRANIDS]>=20){ + alter_influence(eFACTION.TAU, 1); + } + } + + if (planet_type == "Daemon"){ + if (pdf > 0) { + pdf = 0; + } + if (guardsmen > 0) { + guardsmen = 0; + } + } + + } + + } + + + static end_turn_genestealer_cults = function(){ + // Genestealer cults grow in number + if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; + cult.cult_age++; + alter_influence(eFACTION.TYRANIDS, cult.cult_age / 100); + var planet_garrison = garrisons; + if (cult.hiding) { + var find_nid_chance = 50 - planet_garrison.total_garrison; + if (population_influences[eFACTION.TYRANIDS] > 50) { + var find_cult_chance = irandom(50); + var alert_text = $"A hidden Genestealer Cult on {name()} Has suddenly burst forth from hiding!"; + if (planet_garrison.garrison_force) { + var alert_text = $"A hidden Genestealer Cult on {name()} Has been discovered by marine garrisons!"; + find_cult_chance -= 25; + } + if (find_cult_chance < 1) { + cult.hiding = false; + scr_popup("System Lost", alert_text, "Genestealer Cult", ""); + set_new_owner(eFACTION.TYRANIDS); + scr_event_log("red", $"A hidden Genestealer Cult on {name()} has Started a revolt.", system.name); + edit_forces(eFACTION.TYRANIDS,1); + } + } + } + var _nids = planet_forces[eFACTION.TYRANIDS]; + if ((!cult.hiding) && (_nids <= 3) && (planet_type != "Space Hulk") && (population_influences[eFACTION.TYRANIDS] > 10)) { + var spread = 0; + var _rando = irandom(150); + _rando -= population_influences[eFACTION.TYRANIDS]; + if (_rando <= 15) { + spread = 1; + } + + if ((planet_type == "Lava") && (_nids >= 2)) { + spread = 0; + } + if (((planet_type == "Ice") || (planet_type == "Desert")) && (_nids >= 3)) { + spread = 0; + } + + if (spread == 1) { + add_forces(eFACTION.TYRANIDS, 1); + } + } + if (population_influences[eFACTION.TYRANIDS] > 55) { + set_new_owner(eFACTION.TYRANIDS); + } + } else if (population_influences[eFACTION.TYRANIDS] > 5) { + alter_influence(eFACTION.TYRANIDS, -1); + if ((irandom(200) + (population_influences[eFACTION.TYRANIDS] / 10)) > 195) { + add_feature(eP_FEATURES.GENE_STEALER_CULT); + } + } + } + + static end_turn_heretics_and_corruption_growth = function(){ + // traitors cults + var notixt; + var is_ork; + notixt = false; + + var _rando = roll_dice(1,100); + + if ((current_owner == eFACTION.CHAOS) && (corruption < 80)) { + alter_corruption(1); + } + + if ((current_owner != eFACTION.CHAOS) && (current_owner != eFACTION.HERETICS) && (current_owner != eFACTION.ELDAR) && (planet_type != "Dead") && (planet_type != "Craftworld")) { + success = false; + is_ork = current_owner == eFACTION.ORK; + + if (!is_ork) { + //made a linear function for this while here...now the minimum for the roll is a bit higher, but + var score_to_beat = (3 / 4) * (corruption + secret_corruption) - 27.5; + + //if (corruption+secret_corruption>=25) and (_rando<=3) then success=true; + //if (corruption+secret_corruption>=50) and (_rando<=10) then success=true; + //if (corruption+secret_corruption>=70) and (_rando<=25) then success=true; + //if (corruption+secret_corruption>=90) and (_rando<=40) then success=true; + if (_rando < score_to_beat) { + success = true; + } + } + + if (success && (pdf == 0) && (guardsmen == 0) && (planet_forces[eFACTION.TAU] == 0) && (planet_forces[eFACTION.ORK] == 0)) { + current_owner = 10; + scr_alert("red", "owner", $"{name()} has fallen to heretics!", x, y); + + if (system.visited == 1) { + //visited variable check whether the star has been visited or not 1 for true 0 for false + if (planet_type == "Forge") { + add_disposition(-10); + // 10 disposition decreases for the respective planet + obj_controller.disposition[3] -= 3; // 10 disposition decrease for the toaster Fetishest since they aren't that numerous + } else if (has_feature(eP_FEATURES.SORORITAS_CATHEDRAL) || (planet_type == "Shrine")) { + add_disposition(-4); // similarly 10 disposition decrease, note those nurses are a bit pissy and + // and you can't easily gain their favor because you cannot ask them to "step down" from office. + obj_controller.disposition[5] -= 5; + } else { + // the missus diplomacy 0 is when they cringe when you enter the office and cannot ask them for a date. + } + } + } + + if (success && (planet_type != "Space Hulk")) { + _rando = roll_dice(1,100); + // // // obj_controller.x=self.x;obj_controller.y=self.y; + if (is_garrison_force) { + _rando -= total_garrison; + } + + var tixt = ""; + + // controls losing pdf due to heretic cults + var traitor_mod = 0; + + if (_rando <= 40) { + notixt = true; + var garrison_mod = choose(0.05, 0.1, 0.15, 0.2); + + if (is_garrison_force) { + garrison_mod -= 0.01 * total_garrison; + } + + if (garrison_mod > 0) { + var lost = floor(pdf * garrison_mod); + + if (pdf <= 500) { + lost = pdf ; + edit_forces(eFACTION.HERETICS, 1); + } + + edit_pdf(-lost); + + if (planet_forces[eFACTION.HERETICS] == 0) { + if (pdf > 0) { + tixt = $"{scr_display_number(lost)} PDF killed in a rebellion on {name()}."; + } else if (pdf == 0) { + tixt = $"Heretic cults have appeared in {name()}."; + } + + scr_alert("purple", "owner", tixt, x, y); + scr_event_log("purple", tixt, system.name); + } + } else { + tixt = $"Marine garrisons prevents rebellion on {name()}"; + scr_alert("green", "owner", tixt, x, y); + scr_event_log("green", tixt, system.name); + corruption -= irandom(5); + } + // Cult crushed; don't bother showing if there's already fighting going on over there + } else if ((_rando >= 41) && (_rando < 81) && (planet_forces[eFACTION.HERETICS] < 2)) { + if (is_garrison_force) { + traitor_mod = choose(1, 2); + } else { + traitor_mod = 2; + } + + planet_forces[eFACTION.HERETICS] = traitor_mod; + tixt = $"Heretic cults have appeared in {name()}."; + } else if ((_rando >= 81) && (_rando < 91) && (planet_forces[eFACTION.HERETICS] < 3)) { + // Minor uprising + if (is_garrison_force) { + traitor_mod = choose(2, 3); + } else { + traitor_mod = 3; + } + edit_forces(eFACTION.HERETICS,traitor_mod); + tixt = $"Heretic cults have spread around {name()}."; + } // Major uprising + + // major and huge uprisings are impossible as long as a garrisons of at least 10 marines is present + if ((_rando >= 91) && (_rando < 100) && (planet_forces[eFACTION.HERETICS] < 4)) { + notixt = true; + edit_forces(eFACTION.HERETICS,4); + + if ((obj_controller.faction_defeated[10] == 0) && (obj_controller.faction_gender[10] == 1)) { + edit_forces(eFACTION.HERETICS,5); + } + + var n_name = name(); + scr_popup("Heretic Revolt", $"A massive heretic uprising on {n_name} threatens to plunge the star system into chaos.", "chaos_cultist", ""); + scr_alert("red", "owner", $"Massive heretic uprising on {n_name}.", x, y); + scr_event_log("purple", $"Massive heretic uprising on {n_name}.", system.name); + } // Huge uprising + + if ((_rando >= 100) && (planet_forces[eFACTION.HERETICS] < 5)) { + edit_forces(eFACTION.HERETICS,6); + set_new_owner(eFACTION.HERETICS) + add_feature(eP_FEATURES.DAEMONIC_INCURSION); + + set_corruption(corruption < 80 ? 80 : 95) + + tixt = $"Daemonic incursion on {name()}!"; + } // Oh god what + + if ((_rando >= 41) && (!notixt) && tixt != "") { + scr_alert("red", "owner", tixt, x, y); + scr_event_log("purple", tixt, system.name); + } + // if (planet_forces[eFACTION.HERETICS]>2){obj_controller.x=self.x;obj_controller.y=self.y;} + } // End traitors cult + } + + } + + static check_old_battles_feature = function(){ + if (has_feature(eP_FEATURES.OLDBATTLEGROUND)){ + var _feats = get_features(eP_FEATURES.OLDBATTLEGROUND); + + for (var i=0;i 5) && (action_score <= 10)) { siz_penalty = 5; } + // if ((action_score > 10) && (action_score <= 20)) { siz_penalty = 20; } + // if ((action_score > 20) && (action_score <= 50)) { siz_penalty = 30; } + // if ((action_score > 50) && (action_score <= 100)) { siz_penalty = 50; } + // if ((action_score > 100) && (action_score <= 200)) { siz_penalty = 75; } + // if (action_score > 200) { siz_penalty = 125; } + + var spec1=0,spec2=0,txt=""; // TODO consider making it a battle with Planetary governor's guards + txt="Your Astartes descend upon the surface of {name()} and plot the movements and schedule of the governor. "; + txt+="Once the time is right their target is ambushed " + txt+=choose("in their home","in the streets","while driving","taking a piss")+" and tranquilized. "; + + if(scr_has_disadv("Never Forgive")) then spec1=1; + if (global.chapter_name="Space Wolves" || obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES) { + spec1=3; + } + else if (global.chapter_name="Iron Hands" || obj_ini.progenitor == ePROGENITOR.IRON_HANDS) { + spec1=6; + } + if (obj_ini.omophagea=1){ + spec1=choose(spec1,20); + } + + if (spec1=1) then txt+="They are brought to the already-prepared facilities for Fallen, tortured to make "+string(choose("him","him","her"))+" appear a heretic, and then incinerated. "; + if (spec1=3) then txt+=string(choose("He","He","She"))+" is tossed to the Fenrisian Wolves and viciously mauled, torn apart, and eaten. The beasts leave nothing but bloody scraps. "; + if (spec1=6) then txt+=string(choose("He","He","She"))+" is stuck in with the other criminals, and scum, to be turned into a servitor. Soon nothing remains that could be likened to the former Governor. "; + if (spec1=20){ + if (action_score>1) then txt+="Things get out of hand, and the Governor is torn limb from limb and consumed. "+string(choose("His","His","Her"))+" flesh is torn off and eaten, bone pulverized, and marrow sucked free. "; + if (action_score=1) then txt+="Your battle brother chops apart the Governor and eats a sizeable portion of "+string(choose("his","his","her"))+" flesh, focusing upon the eyes, teeth, and fingers. Once full the rest is disposed of. "; + } + + if (spec1=0){ + spec2=choose(1,2,3,4,5,5,5); + if (spec2=1) then txt+="Their still-living body is disintegrated by acid. "; + if (spec2=2) then txt+="The Governor is jettisoned into the local star at the first opportunity. "; + if (spec2=3) then txt+=string(choose("He","He","She"))+" is burned as fuel for one of your vessels. "; + if (spec2=4) then txt+="A few grenades is all it takes to blow "+string(choose("his","his","her"))+" body to smithereens. "; + if (spec2=5) then txt+=string(choose("He","He","She"))+" is executed in a mundane fashion and buried. "; + } + + txt+="What is thy will?"; + + var pip=instance_create(0,0,obj_popup); + pip.title="Planetary Governor Assassinated"; + pip.text=txt; + pip.planet=planet; + pip.p_data = new PlanetData(planet,star); + var options = [ + { + str1 : "Allow the official successor to become Planetary Governor.", + choice_func : allow_governor_successor, + }, + { + str1 : "Ensure that a sympathetic successor will be the one to rule.", + choice_func : install_sympathetic_successor, + }, + { + str1 : "Remove all successors and install a loyal Chapter Serf.", + choice_func : install_chapter_surf, + }, + ] + pip.add_option(options); + pip.cooldown=20; + + // Result- this is the multiplier for the chance of discovery with the inquisition, can also be used to determine + // the new Governor disposition if they are the official successor + if (aroll < chance){// Discovered + pip.estimate=2; + } else if (aroll >= chance){// Success + pip.estimate=1; + } + // If there are enemy non-chaos forces then they may be used as a cover + // Does not work with chaos because if the governor dies, with chaos present, the new governor would possibly be investigated + if (planet_forces[eFACTION.ORK]>=4) or (planet_forces[eFACTION.NECRONS]>=3) or (planet_forces[eFACTION.TYRANIDS]>=5){ + pip.estimate=pip.estimate*0.5; + } + } + + } + + + + + diff --git a/scripts/scr_Table/scr_Table.gml b/scripts/scr_Table/scr_Table.gml index 5e11e0f7b..d8463d93a 100644 --- a/scripts/scr_Table/scr_Table.gml +++ b/scripts/scr_Table/scr_Table.gml @@ -18,8 +18,6 @@ function Table(data) constructor { move_data_to_current_scope(data); - update(); - static update = function(data) { move_data_to_current_scope(data); w = 0; @@ -55,6 +53,8 @@ function Table(data) constructor { } }; + update(data); + static draw = function() { add_draw_return_values(); @@ -97,10 +97,14 @@ function Table(data) constructor { _row.click_left(); } } + if (struct_exists(_row,"click_right")){ + if (mouse_button_clicked(mb_right)){ + _row.click_right(); + } + } } - - _row_level += row_h; - } - pop_draw_return_values(); - }; + _row_level += row_h; + } + pop_draw_return_values(); + }; } diff --git a/scripts/scr_add_artifact/scr_add_artifact.gml b/scripts/scr_add_artifact/scr_add_artifact.gml index b921bf4cd..4d1f44b70 100644 --- a/scripts/scr_add_artifact/scr_add_artifact.gml +++ b/scripts/scr_add_artifact/scr_add_artifact.gml @@ -38,6 +38,7 @@ function scr_add_artifact(artifact_type = "random", artifact_tags = "", is_ident good = false; } } + if (base_type == "") { if (array_contains(["Weapon", "Armour", "Gear", "Device"], artifact_type)) { base_type = artifact_type; @@ -284,14 +285,23 @@ function ArtifactStruct(Index) constructor { return obj_ini.artifact[index]; }; + static update_type = function(new_type){ + obj_ini.artifact[index] = new_type; + } + static condition = function() { return obj_ini.artifact_condition[index]; }; - static loc = function() { + static loc = function(set_loc) { return obj_ini.artifact_loc[index]; }; + + static set_loc = function(new_loc){ + obj_ini.artifact_loc[index] = new_loc; + } + //combination of what is normally lid and wid static sid = function() { return obj_ini.artifact_sid[index]; @@ -303,7 +313,8 @@ function ArtifactStruct(Index) constructor { "Statue", "Casket", "Chalice", - "Robot" + "Robot", + "trophy" ]; if (array_contains(none_equips, type())) { _can_equip = false; @@ -363,6 +374,11 @@ function ArtifactStruct(Index) constructor { return obj_ini.artifact_identified[index]; }; + static add_tag = function(tag_to_add){ + if (!array_contains(tags(), tag_to_add)){ + array_push(obj_ini.artifact_tags[index],tag_to_add); + } + } static has_tag = function(wanted_tag) { return array_contains(tags(), wanted_tag); }; diff --git a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml index f7970eeb3..f1a40b828 100644 --- a/scripts/scr_apothecary_ground/scr_apothecary_ground.gml +++ b/scripts/scr_apothecary_ground/scr_apothecary_ground.gml @@ -260,9 +260,13 @@ function process_specialist_points() { // Planet specific logic (Orbit is 0, Planets are 1-4) if (turn_end && _p > 0 && array_length(_star_inst.p_feature[_p]) > 0) { - var _planet_data = new PlanetData(_p, _star_inst); - _planet_data.recover_starship(_cur_techs); - _planet_data.planet_training(_pool.heal); + if (array_length(_star_inst.p_feature[_p])!=0){ + var _planet_data = _star_inst.system_datas[_p]; + _planet_data.refresh_data(); + _planet_data.recover_starship(_cur_techs); + _planet_data.planet_training(_pool.heal); + _planet_data.search_old_battle_grounds(_cur_units); + } } } else if (_p == 0 && string_pos("ref instance", _cur_loc) > 0) { _handle_instance_point_recording(_cur_loc, _stats); diff --git a/scripts/scr_buttons/scr_buttons.gml b/scripts/scr_buttons/scr_buttons.gml index 0f6efa355..6281366ee 100644 --- a/scripts/scr_buttons/scr_buttons.gml +++ b/scripts/scr_buttons/scr_buttons.gml @@ -71,15 +71,15 @@ function Box(data) constructor{ /// @example /// var rs = new ReactiveString("Hello", 100, 200); /// rs.draw(); -function ReactiveString(text, x1 = 0, y1 = 0, data = false) constructor { +function ReactiveString(text, x1 = 0, y1 = 0, data = false) constructor{ + standard_loc_data(); + self.x1 = x1; self.y1 = y1; - x2 = 0; - y2 = 0; + self.text = text; + halign = fa_left; valign = fa_top; - - self.text = text; text_max_width = -1; font = fnt_40k_14; colour = CM_GREEN_COLOR; @@ -87,7 +87,8 @@ function ReactiveString(text, x1 = 0, y1 = 0, data = false) constructor { max_width = -1; h = 0; w = 0; - scale_text = false; + scale_text=false; + scale = 1; move_data_to_current_scope(data); @@ -110,7 +111,8 @@ function ReactiveString(text, x1 = 0, y1 = 0, data = false) constructor { h = string_height(text) * scale; } } else { - w = string_width(text); + w = string_width(text) * scale; + h = string_height(text) * scale; } pop_draw_return_values(); @@ -156,11 +158,9 @@ function ReactiveString(text, x1 = 0, y1 = 0, data = false) constructor { /// @param {struct|bool} [data=false] Optional struct of properties to apply. /// @returns {LabeledIcon} function LabeledIcon(icon, text, x1 = 0, y1 = 0, data = false) constructor { + standard_loc_data(); self.x1 = x1; self.y1 = y1; - x2 = 0; - y2 = 0; - self.text = text; text_max_width = -1; font = fnt_40k_14; @@ -336,8 +336,7 @@ function standard_loc_data() { /// @param {struct|bool} [data=false] Initial property overrides. /// @returns {UnitButtonObject} function UnitButtonObject(data = false) constructor { - x1 = 0; - y1 = 0; + standard_loc_data(); w = 102; h = 30; h_gap = 4; @@ -497,10 +496,11 @@ function PurchaseButton(req) : UnitButtonObject() constructor { static draw = function(allow_click = true) { add_draw_return_values(); - var _but = draw_unit_buttons([x1, y1, x2, y2], label, [1, 1], color,,, alpha); + draw_sprite_ext(spr_requisition, 0, x1, y1, scale, scale, 0, c_white, 1); + var _but = draw_unit_buttons([x1 + (get_sprite_width(spr_requisition) * scale), y1, x2, y2], label, [1, 1], color,,, alpha); var _sh = sprite_get_height(spr_requisition); var _scale = (y2 - y1) / _sh; - draw_sprite_ext(spr_requisition, 0, x1, y2, _scale, _scale, 0, c_white, 1); + var _allow_click = obj_controller.requisition >= req_value; if (scr_hit(x1, y1, x2, y2) && tooltip != "") { tooltip_draw(tooltip); @@ -869,10 +869,7 @@ function MultiSelect(options_array, title, data = {}) constructor { self.title = title; x_gap = 10; y_gap = 5; - x1 = 0; - y1 = 0; - x2 = 0; - y2 = 0; + standard_loc_data(); on_change = false; active_col = CM_GREEN_COLOR; inactive_col = c_gray; @@ -884,6 +881,7 @@ function MultiSelect(options_array, title, data = {}) constructor { _next_tog.active = false; array_push(toggles, _next_tog); } + static update = item_data_updater; update(data); @@ -983,8 +981,7 @@ function RadioSet(options_array, title = "", data = {}) constructor { allow_changes = true; x_gap = 10; y_gap = 5; - x1 = 0; - y1 = 0; + standard_loc_data(); title_font = fnt_40k_14b; draw_title = true; space_evenly = false; @@ -1114,10 +1111,7 @@ function RadioSet(options_array, title = "", data = {}) constructor { /// @param {struct} [data={}] Initial properties. /// @returns {ToggleButton} function ToggleButton(data = {}) constructor { - x1 = 0; - y1 = 0; - x2 = 0; - y2 = 0; + standard_loc_data(); tooltip = ""; str1 = ""; width = 0; @@ -1245,10 +1239,7 @@ function ToggleButton(data = {}) constructor { /// @param {struct} [data={}] Initial properties. /// @returns {InteractiveButton} function InteractiveButton(data = {}) constructor { - x1 = 0; - y1 = 0; - x2 = 0; - y2 = 0; + standard_loc_data(); str1 = ""; inactive_tooltip = ""; tooltip = ""; diff --git a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml index 6e895eb73..2144107c3 100644 --- a/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml +++ b/scripts/scr_chapter_managent_events/scr_chapter_managent_events.gml @@ -278,3 +278,180 @@ function new_forge_master_chosen(pick) { } } } + + +function strange_build_event(){ + LOGGER.info("RE: Fey Mood"); + var _search_params = {trait : ["crafter","tinkerer"], trait_any : true} + var marine_and_company = scr_random_marine("",0, _search_params); + if (marine_and_company == "none"){ + marine_and_company = scr_random_marine("",0, "none"); + } + if(marine_and_company != "none"){ + var marine = marine_and_company[0]; + var company = marine_and_company[1]; + var text=""; + var _unit = fetch_unit(marine_and_company); + var role = _unit.role(); + text = _unit.name_role(); + text+=" is taken by a strange mood and starts building!"; + + + var crafted_object; + var craft_roll=roll_dice_chapter(1, 100, "low"); + var heritical_item = false; + + //this bit should be improved, idk what duke was checking for here + //TODO make craft chance reflective of crafters skill, rewards players for having skilled tech area + if (scr_has_disadv("Tech-Heresy")) { + craft_roll+=20; + } + if (_unit.has_trait("tech_heretic")){ + craft_roll+=60; + } + if (scr_has_adv("Crafter")) { + if (craft_roll>80) { + craft_roll-=10; + } + if (craft_roll<60) { + craft_roll+=10; + } + } + + if (craft_roll<=50){ + crafted_object=choose("Icon","Icon","Statue"); + } + else if ((craft_roll>50) && (craft_roll<=60)) { + crafted_object=choose("Bike","Rhino"); + } + else if ((craft_roll>60) && (craft_roll<=80)) { + crafted_object="Artifact"; + } + else { + crafted_object=choose("baby","robot","demon","fusion"); + heritical_item=1; + } + + + add_event({ + e_id : "strange_building", + duration : 1, + name : _unit.name(), + company : company, + marine : marine, + crafted : crafted_object, + }) + + scr_popup("Can He Build marine?!?",text,"tech_build",""); + + var marine_is_planetside = _unit.planet_location>0; + if (marine_is_planetside && heritical_item) { + var _system = find_star_by_name(_unit.location_string); + var _planet = _unit.planet_location; + if (_system!="none"){ + with (_system){ + p_hurssy[_planet]+=6; + p_hurssy_time[_planet]=2; + } + } + } + else if (!marine_is_planetside and heritical_item){ + var _fleet = find_ships_fleet(_unit.ship_location); + if (_fleet!="none"){ + //the intended code for here was to add some sort of chaos event on the ship stashed up ready to fire in a few turns + } + } + return true; + } + return false; +} + +function init_mutated_gene_random_event(){ + //TODO make reprocussions to ignoring this + log_message("RE: Gene-Seed Mutation"); + var text = "The Chapter's gene-seed has mutated! Apothecaries are scrambling to control the damage and prevent further contamination. What is thy will?"; + var _opt1 = "Dispose of "; + var _percent_remove = 0; + if (obj_controller.gene_seed <= 30) { + _opt1 += "100% of the gene-seed."; + _percent_remove = 100; + } + if ((obj_controller.gene_seed > 30) && (obj_controller.gene_seed < 60)) { + _opt1 += "50% of all gene-seed."; + _percent_remove = 50; + } + if (obj_controller.gene_seed >= 60) { + _opt1 += "33% of all gene-seed."; + _percent_remove = 33; + } + + var _opt2 = "Tell the apothecaries to let it be."; + + + var _pop_data = { + percent_remove : _percent_remove, + options : [ + { + str1:_opt1, + choice_func : event_dispose_of_mutated_gene, + }, + { + str1:_opt2, + choice_func : function(){ + scr_loyalty("Mutant Gene-Seed", "+"); + popup_default_close(); + } + }, + ] + } + + scr_popup("Gene-Seed Mutated!",text,"gene_bad",_pop_data); + scr_event_log("red","The Chapter Gene-Seed has mutated."); + + return true; +} + + +function event_dispose_of_mutated_gene() { + if (pop_data.percent_remove > 0) { + var _removal_amount = ceil(obj_controller.gene_seed * (pop_data.percent_remove / 100)); + obj_controller.gene_seed -= _removal_amount; + } + popup_default_close(); +} + + +function init_marine_distinguishment_event(){ + log_message("RE: Promotion"); + var marine_and_company = scr_random_marine([obj_ini.role[100][8],obj_ini.role[100][12],obj_ini.role[100][9],obj_ini.role[100][10]],0); + if(marine_and_company == "none") + { + log_error("RE: Promotion, couldn't pick a space marine"); + return false; + } + var marine=marine_and_company[1]; + var company=marine_and_company[0]; + var _unit = fetch_unit(marine_and_company); + var role=_unit.role(); + var text = _unit.name_role(); + var company_text = scr_convert_company_to_string(company); + //var company_text = scr_company_string(company); + if(company_text != ""){ + company_text = $"({company_text})"; + } + text += company_text; + text += " has distinguished himself.\n\nHe is up for review to be promoted."; + + if (company != 10){ + _unit.add_exp(10); + } + else { + _unit.add_exp(max(20, _unit.experience)); + } + + scr_popup("Promotions!",text,"distinguished",""); + scr_event_log("green",text); + return true; +} + + diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 4c3424c3f..b529cbcc9 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -138,17 +138,6 @@ function scr_cheatcode(argument0) { } } break; - - case "mechmission": - LOGGER.debug("mech_mission"); - - if (array_length(cheat_arguments)) { - spawn_mechanicus_mission(cheat_arguments[0]); - } else { - spawn_mechanicus_mission(); - } - break; - case "inquismission": var mission = cheat_arguments[0]; LOGGER.debug($"{mission},"); @@ -426,46 +415,50 @@ function draw_planet_debug_options() { } } -/// @mixin -function draw_planet_debug_features() { - static _addable_features = [ - { - e_num: eP_FEATURES.GENE_STEALER_CULT, - name: "GeneStealer Cult", - }, - { - e_num: eP_FEATURES.ANCIENT_RUINS, - name: "Ancient Ruins", - }, - { - e_num: eP_FEATURES.ARTIFACT, - name: "Artefact", - }, - { - e_num: eP_FEATURES.STC_FRAGMENT, - name: "STC Fragment", - }, - { - e_num: eP_FEATURES.SORORITAS_CATHEDRAL, - name: "Sororitas Cathedral", - }, - { - e_num: eP_FEATURES.ORKWARBOSS, - name: "Ork Warboss", - }, - { - e_num: eP_FEATURES.ORKSTRONGHOLD, - name: "Ork stronghold", - }, - { - e_num: eP_FEATURES.MONASTERY, - name: "Fortress Monastery", - }, - { - e_num: eP_FEATURES.STARSHIP, - name: "Ancient Starship", - } - ]; +//@mixin +function draw_planet_debug_features(){ + static _addable_features = [ + { + e_num : eP_FEATURES.GENE_STEALER_CULT, + name : "GeneStealer Cult" + }, + { + e_num : eP_FEATURES.ANCIENT_RUINS, + name : "Ancient Ruins" + }, + { + e_num : eP_FEATURES.ARTIFACT, + name : "Artefact" + }, + { + e_num : eP_FEATURES.STC_FRAGMENT, + name : "STC Fragment" + }, + { + e_num : eP_FEATURES.SORORITAS_CATHEDRAL, + name : "Sororitas Cathedral" + }, + { + e_num : eP_FEATURES.ORKWARBOSS, + name : "Ork Warboss" + }, + { + e_num : eP_FEATURES.ORKSTRONGHOLD, + name : "Ork stronghold" + }, + { + e_num : eP_FEATURES.MONASTERY, + name : "Fortress Monastery" + }, + { + e_num : eP_FEATURES.STARSHIP, + name : "Ancient Starship" + }, + { + e_num : eP_FEATURES.OLDBATTLEGROUND, + name : "Old Battle Ground" + }, + ] var base_y = 220; base_y += 2; @@ -476,51 +469,79 @@ function draw_planet_debug_features() { draw_text(38, _y, _feat.name); if (point_and_click([38, _y, 337, _y + 20])) { var _new_feat = new NewPlanetFeature(_feat.e_num); + _new_feat.player_hidden = false; array_push(target.p_feature[obj_controller.selecting_planet], _new_feat); } } } + /// @mixin -function draw_planet_debug_problems() { - var base_y = 220; - var _keys = PLANET_PROBLEM_KEYS; - base_y += 2; - for (var i = 0; i < array_length(_keys); i++) { - var _y = base_y + i * 20; - draw_text(38, _y, _keys[i]); - if (scr_hit(38, _y, 337, _y + 20)) { - tooltip_draw(mission_name_key(_keys[i])); - if (mouse_button_clicked()) { - switch (_keys[i]) { - case "inquisitor": - mission_inquistion_hunt_inquisitor(target.id); - break; - case "necron": - mission_inquisition_tomb_world(target.id); - break; - case "mech_raider": - spawn_mechanicus_mission("mech_raider"); - break; - case "mech_mars": - spawn_mechanicus_mission("mech_mars"); - break; - case "mech_bionics": - spawn_mechanicus_mission("mech_bionics"); - break; - - default: - scr_popup("error", "no specific debug action created please consider helping to make one", ""); - break; - } - } - } - } +function draw_planet_debug_problems(){ + var base_y = 220; + var _keys = PLANET_PROBLEM_KEYS; + base_y += 2; + for (var i=0;i= upgrade_cost) { - obj_controller.requisition -= upgrade_cost; - feature.size++; - worker_capacity *= 2; - } - } - if (feature.size > 1 && !feature.vehicle_hanger) { - var upgrade_cost = 3000; - var build_coords = draw_unit_buttons(next_position, $"Build Vehicle Hanger({upgrade_cost} req)", [1, 1], c_red); - if (scr_hit(build_coords)) { - tooltip_draw("Required to Build Vehicles in the Forge"); - } - if (point_and_click(build_coords) && obj_controller.requisition >= upgrade_cost) { - feature.vehicle_hanger = 1; - obj_controller.requisition -= upgrade_cost; - array_push(obj_controller.player_forge_data.vehicle_hanger, [obj_controller.selected.name, planet_data.planet]); - } - } else if (feature.vehicle_hanger) { - draw_text(next_position[0], next_position[1], "Forge has a vehicle hanger"); - //TODO somthing if the forge has a hanger - } - break; - case eP_FEATURES.NECRON_TOMB: - generic = true; - if (feature.awake == 0 && feature.sealed == 0) { - title = "Dormant Necron Tomb"; - body = "Scans indicate a Necron Tomb lies hidden under the surface of the planet, all signs indicate the tombis dormant as we must hope it remains"; - } else if (feature.sealed) { - title = "Sealed Necron Tomb"; - body = "Exterminatus and standard imperial armaments are no proof against the Necron Scourge with any luck those sealed within this tomb will remain there"; - } else if (feature.awake) { - title = "Awake Tomb"; - body = "The Cursed ranks of living metal spew forth from the Necron tomb below"; - } - break; - case eP_FEATURES.ARTIFACT: - generic = true; - title = "Unknown Artifact"; - body = "Unload Marines onto the planet to search for the artifact"; - break; - case eP_FEATURES.ANCIENT_RUINS: - generic = true; - title = "Ancinet Ruins"; - body = "Unload Marines onto the planet to explore the ruins"; - break; - case eP_FEATURES.STC_FRAGMENT: - generic = true; - title = "STC Fragment"; - body = $"Unload a {obj_ini.role[100][16]} and whatever entourage you deem necessary to recover the STC Fragment"; - break; - case eP_FEATURES.GENE_STEALER_CULT: - generic = true; - var cult_control = planet_data.population_influences[eFACTION.TYRANIDS]; - title = $"Cult of {feature.name}"; - var control_string = ""; - if (cult_control < 25) { - control_string = "currently has limited influence on the planet but is fast gaining speed"; - } else if (cult_control < 50) { - control_string = "Is rapidly gaining momentum with the planets populace and will soon sieze control of the planet if left unchecked"; - } else if (cult_control < 75) { - control_string = "Has managed to galvanise the populace to overcome the former governor of the planet turning much of the local pdf to it's cause, it must be stopped, lest it spread."; - } else { - control_string = "The cult’s rot and control of the planet is complete; even if the cult can be dismantled, the corruption is great and the population will need significant purging and monitoring to remove the taint"; - } - body = $"The Cult of {feature.name} {control_string}"; - break; - case eP_FEATURES.VICTORY_SHRINE: - draw_text_transformed(xx + (area_width / 2), yy + 10, "Victory Shrine", 2, 2, 0); - draw_set_halign(fa_left); - draw_set_color(c_gray); - /*if (!feature.parade){ + exit_button = new UnitButtonObject({label:"<---",color:CM_RED_COLOR}); + + draw_planet_features = function(xx,yy){ + add_draw_return_values(); + draw_set_halign(fa_center); + draw_set_valign(fa_top); + draw_set_font(fnt_40k_14); + //draw_sprite(spr_planset_screen,0,xx,yy); + if (exit_sequence){ + xx-=(25*exit_count); + main_slate.draw(xx,yy, 1.38,1.38); + exit_count++; + remove = (xx-25<=obj_star_select.main_data_slate.XX); + } else if (entrance_sequence){ + enter_count--; + xx-=(25*enter_count); + if (enter_count==1) then entrance_sequence = false; + main_slate.draw(xx,yy, 1.38,1.38); + }else { + main_slate.draw(xx,yy, 1.4,1.4); + } + w = main_slate.width; + h = main_slate.height; + generic = false; + title=""; + body=""; + button_tooltip = ""; + //draw_glow_dot(xx+150, yy+150); + //rack_and_pinion(xx+230, yy+170); + var rectangle = []; + draw_set_color(c_green); + exit_button.update({x1:xx+12,y1:yy+20}); + if (exit_button.draw()){ + exit_sequence=true; + }; + draw_set_halign(fa_center); + switch (feature.f_type){ + case eP_FEATURES.FORGE: + draw_text_transformed(xx+(w/2), yy +10, "Chapter Forge", 2, 2, 0); + draw_set_halign(fa_left); + draw_set_color(c_gray); + + draw_text(xx+10, yy+50, $"Working Techs : {feature.techs_working}/{worker_capacity}"); + forge_assign_button.update({x1:xx+10,y1 : yy+70}); + forge_assign_button.draw(); + //TODO move over to using the draw button object ot streamline this + var _next_position = {x1:xx+10, y1: yy+95}; + if (feature.size<3){ + var upgrade_cost = 2000 * feature.size; + forge_upgrade_button.update(_next_position); + forge_upgrade_button.update({ + label:$"Upgrade Forge ({upgrade_cost} req)", + }); + forge_upgrade_button.draw(); + _next_position={ + x1:forge_upgrade_button.x1, + y1:forge_upgrade_button.y2, + } + } + if (feature.size>1 && !feature.vehicle_hanger){ + var upgrade_cost = 3000; + var build_coords = draw_unit_buttons(_next_position, $"Build Vehicle Hanger({upgrade_cost} req)",[1,1],c_red); + if (scr_hit(build_coords)){ + tooltip_draw("Required to Build Vehicles in the Forge") + } + if (point_and_click(build_coords) && obj_controller.requisition>=upgrade_cost){ + feature.vehicle_hanger=1; + obj_controller.requisition -= upgrade_cost; + array_push(obj_controller.player_forge_data.vehicle_hanger,[obj_controller.selected.name,planet_data.planet]); + } + } else if(feature.vehicle_hanger){ + draw_text(_next_position[0], _next_position[1], "Forge has a vehicle hanger Allowing vehicles to be coonstructed behavior"); + //TODO somthing if the forge has a hanger + } + break; + case eP_FEATURES.NECRON_TOMB: + + generic=true; + if (feature.awake==0 && feature.sealed==0){ + title = "Dormant Necron Tomb"; + body = "Scans indicate a Necron Tomb lies hidden under the surface of the planet, all signs indicate the tombis dormant as we must hope it remains"; + } else if (feature.sealed){ + title = "Sealed Necron Tomb"; + body = "Exterminatus and standard imperial armaments are no proof against the Necron Scourge with any luck those sealed within this tomb will remain there"; + } else if (feature.awake){ + title = "Awake Tomb"; + body = "The Cursed ranks of living metal spew forth from the Necron tomb below" + } + break; + case eP_FEATURES.ARTIFACT: + generic=true; + title = "Unknown Artifact"; + body = "Unload Marines onto the planet to search for the artifact"; + break; + case eP_FEATURES.ANCIENT_RUINS: + generic=true; + title = "Ancinet Ruins"; + body = "Unload Marines onto the planet to explore the ruins"; + break; + case eP_FEATURES.OLDBATTLEGROUND: + generic=true; + title = "Old Battlefield"; + body = $"The site of a previously unrecorded battle between {feature.faction1} and {feature.faction2} forces long forgotten\nUnload Marines to search Techmarines are advisable to help, it would be best any tech priests not be aware of such an operation it may create a conflict of interest"; + break; + case eP_FEATURES.STC_FRAGMENT: + generic=true; + title = "STC Fragment"; + body = $"Unload a {obj_ini.role[100][16]} and whatever entourage you deem necessary to recover the STC Fragment"; + break; + case eP_FEATURES.GENE_STEALER_CULT: + generic=true; + var cult_control = planet_data.population_influences[eFACTION.TYRANIDS]; + title = $"Cult of {feature.name}"; + var control_string = ""; + if (cult_control<25){ + control_string = "currently has limited influence on the planet but is fast gaining speed"; + } else if (cult_control<50){ + control_string = "Is rapidly gaining momentum with the planets populace and will soon sieze control of the planet if left unchecked"; + }else if (cult_control<75){ + control_string = "Has managed to galvanise the populace to overcome the former governor of the planet turning much of the local pdf to it's cause, it must be stopped, lest it spread."; + } else { + control_string = "The cult’s rot and control of the planet is complete; even if the cult can be dismantled, the corruption is great and the population will need significant purging and monitoring to remove the taint"; + } + body = $"The Cult of {feature.name} {control_string}"; + break; + case eP_FEATURES.VICTORY_SHRINE: + draw_text_transformed(xx+(w/2), yy +10, "Victory Shrine", 2, 2, 0); + draw_set_halign(fa_left); + draw_set_color(c_gray); + /*if (!feature.parade){ if (point_and_click(draw_unit_buttons([xx+10, yy+70], "Parade (500 req)",[1,1],c_red))){ obj_controller.requisition-=500; feature.forge=1; feature.forge_data = new PlayerForge(); } }*/ - break; - case eP_FEATURES.MONASTERY: - draw_text_transformed(xx + (area_width / 2), yy + 10, feature.name, 2, 2, 0); - if (feature.forge == 0) { - draw_text_transformed(xx + 80, yy + 50, "Forge", 1, 1, 0); - if (draw_building_builder(xx + 40, yy + 70, 500, spr_forge_holo)) { - obj_controller.requisition -= 500; - feature.forge = 1; - feature.forge_data = new PlayerForge(); - } - } - break; - case eP_FEATURES.ORKSTRONGHOLD: - title = "Ork Stronghold"; - generic = true; - if (planet_data.planet_forces[eFACTION.ORK]) { - body = $"For as long as this Stronghold stands the orks here will continue to fortify it. The larger it gets the greater the capacity of this planet to produce orkish machines of war and ships and the better protected the ork forces will be from bombardment"; - } else { - body = "Without a force of orks to hold it together the fortress is slowly pulled apart from within by the inhabitants, It's capabilities will constantly decrease until soon there will be nothing left"; - } - break; + break; + case eP_FEATURES.MONASTERY: + draw_text_transformed(xx+(w/2), yy +10, feature.name, 2, 2, 0); + if (feature.forge==0){ + draw_text_transformed(xx+80, yy +50, "Forge", 1, 1, 0); + if (draw_building_builder(xx+40, yy+70,500,spr_forge_holo)){ + obj_controller.requisition-=500; + feature.forge=1; + feature.forge_data = new PlayerForge(); + }; + } + break; + case eP_FEATURES.ORKSTRONGHOLD: + title = "Ork Stronghold"; + generic = true; + if (planet_data.planet_forces[eFACTION.ORK]){ + body = $"For as long as this Stronghold stands the orks here will continue to fortify it. The larger it gets the greater the capacity of this planet to produce orkish machines of war and ships and the better protected the ork forces will be from bombardment"; + } else { + body = "Without a force of orks to hold it together the fortress is slowly pulled apart from within by the inhabitants, It's capabilities will constantly decrease until soon there will be nothing left"; + } + break case eP_FEATURES.RECRUITING_WORLD: generic = true; var _planet = planet_data.planet; @@ -205,23 +228,22 @@ function FeatureSelected(_feature, _system, _planet) constructor { body += $"There is a {_recruit_find_chance * 100}% of producing a successful recruit this month on the basis of the available apothecary time to screen candidates and the chances of the aspirants passing their trials to an acceptable standard,\n\n"; - if ((obj_controller.faction_status[p_data.current_owner] == "War" || obj_controller.faction_status[p_data.current_owner] == "Antagonism") && (p_data.player_disposition <= 50)) { - // TODO LOW RECRUITING_DIALOG // Make this more dynamic. + if (obj_controller.faction_status[p_data.current_owner] == "War" || obj_controller.faction_status[p_data.current_owner] == "Antagonism") && (p_data.player_disposition <= 50) { // TODO LOW RECRUITING_DIALOG // Make this more dynamic. if (_recruit_world.recruit_type == 0) { - body += "Since our relations with the populations' faction are... strained, we are having to do our recruiting operation covertly,\n\n"; + body += "Since our relations with the populations' faction are... strained, we are having to do our recruiting operation covertly,\n\n" } else { - body += "Since our relations with the populations' faction are... strained, we are having to do our recruiting operation covertly,"; - body += " our brothers are authorized to use more extreme methods of recruitment,\n\n"; + body += "Since our relations with the populations' faction are... strained, we are having to do our recruiting operation covertly," + body += " our brothers are authorized to use more extreme methods of recruitment,\n\n" } } else if (obj_controller.faction_status[p_data.current_owner] == "War" || obj_controller.faction_status[p_data.current_owner] == "Antagonism") { if (_recruit_world.recruit_type == 0) { - body += "The population has grown accustomed to us and their Governor has given us the clear to openly recruit,\n\n"; + body += "The population has grown accustomed to us and their Governor has given us the clear to openly recruit,\n\n" } else { - body += "The population has grown accustomed to us and their Governor has given us the clear to openly recruit,"; - body += " however our brothers are still authorized to use more extreme methods of recruitment regardless,\n\n"; + body += "The population has grown accustomed to us and their Governor has given us the clear to openly recruit," + body += " however our brothers are still authorized to use more extreme methods of recruitment regardless,\n\n" } - } else if (_recruit_world.recruit_type == 1) { - body += "We've authorized our brothers to use more extreme methods of recruitment, should we really allow this Milord?\n\n"; + } else if (_recruit_world.recruit_type == 1){ + body += "We've authorized our brothers to use more extreme methods of recruitment, should we really allow this Milord?\n\n" } if (p_data.player_disposition < 100) { @@ -230,90 +252,121 @@ function FeatureSelected(_feature, _system, _planet) constructor { body += "To increase recruit success chance more apothecaries will be required on the planet surface."; } break; - case eP_FEATURES.MISSION: - var mission_description = $""; - var planet_name = planet_numeral_name(planet_data.planet, obj_star_select.target); - var button_text = "none"; - var button_function = "none"; - var help = "none"; - switch (feature.problem) { - case "provide_garrison": - var reason; - if (feature.reason == "importance") {} - mission_description = $"The governor of {planet_name} has requested a force of marines might stay behind following your departure.\n\n\n assign a squad to garrison to initiate mission, The garrison leeader will need to be capable of conducting himself in a diplomatic manner in order for the garrison duration to be a success"; + case eP_FEATURES.MISSION: + var mission_description=$""; + var planet_name = planet_numeral_name(planet_data.planet, obj_star_select.target); + var button_text="none"; + var button_function="none"; + var help = "none"; + switch(feature.problem){ + case "provide_garrison": + var reason; + if (feature.reason == "importance"){ - break; - case "join_communion": - mission_description = $"The governor of {planet_name} has Invited a delegate of your forces to take part in ceremony."; - break; - case "hunt_beast": - mission_description = $"The governor of {planet_name} has bemoaned the raiding of huge beasts on the fringes of the planets largest city, the numbers have swelled recently and are causing huge damage to the planets small economy. You could send a force to intervene, it would provide a fine test of metal for any that partake."; - help = "This is a good opportunity to provide experience and training, having at least one marine with experience in such matters would be advisable"; - button_text = "Send Hunters"; - button_function = function() { - var dudes = collect_role_group("all", obj_star_select.target.name); - group_selection(dudes, {purpose: "Beast Hunt", purpose_code: feature.problem, number: 3, system: planet_data.system, feature: obj_star_select.feature, planet: planet_data.planet, array_slot: feature.array_position, selections: []}); - destroy = true; - }; - break; - case "protect_raiders": - mission_description = $"The governor of {planet_name} has sent many requests to the sector commander for help with defending against xenos raids on the populace of the planet, the reports seem to suggest the xenos in question are in fact dark eldar."; - help = "Set a squad to ambush"; - button_text = "Send Squad"; - _button_tooltip = "milage may vary on playability of this mission progress at your own risk"; - button_function = function() { - var dudes = collect_role_group("all", obj_star_select.target.name); - group_selection(dudes, {purpose: "Select Squad for Ambush", purpose_code: feature.problem, number: 1, system: planet_data.system, feature: obj_star_select.feature, planet: planet_data.planet, array_slot: feature.array_position, select_type: eMISSION_SELECT_TYPE.SQUADS, selections: []}); - destroy = true; - }; - break; - case "train_forces": - mission_description = $"The governor of {planet_name} fears the planet will not hold in the case of major incursion, it has not seen war in some time and he fears the ineptitude of the commanders available, he asks for aid in planning a thorough plan for defense and schedule of works for a period of at least 6 months."; - help = $"A task best suited to the more knowledgable or wise of your Commanders"; - button_text = "Assign Officer"; - button_function = function() { - var dudes = collect_role_group(SPECIALISTS_CAPTAIN_CANDIDATES, obj_star_select.target.name); - group_selection(dudes, {purpose: "Select Officer", purpose_code: feature.problem, number: 1, system: planet_data.system, feature: obj_star_select.feature, planet: planet_data.planet, array_slot: feature.array_position, selections: []}); - destroy = true; - }; - break; - case "Purge_enemies": - mission_description = $"The governor of {planet_name} has expressed his distaste of the neighboring governance of {target.name} {feature.target} he has expressed his views that they engage in heretical ways and harbor xenos enemies though in truth it is more likely that he simply wishes his political enemies disposed of, whatever the case his planet has great economic means and he has made bare his plans to compensate the emperors angels for their aid"; - break; - } - draw_text_transformed(xx + (area_width / 2), yy + 5, mission_name_key(feature.problem), 2, 2, 0); - draw_set_halign(fa_left); - draw_set_color(c_gray); - draw_text_ext(xx + 10, yy + 40, mission_description, -1, area_width - 20); - var text_body_height = string_height_ext(string_hash_to_newline(mission_description), -1, area_width - 20); - if (help != "none") { - draw_text_ext(xx + 10, yy + 40 + text_body_height + 10, help, -1, area_width - 20); - text_body_height += string_height_ext(string_hash_to_newline(mission_description), -1, area_width - 20) + 10; - } + } + mission_description=$"The governor of {planet_name} has requested a force of marines might stay behind following your departure.\n\n\n assign a squad to garrison to initiate mission, The garrison leeader will need to be capable of conducting himself in a diplomatic manner in order for the garrison duration to be a success"; - if (button_text != "none") { - var _button = draw_unit_buttons([xx + ((area_width / 2) - (string_width(button_text) / 2)), yy + 40 + text_body_height + 10], button_text); - if (_button_tooltip != "" && scr_hit(_button)) { - tooltip_draw(_button_tooltip); - } - if (point_and_click(_button)) { - if (is_callable(button_function)) { - button_function(); - destroy = true; - } else { - tooltip_draw("no implemented function"); - } - } - } - break; - } - if (generic) { - draw_text_ext_transformed(xx + (area_width / 2), yy + 5, title, -1, area_width - 20, 2, 2, 0); + break; + case "join_communion": + mission_description=$"The governor of {planet_name} has Invited a delegate of your forces to take part in ceremony."; + break; + case "hunt_beast": + mission_description=$"The governor of {planet_name} has bemoaned the raiding of huge beasts on the fringes of the planets largest city, the numbers have swelled recently and are causing huge damage to the planets small economy. You could send a force to intervene, it would provide a fine test of metal for any that partake."; + help = "This is a good opportunity to provide experience and training, having at least one marine with experience in such matters would be advisable"; + button_text = "Send Hunters"; + button_function = function(){ + var dudes = collect_role_group("all", obj_star_select.target.name); + group_selection(dudes,{ + purpose:"Beast Hunt", + purpose_code : feature.problem, + number:3, + system:planet_data.system, + feature:obj_star_select.feature, + planet : planet_data.planet, + array_slot : feature.array_position, + selections : [] + }); + destroy=true; + } + break; + case "protect_raiders": + mission_description=$"The governor of {planet_name} has sent many requests to the sector commander for help with defending against xenos raids on the populace of the planet, the reports seem to suggest the xenos in question are in fact dark eldar."; + help = "Set a squad to ambush"; + button_text = "Send Squad"; + button_tooltip = "milage may vary on playability of this mission progress at your own risk"; + button_function = function(){ + var dudes = collect_role_group("all", obj_star_select.target.name); + group_selection(dudes,{ + purpose:"Select Squad for Ambush", + purpose_code : feature.problem, + number:1, + _system : planet_data.system, + feature:obj_star_select.feature, + planet : planet_data.planet, + array_slot : feature.array_position, + select_type : MissionSelectType.Squads, + selections : [] + }); + destroy=true; + } + break; + case "train_forces": + mission_description=$"The governor of {planet_name} fears the planet will not hold in the case of major incursion, it has not seen war in some time and he fears the ineptitude of the commanders available, he asks for aid in planning a thorough plan for defense and schedule of works for a period of at least 6 months."; + help = $"A task best suited to the more knowledgable or wise of your Commanders" + button_text = "Assign Officer"; + button_function = function(){ + var dudes = collect_role_group(SPECIALISTS_CAPTAIN_CANDIDATES, obj_star_select.target.name); + group_selection(dudes,{ + purpose:"Select Officer", + purpose_code : feature.problem, + number:1, + system:planet_data.system, + feature:obj_star_select.feature, + planet : planet_data.planet, + array_slot : feature.array_position, + selections : [] + }); + destroy=true; + } + break; + case "Purge_enemies": + mission_description=$"The governor of {planet_name} has expressed his distaste of the neighboring governance of {target.name} {feature.target} he has expressed his views that they engage in heretical ways and harbor xenos enemies though in truth it is more likely that he simply wishes his political enemies disposed of, whatever the case his planet has great economic means and he has made bare his plans to compensate the emperors angels for their aid"; + break; + } + draw_text_transformed(xx+(w/2), yy +5, mission_name_key(feature.problem), 2, 2, 0); + draw_set_halign(fa_left); + draw_set_color(c_gray); + draw_text_ext(xx+10, yy+40,mission_description,-1,w-20); + var text_body_height = string_height_ext(string_hash_to_newline(mission_description),-1,w-20); + if (help!="none"){ + draw_text_ext(xx+10, yy+40+text_body_height+10,help,-1,w-20); + text_body_height += string_height_ext(string_hash_to_newline(mission_description),-1,w-20)+10; + } + + if (button_text!="none"){ + var _button = draw_unit_buttons([xx+((w/2)-(string_width(button_text)/2)), yy+40+text_body_height+10], button_text); + if (button_tooltip != "" && scr_hit(_button)){ + tooltip_draw(button_tooltip); + } + if (point_and_click(_button)){ + if (is_callable(button_function)){ + button_function(); + destroy=true; + } else { + tooltip_draw("no implemented function"); + } + } + } + break; + } + if (generic){ + draw_text_ext_transformed(xx+(w/2), yy +5, title, -1, w-20, 2, 2, 0) - draw_set_halign(fa_left); - draw_set_color(c_gray); - draw_text_ext(xx + 10, yy + 40, body, -1, area_width - 20); - } - return "done"; - }; + draw_set_halign(fa_left); + draw_set_color(c_gray); + draw_text_ext(xx+10, yy+45,body,-1,w-20); + } + pop_draw_return_values(); + return "done"; + } } diff --git a/scripts/scr_draw_text/scr_draw_text.gml b/scripts/scr_draw_text/scr_draw_text.gml index d7118b111..4c10be398 100644 --- a/scripts/scr_draw_text/scr_draw_text.gml +++ b/scripts/scr_draw_text/scr_draw_text.gml @@ -63,19 +63,20 @@ function draw_text_glow_transformed(_x, _y, _text, _text_scale = [1, 1], _angle /// @function draw_text_outline /// @description This function will draw text in a similar way to draw_text(), only now the text will have an outline that may improve readability. -function draw_text_outline(_x, _y, _text, _outl_col = c_black, _text_col = -1) { +function draw_text_outline(_x, _y, _text, _outl_col=c_black, _text_col=-1,scale =1){ var _cur_color = draw_get_color(); draw_set_color(_outl_col); - draw_text(_x - 1.5, _y, _text); - draw_text(_x + 1.5, _y, _text); - draw_text(_x, _y - 1.5, _text); - draw_text(_x, _y + 1.5, _text); - if (_text_col != -1) { + draw_text_transformed(_x-1.5, _y, _text, scale, scale, 0); + draw_text_transformed(_x+1.5, _y, _text, scale, scale, 0); + draw_text_transformed(_x, _y-1.5, _text, scale, scale, 0); + draw_text_transformed(_x, _y+1.5, _text, scale, scale, 0); + if (_text_col != -1){ draw_set_color(_text_col); - } else { + } + else{ draw_set_color(_cur_color); } - draw_text(_x, _y, _text); + draw_text_transformed(_x, _y, _text,scale, scale, 0); draw_set_color(_cur_color); } diff --git a/scripts/scr_drop_select_function/scr_drop_select_function.gml b/scripts/scr_drop_select_function/scr_drop_select_function.gml index 47b8a8586..7124b15a3 100644 --- a/scripts/scr_drop_select_function/scr_drop_select_function.gml +++ b/scripts/scr_drop_select_function/scr_drop_select_function.gml @@ -435,7 +435,11 @@ function drop_select_draw() { _purge_score = array_length(roster.selected_units); } - scr_purge_world(p_target, planet_number, purge, _purge_score); + var _p_data = p_target.system_data[planet_number]; + + _p_data.refresh_data(); + + _p_data.purge(); } } } diff --git a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml index 7f1b17dc7..a5fc51ed7 100644 --- a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml +++ b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml @@ -1,11 +1,22 @@ /// @mixin function scr_enemy_ai_a() { - system_garrison = []; - system_sabatours = []; - system_datas = [0]; - for (var i = 1; i <= planets; i++) { - array_push(system_datas, new PlanetData(i, self)); + var _ops = p_operatives[i]; + if (system_garrison[i] == false){ + system_garrison[i] = new GarrisonForce(_ops, true); + } else { + system_garrison[i].update(_ops, true) + } + if (system_sabatours[i] == false){ + system_sabatours[i] = new GarrisonForce(_ops, true, "sabotage"); + } else { + system_sabatours[i].update(_ops, true) + } + if (system_datas[i] == false){ + system_datas[i] = new PlanetData(i, self) + } else { + system_datas[i].refresh_data(); + } } // guardsmen hop from planet to planet //not sure we really need this as it's handled with tht navy fleet functions but fuck it updated it and leaving it fot the sec @@ -43,19 +54,14 @@ function scr_enemy_ai_a() { var stop; var rand = 0; - var garrison_force = false, total_garrison = 0; + var _garrison_force = false, total_garrison = 0; var _planet_data; for (var _run = 1; _run <= planets; _run++) { - _planet_data = system_datas[_run]; - garrison_force = false; - var garrison = new GarrisonForce(p_operatives[_run], true); - var sabatours = new GarrisonForce(p_operatives[_run], true, "sabotage"); - _planet_data.garrison = garrison; - _planet_data.sabatours = sabatours; - garrison_force = garrison.garrison_force; - array_push(system_garrison, garrison); - array_push(system_sabatours, sabatours); + _planet_data = system_datas[_run]; + _garrison = _planet_data.garrisons; + _sabatours = _planet_data.sabatours; + _garrison_force = _garrison.garrison_force; stop = 0; ensure_no_planet_negatives(_run); @@ -104,11 +110,11 @@ function scr_enemy_ai_a() { if ((p_tyranids[_run] > 0) && (stop != 1) && (p_owner[_run] != 9)) { // This might have been causing the problem /*if (p_tyranids[_run]<5) and (p_guardsmen[_run]>0){ - if (p_tyranids[_run]=4) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-100000); - if (p_tyranids[_run]=3) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-20000); - if (p_tyranids[_run]=2) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-5000); - if (p_tyranids[_run]=1) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-500); - }*/ + if (p_tyranids[_run]=4) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-100000); + if (p_tyranids[_run]=3) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-20000); + if (p_tyranids[_run]=2) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-5000); + if (p_tyranids[_run]=1) then p_guardsmen[_run]=max(0,p_guardsmen[_run]-500); + }*/ if (p_tyranids[_run] >= 5) { tyranids_score = 7; } @@ -134,9 +140,9 @@ function scr_enemy_ai_a() { var defence_mult = _planet_data.fortification_level * 0.1; try { - if (pdf_with_player && garrison_force) { - //if player supports give garrison bonus - pdf_score = determine_pdf_defence(_planet_data.pdf, garrison, _planet_data.fortification_level)[0]; + if (pdf_with_player && _garrison_force) { + //if player supports give _garrison bonus + pdf_score = determine_pdf_defence(_planet_data.pdf, _garrison, _planet_data.fortification_level)[0]; } else { pdf_score = determine_pdf_defence(_planet_data.pdf,, _planet_data.fortification_level)[0]; } @@ -424,7 +430,7 @@ function scr_enemy_ai_a() { var after_combat_sisters = sisters_score; var tempor = 0, rand1 = 0, rand2 = 0; - var _active_garrison = pdf_with_player && garrison.viable_garrison > 0; + var _active_garrison = pdf_with_player && _garrison.viable_garrison > 0; // Guard attack if ((guard_score > 0) && (guard_attack != "") && (guard_score > 0.5)) { LOGGER.debug($"{name}:{guard_attack}"); @@ -464,7 +470,7 @@ function scr_enemy_ai_a() { if (guard_attack == "pdf") { if (pdf_with_player) { - pdf_mod = irandom_range(1, 6 + garrison.total_garrison * 0.1); + pdf_mod = irandom_range(1, 6 + _garrison.total_garrison * 0.1); } else { pdf_mod = irandom(5) + 1; } @@ -777,18 +783,18 @@ function scr_enemy_ai_a() { _planet_data.pdf_defence_loss_to_orks(); if (_active_garrison) { - var tixt = $"Chapter Forces led by {garrison.garrison_leader.name_role()} on {name} {scr_roman_numerals()[_run - 1]} were unable to secure PDF victory chapter support requested"; - if (garrison.garrison_sustain_damages("loose") > 0) { - tixt += $". {garrison.garrison_sustain_damages("loose")} Marines Lost"; + var tixt = $"Chapter Forces led by {_garrison.garrison_leader.name_role()} on {name} {scr_roman_numerals()[_run - 1]} were unable to secure PDF victory chapter support requested"; + if (_garrison.garrison_sustain_damages("loose") > 0) { + tixt += $". {_garrison.garrison_sustain_damages("loose")} Marines Lost"; } scr_alert("red", "owner", tixt, x, y); - //garrison.determine_battle(false,rand2-rand1, eFACTION.ORK); + //_garrison.determine_battle(false,rand2-rand1, eFACTION.ORK); } } else { if (_active_garrison) { - var tixt = $"Chapter Forces led by {garrison.garrison_leader.name_role()} on {name} {scr_roman_numerals()[_run - 1]} secure PDF victory"; - if (garrison.garrison_sustain_damages("win") > 0) { - tixt += $". {garrison.garrison_sustain_damages("win")} Marines Lost"; + var tixt = $"Chapter Forces led by {_garrison.garrison_leader.name_role()} on {name} {scr_roman_numerals()[_run - 1]} secure PDF victory"; + if (_garrison.garrison_sustain_damages("win") > 0) { + tixt += $". {_garrison.garrison_sustain_damages("win")} Marines Lost"; } scr_alert("green", "owner", tixt, x, y); } @@ -853,9 +859,9 @@ function scr_enemy_ai_a() { } } else if (traitors_attack == "guard") { /*if (traitors_attack="eldar"){ - rand2=(choose(1,2,3,4,5)*eldar_score)*choose(1,1.25); - if (rand1>rand2) then after_combat_csm-=1; - }*/ + rand2=(choose(1,2,3,4,5)*eldar_score)*choose(1,1.25); + if (rand1>rand2) then after_combat_csm-=1; + }*/ rand2 = (choose(1, 2, 3, 4, 5) * guard_score) * choose(1, 1.25); if (rand1 > rand2) { if (traitors_score <= 3) { @@ -1028,7 +1034,7 @@ function scr_enemy_ai_a() { rand2 = (choose(1, 2, 3, 4, 5) * guard_score) * choose(1, 1.25); if (rand1 > rand2) { /*if (tyranids_score<=3) then p_guardsmen[_run]=floor(p_guardsmen[_run]*0.6); - if (tyranids_score>=4) then p_guardsmen[_run]=floor(p_guardsmen[_run]*0.5);*/ + if (tyranids_score>=4) then p_guardsmen[_run]=floor(p_guardsmen[_run]*0.5);*/ var onh = 0; if ((tyranids_score == 1) && (onh == 0)) { p_guardsmen[_run] -= 2000; diff --git a/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml b/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml index 52ce5e2c4..e37f37065 100644 --- a/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml +++ b/scripts/scr_enemy_ai_b/scr_enemy_ai_b.gml @@ -7,384 +7,8 @@ function scr_enemy_ai_b() { i = 0; for (i = 1; i <= planets; i++) { - var cur_garrison = system_garrison[i - 1]; - var cur_sabatours = system_sabatours[i - 1]; - - sabotage_force = cur_sabatours.garrison_force; - total_garrison = cur_garrison.total_garrison; - is_garrison_force = cur_garrison.garrison_force; - - var planet_string = $"{string(name)} {scr_roman_numerals()[i - 1]}"; - // Orks grow in number - var ork_growth = floor(random(100)) + 1; - success = false; // This part handles the increasing in numbers - if ((p_owner[i] == 7) && (p_orks[i] < 5) && (p_traitors[i] == 0) && (p_player[i] <= 0 || !is_garrison_force)) { - if ((p_orks[i] > 0) && (p_orks[i] < 5) && (ork_growth <= 15)) { - if (sabotage_force) { - if (irandom(3) < 2) { - scr_event_log("green", $"sabotage force on {planet_string} disrupts ork forces", name); - } else { - p_orks[i] += 1; - } - } else { - p_orks[i] += 1; - } - } - } - if ((p_population[i] < p_max_population[i]) && (p_type[i] != "Dead") && (p_type[i] != "Craftworld") && (p_owner[i] <= 5) && (p_traitors[i] == 0) && (p_tau[i] == 0) && (p_orks[i] == 0) && (p_necrons[i] == 0) && (p_tyranids[i] == 0)) { - if (p_large[i] == 0) { - p_population[i] = round(p_population[i] * 1.0008); - } else if (p_large[i] == 1) { - p_population[i] += choose(0, 0.01); - } - } - - // increasing necrons - if (array_length(p_feature[i]) != 0) { - var has_awake_tomb = false, nfleet = 0; - if (awake_tomb_world(p_feature[i]) == 1) { - has_awake_tomb = true; - } - if (has_awake_tomb) { - if (p_necrons[i] < 3) { - p_necrons[i] += 2; - } else if (p_necrons[i] < 6) { - p_necrons[i] += 1; - } - } - if (sabotage_force && irandom(2) < 2) { - p_necrons[i]--; - scr_event_log("green", $"sabotage force on {planet_string} disrupts necron forces", name); - } - - if (has_awake_tomb) { - // Necron fleets, woooo - //necrons kill populatin - if ((p_population[i] > 0) && (p_player[i] + p_pdf[i] + p_guardsmen[i] + p_tyranids[i] == 0)) { - p_population[i] = p_population[i] * 0.75; - if ((p_large[i] == 0) && (p_population[i] <= 5000)) { - p_population[i] = 0; - } - } - - var fleet_spawn_chance = roll_dice_chapter(1, 100, "high"); - onceh = 0; - - if (fleet_spawn_chance <= 15) { - if (present_fleet[eFACTION.NECRONS] > 0) { - //if necron fleet - necron_fleet = instance_nearest(x, y, obj_en_fleet); - - if (necron_fleet.owner == eFACTION.NECRONS) { - if (necron_fleet.escort_number < necron_fleet.capital_number * 1.5) { - necron_fleet.escort_number += 2; - } else if (necron_fleet.frigate_number < necron_fleet.capital_number * 3) { - necron_fleet.frigate_number += 1; - } else { - necron_fleet.capital_number += 1; - } - } - } else if (present_fleet[eFACTION.NECRONS] == 0) { - necron_fleet = instance_create(x, y, obj_en_fleet); - necron_fleet.owner = eFACTION.NECRONS; - necron_fleet.capital_number = 1; - necron_fleet.sprite_index = spr_fleet_necron; - necron_fleet.image_speed = 0; - necron_fleet.image_index = 1; - present_fleet[eFACTION.NECRONS] += 1; - } - var enemy_fleets = 0; - with (necron_fleet) { - if (owner == eFACTION.NECRONS) { - var ii = 0; - ii += capital_number; - ii += round((frigate_number / 2)); - ii += round((escort_number / 4)); - if (ii <= 1) { - ii = 1; - } // image_index=max(8,round(ii)); - - if ((ii >= 7) && (capital_number > 1)) { - for (var fleet_n = 1; fleet_n <= 10; fleet_n++) { - if (orbiting.present_fleet[fleet_n] > 0) { - enemy_fleets++; - } - } - } - } - } - if (enemy_fleets > 0) { - var necron_fleet2; - necron_fleet2 = instance_create(x, y, obj_en_fleet); - necron_fleet2.owner = eFACTION.NECRONS; - necron_fleet2.sprite_index = spr_fleet_necron; - // necron_fleet2.image_index=0; - necron_fleet.image_speed = 0; - necron_fleet2.capital_number = 1; - necron_fleet2.frigate_number = round(necron_fleet.frigate_number / 2); - necron_fleet2.escort_number = round(necron_fleet.escort_number / 2); - present_fleet[eFACTION.NECRONS] += 1; - - necron_fleet.capital_number -= 1; - necron_fleet.frigate_number -= necron_fleet2.frigate_number; - necron_fleet.escort_number -= necron_fleet2.escort_number; - var nearest_planet_coords = [ - 0, - 0 - ]; - var found_near_planet = false; - with (obj_star) { - if (present_fleet[eFACTION.NECRONS] == 0) { - if (!array_contains(p_type, "Dead")) { - for (var plan = 1; plan <= planets; plan++) { - if (p_owner[plan] <= 5) { - found_near_planet = true; - nearest_planet_coords = [ - x, - y - ]; - break; - } - } - } - } - } - - if (found_near_planet) { - var tgt1, tgt2; - - necron_fleet2.action_x = nearest_planet_coords[0]; - necron_fleet2.action_y = nearest_planet_coords[1]; - necron_fleet2.alarm[4] = 1; - } - } - } - } - } - // traitors cults - var notixt; - var is_ork; - notixt = false; - - rando = irandom(99) + 1; - - if ((p_owner[i] == eFACTION.CHAOS) && (p_heresy[i] < 80)) { - p_heresy[i] += 1; - } - - if ((p_owner[i] != eFACTION.CHAOS) && (p_owner[i] != eFACTION.HERETICS) && (p_owner[i] != eFACTION.ELDAR) && (planets >= i) && (p_type[i] != "Dead") && (p_type[i] != "Craftworld")) { - success = false; - is_ork = p_owner[i] == eFACTION.ORK; - - if (!is_ork) { - //made a linear function for this while here...now the minimum for the roll is a bit higher, but - var score_to_beat = (3 / 4) * (p_heresy[i] + p_heresy_secret[i]) - 27.5; - - //if (p_heresy[i]+p_heresy_secret[i]>=25) and (rando<=3) then success=true; - //if (p_heresy[i]+p_heresy_secret[i]>=50) and (rando<=10) then success=true; - //if (p_heresy[i]+p_heresy_secret[i]>=70) and (rando<=25) then success=true; - //if (p_heresy[i]+p_heresy_secret[i]>=90) and (rando<=40) then success=true; - if (rando < score_to_beat) { - success = true; - } - } - - if (success && (p_pdf[i] == 0) && (p_guardsmen[i] == 0) && (p_tau[i] == 0) && (p_orks[i] == 0)) { - p_owner[i] = 10; - scr_alert("red", "owner", string(name) + " " + string(i) + " has fallen to heretics!", x, y); - - if (visited == 1) { - //visited variable check whether the star has been visited or not 1 for true 0 for false - if (p_type[i] == "Forge") { - dispo[i] -= 10; // 10 disposition decreases for the respective planet - obj_controller.disposition[3] -= 3; // 10 disposition decrease for the toaster Fetishest since they aren't that numerous - } else if (planet_feature_bool(p_feature[i], eP_FEATURES.SORORITAS_CATHEDRAL) || (p_type[i] == "Shrine")) { - dispo[i] -= 4; // similarly 10 disposition decrease, note those nurses are a bit pissy and - // and you can't easily gain their favor because you cannot ask them to "step down" from office. - obj_controller.disposition[5] -= 5; - } else { - // the missus diplomacy 0 is when they cringe when you enter the office and cannot ask them for a date. - } - } - } - - if (success && (p_type[i] != "Space Hulk")) { - rando = floor(random(100)) + 1; - // // // obj_controller.x=self.x;obj_controller.y=self.y; - if (is_garrison_force) { - rando -= total_garrison; - } - - var tixt = ""; - - // controls losing pdf due to heretic cults - var traitor_mod = 0; - - if (rando <= 40) { - notixt = true; - var garrison_mod = choose(0.05, 0.1, 0.15, 0.2); - - if (is_garrison_force) { - garrison_mod -= 0.01 * total_garrison; - } - - if (garrison_mod > 0) { - var lost = floor(p_pdf[i] * garrison_mod); - - if (p_pdf[i] <= 500) { - lost = p_pdf[i]; - p_traitors[i] = 1; - } - - p_pdf[i] -= lost; - - if (p_traitors[i] == 0) { - if (p_pdf[i] > 0) { - tixt = $"{scr_display_number(lost)} PDF killed in a rebellion on {planet_string}."; - } else if (p_pdf[i] == 0) { - tixt = $"Heretic cults have appeared in {planet_string}."; - } - - scr_alert("purple", "owner", tixt, x, y); - scr_event_log("purple", tixt, name); - } - } else { - tixt = $"Marine garrison prevents rebellion on {planet_string}"; - scr_alert("green", "owner", tixt, x, y); - scr_event_log("green", tixt, name); - p_heresy[i] -= irandom(5); - } - // Cult crushed; don't bother showing if there's already fighting going on over there - } else if ((rando >= 41) && (rando < 81) && (p_traitors[i] < 2)) { - if (is_garrison_force) { - traitor_mod = choose(1, 2); - } else { - traitor_mod = 2; - } - - p_traitors[i] = traitor_mod; - tixt = $"Heretic cults have appeared in {planet_string}."; - } else if ((rando >= 81) && (rando < 91) && (p_traitors[i] < 3)) { - // Minor uprising - if (is_garrison_force) { - traitor_mod = choose(2, 3); - } else { - traitor_mod = 3; - } - p_traitors[i] = traitor_mod; - tixt = $"Heretic cults have spread around {planet_string}."; - } // Major uprising - - // major and huge uprisings are impossible as long as a garrison of at least 10 marines is present - if ((rando >= 91) && (rando < 100) && (p_traitors[i] < 4)) { - notixt = true; - p_traitors[i] = 4; - - if ((obj_controller.faction_defeated[10] == 0) && (obj_controller.faction_gender[10] == 1)) { - p_traitors[i] = 5; - } - - var n_name = planet_numeral_name(i); - scr_popup("Heretic Revolt", $"A massive heretic uprising on {n_name} threatens to plunge the star system into chaos.", "chaos_cultist", ""); - scr_alert("red", "owner", $"Massive heretic uprising on {n_name}.", x, y); - scr_event_log("purple", $"Massive heretic uprising on {n_name}.", name); - } // Huge uprising - - if ((rando >= 100) && (p_traitors[i] < 5)) { - p_traitors[i] = 6; - p_owner[i] = 10; - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.DAEMONIC_INCURSION)); - - if (p_heresy[i] >= 80) { - p_heresy[i] = 95; - } else if (p_heresy[i] < 80) { - p_heresy[i] = 80; - } - - tixt = $"Daemonic incursion on {planet_numeral_name(i)}!"; - } // Oh god what - - if ((rando >= 41) && (!notixt) && tixt != "") { - scr_alert("red", "owner", tixt, x, y); - scr_event_log("purple", tixt, name); - } - // if (p_traitors[i]>2){obj_controller.x=self.x;obj_controller.y=self.y;} - } // End traitors cult - } - // Genestealer cults grow in number - if (planet_feature_bool(p_feature[i], eP_FEATURES.GENE_STEALER_CULT)) { - var cult = return_planet_features(p_feature[i], eP_FEATURES.GENE_STEALER_CULT)[0]; - cult.cult_age++; - adjust_influence(eFACTION.TYRANIDS, cult.cult_age / 100, i); - var planet_garrison = system_garrison[i - 1]; - if (cult.hiding) { - var find_nid_chance = 50 - planet_garrison.total_garrison; - if (p_influence[i][eFACTION.TYRANIDS] > 50) { - var find_cult_chance = irandom(50); - var alert_text = $"A hidden Genestealer Cult in {name} Has suddenly burst forth from hiding!"; - if (planet_garrison.garrison_force) { - var alert_text = $"A hidden Genestealer Cult in {name} Has been discovered by marine garrison!"; - find_cult_chance -= 25; - } - if (find_cult_chance < 1) { - cult.hiding = false; - scr_popup("System Lost", alert_text, "Genestealer Cult", ""); - owner = eFACTION.TYRANIDS; - scr_event_log("red", $"A hidden Genestealer Cult in {name} {i} has Started a revolt.", name); - p_tyranids[i] += 1; - } - } - } - if ((!cult.hiding) && (p_tyranids[i] <= 3) && (p_type[i] != "Space Hulk") && (p_influence[i][eFACTION.TYRANIDS] > 10)) { - var spread = 0; - rando = irandom(150); - rando -= p_influence[i][eFACTION.TYRANIDS]; - if (rando <= 15) { - spread = 1; - } - - if ((p_type[i] == "Lava") && (p_tyranids[i] == 2)) { - spread = 0; - } - if (((p_type[i] == "Ice") || (p_type[i] == "Desert")) && (p_tyranids[i] == 3)) { - spread = 0; - } - - if (spread == 1) { - p_tyranids[i] += 1; - } - } - if (p_influence[i][eFACTION.TYRANIDS] > 55) { - p_owner[i] = eFACTION.TYRANIDS; - } - } else if (p_influence[i][eFACTION.TYRANIDS] > 5) { - adjust_influence(eFACTION.TYRANIDS, -1, i); - if ((irandom(200) + (p_influence[i][eFACTION.TYRANIDS] / 10)) > 195) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.GENE_STEALER_CULT)); - } - } - - // Spread influence on controlled sector - if ((p_type[i] != "Space Hulk") && (p_type[i] != "Dead")) { - if ((p_heresy[i] < 70) && (owner == 10)) { - p_heresy[i] += 2; - } - if ((p_heresy[i] < 70) && (owner == 8)) { - var doggy = floor(random(100)) + 1; - if ((doggy <= 5) && (p_heresy[i] >= 20)) { - p_heresy[i] += 1; - } - } - } - - if ((p_type[i] == "Daemon") && (p_type[i] != "Space Hulk")) { - if (p_pdf[i] > 0) { - p_pdf[i] = 0; - } - if (p_guardsmen[i] > 0) { - p_guardsmen[i] = 0; - } - } + system_datas[i].refresh_data(); + system_datas[i].end_of_turn_population_influence_and_enemy_growth(); // if (p_heresy[i]>0) and (owner != eFACTION.CHAOS) then p_heresy[i]-=2; } // Tau rebellions @@ -463,7 +87,7 @@ function scr_enemy_ai_b() { } if (badd == 1) { - scr_alert("red", "owner", "Planet " + planet_string + " has succeeded to the Tau Empire!", x, y); + scr_alert("red", "owner", "Planet {planet_numeral_name(i)} has succeed ed to the Tau Empire!", x, y); if (visited == 1) { //visited variable checks whether the star has been visited by the chapter or not 1 for true 0 for false if (p_type[i] == "Forge") { diff --git a/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml b/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml index f02d88960..2c35b2f7e 100644 --- a/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml +++ b/scripts/scr_enemy_ai_c/scr_enemy_ai_c.gml @@ -161,7 +161,7 @@ function scr_enemy_ai_c() { } /*if (fleet!=0){ if (instance_exists(fleet)) then with(fleet){ - var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); + var ii=round(standard_fleet_strength_calc()); if (ii<=1) then ii=1;image_index=ii; } }*/ @@ -487,7 +487,7 @@ function scr_enemy_ai_c() { } /*if (fleet!=0){ if (instance_exists(fleet)) then with(fleet){ - var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); + var ii=round(standard_fleet_strength_calc()); if (ii<=1) then ii=1;image_index=ii; } }*/ @@ -546,18 +546,53 @@ function scr_enemy_ai_c() { } } - with (obj_star) { - if (x < -10000) { - x += 20000; - y += 20000; - } - if (x < -10000) { - x += 20000; - y += 20000; - } - if (x < -10000) { - x += 20000; - y += 20000; - } - } + // Tyranids here + var i=0; + repeat(planets){i+=1; + if (p_tyranids[i]>=5) and (planets>=i) and (p_player[i]+p_orks[i]+p_guardsmen[i]+p_pdf[i]+p_chaos[i]=0){ + var ship=scr_orbiting_fleet(eFACTION.TYRANIDS); + if (ship!="none") and (p_type[i]!="Dead") and (array_length(p_feature[i])!=0){ + if (ship.capital_number>0){ + if (planet_feature_bool(p_feature[i], eP_FEATURES.RECLAMATION_POOLS) ==1){ + p_tyranids[i]=0; + if (p_type[i]="Death") or (p_type[i]="Hive") then ship.capital_number+=choose(0,1,1); + ship.capital_number+=1; + ship.escort_number+=3; + ship.image_index=round(standard_fleet_strength_calc()); + p_type[i]="Dead"; + delete_features(p_feature[i], eP_FEATURES.RECLAMATION_POOLS);// show_message("D"); + if (planets=1) and (p_type[1]="Dead") then image_alpha=0.33; + if (planets=2) and (p_type[1]="Dead") and (p_type[2]="Dead") then image_alpha=0.33; + if (planets=3) and (p_type[1]="Dead") and (p_type[2]="Dead") and (p_type[3]="Dead") then image_alpha=0.33; + if (planets=4) and (p_type[1]="Dead") and (p_type[2]="Dead") and (p_type[3]="Dead") and (p_type[4]="Dead") then image_alpha=0.33; + + + // if image_alpha = 0.33 then send the ship somewhere new + + } + if (planet_feature_bool(p_feature[i], eP_FEATURES.CAPILLARY_TOWERS)==1) and (p_type[i]!="Dead"){ + p_population[i]=floor(p_population[i]*0.3); + } + if (planet_feature_bool(p_feature[i], eP_FEATURES.CAPILLARY_TOWERS)==1) and (p_type[i]!="Dead"){ + p_feature[i]=[]; + array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CAPILLARY_TOWERS), new NewPlanetFeature(eP_FEATURES.RECLAMATION_POOLS)); + p_population[i]=0;// show_message("C"); + } + if (planet_feature_bool(p_feature[i], eP_FEATURES.CAPILLARY_TOWERS)==0) and (planet_feature_bool(p_feature[i], eP_FEATURES.RECLAMATION_POOLS)==0) and (p_type[i]!="Dead"){ + array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.CAPILLARY_TOWERS));// show_message("B"); + } + } + } + } + } + + + + with(obj_star){ + if (x<-10000){x+=20000;y+=20000;} + if (x<-10000){x+=20000;y+=20000;} + if (x<-10000){x+=20000;y+=20000;} + } + + } 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 bea9a3fde..db6db7814 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -341,10 +341,10 @@ function scr_enemy_ai_d() { fleet.escort_number = round(random_range(12, 27)); /*fleet.capital_number=choose(5,6); - fleet.frigate_number=round(random_range(4,8)); - fleet.escort_number=round(random_range(8,18));*/ + fleet.frigate_number=round(random_range(4,8)); + fleet.escort_number=round(random_range(8,18));*/ - fleet.image_index = floor(fleet.capital_number + (fleet.frigate_number / 2) + (fleet.escort_number / 4)); + fleet.image_index = round(standard_fleet_strength_calc()); fleet.image_alpha = 0; fleet.action_x = x; @@ -439,11 +439,11 @@ function scr_enemy_ai_d() { if (!already_enroute) { var pop_doner_options = []; //this stops needless repeats of searches - if (!struct_exists(obj_controller.end_turn_insights, "population_doners")) { - pop_doner_options = find_population_doners(); + if (!struct_exists(obj_controller.end_turn_insights, "population_donors")) { + pop_doner_options = find_population_donors(); } - obj_controller.end_turn_insights.population_doners = pop_doner_options; - pop_doner_options = obj_controller.end_turn_insights.population_doners; + obj_controller.end_turn_insights.population_donors = pop_doner_options; + pop_doner_options = obj_controller.end_turn_insights.population_donors; var deletion = -1; for (var i = 0; i < array_length(pop_doner_options); i++) { @@ -535,13 +535,12 @@ function scr_enemy_ai_d() { // Local problems will go here var planet; - for (var i = 0; i <= planets; i++) { - planet = i + 1; - if (i < array_length(system_garrison)) { - var garrison = system_garrison[i]; - if (garrison.garrison_force) { - if (garrison.garrison_disposition_change(self, planet) != "none") { - dispo[planet] += garrison.dispo_change; + for (var planet=1;planet<=planets;planet++){ + if (planet < array_length(system_garrison)) { + var _garrison = system_garrison[planet]; + if (_garrison.garrison_force) { + if (_garrison.garrison_disposition_change(self, planet) != "none") { + dispo[planet] += _garrison.dispo_change; } } } diff --git a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml index a196e4d44..bca841ecf 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -714,7 +714,8 @@ function scr_enemy_ai_e() { halfpop = p_max_population[run] / 2; if (array_length(p_feature[run])) { - var planet_data = new PlanetData(run, self); + var _planet_data = new PlanetData(run, self); + _planet_data = system_datas[run]; // Transforming billions pop number to a real number so the code can handle it // Otherwise, 3 and a half billions get translated as 3,50 instead of 3500000000 @@ -768,6 +769,8 @@ function scr_enemy_ai_e() { } } } + _planet_data.refresh_data(); + _planet_data.check_old_battles_feature(); } // End p_feature!="" // Work on upgrades diff --git a/scripts/scr_event_code/scr_event_code.gml b/scripts/scr_event_code/scr_event_code.gml index baba59bc3..0564e4337 100644 --- a/scripts/scr_event_code/scr_event_code.gml +++ b/scripts/scr_event_code/scr_event_code.gml @@ -31,220 +31,248 @@ function find_event(e_id) { return _event_found; } -function event_end_turn_action() { - var _event_length = array_length(event); - for (var i = _event_length - 1; i >= 0; i--) { - var _event = event[i]; - if (_event.e_id == "" || _event.duration < 0) { - array_delete(event, i, 1); - continue; + +function event_remove_player_serf(_event) { + var _star_name = _event.system; + var _event_star = find_star_by_name(_event.system); + var _planet = _event.planet; + if (_event_star != "none") { + _event_star.dispo[_planet] = -10; // Resets + var twix = $"Inquisition executes Chapter Serf in control of {planet_numeral_name(_planet, _event_star)} and installs a new Planetary Governor."; + if (_event_star.p_owner[_planet] == eFACTION.PLAYER) { + _event_star.p_owner[_planet] = _event_star.p_first[_planet]; } + scr_alert("", "", twix, 0, 0); + scr_event_log("", twix, _star_name); + } +} - _event.duration -= 1; +function event_game_over_man(_event) { + obj_controller.alarm[8] = 1; +} - if (_event.duration == 0) { - if (_event.e_id == "game_over_man") { - obj_controller.alarm[8] = 1; - } - // Removes planetary governor installed by the chapter - if (_event.e_id == "remove_surf") { - var _star_name = _event.system; - var _event_star = find_star_by_name(_event.system); - var _planet = _event.planet; - if (_event_star != "none") { - _event_star.dispo[_planet] = -10; // Resets - var twix = $"Inquisition executes Chapter Serf in control of {planet_numeral_name(_planet, _event_star)} and installs a new Planetary Governor."; - if (_event_star.p_owner[_planet] == eFACTION.PLAYER) { - _event_star.p_owner[_planet] = _event_star.p_first[_planet]; - } - scr_alert("", "", twix, 0, 0); - scr_event_log("", twix, _star_name); - } - } else if (_event.e_id == "enemy_imperium") { - // Changes relation to good - scr_alert("green", "enemy", "You have made amends with your enemy in the Imperium.", 0, 0); - disposition[eFACTION.IMPERIUM] += 20; - scr_event_log("", "Amends made with Imperium."); - } else if (_event.e_id == "enemy_mechanicus") { - scr_alert("green", "enemy", "You have made amends with your Mechanicus enemy.", 0, 0); - disposition[eFACTION.MECHANICUS] += 20; - scr_event_log("", "Amends made with Mechanicus enemy."); - } else if (_event.e_id == "enemy_inquisition") { - scr_alert("green", "enemy", "You have made amends with your enemy in the Inquisition.", 0, 0); - disposition[eFACTION.INQUISITION] += 20; - scr_event_log("", "Amends made with Inquisition enemy."); - } else if (_event.e_id == "enemy_ecclesiarchy") { - scr_alert("green", "enemy", "You have made amends with your enemy in the Ecclesiarchy.", 0, 0); - disposition[eFACTION.ECCLESIARCHY] += 20; - scr_event_log("", "Amends made with Ecclesiarchy enemy."); - } else if (_event.e_id == "imperium_daemon") { - // Sector commander losses its mind - var alert_string = $"Sector Commander {faction_leader[eFACTION.IMPERIUM]} has gone insane."; - scr_alert("red", "lol", alert_string, 0, 0); - faction_defeated[eFACTION.IMPERIUM] = 1; - scr_event_log("red", alert_string); +function event_enemy_imperium(_event) { + // Changes relation to good + scr_alert("green", "enemy", "You have made amends with your enemy in the Imperium.", 0, 0); + disposition[eFACTION.IMPERIUM] += 20; + scr_event_log("", "Amends made with Imperium."); +} + +function event_enemy_mechanicus(_event) { + scr_alert("green", "enemy", "You have made amends with your Mechanicus enemy.", 0, 0); + disposition[eFACTION.MECHANICUS] += 20; + scr_event_log("", "Amends made with Mechanicus enemy."); +} + +function event_enemy_inquisition(_event) { + scr_alert("green", "enemy", "You have made amends with your enemy in the Inquisition.", 0, 0); + disposition[eFACTION.INQUISITION] += 20; + scr_event_log("", "Amends made with Inquisition enemy."); +} + +function event_enemy_ecclesiarchy(_event) { + scr_alert("green", "enemy", "You have made amends with your enemy in the Ecclesiarchy.", 0, 0); + disposition[eFACTION.ECCLESIARCHY] += 20; + scr_event_log("", "Amends made with Ecclesiarchy enemy."); +} + +function event_imperium_daemon(_event) { + // Sector commander losses its mind + var alert_string = $"Sector Commander {faction_leader[eFACTION.IMPERIUM]} has gone insane."; + scr_alert("red", "lol", alert_string, 0, 0); + faction_defeated[eFACTION.IMPERIUM] = 1; + scr_event_log("red", alert_string); +} + +function event_chaos_invasion(_event) { + // Starts chaos invasion + var xx = 0, yy = 0, flee = 0, dirr = 0; + var star_id = scr_random_find(1, true, "", ""); + if (star_id != undefined) { + scr_event_log("purple", $"Chaos Fleets exit the warp near the {star_id.name} system.", star_id.name); + for (var j = 0; j < 4; j++) { + dirr += irandom_range(50, 100); + xx = star_id.x + lengthdir_x(72, dirr); + yy = star_id.y + lengthdir_y(72, dirr); + flee = instance_create(xx, yy, obj_en_fleet); + flee.owner = eFACTION.CHAOS; + flee.sprite_index = spr_fleet_chaos; + flee.image_index = 4; + flee.capital_number = choose(0, 1); + flee.frigate_number = choose(2, 3); + flee.escort_number = choose(4, 5, 6); + flee.cargo_data.csm = true; + obj_controller.chaos_fleets += 1; + flee.action_x = star_id.x; + flee.action_y = star_id.y; + with (flee) { + set_fleet_movement(); } - // Starts chaos invasion - if (_event.e_id == "chaos_invasion") { - var xx = 0, yy = 0, flee = 0, dirr = 0; - var star_id = scr_random_find(1, true, "", ""); - if (star_id != undefined) { - scr_event_log("purple", $"Chaos Fleets exit the warp near the {star_id.name} system.", star_id.name); - for (var j = 0; j < 4; j++) { - dirr += irandom_range(50, 100); - xx = star_id.x + lengthdir_x(72, dirr); - yy = star_id.y + lengthdir_y(72, dirr); - flee = instance_create(xx, yy, obj_en_fleet); - flee.owner = eFACTION.CHAOS; - flee.sprite_index = spr_fleet_chaos; - flee.image_index = 4; - flee.capital_number = choose(0, 1); - flee.frigate_number = choose(2, 3); - flee.escort_number = choose(4, 5, 6); - flee.cargo_data.csm = true; - obj_controller.chaos_fleets += 1; - flee.action_x = star_id.x; - flee.action_y = star_id.y; - with (flee) { - set_fleet_movement(); - } - } + } + } +} + +function event_ship_construction(_event) { + // Ships construction + var new_ship_event = _event.ship_class; + var active_forges = []; + var chosen_star = false; + with (obj_star) { + if (owner == eFACTION.MECHANICUS) { + for (f = 1; f <= planets; f++) { + if ((p_type[f] == "Forge") && (p_owner[f] == eFACTION.MECHANICUS)) { + array_push(active_forges, new PlanetData(f, self)); } } - // Ships construction - if (_event.e_id == "ship_construction") { - var new_ship_event = _event.ship_class; - var active_forges = []; - var chosen_star = false; - with (obj_star) { - if (owner == eFACTION.MECHANICUS) { - for (f = 1; f <= planets; f++) { - if ((p_type[f] == "Forge") && (p_owner[f] == eFACTION.MECHANICUS)) { - array_push(active_forges, new PlanetData(f, self)); - } - } - } - } - if (array_length(active_forges) > 0) { - var ship_spawn = active_forges[irandom(array_length(active_forges) - 1)]; - var _new_player_fleet = instance_create(ship_spawn.system.x, ship_spawn.system.y, obj_p_fleet); + } + } + if (array_length(active_forges) > 0) { + var ship_spawn = active_forges[irandom(array_length(active_forges) - 1)]; + var _new_player_fleet = instance_create(ship_spawn.system.x, ship_spawn.system.y, obj_p_fleet); + // Creates the ship + var last_ship = new_player_ship(new_ship_event, ship_spawn.system.name); - // Creates the ship - var last_ship = new_player_ship(new_ship_event, ship_spawn.system.name); + add_ship_to_fleet(last_ship, _new_player_fleet); - add_ship_to_fleet(last_ship, _new_player_fleet); + // show_message(string(obj_ini.ship_class[last_ship])+":"+string(obj_ini.ship[last_ship])); - // show_message(string(obj_ini.ship_class[last_ship])+":"+string(obj_ini.ship[last_ship])); + if (obj_ini.ship_size[last_ship] != 1) { + scr_popup("Ship Constructed", $"Your new {obj_ini.ship_class[last_ship]} '{obj_ini.ship[last_ship]}' has finished being constructed. It is orbiting {ship_spawn.system.name} and awaits its maiden voyage.", "shipyard", ""); + } + if (obj_ini.ship_size[last_ship] == 1) { + scr_popup("Ship Constructed", $"Your new {obj_ini.ship_class[last_ship]} Escort '{obj_ini.ship[last_ship]}' has finished being constructed. It is orbiting {ship_spawn.system.name} and awaits its maiden voyage.", "shipyard", ""); + } + var bob = instance_create(ship_spawn.system.x + 16, ship_spawn.system.y - 24, obj_star_event); + bob.image_alpha = 1; + bob.image_speed = 1; + } + if (array_length(active_forges) == 0) { + _event.duration = 1; + scr_popup("Ship Construction Halted", $"A lack of suitable forge worlds in the system has halted construction of your requested ship.", "shipyard", ""); + } +} - if (obj_ini.ship_size[last_ship] != 1) { - scr_popup("Ship Constructed", $"Your new {obj_ini.ship_class[last_ship]} '{obj_ini.ship[last_ship]}' has finished being constructed. It is orbiting {ship_spawn.system.name} and awaits its maiden voyage.", "shipyard", ""); - } - if (obj_ini.ship_size[last_ship] == 1) { - scr_popup("Ship Constructed", $"Your new {obj_ini.ship_class[last_ship]} Escort '{obj_ini.ship[last_ship]}' has finished being constructed. It is orbiting {ship_spawn.system.name} and awaits its maiden voyage.", "shipyard", ""); - } - var bob = instance_create(ship_spawn.system.x + 16, ship_spawn.system.y - 24, obj_star_event); - bob.image_alpha = 1; - bob.image_speed = 1; - } - if (array_length(active_forges) == 0) { - _event.duration = 1; - scr_popup("Ship Construction Halted", $"A lack of suitable forge worlds in the system has halted construction of your requested ship.", "shipyard", ""); - } - } - // Spare the inquisitor - if (_event.e_id == "inquisitor_spared") { - hunt_inquisition_spared_inquisitor_consequence(_event); - } +function event_inquisitor_spared(_event) { + // Spare the inquisitor + hunt_inquisition_spared_inquisitor_consequence(_event); +} - if (_event.e_id == "strange_building") { - var marine_name = _event.name; - var comp = _event.company; - var marine_num = _event.marine; - var _unit = fetch_unit([marine_num, comp]); - var item = _event.crafted; +function event_strange_building(_event) { + var marine_name = _event.name; + var comp = _event.company; + var marine_num = _event.marine; + var _unit = fetch_unit([marine_num, comp]); + var item = _event.crafted; - LOGGER.warning($"comp: {comp}, marine_num: {marine_num}"); + LOGGER.warning($"comp: {comp}, marine_num: {marine_num}"); - var killy = 0, tixt = $"{obj_ini.role[100][16]} {marine_name} has finished his work- "; + var killy = 0, tixt = $"{obj_ini.role[100][16]} {marine_name} has finished his work- "; - if (item == "Icon") { - tixt += $"it is a {global.chapter_name} Icon wrought in metal, finely decorated. Pride for his chapter seems to have overtaken him. There are no corrections to be made and the item is placed where many may view it."; - } - if (item == "Statue") { - tixt += "it is a small, finely crafted statue wrought in metal. The " + string(obj_ini.role[100][16]) + " is scolded for the waste of material, but none daresay the quality of the piece."; - } - if (item == "Bike") { - scr_add_item("Bike", 1); - tixt += "it is a finely crafted Bike, conforming mostly to STC standards. The other " + string(obj_ini.role[100][16]) + " are surprised at the rapid pace of his work."; - } - if (item == "Rhino") { - scr_add_vehicle("Rhino", 0, {}, "Storm Bolter", "Storm Bolter", "", "Artificer Hull", "Dozer Blades"); - tixt += "it is a finely crafted Rhino, conforming to STC standards. The other " + string(obj_ini.role[100][16]) + " are surprised at the rapid pace of his work."; - } - if (item == "Artifact") { - scr_event_log("", string(obj_ini.role[100][16]) + " " + string(marine_name) + " constructs an Artifact."); - var _last_artifact = scr_add_artifact("random_nodemon", "", 0); + if (item == "Icon") { + tixt += $"it is a {global.chapter_name} Icon wrought in metal, finely decorated. Pride for his chapter seems to have overtaken him. There are no corrections to be made and the item is placed where many may view it."; + } + if (item == "Statue") { + tixt += "it is a small, finely crafted statue wrought in metal. The " + string(obj_ini.role[100][16]) + " is scolded for the waste of material, but none daresay the quality of the piece."; + } + if (item == "Bike") { + scr_add_item("Bike", 1); + tixt += "it is a finely crafted Bike, conforming mostly to STC standards. The other " + string(obj_ini.role[100][16]) + " are surprised at the rapid pace of his work."; + } + if (item == "Rhino") { + scr_add_vehicle("Rhino", 0, {}, "Storm Bolter", "Storm Bolter", "", "Artificer Hull", "Dozer Blades"); + tixt += "it is a finely crafted Rhino, conforming to STC standards. The other " + string(obj_ini.role[100][16]) + " are surprised at the rapid pace of his work."; + } + if (item == "Artifact") { + scr_event_log("", string(obj_ini.role[100][16]) + " " + string(marine_name) + " constructs an Artifact."); + var _last_artifact = scr_add_artifact("random_nodemon", "", 0); - tixt += $"some form of divine inspiration has seemed to have taken hold of him. An artifact {obj_ini.artifact[_last_artifact]} has been crafted."; - } - if (item == "baby") { - _unit.edit_corruption(choose(8, 12, 16, 20)); - tixt += "some form of horrendous statue. A weird amalgram of limbs and tentacles, the sheer atrocity of it is made worse by the tiny, baby-like form, the once natural shape of a human child twisted nearly beyond recognition."; - } else if (item == "robot") { - _unit.edit_corruption(choose(2, 4, 6, 8, 10)); - tixt += $"some form of small, box-like robot. It seems to teeter around haphazardly, nearly falling over with each step. {_unit.name()} maintains that it has no AI, though the other " + string(obj_ini.role[100][16]) + " express skepticism."; - _unit.add_trait("tech_heretic"); - } else if (item == "demon") { - _unit.edit_corruption(choose(8, 12, 16, 20)); - tixt += "some form of horrendous statue. What was meant to be some sort of angel, or primarch, instead has a mishappen face that is hardly human in nature. Between the fetid, ragged feathers and empty sockets it is truly blasphemous."; - _unit.add_trait("tech_heretic"); - } else if (item == "fusion") { - //TODO if tech heretic chosen don't kill the dude - // _unit.corruption+=choose(70); - tixt += $"some kind of ill-mannered ascension. One of your battle-brothers enters the armamentarium to find {marine_name} fused to a vehicle, his flesh twisted and submerged into the frame. Mechendrites and weapons fire upon the marine without warning, a windy scream eminating from the abomination. It takes several battle-brothers to take out what was once a " + string(obj_ini.role[100][16]) + "."; - - // This is causing the problem - - scr_kill_unit(comp, marine_num); + tixt += $"some form of divine inspiration has seemed to have taken hold of him. An artifact {obj_ini.artifact[_last_artifact]} has been crafted."; + } + if (item == "baby") { + _unit.edit_corruption(choose(8, 12, 16, 20)); + tixt += "some form of horrendous statue. A weird amalgram of limbs and tentacles, the sheer atrocity of it is made worse by the tiny, baby-like form, the once natural shape of a human child twisted nearly beyond recognition."; + } else if (item == "robot") { + _unit.edit_corruption(choose(2, 4, 6, 8, 10)); + tixt += $"some form of small, box-like robot. It seems to teeter around haphazardly, nearly falling over with each step. {_unit.name()} maintains that it has no AI, though the other " + string(obj_ini.role[100][16]) + " express skepticism."; + _unit.add_trait("tech_heretic"); + } else if (item == "demon") { + _unit.edit_corruption(choose(8, 12, 16, 20)); + tixt += "some form of horrendous statue. What was meant to be some sort of angel, or primarch, instead has a mishappen face that is hardly human in nature. Between the fetid, ragged feathers and empty sockets it is truly blasphemous."; + _unit.add_trait("tech_heretic"); + } else if (item == "fusion") { + //TODO if tech heretic chosen don't kill the dude + // _unit.corruption+=choose(70); + tixt += $"some kind of ill-mannered ascension. One of your battle-brothers enters the armamentarium to find {marine_name} fused to a vehicle, his flesh twisted and submerged into the frame. Mechendrites and weapons fire upon the marine without warning, a windy scream eminating from the abomination. It takes several battle-brothers to take out what was once a " + string(obj_ini.role[100][16]) + "."; + + // This is causing the problem + + scr_kill_unit(comp, marine_num); + with (obj_ini) { + scr_company_order(0); + } + } + if (item != "fusion") { + var options = [ + { + str1: "Execute the heretic", + choice_func: function() { + scr_kill_unit(pop_data.company, pop_data.marine_number); + var company_to_order = pop_data.company; with (obj_ini) { - scr_company_order(0); + scr_company_order(company_to_order); } - } - if (item != "fusion") { - var options = [ - { - str1: "Execute the heretic", - choice_func: function() { - scr_kill_unit(pop_data.company, pop_data.marine_number); - var company_to_order = pop_data.company; - with (obj_ini) { - scr_company_order(company_to_order); - } - popup_default_close(); - }, - }, - { - str1: "Move him to the Penitorium", - choice_func: function() { - popup_default_close(); - }, - }, - { - str1: "I see no problem", - choice_func: popup_default_close, - } - ]; - var _pop_data = { - options: options, - marine_number: marine_num, - company: comp, - marine_name: marine_name, - }; - } else { - _pop_data = ""; - } + popup_default_close(); + }, + }, + { + str1: "Move him to the Penitorium", + choice_func: function() { + popup_default_close(); + }, + }, + { + str1: "I see no problem", + choice_func: popup_default_close, + } + ]; + var _pop_data = { + options: options, + marine_number: marine_num, + company: comp, + marine_name: marine_name, + }; + } else { + _pop_data = ""; + } + + scr_popup("He Built It", tixt, "tech_build", _pop_data); +} + + +function event_end_turn_action() { + var _event_length = array_length(event); + for (var i = _event_length - 1; i >= 0; i--) { + var _event = event[i]; + if (_event.e_id == "" || _event.duration < 0) { + array_delete(event, i, 1); + continue; + } - scr_popup("He Built It", tixt, "tech_build", _pop_data); + _event.duration -= 1; + + if (_event.duration == 0) { + switch (_event.e_id) { + case "game_over_man": event_game_over_man(_event); break; + case "remove_surf": event_remove_player_serf(_event); break; + case "enemy_imperium": event_enemy_imperium(_event); break; + case "enemy_mechanicus": event_enemy_mechanicus(_event); break; + case "enemy_inquisition": event_enemy_inquisition(_event); break; + case "enemy_ecclesiarchy": event_enemy_ecclesiarchy(_event); break; + case "imperium_daemon": event_imperium_daemon(_event); break; + case "chaos_invasion": event_chaos_invasion(_event); break; + case "ship_construction": event_ship_construction(_event); break; + case "inquisitor_spared": event_inquisitor_spared(_event); break; + case "strange_building": event_strange_building(_event); break; } if (_event.duration <= 0) { array_delete(event, i, 1); @@ -254,6 +282,7 @@ function event_end_turn_action() { } } + function handle_discovered_governor_assasinations() { for (var i = 0; i < array_length(obj_controller.event); i++) { var _event = obj_controller.event[i]; @@ -296,84 +325,6 @@ function handle_discovered_governor_assasinations() { } } -function strange_build_event() { - LOGGER.info("RE: Fey Mood"); - var _search_params = { - trait: [ - "crafter", - "tinkerer" - ], - trait_any: true, - }; - var marine_and_company = scr_random_marine("", 0, _search_params); - if (marine_and_company == "none") { - marine_and_company = scr_random_marine("", 0, "none"); - } - if (marine_and_company != "none") { - var marine = marine_and_company[0]; - var company = marine_and_company[1]; - var text = ""; - var _unit = fetch_unit(marine_and_company); - var role = _unit.role(); - text = _unit.name_role(); - text += " is taken by a strange mood and starts building!"; - - var crafted_object; - var craft_roll = roll_dice_chapter(1, 100, "low"); - var heritical_item = false; - - //this bit should be improved, idk what duke was checking for here - //TODO make craft chance reflective of crafters skill, rewards players for having skilled tech area - if (scr_has_disadv("Tech-Heresy")) { - craft_roll += 20; - } - if (_unit.has_trait("tech_heretic")) { - craft_roll += 60; - } - if (scr_has_adv("Crafter")) { - if (craft_roll > 80) { - craft_roll -= 10; - } - if (craft_roll < 60) { - craft_roll += 10; - } - } - - if (craft_roll <= 50) { - crafted_object = choose("Icon", "Icon", "Statue"); - } else if ((craft_roll > 50) && (craft_roll <= 60)) { - crafted_object = choose("Bike", "Rhino"); - } else if ((craft_roll > 60) && (craft_roll <= 80)) { - crafted_object = "Artifact"; - } else { - crafted_object = choose("baby", "robot", "demon", "fusion"); - heritical_item = 1; - } - - add_event({e_id: "strange_building", duration: 1, name: _unit.name(), company: company, marine: marine, crafted: crafted_object}); - - scr_popup("Can He Build marine?!?", text, "tech_build", ""); - - var marine_is_planetside = _unit.planet_location > 0; - if (marine_is_planetside && heritical_item) { - var _system = find_star_by_name(_unit.location_string); - var _planet = _unit.planet_location; - if (_system != "none") { - with (_system) { - p_hurssy[_planet] += 6; - p_hurssy_time[_planet] = 2; - } - } - } else if (!marine_is_planetside && heritical_item) { - var _fleet = find_ships_fleet(_unit.ship_location); - if (_fleet != "none") { - //the intended code for here was to add some sort of chaos event on the ship stashed up ready to fire in a few turns - } - } - return true; - } - return false; -} function make_faction_enemy_event() { LOGGER.info("RE: Enemy"); @@ -436,11 +387,3 @@ function make_faction_enemy_event() { } return false; } - -function event_dispose_of_mutated_gene() { - if (pop_data.percent_remove > 0) { - var _removal_amount = ceil(obj_controller.gene_seed * (pop_data.percent_remove / 100)); - obj_controller.gene_seed -= _removal_amount; - } - popup_default_close(); -} diff --git a/scripts/scr_fleet_events/scr_fleet_events.gml b/scripts/scr_fleet_events/scr_fleet_events.gml new file mode 100644 index 000000000..9e7b1b1b5 --- /dev/null +++ b/scripts/scr_fleet_events/scr_fleet_events.gml @@ -0,0 +1,60 @@ +function add_event_to_fleet(event , fleet){ + event.fleet_uid = fleet.uid; + array_push(fleet.events, event); +} + + + +function FleetEvent(_event_data) constructor{ + + self.fleetevent_data = _event_data; + + static load_json_data = function(data){ + var names = variable_struct_get_names(data); + for (var i = 0; i < array_length(names); i++) { + variable_struct_set(self, names[i], variable_struct_get(data, names[i])) + } + } + + timer = -1; + + state = "increment"; + + static turn_sequence = function(){ + if (struct_exists(self , "turn_end")){ + call_fleet_event_function(turn_end); + } + + if (struct_exists(self , "timer") && timer > 0){ + timer--; + + if (timer == 0 ){ + if (struct_exists(self,"timer_end")){ + call_fleet_event_function(timer_end); + } + state = "destroy"; + } + } + } + + static destroy_sequence = function(){ + if (struct_exists(self , "destroy")){ + call_fleet_event_function(destroy); + } + } + + static call_fleet_event_function = function(_func_name){ + if (struct_exists(fleet_event_functions,_func_name)){ + fleet_event_functions[$ _func_name](); + } + } + + static fleet_event_functions = { + "deliver_trophy_mission_timed_out" : deliver_trophy_mission_timed_out, + "deliver_trophy_mission_fleet_destroyed" : deliver_trophy_mission_fleet_destroyed, + "deliver_trophy_end_turn_check" :deliver_trophy_end_turn_check, + "mech_fleet_explore_battle_grounds":mech_fleet_explore_battle_grounds + } + + +} \ No newline at end of file diff --git a/scripts/scr_fleet_events/scr_fleet_events.yy b/scripts/scr_fleet_events/scr_fleet_events.yy new file mode 100644 index 000000000..9ab241e72 --- /dev/null +++ b/scripts/scr_fleet_events/scr_fleet_events.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"scr_fleet_events", + "isCompatibility":false, + "isDnD":false, + "name":"scr_fleet_events", + "parent":{ + "name":"fleet", + "path":"folders/Scripts/fleet.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 36ce15632..5a7073aca 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -12,6 +12,17 @@ function distribute_strength_to_fleet(strength, fleet) { } } + +function standard_fleet_strength_calc(fleet = "none"){ + if (fleet == "none"){ + return capital_number + (frigate_number/2) + (escort_number/4); + } else { + with (fleet){ + return standard_fleet_strength_calc(); + } + } +} + /// @mixin obj_en_fleet function random_sector_exit_point(){ action_x = choose(room_width * -1, room_width * 2); @@ -28,11 +39,12 @@ function in_room(object = undefined){ } //to be run within with scope -function set_fleet_target(targ_x, targ_y, final_target) { - action_x = targ_x; - action_y = targ_y; - target = final_target; - action_eta = floor(point_distance(x, y, targ_x, targ_y) / 128) + 1; +//@mixin obj_en_fleet +function set_fleet_target(targ_x, targ_y, final_target){ + action_x = targ_x; + action_y = targ_y; + target = final_target; + action_eta = floor(point_distance(x,y,targ_x,targ_y)/128)+1; } function scr_valid_fleet_target(target) { @@ -50,6 +62,18 @@ function scr_valid_fleet_target(target) { return valid; } +function get_fleet_uid(search_uid){ + var _fleet = -1; + with (obj_en_fleet){ + if (uid == search_uid){ + _fleet = id; + break; + } + } + + return _fleet; +} + function fleets_next_location(fleet = "none", visited = []) { var targ_location = "none"; @@ -62,11 +86,11 @@ function fleets_next_location(fleet = "none", visited = []) { array_push(visited, fleet.id); // Check if the fleet has a 'target' variable - if (variable_instance_exists(fleet, "target")) { + if (fleet.action != "" && variable_instance_exists(fleet, "target")) { // If the target is valid and not already in the visited list, proceed recursively var fleet_target_valid = scr_valid_fleet_target(fleet.target); if (!fleet_target_valid) { - fleet.target = 0; + fleet.target = noone; } if (fleet_target_valid && !array_contains(visited, fleet.target.id)) { // Recursive call with the target and the updated visited list @@ -665,17 +689,22 @@ function fleet_arrival_logic() { cur_star = instance_nearest(action_x, action_y, obj_star); x = cur_star.x; y = cur_star.y; - sta = instance_nearest(action_x, action_y, obj_star); + sta=instance_nearest(action_x,action_y,obj_star); + action_x=0; + action_y=0; is_orbiting(); + arrival_logic_finished = false; + // cur_star.present_fleets+=1;if (owner = eFACTION.TAU) then cur_star.tau_fleets+=1; - - if (owner == eFACTION.MECHANICUS) { - if (trade_goods == "mars_spelunk1") { - trade_goods = "mars_spelunk2"; - action_x = home_x; - action_y = home_y; - action_eta = 52; + + + if (owner == eFACTION.MECHANICUS){ + if (trade_goods == "mars_spelunk1"){ + trade_goods="mars_spelunk2"; + action_x=home_x; + action_y=home_y; + action_eta=52; action = "move"; exit; } else if (trade_goods == "mars_spelunk2") { @@ -792,42 +821,7 @@ function fleet_arrival_logic() { exit; } } - - /*if (owner = eFACTION.IMPERIUM) and (guardsmen>0){// 135 ; guardsmen onto planet - var en_p,en_planets,land,i; - i=0;en_planets=0;land=0; - - if (sta.x=home_x) and (sta.y=home_y){ - repeat(4){i+=1; - en_p[i]=0; - if (sta.p_owner[i]<=5){en_p[i]=1;en_planets+=1;} - } - - if (guardsmen>0) and (en_planets>0){ - land=floor(guardsmen/en_planets); - i=0; - repeat(4){i+=1; - if (en_p[i]=1){guardsmen-=land;sta.p_guardsmen[i]+=land;} - } - if (guardsmen<5) then guardsmen=0; - } - } - if (sta.owner>5) or ((sta.owner = eFACTION.PLAYER) and (obj_controller.faction_status[eFACTION.IMPERIUM]="War")){ - repeat(4){i+=1; - en_p[i]=0; - if (sta.p_player[i]>0) and (obj_controller.faction_status[eFACTION.IMPERIUM]="War"){en_p[i]=1;en_planets+=1;} - } - - if (guardsmen>0) and (en_planets>0){ - land=floor(guardsmen/en_planets); - i=0; - repeat(4){i+=1; - if (en_p[i]=1){guardsmen-=land;sta.p_guardsmen[i]+=land;} - } - if (guardsmen<5) then guardsmen=0; - } - } - }*/ + if (owner == eFACTION.INQUISITION) { if (string_count("DELETE", trade_goods) > 0) { @@ -848,9 +842,18 @@ function fleet_arrival_logic() { } else if (owner == eFACTION.TYRANIDS) { var mess = 1, plap = instance_nearest(action_x, action_y, obj_p_fleet); - if (instance_exists(plap)) { - if (point_distance(plap.x, plap.y, action_x, action_y) < 80) { - mess = 0; + if (string_count("DELETE",trade_goods)>0) then instance_destroy(); + if (obj_controller.known[eFACTION.INQUISITION]=0) then obj_controller.known[eFACTION.INQUISITION]=1; + } + + else if (owner=eFACTION.TAU) { + + if (instance_exists(obj_p_ship)){ + var p_ship=instance_nearest(x,y,obj_p_ship); + if (p_ship.action="") and (point_distance(x,y,p_ship.x,p_ship.y)<80){ + if (obj_controller.p_known[8]=0){ + obj_controller.p_known[8]=1; + } } } @@ -859,10 +862,13 @@ function fleet_arrival_logic() { scr_event_log("red", $"Contact has been lost with {sta.name}."); sta.vision = 0; } + + if (mess=1) and (orbiting.vision!=0){ + scr_alert("red","owner",$"Contact has been lost with {orbiting.name}!",orbiting.x,orbiting.y); + scr_event_log("red",$"Contact has been lost with {orbiting.name}.");orbiting.vision=0;} } - action_x = 0; - action_y = 0; - + + // 135 ; fleet chase if ((string_count("Inqis", trade_goods) > 0) && (string_count("fleet", trade_goods) > 0) && (!string_count("_her", trade_goods))) { inquisition_fleet_inspection_chase(); @@ -873,189 +879,147 @@ function fleet_arrival_logic() { x = -100; y = -100; - cur_star = instance_nearest(old_x, old_y, obj_en_fleet); - var mergus = false; - - mergus = cur_star.image_index; - if (mergus < 3) { - mergus = 0; - } - if (mergus >= 3) { - mergus = 10; - } - if ((owner == eFACTION.TAU) && (mergus >= 3)) { - mergus = 0; - } - if (string_count("_her", trade_goods) == 0) { - mergus = 99; - } // was 999 - - // Think this might be causing the crash - if ((owner == eFACTION.TAU) && (sta.present_fleet[eFACTION.IMPERIUM] + sta.present_fleet[eFACTION.PLAYER] >= 1) && (sta.present_fleet[eFACTION.TAU] == 1) && (image_index == 1) && (ret == 0)) { - mergus = 15; - } - if ((cur_star.owner == eFACTION.TAU) && (owner == eFACTION.TAU) && (ret == 1)) { - mergus = 0; - } - - if ((owner == eFACTION.TAU) && (image_index == 1)) { - // show_message("Tau||| Other Owner: "+string(cur_star.owner)+" ret: "+string(ret)+" mergus: "+string(mergus)); - } - - if ((owner == eFACTION.CHAOS) && fleet_has_cargo("csm") || fleet_has_cargo("warband")) { - mergus = 0; - } - // if (cur_star.owner!=owner) then mergus=0; - - if ((cur_star.x == old_x) && (cur_star.y == old_y) && (cur_star.owner == self.owner) && (cur_star.action == "") && (mergus == 1999)) { - // Merge the fleets - cur_star.escort_number += self.escort_number; - cur_star.frigate_number += self.frigate_number; // show_message("Tau fleet merging"); - cur_star.capital_number += self.capital_number; - cur_star.guardsmen += self.guardsmen; - - cur_star = instance_nearest(old_x, old_y, obj_star); - // if (cur_star.present_fleets>=1) then cur_star.present_fleets-=1; - if (owner == eFACTION.TAU) { - obj_controller.tau_fleets -= 1; - cur_star.tau_fleets -= 1; - } - if (owner == eFACTION.CHAOS) { - obj_controller.chaos_fleets -= 1; - } - - instance_destroy(); - } // End merge fleets - - if ((owner == eFACTION.TAU) && (mergus == 15)) { - // Get the fuck out - var new_star, stue; - new_star = 0; - stue = 0; - ret = 1; - - instance_activate_object(obj_star); // new_star - stue = instance_nearest(x, y, obj_star); - - if (image_index == 1) { - // Start influence thing - var tau_influence; - var tau_influence_chance = irandom(100) + 1; - var tau_influence_planet = irandom(stue.planets) + 1; - - with (stue) { - if (p_type[tau_influence_planet] != "Dead") { - scr_alert("green", "owner", $"Tau ship broadcasts subversive messages to {planet_numeral_name(tau_influence_planet)}.", sta.x, sta.y); - tau_influence = p_influence[tau_influence_planet][eFACTION.TAU]; - - if ((tau_influence_chance <= 70) && (tau_influence < 70)) { - adjust_influence[tau_influence_planet](eFACTION.TAU, 10, tau_influence_planet); - if (p_type[tau_influence_planet] == "Forge") { - adjust_influence(eFACTION.TAU, -5, tau_influence_planet); - } - } - - if ((tau_influence_chance <= 3) && (tau_influence < 70)) { - adjust_influence(eFACTION.TAU, 30, tau_influence_planet); - if (p_type[tau_influence_planet] == "Forge") { - adjust_influence(eFACTION.TAU, -25, tau_influence_planet); - } - } - } - } - } - - instance_deactivate_object(stue); - - with (obj_star) { - if (owner != eFACTION.TAU) { - instance_deactivate_object(instance_id); - } - } - - var good; - good = 0; - - repeat (100) { - var xx, yy; - if (good == 0) { - xx = x + choose(random(300), random(300) * -1); - yy = y + choose(random(300), random(300) * -1); - new_star = instance_nearest(xx, yy, obj_star); - if (new_star.owner != eFACTION.TAU) { - with (new_star) { - instance_deactivate_object(id); - } - } - if (new_star.owner == eFACTION.TAU) { - good = 1; - } + //interactions and merging with other already present fleets + + var old_x=x,old_y=y; + var _other_orbiting = []; + var _id = id; + with (obj_en_fleet){ + if (x!=old_x || y!=old_y){ + continue; + } + if (_id==id ){ + continue; + } + + array_push(_other_orbiting,id); + + } + + var _fleet_strength = standard_fleet_strength_calc(); + for (var i=0;i0){ + _attempt_merge=true; + } + + } + + if (!string_count("_her",trade_goods)){ + _attempt_merge = false; + } + + if (owner=eFACTION.CHAOS) and (fleet_has_cargo("csm")) or ( fleet_has_cargo("warband")){ + var _csm = fleet_has_cargo("warband"); + _attempt_merge = false; + } + + // if (cur_star.owner!=owner) then _other_fleet_strength=0; + + + + + //This will never trigger at the moment + if (_attempt_merge){// Merge the fleets + merge_fleets(id,_other_fleet) + + }// End merge fleets + + + //if fleet is damaged but existing fleet is too large to merge feck off elsewhere preferably somewhere friendly + else if (_same_owner && (owner == eFACTION.TAU || (owner = eFACTION.CHAOS && !csm))){// Move somewhere new + + if (standard_fleet_strength_calc()<3){ + + var _chosen =false; + var _chosen_id = nearest_star_with_ownership(x,y,owner,orbiting,true,true); + while (_chosen_id != "none"){ + if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none"){ + _chosen_id = nearest_star_with_ownership(x,y,owner,orbiting,true,true); + } else { + break; + } + } + + instance_activate_object(obj_star); + if (_chosen_id !="none"){ + action_x=_chosen_id.x; + action_y=_chosen_id.y; + set_fleet_movement(); + arrival_logic_finished = true; + } + + //TODO somelogc to go find somewhere else if there are no avialable rebuild planets + } else { + + _chosen_id = nearest_star_with_ownership(x,y,[2,3,4,5,7],orbiting); + } + } + } + + if (owner=eFACTION.TAU && !arrival_logic_finished) { + + + //so i'mjust sort of crudely interpreting things how i think duke meant to make it + //basically if the tau fleet is weakened or small instead of trying a hostile takeover + //they instrsd instigste a tau propaganda campaign and get the fuck out the system + + //if tau fleet is too weak then flee + if (standard_fleet_strength_calc()<3){// Start influence thing + + with (orbiting){ + tau_broadcast_propaganda_to_planet(); } + var _chosen =false; + var _chosen_id = nearest_star_with_ownership(x,y,owner,orbiting,true,true); + while (_chosen_id != "none"){ + if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none"){ + _chosen_id = nearest_star_with_ownership(x,y,owner,orbiting,true,true); + } else { + break; + } + } + + instance_activate_object(obj_star); + if (_chosen_id !="none"){ + action_x=_chosen_id.x; + action_y=_chosen_id.y; + set_fleet_movement(); + arrival_logic_finished = true; + } } - - // show_message("Get the fuck out working?: "+string(good)); - - if (new_star.owner == eFACTION.TAU) { - // show_message("Tau fleet actually fleeing"); - action_x = new_star.x; - action_y = new_star.y; - set_fleet_movement(); - } - - instance_activate_object(obj_star); - // This appears bugged + + } - x = old_x; - y = old_y; - - var _csm = fleet_has_cargo("warband"); - - if ((cur_star.x == old_x) && (cur_star.y == old_y) && (cur_star.owner == self.owner) && (cur_star.action == "") && ((owner == eFACTION.TAU) || (owner == eFACTION.CHAOS)) && (mergus == 10) && (!_csm)) { - // Move somewhere new - var stue, stue2; - stue = 0; - stue2 = 0; - var goood = 0; - - with (obj_star) { - if (is_dead_star()) { - instance_deactivate_object(id); - } - } - stue = instance_nearest(x, y, obj_star); - instance_deactivate_object(stue); - repeat (10) { - if (goood == 0) { - stue2 = instance_nearest(x + choose(random(400), random(400) * -1), y + choose(random(400), random(400) * -1), obj_star); - if ((owner == eFACTION.TAU) && (stue2.owner == eFACTION.TAU)) { - goood = 1; - } - if ((owner == eFACTION.CHAOS) && (stue2.owner != eFACTION.CHAOS)) { - goood = 1; - } - if (stue2.planets == 0) { - goood = 0; - } - if ((stue.present_fleet[eFACTION.IMPERIUM] > 0) || (stue.present_fleet[eFACTION.PLAYER] > 0)) { - goood = 0; - } - if ((stue2.planets == 1) && (stue2.p_type[1] == "Dead")) { - goood = 0; - } - } - } - action_x = stue2.x; - action_y = stue2.y; - set_fleet_movement(); // stue.present_fleets-=1; - instance_activate_object(obj_star); - } + + + // ORKS // Right here check to see if the fleet is being useless // If yes check for connected planet, see if not owned by orks // If not owned by orks then start heading that way // If the connected planet is owned by orks then choose a random one within 400 not owned by orks + + + else if (owner == eFACTION.ORK){ + if (is_orbiting()){ + with (orbiting){ + ork_fleet_arrive_target(); + } + } if (owner == eFACTION.ORK) { if (is_orbiting()) { @@ -1123,7 +1087,6 @@ function fleet_arrival_logic() { instance_activate_object(obj_star); } - exit; // end of eta=0 } function choose_fleet_sprite_image() { @@ -1193,10 +1156,35 @@ function fleet_respond_crusade() { } } - var enemu; - //var cs - with (obj_star) { - var cs = instance_nearest(x, y, obj_crusade); +function merge_fleets(main_fleet, merge_fleet){ + main_fleet.capital_number += merge_fleet.capital_number; + main_fleet.frigate_number += merge_fleet.frigate_number; + main_fleet.escort_number += merge_fleet.escort_number; + var _merge_cargo = struct_get_names(merge_fleet.cargo_data); + //TODO custom merge stuff + for (var i=0;i cs.radius) { y -= 20000; diff --git a/scripts/scr_forge_world_functions/scr_forge_world_functions.gml b/scripts/scr_forge_world_functions/scr_forge_world_functions.gml index ad8b69d10..407899120 100644 --- a/scripts/scr_forge_world_functions/scr_forge_world_functions.gml +++ b/scripts/scr_forge_world_functions/scr_forge_world_functions.gml @@ -3,79 +3,105 @@ function imperial_navy_fleet_construction() { // ** Check number of navy fleets ** - var new_navy_fleets = []; - with (obj_en_fleet) { - if ((owner == eFACTION.IMPERIUM) && (navy == 1)) { - array_push(new_navy_fleets, id); - } - } - //delete navy fleets if more than required - var navy_fleet_count = array_length(new_navy_fleets); - var cur_fleet; - if (navy_fleet_count > target_navy_number) { - for (var i = 0; i < navy_fleet_count; i++) { - cur_fleet = new_navy_fleets[i]; - if (cur_fleet.guardsmen_unloaded) { - continue; - } else { - instance_destroy(cur_fleet); - navy_fleet_count--; - array_delete(new_navy_fleets, i, 1); - i--; - if (navy_fleet_count <= target_navy_number) { - break; - } - } - } + var new_navy_fleets = get_imperial_navy_fleets(); + //delete navy fleets if more than required + var navy_fleet_count = array_length(new_navy_fleets); + var cur_fleet; + if (navy_fleet_count>target_navy_number) { + for (var i=0;i=0;i--){ + var _sys = _forge_systems[i]; + var good=true; + for(var o=1; o<=_sys.planets; o++) { + + if (_sys[p_type] == "Forge"){ + var _nearest = instance_nearest(x,y,obj_en_fleet) + if (_nearest.x ==x && _nearest.y==y && _nearest.navy){ + good=false; + break; + } + } + } + + if (!good){ + array_delete(_forge_systems,i,1); + } + } + // After initial navy fleet construction fleet growth is handled in obj_en_fleet.alarm_5 + if (array_length(_forge_systems)){ + var construction_forge; + construction_forge = array_random_element(_forge_systems); + build_new_navy_fleet(construction_forge) + } + } +} + +function get_imperium_forge_systems(){ + var _forge_systems = []; + with(obj_star){ + var good=false; + for(var o=1; o<=planets; o++) { + if (p_type[o]=="Forge") + and (p_owner[o]==eFACTION.MECHANICUS) + and (p_orks[o]+p_tau[o]+p_tyranids[o]+p_chaos[o]+p_traitors[o]+p_necrons[o]==0) { + + var enemy_fleets = [ + eFACTION.ORK, + eFACTION.TAU, + eFACTION.TYRANIDS, + eFACTION.CHAOS, + eFACTION.NECRONS + ] + + var enemy_fleet_count = array_reduce(enemy_fleets, function(prev, curr) { + return prev + present_fleet[curr] + }, 0); + + good = enemy_fleet_count<=0; } - if (good == true) { - array_push(forge_systems, id); + if (good){ + break; } } - // After initial navy fleet construction fleet growth is handled in obj_en_fleet.alarm_5 - if (array_length(forge_systems)) { - var construction_forge, new_navy_fleet; - construction_forge = choose_array(forge_systems); - build_new_navy_fleet(construction_forge); + if (good){ + good = x<=room_width && y<=room_height; + } + if (good){ + array_push(_forge_systems, id); } } + return _forge_systems; } -function build_planet_defence_fleets() { - imp_ships = 0; - var _defence_fleet_log = {}; - with (obj_en_fleet) { - if (owner == eFACTION.IMPERIUM) { - var _imperial_fleet_defence_score = capital_number + (frigate_number / 2) + (escort_number / 4); +function build_planet_defence_fleets(){ + imp_ships=0; + var _defence_fleet_log = {}; + with(obj_en_fleet){ + if (owner==eFACTION.IMPERIUM){ + var _imperial_fleet_defence_score = round(standard_fleet_strength_calc()); obj_controller.imp_ships += _imperial_fleet_defence_score; //log this to prevent double work later figuring out if a planet has an orbiting defence fleet if (!navy && action == "" && is_orbiting()) { diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index 721cdee32..66f79398c 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -28,7 +28,7 @@ function disposition_description_chart(dispo) { } } -function GarrisonForce(planet_operatives, turn_end = false, type = "garrison") constructor { +function GarrisonForce(operatives, turn_end = false, type = "garrison") constructor { garrison_squads = []; total_garrison = 0; garrison_leader = false; @@ -37,6 +37,8 @@ function GarrisonForce(planet_operatives, turn_end = false, type = "garrison") c time_on_planet = 0; viable_garrison = 0; var operative, unit, member; + self.type = type + static update = function(operatives,turn_end){ for (var ops = 0; ops < array_length(planet_operatives); ops++) { if (planet_operatives[ops].type == "squad") { if (planet_operatives[ops].job == type) { @@ -53,28 +55,23 @@ function GarrisonForce(planet_operatives, turn_end = false, type = "garrison") c if (!is_struct(unit)) { continue; } - if (unit.name() == "") { - continue; + if (turn_end) { + operatives[ops].task_time++; } - array_push(members, unit); - if (unit.hp() > 0) { - viable_garrison++; + if (operatives[ops].task_time > time_on_planet) { + time_on_planet = operatives[ops].task_time; } + } else { + array_delete(operatives, ops, 1); + ops--; } - if (turn_end) { - planet_operatives[ops].task_time++; - } - if (planet_operatives[ops].task_time > time_on_planet) { - time_on_planet = planet_operatives[ops].task_time; - } - } else { - array_delete(planet_operatives, ops, 1); - ops--; } } } } + update(operatives,turn_end); + static garrison_sustain_damages = function(win_or_loss) { var unit; var member_count = array_length(members); diff --git a/scripts/scr_governors/scr_governors.gml b/scripts/scr_governors/scr_governors.gml new file mode 100644 index 000000000..906f16b5c --- /dev/null +++ b/scripts/scr_governors/scr_governors.gml @@ -0,0 +1,52 @@ + +enum ePREFERENCE{ + HATES = 0, + DISLIKES, + NEUTRAL, + LIKES, + LOVES +} + +function GovernorProfile() constructor{ + born = obj_controller.turn - irandom_range(240,4800); + + uid = scr_uuid_generate(); + + static age = function(){ + var _age = born - obj_controller.turn; + if (_age < 0){ + _age = (born * -1) + obj_controller.turn; + } + + _age/=12; + + return age; + } + + gender = set_gender(); + + name = global.name_generator.GenerateFromSet($"imperial_{string_gender(gender)}"); + + astartes_view = irandom(4);//0 hates astartes 4 likes astartes + + sector_commander_view = irandom(4);//likes commmander hates commander + + personal_security = irandom(4); // 0 no security , 4 high secirity + + known_to_cm = false; + + known_to_chapter = false; + + constitution = 10; + strength = 10; + luck = 10; + dexterity = 10; + wisdom = irandom_range(20, 50); + piety = irandom_range(20, 60); + charisma = irandom_range(20, 60); + technology = irandom_range(10, 40); + intelligence = irandom_range(20, 50); + weapon_skill = 5; + ballistic_skill = 5; + +} \ No newline at end of file diff --git a/scripts/scr_governors/scr_governors.yy b/scripts/scr_governors/scr_governors.yy new file mode 100644 index 000000000..99d71d1e8 --- /dev/null +++ b/scripts/scr_governors/scr_governors.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"scr_governors", + "isCompatibility":false, + "isDnD":false, + "name":"scr_governors", + "parent":{ + "name":"marines_and_profiles", + "path":"folders/Scripts/marines_and_profiles.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/scr_hit/scr_hit.gml b/scripts/scr_hit/scr_hit.gml index bdc54f2b9..fcf874a2e 100644 --- a/scripts/scr_hit/scr_hit.gml +++ b/scripts/scr_hit/scr_hit.gml @@ -82,6 +82,21 @@ function point_and_click(_rect, _cooldown = 60, _lock_bypass = false) { return _point_and_click_logic(_rect, _cooldown, _lock_bypass, false); } +function scr_click_left(cooldown = 60, lock_bypass = false){ + + return click_controller(cooldown,lock_bypass); +} + +function scr_click_right(cooldown = 60, lock_bypass = false){ + + return click_controller(cooldown,lock_bypass ,mb_right); +} + +function click_controller(cooldown = 60, lock_bypass = false, mouse_button_lr=mb_left){ + if (lock_bypass == false && global.ui_click_lock == true) { + return false; + } +} /// @description Returns true if left mouse button was clicked outside the desired rectangle area. /// @param {Array} _rect The [x1, y1, x2, y2] array defining the exclusion zone. /// @param {Real} _cooldown The cooldown duration in frames. @@ -107,6 +122,7 @@ function mouse_button_clicked(button = mb_left, cooldown = 60, lock_bypass = fal return false; } + return mouse_clicked; var controller_exist = instance_exists(obj_controller); if (controller_exist && obj_controller.cooldown > 0) { if (is_debug_overlay_open()) { diff --git a/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml b/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml index e18c6bcd9..4e0ef10cc 100644 --- a/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml +++ b/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml @@ -103,102 +103,97 @@ function check_navy_guard_still_live() { } } -function build_new_navy_fleet(construction_forge) { - new_navy_fleet = instance_create(construction_forge.x, construction_forge.y, obj_en_fleet); - with (new_navy_fleet) { - owner = eFACTION.IMPERIUM; - - capital_number = 0; - frigate_number = 0; - escort_number = 1; - home_x = x; - home_y = y; - warp_able = true; - with (construction_forge) { - present_fleet[2] += 1; +function build_new_navy_fleet(construction_forge){ + new_navy_fleet=instance_create(construction_forge.x,construction_forge.y,obj_en_fleet); + + with(new_navy_fleet){ + owner=eFACTION.IMPERIUM; + + capital_number=0; + frigate_number=0; + escort_number=1; + home_x=x; + home_y=y; + warp_able = true; + with (construction_forge){ + present_fleet[2]+=1; } - orbiting = construction_forge; - navy = 1; - - var total_ships = 0; - total_ships += capital_number - 1; - total_ships += round((frigate_number / 2)); - total_ships += round((escort_number / 4)); - if (total_ships <= 1 && capital_number + frigate_number + escort_number > 0) { - total_ships = 1; + orbiting=construction_forge; + navy=1; + + var total_ships=0; + total_ships+=round(standard_fleet_strength_calc()); + if (total_ships<=1 && capital_number+frigate_number+escort_number>0){ + total_ships=1; } - choose_fleet_sprite_image(); - image_index = total_ships; - image_speed = 0; - - trade_goods = "building_ships"; - } + choose_fleet_sprite_image() + image_index=total_ships; + image_speed=0; + + trade_goods="building_ships"; + } } /// @mixin -function new_navy_ships_forge() { - if (trade_goods == "building_ships") { - var onceh = 0, advance = false, p = 0; - - p = 0; +function new_navy_ships_forge(){ + if (trade_goods=="building_ships"){ + var onceh=0,advance=false,p=0; + + p=0; is_orbiting(); - for (var p = 1; p <= orbiting.planets; p++) { - if (orbiting.p_type[p] == "Forge") { + for (var p=1;p<=orbiting.planets;p++){ + if (orbiting.p_type[p]="Forge"){ //if no non-imperium,player, or eldar aligned fleets or ground forces, continue - if (orbiting.p_orks[p] + orbiting.p_chaos[p] + orbiting.p_tyranids[p] + orbiting.p_necrons[p] + orbiting.p_tau[p] + orbiting.p_traitors[p] == 0) { - if (orbiting.present_fleet[7] + orbiting.present_fleet[8] + orbiting.present_fleet[9] + orbiting.present_fleet[10] + orbiting.present_fleet[13] == 0) { - advance = 1; + if (orbiting.p_orks[p]+orbiting.p_chaos[p]+orbiting.p_tyranids[p]+orbiting.p_necrons[p]+orbiting.p_tau[p]+orbiting.p_traitors[p]=0){ + if (orbiting.present_fleet[7]+orbiting.present_fleet[8]+orbiting.present_fleet[9]+orbiting.present_fleet[10]+orbiting.present_fleet[13]=0){ + advance=1; } } - } + } } - - if (!advance) { + + if (!advance){ exit; } - //TODO here we can make fleet be restored more quickly by better forge worlds - if (escort_number < 12) { - escort_number += 1; - } else if (frigate_number < 5) { - frigate_number += 0.25; - onceh = 1; - if (frigate_number > 4.99) { - frigate_number = 5; - } - } else if (capital_number < 1) { - capital_number += 0.0834; - if (capital_number > 1) { - capital_number = 1; - } + //TODO here we can make fleet be restored more quickly by better forge worlds + if (escort_number<12) { + escort_number+=1; + } + + else if (frigate_number<5) { + frigate_number+=0.25; + onceh=1; + if (frigate_number>4.99) then frigate_number=5; } - if (onceh == 1) { - var ii = 0; - ii += capital_number; - ii += round((frigate_number / 2)); - ii += round((escort_number / 4)); - image_index = ii <= 1 ? 1 : ii; + else if (capital_number<1) { + capital_number+=0.0834; + if (capital_number>1) then capital_number=1; } + if (onceh=1){ + var ii=round(standard_fleet_strength_calc()); - if (capital_number >= 1 && frigate_number >= 5 && escort_number >= 12) { - var i = -1; - repeat (capital_number) { - i += 1; - capital_max_imp[i] = (((floor(random(15)) + 1) * 1000000) + 15000000) * 2; + image_index=ii<=1?1:ii; + } + + if (capital_number>=1 && frigate_number>=5 && escort_number>=12){ + var i=-1; + repeat(capital_number){i+=1; + capital_max_imp[i]=(((floor(random(15))+1)*1000000)+15000000)*2; } - i = -1; - repeat (frigate_number) { - i += 1; - frigate_max_imp[i] = (500000 + (floor(random(50)) + 1) * 10000) * 2; + i=-1; + repeat(frigate_number){i+=1; + frigate_max_imp[i]=(500000+(floor(random(50))+1)*10000)*2; } - trade_goods = ""; + trade_goods=""; } + //if (trade_goods="building_ships" || !advance) then exit; end_sequence_finished = true; - } + } } //TODO further breakup into a nvay fleet functions script @@ -1088,8 +1083,22 @@ function setup_start_imperial_navy_fleet(system) { with (nav) { orbiting = system; - owner = eFACTION.IMPERIUM; - navy = 1; + owner=eFACTION.IMPERIUM; + navy=1; + + capital_number = choose(1,2,3); + frigate_number = (capital_number*2)+3; + escort_number=12; + home_x=x; + home_y=y; + warp_able=true; + + image_speed=0; + ii+=round(standard_fleet_strength_calc()); + if (ii<=1) and (ii>0){ + ii=1; + } + image_index=ii; capital_number = choose(1, 2, 3); frigate_number = (capital_number * 2) + 3; @@ -1117,3 +1126,19 @@ function setup_start_imperial_navy_fleet(system) { } } } + +function get_imperial_navy_fleets(){ + var _fleets = []; + + with (obj_en_fleet){ + if (owner != eFACTION.IMPERIUM || !navy){ + continue; + } else if (owner == eFACTION.IMPERIUM && navy){ + array_push(_fleets, id); + } + } + + return _fleets; +} + + diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 6848d52da..334f59abb 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -11,7 +11,7 @@ Helpers: scr_mission_eta -> given the xy of a _star where the mission is, calculate how long you should have to complete the mission Todo? maybe add a disposition influence here so that angy inquisitor gives you less spare time and vice versa - scr_star_has_planet_with_feature -> given the id of a _star and a `P_features` enum value, check if any planet on that _star has the desired feature + scr_star_has_planet_with_feature -> given the id of a _star and a `eP_FEATURES` enum value, check if any planet on that _star has the desired feature star_has_planet_with_forces -> given the id of a _star, and a faction, returns whether or not there are forces present there and in sufficient number */ diff --git a/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml b/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml index d57ffc54b..d77cc21da 100644 --- a/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml +++ b/scripts/scr_khornate_fleet_functions/scr_khornate_fleet_functions.gml @@ -260,38 +260,31 @@ function spawn_chaos_warlord() { home_x = x + lengthdir_x(5000, point_direction(x, y, room_width / 2, room_height / 2)); home_y = y + lengthdir_y(5000, point_direction(x, y, room_width / 2, room_height / 2)); cargo_data.warband = {}; - capital_number = 10; - frigate_number = 20; - escort_number = 40; - } - var rep, filtered_array, candidate_systems; - candidate_systems = []; - with (obj_star) { - rep = 0; - ya = false; - //should probably get turned into its own helper if used multiple times - filtered_array = array_filter(p_owner, function(val, idx) { - return scr_is_planet_owned_by_allies(self, idx); - }); - if (array_length(filtered_array)) { - array_push(candidate_systems, self); - } - } + capital_number=10; + frigate_number=20; + escort_number=40; + } + var rep, filtered_array, candidate_systems; + candidate_systems = []; + with(obj_star){ + rep=0; + ya=false; + //should probably get turned into its own helper if used multiple times + filtered_array = array_filter(p_owner, function(val, idx) { + return scr_is_planet_owned_by_allies(self, idx) + }) + if array_length(filtered_array) + array_push(candidate_systems, self) + } + + if (array_length(candidate_systems)){ + var fleet_target = nearest_instance(candidate_systems,nfleet); - var fleet_target = array_reduce(candidate_systems, method({nfleet}, function(prev, curr) { - if (!prev) { - return curr; + with (nfleet){ + nfleet.action_x=fleet_target.x; + nfleet.action_y=fleet_target.y; + set_fleet_movement() } - var prev_dist = point_distance(prev.x, prev.y, nfleet.x, nfleet.y); - var curr_dist = point_distance(curr.x, curr.y, nfleet.x, nfleet.y); - - return (prev_dist > curr_dist) ? curr : prev; - }), noone); - - with (nfleet) { - nfleet.action_x = fleet_target.x; - nfleet.action_y = fleet_target.y; - set_fleet_movement(); } var tix = $"Chaos Lord {faction_leader[eFACTION.CHAOS]} continues his Black Crusade into Sector {obj_ini.sector_name}."; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index 87ad838bc..8a75968a5 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -84,6 +84,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} religion_sub_cult = "none"; base_group = "none"; role_history = []; + epithets = []; enum eROLE_TAG { Techmarine = 0, Librarian = 1, @@ -397,17 +398,52 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; //adds a trait to a marines trait list - static add_trait = function(trait) { - var balance_value; + static add_trait = function(trait,return_stat_diff = false, return_description = false) { + + if (return_stat_diff){ + var _start_stats = get_stat_line(); + } if (struct_exists(global.trait_list, trait)) { if (!array_contains(traits, trait)) { + + var _return_string = ""; var selec_trait = global.trait_list[$ trait]; stat_boosts(selec_trait); array_push(traits, trait); + + if (return_stat_diff){ + var _end_stats = get_stat_line(); + + var _stat_diff = compare_stats(_end_stats,_start_stats); + } + + if (return_description){ + _return_string += $"{name_role()} Has gained the trait {selec_trait.display_name}"; + } + + if (return_stat_diff){ + _return_string +=$", {(print_stat_diffs(_stat_diff))}" + } + + return _return_string } } + + return ""; }; + + //TODO build epithets in to marine profile + static add_epithet = function(epithet){ + if (is_string(epithet)){ + epithet = { + title : epithet, + story : "", + } + } + array_push(epithets,epithet); + } + static has_trait = marine_has_trait; static add_feat = function(feat) { @@ -1689,7 +1725,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; //quick way of getting name and role combined in string - static name_role = function() { + static name_role = function(include_epithet = true) { var temp_role = role(); if (squad != "none") { var _squad = get_squad(); @@ -1700,6 +1736,13 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} } } } + + var _name = "{temp_role} {name()}"; + if (include_epithet){ + if (array_length(epithets)){ + _name += $" {epithets[0].title}"; + } + } return string("{0} {1}", temp_role, name()); }; @@ -1949,7 +1992,19 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} }; static get_stat_line = function() { - return {"constitution": constitution, "strength": strength, "luck": luck, "dexterity": dexterity, "wisdom": wisdom, "piety": piety, "charisma": charisma, "technology": technology, "intelligence": intelligence, "weapon_skill": weapon_skill, "ballistic_skill": ballistic_skill}; + return variable_clone({ + "constitution": constitution, + "strength": strength, + "luck": luck, + "dexterity": dexterity, + "wisdom": wisdom, + "piety": piety, + "charisma": charisma, + "technology": technology, + "intelligence": intelligence, + "weapon_skill": weapon_skill, + "ballistic_skill": ballistic_skill + }); }; //TODO: Make this into a universal stat gathering function from all gear, for any stat; diff --git a/scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.gml b/scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.gml new file mode 100644 index 000000000..3ba26c80f --- /dev/null +++ b/scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.gml @@ -0,0 +1,55 @@ +function spawn_mechanicus_explore_fleet(){ + + var _forges = get_imperium_forge_systems(); + if (!array_length(_forges)){ + return -1; + } + + var _forge = array_random_element(_forges); + var _fleet = instance_create(_forge.x, _forge.y, obj_en_fleet); + + with (_fleet){ + owner = eFACTION.MECHANICUS; + warp_able = true; + capital_number = 2; + frigate_number = 5; + escort_number = 20; + navy = 0; + choose_fleet_sprite_image(); + } + + return _fleet; +} + +///@mixin FleetEvent +function mech_fleet_explore_battle_grounds(){ + var _navy_fleet = get_fleet_uid(fleet_uid); + + if (!is_orbiting(_navy_fleet)){ + return; + } + + var _has_battle = system_feature_bool(orbiting.p_feature,eP_FEATURES.OLDBATTLEGROUND); + if (_has_battle){ + var _p_data = orbiting.system_datas[_has_battle]; + _p_data.refresh_data(); + } else{ + return; + } + + var _battle_ground = _p_data.get_features(eP_FEATURES.OLDBATTLEGROUND)[0]; + + if (_battle_ground.explored == 0){ + var _text = $"The Mechanicus have arrived on {_p_data.name()} It will now be impossible to access the site without Mechanicus surveillance any potential rescources will now be fully put towards their aimsin service of the Ommnissiah"; + scr_popup($"Mechanicus Scavange {_p_data.name()}", _text, "mech"); + } else { + var _marines = _p_data.collect_planet_group("all"); + if (array_length(_marines)){ + var _heritecs = obj_controller.tech_status == "heretics"; + if (_heritecs){ + _text = "The Rumours of the heretical practices of your marines have not gone un-noticed your presence is thusly even more enraging to mechanicus"; + } + + } + } +} \ No newline at end of file diff --git a/scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.yy b/scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.yy new file mode 100644 index 000000000..da0672f64 --- /dev/null +++ b/scripts/scr_mechanicus_fleet_functions/scr_mechanicus_fleet_functions.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"scr_mechanicus_fleet_functions", + "isCompatibility":false, + "isDnD":false, + "name":"scr_mechanicus_fleet_functions", + "parent":{ + "name":"fleet", + "path":"folders/Scripts/fleet.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index b0c37d0c9..fdf13f047 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -5,13 +5,13 @@ function mechanicus_missions_end_turn(planet) { var _lr_count = scr_vehicle_count("Land Raider", [name, planet, -1]); if ((array_length(_techs) >= 6) && (_lr_count >= 1)) { var _prob_data = p_problem_other_data[planet][raider_planet_slot]; - var percent_complete = increment_mission_completion(_prob_data); - scr_alert("", $"mission", $"Mechanicus Mission on {planet_numeral_name(planet)} is {floor(percent_complete)}% complete.", 0, 0); - if (percent_complete >= 100) { - remove_planet_problem(planet, "mech_raider"); - scr_mission_reward("mech_raider", id, planet); - } - } + var percent_complete = increment_mission_completion(_prob_data); + scr_alert("",$"mission",$"Mechanicus Mission on {planet_numeral_name(planet)} is {floor(percent_complete)}% complete.",0,0); + if (percent_complete>=100){ + remove_planet_problem(planet,"mech_raider"); + scr_mission_reward("mech_raider",id,planet); + } + } } var bionics_planet_slot = has_problem_planet_with_time(planet, "mech_bionics"); if (bionics_planet_slot > -1) { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 45e5c4c91..0ac7c8ed0 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -1,124 +1,137 @@ // Script assets have changed for v2.3.0 see // https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information -function MissionHandler(planet, system) : PlanetData(planet, system) constructor {} -function location_out_of_player_control(unit_loc) { - static _locs = [ - "Terra", - "Mechanicus Vessel", - "Lost", - "Mars" - ]; - return array_contains(_locs, unit_loc); +function location_out_of_player_control(unit_loc){ + static _locs = ["Terra", "Mechanicus Vessel", "Lost", "Mars"]; + return (array_contains(_locs,unit_loc )); } -#macro PLANET_PROBLEM_KEYS ["meeting_trap","meeting","succession","mech_raider","mech_bionics","mech_mars","mech_tomb1","fallen","great_crusade","harlequins","fund_elder","provide_garrison","hunt_beast","protect_raiders","join_communion","join_parade","recover_artifacts","train_forces","spyrer","inquisitor","recon","cleanse","purge","tyranid_org","artifact_loan","necron","ethereal","demon_world"] -function mission_name_key(mission) { +/// @desc Compares two location arrays to determine if they represent the same place. +/// @param {array} _first_loc +/// @param {array} _second_loc +/// @returns {bool} +function locations_are_equal(_first_loc, _second_loc) { + if (!is_array(_first_loc) || !is_array(_second_loc) || array_length(_first_loc) < 3 || array_length(_second_loc) < 3) { + LOGGER.error("Attempted to compare non-array or broken location data."); + return false; + } + + var _first_type = _first_loc[2]; + var _second_type = _second_loc[2]; + var _not_lost = (_first_type != "Warp" && _first_type != "Lost") && (_second_type != "Warp" && _second_type != "Lost"); + + if (_not_lost && (_first_type == _second_type)) { + return true; + } + + return (_first_loc[1] == _second_loc[1]) && (_first_loc[0] == _second_loc[0]); +} + + +#macro PLANET_PROBLEM_KEYS ["meeting_trap","meeting","succession","mech_raider","mech_bionics","mech_mars","mech_tomb1","fallen","great_crusade","harlequins","fund_elder","provide_garrison","hunt_beast","protect_raiders","join_communion","join_parade","recover_artifacts","train_forces","spyrer","inquisitor","recon","cleanse","purge","tyranid_org","artifact_loan","necron","ethereal","demon_world","deliver_trophy"] + +function mission_name_key(mission){ var mission_key = { - "meeting_trap": "Chaos Lord Meeting", - "meeting": "Chaos Lord Meeting", - "succession": "War of succession", - "mech_raider": "Provide Land Raider to Mechanicus", - "mech_bionics": "Provide Bionic Augmented marines to study", - "mech_mars": "Send Techmarines to mars", + "meeting_trap" : "Chaos Lord Meeting", + "meeting" : "Chaos Lord Meeting", + "succession" : "War of succession", + "mech_raider" : "Provide Land Raider to Mechanicus", + "mech_bionics" : "Provide Bionic Augmented marines to study", + "mech_mars" : "Send Techmarines to mars", "mech_tomb1": "Explore Mechanicus Tomb", - "fallen": "Find Chapter Fallen", + "fallen" : "Find Chapter Fallen", "great_crusade": "Answer Crusade Muster Call", - "harlequins": "Harlequin presence Report", - "fund_elder": "provide assistance to Eldar", - "provide_garrison": "Provision Garrison", - "hunt_beast": "Hunt Beasts", - "protect_raiders": "Protect From Raiders", - "join_communion": "Join Planetary Religious Celebration", - "join_parade": "Join Parade on Planet Surface", - "recover_artifacts": "Recover Artifacts", - "train_forces": "Train Planet Forces", + "harlequins" : "Harlequin presence Report", + "fund_elder" : "provide assistance to Eldar", + "provide_garrison" : "Provision Garrison", + "hunt_beast" : "Hunt Beasts", + "protect_raiders" : "Protect From Raiders", + "join_communion" : "Join Planetary Religious Celebration", + "join_parade" : "Join Parade on Planet Surface", + "recover_artifacts" : "Recover Artifacts", + "train_forces" : "Train Planet Forces", // Inquisition missions - "spyrer": "Kill Spyrer for Inquisitor", + "spyrer" : "Kill Spyrer for Inquisitor", "inquisitor": "Radical Inquisitor Arriving", - "recon": "Recon Mission for Inquisitor", - "cleanse": "Cleanse Planet for Inquisitor", + "recon" : "Recon Mission for Inquisitor", + "cleanse" : "Cleanse Planet for Inquisitor", "purge": "Purge Leadership for Inquisitor", - "tyranid_org": "Capture Tyranid for Inquisitor", + "tyranid_org" : "Capture Tyranid for Inquisitor", // "bomb" : "Bombard World for Inquisitor", - "artifact_loan": "Safeguard Artifact for the Inquisition", + "artifact_loan" : "Safeguard Artifact for the Inquisition", "necron": "Bomb Necron Tomb for Inquisitor", "ethereal": "Capture Ethereal for Inquisitor", - "demon_world": "Clear Demon World for Inquisitor", - }; - if (struct_exists(mission_key, mission)) { - return mission_key[$ mission]; - } else { - return "none"; + "demon_world": "Clear Demon World for Inquisitor" + } + if (struct_exists(mission_key, mission)){ + return mission_key[$ mission]; + } else{ + return "none" + } } +function scr_new_governor_mission(planet, problem = ""){ -function scr_new_governor_mission(planet, problem = "") { - if (p_owner[planet] != eFACTION.IMPERIUM) { - exit; - } - var planet_type = p_type[planet]; - if (problem == "") { - if (planet_type == "Death") { + if p_owner[planet] != eFACTION.IMPERIUM then exit; + var planet_type= p_type[planet]; + if (problem == ""){ + if (planet_type=="Death"){ problem = choose("hunt_beast", "provide_garrison"); - accept_time = 6 + irandom(30); - } else if (planet_type == "Hive") { + accept_time = 6+irandom(30); + } else if (planet_type == "Hive"){ problem = choose("show_of_power", "provide_garrison", "purge_enemies", "raid_black_market"); - } else if (planet_type == "Temperate") { + } else if (planet_type == "Temperate"){ problem = choose("provide_garrison", "train_forces", "join_parade"); - } else if (planet_type == "Shrine") { + }else if (planet_type == "Shrine"){ problem = choose("provide_garrison", "join_communion"); - } else if (planet_type == "Ice") { + }else if (planet_type == "Ice"){ problem = choose("provide_garrison", "hunt_beast"); - } else if (planet_type == "Lava") { + }else if (planet_type == "Lava"){ problem = choose("provide_garrison", "protect_raiders"); - } else if (planet_type == "Agri") { + }else if (planet_type == "Agri"){ problem = choose("provide_garrison", "protect_raiders", "recover_artifacts"); - } else if (planet_type == "Desert") { + }else if (planet_type == "Desert"){ problem = choose("provide_garrison", "protect_raiders", "recover_artifacts"); - } else if (planet_type == "Feudal") { + }else if (planet_type == "Feudal"){ problem = choose("hunt_beast", "protect_raiders"); } } var mission_data = { - stage: "preliminary", - applicant: "Governor", + stage : "preliminary", + applicant : "Governor" }; - if (problem != "") { - if (problem == "provide_garrison") { - if (system_garrison[planet - 1].garrison_force) { + if (problem != ""){ + if (problem == "provide_garrison"){ + if (system_garrison[planet].garrison_force){ exit; } mission_data.reason = choose("stability", "importance"); - } else if (problem == "purge_enemies") { + } else if (problem=="purge_enemies"){ var enemy = 0; - if (planets > 1) { - for (var i = 1; i <= planets; i++) { - if (i == planet) { - continue; - } - if (p_owner[i] == eFACTION.IMPERIUM) { - enemy = i; + if (planets>1){ + for (var i=1;i<=planets;i++){ + if (i=planet) then continue; + if (p_owner[i]==eFACTION.IMPERIUM){ + enemy=i; break; } } } - mission_data.target = enemy; - if (!enemy) { - exit; - } + mission_data.target=enemy; + if (!enemy) then exit; } - add_new_problem(planet, problem, 20 + irandom(20),, mission_data); + add_new_problem(planet,problem, 20+irandom(20), ,mission_data); } } -function init_marine_acting_strange() { - LOGGER.info("RE: Strange Behavior"); - var marine_and_company = scr_random_marine("", 0); - if (marine_and_company == "none") { - LOGGER.error("RE: Strange Behavior, couldn't pick a space marine"); +function init_marine_acting_strange(){ + global.logger.info("RE: Strange Behavior"); + var marine_and_company = scr_random_marine("",0); + if(marine_and_company == "none") + { + global.logger.error("RE: Strange Behavior, couldn't pick a space marine"); exit; } @@ -126,91 +139,47 @@ function init_marine_acting_strange() { var role = unit.role(); var text = unit.name_role(); var company_text = scr_convert_company_to_string(unit.company); - if (company_text != "") { + if(company_text != ""){ company_text = $"({company_text})"; text += company_text; } text += " is behaving strangely."; - scr_alert("color", "lol", text, 0, 0); - scr_event_log("color", text); -} - -function init_garrison_mission(planet, star, mission_slot) { - var problems_data = star.p_problem_other_data[planet]; - var mission_data = problems_data[mission_slot]; - if (mission_data.stage == "preliminary") { - var numeral_name = planet_numeral_name(planet, star); - mission_data.stage = "active"; - var garrison_length = 10 + irandom(6); - star.p_timer[planet][mission_slot] = garrison_length; - //pop.image="ancient_ruins"; - var gar_pop = instance_create(0, 0, obj_popup); - //TODO some new universal methods for popups - gar_pop.title = $"Requested Garrison Provided to {numeral_name}"; - gar_pop.text = $"The governor of {numeral_name} Thanks you for considering his request for a garrison, you agree that the garrison will remain for at least {garrison_length} months."; - //pip.image="event_march" - gar_pop.add_option("Commence Garrison"); - gar_pop.image = ""; - gar_pop.cooldown = 8; - obj_controller.cooldown = 8; - scr_event_log("", $"Garrison committed to {numeral_name} for {garrison_length} months.", star.name); - } + scr_alert("color","lol",text,0,0); + scr_event_log("color",text); } -function init_beast_hunt_mission(planet, star, mission_slot) { - var problems_data = star.p_problem_other_data[planet]; - var mission_data = problems_data[mission_slot]; - if (mission_data.stage == "preliminary") { - var numeral_name = planet_numeral_name(planet, star); - mission_data.stage = "active"; - var _mission_length = irandom_range(2, 5); - star.p_timer[planet][mission_slot] = _mission_length; - //pop.image="ancient_ruins"; - var gar_pop = instance_create(0, 0, obj_popup); - //TODO some new universal methods for popups - gar_pop.title = $"Marines assigned to hunt beasts around {numeral_name}"; - gar_pop.text = $"The govornor of {numeral_name} Thanks you for the participation of your elite warriors in your execution of such a menial task."; - //pip.image="event_march" - gar_pop.add_option("Happy Hunting"); - gar_pop.image = ""; - gar_pop.cooldown = 8; - obj_controller.cooldown = 20; - scr_event_log("", $"Beast hunters deployed to {numeral_name} for {_mission_length} months.", star.name); - } -} - -function role_compare(unit, role) { +function role_compare(unit, role){ return unit.role() == obj_ini.role[100][role]; } -function init_protect_raider_mission(squad) { +function init_protect_raider_mission(squad){ var _squad_units = squad.get_squad_structs(); var _squad_wisdom = stat_average(_squad_units, "wisdom"); var _squad_dex = stat_average(_squad_units, "dexterity"); var _tester = global.character_tester; var _pdata = new PlanetData(selection_data.planet, selection_data.system); - var _mod = _squad_wisdom + _squad_dex / 20; - if (scr_has_adv("Ambushers")) { - _mod += 10; + var _mod = _squad_wisdom+_squad_dex/20; + if (scr_has_adv("Ambushers")){ + _mod += 10 } var _leader = fetch_unit(squad.determine_leader()); - var _wis_test = _tester.standard_test(_leader, "wisdom", _mod, ["ambush"]); + var _wis_test = _tester.standard_test(_leader, "wisdom", _mod, ["ambush"]); - if (!_wis_test[0]) { + if (!_wis_test[0]){ var _mission_data = variable_clone(selection_data); - if (_wis_test[1] < -25) { + if (_wis_test[1] < -25){ scr_toggle_manage(); - var gar_pop = instance_create(0, 0, obj_popup); - gar_pop.title = $"Strange Disappearance"; + var gar_pop = instance_create(0, 0, obj_popup); + gar_pop.title=$"Strange Disappearance"; gar_pop.pdata = _pdata; - gar_pop.text = $"Your Marines make planet fall and are directed to report to the governor for the duration of the operation after a period of reconnaissance dig in for their ambush. After a two weeks have passed A message from the governor reaches your astropaths that your marines have not been heard of for some time, The raiders also were not noted to have arrived onor left the planet"; + gar_pop.text=$"Your Marines make planet fall and are directed to report to the governor for the duration of the operation after a period of reconnaissance dig in for their ambush. After a two weeks have passed A message from the governor reaches your astropaths that your marines have not been heard of for some time, The raiders also were not noted to have arrived onor left the planet"; //pip.image="event_march" var _dead_marine = array_random_index(_squad_units); - for (var i = 0; i < array_length(_dead_marine); i++) { - if (i == _dead_marine) { + for (var i = 0;i _worst_hit) { + if (_loyalty_hit>_worst_hit){ _worst_hit = _loyalty_hit; _worst = i; } } } - - if (_worst == -1) { - text = $"You are able to convince your captains of the strategic need to cover up the incidence, various excuses are made and fake logs that cover up the disaster of the mission"; + + if (_worst == -1){ + text = $"You are able to convince your captains of the strategic need to cover up the incidence, various excuses are made and fake logs that cover up the disaster of the mission" } else { - text = $"Not all of your captains are convinced of the need to use deceit and a none have breached the order but it has soured your relations with a few namely {_caps[_worst].name_role()}"; - } + text = $"Not all of your captains are convinced of the need to use deceit and a none have breached the order but it has soured your relations with a few namely {_caps[_worst].name_role()}" + } } -function protect_raiders_hold_memorial() { - reset_popup_options(); - options1 = "continue"; - _pdata.add_disposition(-30); - text = $"You prepare to have a large public memorial for your fallen marines on the planet surface as a show of defiance. The chapter are pleased by such an act and the population of the planet are mesmerized by the spectacle. The governor is furious not only has his incompetence to deal with the planets xenos issue been made public in such a way that the sector commander has now heard about it but he perceives his failures are being paraded in font of him\n nGovernor Disposition : -30"; +function protect_raiders_hold_memorial(){ + reset_popup_options(); + options1 = "continue"; + _pdata.add_disposition(-30); + text = $"You prepare to have a large public memorial for your fallen marines on the planet surface as a show of defiance. The chapter are pleased by such an act and the population of the planet are mesmerized by the spectacle. The governor is furious not only has his incompetence to deal with the planets xenos issue been made public in such a way that the sector commander has now heard about it but he perceives his failures are being paraded in font of him\n nGovernor Disposition : -30"; } -function init_train_forces_mission(planet, star, mission_slot, marine) { - var _pdata = new PlanetData(planet, star); - var mission_data = _pdata.problems_data[mission_slot]; - if (mission_data.stage == "preliminary") { - var numeral_name = _pdata.name(); +function init_garrison_mission(planet, star, mission_slot){ + var problems_data = star.p_problem_other_data[planet] + var mission_data = problems_data[mission_slot]; + if (mission_data.stage == "preliminary"){ + var numeral_name = planet_numeral_name(planet, star); mission_data.stage = "active"; - var _mission_length = irandom_range(3, 12); - star.p_timer[planet][mission_slot] = _mission_length; + var garrison_length=(10+irandom(6)); + star.p_timer[planet][mission_slot] = garrison_length; //pop.image="ancient_ruins"; - var gar_pop = instance_create(0, 0, obj_popup); + var gar_pop=instance_create(0,0,obj_popup); //TODO some new universal methods for popups - gar_pop.title = $"Training forces on {numeral_name} begins"; - gar_pop.text = $"{marine.name_role()} Has taken leave of his current post in order to aid the governor of {numeral_name} and his pdf commanders with training local forces and bolstering defences."; - var _is_cap = role_compare(marine, eROLE.CAPTAIN); - - if (_is_cap) { - gar_pop.text += "the governor seems to be impressed that such a high ranking officer has been assigned to his request (disp +3)"; - _pdata.add_disposition(3); - } - + gar_pop.title=$"Requested Garrison Provided to {numeral_name}"; + gar_pop.text=$"The governor of {numeral_name} Thanks you for considering his request for a garrison, you agree that the garrison will remain for at least {garrison_length} months."; //pip.image="event_march" - gar_pop.add_option($"Good luck {marine.name()}"); - gar_pop.image = ""; - gar_pop.cooldown = 500; - obj_controller.cooldown = 500; - scr_event_log("", $"{marine.name_role()} deployed to {numeral_name} for {_mission_length} months.", star.name); - } + gar_pop.add_option("Commence Garrison"); + gar_pop.image=""; + gar_pop.cooldown=8; + obj_controller.cooldown=8; + scr_event_log("",$"Garrison committed to {numeral_name} for {garrison_length} months.", star.name ); + } } + //@mixin obj_star -function complete_garrison_mission(targ_planet, problem_index) { +function complete_garrison_mission(targ_planet, problem_index){ var planet = new PlanetData(targ_planet, self); - if (problem_has_key_and_value(targ_planet, problem_index, "stage", "active")) { - if (planet.current_owner == eFACTION.IMPERIUM && system_garrison[targ_planet - 1].garrison_force) { + if (problem_has_key_and_value(targ_planet,problem_index,"stage", "active")){ + if (planet.current_owner == eFACTION.IMPERIUM && system_garrison[targ_planet].garrison_force){ var _mission_string = $"The garrison on {planet_numeral_name(targ_planet)} has finished the period of garrison support agreed with the planetary governor."; - var p_garrison = system_garrison[targ_planet - 1]; - var result = p_garrison.garrison_disposition_change(id, targ_planet); - if (!p_garrison.garrison_leader) { + var p_garrison = system_garrison[targ_planet]; + var result = p_garrison.garrison_disposition_change(id, targ_planet); + if (!p_garrison.garrison_leader){ p_garrison.find_leader(); } - if (result == "none") { - //TODO make a dedicated plus minus string function if there isn't one already - } else if (!result) { - var effect = result * irandom_range(1, 5); + if (result == "none"){ + //TODO make a dedicated plus minus string function if there isn't one already + } else if (!result){ + var effect = result * irandom_range(1,5); dispo[targ_planet] += effect; _mission_string += $"A number of diplomatic incidents occured over the period which had considerable negative effects on our disposition with the planetary governor (disposition -{effect})"; } else { - var effect = result * irandom_range(1, 5); + var effect = result * irandom_range(1,5); dispo[targ_planet] += result * effect; _mission_string += $"As a diplomatic mission the duration of the stay was a success with our political position with the planet being enhanced greatly (disposition +{effect})"; } var tester = global.character_tester; - var widom_test = tester.standard_test(p_garrison.garrison_leader, "wisdom", 0, ["siege"]); - if (widom_test[0]) { + var widom_test = tester.standard_test(p_garrison.garrison_leader, "wisdom",0, ["siege"]); + if (widom_test[0]){ p_fortified[targ_planet]++; - _mission_string += $"while stationed {p_garrison.garrison_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications++)."; + _mission_string+=$"while stationed {p_garrison.garrison_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications++)."; } //TODO just generall apply this each turn with a garrison to see if a cult is found - if (planet_feature_bool(p_feature[targ_planet], eP_FEATURES.GENE_STEALER_CULT)) { - var cult = return_planet_features(planet.features, eP_FEATURES.GENE_STEALER_CULT)[0]; - if (cult.hiding) { - widom_test = tester.standard_test(p_garrison.garrison_leader, "wisdom", 0, ["tyranids"]); - if (widom_test[0]) { + if (planet_feature_bool(p_feature[targ_planet], P_features.Gene_Stealer_Cult)){ + var cult = return_planet_features(planet.features,P_features.Gene_Stealer_Cult)[0]; + if (cult.hiding){ + widom_test = tester.standard_test(p_garrison.garrison_leader, "wisdom",0, ["tyranids"]); + if (widom_test[0]){ cult.hiding = false; - _mission_string += "Most alarmingly signs of a genestealer cult are noted by the garrison. how far the rot has gone will now need to be investigated and the xenos taint purged."; + _mission_string+="Most alarmingly signs of a genestealer cult are noted by the garrison. how far the rot has gone will now need to be investigated and the xenos taint purged."; } } } - scr_popup($"Agreed Garrison of {planet_numeral_name(targ_planet)} complete", _mission_string, "", ""); + scr_popup($"Agreed Garrison of {planet_numeral_name(targ_planet)} complete",_mission_string,"",""); } else { planet.add_disposition(-20); - scr_popup($"Agreed Garrison of {planet_numeral_name(targ_planet)}", $"your agreed garrison of {planet_numeral_name(targ_planet)} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)", "", ""); + scr_popup($"Agreed Garrison of {planet_numeral_name(targ_planet)}",$"your agreed garrison of {planet_numeral_name(targ_planet)} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)","",""); } remove_planet_problem(targ_planet, "provide_garrison"); } else { remove_planet_problem(targ_planet, "provide_garrison"); - } + } +} + + + +function init_train_forces_mission(planet, star, mission_slot, marine){ + var _pdata = new PlanetData(planet, star); + var mission_data = _pdata.problems_data[mission_slot]; + if (mission_data.stage == "preliminary"){ + var numeral_name = _pdata.name(); + mission_data.stage = "active"; + var _mission_length=(irandom_range(3,12)); + star.p_timer[planet][mission_slot] = _mission_length; + //pop.image="ancient_ruins"; + var gar_pop=instance_create(0,0,obj_popup); + //TODO some new universal methods for popups + gar_pop.title=$"Training forces on {numeral_name} begins"; + gar_pop.text=$"{marine.name_role()} Has taken leave of his current post in order to aid the governor of {numeral_name} and his pdf commanders with training local forces and bolstering defences."; + var _is_cap = role_compare(marine, eROLE.CAPTAIN); + + if (_is_cap){ + gar_pop.text += "the governor seems to be impressed that such a high ranking officer has been assigned to his request (disp +3)"; + _pdata.add_disposition(3); + } + + //pip.image="event_march" + gar_pop.add_option($"Good luck {marine.name()}"); + gar_pop.image=""; + gar_pop.cooldown=500; + obj_controller.cooldown=500; + scr_event_log("",$"{marine.name_role()} deployed to {numeral_name} for {_mission_length} months.", star.name); + } } -function complete_train_forces_mission(targ_planet, problem_index) { + +function complete_train_forces_mission(targ_planet, problem_index){ var planet = new PlanetData(targ_planet, self); - if (problem_has_key_and_value(targ_planet, problem_index, "stage", "active")) { + if (problem_has_key_and_value(targ_planet,problem_index,"stage","active")){ var man_conditions = { "job": "train_forces", - "max": 1, - }; + "max" : 1, + } var _mission_string = ""; - var _trainer = collect_role_group("all", [name, targ_planet, 0], false, man_conditions); - if (array_length(_trainer)) { + var _trainer = collect_role_group("all",[name,targ_planet,0], false, man_conditions); + if (array_length(_trainer)){ var _unit_report_string = ""; var _tester = global.character_tester; var _wis_test_difficulty = -20; _trainer = _trainer[0]; var _tyannic_vet = _trainer.has_trait("tyrannic_vet"); - if (_tyannic_vet) { + if (_tyannic_vet){ _wis_test_difficulty += 10; - if (planet.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - var _cult = planet.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; - if (_cult.hiding) { - planet.delete_feature(eP_FEATURES.GENE_STEALER_CULT); + if (planet.has_feature(P_features.Gene_Stealer_Cult)){ + var _cult = planet.get_features(P_features.Gene_Stealer_Cult)[0]; + if (_cult.hiding){ + planet.delete_feature(P_features.Gene_Stealer_Cult); _mission_string += $"Fortune has smiled on this mission, {_trainer.name_role()}'s abilities as a Veteran of dealing with the Tyranids came in handy and in a short period was able to discern the existencee of a cult. He was able to organise those he considered to be still loyal to rally an extermiation of the cult, reeports suggest he was so successful as to have completely wiped the genestealer presence from the planet"; } } } var _siege_master = _trainer.has_trait("siege_master"); - if (_siege_master) { - _wis_test_difficulty += 10; + if (_siege_master){ + _wis_test_difficulty+=10; } var _brute = _trainer.has_trait("brute"); - if (_brute) { - _wis_test_difficulty -= 10; + if (_brute){ + _wis_test_difficulty-=10; } var _leader = _trainer.has_trait("natural_leader"); - if (_leader) { - _wis_test_difficulty += 10; + if (_leader){ + _wis_test_difficulty+=10; } - _unit_pass = _tester.standard_test(_trainer, "wisdom", _wis_test_difficulty); - if (_unit_pass[0]) { - var _new_pdf = planet.recruit_pdf((_unit_pass[1] / 10)); //this will approximate podf improvement for the time being + _unit_pass = _tester.standard_test(_trainer, "wisdom",_wis_test_difficulty); + if (_unit_pass[0]){ + var _new_pdf = planet.recruit_pdf((_unit_pass[1]/10));//this will approximate podf improvement for the time being _mission_string += $"Training of the Pdf went well and improved the quality of the pdf as well as providing sizeable big recruitment improvement for the planet {_new_pdf} new pdf were recruited"; - if (_leader) { + if (_leader){ var _disp_gain = 10; planet.add_disposition(_disp_gain); - _mission_string += $"\n{_trainer.name_role()}s reputation a natural and confident leader proved well earned as he also made excellent diplomatic headway with the governor and his generals (disposition +{_disp_gain})"; + _mission_string += $"\n{_trainer.name_role()}s reputation a natural and confident leader proved well earned as he also made excellent diplomatic headway with the governor and his generals (disposition +{_disp_gain})" } - if (_siege_master) { + if (_siege_master){ _mission_string += $"{_trainer.name()}s trained eye as a Siege Master also allowed him to make several improvements to the planets fortifications (fortification +1)"; planet.alter_fortification(1); } else { - if (roll_dice(1, 100) > 75 && _trainer.intelligence > 45) { + if (roll_dice(1, 100) > 75 && _trainer.intelligence > 45){ _mission_string += $"{_trainer.name()} has proven themselves a great strategist when it comes to defensive structures beyond previousy known "; var _start_stats = variable_clone(_trainer.get_stat_line()); _trainer.add_trait("siege_master"); var end_stat = _trainer.get_stat_line(); - var _stat_diff = compare_stats(end_stat, _start_stats); - _unit_report_string += $"{_trainer.name_role()} Has gained the trait {global.trait_list.siege_master.display_name}, {print_stat_diffs(_stat_diff)}\n"; + var _stat_diff = compare_stats(end_stat,_start_stats); + _unit_report_string += $"{_trainer.name_role()} Has gained the trait {global.trait_list.siege_master.display_name}, {(print_stat_diffs(_stat_diff))}\n"; _mission_string += "The new insights have allowed for minor improvements to planetary fortifications (fortification +1)"; planet.alter_fortification(1); } } } else { disp_loss = -5; - _mission_string += "The orgional training mission was a failiure"; - if (_brute) { - _mission_string += "in no short part due to his brutish nature"; + _mission_string += "The orgional training mission was a failiure" + if (_brute){ + _mission_string += "in no short part due to his brutish nature (Trait : Brute)"; } _mission_string += "."; - _mission_string += "He failed to work effectively with the existing chain of command"; - - if (_unit_pass[1] < -20) { - var _hard_loss_traits = [ - "harshborn", - "feral", - "zealous_faith", - "blood_for_blood", - "blunt", - "brute", - "brawler" - ]; + _mission_string+= "He failed to work effectively with the existing chain of command"; + + if (_unit_pass[1]<-20){ + var _hard_loss_traits = ["harshborn", "feral", "zealous_faith", "blood_for_blood", "blunt","brute", "brawler"]; var _hard_loss = false; - for (var i = 0; i < array_length(_hard_loss_traits); i++) { - if (array_contains(_trainer.traits, _hard_loss_traits[i])) { + for (var i=0;i= -10) { - if (irandom(100) < _unit.luck) { + } else if (_tough_check[1]>=-10){ + if (irandom(100)<_unit.luck){ _unit.add_or_sub_health(-100); _unit_report_string += $"{_unit.name_role()} Was injured (health - 100)\n"; } else { @@ -527,54 +627,253 @@ function complete_beast_hunt_mission(targ_planet, problem_index) { } } } - _unit.job = "none"; + _unit.job="none" + } + + var _pop_data = ""; + var _navy_fleets = get_imperial_navy_fleets(); + if (array_length(_successful_hunters) && _largest_pass > 20 && array_length(_navy_fleets)){ + _pop_data = { + trophy_owner : array_random_element(_successful_hunters), + system: self.name, + planet : targ_planet, + target_fleet : array_random_element(_navy_fleets), + beast :_problem_data.beast_name, + planet_type : _planet.planet_type, + }; + + var _options = { + choice_func : init_deliver_trophy_mission, + str1 : "Continue", + } + + _pop_data.options = _options; } - if (_success) { - _mission_string = $"The mission was a success and a great number of beasts rounded up and slain, your marines were able to gain great skills and the prestige of your chapter has increased greatly across the planets populace."; - if (_deaths) { - _mission_string += $"Unfortunatly {_deaths} of your marines died."; + if (_success){ + _mission_string = $"The mission was a success and a great number of beasts rounded up and slain, your marines were able to gain great skills and the prestige of your chapter has increased greatly across the planets populace." + if (_deaths){ + _mission_string += $"Unfortunatly {_deaths} of your marines died." } _mission_string += $"\n{_unit_report_string}"; } else { _mission_string = $"The mission was a failiure. The governor is disapointed and the legend of your chapter has undoubtedly been diminished"; _mission_string += $"\n{_unit_report_string}"; } - scr_popup($"Beast Hunt on {planet_numeral_name(i)}", _mission_string, "", ""); + scr_popup($"Beast Hunt on {planet_numeral_name(i)}",_mission_string,"",_pop_data); remove_planet_problem(targ_planet, "hunt_beast"); + } else { remove_planet_problem(targ_planet, "hunt_beast"); + } +} +function init_deliver_trophy_mission(){ + pop_data.trophy_name = format_beast_trophy(pop_data.beast); + text = $"Much fanfare is made of the great trophy {pop_data.trophy_owner.name_role()} bears: {pop_data.trophy_name}."; + text += $" The governor proclaims it proof that {pop_data.beast} was the most fearsome predator in the sector."; + + + text += $"\n\nAn astropathic message is later recieved from the Commander of an Imperial Navy fleet explaining that his fleet is currrently home to the {irandom_numeral(100)},{irandom_numeral(100)} and {irandom_numeral(100)} {pop_data.system} Regiments and pleads that the trophy be handed over to his fleet in order to boost the moral of the regiments and fleet in general"; + + replace_options([ + { + str1 : "Refuse and place the trophy into the Librarium", + choice_func : function(){ + reset_popup_options(); + var _tag = ""; + var _daemonic = roll_dice_chapter(1, 10, "low"); + if (_daemonic == 10){ + _tag = "daemonic"; + } + var _arti = scr_add_artifact("trophy", _tag, 0, ""); + _arti = fetch_artifact(_arti); + _arti.name = pop_data.trophy_name; + _arti.set_loc(_pop_data.system); + //base_type == choose("gear", "weapon", "trophy"); + var _base_type = choose("weapon", "trophy"); + if (_base_type == "weapon"){ + _arti.update_type("Company Standard"); + } + + text = "Your Marines elect to keep the {pop_data.trophy_name} for the chapter in it's honour!"; + + if (_base_type == "weapon"){ + text += "The grisly remains have been fashioned into a make shift standard that is crude but fearsome to behold"; + } + } + + }, + { + str1 : "Accept", + choice_func : accept_deliver_trophy_mission + } + ]); + +} + + + +function accept_deliver_trophy_mission(){ + text = $"You Send a reply to tell the commander you accept and will ensure the trophy is delivered in person by the marine that slew the beast"; + var _targ_fleet = pop_data.target_fleet; + + var _targ_fleet_intercept = fleets_next_location(_targ_fleet); + if (_targ_fleet.action == ""){ + text += $"\n\n the fleet in question is currently active around the {_targ_fleet_intercept.name} system"; + } else { + text += $"\n\n the fleet will next be accessible around the {_targ_fleet_intercept.name} system"; + } + + pop_data.target_fleet = _targ_fleet.uid; + + pop_data.delivering_marine = pop_data.trophy_owner.name_role(); + var _t_owner = pop_data.trophy_owner; + pop_data.trophy_owner = _t_owner.uid; + + var _fleet_event = new FleetEvent(pop_data); + + _fleet_event.turn_end = "deliver_trophy_end_turn_check"; + _fleet_event.destroy = "deliver_trophy_mission_fleet_destroyed"; + _fleet_event.timer_end = "deliver_trophy_mission_timed_out"; + + _fleet_event.timer = 120; + + _targ_fleet.add_event(_fleet_event); + + reset_popup_options(); +} + + +///@mixin FleetEvent +function deliver_trophy_mission_timed_out(){ + scr_popup( + "Objective Forgotten", + $"It has been so long in the life of a mortal that the commanders that once saught your delivery of the trophy from the hunt on {fleetevent_data.system} have now all either died or moved to greener pastures. The trophy will instead remain in the chapters possession", + ); +} + +///@mixin FleetEvent +function deliver_trophy_mission_fleet_destroyed(){ + scr_popup( + "Fleet Destroyed", + $"With the Imperial Navy fleet containing the regiments from {fleetevent_data.system} destroyed there is no reason to now deliver the trophy from the hunt to them The trophy will instead remain in the chapters possession", + ); +} + +function get_beast_epithet(_planet_type){ + switch (_planet_type){ + case "Feudal": return "The King-Slayer"; + case "Ice": return "The Pale Reaper"; + case "Death": return "The Emperor’s Fang"; + } + return ""; +} + + + +///@mixin FleetEvent +function deliver_trophy_end_turn_check(){ + var _navy_fleet = get_fleet_uid(fleet_uid); + if (!instance_exists(_navy_fleet)){ + deliver_trophy_mission_fleet_destroyed(); + return; + } + + var _ratio =0; + with (_navy_fleet){ + _ratio = fleet_remaining_guard_ratio(); + } + + if (_ratio<=0){ + scr_popup( + "Regiments Destroyed ", + $"The guard Regiments from {fleetevent_data.system} serving in the imperial navy fleet have been annihilated wholesale there is no reason to now deliver the trophy from the hunt to them The trophy will instead remain in the chapters possession", + ); + return; + } + + if (is_orbiting(_navy_fleet)){ + var _nearest_player = instance_at_location(_navy_fleet.x,_navy_fleet.y,obj_p_fleet); + if (instance_exists(_nearest_player)){ + var _ships = fleet_full_ship_array(_nearest_player); + var _marine = fetch_unit_uid(fleetevent_data.trophy_owner); + var _present = _marine.is_at_location("", 0, _ships); + var _meet_point = _navy_fleet.orbiting; + if (_present){ + var _text = "{_marine.role(name)} is able to rendevous with the imperial navy at {_meet_point.name}." + _text += $" The guard regiments of {fleetevent_data.system} are overjoyed at the delivery of the trophy and find the beast that the head came from adorns many of the regiments banners."; + var _marine_epithet = get_beast_epithet(fleetevent_data.planet_type); + + _marine.add_epithet({ + title : _marine_epithet, + story : $"Slew a mighty beast in {fleetevent_data.system} after harvesting the {pop_data.trophy_name} their exploits became legendary within the sector largly due the aderation of the {fleetevent_data.system} regiments" + }) + _text += $" While The task is for the most part thankless your chapters esteem has risen greatly with the exploits of {_marine.name_role()} spreading far and wide amoung guard regiments and has garnered the epithet {_marine_epithet}."; + var _roll = roll_dice_chapter(1, 100, "high"); + if (_roll>30 && _roll<70){ + //TODO would be cool to have this changed to be a guard specific piece of equipment + _text += "In return for your labour and in honour of your chapter the commander of the guard division has a brand new Rhino destined for the army diverted to your chapter"; + scr_add_vehicle("Rhino"); + } else if (_roll>=70 ){ + init_newly_revealed_battle_ground(); + } + scr_popup( + "Trophy Delivered ", + _text, + ); + } + } + } +} + +function init_newly_revealed_battle_ground(){ + var _wanted_types = ["Ice","Desert","Agri","Lava","Death"]; + var _star = scr_get_stars(true,[],_wanted_types)[0]; + if (array_length(_star)){ + _star = _star[0] } + _text += "During the concourse that follows with the fleet command your marines learn of a old battle ground discovered on {_star.name}."; + _text += "According too intel it appeared to be an old astartes battle ground from an unknown age, communications have been passed onto the adeptus mechanicus who will no doubt pick the site clean should they reach it before you do"; + + var _planet = scr_get_planet_with_type(_wanted_types); + var _battle_ground = new NewPlanetFeature(P_features.OLDBATTLEGROUND); + + _battle_ground.player_hidden = false; + + _battle_ground.imperium_known = true; + + _star.add_feature(_planet,_battle_ground); } + //TODO allow most of these functions to be condensed and allow arrays of problems or planets and maybe increase filtering options //filtering options could be done via universal methods that all the filters to be passed to many other game systems -function has_any_problem_planet(planet, star = "none") { - if (star == "none") { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] != "") { +function has_any_problem_planet(planet, star="none"){ + if (star=="none"){ + for (var i=0;i 0) { - _had_problem = i; + if (star=="none"){ + for (var i = 0;i0){ + _had_problem=i; } } } } else { - with (star) { - _had_problem = has_problem_planet_with_time(planet, problem); + with (star){ + _had_problem=has_problem_planet_with_time(planet, problem) } } - return _had_problem; + return _had_problem; } -//returns the array position of a gien problem on a given planet -function find_problem_planet(planet, problem, star = "none") { - if (star == "none") { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] == problem) { + +//returns the array position of a gien problem on a given planet +function find_problem_planet(planet, problem, star="none"){ + if (star=="none"){ + for (var i = 0;i 0) { - p_tyranids[ork_attack_planet] -= floor(_ork_fleet.capital_number + (_ork_fleet.frigate_number / 2)); + if (ork_attack_planet>0){ + p_tyranids[ork_attack_planet] -= round(standard_fleet_strength_calc(_ork_fleet)); var _pdata = new PlanetData(ork_attack_planet, self); diff --git a/scripts/scr_planetary_feature/scr_planetary_feature.gml b/scripts/scr_planetary_feature/scr_planetary_feature.gml index 76153adc5..f7593908e 100644 --- a/scripts/scr_planetary_feature/scr_planetary_feature.gml +++ b/scripts/scr_planetary_feature/scr_planetary_feature.gml @@ -1,32 +1,33 @@ enum eP_FEATURES { - SORORITAS_CATHEDRAL, - NECRON_TOMB, - ARTIFACT, - STC_FRAGMENT, - ANCIENT_RUINS, - CAVE_NETWORK, - RECRUITING_WORLD, - MONASTERY, - WARLORD6, - ORKWARBOSS, - WARLORD10, - SPECIAL_FORCE, - CHAOSWARBAND, - WEBWAY, - SECRET_BASE, - STARSHIP, - SUCCESSION_WAR, - MECHANICUS_FORGE, - RECLAMATION_POOLS, - CAPILLARY_TOWERS, - DAEMONIC_INCURSION, - VICTORY_SHRINE, - ARSENAL, - GENE_VAULT, - FORGE, - GENE_STEALER_CULT, - MISSION, - ORKSTRONGHOLD, + SORORITAS_CATHEDRAL, + NECRON_TOMB, + ARTIFACT, + STC_FRAGMENT, + ANCIENT_RUINS, + CAVE_NETWORK, + RECRUITING_WORLD, + MONASTERY, + WARLORD6, + ORKWARBOSS, + WARLORD10, + SPECIAL_FORCE, + CHAOSWARBAND, + WEBWAY, + SECRET_BASE, + STARSHIP, + SUCCESSION_WAR, + MECHANICUS_FORGE, + RECLAMATION_POOLS, + CAPILLARY_TOWERS, + DAEMONIC_INCURSION, + VICTORY_SHRINE, + ARSENAL, + GENE_VAULT, + FORGE, + GENE_STEALER_CULT, + MISSION, + ORKSTRONGHOLD, + OLDBATTLEGROUND } enum eBASE_TYPES { @@ -42,12 +43,152 @@ function PlayerForge() constructor { } // Function creates a new struct planet feature of a specified type -function NewPlanetFeature(feature_type, other_data = {}) constructor { - f_type = feature_type; - - static reveal_to_player = function() { - if (player_hidden == 1) { - player_hidden = 0; +function NewPlanetFeature(feature_type, other_data={}) constructor{ + f_type = feature_type; + static reveal_to_player = function(){ + if (player_hidden == 1){ + player_hidden = 0; + } + } + switch(f_type){ + case eP_FEATURES.GENE_STEALER_CULT: + PDF_control = 0; + sealed = 0; + player_hidden = 1; + planet_display = "Genestealer Cult"; + cult_age = 0; + hiding=true; + name = global.name_generator.GenerateFromSet("genestealercult") + break; + case eP_FEATURES.NECRON_TOMB: + awake = 0; + sealed = 0; + player_hidden = 1; + planet_display = "Dormant Necron Tomb"; + break; + case eP_FEATURES.OLDBATTLEGROUND: + player_hidden = true; + imperium_known = false; + //This is janky but we have no way of defining non player astartes + faction1 = "astartes"; + faction2 = "imperium"; + explore_size = irandom_range(1000, 10000); + explored = 0; + planet_display = "Old Battle Ground"; + break; + case eP_FEATURES.SECRET_BASE: + base_type = base_types.Lair; + inquis_hidden = 1; + planet_display = "Hidden Secret Base"; + player_hidden = 0; + style = "UTL"; + if (struct_exists(other_data, "style")){ + style = other_data[$ "style"]; + } + built = obj_controller.turn +3; + forge = 0; + hippo=0; + beastarium=0; + torture=0; + narcotics=0; + relic=0; + cookery=0; + vox=0; + librarium=0; + throne=0; + stasis=0; + swimming=0; + stock=0; + break; + case eP_FEATURES.ARSENAL: + inquis_hidden = 1; + planet_display = "Arsenal"; + player_hidden = 0; + built = obj_controller.turn+3; + break; + case eP_FEATURES.GENE_VAULT: + inquis_hidden=1; + planet_display = "Arsenal"; + player_hidden = 0; + built = obj_controller.turn+3; + break; + case eP_FEATURES.STARSHIP: + f_type = eP_FEATURES.STARSHIP; + planet_display = "Ancient Starship"; + funds_spent = 0; + player_hidden = 0; + engineer_score = 0; + break; + case eP_FEATURES.ANCIENT_RUINS: + static ruins_explored = scr_ruins_explored; + static explore = scr_explore_ruins; + static determine_race = scr_ruins_determine_race; + static recover_from_dead = scr_ruins_recover_from_dead; + static forces_defeated = scr_ruins_player_forces_defeated; + static find_starship = scr_ruins_find_starship; + static suprise_attack = scr_ruins_suprise_attack_player; + static ruins_combat_end=scr_ruins_combat_end; + scr_ancient_ruins_setup(); + break; + case eP_FEATURES.STC_FRAGMENT: + player_hidden = 1; + Fragment_type =0; + planet_display = "STC Fragment"; + break; + case eP_FEATURES.CAVE_NETWORK: + player_hidden = 1; + cave_depth =irandom(3);//allow_multiple levels of caves, option to go deeper + planet_display = "Unexplored Cave Network"; + break; + case eP_FEATURES.SORORITAS_CATHEDRAL: + player_hidden = 1; + planet_display = "Sororitas Cathedral"; + break; + case eP_FEATURES.ARTIFACT: + player_hidden = 1; + planet_display = "Artifact"; + break; + case eP_FEATURES.ORKWARBOSS: + player_hidden = 1; + planet_display = "Ork Warboss"; + Warboss = "alive"; + name = global.name_generator.generate_ork_name(); + turns_static = 0; + break; + case eP_FEATURES.ORKSTRONGHOLD: + player_hidden = 1; + planet_display= "Ork Stronghold"; + tier = 1; + break; + case eP_FEATURES.MONASTERY: + planet_display="Fortress Monastary"; + player_hidden = 0; + forge=0; + name=global.name_generator.GenerateFromSet("imperial_ship"); + break; + case eP_FEATURES.RECRUITING_WORLD: + planet_display="Recruitment"; + player_hidden = 0; + recruit_type = 0; + recruit_cost = 0; + break; + case eP_FEATURES.CHAOSWARBAND: + if !(struct_exists(other_data, "patron")){ + patron = choose("slaanesh", "tzeentch", "khorne", "nurgle", "undivided"); + } else { + self.patron = other_data.patron; + } + default: + player_hidden = 1; + planet_display = 0; + } + if (global.cheat_debug){ + player_hidden = 0; + } + static load_json_data = function(data){ + var names = variable_struct_get_names(data); + for (var i = 0; i < array_length(names); i++) { + variable_struct_set(self, names[i], variable_struct_get(data, names[i])) } }; @@ -219,15 +360,16 @@ function return_planet_features(planet, search_feature) { } // returns 1 if dearch feature is on at least one planet in system returns 0 is search feature is not found in system -function system_feature_bool(system, search_feature) { - var sys_bool = 0; - for (var sys = 1; sys < 5; sys++) { - sys_bool = planet_feature_bool(system[sys], search_feature); - if (sys_bool == 1) { - break; - } - } - return sys_bool; +function system_feature_bool(system, search_feature){ + var sys_bool = 0; + for (var sys =1; sys<5; sys++){ + sys_bool = planet_feature_bool(system[sys], search_feature) + if (sys_bool==1){ + sys_bool = sys; + break; + } + } + return sys_bool; } //returns 1 if feature found on given planet returns 0 if feature not found on planet @@ -326,60 +468,60 @@ function awaken_tomb_world(planet) { // creates alerts for discovering features on a planet function scr_planetary_feature(planet_num) { - var plan_feat_count = array_length(p_feature[planet_num]); - //need to iterate over features instead of just looking at first - for (var f = 0; f < plan_feat_count; f++) { - var feat = p_feature[planet_num][f]; - if (feat.player_hidden == 1) { - feat.player_hidden = 0; - var numeral_n = planet_numeral_name(planet_num); - switch (feat.f_type) { - case eP_FEATURES.SORORITAS_CATHEDRAL: - if (obj_controller.known[eFACTION.ECCLESIARCHY] == 0) { - obj_controller.known[eFACTION.ECCLESIARCHY] = 1; - } - var lop = $"Sororitas Cathedral discovered on {numeral_n}."; - scr_alert("green", "feature", lop, x, y); - scr_event_log("", lop); - if (p_heresy[planet_num] > 10) { - p_heresy[planet_num] -= 10; - } - p_sisters[planet_num] = choose(2, 2, 3); - goo = 1; - break; - case eP_FEATURES.NECRON_TOMB: - var lop = $"Necron Tomb discovered on {numeral_n}."; - scr_alert("red", "feature", lop, x, y); - scr_event_log("red", lop); - break; - case eP_FEATURES.ARTIFACT: - var lop = $"Artifact discovered on {numeral_n}."; - scr_alert("green", "feature", lop, x, y); - scr_event_log("", lop); - break; - case eP_FEATURES.STC_FRAGMENT: - var lop = $"STC Fragment located on {numeral_n}."; - scr_alert("green", "feature", lop, x, y); - scr_event_log("", lop); - break; - case eP_FEATURES.ANCIENT_RUINS: - var lop = $"A {feat.ruins_size} Ancient Ruins discovered on {string(name)} {scr_roman(planet_num)}."; - scr_alert("green", "feature", lop, x, y); - scr_event_log("", lop); - break; - case eP_FEATURES.CAVE_NETWORK: - var lop = $"Extensive Cave Network discovered on {numeral_n}."; - scr_alert("green", "feature", lop, x, y); - scr_event_log("", lop); - break; - case eP_FEATURES.ORKWARBOSS: - var lop = $"Ork Warboss discovered on {numeral_n}."; - scr_alert("red", "feature", lop, x, y); - scr_event_log("red", lop); - break; - } - } - } + var plan_feat_count = array_length(p_feature[planet_num]); + //need to iterate over features instead of just looking at first + for (var f= 0; f < plan_feat_count;f++){ + var feat = p_feature[planet_num][f]; + if (feat.player_hidden ==1){ + feat.player_hidden =0; + var numeral_n = planet_numeral_name(planet_num); + switch (feat.f_type){ + case eP_FEATURES.SORORITAS_CATHEDRAL: + if (obj_controller.known[eFACTION.ECCLESIARCHY]=0) then obj_controller.known[eFACTION.ECCLESIARCHY]=1; + var lop=$"Sororitas Cathedral discovered on {numeral_n}."; + scr_alert("green","feature",lop,x,y); + scr_event_log("",lop); + if (p_heresy[planet_num]>10) then p_heresy[planet_num]-=10; + p_sisters[planet_num]=choose(2,2,3);goo=1; + break; + case eP_FEATURES.NECRON_TOMB: + var lop=$"Necron Tomb discovered on {numeral_n}."; + scr_alert("red","feature",lop,x,y); + scr_event_log("red",lop); + break; + case eP_FEATURES.ARTIFACT: + var lop=$"Artifact discovered on {numeral_n}."; + scr_alert("green","feature",lop,x,y); + scr_event_log("",lop); + break; + case eP_FEATURES.STC_FRAGMENT: + var lop=$"STC Fragment located on {numeral_n}."; + scr_alert("green","feature",lop,x,y); + scr_event_log("",lop); + break; + case eP_FEATURES.ANCIENT_RUINS: + var lop=$"A {feat.ruins_size} Ancient Ruins discovered on {string(name)} {scr_roman(planet_num)}."; + scr_alert("green","feature",lop,x,y); + scr_event_log("",lop); + break; + case eP_FEATURES.CAVE_NETWORK: + var lop=$"Extensive Cave Network discovered on {numeral_n}."; + scr_alert("green","feature",lop,x,y); + scr_event_log("",lop); + break; + case eP_FEATURES.ORKWARBOSS: + var lop=$"Ork Warboss discovered on {numeral_n}."; + scr_alert("red","feature",lop,x,y); + scr_event_log("red",lop); + break; + case eP_FEATURES.OLDBATTLEGROUND: + var lop=$"Old Battle Ground discovered on {numeral_n}."; + scr_alert("green","feature",lop,x,y); + scr_event_log("red",lop); + break; + } + } + } } function create_starship_event() { 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 4b749da32..8e02dfc0e 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -18,6 +18,14 @@ function fleet_has_roles(fleet = "none", roles) { } } +function get_player_fleet_intercept_time(star,time_abundance){ + var _travel = -1 + var _nearest_player_fleet = instance_nearest(star.x, star.y, obj_p_fleet); + if (instance_exists(_nearest_player_fleet)){ + _travel = get_viable_travel_time(time_abundance, _nearest_player_fleet.x, _nearest_player_fleet.y, star.x, star.y, _nearest_player_fleet, false); + } +} + function fleet_engaged(fleet = undefined){ var _engaged = false; if (fleet == undefined){ @@ -223,16 +231,10 @@ function delete_ship_from_fleet(index, fleet) { fleet.escort_number--; } } - -function set_player_fleet_image() { - var ii = 0; - ii += capital_number; - ii += round((frigate_number / 2)); - ii += round((escort_number / 4)); - if (ii <= 1) { - ii = 1; - } - image_index = min(ii, 9); +function set_player_fleet_image(){ + var ii=round(standard_fleet_strength_calc()) + if (ii<=1) then ii=1; + image_index=min(ii,9); } function find_ships_fleet(index) { diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index af5024e94..5019ad08d 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -437,7 +437,7 @@ function calculate_equipment_needs() { } return floor(all_good); } - +//TODO ensure all popups have an appropriate image assigned for flavour /// @mixin function default_popup_image_index() { var _img = -1; @@ -573,20 +573,27 @@ function default_popup_image_index() { /// @mixin function allow_governor_successor() { - var randa = roll_dice_chapter(1, 100, "high"); - var randa2 = roll_dice(1, 100); - p_data.set_player_disposition(obj_controller.disposition[2] + choose(-1, -2, -3, -4, 0, 1, 2, 3, 4)); + + var _randa = roll_dice_chapter(1, 100, "high"); + var _randa2 = roll_dice(1, 100); + + var _old_governor = p_data.governor; + + var _new_governor = p_data.new_governor(); + var _newdisp = 0; var _text_last = ""; - if (randa <= 3) { - var _newdisp = min(p_data.player_disposition, choose(1, 2, 3, 4, 5, 6) * 3); + if (_randa <= 3) { + _newdisp = min(p_data.player_disposition, irandom_range(3, 18)); p_data.set_player_disposition(_newdisp); _text_last = "Regrettably he has a dim view of your chapter"; } - if (randa >= 95) { - _newdisp = max(p_data.player_disposition, 60 + choose(1, 2, 3, 4, 5, 6) * 3); + else if (_randa >= 95) { + _newdisp = max(p_data.player_disposition, irandom_range(63, 78)); p_data.set_player_disposition(_newdisp); _text_last = "Fortunately you already have good relations with the new governor"; + } else { + p_data.set_player_disposition(obj_controller.disposition[2] + irandom_range(-8,8)); } scr_event_log("", $"Planetary Governor of {p_data.name()} assassinated. The next in line takes over."); diff --git a/scripts/scr_purge_world/scr_purge_world.gml b/scripts/scr_purge_world/scr_purge_world.gml index 1afd559cd..9ce1c5666 100644 --- a/scripts/scr_purge_world/scr_purge_world.gml +++ b/scripts/scr_purge_world/scr_purge_world.gml @@ -1,224 +1,192 @@ -function scr_purge_world(star, planet, action_type, action_score) { - var pop_before, pop_after, sci1, sci2, txt1, txt2, max_kill, overkill, heres_before, heres_after, kill; - var isquest, thequest, questnum; - isquest = 0; - thequest = ""; - questnum = 0; - pop_after = 0; - txt1 = ""; - txt2 = ""; - overkill = 0; - - if (((action_type == eDROP_TYPE.PURGEFIRE) || (action_type == eDROP_TYPE.PURGESELECTIVE)) && (star.p_traitors[planet] == 0) && (star.p_chaos[planet] == 0) && (obj_controller.turn >= obj_controller.chaos_turn)) { - if ((planet_feature_bool(star.p_feature[planet], eP_FEATURES.WARLORD10) == 1) && (obj_controller.known[10] == 0) && (obj_controller.faction_gender[10] == 1)) { - with (obj_drop_select) { - var pop = instance_create(0, 0, obj_popup); - pop.image = "chaos_symbol"; - pop.title = "Concealed Heresy"; - pop.text = $"Your astartes set out and begin to cleanse {planet_numeral_name(planet, star)} of possible heresy. The general populace appears to be devout in their faith, but a disturbing trend appears- the odd citizen cursing your forces, frothing at the mouth, and screaming out heresy most foul. One week into the cleansing a large hostile force is detected approaching and encircling your forces."; - exit; - } - } - if ((planet_feature_bool(star.p_feature[planet], eP_FEATURES.WARLORD10) == 1) && (obj_controller.known[10] >= 2) && (obj_controller.faction_gender[10] == 1)) { - with (obj_drop_select) { - attacking = 10; - obj_controller.cooldown = 30; - combating = 1; // Start battle here - - instance_deactivate_all(true); - instance_activate_object(obj_controller); - instance_activate_object(obj_ini); - instance_activate_object(obj_drop_select); - - instance_create(0, 0, obj_ncombat); - obj_ncombat.battle_object = p_target; - obj_ncombat.battle_loc = p_target.name; - obj_ncombat.battle_id = obj_controller.selecting_planet; - obj_ncombat.dropping = 0; - obj_ncombat.attacking = 10; - obj_ncombat.enemy = 10; - obj_ncombat.formation_set = 1; - - /* - obj_ncombat.battle_object=p_target; - obj_ncombat.battle_loc=p_target.name; - obj_ncombat.battle_id=obj_controller.selecting_planet; - obj_ncombat.dropping=1-attack; - obj_ncombat.attacking=attack; - obj_ncombat.enemy=attacking; - obj_ncombat.formation_set=formation_possible[formation_current]; - */ - - obj_ncombat.leader = 1; - obj_ncombat.threat = 5; - obj_ncombat.battle_special = "WL10_later"; - scr_battle_allies(); - setup_battle_formations(); - roster.add_to_battle(); - } - } - } - - // TODO - while I don't expect Surface to Orbit weapons retaliating against player's purge bombardment, it might still be worthwhile to consider possible situations - - if (action_type == eDROP_TYPE.PURGEBOMBARD) { - // Bombardment - txt1 = choose("Your cruiser and larger ship", "The heavens rumble and thunder as your ship"); - if (ships_selected > 1) { - txt1 += "s"; - } - txt1 += choose(" position themselves over the target in close orbit, and unleash", " unload"); - if (ships_selected == 1) { - txt1 += "s"; - } - txt1 += $" annihilation upon {planet_numeral_name(planet, star)}. Even from space the explosions can be seen, {choose("tearing ground", "hammering", "battering", "thundering")} across the planet's surface."; - - if (star.p_large[planet] == 0) { - max_kill = action_score * 15000000; - } - if (star.p_large[planet] == 1) { - max_kill = action_score * 0.015; - } // Population if large - - pop_before = star.p_population[planet]; - - heres_before = max(star.p_heresy[planet] + star.p_heresy_secret[planet], star.p_influence[planet][eFACTION.TAU]); // Starting heresy - - // Minimum kills - if (pop_before > 0) { - overkill = max(pop_before * 0.1, ((heres_before / 200) * pop_before)); - } - if (pop_before == 0) { - overkill = 0; - } - - kill = min(max_kill, overkill, pop_before); // How many people ARE going to be killed - - pop_after = pop_before - kill; - sci1 = 0; - sci2 = 0; - - if (pop_before > 0) { - sci1 = (pop_after / pop_before) * 100; - } // Relative % of people murderized - if (sci1 > 0) { - sci2 = min((sci1 * 2), action_score * 2); - } // How much hurresy to get rid of - heres_after = heres_before - sci2; - if ((pop_before > 0) && (pop_after == 0)) { - heres_after = 0; - } - - if (star.p_large[planet] == 0) { - pop_after = round(pop_after); - } - if ((pop_after <= 0) && (pop_before > 0)) { - heres_after = 0; - } - - var _displayed_population = star.p_large[planet] == 1 ? $"{pop_before} billion" : scr_display_number(floor(pop_before)); - var _displayed_killed = star.p_large[planet] == 1 ? $"{kill} billion" : scr_display_number(floor(kill)); - txt1 += $"##The world had {_displayed_population} Imperium subjects. {_displayed_killed} were purged over the duration of the bombardment.##Heresy has fallen down to {max(0, heres_after)}%."; - - if (pop_after <= 0) { - if ((star.p_owner[planet] == 2) && (obj_controller.faction_status[2] != "War")) { - if (star.p_type[planet] == "Temperate" || star.p_type[planet] == "Hive" || star.p_type[planet] == "Desert") { - var _disp_hit = -10; - if (star.p_type[planet] == "Temperate") { - _disp_hit = -5; - } - if (star.p_type[planet] == "Desert") { - _disp_hit = -3; - } - - scr_audience(eFACTION.IMPERIUM, "bombard_angry", _disp_hit, "", 0, 0); - } - } - } - if ((star.p_owner[planet] == 3) && (obj_controller.faction_status[3] != "War")) { - if (star.p_type[planet] == "Forge") { - _disp_hit = -15; - } - if (star.p_type[planet] == "Ice") { - _disp_hit = -7; - } - scr_audience(eFACTION.INQUISITION, "bombard_angry", _disp_hit, "", 0, 0); - } - } - - if (action_type == eDROP_TYPE.PURGEFIRE) { - // Burn baby burn - var i = 0; - if (has_problem_planet(planet, "cleanse", star)) { - isquest = 1; - thequest = "cleanse"; - questnum = i; - } - - if (isquest == 1) { - if ((thequest == "cleanse") && (action_score >= 20)) { - remove_planet_problem(planet, thequest, star); - - if (obj_controller.demanding == 0) { - obj_controller.disposition[4] += 1; - } - if (obj_controller.demanding == 1) { - obj_controller.disposition[4] += choose(0, 0, 1); - } +function scr_purge_world(action_type, action_score) { + + var population_reduction_percentage,influence_reduction, max_kill, heres_before, heres_after, kill; + var isquest=0,thequest="",questnum=0,pop_after=0,txt1="",txt2="",overkill=0; + + + var _pop_before = population; + var _no_chaos = (planet_forces[eFACTION.HERETICS] + planet_forces[eFACTION.CHAOS])==0 + if ((action_type==eDROPTYPE.PURGEFIRE || action_type==eDROPTYPE.PURGESELECTIVE) && _no_chaos && obj_controller.turn>=obj_controller.chaos_turn){ + if (has_feature(P_features.Warlord10) && obj_controller.known[10]=0 && obj_controller.faction_gender[10]=1){ + with(obj_drop_select){ + var pop=instance_create(0,0,obj_popup); + pop.image="chaos_symbol"; + pop.title="Concealed Heresy"; + pop.text=$"Your astartes set out and begin to cleanse {name()} of possible heresy. The general populace appears to be devout in their faith, but a disturbing trend appears- the odd citizen cursing your forces, frothing at the mouth, and screaming out heresy most foul. One week into the cleansing a large hostile force is detected approaching and encircling your forces."; + exit; + } + } + if (has_feature(P_features.Warlord10) && obj_controller.known[10]>=2 && obj_controller.faction_gender[10]=1){ + with(obj_drop_select){ + + attacking=10; + obj_controller.cooldown=30; + combating=1;// Start battle here + + instance_deactivate_all(true); + instance_activate_object(obj_controller); + instance_activate_object(obj_ini); + instance_activate_object(obj_drop_select); + + instance_create(0,0,obj_ncombat); + obj_ncombat.battle_object=p_target; + obj_ncombat.battle_loc=p_target.name; + obj_ncombat.battle_id=obj_controller.selecting_planet; + obj_ncombat.dropping=0; + obj_ncombat.attacking=10; + obj_ncombat.enemy=10; + obj_ncombat.formation_set=1; + + obj_ncombat.leader=1; + obj_ncombat.threat=5; + obj_ncombat.battle_special="WL10_later"; + scr_battle_allies(); + setup_battle_formations(); + roster.add_to_battle(); + } + } + } + + var heres_before = max(total_corruption(),population_influences[eFACTION.TAU],population_influences[eFACTION.TYRANIDS]);// Starting heresy + + var heres_target = "corruption"; + + if (max(population_influences[eFACTION.TAU],population_influences[eFACTION.TYRANIDS]) > total_corruption()){ + if (population_influences[eFACTION.TAU]>population_influences[eFACTION.TYRANIDS]){ + heres_target = "tau"; + } else{ + heres_target = "genestealers"; + } + + } + + + // TODO - while I don't expect Surface to Orbit weapons retaliating against player's purge bombardment, it might still be worthwhile to consider possible situations + + if (action_type=eDROPTYPE.PURGEBOMBARD){// Bombardment + var _ship = string_plural("ship",ships_selected); + txt1=choose($"Your cruiser and larger {_ship}", $"The heavens rumble and thunder as your {_ship}"); + txt1+=choose(" position themselves over the target in close orbit, and unleash", " unload"); + var _adjective = choose("tearing ground", "hammering", "battering", "thundering"); + txt1+= $" annihilation upon {name()}. Even from space the explosions can be seen, {_adjective} across the planet's surface."; + + max_kill = population_small_conversion(0.015) * max_kill; + + // Minimum kills + overkill=max(_pop_before*0.1,((heres_before/200)*_pop_before)); + + + kill=min(max_kill,overkill,_pop_before);// How many people ARE going to be killed + + pop_after=max(_pop_before-kill,0); + population_reduction_percentage=0; + influence_reduction=0; + + population_reduction_percentage=(pop_after/_pop_before)*100;// Relative % of people murderized + + if (population_reduction_percentage>0){ + influence_reduction=min((population_reduction_percentage*2),action_score*2);// How much hurresy to get rid of + } + heres_after=heres_before-influence_reduction; + + + if (!population_large){ + pop_after=round(pop_after); + } + + + var _displayed_population = display_population(); + var _displayed_killed = large_population ? $"{kill} billion" : scr_display_number(floor(kill)); + txt1 += $"\n\nThe world had {_displayed_population} Imperium subjects. {_displayed_killed} were purged over the duration of the bombardment.\n\nHeresy has fallen down to {max(0, heres_after)}%."; + + if (pop_after<=0){ + if (current_owner=2 && obj_controller.faction_status[2]!="War"){ + if (planet_type="Temperate" || planet_type="Hive" || planet_type="Desert"){ + var _disp_hit = -10; + if (planet_type="Temperate"){ + _disp_hit = -5; + } + if (planet_type="Desert"){ + _disp_hit = -3; + } + + scr_audience(eFACTION.IMPERIUM, "bombard_angry", _disp_hit, "", 0, 0); + } + } + } + if (current_owner=3 && obj_controller.faction_status[3]!="War"){ + + if (planet_type="Forge"){ + _disp_hit =-15; + } + if (planet_type="Ice"){ + _disp_hit =-7; + } + scr_audience(eFACTION.INQUISITION, "bombard_angry", _disp_hit, "", 0, 0); + + } + + + } + + + if (action_type=eDROPTYPE.PURGEFIRE){// Burn baby burn + var i=0; + if (has_problem("cleanse")){ + isquest=1; + thequest="cleanse"; + questnum=i; + } + + if (isquest=1){ + if (thequest="cleanse" && action_score>=20){ + remove_planet_problem(planet,thequest,star); + + alter_disposition(eFACTION.INQUISITION,obj_controller.demanding ? choose(0,0,1) :1); + + txt1="Your marines scour the underhive of {name()}, spraying mutants down with promethium as they go. It takes several days but a sizeable dent is put in their numbers."; + scr_event_log("","Inquisition Mission Completed: The mutants of {name()} have been cleansed by promethium."); + add_disposition(choose(1,2,3)); + } + }else if (isquest=0){ // TODO add more variation, with planets, features, marine equipment perhaps? + txt1=choose( + $"Timing their visits right, Your forces scour {name()} burning down whatever the local heretic communities call their homes. Their screams were quickly extinguished by fire, turning whatever it was before, into ash.", + $"Your forces scour {name()}, burning homes and towns that reek of heresy. The screams and wails of the damned carry through the air." + ); + + max_kill = population_large_conversion(12000) *action_score; + + // Minimum kills + overkill=min(_pop_before*0.01,((heres_before/200)*_pop_before)); + + kill=min(max_kill,overkill,_pop_before);// How many people ARE going to be killed + + if (!population_large){ + pop_after=max(_pop_before-kill,0); + } + if (large_population){ + pop_after=_pop_before; + } + + population_reduction_percentage=0; + influence_reduction=0; + if (_pop_before>0) { + population_reduction_percentage=(pop_after/_pop_before)*100;// Relative % of people murderized + } + if (population_reduction_percentage>0){ + influence_reduction=min((population_reduction_percentage*2),round(action_score/25));// How much hurresy to get rid of + } + heres_after=heres_before-influence_reduction; + if (_pop_before>0 && pop_after=0) { + heres_after=0; + } + + var nid_influence = population_influences[eFACTION.TYRANIDS]; + if (has_feature( P_features.Gene_Stealer_Cult)) { + var cult = get_features(P_features.Gene_Stealer_Cult)[0]; + if (cult.hiding) { - txt1 = "Your marines scour the underhive of " + string(star.name) + " " + string(planet) + ", spraying mutants down with promethium as they go. It takes several days but a sizeable dent is put in their numbers."; - scr_event_log("", "Inquisition Mission Completed: The mutants of " + string(star.name) + " " + string(scr_roman(planet)) + " have been cleansed by promethium."); - scr_gov_disp(star.name, planet, choose(1, 2, 3)); - } - } else if (isquest == 0) { - // TODO add more variation, with planets, features, marine equipment perhaps? - txt1 = choose($"Timing their visits right, Your forces scour {star.name} {planet} burning down whatever the local heretic communities call their homes. Their screams were quickly extinguished by fire, turning whatever it was before, into ash.", $"Your forces scour {star.name} {planet}, burning homes and towns that reek of heresy. The screams and wails of the damned carry through the air."); - - if (star.p_large[planet] == 0) { - max_kill = action_score * 12000; - } // Population if normal - if (star.p_large[planet] == 1) { - max_kill = action_score * 0.0000012; - } // Population if large - - pop_before = star.p_population[planet]; - - heres_before = max(star.p_heresy[planet] + star.p_heresy_secret[planet], star.p_influence[planet][eFACTION.TAU]); // Starting heresy - - // Minimum kills - if (pop_before > 0) { - overkill = min(pop_before * 0.01, ((heres_before / 200) * pop_before)); - } - if (pop_before == 0) { - overkill = 0; - } - - kill = min(max_kill, overkill, pop_before); // How many people ARE going to be killed - - if (star.p_large[planet] == 0) { - pop_after = pop_before - kill; - } - if (star.p_large[planet] == 1) { - pop_after = pop_before; - } - - sci1 = 0; - sci2 = 0; - if (pop_before > 0) { - sci1 = (pop_after / pop_before) * 100; - } // Relative % of people murderized - if (sci1 > 0) { - sci2 = min((sci1 * 2), round(action_score / 25)); - } // How much hurresy to get rid of - heres_after = heres_before - sci2; - if ((pop_before > 0) && (pop_after == 0)) { - heres_after = 0; - } - - var nid_influence = star.p_influence[planet][eFACTION.TYRANIDS]; - if (planet_feature_bool(star.p_feature[planet], eP_FEATURES.GENE_STEALER_CULT)) { - var cult = return_planet_features(star.p_feature[planet], eP_FEATURES.GENE_STEALER_CULT)[0]; - if (cult.hiding) {} + } } else { if (nid_influence > 25) { txt1 += " Scores of mutant offspring from a genestealer infestation are burnt, while we have damaged their influence over this world, the mutants appear to lack the organisation of a true cult"; @@ -227,247 +195,124 @@ function scr_purge_world(star, planet, action_type, action_score) { txt1 += " There are signs of a genestealer infestation but the cultists are too unorganized to do any real damage to their influence on this world"; } } - if (star.p_large[planet] == 0) { - pop_after = round(pop_after); - } - if ((pop_after <= 0) && (pop_before > 0)) { - heres_after = 0; - } - if (star.p_large[planet] == 0) { - txt1 += "##The planet had a population of " + string(scr_display_number(floor(pop_before))) + " and " + string(scr_display_number(floor(kill))) + " were purged over the duration of the cleansing.##Heresy has fallen down to " + string(max(0, heres_after)) + "%."; - } - if (star.p_large[planet] == 1) { - txt1 += "##The planet had a population of " + string(pop_before) + " billion and " + string(scr_display_number(action_score * 12000)) + " were purged over the duration of the cleansing.##Heresy has fallen down to " + string(max(0, heres_after)) + "%."; - } - } - } - - if (action_type == eDROP_TYPE.PURGESELECTIVE) { - // Blam! - var i = 0; - if (has_problem_planet(planet, "purge", star)) { - isquest = 1; - thequest = "purge"; - questnum = i; - } - - if (isquest == 1) { - if ((thequest == "purge") && (action_score >= 10)) { - remove_planet_problem(planet, "purge", star); - - if (obj_controller.demanding == 0) { - obj_controller.disposition[4] += 1; - } - if (obj_controller.demanding == 1) { - obj_controller.disposition[4] += choose(0, 0, 1); - } + if (!population_large){ + pop_after=round(pop_after); + } + + if (!population_large){ + txt1+="\n\nThe planet had a population of "+string(scr_display_number(floor(_pop_before)))+" and "+string(scr_display_number(floor(kill)))+" were purged over the duration of the cleansing.\n\nHeresy has fallen down to "+string(max(0,heres_after))+"%."; + }else { + txt1+="\n\nThe planet had a population of "+string(_pop_before)+" billion and "+string(scr_display_number(action_score*12000))+" were purged over the duration of the cleansing.\n\nHeresy has fallen down to "+string(max(0,heres_after))+"%."; + } + } + } + + + if (action_type=eDROPTYPE.PURGESELECTIVE){// Blam! + var i=0; + if (has_problem_planet(planet, "purge", star)){ + isquest=1; + thequest="purge"; + questnum=i; + } + + if (isquest=1){ + if (thequest="purge" && action_score>=10){ + remove_planet_problem(planet, "purge", star); + + alter_disposition(eFACTION.INQUISITION,obj_controller.demanding ? choose(0,0,1) :1); + + txt1="Your marines drop fast and hard, blowing through guards and mercenaries with minimal resistance. Before ten minutes have passed all your targets are executed."; + scr_event_log("","Inquisition Mission Completed: The unruly Nobles of {name()} have been purged."); + add_disposition(choose(1,2,3)); + } + } + else if (isquest=0){ // TODO add more variation, with planets, features, possibly marine equipment + txt1=choose( + $"Your marines move across {star.name} {scr_roman(planet)}, searching for high profile targets. Once found, they are dragged outside from their lairs. Their execution would soon follow.", + $"Your marines move across {star.name} {scr_roman(planet)}, rooting out sources of corruption. Heretics are dragged from their lairs and executed in the streets." + ); + + if (!population_large) { + max_kill=action_score*30;// Population if normal + } + if (large_population) { + max_kill=0;// Population if large + } + + _pop_before=population; + + // Minimum kills + kill=min(action_score*30,_pop_before);// How many people ARE going to be killed + + if (!population_large) { + pop_after=max(_pop_before-kill,0); + } + influence_reduction=round(action_score/50); + heres_after=heres_before-influence_reduction; + if (_pop_before>0 && pop_after=0) { + heres_after=0; + } + + if (!population_large) { + pop_after=round(pop_after); + } + + if (!population_large) { + txt1+=$"\n\nThe planet had a population of "+string(scr_display_number(floor(_pop_before)))+" and "+string(scr_display_number(floor(kill)))+" die over the duration of the search.\n\nHeresy has fallen to "+string(max(0,heres_after))+"%."; + } + if (large_population) { + txt1+=$"\n\nThe planet had a population of {_pop_before} billion and {action_score*30} die over the duration of the search.\n\nHeresy has fallen to "+string(max(0,heres_after))+"%."; + } + } + } + + + + if (action_type=eDROPTYPE.PURGEASSASSINATE){ + assasinate_governor_setup(); + } + + if (action_type!=eDROPTYPE.PURGEASSASSINATE){ + if (isquest=0){// DO EET + txt2=txt1; + if (heres_target == "corruption"){ + alter_corruption(-influence_reduction); + }else if (heres_target == "tau"){ + alter_influence(eFACTION.TAU , -influence_reduction); + }else if (heres_target == "genestealers"){ + alter_influence(eFACTION.TYRANIDS , -influence_reduction); + } + + if (action_type 0) && (pop_after == 0)) { - heres_after = 0; - } - - if (star.p_large[planet] == 0) { - pop_after = round(pop_after); - } - if ((pop_after <= 0) && (pop_before > 0)) { - heres_after = 0; - } - if (star.p_large[planet] == 0) { - txt1 += "##The planet had a population of " + string(scr_display_number(floor(pop_before))) + " and " + string(scr_display_number(floor(kill))) + " die over the duration of the search.##Heresy has fallen to " + string(max(0, heres_after)) + "%."; - } - if (star.p_large[planet] == 1) { - txt1 += "##The planet had a population of " + string(pop_before) + " billion and " + string(action_score * 30) + " die over the duration of the search.##Heresy has fallen to " + string(max(0, heres_after)) + "%."; - } - } - } - - if (action_type == eDROP_TYPE.PURGEASSASSINATE) { - var aroll = roll_dice_chapter(1, 100, "high"); - var chance = 100; - // var siz_penalty=0; - - // Disposition - aroll += floor(star.dispo[planet] / 10); - - // Advantages - if (scr_has_adv("Ambushers")) { - aroll += 10; - } - if (scr_has_adv("Lightning Warriors")) { - aroll += 5; - } - - // Size - unused - // if ((action_score > 5) && (action_score <= 10)) { siz_penalty = 5; } - // if ((action_score > 10) && (action_score <= 20)) { siz_penalty = 20; } - // if ((action_score > 20) && (action_score <= 50)) { siz_penalty = 30; } - // if ((action_score > 50) && (action_score <= 100)) { siz_penalty = 50; } - // if ((action_score > 100) && (action_score <= 200)) { siz_penalty = 75; } - // if (action_score > 200) { siz_penalty = 125; } - - var spec1 = 0, spec2 = 0, txt = ""; // TODO consider making it a battle with Planetary governor's guards - txt = "Your Astartes descend upon the surface of " + string(star.name) + " " + string(scr_roman(planet)) + " and plot the movements and schedule of the governor. "; - txt += "Once the time is right their target is ambushed " + choose("in their home", "in the streets", "while driving", "taking a piss") + " and tranquilized. "; - - if (scr_has_disadv("Never Forgive")) { - spec1 = 1; - } - if (global.chapter_name == "Space Wolves" || obj_ini.progenitor == ePROGENITOR.SPACE_WOLVES) { - spec1 = 3; - } - if (global.chapter_name == "Iron Hands" || obj_ini.progenitor == ePROGENITOR.IRON_HANDS) { - spec1 = 6; - } - if (obj_ini.omophagea == 1) { - spec1 = choose(spec1, 20); - } - - if (spec1 == 1) { - txt += "They are brought to the already-prepared facilities for Fallen, tortured to make " + string(choose("him", "him", "her")) + " appear a heretic, and then incinerated. "; - } - if (spec1 == 3) { - txt += string(choose("He", "He", "She")) + " is tossed to the Fenrisian Wolves and viciously mauled, torn apart, and eaten. The beasts leave nothing but bloody scraps. "; - } - if (spec1 == 6) { - txt += string(choose("He", "He", "She")) + " is stuck in with the other criminals, and scum, to be turned into a servitor. Soon nothing remains that could be likened to the former Governor. "; - } - if (spec1 == 20) { - if (action_score > 1) { - txt += "Things get out of hand, and the Governor is torn limb from limb and consumed. " + string(choose("His", "His", "Her")) + " flesh is torn off and eaten, bone pulverized, and marrow sucked free. "; - } - if (action_score == 1) { - txt += "Your battle brother chops apart the Governor and eats a sizeable portion of " + string(choose("his", "his", "her")) + " flesh, focusing upon the eyes, teeth, and fingers. Once full the rest is disposed of. "; - } - } - - if (spec1 == 0) { - spec2 = choose(1, 2, 3, 4, 5, 5, 5); - if (spec2 == 1) { - txt += "Their still-living body is disintegrated by acid. "; - } - if (spec2 == 2) { - txt += "The Governor is jettisoned into the local star at the first opporunity. "; - } - if (spec2 == 3) { - txt += string(choose("He", "He", "She")) + " is burned as fuel for one of your vessels. "; - } - if (spec2 == 4) { - txt += "A few grenades is all it takes to blow " + string(choose("his", "his", "her")) + " body to smithereens. "; - } - if (spec2 == 5) { - txt += string(choose("He", "He", "She")) + " is executed in a mundane fashion and buried. "; - } - } - - txt += "What is thy will?"; - - var pip = instance_create(0, 0, obj_popup); - pip.title = "Planetary Governor Assassinated"; - pip.text = txt; - pip.planet = planet; - pip.p_data = new PlanetData(planet, star); - var options = [ - { - str1: "Allow the official successor to become Planetary Governor.", - choice_func: allow_governor_successor, - }, - { - str1: "Ensure that a sympathetic successor will be the one to rule.", - choice_func: install_sympathetic_successor, - }, - { - str1: "Remove all successors and install a loyal Chapter Serf.", - choice_func: install_chapter_surf, - } - ]; - pip.add_option(options); - pip.cooldown = 20; - - // Result- this is the multiplier for the chance of discovery with the inquisition, can also be used to determine - // the new Governor disposition if they are the official successor - if (aroll < chance) { - // Discovered - pip.estimate = 2; - } else if (aroll >= chance) { - // Success - pip.estimate = 1; - } - // If there are enemy non-chaos forces then they may be used as a cover - // Does not work with chaos because if the governor dies, with chaos present, the new governor would possibly be investigated - if ((star.p_orks[planet] >= 4) || (star.p_necrons[planet] >= 3) || (star.p_tyranids[planet] >= 5)) { - pip.estimate = pip.estimate * 0.5; - } - } - - if (action_type != eDROP_TYPE.PURGEASSASSINATE) { - if (isquest == 0) { - // DO EET - txt2 = txt1; - star.p_heresy[planet] -= sci2; - star.p_influence[planet][eFACTION.TAU] -= sci2; - if (action_type < eDROP_TYPE.PURGESELECTIVE) { - star.p_population[planet] = pop_after; - } - if ((action_type == eDROP_TYPE.PURGESELECTIVE) && (star.p_large[planet] == 0)) { - star.p_population[planet] = pop_after; - } - if (star.p_heresy[planet] < 0) { - star.p_heresy[planet] = 0; - } - if (star.p_influence[planet][eFACTION.TAU] < 0) { - star.p_influence[planet][eFACTION.TAU] = 0; - } - - var pip = instance_create(0, 0, obj_popup); - pip.title = "Purge Results"; - pip.text = txt2; - } - if (isquest == 1) { - // DO EET - var pip; - pip = instance_create(0, 0, obj_popup); - pip.title = "Inquisition Mission Completed"; - pip.text = txt1; - pip.image = "inquisition"; - // scr_event_log("","Inquisition Mission Completed: The unruly nobles of "+string(star.name)+" "+string(scr_roman(planet))+" have been silenced."); - } - } - - if (instance_exists(obj_drop_select)) { - if (instance_exists(sh_target)) { - sh_target.acted = 5; - } - with (obj_drop_select) { - instance_destroy(); - } - instance_destroy(); - } } + diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 6364d5728..79904a461 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -28,183 +28,196 @@ function scr_random_event(execute_now) { force_inquisition_mission = true; } - if (force_inquisition_mission && random_event_next == eEVENT.NONE) { - chosen_event = eEVENT.INQUISITION_MISSION; - } else { - if (execute_now) { - var random_event_roll = irandom(100); - if ((last_event + 30) <= turn) { - random_event_roll = 1; - } // If 30 turns without random event then do one - if (random_event_roll > 5) { - exit; - } // Frequency of events - if ((turn - 15) < last_event) { - exit; - } // Minimum interval between - } - - if (random_event_next != eEVENT.NONE) { - chosen_event = random_event_next; - } else { - var player_luck; - var luck_roll = roll_dice_chapter(1, 100, "low"); - - if (luck_roll <= 45) { - player_luck = eLUCK.GOOD; - } - if ((luck_roll > 45) && (luck_roll < 55)) { - player_luck = eLUCK.NEUTRAL; - } - if (luck_roll >= 55) { - player_luck = eLUCK.BAD; - } - - var events; - if (player_luck == eLUCK.GOOD) { - events = [ - eEVENT.SPACE_HULK, - eEVENT.PROMOTION, - eEVENT.STRANGE_BUILDING, - eEVENT.SORORITAS, - eEVENT.ROGUE_TRADER, - eEVENT.INQUISITION_MISSION, - eEVENT.INQUISITION_PLANET, - eEVENT.MECHANICUS_MISSION - ]; - } else if (player_luck == eLUCK.NEUTRAL) { - events = [ - eEVENT.STRANGE_BEHAVIOR, - eEVENT.FLEET_DELAY, - eEVENT.HARLEQUINS, - eEVENT.SUCCESSION_WAR, - eEVENT.RANDOM_FUN - ]; - } else if (player_luck == eLUCK.BAD) { - events = [ - eEVENT.WARP_STORMS, - eEVENT.ENEMY_FORCES, - eEVENT.CRUSADE, // Reportly breaks often because of lack of imperial fleets and eats player ships // TODO LOW CRUSADE_EVENT // fix - eEVENT.ENEMY, // Save-scumming event, Should probably base this on something else than tech-scavs - eEVENT.MUTATION, - eEVENT.SHIP_LOST, // Another save-scumming event, mainly due to rarity of player ships - //eEVENT.CHAOS_INVASION, // Spawns Chaos fleets way too close to player owned worlds with no warning and usually lots of big ships, save-scum galore and encourages fleet-based chapters // TODO LOW INVASION_EVENT // Make them spawn way farther with more warning, make them have a different goal or remove this event entirely - eEVENT.NECRON_AWAKEN, // Inquisitor check for this is inverted - eEVENT.FALLEN // Event mission cannot be completed and never expires // TODO LOW FALLEN_EVENT // fix - ]; - } - - var events_count = array_length(events); - var events_total = events_count; - var events_share = array_create(events_count, 1); - - for (var i = 0; i < events_count; i++) { - var curr_event = events[i]; - - //DEBUG-INI (EVENTS DEBUG CODE - 1) - //Comment/delete this when not debugging events - //List of possible events above - /*curr_event = eEVENT.NECRON_AWAKEN + if (force_inquisition_mission && random_event_next == eEVENT.NONE) { + chosen_event = eEVENT.INQUISITION_MISSION; + } + else { + if(execute_now) + { + var random_event_roll = irandom(100); + if ((last_event+30)<=turn){ + random_event_roll=1;// If 30 turns without random event then do one + } + if (random_event_roll>5) then exit;// Frequency of events + if ((turn-15) 1500){ + luck_roll+=20; + } + else if (obj_controller.marines > 1000){ + luck_roll+=10; + } + else if (obj_controller.marines > 500){ + luck_roll+=5; + }else if (obj_controller.marines <500){ + luck_roll-=5; + } + + if (luck_roll<=45) then player_luck=luck.good; + if (luck_roll>45) and (luck_roll<55) then player_luck=luck.neutral; + if (luck_roll>=55) then player_luck=luck.bad; + + + var events; + if(player_luck == luck.good){ + events = + [ + eEVENT.SPACE_HULK, + eEVENT.PROMOTION, + eEVENT.STRANGE_BUILDING, + eEVENT.SORORITAS, + eEVENT.ROGUE_TRADER, + eEVENT.INQUISITION_MISSION, + eEVENT.INQUISITION_PLANET, + eEVENT.MECHANICUS_MISSION + ]; + } + else if(player_luck == luck.neutral){ + events = + [ + eEVENT.STRANGE_BEHAVIOR, + eEVENT.FLEET_DELAY, + eEVENT.HARLEQUINS, + eEVENT.SUCCESSION_WAR, + eEVENT.RANDOM_FUN, + ]; + } + else if(player_luck == luck.bad){ + events = + [ + eEVENT.WARP_STORMS, + eEVENT.ENEMY_FORCES, + eEVENT.CRUSADE, + eEVENT.ENEMY, // Save-scumming event, Should probably base this on something else than tech-scavs + eEVENT.MUTATION, + eEVENT.SHIP_LOST, // Another save-scumming event, mainly due to rarity of player ships + eEVENT.CHAOS_INVASION, + eEVENT.NECRON_AWAKEN, // Inquisitor check for this is inverted + eEVENT.FALLEN, // Event mission cannot be completed and never expires // TODO LOW FALLEN_EVENT // fix + ]; + } + + var events_count = array_length(events); + var events_total = events_count; + var events_share = array_create(events_count, 1); + + for(var i = 0; i < events_count; i++){ + var curr_event = events[i]; + + //DEBUG-INI (EVENTS DEBUG CODE - 1) + //Comment/delete this when not debugging events + //List of possible events above + /*curr_event = eEVENT.NECRON_AWAKEN events_count = 1 events_total = events_count; events_share = array_create(events_count, 1);*/ - //DEBUG-FIN (EVENTS DEBUG CODE - 1) - - switch (curr_event) { - case eEVENT.INQUISITION_PLANET: - if (known[eFACTION.INQUISITION] == 0 || obj_controller.faction_status[eFACTION.INQUISITION] == "War") { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.INQUISITION_MISSION: - if (known[eFACTION.INQUISITION] == 0 || obj_controller.disposition[4] < 0 || obj_controller.faction_status[eFACTION.INQUISITION] == "War") { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.MECHANICUS_MISSION: - if (known[eFACTION.MECHANICUS] == 0 || obj_controller.disposition[3] < 50 || obj_controller.faction_status[eFACTION.MECHANICUS] == "War") { - events_share[i] -= 1; - events_total -= 1; - } else if (scr_has_adv("Tech-Brothers")) { - events_share[i] += 2; - events_total += 2; - } - break; - case eEVENT.ENEMY: - if (scr_has_adv("Scavangers")) { - events_share[i] += 2; - events_total += 2; - } - break; - case eEVENT.MUTATION: - if (gene_seed < 5) { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.NECRON_AWAKEN: - if (known[eFACTION.INQUISITION] == 0) { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.CRUSADE: - if (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.FLEET_DELAY: - var has_moving_fleet = false; - with (obj_p_fleet) { - if (action == "move") { - has_moving_fleet = true; - break; - } - } - if (!has_moving_fleet) { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.SHIP_LOST: - var has_moving_fleet = false; - with (obj_p_fleet) { - if (action == "move") { - has_moving_fleet = true; - break; - } - } - if (!has_moving_fleet) { - events_share[i] -= 1; - events_total -= 1; - } - break; - case eEVENT.FALLEN: - if (!scr_has_disadv("Never Forgive")) { - events_share[i] -= 1; - events_total -= 1; - } - } - } - - chosen_event = irandom(events_total); - for (var i = 0; i < events_count; i++) { - chosen_event -= events_share[i]; - if (chosen_event <= 0) { - chosen_event = events[i]; - break; - } - } - //DEBUG-INI (EVENTS DEBUG CODE - 2) - //Comment/delete this when not debugging events - //If event on the switch above, (EVENTS DEBUG CODE - 1) var should be set to event too. - /*chosen_event = eEVENT.NECRON_AWAKEN*/ - //DEBUG-FIN (EVENTS DEBUG CODE - 2) - } - } + //DEBUG-FIN (EVENTS DEBUG CODE - 1) + + switch (curr_event){ + case eEVENT.INQUISITION_PLANET: + if (known[eFACTION.INQUISITION]==0 || obj_controller.faction_status[eFACTION.INQUISITION]=="War") { + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.INQUISITION_MISSION: + if (known[eFACTION.INQUISITION]==0 || obj_controller.disposition[4] < 0 || obj_controller.faction_status[eFACTION.INQUISITION] == "War") { + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.MECHANICUS_MISSION: + if (known[eFACTION.MECHANICUS] == 0 || obj_controller.disposition[3] < 40 || obj_controller.faction_status[eFACTION.MECHANICUS] == "War") { + events_share[i] -= 1; + events_total -= 1; + } + else if(scr_has_adv("Tech-Brothers")){ + events_share[i] += 2; + events_total += 2; + } + break; + case eEVENT.ENEMY: + + break; + case eEVENT.MUTATION: + if(gene_seed < 5){ + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.NECRON_AWAKEN: + if((known[eFACTION.INQUISITION] == 0)){ + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.CRUSADE: + if (obj_controller.faction_status[eFACTION.IMPERIUM] == "War"){ + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.FLEET_DELAY: + var has_moving_fleet = false; + with(obj_p_fleet){ + if(action=="move") + { + has_moving_fleet = true; + break; + } + } + if(!has_moving_fleet){ + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.SHIP_LOST: + var has_moving_fleet = false; + with(obj_p_fleet){ + if(action=="move") + { + has_moving_fleet = true; + break; + } + } + if(!has_moving_fleet){ + events_share[i] -= 1; + events_total -= 1; + } + break; + case eEVENT.FALLEN: + if(!scr_has_disadv("Never Forgive")) + { + events_share[i] -= 1; + events_total -= 1; + } + } + } + + chosen_event = irandom(events_total); + for(var i = 0; i < events_count; i++){ + chosen_event -= events_share[i]; + if(chosen_event <= 0) + { + chosen_event = events[i]; + break; + } + } + //DEBUG-INI (EVENTS DEBUG CODE - 2) + //Comment/delete this when not debugging events + //If event on the switch above, (EVENTS DEBUG CODE - 1) var should be set to event too. + /*chosen_event = eEVENT.NECRON_AWAKEN*/ + //DEBUG-FIN (EVENTS DEBUG CODE - 2) + } + } if (!execute_now) { random_event_next = chosen_event; @@ -401,98 +414,134 @@ function scr_random_event(execute_now) { exit; } - var fleet = eligible_fleets[irandom(fleet_count - 1)]; - - if (fleet.action == "move") { - var targ, delay; - targ = 0; - delay = 0; - if (instance_exists(fleet)) { - delay = choose(1, 2, 2, 3); - fleet.action_eta += delay; - var text = "Eldar pirates have attacked your fleet destined for "; - var target_star = instance_nearest(fleet.action_x, fleet.action_y, obj_star); // isn't there a better way? - var fleet_destination; - if (instance_exists(target_star)) { - fleet_destination = target_star.name; - text += string(fleet_destination) + ". Damage was minimal but the voyage has been delayed by " + string(delay) + " months."; - } else { - text = "Eldar pirates have attacked your fleet. Damage was minimal but the voyage has been delayed by " + string(delay) + " months."; - } - scr_popup("Fleet Attacked", text, "", ""); - _evented = true; - var star_alert = instance_create(fleet.x + 16, fleet.y - 24, obj_star_event); - star_alert.image_alpha = 1; - star_alert.image_speed = 1; - star_alert.col = "red"; - } - } - } else if (chosen_event == eEVENT.HARLEQUINS) { - LOGGER.info("RE: Harlequins"); - var owner = choose(1, 2, 2, 2, 3); - var star = scr_random_find(owner, true, "", ""); - if (!instance_exists(star) && owner != 2) { - owner = 2; - star = scr_random_find(owner, true, "", ""); - } - if (!instance_exists(star)) { - LOGGER.error("RE: Harlequins, couldn't find star"); - exit; - } - - var planet = irandom_range(1, star.planets); - if (add_new_problem(planet, "harlequins", irandom_range(2, 5), star)) { - var text = "Eldar Harlequins have been seen on planet " + string(star.name) + " " + scr_roman(planet) + ". Their purposes are unknown."; - scr_popup("Harlequin Troupe", text, "harlequin", ""); - var star_alert = instance_create(star.x + 16, star.y - 24, obj_star_event); - star_alert.image_alpha = 1; - star_alert.image_speed = 1; - star_alert.col = "green"; - } - } else if (chosen_event == eEVENT.SUCCESSION_WAR) { - LOGGER.info("RE: Succession War"); - var eligible_stars = []; - with (obj_star) { - for (var planet = 1; planet <= planets; planet++) { - if (p_owner[planet] == eFACTION.IMPERIUM && p_type[planet] != "Dead" && p_type[planet] != "Ice" && p_type[planet] != "Lava") { - array_push(eligible_stars, id); - break; - } - } - } - var star_count = array_length(eligible_stars); - if (star_count == 0) { - LOGGER.error("RE: Succession War, couldn't find a star"); - exit; - } - - var star = eligible_stars[irandom(star_count - 1)]; - var planet; - for (var i = 1; i <= star.planets; i++) { - if (star.p_owner[i] == eFACTION.IMPERIUM && star.p_type[i] != "Dead" && star.p_type[i] != "Ice" && star.p_type[i] != "Lava") { - planet = i; - break; - } - } - - array_push(star.p_feature[planet], new NewPlanetFeature(eP_FEATURES.SUCCESSION_WAR)); - add_new_problem(planet, "succession", irandom(6) + 4, star); - star.dispo[planet] = -5000; - - var text = string(star.name) + scr_roman(planet); - scr_popup("War of Succession", "The planetary governor of " + string(text) + " has died. Several subordinates and other parties each claim to be the true heir and successor- war has erupted across the planet as a result. Heresy thrives in chaos.", "succession", ""); - var star_alert = instance_create(star.x + 16, star.y - 24, obj_star_event); - star_alert.image_alpha = 1; - star_alert.image_speed = 1; - star_alert.col = "red"; - scr_event_log("red", "War of Succession on " + string(text)); - _evented = true; - } else if (chosen_event == eEVENT.RANDOM_FUN) { - // Flavor text/events - LOGGER.info("RE: Random"); - var text; - var situation = irandom(4); - var place = irandom(9); + else if (chosen_event == eEVENT.WARP_STORMS){ + log_message("RE: Warp Storm"); + var own,time,him; + + time=irandom_range(6,24); + if (scr_has_disadv("Shitty Luck")){ + own=choose(1,2,0,0,0); + } else if (scr_has_adv("Great Luck")) { + own=choose(1,1,2,2,0); + } else { + own=choose(1,1,2,0,0); + } + + var star_id = scr_random_find(own,true,"",""); + if(star_id == undefined && own == 1){ + own = 2; + star_id = scr_random_find(own,true,"",""); + } + if(star_id == undefined && own == 2){ + own = 0; + star_id = scr_random_find(own,true,"",""); + } + + if(star_id == undefined){ + log_error("RE: Warp Storm, couldn't pick a star for the warp storm"); + exit; + } + else{ + star_id.storm += time; + _evented = true; + var _col = own == 1 ? "red" : "green"; + scr_alert(_col, "Warp", $"Warp Storms rage across the {star_id.name} system.", star_id.x, star_id.y); + scr_event_log(_col, $"Warp Storms rage across the {star_id.name} system."); + } + } + + else if (chosen_event == eEVENT.ENEMY_FORCES){ + log_message("RE: Enemy Forces"); + var own; + if (scr_has_disadv("Shitty Luck")){ + own=choose(1,1,1,1,1,1,2,2,3); + } else if (scr_has_adv("Great Luck")) { + own=choose(1,1,1,2,2,2,2,3,3); + } else { + own=choose(1,1,1,2,2,3); + } + + var star_id = scr_random_find(own,true,"",""); + if(star_id == undefined && own == 1){ + own = 2; + star_id = scr_random_find(own,true,"",""); + } + if(star_id == undefined && own == 2){ + own = 3; + star_id = scr_random_find(own,true,"",""); + } + + if(star_id == undefined) + { + log_error("RE: Enemy Forces, couldn't find a star for the enemy"); + exit; + } + else{ + var eligible_planets = []; + for(var i = 1; i <= star_id.planets; i++){ + if(star_id.p_type[i] != "Dead") + { + array_push(eligible_planets,i); + } + } + if(array_length(eligible_planets) == 0){ + log_error("RE: Enemy Forces, couldn't find a planet in the " + star_id.name +" system for the enemy"); + exit; + } + var planet = array_random_element(eligible_planets); + //var enemy = choose(7,8,9,10,13); + var enemy = choose(7,8,9); + var text; + var max_enemies_on_planet = 6; // I don't know the actual value, i need to change it; + switch(enemy) + { + case 7: + text = "Orks"; + star_id.p_orks[planet] += 4; + star_id.p_orks[planet] = min(star_id.p_orks[planet], max_enemies_on_planet); + break; + case 8: + text = "Tau"; + star_id.p_tau[planet] += 4; + star_id.p_tau[planet] = min(star_id.p_tau[planet], max_enemies_on_planet); + break; + case 9: + text = "Tyranids"; + star_id.p_tyranids[planet] += 5; + star_id.p_tyranids[planet] = min(star_id.p_tyranids[planet], max_enemies_on_planet); + break; + case 10: + text = "Heretics"; + star_id.p_heretics[planet] = 4; + star_id.p_heretics[planet] = min(star_id.p_heretics[planet], max_enemies_on_planet); + break; + case 13: + text = "Necron"; // I don't know if its a good idea to spawn necrons from this event, leaving it in for now + star_id.p_necron[planet] = 4; + star_id.p_necron[planet] = min(star_id.p_necron[planet], max_enemies_on_planet); + break; + default: + log_error("RE: Enemy Forces, couldn't pick an enemy faction"); + exit; + } + scr_alert("red","enemy", $"A Space Hulk carrying {text} breaches Space and has crashed Into {star_id.name} {planet}!",star_id.x,star_id.y); + scr_event_log("red",$"A Space Hulk carrying {text} Space Hulk Crashes Into System {star_id.name} {planet}!"); + _evented = true; + } + } + + else if ((chosen_event == eEVENT.CRUSADE)){ + //i think all events should be hanlded like this then we have far more options on when to call them and how they work + _evented = launch_crusade(); + } + + else if (chosen_event == eEVENT.ENEMY) { + _evented = make_faction_enemy_event(); + } + + else if ((chosen_event == eEVENT.MUTATION)) { + init_mutated_gene_random_event(); + } switch (situation) { case 0: @@ -762,23 +811,23 @@ function event_fallen() { var planet = scr_get_planet_with_owner(star, eFACTION.IMPERIUM); var eta = scr_mission_eta(star.x, star.y, 1); - if (planet > 0) { - LOGGER.info($"Fallen: found star {star.name} planet {planet} as candidate"); - - var assigned_problem = add_new_problem(planet, "fallen", eta, star); - LOGGER.info($"assigned_problem {assigned_problem}"); - - if (!assigned_problem) { - LOGGER.error("RE: Hunt the Fallen, coulnd't assign a problem to the planet"); - return; - } - - var text = "Sources indicate one of the Fallen may be upon " + string(star.name) + " " + string(scr_roman(planet)) + ". We have " + string(eta) + " months to send out a strike team and scour the planet. Any longer and any Fallen that might be there will have escaped."; - scr_popup("Hunt the Fallen", text, "fallen", ""); - scr_event_log("", "Sources indicate one of the Fallen may be upon " + string(star.name) + " " + string(scr_roman(planet)) + ". We have " + string(eta) + " months to investigate."); - var star_alert = instance_create(star.x + 16, star.y - 24, obj_star_event); - star_alert.image_alpha = 1; - star_alert.image_speed = 1; - star_alert.col = "purple"; - } + if (planet>0){ + var assigned_problem = add_new_problem(planet, "fallen", eta, star); + LOGGER.info($"assigned_problem {assigned_problem}"); + if (!assigned_problem) { + log_error("RE: Hunt the Fallen, coulnd't assign a problem to the planet"); + return; + } + + var _planet = system_datas[planet]; + _planet.refresh_data(); + + var text = $"Sources indicate one of the Fallen may be upon {_planet.name()} . We have {eta} months to send out a strike team and scour the planet. Any longer and any Fallen that might be there will have escaped."; + scr_popup("Hunt the Fallen",text,"fallen",""); + scr_event_log("",$"Sources indicate one of the Fallen may be upon {_planet.name()}. We have {eta} months to investigate."); + var star_alert = instance_create(star.x+16,star.y-24,obj_star_event); + star_alert.image_alpha=1; + star_alert.image_speed=1; + star_alert.col="purple"; + } } diff --git a/scripts/scr_roman_numerals/scr_roman_numerals.gml b/scripts/scr_roman_numerals/scr_roman_numerals.gml index 42f3dadfc..b600317e5 100644 --- a/scripts/scr_roman_numerals/scr_roman_numerals.gml +++ b/scripts/scr_roman_numerals/scr_roman_numerals.gml @@ -19,26 +19,10 @@ function int_to_roman(_num) { if (_num < 1 || _num > 100) { return ""; } - - var _roman_numerals = [ - 100, - "C", - 90, - "XC", - 50, - "L", - 40, - "XL", - 10, - "X", - 9, - "IX", - 5, - "V", - 4, - "IV", - 1, - "I" + + static _roman_numerals = [ + 100, "C", 90, "XC", 50, "L", 40, "XL", + 10, "X", 9, "IX", 5, "V", 4, "IV", 1, "I" ]; var _result = ""; @@ -55,3 +39,8 @@ function int_to_roman(_num) { return _result; } + + +function irandom_numeral(max_val){ + return int_to_roman(irandom_range(1, max_val)); +} \ No newline at end of file diff --git a/scripts/scr_save_controller/scr_save_controller.gml b/scripts/scr_save_controller/scr_save_controller.gml new file mode 100644 index 000000000..d843523f4 --- /dev/null +++ b/scripts/scr_save_controller/scr_save_controller.gml @@ -0,0 +1,275 @@ +// Script assets have changed for v2.3.0 see +// https://help.yoyogames.com/hc/en-us/articles/360005277377 for more information +function scr_save_controller(save_id){ + log_message($"Saving to slot {save_id} - Part 1"); + ini_open($"save{save_id}.ini"); + + + // Global variables + ini_write_string("Save","chapter_name",global.chapter_name); + ini_write_string("Save","sector_name",obj_ini.sector_name); + ini_write_string("Save","version",global.game_version); + ini_write_real("Save","play_time",play_time); + ini_write_real("Save","game_seed",global.game_seed); + + // obj_controller variables here + ini_write_real("boolean", "cheat_req", global.cheat_req); + ini_write_real("boolean", "cheat_gene", global.cheat_gene); + ini_write_real("boolean", "cheat_debug", global.cheat_debug); + ini_write_real("boolean", "cheat_disp", global.cheat_disp); + ini_write_real("Controller","cheatyface",obj_controller.cheatyface); + ini_write_real("Controller","x",obj_controller.x); + ini_write_real("Controller","y",obj_controller.y); + ini_write_real("Controller","alll",obj_controller.alll); + ini_write_real("Controller","zoomed",obj_controller.zoomed); + ini_write_real("Controller","chaos_rating",obj_controller.chaos_rating); + ini_write_string("Controller","fleet_type",obj_controller.fleet_type); + ini_write_real("Controller","ifleet_type",obj_ini.fleet_type); + ini_write_real("Controller","home_rule",obj_controller.homeworld_rule); + ini_write_string("Controller","star_names",obj_controller.star_names); + ini_write_real("Controller","craworld",obj_controller.craftworld); + ini_write_real("Controller","turn",obj_controller.turn); + ini_write_real("Controller","last_event",obj_controller.last_event); + ini_write_real("Controller","last_mission",obj_controller.last_mission); + ini_write_real("Controller","last_world_inspection",obj_controller.last_world_inspection); + ini_write_real("Controller","last_fleet_inspection",obj_controller.last_fleet_inspection); + ini_write_real("Controller","chaos_turn",obj_controller.chaos_turn); + ini_write_real("Controller","chaos_fleets",obj_controller.chaos_fleets); + ini_write_real("Controller","tau_fleets",obj_controller.tau_fleets); + ini_write_real("Controller","tau_stars",obj_controller.tau_stars); + ini_write_real("Controller","tau_messenger",obj_controller.tau_messenger); + ini_write_real("Controller","fleet_all",obj_controller.fleet_all); + // ini_write_real("Controller","tolerant",obj_ini.tolerant); + ini_write_real("Controller","stability",obj_ini.stability); + ini_write_real("Controller","purity",obj_ini.purity); + ini_write_real("Controller","unload",obj_controller.unload); + ini_write_real("Controller","diplomacy",obj_controller.diplomacy); + ini_write_real("Controller","trading",obj_controller.trading); + ini_write_real("Controller","audience",obj_controller.audience); + ini_write_real("Controller","force_goodbye",obj_controller.force_goodbye); + ini_write_real("Controller","combat",obj_controller.combat); + ini_write_real("Controller","new_vehicles",obj_controller.new_vehicles); + ini_write_real("Controller","hurssy",obj_controller.hurssy); + ini_write_real("Controller","hurssy_time",obj_controller.hurssy_time); + ini_write_real("Controller","artifacts",obj_controller.artifacts); + ini_write_real("Controller","pmc",obj_controller.popup_master_crafted); + ini_write_real("Controller","wndsel",obj_controller.select_wounded); + ini_write_real("Controller","imdis",obj_ini.imperium_disposition); + ini_write_real("Controller","terra_dir",obj_controller.terra_direction); + + ini_write_real("Controller","stc_wargear",obj_controller.stc_wargear); + ini_write_real("Controller","stc_vehicles",obj_controller.stc_vehicles); + ini_write_real("Controller","stc_ships",obj_controller.stc_ships); + ini_write_real("Controller","stc_un_total",obj_controller.stc_un_total); + ini_write_real("Controller","stc_wargear_un",obj_controller.stc_wargear_un); + ini_write_real("Controller","stc_vehicles_un",obj_controller.stc_vehicles_un); + ini_write_real("Controller","stc_ships_un",obj_controller.stc_ships_un); + + ini_encode_and_json("Controller","stc_bonus", obj_controller.stc_bonus) + + ini_encode_and_json("Controller","adv", obj_ini.adv); + ini_encode_and_json("Controller","dis", obj_ini.dis); + + // Player scheduled event + if (obj_controller.fest_type!=""){ + ini_write_real("Controller","f_si",obj_controller.fest_sid); + ini_write_real("Controller","f_wi",obj_controller.fest_wid); + ini_write_real("Controller","f_pl",obj_controller.fest_planet); + ini_write_string("Controller","f_st",obj_controller.fest_star); + ini_write_string("Controller","f_t",obj_controller.fest_type); + ini_write_real("Controller","f_co",obj_controller.fest_cost); + ini_write_real("Controller","f_wa",obj_controller.fest_warp); + ini_write_real("Controller","f_sch",obj_controller.fest_scheduled); + ini_write_real("Controller","f_la",obj_controller.fest_lav); + ini_write_real("Controller","f_lo",obj_controller.fest_locals); + ini_write_real("Controller","f_f1",obj_controller.fest_feature1); + ini_write_real("Controller","f_f2",obj_controller.fest_feature2); + ini_write_real("Controller","f_f3",obj_controller.fest_feature3); + ini_write_real("Controller","f_di",obj_controller.fest_display); + ini_write_string("Controller","f_dit",obj_controller.fest_display_tags); + ini_write_real("Controller","f_re",obj_controller.fest_repeats); + ini_write_real("Controller","f_hc",obj_controller.fest_honor_co); + ini_write_real("Controller","f_hi",obj_controller.fest_honor_id); + ini_write_real("Controller","f_hon",obj_controller.fest_honoring); + } + + ini_write_real("Controller","f_fee",obj_controller.fest_feasts); + ini_write_real("Controller","f_boo",obj_controller.fest_boozes); + ini_write_real("Controller","f_dru",obj_controller.fest_drugses); + ini_write_real("Controller","rech",obj_controller.recent_happenings); + + ini_encode_and_json("Controller","rect",obj_controller.recent_type); + ini_encode_and_json("Controller","reck",obj_controller.recent_keyword); + ini_encode_and_json("Controller","recu",obj_controller.recent_turn); + ini_encode_and_json("Controller","recn",obj_controller.recent_number); + + ini_write_real("Formation","last_attack",obj_controller.last_attack_form); + ini_write_real("Formation","last_raid",obj_controller.last_raid_form); + j=0; + + ini_encode_and_json("Formation", "form",obj_controller.bat_formation); + ini_encode_and_json("Formation", "form_type",obj_controller.bat_formation_type); + ini_encode_and_json("Formation", "deva",obj_controller.bat_deva_for); + ini_encode_and_json("Formation", "assa",obj_controller.bat_assa_for); + ini_encode_and_json("Formation", "tact",obj_controller.bat_tact_for); + ini_encode_and_json("Formation", "vete",obj_controller.bat_vete_for); + ini_encode_and_json("Formation", "hire",obj_controller.bat_hire_for); + ini_encode_and_json("Formation", "libr",obj_controller.bat_libr_for); + ini_encode_and_json("Formation", "comm",obj_controller.bat_comm_for); + ini_encode_and_json("Formation", "tech",obj_controller.bat_tech_for); + ini_encode_and_json("Formation", "term",obj_controller.bat_term_for); + ini_encode_and_json("Formation", "hono",obj_controller.bat_hono_for); + ini_encode_and_json("Formation", "drea",obj_controller.bat_drea_for); + ini_encode_and_json("Formation", "rhin",obj_controller.bat_rhin_for); + ini_encode_and_json("Formation", "pred",obj_controller.bat_pred_for); + ini_encode_and_json("Formation", "landraid",obj_controller.bat_landraid_for); + ini_encode_and_json("Formation", "landspee",obj_controller.bat_landspee_for); + ini_encode_and_json("Formation", "whirl",obj_controller.bat_whirl_for); + ini_encode_and_json("Formation", "scou",obj_controller.bat_scou_for); + + + ini_write_string("Controller","random_event_next",obj_controller.random_event_next); + + ini_write_string("Controller","useful_info",obj_controller.useful_info); + ini_write_real("Controller","random_event_next",obj_controller.random_event_next); + ini_write_real("Controller","gene_sold",obj_controller.gene_sold); + ini_write_real("Controller","gene_xeno",obj_controller.gene_xeno); + ini_write_real("Controller","gene_tithe",obj_controller.gene_tithe); + ini_write_real("Controller","gene_iou",obj_controller.gene_iou); + + ini_write_real("Controller","und_armouries",obj_controller.und_armouries); + ini_write_real("Controller","und_gene_vaults",obj_controller.und_gene_vaults); + ini_write_real("Controller","und_lairs",obj_controller.und_lairs); + + // + ini_write_real("Controller","penitent",obj_controller.penitent); + ini_write_real("Controller","penitent_current",obj_controller.penitent_current); + ini_write_real("Controller","penitent_max",obj_controller.penitent_max); + ini_write_real("Controller","penitent_turnly",obj_controller.penitent_turnly); + ini_write_real("Controller","penitent_turn",obj_controller.penitent_turn); + ini_write_real("Controller","penitent_end",obj_controller.penitent_end); + ini_write_real("Controller","penitent_blood",obj_controller.blood_debt); + // + ini_write_real("Controller","tagged_training",obj_controller.tagged_training); + ini_write_real("Controller","training_apothecary",obj_controller.training_apothecary); + ini_write_real("Controller","apothecary_recruit_points",obj_controller.apothecary_recruit_points); + ini_write_real("Controller","apothecary_aspirant",obj_controller.apothecary_aspirant); + ini_write_real("Controller","training_chaplain",obj_controller.training_chaplain); + ini_write_real("Controller","chaplain_points",obj_controller.chaplain_points); + ini_write_real("Controller","chaplain_aspirant",obj_controller.chaplain_aspirant); + ini_write_real("Controller","training_psyker",obj_controller.training_psyker); + ini_write_real("Controller","psyker_points",obj_controller.psyker_points); + ini_write_real("Controller","psyker_aspirant",obj_controller.psyker_aspirant); + ini_write_real("Controller","training_techmarine",obj_controller.training_techmarine); + ini_encode_and_json("Controller", "spec_train",obj_controller.spec_train_data); + + ini_write_real("Controller","tech_points",obj_controller.tech_points); + ini_write_real("Controller","tech_aspirant",obj_controller.tech_aspirant); + + ini_write_real("Controller","penitorium",obj_controller.penitorium); + + ini_write_string("Controller","recruiting_worlds",obj_controller.recruiting_worlds); + ini_write_real("Controller","recruiting",obj_controller.recruiting); + ini_write_real("Controller","trial",obj_controller.recruit_trial); + ini_write_real("Controller","recruits",obj_controller.recruits); + ini_write_real("Controller","recruit_last",obj_controller.recruit_last); + // + var g=-1; + repeat(30){g+=1; + ini_write_real("Controller","command"+string(g),obj_controller.command_set[g]); + } + ini_write_real("Controller","modest_livery",obj_controller.modest_livery); + ini_write_real("Controller","progenitor_visuals",obj_controller.progenitor_visuals); + + ini_encode_and_json("Recruit", "data",{ + names :obj_controller.recruit_name, + corruption :obj_controller.recruit_corruption, + distance :obj_controller.recruit_distance, + experience :obj_controller.recruit_exp, + training :obj_controller.recruit_training, + data : obj_controller.recruit_data + + }); + ini_encode_and_json("Controller","lyl",obj_controller.loyal); + ini_encode_and_json("Controller","lyl_nm",obj_controller.loyal_num); + ini_encode_and_json("Controller","lyl_tm",obj_controller.loyal_time); + + + ini_encode_and_json("Controller","inq",obj_controller.inquisitor); + ini_encode_and_json("Controller","inq_ge",obj_controller.inquisitor_gender); + ini_encode_and_json("Controller","inq_ty",obj_controller.inquisitor_type); + + // + g=-1; + repeat(14){g+=1; + ini_write_string("Factions","fac"+string(g),obj_controller.faction[g]); + ini_write_real("Factions","dis"+string(g),obj_controller.disposition[g]); + ini_write_real("Factions","dis_max"+string(g),obj_controller.disposition_max[g]); + + ini_write_string("Factions","lead"+string(g),obj_controller.faction_leader[g]); + ini_write_real("Factions","gen"+string(g),obj_controller.faction_gender[g]); + ini_write_string("Factions","title"+string(g),obj_controller.faction_title[g]); + ini_write_string("Factions","status"+string(g),obj_controller.faction_status[g]); + ini_write_real("Factions","defeated"+string(g),obj_controller.faction_defeated[g]); + ini_write_real("Factions","known"+string(g),known[g]); + + ini_write_real("Factions","annoyed"+string(g),obj_controller.annoyed[g]); + ini_write_real("Factions","ignore"+string(g),obj_controller.ignore[g]); + ini_write_real("Factions","turns_ignored"+string(g),obj_controller.turns_ignored[g]); + } + // + var g;g=0; + // + ini_write_real("Controller","justmet",obj_controller.faction_justmet); + ini_write_real("Controller","check_number",obj_controller.check_number); + ini_write_real("Controller","year_fraction",obj_controller.year_fraction); + ini_write_real("Controller","year",obj_controller.year); + ini_write_real("Controller","millenium",obj_controller.millenium); + // + ini_write_real("Controller","req",obj_controller.requisition); + ini_write_string("Controller","tech_status",obj_controller.tech_status); + // + ini_write_real("Controller","income",obj_controller.income); + ini_write_real("Controller","income_last",obj_controller.income_last); + ini_write_real("Controller","income_base",obj_controller.income_base); + ini_write_real("Controller","income_home",obj_controller.income_home); + ini_write_real("Controller","income_forge",obj_controller.income_forge); + ini_write_real("Controller","income_agri",obj_controller.income_agri); + ini_write_real("Controller","income_training",obj_controller.income_training); + ini_write_real("Controller","income_fleet",obj_controller.income_fleet); + ini_write_real("Controller","income_trade",obj_controller.income_trade); + ini_write_real("Controller","loyalty",obj_controller.loyalty); + ini_write_real("Controller","loyalty_hidden",obj_controller.loyalty_hidden); + ini_write_real("Controller","flag_lair",obj_controller.inqis_flag_lair); + ini_write_real("Controller","flag_gene",obj_controller.inqis_flag_gene); + + + ini_write_real("Controller","gene_seed",obj_controller.gene_seed); + ini_write_real("Controller","marines",obj_controller.marines); + ini_write_real("Controller","command",obj_controller.command); + ini_write_real("Controller","info_chips",obj_controller.info_chips); + ini_write_real("Controller","inspection_passes",obj_controller.inspection_passes); + ini_write_real("Controller","recruiting_worlds_bought",obj_controller.recruiting_worlds_bought); + ini_write_real("Controller","lwt",obj_controller.last_weapons_tab); + + ini_write_real("Controller","bat_devastator_column",obj_controller.bat_devastator_column); + ini_write_real("Controller","bat_assault_column",obj_controller.bat_assault_column); + ini_write_real("Controller","bat_tactical_column",obj_controller.bat_tactical_column); + ini_write_real("Controller","bat_veteran_column",obj_controller.bat_veteran_column); + ini_write_real("Controller","bat_hire_column",obj_controller.bat_hire_column); + ini_write_real("Controller","bat_librarian_column",obj_controller.bat_librarian_column); + ini_write_real("Controller","bat_command_column",obj_controller.bat_command_column); + ini_write_real("Controller","bat_techmarine_column",obj_controller.bat_techmarine_column); + ini_write_real("Controller","bat_terminator_column",obj_controller.bat_terminator_column); + ini_write_real("Controller","bat_honor_column",obj_controller.bat_honor_column); + ini_write_real("Controller","bat_dreadnought_column",obj_controller.bat_dreadnought_column); + ini_write_real("Controller","bat_rhino_column",obj_controller.bat_rhino_column); + ini_write_real("Controller","bat_predator_column",obj_controller.bat_predator_column); + ini_write_real("Controller","bat_landraider_column",obj_controller.bat_landraider_column); + ini_write_real("Controller","bat_scout_column",obj_controller.bat_scout_column); + + ini_close(); +} + + + diff --git a/scripts/scr_specialist_training/scr_specialist_training.gml b/scripts/scr_specialist_training/scr_specialist_training.gml index ebde775d1..df2d84b9c 100644 --- a/scripts/scr_specialist_training/scr_specialist_training.gml +++ b/scripts/scr_specialist_training/scr_specialist_training.gml @@ -1,14 +1,15 @@ /// @mixin function specialistfunct(specialist, req_exp) { + var _roles = active_roles(); var spec_tips = [ - string("{0} Potential", obj_ini.role[100][16]), - string("{0} Potential", obj_ini.role[100][15]), - string("{0} Potential", obj_ini.role[100][14]), - string("{0} Potential", obj_ini.role[100][17]), - string("{0} Applicant", obj_ini.role[100][16]), - string("{0} Applicant", obj_ini.role[100][15]), - string("{0} Applicant", obj_ini.role[100][14]), - string("{0} Applicant", obj_ini.role[100][17]), + string("{0} Potential", _roles[16]), + string("{0} Potential", _roles[15]), + string("{0} Potential", _roles[14]), + string("{0} Potential", _roles[17]), + string("{0} Applicant", _roles[16]), + string("{0} Applicant", _roles[15]), + string("{0} Applicant", _roles[14]), + string("{0} Applicant", _roles[17]), string("Promote to Marine") ]; @@ -66,7 +67,7 @@ function specialistfunct(specialist, req_exp) { break; } - if (role() == obj_ini.role[100][12]) { + if (role() == _roles[12]) { colors[0] = c_fuchsia; } @@ -75,7 +76,7 @@ function specialistfunct(specialist, req_exp) { } if (experience >= req_exp) { - if (!(role() == obj_ini.role[100][12])) { + if (!(role() == _roles[12])) { spec_tip = tips_list[1]; } else { spec_tip = tips_list[2]; @@ -93,7 +94,8 @@ function specialistfunct(specialist, req_exp) { // specialist - Integer index (0: Techmarine, 1: Librarian, 2: Chaplain, 3: Apothecary) // Returns: Array containing company and position of selected marine, or "none" if no suitable marine found function spec_data_set(specialist) { - var _data = obj_controller.spec_train_data[specialist]; + var _roles = active_roles(); + var _data = spec_train_data[specialist]; var _search = { "stat": _data.req, "job": "none", @@ -103,9 +105,13 @@ function spec_data_set(specialist) { _search.role_tag = _data.name; } - var random_marine = scr_random_marine( - // TODO LOW SEARCH_OPTIONAL // Make this function handle optional search_params - [obj_ini.role[100][8], obj_ini.role[100][18], obj_ini.role[100][10], obj_ini.role[100][9]], + var random_marine=scr_random_marine( // TODO LOW SEARCH_OPTIONAL // Make this function handle optional search_params + [ + _roles[8], + _roles[18], + _roles[10], + _roles[9] + ], _data.min_exp, _search ); diff --git a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml index 07cc43d4a..70ecce725 100644 --- a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml +++ b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml @@ -103,13 +103,20 @@ function scr_is_star_owned_by_allies(star) { return array_contains(global.SystemHelps.default_allies, star.owner); } -function scr_get_planet_with_type(star, type) { - for (var i = 1; i <= star.planets; i++) { - if (star.p_type[i] == type) { - return i; - } - } - return -1; +function scr_get_planet_with_type(star, type){ + var _is_array = is_array(type); + for (var i = 1; i <= star.planets; i++){ + if (!_is_array){ + if(star.p_type[i] == type){ + return i; + } + } else{ + if (array_contains(type,star.p_type[i])){ + return i; + } + } + } + return -1; } function stars_with_faction_fleets(search_faction) { @@ -167,38 +174,39 @@ function scr_star_has_planet_with_owner(star, owner) { } /// @returns {Array} stars -function scr_get_stars(shuffled = false, ownership = [], types = []) { - var stars = []; - var _owner_sort = array_length(ownership); - var _types_sort = array_length(types); - with (obj_star) { - if (!_owner_sort && !_types_sort) { - var _add = true; - } else { - var _add = true; - if (_owner_sort && !array_contains(ownership, owner)) { - _add = false; - } - if (_add && _types_sort) { - for (var i = 1; i <= planets; i++) { - types = array_delete_value(types, p_type[i]); - if (!array_length(types)) { - break; - } - } - if (array_length(types)) { - _add = false; - } - } - } - if (_add) { - array_push(stars, id); - } - } - if (shuffled) { - stars = array_shuffle(stars); - } - return stars; +function scr_get_stars(shuffled=false, ownership=[], types = []) { + var stars = []; + var _owner_sort = array_length(ownership); + var _types_sort = array_length(types); + with(obj_star){ + if (!_owner_sort && !_types_sort){ + var _add = true; + } else { + var _add = true; + if (_owner_sort && !array_contains(ownership,owner)){ + _add = false; + } + if (_add && _types_sort){ + _add = false; + for (var i=1;i<=planets;i++){ + if (array_contains(types,p_type[i])){ + _add = true; + break; + } + } + if (array_length(types)){ + _add = false; + } + } + } + if (_add){ + array_push(stars,id); + } + } + if (shuffled){ + stars = array_shuffle(stars); + } + return stars; } function planet_imperium_ground_total(planet_check) { @@ -268,36 +276,36 @@ function shuffled_planet_array() { /// @returns {Instance} /// Returns the `obj_star` instance found after skipping the specified number of nearby stars, /// ignoring any that are disqualified by the exclusion conditions. -function distance_removed_star(origional_x, origional_y, star_offset = choose(2, 3), disclude_hulk = true, disclude_elder = true, disclude_deads = true, warp_concious = true) { - var from = instance_nearest(origional_x, origional_y, obj_star); - var _deactivated = []; - for (var i = 0; i < star_offset; i++) { - from = instance_nearest(origional_x, origional_y, obj_star); - with (from) { - array_push(_deactivated, id); - instance_deactivate_object(id); - } - from = instance_nearest(origional_x, origional_y, obj_star); - if (instance_exists(from)) { - if (disclude_elder && from.owner == eFACTION.ELDAR) { - i--; - array_push(_deactivated, id); - instance_deactivate_object(from); - continue; - } - if (disclude_deads) { - if (is_dead_star(from)) { - i--; - array_push(_deactivated, id); - instance_deactivate_object(from); - continue; - } - } - } +function distance_removed_star(origional_x,origional_y, star_offset = choose(2,3), disclude_hulk=true, disclude_elder=true, disclude_deads=true, warp_concious=true){ + var from = instance_nearest(origional_x,origional_y,obj_star); + var deactivated = []; + for(var i=0; i -1) { - obj_ini.ship_carrying[unit.ship_location] += unit.get_unit_size(); - } - } - }; - - static evaluate_vehicle_for_garrison_log = function(company, array_slot) { - var co = company; - var u = array_slot; - - if (obj_ini.veh_race[co][u] == 0) { - return; - } - if (obj_ini.veh_wid[co][u] > 0) { - unit_location = obj_ini.veh_loc[co][u]; - var _unit = [ - co, - u - ]; - if (!struct_exists(garrison_log, unit_location)) { - garrison_log[$ unit_location] = { - units: [_unit], - vehicles: 1, - garrison: false, - healers: 0, - techies: 0, - }; - } else { - array_push(garrison_log[$ unit_location].units, _unit); - garrison_log[$ unit_location].vehicles++; - } - } else if (obj_ini.veh_lid[co][u] > -1) { - obj_ini.ship_carrying[obj_ini.veh_lid[co][u]] += scr_unit_size("", obj_ini.veh_role[co][u], true); - } - }; - - static update_garrison_log = function() { - try { - for (var i = 0; i < array_length(obj_ini.ship_carrying); i++) { - obj_ini.ship_carrying[i] = 0; - } - var _unit; - delete garrison_log; - garrison_log = {}; - obj_controller.specialist_point_handler.calculate_research_points(false); - ship_count = array_length(obj_ini.ship_carrying); - for (var co = 0; co <= obj_ini.companies; co++) { - for (var u = 0; u < array_length(obj_ini.TTRPG[co]); u++) { - /// @type {Struct.TTRPG_stats} - _unit = fetch_unit([co, u]); - evaluate_unit_for_garrison_log(_unit); - } - try { - for (var u = 0; u < array_length(obj_ini.veh_race[co]); u++) { - evaluate_vehicle_for_garrison_log(co, u); - } - } catch (_exception) { - handle_exception(_exception); - } - } - update_mission_log(); - } catch (_exception) { - handle_exception(_exception); - } - }; - - update_mission_log = function() { - mission_log = []; - var temp_log = []; - var p, i, problems; - with (obj_star) { - for (i = 1; i <= planets; i++) { - problems = p_problem[i]; - for (p = 0; p < array_length(problems); p++) { - if (problems[p] != "") { - if (problem_has_key_and_value(i, p, "stage", "preliminary")) { - continue; - } - var mission_explain = mission_name_key(problems[p]); - if (mission_explain != "none") { - array_push(temp_log, {system: name, mission: mission_explain, time: p_timer[i][p], planet: i}); - } - } - } - } - } - for (i = 0; i < array_length(obj_controller.quest); i++) { - if (obj_controller.quest[i] != "") { - var mission_explain = mission_name_key(obj_controller.quest[i]); - if (mission_explain != "none") { - array_push(temp_log, {system: "", mission: mission_explain, time: obj_controller.quest_end[i] - obj_controller.turn, planet: 0}); - } - } - } - mission_log = temp_log; - }; - hover_item = "none"; - travel_target = []; - travel_time = 0; - travel_increments = []; - is_entered = false; - start_fleet = 0; - start_system = 0; - garrison_log = {}; - mission_log = []; - hide_sequence = 0; - current_hover = -1; - hover_count = 0; - main_panel.inside_method = function() { - var xx = main_panel.XX; - var yy = main_panel.YY; - is_entered = scr_hit(xx, yy, xx + main_panel.width, yy + main_panel.height); - if (view_area == "fleets") { - var cur_fleet; - draw_set_color(c_white); - draw_set_halign(fa_center); - draw_text(xx + 80, yy + 50, "Capitals"); - draw_text(xx + 160, yy + 50, "Frigates"); - draw_text(xx + 240, yy + 50, "Escorts"); - draw_text(xx + 310, yy + 50, "Location"); - var i = start_fleet; - while (i < instance_number(obj_p_fleet) && (yy + 90 + (20 * i) + 12 + 20) < main_panel.YY + yy + main_panel.height) { - if (scr_hit(xx + 10, yy + 90 + (20 * i), xx + main_panel.width, yy + 90 + (20 * i) + 18)) { - draw_set_color(c_gray); - draw_rectangle(xx + 10 + 20, yy + 90 + (20 * i) - 2, xx + main_panel.width - 20, yy + 90 + (20 * i) + 18, 0); - draw_set_color(c_white); - } - cur_fleet = instance_find(obj_p_fleet, i); - draw_text(xx + 80, yy + 90 + (20 * i), cur_fleet.capital_number); - draw_text(xx + 160, yy + 90 + (20 * i), cur_fleet.frigate_number); - draw_text(xx + 240, yy + 90 + (20 * i), cur_fleet.escort_number); - var _fleet_point_data = cur_fleet.point_breakdown; - var _loc_display_string = ""; - var _zoomable_loc = true; - if (cur_fleet.action == "Lost") { - _loc_display_string = "Lost"; - _zoomable_loc = false; - } else if (string_count("crusade", cur_fleet.action)) { - _loc_display_string = "Crusading"; - _zoomable_loc = false; - } else if (cur_fleet.action == "move") { - _loc_display_string = "Warp Travel"; - } else { - var _near_star = instance_nearest(cur_fleet.x, cur_fleet.y, obj_star); - _loc_display_string = _near_star.name; - - var _special_points = obj_controller.specialist_point_handler.point_breakdown.systems; - if (struct_exists(_special_points, _near_star)) { - var _fleet_point_data = _special_points[$ _near_star.name][0]; - } - } - draw_text(xx + 310, yy + 90 + (20 * i), _loc_display_string); - - var _fleet_coords = [ - xx + 10, - yy + 90 + (20 * i) - 2, - xx + main_panel.width, - yy + 90 + (20 * i) + 18 - ]; - - if (_zoomable_loc) { - if (point_and_click([xx + 10, yy + 90 + (20 * i) - 2, xx + main_panel.width, yy + 90 + (20 * i) + 18])) { - travel_target = [ - cur_fleet.x, - cur_fleet.y - ]; - travel_increments = [ - (travel_target[0] - obj_controller.x) / 15, - (travel_target[1] - obj_controller.y) / 15 - ]; - travel_time = 0; - } - } - - if (scr_hit(_fleet_coords)) { - detail_slate.draw(xx + main_panel.width - 10, _fleet_coords[1] - 20, 1.5, 1.5); - var _xx = xx + main_panel.width - 10; - var _yy = _fleet_coords[1] - 20; - draw_set_font(fnt_40k_12i); - draw_text(_xx + 160, _yy + 10, "forge point\ntotal"); - draw_text(_xx + 240, _yy + 10, "forge point\nuse"); - draw_text(_xx + 320, _yy + 10, "apothecary\npoint total"); - draw_text(_xx + 400, _yy + 10, "apothecary\npoint use"); - draw_text(_xx + 60, _yy + 50, "Orbiting"); - var _y_line = _yy + 50; - draw_text(_xx + 160, _y_line, _fleet_point_data.forge_points); - draw_text(_xx + 240, _y_line, _fleet_point_data.forge_points_use); - draw_text(_xx + 320, _y_line, _fleet_point_data.heal_points); - draw_text(_xx + 400, _y_line, _fleet_point_data.heal_points_use); - } - i++; - } - } else if (view_area == "garrisons") { - var system_data; - draw_set_color(c_white); - draw_set_halign(fa_center); - draw_text(xx + 80, yy + 50, "System"); - draw_text(xx + 160, yy + 50, "Troops"); - draw_text(xx + 240, yy + 50, "Healers"); - draw_text(xx + 310, yy + 50, "Techies"); - var i = start_system; - var registered_hover = false; - var system_names = struct_get_names(garrison_log); - var hover_entered = false; - var any_hover = false; - if (hover_item != "none") { - var loc = hover_item.location; - hover_entered = scr_hit(loc[0], loc[1], loc[2], loc[3]); - } - while (i < array_length(system_names) && (yy + 90 + (20 * i) + 12 + 20) < main_panel.YY + yy + main_panel.height) { - var _sys_name = system_names[i]; - system_data = garrison_log[$ _sys_name]; - registered_hover = false; - var _sys_item_y = yy + 90 + (20 * i) + 18; - if (scr_hit(xx + 10, yy + 90 + (20 * i), xx + main_panel.width, _sys_item_y)) { - if (!hover_entered) { - draw_set_color(c_gray); - draw_rectangle(xx + 10 + 20, yy + 90 + (20 * i) - 2, xx + main_panel.width - 20, yy + 90 + (20 * i) + 18, 0); - draw_set_color(c_white); - if (current_hover > -1 && current_hover != i) { - registered_hover = false; - } else { - current_hover = i; - registered_hover = true; - hover_count++; - } - } else { - if (hover_item.root_item == i) { - draw_rectangle(xx + 10 + 20, yy + 90 + (20 * i) - 2, xx + main_panel.width - 20, yy + 90 + (20 * i) + 18, 0); - } - } - detail_slate.draw(xx + main_panel.width - 10, _sys_item_y - 20, 1.5, 1.5); - var _special_points = obj_controller.specialist_point_handler.point_breakdown.systems; - if (struct_exists(_special_points, _sys_name)) { - var _system_point_data = _special_points[$ _sys_name]; - var _xx = xx + main_panel.width - 10; - var _yy = _sys_item_y - 20; - draw_set_font(fnt_40k_12i); - draw_text(_xx + 160, _yy + 10, "forge point\ntotal"); - draw_text(_xx + 240, _yy + 10, "forge point\nuse"); - draw_text(_xx + 320, _yy + 10, "apothecary\npoint total"); - draw_text(_xx + 400, _yy + 10, "apothecary\npoint use"); - draw_text(_xx + 60, _yy + 50, "Orbiting"); - for (var s = 1; s <= 4; s++) { - draw_text(_xx + 60, _yy + 50 + (50 * s), scr_roman(s)); - } - var _y_line = _yy + 50; - for (var o = 0; o < 5; o++) { - var _area_item = _system_point_data[o]; - draw_text(_xx + 220, _y_line, _area_item.forge_points); - draw_text(_xx + 300, _y_line, _area_item.forge_points_use); - draw_text(_xx + 380, _y_line, _area_item.heal_points); - draw_text(_xx + 460, _y_line, _area_item.heal_points_use); - _y_line += 50; - } - } - } - draw_text(xx + 80, yy + 90 + (20 * i), system_names[i]); - draw_text(xx + 160, yy + 90 + (20 * i), array_length(system_data.units)); - draw_text(xx + 240, yy + 90 + (20 * i), system_data.healers); - draw_text(xx + 310, yy + 90 + (20 * i), system_data.techies); - - if (!hover_entered) { - if (point_and_click([xx + 10, yy + 90 + (20 * i) - 2, xx + main_panel.width, yy + 90 + (20 * i) + 18])) { - var star = find_star_by_name(system_names[i]); - if (star != "none") { - travel_target = [ - star.x, - star.y - ]; - travel_increments = [ - (travel_target[0] - obj_controller.x) / 15, - (travel_target[1] - obj_controller.y) / 15 - ]; - travel_time = 0; - } - } - } - if (registered_hover) { - any_hover = true; - if (hover_count == 10) { - hover_item = new HoverBox(); - var mouse_consts = return_mouse_consts(); - hover_item.relative_x = mouse_consts[0]; - hover_item.relative_y = mouse_consts[1]; - hover_item.root_item = i; - } - } - i++; - } - if (!any_hover && !hover_entered) { - current_hover = -1; - hover_count = 0; - hover_item = "none"; - } else if (hover_item != "none") { - if (point_and_click(hover_item.draw(xx + 10, yy + 90 + (20 * hover_item.root_item), "Manage"))) { - group_selection(garrison_log[$ system_names[hover_item.root_item]].units, {purpose: $"{system_names[hover_item.root_item]} Management", purpose_code: "manage", number: 0, system: find_star_by_name(system_names[hover_item.root_item]).id, feature: "none", planet: 0, selections: []}); - } - } - } else if (view_area == "missions") { - draw_set_color(c_white); - draw_set_halign(fa_center); - draw_text(xx + 80, yy + 50, "Location"); - draw_text(xx + 160, yy + 50, "Mission"); - draw_text(xx + 290, yy + 50, "Time Remaining"); - var i = 0; - while (i < array_length(mission_log) && (90 + (20 * i) + 12 + 20) < main_panel.height) { - mission = mission_log[i]; - entered = false; - if (scr_hit(xx + 10, yy + 90 + (20 * i), xx + main_panel.width, yy + 90 + (20 * i) + 18)) { - draw_set_color(c_gray); - draw_rectangle(xx + 10 + 20, yy + 90 + (20 * i) - 2, xx + main_panel.width - 20, yy + 90 + (20 * i) + 18, 0); - draw_set_color(c_white); - entered = true; - } - if (mission.system != "") { - draw_text(xx + 80, yy + 90 + (20 * i), $"{mission.system} {scr_roman_numerals()[mission.planet - 1]}"); - } - draw_set_halign(fa_left); - if (entered) { - draw_text(xx + 160 - 20, yy + 90 + (20 * i), mission.mission); - } else { - draw_text(xx + 160 - 20, yy + 90 + (20 * i), string_truncate(mission.mission, 150)); - } - draw_set_halign(fa_center); - if (!entered) { - draw_text(xx + 310, yy + 90 + (20 * i), mission.time); - } - if (point_and_click([xx + 10, yy + 90 + (20 * i) - 2, xx + main_panel.width, yy + 90 + (20 * i) + 18])) { - var star = find_star_by_name(mission.system); - if (star != "none") { - travel_target = [ - star.x, - star.y - ]; - } - travel_increments = [ - (travel_target[0] - obj_controller.x) / 15, - (travel_target[1] - obj_controller.y) / 15 - ]; - travel_time = 0; - } - i++; - } - } - }; - - static draw = function() { - add_draw_return_values(); - if (obj_controller.menu == 0 && obj_controller.zoomed == 0) { - if (!instances_exist_any([obj_fleet_select, obj_star_select])) { - var x_draw = 0; - var lower_draw = main_panel.height + 110; - if (hide_sequence == 30) { - hide_sequence = 0; - } - if ((hide_sequence > 0 && hide_sequence < 15) || (hide_sequence > 15 && hide_sequence < 30)) { - if (hide_sequence > 15) { - x_draw = ((main_panel.width / 15) * (hide_sequence - 15)) - main_panel.width; - } else { - x_draw = -((main_panel.width / 15) * hide_sequence); - } - hide_sequence++; - } - if (hide_sequence > 15 || hide_sequence < 15) { - main_panel.draw(x_draw, 110, 0.46, 0.75); - if (tab_buttons.fleets.draw(x_draw, 79, "Fleets")) { - view_area = "fleets"; - } - if (tab_buttons.garrisons.draw(115 + x_draw, 79, "System Troops")) { - view_area = "garrisons"; - update_garrison_log(); - } - if (tab_buttons.missions.draw(230 + x_draw, 79, "Missions")) { - view_area = "missions"; - update_garrison_log(); - } - if (x_draw < 0) { - tab_buttons.hider.draw(0, lower_draw, "Show"); - } else { - if (tab_buttons.hider.draw(x_draw + 280, lower_draw, "Hide")) { - hide_sequence++; - } - } - } else if (hide_sequence == 15) { - if (tab_buttons.hider.draw(0, lower_draw, "Show")) { - hide_sequence++; - } - } - /*if (tab_buttons.troops.draw(345,79, "Troops")){ +// https : //help.yoyogames.com/hc/en-us/articles/360005277377 for more information +function UnitQuickFindPanel() constructor{ + main_panel = new DataSlate(); + garrison_log = {}; + ship_count = 0; + tab_buttons = { + "fleets" : new MainMenuButton(spr_ui_but_3, spr_ui_hov_3), + "garrisons" : new MainMenuButton(spr_ui_but_3, spr_ui_hov_3), + "hider" : new MainMenuButton(spr_ui_but_3, spr_ui_hov_3), + "missions" : new MainMenuButton(spr_ui_but_3, spr_ui_hov_3), + } + + static detail_slate = new DataSlateMKTwo(); + + view_area = "fleets"; + + static has_troops = function(name){ + return struct_exists(garrison_log, name); + } + + static player_force_stars = function(){ + var _names = struct_get_names(garrison_log); + var _stars = []; + for (var i=0;i-1){ + obj_ini.ship_carrying[unit.ship_location]+=unit.get_unit_size(); + } + } + } + + static evaluate_vehicle_for_garrison_log = function(company, array_slot){ + + var co = company; + var u = array_slot; + + if (obj_ini.veh_race[co][u]==0) then return; + if (obj_ini.veh_wid[co][u]>0){ + unit_location = obj_ini.veh_loc[co][u]; + var _unit = [co, u]; + if (!struct_exists(garrison_log, unit_location)){ + garrison_log[$ unit_location] = { + units : [_unit], + vehicles : 1, + garrison : false, + healers : 0, + techies : 0 + } + } else { + array_push(garrison_log[$ unit_location].units, _unit); + garrison_log[$ unit_location].vehicles++; + } + } else if (obj_ini.veh_lid[co][u]>-1){ + obj_ini.ship_carrying[obj_ini.veh_lid[co][u]]+=scr_unit_size("",obj_ini.veh_role[co][u],true); + } + } + + + static update_garrison_log = function(){ + try{ + for (var i = 0;i-1 && current_hover!=i){ + registered_hover=false; + } else { + current_hover=i; + registered_hover=true; + hover_count++; + } + } else { + if (hover_item.root_item == i){ + draw_rectangle(xx+10+20, yy+90+(20*i)-2,xx+main_panel.width-20,yy+90+(20*i)+18, 0); + } + } + detail_slate.draw(xx+main_panel.width-10,_sys_item_y-20, 1.5, 1.5); + var _special_points = obj_controller.specialist_point_handler.point_breakdown.systems; + if (struct_exists(_special_points,_sys_name)){ + var _system_point_data = _special_points[$ _sys_name]; + var _xx = xx+main_panel.width-10; + var _yy = _sys_item_y-20; + draw_set_font(fnt_40k_12i); + draw_text(_xx+160, _yy+10,"forge point\ntotal"); + draw_text( _xx+240, _yy+10,"forge point\nuse"); + draw_text( _xx+320, _yy+10,"apothecary\npoint total"); + draw_text(_xx+400, _yy+10,"apothecary\npoint use"); + draw_text(_xx+60, _yy+50,"Orbiting"); + for (var s=1;s<=4;s++){ + draw_text( _xx+60, _yy+50 + (50*s),scr_roman(s)); + } + var _y_line = _yy+50; + for (var o=0;o<5;o++){ + var _area_item = _system_point_data[o]; + draw_text(_xx+220, _y_line,_area_item.forge_points); + draw_text(_xx+300, _y_line,_area_item.forge_points_use); + draw_text(_xx+380, _y_line , _area_item.heal_points); + draw_text(_xx+460, _y_line, _area_item.heal_points_use); + _y_line+=50; + } + + } + } + draw_text(xx+80, yy+90+(20*i), system_names[i]); + draw_text(xx+160, yy+90+(20*i), array_length(system_data.units)); + draw_text(xx+240, yy+90+(20*i), system_data.healers); + draw_text(xx+310, yy+90+(20*i), system_data.techies); + + if (!hover_entered){ + if (point_and_click([xx+10, yy+90+(20*i)-2,xx+main_panel.width,yy+90+(20*i)+18])){ + var star = star_by_name(system_names[i]); + if (star!="none"){ + travel_target = [star.x, star.y]; + travel_increments = [(travel_target[0]-obj_controller.x)/15,(travel_target[1]-obj_controller.y)/15]; + travel_time = 0; + } + } + } + if (registered_hover){ + any_hover=true; + if (hover_count==10){ + hover_item = new HoverBox(); + var mouse_consts = return_mouse_consts() + hover_item.relative_x = (mouse_consts[0]); + hover_item.relative_y = (mouse_consts[1]); + hover_item.root_item=i; + } + } + i++; + } + if (!any_hover && !hover_entered){ + current_hover=-1; + hover_count=0; + hover_item="none"; + }else if (hover_item!="none"){ + if point_and_click(hover_item.draw(xx+10, yy+90+(20*hover_item.root_item), "Manage")){ + group_selection(garrison_log[$system_names[hover_item.root_item]].units,{ + purpose : $"{system_names[hover_item.root_item]} Management", + purpose_code : "manage", + number : 0, + system : star_by_name(system_names[hover_item.root_item]).id, + feature : "none", + planet : 0, + selections : [] + }); + } + } + } else if (view_area == "missions"){ + mission_table.update({ + x1 : xx+60, + y1 : yy+50, + }); + mission_table.draw(); + } + } + static draw = function(){ + add_draw_return_values(); + if (obj_controller.menu==0 && obj_controller.zoomed==0 ){ + if (!instances_exist_any([obj_fleet_select,obj_star_select])){ + + var x_draw=0; + var lower_draw = main_panel.height+110; + if (hide_sequence=30) then hide_sequence=0; + if ((hide_sequence>0 && hide_sequence<15) || (hide_sequence>15 && hide_sequence<30)){ + if (hide_sequence>15){ + x_draw=((main_panel.width/15)*(hide_sequence-15))-main_panel.width; + } else { + x_draw=-((main_panel.width/15)*hide_sequence); + } + hide_sequence++; + } + if (hide_sequence>15 || hide_sequence<15){ + main_panel.draw(x_draw, 110, 0.46, 0.75); + if(tab_buttons.fleets.draw(x_draw,79, "Fleets")){ + view_area="fleets"; + } + if (tab_buttons.garrisons.draw(115+x_draw,79, "System Troops")){ + view_area="garrisons"; + update_garrison_log(); + } + if (tab_buttons.missions.draw(230+x_draw,79, "Missions")){ + view_area="missions"; + update_garrison_log(); + } + if (x_draw<0){ + tab_buttons.hider.draw(0,lower_draw, "Show") + } else { + if (tab_buttons.hider.draw(x_draw+280,lower_draw, "Hide")){ + hide_sequence++; + } + } + } else if (hide_sequence==15){ + if (tab_buttons.hider.draw(0,lower_draw, "Show")){ + hide_sequence++; + } + } + /*if (tab_buttons.troops.draw(345,79, "Troops")){ view_area="troops"; - }*/ - } - if (array_length(travel_target) == 2) { - if (obj_controller.x != travel_target[0] || obj_controller.y != travel_target[1]) { - obj_controller.x += travel_increments[0]; - obj_controller.y += travel_increments[1]; - travel_time++; - } else { - travel_target = []; - } - if (travel_time == 15) { - obj_controller.x = travel_target[0]; - obj_controller.y = travel_target[1]; - travel_target = []; - } - } - } - pop_draw_return_values(); - }; + }*/ + } + if (array_length(travel_target)==2){ + if (obj_controller.x!=travel_target[0] || obj_controller.y!=travel_target[1]){ + obj_controller.x += travel_increments[0]; + obj_controller.y += travel_increments[1]; + travel_time++; + } else { + travel_target=[]; + } + if (travel_time==15){ + obj_controller.x = travel_target[0]; + obj_controller.y = travel_target[1]; + travel_target=[]; + } + } + } + pop_draw_return_values(); + } } -function HoverBox() constructor { - root_item = "none"; - relative_x = 0; - relative_y = 0; - location = [ - 0, - 0, - 0, - 0 - ]; - - static draw = function(xx, yy, button_text) { - location = draw_unit_buttons([relative_x, relative_y], button_text, [1, 1], c_green,, fnt_40k_14b, 1); - return location; - }; +function HoverBox() constructor{ + root_item = "none"; + relative_x = 0; + relative_y = 0; + location = [0,0,0,0]; + static draw = function(xx, yy, button_text){ + location = draw_unit_buttons([relative_x, relative_y], button_text,[1,1], c_green,, fnt_40k_14b, 1); + return location; + } } -function exit_adhoc_manage() { - scr_toggle_manage(); - if (struct_exists(selection_data, "system") && instance_exists(selection_data.system)) { - selection_data.system.alarm[3] = 2; - } +function exit_adhoc_manage(){ + scr_toggle_manage(); + if (struct_exists(selection_data, "system") && instance_exists(selection_data.system)){ + selection_data.system.alarm[3]=2; + } +}; + + function update_garrison_manage(){ + location_viewer.update_garrison_log(); + var _selection = []; + var sys_name = ""; + var _ships = -1; + var _planets = 0 + if (struct_exists(selection_data, "system")&& instance_exists(selection_data.system)){ + if (struct_exists(location_viewer.garrison_log, selection_data.system.name)){ + sys_name = selection_data.system.name; + } + } + + if (struct_exists(selection_data , "ships")){ + _ships = selection_data.ships; + } + + if (struct_exists(selection_data , "planets")){ + _planets = selection_data.planets; + } + + _selection = collect_role_group("all",[sys_name, _planets,_ships]); + + if (array_length(_selection)){ + group_selection(_selection,selection_data); + } else { + exit_adhoc_manage(); + } } -function update_garrison_manage() { - location_viewer.update_garrison_log(); - var _selection = []; - var sys_name = ""; - var _ships = -1; - var _planets = 0; - if (struct_exists(selection_data, "system") && instance_exists(selection_data.system)) { - if (struct_exists(location_viewer.garrison_log, selection_data.system.name)) { - var sys_name = selection_data.system.name; - } - } - - if (struct_exists(selection_data, "ships")) { - _ships = selection_data.ships; - } - - if (struct_exists(selection_data, "planets")) { - _planets = selection_data.planets; - } - - _selection = collect_role_group("all", [sys_name, _planets, _ships]); - if (array_length(_selection)) { - group_selection(_selection, selection_data); - } else { - exit_adhoc_manage(); - } +function update_general_manage_view(){ + with (obj_controller){ + if (managing>0){ + if (managing<=10) and (managing!=0){ + scr_company_view(managing); + } + if (managing>10) or (managing=0){ + scr_special_view(managing); + } + new_company_struct(); + cooldown=10; + sel_loading=-1; + unload=0; + alarm[6]=30; + } else if (managing==-1){ + update_garrison_manage(); + } + } } -function update_general_manage_view() { - with (obj_controller) { - if (managing > 0) { - if ((managing <= 10) && (managing != 0)) { - scr_company_view(managing); - } - if ((managing > 10) || (managing == 0)) { - scr_special_view(managing); - } - new_company_struct(); - cooldown = 10; - sel_loading = -1; - unload = 0; - alarm[6] = 30; - } else if (managing == -1) { - update_garrison_manage(); - } - } -} - -function toggle_selection_borders() { - for (var p = 0; p < array_length(display_unit); p++) { - if ((man_sel[p] == 1) && (man[p] == "man")) { - if (is_struct(display_unit[p])) { - var _unit = display_unit[p]; +function toggle_selection_borders(){ + for(var p=0; p -1) && _unit.controllable()) { - _unit.is_boarder = !_unit.is_boarder; + if (_unit.ship_location>-1) and (_unit.controllable()){ + _unit.is_boarder = !_unit.is_boarder; } } } - } + } } + /// @mixin -function add_bionics_selection() { +function add_bionics_selection(){ if (scr_item_count("Bionics") <= 0) { return; } @@ -587,282 +611,320 @@ function add_bionics_selection() { } } -function jail_selection() { - for (var f = 0; f < array_length(display_unit); f++) { - if (man[f] != "man" || !man_sel[f]) { - continue; - } - _unit = display_unit[f]; - if (_unit.controllable()) { - if (is_struct(display_unit[f]) && !_unit.in_jail()) { - obj_ini.god[_unit.company][_unit.marine_number] += 10; - ma_god[f] += 10; - man_sel[f] = 0; +function jail_selection(){ + for(var f=0; f 0) { - alll = 0; + if (managing>0){ + alll=0; update_general_manage_view(); - } else if (managing == -1) { - update_garrison_manage(); + } else if (managing==-1){ + update_garrison_manage() } - sel_loading = -1; - unload = 0; - alarm[6] = 7; + sel_loading=-1; + unload=0; + alarm[6]=7; } -function load_selection() { - if (man_size > 0 && !location_out_of_player_control(selecting_location)) { +function load_selection(){ + if (man_size>0 && !location_out_of_player_control(selecting_location)){ scr_company_load(selecting_location); - menu = 30; - top = 1; - } + menu=30; + top=1; + } } -function unload_selection() { - if (man_size > 0 && obj_controller.selecting_ship >= 0 && !instance_exists(obj_star_select) && !location_out_of_player_control(selecting_location) && selecting_location != "Warp") { - cooldown = 8000; - var boba = 0; - var unload_star = find_star_by_name(selecting_location); - if (unload_star != "none") { - if (unload_star.space_hulk != 1) { +function unload_selection(){ + if (man_size>0 && obj_controller.selecting_ship>=0 && !instance_exists(obj_star_select)&& + !location_out_of_player_control(selecting_location) && selecting_location!="Warp"){ + cooldown=8000; + var boba=0; + var unload_star = star_by_name(selecting_location); + if (unload_star != "none"){ + if (unload_star.space_hulk!=1){ for (var t = 0; t < array_length(display_unit); t++) { if (man_sel[t] == 1) { - var _unit = display_unit[t]; + var _unit = display_unit[t]; if (is_array(_unit)) { - set_vehicle_last_ship(_unit); + set_vehicle_last_ship(_unit); } else { - _unit.set_last_ship(); + _unit.set_last_ship(); } } } - boba = instance_create(unload_star.x, unload_star.y, obj_star_select); - boba.loading = 1; + boba=instance_create(unload_star.x,unload_star.y,obj_star_select); + boba.loading=1; // selecting location is the ship right now; get it's orbit location - boba.loading_name = selecting_location; - boba.depth = self.depth - 50; + boba.loading_name=selecting_location; + boba.depth=self.depth-50; // sel_uid=obj_ini.ship_uid[selecting_ship]; scr_company_load(obj_ini.ship_location[selecting_ship]); } } - } + } } -function reset_selection_equipment() { - var _unit; - for (var f = 0; f < array_length(display_unit); f++) { +function reset_selection_equipment(){ + var _unit; + for(var f=0; f= 1 || is_specialist(ma_role[f], SPECIALISTS_RANK_AND_FILE) || is_specialist(ma_role[f], SPECIALISTS_SQUAD_LEADERS)) && man_sel[f] == 1) { - nuuum += 1; - if (pip.min_exp == 0) { - pip.min_exp = ma_exp[f]; - } - pip.min_exp = min(ma_exp[f], pip.min_exp); +function promote_selection(){ + if (sel_promoting==1) and (instance_number(obj_popup)==0){ + var pip=instance_create(0,0,obj_popup); + pip.type=5; + pip.company=managing; + + var god=0,nuuum=0; + for(var f=1; f=1 || is_specialist(ma_role[f], SPECIALISTS_RANK_AND_FILE) || is_specialist(ma_role[f], SPECIALISTS_SQUAD_LEADERS)) && man_sel[f]==1){ + nuuum+=1; + if (pip.min_exp==0) then pip.min_exp=ma_exp[f]; + pip.min_exp=min(ma_exp[f],pip.min_exp); } - if ((god == 0) && (ma_promote[f] >= 1) && (man_sel[f] == 1)) { - god = 1; - pip.unit_role = ma_role[f]; + if (god==0) and (ma_promote[f]>=1) and (man_sel[f]==1){ + god=1; + pip.unit_role=ma_role[f]; } } - if (nuuum > 1) { - pip.unit_role = "Marines"; - } - pip.units = nuuum; - } + if (nuuum>1) then pip.unit_role="Marines"; + pip.units=nuuum; + } } //to be run in obj_star_select -function setup_planet_mission_group() { - man_sel = []; - display_unit = []; - man = []; - return_place = []; - for (var i = 0; i < array_length(obj_controller.display_unit); i++) { - if (obj_controller.man_sel[i]) { - array_push(man_sel, obj_controller.man_sel[i]); - array_push(display_unit, obj_controller.display_unit[i]); - array_push(man, obj_controller.man[i]); - array_push(return_place, obj_controller.ma_lid[i]); - } - } +function setup_planet_mission_group(){ + man_sel=[]; + display_unit=[]; + man = []; + return_place = []; + for (var i=0;i 0) { - _helps++; - } - } - _data.help_requests = _helps; - - _data.hover = method(_data, function() { - tooltip_draw($"View {name}"); - }); - - _data.click_left = method(_data, function() { - set_map_pan_to_loc(star_id); - }); - - array_push(_help_requests, _data); - } - - static x1 = 1289; - static y1 = 318; - main_panel.XX = x1; - main_panel.YY = y1; +function HelpfulPlaces()constructor{ + main_panel = new DataSlate({draggable : true,cherub : true}); + var _imperial_help_requests = stars_with_help_requests(); + + var _help_requests = []; + + for (var i=0;i 0){ + _helps++; + } + } + _data.help_requests = _helps; + + _data.hover = method(_data,function(){ + tooltip_draw($"View {name}"); + }); + + _data.click_left = method(_data,function(){ + set_map_pan_to_loc(star_id); + }); + + array_push(_help_requests,_data); + } + + static x1 = 1289; + static y1 = 318; + main_panel.XX=x1; + main_panel.YY=y1; + + static entered = function(){ + return main_panel.entered(); + } + + help_table = new Table( + { + row_key_draw : ["name","system_count","help_requests"], + headings : ["System", "Planets", "Planets\nRequesting Help"], + row_data : _help_requests + } + ); + + + + var _navy_fleets = []; + + with (obj_en_fleet){ + if (owner != eFACTION.IMPERIUM || !navy){ + continue; + } + var _guard_percentage = fleet_remaining_guard_ratio() * 100; + + var _data = { + fleet_id : id, + location : "Warp", + remaining_guard : $"{ _guard_percentage }%", + action : trade_goods, + } + if (is_orbiting()){ + _data.location = orbiting.name; + } + + _data.hover = method(_data,function(){ + if (location != "Warp"){ + tooltip_draw($"View fleet at {location}"); + } else { + tooltip_draw($"View fleet"); + } + + }); + + _data.click_left = method(_data, function(){ + set_map_pan_to_loc(fleet_id); + }); + + + array_push(_navy_fleets, _data); + } + + navy_table = new Table( + { + row_key_draw : ["location","remaining_guard"], + headings : ["Location", "Remaining\nGuard"], + row_data : _navy_fleets + }); + + var _forges = []; + + var _columns = []; + var _longest_name = 0; + with (obj_star){ + var _forge = scr_get_planet_with_type(id,"Forge"); + if (_forge > 0){ + var _data = { + system : id, + planet : _forge, + name : planet_numeral_name(_forge), + owner_name : obj_controller.faction[p_owner[_forge]], + owner : p_owner[_forge], + owner_status : obj_controller.faction_status[p_owner[_forge]], + }; + + _data.click_left = method(_data, function(){ + set_map_pan_to_loc(system); + }); + + _data.hover = method(_data,function(){ + tooltip_draw($"click to view {system.name} system"); + + }); + + var _name_length = string_width(_data.name); + if (_name_length > _longest_name){ + _longest_name = _name_length; + } + + array_push(_forges , _data); + } + } + array_push(_columns , _longest_name); + + forges_table = new Table({ + row_key_draw : ["name","owner_name","owner_status"], + headings : ["Name", " Owner ", " Owner\nStatus "], + row_data : _forges, + set_column_widths : _columns, + }); + + places_radio = new RadioSet([ + { + str1 : "Help Requests", + + }, + { + str1 : "Navy Fleets", + + }, + { + str1 : "Forge Worlds", + } + ]); + + main_panel.inside_method = function(){ + places_radio.update({ + x1 : x1 + 30, + y1 : y1 + 25, + }); + places_radio.draw(); + + var _new_position = { + x1 : x1+40, + y1 : y1+50, + y2 : y1 + main_panel.height, + } + switch (places_radio.current_selection){ + case 1 : + navy_table.update(_new_position); + navy_table.draw(); + break; + case 0 : + help_table.update(_new_position); + help_table.draw(); + break; + case 2 : + forges_table.update(_new_position); + forges_table.draw(); + break; + } + } + + static draw = function(){ + x1 = main_panel.XX; + y1 = main_panel.YY; + main_panel.draw(,, 0.35, 0.6); + } - static entered = function() { - return main_panel.entered(); - }; - help_table = new Table({row_key_draw: ["name", "system_count", "help_requests"], headings: ["System", "Planets", "Planets\nRequesting Help"], row_data: _help_requests}); - - var _navy_fleets = []; - - with (obj_en_fleet) { - if (owner != eFACTION.IMPERIUM || !navy) { - continue; - } - var _guard_percentage = fleet_remaining_guard_ratio() * 100; - - var _data = { - fleet_id: id, - location: "Warp", - remaining_guard: $"{_guard_percentage}%", - action: trade_goods, - }; - if (is_orbiting()) { - _data.location = orbiting.name; - } - - _data.hover = method(_data, function() { - if (location != "Warp") { - tooltip_draw($"View fleet at {location}"); - } else { - tooltip_draw($"View fleet"); - } - }); - - _data.click_left = method(_data, function() { - set_map_pan_to_loc(fleet_id); - }); - - array_push(_navy_fleets, _data); - } +} - navy_table = new Table({row_key_draw: ["location", "remaining_guard"], headings: ["Location", "Remaining\nGuard"], row_data: _navy_fleets}); - - var _forges = []; - - var _columns = []; - var _longest_name = 0; - with (obj_star) { - var _forge = scr_get_planet_with_type(id, "Forge"); - if (_forge > 0) { - var _data = { - system: id, - planet: _forge, - name: planet_numeral_name(_forge), - owner_name: obj_controller.faction[p_owner[_forge]], - owner: p_owner[_forge], - owner_status: obj_controller.faction_status[p_owner[_forge]], - }; - - _data.click_left = method(_data, function() { - set_map_pan_to_loc(system); - }); - - _data.hover = method(_data, function() { - tooltip_draw($"click to view {system.name} system"); - }); - - var _name_length = string_width(_data.name); - if (_name_length > _longest_name) { - _longest_name = _name_length; - } - array_push(_forges, _data); - } - } - array_push(_columns, _longest_name); - - forges_table = new Table({row_key_draw: ["name", "owner_name", "owner_status"], headings: ["Name", " Owner ", " Owner\nStatus "], row_data: _forges, set_column_widths: _columns}); - - places_radio = new RadioSet([{str1: "Help Requests"}, {str1: "Navy Fleets"}, {str1: "Forge Worlds"}]); - - main_panel.inside_method = function() { - places_radio.update({x1: x1 + 30, y1: y1 + 25}); - places_radio.draw(); - - var _new_position = { - x1: x1 + 40, - y1: y1 + 50, - y2: y1 + main_panel.height, - }; - switch (places_radio.current_selection) { - case 1: - navy_table.update(_new_position); - navy_table.draw(); - break; - case 0: - help_table.update(_new_position); - help_table.draw(); - break; - case 2: - forges_table.update(_new_position); - forges_table.draw(); - break; - } - }; - static draw = function() { - x1 = main_panel.XX; - y1 = main_panel.YY; - main_panel.draw(,, 0.35, 0.6); - }; -}