Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,863
Reaction score
12,410
First Language
English
Primarily Uses
RMMZ
I'm trying to replicate one of my mechanics concerning TP.

When TP is not preserved, the engine allocates a random amount of TP at the beginning of battle.
I would like this always to be between 11-18 so that the player is guaranteed to start with something.
In addition, whilst I'm happy with TP being generated by being hit, I would like the amount generated each turn to be based on the actor's AGI, not on damage dealt.

Is this possible in MZ?
Thank you.

EDIT
In case it helps (it probably doesn't) I did the first part with a small edit to the method 'Initialise TP' in the default script 'Game Battler'. I now don't remember how I got the TP to increase based on agility.
 
Last edited:

Maliki79

Veteran
Veteran
Joined
Mar 13, 2012
Messages
880
Reaction score
407
First Language
English
Primarily Uses
N/A
Hey there.

Both parts of your request are fairly easy to implement.
You will need a plugin for it, however.

For now, I can quickly write a snippet to hard code the request you wanted.
(If anyone else would want something like this, I could expand it.)

All that said, I'll need to know exactly how you want AGI to affect TP growth.
 
  • Like
Reactions: Kes

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
522
Reaction score
507
First Language
English
Primarily Uses
RMMZ
If you want to randomly initialize TP between 11 and 18, then you'd want to put this function into a .js file and add it to your project as a plugin:
JavaScript:
Game_Battler.prototype.initTp = function() {
    this.setTp(Math.randomInt(8) + 11);
};

For the increasing based on agility thing, I can't really tell you what to do, since I don't know the exact formula that you want to use, but these are the two relevant functions (they can be found in rmmz_objects.js):
JavaScript:
Game_Battler.prototype.onDamage = function(value) {
    this.removeStatesByDamage();
    this.chargeTpByDamage(value / this.mhp);
};

Game_Battler.prototype.chargeTpByDamage = function(damageRate) {
    const value = Math.floor(50 * damageRate * this.tcr);
    this.gainSilentTp(value);
};

The first function calls the next function, while passing (damage / max HP) to it. The next function uses that value to calculate an amount of TP, and also adds that amount of TP to the battler. You would need to edit them to reflect whatever it is that you want to do. Really, you could get away with just editing the second one... but I personally would probably get some kind of OCD issue from having a function named chargeTpByDamage that doesn't actually utilize damage when deciding how much TP to charge, and that would generally be considered an "un-clean" thing to do.
 
Last edited:
  • Like
Reactions: Kes

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
5,085
Reaction score
3,240
First Language
English
Primarily Uses
RMMV
In addition to Arthran's answer, depending on how complex your system is, VisuStella has an Enhanced TP System plugin that allows you to configure starting rate and what happens on damage via plugin parameters (you could reference Agi in there).

It also lets you have different methods of gaining TP and assign them on a per-actor/enemy basis.
 
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,863
Reaction score
12,410
First Language
English
Primarily Uses
RMMZ
@Maliki79 and @Arthran
Thank you both for your quick responses.
For the AGI increase, the purpose is to ensure that the player is not penalised if an actor has to use a turn to e.g. use an item. As I mentioned in my opening post, to my embarrassment I can't remember now how I did it, so the formula itself has vanished into the mist. I do know that it tended to produce an increase of around 8 - 10 per turn. However, in the light of ATT_Turan's reply, it seems that it won't be necessary to write something specific for this.
Once again, thank you for your replies.

@ATT_Turan Thank you for your encylopedic knowledge of what's out there. I think the VS plugin is going to be the option I pick as, having had a quick look at it, it also does a couple of other things that I've wanted to do for a long time
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
522
Reaction score
507
First Language
English
Primarily Uses
RMMZ
@Kes
Actually, now that I re-read your post, I see that the latter part of my answer was incorrect anyway. I misunderstood and thought that you wanted to make it so that when an actor gets hit, they gain TP based on their agility, rather than based on how much damage was done to them.
 

Latest Threads

Latest Posts

Latest Profile Posts

Well, I hope things go well tomorrow. I think I might be coming down with a cold, so gonna warm up some chicken soup and sleep.
Status too sad. Pls delete, mods. Thanks.
The most important thing to design your game for is fun. If a game isn't fun, why would anyone want to play it? Well, that and "can you play the game?". Anything else is incidental.
I just realized that I have been on this site for nearly 1/3 of my life...
How awesome is that?! Just in love with those eyes!!
Made by @Kato-A !
Hakuen double size_Kato.png

Forum statistics

Threads
124,677
Messages
1,165,180
Members
163,486
Latest member
Alerxuwu
Top