From b8e16e1f1fa9bfcc160f2429aced67ce64c39cfb Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 23 Nov 2024 10:21:57 -0500 Subject: [PATCH] sync levi, maybe fix pyramid boss rewards, fix worms error, dont sync tower wands in generation --- quant.ew/files/core/inventory_helper.lua | 25 ++++++++++++++++--- quant.ew/files/system/enemy_sync.lua | 8 +++++- .../files/system/spawn_hooks/spawn_hooks.lua | 4 +++ quant.ew/files/system/worms/worms.lua | 2 +- quant.ew/init.lua | 3 ++- 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/quant.ew/files/core/inventory_helper.lua b/quant.ew/files/core/inventory_helper.lua index 51d56a0a..9f008bd1 100644 --- a/quant.ew/files/core/inventory_helper.lua +++ b/quant.ew/files/core/inventory_helper.lua @@ -92,12 +92,21 @@ function inventory_helper.serialize_single_item(item) if vel and vel ~= 0 then vx, vy = ComponentGetValue2(vel, "mVelocity") end - local sprite = EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent") - if sprite ~= nil then - sprite = ComponentGetValue2(sprite, "image_file") + local sprite_com = EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent") + local animation + local sprite + if sprite_com ~= nil and sprite_com ~= 0 then + sprite = ComponentGetValue2(sprite_com, "image_file") + animation = ComponentGetValue2(sprite_com, "rect_animation") + end + local shoot_pos = {} + local hotspot = EntityGetFirstComponentIncludingDisabled(item, "HotspotComponent") + if hotspot ~= nil and hotspot ~= 0 then + shoot_pos[1], shoot_pos[2] = ComponentGetValue2(hotspot, "offset") end local varp = EntityGetFilename(item) == "data/entities/items/wand_varpuluuta.xml" - item_data = {true, wand:Serialize(true, true), x, y, extra, is_new, {vx, vy}, sprite, image_inv, varp} + item_data = {true, wand:Serialize(true, true), x, y, extra, is_new, {vx, vy}, + sprite, image_inv, varp, shoot_pos, animation} else item_data = {false, util.serialize_entity(item), x, y} end @@ -121,9 +130,17 @@ function inventory_helper.deserialize_single_item(item_data) local vx, vy = item_data[7][1], item_data[7][2] local image = item_data[8] local image_inv = item_data[9] + local shoot_pos = item_data[11] + local animation = item_data[12] local sprite = EntityGetFirstComponentIncludingDisabled(item, "SpriteComponent") if sprite ~= nil then ComponentSetValue2(sprite, "image_file", image) + ComponentSetValue2(sprite, "rect_animation", animation) + ComponentSetValue2(sprite, "next_rect_animation", animation) + end + local hotspot = EntityGetFirstComponentIncludingDisabled(item, "HotspotComponent") + if hotspot ~= nil then + ComponentSetValue2(hotspot, "offset", shoot_pos[1], shoot_pos[2]) end if item_data[10] then local varp = EntityCreateNew() diff --git a/quant.ew/files/system/enemy_sync.lua b/quant.ew/files/system/enemy_sync.lua index e2a94bbf..aa7ac2b6 100644 --- a/quant.ew/files/system/enemy_sync.lua +++ b/quant.ew/files/system/enemy_sync.lua @@ -117,6 +117,9 @@ local function get_sync_entities(return_all) table_extend(entities, EntityGetWithTag("seed_c")) table_extend(entities, EntityGetWithTag("perk_fungus_tiny")) table_extend(entities, EntityGetWithTag("helpless_animal")) + table_extend_filtered(entities, EntityGetWithTag("touchmagic_immunity"), function(ent) + return EntityGetName(ent) == "$animal_fish_giga" + end) table_extend_filtered(entities, EntityGetWithTag("prop_physics"), function (ent) local f = EntityGetFilename(ent) if f ~= nil then @@ -659,7 +662,10 @@ function rpc.handle_death_data(death_data) end EntityInflictDamage(enemy_id, 1000000000, "DAMAGE_CURSE", "", "NONE", 0, 0, responsible_entity) -- Just to be sure - EntityKill(enemy_id) + async(function() + wait(1) + EntityKill(enemy_id) + end) end ::continue:: end diff --git a/quant.ew/files/system/spawn_hooks/spawn_hooks.lua b/quant.ew/files/system/spawn_hooks/spawn_hooks.lua index 63fa3574..957f11b8 100644 --- a/quant.ew/files/system/spawn_hooks/spawn_hooks.lua +++ b/quant.ew/files/system/spawn_hooks/spawn_hooks.lua @@ -27,6 +27,10 @@ local function is_sync_item(ent_path) if exclude[ent_path] then return false end + local good = "data/entities/items/wands/wand_good" + if string.sub(ent_path, 1, #good) == good then + return false + end local start = "data/entities/items/" if string.sub(ent_path, 1, #start) == start then return true diff --git a/quant.ew/files/system/worms/worms.lua b/quant.ew/files/system/worms/worms.lua index 4e45cb8d..135598e6 100644 --- a/quant.ew/files/system/worms/worms.lua +++ b/quant.ew/files/system/worms/worms.lua @@ -4,7 +4,7 @@ local function get_closest_alive(x, y) local min_dist local min_ent for _, player in pairs(ctx.players) do - if player.status.is_alive then + if not EntityHasTag(player.entity, "ew_notplayer") then local tx, ty = EntityGetTransform(player.entity) local dx, dy = tx - x, ty - y local dist = dx * dx + dy * dy diff --git a/quant.ew/init.lua b/quant.ew/init.lua index 0c653dc9..426b836b 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -26,7 +26,8 @@ constants = dofile_once("mods/quant.ew/files/core/constants.lua") local perk_fns = dofile_once("mods/quant.ew/files/core/perk_fns.lua") -local version = dofile_once("mods/quant.ew/files/version.lua") or "unknown (dev build)" +local version = ModDoesFileExist("mods/quant.ew/files/version.lua") and dofile_once("mods/quant.ew/files/version.lua") + or "unknown (dev build)" print("Noita EW version: "..version) dofile_once("data/scripts/lib/coroutines.lua")