Banishment and code trouble
Posted: Thu Mar 02, 2006 5:28 pm
Ok, I am trying to modify a few spells to banish a player/monsters to a demiplane if they are effected by it. Here is my code, modified from the psionic code.
My trouble is coming from this.. When cast against a single creature (pc or npc) it will banish the creature to the demiplane. If the spell is cast against a group of pc's(hostile or attacking) they will all be banished to the demiplane and each in their seperate 'cage'. If the spell is cast on a group of NPC's(hostile but not attacking) then they will all be banished to the demiplane.
The problem comes here:
If the spell is cast against a group of NPC's(hostile but attacking) then none of them will be banished, not even those that fail the save. If the spell is cast against a group of NPC's with PC's (both hostile and attacking), the PC's will all be banished, but if the NPC count is over 1, then none of the NPC's are banished.
Any ideas?
Code: Select all
//----------------------------------
case SPELL_WORD_OF_FAITH:
{
//Declare major variables
effect eLink = EffectVisualEffect(VFX_FNF_WORD);
effect eVis = EffectVisualEffect(VFX_IMP_DEATH);
float fDelay;
int nDuration=iLevel/2;
object oBanArea=GetObjectByTag("Banishment");
int nDC=17+GetAbilityModifier(ABILITY_WISDOM, oCaster);
//Apply the FNF VFX impact to the target location
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eLink, GetSpellTargetLocation());
//Get the first target in the spell area
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lTarget);
while (GetIsObjectValid(oTarget))
{
//Make a faction check
if(GetIsEnemy(oTarget))
{
fDelay = GetRandomDelay(0.5, 2.0);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_WORD_OF_FAITH));
//Make SR check
if(!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
eLink = EffectVisualEffect(VFX_IMP_SONIC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eLink, oTarget);
if(!WillSave(oTarget, nDC, SAVING_THROW_TYPE_NONE))
{
int nBanIndex=GetLocalInt(oBanArea, "BanIndex")+1;
if (nBanIndex>=37) nBanIndex=1;
location lDest=GetLocation(GetWaypointByTag("Banish_WP_"+IntToString(nBanIndex)));
location lHere=GetLocation(oTarget);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis, lHere);
AssignCommand(oTarget, ClearAllActions(TRUE));
AssignCommand(oTarget, JumpToLocation(lDest));
SetLocalInt(oBanArea, "BanIndex", nBanIndex);
//Wait one round before escape attempt
DelayCommand(6.0, Escape(oTarget, lHere, nDuration, nDC));
}
}
}
//Get the next target in the spell area
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lTarget);
}
SetModuleOverrideSpellScriptFinished();
break;
}
Code: Select all
void Escape(object oBanished, location lReturnSpot, int nDuration, int nDC);
void Escape(object oBanished, location lReturnSpot, int nDuration, int nDC)
{
if (nDuration <= 0 || WillSave(oBanished, nDC, SAVING_THROW_TYPE_NONE))
{
effect eVis2=EffectVisualEffect(VFX_IMP_GOOD_HELP);
eVis2=EffectLinkEffects(eVis2,EffectVisualEffect(VFX_IMP_DISPEL));
AssignCommand(oBanished, ClearAllActions());
DelayCommand(0.3, AssignCommand(oBanished, JumpToLocation(lReturnSpot)));
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis2, lReturnSpot);
if (!GetIsPC(oBanished))
DelayCommand(1.0, AssignCommand(oBanished,
DetermineCombatRound(GetNearestPerceivedEnemy(oBanished))));
}
else DelayCommand(6.0, Escape(oBanished, lReturnSpot, nDuration-1, nDC));
}
The problem comes here:
If the spell is cast against a group of NPC's(hostile but attacking) then none of them will be banished, not even those that fail the save. If the spell is cast against a group of NPC's with PC's (both hostile and attacking), the PC's will all be banished, but if the NPC count is over 1, then none of the NPC's are banished.
Any ideas?