Jump to content

How can I find out when my player has been shot at or when an NPC has


n0ob

Recommended Posts

I want to run a script so that whenever this one particular NPC in my mod shoots at me the script runs or when I get hit by the NPC the script runs.

 

I tried attaching armor to explosion of the projectile and also running enchantment script but they are both unpreditable and work only on some computers for some reason, I am looking for some other way. :wallbash:

Link to comment
Share on other sites

You do ask tricky questions don't you? Did the spawn gun not work out for you?

 

You could place a script on the player and use an OnHit <ActorRef> block to determine if the player has been hit by a specific actor, but this will definitely lead to mod conflicts with other mods if released for download. Its not a good idea to add scripts to the player.

 

There may be a better way, but the best I can think of right now would not be cut and dry. That way would be like this;

Using a combination of GetCombatTarget and IsAnimPlaying on the NPC in conjunction with checking if the player has taken damage could produce the result you want, But it could also lead to false positives if another actor is attacking the player at the same time. The way you check if the player has taken damage is by getting his health every frame and comparing to his health from the last frame. If Current Health - Old Health is negative, then the player has taken damage. Another drawback to this is that there are many many possible attack animations to check for.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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