"Template Teleport Script" - Views: 688 · Hits: 688 - Type: Public

// templ_teleport
/////////////////////////////////////////////////
//Ultimate Teleport Script v 1.3 - (TEMPLATE)
/////////////////////////////////////////////////
//Designed By: Amurayi ([email protected])
//Modified By: Genisys
/*Modified On: 8/15/08
/////////////////////////////////////////////////
Note from Genisys:

I Cleaned up the code to make it more readable,
fixed some errors I found, and restructured
the script to make it work more efficiently.

/////////////////////////////////////////////////

The problem with most of the teleport scripts out there is
that your companions won't be teleported with you if you are being
teleported within the same area. This easy to configure script
is the solution for this old problem. Simply adjust the settings
below to easially set up this script for ANY teleport!

What this script can do:
- Teleports player out of conversation, trigger or from an item
- Teleports player with or without companions
- Teleports player alone or the player's whole party

IMPORTANT: Save this as a template FIRST, then save it again
under a new name, BEFORE you edit this template!
                                                               */
/////////////////////////////////////////////////////////////////

//PROTOTYPE DECLARED
void JumpAssociate(object i_oPC, int i_type, object i_oWP);

//Main Script
void main()
{

object oPC;

//////////////////////////////////////////////////////////////////
////////////////IMPORTANT SETTINGS////////////////////////////////

  //Delete the // on one of the lines below for the proper event
  //NOTE: You MUST define the PC!

  // oPC = GetPCSpeaker();        // for conversations
  // oPC = GetEnteringObject();  // for triggers & areas
  // oPC = GetLastUsedBy();      // for placeable objects & scripted items


  //You MUST enter a tagname for the waypoint below.. (waypoints ONLY!)
  //This is where the PC is being teleported to.

  string sTagname = "tagname"; //What is the tagname of the waypoint?


    //////////////OPTIONAL SETTINGS///////////////

    //Set to 1 if you want to use fancy Visual Effects in the teleport
    int nVisuals = 0; //(0 = Default, don't play animations)

    //Set to 1 if you want to teleport the whole party of the PC
    int iTeleportWholeParty = 0; //(Default = 0, don't teleport party)

    //Set to 1 if you want the Associates of the PC to be teleporeted as well.
    int iTeleportAssociateToo = 0; //(Default = 0, don't teleport associates)

//////////////////////////////////////////////////////////////////////////////


//Any additional scripting code of yours would go here.. (before the teleport)


//////////////////////////////////////////////////////////////////////////////
///////////////////DON'T TOUCH ANYTHING BELOW THIS LINE!!!////////////////////

//Major Variables
object oDWP = GetWaypointByTag(sTagname);
object oFM;
effect eVis;

////////////////////////////////////////////
//***Conditional***//

//If the destination is not valid, tell the PC, DMs, and log file!
if (oDWP == OBJECT_INVALID)
{
 SendMessageToPC(oPC, "Destination not found.");
 SendMessageToAllDMs("The Way Point tagnamed: " + sTagname +  "WAS NOT FOUND IN THE MODULE!!");
 WriteTimestampedLogEntry(sTagname + " Way Point NOT FOUND IN THE MODULE!!**");

 return; //Stop the script here..
}

///////The Teleport (depending upon conditionals set above)////////

    //If we are teleporting the whole party.
    if (iTeleportWholeParty == 1)
        {
        float fT = 3.0;
        oFM = GetFirstFactionMember(oPC);
        // Step through the party members.
        while(GetIsObjectValid(oFM))
            {
            //Delay The Teleports properly
            fT +=0.1;

            //if we are using visual effects (On All PCs only)
            if(nVisuals ==1)
            {
            eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oFM);
            }

            AssignCommand(oFM,  DelayCommand(fT, JumpToObject(oDWP)));

            if (iTeleportAssociateToo == 1)
                {
                // now send the players companions over as well:
                DelayCommand(fT+4.3, JumpAssociate(oFM, ASSOCIATE_TYPE_ANIMALCOMPANION, oDWP));
                DelayCommand(fT+4.4, JumpAssociate(oFM, ASSOCIATE_TYPE_DOMINATED, oDWP));
                DelayCommand(fT+4.5, JumpAssociate(oFM, ASSOCIATE_TYPE_FAMILIAR, oDWP));
                DelayCommand(fT+4.6, JumpAssociate(oFM, ASSOCIATE_TYPE_HENCHMAN, oDWP));
                DelayCommand(fT+4.7, JumpAssociate(oFM, ASSOCIATE_TYPE_SUMMONED, oDWP));
                }
            // Select the next member of the faction and loop.
            oFM = GetNextFactionMember(oFM);
            }
        }
    //Otherwise just jump the PC (and possibly associates)
    else
       {
        //If we are using visual effects (on the PC only)
        if(nVisuals ==1) {
          eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
          ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oPC);
          //Always jump the PC no matter whatt
          AssignCommand(oPC, DelayCommand(3.0, JumpToObject(oDWP)));

          //If the Associates are assigned to go as well
          if (iTeleportAssociateToo == 1) {
            // now send the players companions over as well:
            DelayCommand(3.1, JumpAssociate(oPC, ASSOCIATE_TYPE_ANIMALCOMPANION, oDWP));
            DelayCommand(3.2, JumpAssociate(oPC, ASSOCIATE_TYPE_DOMINATED, oDWP));
            DelayCommand(3.3, JumpAssociate(oPC, ASSOCIATE_TYPE_FAMILIAR, oDWP));
            DelayCommand(3.4, JumpAssociate(oPC, ASSOCIATE_TYPE_HENCHMAN, oDWP));
            DelayCommand(3.5, JumpAssociate(oPC, ASSOCIATE_TYPE_SUMMONED, oDWP));
          }
        }
        else { // No Visual is used, so just telelport them fast!
          //Always jump the PC no matter whatt
          AssignCommand(oPC, ClearAllActions());
          AssignCommand(oPC, DelayCommand(0.1, JumpToObject(oDWP)));

          //If the Associates are assigned to go as well
          if (iTeleportAssociateToo == 1) {
            // now send the players companions over as well:
            DelayCommand(0.2, JumpAssociate(oPC, ASSOCIATE_TYPE_ANIMALCOMPANION, oDWP));
            DelayCommand(0.3, JumpAssociate(oPC, ASSOCIATE_TYPE_DOMINATED, oDWP));
            DelayCommand(0.4, JumpAssociate(oPC, ASSOCIATE_TYPE_FAMILIAR, oDWP));
            DelayCommand(0.5, JumpAssociate(oPC, ASSOCIATE_TYPE_HENCHMAN, oDWP));
            DelayCommand(0.6, JumpAssociate(oPC, ASSOCIATE_TYPE_SUMMONED, oDWP));
          }
        }
      }
}

//PROTOTYPE DEFINED
void JumpAssociate(object i_oPC, int i_type, object i_oWP)
{
    object oAssociate = GetAssociate(i_type, i_oPC);
    if(GetIsObjectValid(oAssociate))
        AssignCommand(oAssociate, JumpToObject(i_oWP));
}