fix throwing things as/after notplayer disappearing

This commit is contained in:
bgkillas 2024-11-24 01:40:04 -05:00
parent e5427ecfae
commit a9be423f2f
2 changed files with 8 additions and 6 deletions

View file

@ -352,7 +352,7 @@ local function remove_non_send(item)
end
end
function inventory_helper.set_item_data(item_data, player_data)
function inventory_helper.set_item_data(item_data, player_data, local_ent)
local player = player_data.entity
if player == nil or not EntityGetIsAlive(player) then
return
@ -416,9 +416,11 @@ function inventory_helper.set_item_data(item_data, player_data)
if (itemInfo.active) then
active_item_entity = item_entity
end
if not local_ent then
EntityAddComponent(item_entity, "LuaComponent", {
script_throw_item = "mods/quant.ew/files/resource/cbs/throw_item.lua",
})
end
local notify = EntityGetFirstComponentIncludingDisabled(item_entity, "LuaComponent", "ew_notify_component")
if notify ~= nil then
EntityRemoveComponent(item_entity, notify)

View file

@ -280,7 +280,7 @@ local function player_died()
EntitySetComponentIsEnabled(child, EntityGetFirstComponentIncludingDisabled(child, "SpriteComponent"), false)
end
end
inventory_helper.set_item_data(item_data, ctx.my_player)
inventory_helper.set_item_data(item_data, ctx.my_player, true)
remove_inventory_tags()
perk_fns.update_perks_for_entity(perk_data, ctx.my_player.entity, allow_notplayer_perk)
util.set_ent_health(ctx.my_player.entity, {max_hp, max_hp})
@ -471,7 +471,7 @@ ctx.cap.health = {
ComponentSetValue2(damage_model, "mFireFramesLeft", 0)
ComponentSetValue2(damage_model, "air_in_lungs", ComponentGetValue2(damage_model, "air_in_lungs_max"))
end
inventory_helper.set_item_data(item_data, ctx.my_player)
inventory_helper.set_item_data(item_data, ctx.my_player, true)
remove_inventory_tags()
local controls = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "ControlsComponent")
if controls ~= nil then