Poison, lethal and fake heal potions

This forum is for those interested in discussing NWN scripting.

Moderators: DM_eaze, Luceran, DM_Jaydaan, ST_DM_Myle, dm_xeen1, DM Nexus, DM_TrainWrek, Carpe_DM1, DM_Unicorn, DM_Griphon, DM_Shadowlands, dm_zane, DM_Centaur, DM_Mystic, DM Rendyll, DM_Avalon

Locked
User avatar
Jazelle
Duke
Duke
Posts: 731
Joined: Thu Jul 06, 2006 12:56 am
Location: Land of gators and lizards
Contact:

Poison, lethal and fake heal potions

Post by Jazelle »

Driller here are the three scripts we use for fake heal, poison and lethal potions. They work very well. Just need to make the three potion items.

leathalhealpotion

Code: Select all


//::///////////////////////////////////////////////
//:: [Harm]
//:: [NW_S0_Harm.nss]
//:: Copyright (c) 2000 Bioware Corp.
//:://////////////////////////////////////////////
//:: Reduces target to 1d4 HP on successful touch
//:: attack.  If the target is undead it is healed.
//:://////////////////////////////////////////////
//:: Created By: Keith Soleski
//:: Created On: Jan 18, 2001
//:://////////////////////////////////////////////
//:: VFX Pass By: Preston W, On: June 20, 2001
//:: Update Pass By: Preston W, On: Aug 1, 2001
//:: Last Update: Georg Zoeller On: Oct 10, 2004
//:://////////////////////////////////////////////

#include "NW_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{

//Make sure this script only executes when the item is used.
if ( GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE ) return;

/*
  Spellcast Hook Code
  Added 2003-06-23 by GeorgZ
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook


    //Declare major variables
    object oTarget = GetItemActivator();
    int nDamage, nHeal;
    int nMetaMagic = GetMetaMagicFeat();
    effect eVis = EffectVisualEffect(246);
    effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
    effect eHeal, eDam;
    //Check that the target is undead
    if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
    {
        //Figure out the amount of damage to heal
        nHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget);
        //Set the heal effect
        eHeal = EffectHeal(nHeal);
        //Apply heal effect and VFX impact
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM, FALSE));
    }
    else
    {
        nDamage = GetCurrentHitPoints(oTarget) + 5;
        //Check for metamagic
        if (nMetaMagic == METAMAGIC_MAXIMIZE)
        {
            nDamage = GetCurrentHitPoints(oTarget) + 5;
        }
        eDam = EffectDamage(nDamage,DAMAGE_TYPE_NEGATIVE);
        //Apply the VFX impact and effects
        DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    }
}
heal_potion_trap

Code: Select all

//::///////////////////////////////////////////////
//:: [Harm]
//:: [NW_S0_Harm.nss]
//:: Copyright (c) 2000 Bioware Corp.
//:://////////////////////////////////////////////
//:: Reduces target to 1d4 HP on successful touch
//:: attack.  If the target is undead it is healed.
//:://////////////////////////////////////////////
//:: Created By: Keith Soleski
//:: Created On: Jan 18, 2001
//:://////////////////////////////////////////////
//:: VFX Pass By: Preston W, On: June 20, 2001
//:: Update Pass By: Preston W, On: Aug 1, 2001
//:: Last Update: Georg Zoeller On: Oct 10, 2004
//:://////////////////////////////////////////////

#include "NW_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-23 by GeorgZ
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook


    //Declare major variables
    object oTarget = GetItemActivator();
    int nDamage, nHeal;
    int nMetaMagic = GetMetaMagicFeat();
    int nTouch = TouchAttackMelee(oTarget);
    effect eVis = EffectVisualEffect(246);
    effect eVis2 = EffectVisualEffect(VFX_IMP_HEALING_G);
    effect eHeal, eDam;
    //Check that the target is undead
    if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
    {
        //Figure out the amount of damage to heal
        nHeal = GetMaxHitPoints(oTarget) - GetCurrentHitPoints(oTarget);
        //Set the heal effect
        eHeal = EffectHeal(nHeal);
        //Apply heal effect and VFX impact
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HARM, FALSE));
    }
    else
    {
        nDamage = GetCurrentHitPoints(oTarget) - d4(1);
        //Check for metamagic
        if (nMetaMagic == METAMAGIC_MAXIMIZE)
        {
            nDamage = GetCurrentHitPoints(oTarget) - 1;
        }
        eDam = EffectDamage(nDamage,DAMAGE_TYPE_NEGATIVE);
        //Apply the VFX impact and effects
        DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    }
}

decoyhealpotion

Code: Select all

//::///////////////////////////////////////////////
//:: Heal
//:: [NW_S0_Heal.nss]
//:: Copyright (c) 2000 Bioware Corp.
//:://////////////////////////////////////////////
//:: Heals the target to full unless they are undead.
//:: If undead they reduced to 1d4 HP.
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 12, 2001
//:://////////////////////////////////////////////
//:: Update Pass By: Preston W, On: Aug 1, 2001

#include "NW_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{

//Make sure this script only executes when the item is used.
if ( GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE ) return;

/*
  Spellcast Hook Code
  Added 2003-06-23 by GeorgZ
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook


  //Declare major variables
  object oTarget = GetItemActivator();
  effect eKill, eHeal;
  int nDamage, nHeal, nModify, nMetaMagic, nTouch;
  effect eSun = EffectVisualEffect(VFX_IMP_SUNSTRIKE);
  effect eHealVis = EffectVisualEffect(VFX_IMP_HEALING_X);
    //Check to see if the target is an undead
    if (GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD)
    {
      //Fire cast spell at event for the specified target
      //SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEAL));

      //Roll damage
      nModify = d4();
      nMetaMagic = GetMetaMagicFeat();
      //Make metamagic check
      if (nMetaMagic == METAMAGIC_MAXIMIZE)
      {
        nModify = 1;
      }
      //Figure out the amount of damage to inflict
      nDamage =  GetCurrentHitPoints(oTarget) - nModify;
      //Set damage
      eKill = EffectDamage(nDamage, DAMAGE_TYPE_POSITIVE);
      //Apply damage effect and VFX impact
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eKill, oTarget);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, eSun, oTarget);
    }
    else
    {
        //Fire cast spell at event for the specified target
        //SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_HEAL, FALSE));
        //Figure out how much to heal
        nHeal = GetMaxHitPoints(oTarget);
        //Set the heal effect
        eHeal = EffectHeal(nHeal);
        //Apply the heal effect and the VFX impact
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHealVis, oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
    }
}
Pass them around then sit back and watch the fun....
The world is a strange place.
User avatar
Valnir
Count
Count
Posts: 146
Joined: Thu Feb 22, 2007 2:14 pm
Location: The Netherlands / Fortress Europe

Post by Valnir »

Yeah, now this looks interesting.
Valnir Raven

Image
User avatar
Jazelle
Duke
Duke
Posts: 731
Joined: Thu Jul 06, 2006 12:56 am
Location: Land of gators and lizards
Contact:

Post by Jazelle »

They work great. We have had no problems with any of them at all.
The world is a strange place.
Locked