Call script TP lock to certain max amount.

Hello everyone!

Does it exist a call script to lock TP to max15 as long as the condition is not met?

More clearly:

I already use this call in a commun event to prevent a party member to get 100TP when it unlocks it's 1st skill.

$game_actors[12].tp=0.

Condition: actors_12 learnd the skill "Blow":

- Turn off switch "TP 12 CHECK"

if not:

- $game_actors[12].tp=0

End of condition.

This works perfectely.

Now, I wish for another party member to lock it's TPmax to 15 as long its skill "Frozen Bite" is not learned.

This member already has a skill, but only 5 TP to use it and not offensive. So, I dont want that member to be

able to reach 100TP and spam its new skill, cause it will be too easy.

Condition: actors_11 learnd the skill "Frost Bite":

- $game_actors[11].tpmax=100           #caped at 15 TP and finaly able to reach 100 TP#

- Turn off switch "TP 11 CHECK"

if not:

- if $game_actors[11].tp>15  -->  $game_actors[11].tp=15   

#Check after fight if need to adjust the TP if over 15 ( I wonder if it possible to call it in a condition page IN-BATTLE#

End of condition.

I know this call script do not work like that. It's just to show my guesses.

Thanks in advence.

EDIT: I tried this Tsukihime's script, but I'm getting error:

=begin============================================================================== ** TP Levels Author: Hime Version: 1.1 Date: May 19, 2012------------------------------------------------------------------------------ ** Change log 1.1 May 20 -Added TP Levels 1.0 May 19 -Initial release------------------------------------------------------------------------------ Change how much max TP you can have based on level Change how much damage you take based on how much TP you consume Your TP Level determines the skill cost and skill damage. You can increase or decrease your TP level by pressing the A and S keys. For skills that should use more than 100 TP, tag the skill with <tp: n> For some integer n <tp-gain: n> If you want a skill to gain more than 100 TP at a time The following script calls will change the max TP tpmax_set(amount, actor_id) tpmax_up(amount, actor_id) tpmax_down(amount, actor_id)===============================================================================end$imported = {} if $imported.nil?$imported["Tsuki_TPLevels"] = true#==============================================================================# ** Configuration. #==============================================================================module Tsuki module TP_Levels # Default Max TP Default_Max_TP = 100 Max_TP_Level = 5 Min_TP_Level = 1 Power_Up_Key = :X Power_Down_Key = :Y # Max amount of TP you can have per level TP_Table = {1 => Default_Max_TP, 2 => 200, 30 => 500, 40 => 1000 } # % extra TP to spend per TP power-level TP_Cost = "(level - 1) * 2" TP_Damage = "(level - 1) * 2" TP_Regex = /<tp:?\s*(\d+)\s*>/ TP_Gain_Regex = /<tp-gain:?\s*(\d+)\s*>/ endend#==============================================================================# ** Rest of the Script#==============================================================================module RPG class Skill < UsableItem include Tsuki::TP_Levels attr_reader :tp_power def load_notetags_tp_levels @tp_power = self.tp_cost > 0 ? true : false matches = TP_Regex.match(self.note) if matches @tp_cost = [matches[1].to_i, 0].max end matches = TP_Gain_Regex.match(self.note) if matches @tp_gain = [matches[1].to_i, 0].max end end endendmodule DataManager class << self alias :tp_levels_load_database :load_database alias :tp_levels_init :init end def self.init tp_levels_init load_notetags_tp_levels end def self.load_database tp_levels_load_database if $BTEST load_notetags_tp_levels end end def self.load_notetags_tp_levels groups = [$data_skills] for group in groups for obj in group next if obj.nil? obj.load_notetags_tp_levels end end endendclass Game_BattlerBase include Tsuki::TP_Levels attr_reader :tp_level alias :th_tp_levels_init_bbase :initialize def initialize th_tp_levels_init_bbase clear_tp_level end alias :th_tp_levels_skill_tp_cost :skill_tp_cost def skill_tp_cost(skill) if skill.tp_power (tp_multiplier(TP_Cost, @tp_level) * th_tp_levels_skill_tp_cost(skill)).ceil else th_tp_levels_skill_tp_cost(skill) end end def tp_multiplier(formula, level) [eval(TP_Cost), 1].max rescue 1 end def tp_level_up @tp_level = [@tp_level + 1, Max_TP_Level].min end def tp_level_down @tp_level = [@tp_level - 1, Min_TP_Level].max end def clear_tp_level @tp_level = 1 endendclass Game_Battler < Game_BattlerBase def apply_tp_modifier(user, item, damage) if item.is_a?(RPG::Skill) && item.tp_power damage * tp_multiplier(TP_Damage, user.tp_level) else damage end end # rewrite... def make_damage_value(user, item) value = item.damage.eval(user, self, $game_variables) value *= item_element_rate(user, item) value *= pdr if item.physical? value *= mdr if item.magical? value *= rec if item.damage.recover? value = apply_critical(value) if @result.critical value = apply_variance(value, item.damage.variance) value = apply_guard(value) value = apply_tp_modifier(user, item, value) @result.make_damage(value.to_i, item) end alias :th_tp_level_on_battle_end 😮n_battle_end def on_battle_end th_tp_level_on_battle_end clear_tp_level endendclass Game_Actor alias :th_tp_levels_setup_actor :setup def setup(actor_id) th_tp_levels_setup_actor(actor_id) get_max_tp end alias :th_tp_levels_level_up :level_up def level_up th_tp_levels_level_up get_max_tp end alias :th_tp_levels_level_down :level_down def level_down th_tp_levels_level_down get_max_tp end def get_max_tp new_tp = Default_Max_TP TP_Table.each do |level, max_tp| new_tp = max_tp if @level >= level end @max_tp = new_tp end def tp_rate @tp.to_f / max_tp end def max_tp return @max_tp end def increase_max_tp(amount) @max_tp += amount end def decrease_max_tp(amount) @max_tp = [@max_tp, 0].max end def set_max_tp(amount) @max_tp = amount endendclass Game_Interpreter def maxtp_set(amount, actor_id=1) $game_actors[actor_id].set_max_tp(amount) end def maxtp_up(amount, actor_id=1) $game_actors[actor_id].increase_max_tp(amount) end def maxtp_down(amount, actor_id=1) $game_actors[actor_id].decrease_max_tp(amount) endendclass Scene_Battle < Scene_Base alias :th_tp_level_create_skill_window :create_skill_window def create_skill_window th_tp_level_create_skill_window @skill_window.set_handler🙂X, method🙂tp_level_down)) @skill_window.set_handler🙂Y, method🙂tp_level_up)) end def tp_level_down BattleManager.actor.tp_level_down @skill_window.refresh @skill_window.activate end def tp_level_up BattleManager.actor.tp_level_up @skill_window.refresh @skill_window.activate endendclass Window_BattleSkill < Window_SkillList include Tsuki::TP_Levels def process_handling return unless open? && active return process_x if Input.trigger?(Power_Up_Key) && handle?🙂X) return process_y if Input.trigger?(Power_Down_Key) && handle?🙂Y) return super end def process_x Sound.play_cursor Input.update deactivate call_handler🙂X) end def process_y Sound.play_cursor Input.update deactivate call_handler🙂Y) endend
Event. com.png

Error.png
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
Knock knock!
I tried to make a script snippet that pretty much limit all actor's max TP to 15 as long as the skill conditions are not met.

Please edit the configuration part at the top of the script. If there is anything you want to change, let me know and I will

try to adjust the script snippet to suit your project.

Spoiler
#===============================================================================
# CONFIGURATION START
#===============================================================================

module Moogle_X
  module TP_LIMIT
    
    ACTOR_1_ID        = 11   # << Change this to "Frost Bite" user actor id number.
    ACTOR_1_SKILL_ID  = 0    # << Change this to "Frost Bite" skill ID number.
    ACTOR_2_ID        = 12   # << Change this to "Blow" user actor ID number.
    ACTOR_2_SKILL_ID  = 0    # << Change this to "Blow" skill ID number.
    
  end # TP_LIMIT
end # Moogle_X

#===============================================================================
# CONFIGURATION END
#===============================================================================

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
 
  #--------------------------------------------------------------------------
  # * Get Maximum Value of TP
  #--------------------------------------------------------------------------
  def max_tp
    if self.id == Moogle_X::TP_LIMIT::ACTOR_1_ID &&
        self.skill_learn?($data_skills[Moogle_X::TP_LIMIT::ACTOR_1_SKILL_ID])
      return 100
    elsif self.id == Moogle_X::TP_LIMIT::ACTOR_2_ID &&
        self.skill_learn?($data_skills[Moogle_X::TP_LIMIT::ACTOR_2_SKILL_ID])
      return 100
    else
      return 15 # <<< Default max tp when any condition is not met.
    end
  end # max_tp

end # class Game_Actor
Thank you Moogle_X, your script works.

Further informations:

I just need it for one ACTOR, and as long it does not learn 1 of 2 (or whatever how many skills it can learn)

the max TP is 15.

Dont lought at me 😛   I tried this. (Of course I'm getting Syntax Error), but I try to understand a little bit how it works.

I hope it will help you to see what I'm thinking.

# I dont know how to use "Spoiler" #

#===============================================================================# CONFIGURATION START#===============================================================================module Moogle_X module TP_LIMIT ACTOR_1_ID = 11 # << Change this to "Skill X" user actor id number. ACTOR_1_SKILL_ID = [132, 142] # << Change this to "Skill X" skill ID number. end # TP_LIMITend # Moogle_X#===============================================================================# CONFIGURATION END#===============================================================================#==============================================================================# ** Game_Actor#------------------------------------------------------------------------------# This class handles actors. It is used within the Game_Actors class# ($game_actors) and is also referenced from the Game_Party class ($game_party).#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Get Maximum Value of TP #-------------------------------------------------------------------------- def max_tp if self.id == Moogle_X::TP_LIMIT::ACTOR_1_ID && self.[132,142].any?skill_learn?{($data_skills[Moogle_X::TP_LIMIT::ACTOR_1_SKILL_ID])} return 100 else return 15 # <<< Default max tp when any condition is not met. end end # max_tpend # class Game_Actor
Thanks in advance.

EDIT: Came back from work and dident see you reply yet.

So I started to "random/guess" how to find out something by my self.

Well... All what I got, was a lot of SyntaxErrors over SyntaxErrors, then Errors after errors again.

And after over 2 hours of sceams D:<   and cries ;_; , what a surprise! 😮   I was finaly able to run a test! 🤣

And it looks to work.

Dont ask me how I did it, I made it like a LEGO game. I've Copy/Paste parts of codes here and there.

I'd like to know if the code is "Stable" and will not cause crash or something.

# == Fridjah's script test == # # Monday, October 12th 2015 9:15 A.M. ########################################class Game_Actor < Game_Battler def max_tp if $game_actors[11]&& [132,142].any? {|i| self.skill_learn?($data_skills)} return 100 else return 15 end endendI dont even know what mean | i | :distrust:
Sorry for not replying quickly. I just got home from day job as well. Here is the updated script. Now, the script will only work for one

actor only. Let me know if you want to change anything.

Spoiler
#===============================================================================
# CONFIGURATION START
#===============================================================================

module Moogle_X
  module TP_LIMIT
    
    ACTOR_ID        = 1   # << Change this actor id number.
    
    # Put any skill id numbers below inside the bracket. If any of the skill is
    # learned by the actor above, he/she will have 100 max TP.
    # Otherwise, if none of the skill below is learned,
    # the max TP amount will be 15.
    SKILL_LIST      = [132,142]
    
  end # TP_LIMIT
end # Moogle_X

#===============================================================================
# CONFIGURATION END
#===============================================================================

#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles actors. It is used within the Game_Actors class
# ($game_actors) and is also referenced from the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
 
  #--------------------------------------------------------------------------
  # * Get Maximum Value of TP
  #--------------------------------------------------------------------------
  def max_tp
    if self.id == Moogle_X::TP_LIMIT::ACTOR_ID
      tp_limit = true
      for i in Moogle_X::TP_LIMIT::SKILL_LIST
        tp_limit = false if skill_learn?($data_skills)
      end
      return 15 if tp_limit   # << Max TP if not learning any skills above.
      return 100 if !tp_limit # << Max TP if learn any (even just 1) of
                              # the skills above in SKILL_LIST.
    else
      return 100 # <<< Default max tp for everyone.
    end
  end # max_tp

end # class Game_Actor
Dont worry Moogle_X, and thank you for your help.

Your script works perfectely and I dident get weird issues.

I'll definitly use it!

PS: About the " lol script" I wrote:

It's the first time I'm doing that kind of stuff.

You look to be a pro-scripter, and I'd wish to know what do you think about my script.

Well, I dont asking you to teach me, but if you just have few minutes to tell me what you think.

Best regards, Fridjah
When you say "lol script" I assume you are refering to this code.

Spoiler
# == Fridjah's script test == #
# Monday, October 12th 2015 9:15 A.M. #
#######################################

class Game_Actor < Game_Battler
def max_tp
if $game_actors[11]&&
[132,142].any? {|i| self.skill_learn?($data_skills)}
return 100
else
return 15
end
end
 

Actually, I am not really familiar with "any?" method. I assume it's just checking if some condition is true or false.

It seems that the code will check the if the actor[11] has learn skill 132 or 142. If the result is true, the max tp will be 100.

Otherwise, it will be 15. There is a potential issue here...

The max_tp method is something that is used by every actor in the game, not just actor[11]. Therefore, all other actor will

have their max tp limited to 15 regardless of their skills.

This is fine if that's what you were intending to do. But, if you prefer the other actors to have the usual 100 max tp, you need one

extra conditional branch like this.

 

Spoiler
# == Fridjah's script test == #
# Monday, October 12th 2015 9:15 A.M. #
#######################################

class Game_Actor < Game_Battler
def max_tp
if self.id == 11

if [132,142].any? {|i| self.skill_learn?($data_skills)}
return 100
else
return 15
end

end

return 100
end
Yes of course, my code.

You were right, after a deeper test with my code, all actors are caped at 15.

I understand that, now.

if self.id == 11You just missed a "end" at the end.

Well, thank you very much for your help!

Good luck on your "Roguelike battle system script" !

Original thread: https://forums.rpgmakerweb.com/threads/call-script-tp-lock-to-certain-max-amount.45715/