forked from xWar131x/TPT2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
find path.tpt2
79 lines (73 loc) · 2.06 KB
/
find path.tpt2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
:import adventure_lib
:name {package}:find path
:global int turbo.cycles.max
:global int turbo.cycles
:global string leon.adventure.path
:local vector curPos
:local string queue
:local string idx
:local string dir
:local string path
:local bool cantPhase
#setField(index, value) lss("_f" . {index}, {value})
#getField(index) lsg("_f" . {index})
turbo.cycles.max = max(turbo.cycles.max, turbo.cycles + 4000)
leon.adventure.path = ""
cantPhase = false == adventure.hasItem("bootsPhasing")\
|| 0 < max(\
max(\
max(\
adventure.countEntities("Chest"),\
adventure.countEntities("Enemy")\
),\
adventure.countEntities("Elite")\
),\
adventure.countEntities("Mimic")\
)
queue = {posToString(x(adventure.playerPos()), y(adventure.playerPos()))} . "S:"
loop1:
curPos = {firstElementPos}
idx = sub(queue, 0, 4)
{setField(if({getField(idx)} != "", "", idx), {firstElementDir})}
queue = sub(queue, 6, 99999) . if({getField(idx)} != {firstElementDir},\
"",\
if(\
adventure.isWall(curPos + vec(0., 1.)) && cantPhase\
|| max(x(curPos), y(curPos)) >= 18.\
|| x(curPos) < 1.,\
"",\
{posToString(x(curPos), y(curPos) + 1.)} . "U:"\
) . if(\
adventure.isWall(curPos + vec(0., -1.)) && cantPhase\
|| min(x(curPos), y(curPos)) < 1.\
|| x(curPos) >= 18.,\
"",\
{posToString(x(curPos), y(curPos) - 1.)} . "D:"\
) . if(\
adventure.isWall(curPos + vec(1., 0.)) && cantPhase\
|| max(x(curPos), y(curPos)) >= 18.\
|| y(curPos) < 1.,\
"",\
{posToString(x(curPos) + 1., y(curPos))} . "R:"\
) . if(\
adventure.isWall(curPos + vec(-1., 0.)) && cantPhase\
|| min(x(curPos), y(curPos)) < 1.\
|| y(curPos) >= 18.,\
"",\
{posToString(x(curPos) - 1., y(curPos))} . "L:"\
)\
)
goto(if(\
queue == "" || contains(idx, sub({target_positions}, 0, 4)),\
l2start,\
loop1\
))
loop2:
leon.adventure.path = dir . leon.adventure.path
curPos -= {nextDir(dir)}
idx = {posToString(x(curPos), y(curPos))}
l2start:
dir = {getField(idx)}
gotoif(loop2, dir != "S")
executesync("{package}:refine path")
wait(0.0)