noita_entangled_worlds/quant.ew/files/resource/append/action_fix.lua

46 lines
1.2 KiB
Lua
Raw Normal View History

2024-05-12 15:31:08 +03:00
-- loop backwards through perk_list so we can remove entries
for i=#actions,1,-1 do
local action = actions[i]
local func = action.action
action.action = function(...)
if reflecting then
2024-05-12 15:31:08 +03:00
func(...)
return
end
local oldSetRandomSeed = SetRandomSeed
local shooter = EntityGetRootEntity(GetUpdatedEntityID())
local x, y = EntityGetTransform(GetUpdatedEntityID())
local seed = math.floor(x * y + GameGetFrameNum())
2024-05-12 15:31:08 +03:00
if EntityHasTag(shooter, "ew_client") then
2024-05-12 15:31:08 +03:00
seed = tonumber(GlobalsGetValue("ew_action_rng_"..EntityGetName(shooter), "0")) or 0
else
if GlobalsGetValue("ew_player_action_rng", "0") ~= "0" then
2024-05-12 15:31:08 +03:00
seed = tonumber(GlobalsGetValue("ew_player_action_rng", "0"))
else
GlobalsSetValue("ew_player_action_rng", tostring(seed))
end
end
SetRandomSeed = function()
2024-05-12 15:31:08 +03:00
oldSetRandomSeed(seed, seed)
end
func(...)
SetRandomSeed = oldSetRandomSeed
end
end
local orig = GetUpdatedEntityID
function GetUpdatedEntityID()
local ent = EntityGetRootEntity(orig())
return ent
2024-05-12 15:31:08 +03:00
end