TouchAttackRanged(object, int)

Executes and determines the results of a ranged touch attack.

int TouchAttackRanged(
    object oTarget,
    int bDisplayFeedback = TRUE
);

Parameters

oTarget

Target of the ranged touch attack.

bDisplayFeedback

Display visual feedback. (Default: TRUE)


Description

The caller will perform a ranged touch attack on oTarget.



Remarks

Generally used to script special abilities such as laying on hands on undead (requires a touch attack to work).

No combat animations are performed, and no damage is dealt. It simply does a roll to see if the target is hit, and if bDisplayFeedback is TRUE, displays feedback in the combat feedback window.


Version

1.61

Example

// Here is a Bioware scrtip as an example. This implements 
// the special ability of a Steam Mephit, which btw can be
// given to any creature by editing the Special Abilities tab.
// (nw_s1_mephsteam.nss)

//::///////////////////////////////////////////////
//:: Steam Mephit Breath
//:: NW_S1_MephSteam
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Steam Mephit shoots out a bolt of steam
    that causes 1d4 damage and reduces AC by 4
    and Attack by 2
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: May 11, 2001
//:://////////////////////////////////////////////

void main()
{
   // Declare major variables
   object oTarget = GetSpellTargetObject();
   int nHD = GetHitDice(OBJECT_SELF);
   effect eVis = EffectVisualEffect(VFX_IMP_ACID_S);
   effect eBolt, eAttack, eAC;
   effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);

   //Roll damage
   int nDamage = d4();
   //Adjust the damage based on the Reflex Save, Evasion and Improved Evasion.
   nDamage = GetReflexAdjustedDamage(nDamage, oTarget, GetSpellSaveDC(),SAVING_THROW_TYPE_FIRE);
   //Make a ranged touch attack
   int nTouch = TouchAttackRanged(oTarget);
   if(nDamage == 0) {nTouch = 0;}
   if(nTouch > 0)
   {
      if(nTouch == 2)
      {
         nDamage *= 2;
      }
      //Fire cast spell at event for the specified target
      SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELLABILITY_MEPHIT_STEAM_BREATH));

      //Set damage, AC mod and attack mod effects
      eBolt = EffectDamage(nDamage, DAMAGE_TYPE_FIRE);
      eAC = EffectACDecrease(4);
      eAttack = EffectAttackDecrease(2);
      effect eLink = EffectLinkEffects(eAC, eAttack);
      eLink = EffectLinkEffects(eLink, eDur);

      //Apply the VFX impact and effects
      ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, RoundsToSeconds(3));
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eBolt, oTarget);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
   }
}

See Also

categories: Combat Actions Functions


 author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Lilac Soul