From cc66a5a904f466d214dbf9419f309aa169f4e7f9 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 12 Aug 2026 19:45:55 +0100 Subject: [PATCH 001/118] start porting to OOP Missions --- ChapterMaster.yyp | 1 + objects/obj_popup/Step_0.gml | 56 ++++++++++--------- objects/obj_star/Create_0.gml | 4 +- scripts/MissionHelper/MissionHelper.gml | 22 ++++++++ scripts/MissionHelper/MissionHelper.yy | 13 +++++ scripts/scr_PlanetData/scr_PlanetData.gml | 25 +++++---- scripts/scr_crusade/scr_crusade.gml | 3 +- .../scr_inquisition_mission.gml | 19 +++---- .../scr_mechanicus_missions.gml | 10 ++-- 9 files changed, 95 insertions(+), 58 deletions(-) create mode 100644 scripts/MissionHelper/MissionHelper.gml create mode 100644 scripts/MissionHelper/MissionHelper.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index f7c6b5122d..098d657304 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -738,6 +738,7 @@ {"id":{"name":"LocalizationManager","path":"scripts/LocalizationManager/LocalizationManager.yy",},}, {"id":{"name":"Logger","path":"scripts/Logger/Logger.yy",},}, {"id":{"name":"macros","path":"scripts/macros/macros.yy",},}, + {"id":{"name":"MissionHelper","path":"scripts/MissionHelper/MissionHelper.yy",},}, {"id":{"name":"NameGenerator","path":"scripts/NameGenerator/NameGenerator.yy",},}, {"id":{"name":"NotificationAlert","path":"scripts/NotificationAlert/NotificationAlert.yy",},}, {"id":{"name":"object_get_depth","path":"scripts/object_get_depth/object_get_depth.yy",},}, diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index 92c1c7a9cb..0552bb4726 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -210,31 +210,33 @@ try { if ((press == 0) && array_length(options) || ((demand == 1) && (mission != "") && (string_count("Inquisition", title) > 0)) || ((demand == 1) && (title == "Inquisition Recon"))) { if (title == "Inquisition Recon") { obj_controller.temp[200] = string(loc); - var mission_star = find_star_by_name(obj_controller.temp[200]); - if (add_new_problem(planet, "recon", estimate, mission_star)) { - title = "Inquisition Mission Demand"; - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to land Astartes on {mission_star.name} {scr_roman(planet)} to investigate the planet within {estimate} months."; - with (mission_star) { - new_star_event_marker("green"); - } - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {mission_star.name} {scr_roman(planet)} within {estimate} months.", mission_star.name); + var _mission_star = find_star_by_name(obj_controller.temp[200]); + var _pdata = _mission_star.get_planet_data(planet); + var _problem = new_problem("recon", estimate); + + title = "Inquisition Mission Demand"; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to land Astartes on {_mission_star.name} {scr_roman(planet)} to investigate the planet within {estimate} months."; + with (_mission_star) { + new_star_event_marker("green"); } + scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {_mission_star.name} {scr_roman(planet)} within {estimate} months.", _mission_star.name); + } if ((mission != "") && (title == "Inquisition Mission")) { obj_controller.temp[200] = string(loc); var onceh = 0; - var mission_star = find_star_by_name(obj_controller.temp[200]); + var _mission_star = find_star_by_name(obj_controller.temp[200]); var mission_is_go = false; - if (mission_star != noone && planet > 0) { + if (_mission_star != noone && planet > 0) { var _estimate = estimate; var _planet = planet; var _mission = mission; - with (mission_star) { - if (add_new_problem(_planet, _mission, _estimate)) { - new_star_event_marker("green"); - mission_is_go = true; - } + var _p_data = _mission_star.get_planet_data(_planet); + with (_mission_star) { + _p_data.new_problem(_mission, _estimate) + new_star_event_marker("green"); + mission_is_go = true; } if (mission_is_go) { @@ -243,20 +245,20 @@ try { } if (mission == "purge") { - scr_event_log("", $"Inquisition Mission Accepted: The nobles of {mission_star.name} {scr_roman(planet)} must be selectively purged within {estimate} months.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The nobles of {_mission_star.name} {scr_roman(planet)} must be selectively purged within {estimate} months.", _mission_star.name); if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to selectively purge the Nobles on {mission_star.name} {scr_roman(onceh)} within {estimate} months."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to selectively purge the Nobles on {_mission_star.name} {scr_roman(onceh)} within {estimate} months."; } } else if (mission == "cleanse") { - scr_event_log("", $"Inquisition Mission Accepted: The mutants beneath {planet_numeral_name(planet, mission_star)} must be cleansed by fire within {estimate} months.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The mutants beneath {planet_numeral_name(planet, _mission_star)} must be cleansed by fire within {estimate} months.", _mission_star.name); if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to cleanse by fire the mutants in Hive {planet_numeral_name(planet, mission_star)} within {estimate} months."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to cleanse by fire the mutants in Hive {planet_numeral_name(planet, _mission_star)} within {estimate} months."; } } if (mission == "spyrer") { - scr_event_log("", $"Inquisition Mission Accepted: The Spyrer on {mission_star.name} {scr_roman(planet)} must be killed within {estimate} months.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The Spyrer on {_mission_star.name} {scr_roman(planet)} must be killed within {estimate} months.", _mission_star.name); if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Spyrer on Hive {mission_star.name} {scr_roman(onceh)} must be removed within {estimate} months."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Spyrer on Hive {_mission_star.name} {scr_roman(onceh)} must be removed within {estimate} months."; } } else if (mission == "tyranid_org") { image = "webber"; @@ -272,7 +274,7 @@ try { reset_popup_options(); scr_add_item("Webber", 4); obj_controller.cooldown = 10; - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wishes for the capture of a particular strain Gaunt noticed on {mission_star.name} {scr_roman(planet)} is advisable.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wishes for the capture of a particular strain Gaunt noticed on {_mission_star.name} {scr_roman(planet)} is advisable.", _mission_star.name); obj_controller.useful_info += "Tyr|"; if (demand) { demand = 0; @@ -289,15 +291,15 @@ try { if (demand) { title = "Inquisition Mission Demand"; - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture the Tau Ethereal somewhere within the {mission_star.name} system."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture the Tau Ethereal somewhere within the {_mission_star.name} system."; } - if (has_problem_star("recon", mission_star)) { - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for {global.chapter_name} to capture the Tau Ethereal somewhere within {mission_star.name}.", mission_star.name); + if (has_problem_star("recon", _mission_star)) { + scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for {global.chapter_name} to capture the Tau Ethereal somewhere within {_mission_star.name}.", _mission_star.name); } } else if (mission == "demon_world") { - scr_event_log("", $"Inquisition Mission Accepted: The demon world of {mission_star.name} {scr_roman(planet)} will be purged by your hand.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The demon world of {_mission_star.name} {scr_roman(planet)} will be purged by your hand.", _mission_star.name); if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {mission_star.name} {scr_roman(onceh)} must be cleansed within {estimate} months."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {_mission_star.name} {scr_roman(onceh)} must be cleansed within {estimate} months."; } } } diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 1fd51b9692..8c4ba0e056 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -67,9 +67,7 @@ p_operatives = array_create_advanced(_planet_array_size, []); p_feature = array_create_advanced(_planet_array_size, []); p_upgrades = array_create_advanced(_planet_array_size, []); p_influence = array_create_advanced(_planet_array_size, array_create(15, 0)); -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)); +p_problem = []; system_datas = array_create(8, undefined); system_garrison = array_create(8, undefined); diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml new file mode 100644 index 0000000000..e986bccb13 --- /dev/null +++ b/scripts/MissionHelper/MissionHelper.gml @@ -0,0 +1,22 @@ +function MissionHelper() constructor{ + +} + + +function PlanetProblem(name, timer, data star, planet){ + timer = timer; + p_id = name; + data = data; + star = star; + planet = planet; + + static __init(){ + switch(p_id){ + case "necron": + new_star_event_marker("green"); + mission_is_go = true; + } + } + + __init(); +} \ No newline at end of file diff --git a/scripts/MissionHelper/MissionHelper.yy b/scripts/MissionHelper/MissionHelper.yy new file mode 100644 index 0000000000..650909366b --- /dev/null +++ b/scripts/MissionHelper/MissionHelper.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"MissionHelper", + "isCompatibility":false, + "isDnD":false, + "name":"MissionHelper", + "parent":{ + "name":"Scripts", + "path":"folders/Scripts.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 43edd8acc1..2237b5e0ef 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -774,9 +774,18 @@ function PlanetData(_planet, _system) constructor { 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 new_problem = function(p_id, timer = -1, data = {}, register = true){ + var _prob = new PlanetProblem(p_id, timer, data,system.name, planet); + if (register){ + register_problem(_prob) + } + return _prob; + } + + static register_problem = function(problem){ + array_push(p_problem, problem); + problems = system.p_problem[planet]; + } static name = function() { return planet_numeral_name(planet, system); @@ -2057,7 +2066,7 @@ function PlanetData(_planet, _system) constructor { static init_war_of_succession = function() { add_feature(eP_FEATURES.SUCCESSION_WAR); - add_problem("succession", irandom(6) + 4); + new_problem("succession", irandom(6) + 4); set_player_disposition(-5000); scr_popup("War of Succession", $"The planetary governor of {name()} 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", ""); @@ -2070,13 +2079,7 @@ function PlanetData(_planet, _system) constructor { static init_fallen_marines = function() { var _eta = scr_mission_eta(system.x, system.y, 1); - - var assigned_problem = add_problem("fallen", _eta); - - if (!assigned_problem) { - LOGGER.error("RE: Hunt the Fallen, coulnd't assign a problem to the planet"); - return; - } + assigned_problem = new_problem("fallen", _eta); var _text = $"Sources indicate one of the Fallen may be upon {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", ""); diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index b528455b8f..6133cb8f98 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -232,7 +232,8 @@ function launch_crusade() { star_alert.image_alpha = 1; star_alert.image_speed = 1; scr_event_log("", $"A Crusade is called; our forces are expected at {star_id.name} in {_eta} months.", star_id.name); - assigned_crusade = add_new_problem(irandom_range(1, star_id.planets), "great_crusade", _eta, star_id); + var _p_data = star_id.get_planet_data(irandom_range(1, star_id.planets)); + assigned_crusade = _p_data.new_problem("great_crusade", _eta, star_id); return true; } } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 970edeae0c..c3d68fe415 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -226,11 +226,12 @@ function mission_inquisition_tomb_world(tomb_worlds) { /// @self Asset.GMObject.obj_popup function init_mission_inquisition_tomb_world() { mission_star = find_star_by_name(pop_data.system); + var _p_data = mission_star.get_planet_data(pop_data.planet); if (mission_star == noone) { popup_default_close(); exit; } - scr_event_log("", $"Inquisition Mission Accepted: {global.chapter_name} have been given a Bomb to seal the Necron Tomb on {mission_star.name} {scr_roman(pop_data.planet)}.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: {global.chapter_name} have been given a Bomb to seal the Necron Tomb on {_p_data.name()}.", mission_star.name); image = "necron_cave"; title = "New Equipment"; @@ -239,7 +240,7 @@ function init_mission_inquisition_tomb_world() { text = $"{global.chapter_name} have been provided with 1x Plasma Bomb in order to complete the mission."; if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty. {global.chapter_name} have been given a Plasma Bomb to seal the Necron Tomb on {mission_star.name} {scr_roman(pop_data.planet)}. It is expected to be completed within {pop_data.estimate} months."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty. {global.chapter_name} have been given a Plasma Bomb to seal the Necron Tomb on {_p_data.name()}. It is expected to be completed within {pop_data.estimate} months."; } reset_popup_options(); scr_add_item("Plasma Bomb", 1); @@ -247,7 +248,11 @@ function init_mission_inquisition_tomb_world() { if (demand) { demand = 0; } - add_new_inquis_mission(); + _p_data.new_problem("necron", estimate, {}); + if (add_new_problem(pop_data.planet, pop_data.mission, pop_data.estimate, mission_star)) { + new_star_event_marker("green"); + mission_is_go = true; + } exit; } @@ -314,14 +319,6 @@ function mission_inquistion_hunt_inquisitor(star_id = noone) { scr_popup("Inquisition Mission", text, "inquisition", _pop_data); } -/// @self Asset.GMObject.obj_popup -function add_new_inquis_mission() { - if (add_new_problem(pop_data.planet, pop_data.mission, pop_data.estimate, mission_star)) { - new_star_event_marker("green"); - mission_is_go = true; - } -} - /// @self Asset.GMObject.obj_popup function init_mission_hunt_inquisitor() { mission_star = find_star_by_name(pop_data.system); diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index b09d90f32e..0b32a8a506 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -284,7 +284,7 @@ function accept_mechanicus_tomb_mission() { } if (_planet > 0) { _planet = _star.get_planet_data(_planet); - _planet.add_problem("mech_tomb1", 17); + _planet.new_problem("mech_tomb1", 17); var _name = _planet.name(); text = $"The Adeptus Mechanicus await your forces at {_name}. They are expecting at least two squads of Astartes and have placed the testing on hold until their arrival. {global.chapter_name} have 16 months to arrive."; scr_event_log("", "Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", _star.name); @@ -309,7 +309,7 @@ function accept_mechanicus_land_raider_mission() { var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); - _planet.add_problem("mech_raider", _mission_time, {completion: 0, required_months: 24}); + _planet.new_problem("mech_raider", _mission_time, {completion: 0, required_months: 24}); text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting six {obj_ini.player_role_data[eROLE.TECHMARINE].role}s and a Land Raider."; scr_event_log("", $"Mechanicus Mission Accepted: Six of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s and a Land Raider are to be stationed at {_mission_loc} for {_mission_time} months.", _star.name); with (_star) { @@ -333,7 +333,7 @@ function accept_mechanicus_bionics_mission() { var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); - _planet.add_problem("mech_bionics", _mission_time, {completion: 0, required_months: 24}); + _planet.new_problem("mech_bionics", _mission_time, {completion: 0, required_months: 24}); text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting ten Astartes with bionics. (Beneficial traits: Weakness of Flesh )"; scr_event_log("", $"Mechanicus Mission Accepted: Ten Astartes with bionics are to be stationed at {_mission_loc} for 24 months for testing purposes.", _star.name); with (_star) { @@ -357,8 +357,8 @@ function accept_mechanicus_mars_mission() { var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); - _planet.add_problem("mech_bionics", _mission_time, {completion: 0, required_months: 24}); - _planet.add_problem("mech_mars", _mission_time); + _planet.new_problem("mech_bionics", _mission_time, {completion: 0, required_months: 24}); + _planet.new_problem("mech_mars", _mission_time); text = $"The Adeptus Mechanicus await your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s at {_mission_loc}. They are willing to hold on the voyage for up to {_mission_time} months."; scr_event_log("", $"Mechanicus Mission Accepted: {obj_ini.player_role_data[eROLE.TECHMARINE].role}s are expected at {_mission_loc} within 30 months, for the voyage to Mars.", _star.name); with (_star) { From d0bc8727a984350135a87d23dc9d0f783ae94004 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 13 Aug 2026 00:50:01 +0100 Subject: [PATCH 002/118] more missioin bitws --- scripts/MissionHelper/MissionHelper.gml | 26 +++++++++++++++---- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- .../scr_chaos_alliance_test.gml | 21 +++------------ .../scr_inquisition_mission.gml | 4 --- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index e986bccb13..a2be1c94b1 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -2,19 +2,35 @@ function MissionHelper() constructor{ } +function SystemProblem(name, timer, data) -function PlanetProblem(name, timer, data star, planet){ +function PlanetProblem(name, timer, data, planet){ timer = timer; p_id = name; data = data; - star = star; - planet = planet; + p_data = planet; + + static mark = fuction(colour){ + with (p_data.system){ + new_star_event_marker(colour) + } + } static __init(){ switch(p_id){ case "necron": - new_star_event_marker("green"); - mission_is_go = true; + mark("green"); + break; + case "meeting": + var rando = choose(1, 2); + i]f (rando == 1) { + obj_controller.diplo_text += $"A proposal that needs further consideration and some negotiation. Meet me at {p_data.name()} and we shall resolve this."; + } + if (rando == 2) { + obj_controller.diplo_text += $"Interesting. I shall be at {p_data.name()} and, if you are sincere, you will come to me and we can take this proposal to its logical conclusion."; + } + scr_event_log("", $"Chaos Lord {obj_controller.faction_leader[eFACTION.CHAOS]} agrees to meet with you on {p_data.name()} to discuss an alliance."); + mark("purple"); } } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 2237b5e0ef..8e3a05615a 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -775,7 +775,7 @@ function PlanetData(_planet, _system) constructor { }; static new_problem = function(p_id, timer = -1, data = {}, register = true){ - var _prob = new PlanetProblem(p_id, timer, data,system.name, planet); + var _prob = new PlanetProblem(p_id, timer, data, self); if (register){ register_problem(_prob) } diff --git a/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml b/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml index 4f38439a66..031bc06a89 100644 --- a/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml +++ b/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml @@ -93,24 +93,9 @@ function scr_chaos_alliance_test() { diplo_text = "[Error: No WL10 planet feature found.]"; } if (instance_exists(that_star)) { - var meeeting_arranged = false; - if (result == "success_trap") { - meeeting_arranged = add_new_problem(that_planet, "meeting_trap", 36, that_star); - } else { - meeeting_arranged = add_new_problem(that_planet, "meeting", 36, that_star); - } - if (meeeting_arranged) { - var rando, new_event; - rando = choose(1, 2); - if (rando == 1) { - diplo_text += "A proposal that needs further consideration and some negotiation. Meet me at " + string(that_title) + " and we shall resolve this."; - } - if (rando == 2) { - diplo_text += "Interesting. I shall be at " + string(that_title) + " and, if you are sincere, you will come to me and we can take this proposal to its logical conclusion."; - } - scr_event_log("", "Chaos Lord " + string(obj_controller.faction_leader[eFACTION.CHAOS]) + " agrees to meet with you on " + string(that_title) + " to discuss an alliance."); - new_star_event_marker("purple"); - } + var meeting_arranged = false; + var _p_data = that_star.get_planet_data(that_planet); + _p_data.new_problem(result == "success_trap" ? "meeting_trap" : "meeting", 36); } } if (result == "fail") { diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index c3d68fe415..55fe718d7c 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -249,10 +249,6 @@ function init_mission_inquisition_tomb_world() { demand = 0; } _p_data.new_problem("necron", estimate, {}); - if (add_new_problem(pop_data.planet, pop_data.mission, pop_data.estimate, mission_star)) { - new_star_event_marker("green"); - mission_is_go = true; - } exit; } From ac05a833c40856ea800040eb6649a99507189ff6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 16 Sep 2026 00:49:01 +0100 Subject: [PATCH 003/118] continuation of OOP missions --- objects/obj_star/Draw_0.gml | 3 - scripts/MissionHelper/MissionHelper.gml | 423 ++++++++++++++++-- scripts/scr_PlanetData/scr_PlanetData.gml | 12 + .../scr_destroy_planet/scr_destroy_planet.gml | 4 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 31 +- .../scr_mission_functions.gml | 380 +--------------- .../scr_unit_quick_find_pane.gml | 4 +- 7 files changed, 416 insertions(+), 441 deletions(-) diff --git a/objects/obj_star/Draw_0.gml b/objects/obj_star/Draw_0.gml index a2d2ecc8cc..1bb574fcfe 100644 --- a/objects/obj_star/Draw_0.gml +++ b/objects/obj_star/Draw_0.gml @@ -9,9 +9,6 @@ if ((p_type[1] == "Craftworld") && (obj_controller.known[eFACTION.ELDAR] == 0)) 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]); -} scale = min(camera_get_view_width(view_camera[0]) / global.default_view_width, 2.4); draw_set_color(c_white); draw_set_alpha(0.25); diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index a2be1c94b1..6c4d479011 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -2,37 +2,410 @@ function MissionHelper() constructor{ } -function SystemProblem(name, timer, data) +function SystemProblem(name, timer, data){} -function PlanetProblem(name, timer, data, planet){ - timer = timer; - p_id = name; - data = data; - p_data = planet; +function PlanetProblem(name, timer, data, planet) constructor{ +timer = timer; +uid = scr_uuid_generate(); +p_id = name; +data = data; +p_data = planet; +planet = p_data.planet; +system = p_data.system; +static refresh_p_data = function(){ + p_data = system.get_planet_data(planet); +} +stage_id = ""; +extend_timer_for_warp_storm = true; - static mark = fuction(colour){ - with (p_data.system){ - new_star_event_marker(colour) - } +static basic_turn_end = function(){ + refresh_p_data(); + if (p_data.system.storm - 1 > 0){ + timer--; } - - static __init(){ + if (timer == 0){ + var _func = undefined; switch(p_id){ + case "hunt_beast": + _func = resolve_hunt_beast; + break; + case "train_forces": + _func = resolve_train_forces; + break; + case "succession": + _func = resolve_succession; + break; + case "recon": + _func = resolve_recon; + break; + case "great_crusade": + _func = resolve_great_crusade; + break; case "necron": - mark("green"); - break; - case "meeting": - var rando = choose(1, 2); - i]f (rando == 1) { - obj_controller.diplo_text += $"A proposal that needs further consideration and some negotiation. Meet me at {p_data.name()} and we shall resolve this."; - } - if (rando == 2) { - obj_controller.diplo_text += $"Interesting. I shall be at {p_data.name()} and, if you are sincere, you will come to me and we can take this proposal to its logical conclusion."; - } - scr_event_log("", $"Chaos Lord {obj_controller.faction_leader[eFACTION.CHAOS]} agrees to meet with you on {p_data.name()} to discuss an alliance."); - mark("purple"); + _func = resolve_necron; + break; + case "spyrer": + _func = resolve_spyrer; + break; + case "fallen": + _func = resolve_fallen; + break; } + if (!is_undefined(_func)){ + try { + _func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + } +} + +static mark = function(colour){ + refresh_p_data(); + with (p_data.system){ + new_star_event_marker(colour) + } +} + +static description = function(){ + return mission_name_key(p_id); +} + +static __init(){ + switch(p_id){ + case "necron": + mark("green"); + break; + case "meeting": + var rando = choose(1, 2); + if (rando == 1) { + obj_controller.diplo_text += $"A proposal that needs further consideration and some negotiation. Meet me at {p_data.name()} and we shall resolve this."; + } + if (rando == 2) { + obj_controller.diplo_text += $"Interesting. I shall be at {p_data.name()} and, if you are sincere, you will come to me and we can take this proposal to its logical conclusion."; + } + scr_event_log("", $"Chaos Lord {obj_controller.faction_leader[eFACTION.CHAOS]} agrees to meet with you on {p_data.name()} to discuss an alliance."); + mark("purple"); + break; + case "fallen": + break; + } +} +__init(); + +static complete_beast_hunt_mission = function() { + refresh_p_data(); + var _hunters = collect_role_group("all", [system.name, planet, 0], false, man_conditions); + if (stage_id == "active") { + var _mission_string = ""; + var man_conditions = { + "job": "hunt_beast", + "max": 3, + }; + var _success = false; + var _tester = global.character_tester; + var _unit_pass; + var _unit; + var _unit_report_string = ""; + var _deaths = 0; + var _successful_hunters = []; + + if (!array_length(_hunters)) { + return; + } + + for (var i = 0; i < array_length(_hunters); i++) { + _unit = _hunters[i]; + _unit_pass = _tester.standard_test(_unit, "weapon_skill", 10, ["beast"]); + if (_unit_pass[0]) { + if (!_success) { + _success = true; + } + _unit_report_string += _unit.add_trait("beast_slayer", true, true); + array_push(_successful_hunters, _unit); + } else { + var _tough_check = _tester.standard_test(_unit, "constitution", _unit.luck); + if (!_tough_check[0]) { + if (_tough_check[1] < -10) { + _unit_report_string += $"{_unit.name_role()} Was mauled to death\n"; + _unit.kill(true, false); + _deaths++; + } else { + if (irandom(100) < _unit.luck) { + _unit.add_or_sub_health(-100); + _unit_report_string += $"{_unit.name_role()} Was injured (health - 100)\n"; + } else { + _unit.add_or_sub_health(-250); + _unit_report_string += $"{_unit.name_role()} Was Badly injured, it is unknown if he will recover (health - 250)\n"; + } + } + } + } + _unit.job = "none"; + } + + 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 {p_data.name()}", _mission_string, "", ""); + } + for (var i = 0; i < array_length(_hunters); i++) { + _hunters[i].job = "none"; + } +} + +static complete_train_forces_mission = function() { + refresh_p_data(); + if (stage_id == "active") { + var man_conditions = { + "job": "train_forces", + "max": 1, + }; + var _mission_string = ""; + var _trainer = collect_role_group("all", [system.name, 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) { + _wis_test_difficulty += 10; + if (p_data.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + var _cult = p_data.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; + if (_cult.hiding) { + p_data.delete_feature(eP_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; + } + var _brute = _trainer.has_trait("brute"); + if (_brute) { + _wis_test_difficulty -= 10; + } + + var _leader = _trainer.has_trait("natural_leader"); + if (_leader) { + _wis_test_difficulty += 10; + } + + var _unit_pass = _tester.standard_test(_trainer, "wisdom", _wis_test_difficulty); + if (_unit_pass[0]) { + var _new_pdf = p_data.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) { + var _disp_gain = 10; + p_data.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})"; + } + 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)"; + p_data.alter_fortification(1); + } else { + 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"; + _mission_string += "The new insights have allowed for minor improvements to planetary fortifications (fortification +1)"; + p_data.alter_fortification(1); + } + } + } else { + var 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 += "."; + + _mission_string += "He failed to work effectively with the existing chain of command"; - __init(); + 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])) { + _hard_loss = true; + } + } + if (_hard_loss) { + _mission_string += $"His particularly grueling regimes and standards imposed upon the senior officers of the pdf caused friction with physical injury being caused to one officer"; + disp_loss = -25; + _mission_string += "(disposition -25)"; + } + } + p_data.add_disposition(disp_loss); + } + _mission_string += $"\n{_unit_report_string}"; + scr_popup($"Training Forces on {p_data.name()}", _mission_string, "", ""); + } + _trainer.job = "none"; + } +} + +static resolve_succession = function() { + refresh_p_data(); + var _result, _alert_text; + var _dice1 = roll_dice(1, 100); + var _dice2 = roll_dice(1, 100); + + _result = eFACTION.IMPERIUM; + _alert_text = ""; + if (_dice1 <= (p_data.corruption * 2)) { + _result = eFACTION.CHAOS; + } + if (_dice2 <= (p_data.population_influences[eFACTION.TAU] * 2)) { + _result = eFACTION.TAU; + } + + if (p_data.current_owner == eFACTION.IMPERIUM && _result != eFACTION.IMPERIUM) { + p_data.edit_pdf(p_data.guardsmen); + p_data.edit_guardsmen(-p_data.guardsmen); + p_data.set_new_owner(_result); + } + + _alert_text = $"War of Succession on {p_data.name()} has ended"; + + if (_result == eFACTION.CHAOS) { + _alert_text += " with Chaos in control."; + p_data.set_player_disposition(0); + scr_alert("red", "succession", _alert_text, p_data.system.x, p_data.system.y); + scr_event_log("purple", _alert_text); + } else if (_result == eFACTION.TAU) { + _alert_text += " with a Tau sympathizer in control."; + p_data.set_player_disposition(10 + choose(1, 2, 3, 4, 5, 6)); + p_data.add_forces(eFACTION.TAU, 2); + scr_alert("red", "succession", _alert_text, p_data.system.x, p_data.system.y); + scr_event_log("red", _alert_text); + } else if (_result == eFACTION.IMPERIUM) { + _alert_text += " The resultant governor is the most staunch pillar of the imperium."; + _alert_text += "."; + scr_alert("green", "succession", _alert_text, p_data.system.x, p_data.system.y); + scr_event_log("", _alert_text); + } else { + //At the moment does not fire but a worty flavour option for down the line + _alert_text += " Word is the new Governor has Heretical leanings and sympathises with xenos."; + } + + p_data.delete_feature(eP_FEATURES.SUCCESSION_WAR); +} + +static resolve_recon = function() { + refresh_p_data(); + var _alert_text = "Inquisition Mission Failed: Investigate "; + alter_disposition(eFACTION.INQUISITION, -5); + _alert_text += $"{p_data.name()}."; + scr_alert("red", "mission_failed", _alert_text, 0, 0); + scr_event_log("red", _alert_text); +} + +static resolve_great_crusade = function() { + refresh_p_data(); + var _crusade_direction; + var _join_crusade = false; + var _player_fleet = instance_nearest(p_data.system.x, p_data.system.y, obj_p_fleet); + + if (_player_fleet.action == "") { + if (point_distance(p_data.system.x, p_data.system.y, _player_fleet.x, _player_fleet.y) < 10) { + _join_crusade = true; + } + } + + if (_join_crusade) { + _crusade_direction = point_direction(room_width / 2, room_height / 2, p_data.system.x, p_data.system.y); + with (_player_fleet) { + action_x = x + lengthdir_x(1200, _crusade_direction); + action_y = y + lengthdir_y(1200, _crusade_direction); + set_fleet_movement(false, "crusade1"); + } + + scr_alert("green", "crusade", "Fleet embarks upon Crusade.", p_data.system.x, p_data.system.y); + scr_event_log("", "Fleet embarks upon Crusade."); + } else { + // hit loyalty here + alter_dispositions([[eFACTION.INQUISITION, -10], [eFACTION.IMPERIUM, -5]]); + var _string = $"No ships designated for Crusade."; + if (obj_controller.penitent == 1) { + obj_controller.penitent_current = 0; + _string += "Your penitence crusade has been lengthened for your failings"; + } + + scr_alert("red", "crusade", _string, p_data.system.x, p_data.system.y); + scr_loyalty("Refusing to Crusade", "+"); + scr_event_log("red", "No ships designated for Crusade."); + } +} + +static resolve_necron = function() { + refresh_p_data(); + alter_disposition(eFACTION.INQUISITION, -8); + var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; + scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); + scr_event_log("red", $"Inquisition Mission Failed: Bombing run failed; the Necron Tomb on {p_data.name()} has become active."); + + p_data.add_forces(eFACTION.NECRONS, 4); + if (awake_tomb_world(p_data.features) == 0) { + awaken_tomb_world(p_data.features); + } +} + +static resolve_spyrer = function() { + refresh_p_data(); + var _planet_name = p_data.name(); + alter_disposition(eFACTION.INQUISITION, -3); + var _alert_text = $"The Spyrer on {_planet_name} has been left unchecked. In the ensuing carnage some high-ranking officials have been killed, along with several Nobles. Panic is running amock in several parts of the hives and the Inquisition is less than pleased."; + var _text = "Inquisition Mission Failed: The Spyrer on {_planet_name} was not removed."; + scr_popup("Inquisition Mission Failed", _alert_text, "spyrer", ""); + scr_event_log("red", _text); +} + +static resolve_fallen = function() { + //TODO marker point for cohesion mechanics + refresh_p_data(); + var _alert_text = ""; + if (irandom(100) > 33) { + // Give all marines +3d6 corruption and reduce loyalty by 20*/ + for (var _co = 0; _co <= obj_ini.companies; _co++) { + for (var _me = 0; _me < company_length(_co); _me++) { + var _unit = fetch_unit([_co, _me]); + if (_unit.base_group != "astartes") { + continue; + } + _unit.edit_corruption(irandom_range(3, 6)); + _unit.alter_loyalty(-10); + } + } + } + _alert_text = $"Any Fallen that may have been on {p_data.name()} "; + _alert_text += "have been given sufficient time to escape. Morale within your chapter has plummeted; some of your battle brothers have become restless and speak among eachother in hushed tones."; + scr_popup("Hunt the Fallen Failed", _alert_text + "\n\n(Chapter wide loyalty: -10)\nChaplains note marked changes in behaviour of some brothers", "fallen", ""); + obj_controller.loyalty -= 10; + obj_controller.loyalty_hidden -= 10; + scr_event_log("red", $"Mission Failed: Any Fallen within the {system.name} system have been given time to escape."); +} } \ No newline at end of file diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index e8e24e5fdc..7efb59ec29 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -787,6 +787,18 @@ function PlanetData(_planet, _system) constructor { problems = system.p_problem[planet]; } + + function problem_count_down(planet, count_change = 1) { + for (var i = array_length(problems) -1; i >= 0; i--) { + var _problem = problems[i]; + _problem.basic_turn_end(); + if (problem.timer == -1){ + array_delete(system.p_problem[i], i,0); + array_delete(problems, i,0); + } + } + } + static name = function() { return planet_numeral_name(planet, system); }; diff --git a/scripts/scr_destroy_planet/scr_destroy_planet.gml b/scripts/scr_destroy_planet/scr_destroy_planet.gml index 2a67d8c8c1..deec228c02 100644 --- a/scripts/scr_destroy_planet/scr_destroy_planet.gml +++ b/scripts/scr_destroy_planet/scr_destroy_planet.gml @@ -164,9 +164,7 @@ function scr_destroy_planet(destruction_method) { p_sisters[baid] = 0; p_necrons[baid] = 0; // - p_problem[baid] = array_create(8, ""); - p_timer[baid] = array_create(8, 0); - p_problem_other_data[baid] = array_create(8, {}); + p_problem[baid] = []; } pip.text += ", scouring all life across the planet. It has been rendered a barren, lifeless chunk of rock."; 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 d9847cc0e5..6f0dccef68 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -21,10 +21,6 @@ function scr_enemy_ai_d() { } var wob = 0; - var fallen = find_problem_planet(i, "fallen"); - if (fallen > -1 && storm - 1 > 0) { - p_timer[i][fallen]++; - } // Requesting help here if (((p_halp[i] == 1) || (p_halp[i] == 1.1)) && (p_population[i] > 0) && (p_owner[i] <= eFACTION.ECCLESIARCHY)) { @@ -85,36 +81,15 @@ function scr_enemy_ai_d() { } } for (var i = 1; i <= planets; i++) { - problem_count_down(i); - if (planet_problemless(i)) { + if (array_length(p_problems[i]) == 0){ continue; } + problem_count_down(i); var _pdata = get_planet_data(i); - with (_pdata) { - problem_end_turn_checks(); - } mechanicus_missions_end_turn(i); - var _beast_hunt = has_problem_planet_and_time(i, "hunt_beast", 0); - if (_beast_hunt > -1) { - try { - complete_beast_hunt_mission(i, _beast_hunt); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } - - var train_forces = has_problem_planet_and_time(i, "train_forces", 0); - if (train_forces > -1) { - try { - complete_train_forces_mission(i, train_forces); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } - if (((p_tyranids[i] == 3) || (p_tyranids[i] == 4)) && (p_population[i] > 0)) { if (!has_problem_planet(i, "Hive Fleet")) { var roll = irandom_range(100, 300); @@ -186,7 +161,7 @@ function scr_enemy_ai_d() { if (storm > 0) { storm -= 1; if (storm == 0) { - var tr = "Warp Storms over " + string(name) + " dissipate."; + var tr = $"Warp Storms over {name} dissipate."; scr_alert("green", "Warp", tr, x, y); scr_event_log("green", tr); } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 2c675f797f..ac6c7964dd 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -42,7 +42,7 @@ global.planet_problem_keys = [ ]; function mission_name_key(mission) { - var mission_key = { + static mission_key = { "meeting_trap": "Chaos Lord Meeting", "meeting": "Chaos Lord Meeting", "succession": "War of succession", @@ -83,181 +83,7 @@ function mission_name_key(mission) { /// @self Struct.PlanetData function problem_end_turn_checks() { - /// @self Struct.PlanetData - static problem_functions = { - "succession": function(problem_index) { - if (problem_timers[problem_index] > 0) { - return; - } - var result, _alert_text; - var dice1 = roll_dice(1, 100); - var dice2 = roll_dice(1, 100); - - result = eFACTION.IMPERIUM; - _alert_text = ""; - if (dice1 <= (corruption * 2)) { - result = eFACTION.CHAOS; - } - if (dice2 <= (population_influences[eFACTION.TAU] * 2)) { - result = eFACTION.TAU; - } - - if (current_owner == eFACTION.IMPERIUM && result != eFACTION.IMPERIUM) { - edit_pdf(guardsmen); - edit_guardsmen(-guardsmen); - set_new_owner(result); - } - - _alert_text = $"War of Succession on {name()} has ended"; - - if (result == eFACTION.CHAOS) { - _alert_text += " with Chaos in control."; - set_player_disposition(0); - scr_alert("red", "succession", _alert_text, x, y); - scr_event_log("purple", _alert_text); - } else if (result == eFACTION.TAU) { - _alert_text += " with a Tau sympathizer in control."; - set_player_disposition(10 + choose(1, 2, 3, 4, 5, 6)); - add_forces(eFACTION.TAU, 2); - scr_alert("red", "succession", _alert_text, x, y); - scr_event_log("red", _alert_text); - } else if (result == eFACTION.IMPERIUM) { - _alert_text += " The resultant governor is the most staunch pillar of the imperium."; - _alert_text += "."; - scr_alert("green", "succession", _alert_text, x, y); - scr_event_log("", _alert_text); - } else { - //At the moment does not fire but a worty flavour option for down the line - _alert_text += " Word is the new Governor has Heretical leanings and sympathises with xenos."; - } - - delete_feature(eP_FEATURES.SUCCESSION_WAR); - remove_problem("succession"); - }, - "recon": function(problem_index) { - if (problem_timers[problem_index] > 0) { - return; - } - var _alert_text = "Inquisition Mission Failed: Investigate "; - alter_disposition(eFACTION.INQUISITION, -5); - _alert_text += $"{name()}."; - scr_alert("red", "mission_failed", _alert_text, 0, 0); - scr_event_log("red", _alert_text); - remove_problem("recon"); - }, - "great_crusade": function(problem_index) { - if (problem_timers[problem_index] > 0) { - return; - } - var _crusade_direction; - var _join_crusade = false; - var _player_fleet = instance_nearest(system.x, system.y, obj_p_fleet); - if (_player_fleet.action == "") { - if (point_distance(system.x, system.y, _player_fleet.x, _player_fleet.y) < 10) { - _join_crusade = true; - } - } - - if (_join_crusade) { - _crusade_direction = point_direction(room_width / 2, room_height / 2, x, y); - with (_player_fleet) { - action_x = x + lengthdir_x(1200, _crusade_direction); - action_y = y + lengthdir_y(1200, _crusade_direction); - set_fleet_movement(false, "crusade1"); - } - - scr_alert("green", "crusade", "Fleet embarks upon Crusade.", x, y); - scr_event_log("", "Fleet embarks upon Crusade."); - } else { - // hit loyalty here - alter_dispositions([[eFACTION.INQUISITION, -10], [eFACTION.IMPERIUM, -5]]); - var _string = $"No ships designated for Crusade."; - if (obj_controller.penitent == 1) { - obj_controller.penitent_current = 0; - _string += "Your penitence crusade has been lengthened for your failings"; - } - - scr_alert("red", "crusade", _string, system.x, system.y); - scr_loyalty("Refusing to Crusade", "+"); - scr_event_log("red", "No ships designated for Crusade."); - } - remove_problem("great_crusade"); - }, - "necron": function(problem_index) { - if (problem_timers[problem_index] > 0) { - return; - } - - alter_disposition(eFACTION.INQUISITION, -8); - var _alert_text = $"The Necron Tomb of planet {name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; - scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); - scr_event_log("red", $"Inquisition Mission Failed: Bombing run failed; the Necron Tomb on {name()} has become active."); - - add_forces(eFACTION.NECRONS, 4); - if (awake_tomb_world(features) == 0) { - awaken_tomb_world(features); - } - remove_problem("necron"); - }, - "spyrer": function(problem_index) { - if (problem_timers[problem_index] > 0) { - return; - } - var _planet_name = name(); - alter_disposition(eFACTION.INQUISITION, -3); - var _alert_text = $"The Spyrer on {_planet_name} has been left unchecked. In the ensuing carnage some high-ranking officials have been killed, along with several Nobles. Panic is running amock in several parts of the hives and the Inquisition is less than pleased."; - var _text = "Inquisition Mission Failed: The Spyrer on {_planet_name} was not removed."; - scr_popup("Inquisition Mission Failed", _alert_text, "spyrer", ""); - scr_event_log("red", _text); - remove_problem("spyrer"); - }, - "fallen": function(problem_index) { - //TODO marker point for cohesion mechanics - if (problem_timers[problem_index] > 0) { - return; - } - var alert_text = ""; - if (irandom(100) > 33) { - // Give all marines +3d6 corruption and reduce loyalty by 20*/ - for (var co = 0; co <= obj_ini.companies; co++) { - for (var me = 0; me < company_length(co); me++) { - var _unit = fetch_unit([co, me]); - if (_unit.base_group != "astartes") { - continue; - } - _unit.edit_corruption(irandom_range(3, 6)); - _unit.alter_loyalty(-10); - } - } - } - alert_text = $"Any Fallen that may have been on {name()} "; - alert_text += "have been given sufficient time to escape. Morale within your chapter has plummeted; some of your battle brothers have become restless and speak among eachother in hushed tones."; - scr_popup("Hunt the Fallen Failed", alert_text + "\n\n(Chapter wide loyalty: -10)\nChaplains note marked changes in behaviour of some brothers", "fallen", ""); - obj_controller.loyalty -= 10; - obj_controller.loyalty_hidden -= 10; - remove_problem("fallen"); - scr_event_log("red", $"Mission Failed: Any Fallen within the {system.name} system have been given time to escape."); - }, - "provide_garrison": complete_garrison_mission, - }; - - for (var i = 0; i < array_length(problems); i++) { - var _problem = problems[i]; - if (_problem == "") { - continue; - } - - if (struct_exists(problem_functions, _problem)) { - try { - var _problem_action = method(self, problem_functions[$ _problem]); - _problem_action(i); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } - } -} /// @self Asset.GMObject.obj_star function scr_new_governor_mission(planet, problem = "") { @@ -579,178 +405,6 @@ function complete_garrison_mission(problem_index) { remove_problem("provide_garrison"); } -function complete_train_forces_mission(targ_planet, problem_index) { - var planet = get_planet_data(targ_planet); - if (problem_has_key_and_value(targ_planet, problem_index, "stage", "active")) { - var man_conditions = { - "job": "train_forces", - "max": 1, - }; - var _mission_string = ""; - var _trainer = collect_role_group("all", [planet.system.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) { - _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); - _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; - } - var _brute = _trainer.has_trait("brute"); - if (_brute) { - _wis_test_difficulty -= 10; - } - - var _leader = _trainer.has_trait("natural_leader"); - if (_leader) { - _wis_test_difficulty += 10; - } - - var _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) { - 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})"; - } - 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) { - _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"; - _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 += "."; - - _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])) { - _hard_loss = true; - } - } - if (_hard_loss) { - _mission_string += $"His particularly grueling regimes and standards imposed upon the senior officers of the pdf caused friction with physical injury being caused to one officer"; - disp_loss = -25; - _mission_string += "(disposition -25)"; - } - } - planet.add_disposition(disp_loss); - } - _mission_string += $"\n{_unit_report_string}"; - scr_popup($"Training Forces on {planet.name()}", _mission_string, "", ""); - remove_planet_problem(targ_planet, "train_forces"); - _trainer.job = "none"; - } - } -} - -function complete_beast_hunt_mission(targ_planet, problem_index) { - var planet = get_planet_data(targ_planet); - if (problem_has_key_and_value(targ_planet, problem_index, "stage", "active")) { - var _mission_string = ""; - var man_conditions = { - "job": "hunt_beast", - "max": 3, - }; - var _hunters = collect_role_group("all", [planet.system.name, targ_planet, 0], false, man_conditions); - var _success = false; - var _tester = global.character_tester; - var _unit_pass; - var _unit; - var _unit_report_string = ""; - var _deaths = 0; - var _successful_hunters = []; - if (!array_length(_hunters)) { - remove_planet_problem(targ_planet, "hunt_beast"); - return; - } - for (var i = 0; i < array_length(_hunters); i++) { - _unit = _hunters[i]; - _unit_pass = _tester.standard_test(_unit, "weapon_skill", 10, ["beast"]); - if (_unit_pass[0]) { - if (!_success) { - _success = true; - } - } - if (_unit_pass[0]) { - _unit_report_string += _unit.add_trait("beast_slayer", true, true); - array_push(_successful_hunters, _unit); - } else { - var _tough_check = _tester.standard_test(_unit, "constitution", _unit.luck); - if (!_tough_check[0]) { - if (_tough_check[1] < -10) { - _unit_report_string += $"{_unit.name_role()} Was mauled to death\n"; - _unit.kill(true, false); - _deaths++; - } 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 { - _unit.add_or_sub_health(-250); - _unit_report_string += $"{_unit.name_role()} Was Badly injured, it is unknown if he will recover (health - 250)\n"; - } - } - } - } - _unit.job = "none"; - } - 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, id)}", _mission_string, "", ""); - remove_planet_problem(targ_planet, "hunt_beast"); - } else { - remove_planet_problem(targ_planet, "hunt_beast"); - } -} //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 @@ -770,24 +424,6 @@ function has_any_problem_planet(planet, star = noone) { return false; } -/// @self Asset.GMObject.obj_star -function planet_problemless(planet, star = noone) { - var _problemless = true; - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] != "") { - _problemless = false; - break; - } - } - } else { - with (star) { - _problemless = planet_problemless(planet); - } - } - return _problemless; -} - // returns a bool for if any planet on a given star has the given problem /// @self Asset.GMObject.obj_star function has_problem_star(problem, star = noone) { @@ -929,20 +565,6 @@ function remove_star_problem(problem, star = noone) { } } -//count donw the p_timer on a given planet -/// @self Asset.GMObject.obj_star -function problem_count_down(planet, count_change = 1) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] != "") { - p_timer[planet][i] -= count_change; - if (p_timer[planet][i] == -5) { - p_problem[planet][i] = ""; - p_timer[planet][i] = -1; - } - } - } -} - //add a new problem /// @self Asset.GMObject.obj_star function add_new_problem(planet, problem, timer, star = noone, other_data = {}) { diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index 27423acb34..4be6081539 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -265,9 +265,7 @@ function UnitQuickFindPanel() constructor { for (var i = 1; i <= planets; i++) { var problems = p_problem[i]; for (var p = 0; p < array_length(problems); p++) { - if (problems[p] == "") { - continue; - } + var _problem = problems[p]; if (problem_has_key_and_value(i, p, "stage", "preliminary")) { continue; } From 73f1d834d231a5cfd51121b7305036b23383b064 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 17 Sep 2026 15:45:18 +0100 Subject: [PATCH 004/118] majority of port done --- scripts/MissionHelper/MissionHelper.gml | 210 +++++++++++++++++- scripts/scr_PlanetData/scr_PlanetData.gml | 2 - scripts/scr_after_combat/scr_after_combat.gml | 2 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 - .../scr_mechanicus_missions.gml | 143 +----------- .../scr_mission_functions.gml | 21 +- .../scr_unit_quick_find_pane.gml | 5 +- 7 files changed, 218 insertions(+), 167 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 6c4d479011..fceebc4e41 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -16,21 +16,56 @@ static refresh_p_data = function(){ p_data = system.get_planet_data(planet); } stage_id = ""; +if (struct_exists(data, "stage")){ + stage_id = data.stage; +} extend_timer_for_warp_storm = true; +remove = false; +zero_timer_checks = true; +per_turn_checks = true; static basic_turn_end = function(){ refresh_p_data(); if (p_data.system.storm - 1 > 0){ timer--; } - if (timer == 0){ + if ((timer > -1) && per_turn_checks) { + var _func = undefined; + switch(p_id){ + case "mech_raider"; + _func = per_turn_check_raider_failed; + break; + case "mech_bionics": + _func = per_turn_check_mech_bionics; + break; + case "mech_bionics": + switch(stage_id): + break; + case "exploring": + _func = per_turn_check_mech_tomb2; + break; + case "awaiting_player"; + default: + _func = per_turn_check_mech_tomb1; + break; + } + if (!is_undefined(_func)){ + try { + _func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + + } + if ((timer == 0) && zero_timer_checks) { var _func = undefined; switch(p_id){ case "hunt_beast": _func = resolve_hunt_beast; break; case "train_forces": - _func = resolve_train_forces; + _func = complete_train_forces_mission; break; case "succession": _func = resolve_succession; @@ -50,6 +85,17 @@ static basic_turn_end = function(){ case "fallen": _func = resolve_fallen; break; + case "mech_raider"; + _func = resolve_mech_raider_failed; + break; + case "mech_bionics": + _func = resolve_mech_bionics; + break; + case "mech_tomb"; + _func = resolve_mech_tomb1_failed; + break; + case "mech_mars": + _func = resolve_mech_mars; } if (!is_undefined(_func)){ try { @@ -72,6 +118,18 @@ static description = function(){ return mission_name_key(p_id); } +static increment_mission_completion = function() { + if (!struct_exists(data, "completion")) { + data.completion = 0; + } + data.completion++; + if (!struct_exists(data, "required_months") || data.required_months <= 0) { + LOGGER.error("Invalid required_months in mission_data"); + return 0; + } + return (data.completion / data.required_months) * 100; +} + static __init(){ switch(p_id){ case "necron": @@ -408,4 +466,152 @@ static resolve_fallen = function() { obj_controller.loyalty_hidden -= 10; scr_event_log("red", $"Mission Failed: Any Fallen within the {system.name} system have been given time to escape."); } + +static per_turn_check_mech_raider = function() { + refresh_p_data(); + var _techs = collect_role_group(SPECIALISTS_TECHS, [system.name, planet, -1]); + var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); + if ((array_length(_techs) >= 6) && (_lr_count >= 1)) { + var _percent_complete = increment_mission_completion(data); + scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); + if (_percent_complete >= 100) { + p_data.remove_problem(p_id); + scr_mission_reward("mech_raider", id, planet); + timer = -1 + per_turn_checks = false; + zero_timer_checks = false; + } + } +} + +static resolve_mech_raider_failed = function() { + refresh_p_data(); + var _alert_text = $"Mechanicus Mission Failed: Land Raider testing at {p_data.name()}."; + scr_alert("red", "mission_failed", _alert_text, 0, 0); + scr_event_log("red", _alert_text); + p_data.alter_disposition(eFACTION.MECHANICUS, -6); + p_data.remove_problem(p_id); +} + +static per_turn_check_mech_bionics = function() { + refresh_p_data(); + var _units = p_data.collect_planet_group(); + var _bionics = _units.tally_attr("bionics"); + if (_bionics >= 10) { + var _percent_complete = increment_mission_completion(data); + scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); + if (_percent_complete >= 100) { + p_data.remove_problem(p_id); + scr_mission_reward("mech_bionics", id, planet); + timer = -1 + per_turn_checks = false; + zero_timer_checks = false; + } + } +} + +static resolve_mech_bionics_failed = function() { + refresh_p_data(); + var _alert_text = $"Mechanicus Mission Failed: bionics testing at {p_data.name()}."; + scr_alert("red", "mission_failed", _alert_text, 0, 0); + scr_event_log("red", _alert_text); + p_data.alter_disposition(eFACTION.MECHANICUS, -6); + p_data.remove_problem(p_id); +} + +static per_turn_check_mech_tomb2 = function() { + refresh_p_data(); + data.turns++; + var _battli = 0; + var _roll1 = roll_dice_chapter(1, 100 + data.turns, "low"); + + if (_roll1 > 98) { + if ((_roll1 >= 90) && (_roll1 < 98)) { + _battli = 1; + } // oops + if (_roll1 >= 98) { + _battli = 2; + } // very oops, much necron, wow + + if ((_battli > 0) && (p_player[planet] > 0)) { + // Queue the battle + obj_turn_end.battles += 1; + obj_turn_end.battle[obj_turn_end.battles] = 1; + obj_turn_end.battle_world[obj_turn_end.battles] = planet; + obj_turn_end.battle_opponent[obj_turn_end.battles] = 13; + obj_turn_end.battle_location[obj_turn_end.battles] = p_data.name(); + obj_turn_end.battle_object[obj_turn_end.battles] = id; + if (_battli == 1) { + obj_turn_end.battle_special[obj_turn_end.battles] = "study2a"; + } + if (_battli == 2) { + obj_turn_end.battle_special[obj_turn_end.battles] = "study2b"; + } + + if (obj_turn_end.battle_opponent[obj_turn_end.battles] == 11) { + if (planet_feature_bool(p_feature[planet], eP_FEATURES.CHAOSWARBAND) == 1) { + obj_turn_end.battle_special[obj_turn_end.battles] = "ChaosWarband"; + } + } + } + if ((_battli > 0) && (p_player[planet] <= 0)) { + // XDDDDD + scr_popup("Mechanicus Mission Failed", $"The Mechanicus Research team on planet {p_data.name()} have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); + obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); + alter_disposition(eFACTION.MECHANICUS, -25); + p_data.remove_problem(p_id); + } + } else { + if (_roll1 > 20) { + scr_alert("", "mission", $"Adeptus Mechanicus research within the Necron Tomb of {p_data.name()} continues.", 0, 0); + } else if (_roll1 <= 20) { + var _text, _reward = choose(1, 1, 2); + if (scr_has_adv("Tech-Brothers")) { + _reward = choose(1, 2); + } + + if (_reward == 1) { + obj_controller.requisition += 400; + _text = $"The Mechanicus Research team on planet {p_data.name()} have completed their work without any major setbacks. Pleased with your astartes' work, they have granted you 400 Requisition to be used as you see fit."; + scr_event_log("", $"Mechanicus Mission Completed: The Mechanicus research team on {p_data.name()} have completed their work."); + } else if (_reward == 2) { + var _last_artifact = scr_add_artifact("random", "", 0); + _text = $"The Mechanicus Research team on planet {p_data.name()} have completed their work without any major setbacks. Pleased with your astartes' work, they have granted your Chapter an artifact, to be used as you see fit."; + scr_event_log("", $"Mechanicus Mission Completed: The Mechanicus research team on {p_data.name()} have completed their work."); + scr_event_log("", "Artifact gifted from Mechanicus."); + } + _text += "\n" + add_disposition(eFACTION.MECHANICUS, 1); + scr_popup("Mechanicus Mission Completed", _text, "mechanicus", ""); + p_data.remove_problem(p_id); + timer = -1 + per_turn_checks = false; + zero_timer_checks = false; + } + } +} + +static per_turn_check_mech_tomb1 = function() { + refresh_p_data(); + var _marines = collect_role_group("all", [system.name, planet, -1]); + if (array_length(_marines) >= 20) { + stage_id = "exploring"; + timer = 999; + data.turns : 0; + scr_popup("Mechanicus Research", $"The Mechanicus Research team on planet {p_data.name()} has taken note of your Astartes and are now prepared to begin their research. Your marines are to stay on the planet until further notice.", "necron_cave", ""); + } +} + +static resolve_mech_tomb1_failed = function() { + refresh_p_data(); + var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; + scr_alert("red", "mission_failed", _alert_text, 0, 0); + scr_event_log("red", _alert_text, system.name); + p_data.alter_disposition(eFACTION.MECHANICUS, -15); + p_data.remove_problem(p_id); +} + +static resolve_mech_mars = function() { + refresh_p_data(); + mechanicus_mars_mission_target_time_elapsed(planet); +} } \ No newline at end of file diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 7c7452b053..6cc64adaa3 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -760,8 +760,6 @@ function PlanetData(_planet, _system) constructor { 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 has_problem = function(problem) { return has_problem_planet(planet, problem, system); diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index e6bc445c63..925bdcb4c4 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -151,7 +151,7 @@ function check_for_plasma_bomb_and_tomb(unit) { var _star = obj_ncombat.battle_object; var _planet = obj_ncombat.battle_id; var _necron_strength = _star.p_necrons[_planet]; - if (unit.gear() == "Plasma Bomb" && !string_count("mech_tomb2", obj_ncombat.battle_special)) { + if (unit.gear() == "Plasma Bomb" && !string_count("mech_tomb", obj_ncombat.battle_special)) { if (obj_ncombat.enemy == eFACTION.NECRONS && awake_tomb_world(_star.p_feature[_planet])) { if (((_necron_strength - 2) < 3 && obj_ncombat.dropping) || (_necron_strength - 1) < 3) { obj_ncombat.plasma_bomb += 1; 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 6f0dccef68..82397613f2 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -88,8 +88,6 @@ function scr_enemy_ai_d() { var _pdata = get_planet_data(i); - mechanicus_missions_end_turn(i); - if (((p_tyranids[i] == 3) || (p_tyranids[i] == 4)) && (p_population[i] > 0)) { if (!has_problem_planet(i, "Hive Fleet")) { var roll = irandom_range(100, 300); diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 0b32a8a506..167a352061 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -1,144 +1,3 @@ -function mechanicus_missions_end_turn(planet) { - var _pdata = get_planet_data(planet); - var raider_planet_slot = has_problem_planet_with_time(planet, "mech_raider"); - if (raider_planet_slot > -1) { - var _techs = collect_role_group(SPECIALISTS_TECHS, [name, planet, -1]); - 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, id)} 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) { - var _units = _pdata.collect_planet_group(); - var _bionics = _units.tally_attr("bionics"); - if (_bionics >= 10) { - var _prob_data = p_problem_other_data[planet][bionics_planet_slot]; - var percent_complete = increment_mission_completion(_prob_data); - scr_alert("", $"mission", $"Mechanicus Mission on {planet_numeral_name(planet, id)} is {floor(percent_complete)}% complete.", 0, 0); - if (percent_complete >= 100) { - remove_planet_problem(planet, "mech_bionics"); - scr_mission_reward("mech_bionics", id, planet); - } - } - } - var tomb2_planet_slot = has_problem_planet_with_time(planet, "mech_tomb2"); - if (tomb2_planet_slot > -1) { - var _mission_data = p_problem_other_data[planet][tomb2_planet_slot]; - _mission_data.turns++; - var battli = 0; - var _roll1 = roll_dice_chapter(1, 100 + _mission_data.turns, "low"); - var completion = _mission_data.completion > 0; - - if (roll1 > 98) { - if ((roll1 >= 90) && (roll1 < 98)) { - battli = 1; - } // oops - if (roll1 >= 98) { - battli = 2; - } // very oops, much necron, wow - - if ((battli > 0) && (p_player[planet] > 0)) { - // Quene the battle - obj_turn_end.battles += 1; - obj_turn_end.battle[obj_turn_end.battles] = 1; - obj_turn_end.battle_world[obj_turn_end.battles] = planet; - obj_turn_end.battle_opponent[obj_turn_end.battles] = 13; - obj_turn_end.battle_location[obj_turn_end.battles] = name; - obj_turn_end.battle_object[obj_turn_end.battles] = id; - if (battli == 1) { - obj_turn_end.battle_special[obj_turn_end.battles] = "study2a"; - } - if (battli == 2) { - obj_turn_end.battle_special[obj_turn_end.battles] = "study2b"; - } - - if (obj_turn_end.battle_opponent[obj_turn_end.battles] == 11) { - if (planet_feature_bool(p_feature[planet], eP_FEATURES.CHAOSWARBAND) == 1) { - obj_turn_end.battle_special[obj_turn_end.battles] = "ChaosWarband"; - } - } - } - if ((battli > 0) && (p_player[planet] <= 0)) { - // XDDDDD - scr_popup("Mechanicus Mission Failed", "The Mechanicus Research team on planet " + string(name) + " " + scr_roman(planet) + " have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); - obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); - obj_controller.disposition[3] -= 25; - remove_planet_problem(planet, "mech_tomb2"); - } - } else { - // Done - if (roll1 > 20) { - scr_alert("", "mission", "Adeptus Mechanicus research within the Necron Tomb of " + string(name) + " " + scr_roman(planet) + " continues.", 0, 0); - } else if (roll1 <= 20) { - // Complete - var text, reward = choose(1, 1, 2); - if (scr_has_adv("Tech-Brothers")) { - reward = choose(1, 2); - } - - if (reward == 1) { - obj_controller.requisition += 400; - text = "The Mechanicus Research team on planet " + string(name) + " " + scr_roman(planet) + " have completed their work without any major setbacks. Pleased with your astartes' work, they have granted you 400 Requisition to be used as you see fit."; - scr_event_log("", "Mechanicus Mission Completed: The Mechanicus research team on " + string(name) + " " + scr_roman(planet) + " have completed their work."); - } else if (reward == 2) { - var last_artifact = scr_add_artifact("random", "", 0); - text = "The Mechanicus Research team on planet " + string(name) + " " + scr_roman(planet) + " have completed their work without any major setbacks. Pleased with your astartes' work, they have granted your Chapter an artifact, to be used as you see fit."; - scr_event_log("", "Mechanicus Mission Completed: The Mechanicus research team on " + string(name) + " " + scr_roman(planet) + " have completed their work."); - scr_event_log("", "Artifact gifted from Mechanicus."); - } - - scr_popup("Mechanicus Mission Completed", text, "mechanicus", ""); - - obj_controller.disposition[3] += 1; - remove_planet_problem(planet, "mech_tomb2"); - } - } - } - var tomb1_planet_slot = has_problem_planet_with_time(planet, "mech_tomb1"); - if (tomb1_planet_slot > -1) { - var _marines = collect_role_group("all", [name, planet, -1]); - if (array_length(_marines) >= 20) { - remove_planet_problem(planet, "mech_tomb1"); - add_new_problem(planet, "mech_tomb2", 999, noone, {turns: 0}); - scr_popup("Mechanicus Research", "The Mechanicus Research team on planet " + string(name) + " " + scr_roman(planet) + " has taken note of your Astartes and are now prepared to begin their research. Your marines are to stay on the planet until further notice.", "necron_cave", ""); - } else {} - } - if (has_problem_planet_and_time(planet, "mech_tomb1", 0) > -1) { - var alert_text = "Mechanicus Mission Failed: Necron Tomb Study at " + string(name) + " " + scr_roman(planet) + "."; - scr_alert("red", "mission_failed", alert_text, 0, 0); - scr_event_log("red", alert_text, name); - alter_disposition(eFACTION.MECHANICUS, -15); - remove_planet_problem(planet, "mech_tomb1"); - } - - var mars_mech_mission = has_problem_planet_and_time(planet, "mech_mars", 0); - if (mars_mech_mission > -1) { - mechanicus_mars_mission_target_time_elapsed(planet); - } - - if (has_problem_planet_and_time(planet, "mech_raider", 0) > -1) { - var alert_text = "Mechanicus Mission Failed: Land Raider testing at " + string(name) + " " + scr_roman(planet) + "."; - scr_alert("red", "mission_failed", alert_text, 0, 0); - scr_event_log("red", alert_text); - alter_disposition(eFACTION.MECHANICUS, -6); - remove_planet_problem(planet, "mech_raider"); - } - if (has_problem_planet_and_time(planet, "mech_bionics", 0) > -1) { - var alert_text = "Mechanicus Mission Failed: bionics testing at " + string(name) + " " + scr_roman(planet) + "."; - scr_alert("red", "mission_failed", alert_text, 0, 0); - scr_event_log("red", alert_text); - alter_disposition(eFACTION.MECHANICUS, -6); - remove_planet_problem(planet, "mech_bionics"); - } -} - function spawn_mechanicus_mission(chosen_mission = "random") { LOGGER.info("RE: Mechanicus Mission"); var mechanicus_missions = []; @@ -284,7 +143,7 @@ function accept_mechanicus_tomb_mission() { } if (_planet > 0) { _planet = _star.get_planet_data(_planet); - _planet.new_problem("mech_tomb1", 17); + _planet.new_problem("mech_tomb", 17, {stage : "awating_player"}); var _name = _planet.name(); text = $"The Adeptus Mechanicus await your forces at {_name}. They are expecting at least two squads of Astartes and have placed the testing on hold until their arrival. {global.chapter_name} have 16 months to arrive."; scr_event_log("", "Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", _star.name); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index ac6c7964dd..da9da26a42 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -17,7 +17,7 @@ global.planet_problem_keys = [ "mech_raider", "mech_bionics", "mech_mars", - "mech_tomb1", + "mech_tomb", "fallen", "great_crusade", "harlequins", @@ -49,7 +49,7 @@ function mission_name_key(mission) { "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", + "mech_tomb": "Explore Mechanicus Tomb", "fallen": "Find Chapter Fallen", "great_crusade": "Answer Crusade Muster Call", "harlequins": "Harlequin presence Report", @@ -482,8 +482,9 @@ function has_problem_planet_with_time(planet, problem, star = noone) { var _had_problem = -1; if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] == problem) { - if (p_timer[planet][i] > 0) { + var _problem = p_problem[planet][i]; + if (_problem.p_id == problem) { + if (_problem.timer > 0) { _had_problem = i; } } @@ -587,18 +588,6 @@ function add_new_problem(planet, problem, timer, star = noone, other_data = {}) return problem_added; } -/// @self Asset.GMObject.obj_star -function increment_mission_completion(mission_data) { - if (!struct_exists(mission_data, "completion")) { - mission_data.completion = 0; - } - mission_data.completion++; - if (!struct_exists(mission_data, "required_months") || mission_data.required_months <= 0) { - LOGGER.error("Invalid required_months in mission_data"); - return 0; - } - return (mission_data.completion / mission_data.required_months) * 100; -} //search problem data for a given and key and iff applicable value on that key //TODO increase filtering and search options diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index 4be6081539..96aa071c6a 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -266,7 +266,7 @@ function UnitQuickFindPanel() constructor { var problems = p_problem[i]; for (var p = 0; p < array_length(problems); p++) { var _problem = problems[p]; - if (problem_has_key_and_value(i, p, "stage", "preliminary")) { + if (_problem.stage_id == "preliminary") { continue; } var mission_explain = mission_name_key(problems[p]); @@ -274,9 +274,10 @@ function UnitQuickFindPanel() constructor { var _data = { system: name, mission: mission_explain, - time: p_timer[i][p], + time: _problem.timer, planet: i, system_id: id, + problem : _problem, }; _data.click_left = method(_data, function() { From efa0c7c1fb1c8865421145c0fa56c27dd4fec929 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Thu, 17 Sep 2026 17:01:06 +0100 Subject: [PATCH 005/118] Update scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 82397613f2..8c98220640 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -81,7 +81,7 @@ function scr_enemy_ai_d() { } } for (var i = 1; i <= planets; i++) { - if (array_length(p_problems[i]) == 0){ +if (array_length(p_problem[i]) == 0){ continue; } problem_count_down(i); From efde849eaf3412e989db4e207a0e16da5a4ce000 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Thu, 17 Sep 2026 17:01:33 +0100 Subject: [PATCH 006/118] Update scripts/scr_crusade/scr_crusade.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_crusade/scr_crusade.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index e24f930740..35b114c8bf 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -233,7 +233,7 @@ function launch_crusade() { star_alert.image_speed = 1; scr_event_log("", $"A Crusade is called; our forces are expected at {star_id.name} in {_eta} months.", star_id.name); var _p_data = star_id.get_planet_data(irandom_range(1, star_id.planets)); - assigned_crusade = _p_data.new_problem("great_crusade", _eta, star_id); + assigned_crusade = _p_data.new_problem("great_crusade", _eta); return true; } } From 845e6a4bf361c36166cee08129a8d8e5687a6d77 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 17 Sep 2026 17:02:46 +0100 Subject: [PATCH 007/118] correct indexing --- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 6cc64adaa3..f5f4b998ba 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -782,7 +782,7 @@ function PlanetData(_planet, _system) constructor { } static register_problem = function(problem){ - array_push(p_problem, problem); + array_push(p_problem[planet], problem); problems = system.p_problem[planet]; } From 21536fb27e26c1248ada9560808b638a409b2494 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Thu, 17 Sep 2026 17:03:36 +0100 Subject: [PATCH 008/118] Apply suggestion from @cubic-dev-ai[bot] Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/MissionHelper/MissionHelper.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index fceebc4e41..17f00579a3 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -476,7 +476,7 @@ static per_turn_check_mech_raider = function() { scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { p_data.remove_problem(p_id); - scr_mission_reward("mech_raider", id, planet); + scr_mission_reward("mech_raider", system, planet); timer = -1 per_turn_checks = false; zero_timer_checks = false; From ed2f4a21e9226ea2dd853962248d0bbeb8c10dd5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 19 Sep 2026 21:58:58 +0100 Subject: [PATCH 009/118] Refactor missions to use object-oriented approach Migrates mission initialization and completion logic into MissionHelper as methods, encapsulating mission state and behavior directly within mission objects. This change removes the reliance on parallel data arrays within PlanetData and scr_mission_functions, improving modularity and simplifying mission management by allowing direct method calls on mission instances. --- scripts/MissionHelper/MissionHelper.gml | 141 +++++++++++++++- scripts/scr_PlanetData/scr_PlanetData.gml | 29 ++-- .../scr_draw_planet_features.gml | 6 +- .../scr_inquisition_mission.gml | 7 - .../scr_manage_task_selector.gml | 7 +- .../scr_mission_functions.gml | 154 +----------------- 6 files changed, 153 insertions(+), 191 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 17f00579a3..85af8777ca 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -12,6 +12,7 @@ data = data; p_data = planet; planet = p_data.planet; system = p_data.system; +f_type = eP_FEATURES.MISSION; static refresh_p_data = function(){ p_data = system.get_planet_data(planet); } @@ -96,6 +97,9 @@ static basic_turn_end = function(){ break; case "mech_mars": _func = resolve_mech_mars; + break; + case "provide_garrison": + _func = complete_garrison_mission; } if (!is_undefined(_func)){ try { @@ -153,6 +157,26 @@ static __init(){ } __init(); + +static init_beast_hunt_mission = function() { + refresh_p_data(); + if (stage_id == "preliminary") { + var _numeral_name = p_data.name() + stage_id = "active"; + var _mission_length = irandom_range(2, 5); + timer[planet][mission_slot] = _mission_length; + var _gar_pop = instance_create(0, 0, obj_popup); + //TODO some new MissonHelper 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."; + _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.", p_data.system.name); + } +} + static complete_beast_hunt_mission = function() { refresh_p_data(); var _hunters = collect_role_group("all", [system.name, planet, 0], false, man_conditions); @@ -222,20 +246,47 @@ static complete_beast_hunt_mission = function() { } } + +stati init_train_forces_mission = fuction(marine) { + refresh_p_data(); + if (stage_id != "preliminary") { + exit; + } + var _numeral_name = p_data.name(); + stage_id = "active"; + var _mission_length = irandom_range(3, 12); + timer = _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 = marine.has_role(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)"; + p_data.add_disposition(3); + } + + data.assigned_unit = marine.uid; + + //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.", p_data.system.name); +} + static complete_train_forces_mission = function() { refresh_p_data(); if (stage_id == "active") { - var man_conditions = { - "job": "train_forces", - "max": 1, - }; var _mission_string = ""; - var _trainer = collect_role_group("all", [system.name, planet, 0], false, man_conditions); - if (array_length(_trainer)) { + var _trainer = fetch_unit_uid(data.assigned_unit); + if (is_struct(_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) { _wis_test_difficulty += 10; @@ -243,7 +294,7 @@ static complete_train_forces_mission = function() { var _cult = p_data.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; if (_cult.hiding) { p_data.delete_feature(eP_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"; + _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"; } } } @@ -614,4 +665,78 @@ static resolve_mech_mars = function() { refresh_p_data(); mechanicus_mars_mission_target_time_elapsed(planet); } + + +static init_garrison_mission = function() { + refresh_p_data(); + var mission_data = problems_data[mission_slot]; + if (stage_id != "preliminary") { + exit; + } + var _numeral_name = p_data.name(); + stage_id = "active"; + var _garrison_length = 10 + irandom(6); + timer = _garrison_length; + 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."; + _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.", p_data.system.name); +} + +static complete_garrison_mission= function() { + refresh_p_data(); + if (stage_id != "active"){ + exit; + } + + p_data.garrisons.update(); + if (p_data.current_owner != eFACTION.IMPERIUM || !p_data.garrisons.garrison_force) { + p_data.add_disposition(-20); + scr_popup($"Agreed Garrison of {name()}", $"your agreed garrison of {name()} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)", "", ""); + return; + } + + var _mission_string = $"The garrison on {name()} has finished the period of garrison support agreed with the planetary governor."; + var _result = p_data.garrisons.garrison_disposition_change(); + if (!p_data.garrisons.garrison_leader) { + p_data.garrisons.find_leader(); + } + + var _effect = 0; + if (_result == "none") { + //TODO make a dedicated plus minus string function if there isn't one already + } else if (_result < 0) { + _effect = _result * irandom_range(1, 5); + _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 { + _effect = _result * irandom_range(1, 5); + _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})"; + } + + p_data.add_disposition(_effect); + var _tester = global.character_tester; + var _widom_test = _tester.standard_test(garrisons.garrison_leader, "wisdom", 0, ["siege"]); + + if (_widom_test[0]) { + p_data.alter_fortification(1); + _mission_string += $"while stationed {garrisons.garrison_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications+1)."; + } + //TODO just generall apply this each turn with a garrison to see if a cult is found + if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + var _cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; + if (_cult.hiding) { + _widom_test = _tester.standard_test(garrisons.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."; + } + } + } + scr_popup($"Agreed Garrison of {name()} complete", _mission_string, "", ""); +} } \ No newline at end of file diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index f5f4b998ba..22df0745ab 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -72,8 +72,6 @@ function PlanetData(_planet, _system) constructor { 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]; @@ -1418,19 +1416,13 @@ function PlanetData(_planet, _system) constructor { } for (var 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 = localize("{0} Audience", [problem_data.applicant]); - problem_data.f_type = eP_FEATURES.MISSION; - problem_data.time = problem_timers[i]; - problem_data.problem = problems[i]; - problem_data.array_position = i; - array_push(planet_displays, [mission_string, problem_data]); - } + var _problem = problems[i]; + if (problem_data.stage_id == "preliminary") { + var mission_string = localize("{0} Audience", [_problem.data.applicant]); + problem_data.time = problem_timers[i]; + problem_data.problem = problems[i]; + problem_data.array_position = i; + array_push(planet_displays, [mission_string, _problem]); } } @@ -1544,9 +1536,10 @@ function PlanetData(_planet, _system) constructor { system.garrison = true; //if there was an outstanding mission to provide the given garrison - var garrison_request = find_problem("provide_garrison"); - if (garrison_request > -1) { - init_garrison_mission(planet, system, garrison_request); + var _garrison_request = find_problem("provide_garrison"); + if (_garrison_request > -1) { + _garrison_request = problems[_garrison_request]; + _garrison_request.init_garrison_mission(); } instance_destroy(obj_star_select); }; diff --git a/scripts/scr_draw_planet_features/scr_draw_planet_features.gml b/scripts/scr_draw_planet_features/scr_draw_planet_features.gml index 91eaedfffb..402988c7a6 100644 --- a/scripts/scr_draw_planet_features/scr_draw_planet_features.gml +++ b/scripts/scr_draw_planet_features/scr_draw_planet_features.gml @@ -237,7 +237,7 @@ function FeatureSelected(_feature, _system, _planet) constructor { 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: []}); + 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, selections: []}); destroy = true; }; break; @@ -248,7 +248,7 @@ function FeatureSelected(_feature, _system, _planet) constructor { _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: []}); + 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, select_type: eMISSION_SELECT_TYPE.SQUADS, selections: []}); destroy = true; }; break; @@ -258,7 +258,7 @@ function FeatureSelected(_feature, _system, _planet) constructor { 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: []}); + 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, selections: []}); destroy = true; }; break; diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 098f4c3620..34d3197ee8 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -318,13 +318,6 @@ function mission_inquistion_hunt_inquisitor(star_id = noone) { scr_popup("Inquisition Mission", text, "inquisition", _pop_data); } -/// @self Asset.GMObject.obj_popup -function add_new_inquis_mission() { - if (add_new_problem(pop_data.planet, pop_data.mission, pop_data.estimate, mission_star)) { - new_star_event_marker("green"); - } -} - /// @self Asset.GMObject.obj_popup function init_mission_hunt_inquisitor() { mission_star = find_star_by_name(pop_data.system); diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index ef4b8727b8..98fc714f5e 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -139,7 +139,8 @@ function task_selector_man_manage() { location: selection_data.system.name, }; _unit.unload(selection_data.planet, selection_data.system); - init_train_forces_mission(selection_data.planet, selection_data.system, selection_data.array_slot, _unit); + var _problem = selection_data.feature; + _problem.init_train_forces_mission(_unit); obj_controller.close_popups = false; exit_adhoc_manage(); exit; @@ -172,8 +173,8 @@ function task_selector_man_manage() { specialist_point_handler.calculate_research_points(); break; case "hunt_beast": - var problem_slot = selection_data.array_slot; - init_beast_hunt_mission(selection_data.planet, selection_data.system, problem_slot); + var _problem = selection_data.feature; + _problem.init_beast_hunt_mission(); obj_controller.close_popups = false; break; } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index da9da26a42..092ccad168 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -167,46 +167,6 @@ function init_marine_acting_strange() { 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; - 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."; - 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); - } -} - -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; - 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."; - 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 init_protect_raider_mission(squad) { var _squad_units = squad.members; var _squad_wisdom = stat_average(_squad_units, "wisdom"); @@ -316,95 +276,6 @@ function protect_raiders_hold_memorial() { 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 = star.get_planet_data(planet); - 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 = marine.has_role(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); - } -} - -/// @self Asset.GMObject.obj_star -function complete_garrison_mission(problem_index) { - if (problem_timers[problem_index] > 0) { - return; - } - var _problem_data = problems_data[problem_index]; - if (!struct_has_value(_problem_data, "stage", "active")) { - remove_problem("provide_garrison"); - return; - } - - garrisons.update(); - if (current_owner != eFACTION.IMPERIUM || !garrisons.garrison_force) { - remove_problem("provide_garrison"); - add_disposition(-20); - scr_popup($"Agreed Garrison of {name()}", $"your agreed garrison of {name()} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)", "", ""); - return; - } - - var _mission_string = $"The garrison on {name()} has finished the period of garrison support agreed with the planetary governor."; - var _result = garrisons.garrison_disposition_change(); - if (!garrisons.garrison_leader) { - garrisons.find_leader(); - } - - var _effect = 0; - if (_result == "none") { - //TODO make a dedicated plus minus string function if there isn't one already - } else if (_result < 0) { - _effect = _result * irandom_range(1, 5); - _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 { - _effect = _result * irandom_range(1, 5); - _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})"; - } - - add_disposition(_effect); - var tester = global.character_tester; - var widom_test = tester.standard_test(garrisons.garrison_leader, "wisdom", 0, ["siege"]); - - if (widom_test[0]) { - alter_fortification(1); - _mission_string += $"while stationed {garrisons.garrison_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications+1)."; - } - //TODO just generall apply this each turn with a garrison to see if a cult is found - if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; - if (cult.hiding) { - widom_test = tester.standard_test(garrisons.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."; - } - } - } - scr_popup($"Agreed Garrison of {name()} complete", _mission_string, "", ""); - - remove_problem("provide_garrison"); -} - //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 @@ -502,7 +373,7 @@ function has_problem_planet_with_time(planet, problem, star = noone) { function find_problem_planet(planet, problem, star = noone) { if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] == problem) { + if (p_problem[planet][i].p_id == problem) { return i; } } @@ -572,6 +443,7 @@ function add_new_problem(planet, problem, timer, star = noone, other_data = {}) var problem_added = false; if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { + array_push if (p_problem[planet][i] == "") { p_problem[planet][i] = problem; p_problem_other_data[planet][i] = other_data; @@ -589,28 +461,6 @@ function add_new_problem(planet, problem, timer, star = noone, other_data = {}) } -//search problem data for a given and key and iff applicable value on that key -//TODO increase filtering and search options -/// @self Asset.GMObject.obj_star -function problem_has_key_and_value(planet, problem, key, value = "", star = noone) { - var has_data = false; - if (star == noone) { - var problem_data = p_problem_other_data[planet][problem]; - if (struct_exists(problem_data, key)) { - if (value == "") { - has_data = true; - } else if (problem_data[$ key] == value) { - has_data = true; - } - } - } else { - with (star) { - has_data = problem_has_key_and_value(planet, problem, key, value); - } - } - return has_data; -} - /// @desc Compares two location arrays to determine if they represent the same place. /// @param {array} _first_loc /// @param {array} _second_loc From 3f427f99512865051a30f93e8782e18810f6e657 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 19 Sep 2026 22:09:10 +0100 Subject: [PATCH 010/118] Refactor planet problem management to PlanetData objects Removes the global `add_new_problem` function, delegating problem addition to `PlanetData` objects via a new `add_problem` method. This change further encapsulates planet-specific state and behavior, reducing reliance on global functions and parallel data arrays. Updates `scr_inquisition_mission`, `scr_new_governor_mission`, and `scr_random_event` (Harlequins) to use the new `PlanetData` method. Additionally, centralizes Harlequin event popup and star marker logic within `MissionHelper`. --- scripts/MissionHelper/MissionHelper.gml | 5 ++++ .../scr_inquisition_mission.gml | 6 ++--- .../scr_mission_functions.gml | 27 ++----------------- scripts/scr_random_event/scr_random_event.gml | 26 ++++++++---------- 4 files changed, 20 insertions(+), 44 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 85af8777ca..7c8dfea4cc 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -152,6 +152,11 @@ static __init(){ break; case "fallen": break; + case "harlequins": + var _text = $"Eldar Harlequins have been seen on planet {p_data.name()}. Their purposes are unknown."; + scr_popup("Harlequin Troupe", _text, "harlequin", ""); + mark("green"); + break; } } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 34d3197ee8..3c05a9162f 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -341,10 +341,8 @@ function init_mission_hunt_inquisitor() { with (_radical_inquisitor_fleet) { set_fleet_movement(false, "move", _est, _est); } - - if (add_new_problem(pop_data.planet, pop_data.mission, pop_data.estimate, mission_star, pop_data.mission_data)) { - new_star_event_marker("green"); - } + var _p_data = mission_star.get_planet_data(pop_data.planet); + _p_data.add_problem(pop_data.mission, pop_data.estimate,pop_data.mission_data) title = "Inquisition Mission Accepted"; text = $"{global.chapter_name} will intercept the radical Inquisitor {pop_data.mission_data.inquisitor_name} at {mission_star.name}, expected within {pop_data.estimate} months."; diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 092ccad168..72e44c8fce 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -140,7 +140,8 @@ function scr_new_governor_mission(planet, problem = "") { exit; } } - add_new_problem(planet, problem, 20 + irandom(20),, mission_data); + var _p_data = get_planet_data(planet); + _p_data.add_problem(problem, 20 + irandom(20),mission_data); } } @@ -437,30 +438,6 @@ function remove_star_problem(problem, star = noone) { } } -//add a new problem -/// @self Asset.GMObject.obj_star -function add_new_problem(planet, problem, timer, star = noone, other_data = {}) { - var problem_added = false; - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - array_push - if (p_problem[planet][i] == "") { - p_problem[planet][i] = problem; - p_problem_other_data[planet][i] = other_data; - p_timer[planet][i] = timer; - problem_added = true; - break; - } - } - } else { - with (star) { - problem_added = add_new_problem(planet, problem, timer, noone, other_data); - } - } - return problem_added; -} - - /// @desc Compares two location arrays to determine if they represent the same place. /// @param {array} _first_loc /// @param {array} _second_loc diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index f0cd21c6a8..b61167ffef 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -433,26 +433,22 @@ function scr_random_event(execute_now) { } } 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, "", ""); + 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)) { + 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"; - } + var _planet = irandom_range(1, _star.planets); + var _pdata = _star.get_planet_data(_planet); + _pdata.new_problem("harlequins", irandom_range(2, 5)); + + } else if (chosen_event == eEVENT.SUCCESSION_WAR) { LOGGER.info("RE: Succession War"); var eligible_stars = []; From ff83281e60284fdcc61645f01ab71fd8cd0a54d3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 19 Sep 2026 22:26:50 +0100 Subject: [PATCH 011/118] Refine PlanetData problem management and remove legacy helpers Enhances the encapsulation of planet problem logic by implementing direct management of problem objects within PlanetData methods. Removes obsolete global helper functions (`find_problem_planet`, `remove_planet_problem`, `open_problem_slot`, etc.) and updates call sites to utilize the PlanetData object's dedicated methods. This change further solidifies the object-oriented approach for handling planet problems, moving away from parallel arrays and external helper functions. --- objects/obj_ncombat/Alarm_5.gml | 5 +- scripts/MissionHelper/MissionHelper.gml | 2 + scripts/scr_PlanetData/scr_PlanetData.gml | 17 ++++-- scripts/scr_after_combat/scr_after_combat.gml | 2 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 7 +-- .../scr_manage_task_selector.gml | 3 +- .../scr_mission_functions.gml | 60 +------------------ 7 files changed, 24 insertions(+), 72 deletions(-) diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index ea5468bad1..f72dcec7f0 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -576,9 +576,8 @@ if ((defeat == 0) && (enemy == eFACTION.TYRANIDS) && (battle_special == "tyranid if (captured_gaunt > 0) { var why = 0, thatta = 0; instance_activate_object(obj_star); - with (obj_star) { - remove_star_problem("tyranid_org"); - } + var _p_data = battle_object.get_planet_data(battle_id); + _p_data.remove_problem("tyranid_org"); } scr_event_log("", "Inquisition Mission Completed: A Gaunt organism has been captured for the Inquisition."); diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 7c8dfea4cc..546704146c 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -157,6 +157,8 @@ static __init(){ scr_popup("Harlequin Troupe", _text, "harlequin", ""); mark("green"); break; + default: + mark("green"); } } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 22df0745ab..77116286a4 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -760,7 +760,12 @@ function PlanetData(_planet, _system) constructor { problems = system.p_problem[planet]; static has_problem = function(problem) { - return has_problem_planet(planet, problem, system); + for (var i = 0; i < array_length(problems); i++){ + if (problems[i].p_id == problem){ + return true; + } + } + return false; }; static remove_problem = function(problem) { @@ -768,7 +773,12 @@ function PlanetData(_planet, _system) constructor { }; static find_problem = function(problem) { - return find_problem_planet(planet, problem, system); + for (var i = 0; i < array_length(problems); i++){ + if (problems[i].p_id == problem){ + return problems[i]; + } + } + return noone; }; static new_problem = function(p_id, timer = -1, data = {}, register = true){ @@ -1537,8 +1547,7 @@ function PlanetData(_planet, _system) constructor { //if there was an outstanding mission to provide the given garrison var _garrison_request = find_problem("provide_garrison"); - if (_garrison_request > -1) { - _garrison_request = problems[_garrison_request]; + if (is_struct(_garrison_request)) { _garrison_request.init_garrison_mission(); } instance_destroy(obj_star_select); diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index 925bdcb4c4..8417bcbdc4 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -151,7 +151,7 @@ function check_for_plasma_bomb_and_tomb(unit) { var _star = obj_ncombat.battle_object; var _planet = obj_ncombat.battle_id; var _necron_strength = _star.p_necrons[_planet]; - if (unit.gear() == "Plasma Bomb" && !string_count("mech_tomb", obj_ncombat.battle_special)) { + if (unit.gear() == "Plasma Bomb" && obj_ncombat.battle_special != "mech_tomb")) { if (obj_ncombat.enemy == eFACTION.NECRONS && awake_tomb_world(_star.p_feature[_planet])) { if (((_necron_strength - 2) < 3 && obj_ncombat.dropping) || (_necron_strength - 1) < 3) { obj_ncombat.plasma_bomb += 1; 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 8c98220640..ab40093eeb 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -100,11 +100,8 @@ if (array_length(p_problem[i]) == 0){ cont = 1; } - var firstest = open_problem_slot(i); - if (cont == 1 && firstest > -1) { - p_problem[i][firstest] = "Hive Fleet"; - p_timer[i][firstest] = irandom_range(60, 120) + 1; - p_timer[i][firstest] += irandom_range(80, 120) + 1; + if (cont == 1) { + _pdata.add_problem("Hive Fleet", irandom_range(60, 120) + irandom_range(80, 120)); var xx = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; var yy = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 98fc714f5e..62e89624ea 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -43,7 +43,8 @@ function task_selector_squad_manage() { var _squad = fetch_squad(company_data.selected_squads[i]); switch (selection_data.purpose_code) { case "protect_raiders": - init_protect_raider_mission(_squad); + var _problem = selection_data.feature; + _problem.init_protect_raider_mission(_squad); break; } } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 72e44c8fce..cc2d9e5139 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -348,43 +348,6 @@ function has_problem_planet_and_time(planet, problem, time, star = noone) { return _had_problem; } -//returns the array position of a given problem on a given planet if the specfied time is above 0 -/// @self Asset.GMObject.obj_star -function has_problem_planet_with_time(planet, problem, star = noone) { - var _had_problem = -1; - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - var _problem = p_problem[planet][i]; - if (_problem.p_id == problem) { - if (_problem.timer > 0) { - _had_problem = i; - } - } - } - } else { - with (star) { - _had_problem = has_problem_planet_with_time(planet, problem); - } - } - return _had_problem; -} - -//returns the array position of a gien problem on a given planet -/// @self Asset.GMObject.obj_star -function find_problem_planet(planet, problem, star = noone) { - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i].p_id == problem) { - return i; - } - } - } else { - with (star) { - return find_problem_planet(planet, problem); - } - } - return -1; -} ///removie all of a given problem from a planet /// @self Asset.GMObject.obj_star @@ -392,10 +355,8 @@ function remove_planet_problem(planet, problem, star = noone) { var _had_problem = false; if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] == problem) { - p_problem[planet][i] = ""; - p_timer[planet][i] = -1; - p_problem_other_data[planet][i] = {}; + if (p_problem[planet][i].p_id == problem) { + array_delete(p_problem[planet],i, 1); _had_problem = true; } } @@ -407,23 +368,6 @@ function remove_planet_problem(planet, problem, star = noone) { return _had_problem; } -//find an open problem slot on a given planet -/// @self Asset.GMObject.obj_star -function open_problem_slot(planet, star = noone) { - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] == "") { - return i; - } - } - } else { - with (star) { - return open_problem_slot(planet); - } - } - return -1; -} - //remove all of a given problem types from a star /// @self Asset.GMObject.obj_star function remove_star_problem(problem, star = noone) { From 220d5ec0b3e65a626704449c1014090f303f6f28 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 20 Sep 2026 23:30:17 +0100 Subject: [PATCH 012/118] Refactor battle queuing to centralize logic and pass structured data Introduces `new_end_turn_battle` in `MissionHelper` to abstract and centralize battle queuing. This new helper enables passing richer, structured data (via `special_feature`) to combat encounters. The `battle_mission` variable is deprecated and consolidated into `battle_special` to streamline battle-related context. Migrates per-turn battle logic from `scr_enemy_ai_e` into `MissionHelper`, enhancing modularity and aligning with the ongoing refactoring towards object-oriented design and better data encapsulation. --- objects/obj_ncombat/Alarm_7.gml | 2 +- objects/obj_ncombat/Create_0.gml | 2 +- objects/obj_turn_end/Mouse_56.gml | 7 ++- scripts/MissionHelper/MissionHelper.gml | 62 ++++++++++++++----- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 36 ----------- .../scr_inquisition_mission.gml | 2 +- .../scr_post_battle_events.gml | 54 ++++++++-------- 7 files changed, 82 insertions(+), 83 deletions(-) diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 5a6141bf41..9e3276e356 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -292,7 +292,7 @@ try { } } - if (battle_mission == "necron_tomb_excursion") { + if (battle_special == "necron_tomb_excursion") { necron_tomb_raid_post_battle_sequence(); } diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 41a2026375..9add2fdd22 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -29,6 +29,7 @@ vehicles_to_recover = 0; end_alive_units = []; average_battle_exp_gain = 0; upgraded_librarians = []; +special_feature = undefined; view_x = obj_controller.x; view_y = obj_controller.y; @@ -63,7 +64,6 @@ if (instance_exists(obj_star)) { LOGGER.error("No obj_star instance found for combat; battle_object defaulted to noone"); } battle_id = 0; -battle_mission = ""; battle_special = ""; battle_data = {}; defeat = 0; diff --git a/objects/obj_turn_end/Mouse_56.gml b/objects/obj_turn_end/Mouse_56.gml index a67db2d289..43af8a6379 100644 --- a/objects/obj_turn_end/Mouse_56.gml +++ b/objects/obj_turn_end/Mouse_56.gml @@ -149,7 +149,12 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e obj_ncombat.fortified = 0; } - obj_ncombat.battle_special = battle_special[current_battle]; + if (is_struct(battle_special[current_battle])){ + obj_ncombat.battle_special = battle_special[current_battle].special_id; + obj_ncombat.special_feature = battle_special[current_battle].special_feature; + } else { + obj_ncombat.battle_special = battle_special[current_battle]; + } obj_ncombat.battle_climate = _planet_data.planet_type; if (_enemy == eFACTION.IMPERIUM) { diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 546704146c..70316b326e 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -49,6 +49,8 @@ static basic_turn_end = function(){ default: _func = per_turn_check_mech_tomb1; break; + case "spyrer": + _func = per_turn_check_spyrer; } if (!is_undefined(_func)){ try { @@ -134,6 +136,19 @@ static increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } +static new_end_turn_battle = function(battle_opponent_id, special_id = p_id){ + var _battle_index = obj_turn_end.battles++; + obj_turn_end.battle[_battle_index] = 1; + obj_turn_end.battle_world[_battle_index] = planet; + obj_turn_end.battle_opponent[_battle_index] = battle_opponent_id; + obj_turn_end.battle_location[_battle_index] = system.name; + obj_turn_end.battle_object[_battle_index] = system; + obj_turn_end.battle_special[_battle_index] = { + special_id : special_id, + special_feature : self + }; +} + static __init(){ switch(p_id){ case "necron": @@ -500,6 +515,31 @@ static resolve_spyrer = function() { scr_event_log("red", _text); } +static per_turn_check_spyrer = function() { + refresh_p_data(); + if (p_data.player_forces > 20) { + var tixt = "The Spyrer on " + planet_numeral_name(run, id) + " seems to have vanished, presumably gone into hiding."; + scr_popup("Spyrer Rampage", tixt, "spyrer", ""); + } else if (p_data.player_forces <= 20) { + new_end_turn_battle(30, "spyrer"); + } +} + +static per_turn_check_fallen = function() { + refresh_p_data(); + if (p_data.player_forces > 0){ + if (choose(true, false)) { + new_end_turn_battle(10, choose(true, false) ? "fallen1" : "fallen2"); + } else { + if (remove_planet_problem(run, "fallen")) { + var tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; + scr_popup("Hunt the Fallen", tixt, "fallen", ""); + scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run, id)}"); + } + } + } +} + static resolve_fallen = function() { //TODO marker point for cohesion mechanics refresh_p_data(); @@ -593,30 +633,20 @@ static per_turn_check_mech_tomb2 = function() { if ((_battli > 0) && (p_player[planet] > 0)) { // Queue the battle - obj_turn_end.battles += 1; - obj_turn_end.battle[obj_turn_end.battles] = 1; - obj_turn_end.battle_world[obj_turn_end.battles] = planet; - obj_turn_end.battle_opponent[obj_turn_end.battles] = 13; - obj_turn_end.battle_location[obj_turn_end.battles] = p_data.name(); - obj_turn_end.battle_object[obj_turn_end.battles] = id; - if (_battli == 1) { - obj_turn_end.battle_special[obj_turn_end.battles] = "study2a"; - } - if (_battli == 2) { - obj_turn_end.battle_special[obj_turn_end.battles] = "study2b"; - } - + var _special = _battli == 1 ? "study2a" : "study2b"; + //currently inaccessible if (obj_turn_end.battle_opponent[obj_turn_end.battles] == 11) { - if (planet_feature_bool(p_feature[planet], eP_FEATURES.CHAOSWARBAND) == 1) { - obj_turn_end.battle_special[obj_turn_end.battles] = "ChaosWarband"; + if (p_data.has_feature(eP_FEATURES.CHAOSWARBAND)) { + _special = "ChaosWarband"; } } + new_end_turn_battle(13, _special); } if ((_battli > 0) && (p_player[planet] <= 0)) { // XDDDDD scr_popup("Mechanicus Mission Failed", $"The Mechanicus Research team on planet {p_data.name()} have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); - alter_disposition(eFACTION.MECHANICUS, -25); + p_data.alter_disposition(eFACTION.MECHANICUS, -25); p_data.remove_problem(p_id); } } else { 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 60020548ae..5a57a067eb 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -528,42 +528,6 @@ function scr_enemy_ai_e() { chaos_meeting = run + 0.1; } } - if (has_problem_planet(run, "spyrer")) { - if (p_player[run] > 20) { - var tixt = "The Spyrer on " + planet_numeral_name(run, id) + " seems to have vanished, presumably gone into hiding."; - scr_popup("Spyrer Rampage", tixt, "spyrer", ""); - } else if (p_player[run] <= 20) { - obj_turn_end.battles += 1; - obj_turn_end.battle[obj_turn_end.battles] = 1; - obj_turn_end.battle_world[obj_turn_end.battles] = run; - obj_turn_end.battle_opponent[obj_turn_end.battles] = 30; - obj_turn_end.battle_location[obj_turn_end.battles] = name; - obj_turn_end.battle_object[obj_turn_end.battles] = id; - obj_turn_end.battle_special[obj_turn_end.battles] = "spyrer"; - } - } - - if ((p_player[run] > 0) && has_problem_planet(run, "fallen")) { - if (choose(true, false)) { - obj_turn_end.battles += 1; - obj_turn_end.battle[obj_turn_end.battles] = 1; - obj_turn_end.battle_world[obj_turn_end.battles] = run; - obj_turn_end.battle_opponent[obj_turn_end.battles] = 10; - obj_turn_end.battle_location[obj_turn_end.battles] = name; - obj_turn_end.battle_object[obj_turn_end.battles] = id; - if (choose(true, false)) { - obj_turn_end.battle_special[obj_turn_end.battles] = "fallen1"; - } else { - obj_turn_end.battle_special[obj_turn_end.battles] = "fallen2"; - } - } else { - if (remove_planet_problem(run, "fallen")) { - var tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; - scr_popup("Hunt the Fallen", tixt, "fallen", ""); - scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run, id)}"); - } - } - } } if (p_player[run] > 0 && has_problem_planet(run, "necron")) { setup_necron_tomb_raid(run); diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 3c05a9162f..2e1e37c4fc 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -887,7 +887,7 @@ function necron_tomb_mission_sequence() { obj_ncombat.enemy = eFACTION.NECRONS; obj_ncombat.threat = 1; obj_ncombat.formation_set = 1; - obj_ncombat.battle_mission = "necron_tomb_excursion"; + obj_ncombat.battle_special = "necron_tomb_excursion"; obj_ncombat.battle_data = pop_data; if (battle == 1) { obj_ncombat.battle_special = "wraith_attack"; diff --git a/scripts/scr_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index 6969acb2d6..66e214aab0 100644 --- a/scripts/scr_post_battle_events/scr_post_battle_events.gml +++ b/scripts/scr_post_battle_events/scr_post_battle_events.gml @@ -65,45 +65,45 @@ function protect_raiders_battle_aftermath() { // show_message(obj_turn_end.current_battle); // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); // title / text / image / speshul - var cur_star = battle_object; - var planet = battle_id; - var _planet = cur_star.get_planet_data(planet); + var _cur_star = battle_object; + var _planet = battle_id; + var _p_data = _cur_star.get_planet_data(_planet); var _planet_string = _planet.name(); - _planet.remove_problem("protect_raiders"); + _p_data.remove_problem("protect_raiders"); if (!defeat) { - _planet.add_disposition(15); - var tixt = $"The Raiding forces on {_planet_string} have been removed. The citizens and craftsman may sleep more soundly. (planet disp +15)"; + _p_data.add_disposition(15); + var _tixt = $"The Raiding forces on {_planet_string} have been removed. The citizens and craftsman may sleep more soundly. (_planet disp +15)"; - scr_popup("Planet Protected", tixt, "protect_raiders", ""); - scr_event_log("", $"Governor Request completed: Raiding forces on {_planet_string} have been eliminated.", cur_star.name); + scr_popup("Planet Protected", _tixt, "protect_raiders", ""); + scr_event_log("", $"Governor Request completed: Raiding forces on {_planet_string} have been eliminated.", _cur_star.name); } else { - _planet.add_disposition(-15); - var tixt = $"The Raiding forces on {_planet_string} dispatched with your forces and will continue with their bloody practices. The citizens remain unsafe and the governor is unimpressed. (planet disp -15)"; - scr_popup("Planet Protected", tixt, "protect_raiders", ""); + _p_data.add_disposition(-15); + var _tixt = $"The Raiding forces on {_planet_string} dispatched with your forces and will continue with their bloody practices. The citizens remain unsafe and the governor is unimpressed. (planet disp -15)"; + scr_popup("Planet Protected", _tixt, "protect_raiders", ""); - scr_event_log("", $"Governor Request failed: Raiding forces on {_planet_string} continue to harrass population.", cur_star.name); + scr_event_log("", $"Governor Request failed: Raiding forces on {_planet_string} continue to harrass population.", _cur_star.name); } instance_deactivate_object(obj_star); } /// @self Asset.GMObject.obj_ncombat function hunt_fallen_battle_aftermath() { - if (!defeat) { - with (obj_turn_end) { - remove_planet_problem(battle_world[current_battle], "fallen", battle_object[current_battle]); - var tixt = "The Fallen on " + battle_object[current_battle].name; - tixt += scr_roman(battle_world[current_battle]); - scr_event_log("", $"Mission Succesful: {tixt} have been captured or purged."); - tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; - var _tex_options = [ - "Suffering is the beginning to penance.", - "Their screams shall be the harbringer of their contrition.", - "The shame they inflicted upon us shall be written in their flesh.", - ]; - tixt += _tex_options[choose(0, 0, 1, 2)]; - scr_popup("Hunt the Fallen Completed", tixt, "fallen", ""); - } + if (defeat) { + exit; } + + var _p_data = battle_object.get_planet_data("fallen"); + _p_data.remove_problem("fallen"); + var _tixt = "The Fallen on " + _p_data.name(); + scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); + _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; + var _tex_options = [ + "Suffering is the beginning to penance.", + "Their screams shall be the harbringer of their contrition.", + "The shame they inflicted upon us shall be written in their flesh.", + ]; + _tixt += _tex_options[choose(0, 0, 1, 2)]; + scr_popup("Hunt the Fallen Completed", _tixt, "fallen", ""); } function space_hulk_explore_battle_aftermath() { From 5a040825edeb2fd6be8a498c328ef9f949729b9b Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 21 Sep 2026 18:00:08 +0100 Subject: [PATCH 013/118] Refactor mission battle logic to use PlanetProblem objects Moves pre-battle squad selection, in-battle special effects, and post-battle resolution logic from global scripts and `obj_ncombat` alarms into dedicated methods on `PlanetProblem` instances within `MissionHelper`. This significantly improves encapsulation by associating battle-related mission behavior directly with the `PlanetProblem` object (via `special_feature`), rather than relying on `battle_special` string parsing or scattered global functions. It also simplifies `obj_ncombat` by delegating special mission aftermath handling. --- objects/obj_ncombat/Alarm_0.gml | 4 +- objects/obj_ncombat/Alarm_1.gml | 4 +- objects/obj_ncombat/Alarm_5.gml | 8 +- objects/obj_ncombat/Alarm_7.gml | 74 +---- scripts/MissionHelper/MissionHelper.gml | 256 ++++++++++++++++-- .../scr_manage_task_selector.gml | 16 +- .../scr_mission_functions.gml | 75 ----- .../scr_post_battle_events.gml | 47 ---- 8 files changed, 255 insertions(+), 229 deletions(-) diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 49add2da9d..f539913c6b 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -82,14 +82,14 @@ try { alpha_strike = 1; } - if ((battle_special == "study2a") || (battle_special == "study2b")) { + if (battle_special == "mars_tomb") { ally = 3; ally_forces = 1; } xxx = instance_nearest(1000, 240, obj_pnunit).x + 80; - if ((string_count("spyrer", battle_special) > 0) || (string_count("fallen", battle_special) > 0) || (string_count("mech", battle_special) > 0) || (battle_special == "space_hulk") || (battle_special == "study2a") || (battle_special == "study2b")) { + if (("spyrer" == battle_special) || (string_count("fallen", battle_special) > 0) || (string_count("mech", battle_special) > 0) || (battle_special == "space_hulk") || (battle_special == "mars_tomb")) { fortified = 0; } diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 81916c39e1..6174e56eb3 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -95,10 +95,10 @@ if (battle_special == "") { } } } -if (string_count("spyrer", battle_special) > 0) { +if (battle_special == "spyrer") { p1 = "Your marines search through the alleyways and corridors likely to contain the Spyrer. It does not take long before the lunatic attacks, springing off from a wall to fall among your men. Your ranks are made up of "; } -if (string_count("protect_raiders", battle_special) > 0) { +if (battle_special == "protect_raiders", battle_special) { p1 = "Following responses from scans, Your marine squad deploys and lies in wait on the planets surface. Either the eldar were expecting you or the scope of the raids on the planet had been underplayed by the governor perhaps to hide his incompetence in allowing such foul xenos actions to persist unchecked for so long."; } if (string_count("fallen", battle_special) > 0) { diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index f72dcec7f0..86c7dc7c03 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -307,10 +307,7 @@ if (battle_special == "fallen1") { if (battle_special == "fallen2") { reduce_fortification = false; } -if (battle_special == "study2a") { - reduce_fortification = false; -} -if (battle_special == "study2b") { +if (battle_special == "mars_tomb") { reduce_fortification = false; } @@ -370,9 +367,8 @@ var _non_power_reduce_events = [ "space_hulk", "fallen1", "fallen2", - "study2a", - "study2b", "protect_raiders", + "mars_tomb" ]; // Disable power reduction for matching events diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 9e3276e356..23fb132338 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -190,28 +190,6 @@ try { } } - if ((battle_special == "study2a") || (battle_special == "study2b")) { - if (defeat == 1) { - if (remove_planet_problem(battle_id, "mech_tomb", battle_object)) { - obj_controller.disposition[3] -= 10; - - if (battle_special == "study2a") { - scr_popup("Mechanicus Mission Failed", "All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust, and the Adeptus Mechanicus is furious with your chapter for not providing enough security. Relations with them are worse than before.", "", ""); - } - if (battle_special == "study2b") { - battle_object.p_necrons[battle_id] = 5; - awaken_tomb_world(battle_object.p_feature[battle_id]); - alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]]); - scr_popup("Mechanicus Mission Failed", "All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust. To make matters worse the Necron Tomb has fully awakened- countless numbers of the souless machines are now pouring out of the tomb. The Adeptus Mechanicus are furious with your chapter.", "necron_army", ""); - scr_alert("", "inqi", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); - scr_event_log("", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb"); - } - - scr_event_log("", "Mechanicus Mission Failed: Necron Tomb Research Party and present astartes have been killed."); - } - } - } - if ((enemy == eFACTION.ECCLESIARCHY) && (obj_controller.faction_status[eFACTION.ECCLESIARCHY] != "War")) { obj_controller.loyalty -= 50; obj_controller.loyalty_hidden -= 50; @@ -222,7 +200,7 @@ try { scr_destroy_planet(1); } - if ((string_count("mech", battle_special) > 0) && (defeat == 0)) { + if ((string_count("mech", battle_special) > 0) && (!defeat)) { with (obj_ground_mission) { scr_return_ship(obj_ground_mission.loc, obj_ground_mission, obj_ground_mission.num); with (obj_ground_mission) { @@ -247,11 +225,11 @@ try { instance_activate_all(); if (turn_count < 20) { - if ((defeat == 0) && (threat >= 4)) { + if ((!defeat) && (threat >= 4)) { scr_recent("battle_victory", $"{battle_loc} {scr_roman(battle_id)}", enemy); } - if ((defeat == 1) && (final_marine_deaths + final_command_deaths >= 10)) { + if ((defeat) && (final_marine_deaths + final_command_deaths >= 10)) { scr_recent("battle_defeat", $"{enemy}, {final_marine_deaths + final_command_deaths}"); } } else { @@ -296,48 +274,10 @@ try { necron_tomb_raid_post_battle_sequence(); } - if ((string_count("spyrer", battle_special) > 0) && (defeat == 0)) { - instance_activate_object(obj_star); - // title / text / image / speshul - var cur_star = obj_turn_end.battle_object[obj_turn_end.current_battle]; - var planet = obj_turn_end.battle_world[obj_turn_end.current_battle]; - var _planet_string = scr_roman_numerals()[planet - 1]; - - remove_planet_problem(planet, "spyrer", cur_star); - - var tixt = $"The Spyrer on {cur_star.name} {_planet_string} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; - - scr_popup("Inquisition Mission Completed", tixt, "spyrer", ""); - - if (obj_controller.demanding == 0) { - obj_controller.disposition[4] += 2; - } - if (obj_controller.demanding == 1) { - obj_controller.disposition[4] += choose(0, 0, 1); - } - - scr_event_log("", $"Inquisition Mission Completed: The Spyrer on {cur_star.name} {planet} has been removed.", cur_star.name); - scr_gov_disp(cur_star.name, planet, choose(1, 2, 3, 4)); - - instance_deactivate_object(obj_star); - } else if (battle_special == "protect_raiders") { - protect_raiders_battle_aftermath(); - } else if (string_count("fallen", battle_special) > 0) { - hunt_fallen_battle_aftermath(); - } else if ((defeat == 0) && (enemy == eFACTION.TYRANIDS) && (battle_special == "tyranid_org")) { - if (captured_gaunt > 1) { - var _pop = instance_create(0, 0, obj_popup); - _pop.image = "inquisition"; - _pop.title = "Inquisition Mission Completed"; - _pop.text = "You have captured several Gaunt organisms. The Inquisitor is pleased with your work, though she notes that only one is needed- the rest are to be purged. It will be stored until it may be retrieved. The mission is a success."; - } - if (captured_gaunt == 1) { - var _pop = instance_create(0, 0, obj_popup); - _pop.image = "inquisition"; - _pop.title = "Inquisition Mission Completed"; - _pop.text = "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success."; - } - } else if ((enemy == eFACTION.PLAYER) && (on_ship == true) && (defeat == 0)) { + if (is_struct(special_feature), && is_instanceof(special_feature, PlanetProblem)){ + special_feature.after_battle_effects(); + } + if ((enemy == eFACTION.PLAYER && on_ship == true) && (!defeat)) { var diceh = roll_dice_chapter(1, 100, "high"); if (diceh <= 15) { diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 70316b326e..35353f4c05 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -39,7 +39,7 @@ static basic_turn_end = function(){ case "mech_bionics": _func = per_turn_check_mech_bionics; break; - case "mech_bionics": + case "mech_tomb": switch(stage_id): break; case "exploring": @@ -53,6 +53,7 @@ static basic_turn_end = function(){ _func = per_turn_check_spyrer; } if (!is_undefined(_func)){ + refresh_p_data(); try { _func(); } catch (_exception) { @@ -104,6 +105,7 @@ static basic_turn_end = function(){ _func = complete_garrison_mission; } if (!is_undefined(_func)){ + refresh_p_data(); try { _func(); } catch (_exception) { @@ -149,6 +151,60 @@ static new_end_turn_battle = function(battle_opponent_id, special_id = p_id){ }; } +static new_battle = function(battle_opponent_id,special_id = p_id){ + var _battle = instance_create(0, 0, obj_ncombat); + _battle.enemy = battle_opponent_id; + _battle.battle_object = system; + _battle.battle_loc = system.name; + _battle.battle_id = planet; + _battle.battle_special = special_id; + _battle.special_feature = self; + return _battle; +} + +static after_battle_effects = function(){ + instance_activate_object(obj_star); + var _func = undefined; + switch(p_id){ + case "spyrer": + _func = spyrer_battle_aftermath; + break; + case "protect_raiders": + _func = protect_raiders_battle_aftermath; + break; + case "fallen": + _func = hunt_fallen_battle_aftermath; + break; + } + if (!is_undefined(_func)){ + refresh_p_data(); + try { + _func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + instance_deactivate_object(obj_star); +} + +static on_squad_selection = function(){ + var _func = undefined; + switch(p_id){ + case "protect_raiders": + _func = protect_raider_squad_selected; + break; + } + if (!is_undefined(_func)){ + refresh_p_data(); + try { + _func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + instance_deactivate_object(obj_star); +} + static __init(){ switch(p_id){ case "necron": @@ -181,7 +237,6 @@ __init(); static init_beast_hunt_mission = function() { - refresh_p_data(); if (stage_id == "preliminary") { var _numeral_name = p_data.name() stage_id = "active"; @@ -200,7 +255,6 @@ static init_beast_hunt_mission = function() { } static complete_beast_hunt_mission = function() { - refresh_p_data(); var _hunters = collect_role_group("all", [system.name, planet, 0], false, man_conditions); if (stage_id == "active") { var _mission_string = ""; @@ -270,7 +324,6 @@ static complete_beast_hunt_mission = function() { stati init_train_forces_mission = fuction(marine) { - refresh_p_data(); if (stage_id != "preliminary") { exit; } @@ -301,7 +354,6 @@ stati init_train_forces_mission = fuction(marine) { } static complete_train_forces_mission = function() { - refresh_p_data(); if (stage_id == "active") { var _mission_string = ""; var _trainer = fetch_unit_uid(data.assigned_unit); @@ -400,7 +452,6 @@ static complete_train_forces_mission = function() { } static resolve_succession = function() { - refresh_p_data(); var _result, _alert_text; var _dice1 = roll_dice(1, 100); var _dice2 = roll_dice(1, 100); @@ -456,7 +507,6 @@ static resolve_recon = function() { } static resolve_great_crusade = function() { - refresh_p_data(); var _crusade_direction; var _join_crusade = false; var _player_fleet = instance_nearest(p_data.system.x, p_data.system.y, obj_p_fleet); @@ -493,7 +543,6 @@ static resolve_great_crusade = function() { } static resolve_necron = function() { - refresh_p_data(); alter_disposition(eFACTION.INQUISITION, -8); var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); @@ -506,7 +555,6 @@ static resolve_necron = function() { } static resolve_spyrer = function() { - refresh_p_data(); var _planet_name = p_data.name(); alter_disposition(eFACTION.INQUISITION, -3); var _alert_text = $"The Spyrer on {_planet_name} has been left unchecked. In the ensuing carnage some high-ranking officials have been killed, along with several Nobles. Panic is running amock in several parts of the hives and the Inquisition is less than pleased."; @@ -516,7 +564,6 @@ static resolve_spyrer = function() { } static per_turn_check_spyrer = function() { - refresh_p_data(); if (p_data.player_forces > 20) { var tixt = "The Spyrer on " + planet_numeral_name(run, id) + " seems to have vanished, presumably gone into hiding."; scr_popup("Spyrer Rampage", tixt, "spyrer", ""); @@ -525,8 +572,26 @@ static per_turn_check_spyrer = function() { } } +static spyrer_battle_aftermath = function(){ + // title / text / image / speshul + if (!obj_ncombat.defeat){ + exit; + } + + remove_planet_problem(planet, "spyrer", system); + + var tixt = $"The Spyrer on {p_data.name()} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; + + scr_popup("Inquisition Mission Completed", tixt, "spyrer", ""); + + var _disp_gain = obj_controller.demanding ? choose(0, 0, 1) : 2; + var _disp_gain_string = alter_disposition(eFACTION.INQUISITION, _disp_gain); + + scr_event_log("", $"Inquisition Mission Completed: The Spyrer on {system.name} {planet} has been removed. {_disp_gain_string}", system.name); + scr_gov_disp(system.name, planet, choose(1, 2, 3, 4)); +} + static per_turn_check_fallen = function() { - refresh_p_data(); if (p_data.player_forces > 0){ if (choose(true, false)) { new_end_turn_battle(10, choose(true, false) ? "fallen1" : "fallen2"); @@ -542,7 +607,6 @@ static per_turn_check_fallen = function() { static resolve_fallen = function() { //TODO marker point for cohesion mechanics - refresh_p_data(); var _alert_text = ""; if (irandom(100) > 33) { // Give all marines +3d6 corruption and reduce loyalty by 20*/ @@ -565,8 +629,26 @@ static resolve_fallen = function() { scr_event_log("red", $"Mission Failed: Any Fallen within the {system.name} system have been given time to escape."); } +function hunt_fallen_battle_aftermath() { + if (obj_ncombat.defeat) { + exit; + } + + var _p_data = battle_object.get_planet_data("fallen"); + _p_data.remove_problem("fallen"); + var _tixt = "The Fallen on " + _p_data.name(); + scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); + _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; + var _tex_options = [ + "Suffering is the beginning to penance.", + "Their screams shall be the harbringer of their contrition.", + "The shame they inflicted upon us shall be written in their flesh.", + ]; + _tixt += _tex_options[choose(0, 0, 1, 2)]; + scr_popup("Hunt the Fallen Completed", _tixt, "fallen", ""); +} + static per_turn_check_mech_raider = function() { - refresh_p_data(); var _techs = collect_role_group(SPECIALISTS_TECHS, [system.name, planet, -1]); var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); if ((array_length(_techs) >= 6) && (_lr_count >= 1)) { @@ -583,7 +665,6 @@ static per_turn_check_mech_raider = function() { } static resolve_mech_raider_failed = function() { - refresh_p_data(); var _alert_text = $"Mechanicus Mission Failed: Land Raider testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); @@ -592,7 +673,6 @@ static resolve_mech_raider_failed = function() { } static per_turn_check_mech_bionics = function() { - refresh_p_data(); var _units = p_data.collect_planet_group(); var _bionics = _units.tally_attr("bionics"); if (_bionics >= 10) { @@ -609,7 +689,6 @@ static per_turn_check_mech_bionics = function() { } static resolve_mech_bionics_failed = function() { - refresh_p_data(); var _alert_text = $"Mechanicus Mission Failed: bionics testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); @@ -618,7 +697,6 @@ static resolve_mech_bionics_failed = function() { } static per_turn_check_mech_tomb2 = function() { - refresh_p_data(); data.turns++; var _battli = 0; var _roll1 = roll_dice_chapter(1, 100 + data.turns, "low"); @@ -631,18 +709,19 @@ static per_turn_check_mech_tomb2 = function() { _battli = 2; } // very oops, much necron, wow - if ((_battli > 0) && (p_player[planet] > 0)) { + if ((_battli > 0) && (p_data.player_forces > 0)) { // Queue the battle var _special = _battli == 1 ? "study2a" : "study2b"; + data.battle_key = _special; //currently inaccessible if (obj_turn_end.battle_opponent[obj_turn_end.battles] == 11) { if (p_data.has_feature(eP_FEATURES.CHAOSWARBAND)) { _special = "ChaosWarband"; } } - new_end_turn_battle(13, _special); + new_end_turn_battle(13, "mars_tomb"); } - if ((_battli > 0) && (p_player[planet] <= 0)) { + if ((_battli > 0) && (p_data.player_forces <= 0)) { // XDDDDD scr_popup("Mechanicus Mission Failed", $"The Mechanicus Research team on planet {p_data.name()} have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); @@ -679,7 +758,6 @@ static per_turn_check_mech_tomb2 = function() { } static per_turn_check_mech_tomb1 = function() { - refresh_p_data(); var _marines = collect_role_group("all", [system.name, planet, -1]); if (array_length(_marines) >= 20) { stage_id = "exploring"; @@ -690,7 +768,6 @@ static per_turn_check_mech_tomb1 = function() { } static resolve_mech_tomb1_failed = function() { - refresh_p_data(); var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); @@ -698,14 +775,34 @@ static resolve_mech_tomb1_failed = function() { p_data.remove_problem(p_id); } +static mech_tomb_battle_aftermath = function() { + if (obj_ncombat.defeat) { + if (remove_planet_problem(battle_id, "mech_tomb", battle_object)) { + var _disp_change = alter_disposition(eFACTION.MECHANICUS, -10); + + if (data.battle_key == "study2a") { + scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust, and the Adeptus Mechanicus is furious with your chapter for not providing enough security. Relations with them are worse than before. {_disp_change}", "", ""); + } + if (data.battle_key == "study2b") { + battle_object.p_necrons[battle_id] = 5; + awaken_tomb_world(battle_object.p_feature[battle_id]); + _disp_change = alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]]); + scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust. To make matters worse the Necron Tomb has fully awakened- countless numbers of the souless machines are now pouring out of the tomb. The Adeptus Mechanicus are furious with your chapter. {_disp_change}", "necron_army", ""); + scr_alert("", "inqi", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); + scr_event_log("", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb"); + } + + scr_event_log("", "Mechanicus Mission Failed: Necron Tomb Research Party and present astartes have been killed."); + } + } +} + static resolve_mech_mars = function() { - refresh_p_data(); mechanicus_mars_mission_target_time_elapsed(planet); } static init_garrison_mission = function() { - refresh_p_data(); var mission_data = problems_data[mission_slot]; if (stage_id != "preliminary") { exit; @@ -726,7 +823,6 @@ static init_garrison_mission = function() { } static complete_garrison_mission= function() { - refresh_p_data(); if (stage_id != "active"){ exit; } @@ -776,4 +872,114 @@ static complete_garrison_mission= function() { } scr_popup($"Agreed Garrison of {name()} complete", _mission_string, "", ""); } + +static protect_raiders_battle_aftermath = function() { + // show_message(obj_turn_end.current_battle); + // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); + // title / text / image / speshul + var _planet_string = p_data.name(); + p_data.remove_problem("protect_raiders"); + if (!obj_ncombat.defeat) { + p_data.add_disposition(15); + var _tixt = $"The Raiding forces on {_planet_string} have been removed. The citizens and craftsman may sleep more soundly. ({_planet_string} disp +15)"; + + scr_popup("Planet Protected", _tixt, "protect_raiders", ""); + scr_event_log("", $"Governor Request completed: Raiding forces on {_planet_string} have been eliminated.", system.name); + } else { + p_data.add_disposition(-15); + var _tixt = $"The Raiding forces on {_planet_string} dispatched with your forces and will continue with their bloody practices. The citizens remain unsafe and the governor is unimpressed. (planet disp -15)"; + scr_popup("Planet Protected", _tixt, "protect_raiders", ""); + scr_event_log("", $"Governor Request failed: Raiding forces on {_planet_string} continue to harrass population.", system.name); + } +} + +static protect_raider_squad_selected = function() { + data.squad = data.squads[0]; + var _squad = data.squad; + var _squad_units = _squad.members; + var _squad_wisdom = stat_average(_squad_units, "wisdom"); + var _squad_dex = stat_average(_squad_units, "dexterity"); + var _tester = global.character_tester; + + var _mod = _squad_wisdom + _squad_dex / 20; + if (scr_has_adv("Ambushers")) { + _mod += 10; + } + + var _leader = _squad.determine_leader(); + if (!is_struct(_leader)) { + return; + } + var _wis_test = _tester.standard_test(_leader, "wisdom", _mod, ["ambush"]); + + if (!_wis_test[0]) { + scr_toggle_manage(); + if (_wis_test[1] < -25) { + 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"; + var _dead_marine = array_random_index(_squad_units); + for (var i = 0; i < array_length(_dead_marine); i++) { + if (i == _dead_marine) { + continue; + } + + var _marine = _dead_marine[i]; + + _marine.location_string = "Lost"; + _marine.ship_location = -1; + _marine.planet_location = 0; + } + gar_pop.text += $"After eventual investigation it appears the eldar anticipated the would be ambushers and turned the tides. {_squad_units[_dead_marine].name_role()}s body is eventually discovered some way off from the main battle his rent armour and body showing the extent of combat that must have occured"; + + gar_pop.text += "\nThe total loss of a squad in what was meant to be a routine operation is bad for moral and your chapters reputation you must now decide how to proceed"; + + gar_pop.add_option({str1: "Suppress the Information", choice_func: protect_raiders_suppress_information}); + + gar_pop.add_option({str1: "Hold a Memorial", choice_func: protect_raiders_hold_memorial}); + } else { + var gar_pop = instance_create(0, 0, obj_popup); + gar_pop.title = $"Ineffective Ambush"; + gar_pop.text = $"Your Marines Are ineffective at setting up an ambush the assailants clearly got wind of the operation or the plan was otherwise so ill thought out that by the time your forces arrived there was little that could be done to intercept them"; + gar_pop.text += $""; + gar_pop.pathway = "protect_raiders_ineffective"; + gar_pop.pdata = pdata; + pdata.add_disposition(-10); + gar_pop.text += "\nThe governor is unhappy and it has done little to improve your reputation with the planets populace but otherwise very little harm has been done. It is likely the raiders will choose better targets without the possible threat of space marine presence for the foreseeable future\nGovernor Disposition : -10"; + + gar_pop.add_option("continue"); + } + } else { + var _battle = new_battle(eFACTION.ELDAR) + _roster = new Roster(); + with (_roster) { + selected_units = _squad_units; + setup_battle_formations(); + add_to_battle(); + } + exit_adhoc_manage(); + delete _roster; + } +} +} + +static capture_tyranid_org_battle_aftermath = function(){ + if (obj_ncombat.defeat){ + exit; + } + if (obj_ncombat.captured_gaunt > 1) { + var _pop = instance_create(0, 0, obj_popup); + _pop.image = "inquisition"; + _pop.title = "Inquisition Mission Completed"; + _pop.text = "You have captured several Gaunt organisms. The Inquisitor is pleased with your work, though she notes that only one is needed- the rest are to be purged. It will be stored until it may be retrieved. The mission is a success."; + } + else if (obj_ncombat.captured_gaunt == 1) { + var _pop = instance_create(0, 0, obj_popup); + _pop.image = "inquisition"; + _pop.title = "Inquisition Mission Completed"; + _pop.text = "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success."; + } +} + } \ No newline at end of file diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 62e89624ea..7637bb1a0b 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -39,13 +39,19 @@ function scr_manage_task_selector() { /// @self Asset.GMObject.obj_controller function task_selector_squad_manage() { + var _squads = []; for (var i = 0; i < array_length(company_data.selected_squads); i++) { var _squad = fetch_squad(company_data.selected_squads[i]); - switch (selection_data.purpose_code) { - case "protect_raiders": - var _problem = selection_data.feature; - _problem.init_protect_raider_mission(_squad); - break; + /*switch (selection_data.purpose_code) { + + }*/ + array_push(_squads, _squad); + } + if (struct_exists(selection_data , "feature") && array_length(_squads)){ + var _feat = selection_data.feature; + if (is_struct(_feat) && is_instanceof(_feat, PlanetProblem){ + _feat.data.squads = _squads; + _feat.on_squad_selection(); } } } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index cc2d9e5139..825a80d896 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -168,81 +168,6 @@ function init_marine_acting_strange() { scr_event_log("color", text); } -function init_protect_raider_mission(squad) { - var _squad_units = squad.members; - var _squad_wisdom = stat_average(_squad_units, "wisdom"); - var _squad_dex = stat_average(_squad_units, "dexterity"); - var _tester = global.character_tester; - - var _pdata = selection_data.system.get_planet_data(selection_data.planet); - var _mod = _squad_wisdom + _squad_dex / 20; - if (scr_has_adv("Ambushers")) { - _mod += 10; - } - - var _leader = squad.determine_leader(); - if (!is_struct(_leader)) { - return; - } - var _wis_test = _tester.standard_test(_leader, "wisdom", _mod, ["ambush"]); - - if (!_wis_test[0]) { - if (_wis_test[1] < -25) { - scr_toggle_manage(); - 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"; - var _dead_marine = array_random_index(_squad_units); - for (var i = 0; i < array_length(_dead_marine); i++) { - if (i == _dead_marine) { - continue; - } - - var _marine = _dead_marine[i]; - - _marine.location_string = "Lost"; - _marine.ship_location = -1; - _marine.planet_location = 0; - } - gar_pop.text += $"After eventual investigation it appears the eldar anticipated the would be ambushers and turned the tides. {_squad_units[_dead_marine].name_role()}s body is eventually discovered some way off from the main battle his rent armour and body showing the extent of combat that must have occured"; - - gar_pop.text += "\nThe total loss of a squad in what was meant to be a routine operation is bad for moral and your chapters reputation you must now decide how to proceed"; - - gar_pop.add_option({str1: "Suppress the Information", choice_func: protect_raiders_suppress_information}); - - gar_pop.add_option({str1: "Hold a Memorial", choice_func: protect_raiders_hold_memorial}); - } else { - scr_toggle_manage(); - var gar_pop = instance_create(0, 0, obj_popup); - gar_pop.title = $"Ineffective Ambush"; - gar_pop.text = $"Your Marines Are ineffective at setting up an ambush the assailants clearly got wind of the operation or the plan was otherwise so ill thought out that by the time your forces arrived there was little that could be done to intercept them"; - gar_pop.text += $""; - gar_pop.pathway = "protect_raiders_ineffective"; - gar_pop.pdata = _pdata; - _pdata.add_disposition(-10); - gar_pop.text += "\nThe governor is unhappy and it has done little to improve your reputation with the planets populace but otherwise very little harm has been done. It is likely the raiders will choose better targets without the possible threat of space marine presence for the foreseeable future\nGovernor Disposition : -10"; - - gar_pop.add_option("continue"); - } - } else { - instance_create(0, 0, obj_ncombat); - obj_ncombat.enemy = eFACTION.ELDAR; - obj_ncombat.battle_object = selection_data.system; - obj_ncombat.battle_loc = selection_data.system.name; - obj_ncombat.battle_id = selection_data.planet; - obj_ncombat.battle_special = "protect_raiders"; - _roster = new Roster(); - with (_roster) { - selected_units = _squad_units; - setup_battle_formations(); - add_to_battle(); - } - exit_adhoc_manage(); - delete _roster; - } -} - /// @self Asset.GMObject.obj_popup function protect_raiders_suppress_information() { title = "Captains Disgruntled"; diff --git a/scripts/scr_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index 66e214aab0..d1af7ab898 100644 --- a/scripts/scr_post_battle_events/scr_post_battle_events.gml +++ b/scripts/scr_post_battle_events/scr_post_battle_events.gml @@ -59,53 +59,6 @@ function necron_tomb_raid_post_battle_sequence() { } } -/// @self Asset.GMObject.obj_ncombat -function protect_raiders_battle_aftermath() { - instance_activate_object(obj_star); - // show_message(obj_turn_end.current_battle); - // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); - // title / text / image / speshul - var _cur_star = battle_object; - var _planet = battle_id; - var _p_data = _cur_star.get_planet_data(_planet); - var _planet_string = _planet.name(); - _p_data.remove_problem("protect_raiders"); - if (!defeat) { - _p_data.add_disposition(15); - var _tixt = $"The Raiding forces on {_planet_string} have been removed. The citizens and craftsman may sleep more soundly. (_planet disp +15)"; - - scr_popup("Planet Protected", _tixt, "protect_raiders", ""); - scr_event_log("", $"Governor Request completed: Raiding forces on {_planet_string} have been eliminated.", _cur_star.name); - } else { - _p_data.add_disposition(-15); - var _tixt = $"The Raiding forces on {_planet_string} dispatched with your forces and will continue with their bloody practices. The citizens remain unsafe and the governor is unimpressed. (planet disp -15)"; - scr_popup("Planet Protected", _tixt, "protect_raiders", ""); - - scr_event_log("", $"Governor Request failed: Raiding forces on {_planet_string} continue to harrass population.", _cur_star.name); - } - instance_deactivate_object(obj_star); -} - -/// @self Asset.GMObject.obj_ncombat -function hunt_fallen_battle_aftermath() { - if (defeat) { - exit; - } - - var _p_data = battle_object.get_planet_data("fallen"); - _p_data.remove_problem("fallen"); - var _tixt = "The Fallen on " + _p_data.name(); - scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); - _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; - var _tex_options = [ - "Suffering is the beginning to penance.", - "Their screams shall be the harbringer of their contrition.", - "The shame they inflicted upon us shall be written in their flesh.", - ]; - _tixt += _tex_options[choose(0, 0, 1, 2)]; - scr_popup("Hunt the Fallen Completed", _tixt, "fallen", ""); -} - function space_hulk_explore_battle_aftermath() { if (!defeat && hulk_treasure > 0) { var shi = 0, loc = ""; From ca017d0ecc160d2ef8c39a26e2beda2075d0668d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 21 Sep 2026 19:19:42 +0100 Subject: [PATCH 014/118] Implement structured data for enemy battle setup Moves hardcoded enemy definitions from `obj_ncombat` to a structured `battle_enemy_data` object, defined in `MissionHelper`. This allows mission-specific enemy forces to be defined declaratively, increasing flexibility and reducing reliance on conditional logic within the combat system. Introduces the `add_enemies` function in `obj_enunit` to dynamically populate units from this structured data. This continues the refactoring towards a more data-driven and encapsulated battle system. --- objects/obj_enunit/Create_0.gml | 19 +++++++++++++ objects/obj_ncombat/Alarm_0.gml | 36 +++++++++++-------------- scripts/MissionHelper/MissionHelper.gml | 35 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 20 deletions(-) diff --git a/objects/obj_enunit/Create_0.gml b/objects/obj_enunit/Create_0.gml index 8746fb2f92..29e2608e3e 100644 --- a/objects/obj_enunit/Create_0.gml +++ b/objects/obj_enunit/Create_0.gml @@ -75,6 +75,25 @@ dudes_wep2 = array_create(_array_size, ""); dudes_gear = array_create(_array_size, ""); dudges_mobi = array_create(_array_size, ""); +add_enemies = function(enemy_data){ + var _start_index = 1; + for (var i = 1; i < _array_size; i++) + if (dudes[i] == ""){ + _start_index = i; + } + { + + } + for (var i = 0; i < array_length(enemy_data); i++){ + var _data = enemy_data[i]; + dudes[_start_index] = _data.name; + dudes_num[_start_index] = _data.number; + if (struct_exists(_data, "special")){ + dudes_special[_start_index] = _data.special; + } + _start_index++; + } +} alarm[1] = 5; hit = function() { diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index f539913c6b..ee22ea9253 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -131,6 +131,21 @@ try { u.column = (_num - j) - ((xxx / 10) - 10); } + var _enemies_assiged = false; + if (!is_undefined(battle_enemy_data)){ + move_data_to_curret_scope(battle_enemy_data); + if (struct_exists(battle_enemy_data , "cols")){ + var _cols = battle_enemy_data.cols; + for (var i = 0; i < array_length(_cols); i++){ + var _col = _cols[i]; + u = instance_create(_col.distance, 240, obj_enunit); + u.add_enemies(_col.enemies); + } + enemies_assiged = true; + } + } + + if (!enemies_assiged){ // *** Enemy Forces Special Event *** // * Malcadon Spyrer * if (string_count("spyrer", battle_special) > 0) { @@ -146,26 +161,6 @@ try { enemies[1] = 1; u.flank = 1; } - - if (battle_special == "protect_raiders") { - fortified = 0; - threat = 3; - u = instance_create(20, 240, obj_enunit); - u.dudes[1] = "Dire Avenger"; - u.dudes_num[1] = 40; - u.dudes_special[1] = "shimmershield"; - u.dudes[2] = "Dire Avenger Exarch"; - u.dudes_num[2] = 4; - u.dudes_special[2] = "shimmershield"; - u.dudes[3] = "Autarch"; - u.dudes_num[3] = 1; - u.dudes[4] = "Farseer"; - u.dudes_num[4] = 1; - u.dudes_special[4] = "farseer_powers"; - u.dudes[5] = "Night Spinner"; - u.dudes_num[5] = 1; - u.enemy = eFACTION.ELDAR; - } // * Small Fallen Group * if (battle_special == "fallen1") { fortified = 0; @@ -3178,6 +3173,7 @@ try { u.flank = 1; } } + } // ** Set up player defenses ** if (player_defenses + player_silos > 0) { diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 35353f4c05..063fe570a8 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -960,6 +960,41 @@ static protect_raider_squad_selected = function() { } exit_adhoc_manage(); delete _roster; + + _battle.battle_enemy_data = { + threat : 3, + fortified : false, + cols : [ + { + distance : 20, + enemies : [ + { + name : "Dire Avenger", + number : 40, + special : "shimmershield" + }, + { + name : "Dire Avenger Exarch", + number : 4, + special : "shimmershield" + }, + { + name : "Autarch", + number : 1 + }, + { + name : "Farseer", + number : 1, + special : "farseer_powers" + }, + { + name : "Night Spinner", + number : 1 + } + ] + } + ] + }; } } } From ff50eebb73e76d862b5228f70f12f8e35c93a167 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 22 Sep 2026 23:59:15 +0100 Subject: [PATCH 015/118] Refactor mission combat setup to use structured data Moves specific mission-based enemy definitions and combat flow logic from `obj_ncombat` and global scripts into `MissionHelper`. This includes the Necron Tomb, Fallen, and Spyrer encounters. Combat encounters now receive detailed enemy setups via the `battle_enemy_data` object, and pre/post-battle narratives are driven by `special_feature.data` flags. This greatly reduces reliance on `battle_special` string parsing, improving encapsulation and enabling a more flexible, data-driven approach to mission design. --- objects/obj_enunit/Create_0.gml | 3 +- objects/obj_ncombat/Alarm_0.gml | 133 +----- objects/obj_ncombat/Alarm_1.gml | 18 +- objects/obj_ncombat/Alarm_5.gml | 8 +- objects/obj_ncombat/Alarm_7.gml | 6 +- objects/obj_ncombat/Create_0.gml | 2 +- objects/obj_popup/Step_0.gml | 5 - objects/obj_turn_end/Mouse_56.gml | 3 + scripts/MissionHelper/MissionHelper.gml | 405 +++++++++++++++++- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 3 - .../scr_inquisition_mission.gml | 174 +------- .../scr_post_battle_events.gml | 61 --- 12 files changed, 432 insertions(+), 389 deletions(-) diff --git a/objects/obj_enunit/Create_0.gml b/objects/obj_enunit/Create_0.gml index 29e2608e3e..eebd60e8e9 100644 --- a/objects/obj_enunit/Create_0.gml +++ b/objects/obj_enunit/Create_0.gml @@ -9,7 +9,7 @@ hostile_splash = 0; flank = 0; flyer = 0; // Works same as flank, but does not get denoted as such neww = 0; - +enemy_dudes = 0; column_size = 0; unit_count = 0; @@ -92,6 +92,7 @@ add_enemies = function(enemy_data){ dudes_special[_start_index] = _data.special; } _start_index++; + enemy_dudes += _data.number; } } alarm[1] = 5; diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index ee22ea9253..1e07954f27 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -89,7 +89,7 @@ try { xxx = instance_nearest(1000, 240, obj_pnunit).x + 80; - if (("spyrer" == battle_special) || (string_count("fallen", battle_special) > 0) || (string_count("mech", battle_special) > 0) || (battle_special == "space_hulk") || (battle_special == "mars_tomb")) { + if ((string_count("mech", battle_special) > 0) || (battle_special == "space_hulk") || (battle_special == "mars_tomb")) { fortified = 0; } @@ -138,7 +138,15 @@ try { var _cols = battle_enemy_data.cols; for (var i = 0; i < array_length(_cols); i++){ var _col = _cols[i]; - u = instance_create(_col.distance, 240, obj_enunit); + if (struct_exists(_col , "engaged") && (_col.engaged)){ + u = instance_create(instance_nearest(x + 1000, 240, obj_pnunit).x + 10, 240, obj_enunit); + u.engaged = true; + with (instance_nearest(x + 1000, 240, obj_pnunit)) { + engaged = 1; + } + } else { + u = instance_create(_col.distance, 240, obj_enunit); + } u.add_enemies(_col.enemies); } enemies_assiged = true; @@ -146,45 +154,6 @@ try { } if (!enemies_assiged){ - // *** Enemy Forces Special Event *** - // * Malcadon Spyrer * - if (string_count("spyrer", battle_special) > 0) { - fortified = 0; - with (obj_enunit) { - instance_destroy(); - } - u = instance_create(10, 240, obj_enunit); - enemy_dudes = "1"; - u.dudes[1] = "Malcadon Spyrer"; - u.dudes_num[1] = 1; - u.dudes_num[1] = 1; - enemies[1] = 1; - u.flank = 1; - } - // * Small Fallen Group * - if (battle_special == "fallen1") { - fortified = 0; - with (obj_enunit) { - instance_destroy(); - } - u = instance_create(80, 240, obj_enunit); - enemy_dudes = "1"; - u.dudes[1] = "Fallen"; - u.dudes_num[1] = 1; - enemies[1] = 1; - } - // * Large Fallen Group * - if (battle_special == "fallen2") { - fortified = 0; - with (obj_enunit) { - instance_destroy(); - } - u = instance_create(80, 240, obj_enunit); - enemy_dudes = "1"; - u.dudes[1] = "Fallen"; - u.dudes_num[1] = choose(1, 1, 2, 2, 3); - enemies[1] = u.dudes_num[1]; - } // * Praetorian Servitor Group * if (string_count("mech", battle_special) > 0) { fortified = 0; @@ -218,60 +187,7 @@ try { engaged = 1; } } - // * Necron Wraith Group * - if (battle_special == "wraith_attack") { - fortified = 0; - with (obj_enunit) { - instance_destroy(); - } - u = instance_create(instance_nearest(x + 1000, 240, obj_pnunit).x + 10, 240, obj_enunit); - enemy_dudes = "2"; - u.dudes[1] = "Necron Wraith"; - u.dudes_num[1] = 1; - enemies[1] = 1; - u.dudes[2] = "Necron Wraith"; - u.dudes_num[2] = 1; - enemies[2] = 1; - u.engaged = 1; - with (instance_nearest(x + 1000, 240, obj_pnunit)) { - engaged = 1; - } - } - // * Canoptek Spyder Group * - if (battle_special == "spyder_attack") { - fortified = 0; - with (obj_enunit) { - instance_destroy(); - } - u = instance_create(instance_nearest(x + 1000, 240, obj_pnunit).x + 10, 240, obj_enunit); - enemy_dudes = "21"; - u.dudes[1] = "Canoptek Spyder"; - u.dudes_num[1] = 1; - enemies[1] = u.dudes[1]; - u.dudes[2] = "Canoptek Scarab"; - u.dudes_num[2] = 20; - enemies[2] = u.dudes[2]; - u.engaged = 1; - with (instance_nearest(x + 1000, 240, obj_pnunit)) { - engaged = 1; - } - } - // * Tomb Stalker Group * - if (battle_special == "stalker_attack") { - fortified = 0; - with (obj_enunit) { - instance_destroy(); - } - u = instance_create(instance_nearest(x + 1000, 240, obj_pnunit).x + 10, 240, obj_enunit); - enemy_dudes = "1"; - u.dudes[1] = "Tomb Stalker"; - u.dudes_num[1] = 1; - enemies[1] = 1; - u.engaged = 1; - with (instance_nearest(x + 1000, 240, obj_pnunit)) { - engaged = 1; - } - } + // * Chaos Space Marine Elite Group * if ((battle_special == "cs_meeting_battle5") || (battle_special == "cs_meeting_battle6")) { fortified = 0; @@ -321,28 +237,7 @@ try { u.dudes_num[2] = 3; enemies[2] = 3; } - // * Tomb world attack enemy setup * - if (battle_special == "wake1_attack") { - enemy = eFACTION.NECRONS; - threat = 2; - } - if (battle_special == "wake2_attack") { - enemy = eFACTION.NECRONS; - threat = 3; - } - if (battle_special == "wake3_attack") { - enemy = eFACTION.NECRONS; - threat = 5; - } - // * Tomb world study attack enemy setup * - if (battle_special == "study2a") { - enemy = eFACTION.NECRONS; - threat = 2; - } - if (battle_special == "study2b") { - enemy = eFACTION.NECRONS; - threat = 3; - } + // ** Space Hulk Forces ** if (battle_special == "space_hulk") { var make; @@ -2081,7 +1976,7 @@ try { } // ** Chaos Forces ** - if ((enemy == eFACTION.CHAOS) && (battle_special != "ship_demon") && (battle_special != "fallen1") && (battle_special != "fallen2") && (battle_special != "WL10_reveal") && (battle_special != "WL10_later") && (string_count("cs_meeting_battle", battle_special) == 0)) { + if ((enemy == eFACTION.CHAOS) && (battle_special != "ship_demon") && (battle_special != "fallen") && (battle_special != "WL10_reveal") && (battle_special != "WL10_later") && (string_count("cs_meeting_battle", battle_special) == 0)) { // Small Chaos Cult Group if (threat == 1) { u = instance_nearest(xxx, 240, obj_enunit); @@ -2988,7 +2883,7 @@ try { } // ** Necron Forces ** - if ((enemy == eFACTION.NECRONS) && ((string_count("_attack", battle_special) == 0) || (string_count("wake", battle_special) > 0))) { + if ((enemy == eFACTION.NECRONS) && ((string_count("_attack", battle_special) == 0))) { // Small Necron Group if (threat == 1) { u = instance_nearest(xxx, 240, obj_enunit); diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 6174e56eb3..a43c2ba0a0 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -127,7 +127,7 @@ if (string_count("fallen", battle_special) > 0) { p1 += " Your ranks are made up of "; } -if (string_count("_attack", battle_special) > 0) { +if ("inquisition_tomb" == battle_special) { var wh = choose(1, 2); if (wh == 1) { p1 = "Cave dirt crunches beneath the soles of your marines as they continue their descent. There is little warning before "; @@ -136,26 +136,28 @@ if (string_count("_attack", battle_special) > 0) { p1 = "The shadows stretch and morph as the lights cast by your marines move along. One large shadow begins to move on its own- "; } - if (string_count("wake", battle_special) > 0) { + if (special_feature.data.tomb_awakens) { p1 = "Cave dirt crunches beneath the soles of your marines as they continue their descent. There is little warning when the ground begins to shake. An old, dusty breeze seems to flow through the tunnel, followed by rumbling sensations and distant mechanical sounds. "; - if (string_count("1", battle_special) > 0) { + if (threat = 2) { p1 += "Within minutes Necrons begin to appear from every direction. There appears to be nearly fourty, cramped in the dark tunnels."; } - if (string_count("2", battle_special) > 0) { + else if (threat = 3) { p1 += "Within minutes Necrons begin to appear from every direction. There appears to be nearly a hundred, cramped in the dark tunnels."; } - if (string_count("3", battle_special) > 0) { + else if (threat = 4) { p1 += "Within minutes Necrons begin to appear from every direction. Their numbers are wihout number."; } + } else { + } - if (string_count("wraith", battle_special) > 0) { + if (special_feature.data.enemy = "wraith") { p1 += "two Necron Wraiths appear out of nowhere and begin to attack."; } - if (string_count("spyder", battle_special) > 0) { + if (special_feature.data.enemy = "spyder") { p1 += "a large Canoptek Spyder launches towards your marines, a small group of scuttling Scarabs quickly following."; } - if (string_count("stalker", battle_special) > 0) { + if (special_feature.data.enemy = "stalker") { p1 += "the tunnel begins to shake and a massive Tomb Stalker scuttles into your midst."; } _newline = p1; diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 86c7dc7c03..c644dc2522 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -301,10 +301,7 @@ if (battle_special == "ruins") { if (battle_special == "ruins_eldar") { reduce_fortification = false; } -if (battle_special == "fallen1") { - reduce_fortification = false; -} -if (battle_special == "fallen2") { +if (battle_special == "fallen") { reduce_fortification = false; } if (battle_special == "mars_tomb") { @@ -365,8 +362,7 @@ var _non_power_reduce_events = [ "tyranid_org", "ship_demon", "space_hulk", - "fallen1", - "fallen2", + "fallen", "protect_raiders", "mars_tomb" ]; diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 23fb132338..a14fc0d107 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -270,14 +270,10 @@ try { } } - if (battle_special == "necron_tomb_excursion") { - necron_tomb_raid_post_battle_sequence(); - } - if (is_struct(special_feature), && is_instanceof(special_feature, PlanetProblem)){ special_feature.after_battle_effects(); } - if ((enemy == eFACTION.PLAYER && on_ship == true) && (!defeat)) { + if ((enemy == eFACTION.PLAYER && on_ship == true) && (!defeat)) { var diceh = roll_dice_chapter(1, 100, "high"); if (diceh <= 15) { diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 9add2fdd22..cd82e55ac9 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -65,7 +65,6 @@ if (instance_exists(obj_star)) { } battle_id = 0; battle_special = ""; -battle_data = {}; defeat = 0; defeat_message = 0; fugg = 0; @@ -118,6 +117,7 @@ charged = 0; fadein = 40; enemy = undefined; +battle_enemy_data = undefined; enem = "Orks"; enem_sing = "Ork"; threat = 0; diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index 0552bb4726..9bd33eac49 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -296,11 +296,6 @@ try { if (has_problem_star("recon", _mission_star)) { scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for {global.chapter_name} to capture the Tau Ethereal somewhere within {_mission_star.name}.", _mission_star.name); } - } else if (mission == "demon_world") { - scr_event_log("", $"Inquisition Mission Accepted: The demon world of {_mission_star.name} {scr_roman(planet)} will be purged by your hand.", _mission_star.name); - if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {_mission_star.name} {scr_roman(onceh)} must be cleansed within {estimate} months."; - } } } } diff --git a/objects/obj_turn_end/Mouse_56.gml b/objects/obj_turn_end/Mouse_56.gml index 43af8a6379..0a27d3cf71 100644 --- a/objects/obj_turn_end/Mouse_56.gml +++ b/objects/obj_turn_end/Mouse_56.gml @@ -152,6 +152,9 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e if (is_struct(battle_special[current_battle])){ obj_ncombat.battle_special = battle_special[current_battle].special_id; obj_ncombat.special_feature = battle_special[current_battle].special_feature; + if (struct_exists(battle_special[current_battle], "battle_enemy_data")){ + obj_ncombat.battle_enemy_data = battle_enemy_data; + } } else { obj_ncombat.battle_special = battle_special[current_battle]; } diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 063fe570a8..2f07a56d59 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -51,6 +51,10 @@ static basic_turn_end = function(){ break; case "spyrer": _func = per_turn_check_spyrer; + break; + case "inquisition_tomb": + per_turn_check_inqisition_tomb; + break; } if (!is_undefined(_func)){ refresh_p_data(); @@ -138,7 +142,7 @@ static increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } -static new_end_turn_battle = function(battle_opponent_id, special_id = p_id){ +static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, enemy_data = undefined){ var _battle_index = obj_turn_end.battles++; obj_turn_end.battle[_battle_index] = 1; obj_turn_end.battle_world[_battle_index] = planet; @@ -149,6 +153,9 @@ static new_end_turn_battle = function(battle_opponent_id, special_id = p_id){ special_id : special_id, special_feature : self }; + if (!is_undefined(enemy_data)){ + obj_turn_end.battle_special[_battle_index].battle_enemy_data = enemy_data; + } } static new_battle = function(battle_opponent_id,special_id = p_id){ @@ -175,6 +182,9 @@ static after_battle_effects = function(){ case "fallen": _func = hunt_fallen_battle_aftermath; break; + case "inquisition_tomb": + inquisition_tomb_battle_aftermath; + break; } if (!is_undefined(_func)){ refresh_p_data(); @@ -228,6 +238,8 @@ static __init(){ scr_popup("Harlequin Troupe", _text, "harlequin", ""); mark("green"); break; + case "inquisition_demon_world": + inquisition_demon_world_init(); default: mark("green"); @@ -565,10 +577,29 @@ static resolve_spyrer = function() { static per_turn_check_spyrer = function() { if (p_data.player_forces > 20) { - var tixt = "The Spyrer on " + planet_numeral_name(run, id) + " seems to have vanished, presumably gone into hiding."; - scr_popup("Spyrer Rampage", tixt, "spyrer", ""); + var _tixt = "The Spyrer on " + planet_numeral_name(run, id) + " seems to have vanished, presumably gone into hiding."; + scr_popup("Spyrer Rampage", _tixt, "spyrer", ""); } else if (p_data.player_forces <= 20) { - new_end_turn_battle(30, "spyrer"); + new_end_turn_battle( + 30, + "spyrer", + { + threat : 1, + fortified : false, + cols : [ + { + distance : 10, + flank : true, + enemies : [ + { + name : "Malcadon Spyrer", + number : 1 + } + ] + } + ] + }; + ); } } @@ -580,9 +611,9 @@ static spyrer_battle_aftermath = function(){ remove_planet_problem(planet, "spyrer", system); - var tixt = $"The Spyrer on {p_data.name()} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; + var _tixt = $"The Spyrer on {p_data.name()} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; - scr_popup("Inquisition Mission Completed", tixt, "spyrer", ""); + scr_popup("Inquisition Mission Completed", _tixt, "spyrer", ""); var _disp_gain = obj_controller.demanding ? choose(0, 0, 1) : 2; var _disp_gain_string = alter_disposition(eFACTION.INQUISITION, _disp_gain); @@ -594,11 +625,51 @@ static spyrer_battle_aftermath = function(){ static per_turn_check_fallen = function() { if (p_data.player_forces > 0){ if (choose(true, false)) { - new_end_turn_battle(10, choose(true, false) ? "fallen1" : "fallen2"); + var _group_big = choose(true, false); + var _battle_enemy_data = {}; + if (_group_big){ + _battle_enemy_data = { + threat : 1, + fortified : false, + cols : [ + { + distance : 80, + enemies : [ + { + name : "Fallen", + number : 1 + } + ] + } + ] + }; + + // * Large Fallen Group * + _battle_enemy_data = { + threat : 1, + fortified : false, + cols : [ + { + distance : 80, + enemies : [ + { + name : "Fallen", + number : choose(1, 1, 2, 2, 3) + } + ] + } + ] + }; + } + new_end_turn_battle( + 10, + "fallen", + _battle_enemy_data + ); } else { if (remove_planet_problem(run, "fallen")) { - var tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; - scr_popup("Hunt the Fallen", tixt, "fallen", ""); + var _tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; + scr_popup("Hunt the Fallen", _tixt, "fallen", ""); scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run, id)}"); } } @@ -719,7 +790,7 @@ static per_turn_check_mech_tomb2 = function() { _special = "ChaosWarband"; } } - new_end_turn_battle(13, "mars_tomb"); + new_end_turn_battle(13, "mars_tomb",{threat : choose(2,3)}); } if ((_battli > 0) && (p_data.player_forces <= 0)) { // XDDDDD @@ -1017,4 +1088,318 @@ static capture_tyranid_org_battle_aftermath = function(){ } } +static per_turn_check_inqisition_tomb = function() { + if (p_player[run] <= 0){ + exit; + } + LOGGER.info($"player on planet with necron mission {name} planet: {planet}"); + var _have_bomb = 0; + _have_bomb = scr_check_equip("Plasma Bomb", system.name, planet, 0); + LOGGER.info($"have bomb? {_have_bomb} "); + if (_have_bomb == 0) { + exit; + } + var _tixt; + _tixt = $"Your marines on {planet_numeral_name(planet, id)}"; + _tixt += " are prepared and ready to enter the Necron Tombs. A Plasma Bomb is in tow."; + var _number = instance_exists(obj_turn_end) ? 1 : 0; + var _pop_data = { + mission: self, + loc: system.name, + planet: planet, + estimate: 999, + number: _number, + data.mission_stage: 1, + options: [ + { + str1: "Begin the Mission", + choice_func: self.necron_tomb_mission_start, + }, + { + str1: "Not Yet", + choice_func: popup_default_close, + }, + ], + }; + scr_popup("Necron Tomb Excursion", _tixt, $"necron_cave", _pop_data); +} + +static necron_tomb_mission_start = function() { + obj_popup.title = $"Necron Tunnels : {mission_stage}"; + obj_popup.replace_options([{str1: "Continue", choice_func: self.necron_tomb_mission_sequence}, {str1: "Return to the surface", choice_func: popup_default_close}]); + obj_popup.image = "necron_tunnels_1"; + obj_popup.text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; +} + +/// @self Asset.GMObject.obj_popup +/// @desc Advances the Necron Tomb mission or starts a combat encounter. +/// @returns {Undefined} +static necron_tomb_mission_sequence = function() { + var battle; + var player_forces = system.player_forces; + var penalty = 0; + var _roll = roll_dice_chapter(1, 100, "low"); + battle = 0; + instance_activate_all(); + + // SMALL TEAM OF MARINES + if (player_forces > 6) { + penalty = 10; + } + if (player_forces > 10) { + penalty = 20; + } + if (player_forces >= 20) { + penalty = 30; + } + if (player_forces >= 40) { + penalty = 50; + } + if (player_forces >= 60) { + penalty = 100; + } + _roll += penalty; + + // _roll=30;if (string_count("3",title)>0) then _roll=70; + + // Result + data.tomb_awakens = false; + if (_roll <= 60) { + advance_necron_tomb_mission(); + exit; + } + if ((_roll > 60) && (_roll <= 82)) { + // Necron Wraith attack + battle = 1; + } + if ((_roll > 82) && (_roll <= 92)) { + // Tomb Spyder attack + battle = 2; + } + if ((_roll > 92) && (_roll <= 97)) { + // Tomb Stalker + battle = 3; + } + if (_roll > 97) { + // Tomb World wakes up + data.tomb_awakens = true; + if (player_forces <= 30) { + battle = 4; + } + if (player_forces > 30) { + battle = 5; + } + if (player_forces > 100) { + battle = 6; + } + } + + if (battle > 0) { + instance_deactivate_all_safe(); + instance_activate_object(obj_star); + obj_ncombat.battle_special = "necron_tomb_excursion"; + var _col = []; + var _battle_data = { + threat : 1, + formation_set : 1, + fortified : 0, + } + switch (battle){ + case 1: + _battle_data.cols = [ + { + distance : 10, + engaged : true, + enemies : [ + { + name : "Necron Wraith", + number : 1 + } + { + name : "Necron Wraith", + number : 1 + } + ] + + } + ] + special_feature.data.enemy = "wraith"; + case 2: + _battle_data.cols = [ + { + distance : 10, + engaged : true, + enemies : [ + { + name : "Canoptek Spyder", + number : 1 + } + { + name : "Canoptek Scarab", + number : 20 + } + ] + + } + ] + special_feature.data.enemy = "spyder" + case 3: + _battle_data.cols = [ + { + distance : 10, + engaged : true, + enemies : [ + { + name : "Tomb Stalker", + number : 1 + } + ] + + } + ] + special_feature.data.enemy = "stalker" + break; + case 4: + _battle_data.threat = 2 + break + case 5: + case 6: + _battle_data.threat = 3 + break + } + + var _battle = new_battle( + eFACTION.NECRONS, + p_id, + _battle_data + ) + _roster = new Roster(); + with (_roster) { + roster_location = system.name; + roster_planet = planet; + determine_full_roster(); + only_locals(); + update_roster(); + if (array_length(selected_units)) { + setup_battle_formations(); + add_to_battle(); + } + } + delete _roster; + instance_deactivate_object(obj_star); + + instance_destroy(obj_popup); + } + + exit; +} + +static inquisition_tomb_battle_aftermath = function(){ + if (!data.tomb_awakens) { + if (defeat == 1) { + obj_controller.combat = 0; + obj_controller.cooldown = 10; + obj_turn_end.alarm[1] = 4; + } else if (defeat == 0) { + obj_controller.combat = 0; + var pip = instance_create(0, 0, obj_popup); + pip.pop_data = battle_data; + + with (pip) { + necron_tomb_mission_start(); + var _completed = advance_necron_tomb_mission(); + if (_completed) { + keyboard_clear(vk_enter); + } else { + text = "The last of the attackers is cut down. Your marines regroup in the tunnel and ready themselves to press deeper into the complex.\n\n" + text; + } + number = pop_data.number; + } + } + } else { + var pip = instance_create(0, 0, obj_popup); + with (pip) { + title = "Necron Tomb Awakens"; + image = "necron_army"; + if (obj_ncombat.defeat == 0) { + text = "Your marines make a tactical retreat back to the surface, hounded by Necrons all the way. The Inquisition mission is a failure- you were to blow up the Necron Tomb World stealthily, not wake it up. The Inquisition is not pleased with your conduct."; + } else { + text = "Your marines are killed down to the last man. The Inquisition mission is a failure- you were to blow up the Necron Tomb World stealthily, not wake it up. The Inquisition is not pleased with your conduct."; + } + } + + var _star_obj = find_star_by_name(battle_loc); + if (_star_obj != noone) { + with (_star_obj) { + var planet = obj_ncombat.battle_id; + if (remove_planet_problem(planet, "necron")) { + p_necrons[planet] = 4; + } + if (awake_tomb_world(p_feature[planet]) == 0) { + awaken_tomb_world(p_feature[planet]); + } + } + } + + pip.pop_data = battle_data; + + alter_disposition(eFACTION.INQUISITION, -5); + obj_controller.combat = 0; + + with (pip) { + number = pop_data.number; + } + } +} + +static inquisition_mission_options = fuction(mission_accept_function){ + var _options = [ + { + str1: "Accept", + choice_func: function(){ + pop_data.mission[$ mission_accept_function], + } + }, + ]; + if (!obj_controller.demanding){ + array_push(_options, { + str1: "Refuse", + choice_func: popup_default_close, + }) + } + return _options +} +static inquisition_demon_world_init = fuction(){ + var text = $"The Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; + text += $" has been uncovered as a Demon World. The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; + var _options = [ + { + str1: "Accept", + choice_func: self.inquisition_demon_world_accept, + }, + { + str1: "Refuse", + choice_func: popup_default_close, + }, + ]; + var _pop_data = { + mission: self, + options: inquisition_mission_options(inquisition_demon_world_accept), + }; + scr_popup( + "Inquisition Mission", + text, + "inquisition", + _pop_data + ); +} + +static inquisition_demon_world_accept = fuction(){ + scr_event_log("", $"Inquisition Mission Accepted: The demon world of {system.name} {scr_roman(planet)} will be purged by your hand.", system.name); + if (demand) { + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {p_data.name()} must be cleansed within {timer} months."; + } + new_star_event_marker("green"); +} + } \ No newline at end of file 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 5a57a067eb..dcfcce692a 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -529,9 +529,6 @@ function scr_enemy_ai_e() { } } } - if (p_player[run] > 0 && has_problem_planet(run, "necron")) { - setup_necron_tomb_raid(run); - } if ((p_player[run] > 0) && (force_count > 0)) { for (var force = 2; force < 14; force++) { battle_opponent = 0; diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 2e1e37c4fc..6839e85556 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -116,17 +116,15 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA function mission_inquisition_demon_world(demon_worlds) { var _star = choose_array(demon_worlds); - var planet = -1; + var _planet = -1; for (var i = 1; i <= _star.planets; i++) { if (_star.p_demons[i] > 1) { - planet = i; + _planet = i; break; } } - var eta = scr_mission_eta(_star.x, _star.y, 25); - var text = $"The Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; - text += $" has been uncovered as a Demon World. The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; - scr_popup("Inquisition Mission", text, "inquisition", $"demon_world|{string(_star.name)}|{string(planet)}|{string(eta + 1)}|"); + var _eta = scr_mission_eta(_star.x, _star.y, 25); + _star.get_planet_data(_planet).new_problem("inquisition_demon_world", _eta) } function mission_inquisition_ethereal() { @@ -708,55 +706,6 @@ function mission_investigate_planet() { scr_popup("Inquisition Recon", text, "inquisition", $"recon|{string(_star.name)}|{string(planet)}|{string(eta)}|"); } -/// @self Asset.GMObject.obj_star -/// @desc Queues the Necron Tomb mission prompt when a Plasma Bomb is present. -/// @param {Real} planet Planet index containing the Necron Tomb. -/// @returns {Undefined} -function setup_necron_tomb_raid(planet) { - LOGGER.info($"player on planet with necron mission {name} planet: {planet}"); - var have_bomb; - have_bomb = scr_check_equip("Plasma Bomb", name, planet, 0); - LOGGER.info($"have bomb? {have_bomb} "); - if (have_bomb > 0) { - var tixt; - tixt = $"Your marines on {planet_numeral_name(planet, id)}"; - tixt += " are prepared and ready to enter the Necron Tombs. A Plasma Bomb is in tow."; - var _number = instance_exists(obj_turn_end) ? 1 : 0; - var _pop_data = { - mission: "necron_tomb_excursion", - loc: name, - planet: planet, - estimate: 999, - number: _number, - mission_stage: 1, - options: [ - { - str1: "Begin the Mission", - choice_func: necron_tomb_mission_start, - }, - { - str1: "Not Yet", - choice_func: popup_default_close, - }, - ], - }; - scr_popup("Necron Tomb Excursion", tixt, $"necron_cave", _pop_data); - } -} - -/// @self Asset.GMObject.obj_popup -/// @desc Initializes the popup and choices for a Necron Tomb mission. -/// @returns {Undefined} -function necron_tomb_mission_start() { - mission_star = find_star_by_name(pop_data.loc); - planet = pop_data.planet; - - title = $"Necron Tunnels : {pop_data.mission_stage}"; - replace_options([{str1: "Continue", choice_func: necron_tomb_mission_sequence}, {str1: "Return to the surface", choice_func: popup_default_close}]); - image = "necron_tunnels_1"; - text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; -} - /// @self Asset.GMObject.obj_popup /// @desc Advances the Necron Tomb mission and renders the resulting popup state. /// @returns {Bool} Whether the mission reached completion. @@ -794,121 +743,6 @@ function advance_necron_tomb_mission() { return false; } -/// @self Asset.GMObject.obj_popup -/// @desc Advances the Necron Tomb mission or starts a combat encounter. -/// @returns {Undefined} -function necron_tomb_mission_sequence() { - var battle; - var player_forces = 0; - var penalty = 0; - var roll = roll_dice_chapter(1, 100, "low"); - battle = 0; - instance_activate_all(); - player_forces = mission_star.p_player[planet]; - - // SMALL TEAM OF MARINES - if (player_forces > 6) { - penalty = 10; - } - if (player_forces > 10) { - penalty = 20; - } - if (player_forces >= 20) { - penalty = 30; - } - if (player_forces >= 40) { - penalty = 50; - } - if (player_forces >= 60) { - penalty = 100; - } - roll += penalty; - - // roll=30;if (string_count("3",title)>0) then roll=70; - - // Result - if (roll <= 60) { - advance_necron_tomb_mission(); - exit; - } - if ((roll > 60) && (roll <= 82)) { - // Necron Wraith attack - battle = 1; - } - if ((roll > 82) && (roll <= 92)) { - // Tomb Spyder attack - battle = 2; - } - if ((roll > 92) && (roll <= 97)) { - // Tomb Stalker - battle = 3; - } - if (roll > 97) { - // Tomb World wakes up - if (player_forces <= 30) { - battle = 4; - } - if (player_forces > 30) { - battle = 5; - } - if (player_forces > 100) { - battle = 6; - } - } - - if (battle > 0) { - instance_deactivate_all_safe(); - instance_activate_object(obj_star); - - instance_create(0, 0, obj_ncombat); - _roster = new Roster(); - var _pop_data = pop_data; - with (_roster) { - roster_location = _pop_data.loc; - roster_planet = _pop_data.planet; - determine_full_roster(); - only_locals(); - update_roster(); - if (array_length(selected_units)) { - setup_battle_formations(); - add_to_battle(); - } - } - delete _roster; - - mission_star = find_star_by_name(pop_data.loc); - - obj_ncombat.battle_object = mission_star; - instance_deactivate_object(obj_star); - obj_ncombat.battle_loc = pop_data.loc; - obj_ncombat.battle_id = pop_data.planet; - obj_ncombat.dropping = 0; - obj_ncombat.attacking = 0; - obj_ncombat.enemy = eFACTION.NECRONS; - obj_ncombat.threat = 1; - obj_ncombat.formation_set = 1; - obj_ncombat.battle_special = "necron_tomb_excursion"; - obj_ncombat.battle_data = pop_data; - if (battle == 1) { - obj_ncombat.battle_special = "wraith_attack"; - } else if (battle == 2) { - obj_ncombat.battle_special = "spyder_attack"; - } else if (battle == 3) { - obj_ncombat.battle_special = "stalker_attack"; - } else if (battle == 4) { - obj_ncombat.battle_special = "wake1_attack"; - } else if (battle == 5) { - obj_ncombat.battle_special = "wake2_attack"; - } else if (battle == 6) { - obj_ncombat.battle_special = "wake2_attack"; - } - - instance_destroy(); - } - - exit; -} - function set_gender() { return choose(eGENDER.FEMALE, eGENDER.MALE); } diff --git a/scripts/scr_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index d1af7ab898..0caf6aa4ab 100644 --- a/scripts/scr_post_battle_events/scr_post_battle_events.gml +++ b/scripts/scr_post_battle_events/scr_post_battle_events.gml @@ -1,64 +1,3 @@ -/// @self Asset.GMObject.obj_ncombat -/// @desc Resolves Necron Tomb combat and resumes or completes the mission. -/// @returns {Undefined} -function necron_tomb_raid_post_battle_sequence() { - if (!string_count("wake", battle_special)) { - if (defeat == 1) { - obj_controller.combat = 0; - obj_controller.cooldown = 10; - obj_turn_end.alarm[1] = 4; - } else if (defeat == 0) { - obj_controller.combat = 0; - var pip = instance_create(0, 0, obj_popup); - pip.pop_data = battle_data; - - with (pip) { - necron_tomb_mission_start(); - var _completed = advance_necron_tomb_mission(); - if (_completed) { - keyboard_clear(vk_enter); - } else { - text = "The last of the attackers is cut down. Your marines regroup in the tunnel and ready themselves to press deeper into the complex.\n\n" + text; - } - number = pop_data.number; - } - } - } else { - var pip = instance_create(0, 0, obj_popup); - with (pip) { - title = "Necron Tomb Awakens"; - image = "necron_army"; - if (obj_ncombat.defeat == 0) { - text = "Your marines make a tactical retreat back to the surface, hounded by Necrons all the way. The Inquisition mission is a failure- you were to blow up the Necron Tomb World stealthily, not wake it up. The Inquisition is not pleased with your conduct."; - } else { - text = "Your marines are killed down to the last man. The Inquisition mission is a failure- you were to blow up the Necron Tomb World stealthily, not wake it up. The Inquisition is not pleased with your conduct."; - } - } - - var _star_obj = find_star_by_name(battle_loc); - if (_star_obj != noone) { - with (_star_obj) { - var planet = obj_ncombat.battle_id; - if (remove_planet_problem(planet, "necron")) { - p_necrons[planet] = 4; - } - if (awake_tomb_world(p_feature[planet]) == 0) { - awaken_tomb_world(p_feature[planet]); - } - } - } - - pip.pop_data = battle_data; - - alter_disposition(eFACTION.INQUISITION, -5); - obj_controller.combat = 0; - - with (pip) { - number = pop_data.number; - } - } -} - function space_hulk_explore_battle_aftermath() { if (!defeat && hulk_treasure > 0) { var shi = 0, loc = ""; From 9f54d04e3edd391f9dae16b7acce8f9df7b173a6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 23 Sep 2026 00:56:37 +0100 Subject: [PATCH 016/118] Streamline Inquisition Demon World mission generation and UI Moves the Demon World problem creation logic directly into `scr_inquisition_mission`, eliminating a redundant helper function. Enhances `MissionHelper` to use dynamic function calls for mission acceptance, provide context-sensitive dialogue for demanded missions, and ensure popups close correctly. --- scripts/MissionHelper/MissionHelper.gml | 29 +++++++------------ .../scr_inquisition_mission.gml | 24 +++++++-------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 2f07a56d59..fa65729d93 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -1357,7 +1357,7 @@ static inquisition_mission_options = fuction(mission_accept_function){ { str1: "Accept", choice_func: function(){ - pop_data.mission[$ mission_accept_function], + pop_data.mission[$ mission_accept_function](); } }, ]; @@ -1370,24 +1370,17 @@ static inquisition_mission_options = fuction(mission_accept_function){ return _options } static inquisition_demon_world_init = fuction(){ - var text = $"The Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; - text += $" has been uncovered as a Demon World. The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; - var _options = [ - { - str1: "Accept", - choice_func: self.inquisition_demon_world_accept, - }, - { - str1: "Refuse", - choice_func: popup_default_close, - }, - ]; + var _text = $"The Inquisitor is trusting you with a special mission. The planet {p_data.name()} has been uncovered as a Demon World"; + if (obj_controller.demanding) { + _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {p_data.name()} must be cleansed within {timer} months."; + } + _text += $"The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; var _pop_data = { mission: self, - options: inquisition_mission_options(inquisition_demon_world_accept), + options: inquisition_mission_options("inquisition_demon_world_accept"), }; scr_popup( - "Inquisition Mission", + "Inquisition Mission Demon World", text, "inquisition", _pop_data @@ -1396,10 +1389,10 @@ static inquisition_demon_world_init = fuction(){ static inquisition_demon_world_accept = fuction(){ scr_event_log("", $"Inquisition Mission Accepted: The demon world of {system.name} {scr_roman(planet)} will be purged by your hand.", system.name); - if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {p_data.name()} must be cleansed within {timer} months."; - } new_star_event_marker("green"); + with(obj_popup){ + popup_default_close(); + } } } \ No newline at end of file diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 6839e85556..045bdaa6bb 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -108,25 +108,21 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA mission_inquisition_ethereal(); break; case eINQUISITION_MISSION.DEMON_WORLD: - mission_inquisition_demon_world(demon_worlds); + var _star = array_random_element(demon_worlds); + var _planet = -1; + for (var i = 1; i <= _star.planets; i++) { + if (_star.p_demons[i] > 1) { + _planet = i; + break; + } + } + var _eta = scr_mission_eta(_star.x, _star.y, 25); + _star.get_planet_data(_planet).new_problem("inquisition_demon_world", _eta) break; } } } -function mission_inquisition_demon_world(demon_worlds) { - var _star = choose_array(demon_worlds); - var _planet = -1; - for (var i = 1; i <= _star.planets; i++) { - if (_star.p_demons[i] > 1) { - _planet = i; - break; - } - } - var _eta = scr_mission_eta(_star.x, _star.y, 25); - _star.get_planet_data(_planet).new_problem("inquisition_demon_world", _eta) -} - function mission_inquisition_ethereal() { LOGGER.info("RE: Ethereal Capture"); var stars = scr_get_stars(); From 962cacd04ec977b5fbcf37a8768286d6b1af6b3a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 23 Sep 2026 00:57:47 +0100 Subject: [PATCH 017/118] Consolidate Mechanicus Mars mission resolution Moves the mission resolution logic for the Mechanicus Mars Catacombs mission from `scr_mechanicus_missions` into `MissionHelper.gml`. This centralizes the handling of unit assignment, mission outcomes, and fleet creation within `MissionHelper`, eliminating a redundant global helper function. --- scripts/MissionHelper/MissionHelper.gml | 42 ++++++++++- .../scr_mechanicus_missions.gml | 71 ------------------- 2 files changed, 41 insertions(+), 72 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index fa65729d93..8d7726c731 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -869,7 +869,47 @@ static mech_tomb_battle_aftermath = function() { } static resolve_mech_mars = function() { - mechanicus_mars_mission_target_time_elapsed(planet); + var _techs_taken = 0; + var _techs = collect_role_group([SPECIALISTS_TECHMARINES,false,true],system.name); + for (i = 0; i < array_length(_techs); i++) { + var _unit = _techs[i]; + system.p_player[planet] -= _unit.get_unit_size(); + _unit.location_string = "Mechanicus Vessel"; + _unit.planet_location = 0; + _unit.ship_location = -1; + _unit.job = { + type: "mechanicus mission", + }; + _techs_taken += 1; + } + + if (_techs_taken == 0) { + var alert_text = $"Mechanicus Mission Failed: Journey to Mars Catacombs at {p_data.name()}."; + scr_alert("red", "mission_failed", alert_text, 0, 0); + scr_event_log("red", alert_text); + alter_disposition(eFACTION.MECHANICUS,-10) + } else if (_techs_taken > 0) { + if (_techs_taken >= 5) { + alter_disposition(eFACTION.MECHANICUS,max(_techs_taken, 4)) + } + var _text = $"Mechanicus Ship departs for the Mars catacombs. Onboard are {_techs_taken} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s."; + scr_alert("", "mission", _text, 0, 0); + scr_event_log("green", _text); + var flit = create_enemy_fleet(system.x, system.y, eFACTION.MECHANICUS); + + with (flit) { + sprite_index = spr_fleet_mechanicus; + capital_number = 1; + image_index = 0; + image_speed = 0; + trade_goods = "mars_spelunk1"; + home_x = x; + home_y = y; + action_x = x + lengthdir_x(3000, obj_controller.terra_direction); + action_y = y + lengthdir_y(3000, obj_controller.terra_direction); + set_fleet_movement(false, "move", 48, 48); + } + } } diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 167a352061..16dd9630ca 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -230,74 +230,3 @@ function accept_mechanicus_mars_mission() { } reset_popup_options(); } - -/// @self Asset.GMObject.obj_star -function mechanicus_mars_mission_target_time_elapsed(planet) { - var techs_taken, com, ide, ship_planet, _unit; - techs_taken = 0; - com = -1; - ide = 0; - ship_planet = ""; - for (com = 0; com <= 10; com++) { - for (ide = 0; ide < array_length(obj_ini.TTRPG[com]); ide++) { - _unit = fetch_unit([com, ide]); - if (!is_struct(_unit)) { - continue; - } - if (_unit.role() == obj_ini.player_role_data[eROLE.TECHMARINE].role) { - // Case 1: on planet - if ((_unit.location_string == name) && (_unit.planet_location == planet)) { - p_player[planet] -= _unit.get_unit_size(); - _unit.location_string = "Mechanicus Vessel"; - _unit.planet_location = 0; - _unit.ship_location = -1; - _unit.job = { - type: "mechanicus mission", - }; - techs_taken += 1; - } - if (_unit.ship_location > -1) { - ship_planet = obj_ini.ship_location[_unit.ship_location]; - if (ship_planet == name) { - obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); - _unit.location_string = "Mechanicus Vessel"; - _unit.planet_location = 0; - _unit.ship_location = -1; - _unit.job = { - type: "mechanicus mission", - }; - techs_taken += 1; - } - } - } - } - } - if (techs_taken == 0) { - var alert_text = $"Mechanicus Mission Failed: Journey to Mars Catacombs at {planet_numeral_name(planet, id)}."; - scr_alert("red", "mission_failed", alert_text, 0, 0); - scr_event_log("red", alert_text); - obj_controller.disposition[3] -= 10; - remove_planet_problem(planet, "mech_mars"); - } else if (techs_taken > 0) { - if (techs_taken >= 5) { - obj_controller.disposition[3] += max(techs_taken, 4); - } - var _text = $"Mechanicus Ship departs for the Mars catacombs. Onboard are {techs_taken} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s."; - scr_alert("", "mission", _text, 0, 0); - scr_event_log("green", _text); - var flit = create_enemy_fleet(x, y, eFACTION.MECHANICUS); - - with (flit) { - sprite_index = spr_fleet_mechanicus; - capital_number = 1; - image_index = 0; - image_speed = 0; - trade_goods = "mars_spelunk1"; - home_x = x; - home_y = y; - action_x = x + lengthdir_x(3000, obj_controller.terra_direction); - action_y = y + lengthdir_y(3000, obj_controller.terra_direction); - set_fleet_movement(false, "move", 48, 48); - } - } -} From 50139bae209823bd9a19deeeb0ab82227cf7d10d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 23 Sep 2026 01:33:14 +0100 Subject: [PATCH 018/118] Refactor Inquisition Necron Tomb mission logic Centralizes the Necron Tomb mission's progression and combat aftermath logic into `MissionHelper.gml`. Renames the mission identifier from "necron" to "inquisition_necron" across the codebase for improved clarity and consistency. This change also updates mission stage tracking to use the `data` object for mission state. --- objects/obj_ncombat/Alarm_0.gml | 2 +- scripts/MissionHelper/MissionHelper.gml | 95 ++++++++++++------- scripts/scr_cheatcode/scr_cheatcode.gml | 2 +- .../scr_inquisition_mission.gml | 64 +++---------- .../scr_mission_functions.gml | 4 +- 5 files changed, 81 insertions(+), 86 deletions(-) diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 1e07954f27..66bfc1ff39 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -2883,7 +2883,7 @@ try { } // ** Necron Forces ** - if ((enemy == eFACTION.NECRONS) && ((string_count("_attack", battle_special) == 0))) { + if (enemy == eFACTION.NECRONS) { // Small Necron Group if (threat == 1) { u = instance_nearest(xxx, 240, obj_enunit); diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 8d7726c731..114962d234 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -84,7 +84,7 @@ static basic_turn_end = function(){ case "great_crusade": _func = resolve_great_crusade; break; - case "necron": + case "inquisition_necron": _func = resolve_necron; break; case "spyrer": @@ -217,7 +217,7 @@ static on_squad_selection = function(){ static __init(){ switch(p_id){ - case "necron": + case "inquisition_necron": mark("green"); break; case "meeting": @@ -1004,7 +1004,7 @@ static protect_raiders_battle_aftermath = function() { } } -static protect_raider_squad_selected = function() { +static protect_raider_squad_selected = function() { data.squad = data.squads[0]; var _squad = data.squad; var _squad_units = _squad.members; @@ -1149,11 +1149,12 @@ static per_turn_check_inqisition_tomb = function() { planet: planet, estimate: 999, number: _number, - data.mission_stage: 1, options: [ { str1: "Begin the Mission", - choice_func: self.necron_tomb_mission_start, + choice_func: function(){ + mission.necron_tomb_mission_start(); + }, }, { str1: "Not Yet", @@ -1165,7 +1166,7 @@ static per_turn_check_inqisition_tomb = function() { } static necron_tomb_mission_start = function() { - obj_popup.title = $"Necron Tunnels : {mission_stage}"; + obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; obj_popup.replace_options([{str1: "Continue", choice_func: self.necron_tomb_mission_sequence}, {str1: "Return to the surface", choice_func: popup_default_close}]); obj_popup.image = "necron_tunnels_1"; obj_popup.text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; @@ -1175,30 +1176,30 @@ static necron_tomb_mission_start = function() { /// @desc Advances the Necron Tomb mission or starts a combat encounter. /// @returns {Undefined} static necron_tomb_mission_sequence = function() { - var battle; + var _battle; var player_forces = system.player_forces; - var penalty = 0; + var _penalty = 0; var _roll = roll_dice_chapter(1, 100, "low"); - battle = 0; + _battle = 0; instance_activate_all(); // SMALL TEAM OF MARINES if (player_forces > 6) { - penalty = 10; + _penalty = 10; } if (player_forces > 10) { - penalty = 20; + _penalty = 20; } if (player_forces >= 20) { - penalty = 30; + _penalty = 30; } if (player_forces >= 40) { - penalty = 50; + _penalty = 50; } if (player_forces >= 60) { - penalty = 100; + _penalty = 100; } - _roll += penalty; + _roll += _penalty; // _roll=30;if (string_count("3",title)>0) then _roll=70; @@ -1210,31 +1211,31 @@ static necron_tomb_mission_sequence = function() { } if ((_roll > 60) && (_roll <= 82)) { // Necron Wraith attack - battle = 1; + _battle = 1; } if ((_roll > 82) && (_roll <= 92)) { // Tomb Spyder attack - battle = 2; + _battle = 2; } if ((_roll > 92) && (_roll <= 97)) { // Tomb Stalker - battle = 3; + _battle = 3; } if (_roll > 97) { // Tomb World wakes up data.tomb_awakens = true; if (player_forces <= 30) { - battle = 4; + _battle = 4; } if (player_forces > 30) { - battle = 5; + _battle = 5; } if (player_forces > 100) { - battle = 6; + _battle = 6; } } - if (battle > 0) { + if (_battle > 0) { instance_deactivate_all_safe(); instance_activate_object(obj_star); obj_ncombat.battle_special = "necron_tomb_excursion"; @@ -1244,7 +1245,7 @@ static necron_tomb_mission_sequence = function() { formation_set : 1, fortified : 0, } - switch (battle){ + switch (_battle){ case 1: _battle_data.cols = [ { @@ -1343,17 +1344,15 @@ static inquisition_tomb_battle_aftermath = function(){ } else if (defeat == 0) { obj_controller.combat = 0; var pip = instance_create(0, 0, obj_popup); - pip.pop_data = battle_data; - + necron_tomb_mission_start(); + var _completed = advance_necron_tomb_mission(); with (pip) { - necron_tomb_mission_start(); - var _completed = advance_necron_tomb_mission(); if (_completed) { keyboard_clear(vk_enter); } else { text = "The last of the attackers is cut down. Your marines regroup in the tunnel and ready themselves to press deeper into the complex.\n\n" + text; } - number = pop_data.number; + number = instance_exists(obj_turn_end); } } } else { @@ -1372,7 +1371,7 @@ static inquisition_tomb_battle_aftermath = function(){ if (_star_obj != noone) { with (_star_obj) { var planet = obj_ncombat.battle_id; - if (remove_planet_problem(planet, "necron")) { + if (remove_planet_problem(planet, "inquisition_necron")) { p_necrons[planet] = 4; } if (awake_tomb_world(p_feature[planet]) == 0) { @@ -1381,17 +1380,49 @@ static inquisition_tomb_battle_aftermath = function(){ } } - pip.pop_data = battle_data; - alter_disposition(eFACTION.INQUISITION, -5); obj_controller.combat = 0; with (pip) { - number = pop_data.number; + number = instance_exists(obj_turn_end); } } } +static advance_necron_tomb_mission = function() { + data.mission_stage++; + obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; + + if (data.mission_stage == 2) { + obj_popup.image = "necron_tunnels_2"; + obj_popup.text = "The energy readings are much stronger, now that your marines are deep inside the tunnels. What was once cramped is now luxuriously large, the tunnel ceiling far overhead decorated by stalactites."; + return false; + } + if (data.mission_stage == 3) { + obj_popup.image = "necron_tunnels_3"; + obj_popup.text = "After several hours of descent the entrance to the Necron Tomb finally looms ahead- dancing, sickly green light shining free. Your marine confirms that the Plasma Bomb is ready."; + return false; + } + if (data.mission_stage >= 4) { + obj_popup.image = ""; + obj_popup.title = "Inquisition Mission Completed"; + obj_popup.text = "Your marines finally enter the deepest catacombs of the Necron Tomb. There they place the Plasma Bomb and arm it. All around are signs of increasing Necron activity. With half an hour set, your men escape back to the surface. There is a brief rumble as the charge goes off, your mission a success."; + reset_popup_options(); + refresh_p_data(); + + alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); + + remove_planet_problem(planet, "inquisition_necron", system); + seal_tomb_world(p_data.features); + + scr_event_log("", $"Inquisition Mission Completed: Your Astartes have sealed the Necron Tomb on {p_data.name()}.", system.name); + p_data.add_disposition(irandom_range(3, 7)); + scr_check_equip("Plasma Bomb", system.name, planet, 1); + return true; + } + return false; +} + static inquisition_mission_options = fuction(mission_accept_function){ var _options = [ { diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 51cf9b2930..567fc5acbf 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -501,7 +501,7 @@ function draw_planet_debug_problems() { case "inquisitor": mission_inquistion_hunt_inquisitor(target.id); break; - case "necron": + case "inquisition_necron": mission_inquisition_tomb_world(target.id); break; case "mech_raider": diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 045bdaa6bb..7e026a54a1 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -206,7 +206,7 @@ function mission_inquisition_tomb_world(tomb_worlds) { system: _star.name, planet: planet, estimate: eta, - mission: "necron", + mission: "inquisition_necron", options: _options, }; @@ -219,13 +219,13 @@ function mission_inquisition_tomb_world(tomb_worlds) { /// @self Asset.GMObject.obj_popup function init_mission_inquisition_tomb_world() { - mission_star = find_star_by_name(pop_data.system); - var _p_data = mission_star.get_planet_data(pop_data.planet); - if (mission_star == noone) { + var _mission_star = find_star_by_name(pop_data.system); + var _p_data = _mission_star.get_planet_data(pop_data.planet); + if (_mission_star == noone) { popup_default_close(); exit; } - scr_event_log("", $"Inquisition Mission Accepted: {global.chapter_name} have been given a Bomb to seal the Necron Tomb on {_p_data.name()}.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: {global.chapter_name} have been given a Bomb to seal the Necron Tomb on {_p_data.name()}.", _mission_star.name); image = "necron_cave"; title = "New Equipment"; @@ -242,7 +242,7 @@ function init_mission_inquisition_tomb_world() { if (demand) { demand = 0; } - _p_data.new_problem("necron", estimate, {}); + _p_data.new_problem("inquisition_necron", estimate, {}); exit; } @@ -314,32 +314,32 @@ function mission_inquistion_hunt_inquisitor(star_id = noone) { /// @self Asset.GMObject.obj_popup function init_mission_hunt_inquisitor() { - mission_star = find_star_by_name(pop_data.system); - if (mission_star == noone) { + var _mission_star = find_star_by_name(pop_data.system); + if (_mission_star == noone) { popup_default_close(); exit; } - scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {pop_data.mission_data.inquisitor_name} enroute to {mission_star.name} must be removed. Estimated arrival in {pop_data.estimate} months.", mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {pop_data.mission_data.inquisitor_name} enroute to {_mission_star.name} must be removed. Estimated arrival in {pop_data.estimate} months.", _mission_star.name); - var _radical_inquisitor_fleet = create_enemy_fleet(mission_star.x - irandom_range(-400, 400), mission_star.y - irandom_range(-400, 400), eFACTION.INQUISITION); + var _radical_inquisitor_fleet = create_enemy_fleet(_mission_star.x - irandom_range(-400, 400), _mission_star.y - irandom_range(-400, 400), eFACTION.INQUISITION); with (_radical_inquisitor_fleet) { base_inquis_fleet(); } fleet_add_cargo("radical_inquisitor", pop_data.mission_data, true, _radical_inquisitor_fleet); - _radical_inquisitor_fleet.action_x = mission_star.x; - _radical_inquisitor_fleet.action_y = mission_star.y; + _radical_inquisitor_fleet.action_x = _mission_star.x; + _radical_inquisitor_fleet.action_y = _mission_star.y; var _est = pop_data.estimate; with (_radical_inquisitor_fleet) { set_fleet_movement(false, "move", _est, _est); } - var _p_data = mission_star.get_planet_data(pop_data.planet); + var _p_data = _mission_star.get_planet_data(pop_data.planet); _p_data.add_problem(pop_data.mission, pop_data.estimate,pop_data.mission_data) title = "Inquisition Mission Accepted"; - text = $"{global.chapter_name} will intercept the radical Inquisitor {pop_data.mission_data.inquisitor_name} at {mission_star.name}, expected within {pop_data.estimate} months."; + text = $"{global.chapter_name} will intercept the radical Inquisitor {pop_data.mission_data.inquisitor_name} at {_mission_star.name}, expected within {pop_data.estimate} months."; reset_popup_options(); } @@ -702,42 +702,6 @@ function mission_investigate_planet() { scr_popup("Inquisition Recon", text, "inquisition", $"recon|{string(_star.name)}|{string(planet)}|{string(eta)}|"); } -/// @self Asset.GMObject.obj_popup -/// @desc Advances the Necron Tomb mission and renders the resulting popup state. -/// @returns {Bool} Whether the mission reached completion. -function advance_necron_tomb_mission() { - pop_data.mission_stage++; - title = $"Necron Tunnels : {pop_data.mission_stage}"; - - if (pop_data.mission_stage == 2) { - image = "necron_tunnels_2"; - text = "The energy readings are much stronger, now that your marines are deep inside the tunnels. What was once cramped is now luxuriously large, the tunnel ceiling far overhead decorated by stalactites."; - return false; - } - if (pop_data.mission_stage == 3) { - image = "necron_tunnels_3"; - text = "After several hours of descent the entrance to the Necron Tomb finally looms ahead- dancing, sickly green light shining free. Your marine confirms that the Plasma Bomb is ready."; - return false; - } - if (pop_data.mission_stage >= 4) { - image = ""; - title = "Inquisition Mission Completed"; - text = "Your marines finally enter the deepest catacombs of the Necron Tomb. There they place the Plasma Bomb and arm it. All around are signs of increasing Necron activity. With half an hour set, your men escape back to the surface. There is a brief rumble as the charge goes off, your mission a success."; - reset_popup_options(); - - alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - - mission_star = find_star_by_name(pop_data.loc); - remove_planet_problem(planet, "necron", mission_star); - seal_tomb_world(mission_star.p_feature[planet]); - - scr_event_log("", $"Inquisition Mission Completed: Your Astartes have sealed the Necron Tomb on {mission_star.name} {scr_roman(planet)}.", mission_star.name); - scr_gov_disp(mission_star.name, planet, irandom_range(3, 7)); - scr_check_equip("Plasma Bomb", pop_data.loc, pop_data.planet, 1); - return true; - } - return false; -} function set_gender() { return choose(eGENDER.FEMALE, eGENDER.MALE); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 825a80d896..afd58f5435 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -36,7 +36,7 @@ global.planet_problem_keys = [ "purge", "tyranid_org", "artifact_loan", - "necron", + "inquisition_necron", "ethereal", "demon_world", ]; @@ -70,7 +70,7 @@ function mission_name_key(mission) { "tyranid_org": "Capture Tyranid for Inquisitor", // "bomb" : "Bombard World for Inquisitor", "artifact_loan": "Safeguard Artifact for the Inquisition", - "necron": "Bomb Necron Tomb for Inquisitor", + "inquisition_necron": "Bomb Necron Tomb for Inquisitor", "ethereal": "Capture Ethereal for Inquisitor", "demon_world": "Clear Demon World for Inquisitor", }; From 4b03eda3ebd780b5e4e894c6c806690b268c66e4 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 23 Sep 2026 01:57:14 +0100 Subject: [PATCH 019/118] Refactor planet data access through `PlanetData` object Migrates various scripts to consistently retrieve and interact with planet data using the `PlanetData` object's methods. This change replaces direct array access and deprecated global helper functions (such as `has_problem_planet`) with encapsulated method calls (`has_feature`, `has_problem`, `name`, `new_problem`, `remove_problem`). This improves code readability, maintainability, and strengthens the encapsulation of planet-specific logic. --- objects/obj_drop_select/Create_0.gml | 5 ++- objects/obj_temp7/Alarm_0.gml | 8 ++-- scripts/MissionHelper/MissionHelper.gml | 38 +++++++++---------- .../scr_drop_select_function.gml | 21 +++++----- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 4 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 9 +++-- .../scr_inquisition_mission.gml | 2 +- .../scr_mission_functions.gml | 16 +------- 8 files changed, 47 insertions(+), 56 deletions(-) diff --git a/objects/obj_drop_select/Create_0.gml b/objects/obj_drop_select/Create_0.gml index 4bf9159e25..0a294fe30d 100644 --- a/objects/obj_drop_select/Create_0.gml +++ b/objects/obj_drop_select/Create_0.gml @@ -155,6 +155,7 @@ btn_back.button_color = CM_GREEN_COLOR; btn_back.width = 90; if (purge == 0) { + var _p_data = p_target.get_planet_data(planet_number); sisters = p_target.p_sisters[planet_number]; eldar = p_target.p_eldar[planet_number]; ork = p_target.p_orks[planet_number]; @@ -211,11 +212,11 @@ if (purge == 0) { } var spesh = false; - if ((planet_feature_bool(p_target.p_feature[planet_number], eP_FEATURES.WARLORD10) == 1) && (obj_controller.faction_defeated[10] == 0) && (obj_controller.faction_gender[10] == 1) && (obj_controller.known[eFACTION.CHAOS] > 0) && (obj_controller.turn >= obj_controller.chaos_turn)) { + if ((_p_data.has_feature(eP_FEATURES.WARLORD10)) && (obj_controller.faction_defeated[10] == 0) && (obj_controller.faction_gender[10] == 1) && (obj_controller.known[eFACTION.CHAOS] > 0) && (obj_controller.turn >= obj_controller.chaos_turn)) { spesh = true; } - if (has_problem_planet(planet_number, "tyranid_org", p_target)) { + if (_p_data.has_problem("tyranid_org")) { tyranids = 2; attacking = 9; } diff --git a/objects/obj_temp7/Alarm_0.gml b/objects/obj_temp7/Alarm_0.gml index 3791505b73..0e53c19454 100644 --- a/objects/obj_temp7/Alarm_0.gml +++ b/objects/obj_temp7/Alarm_0.gml @@ -3,18 +3,18 @@ if (num > 0) { var stah; stah = instance_nearest(x, y, obj_star); obj_controller.menu = 0; - - if (has_problem_planet(num, "recon", stah)) { + var _p_data = stah.get_planet_data(num); + if (_p_data.has_problem("recon")) { var pop; pop = instance_create(0, 0, obj_popup); pop.image = "inquisition"; pop.title = "Investigation Completed"; - pop.text = "Your marines have scouted out " + string(stah.name) + " " + string(scr_roman(num)) + " and satisfied the mission requirements."; + pop.text = $"Your marines have scouted out {_p_data.name()} and satisfied the mission requirements."; pop.add_option("Reload Marines"); pop.add_option("Do Nothing"); - scr_event_log("", "Inquisition Mission Completed: Your Astartes have succesfully scouted " + string(stah.name) + " " + scr_roman(num) + "."); + scr_event_log("", $"Inquisition Mission Completed: Your Astartes have succesfully scouted {_p_data.name()}."); remove_planet_problem(num, "recon", stah); } diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 114962d234..5e2d84e649 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -933,7 +933,7 @@ static init_garrison_mission = function() { scr_event_log("", $"Garrison committed to {_numeral_name} for {_garrison_length} months.", p_data.system.name); } -static complete_garrison_mission= function() { +static complete_garrison_mission = function() { if (stage_id != "active"){ exit; } @@ -1026,10 +1026,10 @@ static protect_raider_squad_selected = function() { if (!_wis_test[0]) { scr_toggle_manage(); if (_wis_test[1] < -25) { - 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"; + var _gar_pop = instance_create(0, 0, obj_popup); + _gar_pop.title = $"Strange Disappearance"; + _gar_pop.pdata = p_data; + _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"; var _dead_marine = array_random_index(_squad_units); for (var i = 0; i < array_length(_dead_marine); i++) { if (i == _dead_marine) { @@ -1042,24 +1042,24 @@ static protect_raider_squad_selected = function() { _marine.ship_location = -1; _marine.planet_location = 0; } - gar_pop.text += $"After eventual investigation it appears the eldar anticipated the would be ambushers and turned the tides. {_squad_units[_dead_marine].name_role()}s body is eventually discovered some way off from the main battle his rent armour and body showing the extent of combat that must have occured"; + _gar_pop.text += $"After eventual investigation it appears the eldar anticipated the would be ambushers and turned the tides. {_squad_units[_dead_marine].name_role()}s body is eventually discovered some way off from the main battle his rent armour and body showing the extent of combat that must have occured"; - gar_pop.text += "\nThe total loss of a squad in what was meant to be a routine operation is bad for moral and your chapters reputation you must now decide how to proceed"; + _gar_pop.text += "\nThe total loss of a squad in what was meant to be a routine operation is bad for moral and your chapters reputation you must now decide how to proceed"; - gar_pop.add_option({str1: "Suppress the Information", choice_func: protect_raiders_suppress_information}); + _gar_pop.add_option({str1: "Suppress the Information", choice_func: protect_raiders_suppress_information}); - gar_pop.add_option({str1: "Hold a Memorial", choice_func: protect_raiders_hold_memorial}); + _gar_pop.add_option({str1: "Hold a Memorial", choice_func: protect_raiders_hold_memorial}); } else { - var gar_pop = instance_create(0, 0, obj_popup); - gar_pop.title = $"Ineffective Ambush"; - gar_pop.text = $"Your Marines Are ineffective at setting up an ambush the assailants clearly got wind of the operation or the plan was otherwise so ill thought out that by the time your forces arrived there was little that could be done to intercept them"; - gar_pop.text += $""; - gar_pop.pathway = "protect_raiders_ineffective"; - gar_pop.pdata = pdata; - pdata.add_disposition(-10); - gar_pop.text += "\nThe governor is unhappy and it has done little to improve your reputation with the planets populace but otherwise very little harm has been done. It is likely the raiders will choose better targets without the possible threat of space marine presence for the foreseeable future\nGovernor Disposition : -10"; - - gar_pop.add_option("continue"); + var _gar_pop = instance_create(0, 0, obj_popup); + _gar_pop.title = $"Ineffective Ambush"; + _gar_pop.text = $"Your Marines Are ineffective at setting up an ambush the assailants clearly got wind of the operation or the plan was otherwise so ill thought out that by the time your forces arrived there was little that could be done to intercept them"; + _gar_pop.text += $""; + _gar_pop.pathway = "protect_raiders_ineffective"; + _gar_pop.pdata = p_data; + p_data.add_disposition(-10); + _gar_pop.text += "\nThe governor is unhappy and it has done little to improve your reputation with the planets populace but otherwise very little harm has been done. It is likely the raiders will choose better targets without the possible threat of space marine presence for the foreseeable future\nGovernor Disposition : -10"; + + _gar_pop.add_option("continue"); } } else { var _battle = new_battle(eFACTION.ELDAR) 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 eeadcd9840..a0146a5db4 100644 --- a/scripts/scr_drop_select_function/scr_drop_select_function.gml +++ b/scripts/scr_drop_select_function/scr_drop_select_function.gml @@ -231,6 +231,7 @@ function drop_select_unit_selection() { btn_attack.draw(); if (btn_attack.clicked()) { if (purge == 0) { + var _p_data = p_target.get_planet_data(planet_number); if (formation_current < 0 || formation_current >= array_length(formation_possible)) { exit; } @@ -271,22 +272,22 @@ function drop_select_unit_selection() { if (obj_ncombat.battle_object.space_hulk == 1) { obj_ncombat.battle_special = "space_hulk"; } - if ((planet_feature_bool(_planet, eP_FEATURES.WARLORD6) == 1) && (obj_ncombat.enemy == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0)) { + if ((_p_data.has_feature(eP_FEATURES.WARLORD6)) && (obj_ncombat.enemy == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0)) { obj_ncombat.leader = 1; } - if (obj_ncombat.enemy == eFACTION.ORK && planet_feature_bool(_planet, eP_FEATURES.ORKWARBOSS)) { + if (obj_ncombat.enemy == eFACTION.ORK && _p_data.has_feature(eP_FEATURES.ORKWARBOSS)) { obj_ncombat.leader = 1; obj_ncombat.ork_warboss = _planet[search_planet_features(_planet, eP_FEATURES.ORKWARBOSS)[0]]; } if ((obj_ncombat.enemy == eFACTION.TYRANIDS) && (obj_ncombat.battle_object.space_hulk == 0)) { - if (has_problem_planet(planet_number, "tyranid_org", p_target)) { + if (_p_data.has_problem("tyranid_org")) { obj_ncombat.battle_special = "tyranid_org"; } } if (obj_ncombat.enemy == eFACTION.HERETICS) { - if (planet_feature_bool(obj_ncombat.battle_object.p_feature[obj_ncombat.battle_id], eP_FEATURES.CHAOSWARBAND) == 1) { + if (_p_data.has_feature(eP_FEATURES.CHAOSWARBAND)) { obj_ncombat.battle_special = "ChaosWarband"; obj_ncombat.leader = 1; } @@ -396,9 +397,7 @@ function drop_select_unit_selection() { _purge_score = roster.selected_count(); } - var _p_data = p_target.system_datas[planet_number]; - - _p_data.refresh_data(); + var _p_data = p_target.get_planet_data(planet_number); _p_data.purge(purge, _purge_score); } @@ -415,6 +414,7 @@ function drop_select_draw() { // God, save us; if (menu == eMENU.DEFAULT) { if (purge == 1) {} else if (purge >= 2) { + var _p_data = p_target.get_planet_data(planet_number); draw_set_halign(fa_center); draw_set_font(fnt_40k_30b); @@ -431,13 +431,13 @@ function drop_select_draw() { "Selective Purging {0}", "Assassinate Governor ({0})", ]; - var _planet_string = planet_numeral_name(planet_number, p_target); + var _planet_string = _p_data.name(); draw_text_transformed(x2 + 14, y2 + 12, string(_purge_strings[purge - 2], _planet_string), 0.6, 0.6, 0); // Disposition here var pp = planet_number; - var succession = has_problem_planet(pp, "succession", p_target); + var succession = _p_data.has_problem("succession"); if (((p_target.dispo[pp] >= 0) && (p_target.p_owner[pp] <= eFACTION.ECCLESIARCHY) && (p_target.p_population[pp] > 0)) && (!succession)) { var wack = 0; @@ -501,6 +501,7 @@ function collect_local_units() { purge_d = ship_max[500]; if (purge == 1) { + var _p_data = p_target.get_planet_data(planet_number); if (sh_target != noone) { max_ships = sh_target.capital_number + sh_target.frigate_number + sh_target.escort_number; @@ -581,7 +582,7 @@ function collect_local_units() { var pp = planet_number; purge_d = p_target.p_type[pp] != "Dead"; - if (has_problem_planet(pp, "succession", p_target)) { + if (_p_data.has_problem("succession")) { purge_d = 0; } 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 ab40093eeb..f9c3bd0f0d 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -89,7 +89,7 @@ if (array_length(p_problem[i]) == 0){ var _pdata = get_planet_data(i); if (((p_tyranids[i] == 3) || (p_tyranids[i] == 4)) && (p_population[i] > 0)) { - if (!has_problem_planet(i, "Hive Fleet")) { + if (!_pdata.has_problem("Hive Fleet")) { var roll = irandom_range(100, 300); var cont = 0; @@ -101,7 +101,7 @@ if (array_length(p_problem[i]) == 0){ } if (cont == 1) { - _pdata.add_problem("Hive Fleet", irandom_range(60, 120) + irandom_range(80, 120)); + _pdata.new_problem("Hive Fleet", irandom_range(60, 120) + irandom_range(80, 120)); var xx = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; var yy = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; 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 dcfcce692a..6401d98deb 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -513,6 +513,7 @@ function scr_enemy_ai_e() { var chaos_meeting = 0; for (var run = 1; run <= planets; run++) { + var _p_data = get_planet_data(run); var forces_list = []; var force_count = 0; if (p_player[run] > 0 && struct_exists(obj_controller.location_viewer.garrison_log, name)) { @@ -522,9 +523,9 @@ function scr_enemy_ai_e() { if (p_player[run] > 0 && force_count > 0) { if (p_player[run] > 0) { - if (has_problem_planet(run, "meeting")) { + if (_p_data.has_problem( "meeting")) { chaos_meeting = run; - } else if (has_problem_planet(run, "meeting_trap")) { + } else if (_p_data.has_problem( "meeting_trap")) { chaos_meeting = run + 0.1; } } @@ -573,13 +574,13 @@ function scr_enemy_ai_e() { } break; case 10: - pause = has_problem_planet(run, "meeting") || has_problem_planet(run, "meeting_trap"); + pause = _p_data.has_problem( "meeting") || _p_data.has_problem( "meeting_trap"); if (p_guardsmen[run] + p_pdf[run] == 0 && p_player[run] > 0 && p_chaos[run] > 0 && !pause && obj_controller.faction_status[10] == "War") { battle_opponent = 10; } break; case 11: - pause = has_problem_planet(run, "meeting") || has_problem_planet(run, "meeting_trap"); + pause = _p_data.has_problem( "meeting") || _p_data.has_problem( "meeting_trap"); if (p_guardsmen[run] + p_pdf[run] == 0 && p_player[run] > 0 && p_traitors[run] > 0 && !pause && obj_controller.faction_status[10] == "War") { battle_opponent = 11; } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 7e026a54a1..80f7eace69 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -336,7 +336,7 @@ function init_mission_hunt_inquisitor() { set_fleet_movement(false, "move", _est, _est); } var _p_data = _mission_star.get_planet_data(pop_data.planet); - _p_data.add_problem(pop_data.mission, pop_data.estimate,pop_data.mission_data) + _p_data.new_problem(pop_data.mission, pop_data.estimate,pop_data.mission_data) title = "Inquisition Mission Accepted"; text = $"{global.chapter_name} will intercept the radical Inquisitor {pop_data.mission_data.inquisitor_name} at {_mission_star.name}, expected within {pop_data.estimate} months."; diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index afd58f5435..9af23c829b 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -141,7 +141,7 @@ function scr_new_governor_mission(planet, problem = "") { } } var _p_data = get_planet_data(planet); - _p_data.add_problem(problem, 20 + irandom(20),mission_data); + _p_data.new_problem(problem, 20 + irandom(20),mission_data); } } @@ -227,7 +227,7 @@ function has_problem_star(problem, star = noone) { var has_problem = false; if (star == noone) { for (var i = 1; i <= planets; i++) { - has_problem = has_problem_planet(i, problem); + has_problem = get_planet_data(i).has_problem(problem); if (has_problem) { has_problem = true; break; @@ -241,18 +241,6 @@ function has_problem_star(problem, star = noone) { return has_problem; } -//returns a bool for if a planet has a given problem -/// @self Asset.GMObject.obj_star -function has_problem_planet(planet, problem, star = noone) { - if (star == noone) { - return array_contains(p_problem[planet], problem); - } else { - with (star) { - return has_problem_planet(planet, problem); - } - } -} - //returns the array position of a given problem on a given planet if the specfied time is given /// @self Asset.GMObject.obj_star function has_problem_planet_and_time(planet, problem, time, star = noone) { From 290be04e0367f94159a613fd93cbc3abe44f71d1 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 23 Sep 2026 14:07:59 +0100 Subject: [PATCH 020/118] Refactor mission unit selection and assignment Centralizes the logic for assigning units to missions and initializing mission-specific behaviors. Previously, `scr_manage_task_selector` directly handled unit job assignment and called mission initialization functions. This commit refactors that process by delegating these responsibilities to `MissionHelper`'s new `on_unit_selection` method. The selector now collects selected units and passes them to the mission helper, which then assigns jobs via `set_members_job_to_mission` and initiates the mission. This improves encapsulation, reduces coupling, and makes mission setup more modular. --- scripts/MissionHelper/MissionHelper.gml | 111 +++++++++++++----- .../scr_manage_task_selector.gml | 43 ++----- 2 files changed, 92 insertions(+), 62 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 5e2d84e649..6f115df80f 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -13,13 +13,19 @@ p_data = planet; planet = p_data.planet; system = p_data.system; f_type = eP_FEATURES.MISSION; +members = []; static refresh_p_data = function(){ p_data = system.get_planet_data(planet); } + stage_id = ""; if (struct_exists(data, "stage")){ stage_id = data.stage; } +if (struct_exists(data, "members")){ + members = data.members; +} + extend_timer_for_warp_storm = true; remove = false; zero_timer_checks = true; @@ -142,33 +148,6 @@ static increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } -static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, enemy_data = undefined){ - var _battle_index = obj_turn_end.battles++; - obj_turn_end.battle[_battle_index] = 1; - obj_turn_end.battle_world[_battle_index] = planet; - obj_turn_end.battle_opponent[_battle_index] = battle_opponent_id; - obj_turn_end.battle_location[_battle_index] = system.name; - obj_turn_end.battle_object[_battle_index] = system; - obj_turn_end.battle_special[_battle_index] = { - special_id : special_id, - special_feature : self - }; - if (!is_undefined(enemy_data)){ - obj_turn_end.battle_special[_battle_index].battle_enemy_data = enemy_data; - } -} - -static new_battle = function(battle_opponent_id,special_id = p_id){ - var _battle = instance_create(0, 0, obj_ncombat); - _battle.enemy = battle_opponent_id; - _battle.battle_object = system; - _battle.battle_loc = system.name; - _battle.battle_id = planet; - _battle.battle_special = special_id; - _battle.special_feature = self; - return _battle; -} - static after_battle_effects = function(){ instance_activate_object(obj_star); var _func = undefined; @@ -215,6 +194,30 @@ static on_squad_selection = function(){ instance_deactivate_object(obj_star); } + +static on_unit_selection = function(){ + var _func = undefined; + switch(p_id){ + case "hunt_beast": + _func = init_beast_hunt_mission; + break; + case "train_forces": + _func = init_train_forces_mission; + } + if (!is_undefined(_func)){ + if (struct_exists(obj_controller.selection_data, "selections")){ + members = obj_controller.selection_data.selections; + } + refresh_p_data(); + try { + _func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + instance_deactivate_object(obj_star); +} + static __init(){ switch(p_id){ case "inquisition_necron": @@ -247,13 +250,54 @@ static __init(){ } __init(); +static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, enemy_data = undefined){ + var _battle_index = obj_turn_end.battles++; + obj_turn_end.battle[_battle_index] = 1; + obj_turn_end.battle_world[_battle_index] = planet; + obj_turn_end.battle_opponent[_battle_index] = battle_opponent_id; + obj_turn_end.battle_location[_battle_index] = system.name; + obj_turn_end.battle_object[_battle_index] = system; + obj_turn_end.battle_special[_battle_index] = { + special_id : special_id, + special_feature : self + }; + if (!is_undefined(enemy_data)){ + obj_turn_end.battle_special[_battle_index].battle_enemy_data = enemy_data; + } +} + +static new_battle = function(battle_opponent_id,special_id = p_id){ + var _battle = instance_create(0, 0, obj_ncombat); + _battle.enemy = battle_opponent_id; + _battle.battle_object = system; + _battle.battle_loc = system.name; + _battle.battle_id = planet; + _battle.battle_special = special_id; + _battle.special_feature = self; + return _battle; +} + +static set_members_job_to_mission = function(){ + for (var i = 0; i < array_length(members); i++){ + var _unit = members[i]; + _unit.job = { + type: p_id, + planet: planet, + location: system.name, + }; + _unit.unload(planet, system); + } +} + + static init_beast_hunt_mission = function() { if (stage_id == "preliminary") { + set_members_job_to_mission(); var _numeral_name = p_data.name() stage_id = "active"; var _mission_length = irandom_range(2, 5); - timer[planet][mission_slot] = _mission_length; + timer = _mission_length; var _gar_pop = instance_create(0, 0, obj_popup); //TODO some new MissonHelper methods for popups _gar_pop.title = $"Marines assigned to hunt beasts around {_numeral_name}"; @@ -263,6 +307,7 @@ static init_beast_hunt_mission = function() { _gar_pop.cooldown = 8; obj_controller.cooldown = 20; scr_event_log("", $"Beast hunters deployed to {_numeral_name} for {_mission_length} months.", p_data.system.name); + obj_controller.close_popups = false; } } @@ -335,10 +380,11 @@ static complete_beast_hunt_mission = function() { } -stati init_train_forces_mission = fuction(marine) { - if (stage_id != "preliminary") { +stati init_train_forces_mission = fuction() { + if (stage_id != "preliminary" || array_length(members) = 0) { exit; } + var _trainer = members[0]; var _numeral_name = p_data.name(); stage_id = "active"; var _mission_length = irandom_range(3, 12); @@ -347,8 +393,8 @@ stati init_train_forces_mission = fuction(marine) { 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 = marine.has_role(eROLE.CAPTAIN); + _gar_pop.text = $"{_trainer.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 = _trainer.has_role(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)"; @@ -363,6 +409,7 @@ stati init_train_forces_mission = fuction(marine) { _gar_pop.cooldown = 500; obj_controller.cooldown = 500; scr_event_log("", $"{marine.name_role()} deployed to {_numeral_name} for {_mission_length} months.", p_data.system.name); + obj_controller.close_popups = false; } static complete_train_forces_mission = function() { diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 7637bb1a0b..3b0d337668 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -19,13 +19,14 @@ function scr_manage_task_selector() { exit; } } + var _man_count; if (selection_data.select_type == eMISSION_SELECT_TYPE.UNITS) { - man_count = array_sum(man_sel); + _man_count = array_sum(man_sel); } else { - man_count = array_length(company_data.selected_squads); + _man_count = array_length(company_data.selected_squads); } if (selection_data.purpose_code != "manage") { - if (man_count == 0 || man_count > selection_data.number) { + if (_man_count == 0 || _man_count > selection_data.number) { proceed_button.draw_shutter(1110, 70, "Proceed", 0.5, false); } else if (proceed_button.draw_shutter(1110, 70, "Proceed", 0.5, true)) { if (selection_data.select_type == eMISSION_SELECT_TYPE.UNITS) { @@ -58,8 +59,7 @@ function task_selector_squad_manage() { /// @self Asset.GMObject.obj_controller function task_selector_man_manage() { - man_count = array_sum(man_sel); - selections = []; + var _selections = []; for (var i = 0; i < array_length(display_unit); i++) { if (ma_name[i] == "") { continue; @@ -67,6 +67,7 @@ function task_selector_man_manage() { /// @type {Struct.TTRPG_stats} var _unit = display_unit[i]; if (man_sel[i]) { + array_push(_selections, _unit); switch (selection_data.purpose_code) { case "forge_assignment": var _forge = selection_data.feature; @@ -131,26 +132,6 @@ function task_selector_man_manage() { managing = selection_data.target_company; update_general_manage_view(); exit; - case "hunt_beast": - _unit.job = { - type: selection_data.purpose_code, - planet: selection_data.planet, - location: selection_data.system.name, - }; - _unit.unload(selection_data.planet, selection_data.system); - break; - case "train_forces": - _unit.job = { - type: selection_data.purpose_code, - planet: selection_data.planet, - location: selection_data.system.name, - }; - _unit.unload(selection_data.planet, selection_data.system); - var _problem = selection_data.feature; - _problem.init_train_forces_mission(_unit); - obj_controller.close_popups = false; - exit_adhoc_manage(); - exit; case "artifact_equip": scr_toggle_lib(); var _arti = fetch_artifact(selection_data.artifact); @@ -175,15 +156,17 @@ function task_selector_man_manage() { } } } + selection_data.selections = _selections; + if (struct_exists(selection_data, "feature")){ + var _feat = selection_data.feature; + if (is_struct(_feat) && is_instanceof(_feat, PlanetProblem){ + _feat.on_unit_selection(); + } + } switch (selection_data.purpose_code) { case "forge_assignment": specialist_point_handler.calculate_research_points(); break; - case "hunt_beast": - var _problem = selection_data.feature; - _problem.init_beast_hunt_mission(); - obj_controller.close_popups = false; - break; } exit_adhoc_manage(); exit; From 5c0daf937066d4b253b0b2ed2d65a3cefb2a880d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Wed, 23 Sep 2026 18:44:01 +0100 Subject: [PATCH 021/118] Refactor PlanetProblem lifecycle and event handling Introduces a centralized mechanism for managing PlanetProblem lifecycle events, including turn-end checks, battle preparation, and mission completion/refusal. This refactors the execution of mission-specific functions using 'handle_triggered_mission_func' to ensure consistent error handling and standardize problem deletion. A new 'before_battle_effects' hook integrates mission-specific logic directly into the pre-combat phase. The "Tyranid Organism" mission serves as a primary example, with its initiation, acceptance, and battle setup logic now consolidated within MissionHelper, removing previous scattered implementations in obj_popup and obj_ncombat. --- objects/obj_ncombat/Alarm_0.gml | 2 +- objects/obj_popup/Step_0.gml | 20 -- scripts/MissionHelper/MissionHelper.gml | 313 ++++++++++-------- scripts/scr_PlanetData/scr_PlanetData.gml | 4 - .../scr_drop_select_function.gml | 6 +- .../scr_manage_task_selector.gml | 2 +- 6 files changed, 181 insertions(+), 166 deletions(-) diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 66bfc1ff39..8125106d18 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -1701,7 +1701,7 @@ try { // ** Tyranid Forces ** // Tyranid story event - if ((enemy == eFACTION.TYRANIDS) || (battle_special == "tyranid_org")) { + if (enemy == eFACTION.TYRANIDS) { u = instance_nearest(xxx, 240, obj_enunit); enemy_dudes = "81"; u.dudes[1] = "Termagaunt"; diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index 9bd33eac49..a7404bfa70 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -260,26 +260,6 @@ try { if (demand) { text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Spyrer on Hive {_mission_star.name} {scr_roman(onceh)} must be removed within {estimate} months."; } - } else if (mission == "tyranid_org") { - image = "webber"; - title = "New Equipment"; - fancy_title = 0; - text_center = 0; - text = $"{global.chapter_name} have been provided with 4x Astartes Webbers in order to complete the mission."; - - if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture a Gaunt organism and return it, unharmed- 4x Webbers have been provided for this purpose."; - } - - reset_popup_options(); - scr_add_item("Webber", 4); - obj_controller.cooldown = 10; - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wishes for the capture of a particular strain Gaunt noticed on {_mission_star.name} {scr_roman(planet)} is advisable.", _mission_star.name); - obj_controller.useful_info += "Tyr|"; - if (demand) { - demand = 0; - } - exit; } else if (mission == "ethereal") { with (obj_star) { if ((p_tau[1] >= 4) || (p_tau[2] >= 4) || (p_tau[3] >= 4) || (p_tau[4] >= 4)) { diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 6f115df80f..c790d3d991 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -1,7 +1,3 @@ -function MissionHelper() constructor{ - -} - function SystemProblem(name, timer, data){} function PlanetProblem(name, timer, data, planet) constructor{ @@ -14,6 +10,7 @@ planet = p_data.planet; system = p_data.system; f_type = eP_FEATURES.MISSION; members = []; +delete = false; static refresh_p_data = function(){ p_data = system.get_planet_data(planet); } @@ -31,6 +28,29 @@ remove = false; zero_timer_checks = true; per_turn_checks = true; + +static handle_triggered_mission_func = function(func){ + if (!is_undefined(func)){ + refresh_p_data(); + try { + func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + if (timer == -1 || (delete)){ + var _prob = -1; + for (var i = 0; i < array_length(system.p_problem); i++){ + if (system.p_problem[i] == self){ + _prob = i; + } + } + if (_prob > -1){ + array_delete(system.p_problem, _prob,0); + array_delete(p_data.problems, _prob,0); + } + } +} static basic_turn_end = function(){ refresh_p_data(); if (p_data.system.storm - 1 > 0){ @@ -62,15 +82,7 @@ static basic_turn_end = function(){ per_turn_check_inqisition_tomb; break; } - if (!is_undefined(_func)){ - refresh_p_data(); - try { - _func(); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } - + handle_triggered_mission_func(_func) } if ((timer == 0) && zero_timer_checks) { var _func = undefined; @@ -114,14 +126,7 @@ static basic_turn_end = function(){ case "provide_garrison": _func = complete_garrison_mission; } - if (!is_undefined(_func)){ - refresh_p_data(); - try { - _func(); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } + handle_triggered_mission_func(_func) } } @@ -148,6 +153,18 @@ static increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } +static before_battle_effects = function(){ + instance_activate_object(obj_star); + var _func = undefined; + switch(p_id){ + case "iquisition_tyranid_org": + _func = iquisition_tyranid_org_setup_battle; + break; + } + handle_triggered_mission_func(_func); + instance_deactivate_object(obj_star); +} + static after_battle_effects = function(){ instance_activate_object(obj_star); var _func = undefined; @@ -165,14 +182,7 @@ static after_battle_effects = function(){ inquisition_tomb_battle_aftermath; break; } - if (!is_undefined(_func)){ - refresh_p_data(); - try { - _func(); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } + handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } @@ -183,14 +193,7 @@ static on_squad_selection = function(){ _func = protect_raider_squad_selected; break; } - if (!is_undefined(_func)){ - refresh_p_data(); - try { - _func(); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } + handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } @@ -208,12 +211,7 @@ static on_unit_selection = function(){ if (struct_exists(obj_controller.selection_data, "selections")){ members = obj_controller.selection_data.selections; } - refresh_p_data(); - try { - _func(); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } + handle_triggered_mission_func(_func); } instance_deactivate_object(obj_star); } @@ -413,101 +411,103 @@ stati init_train_forces_mission = fuction() { } static complete_train_forces_mission = function() { - if (stage_id == "active") { - var _mission_string = ""; - var _trainer = fetch_unit_uid(data.assigned_unit); - if (is_struct(_trainer)) { - var _unit_report_string = ""; - var _tester = global.character_tester; - var _wis_test_difficulty = -20; - var _tyannic_vet = _trainer.has_trait("tyrannic_vet"); - if (_tyannic_vet) { - _wis_test_difficulty += 10; - if (p_data.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - var _cult = p_data.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; - if (_cult.hiding) { - p_data.delete_feature(eP_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; - } - var _brute = _trainer.has_trait("brute"); - if (_brute) { - _wis_test_difficulty -= 10; + if (stage_id != "active") { + exit; + } + var _mission_string = ""; + var _trainer = fetch_unit_uid(data.assigned_unit); + if (is_struct(_trainer)) { + exit; + } + var _unit_report_string = ""; + var _tester = global.character_tester; + var _wis_test_difficulty = -20; + var _tyannic_vet = _trainer.has_trait("tyrannic_vet"); + if (_tyannic_vet) { + _wis_test_difficulty += 10; + if (p_data.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + var _cult = p_data.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; + if (_cult.hiding) { + p_data.delete_feature(eP_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; + } + var _brute = _trainer.has_trait("brute"); + if (_brute) { + _wis_test_difficulty -= 10; + } - var _leader = _trainer.has_trait("natural_leader"); - if (_leader) { - _wis_test_difficulty += 10; - } + var _leader = _trainer.has_trait("natural_leader"); + if (_leader) { + _wis_test_difficulty += 10; + } - var _unit_pass = _tester.standard_test(_trainer, "wisdom", _wis_test_difficulty); - if (_unit_pass[0]) { - var _new_pdf = p_data.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) { - var _disp_gain = 10; - p_data.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})"; - } - 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)"; - p_data.alter_fortification(1); - } else { - 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"; - _mission_string += "The new insights have allowed for minor improvements to planetary fortifications (fortification +1)"; - p_data.alter_fortification(1); - } - } - } else { - var 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 += "."; - - _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])) { - _hard_loss = true; - } - } - if (_hard_loss) { - _mission_string += $"His particularly grueling regimes and standards imposed upon the senior officers of the pdf caused friction with physical injury being caused to one officer"; - disp_loss = -25; - _mission_string += "(disposition -25)"; - } + var _unit_pass = _tester.standard_test(_trainer, "wisdom", _wis_test_difficulty); + if (_unit_pass[0]) { + var _new_pdf = p_data.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) { + var _disp_gain = 10; + p_data.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})"; + } + 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)"; + p_data.alter_fortification(1); + } else { + 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"; + _mission_string += "The new insights have allowed for minor improvements to planetary fortifications (fortification +1)"; + p_data.alter_fortification(1); + } + } + } else { + var 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 += "."; + + _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])) { + _hard_loss = true; } - p_data.add_disposition(disp_loss); } - _mission_string += $"\n{_unit_report_string}"; - scr_popup($"Training Forces on {p_data.name()}", _mission_string, "", ""); + if (_hard_loss) { + _mission_string += $"His particularly grueling regimes and standards imposed upon the senior officers of the pdf caused friction with physical injury being caused to one officer"; + disp_loss = -25; + _mission_string += "(disposition -25)"; + } } - _trainer.job = "none"; + p_data.add_disposition(disp_loss); } + _mission_string += $"\n{_unit_report_string}"; + scr_popup($"Training Forces on {p_data.name()}", _mission_string, "", ""); + _trainer.job = "none"; } static resolve_succession = function() { @@ -770,7 +770,7 @@ static per_turn_check_mech_raider = function() { var _techs = collect_role_group(SPECIALISTS_TECHS, [system.name, planet, -1]); var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); if ((array_length(_techs) >= 6) && (_lr_count >= 1)) { - var _percent_complete = increment_mission_completion(data); + var _percent_complete = increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { p_data.remove_problem(p_id); @@ -794,7 +794,7 @@ static per_turn_check_mech_bionics = function() { var _units = p_data.collect_planet_group(); var _bionics = _units.tally_attr("bionics"); if (_bionics >= 10) { - var _percent_complete = increment_mission_completion(data); + var _percent_complete = increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { p_data.remove_problem(p_id); @@ -1285,7 +1285,6 @@ static necron_tomb_mission_sequence = function() { if (_battle > 0) { instance_deactivate_all_safe(); instance_activate_object(obj_star); - obj_ncombat.battle_special = "necron_tomb_excursion"; var _col = []; var _battle_data = { threat : 1, @@ -1482,7 +1481,10 @@ static inquisition_mission_options = fuction(mission_accept_function){ if (!obj_controller.demanding){ array_push(_options, { str1: "Refuse", - choice_func: popup_default_close, + choice_func: function(){ + pop_data.mission.destroy = true; + popup_default_close; + } }) } return _options @@ -1513,4 +1515,43 @@ static inquisition_demon_world_accept = fuction(){ } } -} \ No newline at end of file +static inquisition_tyranid_org_init = fuction(){ + var _pop_data = { + mission: self, + options: inquisition_mission_options("inquisition_tyranid_org_accept"), + }; + var _text = $"An Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; + _text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; + if (obj_controller.demanding) { + _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture a Gaunt organism and return it, unharmed- 4x Webbers have been provided for this purpose."; + } + scr_popup("Inquisition Mission", _text, "inquisition",_pop_data); +} + +static inquisition_tyranid_org_accept = fuction(){ + + obj_popup.image = "webber"; + obj_popup.title = "New Equipment"; + obj_popup.fancy_title = 0; + obj_popup.text_center = 0; + obj_popup.text = $"{global.chapter_name} have been provided with 4x Astartes Webbers in order to complete the mission."; + reset_popup_options(); + scr_add_item("Webber", 4); + obj_controller.cooldown = 10; + scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wishes for the capture of a particular strain Gaunt noticed on {p_data.name()} is advisable.", system.name); + obj_controller.useful_info += "Tyr|"; + if (demand) { + demand = 0; + +} + + +static iquisition_tyranid_org_setup_battle = function(){ + if ((obj_ncombat.enemy != eFACTION.TYRANIDS) || (obj_ncombat.battle_object.space_hulk)) { + exit; + } + obj_ncombat.battle_special = p_id; +} + + + diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 77116286a4..8d444eab3b 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -799,10 +799,6 @@ function PlanetData(_planet, _system) constructor { for (var i = array_length(problems) -1; i >= 0; i--) { var _problem = problems[i]; _problem.basic_turn_end(); - if (problem.timer == -1){ - array_delete(system.p_problem[i], i,0); - array_delete(problems, i,0); - } } } 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 a0146a5db4..5adce517df 100644 --- a/scripts/scr_drop_select_function/scr_drop_select_function.gml +++ b/scripts/scr_drop_select_function/scr_drop_select_function.gml @@ -280,10 +280,8 @@ function drop_select_unit_selection() { obj_ncombat.ork_warboss = _planet[search_planet_features(_planet, eP_FEATURES.ORKWARBOSS)[0]]; } - if ((obj_ncombat.enemy == eFACTION.TYRANIDS) && (obj_ncombat.battle_object.space_hulk == 0)) { - if (_p_data.has_problem("tyranid_org")) { - obj_ncombat.battle_special = "tyranid_org"; - } + for (var i=0; i Date: Wed, 23 Sep 2026 20:37:53 +0100 Subject: [PATCH 022/118] Refactor mission termination to use `delete` flag This change unifies how missions are marked for completion, failure, or refusal. Instead of directly invoking `remove_planet_problem`, missions now set a `delete` flag. This allows for a centralized and consistent processing of mission removal in the lifecycle. Includes a typo fix for `inquisition_tyranid_org_setup_battle` and ensures `after_battle_effects` correctly calls the aftermath function for relevant missions. --- scripts/MissionHelper/MissionHelper.gml | 104 ++++++++++++------------ 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index c790d3d991..e01f7d1b71 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -84,7 +84,7 @@ static basic_turn_end = function(){ } handle_triggered_mission_func(_func) } - if ((timer == 0) && zero_timer_checks) { + if ((timer == 0) && zero_timer_checks && !delete) { var _func = undefined; switch(p_id){ case "hunt_beast": @@ -158,7 +158,7 @@ static before_battle_effects = function(){ var _func = undefined; switch(p_id){ case "iquisition_tyranid_org": - _func = iquisition_tyranid_org_setup_battle; + _func = inquisition_tyranid_org_setup_battle; break; } handle_triggered_mission_func(_func); @@ -179,8 +179,10 @@ static after_battle_effects = function(){ _func = hunt_fallen_battle_aftermath; break; case "inquisition_tomb": - inquisition_tomb_battle_aftermath; + _func = inquisition_tomb_battle_aftermath; break; + case "tyranid_org": + _func = inquisition_tyranid_org_battle_aftermath } handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); @@ -656,7 +658,7 @@ static spyrer_battle_aftermath = function(){ exit; } - remove_planet_problem(planet, "spyrer", system); + delete = true; var _tixt = $"The Spyrer on {p_data.name()} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; @@ -714,11 +716,10 @@ static per_turn_check_fallen = function() { _battle_enemy_data ); } else { - if (remove_planet_problem(run, "fallen")) { - var _tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; - scr_popup("Hunt the Fallen", _tixt, "fallen", ""); - scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run, id)}"); - } + delete = true; + var _tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; + scr_popup("Hunt the Fallen", _tixt, "fallen", ""); + scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run, id)}"); } } } @@ -751,9 +752,7 @@ function hunt_fallen_battle_aftermath() { if (obj_ncombat.defeat) { exit; } - - var _p_data = battle_object.get_planet_data("fallen"); - _p_data.remove_problem("fallen"); + delete = true; var _tixt = "The Fallen on " + _p_data.name(); scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; @@ -773,7 +772,7 @@ static per_turn_check_mech_raider = function() { var _percent_complete = increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { - p_data.remove_problem(p_id); + delete = true; scr_mission_reward("mech_raider", system, planet); timer = -1 per_turn_checks = false; @@ -787,7 +786,7 @@ static resolve_mech_raider_failed = function() { scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); p_data.alter_disposition(eFACTION.MECHANICUS, -6); - p_data.remove_problem(p_id); + delete = true; } static per_turn_check_mech_bionics = function() { @@ -797,7 +796,7 @@ static per_turn_check_mech_bionics = function() { var _percent_complete = increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { - p_data.remove_problem(p_id); + delete = true; scr_mission_reward("mech_bionics", id, planet); timer = -1 per_turn_checks = false; @@ -811,7 +810,7 @@ static resolve_mech_bionics_failed = function() { scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); p_data.alter_disposition(eFACTION.MECHANICUS, -6); - p_data.remove_problem(p_id); + delete = true; } static per_turn_check_mech_tomb2 = function() { @@ -844,7 +843,7 @@ static per_turn_check_mech_tomb2 = function() { scr_popup("Mechanicus Mission Failed", $"The Mechanicus Research team on planet {p_data.name()} have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); p_data.alter_disposition(eFACTION.MECHANICUS, -25); - p_data.remove_problem(p_id); + delete = true; } } else { if (_roll1 > 20) { @@ -867,7 +866,7 @@ static per_turn_check_mech_tomb2 = function() { } _text += "\n" + add_disposition(eFACTION.MECHANICUS, 1); scr_popup("Mechanicus Mission Completed", _text, "mechanicus", ""); - p_data.remove_problem(p_id); + delete = true; timer = -1 per_turn_checks = false; zero_timer_checks = false; @@ -890,28 +889,29 @@ static resolve_mech_tomb1_failed = function() { scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); p_data.alter_disposition(eFACTION.MECHANICUS, -15); - p_data.remove_problem(p_id); + delete = true; } static mech_tomb_battle_aftermath = function() { if (obj_ncombat.defeat) { - if (remove_planet_problem(battle_id, "mech_tomb", battle_object)) { - var _disp_change = alter_disposition(eFACTION.MECHANICUS, -10); + delete = true; - if (data.battle_key == "study2a") { - scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust, and the Adeptus Mechanicus is furious with your chapter for not providing enough security. Relations with them are worse than before. {_disp_change}", "", ""); - } - if (data.battle_key == "study2b") { - battle_object.p_necrons[battle_id] = 5; - awaken_tomb_world(battle_object.p_feature[battle_id]); - _disp_change = alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]]); - scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust. To make matters worse the Necron Tomb has fully awakened- countless numbers of the souless machines are now pouring out of the tomb. The Adeptus Mechanicus are furious with your chapter. {_disp_change}", "necron_army", ""); - scr_alert("", "inqi", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); - scr_event_log("", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb"); - } + var _disp_change = alter_disposition(eFACTION.MECHANICUS, -10); - scr_event_log("", "Mechanicus Mission Failed: Necron Tomb Research Party and present astartes have been killed."); + if (data.battle_key == "study2a") { + scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust, and the Adeptus Mechanicus is furious with your chapter for not providing enough security. Relations with them are worse than before. {_disp_change}", "", ""); + } + if (data.battle_key == "study2b") { + battle_object.p_necrons[battle_id] = 5; + awaken_tomb_world(battle_object.p_feature[battle_id]); + _disp_change = alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]]); + scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust. To make matters worse the Necron Tomb has fully awakened- countless numbers of the souless machines are now pouring out of the tomb. The Adeptus Mechanicus are furious with your chapter. {_disp_change}", "necron_army", ""); + scr_alert("", "inqi", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); + scr_event_log("", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb"); } + + scr_event_log("", "Mechanicus Mission Failed: Necron Tomb Research Party and present astartes have been killed."); + } } @@ -1036,7 +1036,7 @@ static protect_raiders_battle_aftermath = function() { // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); // title / text / image / speshul var _planet_string = p_data.name(); - p_data.remove_problem("protect_raiders"); + delete = true; if (!obj_ncombat.defeat) { p_data.add_disposition(15); var _tixt = $"The Raiding forces on {_planet_string} have been removed. The citizens and craftsman may sleep more soundly. ({_planet_string} disp +15)"; @@ -1413,19 +1413,17 @@ static inquisition_tomb_battle_aftermath = function(){ } } - var _star_obj = find_star_by_name(battle_loc); - if (_star_obj != noone) { - with (_star_obj) { - var planet = obj_ncombat.battle_id; - if (remove_planet_problem(planet, "inquisition_necron")) { - p_necrons[planet] = 4; - } - if (awake_tomb_world(p_feature[planet]) == 0) { - awaken_tomb_world(p_feature[planet]); - } + delete = true; + + with (system) { + var _planet = obj_ncombat.battle_id; + p_necrons[planet] = 4; + if (awake_tomb_world(p_feature[_planet]) == 0) { + awaken_tomb_world(p_feature[_planet]); } } + alter_disposition(eFACTION.INQUISITION, -5); obj_controller.combat = 0; @@ -1458,7 +1456,7 @@ static advance_necron_tomb_mission = function() { alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - remove_planet_problem(planet, "inquisition_necron", system); + delete = true; seal_tomb_world(p_data.features); scr_event_log("", $"Inquisition Mission Completed: Your Astartes have sealed the Necron Tomb on {p_data.name()}.", system.name); @@ -1475,6 +1473,7 @@ static inquisition_mission_options = fuction(mission_accept_function){ str1: "Accept", choice_func: function(){ pop_data.mission[$ mission_accept_function](); + obj_controller.demanding = 0; } }, ]; @@ -1482,8 +1481,8 @@ static inquisition_mission_options = fuction(mission_accept_function){ array_push(_options, { str1: "Refuse", choice_func: function(){ - pop_data.mission.destroy = true; - popup_default_close; + pop_data.mission.delete = true; + popup_default_close(); } }) } @@ -1529,7 +1528,6 @@ static inquisition_tyranid_org_init = fuction(){ } static inquisition_tyranid_org_accept = fuction(){ - obj_popup.image = "webber"; obj_popup.title = "New Equipment"; obj_popup.fancy_title = 0; @@ -1540,18 +1538,20 @@ static inquisition_tyranid_org_accept = fuction(){ obj_controller.cooldown = 10; scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wishes for the capture of a particular strain Gaunt noticed on {p_data.name()} is advisable.", system.name); obj_controller.useful_info += "Tyr|"; - if (demand) { - demand = 0; - } -static iquisition_tyranid_org_setup_battle = function(){ +static inquisition_tyranid_org_setup_battle = function(){ if ((obj_ncombat.enemy != eFACTION.TYRANIDS) || (obj_ncombat.battle_object.space_hulk)) { exit; } obj_ncombat.battle_special = p_id; } +static inquisition_tyranid_org_battle_aftermath = function(){ + +} +} + From deaea1020d04af08bf739e63aa4816ef90982e8e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 14:00:02 +0100 Subject: [PATCH 023/118] cleanup and scope --- scripts/MissionHelper/MissionHelper.gml | 45 +++++++++---------- scripts/scr_PlanetData/scr_PlanetData.gml | 21 --------- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 +- .../scr_inquisition_mission.gml | 6 +-- .../scr_mission_functions.gml | 5 ++- 5 files changed, 28 insertions(+), 51 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index e01f7d1b71..1c414b19fd 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -28,6 +28,28 @@ remove = false; zero_timer_checks = true; per_turn_checks = true; +static mark = function(colour){ + refresh_p_data(); + with (p_data.system){ + new_star_event_marker(colour) + } +} + +static description = function(){ + return mission_name_key(p_id); +} + +static increment_mission_completion = function() { + if (!struct_exists(data, "completion")) { + data.completion = 0; + } + data.completion++; + if (!struct_exists(data, "required_months") || data.required_months <= 0) { + LOGGER.error("Invalid required_months in mission_data"); + return 0; + } + return (data.completion / data.required_months) * 100; +} static handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ @@ -130,29 +152,6 @@ static basic_turn_end = function(){ } } -static mark = function(colour){ - refresh_p_data(); - with (p_data.system){ - new_star_event_marker(colour) - } -} - -static description = function(){ - return mission_name_key(p_id); -} - -static increment_mission_completion = function() { - if (!struct_exists(data, "completion")) { - data.completion = 0; - } - data.completion++; - if (!struct_exists(data, "required_months") || data.required_months <= 0) { - LOGGER.error("Invalid required_months in mission_data"); - return 0; - } - return (data.completion / data.required_months) * 100; -} - static before_battle_effects = function(){ instance_activate_object(obj_star); var _func = undefined; diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 8d444eab3b..74ed2245b7 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -728,13 +728,6 @@ function PlanetData(_planet, _system) constructor { } }; - deamons = system.p_demons[planet]; - chaos_forces = system.p_chaos[planet]; - - requests_help = system.p_halp[planet]; - - corruption = system.p_heresy[planet]; - static alter_corruption = function(value) { alter_planet_corruption(value, planet, system); corruption = system.p_heresy[planet]; @@ -745,20 +738,6 @@ function PlanetData(_planet, _system) constructor { 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]; - static has_problem = function(problem) { for (var i = 0; i < array_length(problems); i++){ if (problems[i].p_id == problem){ 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 f9c3bd0f0d..6dd75af548 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -119,7 +119,7 @@ if (array_length(p_problem[i]) == 0){ fleet.action_x = x; fleet.action_y = y; - fleet.action_eta = p_timer[i][firstest]; + fleet.action_eta = p_problem[i][firstest].timer; fleet.action = "move"; } } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 80f7eace69..5dee992a3b 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -369,7 +369,7 @@ function resolve_radical_inquisitor_mission(_mission_data) { continue; } - var _stored_data = p_problem_other_data[_planet][i]; + var _stored_data = p_problem[_planet][i].data; if (!is_struct(_stored_data) || !struct_exists(_stored_data, "mission_id")) { continue; } @@ -378,9 +378,7 @@ function resolve_radical_inquisitor_mission(_mission_data) { continue; } - p_problem[_planet][i] = ""; - p_timer[_planet][i] = -1; - p_problem_other_data[_planet][i] = {}; + p_problem[_planet][i].delete = true; _mission_removed = true; break; } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 9af23c829b..7009007a89 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -247,8 +247,9 @@ function has_problem_planet_and_time(planet, problem, time, star = noone) { var _had_problem = -1; if (star == noone) { for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] == problem) { - if (p_timer[planet][i] == time) { + var _prob = p_problem[planet][i]; + if (_prob.p_id == problem) { + if (_prob.timer == time) { _had_problem = i; } } From 23d29113855d6494976da5188422d97c0b89e0ac Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 16:18:01 +0100 Subject: [PATCH 024/118] Centralize mission battle outcome processing Refactors battle-related logic into the `PlanetProblem` system via `MissionHelper` callbacks, allowing missions to manage their state more effectively during and after combat. This moves responsibility for handling fortification/power reduction, enemy casualty processing, and final battle messages from `obj_ncombat` to the active `PlanetProblem` instance. Includes: * Integrating `battle_on_enemy_casulties` and `battle_final_message` hooks. * Centralizing `reduce_fortification` and `reduce_power` flags. * Moving `captured_gaunt` variable and logic to the `Tyranid Organism` mission's data. * Consistently renaming "fallen" missions to "hunt_fallen" and "inquisition_tomb" to "inquisition_necron". * Replacing `choose_array` with `array_random_element`. --- docs/CHEATCODES.md | 1 - objects/obj_ncombat/Alarm_0.gml | 2 +- objects/obj_ncombat/Alarm_1.gml | 4 +- objects/obj_ncombat/Alarm_5.gml | 54 +------- objects/obj_ncombat/Create_0.gml | 3 +- scripts/MissionHelper/MissionHelper.gml | 131 +++++++++++++----- scripts/scr_cheatcode/scr_cheatcode.gml | 6 +- .../scr_choose_weighted.gml | 4 - scripts/scr_flavor/scr_flavor.gml | 3 - .../scr_inquisition_mission.gml | 41 +++--- .../scr_mission_functions.gml | 4 +- scripts/scr_random_event/scr_random_event.gml | 2 +- scripts/scr_shoot/scr_shoot.gml | 14 ++ 13 files changed, 147 insertions(+), 122 deletions(-) diff --git a/docs/CHEATCODES.md b/docs/CHEATCODES.md index fc333cdd6e..7f33aa9817 100644 --- a/docs/CHEATCODES.md +++ b/docs/CHEATCODES.md @@ -71,7 +71,6 @@ Arguments with stars `(argument*)` can be omitted. - `mechmission (mission*)` - triggers a mechaniicus mission, can be run as is or with an optional missiono parameter to specify a particular mission - `mech_mars` - `mech_raider` - - `mech_bionics` ### Disposition: diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 8125106d18..9587650f2d 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -1976,7 +1976,7 @@ try { } // ** Chaos Forces ** - if ((enemy == eFACTION.CHAOS) && (battle_special != "ship_demon") && (battle_special != "fallen") && (battle_special != "WL10_reveal") && (battle_special != "WL10_later") && (string_count("cs_meeting_battle", battle_special) == 0)) { + if ((enemy == eFACTION.CHAOS) && (battle_special != "ship_demon") && (battle_special != "WL10_reveal") && (battle_special != "WL10_later") && (string_count("cs_meeting_battle", battle_special) == 0)) { // Small Chaos Cult Group if (threat == 1) { u = instance_nearest(xxx, 240, obj_enunit); diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index a43c2ba0a0..364c3f98e0 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -101,7 +101,7 @@ if (battle_special == "spyrer") { if (battle_special == "protect_raiders", battle_special) { p1 = "Following responses from scans, Your marine squad deploys and lies in wait on the planets surface. Either the eldar were expecting you or the scope of the raids on the planet had been underplayed by the governor perhaps to hide his incompetence in allowing such foul xenos actions to persist unchecked for so long."; } -if (string_count("fallen", battle_special) > 0) { +if (battle_special == "hunt_fallen") { p1 = "Your marines search through the alleyways and dens likely to contain the Fallen. Several days pass before the search is succesful; the prey is located by Auspex and closed in upon. "; if (battle_climate == "Lava") { p1 = "Your marines search through the broken craggs and spires of the molten planet. Among the bubbling lava, and cracking earth, they search for the Fallen. After several days of searching Auspex detect the prey. "; @@ -127,7 +127,7 @@ if (string_count("fallen", battle_special) > 0) { p1 += " Your ranks are made up of "; } -if ("inquisition_tomb" == battle_special) { +if ("inquisition_necron" == battle_special) { var wh = choose(1, 2); if (wh == 1) { p1 = "Cave dirt crunches beneath the soles of your marines as they continue their descent. There is little warning before "; diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index c644dc2522..a1ee02d87f 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -282,13 +282,6 @@ if (slime > 0) { instance_activate_object(obj_star); -var reduce_fortification = true; -if (battle_special == "tyranid_org") { - reduce_fortification = false; -} -if (string_count("_attack", battle_special) > 0) { - reduce_fortification = false; -} if (battle_special == "ship_demon") { reduce_fortification = false; } @@ -301,12 +294,6 @@ if (battle_special == "ruins") { if (battle_special == "ruins_eldar") { reduce_fortification = false; } -if (battle_special == "fallen") { - reduce_fortification = false; -} -if (battle_special == "mars_tomb") { - reduce_fortification = false; -} if ((fortified > 0) && (!instance_exists(obj_nfort)) && (reduce_fortification == true)) { var _fortification_text = $"Fortification level of {p_data.name()}"; @@ -355,28 +342,21 @@ if (string_count("ruins", battle_special) > 0) { combat_log.push(_newline, eMSG_COLOR.YELLOW); } -var _reduce_power = true; - // Events that should *not* reduce power var _non_power_reduce_events = [ - "tyranid_org", "ship_demon", "space_hulk", - "fallen", - "protect_raiders", - "mars_tomb" ]; // Disable power reduction for matching events if (array_contains(_non_power_reduce_events, battle_special)) { - _reduce_power = false; -} else if (string_count("_attack", battle_special) > 0) { - _reduce_power = false; + reduce_power = false; +} } else if (string_count("ruins", battle_special) > 0) { - _reduce_power = false; + reduce_power = false; } -if (defeat == 0 && _reduce_power) { +if (defeat == 0 && reduce_power) { var enemy_power = 0, new_power = 0, power_reduction = 0, requisition_reward = 0; if (enemy == eFACTION.IMPERIUM) { @@ -561,30 +541,10 @@ if (defeat == 0 && _reduce_power) { } } -if ((defeat == 0) && (enemy == eFACTION.TYRANIDS) && (battle_special == "tyranid_org")) { - _newline = $"{string_plural_count("Gaunt organism", captured_gaunt)} have been captured."; - combat_log.push(_newline, eMSG_COLOR.YELLOW); - - if (captured_gaunt > 0) { - var why = 0, thatta = 0; - instance_activate_object(obj_star); - var _p_data = battle_object.get_planet_data(battle_id); - _p_data.remove_problem("tyranid_org"); - } - - scr_event_log("", "Inquisition Mission Completed: A Gaunt organism has been captured for the Inquisition."); - - if (captured_gaunt > 1) { - if (instance_exists(obj_turn_end)) { - scr_popup("Inquisition Mission Completed", "You have captured several Gaunt organisms. The Inquisitor is pleased with your work, though she notes that only one is needed- the rest are to be purged. It will be stored until it may be retrieved. The mission is a success.", "inquisition", ""); - } - } - if (captured_gaunt == 1) { - if (instance_exists(obj_turn_end)) { - scr_popup("Inquisition Mission Completed", "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success.", "inquisition", ""); - } +if (battle_special != ""){ + if (is_struct(special_feature), && is_instanceof(special_feature, PlanetProblem)){ + special_feature.battle_final_message(); } - instance_deactivate_object(obj_star); } _newline = line_break; diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index cd82e55ac9..de659a327b 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -30,6 +30,8 @@ end_alive_units = []; average_battle_exp_gain = 0; upgraded_librarians = []; special_feature = undefined; +reduce_fortification = true; +reduce_power = true; view_x = obj_controller.x; view_y = obj_controller.y; @@ -76,7 +78,6 @@ stage_elapsed2 = 0; battle_over = 0; done = 0; -captured_gaunt = 0; ethereal = 0; hulk_treasure = 0; four_show = 0; diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 1c414b19fd..16303f6641 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -100,7 +100,7 @@ static basic_turn_end = function(){ case "spyrer": _func = per_turn_check_spyrer; break; - case "inquisition_tomb": + case "inquisition_necron": per_turn_check_inqisition_tomb; break; } @@ -125,12 +125,12 @@ static basic_turn_end = function(){ _func = resolve_great_crusade; break; case "inquisition_necron": - _func = resolve_necron; + _func = resolve_inquisitor_necron; break; case "spyrer": _func = resolve_spyrer; break; - case "fallen": + case "hunt_fallen": _func = resolve_fallen; break; case "mech_raider"; @@ -152,8 +152,9 @@ static basic_turn_end = function(){ } } +//triggered within drop select static before_battle_effects = function(){ - instance_activate_object(obj_star); + instance_activate_object(obj_star); var _func = undefined; switch(p_id){ case "iquisition_tyranid_org": @@ -164,6 +165,39 @@ static before_battle_effects = function(){ instance_deactivate_object(obj_star); } + +//triggered at the end of scr_shoot +static battle_on_enemy_casulties = function(){ + if (!struct_exists(self, casualty_packet)){ + exit; + } + instance_activate_object(obj_star); + var _func = undefined; + switch(p_id){ + case "iquisition_tyranid_org": + _func = inquisition_tyranid_on_enemy_casulties; + break; + } + handle_triggered_mission_func(_func); + + struct_remove(self, "casualty_packet"); + + instance_deactivate_object(obj_star); +} + +//triggers in obj_ncombat alarm 5 +static battle_final_message = function(){ + instance_activate_object(obj_star); + var _func = undefined; + switch(p_id){ + case "iquisition_tyranid_org": + _func = inquisition_tyranid_org_battle_final_message; + break; + } + handle_triggered_mission_func(_func); + instance_deactivate_object(obj_star); +} + static after_battle_effects = function(){ instance_activate_object(obj_star); var _func = undefined; @@ -174,11 +208,11 @@ static after_battle_effects = function(){ case "protect_raiders": _func = protect_raiders_battle_aftermath; break; - case "fallen": + case "hunt_fallen": _func = hunt_fallen_battle_aftermath; break; - case "inquisition_tomb": - _func = inquisition_tomb_battle_aftermath; + case "inquisition_necron": + _func = inquisition_necron_battle_aftermath; break; case "tyranid_org": _func = inquisition_tyranid_org_battle_aftermath @@ -233,7 +267,7 @@ static __init(){ scr_event_log("", $"Chaos Lord {obj_controller.faction_leader[eFACTION.CHAOS]} agrees to meet with you on {p_data.name()} to discuss an alliance."); mark("purple"); break; - case "fallen": + case "hunt_fallen": break; case "harlequins": var _text = $"Eldar Harlequins have been seen on planet {p_data.name()}. Their purposes are unknown."; @@ -242,6 +276,9 @@ static __init(){ break; case "inquisition_demon_world": inquisition_demon_world_init(); + break; + case "tyranid_org": + inquisition_tyranid_org_init(); default: mark("green"); @@ -249,6 +286,7 @@ static __init(){ } __init(); +// by default mission battles do not reduce the fortification level or enemy power on a planet static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, enemy_data = undefined){ var _battle_index = obj_turn_end.battles++; obj_turn_end.battle[_battle_index] = 1; @@ -260,9 +298,17 @@ static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, ene special_id : special_id, special_feature : self }; - if (!is_undefined(enemy_data)){ - obj_turn_end.battle_special[_battle_index].battle_enemy_data = enemy_data; + if (is_undefined(enemy_data)){ + enemy_data = { + } } + if (!struct_exists(enemy_data, "reduce_power")){ + enemy_data.reduce_power = false, + } + if (!struct_exists(enemy_data, "reduce_fortification")){ + enemy_data.reduce_fortification = false, + } + obj_turn_end.battle_special[_battle_index].battle_enemy_data = enemy_data; } static new_battle = function(battle_opponent_id,special_id = p_id){ @@ -602,7 +648,7 @@ static resolve_great_crusade = function() { } } -static resolve_necron = function() { +static resolve_inquisitor_necron = function() { alter_disposition(eFACTION.INQUISITION, -8); var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); @@ -711,7 +757,7 @@ static per_turn_check_fallen = function() { } new_end_turn_battle( 10, - "fallen", + p_id, _battle_enemy_data ); } else { @@ -1121,6 +1167,8 @@ static protect_raider_squad_selected = function() { _battle.battle_enemy_data = { threat : 3, fortified : false, + reduce_fortification : true, + reduce_power : true, cols : [ { distance : 20, @@ -1156,24 +1204,6 @@ static protect_raider_squad_selected = function() { } } -static capture_tyranid_org_battle_aftermath = function(){ - if (obj_ncombat.defeat){ - exit; - } - if (obj_ncombat.captured_gaunt > 1) { - var _pop = instance_create(0, 0, obj_popup); - _pop.image = "inquisition"; - _pop.title = "Inquisition Mission Completed"; - _pop.text = "You have captured several Gaunt organisms. The Inquisitor is pleased with your work, though she notes that only one is needed- the rest are to be purged. It will be stored until it may be retrieved. The mission is a success."; - } - else if (obj_ncombat.captured_gaunt == 1) { - var _pop = instance_create(0, 0, obj_popup); - _pop.image = "inquisition"; - _pop.title = "Inquisition Mission Completed"; - _pop.text = "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success."; - } -} - static per_turn_check_inqisition_tomb = function() { if (p_player[run] <= 0){ exit; @@ -1289,6 +1319,8 @@ static necron_tomb_mission_sequence = function() { threat : 1, formation_set : 1, fortified : 0, + reduce_fortification : true, + reduce_power : true, } switch (_battle){ case 1: @@ -1380,7 +1412,7 @@ static necron_tomb_mission_sequence = function() { exit; } -static inquisition_tomb_battle_aftermath = function(){ +static inquisition_necron_battle_aftermath = function(){ if (!data.tomb_awakens) { if (defeat == 1) { obj_controller.combat = 0; @@ -1518,7 +1550,7 @@ static inquisition_tyranid_org_init = fuction(){ mission: self, options: inquisition_mission_options("inquisition_tyranid_org_accept"), }; - var _text = $"An Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; + var _text = $"An Inquisitor is trusting you with a special mission. The planet {p_data.name()}"; _text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; if (obj_controller.demanding) { _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture a Gaunt organism and return it, unharmed- 4x Webbers have been provided for this purpose."; @@ -1537,19 +1569,50 @@ static inquisition_tyranid_org_accept = fuction(){ obj_controller.cooldown = 10; scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wishes for the capture of a particular strain Gaunt noticed on {p_data.name()} is advisable.", system.name); obj_controller.useful_info += "Tyr|"; + data.captured_gaunt = 0; } - static inquisition_tyranid_org_setup_battle = function(){ if ((obj_ncombat.enemy != eFACTION.TYRANIDS) || (obj_ncombat.battle_object.space_hulk)) { exit; } obj_ncombat.battle_special = p_id; + obj_ncombat.reduce_fortification = false; + obj_ncombat.reduce_power = false; } -static inquisition_tyranid_org_battle_aftermath = function(){ +static inquisition_tyranid_on_enemy_casulties = function(){ + var _c_data = casualty_packet; + if (array_contains(["Termagaunt", "Hormagaunt"], _c_data.weapon) && (_c_data.casulties > 0)) { + data.captured_gaunt += casulties; + } +} +static inquisition_tyranid_org_battle_final_message = fuction(){ + if (obj_ncombat.defeat || data.captured_gaunt == 0) { + exit; + } + var _gaunts = string_plural_count("Gaunt organism", captured_gaunt); + _newline = $"{_gaunts} have been captured."; + obj_ncombat.combat_log.push(_newline, eMSG_COLOR.YELLOW); + +} + +static inquisition_tyranid_org_battle_aftermath = function(){ + if (obj_ncombat.defeat|| data.captured_gaunt == 0){ + exit; + } + if (data.captured_gaunt > 1) { + var _text = "You have captured several Gaunt organisms. The Inquisitor is pleased with your work, though she notes that only one is needed- the rest are to be purged. It will be stored until it may be retrieved. The mission is a success."; + } else { + var _text = "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success."; + } + scr_popup("Inquisition Mission Completed",, "inquisition", ""); + if (data.captured_gaunt > 0) { + delete = true; + } } + } diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 567fc5acbf..482dfa054d 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -497,12 +497,13 @@ function draw_planet_debug_problems() { tooltip_draw(mission_name_key(_keys[i])); if (mouse_button_clicked()) { var _p_data = obj_star_select.p_data; + _p_data.new_problem(_keys[i], 3); switch (_keys[i]) { case "inquisitor": mission_inquistion_hunt_inquisitor(target.id); break; case "inquisition_necron": - mission_inquisition_tomb_world(target.id); + mission_inquisition_necron_world(target.id); break; case "mech_raider": spawn_mechanicus_mission("mech_raider"); @@ -516,9 +517,6 @@ function draw_planet_debug_problems() { case "succession": _p_data.init_war_of_succession(); break; - case "fallen": - _p_data.init_fallen_marines(); - break; default: scr_popup("error", "no specific debug action created please consider helping to make one", ""); break; diff --git a/scripts/scr_choose_weighted/scr_choose_weighted.gml b/scripts/scr_choose_weighted/scr_choose_weighted.gml index fd5e6795ac..e0afe575ba 100644 --- a/scripts/scr_choose_weighted/scr_choose_weighted.gml +++ b/scripts/scr_choose_weighted/scr_choose_weighted.gml @@ -48,7 +48,3 @@ function choose_weighted_range(_choices) { } } } - -function choose_array(choice_array) { - return choice_array[irandom(array_length(choice_array) - 1)]; -} diff --git a/scripts/scr_flavor/scr_flavor.gml b/scripts/scr_flavor/scr_flavor.gml index dd6e558d13..04b851e343 100644 --- a/scripts/scr_flavor/scr_flavor.gml +++ b/scripts/scr_flavor/scr_flavor.gml @@ -517,9 +517,6 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot } } else if (weapon_name == "Webber") { flavoured = true; - if (((target_name == "Termagaunt") || (target_name == "Hormagaunt")) && (casulties > 0)) { - obj_ncombat.captured_gaunt += casulties; - } if ((target.dudes_num[targeh] == 1) && (casulties == 0)) { attack_message = $"{number_of_shots} {weapon_name} spray ooze on the {target_name} but fail to immobilize it."; } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 5dee992a3b..5691a60fff 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -83,7 +83,7 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA var chosen_mission = forced_mission; if (chosen_mission == eINQUISITION_MISSION.RANDOM) { - chosen_mission = choose_array(inquisition_missions); + chosen_mission = array_random_element(inquisition_missions); } switch (chosen_mission) { case eINQUISITION_MISSION.PURGE: @@ -99,10 +99,23 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA mission_inquisition_artifact(); break; case eINQUISITION_MISSION.TOMB_WORLD: - mission_inquisition_tomb_world(necron_tomb_worlds); + mission_inquisition_necron_world(necron_tomb_worlds); break; case eINQUISITION_MISSION.TYRANID_ORGANISM: - mission_inquisition_tyranid_organism(tyranid_org_worlds); + LOGGER.info("RE: Gaunt Capture"); + var _star = array_random_element(worlds); + var planet = -1; + for (var i = 1; i <= _star.planets; i++) { + if (_star.p_tyranids[i] > 4) { + planet = i; + break; + } + } + + var eta = scr_mission_eta(_star.x, _star.y, 1); + eta = min(max(eta, 6), 50); + + _star.get_planet_data(planet).new_problem("tyranid_org", eta); break; case eINQUISITION_MISSION.ETHEREAL: mission_inquisition_ethereal(); @@ -154,25 +167,9 @@ function mission_inquisition_ethereal() { } function mission_inquisition_tyranid_organism(worlds) { - LOGGER.info("RE: Gaunt Capture"); - var _star = choose_array(worlds); - var planet = -1; - for (var i = 1; i <= _star.planets; i++) { - if (_star.p_tyranids[i] > 4) { - planet = i; - break; - } - } - - var eta = scr_mission_eta(_star.x, _star.y, 1); - eta = min(max(eta, 6), 50); - - var text = $"An Inquisitor is trusting you with a special mission. The planet {string(_star.name)} {scr_roman(planet)}"; - text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; - scr_popup("Inquisition Mission", text, "inquisition", $"tyranid_org|{string(_star.name)}|{string(planet)}|{string(eta + 1)}|"); } -function mission_inquisition_tomb_world(tomb_worlds) { +function mission_inquisition_necron_world(tomb_worlds) { LOGGER.info("RE: Necron Tomb Bombing"); var _star = noone; if (is_array(tomb_worlds)) { @@ -195,7 +192,7 @@ function mission_inquisition_tomb_world(tomb_worlds) { var _options = [ { str1: "Accept", - choice_func: init_mission_inquisition_tomb_world, + choice_func: init_mission_inquisition_necron_world, }, { str1: "Refuse", @@ -218,7 +215,7 @@ function mission_inquisition_tomb_world(tomb_worlds) { } /// @self Asset.GMObject.obj_popup -function init_mission_inquisition_tomb_world() { +function init_mission_inquisition_necron_world() { var _mission_star = find_star_by_name(pop_data.system); var _p_data = _mission_star.get_planet_data(pop_data.planet); if (_mission_star == noone) { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 7009007a89..6b5346338b 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -18,7 +18,7 @@ global.planet_problem_keys = [ "mech_bionics", "mech_mars", "mech_tomb", - "fallen", + "hunt_fallen", "great_crusade", "harlequins", "fund_elder", @@ -50,7 +50,7 @@ function mission_name_key(mission) { "mech_bionics": "Provide Bionic Augmented marines to study", "mech_mars": "Send Techmarines to mars", "mech_tomb": "Explore Mechanicus Tomb", - "fallen": "Find Chapter Fallen", + "hunt_fallen": "Find Chapter Fallen", "great_crusade": "Answer Crusade Muster Call", "harlequins": "Harlequin presence Report", "fund_elder": "provide assistance to Eldar", diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index b61167ffef..8793431241 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -748,7 +748,7 @@ function event_fallen() { } LOGGER.info($"Fallen: valid_stars {valid_stars}"); - var star = choose_array(stars); + var star = array_random_element(stars); var planet = scr_get_planet_with_owner(star, eFACTION.IMPERIUM); if (planet > 0 && instance_exists(star)) { diff --git a/scripts/scr_shoot/scr_shoot.gml b/scripts/scr_shoot/scr_shoot.gml index 4ba3f2a3d0..cc92513e9a 100644 --- a/scripts/scr_shoot/scr_shoot.gml +++ b/scripts/scr_shoot/scr_shoot.gml @@ -495,6 +495,20 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat target_object.dudes_num[target_type] -= casualties; obj_ncombat.enemy_forces -= casualties; } + if (obj_ncombat.battle_special != ""){ + if (is_struct(obj_ncombat.special_feature), && is_instanceof(obj_ncombat.special_feature, PlanetProblem)){ + var _feat = obj_ncombat.special_feature; + _feat.casualty_packet = { + number : casualties, + target : target_object, + target_type, + weapon : weapon_index_position < 0 : "defences" : wep_title[weapon_index_position] + + } + _feat.battle_on_enemy_casulties(); + } + } + } } From 1571afa1a2d105d6e8a696071b39d6a2449c86d6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 16:35:41 +0100 Subject: [PATCH 025/118] Implement 'Hive Fleet to Cult' mission and refine mission state management Introduces a new Tyranid mission that simulates a Hive Fleet's approach and the growth of a cult. Its initiation and per-turn events, including fleet creation and 'Shadow in the Warp' notifications, are now fully integrated into the `PlanetProblem` system. This also renames the `delete` flag to `delete_mission` within `PlanetProblem` for improved clarity and consistency following recent mission lifecycle refactoring efforts. The `problem_count_down` function is now a static method of `PlanetData` for better encapsulation. --- scripts/MissionHelper/MissionHelper.gml | 108 ++++++++++++++---- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- scripts/scr_after_combat/scr_after_combat.gml | 2 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 55 +-------- .../scr_manage_task_selector.gml | 2 +- .../scr_mechanicus_missions.gml | 1 - 6 files changed, 91 insertions(+), 79 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 16303f6641..e0baa6a922 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -1,5 +1,11 @@ -function SystemProblem(name, timer, data){} +function SystemProblem(name, timer, data){ +} + +/// @self Asset.GMObject.obj_star +/// @param {sring} name +/// @param {Real} timer +/// @param {constructor PlanetData} _system function PlanetProblem(name, timer, data, planet) constructor{ timer = timer; uid = scr_uuid_generate(); @@ -10,7 +16,7 @@ planet = p_data.planet; system = p_data.system; f_type = eP_FEATURES.MISSION; members = []; -delete = false; +delete_mission = false; static refresh_p_data = function(){ p_data = system.get_planet_data(planet); } @@ -60,7 +66,7 @@ static handle_triggered_mission_func = function(func){ ERROR_HANDLER.handle_exception(_exception); } } - if (timer == -1 || (delete)){ + if (timer == -1 || (delete_mission)){ var _prob = -1; for (var i = 0; i < array_length(system.p_problem); i++){ if (system.p_problem[i] == self){ @@ -101,12 +107,15 @@ static basic_turn_end = function(){ _func = per_turn_check_spyrer; break; case "inquisition_necron": - per_turn_check_inqisition_tomb; + _func =per_turn_check_inqisition_tomb; + break; + case "hive_fleet_to_cult": + _func = per_turn_hive_fleet_to_cult; break; } handle_triggered_mission_func(_func) } - if ((timer == 0) && zero_timer_checks && !delete) { + if ((timer == 0) && zero_timer_checks && !delete_mission) { var _func = undefined; switch(p_id){ case "hunt_beast": @@ -279,6 +288,10 @@ static __init(){ break; case "tyranid_org": inquisition_tyranid_org_init(); + break; + case "hive_fleet_to_cult": + hive_fleet_to_cult_init(); + break; default: mark("green"); @@ -703,7 +716,7 @@ static spyrer_battle_aftermath = function(){ exit; } - delete = true; + delete_mission = true; var _tixt = $"The Spyrer on {p_data.name()} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; @@ -761,7 +774,7 @@ static per_turn_check_fallen = function() { _battle_enemy_data ); } else { - delete = true; + delete_mission = true; var _tixt = "Your marines have scoured " + planet_numeral_name(run, id) + " in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; scr_popup("Hunt the Fallen", _tixt, "fallen", ""); scr_event_log("", $"Mission Successful: No Fallen located upon {planet_numeral_name(run, id)}"); @@ -797,7 +810,7 @@ function hunt_fallen_battle_aftermath() { if (obj_ncombat.defeat) { exit; } - delete = true; + delete_mission = true; var _tixt = "The Fallen on " + _p_data.name(); scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; @@ -817,7 +830,7 @@ static per_turn_check_mech_raider = function() { var _percent_complete = increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { - delete = true; + delete_mission = true; scr_mission_reward("mech_raider", system, planet); timer = -1 per_turn_checks = false; @@ -831,7 +844,7 @@ static resolve_mech_raider_failed = function() { scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); p_data.alter_disposition(eFACTION.MECHANICUS, -6); - delete = true; + delete_mission = true; } static per_turn_check_mech_bionics = function() { @@ -841,7 +854,7 @@ static per_turn_check_mech_bionics = function() { var _percent_complete = increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { - delete = true; + delete_mission = true; scr_mission_reward("mech_bionics", id, planet); timer = -1 per_turn_checks = false; @@ -855,7 +868,7 @@ static resolve_mech_bionics_failed = function() { scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); p_data.alter_disposition(eFACTION.MECHANICUS, -6); - delete = true; + delete_mission = true; } static per_turn_check_mech_tomb2 = function() { @@ -888,7 +901,7 @@ static per_turn_check_mech_tomb2 = function() { scr_popup("Mechanicus Mission Failed", $"The Mechanicus Research team on planet {p_data.name()} have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); p_data.alter_disposition(eFACTION.MECHANICUS, -25); - delete = true; + delete_mission = true; } } else { if (_roll1 > 20) { @@ -911,7 +924,7 @@ static per_turn_check_mech_tomb2 = function() { } _text += "\n" + add_disposition(eFACTION.MECHANICUS, 1); scr_popup("Mechanicus Mission Completed", _text, "mechanicus", ""); - delete = true; + delete_mission = true; timer = -1 per_turn_checks = false; zero_timer_checks = false; @@ -934,12 +947,12 @@ static resolve_mech_tomb1_failed = function() { scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); p_data.alter_disposition(eFACTION.MECHANICUS, -15); - delete = true; + delete_mission = true; } static mech_tomb_battle_aftermath = function() { if (obj_ncombat.defeat) { - delete = true; + delete_mission = true; var _disp_change = alter_disposition(eFACTION.MECHANICUS, -10); @@ -1081,7 +1094,7 @@ static protect_raiders_battle_aftermath = function() { // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); // title / text / image / speshul var _planet_string = p_data.name(); - delete = true; + delete_mission = true; if (!obj_ncombat.defeat) { p_data.add_disposition(15); var _tixt = $"The Raiding forces on {_planet_string} have been removed. The citizens and craftsman may sleep more soundly. ({_planet_string} disp +15)"; @@ -1162,7 +1175,7 @@ static protect_raider_squad_selected = function() { add_to_battle(); } exit_adhoc_manage(); - delete _roster; + delete_mission _roster; _battle.battle_enemy_data = { threat : 3, @@ -1403,7 +1416,7 @@ static necron_tomb_mission_sequence = function() { add_to_battle(); } } - delete _roster; + delete_mission _roster; instance_deactivate_object(obj_star); instance_destroy(obj_popup); @@ -1444,7 +1457,7 @@ static inquisition_necron_battle_aftermath = function(){ } } - delete = true; + delete_mission = true; with (system) { var _planet = obj_ncombat.battle_id; @@ -1487,7 +1500,7 @@ static advance_necron_tomb_mission = function() { alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - delete = true; + delete_mission = true; seal_tomb_world(p_data.features); scr_event_log("", $"Inquisition Mission Completed: Your Astartes have sealed the Necron Tomb on {p_data.name()}.", system.name); @@ -1512,7 +1525,7 @@ static inquisition_mission_options = fuction(mission_accept_function){ array_push(_options, { str1: "Refuse", choice_func: function(){ - pop_data.mission.delete = true; + pop_data.mission.delete_mission = true; popup_default_close(); } }) @@ -1609,10 +1622,59 @@ static inquisition_tyranid_org_battle_aftermath = function(){ } scr_popup("Inquisition Mission Completed",, "inquisition", ""); if (data.captured_gaunt > 0) { - delete = true; + delete_mission = true; } } +static hive_fleet_to_cult_init = function(){ + var xx = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; + var yy = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; + var fleet = create_enemy_fleet(xx, yy, eFACTION.TYRANIDS); + fleet.sprite_index = spr_fleet_tyranid; + fleet.image_speed = 0; + + fleet.capital_number = choose(7, 8, 9); + fleet.frigate_number = round(random_range(6, 12)); + fleet.escort_number = round(random_range(12, 27)); + + fleet.image_index = floor(fleet.capital_number + (fleet.frigate_number / 2) + (fleet.escort_number / 4)); + fleet.image_alpha = 0; + + fleet.action_x = x; + fleet.action_y = y; + + fleet.action_eta = timer; + fleet.action = "move"; +} + +static per_turn_hive_fleet_to_cult = function(){ + if (timer != 3 || scr_has_disadv("Psyker Intolerant")){ + continue; + } + var _has_head_lib = scr_role_count(obj_ini.player_role_data[eROLE.CHIEFLIBRARIAN].role, ""); + + var _head = get_department_head(eCHAPTER_DEPARTMENTS.LIB); + + if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (_has_head_lib != 0) && is_struct(_head)) { + scr_popup("Shadow in the Warp", $"Chief {_head.name_role()} reports a disturbance in the warp. He claims it is like a shadow.", "shadow", ""); + scr_event_log("red", $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role} reports a disturbance in the warp. He claims it is like a shadow."); + } + if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (_has_head_lib == 0)) { + for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { + var _unit = fetch_unit([0, q]); + if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (string_count("0", _unit.specials) > 0) { + scr_popup("Shadow in the Warp", "You are distracted and bothered by a nagging sensation in the warp. It feels as though a shadow descends upon your sector.", "shadow", ""); + scr_event_log("red", "You sense a disturbance in the warp. It feels something like a massive shadow."); + } + break; + } + } + } + + obj_controller.known[eFACTION.TYRANIDS] = 1; +} + } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 74ed2245b7..b7ab8f5112 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -774,7 +774,7 @@ function PlanetData(_planet, _system) constructor { } - function problem_count_down(planet, count_change = 1) { + static problem_count_down = function (count_change = 1) { for (var i = array_length(problems) -1; i >= 0; i--) { var _problem = problems[i]; _problem.basic_turn_end(); diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index 8417bcbdc4..a5c6d917f2 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -151,7 +151,7 @@ function check_for_plasma_bomb_and_tomb(unit) { var _star = obj_ncombat.battle_object; var _planet = obj_ncombat.battle_id; var _necron_strength = _star.p_necrons[_planet]; - if (unit.gear() == "Plasma Bomb" && obj_ncombat.battle_special != "mech_tomb")) { + if (unit.gear() == "Plasma Bomb" && obj_ncombat.battle_special != "mech_tomb") { if (obj_ncombat.enemy == eFACTION.NECRONS && awake_tomb_world(_star.p_feature[_planet])) { if (((_necron_strength - 2) < 3 && obj_ncombat.dropping) || (_necron_strength - 1) < 3) { obj_ncombat.plasma_bomb += 1; 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 6dd75af548..c764f7f24d 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -81,15 +81,12 @@ function scr_enemy_ai_d() { } } for (var i = 1; i <= planets; i++) { -if (array_length(p_problem[i]) == 0){ - continue; - } - problem_count_down(i); var _pdata = get_planet_data(i); + _pdata.problem_count_down(i); if (((p_tyranids[i] == 3) || (p_tyranids[i] == 4)) && (p_population[i] > 0)) { - if (!_pdata.has_problem("Hive Fleet")) { + if (!_pdata.has_problem("hive_fleet_to_cult")) { var roll = irandom_range(100, 300); var cont = 0; @@ -101,55 +98,9 @@ if (array_length(p_problem[i]) == 0){ } if (cont == 1) { - _pdata.new_problem("Hive Fleet", irandom_range(60, 120) + irandom_range(80, 120)); - - var xx = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; - var yy = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; - var fleet = create_enemy_fleet(xx, yy, eFACTION.TYRANIDS); - fleet.sprite_index = spr_fleet_tyranid; - fleet.image_speed = 0; - - fleet.capital_number = choose(7, 8, 9); - fleet.frigate_number = round(random_range(6, 12)); - fleet.escort_number = round(random_range(12, 27)); - - fleet.image_index = floor(fleet.capital_number + (fleet.frigate_number / 2) + (fleet.escort_number / 4)); - fleet.image_alpha = 0; - - fleet.action_x = x; - fleet.action_y = y; - - fleet.action_eta = p_problem[i][firstest].timer; - fleet.action = "move"; - } - } - } - - if (has_problem_planet_and_time(i, "Hive Fleet", 3) > -1) { - var woop = scr_role_count(obj_ini.player_role_data[eROLE.CHIEFLIBRARIAN].role, ""); - var yep = !scr_has_disadv("Psyker Intolerant"); - - var _head = get_department_head(eCHAPTER_DEPARTMENTS.LIB); - - if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop != 0) && yep && is_struct(_head)) { - scr_popup("Shadow in the Warp", $"Chief {_head.name_role()} reports a disturbance in the warp. He claims it is like a shadow.", "shadow", ""); - scr_event_log("red", $"Chief {obj_ini.player_role_data[eROLE.LIBRARIAN].role} reports a disturbance in the warp. He claims it is like a shadow."); - } - if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (woop == 0) && yep) { - for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { - var _unit = fetch_unit([0, q]); - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - if (string_count("0", _unit.specials) > 0) { - scr_popup("Shadow in the Warp", "You are distracted and bothered by a nagging sensation in the warp. It feels as though a shadow descends upon your sector.", "shadow", ""); - scr_event_log("red", "You sense a disturbance in the warp. It feels something like a massive shadow."); - } - break; - } + _pdata.new_problem("hive_fleet_to_cult", irandom_range(60, 120) + irandom_range(80, 120)); } } - - i = 50; - obj_controller.known[eFACTION.TYRANIDS] = 1; } } diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index b038e3c125..177dc81f35 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -50,7 +50,7 @@ function task_selector_squad_manage() { } if (struct_exists(selection_data , "feature") && array_length(_squads)){ var _feat = selection_data.feature; - if (is_struct(_feat) && is_instanceof(_feat, PlanetProblem){ + if (is_struct(_feat) && is_instanceof(_feat, PlanetProblem)){ _feat.data.squads = _squads; _feat.on_squad_selection(); } diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 16dd9630ca..288d627773 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -216,7 +216,6 @@ function accept_mechanicus_mars_mission() { var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); - _planet.new_problem("mech_bionics", _mission_time, {completion: 0, required_months: 24}); _planet.new_problem("mech_mars", _mission_time); text = $"The Adeptus Mechanicus await your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s at {_mission_loc}. They are willing to hold on the voyage for up to {_mission_time} months."; scr_event_log("", $"Mechanicus Mission Accepted: {obj_ini.player_role_data[eROLE.TECHMARINE].role}s are expected at {_mission_loc} within 30 months, for the voyage to Mars.", _star.name); From 187dafa6f7edcc61db111155199c1c0995a55d64 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 16:41:18 +0100 Subject: [PATCH 026/118] Remove obsolete planet problem utility functions Eliminates `has_any_problem_planet` and `has_problem_planet_and_time`, which are no longer required following refinements to the `PlanetProblem` system. References to these functions have been updated to use direct array length checks, providing a more efficient and simplified way to determine if a planet has active problems. --- scripts/scr_cheatcode/scr_cheatcode.gml | 2 +- scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml | 2 +- .../scr_mission_functions.gml | 39 ------------------- 3 files changed, 2 insertions(+), 41 deletions(-) diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 482dfa054d..d512b9f760 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -128,7 +128,7 @@ function scr_cheatcode(argument0) { } with (obj_star) { for (var i = 1; i <= planets; i++) { - var existing_problem = false; //has_any_problem_planet(i); + var existing_problem = false; if (!existing_problem) { if (p_owner[i] == eFACTION.IMPERIUM) { LOGGER.debug("mission"); 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 6401d98deb..3aee617381 100644 --- a/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml +++ b/scripts/scr_enemy_ai_e/scr_enemy_ai_e.gml @@ -748,7 +748,7 @@ function scr_enemy_ai_e() { } for (var i = 1; i <= planets; i++) { - var existing_problem = has_any_problem_planet(i); + var existing_problem = bool(array_length(p_problem[i])); if (!existing_problem) { if (!irandom(50) && p_owner[i] == eFACTION.IMPERIUM) { if (p_owner[i] == eFACTION.IMPERIUM) { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 6b5346338b..e64fa21968 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -203,24 +203,6 @@ function protect_raiders_hold_memorial() { } -//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 -/// @self Asset.GMObject.obj_star -function has_any_problem_planet(planet, star = noone) { - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - if (p_problem[planet][i] != "") { - return true; - } - } - } else { - with (star) { - return has_any_problem_planet(planet); - } - } - return false; -} - // returns a bool for if any planet on a given star has the given problem /// @self Asset.GMObject.obj_star function has_problem_star(problem, star = noone) { @@ -241,27 +223,6 @@ function has_problem_star(problem, star = noone) { return has_problem; } -//returns the array position of a given problem on a given planet if the specfied time is given -/// @self Asset.GMObject.obj_star -function has_problem_planet_and_time(planet, problem, time, star = noone) { - var _had_problem = -1; - if (star == noone) { - for (var i = 0; i < array_length(p_problem[planet]); i++) { - var _prob = p_problem[planet][i]; - if (_prob.p_id == problem) { - if (_prob.timer == time) { - _had_problem = i; - } - } - } - } else { - with (star) { - _had_problem = has_problem_planet_and_time(planet, problem, time); - } - } - return _had_problem; -} - ///removie all of a given problem from a planet /// @self Asset.GMObject.obj_star From 65e5ee4f560b2e9b58480173a5a5e28f8bda17af Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 17:54:28 +0100 Subject: [PATCH 027/118] make inquisition recon mission trigger on turn end --- objects/obj_popup/Step_0.gml | 11 --------- objects/obj_temp7/Alarm_0.gml | 21 ------------------ scripts/MissionHelper/MissionHelper.gml | 27 ++++++++++++++++++++--- scripts/scr_PlanetData/scr_PlanetData.gml | 14 ------------ 4 files changed, 24 insertions(+), 49 deletions(-) diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index a7404bfa70..bbcfb27817 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -329,11 +329,6 @@ try { } // Remove multi-choices } - if ((image == "inquisition") && (title == "Investigation Completed")) { - obj_temp7.alarm[1] = 1; - instance_destroy(); - } - if (image == "artifact2") { ground_forces_collect_artifact(); obj_controller.cooldown = 10; @@ -356,12 +351,6 @@ try { if (title == "Inquisition Recon") { obj_controller.disposition[4] -= 2; } - if ((image == "inquisition") && (title == "Investigation Completed")) { - with (obj_temp7) { - instance_destroy(); - } - instance_destroy(); - } if (title == "Mercy Plea") { // If have any marines within the fleet on the ships diff --git a/objects/obj_temp7/Alarm_0.gml b/objects/obj_temp7/Alarm_0.gml index 0e53c19454..e69de29bb2 100644 --- a/objects/obj_temp7/Alarm_0.gml +++ b/objects/obj_temp7/Alarm_0.gml @@ -1,21 +0,0 @@ -if (num > 0) { - // Hmmmmmmm - var stah; - stah = instance_nearest(x, y, obj_star); - obj_controller.menu = 0; - var _p_data = stah.get_planet_data(num); - if (_p_data.has_problem("recon")) { - var pop; - pop = instance_create(0, 0, obj_popup); - pop.image = "inquisition"; - pop.title = "Investigation Completed"; - pop.text = $"Your marines have scouted out {_p_data.name()} and satisfied the mission requirements."; - - pop.add_option("Reload Marines"); - pop.add_option("Do Nothing"); - - scr_event_log("", $"Inquisition Mission Completed: Your Astartes have succesfully scouted {_p_data.name()}."); - - remove_planet_problem(num, "recon", stah); - } -} diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index e0baa6a922..60b15c96bb 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -112,6 +112,9 @@ static basic_turn_end = function(){ case "hive_fleet_to_cult": _func = per_turn_hive_fleet_to_cult; break; + case "inquisition_recon": + _func = per_turn_inquisition_recon; + break; } handle_triggered_mission_func(_func) } @@ -127,8 +130,8 @@ static basic_turn_end = function(){ case "succession": _func = resolve_succession; break; - case "recon": - _func = resolve_recon; + case "inquisition_recon": + _func = resolve_inquisition_recon; break; case "great_crusade": _func = resolve_great_crusade; @@ -615,8 +618,26 @@ static resolve_succession = function() { p_data.delete_feature(eP_FEATURES.SUCCESSION_WAR); } +static per_turn_inquisition_recon = function() { + if (p_data.player_forces <= 0){ + exit; + } + + var _pop_data = { + mission: self, + }; + scr_popup( + "Investigation Completed", + "Your marines have scouted out {_p_data.name()} and satisfied the mission requirements.", + "inquisition", + _pop_data + ); + scr_event_log("", $"Inquisition Mission Completed: Your Astartes have succesfully scouted {_p_data.name()}."); -static resolve_recon = function() { + delete_mission = true; + +} +static resolve_inquisition_recon = function() { refresh_p_data(); var _alert_text = "Inquisition Mission Failed: Investigate "; alter_disposition(eFACTION.INQUISITION, -5); diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index b989285832..67f699f753 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1572,20 +1572,6 @@ function PlanetData(_planet, _system) constructor { // 135 ; SPECIAL PLANET CRAP HERE // Recon Stuff - - 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"; - - with (arti) { - setup_planet_mission_group(); - } - } if (!instance_exists(obj_ground_mission)) { check_for_artifact_grab_mission(); } From 2ca2a2a600847880bb247cd45bf7ac539dc66841 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 17:55:55 +0100 Subject: [PATCH 028/118] var name --- .../scr_fleet_functions/scr_fleet_functions.gml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 5335ebd13e..2e91286581 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -1047,7 +1047,7 @@ function fleet_arrival_logic() { } } - var kay = 0, temp5 = 0, temp6 = 0, temp7 = 0; + var kay = 0, temp5 = 0, temp6 = 0, _final_star = 0; var _nearest_star = instance_nearest(x, y, obj_star); @@ -1076,23 +1076,23 @@ function fleet_arrival_logic() { if (kay == 50) { temp5 = x + choose(random(300), random(300) * -1); temp6 = y + choose(random(300), random(300) * -1); - temp7 = instance_nearest(temp5, temp6, obj_star); + _final_star = instance_nearest(temp5, temp6, obj_star); - if ((owner == eFACTION.ORK) && (temp7.owner != eFACTION.ORK) && (temp7.planets > 0) && (temp7.image_alpha >= 1)) { + if ((owner == eFACTION.ORK) && (_final_star.owner != eFACTION.ORK) && (_final_star.planets > 0) && (_final_star.image_alpha >= 1)) { kay = 55; } - if ((owner == eFACTION.TAU) && (temp7.owner != eFACTION.TAU) && (temp7.planets > 0) && (temp7.image_alpha >= 1)) { + if ((owner == eFACTION.TAU) && (_final_star.owner != eFACTION.TAU) && (_final_star.planets > 0) && (_final_star.image_alpha >= 1)) { kay = 55; } - if ((owner == eFACTION.CHAOS) && (temp7.owner != eFACTION.CHAOS) && (temp7.planets > 0) && (temp7.image_alpha >= 1)) { + if ((owner == eFACTION.CHAOS) && (_final_star.owner != eFACTION.CHAOS) && (_final_star.planets > 0) && (_final_star.image_alpha >= 1)) { kay = 55; } } } - if ((kay == 55) && instance_exists(temp7)) { - action_x = temp7.x; - action_y = temp7.y; + if ((kay == 55) && instance_exists(_final_star)) { + action_x = _final_star.x; + action_y = _final_star.y; set_fleet_movement(); } From 05e0a18db7bcd2500bfae7a245f544b21f31d81e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 25 Sep 2026 17:57:11 +0100 Subject: [PATCH 029/118] remove legacy temp obj --- ChapterMaster.yyp | 1 - objects/obj_temp7/Alarm_0.gml | 0 objects/obj_temp7/Alarm_1.gml | 2 -- objects/obj_temp7/Create_0.gml | 4 ---- objects/obj_temp7/obj_temp7.yy | 37 ---------------------------------- 5 files changed, 44 deletions(-) delete mode 100644 objects/obj_temp7/Alarm_0.gml delete mode 100644 objects/obj_temp7/Alarm_1.gml delete mode 100644 objects/obj_temp7/Create_0.gml delete mode 100644 objects/obj_temp7/obj_temp7.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 74ee1aae17..253765e9d4 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -709,7 +709,6 @@ {"id":{"name":"obj_temp3","path":"objects/obj_temp3/obj_temp3.yy",},}, {"id":{"name":"obj_temp5","path":"objects/obj_temp5/obj_temp5.yy",},}, {"id":{"name":"obj_temp6","path":"objects/obj_temp6/obj_temp6.yy",},}, - {"id":{"name":"obj_temp7","path":"objects/obj_temp7/obj_temp7.yy",},}, {"id":{"name":"obj_temp8","path":"objects/obj_temp8/obj_temp8.yy",},}, {"id":{"name":"obj_timer","path":"objects/obj_timer/obj_timer.yy",},}, {"id":{"name":"obj_tooltip","path":"objects/obj_tooltip/obj_tooltip.yy",},}, diff --git a/objects/obj_temp7/Alarm_0.gml b/objects/obj_temp7/Alarm_0.gml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/objects/obj_temp7/Alarm_1.gml b/objects/obj_temp7/Alarm_1.gml deleted file mode 100644 index 6e782b11ce..0000000000 --- a/objects/obj_temp7/Alarm_1.gml +++ /dev/null @@ -1,2 +0,0 @@ -scr_return_ship(loc, self, num); -instance_destroy(); diff --git a/objects/obj_temp7/Create_0.gml b/objects/obj_temp7/Create_0.gml deleted file mode 100644 index e8bfa9df6c..0000000000 --- a/objects/obj_temp7/Create_0.gml +++ /dev/null @@ -1,4 +0,0 @@ -num = 0; -loc = ""; -managing = 0; -type = ""; diff --git a/objects/obj_temp7/obj_temp7.yy b/objects/obj_temp7/obj_temp7.yy deleted file mode 100644 index b5cd83e011..0000000000 --- a/objects/obj_temp7/obj_temp7.yy +++ /dev/null @@ -1,37 +0,0 @@ -{ - "$GMObject":"", - "%Name":"obj_temp7", - "eventList":[ - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - {"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":2,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, - ], - "managed":true, - "name":"obj_temp7", - "overriddenProperties":[], - "parent":{ - "name":"Temp", - "path":"folders/Objects/Temp.yy", - }, - "parentObjectId":null, - "persistent":false, - "physicsAngularDamping":0.1, - "physicsDensity":0.5, - "physicsFriction":0.2, - "physicsGroup":0, - "physicsKinematic":false, - "physicsLinearDamping":0.1, - "physicsObject":false, - "physicsRestitution":0.1, - "physicsSensor":false, - "physicsShape":0, - "physicsShapePoints":[], - "physicsStartAwake":true, - "properties":[], - "resourceType":"GMObject", - "resourceVersion":"2.0", - "solid":false, - "spriteId":null, - "spriteMaskId":null, - "visible":true, -} \ No newline at end of file From a024a92a37535ff9038db4107ee6e9ece4d41b5b Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 14:36:34 +0100 Subject: [PATCH 030/118] finish migrating hunt fallen to new system --- scripts/MissionHelper/MissionHelper.gml | 8 ++++ scripts/scr_PlanetData/scr_PlanetData.gml | 13 ------- scripts/scr_cheatcode/scr_cheatcode.gml | 2 - scripts/scr_random_event/scr_random_event.gml | 39 +++++++++---------- 4 files changed, 26 insertions(+), 36 deletions(-) diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index 60b15c96bb..eb4d200e41 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -280,6 +280,7 @@ static __init(){ mark("purple"); break; case "hunt_fallen": + hunt_fallen_init(); break; case "harlequins": var _text = $"Eldar Harlequins have been seen on planet {p_data.name()}. Their purposes are unknown."; @@ -750,6 +751,13 @@ static spyrer_battle_aftermath = function(){ scr_gov_disp(system.name, planet, choose(1, 2, 3, 4)); } +static hunt_fallen_init = function(){ + var _text = localize("Sources indicate one of the Fallen may be upon {0}. We have {1} months to send out a strike team and scour the planet. Any longer and any Fallen that might be there will have escaped.", [p_data.name(), timer]); + scr_popup(localize("Hunt the Fallen"), _text, "fallen", ""); + scr_event_log("", localize("Sources indicate one of the Fallen may be upon {0}. We have {1} months to investigate.", [p_data.name(), timer])); + mark("purple"); +} + static per_turn_check_fallen = function() { if (p_data.player_forces > 0){ if (choose(true, false)) { diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 67f699f753..5806363aee 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -2051,17 +2051,4 @@ function PlanetData(_planet, _system) constructor { _star_alert.col = "red"; scr_event_log("red", localize("War of Succession on {0}", [name()])); }; - - static init_fallen_marines = function() { - var _eta = scr_mission_eta(system.x, system.y, 1); - assigned_problem = new_problem("fallen", _eta); - - var _text = localize("Sources indicate one of the Fallen may be upon {0}. We have {1} months to send out a strike team and scour the planet. Any longer and any Fallen that might be there will have escaped.", [name(), _eta]); - scr_popup(localize("Hunt the Fallen"), _text, "fallen", ""); - scr_event_log("", localize("Sources indicate one of the Fallen may be upon {0}. We have {1} months to investigate.", [name(), _eta])); - var star_alert = create_alert(); - star_alert.image_alpha = 1; - star_alert.image_speed = 1; - star_alert.col = "purple"; - }; } diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index d512b9f760..e93223be46 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -225,8 +225,6 @@ function scr_cheatcode(argument0) { new_inquisitor_inspection(); } else if (cheat_arguments[0] == "slaughtersong") { create_starship_event(); - } else if (cheat_arguments[0] == "fallen") { - event_fallen(); } else if (cheat_arguments[0] == "surfremove") { var _star_id = scr_random_find(0, true, "", ""); add_event({duration: 2, e_id: "governor_assassination", variant: 2, system: _star_id.name, planet: irandom_range(1, _star_id.planets)}); diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 8793431241..a25ae273a2 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -715,7 +715,24 @@ function scr_random_event(execute_now) { } else if (chosen_event == eEVENT.NECRON_AWAKEN) { _evented = awaken_tomb_event(); } else if (chosen_event == eEVENT.FALLEN) { - event_fallen(); + LOGGER.info("RE: Hunt the Fallen"); + var stars = scr_get_stars(); + var valid_stars = scr_get_stars(false, [eFACTION.IMPERIUM]); + + if (array_length(valid_stars) == 0) { + LOGGER.error("RE: Hunt the Fallen, coulnd't find a star"); + exit; + } + LOGGER.info($"Fallen: valid_stars {valid_stars}"); + + var star = array_random_element(stars); + var planet = scr_get_planet_with_owner(star, eFACTION.IMPERIUM); + + if (planet > 0 && instance_exists(star)) { + var _p_data = star.get_planet_data(planet); + var _eta = scr_mission_eta(star.x, star.y, 1); + _p_data.new_problem("hunt_fallen"); + } _evented = true; } @@ -736,23 +753,3 @@ function scr_random_event(execute_now) { //with(obj_en_fleet){if (x<-10000){x+=20000;y+=20000;}} //with(obj_star){if (x<-10000){x+=20000;y+=20000;}} } - -function event_fallen() { - LOGGER.info("RE: Hunt the Fallen"); - var stars = scr_get_stars(); - var valid_stars = scr_get_stars(false, [eFACTION.IMPERIUM]); - - if (array_length(valid_stars) == 0) { - LOGGER.error("RE: Hunt the Fallen, coulnd't find a star"); - exit; - } - LOGGER.info($"Fallen: valid_stars {valid_stars}"); - - var star = array_random_element(stars); - var planet = scr_get_planet_with_owner(star, eFACTION.IMPERIUM); - - if (planet > 0 && instance_exists(star)) { - var _p_data = star.get_planet_data(planet); - _p_data.init_fallen_marines(); - } -} From 1ba1b923e55c593705605a2a9f602a57c0533432 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 14:51:05 +0100 Subject: [PATCH 031/118] split of problems that effect the whole system as system problems --- objects/obj_star/Create_0.gml | 8 +++++ scripts/MissionHelper/MissionHelper.gml | 44 +++++++++++++++++++++++-- scripts/scr_crusade/scr_crusade.gml | 14 +------- 3 files changed, 50 insertions(+), 16 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index b54b386a7d..e09142f3ac 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -119,6 +119,14 @@ add_feature = function(planet, feature) { array_push(p_feature[planet], feature); }; +system_problems = []; + +add_problem = function(p_id, data){ + array_push(system_problems, new SystemProblem(name, data, system)){ + + } +} + system_player_ground_forces = 0; /// @desc Reports whether any planet in this system holds a garrison squad that still has members. diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index eb4d200e41..d1814291e0 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -1,11 +1,49 @@ -function SystemProblem(name, timer, data){ +function SystemProblem(name, data = {}, system){ +timer = 0; +f_type = eP_FEATURES.MISSION; +p_id = name; +data = data; +self.system = system; +if (struct_exists(data, "stage")){ + stage_id = data.stage; +} +if (struct_exists(data, "members")){ + members = data.members; +} + +static mark = function(colour){ + with (system){ + new_star_event_marker(colour) + } +} + +static init = function(){ + switch(p_id){ + case "great_crusade": + great_crusade_init(); + break; + } + +} +static great_crusade_init(){ + //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards + _nearest_player_fleet = data.nearest_player_fleet; + var _travel_leeway = 10; + if (_nearest_player_fleet.action == "move") { + _travel_leeway += _nearest_player_fleet.action_eta; + } + timer = get_viable_travel_time(_travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, star_id.x, star_id.y, _nearest_player_fleet, false); + scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {star_id.name}; {_eta} months from now your ships there shall begin their journey.", "crusade", ""); + mark("green") + scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); +} } -/// @self Asset.GMObject.obj_star /// @param {sring} name /// @param {Real} timer -/// @param {constructor PlanetData} _system +/// @param {struct} data +/// @param {constructor PlanetData} planet function PlanetProblem(name, timer, data, planet) constructor{ timer = timer; uid = scr_uuid_generate(); diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 35b114c8bf..6084dab487 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -217,23 +217,11 @@ function launch_crusade() { LOGGER.error("RE: Crusade, couldn't find a star for the crusade"); return false; } else { - //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards var _nearest_player_fleet = get_nearest_player_fleet(star_id.x, star_id.y); if (_nearest_player_fleet == noone) { return false; } - var travel_leeway = 10; - if (_nearest_player_fleet.action == "move") { - travel_leeway += _nearest_player_fleet.action_eta; - } - var _eta = get_viable_travel_time(travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, star_id.x, star_id.y, _nearest_player_fleet, false); - scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {star_id.name}; {_eta} months from now your ships there shall begin their journey.", "crusade", ""); - var star_alert = instance_create(star_id.x + 16, star_id.y - 24, obj_star_event); - star_alert.image_alpha = 1; - star_alert.image_speed = 1; - scr_event_log("", $"A Crusade is called; our forces are expected at {star_id.name} in {_eta} months.", star_id.name); - var _p_data = star_id.get_planet_data(irandom_range(1, star_id.planets)); - assigned_crusade = _p_data.new_problem("great_crusade", _eta); + star_id.add_problem("great_crusade", {nearest_player_fleet:_nearest_player_fleet}) return true; } } From 128f3f5b3bf015ae527e2865bfa995b2e5bfec09 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 15:05:01 +0100 Subject: [PATCH 032/118] count down for system based problems --- objects/obj_star/Create_0.gml | 11 ++ scripts/MissionHelper/MissionHelper.gml | 125 +++++++++++------- scripts/scr_crusade/scr_crusade.gml | 8 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 3 + .../scr_player_fleet_functions.gml | 11 -- 5 files changed, 97 insertions(+), 61 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index e09142f3ac..fc12c3096a 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -127,6 +127,17 @@ add_problem = function(p_id, data){ } } +/// @self Asset.GMObject.obj_star +has_orbiting_player_fleet = function () { + if (instance_exists(obj_p_fleet)) { + var _nearest = instance_nearest(x, y, obj_p_fleet); + if (point_distance(_nearest.x, _nearest.y, x, y) == 0) { + return true; + } + } + return false; +} + system_player_ground_forces = 0; /// @desc Reports whether any planet in this system holds a garrison squad that still has members. diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/MissionHelper/MissionHelper.gml index d1814291e0..45b8871d9b 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/MissionHelper/MissionHelper.gml @@ -1,5 +1,5 @@ function SystemProblem(name, data = {}, system){ -timer = 0; +timer = -1; f_type = eP_FEATURES.MISSION; p_id = name; data = data; @@ -11,6 +11,50 @@ if (struct_exists(data, "members")){ members = data.members; } +static handle_triggered_mission_func = function(func){ + if (!is_undefined(func)){ + refresh_p_data(); + try { + func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + if (timer == -1 || (delete_mission)){ + var _prob = -1; + for (var i = 0; i < array_length(system.system_problems); i++){ + if (system.p_problem[i] == self){ + _prob = i; + } + } + if (_prob > -1){ + array_delete(system.system_problems, _prob,0); + } + } +} + +static basic_turn_end = function(){ + refresh_p_data(); + if (system.storm - 1 > 0){ + timer--; + } + if ((timer > -1) && per_turn_checks) { + var _func = undefined; + switch(p_id){ + } + handle_triggered_mission_func(_func) + } + if ((timer == 0) && zero_timer_checks && !delete_mission) { + var _func = undefined; + switch(p_id){ + case "great_crusade": + _func = resolve_great_crusade; + break; + } + handle_triggered_mission_func(_func) + } +} + static mark = function(colour){ with (system){ new_star_event_marker(colour) @@ -23,7 +67,6 @@ static init = function(){ great_crusade_init(); break; } - } static great_crusade_init(){ @@ -38,6 +81,35 @@ static great_crusade_init(){ mark("green") scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); } + +static resolve_great_crusade = function() { + var _player_fleet = scr_orbiting_player_fleet(system); + + if (_player_fleet != -1) { + var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); + with (_player_fleet) { + action_x = x + lengthdir_x(1200, _crusade_direction); + action_y = y + lengthdir_y(1200, _crusade_direction); + set_fleet_movement(false, "crusade1"); + } + + scr_alert("green", "crusade", "Fleet embarks upon Crusade.", system.x, system.y); + scr_event_log("", "Fleet embarks upon Crusade."); + } else { + // hit loyalty here + alter_dispositions([[eFACTION.INQUISITION, -10], [eFACTION.IMPERIUM, -5]]); + var _string = $"No ships designated for Crusade."; + if (obj_controller.penitent == 1) { + obj_controller.penitent_current = 0; + _string += "Your penitence crusade has been lengthened for your failings"; + } + + scr_alert("red", "crusade", _string, system.x, system.y); + scr_loyalty("Refusing to Crusade", "+"); + scr_event_log("red", "No ships designated for Crusade."); + } +} + } /// @param {sring} name @@ -106,8 +178,8 @@ static handle_triggered_mission_func = function(func){ } if (timer == -1 || (delete_mission)){ var _prob = -1; - for (var i = 0; i < array_length(system.p_problem); i++){ - if (system.p_problem[i] == self){ + for (var i = 0; i < array_length(p_data.problems); i++){ + if (p_data.problems[i] == self){ _prob = i; } } @@ -171,9 +243,6 @@ static basic_turn_end = function(){ case "inquisition_recon": _func = resolve_inquisition_recon; break; - case "great_crusade": - _func = resolve_great_crusade; - break; case "inquisition_necron": _func = resolve_inquisitor_necron; break; @@ -667,11 +736,11 @@ static per_turn_inquisition_recon = function() { }; scr_popup( "Investigation Completed", - "Your marines have scouted out {_p_data.name()} and satisfied the mission requirements.", + "Your marines have scouted out {p_data.name()} and satisfied the mission requirements.", "inquisition", _pop_data ); - scr_event_log("", $"Inquisition Mission Completed: Your Astartes have succesfully scouted {_p_data.name()}."); + scr_event_log("", $"Inquisition Mission Completed: Your Astartes have succesfully scouted {p_data.name()}."); delete_mission = true; @@ -685,42 +754,6 @@ static resolve_inquisition_recon = function() { scr_event_log("red", _alert_text); } -static resolve_great_crusade = function() { - var _crusade_direction; - var _join_crusade = false; - var _player_fleet = instance_nearest(p_data.system.x, p_data.system.y, obj_p_fleet); - - if (_player_fleet.action == "") { - if (point_distance(p_data.system.x, p_data.system.y, _player_fleet.x, _player_fleet.y) < 10) { - _join_crusade = true; - } - } - - if (_join_crusade) { - _crusade_direction = point_direction(room_width / 2, room_height / 2, p_data.system.x, p_data.system.y); - with (_player_fleet) { - action_x = x + lengthdir_x(1200, _crusade_direction); - action_y = y + lengthdir_y(1200, _crusade_direction); - set_fleet_movement(false, "crusade1"); - } - - scr_alert("green", "crusade", "Fleet embarks upon Crusade.", p_data.system.x, p_data.system.y); - scr_event_log("", "Fleet embarks upon Crusade."); - } else { - // hit loyalty here - alter_dispositions([[eFACTION.INQUISITION, -10], [eFACTION.IMPERIUM, -5]]); - var _string = $"No ships designated for Crusade."; - if (obj_controller.penitent == 1) { - obj_controller.penitent_current = 0; - _string += "Your penitence crusade has been lengthened for your failings"; - } - - scr_alert("red", "crusade", _string, p_data.system.x, p_data.system.y); - scr_loyalty("Refusing to Crusade", "+"); - scr_event_log("red", "No ships designated for Crusade."); - } -} - static resolve_inquisitor_necron = function() { alter_disposition(eFACTION.INQUISITION, -8); var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; @@ -878,7 +911,7 @@ function hunt_fallen_battle_aftermath() { exit; } delete_mission = true; - var _tixt = "The Fallen on " + _p_data.name(); + var _tixt = "The Fallen on " + p_data.name(); scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; var _tex_options = [ diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 6084dab487..7fdedd1637 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -212,16 +212,16 @@ function scr_crusade() { //TODO never place the star out of reach of a player fleet, eiter increase allowed response time or find nearer planet function launch_crusade() { - var star_id = scr_random_find(2, true, "", ""); - if (star_id == noone) { + var _star_id = scr_random_find(2, true, "", ""); + if (_star_id == noone) { LOGGER.error("RE: Crusade, couldn't find a star for the crusade"); return false; } else { - var _nearest_player_fleet = get_nearest_player_fleet(star_id.x, star_id.y); + var _nearest_player_fleet = get_nearest_player_fleet(_star_id.x, _star_id.y); if (_nearest_player_fleet == noone) { return false; } - star_id.add_problem("great_crusade", {nearest_player_fleet:_nearest_player_fleet}) + _star_id.add_problem("great_crusade", {nearest_player_fleet:_nearest_player_fleet}) return true; } } 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 c764f7f24d..f1733dc5ef 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -80,6 +80,9 @@ function scr_enemy_ai_d() { } } } + for (var i = 0; i < array_length(system_problems); i++){ + system_problems[i].basic_end_turn(); + } for (var i = 1; i <= planets; i++) { var _pdata = get_planet_data(i); 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 b432dced29..ae7cf0d7e8 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -625,17 +625,6 @@ function get_nearest_player_fleet(nearest_x, nearest_y, is_static = false, is_mo return chosen_fleet; } -/// @self Asset.GMObject.obj_star -function has_orbiting_player_fleet() { - if (instance_exists(obj_p_fleet)) { - var _nearest = instance_nearest(x, y, obj_p_fleet); - if (point_distance(_nearest.x, _nearest.y, x, y) == 0) { - return true; - } - } - return false; -} - function calculate_fleet_content_size(ship_array) { var total_content = 0; for (var i = 0; i < array_length(ship_array); i++) { From 21647884173d519300614cef55935545eecf2da3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 15:10:03 +0100 Subject: [PATCH 033/118] proper naming of files --- ChapterMaster.yyp | 3 +- .../PlanetProblem.gml} | 114 ----------------- .../PlanetProblem.yy} | 4 +- scripts/SystemProblem/SystemProblem.gml | 115 ++++++++++++++++++ scripts/SystemProblem/SystemProblem.yy | 13 ++ 5 files changed, 132 insertions(+), 117 deletions(-) rename scripts/{MissionHelper/MissionHelper.gml => PlanetProblem/PlanetProblem.gml} (94%) rename scripts/{MissionHelper/MissionHelper.yy => PlanetProblem/PlanetProblem.yy} (78%) create mode 100644 scripts/SystemProblem/SystemProblem.gml create mode 100644 scripts/SystemProblem/SystemProblem.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 253765e9d4..0a9916eb57 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -770,10 +770,10 @@ {"id":{"name":"LocalizationManager","path":"scripts/LocalizationManager/LocalizationManager.yy",},}, {"id":{"name":"Logger","path":"scripts/Logger/Logger.yy",},}, {"id":{"name":"macros","path":"scripts/macros/macros.yy",},}, - {"id":{"name":"MissionHelper","path":"scripts/MissionHelper/MissionHelper.yy",},}, {"id":{"name":"NameGenerator","path":"scripts/NameGenerator/NameGenerator.yy",},}, {"id":{"name":"NotificationAlert","path":"scripts/NotificationAlert/NotificationAlert.yy",},}, {"id":{"name":"object_get_depth","path":"scripts/object_get_depth/object_get_depth.yy",},}, + {"id":{"name":"PlanetProblem","path":"scripts/PlanetProblem/PlanetProblem.yy",},}, {"id":{"name":"scr_add_corruption","path":"scripts/scr_add_corruption/scr_add_corruption.yy",},}, {"id":{"name":"scr_add_item","path":"scripts/scr_add_item/scr_add_item.yy",},}, {"id":{"name":"scr_add_man","path":"scripts/scr_add_man/scr_add_man.yy",},}, @@ -993,6 +993,7 @@ {"id":{"name":"SectorHandler","path":"scripts/SectorHandler/SectorHandler.yy",},}, {"id":{"name":"Set","path":"scripts/Set/Set.yy",},}, {"id":{"name":"SettingsManager","path":"scripts/SettingsManager/SettingsManager.yy",},}, + {"id":{"name":"SystemProblem","path":"scripts/SystemProblem/SystemProblem.yy",},}, {"id":{"name":"TooltipBuilder","path":"scripts/TooltipBuilder/TooltipBuilder.yy",},}, {"id":{"name":"turn_towards_point","path":"scripts/turn_towards_point/turn_towards_point.yy",},}, {"id":{"name":"UIComponents","path":"scripts/UIComponents/UIComponents.yy",},}, diff --git a/scripts/MissionHelper/MissionHelper.gml b/scripts/PlanetProblem/PlanetProblem.gml similarity index 94% rename from scripts/MissionHelper/MissionHelper.gml rename to scripts/PlanetProblem/PlanetProblem.gml index 45b8871d9b..0e2ca6ad16 100644 --- a/scripts/MissionHelper/MissionHelper.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1,117 +1,3 @@ -function SystemProblem(name, data = {}, system){ -timer = -1; -f_type = eP_FEATURES.MISSION; -p_id = name; -data = data; -self.system = system; -if (struct_exists(data, "stage")){ - stage_id = data.stage; -} -if (struct_exists(data, "members")){ - members = data.members; -} - -static handle_triggered_mission_func = function(func){ - if (!is_undefined(func)){ - refresh_p_data(); - try { - func(); - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } - if (timer == -1 || (delete_mission)){ - var _prob = -1; - for (var i = 0; i < array_length(system.system_problems); i++){ - if (system.p_problem[i] == self){ - _prob = i; - } - } - if (_prob > -1){ - array_delete(system.system_problems, _prob,0); - } - } -} - -static basic_turn_end = function(){ - refresh_p_data(); - if (system.storm - 1 > 0){ - timer--; - } - if ((timer > -1) && per_turn_checks) { - var _func = undefined; - switch(p_id){ - } - handle_triggered_mission_func(_func) - } - if ((timer == 0) && zero_timer_checks && !delete_mission) { - var _func = undefined; - switch(p_id){ - case "great_crusade": - _func = resolve_great_crusade; - break; - } - handle_triggered_mission_func(_func) - } -} - -static mark = function(colour){ - with (system){ - new_star_event_marker(colour) - } -} - -static init = function(){ - switch(p_id){ - case "great_crusade": - great_crusade_init(); - break; - } -} - -static great_crusade_init(){ - //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards - _nearest_player_fleet = data.nearest_player_fleet; - var _travel_leeway = 10; - if (_nearest_player_fleet.action == "move") { - _travel_leeway += _nearest_player_fleet.action_eta; - } - timer = get_viable_travel_time(_travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, star_id.x, star_id.y, _nearest_player_fleet, false); - scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {star_id.name}; {_eta} months from now your ships there shall begin their journey.", "crusade", ""); - mark("green") - scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); -} - -static resolve_great_crusade = function() { - var _player_fleet = scr_orbiting_player_fleet(system); - - if (_player_fleet != -1) { - var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); - with (_player_fleet) { - action_x = x + lengthdir_x(1200, _crusade_direction); - action_y = y + lengthdir_y(1200, _crusade_direction); - set_fleet_movement(false, "crusade1"); - } - - scr_alert("green", "crusade", "Fleet embarks upon Crusade.", system.x, system.y); - scr_event_log("", "Fleet embarks upon Crusade."); - } else { - // hit loyalty here - alter_dispositions([[eFACTION.INQUISITION, -10], [eFACTION.IMPERIUM, -5]]); - var _string = $"No ships designated for Crusade."; - if (obj_controller.penitent == 1) { - obj_controller.penitent_current = 0; - _string += "Your penitence crusade has been lengthened for your failings"; - } - - scr_alert("red", "crusade", _string, system.x, system.y); - scr_loyalty("Refusing to Crusade", "+"); - scr_event_log("red", "No ships designated for Crusade."); - } -} - -} - /// @param {sring} name /// @param {Real} timer /// @param {struct} data diff --git a/scripts/MissionHelper/MissionHelper.yy b/scripts/PlanetProblem/PlanetProblem.yy similarity index 78% rename from scripts/MissionHelper/MissionHelper.yy rename to scripts/PlanetProblem/PlanetProblem.yy index 650909366b..7469c69c2d 100644 --- a/scripts/MissionHelper/MissionHelper.yy +++ b/scripts/PlanetProblem/PlanetProblem.yy @@ -1,9 +1,9 @@ { "$GMScript":"v1", - "%Name":"MissionHelper", + "%Name":"PlanetProblem", "isCompatibility":false, "isDnD":false, - "name":"MissionHelper", + "name":"PlanetProblem", "parent":{ "name":"Scripts", "path":"folders/Scripts.yy", diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml new file mode 100644 index 0000000000..1836c57771 --- /dev/null +++ b/scripts/SystemProblem/SystemProblem.gml @@ -0,0 +1,115 @@ +/// @param {sring} name +/// @param {struct} data +function SystemProblem(name, data = {}, system){ +timer = -1; +f_type = eP_FEATURES.MISSION; +p_id = name; +data = data; +self.system = system; +if (struct_exists(data, "stage")){ + stage_id = data.stage; +} +if (struct_exists(data, "members")){ + members = data.members; +} + +static handle_triggered_mission_func = function(func){ + if (!is_undefined(func)){ + refresh_p_data(); + try { + func(); + } catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); + } + } + if (timer == -1 || (delete_mission)){ + var _prob = -1; + for (var i = 0; i < array_length(system.system_problems); i++){ + if (system.p_problem[i] == self){ + _prob = i; + } + } + if (_prob > -1){ + array_delete(system.system_problems, _prob,0); + } + } +} + +static basic_turn_end = function(){ + refresh_p_data(); + if (system.storm - 1 > 0){ + timer--; + } + if ((timer > -1) && per_turn_checks) { + var _func = undefined; + switch(p_id){ + } + handle_triggered_mission_func(_func) + } + if ((timer == 0) && zero_timer_checks && !delete_mission) { + var _func = undefined; + switch(p_id){ + case "great_crusade": + _func = resolve_great_crusade; + break; + } + handle_triggered_mission_func(_func) + } +} + +static mark = function(colour){ + with (system){ + new_star_event_marker(colour) + } +} + +static init = function(){ + switch(p_id){ + case "great_crusade": + init_great_crusade(); + break; + } +} + +static init_great_crusade(){ + //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards + _nearest_player_fleet = data.nearest_player_fleet; + var _travel_leeway = 10; + if (_nearest_player_fleet.action == "move") { + _travel_leeway += _nearest_player_fleet.action_eta; + } + timer = get_viable_travel_time(_travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, star_id.x, star_id.y, _nearest_player_fleet, false); + scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {star_id.name}; {_eta} months from now your ships there shall begin their journey.", "crusade", ""); + mark("green") + scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); +} + +static resolve_great_crusade = function() { + var _player_fleet = scr_orbiting_player_fleet(system); + + if (_player_fleet != -1) { + var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); + with (_player_fleet) { + action_x = x + lengthdir_x(1200, _crusade_direction); + action_y = y + lengthdir_y(1200, _crusade_direction); + set_fleet_movement(false, "crusade1"); + } + + scr_alert("green", "crusade", "Fleet embarks upon Crusade.", system.x, system.y); + scr_event_log("", "Fleet embarks upon Crusade."); + } else { + // hit loyalty here + alter_dispositions([[eFACTION.INQUISITION, -10], [eFACTION.IMPERIUM, -5]]); + var _string = $"No ships designated for Crusade."; + if (obj_controller.penitent == 1) { + obj_controller.penitent_current = 0; + _string += "Your penitence crusade has been lengthened for your failings"; + } + + scr_alert("red", "crusade", _string, system.x, system.y); + scr_loyalty("Refusing to Crusade", "+"); + scr_event_log("red", "No ships designated for Crusade."); + } +} + +} \ No newline at end of file diff --git a/scripts/SystemProblem/SystemProblem.yy b/scripts/SystemProblem/SystemProblem.yy new file mode 100644 index 0000000000..21231b06ff --- /dev/null +++ b/scripts/SystemProblem/SystemProblem.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"SystemProblem", + "isCompatibility":false, + "isDnD":false, + "name":"SystemProblem", + "parent":{ + "name":"Constructors", + "path":"folders/Scripts/Constructors.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file From bfd670d2367e589a644d292e6a0bdb48007e3699 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 15:24:55 +0100 Subject: [PATCH 034/118] make it compile --- objects/obj_ncombat/Alarm_1.gml | 2 +- objects/obj_ncombat/Alarm_5.gml | 4 +- objects/obj_ncombat/Alarm_7.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 46 +++++++++---------- scripts/SystemProblem/SystemProblem.gml | 6 +-- .../scr_mission_functions.gml | 4 -- scripts/scr_shoot/scr_shoot.gml | 4 +- 7 files changed, 32 insertions(+), 36 deletions(-) diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 364c3f98e0..65081e556a 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -98,7 +98,7 @@ if (battle_special == "") { if (battle_special == "spyrer") { p1 = "Your marines search through the alleyways and corridors likely to contain the Spyrer. It does not take long before the lunatic attacks, springing off from a wall to fall among your men. Your ranks are made up of "; } -if (battle_special == "protect_raiders", battle_special) { +if (battle_special == "protect_raiders") { p1 = "Following responses from scans, Your marine squad deploys and lies in wait on the planets surface. Either the eldar were expecting you or the scope of the raids on the planet had been underplayed by the governor perhaps to hide his incompetence in allowing such foul xenos actions to persist unchecked for so long."; } if (battle_special == "hunt_fallen") { diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index a1ee02d87f..6c4a6a3690 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -352,7 +352,7 @@ var _non_power_reduce_events = [ if (array_contains(_non_power_reduce_events, battle_special)) { reduce_power = false; } -} else if (string_count("ruins", battle_special) > 0) { +else if (string_count("ruins", battle_special) > 0) { reduce_power = false; } @@ -542,7 +542,7 @@ if (defeat == 0 && reduce_power) { } if (battle_special != ""){ - if (is_struct(special_feature), && is_instanceof(special_feature, PlanetProblem)){ + if (is_struct(special_feature) && is_instanceof(special_feature, PlanetProblem)){ special_feature.battle_final_message(); } } diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index a14fc0d107..0d4cad7fc2 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -270,7 +270,7 @@ try { } } - if (is_struct(special_feature), && is_instanceof(special_feature, PlanetProblem)){ + if (is_struct(special_feature) && is_instanceof(special_feature, PlanetProblem)){ special_feature.after_battle_effects(); } if ((enemy == eFACTION.PLAYER && on_ship == true) && (!defeat)) { diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 0e2ca6ad16..f9ea885bc7 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -83,22 +83,23 @@ static basic_turn_end = function(){ if ((timer > -1) && per_turn_checks) { var _func = undefined; switch(p_id){ - case "mech_raider"; + case "mech_raider": _func = per_turn_check_raider_failed; break; case "mech_bionics": _func = per_turn_check_mech_bionics; break; case "mech_tomb": - switch(stage_id): - break; + switch(stage_id){ case "exploring": _func = per_turn_check_mech_tomb2; break; - case "awaiting_player"; + case "awaiting_player": default: _func = per_turn_check_mech_tomb1; break; + } + break; case "spyrer": _func = per_turn_check_spyrer; break; @@ -138,13 +139,13 @@ static basic_turn_end = function(){ case "hunt_fallen": _func = resolve_fallen; break; - case "mech_raider"; + case "mech_raider": _func = resolve_mech_raider_failed; break; case "mech_bionics": _func = resolve_mech_bionics; break; - case "mech_tomb"; + case "mech_tomb": _func = resolve_mech_tomb1_failed; break; case "mech_mars": @@ -256,7 +257,7 @@ static on_unit_selection = function(){ instance_deactivate_object(obj_star); } -static __init(){ +static __init = function(){ switch(p_id){ case "inquisition_necron": mark("green"); @@ -291,6 +292,7 @@ static __init(){ break; default: mark("green"); + break; } } @@ -306,17 +308,17 @@ static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, ene obj_turn_end.battle_object[_battle_index] = system; obj_turn_end.battle_special[_battle_index] = { special_id : special_id, - special_feature : self + special_feature : self, }; if (is_undefined(enemy_data)){ enemy_data = { } } if (!struct_exists(enemy_data, "reduce_power")){ - enemy_data.reduce_power = false, + enemy_data.reduce_power = false; } if (!struct_exists(enemy_data, "reduce_fortification")){ - enemy_data.reduce_fortification = false, + enemy_data.reduce_fortification = false; } obj_turn_end.battle_special[_battle_index].battle_enemy_data = enemy_data; } @@ -435,7 +437,7 @@ static complete_beast_hunt_mission = function() { } -stati init_train_forces_mission = fuction() { +static init_train_forces_mission = fuction() { if (stage_id != "preliminary" || array_length(members) = 0) { exit; } @@ -684,7 +686,7 @@ static per_turn_check_spyrer = function() { ] } ] - }; + } ); } } @@ -923,7 +925,7 @@ static per_turn_check_mech_tomb1 = function() { if (array_length(_marines) >= 20) { stage_id = "exploring"; timer = 999; - data.turns : 0; + data.turns = 0; scr_popup("Mechanicus Research", $"The Mechanicus Research team on planet {p_data.name()} has taken note of your Astartes and are now prepared to begin their research. Your marines are to stay on the planet until further notice.", "necron_cave", ""); } } @@ -1153,7 +1155,8 @@ static protect_raider_squad_selected = function() { _gar_pop.add_option("continue"); } } else { - var _battle = new_battle(eFACTION.ELDAR) + var _battle = new_battle(eFACTION.ELDAR); + _roster = new Roster(); with (_roster) { selected_units = _squad_units; @@ -1161,7 +1164,6 @@ static protect_raider_squad_selected = function() { add_to_battle(); } exit_adhoc_manage(); - delete_mission _roster; _battle.battle_enemy_data = { threat : 3, @@ -1201,7 +1203,6 @@ static protect_raider_squad_selected = function() { }; } } -} static per_turn_check_inqisition_tomb = function() { if (p_player[run] <= 0){ @@ -1331,7 +1332,7 @@ static necron_tomb_mission_sequence = function() { { name : "Necron Wraith", number : 1 - } + }, { name : "Necron Wraith", number : 1 @@ -1350,7 +1351,7 @@ static necron_tomb_mission_sequence = function() { { name : "Canoptek Spyder", number : 1 - } + }, { name : "Canoptek Scarab", number : 20 @@ -1387,9 +1388,8 @@ static necron_tomb_mission_sequence = function() { var _battle = new_battle( eFACTION.NECRONS, - p_id, - _battle_data ) + _battle.battle_enemy_data = _battle_data; _roster = new Roster(); with (_roster) { roster_location = system.name; @@ -1402,7 +1402,7 @@ static necron_tomb_mission_sequence = function() { add_to_battle(); } } - delete_mission _roster; + instance_deactivate_object(obj_star); instance_destroy(obj_popup); @@ -1606,7 +1606,7 @@ static inquisition_tyranid_org_battle_aftermath = function(){ } else { var _text = "You have captured a Gaunt organism- the Inquisitor is pleased with your work. The Tyranid will be stored until it may be retrieved. The mission is a success."; } - scr_popup("Inquisition Mission Completed",, "inquisition", ""); + scr_popup("Inquisition Mission Completed",_text, "inquisition", ""); if (data.captured_gaunt > 0) { delete_mission = true; } @@ -1635,7 +1635,7 @@ static hive_fleet_to_cult_init = function(){ static per_turn_hive_fleet_to_cult = function(){ if (timer != 3 || scr_has_disadv("Psyker Intolerant")){ - continue; + exit; } var _has_head_lib = scr_role_count(obj_ini.player_role_data[eROLE.CHIEFLIBRARIAN].role, ""); diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 1836c57771..a0d5399f23 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -42,8 +42,8 @@ static basic_turn_end = function(){ } if ((timer > -1) && per_turn_checks) { var _func = undefined; - switch(p_id){ - } + /*switch(p_id){ + }*/ handle_triggered_mission_func(_func) } if ((timer == 0) && zero_timer_checks && !delete_mission) { @@ -71,7 +71,7 @@ static init = function(){ } } -static init_great_crusade(){ +static init_great_crusade = function(){ //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards _nearest_player_fleet = data.nearest_player_fleet; var _travel_leeway = 10; diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index e64fa21968..c7b6253f2c 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -81,10 +81,6 @@ function mission_name_key(mission) { } } -/// @self Struct.PlanetData -function problem_end_turn_checks() { - - /// @self Asset.GMObject.obj_star function scr_new_governor_mission(planet, problem = "") { if (p_owner[planet] != eFACTION.IMPERIUM) { diff --git a/scripts/scr_shoot/scr_shoot.gml b/scripts/scr_shoot/scr_shoot.gml index cc92513e9a..f9d87bb2f1 100644 --- a/scripts/scr_shoot/scr_shoot.gml +++ b/scripts/scr_shoot/scr_shoot.gml @@ -496,13 +496,13 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat obj_ncombat.enemy_forces -= casualties; } if (obj_ncombat.battle_special != ""){ - if (is_struct(obj_ncombat.special_feature), && is_instanceof(obj_ncombat.special_feature, PlanetProblem)){ + if (is_struct(obj_ncombat.special_feature) && is_instanceof(obj_ncombat.special_feature, PlanetProblem)){ var _feat = obj_ncombat.special_feature; _feat.casualty_packet = { number : casualties, target : target_object, target_type, - weapon : weapon_index_position < 0 : "defences" : wep_title[weapon_index_position] + weapon : weapon_index_position < 0 ? "defences" : wep_title[weapon_index_position] } _feat.battle_on_enemy_casulties(); From e60e3dd96bc656cf51bc2a83580028576d33b8b3 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 15:43:25 +0100 Subject: [PATCH 035/118] review points --- objects/obj_star/Create_0.gml | 8 ++--- scripts/PlanetProblem/PlanetProblem.gml | 40 ++++++++++++----------- scripts/SystemProblem/SystemProblem.gml | 16 +++++---- scripts/scr_PlanetData/scr_PlanetData.gml | 10 +++--- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index fc12c3096a..9e8dfda855 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -67,7 +67,7 @@ p_operatives = array_create_advanced(_planet_array_size, []); p_feature = array_create_advanced(_planet_array_size, []); p_upgrades = array_create_advanced(_planet_array_size, []); p_influence = array_create_advanced(_planet_array_size, array_create(15, 0)); -p_problem = []; +p_problem = array_create_advanced(_planet_array_size, []); p_psionic = []; for (var i = 0; i < _planet_array_size; i++) { p_psionic[i] = irandom(5); @@ -122,9 +122,9 @@ add_feature = function(planet, feature) { system_problems = []; add_problem = function(p_id, data){ - array_push(system_problems, new SystemProblem(name, data, system)){ - - } + var _prob = new SystemProblem(name, data, system); + array_push(system_problems, _prob); + return _prob; } /// @self Asset.GMObject.obj_star diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index f9ea885bc7..6dea32d796 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -70,14 +70,14 @@ static handle_triggered_mission_func = function(func){ } } if (_prob > -1){ - array_delete(system.p_problem, _prob,0); - array_delete(p_data.problems, _prob,0); + array_delete(system.p_problem, _prob,1); + array_delete(p_data.problems, _prob,1); } } } static basic_turn_end = function(){ refresh_p_data(); - if (p_data.system.storm - 1 > 0){ + if (p_data.system.storm <= 0){ timer--; } if ((timer > -1) && per_turn_checks) { @@ -174,7 +174,7 @@ static before_battle_effects = function(){ //triggered at the end of scr_shoot static battle_on_enemy_casulties = function(){ - if (!struct_exists(self, casualty_packet)){ + if (!struct_exists(self, "casualty_packet")){ exit; } instance_activate_object(obj_star); @@ -369,13 +369,13 @@ static init_beast_hunt_mission = function() { } static complete_beast_hunt_mission = function() { - var _hunters = collect_role_group("all", [system.name, planet, 0], false, man_conditions); + var _man_conditions = { + "job": "hunt_beast", + "max": 3, + }; + var _hunters = collect_role_group("all", [system.name, planet, 0], false, _man_conditions); if (stage_id == "active") { var _mission_string = ""; - var man_conditions = { - "job": "hunt_beast", - "max": 3, - }; var _success = false; var _tester = global.character_tester; var _unit_pass; @@ -437,8 +437,8 @@ static complete_beast_hunt_mission = function() { } -static init_train_forces_mission = fuction() { - if (stage_id != "preliminary" || array_length(members) = 0) { +static init_train_forces_mission = function() { + if (stage_id != "preliminary" || array_length(members) == 0) { exit; } var _trainer = members[0]; @@ -458,14 +458,14 @@ static init_train_forces_mission = fuction() { p_data.add_disposition(3); } - data.assigned_unit = marine.uid; + data.assigned_unit = _trainer.uid; //pip.image="event_march" - _gar_pop.add_option($"Good luck {marine.name()}"); + _gar_pop.add_option($"Good luck {_trainer.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.", p_data.system.name); + scr_event_log("", $"{_trainer.name_role()} deployed to {_numeral_name} for {_mission_length} months.", p_data.system.name); obj_controller.close_popups = false; } @@ -475,7 +475,7 @@ static complete_train_forces_mission = function() { } var _mission_string = ""; var _trainer = fetch_unit_uid(data.assigned_unit); - if (is_struct(_trainer)) { + if (!is_struct(_trainer)) { exit; } var _unit_report_string = ""; @@ -665,7 +665,7 @@ static resolve_spyrer = function() { static per_turn_check_spyrer = function() { if (p_data.player_forces > 20) { - var _tixt = "The Spyrer on " + planet_numeral_name(run, id) + " seems to have vanished, presumably gone into hiding."; + var _tixt = $"The Spyrer on {p_data.name()} seems to have vanished, presumably gone into hiding."; scr_popup("Spyrer Rampage", _tixt, "spyrer", ""); } else if (p_data.player_forces <= 20) { new_end_turn_battle( @@ -1341,8 +1341,9 @@ static necron_tomb_mission_sequence = function() { } ] - special_feature.data.enemy = "wraith"; + data.enemy = "wraith"; case 2: + break; _battle_data.cols = [ { distance : 10, @@ -1360,8 +1361,9 @@ static necron_tomb_mission_sequence = function() { } ] - special_feature.data.enemy = "spyder" + data.enemy = "spyder" case 3: + break; _battle_data.cols = [ { distance : 10, @@ -1375,7 +1377,7 @@ static necron_tomb_mission_sequence = function() { } ] - special_feature.data.enemy = "stalker" + data.enemy = "stalker" break; case 4: _battle_data.threat = 2 diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index a0d5399f23..1f92e3e0d0 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -5,7 +5,11 @@ timer = -1; f_type = eP_FEATURES.MISSION; p_id = name; data = data; +stage_id = ""; self.system = system; +zero_timer_checks = true; +delete_mission = false; +members = []; if (struct_exists(data, "stage")){ stage_id = data.stage; } @@ -15,7 +19,6 @@ if (struct_exists(data, "members")){ static handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ - refresh_p_data(); try { func(); } catch (_exception) { @@ -25,18 +28,17 @@ static handle_triggered_mission_func = function(func){ if (timer == -1 || (delete_mission)){ var _prob = -1; for (var i = 0; i < array_length(system.system_problems); i++){ - if (system.p_problem[i] == self){ + if (system.system_problems[i] == self){ _prob = i; } } if (_prob > -1){ - array_delete(system.system_problems, _prob,0); + array_delete(system.system_problems, _prob,1); } } } static basic_turn_end = function(){ - refresh_p_data(); if (system.storm - 1 > 0){ timer--; } @@ -73,13 +75,13 @@ static init = function(){ static init_great_crusade = function(){ //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards - _nearest_player_fleet = data.nearest_player_fleet; + var _nearest_player_fleet = data.nearest_player_fleet; var _travel_leeway = 10; if (_nearest_player_fleet.action == "move") { _travel_leeway += _nearest_player_fleet.action_eta; } - timer = get_viable_travel_time(_travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, star_id.x, star_id.y, _nearest_player_fleet, false); - scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {star_id.name}; {_eta} months from now your ships there shall begin their journey.", "crusade", ""); + timer = get_viable_travel_time(_travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, system.x, system.y, _nearest_player_fleet, false); + scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {system.name}; {timer} months from now your ships there shall begin their journey.", "crusade", ""); mark("green") scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 5806363aee..5d28fb5ffc 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -769,7 +769,7 @@ function PlanetData(_planet, _system) constructor { } static register_problem = function(problem){ - array_push(p_problem[planet], problem); + array_push(system.p_problem[planet], problem); problems = system.p_problem[planet]; } @@ -1403,11 +1403,9 @@ function PlanetData(_planet, _system) constructor { for (var i = 0; i < array_length(problems); i++) { var _problem = problems[i]; if (problem_data.stage_id == "preliminary") { - var mission_string = localize("{0} Audience", [_problem.data.applicant]); - problem_data.time = problem_timers[i]; - problem_data.problem = problems[i]; - problem_data.array_position = i; - array_push(planet_displays, [mission_string, _problem]); + var _mission_string = localize("{0} Audience", [_problem.data.applicant]); + problem_data.problem = _problem; + array_push(planet_displays, [_mission_string, _problem]); } } From 467dd7f3c26eac96a7bf8327152b18df043b8ba0 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 18:13:23 +0100 Subject: [PATCH 036/118] fully move inquisition recon to the new format also create popup_call to simplify triggering planetmission methods from within popups --- objects/obj_ncombat/Alarm_0.gml | 7 +- objects/obj_ncombat/Alarm_1.gml | 16 ++-- objects/obj_popup/Step_0.gml | 14 --- objects/obj_turn_end/Mouse_56.gml | 9 +- scripts/PlanetProblem/PlanetProblem.gml | 85 +++++++++++++------ scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- .../scr_inquisition_mission.gml | 69 +++++++-------- .../scr_mission_functions.gml | 4 +- scripts/scr_random_event/scr_random_event.gml | 2 +- 9 files changed, 109 insertions(+), 99 deletions(-) diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 9587650f2d..9368794581 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -131,7 +131,7 @@ try { u.column = (_num - j) - ((xxx / 10) - 10); } - var _enemies_assiged = false; + var _enemies_assigned = false; if (!is_undefined(battle_enemy_data)){ move_data_to_curret_scope(battle_enemy_data); if (struct_exists(battle_enemy_data , "cols")){ @@ -149,11 +149,10 @@ try { } u.add_enemies(_col.enemies); } - enemies_assiged = true; + _enemies_assigned = true; } } - - if (!enemies_assiged){ + if (!_enemies_assigned){ // * Praetorian Servitor Group * if (string_count("mech", battle_special) > 0) { fortified = 0; diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 65081e556a..561481d4bb 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -138,26 +138,24 @@ if ("inquisition_necron" == battle_special) { if (special_feature.data.tomb_awakens) { p1 = "Cave dirt crunches beneath the soles of your marines as they continue their descent. There is little warning when the ground begins to shake. An old, dusty breeze seems to flow through the tunnel, followed by rumbling sensations and distant mechanical sounds. "; - if (threat = 2) { + if (threat == 2) { p1 += "Within minutes Necrons begin to appear from every direction. There appears to be nearly fourty, cramped in the dark tunnels."; } - else if (threat = 3) { + else if (threat == 3) { p1 += "Within minutes Necrons begin to appear from every direction. There appears to be nearly a hundred, cramped in the dark tunnels."; } - else if (threat = 4) { + else if (threat == 4) { p1 += "Within minutes Necrons begin to appear from every direction. Their numbers are wihout number."; } - } else { - - } + } - if (special_feature.data.enemy = "wraith") { + if (special_feature.data.enemy == "wraith") { p1 += "two Necron Wraiths appear out of nowhere and begin to attack."; } - if (special_feature.data.enemy = "spyder") { + if (special_feature.data.enemy == "spyder") { p1 += "a large Canoptek Spyder launches towards your marines, a small group of scuttling Scarabs quickly following."; } - if (special_feature.data.enemy = "stalker") { + if (special_feature.data.enemy == "stalker") { p1 += "the tunnel begins to shake and a massive Tomb Stalker scuttles into your midst."; } _newline = p1; diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index bbcfb27817..cab5e4164d 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -208,20 +208,6 @@ try { } if ((press == 0) && array_length(options) || ((demand == 1) && (mission != "") && (string_count("Inquisition", title) > 0)) || ((demand == 1) && (title == "Inquisition Recon"))) { - if (title == "Inquisition Recon") { - obj_controller.temp[200] = string(loc); - var _mission_star = find_star_by_name(obj_controller.temp[200]); - var _pdata = _mission_star.get_planet_data(planet); - var _problem = new_problem("recon", estimate); - - title = "Inquisition Mission Demand"; - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to land Astartes on {_mission_star.name} {scr_roman(planet)} to investigate the planet within {estimate} months."; - with (_mission_star) { - new_star_event_marker("green"); - } - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {_mission_star.name} {scr_roman(planet)} within {estimate} months.", _mission_star.name); - - } if ((mission != "") && (title == "Inquisition Mission")) { obj_controller.temp[200] = string(loc); diff --git a/objects/obj_turn_end/Mouse_56.gml b/objects/obj_turn_end/Mouse_56.gml index 0a27d3cf71..b5fffeca97 100644 --- a/objects/obj_turn_end/Mouse_56.gml +++ b/objects/obj_turn_end/Mouse_56.gml @@ -150,10 +150,11 @@ if (!instance_exists(obj_saveload) && !instance_exists(obj_popup) && !instance_e } if (is_struct(battle_special[current_battle])){ - obj_ncombat.battle_special = battle_special[current_battle].special_id; - obj_ncombat.special_feature = battle_special[current_battle].special_feature; - if (struct_exists(battle_special[current_battle], "battle_enemy_data")){ - obj_ncombat.battle_enemy_data = battle_enemy_data; + var _spec_data = battle_special[current_battle]; + obj_ncombat.battle_special = _spec_data.special_id; + obj_ncombat.special_feature = _spec_data.special_feature; + if (struct_exists(_spec_data, "battle_enemy_data")){ + obj_ncombat.battle_enemy_data = _spec_data.battle_enemy_data; } } else { obj_ncombat.battle_special = battle_special[current_battle]; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 6dea32d796..d6a9045dcc 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -53,6 +53,36 @@ static increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } +static popup_call = function(func){ + var _func = function(){ + pop_data.mission[$ "func"](); + } + return _func; +} + +static inquisition_mission_options = fuction(mission_accept_function){ + var _options = [ + { + str1: "Accept", + choice_func: function(){ + pop_data.mission[$ mission_accept_function](); + obj_controller.demanding = 0; + } + }, + ]; + if (!obj_controller.demanding){ + array_push(_options, { + str1: "Refuse", + choice_func: function(){ + pop_data.mission.delete_mission = true; + popup_default_close(); + } + }) + } + return _options +} + + static handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ refresh_p_data(); @@ -290,6 +320,8 @@ static __init = function(){ case "hive_fleet_to_cult": hive_fleet_to_cult_init(); break; + case "inquisition_recon": + inquisition_recon_init(); default: mark("green"); break; @@ -614,6 +646,25 @@ static resolve_succession = function() { p_data.delete_feature(eP_FEATURES.SUCCESSION_WAR); } + +static inquisition_recon_init = function(){ + + var _pop_data = { + mission: self, + options : inquisition_mission_options("") + }; + + var text = $"The Inquisition wishes for you to investigate {p_data.name()}"; + text += $" Boots are expected to be planted on its surface over the course of your investigation."; + text += $" You have {string(eta)} months to complete this task."; + scr_popup("Inquisition Recon", text, "inquisition", $"recon|{string(_star.name)}|{string(planet)}|{string(eta)}|"); +} + +static inquisition_recon_accept = function(){ + mark("green"); + scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {p_data.name()} within {timer} months.", system.name); +} + static per_turn_inquisition_recon = function() { if (p_data.player_forces <= 0){ exit; @@ -1006,7 +1057,7 @@ static resolve_mech_mars = function() { } -static init_garrison_mission = function() { +static provide_garrison_init = function() { var mission_data = problems_data[mission_slot]; if (stage_id != "preliminary") { exit; @@ -1216,7 +1267,7 @@ static per_turn_check_inqisition_tomb = function() { exit; } var _tixt; - _tixt = $"Your marines on {planet_numeral_name(planet, id)}"; + _tixt = $"Your marines on {p_data.name()}"; _tixt += " are prepared and ready to enter the Necron Tombs. A Plasma Bomb is in tow."; var _number = instance_exists(obj_turn_end) ? 1 : 0; var _pop_data = { @@ -1228,9 +1279,7 @@ static per_turn_check_inqisition_tomb = function() { options: [ { str1: "Begin the Mission", - choice_func: function(){ - mission.necron_tomb_mission_start(); - }, + choice_func: popup_call("necron_tomb_mission_start"), }, { str1: "Not Yet", @@ -1243,7 +1292,10 @@ static per_turn_check_inqisition_tomb = function() { static necron_tomb_mission_start = function() { obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; - obj_popup.replace_options([{str1: "Continue", choice_func: self.necron_tomb_mission_sequence}, {str1: "Return to the surface", choice_func: popup_default_close}]); + obj_popup.replace_options([ + {str1: "Continue", choice_func: popup_call("necron_tomb_mission_sequence")}, + {str1: "Return to the surface", choice_func: popup_default_close} + ]); obj_popup.image = "necron_tunnels_1"; obj_popup.text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; } @@ -1499,27 +1551,6 @@ static advance_necron_tomb_mission = function() { return false; } -static inquisition_mission_options = fuction(mission_accept_function){ - var _options = [ - { - str1: "Accept", - choice_func: function(){ - pop_data.mission[$ mission_accept_function](); - obj_controller.demanding = 0; - } - }, - ]; - if (!obj_controller.demanding){ - array_push(_options, { - str1: "Refuse", - choice_func: function(){ - pop_data.mission.delete_mission = true; - popup_default_close(); - } - }) - } - return _options -} static inquisition_demon_world_init = fuction(){ var _text = $"The Inquisitor is trusting you with a special mission. The planet {p_data.name()} has been uncovered as a Demon World"; if (obj_controller.demanding) { diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 5d28fb5ffc..dea15193e1 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1520,7 +1520,7 @@ function PlanetData(_planet, _system) constructor { //if there was an outstanding mission to provide the given garrison var _garrison_request = find_problem("provide_garrison"); if (is_struct(_garrison_request)) { - _garrison_request.init_garrison_mission(); + _garrison_request.provide_garrison_init(); } instance_destroy(obj_star_select); }; diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 5691a60fff..aa88beacb2 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -112,10 +112,10 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA } } - var eta = scr_mission_eta(_star.x, _star.y, 1); - eta = min(max(eta, 6), 50); + var _eta = scr_mission_eta(_star.x, _star.y, 1); + _eta = min(max(_eta, 6), 50); - _star.get_planet_data(planet).new_problem("tyranid_org", eta); + _star.get_planet_data(planet).new_problem("tyranid_org", _eta); break; case eINQUISITION_MISSION.ETHEREAL: mission_inquisition_ethereal(); @@ -159,11 +159,11 @@ function mission_inquisition_ethereal() { break; } } - var eta = scr_mission_eta(_star.x, _star.y, 1); - eta = min(max(eta, 12), 50); + var _eta = scr_mission_eta(_star.x, _star.y, 1); + _eta = min(max(_eta, 12), 50); var text = $"An Inquisitor is trusting you with a special mission."; - text += $"They require that you capture a Tau Ethereal from the planet {string(_star.name)} {scr_roman(planet)} for research purposes. You have {string(eta)} months to locate and capture one. Can your chapter handle this mission?"; - scr_popup("Inquisition Mission", text, "inquisition", $"ethereal|{string(_star.name)}|{string(planet)}|{string(eta + 1)}|"); + text += $"They require that you capture a Tau Ethereal from the planet {string(_star.name)} {scr_roman(planet)} for research purposes. You have {string(_eta)} months to locate and capture one. Can your chapter handle this mission?"; + scr_popup("Inquisition Mission", text, "inquisition", $"ethereal|{string(_star.name)}|{string(planet)}|{string(_eta + 1)}|"); } function mission_inquisition_tyranid_organism(worlds) { @@ -185,7 +185,7 @@ function mission_inquisition_necron_world(tomb_worlds) { array_push(_star.p_feature[planet], new NewPlanetFeature(eP_FEATURES.NECRON_TOMB)); } - var eta = scr_mission_eta(_star.x, _star.y, 1); + var _eta = scr_mission_eta(_star.x, _star.y, 1); if (global.cheat_debug) { LOGGER.debug("mission popup"); } @@ -202,14 +202,14 @@ function mission_inquisition_necron_world(tomb_worlds) { var _pop_data = { system: _star.name, planet: planet, - estimate: eta, + estimate: _eta, mission: "inquisition_necron", options: _options, }; var text = $"The Inquisition is trusting you with a special mission. They have reason to suspect the Necron Tomb on planet {string(_star.name)} {scr_roman(planet)}"; - text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {string(eta)} months. Can your chapter handle this mission?"; + text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {string(_eta)} months. Can your chapter handle this mission?"; scr_popup("Inquisition Mission", text, "inquisition", _pop_data); } @@ -273,11 +273,11 @@ function mission_inquistion_hunt_inquisitor(star_id = noone) { var _name = global.name_generator.GenerateFromSet($"imperial_{string_gender()}"); var planet = irandom_range(1, _star.planets); - var eta = scr_mission_eta(_star.x, _star.y, 1); - eta = max(eta, 8); - var text = $"The Inquisition is trusting you with a special mission. A radical inquisitor named {_name} will be visiting the {_star.name} system in {eta} month's time. They are highly suspect of heresy, and as such, are to be put down. Can your chapter handle this mission?"; + var _eta = scr_mission_eta(_star.x, _star.y, 1); + _eta = max(_eta, 8); + var text = $"The Inquisition is trusting you with a special mission. A radical inquisitor named {_name} will be visiting the {_star.name} system in {_eta} month's time. They are highly suspect of heresy, and as such, are to be put down. Can your chapter handle this mission?"; if (obj_controller.demanding) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {_star.name}, expected within {eta} months. They are to be silenced and removed."; + text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {_star.name}, expected within {_eta} months. They are to be silenced and removed."; } var _options = [ { @@ -300,7 +300,7 @@ function mission_inquistion_hunt_inquisitor(star_id = noone) { var _pop_data = { system: _star.name, planet: planet, - estimate: eta, + estimate: _eta, mission: "inquisitor", options: _options, mission_data: _mission_data, @@ -375,7 +375,7 @@ function resolve_radical_inquisitor_mission(_mission_data) { continue; } - p_problem[_planet][i].delete = true; + p_problem[_planet][i].delete_mission = true; _mission_removed = true; break; } @@ -569,12 +569,12 @@ function mission_inquistion_spyrer() { } var _star = array_random_element(_valid_stars); var planet = scr_get_planet_with_type(_star, "Hive"); - var eta = scr_mission_eta(_star.x, _star.y, 1); - eta = min(max(eta, 6), 50); + var _eta = scr_mission_eta(_star.x, _star.y, 1); + _eta = min(max(_eta, 6), 50); var text = $"The Inquisition is trusting you with a special mission. An experienced Spyrer on hive world {string(_star.name)} {scr_roman(planet)}"; - text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {string(eta)} month's time panic is likely. Can your chapter handle this mission?"; - var mission_params = $"spyrer|{string(_star.name)}|{string(planet)}|{string(eta + 1)}|"; + text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {string(_eta)} month's time panic is likely. Can your chapter handle this mission?"; + var mission_params = $"spyrer|{string(_star.name)}|{string(planet)}|{string(_eta + 1)}|"; LOGGER.info($"Starting spyrer mission with params {mission_params}"); scr_popup("Inquisition Mission", text, "inquisition", mission_params); } @@ -632,28 +632,28 @@ function mission_inquistion_purge() { exit; } - var eta = infinity; + var _eta = infinity; with (obj_p_fleet) { if (capital_number + frigate_number == 0) { - eta = min(scr_mission_eta(_star.x, _star.y, 1), eta); // this is wrong + _eta = min(scr_mission_eta(_star.x, _star.y, 1), _eta); // this is wrong } } - eta = min(max(eta, 12), 100); + _eta = min(max(_eta, 12), 100); var text = "The Inquisition is trusting you with a special mission."; if (mission_flavour == 1) { - text += $" A number of high-ranking nobility on the planet {scr_roman(planet)} are being difficult and harboring heretical thoughts. They are to be selectively purged within {string(eta)} months. Can your chapter handle this mission?"; + text += $" A number of high-ranking nobility on the planet {scr_roman(planet)} are being difficult and harboring heretical thoughts. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; } else if (mission_flavour == 2) { - text += $" A powerful crimelord on the planet {scr_roman(planet)} is gaining an unacceptable amount of power and disrupting daily operations. They are to be selectively purged within {string(eta)} months. Can your chapter handle this mission?"; + text += $" A powerful crimelord on the planet {scr_roman(planet)} is gaining an unacceptable amount of power and disrupting daily operations. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; } else if (mission_flavour == 3) { - text += $" The mutants of hive world {scr_roman(planet)} are growing in numbers and ferocity, rising sporadically from the underhive. They are to be cleansed by promethium within {string(eta)} months. Can your chapter handle this mission?"; + text += $" The mutants of hive world {scr_roman(planet)} are growing in numbers and ferocity, rising sporadically from the underhive. They are to be cleansed by promethium within {string(_eta)} months. Can your chapter handle this mission?"; } if (mission_flavour != 3) { - scr_popup("Inquisition Mission", text, "inquisition", $"purge|{string(_star.name)}|{string(planet)}|{string(real(eta + 1))}|"); + scr_popup("Inquisition Mission", text, "inquisition", $"purge|{string(_star.name)}|{string(planet)}|{string(real(_eta + 1))}|"); } else { - scr_popup("Inquisition Mission", text, "inquisition", $"cleanse|{string(_star.name)}|{string(planet)}|{string(real(eta + 1))}|"); + scr_popup("Inquisition Mission", text, "inquisition", $"cleanse|{string(_star.name)}|{string(planet)}|{string(real(_eta + 1))}|"); } } @@ -681,20 +681,15 @@ function mission_investigate_planet() { LOGGER.error("RE: Investigate Planet, couldn't pick a planet"); exit; } - - var eta = infinity; + var _eta = -1; with (obj_p_fleet) { if (action != "") { continue; } - eta = min(eta, scr_mission_eta(_star.x, _star.y, 1)); + _eta = min(_eta, scr_mission_eta(_star.x, _star.y, 1)); } - eta = min(max(3, eta), 100); - - var text = $"The Inquisition wishes for you to investigate {string(_star.name)} {scr_roman(planet)}"; - text += $" Boots are expected to be planted on its surface over the course of your investigation."; - text += $" You have {string(eta)} months to complete this task."; - scr_popup("Inquisition Recon", text, "inquisition", $"recon|{string(_star.name)}|{string(planet)}|{string(eta)}|"); + _eta = min(max(3, _eta), 100); + _star.get_planet_data(planet).new_problem("inquisition_recon", _eta); } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index c7b6253f2c..c9eea4b4bd 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -31,7 +31,7 @@ global.planet_problem_keys = [ "train_forces", "spyrer", "inquisitor", - "recon", + "inquisition_recon", "cleanse", "purge", "tyranid_org", @@ -64,7 +64,7 @@ function mission_name_key(mission) { // Inquisition missions "spyrer": "Kill Spyrer for Inquisitor", "inquisitor": "Radical Inquisitor Arriving", - "recon": "Recon Mission for Inquisitor", + "inquisition_recon": "Recon Mission for Inquisitor", "cleanse": "Cleanse Planet for Inquisitor", "purge": "Purge Leadership for Inquisitor", "tyranid_org": "Capture Tyranid for Inquisitor", diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index a25ae273a2..554850e63d 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -731,7 +731,7 @@ function scr_random_event(execute_now) { if (planet > 0 && instance_exists(star)) { var _p_data = star.get_planet_data(planet); var _eta = scr_mission_eta(star.x, star.y, 1); - _p_data.new_problem("hunt_fallen"); + _p_data.new_problem("hunt_fallen",_eta); } _evented = true; } From 33fb6e616db1a4157e3bed8028516b29717d0c26 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 18:26:39 +0100 Subject: [PATCH 037/118] review points --- scripts/PlanetProblem/PlanetProblem.gml | 22 +++++++++---------- .../scr_inquisition_mission.gml | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index d6a9045dcc..49ebd1b1b0 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -55,12 +55,12 @@ static increment_mission_completion = function() { static popup_call = function(func){ var _func = function(){ - pop_data.mission[$ "func"](); + pop_data.mission[$ func](); } return _func; } -static inquisition_mission_options = fuction(mission_accept_function){ +static inquisition_mission_options = function(mission_accept_function){ var _options = [ { str1: "Accept", @@ -651,13 +651,13 @@ static inquisition_recon_init = function(){ var _pop_data = { mission: self, - options : inquisition_mission_options("") + options : inquisition_mission_options("inquisition_recon_accept") }; var text = $"The Inquisition wishes for you to investigate {p_data.name()}"; text += $" Boots are expected to be planted on its surface over the course of your investigation."; text += $" You have {string(eta)} months to complete this task."; - scr_popup("Inquisition Recon", text, "inquisition", $"recon|{string(_star.name)}|{string(planet)}|{string(eta)}|"); + scr_popup("Inquisition Recon", text, "inquisition", _pop_data); } static inquisition_recon_accept = function(){ @@ -1394,8 +1394,8 @@ static necron_tomb_mission_sequence = function() { } ] data.enemy = "wraith"; - case 2: break; + case 2: _battle_data.cols = [ { distance : 10, @@ -1414,8 +1414,8 @@ static necron_tomb_mission_sequence = function() { } ] data.enemy = "spyder" + break; case 3: - break; _battle_data.cols = [ { distance : 10, @@ -1551,7 +1551,7 @@ static advance_necron_tomb_mission = function() { return false; } -static inquisition_demon_world_init = fuction(){ +static inquisition_demon_world_init = function(){ var _text = $"The Inquisitor is trusting you with a special mission. The planet {p_data.name()} has been uncovered as a Demon World"; if (obj_controller.demanding) { _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {p_data.name()} must be cleansed within {timer} months."; @@ -1569,7 +1569,7 @@ static inquisition_demon_world_init = fuction(){ ); } -static inquisition_demon_world_accept = fuction(){ +static inquisition_demon_world_accept = function(){ scr_event_log("", $"Inquisition Mission Accepted: The demon world of {system.name} {scr_roman(planet)} will be purged by your hand.", system.name); new_star_event_marker("green"); with(obj_popup){ @@ -1577,7 +1577,7 @@ static inquisition_demon_world_accept = fuction(){ } } -static inquisition_tyranid_org_init = fuction(){ +static inquisition_tyranid_org_init = function(){ var _pop_data = { mission: self, options: inquisition_mission_options("inquisition_tyranid_org_accept"), @@ -1590,7 +1590,7 @@ static inquisition_tyranid_org_init = fuction(){ scr_popup("Inquisition Mission", _text, "inquisition",_pop_data); } -static inquisition_tyranid_org_accept = fuction(){ +static inquisition_tyranid_org_accept = function(){ obj_popup.image = "webber"; obj_popup.title = "New Equipment"; obj_popup.fancy_title = 0; @@ -1620,7 +1620,7 @@ static inquisition_tyranid_on_enemy_casulties = function(){ } } -static inquisition_tyranid_org_battle_final_message = fuction(){ +static inquisition_tyranid_org_battle_final_message = function(){ if (obj_ncombat.defeat || data.captured_gaunt == 0) { exit; } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index aa88beacb2..0d45b1a656 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -681,7 +681,7 @@ function mission_investigate_planet() { LOGGER.error("RE: Investigate Planet, couldn't pick a planet"); exit; } - var _eta = -1; + var _eta = infinity; with (obj_p_fleet) { if (action != "") { continue; From e435dfded750f87becb1a45611c8f888deb7bde6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sat, 26 Sep 2026 20:53:39 +0100 Subject: [PATCH 038/118] consistent naming of inquis missions and port purge mission --- objects/obj_drop_select/Create_0.gml | 2 +- objects/obj_ncombat/Alarm_1.gml | 2 +- objects/obj_popup/Step_0.gml | 12 +--- scripts/PlanetProblem/PlanetProblem.gml | 59 ++++++++++++++----- scripts/scr_cheatcode/scr_cheatcode.gml | 2 +- .../scr_inquisition_mission.gml | 21 +++---- .../scr_mission_functions.gml | 8 +-- .../scr_popup_functions.gml | 2 +- 8 files changed, 61 insertions(+), 47 deletions(-) diff --git a/objects/obj_drop_select/Create_0.gml b/objects/obj_drop_select/Create_0.gml index 0a294fe30d..a15940ec53 100644 --- a/objects/obj_drop_select/Create_0.gml +++ b/objects/obj_drop_select/Create_0.gml @@ -216,7 +216,7 @@ if (purge == 0) { spesh = true; } - if (_p_data.has_problem("tyranid_org")) { + if (_p_data.has_problem("iquisition_tyranid_org")) { tyranids = 2; attacking = 9; } diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index 561481d4bb..b540ece15d 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -95,7 +95,7 @@ if (battle_special == "") { } } } -if (battle_special == "spyrer") { +if (battle_special == "inquisition_spyrer") { p1 = "Your marines search through the alleyways and corridors likely to contain the Spyrer. It does not take long before the lunatic attacks, springing off from a wall to fall among your men. Your ranks are made up of "; } if (battle_special == "protect_raiders") { diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index cab5e4164d..f37ade69b7 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -241,7 +241,7 @@ try { text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to cleanse by fire the mutants in Hive {planet_numeral_name(planet, _mission_star)} within {estimate} months."; } } - if (mission == "spyrer") { + if (mission == "inquisition_spyrer") { scr_event_log("", $"Inquisition Mission Accepted: The Spyrer on {_mission_star.name} {scr_roman(planet)} must be killed within {estimate} months.", _mission_star.name); if (demand) { text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Spyrer on Hive {_mission_star.name} {scr_roman(onceh)} must be removed within {estimate} months."; @@ -259,9 +259,6 @@ try { title = "Inquisition Mission Demand"; text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture the Tau Ethereal somewhere within the {_mission_star.name} system."; } - if (has_problem_star("recon", _mission_star)) { - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for {global.chapter_name} to capture the Tau Ethereal somewhere within {_mission_star.name}.", _mission_star.name); - } } } } @@ -331,13 +328,6 @@ try { } if ((press == 1) && (option2 != "")) { - if (mission == "spyrer") { - obj_controller.disposition[4] -= 2; - } - if (title == "Inquisition Recon") { - obj_controller.disposition[4] -= 2; - } - if (title == "Mercy Plea") { // If have any marines within the fleet on the ships diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 49ebd1b1b0..2d4ff535eb 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -130,7 +130,7 @@ static basic_turn_end = function(){ break; } break; - case "spyrer": + case "inquisition_spyrer": _func = per_turn_check_spyrer; break; case "inquisition_necron": @@ -163,7 +163,7 @@ static basic_turn_end = function(){ case "inquisition_necron": _func = resolve_inquisitor_necron; break; - case "spyrer": + case "inquisition_spyrer": _func = resolve_spyrer; break; case "hunt_fallen": @@ -238,7 +238,7 @@ static after_battle_effects = function(){ instance_activate_object(obj_star); var _func = undefined; switch(p_id){ - case "spyrer": + case "inquisition_spyrer": _func = spyrer_battle_aftermath; break; case "protect_raiders": @@ -250,7 +250,7 @@ static after_battle_effects = function(){ case "inquisition_necron": _func = inquisition_necron_battle_aftermath; break; - case "tyranid_org": + case "iquisition_tyranid_org": _func = inquisition_tyranid_org_battle_aftermath } handle_triggered_mission_func(_func); @@ -314,7 +314,7 @@ static __init = function(){ case "inquisition_demon_world": inquisition_demon_world_init(); break; - case "tyranid_org": + case "iquisition_tyranid_org": inquisition_tyranid_org_init(); break; case "hive_fleet_to_cult": @@ -654,15 +654,16 @@ static inquisition_recon_init = function(){ options : inquisition_mission_options("inquisition_recon_accept") }; - var text = $"The Inquisition wishes for you to investigate {p_data.name()}"; - text += $" Boots are expected to be planted on its surface over the course of your investigation."; - text += $" You have {string(eta)} months to complete this task."; - scr_popup("Inquisition Recon", text, "inquisition", _pop_data); + var _text = $"The Inquisition wishes for you to investigate {p_data.name()}"; + _text += $" Boots are expected to be planted on its surface over the course of your investigation."; + _text += $" You have {string(eta)} months to complete this task."; + scr_popup("Inquisition Recon", _text, "inquisition", _pop_data); } static inquisition_recon_accept = function(){ mark("green"); - scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {p_data.name()} within {timer} months.", system.name); + scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {p_data.name()} within {timer} months.", system.name); + with(obj_popup){ popup_default_close(); } } static per_turn_inquisition_recon = function() { @@ -705,23 +706,25 @@ static resolve_inquisitor_necron = function() { } } +static inquisition_spyrer_init + static resolve_spyrer = function() { var _planet_name = p_data.name(); alter_disposition(eFACTION.INQUISITION, -3); var _alert_text = $"The Spyrer on {_planet_name} has been left unchecked. In the ensuing carnage some high-ranking officials have been killed, along with several Nobles. Panic is running amock in several parts of the hives and the Inquisition is less than pleased."; var _text = "Inquisition Mission Failed: The Spyrer on {_planet_name} was not removed."; - scr_popup("Inquisition Mission Failed", _alert_text, "spyrer", ""); + scr_popup("Inquisition Mission Failed", _alert_text, p_id, ""); scr_event_log("red", _text); } static per_turn_check_spyrer = function() { if (p_data.player_forces > 20) { var _tixt = $"The Spyrer on {p_data.name()} seems to have vanished, presumably gone into hiding."; - scr_popup("Spyrer Rampage", _tixt, "spyrer", ""); + scr_popup("Spyrer Rampage", _tixt, p_id, ""); } else if (p_data.player_forces <= 20) { new_end_turn_battle( 30, - "spyrer", + p_id, { threat : 1, fortified : false, @@ -752,7 +755,7 @@ static spyrer_battle_aftermath = function(){ var _tixt = $"The Spyrer on {p_data.name()} has been removed. The citizens and craftsman may sleep more soundly, the Inquisition likely pleased."; - scr_popup("Inquisition Mission Completed", _tixt, "spyrer", ""); + scr_popup("Inquisition Mission Completed", _tixt, p_id, ""); var _disp_gain = obj_controller.demanding ? choose(0, 0, 1) : 2; var _disp_gain_string = alter_disposition(eFACTION.INQUISITION, _disp_gain); @@ -1681,7 +1684,7 @@ static per_turn_hive_fleet_to_cult = function(){ if ((obj_controller.known[eFACTION.TYRANIDS] == 0) && (_has_head_lib == 0)) { for (var q = 0; q < array_length(obj_ini.TTRPG[0]); q++) { var _unit = fetch_unit([0, q]); - if (_unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + if (_unit.has_role(eROLE.CHAPTERMASTER)) { if (string_count("0", _unit.specials) > 0) { scr_popup("Shadow in the Warp", "You are distracted and bothered by a nagging sensation in the warp. It feels as though a shadow descends upon your sector.", "shadow", ""); scr_event_log("red", "You sense a disturbance in the warp. It feels something like a massive shadow."); @@ -1694,6 +1697,32 @@ static per_turn_hive_fleet_to_cult = function(){ obj_controller.known[eFACTION.TYRANIDS] = 1; } +static inquisition_purge_init = function(){ + var _text = "The Inquisition is trusting you with a special mission."; + if (data.mission_flavour == 1) { + _text += $" A number of high-ranking nobility on the planet {scr_roman(planet)} are being difficult and harboring heretical thoughts. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; + } else if (data.mission_flavour == 2) { + _text += $" A powerful crimelord on the planet {scr_roman(planet)} is gaining an unacceptable amount of power and disrupting daily operations. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; + } else if (data.mission_flavour == 3) { + _text += $" The mutants of hive world {scr_roman(planet)} are growing in numbers and ferocity, rising sporadically from the underhive. They are to be cleansed by promethium within {string(_eta)} months. Can your chapter handle this mission?"; + } + var _pop_data = { + mission: self, + options: inquisition_mission_options("inquisition_purge_accept"), + }; + scr_popup("Inquisition Mission", text, "inquisition", _pop_data); +} + +static inquisition_purge_accept = function(){ + var _text = "Inquisition Mission Accepted:" + if (data.purge_type == eDROP_TYPE.PURGEFIRE){ + _text += $" The mutants beneath {p_data.name()} must be cleansed by fire within {estimate} months."; + } else { + _text += $" The nobles of {p_data.name()} must be selectively purged within {estimate} months." + } + scr_event_log("", _text, system.name); +} + } diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index e93223be46..780956740b 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -159,7 +159,7 @@ function scr_cheatcode(argument0) { case "planet": scr_inquisition_mission(eEVENT.INQUISITION_PLANET); break; - case "spyrer": + case "inquisition_spyrer": scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.SPYRER); break; case "artifact": diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 0d45b1a656..cf7e5a0b2e 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -115,7 +115,7 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA var _eta = scr_mission_eta(_star.x, _star.y, 1); _eta = min(max(_eta, 6), 50); - _star.get_planet_data(planet).new_problem("tyranid_org", _eta); + _star.get_planet_data(planet).new_problem("iquisition_tyranid_org", _eta); break; case eINQUISITION_MISSION.ETHEREAL: mission_inquisition_ethereal(); @@ -638,23 +638,18 @@ function mission_inquistion_purge() { _eta = min(scr_mission_eta(_star.x, _star.y, 1), _eta); // this is wrong } } + _eta += 10; _eta = min(max(_eta, 12), 100); var text = "The Inquisition is trusting you with a special mission."; + var _purge_type = eDROP_TYPE.PURGEFIRE; + if (mission_flavour < 3){ + eDROP_TYPE.PURGESELECTIVE; + } - if (mission_flavour == 1) { - text += $" A number of high-ranking nobility on the planet {scr_roman(planet)} are being difficult and harboring heretical thoughts. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; - } else if (mission_flavour == 2) { - text += $" A powerful crimelord on the planet {scr_roman(planet)} is gaining an unacceptable amount of power and disrupting daily operations. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; - } else if (mission_flavour == 3) { - text += $" The mutants of hive world {scr_roman(planet)} are growing in numbers and ferocity, rising sporadically from the underhive. They are to be cleansed by promethium within {string(_eta)} months. Can your chapter handle this mission?"; - } + var _p_data = _star.get_planet_data(planet); + _p_data.new_problem("inquisition_purge", _eta, {mission_flavour, purge_type:_purge_type}); - if (mission_flavour != 3) { - scr_popup("Inquisition Mission", text, "inquisition", $"purge|{string(_star.name)}|{string(planet)}|{string(real(_eta + 1))}|"); - } else { - scr_popup("Inquisition Mission", text, "inquisition", $"cleanse|{string(_star.name)}|{string(planet)}|{string(real(_eta + 1))}|"); - } } function mission_investigate_planet() { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index c9eea4b4bd..228fd9602f 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -29,12 +29,12 @@ global.planet_problem_keys = [ "join_parade", "recover_artifacts", "train_forces", - "spyrer", + "inquisition_spyrer", "inquisitor", "inquisition_recon", "cleanse", "purge", - "tyranid_org", + "iquisition_tyranid_org", "artifact_loan", "inquisition_necron", "ethereal", @@ -62,12 +62,12 @@ function mission_name_key(mission) { "recover_artifacts": "Recover Artifacts", "train_forces": "Train Planet Forces", // Inquisition missions - "spyrer": "Kill Spyrer for Inquisitor", + "inquisition_spyrer": "Kill Spyrer for Inquisitor", "inquisitor": "Radical Inquisitor Arriving", "inquisition_recon": "Recon Mission for Inquisitor", "cleanse": "Cleanse Planet for Inquisitor", "purge": "Purge Leadership for Inquisitor", - "tyranid_org": "Capture Tyranid for Inquisitor", + "iquisition_tyranid_org": "Capture Tyranid for Inquisitor", // "bomb" : "Bombard World for Inquisitor", "artifact_loan": "Safeguard Artifact for the Inquisition", "inquisition_necron": "Bomb Necron Tomb for Inquisitor", diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index b0e896894e..2b77cc023a 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -495,7 +495,7 @@ function default_popup_image_index() { _img = 21; } else if (image == "webber") { _img = 22; - } else if (image == "spyrer") { + } else if (image == "inquisition_spyrer") { _img = 23; } else if (image == "fortress") { _img = 24; From 229f646cf244213e507e3399dc0711bc8794a602 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 10:52:53 +0100 Subject: [PATCH 039/118] misc --- objects/obj_popup/Step_0.gml | 12 ------------ scripts/PlanetProblem/PlanetProblem.gml | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index f37ade69b7..7d701548ee 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -229,18 +229,6 @@ try { if (demand) { title = "Inquisition Mission Demand"; } - - if (mission == "purge") { - scr_event_log("", $"Inquisition Mission Accepted: The nobles of {_mission_star.name} {scr_roman(planet)} must be selectively purged within {estimate} months.", _mission_star.name); - if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to selectively purge the Nobles on {_mission_star.name} {scr_roman(onceh)} within {estimate} months."; - } - } else if (mission == "cleanse") { - scr_event_log("", $"Inquisition Mission Accepted: The mutants beneath {planet_numeral_name(planet, _mission_star)} must be cleansed by fire within {estimate} months.", _mission_star.name); - if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to cleanse by fire the mutants in Hive {planet_numeral_name(planet, _mission_star)} within {estimate} months."; - } - } if (mission == "inquisition_spyrer") { scr_event_log("", $"Inquisition Mission Accepted: The Spyrer on {_mission_star.name} {scr_roman(planet)} must be killed within {estimate} months.", _mission_star.name); if (demand) { diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 2d4ff535eb..d21b23bf50 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1566,7 +1566,7 @@ static inquisition_demon_world_init = function(){ }; scr_popup( "Inquisition Mission Demon World", - text, + _text, "inquisition", _pop_data ); From 0cd31bb30da16dfb18c767373361e6b8dc94a6b5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 11:26:44 +0100 Subject: [PATCH 040/118] structured names for missions to reduce bloat --- objects/obj_ncombat/Alarm_1.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 305 ++++++------------ scripts/scr_cheatcode/scr_cheatcode.gml | 2 +- .../scr_inquisition_mission.gml | 11 +- .../scr_mission_functions.gml | 4 +- 5 files changed, 111 insertions(+), 213 deletions(-) diff --git a/objects/obj_ncombat/Alarm_1.gml b/objects/obj_ncombat/Alarm_1.gml index b540ece15d..35b4d6cb51 100644 --- a/objects/obj_ncombat/Alarm_1.gml +++ b/objects/obj_ncombat/Alarm_1.gml @@ -127,7 +127,7 @@ if (battle_special == "hunt_fallen") { p1 += " Your ranks are made up of "; } -if ("inquisition_necron" == battle_special) { +if ("inquisition_tomb" == battle_special) { var wh = choose(1, 2); if (wh == 1) { p1 = "Cave dirt crunches beneath the soles of your marines as they continue their descent. There is little warning before "; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index d21b23bf50..5678026b31 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -41,7 +41,7 @@ static description = function(){ return mission_name_key(p_id); } -static increment_mission_completion = function() { +static __increment_mission_completion = function() { if (!struct_exists(data, "completion")) { data.completion = 0; } @@ -53,14 +53,14 @@ static increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } -static popup_call = function(func){ +static __popup_call = function(func){ var _func = function(){ pop_data.mission[$ func](); } return _func; } -static inquisition_mission_options = function(mission_accept_function){ +static __inquisition_mission_options = function(mission_accept_function){ var _options = [ { str1: "Accept", @@ -83,7 +83,7 @@ static inquisition_mission_options = function(mission_accept_function){ } -static handle_triggered_mission_func = function(func){ +static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ refresh_p_data(); try { @@ -105,99 +105,37 @@ static handle_triggered_mission_func = function(func){ } } } + +static __find_func = function(trigger_string){ + var _func_string = "__" + p_id + "_trigger_string"; + if (stage_id != ""){ + _func_string += "_?" + stage_id; + } + if (struct_exists(self,_func_string)){ + return self[$ _func_string] + } + return undefined; +} static basic_turn_end = function(){ refresh_p_data(); if (p_data.system.storm <= 0){ timer--; } if ((timer > -1) && per_turn_checks) { - var _func = undefined; - switch(p_id){ - case "mech_raider": - _func = per_turn_check_raider_failed; - break; - case "mech_bionics": - _func = per_turn_check_mech_bionics; - break; - case "mech_tomb": - switch(stage_id){ - case "exploring": - _func = per_turn_check_mech_tomb2; - break; - case "awaiting_player": - default: - _func = per_turn_check_mech_tomb1; - break; - } - break; - case "inquisition_spyrer": - _func = per_turn_check_spyrer; - break; - case "inquisition_necron": - _func =per_turn_check_inqisition_tomb; - break; - case "hive_fleet_to_cult": - _func = per_turn_hive_fleet_to_cult; - break; - case "inquisition_recon": - _func = per_turn_inquisition_recon; - break; - } - handle_triggered_mission_func(_func) + var _func = __find_func("per_turn"); + __handle_triggered_mission_func(_func) } if ((timer == 0) && zero_timer_checks && !delete_mission) { - var _func = undefined; - switch(p_id){ - case "hunt_beast": - _func = resolve_hunt_beast; - break; - case "train_forces": - _func = complete_train_forces_mission; - break; - case "succession": - _func = resolve_succession; - break; - case "inquisition_recon": - _func = resolve_inquisition_recon; - break; - case "inquisition_necron": - _func = resolve_inquisitor_necron; - break; - case "inquisition_spyrer": - _func = resolve_spyrer; - break; - case "hunt_fallen": - _func = resolve_fallen; - break; - case "mech_raider": - _func = resolve_mech_raider_failed; - break; - case "mech_bionics": - _func = resolve_mech_bionics; - break; - case "mech_tomb": - _func = resolve_mech_tomb1_failed; - break; - case "mech_mars": - _func = resolve_mech_mars; - break; - case "provide_garrison": - _func = complete_garrison_mission; - } - handle_triggered_mission_func(_func) + var _func = __find_func("resolve"); + __handle_triggered_mission_func(_func) } } //triggered within drop select static before_battle_effects = function(){ instance_activate_object(obj_star); - var _func = undefined; - switch(p_id){ - case "iquisition_tyranid_org": - _func = inquisition_tyranid_org_setup_battle; - break; - } - handle_triggered_mission_func(_func); + var _func = __find_func("setup_battle"); + __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } @@ -208,13 +146,8 @@ static battle_on_enemy_casulties = function(){ exit; } instance_activate_object(obj_star); - var _func = undefined; - switch(p_id){ - case "iquisition_tyranid_org": - _func = inquisition_tyranid_on_enemy_casulties; - break; - } - handle_triggered_mission_func(_func); + var _func = __find_func("on_enemy_casulties"); + __handle_triggered_mission_func(_func); struct_remove(self, "casualty_packet"); @@ -223,75 +156,45 @@ static battle_on_enemy_casulties = function(){ //triggers in obj_ncombat alarm 5 static battle_final_message = function(){ - instance_activate_object(obj_star); - var _func = undefined; - switch(p_id){ - case "iquisition_tyranid_org": - _func = inquisition_tyranid_org_battle_final_message; - break; - } - handle_triggered_mission_func(_func); + instance_activate_object(obj_star); + var _func = __find_func("battle_final_message"); + __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } static after_battle_effects = function(){ instance_activate_object(obj_star); - var _func = undefined; - switch(p_id){ - case "inquisition_spyrer": - _func = spyrer_battle_aftermath; - break; - case "protect_raiders": - _func = protect_raiders_battle_aftermath; - break; - case "hunt_fallen": - _func = hunt_fallen_battle_aftermath; - break; - case "inquisition_necron": - _func = inquisition_necron_battle_aftermath; - break; - case "iquisition_tyranid_org": - _func = inquisition_tyranid_org_battle_aftermath - } - handle_triggered_mission_func(_func); + var _func = __find_func("battle_aftermath"); + __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } static on_squad_selection = function(){ - var _func = undefined; - switch(p_id){ - case "protect_raiders": - _func = protect_raider_squad_selected; - break; - } - handle_triggered_mission_func(_func); + var _func = __find_func("squad_selected"); + __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } static on_unit_selection = function(){ - var _func = undefined; - switch(p_id){ - case "hunt_beast": - _func = init_beast_hunt_mission; - break; - case "train_forces": - _func = init_train_forces_mission; - } + var _func = __find_func("unit_select"); if (!is_undefined(_func)){ if (struct_exists(obj_controller.selection_data, "selections")){ members = obj_controller.selection_data.selections; } - handle_triggered_mission_func(_func); + __handle_triggered_mission_func(_func); } instance_deactivate_object(obj_star); } static __init = function(){ - switch(p_id){ - case "inquisition_necron": - mark("green"); - break; + var _func = __find_func("unit_select"); + if (!is_undefined(_func)){ + _func(); + } else { + mark("green"); + } + /*switch(p_id){ case "meeting": var rando = choose(1, 2); if (rando == 1) { @@ -303,30 +206,16 @@ static __init = function(){ scr_event_log("", $"Chaos Lord {obj_controller.faction_leader[eFACTION.CHAOS]} agrees to meet with you on {p_data.name()} to discuss an alliance."); mark("purple"); break; - case "hunt_fallen": - hunt_fallen_init(); - break; case "harlequins": var _text = $"Eldar Harlequins have been seen on planet {p_data.name()}. Their purposes are unknown."; scr_popup("Harlequin Troupe", _text, "harlequin", ""); mark("green"); break; - case "inquisition_demon_world": - inquisition_demon_world_init(); - break; - case "iquisition_tyranid_org": - inquisition_tyranid_org_init(); - break; - case "hive_fleet_to_cult": - hive_fleet_to_cult_init(); - break; - case "inquisition_recon": - inquisition_recon_init(); default: mark("green"); break; - } + }*/ } __init(); @@ -366,7 +255,7 @@ static new_battle = function(battle_opponent_id,special_id = p_id){ return _battle; } -static set_members_job_to_mission = function(){ +static __set_members_job_to_mission = function(){ for (var i = 0; i < array_length(members); i++){ var _unit = members[i]; _unit.job = { @@ -380,9 +269,9 @@ static set_members_job_to_mission = function(){ -static init_beast_hunt_mission = function() { +static __beast_hunt_unit_select = function() { if (stage_id == "preliminary") { - set_members_job_to_mission(); + __set_members_job_to_mission(); var _numeral_name = p_data.name() stage_id = "active"; var _mission_length = irandom_range(2, 5); @@ -400,7 +289,7 @@ static init_beast_hunt_mission = function() { } } -static complete_beast_hunt_mission = function() { +static __beast_hunt_resolve = function() { var _man_conditions = { "job": "hunt_beast", "max": 3, @@ -469,7 +358,7 @@ static complete_beast_hunt_mission = function() { } -static init_train_forces_mission = function() { +static __train_forces_unit_select = function() { if (stage_id != "preliminary" || array_length(members) == 0) { exit; } @@ -501,7 +390,7 @@ static init_train_forces_mission = function() { obj_controller.close_popups = false; } -static complete_train_forces_mission = function() { +static __train_forces_resolve = function() { if (stage_id != "active") { exit; } @@ -601,7 +490,7 @@ static complete_train_forces_mission = function() { _trainer.job = "none"; } -static resolve_succession = function() { +static __succession_resolve = function() { var _result, _alert_text; var _dice1 = roll_dice(1, 100); var _dice2 = roll_dice(1, 100); @@ -647,11 +536,11 @@ static resolve_succession = function() { p_data.delete_feature(eP_FEATURES.SUCCESSION_WAR); } -static inquisition_recon_init = function(){ +static __inquisition_recon_init = function(){ var _pop_data = { mission: self, - options : inquisition_mission_options("inquisition_recon_accept") + options : __inquisition_mission_options(__find_func("accept")) }; var _text = $"The Inquisition wishes for you to investigate {p_data.name()}"; @@ -660,13 +549,13 @@ static inquisition_recon_init = function(){ scr_popup("Inquisition Recon", _text, "inquisition", _pop_data); } -static inquisition_recon_accept = function(){ +static __inquisition_recon_accept = function(){ mark("green"); scr_event_log("", $"Inquisition Mission Accepted: The Inquisition wish for Astartes to land on and investigate {p_data.name()} within {timer} months.", system.name); with(obj_popup){ popup_default_close(); } } -static per_turn_inquisition_recon = function() { +static __inquisition_recon_per_turn = function() { if (p_data.player_forces <= 0){ exit; } @@ -685,7 +574,7 @@ static per_turn_inquisition_recon = function() { delete_mission = true; } -static resolve_inquisition_recon = function() { +static __inquisition_recon_resolve = function() { refresh_p_data(); var _alert_text = "Inquisition Mission Failed: Investigate "; alter_disposition(eFACTION.INQUISITION, -5); @@ -694,7 +583,7 @@ static resolve_inquisition_recon = function() { scr_event_log("red", _alert_text); } -static resolve_inquisitor_necron = function() { +static __inquisitor_necron_resolve = function() { alter_disposition(eFACTION.INQUISITION, -8); var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); @@ -706,9 +595,21 @@ static resolve_inquisitor_necron = function() { } } -static inquisition_spyrer_init +static __inquisition_spyrer_init = function(){ + var _text = $"The Inquisition is trusting you with a special mission. An experienced Spyrer on hive world {p_data.name()}"; + _text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {string(estimate)} month's time panic is likely. Can your chapter handle this mission?"; + var _pop_data = { + mission: self, + options: __inquisition_mission_options(__find_func("accept")), + }; + scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); +} -static resolve_spyrer = function() { +static __inquisition_spyrer_accept = function(){ + var _text = $"Inquisition Mission Accepted: An experienced Spyrer on {p_data.name()} must be put down within {string(estimate)} months."; + scr_event_log("", _text, system.name); +} +static __spyrer_resolve = function() { var _planet_name = p_data.name(); alter_disposition(eFACTION.INQUISITION, -3); var _alert_text = $"The Spyrer on {_planet_name} has been left unchecked. In the ensuing carnage some high-ranking officials have been killed, along with several Nobles. Panic is running amock in several parts of the hives and the Inquisition is less than pleased."; @@ -717,7 +618,7 @@ static resolve_spyrer = function() { scr_event_log("red", _text); } -static per_turn_check_spyrer = function() { +static __inquisition_spyrer_per_turn = function() { if (p_data.player_forces > 20) { var _tixt = $"The Spyrer on {p_data.name()} seems to have vanished, presumably gone into hiding."; scr_popup("Spyrer Rampage", _tixt, p_id, ""); @@ -745,7 +646,7 @@ static per_turn_check_spyrer = function() { } } -static spyrer_battle_aftermath = function(){ +static __inquisition_spyrer_battle_aftermath = function(){ // title / text / image / speshul if (!obj_ncombat.defeat){ exit; @@ -764,14 +665,14 @@ static spyrer_battle_aftermath = function(){ scr_gov_disp(system.name, planet, choose(1, 2, 3, 4)); } -static hunt_fallen_init = function(){ +static __hunt_fallen_init = function(){ var _text = localize("Sources indicate one of the Fallen may be upon {0}. We have {1} months to send out a strike team and scour the planet. Any longer and any Fallen that might be there will have escaped.", [p_data.name(), timer]); scr_popup(localize("Hunt the Fallen"), _text, "fallen", ""); scr_event_log("", localize("Sources indicate one of the Fallen may be upon {0}. We have {1} months to investigate.", [p_data.name(), timer])); mark("purple"); } -static per_turn_check_fallen = function() { +static __hunt_fallen_per_turn = function() { if (p_data.player_forces > 0){ if (choose(true, false)) { var _group_big = choose(true, false); @@ -824,7 +725,7 @@ static per_turn_check_fallen = function() { } } -static resolve_fallen = function() { +static __hunt_fallen_resolve = function() { //TODO marker point for cohesion mechanics var _alert_text = ""; if (irandom(100) > 33) { @@ -848,7 +749,7 @@ static resolve_fallen = function() { scr_event_log("red", $"Mission Failed: Any Fallen within the {system.name} system have been given time to escape."); } -function hunt_fallen_battle_aftermath() { +function __hunt_fallen_battle_aftermath() { if (obj_ncombat.defeat) { exit; } @@ -865,11 +766,11 @@ function hunt_fallen_battle_aftermath() { scr_popup("Hunt the Fallen Completed", _tixt, "fallen", ""); } -static per_turn_check_mech_raider = function() { +static __mech_raider_per_turn = function() { var _techs = collect_role_group(SPECIALISTS_TECHS, [system.name, planet, -1]); var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); if ((array_length(_techs) >= 6) && (_lr_count >= 1)) { - var _percent_complete = increment_mission_completion(); + var _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { delete_mission = true; @@ -881,7 +782,7 @@ static per_turn_check_mech_raider = function() { } } -static resolve_mech_raider_failed = function() { +static __mech_raider_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: Land Raider testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); @@ -889,11 +790,11 @@ static resolve_mech_raider_failed = function() { delete_mission = true; } -static per_turn_check_mech_bionics = function() { +static __mech_bionics_per_turn = function() { var _units = p_data.collect_planet_group(); var _bionics = _units.tally_attr("bionics"); if (_bionics >= 10) { - var _percent_complete = increment_mission_completion(); + var _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { delete_mission = true; @@ -905,7 +806,7 @@ static per_turn_check_mech_bionics = function() { } } -static resolve_mech_bionics_failed = function() { +static __mech_bionics_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: bionics testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); @@ -913,7 +814,7 @@ static resolve_mech_bionics_failed = function() { delete_mission = true; } -static per_turn_check_mech_tomb2 = function() { +static __mech_tomb_per_turn_?exploring = function() { data.turns++; var _battli = 0; var _roll1 = roll_dice_chapter(1, 100 + data.turns, "low"); @@ -1131,7 +1032,7 @@ static complete_garrison_mission = function() { scr_popup($"Agreed Garrison of {name()} complete", _mission_string, "", ""); } -static protect_raiders_battle_aftermath = function() { +static __protect_raiders_battle_aftermath = function() { // show_message(obj_turn_end.current_battle); // show_message(obj_turn_end.battle_world[obj_turn_end.current_battle]); // title / text / image / speshul @@ -1151,7 +1052,7 @@ static protect_raiders_battle_aftermath = function() { } } -static protect_raider_squad_selected = function() { +static __protect_raider_squad_selected = function() { data.squad = data.squads[0]; var _squad = data.squad; var _squad_units = _squad.members; @@ -1258,7 +1159,7 @@ static protect_raider_squad_selected = function() { } } -static per_turn_check_inqisition_tomb = function() { +static __inqisition_tomb_per_turn = function() { if (p_player[run] <= 0){ exit; } @@ -1282,7 +1183,7 @@ static per_turn_check_inqisition_tomb = function() { options: [ { str1: "Begin the Mission", - choice_func: popup_call("necron_tomb_mission_start"), + choice_func: __popup_call("necron_tomb_mission_start"), }, { str1: "Not Yet", @@ -1293,10 +1194,10 @@ static per_turn_check_inqisition_tomb = function() { scr_popup("Necron Tomb Excursion", _tixt, $"necron_cave", _pop_data); } -static necron_tomb_mission_start = function() { +static inquisition_tomb_mission_start = function() { obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; obj_popup.replace_options([ - {str1: "Continue", choice_func: popup_call("necron_tomb_mission_sequence")}, + {str1: "Continue", choice_func: __popup_call("necron_tomb_mission_sequence")}, {str1: "Return to the surface", choice_func: popup_default_close} ]); obj_popup.image = "necron_tunnels_1"; @@ -1306,7 +1207,7 @@ static necron_tomb_mission_start = function() { /// @self Asset.GMObject.obj_popup /// @desc Advances the Necron Tomb mission or starts a combat encounter. /// @returns {Undefined} -static necron_tomb_mission_sequence = function() { +static inquisition_tomb_mission_sequence = function() { var _battle; var player_forces = system.player_forces; var _penalty = 0; @@ -1468,7 +1369,7 @@ static necron_tomb_mission_sequence = function() { exit; } -static inquisition_necron_battle_aftermath = function(){ +static __inquisition_tomb_battle_aftermath = function(){ if (!data.tomb_awakens) { if (defeat == 1) { obj_controller.combat = 0; @@ -1554,7 +1455,7 @@ static advance_necron_tomb_mission = function() { return false; } -static inquisition_demon_world_init = function(){ +static __inquisition_demon_world_init = function(){ var _text = $"The Inquisitor is trusting you with a special mission. The planet {p_data.name()} has been uncovered as a Demon World"; if (obj_controller.demanding) { _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Demon World {p_data.name()} must be cleansed within {timer} months."; @@ -1562,7 +1463,7 @@ static inquisition_demon_world_init = function(){ _text += $"The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; var _pop_data = { mission: self, - options: inquisition_mission_options("inquisition_demon_world_accept"), + options: __inquisition_mission_options(__find_func("accept")), }; scr_popup( "Inquisition Mission Demon World", @@ -1572,7 +1473,7 @@ static inquisition_demon_world_init = function(){ ); } -static inquisition_demon_world_accept = function(){ +static __inquisition_demon_world_accept = function(){ scr_event_log("", $"Inquisition Mission Accepted: The demon world of {system.name} {scr_roman(planet)} will be purged by your hand.", system.name); new_star_event_marker("green"); with(obj_popup){ @@ -1580,10 +1481,10 @@ static inquisition_demon_world_accept = function(){ } } -static inquisition_tyranid_org_init = function(){ +static __inquisition_tyranid_org_init = function(){ var _pop_data = { mission: self, - options: inquisition_mission_options("inquisition_tyranid_org_accept"), + options: __inquisition_mission_options(__find_func("accept")), }; var _text = $"An Inquisitor is trusting you with a special mission. The planet {p_data.name()}"; _text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; @@ -1593,7 +1494,7 @@ static inquisition_tyranid_org_init = function(){ scr_popup("Inquisition Mission", _text, "inquisition",_pop_data); } -static inquisition_tyranid_org_accept = function(){ +static __inquisition_tyranid_org_accept = function(){ obj_popup.image = "webber"; obj_popup.title = "New Equipment"; obj_popup.fancy_title = 0; @@ -1607,7 +1508,7 @@ static inquisition_tyranid_org_accept = function(){ data.captured_gaunt = 0; } -static inquisition_tyranid_org_setup_battle = function(){ +static __inquisition_tyranid_org_setup_battle = function(){ if ((obj_ncombat.enemy != eFACTION.TYRANIDS) || (obj_ncombat.battle_object.space_hulk)) { exit; } @@ -1616,14 +1517,14 @@ static inquisition_tyranid_org_setup_battle = function(){ obj_ncombat.reduce_power = false; } -static inquisition_tyranid_on_enemy_casulties = function(){ +static __inquisition_tyranid_on_enemy_casulties = function(){ var _c_data = casualty_packet; if (array_contains(["Termagaunt", "Hormagaunt"], _c_data.weapon) && (_c_data.casulties > 0)) { data.captured_gaunt += casulties; } } -static inquisition_tyranid_org_battle_final_message = function(){ +static __inquisition_tyranid_org_battle_final_message = function(){ if (obj_ncombat.defeat || data.captured_gaunt == 0) { exit; } @@ -1633,7 +1534,7 @@ static inquisition_tyranid_org_battle_final_message = function(){ } -static inquisition_tyranid_org_battle_aftermath = function(){ +static __inquisition_tyranid_org_battle_aftermath = function(){ if (obj_ncombat.defeat|| data.captured_gaunt == 0){ exit; } @@ -1648,7 +1549,7 @@ static inquisition_tyranid_org_battle_aftermath = function(){ } } -static hive_fleet_to_cult_init = function(){ +static __hive_fleet_to_cult_init = function(){ var xx = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; var yy = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; var fleet = create_enemy_fleet(xx, yy, eFACTION.TYRANIDS); @@ -1669,7 +1570,7 @@ static hive_fleet_to_cult_init = function(){ fleet.action = "move"; } -static per_turn_hive_fleet_to_cult = function(){ +static __hive_fleet_to_cult_per_turn = function(){ if (timer != 3 || scr_has_disadv("Psyker Intolerant")){ exit; } @@ -1697,7 +1598,7 @@ static per_turn_hive_fleet_to_cult = function(){ obj_controller.known[eFACTION.TYRANIDS] = 1; } -static inquisition_purge_init = function(){ +static __inquisition_purge_init = function(){ var _text = "The Inquisition is trusting you with a special mission."; if (data.mission_flavour == 1) { _text += $" A number of high-ranking nobility on the planet {scr_roman(planet)} are being difficult and harboring heretical thoughts. They are to be selectively purged within {string(_eta)} months. Can your chapter handle this mission?"; @@ -1708,12 +1609,12 @@ static inquisition_purge_init = function(){ } var _pop_data = { mission: self, - options: inquisition_mission_options("inquisition_purge_accept"), + options: __inquisition_mission_options(__find_func("accept")), }; scr_popup("Inquisition Mission", text, "inquisition", _pop_data); } -static inquisition_purge_accept = function(){ +static __inquisition_purge_accept = function(){ var _text = "Inquisition Mission Accepted:" if (data.purge_type == eDROP_TYPE.PURGEFIRE){ _text += $" The mutants beneath {p_data.name()} must be cleansed by fire within {estimate} months."; diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 780956740b..73981e988a 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -500,7 +500,7 @@ function draw_planet_debug_problems() { case "inquisitor": mission_inquistion_hunt_inquisitor(target.id); break; - case "inquisition_necron": + case "inquisition_tomb": mission_inquisition_necron_world(target.id); break; case "mech_raider": diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index cf7e5a0b2e..560d505ece 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -203,7 +203,7 @@ function mission_inquisition_necron_world(tomb_worlds) { system: _star.name, planet: planet, estimate: _eta, - mission: "inquisition_necron", + mission: "inquisition_tomb", options: _options, }; @@ -239,7 +239,7 @@ function init_mission_inquisition_necron_world() { if (demand) { demand = 0; } - _p_data.new_problem("inquisition_necron", estimate, {}); + _p_data.new_problem("inquisition_tomb", estimate, {}); exit; } @@ -572,11 +572,8 @@ function mission_inquistion_spyrer() { var _eta = scr_mission_eta(_star.x, _star.y, 1); _eta = min(max(_eta, 6), 50); - var text = $"The Inquisition is trusting you with a special mission. An experienced Spyrer on hive world {string(_star.name)} {scr_roman(planet)}"; - text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {string(_eta)} month's time panic is likely. Can your chapter handle this mission?"; - var mission_params = $"spyrer|{string(_star.name)}|{string(planet)}|{string(_eta + 1)}|"; - LOGGER.info($"Starting spyrer mission with params {mission_params}"); - scr_popup("Inquisition Mission", text, "inquisition", mission_params); + var _p_data = _star.get_planet_data(planet); + _p_data.new_problem("inquisition_spyrer", _eta, {}); } function mission_inquistion_purge() { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 228fd9602f..6cf677b0ea 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -36,7 +36,7 @@ global.planet_problem_keys = [ "purge", "iquisition_tyranid_org", "artifact_loan", - "inquisition_necron", + "inquisition_tomb", "ethereal", "demon_world", ]; @@ -70,7 +70,7 @@ function mission_name_key(mission) { "iquisition_tyranid_org": "Capture Tyranid for Inquisitor", // "bomb" : "Bombard World for Inquisitor", "artifact_loan": "Safeguard Artifact for the Inquisition", - "inquisition_necron": "Bomb Necron Tomb for Inquisitor", + "inquisition_tomb": "Bomb Necron Tomb for Inquisitor", "ethereal": "Capture Ethereal for Inquisitor", "demon_world": "Clear Demon World for Inquisitor", }; From abef2a4d527ac66baa6cb283e18c4cb9152e525d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 11:43:09 +0100 Subject: [PATCH 041/118] add documentation in the top of PlanetProblem script --- scripts/PlanetProblem/PlanetProblem.gml | 27 ++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 5678026b31..cbdde9e12c 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1,3 +1,28 @@ +//All missions that run on a planet now need their own PlanetProblem instance +//missions for the most part can only run from predefined points in the code +// to run from each of these points easch mission must have a registered function these functions are then called implicitly +/* the current entry points for the code are + "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn + "resolve" - runs when the mission timer hits 0 often contains the failiure conditions for the mission + - both of the above runn via basic_turn_end -> PlanetData.problem_count_down -> scr_enemy_ai_d + + "setup_battle" - runs when the player intiates a battle via drop select window on a planet with a problem on + "on_enemy_casulties" - runs during combat after player iflicts casualties to log data or inject mission specific combat logs + "battle_final_message" - runs during combat to tally data and display a final log to the combat log + "battle_aftermath" - runs post combat during obj_ncombat alarm_7 + "squad_selected" - runs after selecting a squad inn the squad select window (scr_manage_task_selector) + "unit_select" - runs after selecting units in the unit selection screen (scr_manage_task_selector) + "init" - runs imediatly after problem is created often used to poopulate initial popupop ir stack popup for turn end + +- other than these entry points and any other later defined poisitions mission specific code should not run outsiide of the PlanetProblem container + +- to set an entry point up simply register the function as a static e.g + if i create static __inquisition_are_dicks_per_turn once a "inquisition_are_dicks" problem is registered on a planet via + PlanetData.new_problem("inquisition_are_dicks",200) the per turn check will run no other code is required +other info + - set a mission for deletion by settinng delete_mission = true; this will delete the mission after the current function + has finished executing and +*/ /// @param {sring} name /// @param {Real} timer /// @param {struct} data @@ -188,7 +213,7 @@ static on_unit_selection = function(){ } static __init = function(){ - var _func = __find_func("unit_select"); + var _func = __find_func("init"); if (!is_undefined(_func)){ _func(); } else { From a1edff618f206728be4eeced5b878c99a1ec9e8f Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 11:47:22 +0100 Subject: [PATCH 042/118] better docs --- scripts/PlanetProblem/PlanetProblem.gml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index cbdde9e12c..484af27435 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1,6 +1,7 @@ //All missions that run on a planet now need their own PlanetProblem instance //missions for the most part can only run from predefined points in the code // to run from each of these points easch mission must have a registered function these functions are then called implicitly +//each function follows the format `___` /* the current entry points for the code are "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn "resolve" - runs when the mission timer hits 0 often contains the failiure conditions for the mission @@ -20,7 +21,7 @@ if i create static __inquisition_are_dicks_per_turn once a "inquisition_are_dicks" problem is registered on a planet via PlanetData.new_problem("inquisition_are_dicks",200) the per turn check will run no other code is required other info - - set a mission for deletion by settinng delete_mission = true; this will delete the mission after the current function + - set a mission for deletion by setting delete_mission = true; this will delete the mission after the current function has finished executing and */ /// @param {sring} name From d2031f9123d7712e20b4d6f947d45c91948a298e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 12:20:34 +0100 Subject: [PATCH 043/118] review points amd update systemProblem call points --- objects/obj_ncombat/Alarm_0.gml | 1 + objects/obj_ncombat/Create_0.gml | 15 ++++ scripts/PlanetProblem/PlanetProblem.gml | 79 +++++++++++-------- scripts/SystemProblem/SystemProblem.gml | 62 +++++++++------ .../scr_chaos_alliance_test.gml | 2 +- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 +- .../scr_inquisition_mission.gml | 2 +- scripts/scr_shoot/scr_shoot.gml | 19 ++--- 8 files changed, 105 insertions(+), 77 deletions(-) diff --git a/objects/obj_ncombat/Alarm_0.gml b/objects/obj_ncombat/Alarm_0.gml index 9368794581..5bf96711c6 100644 --- a/objects/obj_ncombat/Alarm_0.gml +++ b/objects/obj_ncombat/Alarm_0.gml @@ -147,6 +147,7 @@ try { } else { u = instance_create(_col.distance, 240, obj_enunit); } + u.flank = struct_exists(_col, "flank") && _col.flank; u.add_enemies(_col.enemies); } _enemies_assigned = true; diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index de659a327b..21db5c1bb1 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -272,3 +272,18 @@ betchers = obj_ini.betchers; // slight melee penalty catalepsean = obj_ini.catalepsean; // minor global attack decrease occulobe = obj_ini.occulobe; // penalty if morning and susceptible to flash grenades mucranoid = obj_ini.mucranoid; // chance to short-circuit + + +register_kills_to_missions(casulties){ + if (obj_ncombat.battle_special != ""){ + if (is_struct(obj_ncombat.special_feature) && is_instanceof(obj_ncombat.special_feature, PlanetProblem)){ + var _feat = obj_ncombat.special_feature; + _feat.casualty_packet = casulties; + _feat.battle_on_enemy_casulties(); + } + } +} + + + + diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 484af27435..2062bc2047 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -2,6 +2,8 @@ //missions for the most part can only run from predefined points in the code // to run from each of these points easch mission must have a registered function these functions are then called implicitly //each function follows the format `___` +//each one can have extentions written to account for different stage_id's by insteadd usig the syntax +//`___S` if stage id is "" `___` will be used /* the current entry points for the code are "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn "resolve" - runs when the mission timer hits 0 often contains the failiure conditions for the mission @@ -32,7 +34,7 @@ function PlanetProblem(name, timer, data, planet) constructor{ timer = timer; uid = scr_uuid_generate(); p_id = name; -data = data; +self.data = data; p_data = planet; planet = p_data.planet; system = p_data.system; @@ -86,12 +88,16 @@ static __popup_call = function(func){ return _func; } -static __inquisition_mission_options = function(mission_accept_function){ +static __inquisition_mission_options = function(){ var _options = [ { str1: "Accept", choice_func: function(){ - pop_data.mission[$ mission_accept_function](); + var _mission = pop_data.mission + var _func_str = _mission.find_func_ref("accept"); + if (struct_exists(_mission, _func_str)){ + _mission[$ _func_str](); + } obj_controller.demanding = 0; } }, @@ -132,11 +138,15 @@ static __handle_triggered_mission_func = function(func){ } } -static __find_func = function(trigger_string){ - var _func_string = "__" + p_id + "_trigger_string"; +static find_func_ref = function(trigger_string){ + var _func_string = "__" + p_id + trigger_string; if (stage_id != ""){ - _func_string += "_?" + stage_id; + _func_string += "S" + stage_id; } + return find_func_ref +} +static find_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); if (struct_exists(self,_func_string)){ return self[$ _func_string] } @@ -148,11 +158,11 @@ static basic_turn_end = function(){ timer--; } if ((timer > -1) && per_turn_checks) { - var _func = __find_func("per_turn"); + var _func = find_func("per_turn"); __handle_triggered_mission_func(_func) } if ((timer == 0) && zero_timer_checks && !delete_mission) { - var _func = __find_func("resolve"); + var _func = find_func("resolve"); __handle_triggered_mission_func(_func) } } @@ -160,7 +170,7 @@ static basic_turn_end = function(){ //triggered within drop select static before_battle_effects = function(){ instance_activate_object(obj_star); - var _func = __find_func("setup_battle"); + var _func = find_func("setup_battle"); __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } @@ -172,7 +182,7 @@ static battle_on_enemy_casulties = function(){ exit; } instance_activate_object(obj_star); - var _func = __find_func("on_enemy_casulties"); + var _func = find_func("on_enemy_casulties"); __handle_triggered_mission_func(_func); struct_remove(self, "casualty_packet"); @@ -183,27 +193,27 @@ static battle_on_enemy_casulties = function(){ //triggers in obj_ncombat alarm 5 static battle_final_message = function(){ instance_activate_object(obj_star); - var _func = __find_func("battle_final_message"); + var _func = find_func("battle_final_message"); __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } static after_battle_effects = function(){ instance_activate_object(obj_star); - var _func = __find_func("battle_aftermath"); + var _func = find_func("battle_aftermath"); __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } static on_squad_selection = function(){ - var _func = __find_func("squad_selected"); + var _func = find_func("squad_selected"); __handle_triggered_mission_func(_func); instance_deactivate_object(obj_star); } static on_unit_selection = function(){ - var _func = __find_func("unit_select"); + var _func = find_func("unit_select"); if (!is_undefined(_func)){ if (struct_exists(obj_controller.selection_data, "selections")){ members = obj_controller.selection_data.selections; @@ -214,9 +224,9 @@ static on_unit_selection = function(){ } static __init = function(){ - var _func = __find_func("init"); + var _func = find_func("init"); if (!is_undefined(_func)){ - _func(); + __handle_triggered_mission_func(_func()); } else { mark("green"); } @@ -566,12 +576,12 @@ static __inquisition_recon_init = function(){ var _pop_data = { mission: self, - options : __inquisition_mission_options(__find_func("accept")) + options : __inquisition_mission_options() }; var _text = $"The Inquisition wishes for you to investigate {p_data.name()}"; _text += $" Boots are expected to be planted on its surface over the course of your investigation."; - _text += $" You have {string(eta)} months to complete this task."; + _text += $" You have {timer} months to complete this task."; scr_popup("Inquisition Recon", _text, "inquisition", _pop_data); } @@ -623,16 +633,16 @@ static __inquisitor_necron_resolve = function() { static __inquisition_spyrer_init = function(){ var _text = $"The Inquisition is trusting you with a special mission. An experienced Spyrer on hive world {p_data.name()}"; - _text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {string(estimate)} month's time panic is likely. Can your chapter handle this mission?"; + _text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {timer} month's time panic is likely. Can your chapter handle this mission?"; var _pop_data = { mission: self, - options: __inquisition_mission_options(__find_func("accept")), + options: __inquisition_mission_options(), }; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } static __inquisition_spyrer_accept = function(){ - var _text = $"Inquisition Mission Accepted: An experienced Spyrer on {p_data.name()} must be put down within {string(estimate)} months."; + var _text = $"Inquisition Mission Accepted: An experienced Spyrer on {p_data.name()} must be put down within {timer} months."; scr_event_log("", _text, system.name); } static __spyrer_resolve = function() { @@ -840,7 +850,7 @@ static __mech_bionics_resolve = function() { delete_mission = true; } -static __mech_tomb_per_turn_?exploring = function() { +static __mech_tomb_per_turnSexploring = function() { data.turns++; var _battli = 0; var _roll1 = roll_dice_chapter(1, 100 + data.turns, "low"); @@ -901,7 +911,7 @@ static __mech_tomb_per_turn_?exploring = function() { } } -static per_turn_check_mech_tomb1 = function() { +static __mech_tomb_per_turn = function() { var _marines = collect_role_group("all", [system.name, planet, -1]); if (array_length(_marines) >= 20) { stage_id = "exploring"; @@ -911,7 +921,7 @@ static per_turn_check_mech_tomb1 = function() { } } -static resolve_mech_tomb1_failed = function() { +static ___mech_tomb_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); @@ -919,7 +929,7 @@ static resolve_mech_tomb1_failed = function() { delete_mission = true; } -static mech_tomb_battle_aftermath = function() { +static __mech_tomb_battle_aftermath = function() { if (obj_ncombat.defeat) { delete_mission = true; @@ -942,7 +952,7 @@ static mech_tomb_battle_aftermath = function() { } } -static resolve_mech_mars = function() { +static __mech_mars_resolve = function() { var _techs_taken = 0; var _techs = collect_role_group([SPECIALISTS_TECHMARINES,false,true],system.name); for (i = 0; i < array_length(_techs); i++) { @@ -987,8 +997,7 @@ static resolve_mech_mars = function() { } -static provide_garrison_init = function() { - var mission_data = problems_data[mission_slot]; +static __provide_garrison_init = function() { if (stage_id != "preliminary") { exit; } @@ -1007,7 +1016,7 @@ static provide_garrison_init = function() { scr_event_log("", $"Garrison committed to {_numeral_name} for {_garrison_length} months.", p_data.system.name); } -static complete_garrison_mission = function() { +static __garrison_mission_resolve = function() { if (stage_id != "active"){ exit; } @@ -1185,7 +1194,7 @@ static __protect_raider_squad_selected = function() { } } -static __inqisition_tomb_per_turn = function() { +static __inquisition_tomb_per_turn = function() { if (p_player[run] <= 0){ exit; } @@ -1343,7 +1352,7 @@ static inquisition_tomb_mission_sequence = function() { } ] - data.enemy = "spyder" + data.enemy = "spyder"; break; case 3: _battle_data.cols = [ @@ -1359,7 +1368,7 @@ static inquisition_tomb_mission_sequence = function() { } ] - data.enemy = "stalker" + data.enemy = "stalker"; break; case 4: _battle_data.threat = 2 @@ -1489,7 +1498,7 @@ static __inquisition_demon_world_init = function(){ _text += $"The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; var _pop_data = { mission: self, - options: __inquisition_mission_options(__find_func("accept")), + options: __inquisition_mission_options(), }; scr_popup( "Inquisition Mission Demon World", @@ -1510,7 +1519,7 @@ static __inquisition_demon_world_accept = function(){ static __inquisition_tyranid_org_init = function(){ var _pop_data = { mission: self, - options: __inquisition_mission_options(__find_func("accept")), + options: __inquisition_mission_options()), }; var _text = $"An Inquisitor is trusting you with a special mission. The planet {p_data.name()}"; _text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; @@ -1635,7 +1644,7 @@ static __inquisition_purge_init = function(){ } var _pop_data = { mission: self, - options: __inquisition_mission_options(__find_func("accept")), + options: __inquisition_mission_options(), }; scr_popup("Inquisition Mission", text, "inquisition", _pop_data); } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 1f92e3e0d0..85d6c64dab 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -1,6 +1,6 @@ /// @param {sring} name /// @param {struct} data -function SystemProblem(name, data = {}, system){ +function SystemProblem(name, data = {}, system) constructor{ timer = -1; f_type = eP_FEATURES.MISSION; p_id = name; @@ -17,7 +17,7 @@ if (struct_exists(data, "members")){ members = data.members; } -static handle_triggered_mission_func = function(func){ +static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ try { func(); @@ -39,24 +39,32 @@ static handle_triggered_mission_func = function(func){ } static basic_turn_end = function(){ - if (system.storm - 1 > 0){ - timer--; - } - if ((timer > -1) && per_turn_checks) { - var _func = undefined; - /*switch(p_id){ - }*/ - handle_triggered_mission_func(_func) + if (p_data.system.storm <= 0){ + timer--; + } + if ((timer > -1) && per_turn_checks) { + var _func = find_func("per_turn"); + __handle_triggered_mission_func(_func) + } + if ((timer == 0) && zero_timer_checks && !delete_mission) { + var _func = find_func("resolve"); + __handle_triggered_mission_func(_func) + } +} + +static find_func_ref = function(trigger_string){ + var _func_string = "__" + p_id + trigger_string; + if (stage_id != ""){ + _func_string += "S" + stage_id; } - if ((timer == 0) && zero_timer_checks && !delete_mission) { - var _func = undefined; - switch(p_id){ - case "great_crusade": - _func = resolve_great_crusade; - break; - } - handle_triggered_mission_func(_func) + return find_func_ref +} +static find_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + if (struct_exists(self,_func_string)){ + return self[$ _func_string] } + return undefined; } static mark = function(colour){ @@ -65,15 +73,16 @@ static mark = function(colour){ } } -static init = function(){ - switch(p_id){ - case "great_crusade": - init_great_crusade(); - break; - } +static __init = function(){ + var _func = find_func("init"); + if (!is_undefined(_func)){ + __handle_triggered_mission_func(_func()); + } } -static init_great_crusade = function(){ +__init(); + +static great_crusade_init = function(){ //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards var _nearest_player_fleet = data.nearest_player_fleet; var _travel_leeway = 10; @@ -86,7 +95,7 @@ static init_great_crusade = function(){ scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); } -static resolve_great_crusade = function() { +static great_crusade_resolve = function() { var _player_fleet = scr_orbiting_player_fleet(system); if (_player_fleet != -1) { @@ -112,6 +121,7 @@ static resolve_great_crusade = function() { scr_loyalty("Refusing to Crusade", "+"); scr_event_log("red", "No ships designated for Crusade."); } + delete_mission = true; } } \ No newline at end of file diff --git a/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml b/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml index 031bc06a89..d027aaab6c 100644 --- a/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml +++ b/scripts/scr_chaos_alliance_test/scr_chaos_alliance_test.gml @@ -93,7 +93,7 @@ function scr_chaos_alliance_test() { diplo_text = "[Error: No WL10 planet feature found.]"; } if (instance_exists(that_star)) { - var meeting_arranged = false; + var _meeting_arranged = false; var _p_data = that_star.get_planet_data(that_planet); _p_data.new_problem(result == "success_trap" ? "meeting_trap" : "meeting", 36); } 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 f1733dc5ef..b035b644e1 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -81,7 +81,7 @@ function scr_enemy_ai_d() { } } for (var i = 0; i < array_length(system_problems); i++){ - system_problems[i].basic_end_turn(); + system_problems[i].basic_turn_end(); } for (var i = 1; i <= planets; i++) { diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 560d505ece..eee3db16cd 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -103,7 +103,7 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA break; case eINQUISITION_MISSION.TYRANID_ORGANISM: LOGGER.info("RE: Gaunt Capture"); - var _star = array_random_element(worlds); + var _star = array_random_element(tyranid_org_worlds); var planet = -1; for (var i = 1; i <= _star.planets; i++) { if (_star.p_tyranids[i] > 4) { diff --git a/scripts/scr_shoot/scr_shoot.gml b/scripts/scr_shoot/scr_shoot.gml index f9d87bb2f1..79c9123a6d 100644 --- a/scripts/scr_shoot/scr_shoot.gml +++ b/scripts/scr_shoot/scr_shoot.gml @@ -495,20 +495,13 @@ function scr_shoot(weapon_index_position, target_object, target_type, damage_dat target_object.dudes_num[target_type] -= casualties; obj_ncombat.enemy_forces -= casualties; } - if (obj_ncombat.battle_special != ""){ - if (is_struct(obj_ncombat.special_feature) && is_instanceof(obj_ncombat.special_feature, PlanetProblem)){ - var _feat = obj_ncombat.special_feature; - _feat.casualty_packet = { - number : casualties, - target : target_object, - target_type, - weapon : weapon_index_position < 0 ? "defences" : wep_title[weapon_index_position] - - } - _feat.battle_on_enemy_casulties(); - } - } + obj_ncombat.register_kills_to_missions({ + number : casualties, + target : target_object, + target_type, + weapon : weapon_index_position < 0 ? "defences" : wep_title[weapon_index_position], + }); } } From eea3d2bc1ef745c1eafea5f8abc6edf3b90cf433 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 12:24:31 +0100 Subject: [PATCH 044/118] move remainder of inquisition tomb to modern method --- scripts/PlanetProblem/PlanetProblem.gml | 15 +++++++++++ .../scr_inquisition_mission.gml | 27 ++----------------- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 2062bc2047..cecd4fd0f8 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1194,6 +1194,21 @@ static __protect_raider_squad_selected = function() { } } +static __inquisition_tomb_init = function(){ + var _text = $"The Inquisition is trusting you with a special mission. They have reason to suspect the Necron Tomb on planet {p_data.name()}"; + _text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {string(estimate)} months. Can your chapter handle this mission?"; + var _pop_data = { + mission: self, + options: inquisition_mission_options("__inquisition_tomb_accept"), + }; + scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); +} + +static __inquisition_tomb_accept = function(){ + var _text = $"Inquisition Mission Accepted: A bomb must be planted within the Necron Tomb on {p_data.name()} within {string(estimate)} months."; + scr_event_log("", _text, system.name); +} + static __inquisition_tomb_per_turn = function() { if (p_player[run] <= 0){ exit; diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index eee3db16cd..f9dba8a486 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -186,32 +186,9 @@ function mission_inquisition_necron_world(tomb_worlds) { } var _eta = scr_mission_eta(_star.x, _star.y, 1); - if (global.cheat_debug) { - LOGGER.debug("mission popup"); - } - var _options = [ - { - str1: "Accept", - choice_func: init_mission_inquisition_necron_world, - }, - { - str1: "Refuse", - choice_func: popup_default_close, - }, - ]; - var _pop_data = { - system: _star.name, - planet: planet, - estimate: _eta, - mission: "inquisition_tomb", - options: _options, - }; - - var text = $"The Inquisition is trusting you with a special mission. They have reason to suspect the Necron Tomb on planet {string(_star.name)} {scr_roman(planet)}"; - - text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {string(_eta)} months. Can your chapter handle this mission?"; - scr_popup("Inquisition Mission", text, "inquisition", _pop_data); + var _p_data = _star.get_planet_data(planet); + _p_data.new_problem("inquisition_tomb", _eta, {}); } /// @self Asset.GMObject.obj_popup From 956a4d6b6a446effab49c1e9950c4ecdedbd9770 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 12:27:03 +0100 Subject: [PATCH 045/118] remove use of estimate --- scripts/PlanetProblem/PlanetProblem.gml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index cecd4fd0f8..e6d28f076d 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -17,6 +17,8 @@ "unit_select" - runs after selecting units in the unit selection screen (scr_manage_task_selector) "init" - runs imediatly after problem is created often used to poopulate initial popupop ir stack popup for turn end + "accept" is an edge case currently reserved for binding to button clicks in popups + - other than these entry points and any other later defined poisitions mission specific code should not run outsiide of the PlanetProblem container - to set an entry point up simply register the function as a static e.g @@ -1196,16 +1198,16 @@ static __protect_raider_squad_selected = function() { static __inquisition_tomb_init = function(){ var _text = $"The Inquisition is trusting you with a special mission. They have reason to suspect the Necron Tomb on planet {p_data.name()}"; - _text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {string(estimate)} months. Can your chapter handle this mission?"; + _text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {timer} months. Can your chapter handle this mission?"; var _pop_data = { mission: self, - options: inquisition_mission_options("__inquisition_tomb_accept"), + options: inquisition_mission_options(), }; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } static __inquisition_tomb_accept = function(){ - var _text = $"Inquisition Mission Accepted: A bomb must be planted within the Necron Tomb on {p_data.name()} within {string(estimate)} months."; + var _text = $"Inquisition Mission Accepted: A bomb must be planted within the Necron Tomb on {p_data.name()} within {timer} months."; scr_event_log("", _text, system.name); } @@ -1228,7 +1230,6 @@ static __inquisition_tomb_per_turn = function() { mission: self, loc: system.name, planet: planet, - estimate: 999, number: _number, options: [ { @@ -1667,9 +1668,9 @@ static __inquisition_purge_init = function(){ static __inquisition_purge_accept = function(){ var _text = "Inquisition Mission Accepted:" if (data.purge_type == eDROP_TYPE.PURGEFIRE){ - _text += $" The mutants beneath {p_data.name()} must be cleansed by fire within {estimate} months."; + _text += $" The mutants beneath {p_data.name()} must be cleansed by fire within {timer} months."; } else { - _text += $" The nobles of {p_data.name()} must be selectively purged within {estimate} months." + _text += $" The nobles of {p_data.name()} must be selectively purged within {timer} months." } scr_event_log("", _text, system.name); } From 107a2e3cf6619fa40fdb36d33c1777f049a64ede Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 12:32:23 +0100 Subject: [PATCH 046/118] tweaks --- objects/obj_ncombat/Create_0.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 12 ++++++------ scripts/SystemProblem/SystemProblem.gml | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/objects/obj_ncombat/Create_0.gml b/objects/obj_ncombat/Create_0.gml index 21db5c1bb1..a7d2820f60 100644 --- a/objects/obj_ncombat/Create_0.gml +++ b/objects/obj_ncombat/Create_0.gml @@ -274,7 +274,7 @@ occulobe = obj_ini.occulobe; // penalty if morning and susceptible to flash gren mucranoid = obj_ini.mucranoid; // chance to short-circuit -register_kills_to_missions(casulties){ +register_kills_to_missions = function(casulties){ if (obj_ncombat.battle_special != ""){ if (is_struct(obj_ncombat.special_feature) && is_instanceof(obj_ncombat.special_feature, PlanetProblem)){ var _feat = obj_ncombat.special_feature; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index e6d28f076d..22a68e29d5 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -141,11 +141,11 @@ static __handle_triggered_mission_func = function(func){ } static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + trigger_string; + var _func_string = "__" + p_id + "_" trigger_string; if (stage_id != ""){ _func_string += "S" + stage_id; } - return find_func_ref + return return _func_string } static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); @@ -161,11 +161,11 @@ static basic_turn_end = function(){ } if ((timer > -1) && per_turn_checks) { var _func = find_func("per_turn"); - __handle_triggered_mission_func(_func) + __handle_triggered_mission_func(_func); } if ((timer == 0) && zero_timer_checks && !delete_mission) { var _func = find_func("resolve"); - __handle_triggered_mission_func(_func) + __handle_triggered_mission_func(_func); } } @@ -228,7 +228,7 @@ static on_unit_selection = function(){ static __init = function(){ var _func = find_func("init"); if (!is_undefined(_func)){ - __handle_triggered_mission_func(_func()); + __handle_triggered_mission_func(_func); } else { mark("green"); } @@ -1535,7 +1535,7 @@ static __inquisition_demon_world_accept = function(){ static __inquisition_tyranid_org_init = function(){ var _pop_data = { mission: self, - options: __inquisition_mission_options()), + options: __inquisition_mission_options(), }; var _text = $"An Inquisitor is trusting you with a special mission. The planet {p_data.name()}"; _text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 85d6c64dab..ca95c0d969 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -44,20 +44,20 @@ static basic_turn_end = function(){ } if ((timer > -1) && per_turn_checks) { var _func = find_func("per_turn"); - __handle_triggered_mission_func(_func) + __handle_triggered_mission_func(_func); } if ((timer == 0) && zero_timer_checks && !delete_mission) { var _func = find_func("resolve"); - __handle_triggered_mission_func(_func) + __handle_triggered_mission_func(_func); } } static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + trigger_string; + var _func_string = "__" + p_id + "_" trigger_string; if (stage_id != ""){ _func_string += "S" + stage_id; } - return find_func_ref + return return _func_string } static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); @@ -76,7 +76,7 @@ static mark = function(colour){ static __init = function(){ var _func = find_func("init"); if (!is_undefined(_func)){ - __handle_triggered_mission_func(_func()); + __handle_triggered_mission_func(); } } From bce7c330a03bc2272f8b14d714af64f3bee531f1 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 12:51:08 +0100 Subject: [PATCH 047/118] minor errors --- scripts/PlanetProblem/PlanetProblem.gml | 10 +++++----- scripts/SystemProblem/SystemProblem.gml | 15 ++++++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 22a68e29d5..5eac79161c 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -141,11 +141,11 @@ static __handle_triggered_mission_func = function(func){ } static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + "_" trigger_string; + var _func_string = "__" + p_id + "_" + trigger_string; if (stage_id != ""){ _func_string += "S" + stage_id; } - return return _func_string + return _func_string } static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); @@ -923,7 +923,7 @@ static __mech_tomb_per_turn = function() { } } -static ___mech_tomb_resolve = function() { +static __mech_tomb_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); @@ -1201,7 +1201,7 @@ static __inquisition_tomb_init = function(){ _text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {timer} months. Can your chapter handle this mission?"; var _pop_data = { mission: self, - options: inquisition_mission_options(), + options: __inquisition_mission_options(), }; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } @@ -1212,7 +1212,7 @@ static __inquisition_tomb_accept = function(){ } static __inquisition_tomb_per_turn = function() { - if (p_player[run] <= 0){ + if (p_data.player_forces <= 0){ exit; } LOGGER.info($"player on planet with necron mission {name} planet: {planet}"); diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index ca95c0d969..4560625a14 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -8,6 +8,7 @@ data = data; stage_id = ""; self.system = system; zero_timer_checks = true; +per_turn_checks = true; delete_mission = false; members = []; if (struct_exists(data, "stage")){ @@ -39,7 +40,7 @@ static __handle_triggered_mission_func = function(func){ } static basic_turn_end = function(){ - if (p_data.system.storm <= 0){ + if (system.storm <= 0){ timer--; } if ((timer > -1) && per_turn_checks) { @@ -53,11 +54,11 @@ static basic_turn_end = function(){ } static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + "_" trigger_string; + var _func_string = "__" + p_id + "_" + trigger_string; if (stage_id != ""){ _func_string += "S" + stage_id; } - return return _func_string + return _func_string } static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); @@ -76,13 +77,13 @@ static mark = function(colour){ static __init = function(){ var _func = find_func("init"); if (!is_undefined(_func)){ - __handle_triggered_mission_func(); + __handle_triggered_mission_func(_func); } } __init(); -static great_crusade_init = function(){ +static __great_crusade_init = function(){ //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards var _nearest_player_fleet = data.nearest_player_fleet; var _travel_leeway = 10; @@ -92,10 +93,10 @@ static great_crusade_init = function(){ timer = get_viable_travel_time(_travel_leeway, _nearest_player_fleet.x, _nearest_player_fleet.y, system.x, system.y, _nearest_player_fleet, false); scr_popup("Crusade", $"Fellow Astartes legions are preparing to embark on a Crusade to a nearby sector. Your forces are expected at {system.name}; {timer} months from now your ships there shall begin their journey.", "crusade", ""); mark("green") - scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", star_id.name); + scr_event_log("", $"A Crusade is called; our forces are expected at {system.name} in {timer} months.", system.name); } -static great_crusade_resolve = function() { +static __great_crusade_resolve = function() { var _player_fleet = scr_orbiting_player_fleet(system); if (_player_fleet != -1) { From 16e333ee620046824556153e99ffe63c50923589 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 14:51:05 +0100 Subject: [PATCH 048/118] save and load --- objects/obj_star/Create_0.gml | 24 +++--- scripts/PlanetProblem/PlanetProblem.gml | 86 +++++++++++++------ scripts/scr_PlanetData/scr_PlanetData.gml | 28 ++++++ .../scr_marine_struct/scr_marine_struct.gml | 19 ++++ 4 files changed, 119 insertions(+), 38 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 9e8dfda855..f1d9f706f4 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -181,18 +181,7 @@ serialize = function() { var planet_data = []; for (var p = 1; p <= object_star.planets; p++) { - planet_data[p] = { - dispo: object_star.dispo[p], - planet: object_star.planet[p], - }; - var var_names = variable_instance_get_names(object_star); - for (var n = 0; n < array_length(var_names); n++) { - var var_name = var_names[n]; - if (string_starts_with(var_name, "p_")) { - var val = object_star[$ var_name][p]; - variable_struct_set(planet_data[p], var_name, val); - } - } + planet_data[p] = get_planet_data(p).save(); } var save_data = { @@ -259,7 +248,7 @@ function deserialize(save_data) { continue; } - var _new_feat = new NewPlanetFeature(_feat.f_type); + var _new_feat = new PlanetFeature(_feat.f_type); _new_feat.load_json_data(_feat); @@ -267,6 +256,15 @@ function deserialize(save_data) { } continue; } + if (var_name == "p_problem") { + var _planet_problems = planet[$ var_name]; + for (var f = 0; f < array_length(_planet_problems); f++) { + var _new_prob = new PlanetProblem("", 0, {}, {planet:p,system:id}); + _new_prob.load(_planet_problems[f]); + array_push(p_problem, _new_prob); + } + continue; + } var val = planet[$ var_name]; self[$ var_name][p] = val; } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 5eac79161c..4d8e3e2c8b 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -43,8 +43,9 @@ system = p_data.system; f_type = eP_FEATURES.MISSION; members = []; delete_mission = false; -static refresh_p_data = function(){ +static __refresh_data = function(){ p_data = system.get_planet_data(planet); + members = clean_unit_array(members); } stage_id = ""; @@ -61,12 +62,33 @@ zero_timer_checks = true; per_turn_checks = true; static mark = function(colour){ - refresh_p_data(); + __refresh_data(); with (p_data.system){ new_star_event_marker(colour) } } +static save = function(){ + var _save_copy = variable_clone(_save_copy); + struct_remove(save_copy, "system"); + struct_remove(save_copy, "p_data"); + var _mems = clean_unit_array(members); + _save_copy.members = []; + for (var i=0;i= 0; i--){ + var _unit = array[i]; + if (!is_struct(_unit)){ + array_delete(array, i, 1); + continue; + } + if (_unit.marine_number > (company_length(_unit.company) - 1)){ + array_delete(array, i, 1); + continue; + } + if (fetch_unit([_unit.company, _unit.marine_number]).uid != _unit.uid){ + array_delete(array, i, 1); + continue; + } + } + return array; +} + /// @desc Localizes a unit's role and appends its name and first epithet, mirroring /// name_role()'s display order while keeping the role translatable. /// @param {Struct} _unit A marine unit struct. From eda4646ad735b1238d38e1110162a3aa1cec47bc Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 15:15:44 +0100 Subject: [PATCH 049/118] add on_purge mission hook point and complete inquisition_purge mission --- scripts/PlanetProblem/PlanetProblem.gml | 47 +++++- scripts/SystemProblem/SystemProblem.gml | 2 +- scripts/scr_purge_world/scr_purge_world.gml | 155 +++++++++----------- 3 files changed, 118 insertions(+), 86 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 4d8e3e2c8b..94b76ad3dc 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -15,6 +15,7 @@ "battle_aftermath" - runs post combat during obj_ncombat alarm_7 "squad_selected" - runs after selecting a squad inn the squad select window (scr_manage_task_selector) "unit_select" - runs after selecting units in the unit selection screen (scr_manage_task_selector) + "on_purge" - at the top of PlanetData.purge() passes in {action_type, action_score} as purge_data overrides standdard purge popups "init" - runs imediatly after problem is created often used to poopulate initial popupop ir stack popup for turn end "accept" is an edge case currently reserved for binding to button clicks in popups @@ -68,6 +69,10 @@ static mark = function(colour){ } } +static has_data = function(key){ + return struct_exists(self, key); +} + static save = function(){ var _save_copy = variable_clone(_save_copy); struct_remove(save_copy, "system"); @@ -178,7 +183,12 @@ static find_func_ref = function(trigger_string){ if (stage_id != ""){ _func_string += "S" + stage_id; } - return _func_string + return _func_string; +} + +static has_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + return struct_exists(self,_func_string); } static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); @@ -258,6 +268,16 @@ static on_unit_selection = function(){ instance_deactivate_object(obj_star); } +static on_purge = function(){ + if (!struct_exists(self, "purge_data")){ + exit; + } + var _func = find_func("on_purge"); + __handle_triggered_mission_func(_func); + + struct_remove(self, "purge_data"); +} + static __init = function(){ if (p_id == ""){ exit; @@ -1711,6 +1731,31 @@ static __inquisition_purge_accept = function(){ scr_event_log("", _text, system.name); } +static __inquisition_purge_on_purge = function(){ + switch (data.purge_type){ + case eDROP_TYPE.PURGESELECTIVE: + delete_mission = true; + + alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); + + _popup_text = "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)); + scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); + break; + case eDROP_TYPE.PURGEFIRE: + delete_mission = true; + + alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); + + _popup_text = $"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)); + scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); + break; + } +} + } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 4560625a14..11a5a5bc5d 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -58,7 +58,7 @@ static find_func_ref = function(trigger_string){ if (stage_id != ""){ _func_string += "S" + stage_id; } - return _func_string + return _func_string; } static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); diff --git a/scripts/scr_purge_world/scr_purge_world.gml b/scripts/scr_purge_world/scr_purge_world.gml index d1f7bdeef7..cf14cedebf 100644 --- a/scripts/scr_purge_world/scr_purge_world.gml +++ b/scripts/scr_purge_world/scr_purge_world.gml @@ -132,8 +132,42 @@ function PlayerPurge(action_type, action_score, planet_data) constructor { }; } +function log_ship_effort_purge(){ + if (instance_exists(obj_drop_select)) { + with (obj_drop_select) { + if (instance_exists(sh_target)) { + sh_target.acted = 5; + } + instance_destroy(); + } + } +} + /// @self Struct.PlanetData function scr_purge_world(action_type, action_score) { + + var _mission_override = false; + for (var i = 0; i < problems; i++){ + var _prob = problems[i]; + if (!_prob.has_func("on_purge")){ + continue; + } + if (!_prob.has_data("purge_type")){ + continue; + } + if (_prob.data.purge_type == action_type){ + _prob.purge_data = { + action_type, + action_score, + } + _mission_override = true; + _prob.on_purge(); + } + } + if (_mission_override){ + log_ship_effort_purge(); + exit; + } var _purge = new PlayerPurge(action_type, action_score, self); var _isquest = 0; @@ -215,109 +249,62 @@ function scr_purge_world(action_type, action_score) { if (action_type == eDROP_TYPE.PURGEFIRE) { // Burn baby burn - var i = 0; - if (has_problem("cleanse")) { - _isquest = true; - _thequest = "cleanse"; - _questnum = i; - } + // TODO add more variation, with planets, features, marine equipment perhaps? + _popup_text = 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."); - if (_isquest) { - if (_thequest == "cleanse" && action_score >= 20) { - remove_problem(_thequest); - - alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - - _popup_text = $"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)); - } + var nid_influence = population_influences[eFACTION.TYRANIDS]; + if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; + if (cult.hiding) {} } else { - // TODO add more variation, with planets, features, marine equipment perhaps? - _popup_text = 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."); - - var nid_influence = population_influences[eFACTION.TYRANIDS]; - if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; - if (cult.hiding) {} - } else { - if (nid_influence > 25) { - _popup_text += " 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"; - adjust_influence(eFACTION.TYRANIDS, -10, planet, system); - } else if (nid_influence > 0) { - _popup_text += " 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 (nid_influence > 25) { + _popup_text += " 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"; + adjust_influence(eFACTION.TYRANIDS, -10, planet, system); + } else if (nid_influence > 0) { + _popup_text += " There are signs of a genestealer infestation but the cultists are too unorganized to do any real damage to their influence on this world"; } - - _popup_text += _purge.population_death_string(); } + + _popup_text += _purge.population_death_string(); + } if (action_type == eDROP_TYPE.PURGESELECTIVE) { // Blam! var i = 0; - if (has_problem("purge")) { - _isquest = 1; - _thequest = "purge"; - _questnum = i; - } - - if (_isquest == 1) { - if (_thequest == "purge" && action_score >= 10) { - remove_problem("purge"); - alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); + // TODO add more variation, with planets, features, possibly marine equipment + _popup_text = $"Your marines move across {name()},"; + _popup_text += choose($"searching for high profile targets. Once found, they are dragged outside from their lairs. Their execution would soon follow.", $"rooting out sources of corruption. Heretics are dragged from their lairs and executed in the streets."); - _popup_text = "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 - _popup_text = $"Your marines move across {name()},"; - _popup_text += choose($"searching for high profile targets. Once found, they are dragged outside from their lairs. Their execution would soon follow.", $"rooting out sources of corruption. Heretics are dragged from their lairs and executed in the streets."); + _popup_text += _purge.population_death_string(); - _popup_text += _purge.population_death_string(); - } } if (action_type == eDROP_TYPE.PURGEASSASSINATE) { assasinate_governor_setup(action_score); } else if (action_type != eDROP_TYPE.PURGEASSASSINATE) { - if (_isquest == 0) { - // DO EET - var _txt2 = _popup_text; - switch (_purge.heres_target) { - case "corruption": - alter_corruption(-_purge.influence_reduction); - break; - case "tau": - alter_influence(eFACTION.TAU, -_purge.influence_reduction); - break; - case "genestealers": - alter_influence(eFACTION.TYRANIDS, -_purge.influence_reduction); - break; - } - set_population(population_large_conversion(_purge.pop_after)); - - var pip = instance_create(0, 0, obj_popup); - pip.title = "Purge Results"; - pip.text = _txt2; - } - if (_isquest) { - // DO EET - var pip = instance_create(0, 0, obj_popup); - scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); + // DO EET + var _txt2 = _popup_text; + switch (_purge.heres_target) { + case "corruption": + alter_corruption(-_purge.influence_reduction); + break; + case "tau": + alter_influence(eFACTION.TAU, -_purge.influence_reduction); + break; + case "genestealers": + alter_influence(eFACTION.TYRANIDS, -_purge.influence_reduction); + break; } - } - if (instance_exists(obj_drop_select)) { - with (obj_drop_select) { - if (instance_exists(sh_target)) { - sh_target.acted = 5; - } - instance_destroy(); - } + set_population(population_large_conversion(_purge.pop_after)); + + var pip = instance_create(0, 0, obj_popup); + pip.title = "Purge Results"; + pip.text = _txt2; + } + log_ship_effort_purge(); } From 89ba1898054b3b6f60d77d37aae190e1c213cd6a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 15:20:47 +0100 Subject: [PATCH 050/118] correct local var names --- objects/obj_en_fleet/Create_0.gml | 26 ++++++++--------- objects/obj_ini/Create_0.gml | 14 +++++----- objects/obj_star/Create_0.gml | 34 +++++++++++------------ scripts/scr_PlanetData/scr_PlanetData.gml | 14 +++++----- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index e0290b167d..d9b17a9be2 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -80,9 +80,9 @@ escort_health = 100; /// Called from save function to take all object variables and convert them to a json savable format and return it serialize = function() { - var object_fleet = self; + var _object_fleet = self; - var save_data = { + var _save_data = { obj: object_get_name(object_index), x, y, @@ -96,11 +96,11 @@ serialize = function() { "orbiting", ]; - copy_serializable_fields(object_fleet, save_data, excluded_from_save); + copy_serializable_fields(_object_fleet, _save_data, excluded_from_save); - return save_data; + return _save_data; }; -deserialize = function(save_data) { +deserialize = function(_save_data) { var exclusions = [ "id", "cargo_data", @@ -108,22 +108,22 @@ deserialize = function(save_data) { ]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting - var all_names = struct_get_names(save_data); - var _len = array_length(all_names); + var _all_names = struct_get_names(_save_data); + var _len = array_length(_all_names); for (var i = 0; i < _len; i++) { - var var_name = all_names[i]; - if (array_contains(exclusions, var_name)) { + var _var_name = _all_names[i]; + if (array_contains(exclusions, _var_name)) { continue; } - var loaded_value = struct_get(save_data, var_name); + var _loaded_value = struct_get(_save_data, _var_name); try { - variable_instance_set(self, var_name, loaded_value); + variable_instance_set(self, _var_name, _loaded_value); } catch (e) { LOGGER.exception("Deserialization failed", e); } } - if (struct_exists(save_data, "cargo_data")) { - variable_instance_set(self, "cargo_data", save_data.cargo_data); + if (struct_exists(_save_data, "cargo_data")) { + variable_instance_set(self, "cargo_data", _save_data.cargo_data); if (fleet_has_cargo("ork_warboss")) { var _boss = new NewPlanetFeature(eP_FEATURES.ORKWARBOSS); _boss.load_json_data(cargo_data.ork_warboss); diff --git a/objects/obj_ini/Create_0.gml b/objects/obj_ini/Create_0.gml index 588678f22e..9e663118a4 100644 --- a/objects/obj_ini/Create_0.gml +++ b/objects/obj_ini/Create_0.gml @@ -239,21 +239,21 @@ deserialize = function(save_data) { ]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting - var all_names = struct_get_names(save_data); + var _all_names = struct_get_names(save_data); - if (!array_contains(all_names, "chapter_squad_arrangement")) { + if (!array_contains(_all_names, "chapter_squad_arrangement")) { chapter_squad_arrangement = json_to_gamemaker(working_directory + $"main/squads/company_squad_builds.json", json_parse); } - for (var i = 0; i < array_length(all_names); i++) { - var var_name = all_names[i]; - if (array_contains(exclusions, var_name)) { + for (var i = 0; i < array_length(_all_names); i++) { + var _var_name = _all_names[i]; + if (array_contains(exclusions, _var_name)) { continue; } - var loaded_value = struct_get(save_data, var_name); + var loaded_value = struct_get(save_data, _var_name); try { - variable_instance_set(id, var_name, loaded_value); + variable_instance_set(id, _var_name, loaded_value); } catch (e) { LOGGER.exception("Deserialization failed", e); } diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index f1d9f706f4..272c6e4f89 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -222,26 +222,26 @@ function deserialize(save_data) { ]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting - var all_names = struct_get_names(save_data); - for (var i = 0; i < array_length(all_names); i++) { - var var_name = all_names[i]; - if (array_contains(exclusions, var_name)) { + var _all_names = struct_get_names(save_data); + for (var i = 0; i < array_length(_all_names); i++) { + var _var_name = _all_names[i]; + if (array_contains(exclusions, _var_name)) { continue; } - var loaded_value = struct_get(save_data, var_name); - variable_instance_set(id, var_name, loaded_value); + var _loaded_value = struct_get(save_data, _var_name); + variable_instance_set(id, _var_name, _loaded_value); } if (struct_exists(save_data, "planet_data")) { var planet_arr = save_data.planet_data; for (var p = 1; p < array_length(planet_arr); p++) { - var planet = planet_arr[p]; - var var_names = struct_get_names(planet); - for (var v = 0; v < array_length(var_names); v++) { - var var_name = var_names[v]; + var _planet = planet_arr[p]; + var _var_names = struct_get_names(_planet); + for (var v = 0; v < array_length(_var_names); v++) { + var _var_name = _var_names[v]; - if (var_name == "p_feature") { - var _planet_features = planet[$ var_name]; + if (_var_name == "p_feature") { + var _planet_features = _planet[$ _var_name]; for (var f = 0; f < array_length(_planet_features); f++) { var _feat = _planet_features[f]; if (!is_struct(_feat) || !struct_exists(_feat, "f_type")) { @@ -256,17 +256,17 @@ function deserialize(save_data) { } continue; } - if (var_name == "p_problem") { - var _planet_problems = planet[$ var_name]; + if (_var_name == "p_problem") { + var _planet_problems = _planet[$ _var_name]; for (var f = 0; f < array_length(_planet_problems); f++) { - var _new_prob = new PlanetProblem("", 0, {}, {planet:p,system:id}); + var _new_prob = new PlanetProblem("", 0, {}, {_planet:p,system:id}); _new_prob.load(_planet_problems[f]); array_push(p_problem, _new_prob); } continue; } - var val = planet[$ var_name]; - self[$ var_name][p] = val; + var _val = _planet[$ _var_name]; + self[$ _var_name][p] = _val; } } } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 6eb765c617..b8c6e465f7 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -21,17 +21,17 @@ function PlanetData(_planet, _system) constructor { dispo: system.dispo[planet], planet: system.planet[planet], }; - var var_names = variable_instance_get_names(system); - for (var n = 0; n < array_length(var_names); n++) { - var var_name = var_names[n]; - if (!string_starts_with(var_name, "p_")) { + var __var_names = variable_instance_get_names(system); + for (var n = 0; n < array_length(__var_names); n++) { + var _var_name = __var_names[n]; + if (!string_starts_with(_var_name, "p_")) { continue; } - var _val = system[$ var_name][planet]; - if (_val == "var_name"){ + var _val = system[$ _var_name][planet]; + if (_val == "p_problem"){ _val = save_problems(); } - variable_struct_set(_planet_data, var_name, _val); + variable_struct_set(_planet_data, _var_name, _val); } return _planet_data; From d24257546830f202fbd6ccf608d55637e651ec61 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Sun, 27 Sep 2026 15:22:55 +0100 Subject: [PATCH 051/118] Update scripts/scr_marine_struct/scr_marine_struct.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_marine_struct/scr_marine_struct.gml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index dcb89b7fac..a5ca5632f5 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -2451,7 +2451,8 @@ function clean_unit_array(array){ array_delete(array, i, 1); continue; } - if (fetch_unit([_unit.company, _unit.marine_number]).uid != _unit.uid){ + var _current_unit = fetch_unit([_unit.company, _unit.marine_number]); + if (!is_struct(_current_unit) || _current_unit.uid != _unit.uid){ array_delete(array, i, 1); continue; } From ca22304f721941884e92c0dda027452310fa0fec Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 15:23:14 +0100 Subject: [PATCH 052/118] loadinng safety --- objects/obj_star/Create_0.gml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 272c6e4f89..9d70ab0cb6 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -259,6 +259,9 @@ function deserialize(save_data) { if (_var_name == "p_problem") { var _planet_problems = _planet[$ _var_name]; for (var f = 0; f < array_length(_planet_problems); f++) { + if (!is_struct(_planet_problems)){ + continue; + } var _new_prob = new PlanetProblem("", 0, {}, {_planet:p,system:id}); _new_prob.load(_planet_problems[f]); array_push(p_problem, _new_prob); From 6413295531cfdab0d50679e2ab1f96e58c8b8528 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 15:25:29 +0100 Subject: [PATCH 053/118] remove legacy variables --- scripts/scr_purge_world/scr_purge_world.gml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/scripts/scr_purge_world/scr_purge_world.gml b/scripts/scr_purge_world/scr_purge_world.gml index cf14cedebf..1f7963d7ba 100644 --- a/scripts/scr_purge_world/scr_purge_world.gml +++ b/scripts/scr_purge_world/scr_purge_world.gml @@ -169,10 +169,6 @@ function scr_purge_world(action_type, action_score) { exit; } var _purge = new PlayerPurge(action_type, action_score, self); - - var _isquest = 0; - var _thequest = ""; - var _questnum = 0; var _popup_text = ""; _purge.pop_before = population_as_small(); @@ -252,15 +248,15 @@ function scr_purge_world(action_type, action_score) { // TODO add more variation, with planets, features, marine equipment perhaps? _popup_text = 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."); - var nid_influence = population_influences[eFACTION.TYRANIDS]; + var _nid_influence = population_influences[eFACTION.TYRANIDS]; if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { var cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; if (cult.hiding) {} } else { - if (nid_influence > 25) { + if (_nid_influence > 25) { _popup_text += " 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"; adjust_influence(eFACTION.TYRANIDS, -10, planet, system); - } else if (nid_influence > 0) { + } else if (_nid_influence > 0) { _popup_text += " There are signs of a genestealer infestation but the cultists are too unorganized to do any real damage to their influence on this world"; } } @@ -270,9 +266,6 @@ function scr_purge_world(action_type, action_score) { } if (action_type == eDROP_TYPE.PURGESELECTIVE) { - // Blam! - var i = 0; - // TODO add more variation, with planets, features, possibly marine equipment _popup_text = $"Your marines move across {name()},"; _popup_text += choose($"searching for high profile targets. Once found, they are dragged outside from their lairs. Their execution would soon follow.", $"rooting out sources of corruption. Heretics are dragged from their lairs and executed in the streets."); @@ -301,9 +294,9 @@ function scr_purge_world(action_type, action_score) { set_population(population_large_conversion(_purge.pop_after)); - var pip = instance_create(0, 0, obj_popup); - pip.title = "Purge Results"; - pip.text = _txt2; + var _pip = instance_create(0, 0, obj_popup); + _pip.title = "Purge Results"; + _pip.text = _txt2; } log_ship_effort_purge(); From 7e89b2f749bc050a46fab251ecf6531befeb61fb Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 15:45:41 +0100 Subject: [PATCH 054/118] more review points --- objects/obj_star/Create_0.gml | 8 ++-- scripts/PlanetProblem/PlanetProblem.gml | 43 +++++++++------------ scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- scripts/scr_purge_world/scr_purge_world.gml | 2 +- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 9d70ab0cb6..c7f8da0738 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -248,7 +248,7 @@ function deserialize(save_data) { continue; } - var _new_feat = new PlanetFeature(_feat.f_type); + var _new_feat = new NewPlanetFeature(_feat.f_type); _new_feat.load_json_data(_feat); @@ -259,12 +259,12 @@ function deserialize(save_data) { if (_var_name == "p_problem") { var _planet_problems = _planet[$ _var_name]; for (var f = 0; f < array_length(_planet_problems); f++) { - if (!is_struct(_planet_problems)){ + if (!is_struct(_planet_problems[f])){ continue; } - var _new_prob = new PlanetProblem("", 0, {}, {_planet:p,system:id}); + var _new_prob = new PlanetProblem("", 0, {}, {planet:p,system:id}); _new_prob.load(_planet_problems[f]); - array_push(p_problem, _new_prob); + array_push(p_problem[p], _new_prob); } continue; } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 94b76ad3dc..9107fb9921 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -70,23 +70,23 @@ static mark = function(colour){ } static has_data = function(key){ - return struct_exists(self, key); + return struct_exists(data, key); } static save = function(){ - var _save_copy = variable_clone(_save_copy); + var _save_copy = variable_clone(self); struct_remove(save_copy, "system"); struct_remove(save_copy, "p_data"); var _mems = clean_unit_array(members); _save_copy.members = []; for (var i=0;i -1){ - array_delete(system.p_problem, _prob,1); + array_delete(system.p_problem[planet], _prob,1); array_delete(p_data.problems, _prob,1); } } @@ -880,7 +873,7 @@ static __mech_raider_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: Land Raider testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); - p_data.alter_disposition(eFACTION.MECHANICUS, -6); + alter_disposition(eFACTION.MECHANICUS, -6); delete_mission = true; } @@ -904,7 +897,7 @@ static __mech_bionics_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: bionics testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); - p_data.alter_disposition(eFACTION.MECHANICUS, -6); + alter_disposition(eFACTION.MECHANICUS, -6); delete_mission = true; } @@ -937,7 +930,7 @@ static __mech_tomb_per_turnSexploring = function() { // XDDDDD scr_popup("Mechanicus Mission Failed", $"The Mechanicus Research team on planet {p_data.name()} have been killed by Necrons in the absence of your astartes. The Mechanicus are absolutely livid, doubly so because of the promised security they did not recieve.", "", ""); obj_controller.turns_ignored[3] += choose(8, 10, 12, 14, 16, 18, 20, 22, 24); - p_data.alter_disposition(eFACTION.MECHANICUS, -25); + alter_disposition(eFACTION.MECHANICUS, -25); delete_mission = true; } } else { @@ -983,7 +976,7 @@ static __mech_tomb_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); - p_data.alter_disposition(eFACTION.MECHANICUS, -15); + alter_disposition(eFACTION.MECHANICUS, -15); delete_mission = true; } @@ -1290,11 +1283,11 @@ static __inquisition_tomb_per_turn = function() { options: [ { str1: "Begin the Mission", - choice_func: __popup_call("necron_tomb_mission_start"), + choice_func: necron_tomb_mission_start, }, { str1: "Not Yet", - choice_func: __popup_call("__popup_delete"), + choice_func:__popup_delete, }, ], }; @@ -1304,8 +1297,8 @@ static __inquisition_tomb_per_turn = function() { static inquisition_tomb_mission_start = function() { obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; obj_popup.replace_options([ - {str1: "Continue", choice_func: __popup_call("necron_tomb_mission_sequence")}, - {str1: "Return to the surface", choice_func: __popup_call("__popup_delete")} + {str1: "Continue", choice_func: necron_tomb_mission_sequence}, + {str1: "Return to the surface", choice_func: __popup_delete} ]); obj_popup.image = "necron_tunnels_1"; obj_popup.text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; @@ -1732,15 +1725,15 @@ static __inquisition_purge_accept = function(){ } static __inquisition_purge_on_purge = function(){ - switch (data.purge_type){ + switch (purge_data.action_type){ case eDROP_TYPE.PURGESELECTIVE: delete_mission = true; alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - _popup_text = "Your marines drop fast and hard, blowing through guards and mercenaries with minimal resistance. Before ten minutes have passed all your targets are executed."; + var _popup_text = "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)); + p_data.add_disposition(choose(1, 2, 3)); scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); break; case eDROP_TYPE.PURGEFIRE: @@ -1748,9 +1741,9 @@ static __inquisition_purge_on_purge = function(){ alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - _popup_text = $"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."; + var _popup_text = $"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)); + p_data.add_disposition(choose(1, 2, 3)); scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); break; } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index b8c6e465f7..cc20ce9d05 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -28,7 +28,7 @@ function PlanetData(_planet, _system) constructor { continue; } var _val = system[$ _var_name][planet]; - if (_val == "p_problem"){ + if (_var_name == "p_problem"){ _val = save_problems(); } variable_struct_set(_planet_data, _var_name, _val); diff --git a/scripts/scr_purge_world/scr_purge_world.gml b/scripts/scr_purge_world/scr_purge_world.gml index 1f7963d7ba..03627ba505 100644 --- a/scripts/scr_purge_world/scr_purge_world.gml +++ b/scripts/scr_purge_world/scr_purge_world.gml @@ -147,7 +147,7 @@ function log_ship_effort_purge(){ function scr_purge_world(action_type, action_score) { var _mission_override = false; - for (var i = 0; i < problems; i++){ + for (var i = 0; i < array_length(problems); i++){ var _prob = problems[i]; if (!_prob.has_func("on_purge")){ continue; From 42dc8877b525ddf2af897a7e53ef2a5baf0b46f8 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 17:01:48 +0100 Subject: [PATCH 055/118] extract mission select feature drawing into PlanetProblem constructor --- scripts/PlanetProblem/PlanetProblem.gml | 160 ++++++++++++++---- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- scripts/scr_UnitGroup/scr_UnitGroup.gml | 5 + .../scr_draw_planet_features.gml | 80 +-------- .../scr_inquisition_mission.gml | 2 +- .../scr_mission_functions.gml | 4 +- 6 files changed, 139 insertions(+), 114 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 9107fb9921..257518ba19 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -33,12 +33,12 @@ other info /// @param {Real} timer /// @param {struct} data /// @param {constructor PlanetData} planet -function PlanetProblem(name, timer, data, planet) constructor{ -timer = timer; +function PlanetProblem(_name, _timer, _data, _planet_data) constructor{ +timer = _timer; uid = scr_uuid_generate(); -p_id = name; -self.data = data; -p_data = planet; +p_id = _name; +data = _data; +p_data = _planet_data; planet = p_data.planet; system = p_data.system; f_type = eP_FEATURES.MISSION; @@ -75,8 +75,8 @@ static has_data = function(key){ static save = function(){ var _save_copy = variable_clone(self); - struct_remove(save_copy, "system"); - struct_remove(save_copy, "p_data"); + struct_remove(_save_copy, "system"); + struct_remove(_save_copy, "p_data"); var _mems = clean_unit_array(members); _save_copy.members = []; for (var i=0;i= 20) { + stage_id = "exploring"; + timer = 999; + data.turns = 0; + scr_popup("Mechanicus Research", $"The Mechanicus Research team on planet {p_data.name()} has taken note of your Astartes and are now prepared to begin their research. Your marines are to stay on the planet until further notice.", "necron_cave", ""); + } + } else { + __mech_tomb_exploring(); + } +} + +static __mech_tomb_exploring = function() { data.turns++; var _battli = 0; var _roll1 = roll_dice_chapter(1, 100 + data.turns, "low"); @@ -962,16 +1039,6 @@ static __mech_tomb_per_turnSexploring = function() { } } -static __mech_tomb_per_turn = function() { - var _marines = collect_role_group("all", [system.name, planet, -1]); - if (array_length(_marines) >= 20) { - stage_id = "exploring"; - timer = 999; - data.turns = 0; - scr_popup("Mechanicus Research", $"The Mechanicus Research team on planet {p_data.name()} has taken note of your Astartes and are now prepared to begin their research. Your marines are to stay on the planet until further notice.", "necron_cave", ""); - } -} - static __mech_tomb_resolve = function() { var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); @@ -1047,6 +1114,10 @@ static __mech_mars_resolve = function() { } } +static __provide_garrison_feature_selected = function() { + if (data.reason == "importance") {} + draw_data.mission_description = $"The governor of {p_data.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"; +} static __provide_garrison_init = function() { if (stage_id != "preliminary") { @@ -1075,11 +1146,11 @@ static __garrison_mission_resolve = function() { p_data.garrisons.update(); if (p_data.current_owner != eFACTION.IMPERIUM || !p_data.garrisons.garrison_force) { p_data.add_disposition(-20); - scr_popup($"Agreed Garrison of {name()}", $"your agreed garrison of {name()} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)", "", ""); + scr_popup($"Agreed Garrison of {p_data.name()}", $"your agreed garrison of {p_data.name()} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)", "", ""); return; } - var _mission_string = $"The garrison on {name()} has finished the period of garrison support agreed with the planetary governor."; + var _mission_string = $"The garrison on {p_data.name()} has finished the period of garrison support agreed with the planetary governor."; var _result = p_data.garrisons.garrison_disposition_change(); if (!p_data.garrisons.garrison_leader) { p_data.garrisons.find_leader(); @@ -1115,7 +1186,18 @@ static __garrison_mission_resolve = function() { } } } - scr_popup($"Agreed Garrison of {name()} complete", _mission_string, "", ""); + scr_popup($"Agreed Garrison of {p_data.name()} complete", _mission_string, "", ""); +} + +static protect_raiders_feature_selected = function() { + draw_data.mission_description = $"The governor of {p_data.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."; + draw_data.help = "Set a squads to ambush"; + draw_data.button_text = "Send Squad"; + draw_data.button_tooltip = "milage may vary on playability of this mission progress at your own risk"; + button_function = function() { + var _dudes = collect_role_group("all", system.name); + select_squads(_dudes, "Select Squad for Ambush", 1) + }; } static __protect_raiders_battle_aftermath = function() { @@ -1298,7 +1380,7 @@ static inquisition_tomb_mission_start = function() { obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; obj_popup.replace_options([ {str1: "Continue", choice_func: necron_tomb_mission_sequence}, - {str1: "Return to the surface", choice_func: __popup_delete} + {str1: "Return to the surface", choice_func: __popup_delete } ]); obj_popup.image = "necron_tunnels_1"; obj_popup.text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; @@ -1650,9 +1732,9 @@ static __inquisition_tyranid_org_battle_aftermath = function(){ } static __hive_fleet_to_cult_init = function(){ - var xx = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; - var yy = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; - var fleet = create_enemy_fleet(xx, yy, eFACTION.TYRANIDS); + var draw_data.x1 = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; + var draw_data.y1 = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; + var fleet = create_enemy_fleet(draw_data.x1, draw_data.y1, eFACTION.TYRANIDS); fleet.sprite_index = spr_fleet_tyranid; fleet.image_speed = 0; @@ -1732,7 +1814,7 @@ static __inquisition_purge_on_purge = function(){ alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); var _popup_text = "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."); + scr_event_log("", $"Inquisition Mission Completed: The unruly Nobles of {p_data.name()} have been purged."); p_data.add_disposition(choose(1, 2, 3)); scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); break; @@ -1741,15 +1823,23 @@ static __inquisition_purge_on_purge = function(){ alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - var _popup_text = $"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."); + var _popup_text = $"Your marines scour the underhive of {p_data.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 {p_data.name()} have been cleansed by promethium."); p_data.add_disposition(choose(1, 2, 3)); scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); break; } } +static __join_communion_feature_selected = function(){ + draw_data.mission_description = $"The governor of {p_data.name()} has Invited a delegate of your forces to take part in ceremony."; + draw_data.help = "This mission is not yet completed" +} + +static __governor_purge_enemies_feature_selected = function(){ + draw_data.mission_description = $"The governor of {p_data.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"; } +} diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index cc20ce9d05..683f5291e8 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1430,7 +1430,7 @@ function PlanetData(_planet, _system) constructor { for (var i = 0; i < array_length(problems); i++) { var _problem = problems[i]; - if (problem_data.stage_id == "preliminary") { + if (_problem.stage_id == "preliminary") { var _mission_string = localize("{0} Audience", [_problem.data.applicant]); problem_data.problem = _problem; array_push(planet_displays, [_mission_string, _problem]); diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 35f56efdd1..73c85c2294 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -967,6 +967,11 @@ enum eMISSION_SELECT_TYPE { } function group_selection(group, selection_data = {}) { + if (instance_exists(obj_star_select)){ + if (is_struct(obj_star_select, "feature")){ + obj_star_select.feature.destroy = true; + } + } try { var _unit, s, unit_location; obj_controller.selection_data = selection_data; diff --git a/scripts/scr_draw_planet_features/scr_draw_planet_features.gml b/scripts/scr_draw_planet_features/scr_draw_planet_features.gml index 402988c7a6..1391878dda 100644 --- a/scripts/scr_draw_planet_features/scr_draw_planet_features.gml +++ b/scripts/scr_draw_planet_features/scr_draw_planet_features.gml @@ -72,7 +72,6 @@ function FeatureSelected(_feature, _system, _planet) constructor { obj_controller.unit_profile = false; obj_controller.view_squad = false; group_selection(techs, {purpose: "Forge Assignment", purpose_code: "forge_assignment", number: worker_capacity, system: planet_data.system, feature: feature, planet: planet_data.planet, selections: []}); - destroy = true; } //TODO move over to using the draw button object ot streamline this var next_position = [ @@ -216,81 +215,12 @@ function FeatureSelected(_feature, _system, _planet) constructor { } 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"; - - 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, 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, 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, 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; + feature.draw_data = { + x1 :xx, + y1 : yy, + w : area_width, } - 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; - } - - 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; + feature.planet_draw_feature_selected(); } if (generic) { draw_text_ext_transformed(xx + (area_width / 2), yy + 5, title, -1, area_width - 20, 2, 2, 0); diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index f9dba8a486..f8a625bdcf 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -618,7 +618,7 @@ function mission_inquistion_purge() { var text = "The Inquisition is trusting you with a special mission."; var _purge_type = eDROP_TYPE.PURGEFIRE; if (mission_flavour < 3){ - eDROP_TYPE.PURGESELECTIVE; + _purge_type = eDROP_TYPE.PURGESELECTIVE; } var _p_data = _star.get_planet_data(planet); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 6cf677b0ea..28a3e3c8e8 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -91,7 +91,7 @@ function scr_new_governor_mission(planet, problem = "") { if (planet_type == "Death") { problem = choose("hunt_beast", "provide_garrison"); } else if (planet_type == "Hive") { - problem = choose("show_of_power", "provide_garrison", "purge_enemies", "raid_black_market"); + problem = choose("show_of_power", "provide_garrison", "governor_purge_enemies", "raid_black_market"); } else if (planet_type == "Temperate") { problem = choose("provide_garrison", "train_forces", "join_parade"); } else if (planet_type == "Shrine") { @@ -118,7 +118,7 @@ function scr_new_governor_mission(planet, problem = "") { exit; } mission_data.reason = choose("stability", "importance"); - } else if (problem == "purge_enemies") { + } else if (problem == "governor_purge_enemies") { var enemy = 0; if (planets > 1) { for (var i = 1; i <= planets; i++) { From a6206adac2c1987a5c4ca0bd3d6ebbd9e22060d0 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 17:10:30 +0100 Subject: [PATCH 056/118] clean arrays of marines throughout --- objects/obj_star/Create_0.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 2 +- scripts/scr_UnitGroup/scr_UnitGroup.gml | 4 ++-- scripts/scr_company_order/scr_company_order.gml | 2 +- scripts/scr_company_struct/scr_company_struct.gml | 12 ++++-------- .../scr_diplomacy_helpers/scr_diplomacy_helpers.gml | 2 +- scripts/scr_garrison/scr_garrison.gml | 2 +- scripts/scr_marine_struct/scr_marine_struct.gml | 2 +- scripts/scr_squads/scr_squads.gml | 5 +++++ scripts/scr_start_load/scr_start_load.gml | 2 +- 10 files changed, 18 insertions(+), 17 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index c7f8da0738..fa3e92c0e3 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -153,7 +153,7 @@ function has_garrison() { if (_operative.job != "garrison") { continue; } - if (array_length(fetch_squad(_operative.reference).members) > 0) { + if (array_length(fetch_squad(_operative.reference).get_members()) > 0) { return true; } } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 257518ba19..399bc4ba40 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1223,7 +1223,7 @@ static __protect_raiders_battle_aftermath = function() { static __protect_raider_squad_selected = function() { data.squad = data.squads[0]; var _squad = data.squad; - var _squad_units = _squad.members; + var _squad_units = _squad.get_members(); var _squad_wisdom = stat_average(_squad_units, "wisdom"); var _squad_dex = stat_average(_squad_units, "dexterity"); var _tester = global.character_tester; diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 73c85c2294..9ab59c7488 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -107,7 +107,7 @@ function UnitGroup(units = []) constructor { var _squad = fetch_squad(_squads[s]); var _squad_units = _replica.get_from({squad: _squads[s]}, true, true); - if (_squad_units.number() < array_length(_squad.members)) { + if (_squad_units.number() < array_length(_squad.get_members())) { _squad_units.move_to_company(company, false, false); continue; } else { @@ -503,7 +503,7 @@ function UnitGroup(units = []) constructor { continue; } var _squad = fetch_squad(_unit.squad); - var _members_count = array_length(_squad.members); + var _members_count = array_length(_squad.get_members()); var _conditions = { squad: _unit.squad, max_wanted: _members_count, diff --git a/scripts/scr_company_order/scr_company_order.gml b/scripts/scr_company_order/scr_company_order.gml index 3db891da0c..e6a711840b 100644 --- a/scripts/scr_company_order/scr_company_order.gml +++ b/scripts/scr_company_order/scr_company_order.gml @@ -76,7 +76,7 @@ function scr_company_order(company) { for (var i = 0; i < array_length(_squad_ids); i++) { var _squad = fetch_squad(_squad_ids[i]); if (_squad.base_company != co) { - if (!bool(array_length(_squad.members))) { + if (!bool(array_length(_squad.get_members()))) { array_push(_empty_squads, _squad); } continue; diff --git a/scripts/scr_company_struct/scr_company_struct.gml b/scripts/scr_company_struct/scr_company_struct.gml index 0bde49fc2a..ae878a91b8 100644 --- a/scripts/scr_company_struct/scr_company_struct.gml +++ b/scripts/scr_company_struct/scr_company_struct.gml @@ -53,7 +53,7 @@ function CompanyStruct(comp) constructor { continue; } _search_squad.update_fulfilment(); - if (bool(array_length(_search_squad.members))) { + if (bool(array_length(_search_squad.get_members()))) { array_push(company_squads, _search_squad); } } @@ -81,7 +81,7 @@ function CompanyStruct(comp) constructor { var _search_squad = _unit.get_squad(); _search_squad.update_fulfilment(); - if (array_length(_search_squad.members) > 0) { + if (array_length(_search_squad.get_members()) > 0) { array_push(company_squads, _search_squad); array_push(_squad_ids, _unit.squad); } @@ -222,7 +222,7 @@ function CompanyStruct(comp) constructor { if (!is_struct(_cur_squad)) { return; } - var _member_count = array_length(_cur_squad.members); + var _member_count = array_length(_cur_squad.get_members()); var _reset_surface = false; var _member = _member_count > 0 ? _cur_squad.fetch_member(0) : undefined; var _first_uid = is_struct(_member) ? _member.uid : undefined; @@ -235,11 +235,7 @@ function CompanyStruct(comp) constructor { for (var i = 0; i < _member_count; i++) { _member = _cur_squad.fetch_member(i); if (_reset_surface || i >= array_length(squad_draw_surfaces)) { - if (is_struct(_member)) { - array_push(squad_draw_surfaces, [_member.uid, _member.draw_unit_image()]); - } else { - array_push(squad_draw_surfaces, [undefined, undefined]); - } + array_push(squad_draw_surfaces, [_member.uid, _member.draw_unit_image()]); } var _mem_draw_data = squad_draw_surfaces[i]; if (!is_array(_mem_draw_data) || !is_struct(_member)) { diff --git a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml index 6e2d8155f8..7b8a52319a 100644 --- a/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml +++ b/scripts/scr_diplomacy_helpers/scr_diplomacy_helpers.gml @@ -328,7 +328,7 @@ function scr_emmisary_diplomacy_routes() { var _squad_ids = get_squad_ids(); for (var i = 0; i < array_length(_squad_ids); i++) { kill_squad = fetch_squad(_squad_ids[i]); - if (kill_squad.type == "tactical_squad" && array_length(kill_squad.members) > 4) { + if (kill_squad.type == "tactical_squad" && array_length(kill_squad.get_members()) > 4) { var chapter_master = fetch_unit([0, 1]); chapter_master.add_trait("blood_for_blood"); chapter_master.edit_corruption(20); diff --git a/scripts/scr_garrison/scr_garrison.gml b/scripts/scr_garrison/scr_garrison.gml index ab7805f1d3..453030a3ff 100644 --- a/scripts/scr_garrison/scr_garrison.gml +++ b/scripts/scr_garrison/scr_garrison.gml @@ -47,7 +47,7 @@ function GarrisonForce(system, planet, type = "garrison") constructor { static evaluate_operative_squad = function(operative_squad) { //marine garrison on planet var _squad = fetch_squad(operative_squad.reference); - if (array_length(_squad.members) > 0) { + if (array_length(_squad.get_members()) > 0) { array_push(garrison_squads, _squad); total_garrison += array_length(_squad.members); garrison_force = true; diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index a5ca5632f5..eded65efd3 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -1841,7 +1841,7 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (squad != "none") { var _squad = get_squad(); - for (var r = 0; r < array_length(_squad.members); r++) { + for (var r = 0; r < array_length(_squad.get_members()); r++) { squad_member = _squad.members[r]; if (squad_member.uid == uid) { array_delete(_squad.members, r, 1); diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index 157e00bb1f..e09d2405ff 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -665,8 +665,13 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { return data_pack; }; + static clean_members = function(){ + members = clean_unit_array(members); + } + static get_members = function(as_UnitGroup = false) { var mems = []; + clean_members(); for (var i = 0; i < array_length(members); i++) { array_push(mems, fetch_member(i)); } diff --git a/scripts/scr_start_load/scr_start_load.gml b/scripts/scr_start_load/scr_start_load.gml index ed2d67ced5..7a31f65c53 100644 --- a/scripts/scr_start_load/scr_start_load.gml +++ b/scripts/scr_start_load/scr_start_load.gml @@ -108,7 +108,7 @@ function scr_start_load(fleet, load_from_star, load_options) { var company_squad_dist = total_distribute_squads[_comp - 2]; for (var squad = 0; squad < array_length(company_squad_dist); squad++) { var _squad = company_squad_dist[squad]; - var _members = _squad.members; + var _members = _squad.get_members(); for (var squad_member = 0; squad_member < array_length(_members); squad_member++) { var _marine = _members[squad_member]; var marine_size = _marine.get_unit_size(); From e6a9e9338a05d2e2aa8c85b43a1ef1cc9fdef417 Mon Sep 17 00:00:00 2001 From: Nelsonh <81228864+OH296@users.noreply.github.com> Date: Sun, 27 Sep 2026 17:21:29 +0100 Subject: [PATCH 057/118] Update scripts/scr_marine_struct/scr_marine_struct.gml Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- scripts/scr_marine_struct/scr_marine_struct.gml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/scr_marine_struct/scr_marine_struct.gml b/scripts/scr_marine_struct/scr_marine_struct.gml index eded65efd3..f7f16e6ae7 100644 --- a/scripts/scr_marine_struct/scr_marine_struct.gml +++ b/scripts/scr_marine_struct/scr_marine_struct.gml @@ -1841,7 +1841,8 @@ function TTRPG_stats(faction, comp, mar, class = "marine", other_spawn_data = {} if (squad != "none") { var _squad = get_squad(); - for (var r = 0; r < array_length(_squad.get_members()); r++) { + var _member_count = array_length(_squad.get_members()); + for (var r = 0; r < _member_count; r++) { squad_member = _squad.members[r]; if (squad_member.uid == uid) { array_delete(_squad.members, r, 1); From bb151f96bdf650004607247f08a6fce9aab43129 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 17:22:31 +0100 Subject: [PATCH 058/118] review --- scripts/PlanetProblem/PlanetProblem.gml | 11 ++++++----- .../scr_mission_functions/scr_mission_functions.gml | 1 + scripts/scr_squads/scr_squads.gml | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 399bc4ba40..4105820c9b 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -257,6 +257,7 @@ static on_unit_selection = function(){ instance_deactivate_object(obj_star); } +//TODO in the future this should be calcuated once on feature selection and then draw each turn static planet_draw_feature_selected = function(){ if (!struct_exists(self, "draw_data")){ exit; @@ -272,7 +273,7 @@ static planet_draw_feature_selected = function(){ } static __feature_selected_draw = function(){ - draw_text_transformed(draw_data.x1 + (draw_data.w / 2), draw_data.y1 + 5, mission_name_key(feature.p_id), 2, 2, 0); + draw_text_transformed(draw_data.x1 + (draw_data.w / 2), draw_data.y1 + 5, description(p_id), 2, 2, 0); draw_set_halign(fa_left); draw_set_color(c_gray); draw_text_ext(draw_data.x1 + 10, draw_data.y1 + 40, draw_data.mission_description, -1, draw_data.w - 20); @@ -345,11 +346,11 @@ __init(); static select_units = function(select_from, purpose_string, number, selections = []){ - group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: 1, system , feature: self, planet: planet, selections: []}); + group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: 1, system , feature: self, planet, selections}); } static select_squads = function(select_from, purpose_string, number, selections = []){ - group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: 1, system , feature: self, planet: planet, selections: [], select_type: eMISSION_SELECT_TYPE.SQUADS}); + group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: 1, system , feature: self, planet, selections, select_type: eMISSION_SELECT_TYPE.SQUADS}); } // by default mission battles do not reduce the fortification level or enemy power on a planet static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, enemy_data = undefined){ @@ -1115,7 +1116,7 @@ static __mech_mars_resolve = function() { } static __provide_garrison_feature_selected = function() { - if (data.reason == "importance") {} + //TODO : complete logic if (data.reason == "importance") {} draw_data.mission_description = $"The governor of {p_data.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"; } @@ -1837,7 +1838,7 @@ static __join_communion_feature_selected = function(){ } static __governor_purge_enemies_feature_selected = function(){ - draw_data.mission_description = $"The governor of {p_data.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"; + draw_data.mission_description = $"The governor of {p_data.name()} has expressed his distaste of the neighboring governance of {system.name} {data.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"; } } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 28a3e3c8e8..fc29416758 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -39,6 +39,7 @@ global.planet_problem_keys = [ "inquisition_tomb", "ethereal", "demon_world", + "governor_purge_enemies" ]; function mission_name_key(mission) { diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index e09d2405ff..aa7cfcae0b 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -667,7 +667,7 @@ function UnitSquad(squad_type = undefined, company = 0) constructor { static clean_members = function(){ members = clean_unit_array(members); - } + }; static get_members = function(as_UnitGroup = false) { var mems = []; From 34a2e6351c5dae4cc9d50939f643d829a10cb714 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 17:30:45 +0100 Subject: [PATCH 059/118] better docs --- scripts/PlanetProblem/PlanetProblem.gml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 4105820c9b..84e321b6f6 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -18,7 +18,15 @@ "on_purge" - at the top of PlanetData.purge() passes in {action_type, action_score} as purge_data overrides standdard purge popups "init" - runs imediatly after problem is created often used to poopulate initial popupop ir stack popup for turn end - "accept" is an edge case currently reserved for binding to button clicks in popups + "accept" - is an edge case currently reserved for binding to button clicks in popups + + "planet_draw_feature_selected" - runs in a FeatureSelected instance it allows a player to select the mission from the star_Select/planet screen and view data about it + - each `____feature_selected` function fills the draw_data struct so that __feature_selected_draw can run + - by attatching a fuction to draw_data.button_function you can create windws to select specific marines and squads for isssions + - do this by using select_units and select_squads which are binds of group_selection + - to handle the selectedd marines create `___unit_select` and ___squad_selected` functions + - selected marines will auutooatically get added to the members array creating a direct link to marines participating in a mission + - other than these entry points and any other later defined poisitions mission specific code should not run outsiide of the PlanetProblem container From f81e61178efa67b5ac5c76cc22c1a5026ac1b303 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 17:44:15 +0100 Subject: [PATCH 060/118] reviews --- scripts/PlanetProblem/PlanetProblem.gml | 118 ++++++++++++------------ scripts/scr_UnitGroup/scr_UnitGroup.gml | 2 +- 2 files changed, 60 insertions(+), 60 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 84e321b6f6..c11ec1e213 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -2,33 +2,33 @@ //missions for the most part can only run from predefined points in the code // to run from each of these points easch mission must have a registered function these functions are then called implicitly //each function follows the format `___` -//each one can have extentions written to account for different stage_id's by insteadd usig the syntax +//each one can have extensions written to account for different stage_id's by instead usig the syntax //`___S` if stage id is "" `___` will be used /* the current entry points for the code are "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn - "resolve" - runs when the mission timer hits 0 often contains the failiure conditions for the mission + "resolve" - runs when the mission timer hits 0 often contains the failure conditions for the mission - both of the above runn via basic_turn_end -> PlanetData.problem_count_down -> scr_enemy_ai_d - "setup_battle" - runs when the player intiates a battle via drop select window on a planet with a problem on - "on_enemy_casulties" - runs during combat after player iflicts casualties to log data or inject mission specific combat logs + "setup_battle" - runs when the player initiates a battle via drop select window on a planet with a problem on + "on_enemy_casulties" - runs during combat after player inflicts casualties to log data or inject mission specific combat logs "battle_final_message" - runs during combat to tally data and display a final log to the combat log "battle_aftermath" - runs post combat during obj_ncombat alarm_7 "squad_selected" - runs after selecting a squad inn the squad select window (scr_manage_task_selector) "unit_select" - runs after selecting units in the unit selection screen (scr_manage_task_selector) - "on_purge" - at the top of PlanetData.purge() passes in {action_type, action_score} as purge_data overrides standdard purge popups - "init" - runs imediatly after problem is created often used to poopulate initial popupop ir stack popup for turn end + "on_purge" - at the top of PlanetData.purge() passes in {action_type, action_score} as purge_data overrides standard purge popups + "init" - runs immediately after problem is created often used to populate initial popup or stack popup for turn end "accept" - is an edge case currently reserved for binding to button clicks in popups "planet_draw_feature_selected" - runs in a FeatureSelected instance it allows a player to select the mission from the star_Select/planet screen and view data about it - each `____feature_selected` function fills the draw_data struct so that __feature_selected_draw can run - - by attatching a fuction to draw_data.button_function you can create windws to select specific marines and squads for isssions + - by attaching a function to draw_data.button_function you can create windows to select specific marines and squads for missions - do this by using select_units and select_squads which are binds of group_selection - - to handle the selectedd marines create `___unit_select` and ___squad_selected` functions - - selected marines will auutooatically get added to the members array creating a direct link to marines participating in a mission + - to handle the selected marines create `___unit_select` and ___squad_selected` functions + - selected marines will automatically get added to the members array creating a direct link to marines participating in a mission -- other than these entry points and any other later defined poisitions mission specific code should not run outsiide of the PlanetProblem container +- other than these entry points and any other later defined positions mission specific code should not run outside of the PlanetProblem container - to set an entry point up simply register the function as a static e.g if i create static __inquisition_are_dicks_per_turn once a "inquisition_are_dicks" problem is registered on a planet via @@ -90,7 +90,7 @@ static save = function(){ for (var i=0;i 60) && (_roll <= 82)) { @@ -1569,8 +1557,8 @@ static __inquisition_tomb_battle_aftermath = function(){ } else if (defeat == 0) { obj_controller.combat = 0; var pip = instance_create(0, 0, obj_popup); - necron_tomb_mission_start(); - var _completed = advance_necron_tomb_mission(); + inquisition_tomb_mission_start(); + var _completed = advance_inquisition_tomb_mission(); with (pip) { if (_completed) { keyboard_clear(vk_enter); @@ -1612,7 +1600,7 @@ static __inquisition_tomb_battle_aftermath = function(){ } } -static advance_necron_tomb_mission = function() { +static advance_inquisition_tomb_mission = function() { data.mission_stage++; obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; @@ -1646,6 +1634,18 @@ static advance_necron_tomb_mission = function() { return false; } +static __inquisition_tomb_resolve = function() { + alter_disposition(eFACTION.INQUISITION, -8); + var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; + scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); + scr_event_log("red", $"Inquisition Mission Failed: Bombing run failed; the Necron Tomb on {p_data.name()} has become active."); + + p_data.add_forces(eFACTION.NECRONS, 4); + if (awake_tomb_world(p_data.features) == 0) { + awaken_tomb_world(p_data.features); + } +} + static __inquisition_demon_world_init = function(){ var _text = $"The Inquisitor is trusting you with a special mission. The planet {p_data.name()} has been uncovered as a Demon World"; if (obj_controller.demanding) { @@ -1708,7 +1708,7 @@ static __inquisition_tyranid_org_setup_battle = function(){ obj_ncombat.reduce_power = false; } -static __inquisition_tyranid_on_enemy_casulties = function(){ +static __inquisition_tyranid_org_on_enemy_casulties = function(){ var _c_data = casualty_packet; if (array_contains(["Termagaunt", "Hormagaunt"], _c_data.weapon) && (_c_data.casulties > 0)) { data.captured_gaunt += casulties; @@ -1741,24 +1741,24 @@ static __inquisition_tyranid_org_battle_aftermath = function(){ } static __hive_fleet_to_cult_init = function(){ - var draw_data.x1 = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; - var draw_data.y1 = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; - var fleet = create_enemy_fleet(draw_data.x1, draw_data.y1, eFACTION.TYRANIDS); - fleet.sprite_index = spr_fleet_tyranid; - fleet.image_speed = 0; + var _x1 = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; + var _y1 = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; + var _fleet = create_enemy_fleet(_x1, _y1, eFACTION.TYRANIDS); + _fleet.sprite_index = spr_fleet_tyranid; + _fleet.image_speed = 0; - fleet.capital_number = choose(7, 8, 9); - fleet.frigate_number = round(random_range(6, 12)); - fleet.escort_number = round(random_range(12, 27)); + _fleet.capital_number = choose(7, 8, 9); + _fleet.frigate_number = round(random_range(6, 12)); + _fleet.escort_number = round(random_range(12, 27)); - fleet.image_index = floor(fleet.capital_number + (fleet.frigate_number / 2) + (fleet.escort_number / 4)); - fleet.image_alpha = 0; + _fleet.image_index = floor(_fleet.capital_number + (_fleet.frigate_number / 2) + (_fleet.escort_number / 4)); + _fleet.image_alpha = 0; - fleet.action_x = x; - fleet.action_y = y; + _fleet.action_x = x; + _fleet.action_y = y; - fleet.action_eta = timer; - fleet.action = "move"; + _fleet.action_eta = timer; + _fleet.action = "move"; } static __hive_fleet_to_cult_per_turn = function(){ diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index 9ab59c7488..ef86aa86ac 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -968,7 +968,7 @@ enum eMISSION_SELECT_TYPE { function group_selection(group, selection_data = {}) { if (instance_exists(obj_star_select)){ - if (is_struct(obj_star_select, "feature")){ + if (is_struct(obj_star_select.feature)){ obj_star_select.feature.destroy = true; } } From ccb4b1c19dda9342127dc59aaebdde3b794bb160 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Sun, 27 Sep 2026 17:56:22 +0100 Subject: [PATCH 061/118] more tweaks --- objects/obj_drop_select/Create_0.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 20 +++++++++---------- .../scr_inquisition_mission.gml | 5 +---- .../scr_mission_functions.gml | 4 ++-- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/objects/obj_drop_select/Create_0.gml b/objects/obj_drop_select/Create_0.gml index a15940ec53..54c153de0d 100644 --- a/objects/obj_drop_select/Create_0.gml +++ b/objects/obj_drop_select/Create_0.gml @@ -216,7 +216,7 @@ if (purge == 0) { spesh = true; } - if (_p_data.has_problem("iquisition_tyranid_org")) { + if (_p_data.has_problem("inquisition_tyranid_org")) { tyranids = 2; attacking = 9; } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index c11ec1e213..33459ea707 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -292,7 +292,7 @@ static __feature_selected_draw = function(){ } if (draw_data.button_text != "") { - var _button = draw_unit_buttons([draw_data.x1 + ((draw_data.w / 2) - (string_width(button_text) / 2)), draw_data.y1 + 40 + _text_body_height + 10], button_text); + var _button = draw_unit_buttons([draw_data.x1 + ((draw_data.w / 2) - (string_width(draw_data.button_text) / 2)), draw_data.y1 + 40 + _text_body_height + 10], draw_data.button_text); if (draw_data.button_tooltip != "" && scr_hit(_button)) { tooltip_draw(draw_data.button_tooltip); } @@ -409,12 +409,12 @@ static __set_members_job_to_mission = function(){ } static __hunt_beast_feature_selected = function(){ - draw_data.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."; + draw_data.mission_description = $"The governor of {p_data.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."; draw_data.help = "This is a good opportunity to provide experience and training, having at least one marine with experience in such matters would be advisable"; draw_data.button_text = "Send Hunters"; - button_function = function() { + draw_data.button_function = function() { var _dudes = collect_role_group("all", system.name); - select_units(_dudes, ,"Beast Hunt", number: 3}); + select_units(_dudes, ,"Beast Hunt", number: 3); }; } @@ -864,7 +864,7 @@ static __hunt_fallen_per_turn = function() { ); } else { delete_mission = true; - var _tixt = "Your marines have scoured {p_data.name()} in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; + var _tixt = $"Your marines have scoured {p_data.name()} in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; scr_popup("Hunt the Fallen", _tixt, "fallen", ""); scr_event_log("", $"Mission Successful: No Fallen located upon {p_data.name()}"); } @@ -1711,7 +1711,7 @@ static __inquisition_tyranid_org_setup_battle = function(){ static __inquisition_tyranid_org_on_enemy_casulties = function(){ var _c_data = casualty_packet; if (array_contains(["Termagaunt", "Hormagaunt"], _c_data.weapon) && (_c_data.casulties > 0)) { - data.captured_gaunt += casulties; + data.captured_gaunt += _c_data.casulties; } } @@ -1719,8 +1719,8 @@ static __inquisition_tyranid_org_battle_final_message = function(){ if (obj_ncombat.defeat || data.captured_gaunt == 0) { exit; } - var _gaunts = string_plural_count("Gaunt organism", captured_gaunt); - _newline = $"{_gaunts} have been captured."; + var _gaunts = string_plural_count("Gaunt organism", data.captured_gaunt); + var _newline = $"{_gaunts} have been captured."; obj_ncombat.combat_log.push(_newline, eMSG_COLOR.YELLOW); } @@ -1754,8 +1754,8 @@ static __hive_fleet_to_cult_init = function(){ _fleet.image_index = floor(_fleet.capital_number + (_fleet.frigate_number / 2) + (_fleet.escort_number / 4)); _fleet.image_alpha = 0; - _fleet.action_x = x; - _fleet.action_y = y; + _fleet.action_x = system.x; + _fleet.action_y = system.y; _fleet.action_eta = timer; _fleet.action = "move"; diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index f8a625bdcf..0b3cdeb75c 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -115,7 +115,7 @@ function scr_inquisition_mission(event, forced_mission = eINQUISITION_MISSION.RA var _eta = scr_mission_eta(_star.x, _star.y, 1); _eta = min(max(_eta, 6), 50); - _star.get_planet_data(planet).new_problem("iquisition_tyranid_org", _eta); + _star.get_planet_data(planet).new_problem("inquisition_tyranid_org", _eta); break; case eINQUISITION_MISSION.ETHEREAL: mission_inquisition_ethereal(); @@ -166,9 +166,6 @@ function mission_inquisition_ethereal() { scr_popup("Inquisition Mission", text, "inquisition", $"ethereal|{string(_star.name)}|{string(planet)}|{string(_eta + 1)}|"); } -function mission_inquisition_tyranid_organism(worlds) { -} - function mission_inquisition_necron_world(tomb_worlds) { LOGGER.info("RE: Necron Tomb Bombing"); var _star = noone; diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index fc29416758..a7a9e5d318 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -34,7 +34,7 @@ global.planet_problem_keys = [ "inquisition_recon", "cleanse", "purge", - "iquisition_tyranid_org", + "inquisition_tyranid_org", "artifact_loan", "inquisition_tomb", "ethereal", @@ -68,7 +68,7 @@ function mission_name_key(mission) { "inquisition_recon": "Recon Mission for Inquisitor", "cleanse": "Cleanse Planet for Inquisitor", "purge": "Purge Leadership for Inquisitor", - "iquisition_tyranid_org": "Capture Tyranid for Inquisitor", + "inquisition_tyranid_org": "Capture Tyranid for Inquisitor", // "bomb" : "Bombard World for Inquisitor", "artifact_loan": "Safeguard Artifact for the Inquisition", "inquisition_tomb": "Bomb Necron Tomb for Inquisitor", From 76e69f2c7e04115f4c1e64ea95dbd7ad5b79bea2 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 12:44:06 +0100 Subject: [PATCH 062/118] port more logic over to missin init sequence --- scripts/PlanetProblem/PlanetProblem.gml | 185 ++++++++++++------ scripts/scr_PlanetData/scr_PlanetData.gml | 27 ++- scripts/scr_cheatcode/scr_cheatcode.gml | 26 +-- .../scr_mission_functions.gml | 56 ++---- .../scr_unit_quick_find_pane.gml | 25 +-- 5 files changed, 166 insertions(+), 153 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 33459ea707..649530ba47 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -7,7 +7,7 @@ /* the current entry points for the code are "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn "resolve" - runs when the mission timer hits 0 often contains the failure conditions for the mission - - both of the above runn via basic_turn_end -> PlanetData.problem_count_down -> scr_enemy_ai_d + - both of the above run via basic_turn_end -> PlanetData.problem_count_down -> scr_enemy_ai_d "setup_battle" - runs when the player initiates a battle via drop select window on a planet with a problem on "on_enemy_casulties" - runs during combat after player inflicts casualties to log data or inject mission specific combat logs @@ -103,7 +103,9 @@ static load = function(data){ } static description = function(){ - return mission_name_key(p_id); + var _n = mission_name_key(p_id); + _n = _n == "" ? p_id : _n; + return _n; } static __increment_mission_completion = function() { @@ -257,15 +259,16 @@ static on_squad_selection = function(){ static on_unit_selection = function(){ var _func = find_func("unit_select"); if (!is_undefined(_func)){ - if (struct_exists(obj_controller.selection_data, "selections")){ - members = obj_controller.selection_data.selections; + var _selec_data = obj_controller.selection_data; + if (struct_exists(_selec_data, "selections")){ + members = _selec_data.selections; } __handle_triggered_mission_func(_func); } instance_deactivate_object(obj_star); } -//TODO in the future this should be calcuated once on feature selection and then draw each turn +//TODO in the future this should be calculated once on feature selection and then draw each turn static planet_draw_feature_selected = function(){ if (!struct_exists(self, "draw_data")){ exit; @@ -406,6 +409,11 @@ static __set_members_job_to_mission = function(){ }; _unit.unload(planet, system); } +}; + +static __hunt_beast_init = function(){ + stage_id = "preliminary"; + data.applicant = "Governor" } static __hunt_beast_feature_selected = function(){ @@ -414,9 +422,9 @@ static __hunt_beast_feature_selected = function(){ draw_data.button_text = "Send Hunters"; draw_data.button_function = function() { var _dudes = collect_role_group("all", system.name); - select_units(_dudes, ,"Beast Hunt", number: 3); + select_units(_dudes, "Beast Hunt", 3); }; -} +}; static __hunt_beast_unit_select = function() { @@ -424,84 +432,91 @@ static __hunt_beast_unit_select = function() { __set_members_job_to_mission(); var _numeral_name = p_data.name() stage_id = "active"; - var _mission_length = irandom_range(2, 5); - timer = _mission_length; + timer = irandom_range(2, 5);; var _gar_pop = instance_create(0, 0, obj_popup); //TODO some new MissonHelper 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."; + _gar_pop.text = $"The governor of {_numeral_name} Thanks you for the participation of your elite warriors in your execution of such a menial task."; _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.", p_data.system.name); + scr_event_log("", $"Beast hunters deployed to {_numeral_name} for {timer} months.", p_data.system.name); obj_controller.close_popups = false; } } static __hunt_beast_resolve = function() { - var _man_conditions = { - "job": "hunt_beast", - "max": 3, - }; - var _hunters = collect_role_group("all", [system.name, planet, 0], false, _man_conditions); - if (stage_id == "active") { - var _mission_string = ""; - var _success = false; - var _tester = global.character_tester; - var _unit_pass; - var _unit; - var _unit_report_string = ""; - var _deaths = 0; - var _successful_hunters = []; - - if (!array_length(_hunters)) { - return; + if (stage_id == "preliminary"){ + delete_mission = true; + exit; + } + var _hunters = clean_unit_array(members); + if (array_length(_hunters) == 0){ + var _man_conditions = { + "job": "hunt_beast", + "max": 3, + }; + _hunters = collect_role_group("all", [system.name, planet, 0], false, _man_conditions); + if (array_length(_hunters) == 0){ + delete_mission = true; + exit; } + } - for (var i = 0; i < array_length(_hunters); i++) { - _unit = _hunters[i]; - _unit_pass = _tester.standard_test(_unit, "weapon_skill", 10, ["beast"]); - if (_unit_pass[0]) { - if (!_success) { - _success = true; - } - _unit_report_string += _unit.add_trait("beast_slayer", true, true); - array_push(_successful_hunters, _unit); - } else { - var _tough_check = _tester.standard_test(_unit, "constitution", _unit.luck); - if (!_tough_check[0]) { - if (_tough_check[1] < -10) { - _unit_report_string += $"{_unit.name_role()} Was mauled to death\n"; - _unit.kill(true, false); - _deaths++; + var _mission_string = ""; + var _success = false; + var _tester = global.character_tester; + var _unit_report_string = ""; + var _deaths = 0; + var _successful_hunters = []; + + if (!array_length(_hunters)) { + return; + } + + for (var i = 0; i < array_length(_hunters); i++) { + var _unit = _hunters[i]; + var _unit_pass = _tester.standard_test(_unit, "weapon_skill", 10, ["beast"]); + if (_unit_pass[0]) { + if (!_success) { + _success = true; + } + _unit_report_string += _unit.add_trait("beast_slayer", true, true); + array_push(_successful_hunters, _unit); + } else { + var _tough_check = _tester.standard_test(_unit, "constitution", _unit.luck); + if (!_tough_check[0]) { + if (_tough_check[1] < -10) { + _unit_report_string += $"{_unit.name_role()} Was mauled to death\n"; + _unit.kill(true, false); + _deaths++; + } else { + if (irandom(30) < _unit.luck) { + _unit.add_or_sub_health(-100); + _unit_report_string += $"{_unit.name_role()} Was injured (health - 100)\n"; } else { - if (irandom(100) < _unit.luck) { - _unit.add_or_sub_health(-100); - _unit_report_string += $"{_unit.name_role()} Was injured (health - 100)\n"; - } else { - _unit.add_or_sub_health(-250); - _unit_report_string += $"{_unit.name_role()} Was Badly injured, it is unknown if he will recover (health - 250)\n"; - } + _unit.add_or_sub_health(-250); + _unit_report_string += $"{_unit.name_role()} Was Badly injured, it is unknown if he will recover (health - 250)\n"; } } } - _unit.job = "none"; } + _unit.job = "none"; + } - 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}"; + 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 += $"Unfortunately {_deaths} of your marines died."; } - - scr_popup($"Beast Hunt on {p_data.name()}", _mission_string, "", ""); + _mission_string += $"\n{_unit_report_string}"; + } else { + _mission_string = $"The mission was a failure. The governor is disappointed and the legend of your chapter has undoubtedly been diminished"; + _mission_string += $"\n{_unit_report_string}"; } + + scr_popup($"Beast Hunt on {p_data.name()}", _mission_string, "", ""); for (var i = 0; i < array_length(_hunters); i++) { _hunters[i].job = "none"; } @@ -1110,12 +1125,22 @@ static __mech_mars_resolve = function() { } } +static __provide_garrison_init = function(){ + if (system.get_garrison(planet).garrison_force) { + delete_mission = true; + exit; + } + stage_id = "preliminary"; + data.applicant = "Governor" + data.reason = choose("stability", "importance"); +} + static __provide_garrison_feature_selected = function() { //TODO : complete logic if (data.reason == "importance") {} draw_data.mission_description = $"The governor of {p_data.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"; } -static __provide_garrison_init = function() { +static provide_garrison_on_garrison = function() { if (stage_id != "preliminary") { exit; } @@ -1186,6 +1211,11 @@ static __provide_garrison_resolve = function() { scr_popup($"Agreed Garrison of {p_data.name()} complete", _mission_string, "", ""); } +static __protect_raiders_init = function(){ + stage_id = "preliminary"; + data.applicant = "Governor" +} + static __protect_raiders_feature_selected = function() { draw_data.mission_description = $"The governor of {p_data.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."; draw_data.help = "Set a squads to ambush"; @@ -1845,6 +1875,33 @@ static __join_communion_feature_selected = function(){ draw_data.help = "This mission is not yet completed" } +static __governor_purge_enemies_init = function(){ + if (system.planets < 2){ + delete_mission = true; + exit; + } + var _planet = planet; + var _enemy = 0; + with (system){ + for (var i = 1; i <= planets; i++) { + if (i == _planet) { + continue; + } + if (p_owner[i] == eFACTION.IMPERIUM) { + enemy = i; + break; + } + } + } + if (_enemy == 0){ + delete_mission = true; + exit; + } + data.enemy = _enemy; + stage_id = "preliminary"; + data.applicant = "Governor"; +} + static __governor_purge_enemies_feature_selected = function(){ draw_data.mission_description = $"The governor of {p_data.name()} has expressed his distaste of the neighboring governance of {system.name} {data.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"; } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 683f5291e8..9cc1e1c889 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -809,6 +809,31 @@ function PlanetData(_planet, _system) constructor { } } + static problems_to_mission_log = function(){ + var _logs = []; + for (var p = 0; p < array_length(problems); p++) { + var _problem = problems[p]; + + if (_problem.stage_id == "preliminary") { + continue; + } + var _mission_explain = _problem.description(); + var _data = { + system: name, + mission: _mission_explain, + time: _problem.timer, + problem : _problem, + }; + + _data.click_left = method(_data, function() { + set_map_pan_to_loc(problem.system); + }); + + array_push(_logs, _data); + } + return _logs; + } + static name = function() { return planet_numeral_name(planet, system); }; @@ -1548,7 +1573,7 @@ function PlanetData(_planet, _system) constructor { //if there was an outstanding mission to provide the given garrison var _garrison_request = find_problem("provide_garrison"); if (is_struct(_garrison_request)) { - _garrison_request.provide_garrison_init(); + _garrison_request.provide_garrison_on_garrison(); } instance_destroy(obj_star_select); }; diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 73981e988a..b13c26d90a 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -159,24 +159,12 @@ function scr_cheatcode(argument0) { case "planet": scr_inquisition_mission(eEVENT.INQUISITION_PLANET); break; - case "inquisition_spyrer": - scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.SPYRER); - break; case "artifact": scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.ARTIFACT); break; case "inquisitor": scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.INQUISITOR); break; - case "purge": - scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.PURGE); - break; - case "tomb_world": - scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.TOMB_WORLD); - break; - case "tyranid_organism": - scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.TYRANID_ORGANISM); - break; case "demon": scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.DEMON_WORLD); break; @@ -496,22 +484,11 @@ function draw_planet_debug_problems() { if (mouse_button_clicked()) { var _p_data = obj_star_select.p_data; _p_data.new_problem(_keys[i], 3); + /* switch (_keys[i]) { case "inquisitor": mission_inquistion_hunt_inquisitor(target.id); break; - case "inquisition_tomb": - mission_inquisition_necron_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; case "succession": _p_data.init_war_of_succession(); break; @@ -519,6 +496,7 @@ function draw_planet_debug_problems() { scr_popup("error", "no specific debug action created please consider helping to make one", ""); break; } + */ } } } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index a7a9e5d318..eb34b00b50 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -1,5 +1,3 @@ -function MissionHandler(planet, system) : PlanetData(planet, system) constructor {} - function location_out_of_player_control(unit_loc) { static _locs = [ "Terra", @@ -78,7 +76,7 @@ function mission_name_key(mission) { if (struct_exists(mission_key, mission)) { return mission_key[$ mission]; } else { - return "none"; + return ""; } } @@ -87,25 +85,25 @@ function scr_new_governor_mission(planet, problem = "") { if (p_owner[planet] != eFACTION.IMPERIUM) { exit; } - var planet_type = p_type[planet]; + var _planet_type = p_type[planet]; if (problem == "") { - if (planet_type == "Death") { + if (_planet_type == "Death") { problem = choose("hunt_beast", "provide_garrison"); - } else if (planet_type == "Hive") { + } else if (_planet_type == "Hive") { problem = choose("show_of_power", "provide_garrison", "governor_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"); } } @@ -114,29 +112,6 @@ function scr_new_governor_mission(planet, problem = "") { applicant: "Governor", }; if (problem != "") { - if (problem == "provide_garrison") { - if (get_garrison(planet).garrison_force) { - exit; - } - mission_data.reason = choose("stability", "importance"); - } else if (problem == "governor_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; - break; - } - } - } - mission_data.target = enemy; - if (!enemy) { - exit; - } - } var _p_data = get_planet_data(planet); _p_data.new_problem(problem, 20 + irandom(20),mission_data); } @@ -153,16 +128,15 @@ function init_marine_acting_strange() { if (!is_struct(unit)) { exit; } - var role = unit.role(); - var text = unit.name_role(); + var _text = unit.name_role(); var company_text = scr_convert_company_to_string(unit.company); 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); + _text += " is behaving strangely."; + scr_alert("color", "lol", _text, 0, 0); + scr_event_log("color", _text); } /// @self Asset.GMObject.obj_popup diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index 96aa071c6a..b182f6caad 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -264,29 +264,8 @@ function UnitQuickFindPanel() constructor { with (obj_star) { for (var i = 1; i <= planets; i++) { var problems = p_problem[i]; - for (var p = 0; p < array_length(problems); p++) { - var _problem = problems[p]; - if (_problem.stage_id == "preliminary") { - continue; - } - var mission_explain = mission_name_key(problems[p]); - if (mission_explain != "none") { - var _data = { - system: name, - mission: mission_explain, - time: _problem.timer, - planet: i, - system_id: id, - problem : _problem, - }; - - _data.click_left = method(_data, function() { - set_map_pan_to_loc(system_id); - }); - - array_push(temp_log, _data); - } - } + var _p_data = get_planet_data(i); + temp_log = array_concat(temp_log, _p_data.problems_to_mission_log()); } } with (obj_en_fleet) { From f85592bd999377e4914656579b5f242525a15a5f Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 13:00:24 +0100 Subject: [PATCH 063/118] now testing --- scripts/PlanetProblem/PlanetProblem.gml | 32 ++++++++---- scripts/scr_PlanetData/scr_PlanetData.gml | 63 +++++++++++------------ 2 files changed, 52 insertions(+), 43 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 649530ba47..5aa58d4c9e 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -108,6 +108,10 @@ static description = function(){ return _n; } +static view_on_planet_screen = function(){ + return (stage_id == "preliminary") && (has_data("applicant")); +} + static __increment_mission_completion = function() { if (!struct_exists(data, "completion")) { data.completion = 0; @@ -277,6 +281,7 @@ static planet_draw_feature_selected = function(){ draw_data.button_text = ""; draw_data.button_function = noone; draw_data.help = ""; + draw_data.button_tooltip = ""; var _func = find_func("feature_selected"); __handle_triggered_mission_func(_func); __feature_selected_draw(); @@ -916,11 +921,11 @@ function __hunt_fallen_battle_aftermath() { } delete_mission = true; var _tixt = "The Fallen on " + p_data.name(); - scr_event_log("", $"Mission Succesful: {_tixt} have been captured or purged."); + scr_event_log("", $"Mission Successful: {_tixt} have been captured or purged."); _tixt += $" have been captured or purged. They shall be brought to the Chapter {obj_ini.player_role_data[eROLE.CHAPLAIN].role}s posthaste, in order to account for their sins. "; var _tex_options = [ "Suffering is the beginning to penance.", - "Their screams shall be the harbringer of their contrition.", + "Their screams shall be the harbinger of their contrition.", "The shame they inflicted upon us shall be written in their flesh.", ]; _tixt += _tex_options[choose(0, 0, 1, 2)]; @@ -1038,7 +1043,7 @@ static __mech_tomb_exploring = function() { var _last_artifact = scr_add_artifact("random", "", 0); _text = $"The Mechanicus Research team on planet {p_data.name()} have completed their work without any major setbacks. Pleased with your astartes' work, they have granted your Chapter an artifact, to be used as you see fit."; scr_event_log("", $"Mechanicus Mission Completed: The Mechanicus research team on {p_data.name()} have completed their work."); - scr_event_log("", "Artifact gifted from Mechanicus."); + scr_event_log("", "Artefact gifted from Mechanicus."); } _text += "\n" + add_disposition(eFACTION.MECHANICUS, 1); scr_popup("Mechanicus Mission Completed", _text, "mechanicus", ""); @@ -1072,11 +1077,11 @@ static __mech_tomb_battle_aftermath = function() { awaken_tomb_world(battle_object.p_feature[battle_id]); _disp_change = alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]]); scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust. To make matters worse the Necron Tomb has fully awakened- countless numbers of the souless machines are now pouring out of the tomb. The Adeptus Mechanicus are furious with your chapter. {_disp_change}", "necron_army", ""); - scr_alert("", "inqi", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); + scr_alert("", "inquisition", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); scr_event_log("", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb"); } - scr_event_log("", "Mechanicus Mission Failed: Necron Tomb Research Party and present astartes have been killed."); + scr_event_log("", "Mechanicus Mission Failed: Necron Tomb Research Party and present Astartes have been killed."); } } @@ -1177,6 +1182,7 @@ static __provide_garrison_resolve = function() { if (!p_data.garrisons.garrison_leader) { p_data.garrisons.find_leader(); } + var _leader = garrisons.garrison_leader; var _effect = 0; if (_result == "none") { @@ -1191,20 +1197,20 @@ static __provide_garrison_resolve = function() { p_data.add_disposition(_effect); var _tester = global.character_tester; - var _widom_test = _tester.standard_test(garrisons.garrison_leader, "wisdom", 0, ["siege"]); + var _widom_test = _tester.standard_test(_leader, "wisdom", 0, ["siege"]); if (_widom_test[0]) { p_data.alter_fortification(1); - _mission_string += $"while stationed {garrisons.garrison_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications+1)."; + _mission_string += $"while stationed {_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications+1)."; } - //TODO just generall apply this each turn with a garrison to see if a cult is found + //TODO just generally apply this each turn with a garrison to see if a cult is found if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { var _cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; if (_cult.hiding) { - _widom_test = _tester.standard_test(garrisons.garrison_leader, "wisdom", 0, ["tyranids"]); + _widom_test = _tester.standard_test(_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."; } } } @@ -1213,7 +1219,7 @@ static __provide_garrison_resolve = function() { static __protect_raiders_init = function(){ stage_id = "preliminary"; - data.applicant = "Governor" + data.applicant = "Governor"; } static __protect_raiders_feature_selected = function() { @@ -1870,6 +1876,10 @@ static __inquisition_purge_on_purge = function(){ } } +static __join_communion_init = function(){ + stage_id = "preliminary"; + data.applicant = "Governor"; +} static __join_communion_feature_selected = function(){ draw_data.mission_description = $"The governor of {p_data.name()} has Invited a delegate of your forces to take part in ceremony."; draw_data.help = "This mission is not yet completed" diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 9cc1e1c889..0a174e5563 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1408,29 +1408,29 @@ function PlanetData(_planet, _system) constructor { draw_text(xx + 349, yy + 346, string_hash_to_newline(string(presence_text))); - var planet_displays = []; - var feat_count = array_length(features); - var upgrade_count = array_length(upgrades); + var _planet_displays = []; + var _feat_count = array_length(features); + var _upgrade_count = array_length(upgrades); var size = global.planet_size; - if (feat_count > 0) { - for (var i = 0; i < feat_count; i++) { + if (_feat_count > 0) { + for (var i = 0; i < _feat_count; i++) { var cur_feature = features[i]; try { if (cur_feature.planet_display != 0) { if (cur_feature.f_type == eP_FEATURES.GENE_STEALER_CULT) { if (!cur_feature.hiding) { - array_push(planet_displays, [cur_feature.planet_display, cur_feature]); + array_push(_planet_displays, [cur_feature.planet_display, cur_feature]); } } else if (cur_feature.player_hidden == 1) { - array_push(planet_displays, ["????", ""]); + array_push(_planet_displays, ["????", ""]); } else { - array_push(planet_displays, [cur_feature.planet_display, cur_feature]); + array_push(_planet_displays, [cur_feature.planet_display, cur_feature]); } if (cur_feature.f_type == eP_FEATURES.MONASTERY) { if (cur_feature.forge > 0) { - var forge = cur_feature.forge_data; - var size_string = localize("{0} Chapter Forge", [size[forge.size]]); - array_push(planet_displays, [size_string, forge]); + var _forge = cur_feature.forge_data; + var _size_string = localize("{0} Chapter Forge", [size[forge.size]]); + array_push(_planet_displays, [_size_string, _forge]); } } } @@ -1440,14 +1440,14 @@ function PlanetData(_planet, _system) constructor { } } } - if (upgrade_count > 0) { - for (var i = 0; i < upgrade_count; i++) { + if (_upgrade_count > 0) { + for (var i = 0; i < _upgrade_count; i++) { var _upgrade = upgrades[i]; if (_upgrade.f_type == eP_FEATURES.SECRET_BASE) { if (_upgrade.forge > 0) { - var forge = _upgrade.forge_data; - var size_string = localize("{0} Chapter Forge", [size[forge.size]]); - array_push(planet_displays, [size_string, forge]); + var _forge = _upgrade.forge_data; + var _size_string = localize("{0} Chapter Forge", [size[_forge.size]]); + array_push(_planet_displays, [_size_string, _forge]); } } } @@ -1455,26 +1455,25 @@ function PlanetData(_planet, _system) constructor { for (var i = 0; i < array_length(problems); i++) { var _problem = problems[i]; - if (_problem.stage_id == "preliminary") { + if (_problem.view_on_planet_screen()) { var _mission_string = localize("{0} Audience", [_problem.data.applicant]); - problem_data.problem = _problem; - array_push(planet_displays, [_mission_string, _problem]); + array_push(_planet_displays, [_mission_string, _problem]); } } - var button_size; - var y_move = 0; - var button_colour; - for (var i = 0; i < array_length(planet_displays); i++) { - button_colour = c_green; - if (planet_displays[i][0] == "????") { - button_colour = c_red; + var _button_size; + var _y_move = 0; + var _button_colour; + for (var i = 0; i < array_length(_planet_displays); i++) { + _button_colour = c_green; + if (_planet_displays[i][0] == "????") { + _button_colour = c_red; } - button_size = draw_unit_buttons([xx + 535, yy + 346 + y_move], planet_displays[i][0], [1, 1], button_colour,, fnt_40k_14b, 1); - y_move += button_size[3] - button_size[1]; - if (point_and_click(button_size)) { - if (planet_displays[i][0] != "????") { - obj_star_select.feature = new FeatureSelected(planet_displays[i][1], system, current_planet); + _button_size = draw_unit_buttons([xx + 535, yy + 346 + _y_move], _planet_displays[i][0], [1, 1], _button_colour,, fnt_40k_14b, 1); + _y_move += _button_size[3] - _button_size[1]; + if (point_and_click(_button_size)) { + if (_planet_displays[i][0] != "????") { + obj_star_select.feature = new FeatureSelected(_planet_displays[i][1], system, current_planet); } else { obj_star_select.feature = ""; } @@ -1586,7 +1585,7 @@ function PlanetData(_planet, _system) constructor { if (garrisons.garrison_force) { garrisons.find_leader(); garrisons.garrison_disposition_change(true); - } + } }; static planet_selection_logic = function() { From 5f8551dadefe17c7002e9ee038adc61b8cb4baa1 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 13:22:52 +0100 Subject: [PATCH 064/118] spelling and stuff --- scripts/PlanetProblem/PlanetProblem.gml | 26 ++++++++++--------- .../scr_manage_task_selector.gml | 3 +++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 5aa58d4c9e..80cd4b5d47 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -360,13 +360,15 @@ static __init = function(){ } __init(); - +//self must be referenced like this or the compiler assumes i want feature to refer to the arg struct i'm passing static select_units = function(select_from, purpose_string, number, selections = []){ - group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: number, system , feature: self, planet, selections}); + var _self = self; + group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: number, system , feature: _self, planet, selections}); } static select_squads = function(select_from, purpose_string, number, selections = []){ - group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: number, system , feature: self, planet, selections, select_type: eMISSION_SELECT_TYPE.SQUADS}); + var _self = self; + group_selection(select_from, {purpose: purpose_string, purpose_code: p_id, number: number, system , feature: _self, planet, selections, select_type: eMISSION_SELECT_TYPE.SQUADS}); } // by default mission battles do not reduce the fortification level or enemy power on a planet static new_end_turn_battle = function(battle_opponent_id, special_id = p_id, enemy_data = undefined){ @@ -632,7 +634,7 @@ static __train_forces_resolve = function() { } } else { var disp_loss = -5; - _mission_string += "The orgional training mission was a failiure"; + _mission_string += "The original training mission was a failure"; if (_brute) { _mission_string += "in no short part due to his brutish nature"; } @@ -657,7 +659,7 @@ static __train_forces_resolve = function() { } } if (_hard_loss) { - _mission_string += $"His particularly grueling regimes and standards imposed upon the senior officers of the pdf caused friction with physical injury being caused to one officer"; + _mission_string += $"His particularly gruelling regimes and standards imposed upon the senior officers of the pdf caused friction with physical injury being caused to one officer"; disp_loss = -25; _mission_string += "(disposition -25)"; } @@ -708,7 +710,7 @@ static __succession_resolve = function() { scr_alert("green", "succession", _alert_text, p_data.system.x, p_data.system.y); scr_event_log("", _alert_text); } else { - //At the moment does not fire but a worty flavour option for down the line + //At the moment does not fire but a worthy flavour option for down the line _alert_text += " Word is the new Governor has Heretical leanings and sympathises with xenos."; } @@ -748,7 +750,7 @@ static __inquisition_recon_per_turn = function() { "inquisition", _pop_data ); - scr_event_log("", $"Inquisition Mission Completed: Your Astartes have succesfully scouted {p_data.name()}."); + scr_event_log("", $"Inquisition Mission Completed: Your Astartes have successfully scouted {p_data.name()}."); delete_mission = true; @@ -813,7 +815,7 @@ static __inquisition_spyrer_per_turn = function() { } static __inquisition_spyrer_battle_aftermath = function(){ - // title / text / image / speshul + // title / text / image / special if (!obj_ncombat.defeat){ exit; } @@ -1189,7 +1191,7 @@ static __provide_garrison_resolve = function() { //TODO make a dedicated plus minus string function if there isn't one already } else if (_result < 0) { _effect = _result * irandom_range(1, 5); - _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})"; + _mission_string += $"A number of diplomatic incidents occurred over the period which had considerable negative effects on our disposition with the planetary governor (disposition -{_effect})"; } else { _effect = _result * irandom_range(1, 5); _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})"; @@ -1226,7 +1228,7 @@ static __protect_raiders_feature_selected = function() { draw_data.mission_description = $"The governor of {p_data.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."; draw_data.help = "Set a squads to ambush"; draw_data.button_text = "Send Squad"; - draw_data.button_tooltip = "milage may vary on playability of this mission progress at your own risk"; + draw_data.button_tooltip = "mileage may vary on playability of this mission progress at your own risk"; draw_data.button_function = function() { var _dudes = collect_role_group("all", system.name); select_squads(_dudes, "Select Squad for Ambush", 1) @@ -1830,7 +1832,7 @@ static __inquisition_purge_init = function(){ if (data.mission_flavour == 1) { _text += $" A number of high-ranking nobility on the {p_data.name()} are being difficult and harboring heretical thoughts. They are to be selectively purged within {timer} months. Can your chapter handle this mission?"; } else if (data.mission_flavour == 2) { - _text += $" A powerful crimelord on the {p_data.name()} is gaining an unacceptable amount of power and disrupting daily operations. They are to be selectively purged within {timer} months. Can your chapter handle this mission?"; + _text += $" A powerful crime-lord on the {p_data.name()} is gaining an unacceptable amount of power and disrupting daily operations. They are to be selectively purged within {timer} months. Can your chapter handle this mission?"; } else if (data.mission_flavour == 3) { _text += $" The mutants of hive world {p_data.name()} are growing in numbers and ferocity, rising sporadically from the underhive. They are to be cleansed by promethium within {timer} months. Can your chapter handle this mission?"; } @@ -1868,7 +1870,7 @@ static __inquisition_purge_on_purge = function(){ alter_disposition(eFACTION.INQUISITION, obj_controller.demanding ? choose(0, 0, 1) : 1); - var _popup_text = $"Your marines scour the underhive of {p_data.name()}, spraying mutants down with promethium as they go. It takes several days but a sizeable dent is put in their numbers."; + var _popup_text = $"Your marines scour the under-hive of {p_data.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 {p_data.name()} have been cleansed by promethium."); p_data.add_disposition(choose(1, 2, 3)); scr_popup("Inquisition Mission Completed", _popup_text, "inquisition"); diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index 177dc81f35..ae053fe534 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -158,8 +158,11 @@ function task_selector_man_manage() { } selection_data.selections = _selections; if (struct_exists(selection_data, "feature")){ + LOGGER.info("feature select call point") var _feat = selection_data.feature; + LOGGER.info($"is struct: {is_struct(_feat)}, is_ instance{is_instanceof(_feat, PlanetProblem)}, \nfeature: {_feat}") if (is_struct(_feat) && is_instanceof(_feat, PlanetProblem)){ + LOGGER.info("feature is real") _feat.on_unit_selection(); } } From e39fa868c43e1eac9085975551c29c150667568e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 13:30:43 +0100 Subject: [PATCH 065/118] add delete_mission flag to all resolve functions --- scripts/PlanetProblem/PlanetProblem.gml | 18 ++++++++++++++---- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 80cd4b5d47..2b1d30c0da 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -183,6 +183,7 @@ static __handle_triggered_mission_func = function(func){ } } __check_delete(); + obj_controller.location_viewer.update_mission_log(); } static find_func_ref = function(trigger_string){ @@ -454,8 +455,8 @@ static __hunt_beast_unit_select = function() { } static __hunt_beast_resolve = function() { + delete_mission = true; if (stage_id == "preliminary"){ - delete_mission = true; exit; } var _hunters = clean_unit_array(members); @@ -466,7 +467,6 @@ static __hunt_beast_resolve = function() { }; _hunters = collect_role_group("all", [system.name, planet, 0], false, _man_conditions); if (array_length(_hunters) == 0){ - delete_mission = true; exit; } } @@ -527,6 +527,7 @@ static __hunt_beast_resolve = function() { for (var i = 0; i < array_length(_hunters); i++) { _hunters[i].job = "none"; } + delete_mission = true; } static __train_forces_feature_selected = function() { @@ -572,6 +573,7 @@ static __train_forces_unit_select = function() { } static __train_forces_resolve = function() { + delete_mission = true; if (stage_id != "active") { exit; } @@ -756,6 +758,7 @@ static __inquisition_recon_per_turn = function() { } static __inquisition_recon_resolve = function() { + delete_mission = true; var _alert_text = "Inquisition Mission Failed: Investigate "; alter_disposition(eFACTION.INQUISITION, -5); _alert_text += $"{p_data.name()}."; @@ -778,6 +781,7 @@ static __inquisition_spyrer_accept = function(){ scr_event_log("", _text, system.name); } static __inquisition_spyrer_resolve = function() { + delete_mission = true; var _planet_name = p_data.name(); alter_disposition(eFACTION.INQUISITION, -3); var _alert_text = $"The Spyrer on {_planet_name} has been left unchecked. In the ensuing carnage some high-ranking officials have been killed, along with several Nobles. Panic is running amock in several parts of the hives and the Inquisition is less than pleased."; @@ -894,6 +898,7 @@ static __hunt_fallen_per_turn = function() { } static __hunt_fallen_resolve = function() { + delete_mission = true; //TODO marker point for cohesion mechanics var _alert_text = ""; if (irandom(100) > 33) { @@ -910,7 +915,7 @@ static __hunt_fallen_resolve = function() { } } _alert_text = $"Any Fallen that may have been on {p_data.name()} "; - _alert_text += "have been given sufficient time to escape. Morale within your chapter has plummeted; some of your battle brothers have become restless and speak among eachother in hushed tones."; + _alert_text += "have been given sufficient time to escape. Morale within your chapter has plummeted; some of your battle brothers have become restless and speak among each other in hushed tones."; scr_popup("Hunt the Fallen Failed", _alert_text + "\n\n(Chapter wide loyalty: -10)\nChaplains note marked changes in behaviour of some brothers", "fallen", ""); obj_controller.loyalty -= 10; obj_controller.loyalty_hidden -= 10; @@ -951,6 +956,7 @@ static __mech_raider_per_turn = function() { } static __mech_raider_resolve = function() { + delete_mission = true; var _alert_text = $"Mechanicus Mission Failed: Land Raider testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); @@ -975,6 +981,7 @@ static __mech_bionics_per_turn = function() { } static __mech_bionics_resolve = function() { + delete_mission = true; var _alert_text = $"Mechanicus Mission Failed: bionics testing at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text); @@ -1058,6 +1065,7 @@ static __mech_tomb_exploring = function() { } static __mech_tomb_resolve = function() { + delete_mission = true; var _alert_text = $"Mechanicus Mission Failed: Necron Tomb Study at {p_data.name()}."; scr_alert("red", "mission_failed", _alert_text, 0, 0); scr_event_log("red", _alert_text, system.name); @@ -1089,6 +1097,7 @@ static __mech_tomb_battle_aftermath = function() { } static __mech_mars_resolve = function() { + delete_mission = true; var _techs_taken = 0; var _techs = collect_role_group([SPECIALISTS_TECHMARINES,false,true],system.name); for (i = 0; i < array_length(_techs); i++) { @@ -1167,8 +1176,8 @@ static provide_garrison_on_garrison = function() { } static __provide_garrison_resolve = function() { + delete_mission = true; if (stage_id != "active"){ - delete_mission = true; exit; } @@ -1673,6 +1682,7 @@ static advance_inquisition_tomb_mission = function() { } static __inquisition_tomb_resolve = function() { + delete_mission = true; alter_disposition(eFACTION.INQUISITION, -8); var _alert_text = $"The Necron Tomb of planet {p_data.name()} has not been deactivated in time. It has awakened, rank upon rank of Necrons pouring out to the planet's surface. The Inquisition is not pleased with your failure."; scr_popup("Inquisition Mission Failed", _alert_text, "necron_army", ""); diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 0a174e5563..14027bb8a3 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -819,7 +819,7 @@ function PlanetData(_planet, _system) constructor { } var _mission_explain = _problem.description(); var _data = { - system: name, + system: name(), mission: _mission_explain, time: _problem.timer, problem : _problem, From 1e4c31c9c1650af9d5dc24acea913a7f6c402a75 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 13:34:56 +0100 Subject: [PATCH 066/118] auto delete errored missions --- scripts/PlanetProblem/PlanetProblem.gml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 2b1d30c0da..7b10918cb1 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -37,6 +37,9 @@ other info - set a mission for deletion by setting delete_mission = true; this will delete the mission after the current function has finished executing and */ + +//ANYTIME an exception is caught on a entry point for a mission the mission is prematurely deleted this ensures the player is not unfairly penalised for errors + /// @param {sring} name /// @param {Real} timer /// @param {struct} data @@ -179,6 +182,7 @@ static __handle_triggered_mission_func = function(func){ try { func(); } catch (_exception) { + delete_mission = true; ERROR_HANDLER.handle_exception(_exception); } } From cf61a7b0e366381cf2a9417af303df01b173921f Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 14:48:38 +0100 Subject: [PATCH 067/118] further upgrades --- objects/obj_star/Create_0.gml | 3 + scripts/PlanetProblem/PlanetProblem.gml | 133 +++++++++++------- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 28 +--- .../scr_mechanicus_missions.gml | 29 +--- scripts/scr_random_event/scr_random_event.gml | 106 +++++++------- 5 files changed, 145 insertions(+), 154 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index fa3e92c0e3..d93c235141 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -269,6 +269,9 @@ function deserialize(save_data) { continue; } var _val = _planet[$ _var_name]; + if (!is_array(self[$ _var_name])){ + self[$ _var_name] = array_create(9, 0); + } self[$ _var_name][p] = _val; } } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 7b10918cb1..fe0425c87b 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -115,6 +115,7 @@ static view_on_planet_screen = function(){ return (stage_id == "preliminary") && (has_data("applicant")); } +//requires the completion and required_months flag to be in the data struct static __increment_mission_completion = function() { if (!struct_exists(data, "completion")) { data.completion = 0; @@ -849,55 +850,56 @@ static __hunt_fallen_init = function(){ } static __hunt_fallen_per_turn = function() { - if (p_data.player_forces > 0){ - if (choose(true, false)) { - var _group_big = choose(true, false); - var _battle_enemy_data = {}; - if (_group_big){ - _battle_enemy_data = { - threat : 1, - fortified : false, - cols : [ - { - distance : 80, - enemies : [ - { - name : "Fallen", - number : 1 - } - ] - } - ] - }; + if (p_data.player_forces <= 0){ + exit; + } + if (irandom(1) == 1) { + var _group_big = choose(true, false); + var _battle_enemy_data = {}; + if (_group_big){ + _battle_enemy_data = { + threat : 1, + fortified : false, + cols : [ + { + distance : 80, + enemies : [ + { + name : "Fallen", + number : 1 + } + ] + } + ] + }; - // * Large Fallen Group * - _battle_enemy_data = { - threat : 1, - fortified : false, - cols : [ - { - distance : 80, - enemies : [ - { - name : "Fallen", - number : choose(1, 1, 2, 2, 3) - } - ] - } - ] - }; - } - new_end_turn_battle( - 10, - p_id, - _battle_enemy_data - ); - } else { - delete_mission = true; - var _tixt = $"Your marines have scoured {p_data.name()} in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; - scr_popup("Hunt the Fallen", _tixt, "fallen", ""); - scr_event_log("", $"Mission Successful: No Fallen located upon {p_data.name()}"); + // * Large Fallen Group * + _battle_enemy_data = { + threat : 1, + fortified : false, + cols : [ + { + distance : 80, + enemies : [ + { + name : "Fallen", + number : choose(3, 4, 5) + } + ] + } + ] + }; } + new_end_turn_battle( + 10, + p_id, + _battle_enemy_data + ); + } else { + delete_mission = true; + var _tixt = $"Your marines have scoured {p_data.name()} in search of the Fallen. Despite their best efforts, and meticulous searching, none have been found. It appears as though the information was faulty or out of date."; + scr_popup("Hunt the Fallen", _tixt, "fallen", ""); + scr_event_log("", $"Mission Successful: No Fallen located upon {p_data.name()}"); } } @@ -943,10 +945,28 @@ function __hunt_fallen_battle_aftermath() { scr_popup("Hunt the Fallen Completed", _tixt, "fallen", ""); } +static __mech_raider_init = function(){ + var _mission_loc = _planet.name(); + var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); + var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); + var _vacation_time = 24; + _mission_time += _vacation_time; + var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true]); + + var _techs_required = min(array_length(_techs) - 2, 6); + + data = {completion: 0, required_months: _vacation_time,techs_required:_techs_required} + var _eligible_roles = role_groups(SPECIALISTS_TECHMARINES); + obj_popup.text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting {_techs_required} {_eligible_roles}s and a Land Raider."; + scr_event_log("", $"Mechanicus Mission Accepted: {_techs_required} of your {_eligible_roles}s and a Land Raider are to be stationed at {_mission_loc} for {_mission_time} months.", _star.name); + mark("green"); + title = "Mechanicus Mission Accepted"; +} + static __mech_raider_per_turn = function() { - var _techs = collect_role_group(SPECIALISTS_TECHS, [system.name, planet, -1]); + var _techs = collect_role_group(SPECIALISTS_TECHMARINES, false, true, [system.name, planet, -1]); var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); - if ((array_length(_techs) >= 6) && (_lr_count >= 1)) { + if ((array_length(_techs) >= data.techs_required) && (_lr_count >= 1)) { var _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { @@ -992,9 +1012,17 @@ static __mech_bionics_resolve = function() { alter_disposition(eFACTION.MECHANICUS, -6); delete_mission = true; } - +static __mech_tomb_init = function() { + var _name = p_data.name(); + obj_popup.text = $"The Adeptus Mechanicus await your forces at {_name}. They are expecting at least two squads of Astartes and have placed the testing on hold until their arrival. {global.chapter_name} have 16 months to arrive."; + scr_event_log("", "Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", _star.name); + mark("green"); + obj_popup.title = "Mechanicus Mission Accepted"; + reset_popup_options(); + obj_popup.cooldown = 15; +} static __mech_tomb_per_turn = function() { - if (stage_id != "exploring"){ + if (stage_id == "awating_player"){ var _marines = collect_role_group("all", [system.name, planet, -1]); if (array_length(_marines) >= 20) { stage_id = "exploring"; @@ -1929,7 +1957,8 @@ static __governor_purge_enemies_init = function(){ } static __governor_purge_enemies_feature_selected = function(){ - draw_data.mission_description = $"The governor of {p_data.name()} has expressed his distaste of the neighboring governance of {system.name} {data.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"; + draw_data.mission_description = $"The governor of {p_data.name()} has expressed his distaste of the neighbouring governance of {system.name} {data.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"; + draw_data.help = "This mission is not yet complete"; } } 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 b035b644e1..8a237f8302 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -1,16 +1,8 @@ /// @self Asset.GMObject.obj_star function scr_enemy_ai_d() { - if (x < -15000) { + while (x < -15000){ x += 20000; - y += 20000; - } - if (x < -15000) { - x += 20000; - y += 20000; - } - if (x < -15000) { - x += 20000; - y += 20000; + y += 20000; } // Planetary problems here @@ -118,27 +110,13 @@ function scr_enemy_ai_d() { if (trader > 0) { trader -= 1; if (trader == 0) { - var tr = "Rogue Trader fleet departs from " + string(name) + "."; + var tr = $"Rogue Trader fleet departs from {name}."; scr_alert("green", "Warp", tr, x, y); scr_event_log("green", tr); } } // Colonists Colonize - - with (obj_star) { - if (x < -10000) { - x += 20000; - y += 20000; - } - } - with (obj_star) { - if (x < -10000) { - x += 20000; - y += 20000; - } - } - var already_enroute = false; var cur_star = id; with (obj_en_fleet) { diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 288d627773..55f994536b 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -7,7 +7,8 @@ function spawn_mechanicus_mission(chosen_mission = "random") { if (array_length(_forge_stars)) { array_push(mechanicus_missions, "mech_bionics"); - if (scr_role_count(obj_ini.player_role_data[eROLE.TECHMARINE].role, "") >= 6) { + var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true]); + if (_techs >= 3) { array_push(mechanicus_missions, "mech_raider"); } } @@ -142,17 +143,8 @@ function accept_mechanicus_tomb_mission() { } } if (_planet > 0) { - _planet = _star.get_planet_data(_planet); - _planet.new_problem("mech_tomb", 17, {stage : "awating_player"}); - var _name = _planet.name(); - text = $"The Adeptus Mechanicus await your forces at {_name}. They are expecting at least two squads of Astartes and have placed the testing on hold until their arrival. {global.chapter_name} have 16 months to arrive."; - scr_event_log("", "Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", _star.name); - with (_star) { - new_star_event_marker("green"); - } - title = "Mechanicus Mission Accepted"; - reset_popup_options(); - cooldown = 15; + planet = _star.get_planet_data(_planet); + _planet.new_problem("mech_tomb", scr_mission_eta(_star.x, _star.y), {stage : "awating_player"}); exit; } } @@ -163,18 +155,7 @@ function accept_mechanicus_land_raider_mission() { var _forge_planet = scr_get_planet_with_type(_star, "Forge"); if (_forge_planet > 0) { var _planet = _star.get_planet_data(_forge_planet); - - var _mission_loc = _planet.name(); - var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); - var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); - - _planet.new_problem("mech_raider", _mission_time, {completion: 0, required_months: 24}); - text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting six {obj_ini.player_role_data[eROLE.TECHMARINE].role}s and a Land Raider."; - scr_event_log("", $"Mechanicus Mission Accepted: Six of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s and a Land Raider are to be stationed at {_mission_loc} for {_mission_time} months.", _star.name); - with (_star) { - new_star_event_marker("green"); - } - title = "Mechanicus Mission Accepted"; + _planet.new_problem("mech_raider", _mission_time,{}); } else { text = $"Error valid forge planet not found please open a bug report if seen"; } diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 554850e63d..7f23d515fb 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -219,18 +219,18 @@ function scr_random_event(execute_now) { LOGGER.info("RE: Space Hulk"); var own = choose(1, 1, 2); - var star_id = scr_random_find(own, true, "", ""); - if (star_id == noone && own == 1) { + var _star_id = scr_random_find(own, true, "", ""); + if (_star_id == noone && own == 1) { // find the nearest star to a player fleet and user that one, dukecode did that // we could also try to find to find another star but this one is owned by the imperium and not the player, this code is doing that own = 2; - star_id = scr_random_find(own, true, "", ""); + _star_id = scr_random_find(own, true, "", ""); } - if (star_id == noone && own == 2) { - star_id = scr_random_find(0, true, "", ""); // try for litteraly any star + if (_star_id == noone && own == 2) { + _star_id = scr_random_find(0, true, "", ""); // try for litteraly any star } - if (star_id == noone) { + if (_star_id == noone) { LOGGER.error("RE: Space Hulk, couldn't find a star for the spacehulk"); exit; } else { @@ -238,8 +238,8 @@ function scr_random_event(execute_now) { var spaceHulkX, spaceHulkY, tries_to_place_space_hulk; tries_to_place_space_hulk = 0; while (!positionFound && tries_to_place_space_hulk < 50) { - spaceHulkX = star_id.x + (choose(-1, 1) * irandom_range(50, 60)); - spaceHulkY = star_id.y + (choose(-1, 1) * irandom_range(50, 80)); + spaceHulkX = _star_id.x + (choose(-1, 1) * irandom_range(50, 60)); + spaceHulkY = _star_id.y + (choose(-1, 1) * irandom_range(50, 80)); spaceHulkY = max(spaceHulkY, 40); var distanceToNearestStarOk = point_distance(spaceHulkX, spaceHulkY, instance_nearest(spaceHulkX, spaceHulkY, obj_star).x, instance_nearest(spaceHulkX, spaceHulkY, obj_star).y) >= 70; if (distanceToNearestStarOk) { @@ -249,15 +249,15 @@ function scr_random_event(execute_now) { } if (tries_to_place_space_hulk >= 50) { // its possible for there to be no good spot for the space hulk at a star, if there are too many stars in close proximity - LOGGER.error($"RE: Space Hulk, couldn't find a spot for the spacehulk at the {star_id.name} system"); + LOGGER.error($"RE: Space Hulk, couldn't find a spot for the spacehulk at the {_star_id.name} system"); exit; } try { var spaceHulk = scr_create_space_hulk(spaceHulkX, spaceHulkY); - scr_alert(own ? "red" : "green", "space_hulk", $"The Space Hulk {spaceHulk.name} appears near the {star_id.name} system.", spaceHulkX, spaceHulkY); + scr_alert(own ? "red" : "green", "space_hulk", $"The Space Hulk {spaceHulk.name} appears near the {_star_id.name} system.", spaceHulkX, spaceHulkY); - scr_event_log("", $"The Space Hulk {spaceHulk.name} appears near the {star_id.name} system.", star_id.name); + scr_event_log("", $"The Space Hulk {spaceHulk.name} appears near the {_star_id.name} system.", _star_id.name); _evented = true; } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); @@ -302,36 +302,36 @@ function scr_random_event(execute_now) { LOGGER.info("RE: Sororitas Company"); var own; own = choose(1, 2); - var star_id = scr_random_find(own, true, "", ""); + var _star_id = scr_random_find(own, true, "", ""); - if (star_id == noone && own == 1) { + if (_star_id == noone && own == 1) { own = 2; - star_id = scr_random_find(own, true, "", ""); + _star_id = scr_random_find(own, true, "", ""); } - if (star_id == noone) { + if (_star_id == noone) { LOGGER.error("RE: Sororitas Company, couldn't find a star for the company"); exit; } else { var eligible_planets = []; - for (var i = 1; i <= star_id.planets; i++) { - if (star_id.p_type[i] != "Dead") { + 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) { - LOGGER.error("RE: Sororitas Company, couldn't find a planet on the " + star_id.name + " system for the company"); + LOGGER.error("RE: Sororitas Company, couldn't find a planet on the " + _star_id.name + " system for the company"); exit; } - var planet = eligible_planets[irandom(array_length(eligible_planets) - 1)]; - ++star_id.p_sisters[planet]; + var _planet = _star_id.get_plaet_data(array_random_element(eligible_planets)); + _planet.add_forces(eFACTION.ECCLESIARCHY, 1); _evented = true; - if ((own != 1) && (star_id.p_player[planet] <= 0) && (star_id.present_fleet[1] == 0)) { - scr_alert("green", "sororitas", "Sororitas place a company of sisters on " + string(star_id.name) + " " + string(planet) + ".", star_id.x, star_id.y); + if ((own != 1) && (_planet.player_forces <= 0) && (_star_id.present_fleet[1] == 0)) { + scr_alert("green", "sororitas", $"Sororitas place a company of sisters on {_planet.name()}.", _star_id.x, _star_id.y); } else { - scr_popup("Sororitas", "The Ecclesiarchy have placed a company of sisters on " + string(star_id.name) + " " + string(planet) + ".", "sororitas", ""); + scr_popup("Sororitas", $"The Ecclesiarchy have placed a company of sisters on {_planet.name()}.", "sororitas", ""); if (known[eFACTION.ECCLESIARCHY] == 0) { known[eFACTION.ECCLESIARCHY] = 1; // this seesms like a thing another part of code already does, not sure tho } @@ -553,25 +553,25 @@ function scr_random_event(execute_now) { own = choose(1, 1, 2, 0, 0); } - var star_id = scr_random_find(own, true, "", ""); - if (star_id == noone && own == 1) { + var _star_id = scr_random_find(own, true, "", ""); + if (_star_id == noone && own == 1) { own = 2; - star_id = scr_random_find(own, true, "", ""); + _star_id = scr_random_find(own, true, "", ""); } - if (star_id == noone && own == 2) { + if (_star_id == noone && own == 2) { own = 0; - star_id = scr_random_find(own, true, "", ""); + _star_id = scr_random_find(own, true, "", ""); } - if (star_id == noone) { + if (_star_id == noone) { LOGGER.error("RE: Warp Storm, couldn't pick a star for the warp storm"); exit; } else { - star_id.storm += time; + _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."); + 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) { LOGGER.info("RE: Enemy Forces"); @@ -584,28 +584,28 @@ function scr_random_event(execute_now) { own = choose(1, 1, 1, 2, 2, 3); } - var star_id = scr_random_find(own, true, "", ""); - if (star_id == noone && own == 1) { + var _star_id = scr_random_find(own, true, "", ""); + if (_star_id == noone && own == 1) { own = 2; - star_id = scr_random_find(own, true, "", ""); + _star_id = scr_random_find(own, true, "", ""); } - if (star_id == noone && own == 2) { + if (_star_id == noone && own == 2) { own = 3; - star_id = scr_random_find(own, true, "", ""); + _star_id = scr_random_find(own, true, "", ""); } - if (star_id == noone) { + if (_star_id == noone) { LOGGER.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") { + 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) { - LOGGER.error("RE: Enemy Forces, couldn't find a planet in the " + star_id.name + " system for the enemy"); + LOGGER.error("RE: Enemy Forces, couldn't find a planet in the " + _star_id.name + " system for the enemy"); exit; } var planet = eligible_planets[irandom(array_length(eligible_planets) - 1)]; @@ -616,35 +616,35 @@ function scr_random_event(execute_now) { 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); + _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); + _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); + _star_id.p_tyranids[planet] += 5; + _star_id.p_tyranids[planet] = min(_star_id.p_tyranids[planet], max_enemies_on_planet); break; //case 10: this doesn't work // text = "Heretics"; - // star_id.p_heretics[planet] = 4; - // star_id.p_heretics[planet] = min(star_id.p_heretics[planet], max_enemies_on_planet); + // _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); + // _star_id.p_necron[planet] = 4; + // _star_id.p_necron[planet] = min(_star_id.p_necron[planet], max_enemies_on_planet); // break; default: LOGGER.error("RE: Enemy Forces, couldn't pick an enemy faction"); exit; } - scr_alert("red", "enemy", $"{text} forces suddenly appear at {star_id.name} {planet}!", star_id.x, star_id.y); - scr_event_log("red", $"{text} forces suddenly appear at {star_id.name} {planet}!"); + scr_alert("red", "enemy", $"{text} forces suddenly appear at {_star_id.name} {planet}!", _star_id.x, _star_id.y); + scr_event_log("red", $"{text} forces suddenly appear at {_star_id.name} {planet}!"); _evented = true; } } else if (chosen_event == eEVENT.CRUSADE) { From d2a5c9661979ea5c0053a60a4650d4472c975b2c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 15:28:58 +0100 Subject: [PATCH 068/118] review points --- objects/obj_star/Create_0.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 8 +++---- scripts/scr_PlanetData/scr_PlanetData.gml | 2 +- .../scr_manage_task_selector.gml | 2 -- .../scr_mechanicus_missions.gml | 6 ++--- .../scr_mission_functions.gml | 10 ++++---- scripts/scr_random_event/scr_random_event.gml | 23 ++++++++----------- 7 files changed, 23 insertions(+), 30 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index d93c235141..3d9317fa20 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -269,7 +269,7 @@ function deserialize(save_data) { continue; } var _val = _planet[$ _var_name]; - if (!is_array(self[$ _var_name])){ + if (!is_array(self[$ _var_name])) { self[$ _var_name] = array_create(9, 0); } self[$ _var_name][p] = _val; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index fe0425c87b..a37bae9039 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -946,9 +946,9 @@ function __hunt_fallen_battle_aftermath() { } static __mech_raider_init = function(){ - var _mission_loc = _planet.name(); - var _nearest_fleet = instance_nearest(_star.x, _star.y, obj_p_fleet); - var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, _star.x, _star.y, _nearest_fleet, false); + var _mission_loc = p_data.name(); + var _nearest_fleet = instance_nearest(system.x, system.y, obj_p_fleet); + var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, system.x, system.y, _nearest_fleet, false); var _vacation_time = 24; _mission_time += _vacation_time; var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true]); @@ -1942,7 +1942,7 @@ static __governor_purge_enemies_init = function(){ continue; } if (p_owner[i] == eFACTION.IMPERIUM) { - enemy = i; + _enemy = i; break; } } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 14027bb8a3..25d9ad9fd8 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -1429,7 +1429,7 @@ function PlanetData(_planet, _system) constructor { if (cur_feature.f_type == eP_FEATURES.MONASTERY) { if (cur_feature.forge > 0) { var _forge = cur_feature.forge_data; - var _size_string = localize("{0} Chapter Forge", [size[forge.size]]); + var _size_string = localize("{0} Chapter Forge", [size[_forge.size]]); array_push(_planet_displays, [_size_string, _forge]); } } diff --git a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml index ae053fe534..fac5036bea 100644 --- a/scripts/scr_manage_task_selector/scr_manage_task_selector.gml +++ b/scripts/scr_manage_task_selector/scr_manage_task_selector.gml @@ -160,9 +160,7 @@ function task_selector_man_manage() { if (struct_exists(selection_data, "feature")){ LOGGER.info("feature select call point") var _feat = selection_data.feature; - LOGGER.info($"is struct: {is_struct(_feat)}, is_ instance{is_instanceof(_feat, PlanetProblem)}, \nfeature: {_feat}") if (is_struct(_feat) && is_instanceof(_feat, PlanetProblem)){ - LOGGER.info("feature is real") _feat.on_unit_selection(); } } diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 55f994536b..90e168a0c1 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -8,7 +8,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { if (array_length(_forge_stars)) { array_push(mechanicus_missions, "mech_bionics"); var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true]); - if (_techs >= 3) { + if (array_length(_techs >= 3)) { array_push(mechanicus_missions, "mech_raider"); } } @@ -143,7 +143,7 @@ function accept_mechanicus_tomb_mission() { } } if (_planet > 0) { - planet = _star.get_planet_data(_planet); + _planet = _star.get_planet_data(_planet); _planet.new_problem("mech_tomb", scr_mission_eta(_star.x, _star.y), {stage : "awating_player"}); exit; } @@ -155,7 +155,7 @@ function accept_mechanicus_land_raider_mission() { var _forge_planet = scr_get_planet_with_type(_star, "Forge"); if (_forge_planet > 0) { var _planet = _star.get_planet_data(_forge_planet); - _planet.new_problem("mech_raider", _mission_time,{}); + _planet.new_problem("mech_raider", 1, {}); } else { text = $"Error valid forge planet not found please open a bug report if seen"; } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index eb34b00b50..1ca646005e 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -124,15 +124,15 @@ function init_marine_acting_strange() { exit; } - var unit = fetch_unit(marine_and_company); - if (!is_struct(unit)) { + var _unit = fetch_unit(marine_and_company); + if (!is_struct(_unit)) { exit; } - var _text = unit.name_role(); - var company_text = scr_convert_company_to_string(unit.company); + var _text = _unit.name_role(); + var company_text = scr_convert_company_to_string(_unit.company); if (company_text != "") { company_text = $"({company_text})"; - text += company_text; + _text += company_text; } _text += " is behaving strangely."; scr_alert("color", "lol", _text, 0, 0); diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 7f23d515fb..47d64eb6be 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -241,8 +241,8 @@ function scr_random_event(execute_now) { spaceHulkX = _star_id.x + (choose(-1, 1) * irandom_range(50, 60)); spaceHulkY = _star_id.y + (choose(-1, 1) * irandom_range(50, 80)); spaceHulkY = max(spaceHulkY, 40); - var distanceToNearestStarOk = point_distance(spaceHulkX, spaceHulkY, instance_nearest(spaceHulkX, spaceHulkY, obj_star).x, instance_nearest(spaceHulkX, spaceHulkY, obj_star).y) >= 70; - if (distanceToNearestStarOk) { + var _distanceToNearestStarOk = point_distance(spaceHulkX, spaceHulkY, instance_nearest(spaceHulkX, spaceHulkY, obj_star).x, instance_nearest(spaceHulkX, spaceHulkY, obj_star).y) >= 70; + if (_distanceToNearestStarOk) { positionFound = true; } tries_to_place_space_hulk++; @@ -277,15 +277,10 @@ function scr_random_event(execute_now) { LOGGER.error("RE: Promotion, couldn't pick a space marine"); exit; } - 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.##He åis up for review to be promoted."; + var _text = _unit.name_role(); + var _company_text = $"({scr_convert_company_to_string(company)})"; + _text += _company_text; + _text += " has distinguished himself.##He åis up for review to be promoted."; if (company != 10) { _unit.add_exp(10); @@ -293,8 +288,8 @@ function scr_random_event(execute_now) { _unit.add_exp(max(20, _unit.experience)); } - scr_popup("Promotions!", text, "distinguished", ""); - scr_event_log("green", text); + scr_popup("Promotions!", _text, "distinguished", ""); + scr_event_log("green", _text); _evented = true; } else if (chosen_event == eEVENT.STRANGE_BUILDING) { _evented = strange_build_event(); @@ -324,7 +319,7 @@ function scr_random_event(execute_now) { exit; } - var _planet = _star_id.get_plaet_data(array_random_element(eligible_planets)); + var _planet = _star_id.get_planet_data(array_random_element(eligible_planets)); _planet.add_forces(eFACTION.ECCLESIARCHY, 1); _evented = true; From f7c2b8d45f4d66204f5b7fa22714bac903797c37 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 15:37:58 +0100 Subject: [PATCH 069/118] more review points --- objects/obj_star/Create_0.gml | 80 +++++++++---------- scripts/PlanetProblem/PlanetProblem.gml | 2 +- scripts/macros/macros.gml | 1 + scripts/scr_event_code/scr_event_code.gml | 14 ++-- scripts/scr_random_event/scr_random_event.gml | 2 +- 5 files changed, 50 insertions(+), 49 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 3d9317fa20..6ef014c005 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -29,47 +29,47 @@ visited = 0; stored_owner = -1; // sets up default planet variables -var _planet_array_size = 9; -planet = array_create(_planet_array_size, 0); -dispo = array_create(_planet_array_size, -50); -p_type = array_create(_planet_array_size, ""); -p_owner = array_create(_planet_array_size, 0); -p_first = array_create(_planet_array_size, 0); -p_population = array_create(_planet_array_size, 0); -p_max_population = array_create(_planet_array_size, 0); -p_large = array_create(_planet_array_size, 0); -p_pop = array_create(_planet_array_size, ""); -p_guardsmen = array_create(_planet_array_size, 0); -p_pdf = array_create(_planet_array_size, 0); -p_fortified = array_create(_planet_array_size, 0); -p_station = array_create(_planet_array_size, 0); -p_player = array_create(_planet_array_size, 0); -p_lasers = array_create(_planet_array_size, 0); -p_silo = array_create(_planet_array_size, 0); -p_defenses = array_create(_planet_array_size, 0); -p_orks = array_create(_planet_array_size, 0); -p_tau = array_create(_planet_array_size, 0); -p_eldar = array_create(_planet_array_size, 0); -p_tyranids = array_create(_planet_array_size, 0); -p_traitors = array_create(_planet_array_size, 0); -p_chaos = array_create(_planet_array_size, 0); -p_demons = array_create(_planet_array_size, 0); -p_sisters = array_create(_planet_array_size, 0); -p_necrons = array_create(_planet_array_size, 0); -p_halp = array_create(_planet_array_size, 0); -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, 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, []); -p_influence = array_create_advanced(_planet_array_size, array_create(15, 0)); -p_problem = array_create_advanced(_planet_array_size, []); +var PLANET_ARRAY_SIZE = 9; +planet = array_create(PLANET_ARRAY_SIZE, 0); +dispo = array_create(PLANET_ARRAY_SIZE, -50); +p_type = array_create(PLANET_ARRAY_SIZE, ""); +p_owner = array_create(PLANET_ARRAY_SIZE, 0); +p_first = array_create(PLANET_ARRAY_SIZE, 0); +p_population = array_create(PLANET_ARRAY_SIZE, 0); +p_max_population = array_create(PLANET_ARRAY_SIZE, 0); +p_large = array_create(PLANET_ARRAY_SIZE, 0); +p_pop = array_create(PLANET_ARRAY_SIZE, ""); +p_guardsmen = array_create(PLANET_ARRAY_SIZE, 0); +p_pdf = array_create(PLANET_ARRAY_SIZE, 0); +p_fortified = array_create(PLANET_ARRAY_SIZE, 0); +p_station = array_create(PLANET_ARRAY_SIZE, 0); +p_player = array_create(PLANET_ARRAY_SIZE, 0); +p_lasers = array_create(PLANET_ARRAY_SIZE, 0); +p_silo = array_create(PLANET_ARRAY_SIZE, 0); +p_defenses = array_create(PLANET_ARRAY_SIZE, 0); +p_orks = array_create(PLANET_ARRAY_SIZE, 0); +p_tau = array_create(PLANET_ARRAY_SIZE, 0); +p_eldar = array_create(PLANET_ARRAY_SIZE, 0); +p_tyranids = array_create(PLANET_ARRAY_SIZE, 0); +p_traitors = array_create(PLANET_ARRAY_SIZE, 0); +p_chaos = array_create(PLANET_ARRAY_SIZE, 0); +p_demons = array_create(PLANET_ARRAY_SIZE, 0); +p_sisters = array_create(PLANET_ARRAY_SIZE, 0); +p_necrons = array_create(PLANET_ARRAY_SIZE, 0); +p_halp = array_create(PLANET_ARRAY_SIZE, 0); +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, 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, []); +p_influence = array_create_advanced(PLANET_ARRAY_SIZE, array_create(15, 0)); +p_problem = array_create_advanced(PLANET_ARRAY_SIZE, []); p_psionic = []; -for (var i = 0; i < _planet_array_size; i++) { +for (var i = 0; i < PLANET_ARRAY_SIZE; i++) { p_psionic[i] = irandom(5); } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index a37bae9039..81d88ef605 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1015,7 +1015,7 @@ static __mech_bionics_resolve = function() { static __mech_tomb_init = function() { var _name = p_data.name(); obj_popup.text = $"The Adeptus Mechanicus await your forces at {_name}. They are expecting at least two squads of Astartes and have placed the testing on hold until their arrival. {global.chapter_name} have 16 months to arrive."; - scr_event_log("", "Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", _star.name); + scr_event_log("", $"Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", system.name); mark("green"); obj_popup.title = "Mechanicus Mission Accepted"; reset_popup_options(); diff --git a/scripts/macros/macros.gml b/scripts/macros/macros.gml index 4ce6a2aa96..6a3ae40f16 100644 --- a/scripts/macros/macros.gml +++ b/scripts/macros/macros.gml @@ -10,6 +10,7 @@ #macro CM_RED_COLOR #bf4040 #macro COL_REQUISITION #2398F8 #macro COL_FORGE_POINTS #af5a00 +#macro PLANET_ARRAY_SIZE 9 // First candidate TTF used when a language needs CJK glyphs that the latin fonts lack. #macro STR_CJK_FALLBACK_FONT "fonts/simhei.ttf" diff --git a/scripts/scr_event_code/scr_event_code.gml b/scripts/scr_event_code/scr_event_code.gml index 2386994d3c..477dce570b 100644 --- a/scripts/scr_event_code/scr_event_code.gml +++ b/scripts/scr_event_code/scr_event_code.gml @@ -89,13 +89,13 @@ function event_end_turn_action() { // 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 != noone) { - scr_event_log("purple", $"Chaos Fleets exit the warp near the {star_id.name} system.", star_id.name); + var _star_id = scr_random_find(1, true, "", ""); + if (_star_id != noone) { + 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); + xx = _star_id.x + lengthdir_x(72, dirr); + yy = _star_id.y + lengthdir_y(72, dirr); flee = create_enemy_fleet(xx, yy, eFACTION.CHAOS); flee.sprite_index = spr_fleet_chaos; flee.image_index = 4; @@ -104,8 +104,8 @@ function event_end_turn_action() { flee.escort_number = choose(4, 5, 6); flee.cargo_data.chaos = true; obj_controller.chaos_fleets += 1; - flee.action_x = star_id.x; - flee.action_y = star_id.y; + flee.action_x = _star_id.x; + flee.action_y = _star_id.y; with (flee) { set_fleet_movement(); } diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 47d64eb6be..e19a9badfa 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -607,7 +607,7 @@ function scr_random_event(execute_now) { //var enemy = choose(7,8,9,10,13); var enemy = choose(7, 8, 9); var text; - var max_enemies_on_planet = 5; // I don't know the actual value, i need to change it; + var max_enemies_on_planet = 6; // I don't know the actual value, i need to change it; switch (enemy) { case 7: text = "Orks"; From 43fde944595e1236d890976b6f85f35f4dc70e6a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 15:39:09 +0100 Subject: [PATCH 070/118] use PLANET_ARRAY_SIZE macro for system array creation --- objects/obj_star/Create_0.gml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 6ef014c005..fbdb02c983 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -29,7 +29,6 @@ visited = 0; stored_owner = -1; // sets up default planet variables -var PLANET_ARRAY_SIZE = 9; planet = array_create(PLANET_ARRAY_SIZE, 0); dispo = array_create(PLANET_ARRAY_SIZE, -50); p_type = array_create(PLANET_ARRAY_SIZE, ""); @@ -270,7 +269,7 @@ function deserialize(save_data) { } var _val = _planet[$ _var_name]; if (!is_array(self[$ _var_name])) { - self[$ _var_name] = array_create(9, 0); + self[$ _var_name] = array_create(PLANET_ARRAY_SIZE, 0); } self[$ _var_name][p] = _val; } From 1a445b6bb27b1f535f5481b4ca8e55a78b3a1896 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 15:43:51 +0100 Subject: [PATCH 071/118] variable naming --- scripts/scr_mission_functions/scr_mission_functions.gml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 1ca646005e..f2881c432b 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -129,10 +129,10 @@ function init_marine_acting_strange() { exit; } var _text = _unit.name_role(); - var company_text = scr_convert_company_to_string(_unit.company); - if (company_text != "") { - company_text = $"({company_text})"; - _text += company_text; + var _company_text = scr_convert_company_to_string(_unit.company); + if (_company_text != "") { + _company_text = $"({_company_text})"; + _text += _company_text; } _text += " is behaving strangely."; scr_alert("color", "lol", _text, 0, 0); From ba5424b92a08851319ee95d96a5468d173ec9cc4 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:01:20 +0100 Subject: [PATCH 072/118] even more minor changes --- scripts/PlanetProblem/PlanetProblem.gml | 33 ++++++++++--------- .../scr_mechanicus_missions.gml | 4 +-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 81d88ef605..f0bdbebaae 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -948,25 +948,25 @@ function __hunt_fallen_battle_aftermath() { static __mech_raider_init = function(){ var _mission_loc = p_data.name(); var _nearest_fleet = instance_nearest(system.x, system.y, obj_p_fleet); - var _mission_time = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, system.x, system.y, _nearest_fleet, false); + timer = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, system.x, system.y, _nearest_fleet, false); var _vacation_time = 24; - _mission_time += _vacation_time; + timer += _vacation_time; var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true]); + //tech count is calculated earlier called mission is not added to p_problems array if less than 3 var _techs_required = min(array_length(_techs) - 2, 6); - data = {completion: 0, required_months: _vacation_time,techs_required:_techs_required} var _eligible_roles = role_groups(SPECIALISTS_TECHMARINES); obj_popup.text = $"The Adeptus Mechanicus await your forces at {_mission_loc}. They are expecting {_techs_required} {_eligible_roles}s and a Land Raider."; - scr_event_log("", $"Mechanicus Mission Accepted: {_techs_required} of your {_eligible_roles}s and a Land Raider are to be stationed at {_mission_loc} for {_mission_time} months.", _star.name); + scr_event_log("", $"Mechanicus Mission Accepted: {_techs_required} of your {_eligible_roles}s and a Land Raider are to be stationed at {_mission_loc} for {timer} months.", system.name); mark("green"); title = "Mechanicus Mission Accepted"; } static __mech_raider_per_turn = function() { - var _techs = collect_role_group(SPECIALISTS_TECHMARINES, false, true, [system.name, planet, -1]); + var _techs = collect_role_group(SPECIALISTS_TECHMARINES,[system.name, planet, -1] , false,{},true ); var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); - if ((array_length(_techs) >= data.techs_required) && (_lr_count >= 1)) { + if ((_techs.number() >= data.techs_required) && (_lr_count >= 1)) { var _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); if (_percent_complete >= 100) { @@ -1132,7 +1132,7 @@ static __mech_mars_resolve = function() { delete_mission = true; var _techs_taken = 0; var _techs = collect_role_group([SPECIALISTS_TECHMARINES,false,true],system.name); - for (i = 0; i < array_length(_techs); i++) { + for (var i = 0; i < array_length(_techs); i++) { var _unit = _techs[i]; system.p_player[planet] -= _unit.get_unit_size(); _unit.location_string = "Mechanicus Vessel"; @@ -1213,19 +1213,20 @@ static __provide_garrison_resolve = function() { exit; } - p_data.garrisons.update(); - if (p_data.current_owner != eFACTION.IMPERIUM || !p_data.garrisons.garrison_force) { + var _garrison = p_data.garrisons; + _garrison.update(); + if (p_data.current_owner != eFACTION.IMPERIUM || !_garrison.garrison_force) { p_data.add_disposition(-20); scr_popup($"Agreed Garrison of {p_data.name()}", $"your agreed garrison of {p_data.name()} was cut short by your chapter the planetary governor has expressed his displeasure (disposition -20)", "", ""); return; } var _mission_string = $"The garrison on {p_data.name()} has finished the period of garrison support agreed with the planetary governor."; - var _result = p_data.garrisons.garrison_disposition_change(); - if (!p_data.garrisons.garrison_leader) { - p_data.garrisons.find_leader(); + var _result = _garrison.garrison_disposition_change(); + if (!_garrison.garrison_leader) { + _garrison.find_leader(); } - var _leader = garrisons.garrison_leader; + var _leader = _garrison.garrison_leader; var _effect = 0; if (_result == "none") { @@ -1247,8 +1248,8 @@ static __provide_garrison_resolve = function() { _mission_string += $"while stationed {_leader.name_role()} makes several notable observations and is able to instruct the planets defense core leaving the world better defended (fortifications+1)."; } //TODO just generally apply this each turn with a garrison to see if a cult is found - if (has_feature(eP_FEATURES.GENE_STEALER_CULT)) { - var _cult = get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; + if (p_data.has_feature(eP_FEATURES.GENE_STEALER_CULT)) { + var _cult = p_data.get_features(eP_FEATURES.GENE_STEALER_CULT)[0]; if (_cult.hiding) { _widom_test = _tester.standard_test(_leader, "wisdom", 0, ["tyranids"]); if (_widom_test[0]) { @@ -1951,7 +1952,7 @@ static __governor_purge_enemies_init = function(){ delete_mission = true; exit; } - data.enemy = _enemy; + data.target = _enemy; stage_id = "preliminary"; data.applicant = "Governor"; } diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 90e168a0c1..12a08696bf 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -7,8 +7,8 @@ function spawn_mechanicus_mission(chosen_mission = "random") { if (array_length(_forge_stars)) { array_push(mechanicus_missions, "mech_bionics"); - var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true]); - if (array_length(_techs >= 3)) { + var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true],"",false,{},true); + if (_techs.number >= 3) { array_push(mechanicus_missions, "mech_raider"); } } From 3eb7d5e66dbdf8c475d9a816d0cf0a2f6431ac8c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:15:51 +0100 Subject: [PATCH 073/118] move rewards move rewards from mech missions into correct sequence position in PlanetProblem --- scripts/PlanetProblem/PlanetProblem.gml | 150 ++++++++++++++++-- .../scr_mission_reward/scr_mission_reward.gml | 138 ---------------- 2 files changed, 137 insertions(+), 151 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index f0bdbebaae..63b3cc7ec8 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -966,17 +966,83 @@ static __mech_raider_init = function(){ static __mech_raider_per_turn = function() { var _techs = collect_role_group(SPECIALISTS_TECHMARINES,[system.name, planet, -1] , false,{},true ); var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); + var _percent_complete = 0; if ((_techs.number() >= data.techs_required) && (_lr_count >= 1)) { var _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); - if (_percent_complete >= 100) { - delete_mission = true; - scr_mission_reward("mech_raider", system, planet); - timer = -1 - per_turn_checks = false; - zero_timer_checks = false; + } + if (_percent_complete < 100){ + exit; + } + var _cleanup = array_create(11, 0); + delete_mission = true; + scr_mission_reward("mech_raider", system, planet); + timer = -1 + per_turn_checks = false; + zero_timer_checks = false; + + var _roll1 = roll_dice_chapter(1, 100, "low"); + var result = ""; + + if (_roll1 <= 33) { + result = "New"; + } + if ((_roll1 > 33) && (_roll1 <= 66)) { + result = "Land Raider"; + } + if (_roll1 > 66) { + result = "Requisition"; + } + var _tech_role = obj_ini.player_role_data[eROLE.TECHMARINE].role; + + if (result == "New") { + scr_popup("Mechanicus Mission Completed", $"Your {obj_ini.player_role_data[eROLE.TECHMARINE].role} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 300 Requisition has been given to your Chapter and relations are better than before.", "mechanicus", ""); + obj_controller.requisition += 300; + alter_disposition(eFACTION.MECHANICUS ,2); + var _found = false; + for (var com = 0; com <= obj_ini.companies; com++) { + if (_found) { + break; + } + for (var i = 1; i <= 100; i++) { + if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { + destroy_vehicle(com, i); + _found = true; + break; + } + } + } + } + if (result == "Land Raider") { + scr_popup("Mechanicus Mission Completed", $"Your {_tech_role} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. A new Land Raider has been provided in return.", "mechanicus", ""); + var _found = false; + alter_disposition(eFACTION.MECHANICUS ,1); + for (var com = 0; com <= obj_ini.companies; com++) { + if (_found) { + break; + } + for (var i = 1; i <= 100; i++) { + if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { + _found = true; + obj_ini.veh_hp[com][i] = 100; + } + } + } + } + if (result == "Requisition") { + scr_popup("Mechanicus Mission Completed", $"Your {_tech_role} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 600 Requisition has been given to your Chapter as compensation.", "mechanicus", ""); + obj_controller.requisition += 600; + alter_disposition(eFACTION.MECHANICUS ,1); + } + + for (var i = 0; i <= obj_ini.companies; i++) { + if (_cleanup[i] == 1) { + with (obj_ini) { + scr_vehicle_order(i); + } } } + } static __mech_raider_resolve = function() { @@ -991,17 +1057,75 @@ static __mech_raider_resolve = function() { static __mech_bionics_per_turn = function() { var _units = p_data.collect_planet_group(); var _bionics = _units.tally_attr("bionics"); + var _percent_complete = 0; if (_bionics >= 10) { - var _percent_complete = __increment_mission_completion(); + _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); - if (_percent_complete >= 100) { - delete_mission = true; - scr_mission_reward("mech_bionics", id, planet); - timer = -1 - per_turn_checks = false; - zero_timer_checks = false; + } + if (_percent_complete < 100){ + exit; + } + var _cleanup = array_create(11, 0); + delete_mission = true; + timer = -1 + per_turn_checks = false; + zero_timer_checks = false; + var _roll1 = roll_dice_chapter(1, 100, "low"); + var result = ""; + + if (_roll1 <= 33) { + result = "Requisition"; + } + if ((_roll1 > 33) && (_roll1 <= 66)) { + result = "Bionics"; + } + if (_roll1 > 66) { + result = "Marines Lost"; + } + mech_disp_change = 0; + var _text = "The Adeptus Mechanicus have finished experimenting on your marines"; + var _marines = collect_role_group("all", [star.name, planet, -1], false, {}, true); + if (result == "Marines Lost") { + _text += "- unfortunantly none of them have survived. 150 Requisition has provided as weregild for each Astartes lost."; + mech_disp_change = 2; + obj_controller.requisition += 150 * _marines.number(); + _marines.kill_percent(100); + } else if (result == "Bionics" || result == "Requisition") { + obj_controller.disposition[3] += 1; + mech_disp_change = 1; + + if (result == "Bionics") { + var _new_bionics = irandom_range(40, 100); + scr_add_item("Bionics", _new_bionics); + _text += $" A large amount of additional Bionics have been provided by the Mechanicus as a reward ( X{_new_bionics} Bionics added to stocks)"; + } else if (result == "Requisition") { + req_gain = irandom_range(200, 650); + _text += $"{req_gain} Requisition has been provided by the Mechanicus as a reward."; + obj_controller.requisition += req_gain; + } + var _limit = 0; + for (var i = 0; i < array_length(_marines.units); i++) { + var _unit = _marines.units[i]; + if (_unit.bionics > 0) { + _unit.update_health(irandom_range(2, 80)); + + if (!_unit.has_trait("flesh_is_weak")) { + _unit.update_loyalty(-20); + } + + repeat (choose(2, 3, 4)) { + _unit.add_bionics(); + } + _limit++; + } + if (_limit >= 10) { + break; + } } } + _text += $"\n mechanics Disposition {mech_disp_change > 0 ? "+" : "-"}{mech_disp_change}"; + scr_popup("Mechanicus Mission Completed", _text, "mechanicus"); + sort_all_companies_to_map(_cleanup); } static __mech_bionics_resolve = function() { diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index c673ffb77d..93fed9e8ef 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -99,143 +99,5 @@ function scr_mission_reward(mission, star, planet) { sort_all_companies_to_map(cleanup); } - if (mission == "mech_raider") { - var roll1 = roll_dice_chapter(1, 100, "low"); - var result = ""; - - if (roll1 <= 33) { - result = "New"; - } - if ((roll1 > 33) && (roll1 <= 66)) { - result = "Land Raider"; - } - if (roll1 > 66) { - result = "Requisition"; - } - - if (result == "New") { - scr_popup("Mechanicus Mission Completed", $"Your {obj_ini.player_role_data[eROLE.TECHMARINE].role} have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 300 Requisition has been given to your Chapter and relations are better than before.", "mechanicus", ""); - obj_controller.requisition += 300; - obj_controller.disposition[3] += 2; - var onceh = 0; - for (var com = 0; com <= 10; com++) { - if (onceh == 0) { - for (var i = 1; i <= 100; i++) { - if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { - onceh = 1; - obj_ini.veh_race[com][i] = 0; - obj_ini.veh_loc[com][i] = ""; - obj_ini.veh_role[com][i] = ""; - obj_ini.veh_lid[com][i] = -1; - obj_ini.veh_wid[com][i] = 0; - obj_ini.veh_wep1[com][i] = ""; - obj_ini.veh_wep2[com][i] = ""; - obj_ini.veh_wep3[com][i] = ""; - obj_ini.veh_upgrade[com][i] = ""; - obj_ini.veh_acc[com][i] = ""; - obj_ini.veh_hp[com][i] = 0; - obj_ini.veh_chaos[com][i] = 0; - obj_ini.veh_uid[com][i] = 0; - cleanup[com] = 1; - star.p_player[planet] -= 20; - } - } - } else { - break; - } - } - } - if (result == "Land Raider") { - scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. A new Land Raider has been provided in return.", "mechanicus", ""); - var onceh = 0; - obj_controller.disposition[3] += 1; - for (var com = 0; com <= 10; com++) { - if (onceh == 0) { - for (var i = 1; i <= 100; i++) { - if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { - onceh = 1; - obj_ini.veh_hp[com][i] = 100; - } - } - } else { - break; - } - } - } - if (result == "Requisition") { - scr_popup("Mechanicus Mission Completed", "Your " + string(obj_ini.player_role_data[eROLE.TECHMARINE].role) + " have worked with the Adeptus Mechanicus in a satisfactory manor. The testing and training went well, but your Land Raider was ultimately lost. 600 Requisition has been given to your Chapter as compensation.", "mechanicus", ""); - obj_controller.requisition += 600; - obj_controller.disposition[3] += 1; - } - - for (var i = 0; i <= 10; i++) { - if (cleanup[i] == 1) { - obj_controller.temp[3000] = real(i); - with (obj_ini) { - scr_vehicle_order(obj_controller.temp[3000]); - } - } - } - } - cleanup = array_create(11, 0); - - if (mission == "mech_bionics") { - var roll1 = roll_dice_chapter(1, 100, "low"); - var result = ""; - - if (roll1 <= 33) { - result = "Requisition"; - } - if ((roll1 > 33) && (roll1 <= 66)) { - result = "Bionics"; - } - if (roll1 > 66) { - result = "Marines Lost"; - } - mech_disp_change = 0; - var _text = "The Adeptus Mechanicus have finished experimenting on your marines"; - var _marines = collect_role_group("all", [star.name, planet, -1], false, {}, true); - if (result == "Marines Lost") { - _text += "- unfortunantly none of them have survived. 150 Requisition has provided as weregild for each Astartes lost."; - mech_disp_change = 2; - obj_controller.requisition += 150 * _marines.number(); - _marines.kill_percent(100); - } else if (result == "Bionics" || result == "Requisition") { - obj_controller.disposition[3] += 1; - mech_disp_change = 1; - - if (result == "Bionics") { - var _new_bionics = irandom_range(40, 100); - scr_add_item("Bionics", _new_bionics); - _text += $" A large amount of additional Bionics have been provided by the Mechanicus as a reward ( X{_new_bionics} Bionics added to stocks)"; - } else if (result == "Requisition") { - req_gain = irandom_range(200, 650); - _text += $"{req_gain} Requisition has been provided by the Mechanicus as a reward."; - obj_controller.requisition += req_gain; - } - var _limit = 0; - for (var i = 0; i < array_length(_marines.units); i++) { - var _unit = _marines.units[i]; - if (_unit.bionics > 0) { - _unit.update_health(irandom_range(2, 80)); - - if (!_unit.has_trait("flesh_is_weak")) { - _unit.update_loyalty(-20); - } - - repeat (choose(2, 3, 4)) { - _unit.add_bionics(); - } - _limit++; - } - if (_limit >= 10) { - break; - } - } - } - _text += $"\n mechanics Disposition {mech_disp_change > 0 ? "+" : "-"}{mech_disp_change}"; - scr_popup("Mechanicus Mission Completed", _text, "mechanicus"); - sort_all_companies_to_map(cleanup); - } } From 5de9e666d3b9afdc55f8c0f71fe1323ebd13db0a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:18:12 +0100 Subject: [PATCH 074/118] minor review points --- scripts/PlanetProblem/PlanetProblem.gml | 6 +++--- scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 63b3cc7ec8..8cbbd4ebb7 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1946,8 +1946,8 @@ static __inquisition_tyranid_org_battle_aftermath = function(){ } static __hive_fleet_to_cult_init = function(){ - var _x1 = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + x; - var _y1 = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + y; + var _x1 = (random_range(room_width * 1.25, room_width * 2) * choose(-1, 1)) + system.x; + var _y1 = (random_range(room_height * 1.25, room_height * 2) * choose(-1, 1)) + system.y; var _fleet = create_enemy_fleet(_x1, _y1, eFACTION.TYRANIDS); _fleet.sprite_index = spr_fleet_tyranid; _fleet.image_speed = 0; @@ -2007,7 +2007,7 @@ static __inquisition_purge_init = function(){ mission: self, options: __inquisition_mission_options(), }; - scr_popup("Inquisition Mission", text, "inquisition", _pop_data); + scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } static __inquisition_purge_accept = function(){ diff --git a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml index 12a08696bf..c897af06ae 100644 --- a/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml +++ b/scripts/scr_mechanicus_missions/scr_mechanicus_missions.gml @@ -8,7 +8,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { if (array_length(_forge_stars)) { array_push(mechanicus_missions, "mech_bionics"); var _techs = collect_role_group([SPECIALISTS_TECHMARINES, false, true],"",false,{},true); - if (_techs.number >= 3) { + if (_techs.number() >= 3) { array_push(mechanicus_missions, "mech_raider"); } } @@ -136,7 +136,7 @@ function spawn_mechanicus_mission(chosen_mission = "random") { function accept_mechanicus_tomb_mission() { var _planet = false; var _star = pop_data.star; - for (var i = 1; i < _star.planets; i++) { + for (var i = 1; i <= _star.planets; i++) { if (awake_tomb_world(_star.p_feature[i]) != 0) { _planet = i; break; From 76bbc60965a75b8cfe0f7f7ca1fd3a2a4b2d968a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:22:25 +0100 Subject: [PATCH 075/118] typos --- scripts/PlanetProblem/PlanetProblem.gml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 8cbbd4ebb7..5f1aee7af1 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1,8 +1,8 @@ //All missions that run on a planet now need their own PlanetProblem instance //missions for the most part can only run from predefined points in the code -// to run from each of these points easch mission must have a registered function these functions are then called implicitly +// to run from each of these points each mission must have a registered function these functions are then called implicitly //each function follows the format `___` -//each one can have extensions written to account for different stage_id's by instead usig the syntax +//each one can have extensions written to account for different stage_id's by instead using the syntax //`___S` if stage id is "" `___` will be used /* the current entry points for the code are "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn @@ -40,7 +40,7 @@ other info //ANYTIME an exception is caught on a entry point for a mission the mission is prematurely deleted this ensures the player is not unfairly penalised for errors -/// @param {sring} name +/// @param {string} name /// @param {Real} timer /// @param {struct} data /// @param {constructor PlanetData} planet From 708045fe4f3f7da97ec0c52b71044495e9fd0e30 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:29:37 +0100 Subject: [PATCH 076/118] argument changes --- scripts/PlanetProblem/PlanetProblem.gml | 29 ++++++++++++------------- scripts/SystemProblem/SystemProblem.gml | 8 +++---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 5f1aee7af1..a81ea0ac9f 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -968,15 +968,14 @@ static __mech_raider_per_turn = function() { var _lr_count = scr_vehicle_count("Land Raider", [system.name, planet, -1]); var _percent_complete = 0; if ((_techs.number() >= data.techs_required) && (_lr_count >= 1)) { - var _percent_complete = __increment_mission_completion(); + _percent_complete = __increment_mission_completion(); scr_alert("", "mission", $"Mechanicus Mission on {p_data.name()} is {floor(_percent_complete)}% complete.", 0, 0); } if (_percent_complete < 100){ exit; } - var _cleanup = array_create(11, 0); + var _cleanup = array_create(11, false); delete_mission = true; - scr_mission_reward("mech_raider", system, planet); timer = -1 per_turn_checks = false; zero_timer_checks = false; @@ -1005,8 +1004,9 @@ static __mech_raider_per_turn = function() { break; } for (var i = 1; i <= 100; i++) { - if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { + if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == system.name) && (obj_ini.veh_wid[com][i] == planet)) { destroy_vehicle(com, i); + _cleanup[com] = true; _found = true; break; } @@ -1022,7 +1022,7 @@ static __mech_raider_per_turn = function() { break; } for (var i = 1; i <= 100; i++) { - if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == star.name) && (obj_ini.veh_wid[com][i] == planet)) { + if ((obj_ini.veh_role[com][i] == "Land Raider") && (obj_ini.veh_loc[com][i] == system.name) && (obj_ini.veh_wid[com][i] == planet)) { _found = true; obj_ini.veh_hp[com][i] = 100; } @@ -1036,7 +1036,7 @@ static __mech_raider_per_turn = function() { } for (var i = 0; i <= obj_ini.companies; i++) { - if (_cleanup[i] == 1) { + if (_cleanup[i]) { with (obj_ini) { scr_vehicle_order(i); } @@ -1082,26 +1082,25 @@ static __mech_bionics_per_turn = function() { if (_roll1 > 66) { result = "Marines Lost"; } - mech_disp_change = 0; + var _mech_disp_change = 0; var _text = "The Adeptus Mechanicus have finished experimenting on your marines"; - var _marines = collect_role_group("all", [star.name, planet, -1], false, {}, true); + var _marines = collect_role_group("all", [system.name, planet, -1], false, {}, true); if (result == "Marines Lost") { _text += "- unfortunantly none of them have survived. 150 Requisition has provided as weregild for each Astartes lost."; - mech_disp_change = 2; + _mech_disp_change = 2; obj_controller.requisition += 150 * _marines.number(); _marines.kill_percent(100); } else if (result == "Bionics" || result == "Requisition") { - obj_controller.disposition[3] += 1; - mech_disp_change = 1; + _mech_disp_change = 1; if (result == "Bionics") { var _new_bionics = irandom_range(40, 100); scr_add_item("Bionics", _new_bionics); _text += $" A large amount of additional Bionics have been provided by the Mechanicus as a reward ( X{_new_bionics} Bionics added to stocks)"; } else if (result == "Requisition") { - req_gain = irandom_range(200, 650); - _text += $"{req_gain} Requisition has been provided by the Mechanicus as a reward."; - obj_controller.requisition += req_gain; + var _req_gain = irandom_range(200, 650); + _text += $"{_req_gain} Requisition has been provided by the Mechanicus as a reward."; + obj_controller.requisition += _req_gain; } var _limit = 0; for (var i = 0; i < array_length(_marines.units); i++) { @@ -1123,7 +1122,7 @@ static __mech_bionics_per_turn = function() { } } } - _text += $"\n mechanics Disposition {mech_disp_change > 0 ? "+" : "-"}{mech_disp_change}"; + _text += $"\n{alter_disposition(eFACTION.MECHANICUS, _mech_disp_change)}"; scr_popup("Mechanicus Mission Completed", _text, "mechanicus"); sort_all_companies_to_map(_cleanup); } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 11a5a5bc5d..4b317887b5 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -1,12 +1,12 @@ /// @param {sring} name /// @param {struct} data -function SystemProblem(name, data = {}, system) constructor{ +function SystemProblem(_name, _data = {}, _system) constructor{ timer = -1; f_type = eP_FEATURES.MISSION; -p_id = name; -data = data; +p_id = _name; +data = _data; stage_id = ""; -self.system = system; +system = _system; zero_timer_checks = true; per_turn_checks = true; delete_mission = false; From 9b7070c5c77ba90d76431b7a8916d97f1e75ee95 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:39:36 +0100 Subject: [PATCH 077/118] wrong arguments to alter_disposition --- scripts/PlanetProblem/PlanetProblem.gml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index a81ea0ac9f..8eee5100ad 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -836,7 +836,7 @@ static __inquisition_spyrer_battle_aftermath = function(){ scr_popup("Inquisition Mission Completed", _tixt, p_id, ""); var _disp_gain = obj_controller.demanding ? choose(0, 0, 1) : 2; - var _disp_gain_string = alter_disposition(eFACTION.INQUISITION, _disp_gain); + var _disp_gain_string = alter_disposition(eFACTION.INQUISITION, _disp_gain, true); scr_event_log("", $"Inquisition Mission Completed: The Spyrer on {system.name} {planet} has been removed. {_disp_gain_string}", system.name); scr_gov_disp(system.name, planet, choose(1, 2, 3, 4)); @@ -1122,7 +1122,7 @@ static __mech_bionics_per_turn = function() { } } } - _text += $"\n{alter_disposition(eFACTION.MECHANICUS, _mech_disp_change)}"; + _text += $"\n{alter_disposition(eFACTION.MECHANICUS, _mech_disp_change, true)}"; scr_popup("Mechanicus Mission Completed", _text, "mechanicus"); sort_all_companies_to_map(_cleanup); } @@ -1232,7 +1232,7 @@ static __mech_tomb_battle_aftermath = function() { if (obj_ncombat.defeat) { delete_mission = true; - var _disp_change = alter_disposition(eFACTION.MECHANICUS, -10); + var _disp_change = alter_disposition(eFACTION.MECHANICUS, -10, true); if (data.battle_key == "study2a") { scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust, and the Adeptus Mechanicus is furious with your chapter for not providing enough security. Relations with them are worse than before. {_disp_change}", "", ""); @@ -1240,7 +1240,7 @@ static __mech_tomb_battle_aftermath = function() { if (data.battle_key == "study2b") { battle_object.p_necrons[battle_id] = 5; awaken_tomb_world(battle_object.p_feature[battle_id]); - _disp_change = alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]]); + _disp_change = alter_dispositions([[eFACTION.MECHANICUS, -15], [eFACTION.INQUISITION, -5]], true); scr_popup("Mechanicus Mission Failed", $"All of your Astartes and the Mechanicus Research party have been killed down to the last man. The research is a bust. To make matters worse the Necron Tomb has fully awakened- countless numbers of the souless machines are now pouring out of the tomb. The Adeptus Mechanicus are furious with your chapter. {_disp_change}", "necron_army", ""); scr_alert("", "inquisition", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb", 0, 0); scr_event_log("", "The Inquisition is displeased with your Chapter for tampering with and awakening a Necron Tomb"); From e2dcad9a3f6ff94d6cc665a771bbea000886bb10 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:40:46 +0100 Subject: [PATCH 078/118] arg order --- objects/obj_star/Create_0.gml | 4 ++-- scripts/SystemProblem/SystemProblem.gml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index fbdb02c983..27ee3cdf3c 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -120,8 +120,8 @@ add_feature = function(planet, feature) { system_problems = []; -add_problem = function(p_id, data){ - var _prob = new SystemProblem(name, data, system); +add_problem = function(p_id, data = {}){ + var _prob = new SystemProblem(name, SystemProblem, data); array_push(system_problems, _prob); return _prob; } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 4b317887b5..746779d621 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -1,6 +1,6 @@ /// @param {sring} name /// @param {struct} data -function SystemProblem(_name, _data = {}, _system) constructor{ +function SystemProblem(_name, _system, _data = {}) constructor{ timer = -1; f_type = eP_FEATURES.MISSION; p_id = _name; From dac29f7110689d879aaf5ee3d453da46116ea4e5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 16:42:18 +0100 Subject: [PATCH 079/118] passing name not p_id --- objects/obj_star/Create_0.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 27ee3cdf3c..1b26b3878d 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -121,7 +121,7 @@ add_feature = function(planet, feature) { system_problems = []; add_problem = function(p_id, data = {}){ - var _prob = new SystemProblem(name, SystemProblem, data); + var _prob = new SystemProblem(p_id, self, data); array_push(system_problems, _prob); return _prob; } From eb39ecaef8f4e647d704149abd2efd409a4228d5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 17:04:49 +0100 Subject: [PATCH 080/118] add fleet problems --- ChapterMaster.yyp | 1 + objects/obj_p_fleet/Create_0.gml | 43 ++++- scripts/FleetProblem/FleetProblem.gml | 212 ++++++++++++++++++++++++ scripts/FleetProblem/FleetProblem.yy | 13 ++ scripts/PlanetProblem/PlanetProblem.gml | 2 - 5 files changed, 265 insertions(+), 6 deletions(-) create mode 100644 scripts/FleetProblem/FleetProblem.gml create mode 100644 scripts/FleetProblem/FleetProblem.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 0a9916eb57..d429ee622e 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -753,6 +753,7 @@ {"id":{"name":"ErrorHandler","path":"scripts/ErrorHandler/ErrorHandler.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":"FleetProblem","path":"scripts/FleetProblem/FleetProblem.yy",},}, {"id":{"name":"GitHub","path":"scripts/GitHub/GitHub.yy",},}, {"id":{"name":"GitHubBugReporter","path":"scripts/GitHubBugReporter/GitHubBugReporter.yy",},}, {"id":{"name":"GitHubContent","path":"scripts/GitHubContent/GitHubContent.yy",},}, diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index b966ba1002..b4d362f696 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -48,6 +48,21 @@ acted = 0; hurssy = 0; hurssy_time = 0; /// Called from save function to take all object variables and convert them to a json savable format and return it + +problems = []; +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +/// @returns {Struct.FleetProblem} +add_problem = function(_name, _timer, _data = {}){ + var _problem = new FleetProblem(_name, _timer, _data, self); + if (_problem.delete_mission){ + return undefined; + } + array_push(problems, _problem); + return _problem; +} + serialize = function() { var object_fleet = self; @@ -62,15 +77,21 @@ serialize = function() { "serialize", "deserialize", "orbiting", + "problems", ]; copy_serializable_fields(object_fleet, save_data, excluded_from_save); + save_data.problems = []; + for (var i = 0; i < array_length(problems); i++) { + array_push(save_data.problems, problems[i].save()); + } + return save_data; }; deserialize = function(save_data) { - var exclusions = ["orbiting"]; // skip automatic setting of certain vars, handle explicitly later + var exclusions = ["orbiting", "problems"]; // skip automatic setting of certain vars, handle explicitly later // Automatic var setting var all_names = struct_get_names(save_data); @@ -88,7 +109,21 @@ deserialize = function(save_data) { } } - set_player_fleet_image(); -}; + // Problems, old saves won't have this key + problems = []; + if (struct_exists(save_data, "problems")) { + for (var i = 0; i < array_length(save_data.problems); i++) { + try { + // empty p_id stops __init from running, load() then restores the real p_id and timer + var _problem = new FleetProblem("", 0, {}, self); + _problem.load(save_data.problems[i]); + _problem.fleet = self; + array_push(problems, _problem); + } catch (e) { + LOGGER.exception("Fleet problem deserialization failed", e); + } + } + } -#endregion + set_player_fleet_image(); +}; \ No newline at end of file diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml new file mode 100644 index 0000000000..68fb17ae53 --- /dev/null +++ b/scripts/FleetProblem/FleetProblem.gml @@ -0,0 +1,212 @@ +//All missions that run on a fleet need their own FleetProblem instance +//missions for the most part can only run from predefined points in the code +// to run from each of these points each mission must have a registered function these functions are then called implicitly +//each function follows the format `___` +/* the current entry points for the code are + "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn + - runs via basic_turn_end + + "init" - runs immediately after problem is created often used to populate initial popup or stack popup for turn end + + "on_arrival" - runs when the fleet arrives at a star, event_data holds {star} + "on_load" - runs when units are loaded onto the fleet, event_data holds {units} + "on_unload" - runs when units are unloaded from the fleet, event_data holds {units} + "on_split" - runs on the original fleet when it splits, event_data holds {new_fleet} + "on_merge" - runs on the receiving fleet when another fleet merges into it, event_data holds {merged_fleet} + "on_destruction" - runs when the fleet is destroyed, the mission is deleted after this function has run + - must be triggered BEFORE the fleet instance is destroyed + +- other than these entry points and any other later defined positions mission specific code should not run outside of the FleetProblem container + +- to set an entry point up simply register the function as a static e.g + if i create static __example_per_turn once an "example" problem is registered on a fleet the per turn check will run + no other code is required + +other info + - the owning fleet must have a `problems = []` array in its create event + - entry points that receive extra information read it from event_data, which only exists for the duration of the call + - set a mission for deletion by setting delete_mission = true; this will delete the mission after the current function + has finished executing + - functions prefixed with `__` are only accessible from within the FleetProblem's internal scope +*/ + +//ANYTIME an exception is caught on a entry point for a mission the mission is prematurely deleted this ensures the player is not unfairly penalised for errors + +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +/// @param {Id.Instance.obj_p_fleet} _fleet +function FleetProblem(_name, _timer, _data, _fleet) constructor{ +timer = _timer; +uid = scr_uuid_generate(); +p_id = _name; +data = _data; +fleet = _fleet; +delete_mission = false; + +static __refresh_data = function(){ + if (!instance_exists(fleet)){ + delete_mission = true; + } +} + +stage_id = ""; +if (struct_exists(data, "stage")){ + stage_id = data.stage; +} + +remove = false; +per_turn_checks = true; + +static has_data = function(key){ + return struct_exists(data, key); +} + +static save = function(){ + var _save_copy = variable_clone(self); + struct_remove(_save_copy, "fleet"); + return _save_copy; +} + +//the owning fleet must re-attach itself after loading (problem.fleet = self) +static load = function(data){ + move_data_to_current_scope(data); +} + +static description = function(){ + var _n = mission_name_key(p_id); + _n = _n == "" ? p_id : _n; + return _n; +} + +//requires the completion and required_months flag to be in the data struct +static __increment_mission_completion = function() { + if (!struct_exists(data, "completion")) { + data.completion = 0; + } + data.completion++; + if (!struct_exists(data, "required_months") || data.required_months <= 0) { + LOGGER.error("Invalid required_months in mission_data"); + return 0; + } + return (data.completion / data.required_months) * 100; +} + +static __popup_delete = function(){ + with(obj_popup){ + popup_default_close(); + } + __check_delete(); +} + +static __check_delete = function(){ + if (timer == -1 || (delete_mission)){ + if (!instance_exists(fleet)){ + exit; + } + var _prob = -1; + for (var i = 0; i < array_length(fleet.problems); i++){ + if (fleet.problems[i] == self){ + _prob = i; + } + } + if (_prob > -1){ + array_delete(fleet.problems, _prob, 1); + } + } +} + +static __handle_triggered_mission_func = function(func){ + if (!is_undefined(func)){ + __refresh_data(); + try { + func(); + } catch (_exception) { + delete_mission = true; + ERROR_HANDLER.handle_exception(_exception); + } + } + __check_delete(); + obj_controller.location_viewer.update_mission_log(); +} + +static find_func_ref = function(trigger_string){ + var _func_string = "__" + p_id + "_" + trigger_string; + return _func_string; +} + +static has_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + return struct_exists(self,_func_string); +} + +static find_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + if (struct_exists(self,_func_string)){ + return self[$ _func_string] + } + return undefined; +} + +//runs the entry point with event_data available for the duration of the call +static __trigger_with_event = function(trigger_string, _event_data){ + var _func = find_func(trigger_string); + if (is_undefined(_func)){ + exit; + } + event_data = _event_data; + __handle_triggered_mission_func(_func); + struct_remove(self, "event_data"); +} + +static basic_turn_end = function(){ + timer--; + if ((timer > -1) && per_turn_checks) { + var _func = find_func("per_turn"); + __handle_triggered_mission_func(_func); + } +} + +/// @param {Id.Instance.obj_star} star +static on_arrival = function(star){ + __trigger_with_event("on_arrival", {star}); +} + +/// @param {array} units +static on_load = function(units){ + __trigger_with_event("on_load", {units}); +} + +/// @param {array} units +static on_unload = function(units){ + __trigger_with_event("on_unload", {units}); +} + +/// @param {Id.Instance.obj_p_fleet} new_fleet +static on_split = function(new_fleet){ + __trigger_with_event("on_split", {new_fleet}); +} + +/// @param {Id.Instance.obj_p_fleet} merged_fleet +static on_merge = function(merged_fleet){ + __trigger_with_event("on_merge", {merged_fleet}); +} + +//call this before the fleet instance is destroyed +static on_destruction = function(){ + __trigger_with_event("on_destruction", {}); + delete_mission = true; + __check_delete(); +} + +static __init = function(){ + if (p_id == ""){ + exit; + } + var _func = find_func("init"); + if (!is_undefined(_func)){ + __handle_triggered_mission_func(_func); + } +} +__init(); +} \ No newline at end of file diff --git a/scripts/FleetProblem/FleetProblem.yy b/scripts/FleetProblem/FleetProblem.yy new file mode 100644 index 0000000000..d8ada024c5 --- /dev/null +++ b/scripts/FleetProblem/FleetProblem.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"FleetProblem", + "isCompatibility":false, + "isDnD":false, + "name":"FleetProblem", + "parent":{ + "name":"Constructors", + "path":"folders/Scripts/Constructors.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 8eee5100ad..b93c0a7afb 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -2,8 +2,6 @@ //missions for the most part can only run from predefined points in the code // to run from each of these points each mission must have a registered function these functions are then called implicitly //each function follows the format `___` -//each one can have extensions written to account for different stage_id's by instead using the syntax -//`___S` if stage id is "" `___` will be used /* the current entry points for the code are "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn "resolve" - runs when the mission timer hits 0 often contains the failure conditions for the mission From 950459d7362946647e54c150da37af8e84bb4f57 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 18:38:29 +0100 Subject: [PATCH 081/118] move end rurn player fleet stuff to a function call --- objects/obj_p_fleet/Alarm_1.gml | 161 ----------------- .../scr_controller_helpers.gml | 6 +- .../scr_player_fleet_functions.gml | 164 ++++++++++++++++++ 3 files changed, 169 insertions(+), 162 deletions(-) diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index b0656e3c18..e69de29bb2 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -1,161 +0,0 @@ -try { - acted = 0; - - if (action == "Lost") { - set_fleet_location("Lost"); - exit; - } else if (action == "") { - var spid = instance_nearest(x, y, obj_star); - fleet_register_at_star(self, spid); - - if (instance_exists(orbiting)) { - if (orbiting.visited == 0) { - for (var planet_num = 1; planet_num <= orbiting.planets; planet_num += 1) { - if (array_length(orbiting.p_feature[planet_num]) != 0) { - with (orbiting) { - scr_planetary_feature(planet_num); - } - } - } - orbiting.visited = 1; - } - - meet_system_governors(orbiting); - } - } else if (array_contains(global.fleet_move_options, action)) { - set_fleet_location("Warp"); - - if (instance_nearest(action_x, action_y, obj_star).storm > 0) { - exit; - } - - var spid = point_distance(x, y, action_x, action_y); - spid = spid / action_eta; - var dir = point_direction(x, y, action_x, action_y); - - x = x + lengthdir_x(spid, dir); - y = y + lengthdir_y(spid, dir); - - action_eta -= 1; - just_left = false; - - if ((action_eta == 0) && (action == "crusade1")) { - var dr = point_direction(room_width / 2, room_height / 2, x, y); - action_x = x + lengthdir_x(600, dr); - action_y = y + lengthdir_y(600, dr); - action = "crusade2"; - set_fleet_movement(false, "crusade2"); - } - if ((action_eta == 0) && (action == "crusade2")) { - with (obj_star) { - if (owner > 5) { - instance_deactivate_object(id); - } - var enemies = false; - for (var i = 6; i < 13; i++) { - if (scr_orbiting_fleet(i) != noone) { - enemies = true; - break; - } - } - if (enemies) { - instance_deactivate_object(id); - } - } - var ret = instance_nearest(x, y, obj_star); - action_x = ret.x; - action_y = ret.y; - action = "crusade3"; - set_fleet_movement(false, "crusade3"); - instance_activate_object(obj_star); - } - if ((action_eta == 0) && (action == "crusade3")) { - // Popup here - scr_crusade(); - action = ""; - } - - if ((action_eta == 0) && (action != "crusade1") && (action != "crusade2")) { - // Check to see if there are already player ships in the spot where this object will move to - // If yes, combine the two of them - - var steh = instance_nearest(action_x, action_y, obj_star); - if (steh.vision == 0) { - steh.vision = 1; - } - fleet_register_at_star(id, steh); - - meet_system_governors(steh); - - if ((steh.p_owner[1] == eFACTION.ECCLESIARCHY) || (steh.p_owner[2] == eFACTION.ECCLESIARCHY) || (steh.p_owner[3] == eFACTION.ECCLESIARCHY) || (steh.p_owner[4] == eFACTION.ECCLESIARCHY)) { - if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { - obj_controller.known[eFACTION.ECCLESIARCHY] = 1; - } - } - if ((steh.owner == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0) && (obj_controller.known[eFACTION.ELDAR] == 0)) { - obj_controller.known[eFACTION.ELDAR] = 1; - } - if ((steh.owner == eFACTION.TAU) && (obj_controller.faction_defeated[8] == 0) && (obj_controller.known[eFACTION.TAU] == 0)) { - obj_controller.known[eFACTION.TAU] = 1; - } - - action = ""; - x = action_x; - y = action_y; - action_x = 0; - action_y = 0; - - var i; - set_fleet_location(steh.name); - if (steh.visited == 0) { - for (var plan_num = 1; plan_num <= steh.planets; plan_num++) { - if (array_length(steh.p_feature[plan_num]) != 0) { - with (steh) { - scr_planetary_feature(plan_num); - } - } - } - steh.visited = 1; - } - if (array_length(complex_route) > 0) { - set_new_player_fleet_course(complex_route); - } - } - } - - if ((action == "") && (obj_controller.known[eFACTION.ELDAR] == 0)) { - instance_activate_object(obj_star); // Kind of half-ass band-aiding that bug, might need to remove this later; this might cause problems later - - with (obj_star) { - if (p_type[1] != "Craftworld") { - instance_deactivate_object(id); - } - } - - var steh = instance_nearest(x, y, obj_star); - if (instance_exists(steh) && (steh != 0)) { - if (steh.p_type[1] == "Craftworld") { - var dist, rando; - dist = 999; - rando = floor(random(100)) + 1; - dist = point_distance(x, y, steh.old_x, steh.old_y); - - if ((rando >= 95) && (dist <= 300)) { - obj_controller.known[eFACTION.ELDAR] = 1; - scr_alert("green", "elfs", "Eldar Craftworld discovered.", steh.old_x, steh.old_y); - with (obj_en_fleet) { - if (owner == eFACTION.ELDAR) { - image_alpha = 1; - } - } - } - // Quene eldar introduction - // if (rando>=95) and (dist<=300) then show_message("MON'KEIGH"); - } - } - - instance_activate_object(obj_star); - } -} catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); -} diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index 4605a50d5f..d712aee36a 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -489,7 +489,11 @@ function scr_end_turn() { } if (instance_exists(obj_p_fleet)) { - obj_p_fleet.alarm[1] = 1; + wait_and_execute(1, function(){ + with(obj_p_fleet){ + player_fleet_end_turn(); + } + }); } if (instance_exists(obj_en_fleet)) { obj_en_fleet.alarm[1] = 1; 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 ae7cf0d7e8..5baf1680dd 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -646,3 +646,167 @@ function calculate_fleet_bombard_score(ship_array) { } return bomb_score; } + +function player_fleet_end_turn(){ +try { + acted = 0; + + if (action == "Lost") { + set_fleet_location("Lost"); + exit; + } else if (action == "") { + var spid = instance_nearest(x, y, obj_star); + fleet_register_at_star(self, spid); + + if (instance_exists(orbiting)) { + if (orbiting.visited == 0) { + for (var planet_num = 1; planet_num <= orbiting.planets; planet_num += 1) { + if (array_length(orbiting.p_feature[planet_num]) != 0) { + with (orbiting) { + scr_planetary_feature(planet_num); + } + } + } + orbiting.visited = 1; + } + + meet_system_governors(orbiting); + } + } else if (array_contains(global.fleet_move_options, action)) { + set_fleet_location("Warp"); + + if (instance_nearest(action_x, action_y, obj_star).storm > 0) { + exit; + } + + var spid = point_distance(x, y, action_x, action_y); + spid = spid / action_eta; + var dir = point_direction(x, y, action_x, action_y); + + x = x + lengthdir_x(spid, dir); + y = y + lengthdir_y(spid, dir); + + action_eta -= 1; + just_left = false; + + if ((action_eta == 0) && (action == "crusade1")) { + var dr = point_direction(room_width / 2, room_height / 2, x, y); + action_x = x + lengthdir_x(600, dr); + action_y = y + lengthdir_y(600, dr); + action = "crusade2"; + set_fleet_movement(false, "crusade2"); + } + if ((action_eta == 0) && (action == "crusade2")) { + with (obj_star) { + if (owner > 5) { + instance_deactivate_object(id); + } + var enemies = false; + for (var i = 6; i < 13; i++) { + if (scr_orbiting_fleet(i) != noone) { + enemies = true; + break; + } + } + if (enemies) { + instance_deactivate_object(id); + } + } + var ret = instance_nearest(x, y, obj_star); + action_x = ret.x; + action_y = ret.y; + action = "crusade3"; + set_fleet_movement(false, "crusade3"); + instance_activate_object(obj_star); + } + if ((action_eta == 0) && (action == "crusade3")) { + // Popup here + scr_crusade(); + action = ""; + } + + if ((action_eta == 0) && (action != "crusade1") && (action != "crusade2")) { + // Check to see if there are already player ships in the spot where this object will move to + // If yes, combine the two of them + + var steh = instance_nearest(action_x, action_y, obj_star); + if (steh.vision == 0) { + steh.vision = 1; + } + fleet_register_at_star(id, steh); + + meet_system_governors(steh); + + if ((steh.p_owner[1] == eFACTION.ECCLESIARCHY) || (steh.p_owner[2] == eFACTION.ECCLESIARCHY) || (steh.p_owner[3] == eFACTION.ECCLESIARCHY) || (steh.p_owner[4] == eFACTION.ECCLESIARCHY)) { + if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { + obj_controller.known[eFACTION.ECCLESIARCHY] = 1; + } + } + if ((steh.owner == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0) && (obj_controller.known[eFACTION.ELDAR] == 0)) { + obj_controller.known[eFACTION.ELDAR] = 1; + } + if ((steh.owner == eFACTION.TAU) && (obj_controller.faction_defeated[8] == 0) && (obj_controller.known[eFACTION.TAU] == 0)) { + obj_controller.known[eFACTION.TAU] = 1; + } + + action = ""; + x = action_x; + y = action_y; + action_x = 0; + action_y = 0; + + var i; + set_fleet_location(steh.name); + if (steh.visited == 0) { + for (var plan_num = 1; plan_num <= steh.planets; plan_num++) { + if (array_length(steh.p_feature[plan_num]) != 0) { + with (steh) { + scr_planetary_feature(plan_num); + } + } + } + steh.visited = 1; + } + if (array_length(complex_route) > 0) { + set_new_player_fleet_course(complex_route); + } + } + } + + if ((action == "") && (obj_controller.known[eFACTION.ELDAR] == 0)) { + instance_activate_object(obj_star); // Kind of half-ass band-aiding that bug, might need to remove this later; this might cause problems later + + with (obj_star) { + if (p_type[1] != "Craftworld") { + instance_deactivate_object(id); + } + } + + var steh = instance_nearest(x, y, obj_star); + if (instance_exists(steh) && (steh != 0)) { + if (steh.p_type[1] == "Craftworld") { + var dist, rando; + dist = 999; + rando = floor(random(100)) + 1; + dist = point_distance(x, y, steh.old_x, steh.old_y); + + if ((rando >= 95) && (dist <= 300)) { + obj_controller.known[eFACTION.ELDAR] = 1; + scr_alert("green", "elfs", "Eldar Craftworld discovered.", steh.old_x, steh.old_y); + with (obj_en_fleet) { + if (owner == eFACTION.ELDAR) { + image_alpha = 1; + } + } + } + // Quene eldar introduction + // if (rando>=95) and (dist<=300) then show_message("MON'KEIGH"); + } + } + + instance_activate_object(obj_star); + } +} catch (_exception) { + ERROR_HANDLER.handle_exception(_exception); +} +} From 7d7dd1eccae5dac539a3241a0691f58f52140ced Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 19:25:20 +0100 Subject: [PATCH 082/118] make player fleet move make sense --- objects/obj_p_fleet/Create_0.gml | 37 ++++++++ scripts/FleetProblem/FleetProblem.gml | 66 ++++++++++++-- scripts/PlanetProblem/PlanetProblem.gml | 6 +- scripts/SystemProblem/SystemProblem.gml | 7 +- .../scr_fleet_functions.gml | 15 +++- .../scr_player_fleet_functions.gml | 90 ++++--------------- 6 files changed, 130 insertions(+), 91 deletions(-) diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index b4d362f696..85d4ed52bd 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -63,6 +63,43 @@ add_problem = function(_name, _timer, _data = {}){ return _problem; } +arrive_at_star = function(){ + set_fleet_location(orbiting.name); + if (orbiting.visited == 0) { + for (var plan_num = 1; plan_num <= orbiting.planets; plan_num++) { + if (array_length(orbiting.p_feature[plan_num]) != 0) { + with (orbiting) { + scr_planetary_feature(plan_num); + } + } + } + orbiting.visited = 1; + } + if (orbiting.vision == 0) { + orbiting.vision = 1; + } + meet_system_governors(orbiting); + + if (array_contains(orbiting.p_owner, eFACTION.ECCLESIARCHY)) { + if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { + obj_controller.known[eFACTION.ECCLESIARCHY] = 1; + } + } + if ((orbiting.owner == eFACTION.ELDAR) && (obj_controller.faction_defeated[eFACTION.ELDAR] == 0) && (obj_controller.known[eFACTION.ELDAR] == 0)) { + obj_controller.known[eFACTION.ELDAR] = 1; + } + if ((orbiting.owner == eFACTION.TAU) && (obj_controller.faction_defeated[eFACTION.TAU] == 0) && (obj_controller.known[eFACTION.TAU] == 0)) { + obj_controller.known[eFACTION.TAU] = 1; + } +} + +arrive_at_waypoint = function(){ + for (var i = 0; i < array_length(problems); i++){ + problems[i].on_waypoint_arrival(); + } + set_new_player_fleet_course(complex_route); +} + serialize = function() { var object_fleet = self; diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 68fb17ae53..e68497c560 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -149,7 +149,7 @@ static find_func = function(trigger_string){ } //runs the entry point with event_data available for the duration of the call -static __trigger_with_event = function(trigger_string, _event_data){ +static __trigger_with_event = function(trigger_string, _event_data = {}){ var _func = find_func(trigger_string); if (is_undefined(_func)){ exit; @@ -161,15 +161,19 @@ static __trigger_with_event = function(trigger_string, _event_data){ static basic_turn_end = function(){ timer--; + var _func = undefined; if ((timer > -1) && per_turn_checks) { var _func = find_func("per_turn"); - __handle_triggered_mission_func(_func); } + __handle_triggered_mission_func(_func); } -/// @param {Id.Instance.obj_star} star -static on_arrival = function(star){ - __trigger_with_event("on_arrival", {star}); +static on_waypoint_arrival = function(){ + __trigger_with_event("on_waypoint_arrival"); +} + +static on_final_arrival = function(){ + __trigger_with_event("on_final_arrival"); } /// @param {array} units @@ -209,4 +213,54 @@ static __init = function(){ } } __init(); -} \ No newline at end of file + +static __great_crusade_init(){ + var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); + fleet.action_x = x + lengthdir_x(1200, _crusade_direction); + fleet.action_y = y + lengthdir_y(1200, _crusade_direction); + fleet.set_fleet_movement(false, p_id); + stage_id = "travel_to_crusade"; +} + +static __great_crusade_on_final_arrival(){ + if (stage_id == "travel_to_crusade"){ + var dr = point_direction(room_width / 2, room_height / 2, x, y); + fleet.action_x = x + lengthdir_x(600, dr); + fleet.action_y = y + lengthdir_y(600, dr); + set_fleet_movement(false, p_id); + stage_id = "crusading" + } else if (stage_id == "crusading"){ + with (obj_star) { + if (owner > 5) { + instance_deactivate_object(id); + } + var enemies = false; + for (var i = 6; i < 13; i++) { + if (scr_orbiting_fleet(i) != noone) { + enemies = true; + break; + } + } + if (enemies) { + instance_deactivate_object(id); + } + } + var ret = instance_nearest(x, y, obj_star); + action_x = ret.x; + action_y = ret.y; + action = "crusade3"; + set_fleet_movement(false, "crusade3"); + instance_activate_object(obj_star); + stage_id = "returning_home" + } else if (stage_id == "returning_home"){ + scr_crusade(); + action = ""; + } +} +} + + + + + + diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index b93c0a7afb..bc52c5207f 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -972,7 +972,7 @@ static __mech_raider_per_turn = function() { if (_percent_complete < 100){ exit; } - var _cleanup = array_create(11, false); + var _cleanup = array_create(obj_ini.companies+1, false); delete_mission = true; timer = -1 per_turn_checks = false; @@ -1063,7 +1063,7 @@ static __mech_bionics_per_turn = function() { if (_percent_complete < 100){ exit; } - var _cleanup = array_create(11, 0); + var _cleanup = array_create(obj_ini.companies + 1, 0); delete_mission = true; timer = -1 per_turn_checks = false; @@ -1111,7 +1111,7 @@ static __mech_bionics_per_turn = function() { } repeat (choose(2, 3, 4)) { - _unit.add_bionics(); + _unit.add_bionics("none", "any", false); } _limit++; } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 746779d621..1620536103 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -100,12 +100,7 @@ static __great_crusade_resolve = function() { var _player_fleet = scr_orbiting_player_fleet(system); if (_player_fleet != -1) { - var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); - with (_player_fleet) { - action_x = x + lengthdir_x(1200, _crusade_direction); - action_y = y + lengthdir_y(1200, _crusade_direction); - set_fleet_movement(false, "crusade1"); - } + _player_fleet.add_problem("great_crusade",infinte, {}); scr_alert("green", "crusade", "Fleet embarks upon Crusade.", system.x, system.y); scr_event_log("", "Fleet embarks upon Crusade."); diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 2e91286581..0252d6e047 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -13,6 +13,19 @@ function distribute_strength_to_fleet(strength, fleet) { } } } +/// @{Id.Instance.obj_p_fleet} +function fleet_is_orbiting(){ + orbiting = noone; + if (fleet.action == "move"){ + return orbiting; + } + var _star = instance_nearest(x, y, obj_star); + if (_star.x == x && _star.y == y){ + orbiting = _star.id + return orbiting; + } + return noone; +} /// @self Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet /// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet @@ -677,7 +690,7 @@ function fleet_star_draw_offsets() { } //TODO further split this shite up -/// @self Asset.GMObject.obj_en_fleet|Asset.GMObject.obj_p_fleet +/// @self Asset.GMObject.obj_en_fleet function fleet_arrival_logic() { var _dest_star = instance_nearest(action_x, action_y, obj_star); x = _dest_star.x; 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 5baf1680dd..920f011ce1 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -649,8 +649,11 @@ function calculate_fleet_bombard_score(ship_array) { function player_fleet_end_turn(){ try { - acted = 0; + for (var i = 0; i < array_length(problems); i++){ + problems[i].basic_turn_end(); + } + acted = 0; if (action == "Lost") { set_fleet_location("Lost"); exit; @@ -689,86 +692,23 @@ try { action_eta -= 1; just_left = false; - if ((action_eta == 0) && (action == "crusade1")) { - var dr = point_direction(room_width / 2, room_height / 2, x, y); - action_x = x + lengthdir_x(600, dr); - action_y = y + lengthdir_y(600, dr); - action = "crusade2"; - set_fleet_movement(false, "crusade2"); - } - if ((action_eta == 0) && (action == "crusade2")) { - with (obj_star) { - if (owner > 5) { - instance_deactivate_object(id); - } - var enemies = false; - for (var i = 6; i < 13; i++) { - if (scr_orbiting_fleet(i) != noone) { - enemies = true; - break; - } - } - if (enemies) { - instance_deactivate_object(id); - } - } - var ret = instance_nearest(x, y, obj_star); - action_x = ret.x; - action_y = ret.y; - action = "crusade3"; - set_fleet_movement(false, "crusade3"); - instance_activate_object(obj_star); - } - if ((action_eta == 0) && (action == "crusade3")) { - // Popup here - scr_crusade(); - action = ""; - } - - if ((action_eta == 0) && (action != "crusade1") && (action != "crusade2")) { - // Check to see if there are already player ships in the spot where this object will move to - // If yes, combine the two of them - - var steh = instance_nearest(action_x, action_y, obj_star); - if (steh.vision == 0) { - steh.vision = 1; - } - fleet_register_at_star(id, steh); - - meet_system_governors(steh); - - if ((steh.p_owner[1] == eFACTION.ECCLESIARCHY) || (steh.p_owner[2] == eFACTION.ECCLESIARCHY) || (steh.p_owner[3] == eFACTION.ECCLESIARCHY) || (steh.p_owner[4] == eFACTION.ECCLESIARCHY)) { - if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { - obj_controller.known[eFACTION.ECCLESIARCHY] = 1; - } - } - if ((steh.owner == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0) && (obj_controller.known[eFACTION.ELDAR] == 0)) { - obj_controller.known[eFACTION.ELDAR] = 1; - } - if ((steh.owner == eFACTION.TAU) && (obj_controller.faction_defeated[8] == 0) && (obj_controller.known[eFACTION.TAU] == 0)) { - obj_controller.known[eFACTION.TAU] = 1; - } - + if (action_eta == 0){ action = ""; x = action_x; y = action_y; - action_x = 0; - action_y = 0; - - var i; - set_fleet_location(steh.name); - if (steh.visited == 0) { - for (var plan_num = 1; plan_num <= steh.planets; plan_num++) { - if (array_length(steh.p_feature[plan_num]) != 0) { - with (steh) { - scr_planetary_feature(plan_num); - } - } - } - steh.visited = 1; + fleet_is_orbiting(); + if (orbiting != noone){ + arrive_at_star(); + } else { + set_fleet_location("Near " + instance_nearest(obj_star).name); } + if (array_length(complex_route) > 0) { set_new_player_fleet_course(complex_route); + } else { + for (var i = 0; i < array_length(problems); i++){ + problems[i].on_final_arrival(); + } } } } From 050b1f0105b8aa05ac43d5ec1796095fc76cceaa Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 19:28:50 +0100 Subject: [PATCH 083/118] fix discovering craft worlds --- objects/obj_p_fleet/Create_0.gml | 23 ++++++++++-- .../scr_player_fleet_functions.gml | 36 +------------------ 2 files changed, 22 insertions(+), 37 deletions(-) diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 85d4ed52bd..8663f92179 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -63,7 +63,7 @@ add_problem = function(_name, _timer, _data = {}){ return _problem; } -arrive_at_star = function(){ +arrived_at_star = function(){ set_fleet_location(orbiting.name); if (orbiting.visited == 0) { for (var plan_num = 1; plan_num <= orbiting.planets; plan_num++) { @@ -90,7 +90,26 @@ arrive_at_star = function(){ } if ((orbiting.owner == eFACTION.TAU) && (obj_controller.faction_defeated[eFACTION.TAU] == 0) && (obj_controller.known[eFACTION.TAU] == 0)) { obj_controller.known[eFACTION.TAU] = 1; - } + } + + + if (steh.p_type[1] == "Craftworld") { + rando = roll_dice_chapter(1, 100, "high"); + + if ((rando >= 95)) { + obj_controller.known[eFACTION.ELDAR] = 1; + scr_alert("green", "elfs", "Eldar Craftworld discovered.", steh.old_x, steh.old_y); + with (obj_en_fleet) { + if (owner == eFACTION.ELDAR) { + image_alpha = 1; + } + } + } + // Quene eldar introduction + // if (rando>=95) and (dist<=300) then show_message("MON'KEIGH"); + } + + instance_activate_object(obj_star); } arrive_at_waypoint = function(){ 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 920f011ce1..af368baa05 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -698,7 +698,7 @@ try { y = action_y; fleet_is_orbiting(); if (orbiting != noone){ - arrive_at_star(); + arrived_at_star(); } else { set_fleet_location("Near " + instance_nearest(obj_star).name); } @@ -712,40 +712,6 @@ try { } } } - - if ((action == "") && (obj_controller.known[eFACTION.ELDAR] == 0)) { - instance_activate_object(obj_star); // Kind of half-ass band-aiding that bug, might need to remove this later; this might cause problems later - - with (obj_star) { - if (p_type[1] != "Craftworld") { - instance_deactivate_object(id); - } - } - - var steh = instance_nearest(x, y, obj_star); - if (instance_exists(steh) && (steh != 0)) { - if (steh.p_type[1] == "Craftworld") { - var dist, rando; - dist = 999; - rando = floor(random(100)) + 1; - dist = point_distance(x, y, steh.old_x, steh.old_y); - - if ((rando >= 95) && (dist <= 300)) { - obj_controller.known[eFACTION.ELDAR] = 1; - scr_alert("green", "elfs", "Eldar Craftworld discovered.", steh.old_x, steh.old_y); - with (obj_en_fleet) { - if (owner == eFACTION.ELDAR) { - image_alpha = 1; - } - } - } - // Quene eldar introduction - // if (rando>=95) and (dist<=300) then show_message("MON'KEIGH"); - } - } - - instance_activate_object(obj_star); - } } catch (_exception) { ERROR_HANDLER.handle_exception(_exception); } From 04706f5e895c65c78fa0341b3400ff7428e34972 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 19:35:59 +0100 Subject: [PATCH 084/118] consolidate great crusade mission --- scripts/FleetProblem/FleetProblem.gml | 215 +++++++++++++++++- scripts/scr_crusade/scr_crusade.gml | 212 ----------------- .../scr_player_fleet_functions.gml | 2 +- 3 files changed, 214 insertions(+), 215 deletions(-) diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index e68497c560..e851c214fb 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -253,10 +253,221 @@ static __great_crusade_on_final_arrival(){ instance_activate_object(obj_star); stage_id = "returning_home" } else if (stage_id == "returning_home"){ - scr_crusade(); - action = ""; + __great_crusade_results(); + } } + +static __great_crusade_results = function(){ + var _unit; + var co = 0, i = 0, apoth = 0, death_determination = 0, death_determination_2 = 0, roll3 = 0, type = "", artifacts = 0; + var seed = 0; + var marines_lost = 0; + var heroics_strings = []; + var clean = []; + + //index 1: death_determine 1 //index 2: death_determine 2 /index 3: apoth_recovery + //index 3 exp_gains irandom + static + var death_sets = { + normal: [ + 80, + 90, + 40, + [ + 5, + 10, + ], + ], + hard: [ + 60, + 80, + 30, + [ + 20, + 20, + ], + ], + brutal: [ + 20, + 65, + 20, + [ + 40, + 20, + ], + ], + }; + + death_determination = floor(random(100)) + 1; + roll3 = irandom(99) + 1; + + if (death_determination <= 50) { + type = "normal"; + artifacts = choose(0, 0, 0, 0, 0, 1); + } else if (death_determination > 50 && death_determination <= 80) { + type = "hard"; + artifacts = choose(0, 0, 1); + } else if (death_determination > 80) { + type = "brutal"; + artifacts = choose(1, 2, 3); + } + + var death_data = death_sets[$ type]; + + for (co = 0; co <= obj_ini.companies; co++) { + clean[co] = 0; + } + var total_ship_id = array_concat(fleet.capital_num, fleet.frigate_num, fleet.escort_num); + + for (co = 0; co <= obj_ini.companies; co++) { + for (i = 0; i < company_length(co); i++) { + _unit = fetch_unit([co, i]); + if (!is_struct(_unit)) { + continue; + } + if (_unit.ship_location == -1) { + continue; + } + if (array_contains(total_ship_id, _unit.ship_location)) { + death_determination = floor(random(100)) + 1; + //specialist trait greatly reduces death risk + //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait + if (_unit.has_trait("very_hard_to_kill")) { + death_determination -= 20; + } + death_determination_2 = death_determination; + death_determination -= _unit.experience / 2; + + //more generalised trait bonus mainly linked to chapter advantage of same name + if (_unit.has_trait("slow_and_purposeful")) { + death_determination -= 10; + } + + var _dead = false; + if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { + _dead = true; + if (_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { + if (irandom(20) < _unit.luck) { + _dead = false; + } else { + if (irandom(100) < _unit.weapon_skill) { + var heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); + //TODO figure out a blance in reward for captains or high rnaking death on crusade + //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades + //var consolations = ["ship", "req",""] + //var consolation_prize = irandom(2) + var heroic_death = $"{_unit.full_title()} died {heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; + array_push(heroics_strings, heroic_death); + } + } + } else if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role || _unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { + _dead = false; + } + } + if (_dead) { + obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); + if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { + obj_controller.command--; + } else { + obj_controller.marines--; + } + + clean[co] = 1; + marines_lost++; + _unit.kill(false, true); + } else { + if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { + apoth++; + } + _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); + + if (irandom(99) == 1 && irandom(20) < _unit.luck) { + var heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); + _unit.add_trait(heroic_deed); + array_push(heroics_strings, string(global.trait_list[$ heroic_deed].flavour_text, _unit.full_title())); + } + } + } + } + } + + if (obj_ini.doomed == 0) { + if (apoth > 0) { + seed = min(seed, apoth * death_data[2]); + } + if (apoth == 0) { + seed = floor(seed * 0.2); + } + obj_controller.gene_seed += seed; + } + + with (obj_ini) { + for (var _c = 0; _c <= 10; _c++) { + scr_company_order(_c); + } + } + + if (roll3 <= 10) { + artifacts += 1; + } + if (artifacts > 0) { + repeat (artifacts) { + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + scr_add_artifact("random", "", 4, obj_ini.home_name, -1); + } + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + scr_add_artifact("random", "", 4, obj_ini.ship[0], 0); + } + } + } + + var tixt = "Your ships have returned from the Crusade. "; + if (type == "normal") { + tixt += "The combat was as could be expected- "; + } + if (type == "hard") { + tixt += "The combat was fairly grueling- "; + } + if (type == "brutal") { + tixt += "The combat was absolutely brutal- your marines were the first into the fray, and as a result "; + } + + tixt += string(marines_lost) + " of your battle brothers fell in combat."; + + if (obj_ini.doomed == 0) { + if ((apoth > 0) && (seed > 0)) { + tixt += " The " + string(apoth) + " surviving " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " were able to recover " + string(seed) + " Gene-Seed."; + } + if ((apoth == 0) && (seed > 0)) { + tixt += " You had no able-bodied " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; + } + } + if (obj_ini.doomed == 1) { + tixt += " Due to fatal mutations in your marines none of the fallen Gene-Seed was recoverable."; + } + + if (artifacts > 0) { + tixt += " " + string(artifacts) + " Artifacts were granted to your Chapter or looted."; + } + if ((roll3 <= 10) && (artifacts > 1)) { + tixt += " One of them were given as a bonus for exceptional valor."; + } + + if (array_length(heroics_strings) == 1) { + tixt += " A heroic deed was recorded"; + } else if (array_length(heroics_strings) > 1) { + tixt += " Several deeds were recorded"; + } + // title / text / image / speshul + scr_popup("Crusade Results", tixt, "crusade", ""); + for (i = 0; i < array_length(heroics_strings); i++) { + scr_popup("Heroic Deed", heroics_strings[i], "crusade", ""); + } + + delete_mission = true; + fleet.action = ""; +} +} } diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml index 7fdedd1637..a6023d33d6 100644 --- a/scripts/scr_crusade/scr_crusade.gml +++ b/scripts/scr_crusade/scr_crusade.gml @@ -1,215 +1,3 @@ -/// @self Id.Instance.obj_fleet -function scr_crusade() { - // Executed to kill the fuck out of the player's marines - // Think it is ran in the obj_p_fleet object when arriving back from crusade - - var _unit; - var co = 0, i = 0, apoth = 0, death_determination = 0, death_determination_2 = 0, roll3 = 0, type = "", artifacts = 0, clean = 0; - seed = 0; - marines_lost = 0; - var heroics_strings = []; - - //index 1: death_determine 1 //index 2: death_determine 2 /index 3: apoth_recovery - //index 3 exp_gains irandom + static - var death_sets = { - normal: [ - 80, - 90, - 40, - [ - 5, - 10, - ], - ], - hard: [ - 60, - 80, - 30, - [ - 20, - 20, - ], - ], - brutal: [ - 20, - 65, - 20, - [ - 40, - 20, - ], - ], - }; - - death_determination = floor(random(100)) + 1; - roll3 = irandom(99) + 1; - - if (death_determination <= 50) { - type = "normal"; - artifacts = choose(0, 0, 0, 0, 0, 1); - } else if (death_determination > 50 && death_determination <= 80) { - type = "hard"; - artifacts = choose(0, 0, 1); - } else if (death_determination > 80) { - type = "brutal"; - artifacts = choose(1, 2, 3); - } - - var death_data = death_sets[$ type]; - - for (co = 0; co <= obj_ini.companies; co++) { - clean[co] = 0; - } - var total_ship_id = array_concat(capital_num, frigate_num, escort_num); - - for (co = 0; co <= obj_ini.companies; co++) { - for (i = 0; i < company_length(co); i++) { - dead = false; - _unit = fetch_unit([co, i]); - if (!is_struct(_unit)) { - continue; - } - if (_unit.ship_location == -1) { - continue; - } - if (array_contains(total_ship_id, _unit.ship_location)) { - death_determination = floor(random(100)) + 1; - //specialist trait greatly reduces death risk - //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait - if (_unit.has_trait("very_hard_to_kill")) { - death_determination -= 20; - } - death_determination_2 = death_determination; - death_determination -= _unit.experience / 2; - - //more generalised trait bonus mainly linked to chapter advantage of same name - if (_unit.has_trait("slow_and_purposeful")) { - death_determination -= 10; - } - - var _dead = false; - if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { - _dead = true; - if (_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { - if (irandom(20) < _unit.luck) { - _dead = false; - } else { - if (irandom(100) < _unit.weapon_skill) { - var heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); - //TODO figure out a blance in reward for captains or high rnaking death on crusade - //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades - //var consolations = ["ship", "req",""] - //var consolation_prize = irandom(2) - var heroic_death = $"{_unit.full_title()} died {heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; - array_push(heroics_strings, heroic_death); - } - } - } else if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role || _unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - _dead = false; - } - } - if (_dead) { - var man_size = 0; - obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); - if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { - obj_controller.command--; - } else { - obj_controller.marines--; - } - - clean[co] = 1; - marines_lost++; - _unit.kill(false, true); - } else { - if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { - apoth++; - } - _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); - - if (irandom(99) == 1 && irandom(20) < _unit.luck) { - var heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); - _unit.add_trait(heroic_deed); - array_push(heroics_strings, string(global.trait_list[$ heroic_deed].flavour_text, _unit.full_title())); - } - } - } - } - } - - if (obj_ini.doomed == 0) { - if (apoth > 0) { - seed = min(seed, apoth * death_data[2]); - } - if (apoth == 0) { - seed = floor(seed * 0.2); - } - obj_controller.gene_seed += seed; - } - - with (obj_ini) { - for (i = 0; i <= 10; i++) { - scr_company_order(i); - } - } - - if (roll3 <= 10) { - artifacts += 1; - } - if (artifacts > 0) { - repeat (artifacts) { - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - scr_add_artifact("random", "", 4, obj_ini.home_name, -1); - } - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - scr_add_artifact("random", "", 4, obj_ini.ship[0], 0); - } - } - } - - var tixt = "Your ships have returned from the Crusade. "; - if (type == "normal") { - tixt += "The combat was as could be expected- "; - } - if (type == "hard") { - tixt += "The combat was fairly grueling- "; - } - if (type == "brutal") { - tixt += "The combat was absolutely brutal- your marines were the first into the fray, and as a result "; - } - - tixt += string(marines_lost) + " of your battle brothers fell in combat."; - - if (obj_ini.doomed == 0) { - if ((apoth > 0) && (seed > 0)) { - tixt += " The " + string(apoth) + " surviving " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " were able to recover " + string(seed) + " Gene-Seed."; - } - if ((apoth == 0) && (seed > 0)) { - tixt += " You had no able-bodied " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; - } - } - if (obj_ini.doomed == 1) { - tixt += " Due to fatal mutations in your marines none of the fallen Gene-Seed was recoverable."; - } - - if (artifacts > 0) { - tixt += " " + string(artifacts) + " Artifacts were granted to your Chapter or looted."; - } - if ((roll3 <= 10) && (artifacts > 1)) { - tixt += " One of them were given as a bonus for exceptional valor."; - } - - if (array_length(heroics_strings) == 1) { - tixt += " A heroic deed was recorded"; - } else if (array_length(heroics_strings) > 1) { - tixt += " Several deeds were recorded"; - } - // title / text / image / speshul - scr_popup("Crusade Results", tixt, "crusade", ""); - for (i = 0; i < array_length(heroics_strings); i++) { - scr_popup("Heroic Deed", heroics_strings[i], "crusade", ""); - } -} - //TODO never place the star out of reach of a player fleet, eiter increase allowed response time or find nearer planet function launch_crusade() { var _star_id = scr_random_find(2, true, "", ""); 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 af368baa05..4cffa9c1f3 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -704,7 +704,7 @@ try { } if (array_length(complex_route) > 0) { - set_new_player_fleet_course(complex_route); + arrive_at_waypoint(); } else { for (var i = 0; i < array_length(problems); i++){ problems[i].on_final_arrival(); From d2a1cec647657e08fc2d30b42cf38b2eb78935ed Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 19:45:18 +0100 Subject: [PATCH 085/118] cleanup crusade results --- scripts/FleetProblem/FleetProblem.gml | 125 ++++++++++++-------------- 1 file changed, 59 insertions(+), 66 deletions(-) diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index e851c214fb..0ada62e60a 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -319,74 +319,66 @@ static __great_crusade_results = function(){ } var total_ship_id = array_concat(fleet.capital_num, fleet.frigate_num, fleet.escort_num); - for (co = 0; co <= obj_ini.companies; co++) { - for (i = 0; i < company_length(co); i++) { - _unit = fetch_unit([co, i]); - if (!is_struct(_unit)) { - continue; - } - if (_unit.ship_location == -1) { - continue; - } - if (array_contains(total_ship_id, _unit.ship_location)) { - death_determination = floor(random(100)) + 1; - //specialist trait greatly reduces death risk - //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait - if (_unit.has_trait("very_hard_to_kill")) { - death_determination -= 20; - } - death_determination_2 = death_determination; - death_determination -= _unit.experience / 2; + var _units = collect_role_group("all", ["", 0 , total_ship_id],false, {}, true); + for (var i = 0; i < _units.number(); i++){ + _unit = _units.units[i]; + + death_determination = floor(random(100)) + 1; + //specialist trait greatly reduces death risk + //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait + if (_unit.has_trait("very_hard_to_kill")) { + death_determination -= 20; + } + death_determination_2 = death_determination; + death_determination -= _unit.experience / 2; - //more generalised trait bonus mainly linked to chapter advantage of same name - if (_unit.has_trait("slow_and_purposeful")) { - death_determination -= 10; - } + //more generalised trait bonus mainly linked to chapter advantage of same name + if (_unit.has_trait("slow_and_purposeful")) { + death_determination -= 10; + } - var _dead = false; - if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { - _dead = true; - if (_unit.role() == obj_ini.player_role_data[eROLE.CAPTAIN].role) { - if (irandom(20) < _unit.luck) { - _dead = false; - } else { - if (irandom(100) < _unit.weapon_skill) { - var heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); - //TODO figure out a blance in reward for captains or high rnaking death on crusade - //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades - //var consolations = ["ship", "req",""] - //var consolation_prize = irandom(2) - var heroic_death = $"{_unit.full_title()} died {heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; - array_push(heroics_strings, heroic_death); - } - } - } else if (_unit.role() == obj_ini.player_role_data[eROLE.ANCIENT].role || _unit.role() == obj_ini.player_role_data[eROLE.CHAPTERMASTER].role) { - _dead = false; + var _dead = false; + if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { + _dead = true; + if (_unit.has_role(eROLE.CAPTAIN)) { + if (irandom(20) < _unit.luck) { + _dead = false; + } else { + if (irandom(100) < _unit.weapon_skill) { + var _heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); + //TODO figure out a blance in reward for captains or high rnaking death on crusade + //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades + //var consolations = ["ship", "req",""] + //var consolation_prize = irandom(2) + var heroic_death = $"{_unit.full_title()} died {_heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; + array_push(heroics_strings, heroic_death); } } - if (_dead) { - obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); - if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { - obj_controller.command--; - } else { - obj_controller.marines--; - } + } else if (_unit.has_role(eROLE.ANCIENT) || _unit.has_role(eROLE.CHAPTERMASTER])) { + _dead = false; + } + } + if (_dead) { + obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); + if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { + obj_controller.command--; + } else { + obj_controller.marines--; + } - clean[co] = 1; - marines_lost++; - _unit.kill(false, true); - } else { - if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { - apoth++; - } - _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); + clean[co] = 1; + marines_lost++; + _unit.kill(false, true); + } else { + if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { + apoth++; + } + _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); - if (irandom(99) == 1 && irandom(20) < _unit.luck) { - var heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); - _unit.add_trait(heroic_deed); - array_push(heroics_strings, string(global.trait_list[$ heroic_deed].flavour_text, _unit.full_title())); - } - } + if (irandom(99) == 1 && irandom(20) < _unit.luck) { + var _heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); + _unit.add_trait(_heroic_deed); + array_push(heroics_strings, string(global.trait_list[$ _heroic_deed].flavour_text, _unit.full_title())); } } } @@ -402,7 +394,7 @@ static __great_crusade_results = function(){ } with (obj_ini) { - for (var _c = 0; _c <= 10; _c++) { + for (var _c = 0; _c <= obj_ini.companies; _c++) { scr_company_order(_c); } } @@ -434,12 +426,13 @@ static __great_crusade_results = function(){ tixt += string(marines_lost) + " of your battle brothers fell in combat."; + var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY].role; if (obj_ini.doomed == 0) { if ((apoth > 0) && (seed > 0)) { - tixt += " The " + string(apoth) + " surviving " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + " were able to recover " + string(seed) + " Gene-Seed."; + tixt += $" The {apoth} surviving {_apoth_role} were able to recover {seed} Gene-Seed."; } if ((apoth == 0) && (seed > 0)) { - tixt += " You had no able-bodied " + string(obj_ini.player_role_data[eROLE.APOTHECARY].role) + ", or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; + tixt += $" You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; } } if (obj_ini.doomed == 1) { @@ -447,7 +440,7 @@ static __great_crusade_results = function(){ } if (artifacts > 0) { - tixt += " " + string(artifacts) + " Artifacts were granted to your Chapter or looted."; + tixt += $" {artifacts} Artifacts were granted to your Chapter or looted."; } if ((roll3 <= 10) && (artifacts > 1)) { tixt += " One of them were given as a bonus for exceptional valor."; From a3466650ba88fbdbd3535c1b0f036f1db8b4098c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Mon, 28 Sep 2026 19:50:56 +0100 Subject: [PATCH 086/118] more tweaks --- scripts/FleetProblem/FleetProblem.gml | 113 +++++++++++++------------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 0ada62e60a..676961ad58 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -259,12 +259,11 @@ static __great_crusade_on_final_arrival(){ } static __great_crusade_results = function(){ - var _unit; - var co = 0, i = 0, apoth = 0, death_determination = 0, death_determination_2 = 0, roll3 = 0, type = "", artifacts = 0; - var seed = 0; - var marines_lost = 0; - var heroics_strings = []; - var clean = []; + var _apoth = 0, _death_determination = 0, _death_determination_2 = 0, _roll3 = 0, _type = "", _artifacts = 0; + var _seed = 0; + var _marines_lost = 0; + var _heroics_strings = []; + var _clean = []; //index 1: death_determine 1 //index 2: death_determine 2 /index 3: apoth_recovery //index 3 exp_gains irandom + static @@ -298,47 +297,47 @@ static __great_crusade_results = function(){ ], }; - death_determination = floor(random(100)) + 1; - roll3 = irandom(99) + 1; - - if (death_determination <= 50) { - type = "normal"; - artifacts = choose(0, 0, 0, 0, 0, 1); - } else if (death_determination > 50 && death_determination <= 80) { - type = "hard"; - artifacts = choose(0, 0, 1); - } else if (death_determination > 80) { - type = "brutal"; - artifacts = choose(1, 2, 3); + _death_determination = floor(random(100)) + 1; + _roll3 = irandom(99) + 1; + + if (_death_determination <= 50) { + _type = "normal"; + _artifacts = choose(0, 0, 0, 0, 0, 1); + } else if (_death_determination > 50 && _death_determination <= 80) { + _type = "hard"; + _artifacts = choose(0, 0, 1); + } else if (_death_determination > 80) { + _type = "brutal"; + _artifacts = choose(1, 2, 3); } - var death_data = death_sets[$ type]; + var death_data = death_sets[$ _type]; - for (co = 0; co <= obj_ini.companies; co++) { - clean[co] = 0; + for (var co = 0; co <= obj_ini.companies; co++) { + _clean[co] = 0; } var total_ship_id = array_concat(fleet.capital_num, fleet.frigate_num, fleet.escort_num); var _units = collect_role_group("all", ["", 0 , total_ship_id],false, {}, true); for (var i = 0; i < _units.number(); i++){ - _unit = _units.units[i]; + var _unit = _units.units[i]; - death_determination = floor(random(100)) + 1; + _death_determination = floor(random(100)) + 1; //specialist trait greatly reduces death risk //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait if (_unit.has_trait("very_hard_to_kill")) { - death_determination -= 20; + _death_determination -= 20; } - death_determination_2 = death_determination; - death_determination -= _unit.experience / 2; + _death_determination_2 = _death_determination; + _death_determination -= _unit.experience / 2; //more generalised trait bonus mainly linked to chapter advantage of same name if (_unit.has_trait("slow_and_purposeful")) { - death_determination -= 10; + _death_determination -= 10; } var _dead = false; - if (death_determination > death_data[0] || death_determination_2 > death_data[1]) { + if (_death_determination > death_data[0] || _death_determination_2 > death_data[1]) { _dead = true; if (_unit.has_role(eROLE.CAPTAIN)) { if (irandom(20) < _unit.luck) { @@ -351,7 +350,7 @@ static __great_crusade_results = function(){ //var consolations = ["ship", "req",""] //var consolation_prize = irandom(2) var heroic_death = $"{_unit.full_title()} died {_heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; - array_push(heroics_strings, heroic_death); + array_push(_heroics_strings, heroic_death); } } } else if (_unit.has_role(eROLE.ANCIENT) || _unit.has_role(eROLE.CHAPTERMASTER])) { @@ -366,31 +365,31 @@ static __great_crusade_results = function(){ obj_controller.marines--; } - clean[co] = 1; - marines_lost++; + _clean[co] = 1; + _marines_lost++; _unit.kill(false, true); } else { if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { - apoth++; + _apoth++; } _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); if (irandom(99) == 1 && irandom(20) < _unit.luck) { var _heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); _unit.add_trait(_heroic_deed); - array_push(heroics_strings, string(global.trait_list[$ _heroic_deed].flavour_text, _unit.full_title())); + array_push(_heroics_strings, string(global.trait_list[$ _heroic_deed].flavour_text, _unit.full_title())); } } } if (obj_ini.doomed == 0) { - if (apoth > 0) { - seed = min(seed, apoth * death_data[2]); + if (_apoth > 0) { + _seed = min(_seed, _apoth * death_data[2]); } - if (apoth == 0) { - seed = floor(seed * 0.2); + if (_apoth == 0) { + _seed = floor(_seed * 0.2); } - obj_controller.gene_seed += seed; + obj_controller.gene_seed += _seed; } with (obj_ini) { @@ -399,11 +398,11 @@ static __great_crusade_results = function(){ } } - if (roll3 <= 10) { - artifacts += 1; + if (_roll3 <= 10) { + _artifacts += 1; } - if (artifacts > 0) { - repeat (artifacts) { + if (_artifacts > 0) { + repeat (_artifacts) { if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { scr_add_artifact("random", "", 4, obj_ini.home_name, -1); } @@ -414,47 +413,47 @@ static __great_crusade_results = function(){ } var tixt = "Your ships have returned from the Crusade. "; - if (type == "normal") { + if (_type == "normal") { tixt += "The combat was as could be expected- "; } - if (type == "hard") { + if (_type == "hard") { tixt += "The combat was fairly grueling- "; } - if (type == "brutal") { + if (_type == "brutal") { tixt += "The combat was absolutely brutal- your marines were the first into the fray, and as a result "; } - tixt += string(marines_lost) + " of your battle brothers fell in combat."; + tixt += $"{_marines_lost} of your battle brothers fell in combat."; var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY].role; if (obj_ini.doomed == 0) { - if ((apoth > 0) && (seed > 0)) { - tixt += $" The {apoth} surviving {_apoth_role} were able to recover {seed} Gene-Seed."; + if ((_apoth > 0) && (_seed > 0)) { + tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; } - if ((apoth == 0) && (seed > 0)) { - tixt += $" You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(seed) + " of your Gene-Seed."; + if ((_apoth == 0) && (_seed > 0)) { + tixt += $" You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(_seed) + " of your Gene-Seed."; } } if (obj_ini.doomed == 1) { tixt += " Due to fatal mutations in your marines none of the fallen Gene-Seed was recoverable."; } - if (artifacts > 0) { - tixt += $" {artifacts} Artifacts were granted to your Chapter or looted."; + if (_artifacts > 0) { + tixt += $" {_artifacts} Artifacts were granted to your Chapter or looted."; } - if ((roll3 <= 10) && (artifacts > 1)) { + if ((_roll3 <= 10) && (_artifacts > 1)) { tixt += " One of them were given as a bonus for exceptional valor."; } - if (array_length(heroics_strings) == 1) { + if (array_length(_heroics_strings) == 1) { tixt += " A heroic deed was recorded"; - } else if (array_length(heroics_strings) > 1) { + } else if (array_length(_heroics_strings) > 1) { tixt += " Several deeds were recorded"; } // title / text / image / speshul scr_popup("Crusade Results", tixt, "crusade", ""); - for (i = 0; i < array_length(heroics_strings); i++) { - scr_popup("Heroic Deed", heroics_strings[i], "crusade", ""); + for (i = 0; i < array_length(_heroics_strings); i++) { + scr_popup("Heroic Deed", _heroics_strings[i], "crusade", ""); } delete_mission = true; From bf2b83cecc18715e5d9328f8c9620536491683e6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 29 Sep 2026 15:27:50 +0100 Subject: [PATCH 087/118] geerally clean up fleet based functions --- objects/obj_bomb_select/Alarm_1.gml | 2 +- objects/obj_en_fleet/Alarm_1.gml | 11 --- objects/obj_en_fleet/Step_0.gml | 35 +--------- objects/obj_fleet_select/Create_0.gml | 2 +- objects/obj_p_fleet/Alarm_7.gml | 4 +- objects/obj_p_fleet/Create_0.gml | 30 +++++++++ objects/obj_star/Create_0.gml | 25 ++++++- objects/obj_star_select/Draw_64.gml | 21 +++--- scripts/FleetProblem/FleetProblem.gml | 17 +++-- scripts/PlanetProblem/PlanetProblem.gml | 6 +- scripts/SystemProblem/SystemProblem.gml | 4 +- scripts/globals/globals.gml | 8 --- scripts/scr_PlanetData/scr_PlanetData.gml | 7 +- .../scr_controller_helpers.gml | 10 +-- .../scr_fleet_advisor/scr_fleet_advisor.gml | 2 +- .../scr_fleet_functions.gml | 59 +++------------- .../scr_imperial_navy_functions.gml | 2 +- .../scr_ini_ship_cleanup.gml | 2 +- .../scr_inquisition_inspection.gml | 6 +- .../scr_player_fleet_combat_functions.gml | 2 +- .../scr_player_fleet_functions.gml | 67 +++++-------------- .../scr_player_ship_functions.gml | 3 +- .../scr_post_battle_events.gml | 2 +- scripts/scr_ruins_reward/scr_ruins_reward.gml | 4 +- 24 files changed, 135 insertions(+), 196 deletions(-) diff --git a/objects/obj_bomb_select/Alarm_1.gml b/objects/obj_bomb_select/Alarm_1.gml index fa56abb0a9..e88a1be40b 100644 --- a/objects/obj_bomb_select/Alarm_1.gml +++ b/objects/obj_bomb_select/Alarm_1.gml @@ -5,7 +5,7 @@ ship_use = []; ship_max = []; ship_ide = []; -var _ships = fleet_full_ship_array(sh_target); +var _ships = sh_target.full_ship_array(); max_ships = array_length(_ships); bomb_a = calculate_fleet_bombard_score(_ships); var _total_fleet_loaded = calculate_fleet_content_size(_ships); diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index f663259b03..94beda6cc4 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -1,6 +1,4 @@ try { - var orb = orbiting; - if ((round(owner) != eFACTION.IMPERIUM) && (navy == 1)) { owner = 0; } @@ -205,15 +203,6 @@ try { } } - if (owner == eFACTION.TAU) { - if (instance_exists(obj_p_fleet) && (obj_controller.known[eFACTION.TAU] == 0)) { - var p_ship = instance_nearest(x, y, obj_p_fleet); - if ((p_ship.action == "") && (point_distance(x, y, p_ship.x, p_ship.y) <= 80)) { - obj_controller.known[eFACTION.TAU] = 1; - } - } - } - if (owner == eFACTION.TYRANIDS) { // Juggle bio-resources if (capital_number * 2 > frigate_number) { diff --git a/objects/obj_en_fleet/Step_0.gml b/objects/obj_en_fleet/Step_0.gml index 03eda8829f..00182c8f7e 100644 --- a/objects/obj_en_fleet/Step_0.gml +++ b/objects/obj_en_fleet/Step_0.gml @@ -67,15 +67,9 @@ if (ii_check == 0) { } } -if (owner == eFACTION.TYRANIDS) { +if (owner == eFACTION.TYRANIDS && orbiting != noone) { image_alpha = 0; - if (instance_exists(obj_p_fleet)) { - var bundy = instance_nearest(x, y, obj_p_fleet); - if ((bundy.action == "") && (self.action == "") && (point_distance(bundy.x, bundy.y, x, y) < 90) && (bundy.x > x) && (bundy.y < y)) { - image_alpha = 1; - } - } - if ((instance_nearest(x, y - 32, obj_star).vision == 1) && (action == "")) { + if (orbiting.has_orbiting_player_fleet() || orbiting.vision == 1){ image_alpha = 1; } } @@ -146,30 +140,7 @@ if ((owner == eFACTION.TYRANIDS) && (trade_goods == "")) { } if (global.load >= 0) { - if (owner == eFACTION.IMPERIUM) { - sprite_index = spr_fleet_imperial; - } - if (owner == eFACTION.MECHANICUS) { - sprite_index = spr_fleet_mechanicus; - } - if (owner == eFACTION.INQUISITION) { - sprite_index = spr_fleet_inquisition; - } - if (owner == eFACTION.ELDAR) { - sprite_index = spr_fleet_eldar; - } - if (owner == eFACTION.ORK) { - sprite_index = spr_fleet_ork; - } - if (owner == eFACTION.TAU) { - sprite_index = spr_fleet_tau; - } - if (owner == eFACTION.TYRANIDS) { - sprite_index = spr_fleet_tyranid; - } - if (owner == eFACTION.CHAOS) { - sprite_index = spr_fleet_chaos; - } + choose_fleet_sprite_image(); } if (image_index == 0) { image_index = 1; diff --git a/objects/obj_fleet_select/Create_0.gml b/objects/obj_fleet_select/Create_0.gml index be7f34968d..9531fd28fe 100644 --- a/objects/obj_fleet_select/Create_0.gml +++ b/objects/obj_fleet_select/Create_0.gml @@ -76,7 +76,7 @@ selection_window.inside_method = function() { var math_string = (string_width("Manage Units") / 2) + 6; if (point_and_click(draw_unit_buttons([center_draw - math_string, yy + height - 50], "Manage Units", [1, 1], c_blue))) { - var _fleet_array = fleet_full_ship_array(current_fleet); + var _fleet_array = current_fleet.full_ship_array(); var _fleet_marines = collect_role_group("all", ["", 0, _fleet_array]); group_selection(_fleet_marines, {purpose: "Ship Management", purpose_code: "manage", number: 0, system: 0, ships: _fleet_array, feature: "none", planet: 0, selections: []}); diff --git a/objects/obj_p_fleet/Alarm_7.gml b/objects/obj_p_fleet/Alarm_7.gml index 7c35df479b..51ad0d35c9 100644 --- a/objects/obj_p_fleet/Alarm_7.gml +++ b/objects/obj_p_fleet/Alarm_7.gml @@ -6,7 +6,7 @@ if (capital_number == 0) { var c = 0; var good = 0; var capital_id; -var capital_list = fleet_full_ship_array(,, true, true); +var capital_list = full_ship_array(false, true, true); for (var i = 0; i < array_length(capital_list); i++) { // Find the healthiest capital ship capital_id = capital_list[i]; @@ -20,7 +20,7 @@ for (var i = 0; i < array_length(capital_list); i++) { } if (good > 0) { - var ships_list = fleet_full_ship_array(, true); + var ships_list = full_ship_array(, true); var _art_keys = struct_get_names(obj_ini.artifact_map); for (var _i = 0; _i < array_length(_art_keys); _i++) { var arti = obj_ini.artifact_map[$ _art_keys[_i]]; diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 8663f92179..9c9680f2f8 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -37,6 +37,7 @@ escort_health = 100; complex_route = []; just_left = false; +beyond_engagement = false; action = ""; action_x = 0; @@ -119,6 +120,35 @@ arrive_at_waypoint = function(){ set_new_player_fleet_course(complex_route); } +full_ship_array = function(exclude_capitals = false, exclude_frigates = false, exclude_escorts = false) { + var all_ships = []; + var _ship_count = array_length(obj_ini.ship); + + if (!exclude_capitals) { + for (var i = 0; i < array_length(capital_num); i++) { + if (capital_num[i] < _ship_count) { + array_push(all_ships, capital_num[i]); + } + } + } + if (!exclude_frigates) { + for (var i = 0; i < array_length(frigate_num); i++) { + if (frigate_num[i] < _ship_count) { + array_push(all_ships, frigate_num[i]); + } + } + } + if (!exclude_escorts) { + for (var i = 0; i < array_length(escort_num); i++) { + if (escort_num[i] < _ship_count) { + array_push(all_ships, escort_num[i]); + } + } + } + + return all_ships; +} + serialize = function() { var object_fleet = self; diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 1b26b3878d..1f2485d640 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -27,6 +27,7 @@ storm_image = 0; trader = 0; visited = 0; stored_owner = -1; +navy_enemy_fleet_enroute = false; // sets up default planet variables planet = array_create(PLANET_ARRAY_SIZE, 0); @@ -130,13 +131,35 @@ add_problem = function(p_id, data = {}){ has_orbiting_player_fleet = function () { if (instance_exists(obj_p_fleet)) { var _nearest = instance_nearest(x, y, obj_p_fleet); - if (point_distance(_nearest.x, _nearest.y, x, y) == 0) { + if (action != "move" && point_distance(_nearest.x, _nearest.y, x, y) == 0) { return true; } } return false; } +/// @function get_orbiting_player_fleet() +/// @description Returns the ID of the nearest player fleet orbiting the given system or star. +/// The system instance or identifier to check. If `noone`, the function checks the calling star instance. +/// @returns {Id.Instance.obj_p_fleet} The instance ID of the orbiting player fleet, or -1 if none is found. +/// +/// @example +/// ```gml +/// var fleet_id = get_orbiting_player_fleet(); +/// if (fleet_id != noone) { +/// LOGGER.debug("Fleet orbiting star: " + string(fleet_id)); +/// } +/// ``` +get_orbiting_player_fleet = function() { + var _fleet = instance_nearest(x, y, obj_p_fleet); + if (object_distance(self, _fleet) > 0 && action != "move") { + return noone; + } else { + return _fleet.id; + } + return noone; +} + system_player_ground_forces = 0; /// @desc Reports whether any planet in this system holds a garrison squad that still has members. diff --git a/objects/obj_star_select/Draw_64.gml b/objects/obj_star_select/Draw_64.gml index 26d6ffa84b..b3d4ce0bfe 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -158,11 +158,9 @@ try { } 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) { - array_push(buttons, "Cyclonic Torpedo"); - } + var _pfleet = target.get_orbiting_player_fleet(); + if (_pfleet != noone && calculate_fleet_bombard_score(_pfleet.full_ship_array()) > 0) { + array_push(buttons, "Cyclonic Torpedo"); } } } else if (p_data.player_forces > 0) { @@ -292,6 +290,7 @@ try { } } } + var _p_fleet = target.get_orbiting_player_fleet() if (current_button != "") { if (array_contains(["Build", "Base", "Arsenal", "Gene-Vault"], current_button)) { /// @type {Id.Instance.obj_temp_build} @@ -312,12 +311,12 @@ try { with (obj_star_select) { instance_destroy(); } - } else if (current_button == "Raid" && instance_nearest(x, y, obj_p_fleet).acted <= 1) { + } else if (current_button == "Raid" && _p_fleet.acted <= 1) { // feather ignore once GM2064 - 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}); + instance_create_layer(x, y, layer_get_all()[0], obj_drop_select, {p_target: target, planet_number: obj_controller.selecting_planet, sh_target: _p_fleet, purge: 0}); } else if (current_button == "Attack") { var _allow_attack = true; - var _targ = !target.present_fleet[1] ? noone : instance_nearest(x, y, obj_p_fleet); + var _targ = !target.present_fleet[1] ? noone : _p_fleet; if (instance_exists(_targ)) { if (_targ.acted >= 2) { _allow_attack = false; @@ -329,7 +328,7 @@ try { } } else if (current_button == "Purge") { var _allow_attack = true; - var _targ = !target.present_fleet[1] ? noone : instance_nearest(x, y, obj_p_fleet); + var _targ = !target.present_fleet[1] ? noone : _p_fleet; if (instance_exists(_targ)) { if (_targ.acted >= 2) { _allow_attack = false; @@ -343,9 +342,9 @@ try { 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.sh_target = _p_fleet; obj_bomb_select.p_data = p_data; - if (instance_nearest(x, y, obj_p_fleet).acted > 0) { + if (_p_fleet.acted > 0) { with (obj_bomb_select) { instance_destroy(); } diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 676961ad58..5646dfe3db 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -218,8 +218,9 @@ static __great_crusade_init(){ var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); fleet.action_x = x + lengthdir_x(1200, _crusade_direction); fleet.action_y = y + lengthdir_y(1200, _crusade_direction); - fleet.set_fleet_movement(false, p_id); + fleet.set_fleet_movement(false, "move"); stage_id = "travel_to_crusade"; + fleet.beyond_engagement = true; } static __great_crusade_on_final_arrival(){ @@ -227,8 +228,9 @@ static __great_crusade_on_final_arrival(){ var dr = point_direction(room_width / 2, room_height / 2, x, y); fleet.action_x = x + lengthdir_x(600, dr); fleet.action_y = y + lengthdir_y(600, dr); - set_fleet_movement(false, p_id); + set_fleet_movement(false, "move"); stage_id = "crusading" + fleet.beyond_engagement = true; } else if (stage_id == "crusading"){ with (obj_star) { if (owner > 5) { @@ -249,15 +251,20 @@ static __great_crusade_on_final_arrival(){ action_x = ret.x; action_y = ret.y; action = "crusade3"; - set_fleet_movement(false, "crusade3"); - instance_activate_object(obj_star); + set_fleet_movement(false, "move"); + instance_activate_object(obj_star); + fleet.beyond_engagement = true; stage_id = "returning_home" } else if (stage_id == "returning_home"){ __great_crusade_results(); - + fleet.beyond_engagement = false; } } +static __great_crusade_status_description = function(){ + +} + static __great_crusade_results = function(){ var _apoth = 0, _death_determination = 0, _death_determination_2 = 0, _roll3 = 0, _type = "", _artifacts = 0; var _seed = 0; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index bc52c5207f..0678e3c1ec 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -945,7 +945,11 @@ function __hunt_fallen_battle_aftermath() { static __mech_raider_init = function(){ var _mission_loc = p_data.name(); - var _nearest_fleet = instance_nearest(system.x, system.y, obj_p_fleet); + var _nearest_fleet = get_nearest_player_fleet(system.x, system.y); + if (_nearest_fleet == noone){ + delete_mission = true; + exit; + } timer = get_viable_travel_time(5, _nearest_fleet.x, _nearest_fleet.y, system.x, system.y, _nearest_fleet, false); var _vacation_time = 24; timer += _vacation_time; diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 1620536103..a08aa4a5eb 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -97,9 +97,9 @@ static __great_crusade_init = function(){ } static __great_crusade_resolve = function() { - var _player_fleet = scr_orbiting_player_fleet(system); + var _player_fleet = system.get_orbiting_player_fleet(); - if (_player_fleet != -1) { + if (_player_fleet != noone) { _player_fleet.add_problem("great_crusade",infinte, {}); scr_alert("green", "crusade", "Fleet embarks upon Crusade.", system.x, system.y); diff --git a/scripts/globals/globals.gml b/scripts/globals/globals.gml index 51140787ff..021cda3333 100644 --- a/scripts/globals/globals.gml +++ b/scripts/globals/globals.gml @@ -135,14 +135,6 @@ global.xenos_factions = [ eFACTION.TYRANIDS, ]; -global.fleet_move_options = [ - "move", - "crusade1", - "crusade2", - "crusade3", - "mars_spelunk1", -]; - global.alliance_grades = [ "Hated", "Hostile", diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index 25d9ad9fd8..e7ee7c9981 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -645,11 +645,8 @@ function PlanetData(_planet, _system) constructor { 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 == "")) { - exit; - } + if (has_orbiting_player_fleet()) { + exit; } if (planet_type == "Forge") { _rando -= 80; diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index d712aee36a..d5c24b6e84 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -469,22 +469,18 @@ function scr_end_turn() { turn += 1; with (obj_star) { - present_fleet[20] = 0; + navy_enemy_fleet_enroute = false; } with (obj_p_fleet) { if ((action == "move") && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War")) { var him = instance_nearest(action_x, action_y, obj_star); - if (point_distance(action_x, action_y, him.x, him.y) < 10) { - him.present_fleet[20] = 1; - } + navy_enemy_fleet_enroute = (point_distance(action_x, action_y, him.x, him.y) == 0); } } with (obj_en_fleet) { if ((action == "move") && (owner > 5)) { var him = instance_nearest(action_x, action_y, obj_star); - if (point_distance(action_x, action_y, him.x, him.y) < 10) { - him.present_fleet[20] = 1; - } + navy_enemy_fleet_enroute = (point_distance(action_x, action_y, him.x, him.y) == 0); } } diff --git a/scripts/scr_fleet_advisor/scr_fleet_advisor.gml b/scripts/scr_fleet_advisor/scr_fleet_advisor.gml index 136af8d50d..2bdd6ffde0 100644 --- a/scripts/scr_fleet_advisor/scr_fleet_advisor.gml +++ b/scripts/scr_fleet_advisor/scr_fleet_advisor.gml @@ -236,7 +236,7 @@ function scr_fleet_advisor() { tooltip_draw(localize("Carrying ({0}): {1}", [cn.temp[118], cn.temp[119]])); if (_goto_button.click()) { with (obj_p_fleet) { - var _fleet_ships = fleet_full_ship_array(); + var _fleet_ships = full_ship_array(); if (array_contains(_fleet_ships, i)) { cn.x = x; cn.y = y; diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 0252d6e047..17ad5b4da2 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -244,7 +244,7 @@ function set_fleet_movement(_fastest_route = true, _new_action = "move", _minimu /// @param {Struct} unit function load_unit_to_fleet(fleet, unit) { var loaded = false; - var all_ships = fleet_full_ship_array(fleet); + var all_ships = fleet.full_ship_array(); for (var i = 0; i < array_length(all_ships); i++) { var ship_ident = all_ships[i]; @@ -539,39 +539,7 @@ function object_distance(obj_1, obj_2) { return point_distance(obj_1.x, obj_1.y, obj_2.x, obj_2.y); } -/// @function scr_orbiting_player_fleet(system) -/// @description Returns the ID of the nearest player fleet orbiting the given system or star. -/// @param {Id.Instance.obj_star} system -/// The system instance or identifier to check. If `noone`, the function checks the calling star instance. -/// @returns {Id.Instance.obj_p_fleet} The instance ID of the orbiting player fleet, or -1 if none is found. -/// -/// @example -/// ```gml -/// var fleet_id = scr_orbiting_player_fleet(); -/// if (fleet_id != -1) { -/// LOGGER.debug("Fleet orbiting star: " + string(fleet_id)); -/// } -/// ``` -function scr_orbiting_player_fleet(system = noone) { - if (system == noone && !is_struct(self) && object_index == obj_star) { - var _fleet = instance_nearest(x, y, obj_p_fleet); - if (object_distance(self, _fleet) > 0) { - return -1; - } else { - return _fleet.id; - } - } else if (system != noone) { - try { - with (system) { - return scr_orbiting_player_fleet(); - } - } catch (_exception) { - ERROR_HANDLER.handle_exception(_exception); - } - } - return -1; -} function get_orbiting_fleets(faction, system = noone) { var _fleets = []; @@ -1354,6 +1322,15 @@ function fleet_register_at_star(_fleet, _star) { if (_faction == eFACTION.PLAYER && _star.vision == 0) { _star.vision = 1; } + + if (_faction != eFACTION.PLAYER){ + if (obj_controller.known[_faction] == 0){ + var _p_fleet = get_orbiting_player_fleet(); + if (_p_fleet != noone){ + obj_controller.known[_faction] == 1; + } + } + } } /// @desc Unregisters a fleet from its orbiting star (if there is one), clears orbiting and decrements present_fleet. @@ -1409,22 +1386,6 @@ function fleet_register_at_nearest_star(_fleet, _max_distance = undefined) { return noone; } -/// @desc Creates a new player fleet, registering at the nearest star if within 50px. -/// @param {Real} _x -/// @param {Real} _y -/// @param {Array} _ships Optional array of ship IDs to add to the fleet -/// @returns {Id.Instance.obj_p_fleet} -function create_player_fleet(_x, _y, _ships = []) { - var _fleet = instance_create(_x, _y, obj_p_fleet); - _fleet.owner = eFACTION.PLAYER; - fleet_register_at_nearest_star(_fleet); - - for (var _i = 0; _i < array_length(_ships); _i++) { - add_ship_to_fleet(_ships[_i], _fleet); - } - - return _fleet; -} /// @desc Creates a new enemy fleet, registering at the nearest star if within 50px. /// @param {Real} _x 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 9c26be7962..f75a41fc46 100644 --- a/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml +++ b/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml @@ -7,7 +7,7 @@ function navy_orbiting_planet_end_turn_action() { if (trade_goods == "") { ///basicically if there is a player fleet enroute for this star and the player is at war with the navy it will trigger ///meaning the navy fleet is going to sit and wait fot the player to arrive - if (orbiting.present_fleet[20] > 0) { + if (orbiting.navy_enemy_fleet_enroute = true) { end_sequence_finished = true; } } diff --git a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml index d6eba64b59..54e3a6771b 100644 --- a/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml +++ b/scripts/scr_ini_ship_cleanup/scr_ini_ship_cleanup.gml @@ -40,7 +40,7 @@ function scr_kill_ship(index) { } if (_ship_fleet != noone) { delete_ship_from_fleet(index, _ship_fleet); - _available_ships = fleet_full_ship_array(_ship_fleet); + _available_ships = _ship_fleet.full_ship_array(); } _units_on_ship = array_shuffle(_units_on_ship); for (var i = 0; i < array_length(_available_ships); i++) { diff --git a/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml index 1ba8ea076a..c26d953135 100644 --- a/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml +++ b/scripts/scr_inquisition_inspection/scr_inquisition_inspection.gml @@ -26,7 +26,7 @@ function check_for_next_inquisitor_inspection() { if (_player_fleets == 1) { //can't inspect if fleet not in room //can't innspect if on other non negotiable action e.g crusading - _inspec = in_room(_player_fleet) && !fleet_engaged(_player_fleet); + _inspec = in_room(_player_fleet) && !_player_fleet.beyond_engagement; } else if (_player_fleets == 0) { _inspec = false; } @@ -551,7 +551,7 @@ function inquisition_inspection_loyalty(inspection_type) { var player_inspection_fleet = instance_nearest(obj_en_fleet.x, obj_en_fleet.y, obj_p_fleet); _inspect_results.star = instance_nearest(player_inspection_fleet.x, player_inspection_fleet.y, obj_star); - _inspect_results.ships = fleet_full_ship_array(player_inspection_fleet); + _inspect_results.ships = player_inspection_fleet.full_ship_array(); _inspect_results.collect_inspection_units(); @@ -569,7 +569,7 @@ function inquisition_inspection_loyalty(inspection_type) { } var ca, ia; - var player_ships = fleet_full_ship_array(player_inspection_fleet); + var player_ships = player_inspection_fleet.full_ship_array(); var _search_units = collect_role_group("all", ["", 0, player_ships]); _inspect_results.inquisitor_inspect_units(_search_units); diff --git a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml index 5fc48549c2..ca3d2d46a0 100644 --- a/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml +++ b/scripts/scr_player_fleet_combat_functions/scr_player_fleet_combat_functions.gml @@ -3,7 +3,7 @@ function add_fleet_ships_to_combat(fleet, combat) { var capital_count = array_length(fleet.capital); var _ship_id; - var _ships = fleet_full_ship_array(fleet); + var _ships = fleet.full_ship_array(); var _ship_array_length = array_length(_ships); for (var i = 0; i < _ship_array_length; i++) { try { 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 4cffa9c1f3..210135d1e5 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -1,5 +1,5 @@ function fleet_has_roles(fleet, roles = []) { - var all_ships = fleet_full_ship_array(fleet); + var all_ships = fleet.full_ship_array(); for (var i = 0; i <= 10; i++) { for (var s = 0; s < array_length(obj_ini.TTRPG[i]); s++) { var unit = fetch_unit([i, s]); @@ -17,17 +17,21 @@ function fleet_has_roles(fleet, roles = []) { } } -function fleet_engaged(fleet) { - var _engaged = false; - var _fleet_action = fleet.action; - if (_fleet_action != "" && _fleet_action != "move") { - //don't inspect if engaged in non negotiable actions - if (array_contains(global.fleet_move_options, _fleet_action)) { - _engaged = true; - } + +/// @desc Creates a new player fleet, registering at the nearest star if within 50px. +/// @param {Real} _x +/// @param {Real} _y +/// @param {Array} _ships Optional array of ship IDs to add to the fleet +/// @returns {Id.Instance.obj_p_fleet} +function create_player_fleet(_x, _y, _ships = []) { + var _fleet = instance_create(_x, _y, obj_p_fleet); + _fleet.owner = eFACTION.PLAYER; + fleet_register_at_nearest_star(_fleet); + for (var _i = 0; _i < array_length(_ships); _i++) { + add_ship_to_fleet(_ships[_i], _fleet); } - return _engaged; + return _fleet; } function split_selected_into_new_fleet(start_fleet) { @@ -137,7 +141,7 @@ function find_and_move_ship_between_fleets(out_fleet, in_fleet, index) { } function merge_player_fleets(main_fleet, merge_fleet) { - var _merge_ships = fleet_full_ship_array(merge_fleet); + var _merge_ships = merge_fleet.full_ship_array(); for (var i = 0; i < array_length(_merge_ships); i++) { if (_merge_ships[i] < array_length(obj_ini.ship)) { @@ -451,41 +455,8 @@ function player_retreat_from_fleet_combat(destination_star = noone) { } } -function fleet_full_ship_array(fleet = noone, exclude_capitals = false, exclude_frigates = false, exclude_escorts = false) { - var all_ships = []; - var _ship_count = array_length(obj_ini.ship); - if (fleet == noone) { - if (!exclude_capitals) { - for (var i = 0; i < array_length(capital_num); i++) { - if (capital_num[i] < _ship_count) { - array_push(all_ships, capital_num[i]); - } - } - } - if (!exclude_frigates) { - for (var i = 0; i < array_length(frigate_num); i++) { - if (frigate_num[i] < _ship_count) { - array_push(all_ships, frigate_num[i]); - } - } - } - if (!exclude_escorts) { - for (var i = 0; i < array_length(escort_num); i++) { - if (escort_num[i] < _ship_count) { - array_push(all_ships, escort_num[i]); - } - } - } - } else { - with (fleet) { - all_ships = fleet_full_ship_array(); - } - } - return all_ships; -} - function set_fleet_location(location) { - var fleet_ships = fleet_full_ship_array(); + var fleet_ships = full_ship_array(); for (var i = 0; i < array_length(fleet_ships); i++) { var temp = fleet_ships[i]; if (temp >= 0 && temp < array_length(obj_ini.ship_location)) { @@ -605,9 +576,7 @@ function get_nearest_player_fleet(nearest_x, nearest_y, is_static = false, is_mo } } if (stop_complex_actions) { - if (string_count("crusade", action) || action == "Lost") { - viable = false; - } + viable = !beyond_engagement; } if (!viable) { continue; @@ -675,7 +644,7 @@ try { meet_system_governors(orbiting); } - } else if (array_contains(global.fleet_move_options, action)) { + } else if (action == "move") { set_fleet_location("Warp"); if (instance_nearest(action_x, action_y, obj_star).storm > 0) { diff --git a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml index 831be96c1f..56b05da108 100644 --- a/scripts/scr_player_ship_functions/scr_player_ship_functions.gml +++ b/scripts/scr_player_ship_functions/scr_player_ship_functions.gml @@ -180,7 +180,7 @@ function loose_ship_to_warp_event() { } var _fleet = array_random_element(eligible_fleets); - var _ships = fleet_full_ship_array(_fleet); + var _ships = _fleet.full_ship_array(); var _ship_index = array_random_element(_ships); var text = "The "; @@ -226,6 +226,7 @@ function loose_ship_to_warp_event() { } _lost_ship_fleet.action = "Lost"; + _lost_ship_fleet.beyond_engagement = false; fleet_unregister_from_star(_lost_ship_fleet); _lost_ship_fleet.alarm[1] = 2; diff --git a/scripts/scr_post_battle_events/scr_post_battle_events.gml b/scripts/scr_post_battle_events/scr_post_battle_events.gml index 0caf6aa4ab..f5e94e1aac 100644 --- a/scripts/scr_post_battle_events/scr_post_battle_events.gml +++ b/scripts/scr_post_battle_events/scr_post_battle_events.gml @@ -4,7 +4,7 @@ function space_hulk_explore_battle_aftermath() { var shiyp = instance_nearest(battle_object.x, battle_object.y, obj_p_fleet); if (shiyp.x == battle_object.x && shiyp.y == battle_object.y) { - shi = fleet_full_ship_array(shiyp)[0]; + shi = shiyp.full_ship_array()[0]; loc = obj_ini.ship[shi]; } diff --git a/scripts/scr_ruins_reward/scr_ruins_reward.gml b/scripts/scr_ruins_reward/scr_ruins_reward.gml index 4bd29b9e58..edef963171 100644 --- a/scripts/scr_ruins_reward/scr_ruins_reward.gml +++ b/scripts/scr_ruins_reward/scr_ruins_reward.gml @@ -112,10 +112,10 @@ function scr_ruins_reward(_star_system, _pid_idx, _ruins) { /// @param {Id.Instance.obj_popup} _popup static _process_artifact_reward = function(_star, _pidx, _popup) { var _chosen_ship = -1; - var _fleet = scr_orbiting_player_fleet(_star); + var _fleet = _star.get_orbiting_player_fleet(); if (instance_exists(_fleet)) { - var _ships = fleet_full_ship_array(_fleet); + var _ships = _fleet.full_ship_array(); if (array_length(_ships) > 0) { _chosen_ship = _ships[0]; } From 3af790c704d9008a17b385337ee9940f22c53f8e Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 29 Sep 2026 16:13:48 +0100 Subject: [PATCH 088/118] rebuild mission log updater to account for new architecture --- objects/obj_p_fleet/Create_0.gml | 11 +++ objects/obj_star/Create_0.gml | 17 +++- scripts/FleetProblem/FleetProblem.gml | 77 +++++++++++++++---- scripts/SystemProblem/SystemProblem.gml | 13 +++- scripts/scr_PlanetData/scr_PlanetData.gml | 31 +------- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 4 +- .../scr_fleet_functions.gml | 4 +- .../scr_mission_functions.gml | 26 +++++++ .../scr_player_fleet_functions.gml | 2 +- .../scr_unit_quick_find_pane.gml | 56 ++------------ 10 files changed, 138 insertions(+), 103 deletions(-) diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 9c9680f2f8..14c5f4f784 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -64,6 +64,17 @@ add_problem = function(_name, _timer, _data = {}){ return _problem; } +problems_to_mission_log = function(){ + var _temp_log = [] + for (var i = 0; i < array_length(problems); i++) { + var _mission_data = problems[i].mission_log_entry(); + array_push(_temp_log, _mission_data); + } + + return _temp_log; +} + + arrived_at_star = function(){ set_fleet_location(orbiting.name); if (orbiting.visited == 0) { diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 1f2485d640..2ce8b2a938 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -119,14 +119,25 @@ add_feature = function(planet, feature) { array_push(p_feature[planet], feature); }; -system_problems = []; +problems = []; add_problem = function(p_id, data = {}){ var _prob = new SystemProblem(p_id, self, data); - array_push(system_problems, _prob); + array_push(problems, _prob); return _prob; } +problems_to_mission_log = function(){ + var _temp_log = []; + for (var i = 1; i <= planets; i++) { + var problems = p_problem[i]; + var _p_data = get_planet_data(i); + _temp_log = array_concat(_temp_log, _p_data.problems_to_mission_log()); + } + _temp_log = array_concat(_temp_log, generic_problems_to_mission_log()); + return _temp_log; +} + /// @self Asset.GMObject.obj_star has_orbiting_player_fleet = function () { if (instance_exists(obj_p_fleet)) { @@ -152,7 +163,7 @@ has_orbiting_player_fleet = function () { /// ``` get_orbiting_player_fleet = function() { var _fleet = instance_nearest(x, y, obj_p_fleet); - if (object_distance(self, _fleet) > 0 && action != "move") { + if (object_distance(self, _fleet) > 0 && _fleet.action != "move") { return noone; } else { return _fleet.id; diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 5646dfe3db..03d5341d62 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -8,14 +8,16 @@ "init" - runs immediately after problem is created often used to populate initial popup or stack popup for turn end - "on_arrival" - runs when the fleet arrives at a star, event_data holds {star} - "on_load" - runs when units are loaded onto the fleet, event_data holds {units} - "on_unload" - runs when units are unloaded from the fleet, event_data holds {units} - "on_split" - runs on the original fleet when it splits, event_data holds {new_fleet} - "on_merge" - runs on the receiving fleet when another fleet merges into it, event_data holds {merged_fleet} + "on_arrival" - runs when the fleet arrives at a star, fleet_event_data holds {star} + "on_load" - runs when units are loaded onto the fleet, fleet_event_data holds {units} + "on_unload" - runs when units are unloaded from the fleet, fleet_event_data holds {units} + "on_split" - runs on the original fleet when it splits, fleet_event_data holds {new_fleet} + "on_merge" - runs on the receiving fleet when another fleet merges into it, fleet_event_data holds {merged_fleet} "on_destruction" - runs when the fleet is destroyed, the mission is deleted after this function has run - must be triggered BEFORE the fleet instance is destroyed + "mission_log_entry" - runs to provide a data row for the mission log + - other than these entry points and any other later defined positions mission specific code should not run outside of the FleetProblem container - to set an entry point up simply register the function as a static e.g @@ -24,7 +26,7 @@ other info - the owning fleet must have a `problems = []` array in its create event - - entry points that receive extra information read it from event_data, which only exists for the duration of the call + - entry points that receive extra information read it from fleet_event_data, which only exists for the duration of the call - set a mission for deletion by setting delete_mission = true; this will delete the mission after the current function has finished executing - functions prefixed with `__` are only accessible from within the FleetProblem's internal scope @@ -148,15 +150,15 @@ static find_func = function(trigger_string){ return undefined; } -//runs the entry point with event_data available for the duration of the call +//runs the entry point with fleet_event_data available for the duration of the call static __trigger_with_event = function(trigger_string, _event_data = {}){ var _func = find_func(trigger_string); if (is_undefined(_func)){ exit; } - event_data = _event_data; + fleet_event_data = _event_data; __handle_triggered_mission_func(_func); - struct_remove(self, "event_data"); + struct_remove(self, "fleet_event_data"); } static basic_turn_end = function(){ @@ -203,6 +205,19 @@ static on_destruction = function(){ __check_delete(); } +static mission_log_entry = function(){ + var _func = find_func("mission_log_entry") + if (!is_undefined(_func)){ + try { + return _func(); + } catch (_exception) { + delete_mission = true; + ERROR_HANDLER.handle_exception(_exception); + } + } + __check_delete(); +} + static __init = function(){ if (p_id == ""){ exit; @@ -214,7 +229,7 @@ static __init = function(){ } __init(); -static __great_crusade_init(){ +static __great_crusade_init = function(){ var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); fleet.action_x = x + lengthdir_x(1200, _crusade_direction); fleet.action_y = y + lengthdir_y(1200, _crusade_direction); @@ -223,7 +238,7 @@ static __great_crusade_init(){ fleet.beyond_engagement = true; } -static __great_crusade_on_final_arrival(){ +static __great_crusade_on_final_arrival = function(){ if (stage_id == "travel_to_crusade"){ var dr = point_direction(room_width / 2, room_height / 2, x, y); fleet.action_x = x + lengthdir_x(600, dr); @@ -360,7 +375,7 @@ static __great_crusade_results = function(){ array_push(_heroics_strings, heroic_death); } } - } else if (_unit.has_role(eROLE.ANCIENT) || _unit.has_role(eROLE.CHAPTERMASTER])) { + } else if (_unit.has_role(eROLE.ANCIENT) || _unit.has_role(eROLE.CHAPTERMASTER)) { _dead = false; } } @@ -459,15 +474,49 @@ static __great_crusade_results = function(){ } // title / text / image / speshul scr_popup("Crusade Results", tixt, "crusade", ""); - for (i = 0; i < array_length(_heroics_strings); i++) { + for (var i = 0; i < array_length(_heroics_strings); i++) { scr_popup("Heroic Deed", _heroics_strings[i], "crusade", ""); } delete_mission = true; fleet.action = ""; -} } + +static __deliver_hunt_trophy_mission_log_entry = function(){ + var _problem = problems[i]; + var _mission = localize("Deliver Trophy Guard"); + var _sys = fleets_next_location(); + var _mission_data = { + mission: _problem, + system: _sys.name, + system_id: _sys.id, + target: id, + important_person: _event.data.trophy_owner, + person_name: _event.data.delivering_marine, + planet: 0, + start_system: _event.data.system, + time: timer, + }; + + _mission_data.click_left = method(_mission_data, function() { + set_map_pan_to_loc(system_id); + }); + + _mission_data.hover = method(_mission_data, function() { + tooltip_draw(localize("You are to have {0} deliver trophy hunted on {1} to the {1} regiments\n\nLeft click to see target fleet intercept system right click to view the trophy bearing marine {0}", [person_name, start_system])); + }); + + _mission_data.click_right = method(_mission_data, function() { + var _unit = fetch_unit_uid(important_person); + if (is_struct(_unit)) { + var _unit_l = [_unit]; + group_selection(_unit_l); + } + }); + return _mission_data; } +} + diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index a08aa4a5eb..f6d1dca7b5 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -18,6 +18,13 @@ if (struct_exists(data, "members")){ members = data.members; } +static description = function(){ + var _n = mission_name_key(p_id); + _n = _n == "" ? p_id : _n; + return _n; +} + + static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ try { @@ -28,13 +35,13 @@ static __handle_triggered_mission_func = function(func){ } if (timer == -1 || (delete_mission)){ var _prob = -1; - for (var i = 0; i < array_length(system.system_problems); i++){ - if (system.system_problems[i] == self){ + for (var i = 0; i < array_length(system.problems); i++){ + if (system.problems[i] == self){ _prob = i; } } if (_prob > -1){ - array_delete(system.system_problems, _prob,1); + array_delete(system.problems, _prob,1); } } } diff --git a/scripts/scr_PlanetData/scr_PlanetData.gml b/scripts/scr_PlanetData/scr_PlanetData.gml index e7ee7c9981..e961c62585 100644 --- a/scripts/scr_PlanetData/scr_PlanetData.gml +++ b/scripts/scr_PlanetData/scr_PlanetData.gml @@ -641,11 +641,11 @@ function PlanetData(_planet, _system) constructor { } // 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) { + 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 (has_orbiting_player_fleet()) { + if (system.has_orbiting_player_fleet()) { exit; } if (planet_type == "Forge") { @@ -806,30 +806,7 @@ function PlanetData(_planet, _system) constructor { } } - static problems_to_mission_log = function(){ - var _logs = []; - for (var p = 0; p < array_length(problems); p++) { - var _problem = problems[p]; - - if (_problem.stage_id == "preliminary") { - continue; - } - var _mission_explain = _problem.description(); - var _data = { - system: name(), - mission: _mission_explain, - time: _problem.timer, - problem : _problem, - }; - - _data.click_left = method(_data, function() { - set_map_pan_to_loc(problem.system); - }); - - array_push(_logs, _data); - } - return _logs; - } + static problems_to_mission_log = method(self, generic_problems_to_mission_log); static name = function() { return planet_numeral_name(planet, system); 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 8a237f8302..6d80f9259a 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -72,8 +72,8 @@ function scr_enemy_ai_d() { } } } - for (var i = 0; i < array_length(system_problems); i++){ - system_problems[i].basic_turn_end(); + for (var i = 0; i < array_length(problems); i++){ + problems[i].basic_turn_end(); } for (var i = 1; i <= planets; i++) { diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 17ad5b4da2..bd849b727b 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -1325,9 +1325,9 @@ function fleet_register_at_star(_fleet, _star) { if (_faction != eFACTION.PLAYER){ if (obj_controller.known[_faction] == 0){ - var _p_fleet = get_orbiting_player_fleet(); + var _p_fleet = _star.get_orbiting_player_fleet(); if (_p_fleet != noone){ - obj_controller.known[_faction] == 1; + obj_controller.known[_faction] = 1; } } } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index f2881c432b..d8dc7a9f2e 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -228,6 +228,32 @@ function remove_star_problem(problem, star = noone) { } } +/// @self struct.PlanetData | Asset.GMObject.obj_star +function generic_problems_to_mission_log (){ + var _logs = []; + for (var p = 0; p < array_length(problems); p++) { + var _problem = problems[p]; + + if (_problem.stage_id == "preliminary") { + continue; + } + var _mission_explain = _problem.description(); + var _data = { + system: is_callable(name) ? name() : name, + mission: _mission_explain, + time: _problem.timer, + problem : _problem, + }; + + _data.click_left = method(_data, function() { + set_map_pan_to_loc(problem.system); + }); + + array_push(_logs, _data); + } + return _logs; +} + /// @desc Compares two location arrays to determine if they represent the same place. /// @param {array} _first_loc /// @param {array} _second_loc 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 210135d1e5..b1b6acd3fc 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -669,7 +669,7 @@ try { if (orbiting != noone){ arrived_at_star(); } else { - set_fleet_location("Near " + instance_nearest(obj_star).name); + set_fleet_location("Near " + instance_nearest(x, y,obj_star).name); } if (array_length(complex_route) > 0) { diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index b182f6caad..73b40c489f 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -260,60 +260,14 @@ function UnitQuickFindPanel() constructor { update_mission_log = function() { mission_log = []; - var temp_log = []; + var _temp_log = []; with (obj_star) { - for (var i = 1; i <= planets; i++) { - var problems = p_problem[i]; - var _p_data = get_planet_data(i); - temp_log = array_concat(temp_log, _p_data.problems_to_mission_log()); - } + _temp_log = array_concat(_temp_log, problems_to_mission_log()); } - with (obj_en_fleet) { - if (array_length(events)) { - for (var i = 0; i < array_length(events); i++) { - var _event = events[i]; - if (struct_exists(_event, "turn_end")) { - switch (_event.turn_end) { - //this is being pre seeded for a later coming feature set - case "deliver_trophy_end_turn_check": - var _mission = localize("Deliver Trophy Guard"); - var _sys = fleets_next_location(); - var _mission_data = { - mission: _mission, - system: _sys.name, - system_id: _sys.id, - target: id, - important_person: _event.fleetevent_data.trophy_owner, - person_name: _event.fleetevent_data.delivering_marine, - planet: 0, - start_system: _event.fleetevent_data.system, - time: _event.timer, - }; - - _mission_data.click_left = method(_mission_data, function() { - set_map_pan_to_loc(system_id); - }); - - _mission_data.hover = method(_mission_data, function() { - tooltip_draw(localize("You are to have {0} deliver trophy hunted on {1} to the {1} regiments\n\nLeft click to see target fleet intercept system right click to view the trophy bearing marine {0}", [person_name, start_system])); - }); - - _mission_data.click_right = method(_mission_data, function() { - var _unit = fetch_unit_uid(important_person); - if (is_struct(_unit)) { - var _unit_l = [_unit]; - group_selection(_unit_l); - } - }); - - array_push(temp_log, _mission_data); - break; - } - } - } - } + with (obj_p_fleet) { + _temp_log = array_concat(_temp_log, problems_to_mission_log()); } - mission_log = temp_log; + mission_log = _temp_log; var xx = main_panel.XX; var yy = main_panel.YY; var _data = { From afda1d3bc4e9ec97319af6c4f94bc805c19c2b86 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 29 Sep 2026 17:18:59 +0100 Subject: [PATCH 089/118] add a system debug slate by hijacking garrison slate when not in use --- objects/obj_p_fleet/Create_0.gml | 5 ++ objects/obj_star/Create_0.gml | 9 +-- objects/obj_star_select/Draw_64.gml | 2 + scripts/FleetProblem/FleetProblem.gml | 65 ++++++++++++------- scripts/SystemProblem/SystemProblem.gml | 2 +- scripts/scr_cheatcode/scr_cheatcode.gml | 48 +++++++++++--- .../scr_controller_helpers.gml | 8 +-- .../scr_imperial_navy_functions.gml | 2 +- .../scr_popup_functions.gml | 1 + 9 files changed, 99 insertions(+), 43 deletions(-) diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 14c5f4f784..50cfc7a67b 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -160,6 +160,11 @@ full_ship_array = function(exclude_capitals = false, exclude_frigates = false, e return all_ships; } +calculate_eta = function(target_x, target_y,from_star = true, to_star = true){ + calculate_fleet_eta(x, y, target_x, target_y, fleet_speed, from_star , to_star , warp_able); +} + +move = method(self, set_fleet_movement); serialize = function() { var object_fleet = self; diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 2ce8b2a938..3f404020bc 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -130,7 +130,6 @@ add_problem = function(p_id, data = {}){ problems_to_mission_log = function(){ var _temp_log = []; for (var i = 1; i <= planets; i++) { - var problems = p_problem[i]; var _p_data = get_planet_data(i); _temp_log = array_concat(_temp_log, _p_data.problems_to_mission_log()); } @@ -142,7 +141,7 @@ problems_to_mission_log = function(){ has_orbiting_player_fleet = function () { if (instance_exists(obj_p_fleet)) { var _nearest = instance_nearest(x, y, obj_p_fleet); - if (action != "move" && point_distance(_nearest.x, _nearest.y, x, y) == 0) { + if (_nearest.action != "move" && point_distance(_nearest.x, _nearest.y, x, y) == 0) { return true; } } @@ -163,12 +162,14 @@ has_orbiting_player_fleet = function () { /// ``` get_orbiting_player_fleet = function() { var _fleet = instance_nearest(x, y, obj_p_fleet); - if (object_distance(self, _fleet) > 0 && _fleet.action != "move") { + if (!instance_exists(_fleet)){ + return noone; + } + if (object_distance(self, _fleet) > 0 || _fleet.action == "move") { return noone; } else { return _fleet.id; } - return noone; } system_player_ground_forces = 0; diff --git a/objects/obj_star_select/Draw_64.gml b/objects/obj_star_select/Draw_64.gml index b3d4ce0bfe..5edc9d254a 100644 --- a/objects/obj_star_select/Draw_64.gml +++ b/objects/obj_star_select/Draw_64.gml @@ -374,6 +374,8 @@ try { scr_destroy_planet(2); } } + } else if (global.cheat_debug ){ + draw_system_debug(); } if (target != 0) { diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 03d5341d62..2875a46721 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -206,16 +206,37 @@ static on_destruction = function(){ } static mission_log_entry = function(){ - var _func = find_func("mission_log_entry") + var _func = find_func("mission_log_entry"); if (!is_undefined(_func)){ try { return _func(); } catch (_exception) { delete_mission = true; ERROR_HANDLER.handle_exception(_exception); + __check_delete(); + return undefined; } } - __check_delete(); + return __default_mission_log_entry(); +} + +static __default_mission_log_entry = function(){ + if (!instance_exists(fleet)){ + return undefined; + } + var _near_star = instance_nearest(fleet.x, fleet.y ,obj_star); + var _data = { + system: _near_star, + mission: description(), + time: timer, + problem: self, + }; + + _data.click_left = method(_data, function() { + set_map_pan_to_loc(problem.fleet); + }); + + return _data; } static __init = function(){ @@ -230,20 +251,20 @@ static __init = function(){ __init(); static __great_crusade_init = function(){ - var _crusade_direction = point_direction(room_width / 2, room_height / 2, system.x, system.y); - fleet.action_x = x + lengthdir_x(1200, _crusade_direction); - fleet.action_y = y + lengthdir_y(1200, _crusade_direction); - fleet.set_fleet_movement(false, "move"); + var _crusade_direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); + fleet.action_x = fleet.x + lengthdir_x(1200, _crusade_direction); + fleet.action_y = fleet.y + lengthdir_y(1200, _crusade_direction); + fleet.move(false, "move"); stage_id = "travel_to_crusade"; fleet.beyond_engagement = true; } static __great_crusade_on_final_arrival = function(){ if (stage_id == "travel_to_crusade"){ - var dr = point_direction(room_width / 2, room_height / 2, x, y); - fleet.action_x = x + lengthdir_x(600, dr); - fleet.action_y = y + lengthdir_y(600, dr); - set_fleet_movement(false, "move"); + var _direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); + fleet.action_x = fleet.x + lengthdir_x(600, _direction); + fleet.action_y = fleet.y + lengthdir_y(600, _direction); + fleet.move(false, "move"); stage_id = "crusading" fleet.beyond_engagement = true; } else if (stage_id == "crusading"){ @@ -262,11 +283,10 @@ static __great_crusade_on_final_arrival = function(){ instance_deactivate_object(id); } } - var ret = instance_nearest(x, y, obj_star); - action_x = ret.x; - action_y = ret.y; - action = "crusade3"; - set_fleet_movement(false, "move"); + var _return_star = instance_nearest(x, fleet.y, obj_star); + action_x = _return_star.x; + action_y = _return_star.y; + fleet.move(false, "move"); instance_activate_object(obj_star); fleet.beyond_engagement = true; stage_id = "returning_home" @@ -442,10 +462,10 @@ static __great_crusade_results = function(){ tixt += "The combat was fairly grueling- "; } if (_type == "brutal") { - tixt += "The combat was absolutely brutal- your marines were the first into the fray, and as a result "; + tixt += "The combat was absolutely brutal- fleet.your marines were the first into the fray, and as a result "; } - tixt += $"{_marines_lost} of your battle brothers fell in combat."; + tixt += $"{_marines_lost} of fleet.your battle brothers fell in combat."; var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY].role; if (obj_ini.doomed == 0) { @@ -453,15 +473,15 @@ static __great_crusade_results = function(){ tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; } if ((_apoth == 0) && (_seed > 0)) { - tixt += $" You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(_seed) + " of your Gene-Seed."; + tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(_seed) + " of fleet.your Gene-Seed."; } } if (obj_ini.doomed == 1) { - tixt += " Due to fatal mutations in your marines none of the fallen Gene-Seed was recoverable."; + tixt += " Due to fatal mutations in fleet.your marines none of the fallen Gene-Seed was recoverable."; } if (_artifacts > 0) { - tixt += $" {_artifacts} Artifacts were granted to your Chapter or looted."; + tixt += $" {_artifacts} Artifacts were granted to fleet.your Chapter or looted."; } if ((_roll3 <= 10) && (_artifacts > 1)) { tixt += " One of them were given as a bonus for exceptional valor."; @@ -483,14 +503,13 @@ static __great_crusade_results = function(){ } static __deliver_hunt_trophy_mission_log_entry = function(){ - var _problem = problems[i]; var _mission = localize("Deliver Trophy Guard"); var _sys = fleets_next_location(); var _mission_data = { - mission: _problem, + mission: self, system: _sys.name, system_id: _sys.id, - target: id, + target: self, important_person: _event.data.trophy_owner, person_name: _event.data.delivering_marine, planet: 0, diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index f6d1dca7b5..f11633775d 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -107,7 +107,7 @@ static __great_crusade_resolve = function() { var _player_fleet = system.get_orbiting_player_fleet(); if (_player_fleet != noone) { - _player_fleet.add_problem("great_crusade",infinte, {}); + _player_fleet.add_problem("great_crusade",infinity, {}); scr_alert("green", "crusade", "Fleet embarks upon Crusade.", system.x, system.y); scr_event_log("", "Fleet embarks upon Crusade."); diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index b13c26d90a..a39e896b54 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -382,6 +382,34 @@ function scr_cheatcode(argument0) { } } +/// @self Asset.GMObject.obj_star_select +function draw_system_debug(){ + garrison_data_slate.inside_method = function() { + garrison_data_slate.title = localize("Garrison Report"); + draw_set_color(c_gray); + var xx = garrison_data_slate.XX; + var yy = garrison_data_slate.YY; + var _base_y = yy + 20; + var _keys = global.planet_problem_keys; + var _star_missions = [ + "great_crusade", + ] + _base_y += 2; + for (var i = 0; i < array_length(_star_missions); i++) { + var _y = _base_y + i * 20; + draw_text(38, _y, _star_missions[i]); + if (scr_hit(38, _y, 337, _y + 20)) { + tooltip_draw(mission_name_key(_star_missions[i])); + if (mouse_button_clicked()) { + var _p_data = obj_star_select.p_data; + _p_data.new_problem(_star_missions[i], 3); + } + } + } + }; + garrison_data_slate.draw(340 + main_data_slate.width, 160, 0.6, 0.6); +} + /// @self Asset.GMObject.obj_star_select function draw_planet_debug_options() { try { @@ -457,11 +485,11 @@ function draw_planet_debug_features() { }, ]; - var base_y = 220; - base_y += 2; + var _base_y = 220; + _base_y += 2; for (var i = 0; i < array_length(_addable_features); i++) { - var _y = base_y + i * 20; + var _y = _base_y + i * 20; var _feat = _addable_features[i]; draw_text(38, _y, _feat.name); if (point_and_click([38, _y, 337, _y + 20])) { @@ -473,11 +501,11 @@ function draw_planet_debug_features() { /// @self Asset.GMObject.obj_star_select function draw_planet_debug_problems() { - var base_y = 220; + var _base_y = 220; var _keys = global.planet_problem_keys; - base_y += 2; + _base_y += 2; for (var i = 0; i < array_length(_keys); i++) { - var _y = base_y + i * 20; + 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])); @@ -506,9 +534,9 @@ function draw_planet_debug_problems() { function draw_planet_debug_forces() { add_draw_return_values(); var current_planet = obj_controller.selecting_planet; - var base_y = 220; + var _base_y = 220; // Close window if clicked outside - if (!scr_hit([36, base_y, 337, base_y + 281]) && mouse_button_clicked()) { + if (!scr_hit([36, _base_y, 337, _base_y + 281]) && mouse_button_clicked()) { debug = 0; exit; } @@ -536,9 +564,9 @@ function draw_planet_debug_forces() { ]; // Loop through each faction row - base_y += 2; + _base_y += 2; for (var i = 0; i < array_length(faction_names); i++) { - var _y = base_y + i * 20; + var _y = _base_y + i * 20; var key = faction_keys[i]; // Draw faction name and value diff --git a/scripts/scr_controller_helpers/scr_controller_helpers.gml b/scripts/scr_controller_helpers/scr_controller_helpers.gml index d5c24b6e84..3a56f20ff4 100644 --- a/scripts/scr_controller_helpers/scr_controller_helpers.gml +++ b/scripts/scr_controller_helpers/scr_controller_helpers.gml @@ -473,14 +473,14 @@ function scr_end_turn() { } with (obj_p_fleet) { if ((action == "move") && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War")) { - var him = instance_nearest(action_x, action_y, obj_star); - navy_enemy_fleet_enroute = (point_distance(action_x, action_y, him.x, him.y) == 0); + var _him = instance_nearest(action_x, action_y, obj_star); + _him.navy_enemy_fleet_enroute = (point_distance(action_x, action_y, _him.x, _him.y) == 0); } } with (obj_en_fleet) { if ((action == "move") && (owner > 5)) { - var him = instance_nearest(action_x, action_y, obj_star); - navy_enemy_fleet_enroute = (point_distance(action_x, action_y, him.x, him.y) == 0); + var _him = instance_nearest(action_x, action_y, obj_star); + _him.navy_enemy_fleet_enroute = (point_distance(action_x, action_y, _him.x, _him.y) == 0); } } 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 f75a41fc46..77ee0d481c 100644 --- a/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml +++ b/scripts/scr_imperial_navy_functions/scr_imperial_navy_functions.gml @@ -7,7 +7,7 @@ function navy_orbiting_planet_end_turn_action() { if (trade_goods == "") { ///basicically if there is a player fleet enroute for this star and the player is at war with the navy it will trigger ///meaning the navy fleet is going to sit and wait fot the player to arrive - if (orbiting.navy_enemy_fleet_enroute = true) { + if (orbiting.navy_enemy_fleet_enroute) { end_sequence_finished = true; } } diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 2b77cc023a..04bfe66533 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -9,6 +9,7 @@ enum ePOPUP_TYPE { ITEM_GIFT = 9, ADD_TAGS = 12, SYSTEM_DEBUG = 13, + PLAYER_FLEETDEBUG = 14, BATTLE_OPTIONS = 98, FLEET_MOVE = 99, } From a320d0db056e32c90e30f18e850151e800f6ef3c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Tue, 29 Sep 2026 18:05:12 +0100 Subject: [PATCH 090/118] apply inheritance to cut down on bloat --- scripts/FleetProblem/FleetProblem.gml | 130 +++++++++++------- scripts/PlanetProblem/PlanetProblem.gml | 88 ++++-------- scripts/SystemProblem/SystemProblem.gml | 63 ++++----- scripts/scr_cheatcode/scr_cheatcode.gml | 24 ++-- .../scr_fleet_functions.gml | 2 +- .../scr_mission_functions.gml | 63 +++++++++ 6 files changed, 207 insertions(+), 163 deletions(-) diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 2875a46721..f456531f8b 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -38,13 +38,8 @@ other info /// @param {Real} _timer /// @param {struct} _data /// @param {Id.Instance.obj_p_fleet} _fleet -function FleetProblem(_name, _timer, _data, _fleet) constructor{ -timer = _timer; -uid = scr_uuid_generate(); -p_id = _name; -data = _data; +function FleetProblem(_name, _timer, _data, _fleet) : Problem(_name, _timer, _data) constructor{ fleet = _fleet; -delete_mission = false; static __refresh_data = function(){ if (!instance_exists(fleet)){ @@ -52,18 +47,8 @@ static __refresh_data = function(){ } } -stage_id = ""; -if (struct_exists(data, "stage")){ - stage_id = data.stage; -} - -remove = false; per_turn_checks = true; -static has_data = function(key){ - return struct_exists(data, key); -} - static save = function(){ var _save_copy = variable_clone(self); struct_remove(_save_copy, "fleet"); @@ -75,12 +60,6 @@ static load = function(data){ move_data_to_current_scope(data); } -static description = function(){ - var _n = mission_name_key(p_id); - _n = _n == "" ? p_id : _n; - return _n; -} - //requires the completion and required_months flag to be in the data struct static __increment_mission_completion = function() { if (!struct_exists(data, "completion")) { @@ -94,13 +73,6 @@ static __increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } -static __popup_delete = function(){ - with(obj_popup){ - popup_default_close(); - } - __check_delete(); -} - static __check_delete = function(){ if (timer == -1 || (delete_mission)){ if (!instance_exists(fleet)){ @@ -118,37 +90,101 @@ static __check_delete = function(){ } } -static __handle_triggered_mission_func = function(func){ - if (!is_undefined(func)){ - __refresh_data(); +//runs the entry point with fleet_event_data available for the duration of the call +static __trigger_with_event = function(trigger_string, _event_data){ + var _func = find_func(trigger_string); + if (is_undefined(_func)){ + exit; + } + fleet_event_data = _event_data; + __handle_triggered_mission_func(_func); + struct_remove(self, "fleet_event_data"); +} + +static basic_turn_end = function(){ + timer--; + if ((timer > -1) && per_turn_checks) { + var _func = find_func("per_turn"); + __handle_triggered_mission_func(_func); + } + __check_delete(); +} + +/// @param {Id.Instance.obj_star} star +static on_arrival = function(star){ + __trigger_with_event("on_arrival", {star}); +} + +/// @param {array} units +static on_load = function(units){ + __trigger_with_event("on_load", {units}); +} + +/// @param {array} units +static on_unload = function(units){ + __trigger_with_event("on_unload", {units}); +} + +/// @param {Id.Instance.obj_p_fleet} new_fleet +static on_split = function(new_fleet){ + __trigger_with_event("on_split", {new_fleet}); +} + +/// @param {Id.Instance.obj_p_fleet} merged_fleet +static on_merge = function(merged_fleet){ + __trigger_with_event("on_merge", {merged_fleet}); +} + +//call this before the fleet instance is destroyed +static on_destruction = function(){ + __trigger_with_event("on_destruction", {}); + delete_mission = true; + __check_delete(); +} + +static mission_log_entry = function(){ + var _func = find_func("mission_log_entry"); + if (!is_undefined(_func)){ try { - func(); + return _func(); } catch (_exception) { delete_mission = true; ERROR_HANDLER.handle_exception(_exception); + __check_delete(); + return undefined; } } - __check_delete(); - obj_controller.location_viewer.update_mission_log(); + return __default_mission_log_entry(); } -static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + "_" + trigger_string; - return _func_string; -} +static __default_mission_log_entry = function(){ + if (!instance_exists(fleet)){ + return undefined; + } + var _data = { + system: is_callable(fleet.name) ? fleet.name() : object_get_name(fleet.object_index), + mission: description(), + time: timer, + problem: self, + }; + + _data.click_left = method(_data, function() { + set_map_pan_to_loc(problem.fleet); + }); -static has_func = function(trigger_string){ - var _func_string = find_func_ref(trigger_string); - return struct_exists(self,_func_string); + return _data; } -static find_func = function(trigger_string){ - var _func_string = find_func_ref(trigger_string); - if (struct_exists(self,_func_string)){ - return self[$ _func_string] +static __init = function(){ + if (p_id == ""){ + exit; + } + var _func = find_func("init"); + if (!is_undefined(_func)){ + __handle_triggered_mission_func(_func); } - return undefined; } +__init(); //runs the entry point with fleet_event_data available for the duration of the call static __trigger_with_event = function(trigger_string, _event_data = {}){ diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 0678e3c1ec..c2945cd67b 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -38,32 +38,23 @@ other info //ANYTIME an exception is caught on a entry point for a mission the mission is prematurely deleted this ensures the player is not unfairly penalised for errors -/// @param {string} name -/// @param {Real} timer -/// @param {struct} data -/// @param {constructor PlanetData} planet -function PlanetProblem(_name, _timer, _data, _planet_data) constructor{ -timer = _timer; -uid = scr_uuid_generate(); -p_id = _name; -data = _data; +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +/// @param {constructor PlanetData} _planet_data +function PlanetProblem(_name, _timer, _data, _planet_data) : Problem(_name, _timer, _data) constructor{ p_data = _planet_data; planet = p_data.planet; system = p_data.system; -f_type = eP_FEATURES.MISSION; -members = []; -delete_mission = false; -static __refresh_data = function(){ - p_data = system.get_planet_data(planet); - members = clean_unit_array(members); -} -stage_id = ""; -if (struct_exists(data, "stage")){ - stage_id = data.stage; +//base only assigns members when data.members exists; default it here without clobbering that +if (!variable_struct_exists(self, "members")){ + members = []; } -if (struct_exists(data, "members")){ - members = data.members; + +static __refresh_data = function(){ + p_data = system.get_planet_data(planet); + members = clean_unit_array(members); } extend_timer_for_warp_storm = true; @@ -78,10 +69,6 @@ static mark = function(colour){ } } -static has_data = function(key){ - return struct_exists(data, key); -} - static save = function(){ var _save_copy = variable_clone(self); struct_remove(_save_copy, "system"); @@ -103,12 +90,6 @@ static load = function(data){ f_type = eP_FEATURES.MISSION; } -static description = function(){ - var _n = mission_name_key(p_id); - _n = _n == "" ? p_id : _n; - return _n; -} - static view_on_planet_screen = function(){ return (stage_id == "preliminary") && (has_data("applicant")); } @@ -126,7 +107,6 @@ static __increment_mission_completion = function() { return (data.completion / data.required_months) * 100; } - static __inquisition_mission_options = function(){ var _options = [ { @@ -153,13 +133,6 @@ static __inquisition_mission_options = function(){ return _options } -static __popup_delete = function(){ - with(obj_popup){ - popup_default_close(); - } - __check_delete(); -} - static __check_delete = function(){ if (timer == -1 || (delete_mission)){ var _prob = -1; @@ -175,6 +148,7 @@ static __check_delete = function(){ } } +//overrides Problem's base version static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ __refresh_data(); @@ -189,34 +163,18 @@ static __handle_triggered_mission_func = function(func){ obj_controller.location_viewer.update_mission_log(); } -static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + "_" + trigger_string; - return _func_string; -} - -static has_func = function(trigger_string){ - var _func_string = find_func_ref(trigger_string); - return struct_exists(self,_func_string); -} -static find_func = function(trigger_string){ - var _func_string = find_func_ref(trigger_string); - if (struct_exists(self,_func_string)){ - return self[$ _func_string] - } - return undefined; -} static basic_turn_end = function(){ - if (p_data.system.storm <= 0){ - timer--; - } - if ((timer > -1) && per_turn_checks) { - var _func = find_func("per_turn"); + if (p_data.system.storm <= 0){ + timer--; + } + if ((timer > -1) && per_turn_checks) { + var _func = find_func("per_turn"); __handle_triggered_mission_func(_func); - } - if ((timer == 0) && zero_timer_checks && !delete_mission) { - var _func = find_func("resolve"); - __handle_triggered_mission_func(_func); - } + } + if ((timer == 0) && zero_timer_checks && !delete_mission) { + var _func = find_func("resolve"); + __handle_triggered_mission_func(_func); + } } //triggered within drop select diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index f11633775d..37a35b6408 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -1,30 +1,19 @@ -/// @param {sring} name -/// @param {struct} data -function SystemProblem(_name, _system, _data = {}) constructor{ -timer = -1; -f_type = eP_FEATURES.MISSION; -p_id = _name; -data = _data; -stage_id = ""; +/// @param {string} _name +/// @param {Asset.GMObject.obj_star} _system +/// @param {struct} _data +/// @param {Real} _timer +function SystemProblem(_name, _system, _data = {}, _timer = -1) : Problem(_name, _timer, _data) constructor{ system = _system; -zero_timer_checks = true; -per_turn_checks = true; -delete_mission = false; -members = []; -if (struct_exists(data, "stage")){ - stage_id = data.stage; -} -if (struct_exists(data, "members")){ - members = data.members; -} -static description = function(){ - var _n = mission_name_key(p_id); - _n = _n == "" ? p_id : _n; - return _n; +//base only assigns members when data.members exists; default it here without clobbering that +if (!variable_struct_exists(self, "members")){ + members = []; } +zero_timer_checks = true; +per_turn_checks = true; +//overrides Problem's base version — appends the stage suffix and skips __refresh_data/location_viewer static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ try { @@ -47,26 +36,20 @@ static __handle_triggered_mission_func = function(func){ } static basic_turn_end = function(){ - if (system.storm <= 0){ - timer--; - } - if ((timer > -1) && per_turn_checks) { - var _func = find_func("per_turn"); + if (system.storm <= 0){ + timer--; + } + if ((timer > -1) && per_turn_checks) { + var _func = find_func("per_turn"); + __handle_triggered_mission_func(_func); + } + if ((timer == 0) && zero_timer_checks && !delete_mission) { + var _func = find_func("resolve"); __handle_triggered_mission_func(_func); - } - if ((timer == 0) && zero_timer_checks && !delete_mission) { - var _func = find_func("resolve"); - __handle_triggered_mission_func(_func); - } -} - -static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + "_" + trigger_string; - if (stage_id != ""){ - _func_string += "S" + stage_id; } - return _func_string; } + + static find_func = function(trigger_string){ var _func_string = find_func_ref(trigger_string); if (struct_exists(self,_func_string)){ @@ -92,7 +75,7 @@ __init(); static __great_crusade_init = function(){ //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards - var _nearest_player_fleet = data.nearest_player_fleet; + var _nearest_player_fleet = has_data("nearest_player_fleet") ? data.nearest_player_fleet : instance_nearest(system.x, system.y, obj_p_fleet); var _travel_leeway = 10; if (_nearest_player_fleet.action == "move") { _travel_leeway += _nearest_player_fleet.action_eta; diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index a39e896b54..25da7efdd3 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -384,30 +384,34 @@ function scr_cheatcode(argument0) { /// @self Asset.GMObject.obj_star_select function draw_system_debug(){ - garrison_data_slate.inside_method = function() { - garrison_data_slate.title = localize("Garrison Report"); + add_draw_return_values(); + debug_slate.inside_method = function() { + debug_slate.title = localize("DEBUG"); draw_set_color(c_gray); - var xx = garrison_data_slate.XX; - var yy = garrison_data_slate.YY; - var _base_y = yy + 20; + var xx = debug_slate.XX; + var yy = debug_slate.YY; + var _base_y = yy + 50; + var _base_x = xx + 75; var _keys = global.planet_problem_keys; var _star_missions = [ "great_crusade", ] _base_y += 2; + draw_set_font(fnt_40k_12); for (var i = 0; i < array_length(_star_missions); i++) { var _y = _base_y + i * 20; - draw_text(38, _y, _star_missions[i]); - if (scr_hit(38, _y, 337, _y + 20)) { + var _c = draw_unit_buttons([_base_x, _base_y], _star_missions[i]); + if (scr_hit(_c[0], _c[1],_c[2],_c[3])) { tooltip_draw(mission_name_key(_star_missions[i])); if (mouse_button_clicked()) { - var _p_data = obj_star_select.p_data; - _p_data.new_problem(_star_missions[i], 3); + target.add_problem(_star_missions[i], 3).timer = 3; } } + _base_y += _c[3] - _c[1]; } }; - garrison_data_slate.draw(340 + main_data_slate.width, 160, 0.6, 0.6); + debug_slate.draw(350 + main_data_slate.width, 160, 0.6, 0.6); + pop_draw_return_values(); } /// @self Asset.GMObject.obj_star_select diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index bd849b727b..552aeafbe6 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -16,7 +16,7 @@ function distribute_strength_to_fleet(strength, fleet) { /// @{Id.Instance.obj_p_fleet} function fleet_is_orbiting(){ orbiting = noone; - if (fleet.action == "move"){ + if (fleet == "move"){ return orbiting; } var _star = instance_nearest(x, y, obj_star); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index d8dc7a9f2e..05e270a406 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -1,3 +1,66 @@ +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +function Problem(_name, _timer, _data) constructor { + p_id = _name; + timer = _timer; + data = _data; + uid = scr_uuid_generate(); + delete_mission = false; + f_type = eP_FEATURES.MISSION; + stage_id = ""; + if (struct_exists(data, "stage")){ + stage_id = data.stage; + } + if (struct_exists(data, "members")){ + members = data.members; + } + static has_data = function(key){ + return struct_exists(data, key); + } + static description = function(){ + var _n = mission_name_key(p_id); + _n = _n == "" ? p_id : _n; + return _n; + } + static __popup_delete = function(){ + with(obj_popup){ + popup_default_close(); + } + __check_delete(); + } + + static find_func_ref = function(trigger_string){ + var _func_string = "__" + p_id + "_" + trigger_string; + return _func_string; + } + + static has_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + return struct_exists(self,_func_string); + } + static find_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + if (struct_exists(self,_func_string)){ + return self[$ _func_string] + } + return undefined; + } + static __handle_triggered_mission_func = function(func){ + if (!is_undefined(func)){ + __refresh_data(); + try { + func(); + } catch (_exception) { + delete_mission = true; + ERROR_HANDLER.handle_exception(_exception); + } + } + __check_delete(); + obj_controller.location_viewer.update_mission_log(); + } +} + function location_out_of_player_control(unit_loc) { static _locs = [ "Terra", From 2d16f9c99f45ae971e3fa7340c134cd84ff411a6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 14:37:10 +0100 Subject: [PATCH 091/118] allow SystemProblems to be called with noone value for system allows the problem to be assigned to a system within the __init phase --- objects/obj_star/Create_0.gml | 4 +- scripts/FleetProblem/FleetProblem.gml | 110 +----------------- scripts/SystemProblem/SystemProblem.gml | 16 ++- scripts/scr_cheatcode/scr_cheatcode.gml | 9 +- .../scr_fleet_functions.gml | 2 +- scripts/scr_random_event/scr_random_event.gml | 3 +- 6 files changed, 25 insertions(+), 119 deletions(-) diff --git a/objects/obj_star/Create_0.gml b/objects/obj_star/Create_0.gml index 908d44f27f..affe86e846 100644 --- a/objects/obj_star/Create_0.gml +++ b/objects/obj_star/Create_0.gml @@ -124,8 +124,8 @@ add_feature = function(planet, feature) { problems = []; -add_problem = function(p_id, data = {}){ - var _prob = new SystemProblem(p_id, self, data); +add_problem = function(p_id, data = {}, timer = -1){ + var _prob = new SystemProblem(p_id, self, data, timer); array_push(problems, _prob); return _prob; } diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index f456531f8b..c3c16f9f28 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -186,106 +186,6 @@ static __init = function(){ } __init(); -//runs the entry point with fleet_event_data available for the duration of the call -static __trigger_with_event = function(trigger_string, _event_data = {}){ - var _func = find_func(trigger_string); - if (is_undefined(_func)){ - exit; - } - fleet_event_data = _event_data; - __handle_triggered_mission_func(_func); - struct_remove(self, "fleet_event_data"); -} - -static basic_turn_end = function(){ - timer--; - var _func = undefined; - if ((timer > -1) && per_turn_checks) { - var _func = find_func("per_turn"); - } - __handle_triggered_mission_func(_func); -} - -static on_waypoint_arrival = function(){ - __trigger_with_event("on_waypoint_arrival"); -} - -static on_final_arrival = function(){ - __trigger_with_event("on_final_arrival"); -} - -/// @param {array} units -static on_load = function(units){ - __trigger_with_event("on_load", {units}); -} - -/// @param {array} units -static on_unload = function(units){ - __trigger_with_event("on_unload", {units}); -} - -/// @param {Id.Instance.obj_p_fleet} new_fleet -static on_split = function(new_fleet){ - __trigger_with_event("on_split", {new_fleet}); -} - -/// @param {Id.Instance.obj_p_fleet} merged_fleet -static on_merge = function(merged_fleet){ - __trigger_with_event("on_merge", {merged_fleet}); -} - -//call this before the fleet instance is destroyed -static on_destruction = function(){ - __trigger_with_event("on_destruction", {}); - delete_mission = true; - __check_delete(); -} - -static mission_log_entry = function(){ - var _func = find_func("mission_log_entry"); - if (!is_undefined(_func)){ - try { - return _func(); - } catch (_exception) { - delete_mission = true; - ERROR_HANDLER.handle_exception(_exception); - __check_delete(); - return undefined; - } - } - return __default_mission_log_entry(); -} - -static __default_mission_log_entry = function(){ - if (!instance_exists(fleet)){ - return undefined; - } - var _near_star = instance_nearest(fleet.x, fleet.y ,obj_star); - var _data = { - system: _near_star, - mission: description(), - time: timer, - problem: self, - }; - - _data.click_left = method(_data, function() { - set_map_pan_to_loc(problem.fleet); - }); - - return _data; -} - -static __init = function(){ - if (p_id == ""){ - exit; - } - var _func = find_func("init"); - if (!is_undefined(_func)){ - __handle_triggered_mission_func(_func); - } -} -__init(); - static __great_crusade_init = function(){ var _crusade_direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); fleet.action_x = fleet.x + lengthdir_x(1200, _crusade_direction); @@ -319,9 +219,9 @@ static __great_crusade_on_final_arrival = function(){ instance_deactivate_object(id); } } - var _return_star = instance_nearest(x, fleet.y, obj_star); - action_x = _return_star.x; - action_y = _return_star.y; + var _return_star = instance_nearest(fleet.x, fleet.y, obj_star); + fleet.action_x = _return_star.x; + fleet.action_y = _return_star.y; fleet.move(false, "move"); instance_activate_object(obj_star); fleet.beyond_engagement = true; @@ -509,7 +409,7 @@ static __great_crusade_results = function(){ tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; } if ((_apoth == 0) && (_seed > 0)) { - tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover " + string(_seed) + " of fleet.your Gene-Seed."; + tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of fleet.your Gene-Seed."; } } if (obj_ini.doomed == 1) { @@ -517,7 +417,7 @@ static __great_crusade_results = function(){ } if (_artifacts > 0) { - tixt += $" {_artifacts} Artifacts were granted to fleet.your Chapter or looted."; + tixt += $" {_artifacts} Artifacts were granted to your Chapter or looted."; } if ((_roll3 <= 10) && (_artifacts > 1)) { tixt += " One of them were given as a bonus for exceptional valor."; diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 37a35b6408..4ca6db18e9 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -13,7 +13,6 @@ if (!variable_struct_exists(self, "members")){ zero_timer_checks = true; per_turn_checks = true; -//overrides Problem's base version — appends the stage suffix and skips __refresh_data/location_viewer static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ try { @@ -74,8 +73,21 @@ static __init = function(){ __init(); static __great_crusade_init = function(){ + if (system == noone){ + system = scr_random_find(2, true, "", ""); + if (system == noone) { + delete_mission = true; + LOGGER.error("RE: Crusade, couldn't find a star for the crusade"); + exit; + } + array_push(system.problems ,self); + } //TODO decide the target/purpose of the crusade to create more variety and to help with post crusade rewards - var _nearest_player_fleet = has_data("nearest_player_fleet") ? data.nearest_player_fleet : instance_nearest(system.x, system.y, obj_p_fleet); + var _nearest_player_fleet = get_nearest_player_fleet(system.x, system.y); + if (_nearest_player_fleet == noone){ + delete_mission = true; + exit; + } var _travel_leeway = 10; if (_nearest_player_fleet.action == "move") { _travel_leeway += _nearest_player_fleet.action_eta; diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 25da7efdd3..346aab77e5 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -197,12 +197,7 @@ function scr_cheatcode(argument0) { } break; case "event": - if (cheat_arguments[0] == "crusade") { - LOGGER.debug("crusading"); - with (obj_controller) { - launch_crusade(); - } - } else if (cheat_arguments[0] == "tomb") { + if (cheat_arguments[0] == "tomb") { LOGGER.debug("necron_tomb_awaken"); with (obj_controller) { awaken_tomb_event(); @@ -404,7 +399,7 @@ function draw_system_debug(){ if (scr_hit(_c[0], _c[1],_c[2],_c[3])) { tooltip_draw(mission_name_key(_star_missions[i])); if (mouse_button_clicked()) { - target.add_problem(_star_missions[i], 3).timer = 3; + target.add_problem(_star_missions[i], {}, 3).timer = 3; } } _base_y += _c[3] - _c[1]; diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 552aeafbe6..9cffb8004f 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -16,7 +16,7 @@ function distribute_strength_to_fleet(strength, fleet) { /// @{Id.Instance.obj_p_fleet} function fleet_is_orbiting(){ orbiting = noone; - if (fleet == "move"){ + if (action == "move"){ return orbiting; } var _star = instance_nearest(x, y, obj_star); diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index e19a9badfa..600def0a6e 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -643,8 +643,7 @@ function scr_random_event(execute_now) { _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(); + new SystemProblem("great_crusade", noone); } else if (chosen_event == eEVENT.ENEMY) { _evented = make_faction_enemy_event(); } else if (chosen_event == eEVENT.MUTATION) { From 1db10002887924284a3c7a8cf266f4b82b1c84ea Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 15:07:51 +0100 Subject: [PATCH 092/118] check reduction --- ChapterMaster.yyp | 1 - scripts/PlanetProblem/PlanetProblem.gml | 3 ++ scripts/scr_after_combat/scr_after_combat.gml | 51 +++++++++---------- scripts/scr_crusade/scr_crusade.gml | 15 ------ scripts/scr_crusade/scr_crusade.yy | 13 ----- 5 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 scripts/scr_crusade/scr_crusade.gml delete mode 100644 scripts/scr_crusade/scr_crusade.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index d429ee622e..1747b8d41e 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -821,7 +821,6 @@ {"id":{"name":"scr_creation_draw_slides","path":"scripts/scr_creation_draw_slides/scr_creation_draw_slides.yy",},}, {"id":{"name":"scr_creation_home_planet_create","path":"scripts/scr_creation_home_planet_create/scr_creation_home_planet_create.yy",},}, {"id":{"name":"scr_creation","path":"scripts/scr_creation/scr_creation.yy",},}, - {"id":{"name":"scr_crusade","path":"scripts/scr_crusade/scr_crusade.yy",},}, {"id":{"name":"scr_culture_visuals","path":"scripts/scr_culture_visuals/scr_culture_visuals.yy",},}, {"id":{"name":"scr_DataSlate","path":"scripts/scr_DataSlate/scr_DataSlate.yy",},}, {"id":{"name":"scr_demand","path":"scripts/scr_demand/scr_demand.yy",},}, diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index c2945cd67b..7fdc984c7c 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1097,6 +1097,9 @@ static __mech_bionics_resolve = function() { } static __mech_tomb_init = function() { var _name = p_data.name(); + if (!instance_exists(obj_popup)){ + scr_popup("Mechanicus Mission Accepted", "","mechanicus"); + } obj_popup.text = $"The Adeptus Mechanicus await your forces at {_name}. They are expecting at least two squads of Astartes and have placed the testing on hold until their arrival. {global.chapter_name} have 16 months to arrive."; scr_event_log("", $"Mechanicus Mission Accepted: At least two squads of marines are expected at {_name} within 16 months.", system.name); mark("green"); diff --git a/scripts/scr_after_combat/scr_after_combat.gml b/scripts/scr_after_combat/scr_after_combat.gml index 8b35482f1f..f4ca3800f5 100644 --- a/scripts/scr_after_combat/scr_after_combat.gml +++ b/scripts/scr_after_combat/scr_after_combat.gml @@ -144,55 +144,54 @@ function after_battle_slime_and_equipment_maintenance(unit) { } } + +/// @self Asset.GMObject.obj_pnunit function check_for_plasma_bomb_and_tomb(unit) { - if (obj_ncombat.plasma_bomb || obj_ncombat.defeat) { - return; - } var _star = obj_ncombat.battle_object; var _planet = obj_ncombat.battle_id; var _necron_strength = _star.p_necrons[_planet]; - if (unit.gear() == "Plasma Bomb" && obj_ncombat.battle_special != "mech_tomb") { + if (unit.gear() == "Plasma Bomb") { if (obj_ncombat.enemy == eFACTION.NECRONS && awake_tomb_world(_star.p_feature[_planet])) { if (((_necron_strength - 2) < 3 && obj_ncombat.dropping) || (_necron_strength - 1) < 3) { obj_ncombat.plasma_bomb += 1; unit.update_gear("", false, false); + return false; } } } + return true; } /// @self Asset.GMObject.obj_pnunit function after_battle_part2() { var _unit; - + var _destroy_tomb = (!obj_ncombat.plasma_bomb && !obj_ncombat.defeat && obj_ncombat.battle_special != "mech_tomb"); + var _check_exterminatus = (obj_ncombat.dropping && !obj_ncombat.defeat); for (var i = 0; i < array_length(unit_struct); i++) { _unit = unit_struct[i]; - if (!marine_dead[i] && marine_type[i] == "Death Company") { - if (_unit.role() != "Death Company") { - _unit.update_role("Death Company"); - } - } - - if (!marine_dead[i] && !ally[i]) { - after_battle_slime_and_equipment_maintenance(_unit); - - check_for_plasma_bomb_and_tomb(_unit); - - if ((_unit.gear() == "Exterminatus") && (obj_ncombat.dropping != 0) && (obj_ncombat.defeat == 0)) { - if (obj_ncombat.exterminatus == 0) { - obj_ncombat.exterminatus += 1; - _unit.update_gear("", false, false); - } - // obj_ncombat.exterminatus+=1;scr_add_item("Exterminatus",1); - // _unit.gear()=""; - } - } - var destroy = 0; if ((marine_dead[i] || obj_ncombat.defeat != 0) && !ally[i]) { after_combat_recover_marine_gene_seed(_unit); after_combat_dead_marine_equipment_recovered(_unit); } + + if (marine_dead[i] || ally[i]) { + continue; + } + after_battle_slime_and_equipment_maintenance(_unit); + if (_destroy_tomb){ + _destroy_tomb = check_for_plasma_bomb_and_tomb(_unit); + } + if (marine_type[i] == "Death Company") { + if (_unit.role() != "Death Company") { + _unit.update_role("Death Company"); + } + } + if (_check_exterminatus && (_unit.gear() == "Exterminatus")) { + _check_exterminatus = false; + obj_ncombat.exterminatus += 1; + _unit.update_gear("", false, false); + } } for (var i = 0; i < array_length(veh_dead); i++) { diff --git a/scripts/scr_crusade/scr_crusade.gml b/scripts/scr_crusade/scr_crusade.gml deleted file mode 100644 index a6023d33d6..0000000000 --- a/scripts/scr_crusade/scr_crusade.gml +++ /dev/null @@ -1,15 +0,0 @@ -//TODO never place the star out of reach of a player fleet, eiter increase allowed response time or find nearer planet -function launch_crusade() { - var _star_id = scr_random_find(2, true, "", ""); - if (_star_id == noone) { - LOGGER.error("RE: Crusade, couldn't find a star for the crusade"); - return false; - } else { - var _nearest_player_fleet = get_nearest_player_fleet(_star_id.x, _star_id.y); - if (_nearest_player_fleet == noone) { - return false; - } - _star_id.add_problem("great_crusade", {nearest_player_fleet:_nearest_player_fleet}) - return true; - } -} diff --git a/scripts/scr_crusade/scr_crusade.yy b/scripts/scr_crusade/scr_crusade.yy deleted file mode 100644 index 86afe689cc..0000000000 --- a/scripts/scr_crusade/scr_crusade.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_crusade", - "isCompatibility":false, - "isDnD":false, - "name":"scr_crusade", - "parent":{ - "name":"Combat", - "path":"folders/Scripts/Combat.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file From 10795cd1527204e890a543a7de4a4b3c0dac6062 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 15:28:16 +0100 Subject: [PATCH 093/118] make larger inheritance sstructure for problems to reduce bloat --- ChapterMaster.yyp | 3 + objects/obj_controller/Create_0.gml | 14 +- objects/obj_en_fleet/Create_0.gml | 15 +- objects/obj_ncombat/Alarm_5.gml | 10 +- objects/obj_ncombat/Alarm_7.gml | 2 +- objects/obj_p_fleet/Create_0.gml | 28 +- objects/obj_popup_dialogue/Draw_64.gml | 2 +- scripts/AiFleetProblem/AiFleetProblem.gml | 107 ++++++ scripts/AiFleetProblem/AiFleetProblem.yy | 13 + scripts/Armamentarium/Armamentarium.gml | 46 +-- scripts/FleetProblem/FleetProblem.gml | 311 +-------------- scripts/GitHub/GitHub.gml | 8 +- .../LocalizationManager.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 39 -- .../PlayerFleetProblem/PlayerFleetProblem.gml | 359 ++++++++++++++++++ .../PlayerFleetProblem/PlayerFleetProblem.yy | 13 + scripts/Problem/Problem.gml | 101 +++++ scripts/Problem/Problem.yy | 13 + scripts/scr_bomb_world/scr_bomb_world.gml | 2 +- .../scr_draw_management_unit.gml | 2 +- scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml | 4 +- .../scr_equipment_struct.gml | 2 +- scripts/scr_flavor/scr_flavor.gml | 2 +- scripts/scr_librarium/scr_librarium.gml | 2 +- scripts/scr_livery_setup/scr_livery_setup.gml | 2 +- .../scr_mission_functions.gml | 62 --- .../scr_mission_reward/scr_mission_reward.gml | 12 +- .../scr_player_fleet_functions.gml | 4 +- .../scr_punit_combat_heplers.gml | 8 +- .../scr_reequip_units/scr_reequip_units.gml | 2 +- scripts/scr_squads/scr_squads.gml | 2 +- .../scr_unit_equip_functions.gml | 2 +- 32 files changed, 690 insertions(+), 504 deletions(-) create mode 100644 scripts/AiFleetProblem/AiFleetProblem.gml create mode 100644 scripts/AiFleetProblem/AiFleetProblem.yy create mode 100644 scripts/PlayerFleetProblem/PlayerFleetProblem.gml create mode 100644 scripts/PlayerFleetProblem/PlayerFleetProblem.yy create mode 100644 scripts/Problem/Problem.gml create mode 100644 scripts/Problem/Problem.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index 1747b8d41e..da61f07222 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -735,6 +735,7 @@ {"id":{"name":"__gml_pragma_global","path":"scripts/__gml_pragma_global/__gml_pragma_global.yy",},}, {"id":{"name":"__HTTPParent","path":"scripts/__HTTPParent/__HTTPParent.yy",},}, {"id":{"name":"__StructToDSMap","path":"scripts/__StructToDSMap/__StructToDSMap.yy",},}, + {"id":{"name":"AiFleetProblem","path":"scripts/AiFleetProblem/AiFleetProblem.yy",},}, {"id":{"name":"Armamentarium","path":"scripts/Armamentarium/Armamentarium.yy",},}, {"id":{"name":"ArtifactStruct","path":"scripts/ArtifactStruct/ArtifactStruct.yy",},}, {"id":{"name":"AudioManager","path":"scripts/AudioManager/AudioManager.yy",},}, @@ -775,6 +776,8 @@ {"id":{"name":"NotificationAlert","path":"scripts/NotificationAlert/NotificationAlert.yy",},}, {"id":{"name":"object_get_depth","path":"scripts/object_get_depth/object_get_depth.yy",},}, {"id":{"name":"PlanetProblem","path":"scripts/PlanetProblem/PlanetProblem.yy",},}, + {"id":{"name":"PlayerFleetProblem","path":"scripts/PlayerFleetProblem/PlayerFleetProblem.yy",},}, + {"id":{"name":"Problem","path":"scripts/Problem/Problem.yy",},}, {"id":{"name":"scr_add_corruption","path":"scripts/scr_add_corruption/scr_add_corruption.yy",},}, {"id":{"name":"scr_add_item","path":"scripts/scr_add_item/scr_add_item.yy",},}, {"id":{"name":"scr_add_man","path":"scripts/scr_add_man/scr_add_man.yy",},}, diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 0446b3bba7..b2e5c292c9 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1348,7 +1348,7 @@ var _build_clause = function(_prefix, _parts) { if (array_length(_parts) == 0) { return ""; } - return $"{_prefix} {string_join_ext(", ", _parts)}."; + return $"{_prefix} {string_join_ext(}, {, _parts)}."; }; LOGGER.info("Command staff"); @@ -1415,7 +1415,7 @@ for (var i = 0, l = array_length(_specialist_display); i < l; i++) { temp[35] = _build_clause("Specialist branches staffed by", _parts); var _honour_guard_count = _hq_index.has_role(_canon[eROLE.HONOURGUARD]) ? _hq_index.role_count(_canon[eROLE.HONOURGUARD]) : 0; if (_honour_guard_count > 0) { - temp[35] += $"\n\nHonour Guard, having the {_honour_guard_count} most veteran {string_plural("marine", _honour_guard_count)} of your chapter serving in it."; + temp[35] += $"\n\nHonour Guard, having the {_honour_guard_count} most veteran {string_plural(}marine{, _honour_guard_count)} of your chapter serving in it."; } var _vehicle_display = [ @@ -1496,7 +1496,7 @@ for (var i = 0; i < _ship_count; i++) { } } -temp[62] += $" {string_plural_count("warship", ships)}-\n"; +temp[62] += $" {string_plural_count(}warship{, ships)}-\n"; if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD || bb == 1) { temp[62] += $"Your flagship, Battle Barge {obj_ini.ship[0]}."; @@ -1504,19 +1504,19 @@ if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD || bb == 1) { bb--; } if (bb > 0) { - temp[62] += $"{string_plural_count("Battle Barge", bb)}: {array_to_string_order(bb_names, true)}"; + temp[62] += $"{string_plural_count(}Battle Barge{, bb)}: {array_to_string_order(bb_names, true)}"; temp[62] += "\n"; } if (sk > 0) { - temp[62] += $"{string_plural_count("Strike Cruiser", sk)}: {array_to_string_order(sk_names, true)}"; + temp[62] += $"{string_plural_count(}Strike Cruiser{, sk)}: {array_to_string_order(sk_names, true)}"; temp[62] += "\n"; } if (glad > 0) { - temp[62] += $"{string_plural_count("Gladius Escort", glad)}: {array_to_string_order(glad_names, true)}"; + temp[62] += $"{string_plural_count(}Gladius Escort{, glad)}: {array_to_string_order(glad_names, true)}"; temp[62] += "\n"; } if (hunt > 0) { - temp[62] += $"{string_plural_count("Hunter Escort", hunt)}: {array_to_string_order(hunt_names, true)}"; + temp[62] += $"{string_plural_count(}Hunter Escort{, hunt)}: {array_to_string_order(hunt_names, true)}"; temp[62] += "\n"; } diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index aa4d9c7dee..74d16eb67d 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -76,7 +76,19 @@ trade_goods = ""; capital_health = 100; frigate_health = 100; escort_health = 100; - +problems = []; +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +/// @returns {Struct.AiFleetProblem} +add_problem = function(_name, _timer, _data = {}){ + var _problem = new AiFleetProblem(_name, _timer, _data, self); + if (_problem.delete_mission){ + return undefined; + } + array_push(problems, _problem); + return _problem; +} #region save/load serialization /// Called from save function to take all object variables and convert them to a json savable format and return it @@ -132,6 +144,7 @@ deserialize = function(_save_data) { cargo_data.ork_warboss = _boss; } } + load_fleet_problems(AiFleetProblems, save_data); }; #endregion diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 6c4a6a3690..4866e55e4e 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -113,7 +113,7 @@ var _newline = ""; var _total_deaths = final_marine_deaths + final_command_deaths; var _total_injured = _total_deaths + injured + units_saved_count; if (_total_injured > 0) { - _newline = $"{string_plural_count("unit", _total_injured)} {smart_verb("was", _total_injured)} critically injured."; + _newline = $"{string_plural_count(}unit{, _total_injured)} {smart_verb(}was{, _total_injured)} critically injured."; combat_log.push(_newline, eMSG_COLOR.DEFAULT); if (units_saved_count > 0) { @@ -127,7 +127,7 @@ if (_total_injured > 0) { _units_saved_string += smart_delimeter_sign(_unit_roles, i, false); } - _newline = $"{units_saved_count}x {smart_verb("was", units_saved_count)} saved by the {string_plural(roles[eROLE.APOTHECARY], apothecaries_alive)}. ({_units_saved_string})"; + _newline = $"{units_saved_count}x {smart_verb(}was{, units_saved_count)} saved by the {string_plural(roles[eROLE.APOTHECARY], apothecaries_alive)}. ({_units_saved_string})"; combat_log.push(_newline, eMSG_COLOR.DEFAULT); } @@ -194,7 +194,7 @@ if (red_thirst > 2) { var _total_damaged_count = vehicle_deaths + vehicles_saved_count; if (_total_damaged_count > 0) { - _newline = $"{string_plural_count("vehicle", _total_damaged_count)} {smart_verb("was", _total_damaged_count)} disabled during battle."; + _newline = $"{string_plural_count(}vehicle{, _total_damaged_count)} {smart_verb(}was{, _total_damaged_count)} disabled during battle."; combat_log.push(_newline, eMSG_COLOR.DEFAULT); if (vehicles_saved_count > 0) { @@ -208,7 +208,7 @@ if (_total_damaged_count > 0) { _vehicles_saved_string += smart_delimeter_sign(_vehicle_types, i, false); } - _newline = $"{string_plural(roles[eROLE.TECHMARINE], techmarines_alive)} {smart_verb("was", techmarines_alive)} able to restore {vehicles_saved_count}. ({_vehicles_saved_string})"; + _newline = $"{string_plural(roles[eROLE.TECHMARINE], techmarines_alive)} {smart_verb(}was{, techmarines_alive)} able to restore {vehicles_saved_count}. ({_vehicles_saved_string})"; combat_log.push(_newline, eMSG_COLOR.DEFAULT); } @@ -223,7 +223,7 @@ if (_total_damaged_count > 0) { _vehicles_lost_string += smart_delimeter_sign(_vehicle_types, i, false); } - _newline = $"{vehicle_deaths} {smart_verb("was", vehicle_deaths)} lost forever. ({_vehicles_lost_string})"; + _newline = $"{vehicle_deaths} {smart_verb(}was{, vehicle_deaths)} lost forever. ({_vehicles_lost_string})"; combat_log.push(_newline, eMSG_COLOR.RED); } diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 0d4cad7fc2..45cea2e98d 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -6,7 +6,7 @@ try { obj_controller.cooldown = 10; - LOGGER.info($"Ground Combat - {(defeat ? "Defeat" : "Victory")} - Enemy:{enemy} ({battle_special})"); + LOGGER.info($"Ground Combat - {(defeat ? }Defeat {: }Victory{)} - Enemy:{enemy} ({battle_special})"); // If battling own dudes, then remove the loyalists after the fact diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 50cfc7a67b..f2f31a7cf5 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -50,19 +50,6 @@ hurssy = 0; hurssy_time = 0; /// Called from save function to take all object variables and convert them to a json savable format and return it -problems = []; -/// @param {string} _name -/// @param {Real} _timer -/// @param {struct} _data -/// @returns {Struct.FleetProblem} -add_problem = function(_name, _timer, _data = {}){ - var _problem = new FleetProblem(_name, _timer, _data, self); - if (_problem.delete_mission){ - return undefined; - } - array_push(problems, _problem); - return _problem; -} problems_to_mission_log = function(){ var _temp_log = [] @@ -213,19 +200,6 @@ deserialize = function(save_data) { // Problems, old saves won't have this key problems = []; - if (struct_exists(save_data, "problems")) { - for (var i = 0; i < array_length(save_data.problems); i++) { - try { - // empty p_id stops __init from running, load() then restores the real p_id and timer - var _problem = new FleetProblem("", 0, {}, self); - _problem.load(save_data.problems[i]); - _problem.fleet = self; - array_push(problems, _problem); - } catch (e) { - LOGGER.exception("Fleet problem deserialization failed", e); - } - } - } - + load_fleet_problems(PlayerFleetProblems, save_data); set_player_fleet_image(); }; \ No newline at end of file diff --git a/objects/obj_popup_dialogue/Draw_64.gml b/objects/obj_popup_dialogue/Draw_64.gml index 79a3999c14..a11ef42999 100644 --- a/objects/obj_popup_dialogue/Draw_64.gml +++ b/objects/obj_popup_dialogue/Draw_64.gml @@ -34,7 +34,7 @@ if (scr_hit(x + 19, y + 46, x + 280, y + 70)) { draw_set_font(fnt_40k_14); draw_set_color(c_gray); -draw_text(x + 150 + (blink ? 2 : 0), y + 50, $"{inputting}{blink ? "|" : ""}"); +draw_text(x + 150 + (blink ? 2 : 0), y + 50, $"{inputting}{blink ? }| {: }"); // Button 1s draw_set_alpha(0.25); diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml new file mode 100644 index 0000000000..81725dc25a --- /dev/null +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -0,0 +1,107 @@ +//All missions that run on a fleet need their own FleetProblem instance +//missions for the most part can only run from predefined points in the code +// to run from each of these points each mission must have a registered function these functions are then called implicitly +//each function follows the format `___` +/* the current entry points for the code are + "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn + - runs via basic_turn_end + + "init" - runs immediately after problem is created often used to populate initial popup or stack popup for turn end + + "on_arrival" - runs when the fleet arrives at a star, fleet_event_data holds {star} + "on_load" - runs when units are loaded onto the fleet, fleet_event_data holds {units} + "on_unload" - runs when units are unloaded from the fleet, fleet_event_data holds {units} + "on_split" - runs on the original fleet when it splits, fleet_event_data holds {new_fleet} + "on_merge" - runs on the receiving fleet when another fleet merges into it, fleet_event_data holds {merged_fleet} + "on_destruction" - runs when the fleet is destroyed, the mission is deleted after this function has run + - must be triggered BEFORE the fleet instance is destroyed + + "mission_log_entry" - runs to provide a data row for the mission log + +- other than these entry points and any other later defined positions mission specific code should not run outside of the FleetProblem container + +- to set an entry point up simply register the function as a static e.g + if i create static __example_per_turn once an "example" problem is registered on a fleet the per turn check will run + no other code is required + +other info + - the owning fleet must have a `problems = []` array in its create event + - entry points that receive extra information read it from fleet_event_data, which only exists for the duration of the call + - set a mission for deletion by setting delete_mission = true; this will delete the mission after the current function + has finished executing + - functions prefixed with `__` are only accessible from within the FleetProblem's internal scope +*/ + +//ANYTIME an exception is caught on a entry point for a mission the mission is prematurely deleted this ensures the player is not unfairly penalised for errors + +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +/// @param {Id.Instance.obj_p_fleet} _fleet +function FleetProblem(_name, _timer, _data, _fleet) : Problem(_name, _timer, _data) constructor{ +fleet = _fleet; + +per_turn_checks = true; + +/// @param {array} units +static on_load = function(units){ + __trigger_with_event("on_load", {units}); +} + +/// @param {array} units +static on_unload = function(units){ + __trigger_with_event("on_unload", {units}); +} + +/// @param {Id.Instance.obj_p_fleet} new_fleet +static on_split = function(new_fleet){ + __trigger_with_event("on_split", {new_fleet}); +} + +/// @param {Id.Instance.obj_p_fleet} merged_fleet +static on_merge = function(merged_fleet){ + __trigger_with_event("on_merge", {merged_fleet}); +} + +__init(); + +static __deliver_hunt_trophy_mission_log_entry = function(){ + var _mission = localize("Deliver Trophy Guard"); + var _sys = fleets_next_location(); + var _mission_data = { + mission: self, + system: _sys.name, + system_id: _sys.id, + target: self, + important_person: _event.data.trophy_owner, + person_name: _event.data.delivering_marine, + planet: 0, + start_system: _event.data.system, + time: timer, + }; + + _mission_data.click_left = method(_mission_data, function() { + set_map_pan_to_loc(system_id); + }); + + _mission_data.hover = method(_mission_data, function() { + tooltip_draw(localize("You are to have {0} deliver trophy hunted on {1} to the {1} regiments\n\nLeft click to see target fleet intercept system right click to view the trophy bearing marine {0}", [person_name, start_system])); + }); + + _mission_data.click_right = method(_mission_data, function() { + var _unit = fetch_unit_uid(important_person); + if (is_struct(_unit)) { + var _unit_l = [_unit]; + group_selection(_unit_l); + } + }); + return _mission_data; +} +} + + + + + + + diff --git a/scripts/AiFleetProblem/AiFleetProblem.yy b/scripts/AiFleetProblem/AiFleetProblem.yy new file mode 100644 index 0000000000..511715f72c --- /dev/null +++ b/scripts/AiFleetProblem/AiFleetProblem.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"AiFleetProblem", + "isCompatibility":false, + "isDnD":false, + "name":"AiFleetProblem", + "parent":{ + "name":"Constructors", + "path":"folders/Scripts/Constructors.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/Armamentarium/Armamentarium.gml b/scripts/Armamentarium/Armamentarium.gml index ae9d6abef4..24dfff19ba 100644 --- a/scripts/Armamentarium/Armamentarium.gml +++ b/scripts/Armamentarium/Armamentarium.gml @@ -112,15 +112,15 @@ function ShopItem(_name) constructor { return ""; } - return $"{localize("Missing Requirements:\n{0}", [string_join_ext("\n", missing_technologies)])}"; + return $"{localize(}Missing Requirements:\n{0}{, [string_join_ext(}\n{, missing_technologies)])}"; }; static get_buy_cost_tooltip = function() { - var _text = $"{localize("Base Value: {0}\n\n", [value])}"; + var _text = $"{localize(}Base Value: {0}\n\n{, [value])}"; var _seller = (best_seller == "rogue_trader") ? localize("Rogue Trader") : string_upper_first(best_seller); - _text += $"{localize("Best Seller: {0}\n", [_seller])}"; - _text += $"{localize("Disposition Modifier: x{0}", [buy_cost_mod])}"; + _text += $"{localize(}Best Seller: {0}\n{, [_seller])}"; + _text += $"{localize(}Disposition Modifier: x{0}{, [buy_cost_mod])}"; return _text; }; @@ -130,11 +130,11 @@ function ShopItem(_name) constructor { /// @returns {string} static get_forge_cost_tooltip = function(_stc_details = "") { var _base_forge = value * SHOP_FORGE_MOD; - var _text = $"{localize("Base Forging Cost: {0}\n", [_base_forge])}"; + var _text = $"{localize(}Base Forging Cost: {0}\n{, [_base_forge])}"; if (_stc_details != "") { _text += $"\n{_stc_details}"; - _text += $"\n{localize("Total Modifier: x{0}", [string_format(forge_cost_mod, 1, 2)])}"; + _text += $"\n{localize(}Total Modifier: x{0}{, [string_format(forge_cost_mod, 1, 2)])}"; } return _text; @@ -362,7 +362,7 @@ function STCResearchPanel(_controller_ref, _on_change_callback) constructor { draw_set_font(cjk_font(fnt_aldrich_12)); draw_set_color(c_gray); - draw_text(_x + 34, _y, $"{localize("{0} Unidentified Fragments", [_total_un])}"); + draw_text(_x + 34, _y, $"{localize(}{0} Unidentified Fragments{, [_total_un])}"); var _has_fragments = _total_un > 0; draw_set_alpha(_has_fragments ? 1 : 0.25); @@ -811,7 +811,7 @@ function Armamentarium(_controller) constructor { case "mobility": discount_stc = controller.stc_wargear * 5; if (discount_stc > 0) { - global_cost_tooltip += $"{localize("Wargear STC: -{0}%\n", [discount_stc])}"; + global_cost_tooltip += $"{localize(}Wargear STC: -{0}%\n{, [discount_stc])}"; } break; case "vehicles": @@ -819,13 +819,13 @@ function Armamentarium(_controller) constructor { var _hanger_bonus = max(array_length(controller.player_forge_data.vehicle_hanger) - 1, 0); discount_stc = (controller.stc_vehicles + _hanger_bonus) * 3; if (discount_stc > 0) { - global_cost_tooltip += $"{localize("Vehicle STC & Hangars: -{0}%\n", [discount_stc])}"; + global_cost_tooltip += $"{localize(}Vehicle STC & Hangars: -{0}%\n{, [discount_stc])}"; } break; case "ships": discount_stc = controller.stc_ships * 5; if (discount_stc > 0) { - global_cost_tooltip += $"{localize("Ship STC: -{0}%\n", [discount_stc])}"; + global_cost_tooltip += $"{localize(}Ship STC: -{0}%\n{, [discount_stc])}"; } break; } @@ -839,22 +839,22 @@ function Armamentarium(_controller) constructor { var _diff = _max_techs - count_total; var _req_dispo = (abs(_diff) * 2) + ((_dispo_mech % 2 == 0) ? 2 : 1); - var _text = $"{localize("Subject ID confirmed. Rank Identified. Salutations Chapter Master. The status report is ready.")}"; - _text += $"\n\n{localize("Personnel: {0}s: {1}, Aspirants: {2}.", [_role_tech, count_techmarines, count_aspirants])}"; - _text += $"\n\n{localize("Training: ")}"; + var _text = $"{localize(}Subject ID confirmed. Rank Identified. Salutations Chapter Master. The status report is ready.{)}"; + _text += $"\n\n{localize(}Personnel: {0}s: {1}, Aspirants: {2}.{, [_role_tech, count_techmarines, count_aspirants])}"; + _text += $"\n\n{localize(}Training: {)}"; if (controller.faction_status[eFACTION.MECHANICUS] != "War") { - _text += (_diff > 0) ? $"{localize("We can train {0} more {1}(s).", [_diff, _role_tech])}" : $"{localize("To train more, we need {0} more Mechanicus Disposition.", [_req_dispo])}"; + _text += (_diff > 0) ? $"{localize(}We can train {0} more {1}(s).{, [_diff, _role_tech])}" : $"{localize(}To train more, we need {0} more Mechanicus Disposition.{, [_req_dispo])}"; } else { - _text += $"{localize("Training handled internally due to Mechanicus hostilities.")}"; + _text += $"{localize(}Training handled internally due to Mechanicus hostilities.{)}"; } var _pace = controller.training_techmarine; - _text += $"{localize(" The training pace is {0}.", [global.recruitment_pace_descriptions[_pace] ?? localize("unknown")])}"; + _text += $"{localize(} The training pace is {0}.{, [global.recruitment_pace_descriptions[_pace] ?? localize(}unknown{)])}"; if (controller.tech_aspirant > 0 && _pace > 0) { var _eta_val = floor((359 - controller.tech_points) / global.techmarine_training_tiers[_pace]) + 1; - _text += $"{localize(" An Aspirant will finish training in {0} month(s).", [_eta_val])}"; + _text += $"{localize(} An Aspirant will finish training in {0} month(s).{, [_eta_val])}"; } advisor_report_text = _text; }; @@ -1167,12 +1167,12 @@ function Armamentarium(_controller) constructor { var _master_craft = controller.master_craft_chance; var _forge_count = controller.player_forge_data.player_forges; - var _text = $"{localize("Status Report:\n\n")}"; - _text += $"{localize("Forge Point production per turn: {0}\n", [controller.forge_points])}"; - _text += $"{localize("Chapter Total {0}s: {1}\n\n", [_role_name, count_total])}"; - _text += $"{localize("Planetary Forges in operation: {0}\n\n", [_forge_count])}"; - _text += $"{localize("Master Craft Forge Chance: {0}%\n", [_master_craft])}"; - _text += $"{localize("Assign techmarines to forges to increase Master Craft Chance")}"; + var _text = $"{localize(}Status Report:\n\n{)}"; + _text += $"{localize(}Forge Point production per turn: {0}\n{, [controller.forge_points])}"; + _text += $"{localize(}Chapter Total {0}s: {1}\n\n{, [_role_name, count_total])}"; + _text += $"{localize(}Planetary Forges in operation: {0}\n\n{, [_forge_count])}"; + _text += $"{localize(}Master Craft Forge Chance: {0}%\n{, [_master_craft])}"; + _text += $"{localize(}Assign techmarines to forges to increase Master Craft Chance{)}"; draw_set_color(c_gray); draw_set_font(cjk_font(fnt_aldrich_12)); diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index c3c16f9f28..fe4858352f 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -37,7 +37,7 @@ other info /// @param {string} _name /// @param {Real} _timer /// @param {struct} _data -/// @param {Id.Instance.obj_p_fleet} _fleet +/// @param {Id.Instance.obj_p_fleet} | {Id.Instance.obj_en_fleet} _fleet function FleetProblem(_name, _timer, _data, _fleet) : Problem(_name, _timer, _data) constructor{ fleet = _fleet; @@ -60,19 +60,6 @@ static load = function(data){ move_data_to_current_scope(data); } -//requires the completion and required_months flag to be in the data struct -static __increment_mission_completion = function() { - if (!struct_exists(data, "completion")) { - data.completion = 0; - } - data.completion++; - if (!struct_exists(data, "required_months") || data.required_months <= 0) { - LOGGER.error("Invalid required_months in mission_data"); - return 0; - } - return (data.completion / data.required_months) * 100; -} - static __check_delete = function(){ if (timer == -1 || (delete_mission)){ if (!instance_exists(fleet)){ @@ -115,16 +102,6 @@ static on_arrival = function(star){ __trigger_with_event("on_arrival", {star}); } -/// @param {array} units -static on_load = function(units){ - __trigger_with_event("on_load", {units}); -} - -/// @param {array} units -static on_unload = function(units){ - __trigger_with_event("on_unload", {units}); -} - /// @param {Id.Instance.obj_p_fleet} new_fleet static on_split = function(new_fleet){ __trigger_with_event("on_split", {new_fleet}); @@ -184,292 +161,6 @@ static __init = function(){ __handle_triggered_mission_func(_func); } } -__init(); - -static __great_crusade_init = function(){ - var _crusade_direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); - fleet.action_x = fleet.x + lengthdir_x(1200, _crusade_direction); - fleet.action_y = fleet.y + lengthdir_y(1200, _crusade_direction); - fleet.move(false, "move"); - stage_id = "travel_to_crusade"; - fleet.beyond_engagement = true; -} - -static __great_crusade_on_final_arrival = function(){ - if (stage_id == "travel_to_crusade"){ - var _direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); - fleet.action_x = fleet.x + lengthdir_x(600, _direction); - fleet.action_y = fleet.y + lengthdir_y(600, _direction); - fleet.move(false, "move"); - stage_id = "crusading" - fleet.beyond_engagement = true; - } else if (stage_id == "crusading"){ - with (obj_star) { - if (owner > 5) { - instance_deactivate_object(id); - } - var enemies = false; - for (var i = 6; i < 13; i++) { - if (scr_orbiting_fleet(i) != noone) { - enemies = true; - break; - } - } - if (enemies) { - instance_deactivate_object(id); - } - } - var _return_star = instance_nearest(fleet.x, fleet.y, obj_star); - fleet.action_x = _return_star.x; - fleet.action_y = _return_star.y; - fleet.move(false, "move"); - instance_activate_object(obj_star); - fleet.beyond_engagement = true; - stage_id = "returning_home" - } else if (stage_id == "returning_home"){ - __great_crusade_results(); - fleet.beyond_engagement = false; - } -} - -static __great_crusade_status_description = function(){ - -} - -static __great_crusade_results = function(){ - var _apoth = 0, _death_determination = 0, _death_determination_2 = 0, _roll3 = 0, _type = "", _artifacts = 0; - var _seed = 0; - var _marines_lost = 0; - var _heroics_strings = []; - var _clean = []; - - //index 1: death_determine 1 //index 2: death_determine 2 /index 3: apoth_recovery - //index 3 exp_gains irandom + static - var death_sets = { - normal: [ - 80, - 90, - 40, - [ - 5, - 10, - ], - ], - hard: [ - 60, - 80, - 30, - [ - 20, - 20, - ], - ], - brutal: [ - 20, - 65, - 20, - [ - 40, - 20, - ], - ], - }; - - _death_determination = floor(random(100)) + 1; - _roll3 = irandom(99) + 1; - - if (_death_determination <= 50) { - _type = "normal"; - _artifacts = choose(0, 0, 0, 0, 0, 1); - } else if (_death_determination > 50 && _death_determination <= 80) { - _type = "hard"; - _artifacts = choose(0, 0, 1); - } else if (_death_determination > 80) { - _type = "brutal"; - _artifacts = choose(1, 2, 3); - } - - var death_data = death_sets[$ _type]; - - for (var co = 0; co <= obj_ini.companies; co++) { - _clean[co] = 0; - } - var total_ship_id = array_concat(fleet.capital_num, fleet.frigate_num, fleet.escort_num); - - var _units = collect_role_group("all", ["", 0 , total_ship_id],false, {}, true); - for (var i = 0; i < _units.number(); i++){ - var _unit = _units.units[i]; - - _death_determination = floor(random(100)) + 1; - //specialist trait greatly reduces death risk - //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait - if (_unit.has_trait("very_hard_to_kill")) { - _death_determination -= 20; - } - _death_determination_2 = _death_determination; - _death_determination -= _unit.experience / 2; - - //more generalised trait bonus mainly linked to chapter advantage of same name - if (_unit.has_trait("slow_and_purposeful")) { - _death_determination -= 10; - } - - var _dead = false; - if (_death_determination > death_data[0] || _death_determination_2 > death_data[1]) { - _dead = true; - if (_unit.has_role(eROLE.CAPTAIN)) { - if (irandom(20) < _unit.luck) { - _dead = false; - } else { - if (irandom(100) < _unit.weapon_skill) { - var _heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); - //TODO figure out a blance in reward for captains or high rnaking death on crusade - //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades - //var consolations = ["ship", "req",""] - //var consolation_prize = irandom(2) - var heroic_death = $"{_unit.full_title()} died {_heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; - array_push(_heroics_strings, heroic_death); - } - } - } else if (_unit.has_role(eROLE.ANCIENT) || _unit.has_role(eROLE.CHAPTERMASTER)) { - _dead = false; - } - } - if (_dead) { - obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); - if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { - obj_controller.command--; - } else { - obj_controller.marines--; - } - - _clean[co] = 1; - _marines_lost++; - _unit.kill(false, true); - } else { - if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { - _apoth++; - } - _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); - - if (irandom(99) == 1 && irandom(20) < _unit.luck) { - var _heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); - _unit.add_trait(_heroic_deed); - array_push(_heroics_strings, string(global.trait_list[$ _heroic_deed].flavour_text, _unit.full_title())); - } - } - } - - if (obj_ini.doomed == 0) { - if (_apoth > 0) { - _seed = min(_seed, _apoth * death_data[2]); - } - if (_apoth == 0) { - _seed = floor(_seed * 0.2); - } - obj_controller.gene_seed += _seed; - } - - with (obj_ini) { - for (var _c = 0; _c <= obj_ini.companies; _c++) { - scr_company_order(_c); - } - } - - if (_roll3 <= 10) { - _artifacts += 1; - } - if (_artifacts > 0) { - repeat (_artifacts) { - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - scr_add_artifact("random", "", 4, obj_ini.home_name, -1); - } - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - scr_add_artifact("random", "", 4, obj_ini.ship[0], 0); - } - } - } - - var tixt = "Your ships have returned from the Crusade. "; - if (_type == "normal") { - tixt += "The combat was as could be expected- "; - } - if (_type == "hard") { - tixt += "The combat was fairly grueling- "; - } - if (_type == "brutal") { - tixt += "The combat was absolutely brutal- fleet.your marines were the first into the fray, and as a result "; - } - - tixt += $"{_marines_lost} of fleet.your battle brothers fell in combat."; - - var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY].role; - if (obj_ini.doomed == 0) { - if ((_apoth > 0) && (_seed > 0)) { - tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; - } - if ((_apoth == 0) && (_seed > 0)) { - tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of fleet.your Gene-Seed."; - } - } - if (obj_ini.doomed == 1) { - tixt += " Due to fatal mutations in fleet.your marines none of the fallen Gene-Seed was recoverable."; - } - - if (_artifacts > 0) { - tixt += $" {_artifacts} Artifacts were granted to your Chapter or looted."; - } - if ((_roll3 <= 10) && (_artifacts > 1)) { - tixt += " One of them were given as a bonus for exceptional valor."; - } - - if (array_length(_heroics_strings) == 1) { - tixt += " A heroic deed was recorded"; - } else if (array_length(_heroics_strings) > 1) { - tixt += " Several deeds were recorded"; - } - // title / text / image / speshul - scr_popup("Crusade Results", tixt, "crusade", ""); - for (var i = 0; i < array_length(_heroics_strings); i++) { - scr_popup("Heroic Deed", _heroics_strings[i], "crusade", ""); - } - - delete_mission = true; - fleet.action = ""; -} - -static __deliver_hunt_trophy_mission_log_entry = function(){ - var _mission = localize("Deliver Trophy Guard"); - var _sys = fleets_next_location(); - var _mission_data = { - mission: self, - system: _sys.name, - system_id: _sys.id, - target: self, - important_person: _event.data.trophy_owner, - person_name: _event.data.delivering_marine, - planet: 0, - start_system: _event.data.system, - time: timer, - }; - - _mission_data.click_left = method(_mission_data, function() { - set_map_pan_to_loc(system_id); - }); - - _mission_data.hover = method(_mission_data, function() { - tooltip_draw(localize("You are to have {0} deliver trophy hunted on {1} to the {1} regiments\n\nLeft click to see target fleet intercept system right click to view the trophy bearing marine {0}", [person_name, start_system])); - }); - - _mission_data.click_right = method(_mission_data, function() { - var _unit = fetch_unit_uid(important_person); - if (is_struct(_unit)) { - var _unit_l = [_unit]; - group_selection(_unit_l); - } - }); - return _mission_data; -} } diff --git a/scripts/GitHub/GitHub.gml b/scripts/GitHub/GitHub.gml index b5a08edb8d..82b75d32c7 100644 --- a/scripts/GitHub/GitHub.gml +++ b/scripts/GitHub/GitHub.gml @@ -626,16 +626,16 @@ function GitHub(_authToken = undefined) constructor { _queryParams += $"since={_since}&"; } if (_collab != undefined) { - _queryParams += $"collab={_collab ? "true" : "false"}&"; + _queryParams += $"collab={_collab ? }true {: }false&"; } if (_orgs != undefined) { - _queryParams += $"orgs={_orgs ? "true" : "false"}&"; + _queryParams += $"orgs={_orgs ? }true {: }false&"; } if (_owned != undefined) { - _queryParams += $"owned={_owned ? "true" : "false"}&"; + _queryParams += $"owned={_owned ? }true {: }false&"; } if (_pulls != undefined) { - _queryParams += $"pulls={_pulls ? "true" : "false"}&"; + _queryParams += $"pulls={_pulls ? }true {: }false&"; } if (_perPage != undefined || _page != undefined) { _queryParams += __buildPaginationQueryParams(_perPage, _page); diff --git a/scripts/LocalizationManager/LocalizationManager.gml b/scripts/LocalizationManager/LocalizationManager.gml index a91b567168..1099e2a430 100644 --- a/scripts/LocalizationManager/LocalizationManager.gml +++ b/scripts/LocalizationManager/LocalizationManager.gml @@ -73,7 +73,7 @@ function LocalizationManager() constructor { } if (array_length(_missing_keys) > 0) { - LOGGER.warning($"Language '{self.language}' is missing {array_length(_missing_keys)} translations from '{LANG_EN}': {string_join_ext(", ", _missing_keys)}"); + LOGGER.warning($"Language '{self.language}' is missing {array_length(_missing_keys)} translations from '{LANG_EN}': {string_join_ext(}, {, _missing_keys)}"); } }; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 7fdc984c7c..3d93358e68 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -94,45 +94,6 @@ static view_on_planet_screen = function(){ return (stage_id == "preliminary") && (has_data("applicant")); } -//requires the completion and required_months flag to be in the data struct -static __increment_mission_completion = function() { - if (!struct_exists(data, "completion")) { - data.completion = 0; - } - data.completion++; - if (!struct_exists(data, "required_months") || data.required_months <= 0) { - LOGGER.error("Invalid required_months in mission_data"); - return 0; - } - return (data.completion / data.required_months) * 100; -} - -static __inquisition_mission_options = function(){ - var _options = [ - { - str1: "Accept", - choice_func: function(){ - var _mission = pop_data.mission - var _func_str = _mission.find_func_ref("accept"); - if (struct_exists(_mission, _func_str)){ - _mission[$ _func_str](); - } - obj_controller.demanding = 0; - } - }, - ]; - if (!obj_controller.demanding){ - array_push(_options, { - str1: "Refuse", - choice_func: function(){ - pop_data.mission.delete_mission = true; - popup_default_close(); - } - }) - } - return _options -} - static __check_delete = function(){ if (timer == -1 || (delete_mission)){ var _prob = -1; diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml new file mode 100644 index 0000000000..8180dd3e64 --- /dev/null +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -0,0 +1,359 @@ +//All missions that run on a fleet need their own FleetProblem instance +//missions for the most part can only run from predefined points in the code +// to run from each of these points each mission must have a registered function these functions are then called implicitly +//each function follows the format `___` +/* the current entry points for the code are + "per_turn" - runs every end turn to check for certain conditions often contains reactions to actions player has done last turn + - runs via basic_turn_end + + "init" - runs immediately after problem is created often used to populate initial popup or stack popup for turn end + + "on_arrival" - runs when the fleet arrives at a star, fleet_event_data holds {star} + "on_load" - runs when units are loaded onto the fleet, fleet_event_data holds {units} + "on_unload" - runs when units are unloaded from the fleet, fleet_event_data holds {units} + "on_split" - runs on the original fleet when it splits, fleet_event_data holds {new_fleet} + "on_merge" - runs on the receiving fleet when another fleet merges into it, fleet_event_data holds {merged_fleet} + "on_destruction" - runs when the fleet is destroyed, the mission is deleted after this function has run + - must be triggered BEFORE the fleet instance is destroyed + + "mission_log_entry" - runs to provide a data row for the mission log + +- other than these entry points and any other later defined positions mission specific code should not run outside of the FleetProblem container + +- to set an entry point up simply register the function as a static e.g + if i create static __example_per_turn once an "example" problem is registered on a fleet the per turn check will run + no other code is required + +other info + - the owning fleet must have a `problems = []` array in its create event + - entry points that receive extra information read it from fleet_event_data, which only exists for the duration of the call + - set a mission for deletion by setting delete_mission = true; this will delete the mission after the current function + has finished executing + - functions prefixed with `__` are only accessible from within the FleetProblem's internal scope +*/ + +//ANYTIME an exception is caught on a entry point for a mission the mission is prematurely deleted this ensures the player is not unfairly penalised for errors + +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +/// @param {Id.Instance.obj_p_fleet} _fleet +function PlayerFleetProblem(_name, _timer, _data, _fleet) : FleetProblem(_name, _timer, _data) constructor{ +fleet = _fleet; + +per_turn_checks = true; + +/// @param {array} units +static on_load = function(units){ + __trigger_with_event("on_load", {units}); +} + +/// @param {array} units +static on_unload = function(units){ + __trigger_with_event("on_unload", {units}); +} + +/// @param {Id.Instance.obj_p_fleet} new_fleet +static on_split = function(new_fleet){ + __trigger_with_event("on_split", {new_fleet}); +} + +/// @param {Id.Instance.obj_p_fleet} merged_fleet +static on_merge = function(merged_fleet){ + __trigger_with_event("on_merge", {merged_fleet}); +} + +__init(); + +static __great_crusade_init = function(){ + var _crusade_direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); + fleet.action_x = fleet.x + lengthdir_x(1200, _crusade_direction); + fleet.action_y = fleet.y + lengthdir_y(1200, _crusade_direction); + fleet.move(false, "move"); + stage_id = "travel_to_crusade"; + fleet.beyond_engagement = true; +} + +static __great_crusade_on_final_arrival = function(){ + if (stage_id == "travel_to_crusade"){ + var _direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); + fleet.action_x = fleet.x + lengthdir_x(600, _direction); + fleet.action_y = fleet.y + lengthdir_y(600, _direction); + fleet.move(false, "move"); + stage_id = "crusading" + fleet.beyond_engagement = true; + } else if (stage_id == "crusading"){ + with (obj_star) { + if (owner > 5) { + instance_deactivate_object(id); + } + var enemies = false; + for (var i = 6; i < 13; i++) { + if (scr_orbiting_fleet(i) != noone) { + enemies = true; + break; + } + } + if (enemies) { + instance_deactivate_object(id); + } + } + var _return_star = instance_nearest(fleet.x, fleet.y, obj_star); + fleet.action_x = _return_star.x; + fleet.action_y = _return_star.y; + fleet.move(false, "move"); + instance_activate_object(obj_star); + fleet.beyond_engagement = true; + stage_id = "returning_home" + } else if (stage_id == "returning_home"){ + __great_crusade_results(); + fleet.beyond_engagement = false; + } +} + +static __great_crusade_status_description = function(){ + +} + +static __great_crusade_results = function(){ + var _apoth = 0, _death_determination = 0, _death_determination_2 = 0, _roll3 = 0, _type = "", _artifacts = 0; + var _seed = 0; + var _marines_lost = 0; + var _heroics_strings = []; + var _clean = []; + + //index 1: death_determine 1 //index 2: death_determine 2 /index 3: apoth_recovery + //index 3 exp_gains irandom + static + var death_sets = { + normal: [ + 80, + 90, + 40, + [ + 5, + 10, + ], + ], + hard: [ + 60, + 80, + 30, + [ + 20, + 20, + ], + ], + brutal: [ + 20, + 65, + 20, + [ + 40, + 20, + ], + ], + }; + + _death_determination = floor(random(100)) + 1; + _roll3 = irandom(99) + 1; + + if (_death_determination <= 50) { + _type = "normal"; + _artifacts = choose(0, 0, 0, 0, 0, 1); + } else if (_death_determination > 50 && _death_determination <= 80) { + _type = "hard"; + _artifacts = choose(0, 0, 1); + } else if (_death_determination > 80) { + _type = "brutal"; + _artifacts = choose(1, 2, 3); + } + + var death_data = death_sets[$ _type]; + + for (var co = 0; co <= obj_ini.companies; co++) { + _clean[co] = 0; + } + var total_ship_id = array_concat(fleet.capital_num, fleet.frigate_num, fleet.escort_num); + + var _units = collect_role_group("all", ["", 0 , total_ship_id],false, {}, true); + for (var i = 0; i < _units.number(); i++){ + var _unit = _units.units[i]; + + _death_determination = floor(random(100)) + 1; + //specialist trait greatly reduces death risk + //TODO figure out how to quantify and present these risks so the player knows to protect dudes with trait + if (_unit.has_trait("very_hard_to_kill")) { + _death_determination -= 20; + } + _death_determination_2 = _death_determination; + _death_determination -= _unit.experience / 2; + + //more generalised trait bonus mainly linked to chapter advantage of same name + if (_unit.has_trait("slow_and_purposeful")) { + _death_determination -= 10; + } + + var _dead = false; + if (_death_determination > death_data[0] || _death_determination_2 > death_data[1]) { + _dead = true; + if (_unit.has_role(eROLE.CAPTAIN)) { + if (irandom(20) < _unit.luck) { + _dead = false; + } else { + if (irandom(100) < _unit.weapon_skill) { + var _heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); + //TODO figure out a blance in reward for captains or high rnaking death on crusade + //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades + //var consolations = ["ship", "req",""] + //var consolation_prize = irandom(2) + var heroic_death = $"{_unit.full_title()} died {_heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; + array_push(_heroics_strings, heroic_death); + } + } + } else if (_unit.has_role(eROLE.ANCIENT) || _unit.has_role(eROLE.CHAPTERMASTER)) { + _dead = false; + } + } + if (_dead) { + obj_ini.ship_carrying[_unit.ship_location] -= _unit.get_unit_size(); + if (_unit.IsSpecialist(SPECIALISTS_STANDARD, true)) { + obj_controller.command--; + } else { + obj_controller.marines--; + } + + _clean[co] = 1; + _marines_lost++; + _unit.kill(false, true); + } else { + if (_unit.IsSpecialist(SPECIALISTS_APOTHECARIES) && (_unit.gear() == "Narthecium")) { + _apoth++; + } + _unit.add_exp(irandom(death_data[3][0]) + death_data[3][1]); + + if (irandom(99) == 1 && irandom(20) < _unit.luck) { + var _heroic_deed = choose("still_standing", "lone_survivor", "beast_slayer"); + _unit.add_trait(_heroic_deed); + array_push(_heroics_strings, string(global.trait_list[$ _heroic_deed].flavour_text, _unit.full_title())); + } + } + } + + if (obj_ini.doomed == 0) { + if (_apoth > 0) { + _seed = min(_seed, _apoth * death_data[2]); + } + if (_apoth == 0) { + _seed = floor(_seed * 0.2); + } + obj_controller.gene_seed += _seed; + } + + with (obj_ini) { + for (var _c = 0; _c <= obj_ini.companies; _c++) { + scr_company_order(_c); + } + } + + if (_roll3 <= 10) { + _artifacts += 1; + } + if (_artifacts > 0) { + repeat (_artifacts) { + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + scr_add_artifact("random", "", 4, obj_ini.home_name, -1); + } + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + scr_add_artifact("random", "", 4, obj_ini.ship[0], 0); + } + } + } + + var tixt = "Your ships have returned from the Crusade. "; + if (_type == "normal") { + tixt += "The combat was as could be expected- "; + } + if (_type == "hard") { + tixt += "The combat was fairly grueling- "; + } + if (_type == "brutal") { + tixt += "The combat was absolutely brutal- fleet.your marines were the first into the fray, and as a result "; + } + + tixt += $"{_marines_lost} of fleet.your battle brothers fell in combat."; + + var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY].role; + if (obj_ini.doomed == 0) { + if ((_apoth > 0) && (_seed > 0)) { + tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; + } + if ((_apoth == 0) && (_seed > 0)) { + tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of fleet.your Gene-Seed."; + } + } + if (obj_ini.doomed == 1) { + tixt += " Due to fatal mutations in fleet.your marines none of the fallen Gene-Seed was recoverable."; + } + + if (_artifacts > 0) { + tixt += $" {_artifacts} Artifacts were granted to your Chapter or looted."; + } + if ((_roll3 <= 10) && (_artifacts > 1)) { + tixt += " One of them were given as a bonus for exceptional valor."; + } + + if (array_length(_heroics_strings) == 1) { + tixt += " A heroic deed was recorded"; + } else if (array_length(_heroics_strings) > 1) { + tixt += " Several deeds were recorded"; + } + // title / text / image / speshul + scr_popup("Crusade Results", tixt, "crusade", ""); + for (var i = 0; i < array_length(_heroics_strings); i++) { + scr_popup("Heroic Deed", _heroics_strings[i], "crusade", ""); + } + + delete_mission = true; + fleet.action = ""; +} + +static __deliver_hunt_trophy_mission_log_entry = function(){ + var _mission = localize("Deliver Trophy Guard"); + var _sys = fleets_next_location(); + var _mission_data = { + mission: self, + system: _sys.name, + system_id: _sys.id, + target: self, + important_person: _event.data.trophy_owner, + person_name: _event.data.delivering_marine, + planet: 0, + start_system: _event.data.system, + time: timer, + }; + + _mission_data.click_left = method(_mission_data, function() { + set_map_pan_to_loc(system_id); + }); + + _mission_data.hover = method(_mission_data, function() { + tooltip_draw(localize("You are to have {0} deliver trophy hunted on {1} to the {1} regiments\n\nLeft click to see target fleet intercept system right click to view the trophy bearing marine {0}", [person_name, start_system])); + }); + + _mission_data.click_right = method(_mission_data, function() { + var _unit = fetch_unit_uid(important_person); + if (is_struct(_unit)) { + var _unit_l = [_unit]; + group_selection(_unit_l); + } + }); + return _mission_data; +} +} + + + + + + + diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.yy b/scripts/PlayerFleetProblem/PlayerFleetProblem.yy new file mode 100644 index 0000000000..f695cbe860 --- /dev/null +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"PlayerFleetProblem", + "isCompatibility":false, + "isDnD":false, + "name":"PlayerFleetProblem", + "parent":{ + "name":"Constructors", + "path":"folders/Scripts/Constructors.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml new file mode 100644 index 0000000000..b45c3bb732 --- /dev/null +++ b/scripts/Problem/Problem.gml @@ -0,0 +1,101 @@ +/// @param {string} _name +/// @param {Real} _timer +/// @param {struct} _data +function Problem(_name, _timer, _data) constructor { + p_id = _name; + timer = _timer; + data = _data; + uid = scr_uuid_generate(); + delete_mission = false; + f_type = eP_FEATURES.MISSION; + stage_id = ""; + if (struct_exists(data, "stage")){ + stage_id = data.stage; + } + if (struct_exists(data, "members")){ + members = data.members; + } + static has_data = function(key){ + return struct_exists(data, key); + } + static description = function(){ + var _n = mission_name_key(p_id); + _n = _n == "" ? p_id : _n; + return _n; + } + static __popup_delete = function(){ + with(obj_popup){ + popup_default_close(); + } + __check_delete(); + } + + static find_func_ref = function(trigger_string){ + var _func_string = "__" + p_id + "_" + trigger_string; + return _func_string; + } + + static has_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + return struct_exists(self,_func_string); + } + static find_func = function(trigger_string){ + var _func_string = find_func_ref(trigger_string); + if (struct_exists(self,_func_string)){ + return self[$ _func_string] + } + return undefined; + } + static __handle_triggered_mission_func = function(func){ + if (!is_undefined(func)){ + __refresh_data(); + try { + func(); + } catch (_exception) { + delete_mission = true; + ERROR_HANDLER.handle_exception(_exception); + } + } + __check_delete(); + obj_controller.location_viewer.update_mission_log(); + } + + //requires the completion and required_months flag to be in the data struct + static __increment_mission_completion = function() { + if (!struct_exists(data, "completion")) { + data.completion = 0; + } + data.completion++; + if (!struct_exists(data, "required_months") || data.required_months <= 0) { + LOGGER.error("Invalid required_months in mission_data"); + return 0; + } + return (data.completion / data.required_months) * 100; + } + + static __inquisition_mission_options = function(){ + var _options = [ + { + str1: "Accept", + choice_func: function(){ + var _mission = pop_data.mission + var _func_str = _mission.find_func_ref("accept"); + if (struct_exists(_mission, _func_str)){ + _mission[$ _func_str](); + } + obj_controller.demanding = 0; + } + }, + ]; + if (!obj_controller.demanding){ + array_push(_options, { + str1: "Refuse", + choice_func: function(){ + pop_data.mission.delete_mission = true; + popup_default_close(); + } + }) + } + return _options + } +} \ No newline at end of file diff --git a/scripts/Problem/Problem.yy b/scripts/Problem/Problem.yy new file mode 100644 index 0000000000..8d1a3f3f4d --- /dev/null +++ b/scripts/Problem/Problem.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"Problem", + "isCompatibility":false, + "isDnD":false, + "name":"Problem", + "parent":{ + "name":"Constructors", + "path":"folders/Scripts/Constructors.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file diff --git a/scripts/scr_bomb_world/scr_bomb_world.gml b/scripts/scr_bomb_world/scr_bomb_world.gml index e6d00bc1de..333aab42cf 100644 --- a/scripts/scr_bomb_world/scr_bomb_world.gml +++ b/scripts/scr_bomb_world/scr_bomb_world.gml @@ -13,7 +13,7 @@ function scr_bomb_world(bombard_target_faction, bombard_ment_power, target_stren if (obj_bomb_select.ships_selected == 1) { txt1 += "s"; } - txt1 += $" annihilation upon {name()}. Even from space the explosions can be seen, {choose("tearing ground", "hammering", "battering", "thundering")} across the planet's surface."; + txt1 += $" annihilation upon {name()}. Even from space the explosions can be seen, {choose(}tearing ground{, }hammering{, }battering{, }thundering{)} across the planet's surface."; kill = population_small_conversion(0.15); diff --git a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml index 5a4191503b..3881721542 100644 --- a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml +++ b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml @@ -304,7 +304,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l } } - var exp_string = $"{localize("{0} EXP", [round(ma_exp[selected])])}"; + var exp_string = $"{localize(}{0} EXP{, [round(ma_exp[selected])])}"; var hpText = [ xx + 240 + 8, yy + 66, 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 f90af67641..4666a26930 100644 --- a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml +++ b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml @@ -741,7 +741,7 @@ function scr_enemy_ai_a() { 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"; + tixt += $". {_garrison.garrison_sustain_damages(}loose{)} Marines Lost"; } scr_alert("red", "owner", tixt, x, y); } @@ -749,7 +749,7 @@ function scr_enemy_ai_a() { 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"; + tixt += $". {_garrison.garrison_sustain_damages(}win{)} Marines Lost"; } scr_alert("green", "owner", tixt, x, y); } diff --git a/scripts/scr_equipment_struct/scr_equipment_struct.gml b/scripts/scr_equipment_struct/scr_equipment_struct.gml index 4cf64f4647..1c1433b78c 100644 --- a/scripts/scr_equipment_struct/scr_equipment_struct.gml +++ b/scripts/scr_equipment_struct/scr_equipment_struct.gml @@ -376,7 +376,7 @@ function EquipmentStruct(item_data = undefined, core_type = "", quality_request break; case "req_exp": if (req_exp > 0) { - item_desc_tooltip += $"{localize("#Requires {0} EXP#", [req_exp])}"; + item_desc_tooltip += $"{localize(}#Requires {0} EXP#{, [req_exp])}"; } break; case "tags": diff --git a/scripts/scr_flavor/scr_flavor.gml b/scripts/scr_flavor/scr_flavor.gml index 04b851e343..6f058dcd13 100644 --- a/scripts/scr_flavor/scr_flavor.gml +++ b/scripts/scr_flavor/scr_flavor.gml @@ -329,7 +329,7 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot flavoured = true; if (!character_shot) { if (number_of_shots < 10) { - attack_message += $"{number_of_shots} vehicle{((number_of_shots > 1) ? "s" : "")} thunder forward, armoured hulls crashing into the enemy lines- "; + attack_message += $"{number_of_shots} vehicle{((number_of_shots > 1) ? }s {: }{)} thunder forward, armoured hulls crashing into the enemy lines- "; } else { attack_message += $"An armoured column of {number_of_shots} vehicles smashes into the enemy, grinding everything in its path- "; } diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index f1a64ce6c4..6583eea55a 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -27,7 +27,7 @@ function scr_librarium_gui() { } /// @type {Struct.ArtifactStruct} var cur_arti = fetch_artifact(menu_artifact); - var artif_descr = $"This artifact is an unidentified {cur_arti.get_type_name()}.##It is stored on {cur_arti.get_ship_id() > -1 ? "the ship" : ""} '{cur_arti.get_location_string()}'."; + var artif_descr = $"This artifact is an unidentified {cur_arti.get_type_name()}.##It is stored on {cur_arti.get_ship_id() > -1 ? }the ship {: } '{cur_arti.get_location_string()}'."; var artif_timer = cur_arti.get_identification_timer(); draw_set_color(#5F730D); diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index a66eb15dc9..d8bc7a8713 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -144,7 +144,7 @@ function scr_livery_setup() { draw_set_font(cjk_font(fnt_40k_30b)); draw_set_halign(fa_center); if (_livery_type != 2) { - var liv_string = $"Full Livery \n{livery_picker.role_set == 0 ? "default" : player_role_data[livery_picker.role_set].role}"; + var liv_string = $"Full Livery \n{livery_picker.role_set == 0 ? }default {: player_role_data[livery_picker.role_set].role}"; draw_text(160, 100, liv_string); } else { draw_text(160, 100, "Company Livery"); diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index 05e270a406..f7b14f5053 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -1,65 +1,3 @@ -/// @param {string} _name -/// @param {Real} _timer -/// @param {struct} _data -function Problem(_name, _timer, _data) constructor { - p_id = _name; - timer = _timer; - data = _data; - uid = scr_uuid_generate(); - delete_mission = false; - f_type = eP_FEATURES.MISSION; - stage_id = ""; - if (struct_exists(data, "stage")){ - stage_id = data.stage; - } - if (struct_exists(data, "members")){ - members = data.members; - } - static has_data = function(key){ - return struct_exists(data, key); - } - static description = function(){ - var _n = mission_name_key(p_id); - _n = _n == "" ? p_id : _n; - return _n; - } - static __popup_delete = function(){ - with(obj_popup){ - popup_default_close(); - } - __check_delete(); - } - - static find_func_ref = function(trigger_string){ - var _func_string = "__" + p_id + "_" + trigger_string; - return _func_string; - } - - static has_func = function(trigger_string){ - var _func_string = find_func_ref(trigger_string); - return struct_exists(self,_func_string); - } - static find_func = function(trigger_string){ - var _func_string = find_func_ref(trigger_string); - if (struct_exists(self,_func_string)){ - return self[$ _func_string] - } - return undefined; - } - static __handle_triggered_mission_func = function(func){ - if (!is_undefined(func)){ - __refresh_data(); - try { - func(); - } catch (_exception) { - delete_mission = true; - ERROR_HANDLER.handle_exception(_exception); - } - } - __check_delete(); - obj_controller.location_viewer.update_mission_log(); - } -} function location_out_of_player_control(unit_loc) { static _locs = [ diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index 93fed9e8ef..f7f36f29aa 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -72,27 +72,27 @@ function scr_mission_reward(mission, star, planet) { var tixt = $"The journey into the Mars Catacombs was a success. Your {techs_alive} remaining {obj_ini.player_role_data[eROLE.TECHMARINE].role}s were useful to the Mechanicus force and return with a bounty. They await retrieval at {star.name} {scr_roman(planet)}.\n"; tixt += $"\n{found_requisition} Requisition from salvage"; if (found_artifact > 0) { - tixt += $"\n{string_plural("Unidentified Artifacts", found_artifact)} recovered"; + tixt += $"\n{string_plural(}Unidentified Artifacts{, found_artifact)} recovered"; } if (found_stc > 0) { - tixt += $"\n{string_plural("STC Fragment", found_stc)} recovered"; + tixt += $"\n{string_plural(}STC Fragment{, found_stc)} recovered"; } if (_tech_point_gain) { - tixt += $"\n{string_plural("Tech Point", _tech_point_gain)} recovered"; + tixt += $"\n{string_plural(}Tech Point{, _tech_point_gain)} recovered"; } scr_popup("Mechanicus Mission Completed", tixt, "mechanicus", ""); tixt = "Mechanicus Mission Completed: {techs_alive}/{techs_alive+techs_lost} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s return with "; tixt += string(found_requisition) + " Requisition, "; if (found_artifact > 0) { - tixt += $"\n{found_artifact} : {string_plural("Unidentified Artifacts", found_artifact)} recovered"; + tixt += $"\n{found_artifact} : {string_plural(}Unidentified Artifacts{, found_artifact)} recovered"; } if (found_stc > 0) { - tixt += $"\n{found_stc} : {string_plural("STC Fragment", found_stc)} recovered"; + tixt += $"\n{found_stc} : {string_plural(}STC Fragment{, found_stc)} recovered"; } if (_tech_point_gain) { - tixt += $"\n{_tech_point_gain} {string_plural("Tech Point", _tech_point_gain)} gained"; + tixt += $"\n{_tech_point_gain} {string_plural(}Tech Point{, _tech_point_gain)} gained"; } scr_event_log("green", tixt); 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 b1b6acd3fc..a68297ff98 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -421,13 +421,13 @@ function player_retreat_from_fleet_combat(destination_star = noone) { var _total_remaining = _p_fleet.escort_number + _p_fleet.frigate_number + _p_fleet.capital_number; - var _text = $"Your fleet is given the command to fall back to {destination_star.name ?? "outer space"}. The vessels turn and prepare to enter the Warp, constantly under a hail of enemy fire."; + var _text = $"Your fleet is given the command to fall back to {destination_star.name ?? }outer space. The vessels turn and prepare to enter the Warp, constantly under a hail of enemy fire."; if (_total_lost > 0 && _total_remaining > 0) { _text += "\n\nSome of your ships remain behind to draw off the attack and give the rest of your fleet a chance to escape."; for (var t = 0; t < array_length(_tiers); t++) { var _casualties = _tiers[t].lost; if (_casualties > 0) { - _text += $" {_casualties} {string_plural(_tiers[t].label, _casualties)} {smart_verb("was", _casualties)} destroyed."; + _text += $" {_casualties} {string_plural(_tiers[t].label, _casualties)} {smart_verb(}was{, _casualties)} destroyed."; } } } else if (_total_lost == 0) { diff --git a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml index d8e345a204..f5109497f3 100644 --- a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml +++ b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml @@ -224,16 +224,16 @@ function move_enemy_blocks() { function block_composition_string() { var _composition_string = $"{unit_count}x Total; "; if (men > 0) { - _composition_string += $"{string_plural_count("Normal Unit", men)}; "; + _composition_string += $"{string_plural_count(}Normal Unit{, men)}; "; } if (medi > 0) { - _composition_string += $"{string_plural_count("Big Unit", medi)}; "; + _composition_string += $"{string_plural_count(}Big Unit{, medi)}; "; } if (dreads > 0) { - _composition_string += $"{string_plural_count("Walker", dreads)}; "; + _composition_string += $"{string_plural_count(}Walker{, dreads)}; "; } if (veh > 0) { - _composition_string += $"{string_plural_count("Vehicle", veh)}; "; + _composition_string += $"{string_plural_count(}Vehicle{, veh)}; "; } _composition_string += $"\n"; diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index 9912c509d2..00d8d44994 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -289,7 +289,7 @@ function draw_popup_equip(before_after_styling = true) { _descriptor = "Vehicles"; } if (company != -1) { - draw_text(_x1 + 286, _y1 + 32, $"{comp} {localize("Company")}, {unit_count} {localize(_descriptor)}"); + draw_text(_x1 + 286, _y1 + 32, $"{comp} {localize(}Company{)}, {unit_count} {localize(_descriptor)}"); } draw_set_halign(fa_left); diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index aa7cfcae0b..fb61fc0050 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -806,7 +806,7 @@ function SquadArrangementEditor(company) constructor { var _btn = new UnitButtonObject({ style: "pixel", label: _squad_data.type_data.display_data, - tooltip: $"add {_key} as a {require_filter ? "required" : "proportional"} squad", + tooltip: $"add {_key} as a {require_filter ? }required {: }proportional squad", set_width: true, x1: picker_x, y1: _py, diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index 274d047a55..d80f7a947f 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -465,7 +465,7 @@ function alter_unit_equipment(update_equipment, from_armoury = true, to_armoury break; } if (_outcome == "no_items") { - _missing_items += $"{_missing_items == "" ? "" : ","} {localize(_item)}"; + _missing_items += $"{_missing_items == } {? } {: }, {localize(_item)}"; _success = false; } } From 4150dd5e4ff747dc9415b265954f476fc22ca6c5 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 16:21:58 +0100 Subject: [PATCH 094/118] rename hint_inquisitor to radical_inquisitor and move to AiFleetProblem --- scripts/AiFleetProblem/AiFleetProblem.gml | 195 +++++++++++- scripts/FleetProblem/FleetProblem.gml | 6 +- .../PlayerFleetProblem/PlayerFleetProblem.gml | 35 +-- scripts/SystemProblem/SystemProblem.gml | 61 +++- .../scr_fleet_functions.gml | 3 + .../scr_inquisition_fleet_functions.gml | 40 --- .../scr_inquisition_mission.gml | 281 +----------------- 7 files changed, 261 insertions(+), 360 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 81725dc25a..bb3c51a525 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -37,8 +37,8 @@ other info /// @param {string} _name /// @param {Real} _timer /// @param {struct} _data -/// @param {Id.Instance.obj_p_fleet} _fleet -function FleetProblem(_name, _timer, _data, _fleet) : Problem(_name, _timer, _data) constructor{ +/// @param {Id.Instance.obj_en_fleet} _fleet +function AiFleetProblem(_name, _timer = -1, _data ={}, _fleet = noone) : FleetProblem(_name, _timer, _data, _fleet) constructor{ fleet = _fleet; per_turn_checks = true; @@ -97,6 +97,197 @@ static __deliver_hunt_trophy_mission_log_entry = function(){ }); return _mission_data; } + +static radical_inquisitor_init = function(){ + if (!instance_exists(obj_popup)){ + scr_popup("","","",""); + } + obj_popup.title = _"Inquisition Mission Accepted"; + obj_popup.text = $"{global.chapter_name} will intercept the radical Inquisitor {data.inquisitor_name} at {data.target_name}, expected within {timer} months."; +} + +static radical_inquisitor_on_arrival = function(){ + if (!orbiting.has_orbiting_player_fleet()) { + with (fleet){ + random_sector_exit_point(); + action_spd = 256; + action = ""; + set_fleet_movement(); + instance_destroy(); + } + alter_disposition(eFACTION.INQUISITION, -15); + scr_popup("Inquisitor Mission Failed", "The radical Inquisitor has departed from the planned intercept coordinates. They will now be nearly impossible to track- the mission is a failure.", "inquisition", ""); + scr_event_log("red", "Inquisition Mission Failed: The radical Inquisitor has departed from the planned intercept coordinates."); + delete_mission = true; + exit; + } + + action = ""; + var _gender = string_gender_third_person(data.inquisitor_gender); + + var _tixt = $"You have located the radical Inquisitor. As you prepare to destroy their ship, and complete the mission, you recieve a hail- it appears as though {_gender} wishes to speak."; + var _options = [ + { + str1: "Destroy their vessel", + choice_func: method(self, radical_inquisitor_destroy_inquisitor_ship), + }, + { + str1: "Hear them out", + choice_func: method(self, radical_inquisitor_hear_them_out), + }, + ]; + scr_popup("Inquisitor Located", _tixt, "inquisition", _radical_inquisitor); + exit; +} + +/// @self Asset.GMObject.obj_popup +static radical_inquisitor_destroy_inquisitor_ship function() { + LOGGER.debug("mission_hunt_inquisitor_destroy_inquisitor_ship"); + var _final_disp_mod = 0; + + if (obj_controller.demanding == 0) { + _final_disp_mod += 1; + } else if (obj_controller.demanding == 1) { + _final_disp_mod += choose(0, 0, 1); + } + + if ((obj_popup.title == "Artifact Offered") || (obj_popup.title == "Mercy Plea")) { + _final_disp_mod -= choose(0, 1); + } + + alter_disposition(eFACTION.INQUISITION, _final_disp_mod); + + obj_popup.title = "Inquisition Mission Completed"; + obj_popup.image = "exploding_ship"; + obj_popup.text = "The Inquisitor's ship begans to bank and turn, to flee, but is immediately fired upon by your fleet. The ship explodes, taking the Inquisitor with it. The mission has been accomplished."; + reset_popup_options(); + scr_event_log("", "Inquisition Mission Completed: The radical Inquisitor has been purged."); + delete_mission = true; + __check_delete(); + exit; +} + + +/// @self Asset.GMObject.obj_popup +static radical_inquisitor_hear_them_out = function() { + var _offer = choose(1, 1, 2, 2, 3); + + var _gender = data.inquisitor_gender; + var _gender_third = string_gender_third_person(_gender); + var gender_pronoun = string_gender_pronouns(_gender); + + if (_offer == 1) { + replace_options([ + { + str1: "Destroy their vessel", + choice_func: method(self, radical_inquisitor_destroy_inquisitor_ship), + }, + { + str1: "Take the artifact and then destroy them", + choice_func: method(self, radical_inquisitor_artifact_double_cross) + }, + { + str1: "Take the artifact and spare them", + choice_func: mission_hunt_inquisitor_take_artifact_bribe + } + ]); + obj_popup.title = "Artifact Offered"; + obj_popup.text = $"The Inquisitor claims that this is a massive misunderstanding, and {_gender_third} wishes to prove {gender_pronoun} innocence. If {global.chapter_name} allow their ship to leave {_gender_third} will give {global.chapter_name} an artifact."; + exit; + } else if (_offer == 2) { + replace_options( + [ + { + str1: "Destroy their vessel", + choice_func: mission_hunt_inquisitor_destroy_inquisitor_ship + }, + { + str1: "Search their ship", + //choice_func : instance_destroy, // TODO: Implement proper ship search logic + }, + { + str1: "Spare them", + choice_func: method(self, radical_inquisitor_show_mercy) + }, + ], + ); + title = "Mercy Plea"; + text = $"The Inquisitor claims that {_gender_third} has key knowledge that would grant the Imperium vital power over the forces of Chaos. If {global.chapter_name} allow {gender_pronoun} ship to leave the forces of Chaos within this sector will be weakened."; + exit; + } else if (_offer == 3) { + with (fleet) { + with (instance_nearest(fleet.x, fleet.y, obj_p_fleet)) { + scr_add_corruption(true, "1d3"); + } + instance_destroy(); + } + obj_popup.title = "Inquisition Mission Completed"; + obj_popup.image = "exploding_ship"; + obj_popup.text = $"{global.chapter_name} allow communications. As soon as the vox turns on {global.chapter_name} hear a sickly, hateful voice. They begin to speak of the inevitable death of your marines, the fall of all that is and ever shall be, and " + string(gender_pronoun) + " Lord of Decay. Their ship is fired upon and destroyed without hesitation."; + reset_popup_options(); + scr_event_log("", "Inquisition Mission Completed: The radical Inquisitor has been purged."); + } + delete_mission = true; + __check_delete(); +} + +static radical_inquisitor_show_mercy() { + with (fleet) { + random_sector_exit_point(); + trade_goods = "|DELETE|"; + action_spd = 256; + set_fleet_movement(false, 8); + } + + obj_popup.title = "Inquisition Mission Completed"; + obj_popup.text = $"{global.chapter_name} allow the Inquisitor to leave, trusting in their words. If they truly do have key information it is a risk {global.chapter_name} are willing to take. What's the worst that could happen?"; + obj_popup.image = "artifact_recovered"; + reset_popup_options(); + scr_event_log("", "Inquisition Mission Completed?: The radical Inquisitor has been allowed to flee in order to weaken the forces of Chaos, as they promised."); + add_event({e_id: "inquisitor_spared", duration: irandom_range(6, 18) + 1, variation: 2}); + delete_mission = true; + __check_delete(); +} + +static radical_inquisitor_artifact_double_cross function() { + with (fleet) { + instance_destroy(); + } + var last_artifact = scr_add_artifact("random", "", 4); + + reset_popup_options(); + + obj_popup.title = "Inquisition Mission Completed"; + obj_popup.text = "Your ship sends over a boarding party, who retrieve the offered artifact- "; + obj_popup.text += $" some form of {fetch_artifact(last_artifact).get_type_name()}. Once it is safely stowed away your ship is then ordered to fire. The Inquisitor's own seems to hesitate an instant before banking away, but is quickly destroyed."; + obj_popup.image = "exploding_ship"; + scr_event_log("", "Artifact recovered from radical Inquisitor."); + scr_event_log("", "Inquisition Mission Completed: The radical Inquisitor has been purged."); + delete_mission = true; + __check_delete(); +} + +/// @self Asset.GMObject.obj_popup +function radical_inquisitor_take_artifact_bribe() { + with (fleet) { + random_sector_exit_point(); + trade_goods = "|DELETE|"; + action_spd = 256; + set_fleet_movement(false); + } + var last_artifact = scr_add_artifact("random", "", 4); + + reset_popup_options(); + + obj_popup.title = "Inquisition Mission Completed"; + obj_popup.text = "Your ship sends over a boarding party, who retrieve the offered artifact- "; + obj_popup.text += $" some form of {fetch_artifact(last_artifact).get_type_name()}. As promised {global.chapter_name} allow the Inquisitor to leave, hoping for the best. What's the worst that could happen?"; + obj_popup.image = "artifact_recovered"; + scr_event_log("", "Artifact Recovered from radical Inquisitor."); + scr_event_log("", "Inquisition Mission Completed: The radical Inquisitor has been purged."); + add_event({e_id: "inquisitor_spared", duration: irandom_range(6, 18) + 1, variation: 1}); +} + } diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index fe4858352f..69c42681c4 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -38,7 +38,7 @@ other info /// @param {Real} _timer /// @param {struct} _data /// @param {Id.Instance.obj_p_fleet} | {Id.Instance.obj_en_fleet} _fleet -function FleetProblem(_name, _timer, _data, _fleet) : Problem(_name, _timer, _data) constructor{ +function FleetProblem(_name, _timer = -1, _data ={}, _fleet = noone) : Problem(_name, _timer, _data) constructor{ fleet = _fleet; static __refresh_data = function(){ @@ -98,8 +98,8 @@ static basic_turn_end = function(){ } /// @param {Id.Instance.obj_star} star -static on_arrival = function(star){ - __trigger_with_event("on_arrival", {star}); +static on_arrival = function(){ + __trigger_with_event("on_arrival"); } /// @param {Id.Instance.obj_p_fleet} new_fleet diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index 8180dd3e64..aed60e9fe6 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -38,7 +38,7 @@ other info /// @param {Real} _timer /// @param {struct} _data /// @param {Id.Instance.obj_p_fleet} _fleet -function PlayerFleetProblem(_name, _timer, _data, _fleet) : FleetProblem(_name, _timer, _data) constructor{ +function PlayerFleetProblem(_name, _timer = -1, _data ={}, _fleet = noone) : FleetProblem(_name, _timer, _data, _fleet) constructor{ fleet = _fleet; per_turn_checks = true; @@ -316,39 +316,6 @@ static __great_crusade_results = function(){ delete_mission = true; fleet.action = ""; } - -static __deliver_hunt_trophy_mission_log_entry = function(){ - var _mission = localize("Deliver Trophy Guard"); - var _sys = fleets_next_location(); - var _mission_data = { - mission: self, - system: _sys.name, - system_id: _sys.id, - target: self, - important_person: _event.data.trophy_owner, - person_name: _event.data.delivering_marine, - planet: 0, - start_system: _event.data.system, - time: timer, - }; - - _mission_data.click_left = method(_mission_data, function() { - set_map_pan_to_loc(system_id); - }); - - _mission_data.hover = method(_mission_data, function() { - tooltip_draw(localize("You are to have {0} deliver trophy hunted on {1} to the {1} regiments\n\nLeft click to see target fleet intercept system right click to view the trophy bearing marine {0}", [person_name, start_system])); - }); - - _mission_data.click_right = method(_mission_data, function() { - var _unit = fetch_unit_uid(important_person); - if (is_struct(_unit)) { - var _unit_l = [_unit]; - group_selection(_unit_l); - } - }); - return _mission_data; -} } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 4ca6db18e9..f8a1c15e54 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -2,7 +2,7 @@ /// @param {Asset.GMObject.obj_star} _system /// @param {struct} _data /// @param {Real} _timer -function SystemProblem(_name, _system, _data = {}, _timer = -1) : Problem(_name, _timer, _data) constructor{ +function SystemProblem(_name, _system = noone, _data = {}, _timer = -1) : Problem(_name, _timer, _data) constructor{ system = _system; //base only assigns members when data.members exists; default it here without clobbering that @@ -122,4 +122,63 @@ static __great_crusade_resolve = function() { delete_mission = true; } +static hunt_inquisitor_init = function(){ + LOGGER.info("RE: Inquisitor Hunt"); + + + if (system == noone) { + var _stars = scr_get_stars(); + + if (array_length(_stars) == 0) { + delete_mission = true; + exit; + LOGGER.error("RE: Inquisitor Hunt,couldn't find a _star"); + exit; + } + + system = array_random_element(_stars); + } + + var _gender = set_gender(); + var _name = global.name_generator.GenerateFromSet($"imperial_{string_gender()}"); + + var _eta = scr_mission_eta(system.x, system.y, 1); + _eta = max(_eta, 8); + timer = _eta + var _text = $"The Inquisition is trusting you with a special mission. A radical inquisitor named {_name} will be visiting the {_star.name} system in {_eta} month's time. They are highly suspect of heresy, and as such, are to be put down. Can your chapter handle this mission?"; + if (obj_controller.demanding) { + _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {_star.name}, expected within {_eta} months. They are to be silenced and removed."; + } + + data.inquisitor_name: _name, + data.inquisitor_gender: _gender, + var _pop_data = { + mission: self, + options: __inquisition_mission_options(), + }; + + scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); +} + +static hunt_inquisitor_accept = function(){ + + scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {pop_data.mission_data.inquisitor_name} enroute to {_mission_star.name} must be removed. Estimated arrival in {pop_data.estimate} months.", _mission_star.name); + + var _radical_inquisitor_fleet = create_enemy_fleet(system.x - irandom_range(-400, 400), system.y - irandom_range(-400, 400), eFACTION.INQUISITION); + with (_radical_inquisitor_fleet) { + base_inquis_fleet(); + } + _radical_inquisitor_fleet.action_x = system.x; + _radical_inquisitor_fleet.action_y = system.y; + with (_radical_inquisitor_fleet) { + set_fleet_movement(false, "move", timer, timer); + } + data.target_name = system.name; + _radical_inquisitor_fleet.add_problem("radical_inquisitor", timer, data); + + delete_mission = true; + reset_popup_options(); + exit; +} + } \ 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 9cffb8004f..045dc58172 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -667,6 +667,9 @@ function fleet_arrival_logic() { action = ""; fleet_register_at_star(id, _dest_star); + for (var i=0; i Date: Thu, 1 Oct 2026 16:33:56 +0100 Subject: [PATCH 095/118] various cleaups --- scripts/AiFleetProblem/AiFleetProblem.gml | 47 ++++++++++++++++------- scripts/Problem/Problem.gml | 8 ++++ scripts/SystemProblem/SystemProblem.gml | 4 +- scripts/scr_cheatcode/scr_cheatcode.gml | 1 + 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index bb3c51a525..135a7e0c32 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -98,15 +98,34 @@ static __deliver_hunt_trophy_mission_log_entry = function(){ return _mission_data; } -static radical_inquisitor_init = function(){ +static __radical_inquisitor_init = function(){ if (!instance_exists(obj_popup)){ scr_popup("","","",""); } - obj_popup.title = _"Inquisition Mission Accepted"; + obj_popup.title = "Inquisition Mission Accepted"; obj_popup.text = $"{global.chapter_name} will intercept the radical Inquisitor {data.inquisitor_name} at {data.target_name}, expected within {timer} months."; } -static radical_inquisitor_on_arrival = function(){ +static __radical_inquisitor_mission_log_entry = function(){ + var _mission = "Intercept Radical Inquisitor"; + var _sys = fleets_next_location(); + var _mission_data = { + mission: self, + system: data.target_name, + system_id: find_star_by_name(data.target_name), + time: timer, + }; + + _mission_data.click_left = method(_mission_data, function() { + set_map_pan_to_loc(mission.fleet); + }); + + _mission_data.hover = method(_mission_data, function() { + tooltip_draw($"intercept the radical Inquisitor {mission.data.inquisitor_name} at {mission.data.target_name}, expected within {mission.timer} months."); + }); +} + +static __radical_inquisitor_on_arrival = function(){ if (!orbiting.has_orbiting_player_fleet()) { with (fleet){ random_sector_exit_point(); @@ -114,7 +133,7 @@ static radical_inquisitor_on_arrival = function(){ action = ""; set_fleet_movement(); instance_destroy(); - } + }å alter_disposition(eFACTION.INQUISITION, -15); scr_popup("Inquisitor Mission Failed", "The radical Inquisitor has departed from the planned intercept coordinates. They will now be nearly impossible to track- the mission is a failure.", "inquisition", ""); scr_event_log("red", "Inquisition Mission Failed: The radical Inquisitor has departed from the planned intercept coordinates."); @@ -136,12 +155,12 @@ static radical_inquisitor_on_arrival = function(){ choice_func: method(self, radical_inquisitor_hear_them_out), }, ]; - scr_popup("Inquisitor Located", _tixt, "inquisition", _radical_inquisitor); + scr_popup("Inquisitor Located", _tixt, "inquisition", {mission:self, options : _options}); exit; } /// @self Asset.GMObject.obj_popup -static radical_inquisitor_destroy_inquisitor_ship function() { +static __radical_inquisitor_destroy_inquisitor_ship function() { LOGGER.debug("mission_hunt_inquisitor_destroy_inquisitor_ship"); var _final_disp_mod = 0; @@ -169,7 +188,7 @@ static radical_inquisitor_destroy_inquisitor_ship function() { /// @self Asset.GMObject.obj_popup -static radical_inquisitor_hear_them_out = function() { +static __radical_inquisitor_hear_them_out = function() { var _offer = choose(1, 1, 2, 2, 3); var _gender = data.inquisitor_gender; @@ -180,15 +199,15 @@ static radical_inquisitor_hear_them_out = function() { replace_options([ { str1: "Destroy their vessel", - choice_func: method(self, radical_inquisitor_destroy_inquisitor_ship), + choice_func: method(self, __popup_choice("inquisitor_ship")), }, { str1: "Take the artifact and then destroy them", - choice_func: method(self, radical_inquisitor_artifact_double_cross) + choice_func: method(self, __popup_choice("artifact_double_cross")) }, { str1: "Take the artifact and spare them", - choice_func: mission_hunt_inquisitor_take_artifact_bribe + choice_func: __popup_choice("take_artifact_bribe"); } ]); obj_popup.title = "Artifact Offered"; @@ -199,7 +218,7 @@ static radical_inquisitor_hear_them_out = function() { [ { str1: "Destroy their vessel", - choice_func: mission_hunt_inquisitor_destroy_inquisitor_ship + choice_func: __popup_choice("destroy_inquisitor_ship"); }, { str1: "Search their ship", @@ -207,7 +226,7 @@ static radical_inquisitor_hear_them_out = function() { }, { str1: "Spare them", - choice_func: method(self, radical_inquisitor_show_mercy) + choice_func: __popup_choice("show_mercy"); }, ], ); @@ -231,7 +250,7 @@ static radical_inquisitor_hear_them_out = function() { __check_delete(); } -static radical_inquisitor_show_mercy() { +static __radical_inquisitor_show_mercy() { with (fleet) { random_sector_exit_point(); trade_goods = "|DELETE|"; @@ -249,7 +268,7 @@ static radical_inquisitor_show_mercy() { __check_delete(); } -static radical_inquisitor_artifact_double_cross function() { +static __radical_inquisitor_artifact_double_cross function() { with (fleet) { instance_destroy(); } diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml index b45c3bb732..1453e4f5b0 100644 --- a/scripts/Problem/Problem.gml +++ b/scripts/Problem/Problem.gml @@ -46,6 +46,14 @@ function Problem(_name, _timer, _data) constructor { } return undefined; } + + static __popup_choice(trigger_string){ + var _func = find_func(trigger_string); + if (!is_undefined(_func)){ + return method(self, _func); + } + return undefined; + } static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ __refresh_data(); diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index f8a1c15e54..26f471ae13 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -122,7 +122,7 @@ static __great_crusade_resolve = function() { delete_mission = true; } -static hunt_inquisitor_init = function(){ +static __hunt_inquisitor_init = function(){ LOGGER.info("RE: Inquisitor Hunt"); @@ -160,7 +160,7 @@ static hunt_inquisitor_init = function(){ scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } -static hunt_inquisitor_accept = function(){ +static __hunt_inquisitor_accept = function(){ scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {pop_data.mission_data.inquisitor_name} enroute to {_mission_star.name} must be removed. Estimated arrival in {pop_data.estimate} months.", _mission_star.name); diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 346aab77e5..6b2f82f18b 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -390,6 +390,7 @@ function draw_system_debug(){ var _keys = global.planet_problem_keys; var _star_missions = [ "great_crusade", + "radical_inquisitor" ] _base_y += 2; draw_set_font(fnt_40k_12); From cff8a1904e4e7e80498f09ace1472b5b04f63ef7 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 16:36:16 +0100 Subject: [PATCH 096/118] delete cheats that the debug sweet has replaced --- scripts/scr_cheatcode/scr_cheatcode.gml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 6b2f82f18b..79ce2a3286 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -162,9 +162,6 @@ function scr_cheatcode(argument0) { case "artifact": scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.ARTIFACT); break; - case "inquisitor": - scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.INQUISITOR); - break; case "demon": scr_inquisition_mission(eEVENT.INQUISITION_MISSION, eINQUISITION_MISSION.DEMON_WORLD); break; @@ -175,27 +172,6 @@ function scr_cheatcode(argument0) { LOGGER.debug("inquisitor mission initiated"); obj_controller.location_viewer.update_mission_log(); break; - case "artifactpopulate": - with (obj_star) { - for (var i = 1; i <= planets; i++) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.ARTIFACT)); - } - } - break; - case "ruinspopulate": - with (obj_star) { - for (var i = 1; i <= planets; i++) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.ANCIENT_RUINS)); - } - } - break; - case "stcpopulate": - with (obj_star) { - for (var i = 1; i <= planets; i++) { - array_push(p_feature[i], new NewPlanetFeature(eP_FEATURES.STC_FRAGMENT)); - } - } - break; case "event": if (cheat_arguments[0] == "tomb") { LOGGER.debug("necron_tomb_awaken"); From a7899b2fef1fe20b8a001aaf05c7910e93a3e11a Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 16:43:22 +0100 Subject: [PATCH 097/118] fuck ups --- scripts/AiFleetProblem/AiFleetProblem.gml | 4 +- scripts/Armamentarium/Armamentarium.gml | 46 +++++++++++------------ scripts/FleetProblem/FleetProblem.gml | 2 +- scripts/Problem/Problem.gml | 4 +- scripts/SystemProblem/SystemProblem.gml | 4 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 135a7e0c32..261ea79cfb 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -133,7 +133,7 @@ static __radical_inquisitor_on_arrival = function(){ action = ""; set_fleet_movement(); instance_destroy(); - }å + } alter_disposition(eFACTION.INQUISITION, -15); scr_popup("Inquisitor Mission Failed", "The radical Inquisitor has departed from the planned intercept coordinates. They will now be nearly impossible to track- the mission is a failure.", "inquisition", ""); scr_event_log("red", "Inquisition Mission Failed: The radical Inquisitor has departed from the planned intercept coordinates."); @@ -160,7 +160,7 @@ static __radical_inquisitor_on_arrival = function(){ } /// @self Asset.GMObject.obj_popup -static __radical_inquisitor_destroy_inquisitor_ship function() { +static __radical_inquisitor_destroy_inquisitor_ship = function() { LOGGER.debug("mission_hunt_inquisitor_destroy_inquisitor_ship"); var _final_disp_mod = 0; diff --git a/scripts/Armamentarium/Armamentarium.gml b/scripts/Armamentarium/Armamentarium.gml index 24dfff19ba..382b982b50 100644 --- a/scripts/Armamentarium/Armamentarium.gml +++ b/scripts/Armamentarium/Armamentarium.gml @@ -112,15 +112,15 @@ function ShopItem(_name) constructor { return ""; } - return $"{localize(}Missing Requirements:\n{0}{, [string_join_ext(}\n{, missing_technologies)])}"; + return localize("Missing Requirements:\n{0}", [string_join_ext("\n", missing_technologies)]); }; static get_buy_cost_tooltip = function() { - var _text = $"{localize(}Base Value: {0}\n\n{, [value])}"; + var _text = localize("Base Value: {0}\n\n", [value]); var _seller = (best_seller == "rogue_trader") ? localize("Rogue Trader") : string_upper_first(best_seller); - _text += $"{localize(}Best Seller: {0}\n{, [_seller])}"; - _text += $"{localize(}Disposition Modifier: x{0}{, [buy_cost_mod])}"; + _text += localize("Best Seller: {0}\n", [_seller]); + _text += localize("Disposition Modifier: x{0}", [buy_cost_mod]); return _text; }; @@ -130,11 +130,11 @@ function ShopItem(_name) constructor { /// @returns {string} static get_forge_cost_tooltip = function(_stc_details = "") { var _base_forge = value * SHOP_FORGE_MOD; - var _text = $"{localize(}Base Forging Cost: {0}\n{, [_base_forge])}"; + var _text = $"{localize("Base Forging Cost: {0}\n", [_base_forge])}"; if (_stc_details != "") { _text += $"\n{_stc_details}"; - _text += $"\n{localize(}Total Modifier: x{0}{, [string_format(forge_cost_mod, 1, 2)])}"; + _text += $"\n{localize("Total Modifier: x{0}", [string_format(forge_cost_mod, 1, 2)])}"; } return _text; @@ -362,7 +362,7 @@ function STCResearchPanel(_controller_ref, _on_change_callback) constructor { draw_set_font(cjk_font(fnt_aldrich_12)); draw_set_color(c_gray); - draw_text(_x + 34, _y, $"{localize(}{0} Unidentified Fragments{, [_total_un])}"); + draw_text(_x + 34, _y, $"{localize("{0} Unidentified Fragments", [_total_un])}"); var _has_fragments = _total_un > 0; draw_set_alpha(_has_fragments ? 1 : 0.25); @@ -811,7 +811,7 @@ function Armamentarium(_controller) constructor { case "mobility": discount_stc = controller.stc_wargear * 5; if (discount_stc > 0) { - global_cost_tooltip += $"{localize(}Wargear STC: -{0}%\n{, [discount_stc])}"; + global_cost_tooltip += $"{localize("Wargear STC: -{0}%\n", [discount_stc])}"; } break; case "vehicles": @@ -819,13 +819,13 @@ function Armamentarium(_controller) constructor { var _hanger_bonus = max(array_length(controller.player_forge_data.vehicle_hanger) - 1, 0); discount_stc = (controller.stc_vehicles + _hanger_bonus) * 3; if (discount_stc > 0) { - global_cost_tooltip += $"{localize(}Vehicle STC & Hangars: -{0}%\n{, [discount_stc])}"; + global_cost_tooltip += $"{localize("Vehicle STC & Hangars: -{0}%\n", [discount_stc])}"; } break; case "ships": discount_stc = controller.stc_ships * 5; if (discount_stc > 0) { - global_cost_tooltip += $"{localize(}Ship STC: -{0}%\n{, [discount_stc])}"; + global_cost_tooltip += $"{localize("Ship STC: -{0}%\n", [discount_stc])}"; } break; } @@ -839,22 +839,22 @@ function Armamentarium(_controller) constructor { var _diff = _max_techs - count_total; var _req_dispo = (abs(_diff) * 2) + ((_dispo_mech % 2 == 0) ? 2 : 1); - var _text = $"{localize(}Subject ID confirmed. Rank Identified. Salutations Chapter Master. The status report is ready.{)}"; - _text += $"\n\n{localize(}Personnel: {0}s: {1}, Aspirants: {2}.{, [_role_tech, count_techmarines, count_aspirants])}"; - _text += $"\n\n{localize(}Training: {)}"; + var _text = $"{localize("Subject ID confirmed. Rank Identified. Salutations Chapter Master. The status report is ready.")}"; + _text += $"\n\n{localize("Personnel: {0}s: {1}, Aspirants: {2}.", [_role_tech, count_techmarines, count_aspirants])}"; + _text += $"\n\n{localize("Training: ")}"; if (controller.faction_status[eFACTION.MECHANICUS] != "War") { - _text += (_diff > 0) ? $"{localize(}We can train {0} more {1}(s).{, [_diff, _role_tech])}" : $"{localize(}To train more, we need {0} more Mechanicus Disposition.{, [_req_dispo])}"; + _text += (_diff > 0) ? $"{localize("We can train {0} more {1}(s).", [_diff, _role_tech])}" : $"{localize("To train more, we need {0} more Mechanicus Disposition.", [_req_dispo])}"; } else { - _text += $"{localize(}Training handled internally due to Mechanicus hostilities.{)}"; + _text += $"{localize("Training handled internally due to Mechanicus hostilities.")}"; } var _pace = controller.training_techmarine; - _text += $"{localize(} The training pace is {0}.{, [global.recruitment_pace_descriptions[_pace] ?? localize(}unknown{)])}"; + _text += $"{localize(" The training pace is {0}.", [global.recruitment_pace_descriptions[_pace] ?? localize("unknown")])}"; if (controller.tech_aspirant > 0 && _pace > 0) { var _eta_val = floor((359 - controller.tech_points) / global.techmarine_training_tiers[_pace]) + 1; - _text += $"{localize(} An Aspirant will finish training in {0} month(s).{, [_eta_val])}"; + _text += $"{localize(" An Aspirant will finish training in {0} month(s).", [_eta_val])}"; } advisor_report_text = _text; }; @@ -1167,12 +1167,12 @@ function Armamentarium(_controller) constructor { var _master_craft = controller.master_craft_chance; var _forge_count = controller.player_forge_data.player_forges; - var _text = $"{localize(}Status Report:\n\n{)}"; - _text += $"{localize(}Forge Point production per turn: {0}\n{, [controller.forge_points])}"; - _text += $"{localize(}Chapter Total {0}s: {1}\n\n{, [_role_name, count_total])}"; - _text += $"{localize(}Planetary Forges in operation: {0}\n\n{, [_forge_count])}"; - _text += $"{localize(}Master Craft Forge Chance: {0}%\n{, [_master_craft])}"; - _text += $"{localize(}Assign techmarines to forges to increase Master Craft Chance{)}"; + var _text = $"{localize("Status Report:\n\n")}"; + _text += $"{localize("Forge Point production per turn: {0}\n", [controller.forge_points])}"; + _text += $"{localize("Chapter Total {0}s: {1}\n\n", [_role_name, count_total])}"; + _text += $"{localize("Planetary Forges in operation: {0}\n\n", [_forge_count])}"; + _text += $"{localize("Master Craft Forge Chance: {0}%\n", [_master_craft])}"; + _text += $"{localize("Assign techmarines to forges to increase Master Craft Chance")}"; draw_set_color(c_gray); draw_set_font(cjk_font(fnt_aldrich_12)); diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 69c42681c4..b065763633 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -38,7 +38,7 @@ other info /// @param {Real} _timer /// @param {struct} _data /// @param {Id.Instance.obj_p_fleet} | {Id.Instance.obj_en_fleet} _fleet -function FleetProblem(_name, _timer = -1, _data ={}, _fleet = noone) : Problem(_name, _timer, _data) constructor{ +function FleetProblem(_name, _timer = -1, _data = {}, _fleet = noone) : Problem(_name, _timer, _data) constructor{ fleet = _fleet; static __refresh_data = function(){ diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml index 1453e4f5b0..e5dfde5661 100644 --- a/scripts/Problem/Problem.gml +++ b/scripts/Problem/Problem.gml @@ -47,7 +47,7 @@ function Problem(_name, _timer, _data) constructor { return undefined; } - static __popup_choice(trigger_string){ + static __popup_choice = function(trigger_string){ var _func = find_func(trigger_string); if (!is_undefined(_func)){ return method(self, _func); @@ -69,7 +69,7 @@ function Problem(_name, _timer, _data) constructor { } //requires the completion and required_months flag to be in the data struct - static __increment_mission_completion = function() { + static __increment_mission_completion = function() { if (!struct_exists(data, "completion")) { data.completion = 0; } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 26f471ae13..66927b3779 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -150,8 +150,8 @@ static __hunt_inquisitor_init = function(){ _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {_star.name}, expected within {_eta} months. They are to be silenced and removed."; } - data.inquisitor_name: _name, - data.inquisitor_gender: _gender, + data.inquisitor_name = _name, + data.inquisitor_gender = _gender, var _pop_data = { mission: self, options: __inquisition_mission_options(), From 359e91ab670c6d5033f80c8fb48c4b053b4fd4ca Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 16:47:40 +0100 Subject: [PATCH 098/118] fuck ups 2 --- scripts/GitHub/GitHub.gml | 8 ++++---- scripts/LocalizationManager/LocalizationManager.gml | 2 +- scripts/scr_bomb_world/scr_bomb_world.gml | 2 +- .../scr_draw_management_unit.gml | 2 +- scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml | 4 ++-- .../scr_equipment_struct/scr_equipment_struct.gml | 2 +- scripts/scr_flavor/scr_flavor.gml | 2 +- scripts/scr_librarium/scr_librarium.gml | 2 +- scripts/scr_livery_setup/scr_livery_setup.gml | 2 +- scripts/scr_mission_reward/scr_mission_reward.gml | 12 ++++++------ .../scr_player_fleet_functions.gml | 4 ++-- .../scr_punit_combat_heplers.gml | 8 ++++---- scripts/scr_reequip_units/scr_reequip_units.gml | 2 +- scripts/scr_squads/scr_squads.gml | 2 +- .../scr_unit_equip_functions.gml | 2 +- 15 files changed, 28 insertions(+), 28 deletions(-) diff --git a/scripts/GitHub/GitHub.gml b/scripts/GitHub/GitHub.gml index 82b75d32c7..b5a08edb8d 100644 --- a/scripts/GitHub/GitHub.gml +++ b/scripts/GitHub/GitHub.gml @@ -626,16 +626,16 @@ function GitHub(_authToken = undefined) constructor { _queryParams += $"since={_since}&"; } if (_collab != undefined) { - _queryParams += $"collab={_collab ? }true {: }false&"; + _queryParams += $"collab={_collab ? "true" : "false"}&"; } if (_orgs != undefined) { - _queryParams += $"orgs={_orgs ? }true {: }false&"; + _queryParams += $"orgs={_orgs ? "true" : "false"}&"; } if (_owned != undefined) { - _queryParams += $"owned={_owned ? }true {: }false&"; + _queryParams += $"owned={_owned ? "true" : "false"}&"; } if (_pulls != undefined) { - _queryParams += $"pulls={_pulls ? }true {: }false&"; + _queryParams += $"pulls={_pulls ? "true" : "false"}&"; } if (_perPage != undefined || _page != undefined) { _queryParams += __buildPaginationQueryParams(_perPage, _page); diff --git a/scripts/LocalizationManager/LocalizationManager.gml b/scripts/LocalizationManager/LocalizationManager.gml index 1099e2a430..a91b567168 100644 --- a/scripts/LocalizationManager/LocalizationManager.gml +++ b/scripts/LocalizationManager/LocalizationManager.gml @@ -73,7 +73,7 @@ function LocalizationManager() constructor { } if (array_length(_missing_keys) > 0) { - LOGGER.warning($"Language '{self.language}' is missing {array_length(_missing_keys)} translations from '{LANG_EN}': {string_join_ext(}, {, _missing_keys)}"); + LOGGER.warning($"Language '{self.language}' is missing {array_length(_missing_keys)} translations from '{LANG_EN}': {string_join_ext(", ", _missing_keys)}"); } }; diff --git a/scripts/scr_bomb_world/scr_bomb_world.gml b/scripts/scr_bomb_world/scr_bomb_world.gml index 333aab42cf..e6d00bc1de 100644 --- a/scripts/scr_bomb_world/scr_bomb_world.gml +++ b/scripts/scr_bomb_world/scr_bomb_world.gml @@ -13,7 +13,7 @@ function scr_bomb_world(bombard_target_faction, bombard_ment_power, target_stren if (obj_bomb_select.ships_selected == 1) { txt1 += "s"; } - txt1 += $" annihilation upon {name()}. Even from space the explosions can be seen, {choose(}tearing ground{, }hammering{, }battering{, }thundering{)} across the planet's surface."; + txt1 += $" annihilation upon {name()}. Even from space the explosions can be seen, {choose("tearing ground", "hammering", "battering", "thundering")} across the planet's surface."; kill = population_small_conversion(0.15); diff --git a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml index 3881721542..5a4191503b 100644 --- a/scripts/scr_draw_management_unit/scr_draw_management_unit.gml +++ b/scripts/scr_draw_management_unit/scr_draw_management_unit.gml @@ -304,7 +304,7 @@ function scr_draw_management_unit(selected, yy = 0, xx = 0, draw = true, click_l } } - var exp_string = $"{localize(}{0} EXP{, [round(ma_exp[selected])])}"; + var exp_string = $"{localize("{0} EXP", [round(ma_exp[selected])])}"; var hpText = [ xx + 240 + 8, yy + 66, 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 4666a26930..f90af67641 100644 --- a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml +++ b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml @@ -741,7 +741,7 @@ function scr_enemy_ai_a() { 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"; + tixt += $". {_garrison.garrison_sustain_damages("loose")} Marines Lost"; } scr_alert("red", "owner", tixt, x, y); } @@ -749,7 +749,7 @@ function scr_enemy_ai_a() { 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"; + tixt += $". {_garrison.garrison_sustain_damages("win")} Marines Lost"; } scr_alert("green", "owner", tixt, x, y); } diff --git a/scripts/scr_equipment_struct/scr_equipment_struct.gml b/scripts/scr_equipment_struct/scr_equipment_struct.gml index 1c1433b78c..4cf64f4647 100644 --- a/scripts/scr_equipment_struct/scr_equipment_struct.gml +++ b/scripts/scr_equipment_struct/scr_equipment_struct.gml @@ -376,7 +376,7 @@ function EquipmentStruct(item_data = undefined, core_type = "", quality_request break; case "req_exp": if (req_exp > 0) { - item_desc_tooltip += $"{localize(}#Requires {0} EXP#{, [req_exp])}"; + item_desc_tooltip += $"{localize("#Requires {0} EXP#", [req_exp])}"; } break; case "tags": diff --git a/scripts/scr_flavor/scr_flavor.gml b/scripts/scr_flavor/scr_flavor.gml index 6f058dcd13..04b851e343 100644 --- a/scripts/scr_flavor/scr_flavor.gml +++ b/scripts/scr_flavor/scr_flavor.gml @@ -329,7 +329,7 @@ function scr_flavor(id_of_attacking_weapons, target, target_type, number_of_shot flavoured = true; if (!character_shot) { if (number_of_shots < 10) { - attack_message += $"{number_of_shots} vehicle{((number_of_shots > 1) ? }s {: }{)} thunder forward, armoured hulls crashing into the enemy lines- "; + attack_message += $"{number_of_shots} vehicle{((number_of_shots > 1) ? "s" : "")} thunder forward, armoured hulls crashing into the enemy lines- "; } else { attack_message += $"An armoured column of {number_of_shots} vehicles smashes into the enemy, grinding everything in its path- "; } diff --git a/scripts/scr_librarium/scr_librarium.gml b/scripts/scr_librarium/scr_librarium.gml index 6583eea55a..f1a64ce6c4 100644 --- a/scripts/scr_librarium/scr_librarium.gml +++ b/scripts/scr_librarium/scr_librarium.gml @@ -27,7 +27,7 @@ function scr_librarium_gui() { } /// @type {Struct.ArtifactStruct} var cur_arti = fetch_artifact(menu_artifact); - var artif_descr = $"This artifact is an unidentified {cur_arti.get_type_name()}.##It is stored on {cur_arti.get_ship_id() > -1 ? }the ship {: } '{cur_arti.get_location_string()}'."; + var artif_descr = $"This artifact is an unidentified {cur_arti.get_type_name()}.##It is stored on {cur_arti.get_ship_id() > -1 ? "the ship" : ""} '{cur_arti.get_location_string()}'."; var artif_timer = cur_arti.get_identification_timer(); draw_set_color(#5F730D); diff --git a/scripts/scr_livery_setup/scr_livery_setup.gml b/scripts/scr_livery_setup/scr_livery_setup.gml index d8bc7a8713..a66eb15dc9 100644 --- a/scripts/scr_livery_setup/scr_livery_setup.gml +++ b/scripts/scr_livery_setup/scr_livery_setup.gml @@ -144,7 +144,7 @@ function scr_livery_setup() { draw_set_font(cjk_font(fnt_40k_30b)); draw_set_halign(fa_center); if (_livery_type != 2) { - var liv_string = $"Full Livery \n{livery_picker.role_set == 0 ? }default {: player_role_data[livery_picker.role_set].role}"; + var liv_string = $"Full Livery \n{livery_picker.role_set == 0 ? "default" : player_role_data[livery_picker.role_set].role}"; draw_text(160, 100, liv_string); } else { draw_text(160, 100, "Company Livery"); diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index f7f36f29aa..93fed9e8ef 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -72,27 +72,27 @@ function scr_mission_reward(mission, star, planet) { var tixt = $"The journey into the Mars Catacombs was a success. Your {techs_alive} remaining {obj_ini.player_role_data[eROLE.TECHMARINE].role}s were useful to the Mechanicus force and return with a bounty. They await retrieval at {star.name} {scr_roman(planet)}.\n"; tixt += $"\n{found_requisition} Requisition from salvage"; if (found_artifact > 0) { - tixt += $"\n{string_plural(}Unidentified Artifacts{, found_artifact)} recovered"; + tixt += $"\n{string_plural("Unidentified Artifacts", found_artifact)} recovered"; } if (found_stc > 0) { - tixt += $"\n{string_plural(}STC Fragment{, found_stc)} recovered"; + tixt += $"\n{string_plural("STC Fragment", found_stc)} recovered"; } if (_tech_point_gain) { - tixt += $"\n{string_plural(}Tech Point{, _tech_point_gain)} recovered"; + tixt += $"\n{string_plural("Tech Point", _tech_point_gain)} recovered"; } scr_popup("Mechanicus Mission Completed", tixt, "mechanicus", ""); tixt = "Mechanicus Mission Completed: {techs_alive}/{techs_alive+techs_lost} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s return with "; tixt += string(found_requisition) + " Requisition, "; if (found_artifact > 0) { - tixt += $"\n{found_artifact} : {string_plural(}Unidentified Artifacts{, found_artifact)} recovered"; + tixt += $"\n{found_artifact} : {string_plural("Unidentified Artifacts", found_artifact)} recovered"; } if (found_stc > 0) { - tixt += $"\n{found_stc} : {string_plural(}STC Fragment{, found_stc)} recovered"; + tixt += $"\n{found_stc} : {string_plural("STC Fragment", found_stc)} recovered"; } if (_tech_point_gain) { - tixt += $"\n{_tech_point_gain} {string_plural(}Tech Point{, _tech_point_gain)} gained"; + tixt += $"\n{_tech_point_gain} {string_plural("Tech Point", _tech_point_gain)} gained"; } scr_event_log("green", tixt); 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 a68297ff98..b1b6acd3fc 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -421,13 +421,13 @@ function player_retreat_from_fleet_combat(destination_star = noone) { var _total_remaining = _p_fleet.escort_number + _p_fleet.frigate_number + _p_fleet.capital_number; - var _text = $"Your fleet is given the command to fall back to {destination_star.name ?? }outer space. The vessels turn and prepare to enter the Warp, constantly under a hail of enemy fire."; + var _text = $"Your fleet is given the command to fall back to {destination_star.name ?? "outer space"}. The vessels turn and prepare to enter the Warp, constantly under a hail of enemy fire."; if (_total_lost > 0 && _total_remaining > 0) { _text += "\n\nSome of your ships remain behind to draw off the attack and give the rest of your fleet a chance to escape."; for (var t = 0; t < array_length(_tiers); t++) { var _casualties = _tiers[t].lost; if (_casualties > 0) { - _text += $" {_casualties} {string_plural(_tiers[t].label, _casualties)} {smart_verb(}was{, _casualties)} destroyed."; + _text += $" {_casualties} {string_plural(_tiers[t].label, _casualties)} {smart_verb("was", _casualties)} destroyed."; } } } else if (_total_lost == 0) { diff --git a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml index f5109497f3..d8e345a204 100644 --- a/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml +++ b/scripts/scr_punit_combat_heplers/scr_punit_combat_heplers.gml @@ -224,16 +224,16 @@ function move_enemy_blocks() { function block_composition_string() { var _composition_string = $"{unit_count}x Total; "; if (men > 0) { - _composition_string += $"{string_plural_count(}Normal Unit{, men)}; "; + _composition_string += $"{string_plural_count("Normal Unit", men)}; "; } if (medi > 0) { - _composition_string += $"{string_plural_count(}Big Unit{, medi)}; "; + _composition_string += $"{string_plural_count("Big Unit", medi)}; "; } if (dreads > 0) { - _composition_string += $"{string_plural_count(}Walker{, dreads)}; "; + _composition_string += $"{string_plural_count("Walker", dreads)}; "; } if (veh > 0) { - _composition_string += $"{string_plural_count(}Vehicle{, veh)}; "; + _composition_string += $"{string_plural_count("Vehicle", veh)}; "; } _composition_string += $"\n"; diff --git a/scripts/scr_reequip_units/scr_reequip_units.gml b/scripts/scr_reequip_units/scr_reequip_units.gml index 00d8d44994..9912c509d2 100644 --- a/scripts/scr_reequip_units/scr_reequip_units.gml +++ b/scripts/scr_reequip_units/scr_reequip_units.gml @@ -289,7 +289,7 @@ function draw_popup_equip(before_after_styling = true) { _descriptor = "Vehicles"; } if (company != -1) { - draw_text(_x1 + 286, _y1 + 32, $"{comp} {localize(}Company{)}, {unit_count} {localize(_descriptor)}"); + draw_text(_x1 + 286, _y1 + 32, $"{comp} {localize("Company")}, {unit_count} {localize(_descriptor)}"); } draw_set_halign(fa_left); diff --git a/scripts/scr_squads/scr_squads.gml b/scripts/scr_squads/scr_squads.gml index fb61fc0050..aa7cfcae0b 100644 --- a/scripts/scr_squads/scr_squads.gml +++ b/scripts/scr_squads/scr_squads.gml @@ -806,7 +806,7 @@ function SquadArrangementEditor(company) constructor { var _btn = new UnitButtonObject({ style: "pixel", label: _squad_data.type_data.display_data, - tooltip: $"add {_key} as a {require_filter ? }required {: }proportional squad", + tooltip: $"add {_key} as a {require_filter ? "required" : "proportional"} squad", set_width: true, x1: picker_x, y1: _py, diff --git a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml index d80f7a947f..274d047a55 100644 --- a/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml +++ b/scripts/scr_unit_equip_functions/scr_unit_equip_functions.gml @@ -465,7 +465,7 @@ function alter_unit_equipment(update_equipment, from_armoury = true, to_armoury break; } if (_outcome == "no_items") { - _missing_items += $"{_missing_items == } {? } {: }, {localize(_item)}"; + _missing_items += $"{_missing_items == "" ? "" : ","} {localize(_item)}"; _success = false; } } From fbc4e588c10ab1a59f56dfe0dcce8633ab664f4d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 16:49:15 +0100 Subject: [PATCH 099/118] fuckk ups part 3 --- objects/obj_controller/Create_0.gml | 14 +++++++------- objects/obj_ncombat/Alarm_5.gml | 10 +++++----- objects/obj_ncombat/Alarm_7.gml | 2 +- objects/obj_popup_dialogue/Draw_64.gml | 2 +- scripts/AiFleetProblem/AiFleetProblem.gml | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index b2e5c292c9..0446b3bba7 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -1348,7 +1348,7 @@ var _build_clause = function(_prefix, _parts) { if (array_length(_parts) == 0) { return ""; } - return $"{_prefix} {string_join_ext(}, {, _parts)}."; + return $"{_prefix} {string_join_ext(", ", _parts)}."; }; LOGGER.info("Command staff"); @@ -1415,7 +1415,7 @@ for (var i = 0, l = array_length(_specialist_display); i < l; i++) { temp[35] = _build_clause("Specialist branches staffed by", _parts); var _honour_guard_count = _hq_index.has_role(_canon[eROLE.HONOURGUARD]) ? _hq_index.role_count(_canon[eROLE.HONOURGUARD]) : 0; if (_honour_guard_count > 0) { - temp[35] += $"\n\nHonour Guard, having the {_honour_guard_count} most veteran {string_plural(}marine{, _honour_guard_count)} of your chapter serving in it."; + temp[35] += $"\n\nHonour Guard, having the {_honour_guard_count} most veteran {string_plural("marine", _honour_guard_count)} of your chapter serving in it."; } var _vehicle_display = [ @@ -1496,7 +1496,7 @@ for (var i = 0; i < _ship_count; i++) { } } -temp[62] += $" {string_plural_count(}warship{, ships)}-\n"; +temp[62] += $" {string_plural_count("warship", ships)}-\n"; if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD || bb == 1) { temp[62] += $"Your flagship, Battle Barge {obj_ini.ship[0]}."; @@ -1504,19 +1504,19 @@ if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD || bb == 1) { bb--; } if (bb > 0) { - temp[62] += $"{string_plural_count(}Battle Barge{, bb)}: {array_to_string_order(bb_names, true)}"; + temp[62] += $"{string_plural_count("Battle Barge", bb)}: {array_to_string_order(bb_names, true)}"; temp[62] += "\n"; } if (sk > 0) { - temp[62] += $"{string_plural_count(}Strike Cruiser{, sk)}: {array_to_string_order(sk_names, true)}"; + temp[62] += $"{string_plural_count("Strike Cruiser", sk)}: {array_to_string_order(sk_names, true)}"; temp[62] += "\n"; } if (glad > 0) { - temp[62] += $"{string_plural_count(}Gladius Escort{, glad)}: {array_to_string_order(glad_names, true)}"; + temp[62] += $"{string_plural_count("Gladius Escort", glad)}: {array_to_string_order(glad_names, true)}"; temp[62] += "\n"; } if (hunt > 0) { - temp[62] += $"{string_plural_count(}Hunter Escort{, hunt)}: {array_to_string_order(hunt_names, true)}"; + temp[62] += $"{string_plural_count("Hunter Escort", hunt)}: {array_to_string_order(hunt_names, true)}"; temp[62] += "\n"; } diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 4866e55e4e..6c4a6a3690 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -113,7 +113,7 @@ var _newline = ""; var _total_deaths = final_marine_deaths + final_command_deaths; var _total_injured = _total_deaths + injured + units_saved_count; if (_total_injured > 0) { - _newline = $"{string_plural_count(}unit{, _total_injured)} {smart_verb(}was{, _total_injured)} critically injured."; + _newline = $"{string_plural_count("unit", _total_injured)} {smart_verb("was", _total_injured)} critically injured."; combat_log.push(_newline, eMSG_COLOR.DEFAULT); if (units_saved_count > 0) { @@ -127,7 +127,7 @@ if (_total_injured > 0) { _units_saved_string += smart_delimeter_sign(_unit_roles, i, false); } - _newline = $"{units_saved_count}x {smart_verb(}was{, units_saved_count)} saved by the {string_plural(roles[eROLE.APOTHECARY], apothecaries_alive)}. ({_units_saved_string})"; + _newline = $"{units_saved_count}x {smart_verb("was", units_saved_count)} saved by the {string_plural(roles[eROLE.APOTHECARY], apothecaries_alive)}. ({_units_saved_string})"; combat_log.push(_newline, eMSG_COLOR.DEFAULT); } @@ -194,7 +194,7 @@ if (red_thirst > 2) { var _total_damaged_count = vehicle_deaths + vehicles_saved_count; if (_total_damaged_count > 0) { - _newline = $"{string_plural_count(}vehicle{, _total_damaged_count)} {smart_verb(}was{, _total_damaged_count)} disabled during battle."; + _newline = $"{string_plural_count("vehicle", _total_damaged_count)} {smart_verb("was", _total_damaged_count)} disabled during battle."; combat_log.push(_newline, eMSG_COLOR.DEFAULT); if (vehicles_saved_count > 0) { @@ -208,7 +208,7 @@ if (_total_damaged_count > 0) { _vehicles_saved_string += smart_delimeter_sign(_vehicle_types, i, false); } - _newline = $"{string_plural(roles[eROLE.TECHMARINE], techmarines_alive)} {smart_verb(}was{, techmarines_alive)} able to restore {vehicles_saved_count}. ({_vehicles_saved_string})"; + _newline = $"{string_plural(roles[eROLE.TECHMARINE], techmarines_alive)} {smart_verb("was", techmarines_alive)} able to restore {vehicles_saved_count}. ({_vehicles_saved_string})"; combat_log.push(_newline, eMSG_COLOR.DEFAULT); } @@ -223,7 +223,7 @@ if (_total_damaged_count > 0) { _vehicles_lost_string += smart_delimeter_sign(_vehicle_types, i, false); } - _newline = $"{vehicle_deaths} {smart_verb(}was{, vehicle_deaths)} lost forever. ({_vehicles_lost_string})"; + _newline = $"{vehicle_deaths} {smart_verb("was", vehicle_deaths)} lost forever. ({_vehicles_lost_string})"; combat_log.push(_newline, eMSG_COLOR.RED); } diff --git a/objects/obj_ncombat/Alarm_7.gml b/objects/obj_ncombat/Alarm_7.gml index 45cea2e98d..0d4cad7fc2 100644 --- a/objects/obj_ncombat/Alarm_7.gml +++ b/objects/obj_ncombat/Alarm_7.gml @@ -6,7 +6,7 @@ try { obj_controller.cooldown = 10; - LOGGER.info($"Ground Combat - {(defeat ? }Defeat {: }Victory{)} - Enemy:{enemy} ({battle_special})"); + LOGGER.info($"Ground Combat - {(defeat ? "Defeat" : "Victory")} - Enemy:{enemy} ({battle_special})"); // If battling own dudes, then remove the loyalists after the fact diff --git a/objects/obj_popup_dialogue/Draw_64.gml b/objects/obj_popup_dialogue/Draw_64.gml index a11ef42999..79a3999c14 100644 --- a/objects/obj_popup_dialogue/Draw_64.gml +++ b/objects/obj_popup_dialogue/Draw_64.gml @@ -34,7 +34,7 @@ if (scr_hit(x + 19, y + 46, x + 280, y + 70)) { draw_set_font(fnt_40k_14); draw_set_color(c_gray); -draw_text(x + 150 + (blink ? 2 : 0), y + 50, $"{inputting}{blink ? }| {: }"); +draw_text(x + 150 + (blink ? 2 : 0), y + 50, $"{inputting}{blink ? "|" : ""}"); // Button 1s draw_set_alpha(0.25); diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 261ea79cfb..dd3dd0055a 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -207,7 +207,7 @@ static __radical_inquisitor_hear_them_out = function() { }, { str1: "Take the artifact and spare them", - choice_func: __popup_choice("take_artifact_bribe"); + choice_func: __popup_choice("take_artifact_bribe") } ]); obj_popup.title = "Artifact Offered"; @@ -218,7 +218,7 @@ static __radical_inquisitor_hear_them_out = function() { [ { str1: "Destroy their vessel", - choice_func: __popup_choice("destroy_inquisitor_ship"); + choice_func: __popup_choice("destroy_inquisitor_ship"), }, { str1: "Search their ship", @@ -226,7 +226,7 @@ static __radical_inquisitor_hear_them_out = function() { }, { str1: "Spare them", - choice_func: __popup_choice("show_mercy"); + choice_func: __popup_choice("show_mercy"), }, ], ); From d2b74fc7038d2d479c2608d03f88cf728ddb239d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 16:54:47 +0100 Subject: [PATCH 100/118] final spinn up issues --- objects/obj_p_fleet/Create_0.gml | 2 ++ scripts/AiFleetProblem/AiFleetProblem.gml | 6 +++--- scripts/SystemProblem/SystemProblem.gml | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index f2f31a7cf5..a9bb4a42fb 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -26,6 +26,8 @@ escort = []; escort_num = []; escort_sel = []; escort_uid = []; +problems = []; + image_speed = 0; diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index dd3dd0055a..65428ae418 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -250,7 +250,7 @@ static __radical_inquisitor_hear_them_out = function() { __check_delete(); } -static __radical_inquisitor_show_mercy() { +static __radical_inquisitor_show_mercy = function() { with (fleet) { random_sector_exit_point(); trade_goods = "|DELETE|"; @@ -268,7 +268,7 @@ static __radical_inquisitor_show_mercy() { __check_delete(); } -static __radical_inquisitor_artifact_double_cross function() { +static __radical_inquisitor_artifact_double_cross = function() { with (fleet) { instance_destroy(); } @@ -287,7 +287,7 @@ static __radical_inquisitor_artifact_double_cross function() { } /// @self Asset.GMObject.obj_popup -function radical_inquisitor_take_artifact_bribe() { +static __radical_inquisitor_take_artifact_bribe = function() { with (fleet) { random_sector_exit_point(); trade_goods = "|DELETE|"; diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 66927b3779..6cc242e555 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -150,8 +150,8 @@ static __hunt_inquisitor_init = function(){ _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {_star.name}, expected within {_eta} months. They are to be silenced and removed."; } - data.inquisitor_name = _name, - data.inquisitor_gender = _gender, + data.inquisitor_name = _name; + data.inquisitor_gender = _gender; var _pop_data = { mission: self, options: __inquisition_mission_options(), From 1a971848cdcac1ce38ba25dbc975448f8d9265dc Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 17:10:42 +0100 Subject: [PATCH 101/118] remove legacy inquisitor edge cases --- objects/obj_popup/Step_0.gml | 151 ++++++++--------------------------- 1 file changed, 35 insertions(+), 116 deletions(-) diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index 7d701548ee..d83f4470ab 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -43,9 +43,6 @@ try { } exit; } - if (((title == "Inquisition Mission") || (title == "Inquisition Recon")) && (title != "Artifact Located") && (obj_controller.demanding == 1)) { - demand = 1; - } if ((image == "chaos_messenger") && (title == "Chaos Meeting")) { if ((mission == "meeting_1") || (mission == "meeting_1t")) { @@ -203,131 +200,53 @@ try { } if (title == "Scheduled Event:2") { exit; - } else if (((title == "Inquisition Mission") || (title == "Inquisition Recon")) && (array_length(options) == 0)) { - add_option(["Accept", "Refuse"], true); - } - - if ((press == 0) && array_length(options) || ((demand == 1) && (mission != "") && (string_count("Inquisition", title) > 0)) || ((demand == 1) && (title == "Inquisition Recon"))) { - - if ((mission != "") && (title == "Inquisition Mission")) { - obj_controller.temp[200] = string(loc); - var onceh = 0; - var _mission_star = find_star_by_name(obj_controller.temp[200]); - var mission_is_go = false; - if (_mission_star != noone && planet > 0) { - var _estimate = estimate; - var _planet = planet; - var _mission = mission; - var _p_data = _mission_star.get_planet_data(_planet); - with (_mission_star) { - _p_data.new_problem(_mission, _estimate) - new_star_event_marker("green"); - mission_is_go = true; + } + /* + if (mission == "artifact") { + var last_artifact; + scr_quest(0, "artifact_loan", 4, estimate); + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + image = "fortress"; + if (obj_ini.home_type == "Hive") { + image = "fortress_hive"; } - - if (mission_is_go) { - if (demand) { - title = "Inquisition Mission Demand"; - } - if (mission == "inquisition_spyrer") { - scr_event_log("", $"Inquisition Mission Accepted: The Spyrer on {_mission_star.name} {scr_roman(planet)} must be killed within {estimate} months.", _mission_star.name); - if (demand) { - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. An out of control Spyrer on Hive {_mission_star.name} {scr_roman(onceh)} must be removed within {estimate} months."; - } - } else if (mission == "ethereal") { - with (obj_star) { - if ((p_tau[1] >= 4) || (p_tau[2] >= 4) || (p_tau[3] >= 4) || (p_tau[4] >= 4)) { - new_star_event_marker("green"); - } - } - scr_quest(0, "ethereal_capture", 4, estimate); - obj_controller.useful_info += "Tau|"; - - if (demand) { - title = "Inquisition Mission Demand"; - text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. {global.chapter_name} are to capture the Tau Ethereal somewhere within the {_mission_star.name} system."; - } - } + if (obj_ini.home_type == "Death") { + image = "fortress_death"; } - } - if (!mission_is_go) { - if (mission == "artifact") { - var last_artifact; - scr_quest(0, "artifact_loan", 4, estimate); - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - image = "fortress"; - if (obj_ini.home_type == "Hive") { - image = "fortress_hive"; - } - if (obj_ini.home_type == "Death") { - image = "fortress_death"; - } - if (obj_ini.home_type == "Ice") { - image = "fortress_ice"; - } - if (obj_ini.home_type == "Lava") { - image = "fortress_lava"; - } - last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.home_name, -1); - } else if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - image = "artifact_given"; - last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 0); - } - - title = "New Artifact"; - fancy_title = 0; - text_center = 0; - text = "The Inquisition has left an Artifact in your care, until it may be retrieved. It has been stored "; - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - text += "within your Fortress Monastery."; - } - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - text += $"upon your ship '{obj_ini.ship[0]}'."; - } - scr_event_log("", "Inquisition Mission Accepted: The Inquisition has left an Artifact in your care."); - - text += $" It is some form of {fetch_artifact(last_artifact).get_type_name()}."; - reset_popup_options(); - obj_controller.cooldown = 10; - exit; + if (obj_ini.home_type == "Ice") { + image = "fortress_ice"; + } + if (obj_ini.home_type == "Lava") { + image = "fortress_lava"; } + last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.home_name, -1); + } else if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + image = "artifact_given"; + last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 0); } - if (demand) { - demand = 0; - reset_popup_options(); - exit; - } // Remove multi-choices - } + title = "New Artifact"; + fancy_title = 0; + text_center = 0; + text = "The Inquisition has left an Artifact in your care, until it may be retrieved. It has been stored "; + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + text += "within your Fortress Monastery."; + } + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + text += $"upon your ship '{obj_ini.ship[0]}'."; + } + scr_event_log("", "Inquisition Mission Accepted: The Inquisition has left an Artifact in your care."); - if (image == "artifact2") { - ground_forces_collect_artifact(); + text += $" It is some form of {fetch_artifact(last_artifact).get_type_name()}."; + reset_popup_options(); obj_controller.cooldown = 10; - instance_destroy(); - } - - obj_controller.cooldown = 10; - if (obj_controller.complex_event == false) { - if (number != 0 && instance_exists(obj_turn_end)) { - obj_turn_end.alarm[1] = 4; - } - instance_destroy(); + exit; } } + */ if ((press == 1) && (option2 != "")) { - if (title == "Mercy Plea") { - // If have any marines within the fleet on the ships - var able, i; - able = 0; - i = 0; - - // Several things can happen when the ship is searched; - // Full of demons, maybe remove a marine, fired upon and explodes - - exit; - } if (image == "artifact2") { scr_return_ship(obj_ground_mission.loc, obj_ground_mission, obj_ground_mission.num); From 9a7322d72bb62b0ecfb1c446b3a6d503418b0357 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 17:24:23 +0100 Subject: [PATCH 102/118] legacy var names --- scripts/FleetProblem/FleetProblem.gml | 17 +++++++++++++++++ scripts/Problem/Problem.gml | 1 + scripts/SystemProblem/SystemProblem.gml | 8 ++++---- scripts/scr_cheatcode/scr_cheatcode.gml | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index b065763633..0a6845fab2 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -163,6 +163,23 @@ static __init = function(){ } } +function load_fleet_problems(_problem_constructor, _save_data){ + // Problems, old saves won't have this key + problems = []; + if (struct_exists(_save_data, "problems")) { + for (var i = 0; i < array_length(_save_data.problems); i++) { + try { + // empty p_id stops __init from running, load() theadn restores the real p_id and timer + var _problem = new _problem_constructor("", 0, {}, self); + _problem.load(_save_data.problems[i]); + _problem.fleet = self; + array_push(problems, _problem); + } catch (e) { + LOGGER.exception("Fleet problem deserialization failed", e); + } + } + } +} diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml index e5dfde5661..16f0b2176e 100644 --- a/scripts/Problem/Problem.gml +++ b/scripts/Problem/Problem.gml @@ -86,6 +86,7 @@ function Problem(_name, _timer, _data) constructor { { str1: "Accept", choice_func: function(){ + show_debug_message("accepted"); var _mission = pop_data.mission var _func_str = _mission.find_func_ref("accept"); if (struct_exists(_mission, _func_str)){ diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 6cc242e555..4b0095c4cb 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -145,9 +145,9 @@ static __hunt_inquisitor_init = function(){ var _eta = scr_mission_eta(system.x, system.y, 1); _eta = max(_eta, 8); timer = _eta - var _text = $"The Inquisition is trusting you with a special mission. A radical inquisitor named {_name} will be visiting the {_star.name} system in {_eta} month's time. They are highly suspect of heresy, and as such, are to be put down. Can your chapter handle this mission?"; + var _text = $"The Inquisition is trusting you with a special mission. A radical inquisitor named {_name} will be visiting the {system.name} system in {_eta} month's time. They are highly suspect of heresy, and as such, are to be put down. Can your chapter handle this mission?"; if (obj_controller.demanding) { - _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {_star.name}, expected within {_eta} months. They are to be silenced and removed."; + _text = $"The Inquisition demands that your Chapter demonstrate its loyalty to the Imperium of Mankind and the Emperor. A radical inquisitor is enroute to {system.name}, expected within {_eta} months. They are to be silenced and removed."; } data.inquisitor_name = _name; @@ -156,13 +156,13 @@ static __hunt_inquisitor_init = function(){ mission: self, options: __inquisition_mission_options(), }; - + show_debug_message("works"); scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } static __hunt_inquisitor_accept = function(){ - scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {pop_data.mission_data.inquisitor_name} enroute to {_mission_star.name} must be removed. Estimated arrival in {pop_data.estimate} months.", _mission_star.name); + scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {data.inquisitor_name} enroute to {system.name} must be removed. Estimated arrival in {pop_data.estimate} months.", system.name); var _radical_inquisitor_fleet = create_enemy_fleet(system.x - irandom_range(-400, 400), system.y - irandom_range(-400, 400), eFACTION.INQUISITION); with (_radical_inquisitor_fleet) { diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index 79ce2a3286..da5046ac99 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -366,7 +366,7 @@ function draw_system_debug(){ var _keys = global.planet_problem_keys; var _star_missions = [ "great_crusade", - "radical_inquisitor" + "hunt_inquisitor" ] _base_y += 2; draw_set_font(fnt_40k_12); From f11b82b18e1b937bb75ca879cfe42aa655949758 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 20:13:55 +0100 Subject: [PATCH 103/118] minor changes --- scripts/AiFleetProblem/AiFleetProblem.gml | 12 +++++------- scripts/FleetProblem/FleetProblem.gml | 6 +++++- .../PlayerFleetProblem/PlayerFleetProblem.gml | 16 ++++++++-------- scripts/SystemProblem/SystemProblem.gml | 5 +++-- .../scr_player_fleet_functions.gml | 2 +- scripts/scr_random_event/scr_random_event.gml | 5 ++++- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 65428ae418..7aaa053105 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -67,7 +67,7 @@ __init(); static __deliver_hunt_trophy_mission_log_entry = function(){ var _mission = localize("Deliver Trophy Guard"); - var _sys = fleets_next_location(); + var _sys = fleets_next_location(fleet); var _mission_data = { mission: self, system: _sys.name, @@ -108,7 +108,7 @@ static __radical_inquisitor_init = function(){ static __radical_inquisitor_mission_log_entry = function(){ var _mission = "Intercept Radical Inquisitor"; - var _sys = fleets_next_location(); + var _sys = fleets_next_location(fleet); var _mission_data = { mission: self, system: data.target_name, @@ -126,7 +126,7 @@ static __radical_inquisitor_mission_log_entry = function(){ } static __radical_inquisitor_on_arrival = function(){ - if (!orbiting.has_orbiting_player_fleet()) { + if (!fleet.orbiting.has_orbiting_player_fleet()) { with (fleet){ random_sector_exit_point(); action_spd = 256; @@ -140,19 +140,17 @@ static __radical_inquisitor_on_arrival = function(){ delete_mission = true; exit; } - - action = ""; var _gender = string_gender_third_person(data.inquisitor_gender); var _tixt = $"You have located the radical Inquisitor. As you prepare to destroy their ship, and complete the mission, you recieve a hail- it appears as though {_gender} wishes to speak."; var _options = [ { str1: "Destroy their vessel", - choice_func: method(self, radical_inquisitor_destroy_inquisitor_ship), + choice_func: method(self, __popup_choice("destroy_inquisitor_ship")), }, { str1: "Hear them out", - choice_func: method(self, radical_inquisitor_hear_them_out), + choice_func: method(self, __popup_choice("hear_them_out")), }, ]; scr_popup("Inquisitor Located", _tixt, "inquisition", {mission:self, options : _options}); diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 0a6845fab2..102d7c356f 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -78,7 +78,7 @@ static __check_delete = function(){ } //runs the entry point with fleet_event_data available for the duration of the call -static __trigger_with_event = function(trigger_string, _event_data){ +static __trigger_with_event = function(trigger_string, _event_data = {}){ var _func = find_func(trigger_string); if (is_undefined(_func)){ exit; @@ -107,6 +107,10 @@ static on_split = function(new_fleet){ __trigger_with_event("on_split", {new_fleet}); } +static on_waypoint_arrival = function(new_fleet){ + __trigger_with_event("on_waypoint_arrival"); +} + /// @param {Id.Instance.obj_p_fleet} merged_fleet static on_merge = function(merged_fleet){ __trigger_with_event("on_merge", {merged_fleet}); diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index aed60e9fe6..1b28ff2895 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -74,7 +74,7 @@ static __great_crusade_init = function(){ fleet.beyond_engagement = true; } -static __great_crusade_on_final_arrival = function(){ +static __great_crusade_on_arrival = function(){ if (stage_id == "travel_to_crusade"){ var _direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); fleet.action_x = fleet.x + lengthdir_x(600, _direction); @@ -201,9 +201,9 @@ static __great_crusade_results = function(){ _dead = false; } else { if (irandom(100) < _unit.weapon_skill) { - var _heroic_deed = choose("holding a breach in imperial defenses allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); - //TODO figure out a blance in reward for captains or high rnaking death on crusade - //adds dynamacism as itt creates reward for the potential loss of men and talent during crusades + var _heroic_deed = choose("holding a breach in imperial defences allowing allied forces to regroup,", "slaying the enemy leader in glorious combat, while victorious he ultimately succumbed to his wounds,", "leading an imortant boarding mission,"); + //TODO figure out a blance in reward for captains or high ranking death on crusade + //adds dynamism as it creates reward for the potential loss of men and talent during crusades //var consolations = ["ship", "req",""] //var consolation_prize = irandom(2) var heroic_death = $"{_unit.full_title()} died {_heroic_deed} {_unit.name()} dies a hero of the {global.chapter_name}"; @@ -274,7 +274,7 @@ static __great_crusade_results = function(){ tixt += "The combat was as could be expected- "; } if (_type == "hard") { - tixt += "The combat was fairly grueling- "; + tixt += "The combat was fairly gruelling- "; } if (_type == "brutal") { tixt += "The combat was absolutely brutal- fleet.your marines were the first into the fray, and as a result "; @@ -296,10 +296,10 @@ static __great_crusade_results = function(){ } if (_artifacts > 0) { - tixt += $" {_artifacts} Artifacts were granted to your Chapter or looted."; + tixt += $" {_artifacts} Artefacts were granted to your Chapter or looted."; } if ((_roll3 <= 10) && (_artifacts > 1)) { - tixt += " One of them were given as a bonus for exceptional valor."; + tixt += " One of them were given as a bonus for exceptional valour."; } if (array_length(_heroics_strings) == 1) { @@ -307,7 +307,7 @@ static __great_crusade_results = function(){ } else if (array_length(_heroics_strings) > 1) { tixt += " Several deeds were recorded"; } - // title / text / image / speshul + // title / text / image / scr_popup("Crusade Results", tixt, "crusade", ""); for (var i = 0; i < array_length(_heroics_strings); i++) { scr_popup("Heroic Deed", _heroics_strings[i], "crusade", ""); diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 4b0095c4cb..d155f51359 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -137,7 +137,8 @@ static __hunt_inquisitor_init = function(){ } system = array_random_element(_stars); - } + } + array_push(system.problems, self); var _gender = set_gender(); var _name = global.name_generator.GenerateFromSet($"imperial_{string_gender()}"); @@ -162,7 +163,7 @@ static __hunt_inquisitor_init = function(){ static __hunt_inquisitor_accept = function(){ - scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {data.inquisitor_name} enroute to {system.name} must be removed. Estimated arrival in {pop_data.estimate} months.", system.name); + scr_event_log("", $"Inquisition Mission Accepted: The radical Inquisitor {data.inquisitor_name} enroute to {system.name} must be removed. Estimated arrival in {timer} months.", system.name); var _radical_inquisitor_fleet = create_enemy_fleet(system.x - irandom_range(-400, 400), system.y - irandom_range(-400, 400), eFACTION.INQUISITION); with (_radical_inquisitor_fleet) { 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 b1b6acd3fc..c4c96da0a0 100644 --- a/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml +++ b/scripts/scr_player_fleet_functions/scr_player_fleet_functions.gml @@ -676,7 +676,7 @@ try { arrive_at_waypoint(); } else { for (var i = 0; i < array_length(problems); i++){ - problems[i].on_final_arrival(); + problems[i].on_arrival(); } } } diff --git a/scripts/scr_random_event/scr_random_event.gml b/scripts/scr_random_event/scr_random_event.gml index 600def0a6e..80421df2c3 100644 --- a/scripts/scr_random_event/scr_random_event.gml +++ b/scripts/scr_random_event/scr_random_event.gml @@ -643,7 +643,8 @@ function scr_random_event(execute_now) { _evented = true; } } else if (chosen_event == eEVENT.CRUSADE) { - new SystemProblem("great_crusade", noone); + var _crusade = new SystemProblem("great_crusade", noone); + _evented = _crusade.delete_mission != true; } else if (chosen_event == eEVENT.ENEMY) { _evented = make_faction_enemy_event(); } else if (chosen_event == eEVENT.MUTATION) { @@ -689,6 +690,7 @@ function scr_random_event(execute_now) { scr_event_log("red", "The Chapter Gene-Seed has mutated."); } else if (chosen_event == eEVENT.SHIP_LOST) { loose_ship_to_warp_event(); + _evented = true; } else if (chosen_event == eEVENT.CHAOS_INVASION) { LOGGER.info("RE: Chaos Invasion"); @@ -706,6 +708,7 @@ function scr_random_event(execute_now) { } else if ((psyker_intolerant || !_has_chief_psyker) && _cm_is_psyker) { scr_popup("The Maw of the Warp Yawns Wide", "The barrier between the realm of man and the Immaterium feels thin and tested to you. Dark forces are afoot.", "Warp", ""); } + _evented = true; } else if (chosen_event == eEVENT.NECRON_AWAKEN) { _evented = awaken_tomb_event(); } else if (chosen_event == eEVENT.FALLEN) { From e9260d9dd5dd6b8be736802f681fec86be40c61b Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 20:37:17 +0100 Subject: [PATCH 104/118] remove last of legacy inquisition mission code --- objects/obj_en_fleet/Create_0.gml | 2 +- objects/obj_p_fleet/Create_0.gml | 2 +- objects/obj_popup/Step_0.gml | 43 ------------- scripts/AiFleetProblem/AiFleetProblem.gml | 9 ++- scripts/FleetProblem/FleetProblem.gml | 2 +- scripts/Problem/Problem.gml | 1 - scripts/SystemProblem/SystemProblem.gml | 3 +- .../scr_inquisition_mission.gml | 61 ++++++++++++++++++- 8 files changed, 70 insertions(+), 53 deletions(-) diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 74d16eb67d..f431964bee 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -144,7 +144,7 @@ deserialize = function(_save_data) { cargo_data.ork_warboss = _boss; } } - load_fleet_problems(AiFleetProblems, save_data); + load_fleet_problems(AiFleetProblem, save_data); }; #endregion diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index a9bb4a42fb..14574ce85e 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -202,6 +202,6 @@ deserialize = function(save_data) { // Problems, old saves won't have this key problems = []; - load_fleet_problems(PlayerFleetProblems, save_data); + load_fleet_problems(PlayerFleetProblem, save_data); set_player_fleet_image(); }; \ No newline at end of file diff --git a/objects/obj_popup/Step_0.gml b/objects/obj_popup/Step_0.gml index d83f4470ab..f3a3b30f2b 100644 --- a/objects/obj_popup/Step_0.gml +++ b/objects/obj_popup/Step_0.gml @@ -201,49 +201,6 @@ try { if (title == "Scheduled Event:2") { exit; } - /* - if (mission == "artifact") { - var last_artifact; - scr_quest(0, "artifact_loan", 4, estimate); - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - image = "fortress"; - if (obj_ini.home_type == "Hive") { - image = "fortress_hive"; - } - if (obj_ini.home_type == "Death") { - image = "fortress_death"; - } - if (obj_ini.home_type == "Ice") { - image = "fortress_ice"; - } - if (obj_ini.home_type == "Lava") { - image = "fortress_lava"; - } - last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.home_name, -1); - } else if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - image = "artifact_given"; - last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 0); - } - - title = "New Artifact"; - fancy_title = 0; - text_center = 0; - text = "The Inquisition has left an Artifact in your care, until it may be retrieved. It has been stored "; - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - text += "within your Fortress Monastery."; - } - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - text += $"upon your ship '{obj_ini.ship[0]}'."; - } - scr_event_log("", "Inquisition Mission Accepted: The Inquisition has left an Artifact in your care."); - - text += $" It is some form of {fetch_artifact(last_artifact).get_type_name()}."; - reset_popup_options(); - obj_controller.cooldown = 10; - exit; - } - } - */ if ((press == 1) && (option2 != "")) { diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 7aaa053105..6e89b1ba52 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -126,6 +126,11 @@ static __radical_inquisitor_mission_log_entry = function(){ } static __radical_inquisitor_on_arrival = function(){ + if (orbiting == noone){ + LOGGER.error("radical_inquisitor mission inquisitor fleet did not arrive at system"); + delete_mission = true; + exit; + } if (!fleet.orbiting.has_orbiting_player_fleet()) { with (fleet){ random_sector_exit_point(); @@ -146,11 +151,11 @@ static __radical_inquisitor_on_arrival = function(){ var _options = [ { str1: "Destroy their vessel", - choice_func: method(self, __popup_choice("destroy_inquisitor_ship")), + choice_func: , __popup_choice("destroy_inquisitor_ship"), }, { str1: "Hear them out", - choice_func: method(self, __popup_choice("hear_them_out")), + choice_func: _popup_choice("hear_them_out"), }, ]; scr_popup("Inquisitor Located", _tixt, "inquisition", {mission:self, options : _options}); diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 102d7c356f..38ddc3dc3e 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -107,7 +107,7 @@ static on_split = function(new_fleet){ __trigger_with_event("on_split", {new_fleet}); } -static on_waypoint_arrival = function(new_fleet){ +static on_waypoint_arrival = function(){ __trigger_with_event("on_waypoint_arrival"); } diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml index 16f0b2176e..e5dfde5661 100644 --- a/scripts/Problem/Problem.gml +++ b/scripts/Problem/Problem.gml @@ -86,7 +86,6 @@ function Problem(_name, _timer, _data) constructor { { str1: "Accept", choice_func: function(){ - show_debug_message("accepted"); var _mission = pop_data.mission var _func_str = _mission.find_func_ref("accept"); if (struct_exists(_mission, _func_str)){ diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index d155f51359..4230450b3b 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -137,8 +137,8 @@ static __hunt_inquisitor_init = function(){ } system = array_random_element(_stars); + array_push(system.problems, self); } - array_push(system.problems, self); var _gender = set_gender(); var _name = global.name_generator.GenerateFromSet($"imperial_{string_gender()}"); @@ -157,7 +157,6 @@ static __hunt_inquisitor_init = function(){ mission: self, options: __inquisition_mission_options(), }; - show_debug_message("works"); scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index cac136701c..055ccdb009 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -221,10 +221,67 @@ function mission_inquisition_artifact() { var text; LOGGER.info("RE: Artifact Hold"); text = "The Inquisition is trusting you with a special mission. A local Inquisitor has a powerful artifact. You are to keep it safe, and NOT use it, until the artifact may be safely retrieved. Can your chapter handle this mission?"; - scr_popup("Inquisition Mission", text, "inquisition", $"artifact|bop|0|{string(irandom_range(6, 26))}|"); + var _pop_data = { + options : [ + { + str1: "Accept", + choice_func: mission_inquisition_artifact_accept, + }, + { + str1 "Refuse", + choice_func: popup_default_close() + } + ] + estimate : irandom_range(6, 26) + } + + scr_popup("Inquisition Mission", text, "inquisition", _pop_data); +} + + +// @self Asset.GMObject.obj_popup +function mission_inquisition_artifact_accept(){ + var _last_artifact; + scr_quest(0, "artifact_loan", 4, estimate); + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + image = "fortress"; + if (obj_ini.home_type == "Hive") { + image = "fortress_hive"; + } + if (obj_ini.home_type == "Death") { + image = "fortress_death"; + } + if (obj_ini.home_type == "Ice") { + image = "fortress_ice"; + } + if (obj_ini.home_type == "Lava") { + image = "fortress_lava"; + } + _last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.home_name, -1); + } else if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + image = "artifact_given"; + _last_artifact = scr_add_artifact("good", "inquisition", 0, obj_ini.ship[0], 0); + } + + title = "New Artifact"; + fancy_title = 0; + text_center = 0; + text = "The Inquisition has left an Artifact in your care, until it may be retrieved. It has been stored "; + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + text += "within your Fortress Monastery."; + } + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + text += $"upon your ship '{obj_ini.ship[0]}'."; + } + scr_event_log("", "Inquisition Mission Accepted: The Inquisition has left an Artifact in your care."); + + text += $" It is some form of {fetch_artifact(_last_artifact).get_type_name()}."; + reset_popup_options(); + obj_controller.cooldown = 10; + exit; + } } -/// @self Asset.GMObject.obj_popup function hunt_inquisition_spared_inquisitor_consequence(event) { var _diceh = roll_dice_chapter(1, 100, "high"); From 9a317ab222675ecb75fccbad8b9d742d1c34d41b Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 20:38:53 +0100 Subject: [PATCH 105/118] remove fleet.your typo --- scripts/PlayerFleetProblem/PlayerFleetProblem.gml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index 1b28ff2895..93938e5151 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -277,10 +277,10 @@ static __great_crusade_results = function(){ tixt += "The combat was fairly gruelling- "; } if (_type == "brutal") { - tixt += "The combat was absolutely brutal- fleet.your marines were the first into the fray, and as a result "; + tixt += "The combat was absolutely brutal- your marines were the first into the fray, and as a result "; } - tixt += $"{_marines_lost} of fleet.your battle brothers fell in combat."; + tixt += $"{_marines_lost} of your battle brothers fell in combat."; var _apoth_role = obj_ini.player_role_data[eROLE.APOTHECARY].role; if (obj_ini.doomed == 0) { @@ -288,11 +288,11 @@ static __great_crusade_results = function(){ tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; } if ((_apoth == 0) && (_seed > 0)) { - tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of fleet.your Gene-Seed."; + tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of your Gene-Seed."; } } if (obj_ini.doomed == 1) { - tixt += " Due to fatal mutations in fleet.your marines none of the fallen Gene-Seed was recoverable."; + tixt += " Due to fatal mutations in your marines none of the fallen Gene-Seed was recoverable."; } if (_artifacts > 0) { From 9270217901944d296d32994aca511914eabb10c8 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 20:42:05 +0100 Subject: [PATCH 106/118] explicit scope bind for functions --- scripts/AiFleetProblem/AiFleetProblem.gml | 3 +++ scripts/PlanetProblem/PlanetProblem.gml | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 6e89b1ba52..48024c9425 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -65,6 +65,8 @@ static on_merge = function(merged_fleet){ __init(); + +//unfinished will be completed in adjacent pr static __deliver_hunt_trophy_mission_log_entry = function(){ var _mission = localize("Deliver Trophy Guard"); var _sys = fleets_next_location(fleet); @@ -123,6 +125,7 @@ static __radical_inquisitor_mission_log_entry = function(){ _mission_data.hover = method(_mission_data, function() { tooltip_draw($"intercept the radical Inquisitor {mission.data.inquisitor_name} at {mission.data.target_name}, expected within {mission.timer} months."); }); + return _mission_data; } static __radical_inquisitor_on_arrival = function(){ diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 3d93358e68..766ab0ddce 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -350,10 +350,10 @@ static __hunt_beast_feature_selected = function(){ draw_data.mission_description = $"The governor of {p_data.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."; draw_data.help = "This is a good opportunity to provide experience and training, having at least one marine with experience in such matters would be advisable"; draw_data.button_text = "Send Hunters"; - draw_data.button_function = function() { + draw_data.button_function = method(self, function() { var _dudes = collect_role_group("all", system.name); select_units(_dudes, "Beast Hunt", 3); - }; + }); }; @@ -456,10 +456,10 @@ static __train_forces_feature_selected = function() { draw_data.mission_description = $"The governor of {p_data.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."; draw_data.help = $"A task best suited to the more knowledgable or wise of your Commanders"; draw_data.button_text = "Assign Officer"; - draw_data.button_function = function() { + draw_data.button_function = method(self, function() { var _dudes = collect_role_group(SPECIALISTS_CAPTAIN_CANDIDATES, system.name); select_units(_dudes,"Select Officer", 1); - }; + }); } static __train_forces_unit_select = function() { @@ -1318,10 +1318,10 @@ static __protect_raiders_feature_selected = function() { draw_data.help = "Set a squads to ambush"; draw_data.button_text = "Send Squad"; draw_data.button_tooltip = "mileage may vary on playability of this mission progress at your own risk"; - draw_data.button_function = function() { + draw_data.button_function = method(self, function() { var _dudes = collect_role_group("all", system.name); select_squads(_dudes, "Select Squad for Ambush", 1) - }; + }); } static __protect_raiders_battle_aftermath = function() { From a89582f2d910c34b5b4bca135412e375e85a0db6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 21:00:03 +0100 Subject: [PATCH 107/118] make it end --- objects/obj_en_fleet/Create_0.gml | 2 +- scripts/AiFleetProblem/AiFleetProblem.gml | 6 +++--- scripts/PlayerFleetProblem/PlayerFleetProblem.gml | 2 +- .../scr_inquisition_mission/scr_inquisition_mission.gml | 9 ++++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index f431964bee..7a82d74a85 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -144,7 +144,7 @@ deserialize = function(_save_data) { cargo_data.ork_warboss = _boss; } } - load_fleet_problems(AiFleetProblem, save_data); + load_fleet_problems(AiFleetProblem, _save_data); }; #endregion diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 48024c9425..f947e45ed1 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -129,7 +129,7 @@ static __radical_inquisitor_mission_log_entry = function(){ } static __radical_inquisitor_on_arrival = function(){ - if (orbiting == noone){ + if (fleet.orbiting == noone){ LOGGER.error("radical_inquisitor mission inquisitor fleet did not arrive at system"); delete_mission = true; exit; @@ -154,11 +154,11 @@ static __radical_inquisitor_on_arrival = function(){ var _options = [ { str1: "Destroy their vessel", - choice_func: , __popup_choice("destroy_inquisitor_ship"), + choice_func: __popup_choice("destroy_inquisitor_ship"), }, { str1: "Hear them out", - choice_func: _popup_choice("hear_them_out"), + choice_func: __popup_choice("hear_them_out"), }, ]; scr_popup("Inquisitor Located", _tixt, "inquisition", {mission:self, options : _options}); diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index 93938e5151..f44b134bec 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -288,7 +288,7 @@ static __great_crusade_results = function(){ tixt += $" The {_apoth} surviving {_apoth_role} were able to recover {_seed} Gene-Seed."; } if ((_apoth == 0) && (_seed > 0)) { - tixt += $" fleet.You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of your Gene-Seed."; + tixt += $" You had no able-bodied {_apoth_role}, or all of them perished in the Crusade. Foreign Apothecaries were able to recover {_seed} of your Gene-Seed."; } } if (obj_ini.doomed == 1) { diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 055ccdb009..066b5dd60f 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -228,10 +228,10 @@ function mission_inquisition_artifact() { choice_func: mission_inquisition_artifact_accept, }, { - str1 "Refuse", - choice_func: popup_default_close() + str1 : "Refuse", + choice_func: popup_default_close, } - ] + ], estimate : irandom_range(6, 26) } @@ -242,7 +242,7 @@ function mission_inquisition_artifact() { // @self Asset.GMObject.obj_popup function mission_inquisition_artifact_accept(){ var _last_artifact; - scr_quest(0, "artifact_loan", 4, estimate); + scr_quest(0, "artifact_loan", 4, pop_data.estimate); if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { image = "fortress"; if (obj_ini.home_type == "Hive") { @@ -279,7 +279,6 @@ function mission_inquisition_artifact_accept(){ reset_popup_options(); obj_controller.cooldown = 10; exit; - } } From 7e04f47336f6ad66985b210931e3550ffb87aa96 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 22:22:43 +0100 Subject: [PATCH 108/118] legacy --- scripts/AiFleetProblem/AiFleetProblem.gml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index f947e45ed1..a369833ced 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -75,10 +75,10 @@ static __deliver_hunt_trophy_mission_log_entry = function(){ system: _sys.name, system_id: _sys.id, target: self, - important_person: _event.data.trophy_owner, - person_name: _event.data.delivering_marine, + important_person: data.trophy_owner, + person_name: data.delivering_marine, planet: 0, - start_system: _event.data.system, + start_system: data.system, time: timer, }; @@ -202,14 +202,14 @@ static __radical_inquisitor_hear_them_out = function() { var gender_pronoun = string_gender_pronouns(_gender); if (_offer == 1) { - replace_options([ + obj_popop.replace_options([ { str1: "Destroy their vessel", - choice_func: method(self, __popup_choice("inquisitor_ship")), + choice_func: __popup_choice("destroy_inquisitor_ship"), }, { str1: "Take the artifact and then destroy them", - choice_func: method(self, __popup_choice("artifact_double_cross")) + choice_func: __popup_choice("artifact_double_cross"), }, { str1: "Take the artifact and spare them", @@ -220,7 +220,7 @@ static __radical_inquisitor_hear_them_out = function() { obj_popup.text = $"The Inquisitor claims that this is a massive misunderstanding, and {_gender_third} wishes to prove {gender_pronoun} innocence. If {global.chapter_name} allow their ship to leave {_gender_third} will give {global.chapter_name} an artifact."; exit; } else if (_offer == 2) { - replace_options( + obj_popop.replace_options( [ { str1: "Destroy their vessel", @@ -236,8 +236,8 @@ static __radical_inquisitor_hear_them_out = function() { }, ], ); - title = "Mercy Plea"; - text = $"The Inquisitor claims that {_gender_third} has key knowledge that would grant the Imperium vital power over the forces of Chaos. If {global.chapter_name} allow {gender_pronoun} ship to leave the forces of Chaos within this sector will be weakened."; + obj_popop.title = "Mercy Plea"; + obj_popop.text = $"The Inquisitor claims that {_gender_third} has key knowledge that would grant the Imperium vital power over the forces of Chaos. If {global.chapter_name} allow {gender_pronoun} ship to leave the forces of Chaos within this sector will be weakened."; exit; } else if (_offer == 3) { with (fleet) { From 3c24be0cbd221a2a811dcb5601443aea1d2e415d Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Thu, 1 Oct 2026 23:07:19 +0100 Subject: [PATCH 109/118] popop --- scripts/AiFleetProblem/AiFleetProblem.gml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index a369833ced..97ac31bc7f 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -202,7 +202,7 @@ static __radical_inquisitor_hear_them_out = function() { var gender_pronoun = string_gender_pronouns(_gender); if (_offer == 1) { - obj_popop.replace_options([ + obj_popup.replace_options([ { str1: "Destroy their vessel", choice_func: __popup_choice("destroy_inquisitor_ship"), @@ -220,7 +220,7 @@ static __radical_inquisitor_hear_them_out = function() { obj_popup.text = $"The Inquisitor claims that this is a massive misunderstanding, and {_gender_third} wishes to prove {gender_pronoun} innocence. If {global.chapter_name} allow their ship to leave {_gender_third} will give {global.chapter_name} an artifact."; exit; } else if (_offer == 2) { - obj_popop.replace_options( + obj_popup.replace_options( [ { str1: "Destroy their vessel", @@ -236,8 +236,8 @@ static __radical_inquisitor_hear_them_out = function() { }, ], ); - obj_popop.title = "Mercy Plea"; - obj_popop.text = $"The Inquisitor claims that {_gender_third} has key knowledge that would grant the Imperium vital power over the forces of Chaos. If {global.chapter_name} allow {gender_pronoun} ship to leave the forces of Chaos within this sector will be weakened."; + obj_popup.title = "Mercy Plea"; + obj_popup.text = $"The Inquisitor claims that {_gender_third} has key knowledge that would grant the Imperium vital power over the forces of Chaos. If {global.chapter_name} allow {gender_pronoun} ship to leave the forces of Chaos within this sector will be weakened."; exit; } else if (_offer == 3) { with (fleet) { From 4d5780856a404f8339873910d5460ec783f341fb Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 12:00:38 +0100 Subject: [PATCH 110/118] clutch of upgrades --- objects/obj_en_fleet/Create_0.gml | 9 +- objects/obj_p_fleet/Create_0.gml | 10 +- scripts/FleetProblem/FleetProblem.gml | 8 +- scripts/PlanetProblem/PlanetProblem.gml | 3 +- .../PlayerFleetProblem/PlayerFleetProblem.gml | 8 +- .../scr_fleet_functions.gml | 21 +++ .../scr_ork_fleet_functions.gml | 2 +- .../scr_unit_quick_find_pane.gml | 147 +++++++++--------- 8 files changed, 113 insertions(+), 95 deletions(-) diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 7a82d74a85..319176c225 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -81,14 +81,7 @@ problems = []; /// @param {Real} _timer /// @param {struct} _data /// @returns {Struct.AiFleetProblem} -add_problem = function(_name, _timer, _data = {}){ - var _problem = new AiFleetProblem(_name, _timer, _data, self); - if (_problem.delete_mission){ - return undefined; - } - array_push(problems, _problem); - return _problem; -} +add_problem = method(self, add_fleet_problem); #region save/load serialization /// Called from save function to take all object variables and convert them to a json savable format and return it diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 14574ce85e..9a5513b2f1 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -53,6 +53,8 @@ hurssy_time = 0; /// Called from save function to take all object variables and convert them to a json savable format and return it +add_problem = method(self, add_fleet_problem); + problems_to_mission_log = function(){ var _temp_log = [] for (var i = 0; i < array_length(problems); i++) { @@ -94,12 +96,12 @@ arrived_at_star = function(){ } - if (steh.p_type[1] == "Craftworld") { - rando = roll_dice_chapter(1, 100, "high"); + if (orbiting.p_type[1] == "Craftworld") { + var _rando = roll_dice_chapter(1, 100, "high"); - if ((rando >= 95)) { + if ((_rando >= 95)) { obj_controller.known[eFACTION.ELDAR] = 1; - scr_alert("green", "elfs", "Eldar Craftworld discovered.", steh.old_x, steh.old_y); + scr_alert("green", "elfs", "Eldar Craftworld discovered.", orbiting.old_x, orbiting.old_y); with (obj_en_fleet) { if (owner == eFACTION.ELDAR) { image_alpha = 1; diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 38ddc3dc3e..6eca4438ac 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -143,7 +143,7 @@ static __default_mission_log_entry = function(){ return undefined; } var _data = { - system: is_callable(fleet.name) ? fleet.name() : object_get_name(fleet.object_index), + system: fleet_location_description(fleet).loc, mission: description(), time: timer, problem: self, @@ -184,6 +184,12 @@ function load_fleet_problems(_problem_constructor, _save_data){ } } } +function add_fleet_problem(_p_id, _timer = -1, _data = {}){ + var _instance = object_index == obj_en_fleet ? AiFleetProblem : PlayerFleetProblem; + var _problem = new _instance(_p_id, _timer, _data, self); + array_push(problems, _problem); + return _problem; +} diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 766ab0ddce..e6a7def0d0 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -104,7 +104,6 @@ static __check_delete = function(){ } if (_prob > -1){ array_delete(system.p_problem[planet], _prob,1); - array_delete(p_data.problems, _prob,1); } } } @@ -1879,7 +1878,7 @@ static __hive_fleet_to_cult_init = function(){ _fleet.frigate_number = round(random_range(6, 12)); _fleet.escort_number = round(random_range(12, 27)); - _fleet.image_index = floor(_fleet.capital_number + (_fleet.frigate_number / 2) + (_fleet.escort_number / 4)); + _fleet.image_index = standard_fleet_strength_calc(_fleet); _fleet.image_alpha = 0; _fleet.action_x = system.x; diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index f44b134bec..91485fdfe7 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -67,9 +67,9 @@ __init(); static __great_crusade_init = function(){ var _crusade_direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); - fleet.action_x = fleet.x + lengthdir_x(1200, _crusade_direction); - fleet.action_y = fleet.y + lengthdir_y(1200, _crusade_direction); - fleet.move(false, "move"); + fleet.action_x = fleet.x + lengthdir_x(room_width / 2, _crusade_direction); + fleet.action_y = fleet.y + lengthdir_y(room_height / 2, _crusade_direction); + fleet.move(false, "move", irandom_range(24, 36), irandom_range(24, 36)); stage_id = "travel_to_crusade"; fleet.beyond_engagement = true; } @@ -101,7 +101,7 @@ static __great_crusade_on_arrival = function(){ var _return_star = instance_nearest(fleet.x, fleet.y, obj_star); fleet.action_x = _return_star.x; fleet.action_y = _return_star.y; - fleet.move(false, "move"); + fleet.move(false, "move", irandom_range(24, 36), irandom_range(24, 36)); instance_activate_object(obj_star); fleet.beyond_engagement = true; stage_id = "returning_home" diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 045dc58172..24b5950905 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -27,6 +27,27 @@ function fleet_is_orbiting(){ return noone; } +/// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} _fleet +function fleet_location_description(_fleet){ + var _loc = ""; + var _zoomable = true; + if (!point_in_rectangle(_fleet.x, _fleet.y, 0, 0, room_width, room_height)){ + _loc = "Out of Sector" + _zoomable = false; + } + else if (_fleet.action == "Lost") { + _loc = localize("Lost"); + _zoomable = false; + } else if (_fleet.action == "move") { + _loc = localize("Warp Travel"); + } else { + var _near_star = instance_nearest(_fleet.x, _fleet.y, obj_star); + _loc = _near_star.name; + } + return {loc: _loc , zoomable : _zoomable}; +} + + /// @self Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet /// @param {Id.Instance.obj_en_fleet|Id.Instance.obj_p_fleet} fleet function standard_fleet_strength_calc(fleet = noone) { diff --git a/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml b/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml index 6ff2f068b4..54c8bd200d 100644 --- a/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml +++ b/scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.gml @@ -67,7 +67,7 @@ function ork_fleet_arrive_target() { } } if (ork_attack_planet > 0) { - p_tyranids[ork_attack_planet] -= floor(_ork_fleet.capital_number + (_ork_fleet.frigate_number / 2)); + p_tyranids[ork_attack_planet] -= floor(standard_fleet_strength_calc(_ork_fleet)); var _pdata = get_planet_data(ork_attack_planet); diff --git a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml index ed6786ea44..2a2fd1a9cc 100644 --- a/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml +++ b/scripts/scr_unit_quick_find_pane/scr_unit_quick_find_pane.gml @@ -27,14 +27,14 @@ function UnitQuickFindPanel() constructor { current_hover = -1; hover_count = 0; - var xx = main_panel.XX; - var yy = main_panel.YY; + var _xx = main_panel.XX; + var _yy = main_panel.YY; fleet_table = new Table({ - x1: xx + 10, - y1: yy + 50, - x2: xx + main_panel.width, - y2: yy + main_panel.height, + x1: _xx + 10, + y1: _yy + 50, + x2: _xx + main_panel.width, + y2: _yy + main_panel.height, headings: ["Capitals", "Frigates", "Escorts", "Location"], row_key_draw: ["capitals", "frigates", "escorts", "location"], set_column_widths: [70, 70, 70, 100], @@ -159,32 +159,21 @@ function UnitQuickFindPanel() constructor { // ── UPDATER (call in Step or whenever fleet data changes) ──────────────────── static update_fleet_table = function() { - var xx = main_panel.XX; - var yy = main_panel.YY; + var _xx = main_panel.XX; + var _yy = main_panel.YY; var _rows = []; for (var i = start_fleet; i < instance_number(obj_p_fleet); i++) { var _cur_fleet = instance_find(obj_p_fleet, i); // ── Resolve location string ─────────────────────────────────────────── - var _loc = ""; - var _zoomable = true; + var _loc = fleet_location_description(_cur_fleet); var _point_data = _cur_fleet.point_breakdown; - if (_cur_fleet.action == "Lost") { - _loc = localize("Lost"); - _zoomable = false; - } else if (string_count("crusade", _cur_fleet.action)) { - _loc = localize("Crusading"); - _zoomable = false; - } else if (_cur_fleet.action == "move") { - _loc = localize("Warp Travel"); - } else { - var _near_star = instance_nearest(_cur_fleet.x, _cur_fleet.y, obj_star); - _loc = _near_star.name; - var _sys_points = obj_controller.specialist_point_handler.point_breakdown.systems; - if (struct_exists(_sys_points, _near_star.name)) { - _point_data = _sys_points[$ _near_star.name][0]; + var _sys_points = obj_controller.specialist_point_handler.point_breakdown.systems; + if (_cur_fleet.orbiting != noone){ + if (struct_exists(_sys_points, _cur_fleet.orbiting.name)) { + _point_data = _sys_points[$ _cur_fleet.orbiting.name][0]; } } @@ -193,7 +182,7 @@ function UnitQuickFindPanel() constructor { capitals: _cur_fleet.capital_number, frigates: _cur_fleet.frigate_number, escorts: _cur_fleet.escort_number, - location: _loc, + location: _loc.loc, parent: self, fleet: _cur_fleet, point_data: _point_data, @@ -205,7 +194,7 @@ function UnitQuickFindPanel() constructor { }); // Click to pan camera — only when location is meaningful - if (_zoomable) { + if (_loc.zoomable) { _row.click_left = method(_row, function() { set_map_pan_to_loc(fleet); }); @@ -228,8 +217,8 @@ function UnitQuickFindPanel() constructor { }; static draw_fleet_area = function() { - var xx = main_panel.XX; - var yy = main_panel.YY; + var _xx = main_panel.XX; + var _yy = main_panel.YY; if (fleet_table.row_count() != instance_number(obj_p_fleet)) { update_fleet_table(); @@ -237,7 +226,7 @@ function UnitQuickFindPanel() constructor { if (fleet_table.last_drawn_sequence != hide_sequence){ fleet_table.last_drawn_sequence = hide_sequence; - fleet_table.update({x1: xx + 40, y1: yy + 50, y2: yy + 50 + main_panel.height, colour: c_white, font: fnt_40k_14}); + fleet_table.update({x1: _xx + 40, y1: _yy + 50, y2: _yy + 50 + main_panel.height, colour: c_white, font: fnt_40k_14}); } fleet_table.draw(); @@ -246,7 +235,7 @@ function UnitQuickFindPanel() constructor { if (hovered_fleet_data != undefined) { var _fpd = hovered_fleet_data; var _sx = main_panel.XX + main_panel.width - 10; - var _sy = yy + 108; + var _sy = _yy + 108; detail_slate.draw(_sx, _sy, 1.5, 1.5); draw_specialist_point_headers(_sx, _sy); @@ -272,12 +261,12 @@ function UnitQuickFindPanel() constructor { _temp_log = array_concat(_temp_log, problems_to_mission_log()); } mission_log = _temp_log; - var xx = main_panel.XX; - var yy = main_panel.YY; + var _xx = main_panel.XX; + var _yy = main_panel.YY; var _data = { - x1: xx + 60, - y1: yy + 50, - y2: yy + main_panel.height + 50, + x1: _xx + 60, + y1: _yy + 50, + y2: _yy + main_panel.height + 50, set_column_widths: [ 70, 150, @@ -299,9 +288,9 @@ function UnitQuickFindPanel() constructor { }; static main_panel_content = 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); + var _xx = main_panel.XX; + var _yy = main_panel.YY; + is_entered = scr_hit(_xx, _yy, _xx + main_panel.width, _yy + main_panel.height); // ── DRAW ───────────────────────────────────────────────────────────────────── if (view_area == "fleets") { draw_fleet_area(); @@ -310,10 +299,10 @@ function UnitQuickFindPanel() constructor { draw_set_color(c_white); draw_set_font(cjk_font(fnt_40k_14)); draw_set_halign(fa_center); - draw_text(xx + 80, yy + 50, localize("System")); - draw_text(xx + 160, yy + 50, localize("Troops")); - draw_text(xx + 240, yy + 50, localize("Healers")); - draw_text(xx + 310, yy + 50, localize("Techies")); + draw_text(_xx + 80, _yy + 50, localize("System")); + draw_text(_xx + 160, _yy + 50, localize("Troops")); + draw_text(_xx + 240, _yy + 50, localize("Healers")); + draw_text(_xx + 310, _yy + 50, localize("Techies")); var i = start_system; var registered_hover = false; var system_names = struct_get_names(garrison_log); @@ -323,15 +312,15 @@ function UnitQuickFindPanel() constructor { var loc = hover_item.location; hover_entered = scr_hit(loc[0], loc[1], loc[2], loc[3]); } - while (i < array_length(system_names) && (yy + 122 + (20 * i)) < main_panel.YY + yy + main_panel.height) { + while (i < array_length(system_names) && (_yy + 122 + (20 * i)) < 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 + 108 + (20 * i); - if (scr_hit(xx + 10, yy + 90 + (20 * i), xx + main_panel.width, _sys_item_y)) { + var _sys_item_y = _yy + 108 + (20 * i); + 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 + 30, yy + 88 + (20 * i), xx + main_panel.width - 20, yy + 108 + (20 * i), 0); + draw_rectangle(_xx + 30, _yy + 88 + (20 * i), _xx + main_panel.width - 20, _yy + 108 + (20 * i), 0); draw_set_color(c_white); if (current_hover > -1 && current_hover != i) { registered_hover = false; @@ -342,14 +331,14 @@ function UnitQuickFindPanel() constructor { } } else { if (hover_item.root_item == i) { - draw_rectangle(xx + 30, yy + 88 + (20 * i), xx + main_panel.width - 20, yy + 108 + (20 * i), 0); + draw_rectangle(_xx + 30, _yy + 88 + (20 * i), _xx + main_panel.width - 20, _yy + 108 + (20 * i), 0); } } - detail_slate.draw(xx + main_panel.width - 10, _sys_item_y - 20, 1.5, 1.5); + 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 _xx = _xx + main_panel.width - 10; var _yy = _sys_item_y - 20; draw_specialist_point_headers(_xx, _yy); for (var s = 1; s <= 4; s++) { @@ -366,13 +355,13 @@ function UnitQuickFindPanel() constructor { } } } - 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); + 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 + 88 + (20 * i), xx + main_panel.width, yy + 108 + (20 * i)])) { + if (point_and_click([_xx + 10, _yy + 88 + (20 * i), _xx + main_panel.width, _yy + 108 + (20 * i)])) { var _star = find_star_by_name(system_names[i]); if (_star != noone) { set_map_pan_to_loc(_star); @@ -396,34 +385,42 @@ function UnitQuickFindPanel() constructor { hover_count = 0; hover_item = noone; } else if (hover_item != noone) { - if (point_and_click(hover_item.draw(xx + 10, yy + 90 + (20 * hover_item.root_item), localize("Manage")))) { + if (point_and_click(hover_item.draw(localize("Manage")))) { group_selection(garrison_log[$ system_names[hover_item.root_item]].units, {purpose: localize("{0} Management", [system_names[hover_item.root_item]]), 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") { - mission_table.update({x1: xx + 35, y1: yy + 50}); + mission_table.update({x1: _xx + 35, y1: _yy + 50}); mission_table.draw(); } }; main_panel.inside_method = method(self, main_panel_content); + static pane_hide_frames = 15; + static pane_hidden = 15; + static pane_revealed = 0; + static sequence_complete = 30; + static pane_moving = function(){ + return hide_sequence != pane_hidden && hide_sequence != pane_revealed; + } static hide_reveal_sequence = function(){ 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)) { - var _increment = (main_panel.width / 15); - if (hide_sequence > 15) { - _x_draw = (_increment * (hide_sequence - 15)) - main_panel.width; + if (hide_sequence == sequence_complete) { + hide_sequence = pane_revealed; + } + var _increment = 0; + if (pane_moving()) { + _increment = (main_panel.width / pane_hide_frames); + if (hide_sequence > pane_hide_frames) { + _x_draw = (_increment * (hide_sequence - pane_hide_frames)) - main_panel.width; } else { _x_draw = -(_increment * hide_sequence); } hide_sequence++; } - if (hide_sequence > 15 || hide_sequence < 15) { + if (hide_sequence != pane_hidden) { main_panel.draw(_x_draw, 110, 0.46, 0.75); if (tab_buttons.fleets.draw(_x_draw, 79, localize("Fleets"))) { view_area = "fleets"; @@ -444,14 +441,11 @@ function UnitQuickFindPanel() constructor { hide_sequence++; } } - } else if (hide_sequence == 15) { - if (tab_buttons.hider.draw(0, _lower_draw, localize("Show"))) { + } else { + if (tab_buttons.hider.draw(_increment * (hide_sequence - 15) , _lower_draw , localize("Show"))) { hide_sequence++; } } - /*if (tab_buttons.troops.draw(345,79, "Troops")){ - view_area="troops"; - }*/ } static travel_camera_to_target = function(){ @@ -473,6 +467,7 @@ function UnitQuickFindPanel() constructor { } } + errored_once = false; static draw = function() { try { add_draw_return_values(); @@ -484,7 +479,12 @@ function UnitQuickFindPanel() constructor { } travel_camera_to_target(); pop_draw_return_values(); - } catch (_exception) {} //dangerous to handle will just make game unplayable if crash does occur + } catch (_exception) { + if (!errored_once){ + ERROR_HANDLER.handle_exception(_exception); + errored_once = true; + } + } //dangerous to handle will just make game unplayable if crash does occur }; LOGGER.info("UnitQuickFindPanel successfully initialised"); @@ -501,7 +501,7 @@ function HoverBox() constructor { 0, ]; - static draw = function(xx, yy, button_text) { + static draw = function(button_text) { location = draw_unit_buttons([relative_x, relative_y], button_text, [1, 1], c_green,, fnt_40k_14b, 1); return location; }; @@ -805,13 +805,10 @@ function HelpfulPlaces() constructor { var _data = { fleet_id: id, - location: "Warp", + location: fleet_location_description(self).loc, remaining_guard: $"{_guard_percentage}%", action: trade_goods, }; - if (instance_exists(orbiting)) { - _data.location = orbiting.name; - } _data.hover = method(_data, function() { if (location != "Warp") { From 3a1228442fa270014ef7b44f986abf4f5f55c363 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 12:06:15 +0100 Subject: [PATCH 111/118] correct. scoping --- scripts/AiFleetProblem/AiFleetProblem.gml | 4 ++-- scripts/PlanetProblem/PlanetProblem.gml | 16 ++++++++-------- scripts/SystemProblem/SystemProblem.gml | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 97ac31bc7f..607ea7e201 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -71,7 +71,6 @@ static __deliver_hunt_trophy_mission_log_entry = function(){ var _mission = localize("Deliver Trophy Guard"); var _sys = fleets_next_location(fleet); var _mission_data = { - mission: self, system: _sys.name, system_id: _sys.id, target: self, @@ -81,6 +80,7 @@ static __deliver_hunt_trophy_mission_log_entry = function(){ start_system: data.system, time: timer, }; + _pop_data.mission = self; _mission_data.click_left = method(_mission_data, function() { set_map_pan_to_loc(system_id); @@ -112,11 +112,11 @@ static __radical_inquisitor_mission_log_entry = function(){ var _mission = "Intercept Radical Inquisitor"; var _sys = fleets_next_location(fleet); var _mission_data = { - mission: self, system: data.target_name, system_id: find_star_by_name(data.target_name), time: timer, }; + _pop_data.mission = self; _mission_data.click_left = method(_mission_data, function() { set_map_pan_to_loc(mission.fleet); diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index e6a7def0d0..eb542a78b1 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -643,9 +643,9 @@ static __succession_resolve = function() { static __inquisition_recon_init = function(){ var _pop_data = { - mission: self, options : __inquisition_mission_options() }; + _pop_data.mission = self; var _text = $"The Inquisition wishes for you to investigate {p_data.name()}"; _text += $" Boots are expected to be planted on its surface over the course of your investigation."; @@ -665,8 +665,8 @@ static __inquisition_recon_per_turn = function() { } var _pop_data = { - mission: self, }; + _pop_data.mission = self; scr_popup( "Investigation Completed", "Your marines have scouted out {p_data.name()} and satisfied the mission requirements.", @@ -691,9 +691,9 @@ static __inquisition_spyrer_init = function(){ var _text = $"The Inquisition is trusting you with a special mission. An experienced Spyrer on hive world {p_data.name()}"; _text += $" has began to hunt indiscriminately, and proven impossible to take down by conventional means. If they are not put down within {timer} month's time panic is likely. Can your chapter handle this mission?"; var _pop_data = { - mission: self, options: __inquisition_mission_options(), }; + _pop_data.mission = self; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } @@ -1454,9 +1454,9 @@ static __inquisition_tomb_init = function(){ var _text = $"The Inquisition is trusting you with a special mission. They have reason to suspect the Necron Tomb on planet {p_data.name()}"; _text += $" may become active. You are to send a small group of marines to plant a bomb deep inside, within {timer} months. Can your chapter handle this mission?"; var _pop_data = { - mission: self, options: __inquisition_mission_options(), }; + _pop_data.mission = self; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } @@ -1481,7 +1481,6 @@ static __inquisition_tomb_per_turn = function() { _tixt += " are prepared and ready to enter the Necron Tombs. A Plasma Bomb is in tow."; var _number = instance_exists(obj_turn_end) ? 1 : 0; var _pop_data = { - mission: self, loc: system.name, planet: planet, number: _number, @@ -1496,6 +1495,7 @@ static __inquisition_tomb_per_turn = function() { }, ], }; + _pop_data.mission = self; scr_popup("Necron Tomb Excursion", _tixt, $"necron_cave", _pop_data); } @@ -1780,9 +1780,9 @@ static __inquisition_demon_world_init = function(){ } _text += $"The taint of chaos must be eradicated from this system. Can your chapter handle this mission?"; var _pop_data = { - mission: self, options: __inquisition_mission_options(), }; + _pop_data.mission = self; scr_popup( "Inquisition Mission Demon World", _text, @@ -1801,9 +1801,9 @@ static __inquisition_demon_world_accept = function(){ static __inquisition_tyranid_org_init = function(){ var _pop_data = { - mission: self, options: __inquisition_mission_options(), }; + _pop_data.mission = self; var _text = $"An Inquisitor is trusting you with a special mission. The planet {p_data.name()}"; _text += " is ripe with Tyranid organisms. They require that you capture one of the Gaunt species for research purposes. Can your chapter handle this mission?"; if (obj_controller.demanding) { @@ -1926,9 +1926,9 @@ static __inquisition_purge_init = function(){ _text += $" The mutants of hive world {p_data.name()} are growing in numbers and ferocity, rising sporadically from the underhive. They are to be cleansed by promethium within {timer} months. Can your chapter handle this mission?"; } var _pop_data = { - mission: self, options: __inquisition_mission_options(), }; + _pop_data.mission = self; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 4230450b3b..83f413c8d1 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -154,9 +154,9 @@ static __hunt_inquisitor_init = function(){ data.inquisitor_name = _name; data.inquisitor_gender = _gender; var _pop_data = { - mission: self, options: __inquisition_mission_options(), }; + _pop_data.mission = self; scr_popup("Inquisition Mission", _text, "inquisition", _pop_data); } From 9946336e4c6e36a579126b6a12774525041ecc7c Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 19:45:07 +0100 Subject: [PATCH 112/118] review points --- scripts/AiFleetProblem/AiFleetProblem.gml | 4 ++-- scripts/FleetProblem/FleetProblem.gml | 1 + scripts/PlayerFleetProblem/PlayerFleetProblem.gml | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 607ea7e201..364bbefabe 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -80,7 +80,7 @@ static __deliver_hunt_trophy_mission_log_entry = function(){ start_system: data.system, time: timer, }; - _pop_data.mission = self; + _mission_data.mission = self; _mission_data.click_left = method(_mission_data, function() { set_map_pan_to_loc(system_id); @@ -116,7 +116,7 @@ static __radical_inquisitor_mission_log_entry = function(){ system_id: find_star_by_name(data.target_name), time: timer, }; - _pop_data.mission = self; + _mission_data.mission = self; _mission_data.click_left = method(_mission_data, function() { set_map_pan_to_loc(mission.fleet); diff --git a/scripts/FleetProblem/FleetProblem.gml b/scripts/FleetProblem/FleetProblem.gml index 6eca4438ac..4310936212 100644 --- a/scripts/FleetProblem/FleetProblem.gml +++ b/scripts/FleetProblem/FleetProblem.gml @@ -187,6 +187,7 @@ function load_fleet_problems(_problem_constructor, _save_data){ function add_fleet_problem(_p_id, _timer = -1, _data = {}){ var _instance = object_index == obj_en_fleet ? AiFleetProblem : PlayerFleetProblem; var _problem = new _instance(_p_id, _timer, _data, self); + if (_problem.delete_mission) return undefined; array_push(problems, _problem); return _problem; } diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index 91485fdfe7..5a8b976e0f 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -69,7 +69,7 @@ static __great_crusade_init = function(){ var _crusade_direction = point_direction(room_width / 2, room_height / 2, fleet.x, fleet.y); fleet.action_x = fleet.x + lengthdir_x(room_width / 2, _crusade_direction); fleet.action_y = fleet.y + lengthdir_y(room_height / 2, _crusade_direction); - fleet.move(false, "move", irandom_range(24, 36), irandom_range(24, 36)); + fleet.move(false, "move", irandom_range(24, 35), 36); stage_id = "travel_to_crusade"; fleet.beyond_engagement = true; } @@ -101,7 +101,7 @@ static __great_crusade_on_arrival = function(){ var _return_star = instance_nearest(fleet.x, fleet.y, obj_star); fleet.action_x = _return_star.x; fleet.action_y = _return_star.y; - fleet.move(false, "move", irandom_range(24, 36), irandom_range(24, 36)); + fleet.move(false, "move", irandom_range(24, 35), 36); instance_activate_object(obj_star); fleet.beyond_engagement = true; stage_id = "returning_home" From 834007026b9876a689bb5a7ef15d45c3134357fd Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 21:38:52 +0100 Subject: [PATCH 113/118] upgrade popup option constructor and fix scope issueand --- objects/obj_en_fleet/Create_0.gml | 2 + objects/obj_p_fleet/Create_0.gml | 1 + scripts/AiFleetProblem/AiFleetProblem.gml | 42 ++------- scripts/PlanetProblem/PlanetProblem.gml | 25 +++--- scripts/Problem/Problem.gml | 28 +++++- scripts/SystemProblem/SystemProblem.gml | 4 +- .../scr_popup_functions.gml | 90 +++++++++++-------- 7 files changed, 102 insertions(+), 90 deletions(-) diff --git a/objects/obj_en_fleet/Create_0.gml b/objects/obj_en_fleet/Create_0.gml index 319176c225..e5d930ff5e 100644 --- a/objects/obj_en_fleet/Create_0.gml +++ b/objects/obj_en_fleet/Create_0.gml @@ -82,6 +82,8 @@ problems = []; /// @param {struct} _data /// @returns {Struct.AiFleetProblem} add_problem = method(self, add_fleet_problem); +move = method(self, set_fleet_movement); + #region save/load serialization /// Called from save function to take all object variables and convert them to a json savable format and return it diff --git a/objects/obj_p_fleet/Create_0.gml b/objects/obj_p_fleet/Create_0.gml index 9a5513b2f1..8843250b89 100644 --- a/objects/obj_p_fleet/Create_0.gml +++ b/objects/obj_p_fleet/Create_0.gml @@ -156,6 +156,7 @@ calculate_eta = function(target_x, target_y,from_star = true, to_star = true){ } move = method(self, set_fleet_movement); + serialize = function() { var object_fleet = self; diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 364bbefabe..0344aba4af 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -152,16 +152,10 @@ static __radical_inquisitor_on_arrival = function(){ var _tixt = $"You have located the radical Inquisitor. As you prepare to destroy their ship, and complete the mission, you recieve a hail- it appears as though {_gender} wishes to speak."; var _options = [ - { - str1: "Destroy their vessel", - choice_func: __popup_choice("destroy_inquisitor_ship"), - }, - { - str1: "Hear them out", - choice_func: __popup_choice("hear_them_out"), - }, + __create_popup_option("Destroy their vessel", "destroy_inquisitor_ship"), + __create_popup_option("Hear them out", "hear_them_out"), ]; - scr_popup("Inquisitor Located", _tixt, "inquisition", {mission:self, options : _options}); + scr_popup("Inquisitor Located", _tixt, "inquisition", {mission: self, options : _options}); exit; } @@ -203,18 +197,9 @@ static __radical_inquisitor_hear_them_out = function() { if (_offer == 1) { obj_popup.replace_options([ - { - str1: "Destroy their vessel", - choice_func: __popup_choice("destroy_inquisitor_ship"), - }, - { - str1: "Take the artifact and then destroy them", - choice_func: __popup_choice("artifact_double_cross"), - }, - { - str1: "Take the artifact and spare them", - choice_func: __popup_choice("take_artifact_bribe") - } + __create_popup_option("Destroy their vessel", "destroy_inquisitor_ship"), + __create_popup_option("Take the artifact and then destroy them", "artifact_double_cross"), + __create_popup_option("Take the artifact and spare them", "take_artifact_bribe"), ]); obj_popup.title = "Artifact Offered"; obj_popup.text = $"The Inquisitor claims that this is a massive misunderstanding, and {_gender_third} wishes to prove {gender_pronoun} innocence. If {global.chapter_name} allow their ship to leave {_gender_third} will give {global.chapter_name} an artifact."; @@ -222,18 +207,9 @@ static __radical_inquisitor_hear_them_out = function() { } else if (_offer == 2) { obj_popup.replace_options( [ - { - str1: "Destroy their vessel", - choice_func: __popup_choice("destroy_inquisitor_ship"), - }, - { - str1: "Search their ship", - //choice_func : instance_destroy, // TODO: Implement proper ship search logic - }, - { - str1: "Spare them", - choice_func: __popup_choice("show_mercy"), - }, + __create_popup_option("Destroy their vessel", "destroy_inquisitor_ship"), + //__create_popup_option("Search their ship"), // TODO: Implement proper ship search logic + __create_popup_option("Spare them", "show_mercy"), ], ); obj_popup.title = "Mercy Plea"; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index eb542a78b1..20e245fa26 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1385,9 +1385,10 @@ static __protect_raiders_squad_selected = function() { _gar_pop.text += "\nThe total loss of a squad in what was meant to be a routine operation is bad for moral and your chapters reputation you must now decide how to proceed"; - _gar_pop.add_option({str1: "Suppress the Information", choice_func: protect_raiders_suppress_information}); - - _gar_pop.add_option({str1: "Hold a Memorial", choice_func: protect_raiders_hold_memorial}); + _gar_pop.replace_options([ + __create_popup_option("Suppress the Information", "suppress_information"), + __create_popup_option("Hold a Memorial", "hold_memorial"), + ]); } else { var _gar_pop = instance_create(0, 0, obj_popup); _gar_pop.title = $"Ineffective Ambush"; @@ -1484,26 +1485,20 @@ static __inquisition_tomb_per_turn = function() { loc: system.name, planet: planet, number: _number, - options: [ - { - str1: "Begin the Mission", - choice_func: inquisition_tomb_mission_start, - }, - { - str1: "Not Yet", - choice_func:__popup_delete, - }, - ], }; _pop_data.mission = self; + _pop_data.options = [ + __create_popup_option("Begin the Mission", "inquisition_tomb_mission_start"), + __create_popup_option("Not Yet"), + ]; scr_popup("Necron Tomb Excursion", _tixt, $"necron_cave", _pop_data); } static inquisition_tomb_mission_start = function() { obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; obj_popup.replace_options([ - {str1: "Continue", choice_func: inquisition_tomb_mission_sequence}, - {str1: "Return to the surface", choice_func: __popup_delete } + __create_popup_option("Continue", "inquisition_tomb_mission_sequence"), + __create_popup_option("Return to the surface"), ]); obj_popup.image = "necron_tunnels_1"; obj_popup.text = "Your marines enter the massive tunnel complex, following the energy readings. At first the walls are cramped and tiny, closing about them, but the tunnels widen at a rapid pace."; diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml index e5dfde5661..4842595814 100644 --- a/scripts/Problem/Problem.gml +++ b/scripts/Problem/Problem.gml @@ -50,10 +50,32 @@ function Problem(_name, _timer, _data) constructor { static __popup_choice = function(trigger_string){ var _func = find_func(trigger_string); if (!is_undefined(_func)){ - return method(self, _func); + if (instance_exists(self) && self.object_index == obj_popup){ + return method(self.pop_data.mission, _func); + } else if (is_struct(self) && is_instanceof(self, Problem)){ + return method(self, _func); + } } return undefined; } + + static __create_popup_option = function(_str1 = "", _func_string = "popup_delete"){ + var _opt = { + str1 : _str1, + run_in_popup : false + } + if (_func_string == "popup_delete"){ + _opt.choice_func = __popup_delete; + } else { + var _func = __popup_choice(_func_string); + if (!is_undefined(_func)){ + _opt.choice_func = _func; + } + } + + return _opt; + } + static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ __refresh_data(); @@ -89,7 +111,9 @@ function Problem(_name, _timer, _data) constructor { var _mission = pop_data.mission var _func_str = _mission.find_func_ref("accept"); if (struct_exists(_mission, _func_str)){ - _mission[$ _func_str](); + with(_mission){ + _mission[$ _func_str](); + } } obj_controller.demanding = 0; } diff --git a/scripts/SystemProblem/SystemProblem.gml b/scripts/SystemProblem/SystemProblem.gml index 83f413c8d1..d794ac075e 100644 --- a/scripts/SystemProblem/SystemProblem.gml +++ b/scripts/SystemProblem/SystemProblem.gml @@ -170,9 +170,7 @@ static __hunt_inquisitor_accept = function(){ } _radical_inquisitor_fleet.action_x = system.x; _radical_inquisitor_fleet.action_y = system.y; - with (_radical_inquisitor_fleet) { - set_fleet_movement(false, "move", timer, timer); - } + _radical_inquisitor_fleet.move(false, "move", timer, timer); data.target_name = system.name; _radical_inquisitor_fleet.add_problem("radical_inquisitor", timer, data); diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 04bfe66533..85081032a7 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -118,6 +118,56 @@ function PopupOption(data) constructor { if (!struct_exists(self, "choice_func")) { choice_func = popup_default_close; } + if (!struct_exists(self, "run_in_popup")) { + run_in_popup = true; + } + + static get_label = function(_index) { + return $"{_index + 1}. {str1}"; + } + + static on_hover = function(_popup) { + if (struct_exists(self, "hover") && is_callable(hover)) { + var _hover = hover; + with (_popup) { + script_execute(_hover); + } + } + } + + static on_click = function(_popup) { + if (!is_callable(choice_func)) { + return; + } + var _newest_popup = noone; + with (obj_popup) { + if (id > _newest_popup) { + _newest_popup = id; + } + } + + var _func = choice_func; + if (run_in_popup) { + with (_popup) { + script_execute(_func); + } + } else { + _func(); + } + + _popup.press = -1; + if (instance_exists(_popup)) { + var _replaced = false; + with (obj_popup) { + if (id > _newest_popup) { + _replaced = true; + } + } + if (_replaced) { + instance_destroy(_popup); + } + } + } } /// @self Asset.GMObject.obj_popup @@ -195,14 +245,7 @@ function draw_popup_options() { entered_option = -1; for (var i = 0; i < array_length(options); i++) { var _opt = options[i]; - var _opt_string = ""; - if (!is_struct(_opt)) { - _opt_string = _opt; - } else { - _opt_string = _opt.str1; - } - - _opt_string = $"{i + 1}. {_opt_string}"; + var _opt_string = _opt.get_label(i); var _string_x = x1 + 25.5; var _string_y = y1 + 20 + sz; @@ -214,37 +257,10 @@ function draw_popup_options() { draw_sprite(spr_popup_select, 0, x1 + 8.5, y1 + 21 + sz); entered_option = i; current_option = _opt; - var _is_struct = is_struct(_opt); - if (_is_struct && struct_exists(_opt, "hover")) { - if (is_callable(_opt.hover)) { - script_execute(_opt.hover); - } - } + _opt.on_hover(self); if (mouse_button_clicked(,, true)) { press = i; - if (_is_struct && struct_exists(_opt, "choice_func")) { - if (is_callable(_opt.choice_func)) { - var _newest_popup = noone; - with (obj_popup) { - if (id > _newest_popup) { - _newest_popup = id; - } - } - script_execute(_opt.choice_func); - press = -1; - if (instance_exists(id)) { - var _replaced = false; - with (obj_popup) { - if (id > _newest_popup) { - _replaced = true; - } - } - if (_replaced) { - instance_destroy(); - } - } - } - } + _opt.on_click(self); } } From 07ef1876bd9cb461b55d36df9efeab11b87098a4 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 23:07:20 +0100 Subject: [PATCH 114/118] better popup inntergration with Problems --- objects/obj_controller/Mouse_50.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 40 +++++++- scripts/Problem/Problem.gml | 12 ++- scripts/scr_UnitGroup/scr_UnitGroup.gml | 3 + .../scr_mission_functions.gml | 34 ------- scripts/scr_role_count/scr_role_count.gml | 96 ++----------------- 6 files changed, 54 insertions(+), 133 deletions(-) diff --git a/objects/obj_controller/Mouse_50.gml b/objects/obj_controller/Mouse_50.gml index c619512e7a..c090d437f9 100644 --- a/objects/obj_controller/Mouse_50.gml +++ b/objects/obj_controller/Mouse_50.gml @@ -82,7 +82,7 @@ if ((menu == eMENU.RECLUSIAM) && (cooldown <= 0) && (penitorium > 0)) { if ((mouse_y >= yy + 455) && (mouse_y < yy + 473) && (training_techmarine < 6)) { cooldown = 8000; if (faction_status[eFACTION.MECHANICUS] != "War") { - var _chapter_tech_count = scr_role_count("Techmarine", ""); + var _chapter_tech_count = collect_role_group(SPECIALISTS_TECHMARINES, "",false,{},true).number(); if (_chapter_tech_count >= ((disposition[3] / 2) + 5)) { training_techmarine = 0; } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index 20e245fa26..a0450b5a40 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1343,6 +1343,38 @@ static __protect_raiders_battle_aftermath = function() { } } +static __protect_raiders_suppress_information= function() { + obj_popup.title = "Captains Disgruntled"; + __add_option("continue"); + var _caps = scr_role_count(eROLE.CAPTAIN ,"", "units"); + var _worst = -1; + var _worst_hit = -1; + for (var i = 0; i < array_length(_caps); i++) { + if (irandom(2)) { + continue; + } + var _cap = _caps[i]; + var _loyalty_hit = irandom(6); + if (_loyalty_hit > _worst_hit) { + _worst_hit = _loyalty_hit; + _worst = i; + } + } + if (_worst == -1) { + obj_popup.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 { + obj_popup.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()}"; + } +} + +static __protect_raiders_hold_memorial() { + reset_popup_options(); + __add_option("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"; +} + + static __protect_raiders_squad_selected = function() { data.squad = data.squads[0]; var _squad = data.squad; @@ -1423,12 +1455,12 @@ static __protect_raiders_squad_selected = function() { enemies : [ { name : "Dire Avenger", - number : 40, + number : 20, special : "shimmershield" }, { name : "Dire Avenger Exarch", - number : 4, + number : 2, special : "shimmershield" }, { @@ -1488,7 +1520,7 @@ static __inquisition_tomb_per_turn = function() { }; _pop_data.mission = self; _pop_data.options = [ - __create_popup_option("Begin the Mission", "inquisition_tomb_mission_start"), + __create_popup_option("Begin the Mission", "mission_start"), __create_popup_option("Not Yet"), ]; scr_popup("Necron Tomb Excursion", _tixt, $"necron_cave", _pop_data); @@ -1497,7 +1529,7 @@ static __inquisition_tomb_per_turn = function() { static inquisition_tomb_mission_start = function() { obj_popup.title = $"Necron Tunnels : {data.mission_stage}"; obj_popup.replace_options([ - __create_popup_option("Continue", "inquisition_tomb_mission_sequence"), + __create_popup_option("Continue", "mission_sequence"), __create_popup_option("Return to the surface"), ]); obj_popup.image = "necron_tunnels_1"; diff --git a/scripts/Problem/Problem.gml b/scripts/Problem/Problem.gml index 4842595814..67ff6a0261 100644 --- a/scripts/Problem/Problem.gml +++ b/scripts/Problem/Problem.gml @@ -50,11 +50,7 @@ function Problem(_name, _timer, _data) constructor { static __popup_choice = function(trigger_string){ var _func = find_func(trigger_string); if (!is_undefined(_func)){ - if (instance_exists(self) && self.object_index == obj_popup){ - return method(self.pop_data.mission, _func); - } else if (is_struct(self) && is_instanceof(self, Problem)){ - return method(self, _func); - } + return method(self, _func); } return undefined; } @@ -70,12 +66,18 @@ function Problem(_name, _timer, _data) constructor { var _func = __popup_choice(_func_string); if (!is_undefined(_func)){ _opt.choice_func = _func; + } else { + LOGGER.error($"unknown popup trigger {_func_string} for {p_id}") } } return _opt; } + static __add_option = function(_str1 = "", _func_string = "popup_delete"){ + add_option(__create_popup_option(_str1, _func_string)); + } + static __handle_triggered_mission_func = function(func){ if (!is_undefined(func)){ __refresh_data(); diff --git a/scripts/scr_UnitGroup/scr_UnitGroup.gml b/scripts/scr_UnitGroup/scr_UnitGroup.gml index ef86aa86ac..72f64851a7 100644 --- a/scripts/scr_UnitGroup/scr_UnitGroup.gml +++ b/scripts/scr_UnitGroup/scr_UnitGroup.gml @@ -757,6 +757,9 @@ function SearchConditions(data) constructor { array_push(checks_order, squadless_valuate); } if (role != "") { + if (!is_real(role)){ + role = obj_ini.player_role_data[role].role; + } array_push(checks_order, role_valuate); } if (bool(array_length(roles))) { diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index f7b14f5053..bd6c12f90d 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -140,40 +140,6 @@ function init_marine_acting_strange() { scr_event_log("color", _text); } -/// @self Asset.GMObject.obj_popup -function protect_raiders_suppress_information() { - title = "Captains Disgruntled"; - options1 = "continue"; - pathway = ""; - var _caps = scr_role_count(obj_ini.player_role_data[eROLE.CAPTAIN].role); - var _worst = -1; - var _worst_hit = -1; - for (var i = 0; i < array_length(_caps); i++) { - if (!irandom(2)) { - var _cap = _caps[i]; - var _loyalty_hit = irandom(6); - 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"; - } 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()}"; - } -} - -/// @self Asset.GMObject.obj_popup -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"; -} - // returns a bool for if any planet on a given star has the given problem /// @self Asset.GMObject.obj_star diff --git a/scripts/scr_role_count/scr_role_count.gml b/scripts/scr_role_count/scr_role_count.gml index 9e62e5f885..461eabcc5c 100644 --- a/scripts/scr_role_count/scr_role_count.gml +++ b/scripts/scr_role_count/scr_role_count.gml @@ -1,94 +1,12 @@ function scr_role_count(target_role, search_location = "", return_type = "count") { - // Take a guess - var units = []; - var count = 0; - var coom = -999; - if (is_string(search_location)) { - if (search_location == "0") { - coom = 0; - } else if (search_location == "1") { - coom = 1; - } else if (search_location == "2") { - coom = 2; - } else if (search_location == "3") { - coom = 3; - } else if (search_location == "4") { - coom = 4; - } else if (search_location == "5") { - coom = 5; - } else if (search_location == "6") { - coom = 6; - } else if (search_location == "7") { - coom = 7; - } else if (search_location == "8") { - coom = 8; - } else if (search_location == "9") { - coom = 9; - } else if (search_location == "10") { - coom = 10; - } - } else { - coom = search_location; - } - - if (coom >= 0) { - for (var i = 0; i < array_length(obj_ini.TTRPG[coom]); i++) { - var unit = fetch_unit([coom, i]); - if (!is_struct(unit) || unit.name() == "") { - continue; - } - if ((unit.role() == target_role) && (obj_ini.TTRPG[coom][i].god_status < 10)) { - count += 1; - if (return_type == "units") { - var _u = fetch_unit([coom, i]); - if (is_struct(_u)) { - array_push(units, _u); - } - } - } - } - } - - if (coom < 0) { - for (var com = 0; com <= obj_ini.companies; com++) { - for (var i = 0; i < array_length(obj_ini.TTRPG[com]); i++) { - var match = false; - var unit = fetch_unit([com, i]); - if (!is_struct(unit) || unit.name() == "") { - continue; - } - if ((unit.role() == target_role) && (search_location == "")) { - match = true; - } - if ((unit.role() == target_role) && (unit.location_string == obj_ini.home_name) && (search_location == "home")) { - match = true; - } - if ((unit.role() == target_role) && (search_location == "field") && ((unit.location_string != obj_ini.home_name) || (unit.ship_location > -1))) { - match = true; - } + var _units = collect_role_group("all", search_location, false, {role:target_role}, true); - if ((search_location != "home") && (search_location != "field")) { - if (unit.role() == target_role) { - var t1 = unit.location_string + "|" + string(unit.planet_location) + "|"; - if (search_location == t1) { - match = true; - } - } - } - if (match) { - count++; - if (return_type == "units") { - array_push(units, unit); - } - } - } - } + if (return_type == "units"){ + return _units.units; + } else if return_type == "count"{ + return _units.number(); + }else if return_type == "group"{ + return _units; } - - if (return_type == "units") { - return units; - } - - return count; } From a20b4180793f9b5e0f7a87d9d46ae706589e02c6 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 23:24:04 +0100 Subject: [PATCH 115/118] port mars_Spelunk mission to new system --- scripts/AiFleetProblem/AiFleetProblem.gml | 118 +++++++++++++++++- scripts/PlanetProblem/PlanetProblem.gml | 9 +- .../PlayerFleetProblem/PlayerFleetProblem.gml | 4 +- .../scr_fleet_functions.gml | 18 --- .../scr_mission_reward/scr_mission_reward.gml | 103 --------------- 5 files changed, 119 insertions(+), 133 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index 0344aba4af..d95a913fda 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -150,12 +150,12 @@ static __radical_inquisitor_on_arrival = function(){ } var _gender = string_gender_third_person(data.inquisitor_gender); - var _tixt = $"You have located the radical Inquisitor. As you prepare to destroy their ship, and complete the mission, you recieve a hail- it appears as though {_gender} wishes to speak."; + var __tixt = $"You have located the radical Inquisitor. As you prepare to destroy their ship, and complete the mission, you recieve a hail- it appears as though {_gender} wishes to speak."; var _options = [ __create_popup_option("Destroy their vessel", "destroy_inquisitor_ship"), __create_popup_option("Hear them out", "hear_them_out"), ]; - scr_popup("Inquisitor Located", _tixt, "inquisition", {mission: self, options : _options}); + scr_popup("Inquisitor Located", __tixt, "inquisition", {mission: self, options : _options}); exit; } @@ -274,7 +274,7 @@ static __radical_inquisitor_take_artifact_bribe = function() { random_sector_exit_point(); trade_goods = "|DELETE|"; action_spd = 256; - set_fleet_movement(false); + fleet.move(false) } var last_artifact = scr_add_artifact("random", "", 4); @@ -289,6 +289,118 @@ static __radical_inquisitor_take_artifact_bribe = function() { add_event({e_id: "inquisitor_spared", duration: irandom_range(6, 18) + 1, variation: 1}); } +static __mech_mars_init = fuction(){ + fleet.home_x = x; + fleet.home_y = y; + fleet.action_x = x + lengthdir_x(3000, obj_controller.terra_direction); + fleet.action_y = y + lengthdir_y(3000, obj_controller.terra_direction); + fleet.move(false, "move", 48, 48); + stage_id = "to_mars"; +} + +static __mech_mars_on_arrival(){ + if (stage_id == "to_mars"){ + fleet.action_x = home_x; + fleet.action_y = home_y; + fleet.move(false, "move", 48, 48); + stage_id = "returning_home"; + exit; + } + + var _cleanup = array_create(11, 0); + + var _roll1 = roll_dice_chapter(1, 100, "high"); // For the first STC + var _found_stc = 0, _found_artifact = 0, _found_requisition = 0; + var _techs_lost = 0, techs_alive = 0; + + var _conditions = { + job: "mecanicus mission", + }; + var _techs = collect_role_group(SPECIALISTS_TECHS, star.name, false, _conditions); + + var _tech_point_gain = 0; + + for (var i = 0; i < array_length(_techs); i++) { + var _tech = _techs[i]; + var _tech_roll = global.character_tester.standard_test(_tech, "technology", -10)[1]; + var _wep_test = global.character_tester.standard_test(_tech, "weapon_skill", 10); + if (!_wep_test[0]) { + _tech.kill(true, false); + _techs_lost++; + _cleanup[_tech.company] = true; + } else { + star.p_player[planet] += _tech.get_unit_size(); + _tech.location_string = star.name; + + _tech.planet_location = planet; + + _tech.ship_location = -1; + + _tech.job = "none"; + techs_alive += 1; + + _tech.add_experience(irandom_range(3, 18)); + var gain = irandom(2); + + _tech.technology += gain; + _tech_point_gain += gain; + if (_tech_roll < 10 && _tech_roll > 0) { + _found_requisition += irandom_range(5, 40); + } + } + if ((_tech_roll >= 10) && (_tech_roll < 15)) { + _found_requisition += 100; + } + if ((_tech_roll >= 15) && (_tech_roll < 25)) { + var last_artifact = scr_add_artifact("random", "", 4); + _found_artifact += 1; + } + if (_tech_roll >= 25) { + scr_add_stc_fragment(); // STC here + _found_stc += 1; + } + } + + obj_controller.requisition += _found_requisition; + if ((techs_alive + _techs_lost >= 2) && (techs_alive > 0)) { + if (_roll1 >= (40 + (techs_alive + _techs_lost) * 5)) { + scr_add_stc_fragment(); // STC here + _found_stc += 1; + } + } + + var _tixt = $"The journey into the Mars Catacombs was a success. Your {techs_alive} remaining {obj_ini.player_role_data[eROLE.TECHMARINE].role}s were useful to the Mechanicus force and return with a bounty. They await retrieval at {star.name} {scr_roman(planet)}.\n"; + _tixt += $"\n{_found_requisition} Requisition from salvage"; + if (_found_artifact > 0) { + _tixt += $"\n{string_plural("Unidentified Artifacts", _found_artifact)} recovered"; + } + if (_found_stc > 0) { + _tixt += $"\n{string_plural("STC Fragment", _found_stc)} recovered"; + } + + if (_tech_point_gain) { + _tixt += $"\n{string_plural("Tech Point", _tech_point_gain)} recovered"; + } + + scr_popup("Mechanicus Mission Completed", _tixt, "mechanicus", ""); + _tixt = "Mechanicus Mission Completed: {techs_alive}/{techs_alive+_techs_lost} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s return with "; + _tixt += string(_found_requisition) + " Requisition, "; + if (_found_artifact > 0) { + _tixt += $"\n{_found_artifact} : {string_plural("Unidentified Artifacts", _found_artifact)} recovered"; + } + if (_found_stc > 0) { + _tixt += $"\n{_found_stc} : {string_plural("STC Fragment", _found_stc)} recovered"; + } + if (_tech_point_gain) { + _tixt += $"\n{_tech_point_gain} {string_plural("Tech Point", _tech_point_gain)} gained"; + } + scr_event_log("green", _tixt); + + sort_all_companies_to_map(_cleanup); + + delete_mission = true; +} + } diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index a0450b5a40..b1d5d88fed 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1209,13 +1209,10 @@ static __mech_mars_resolve = function() { capital_number = 1; image_index = 0; image_speed = 0; - trade_goods = "mars_spelunk1"; home_x = x; home_y = y; - action_x = x + lengthdir_x(3000, obj_controller.terra_direction); - action_y = y + lengthdir_y(3000, obj_controller.terra_direction); - set_fleet_movement(false, "move", 48, 48); } + flit.add_problem("mech_mars"); } } @@ -1819,7 +1816,7 @@ static __inquisition_demon_world_init = function(){ } static __inquisition_demon_world_accept = function(){ - scr_event_log("", $"Inquisition Mission Accepted: The demon world of {system.name} {scr_roman(planet)} will be purged by your hand.", system.name); + scr_event_log("", $"Inquisition Mission Accepted: The demon world of {p_data.name()} will be purged by your hand.", system.name); new_star_event_marker("green"); with(obj_popup){ popup_default_close(); @@ -1842,8 +1839,6 @@ static __inquisition_tyranid_org_init = function(){ static __inquisition_tyranid_org_accept = function(){ obj_popup.image = "webber"; obj_popup.title = "New Equipment"; - obj_popup.fancy_title = 0; - obj_popup.text_center = 0; obj_popup.text = $"{global.chapter_name} have been provided with 4x Astartes Webbers in order to complete the mission."; reset_popup_options(); scr_add_item("Webber", 4); diff --git a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml index 5a8b976e0f..a1f03b74b8 100644 --- a/scripts/PlayerFleetProblem/PlayerFleetProblem.gml +++ b/scripts/PlayerFleetProblem/PlayerFleetProblem.gml @@ -273,10 +273,10 @@ static __great_crusade_results = function(){ if (_type == "normal") { tixt += "The combat was as could be expected- "; } - if (_type == "hard") { + else if (_type == "hard") { tixt += "The combat was fairly gruelling- "; } - if (_type == "brutal") { + else if (_type == "brutal") { tixt += "The combat was absolutely brutal- your marines were the first into the fray, and as a result "; } diff --git a/scripts/scr_fleet_functions/scr_fleet_functions.gml b/scripts/scr_fleet_functions/scr_fleet_functions.gml index 24b5950905..89b898cc51 100644 --- a/scripts/scr_fleet_functions/scr_fleet_functions.gml +++ b/scripts/scr_fleet_functions/scr_fleet_functions.gml @@ -691,21 +691,6 @@ function fleet_arrival_logic() { for (var i=0; i 0) { cancel = true; } - if (string_count("spelunk", trade_goods) > 0) { - cancel = true; - } if (fleet_has_cargo("warband")) { cancel = true; } diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml index 93fed9e8ef..e69de29bb2 100644 --- a/scripts/scr_mission_reward/scr_mission_reward.gml +++ b/scripts/scr_mission_reward/scr_mission_reward.gml @@ -1,103 +0,0 @@ -function scr_mission_reward(mission, star, planet) { - // mission: mission designation - // star: target star system - // planet: planet number - - // "mech_bionics",id,i - // "mech_raider",id,i - - var cleanup = array_create(11, 0); - - if (mission == "mars_spelunk") { - var roll1 = roll_dice_chapter(1, 100, "high"); // For the first STC - var found_stc = 0, found_artifact = 0, found_requisition = 0; - var techs_lost = 0, techs_alive = 0; - - var _conditions = { - job: "mecanicus mission", - }; - var _techs = collect_role_group(SPECIALISTS_TECHS, star.name, false, _conditions); - - var _tech_point_gain = 0; - - for (var i = 0; i < array_length(_techs); i++) { - var _tech = _techs[i]; - var _tech_roll = global.character_tester.standard_test(_tech, "technology", -10)[1]; - var _wep_test = global.character_tester.standard_test(_tech, "weapon_skill", 10); - if (!_wep_test[0]) { - _tech.kill(true, false); - techs_lost++; - cleanup[_tech.company] = true; - } else { - star.p_player[planet] += _tech.get_unit_size(); - _tech.location_string = star.name; - - _tech.planet_location = planet; - - _tech.ship_location = -1; - - _tech.job = "none"; - techs_alive += 1; - - _tech.add_experience(irandom_range(3, 18)); - var gain = irandom(2); - - _tech.technology += gain; - _tech_point_gain += gain; - if (_tech_roll < 10 && _tech_roll > 0) { - found_requisition += irandom_range(5, 40); - } - } - if ((_tech_roll >= 10) && (_tech_roll < 15)) { - found_requisition += 100; - } - if ((_tech_roll >= 15) && (_tech_roll < 25)) { - var last_artifact = scr_add_artifact("random", "", 4); - found_artifact += 1; - } - if (_tech_roll >= 25) { - scr_add_stc_fragment(); // STC here - found_stc += 1; - } - } - - obj_controller.requisition += found_requisition; - if ((techs_alive + techs_lost >= 2) && (techs_alive > 0)) { - if (roll1 >= (40 + (techs_alive + techs_lost) * 5)) { - scr_add_stc_fragment(); // STC here - found_stc += 1; - } - } - - var tixt = $"The journey into the Mars Catacombs was a success. Your {techs_alive} remaining {obj_ini.player_role_data[eROLE.TECHMARINE].role}s were useful to the Mechanicus force and return with a bounty. They await retrieval at {star.name} {scr_roman(planet)}.\n"; - tixt += $"\n{found_requisition} Requisition from salvage"; - if (found_artifact > 0) { - tixt += $"\n{string_plural("Unidentified Artifacts", found_artifact)} recovered"; - } - if (found_stc > 0) { - tixt += $"\n{string_plural("STC Fragment", found_stc)} recovered"; - } - - if (_tech_point_gain) { - tixt += $"\n{string_plural("Tech Point", _tech_point_gain)} recovered"; - } - - scr_popup("Mechanicus Mission Completed", tixt, "mechanicus", ""); - tixt = "Mechanicus Mission Completed: {techs_alive}/{techs_alive+techs_lost} of your {obj_ini.player_role_data[eROLE.TECHMARINE].role}s return with "; - tixt += string(found_requisition) + " Requisition, "; - if (found_artifact > 0) { - tixt += $"\n{found_artifact} : {string_plural("Unidentified Artifacts", found_artifact)} recovered"; - } - if (found_stc > 0) { - tixt += $"\n{found_stc} : {string_plural("STC Fragment", found_stc)} recovered"; - } - if (_tech_point_gain) { - tixt += $"\n{_tech_point_gain} {string_plural("Tech Point", _tech_point_gain)} gained"; - } - scr_event_log("green", tixt); - - sort_all_companies_to_map(cleanup); - } - - cleanup = array_create(11, 0); -} From 5476c96c74cb26163b678b528841ea20b0b4a1ea Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 23:27:50 +0100 Subject: [PATCH 116/118] compile error --- scripts/AiFleetProblem/AiFleetProblem.gml | 2 +- scripts/PlanetProblem/PlanetProblem.gml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/AiFleetProblem/AiFleetProblem.gml b/scripts/AiFleetProblem/AiFleetProblem.gml index d95a913fda..3b530f687b 100644 --- a/scripts/AiFleetProblem/AiFleetProblem.gml +++ b/scripts/AiFleetProblem/AiFleetProblem.gml @@ -298,7 +298,7 @@ static __mech_mars_init = fuction(){ stage_id = "to_mars"; } -static __mech_mars_on_arrival(){ +static __mech_mars_on_arrival = function(){ if (stage_id == "to_mars"){ fleet.action_x = home_x; fleet.action_y = home_y; diff --git a/scripts/PlanetProblem/PlanetProblem.gml b/scripts/PlanetProblem/PlanetProblem.gml index b1d5d88fed..b453ca0328 100644 --- a/scripts/PlanetProblem/PlanetProblem.gml +++ b/scripts/PlanetProblem/PlanetProblem.gml @@ -1364,7 +1364,7 @@ static __protect_raiders_suppress_information= function() { } } -static __protect_raiders_hold_memorial() { +static __protect_raiders_hold_memorial = function() { reset_popup_options(); __add_option("continue"); _pdata.add_disposition(-30); From 203d8bd20b76fdf8e43a7f86eb210d16cb2c4ffe Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 23:28:30 +0100 Subject: [PATCH 117/118] delete redundant mission_reward script --- ChapterMaster.yyp | 1 - scripts/scr_mission_reward/scr_mission_reward.gml | 0 scripts/scr_mission_reward/scr_mission_reward.yy | 13 ------------- 3 files changed, 14 deletions(-) delete mode 100644 scripts/scr_mission_reward/scr_mission_reward.gml delete mode 100644 scripts/scr_mission_reward/scr_mission_reward.yy diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index da61f07222..a0cf149ded 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -903,7 +903,6 @@ {"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",},}, - {"id":{"name":"scr_mission_reward","path":"scripts/scr_mission_reward/scr_mission_reward.yy",},}, {"id":{"name":"scr_necron_tombs","path":"scripts/scr_necron_tombs/scr_necron_tombs.yy",},}, {"id":{"name":"scr_ork_fleet_functions","path":"scripts/scr_ork_fleet_functions/scr_ork_fleet_functions.yy",},}, {"id":{"name":"scr_ork_planet_functions","path":"scripts/scr_ork_planet_functions/scr_ork_planet_functions.yy",},}, diff --git a/scripts/scr_mission_reward/scr_mission_reward.gml b/scripts/scr_mission_reward/scr_mission_reward.gml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scripts/scr_mission_reward/scr_mission_reward.yy b/scripts/scr_mission_reward/scr_mission_reward.yy deleted file mode 100644 index 530089629a..0000000000 --- a/scripts/scr_mission_reward/scr_mission_reward.yy +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$GMScript":"v1", - "%Name":"scr_mission_reward", - "isCompatibility":false, - "isDnD":false, - "name":"scr_mission_reward", - "parent":{ - "name":"Turn", - "path":"folders/Scripts/Turn.yy", - }, - "resourceType":"GMScript", - "resourceVersion":"2.0", -} \ No newline at end of file From 811cd0a8301d8559d245f16c04e3d74abec987b9 Mon Sep 17 00:00:00 2001 From: Nelsonh Date: Fri, 2 Oct 2026 23:32:21 +0100 Subject: [PATCH 118/118] legacy popup options --- scripts/scr_cheatcode/scr_cheatcode.gml | 2 +- .../scr_popup_functions/scr_popup_functions.gml | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/scripts/scr_cheatcode/scr_cheatcode.gml b/scripts/scr_cheatcode/scr_cheatcode.gml index da5046ac99..b7f52bdc88 100644 --- a/scripts/scr_cheatcode/scr_cheatcode.gml +++ b/scripts/scr_cheatcode/scr_cheatcode.gml @@ -746,7 +746,7 @@ function system_debug_remove_fleet() { } array_push(_opts, {"str1": "exit", choice_func: popup_default_close}); - replace_options(_opts, false, false); + replace_options(_opts, false); text = "Which fleet would you like to delete?"; } diff --git a/scripts/scr_popup_functions/scr_popup_functions.gml b/scripts/scr_popup_functions/scr_popup_functions.gml index 85081032a7..db69a8b473 100644 --- a/scripts/scr_popup_functions/scr_popup_functions.gml +++ b/scripts/scr_popup_functions/scr_popup_functions.gml @@ -171,7 +171,7 @@ function PopupOption(data) constructor { } /// @self Asset.GMObject.obj_popup -function add_option(option, if_empty = false, use_default_option = true) { +function add_option(option, if_empty = false) { if (if_empty) { if (array_length(options)) { return; @@ -184,21 +184,17 @@ function add_option(option, if_empty = false, use_default_option = true) { } if (is_array(option)) { for (var i = 0; i < array_length(option); i++) { - add_option(option[i], false, use_default_option); + add_option(option[i], false); } } else if (array_length(options) < 10) { - if (use_default_option) { - array_push(options, new PopupOption(option)); - } else { - array_push(options, option); - } + array_push(options, new PopupOption(option)); } } /// @self Asset.GMObject.obj_popup -function replace_options(option, if_empty = false, use_default_option = true) { +function replace_options(option, if_empty = false) { options = []; - add_option(option, if_empty, use_default_option); + add_option(option, if_empty); } function evaluate_popup_option(opt) {