@@ -158,6 +158,18 @@ local function combine_tables(a, b)
158
158
return c
159
159
end
160
160
161
+ local function find_teleport_wand ()
162
+ for _ , ent in ipairs (wandfinder .get_all_wands ({}) or {}) do
163
+ for _ , child in pairs (EntityGetAllChildren (ent ) or {}) do
164
+ local spell = EntityGetFirstComponentIncludingDisabled (child , " ItemActionComponent" )
165
+ local spell_name = ComponentGetValue2 (spell , " action_id" )
166
+ if spell_name == " TELEPORT_PROJECTILE" or spell_name == " TELEPORT_PROJECTILE_SHORT" then
167
+ return ent
168
+ end
169
+ end
170
+ end
171
+ end
172
+
161
173
local function find_new_wand ()
162
174
local children = EntityGetAllChildren (state .attack_wand )
163
175
local kick_mode
@@ -179,7 +191,6 @@ local function find_new_wand()
179
191
state .bad_wands [state .target or 1 ] = {}
180
192
end
181
193
table.insert (state .bad_wands [state .target or 1 ], state .attack_wand )
182
- table.insert (state .empty_wands , state .attack_wand )
183
194
state .attack_wand = wandfinder .find_attack_wand (combine_tables (state .empty_wands , state .bad_wands [state .target or 1 ]))
184
195
changed_held = true
185
196
return
@@ -217,12 +228,17 @@ local function find_new_wand()
217
228
end
218
229
if not is_any_not_empty then
219
230
table.insert (state .empty_wands , state .attack_wand )
220
- state .attack_wand , kick_mode = wandfinder .find_attack_wand (combine_tables (state .empty_wands , state .bad_wands [state .target or 1 ]))
231
+ if state .attack_wand == state .teleport_wand then
232
+ state .attack_wand , kick_mode = wandfinder .find_attack_wand (state .empty_wands )
233
+ else
234
+ state .attack_wand , kick_mode = wandfinder .find_attack_wand (combine_tables (state .empty_wands , state .bad_wands [state .target or 1 ]))
235
+ end
221
236
changed_held = true
222
237
end
223
238
end
224
239
if kick_mode then
225
240
state .kick_mode = true
241
+ state .attack_wand = state .teleport_wand
226
242
end
227
243
end
228
244
@@ -527,6 +543,7 @@ local function init_state()
527
543
had_potion = false ,
528
544
529
545
attack_wand = wandfinder .find_attack_wand ({}),
546
+ teleport_wand = find_teleport_wand (),
530
547
empty_wands = {},
531
548
bad_wands = {},
532
549
good_wands = {},
@@ -595,7 +612,9 @@ local function choose_wand_actions()
595
612
end
596
613
state .dont_throw = false
597
614
aim_at (t_x , t_y )
598
- fire_wand (not state .last_did_hit and state .init_timer > no_shoot_time and not changed_held )-- or has_water_potion)
615
+ fire_wand (not state .last_did_hit and state .init_timer > no_shoot_time
616
+ and not changed_held and (state .teleport_wand == nil or
617
+ state .teleport_wand ~= state .attack_wand or state .last_length > 100 * 100 ))
599
618
if changed_held then
600
619
changed_held = false
601
620
end
@@ -681,6 +700,14 @@ local function choose_movement()
681
700
end
682
701
local t_x , t_y = EntityGetTransform (state .target )
683
702
local dist = my_x - t_x
703
+ local dy = my_y - t_y
704
+ if dist * dist + dy * dy > 132 * 132
705
+ and state .teleport_wand ~= nil
706
+ and state .attack_wand ~= state .teleport_wand
707
+ and GameGetFrameNum () % 100 == 0 then
708
+ state .attack_wand = state .teleport_wand
709
+ changed_held = true
710
+ end
684
711
local LIM = give_space
685
712
if swap_side and (on_right ~= (my_x > t_x ) or GameGetFrameNum () % 300 == 299 ) then
686
713
swap_side = false
@@ -867,7 +894,7 @@ local function choose_movement()
867
894
move = - 1
868
895
end
869
896
state .dtype = 0
870
- if (is_froze or state .kick_mode ) and math.abs (dist ) < 10 then
897
+ if (is_froze or state .kick_mode ) and math.abs (dist ) < 10 and my_y < t_y then
871
898
state .control_w = false
872
899
end
873
900
local did_hit_up , _ , _ = RaytracePlatforms (my_x , my_y , my_x , my_y - 40 )
@@ -1041,10 +1068,10 @@ local function teleport_outside_cursed()
1041
1068
end
1042
1069
1043
1070
local function hold_something ()
1044
- local ch_x , ch_y = EntityGetTransform (state .entity )
1045
1071
if GameGetFrameNum () % 20 == 5 then
1046
1072
find_new_wand ()
1047
1073
end
1074
+ local ch_x , ch_y = EntityGetTransform (state .entity )
1048
1075
local inventory = EntityGetFirstComponent (ctx .my_player .entity , " Inventory2Component" )
1049
1076
local holding = ComponentGetValue2 (inventory , " mActualActiveItem" )
1050
1077
local i = 1
@@ -1220,7 +1247,7 @@ local function find_target()
1220
1247
else
1221
1248
local dx = x - x1
1222
1249
local dy = y - y1
1223
- state .last_length = dx * dx + dy + dy
1250
+ state .last_length = dx * dx + dy * dy
1224
1251
if not is_suitable_target (state .target )
1225
1252
or (state .last_length > (MAX_RADIUS + 128 ) * (MAX_RADIUS + 128 ))
1226
1253
or (IsInvisible (state .target ) and state .last_length > (INVIS_RANGE + 32 )* (INVIS_RANGE + 32 )) then
@@ -1436,7 +1463,7 @@ local function update()
1436
1463
1437
1464
find_target ()
1438
1465
1439
- do_kick = state .last_length ~= nil and state .last_length < no_shoot_time
1466
+ do_kick = state .last_length ~= nil and state .last_length < 100
1440
1467
1441
1468
hold_something ()
1442
1469
0 commit comments