Difference between revisions of "GetCombatTarget"
Jump to navigation
Jump to search
imported>Antares m (Very Minor edit, changed a few words around clarifying what a solution achieved in regards to the player's combat targets.) |
imported>Qazaaq m (adding tooltip to AoE) |
||
Line 7: | Line 7: | ||
''- A loose workaround for this can be done by checking the combat targets of any NPC's within a given proximity of the Player, see below.'' | ''- A loose workaround for this can be done by checking the combat targets of any NPC's within a given proximity of the Player, see below.'' | ||
==Retrieving the Player's Potential Combat Targets== | ==Retrieving the Player's Potential Combat Targets== | ||
*To get the player's potential combat targets, you can either cast an AoE spell in the vicinity of the player, with the script attached to the spell could be: | *To get the player's potential combat targets, you can either cast an {{Tooltip|AoE|Area of Effect}} spell in the vicinity of the player, with the script attached to the spell could be: | ||
<pre>begin scriptEffectStart | <pre>begin scriptEffectStart |
Revision as of 15:31, 9 October 2008
Syntax:
[ActorID.]GetCombatTarget
Returns the calling actor's current combat target.
Player.GetCombatTarget will always return 0 as the game cannot read the player's mind.
- A loose workaround for this can be done by checking the combat targets of any NPC's within a given proximity of the Player, see below.
Retrieving the Player's Potential Combat Targets
- To get the player's potential combat targets, you can either cast an AoE spell in the vicinity of the player, with the script attached to the spell could be:
begin scriptEffectStart if ( getCombatTarget == player ) ; Do stuff endIf end
To use a centralized script, have the spell pass the NPC's reference to an activator function
begin ScriptEffectStart if (GetCombatTarget == player) set ActRef.rNPC to GetSelf ActRef.Activate player, 1 endif end
The downside - each NPC can't have its own set of variables, but most of the time their not necessary.
- In turn, OBSE's Reference Walking Functions to get the references within a certain proximity to the player, check for their combat targets and do the appropriate code. Make sure this script in second intervals or greater. To track the combat targets, a Pluggy reference array can be used.
For a pseudo-code example, look into this forum thread.