Frostorm

[]D[][]V[][]D
Veteran
Joined
Feb 22, 2016
Messages
2,370
Reaction score
1,985
First Language
English
Primarily Uses
RMMV
So I'm trying to learn the math/mechanics behind a CTB battle system. I found this Googling but found some of it confusing. Specifically, step 1 says that:
Calculate the average speed of each member of the combat, (sum all of the speeds of enemies and characters, then divide the members speed by this sum, you know, average)

TotalSpeed = SUM(Members)

Member.AverageSpeed = Member.Speed / TotalSpeed
However, shouldn't a unit's avg speed be TotalSpeed divided by # of units?

What should my approach be if my current battle system (which I'm trying to edit, not replace) currently manages turn order via an array in which the order of said array elements dictates the turn order? This is the function that handles turn order in LeTBS (Lecode's Tactical Battle System):
JavaScript:
BattleManagerTBS.determineTurnOrderSimple = function () {
    var array = [];
    this._turnOrder = [];
    this._activeIndex = 0;

    this.allPlayableEntities().forEach(function (entity) {
        array.push(entity);
    });
    array = array.sort(function (a, b) {
        return eval(Lecode.S_TBS.turnOrderSortMethod);
    });
    this._turnOrder = array;
    this._turnOrderVisual.set(this._turnOrder);
};
Note that return eval(Lecode.S_TBS.turnOrderSortMethod) simply refers to: b._battler.luk - a._battler.luk
Basically, LUK is my Speed stat. Anyway, I'm simply trying to figure out how to manipulate the array so that the turn order can have a CTB mechanic instead of the basic "fastest to slowest" turn order.
 
Last edited:

Alexandre

Veteran
Veteran
Joined
Jul 8, 2015
Messages
221
Reaction score
104
First Language
French
Primarily Uses
However, shouldn't a unit's avg speed be TotalSpeed divided by # of units?

As the article itself says, it uses, I quote 'terrible pseudo code', so yes, it is good to keep your logical thinking while implementing it.

The article probably doesn't have in mind apparition of enemies mid-way during combat, so for it # of units basically a constant since it will be the same for everyone. You could replace it by any other constant, it wouldn't change the core thinking.

PS: Yep CTB implementation is closer to a weird ATB, I wouldn't take too much inspiration from it.
 

Latest Threads

Latest Profile Posts

Hi everyone! Enjoying this nice long weekend. How are you all doing? :)
I just successfully tested having events check if specific actors are in a particular party slot and then changing image to match. This will let me make scenes take into account who is in the party at the time and arrange them accordingly - this is important since I'll have extra actors beyond current party. The script used is the same from MV and is compatible with my current core plugin setup in MZ. Thank goodness.
That awkward moment when you're talking about thinking about writing a limited shop stock plugin for MZ and then find out you already wrote one...last May. My memory is so bad.
When I open my project and I'm like, hell yeah.
Some drawings I made in Lapis, one day I intend to involve them in some RPG Maker project.
* maybe two wall frames
*or some sprite flower tiara, or maybe it inspires someone to do something.
bdd19b62e539d17b3b00cc3d63034f7d.jpg

fcca5c8471b34483da8e032cfe579275.jpg

Forum statistics

Threads
118,424
Messages
1,115,848
Members
155,376
Latest member
L4TNG
Top