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

Author Topic: Accessing player characters across Areas / Instances in HSL  (Read 2857 times)

Malumm

  • General Accounts
  • *
  • Posts: 35
    • View Profile
    • SynapticSwitch

Hi everyone.

If two players are in the same area and instance as each other, I can do the following to access one from the other in script :

  targetAccount as NodeRef of Class _PlayerAccount = idTargetPC
  targetChar as NodeRef of Class E_playerCharacter = targetAccount.GetMyChar()


How do I create this same functionality across areas / instances?
Logged

Irushian

  • General Accounts
  • *
  • Posts: 44
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #1 on: Aug 17, 15, 02:33:30 PM »

What is it that you're trying to accomplish with this?

function WhereIsPlayer(character as id, area references id, instance references id) as boolean
Returns false if they're not online, populates the variables passed (as they're references) with the location.

function FindPlayerByName(findName as string) as id
Gets the root node id of a player by their current character name. Only sees the players online at the area server level, or all players at the world server level.

Your question is a little bit on the vague side, so it's been a bit hard to actually answer to what you're wanting.
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #2 on: Aug 17, 15, 02:41:12 PM »

This is not simple. You'd probably have to setup a system area which is registered for player location. This system area would act as a mediator between the two players. But it will be better if you describe what are you trying to accomplish.
Logged

Malumm

  • General Accounts
  • *
  • Posts: 35
    • View Profile
    • SynapticSwitch
Re: Accessing player characters across Areas / Instances in HSL
« Reply #3 on: Aug 17, 15, 02:49:31 PM »

I'm working on the ability for two player's to travel to a new instance of a different area. Like sending two players from any area to an instanced dungeon.

I cannot simply call _ChangeAreaRequest( ..., ..., "new") on both players because they will end up in different instances. I'm thinking of pulling one over after the first player is loaded in the new area.
Logged

Irushian

  • General Accounts
  • *
  • Posts: 44
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #4 on: Aug 17, 15, 02:57:15 PM »

Ah, because the "areas" are different servers, they wouldn't have the same information stored on them, so you'd not be able to get a pointer (NodeRef) to the other from there.

Have a look at the $TRAVEL system node, you could also extend that system node for any extra functionality that you would like.
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #5 on: Aug 17, 15, 03:13:13 PM »

There could be million better ways to do that than this, but here is how i would do it:

Code: [Select]
1. create a new area

2. add it to keepup list in function KeepUpList()
  KeepAreaUp(<insert area number>, 2)

3. in HE_PostOnAreaLoad register for player events
  if (area.AreaID == <insert area number>)
    println ("Registered SystemAreaPlayerLocation for player events.")
    $WORLD._RegisterSystemArea( PLAYER )
  .


4. create new class, for example SystemAreaPlayerLocation
in SystemAreaPlayerLocationClassMethods add
remote function PullPlayer2MeRequest (account, area, instance)
  area as Class _AreaInstance = $WORLD._WhereIsPlayer(account)
  if (area._currentArea <> 0)
    call area area._currentArea instance area._currentAreaInstance E_PlayerCharacterClassMethods:PullPlayer2MeForward(account, area, instance) failure PullPlayer2MeForwardFailure
  .

.

5. update E_PlayerCharacterClassMethods

remote function PullPlayer2MeForward (account, area, instance)
  //handle _ChangeAreaRequest here
.

6. now all you need is to send request to system area which will be forwarded to distant player
call area <insert area number> instance <insert instance number, instance 2>  SystemAreaPlayerLocationClassMethods:PullPlayer2MeRequest(account, area, instance) failure PullPlayer2MeRequestFailure
Logged

Malumm

  • General Accounts
  • *
  • Posts: 35
    • View Profile
    • SynapticSwitch
Re: Accessing player characters across Areas / Instances in HSL
« Reply #6 on: Aug 17, 15, 04:18:36 PM »

Thank you very much.

I took both of your advice. I integrated the remote call into the $TRAVEL system and it works now!

Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Accessing player characters across Areas / Instances in HSL
« Reply #7 on: Aug 18, 15, 12:34:12 AM »

Another way to do it, which can also be used for different areas and/or diff instances. Just need to send the name. Then use the _ChangeAreaRequest() with the info of other player.

In server side script:

Code: [Select]
// get player info from server
untrusted remote method getTargetPlayerInfo(targName as String)
  acct as NodeRef of Class E_playerAccount = SYSTEM.REMOTE.client   // player asking

  TargID as ID = $WORLD._FindPlayerByName(targName)
  location as Class _AreaInstance = $WORLD._WhereIsPlayer(TargID)
  area as ID = location._currentArea
  instance as ID = location._currentAreaInstance

  call area area instance instance getTargetInfo(TargID, acct)
.

// target player area
remote function getTargetInfo(TargID as ID, account as ID)
  TargData as String = getPlayerInfo(TargID)
  call client account TMP_TargInfoClassMethods:getPlayerInfo(TargData)    // info for player asking
.

function getPlayerInfo(accountID as ID) as String
  acct as NodeRef of Class E_playerAccount = accountID
  char as NodeRef of Class E_playerCharacter = acct.GetMyChar()

  area as ID = char._currentArea
  instance as ID = char._currentAreaInstance

  data as String = area+","+instance     // combine into 1 string
.
« Last Edit: Aug 18, 15, 12:35:53 AM by Thazager »
Logged

AWW_boss

  • General Accounts
  • *
  • Posts: 846
  • gdfgd
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #8 on: Aug 18, 15, 01:22:51 AM »


Hmm, does this line work even if the area is not registered for player events? 

  location as Class _AreaInstance = $WORLD._WhereIsPlayer(TargID)

I was led to belive by wiki that you need to register area for player events, but perhaps i misinterpreted it:
"Registering a system area enables a variety of information on the $WORLD system node that would otherwise only be available by making remote calls to the world server"
http://hewiki.heroengine.com/wiki/System_area
Logged

Irushian

  • General Accounts
  • *
  • Posts: 44
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #9 on: Aug 18, 15, 07:57:18 AM »

He's only wanting to move characters together to a new area and instance, so he doesn't really need a system area for that. All he needs is the area and instance ID to move them to (easy to do), and then to get both characters to move via $TRAVEL (code already there to do it). A system area would be overkill for such a simple task.
Logged

ToY-Krun

  • General Accounts
  • *
  • Posts: 677
  • Support Volunteer
    • View Profile
Re: Accessing player characters across Areas / Instances in HSL
« Reply #10 on: Aug 18, 15, 05:26:18 PM »

Specify what instance you want them to go to  such as :

$Travel._MakeChangeAreaRequest(AccountID, AreaID , InstanceNumber)

Both (or any) will go to that area/instance, if it is not spun up, it will be spun up prior to them traveling.
« Last Edit: Aug 18, 15, 05:29:01 PM by ToY-Krun »
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Accessing player characters across Areas / Instances in HSL
« Reply #11 on: Aug 22, 15, 02:35:49 AM »

He should build a system area though to manage the movement. Cause you don't want to willy nilly send them to an instance.

So can't just shove a person into an instance and call it done. You also want a system in place that manages the instances better than just waiting for people to not be in it and it spin down.

For getting things roughed in this is fine, but for a game launch you will want to build a system area that has management capabilities, so you can keep things refined on who is where and why.

So it's build it now or build it later but you should build it.

Things the system area should be doing is checking for empty spun up instances to put the group into, (unless it needs a full reset) for a dungeon that has special triggered events or such. But even then you want the system area looking for empty instances to spin down sooner than their default time outs. Also if it's not needed to be reset cause it's just a dungeon run like in most games, then you can shove them in an already spun up instance and save a ton of overhead and resources.

It would also keep eye on single person instances and make sure they don't get out of hand. Nothing is wrong with it happening but you best make a decision on if it should happen. Meaning, it's a dungeon run but there is one guy sitting in an instance and hasn't moved for 2 hours. I should probably move him outside the dungeon instance. You can't just log him out there cause it's not a guarantee he will be coming back to that instance. That also brings up the other aspect. Player disconnects while in a dungeon instance. Need to gracefully handle this aspect as well. Now you could manage this in login scripts that always put a loading player in limbo while it tests to validate the players "loading" area is still valid or if it's not going to be valid and where to put them if it's not a valid aspect. Problem is it could very well be valid but only way to really tell properly is to have a system area managing the dungeon instances. So think of it this way, i'm in dungeon instance 12 with my party. I disconnect, when i get done yelling at comcast, I hop back in and go to load well game would like to send me to dungeon instance 12 but should it? Is it still up, is it up but i've given that instance to a different set of people cause i was the tank and my disconnect wiped the group so they left till I could get back online? So I can't log back into dungeon instance 12 but I can't also just randomly log back into any instance either, so I need the game or some system to say well you need to go here now instead. OR it could say hey your dungeonInstance ID the system area been tracking for you has you just fine going back to join up with your party. Go have fun as if you never disconnected.

The system area also will be a great resource tool for your developers. You can build logging tools into the system area, so your developers can hit the world open a GUI and the system area can spit a screen that has all the dungeon instances, how many people are in each, for how long they have been there, and a wide assortment of other need to know information. That just using a script to slam to people together won't do for you well. A lot of times people leave off or forget the notion you need management systems for your systems. Meaning you need a system that can look across all the areas and see what the heck is going on. Or you won't be able to tweak your gameplay and user experience. Often times you don't think about it cause we never see it as players. The system area for the dungeon management will become a key tool you will want to build. Things like how many times a day is a dungeon ran, how many monsters / spawns per dungeon run on average is happening. You need to know those things, or your game will regretably be a nightmare to manage once you get to beta why? well need to know that in dungeon XY people head to it and sit at the skeleton camp for hours on end. Well why? oh wait cause the loot table versus challenge is super high so they are just farming it for reasons you didn't mean. Or no one ever plays this dungeon why? We thought it was going to be great but it sits empty what design element, quest element, or other user reasons are people not heading to it.

Lastly as mentioned you really want to make sure the instance is safe for the player to be in. Cause resources are precious and you need to manage them, more than just sucking up more. Think about a million players, all wanting to hit a dungeon and it's instances, sure you will have to hold / account for it, but you need some mechanic other than an area just randomly spinning up another instance and tossing people in it. Doing that and within an hour or so you would end up with a jumbled mess of wasted resources.

So for starting out getting feet wet go the travel and brute force method. Just note for anything permanent you will want to build a system area that has a complex system within it, or you will just be asking for trouble in the end.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]