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

42 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
func(...)
return
end
local oldSetRandomSeed = SetRandomSeed
local shooter = EntityGetRootEntity(GetUpdatedEntityID())
local x, y = EntityGetTransform(GetUpdatedEntityID())
local seed = x * y + GameGetFrameNum()
if(EntityHasTag(shooter, "ew_client"))then
--GamePrint("2: shooter_rng_"..EntityGetName(shooter))
seed = tonumber(GlobalsGetValue("ew_action_rng_"..EntityGetName(shooter), "0")) or 0
else
if(GlobalsGetValue("ew_player_action_rng", "0") ~= "0")then
seed = tonumber(GlobalsGetValue("ew_player_action_rng", "0"))
else
GlobalsSetValue("ew_player_action_rng", tostring(seed))
end
end
SetRandomSeed = function()
oldSetRandomSeed(seed, seed)
end
func(...)
SetRandomSeed = oldSetRandomSeed
end
end