fix cape as notplayer, dont make potion breaking noise on picking up a potion, fix spectator shield not working always

This commit is contained in:
bgkillas 2024-10-27 10:36:10 -04:00
parent 37cfd514e4
commit e3b34abe1a
5 changed files with 17 additions and 10 deletions

View file

@ -267,6 +267,8 @@ local player_fns = {
if EntityGetName(child) == "notcursor" then if EntityGetName(child) == "notcursor" then
EntityApplyTransform(child, message.mouse_x, message.mouse_y) EntityApplyTransform(child, message.mouse_x, message.mouse_y)
elseif EntityGetName(child) == "cursor" then elseif EntityGetName(child) == "cursor" then
player_data.mouse_x = message.my_x
player_data.mouse_y = message.my_y
EntityApplyTransform(child, message.my_x, message.my_y) EntityApplyTransform(child, message.my_x, message.my_y)
end end
end end
@ -378,6 +380,8 @@ local player_fns = {
projectile_rng_init = {}, projectile_rng_init = {},
projectile_seed_chain = {}, -- TODO clean projectile_seed_chain = {}, -- TODO clean
currently_polymorphed = false, currently_polymorphed = false,
mouse_x = 0,
mouse_y = 0,
} }
end, end,
} }

View file

@ -96,6 +96,12 @@ function item_sync.remove_item_with_id_now(gid)
for _, item in ipairs(global_items) do for _, item in ipairs(global_items) do
local i_gid = item_sync.get_global_item_id(item) local i_gid = item_sync.get_global_item_id(item)
if i_gid == gid then if i_gid == gid then
--TODO properly note when actually was from a peer picking up a potion maybe
for _, audio in ipairs(EntityGetComponent(item, "AudioComponent") or {}) do
if string.sub(ComponentGetValue2(audio, "event_root"), 1, 10) == "collision/" then
EntitySetComponentIsEnabled(item, audio, false)
end
end
EntityKill(item) EntityKill(item)
end end
end end

View file

@ -1,4 +1,4 @@
<Entity > <Entity name="cape">
<VerletPhysicsComponent <VerletPhysicsComponent
num_points="150" num_points="150"

View file

@ -88,7 +88,7 @@ function module.on_world_update()
if EntityGetName(child) == "cape" then if EntityGetName(child) == "cape" then
local cpe = EntityGetFirstComponentIncludingDisabled(child, "VerletPhysicsComponent") local cpe = EntityGetFirstComponentIncludingDisabled(child, "VerletPhysicsComponent")
local cx, cy = ComponentGetValue2(cpe, "m_position_previous") local cx, cy = ComponentGetValue2(cpe, "m_position_previous")
local dcx, dcy = x - cx, y - cy local dcx, dcy = mx - cx, my - cy
if dcx * dcx + dcy * dcy > 300 * 300 then if dcx * dcx + dcy * dcy > 300 * 300 then
EntityKill(child) EntityKill(child)
else else

View file

@ -24,7 +24,9 @@ rpc.opts_everywhere()
rpc.opts_reliable() rpc.opts_reliable()
function rpc.del_shield() function rpc.del_shield()
if shield_entities[ctx.rpc_peer_id] ~= nil then if shield_entities[ctx.rpc_peer_id] ~= nil then
EntityKill(shield_entities[ctx.rpc_peer_id][2]) if EntityGetIsAlive(shield_entities[ctx.rpc_peer_id][2]) then
EntityKill(shield_entities[ctx.rpc_peer_id][2])
end
shield_entities[ctx.rpc_peer_id] = nil shield_entities[ctx.rpc_peer_id] = nil
end end
end end
@ -80,7 +82,7 @@ function module.on_world_update()
end end
if GameGetFrameNum() % 10 == 8 then if GameGetFrameNum() % 10 == 8 then
local notplayer_active = GameHasFlagRun("ew_flag_notplayer_active") local notplayer_active = GameHasFlagRun("ew_flag_notplayer_active")
if shield_entities[ctx.my_id] ~= nil and not EntityGetIsAlive(shield_entities[ctx.my_id]) then if shield_entities[ctx.my_id] ~= nil and not EntityGetIsAlive(shield_entities[ctx.my_id][2]) then
rpc.del_shield() rpc.del_shield()
end end
if notplayer_active and ctx.spectating_over_peer_id ~= nil and is_acceptable_help_target(ctx.spectating_over_peer_id) then if notplayer_active and ctx.spectating_over_peer_id ~= nil and is_acceptable_help_target(ctx.spectating_over_peer_id) then
@ -108,12 +110,7 @@ function module.on_world_update()
his_x, his_y = DEBUG_GetMouseWorld() his_x, his_y = DEBUG_GetMouseWorld()
end end
else else
for _, child in ipairs(EntityGetAllChildren(ctx.players[shield_id].entity) or {}) do his_x, his_y = ctx.players[shield_id].mouse_x, ctx.players[shield_id].mouse_y
if (EntityGetName(child) == "cursor") then
his_x, his_y = EntityGetTransform(child)
break
end
end
end end
if his_x == nil or my_x == nil then if his_x == nil or my_x == nil then
goto continue goto continue