#### Archived

This topic is now archived and is closed to further replies.

# Rpg Battle Engine Question

## Recommended Posts

Hi, how are you all doing, Im creating a battle engine, and i was hoping someone could help me out with a problem im having. Its a sideview battle engine, and the problem im having is I cant seem to come up with a way to decide whose turn it is. For example lets say there are two heroes on your team and your facing one enemy. The way i want to do it, is where the persons turn is determined by their agility. So lets say Hero 1 has an agility of 15, Hero 2 an agility of 5 and the monster an agility of 10, in the English Language how would i determine whose turn it is next? It would be easy to determine this if these heroes were always in your team, but what if they arent? I appreciate any help i could get Dario

##### Share on other sites
CREATE LIST TO HOLD HEROES AND MONSTERSFOR EACH OBJECT NOT IN THE LIST ADD OBJECT TO LIST, SO THAT ITS AGILITY IS GREATER THAN ALL THOSE AFTER HIM, AND LESSER THAN ALL THOSE BEFORE HIM.(google for insertion sort)WHILE THE BATTLE IS NOT FINISHED FOR EACH OBJECT IN THE LIST  IF OBJECT IS A MONSTER   GENERATE NEXT MOVE USING AI   EXECUTE NEXT MOVE  ELSE   GET NEXT MOVE FROM PLAYER INPUT   EXECUTE NEXT MOVE

ToohrVyk
-------------
Extatica - a free 3d game engine
Available soon!

##### Share on other sites
i still don''t get it

##### Share on other sites
I think ToohrVyk was suggesting that you simply go in order of an agility rating. The higher the rating the closer you are to the ''front of the line''.

##### Share on other sites
Oh ok i understand that, but uhh lets say i wanted to add a little more for example, lets say the enemies agility is 17 and the heroes agility is 8. How would i make it where the enemy gets two turns before the hero gets his turn because 8X2=16 which still is lower then the enemies agl.

##### Share on other sites
After the bad guys turn, deduct 8(the hero''s agility) and put the evil guy on the list again and sort it

ZoomBoy
Developing a iso-tile 2D RPG with skills, weapons, and adventure. See my old Hex-Tile RPG GAME, character editor, diary, 3D Art resources at Check out my web-site

##### Share on other sites
Well, if you use a list of whose turn it is, its pretty easy.

Just have some storage variable with ''Agility'' in it, and subtract by some "base" factor, say 8 for the time being.

So lets build a list:

BASE LOOP:
1. Grab the next character in the list (If you want to, start with the Enemies or the Heroes)
2. Declare TempAgility = Current Character

NESTED LOOP INSIDE BASE LOOP:
.1 Subtract the base factor (8 from above) from TempAgility
.2 Add the current character to the bottom of the list
-------

That should do it. Build a list, its the best way.

##### Share on other sites
you could have a percentage number, say 100, for each enemy and player. while the objects percentage number != 100, increment it by the agility every loop (or every 5 loops to slow it down) until it reaches 100. when the first player to hit his percentage reaches it, set a flag to accept input for that player. if the second hero reaches his percentage mark after the first while the first is accepting input, then after the first player has executed his move, check to see who else has a percentage of 100 to see who goes next. if you have multiple characters who have %100 after the first, then see who has the hightest agility to see who goes second, and so on. after each move, reset the percentage number and you start right back over.

it works just as well for the enemy, who will continue to fight the player as long as his % number is still being incremented, just reset it after each AI move.

Hope this helps.

• ### Forum Statistics

• Total Topics
628333
• Total Posts
2982139

• 9
• 24
• 9
• 9
• 13