State Applied based on current HP/MP/TP

Neo Soul Gamer

Veteran
Veteran
Joined
Aug 10, 2012
Messages
653
Reaction score
391
First Language
English
Primarily Uses
N/A
So I found this script...

module Moon module Auto_States #--------------------------------------------------------------------------- # Dont touch here. These tags are hard coded in the game's scripts, # so if you change something here - it won't work. #--------------------------------------------------------------------------- BASE_BATTLER_STATES = [ #Actor or Enemy stats "hp" , # Current Hit Point "mhp", # Maximum Hit Point "mp" , # Current Magic Point "mmp", # Maximum Magic Point "tp" , # Current TP "atk", # ATtacK power "def", # DEFense power "mat", # Magic ATtack power "mdf", # Magic DeFense power "agi", # AGIlity "luk", # LUcK "hit", # HIT rate "eva", # EVAsion rate "cri", # CRItical rate "cev", # Critical EVasion rate "mev", # Magic EVasion rate "mrf", # Magic ReFlection rate "cnt", # CouNTer attack rate "hrg", # Hp ReGeneration rate "mrg", # Mp ReGeneration rate "trg", # Tp ReGeneration rate "tgr", # TarGet Rate "grd", # GuaRD effect rate "rec", # RECovery effect rate "pha", # PHArmacology "mcr", # Mp Cost Rate "tcr", # Tp Charge Rate "pdr", # Physical Damage Rate "mdr", # Magical Damage Rate "fdr", # Floor Damage Rate "exr" # EXperience Rate ]; ACTOR = [ # Actor only stats "name", # Name "nickname", # Nickname "exp", # Current XP "class", # Class "level" # Level ]; TAG_A = /<add if\s*(\w+)\s*(<=|!=|==|>=|=|<|>)\s*(\d*|['|"]\w+['|"])\s*>/i TAG_R = /<remove if\s*(\w+)\s*(<=|!=|==|>=|=|<|>)\s*(\d*|['|"]\w+['|"])\s*>/i endendclass RPG::State < RPG::BaseItem def auto? return false if get_auto.empty? return true end def check_auto_state @auto_state = Auto_States.new(@id) return false if @note.nil? note.each_line { |l| if Moon::Auto_States::TAG_A =~ l next if $1.nil? or $2.nil? or $3.nil? @auto_state.add($1,$2,$3, true) end if Moon::Auto_States::TAG_R =~ l next if $1.nil? or $2.nil? or $3.nil? @auto_state.add($1,$2,$3, false) end } return true if @auto_state.empty? return false end def get_auto check_auto_state if @auto_state.nil? return @auto_state endendclass Auto_States attr_reader :state_id def initialize(state_id) @state_id = state_id @state_conds = [] @remove_conds = [] end def empty? state_empty? and remove_empty? end def state_empty? @state_conds.empty? end def remove_empty? @remove_conds.empty? end def add(type, cond, para, adding) if adding @state_conds.push( Auto_State_Cond.new(type, cond, para) ) else @remove_conds.push( Auto_State_Cond.new(type, cond, para) ) end end def check(sub) return [false, @state_id] if state_empty? @state_conds.each { |sc| return [false, @state_id] unless sc.check(sub) } return [true, @state_id] end def check_r(sub) return [false, @state_id] if remove_empty? @remove_conds.each { |rc| return [false, @state_id] unless rc.check(sub) } return [true, @state_id] endendclass Auto_State_Cond def initialize(type, cond, para) @type = type @cond = cond @para = para end def corrections @type = "class.name" if /^class$/i =~ @type @cond = "==" if /^=$/ =~ @cond end def check(subject) bbs = Moon::Auto_States::BASE_BATTLER_STATES a = Moon::Auto_States::ACTOR return false unless bbs.include?(@type) or a.include?(@type) if a.include?(@type) return false unless subject.is_a?(Game_Actor) end begin corrections sub = "$game_actors" id = subject.id return true if eval("#{sub}[#{id}].#{@type} #{@cond} #{@para}") rescue print "Auto State Error: #{$!}\t" if $TEST end return false endendclass Game_System attr_reader :auto_states alias game_sys_auto_states_initialize_moon initialize def initialize game_sys_auto_states_initialize_moon @auto_states = [] for i in 0..$data_states.size state = $data_states next if state.nil? @auto_states.push(state.get_auto) if state.auto? end endendclass Scene_Battle alias auto_states_battle_process_event process_event def process_event auto_states_battle_process_event $game_party.members.each { |battler| auto_states(battler) } end alias auto_states_execute_action_moon execute_action def execute_action auto_states_execute_action_moon auto_states(@subject) if @subject.is_a?(Game_Actor) end def auto_states(sub) $game_system.auto_states.each { |s| next if s.nil? sc = s.check(sub) rc = s.check_r(sub) sub.add_state(sc[1]) if sc[0] and !rc[0] sub.remove_state(rc[1]) if sub.state?(rc[1]) and rc[0] } endend

It actually works incredibly well. However, I'd like for the effect to apply to enemies as well. As it is, it'll only work on party members. 

Wondering if anyone can edit this to produced the desired effect.
 

Titou

Villager
Member
Joined
Mar 13, 2014
Messages
5
Reaction score
2
First Language
French
Primarily Uses
Hi. Intresting script i think, but i don't understand how to use the tag : where and how.

If you can give more information about this i think it's can be awsome for me :)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,078
Members
137,580
Latest member
Snavi
Top