From e0d3fe7380c9d81be6d9dfe92cdd13d4a0c5b53d Mon Sep 17 00:00:00 2001 From: Nikita Tomashevich Date: Tue, 17 Sep 2024 11:03:06 +0300 Subject: [PATCH] (Hopefully) Randomize perks for players --- .../system/randomize_perks/override_perk_list.lua | 11 +++++++++++ .../files/system/randomize_perks/randomize_perks.lua | 3 +++ quant.ew/init.lua | 5 +++++ 3 files changed, 19 insertions(+) create mode 100644 quant.ew/files/system/randomize_perks/override_perk_list.lua create mode 100644 quant.ew/files/system/randomize_perks/randomize_perks.lua diff --git a/quant.ew/files/system/randomize_perks/override_perk_list.lua b/quant.ew/files/system/randomize_perks/override_perk_list.lua new file mode 100644 index 00000000..c04dcd1e --- /dev/null +++ b/quant.ew/files/system/randomize_perks/override_perk_list.lua @@ -0,0 +1,11 @@ +local orig_perk_get_spawn_order = perk_get_spawn_order + +function perk_get_spawn_order( ignore_these_ ) + SetRandomSeed(1, 2 + CrossCall("ew_per_peer_seed")) + local orig_SetRandomSeed = SetRandomSeed + function SetRandomSeed(x, y) end + + orig_perk_get_spawn_order( ignore_these_ ) + + SetRandomSeed = orig_SetRandomSeed +end \ No newline at end of file diff --git a/quant.ew/files/system/randomize_perks/randomize_perks.lua b/quant.ew/files/system/randomize_perks/randomize_perks.lua new file mode 100644 index 00000000..e51c5a6b --- /dev/null +++ b/quant.ew/files/system/randomize_perks/randomize_perks.lua @@ -0,0 +1,3 @@ +ModLuaFileAppend("data/scripts/perks/perk.lua", "mods/quant.ew/files/system/randomize_perks/override_perk_list.lua") + + diff --git a/quant.ew/init.lua b/quant.ew/init.lua index 036b458e..36f904bb 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -37,6 +37,10 @@ ModLuaFileAppend("data/scripts/gun/gun_actions.lua", "mods/quant.ew/files/resour ModMagicNumbersFileAdd("mods/quant.ew/files/magic.xml") +np.CrossCallAdd("ew_per_peer_seed", function() + return tonumber(ctx.my_id, 16) +end) + local function load_modules() ctx.dofile_and_add_hooks("mods/quant.ew/files/system/item_sync.lua") @@ -94,6 +98,7 @@ local function load_modules() ctx.load_system("spectate") ctx.load_system("effect_data_sync") ctx.load_system("gen_sync") + ctx.load_system("randomize_perks") end local function is_suitable_target(entity)