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

Author Topic: Working on Skill based systems  (Read 3039 times)

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Working on Skill based systems
« on: Nov 06, 14, 01:30:13 PM »

I am working on making skill based systems similar to Ultima Online, but I can't quite get it to work due to my poor programming skills. What I have so far:

I created a class for crafting skills S_CraftingSkills
I created and added two test fields S_BlacksmithingSkill and S_CookingSkill as floats

I created basic script S_CraftingSkillsClassMethods
Code: [Select]
method AdjustBlacksmithingSkill()
  me.S_BlacksmithingSkill = (me.S_BlacksmithingSkill + .1)
  println("Blacksmithing up by one")
.

method AdjustCookingSkill()
  me.S_CookingSkill = (me.S_CookingSkill + .1)
  println("Cooking up by one")
.

Now for testing I am trying to figure out how to call the Adjust methods from a gui script class methods but I am not sure how to do that. I have tried a few things, using the https://community.heroengine.com/forums/index.php/topic,1895.msg10218.html#msg10218 Simple Mana System tutorial as a guideline but it is too complex for what I am trying to do.  I know in itself it's pretty simple but as I said, my programming is not very good.

Any help or suggestions in the right direction are greatly appreciated!

edit: I did parent my E_playerCharacter class to this class
« Last Edit: Nov 06, 14, 01:36:50 PM by Amarak »
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Working on Skill based systems
« Reply #1 on: Nov 06, 14, 06:46:42 PM »

I suggest going to watch the spec tutorial videos. They cover the core bases / start of making a skill system in HE. Should be able to derive a good base from watching the videos, and then just make improvements to build out to the full system.

You don't want to try and build classes for each skill cause that won't work well. Challenges come into play with accessing the data, values of the fields in a non-cached means.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Working on Skill based systems
« Reply #2 on: Nov 06, 14, 07:30:40 PM »

Yes, the specs make it easier for a non programmer to add things into the game. Though you will need a programmer to set the specs up. The mana system is a little different from using a skill.

If by chance you made the skill system yourself, 1st start with a key press to activate the skill. Then when the skill is being performed, you could also call the method to increase the skill value as the player has attempted to use it. You could also call the method based on whether or not the skill was successful.
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Working on Skill based systems
« Reply #3 on: Nov 06, 14, 08:52:42 PM »

and the spec system makes things about 90 times easier to code, and about 100 times faster, cause you configure the specs for each unique type, aka aoe, bolt, point blank aoe, etc then you create all the other skills by just filling in simple to key fields. Versus trying to build classes for hundreds of skills.
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Working on Skill based systems
« Reply #4 on: Nov 06, 14, 11:30:56 PM »

Thanks so far...I did set up a spec system for spells, it isn't exactly the same thing I am trying to accomplish here. This is for crafting skills, and I know I could use key value pairs for this with simple skill name and skill value, but again I can't program that in HSL.

I am trying to learn programming here using small steps so I figured if I could start with something as simple as changing the value in a field that is on the player character it would be a start. So, I guess in the most basic idea, I was wondering how to use a button press to activate the method to increase the skill.

It seems to me it would be along the lines of a gui class method, the button press would grab a reference of the player character (or the crafting class that the player character is parented to), and activate the method that increases the skill's value.  I just don't know exactly how to do that in HSL.



« Last Edit: Nov 07, 14, 02:42:25 AM by Amarak »
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Working on Skill based systems
« Reply #5 on: Nov 09, 14, 12:28:18 PM »

I'm still trying to find a code example of how to call a method on E_playerCharacter (or any other node for that matter) by clicking a GUI button. Can anyone please point me in the right direction?
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Working on Skill based systems
« Reply #6 on: Nov 09, 14, 02:17:33 PM »

to call a method http://hewiki.heroengine.com/wiki/Methods . They are similar to functions but a little different, they need a node set up.

A GUI button is a little different, it uses a script with a method setup to receive mouse interaction. Each GUI that can respond to a mouse click or pass over. Each script will have its own mouse method in it.

Code: [Select]
// in some script that has a gui of the same name
method onMouseClick(args references Class GUIMouseEvent)
  target as NodeRef of Class GUIControl = args.source

  if args.leftButton      // checking for left mouse click
    when target.name   // checking which button we clicked on
      is "myButton"       // did we click this 1?
         doThisFunction()
      .
    .
  .
.

function doThisFunction()
  println("we have called this function")
.
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Working on Skill based systems
« Reply #7 on: Nov 09, 14, 06:18:03 PM »

Thanks Thazager, I got that to work with no problem! So for buttons is it best to make a button and its script then add the button to a GUI panel or window in the GUI Editor?

I've been working on the functions wiki, but still can't quite find the right way to access a field on the E_playerCharacter. With the example you gave me, it asks for an argument in the doThisFunction call on the button click after I modify the actual function. It seems to want a reference or return but I've tried many things, from the player node to the float (which is the field I am trying to access) and I just can't get the HSL referencing figured out.

 
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Working on Skill based systems
« Reply #8 on: Nov 09, 14, 06:49:21 PM »

Thanks Thazager, I got that to work with no problem! So for buttons is it best to make a button and its script then add the button to a GUI panel or window in the GUI Editor?

If you add a button via the GUI editor, or HSL you can use the method "_onButtonMouseClick" to handle the click of a button

Example:
Code: [Select]
method _onButtonMouseClick(button as NodeRef of Class _GUIButton, args references Class GUIMouseEvent)
  when tolower(button.name)
    is "mybutton"
      println("Clicked on My Button")
    .
    is "close"
      println("Clicked on The close Button")
    .
  .
.
I've been working on the functions wiki, but still can't quite find the right way to access a field on the E_playerCharacter. With the example you gave me, it asks for an argument in the doThisFunction call on the button click after I modify the actual function. It seems to want a reference or return but I've tried many things, from the player node to the float (which is the field I am trying to access) and I just can't get the HSL referencing figured out.
Building on the previous example:

Code: [Select]
method _onButtonMouseClick(button as NodeRef of Class _GUIButton, args references Class GUIMouseEvent)
  when tolower(button.name)
    is "print_stats"
      me.PrintPlayerData()
    .
    is "close"
      println("Clicked on The close Button")
    .
  .
.

method PrintPlayerData()
  account as NodeRef of Class _PlayerAccount  = GetAccountID()
  playerChar as NodeRef of Class E_PlayerCharacter = account.GetMyCharacter()
  println("Player HP: " + playerChar.E_hitPoints)
  println("Player Level: " + playerChar.E_level)
  println("Player Wealth: " + playerChar.E_wealth)

.
« Last Edit: Nov 09, 14, 06:56:32 PM by Jrome90 »
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Working on Skill based systems
« Reply #9 on: Nov 09, 14, 07:10:42 PM »

Thanks Jrome! I am almost there :)
The last thing I was trying to figure out in this exercise is how to call a function in another class. I have a field  on E_playerCharacter, we can use Wealth as an example, and a simple method to add 5 to wealth.
How would the button access the method to increase wealth?

Code: [Select]
method AddWealth()
me.wealth = (me.wealth + 5)
.

I know these are basic questions, and I apologize, but this is how I learn, and while I know I will have to hire a programmer in the future, I'm just trying to do enough to get a demo made so I have something to show prospective team members. I don't want to be one of those "Looking for programmer, I have this idea..."

I want to be one of those "Here's a basic demo of my game, I need a programmer to flesh it out" kind of guys.
Logged

Thazager

  • General Accounts
  • *
  • Posts: 1155
  • Never stop learning
    • View Profile
    • Heroes and Villains MMORPG
Re: Working on Skill based systems
« Reply #10 on: Nov 09, 14, 08:33:07 PM »

to call a function in another class, you need to first set the node for that class

example:
  account as NodeRef of Class _PlayerAccount  = GetAccountID()                            // this gets the account for the player
  playerChar as NodeRef of Class E_PlayerCharacter = account.GetMyCharacter()    // this gets the current character for that player

then to access a field n class E_PlayerCharacter similar to above, use a period between noderef and the field

playerChar.wealth = value

to call the method AddWealth() you can call it in that same script using me.AddWealth() or from another script setting up a noderef of the class of that script, then the function name.

example:
  playerChar as noderef of E_PlayerCharacter      // this would set up a noderef if the method was in E_PlayerCharacterClassMethods
  playerChar.AddWealth()


Another idea would be to pass a value in, so that with the call you could also set the value
  playerChar.AddWealth(5)

using

method AddWealth(value as Integer)
  me.wealth += value
.

« Last Edit: Nov 09, 14, 08:34:51 PM by Thazager »
Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Working on Skill based systems
« Reply #11 on: Nov 09, 14, 08:47:45 PM »

Awesome! Thanks a ton, that's exactly what I've been looking for.
 ;D
Logged

Jrome90

  • General Accounts
  • *
  • Posts: 330
    • View Profile
Re: Working on Skill based systems
« Reply #12 on: Nov 09, 14, 11:49:28 PM »

If you are adding wealth on the client side that will be temporary.
The best way is to call a method/ function on the server so that it gets saved for the character.

But even then, that is not the recommended way to do it. Ideally the only thing that gives a character wealth should be the server.

Logged

Amarak

  • General Accounts
  • *
  • Posts: 281
    • View Profile
Re: Working on Skill based systems
« Reply #13 on: Nov 10, 14, 08:43:45 AM »

Quote
The best way is to call a method/ function on the server so that it gets saved for the character.

Yeah I saw that. I'm looking at remote calls and such next. They have some good stuff on the wiki about it so hopefully it will be easier to learn.
Logged