Author Topic: Spell Scripts!  (Read 9233 times)

Ser Red Ronnet Connington

  • Guest
Spell Scripts!
« on: September 21, 2007, 08:19:18 AM »
Sorry for this 420. I tried to send a message to you earlier but for some reason LM had a database error. So to be safe il resend what I asked. Basically I am having trouble with 3 scripts. All 3 are spell scripts. All 3 have the same problem. Fod/Implosion?destruction; what I have done to them is I have removed the death effect that occurs when the opponent rolls a 1. I have replaced that with a damage effect of 100 damage, divine in implosions case, magical in fods case and i did not get to destruction. The problem is it is not working consistently. Infact it only worked once. That being Implosion / Fod, destruction i have not yet done. But what happened was the death effect was removed and it applied my 100 damage effect, but normally, and I have tested it about 20 times, all it does is it claims that when they roll a 1 its a success and no damage is done. Now I dont know why. It could be because of the Saves but I am not sure. I have tinkered with them a lot though so il post em to u. Basically what I want is for Fod/Imp/Destruc to do 100 damage when they roll a 1 instead of doing death. Autofail is on 1=1.

Quote
//::///////////////////////////////////////////////
//:: Implosion
//:: NW_S0_Implosion.nss
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    All persons within a 5ft radius of the spell must
    save at +3 DC or die.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: April 13, 2001
//:://////////////////////////////////////////////

#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"

void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  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;
    int nDam = 100;
    effect eDam = EffectDamage(nDam, DAMAGE_TYPE_DIVINE);
    effect eImplode= EffectVisualEffect(VFX_FNF_IMPLOSION);
    float fDelay;

    //Apply the implose effect
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImplode, GetSpellTargetLocation());
    //Get the first target in the shape
    oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, GetSpellTargetLocation());
    while (GetIsObjectValid(oTarget))
    {
        if (spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, OBJECT_SELF))
        {
           //Fire cast spell at event for the specified target
            SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_IMPLOSION));
           fDelay = GetRandomDelay(0.4, 1.2);
           //Make SR check
           if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
           {
                //Make Reflex save
                if(!MySavingThrow(SAVING_THROW_FORT, oTarget, GetSpellSaveDC()+3, SAVING_THROW_TYPE_NONE, OBJECT_SELF, fDelay))
                {
                    //Apply damage effect and the VFX impact

                    DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));

                }
           }
        }
       //Get next target in the shape
       oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, GetSpellTargetLocation());
    }
}
thats implosion

Quote
//::///////////////////////////////////////////////
//:: Finger of Death
//:: NW_S0_FingDeath
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
// You can slay any one living creature within range.
// The victim is entitled to a Fortitude saving throw to
// survive the attack. If he succeeds, he instead
// sustains 3d6 points of damage +1 point per caster
// level.
*/
//:://////////////////////////////////////////////
//:: Created By: Noel Borstad
//:: Created On: Oct 17, 2000
//:://////////////////////////////////////////////
//:: Updated By: Georg Z, On: Aug 21, 2003 - no longer affects placeables

#include "x0_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 = GetSpellTargetObject();
    int nCasterLvl = GetCasterLevel(OBJECT_SELF);
    int nMetaMagic = GetMetaMagicFeat();
    int nDamage;
    int nDamage2 = 100;
    effect eDam;
    effect eDam2 = EffectDamage(nDamage2, DAMAGE_TYPE_MAGICAL);
    effect eVis = EffectVisualEffect(VFX_IMP_DEATH_L);
    effect eVis2 = EffectVisualEffect(VFX_IMP_NEGATIVE_ENERGY);

    if(nCasterLvl > 25)
    {
     nCasterLvl = 25;
    }

    if(spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, OBJECT_SELF))
    {
        //GZ: I still signal this event for scripting purposes, even if a placeable
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_FINGER_OF_DEATH));
         if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
        {

            //Make SR check
            if (!MyResistSpell(OBJECT_SELF, oTarget))
               {
                 //Make Forttude save
                 if (!MySavingThrow(SAVING_THROW_FORT, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_NONE))
                 {
                    //Apply the death effect and VFX impact
                    ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam2, oTarget);
                    //ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
                 }
                 else
                 {
                    //Roll damage
                    nDamage = d6(3) + nCasterLvl;
                    //Make metamagic checks
                    if (nMetaMagic == METAMAGIC_MAXIMIZE)
                    {
                        nDamage = 18 + nCasterLvl;
                    }
                    if (nMetaMagic == METAMAGIC_EMPOWER)
                    {
                        nDamage = nDamage + (nDamage/2);
                    }
                    //Set damage effect
                    eDam = EffectDamage(nDamage, DAMAGE_TYPE_NEGATIVE);
                    //Apply damage effect and VFX impact
                    ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
                    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis2, oTarget);
                }
            }
        }
    }
}
thats fod

Quote
//::///////////////////////////////////////////////
//:: Destruction
//:: NW_S0_Destruc
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    The target creature is destroyed if it fails a
    Fort save, otherwise it takes 10d6 damage.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Aug 13, 2001
//:://////////////////////////////////////////////

#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 = GetSpellTargetObject();
    int nMetaMagic = GetMetaMagicFeat();
    int nDamage = 100, nDamage2;
    effect eDam, eDam2;
    effect eVis = EffectVisualEffect(234);
    if(!GetIsReactionTypeFriendly(oTarget))
    {
        //Fire cast spell at event for the specified target
        SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_DESTRUCTION));
        //Make SR check
        if(!MyResistSpell(OBJECT_SELF, oTarget))
        {
            //Make a saving throw check
            if(!/*Fort Save*/ MySavingThrow(SAVING_THROW_FORT, oTarget, GetSpellSaveDC()))
            {
                //Apply the VFX impact and effects
                eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
            }
            else
            {
                nDamage2 = d6(10);
                //Enter Metamagic conditions
                if (nMetaMagic == METAMAGIC_MAXIMIZE)
                {
                    nDamage2 = 60;//Damage is at max
                }
                else if (nMetaMagic == METAMAGIC_EMPOWER)
                {
                    nDamage2 = nDamage2 + (nDamage2/2); //Damage/Healing is +50%
                }
                //Set damage effect
                eDam2 = EffectDamage(nDamage2, DAMAGE_TYPE_DIVINE);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam2, oTarget);
            }
            //Apply VFX impact
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
        }
    }
}
destruction.

Any help with these would be great!

If anyone else can help please give it a shot!

Offline 420

  • Hero Member
  • *****
  • Posts: 4087
    • View Profile
    • Email
Spell Scripts!
« Reply #1 on: September 23, 2007, 09:25:29 PM »
Quote
I tried to send a message to you earlier but for some reason LM had a database error.
[snapback]37589[/snapback]
Mo said he was going to fix that...

Anyway, I've been out of town for 4 days and just got back an hour ago so I'll look your scripts over after I get some dinner.

-420
« Last Edit: September 23, 2007, 09:25:43 PM by 420 »

Ser Red Ronnet Connington

  • Guest
Spell Scripts!
« Reply #2 on: September 24, 2007, 10:56:17 AM »
Quote
Mo said he was going to fix that...

Anyway, I've been out of town for 4 days and just got back an hour ago so I'll look your scripts over after I get some dinner.

-420
[snapback]37619[/snapback]

Thanks, 420, the scripts in the end were fine, it was the overiding nw_i0_spells script that was messing up the saving throws! But I am trying now to script a delay into a certain spell, namely divine power. The delay will be X amount of rounds before it can be casted again by an individual. Would one do something like that in the spell script or in the spell hook, or even somewhere else! Any advice with that would be appreciated. What function I would use I dont know.

Offline 420

  • Hero Member
  • *****
  • Posts: 4087
    • View Profile
    • Email
Spell Scripts!
« Reply #3 on: September 24, 2007, 02:42:19 PM »
Quote
But I am trying now to script a delay into a certain spell, namely divine power. The delay will be X amount of rounds before it can be casted again by an individual. Would one do something like that in the spell script or in the spell hook, or even somewhere else! Any advice with that would be appreciated. What function I would use I dont know.
[snapback]37628[/snapback]
Use the spellhook for this since you want to "intercept" the spell. I do this with Time Stop on Smith Hold so that each PC can only cast it once every 24 game hours (48 minutes real time).

Let's say you want to only allow a PC to cast Divine Power once every 10 rounds (60 seconds real time). The following code should be incorporated into the spellhook script:
Quote
#include "x2_inc_switches"

void main()
{
int nSpell=GetSpellId();

if(nSpell == SPELL_DIVINE_POWER)
    {
    if(GetLocalInt(OBJECT_SELF, "DPTime") == 1)
        {
        FloatingTextStringOnCreature("Divine Power can only be cast once every 10 rounds.", OBJECT_SELF, FALSE);
        SetModuleOverrideSpellScriptFinished();
        }
    else
        {
        SetLocalInt(OBJECT_SELF, "DPTime", 1);
        DelayCommand(60.0, ExecuteScript("dptimeup", OBJECT_SELF));
        }
    }
}

Now make a scripted named "dptimeup" that removes temporary ban:
Quote
void main()
{
DeleteLocalInt(OBJECT_SELF, "DPTime");
}

-420
« Last Edit: September 24, 2007, 02:43:12 PM by 420 »

Ser Red Ronnet Connington

  • Guest
Spell Scripts!
« Reply #4 on: September 24, 2007, 06:11:06 PM »
Quote
Use the spellhook for this since you want to "intercept" the spell. I do this with Time Stop on Smith Hold so that each PC can only cast it once every 24 game hours (48 minutes real time).

Let's say you want to only allow a PC to cast Divine Power once every 10 rounds (60 seconds real time). The following code should be incorporated into the spellhook script:
Now make a scripted named "dptimeup" that removes temporary ban:
-420
[snapback]37647[/snapback]

Thx mate for the help. Unfortunetly its not worked so far. Do i have to set a variable in the mod to activate the spell hook? also do I compile the spell hook with the script in the main body of the rest of the spell hook. or after it?

Offline 420

  • Hero Member
  • *****
  • Posts: 4087
    • View Profile
    • Email
Spell Scripts!
« Reply #5 on: September 24, 2007, 06:17:17 PM »
Quote
Thx mate for the help. Unfortunetly its not worked so far. Do i have to set a variable in the mod to activate the spell hook? also do I compile the spell hook with the script in the main body of the rest of the spell hook. or after it?
[snapback]37653[/snapback]
Set a global string called X2_S_UD_SPELLSCRIPT with the value of the name of the spellhook script.

Name Type Value

X2_S_UD_SPELLSCRIPT string myspellhook

If you already have a spellhook script it should already have:
#include "x2_inc_switches"

Just add the code inside the void main area to the existing script.

-420

Ser Red Ronnet Connington

  • Guest
Spell Scripts!
« Reply #6 on: September 24, 2007, 06:29:09 PM »
Quote
Set a global string called X2_S_UD_SPELLSCRIPT with the value of the name of the spellhook script.

Name Type Value

X2_S_UD_SPELLSCRIPT string myspellhook

If you already have a spellhook script it should already have:
#include "x2_inc_switches"

Just add the code inside the void main area to the existing script.

-420
[snapback]37654[/snapback]

Hmm this is what I have done mate. I have compiled the spellhook with its standard name, and thus used it as the Value of the Global string(variable).

Therefore it looks like this X2_S_UD_SPELLSCRIPT string x2_inc_spellhook

It is still not working for some reason.

This is what I have done to the spellhook itself, this is where I added the script as their is no current void main section itself.

Quote
//::///////////////////////////////////////////////
//:: Spell Hook Include File
//:: x2_inc_spellhook
//:: Copyright © 2003 Bioware Corp.
//:://////////////////////////////////////////////
/*

    This file acts as a hub for all code that
    is hooked into the nwn spellscripts'

    If you want to implement material components
    into spells or add restrictions to certain
    spells, this is the place to do it.

*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: 2003-06-04
//:: Updated On: 2003-10-25
//:://////////////////////////////////////////////

//#include "x2_inc_itemprop" - Inherited from x2_inc_craft
#include "x2_inc_craft"
#include "x2_inc_switches"

const int X2_EVENT_CONCENTRATION_BROKEN = 12400;


// Use Magic Device Check.
// Returns TRUE if the Spell is allowed to be cast, either because the
// character is allowed to cast it or he has won the required UMD check
// Only active on spell scroll
int X2UseMagicDeviceCheck();


// This function holds all functions that are supposed to run before the actual
// spellscript gets run. If this functions returns FALSE, the spell is aborted
// and the spellscript will not run
int X2PreSpellCastCode();


// check if the spell is prohibited from being cast on items
// returns FALSE if the spell was cast on an item but is prevented
// from being cast there by its corresponding entry in des_crft_spells
// oItem - pass GetSpellTargetObject in here
int X2CastOnItemWasAllowed(object oItem);

// Sequencer Item Property Handling
// Returns TRUE (and charges the sequencer item) if the spell
// ... was cast on an item AND
// ... the item has the sequencer property
// ... the spell was non hostile
// ... the spell was not cast from an item
// in any other case, FALSE is returned an the normal spellscript will be run
// oItem - pass GetSpellTargetObject in here
int X2GetSpellCastOnSequencerItem(object oItem);

int X2RunUserDefinedSpellScript();



int X2UseMagicDeviceCheck()
{
    int nRet = ExecuteScriptAndReturnInt("x2_pc_umdcheck",OBJECT_SELF);
    return nRet;
}

//------------------------------------------------------------------------------
// GZ: This is a filter I added to prevent spells from firing their original spell
// script when they were cast on items and do not have special coding for that
// case. If you add spells that can be cast on items you need to put them into
// des_crft_spells.2da
//------------------------------------------------------------------------------
int X2CastOnItemWasAllowed(object oItem)
{
    int bAllow = (Get2DAString(X2_CI_CRAFTING_SP_2DA,"CastOnItems",GetSpellId()) == "1");
    if (!bAllow)
    {
        FloatingTextStrRefOnCreature(83453, OBJECT_SELF); // not cast spell on item
    }
    return bAllow;

}


//------------------------------------------------------------------------------
// Execute a user overridden spell script.
//------------------------------------------------------------------------------
int X2RunUserDefinedSpellScript()
{
    // See x2_inc_switches for details on this code
    string sScript =  GetModuleOverrideSpellscript();
    if (sScript != "")
    {
        ExecuteScript(sScript,OBJECT_SELF);
        if (GetModuleOverrideSpellScriptFinished() == TRUE)
        {
            return FALSE;
        }
    }
    return TRUE;
}


void main()
{
int nSpell=GetSpellId();

if(nSpell == SPELL_DIVINE_POWER)
    {
    if(GetLocalInt(OBJECT_SELF, "DPTime") == 1)
        {
        FloatingTextStringOnCreature("Divine Power can only be cast once every 10 rounds.", OBJECT_SELF, FALSE);
        SetModuleOverrideSpellScriptFinished();
        }
    else
        {
        SetLocalInt(OBJECT_SELF, "DPTime", 1);
        DelayCommand(60.0, ExecuteScript("dptimeup", OBJECT_SELF));
        }
    }
}



//------------------------------------------------------------------------------
// Created Brent Knowles, Georg Zoeller 2003-07-31
// Returns TRUE (and charges the sequencer item) if the spell
// ... was cast on an item AND
// ... the item has the sequencer property
// ... the spell was non hostile
// ... the spell was not cast from an item
// in any other case, FALSE is returned an the normal spellscript will be run
//------------------------------------------------------------------------------
int X2GetSpellCastOnSequencerItem(object oItem)
{

    if (!GetIsObjectValid(oItem))
    {
        return FALSE;
    }

    int nMaxSeqSpells = IPGetItemSequencerProperty(oItem); // get number of maximum spells that can be stored
    if (nMaxSeqSpells <1)
    {
        return FALSE;
    }

    if (GetIsObjectValid(GetSpellCastItem())) // spell cast from item?
    {
        // we allow scrolls
        int nBt = GetBaseItemType(GetSpellCastItem());
        if ( nBt !=BASE_ITEM_SPELLSCROLL && nBt != 105)
        {
            FloatingTextStrRefOnCreature(83373, OBJECT_SELF);
            return TRUE; // wasted!
        }
    }

    // Check if the spell is marked as hostile in spells.2da
    int nHostile = StringToInt(Get2DAString("spells","HostileSetting",GetSpellId()));
    if(nHostile ==1)
    {
        FloatingTextStrRefOnCreature(83885,OBJECT_SELF);
        return TRUE; // no hostile spells on sequencers, sorry ya munchkins :)
    }

    int nNumberOfTriggers = GetLocalInt(oItem, "X2_L_NUMTRIGGERS");
    // is there still space left on the sequencer?
    if (nNumberOfTriggers < nMaxSeqSpells)
    {
        // success visual and store spell-id on item.
        effect eVisual = EffectVisualEffect(VFX_IMP_BREACH);
        nNumberOfTriggers++;
        //NOTE: I add +1 to the SpellId to spell 0 can be used to trap failure
        int nSID = GetSpellId()+1;
        SetLocalInt(oItem, "X2_L_SPELLTRIGGER" + IntToString(nNumberOfTriggers), nSID);
        SetLocalInt(oItem, "X2_L_NUMTRIGGERS", nNumberOfTriggers);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, OBJECT_SELF);
        FloatingTextStrRefOnCreature(83884, OBJECT_SELF);
    }
    else
    {
        FloatingTextStrRefOnCreature(83859,OBJECT_SELF);
    }

    return TRUE; // in any case, spell is used up from here, so do not fire regular spellscript
}

//------------------------------------------------------------------------------
// * This is our little concentration system for black blade of disaster
// * if the mage tries to cast any kind of spell, the blade is signaled an event to die
//------------------------------------------------------------------------------
void X2BreakConcentrationSpells()
{
    // * At the moment we got only one concentration spell, black blade of disaster

    object oAssoc = GetAssociate(ASSOCIATE_TYPE_SUMMONED);
    if (GetIsObjectValid(oAssoc) && GetIsPC(OBJECT_SELF)) // only applies to PCS
    {
        if(GetTag(oAssoc) == "x2_s_bblade") // black blade of disaster
        {
            if (GetLocalInt(OBJECT_SELF,"X2_L_CREATURE_NEEDS_CONCENTRATION"))
            {
                SignalEvent(oAssoc,EventUserDefined(X2_EVENT_CONCENTRATION_BROKEN));
            }
        }
    }
}

//------------------------------------------------------------------------------
// being hit by any kind of negative effect affecting the caster's ability to concentrate
// will cause a break condition for concentration spells
//------------------------------------------------------------------------------
int X2GetBreakConcentrationCondition(object oPlayer)
{
     effect e1 = GetFirstEffect(oPlayer);
     int nType;
     int bRet = FALSE;
     while (GetIsEffectValid(e1) && !bRet)
     {
        nType = GetEffectType(e1);

        if (nType == EFFECT_TYPE_STUNNED || nType == EFFECT_TYPE_PARALYZE ||
            nType == EFFECT_TYPE_SLEEP || nType == EFFECT_TYPE_FRIGHTENED ||
            nType == EFFECT_TYPE_PETRIFY || nType == EFFECT_TYPE_CONFUSED ||
            nType == EFFECT_TYPE_DOMINATED || nType == EFFECT_TYPE_POLYMORPH)
         {
           bRet = TRUE;
         }
                    e1 = GetNextEffect(oPlayer);
     }
    return bRet;
}

void X2DoBreakConcentrationCheck()
{
    object oMaster = GetMaster();
    if (GetLocalInt(OBJECT_SELF,"X2_L_CREATURE_NEEDS_CONCENTRATION"))
    {
         if (GetIsObjectValid(oMaster))
         {
            int nAction = GetCurrentAction(oMaster);
            // master doing anything that requires attention and breaks concentration
            if (nAction == ACTION_DISABLETRAP || nAction == ACTION_TAUNT ||
                nAction == ACTION_PICKPOCKET || nAction ==ACTION_ATTACKOBJECT ||
                nAction == ACTION_COUNTERSPELL || nAction == ACTION_FLAGTRAP ||
                nAction == ACTION_CASTSPELL || nAction == ACTION_ITEMCASTSPELL)
            {
                SignalEvent(OBJECT_SELF,EventUserDefined(X2_EVENT_CONCENTRATION_BROKEN));
            }
            else if (X2GetBreakConcentrationCondition(oMaster))
            {
                SignalEvent(OBJECT_SELF,EventUserDefined(X2_EVENT_CONCENTRATION_BROKEN));
            }
         }
    }
}

//------------------------------------------------------------------------------
// if FALSE is returned by this function, the spell will not be cast
// the order in which the functions are called here DOES MATTER, changing it
// WILL break the crafting subsystems
//------------------------------------------------------------------------------
int X2PreSpellCastCode()
{
   object oTarget = GetSpellTargetObject();
   int nContinue;

   //---------------------------------------------------------------------------
   // This stuff is only interesting for player characters we assume that use
   // magic device always works and NPCs don't use the crafting feats or
   // sequencers anyway. Thus, any NON PC spellcaster always exits this script
   // with TRUE (unless they are DM possessed or in the Wild Magic Area in
   // Chapter 2 of Hordes of the Underdark.
   //---------------------------------------------------------------------------
   if (!GetIsPC(OBJECT_SELF))
   {
       if( !GetIsDMPossessed(OBJECT_SELF) && !GetLocalInt(GetArea(OBJECT_SELF), "X2_L_WILD_MAGIC"))
       {
            return TRUE;
       }
   }

   //---------------------------------------------------------------------------
   // Break any spell require maintaining concentration (only black blade of
   // disaster)
   // /*REM*/ X2BreakConcentrationSpells();
   //---------------------------------------------------------------------------

   //---------------------------------------------------------------------------
   // Run use magic device skill check
   //---------------------------------------------------------------------------
   nContinue = X2UseMagicDeviceCheck();

   if (nContinue)
   {
       //-----------------------------------------------------------------------
       // run any user defined spellscript here
       //-----------------------------------------------------------------------
       nContinue = X2RunUserDefinedSpellScript();
   }

   //---------------------------------------------------------------------------
   // The following code is only of interest if an item was targeted
   //---------------------------------------------------------------------------
   if (GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_ITEM)
   {

       //-----------------------------------------------------------------------
       // Check if spell was used to trigger item creation feat
       //-----------------------------------------------------------------------
       if (nContinue) {
           nContinue = !ExecuteScriptAndReturnInt("x2_pc_craft",OBJECT_SELF);
       }

       //-----------------------------------------------------------------------
       // Check if spell was used for on a sequencer item
       //-----------------------------------------------------------------------
       if (nContinue)
       {
            nContinue = (!X2GetSpellCastOnSequencerItem(oTarget));
       }

       //-----------------------------------------------------------------------
       // * Execute item OnSpellCast At routing script if activated
       //-----------------------------------------------------------------------
       if (GetModuleSwitchValue(MODULE_SWITCH_ENABLE_TAGBASED_SCRIPTS) == TRUE)
       {
             SetUserDefinedItemEventNumber(X2_ITEM_EVENT_SPELLCAST_AT);
             int nRet =   ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oTarget),OBJECT_SELF);
             if (nRet == X2_EXECUTE_SCRIPT_END)
             {
                return FALSE;
             }
       }

       //-----------------------------------------------------------------------
       // Prevent any spell that has no special coding to handle targetting of items
       // from being cast on items. We do this because we can not predict how
       // all the hundreds spells in NWN will react when cast on items
       //-----------------------------------------------------------------------
       if (nContinue) {
           nContinue = X2CastOnItemWasAllowed(oTarget);
       }
   }

   return nContinue;
}

« Last Edit: September 24, 2007, 06:37:15 PM by Ser Red Ronnet Connington »

Offline 420

  • Hero Member
  • *****
  • Posts: 4087
    • View Profile
    • Email
Spell Scripts!
« Reply #7 on: September 24, 2007, 06:36:47 PM »
Quote
//:: Spell Hook Include File
[snapback]37655[/snapback]
That's just an Include File with custom functions for spellhook scripts. Ignore its existence.

Make a brand new script and just copy and past my code into it.

-420


Ser Red Ronnet Connington

  • Guest
Spell Scripts!
« Reply #8 on: September 24, 2007, 06:45:02 PM »
Quote
That's just an Include File with custom functions for spellhook scripts. Ignore its existence.

Make a brand new script and just copy and past my code into it.

-420
[snapback]37656[/snapback]

Ok this is what I have done, I have made a completely new module, with no scripts in it. I have then set the Global Variable-- a string.

To this: X2_S_UD_SPELLSCRIPT string myspellhook

I have then created a new script and called it this: myspellhook

Then the code in the script looks like this

Quote
#include "x2_inc_switches"
void main()
{
int nSpell=GetSpellId();

if(nSpell == SPELL_DIVINE_POWER)
    {
    if(GetLocalInt(OBJECT_SELF, "DPTime") == 1)
        {
        FloatingTextStringOnCreature("Divine Power can only be cast once every 10 rounds.", OBJECT_SELF, FALSE);
        SetModuleOverrideSpellScriptFinished();
        }
    else
        {
        SetLocalInt(OBJECT_SELF, "DPTime", 1);
        DelayCommand(60.0, ExecuteScript("dptimeup", OBJECT_SELF));
        }
    }
}

After that I have created a script called: dptimeup

with this code in it
Quote
void main()
{
DeleteLocalInt(OBJECT_SELF, "DPTime");
}
I then compiled all scripts and built mod and saved, it then still did not work.
« Last Edit: September 24, 2007, 06:45:43 PM by Ser Red Ronnet Connington »

Offline 420

  • Hero Member
  • *****
  • Posts: 4087
    • View Profile
    • Email
Spell Scripts!
« Reply #9 on: September 24, 2007, 07:40:46 PM »
I just followed your instructions exactly and it worked fine for me. Make sure that when you add the global variable you hit "Add" and not "OK". I make that mistake all the time.

Here is the mod I made: [attachmentid=1304]

-420

[attachment deleted by admin]

Ser Red Ronnet Connington

  • Guest
Spell Scripts!
« Reply #10 on: September 24, 2007, 09:46:12 PM »
Quote
I just followed your instructions exactly and it worked fine for me. Make sure that when you add the global variable you hit "Add" and not "OK". I make that mistake all the time.

Here is the mod I made: [attachmentid=1304]

-420
[snapback]37659[/snapback]

Thx mate, i used the replace function on the string and for some reason it did not work so i readded it and it worked!!!