//::////////////////////////////////////////////////////////////////////////////
//::
//:: Script Name: tele_handler_e
//::
//:: Use: This script is used as a teleportation system handler whereas the
//:: player will be teleported to multiple places defined by the variable on
//:: the placeable used to teleport the player. This eliminates the need for
//:: a custom teleportation script for each teleportation. This script is based
//:: on conversational teleportation, there is another script "teleport_handler"
//:: based on teleportation from an OnUsed event from a placeable, etc. This
//:: script is based on player OnEnter event, "tele_handler_c" is based on
//:: GetPCSpeaker event.
//::
//:: Created By: Birdman076
//::
//:: Created On: July 27, 2009
//::
//:: Note: This script will check for a variable defined on the trigger used
//:: to teleport the player to a waypoint. If the variable is not defined on
//:: the placeable nothing will happen. This will only work for a player, not a
//:: whole party.
//::
//::////////////////////////////////////////////////////////////////////////////
string sSayThis;
int iTalkVolume = TALKVOLUME_TALK;
int iTalkFlag = 0;
#include "nw_i0_tool"
location lTarget;
object oTarget;
//Put this script on conversation
    void main()
    {
    object oPC = GetEnteringObject();

//check to make sure we are a player
    if (!GetIsPC(oPC)) return;

//Start of 1st set of conditions.
//This first set of conditions will do the following: check for an integer stored
//On the placeable in question. It will then get the waypoint by tag which we have
//created and placed in the area we wish to send the player. It will verify it is valid
//if it is valid we will then clear all actions of the player and jump them to the
//location with some visual effects, in this case the "unsummon" effect.
if (GetLocalInt(OBJECT_SELF, "UNDER_WP2_TELE")== 1)
   {
   oTarget = GetWaypointByTag("UNDER_WP2");
   lTarget = GetLocation(oTarget);
   if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;
   AssignCommand(oPC, ClearAllActions());
   AssignCommand(oPC, PlaySound("as_mg_telepout1"));
   DelayCommand(1.0, AssignCommand(oPC, ActionJumpToLocation(lTarget)));
//End 1st set of conditions

//Start 2nd set of conditions same template as 1st
   }
else if (GetLocalInt(OBJECT_SELF, "SOMEVAR")== 1)
   {
if (GetNearestObjectByTag("TAER_PRLCHPRT", OBJECT_SELF) == OBJECT_INVALID){

if((!HasItem(GetEnteringObject(), "TAER_CRUWL")) == FALSE){
    object oItemToTake = GetItemPossessedBy(GetEnteringObject(), "TAER_CRUWL");
       DestroyObject(oItemToTake);
       DestroyObject(oItemToTake);
       DestroyObject(oItemToTake);
    object oTarget = GetObjectByTag("LCPORTCRT");
    object oPC = GetEnteringObject();
    AssignCommand(oPC, ClearAllActions(TRUE));
    AssignCommand(oPC, PlaySound("as_mg_telepout1"));
    CreateObject(OBJECT_TYPE_PLACEABLE, "lichportalz", GetLocation(oTarget), TRUE);
    }

else {
   object oPC = GetEnteringObject();
   sSayThis = "I sense great power here.  I wonder how I can release it?";
   AssignCommand(oPC, ClearAllActions(TRUE));
   AssignCommand(oPC, ActionSpeakString(sSayThis, iTalkVolume));}}

else {
    object oItemToTake = GetItemPossessedBy(GetEnteringObject(), "TAER_CRUWL");
    DestroyObject(oItemToTake);
    DestroyObject(oItemToTake);
    DestroyObject(oItemToTake);}
//End 2nd set of conditions
   }
}