Guest User

Untitled

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