fix some errors

This commit is contained in:
bgkillas 2024-10-05 17:37:41 -04:00
parent f98f7178a7
commit 2bb5239a5a
3 changed files with 12 additions and 7 deletions

View file

@ -102,7 +102,10 @@ end
function net_handling.mod.fire(peer_id, fire_data)
local player_data = player_fns.peer_get_player_data(peer_id)
local entity = player_data.entity
if ctx.my_id ~= ctx.host_id then
if not EntityGetIsAlive(entity) then
return
end
if ctx.my_id ~= ctx.host_id and EntityGetIsAlive(ctx.my_player.entity) then
local x, y = EntityGetTransform(entity)
local my_x, my_y = EntityGetTransform(ctx.my_player.entity)
local cam_x, cam_y = GameGetCameraPos()

View file

@ -11,7 +11,7 @@ local gui = GuiCreate()
function rpc.kill_karl()
for _, entity in ipairs(EntityGetWithTag("racing_cart")) do
local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl")
if ComponentGetValue2(com, "value_string") == ctx.rpc_peer_id then
if com ~= nil and ComponentGetValue2(com, "value_string") == ctx.rpc_peer_id then
EntityKill(entity)
break
end
@ -22,7 +22,7 @@ function rpc.send_karl(x, y, vx, vy, t, jet, rgb)
local players_karl
for _, entity in ipairs(EntityGetWithTag("racing_cart")) do
local com = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_karl")
if ComponentGetValue2(com, "value_string") == ctx.rpc_peer_id then
if com ~= nil and ComponentGetValue2(com, "value_string") == ctx.rpc_peer_id then
if players_karl ~= nil then
EntityKill(entity)
else

View file

@ -84,11 +84,13 @@ function module.on_projectile_fired(shooter_id, projectile_id, initial_rng, posi
-- Do not sync notplayer's projectiles extra time.
if ctx.my_player.currently_polymorphed and shooter_id == ctx.my_player.entity and not EntityHasTag(shooter_id, "player_unit") then
local projectileComponent = EntityGetFirstComponentIncludingDisabled(projectile_id, "ProjectileComponent")
local entity_that_shot = ComponentGetValue2(projectileComponent, "mEntityThatShot")
if entity_that_shot == 0 then
rpc.replicate_projectile(np.SerializeEntity(projectile_id), position_x, position_y, target_x, target_y)
if projectileComponent ~= nil then
local entity_that_shot = ComponentGetValue2(projectileComponent, "mEntityThatShot")
if entity_that_shot == 0 then
rpc.replicate_projectile(np.SerializeEntity(projectile_id), position_x, position_y, target_x, target_y)
end
EntityAddTag(projectile_id, "ew_no_enemy_sync")
end
EntityAddTag(projectile_id, "ew_no_enemy_sync")
end
end