ability/magic system
Displaying 1-10 of 10 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
RageCage

This is a question thats been bothering me...
What would be a good way to go about creating an ability/magic system? right now the best idea I have would be to:

create a .dat file with name and description of ability/magic

read the file and store the name and desc under an array

a big ass switch statement that looks at the index of the array and for each individual ability/magic, does a special action.

but then how do I handle things that last for a few turns and goes away? ex: poison

I have my doubts anyone will be able to help me but I figure it's worth a try

Posted on 2004-04-10 07:03:29 (last edited on 2004-04-10 07:04:34)

anonymous

seems to me like that would depend pretty much entirely on the context i.e. how the rest of your battle system or whatever works

Posted on 2004-04-10 13:10:07

Omni

Don't have a big switch.

Instead, for each member of the Magic Spells, give them two or three arrays, like so:


def POISON 4

magic_spell_names[SPELLS]
magic_spell_damage[SPELLS]
magic_spell_element[SPELLS]
magic_spell_status[SPELLS]


Now this way, all you need is a Number ID, like 4--also POISON.


magic_spell_names[4] = "Poison"
magic_spell_damage[4] = 30 //maybe...
magic_spell_element[4] = "Poison" //or whatever element.
magic_spell_status[4] = POISON

void CastMagicSpell(int enemy_ID, int spell_ID)
CastMagicSpell(enemy_0, POISON)


Simple, easy way to do it. Then, each round of your battle, check a variable like:


if (player_status[0] == POISON)
{
player_HP[0]--;
}


Something like that. That's how I'd look at it, anyway. Be creative!

Posted on 2004-04-10 15:12:59

andy

uhhhhhhh don't do what he said.

Just have a field of the skill struct be the name of a function. Use CallFunction to call it.

CallFunction(skills[skillLists[characterIndex]].CastFunction)

Posted on 2004-04-10 17:53:25

RageCage

well the thing I'm trying to avoid is a lot of repeating code when I could probably make one function thatd know the difference between heal, fireball, and poison just by puting them through a similar protocol. the problem is that like 70-80% of the magics/abilities you see in games could easily put through a protocol but then theres a few off ones such as flee and steal.

what I was thinking might work is a data file that would contain:

NAME,
index_stat_affected,
0/1_for_negetively/positively_affected,
amount,
turns_to_last(0=infinite),
0/1_for_callEveryTurn_or_not

with this you can fit in spells like fireball, heal, warcry(temp raise all allies atk), poision, sleep, etc. and you can simply call the index of the spell into a function and it knows what to do easily. No switch statements, no long list of functions.

problem is there is certain special ones such as flee and steal. There's very very few of these non-stat affecting abilities/magics. So if I had special conditions just for those... it might just work...

comments?

Posted on 2004-04-10 18:23:29 (last edited on 2004-04-10 18:25:29)

Omni

Hmm. Object-oriented programming in Verge...

Posted on 2004-04-10 20:32:15

RageCage

?

Posted on 2004-04-10 20:50:54

Omni

Sorry, I was looking at the_Speed_Bump's post. Anyway, your method looks great, and not that different from what I had in mind.

Posted on 2004-04-10 21:16:14

Technetium

Well, I always like to do things the most inefficient way possible, because it is fun spending an hour to debug each tiny little problem.

As such, I have a different function for each character's menu to select a magic spell. Then it goes to a different function for the casting graphics and effects based on what you pick. I make heavy use of switch/case. It's probably much longer than andy's method, and probably more prone to bugs. If you can figure out what andy's talking about, then go with his idea instead. I, on the other hand, will continue to look at his suggestion and scratch my head in my inability to comprehend. :-)

For continuous status effects, like poison, that's easy. I'll assume you contain your battle system in some kind of main loop. At the start of each loop, or wherever in the loop you like best, just have it test if each character's status type is activated or not. This means you'll have to create all kinds of variables, the likes of "character[x].poison" and such.

Posted on 2004-04-11 19:22:57

RageCage

heh, yeah I'm a effeciency freak... or I try to be.

Posted on 2004-04-12 03:14:53


Displaying 1-10 of 10 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.