Author Topic: simple portal help please.  (Read 408 times)

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
simple portal help please.
« on: April 01, 2011, 09:04:28 pm »


                I just want it so that if your already at the waypoint it does nothing.

void main(){
object oPC = GetPCSpeaker();object oTarget;oTarget = oPC;int nInt;nInt = GetObjectType(oTarget);if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_TORNADO), oTarget);else ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_TORNADO), GetLocation(oTarget));location lTarget;oTarget = GetWaypointByTag("wtown01");lTarget = GetLocation(oTarget);
if (GetAreaFromLocation(lTarget)==OBJECT_INVALID) return;oTarget=GetFirstFactionMember(oPC, FALSE);while (GetIsObjectValid(oTarget))   {
   AssignCommand(oTarget, ClearAllActions());   AssignCommand(oTarget, ActionWait(1.0f));   AssignCommand(oTarget, ActionJumpToLocation(lTarget));   oTarget=GetNextFactionMember(oPC, FALSE);   }
}

               
               

               


                     Modifié par Knight_Shield, 01 avril 2011 - 08:05 .
                     
                  


            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
simple portal help please.
« Reply #1 on: April 02, 2011, 12:35:43 am »


               First,


object oPC = GetPCSpeaker();
object oTarget = oPC;

means the oTarget is ALWAYS going to be the PC, which means ...


if (nInt != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_TORNADO), oTarget);

Will ALWAYS be false and hence fire the line after the if, never firing the else. I'm really not sure what you were trying to do there, so I'll just point this out and hope that that illuminates something for you.


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

...
I'm also uncertain what you are doing with this bit above here, if it found the object, the location will return a valid area.

... I might suggest you try the following ...

Get the waypoint you desire, and check the area it is in and the area the PC is in, if they are not the same, they are in different areas and should be treated as you desire in either case.

... If they are in the same area, check the distance between them, if close 'enough' treat as desired.





...

The following code is off the top of my head, not tested, but should give you a framework to draw from. Message me if you have questions.

Be well. Game on.
GM_ODA


void main()
{
object oPC = GetPCSpeaker();
object oTarget = GetWaypointByTag("wtown01");
if(GetArea(oTarget)==GetArea(oPC))
{
// place code here to handle oTarget and oPC being in same area...
}
else
{
// place code here to handle oTarget and oPC being in different areas...
}
}


               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
simple portal help please.
« Reply #2 on: April 02, 2011, 02:24:59 am »


               This might help as well.
Click Here

If your familiar with variables here is a portal system we use so all you need is one placeable which you can change its looks with ease.

////////////////////////////////////////////////
//  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));
            }
        }
}
 
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
simple portal help please.
« Reply #3 on: April 02, 2011, 03:48:24 am »


               thanks guys..I actually use lilac's to replace the script I posted because it was jumping e... ve.. ry... one in the party regardless of where they were.I will look into yours TSMDude.I have a really cool land gate where you dial codes but this new one you actually have to go to the location before you can use it.Keep from having to give players another rule.This way they have to walk and look at the scenery.
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
simple portal help please.
« Reply #4 on: April 02, 2011, 04:24:39 pm »


               sorry to hijack the thread but it is the right topic
how would i get the players party leader?
want to do a simple script for a portal that sends the player to their party leader when its used.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
simple portal help please.
« Reply #5 on: April 02, 2011, 06:06:59 pm »


               GetFactionLeader
               
               

               
            

Legacy_Ryuhi2000

  • Full Member
  • ***
  • Posts: 159
  • Karma: +0/-0
simple portal help please.
« Reply #6 on: April 02, 2011, 07:16:12 pm »


               thanks
               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
simple portal help please.
« Reply #7 on: April 03, 2011, 10:28:58 pm »


               Just tested you script  ehye_khandee  works great .
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
simple portal help please.
« Reply #8 on: April 03, 2011, 10:34:28 pm »


               Bless you friend. Best wishes to you on your module. THANKS for the status update. Glad to know it helped.

Be well. Game on.
GM_ODA