View difference between Paste ID: aRuJNpyx and wwQXxguL
SHOW: | | - or go back to the newest paste.
1
/**
2
*	@filename	Precast.js
3
*	@author		D3STROY3R, kolton
4
*	@desc		handle player prebuff sequence
5
*/
6
7
var Precast = new function () {
8
	this.haveCTA = -1;
9
10
	this.weaponSwitch = function (slot) {
11
		if (me.gametype === 0) {
12
			return true;
13
		}
14
15
		var i, tick;
16
17
		if (!arguments.length) {
18
			slot = me.weaponswitch === 0 ? 1 : 0;
19
		} else if (me.weaponswitch === slot) {
20
			return true;
21
		}
22
23
		delay(500);
24
25
		for (i = 0; i < 10; i += 1) {
26
			weaponSwitch();
27
28
			tick = getTickCount();
29
30
			while (getTickCount() - tick < 2000) {
31
				if (me.weaponswitch === slot) {
32
					delay(me.ping + 1);
33
34
					return true;
35
				}
36
37
				delay(10);
38
			}
39
		}
40
41
		return false;
42
	};
43
44
	this.precastCTA = function (force) {
45
		if (!force && me.getState(32)) {
46
			return true;
47
		}
48
49
		if (me.gametype === 0 || me.classid === 4 || me.inTown) {
50
			return false;
51
		}
52
53
		if (this.BOSwitch()) {
54
			Skill.cast(155, 0); // Battle Command
55
			Skill.cast(149, 0); // Battle Orders
56
			this.weaponSwitch(Math.abs(this.haveCTA - 1));
57
58
			return true;
59
		}
60
61
		return false;
62
	};
63
64-
		// add this
64+
	// add this
65
	this.checkPlayers = function () {
66
		if (!Config.PublicMode) {
67
			return false;
68
		}
69
70
		var player = getUnit(0);
71
72
		if (player) {
73
			do {
74
				if (player.name !== me.name && !player.getState(32)) {
75
					Attack.getIntoPosition(player, 10, 0x4);
76
77
					return true;
78
				}
79
			} while (player.getNext());
80
		}
81
82
		return false;
83
	};
84
	// stop
85
86
	this.doPrecast = function (force) {
87
		var buffSummons = false;
88
89
		if (!me.getState(32) || force) {
90-
			// add this
90+
			// add
91
			if (this.checkPlayers()) {
92
				force = true;
93
			}
94
			// stop
95-
			
95+
96
			this.precastCTA(force);
97
		}
98
99
		switch (me.classid) {
100
		case 0: // Amazon
101
			if (Config.SummonValkyrie) {
102
				this.summon(32); // Valkyrie
103
			}
104
105
			break;
106
		case 1: // Sorceress
107
			if (!me.getState(38) || force) { // ts
108
				Skill.cast(57, 0); // Thunder Storm
109
			}
110
111
			if (!me.getState(30) || force) {
112
				Skill.cast(58, 0); // Energy Shield
113
			}
114
115
			if ((!me.getState(88) && !me.getState(10) && !me.getState(20)) || force) {
116
				if (!Skill.cast(50, 0)) { // Shiver Armor
117
					if (!Skill.cast(60, 0)) { // Chilling Armor
118
						Skill.cast(40, 0); // Frozen Armor
119
					}
120
				}
121
			}
122
123
			break;
124
		case 2: // Necromancer
125
			if (!me.getState(14) || force) {
126
				Skill.cast(68, 0);
127
			}
128
129
			switch (Config.Golem) {
130
			case 0:
131
			case "None":
132
				break;
133
			case 1:
134
			case "Clay":
135
				this.summon(75);
136
				break;
137
			case 2:
138
			case "Blood":
139
				this.summon(85);
140
				break;
141
			case 3:
142
			case "Fire":
143
				this.summon(94);
144
				break;
145
			}
146
147
			break;
148
		case 3: // Paladin
149
			if (!me.getState(101) || force) {
150
				Skill.cast(117, 0); // Holy Shield
151
			}
152
153
			break;
154
		case 4: // Barbarian
155
			if (!me.getState(32) || !me.getState(51) || !me.getState(26) || force) {
156
				if (Config.BOSwitch) {
157
					Precast.weaponSwitch(Config.BOSwitch);
158
				}
159
160
				if (!me.getState(51) || force) {
161
					Skill.cast(155, 0); // Battle Command
162
				}
163
164
				if (!me.getState(32) || force) {
165
					Skill.cast(149, 0); // Battle Orders
166
				}
167
168
				if (!me.getState(26) || force) {
169-
				
169+
170
				}
171
172
				if (Config.BOSwitch) {
173-
					
173+
174
				}
175
			}
176
177
			break;
178
		case 5: // Druid
179
			if (!me.getState(151) || force) {
180
				Skill.cast(235, 0); // Cyclone Armor
181
			}
182
183
			if (Config.SummonRaven) {
184
				this.summon(221); // Raven
185
			}
186
187
			switch (Config.SummonAnimal) {
188
			case 1:
189
			case "Spirit Wolf":
190
				buffSummons = this.summon(227) || buffSummons; // Summon Spirit Wolf
191
192
				break;
193
			case 2:
194
			case "Dire Wolf":
195
				buffSummons = this.summon(237) || buffSummons; // Summon Dire Wolf
196
197
				break;
198
			case 3:
199
			case "Grizzly":
200
				buffSummons = this.summon(247) || buffSummons; // Summon Grizzly
201
202
				break;
203
			}
204
205
			switch (Config.SummonVine) {
206
			case 1:
207
			case "Poison Creeper":
208
				buffSummons = this.summon(222) || buffSummons; // Poison Creeper
209
210
				break;
211
			case 2:
212
			case "Carrion Vine":
213
				buffSummons = this.summon(231) || buffSummons; // Carrion Vine
214
215
				break;
216
			case 3:
217
			case "Solar Creeper":
218
				buffSummons = this.summon(241) || buffSummons; // Solar Creeper
219
220
				break;
221
			}
222
223
			switch (Config.SummonSpirit) {
224
			case 1:
225
			case "Oak Sage":
226
				buffSummons = this.summon(226) || buffSummons; // Oak Sage
227
228
				break;
229
			case 2:
230
			case "Heart of Wolverine":
231
				buffSummons = this.summon(236) || buffSummons; // Heart of Wolverine
232
233
				break;
234
			case 3:
235
			case "Solar Creeper":
236
				buffSummons = this.summon(241) || buffSummons; // Solar Creeper
237
238
				break;
239
			}
240
241
			if (!me.getState(144) || force) {
242
				Skill.cast(250, 0); // Hurricane
243
			}
244
245
			if (buffSummons) {
246
				this.precastCTA(force);
247
			}
248
249
			break;
250
		case 6: // Assassin
251
			if (Config.UseFade && (!me.getState(159) || force)) {
252
				Skill.cast(267, 0); // Fade
253
			}
254
255
			if (Config.UseVenom && (!me.getState(31) || force)) {
256
				Skill.cast(278, 0); // Venom
257
			}
258
259
			if (!me.getState(158) || force) {
260
				Skill.cast(277, 0); // Blade Shield	
261
			}
262
263
			if (!Config.UseFade && Config.UseBoS && (!me.getState(157) || force)) {
264
				Skill.cast(258, 0); // Burst of Speed
265
			}
266
267
			switch (Config.SummonShadow) {
268
			case 1:
269
			case "Warrior":
270
				this.summon(268); // Shadow Warrior
271
				break;
272
			case 2:
273
			case "Master":
274
				this.summon(279); // Shadow Master
275
				break;
276
			}
277
278
			break;
279
		}
280
	};
281
282
	this.BOSwitch = function () {
283
		var item;
284
285
		if (this.haveCTA < 0) {
286
			item = me.getItem(-1, 1);
287
288
			if (item) {
289
MainLoop:
290
				do {
291
					if (item.getPrefix(20519)) { // Call to Arms
292
						switch (item.bodylocation) {
293
						case 4:
294
						case 5:
295
							this.haveCTA = me.weaponswitch;
296
297
							break MainLoop;
298
						case 11:
299
						case 12:
300
							this.haveCTA = Math.abs(me.weaponswitch - 1);
301
302
							break MainLoop;
303
						}
304
					}
305
				} while (item.getNext());
306
			}
307
		}
308
309
		if (this.haveCTA > -1) {
310
			return this.weaponSwitch(this.haveCTA);
311
		}
312
313
		return false;
314
	};
315
316
	this.summon = function (skillId) {
317
		if (!me.getSkill(skillId, 1)) {
318
			return false;
319
		}
320
321
		var minion, rv,
322
			count = 1;
323
324
		switch (skillId) {
325
		case 32: // Valkyrie
326
			minion = 2;
327
328
			break;
329
		case 75: // Clay Golem
330
		case 85: // Blood Golem
331
		case 94: // Fire Golem
332
			minion = 3;
333
334
			break;
335
		case 221: // Raven
336
			minion = 10;
337
			count = Math.min(me.getSkill(221, 1), 5);
338
339
			break;
340
		case 226: // Oak Sage
341
		case 236: // Heart of Wolverine
342
		case 246: // Spirit of Barbs
343
			minion = 13;
344
345
			break;
346
		case 222: // Poison Creeper
347
		case 231: // Carrion Vine
348
		case 241: // Solar Creeper
349
			minion = 14;
350
351
			break;
352
		case 227: // Spirit Wolf
353
			minion = 11;
354
			count = Math.min(me.getSkill(227, 1), 5);
355
356
			break;
357
		case 237: // Dire Wolf
358
			minion = 12;
359
			count = Math.min(me.getSkill(237, 1), 3);
360
361
			break;
362
		case 247: // Grizzly
363
			minion = 15;
364
365
			break;
366
		case 268: // Shadow Warrior
367
		case 279: // Shadow Master
368
			minion = 16;
369
370
			break;
371
		}
372
373
		while (me.getMinionCount(minion) < count) {
374
			rv = true;
375
376
			Skill.cast(skillId, 0);
377
			delay(200);
378
		}
379
380
		return !!rv;
381
	};
382
};