Skip to content

Commit

Permalink
Minor cleanup (#39)
Browse files Browse the repository at this point in the history
* Update enemy_mapping format

string.key function already turns strings into Idstrings

* Add missing enemy_mapping units

This includes Bellmead Marshals as well as all other faction-specific assault units

* Fix cop_scared surrender preset

This is the unkillable loud tutorial cop the game makes you dominate

* Fix groupaitweakdata oversights

short_ponr_heists now takes effect, and some PONR reenforce tweaks are fixed to actually apply to PONR

* Convert spaces to tabs

* Couple more spaces to tabs

* Fix error on game launch

* Make scripted spawn replacements work as intended
  • Loading branch information
erushinj authored Nov 2, 2023
1 parent c2941a2 commit 369bd10
Show file tree
Hide file tree
Showing 32 changed files with 361 additions and 305 deletions.
1 change: 0 additions & 1 deletion lua/charactertweakdata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ Hooks:PostHook(CharacterTweakData, "init", "eclipse_init", function(self)

-- surrender presets
self.security.surrender = self.presets.surrender.weak
self.cop_scared.surrender = self.presets.surrender.weak
self.cop.surrender = self.presets.surrender.weak
self.fbi.surrender = self.presets.surrender.weak
self.swat.surrender = self.presets.surrender.weak
Expand Down
2 changes: 1 addition & 1 deletion lua/criminalsmanager.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if Global.game_settings.one_down then
if Global.game_settings and Global.game_settings.one_down then
CriminalsManager.MAX_NR_TEAM_AI = 1
else
CriminalsManager.MAX_NR_TEAM_AI = 2
Expand Down
143 changes: 112 additions & 31 deletions lua/elementspawnenemydummy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,93 @@ local enemy_replacements = {
}
enemy_replacements.hard = enemy_replacements.normal
local enemy_mapping = {
[Idstring("units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1"):key()] = "dozer_1",
[Idstring("units/payday2/characters/ene_bulldozer_2/ene_bulldozer_2"):key()] = "dozer_1",
[Idstring("units/payday2/characters/ene_bulldozer_3/ene_bulldozer_3"):key()] = "dozer_1",
[Idstring("units/payday2/characters/ene_city_heavy_g36/ene_city_heavy_g36"):key()] = "heavy_1",
[Idstring("units/payday2/characters/ene_city_heavy_r870/ene_city_heavy_r870"):key()] = "heavy_2",
[Idstring("units/payday2/characters/ene_city_shield/ene_city_shield"):key()] = "shield",
[Idstring("units/payday2/characters/ene_city_swat_1/ene_city_swat_1"):key()] = "swat_1",
[Idstring("units/payday2/characters/ene_city_swat_2/ene_city_swat_2"):key()] = "swat_2",
[Idstring("units/payday2/characters/ene_city_swat_3/ene_city_swat_3"):key()] = "swat_3",
[Idstring("units/payday2/characters/ene_city_swat_r870/ene_city_swat_r870"):key()] = "swat_2",
[Idstring("units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1"):key()] = "heavy_1",
[Idstring("units/payday2/characters/ene_fbi_heavy_r870/ene_fbi_heavy_r870"):key()] = "heavy_2",
[Idstring("units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1"):key()] = "swat_1",
[Idstring("units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2"):key()] = "swat_2",
[Idstring("units/payday2/characters/ene_shield_1/ene_shield_1"):key()] = "shield",
[Idstring("units/payday2/characters/ene_shield_2/ene_shield_2"):key()] = "shield",
[Idstring("units/payday2/characters/ene_sniper_1/ene_sniper_1"):key()] = "sniper",
[Idstring("units/payday2/characters/ene_sniper_2/ene_sniper_2"):key()] = "sniper",
[Idstring("units/payday2/characters/ene_swat_1/ene_swat_1"):key()] = "swat_1",
[Idstring("units/payday2/characters/ene_swat_2/ene_swat_2"):key()] = "swat_2",
[Idstring("units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1"):key()] = "heavy_1",
[Idstring("units/payday2/characters/ene_swat_heavy_r870/ene_swat_heavy_r870"):key()] = "heavy_2",
[Idstring("units/payday2/characters/ene_medic_m4/ene_medic_m4"):key()] = "medic_1",
[Idstring("units/payday2/characters/ene_medic_r870/ene_medic_r870"):key()] = "medic_2",
[Idstring("units/payday2/characters/ene_tazer_1/ene_tazer_1"):key()] = "taser",
[Idstring("units/payday2/characters/ene_spook_1/ene_spook_1"):key()] = "cloaker",
[Idstring("units/pd2_dlc_gitgud/characters/ene_zeal_swat_heavy/ene_zeal_swat_heavy"):key()] = "heavy_1",
[Idstring("units/pd2_dlc_gitgud/characters/ene_zeal_swat_shield/ene_zeal_swat_shield"):key()] = "shield",
[Idstring("units/pd2_dlc_gitgud/characters/ene_zeal_swat/ene_zeal_swat"):key()] = "swat_1",
[Idstring("units/pd2_dlc_usm1/characters/ene_male_marshal_marksman_1/ene_male_marshal_marksman_1"):key()] = "swat_1",
[Idstring("units/pd2_dlc_usm2/characters/ene_male_marshal_shield_1/ene_male_marshal_shield_1"):key()] = "shield",
[("units/payday2/characters/ene_bulldozer_1/ene_bulldozer_1"):key()] = "dozer_1",
[("units/payday2/characters/ene_bulldozer_2/ene_bulldozer_2"):key()] = "dozer_1",
[("units/payday2/characters/ene_bulldozer_3/ene_bulldozer_3"):key()] = "dozer_1",
[("units/payday2/characters/ene_city_heavy_g36/ene_city_heavy_g36"):key()] = "heavy_1",
[("units/payday2/characters/ene_city_heavy_r870/ene_city_heavy_r870"):key()] = "heavy_2",
[("units/payday2/characters/ene_city_shield/ene_city_shield"):key()] = "shield",
[("units/payday2/characters/ene_city_swat_1/ene_city_swat_1"):key()] = "swat_1",
[("units/payday2/characters/ene_city_swat_2/ene_city_swat_2"):key()] = "swat_2",
[("units/payday2/characters/ene_city_swat_3/ene_city_swat_3"):key()] = "swat_3",
[("units/payday2/characters/ene_city_swat_r870/ene_city_swat_r870"):key()] = "swat_2",
[("units/payday2/characters/ene_fbi_heavy_1/ene_fbi_heavy_1"):key()] = "heavy_1",
[("units/payday2/characters/ene_fbi_heavy_r870/ene_fbi_heavy_r870"):key()] = "heavy_2",
[("units/payday2/characters/ene_fbi_swat_1/ene_fbi_swat_1"):key()] = "swat_1",
[("units/payday2/characters/ene_fbi_swat_2/ene_fbi_swat_2"):key()] = "swat_2",
[("units/payday2/characters/ene_shield_1/ene_shield_1"):key()] = "shield",
[("units/payday2/characters/ene_shield_2/ene_shield_2"):key()] = "shield",
[("units/payday2/characters/ene_sniper_1/ene_sniper_1"):key()] = "sniper",
[("units/payday2/characters/ene_sniper_2/ene_sniper_2"):key()] = "sniper",
[("units/payday2/characters/ene_swat_1/ene_swat_1"):key()] = "swat_1",
[("units/payday2/characters/ene_swat_2/ene_swat_2"):key()] = "swat_2",
[("units/payday2/characters/ene_swat_heavy_1/ene_swat_heavy_1"):key()] = "heavy_1",
[("units/payday2/characters/ene_swat_heavy_r870/ene_swat_heavy_r870"):key()] = "heavy_2",
[("units/payday2/characters/ene_medic_m4/ene_medic_m4"):key()] = "medic_1",
[("units/payday2/characters/ene_medic_r870/ene_medic_r870"):key()] = "medic_2",
[("units/payday2/characters/ene_tazer_1/ene_tazer_1"):key()] = "taser",
[("units/payday2/characters/ene_spook_1/ene_spook_1"):key()] = "cloaker",
[("units/pd2_dlc_gitgud/characters/ene_zeal_swat_heavy/ene_zeal_swat_heavy"):key()] = "heavy_1",
[("units/pd2_dlc_gitgud/characters/ene_zeal_swat_shield/ene_zeal_swat_shield"):key()] = "shield",
[("units/pd2_dlc_gitgud/characters/ene_zeal_swat/ene_zeal_swat"):key()] = "swat_1",
[("units/pd2_dlc_usm1/characters/ene_male_marshal_marksman_1/ene_male_marshal_marksman_1"):key()] = "swat_1",
[("units/pd2_dlc_usm2/characters/ene_male_marshal_shield_1/ene_male_marshal_shield_1"):key()] = "shield",
[("units/pd2_dlc_gitgud/characters/ene_zeal_bulldozer_2/ene_zeal_bulldozer_2"):key()] = "dozer_1",
[("units/pd2_dlc_gitgud/characters/ene_zeal_bulldozer_3/ene_zeal_bulldozer_3"):key()] = "dozer_1",
[("units/pd2_dlc_gitgud/characters/ene_zeal_bulldozer/ene_zeal_bulldozer"):key()] = "dozer_1",
[("units/pd2_dlc_drm/characters/ene_bulldozer_minigun_classic/ene_bulldozer_minigun_classic"):key()] = "dozer_1",
[("units/pd2_dlc_drm/characters/ene_bulldozer_minigun/ene_bulldozer_minigun"):key()] = "dozer_1",
[("units/pd2_dlc_drm/characters/ene_bulldozer_medic/ene_bulldozer_medic"):key()] = "dozer_1",
[("units/pd2_dlc_mad/characters/ene_akan_fbi_tank_r870/ene_akan_fbi_tank_r870"):key()] = "dozer_1",
[("units/pd2_dlc_mad/characters/ene_akan_fbi_tank_saiga/ene_akan_fbi_tank_saiga"):key()] = "dozer_1",
[("units/pd2_dlc_mad/characters/ene_akan_fbi_tank_rpk_lmg/ene_akan_fbi_tank_rpk_lmg"):key()] = "dozer_1",
[("units/pd2_dlc_hvh/characters/ene_bulldozer_hvh_1/ene_bulldozer_hvh_1"):key()] = "dozer_1",
[("units/pd2_dlc_hvh/characters/ene_bulldozer_hvh_2/ene_bulldozer_hvh_2"):key()] = "dozer_1",
[("units/pd2_dlc_hvh/characters/ene_bulldozer_hvh_3/ene_bulldozer_hvh_3"):key()] = "dozer_1",
[("units/pd2_dlc_bph/characters/ene_murkywater_bulldozer_2/ene_murkywater_bulldozer_2"):key()] = "dozer_1",
[("units/pd2_dlc_bph/characters/ene_murkywater_bulldozer_3/ene_murkywater_bulldozer_3"):key()] = "dozer_1",
[("units/pd2_dlc_bph/characters/ene_murkywater_bulldozer_4/ene_murkywater_bulldozer_4"):key()] = "dozer_1",
[("units/pd2_dlc_bph/characters/ene_murkywater_bulldozer_1/ene_murkywater_bulldozer_1"):key()] = "dozer_1",
[("units/pd2_dlc_bph/characters/ene_murkywater_bulldozer_medic/ene_murkywater_bulldozer_medic"):key()] = "dozer_1",
[("units/pd2_dlc_bex/characters/ene_swat_dozer_policia_federale_r870/ene_swat_dozer_policia_federale_r870"):key()] = "dozer_1",
[("units/pd2_dlc_bex/characters/ene_swat_dozer_policia_federale_saiga/ene_swat_dozer_policia_federale_saiga"):key()] = "dozer_1",
[("units/pd2_dlc_bex/characters/ene_swat_dozer_policia_federale_m249/ene_swat_dozer_policia_federale_m249"):key()] = "dozer_1",
[("units/pd2_dlc_bex/characters/ene_swat_dozer_policia_federale_minigun/ene_swat_dozer_policia_federale_minigun"):key()] = "dozer_1",
[("units/pd2_dlc_bex/characters/ene_swat_dozer_medic_policia_federale/ene_swat_dozer_medic_policia_federale"):key()] = "dozer_1",
[("units/pd2_dlc_mad/characters/ene_akan_cs_shield_c45/ene_akan_cs_shield_c45"):key()] = "shield",
[("units/pd2_dlc_mad/characters/ene_akan_fbi_shield_sr2_smg/ene_akan_fbi_shield_sr2_smg"):key()] = "shield",
[("units/pd2_dlc_mad/characters/ene_akan_fbi_shield_dw_sr2_smg/ene_akan_fbi_shield_dw_sr2_smg"):key()] = "shield",
[("units/pd2_dlc_hvh/characters/ene_shield_hvh_2/ene_shield_hvh_2"):key()] = "shield",
[("units/pd2_dlc_hvh/characters/ene_shield_hvh_1/ene_shield_hvh_1"):key()] = "shield",
[("units/pd2_dlc_bph/characters/ene_murkywater_shield/ene_murkywater_shield"):key()] = "shield",
[("units/pd2_dlc_bex/characters/ene_swat_shield_policia_federale_c45/ene_swat_shield_policia_federale_c45"):key()] = "shield",
[("units/pd2_dlc_bex/characters/ene_swat_shield_policia_federale_mp9/ene_swat_shield_policia_federale_mp9"):key()] = "shield",
[("units/pd2_dlc_mad/characters/ene_akan_cs_swat_sniper_svd_snp/ene_akan_cs_swat_sniper_svd_snp"):key()] = "sniper",
[("units/pd2_dlc_hvh/characters/ene_sniper_hvh_2/ene_sniper_hvh_2"):key()] = "sniper",
[("units/pd2_dlc_bph/characters/ene_murkywater_sniper/ene_murkywater_sniper"):key()] = "sniper",
[("units/pd2_dlc_bex/characters/ene_swat_policia_sniper/ene_swat_policia_sniper"):key()] = "sniper",
[("units/pd2_dlc_gitgud/characters/ene_zeal_tazer/ene_zeal_tazer"):key()] = "taser",
[("units/pd2_dlc_mad/characters/ene_akan_cs_tazer_ak47_ass/ene_akan_cs_tazer_ak47_ass"):key()] = "taser",
[("units/pd2_dlc_hvh/characters/ene_tazer_hvh_1/ene_tazer_hvh_1"):key()] = "taser",
[("units/pd2_dlc_bph/characters/ene_murkywater_tazer/ene_murkywater_tazer"):key()] = "taser",
[("units/pd2_dlc_bex/characters/ene_swat_tazer_policia_federale/ene_swat_tazer_policia_federale"):key()] = "taser",
[("units/pd2_dlc_gitgud/characters/ene_zeal_cloaker/ene_zeal_cloaker"):key()] = "cloaker",
[("units/pd2_dlc_mad/characters/ene_akan_fbi_spooc_asval_smg/ene_akan_fbi_spooc_asval_smg"):key()] = "cloaker",
[("units/pd2_dlc_hvh/characters/ene_spook_hvh_1/ene_spook_hvh_1"):key()] = "cloaker",
[("units/pd2_dlc_bph/characters/ene_murkywater_cloaker/ene_murkywater_cloaker"):key()] = "cloaker",
[("units/pd2_dlc_bex/characters/ene_swat_cloaker_policia_federale/ene_swat_cloaker_policia_federale"):key()] = "cloaker",
[("units/pd2_dlc_gitgud/characters/ene_zeal_medic_m4/ene_zeal_medic_m4"):key()] = "medic_1",
[("units/pd2_dlc_mad/characters/ene_akan_medic_ak47_ass/ene_akan_medic_ak47_ass"):key()] = "medic_1",
[("units/pd2_dlc_hvh/characters/ene_medic_hvh_m4/ene_medic_hvh_m4"):key()] = "medic_1",
[("units/pd2_dlc_bph/characters/ene_murkywater_medic/ene_murkywater_medic"):key()] = "medic_1",
[("units/pd2_dlc_bex/characters/ene_swat_medic_policia_federale/ene_swat_medic_policia_federale"):key()] = "medic_1",
[("units/pd2_dlc_gitgud/characters/ene_zeal_medic_r870/ene_zeal_medic_r870"):key()] = "medic_2",
[("units/pd2_dlc_mad/characters/ene_akan_medic_r870/ene_akan_medic_r870"):key()] = "medic_2",
[("units/pd2_dlc_hvh/characters/ene_medic_hvh_r870/ene_medic_hvh_r870"):key()] = "medic_2",
[("units/pd2_dlc_bph/characters/ene_murkywater_medic_r870/ene_murkywater_medic_r870"):key()] = "medic_2",
[("units/pd2_dlc_bex/characters/ene_swat_medic_policia_federale_r870/ene_swat_medic_policia_federale_r870"):key()] = "medic_2",
[("units/pd2_dlc_usm1/characters/ene_male_marshal_marksman_2/ene_male_marshal_marksman_2"):key()] = "swat_1",
[("units/pd2_dlc_usm2/characters/ene_male_marshal_shield_2/ene_male_marshal_shield_2"):key()] = "shield",
}

local difficulty
Expand All @@ -89,11 +145,36 @@ if tweak_data.levels[level_id] and tweak_data.levels[level_id].group_ai_state ==
else
difficulty = Global.game_settings and Global.game_settings.difficulty or "normal"
end

local mission_script_elements = StreamHeist:mission_script_patches()
Hooks:PostHook(ElementSpawnEnemyDummy, "init", "sh_init", function(self)
local element_mapping = mission_script_elements and mission_script_elements[self._id]
self._enemy_mapping = element_mapping and element_mapping.enemy

local mapped_name = enemy_mapping[self._enemy_name:key()]
local mapped_unit = enemy_replacements[difficulty] and enemy_replacements[difficulty][mapped_name]
local mapped_unit_ids = mapped_unit and Idstring(mapped_unit)
if mapped_unit_ids and mapped_unit_ids ~= self._enemy_name then
self._enemy_name = mapped_unit_ids
end
end)

local produce_original = ElementSpawnEnemyDummy.produce
function ElementSpawnEnemyDummy:produce(params, ...)
if params and params.name or not self._enemy_mapping then
return produce_original(self, params, ...)
end

local original_enemy_name = self._enemy_name
if type(self._enemy_mapping) == "table" then
self._enemy_name = table.random(self._enemy_mapping)
else
self._enemy_name = self._enemy_mapping
end

local result = produce_original(self, params, ...)

self._enemy_name = original_enemy_name

return result
end
18 changes: 9 additions & 9 deletions lua/groupaitweakdata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1929,13 +1929,13 @@ Hooks:PostHook(GroupAITweakData, "_init_task_data", "eclipse__init_task_data", f

local job = Global.level_data and Global.level_data.level_id
local short_ponr_heists = {
bph,
red2,
bex,
pex,
glace,
hox_2,
firestarter_2,
bph = true,
red2 = true,
bex = true,
pex = true,
glace = true,
hox_2 = true,
firestarter_2 = true,
}

-- Sustain
Expand Down Expand Up @@ -1991,7 +1991,7 @@ Hooks:PostHook(GroupAITweakData, "_init_task_data", "eclipse__init_task_data", f
fbi_tanks = { 0, 0.02, 0.1 },
spoocs = { 0, 0.03, 0.06 },
}
self.besiege.reenforce.groups = {
self.ponr.reenforce.groups = {
reenforce_common = { 0.3, 0.3, 0.3 },
reenforce_sneaky = { 0, 0.05, 0.1 },
}
Expand All @@ -2010,7 +2010,7 @@ Hooks:PostHook(GroupAITweakData, "_init_task_data", "eclipse__init_task_data", f
gensec_tanks = { 0, 0, 0.1 },
spoocs = { 0, 0.045, 0.09 },
}
self.besiege.reenforce.groups = {
self.ponr.reenforce.groups = {
reenforce_common = { 0.3, 0.3, 0.3 },
reenforce_sneaky = { 0.2, 0.2, 0.2 },
}
Expand Down
34 changes: 17 additions & 17 deletions mod.lua
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
if not EclipseDebug then
EclipseDebug = {}
local log_levels = {
"Debug",
"Warning",
"Error"
}

function EclipseDebug:log(level, message)
assert(0 < level and level < 4, "Eclipse log level must be between 1-3.")
assert(message ~= nil, "Eclipse empty log message.")

log(string.format("Eclipse %s: %s", log_levels[level], message))
end

function EclipseDebug:log_chat(message)
managers.chat:_receive_message(managers.chat.GAME, "Eclipse", message, Color.green)
end
EclipseDebug = {}
local log_levels = {
"Debug",
"Warning",
"Error"
}

function EclipseDebug:log(level, message)
assert(0 < level and level < 4, "Eclipse log level must be between 1-3.")
assert(message ~= nil, "Eclipse empty log message.")

log(string.format("Eclipse %s: %s", log_levels[level], message))
end

function EclipseDebug:log_chat(message)
managers.chat:_receive_message(managers.chat.GAME, "Eclipse", message, Color.green)
end
end

if not StreamHeist then
Expand Down
10 changes: 5 additions & 5 deletions req/mission_script/bex.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
return {
[101829] = {
ponr = 240,
ponr_player_mul = {2, 1.5, 1.25, 1}
}
}
[101829] = {
ponr = 240,
ponr_player_mul = {2, 1.5, 1.25, 1}
}
}
10 changes: 5 additions & 5 deletions req/mission_script/big.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
return {
[100809] = {
ponr = 180,
ponr_player_mul = {2, 1.25, 1, 1}
},
[100809] = {
ponr = 180,
ponr_player_mul = {2, 1.25, 1, 1}
},
[105844] = {
reinforce = {
{
Expand All @@ -17,4 +17,4 @@ return {
}
}
}
}
}
12 changes: 6 additions & 6 deletions req/mission_script/born.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
return {
[100628] = {
[100628] = {
values = {
enabled = false
}
},
[100720] = {
set_ponr_state = true
}
}
},
[100720] = {
set_ponr_state = true
}
}
18 changes: 9 additions & 9 deletions req/mission_script/dah.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
return {
[101967] = {
values = {
enabled = false
}
},
[100614] = {
set_ponr_state = true
}
}
[101967] = {
values = {
enabled = false
}
},
[100614] = {
set_ponr_state = true
}
}
12 changes: 6 additions & 6 deletions req/mission_script/des.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ return {
}
}
},
-- add point of no return
[100286] = {
ponr = 300,
ponr_player_mul = {1.6, 1.2, 1, 0.8}
}
}
-- add point of no return
[100286] = {
ponr = 300,
ponr_player_mul = {1.6, 1.2, 1, 0.8}
}
}
14 changes: 7 additions & 7 deletions req/mission_script/dinner.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
return {
[103218] = {
[103218] = {
values = {
enabled = false
}
},
[101061] = {
ponr = 200,
ponr_player_mul = {1.5, 1.25, 1, 1}
}
}
},
[101061] = {
ponr = 200,
ponr_player_mul = {1.5, 1.25, 1, 1}
}
}
10 changes: 5 additions & 5 deletions req/mission_script/firestarter_2.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
return {
[107196] = {
ponr = 60,
ponr_player_mul = {2.5, 1.5, 1, 1}
}
}
[107196] = {
ponr = 60,
ponr_player_mul = {2.5, 1.5, 1, 1}
}
}
Loading

0 comments on commit 369bd10

Please sign in to comment.