Public Group

# Special Skills, Spells, and Abilities

This topic is 1864 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So after a good deal of work, I have a basic SRPG style battle system up and running.  I have characters and enemies (no AI yet) that take turns.  They can move around and perform basic attacks.  I'm reasonably happy with the way I have the system laid out behind the scenes, which I'll detail in as concise a way as possible, and then get to my question:

• I have a Battle_Controller class which handles input, both from keyboard and mouse events (in SFML), and from GUI events.
• I have a Battle_Map class which handles the map itself (tile map).
• I have a Battle_Manager class which handles the battle in different ways.  It maintains an std::list with the turn order, it activates the character or enemy whose turn it is, and theoretically, it should provide the interface through which the various units on the battlefield interact.  Currently, there is an attack method that takes an attacker and defender and resolves the attack.
• Finally, I have a Character class and an Enemy class, both of which derive from an interface called iUnit (which would also be used for neutral characters, AI controlled allies, etc).  They are primarily collections of data and don't actually "do" anything on their own.

So with that in mind, I've started to think about how I might integrate skills and what not.  The thing is, attacking is easy, since all the access I need is to two units on the battlefield.  I pull statistics from those two units, perform some calculations, and assign damage as needed.

But for a game where I want to put a great deal of emphasis on a wide variety of special skills, I'm having trouble planning out how to implement a robust and extendable system.  For one thing, just off the top of my head, I want to have spells that alter the terrain, so I'll need a pipeline to alter the tiles in the Battle_Map.  I want buffs and debuffs that work for some number of turns, so I'll have to have a way to maintain those counters somewhere.  I mean, ultimately the problem is that various skills, spells, and abilities will need to potentially have access to just about any data that relates to the battle (and, in some cases, maybe some outside battle data as well).  I'm not sure how I can achieve this while still maintaining some semblence of decoupling.

For a second thing, I'm kind of wondering where and how I should specify who has access to which skills, and further, where I should define what skills do what.  My tentative plan is to have characters and enemies and so on maintain a simple std::vector<bool> skills which will have as many entries as there are total skills in the game.  So, say skill #5 is fireball, a character who can cast fireball would have a skills[4] entry which evaluated as true where a character who couldn't would have skills[4] evaluate as false.  Its not exactly elegant, but I think it would work.

But then the problem is, I'll have to define what these skills actually do somewhere.  Maybe a dedicated class that just has skill related methods (one method per skill in the game)?  That could be huge and unweildy, but I think it would work...

Ultimately, I'm just having trouble envisioning how all these things should work together on a conceptual level.  This is a technical question, but I'm not looking for very specific code advice, just a general overview of how these things are usually done.

##### Share on other sites

Why don't you make a class Skill and add a list in your iUnit class that will contain numerous instances of Skill(for the different skills) - basically your units will contain a list of skills.  Add some method in iUnit to access a given skill (basically you search in the list of skills) and from there you can use the Skill class methods for the given instance of skill.

Something like this:

class iUnit
{

protected:
list list_of_skills;

Skill& access_skill_by_index(unsigned short input_index)
{
//find the given instance of skill in list_of_skills by using the input_index
//and return that instance
}

...

};


You can use whatever you find better for "list" - an array, a vector, a linked list etc. And you can code the access_skill_by_index method differently - you might want to access a given skill by some other means.

Edited by lightxbulb

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631429
• Total Posts
3000035
×