//////////////////////////////////////////////////////////////////////////////// // wazoo_s0_ropetri - Spells Out The Wazoo - Rope Trick Spell // By Deva Bryson Winblood. 09/18/2004 //////////////////////////////////////////////////////////////////////////////// #include "x2_inc_spellhook" /////////////////////////// // PROTOTYPES /////////////////////////// // FILE: wazoo_s0_ropetri FUNCTION: fnCatastrophe() // what happens when you cast a rope trick within a rope trick. :) void fnCatastrophe(object oCaster); ////////////////////////////////////////////////////////////////////////// MAIN void main() { object oCaster=OBJECT_SELF; object oRope; object oLink; int nLevel=GetCasterLevel(oCaster); int nLink; int nTime; vector vV; float fF; if (!X2PreSpellCastCode()) { // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell return; } if (GetLocalInt(oCaster,"bIsUnderwater")) { // cannot use while underwater - Nov 12th, 2008 - Deva Winblood FloatingTextStringOnCreature("** Not useable underwater **",oCaster,FALSE); SendMessageToPC(oCaster,"The ropetrick spell fails when cast underwater."); return; } // cannot use while underwater - Nov 12th, 2008 - Deva Winblood if (GetName(GetArea(oCaster))!="Rope Trick") { // not in a rope trick area SendMessageToPC(oCaster,"You have successfully cast Rope Trick which will last "+IntToString(nLevel)+" game hours or until someone goes up the rope and comes back down."); nLink=1; oLink=GetObjectByTag("wazoo_ropetrick_d"+IntToString(nLink)); while(GetIsObjectValid(oLink)&&GetLocalInt(oLink,"bUsed")) { // look for useable rope trick area nLink++; oLink=GetObjectByTag("wazoo_ropetrick_d"+IntToString(nLink)); } // look for useable rope trick area if (GetIsObjectValid(oLink)&&GetLocalInt(oLink,"bUsed")==FALSE) { // rope trick useable area found oRope=CreateObject(OBJECT_TYPE_PLACEABLE,"wazoo_po_ropetd",GetLocation(oCaster)); SetLocalInt(oLink,"bUsed",TRUE); SetLocalObject(oLink,"oCaster",oCaster); SetLocalObject(oLink,"oRope",oRope); SetLocalObject(oRope,"oLink",oLink); SetLocalInt(oLink,"bCasterHasUsed",FALSE); nTime=(GetCalendarMonth()*30*24)+(GetCalendarDay()*24)+GetTimeHour(); nTime=nTime+nLevel; SetLocalInt(oLink,"nEndTime",nTime); SetLocalObject(oLink,"oArea",GetArea(oCaster)); vV=GetPosition(oRope); fF=vV.x; SetLocalFloat(oLink,"fX",fF); fF=vV.y; SetLocalFloat(oLink,"fY",fF); fF=vV.z; SetLocalFloat(oLink,"fZ",fF); fF=GetFacing(oCaster); SetLocalFloat(oLink,"fOrientation",fF); } // rope trick useable area found else { // error SendMessageToPC(oCaster,"ROPE TRICK ERROR: There are "+IntToString(nLink-1)+" rope trick areas and all of them were flagged as used!"); DestroyObject(oRope); } // error } // not in a rope trick area else { // catastrophe fnCatastrophe(oCaster); } // catastrophe } ////////////////////////////////////////////////////////////////////////// MAIN /////////////////////////// // FUNCTIONS /////////////////////////// void fnCatastrophe(object oCaster) { // PURPOSE: Handle casting rope trick within rope trick effect eBlast=EffectVisualEffect(VFX_FNF_FIREBALL); effect eDamage=EffectDamage(d6(10)); int nN; object oOb; ApplyEffectAtLocation(DURATION_TYPE_INSTANT,eBlast,GetLocation(oCaster)); nN=1; oOb=GetNearestObject(OBJECT_TYPE_CREATURE,oCaster,nN); while(GetIsObjectValid(oOb)&&GetDistanceBetween(oCaster,oOb)<6.0) { // blast ApplyEffectToObject(DURATION_TYPE_INSTANT,eDamage,oOb); nN=1; oOb=GetNearestObject(OBJECT_TYPE_CREATURE,oCaster,nN); } // blast nN=1; oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,oCaster,nN); while(GetIsObjectValid(oOb)&&GetName(oOb)!="Rope Trick Exit") { // look for exit nN++; oOb=GetNearestObject(OBJECT_TYPE_PLACEABLE,oCaster,nN); } // look for exit if (GetIsObjectValid(oOb)&&GetName(oOb)=="Rope Trick Exit") { // found exit DeleteLocalInt(oOb,"bUsed"); } // found exit ApplyEffectToObject(DURATION_TYPE_INSTANT,eDamage,oCaster); } // fnCatastrophe()