From e673eb99300298b12552f7c401abd61b0b2180dc Mon Sep 17 00:00:00 2001 From: bgkillas Date: Sat, 23 Nov 2024 21:22:30 -0500 Subject: [PATCH] dont send map perk to peers, fix vomit/food clock potion on peers grabbing perks --- quant.ew/files/core/perk_fns.lua | 1 + quant.ew/files/system/map/append.lua | 8 +++++++ quant.ew/files/system/map/map.lua | 24 +++++++++++++++++++ .../perk_patches/append/perks_common.lua | 14 +++++++++++ quant.ew/init.lua | 1 + 5 files changed, 48 insertions(+) create mode 100644 quant.ew/files/system/map/append.lua create mode 100644 quant.ew/files/system/map/map.lua diff --git a/quant.ew/files/core/perk_fns.lua b/quant.ew/files/core/perk_fns.lua index fa2b69b6..11d3d6a6 100644 --- a/quant.ew/files/core/perk_fns.lua +++ b/quant.ew/files/core/perk_fns.lua @@ -19,6 +19,7 @@ local perks_to_ignore = { EXTRA_MANA = true, TELEKINESIS = true, HEARTS_MORE_EXTRA_HP = true, + MAP = true, } local global_perks = { diff --git a/quant.ew/files/system/map/append.lua b/quant.ew/files/system/map/append.lua new file mode 100644 index 00000000..1d041d00 --- /dev/null +++ b/quant.ew/files/system/map/append.lua @@ -0,0 +1,8 @@ +local old = GameCreateSpriteForXFrames +function GameCreateSpriteForXFrames(filename, ...) + if filename == "data/particles/spatial_map_player.png" then + CrossCall("ew_place_player_on_map") + else + old(filename, ...) + end +end \ No newline at end of file diff --git a/quant.ew/files/system/map/map.lua b/quant.ew/files/system/map/map.lua new file mode 100644 index 00000000..ab113e51 --- /dev/null +++ b/quant.ew/files/system/map/map.lua @@ -0,0 +1,24 @@ +dofile_once("data/scripts/lib/utilities.lua") + +ModLuaFileAppend("data/scripts/perks/map.lua", "mods/quant.ew/files/system/map/append.lua") + +util.add_cross_call("ew_place_player_on_map", function() + for peer_id, data in pairs(ctx.players) do + local x, y = EntityGetTransform(data.entity) + y = y - 4 + local _, mx = check_parallel_pos( x ) + local map_x = 0 * 512 + local map_y = 10 * 512 + + local mult_x = 512 / 6.0 + local mult_y = 512 / 6.0 + + local dx = math.min( math.max( ( map_x - mx ) / mult_x, -420), 420 ) + local dy = math.min( math.max( ( map_y - y ) / mult_y, -240), 240 ) + local pi_x = x - dx * 0.5 + local pi_y = y - dy * 0.5 + GameCreateSpriteForXFrames("data/particles/spatial_map_player.png", pi_x, pi_y, true, 0, 0, 1, true) + end +end) + +return {} \ No newline at end of file diff --git a/quant.ew/files/system/perk_patches/append/perks_common.lua b/quant.ew/files/system/perk_patches/append/perks_common.lua index ae3da32d..8bd95dc8 100644 --- a/quant.ew/files/system/perk_patches/append/perks_common.lua +++ b/quant.ew/files/system/perk_patches/append/perks_common.lua @@ -28,6 +28,20 @@ patch_perk_2("SHIELD", function(entity_perk_item, entity_who_picked, item_name, orig_fn(entity_perk_item, entity_who_picked, item_name, pickup_count) end) +patch_perk_2("FOOD_CLOCK", function(entity_perk_item, entity_who_picked, item_name, pickup_count, orig_fn) + if entity_who_picked ~= EntityGetWithTag("player_unit")[1] then + function EntityLoad() end + end + orig_fn(entity_perk_item, entity_who_picked, item_name, pickup_count) +end) + +patch_perk_2("VOMIT_RATS", function(entity_perk_item, entity_who_picked, item_name, pickup_count, orig_fn) + if entity_who_picked ~= EntityGetWithTag("player_unit")[1] then + function EntityLoad() end + end + orig_fn(entity_perk_item, entity_who_picked, item_name, pickup_count) +end) + patch_perk_2("ATTACK_FOOT", function(entity_perk_item, entity_who_picked, item_name, pickup_count, orig_fn) if pickup_count ~= 1 then GameHasFlagRun("ATTACK_FOOT_CLIMBER") diff --git a/quant.ew/init.lua b/quant.ew/init.lua index ad0ec726..971681e5 100755 --- a/quant.ew/init.lua +++ b/quant.ew/init.lua @@ -129,6 +129,7 @@ local function load_modules() ctx.load_system("spell_refresh") ctx.load_system("shiny_orb") ctx.load_system("potion_mimic") + ctx.load_system("map") end local function load_extra_modules()