[RMVX ACE] RANDOMIZE TRG
Posts
Pages:
1
Is it possible to randomize TRG(TP Regeneration Rate)?
I want to make a spell to regenerate random number of TP per turn.
I want to make a spell to regenerate random number of TP per turn.
Do you want the spell to regenerate TP instantly or by a certain amount of turns. Like over the next 3 turns each player regains some TP.
It's possible!
Assuming that the said spell will inflict a specific state (that applies the random TRG), this will do the job:
Edit: The previous is good if you only want a certain state to restore random amounts of TP. If you want ALL states with a TRG feature to go random, use this:
Assuming that the said spell will inflict a specific state (that applies the random TRG), this will do the job:
class Game_Battler < Game_BattlerBase def regenerate_tp state_id = 1 # The ID of the state to be used min = 0 # The minimum amount of TP to be restored max = 100 # The maximum amount of TP to be restored self.tp += self.state?(state_id) ? (min + rand(max)) : 100 * trg end end
Edit: The previous is good if you only want a certain state to restore random amounts of TP. If you want ALL states with a TRG feature to go random, use this:
class Game_Battler < Game_BattlerBase def regenerate_tp min = 0 # The minimum amount of TP to be restored max = 100 # The maximum amount of TP to be restored self.tp += (min + rand(max)) end end
author=kory_toombs
Do you want the spell to regenerate TP instantly or by a certain amount of turns. Like over the next 3 turns each player regains some TP.
I wanted to make a spell which regenerate TP next few turns.
karins gave me a perfect answer but I appreciate your help too!
author=karins_soulkeeper
It's possible!
Assuming that the said spell will inflict a specific state (that applies the random TRG), this will do the job:
class Game_Battler < Game_BattlerBase
def regenerate_tp
state_id = 1 # The ID of the state to be used
min = 0 # The minimum amount of TP to be restored
max = 100 # The maximum amount of TP to be restored
self.tp += self.state?(state_id) ? (min + rand(max)) : 100 * trg
end
end
karins,you perfectly solved the problem.
Thank you for your help!
Shouldn't it be min + rand(max-min)?
min + rand(max) can return values higher than max if min isn't 0.
min + rand(max) can return values higher than max if min isn't 0.
Pages:
1
















