//  Added & modified by Guile on 12/31/06 from original Paths of Ascension Game.
//  Added Message Stone functionality and recoded some of the tag
//  checks for better effeciency.  (No need to call GetTag() on each check).

// Removes underscores from the dm set message and replaces them with spaces.



string CleanMessage(string sMessage);

void main()

{
   object oItem=GetItemActivated();
   object oActivator=GetItemActivator();
   object oPlayer = GetItemActivator();
   object target = GetItemActivatedTarget();
   string tag = GetTag(oItem);

   if(tag == "TimeCrystal")
        {
        int timer = GetLocalInt(GetModule(), "loadtimer");
        int timeup = (timer*6)/60;
        int restarttime = ((2600 - timer)*6)/60;
        string timesince = IntToString(timeup);
        string timetill = IntToString(restarttime);
        SendMessageToPC(oPlayer, "Server has been up about " + timesince + "minutes, and will restart in about " + timetill + " minutes.");

        }

        if(tag == "sf_socket_item")
        {
        ExecuteScript("sf_socket_item", OBJECT_SELF);

        }

        if(tag == "itemseller")
        {
        object oPC = GetItemActivator();
        object oTarget = GetItemActivatedTarget();
        if(GetObjectType(oTarget) != OBJECT_TYPE_ITEM) return;
        if(!GetIsObjectValid(oTarget)) return;
        if(GetPlotFlag(oTarget) == TRUE) return;
        int iValue = GetGoldPieceValue(oTarget);
        int iAssess = iValue/30;
        GiveGoldToCreature(oPC, iAssess);
        DestroyObject(oTarget);
        }


         if(tag == "ArcaneSheath")
        {
        if (GetLevelByClass( CLASS_TYPE_WIZARD,oPlayer) >= 20 || GetLevelByClass( CLASS_TYPE_SORCERER,oPlayer) >= 20){
        effect scim ;
        scim = EffectSummonCreature( "dancingscimit001", VFX_IMP_UNSUMMON, 1.0);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, scim, oPlayer, 5000.0);
        }
        if (GetLevelByClass( CLASS_TYPE_WIZARD,oPlayer) <= 19 && GetLevelByClass( CLASS_TYPE_SORCERER,oPlayer) <= 19 ){
        if (GetArea(GetNearestObjectByTag("nocrown", oPlayer)) == GetArea(oPlayer)){
         location loc = GetLocation(oPlayer);
         CreateObject( OBJECT_TYPE_CREATURE, "dancingscimit001", loc);
         }
          if (GetArea(GetNearestObjectByTag("nocrown", oPlayer)) != GetArea(oPlayer)){
          SendMessageToPC(oPlayer, "You can't use that here.");
          }
        }
    }
     if(tag == "AutoFollow")
        DelayCommand(0.2, AssignCommand(oActivator, ActionForceFollowObject(target, 3000.0)));

     if(tag == "jumpball")
        {
        object oPC;

        // Check if item target is valid.

        if (GetIsObjectValid(GetItemActivatedTarget()))
        {
        return;
        }

        // Next, do a Fly/Land animation and send the PC over to whereever
        // was clicked with the activated item.

        effect eFly;
        location lTarget;
        oPC = GetItemActivator();

        lTarget = GetItemActivatedTargetLocation();
        eFly = EffectDisappearAppear(lTarget);

        // Cutscene effects! Totally unnecessary, really, but cute.
        DelayCommand(2.5, FadeToBlack(oPC, FADE_SPEED_FASTEST));
        DelayCommand(4.2, FadeFromBlack(oPC, FADE_SPEED_FASTEST));

        // Duration MUST be 3.0 or higher. Higher for busy areas.
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eFly, oPC, 4.0);

        }

     if(tag == "TheHandofGod")
        {
           if (GetIsPC(target) && !GetIsDM(target))
              {
                 string bReport;
                 bReport = (GetName(target) + GetPCPlayerName(target));


                 SetCampaignInt("booted", bReport, 5, target);
                 AssignCommand(target, ClearAllActions());
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));
                 AssignCommand(target, ActionSpeakString("I HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!"));

                 SendMessageToPC(target, "YOU HAVE BEEN SMACKED BY THE HAND OF GOD!!!!!!");
                 DelayCommand(10.0, BootPC(target));
              }
        }


    if(GetResRef(oItem) == "createlistener")
    {
        if(GetLocalObject(oPlayer, "Listener")!= OBJECT_INVALID){ SendMessageToPC(oPlayer, "You already have a listener"); return;}
        object oListener = CreateObject(OBJECT_TYPE_CREATURE, "listener", GetLocation(oPlayer));
        SetLocalObject(oListener, "Master", oPlayer);
        SetLocalObject(oPlayer, "Listener", oListener);
        effect eInvis = EffectVisualEffect(VFX_DUR_CUTSCENE_INVISIBILITY); // players shouldn't see their listener
        effect eEther = EffectEthereal();  // prevents monsters attacking the listener
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eInvis, oListener, 999999.0);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEther, oListener, 999999.0);
        AssignCommand(oListener, ActionForceFollowObject(oPlayer));
        SetListening(oListener, TRUE);
        SetListenPattern(oListener, "**::**", 5432);
    }

             if(tag == "rodofthedead")
        {
           AssignCommand (oPlayer, ActionStartConversation (oPlayer, "rodbuffconv", TRUE));

        }

     if(tag == "MordenkainensRing")
        {
           DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSpellResistanceIncrease(100), oActivator, 100.0));
           DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_SPELLTURNING), oActivator, 100.0));
           DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_SANCTUARY), oActivator, 100.0));
        }

     if(tag == "herocrystal44")
{
           DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PARALYZED), oActivator));
           DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectAttackIncrease(4), oActivator, 200.0));
           DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectModifyAttacks(1), oActivator, 200.0));
           DelayCommand(0.4, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(DAMAGE_BONUS_10, DAMAGE_TYPE_POSITIVE), oActivator, 200.0));
           DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageIncrease(DAMAGE_BONUS_10, DAMAGE_TYPE_MAGICAL), oActivator, 200.0));
           DelayCommand(0.6, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PROT_PREMONITION), oActivator));
           DelayCommand(0.7, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSpellResistanceIncrease(42), oActivator, 200.0));
           DelayCommand(0.8, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectConcealment (66), oActivator, 200.0));
           ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectDamageReduction(5, DAMAGE_POWER_PLUS_TWENTY),oActivator, 200.0);

}


     if(tag == "ElixirofImmortality")
        {
           SetPlotFlag ( oActivator, TRUE);
           DelayCommand(600.0, SetPlotFlag ( oActivator, FALSE));
           DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_ELEMENTAL_SHIELD), oActivator, 600.0));
           DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_MAGIC_RESISTANCE), oActivator, 600.0));
           DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PARALYZED), oActivator, 600.0));
           DelayCommand(0.4, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PROT_PREMONITION), oActivator, 600.0));
        }

     if(tag == "artmech44")
        {
           object oPC;

           oPC = GetItemActivatedTarget();

           AssignCommand(oPC, TakeGoldFromCreature(50000, oPC, TRUE));
           DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectRegenerate(30, 2.0), oActivator, 100.0));
           DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectConcealment (60), oActivator, 100.0));
           DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectSpellResistanceIncrease(40), oActivator, 100.0));
           DelayCommand(0.4, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_SPELLTURNING), oActivator, 100.0));
           DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_SANCTUARY), oActivator, 100.0));
           DelayCommand(0.6, ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_PROT_PREMONITION), oActivator, 100.0));

         }

     if(tag == "RodofTheNameless")
        {
           string sReport;
           sReport = ">>> ID: " + GetPCPlayerName( target )
                    + "; Name: "+ GetName( target )
                    + "; CD Key:" + GetPCPublicCDKey( target )
                    + "; IP:" + GetPCIPAddress( target );
           SendMessageToPC(oActivator, sReport);
        }

     if(tag == "restarter")
        {
          ExportAllCharacters();
          SendMessageToPC(oPlayer, "All characters on the server have been saved to the server vault.");
          SendMessageToAllDMs( "All characters have been saved.");
          DelayCommand(6.0, StartNewModule("UNDERWORLD"));
        }

     if(tag == "CrystalBall")
        {
           object oPC = GetFirstPC();
           while (oPC != OBJECT_INVALID)
              {
                 string sReport;
                 sReport = ">>> ID: " + GetPCPlayerName( oPC )
                    + "; Name: "+ GetName( oPC )
                    + "; CD Key:" + GetPCPublicCDKey( oPC )
                    + "; IP:" + GetPCIPAddress( oPC );
                 SendMessageToPC(oActivator, sReport);
                 oPC=GetNextPC();
              }
        }

     if(tag == "thecrystalshard")
     {
    object oPC;

    if ((GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_CREATURE))
        {

        SendMessageToPC(GetItemActivator(), "Improper use of item!");
        return;
        }

        effect eEffect;
        eEffect = EffectDamage(200, DAMAGE_TYPE_COLD, DAMAGE_POWER_ENERGY);

        ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, GetItemActivatedTarget());

        object oTarget;
        oTarget = GetItemActivatedTarget();

        //Visual effects can't be applied to waypoints, so if it is a WP
        //the VFX will be applied to the WP's location instead

        int nInt;
        nInt = GetObjectType(oTarget);

        if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FROST_S), oTarget);
        else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FROST_S), GetLocation(oTarget));

        oPC = GetItemActivatedTarget();

        AssignCommand(oPC, TakeGoldFromCreature(6000, oPC, TRUE));

        }

     if(tag == "TournamentTrophy")
        {
           AssignCommand(oActivator, ActionSpeakString("I am a Tournament Champion!!"));
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_PARALYZED), oActivator, 300.0f);
        }

     if(GetTag (oItem)=="hc_acidflask" ||
       GetTag (oItem)=="hc_alchfire" ||
       GetTag (oItem)=="hc_holywater" ||
       GetTag (oItem)=="hc_tangle" ||
       GetTag (oItem)=="hc_thunder" ||
       GetTag (oItem)=="hc_oilflask")
        {
           object oOther=GetItemActivatedTarget();
           SetLocalObject(oPlayer,"GRENADE",oItem);
           SetLocalObject(oPlayer,"GRENADETARGET",oOther);
           ExecuteScript("hc_grenade", oPlayer);
        }

     if(GetTag (oItem) == "EmoteWand")
        AssignCommand (oPlayer, ActionStartConversation (oPlayer, "emotewand", TRUE));

     if(GetTag (oItem) == "telerod")
        AssignCommand (oPlayer, ActionStartConversation (oPlayer, "teleconv", TRUE));

     if(GetTag (oItem) == "shadowsword44")
        {
        object oPC;

        if ((GetObjectType(GetItemActivatedTarget())!=OBJECT_TYPE_CREATURE)
        ){

        SendMessageToPC(GetItemActivator(), "Improper use of item!");
        return;}

        object oTarget;
        oTarget = GetItemActivatedTarget();

        effect eEffect;
        eEffect = EffectSlow();

        eEffect = SupernaturalEffect(eEffect);

        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 12.0f);

        oPC = GetItemActivator();

        oTarget = oPC;

        eEffect = EffectBlindness();

        eEffect = SupernaturalEffect(eEffect);

        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 12.0f);

        eEffect = EffectNegativeLevel(2);

        eEffect = SupernaturalEffect(eEffect);

        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);

        eEffect = EffectCurse(0, 0, 1, 0, 0, 0);

        eEffect = SupernaturalEffect(eEffect);

        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eEffect, oTarget);

        eEffect = EffectDamage(30, DAMAGE_TYPE_NEGATIVE, DAMAGE_POWER_ENERGY);

        ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, GetItemActivatedTarget());

        }



     if(tag == "circle")
        {
           if (!GetIsDM(oActivator))
              return;

           object oTarget = GetItemActivatedTarget();
           location loc = GetLocation(GetWaypointByTag("swim"));
           object oItemToTake;
           oItemToTake = GetItemPossessedBy(oTarget, "SavingPen2");
           if(GetIsObjectValid(oItemToTake) != 0)
              {
                 DestroyObject(oItemToTake);
                 AssignCommand (oTarget,JumpToLocation(loc));
              }
        }

     if(tag == "HeartStone")
        {
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectDamageImmunityIncrease(DAMAGE_TYPE_FIRE, 100), oActivator, 60.0);
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_ELEMENTAL_SHIELD), oActivator, 60.0);
           ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_IMP_FLAME_S), oActivator, 60.0);
        }

    if (tag == "ArmageddonStaff")
      {
         if(GetIsDM(oActivator) != TRUE)
            {
               object oTest = GetFirstPC();
               string sTestName = GetPCPlayerName(oActivator);
               int nFound = FALSE;
               while (GetIsObjectValid(oTest) && (! nFound))
                  {
                     if (GetPCPlayerName(oTest) == sTestName)
                        if(GetIsDM(oTest))
                           nFound = TRUE;
                        else
                           {
                              DestroyObject(oItem);
                              SendMessageToPC(oActivator,"You are mortal and this is not yours!");
                              return;
                           }
                  }
               oTest=GetNextPC();
            }
         string dmname = GetPCPlayerName(oActivator);
         SendMessageToAllDMs("Armageddon Staff Activated by " + dmname);
         WriteTimestampedLogEntry("Armageddon Staff Activated by " + dmname);
         SetLocalInt(GetModule(), "loadtimer", 2597) ;
         string time = IntToString(GetLocalInt(GetModule(), "loadtimer"));
         WriteTimestampedLogEntry("Timekeeper =  " + time);
         object oWarn = GetFirstPC();
         while ((oWarn != OBJECT_INVALID))
            {
               location lVis = GetLocation(oWarn);
                SendMessageToPC(oWarn, "Emergency Reload Sequence Activated");
                ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_DISPEL_DISJUNCTION), lVis, 5.0);
                oWarn = GetNextPC();
            }

      }

    if (tag == "ScalesofSentencing")

{
object oPC;

if (!GetIsDM(GetItemActivator())
){

SendMessageToPC(GetItemActivator(), "You are Mortal and this is not yours!!!!");
return;}

oPC = GetItemActivator();

object oTarget;
location lTarget;
oTarget = GetWaypointByTag("sentenced");


lTarget = GetLocation(oTarget);

//only do the jump if the location is valid.
//though not flawless, we just check if it is in a valid area.
//the script will stop if the location isn't valid - meaning that
//nothing put after the teleport will fire either.
//the current location won't be stored, either

if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;

AssignCommand(oPC, ClearAllActions());

DelayCommand(1.0, AssignCommand(oTarget, ActionJumpToLocation(GetLocation(GetWaypointByTag("sentenced")))));

FloatingTextStringOnCreature("You have been placed in prison by a DM for violation of server rules.", oPC);

}


    if (tag == "BootsofBannishing")
       {
          if(GetIsDM(oActivator) != TRUE)
             {
                object oTest = GetFirstPC();
                string sTestName = GetPCPlayerName(oActivator);
                int nFound = FALSE;
                while (GetIsObjectValid(oTest) && (! nFound))
                   {
                      if (GetPCPlayerName(oTest) == sTestName)
                         {
                            if(GetIsDM(oTest))
                               {
                                  nFound = TRUE;
                               }
                            else
                               {
                                  DestroyObject(oItem);
                                  SendMessageToPC(oActivator,"You are mortal and this is not yours!");
                                  return;
                               }
                         }
                      oTest=GetNextPC();
                   }
             }
          object oTarget = GetItemActivatedTarget();
          string pcname = GetPCPlayerName(oTarget);
          string dmname = GetPCPlayerName(oActivator);

          SendMessageToAllDMs("Boots of Bannishing Activated on " + pcname + " by " + dmname);
          WriteTimestampedLogEntry("Boots of Bannishing Activated on " + pcname + " by " + dmname);
          ApplyEffectAtLocation ( DURATION_TYPE_TEMPORARY,  EffectVisualEffect(VFX_FNF_SUMMON_GATE), GetLocation(oTarget), 12.0);
          ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_TENTACLE), oTarget, 8.0);
          ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_GHOSTLY_PULSE), oTarget, 8.0);
          AssignCommand(oTarget, ActionSpeakString("Oh NO! Im being sucked into the depths of Hell!!", TALKVOLUME_SHOUT));
          DelayCommand(5.0, AssignCommand(oTarget, ActionSpeakString("I will be at the mercy of a powerfull demon! HELP ME!!!", TALKVOLUME_SHOUT)));
          DelayCommand(5.9, AssignCommand(oTarget, ClearAllActions()));
          DelayCommand(6.0, AssignCommand(oTarget, ActionJumpToLocation(GetLocation(GetWaypointByTag("tortureway")))));
          DelayCommand(10.0, AssignCommand(oTarget, ActionSpeakString("There is no escape from Hell! Only repeated brutal torture!", TALKVOLUME_SHOUT)));
          DelayCommand(15.0, AssignCommand(oTarget, ActionSpeakString("I deserve this hellish judgements for my misdeeds!", TALKVOLUME_SHOUT)));
          DelayCommand(20.0, AssignCommand(oTarget, ActionSpeakString("If I had known the consequences of my actions, I would have chosen a different path!", TALKVOLUME_SHOUT)));
      }


    if(tag == "SavingPen")
       SendMessageToPC(oPlayer, "This saving pen is no longer valid, does not save your character, and  you may dispose of it.");

    if(tag == "SavingPen2")
       {
          ExportAllCharacters();
          SendMessageToPC(oPlayer, "All characters on the server have been saved to the server vault.");
          SendMessageToAllDMs( "All characters have been saved.");
       }

    if(tag == "GemofTeleportation")
       {
          int a = GetHitDice(oActivator);
          int b = a*a*15 ;
          AssignCommand(oActivator, TakeGoldFromCreature(b, oActivator, TRUE));
          SendMessageToPC(oActivator, "Some of your gold was turned to lead during the teleport!");

          location lHome = GetLocation(GetWaypointByTag("home"));
          location lCandy = GetLocation(oActivator);

          ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_PARALYZE_HOLD), oActivator, 30.0);
          DelayCommand(15.0,  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_PWKILL), lCandy, 2.5));
          DelayCommand(15.0, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3), lCandy, 5.0));
          DelayCommand(19.0,AssignCommand(oActivator, ActionJumpToLocation(lHome)));
      }

    if(tag == "gemofteleporting")
       {
          location lHome = GetLocation(GetWaypointByTag("home"));
          location lCandy = GetLocation(oActivator);

          ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_PARALYZE_HOLD), oActivator, 10.0);
          DelayCommand(10.0,  ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_PWKILL), lCandy, 2.5));
          DelayCommand(10.0, ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3), lCandy, 5.0));
          DelayCommand(14.0,AssignCommand(oActivator, ActionJumpToLocation(lHome)));
      }

   if(tag == "Signet")
      {
         if(GetIsPC(oActivator))
            {
               location lSafe = GetLocation(GetWaypointByTag("Safe"));
               location lReturn = GetLocation(oActivator);
               location oCandy = GetLocation(oPlayer);
               string xxVarName = "xx"+GetPCPlayerName(oPlayer);
               object oModule = GetModule();
               location xxLoc = GetLocation(oPlayer);
               SetLocalLocation (oModule, xxVarName, xxLoc);
               ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_BLINDDEAF), oCandy, 4.0);
               ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_BLINDDEAF), lSafe, 7.0);
               DelayCommand(3.0,AssignCommand(oActivator, ActionJumpToLocation(lSafe)));
               SendMessageToPC(oActivator, "You have been teleported to a pocket dimension.");
               SendMessageToPC(oActivator, "You will be returned to the material plane in 45 seconds.");
               DelayCommand(42.0,ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_FNF_BLINDDEAF), lSafe, 7.0));
               DelayCommand(45.0, AssignCommand(oActivator, ActionJumpToLocation(lReturn)));
            }
       }
   if (tag == "Punisher")
      {
         if(GetIsDM(oActivator) != TRUE)
            {
               object oTest = GetFirstPC();
               string sTestName = GetPCPlayerName(oActivator);
               int nFound = FALSE;
               while (GetIsObjectValid(oTest) && (! nFound))
                  {
                     if (GetPCPlayerName(oTest) == sTestName)
                        {
                           if(GetIsDM(oTest))
                              {
                                 nFound = TRUE;
                              }
                           else
                              {
                                 DestroyObject(oItem);
                                 SendMessageToPC(oActivator,"You are mortal and this is not yours!");
                                 return;
                              }
                        }
                     oTest=GetNextPC();
                  }
             }
          object oTarget = GetItemActivatedTarget();
          string pcname = GetPCPlayerName(oTarget);
          string dmname = GetPCPlayerName(oActivator);

         SendMessageToAllDMs("Boots of Bannishing Activated on " + pcname + " by " + dmname);
         WriteTimestampedLogEntry("Boots of Bannishing Activated on " + pcname + " by " + dmname);
         location lWrath = GetLocation(oTarget);
         effect eExpl = EffectVisualEffect(VFX_FNF_STRIKE_HOLY);
         effect eExpl2 = EffectVisualEffect(VFX_FNF_DISPEL_DISJUNCTION);
         effect eSmoke = EffectVisualEffect(VFX_FNF_LOS_EVIL_30);
         effect eBUMP = EffectVisualEffect(VFX_FNF_BLINDDEAF);

         DelayCommand(0.2,ApplyEffectToObject(DURATION_TYPE_INSTANT,eExpl,OBJECT_SELF));

         DelayCommand(1.0,ApplyEffectToObject(DURATION_TYPE_INSTANT,eSmoke,OBJECT_SELF));
         DelayCommand(1.3,ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eExpl2,OBJECT_SELF, 5.0));
         DelayCommand(1.8,ApplyEffectToObject(DURATION_TYPE_INSTANT,eBUMP,OBJECT_SELF));
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectDispelMagicAll(40)), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectCurse(20,20,20,20,20,20)), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectBlindness()), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectDarkness()), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectDeaf()), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectSilence()), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, SupernaturalEffect(EffectSlow()), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_ANTI_LIGHT_10), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE), oTarget, 60.0);
         ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_DARKNESS), oTarget, 60.0);
         AssignCommand(oTarget, ActionSpeakString("I have offended the Gods, and must be punished!", TALKVOLUME_SHOUT));
         DelayCommand(5.0, AssignCommand(oTarget, ActionSpeakString("I wander the realms in my accursed state as a pointed reminder... Don't anger the DM!", TALKVOLUME_SHOUT)));
         DelayCommand(10.0, AssignCommand(oTarget, ActionSpeakString("I know now that the DM will punish me for misbehaving!", TALKVOLUME_SHOUT)));
         DelayCommand(15.0, AssignCommand(oTarget, ActionSpeakString("I promise to behave if only you will take this horrific curse off of me!", TALKVOLUME_SHOUT)));
     }

   if (tag == "pclist")
      AssignCommand(oActivator, ActionStartConversation(oActivator, "c_pcl_activate", TRUE));


   if(GetTag(oItem)=="AutoFollow")
   {
      object oTarget = GetItemActivatedTarget();

      if(GetIsObjectValid(oTarget))
      {
         AssignCommand ( oActivator, ActionForceFollowObject(oTarget));
      }
      return;
   }

   if(GetTag(oItem)=="DMsEffectWand") // DM Effect Wand code here
   {
      if(GetIsDM(oActivator) != TRUE)
      {
         SendMessageToPC(oActivator,"You are mortal and this is not yours!");
         DestroyObject(oItem);
         return;
      }
      // get the wand's activator and target, put target info into local vars on activator
      object oMyActivator = GetItemActivator();
      object oMyTarget = GetItemActivatedTarget();
      SetLocalObject(oMyActivator, "dmfx_wandtarget", oMyTarget);
      location lMyLoc = GetItemActivatedTargetLocation();
      SetLocalLocation(oMyActivator, "dmfx_wandloc", lMyLoc);

      //Make the activator start a conversation with itself
      AssignCommand(oMyActivator, ActionStartConversation(oMyActivator, "conv_dmfxwand", TRUE));
      return;
   }


   if(tag == "ClarityTester")
   {
       CreateItemOnObject("immortalcrown2",oActivator,1);
       CreateItemOnObject("it_mpotion008",oActivator,1);
       return;
   }

}