#include "NW_I0_SPELLS"
#include "prc_inc_spells"

void main()
{
  int nEvent = GetUserDefinedEventNumber();
  if (!(GetLocalInt(OBJECT_SELF, "fired") == 1) && nEvent == 1003)
  {
    SetLocalInt(OBJECT_SELF, "fired", 1);
    object oTele = GetNearestCreature(CREATURE_TYPE_REPUTATION, REPUTATION_TYPE_ENEMY);
        {
        if (GetIsPC(oTele) && !PRCMySavingThrow(10,oTele,25,SAVING_THROW_TYPE_SPELL))
        {
        AssignCommand(OBJECT_SELF,ActionCastFakeSpellAtObject(SPELL_PHANTASMAL_KILLER,oTele));

        object oDest1 = GetObjectByTag("WP_CRYPTTHING_1");
        location lDest1 = GetLocation(oDest1);
        object oDest2 = GetObjectByTag("WP_CRYPTTHING_2");
        location lDest2 = GetLocation(oDest2);
        object oDest3 = GetObjectByTag("WP_CRYPTTHING_3");
        location lDest3 = GetLocation(oDest3);
        object oDest4 = GetObjectByTag("WP_CRYPTTHING_4");
        location lDest4 = GetLocation(oDest4);
        object oDest5 = GetObjectByTag("WP_CRYPTTHING_5");
        location lDest5 = GetLocation(oDest5);
        object oDest6 = GetObjectByTag("WP_CRYPTTHING_6");
        location lDest6 = GetLocation(oDest6);
        SetLocalInt(OBJECT_SELF, "duration", DURATION_TYPE_TEMPORARY);
        int duration = GetLocalInt(OBJECT_SELF, "duration");
        SetLocalInt(OBJECT_SELF, "vfx", VFX_IMP_AC_BONUS);
        int vfx = GetLocalInt(OBJECT_SELF, "vfx");
        effect eEffect = EffectVisualEffect(vfx);

        int nRoll=d6();

        switch (nRoll)
        {
            case 1:
                ApplyEffectToObject(duration, eEffect, oTele, 5.0);
                DelayCommand(3.0, AssignCommand(oTele, JumpToLocation(lDest1)));
            break;
            case 2:
                ApplyEffectToObject(duration, eEffect, oTele, 5.0);
                DelayCommand(3.0, AssignCommand(oTele, JumpToLocation(lDest2)));
            break;
            case 3:
                ApplyEffectToObject(duration, eEffect, oTele, 5.0);
                DelayCommand(3.0, AssignCommand(oTele, JumpToLocation(lDest3)));
            break;
            case 4:
                ApplyEffectToObject(duration, eEffect, oTele, 5.0);
                DelayCommand(3.0, AssignCommand(oTele, JumpToLocation(lDest4)));
            break;
            case 5:
                ApplyEffectToObject(duration, eEffect, oTele, 5.0);
                DelayCommand(3.0, AssignCommand(oTele, JumpToLocation(lDest5)));
            break;
            case 6:
                ApplyEffectToObject(duration, eEffect, oTele, 5.0);
                DelayCommand(3.0, AssignCommand(oTele, JumpToLocation(lDest6)));
            break;
}
}
}
}
}
