GetAttackTarget(object)

From NWN Lexicon
Jump to: navigation, search

Determines the current foe under attack by the specified creature.

object GetAttackTarget(
    object oCreature = OBJECT_SELF
);

Parameters

oCreature
Creature currently involved in combat. (Default: OBJECT_SELF)


Description

Get the attack target of oCreature.

It gets cleared when the attack action is removed or you lose your target (if they die or go invisible) or the round ends.


Remarks

This is useful in OnCombatRoundEnd since it is retained, unlike GetAttemptedAttackTarget, so you can determine who you were attacking in the previous round.

In other uses it can be good to see what a creature is intentionally targeting for the purposes of, for instance, knowing if you can parry them or sneak attack them.

It is not set when a creature is casting a spell at something, only when ActionAttack or similar actions are used. To know if they're casting a spell use GetCurrentAction. Since casting a spell can be on the ground you won't be able to tell what they're directly casting against.


Version

1.26

See Also

functions: 

GetIsInCombat GetAttemptedAttackTarget GetAttemptedSpellTarget GetCurrentAction

events: 

OnPhysicalAttacked Event OnCombatRoundEnd



 author: Jody Fletcher, editor: Charles Feduke, additional contributor(s): Jon McCarty, Noel Borstad