# How to approach dual skills in an rpg game

I am developing an rpg-sort of game. My question is how a dual-tech system would work (like snes chrono trigger game had). I already have coded how to use a single skill.

Probably not the best way to do it, but here is how i have it working right now:

I have a Skill class and in my level, I define a Skill currentSkill When a skill is activated, the level starts rendering everything at half-speed except for the skill caster and the skill target.

Now what i am not really sure how to do is, how to structure my dual-skill class, and how to make this one's animation (which would include animating the 2 skill casters + skill targets) affect the initial skill cast.

The dual skill should be activated after a single skill is activated, eg. Character A casts skill a, which can be combined with character B skill b to produce skill c.

If that was somehow clear to you (think I complicated it) could you please provide some pseudo code / idea / example on how to achieve it?

EDIT:

I realize after reading the comments (and re-reading my question) that i was not clear on what I want to achieve, so I'll try to re-word myself (non native english speaker, so sorry for the lack of grammar)

Some considerations :

• It's not a multiplayer game so I will refer to the characters (or "players") you can use as units.
• Its some kind of rpg battle game ( it's pretty much a clone of the mobile game battlehearts but with dual-skills added, if you have seen that, you can get a pretty good idea on what game i'm working on).

basic idea:

1. Unit A casts skill a.
2. Unit B checks that he can combine its skill b with skill a.
3. Unit B casts skill b.
4. Unit A skill gets canceled
5. Unit B skill gets canceled
6. Unit A and B cast skill c.

here's some example:

• Unit A is swordman (with a single-target critical-hit skill called Bash)
• Unit B is mage (with a skill called air strike).
• bash + air strike = air slash ( skill that pierces and damages all enemies in a line, for example)

.asd

1. swordman uses bash
2. mage "realizes" he can combine it with air strike
3. on mage, skill air slash gets enabled.
4. when used, air strike consumes bash's and air stryke's cooldown, but executes a different skill (im talking about a different animation here, not sync'ing bash and air strike animations)

question is, how would you structure the code to achieve the above behavior? what kind of datastructure would you use to store information about dual-skills?

• What exactly do you want to do? – Gustavo Maciel Mar 8 '12 at 2:09
• Are you saying you have a game where players can cast a spell or create some effect and you want to expand that so that some spells/effects get created when multiple players combine their spells/effects? – George Duckett Mar 8 '12 at 13:50
• -1: I read your question, and I start to think that I almost understand what you are asking, and then I take a step back and am lost. I think it is a terminology issue. In any case, I don't think we'll be able to help you unless you clarify the question. Sorry. – PlayDeezGames Mar 8 '12 at 14:55

I think I get the idea. You want to combine 2 skills into 1 combined skill, or do you mean a combine effect based off of the two skills. Like if hit with a two fire spells in a row, you are prone to more fire damage and get a fire debuff? If not, it's just as another said, your wording.

A couple things. I am not sure how you can activate a dual-skill off of a single skill if the dual skill requires Character A's skill choice and Character B's skill choice to produce skill C.

I take it it is something turn-based like Chrono-Trigger? You select skills for the characters and then they do them in order of selection based on some sort of initiative timer. If I were doing this, I would possibly have some sort of checker for a bunch of spell flags that can produce the combined effect. You wouldn't need to check this until after the second class's ability is chosen, and then the third. If this is real-time, it's going to be more difficult as you need to set an amount of time that you allot to let the player select multiple skills to cause an effect, if this is something you even want to worry about.

Guild Wars 2 has something like this. Thieves and Necromancers can put down a Ground Target AOE that lets spells, arrows, rocks, etc, to absorb the effect. So, if an arrow that is normal goes through the effect, it adds poison damage.

I would do it with, off the top of my head, enum states possibly. Though this probably isn't the best way to do it.

• thanks, reading your answer I realized i never thought about this: If this is real-time, it's going to be more difficult as you need to set an amount of time that you allot to let the player select multiple skills – Xavier Guzman Mar 8 '12 at 17:37
• Xavier Guzman - This might be what you're looking for. rpgrevolution.com/forums/index.php?showtopic=34544 – Joel Brockman Mar 8 '12 at 18:17

Try an event based design:

1) Define a class SkillActivatedEvent that stores a Skill object, a Unit object, and some other properties like the area in which the skill is active

2) Raise a SkillActivatedEvent whenever a skill is used

3a) Let skills that are already in effect react to SkillActivatedEvents by changing the behavior of the new skill, by changing their own behavior, or by unregistering both itself and the new skill in favor of a new skill. If you take this route, information about dual skills is stored in or accessed by your skill objects

3b) Alternatively, let your game controller react to SkillActivatedEvents by going through all the active skills and looking for any combos to apply. In this case, information about dual skills is stored in or accessed by your game controller object.

As for data structures:

• You can hard-code the combinations in the form of if-statements, either in your Skill or game controller class.

• You can also use a table-like association between a tuple of skills and a combo skill that either your skill objects or game controller object accesses. " => air slash" could be stored in a simple database table, an XML file, or whatever storage system you want to use.

Factors that make hard-coding combos more viable include:

• You only have a small number of combos
• Interactions between combo skills and their "ingredient" skills is unlikely to change
• Combo skills have parameters that depend on the parameters of their ingredient skills, and these dependencies are unique in most cases

(The negation of these factors make the tuble-combo association datastructures more viable.)