From 14022d7a57592917bc2a81f2ed977599d3473669 Mon Sep 17 00:00:00 2001 From: Luken Date: Thu, 13 May 2021 02:03:00 +0200 Subject: [PATCH] Added Civilian Detection Stuff --- NX-Tweaks/locales/en.json | 8 ++++- NX-Tweaks/menu/Menu.lua | 4 ++- NX-Tweaks/mod.txt | 14 +++++--- NX-Tweaks/scripts/GroupAIStateBase.lua | 49 ++++++++++++++++++++++++++ NX-Tweaks/scripts/Interaction.lua | 2 ++ 5 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 NX-Tweaks/scripts/GroupAIStateBase.lua diff --git a/NX-Tweaks/locales/en.json b/NX-Tweaks/locales/en.json index dd41316..c6ab01a 100644 --- a/NX-Tweaks/locales/en.json +++ b/NX-Tweaks/locales/en.json @@ -2,5 +2,11 @@ "nx_ssc": "NX-Tweaks", "nx_disable_shaped_charges_during_stealth_title": "Disable Shaped Charges During Stealth", - "nx_disable_shaped_charges_during_stealth_desc": "turn off to use shaped charges during stealth, how sneaky!" + "nx_disable_shaped_charges_during_stealth_desc": "turn off to use shaped charges during stealth, how sneaky!", + + "nx_civilians_distinguish_detection_title": "Civilians: Distinguish Detection", + "nx_civilians_distinguish_detection_desc": "changes the icon & color of the detection marker for civilians", + + "nx_civilians_display_intimidation_title": "Civilians: Display Intimidation", + "nx_civilians_display_intimidation_desc": "changes the icon & color of the marker for intimidated/dropped civilians" } diff --git a/NX-Tweaks/menu/Menu.lua b/NX-Tweaks/menu/Menu.lua index 573d820..abfa6a1 100644 --- a/NX-Tweaks/menu/Menu.lua +++ b/NX-Tweaks/menu/Menu.lua @@ -9,7 +9,9 @@ NX.settings_file = SavePath .. "NX-Tweaks.json" NX.locale_file = NX.locale_path .. "en.json" NX.settings = { - disable_shaped_charges_during_stealth = true + disable_shaped_charges_during_stealth = true, + civilians_distinguish_detection = false, + civilians_display_intimidation = false, } -- no BLT, no MenuHelper ): diff --git a/NX-Tweaks/mod.txt b/NX-Tweaks/mod.txt index 6b9e035..d407e44 100644 --- a/NX-Tweaks/mod.txt +++ b/NX-Tweaks/mod.txt @@ -1,22 +1,26 @@ { "name": "NX-Tweaks", - "description": "This mod provides some smaller quality of life changes to improve your game experience (: \n\nFeatures:\n- Disable Shaped Charges During Stealth", + "description": "This mod provides some smaller quality of life changes to improve your game experience (: \n\nFeatures:\n- Disable Shaped Charges During Stealth\n- Civilians: Distinguish Detection\n- Civilians: Display Intimidation", "author": "Luken", "contact": "Discord @ Luken#1104", - "version": "0.0.2", + "version": "0.0.3", "blt_version": 2, "color": "0 0 0", "image": "NX_1000px.png", - "priority": 100, + "priority": 0, "hooks" : [ { "hook_id": "lib/managers/menumanager", "script_path": "menu/Menu.lua" }, { - "hook_id" : "lib/units/interactions/interactionext", - "script_path" : "scripts/Interaction.lua" + "hook_id": "lib/units/interactions/interactionext", + "script_path": "scripts/Interaction.lua" }, + { + "hook_id": "lib/managers/group_ai_states/groupaistatebase", + "script_path": "scripts/GroupAIStateBase.lua" + } ], "updates" : [ { diff --git a/NX-Tweaks/scripts/GroupAIStateBase.lua b/NX-Tweaks/scripts/GroupAIStateBase.lua new file mode 100644 index 0000000..c5ab47b --- /dev/null +++ b/NX-Tweaks/scripts/GroupAIStateBase.lua @@ -0,0 +1,49 @@ +-- civilians_distinguish_detection +-- civilians_display_intimidation + +local _upd_criminal_suspicion_progress_original = GroupAIStateBase._upd_criminal_suspicion_progress + +function GroupAIStateBase:_upd_criminal_suspicion_progress(...) + if self._ai_enabled then + for obs_key, obs_susp_data in pairs(self._suspicion_hud_data or {}) do + local unit = obs_susp_data.u_observer + + if managers.enemy:is_civilian(unit) then + local waypoint_id = "susp1" .. tostring(obs_key) + local waypoint = managers.hud and managers.hud._hud.waypoints[waypoint_id] + + if waypoint then + local color, arrow_color + + if unit:anim_data().drop and NX.settings.civilians_display_intimidation then + if not obs_susp_data._subdued_civ then + obs_susp_data._alerted_civ = nil + obs_susp_data._subdued_civ = true + color = Color(0, 0.71, 1) + arrow_color = Color(0, 0.35, 0.5) + waypoint.bitmap:set_image("guis/textures/menu_tickbox") + waypoint.bitmap:set_texture_rect(24, 0, 24, 24) + end + elseif obs_susp_data.alerted and NX.settings.civilians_distinguish_detection then + if not obs_susp_data._alerted_civ then + obs_susp_data._subdued_civ = nil + obs_susp_data._alerted_civ = true + + color = Color(1, 0.5, 0) + arrow_color = Color(0.5, 0.25, 0) + waypoint.bitmap:set_image("guis/textures/menu_tickbox") + waypoint.bitmap:set_texture_rect(0, 0, 24, 24) + end + end + + if color and arrow_color then + waypoint.bitmap:set_color(color) + waypoint.arrow:set_color(arrow_color:with_alpha(0.75)) + end + end + end + end + end + + return _upd_criminal_suspicion_progress_original(self, ...) +end diff --git a/NX-Tweaks/scripts/Interaction.lua b/NX-Tweaks/scripts/Interaction.lua index 9f7dc2f..592358f 100644 --- a/NX-Tweaks/scripts/Interaction.lua +++ b/NX-Tweaks/scripts/Interaction.lua @@ -1,3 +1,5 @@ +-- disable_shaped_charges_during_stealth + if string.lower(RequiredScript) == "lib/units/interactions/interactionext" then local BaseInteraction_can_select_original = BaseInteractionExt.can_select