Difference between revisions of "GetCombatTarget"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Scruggs
(add to Combat Functions category)
imported>Shademe
m (Just fixed some grammatical errors and alignment isues)
 
(9 intermediate revisions by 7 users not shown)
Line 2: Line 2:
  [''ActorID''.]GetCombatTarget
  [''ActorID''.]GetCombatTarget


'''Example:'''
Returns the calling actor's current combat target. 
  set refVar to GetCombatTarget
 
Player.GetCombatTarget will always return 0 as the game cannot read the player's mind.<BR>
:''- 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, an {{Tooltip|AoE|Area of Effect}} spell can be cast in the vicinity of the player, with a script attached :
 
begin ScriptEffectStart
    if ( GetCombatTarget == player )
        ; Do stuff
    endif
end
 
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 to this solution is that each NPC can't have its own set of variables, but most of the time they are 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.


Returns the calling actor's current combat target.
For a pseudo-code example, [http://www.bethsoft.com/bgsforums/index.php?showtopic=885227 look] into this forum thread.
 
[[Category: Functions]]
[[Category: Functions (CS)]]
[[Category: Functions (CS 1.0)]]
[[Category: Actor Functions]]
[[Category: Actor Functions (CS 1.0)]]
[[Category: Combat Functions]]
[[Category: Combat Functions (CS 1.0)]]
[[Category: Record Variable Functions]]
[[Category: Record Variable Functions (CS 1.0)]]


Player.GetCombatTarget will always return 0 as the game has no way to determine what target the player has chosen.
<!-- Begin Search Terms
Get
Combat
Target
   
   
[[Category: Functions]]
End Search Terms -->
[[Category: Reference Variable Functions]]
[[Category:Actor Functions]]
[[Category:Combat_Functions]]

Latest revision as of 02:20, 10 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[edit | edit source]

  • To get the player's potential combat targets, an AoE spell can be cast in the vicinity of the player, with a script attached :
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 to this solution is that each NPC can't have its own set of variables, but most of the time they are 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.