HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.
Pages: [1] 2

Author Topic: [Resolved] Need help for rendering characters in character selection area  (Read 6371 times)

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile

Hello guys ,

I wanted to ask how i can render and load a player character while he/she is selecting one of the characters?
Could you please give me a guide how the best way for it is ?

I have changed E_playerAccount,E_playerCharacter , CSSGUI and its methods , everything is ready to loading a character when player selects a character.. Please give me a clue about how to do this

Note - I tried to learn from social reference but seems its just about hiding and showing a male or a female character, but i want it loads all items , weapons , body parts of a character when the player selected it .
« Last Edit: Feb 02, 13, 09:21:58 PM by feredfn »
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Need help for rendering characters in CSS
« Reply #1 on: Jan 19, 13, 06:50:51 PM »

The HJRef does that.  It is a little complex to do, but you can look through that code to see how they got the character to appear.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: Need help for rendering characters in CSS
« Reply #2 on: Jan 20, 13, 01:42:18 AM »

Thank you ,
Yeah , but somewhere i think in the wiki i have read they used different way of CCS and CSS than the way they recommend now for these systems , that's why i didn't check HJ ref for this goal , or rendering the character is same technique ?
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Need help for rendering characters in CSS
« Reply #3 on: Jan 20, 13, 06:57:39 AM »

To render characters in CSS, you should call "SendCharacterOutfitToPlayer" on the server.  On the client, this calls "_GotCharacterOutfit" in the character system class.  There is an HE override method "HE_GotCharacterOutfit" which you can implement in your CharacterSystem class.  You get an outfit handle passed in and using that handle you can call "CreateCharacterFromOutfit" to create the HBNode to display.

That is the main concept but of course the devil is in the details...such as, how do you generate the _characterAppearance data on the server to to create the outfit? 

In my case, I am saving appearance data for each character in an arbitrary root node.  The CSS system loads that node and can create the characterAppearance to send for each character. 
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: Need help for rendering characters in CSS
« Reply #4 on: Jan 20, 13, 07:12:41 AM »

Hmm..
Thank you , ... at least the concept can be my lost key :P

Can you please tell me how i can save such data to an arbitrary root node? i tried wiki and searching the forum but i just think im not much familiar with HSL yet  , i found CreateRootNode method but im not sure which  data i should pass as its parameters and when

 
« Last Edit: Jan 20, 13, 12:55:47 PM by feredfn »
Logged

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: [] Need help for rendering characters in CSS
« Reply #5 on: Jan 23, 13, 02:13:47 PM »

Hi again,

I tried to follow and understand the concept which TGSRofar explained,
First i want to say , when player creates its character , i force it to go back to CSS area instead of starting area, so player can again select which char he/she wants to get into the game with ( this works at least i think it works :P ) but about showing character Appearance i did this so far

i really dont know if i did it correctly but
when player request for character creation and the name is ok ( which  means character is going to be created ) i add a base hard associate from its characterAppearance data as target to account as parent .

then when it goes to CSS area , the account holds , the character appearance data via that Base_Hard_Association
i then used SendCharacterOutfitToPlayer ( in my characterSelectionSystemClassMethod (Server) )
then GotCharacterOutfit ( in E_CharacterSystemClassMethod (Client) )
then CreateCharacterFromOutfit ( in CharacterSelectionSystemClassMethod (Client) )

it creates a character but , the problem is , looks like created characters are exist  in any instance of the CSS Area :)

can you please tell me first is this good approach for this purpose? then , how i can remove them? , when i select them and press delete button , it says " Tried to delete something that`s not an instance " or something similar to it :P

* Update : uh uh uh , looks like i kinda messed it up, the spawned character will move to every areas , and every accounts will see them all... so perhaps its not a good approach
« Last Edit: Jan 23, 13, 02:56:55 PM by feredfn »
Logged

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: [] Need help for rendering characters in CSS
« Reply #6 on: Jan 24, 13, 10:23:57 AM »

Hi again ,

Looks like im not able to make it works , i guess i dont underestand some aspects of how such these things define in HeroEngine ...
 
so i m here again to ask for your helps :P
in this " https://community.heroengine.com/forums/index.php/topic,195.msg669.html#msg669 HE-Jay described good amount of details on what i want to achieve , and he pointed it on middle of hist post , what i want to do is , i need to visualize a single character at a time ,and only query it when we 'switch' our selected character.

 - He wrote "we can store the desired information on the character node" - Please tell me how ?
 - He wrote "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 - Please tell me how ?
 - He wrote " - see the CSS method '_CSSSelectCharacter'  " , I saw but well still feel i don't understand it
Logged

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile

Guys please ,any help would be amazing.

do i explain badly , or none is trying same approach ? or its as simple as that everyone who just wants this ,gets it working ?:P
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1160
  • Never stop learning
    • View Profile

We have not yet set up our selection area, though I have attempted a while back to get a new GUI for the area.
Logged
Lead scripter for EO, Repop helper.
HSL Video tutorials:
https://community.heroengine.com/forums/index.php/topic,1719.msg36858.html#msg3685

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile

I'll explain to you how I am handling this.

First I save/store the last known _characterAppearance information for each character in an account using an arbitrary root node.  Currently, I update this when the character leaves an area but I will probably eventually change this to update when something causes an appearance change.

To display a character on the client, the CSS GUI does a remote call to the server to request a visible character by character name.  The server loads the arbitrary root node and gets the appearance data for the character being requested. The server then calls SendCharacterOutfitToPlayer(account, appearance_data, other_data).  appearance_data is a _characterAppearance node based on the saved appearance data. other_data contains additional information I need on the client to know what character is being created (such as name).

On the client, in my override of the class _characterSystem, I implement HE_GotCharacterOutfit which is called as a result of the server call SendCharacterOutfitToPlayer.  I then call a method in the CSS GUI for receiving the character outfit info.  one of the additional data items I send from the server is the fqn for the character so AddCharacterSpec is called when the outfit is received.  CreateCharacterFromOutfit is also called at this point.

From here it might get a little tricky and it really depends on your specific implementation on how to proceed...but...you need to have a way to know when the characterspec is ready.  When it is ready, you can set your character HBNode (id returned from CreateCharacterFromOutfit) to render (char["Render"] = true), and position it where you want it in your character selection area.

Hopefully this helps you some.  This does not explain every little nuance about how to implement but does provide the overall sequence of events.

Oviously, one thing that you will need to work out is how to store the appearance data.  I chose to use an arbitrary root node based on what someone else said they were doing.  I only have that node loaded when I need to retrieve or save the data and release it when it isn't needed.

If you have any further questions I will do my best to help out some more.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: [] Need help for rendering characters in character selection area
« Reply #10 on: Jan 30, 13, 11:15:58 AM »

Thank you Thazager and again special thanks TGSRofar.

I wanted to say something about my self first .
I'm a developer programmer since  10 years ago ( as a pro 4 years ), i used to code with PHP , Javascript , C# .net , ASP .net both object oriented , classic and also MVC and MVVM design ... I always learn everything by R&D over the net and via books plus hard praticing  and working, i'm ( or even my friends who are helping me on our project are )  player of all good games , WOW first shipped to Catacalysm , Lineage 2 , Diablo 2-3 , Warcraft 2-3 , DungeonSiege from first version to last , Fallout  2-3 ... So i feel i'm with lot of good ideas and basic knowledges of RPG , MMO and video games...

But all these background did not help me yet to underestanding HSL , I really dont underesntad why im not getting familar with this smart language :P , it looks fine but i just cant make what i want with any approachs i try ...

Maybe if first i could somehow increase my HSL knowledge and skill , i could underestand such ur guides even better . I have read most of the wiki and forum's posts , even multiple times on some pages , But still cant be sure im on the right place...

Forexample i read 10 times the arbitrary root node wiki page , but still not sure what exaclty it is . i tried to save some data ( like _characterAppearance ) to account or even area , but then i wasnt able to load them ( i was not even sure if i was able to save it neither ).

My first problem is i cant save / store such these data anywhere or at least cant load if even they are saved... This is becuase im not sure where / when i should save and where / when / how i should load ..

I feel im getting old :P i used to learn scripting fast  about 3 to 7 years ago.

So can you give me a little deeper detail about how i can achieve that ?
the first time when i want to save _characterAppearance is exaclty when a player created a character, since i want instead of moving to starting area, move client back to CS Area (1) .

Maybe if i with ur helps can manage to achieve this, i could do other steps as what you have explained easier.
( Sorry for this long post  )
« Last Edit: Jan 30, 13, 11:25:40 AM by feredfn »
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: [] Need help for rendering characters in character selection area
« Reply #11 on: Jan 30, 13, 05:37:51 PM »

I understand what you are saying. I am an experienced programmer and struggled with trying to understand how to accomplish various things in HE when I first start (still struggle at times :) ) Hang in there and eventually it will all come together for you.

I'll do my best to explain how I'm handling the appearance data with an arbitrary root node.

I created a class to store character information that I want available for CSS, named CharInfo.  One field of that class is a _characterAppearance type field and I have some other fields for other information, such as character name, class, level, etc.

I created a field for my _playerAccount class named CharInfoRef of type NodeRef of Class CharInfo.  I suppose this could have (maybe should have) been an ID field but not sure that matters.

The CharInfoRef is basically the id of my arbitrary root node.

I created a class named CSSCharInfoLoader to manage loading the root node.  This class has some fields to help manage the process of loading and unloading the root node.

This class has methods to Load the data, Update the data, Delete a character from the data, and Unload the node.
It also implements the callbacks for the node being loaded and unloaded.

So when I want to load the data, I simply create an instance of my CSSCharInfoLoader class, call the Load method and pass in the account.CharInfoRef as the ID of the node to load (assuming account.CharInfoRef has at some point been assigned and is not 0).  I load this in HE_CSSEnteredArea.

When the node is loaded my CSSCharInfoLoader instance destroys itself because it has completed what it was supposed to do.

As long as CSS is active, I have the node loaded and my account.CharInfoRef is valid and contains the data for all the characters.

When HE_CSSCharacterSelected is called, I create an instance of CSSCharInfoLoader and call the unload because I no longer need the data.  When it is unloaded, the CSSCharInfoLoader deletes itself.

When I want to access the data for characters, I cast the account.CharInfoRef to an instance of another class I created called CSSCharInfoData which has one field named CSSCharInfo.  This field is a lookuplist indexed by string of class CharInfo.  So this is how the data is actually stored.

Okay, so how and when does the root node get created?

This happens in character creation in HE_CCSSendCharacterToStartingArea. This will happen if this is the first character created for the account (in other words account.CharInfoRef = 0). 

When it is created, I create a persisted node of type "CSSCharInfoData".
I define a variable of class CharInfo.
I set all the fields in CharInfo for the current character.
I add the CharInfo to the CSSCharInfo lookuplist in CSSCharInfoData.
I create the root node (passing my CSSCharInfoData node).
Finally, I set account.CharInfoRef equal to my CSSCharInfoNode.

I'm not sure this is the best way to go about this.  When I did all this I was still learning and now that you caused me to go back and review all this I suspect I might do this a little differently if I was just implementing it now but it works fine so I'll probably leave it alone :)

See if this helps you any and I will try to clear up anything that might be a little confusing in my attempt to explain this.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: [] Need help for rendering characters in character selection area
« Reply #12 on: Jan 31, 13, 06:39:50 AM »

 :D Uh Cheers mate.

i was trying this guide , this is my "CCSSendCharacterToStartingArea" Method , so i hope i saved some data of a character when character is created by the player ( for now i wasnt try to save character appearence yet)

Code: [Select]
method HE_CCSSendCharacterToStartingArea( account as NodeRef of Class _PlayerAccount ) as Boolean
  charInfo as Class B_CSS_CharacterInfo
  charInfo.B_CSS_CharacterInfo_LastArea = "Village of Applebriar"
  charInfo.B_CSS_CharacterInfo_Name = account._cssLastSelected
 
  where account is kindof Fered_PlayerAccount
    if(account.B_CSS_Account_CharactersInfoRef == 0)
      println("Account Characters info ref is null,So we create a peristed node for it from class B_CSS_CharactersInfo")
      charactersData as NodeRef of Class B_CSS_CharactersInfo = CreatePersistedNodeFromClass("B_CSS_CharactersInfo")
      charactersData.B_CSS_CharactersInfoList[account._cssLastSelected] = charInfo 
      errorReason as String
      if CreateRootNode( charactersData, account, errorReason )
        println("Root Node created")
        account.B_CSS_Account_CharactersInfoRef = charactersData
      else
        println(errorReason)
      .
    else
      charactersData as NodeRef of Class B_CSS_CharactersInfo = account.B_CSS_Account_CharactersInfoRef
      charactersData.B_CSS_CharactersInfoList[account._cssLastSelected] = charInfo
    .
  .
  $Travel._ChangeAreaRequest( account, me.HE_GetStartingArea(), "1" )
  return true
.

it prints , Root Node Created ,  so did i follow ur guide correclty up to saving the data for new created character?

Thanx in advance
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: [] Need help for rendering characters in character selection area
« Reply #13 on: Jan 31, 13, 04:06:34 PM »

That looks about right to me so far :)
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

feredfn

  • General Accounts
  • *
  • Posts: 154
    • View Profile
Re: [] Need help for rendering characters in character selection area
« Reply #14 on: Jan 31, 13, 04:30:30 PM »

Good :)

Ok , i did this for other steps , but looks like something is wrong , first i overrided  "CSSEnteredArea" as the below :
Code: [Select]
method HE_CSSEnteredArea( account as NodeRef of Class _PlayerAccount ) as Boolean
  println("Entered CSS ARea")
  load as NodeRef of Class  B_CSS_DataLoader = createNodeFromClass("B_CSS_DataLoader")
  load.loadRootNode(account)
  return true
.

Which  B_CSS_DataLoader is a class with these codes
Code: [Select]
method loadRootNode(account as NodeRef of Class fered_PlayerAccount)
  println("loading")
  if IsRootNodeLoaded(account)
    me.loadData(account.B_CSS_Account_CharactersInfoRef)
  else
    RequestRootNodeLoad(account, me)
  .
.
method _RootNodeLoadedNotification( rootID as ID )
  account as NodeRef of Class fered_playerAccount = rootID
  me.loadData(account.B_CSS_Account_CharactersInfoRef)
.
method _RootNodeLoadFailedNotification( rootID as ID, areaID as ID, areaInstance as ID, failureReason as String )
  println("failed to lead : " + failureReason)
.

method loadData( charactersData as NodeRef of Class B_CSS_CharactersInfo )
  println("loaded")
  println("Charname is : " + charactersData.B_CSS_CharactersInfoList["fere"].B_CSS_CharacterInfo_Name)
  println("LastArea is : " + charactersData.B_CSS_CharactersInfoList["fere"].B_CSS_CharacterInfo_LastArea)
.

This is the log and error

Code: [Select]
[hsl_debug] 1,3: SCRIPT[B_CSS_DataLoaderClassMethods]: loading
[hsl_debug] 1,3: SCRIPT[B_CSS_DataLoaderClassMethods]: loaded
[color=red][hsl_error] 1,3: [Character Selection] SCRIPT ERROR: GOM::getVariableReferenceFromNode (10773): requested node ID (9223372057238021799) not found[/color]
01/31/2013 22:29:14 UTC
Call trace:
  Script B_CSS_DataLoaderClassMethods line 19 me[id=9223372057630021551 class=B_CSS_DataLoader]
  Script B_CSS_DataLoaderClassMethods line 4 me[9223372057630021551]
  Script Fered_CharacterSelectionSystemClassMethods line 59 me[id=9223372057630021531 class=_characterSelection,Fered_CharacterSelectionSystem]
  Script _CharacterSelectionClassMethods line 45 me[9223372057630021531]
  Script _AccountClassMethods line 498 me[9223372057630021550]
  Script _AccountClassMethods line 458 me[9223372057630021550]
starting method/function _CONNECTIONENTEREDAREA
starting me[id=9223372057630021550 class=_Account,Fered_Account]
Logged
Pages: [1] 2