Skip to content

Commit

Permalink
fix chest duping probably, fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Dec 5, 2024
1 parent 0e09558 commit 942d6a1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 14 deletions.
4 changes: 3 additions & 1 deletion noita-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
37 changes: 37 additions & 0 deletions quant.ew/data/scripts/perks/angry_levitation_death.lua
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions quant.ew/data/scripts/perks/mana_from_kills_death.lua
Original file line number Diff line number Diff line change
@@ -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
8 changes: 4 additions & 4 deletions quant.ew/files/system/item_sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down
22 changes: 13 additions & 9 deletions quant.ew/files/system/player_tether/player_tether.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 942d6a1

Please sign in to comment.