HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Change Area  (Read 994 times)

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
[Resolved] Change Area
« on: Feb 15, 13, 12:19:07 PM »

Hey all,
I have a trigger that sends the character to another area
which works fine.
I set up an arrival path in the area the character is going to
and they arrive there fine.

Then I want to exit the new area and head back to the original area,
which also has an arrival path.
But I want the char to end up by the trigger not the arrival path.

Is there a way to ChangeAreaRequest and specify a path other than the arrival path?
Right now I use for the trigger script
Code: [Select]
function Travel_To_Test3_TriggerEnter( traveler as NodeRef )
  println( "Entered trigger..." )
  where traveler is kindof E_playerCharacter
    account as NodeRef of Class E_playerAccount = traveler.GetMyAccount()
    $Travel._ChangeAreaRequest( account, 9223372060865132781, "3" )//Test3 Area
  .
.
« Last Edit: Feb 19, 13, 09:00:37 AM by HE-Cooper »
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Change Area
« Reply #1 on: Feb 15, 13, 04:04:36 PM »

Take a look at the code of the function DoPositioning() in E_AccountClassMethods.  Towards the bottom is where the path is chosen and it is hard-coded to choose the "Arrival" path.  You can change the algorithm of that function to allow arriving at different paths based on game-specific criteria.

For our game we have changed that functionality quite a bit to control the use of multiple paths.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

cloudnine

  • General Accounts
  • *
  • Posts: 80
    • View Profile
    • Youtube
Re: Change Area
« Reply #2 on: Feb 16, 13, 01:21:18 AM »

Right on, I got it to work.
I added two vector3 fields to the _playeraccount class
and before doing the changeAreaRequest set them to the exit path position and rotation.
Also set the arrivalpath on _playeraccount field to the exit path id
Then in DoPositioning() right before it teleports the char
check if the arrivalpath = 0
If it isn't 0, I use the two vector3 fields for the teleport.
Then in HE_PostCharacterActivated in E_Account,
set the arrivalpath back to 0.
New Triggerscript
Code: [Select]
function Travel_To_Test3_TriggerEnter( traveler as NodeRef )
  println( "Entered trigger..." )
  where traveler is kindof E_playerCharacter
    account as NodeRef of Class E_playerAccount = traveler.GetMyAccount()
    traveler.ArrivalPath = 9223372066297132959 //Test3 area exit cave
    traveler.SoloExitPos = (-0.3257331,0.08600255,-4.529782)
    traveler.SoloExitRot = (0,-107.6402,0)
    $Travel._ChangeAreaRequest( account, 9223372060865132781, "3" )//Test3 Area
  .
.
And the last part of DoPositioning()
Code: [Select]
default
          label notarget
          //added solo arrival
          if pc.ArrivalPath = 0
             path as NodeRef of Class PathNode = PathUtils:GetPathByName( "Arrival" )
         
            if path != None
              pos = GetPositionOnPath( path )
              Debug( "LoginProcess", name + " is moving between areas and I found an Arrival path (" + path + ").  Teleporting to " + pos + "." )
              account._TeleportPlayer( pos, rot )
            else
              Debug ( "LoginProcess", "No Arrival path found or target for " + name + " in area '" + GetAreaName( GetAreaNumber() ) + "', so positioning at origin." )
              account._TeleportPlayer( pos, rot )
            .
          else
            account._TeleportPlayer( pc.SoloExitPos, pc.SoloExitRot)//rot )
Logged