Implementing battle actions in an RPG?

Hello, I’m in the process of developing my first Java RPG. So far i have a basic battle system in place in which creatures are created from data stored in XML files (which upon starting the game is parsed into a GameData object which various methods can search). The creatures can act in a certain order, attack other creatures, take damage and die.

Now in order for the battles to really take shape i need to implement a variety of special actions. Player characters will share a small number of universal actions (such as Move, Basic Attack, and Defend) and will learn a number of unique actions as the game progresses (Mostly special attacks and utility powers). Monsters will have a predetermined list of actions they can take, which varies from species to species (naturally all will be able to at least Move and Attack). Initially Actions are performed by typing the name of the Action into the console, as I have yet to implement anything graphics-wise, eventually they will be handled through a GUI.

My question is how to implement actions like this? Should Actions be their own class or part of the Main class? How much of an Action should be programmed in Java and how much should be stored in XML?

Thanks to anyone who can help me out. :smiley:

You want to break it down to its simple components. With a special attack, it would be the same as attack, but more damage, or it could be fire damage. If its different types of damage, I would have the victim have a method for taking fire damage. Breaking it into types of damage, your XML could list the type of damage (fire).
Instead of pulling the Action in its own class, maybe a class for handling the damage. This class would have attributes unique to the character or monster, to determine how it takes damage for a specific type.

Does that help?

In my opinion…

If this is your first game I would put none of the actions in XML. Keep it all in Java until you come to that day that you’re writing a lot of boilerplate code. If that day happens, then you can refactor your code to add more actions without recompiling.

Why? Because you likely not have that many actions compared to mobiles and objects.

Good point. Java first is the best approach. Also I would recommend using the javax.script API instead of XML.