Skip to content

Commit

Permalink
1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
irbizzelus authored Jan 15, 2024
1 parent 2cdb237 commit 2c04987
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 81 deletions.
16 changes: 0 additions & 16 deletions lua/copdamage.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
Hooks:PreHook(CopDamage, "damage_melee", "IDC_melee_insta_kill_on_hostages", function(self,attack_data)
if immdomcops.settings.meleekill == true and immdomcops.hostages[self._unit:id()] and attack_data.damage > 0 then
if immdomcops.hostages[self._unit:id()] == "tied_down" then
attack_data.damage = 999999

self._unit:character_damage():set_invulnerable(false)
self._unit:character_damage():set_immortal(false)
self._unit:network():send("set_unit_invulnerable", false, false)

immdomcops.hostages[self._unit:id()] = nil

managers.money:civilian_killed() -- thats what you get for killing prisoners of war lmao
end
end
end)

Hooks:PostHook(CopDamage, "die", "IDC_post_cop_death_countour_cleanup", function(self,attack_data)
if immdomcops.settings.highlights == true then
self._unit:contour():remove( "friendly" , true )
Expand Down
69 changes: 27 additions & 42 deletions lua/copmovement.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,63 @@ Hooks:PostHook(CopMovement, "action_request", "IDC_post_action_request_tweak_uni
return
end

-- idk, some check if unit is busy or something? ask Undeadsewer, thats his code
-- idk, some check if unit is busy or something? ask Undeadsewer, that's his code
if self._unit:base().mic_is_being_moved then
return
end

if managers.enemy:is_civilian( self._unit ) then
if managers.enemy:is_civilian(self._unit) then
return
end

-- Check if 'cop' action is requested by an actuall cop and not by Hoxton or other friendly ai, who are supposed to be immortal
-- check if 'cop' action is requested by an actuall cop and not by Hoxton or other friendly ai, who are supposed to be immortal
if self._unit:base():char_tweak().access == "teamAI4" then
return
end

-- only highlights in stealth
if managers.groupai:state():whisper_mode() and action_desc.variant == "tied_all_in_one" then

-- Only add highlights in stealth
if immdomcops.settings.highlights == true then
self._unit:contour():add( "friendly" , true )
end

-- If hands are up activate highlights and invulnerability, and sync that info to clients
-- on hands up activate everything
elseif action_desc.variant == "hands_up" then

if immdomcops.settings.highlights == true then
self._unit:contour():add( "friendly" , true )
end

self._unit:network():send("set_unit_invulnerable", true, true)
self._unit:character_damage():set_invulnerable(true)
self._unit:character_damage():set_immortal(true)

-- add unit's id to our list of immortal hostages
immdomcops.hostages[self._unit:id()] = "hands_up"

immdomcops.hostages[self._unit:id()] = "giving_up"
elseif action_desc.variant == "hands_back" then

-- dont remove highlights if getting on knees

elseif action_desc.variant == "tied" then

-- dont remove highlights if cuffed

-- add unit's id to our list of immortal hostages for melee insta kill tracking
immdomcops.hostages[self._unit:id()] = "tied_down"

immdomcops.hostages[self._unit:id()] = "gave_up"
DelayedCalls:Add("IDC_remove_invuln_for_unit_"..tostring(self._unit:id()), immdomcops.settings.immortality_duration, function()
if alive(self._unit) and self._unit:character_damage().set_immortal and self._unit:character_damage()._immortal ~= false then
self._unit:network():send("set_unit_invulnerable", false, false)
self._unit:character_damage():set_invulnerable(false)
self._unit:character_damage():set_immortal(false)
immdomcops.hostages[self._unit:id()] = nil
end

if alive(self._unit) and not managers.groupai:state():is_enemy_converted_to_criminal(self._unit) and self._unit:contour() and self._unit:contour()._contour_list and #self._unit:contour()._contour_list >= 1 and not immdomcops.settings.keep_hl_for_mortals then
for i=1, #self._unit:contour()._contour_list do
if self._unit:contour()._contour_list[i] and self._unit:contour()._contour_list[i].type and self._unit:contour()._contour_list[i].type == "friendly" then
self._unit:contour():remove( "friendly" , true )
end
end
end
end)
else

if immdomcops.settings.highlights == true then
if managers.groupai:state():is_enemy_converted_to_criminal(self._unit) then
-- dont remove highlights if enemy is converted
else
-- remove highlights otherwise
-- sanity check #1
if self._unit:contour() then
-- sanity check #2
if self._unit:contour()._contour_list then
if #self._unit:contour()._contour_list >= 1 then

for i=1, #self._unit:contour()._contour_list do
-- yet another sanity check
if self._unit:contour()._contour_list[i] and self._unit:contour()._contour_list[i].type and self._unit:contour()._contour_list[i].type == "friendly" then
self._unit:contour():remove( "friendly" , true )
end
end

if self._unit:contour() and self._unit:contour()._contour_list and #self._unit:contour()._contour_list >= 1 then
for i=1, #self._unit:contour()._contour_list do
if self._unit:contour()._contour_list[i] and self._unit:contour()._contour_list[i].type and self._unit:contour()._contour_list[i].type == "friendly" then
self._unit:contour():remove( "friendly" , true )
end
end
end
Expand All @@ -78,21 +69,15 @@ Hooks:PostHook(CopMovement, "action_request", "IDC_post_action_request_tweak_uni

-- if unit is part of our hostage list and requests a new action, remove their immortality since they are now untied/converted and their AI sends requests again
if immdomcops.hostages[self._unit:id()] then
-- check that unit can be immortal, just in case
if self._unit:character_damage().set_immortal then
-- check that unit is allready immortal
if self._unit:character_damage()._immortal ~= false then

self._unit:character_damage():set_invulnerable(false)
self._unit:character_damage():set_immortal(false)
self._unit:network():send("set_unit_invulnerable", false, false)

-- remove unit's id from our hostage list
immdomcops.hostages[self._unit:id()] = nil
end
end
end

end

end)
3 changes: 2 additions & 1 deletion lua/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ if not immdomcops then
immdomcops.hostages = {}
immdomcops.settings = {
highlights = true,
meleekill = true
keep_hl_for_mortals = true,
immortality_duration = 5
}

function immdomcops:Save()
Expand Down
2 changes: 1 addition & 1 deletion main.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<mod name="Immortal Dominated Cops" author="irbizzelus" color="Color(0.85,0,0.85)">
<AssetUpdates id="irbizzelus/IMMDOMCOPS" provider="github" release="true" version="1.6.1"/>
<AssetUpdates id="irbizzelus/IMMDOMCOPS" provider="github" release="true" version="1.7"/>
</mod>
25 changes: 23 additions & 2 deletions menus/immdomcopsmenu.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
dofile(ModPath .. "lua/menu.lua")
if not immdomcops then
dofile(ModPath .. "lua/menu.lua")
end

Hooks:Add('LocalizationManagerPostInit', 'immdomcops_loc', function(loc)
immdomcops:Load()
Expand Down Expand Up @@ -39,12 +41,31 @@ Hooks:Add('MenuManagerInitialize', 'immdomcops_init', function(menu_manager)
immdomcops:Save()
end

MenuCallbackHandler.idc_cb_meleekill = function(this, item)
MenuCallbackHandler.idc_cb_keep_hl_for_mortals = function(this, item)
immdomcops.settings[item:name()] = item:value() == 'on'
immdomcops:Save()
end

MenuCallbackHandler.idc_cb_immortality_duration = function(this, item)
immdomcops.settings.immortality_duration = math.floor(tonumber(item:value()))
immdomcops:Save()
end

immdomcops:Load()

MenuHelper:LoadFromJsonFile(immdomcops.modpath .. 'menus/immdomcopsmenu.txt', immdomcops, immdomcops.settings)
end)

Hooks:PostHook(MenuManager, "_node_selected", "IDC:Node", function(self, menu_name, node)
if type(node) == "table" and node._parameters.name == "main" and not immdomcops.settings.changelog_msg_shown or immdomcops.settings.changelog_msg_shown < 1.7 then
DelayedCalls:Add("IDC_showchangelogmsg_delayed", 0.9, function()
local menu_options = {}
menu_options[#menu_options+1] = {text = "Understood", is_cancel_button = true}
local message = "1.7 Important Update!!!\n\n- This update changed this mod's core mechanic of immortality to NOT LAST FOREVER. From now on, after FULLY intimidating a cop, they will loose their immortality after certain amount of seconds (you can change this duration in IDC mod options). Melee insta-kill option was removed and replaced with 2 new settings related to this change.\n- LOCALIZATION is not up to date unless you are running English/Russian language options in BLT settings.\n\nOn a personal note, from now on any user running versions older then 1.7 are considered cheaters in my eyes, because keeping a bunch of tied down immortal cops for perk/skill bonuses or easier game completions should not have been a thing with this mod from the start. Now this mod just removes frustration that other players could cause, without providing any gameplay advantages."
local menu = QuickMenu:new("Immortal dom'ed cops", message, menu_options)
menu:Show()
immdomcops.settings.changelog_msg_shown = 1.7
immdomcops:Save()
end)
end
end)
26 changes: 21 additions & 5 deletions menus/immdomcopsmenu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
"back_callback": "idc_immdomcopssave",
"items":
[
{
"type" : "divider",
"size" : 22
},
{
"type" : "toggle",
"id" : "highlights",
Expand All @@ -17,12 +21,24 @@
},
{
"type" : "toggle",
"id" : "meleekill",
"title" : "IMMDOMCOP_meleekill",
"description" : "IMMDOMCOP_meleekill_desc",
"callback" : "idc_cb_meleekill",
"value" : "meleekill",
"id" : "keep_hl_for_mortals",
"title" : "IMMDOMCOP_keep_hl_for_mortals",
"description" : "IMMDOMCOP_keep_hl_for_mortals_desc",
"callback" : "idc_cb_keep_hl_for_mortals",
"value" : "keep_hl_for_mortals",
"default_value" : true
},
{
"type" : "slider",
"id" : "immortality_duration",
"title" : "IMMDOMCOP_immortality_duration",
"description" : "IMMDOMCOP_immortality_duration_desc",
"callback" : "idc_cb_immortality_duration",
"value" : "immortality_duration",
"default_value" : 5,
"min" : 5,
"max" : 30,
"step" : 1
}
]
}
6 changes: 4 additions & 2 deletions menus/lang/immdomcopsmenu_chs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"IMMDOMCOP_desc": "Immortal dominated cops(已被恐吓的警察无敌)模组设置",
"IMMDOMCOP_highlights": "高亮轮廓",
"IMMDOMCOP_highlights_desc": "勾选或取消勾选以决定是否高亮被恐吓的警察的轮廓",
"IMMDOMCOP_meleekill": "近战一击必杀",
"IMMDOMCOP_meleekill_desc": "勾选后主机近战攻击已经完全投降的敌人会直接将其击杀"
"IMMDOMCOP_keep_hl_for_mortals": "Mortal highlights",
"IMMDOMCOP_keep_hl_for_mortals_desc": "If enabled, intimidated enemies who have lost their immortality will keep their blue highlight untill untied or killed. Requires highlights option to work.",
"IMMDOMCOP_immortality_duration": "Immortality duration",
"IMMDOMCOP_immortality_duration_desc": "After enemy completely gives up, they will loose their immortality after this amount of seconds. Slider values: 5-30.",
}
6 changes: 4 additions & 2 deletions menus/lang/immdomcopsmenu_en.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"IMMDOMCOP_desc": "",
"IMMDOMCOP_highlights": "Highlights",
"IMMDOMCOP_highlights_desc": "Enable or disable intimidated enemy highlighs",
"IMMDOMCOP_meleekill": "Melee insta-kill",
"IMMDOMCOP_meleekill_desc": "If enabled host can insta kill any cop who has given up completely with a melee attack"
"IMMDOMCOP_keep_hl_for_mortals": "Mortal highlights",
"IMMDOMCOP_keep_hl_for_mortals_desc": "If enabled, intimidated enemies who have lost their immortality will keep their blue highlight untill untied or killed. Requires highlights option to work.",
"IMMDOMCOP_immortality_duration": "Immortality duration",
"IMMDOMCOP_immortality_duration_desc": "After enemy completely gives up, they will loose their immortality after this amount of seconds. Slider values: 5-30.",
}
6 changes: 4 additions & 2 deletions menus/lang/immdomcopsmenu_es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"IMMDOMCOP_desc": "",
"IMMDOMCOP_highlights": "Contornos",
"IMMDOMCOP_highlights_desc": "Activa o desactiva los contornos de los enemigos dominados",
"IMMDOMCOP_meleekill": "Insta-Muerte cuerpo a cuerpo",
"IMMDOMCOP_meleekill_desc": "Si se activa el host puede matar instantáneamente a cualquier policía que se haya rendido completamente, con un ataque cuerpo a cuerpo"
"IMMDOMCOP_keep_hl_for_mortals": "Mortal highlights",
"IMMDOMCOP_keep_hl_for_mortals_desc": "If enabled, intimidated enemies who have lost their immortality will keep their blue highlight untill untied or killed. Requires highlights option to work.",
"IMMDOMCOP_immortality_duration": "Immortality duration",
"IMMDOMCOP_immortality_duration_desc": "After enemy completely gives up, they will loose their immortality after this amount of seconds. Slider values: 5-30.",
}
6 changes: 4 additions & 2 deletions menus/lang/immdomcopsmenu_fr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"IMMDOMCOP_desc": "",
"IMMDOMCOP_highlights": "Surbrillance",
"IMMDOMCOP_highlights_desc": "Active ou désactive la surbrillance des ennemis dominés",
"IMMDOMCOP_meleekill": "Meutre instantanée via mélée",
"IMMDOMCOP_meleekill_desc": "Si activer, l'hôte peut tuer instantanément un flic qui s'est rendu avec une attaque de mêlée"
"IMMDOMCOP_keep_hl_for_mortals": "Mortal highlights",
"IMMDOMCOP_keep_hl_for_mortals_desc": "If enabled, intimidated enemies who have lost their immortality will keep their blue highlight untill untied or killed. Requires highlights option to work.",
"IMMDOMCOP_immortality_duration": "Immortality duration",
"IMMDOMCOP_immortality_duration_desc": "After enemy completely gives up, they will loose their immortality after this amount of seconds. Slider values: 5-30.",
}
6 changes: 4 additions & 2 deletions menus/lang/immdomcopsmenu_pt-br.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"IMMDOMCOP_desc": "",
"IMMDOMCOP_highlights": "Destaque",
"IMMDOMCOP_highlights_desc": "Decide se os policiais dominados são destacados",
"IMMDOMCOP_meleekill": "Instakill com Melee",
"IMMDOMCOP_meleekill_desc": "Se estiver ativado, o Host poderá matar o policial dominado com a Melee"
"IMMDOMCOP_keep_hl_for_mortals": "Mortal highlights",
"IMMDOMCOP_keep_hl_for_mortals_desc": "If enabled, intimidated enemies who have lost their immortality will keep their blue highlight untill untied or killed. Requires highlights option to work.",
"IMMDOMCOP_immortality_duration": "Immortality duration",
"IMMDOMCOP_immortality_duration_desc": "After enemy completely gives up, they will loose their immortality after this amount of seconds. Slider values: 5-30.",
}
8 changes: 5 additions & 3 deletions menus/lang/immdomcopsmenu_ru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"IMMDOMCOP_title": "Immortal dominated cops",
"IMMDOMCOP_desc": "",
"IMMDOMCOP_highlights": "Подсветка",
"IMMDOMCOP_highlights_desc": "Включить или выключить подсветку сдавшихся врагов.",
"IMMDOMCOP_meleekill": "Убийство с рукопашного оружия",
"IMMDOMCOP_meleekill_desc": "Позволяет лидеру лобби убивать полностью сдавшихся врагов оружием ближнего боя"
"IMMDOMCOP_highlights_desc": "Включить или выключить подсветку сдающихся врагов синим контуром.",
"IMMDOMCOP_keep_hl_for_mortals": "Подсветка смертных",
"IMMDOMCOP_keep_hl_for_mortals_desc": "После того как враги потеряли свою неуязвимость, они продолжат подсветчиваться синим контуром, пока они не умрут или их не освободят союзники. Работает только если подсветка включена.",
"IMMDOMCOP_immortality_duration": "Продолжительность неуязвимости",
"IMMDOMCOP_immortality_duration_desc": "После того как враг полностью сдался, он потеряет свою неуязвимость через указанное количество секунд. Значения слайдера: 5-30.",
}
2 changes: 1 addition & 1 deletion mod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description" : "Gives immportality and visual highlights to dominated enemies.",
"author" : "irbizzelus\nBased on Undeadsewer's Intimidated Outlines",
"contact" : "Steam profile link is on my modworkshop account\nUndeadsewer: [email protected]",
"version" : "1.6.1",
"version" : "1.7",
"hooks" : [
{ "hook_id" : "lib/units/enemies/cop/copmovement", "script_path" : "lua/copmovement.lua" },
{ "hook_id" : "lib/units/enemies/cop/copdamage", "script_path" : "lua/copdamage.lua" },
Expand Down

0 comments on commit 2c04987

Please sign in to comment.