DarkHorseDre

PrecastChargedSkill.js

Sep 21st, 2020 (edited)
602
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *  @filename   PrecastChargedSkill.js
  3.  *  @author     DHD
  4.  *  @desc       handle player prebuff sequence for chargedskills only - temporary until merged into precast.js
  5.  *  @WARNING    If you are wearing hoto and wisp and/or NP and you cast oak FIRST then switch to CTA, as you switch
  6.  *  it kills the oak, EVEN if you casted the NP/Wisp version!!!
  7.  *  the answer is to precast cta first then cast oak via PrecastChargedSkill, or dont use it with hoto
  8.  */
  9.  
  10. function PrecastChargedSkill (force) {
  11.  
  12.     if (!force && me.getState(149)) {
  13.         //print("failed getstate");
  14.         return true;
  15.     }
  16.     if (me.gametype === 0 || me.inTown) {
  17.         return false;
  18.     }
  19.  
  20.     var bestChargeLevel = 0;
  21.  
  22.         for (var i = 0; i < Skill.charges.length; i++) {
  23.  
  24.             var oakItem;
  25.             if (bestChargeLevel === 0 && Skill.charges[i].skill === 226) { //initially set the first encountered oak sage skill as target
  26.                 bestChargeLevel = Skill.charges[i].level;
  27.                 oakItem = Skill.charges[i].unit;
  28.                 //print("best charge level initial: " + bestChargeLevel);
  29.                 continue;
  30.             }
  31.             if (Skill.charges[i].level > bestChargeLevel && Skill.charges[i].skill === 226) { //now compare each match on oaksage on skill level
  32.                 bestChargeLevel = Skill.charges[i].level;
  33.                 oakItem = Skill.charges[i].unit;
  34.                 //print("best charge level subsequent: " + bestchargelevel);
  35.                 continue;
  36.             }
  37.  
  38.         }
  39.  
  40.         //print(JSON.stringify(oakItem));
  41.             Skill.setSkill(226, 0, oakItem); //0 is right hand, charged skills always right
  42.             Packet.castSkill(0, me.x, me.y); //cannot be skill.cast
  43.  
  44.         return true;
  45.  
  46. };
RAW Paste Data