Seriously, go play Phoenix Wright already.

The other day I posted a list of things I’d need to do to the distraction engine to have it cope with my new miniRPG, and I casually mentioned “Finish the battle engine” as something silly that still needed to be finished in the next few days. I guess I wasn’t thinking straight. I’ve haven’t mucked around with the code in this thing for about six months now, so I had no idea how much work was going to be involved. It seems there are some major gaps in my assessment of the situation…

So I had a look through the code, and worked out where I stand, and exactly what I need. Here’s what I have at the moment:

– When the “battlemode” flag is enabled, I start an ATB system, where the turns of players are queued up.
– Each action has a name. On a player’s turn, the action associated with the hero’s name is automatically called. (e.g. on Squall’s turn, the action “Squall” is called automatically.)

Each action has a type, with a couple of variables – “size”, “cost”, and a generic array called “link”. The current implemented types are:

LIST
Default for selections. Specifify “size” as the number of elements, link[0], link[1] etc are the actions to call (by name).

HERO_LIST
As list, except the hero’s name is shoved in front of it, so that when player1 selects “Attack” and player2 selects “Attack”, they do different things, because the engine acts like you’ve selected “Player1_Attack”.

SKILL_LIST
As list, except you also specify a “cost” for each link, and this is displayed beside the action, along with the SP.

ACT
So far, this doesn’t really do anything. It calls a routine which processes a basic script that’s coded into the links of the action. This scripting language supports the following commands, so far:
end” – destorys all textboxes, and continues with the ATB.
damage” – so far, it adds “floating” damage to the caster, displaying the floating text with it.
wait” – waits a given number of frames
link” – runs the next action in the queue.

To clarify, here’s how that structure currently looks with the variables hardcoded into the engine:


void init_stats(characterclass *heros, characterclass *enemies, actions *action){
  //This is a temporary routine - eventually, everything will be inputted
  //externally.
  
  heros[0].name = "Remy";
  heros[0].strength = 14;  heros[0].defence = 10;
  heros[0].intelligence = 27;  heros[0].speed = 15;
  heros[0].limit = 0;  heros[0].time = 0;
  heros[0].hp = 9999; heros[0].maxhp=9999;
  heros[0].sp = 30; heros[0].maxsp=30;
  heros[0].action = heros[0].name+"_default";
  
  //Every inital action will have to be a list - unless the character is
  //beserked or fighting with the enemy or something.
  numactions=7;
  action[0].name="Remy_default";
  action[0].type=HERO_LIST;
  action[0].size=3;
  action[0].link[0]="Attack";
  action[0].link[1]="Skills";
  action[0].link[2]="Item";
  
  action[3].name="Remy_Attack";
  action[3].type=ACT;
  action[3].size=3;
  action[3].link[0]="damage";
  action[3].link[1]="120";
  action[3].link[2]="end";
  
  action[4].name="Remy_Skills";
  action[4].type=SKILL_LIST;
  action[4].size=10;
  action[4].link[0]="Skills"; 
  action[4].link[1]="Smash"; action[4].cost[1] = 30;
  action[4].link[2]="Hyper"; action[4].cost[2] = 25;
  action[4].link[3]="Trip"; action[4].cost[3] = 20;
  action[4].link[4]="Bomb"; action[4].cost[4] = 15;
  action[4].link[5]="Double"; action[4].cost[5] = 10;
  action[4].link[6]="Refresh"; action[4].cost[6] = 15;
  action[4].link[7]="Protect"; action[4].cost[7] = 20;
  action[4].link[8]="Meditate"; action[4].cost[8] = 20;
  action[4].link[9]="Focus"; action[4].cost[9] = 10;
}      
   

So… I guess this is where I need to go from here:

– Add more actions and list types (e.g. Inventory support, Limit breaks).
– Expand the ACT action to do something more useful, i.e.
* draw battle animations, (need to think about this one)
* deal actual damage
* turn status effects on and off
* trigger sound effects
– After that, I need to add enemies to the mix
– Then, mortality. What happens when everyone dies? What happens if you kill all the enemies?
– Leveling up, I guess, is next. Should probably be handled in a generic way, i.e. all enemies carry a certain about of stuff, including XP points.
– When I get that far, the next step is to have the heros walk about, get into a fight, finish the fight, and walk on. when I’ve done that, the basics of the battle engine will be complete.

I’ve also been reading up on A* Pathfinding. I’m pretty sure I understand how it works, but it’s going to take me a few days on top of the battle engine to implement… I think it’s a good idea to implement it, as it’ll make a lot of things down the line much simpler – but I couldn’t help nagging myself while reading about it. I should really be making a game, not coding an engine.

* Post a Comment

No comments yet

Leave a reply