mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
implement shiny orb sync properly
This commit is contained in:
parent
4eb4f2d085
commit
89498171c0
3 changed files with 20 additions and 48 deletions
|
@ -1,3 +1,3 @@
|
|||
function kick()
|
||||
CrossCall("ew_kicked_orb", GetUpdatedEntityID())
|
||||
CrossCall("ew_kicked_orb", GetUpdatedEntityID(), false)
|
||||
end
|
3
quant.ew/files/system/shiny_orb/append_greed.lua
Normal file
3
quant.ew/files/system/shiny_orb/append_greed.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
function kick()
|
||||
CrossCall("ew_kicked_orb", GetUpdatedEntityID(), true)
|
||||
end
|
|
@ -4,65 +4,34 @@ local rpc = net.new_rpc_namespace()
|
|||
|
||||
ModLuaFileAppend("data/scripts/items/gold_orb.lua", "mods/quant.ew/files/system/shiny_orb/append.lua")
|
||||
|
||||
ModLuaFileAppend("data/scripts/items/gold_orb_greed.lua", "mods/quant.ew/files/system/shiny_orb/append.lua")
|
||||
ModLuaFileAppend("data/scripts/items/gold_orb_greed.lua", "mods/quant.ew/files/system/shiny_orb/append_greed.lua")
|
||||
|
||||
dofile_once("data/scripts/lib/utilities.lua")
|
||||
|
||||
rpc.opts_everywhere()
|
||||
function rpc.kicked_orb(gid, rx, ry)
|
||||
function rpc.kicked_orb(gid, rx, ry, greed)
|
||||
if gid == nil or item_sync.find_by_gid(gid) == nil then
|
||||
return
|
||||
end
|
||||
local entity_id = item_sync.find_by_gid(gid)
|
||||
|
||||
local x, y = EntityGetTransform( entity_id )
|
||||
|
||||
local comp = EntityGetFirstComponent( entity_id, "VariableStorageComponent", "kick_count" )
|
||||
|
||||
SetRandomSeed( GameGetFrameNum(), x + y + entity_id )
|
||||
|
||||
if ( comp ~= nil ) then
|
||||
local count = ComponentGetValue2( comp, "value_int" )
|
||||
count = count + 1
|
||||
ComponentSetValue2( comp, "value_int", count )
|
||||
|
||||
SetRandomSeed(rx, ry)
|
||||
|
||||
local outcome = Random( 1, 22 )
|
||||
|
||||
if ( count < 2 ) then
|
||||
outcome = 10
|
||||
elseif ( count <= 4 ) then
|
||||
outcome = math.max( outcome, 2 )
|
||||
elseif ( count > 4 ) then
|
||||
outcome = math.max( 1, outcome - ( count - 2 ) )
|
||||
end
|
||||
|
||||
-- print( tostring( outcome ) )
|
||||
|
||||
if ( outcome == 1 ) then
|
||||
EntityLoad( "data/entities/projectiles/deck/explosion.xml", x, y )
|
||||
EntityKill( entity_id )
|
||||
return
|
||||
elseif ( outcome == 20 ) then
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_200.xml", x, y, Random(-40,40), Random(-40,40) )
|
||||
elseif ( outcome == 15 ) then
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_50.xml", x - 8, y, Random(-40,40), Random(-40,40) )
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_50.xml", x + 8, y, Random(-40,40), Random(-40,40) )
|
||||
elseif ( outcome < 10 ) then
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_10.xml", x, y, Random(-40,40), Random(-40,40) )
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_10.xml", x, y, Random(-40,40), Random(-40,40) )
|
||||
else
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_10.xml", x - 8, y, Random(-40,40), Random(-40,40) )
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_10.xml", x + 8, y, Random(-40,40), Random(-40,40) )
|
||||
shoot_projectile( entity_id, "data/entities/items/pickup/goldnugget_10.xml", x + 8, y, Random(-40,40), Random(-40,40) )
|
||||
end
|
||||
local old = SetRandomSeed
|
||||
function SetRandomSeed()
|
||||
old(rx, ry)
|
||||
end
|
||||
function GetUpdatedEntityID()
|
||||
return entity_id
|
||||
end
|
||||
if greed then
|
||||
dofile("data/scripts/items/gold_orb_greed.lua")
|
||||
else
|
||||
dofile("data/scripts/items/gold_orb.lua")
|
||||
end
|
||||
drop()
|
||||
end
|
||||
|
||||
np.CrossCallAdd("ew_kicked_orb", function(entity)
|
||||
np.CrossCallAdd("ew_kicked_orb", function(entity, greed)
|
||||
local x, y = EntityGetTransform( entity )
|
||||
rpc.kicked_orb(item_sync.get_global_item_id(entity), x + entity, y - GameGetFrameNum())
|
||||
rpc.kicked_orb(item_sync.get_global_item_id(entity), x + entity, y - GameGetFrameNum(), greed)
|
||||
end)
|
||||
|
||||
return {}
|
Loading…
Add table
Add a link
Reference in a new issue