From 89498171c0efc7d228f202bf20d410be7691c8b6 Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sun, 3 Nov 2024 21:29:57 -0500 Subject: [PATCH] implement shiny orb sync properly --- quant.ew/files/system/shiny_orb/append.lua | 2 +- .../files/system/shiny_orb/append_greed.lua | 3 + quant.ew/files/system/shiny_orb/shiny_orb.lua | 63 +++++-------------- 3 files changed, 20 insertions(+), 48 deletions(-) create mode 100644 quant.ew/files/system/shiny_orb/append_greed.lua diff --git a/quant.ew/files/system/shiny_orb/append.lua b/quant.ew/files/system/shiny_orb/append.lua index f37c5791..1a8d63ee 100644 --- a/quant.ew/files/system/shiny_orb/append.lua +++ b/quant.ew/files/system/shiny_orb/append.lua @@ -1,3 +1,3 @@ function kick() - CrossCall("ew_kicked_orb", GetUpdatedEntityID()) + CrossCall("ew_kicked_orb", GetUpdatedEntityID(), false) end \ No newline at end of file diff --git a/quant.ew/files/system/shiny_orb/append_greed.lua b/quant.ew/files/system/shiny_orb/append_greed.lua new file mode 100644 index 00000000..3208cb3b --- /dev/null +++ b/quant.ew/files/system/shiny_orb/append_greed.lua @@ -0,0 +1,3 @@ +function kick() + CrossCall("ew_kicked_orb", GetUpdatedEntityID(), true) +end \ No newline at end of file diff --git a/quant.ew/files/system/shiny_orb/shiny_orb.lua b/quant.ew/files/system/shiny_orb/shiny_orb.lua index fe6ccb81..52c004b1 100644 --- a/quant.ew/files/system/shiny_orb/shiny_orb.lua +++ b/quant.ew/files/system/shiny_orb/shiny_orb.lua @@ -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 {} \ No newline at end of file