Update max health based on amount of players

This commit is contained in:
IQuant 2024-05-15 20:50:27 +03:00
parent dea61560e9
commit 7a0efd4a9c
2 changed files with 10 additions and 3 deletions

View file

@ -417,6 +417,11 @@ function player_fns.spawn_player_for(peer_id, x, y)
util.set_ent_firing_blocked(new, true)
ctx.player_data_by_local_entity[new] = new_playerdata
ctx.events.new_player_just_spawned = true
local we = GameGetWorldStateEntity()
local seen = util.get_ent_variable(we, "player_seen") or {}
ctx.events.new_player_seen = seen[peer_id] == nil
seen[peer_id] = true
util.set_ent_variable(we, "player_seen", seen)
end
function player_fns.is_inventory_open()

View file

@ -130,9 +130,6 @@ function OnPlayerSpawned( player_entity ) -- This runs when player entity has be
np.SetPauseState(4)
np.SetPauseState(0)
local hp = util.get_ent_health(player_entity)
util.set_ent_health(player_entity, {hp*3, hp*3})
EntityAddTag(player_entity, "polymorphable_NOT") -- TODO
if ctx.is_host then
@ -185,6 +182,11 @@ local function on_world_pre_update_inner()
end
end
if ctx.events.new_player_seen then
local hp, max_hp = util.get_ent_health(my_player.entity)
util.set_ent_health(my_player.entity, {hp+4, max_hp+4})
end
if GameGetFrameNum() == 0 then
net.send_welcome()
end