From 2903311aee46c1e88075ca37aa4d023a5248399f Mon Sep 17 00:00:00 2001 From: bgkillas Date: Tue, 10 Dec 2024 11:03:34 -0500 Subject: [PATCH] kick mode if no wand --- .../files/system/notplayer_ai/notplayer_ai.lua | 17 ++++++++++++----- .../files/system/notplayer_ai/wandfinder.lua | 3 ++- quant.ew/files/system/text/text.lua | 5 ++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua index 91a6bb56..fedc4e55 100644 --- a/quant.ew/files/system/notplayer_ai/notplayer_ai.lua +++ b/quant.ew/files/system/notplayer_ai/notplayer_ai.lua @@ -160,9 +160,10 @@ end local function find_new_wand() local children = EntityGetAllChildren(state.attack_wand) + local kick_mode if children == nil then table.insert(state.empty_wands, state.attack_wand) - state.attack_wand = wandfinder.find_attack_wand(combine_tables(state.empty_wands, state.bad_wands[state.target or 1])) + state.attack_wand, kick_mode = wandfinder.find_attack_wand(combine_tables(state.empty_wands, state.bad_wands[state.target or 1])) changed_held = true else local bad_mod = false @@ -216,10 +217,13 @@ local function find_new_wand() end if not is_any_not_empty then table.insert(state.empty_wands, state.attack_wand) - state.attack_wand = wandfinder.find_attack_wand(combine_tables(state.empty_wands, state.bad_wands[state.target or 1])) + state.attack_wand, kick_mode = wandfinder.find_attack_wand(combine_tables(state.empty_wands, state.bad_wands[state.target or 1])) changed_held = true end end + if kick_mode then + state.kick_mode = true + end end local function has_pheremoned(entity) @@ -511,6 +515,7 @@ local function init_state() dont_throw = true, stop_potion = false, bathe = false, + kick_mode = false, bad_potions = get_potions_of_type(bad_mats), good_potions = get_potions_of_type(good_mats), @@ -686,8 +691,8 @@ local function choose_movement() give_space = 100 end local is_froze = is_frozen(state.target) - if is_froze then - give_space = 5 + if is_froze or state.kick_mode then + give_space = 4 end if dist > 0 then state.control_a = dist > LIM @@ -862,7 +867,7 @@ local function choose_movement() move = -1 end state.dtype = 0 - if is_froze and math.abs(dist) < 10 then + if (is_froze or state.kick_mode) and math.abs(dist) < 10 then state.control_w = false end local did_hit_up, _, _ = RaytracePlatforms(my_x, my_y, my_x, my_y - 40) @@ -1132,6 +1137,8 @@ local function hold_something() EntitySetComponentsWithTagEnabled(pity_potion, "enabled_in_world", false) EntitySetComponentsWithTagEnabled(pity_potion, "enabled_in_hand", false) EntitySetComponentsWithTagEnabled(pity_potion, "enabled_in_inventory", true) + local item = EntityGetFirstComponentIncludingDisabled(pity_potion, "SpriteParticleEmitterComponent") + EntitySetComponentIsEnabled(pity_potion, item, false) end end diff --git a/quant.ew/files/system/notplayer_ai/wandfinder.lua b/quant.ew/files/system/notplayer_ai/wandfinder.lua index 9427fccc..ef20622a 100644 --- a/quant.ew/files/system/notplayer_ai/wandfinder.lua +++ b/quant.ew/files/system/notplayer_ai/wandfinder.lua @@ -26,7 +26,8 @@ end function wandfinder.find_attack_wand(dont_do) local wands = get_all_wands(dont_do) if #wands == 0 then - return nil + wands = get_all_wands({}) + return wands[Random(1, #wands)], true end local largest = {-1, -1} for _, wand in ipairs(wands) do diff --git a/quant.ew/files/system/text/text.lua b/quant.ew/files/system/text/text.lua index 67e160de..81707594 100644 --- a/quant.ew/files/system/text/text.lua +++ b/quant.ew/files/system/text/text.lua @@ -3,7 +3,6 @@ local gui = GuiCreate() local rpc = net.new_rpc_namespace() local text = "" -local enabled = false rpc.opts_everywhere() rpc.opts_reliable() @@ -31,8 +30,8 @@ local function world2gui( x, y ) return x, y, vres_scaling_factor end -local function calculateTextWidth(gui, text) - local width, _ = GuiGetTextDimensions(gui, text) +local function calculateTextWidth(msg) + local width, _ = GuiGetTextDimensions(gui, msg) return width end