Jump to content

Player.GetAttacked sticks on 1


Athelbras

Recommended Posts

it's an event handler, it requires the beta NVSE. It's a standalone object script, it is not linked to anything:

scn aaaOnHitEH

ref rTarget
ref rAttacker

ref MyRef

Begin Function {rTarget, rAttacker}

    PrintC "I'm HIT!"

end

and the event itself can be declared on a quest script, i.e. on get game loaded / restarted, something like this:

    If GetGameLoaded
        SetEventHandler "OnHit" aaaOnHitEH "first"::playerref
   endif
Link to comment
Share on other sites

  • 2 weeks later...
Using player.IsInCombat plus checking player health every frame works. I've used it on both my FO3 and NV companion mods.

The condition InsInCombat will return true if enemies are nearby but still searching, so that starts the health monitoring. If health drops - well you've taken hits! Or jumpped off a cliff :) So it isn't perfect...


The simplest way to get actor REFs in a cell is with NVSE, but:


To run functions on actors in a cell without NVSE:

Run a 'Radar' quest script - at 1 or 2 second speed and have it apply a script effect touch spell to the player that detects actors in a certain radius - like 3000 units. Then the scripteffectstart block runs on the actor. From that script you can get their combat state and refId:


set MyQuestScript.rEnemy1REF to GetSelf

set rTargetREF to GetCombatTarget

if rTargetREF == PlayerREF

;Do things, set flags, GetLOS, etc, check player health


Unfortunately, GetSelf only returns non zero if the actor was placed in the world by the Geck. If you absolutely need the REFId regardless of the actor's origin, you can place an activator in a remote cell and have the scripteffectstart block also make the actor activate it. An activation block will run even if the cell that the activator is in, is not loaded. Then you can get the REFid of the actor using GetActionREF.
Link to comment
Share on other sites

You could possibly use the method that Rex was supposed to use for detecting npc's as well, by using a large radius explosion that does no damage. I'm not entirely sure how much resources that takes up though, but it's been implemented by at least one other person.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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