Skip to content

Commit f5cb81d

Browse files
committed
try to fix notplayer holding 2 wands, fix an error in ai logic
1 parent 2bf1f58 commit f5cb81d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

quant.ew/files/system/notplayer_ai/notplayer_ai.lua

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,12 @@ local function teleport_outside_cursed()
10691069
end
10701070

10711071
local function hold_something()
1072+
if state.init_timer == 10 then
1073+
state.attack_wand = wandfinder.find_attack_wand({state.attack_wand})
1074+
end
1075+
if state.init_timer == 40 then
1076+
state.attack_wand = wandfinder.find_attack_wand({})
1077+
end
10721078
if GameGetFrameNum() % 20 == 5 then
10731079
find_new_wand()
10741080
end
@@ -1175,7 +1181,7 @@ local function hold_something()
11751181
spectate.disable_throwing(true, ctx.my_player.entity)
11761182
end
11771183

1178-
if has_water_potion or state.water_potion ~= nil then
1184+
if (has_water_potion or state.water_potion ~= nil) and state.water_potions[1] ~= nil then
11791185
state.expected_held = state.water_potions[1]
11801186
np.SetActiveHeldEntity(state.entity, state.water_potions[1], false, false)
11811187
if state.water_potion == nil then
@@ -1187,7 +1193,7 @@ local function hold_something()
11871193
state.had_potion = true
11881194
end
11891195
state.bathe = not target_is_ambrosia
1190-
elseif (has_bad_potion or state.bad_potion ~= nil) and tablet then
1196+
elseif (has_bad_potion or state.bad_potion ~= nil) and tablet and state.bad_potions[i] ~= nil then
11911197
state.expected_held = state.bad_potions[i]
11921198
if EntityHasTag(state.bad_potions[i], "potion") then
11931199
state.had_potion = true
@@ -1197,7 +1203,7 @@ local function hold_something()
11971203
state.bad_potion = state.bad_potions[i]
11981204
changed_held = true
11991205
end
1200-
elseif has_good_potion or state.good_potion ~= nil then
1206+
elseif (has_good_potion or state.good_potion ~= nil) and state.good_potion[1] ~= nil then
12011207
if EntityHasTag(state.good_potions[1], "potion") then
12021208
state.had_potion = true
12031209
end
@@ -1207,11 +1213,9 @@ local function hold_something()
12071213
state.good_potion = state.good_potions[1]
12081214
changed_held = true
12091215
end
1210-
else
1211-
if state.attack_wand ~= nil then
1212-
state.expected_held = state.attack_wand
1213-
np.SetActiveHeldEntity(state.entity, state.attack_wand, false, false)
1214-
end
1216+
elseif state.attack_wand ~= nil then
1217+
state.expected_held = state.attack_wand
1218+
np.SetActiveHeldEntity(state.entity, state.attack_wand, false, false)
12151219
end
12161220
local holding2 = ComponentGetValue2(inventory, "mActualActiveItem")
12171221
if holding ~= holding2 then

0 commit comments

Comments
 (0)