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

Author Topic: [Resolved] Character Selection data  (Read 7361 times)

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
[Resolved] Character Selection data
« on: Jan 10, 11, 04:34:54 PM »

I'm trying to create a character selection system that can display all valid characters on the account with information about those characters.  This is similar to the HJ character selection so I attempted to use the HJ reference as a guide for doing this.  At first glance, I thought it to be simple enough. 

I created a child class of _PlayerConnection and put basically the same code in it that is in HJ_playerConnectionClassMethods.  This code loads all the character nodes for the account and adds associations for them.

Then, of course I had to create a child class of _Account in order to Factory my child PlayerConnection.  Then I added my _Account class to the ACCOUNT system node.

Then in my character Selection class methods script, I override _CSSInvokeGUI by implementing HE_CSSInvokeGUI and override _CSSMarshalCharacterData by implementing HE_CSSMarshalCharacterData.  Again, very similar to the HJ code.

The only other thing on the server that it looked like I needed to do anything with is the _PlayerAccount class.  In HJ reference, there is a HJplayer_account class and one method in that class is called to get the last character selected. This became a little confusing to me because instead of creating a child of _PlayerAccount, in HJ reference, the HJplayer_account is Glommed to the _PlayerAccount node instead.  Not sure I understand why it's done that way. So I just created a child of _PlayerAccount instead.

When I first implemented these classes, I think it kind of worked. I was getting the desired data to the client for the characters on the account. However, I could not select and send a character to the world.
 
I have tried a lot of different things now and in the process have experienced numerous problems in my attempts.  I have reverted back to the E_CharcterSelectionSystem and E_Account several times in order to get to a state where I could create a character and enter the world again.  Then back to my system to try some things again. Often I have been in a situation where I would get a list of characters, select one, try to enter the world and get an immediate disconnection. I assume there is some mismatch between account\player connection nodes that the characters were created with and the ones active at the time. In those cases, I could only delete the characters and start clean. These issues seem very difficult for me to debug because often it appears as if the errors are occuring in required system scripts and I can't mess around with those to do any debug. 

In summary, I think I can get back to a state where I get the data I need sent to the client character selection GUI, but with that combination of account and playerConnection, attempting to send the character to the world fails (and I haven't determined where/why this is failing yet). There is no error, just nothing happens.

Is this the wrong way to go about this? Is there an easier way?  Is there just additional things I need to implement on the server before this will work?

Also, I'm not sure if this is something that has started happening due what I have done up to this point or not...I don't recall if this was always happening or not...but whenever I enter the character selection area and the character selection system is initializing, I get a good number of messages in the console (Got event: CSSERROR02 but I don't know what to do now?).  This would indicate that a character is found that doesn't belong to the account. Almost seems as if deleting characters doesn't completely get rid of all references to them in the account or something.
« Last Edit: Nov 01, 12, 10:37:42 AM by HE-Cooper »
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

MP-LUNG

  • General Accounts
  • *
  • Posts: 2
    • View Profile
Re: Character Selection data
« Reply #1 on: Jan 12, 11, 01:25:50 PM »

I had a similar situation.  I wanted to load a Character with some of its basic info (appearance, name, race, area) on the character selection area.  Because of the Hero engine hierarchy, loading a character (root node) will consequently load everything associated to it (inventory, quests, etc...).  What I did was create a CharacterInfo root node that contains only the info that I needed.  When the player leave the game, this root node will copy the character appearance and some basic information.

When the player log back in, I load the CharacterInfos (multiple characters) to display the characters and info.  Once a character is selected, I unload all the CharacterInfos.  Remember, to handle the case of deleting characters.  I am not sure if this is the best way to do it, but it does the trick.

Lung
Logged

HE-JAY

  • HeroEngine
  • *****
  • Posts: 122
    • View Profile
Re: Character Selection data
« Reply #2 on: Jan 12, 11, 03:57:00 PM »

It seems like you have a good grasp of the steps involved in extending the $ACCOUNT system node to make use of custom player account and connection classes, but I'll summarize the steps and provide some common troubleshooting steps just to make sure we're on the same page.  I'll also provide some reference materials you can review on the wiki which - if you haven't already taken a look at - may help solidify an understanding of the way the login process and the $ACCOUNT node operate. Finally, I'll go over some of the trickier parts of getting your new custom character fully logged into the world by overriding the default CSS GUI.  As always, if this doesn't answer your question fully, feel free to respond with follow-ups.

First, I recommend that you avoid copying HJ code for your own systems, as it relies on workarounds that are unnecessary in more current versions of HeroEngine (glomming the account decorator onto a player's account node, for example). Instead, we'll build a custom CSS from the ground-up using the minimum effective number of steps. It seems most of this has given you no problems, but I'll review the process anyway for completeness.

In order to take advantage of custom player account and player connection classes, we need to perform the following steps (we're going to stop and test things after each major segment to ensure any problems you're having are 'not' due to the steps involved in that segment):
  • Create our custom Ex_PlayerAccount and Ex_PlayerConnection classes in the DOM, making sure they derive from the appropriate _PlayerAccount and _PlayerConnection clean engine classes (and making sure your server-side Ex_PlayerAccount class replicates to its client-side counterpart). Don't worry about adding any custom code to these classes yet.
  • Create a custom Ex_Account class to house our HE_FactoryAccountRootNode and HE_FactoryPlayerConnection overrides.
  • Glom this class onto the ACCOUNT prototype using the System Nodes Configuration GUI (http://wiki.heroengine.com/wiki/Customizing_HeroEngine#Using_the_HeroEngine_Control_Panel).

STOP and test this bare-bones setup:
  • Check: Do accounts logging in for the first time acquire the new Ex_PlayerAccount and Ex_PlayerConnection classes? ("\sn <ACCOUNT_ID>" in the CLI)
  • Check: Is the account replicated correctly to the client?
  • fyi: you can 'reset' an account by destroying it via $ACCOUNT._DestroyAccountRootNode(...), logging out and then logging back in.

Now that we know the basic setup of your game-specific account and connection classes works, we can move on to overriding the default CSS GUI (we're not going to worry about tacking on any additional data just yet; let's make sure the basic GUI functionality works before we start tweaking it).
  • Create your custom Ex_CharacterSelection claass both on the server and client, overriding the default GUI by implementing HE_CSSInvokeGUI on the client.
  • Ensure that your client GUI incorporates the following functionality:
    • Make sure it can process the character list from the server (by default, the CSS sends a list of characters as well as the most recently selected character when it calls the client-side Remote_CSSInvokeGUI function.
    • Make sure it calls the appropriate CSS methods when the user attempts to login (_CSSRequestSetLoadInCleanTestArea and _CSSRequestSelectCharacter), create a character (_CSSRequestCreateCharacter), and delete a character (_CSSConfirmDeleteCharacter)

STOP and test again.
  • Check: can we log in with a character?
  • Check: can we create a character?
  • Check: can we delete a character?

If successful, we should now have a working override for the CSS, our player account and player connection.  We can set aside this working code and move on to adding additional data to the character.

At this point, we can do one of two things:
  • If we need to visualize all of our characters at the same time during character selection (e.g. a line-up), we can do as Lung suggested and create a 'characters info' class (of which each account will have one instantiation) which will store the desired visualization data (name, level, outfit, etc) without requiring us to load all characters. This could be passed to the client with the initial set of character names on Remote_CSSInvoke_GUI.
  • If we only need to visualize a single character at a time, we can store the desired information on the character node, but only query it when we 'switch' our selected character (this would make an asynchronous call to the server saying 'load new character and give me the information I need to visualize it in character selection' - see the CSS method '_CSSSelectCharacter')

Both methods have their advantages and disadvantages, but both will require you to load the requisite root nodes, respond to this loading and pass along the desired information to the client.  The client will visualize the characters, offer its character selection GUI, and respond to events just like the default GUI would. Selecting a new character will call the CSS's Untrusted_CSSRequestSelectCharacter, deleting will call its paired untrusted function, etc. This should all work fairly seamlessly, as you're not modifying the core functionality provided by the CSS.

Potential problems you may be experiencing at this point when trying to send a character to the world:
  • Are you utilizing the stock CSS functionality for initiating travel to the starting area, or have you overridden it? The default CSS utilizes the $TRAVEL system node to spin up the desired area prior to sending a character to it (see $TRAVEL._ChangeAreaRequest).  If you're trying to manually send a player to an area that is not spun up, travel will fail.
  • Similarly, attempting to send a player to a new instance of an area will fail if you've reached the configured limit of simultaneously spun-up areas.
  • Are you positive the area and instance you're specifying when initiating travel is valid? Check the ID and the existence of the area in the world.

Regarding the instant disconnects:
  • If an account's root nodes are already loaded in the world and a second attempt is made to log in, the _playerConnection's '_KickPlayerConnection' method will be called on the new connection. Overriding this on your custom Ex_playerConnection class to offer exclusions may help you troubleshoot whether this is the case. Remember to unload all root nodes associated with the account before completing the logoff process. (Important: please maintain the exclusions for the 'HE-ADMIN' and 'CHRISTOPHER' accounts if you choose to override your base playerConnection _KickPlayerConnection method.)

Regarding the CSSERROR02 error:
  • To check whether characters are getting deleted or cleaned-up appropriately (and I suspect the reason they're not is due entirely to the copied HJ code which should now be gone), ensure that the account node does not associate itself via a CharacterAssociation with the character node.

Finally, a few resources for perusal in overriding the default behavior of CSS and player accounts:

Let me know if you want me to go over anything else in particular. But following these steps, you should be able to incrementally rule out where the problem is occurring.
« Last Edit: Jan 12, 11, 04:12:15 PM by HE-Jay »
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Character Selection data
« Reply #3 on: Jan 12, 11, 05:35:39 PM »

Wow, great information Jay.  Thanks for this.  Yes, I have found that HJ can be a reasonable reference for certain things but you really have to be careful regarding understanding what is applicable to the current HE architecture and what is not.  I'll be going through this and let you know if I have any futher questions but I suspect this will clear things up for me.  Thanks again.

Thanks for your suggestion as well Lung.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Character Selection data
« Reply #4 on: Jan 15, 11, 09:48:47 AM »

This has helped quite a bit in understanding the steps to take and the necessary classes.  I think the main problem with my original attempt was that I had not replicated my _PlayerAccount class to the client.  Also, I was unaware of how to reset the account by destroying the root node.

However, I am still having a problem in that accounts logging in for the first time do not acquire my _PlayerAccount class.  The player account class is always "E_playerAccount".  This tells me that the version of HE_UsePrototypeForAccountRootNode being called would be the one in "E_AccountClassMethods"?  But I have my account class Glommed to the ACCOUNT prototype, not E_Account so this shouldn't happen.  I do have HE_UsePrototypeForAccountRootNode implemented returning my account prototype which is based off my player account class.

At this point, I can create, delete, and log in characters but obviously something is still not right.

One slight correction to the above statement.  I can create and delete (upon completion of the character creation, the character does travel to the desired area).  When I attempt to login from the Character Selection system, the Character Creation area is loaded instead of sending the character to the game area.
« Last Edit: Jan 15, 11, 11:17:03 AM by rfarrel »
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

HE-CHRISTOPHER

  • HeroEngine
  • *****
  • Posts: 424
    • View Profile
Re: Character Selection data
« Reply #5 on: Jan 17, 11, 11:15:41 AM »

An oversight in the code supporting the system configuration UI resulted in instantiations of system nodes living in the world server (area 0 instance 0) not being updated until the next time a reboot occurred.  Consequently, the code running on the world server in your world was still the E_AccountClassMethods (since the instantiation was of classes _Account and E_Account still).  I've modified the instantiation by hand (-qn _account, -mnrc <id>, E_Account, -mnac <id>, <your>_Account).

Optionally, you could have used the external functions in a remote procedure call to the world server to instruct it to destroy the instantiation of the system node.

The issue only affects modification of system node instantiations in the world server (mostly $ACCOUNT and $WORLD) and has been fixed for the next release.
Logged
Christopher Larsen
CTO
HeroEngine

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Character Selection data
« Reply #6 on: Jan 17, 11, 04:59:51 PM »

Thanks Christopher.  I thought this issue might be related to that problem. I read the other thread that addressed this same issue but I wasn't sure how to go about resolving it.  All is good now.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Character Selection data
« Reply #7 on: Jan 23, 11, 10:20:38 AM »

Regarding the CSSERROR02 error:
  • To check whether characters are getting deleted or cleaned-up appropriately (and I suspect the reason they're not is due entirely to the copied HJ code which should now be gone), ensure that the account node does not associate itself via a CharacterAssociation with the character node.

It appears as if this error is occuring as a result of entering the CCS and leaving without completing the process of fully creating a character.  The character never gets named and never enters a game area.  The character id gets associated with the account but during character selection, an attempt is made to clean up (delete) characters that are incomplete or do not have a name.  But for some reason, it's failing the validation for checking that the account owns the character.  Not sure why this would happen since the "AccountCharacterAssociation" is made when the character is created upon entering the CCS.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Character Selection data
« Reply #8 on: Mar 01, 11, 11:36:42 AM »

I just wanted to add that I also ran into the problem HE-CHRISTOPHER mentioned about classes not glommed onto the world server system nodes.

I was adding my class onto the TRAVEL system node, and in particular, I was supplying a definition for HE_AreaSpinupTravel(), which ends up being called on the world server.  So, that is another system to go along with ACCOUNT and WORLD.

The CLI fix he mentioned worked perfectly.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

craigbe

  • Developers
  • *
  • Posts: 69
    • View Profile
Re: [Resolved] Character Selection data
« Reply #9 on: Feb 22, 13, 06:09:24 PM »

Ok this is super helpful, but I have a question because I'm a newbie..

HE-Jay said -

"Create our custom Ex_PlayerAccount and Ex_PlayerConnection classes in the DOM, making sure they derive from the appropriate _PlayerAccount and _PlayerConnection clean engine classes (and making sure your server-side Ex_PlayerAccount class replicates to its client-side counterpart). Don't worry about adding any custom code to these classes yet."

I don't understand how you make sure the server-side class replicates to the client side counterpart?  It sounds like something I should have run across while reading the wiki but for some reason I can't place it.

Thanks!

Craig
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: [Resolved] Character Selection data
« Reply #10 on: Feb 22, 13, 07:22:32 PM »

Wow, this topic is a blast from the past!

Craig, search the herowiki for replication, and in particular the section called "Replication Parameters".
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

craigbe

  • Developers
  • *
  • Posts: 69
    • View Profile
Re: [Resolved] Character Selection data
« Reply #11 on: Feb 22, 13, 07:29:48 PM »

lol.. this is a great topic!  I did find the answer thanks Scott, but of course now I have another question..

Can anyone post more information about how this would be implemented?  Maybe a bit more 'basic'?

"If we only need to visualize a single character at a time, we can store the desired information on the character node, but only query it when we 'switch' our selected character (this would make an asynchronous call to the server saying 'load new character and give me the information I need to visualize it in character selection' - see the CSS method '_CSSSelectCharacter')"

This is what I want to do and looking at the server scripts I see they're all unique methods so I'm not sure how you go about adding functionality?

Thanks!

Craig
Logged