Untitled
unknown
java
2 years ago
4.0 kB
3
Indexable
public void cyclePathing() { // Check if the shield attack is valid (otherwise messes up the pathing) if(c.getCombatSystem().getSpecialAttacks().currentShieldAttack != null && !c.getCombatSystem().getSpecialAttacks().isWearingRightShieldForShieldAttack()) { c.getCombatSystem().getSpecialAttacks().currentShieldAttack = null; } // Check if you're attacking an player using melee or range if(c.isAttackingPlayer()) { if(c.getCombatSystem().getMisc().getCurrentAttackStyle() != AttackStyle.MELEE) { if(c.getCombatSystem().getAttackPlayer().isCloseEnoughToContinueAttackWithMagicOrRange(c.getAttackingEntity().getPlayer().getClient())) { getClientWalkingSteps().clear(); c.stopAllMovementInTick(); } } } // Check if you're attacking an npc using melee or range if(c.isAttackingNpc()) { if(c.getAttackingEntity().getSize() > 1 || c.getCombatSystem().getMisc().getCurrentAttackStyle() != AttackStyle.MELEE) { if(c.getAttackingEntity().getSize() > 1 || c.getCombatSystem().getAttackNpc().isCloseEnoughToContinueAttackWithMagicOrRange(c.getAttackingEntity().getNpc())) { getClientWalkingSteps().clear(); if(c.getCombatSystem().getMisc().getCurrentAttackStyle() != AttackStyle.MELEE) { c.stopAllMovementInTick(); } } } } // Check if player has any client sided pathing set if(getClientWalkingSteps().size() > 0) { // Set the last movement tick c.lastMovementTick = Server.getTick(); // Reset the current walking queue resetMovement(); // Check if you're following if(c.getWalkingToPlayer().isWalking() && c.getWalkingToPlayer().getWalkType() == WalkType.FOLLOW_WALK) { getClientWalkingSteps().clear(); return; } // Check if pathing is bugged boolean isForwardAndBackwardBugHappening = c.getMovement().isPathBackAndForwardBugged(c.getLocation(), c.getMovement().getClientWalkingSteps()); // Start looping the new client sided steps int endX = c.getX(), endY = c.getY(); // Start logging paths for Staff if(c.isModOrHigher() || c.isServerSupportOrHigher()) { for(Location nextPoint : getClientWalkingSteps()) { addToPath(nextPoint, false); endX = nextPoint.getX(); endY = nextPoint.getY(); } } else { for(Location nextPoint : getClientWalkingSteps()) { addToPath(nextPoint, false); endX = nextPoint.getX(); endY = nextPoint.getY(); } } // Clear the Pathing again getClientWalkingSteps().clear(); // Check on forward and backward pathing if(isForwardAndBackwardBugHappening) { totalFailedClientPaths++; } else { totalSuccesfulClientPaths++; } if(totalFailedClientPaths > 100000000|| totalSuccesfulClientPaths > 100000000) { totalSuccesfulClientPaths = 0; totalFailedClientPaths = 0; } if(isPathValid(getWayPoints()) && !isForwardAndBackwardBugHappening) { finish(); } else { // Reset Movement resetMovement(); // Grab the x and y to go to int xToGoTo = endX, yToGoTo = endY; // Find out the x and y to go to (walking to npc, not attacking) if(c.getWalkingToNpc().isWalking() && c.getWalkingToNpc().getWalkType() != WalkType.ATTACK_WALK) { NPC npc = NPCHandler.getNpcFromId(c.getWalkingToNpc().getNpcId()); if(npc != null) { xToGoTo = npc.getX(); yToGoTo = npc.getY(); } } else if(c.getWalkingToPlayer().isWalking() && c.getWalkingToNpc().getWalkType() != WalkType.FOLLOW_WALK && c.getWalkingToNpc().getWalkType() != WalkType.ATTACK_WALK) { Client o = PlayerHandler.getClientFromId(c.getWalkingToPlayer().getPlayerId()); if(o != null) { xToGoTo = o.getX(); yToGoTo = o.getY(); } } // Find the right route (different path) if(xToGoTo != endX || yToGoTo != endY) { PathFinder.findRouteNextTo(c, xToGoTo, yToGoTo, false, 16, 16); } else { PathFinder.findRoute(c, xToGoTo, yToGoTo, false, 16, 16); } } }
Editor is loading...