yfoo Posted December 14, 2017 Share Posted December 14, 2017 In the process of writing a stun alching script I noticed that after calling castSpellOnEntity(HIGH_ALCH) then calling hoverSpell(STUN). The next call of castSpell(STUN) will not process until after the previous call of castSpellOnEntity(HIGH_ALCH). To better summarize: cast high alch -> hover cursor over stun -> pause until after high alch completes -> cast stun. However by replacing hoverSpell() with a call to Mouse.move() with random coordinates within the bounds of the stun spell, stun will be casted mid animation of high alch resulting in the desired outcome. My conclusion is that internally castSpell() or castSpellOnEntity() will delay the next castSpell() or castSpellOnEntity(). Can anyone else confim this? On another note, how do you check what interface tab the player is currently at (i.e: magic tab, inventory tab, quest tab, etc.) relevant code that handles stun alching: public int executeNodeAction() throws InterruptedException{ Magic m = hostScriptReference.getMagic(); PriorityNode nextNode = this.pq.peek(); hostScriptReference.log("Executing: " + nextNode.p.name()); switch(nextNode.p){ case ALCH: if(m.canCast(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)){ m.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY); MethodProvider.sleep(ConstantsAndStatics.randomNormalDist(ConstantsAndStatics.BETWEEN_ALCH_MEAN_MS, ConstantsAndStatics.BETWEEN_ALCH_STDDEV_MS)); if(m.isSpellSelected()){ hostScriptReference.getInventory().interact("Cast","Magic longbow"); } MethodProvider.sleep(ConstantsAndStatics.randomNormalDist(ConstantsAndStatics.RS_GAME_TICK_MS, 80)); swapKeysStunAlch(); if(hoverOverStun()){ //originally was m.hoverSpell(Spells.NormalSpells.STUN) //return (int) ConstantsAndStatics.randomNormalDist(50, 5); return 0; //force onLoop to not sleep to better test } } hostScriptReference.log("cannot cast alch"); return 10; case STUN: if(m.canCast(Spells.NormalSpells.STUN)){ if(npc == null){ hostScriptReference.log("no NPC creating instance"); npc = hostScriptReference.getNpcs().closest("Monk of Zamorak"); } stop = System.currentTimeMillis(); m.castSpellOnEntity(Spells.NormalSpells.STUN, npc); swapKeysStunAlch(); if(m.hoverSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY)){ //return (int) ConstantsAndStatics.randomNormalDist(50, 5); return 0; //force onLoop to not sleep to better test } } hostScriptReference.log("cannot cast stun"); return 10; case ALCH_ERROR: //for later implementations of emulating human mistakes return 0; case STUN_ERROR: return 0; } return 1000; } private boolean hoverOverStun(){ int randX = ThreadLocalRandom.current().nextInt(STUN_UPPER_LEFT_BOUND.x, STUN_LOWER_RIGHT_BOUND.x); int randY = ThreadLocalRandom.current().nextInt(STUN_UPPER_LEFT_BOUND.y, STUN_LOWER_RIGHT_BOUND.y); hostScriptReference.log("hovering stun at: (" + randX + ", " + randY + ")"); return !hostScriptReference.getMouse().move(randX, randY); } The onLoop() method: @Override public int onLoop() throws InterruptedException { return pqw.executeNodeAction(); } Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted December 14, 2017 Share Posted December 14, 2017 To check if a tab is open, use Tabs#isOpen. For example: getTabs().isOpen(Tab.MAGIC) The return values speak for themselves. About the other problem, I think your solution works fine but you'll need to open the tab first which can be done with Tabs#open. Quote Link to comment Share on other sites More sharing options...
H0rn Posted December 21, 2017 Share Posted December 21, 2017 I have the same problem, let me know if you figure out a fix. Quote Link to comment Share on other sites More sharing options...