Aller au contenu

Photo

Teleport script - works, but not teleporting whole party?


  • Veuillez vous connecter pour répondre
16 réponses à ce sujet

#1
dickel

dickel
  • Members
  • 72 messages
Here is the teleport script I got from somewhere and I reckon it seems pretty awesome.

[nwscript] ////////////////////////////////////////////////
//  BOG Fully Flexible Teleport system 1.0
/////////////////////////////////////////////////
//  Author: Baron of Gateford
//  Date: 06-12-2004
//  This is based on a script by Amurayi
//  The original Amurayi script allowed for a lot of flexibility but meant you needed multiple versions of it.
//
//  You now only need this ONE script to handle teleports.
//  All paramters are set via local variables set on the object that is going to teleport the PC.
//
//  Via local variables you can choose whether to;
//  teleport player out of conversation, trigger or placeable
//  teleport player with or without companions (if teleporting within same area)
//  teleport player alone or the whole party (players)
//  Make the player say a one liner when being teleported.
//  Send a message to the Player to let them know what happened.
//  Choose from 5 visual effects to play when the player is teleported.
//
//  Installation Instructions
//  -------------------------
//  Cut and paste this script in to your script editor and save the script to something sensible.
//  e.g. Teleport_script, or BOG_teleport, or whatever takes your fancy.
//
//  Place this script on the one of the following script slots (depending on who/what teleports the PC)
//  Onused - for placeables that when used teleport the PC
//  OnEnter - for triggers that teleport the PC when the PC enters them.
//  Action Taken(of conversation) - when the PC is teleported via a conversation node (called from either NPC or Placeable).
//
//  Now set the variables on the object performing the teleport (NPC/Trigger/placeable)
//
//  Variable instructions.
//  ----------------------
//  The following lists the variables that need to be set-up in order for this teleport system to work.
//  They need to be set on either the placeable,trigger, or NPC that will teleport the PC.
//
//      To set variables on an object;
//      Open up the toolset, right mouse click the object.
//      select 'variables' from the pop up menu.
//
//  TeleType (int)
//     0 = objects (onused)
//     1 = trigger (onenter)
//     2 = coversation
//  This variable is MANDATORY, and lets the script know what kind of object is being used.
//  e.g. if this teleport script is placed on the actions taken slot of a conversation, then set this variable to 2.
//       if this teleport script is placed on the OnEnter slot of a trigger, then set this variable to 1.
//  It will default to onused if it is not set.
//
//  TeleDest (string)
//     Tag of waypoint to be teleported to.
//  This is MANDATORY. The value of this string must be the TAG of the waypoint to be teleported to.
//
//  TeleParty (int)
//     0 = self
//     1 = whole party
//  Set this variable to 1 to teleport the PC and the entire party.
//  It will default to just the PC if it is not set.
//
//  TeleHench (int)
//     0 = self
//     1 = pc and henchman/asociates
//  Set this variable to 1 if you are teleporting within the same area and want all henchmen/associates to be teleported too.
//  It will default to just the PC if it is not set.
//
//  TeleSay (string)
//     Speech pc says when leaving (to let other players know what is happening)
//  Enter the text in this string variable to the text you want the PC to say when he gets teleported.
//  e.g. "I'm going to the Wizards lab", or "I am going down this hole" etc.
//  The PC will not say anything if not set.
//
//  TeleMessage (string)
//     Message sent to pc to describe what happened
//  Enter the text in this string variable to the message you want to send to the PC to describe what happened
//  e.g. "You arrive at the wizards lab", or "You climb down the hole" etc.
//
//  TeleVisual (int)
//     0 = No visual effect
//     1 = Summon monster 1 - Large white explosion that turns to smoke.
//     2 = Summon monster 2 - Purple glyph with white lines moving around purple spots.
//     3 = Summon monster 3 - Blue glyph with orange light on floor and white rising light.
//     4 = Implosion        - Yellow/black "black hole" type look.
//     5 = Summon undead    - Small white cloud.
//  Set this variable to the values listed above for the corresponding visual effect to be used when the PC is teleported.
//  If the variable is set to a value greater than 5 then the VFX used is Summon Monster 1.
//  The VFX will only be used on actual player characters (not henchmen/familiars etc.)
//
///////////////////////////////////////////////
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));
}
void main()
{
    object oPC;
    //Get the type of object used for the teleport function
    int iTeletype = GetLocalInt(OBJECT_SELF,"TeleType");
    if (iTeletype == 2)
       {
        oPC = GetPCSpeaker();     // for conversations
       }
    else if (iTeletype == 1)
       {
        oPC = GetEnteringObject();  // for triggers
       }
    else
       {
        oPC = GetLastUsedBy();    // for items/objects (default if Teletype int not set)
       }
    // set TeleParty to 1 if you want to teleport the whole party of the player, wherever every member is:
    int iTeleportWholeParty = GetLocalInt(OBJECT_SELF,"TeleParty");
    // set TeleHench to 1 if you want the Associates of the player to be teleported as well, otherwise to 0:
    int iTeleportAssociateToo = GetLocalInt(OBJECT_SELF,"TeleHench");
    //Get the destination waypoint tag from the local variables set
    string sTeleDest = GetLocalString(OBJECT_SELF,"TeleDest");
    object oDWP = GetWaypointByTag(sTeleDest);
    // Make the player say something on his departure (so others will now that he teleported, not crashed):
    string sGoodbye = GetLocalString(OBJECT_SELF,"TeleSay");
    // Enter the message being sent to the player when teleport starts:
    string sTeleportmessage = GetLocalString(OBJECT_SELF,"TeleMessage");
    // The visual effect to be played when teleport happens
    effect eVis;
    int iTeleVisual = GetLocalInt(OBJECT_SELF,"TeleVisual");
    if (iTeleVisual == 1)
        {
         eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);
        }
    if (iTeleVisual == 2)
        {
         eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_2);
        }
    if (iTeleVisual == 3)
        {
         eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_3);
        }
    if (iTeleVisual == 4)
        {
         eVis = EffectVisualEffect(VFX_FNF_IMPLOSION);
        }
    if (iTeleVisual == 5)
        {
         eVis = EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD);
        }
    if (iTeleVisual > 5)
        {
         eVis = EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);
        }
    // Don't start Teleport at all if activator isn't a player or DM
    if(!GetIsPC(oPC))
        return;
    if (iTeleportWholeParty == 1)
        {
        object oFM = GetFirstFactionMember(oPC);
        // Step through the party members.
        while(GetIsObjectValid(oFM))
            {
            //only use the visual effect if the local variable has been set
            if (iTeleVisual > 0)
                {
                 ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oFM);
                }
            //only let the PC say something if the local variable has been set
            if (sGoodbye != "")
                {
                 AssignCommand(oFM, ActionSpeakString(sGoodbye));
                }
            //only send a message to the PC if the local variable has been set
            if (sTeleportmessage != "")
                {
                 SendMessageToPC(oFM, sTeleportmessage);
                }
            AssignCommand(oFM,  DelayCommand(2.0, JumpToObject(oDWP)));
            if (iTeleportAssociateToo == 1)
                {
                // now send the players companions over as well:
                DelayCommand(2.0, JumpAssociate(oFM, ASSOCIATE_TYPE_ANIMALCOMPANION, oDWP));
                DelayCommand(2.0, JumpAssociate(oFM, ASSOCIATE_TYPE_DOMINATED, oDWP));
                DelayCommand(2.0, JumpAssociate(oFM, ASSOCIATE_TYPE_FAMILIAR, oDWP));
                DelayCommand(2.0, JumpAssociate(oFM, ASSOCIATE_TYPE_HENCHMAN, oDWP));
                DelayCommand(2.0, JumpAssociate(oFM, ASSOCIATE_TYPE_SUMMONED, oDWP));
                }
            // Select the next member of the faction and loop.
            oFM = GetNextFactionMember(oFM);
            }
        }
    else
       {
        //only use the visual effect if the local variable has been set
        if (iTeleVisual > 0)
           {
           ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oPC);
           }
        //only let the PC say something if the local variable has been set
        if (sGoodbye != "")
           {
           AssignCommand(oPC, ActionSpeakString(sGoodbye));
           }
        //only send a message to the PC if the local variable has been set
        if (sTeleportmessage != "")
           {
           SendMessageToPC(oPC, sTeleportmessage);
           }
        AssignCommand(oPC, DelayCommand(2.0, JumpToObject(oDWP)));
        if (iTeleportAssociateToo == 1)
            {
            // now send the players companions over as well:
            DelayCommand(2.0, JumpAssociate(oPC, ASSOCIATE_TYPE_ANIMALCOMPANION, oDWP));
            DelayCommand(2.0, JumpAssociate(oPC, ASSOCIATE_TYPE_DOMINATED, oDWP));
            DelayCommand(2.0, JumpAssociate(oPC, ASSOCIATE_TYPE_FAMILIAR, oDWP));
            DelayCommand(2.0, JumpAssociate(oPC, ASSOCIATE_TYPE_HENCHMAN, oDWP));
            DelayCommand(2.0, JumpAssociate(oPC, ASSOCIATE_TYPE_SUMMONED, oDWP));
            }
        }
} [/nwscript]

It works fine - I have it placed on a placeable and when clicked on (on used) the PC (and I had hoped the rest of the party too) gets teleported to a waypoint.
I have correctly placed all the variables on the placeable portal, but for some reason only the first PC gets tele'd and the rest of the party gets left behind. (it is teleporting to another location in the same area atm)

Im no script monkey, but if someone could tell me from the above script why this might not be working, that'd be ace.
ps- As I said, I have double checked the variables, the variables TeleParty and TeleHench are both variable integers and set to 1. Hope that helps.
Peace.:wizard:

Modifié par dickel, 09 avril 2011 - 04:03 .


#2
dickel

dickel
  • Members
  • 72 messages

Modifié par dickel, 09 avril 2011 - 05:10 .


#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Did you set this variable as per the instructions?

// TeleParty (int)
// 0 = self
// 1 = whole party
// Set this variable to 1 to teleport the PC and the entire party.
// It will default to just the PC if it is not set.

#4
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
Double check the variables. That's a fancy script with lots of features. I use this much simpler one for jumping the party to a waypoint on use. No teleporting effect in it though that could be easily added.

// bb_onused_travel
// by Brendan Bellina
// May, 2009

// Based on ga_bb_travel

// Set to the onused script of an object to travel when object is used
// Transports the player and party to the target waypoint's location in current module or in another module.
// Note that because SinglePartyTransition is used the party members will be restored to life.

#include "ginc_transition"

void main()
{
object oPC = GetLastUsedBy();

if (GetIsPC(oPC))
{
string sWP = GetLocalString(OBJECT_SELF,"sTarget");
string sModule = GetLocalString(OBJECT_SELF,"sModule");

object oTarget = GetObjectByTag(sWP); // GetWaypointByTag won't work here

// check if the target exists in the current module
if(GetIsObjectValid(oTarget))
{
// exists in module: jump the party to the target
SinglePartyTransition(oPC, oTarget);
}
else
{
// does not exist in module: load the appropriate module and jump the party to the target
LoadNewModule(sModule, sWP);
}
}
}

Regards

Modifié par Kaldor Silverwand, 09 avril 2011 - 06:15 .


#5
dickel

dickel
  • Members
  • 72 messages
Yeah I have now triple checked the integers and variables. I have set the correct ones, yet it does not matter who in the party clicks the placeable, only the first PC always gets teleported.
The party is created using the SOZ party creation GUI, would this make a difference on party members as opposed to if I just created NPC's that joined the party via the roster?

#6
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
Possibly. Depends on whether the GetAssociate function recognizes them or not. The script you are using was written for NWN1 not NWN2.

#7
dickel

dickel
  • Members
  • 72 messages
@Kaldor
Would the 'GetAssociate' function in this case be the following line?
object oFM = GetFirstFactionMember(oPC);

..as in GetFirstFactionMember?
If this is true, then I would have thought (as i said i cant script) that this would be the correct function to use? Only based off various script posts and forum entries I have read.
I thought I recalled that 'GetFirstFactionMember' was a good one to use, while using the SOZ party creator in a campaign?

#8
Guest_Chaos Wielder_*

Guest_Chaos Wielder_*
  • Guests
Try this:

void main()
{
object oUsed=GetLastUsedBy();
string sTeleDest = GetLocalString(OBJECT_SELF,"TeleDest");

object o=GetFirstFactionMember(oUsed, FALSE);

while(GetIsObjectValid(o))
{
AssignCommand(o, ClearAllActions(TRUE));
AssignCommand(o, ActionJumpToLocation(GetLocation(GetWaypointByTag(sTeleDest))));
o=GetNextFactionMember(oUsed, FALSE);
}
AssignCommand(oUsed, ClearAllActions(TRUE));
AssignCommand(oUsed, ActionJumpToLocation(GetLocation(GetWaypointByTag(sTeleDest))));
}

#9
kamal_

kamal_
  • Members
  • 5 238 messages
I used the script in Path of Evil. It's in the Halruaa module if you downloaded it. It works there, but I can't remember if I had to make changes.

#10
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages

dickel wrote...

@Kaldor
Would the 'GetAssociate' function in this case be the following line?
object oFM = GetFirstFactionMember(oPC);

..as in GetFirstFactionMember?
If this is true, then I would have thought (as i said i cant script) that this would be the correct function to use? Only based off various script posts and forum entries I have read.
I thought I recalled that 'GetFirstFactionMember' was a good one to use, while using the SOZ party creator in a campaign?


If you are teleporting the whole party then I guess the associate shouldn't matter since all party members are in the faction.

I would do two things: first doublecheck that the TeleParty variable on the object is set to be an integer and not a string.

Two, change this line in the script and recompile it:
oFM = GetNextFactionMember(oFM);

I think it should be:
oFM = GetNextFactionMember(oPC);

Regards

Modifié par Kaldor Silverwand, 10 avril 2011 - 06:58 .


#11
dickel

dickel
  • Members
  • 72 messages
Thanks Kaldor but no luck sadly.
It compiled successfully, but still only the first pc gets ported.
I have just ended up wacking down generic area transition triggers instead. Much easier that way. Doesn't look quite as 'exciting' but oh well.

Thanks also to the others who replied.

Modifié par dickel, 11 avril 2011 - 02:32 .


#12
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
You can also download kamal_'s Path of Evil and see what he did to make the script work.

Regards

#13
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages
Hi,

There is a really easy way to do this by using the JumpPartyToArea function. It is very similar to Kaldor's script, but simply avoids using the SinglePartyTransition wrapper, which makes sure the party are alive prior to being transferred with the JumpPartyToArea function. In fact, the script Kaldor provided should have worked well for you, apart from the fact it did not determine which method the player was using to request the teleport. (i.e. Conversation, entering trigger or on used.) The script below will only transfer living PCs. If you want to force dead PCs back to life before transfer, then change the function from JumpPartyToArea to SinglePartyTransition in the script below.


This function automatically transfers everybody. You do not need to differentiate between players or followers, UNLESS you want to enable players to be in different areas at different times. Is this the case? Are you programming for a multi-player game where the players can be in different places at different times? I would not recommend this unless you are fully proficient with scripting as there a whole number of other issues to contend with if this were the case. Posted Image

Here is a *very* cut down version of the script I am using. I left in the bit of code that uses a visual effect, but you will need to define the effect used under the name used. i.e. Change "Teleport" to a visual effect you want to use. I.e. A "sef" file of your choice.

EDIT: Changed GetWaypointByTag to GetObjectByTag in script because I find it more reliable.

Lance.

void Dematerialise(object oPC);
void Dematerialise(object oPC)
{
 object oFM = GetFirstFactionMember(oPC, FALSE);
  
 while(oFM != OBJECT_INVALID)
 {
  DeleteLocalInt(oFM, "TELEPORTUSED");
  effect eTransport = EffectNWN2SpecialEffectFile("Teleport");
  DelayCommand(0.75, ApplyEffectToObject(DURATION_TYPE_INSTANT, eTransport, oFM)); 
 
 oFM = GetNextFactionMember(oPC, FALSE);
 } 
}
void main()
{
 object oPC = GetPCSpeaker();
    if(oPC == OBJECT_INVALID){oPC = GetEnteringObject();}
 if(oPC == OBJECT_INVALID){oPC = GetLastUsedBy();}
  
 string sTeleDest = GetLocalString(OBJECT_SELF,"TeleDest"); // Waypoint Tag of Destination
    object oTarget = GetObjectByTag(sTeleDest);
    // check if the target exists in the current module
    if(GetIsObjectValid(oTarget))
    {
        // TELEPORTED
    
  object oFM = GetFirstFactionMember(oPC, FALSE);
  
  while(oFM!= OBJECT_INVALID)
  {  
  effect eTransport = EffectNWN2SpecialEffectFile("Teleport");
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eTransport, oFM);
  oFM = GetNextFactionMember(oPC, FALSE);
  }
    
  DelayCommand(1.0, JumpPartyToArea(oPC, oTarget));
    }
}


Also, there is indeed an error in the original script that was posted by you as Kaldor pointed out: oFM = GetNextFactionMember(oFM); should be oFM = GetNextFactionMember(oPC);

Modifié par Lance Botelle, 11 avril 2011 - 12:41 .


#14
dickel

dickel
  • Members
  • 72 messages
Thanks again Lance. It took me a few days to get around to testing it but it works well.
I tried replacing the "Teleport" part to implosion (just to test, need a better teleport VFX)
implosion is VFX_FNF_IMPLOSION, but that doesnt seem to work.
Does anyone know whether i need to use VFX_INF ones and not VFX_FNF ones?
ta

#15
MasterChanger

MasterChanger
  • Members
  • 686 messages

dickel wrote...

Thanks again Lance. It took me a few days to get around to testing it but it works well.
I tried replacing the "Teleport" part to implosion (just to test, need a better teleport VFX)
implosion is VFX_FNF_IMPLOSION, but that doesnt seem to work.
Does anyone know whether i need to use VFX_INF ones and not VFX_FNF ones?
ta


That's if you're using EffectVisualEffect, which looks for an integer ID for the VFX (that's what those constants are, if you look in the script assist). EffectNWN2SpecialEffectFile, which is what Lance used, looks for a string filename for the SEF itself. Using the filename takes a tiny bit more work because there aren't constants pre-defined for you, but it's also far more flexible.

Either would work in this situation, but you have to use terms that match what your function is looking for.

#16
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

dickel wrote...

Thanks again Lance. It took me a few days to get around to testing it but it works well.
I tried replacing the "Teleport" part to implosion (just to test, need a better teleport VFX)
implosion is VFX_FNF_IMPLOSION, but that doesnt seem to work.
Does anyone know whether i need to use VFX_INF ones and not VFX_FNF ones?
ta


Hi,

Sorry for the late reply, I have been away from the boards. Thanks MC for answering this. Posted Image

As MC says, you need to use a SEF file, which you can look up in the effects folder. There are loads of them. I hope that makes sense.

Post here again if you don't know where to find the sef files info.

EDIT: I did a quick search in the effects folders and found two sef files that may be OK to use. (I have not tested to see what these look like myself, but they are called: fx_teleport.sef and fx_teleport_new.sef. Try both of these in place of the teleport I use in my script. Do not add the .sef part of the name though.)

i.e. Try either

EffectNWN2SpecialEffectFile("fx_teleport");

or

EffectNWN2SpecialEffectFile("fx_teleport_new");

Lance.

Modifié par Lance Botelle, 21 avril 2011 - 09:41 .


#17
Kaldor Silverwand

Kaldor Silverwand
  • Members
  • 1 585 messages
For my ring of teleportation (available on the vault) I use EffectNWN2SpecialEffectFile("fx_teleport") and it works nicely. I also played around with EffectVisualEffect(VFX_IMP_MAGBLUE).