MZ VisuStella Battle System CTB: Custom Parameters, Turn Delays

Hello again! Apologies for the slew of questions, but thank you so much for all the kindness and helpfulness you all always show to us. 🙏

This time, we have two questions about the CTB Battle System, and the first of which is kind of a long story that basically boils down to just needing to know more about JavaScript math syntax as it pertains to custom parameters.

Spoiler: First off....
See, we're using the CTB battle engine, which operates mostly on the party's built-in default AGI parameter to determine turn order, how quickly more turns come, etc. We were already planning to use AGI as part of a custom accuracy formula along with a new custom parameter, Dexterity. (Basically, a.DEX vs. b.AGI go into the overall initial to-hit multiplications, with a.hit and b.eva taken out and just flat added to or from the subtotal to get the grand total.) We'd like AGI to be a separate stat that only governs general elusiveness versus incoming damage, as opposed to... let's make a new parameter and call it SPEED, for the CTB turn order calculations.

This, however, raises some questions about how to convert the default CTB math settings to use the new variable instead of the old one.

Current formula for JS: Speed:
// Declare Constants const user = this; // Process Calculation let speed = Math.sqrt(user.agi) + 1; // Return Value return speed;

Okay, this one's pretty straightforward. Just change user.agi to user.SPE (or whatever.) Easy.

Current formula for JS: Base Speed:
// Declare Constants const user = this; const baseAgility = user.paramBasePlus(6); // Process Calculation let speed = Math.sqrt(baseAgility) + 1; // Return Value return speed;
Okay, now things get tricky. A non-default parameter, a custom one like Speed doesn't really have that paramBasePlus() equivalent, right? We're using JJMENET's Custom Parameters Plugin to allow them to function as stats that can grow with class level, but if that gives it a variable name like that we could swap in here, then we wouldn't know what that name is.

The JS parameters for Relative Speed, Acceleration, and Cast Time all invoke user.tpbSpeed(), user.tpbRelativeSpeed(), $gameParty.tpbReferenceTime, and just... a lot of TPB-related stats like this. I would assume most of those are set by default to key off AGI as well, but no clue where one would look to change those.

Honestly, it seems like so much work to try to weed AGI out of every instance of the code where it's used that it might be easier to just leave it in place, change the display name so AGI = "Speed," use that for the dedicated speed variable, and our new custom variable we're using in the accuracy calculations can be something else. The problem there is mostly just in finding a name for what to call it... we probably can't go with Agility at that point, because (to our knowledge? Unless I'm missing something?) you can't change the short names for the built-in parameters like AGI and kind of just have to work around those, even if the long-form display name can be whatever you want. If we don't think of a different name for the custom parameter, we'd have a situation where AGI = "Speed" and SPE = "Agility," which is just weird. 😛

Spoiler: And then...
Speaking of Cast Time, our second question pertains to how the CTP plugin handles variable modifications to the recharge time after taking one's turn. What we'd like to have is something like how Tactics Ogre does it, where the more you do during your turn, the more it "spends" from a sort of CT budget and thus the more deficit there is to make up before one's next turn. We're not talking about charge or casting times--everything one chooses to do during one's turn should be instant. However, if one does a basic attack with a fast and light weapon like a dagger versus a big heavy weapon like a warhammer, both attacks should go off instantly but the one who swung a warhammer should have longer to wait before their next turn arrives.

One possible way we thought to try to implement this came from the following description in their readme:
With TPB, skills and items with negative speed values will cause the battler to enter a "casting" state, meaning they have to wait extra time before the action takes off. With this delayed action execution, one might assume that if there is a positive speed value, the battler would require less time for their next turn. However, this isn't the case with RPG Maker MZ's TPB. By changing it to CTB, skills and items with positive speed values will have an impact on how full their CTB Speed will be in the following turn. A value of 2000 will put the turn at 50% ready, 1000 will put the gauge at 25% ready, 500 will put it at 12.5% ready, and so on. Notetags can also be used to influence this.
Right, so, maybe we could make 50% gauge a sort of default starting point, and heavier weapons and skills go down from there. An "average" weapon like a Sword could have, I don't know, 1500 speed, a Dagger could have 2000, a warhammer could go all the way down to 0, etc. This didn't quite feel right when tested, though... rather than making heavy weapons feel slower, it just made lighter ones feel too fast. It feels like this system is balanced such that 0 is the default for a reason. And if we go below that, then it becomes a charge/cast time thing... again, I don't want a delay on swinging the warhammer; I just want them to pay for it with the time until next turn after that.

Another possibility we saw:
<CTB After Speed: x%> - Used for: Skill, Item Notetags - After using the skill/item, the user's CTB Speed will be set to x%. - Replace 'x' with a percentile value representing the amount you want the CTB Speed to reset to after the skill/item's usage.
So 100% is normal/average; we could set Swords to that, make Daggers 110%, Warhammers 80%, or whatever numbers feel right, right? Ahahahaha no; it appears to function in practice more like an additive bonus than a "set value to," because 100% and even 50% or 25% were making the actor get infinite turns as long as they kept swinging. So maybe set it to like... 5% or something on a Dagger's because that's plus 5%, but... does that stack? Does 5% on a skill you use twice in a row mean "just set it to 105%" twice in a row or are they gaining an extra 5% on top of what they already had every time they use it? And is that really even how this works, or are we just imagining things? It was at around this point that I realized I was somewhat out of my depth, here, and decided maybe someone here would know better as far as how best to implement this system.

Whew. Hopefully that's it for now... I really can't thank you enough for hearing us out. 😊
I am NOT an expert. I have the same issues and questions. I've been playing with the allowed formulas and pulling my hair out. This is what I use now:

original CAST TIME FORMULA: let time = delay / user.tpbSpeed();
CHANGED TO: let time = delay / 100

With this formula, -1 skill speed is a 1% of a turn delay, so -100 makes you wait a turn till it activates, then another turn yet before you can act.


I don't know how to make the code read a stat other than the Agility. It seems like LUK would make sense for start of battle order. I do not even know what the initiative (start of combat) formula is actually doing. I would like to see CTB completely redone, but I can't find another plugin that works any better. Here are the skill settings to use for approximate desired turn speeds:

0% turn duration = +2000ss +skilltag <CTB After Speed: 100%>
20% turn duration = +2000ss +skilltag <CTB After Speed: 80%>
40% turn duration = +2000 skill speed
60% turn duration = +1400 skill speed
80% turn duration = +700 skill speed
100% turn duration = (no change)
120% turn duration = -20 skill speed
140% turn duration = -40 skill speed
160% turn duration = -60 skill speed
180% turn duration = -80 skill speed
200% turn duration = -100 skill speed

It works very well but one warning: Don't make too many skills at 0% and 20% execution speed. Using many in a row can stack up a free extra turn, due to the way it is calculated, so make sure they are not free cost, or that they have limited uses. This turns the glitch into a feature, but prevents game breaking exploitation.

@ZimXero, please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/visustella-battle-system-ctb-custom-parameters-turn-delays.160032/