mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 15:13:16 +00:00
make item_data.gid == nil error slightly more silent, fix game over teleporting your camera to 0,0
This commit is contained in:
parent
cfb1dd9eb8
commit
e2aaa7bc2d
3 changed files with 83 additions and 65 deletions
|
@ -155,7 +155,10 @@ function inventory_helper.deserialize_single_item(item_data)
|
|||
ComponentAddTag(item_cost_component, "enabled_in_world")
|
||||
ComponentAddTag(item_cost_component, "shop_cost")
|
||||
ComponentSetValue2(item_cost_component, "cost", item_data.shop_info[1])
|
||||
if string.sub(item_data.gid, 1, 16) ~= ctx.my_id then
|
||||
if item_data.gid == nil then
|
||||
ComponentSetValue2(item_cost_component, "stealable", false)
|
||||
print("ERROR: why is ".. item_data.shop_info .. " gid nil" .. " item")
|
||||
elseif string.sub(item_data.gid, 1, 16) ~= ctx.my_id then
|
||||
ComponentSetValue2(item_cost_component, "stealable", false)
|
||||
else
|
||||
local mx, my = GameGetCameraPos()
|
||||
|
@ -290,8 +293,10 @@ end
|
|||
|
||||
function inventory_helper.set_item_data(item_data, player_data)
|
||||
local player = player_data.entity
|
||||
if (not EntityGetIsAlive(player)) then
|
||||
if player == nil or not EntityGetIsAlive(player) then
|
||||
if player ~= nil then
|
||||
GamePrint("Skip set_item_data, player ".. player_data.name .. " " .. player_data.entity .. " is dead")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -379,11 +384,13 @@ function inventory_helper.set_item_data(item_data, player_data)
|
|||
np.SetActiveHeldEntity(player, active_item_entity, false, false)
|
||||
end
|
||||
end
|
||||
local inventory2Comp = EntityGetFirstComponentIncludingDisabled(player, "Inventory2Component")
|
||||
if inventory2Comp ~= nil then
|
||||
async(function()
|
||||
wait(1)
|
||||
local inventory2Comp = EntityGetFirstComponentIncludingDisabled(player, "Inventory2Component")
|
||||
ComponentSetValue2(inventory2Comp, "mForceRefresh", true)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function inventory_helper.has_inventory_changed(player_data)
|
||||
|
|
|
@ -23,6 +23,32 @@ function module.on_player_died(player_entity)
|
|||
-- Also inventory items seem to be borked.
|
||||
end
|
||||
|
||||
local function end_poly_effect(ent)
|
||||
local serialized
|
||||
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
|
||||
local game_effect_comp = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
|
||||
if game_effect_comp then
|
||||
local effect = ComponentGetValue2(game_effect_comp, "effect")
|
||||
if effect == "POLYMORPH" or effect == "POLYMORPH_RANDOM" or effect == "POLYMORPH_UNSTABLE" then
|
||||
serialized = ComponentGetValue2(game_effect_comp, "mSerializedData")
|
||||
if serialized ~= nil then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if serialized == nil then
|
||||
return
|
||||
end
|
||||
local x, y = EntityGetTransform(ent)
|
||||
local new_ent = EntityCreateNew()
|
||||
np.DeserializeEntity(new_ent, base64.decode(serialized), x, y)
|
||||
np.SetPlayerEntity(new_ent)
|
||||
EntityKill(ent)
|
||||
GameAddFlagRun("ew_cam_wait")
|
||||
return new_ent
|
||||
end
|
||||
|
||||
local function do_switch_effect(short)
|
||||
-- Make an effect
|
||||
if not EntityGetIsAlive(ctx.my_player.entity) then
|
||||
|
@ -110,6 +136,9 @@ local function allow_notplayer_perk(perk_id)
|
|||
end
|
||||
|
||||
local function player_died()
|
||||
if ctx.my_player.entity == nil then
|
||||
return
|
||||
end
|
||||
-- Serialize inventory, perks, and max_hp, we'll need to copy it over to notplayer.
|
||||
local item_data = inventory_helper.get_item_data(ctx.my_player)
|
||||
remove_inventory()
|
||||
|
@ -143,12 +172,16 @@ local function player_died()
|
|||
end
|
||||
|
||||
local function do_game_over(message)
|
||||
GameSetCameraFree(false)
|
||||
net.proxy_notify_game_over()
|
||||
ctx.run_ended = true
|
||||
GameSetCameraFree(true)
|
||||
GameRemoveFlagRun("ew_flag_notplayer_active")
|
||||
ctx.my_player.entity = end_poly_effect(ctx.my_player.entity)
|
||||
local damage_model = EntityGetFirstComponentIncludingDisabled(ctx.my_player.entity, "DamageModelComponent")
|
||||
if damage_model ~= nil then
|
||||
ComponentSetValue2(damage_model, "wait_for_kill_flag_on_death", false)
|
||||
EntityInflictDamage(ctx.my_player.entity, 1000000, "DAMAGE_CURSE", message, "NONE", 0, 0, GameGetWorldStateEntity())
|
||||
end
|
||||
GameTriggerGameOver()
|
||||
EntityKill(ctx.my_player.entity)
|
||||
end
|
||||
|
@ -241,32 +274,6 @@ function module.inflict_damage(dmg)
|
|||
module.set_health(math.min(math.max(hp-dmg, 0), module.max_health()))
|
||||
end
|
||||
|
||||
local function end_poly_effect(ent)
|
||||
local serialized
|
||||
for _, child in ipairs(EntityGetAllChildren(ent) or {}) do
|
||||
local game_effect_comp = EntityGetFirstComponentIncludingDisabled(child, "GameEffectComponent")
|
||||
if game_effect_comp then
|
||||
local effect = ComponentGetValue2(game_effect_comp, "effect")
|
||||
if effect == "POLYMORPH" or effect == "POLYMORPH_RANDOM" or effect == "POLYMORPH_UNSTABLE" then
|
||||
serialized = ComponentGetValue2(game_effect_comp, "mSerializedData")
|
||||
if serialized ~= nil then
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if serialized == nil then
|
||||
return
|
||||
end
|
||||
local x, y = EntityGetTransform(ent)
|
||||
local new_ent = EntityCreateNew()
|
||||
np.DeserializeEntity(new_ent, base64.decode(serialized), x, y)
|
||||
np.SetPlayerEntity(new_ent)
|
||||
EntityKill(ent)
|
||||
GameAddFlagRun("ew_cam_wait")
|
||||
return new_ent
|
||||
end
|
||||
|
||||
-- Provides health capability
|
||||
ctx.cap.health = {
|
||||
health = module.health,
|
||||
|
@ -274,7 +281,7 @@ ctx.cap.health = {
|
|||
set_health = module.set_health,
|
||||
set_max_health = module.set_max_health,
|
||||
inflict_damage = module.inflict_damage,
|
||||
do_game_over = function(message) do_game_over(message) rpc.trigger_game_over(message) end,
|
||||
do_game_over = function(message) rpc.trigger_game_over(message) end,
|
||||
on_poly_death = function()
|
||||
local notplayer_active = GameHasFlagRun("ew_flag_notplayer_active")
|
||||
if notplayer_active then
|
||||
|
@ -343,6 +350,7 @@ function rpc.trigger_game_over(message)
|
|||
do_game_over(message)
|
||||
for _, player_data in pairs(ctx.players) do
|
||||
local entity = player_data.entity
|
||||
if entity ~= nil and EntityGetIsAlive(entity) then
|
||||
EntitySetComponentsWithTagEnabled(entity, "health_bar", false)
|
||||
EntitySetComponentsWithTagEnabled(entity, "health_bar_back", false)
|
||||
if EntityHasTag(entity, "ew_notplayer") then
|
||||
|
@ -369,6 +377,7 @@ function rpc.trigger_game_over(message)
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -718,11 +718,13 @@ local function teleport_to_area(area)
|
|||
x, y = 6400, 15000
|
||||
end
|
||||
end
|
||||
if x ~= nil then
|
||||
async(function()
|
||||
EntitySetTransform(ctx.my_player.entity, x, y)
|
||||
wait(30)
|
||||
EntitySetTransform(ctx.my_player.entity, x, y)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
local function teleport_to_next_hm()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue