From 942d6a189f8aeaa5862fed2f23e86a9c0540d17f Mon Sep 17 00:00:00 2001 From: bgkillas Date: Wed, 4 Dec 2024 21:58:45 -0500 Subject: [PATCH] fix chest duping probably, fix some errors --- noita-proxy/src/lib.rs | 4 +- .../scripts/perks/angry_levitation_death.lua | 37 +++++++++++++++++++ .../scripts/perks/mana_from_kills_death.lua | 27 ++++++++++++++ quant.ew/files/system/item_sync.lua | 8 ++-- .../system/player_tether/player_tether.lua | 22 ++++++----- 5 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 quant.ew/data/scripts/perks/angry_levitation_death.lua create mode 100644 quant.ew/data/scripts/perks/mana_from_kills_death.lua diff --git a/noita-proxy/src/lib.rs b/noita-proxy/src/lib.rs index 21db41da..ff24296b 100644 --- a/noita-proxy/src/lib.rs +++ b/noita-proxy/src/lib.rs @@ -320,7 +320,9 @@ impl Default for DefaultSettings { health_lost_on_revive: 0, no_material_damage: false, global_hp_loss: false, - perk_ban_list: "GLOBAL_GORE,GLASS_CANNON,REVENGE_RATS,PLAGUE_RATS,VOMIT_RATS,CORDYCEPS,MOLD".to_string(), + perk_ban_list: + "GLOBAL_GORE,GLASS_CANNON,REVENGE_RATS,PLAGUE_RATS,VOMIT_RATS,CORDYCEPS,MOLD" + .to_string(), perma_death: false, physics_damage: true, share_gold: false, diff --git a/quant.ew/data/scripts/perks/angry_levitation_death.lua b/quant.ew/data/scripts/perks/angry_levitation_death.lua new file mode 100644 index 00000000..526a78d0 --- /dev/null +++ b/quant.ew/data/scripts/perks/angry_levitation_death.lua @@ -0,0 +1,37 @@ +dofile_once("data/scripts/lib/utilities.lua") + +function death( damage_type_bit_field, damage_message, entity_thats_responsible, drop_items ) + local entity_id = GetUpdatedEntityID() + local pos_x, pos_y = EntityGetTransform( entity_id ) + + SetRandomSeed( GameGetFrameNum(), pos_x + pos_y + entity_id ) + + local perk_flag = "PERK_PICKED_HOVER_BOOST" + local pickup_count = tonumber( GlobalsGetValue( perk_flag .. "_PICKUP_COUNT", "0" ) ) + 1 + + local player_id = 0 + + local models = EntityGetComponent( entity_id, "VariableStorageComponent" ) + for i,v in ipairs( models or {}) do + local name = ComponentGetValue2( v, "name" ) + if ( name == "angry_levitation" ) then + player_id = ComponentGetValue2( v, "value_int" ) + end + end + + if ( player_id ~= nil ) and ( player_id ~= NULL_ENTITY ) then + local comp = EntityGetFirstComponent( player_id, "CharacterDataComponent" ) + + if ( comp ~= nil ) then + local flight = ComponentGetValue2( comp, "mFlyingTimeLeft" ) + local maxflight = ComponentGetValue2( comp, "fly_time_max" ) or 3.0 + + maxflight = 2 ^ pickup_count + ( 2 ^ ( pickup_count - 1 ) ) + + -- print( tostring(flight) .. ", " .. tostring(maxflight)) + flight = math.min( maxflight, flight + 1.2 ) + + ComponentSetValue2( comp, "mFlyingTimeLeft", flight ) + end + end +end \ No newline at end of file diff --git a/quant.ew/data/scripts/perks/mana_from_kills_death.lua b/quant.ew/data/scripts/perks/mana_from_kills_death.lua new file mode 100644 index 00000000..1de4e0cd --- /dev/null +++ b/quant.ew/data/scripts/perks/mana_from_kills_death.lua @@ -0,0 +1,27 @@ +dofile_once("data/scripts/lib/utilities.lua") + +function death( damage_type_bit_field, damage_message, entity_thats_responsible, drop_items ) + local entity_id = GetUpdatedEntityID() + local pos_x, pos_y = EntityGetTransform( entity_id ) + + SetRandomSeed( GameGetFrameNum(), pos_x + pos_y + entity_id ) + + local player_id = 0 + local flag_name = "PERK_PICKED_MANA_FROM_KILLS" + local pickup_count = tonumber( GlobalsGetValue( flag_name .. "_PICKUP_COUNT", "0" ) ) + + local models = EntityGetComponent( entity_id, "VariableStorageComponent" ) + for i,v in ipairs( models or {} ) do + local name = ComponentGetValue2( v, "name" ) + if ( name == "mana_from_kills" ) then + player_id = ComponentGetValue2( v, "value_int" ) + end + end + + if ( player_id ~= nil ) and ( player_id ~= NULL_ENTITY ) and ( pickup_count > 0 ) then + for i=1,pickup_count do + local eid = EntityLoad( "data/entities/misc/perks/mana_from_kills_effect.xml", pos_x, pos_y ) + EntityAddChild( player_id, eid ) + end + end +end \ No newline at end of file diff --git a/quant.ew/files/system/item_sync.lua b/quant.ew/files/system/item_sync.lua index ca518e9f..6bb6bdd5 100644 --- a/quant.ew/files/system/item_sync.lua +++ b/quant.ew/files/system/item_sync.lua @@ -24,6 +24,8 @@ local gid_last_frame_updated = {} local wait_on_send = {} +local wait_for_gid = {} + function rpc.open_chest(gid) local ent = item_sync.find_by_gid(gid) if ent ~= nil then @@ -37,6 +39,7 @@ function rpc.open_chest(gid) file = "data/scripts/items/chest_random.lua" end if file ~= nil then + wait_for_gid[gid] = GameGetFrameNum() + 600 EntityAddComponent2(ent, "LuaComponent", { script_source_file = file, execute_on_added = true, @@ -206,8 +209,6 @@ function item_sync.host_localize_item(gid, peer_id) end end -local wait_for_gid = {} - local function make_global(item, give_authority_to) if not EntityGetIsAlive(item) then print("Thrown item vanished before we could send it") @@ -599,8 +600,7 @@ function rpc.item_globalize(item_data) end local item = inventory_helper.deserialize_single_item(item_data) add_stuff_to_globalized_item(item, item_data.gid) - local coms = EntityGetComponent(item, "VariableStorageComponent") - for _, com in ipairs(coms) do + for _, com in ipairs(EntityGetComponent(item, "VariableStorageComponent") or {}) do if ComponentGetValue2(com, "name") == "throw_time" then ComponentSetValue2(com, "value_int", GameGetFrameNum()) end diff --git a/quant.ew/files/system/player_tether/player_tether.lua b/quant.ew/files/system/player_tether/player_tether.lua index 390a8931..df0a39c7 100644 --- a/quant.ew/files/system/player_tether/player_tether.lua +++ b/quant.ew/files/system/player_tether/player_tether.lua @@ -184,15 +184,19 @@ local was_not_hm = false local was_notplayer = false function rpc.give_new_length(new_range) - tether_length = new_range - tether_length_2 = new_range + 128 - tether_length_3 = math.max(tether_length_3 or 0, tether_length_2) - local host_playerdata = player_fns.peer_get_player_data(ctx.host_id, true) - if new_range == 0 then - tether_enable(false, host_playerdata.entity) - else - tether_enable(true, host_playerdata.entity) - set_tether_length(tether_length_3, host_playerdata.entity) + if new_range ~= nil then + tether_length = new_range + tether_length_2 = new_range + 128 + tether_length_3 = math.max(tether_length_3 or 0, tether_length_2) + local host_playerdata = player_fns.peer_get_player_data(ctx.host_id, true) + if host_playerdata ~= nil and host_playerdata.entity ~= nil then + if new_range == 0 then + tether_enable(false, host_playerdata.entity) + else + tether_enable(true, host_playerdata.entity) + set_tether_length(tether_length_3, host_playerdata.entity) + end + end end end