Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Implementing battle actions in an RPG?  (Read 1762 times)
0 Members and 2 Guests are viewing this topic.
Offline Indignation211

JGO n00b
*

Posts: 10



« on: 2011-02-02 16:37:09 »

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. Cheesy

Offline aazimon

Full Member
**

Posts: 208
Medals: 5



« Reply #1 on: 2011-02-09 18:00:19 »

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 (<DamageType>fire</DamageType>).
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?
Offline loom_weaver

Full Member
**

Posts: 224
Medals: 14



« Reply #2 on: 2011-02-09 22:18:13 »

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.
Games published by our own members! Go get 'em!
Offline sproket

JGO n00b
*

Posts: 26



« Reply #3 on: 2011-03-04 19:39:10 »

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.

Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.09 seconds with 19 queries.