SIMPLE TP SCRIPTING REQUEST (IN VX ACE)
Posts
Pages:
1
I'm a little embarrassed asking this since it's probably really simple, but I haven't been able to figure it out.
I'm using the "Preserve TP" flag on all party members so they retain TP from battle to battle, but I wanted to have them lose 20% of their TP after every battle to encourage TP usage while still letting the party retain some of it.
I have a common event that runs after battles, but then I noticed that there's no handlers for modifying TP in VX Ace's standard commands. Is there a simple piece of script code I could put there that would reduce everyone in the party's current TP by 20%?
Thanks a lot! :D
I'm using the "Preserve TP" flag on all party members so they retain TP from battle to battle, but I wanted to have them lose 20% of their TP after every battle to encourage TP usage while still letting the party retain some of it.
I have a common event that runs after battles, but then I noticed that there's no handlers for modifying TP in VX Ace's standard commands. Is there a simple piece of script code I could put there that would reduce everyone in the party's current TP by 20%?
Thanks a lot! :D
You can change TP directly via a script call command such as:
Replace id with the ID# of the actor whose TP you want to change and this will set their TP to 20. To change everybody's TP you can do this:
$game_party has the information on the player's party and members is all the members in the party or if the player is in battle all the actors in said battle. This will go through each actor and reduce their TP to 80% with the decimal truncated off. I'd put this in the code called when battle ends: In the BattleManager class in the battle_end method on line 268. This is called when a battle is ending in either victory or defeat or running away so it'll always reduce the party's TP. I think this should do the trick:
This will make the game reduce the battle member's TP by 80% when battle ends then it will call the rest of the code that ends the battle. If you want to change it so TP only happens on a win/loss/escape you can change the battle_end part to:
Additionally if you want to change who the TP loss happens to you can change the .members to .battle_members or .all_members like so:
e: runaway text in code tags
$game_actors[id].tp = 20
Replace id with the ID# of the actor whose TP you want to change and this will set their TP to 20. To change everybody's TP you can do this:
$game_party.members.each do |actor| actor.tp = (actor.tp * 0.8).to_i end
module BattleManager # This is so the original battle_end method is called. Extra Ruby voodoo due to how the battle_end method is defined class << self alias battle_end_tploss_original battle_end unless $@ end # This is called when a battle ends def self.battle_end(result) # Change the TP of every actor who took part in battle $game_party.members.each do |actor| actor.tp = (actor.tp * 0.8).to_i end # Do the rest of the battle_end code so the battle will actually end battle_end_tploss_original(result) end end
def self.battle_end(result) # Result is what the battle ended with. 0 is victory, 1 is escape, 2 is loss. #Let's assume only a victory will cause TP loss if result == 0 # So only do the TP loss work when result is zero aka a victory $game_party.members.each do |actor| actor.tp = (actor.tp * 0.8).to_i end end battle_end_tploss_original(result) end
Additionally if you want to change who the TP loss happens to you can change the .members to .battle_members or .all_members like so:
# This will explicitly only affect the actors who can take part in a fight. # .members should be good enough unless you're doing an event script call command when you aren't in battle as #.members will affect all party members when you aren't in battle $game_party.battle_members.each do |actor| # This will _always_ affect every party member even if they didn't take part in the fight $game_party.all_members.each do |actor|
e: runaway text in code tags
Pages:
1















