fix some errors

This commit is contained in:
bgkillas 2024-10-19 15:38:35 -04:00
parent 96c7607436
commit 21af576be3
4 changed files with 8 additions and 10 deletions

View file

@ -145,7 +145,7 @@ local function player_died()
-- This may look like a hack, but it allows to use existing poly machinery to change player entity AND to store the original player for later, -- This may look like a hack, but it allows to use existing poly machinery to change player entity AND to store the original player for later,
-- Which is, like, perfect. -- Which is, like, perfect.
local ent = LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/local_health/notplayer/poly_effect.xml") local ent = LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/local_health/notplayer/poly_effect.xml")
ctx.my_player.entity = ent + 1 polymorph.switch_entity(ent + 1)
GameAddFlagRun("ew_flag_notplayer_active") GameAddFlagRun("ew_flag_notplayer_active")
do_switch_effect(false) do_switch_effect(false)
EntitySetName(ctx.my_player.entity, ctx.my_id.."?") EntitySetName(ctx.my_player.entity, ctx.my_id.."?")
@ -154,7 +154,6 @@ local function player_died()
EntityAddTag(iron, "kill_on_revive") EntityAddTag(iron, "kill_on_revive")
LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/spectate/no_tinker.xml") LoadGameEffectEntityTo(ctx.my_player.entity, "mods/quant.ew/files/system/spectate/no_tinker.xml")
set_cosmetics_locally(ctx.my_id) set_cosmetics_locally(ctx.my_id)
polymorph.switch_entity(ent + 1)
remove_healthbar_locally() remove_healthbar_locally()
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
@ -184,8 +183,8 @@ local function do_game_over(message)
if damage_model ~= nil and #(EntityGetAllChildren(ctx.my_player.entity) or {}) ~= 0 then if damage_model ~= nil and #(EntityGetAllChildren(ctx.my_player.entity) or {}) ~= 0 then
set_camera_free(true) set_camera_free(true)
GameRemoveFlagRun("ew_cam_wait") GameRemoveFlagRun("ew_cam_wait")
ctx.my_player.entity = end_poly_effect(ctx.my_player.entity) local ent = end_poly_effect(ctx.my_player.entity)
polymorph.switch_entity(ctx.my_player.entity) polymorph.switch_entity(ent)
if ctx.my_player.entity ~= nil then if ctx.my_player.entity ~= nil then
ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", false) ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", false)
EntityInflictDamage(ctx.my_player.entity, 1000000, "DAMAGE_CURSE", message, "NONE", 0, 0, GameGetWorldStateEntity()) EntityInflictDamage(ctx.my_player.entity, 1000000, "DAMAGE_CURSE", message, "NONE", 0, 0, GameGetWorldStateEntity())
@ -306,7 +305,7 @@ ctx.cap.health = {
remove_inventory() remove_inventory()
GameRemoveFlagRun("ew_flag_notplayer_active") GameRemoveFlagRun("ew_flag_notplayer_active")
local ent = end_poly_effect(ctx.my_player.entity) local ent = end_poly_effect(ctx.my_player.entity)
ctx.my_player.entity = ent polymorph.switch_entity(ent)
for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do for _, child in ipairs(EntityGetAllChildren(ctx.my_player.entity) or {}) do
if not EntityHasTag(child, "perk_entity") then if not EntityHasTag(child, "perk_entity") then
local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent") local com = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
@ -340,7 +339,6 @@ ctx.cap.health = {
end end
if GameHasFlagRun("ew_kill_player") then if GameHasFlagRun("ew_kill_player") then
GameRemoveFlagRun("ew_kill_player") GameRemoveFlagRun("ew_kill_player")
polymorph.switch_entity(ent)
async(function() async(function()
wait(1) wait(1)
if GameHasFlagRun("ending_game_completed") then if GameHasFlagRun("ending_game_completed") then
@ -351,11 +349,9 @@ ctx.cap.health = {
end) end)
else else
do_switch_effect(true) do_switch_effect(true)
polymorph.switch_entity(ent)
end end
else else
local ent = end_poly_effect(ctx.my_player.entity) local ent = end_poly_effect(ctx.my_player.entity)
ctx.my_player.entity = ent
polymorph.switch_entity(ent) polymorph.switch_entity(ent)
async(function() async(function()
wait(1) wait(1)

View file

@ -67,6 +67,9 @@ function module.on_world_update()
for peer_id, player in pairs(ctx.players) do for peer_id, player in pairs(ctx.players) do
local ent = player.entity local ent = player.entity
local x, y = EntityGetTransform(ent) local x, y = EntityGetTransform(ent)
if x == nil or not EntityGetIsAlive(ent) or EntityHasTag(ent, "polymorphed") then
return
end
local dx, dy = x - mx, y - my local dx, dy = x - mx, y - my
local cape local cape
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do for _, child in ipairs(EntityGetAllChildren(ent) or {}) do

View file

@ -2,7 +2,6 @@ local util = dofile_once("mods/quant.ew/files/core/util.lua")
local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua") local ctx = dofile_once("mods/quant.ew/files/core/ctx.lua")
local net = dofile_once("mods/quant.ew/files/core/net.lua") local net = dofile_once("mods/quant.ew/files/core/net.lua")
local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua") local player_fns = dofile_once("mods/quant.ew/files/core/player_fns.lua")
local wandfinder = dofile_once("mods/quant.ew/files/system/notplayer_ai/wandfinder.lua")
local np = require("noitapatcher") local np = require("noitapatcher")
local rpc = net.new_rpc_namespace() local rpc = net.new_rpc_namespace()

View file

@ -118,7 +118,7 @@ function module.on_world_update()
end end
end end
end end
if his_x == nil then if his_x == nil or my_x == nil then
goto continue goto continue
end end
local dx, dy = his_x - my_x, his_y - my_y local dx, dy = his_x - my_x, his_y - my_y