-
Notifications
You must be signed in to change notification settings - Fork 0
/
p3_slay.inc
executable file
·225 lines (168 loc) · 5.47 KB
/
p3_slay.inc
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
SUB p3_slay_init {
/call p3RegisterCommand STOP slayStop 50
/call p3RegisterCommand KILL slayKill 55
/call p3RegisterCommand ROAMMOVESTART slayRoamStart 55
/declare slayProxMobs list outer
/declare slayTankStates[16] string outer -
/declare slayCheckTimer timer outer 0
/declare slaySearch string outer
/declare slayEnabled bool outer FALSE
/declare slayLeaderName string outer -
/declare amSlayLeader bool outer FALSE
/declare slayMembers string outer -
/declare slayLevelRange string outer 1 80
/declare slayRadius string outer 50
/declare slayExtra string outer
/varset slayLeaderName ${getBotIniOption[Slay.Leader,${slayLeaderName}]}
/varset slayMembers ${getBotIniOption[Slay.Members,${slayMembers}]}
/varset slayLevelRange ${getBotIniOption[Slay.MobLevelRange,${slayLevelRange}]}
/varset slayRadius ${getBotIniOption[Slay.ScanRadius,${slayRadius}]}
/varset slayExtra ${getBotIniOption[Slay.ExtraParams,${slayExtra}]}
/if (${slayLeaderName.Upper.Equal[${Me.CleanName}]}==TRUE) /varset amSlayLeader TRUE
/varset slaySearch npc los radius ${slayRadius} range ${slayLevelRange} ${slayExtra}
/if (${amSlayLeader}==TRUE) {
|/varset slayEnabled TRUE
/call clearTankStates
}
/RETURN
}
SUB slayRoamStart(string cmd, string opts) {
/varset slayCheckTimer 20
/RETURN
}
SUB slayKill(string cmd, string opts) {
/varset slayCheckTimer 2
/RETURN
}
SUB slayStop(string cmd, string opts) {
/call clearTankStates
/varset slayCheckTimer 30
/return
}
SUB slayMaintenance {
/if (${Me.Invis}==TRUE) /return
/if (${slayEnabled}==FALSE) /return
/if (${amSlayLeader}==FALSE) /return
/if (${slayCheckTimer}>0) /return
/if ((${Stick.Active}==TRUE || ${Nav.Active}==TRUE) && ${assistSpawnID}==0) /RETURN
/varset slayCheckTimer 5
/call verifySlayTankStates
/call scanMobs
/call checkTankAssignments
/RETURN
}
SUB scanMobs() {
/declare mobCount int local
/declare i int local
/declare xSpawn spawn local
/invoke ${slayProxMobs.Clear}
/varset mobCount ${SpawnCount[${slaySearch} loc ${Me.X} ${Me.Y}]}
/if (${mobCount}>0) {
/for i 1 to ${mobCount}
/if (${NearestSpawn[${i},${slaySearch}].ID}!=NULL) {
/vardata xSpawn NearestSpawn[${i},${slaySearch}]
/if (${xSpawn.Aggressive}==FALSE) /continue
/if (${noTouchIDs.Contains[${xSpawn.ID}]}) /continue
/invoke ${slayProxMobs.Append[${xSpawn.ID}]}
}
/next i
}
/varset mobCount ${SpawnCount[${slaySearch} loc ${Me.X} ${Me.Y} npcpet]}
/if (${mobCount}>0) {
/for i 1 to ${mobCount}
/if (${NearestSpawn[${i},${slaySearch} npcpet].ID}!=NULL) {
/vardata xSpawn NearestSpawn[${i},${slaySearch} npcpet]
/if (${xSpawn.Master.Type.Equal[PC]}) /continue
/if (${xSpawn.Aggressive}==FALSE) /continue
|/if (${xSpawn.Charmed.ID}!==NULL) /continue
/invoke ${slayProxMobs.Append[${xSpawn.ID}]}
}
/next i
}
/RETURN
}
SUB verifySlayTankStates() {
/declare max int local ${Math.Calc[${slayMembers.Count[,]}+1]}
/declare tankName string local
/declare tankTargetID string local
/declare i int local
/declare e string local
/for i 1 to ${max}
/varset e ${slayTankStates[${i}]}
/varset tankName ${e.Token[1,:]}
/varset tankTargetID ${e.Token[2,:]}
/if (${tankTargetID} != 0 && ${NetBots[${tankName}].TargetID} != ${tankTargetID}) {
/varset slayTankStates[${i}] ${tankName}:0
}
/next i
/RETURN
}
SUB clearTankStates() {
/declare max int local ${Math.Calc[${slayMembers.Count[,]}+1]}
/declare i int local
/for i 1 to ${max}
/varset slayTankStates[${i}] ${slayMembers.Token[${i},,]}:0
/next i
/RETURN
}
SUB checkTankAssignments() {
/if (${slayProxMobs.Count}==0) /RETURN
/declare i int local
/declare mobID int local
/declare freeTankIndex int local
/declare freeTankName string local
/for i 0 to ${Math.Calc[${slayProxMobs.Count}-1]}
/varset freeTankIndex ${getFreeTankIndex[]}
/varset freeTankName ${slayTankStates[${freeTankIndex}].Token[1,:]}
/varset mobID ${slayProxMobs.Item[${i}]}]}
/if (${freeTankIndex}==NULL) /RETURN
/if (${arrayIndexOf[slayTankStates,:${slayProxMobs.Item[${i}]}]}==NULL) {
/varset slayTankStates[${freeTankIndex}] ${freeTankName}:${mobID}
/bct ${freeTankName} assist on ${mobID}
/BC ${freeTankName} slay on ${mobID}
}
/next i
/RETURN
}
SUB getFreeTankIndex() {
/declare i int local
/declare tankName string local
/for i 0 to ${Math.Calc[${slayTankStates.Size}-1]}
/varset tankName ${slayTankStates[${i}].Token[1,:]}
/if (${Spawn[=${tankName}].ID}==NULL) /continue
/if (${slayTankStates[${i}].Find[:0]}!=NULL) /return ${i}
/next i
/RETURN NULL
}
SUB arrayIndexOf(string arr, string search) {
/declare i int local
/for i 0 to ${Math.Calc[${${arr}.Size}-1]}
/if (${${arr}[${i}].Find[${search}]}!=NULL) {
/return ${i}
}
/next i
/RETURN NULL
}
SUB slayBuildTeam() {
/declare i int local
/declare j int local
/declare c string local
/declare botName string local
/declare finalMembers string local
/declare prefTankOrder list local
/invoke ${prefTankOrder.Append[WAR,PAL,SHD,MNK,RNG,ROG,BST,BER]}
/for i 1 to ${Math.Calc[${prefTankOrder.Count}-1]}
/varset c ${prefTankOrder.Item[${i}]}
/for j 1 to ${NetBots.Counts}
/varset botName ${NetBots.Client[${j}]}
/if (${NetBots[${botName}].Class.ShortName.Equal[${c}]}) {
/varset finalMembers ${finalMembers},${botName}
}
/next j
/next i
/varset finalMembers ${finalMembers.Right[-1]}
/varset slayMembers ${finalMembers}
/call writeBotIniOption "Slay.Members" "${finalMembers}"
/echo New Slay Team/Order: ${finalMembers}
/RETURN
}