Jump to content

projectile/animation based prayer switching


xlDino

Recommended Posts

	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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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