From a915eb527a39eca978f2f5d759a4913d2ae7063b Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:16:48 +0300 Subject: [PATCH 01/16] fix: Necron melee weapons; logging flood --- objects/obj_enunit/Alarm_1.gml | 10 +++++----- scripts/scr_en_weapon/scr_en_weapon.gml | 13 +++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/objects/obj_enunit/Alarm_1.gml b/objects/obj_enunit/Alarm_1.gml index 0eddccc0d7..5234565425 100644 --- a/objects/obj_enunit/Alarm_1.gml +++ b/objects/obj_enunit/Alarm_1.gml @@ -1685,7 +1685,7 @@ if (__b__) { } if (dudes[j] == "Flayed One") { - scr_en_weapon("Melee5", true, dudes_num[j], dudes[j], j); + scr_en_weapon("Melee Weapon", true, dudes_num[j], dudes[j], j); dudes_ac[j] = 10; dudes_hp[j] = 75; dudes_dr[j] = 0.9; @@ -1693,7 +1693,7 @@ if (__b__) { } if (dudes[j] == "Necron Warrior") { scr_en_weapon("Gauss Flayer", true, dudes_num[j], dudes[j], j); - scr_en_weapon("Melee3", true, dudes_num[j], dudes[j], j); + scr_en_weapon("Melee Weapon", true, dudes_num[j], dudes[j], j); dudes_ac[j] = 10; dudes_hp[j] = 75; dudes_dr[j] = 0.9; @@ -1701,7 +1701,7 @@ if (__b__) { } if (dudes[j] == "Necron Immortal") { scr_en_weapon("Gauss Blaster", true, dudes_num[j], dudes[j], j); - scr_en_weapon("Melee3", true, dudes_num[j], dudes[j], j); + scr_en_weapon("Melee Weapon", true, dudes_num[j], dudes[j], j); dudes_ac[j] = 15; dudes_hp[j] = 90; dudes_dr[j] = 0.85; @@ -1719,7 +1719,7 @@ if (__b__) { } if (dudes[j] == "Necron Destroyer") { scr_en_weapon("Gauss Cannon", true, dudes_num[j], dudes[j], j); - scr_en_weapon("Melee3", true, dudes_num[j], dudes[j], j); + scr_en_weapon("Melee Weapon", true, dudes_num[j], dudes[j], j); dudes_ac[j] = 25; dudes_hp[j] = 250; dudes_dr[j] = 0.75; @@ -1749,7 +1749,7 @@ if (__b__) { dudes_vehicle[j] = 1; } if (dudes[j] == "Canoptek Scarab") { - scr_en_weapon("Melee3", false, dudes_num[j] * 2, dudes[j], j); + scr_en_weapon("Melee Weapon", false, dudes_num[j] * 2, dudes[j], j); dudes_ac[j] = 5; dudes_hp[j] = 30; dudes_dr[j] = 0.75; diff --git a/scripts/scr_en_weapon/scr_en_weapon.gml b/scripts/scr_en_weapon/scr_en_weapon.gml index 19f1bfd61f..ca78237877 100644 --- a/scripts/scr_en_weapon/scr_en_weapon.gml +++ b/scripts/scr_en_weapon/scr_en_weapon.gml @@ -146,7 +146,6 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { spli = 3; break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } @@ -381,7 +380,6 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { spli = 3; break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } @@ -486,7 +484,6 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { spli = 3; break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } @@ -560,7 +557,6 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { rang = 20; break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } @@ -671,12 +667,11 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { amm = 1; break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } - if (obj_ncombat.enemy >= 10 || obj_ncombat.enemy == 2 || obj_ncombat.enemy == 5 || obj_ncombat.enemy == 1) { + if (obj_ncombat.enemy == eFACTION.CHAOS || obj_ncombat.enemy == eFACTION.HERETICS || obj_ncombat.enemy == eFACTION.IMPERIUM || obj_ncombat.enemy == eFACTION.ECCLESIARCHY || obj_ncombat.enemy == eFACTION.PLAYER) { switch (name) { case "Plasma Pistol": atta = 70; @@ -968,7 +963,6 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { spli = choose(0, 1); break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } @@ -1061,7 +1055,6 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { spli = 3; break; default: - LOGGER.debug($"Unknown weapon name: {name}; script: scr_en_weapon.gml"); break; } } @@ -1092,6 +1085,10 @@ function scr_en_weapon(name, is_man, man_number, man_type, group) { amm = -1; } + if (atta == 0) { + LOGGER.debug($"Weapon {name} has 0 attack!"); + } + var goody = 0; var first = -1; for (var b = 0; b < 30; b++) { From bfa01be488a7be1838cd159d9c8bf646e3322476 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 20:17:54 +0300 Subject: [PATCH 02/16] fix: Necron tomb mission crash; proper error logging --- .../scr_inquisition_mission/scr_inquisition_mission.gml | 1 + .../scr_system_search_helpers.gml | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml index 7bdfa4155b..bfcfa850bd 100644 --- a/scripts/scr_inquisition_mission/scr_inquisition_mission.gml +++ b/scripts/scr_inquisition_mission/scr_inquisition_mission.gml @@ -811,6 +811,7 @@ function necron_tomb_mission_sequence() { instance_deactivate_all(true); instance_activate_object(obj_controller); instance_activate_object(obj_ini); + instance_activate_object(obj_star); instance_create(0, 0, obj_ncombat); _roster = new Roster(); diff --git a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml index b88d99852b..fc93e3c7db 100644 --- a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml +++ b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml @@ -216,11 +216,18 @@ function planet_imperium_ground_total(planet_check) { /// Returns the `obj_star` instance that matches `search_name`, /// or the string `"none"` if no matching star is found. function star_by_name(search_name) { + if (!instance_exists(obj_star)) { + LOGGER.error("Not a single instance of obj_star exists!"); + return; + } + with (obj_star) { if (name == search_name) { return self; } } + + LOGGER.error($"Star {search_name} wasn't found!") return "none"; } From b75a63b9c02bd6515879032de5e73b7321331216 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:20:28 +0300 Subject: [PATCH 03/16] refactor: Different error handling for search helper --- scripts/scr_logging_functions/scr_logging_functions.gml | 4 ++-- .../scr_system_search_helpers.gml | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/scr_logging_functions/scr_logging_functions.gml b/scripts/scr_logging_functions/scr_logging_functions.gml index ace8a2a03f..d3f8d70ab9 100644 --- a/scripts/scr_logging_functions/scr_logging_functions.gml +++ b/scripts/scr_logging_functions/scr_logging_functions.gml @@ -152,8 +152,8 @@ function try_and_report_loop(dev_marker = "Generic Error", func, turn_end = true /// @description Shows a popup for errors triggered by an unexpected condition(s). /// @param {string} _message - The message to display to the user. -/// @param {string} _header - Optional header for the popup (default: "Assertion Error"). -function assert_error_popup(_message, _header = "Assertion Error") { +/// @param {string} _header - Optional header for the popup (default: "Your game just encountered an error!"). +function assert_error_popup(_message, _header = "Your game just encountered an error!") { var _stacktrace_array = debug_get_callstack(); array_shift(_stacktrace_array); // throw away the first line, it's this function diff --git a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml index fc93e3c7db..c40a2fb052 100644 --- a/scripts/scr_system_search_helpers/scr_system_search_helpers.gml +++ b/scripts/scr_system_search_helpers/scr_system_search_helpers.gml @@ -217,8 +217,8 @@ function planet_imperium_ground_total(planet_check) { /// or the string `"none"` if no matching star is found. function star_by_name(search_name) { if (!instance_exists(obj_star)) { - LOGGER.error("Not a single instance of obj_star exists!"); - return; + assert_error_popup("Not a single instance of obj_star exists!"); + return "none"; } with (obj_star) { @@ -227,7 +227,8 @@ function star_by_name(search_name) { } } - LOGGER.error($"Star {search_name} wasn't found!") + assert_error_popup($"Star {search_name} wasn't found!"); + return "none"; } From c9c433981c1c971f2968e0738863daf77c155b5a Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:08:52 +0300 Subject: [PATCH 04/16] refactor: Handle error stuff a bit --- .../scr_logging_functions.gml | 168 ++++++++++-------- 1 file changed, 89 insertions(+), 79 deletions(-) diff --git a/scripts/scr_logging_functions/scr_logging_functions.gml b/scripts/scr_logging_functions/scr_logging_functions.gml index d3f8d70ab9..8fd07ed7fd 100644 --- a/scripts/scr_logging_functions/scr_logging_functions.gml +++ b/scripts/scr_logging_functions/scr_logging_functions.gml @@ -1,8 +1,9 @@ #macro STR_ERROR_MESSAGE_HEAD $"Your game just encountered and caught an error!" #macro STR_ERROR_MESSAGE_HEAD2 $"Your game just encountered a critical error! :(" #macro STR_ERROR_MESSAGE_HEAD3 "Your game just encountered and caught an error! ({0})" -#macro STR_ERROR_MESSAGE $"The error log is automatically copied into your clipboard and a copy is created at: \nC:>Users>(UserName)>AppData>Local>ChapterMaster>Logs\n\nPlease, follow these steps:\n1) Create a bug report on our 'Chapter Master Discord' server.\n2) Press CTRL+V to paste the error log.\n3) Title the report with the error log's first line.\n4) If the log isn't pasted, locate and attach the latest error log file.\n\nThank you!" #macro STR_ERROR_MESSAGE_PS $"P.S. You can ALT-TAB and try to continue playing, though it’s recommended to wait for a response in the bug-report forum." +#macro ERR_LOG_DIRECTORY "Logs/" +#macro ERR_PATH_LAST_MESSAGES "last_messages.log" enum eLOG_LEVEL { DEBUG, @@ -15,19 +16,46 @@ enum eLOG_LEVEL { /// @description Logs the _message into a file in the Logs folder. /// @param {string} _message - The message to log. function create_error_file(_message) { - if (string_length(_message) > 0) { - var _log_file = file_text_open_write($"Logs/{DATE_TIME_1}_error.log"); - file_text_write_string(_log_file, _message); - file_text_close(_log_file); + if (string_length(_message) == 0) { + return; } + + if (!directory_exists(ERR_LOG_DIRECTORY)) { + directory_create(ERR_LOG_DIRECTORY); + } + + var _log_file = file_text_open_write($"{ERR_LOG_DIRECTORY}{DATE_TIME_1}_error.log"); + file_text_write_string(_log_file, _message); + file_text_close(_log_file); + copy_last_messages_file(); } /// @description Creates a copy of the last_messages.log file, with the current date in the name, in the same folder. function copy_last_messages_file() { - if (file_exists(PATH_LAST_MESSAGES)) { - file_copy(PATH_LAST_MESSAGES, $"Logs/{DATE_TIME_1}_messages.log"); + if (!file_exists(ERR_PATH_LAST_MESSAGES)) return; + + if (!directory_exists(ERR_LOG_DIRECTORY)) { + directory_create(ERR_LOG_DIRECTORY); + } + + file_copy(ERR_PATH_LAST_MESSAGES, $"{ERR_LOG_DIRECTORY}{DATE_TIME_1}_messages.log"); +} + +/// @desc Provides game-specific state data to the error handler without tight coupling. +/// @returns {Struct} +function error_get_context() { + var _context = { + chapter: global.chapter_name ?? "???", + seed: global.game_seed ?? "???", + turn: "???" + }; + + if (instance_exists(obj_controller)) { + _context.turn = obj_controller.turn; } + + return _context; } /// @description Displays a popup, logs the error into file, and copies to clipboard. @@ -37,74 +65,53 @@ function copy_last_messages_file() { /// @param {string} _critical - Optional. /// @param {string} _report_title - Optional. Preset title for the bug report. function handle_error(_header, _message, _stacktrace = "", _critical = false, _report_title = "") { - var _full_message = ""; - var _header_section = ""; - var _info_section = ""; - var _save_section = ""; - var _error_section = ""; - var _footer_section = ""; - - _header_section += $"{LB_92}\n"; - _header_section += $"{_header}\n\n"; - _full_message += _header_section; - - // _info_section += $"Operating System: {os_type_format(os_type)}\n"; // Uncomment this when we start compiling for different platforms; - _info_section += $"Date-Time: {DATE_TIME_3}\n"; - _info_section += $"Game Version: {global.game_version}\n"; - _info_section += $"Build Date: {global.build_date}\n"; - _info_section += $"Commit Hash: {global.commit_hash}\n\n"; - _full_message += _info_section; - - if (global.chapter_name != "None") { - _save_section += $"Chapter Name: {global.chapter_name}\n"; - } - if (instance_exists(obj_controller)) { - _save_section += $"Current Turn: {obj_controller.turn}\n"; - } - if (global.game_seed != 0) { - _save_section += $"Game Seed: {global.game_seed}\n"; - } - if (_save_section != "") { - _full_message += "Save Details:\n"; - _full_message += $"{_save_section}\n"; - } - - _error_section += "Error Details:\n"; - _error_section += $"{_message}\n\n"; - _error_section += "Stacktrace:\n"; - _error_section += $"{_stacktrace}\n"; - _full_message += _error_section; - - _footer_section += $"{LB_92}"; - _full_message += _footer_section; - - if (_report_title != "") { - _report_title += "\n"; - } - - var _error_file_text = $"{_report_title}{_full_message}"; - var _commit_history_link = ""; - if (global.commit_hash != "unknown hash") { - _commit_history_link = $"https://github.com/Adeptus-Dominus/ChapterMaster/commits/{global.commit_hash}"; - _error_file_text += $"\n{_commit_history_link}"; + var _context = error_get_context(); + var _full_log = ""; + + var _sections = [ + LB_92, + _header, + "", + $"Date-Time: {DATE_TIME_3}", + $"Game Version: {global.game_version}", + $"Build Date: {global.build_date}", + $"Commit Hash: {global.commit_hash}", + "", + "Save Details:", + $"Chapter Name: {_context.chapter}", + $"Current Turn: {_context.turn}", + $"Game Seed: {_context.seed}", + "", + "Error Details:", + _message, + "", + "Stacktrace:", + _stacktrace, + LB_92 + ]; + + for (var i = 0, _len = array_length(_sections); i < _len; i++) { + _full_log += $"{_sections[i]}\n"; } + var _error_file_text = (_report_title != "") ? $"{_report_title}\n{_full_log}" : _full_log; create_error_file(_error_file_text); - show_debug_message($"{_header_section}{_error_section}{_footer_section}"); - - var _clipboard_message = ""; - _clipboard_message += $"{_report_title}"; - _clipboard_message += $"{markdown_codeblock(_full_message, "log")}\n"; - if (_commit_history_link != "") { - _clipboard_message += $"\n{_commit_history_link}"; + + var _clipboard = (_report_title != "") ? $"{_report_title}\n" : ""; + _clipboard += markdown_codeblock(_full_log, "log"); + clipboard_set_text(_clipboard); + + var _path_hint = string_replace(game_save_id, "/", "\\"); + var _player_msg = $"{_header}\n\n{_message}\n\n"; + _player_msg += $"The error log is in your clipboard and saved at:\n{_path_hint}Logs\\\n\n"; + _player_msg += "1) Create a bug report on Discord.\n2) Press CTRL+V to paste the log.\n\nThank you!"; + + if (!_critical) { + _player_msg += $"\n\n{STR_ERROR_MESSAGE_PS}"; } - clipboard_set_text(_clipboard_message); - var _player_message = ""; - _player_message += $"{_header}\n\n"; - _player_message += $"{STR_ERROR_MESSAGE}"; - _player_message += _critical ? "" : $"\n\n{STR_ERROR_MESSAGE_PS}"; - show_message(_player_message); + show_debug_message(_full_log); + show_message(_player_msg); } /// @function handle_exception @@ -117,10 +124,7 @@ function handle_exception(_exception, custom_title = STR_ERROR_MESSAGE_HEAD, cri var _header = critical ? STR_ERROR_MESSAGE_HEAD2 : custom_title; var _message = _exception.longMessage; var _stacktrace = _exception.stacktrace; - - for (var i = 0; i < array_length(_stacktrace); i++) { - _stacktrace[i] = clean_stacktrace_line(_stacktrace[i]); - } + clean_stacktrace(_stacktrace); _stacktrace = array_to_string_list(_stacktrace); @@ -158,6 +162,7 @@ function assert_error_popup(_message, _header = "Your game just encountered an e array_shift(_stacktrace_array); // throw away the first line, it's this function array_pop(_stacktrace_array); // and the last line, it's the `0` debug_get_callstack returns for the top of the stack + clean_stacktrace(_stacktrace_array); var _stacktrace = array_to_string_list(_stacktrace_array); @@ -183,10 +188,7 @@ function markdown_codeblock(_message, _language = "") { /// @param {real} _time - Usually hours, minutes or seconds. /// @returns {string} function format_time(_time) { - if (_time < 10) { - _time = $"0{_time}"; - } - return string(_time); + return (_time < 10) ? $"0{_time}" : string(_time); } function clean_callstack_prefixes(_string) { @@ -196,7 +198,15 @@ function clean_callstack_prefixes(_string) { return _string; } -/// @desc Reformats: "Location > L[Num] > Method > Code Snippet" +/// @desc Reformats: "Location:[LineNum] > Method > Code Snippet" +/// @param {array} _stacktrace_array The array from debug_get_callstack() +function clean_stacktrace(_stacktrace_array) { + for (var i = 0, l = array_length(_stacktrace_array); i < l; i++) { + _stacktrace_array[@ i] = clean_stacktrace_line(_stacktrace_array[i]); + } +} + +/// @desc Reformats: "Location:[LineNum] > Method > Code Snippet" /// @param {string} _line_string The raw string from debug_get_callstack() /// @returns {string} function clean_stacktrace_line(_line_string) { From 7b7897718160e5678cfab91cba0eadcdd97198cc Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:09:42 +0300 Subject: [PATCH 05/16] refactor: Nuke overengineered try_and_report_loop() --- objects/obj_controller/Alarm_5.gml | 1272 +++++++++-------- objects/obj_en_fleet/Alarm_1.gml | 837 ++++++----- objects/obj_en_fleet/Alarm_4.gml | 226 +-- objects/obj_p_fleet/Alarm_1.gml | 310 ++-- objects/obj_turn_end/Alarm_0.gml | 401 +++--- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 6 +- .../scr_logging_functions.gml | 18 - .../scr_specialist_point_handler.gml | 6 +- 8 files changed, 1536 insertions(+), 1540 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index f057d67769..eeae46eb68 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -1,198 +1,226 @@ // TODO script description: This is the turn management in general // TODO refactor -try_and_report_loop("final end turn alarm 5", function() { - var recruit_count = 0; - var random_marine, marine_position; - var eq1 = 1, eq2 = 1, eq3 = 1, t = 0, r = 0; - var marine_company = 0; - var warn = "", w5 = 0; - var g1 = 0, g2 = 0; - var onceh = 0, stahp = 0; - var disc = 0, droll = 0; - var rund = 0; - var spikky = 0; - var roll = 0; - var novice_type = ""; - var unit; - - try_and_report_loop("chaos_spread", function() { - var times = max(1, round(turn / 150)); - if ((known[eFACTION.CHAOS] == 2) && (faction_defeated[eFACTION.CHAOS] == 0)) { - times += 1; - } - var xx3, yy3, plani, _star; - xx3 = irandom(room_width) + 1; - yy3 = irandom(room_height) + 1; - _star = instance_nearest(xx3, yy3, obj_star); - plani = floor(random(_star.planets)) + 1; - - // ** Chaos influence / corruption ** - if ((faction_gender[eFACTION.CHAOS] == 1) && (faction_defeated[eFACTION.CHAOS] == 0) && (turn >= chaos_turn)) { - repeat (times) { - if ((_star.p_type[plani] != "Dead") && (_star.planets > 0) && (turn >= 20)) { - var cathedral = 0; - if (planet_feature_bool(_star.p_feature[plani], eP_FEATURES.SORORITAS_CATHEDRAL) == 1) { - cathedral = choose(0, 1, 1); - } - - if (cathedral == 0) { - if ((_star.p_heresy[plani] >= 0) && (_star.p_heresy[plani] < 10)) { - _star.p_heresy[plani] += choose(0, 0, 0, 0, 0, 0, 0, 0, 5); - } else if ((_star.p_heresy[plani] >= 10) && (_star.p_heresy[plani] < 20)) { - _star.p_heresy[plani] += choose(-2, -2, -2, 5, 10, 15); - } else if ((_star.p_heresy[plani] >= 20) && (_star.p_heresy[plani] < 40)) { - _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10); - } else if ((_star.p_heresy[plani] >= 40) && (_star.p_heresy[plani] < 60)) { - _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10, 15); - } else if ((_star.p_heresy[plani] >= 60) && (_star.p_heresy[plani] < 100)) { - _star.p_heresy[plani] += choose(-1, 0, 0, 0, 0, 5, 10, 15); +try { + var recruit_count = 0; + var random_marine, marine_position; + var eq1 = 1, eq2 = 1, eq3 = 1, t = 0, r = 0; + var marine_company = 0; + var warn = "", w5 = 0; + var g1 = 0, g2 = 0; + var onceh = 0, stahp = 0; + var disc = 0, droll = 0; + var rund = 0; + var spikky = 0; + var roll = 0; + var novice_type = ""; + var unit; + + try_and_report_loop("chaos_spread", function() { + var times = max(1, round(turn / 150)); + if ((known[eFACTION.CHAOS] == 2) && (faction_defeated[eFACTION.CHAOS] == 0)) { + times += 1; + } + var xx3, yy3, plani, _star; + xx3 = irandom(room_width) + 1; + yy3 = irandom(room_height) + 1; + _star = instance_nearest(xx3, yy3, obj_star); + plani = floor(random(_star.planets)) + 1; + + // ** Chaos influence / corruption ** + if ((faction_gender[eFACTION.CHAOS] == 1) && (faction_defeated[eFACTION.CHAOS] == 0) && (turn >= chaos_turn)) { + repeat (times) { + if ((_star.p_type[plani] != "Dead") && (_star.planets > 0) && (turn >= 20)) { + var cathedral = 0; + if (planet_feature_bool(_star.p_feature[plani], eP_FEATURES.SORORITAS_CATHEDRAL) == 1) { + cathedral = choose(0, 1, 1); + } + + if (cathedral == 0) { + if ((_star.p_heresy[plani] >= 0) && (_star.p_heresy[plani] < 10)) { + _star.p_heresy[plani] += choose(0, 0, 0, 0, 0, 0, 0, 0, 5); + } else if ((_star.p_heresy[plani] >= 10) && (_star.p_heresy[plani] < 20)) { + _star.p_heresy[plani] += choose(-2, -2, -2, 5, 10, 15); + } else if ((_star.p_heresy[plani] >= 20) && (_star.p_heresy[plani] < 40)) { + _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10); + } else if ((_star.p_heresy[plani] >= 40) && (_star.p_heresy[plani] < 60)) { + _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10, 15); + } else if ((_star.p_heresy[plani] >= 60) && (_star.p_heresy[plani] < 100)) { + _star.p_heresy[plani] += choose(-1, 0, 0, 0, 0, 5, 10, 15); + } + } + if (_star.p_heresy[plani] < 0) { + _star.p_heresy[plani] = 0; } - } - if (_star.p_heresy[plani] < 0) { - _star.p_heresy[plani] = 0; } } } - } - - instance_activate_object(obj_star); - }); - - // ** Build new Imperial Ships ** - build_planet_defence_fleets(); - - apothecary_training(); - chaplain_training(); - librarian_training(); - techmarine_training(); - - if (obj_ini.fleet_type != 1) { - with (obj_temp5) { - instance_destroy(); - } - with (obj_p_fleet) { - if (action != "") { - instance_create(x, y, obj_temp5); + + instance_activate_object(obj_star); + }); + + // ** Build new Imperial Ships ** + build_planet_defence_fleets(); + + apothecary_training(); + chaplain_training(); + librarian_training(); + techmarine_training(); + + if (obj_ini.fleet_type != 1) { + with (obj_temp5) { + instance_destroy(); + } + with (obj_p_fleet) { + if (action != "") { + instance_create(x, y, obj_temp5); + } + if ((x < 0) || (x > room_width) || (y < 0) || (y > room_height)) { + instance_create(x, y, obj_temp5); + } } - if ((x < 0) || (x > room_width) || (y < 0) || (y > room_height)) { - instance_create(x, y, obj_temp5); + if (instance_number(obj_temp5) >= instance_number(obj_p_fleet)) { + stahp = 1; + } + with (obj_temp5) { + instance_destroy(); } } - if (instance_number(obj_temp5) >= instance_number(obj_p_fleet)) { - stahp = 1; - } - with (obj_temp5) { - instance_destroy(); - } - } - - var recruits_finished = 0, recruit_first = ""; - - var total_recruits = 0; - var i = 0; - while (i < array_length(recruit_name)) { - if (recruit_name[i] == "") { + + var recruits_finished = 0, recruit_first = ""; + + var total_recruits = 0; + var i = 0; + while (i < array_length(recruit_name)) { + if (recruit_name[i] == "") { + i++; + continue; + } + if (recruit_distance[i] <= 0) { + recruit_training[i] -= 1; + } + if (recruit_training[i] <= 0) { + scr_add_man(obj_ini.role[100][12], 10, recruit_exp[i], recruit_name[i], recruit_corruption[i], false, "default", recruit_data[i]); + if (recruit_first == "") { + recruit_first = recruit_name[i]; + } + recruits_finished += 1; + array_delete(recruit_name, i, 1); + array_delete(recruit_corruption, i, 1); + array_delete(recruit_distance, i, 1); + array_delete(recruit_training, i, 1); + array_delete(recruit_exp, i, 1); + array_delete(recruit_data, i, 1); + continue; + } else { + total_recruits++; + } i++; - continue; - } - if (recruit_distance[i] <= 0) { - recruit_training[i] -= 1; - } - if (recruit_training[i] <= 0) { - scr_add_man(obj_ini.role[100][12], 10, recruit_exp[i], recruit_name[i], recruit_corruption[i], false, "default", recruit_data[i]); - if (recruit_first == "") { - recruit_first = recruit_name[i]; - } - recruits_finished += 1; - array_delete(recruit_name, i, 1); - array_delete(recruit_corruption, i, 1); - array_delete(recruit_distance, i, 1); - array_delete(recruit_training, i, 1); - array_delete(recruit_exp, i, 1); - array_delete(recruit_data, i, 1); - continue; - } else { - total_recruits++; - } - i++; - } - with (obj_ini) { - scr_company_order(10); - } - if (recruits_finished == 1) { - scr_alert("green", "recruitment", $"{obj_ini.role[100][12]} {recruit_first} has joined X Company.", 0, 0); - } else if (recruits_finished > 1) { - scr_alert("green", "recruitment", $"{recruits_finished}x {obj_ini.role[100][12]} have joined X Company.", 0, 0); - } - - recruits = total_recruits; - - /* TODO implement Lamenters get Black Rage and story -if (turn=240) and (global.chapter_name="Lamenters"){ - obj_ini.strin2+="Black Rage"; - scr_popup("Geneseed Mutation","Your Chapter has begun to have visions and nightmares of Sanguinius' fall. The less mentally disciplined of your battle-brothers no longer are able to sleep soundly, waking from sleep in a screaming, frothing rage. It appears the Black Rage has returned.","black_rage",""); -} -*/ - // ** Battlefield Loot ** - if (scr_has_adv("Tech-Scavengers")) { - var lroll1, lroll2, loot = ""; - lroll1 = roll_dice_chapter(1, 100, "low"); - lroll2 = roll_dice_chapter(1, 100, "low"); - if (lroll1 <= 5) { - loot = choose("Chainsword", "Bolt Pistol", "Combat Knife", "Narthecium"); - if (lroll2 <= 80) { - loot = choose("Power Sword", "Storm Bolter"); - } - if (lroll2 <= 60) { - loot = choose("Plasma Pistol", "Chainfist", "Lascannon", "Heavy Bolter", "Assault Cannon", "Bike"); - } - if (lroll2 <= 30) { - loot = choose("Artificer Armour", "Plasma Gun", "Chainfist", "Rosarius", "Psychic Hood"); - } - if (lroll2 <= 10) { - loot = choose("Terminator Armour", "Artificer Armour", "Dreadnought", "Plasma Gun", "Power Fist", "Thunder Hammer", "Iron Halo"); - } - var tix = "A " + string(loot) + " has been gifted to the Chapter."; - tix = string_replace(tix, "A A", "An A"); - tix = string_replace(tix, "A E", "An E"); - tix = string_replace(tix, "A I", "An I"); - tix = string_replace(tix, "A O", "An O"); - scr_add_item(string(loot), 1); - scr_alert("", "loot", tix, 0, 0); } - } - imperial_navy_fleet_construction(); - - // ** Adeptus Mechanicus Geneseed Tithe ** - if ((gene_tithe == 0) && (faction_status[eFACTION.IMPERIUM] != "War")) { - gene_tithe = 24; - - var expected, txt = "", mech_mad = false; - var onceh = 0; - expected = max(1, round(obj_controller.gene_seed / 20)); - if (obj_controller.faction_status[eFACTION.MECHANICUS] == "War") { - mech_mad = true; - } - - if ((obj_controller.gene_seed <= 0) || (mech_mad == true)) { - onceh = 2; - gene_iou += 1; - loyalty -= 2; - loyalty_hidden -= 2; - txt = "No Gene-Seed for Adeptus Mechanicus tithe. High Lords of Terra IOU increased to " + string(gene_iou) + "."; - } - if (mech_mad == false) { - if ((obj_controller.gene_seed > 0) && (und_gene_vaults == 0) && (onceh == 0)) { - obj_controller.gene_seed -= expected; - onceh = 1; - if ((obj_controller.gene_seed >= gene_iou) && (gene_iou > 0)) { - expected += gene_iou; - obj_controller.gene_seed -= gene_iou; - gene_iou = 0; - onceh = 3; - } - for (var i = 0; i < 50; i++) { + with (obj_ini) { + scr_company_order(10); + } + if (recruits_finished == 1) { + scr_alert("green", "recruitment", $"{obj_ini.role[100][12]} {recruit_first} has joined X Company.", 0, 0); + } else if (recruits_finished > 1) { + scr_alert("green", "recruitment", $"{recruits_finished}x {obj_ini.role[100][12]} have joined X Company.", 0, 0); + } + + recruits = total_recruits; + + /* TODO implement Lamenters get Black Rage and story + if (turn=240) and (global.chapter_name="Lamenters"){ + obj_ini.strin2+="Black Rage"; + scr_popup("Geneseed Mutation","Your Chapter has begun to have visions and nightmares of Sanguinius' fall. The less mentally disciplined of your battle-brothers no longer are able to sleep soundly, waking from sleep in a screaming, frothing rage. It appears the Black Rage has returned.","black_rage",""); + } + */ + // ** Battlefield Loot ** + if (scr_has_adv("Tech-Scavengers")) { + var lroll1, lroll2, loot = ""; + lroll1 = roll_dice_chapter(1, 100, "low"); + lroll2 = roll_dice_chapter(1, 100, "low"); + if (lroll1 <= 5) { + loot = choose("Chainsword", "Bolt Pistol", "Combat Knife", "Narthecium"); + if (lroll2 <= 80) { + loot = choose("Power Sword", "Storm Bolter"); + } + if (lroll2 <= 60) { + loot = choose("Plasma Pistol", "Chainfist", "Lascannon", "Heavy Bolter", "Assault Cannon", "Bike"); + } + if (lroll2 <= 30) { + loot = choose("Artificer Armour", "Plasma Gun", "Chainfist", "Rosarius", "Psychic Hood"); + } + if (lroll2 <= 10) { + loot = choose("Terminator Armour", "Artificer Armour", "Dreadnought", "Plasma Gun", "Power Fist", "Thunder Hammer", "Iron Halo"); + } + var tix = "A " + string(loot) + " has been gifted to the Chapter."; + tix = string_replace(tix, "A A", "An A"); + tix = string_replace(tix, "A E", "An E"); + tix = string_replace(tix, "A I", "An I"); + tix = string_replace(tix, "A O", "An O"); + scr_add_item(string(loot), 1); + scr_alert("", "loot", tix, 0, 0); + } + } + imperial_navy_fleet_construction(); + + // ** Adeptus Mechanicus Geneseed Tithe ** + if ((gene_tithe == 0) && (faction_status[eFACTION.IMPERIUM] != "War")) { + gene_tithe = 24; + + var expected, txt = "", mech_mad = false; + var onceh = 0; + expected = max(1, round(obj_controller.gene_seed / 20)); + if (obj_controller.faction_status[eFACTION.MECHANICUS] == "War") { + mech_mad = true; + } + + if ((obj_controller.gene_seed <= 0) || (mech_mad == true)) { + onceh = 2; + gene_iou += 1; + loyalty -= 2; + loyalty_hidden -= 2; + txt = "No Gene-Seed for Adeptus Mechanicus tithe. High Lords of Terra IOU increased to " + string(gene_iou) + "."; + } + if (mech_mad == false) { + if ((obj_controller.gene_seed > 0) && (und_gene_vaults == 0) && (onceh == 0)) { + obj_controller.gene_seed -= expected; + onceh = 1; + if ((obj_controller.gene_seed >= gene_iou) && (gene_iou > 0)) { + expected += gene_iou; + obj_controller.gene_seed -= gene_iou; + gene_iou = 0; + onceh = 3; + } + for (var i = 0; i < 50; i++) { + if ((obj_controller.gene_seed < gene_iou) && (obj_controller.gene_seed > 0) && (gene_iou > 0)) { + expected += 1; + obj_controller.gene_seed -= 1; + gene_iou -= 1; + if (gene_iou == 0) { + onceh = 3; + } + } + } + + if (gene_iou < 0) { + gene_iou = 0; + } + + txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; + if (gene_iou > 0) { + txt += " IOU remains at " + string(gene_iou) + "."; + } + if (onceh == 3) { + txt += " IOU has been payed off."; + } + } + + if ((obj_controller.gene_seed > 0) && (und_gene_vaults > 0) && (onceh == 0)) { + expected = 1; + obj_controller.gene_seed -= expected; + onceh = 1; + if ((obj_controller.gene_seed < gene_iou) && (obj_controller.gene_seed > 0) && (gene_iou > 0)) { expected += 1; obj_controller.gene_seed -= 1; @@ -201,527 +229,501 @@ if (turn=240) and (global.chapter_name="Lamenters"){ onceh = 3; } } - } - - if (gene_iou < 0) { - gene_iou = 0; - } - - txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; - if (gene_iou > 0) { - txt += " IOU remains at " + string(gene_iou) + "."; - } - if (onceh == 3) { - txt += " IOU has been payed off."; - } - } - - if ((obj_controller.gene_seed > 0) && (und_gene_vaults > 0) && (onceh == 0)) { - expected = 1; - obj_controller.gene_seed -= expected; - onceh = 1; - - if ((obj_controller.gene_seed < gene_iou) && (obj_controller.gene_seed > 0) && (gene_iou > 0)) { - expected += 1; - obj_controller.gene_seed -= 1; - gene_iou -= 1; - if (gene_iou == 0) { - onceh = 3; + + if (gene_iou < 0) { + gene_iou = 0; + } + + txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; + if (gene_iou > 0) { + txt += " IOU remains at " + string(gene_iou) + "."; + } + if (onceh == 3) { + txt += " IOU has been payed off."; } } - - if (gene_iou < 0) { - gene_iou = 0; - } - - txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; - if (gene_iou > 0) { - txt += " IOU remains at " + string(gene_iou) + "."; + + if (onceh != 2) { + scr_alert("green", "tithes", txt, 0, 0); + scr_event_log("", txt); } - if (onceh == 3) { - txt += " IOU has been payed off."; + if (onceh == 2) { + scr_alert("red", "tithes", txt, 0, 0); + scr_event_log("red", txt); } } - - if (onceh != 2) { - scr_alert("green", "tithes", txt, 0, 0); - scr_event_log("", txt); - } - if (onceh == 2) { - scr_alert("red", "tithes", txt, 0, 0); - scr_event_log("red", txt); - } } - } - if (gene_sold > 0) { - disc = 0; - droll = 0; - gene_sold = floor(gene_sold * 75) / 100; - - if (gene_sold < 1) { - gene_sold = 0; - } - if (gene_sold >= 50) { - disc = round(gene_sold / 7); - droll = floor(random(100)) + 1; - - // Inquisition takes notice - if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { - var disp_change = -3; - if (gene_sold >= 100) { - disp_change = -5; - } - if (gene_sold >= 200) { - disp_change = -7; - } - if (gene_sold >= 400) { - disp_change = -10; - } + if (gene_sold > 0) { + disc = 0; + droll = 0; + gene_sold = floor(gene_sold * 75) / 100; + + if (gene_sold < 1) { gene_sold = 0; - scr_audience(4, "gene_trade", disp_change, "", 2, 0); } - } - } - if (gene_xeno > 0) { - disc = 0; - droll = 0; - gene_xeno = floor(gene_xeno * 90) / 100; - - if (gene_xeno < 1) { - gene_xeno = 0; - } - if (gene_xeno >= 5) { - disc = round(gene_xeno / 5); - droll = floor(random(100)) + 1; - - // Inquisition takes notice - if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { - gene_xeno = 99999; - alarm[8] = 1; + if (gene_sold >= 50) { + disc = round(gene_sold / 7); + droll = floor(random(100)) + 1; + + // Inquisition takes notice + if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { + var disp_change = -3; + if (gene_sold >= 100) { + disp_change = -5; + } + if (gene_sold >= 200) { + disp_change = -7; + } + if (gene_sold >= 400) { + disp_change = -10; + } + gene_sold = 0; + scr_audience(4, "gene_trade", disp_change, "", 2, 0); + } } } - } - var p = 0, penitorium = 0, unit; - for (var c = 0; c < 11; c++) { - for (var e = 0; e < array_length(obj_ini.god[c]); e++) { - if (obj_ini.god[c][e] == 10) { - unit = fetch_unit([c, e]); - p += 1; - penit_co[p] = c; - penit_id[p] = e; - penitorium += 1; - unit.alter_loyalty(-1); - if ((unit.corruption < 90) && (unit.corruption > 0)) { - var heresy_old = 0, heresy_new = 0; - heresy_old = round((unit.corruption * unit.corruption) / 50) - 0.5; - heresy_new = (heresy_old * 50) / unit.corruption; - unit.corruption = max(0, heresy_new); + if (gene_xeno > 0) { + disc = 0; + droll = 0; + gene_xeno = floor(gene_xeno * 90) / 100; + + if (gene_xeno < 1) { + gene_xeno = 0; + } + if (gene_xeno >= 5) { + disc = round(gene_xeno / 5); + droll = floor(random(100)) + 1; + + // Inquisition takes notice + if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { + gene_xeno = 99999; + alarm[8] = 1; } } } - } - // STC Bonuses - if (obj_controller.stc_ships >= 6) { - //self healing ships logic - for (var v = 0; v < array_length(obj_ini.ship_hp); v++) { - if (obj_ini.ship[v] == "" || obj_ini.ship_hp[v] < 0) { - continue; - } - if (obj_ini.ship_hp[v] < obj_ini.ship_maxhp[v]) { - var _max = obj_ini.ship_maxhp[v]; - obj_ini.ship_hp[v] = min(_max, obj_ini.ship_hp[v] + round(_max * 0.06)); + var p = 0, penitorium = 0, unit; + for (var c = 0; c < 11; c++) { + for (var e = 0; e < array_length(obj_ini.god[c]); e++) { + if (obj_ini.god[c][e] == 10) { + unit = fetch_unit([c, e]); + p += 1; + penit_co[p] = c; + penit_id[p] = e; + penitorium += 1; + unit.alter_loyalty(-1); + if ((unit.corruption < 90) && (unit.corruption > 0)) { + var heresy_old = 0, heresy_new = 0; + heresy_old = round((unit.corruption * unit.corruption) / 50) - 0.5; + heresy_new = (heresy_old * 50) / unit.corruption; + unit.corruption = max(0, heresy_new); + } + } } } - } - - try_and_report_loop("Secret Chaos Warlord spawn", function() { - if ((turn == 5) && (faction_gender[eFACTION.CHAOS] == 1)) { - // show_message("Turn 100"); - - var _star_found = false; - var _choice_star = noone; - var _stars = scr_get_stars(true); - for (var i = 0; i < array_length(_stars); i++) { - if (is_dead_star(_stars[i])) { + // STC Bonuses + if (obj_controller.stc_ships >= 6) { + //self healing ships logic + for (var v = 0; v < array_length(obj_ini.ship_hp); v++) { + if (obj_ini.ship[v] == "" || obj_ini.ship_hp[v] < 0) { continue; } - with (_stars[i]) { - if (owner == eFACTION.IMPERIUM && planets) { - if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { - _star_found = true; - _choice_star = self.id; - break; + if (obj_ini.ship_hp[v] < obj_ini.ship_maxhp[v]) { + var _max = obj_ini.ship_maxhp[v]; + obj_ini.ship_hp[v] = min(_max, obj_ini.ship_hp[v] + round(_max * 0.06)); + } + } + } + + try_and_report_loop("Secret Chaos Warlord spawn", function() { + if ((turn == 5) && (faction_gender[eFACTION.CHAOS] == 1)) { + // show_message("Turn 100"); + + var _star_found = false; + var _choice_star = noone; + var _stars = scr_get_stars(true); + for (var i = 0; i < array_length(_stars); i++) { + if (is_dead_star(_stars[i])) { + continue; + } + with (_stars[i]) { + if (owner == eFACTION.IMPERIUM && planets) { + if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { + _star_found = true; + _choice_star = self.id; + break; + } } } + if (_star_found) { + break; + } } if (_star_found) { - break; + var _planet = array_random_element(planets_without_type("Dead", _choice_star)); + _choice_star.warlord[_planet] = 1; + array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); + + var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; + + _choice_star.p_heresy[_planet] += _heresy_inc; + + if (_choice_star.p_heresy[_planet] < 50) { + _choice_star.p_heresy_secret[_planet] = 10; + } } } - if (_star_found) { - var _planet = array_random_element(planets_without_type("Dead", _choice_star)); - _choice_star.warlord[_planet] = 1; - array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); - - var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; - - _choice_star.p_heresy[_planet] += _heresy_inc; - - if (_choice_star.p_heresy[_planet] < 50) { - _choice_star.p_heresy_secret[_planet] = 10; + }); + // * Blood debt end * + if ((blood_debt == 1) && (penitent == 1)) { + penitent_turn += 1; + // was -60 + penitent_turnly = ((penitent_turn * penitent_turn) - 512) * -1; + if (penitent_turnly > 0) { + penitent_turnly = 0; + } + penitent_current += penitent_turnly; + if (penitent_current <= 0) { + penitent = 0; + alarm[8] = 1; + } + if (penitent_end < 30000) { + penitent_end += 41000; + } + if ((penitent_current >= penitent_max) || (((obj_controller.millenium * 1000) + obj_controller.year) >= penitent_end)) { + penitent = 0; + if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { + scr_audience(4, "penitent_end", 0, "", 0, 0); + } + if (known[eFACTION.ECCLESIARCHY] >= 2) { + scr_audience(5, "penitent_end", 0, "", 0, 0); + } + disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.MECHANICUS] += 15; + disposition[eFACTION.INQUISITION] += 20; + disposition[eFACTION.ECCLESIARCHY] += 20; + var o = 0; + if (scr_has_adv("Reverent Guardians")) { + o = 500; + } + if (o > 100) { + obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; } + scr_event_log("", "Blood Debt payed off. You may once more recruit Astartes."); } } - }); - // * Blood debt end * - if ((blood_debt == 1) && (penitent == 1)) { - penitent_turn += 1; - // was -60 - penitent_turnly = ((penitent_turn * penitent_turn) - 512) * -1; - if (penitent_turnly > 0) { + // * Penitent Crusade end * + if ((penitent == 1) && (blood_debt == 0)) { + penitent_turn += 1; + penitent_current += 1; penitent_turnly = 0; - } - penitent_current += penitent_turnly; - if (penitent_current <= 0) { - penitent = 0; - alarm[8] = 1; - } - if (penitent_end < 30000) { - penitent_end += 41000; - } - if ((penitent_current >= penitent_max) || (((obj_controller.millenium * 1000) + obj_controller.year) >= penitent_end)) { - penitent = 0; - if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { - scr_audience(4, "penitent_end", 0, "", 0, 0); - } - if (known[eFACTION.ECCLESIARCHY] >= 2) { - scr_audience(5, "penitent_end", 0, "", 0, 0); - } - disposition[eFACTION.IMPERIUM] += 20; - disposition[eFACTION.MECHANICUS] += 15; - disposition[eFACTION.INQUISITION] += 20; - disposition[eFACTION.ECCLESIARCHY] += 20; - var o = 0; - if (scr_has_adv("Reverent Guardians")) { - o = 500; + + if (penitent_current <= 0) { + penitent = 0; + alarm[8] = 1; } - if (o > 100) { - obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + if (penitent_current >= penitent_max) { + penitent = 0; + if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { + scr_audience(4, "penitent_end", 0, "", 0, 0); + } + if (known[eFACTION.ECCLESIARCHY] >= 2) { + scr_audience(5, "penitent_end", 0, "", 0, 0); + } + disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.MECHANICUS] += 15; + disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.ECCLESIARCHY] += 20; + var o = 0; + if (scr_has_adv("Reverent Guardians")) { + o = 500; + } + if (o > 100) { + obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + } + scr_event_log("", "Penitent Crusade ends. You may once more recruit Astartes."); } - scr_event_log("", "Blood Debt payed off. You may once more recruit Astartes."); } - } - // * Penitent Crusade end * - if ((penitent == 1) && (blood_debt == 0)) { - penitent_turn += 1; - penitent_current += 1; - penitent_turnly = 0; - - if (penitent_current <= 0) { - penitent = 0; - alarm[8] = 1; + // ** Ork WAAAAGH ** + if (((turn >= irandom(200) + 100) || (obj_ini.fleet_type == eFACTION.MECHANICUS)) && (faction_defeated[eFACTION.ORK] == 0)) {} + + if (known[eFACTION.ECCLESIARCHY] == 1) { + spikky = choose(0, 1, 1); + if (spikky) { + var _topic = faction_status[eFACTION.ECCLESIARCHY] == "War" ? "declare_war" : "intro"; + scr_audience(eFACTION.ECCLESIARCHY, _topic); + } } - if (penitent_current >= penitent_max) { - penitent = 0; - if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { - scr_audience(4, "penitent_end", 0, "", 0, 0); + if ((known[eFACTION.ELDAR] == 1) && (faction_defeated[eFACTION.ELDAR] == 0)) { + spikky = choose(0, 1); + if (spikky == 1) { + scr_audience(eFACTION.ELDAR, "intro1"); } - if (known[eFACTION.ECCLESIARCHY] >= 2) { - scr_audience(5, "penitent_end", 0, "", 0, 0); + } + if ((known[eFACTION.ORK] == 0.5) && (faction_defeated[eFACTION.ORK] == 0)) { + if (1 == irandom(7)) { + scr_audience(eFACTION.ORK, "intro"); } - disposition[eFACTION.IMPERIUM] += 20; - disposition[eFACTION.MECHANICUS] += 15; - disposition[eFACTION.IMPERIUM] += 20; - disposition[eFACTION.ECCLESIARCHY] += 20; - var o = 0; - if (scr_has_adv("Reverent Guardians")) { - o = 500; + } + if ((known[eFACTION.TAU] == 1) && (faction_defeated[eFACTION.TAU] == 0)) { + scr_audience(eFACTION.TAU, "intro"); + } + // ** Quests here ** + // 135 ; quests + for (var i = 1; i <= 40; i++) { + if ((quest_end[i] <= turn) && (quest[i] != "")) { + scr_quest(1, quest[i], quest_faction[i], 0); + quest[i] = ""; } - if (o > 100) { - obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + if ((quest[i] == "") && (quest[i + 1] != "")) { + quest[i] = quest[i + 1]; + quest_faction[i] = quest_faction[i + 1]; + quest_end[i] = quest_end[i + 1]; + quest[i + 1] += ""; + quest_faction[i + 1] = 0; + quest_end[i + 1] = 0; } - scr_event_log("", "Penitent Crusade ends. You may once more recruit Astartes."); } - } - // ** Ork WAAAAGH ** - if (((turn >= irandom(200) + 100) || (obj_ini.fleet_type == eFACTION.MECHANICUS)) && (faction_defeated[eFACTION.ORK] == 0)) {} - - if (known[eFACTION.ECCLESIARCHY] == 1) { - spikky = choose(0, 1, 1); - if (spikky) { - var _topic = faction_status[eFACTION.ECCLESIARCHY] == "War" ? "declare_war" : "intro"; - scr_audience(eFACTION.ECCLESIARCHY, _topic); + // ** Inquisition stuff here ** + if (disposition[eFACTION.ELDAR] >= 60) { + scr_loyalty("Xeno Associate", "+"); } - } - if ((known[eFACTION.ELDAR] == 1) && (faction_defeated[eFACTION.ELDAR] == 0)) { - spikky = choose(0, 1); - if (spikky == 1) { - scr_audience(eFACTION.ELDAR, "intro1"); + if (disposition[eFACTION.ORK] >= 60) { + scr_loyalty("Xeno Associate", "+"); } - } - if ((known[eFACTION.ORK] == 0.5) && (faction_defeated[eFACTION.ORK] == 0)) { - if (1 == irandom(7)) { - scr_audience(eFACTION.ORK, "intro"); + if (disposition[eFACTION.TAU] >= 60) { + scr_loyalty("Xeno Associate", "+"); } - } - if ((known[eFACTION.TAU] == 1) && (faction_defeated[eFACTION.TAU] == 0)) { - scr_audience(eFACTION.TAU, "intro"); - } - // ** Quests here ** - // 135 ; quests - for (var i = 1; i <= 40; i++) { - if ((quest_end[i] <= turn) && (quest[i] != "")) { - scr_quest(1, quest[i], quest_faction[i], 0); - quest[i] = ""; - } - if ((quest[i] == "") && (quest[i + 1] != "")) { - quest[i] = quest[i + 1]; - quest_faction[i] = quest_faction[i + 1]; - quest_end[i] = quest_end[i + 1]; - quest[i + 1] += ""; - quest_faction[i + 1] = 0; - quest_end[i + 1] = 0; + + var loyalty_counter = 0; + loyalty_counter = scr_role_count(obj_ini.role[100][15], ""); + if (loyalty_counter == 0) { + scr_loyalty("Lack of Apothecary", "+"); } - } - // ** Inquisition stuff here ** - if (disposition[eFACTION.ELDAR] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (disposition[eFACTION.ORK] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (disposition[eFACTION.TAU] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - - var loyalty_counter = 0; - loyalty_counter = scr_role_count(obj_ini.role[100][15], ""); - if (loyalty_counter == 0) { - scr_loyalty("Lack of Apothecary", "+"); - } - - loyalty_counter = scr_role_count(obj_ini.role[100][14], ""); - if (loyalty_counter == 0) { - scr_loyalty("Undevout", "+"); - } - // TODO in another PR rework how Non-Codex Size is determined, perhaps the inquisition needs to pass some checks or do an investigation event - // which you could eventually interrupt (kill the team) and cover it up? - if (marines >= 1050) { - scr_loyalty("Non-Codex Size", "+"); - } - - var last_inquisitor_inspection = 0; - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - last_inquisitor_inspection = last_world_inspection; - } - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - last_inquisitor_inspection = last_fleet_inspection; - } - - var inspec = false; - if ((loyalty >= 85) && ((last_inquisitor_inspection + 59) < turn)) { - inspec = true; - } - if ((loyalty >= 70) && (loyalty < 85) && ((last_inquisitor_inspection + 47) < turn)) { - inspec = true; - } - if ((loyalty >= 50) && (loyalty < 70) && ((last_inquisitor_inspection + 35) < turn)) { - inspec = true; - } - if ((loyalty < 50) && ((last_inquisitor_inspection + 11 + choose(1, 2, 3, 4)) < turn)) { - inspec = true; - } - - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - if ((instance_number(obj_p_fleet) == 1) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { - // Might be crusading, right? - if ((obj_p_fleet.x < 0) || (obj_p_fleet.x > room_width) || (obj_p_fleet.y < 0) || (obj_p_fleet.y > room_height)) { - inspec = false; - } + + loyalty_counter = scr_role_count(obj_ini.role[100][14], ""); + if (loyalty_counter == 0) { + scr_loyalty("Undevout", "+"); } - if (instance_number(obj_p_fleet) == 0) { - inspec = false; + // TODO in another PR rework how Non-Codex Size is determined, perhaps the inquisition needs to pass some checks or do an investigation event + // which you could eventually interrupt (kill the team) and cover it up? + if (marines >= 1050) { + scr_loyalty("Non-Codex Size", "+"); } - } - instance_activate_object(obj_p_fleet); - - //setup inquisitor inspections - var inquisitor_fleet_count = 0; - with (obj_fleet) { - if (owner == eFACTION.INQUISITION) { - inquisitor_fleet_count++; + + var last_inquisitor_inspection = 0; + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + last_inquisitor_inspection = last_world_inspection; } - } - - inspec = inspec && faction_status[eFACTION.INQUISITION] != "War" && inquisitor_fleet_count == 0; - if (inspec) { - new_inquisitor_inspection(); - } - - with (obj_temp6) { - instance_destroy(); - } - - for (var i = 1; i <= 10; i++) { - if ((turns_ignored[i] == 0) && (annoyed[i] > 0)) { - annoyed[i] -= 1; + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + last_inquisitor_inspection = last_fleet_inspection; } - } - - // ** Various checks for imperium and faction relations ** - try { - event_end_turn_action(); - } catch (_exception) { - handle_exception(_exception); - } - // Right here need to sort the battles within the obj_turn_end - with (obj_turn_end) { - scr_battle_sort(); - } - - for (var i = 1; i <= 10; i++) { - if ((turns_ignored[i] > 0) && (turns_ignored[i] < 500)) { - turns_ignored[i] -= 1; + + var inspec = false; + if ((loyalty >= 85) && ((last_inquisitor_inspection + 59) < turn)) { + inspec = true; } - } - if ((known[eFACTION.ELDAR] >= 2) && (faction_gender[6] == 2) && (turn % 10 == 0)) { - turns_ignored[6] += floor(random_range(0, 6)); - } - - with (obj_ground_mission) { - instance_destroy(); - } - scr_random_event(true); - - // ** Random events here ** - if ((hurssy_time > 0) && (hurssy > 0)) { - hurssy_time -= 1; - } - if ((hurssy_time == 0) && (hurssy > 0)) { - hurssy_time = -1; - hurssy = 0; - } - with (obj_p_fleet) { - if ((hurssy_time > 0) && (hurssy > 0)) { - hurssy_time -= 1; + if ((loyalty >= 70) && (loyalty < 85) && ((last_inquisitor_inspection + 47) < turn)) { + inspec = true; } - if ((hurssy_time == 0) && (hurssy > 0)) { - hurssy_time = -1; - hurssy = 0; + if ((loyalty >= 50) && (loyalty < 70) && ((last_inquisitor_inspection + 35) < turn)) { + inspec = true; } - } - with (obj_star) { - if ((p_hurssy_time[1] > 0) && (p_hurssy[1] > 0)) { - p_hurssy_time[1] -= 1; + if ((loyalty < 50) && ((last_inquisitor_inspection + 11 + choose(1, 2, 3, 4)) < turn)) { + inspec = true; } - if ((p_hurssy_time[1] == 0) && (p_hurssy[1] > 0)) { - p_hurssy_time[1] = -1; - p_hurssy[1] = 0; + + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + if ((instance_number(obj_p_fleet) == 1) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { + // Might be crusading, right? + if ((obj_p_fleet.x < 0) || (obj_p_fleet.x > room_width) || (obj_p_fleet.y < 0) || (obj_p_fleet.y > room_height)) { + inspec = false; + } + } + if (instance_number(obj_p_fleet) == 0) { + inspec = false; + } } - if ((p_hurssy_time[2] > 0) && (p_hurssy[2] > 0)) { - p_hurssy_time[2] -= 1; + instance_activate_object(obj_p_fleet); + + //setup inquisitor inspections + var inquisitor_fleet_count = 0; + with (obj_fleet) { + if (owner == eFACTION.INQUISITION) { + inquisitor_fleet_count++; + } } - if ((p_hurssy_time[2] == 0) && (p_hurssy[2] > 0)) { - p_hurssy_time[2] = -1; - p_hurssy[2] = 0; + + inspec = inspec && faction_status[eFACTION.INQUISITION] != "War" && inquisitor_fleet_count == 0; + if (inspec) { + new_inquisitor_inspection(); } - if ((p_hurssy_time[3] > 0) && (p_hurssy[3] > 0)) { - p_hurssy_time[3] -= 1; + + with (obj_temp6) { + instance_destroy(); } - if ((p_hurssy_time[3] == 0) && (p_hurssy[3] > 0)) { - p_hurssy_time[3] = -1; - p_hurssy[3] = 0; + + for (var i = 1; i <= 10; i++) { + if ((turns_ignored[i] == 0) && (annoyed[i] > 0)) { + annoyed[i] -= 1; + } } - if ((p_hurssy_time[4] > 0) && (p_hurssy[4] > 0)) { - p_hurssy_time[4] -= 1; + + // ** Various checks for imperium and faction relations ** + try { + event_end_turn_action(); + } catch (_exception) { + handle_exception(_exception); } - if ((p_hurssy_time[4] == 0) && (p_hurssy[4] > 0)) { - p_hurssy_time[4] = -1; - p_hurssy[4] = 0; + // Right here need to sort the battles within the obj_turn_end + with (obj_turn_end) { + scr_battle_sort(); } - } - - if (turn == 2) { - if ((obj_ini.master_name == "Zakis Randi") || (global.chapter_name == "Knights Inductor") && (obj_controller.faction_status[eFACTION.IMPERIUM] != "War")) { - alarm[8] = 1; + + for (var i = 1; i <= 10; i++) { + if ((turns_ignored[i] > 0) && (turns_ignored[i] < 500)) { + turns_ignored[i] -= 1; + } } - } - // ** Player-set events ** - if ((fest_scheduled > 0) && (fest_repeats > 0)) { - var lock = "", cm_present = false; - fest_repeats -= 1; - lock = scr_master_loc(); - - if ((fest_sid > 0) && (obj_ini.ship[fest_sid] == lock)) { - cm_present = true; + if ((known[eFACTION.ELDAR] >= 2) && (faction_gender[6] == 2) && (turn % 10 == 0)) { + turns_ignored[6] += floor(random_range(0, 6)); } - if ((fest_wid > 0) && (string(fest_star) + "." + string(fest_wid) == lock)) { - cm_present = true; + + with (obj_ground_mission) { + instance_destroy(); } - - if (cm_present == true) { - var imag = ""; - - if (fest_type == "Great Feast") { - imag = "event_feast"; + scr_random_event(true); + + // ** Random events here ** + if ((hurssy_time > 0) && (hurssy > 0)) { + hurssy_time -= 1; + } + if ((hurssy_time == 0) && (hurssy > 0)) { + hurssy_time = -1; + hurssy = 0; + } + with (obj_p_fleet) { + if ((hurssy_time > 0) && (hurssy > 0)) { + hurssy_time -= 1; + } + if ((hurssy_time == 0) && (hurssy > 0)) { + hurssy_time = -1; + hurssy = 0; } - if (fest_type == "Tournament") { - imag = "event_tournament"; + } + with (obj_star) { + if ((p_hurssy_time[1] > 0) && (p_hurssy[1] > 0)) { + p_hurssy_time[1] -= 1; } - if (fest_type == "Deathmatch") { - imag = "event_deathmatch"; + if ((p_hurssy_time[1] == 0) && (p_hurssy[1] > 0)) { + p_hurssy_time[1] = -1; + p_hurssy[1] = 0; } - if (fest_type == "Imperial Mass") { - imag = "event_mass"; + if ((p_hurssy_time[2] > 0) && (p_hurssy[2] > 0)) { + p_hurssy_time[2] -= 1; } - if (fest_type == "Cult Sermon") { - imag = "event_ccult"; + if ((p_hurssy_time[2] == 0) && (p_hurssy[2] > 0)) { + p_hurssy_time[2] = -1; + p_hurssy[2] = 0; } - if (fest_type == "Chapter Relic") { - imag = "event_ccrelic"; + if ((p_hurssy_time[3] > 0) && (p_hurssy[3] > 0)) { + p_hurssy_time[3] -= 1; } - if (fest_type == "Triumphal March") { - imag = "event_march"; + if ((p_hurssy_time[3] == 0) && (p_hurssy[3] > 0)) { + p_hurssy_time[3] = -1; + p_hurssy[3] = 0; } - - if (fest_wid > 0) { - scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on " + string(fest_star) + " " + scr_roman(fest_wid) + ". Would you like to spectate the event?", imag, ""); + if ((p_hurssy_time[4] > 0) && (p_hurssy[4] > 0)) { + p_hurssy_time[4] -= 1; } - if (fest_sid > 0) { - scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on the ship '" + string(obj_ini.ship[fest_sid]) + ". Would you like to spectate the event?", imag, ""); + if ((p_hurssy_time[4] == 0) && (p_hurssy[4] > 0)) { + p_hurssy_time[4] = -1; + p_hurssy[4] = 0; } } - } - - // ** Income ** - // if (income_controlled_planets>0){ - - // var tithe_string = income_controlled_planets==1? $"-{income_tribute} Requisition granted by tithes from 1 planet.": $"-{income_tribute} Requisition granted by tithes from {income_controlled_planets} planets."; - // scr_alert("yellow", "planet_tithe", tithe_string); - // instance_activate_object(obj_p_fleet); - - // with(obj_star){ - // if (x<-10000){ - // x+=20000; - // y+=20000; - // } - // } - // } - - //research and forge related actions - - research_end(); - merge_ork_fleets(); - location_viewer.update_mission_log(); - init_ork_waagh(); - return_lost_ships_chance(); - //complex route plotting for player fleets - with (obj_p_fleet) { - if (array_length(complex_route) > 0 && action == "") { - set_new_player_fleet_course(complex_route); + + if (turn == 2) { + if ((obj_ini.master_name == "Zakis Randi") || (global.chapter_name == "Knights Inductor") && (obj_controller.faction_status[eFACTION.IMPERIUM] != "War")) { + alarm[8] = 1; + } } - } -}); + // ** Player-set events ** + if ((fest_scheduled > 0) && (fest_repeats > 0)) { + var lock = "", cm_present = false; + fest_repeats -= 1; + lock = scr_master_loc(); + + if ((fest_sid > 0) && (obj_ini.ship[fest_sid] == lock)) { + cm_present = true; + } + if ((fest_wid > 0) && (string(fest_star) + "." + string(fest_wid) == lock)) { + cm_present = true; + } + + if (cm_present == true) { + var imag = ""; + + if (fest_type == "Great Feast") { + imag = "event_feast"; + } + if (fest_type == "Tournament") { + imag = "event_tournament"; + } + if (fest_type == "Deathmatch") { + imag = "event_deathmatch"; + } + if (fest_type == "Imperial Mass") { + imag = "event_mass"; + } + if (fest_type == "Cult Sermon") { + imag = "event_ccult"; + } + if (fest_type == "Chapter Relic") { + imag = "event_ccrelic"; + } + if (fest_type == "Triumphal March") { + imag = "event_march"; + } + + if (fest_wid > 0) { + scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on " + string(fest_star) + " " + scr_roman(fest_wid) + ". Would you like to spectate the event?", imag, ""); + } + if (fest_sid > 0) { + scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on the ship '" + string(obj_ini.ship[fest_sid]) + ". Would you like to spectate the event?", imag, ""); + } + } + } + + // ** Income ** + // if (income_controlled_planets>0){ + + // var tithe_string = income_controlled_planets==1? $"-{income_tribute} Requisition granted by tithes from 1 planet.": $"-{income_tribute} Requisition granted by tithes from {income_controlled_planets} planets."; + // scr_alert("yellow", "planet_tithe", tithe_string); + // instance_activate_object(obj_p_fleet); + + // with(obj_star){ + // if (x<-10000){ + // x+=20000; + // y+=20000; + // } + // } + // } + + //research and forge related actions + + research_end(); + merge_ork_fleets(); + location_viewer.update_mission_log(); + init_ork_waagh(); + return_lost_ships_chance(); + //complex route plotting for player fleets + with (obj_p_fleet) { + if (array_length(complex_route) > 0 && action == "") { + set_new_player_fleet_course(complex_route); + } + } +} catch (_exception) { + handle_exception(_exception); +} if (helpful_places != false) { helpful_places = new HelpfulPlaces(); diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index 6c5fdf1c7d..acf912aa62 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -1,478 +1,477 @@ -try_and_report_loop("enemy fleet main end turn action", function() { - var orb = orbiting; - - if ((round(owner) != eFACTION.IMPERIUM) && (navy == 1)) { - owner = noone; - } - - //TODO centralise orbiting logic - var _is_orbiting = is_orbiting(); - if (orbiting != 0 && action == "" && owner != noone) { - var orbiting_found = _is_orbiting; - if (orbiting_found) { - orbiting_found = variable_instance_exists(orbiting, "present_fleet"); - if (orbiting_found) { - orbiting.present_fleet[owner] += 1; - } - } else if (!orbiting_found) { - orbiting = instance_nearest(x, y, obj_star); - orbiting.present_fleet[owner]++; +try { + var orb = orbiting; + + if ((round(owner) != eFACTION.IMPERIUM) && (navy == 1)) { + owner = noone; } - } - var _khorne_cargo = fleet_has_cargo("warband"); - if (_khorne_cargo && owner == eFACTION.CHAOS) { - khorne_fleet_cargo(); - } - - if (_is_orbiting) { - turns_static++; - if (turns_static > 5 && owner == eFACTION.ORK) { - if (!irandom(7)) { - ork_fleet_move(); - _is_orbiting = false; + + //TODO centralise orbiting logic + var _is_orbiting = is_orbiting(); + if (orbiting != 0 && action == "" && owner != noone) { + var orbiting_found = _is_orbiting; + if (orbiting_found) { + orbiting_found = variable_instance_exists(orbiting, "present_fleet"); + if (orbiting_found) { + orbiting.present_fleet[owner] += 1; + } + } else if (!orbiting_found) { + orbiting = instance_nearest(x, y, obj_star); + orbiting.present_fleet[owner]++; } } - if (instance_exists(obj_crusade)) { - try { - fleet_respond_crusade(); - } catch (_exception) { - handle_exception(_exception); - } + var _khorne_cargo = fleet_has_cargo("warband"); + if (_khorne_cargo && owner == eFACTION.CHAOS) { + khorne_fleet_cargo(); } - } else { - turns_static = 0; - } - - var dir = 0; - var ret = 0; - - if (navy && action == "" && _is_orbiting) { - navy_orbiting_planet_end_turn_action(); - } else if (action == "" && _is_orbiting) { - var max_dis = 400; - - if ((orbiting.owner == eFACTION.PLAYER) && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") && (owner == eFACTION.IMPERIUM)) { - for (var i = 1; i <= orbiting.planets; i++) { - if (orbiting.p_owner[i] == 1) { - orbiting.p_pdf[i] -= capital_number * 50000; - } - if (orbiting.p_owner[i] == 1) { - orbiting.p_pdf[i] -= frigate_number * 10000; + + if (_is_orbiting) { + turns_static++; + if (turns_static > 5 && owner == eFACTION.ORK) { + if (!irandom(7)) { + ork_fleet_move(); + _is_orbiting = false; } - if (orbiting.p_pdf[i] < 0) { - orbiting.p_pdf[i] = 0; + } + if (instance_exists(obj_crusade)) { + try { + fleet_respond_crusade(); + } catch (_exception) { + handle_exception(_exception); } } + } else { + turns_static = 0; } - - // 1355; - - if (instance_exists(obj_crusade) && (owner == eFACTION.ORK) && (orbiting.owner == eFACTION.ORK)) { - // Ork crusade AI - var max_dis; - max_dis = 400; - - var fleet_owner = owner; - with (obj_crusade) { - if (owner != fleet_owner) { - x -= 40000; + + var dir = 0; + var ret = 0; + + if (navy && action == "" && _is_orbiting) { + navy_orbiting_planet_end_turn_action(); + } else if (action == "" && _is_orbiting) { + var max_dis = 400; + + if ((orbiting.owner == eFACTION.PLAYER) && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") && (owner == eFACTION.IMPERIUM)) { + for (var i = 1; i <= orbiting.planets; i++) { + if (orbiting.p_owner[i] == 1) { + orbiting.p_pdf[i] -= capital_number * 50000; + } + if (orbiting.p_owner[i] == 1) { + orbiting.p_pdf[i] -= frigate_number * 10000; + } + if (orbiting.p_pdf[i] < 0) { + orbiting.p_pdf[i] = 0; + } } } - - with (obj_star) { - var ns = instance_nearest(x, y, obj_crusade); - if (point_distance(x, y, ns.x, ns.y) > ns.radius) { - x -= 40000; + + // 1355; + + if (instance_exists(obj_crusade) && (owner == eFACTION.ORK) && (orbiting.owner == eFACTION.ORK)) { + // Ork crusade AI + var max_dis; + max_dis = 400; + + var fleet_owner = owner; + with (obj_crusade) { + if (owner != fleet_owner) { + x -= 40000; + } } - if (owner == ns.owner) { - x -= 40000; + + with (obj_star) { + var ns = instance_nearest(x, y, obj_crusade); + if (point_distance(x, y, ns.x, ns.y) > ns.radius) { + x -= 40000; + } + if (owner == ns.owner) { + x -= 40000; + } } - } - - var ns = instance_nearest(x, y, obj_star); - if ((ns.owner != eFACTION.ORK) && (point_distance(x, y, ns.x, ns.y) <= max_dis) && (point_distance(x, y, ns.x, ns.y) > 40) && instance_exists(obj_crusade) && (image_index > 3)) { - action_x = ns.x; - action_y = ns.y; - set_fleet_movement(); - home_x = orbiting.x; - home_y = orbiting.y; - exit; - } - - with (obj_star) { - if (x < -30000) { - x += 40000; + + var ns = instance_nearest(x, y, obj_star); + if ((ns.owner != eFACTION.ORK) && (point_distance(x, y, ns.x, ns.y) <= max_dis) && (point_distance(x, y, ns.x, ns.y) > 40) && instance_exists(obj_crusade) && (image_index > 3)) { + action_x = ns.x; + action_y = ns.y; + set_fleet_movement(); + home_x = orbiting.x; + home_y = orbiting.y; + exit; } - if (x < -30000) { - x += 40000; + + with (obj_star) { + if (x < -30000) { + x += 40000; + } + if (x < -30000) { + x += 40000; + } + if (x < -30000) { + x += 40000; + } } - if (x < -30000) { - x += 40000; + with (obj_crusade) { + if (x < -30000) { + x += 40000; + } + if (x < -30000) { + x += 40000; + } + if (x < -30000) { + x += 40000; + } } } - with (obj_crusade) { - if (x < -30000) { - x += 40000; - } - if (x < -30000) { - x += 40000; - } - if (x < -30000) { - x += 40000; + + instance_activate_object(obj_star); + instance_activate_object(obj_crusade); + instance_activate_object(obj_en_fleet); + + /*if (action="") and (owner = eFACTION.IMPERIUM){// Defend nearby systems and return when done + + with(obj_star){ + // 137 ; might want for it to defend under other circumstances + if (present_fleet[8]>0) and (owner<=5) and (x>2) and (y>2) then instance_create(x,y,obj_temp3); + } + if (instance_number(obj_temp3)=0) then ret=1; + if (instance_number(obj_temp3)>0){ + var you,dis,mem; + you=instance_nearest(x,y,obj_temp3); + dis=point_distance(x,y,you.x,you.y); + + if (dis<300) and (image_index>=3){ + action_x=you.x;action_y=you.y; + home_x=instance_nearest(x,y,obj_star).x; + home_y=instance_nearest(x,y,obj_star).y; + set_fleet_movement();with(obj_temp3){instance_destroy();} + exit; } + if (dis>=300) then ret=1; } - } - - instance_activate_object(obj_star); - instance_activate_object(obj_crusade); - instance_activate_object(obj_en_fleet); - - /*if (action="") and (owner = eFACTION.IMPERIUM){// Defend nearby systems and return when done - - with(obj_star){ - // 137 ; might want for it to defend under other circumstances - if (present_fleet[8]>0) and (owner<=5) and (x>2) and (y>2) then instance_create(x,y,obj_temp3); - } - if (instance_number(obj_temp3)=0) then ret=1; - if (instance_number(obj_temp3)>0){ - var you,dis,mem; - you=instance_nearest(x,y,obj_temp3); - dis=point_distance(x,y,you.x,you.y); - if (dis<300) and (image_index>=3){ - action_x=you.x;action_y=you.y; - home_x=instance_nearest(x,y,obj_star).x; - home_y=instance_nearest(x,y,obj_star).y; - set_fleet_movement();with(obj_temp3){instance_destroy();} - exit; - } - if (dis>=300) then ret=1; - } - - if (instance_exists(obj_crusade)){ - var cru;cru=instance_nearest(x,y,obj_crusade); - if (cru.owner=self.owner) and (point_distance(x,y,cru.x,cru.y)0){ - action_x=home_x; - action_y=home_y; - set_fleet_movement(); + if (instance_exists(obj_crusade)){ + var cru;cru=instance_nearest(x,y,obj_crusade); + if (cru.owner=self.owner) and (point_distance(x,y,cru.x,cru.y)0){ + action_x=home_x; + action_y=home_y; + set_fleet_movement(); } } - if (((orbiting.owner == eFACTION.PLAYER || system_feature_bool(orbiting.p_feature, eP_FEATURES.MONASTERY)) || (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD)) && (trade_goods != "cancel_inspection") && valid) { - if (obj_controller.disposition[6] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (obj_controller.disposition[7] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (obj_controller.disposition[8] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - - if ((orbiting.p_owner[2] == 1) && (orbiting.p_heresy[2] >= 60)) { - scr_loyalty("Heretic Homeworld", "+"); + + with(obj_temp3){instance_destroy();} + }*/ + + if (owner == eFACTION.INQUISITION) { + var valid = true; + if (instance_exists(target)) { + if (instance_nearest(target.x, target.y, obj_star).id != instance_nearest(x, y, obj_star).id) { + valid = false; + } } - - var whom = -1; - whom = inquisitor; - var inquisitors = obj_controller.inquisitor; - var inquis_string = $"Inquisitor {whom > -1 ? inquisitors[whom] : inquisitors[0]}"; - - // INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; - var cur_star, t, type, cha, dem, tem1, tem1_base, perc, popup; - t = 0; - type = 0; - cha = 0; - dem = 0; - tem1 = 0; - popup = 0; - perc = 0; - tem1_base = 0; - - cur_star = instance_nearest(x, y, obj_star); - - if (string_count("investigate", trade_goods) > 0) { - // Check for xenos or demon-equip items on those planets - //TODO update this to check weapon or artifact tags - var e = 0, ia = -1, ca = 0; - var _unit; - repeat (4400) { - if ((ca <= 10) && (ca >= 0)) { - ia += 1; - if (ia == 400) { - ca += 1; - ia = 1; - if (ca == 11) { - ca = -5; - } - } - if ((ca >= 0) && (ca < 11)) { - _unit = fetch_unit([ca, ia]); - if ((_unit.location_string == cur_star.name) && (_unit.planet_location > 0)) { - if ((_unit.role() == "Ork Sniper") && (obj_ini.race[ca][ia] != 1)) { - tem1_base = 3; - } - if ((_unit.role() == "Flash Git") && (obj_ini.race[ca][ia] != 1)) { - tem1_base = 3; - } - if ((_unit.role() == "Ranger") && (obj_ini.race[ca][ia] != 1)) { - tem1_base = 3; + if (((orbiting.owner == eFACTION.PLAYER || system_feature_bool(orbiting.p_feature, eP_FEATURES.MONASTERY)) || (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD)) && (trade_goods != "cancel_inspection") && valid) { + if (obj_controller.disposition[6] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + if (obj_controller.disposition[7] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + if (obj_controller.disposition[8] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + + if ((orbiting.p_owner[2] == 1) && (orbiting.p_heresy[2] >= 60)) { + scr_loyalty("Heretic Homeworld", "+"); + } + + var whom = -1; + whom = inquisitor; + var inquisitors = obj_controller.inquisitor; + var inquis_string = $"Inquisitor {whom > -1 ? inquisitors[whom] : inquisitors[0]}"; + + // INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; + var cur_star, t, type, cha, dem, tem1, tem1_base, perc, popup; + t = 0; + type = 0; + cha = 0; + dem = 0; + tem1 = 0; + popup = 0; + perc = 0; + tem1_base = 0; + + cur_star = instance_nearest(x, y, obj_star); + + if (string_count("investigate", trade_goods) > 0) { + // Check for xenos or demon-equip items on those planets + //TODO update this to check weapon or artifact tags + var e = 0, ia = -1, ca = 0; + var _unit; + repeat (4400) { + if ((ca <= 10) && (ca >= 0)) { + ia += 1; + if (ia == 400) { + ca += 1; + ia = 1; + if (ca == 11) { + ca = -5; } - if (_unit.equipped_artifact_tag("daemon")) { - tem1_base += 3; - dem += 1; + } + if ((ca >= 0) && (ca < 11)) { + _unit = fetch_unit([ca, ia]); + if ((_unit.location_string == cur_star.name) && (_unit.planet_location > 0)) { + if ((_unit.role() == "Ork Sniper") && (obj_ini.race[ca][ia] != 1)) { + tem1_base = 3; + } + if ((_unit.role() == "Flash Git") && (obj_ini.race[ca][ia] != 1)) { + tem1_base = 3; + } + if ((_unit.role() == "Ranger") && (obj_ini.race[ca][ia] != 1)) { + tem1_base = 3; + } + if (_unit.equipped_artifact_tag("daemon")) { + tem1_base += 3; + dem += 1; + } } } } } + repeat (cur_star.planets) { + t += 1; + inquisitor_contraband_take_popup(_cur_star, planet); + } + } else if (string_count("investigate", trade_goods) == 0) { + inquisition_inspection_logic(); } - repeat (cur_star.planets) { - t += 1; - inquisitor_contraband_take_popup(_cur_star, planet); + // End Test-Slave Incubator Crap + + if (obj_controller.known[eFACTION.INQUISITION] == 1) { + obj_controller.known[eFACTION.INQUISITION] = 3; } - } else if (string_count("investigate", trade_goods) == 0) { - inquisition_inspection_logic(); - } - // End Test-Slave Incubator Crap - - if (obj_controller.known[eFACTION.INQUISITION] == 1) { - obj_controller.known[eFACTION.INQUISITION] = 3; - } - if (obj_controller.known[eFACTION.INQUISITION] == 2) { - obj_controller.known[eFACTION.INQUISITION] = 4; - } - - orbiting = instance_nearest(x, y, obj_star); - - // 135; - if (obj_controller.loyalty_hidden <= 0) { - // obj_controller.alarm[7]=1;global.defeat=2; - var moo = false; - if ((obj_controller.penitent == 1) && (moo == false)) { - obj_controller.alarm[8] = 1; - moo = true; + if (obj_controller.known[eFACTION.INQUISITION] == 2) { + obj_controller.known[eFACTION.INQUISITION] = 4; } - if ((obj_controller.penitent == 0) && (moo == false)) { - scr_audience(4, "loyalty_zero", 0, "", 0, 0); + + orbiting = instance_nearest(x, y, obj_star); + + // 135; + if (obj_controller.loyalty_hidden <= 0) { + // obj_controller.alarm[7]=1;global.defeat=2; + var moo = false; + if ((obj_controller.penitent == 1) && (moo == false)) { + obj_controller.alarm[8] = 1; + moo = true; + } + if ((obj_controller.penitent == 0) && (moo == false)) { + scr_audience(4, "loyalty_zero", 0, "", 0, 0); + } } + + exit_star = distance_removed_star(x, y, choose(2, 3, 4)); + action_x = exit_star.x; + action_y = exit_star.y; + orbiting = exit_star; + set_fleet_movement(); + trade_goods = "|DELETE|"; + exit; } - - exit_star = distance_removed_star(x, y, choose(2, 3, 4)); - action_x = exit_star.x; - action_y = exit_star.y; - orbiting = exit_star; - set_fleet_movement(); - trade_goods = "|DELETE|"; - exit; } - } - - 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.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 (image_index>=4){ - with(obj_star){ - if (owner = eFACTION.TAU) and (present_fleets>0) and (tau_fleets=0){ - instance_create(x,y,obj_temp5); + + /*if (image_index>=4){ + with(obj_star){ + if (owner = eFACTION.TAU) and (present_fleets>0) and (tau_fleets=0){ + instance_create(x,y,obj_temp5); + } } - } - if (instance_exists(obj_temp5)){ - var wop;wop=instance_nearest(x,y,obj_temp5); - if (wop!=0) and (point_distance(x,y,wop.x,wop.y)<300) and (wop.x>5) and (wop.y>5){ - target_x=wop.x;target_y=wop.y; - home_x=x;home_y=y; - set_fleet_movement(); + if (instance_exists(obj_temp5)){ + var wop;wop=instance_nearest(x,y,obj_temp5); + if (wop!=0) and (point_distance(x,y,wop.x,wop.y)<300) and (wop.x>5) and (wop.y>5){ + target_x=wop.x;target_y=wop.y; + home_x=x;home_y=y; + set_fleet_movement(); + } } + with(obj_temp5){instance_destroy();} + }*/ } - with(obj_temp5){instance_destroy();} - }*/ - } - - if (owner == eFACTION.TYRANIDS) { - // Juggle bio-resources - if (capital_number * 2 > frigate_number) { - capital_number -= 1; - frigate_number += 2; - } - - if (capital_number * 4 > escort_number) { - var rand; - rand = choose(1, 2, 3, 4); - if (rand == 4) { - escort_number += 1; + + if (owner == eFACTION.TYRANIDS) { + // Juggle bio-resources + if (capital_number * 2 > frigate_number) { + capital_number -= 1; + frigate_number += 2; } - } - - if (capital_number > 0) { - var capitals_engaged = 0; - with (orbiting) { - for (var i = 1; i < planets; i++) { - if (capitals_engaged == capital_number) { - break; - } - if (p_type[i] != "Dead") { - p_tyranids[4] = 5; - capitals_engaged += 1; + + if (capital_number * 4 > escort_number) { + var rand; + rand = choose(1, 2, 3, 4); + if (rand == 4) { + escort_number += 1; + } + } + + if (capital_number > 0) { + var capitals_engaged = 0; + with (orbiting) { + for (var i = 1; i < planets; i++) { + if (capitals_engaged == capital_number) { + break; + } + if (p_type[i] != "Dead") { + p_tyranids[4] = 5; + capitals_engaged += 1; + } } } } - } - - var n = false; - with (orbiting) { - n = is_dead_star(); - } - - if (n) { - var xx, yy, good, plin, plin2; - xx = 0; - yy = 0; - good = 0; - plin = 0; - plin2 = 0; - - if (capital_number > 5) { - n = 5; + + var n = false; + with (orbiting) { + n = is_dead_star(); } - - instance_deactivate_object(orbiting); - - repeat (100) { - if (good != 5) { - xx = self.x + random_range(-300, 300); - yy = self.y + random_range(-300, 300); - if (good == 0) { - plin = instance_nearest(xx, yy, obj_star); - } - if ((good == 1) && (n == 5)) { - plin2 = instance_nearest(xx, yy, obj_star); - } - - good = !array_contains(plin.p_type, "dead"); - - if ((good == 1) && (n == 5)) { - if (!instance_exists(plin2)) { - exit; + + if (n) { + var xx, yy, good, plin, plin2; + xx = 0; + yy = 0; + good = 0; + plin = 0; + plin2 = 0; + + if (capital_number > 5) { + n = 5; + } + + instance_deactivate_object(orbiting); + + repeat (100) { + if (good != 5) { + xx = self.x + random_range(-300, 300); + yy = self.y + random_range(-300, 300); + if (good == 0) { + plin = instance_nearest(xx, yy, obj_star); } - if (!array_contains(plin.p_type, "dead")) { - good++; + if ((good == 1) && (n == 5)) { + plin2 = instance_nearest(xx, yy, obj_star); } - - var new_fleet; - new_fleet = instance_create(x, y, obj_en_fleet); - new_fleet.capital_number = floor(capital_number * 0.4); - new_fleet.frigate_number = floor(frigate_number * 0.4); - new_fleet.escort_number = floor(escort_number * 0.4); - - capital_number -= new_fleet.capital_number; - frigate_number -= new_fleet.frigate_number; - escort_number -= new_fleet.escort_number; - - new_fleet.owner = eFACTION.TYRANIDS; - new_fleet.sprite_index = spr_fleet_tyranid; - new_fleet.image_index = 1; - - /*with(new_fleet){ - var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); - if (ii<=1) then ii=1;image_index=ii; - }*/ - - new_fleet.action_x = plin2.x; - new_fleet.action_y = plin2.y; - with (new_fleet) { - set_fleet_movement(); + + good = !array_contains(plin.p_type, "dead"); + + if ((good == 1) && (n == 5)) { + if (!instance_exists(plin2)) { + exit; + } + if (!array_contains(plin.p_type, "dead")) { + good++; + } + + var new_fleet; + new_fleet = instance_create(x, y, obj_en_fleet); + new_fleet.capital_number = floor(capital_number * 0.4); + new_fleet.frigate_number = floor(frigate_number * 0.4); + new_fleet.escort_number = floor(escort_number * 0.4); + + capital_number -= new_fleet.capital_number; + frigate_number -= new_fleet.frigate_number; + escort_number -= new_fleet.escort_number; + + new_fleet.owner = eFACTION.TYRANIDS; + new_fleet.sprite_index = spr_fleet_tyranid; + new_fleet.image_index = 1; + + /*with(new_fleet){ + var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); + if (ii<=1) then ii=1;image_index=ii; + }*/ + + new_fleet.action_x = plin2.x; + new_fleet.action_y = plin2.y; + with (new_fleet) { + set_fleet_movement(); + } + break; } - break; - } - - if ((good == 1) && instance_exists(plin)) { - action_x = plin.x; - action_y = plin.y; - set_fleet_movement(); - if (n != 5) { - good = 5; + + if ((good == 1) && instance_exists(plin)) { + action_x = plin.x; + action_y = plin.y; + set_fleet_movement(); + if (n != 5) { + good = 5; + } } } } + instance_activate_object(obj_star); } - instance_activate_object(obj_star); } } - } - - if ((action == "move") && (action_eta > 5000)) { - var woop = instance_nearest(x, y, obj_star); - if (woop.storm == 0) { - action_eta -= 10000; - } else { - if (!instance_nearest(target_x, target_y, obj_star).storm) { + + if ((action == "move") && (action_eta > 5000)) { + var woop = instance_nearest(x, y, obj_star); + if (woop.storm == 0) { action_eta -= 10000; + } else { + if (!instance_nearest(target_x, target_y, obj_star).storm) { + action_eta -= 10000; + } } - } - } else if ((action == "move") && (action_eta < 5000)) { - if (instance_nearest(action_x, action_y, obj_star).storm > 0) { - exit; - } - if (action_x + action_y == 0) { - exit; - } - - var dos = 0; - dos = point_distance(x, y, action_x, action_y); - orbiting = dos / action_eta; - dir = point_direction(x, y, action_x, action_y); - - x = x + lengthdir_x(orbiting, dir); - y = y + lengthdir_y(orbiting, dir); - - action_eta -= 1; - - /*if (owner>5){ - - }*/ - - if ((action_eta == 2) && (owner == eFACTION.INQUISITION) && (inquisitor > -1)) { - inquisitor_ship_approaches(); - } else if (action_eta == 0) { - action = ""; - if (array_length(complex_route) > 0) { - var target_loc = star_by_name(complex_route[0]); - if (target_loc != "none") { - array_delete(complex_route, 0, 1); - action_x = target_loc.x; - action_y = target_loc.y; - target = target_loc; - set_fleet_movement(false); + } else if ((action == "move") && (action_eta < 5000)) { + if (instance_nearest(action_x, action_y, obj_star).storm > 0) { + exit; + } + if (action_x + action_y == 0) { + exit; + } + + var dos = 0; + dos = point_distance(x, y, action_x, action_y); + orbiting = dos / action_eta; + dir = point_direction(x, y, action_x, action_y); + + x = x + lengthdir_x(orbiting, dir); + y = y + lengthdir_y(orbiting, dir); + + action_eta -= 1; + + /*if (owner>5){ + + }*/ + + if ((action_eta == 2) && (owner == eFACTION.INQUISITION) && (inquisitor > -1)) { + inquisitor_ship_approaches(); + } else if (action_eta == 0) { + action = ""; + if (array_length(complex_route) > 0) { + var target_loc = star_by_name(complex_route[0]); + if (target_loc != "none") { + array_delete(complex_route, 0, 1); + action_x = target_loc.x; + action_y = target_loc.y; + target = target_loc; + set_fleet_movement(false); + } else { + complex_route = []; + fleet_arrival_logic(); + } } else { - complex_route = []; fleet_arrival_logic(); } - } else { - fleet_arrival_logic(); } } - } -}); - -/* */ -/* */ +} catch (_exception) { + handle_exception(_exception); +} diff --git a/objects/obj_en_fleet/Alarm_4.gml b/objects/obj_en_fleet/Alarm_4.gml index 16a1ff2fbf..4a104bd1b3 100644 --- a/objects/obj_en_fleet/Alarm_4.gml +++ b/objects/obj_en_fleet/Alarm_4.gml @@ -1,93 +1,21 @@ -try_and_report_loop("fleet alarm 4", function() { - if (action != "") { - var sys, sys_dist, mine, connected, fleet, cont; - sys_dist = 9999; - connected = 0; - cont = 0; - - fleet = instance_id_get(0); - sys = instance_nearest(action_x, action_y, obj_star); - sys_dist = point_distance(action_x, action_y, sys.x, sys.y); - act_dist = point_distance(x, y, sys.x, sys.y); - mine = instance_nearest(x, y, obj_star); - if ((mine.x == sys.x2) && (mine.y == sys.y2)) { - connected = 1; - } - - var eta; - eta = 0; - eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; - if (connected == 0) { - eta = eta * 2; - } - if (connected == 1) { - connected = 1; - } - - if ((owner == eFACTION.INQUISITION) && (action_eta < 2)) { - action_eta = 2; - } - // action_x=sys.x; - // action_y=sys.y; - action = "move"; - - if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { - action_eta += 10000; - } - - x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); - y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); - } - - if (action == "") { - var sys, sys_dist, mine, connected, fleet, cont, target_dist; - sys_dist = 9999; - connected = 0; - cont = 0; - target_dist = 0; - - fleet = id; - sys = instance_nearest(action_x, action_y, obj_star); - sys_dist = point_distance(action_x, action_y, sys.x, sys.y); - if (scr_valid_fleet_target(target)) { - target_dist = point_distance(x, y, target.action_x, target.action_y); - } else { - target = 0; - } - - act_dist = point_distance(x, y, sys.x, sys.y); - mine = instance_nearest(x, y, obj_star); - - // if (owner = eFACTION.TAU) then mine.tau_fleets-=1; - // if (owner = eFACTION.TAU) and (image_index!=1) then mine.tau_fleets-=1; - // mine.present_fleets-=1; - - connected = determine_warp_join(mine, sys); - cont = 1; - - if (cont == 1) { - cont = 20; - } - - if (cont == 20) { - // Move the entire fleet, don't worry about the other crap - turns_static = 0; - var eta = 0; - - if ((trade_goods != "") && (owner != eFACTION.TYRANIDS) && (owner != eFACTION.CHAOS) && (string_count("Inqis", trade_goods) == 0) && (string_count("merge", trade_goods) == 0) && (string_count("_her", trade_goods) == 0) && (trade_goods != "cancel_inspection") && (trade_goods != "return")) { - if (scr_valid_fleet_target(target)) { - if (target.action != "") { - if (target_dist > sys_dist) { - action_x = target.action_x; - action_y = target.action_y; - sys = instance_nearest(action_x, action_y, obj_star); - } - } - } else { - target = 0; - } +try { + if (action != "") { + var sys, sys_dist, mine, connected, fleet, cont; + sys_dist = 9999; + connected = 0; + cont = 0; + + fleet = instance_id_get(0); + sys = instance_nearest(action_x, action_y, obj_star); + sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + act_dist = point_distance(x, y, sys.x, sys.y); + mine = instance_nearest(x, y, obj_star); + if ((mine.x == sys.x2) && (mine.y == sys.y2)) { + connected = 1; } - + + var eta; + eta = 0; eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; if (connected == 0) { eta = eta * 2; @@ -95,34 +23,108 @@ try_and_report_loop("fleet alarm 4", function() { if (connected == 1) { connected = 1; } - - if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { - action_eta = eta; - if ((owner == eFACTION.INQUISITION) && (action_eta < 2) && (string_count("_her", trade_goods) == 0)) { - action_eta = 2; - } - } - - if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { - action_eta += 10000; + + if ((owner == eFACTION.INQUISITION) && (action_eta < 2)) { + action_eta = 2; } - // action_x=sys.x; // action_y=sys.y; action = "move"; - - if ((minimum_eta > action_eta) && (minimum_eta > 0)) { - action_eta = minimum_eta; - } - minimum_eta = 0; - if ((etah > action_eta) && (etah != 0)) { - action_eta = etah; + + if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { + action_eta += 10000; } - + x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); } - } - - etah = 0; -}); + + if (action == "") { + var sys, sys_dist, mine, connected, fleet, cont, target_dist; + sys_dist = 9999; + connected = 0; + cont = 0; + target_dist = 0; + + fleet = id; + sys = instance_nearest(action_x, action_y, obj_star); + sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + if (scr_valid_fleet_target(target)) { + target_dist = point_distance(x, y, target.action_x, target.action_y); + } else { + target = 0; + } + + act_dist = point_distance(x, y, sys.x, sys.y); + mine = instance_nearest(x, y, obj_star); + + // if (owner = eFACTION.TAU) then mine.tau_fleets-=1; + // if (owner = eFACTION.TAU) and (image_index!=1) then mine.tau_fleets-=1; + // mine.present_fleets-=1; + + connected = determine_warp_join(mine, sys); + cont = 1; + + if (cont == 1) { + cont = 20; + } + + if (cont == 20) { + // Move the entire fleet, don't worry about the other crap + turns_static = 0; + var eta = 0; + + if ((trade_goods != "") && (owner != eFACTION.TYRANIDS) && (owner != eFACTION.CHAOS) && (string_count("Inqis", trade_goods) == 0) && (string_count("merge", trade_goods) == 0) && (string_count("_her", trade_goods) == 0) && (trade_goods != "cancel_inspection") && (trade_goods != "return")) { + if (scr_valid_fleet_target(target)) { + if (target.action != "") { + if (target_dist > sys_dist) { + action_x = target.action_x; + action_y = target.action_y; + sys = instance_nearest(action_x, action_y, obj_star); + } + } + } else { + target = 0; + } + } + + eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; + if (connected == 0) { + eta = eta * 2; + } + if (connected == 1) { + connected = 1; + } + + if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { + action_eta = eta; + if ((owner == eFACTION.INQUISITION) && (action_eta < 2) && (string_count("_her", trade_goods) == 0)) { + action_eta = 2; + } + } + + if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { + action_eta += 10000; + } + + // action_x=sys.x; + // action_y=sys.y; + action = "move"; + + if ((minimum_eta > action_eta) && (minimum_eta > 0)) { + action_eta = minimum_eta; + } + minimum_eta = 0; + if ((etah > action_eta) && (etah != 0)) { + action_eta = etah; + } + + x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); + y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); + } + } + + etah = 0; +} catch (_exception) { + handle_exception(_exception); +} diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index 17e9e8d78d..69fc36ecfb 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -1,174 +1,176 @@ -try_and_report_loop("player alarm 1", function() { - var spid, dir; - spid = 0; - dir = 0; - - acted = 0; - - if (action == "Lost") { - set_fleet_location("Lost"); - exit; - } else if (action == "") { - spid = instance_nearest(x, y, obj_star); - // spid.present_fleets+=1; - spid.present_fleet[1] += 1; - if (spid.vision == 0) { - spid.vision = 1; - } - orbiting = spid; - - if ((orbiting != 0) && 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); +try { + var spid, dir; + spid = 0; + dir = 0; + + acted = 0; + + if (action == "Lost") { + set_fleet_location("Lost"); + exit; + } else if (action == "") { + spid = instance_nearest(x, y, obj_star); + // spid.present_fleets+=1; + spid.present_fleet[1] += 1; + if (spid.vision == 0) { + spid.vision = 1; + } + orbiting = spid; + + if ((orbiting != 0) && 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; } - orbiting.visited = 1; + + meet_system_governors(orbiting); } - - meet_system_governors(orbiting); - } - } else if (array_contains(FLEET_MOVE_OPTIONS, action)) { - var i; - set_fleet_location("Warp"); - - if (instance_nearest(action_x, action_y, obj_star).storm > 0) { - exit; - } - - spid = point_distance(x, y, action_x, action_y); - spid = spid / action_eta; - 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) != "none") { - enemies = true; - break; - } - } - if (enemies) { - instance_deactivate_object(id); - } + } else if (array_contains(FLEET_MOVE_OPTIONS, action)) { + var i; + set_fleet_location("Warp"); + + if (instance_nearest(action_x, action_y, obj_star).storm > 0) { + exit; } - 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; + + spid = point_distance(x, y, action_x, action_y); + spid = spid / action_eta; + 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"); } - steh.present_fleet[1] += 1; - orbiting = steh; - // show_message("Present Fleets at alarm[1]: "+string(steh.present_fleets)); - - meet_system_governors(steh); - - if ((steh.p_owner[1] == 5) || (steh.p_owner[2] == 5) || (steh.p_owner[3] == 5) || (steh.p_owner[4] == 5)) { - if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { - obj_controller.known[eFACTION.ECCLESIARCHY] = 1; + 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) != "none") { + 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 ((steh.owner == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0) && (obj_controller.known[eFACTION.ELDAR] == 0)) { - obj_controller.known[eFACTION.ELDAR] = 1; + if ((action_eta == 0) && (action == "crusade3")) { + // Popup here + scr_crusade(); + action = ""; } - 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 < 5; plan_num++) { - if (array_length(steh.p_feature[plan_num]) != 0) { - with (steh) { - scr_planetary_feature(plan_num); + + 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; + } + steh.present_fleet[1] += 1; + orbiting = steh; + // show_message("Present Fleets at alarm[1]: "+string(steh.present_fleets)); + + meet_system_governors(steh); + + if ((steh.p_owner[1] == 5) || (steh.p_owner[2] == 5) || (steh.p_owner[3] == 5) || (steh.p_owner[4] == 5)) { + 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 < 5; 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); } - 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); + + 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; - 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); - - // show_message("Dist: "+string(dist)+", Rando: "+string(rando)); - - 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; + + var steh; + 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); + + // show_message("Dist: "+string(dist)+", Rando: "+string(rando)); + + 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"); } - // Quene eldar introduction - // if (rando>=95) and (dist<=300) then show_message("MON'KEIGH"); } + + instance_activate_object(obj_star); } - - instance_activate_object(obj_star); - } -}); +} catch (_exception) { + handle_exception(_exception); +} diff --git a/objects/obj_turn_end/Alarm_0.gml b/objects/obj_turn_end/Alarm_0.gml index b1678e8978..31091af6e9 100644 --- a/objects/obj_turn_end/Alarm_0.gml +++ b/objects/obj_turn_end/Alarm_0.gml @@ -1,218 +1,219 @@ -// show_message("biiiiiIIIng"); -try_and_report_loop("battle alarm 0 loop", function() { - instance_activate_object(obj_star); - combating = 0; - - var i; - - i = 50; - repeat (50) { - i -= 1; - - if ((battles <= i) && (i >= 2)) { - if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == -50) && (battle_world[i - 1] > 0)) { - var tem1, tem2, tem3, tem4, tem5, tem6, tem7; - tem1 = battle[i - 1]; - tem2 = battle_location[i - 1]; - tem3 = battle_world[i - 1]; - tem4 = battle_opponent[i - 1]; - tem5 = battle_object[i - 1]; - tem6 = battle_pobject[i - 1]; - tem7 = battle_special[i - 1]; - - battle[i - 1] = battle[i]; - battle_location[i - 1] = battle_location[i]; - battle_world[i - 1] = battle_world[i]; - battle_opponent[i - 1] = battle_opponent[i]; - // battle_object[i-1]=battle_object[i]; - battle_pobject[i - 1] = battle_pobject[i]; - battle_special[i - 1] = battle_special[i]; - - battle[i] = tem1; - battle_location[i] = tem2; - battle_world[i] = tem3; - battle_opponent[i] = tem4; - battle_object[i] = tem5; - battle_pobject[i] = tem6; - battle_special[i] = tem7; +try { + instance_activate_object(obj_star); + combating = 0; + + var i; + + i = 50; + repeat (50) { + i -= 1; + + if ((battles <= i) && (i >= 2)) { + if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == -50) && (battle_world[i - 1] > 0)) { + var tem1, tem2, tem3, tem4, tem5, tem6, tem7; + tem1 = battle[i - 1]; + tem2 = battle_location[i - 1]; + tem3 = battle_world[i - 1]; + tem4 = battle_opponent[i - 1]; + tem5 = battle_object[i - 1]; + tem6 = battle_pobject[i - 1]; + tem7 = battle_special[i - 1]; + + battle[i - 1] = battle[i]; + battle_location[i - 1] = battle_location[i]; + battle_world[i - 1] = battle_world[i]; + battle_opponent[i - 1] = battle_opponent[i]; + // battle_object[i-1]=battle_object[i]; + battle_pobject[i - 1] = battle_pobject[i]; + battle_special[i - 1] = battle_special[i]; + + battle[i] = tem1; + battle_location[i] = tem2; + battle_world[i] = tem3; + battle_opponent[i] = tem4; + battle_object[i] = tem5; + battle_pobject[i] = tem6; + battle_special[i] = tem7; + } } } - } - - // Probably want something right here to organize the battle just in case - // Space battles first - // Ground battles after - - if ((battles > 0) && (current_battle <= battles)) { - var ii, xx, yy, good; - ii = 0; - good = 0; - - var battle_star = star_by_name(battle_location[current_battle]); - - if (battle_star != "none") { - // trying to find the star - obj_controller.x = battle_star.x; - obj_controller.y = battle_star.y; - show = current_battle; - - if (battle_world[current_battle] == -50) { - strin[1] = string(round(battle_pobject[current_battle].capital_number)); - strin[2] = string(round(battle_pobject[current_battle].frigate_number)); - strin[3] = string(round(battle_pobject[current_battle].escort_number)); - // pull health values here - strin[4] = string(round(battle_pobject[current_battle].capital_health)); - strin[5] = string(round(battle_pobject[current_battle].frigate_health)); - strin[6] = string(round(battle_pobject[current_battle].escort_health)); - - // pull enemy ships here - - var e = 1; - repeat (10) { - e += 1; - if (e == 11) { - e = 13; - } - if (battle_star.present_fleet[e] > 0) { - obj_controller.temp[1070] = battle_star.id; - obj_controller.temp[1071] = e; - obj_controller.temp[1072] = 0; - obj_controller.temp[1073] = 0; - obj_controller.temp[1074] = 0; - - with (obj_en_fleet) { - if ((orbiting == obj_controller.temp[1070]) && (owner == obj_controller.temp[1071])) { - obj_controller.temp[1072] += round(capital_number); - obj_controller.temp[1073] += round(frigate_number); - obj_controller.temp[1074] += round(escort_number); - } + + // Probably want something right here to organize the battle just in case + // Space battles first + // Ground battles after + + if ((battles > 0) && (current_battle <= battles)) { + var ii, xx, yy, good; + ii = 0; + good = 0; + + var battle_star = star_by_name(battle_location[current_battle]); + + if (battle_star != "none") { + // trying to find the star + obj_controller.x = battle_star.x; + obj_controller.y = battle_star.y; + show = current_battle; + + if (battle_world[current_battle] == -50) { + strin[1] = string(round(battle_pobject[current_battle].capital_number)); + strin[2] = string(round(battle_pobject[current_battle].frigate_number)); + strin[3] = string(round(battle_pobject[current_battle].escort_number)); + // pull health values here + strin[4] = string(round(battle_pobject[current_battle].capital_health)); + strin[5] = string(round(battle_pobject[current_battle].frigate_health)); + strin[6] = string(round(battle_pobject[current_battle].escort_health)); + + // pull enemy ships here + + var e = 1; + repeat (10) { + e += 1; + if (e == 11) { + e = 13; } - - var l1, l2; - l1 = 0; - l2 = 0; - if (obj_controller.faction_status[e] != "War") { - repeat (10) { - l1 += 1; - if ((allied_fleet[l1] == 0) && (l2 == 0)) { - l2 = l1; + if (battle_star.present_fleet[e] > 0) { + obj_controller.temp[1070] = battle_star.id; + obj_controller.temp[1071] = e; + obj_controller.temp[1072] = 0; + obj_controller.temp[1073] = 0; + obj_controller.temp[1074] = 0; + + with (obj_en_fleet) { + if ((orbiting == obj_controller.temp[1070]) && (owner == obj_controller.temp[1071])) { + obj_controller.temp[1072] += round(capital_number); + obj_controller.temp[1073] += round(frigate_number); + obj_controller.temp[1074] += round(escort_number); } } - allied_fleet[l2] = e; - acap[l2] = obj_controller.temp[1072]; - afri[l2] = obj_controller.temp[1073]; - aesc[l2] = obj_controller.temp[1074]; - } - if ((obj_controller.faction_status[e] == "War") || (e == 9) || (e == 13)) { - repeat (10) { - l1 += 1; - if ((enemy_fleet[l1] == 0) && (l2 == 0)) { - l2 = l1; + + var l1, l2; + l1 = 0; + l2 = 0; + if (obj_controller.faction_status[e] != "War") { + repeat (10) { + l1 += 1; + if ((allied_fleet[l1] == 0) && (l2 == 0)) { + l2 = l1; + } } + allied_fleet[l2] = e; + acap[l2] = obj_controller.temp[1072]; + afri[l2] = obj_controller.temp[1073]; + aesc[l2] = obj_controller.temp[1074]; + } + if ((obj_controller.faction_status[e] == "War") || (e == 9) || (e == 13)) { + repeat (10) { + l1 += 1; + if ((enemy_fleet[l1] == 0) && (l2 == 0)) { + l2 = l1; + } + } + enemy_fleet[l2] = e; + ecap[l2] = obj_controller.temp[1072]; + efri[l2] = obj_controller.temp[1073]; + eesc[l2] = obj_controller.temp[1074]; } - enemy_fleet[l2] = e; - ecap[l2] = obj_controller.temp[1072]; - efri[l2] = obj_controller.temp[1073]; - eesc[l2] = obj_controller.temp[1074]; } } } - } - - if (battle_world[current_battle] >= 1) { - scr_count_forces(string(battle_location[current_battle]), battle_world[current_battle], true); - - strin[1] = info_mahreens; - strin[2] = info_vehicles; - - if (info_mahreens + info_vehicles == 0) { - if (battles > current_battle) { - alarm[4] = 1; + + if (battle_world[current_battle] >= 1) { + scr_count_forces(string(battle_location[current_battle]), battle_world[current_battle], true); + + strin[1] = info_mahreens; + strin[2] = info_vehicles; + + if (info_mahreens + info_vehicles == 0) { + if (battles > current_battle) { + alarm[4] = 1; + } + if (battles == current_battle) { + alarm[1] = 1; + } } - if (battles == current_battle) { - alarm[1] = 1; + + strin[3] = ""; + + var tempy = 0; + tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; + + if ((tempy == 1) || (tempy == 2) || (tempy == 3)) { + var array_string = [ + "", + "Minimally", + "Lightly", + "Moderately", + "Highly", + "Extremely", + "Maximally" + ]; + var battle_fortification = battle_object[current_battle].p_fortified[battle_world[current_battle]]; + strin[3] = array_string[clamp(battle_fortification, 1, 6)]; } + + tempy = 0; + if (battle_opponent[current_battle] == 7) { + tempy = battle_object[current_battle].p_orks[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 8) { + tempy = battle_object[current_battle].p_tau[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 9) { + tempy = battle_object[current_battle].p_tyranids[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 10) { + tempy = battle_object[current_battle].p_traitors[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 13) { + tempy = battle_object[current_battle].p_necrons[battle_world[current_battle]]; + } + + if (tempy == 1) { + strin[4] = "Minimal Forces"; + } + if (tempy == 2) { + strin[4] = "Sparse Forces"; + } + if (tempy == 3) { + strin[4] = "Moderate Forces"; + } + if (tempy == 4) { + strin[4] = "Numerous Forces"; + } + if (tempy == 5) { + strin[4] = "Very Numerous"; + } + if (tempy == 6) { + strin[4] = "Overwhelming"; + } + + // if (battle_opponent[current_battle]=2) then obj_controller.alarm[7]=1; + obj_controller.cooldown = 9999; } - - strin[3] = ""; - - var tempy = 0; - tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; - - if ((tempy == 1) || (tempy == 2) || (tempy == 3)) { - var array_string = [ - "", - "Minimally", - "Lightly", - "Moderately", - "Highly", - "Extremely", - "Maximally" - ]; - var battle_fortification = battle_object[current_battle].p_fortified[battle_world[current_battle]]; - strin[3] = array_string[clamp(battle_fortification, 1, 6)]; - } - - tempy = 0; - if (battle_opponent[current_battle] == 7) { - tempy = battle_object[current_battle].p_orks[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 8) { - tempy = battle_object[current_battle].p_tau[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 9) { - tempy = battle_object[current_battle].p_tyranids[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 10) { - tempy = battle_object[current_battle].p_traitors[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 13) { - tempy = battle_object[current_battle].p_necrons[battle_world[current_battle]]; - } - - if (tempy == 1) { - strin[4] = "Minimal Forces"; - } - if (tempy == 2) { - strin[4] = "Sparse Forces"; - } - if (tempy == 3) { - strin[4] = "Moderate Forces"; - } - if (tempy == 4) { - strin[4] = "Numerous Forces"; - } - if (tempy == 5) { - strin[4] = "Very Numerous"; - } - if (tempy == 6) { - strin[4] = "Overwhelming"; - } - - // if (battle_opponent[current_battle]=2) then obj_controller.alarm[7]=1; - obj_controller.cooldown = 9999; - } - - if (obj_controller.zoomed == 1) { - with (obj_controller) { - scr_zoom(); + + if (obj_controller.zoomed == 1) { + with (obj_controller) { + scr_zoom(); + } } } + instance_activate_object(obj_star); } + instance_activate_object(obj_star); - } - - instance_activate_object(obj_star); - - if ((battle[1] == 0) || (current_battle > battles)) { - // This is temporary for the sake of testing - if (battle[1] == 0) { - obj_controller.x = first_x; - obj_controller.y = first_y; + + if ((battle[1] == 0) || (current_battle > battles)) { + // This is temporary for the sake of testing + if (battle[1] == 0) { + obj_controller.x = first_x; + obj_controller.y = first_y; + } + alarm[1] = 1; } - alarm[1] = 1; - } - - /* */ - /* */ -}); + + /* */ + /* */ +} catch (_exception) { + handle_exception(_exception); +} 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 fe6ba3cf7b..5631a041bb 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -280,7 +280,11 @@ function scr_enemy_ai_d() { } var garrison_mission = has_problem_planet_and_time(i, "provide_garrison", 0); if (garrison_mission > -1) { - try_and_report_loop("complete garrison mission", complete_garrison_mission, true, [i, garrison_mission]); + try { + complete_garrison_mission(i, garrison_mission) + } catch (_exception) { + handle_exception(_exception); + } } var _beast_hunt = has_problem_planet_and_time(i, "hunt_beast", 0); if (_beast_hunt > -1) { diff --git a/scripts/scr_logging_functions/scr_logging_functions.gml b/scripts/scr_logging_functions/scr_logging_functions.gml index 8fd07ed7fd..d9152a529e 100644 --- a/scripts/scr_logging_functions/scr_logging_functions.gml +++ b/scripts/scr_logging_functions/scr_logging_functions.gml @@ -136,24 +136,6 @@ function handle_exception(_exception, custom_title = STR_ERROR_MESSAGE_HEAD, cri handle_error(_header, _message, _stacktrace, critical, _report_title); } -/// @description Attempts to run a function and reports any errors caught. -/// @param {string} dev_marker - Developer marker for the error. -/// @param {function} func - The function to run. -/// @param {bool} turn_end - Whether to end the turn after an error. -/// @param {array} args - Arguments to pass to the function. -/// @param {function} catch_custom - Custom function to run on error. -/// @param {array} catch_args - Arguments to pass to the custom function. -function try_and_report_loop(dev_marker = "Generic Error", func, turn_end = true, args = [], catch_custom = 0, catch_args = []) { - try { - method_call(func, args); - } catch (_exception) { - handle_exception(_exception, string(STR_ERROR_MESSAGE_HEAD3, dev_marker), false, dev_marker); - if (is_method(catch_custom)) { - method_call(catch_custom, catch_args); - } - } -} - /// @description Shows a popup for errors triggered by an unexpected condition(s). /// @param {string} _message - The message to display to the user. /// @param {string} _header - Optional header for the popup (default: "Your game just encountered an error!"). diff --git a/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml b/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml index de9e87d813..d29adc46ff 100644 --- a/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml +++ b/scripts/scr_specialist_point_handler/scr_specialist_point_handler.gml @@ -141,7 +141,11 @@ function SpecialistPointHandler() constructor { static calculate_research_points = function(turn_end) { self.turn_end = turn_end; - try_and_report_loop("Specialist points logic", pre_error_wrapped_research_points); + try { + pre_error_wrapped_research_points(); + } catch (ex) { + handle_exception(ex); + } }; static new_tech_heretic_spawn = function() { From 49866bfb8e85d1a115b5d686ad62efacb104a19f Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:15:22 +0300 Subject: [PATCH 06/16] refactor: Nuke last two uses of try_and_report_loop() --- objects/obj_controller/Alarm_5.gml | 139 ++++++++++++++--------------- 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index eeae46eb68..bd935fbfbb 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -16,48 +16,46 @@ try { var novice_type = ""; var unit; - try_and_report_loop("chaos_spread", function() { - var times = max(1, round(turn / 150)); - if ((known[eFACTION.CHAOS] == 2) && (faction_defeated[eFACTION.CHAOS] == 0)) { - times += 1; - } - var xx3, yy3, plani, _star; - xx3 = irandom(room_width) + 1; - yy3 = irandom(room_height) + 1; - _star = instance_nearest(xx3, yy3, obj_star); - plani = floor(random(_star.planets)) + 1; - - // ** Chaos influence / corruption ** - if ((faction_gender[eFACTION.CHAOS] == 1) && (faction_defeated[eFACTION.CHAOS] == 0) && (turn >= chaos_turn)) { - repeat (times) { - if ((_star.p_type[plani] != "Dead") && (_star.planets > 0) && (turn >= 20)) { - var cathedral = 0; - if (planet_feature_bool(_star.p_feature[plani], eP_FEATURES.SORORITAS_CATHEDRAL) == 1) { - cathedral = choose(0, 1, 1); - } - - if (cathedral == 0) { - if ((_star.p_heresy[plani] >= 0) && (_star.p_heresy[plani] < 10)) { - _star.p_heresy[plani] += choose(0, 0, 0, 0, 0, 0, 0, 0, 5); - } else if ((_star.p_heresy[plani] >= 10) && (_star.p_heresy[plani] < 20)) { - _star.p_heresy[plani] += choose(-2, -2, -2, 5, 10, 15); - } else if ((_star.p_heresy[plani] >= 20) && (_star.p_heresy[plani] < 40)) { - _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10); - } else if ((_star.p_heresy[plani] >= 40) && (_star.p_heresy[plani] < 60)) { - _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10, 15); - } else if ((_star.p_heresy[plani] >= 60) && (_star.p_heresy[plani] < 100)) { - _star.p_heresy[plani] += choose(-1, 0, 0, 0, 0, 5, 10, 15); - } - } - if (_star.p_heresy[plani] < 0) { - _star.p_heresy[plani] = 0; + var times = max(1, round(turn / 150)); + if ((known[eFACTION.CHAOS] == 2) && (faction_defeated[eFACTION.CHAOS] == 0)) { + times += 1; + } + var xx3, yy3, plani, _star; + xx3 = irandom(room_width) + 1; + yy3 = irandom(room_height) + 1; + _star = instance_nearest(xx3, yy3, obj_star); + plani = floor(random(_star.planets)) + 1; + + // ** Chaos influence / corruption ** + if ((faction_gender[eFACTION.CHAOS] == 1) && (faction_defeated[eFACTION.CHAOS] == 0) && (turn >= chaos_turn)) { + repeat (times) { + if ((_star.p_type[plani] != "Dead") && (_star.planets > 0) && (turn >= 20)) { + var cathedral = 0; + if (planet_feature_bool(_star.p_feature[plani], eP_FEATURES.SORORITAS_CATHEDRAL) == 1) { + cathedral = choose(0, 1, 1); + } + + if (cathedral == 0) { + if ((_star.p_heresy[plani] >= 0) && (_star.p_heresy[plani] < 10)) { + _star.p_heresy[plani] += choose(0, 0, 0, 0, 0, 0, 0, 0, 5); + } else if ((_star.p_heresy[plani] >= 10) && (_star.p_heresy[plani] < 20)) { + _star.p_heresy[plani] += choose(-2, -2, -2, 5, 10, 15); + } else if ((_star.p_heresy[plani] >= 20) && (_star.p_heresy[plani] < 40)) { + _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10); + } else if ((_star.p_heresy[plani] >= 40) && (_star.p_heresy[plani] < 60)) { + _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10, 15); + } else if ((_star.p_heresy[plani] >= 60) && (_star.p_heresy[plani] < 100)) { + _star.p_heresy[plani] += choose(-1, 0, 0, 0, 0, 5, 10, 15); } } + if (_star.p_heresy[plani] < 0) { + _star.p_heresy[plani] = 0; + } } } - - instance_activate_object(obj_star); - }); + } + + instance_activate_object(obj_star); // ** Build new Imperial Ships ** build_planet_defence_fleets(); @@ -334,45 +332,44 @@ try { } } - try_and_report_loop("Secret Chaos Warlord spawn", function() { - if ((turn == 5) && (faction_gender[eFACTION.CHAOS] == 1)) { - // show_message("Turn 100"); - - var _star_found = false; - var _choice_star = noone; - var _stars = scr_get_stars(true); - for (var i = 0; i < array_length(_stars); i++) { - if (is_dead_star(_stars[i])) { - continue; - } - with (_stars[i]) { - if (owner == eFACTION.IMPERIUM && planets) { - if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { - _star_found = true; - _choice_star = self.id; - break; - } + if ((turn == 5) && (faction_gender[eFACTION.CHAOS] == 1)) { + // show_message("Turn 100"); + + var _star_found = false; + var _choice_star = noone; + var _stars = scr_get_stars(true); + for (var i = 0; i < array_length(_stars); i++) { + if (is_dead_star(_stars[i])) { + continue; + } + with (_stars[i]) { + if (owner == eFACTION.IMPERIUM && planets) { + if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { + _star_found = true; + _choice_star = self.id; + break; } } - if (_star_found) { - break; - } } if (_star_found) { - var _planet = array_random_element(planets_without_type("Dead", _choice_star)); - _choice_star.warlord[_planet] = 1; - array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); - - var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; - - _choice_star.p_heresy[_planet] += _heresy_inc; - - if (_choice_star.p_heresy[_planet] < 50) { - _choice_star.p_heresy_secret[_planet] = 10; - } + break; } } - }); + if (_star_found) { + var _planet = array_random_element(planets_without_type("Dead", _choice_star)); + _choice_star.warlord[_planet] = 1; + array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); + + var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; + + _choice_star.p_heresy[_planet] += _heresy_inc; + + if (_choice_star.p_heresy[_planet] < 50) { + _choice_star.p_heresy_secret[_planet] = 10; + } + } + } + // * Blood debt end * if ((blood_debt == 1) && (penitent == 1)) { penitent_turn += 1; From 394089c986a14a5f41edeb9785fd614d6474f011 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:17:17 +0300 Subject: [PATCH 07/16] style: Run Gobo --- objects/obj_controller/Alarm_5.gml | 1240 ++++++++--------- objects/obj_en_fleet/Alarm_1.gml | 730 +++++----- objects/obj_en_fleet/Alarm_4.gml | 220 +-- objects/obj_p_fleet/Alarm_1.gml | 304 ++-- objects/obj_turn_end/Alarm_0.gml | 394 +++--- scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml | 2 +- scripts/scr_kill_unit/scr_kill_unit.gml | 3 +- .../scr_logging_functions.gml | 16 +- .../scr_mission_functions.gml | 1 - 9 files changed, 1455 insertions(+), 1455 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index bd935fbfbb..77feb905d6 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -2,223 +2,195 @@ // TODO refactor try { - var recruit_count = 0; - var random_marine, marine_position; - var eq1 = 1, eq2 = 1, eq3 = 1, t = 0, r = 0; - var marine_company = 0; - var warn = "", w5 = 0; - var g1 = 0, g2 = 0; - var onceh = 0, stahp = 0; - var disc = 0, droll = 0; - var rund = 0; - var spikky = 0; - var roll = 0; - var novice_type = ""; - var unit; - - var times = max(1, round(turn / 150)); - if ((known[eFACTION.CHAOS] == 2) && (faction_defeated[eFACTION.CHAOS] == 0)) { - times += 1; - } - var xx3, yy3, plani, _star; - xx3 = irandom(room_width) + 1; - yy3 = irandom(room_height) + 1; - _star = instance_nearest(xx3, yy3, obj_star); - plani = floor(random(_star.planets)) + 1; - - // ** Chaos influence / corruption ** - if ((faction_gender[eFACTION.CHAOS] == 1) && (faction_defeated[eFACTION.CHAOS] == 0) && (turn >= chaos_turn)) { - repeat (times) { - if ((_star.p_type[plani] != "Dead") && (_star.planets > 0) && (turn >= 20)) { - var cathedral = 0; - if (planet_feature_bool(_star.p_feature[plani], eP_FEATURES.SORORITAS_CATHEDRAL) == 1) { - cathedral = choose(0, 1, 1); - } + var recruit_count = 0; + var random_marine, marine_position; + var eq1 = 1, eq2 = 1, eq3 = 1, t = 0, r = 0; + var marine_company = 0; + var warn = "", w5 = 0; + var g1 = 0, g2 = 0; + var onceh = 0, stahp = 0; + var disc = 0, droll = 0; + var rund = 0; + var spikky = 0; + var roll = 0; + var novice_type = ""; + var unit; - if (cathedral == 0) { - if ((_star.p_heresy[plani] >= 0) && (_star.p_heresy[plani] < 10)) { - _star.p_heresy[plani] += choose(0, 0, 0, 0, 0, 0, 0, 0, 5); - } else if ((_star.p_heresy[plani] >= 10) && (_star.p_heresy[plani] < 20)) { - _star.p_heresy[plani] += choose(-2, -2, -2, 5, 10, 15); - } else if ((_star.p_heresy[plani] >= 20) && (_star.p_heresy[plani] < 40)) { - _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10); - } else if ((_star.p_heresy[plani] >= 40) && (_star.p_heresy[plani] < 60)) { - _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10, 15); - } else if ((_star.p_heresy[plani] >= 60) && (_star.p_heresy[plani] < 100)) { - _star.p_heresy[plani] += choose(-1, 0, 0, 0, 0, 5, 10, 15); - } - } - if (_star.p_heresy[plani] < 0) { - _star.p_heresy[plani] = 0; - } + var times = max(1, round(turn / 150)); + if ((known[eFACTION.CHAOS] == 2) && (faction_defeated[eFACTION.CHAOS] == 0)) { + times += 1; + } + var xx3, yy3, plani, _star; + xx3 = irandom(room_width) + 1; + yy3 = irandom(room_height) + 1; + _star = instance_nearest(xx3, yy3, obj_star); + plani = floor(random(_star.planets)) + 1; + + // ** Chaos influence / corruption ** + if ((faction_gender[eFACTION.CHAOS] == 1) && (faction_defeated[eFACTION.CHAOS] == 0) && (turn >= chaos_turn)) { + repeat (times) { + if ((_star.p_type[plani] != "Dead") && (_star.planets > 0) && (turn >= 20)) { + var cathedral = 0; + if (planet_feature_bool(_star.p_feature[plani], eP_FEATURES.SORORITAS_CATHEDRAL) == 1) { + cathedral = choose(0, 1, 1); } - } - } - instance_activate_object(obj_star); - - // ** Build new Imperial Ships ** - build_planet_defence_fleets(); - - apothecary_training(); - chaplain_training(); - librarian_training(); - techmarine_training(); - - if (obj_ini.fleet_type != 1) { - with (obj_temp5) { - instance_destroy(); - } - with (obj_p_fleet) { - if (action != "") { - instance_create(x, y, obj_temp5); + if (cathedral == 0) { + if ((_star.p_heresy[plani] >= 0) && (_star.p_heresy[plani] < 10)) { + _star.p_heresy[plani] += choose(0, 0, 0, 0, 0, 0, 0, 0, 5); + } else if ((_star.p_heresy[plani] >= 10) && (_star.p_heresy[plani] < 20)) { + _star.p_heresy[plani] += choose(-2, -2, -2, 5, 10, 15); + } else if ((_star.p_heresy[plani] >= 20) && (_star.p_heresy[plani] < 40)) { + _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10); + } else if ((_star.p_heresy[plani] >= 40) && (_star.p_heresy[plani] < 60)) { + _star.p_heresy[plani] += choose(-2, -1, 0, 0, 0, 0, 0, 0, 5, 10, 15); + } else if ((_star.p_heresy[plani] >= 60) && (_star.p_heresy[plani] < 100)) { + _star.p_heresy[plani] += choose(-1, 0, 0, 0, 0, 5, 10, 15); + } } - if ((x < 0) || (x > room_width) || (y < 0) || (y > room_height)) { - instance_create(x, y, obj_temp5); + if (_star.p_heresy[plani] < 0) { + _star.p_heresy[plani] = 0; } } - if (instance_number(obj_temp5) >= instance_number(obj_p_fleet)) { - stahp = 1; - } - with (obj_temp5) { - instance_destroy(); - } } - - var recruits_finished = 0, recruit_first = ""; - - var total_recruits = 0; - var i = 0; - while (i < array_length(recruit_name)) { - if (recruit_name[i] == "") { - i++; - continue; - } - if (recruit_distance[i] <= 0) { - recruit_training[i] -= 1; + } + + instance_activate_object(obj_star); + + // ** Build new Imperial Ships ** + build_planet_defence_fleets(); + + apothecary_training(); + chaplain_training(); + librarian_training(); + techmarine_training(); + + if (obj_ini.fleet_type != 1) { + with (obj_temp5) { + instance_destroy(); + } + with (obj_p_fleet) { + if (action != "") { + instance_create(x, y, obj_temp5); } - if (recruit_training[i] <= 0) { - scr_add_man(obj_ini.role[100][12], 10, recruit_exp[i], recruit_name[i], recruit_corruption[i], false, "default", recruit_data[i]); - if (recruit_first == "") { - recruit_first = recruit_name[i]; - } - recruits_finished += 1; - array_delete(recruit_name, i, 1); - array_delete(recruit_corruption, i, 1); - array_delete(recruit_distance, i, 1); - array_delete(recruit_training, i, 1); - array_delete(recruit_exp, i, 1); - array_delete(recruit_data, i, 1); - continue; - } else { - total_recruits++; + if ((x < 0) || (x > room_width) || (y < 0) || (y > room_height)) { + instance_create(x, y, obj_temp5); } - i++; } - with (obj_ini) { - scr_company_order(10); + if (instance_number(obj_temp5) >= instance_number(obj_p_fleet)) { + stahp = 1; } - if (recruits_finished == 1) { - scr_alert("green", "recruitment", $"{obj_ini.role[100][12]} {recruit_first} has joined X Company.", 0, 0); - } else if (recruits_finished > 1) { - scr_alert("green", "recruitment", $"{recruits_finished}x {obj_ini.role[100][12]} have joined X Company.", 0, 0); + with (obj_temp5) { + instance_destroy(); } - - recruits = total_recruits; - - /* TODO implement Lamenters get Black Rage and story + } + + var recruits_finished = 0, recruit_first = ""; + + var total_recruits = 0; + var i = 0; + while (i < array_length(recruit_name)) { + if (recruit_name[i] == "") { + i++; + continue; + } + if (recruit_distance[i] <= 0) { + recruit_training[i] -= 1; + } + if (recruit_training[i] <= 0) { + scr_add_man(obj_ini.role[100][12], 10, recruit_exp[i], recruit_name[i], recruit_corruption[i], false, "default", recruit_data[i]); + if (recruit_first == "") { + recruit_first = recruit_name[i]; + } + recruits_finished += 1; + array_delete(recruit_name, i, 1); + array_delete(recruit_corruption, i, 1); + array_delete(recruit_distance, i, 1); + array_delete(recruit_training, i, 1); + array_delete(recruit_exp, i, 1); + array_delete(recruit_data, i, 1); + continue; + } else { + total_recruits++; + } + i++; + } + with (obj_ini) { + scr_company_order(10); + } + if (recruits_finished == 1) { + scr_alert("green", "recruitment", $"{obj_ini.role[100][12]} {recruit_first} has joined X Company.", 0, 0); + } else if (recruits_finished > 1) { + scr_alert("green", "recruitment", $"{recruits_finished}x {obj_ini.role[100][12]} have joined X Company.", 0, 0); + } + + recruits = total_recruits; + + /* TODO implement Lamenters get Black Rage and story if (turn=240) and (global.chapter_name="Lamenters"){ obj_ini.strin2+="Black Rage"; scr_popup("Geneseed Mutation","Your Chapter has begun to have visions and nightmares of Sanguinius' fall. The less mentally disciplined of your battle-brothers no longer are able to sleep soundly, waking from sleep in a screaming, frothing rage. It appears the Black Rage has returned.","black_rage",""); } */ - // ** Battlefield Loot ** - if (scr_has_adv("Tech-Scavengers")) { - var lroll1, lroll2, loot = ""; - lroll1 = roll_dice_chapter(1, 100, "low"); - lroll2 = roll_dice_chapter(1, 100, "low"); - if (lroll1 <= 5) { - loot = choose("Chainsword", "Bolt Pistol", "Combat Knife", "Narthecium"); - if (lroll2 <= 80) { - loot = choose("Power Sword", "Storm Bolter"); - } - if (lroll2 <= 60) { - loot = choose("Plasma Pistol", "Chainfist", "Lascannon", "Heavy Bolter", "Assault Cannon", "Bike"); - } - if (lroll2 <= 30) { - loot = choose("Artificer Armour", "Plasma Gun", "Chainfist", "Rosarius", "Psychic Hood"); - } - if (lroll2 <= 10) { - loot = choose("Terminator Armour", "Artificer Armour", "Dreadnought", "Plasma Gun", "Power Fist", "Thunder Hammer", "Iron Halo"); - } - var tix = "A " + string(loot) + " has been gifted to the Chapter."; - tix = string_replace(tix, "A A", "An A"); - tix = string_replace(tix, "A E", "An E"); - tix = string_replace(tix, "A I", "An I"); - tix = string_replace(tix, "A O", "An O"); - scr_add_item(string(loot), 1); - scr_alert("", "loot", tix, 0, 0); - } - } - imperial_navy_fleet_construction(); - - // ** Adeptus Mechanicus Geneseed Tithe ** - if ((gene_tithe == 0) && (faction_status[eFACTION.IMPERIUM] != "War")) { - gene_tithe = 24; - - var expected, txt = "", mech_mad = false; - var onceh = 0; - expected = max(1, round(obj_controller.gene_seed / 20)); - if (obj_controller.faction_status[eFACTION.MECHANICUS] == "War") { - mech_mad = true; - } - - if ((obj_controller.gene_seed <= 0) || (mech_mad == true)) { - onceh = 2; - gene_iou += 1; - loyalty -= 2; - loyalty_hidden -= 2; - txt = "No Gene-Seed for Adeptus Mechanicus tithe. High Lords of Terra IOU increased to " + string(gene_iou) + "."; - } - if (mech_mad == false) { - if ((obj_controller.gene_seed > 0) && (und_gene_vaults == 0) && (onceh == 0)) { - obj_controller.gene_seed -= expected; - onceh = 1; - if ((obj_controller.gene_seed >= gene_iou) && (gene_iou > 0)) { - expected += gene_iou; - obj_controller.gene_seed -= gene_iou; - gene_iou = 0; - onceh = 3; - } - for (var i = 0; i < 50; i++) { - if ((obj_controller.gene_seed < gene_iou) && (obj_controller.gene_seed > 0) && (gene_iou > 0)) { - expected += 1; - obj_controller.gene_seed -= 1; - gene_iou -= 1; - if (gene_iou == 0) { - onceh = 3; - } - } - } - - if (gene_iou < 0) { - gene_iou = 0; - } - - txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; - if (gene_iou > 0) { - txt += " IOU remains at " + string(gene_iou) + "."; - } - if (onceh == 3) { - txt += " IOU has been payed off."; - } - } - - if ((obj_controller.gene_seed > 0) && (und_gene_vaults > 0) && (onceh == 0)) { - expected = 1; - obj_controller.gene_seed -= expected; - onceh = 1; - + // ** Battlefield Loot ** + if (scr_has_adv("Tech-Scavengers")) { + var lroll1, lroll2, loot = ""; + lroll1 = roll_dice_chapter(1, 100, "low"); + lroll2 = roll_dice_chapter(1, 100, "low"); + if (lroll1 <= 5) { + loot = choose("Chainsword", "Bolt Pistol", "Combat Knife", "Narthecium"); + if (lroll2 <= 80) { + loot = choose("Power Sword", "Storm Bolter"); + } + if (lroll2 <= 60) { + loot = choose("Plasma Pistol", "Chainfist", "Lascannon", "Heavy Bolter", "Assault Cannon", "Bike"); + } + if (lroll2 <= 30) { + loot = choose("Artificer Armour", "Plasma Gun", "Chainfist", "Rosarius", "Psychic Hood"); + } + if (lroll2 <= 10) { + loot = choose("Terminator Armour", "Artificer Armour", "Dreadnought", "Plasma Gun", "Power Fist", "Thunder Hammer", "Iron Halo"); + } + var tix = "A " + string(loot) + " has been gifted to the Chapter."; + tix = string_replace(tix, "A A", "An A"); + tix = string_replace(tix, "A E", "An E"); + tix = string_replace(tix, "A I", "An I"); + tix = string_replace(tix, "A O", "An O"); + scr_add_item(string(loot), 1); + scr_alert("", "loot", tix, 0, 0); + } + } + imperial_navy_fleet_construction(); + + // ** Adeptus Mechanicus Geneseed Tithe ** + if ((gene_tithe == 0) && (faction_status[eFACTION.IMPERIUM] != "War")) { + gene_tithe = 24; + + var expected, txt = "", mech_mad = false; + var onceh = 0; + expected = max(1, round(obj_controller.gene_seed / 20)); + if (obj_controller.faction_status[eFACTION.MECHANICUS] == "War") { + mech_mad = true; + } + + if ((obj_controller.gene_seed <= 0) || (mech_mad == true)) { + onceh = 2; + gene_iou += 1; + loyalty -= 2; + loyalty_hidden -= 2; + txt = "No Gene-Seed for Adeptus Mechanicus tithe. High Lords of Terra IOU increased to " + string(gene_iou) + "."; + } + if (mech_mad == false) { + if ((obj_controller.gene_seed > 0) && (und_gene_vaults == 0) && (onceh == 0)) { + obj_controller.gene_seed -= expected; + onceh = 1; + if ((obj_controller.gene_seed >= gene_iou) && (gene_iou > 0)) { + expected += gene_iou; + obj_controller.gene_seed -= gene_iou; + gene_iou = 0; + onceh = 3; + } + for (var i = 0; i < 50; i++) { if ((obj_controller.gene_seed < gene_iou) && (obj_controller.gene_seed > 0) && (gene_iou > 0)) { expected += 1; obj_controller.gene_seed -= 1; @@ -227,497 +199,525 @@ try { onceh = 3; } } - - if (gene_iou < 0) { - gene_iou = 0; - } - - txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; - if (gene_iou > 0) { - txt += " IOU remains at " + string(gene_iou) + "."; - } - if (onceh == 3) { - txt += " IOU has been payed off."; - } } - - if (onceh != 2) { - scr_alert("green", "tithes", txt, 0, 0); - scr_event_log("", txt); - } - if (onceh == 2) { - scr_alert("red", "tithes", txt, 0, 0); - scr_event_log("red", txt); + + if (gene_iou < 0) { + gene_iou = 0; } - } - } - if (gene_sold > 0) { - disc = 0; - droll = 0; - gene_sold = floor(gene_sold * 75) / 100; - - if (gene_sold < 1) { - gene_sold = 0; - } - if (gene_sold >= 50) { - disc = round(gene_sold / 7); - droll = floor(random(100)) + 1; - - // Inquisition takes notice - if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { - var disp_change = -3; - if (gene_sold >= 100) { - disp_change = -5; - } - if (gene_sold >= 200) { - disp_change = -7; - } - if (gene_sold >= 400) { - disp_change = -10; - } - gene_sold = 0; - scr_audience(4, "gene_trade", disp_change, "", 2, 0); + + txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; + if (gene_iou > 0) { + txt += " IOU remains at " + string(gene_iou) + "."; } - } - } - if (gene_xeno > 0) { - disc = 0; - droll = 0; - gene_xeno = floor(gene_xeno * 90) / 100; - - if (gene_xeno < 1) { - gene_xeno = 0; - } - if (gene_xeno >= 5) { - disc = round(gene_xeno / 5); - droll = floor(random(100)) + 1; - - // Inquisition takes notice - if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { - gene_xeno = 99999; - alarm[8] = 1; + if (onceh == 3) { + txt += " IOU has been payed off."; } } - } - var p = 0, penitorium = 0, unit; - for (var c = 0; c < 11; c++) { - for (var e = 0; e < array_length(obj_ini.god[c]); e++) { - if (obj_ini.god[c][e] == 10) { - unit = fetch_unit([c, e]); - p += 1; - penit_co[p] = c; - penit_id[p] = e; - penitorium += 1; - unit.alter_loyalty(-1); - if ((unit.corruption < 90) && (unit.corruption > 0)) { - var heresy_old = 0, heresy_new = 0; - heresy_old = round((unit.corruption * unit.corruption) / 50) - 0.5; - heresy_new = (heresy_old * 50) / unit.corruption; - unit.corruption = max(0, heresy_new); + + if ((obj_controller.gene_seed > 0) && (und_gene_vaults > 0) && (onceh == 0)) { + expected = 1; + obj_controller.gene_seed -= expected; + onceh = 1; + + if ((obj_controller.gene_seed < gene_iou) && (obj_controller.gene_seed > 0) && (gene_iou > 0)) { + expected += 1; + obj_controller.gene_seed -= 1; + gene_iou -= 1; + if (gene_iou == 0) { + onceh = 3; } } - } - } - // STC Bonuses - if (obj_controller.stc_ships >= 6) { - //self healing ships logic - for (var v = 0; v < array_length(obj_ini.ship_hp); v++) { - if (obj_ini.ship[v] == "" || obj_ini.ship_hp[v] < 0) { - continue; - } - if (obj_ini.ship_hp[v] < obj_ini.ship_maxhp[v]) { - var _max = obj_ini.ship_maxhp[v]; - obj_ini.ship_hp[v] = min(_max, obj_ini.ship_hp[v] + round(_max * 0.06)); - } - } - } - - if ((turn == 5) && (faction_gender[eFACTION.CHAOS] == 1)) { - // show_message("Turn 100"); - var _star_found = false; - var _choice_star = noone; - var _stars = scr_get_stars(true); - for (var i = 0; i < array_length(_stars); i++) { - if (is_dead_star(_stars[i])) { - continue; + if (gene_iou < 0) { + gene_iou = 0; } - with (_stars[i]) { - if (owner == eFACTION.IMPERIUM && planets) { - if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { - _star_found = true; - _choice_star = self.id; - break; - } - } + + txt = string(expected) + " Gene-Seed sent to Adeptus Mechanicus for tithe."; + if (gene_iou > 0) { + txt += " IOU remains at " + string(gene_iou) + "."; } - if (_star_found) { - break; + if (onceh == 3) { + txt += " IOU has been payed off."; } } - if (_star_found) { - var _planet = array_random_element(planets_without_type("Dead", _choice_star)); - _choice_star.warlord[_planet] = 1; - array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); - - var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; - _choice_star.p_heresy[_planet] += _heresy_inc; - - if (_choice_star.p_heresy[_planet] < 50) { - _choice_star.p_heresy_secret[_planet] = 10; - } + if (onceh != 2) { + scr_alert("green", "tithes", txt, 0, 0); + scr_event_log("", txt); + } + if (onceh == 2) { + scr_alert("red", "tithes", txt, 0, 0); + scr_event_log("red", txt); } } + } + if (gene_sold > 0) { + disc = 0; + droll = 0; + gene_sold = floor(gene_sold * 75) / 100; - // * Blood debt end * - if ((blood_debt == 1) && (penitent == 1)) { - penitent_turn += 1; - // was -60 - penitent_turnly = ((penitent_turn * penitent_turn) - 512) * -1; - if (penitent_turnly > 0) { - penitent_turnly = 0; - } - penitent_current += penitent_turnly; - if (penitent_current <= 0) { - penitent = 0; - alarm[8] = 1; - } - if (penitent_end < 30000) { - penitent_end += 41000; - } - if ((penitent_current >= penitent_max) || (((obj_controller.millenium * 1000) + obj_controller.year) >= penitent_end)) { - penitent = 0; - if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { - scr_audience(4, "penitent_end", 0, "", 0, 0); - } - if (known[eFACTION.ECCLESIARCHY] >= 2) { - scr_audience(5, "penitent_end", 0, "", 0, 0); + if (gene_sold < 1) { + gene_sold = 0; + } + if (gene_sold >= 50) { + disc = round(gene_sold / 7); + droll = floor(random(100)) + 1; + + // Inquisition takes notice + if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { + var disp_change = -3; + if (gene_sold >= 100) { + disp_change = -5; } - disposition[eFACTION.IMPERIUM] += 20; - disposition[eFACTION.MECHANICUS] += 15; - disposition[eFACTION.INQUISITION] += 20; - disposition[eFACTION.ECCLESIARCHY] += 20; - var o = 0; - if (scr_has_adv("Reverent Guardians")) { - o = 500; + if (gene_sold >= 200) { + disp_change = -7; } - if (o > 100) { - obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + if (gene_sold >= 400) { + disp_change = -10; } - scr_event_log("", "Blood Debt payed off. You may once more recruit Astartes."); + gene_sold = 0; + scr_audience(4, "gene_trade", disp_change, "", 2, 0); } } - // * Penitent Crusade end * - if ((penitent == 1) && (blood_debt == 0)) { - penitent_turn += 1; - penitent_current += 1; - penitent_turnly = 0; - - if (penitent_current <= 0) { - penitent = 0; + } + if (gene_xeno > 0) { + disc = 0; + droll = 0; + gene_xeno = floor(gene_xeno * 90) / 100; + + if (gene_xeno < 1) { + gene_xeno = 0; + } + if (gene_xeno >= 5) { + disc = round(gene_xeno / 5); + droll = floor(random(100)) + 1; + + // Inquisition takes notice + if ((droll <= disc) && (obj_controller.known[eFACTION.INQUISITION] != 0)) { + gene_xeno = 99999; alarm[8] = 1; } - if (penitent_current >= penitent_max) { - penitent = 0; - if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { - scr_audience(4, "penitent_end", 0, "", 0, 0); - } - if (known[eFACTION.ECCLESIARCHY] >= 2) { - scr_audience(5, "penitent_end", 0, "", 0, 0); - } - disposition[eFACTION.IMPERIUM] += 20; - disposition[eFACTION.MECHANICUS] += 15; - disposition[eFACTION.IMPERIUM] += 20; - disposition[eFACTION.ECCLESIARCHY] += 20; - var o = 0; - if (scr_has_adv("Reverent Guardians")) { - o = 500; - } - if (o > 100) { - obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + } + } + var p = 0, penitorium = 0, unit; + for (var c = 0; c < 11; c++) { + for (var e = 0; e < array_length(obj_ini.god[c]); e++) { + if (obj_ini.god[c][e] == 10) { + unit = fetch_unit([c, e]); + p += 1; + penit_co[p] = c; + penit_id[p] = e; + penitorium += 1; + unit.alter_loyalty(-1); + if ((unit.corruption < 90) && (unit.corruption > 0)) { + var heresy_old = 0, heresy_new = 0; + heresy_old = round((unit.corruption * unit.corruption) / 50) - 0.5; + heresy_new = (heresy_old * 50) / unit.corruption; + unit.corruption = max(0, heresy_new); } - scr_event_log("", "Penitent Crusade ends. You may once more recruit Astartes."); } } - // ** Ork WAAAAGH ** - if (((turn >= irandom(200) + 100) || (obj_ini.fleet_type == eFACTION.MECHANICUS)) && (faction_defeated[eFACTION.ORK] == 0)) {} - - if (known[eFACTION.ECCLESIARCHY] == 1) { - spikky = choose(0, 1, 1); - if (spikky) { - var _topic = faction_status[eFACTION.ECCLESIARCHY] == "War" ? "declare_war" : "intro"; - scr_audience(eFACTION.ECCLESIARCHY, _topic); + } + // STC Bonuses + if (obj_controller.stc_ships >= 6) { + //self healing ships logic + for (var v = 0; v < array_length(obj_ini.ship_hp); v++) { + if (obj_ini.ship[v] == "" || obj_ini.ship_hp[v] < 0) { + continue; + } + if (obj_ini.ship_hp[v] < obj_ini.ship_maxhp[v]) { + var _max = obj_ini.ship_maxhp[v]; + obj_ini.ship_hp[v] = min(_max, obj_ini.ship_hp[v] + round(_max * 0.06)); } } - if ((known[eFACTION.ELDAR] == 1) && (faction_defeated[eFACTION.ELDAR] == 0)) { - spikky = choose(0, 1); - if (spikky == 1) { - scr_audience(eFACTION.ELDAR, "intro1"); + } + + if ((turn == 5) && (faction_gender[eFACTION.CHAOS] == 1)) { + // show_message("Turn 100"); + + var _star_found = false; + var _choice_star = noone; + var _stars = scr_get_stars(true); + for (var i = 0; i < array_length(_stars); i++) { + if (is_dead_star(_stars[i])) { + continue; + } + with (_stars[i]) { + if (owner == eFACTION.IMPERIUM && planets) { + if (scr_orbiting_fleet(eFACTION.IMPERIUM) != "none") { + _star_found = true; + _choice_star = self.id; + break; + } + } + } + if (_star_found) { + break; } } - if ((known[eFACTION.ORK] == 0.5) && (faction_defeated[eFACTION.ORK] == 0)) { - if (1 == irandom(7)) { - scr_audience(eFACTION.ORK, "intro"); + if (_star_found) { + var _planet = array_random_element(planets_without_type("Dead", _choice_star)); + _choice_star.warlord[_planet] = 1; + array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); + + var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; + + _choice_star.p_heresy[_planet] += _heresy_inc; + + if (_choice_star.p_heresy[_planet] < 50) { + _choice_star.p_heresy_secret[_planet] = 10; } } - if ((known[eFACTION.TAU] == 1) && (faction_defeated[eFACTION.TAU] == 0)) { - scr_audience(eFACTION.TAU, "intro"); + } + + // * Blood debt end * + if ((blood_debt == 1) && (penitent == 1)) { + penitent_turn += 1; + // was -60 + penitent_turnly = ((penitent_turn * penitent_turn) - 512) * -1; + if (penitent_turnly > 0) { + penitent_turnly = 0; + } + penitent_current += penitent_turnly; + if (penitent_current <= 0) { + penitent = 0; + alarm[8] = 1; + } + if (penitent_end < 30000) { + penitent_end += 41000; } - // ** Quests here ** - // 135 ; quests - for (var i = 1; i <= 40; i++) { - if ((quest_end[i] <= turn) && (quest[i] != "")) { - scr_quest(1, quest[i], quest_faction[i], 0); - quest[i] = ""; + if ((penitent_current >= penitent_max) || (((obj_controller.millenium * 1000) + obj_controller.year) >= penitent_end)) { + penitent = 0; + if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { + scr_audience(4, "penitent_end", 0, "", 0, 0); } - if ((quest[i] == "") && (quest[i + 1] != "")) { - quest[i] = quest[i + 1]; - quest_faction[i] = quest_faction[i + 1]; - quest_end[i] = quest_end[i + 1]; - quest[i + 1] += ""; - quest_faction[i + 1] = 0; - quest_end[i + 1] = 0; + if (known[eFACTION.ECCLESIARCHY] >= 2) { + scr_audience(5, "penitent_end", 0, "", 0, 0); } + disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.MECHANICUS] += 15; + disposition[eFACTION.INQUISITION] += 20; + disposition[eFACTION.ECCLESIARCHY] += 20; + var o = 0; + if (scr_has_adv("Reverent Guardians")) { + o = 500; + } + if (o > 100) { + obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + } + scr_event_log("", "Blood Debt payed off. You may once more recruit Astartes."); } - // ** Inquisition stuff here ** - if (disposition[eFACTION.ELDAR] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (disposition[eFACTION.ORK] >= 60) { - scr_loyalty("Xeno Associate", "+"); + } + // * Penitent Crusade end * + if ((penitent == 1) && (blood_debt == 0)) { + penitent_turn += 1; + penitent_current += 1; + penitent_turnly = 0; + + if (penitent_current <= 0) { + penitent = 0; + alarm[8] = 1; } - if (disposition[eFACTION.TAU] >= 60) { - scr_loyalty("Xeno Associate", "+"); + if (penitent_current >= penitent_max) { + penitent = 0; + if ((known[eFACTION.INQUISITION] == 2) || (known[eFACTION.INQUISITION] >= 4)) { + scr_audience(4, "penitent_end", 0, "", 0, 0); + } + if (known[eFACTION.ECCLESIARCHY] >= 2) { + scr_audience(5, "penitent_end", 0, "", 0, 0); + } + disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.MECHANICUS] += 15; + disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.ECCLESIARCHY] += 20; + var o = 0; + if (scr_has_adv("Reverent Guardians")) { + o = 500; + } + if (o > 100) { + obj_controller.disposition[eFACTION.ECCLESIARCHY] += 10; + } + scr_event_log("", "Penitent Crusade ends. You may once more recruit Astartes."); } - - var loyalty_counter = 0; - loyalty_counter = scr_role_count(obj_ini.role[100][15], ""); - if (loyalty_counter == 0) { - scr_loyalty("Lack of Apothecary", "+"); + } + // ** Ork WAAAAGH ** + if (((turn >= irandom(200) + 100) || (obj_ini.fleet_type == eFACTION.MECHANICUS)) && (faction_defeated[eFACTION.ORK] == 0)) {} + + if (known[eFACTION.ECCLESIARCHY] == 1) { + spikky = choose(0, 1, 1); + if (spikky) { + var _topic = faction_status[eFACTION.ECCLESIARCHY] == "War" ? "declare_war" : "intro"; + scr_audience(eFACTION.ECCLESIARCHY, _topic); } - - loyalty_counter = scr_role_count(obj_ini.role[100][14], ""); - if (loyalty_counter == 0) { - scr_loyalty("Undevout", "+"); + } + if ((known[eFACTION.ELDAR] == 1) && (faction_defeated[eFACTION.ELDAR] == 0)) { + spikky = choose(0, 1); + if (spikky == 1) { + scr_audience(eFACTION.ELDAR, "intro1"); } - // TODO in another PR rework how Non-Codex Size is determined, perhaps the inquisition needs to pass some checks or do an investigation event - // which you could eventually interrupt (kill the team) and cover it up? - if (marines >= 1050) { - scr_loyalty("Non-Codex Size", "+"); + } + if ((known[eFACTION.ORK] == 0.5) && (faction_defeated[eFACTION.ORK] == 0)) { + if (1 == irandom(7)) { + scr_audience(eFACTION.ORK, "intro"); } - - var last_inquisitor_inspection = 0; - if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { - last_inquisitor_inspection = last_world_inspection; + } + if ((known[eFACTION.TAU] == 1) && (faction_defeated[eFACTION.TAU] == 0)) { + scr_audience(eFACTION.TAU, "intro"); + } + // ** Quests here ** + // 135 ; quests + for (var i = 1; i <= 40; i++) { + if ((quest_end[i] <= turn) && (quest[i] != "")) { + scr_quest(1, quest[i], quest_faction[i], 0); + quest[i] = ""; + } + if ((quest[i] == "") && (quest[i + 1] != "")) { + quest[i] = quest[i + 1]; + quest_faction[i] = quest_faction[i + 1]; + quest_end[i] = quest_end[i + 1]; + quest[i + 1] += ""; + quest_faction[i + 1] = 0; + quest_end[i + 1] = 0; } - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - last_inquisitor_inspection = last_fleet_inspection; + } + // ** Inquisition stuff here ** + if (disposition[eFACTION.ELDAR] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + if (disposition[eFACTION.ORK] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + if (disposition[eFACTION.TAU] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + + var loyalty_counter = 0; + loyalty_counter = scr_role_count(obj_ini.role[100][15], ""); + if (loyalty_counter == 0) { + scr_loyalty("Lack of Apothecary", "+"); + } + + loyalty_counter = scr_role_count(obj_ini.role[100][14], ""); + if (loyalty_counter == 0) { + scr_loyalty("Undevout", "+"); + } + // TODO in another PR rework how Non-Codex Size is determined, perhaps the inquisition needs to pass some checks or do an investigation event + // which you could eventually interrupt (kill the team) and cover it up? + if (marines >= 1050) { + scr_loyalty("Non-Codex Size", "+"); + } + + var last_inquisitor_inspection = 0; + if (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD) { + last_inquisitor_inspection = last_world_inspection; + } + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + last_inquisitor_inspection = last_fleet_inspection; + } + + var inspec = false; + if ((loyalty >= 85) && ((last_inquisitor_inspection + 59) < turn)) { + inspec = true; + } + if ((loyalty >= 70) && (loyalty < 85) && ((last_inquisitor_inspection + 47) < turn)) { + inspec = true; + } + if ((loyalty >= 50) && (loyalty < 70) && ((last_inquisitor_inspection + 35) < turn)) { + inspec = true; + } + if ((loyalty < 50) && ((last_inquisitor_inspection + 11 + choose(1, 2, 3, 4)) < turn)) { + inspec = true; + } + + if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { + if ((instance_number(obj_p_fleet) == 1) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { + // Might be crusading, right? + if ((obj_p_fleet.x < 0) || (obj_p_fleet.x > room_width) || (obj_p_fleet.y < 0) || (obj_p_fleet.y > room_height)) { + inspec = false; + } } - - var inspec = false; - if ((loyalty >= 85) && ((last_inquisitor_inspection + 59) < turn)) { - inspec = true; + if (instance_number(obj_p_fleet) == 0) { + inspec = false; } - if ((loyalty >= 70) && (loyalty < 85) && ((last_inquisitor_inspection + 47) < turn)) { - inspec = true; + } + instance_activate_object(obj_p_fleet); + + //setup inquisitor inspections + var inquisitor_fleet_count = 0; + with (obj_fleet) { + if (owner == eFACTION.INQUISITION) { + inquisitor_fleet_count++; } - if ((loyalty >= 50) && (loyalty < 70) && ((last_inquisitor_inspection + 35) < turn)) { - inspec = true; + } + + inspec = inspec && faction_status[eFACTION.INQUISITION] != "War" && inquisitor_fleet_count == 0; + if (inspec) { + new_inquisitor_inspection(); + } + + with (obj_temp6) { + instance_destroy(); + } + + for (var i = 1; i <= 10; i++) { + if ((turns_ignored[i] == 0) && (annoyed[i] > 0)) { + annoyed[i] -= 1; } - if ((loyalty < 50) && ((last_inquisitor_inspection + 11 + choose(1, 2, 3, 4)) < turn)) { - inspec = true; + } + + // ** Various checks for imperium and faction relations ** + try { + event_end_turn_action(); + } catch (_exception) { + handle_exception(_exception); + } + // Right here need to sort the battles within the obj_turn_end + with (obj_turn_end) { + scr_battle_sort(); + } + + for (var i = 1; i <= 10; i++) { + if ((turns_ignored[i] > 0) && (turns_ignored[i] < 500)) { + turns_ignored[i] -= 1; } - - if (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD) { - if ((instance_number(obj_p_fleet) == 1) && (obj_ini.fleet_type == ePLAYER_BASE.HOME_WORLD)) { - // Might be crusading, right? - if ((obj_p_fleet.x < 0) || (obj_p_fleet.x > room_width) || (obj_p_fleet.y < 0) || (obj_p_fleet.y > room_height)) { - inspec = false; - } - } - if (instance_number(obj_p_fleet) == 0) { - inspec = false; - } + } + if ((known[eFACTION.ELDAR] >= 2) && (faction_gender[6] == 2) && (turn % 10 == 0)) { + turns_ignored[6] += floor(random_range(0, 6)); + } + + with (obj_ground_mission) { + instance_destroy(); + } + scr_random_event(true); + + // ** Random events here ** + if ((hurssy_time > 0) && (hurssy > 0)) { + hurssy_time -= 1; + } + if ((hurssy_time == 0) && (hurssy > 0)) { + hurssy_time = -1; + hurssy = 0; + } + with (obj_p_fleet) { + if ((hurssy_time > 0) && (hurssy > 0)) { + hurssy_time -= 1; } - instance_activate_object(obj_p_fleet); - - //setup inquisitor inspections - var inquisitor_fleet_count = 0; - with (obj_fleet) { - if (owner == eFACTION.INQUISITION) { - inquisitor_fleet_count++; - } + if ((hurssy_time == 0) && (hurssy > 0)) { + hurssy_time = -1; + hurssy = 0; } - - inspec = inspec && faction_status[eFACTION.INQUISITION] != "War" && inquisitor_fleet_count == 0; - if (inspec) { - new_inquisitor_inspection(); + } + with (obj_star) { + if ((p_hurssy_time[1] > 0) && (p_hurssy[1] > 0)) { + p_hurssy_time[1] -= 1; } - - with (obj_temp6) { - instance_destroy(); + if ((p_hurssy_time[1] == 0) && (p_hurssy[1] > 0)) { + p_hurssy_time[1] = -1; + p_hurssy[1] = 0; } - - for (var i = 1; i <= 10; i++) { - if ((turns_ignored[i] == 0) && (annoyed[i] > 0)) { - annoyed[i] -= 1; - } + if ((p_hurssy_time[2] > 0) && (p_hurssy[2] > 0)) { + p_hurssy_time[2] -= 1; } - - // ** Various checks for imperium and faction relations ** - try { - event_end_turn_action(); - } catch (_exception) { - handle_exception(_exception); + if ((p_hurssy_time[2] == 0) && (p_hurssy[2] > 0)) { + p_hurssy_time[2] = -1; + p_hurssy[2] = 0; } - // Right here need to sort the battles within the obj_turn_end - with (obj_turn_end) { - scr_battle_sort(); + if ((p_hurssy_time[3] > 0) && (p_hurssy[3] > 0)) { + p_hurssy_time[3] -= 1; } - - for (var i = 1; i <= 10; i++) { - if ((turns_ignored[i] > 0) && (turns_ignored[i] < 500)) { - turns_ignored[i] -= 1; - } + if ((p_hurssy_time[3] == 0) && (p_hurssy[3] > 0)) { + p_hurssy_time[3] = -1; + p_hurssy[3] = 0; } - if ((known[eFACTION.ELDAR] >= 2) && (faction_gender[6] == 2) && (turn % 10 == 0)) { - turns_ignored[6] += floor(random_range(0, 6)); + if ((p_hurssy_time[4] > 0) && (p_hurssy[4] > 0)) { + p_hurssy_time[4] -= 1; } - - with (obj_ground_mission) { - instance_destroy(); + if ((p_hurssy_time[4] == 0) && (p_hurssy[4] > 0)) { + p_hurssy_time[4] = -1; + p_hurssy[4] = 0; } - scr_random_event(true); - - // ** Random events here ** - if ((hurssy_time > 0) && (hurssy > 0)) { - hurssy_time -= 1; + } + + if (turn == 2) { + if ((obj_ini.master_name == "Zakis Randi") || (global.chapter_name == "Knights Inductor") && (obj_controller.faction_status[eFACTION.IMPERIUM] != "War")) { + alarm[8] = 1; } - if ((hurssy_time == 0) && (hurssy > 0)) { - hurssy_time = -1; - hurssy = 0; + } + // ** Player-set events ** + if ((fest_scheduled > 0) && (fest_repeats > 0)) { + var lock = "", cm_present = false; + fest_repeats -= 1; + lock = scr_master_loc(); + + if ((fest_sid > 0) && (obj_ini.ship[fest_sid] == lock)) { + cm_present = true; } - with (obj_p_fleet) { - if ((hurssy_time > 0) && (hurssy > 0)) { - hurssy_time -= 1; - } - if ((hurssy_time == 0) && (hurssy > 0)) { - hurssy_time = -1; - hurssy = 0; - } + if ((fest_wid > 0) && (string(fest_star) + "." + string(fest_wid) == lock)) { + cm_present = true; } - with (obj_star) { - if ((p_hurssy_time[1] > 0) && (p_hurssy[1] > 0)) { - p_hurssy_time[1] -= 1; - } - if ((p_hurssy_time[1] == 0) && (p_hurssy[1] > 0)) { - p_hurssy_time[1] = -1; - p_hurssy[1] = 0; + + if (cm_present == true) { + var imag = ""; + + if (fest_type == "Great Feast") { + imag = "event_feast"; } - if ((p_hurssy_time[2] > 0) && (p_hurssy[2] > 0)) { - p_hurssy_time[2] -= 1; + if (fest_type == "Tournament") { + imag = "event_tournament"; } - if ((p_hurssy_time[2] == 0) && (p_hurssy[2] > 0)) { - p_hurssy_time[2] = -1; - p_hurssy[2] = 0; + if (fest_type == "Deathmatch") { + imag = "event_deathmatch"; } - if ((p_hurssy_time[3] > 0) && (p_hurssy[3] > 0)) { - p_hurssy_time[3] -= 1; + if (fest_type == "Imperial Mass") { + imag = "event_mass"; } - if ((p_hurssy_time[3] == 0) && (p_hurssy[3] > 0)) { - p_hurssy_time[3] = -1; - p_hurssy[3] = 0; + if (fest_type == "Cult Sermon") { + imag = "event_ccult"; } - if ((p_hurssy_time[4] > 0) && (p_hurssy[4] > 0)) { - p_hurssy_time[4] -= 1; + if (fest_type == "Chapter Relic") { + imag = "event_ccrelic"; } - if ((p_hurssy_time[4] == 0) && (p_hurssy[4] > 0)) { - p_hurssy_time[4] = -1; - p_hurssy[4] = 0; + if (fest_type == "Triumphal March") { + imag = "event_march"; } - } - - if (turn == 2) { - if ((obj_ini.master_name == "Zakis Randi") || (global.chapter_name == "Knights Inductor") && (obj_controller.faction_status[eFACTION.IMPERIUM] != "War")) { - alarm[8] = 1; + + if (fest_wid > 0) { + scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on " + string(fest_star) + " " + scr_roman(fest_wid) + ". Would you like to spectate the event?", imag, ""); } - } - // ** Player-set events ** - if ((fest_scheduled > 0) && (fest_repeats > 0)) { - var lock = "", cm_present = false; - fest_repeats -= 1; - lock = scr_master_loc(); - - if ((fest_sid > 0) && (obj_ini.ship[fest_sid] == lock)) { - cm_present = true; - } - if ((fest_wid > 0) && (string(fest_star) + "." + string(fest_wid) == lock)) { - cm_present = true; - } - - if (cm_present == true) { - var imag = ""; - - if (fest_type == "Great Feast") { - imag = "event_feast"; - } - if (fest_type == "Tournament") { - imag = "event_tournament"; - } - if (fest_type == "Deathmatch") { - imag = "event_deathmatch"; - } - if (fest_type == "Imperial Mass") { - imag = "event_mass"; - } - if (fest_type == "Cult Sermon") { - imag = "event_ccult"; - } - if (fest_type == "Chapter Relic") { - imag = "event_ccrelic"; - } - if (fest_type == "Triumphal March") { - imag = "event_march"; - } - - if (fest_wid > 0) { - scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on " + string(fest_star) + " " + scr_roman(fest_wid) + ". Would you like to spectate the event?", imag, ""); - } - if (fest_sid > 0) { - scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on the ship '" + string(obj_ini.ship[fest_sid]) + ". Would you like to spectate the event?", imag, ""); - } + if (fest_sid > 0) { + scr_popup("Scheduled Event", "Your " + string(fest_type) + " takes place on the ship '" + string(obj_ini.ship[fest_sid]) + ". Would you like to spectate the event?", imag, ""); } } - - // ** Income ** - // if (income_controlled_planets>0){ - - // var tithe_string = income_controlled_planets==1? $"-{income_tribute} Requisition granted by tithes from 1 planet.": $"-{income_tribute} Requisition granted by tithes from {income_controlled_planets} planets."; - // scr_alert("yellow", "planet_tithe", tithe_string); - // instance_activate_object(obj_p_fleet); - - // with(obj_star){ - // if (x<-10000){ - // x+=20000; - // y+=20000; - // } - // } - // } - - //research and forge related actions - - research_end(); - merge_ork_fleets(); - location_viewer.update_mission_log(); - init_ork_waagh(); - return_lost_ships_chance(); - //complex route plotting for player fleets - with (obj_p_fleet) { - if (array_length(complex_route) > 0 && action == "") { - set_new_player_fleet_course(complex_route); - } + } + + // ** Income ** + // if (income_controlled_planets>0){ + + // var tithe_string = income_controlled_planets==1? $"-{income_tribute} Requisition granted by tithes from 1 planet.": $"-{income_tribute} Requisition granted by tithes from {income_controlled_planets} planets."; + // scr_alert("yellow", "planet_tithe", tithe_string); + // instance_activate_object(obj_p_fleet); + + // with(obj_star){ + // if (x<-10000){ + // x+=20000; + // y+=20000; + // } + // } + // } + + //research and forge related actions + + research_end(); + merge_ork_fleets(); + location_viewer.update_mission_log(); + init_ork_waagh(); + return_lost_ships_chance(); + //complex route plotting for player fleets + with (obj_p_fleet) { + if (array_length(complex_route) > 0 && action == "") { + set_new_player_fleet_course(complex_route); } + } } catch (_exception) { handle_exception(_exception); } diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index acf912aa62..ecc38f5c6d 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -1,133 +1,133 @@ try { - var orb = orbiting; - - if ((round(owner) != eFACTION.IMPERIUM) && (navy == 1)) { - owner = noone; - } - - //TODO centralise orbiting logic - var _is_orbiting = is_orbiting(); - if (orbiting != 0 && action == "" && owner != noone) { - var orbiting_found = _is_orbiting; + var orb = orbiting; + + if ((round(owner) != eFACTION.IMPERIUM) && (navy == 1)) { + owner = noone; + } + + //TODO centralise orbiting logic + var _is_orbiting = is_orbiting(); + if (orbiting != 0 && action == "" && owner != noone) { + var orbiting_found = _is_orbiting; + if (orbiting_found) { + orbiting_found = variable_instance_exists(orbiting, "present_fleet"); if (orbiting_found) { - orbiting_found = variable_instance_exists(orbiting, "present_fleet"); - if (orbiting_found) { - orbiting.present_fleet[owner] += 1; - } - } else if (!orbiting_found) { - orbiting = instance_nearest(x, y, obj_star); - orbiting.present_fleet[owner]++; + orbiting.present_fleet[owner] += 1; } + } else if (!orbiting_found) { + orbiting = instance_nearest(x, y, obj_star); + orbiting.present_fleet[owner]++; } - var _khorne_cargo = fleet_has_cargo("warband"); - if (_khorne_cargo && owner == eFACTION.CHAOS) { - khorne_fleet_cargo(); + } + var _khorne_cargo = fleet_has_cargo("warband"); + if (_khorne_cargo && owner == eFACTION.CHAOS) { + khorne_fleet_cargo(); + } + + if (_is_orbiting) { + turns_static++; + if (turns_static > 5 && owner == eFACTION.ORK) { + if (!irandom(7)) { + ork_fleet_move(); + _is_orbiting = false; + } } - - if (_is_orbiting) { - turns_static++; - if (turns_static > 5 && owner == eFACTION.ORK) { - if (!irandom(7)) { - ork_fleet_move(); - _is_orbiting = false; - } + if (instance_exists(obj_crusade)) { + try { + fleet_respond_crusade(); + } catch (_exception) { + handle_exception(_exception); } - if (instance_exists(obj_crusade)) { - try { - fleet_respond_crusade(); - } catch (_exception) { - handle_exception(_exception); + } + } else { + turns_static = 0; + } + + var dir = 0; + var ret = 0; + + if (navy && action == "" && _is_orbiting) { + navy_orbiting_planet_end_turn_action(); + } else if (action == "" && _is_orbiting) { + var max_dis = 400; + + if ((orbiting.owner == eFACTION.PLAYER) && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") && (owner == eFACTION.IMPERIUM)) { + for (var i = 1; i <= orbiting.planets; i++) { + if (orbiting.p_owner[i] == 1) { + orbiting.p_pdf[i] -= capital_number * 50000; + } + if (orbiting.p_owner[i] == 1) { + orbiting.p_pdf[i] -= frigate_number * 10000; + } + if (orbiting.p_pdf[i] < 0) { + orbiting.p_pdf[i] = 0; } } - } else { - turns_static = 0; } - - var dir = 0; - var ret = 0; - - if (navy && action == "" && _is_orbiting) { - navy_orbiting_planet_end_turn_action(); - } else if (action == "" && _is_orbiting) { - var max_dis = 400; - - if ((orbiting.owner == eFACTION.PLAYER) && (obj_controller.faction_status[eFACTION.IMPERIUM] == "War") && (owner == eFACTION.IMPERIUM)) { - for (var i = 1; i <= orbiting.planets; i++) { - if (orbiting.p_owner[i] == 1) { - orbiting.p_pdf[i] -= capital_number * 50000; - } - if (orbiting.p_owner[i] == 1) { - orbiting.p_pdf[i] -= frigate_number * 10000; - } - if (orbiting.p_pdf[i] < 0) { - orbiting.p_pdf[i] = 0; - } + + // 1355; + + if (instance_exists(obj_crusade) && (owner == eFACTION.ORK) && (orbiting.owner == eFACTION.ORK)) { + // Ork crusade AI + var max_dis; + max_dis = 400; + + var fleet_owner = owner; + with (obj_crusade) { + if (owner != fleet_owner) { + x -= 40000; } } - - // 1355; - - if (instance_exists(obj_crusade) && (owner == eFACTION.ORK) && (orbiting.owner == eFACTION.ORK)) { - // Ork crusade AI - var max_dis; - max_dis = 400; - - var fleet_owner = owner; - with (obj_crusade) { - if (owner != fleet_owner) { - x -= 40000; - } + + with (obj_star) { + var ns = instance_nearest(x, y, obj_crusade); + if (point_distance(x, y, ns.x, ns.y) > ns.radius) { + x -= 40000; } - - with (obj_star) { - var ns = instance_nearest(x, y, obj_crusade); - if (point_distance(x, y, ns.x, ns.y) > ns.radius) { - x -= 40000; - } - if (owner == ns.owner) { - x -= 40000; - } + if (owner == ns.owner) { + x -= 40000; } - - var ns = instance_nearest(x, y, obj_star); - if ((ns.owner != eFACTION.ORK) && (point_distance(x, y, ns.x, ns.y) <= max_dis) && (point_distance(x, y, ns.x, ns.y) > 40) && instance_exists(obj_crusade) && (image_index > 3)) { - action_x = ns.x; - action_y = ns.y; - set_fleet_movement(); - home_x = orbiting.x; - home_y = orbiting.y; - exit; + } + + var ns = instance_nearest(x, y, obj_star); + if ((ns.owner != eFACTION.ORK) && (point_distance(x, y, ns.x, ns.y) <= max_dis) && (point_distance(x, y, ns.x, ns.y) > 40) && instance_exists(obj_crusade) && (image_index > 3)) { + action_x = ns.x; + action_y = ns.y; + set_fleet_movement(); + home_x = orbiting.x; + home_y = orbiting.y; + exit; + } + + with (obj_star) { + if (x < -30000) { + x += 40000; } - - with (obj_star) { - if (x < -30000) { - x += 40000; - } - if (x < -30000) { - x += 40000; - } - if (x < -30000) { - x += 40000; - } + if (x < -30000) { + x += 40000; } - with (obj_crusade) { - if (x < -30000) { - x += 40000; - } - if (x < -30000) { - x += 40000; - } - if (x < -30000) { - x += 40000; - } + if (x < -30000) { + x += 40000; } } - - instance_activate_object(obj_star); - instance_activate_object(obj_crusade); - instance_activate_object(obj_en_fleet); - - /*if (action="") and (owner = eFACTION.IMPERIUM){// Defend nearby systems and return when done + with (obj_crusade) { + if (x < -30000) { + x += 40000; + } + if (x < -30000) { + x += 40000; + } + if (x < -30000) { + x += 40000; + } + } + } + + instance_activate_object(obj_star); + instance_activate_object(obj_crusade); + instance_activate_object(obj_en_fleet); + + /*if (action="") and (owner = eFACTION.IMPERIUM){// Defend nearby systems and return when done with(obj_star){ // 137 ; might want for it to defend under other circumstances @@ -165,132 +165,132 @@ try { with(obj_temp3){instance_destroy();} }*/ - - if (owner == eFACTION.INQUISITION) { - var valid = true; - if (instance_exists(target)) { - if (instance_nearest(target.x, target.y, obj_star).id != instance_nearest(x, y, obj_star).id) { - valid = false; - } + + if (owner == eFACTION.INQUISITION) { + var valid = true; + if (instance_exists(target)) { + if (instance_nearest(target.x, target.y, obj_star).id != instance_nearest(x, y, obj_star).id) { + valid = false; } - if (((orbiting.owner == eFACTION.PLAYER || system_feature_bool(orbiting.p_feature, eP_FEATURES.MONASTERY)) || (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD)) && (trade_goods != "cancel_inspection") && valid) { - if (obj_controller.disposition[6] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (obj_controller.disposition[7] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - if (obj_controller.disposition[8] >= 60) { - scr_loyalty("Xeno Associate", "+"); - } - - if ((orbiting.p_owner[2] == 1) && (orbiting.p_heresy[2] >= 60)) { - scr_loyalty("Heretic Homeworld", "+"); - } - - var whom = -1; - whom = inquisitor; - var inquisitors = obj_controller.inquisitor; - var inquis_string = $"Inquisitor {whom > -1 ? inquisitors[whom] : inquisitors[0]}"; - - // INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; - var cur_star, t, type, cha, dem, tem1, tem1_base, perc, popup; - t = 0; - type = 0; - cha = 0; - dem = 0; - tem1 = 0; - popup = 0; - perc = 0; - tem1_base = 0; - - cur_star = instance_nearest(x, y, obj_star); - - if (string_count("investigate", trade_goods) > 0) { - // Check for xenos or demon-equip items on those planets - //TODO update this to check weapon or artifact tags - var e = 0, ia = -1, ca = 0; - var _unit; - repeat (4400) { - if ((ca <= 10) && (ca >= 0)) { - ia += 1; - if (ia == 400) { - ca += 1; - ia = 1; - if (ca == 11) { - ca = -5; - } + } + if (((orbiting.owner == eFACTION.PLAYER || system_feature_bool(orbiting.p_feature, eP_FEATURES.MONASTERY)) || (obj_ini.fleet_type != ePLAYER_BASE.HOME_WORLD)) && (trade_goods != "cancel_inspection") && valid) { + if (obj_controller.disposition[6] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + if (obj_controller.disposition[7] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + if (obj_controller.disposition[8] >= 60) { + scr_loyalty("Xeno Associate", "+"); + } + + if ((orbiting.p_owner[2] == 1) && (orbiting.p_heresy[2] >= 60)) { + scr_loyalty("Heretic Homeworld", "+"); + } + + var whom = -1; + whom = inquisitor; + var inquisitors = obj_controller.inquisitor; + var inquis_string = $"Inquisitor {whom > -1 ? inquisitors[whom] : inquisitors[0]}"; + + // INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; INVESTIGATE DEAD HERE 137 ; + var cur_star, t, type, cha, dem, tem1, tem1_base, perc, popup; + t = 0; + type = 0; + cha = 0; + dem = 0; + tem1 = 0; + popup = 0; + perc = 0; + tem1_base = 0; + + cur_star = instance_nearest(x, y, obj_star); + + if (string_count("investigate", trade_goods) > 0) { + // Check for xenos or demon-equip items on those planets + //TODO update this to check weapon or artifact tags + var e = 0, ia = -1, ca = 0; + var _unit; + repeat (4400) { + if ((ca <= 10) && (ca >= 0)) { + ia += 1; + if (ia == 400) { + ca += 1; + ia = 1; + if (ca == 11) { + ca = -5; } - if ((ca >= 0) && (ca < 11)) { - _unit = fetch_unit([ca, ia]); - if ((_unit.location_string == cur_star.name) && (_unit.planet_location > 0)) { - if ((_unit.role() == "Ork Sniper") && (obj_ini.race[ca][ia] != 1)) { - tem1_base = 3; - } - if ((_unit.role() == "Flash Git") && (obj_ini.race[ca][ia] != 1)) { - tem1_base = 3; - } - if ((_unit.role() == "Ranger") && (obj_ini.race[ca][ia] != 1)) { - tem1_base = 3; - } - if (_unit.equipped_artifact_tag("daemon")) { - tem1_base += 3; - dem += 1; - } + } + if ((ca >= 0) && (ca < 11)) { + _unit = fetch_unit([ca, ia]); + if ((_unit.location_string == cur_star.name) && (_unit.planet_location > 0)) { + if ((_unit.role() == "Ork Sniper") && (obj_ini.race[ca][ia] != 1)) { + tem1_base = 3; + } + if ((_unit.role() == "Flash Git") && (obj_ini.race[ca][ia] != 1)) { + tem1_base = 3; + } + if ((_unit.role() == "Ranger") && (obj_ini.race[ca][ia] != 1)) { + tem1_base = 3; + } + if (_unit.equipped_artifact_tag("daemon")) { + tem1_base += 3; + dem += 1; } } } } - repeat (cur_star.planets) { - t += 1; - inquisitor_contraband_take_popup(_cur_star, planet); - } - } else if (string_count("investigate", trade_goods) == 0) { - inquisition_inspection_logic(); } - // End Test-Slave Incubator Crap - - if (obj_controller.known[eFACTION.INQUISITION] == 1) { - obj_controller.known[eFACTION.INQUISITION] = 3; + repeat (cur_star.planets) { + t += 1; + inquisitor_contraband_take_popup(_cur_star, planet); } - if (obj_controller.known[eFACTION.INQUISITION] == 2) { - obj_controller.known[eFACTION.INQUISITION] = 4; + } else if (string_count("investigate", trade_goods) == 0) { + inquisition_inspection_logic(); + } + // End Test-Slave Incubator Crap + + if (obj_controller.known[eFACTION.INQUISITION] == 1) { + obj_controller.known[eFACTION.INQUISITION] = 3; + } + if (obj_controller.known[eFACTION.INQUISITION] == 2) { + obj_controller.known[eFACTION.INQUISITION] = 4; + } + + orbiting = instance_nearest(x, y, obj_star); + + // 135; + if (obj_controller.loyalty_hidden <= 0) { + // obj_controller.alarm[7]=1;global.defeat=2; + var moo = false; + if ((obj_controller.penitent == 1) && (moo == false)) { + obj_controller.alarm[8] = 1; + moo = true; } - - orbiting = instance_nearest(x, y, obj_star); - - // 135; - if (obj_controller.loyalty_hidden <= 0) { - // obj_controller.alarm[7]=1;global.defeat=2; - var moo = false; - if ((obj_controller.penitent == 1) && (moo == false)) { - obj_controller.alarm[8] = 1; - moo = true; - } - if ((obj_controller.penitent == 0) && (moo == false)) { - scr_audience(4, "loyalty_zero", 0, "", 0, 0); - } + if ((obj_controller.penitent == 0) && (moo == false)) { + scr_audience(4, "loyalty_zero", 0, "", 0, 0); } - - exit_star = distance_removed_star(x, y, choose(2, 3, 4)); - action_x = exit_star.x; - action_y = exit_star.y; - orbiting = exit_star; - set_fleet_movement(); - trade_goods = "|DELETE|"; - exit; } + + exit_star = distance_removed_star(x, y, choose(2, 3, 4)); + action_x = exit_star.x; + action_y = exit_star.y; + orbiting = exit_star; + set_fleet_movement(); + trade_goods = "|DELETE|"; + exit; } - - 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.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 (image_index>=4){ + } + + /*if (image_index>=4){ with(obj_star){ if (owner = eFACTION.TAU) and (present_fleets>0) and (tau_fleets=0){ instance_create(x,y,obj_temp5); @@ -306,172 +306,172 @@ try { } with(obj_temp5){instance_destroy();} }*/ + } + + if (owner == eFACTION.TYRANIDS) { + // Juggle bio-resources + if (capital_number * 2 > frigate_number) { + capital_number -= 1; + frigate_number += 2; } - - if (owner == eFACTION.TYRANIDS) { - // Juggle bio-resources - if (capital_number * 2 > frigate_number) { - capital_number -= 1; - frigate_number += 2; + + if (capital_number * 4 > escort_number) { + var rand; + rand = choose(1, 2, 3, 4); + if (rand == 4) { + escort_number += 1; } - - if (capital_number * 4 > escort_number) { - var rand; - rand = choose(1, 2, 3, 4); - if (rand == 4) { - escort_number += 1; - } - } - - if (capital_number > 0) { - var capitals_engaged = 0; - with (orbiting) { - for (var i = 1; i < planets; i++) { - if (capitals_engaged == capital_number) { - break; - } - if (p_type[i] != "Dead") { - p_tyranids[4] = 5; - capitals_engaged += 1; - } + } + + if (capital_number > 0) { + var capitals_engaged = 0; + with (orbiting) { + for (var i = 1; i < planets; i++) { + if (capitals_engaged == capital_number) { + break; + } + if (p_type[i] != "Dead") { + p_tyranids[4] = 5; + capitals_engaged += 1; } } } - - var n = false; - with (orbiting) { - n = is_dead_star(); + } + + var n = false; + with (orbiting) { + n = is_dead_star(); + } + + if (n) { + var xx, yy, good, plin, plin2; + xx = 0; + yy = 0; + good = 0; + plin = 0; + plin2 = 0; + + if (capital_number > 5) { + n = 5; } - - if (n) { - var xx, yy, good, plin, plin2; - xx = 0; - yy = 0; - good = 0; - plin = 0; - plin2 = 0; - - if (capital_number > 5) { - n = 5; - } - - instance_deactivate_object(orbiting); - - repeat (100) { - if (good != 5) { - xx = self.x + random_range(-300, 300); - yy = self.y + random_range(-300, 300); - if (good == 0) { - plin = instance_nearest(xx, yy, obj_star); + + instance_deactivate_object(orbiting); + + repeat (100) { + if (good != 5) { + xx = self.x + random_range(-300, 300); + yy = self.y + random_range(-300, 300); + if (good == 0) { + plin = instance_nearest(xx, yy, obj_star); + } + if ((good == 1) && (n == 5)) { + plin2 = instance_nearest(xx, yy, obj_star); + } + + good = !array_contains(plin.p_type, "dead"); + + if ((good == 1) && (n == 5)) { + if (!instance_exists(plin2)) { + exit; } - if ((good == 1) && (n == 5)) { - plin2 = instance_nearest(xx, yy, obj_star); + if (!array_contains(plin.p_type, "dead")) { + good++; } - - good = !array_contains(plin.p_type, "dead"); - - if ((good == 1) && (n == 5)) { - if (!instance_exists(plin2)) { - exit; - } - if (!array_contains(plin.p_type, "dead")) { - good++; - } - - var new_fleet; - new_fleet = instance_create(x, y, obj_en_fleet); - new_fleet.capital_number = floor(capital_number * 0.4); - new_fleet.frigate_number = floor(frigate_number * 0.4); - new_fleet.escort_number = floor(escort_number * 0.4); - - capital_number -= new_fleet.capital_number; - frigate_number -= new_fleet.frigate_number; - escort_number -= new_fleet.escort_number; - - new_fleet.owner = eFACTION.TYRANIDS; - new_fleet.sprite_index = spr_fleet_tyranid; - new_fleet.image_index = 1; - - /*with(new_fleet){ + + var new_fleet; + new_fleet = instance_create(x, y, obj_en_fleet); + new_fleet.capital_number = floor(capital_number * 0.4); + new_fleet.frigate_number = floor(frigate_number * 0.4); + new_fleet.escort_number = floor(escort_number * 0.4); + + capital_number -= new_fleet.capital_number; + frigate_number -= new_fleet.frigate_number; + escort_number -= new_fleet.escort_number; + + new_fleet.owner = eFACTION.TYRANIDS; + new_fleet.sprite_index = spr_fleet_tyranid; + new_fleet.image_index = 1; + + /*with(new_fleet){ var ii;ii=0;ii+=capital_number;ii+=round((frigate_number/2));ii+=round((escort_number/4)); if (ii<=1) then ii=1;image_index=ii; }*/ - - new_fleet.action_x = plin2.x; - new_fleet.action_y = plin2.y; - with (new_fleet) { - set_fleet_movement(); - } - break; - } - - if ((good == 1) && instance_exists(plin)) { - action_x = plin.x; - action_y = plin.y; + + new_fleet.action_x = plin2.x; + new_fleet.action_y = plin2.y; + with (new_fleet) { set_fleet_movement(); - if (n != 5) { - good = 5; - } + } + break; + } + + if ((good == 1) && instance_exists(plin)) { + action_x = plin.x; + action_y = plin.y; + set_fleet_movement(); + if (n != 5) { + good = 5; } } } - instance_activate_object(obj_star); } + instance_activate_object(obj_star); } } - - if ((action == "move") && (action_eta > 5000)) { - var woop = instance_nearest(x, y, obj_star); - if (woop.storm == 0) { + } + + if ((action == "move") && (action_eta > 5000)) { + var woop = instance_nearest(x, y, obj_star); + if (woop.storm == 0) { + action_eta -= 10000; + } else { + if (!instance_nearest(target_x, target_y, obj_star).storm) { action_eta -= 10000; - } else { - if (!instance_nearest(target_x, target_y, obj_star).storm) { - action_eta -= 10000; - } - } - } else if ((action == "move") && (action_eta < 5000)) { - if (instance_nearest(action_x, action_y, obj_star).storm > 0) { - exit; } - if (action_x + action_y == 0) { - exit; - } - - var dos = 0; - dos = point_distance(x, y, action_x, action_y); - orbiting = dos / action_eta; - dir = point_direction(x, y, action_x, action_y); - - x = x + lengthdir_x(orbiting, dir); - y = y + lengthdir_y(orbiting, dir); - - action_eta -= 1; - - /*if (owner>5){ + } + } else if ((action == "move") && (action_eta < 5000)) { + if (instance_nearest(action_x, action_y, obj_star).storm > 0) { + exit; + } + if (action_x + action_y == 0) { + exit; + } + + var dos = 0; + dos = point_distance(x, y, action_x, action_y); + orbiting = dos / action_eta; + dir = point_direction(x, y, action_x, action_y); + + x = x + lengthdir_x(orbiting, dir); + y = y + lengthdir_y(orbiting, dir); + + action_eta -= 1; + + /*if (owner>5){ }*/ - - if ((action_eta == 2) && (owner == eFACTION.INQUISITION) && (inquisitor > -1)) { - inquisitor_ship_approaches(); - } else if (action_eta == 0) { - action = ""; - if (array_length(complex_route) > 0) { - var target_loc = star_by_name(complex_route[0]); - if (target_loc != "none") { - array_delete(complex_route, 0, 1); - action_x = target_loc.x; - action_y = target_loc.y; - target = target_loc; - set_fleet_movement(false); - } else { - complex_route = []; - fleet_arrival_logic(); - } + + if ((action_eta == 2) && (owner == eFACTION.INQUISITION) && (inquisitor > -1)) { + inquisitor_ship_approaches(); + } else if (action_eta == 0) { + action = ""; + if (array_length(complex_route) > 0) { + var target_loc = star_by_name(complex_route[0]); + if (target_loc != "none") { + array_delete(complex_route, 0, 1); + action_x = target_loc.x; + action_y = target_loc.y; + target = target_loc; + set_fleet_movement(false); } else { + complex_route = []; fleet_arrival_logic(); } + } else { + fleet_arrival_logic(); } } + } } catch (_exception) { handle_exception(_exception); } diff --git a/objects/obj_en_fleet/Alarm_4.gml b/objects/obj_en_fleet/Alarm_4.gml index 4a104bd1b3..e834ac9051 100644 --- a/objects/obj_en_fleet/Alarm_4.gml +++ b/objects/obj_en_fleet/Alarm_4.gml @@ -1,21 +1,93 @@ try { - if (action != "") { - var sys, sys_dist, mine, connected, fleet, cont; - sys_dist = 9999; - connected = 0; - cont = 0; - - fleet = instance_id_get(0); - sys = instance_nearest(action_x, action_y, obj_star); - sys_dist = point_distance(action_x, action_y, sys.x, sys.y); - act_dist = point_distance(x, y, sys.x, sys.y); - mine = instance_nearest(x, y, obj_star); - if ((mine.x == sys.x2) && (mine.y == sys.y2)) { - connected = 1; + if (action != "") { + var sys, sys_dist, mine, connected, fleet, cont; + sys_dist = 9999; + connected = 0; + cont = 0; + + fleet = instance_id_get(0); + sys = instance_nearest(action_x, action_y, obj_star); + sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + act_dist = point_distance(x, y, sys.x, sys.y); + mine = instance_nearest(x, y, obj_star); + if ((mine.x == sys.x2) && (mine.y == sys.y2)) { + connected = 1; + } + + var eta; + eta = 0; + eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; + if (connected == 0) { + eta = eta * 2; + } + if (connected == 1) { + connected = 1; + } + + if ((owner == eFACTION.INQUISITION) && (action_eta < 2)) { + action_eta = 2; + } + // action_x=sys.x; + // action_y=sys.y; + action = "move"; + + if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { + action_eta += 10000; + } + + x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); + y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); + } + + if (action == "") { + var sys, sys_dist, mine, connected, fleet, cont, target_dist; + sys_dist = 9999; + connected = 0; + cont = 0; + target_dist = 0; + + fleet = id; + sys = instance_nearest(action_x, action_y, obj_star); + sys_dist = point_distance(action_x, action_y, sys.x, sys.y); + if (scr_valid_fleet_target(target)) { + target_dist = point_distance(x, y, target.action_x, target.action_y); + } else { + target = 0; + } + + act_dist = point_distance(x, y, sys.x, sys.y); + mine = instance_nearest(x, y, obj_star); + + // if (owner = eFACTION.TAU) then mine.tau_fleets-=1; + // if (owner = eFACTION.TAU) and (image_index!=1) then mine.tau_fleets-=1; + // mine.present_fleets-=1; + + connected = determine_warp_join(mine, sys); + cont = 1; + + if (cont == 1) { + cont = 20; + } + + if (cont == 20) { + // Move the entire fleet, don't worry about the other crap + turns_static = 0; + var eta = 0; + + if ((trade_goods != "") && (owner != eFACTION.TYRANIDS) && (owner != eFACTION.CHAOS) && (string_count("Inqis", trade_goods) == 0) && (string_count("merge", trade_goods) == 0) && (string_count("_her", trade_goods) == 0) && (trade_goods != "cancel_inspection") && (trade_goods != "return")) { + if (scr_valid_fleet_target(target)) { + if (target.action != "") { + if (target_dist > sys_dist) { + action_x = target.action_x; + action_y = target.action_y; + sys = instance_nearest(action_x, action_y, obj_star); + } + } + } else { + target = 0; + } } - - var eta; - eta = 0; + eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; if (connected == 0) { eta = eta * 2; @@ -23,108 +95,36 @@ try { if (connected == 1) { connected = 1; } - - if ((owner == eFACTION.INQUISITION) && (action_eta < 2)) { - action_eta = 2; + + if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { + action_eta = eta; + if ((owner == eFACTION.INQUISITION) && (action_eta < 2) && (string_count("_her", trade_goods) == 0)) { + action_eta = 2; + } + } + + if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { + action_eta += 10000; } + // action_x=sys.x; // action_y=sys.y; action = "move"; - - if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { - action_eta += 10000; + + if ((minimum_eta > action_eta) && (minimum_eta > 0)) { + action_eta = minimum_eta; + } + minimum_eta = 0; + if ((etah > action_eta) && (etah != 0)) { + action_eta = etah; } - + x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); } - - if (action == "") { - var sys, sys_dist, mine, connected, fleet, cont, target_dist; - sys_dist = 9999; - connected = 0; - cont = 0; - target_dist = 0; - - fleet = id; - sys = instance_nearest(action_x, action_y, obj_star); - sys_dist = point_distance(action_x, action_y, sys.x, sys.y); - if (scr_valid_fleet_target(target)) { - target_dist = point_distance(x, y, target.action_x, target.action_y); - } else { - target = 0; - } - - act_dist = point_distance(x, y, sys.x, sys.y); - mine = instance_nearest(x, y, obj_star); - - // if (owner = eFACTION.TAU) then mine.tau_fleets-=1; - // if (owner = eFACTION.TAU) and (image_index!=1) then mine.tau_fleets-=1; - // mine.present_fleets-=1; - - connected = determine_warp_join(mine, sys); - cont = 1; - - if (cont == 1) { - cont = 20; - } - - if (cont == 20) { - // Move the entire fleet, don't worry about the other crap - turns_static = 0; - var eta = 0; - - if ((trade_goods != "") && (owner != eFACTION.TYRANIDS) && (owner != eFACTION.CHAOS) && (string_count("Inqis", trade_goods) == 0) && (string_count("merge", trade_goods) == 0) && (string_count("_her", trade_goods) == 0) && (trade_goods != "cancel_inspection") && (trade_goods != "return")) { - if (scr_valid_fleet_target(target)) { - if (target.action != "") { - if (target_dist > sys_dist) { - action_x = target.action_x; - action_y = target.action_y; - sys = instance_nearest(action_x, action_y, obj_star); - } - } - } else { - target = 0; - } - } - - eta = floor(point_distance(x, y, action_x, action_y) / action_spd) + 1; - if (connected == 0) { - eta = eta * 2; - } - if (connected == 1) { - connected = 1; - } - - if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { - action_eta = eta; - if ((owner == eFACTION.INQUISITION) && (action_eta < 2) && (string_count("_her", trade_goods) == 0)) { - action_eta = 2; - } - } - - if ((owner != eFACTION.ELDAR) && (mine.storm > 0)) { - action_eta += 10000; - } - - // action_x=sys.x; - // action_y=sys.y; - action = "move"; - - if ((minimum_eta > action_eta) && (minimum_eta > 0)) { - action_eta = minimum_eta; - } - minimum_eta = 0; - if ((etah > action_eta) && (etah != 0)) { - action_eta = etah; - } - - x = x + lengthdir_x(24, point_direction(x, y, sys.x, sys.y)); - y = y + lengthdir_y(24, point_direction(x, y, sys.x, sys.y)); - } - } - - etah = 0; + } + + etah = 0; } catch (_exception) { handle_exception(_exception); } diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index 69fc36ecfb..64afa5c86f 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -1,176 +1,176 @@ try { - var spid, dir; - spid = 0; - dir = 0; - - acted = 0; - - if (action == "Lost") { - set_fleet_location("Lost"); - exit; - } else if (action == "") { - spid = instance_nearest(x, y, obj_star); - // spid.present_fleets+=1; - spid.present_fleet[1] += 1; - if (spid.vision == 0) { - spid.vision = 1; - } - orbiting = spid; - - if ((orbiting != 0) && 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(FLEET_MOVE_OPTIONS, action)) { - var i; - set_fleet_location("Warp"); - - if (instance_nearest(action_x, action_y, obj_star).storm > 0) { - exit; - } - - spid = point_distance(x, y, action_x, action_y); - spid = spid / action_eta; - 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) != "none") { - enemies = true; - break; + var spid, dir; + spid = 0; + dir = 0; + + acted = 0; + + if (action == "Lost") { + set_fleet_location("Lost"); + exit; + } else if (action == "") { + spid = instance_nearest(x, y, obj_star); + // spid.present_fleets+=1; + spid.present_fleet[1] += 1; + if (spid.vision == 0) { + spid.vision = 1; + } + orbiting = spid; + + if ((orbiting != 0) && 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); } } - 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 = ""; + orbiting.visited = 1; } - - 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; + + meet_system_governors(orbiting); + } + } else if (array_contains(FLEET_MOVE_OPTIONS, action)) { + var i; + set_fleet_location("Warp"); + + if (instance_nearest(action_x, action_y, obj_star).storm > 0) { + exit; + } + + spid = point_distance(x, y, action_x, action_y); + spid = spid / action_eta; + 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); } - steh.present_fleet[1] += 1; - orbiting = steh; - // show_message("Present Fleets at alarm[1]: "+string(steh.present_fleets)); - - meet_system_governors(steh); - - if ((steh.p_owner[1] == 5) || (steh.p_owner[2] == 5) || (steh.p_owner[3] == 5) || (steh.p_owner[4] == 5)) { - if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { - obj_controller.known[eFACTION.ECCLESIARCHY] = 1; + var enemies = false; + for (var i = 6; i < 13; i++) { + if (scr_orbiting_fleet(i) != "none") { + enemies = true; + break; } } - if ((steh.owner == eFACTION.ELDAR) && (obj_controller.faction_defeated[6] == 0) && (obj_controller.known[eFACTION.ELDAR] == 0)) { - obj_controller.known[eFACTION.ELDAR] = 1; + if (enemies) { + instance_deactivate_object(id); } - if ((steh.owner == eFACTION.TAU) && (obj_controller.faction_defeated[8] == 0) && (obj_controller.known[eFACTION.TAU] == 0)) { - obj_controller.known[eFACTION.TAU] = 1; + } + 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; + } + steh.present_fleet[1] += 1; + orbiting = steh; + // show_message("Present Fleets at alarm[1]: "+string(steh.present_fleets)); + + meet_system_governors(steh); + + if ((steh.p_owner[1] == 5) || (steh.p_owner[2] == 5) || (steh.p_owner[3] == 5) || (steh.p_owner[4] == 5)) { + if ((obj_controller.faction_defeated[5] == 0) && (obj_controller.known[eFACTION.ECCLESIARCHY] == 0)) { + obj_controller.known[eFACTION.ECCLESIARCHY] = 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 < 5; plan_num++) { - if (array_length(steh.p_feature[plan_num]) != 0) { - with (steh) { - scr_planetary_feature(plan_num); - } + } + 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 < 5; 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); } + 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); - } + } + + 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; - 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); - - // show_message("Dist: "+string(dist)+", Rando: "+string(rando)); - - 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; - } + } + + var steh; + 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); + + // show_message("Dist: "+string(dist)+", Rando: "+string(rando)); + + 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"); } + // Quene eldar introduction + // if (rando>=95) and (dist<=300) then show_message("MON'KEIGH"); } - - instance_activate_object(obj_star); } + + instance_activate_object(obj_star); + } } catch (_exception) { handle_exception(_exception); } diff --git a/objects/obj_turn_end/Alarm_0.gml b/objects/obj_turn_end/Alarm_0.gml index 31091af6e9..8bc27cfde5 100644 --- a/objects/obj_turn_end/Alarm_0.gml +++ b/objects/obj_turn_end/Alarm_0.gml @@ -1,219 +1,219 @@ try { - instance_activate_object(obj_star); - combating = 0; - - var i; - - i = 50; - repeat (50) { - i -= 1; - - if ((battles <= i) && (i >= 2)) { - if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == -50) && (battle_world[i - 1] > 0)) { - var tem1, tem2, tem3, tem4, tem5, tem6, tem7; - tem1 = battle[i - 1]; - tem2 = battle_location[i - 1]; - tem3 = battle_world[i - 1]; - tem4 = battle_opponent[i - 1]; - tem5 = battle_object[i - 1]; - tem6 = battle_pobject[i - 1]; - tem7 = battle_special[i - 1]; - - battle[i - 1] = battle[i]; - battle_location[i - 1] = battle_location[i]; - battle_world[i - 1] = battle_world[i]; - battle_opponent[i - 1] = battle_opponent[i]; - // battle_object[i-1]=battle_object[i]; - battle_pobject[i - 1] = battle_pobject[i]; - battle_special[i - 1] = battle_special[i]; - - battle[i] = tem1; - battle_location[i] = tem2; - battle_world[i] = tem3; - battle_opponent[i] = tem4; - battle_object[i] = tem5; - battle_pobject[i] = tem6; - battle_special[i] = tem7; - } + instance_activate_object(obj_star); + combating = 0; + + var i; + + i = 50; + repeat (50) { + i -= 1; + + if ((battles <= i) && (i >= 2)) { + if ((battle[i] != 0) && (battle[i - 1] != 0) && (battle_world[i] == -50) && (battle_world[i - 1] > 0)) { + var tem1, tem2, tem3, tem4, tem5, tem6, tem7; + tem1 = battle[i - 1]; + tem2 = battle_location[i - 1]; + tem3 = battle_world[i - 1]; + tem4 = battle_opponent[i - 1]; + tem5 = battle_object[i - 1]; + tem6 = battle_pobject[i - 1]; + tem7 = battle_special[i - 1]; + + battle[i - 1] = battle[i]; + battle_location[i - 1] = battle_location[i]; + battle_world[i - 1] = battle_world[i]; + battle_opponent[i - 1] = battle_opponent[i]; + // battle_object[i-1]=battle_object[i]; + battle_pobject[i - 1] = battle_pobject[i]; + battle_special[i - 1] = battle_special[i]; + + battle[i] = tem1; + battle_location[i] = tem2; + battle_world[i] = tem3; + battle_opponent[i] = tem4; + battle_object[i] = tem5; + battle_pobject[i] = tem6; + battle_special[i] = tem7; } } - - // Probably want something right here to organize the battle just in case - // Space battles first - // Ground battles after - - if ((battles > 0) && (current_battle <= battles)) { - var ii, xx, yy, good; - ii = 0; - good = 0; - - var battle_star = star_by_name(battle_location[current_battle]); - - if (battle_star != "none") { - // trying to find the star - obj_controller.x = battle_star.x; - obj_controller.y = battle_star.y; - show = current_battle; - - if (battle_world[current_battle] == -50) { - strin[1] = string(round(battle_pobject[current_battle].capital_number)); - strin[2] = string(round(battle_pobject[current_battle].frigate_number)); - strin[3] = string(round(battle_pobject[current_battle].escort_number)); - // pull health values here - strin[4] = string(round(battle_pobject[current_battle].capital_health)); - strin[5] = string(round(battle_pobject[current_battle].frigate_health)); - strin[6] = string(round(battle_pobject[current_battle].escort_health)); - - // pull enemy ships here - - var e = 1; - repeat (10) { - e += 1; - if (e == 11) { - e = 13; - } - if (battle_star.present_fleet[e] > 0) { - obj_controller.temp[1070] = battle_star.id; - obj_controller.temp[1071] = e; - obj_controller.temp[1072] = 0; - obj_controller.temp[1073] = 0; - obj_controller.temp[1074] = 0; - - with (obj_en_fleet) { - if ((orbiting == obj_controller.temp[1070]) && (owner == obj_controller.temp[1071])) { - obj_controller.temp[1072] += round(capital_number); - obj_controller.temp[1073] += round(frigate_number); - obj_controller.temp[1074] += round(escort_number); - } + } + + // Probably want something right here to organize the battle just in case + // Space battles first + // Ground battles after + + if ((battles > 0) && (current_battle <= battles)) { + var ii, xx, yy, good; + ii = 0; + good = 0; + + var battle_star = star_by_name(battle_location[current_battle]); + + if (battle_star != "none") { + // trying to find the star + obj_controller.x = battle_star.x; + obj_controller.y = battle_star.y; + show = current_battle; + + if (battle_world[current_battle] == -50) { + strin[1] = string(round(battle_pobject[current_battle].capital_number)); + strin[2] = string(round(battle_pobject[current_battle].frigate_number)); + strin[3] = string(round(battle_pobject[current_battle].escort_number)); + // pull health values here + strin[4] = string(round(battle_pobject[current_battle].capital_health)); + strin[5] = string(round(battle_pobject[current_battle].frigate_health)); + strin[6] = string(round(battle_pobject[current_battle].escort_health)); + + // pull enemy ships here + + var e = 1; + repeat (10) { + e += 1; + if (e == 11) { + e = 13; + } + if (battle_star.present_fleet[e] > 0) { + obj_controller.temp[1070] = battle_star.id; + obj_controller.temp[1071] = e; + obj_controller.temp[1072] = 0; + obj_controller.temp[1073] = 0; + obj_controller.temp[1074] = 0; + + with (obj_en_fleet) { + if ((orbiting == obj_controller.temp[1070]) && (owner == obj_controller.temp[1071])) { + obj_controller.temp[1072] += round(capital_number); + obj_controller.temp[1073] += round(frigate_number); + obj_controller.temp[1074] += round(escort_number); } - - var l1, l2; - l1 = 0; - l2 = 0; - if (obj_controller.faction_status[e] != "War") { - repeat (10) { - l1 += 1; - if ((allied_fleet[l1] == 0) && (l2 == 0)) { - l2 = l1; - } + } + + var l1, l2; + l1 = 0; + l2 = 0; + if (obj_controller.faction_status[e] != "War") { + repeat (10) { + l1 += 1; + if ((allied_fleet[l1] == 0) && (l2 == 0)) { + l2 = l1; } - allied_fleet[l2] = e; - acap[l2] = obj_controller.temp[1072]; - afri[l2] = obj_controller.temp[1073]; - aesc[l2] = obj_controller.temp[1074]; } - if ((obj_controller.faction_status[e] == "War") || (e == 9) || (e == 13)) { - repeat (10) { - l1 += 1; - if ((enemy_fleet[l1] == 0) && (l2 == 0)) { - l2 = l1; - } + allied_fleet[l2] = e; + acap[l2] = obj_controller.temp[1072]; + afri[l2] = obj_controller.temp[1073]; + aesc[l2] = obj_controller.temp[1074]; + } + if ((obj_controller.faction_status[e] == "War") || (e == 9) || (e == 13)) { + repeat (10) { + l1 += 1; + if ((enemy_fleet[l1] == 0) && (l2 == 0)) { + l2 = l1; } - enemy_fleet[l2] = e; - ecap[l2] = obj_controller.temp[1072]; - efri[l2] = obj_controller.temp[1073]; - eesc[l2] = obj_controller.temp[1074]; } + enemy_fleet[l2] = e; + ecap[l2] = obj_controller.temp[1072]; + efri[l2] = obj_controller.temp[1073]; + eesc[l2] = obj_controller.temp[1074]; } } } - - if (battle_world[current_battle] >= 1) { - scr_count_forces(string(battle_location[current_battle]), battle_world[current_battle], true); - - strin[1] = info_mahreens; - strin[2] = info_vehicles; - - if (info_mahreens + info_vehicles == 0) { - if (battles > current_battle) { - alarm[4] = 1; - } - if (battles == current_battle) { - alarm[1] = 1; - } - } - - strin[3] = ""; - - var tempy = 0; - tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; - - if ((tempy == 1) || (tempy == 2) || (tempy == 3)) { - var array_string = [ - "", - "Minimally", - "Lightly", - "Moderately", - "Highly", - "Extremely", - "Maximally" - ]; - var battle_fortification = battle_object[current_battle].p_fortified[battle_world[current_battle]]; - strin[3] = array_string[clamp(battle_fortification, 1, 6)]; - } - - tempy = 0; - if (battle_opponent[current_battle] == 7) { - tempy = battle_object[current_battle].p_orks[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 8) { - tempy = battle_object[current_battle].p_tau[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 9) { - tempy = battle_object[current_battle].p_tyranids[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 10) { - tempy = battle_object[current_battle].p_traitors[battle_world[current_battle]]; - } - if (battle_opponent[current_battle] == 13) { - tempy = battle_object[current_battle].p_necrons[battle_world[current_battle]]; - } - - if (tempy == 1) { - strin[4] = "Minimal Forces"; - } - if (tempy == 2) { - strin[4] = "Sparse Forces"; - } - if (tempy == 3) { - strin[4] = "Moderate Forces"; - } - if (tempy == 4) { - strin[4] = "Numerous Forces"; - } - if (tempy == 5) { - strin[4] = "Very Numerous"; + } + + if (battle_world[current_battle] >= 1) { + scr_count_forces(string(battle_location[current_battle]), battle_world[current_battle], true); + + strin[1] = info_mahreens; + strin[2] = info_vehicles; + + if (info_mahreens + info_vehicles == 0) { + if (battles > current_battle) { + alarm[4] = 1; } - if (tempy == 6) { - strin[4] = "Overwhelming"; + if (battles == current_battle) { + alarm[1] = 1; } - - // if (battle_opponent[current_battle]=2) then obj_controller.alarm[7]=1; - obj_controller.cooldown = 9999; } - - if (obj_controller.zoomed == 1) { - with (obj_controller) { - scr_zoom(); - } + + strin[3] = ""; + + var tempy = 0; + tempy = battle_object[current_battle].p_owner[battle_world[current_battle]]; + + if ((tempy == 1) || (tempy == 2) || (tempy == 3)) { + var array_string = [ + "", + "Minimally", + "Lightly", + "Moderately", + "Highly", + "Extremely", + "Maximally" + ]; + var battle_fortification = battle_object[current_battle].p_fortified[battle_world[current_battle]]; + strin[3] = array_string[clamp(battle_fortification, 1, 6)]; + } + + tempy = 0; + if (battle_opponent[current_battle] == 7) { + tempy = battle_object[current_battle].p_orks[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 8) { + tempy = battle_object[current_battle].p_tau[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 9) { + tempy = battle_object[current_battle].p_tyranids[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 10) { + tempy = battle_object[current_battle].p_traitors[battle_world[current_battle]]; + } + if (battle_opponent[current_battle] == 13) { + tempy = battle_object[current_battle].p_necrons[battle_world[current_battle]]; + } + + if (tempy == 1) { + strin[4] = "Minimal Forces"; + } + if (tempy == 2) { + strin[4] = "Sparse Forces"; + } + if (tempy == 3) { + strin[4] = "Moderate Forces"; + } + if (tempy == 4) { + strin[4] = "Numerous Forces"; + } + if (tempy == 5) { + strin[4] = "Very Numerous"; + } + if (tempy == 6) { + strin[4] = "Overwhelming"; + } + + // if (battle_opponent[current_battle]=2) then obj_controller.alarm[7]=1; + obj_controller.cooldown = 9999; + } + + if (obj_controller.zoomed == 1) { + with (obj_controller) { + scr_zoom(); } } - instance_activate_object(obj_star); } - instance_activate_object(obj_star); - - if ((battle[1] == 0) || (current_battle > battles)) { - // This is temporary for the sake of testing - if (battle[1] == 0) { - obj_controller.x = first_x; - obj_controller.y = first_y; - } - alarm[1] = 1; + } + + instance_activate_object(obj_star); + + if ((battle[1] == 0) || (current_battle > battles)) { + // This is temporary for the sake of testing + if (battle[1] == 0) { + obj_controller.x = first_x; + obj_controller.y = first_y; } - - /* */ - /* */ + alarm[1] = 1; + } + + /* */ + /* */ } catch (_exception) { handle_exception(_exception); } 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 5631a041bb..bea9a3fded 100644 --- a/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml +++ b/scripts/scr_enemy_ai_d/scr_enemy_ai_d.gml @@ -281,7 +281,7 @@ function scr_enemy_ai_d() { var garrison_mission = has_problem_planet_and_time(i, "provide_garrison", 0); if (garrison_mission > -1) { try { - complete_garrison_mission(i, garrison_mission) + complete_garrison_mission(i, garrison_mission); } catch (_exception) { handle_exception(_exception); } diff --git a/scripts/scr_kill_unit/scr_kill_unit.gml b/scripts/scr_kill_unit/scr_kill_unit.gml index cd8fc29ce9..d04ea2d92f 100644 --- a/scripts/scr_kill_unit/scr_kill_unit.gml +++ b/scripts/scr_kill_unit/scr_kill_unit.gml @@ -17,8 +17,7 @@ function scr_kill_unit(company, unit_slot) { } _unit.remove_from_squad(); scr_wipe_unit(company, unit_slot); - } - catch (ex) { + } catch (ex) { LOGGER.error($"company: {company}, unit_slot: {unit_slot}"); handle_exception(ex); } diff --git a/scripts/scr_logging_functions/scr_logging_functions.gml b/scripts/scr_logging_functions/scr_logging_functions.gml index d9152a529e..6aefdebc5c 100644 --- a/scripts/scr_logging_functions/scr_logging_functions.gml +++ b/scripts/scr_logging_functions/scr_logging_functions.gml @@ -33,12 +33,14 @@ function create_error_file(_message) { /// @description Creates a copy of the last_messages.log file, with the current date in the name, in the same folder. function copy_last_messages_file() { - if (!file_exists(ERR_PATH_LAST_MESSAGES)) return; - + if (!file_exists(ERR_PATH_LAST_MESSAGES)) { + return; + } + if (!directory_exists(ERR_LOG_DIRECTORY)) { directory_create(ERR_LOG_DIRECTORY); } - + file_copy(ERR_PATH_LAST_MESSAGES, $"{ERR_LOG_DIRECTORY}{DATE_TIME_1}_messages.log"); } @@ -48,13 +50,13 @@ function error_get_context() { var _context = { chapter: global.chapter_name ?? "???", seed: global.game_seed ?? "???", - turn: "???" + turn: "???", }; if (instance_exists(obj_controller)) { _context.turn = obj_controller.turn; } - + return _context; } @@ -96,7 +98,7 @@ function handle_error(_header, _message, _stacktrace = "", _critical = false, _r var _error_file_text = (_report_title != "") ? $"{_report_title}\n{_full_log}" : _full_log; create_error_file(_error_file_text); - + var _clipboard = (_report_title != "") ? $"{_report_title}\n" : ""; _clipboard += markdown_codeblock(_full_log, "log"); clipboard_set_text(_clipboard); @@ -105,7 +107,7 @@ function handle_error(_header, _message, _stacktrace = "", _critical = false, _r var _player_msg = $"{_header}\n\n{_message}\n\n"; _player_msg += $"The error log is in your clipboard and saved at:\n{_path_hint}Logs\\\n\n"; _player_msg += "1) Create a bug report on Discord.\n2) Press CTRL+V to paste the log.\n\nThank you!"; - + if (!_critical) { _player_msg += $"\n\n{STR_ERROR_MESSAGE_PS}"; } diff --git a/scripts/scr_mission_functions/scr_mission_functions.gml b/scripts/scr_mission_functions/scr_mission_functions.gml index b487a41fa0..45e5c4c91c 100644 --- a/scripts/scr_mission_functions/scr_mission_functions.gml +++ b/scripts/scr_mission_functions/scr_mission_functions.gml @@ -806,4 +806,3 @@ function locations_are_equal(_first_loc, _second_loc) { return (_first_loc[1] == _second_loc[1]) && (_first_loc[0] == _second_loc[0]); } - From 8f00c0e837af0c6f214d80ef5aed66c52bef6b17 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:46:58 +0300 Subject: [PATCH 08/16] fix: Penitent end inq dispo award --- objects/obj_controller/Alarm_5.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 77feb905d6..72455a2476 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -428,7 +428,7 @@ try { } disposition[eFACTION.IMPERIUM] += 20; disposition[eFACTION.MECHANICUS] += 15; - disposition[eFACTION.IMPERIUM] += 20; + disposition[eFACTION.INQUISITION] += 20; disposition[eFACTION.ECCLESIARCHY] += 20; var o = 0; if (scr_has_adv("Reverent Guardians")) { From ee89d5589e9dfd3afc320a684085769b477523f0 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:48:44 +0300 Subject: [PATCH 09/16] fix: Inquisition planet investigation --- objects/obj_en_fleet/Alarm_1.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index ecc38f5c6d..873900e83d 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -243,7 +243,7 @@ try { } repeat (cur_star.planets) { t += 1; - inquisitor_contraband_take_popup(_cur_star, planet); + inquisitor_contraband_take_popup(cur_star, t); } } else if (string_count("investigate", trade_goods) == 0) { inquisition_inspection_logic(); From be25feac4e4c2181011ee892873aca983989505f Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:49:38 +0300 Subject: [PATCH 10/16] fix: Tyranid engagement loop --- objects/obj_en_fleet/Alarm_1.gml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index 873900e83d..23fdac3b32 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -326,7 +326,7 @@ try { if (capital_number > 0) { var capitals_engaged = 0; with (orbiting) { - for (var i = 1; i < planets; i++) { + for (var i = 1; i <= planets; i++) { if (capitals_engaged == capital_number) { break; } From 118491f4989322e6cf22fddd6546cd74c137d533 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:54:31 +0300 Subject: [PATCH 11/16] fix: en_fleet early exit safeguard --- objects/obj_en_fleet/Alarm_1.gml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index 23fdac3b32..3035cb3136 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -356,6 +356,7 @@ try { } instance_deactivate_object(orbiting); + var _abort_migration = false; repeat (100) { if (good != 5) { @@ -372,7 +373,8 @@ try { if ((good == 1) && (n == 5)) { if (!instance_exists(plin2)) { - exit; + _abort_migration = true; + break; } if (!array_contains(plin.p_type, "dead")) { good++; @@ -416,6 +418,9 @@ try { } } instance_activate_object(obj_star); + if (_abort_migration) { + exit; + } } } } From adaf9b6958ecc4263fece46e80302454461f9bec Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:54:51 +0300 Subject: [PATCH 12/16] fix: en_fleet action_eta safeguard --- objects/obj_en_fleet/Alarm_1.gml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/objects/obj_en_fleet/Alarm_1.gml b/objects/obj_en_fleet/Alarm_1.gml index 3035cb3136..8b2edd1abb 100644 --- a/objects/obj_en_fleet/Alarm_1.gml +++ b/objects/obj_en_fleet/Alarm_1.gml @@ -428,13 +428,13 @@ try { if ((action == "move") && (action_eta > 5000)) { var woop = instance_nearest(x, y, obj_star); if (woop.storm == 0) { - action_eta -= 10000; + action_eta = max(1, action_eta - 10000); } else { if (!instance_nearest(target_x, target_y, obj_star).storm) { - action_eta -= 10000; + action_eta = max(1, action_eta - 10000); } } - } else if ((action == "move") && (action_eta < 5000)) { + } else if ((action == "move") && (action_eta <= 5000)) { if (instance_nearest(action_x, action_y, obj_star).storm > 0) { exit; } From 3966d265cfc053c2e85f1ae8dbcfd1b762cd6060 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:03:20 +0300 Subject: [PATCH 13/16] chore: Garbage cleanup in en_fleet --- objects/obj_en_fleet/Alarm_4.gml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/objects/obj_en_fleet/Alarm_4.gml b/objects/obj_en_fleet/Alarm_4.gml index e834ac9051..8eb49317c5 100644 --- a/objects/obj_en_fleet/Alarm_4.gml +++ b/objects/obj_en_fleet/Alarm_4.gml @@ -1,11 +1,10 @@ try { if (action != "") { - var sys, sys_dist, mine, connected, fleet, cont; + var sys, sys_dist, mine, connected, cont; sys_dist = 9999; connected = 0; cont = 0; - fleet = instance_id_get(0); sys = instance_nearest(action_x, action_y, obj_star); sys_dist = point_distance(action_x, action_y, sys.x, sys.y); act_dist = point_distance(x, y, sys.x, sys.y); @@ -20,9 +19,6 @@ try { if (connected == 0) { eta = eta * 2; } - if (connected == 1) { - connected = 1; - } if ((owner == eFACTION.INQUISITION) && (action_eta < 2)) { action_eta = 2; @@ -40,13 +36,12 @@ try { } if (action == "") { - var sys, sys_dist, mine, connected, fleet, cont, target_dist; + var sys, sys_dist, mine, connected, cont, target_dist; sys_dist = 9999; connected = 0; cont = 0; target_dist = 0; - fleet = id; sys = instance_nearest(action_x, action_y, obj_star); sys_dist = point_distance(action_x, action_y, sys.x, sys.y); if (scr_valid_fleet_target(target)) { @@ -92,9 +87,6 @@ try { if (connected == 0) { eta = eta * 2; } - if (connected == 1) { - connected = 1; - } if ((action_eta <= 0) || (owner != eFACTION.INQUISITION)) { action_eta = eta; From 79ad88d28841ad82d9b6dfc7ce3c6184f7b61382 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:04:11 +0300 Subject: [PATCH 14/16] fix: p_fleet alarm_1 planet loop sizes --- objects/obj_p_fleet/Alarm_1.gml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/objects/obj_p_fleet/Alarm_1.gml b/objects/obj_p_fleet/Alarm_1.gml index 64afa5c86f..d3458cb138 100644 --- a/objects/obj_p_fleet/Alarm_1.gml +++ b/objects/obj_p_fleet/Alarm_1.gml @@ -19,7 +19,7 @@ try { if ((orbiting != 0) && instance_exists(orbiting)) { if (orbiting.visited == 0) { - for (var planet_num = 1; planet_num < orbiting.planets; planet_num += 1) { + 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); @@ -120,7 +120,7 @@ try { var i; set_fleet_location(steh.name); if (steh.visited == 0) { - for (var plan_num = 1; plan_num < 5; plan_num++) { + 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); From b953b5419f83bcb24893a3df61a6d08658fe2de4 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:18:38 +0300 Subject: [PATCH 15/16] chore: Avoid double cleaning stacktrace --- scripts/scr_logging_functions/scr_logging_functions.gml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/scr_logging_functions/scr_logging_functions.gml b/scripts/scr_logging_functions/scr_logging_functions.gml index 6aefdebc5c..7ac740d52f 100644 --- a/scripts/scr_logging_functions/scr_logging_functions.gml +++ b/scripts/scr_logging_functions/scr_logging_functions.gml @@ -128,13 +128,13 @@ function handle_exception(_exception, custom_title = STR_ERROR_MESSAGE_HEAD, cri var _stacktrace = _exception.stacktrace; clean_stacktrace(_stacktrace); - _stacktrace = array_to_string_list(_stacktrace); - var _critical = critical ? "CRASH! " : ""; var _build_date = global.build_date == "unknown build" ? "" : $"/{global.build_date}"; - var _problem_line = clean_stacktrace_line(_exception.stacktrace[0]); + var _problem_line = (array_length(_stacktrace) > 0) ? _stacktrace[0] : "unknown"; var _report_title = $"{_critical}[{global.game_version}{_build_date}] {_problem_line}"; + _stacktrace = array_to_string_list(_stacktrace); + handle_error(_header, _message, _stacktrace, critical, _report_title); } From 25a203157d60391d57b87c43a1886e259377ef04 Mon Sep 17 00:00:00 2001 From: EttyKitty <20323032+EttyKitty@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:23:01 +0300 Subject: [PATCH 16/16] refactor: Chaos warlord planet choice safeguards --- objects/obj_controller/Alarm_5.gml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/objects/obj_controller/Alarm_5.gml b/objects/obj_controller/Alarm_5.gml index 72455a2476..c3953ee8e9 100644 --- a/objects/obj_controller/Alarm_5.gml +++ b/objects/obj_controller/Alarm_5.gml @@ -356,16 +356,16 @@ try { } } if (_star_found) { - var _planet = array_random_element(planets_without_type("Dead", _choice_star)); - _choice_star.warlord[_planet] = 1; - array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); - - var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; - - _choice_star.p_heresy[_planet] += _heresy_inc; - - if (_choice_star.p_heresy[_planet] < 50) { - _choice_star.p_heresy_secret[_planet] = 10; + var _candidate_planets = planets_without_type("Dead", _choice_star); + if (array_length(_candidate_planets) > 0) { + var _planet = array_random_element(_candidate_planets); + _choice_star.warlord[_planet] = 1; + array_push(_choice_star.p_feature[_planet], new NewPlanetFeature(eP_FEATURES.WARLORD10)); + var _heresy_inc = _choice_star.p_type[_planet] == "Hive" ? 25 : 10; + _choice_star.p_heresy[_planet] += _heresy_inc; + if (_choice_star.p_heresy[_planet] < 50) { + _choice_star.p_heresy_secret[_planet] = 10; + } } } }