Oh one more note if you are implementing current release (1.71b5). The current system has a customized x2_inc_spellhook library which rely on the script 70_spellhook in which is implemented default content of the function X2_PreSpellCastCode. This is in order to allow modify this code (internal spellhook) without need to recompile all spellscripts (very usefull for example if you want NPCs to trigger spellhook as well).
However the 70_spellhook script is not packaged with other spellscripts in builder's resources (oversight), thus spells won't trigger spellhook neither they will allow crafting without this script.
(NOTE: for regular user that install the patch this is not an issue)
You can get the file by installing the patch and openening it in toolset or this is the source code:
//::///////////////////////////////////////////////
//:: Community Patch 1.71: Improve Spell Hook Include File
//:: 70_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: Shadooow
//:: Created On: 2012-01-17
//:://////////////////////////////////////////////
#include "x2_inc_spellhook"
//------------------------------------------------------------------------------
// if X2_EXECUTE_SCRIPT_END is set by this script, the original spell will not be cast
// the order in which the functions are called here DOES MATTER, changing it
// WILL break the crafting subsystems
//------------------------------------------------------------------------------
void main()
{
object oTarget = GetSpellTargetObject();
object oItem = GetSpellCastItem();
if(oItem != OBJECT_INVALID)
{
int spellOverride = GetLocalInt(oItem,"ITEM_SPELL_OVERRIDE");
if(spellOverride != 0 && !GetLocalInt(GetModule(),"SPELL_OVERRIDE_FINISHED"))
{
SetLocalInt(GetModule(),"SPELL_OVERRIDE_FINISHED",TRUE);
ExecuteScript(Get2DAString("spells","ImpactScript",spellOverride < 0 ? 0 : spellOverride),OBJECT_SELF);
SetLocalInt(GetModule(),"SPELL_OVERRIDE_FINISHED",FALSE);
SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
return;
}
}
//---------------------------------------------------------------------------
// This small addition will check to see if the target is mounted and the
// spell is therefor one that should not be permitted.
//---------------------------------------------------------------------------
if(!GetLocalInt(GetModule(),"X3_NO_SHAPESHIFT_SPELL_CHECK"))
{ // do check for abort due to being mounted check
switch(GetPhenoType(oTarget))
{// shape shifting not allowed while mounted
case 3:
case 5:
case 6:
case 8:
if(X3ShapeShiftSpell(oTarget))
{
if(GetIsPC(oTarget))
{
FloatingTextStrRefOnCreature(111982,oTarget,FALSE);
}
SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
return;
}// shape shifting not allowed while mounted
break;
}
} // do check for abort due to being mounted check
//---------------------------------------------------------------------------
// 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;
}
}
//---------------------------------------------------------------------------
// Break any spell require maintaining concentration (only black blade of
// disaster)
// /*REM*/ X2BreakConcentrationSpells();
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Run use magic device skill check
//---------------------------------------------------------------------------
int 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))
{
SetUserDefinedItemEventNumber(X2_ITEM_EVENT_SPELLCAST_AT);
int nRet = ExecuteScriptAndReturnInt(GetUserDefinedItemEventScriptName(oTarget),OBJECT_SELF);
if (nRet == X2_EXECUTE_SCRIPT_END)
{
SetExecutedScriptReturnValue(X2_EXECUTE_SCRIPT_END);
return;
}
}
//-----------------------------------------------------------------------
// 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);
}
}
SetExecutedScriptReturnValue(!nContinue);
}
Modifié par ShaDoOoW, 15 juin 2012 - 09:38 .