From 343e48a3622c85cd22575aaba7957797d6d67cbb Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 23 Nov 2024 20:03:37 -0500 Subject: [PATCH] fix end fight, try to make end fight less laggy, sync angry ghost position, maybe fix shops with dedup off, --- .../data/scripts/animals/tiny_ghost_move.lua | 62 +++++++++++++++++++ .../angry_ghost_memory/angry_ghost_memory.lua | 8 ++- quant.ew/files/system/end_fight/end_fight.lua | 8 ++- .../perk_patches/append/cosmetics_append.lua | 2 +- quant.ew/init.lua | 4 +- 5 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 quant.ew/data/scripts/animals/tiny_ghost_move.lua diff --git a/quant.ew/data/scripts/animals/tiny_ghost_move.lua b/quant.ew/data/scripts/animals/tiny_ghost_move.lua new file mode 100644 index 00000000..254e2659 --- /dev/null +++ b/quant.ew/data/scripts/animals/tiny_ghost_move.lua @@ -0,0 +1,62 @@ +dofile_once("data/scripts/lib/utilities.lua") + +local lerp_amount = 0.975 +local bob_h = 6 +local bob_w = 20 +local bob_speed_y = 0.065 +local bob_speed_x = 0.01421 + +local entity_id = GetUpdatedEntityID() +local pos_x, pos_y = EntityGetTransform( entity_id ) + +if pos_x == 0 and pos_y == 0 then + -- get position from wand when starting + pos_x, pos_y = EntityGetTransform(EntityGetParent(entity_id)) +end + +-- ghost continously lerps towards a target that floats around the parent +local target_x, target_y = EntityGetTransform(EntityGetParent(entity_id)) +if target_x == nil then return end +target_y = target_y - 10 + +local time = CrossCall("ew_host_frame_num") +local r +local var_rnd = EntityGetFirstComponentIncludingDisabled(entity_id, "VariableStorageComponent", "ew_ghost_rnd") +if var_rnd == nil then + r = ProceduralRandomf(entity_id, 0, -1, 1) + EntityAddComponent2(entity_id, "VariableStorageComponent", {_tags="ew_ghost_rnd", value_float = r}) +else + r = ComponentGetValue(var_rnd, "value_float") +end + +-- randomize times and speeds slightly so that multiple ghosts don't fly identically +time = time + r * 10000 +bob_speed_y = bob_speed_y + (r * bob_speed_y * 0.1) +bob_speed_x = bob_speed_x + (r * bob_speed_x * 0.1) +lerp_amount = lerp_amount - (r * lerp_amount * 0.01) + +-- bob +target_y = target_y + math.sin(time * bob_speed_y) * bob_h +target_x = target_x + math.sin(time * bob_speed_x) * bob_w + +local dist_x = pos_x - target_x + +-- move towards target +pos_x,pos_y = vec_lerp(pos_x, pos_y, target_x, target_y, lerp_amount) +EntitySetTransform( entity_id, pos_x, pos_y, 0, 1, 1) + +-- animation state +edit_component( entity_id, "SpriteComponent", function(comp,vars) + local current_anim = ComponentGetValue( comp, "rect_animation") + + -- float when nearby and fly when further away + local mode = "float_" + if math.abs(dist_x) > 28 then mode = "fly_" end + + -- check if changing the animation is needed based on current animation and heading + if dist_x < 2 and current_anim ~= mode.."right" then + ComponentSetValue( comp, "rect_animation", mode.."right") + elseif dist_x > 2 and current_anim ~= mode.."left" then + ComponentSetValue( comp, "rect_animation", mode.."left") + end +end) \ No newline at end of file diff --git a/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua b/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua index bd74919f..db472c65 100644 --- a/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua +++ b/quant.ew/files/system/angry_ghost_memory/angry_ghost_memory.lua @@ -4,7 +4,9 @@ local ghost = {} function rpc.send_ghost_data(ghosts_memory) for i, entity in ipairs(EntityGetAllChildren(ctx.rpc_player_data.entity, "angry_ghost") or {}) do local memory = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "angry_ghost_projectile_memory") - ComponentSetValue2(memory, "value_string", ghosts_memory[i]) + ComponentSetValue2(memory, "value_string", ghosts_memory[i][1]) + EntitySetTransform(entity, ghosts_memory[i][2], ghosts_memory[i][3]) + ComponentSetValue2(EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_ghost_rnd"), "value_float", ghosts_memory[i][4]) end end @@ -15,7 +17,9 @@ function ghost.on_world_update() local ghosts_memory = {} for _, entity in ipairs(EntityGetAllChildren(ctx.my_player.entity, "angry_ghost") or {}) do local memory = EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "angry_ghost_projectile_memory") - table.insert(ghosts_memory, ComponentGetValue2(memory, "value_string")) + local x, y = EntityGetTransform(entity) + local rnd = ComponentGetValue2(EntityGetFirstComponentIncludingDisabled(entity, "VariableStorageComponent", "ew_ghost_rnd"), "value_float") + table.insert(ghosts_memory, {ComponentGetValue2(memory, "value_string"), x, y, rnd}) end if #ghosts_memory ~= 0 then rpc.send_ghost_data(ghosts_memory) diff --git a/quant.ew/files/system/end_fight/end_fight.lua b/quant.ew/files/system/end_fight/end_fight.lua index a1b0e384..05a35e8e 100644 --- a/quant.ew/files/system/end_fight/end_fight.lua +++ b/quant.ew/files/system/end_fight/end_fight.lua @@ -156,9 +156,13 @@ function end_fight.on_world_update() end end if init == -1 then - local x, y = EntityGetTransform(ctx.my_player.entity) - if is_in_box(5632, 7168, 14336, 15872, x, y) then + ModTextFileSetContent("data/entities/misc/loose_chunks.xml", "") + ModTextFileSetContent("data/entities/misc/loose_chunks_huge.xml", "") + ModTextFileSetContent("data/entities/projectiles/deck/crumbling_earth_effect.xml", "") + local _, y = EntityGetTransform(ctx.my_player.entity) + if y < 10414 then stop_fully = true + return end np.MagicNumbersSetValue("STREAMING_CHUNK_TARGET", 6) if EntityHasTag(ctx.my_player.entity, "ew_notplayer") then diff --git a/quant.ew/files/system/perk_patches/append/cosmetics_append.lua b/quant.ew/files/system/perk_patches/append/cosmetics_append.lua index 51873ee1..4392087e 100644 --- a/quant.ew/files/system/perk_patches/append/cosmetics_append.lua +++ b/quant.ew/files/system/perk_patches/append/cosmetics_append.lua @@ -36,7 +36,7 @@ function add_funginess_level(entity_who_picked) if peer_id ~= "DEBUG_NAME:player" then return end - local funginess = tonumber( GlobalsGetValue( "PLAYER_FUNGAL_LEVEL" .. peer_id, "0" ) ) + local funginess = tonumber( GlobalsGetValue( "PLAYER_FUNGAL_LEVEL", "0" ) ) funginess = funginess + 1 GlobalsSetValue( "PLAYER_FUNGAL_LEVEL", tostring( funginess ) ) diff --git a/quant.ew/init.lua b/quant.ew/init.lua index 1fd86fb6..ad0ec726 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -108,7 +108,9 @@ local function load_modules() ctx.load_system("essence_sync") ctx.load_system("spectate") ctx.load_system("effect_data_sync") - ctx.load_system("gen_sync") + if ctx.proxy_opt.item_dedup then + ctx.load_system("gen_sync") + end ctx.load_system("karl") ctx.load_system("remove_wand_sound") if ctx.proxy_opt.randomize_perks then