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