Jump to content
Sign in to follow this  
Sophisticated

Looking for a method to check if I'm being attked by a NPC.

Recommended Posts

Hi guys, I'm trying to find a method to check if a NPC is attacking me, I tried differnt methods for the docs. The one that I could use is by just looking at the animation from the character. But I'd like to have something else to check if my character is already under attack (that also works even when my healthbar isn't showing.).

I looked at the combat, RSNPC and character docs, without succes. I'm hoping someone can help me out.

Share this post


Link to post
Share on other sites
1 hour ago, Sophisticated said:

Hi guys, I'm trying to find a method to check if a NPC is attacking me, I tried differnt methods for the docs. The one that I could use is by just looking at the animation from the character. But I'd like to have something else to check if my character is already under attack (that also works even when my healthbar isn't showing.).

I looked at the combat, RSNPC and character docs, without succes. I'm hoping someone can help me out.

Might be better to also say why the healthbar doesn't matter and why you can't use animation to check.

Share this post


Link to post
Share on other sites
12 hours ago, fegmo said:

You could search for npcs which have their interacting character equal to your player, then check if their animation is equal to their attacking animation

Thanks for your reaction, it look likes that only checking the npc's interacting character to my character is enough.

Share this post


Link to post
Share on other sites
12 hours ago, lets be friends said:

Might be better to also say why the healthbar doesn't matter and why you can't use animation to check.

I have to say, at this point I'm not entirely sure why I said the part about the healthbar, I'm a bit confused there. But the reason I didn't want to use the animation to check if I'm getting attacked is because there are some moments that your character is idle (while getting attacked) and ofcourse you could make a workaround to have it work. But I wanted something more responsive. Instead of having to wait (for a short moment) before knowing if I'm already under attack.

Share this post


Link to post
Share on other sites
3 minutes ago, Sophisticated said:

I have to say, at this point I'm not entirely sure why I said the part about the healthbar, I'm a bit confused there. But the reason I didn't want to use the animation to check if I'm getting attacked is because there are some moments that your character is idle (while getting attacked) and ofcourse you could make a workaround to have it work. But I wanted something more responsive. Instead of having to wait (for a short moment) before knowing if I'm already under attack.

ah ok well I see you're doing the interacting with method so do whatever is best for you but the isInCombat() method will check based on whether a healthbar is visible and also you could do a timed check for the animation so like if the attack animation doesn't pop up for 3 seconds or whatever you want then you're not in combat, if it does then break out of the loop and you'll know you're in combat. (I use the timed one for multi combat safe spotting since you don't have a health bar and the npc is interacting with multiple people.)

Share this post


Link to post
Share on other sites
Posted (edited)
3 minutes ago, lets be friends said:

ah ok well I see you're doing the interacting with method so do whatever is best for you but the isInCombat() method will check based on whether a healthbar is visible and also you could do a timed check for the animation so like if the attack animation doesn't pop up for 3 seconds or whatever you want then you're not in combat, if it does then break out of the loop and you'll know you're in combat. (I use the timed one for multi combat safe spotting since you don't have a health bar and the npc is interacting with multiple people.)

Yes that's what I meant (that's why I didn't want something to do with the healthbar), the isInCombat but I found out a few minutes ago, that my healthbar will always be visible if I'm getting hit. So maybe just maybe I can just stick with only isInCombat(). And I was thinking about the timed check as an extra by checking the animations. Thanks! (I thought when getting hit zero's, the healthbar won't show up.)

Edited by Sophisticated
  • Like 1

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×