fix player tether erroring on perma death, keep polied players loaded in

This commit is contained in:
bgkillas 2024-11-12 16:02:21 -05:00
parent f5c36200aa
commit d7ca6fc099
3 changed files with 10 additions and 4 deletions

View file

@ -543,6 +543,9 @@ function player_fns.replace_player_entity(new_entity, player_data)
local old_entity = player_data.entity
player_data.entity = new_entity
ctx.player_data_by_local_entity[new_entity] = player_data
if player_data.peer_id ~= ctx.my_player.peer_id then
EntityAddComponent2(new_entity, "StreamingKeepAliveComponent")
end
print("Replaced player entity: "..old_entity.." -> "..new_entity)
else
player_fns.spawn_player_for(player_data.peer_id, 0, 0, player_data)

View file

@ -463,14 +463,14 @@ local function init_state()
_tags = "aiming_reticle",
alpha = 1,
image_file = "data/ui_gfx/mouse_cursor.png",
ui_is_parent = 0,
ui_is_parent = false,
offset_x = 6,
offset_y = 35,
has_special_scale = 1,
has_special_scale = true,
special_scale_x = 1,
special_scale_y = 1,
z_index = -10000,
emissive = 1,
emissive = true,
})
local damage_model = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "DamageModelComponent")
if ctx.proxy_opt.no_material_damage then

View file

@ -187,6 +187,10 @@ local was_notplayer = false
function module.on_world_update()
if GameGetFrameNum() % 10 == 7 then
local host_playerdata = player_fns.peer_get_player_data(ctx.host_id, true)
if ctx.proxy_opt.perma_death and (not ctx.my_player.status.is_alive or not host_playerdata.is_alive) then
return
end
local x2, y2 = EntityGetTransform(ctx.my_player.entity)
if np.GetGameModeNr() ~= 2
and tonumber(SessionNumbersGetValue("NEW_GAME_PLUS_COUNT")) == 0
@ -215,7 +219,6 @@ function module.on_world_update()
if ctx.my_id == ctx.host_id then
return
end
local host_playerdata = player_fns.peer_get_player_data(ctx.host_id, true)
if host_playerdata == nil or host_playerdata.entity == nil or not EntityGetIsAlive(host_playerdata.entity) then
return
end