Difference between revisions of "GetCombatTarget"
Jump to navigation
Jump to search
Added methods to find PC's combat targets
imported>Vswe m (Added Search Terms) |
imported>Shademe (Added methods to find PC's combat targets) |
||
Line 5: | Line 5: | ||
Player.GetCombatTarget will always return 0 as the game cannot read the player's mind. | Player.GetCombatTarget will always return 0 as the game cannot read the player's mind. | ||
== Notes == | |||
*To get the player's combat targets, you can either cast an AoE spell in the vicinity of the player, with the script attached to the spell could be: | |||
<pre>begin scriptEffectStart | |||
if ( getCombatTarget == player ) | |||
; Do stuff | |||
endIf | |||
end</pre> | |||
To use a centralized script, have the spell pass the NPC's reference to an [[Activate|activator]] [[Activation_Functions|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 [[GetFirstRef|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|Pluggy]] reference array can be used. | |||
For a pseudo-code example, [http://www.bethsoft.com/bgsforums/index.php?showtopic=885227 look] into this forum thread. | |||
[[Category: Functions]] | [[Category: Functions]] | ||
[[Category: Functions (CS)]] | [[Category: Functions (CS)]] |