Initiative Formula for RPGs
Hi all. I'm trying to come up with a formula to create a starting initiative and initiative rate for characters in an RPG game. The initiative is a gradient bar which allows players to take a turn when it is full: just imagine FF3/6 and FF7, probably many other games. The starting initiative and rate of increase should be somehow affected by the characters agility/speed/movement/what-have-you. It's a more complicated formula than it sounds because it has to take into consideration the growth scale of increased agility. What I mean is: if a character begins with an agility of 10, his starting initiative would be so much and his rate of initiative would be so much. But near the end of the game, the character may have an initiative of 100; so his starting initiative would be way too high and his gradient bar would fill practically instantly. If all the characters have agility that high, including the monsters, then everyone in battle would be attacking instantly, constantly at later levels. Somehow it has to be rescaled based on the agility of everyone involved in the conflict. Final Fantasy somehow employs a formula so the perception changes where it seems your characters aren't attacking any faster although the monsters, with lower agility, are seemig to attack slower. Imagine fighting lvl 1 goblins with your level 100 party. Your level 100 party doesn't seem to attack any faster, but it's as though the goblins are frozen because their agility is so much lower their attack rate has been scaled down. Or the reverse, you are facing a monster of extremely high agility and it seems as though the characters are filling their gradient bars in slow motion. It's kind of hard to explain. Let me ask another question: is there a place I can read about such formulas used in Final Fantasy or other RPGs? (there is a formula faq on gamefaqs but it doesn't include this one)
The system in ff6 is called Active time Battle (as opposed to turn based).
You'd want to get the delta time, and then do:
Character.ATB_Meter += Speed * fDelta;
Now what you can do, is scale the speeds factoring in all the current character's (who are in the battle) speeds. Just play with it until you find out what works. Maybe just alter the monster's speed based on the party average.
You'd want to get the delta time, and then do:
Character.ATB_Meter += Speed * fDelta;
Now what you can do, is scale the speeds factoring in all the current character's (who are in the battle) speeds. Just play with it until you find out what works. Maybe just alter the monster's speed based on the party average.
Thanks. I'm not that good of a programmer to comprehend precisely what you're talking about but it's a good start. What is delta speed?
I guess part of it would be creating a speed increment that determines how much the active meter fills per tick. The speed increment would be different based on all the characters involvd in the battle so it would be to scale; like you said.
It has to something to do with finding the average speed of speeds of all the characters involved in the battle.
Char1.speed == 20
Char2.speed == 27
Char3.speed == 22
Monster1.speed == 45
Monster2.speed == 14
Average speed == 25.6
Then you'd want to scale it so a character with the average speed, 25.6, would require maybe 5 seconds to entirely fill their battle meter from 0 to 100%.
25.6 x 5 = 128
After 1 second of battle, Monster2's initiative would increase 14 points (his speed) but on a scale of 128.
This would increase his meter by 10.9% in one second. In the scale of this battle, it would take him 10 seconds to reach 0 to 100% on the active battle meter.
Do you think this formula works?
I guess part of it would be creating a speed increment that determines how much the active meter fills per tick. The speed increment would be different based on all the characters involvd in the battle so it would be to scale; like you said.
It has to something to do with finding the average speed of speeds of all the characters involved in the battle.
Char1.speed == 20
Char2.speed == 27
Char3.speed == 22
Monster1.speed == 45
Monster2.speed == 14
Average speed == 25.6
Then you'd want to scale it so a character with the average speed, 25.6, would require maybe 5 seconds to entirely fill their battle meter from 0 to 100%.
25.6 x 5 = 128
After 1 second of battle, Monster2's initiative would increase 14 points (his speed) but on a scale of 128.
This would increase his meter by 10.9% in one second. In the scale of this battle, it would take him 10 seconds to reach 0 to 100% on the active battle meter.
Do you think this formula works?
This formula is very wrong. You need to include an output from a random function in computation. If you wanna to see details why it could be VERY wrong, google for "pillar dancing".
A = B + randomGen.nextInt(10) would work.
Additional problems could arise from too small delta.
BTW ATB system is one of types of Turn Based Systems. You could view action of the slowest member as an virtual end of the turn.
Actually TBS could alow all members to act at once.
edit slight typo
[Edited by - Raghar on February 5, 2006 3:49:28 PM]
A = B + randomGen.nextInt(10) would work.
Additional problems could arise from too small delta.
BTW ATB system is one of types of Turn Based Systems. You could view action of the slowest member as an virtual end of the turn.
Actually TBS could alow all members to act at once.
edit slight typo
[Edited by - Raghar on February 5, 2006 3:49:28 PM]
I keep forgetting to post this: Since you want the characters to build up ATB at a constant speed, you can set the speed of an enemy to fast, medium or slow and then scale it accoridng to the party's average speed.
So you'd have your constant speed for ATB building. Constant being however many points you want to fill per second
Character.ATB += ((ATB_CONSTANT * modifier) * fDelta);
Modifier would be to allow for either haste or slow, or stop (like FF).
Then for the monster you do the same thing, but you scale it based on the average to keep it proportional to the party. However, doing this will mean the monsters will always be faster/slower than the players.
So you'd have your constant speed for ATB building. Constant being however many points you want to fill per second
Character.ATB += ((ATB_CONSTANT * modifier) * fDelta);
Modifier would be to allow for either haste or slow, or stop (like FF).
Then for the monster you do the same thing, but you scale it based on the average to keep it proportional to the party. However, doing this will mean the monsters will always be faster/slower than the players.
Seems to me that the simplest way to do this is to determine the shortest time you want a given actor (ally or enemy) to wait between actions, and then to scale all wait times based on that actor's initiative. So for example, if you want to wait five seconds between actions at least, and your actors' initiative stats break down like so:
Actor 1: 50
Actor 2: 100
Actor 3: 10
then your fastest actor is actor 2. Every five seconds, actor 2 will take an action; every ten seconds, actor 1 will act, and actor 3 will most likely not act as most battles are done inside of 50 seconds. :)
One simple way to do this is to require each actor to reach max_initiative ( = the initiative of the fastest actor) ticks before they can act, and they get initiative / min_wait_time ticks per second. Then just seed each character with a random amount of ticks from 0 to their initiative at the start of the battle (modified by ambushes, et cetera), and take it away! Remember that you may want to pause the counters for spell animations and the like.
Incidentally, Chronotrigger solved this problem by having the initiative stat only increase through items or rare statboost consumables, and then capping the stat at 16. This means that fast actors are fast regardless of their other stats (that fly still gets to attack you 10 times to your 1 even though you're 50 levels higher than it...though it won't accomplish much), which may or may not make sense depending on the rest of your game design.
Actor 1: 50
Actor 2: 100
Actor 3: 10
then your fastest actor is actor 2. Every five seconds, actor 2 will take an action; every ten seconds, actor 1 will act, and actor 3 will most likely not act as most battles are done inside of 50 seconds. :)
One simple way to do this is to require each actor to reach max_initiative ( = the initiative of the fastest actor) ticks before they can act, and they get initiative / min_wait_time ticks per second. Then just seed each character with a random amount of ticks from 0 to their initiative at the start of the battle (modified by ambushes, et cetera), and take it away! Remember that you may want to pause the counters for spell animations and the like.
Incidentally, Chronotrigger solved this problem by having the initiative stat only increase through items or rare statboost consumables, and then capping the stat at 16. This means that fast actors are fast regardless of their other stats (that fly still gets to attack you 10 times to your 1 even though you're 50 levels higher than it...though it won't accomplish much), which may or may not make sense depending on the rest of your game design.
Jetblade: an open-source 2D platforming game in the style of Metroid and Castlevania, with procedurally-generated levels
You might also consider using the square root of the number instead of taking the score directly. So, 10 would correspond to about 3, 100 would be 10. This would minimize the huge disparity between very slow and fast, and also make it more difficult to get faster as you progress.
I hope you ment look up table. Square root would kill it. Not to mention that disparity depends on the game system, and large disparity could be really nice.
Quote:
Original post by Raghar
I hope you ment look up table. Square root would kill it. Not to mention that disparity depends on the game system, and large disparity could be really nice.
No. Unless you're calculating the initiative several hundred or thousand times a second, which you wouldn't be, a square root will not kill it.
In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement