///:://///////////////////////////////////////////// //:: Knock //:: NW_S0_Knock //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* Opens doors not locked by magical means. */ //::////////////////////////////////////////////// //:: Created By: Preston Watamaniuk //:: Created On: Nov 29, 2001 //::////////////////////////////////////////////// //:: Last Updated By: Preston Watamaniuk //:: VFX Pass By: Preston W, On: June 22, 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()) { return; } // End of Spell Cast Hook object oTarget; effect eVis = EffectVisualEffect(VFX_IMP_KNOCK); oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 5.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE); float fDelay; int nLevel=20+GetCasterLevel(OBJECT_SELF); int nDC=GetLockUnlockDC(oTarget); while(GetIsObjectValid(oTarget)) { fDelay = 0.0; if((!GetLockKeyRequired(oTarget)) && GetLocked(oTarget)) { if (nLevel>=nDC) { DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget)); AssignCommand(oTarget, SetLocked(oTarget,0)); } else { SendMessageToPC(OBJECT_SELF,"Caster level "+IntToString(GetCasterLevel(OBJECT_SELF))+" plus 20 = "+IntToString(nLevel)+" vs lock DC "+IntToString(nDC)+", knock failed!"); DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_SLOW), oTarget)); } } if(GetLockKeyRequired(oTarget) && GetLocked(oTarget)) { DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_SLOW), oTarget)); SendMessageToPC(OBJECT_SELF,"The knock spell cannot unlock that - there may be some other way to open it"); } oTarget = GetNextObjectInShape(SHAPE_SPHERE, 5.0, GetLocation(OBJECT_SELF), FALSE, OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE); } }