OnPhysicalAttacked

The script attached to this event fires each time the object takes physical damage. This could be used for a reaction to the attack such as changing weapons, fleeing, surrendering, etc.


Trigger

A physical attack is brought against a creature, door, or placeable object. It doesn't need to hit or damage to trigger it.


Function(s)

GetLastAttacker() returns the object that last attacked OBJECT_SELF.
GetLastDamager() returns the object that actually dealt damage last (not neccessarily the last attacker).
GetLastWeaponUsed(oAttacker) will return the last weapon used to attack the creature, if any.
GetLastAttackMode(oAttacker) will return the last combat mode the attacking creature used, if any.
GetLastAttackType(oAttacker) will return the last special attack the attacking creature used, if any.
DetermineCombatRound(object, int) for standard combat round actions.


Remarks

If a creature is attacked and not currently in combat, it goes hostile and emits appropriate shouts to alert allies nearby. It should also be possible to use this routine to allow a member of a non hostile faction to issue a warning to a PC that attacked them, going hostile only on a second attack. At least that seems to be the purpose of the 'NW_FLAG_SET_WARNINGS' flag found in the on spawn routine. However, because the code that makes the faction and allied faction members hostile to the offending player is hard-coded into the engine itself, it is impossible to know for sure why a particular creature has become hostile. As such there seems to be no easy way to actually get this functionality working.


See Also

Objects with Events | Creature | Door | Placeable Object
functions: DetermineCombatRound | GetLastAttacker | GetLastAttackMode | GetLastAttackType | GetLastDamager | GetLastWeaponUsed


 Send comments on this topic.