Jump to content

projectile/animation based prayer switching


Recommended Posts

Posted (edited)
	public void projectilePrayerSwitch() {

    	for (Projectile p : projectiles.getAll()) {
    		
    	    if (p.getId() == 2176) {
    			log("NPC attacked with magic!");
    			prayer.set(PrayerButton.PROTECT_FROM_MAGIC, true);
    			
    	    } else if (p.getId() == 2178) {
    			log("NPC attacked with ranged!");
    			prayer.set(PrayerButton.PROTECT_FROM_MISSILES, true);
    	    		}
    		}
	}

and animations

public void animationPrayerSwitch() {

    // Iterate over all NPCs
    for (NPC npc : npcs.getAll()) {

        // Get the current animation ID of the NPC
        int animationId = npc.getAnimation();
        
        // Check if the NPC is attacking with magic
        if (animationId == 711) {
            log("NPC attacked with magic!");
            // Activate Protect from Magic
            prayer.set(PrayerButton.PROTECT_FROM_MAGIC, true);
        } 

        // Check if the NPC is attacking with ranged
        else if (animationId == 249 || animationId == 250) {
            log("NPC attacked with ranged!");
            // Activate Protect from Missiles
            prayer.set(PrayerButton.PROTECT_FROM_MISSILES, true);
        }
    }
}
Edited by xlDino
  • Like 1
  • Heart 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...