diff --git a/quant.ew/files/resource/cbs/item_notify.lua b/quant.ew/files/resource/cbs/item_notify.lua index d5f7ae9f..9986d235 100644 --- a/quant.ew/files/resource/cbs/item_notify.lua +++ b/quant.ew/files/resource/cbs/item_notify.lua @@ -1,5 +1,5 @@ function throw_item() - GlobalsSetValue("ew_thrown", tostring(GetUpdatedEntityID())) + CrossCall("ew_thrown", GetUpdatedEntityID()) end function item_pickup() @@ -8,5 +8,5 @@ function item_pickup() if com ~= nil then ComponentSetValue2(com, "permanently_attached", false) end - GlobalsSetValue("ew_picked", tostring(ent)) + CrossCall("ew_picked", ent) 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 c00e0488..b22e7b6e 100644 --- a/quant.ew/files/system/item_sync.lua +++ b/quant.ew/files/system/item_sync.lua @@ -259,14 +259,6 @@ function item_sync.make_item_global(item, instant, give_authority_to) end end -local function get_global_ent(key) - local val = tonumber(GlobalsGetValue(key, "0")) - GlobalsSetValue(key, "0") - if val ~= 0 then - return val - end -end - local function remove_client_items_from_world() if GameGetFrameNum() % 5 ~= 3 then return @@ -446,6 +438,27 @@ local function send_item_positions(all) dead_entities = {} end +util.add_cross_call("ew_thrown", function(thrown_item) + if thrown_item ~= nil + and (item_sync.get_global_item_id(thrown_item) == nil or item_sync.is_my_item(item_sync.get_global_item_id(thrown_item))) + and EntityGetFirstComponentIncludingDisabled(thrown_item, "VariableStorageComponent", "ew_egg") == nil then + item_sync.make_item_global(thrown_item) + end +end) + +util.add_cross_call("ew_picked", function(picked_item) + if picked_item ~= nil and EntityHasTag(picked_item, "ew_global_item") then + local gid = item_sync.get_global_item_id(picked_item) + if gid ~= nil then + if ctx.is_host then + item_sync.host_localize_item(gid, ctx.my_id) + else + rpc.item_localize_req(gid) + end + end + end +end) + function item_sync.on_world_update() -- TODO check that we not removing item we are going to pick now, instead of checking if picker gui is open. if is_safe_to_remove() then @@ -489,24 +502,7 @@ function item_sync.on_world_update() if GameGetFrameNum() % 5 == 4 then mark_in_inventory(ctx.my_player) end - local thrown_item = get_global_ent("ew_thrown") - if thrown_item ~= nil - and (item_sync.get_global_item_id(thrown_item) == nil or item_sync.is_my_item(item_sync.get_global_item_id(thrown_item))) - and EntityGetFirstComponentIncludingDisabled(thrown_item, "VariableStorageComponent", "ew_egg") == nil then - item_sync.make_item_global(thrown_item) - end - local picked_item = get_global_ent("ew_picked") - if picked_item ~= nil and EntityHasTag(picked_item, "ew_global_item") then - local gid = item_sync.get_global_item_id(picked_item) - if gid ~= nil then - if ctx.is_host then - item_sync.host_localize_item(gid, ctx.my_id) - else - rpc.item_localize_req(gid) - end - end - end remove_client_items_from_world() end diff --git a/quant.ew/files/system/local_health/local_health.lua b/quant.ew/files/system/local_health/local_health.lua index aa31808f..48da1faf 100644 --- a/quant.ew/files/system/local_health/local_health.lua +++ b/quant.ew/files/system/local_health/local_health.lua @@ -486,7 +486,7 @@ function module.on_world_update() -- Restore the player back to small amount of hp. local new_hp = 3 * max_hp_new / 20 if ctx.proxy_opt.no_notplayer then - new_hp = new_hp * 3 + new_hp = new_hp * 5 end local final_hp = math.max(new_hp, math.min(2/5, max_hp_new)) util.set_ent_health(ctx.my_player.entity, {final_hp, max_hp_new}) diff --git a/quant.ew/init.lua b/quant.ew/init.lua index 89f769a7..69b55a1d 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -227,9 +227,9 @@ function OnProjectileFired(shooter_id, projectile_id, initial_rng, position_x, p np.SetProjectileSpreadRNG(rng) end ---function OnProjectileFiredPost(shooter_id, projectile_id, rng, position_x, position_y, target_x, target_y, send_message, --- unknown1, multicast_index, unknown3) ---end +function OnProjectileFiredPost(shooter_id, projectile_id, rng, position_x, position_y, target_x, target_y, send_message, + unknown1, multicast_index, unknown3) +end function OnPausedChanged(paused, is_wand_pickup) ctx.is_paused = paused