diff --git a/ChapterMaster.yyp b/ChapterMaster.yyp index adc4282c28..f47c00b7fd 100644 --- a/ChapterMaster.yyp +++ b/ChapterMaster.yyp @@ -746,6 +746,7 @@ {"id":{"name":"scr_arti_descr","path":"scripts/scr_arti_descr/scr_arti_descr.yy",},}, {"id":{"name":"scr_audience","path":"scripts/scr_audience/scr_audience.yy",},}, {"id":{"name":"scr_battle_allies","path":"scripts/scr_battle_allies/scr_battle_allies.yy",},}, + {"id":{"name":"scr_battle_count","path":"scripts/scr_battle_count/scr_battle_count.yy",},}, {"id":{"name":"scr_battle_roster","path":"scripts/scr_battle_roster/scr_battle_roster.yy",},}, {"id":{"name":"scr_battle_sort","path":"scripts/scr_battle_sort/scr_battle_sort.yy",},}, {"id":{"name":"scr_bionics_count","path":"scripts/scr_bionics_count/scr_bionics_count.yy",},}, diff --git a/objects/obj_controller/Create_0.gml b/objects/obj_controller/Create_0.gml index 8a584e6472..fee6a2c55c 100644 --- a/objects/obj_controller/Create_0.gml +++ b/objects/obj_controller/Create_0.gml @@ -181,6 +181,7 @@ obj_controller.restart_strength=0; obj_controller.restart_cooperation=0; obj_controller.restart_purity=0; obj_controller.restart_stability=0; +obj_controller.enemies_cleared_count = 0; // ** Sets default equipement for roles ** // 100 is defaults, 101 is the allowable starting equipment diff --git a/objects/obj_ncombat/Alarm_5.gml b/objects/obj_ncombat/Alarm_5.gml index 0674c4cb17..6c12693398 100644 --- a/objects/obj_ncombat/Alarm_5.gml +++ b/objects/obj_ncombat/Alarm_5.gml @@ -490,6 +490,8 @@ if (defeat=0) and (reduce_power=true){ p_owner[battle_planet] = eFACTION.Imperium } dispo[battle_planet] += 10; + obj_controller.enemies_cleared_count += 1; + scr_battle_count(); scr_event_log("", $"{who_cleansed} cleansed from {planet_string}", name); scr_alert("green", "owner", $"{who_cleansed} cleansed from {planet_string}. Control returned to {who_return}", x, y); if (dispo[battle_planet] >= 101) then p_owner[battle_planet] = 1; diff --git a/scripts/scr_battle_count/scr_battle_count.gml b/scripts/scr_battle_count/scr_battle_count.gml new file mode 100644 index 0000000000..e93951c274 --- /dev/null +++ b/scripts/scr_battle_count/scr_battle_count.gml @@ -0,0 +1,41 @@ +function scr_battle_count(){ + + // Check if the count is positive and a multiple of 10 + if (obj_controller.enemies_cleared_count > 0 && (obj_controller.enemies_cleared_count % 10 == 0)) { + + // --- ACTION TO PERFORM EVERY 10 CLEARS --- + + // --- Randomly Choose Flavor Text --- + var _text_array = [ + { + alert : "Word of your Chapter's tireless defence of the Sector reaches influential ears within the Imperium.", + log : "Imperial Factions note the Chapter's continued effectiveness in purging threats." + }, + { + alert : "The efficiency of your recent purges has not gone unnoticed. Certain Imperial factions mark your Chapter's progress.", + log : "Imperial elements acknowledge the Chapter's effectiveness against sector threats." + }, + { + alert : "Data-slate communiques confirm receipt of your operational summaries. Standard commendations issued.", + log : "Administratum logs successful anti-xenos/heretic operations by the Chapter." + }, + { + alert : "Your Chapter's righteous fury against the enemies of Man strengthens the faith of nearby Imperial worlds.", + log : "Tales of the Chapter's victories inspire piety and bolster relations with the faithful." + }, + { + alert : "Your Chapter continues its duties effectively.", + log : "Chapter effectiveness noted by Imperial factions." + } + ] + var _text_choice = array_random_element(_text_array); + + scr_alert(c_blue, $"{_text_choice.alert}"); + scr_event_log(c_blue, $"{_text_choice.log}"); + + // --- Apply bonuses + obj_controller.loyalty+=5; + obj_controller.loyalty_hidden+=5; + // --- END ACTION TO PERFORM --- + } +} diff --git a/scripts/scr_battle_count/scr_battle_count.yy b/scripts/scr_battle_count/scr_battle_count.yy new file mode 100644 index 0000000000..2e8cde2771 --- /dev/null +++ b/scripts/scr_battle_count/scr_battle_count.yy @@ -0,0 +1,13 @@ +{ + "$GMScript":"v1", + "%Name":"scr_battle_count", + "isCompatibility":false, + "isDnD":false, + "name":"scr_battle_count", + "parent":{ + "name":"Helpers", + "path":"folders/Scripts/Helpers.yy", + }, + "resourceType":"GMScript", + "resourceVersion":"2.0", +} \ No newline at end of file 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 a25e88a361..b96ad78831 100644 --- a/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml +++ b/scripts/scr_enemy_ai_a/scr_enemy_ai_a.gml @@ -816,58 +816,126 @@ function scr_enemy_ai_a() { // 135; - var planet_saved = ((p_player[_run] + p_raided[_run]) > 0 && p_orks[_run] = 0 && p_tyranids[_run] < 4 && p_chaos[_run] = 0 && p_traitors[_run] = 0 && p_necrons[_run] = 0 && p_tau[_run] = 0); - - if (planet_saved){ - var who_cleansed=""; - var who_return=""; - var make_alert = false; - var planet_string = $"{name} {scr_roman(_run)}"; - if (p_owner[_run] = 7) { - who_cleansed="Orks" - make_alert=true; - }else if (p_owner[_run] = 8 && p_pdf[_run] = 0) { - who_cleansed="Tau" - make_alert=true; - }else if (p_owner[_run] = 13) { - who_cleansed="Necrons" - make_alert=true; - }else if (p_owner[_run] = 10) { - who_cleansed="Chaos" - make_alert=true; - } else if (planet_feature_bool(p_feature[_run], P_features.Gene_Stealer_Cult) && p_tyranids[_run] <= 0){ - who_cleansed="Gene Stealer Cult" - make_alert=true; - delete_features(p_feature[_run], P_features.Gene_Stealer_Cult); - adjust_influence(eFACTION.Tyranids, -25, _run); - } - if (make_alert){ - if (p_first[_run] = 1){ - p_owner[_run] = eFACTION.Player; - who_return = "your"; - } else if (p_first[_run] = 3 || p_type[_run]=="Forge"){ - who_return="mechanicus"; - obj_controller.disposition[3] += 10; - p_owner[_run] = eFACTION.Mechanicus - }else if (p_type[_run]!="Dead"){ - who_return="the governor"; - if (who_cleansed=="tau"){ - who_return="a more suitable governer" - } - p_owner[_run] = eFACTION.Imperium; - } - dispo[_run] += 10; - scr_event_log("", $"{who_cleansed} cleansed from {planet_string}", name); - scr_alert("green", "owner", $"{who_cleansed} cleansed from {planet_string}. Control returned to {who_return}", x, y); - if (dispo[_run] >= 101) then p_owner[_run] = 1; - } - - } - - if (p_raided[_run] > 0) then p_raided[_run] = 0; - delete _planet_data; - } // end repeat here + // Determine if the planet qualifies as "saved" this turn. + // Conditions: Player forces must be present (or raided flag is set), AND + // all major non-Imperial ground threats (Orks, significant Tyranids, Chaos forces, Necrons, Tau) are eliminated. + var planet_saved = ( + (p_player[_run] + p_raided[_run]) > 0 && // Player involved or planet was raided + p_orks[_run] == 0 && // No Orks + p_tyranids[_run] < 4 && // Tyranids below significant infestation level + p_chaos[_run] == 0 && // No Chaos Space Marines / Daemons + p_traitors[_run] == 0 && // No Heretics / Traitors + p_necrons[_run] == 0 && // No Necrons + p_tau[_run] == 0 // No Tau ground forces + ); + + // --- Apply Effects if Planet Was Saved --- + if (planet_saved) { + // --- Initialize variables for this saved planet --- + var who_cleansed = ""; // String: Describes the primary enemy cleansed + var who_return = ""; // String: Describes who regains control of the planet + var make_alert = false; // Boolean: Flag to trigger alerts and apply bonuses + var original_owner_before_cleanse = p_owner[_run]; // Store owner ID before potential changes + var planet_string = $"{name} {scr_roman(_run)}"; // Formatted planet name (e.g., "SystemName II") + + // --- Determine which enemy faction was primarily defeated --- + // This logic primarily uses the owner just before cleansing as the indicator. + if (original_owner_before_cleanse == eFACTION.Ork) { + who_cleansed = "Orks"; + make_alert = true; + } else if (original_owner_before_cleanse == eFACTION.Tau && p_pdf[_run] == 0) { // Special case: Tau considered cleansed only if their PDF is also gone? + who_cleansed = "Tau"; + make_alert = true; + } else if (original_owner_before_cleanse == eFACTION.Necrons) { + who_cleansed = "Necrons"; + make_alert = true; + } else if (original_owner_before_cleanse == eFACTION.Chaos) { + who_cleansed = "Chaos"; // Includes CSM, Daemons, possibly Traitors if owner flipped + make_alert = true; + // Check Tyranids/GSC based on previous owner OR if GSC feature was present and Nids are now low + } else if (original_owner_before_cleanse == eFACTION.Tyranids || (planet_feature_bool(p_feature[_run], P_features.Gene_Stealer_Cult) && p_tyranids[_run] <= 0)) { + who_cleansed = "Tyranid"; // Generic term initially + + // Check specifically if a Genestealer Cult feature was present + if (planet_feature_bool(p_feature[_run], P_features.Gene_Stealer_Cult)) { + who_cleansed = "Genestealer Cult"; // More specific name + delete_features(p_feature[_run], P_features.Gene_Stealer_Cult); // Remove the cult feature + adjust_influence(eFACTION.Tyranids, -25, _run, self); // Reduce residual Tyranid influence (pass 'self' for star context) + } + make_alert = true; // Trigger alert for Tyranids or GSC + } + + // --- Apply effects ONLY if an enemy was confirmed cleansed --- + if (make_alert) { + + // --- Determine who gets control back based on original owner (p_first) --- + if (p_first[_run] == eFACTION.Player) { // If originally Player owned + p_owner[_run] = eFACTION.Player; + who_return = "your Chapter"; + } else if (p_first[_run] == eFACTION.Mechanicus || p_type[_run] == "Forge") { // If originally Mechanicus or a Forge World + who_return = "the Adeptus Mechanicus"; + obj_controller.disposition[eFACTION.Mechanicus] += 5; // FACTION disposition bonus + p_owner[_run] = eFACTION.Mechanicus; + } else if (p_type[_run] != "Dead") { // If originally Imperial or other non-specific (and not dead) + who_return = "the planetary governor"; // Default return description + if (who_cleansed == "Tau") { who_return = "a loyal governor"; } // Special description for Tau cleanse + + // Check if Sisters should get control or bonus + var _is_shrine_or_cathedral = (p_type[_run] == "Shrine" || planet_feature_bool(p_feature[_run], P_features.Sororitas_Cathedral)); + if (p_first[_run] == eFACTION.Ecclesiarchy || _is_shrine_or_cathedral) { + // If originally Ecclesiarchy, give them control back + if (p_first[_run] == eFACTION.Ecclesiarchy) { + p_owner[_run] = eFACTION.Ecclesiarchy; + who_return = "the Ecclesiarchy"; + } + // Always give faction bonus if it was their original world OR a holy site + obj_controller.disposition[eFACTION.Ecclesiarchy] += 5; // FACTION disposition bonus + } else { // If not originally Ecclesiarchy and not a holy site, defaults to Imperium + p_owner[_run] = eFACTION.Imperium; + } + } else { // If it's a dead world reverting + // If original owner wasn't Player/Mech/Eccl, default ownership to Imperium + if (p_first[_run] != eFACTION.Player && p_first[_run] != eFACTION.Mechanicus && p_first[_run] != eFACTION.Ecclesiarchy) { + p_owner[_run] = eFACTION.Imperium; + who_return = "Imperial Administration"; // Generic term for dead world + } + // Otherwise, it implies Player/Mech/Eccl originally owned the dead world, + // so the p_owner should have been set correctly by the p_first check earlier. + } + + // --- Apply Generic Bonuses/Alerts if control returned meaningfully --- + if (who_return != "") { + + // 1. Increase LOCAL governor disposition (capped) + dispo[_run] = clamp(dispo[_run] + 10, -90, 100); + + // 2. Increment GLOBAL counter for enemies cleared + obj_controller.enemies_cleared_count += 1; + + // 3. calls the function that handles the every-4-clears bonus + scr_battle_count(); + + // 4. Log the cleanse event + scr_event_log("green", $"{who_cleansed} cleansed from {planet_string}", name); + + // 5. Create a screen alert message + scr_alert("green", "owner", $"{who_cleansed} cleansed from {planet_string}. Control returned to {who_return}.", x, y); + + // 6. Check if high local disposition flips the planet to player control + if (dispo[_run] >= 100 && p_owner[_run] != eFACTION.Player && p_type[_run] != "Dead") { + p_owner[_run] = eFACTION.Player; + scr_alert(c_blue, "owner", $"The populace of {planet_string} pledges allegiance to your Chapter!", x, y); + } + } // End if (who_return != "") + } // End if (make_alert) + } // End if (planet_saved) + + // Reset raided flag if it was set for this planet + if (p_raided[_run] > 0) { p_raided[_run] = 0; } + // IMPORTANT: Delete the PlanetData struct if it was used in this loop iteration + delete _planet_data; // Return allocated memory to the Omnissiah + } // end repeat here // quene player battles here diff --git a/scripts/scr_load_controller/scr_load_controller.gml b/scripts/scr_load_controller/scr_load_controller.gml index 9f87a65514..8d2157432b 100644 --- a/scripts/scr_load_controller/scr_load_controller.gml +++ b/scripts/scr_load_controller/scr_load_controller.gml @@ -486,6 +486,7 @@ function scr_load_controller(save_id){ obj_ini.progenitor_disposition=ini_read_real("Controller","progenitor_disposition",0); obj_ini.imperium_disposition=ini_read_real("Controller","imperium_disposition",0); obj_controller.astartes_disposition=ini_read_real("Controller","astartes_disposition",0); + obj_controller.enemies_cleared_count = ini_read_real("Controller", "enemies_cleared_count", 0); obj_controller.bat_devastator_column=ini_read_real("Controller","bat_devastator_column",1); obj_controller.bat_assault_column=ini_read_real("Controller","bat_assault_column",4); diff --git a/scripts/scr_save_controller/scr_save_controller.gml b/scripts/scr_save_controller/scr_save_controller.gml index 961e42aaf8..5ebfe49cc3 100644 --- a/scripts/scr_save_controller/scr_save_controller.gml +++ b/scripts/scr_save_controller/scr_save_controller.gml @@ -11,6 +11,7 @@ function scr_save_controller(save_id){ ini_write_string("Save","version",global.game_version); ini_write_real("Save","play_time",play_time); ini_write_real("Save","game_seed",global.game_seed); + ini_write_real("Save","use_custom_icon",obj_ini.use_custom_icon); // obj_controller variables here ini_write_real("boolean", "cheat_req", global.cheat_req); @@ -173,6 +174,7 @@ function scr_save_controller(save_id){ ini_write_real("Controller","trial",obj_controller.recruit_trial); ini_write_real("Controller","recruits",obj_controller.recruits); ini_write_real("Controller","recruit_last",obj_controller.recruit_last); + ini_write_real("Controller", "enemies_cleared_count", obj_controller.enemies_cleared_count); // var g=-1; repeat(30){g+=1;