Turn Based system?

Hey there, I’ve been interested in making an RPG with a turn based system. I was kinda wondering if someone would be able to point me in the right direction as to how I would go about a turned based system of fighting and the transition from one scene to the battle scene, and then back to the original point of contact with the battle, but with your hp decreased due to damage and items received. I haven’t really given it much thought cause I’m worried about the models and such, but if I could get a good point in a useful direction, that would be awesome, thanks a lot.

Examples would be like FFVII and Xenogears.

POINT -> python

There are many sorts of turn based systems… are you thinking of a setup comparable to Fire Emblem or Advance Wars?

no, like encounters. Based on what you write in the python programming, there’s a number of steps you take till you get an encounter, and when you get into an encounter, you are basically token to another scene (battle scene) with a set of enemies/monsters to fight.

I don’t have an answer now, but this interest me too!

I think python is needed with a timer:
Here’s how i see things:
When the timer reaches a certain time, the python script randomly chooses if there’s a script or not.
If not:
-timer return to zero
If yes:
- the script saves the position of the player
- the script adds an overlay scene (for the transition)
- set the battle scene (how many monsters, etc)
- and then set this new scene as the battle scene

And then, two choices:
- if the player is victorious: resume the prévious scene and load the player’s position
- if player is defeated: set game over screen :slight_smile:

Welle there are just things I’ve been thinking about, but I don’t know enough python for doing it…

Pathfinding will be a major part of this, see my post in this thread for an example: http://blenderartists.org/forum/showthread.php?t=161770 (Note that you will need 2 sets of passable lists, one for the players team and one for the enemy)

So, in a step by step guide of how it could be done:

  1. Encounter an encounter, save position and change scene.

  2. Set up players/enemies in battle field (will probably be one of the hardest thing)

  3. Begin payer fight phase:
    3.1 wait for player to select a unit
    3.2 use pathfinding to move unit, attack if ordered, set a ‘ready’ (or similar) flag to false.
    3.3 wait until all units ‘ready’ flags are false

  4. Begin enemy fight phase:
    4.1 Use AI to determine targets (Take into account distance, enemy health, player health % of success) and move towards it and attack if close enough.
    4.2 Wait until all ‘ready’ flags are false

  5. set all ‘ready’ flags to true

  6. repeat steps 3-5 until 1 side has no units left.This won’t be a walk in the park. Try use a state machine to simplify things, you could use blenders logic states or make your own system.

To be honest, if you don’t really know how to transition between scenes while keeping stats, I don’t think you have enough knowledge to do something like this. So, things you should learn:
-Python modules/classes/functions.
-Accessing different modules/classes/functions from elsewhere.
-The GE API
(GE API Documentation)
(Tutorials for Blender 3D)
-Pathfinding
-Using states
-Handling scenes
-General python

That was a great explanation. Wasn’t it?

Is that sarcasm or not?

? Not at all.
That was a full answer with explanations, links to resources and advices.
Did it sound like sarcasm? (wrong use of english?) That’s not the way I am.

Ok, its just plain text is sometimes hard to interpret. The question at the end, “Wasn’t it”, just sounded a bit like sarcasm.

In that case, thanks.

Hi there andrew, very interesting answer, thanks a lot.

I’l go check some of your links (as I already know some :p) it will surely help me alot.
For my part, I didn’t start working on the battle phases in my game, but it should come soon…

I hope that this will help Chaos Theory too.

Cheeers!

Oh yeah of course. well, I have to start on it somewhere… I have a natural understanding to code, as long as I know what the parameters are being used for and what certain keywords mean, it’ll be easy for me to learn. I’ve been dabbling around different languages and I’ve decided to go ahead and learn python as a first language for me to fully learn. The process of me leaning this will take a month or two (already started learning python), but I catch on very quickly.

[edit] yikes, I wrote a lot more than I thought I did!

Personally for turn-based random encounters, I would do something like this:

Upon entering an area where combat is possible get a random number between X and X+some- this is how far the player can travel before combat is started. As the player moves, reduce this. When it hits 0, start combat:
In each combat-possible area, keep a list of monsters the player can fight. Pick a random set (lets say, up to 3) of these monsters and store their names in a global variable. You might want to add some randomizing to their HP and power, so even if the player fights the same set of monsters again it’ll be slightly different.
Add a new scene for combat (suspend, or save and remove, the main scene).
Add all the monsters and players, in the combat scene you probably want to have empties placed for where players go and empties for where monsters can be- then it’s just a matter of choosing which empty to place the unit on.
Decide initiative(that is, turn order: which unit goes first, who goes next, etc) personally I’d jsut give every unit a stat named “speed” and the higer speed goes sooner.
Make an empty list, and loop through all the units in turn order, appending them to the list.
You are now ready for actual combat.
Using a single script, you can control all the units- the first unit in the list is the one who’s turn it is. If the unit is controlled by the player, wait until the player chooses what to do- if it’s AI controlled, pick an action (generally attack, but you could add if the unit is at X% HP, there’s a chance it will flee, etc)
when the unit’s action is chosen, disable player input, and play whatever animations or graphics. When those have finished, use list.append(list.pop(0)) to move the unit from the first spot in line, to the last. The next unit will now be the first, and you can continue like this.

Make sure to leave a variable on the unit that changes based on where it is in the list- when a unit leaves combat (dies, flees, summoner runs out of mana, whatever) use list.pop(unitPosition) to remove it from the list, before actually deleting the object.

When all the units on one side are gone, you can end combat- if the player lost, end the scene and add a game over scene- if the player won, resume the main scene (or change to it and set the player position and whatnot to their correct places), and then get a new number to decide how long the player can move outside of combat.

alright yeah, that makes sense. I kinda want a battle system like XenoGears where you choose which actions that take up a number of Action points, such as action ‘A’ Does low damage, but rarely misses and takes only one AP, action ‘B’ does moderate damage, usually hits, takes up 2 AP, and then action ‘C’ does massive damage, good chance of not hitting, and takes up 3 AP. Sooner down the game, you’ll eventually gain combos which does massive damage, such as doing action A with B triggers a combo that makes your character do a unique move or moves. I’m pretty sure this would be easily figured out with python, just gotta start writting code for the bge and get used to it.