Skip to content

Commit

Permalink
kick mode if no wand
Browse files Browse the repository at this point in the history
  • Loading branch information
bgkillas committed Dec 10, 2024
1 parent b7bf8bc commit 2903311
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
17 changes: 12 additions & 5 deletions quant.ew/files/system/notplayer_ai/notplayer_ai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion quant.ew/files/system/notplayer_ai/wandfinder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions quant.ew/files/system/text/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local gui = GuiCreate()
local rpc = net.new_rpc_namespace()

local text = ""
local enabled = false

rpc.opts_everywhere()
rpc.opts_reliable()
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 2903311

Please sign in to comment.