Fix having different seeds in gun actions.

This commit is contained in:
IQuant 2024-08-21 23:48:32 +03:00
parent 766cfb6b91
commit f657f811a5

View file

@ -5,7 +5,7 @@ for i=#actions,1,-1 do
local func = action.action local func = action.action
action.action = function(...) action.action = function(...)
if(reflecting)then if reflecting then
func(...) func(...)
return return
end end
@ -15,27 +15,24 @@ for i=#actions,1,-1 do
local shooter = EntityGetRootEntity(GetUpdatedEntityID()) local shooter = EntityGetRootEntity(GetUpdatedEntityID())
local x, y = EntityGetTransform(GetUpdatedEntityID()) local x, y = EntityGetTransform(GetUpdatedEntityID())
local seed = x * y + GameGetFrameNum() local seed = math.floor(x * y + GameGetFrameNum())
if(EntityHasTag(shooter, "ew_client"))then if EntityHasTag(shooter, "ew_client") then
--GamePrint("2: shooter_rng_"..EntityGetName(shooter))
seed = tonumber(GlobalsGetValue("ew_action_rng_"..EntityGetName(shooter), "0")) or 0 seed = tonumber(GlobalsGetValue("ew_action_rng_"..EntityGetName(shooter), "0")) or 0
else else
if(GlobalsGetValue("ew_player_action_rng", "0") ~= "0")then if GlobalsGetValue("ew_player_action_rng", "0") ~= "0" then
seed = tonumber(GlobalsGetValue("ew_player_action_rng", "0")) seed = tonumber(GlobalsGetValue("ew_player_action_rng", "0"))
else else
GlobalsSetValue("ew_player_action_rng", tostring(seed)) GlobalsSetValue("ew_player_action_rng", tostring(seed))
end end
end end
SetRandomSeed = function() SetRandomSeed = function()
oldSetRandomSeed(seed, seed) oldSetRandomSeed(seed, seed)
end end
func(...) func(...)
SetRandomSeed = oldSetRandomSeed SetRandomSeed = oldSetRandomSeed
end end