• 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!

Legacy GM RPG Skills and effects using grids

N

N3ONReaper

Guest
Okay this is going to be a relatively hard one.
I have set up 2 grids, one for skills and one for effects in my RPG (I also have one for the party, but that isn't important for this)
This is how each row in my grid is set up for skills, with each skill being 1 column:
Code:
name
icon
tool tip
cost
dmg Multiplier
Has Effects?
effect id
effect chance
target (0 = 1 enemy, 1 = all enemies, -1 = 1 party member, -2 = all party members)
unlock level
and also for effects:
Code:
name
icon
effect (damage, heal, boost stat, paralyze, lower stat)
multiplier? no,yes
value
turns lasting
stat to boost? (-1 for none)
however, say i wanted to have a skill inflict multiple effects on a target, with different chances, or have an effect lower / boost multiple stats, with different values, some being a multiplier and others not, i am stuck as to how to set it up. I know that 1 cell can only hold 1 value in a grid, so i would need some other workaround, preferably something itterable (so that i can correctly apply the effects with the correct values / chances using a for loop), and without having to create another separate grid for each possible combination. Any ideas??
 
The solution is to store the multiple effects data as another data structure/array, then add the index of that data structure/array to the grid. Brief example:

Code:
var effects = ds_grid_create(3, 4);

effects[# 0, 0] = effect_type.poison; // Effect ID
effects[# 0, 1] = 5; // Duration
effects[# 0, 2] = 0.5; // Effect Chance
effects[# 0, 3] = true; // Stackable (just making stuff up here...)

effects[# 1, 0] = effect_type.paralyze;
effects[# 1, 1] = 2;
effects[# 1, 2] = 0.25;
effects[# 1, 3] = false;

effects[# 1, 0] = effect_type.death;
effects[# 1, 1] = 0;
effects[# 1, 2] = 0.01;
effects[# 1, 3] = false;

skills[# curr_skill, effect_list] = effects; // Grid ID is now stored in the skills grid
... To then use it, you need to pull the effects grid from the skill grid:

Code:
var skill_effects = skills[# skill_id, effects_list];

show_message(skill_effects[# 0, 1]); // Will show '5', for the duration of the poison effect.
... And remember to free the effects grid data structure before you free the skill grid, or you'll end up with a memory leak.
 
Top