• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Formatting RPG Skills

M

Melt81

Guest
Just wondering if anyone could give me a general idea of how you guys would store skills in a game. Here's what I mean.
I have a script with all the skills stored within a 2d Array called SkillScript. The game knows which skill is selected based on a globalvariable called sel.
Code:
//Value
skill[3,2]=20
skill[3,1]=3
skill[3,0]=50
//Target
skill[2,2]=tar
skill[2,1]=tar
skill[2,0]=tar //Global Variable
//Effect
skill[1,2]=DamageTargetScript
skill[1,1]=BurnTargetScript
skill[1,0]=DamageTargetScript //These are basically script names
//Name
skill[0,2] = "Fin Slice" //Kinda continues like this
skill[0,1] = "Scorch"
skill[0,0] =  "Gale's Roar"
Anyway the effects are formatted like this and when an event performs like say I press enter or something this script is triggered.
Code:
SkillScript()
script_execute(skill[1,sel],skill[2,sel],skill[3,sel])
My problem is that I want to know if there are other ways of doing this in case this fails.
 
S

Street Gaming

Guest
This looks almoat exactly how I store my skills in my game Evobeasts. In the way of personal preference, i try and keep variables organized by skill rather than by what the variable does. I would also comment the heck out of them since you may find yourself with tons of variables. The overall direction youre taking looks fine and whats most important is that it makes sense to you.
 

Fabseven

Member
you could also use enum to have a more readable code.
ds_grid are cool two.

Code:
enum e_info
{
   cooldown=0,
   atk=1,
   def = 2,
   spr = 3,
  something=4
.....

}

tabskills[0,e_info.cooldown] = 30
tabskills[0,e_info.atk] = 10
tabskills[0,e_info.def] = 5
tabskills[0,e_info.spr] = sprite_something
...

or

lst_skill = ds_grid_create(e_info.something, 10) //first argument = greater value of your enum e_info, second arg = max nomber of skill , could be resized later if needed.
ds_grid_add(lst_skill, e_info.cooldown, 0 , 30)
ds_grid_add(lst_skill, e_info.atk, 0 , 10)
ds_grid_add(lst_skill, e_info.def, 0 , 5)
ds_grid_add(lst_skill, e_info.spr, 0 , sprite_something)
you can access your dsgrid values by : var xyval = lst_skill[# e_info.cooldown, 0] //xyval will be 30
Read more at http://docs.yoyogames.com/source/dadiospice/002_reference/data structures/ds grids/index.html
I read somewhere that dsgrid are easy to sort too....
 
C

CedSharp

Guest
you could also use enum to have a more readable code.
ds_grid are cool two.

Code:
enum e_info
{
   cooldown=0,
   atk=1,
   def = 2,
   spr = 3,
  something=4
.....

}

tabskills[0,e_info.cooldown] = 30
tabskills[0,e_info.atk] = 10
tabskills[0,e_info.def] = 5
tabskills[0,e_info.spr] = sprite_something
...

or

lst_skill = ds_grid_create(e_info.something, 10) //first argument = greater value of your enum e_info, second arg = max nomber of skill , could be resized later if needed.
ds_grid_add(lst_skill, e_info.cooldown, 0 , 30)
ds_grid_add(lst_skill, e_info.atk, 0 , 10)
ds_grid_add(lst_skill, e_info.def, 0 , 5)
ds_grid_add(lst_skill, e_info.spr, 0 , sprite_something)
you can access your dsgrid values by : var xyval = lst_skill[# e_info.cooldown, 0] //xyval will be 30
Read more at http://docs.yoyogames.com/source/dadiospice/002_reference/data structures/ds grids/index.html
I read somewhere that dsgrid are easy to sort too....
This is how I create my skills table too.
Usually, the first dimension of the grid is the skill "id",
and the second dimensions are the skills necessary values.

Using enums make the code a lot more verbose and you don't need to remember what number does what.

The only drawback in using a ds_grid in such situation is that if you have skills that need 5 values ( or 5 parameter, whatever ),
and some skills that need only 2, then those skills will have 3 unused parameter, since it would mean all skills have 5 parameters.

BUT, usually you don't have millions of skills, so the memory used is tiny and not really noticable.

Using arrays in the same matter works too.
A 2D array is the same as a ds_grid.
The difference lies in how the memory is managed, the speed of read/write access, and of course all the goodies like
sorting or shuffling.

In the end, the way you currently do it is very good. I would just personally use a ds_ structure instead, they feel more stable and fast to me :)
 
Top