fix immortality and make items less easy to break

This commit is contained in:
bgkillas 2024-11-19 18:25:14 -05:00
parent 871994640c
commit 88c3f4c571
3 changed files with 38 additions and 16 deletions

View file

@ -213,6 +213,10 @@ function inventory_helper.get_item_data(player_data, fresh)
if immortal ~= 0 then
EntityRemoveComponent(item, immortal)
end
local damage_component = EntityGetFirstComponentIncludingDisabled(item, "DamageModelComponent")
if damage_component and damage_component ~= 0 then
ComponentSetValue2(damage_component, "wait_for_kill_flag_on_death", false)
end
SetRandomSeed(item + slot_x + item_x, slot_y + item_y)
@ -254,6 +258,16 @@ function inventory_helper.get_item_data(player_data, fresh)
local slot_x, slot_y = ComponentGetValue2(item_comp, "inventory_slot")
local item_x, item_y = EntityGetTransform(item)
local immortal = EntityGetFirstComponentIncludingDisabled(item, "LuaComponent", "ew_immortal")
if immortal ~= 0 then
EntityRemoveComponent(item, immortal)
end
local damage_component = EntityGetFirstComponentIncludingDisabled(item, "DamageModelComponent")
if damage_component and damage_component ~= 0 then
ComponentSetValue2(damage_component, "wait_for_kill_flag_on_death", false)
end
SetRandomSeed(item + slot_x + item_x, slot_y + item_y)
-- local item_id = entity.GetVariable(item, "arena_entity_id")

View file

@ -499,7 +499,11 @@ function rpc.item_globalize(item_data)
ComponentSetValue2(com, "value_int", GameGetFrameNum())
end
end
local damage_component = EntityGetFirstComponentIncludingDisabled(item, "DamageModelComponent")
if damage_component and damage_component ~= 0 then
ComponentSetValue2(damage_component, "wait_for_kill_flag_on_death", true)
EntityAddComponent2(item, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"})
end
if not is_my_item(item_data.gid) then
local itemcom = EntityGetFirstComponentIncludingDisabled(item, "ItemComponent")
if ComponentGetValue2(itemcom, "play_hover_animation") then

View file

@ -22,6 +22,10 @@ function rpc.got_thrown(peer_id, vx, vy)
if immortal == 0 then
EntityAddComponent2(item, "LuaComponent", {_tags="ew_immortal", script_damage_about_to_be_received = "mods/quant.ew/files/resource/cbs/immortal.lua"})
end
local damage_component = EntityGetFirstComponentIncludingDisabled(item, "DamageModelComponent")
if damage_component and damage_component ~= 0 then
ComponentSetValue2(damage_component, "wait_for_kill_flag_on_death", true)
end
end
end