Change stat depend on HP percentage

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
Is there anyway to make a state that will change target's stats depend on how much target's HP percentage?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
Yes there are ways to do it, not an easy way, but yes, its possible...
 

I love stat modifications...

For an example of how you would do this, as that will probably help...

Step 1 - Download THIS script and any other param mod scripts of mine you want to use, along with my core script.

Step 2 - Find all instances of the code within the script that looks like this...

  #--------------------------------------------------------------------------  # Param Plus  #--------------------------------------------------------------------------  def param_plus(param_id)    base  = super    base += actor.pars[param_id]    base += self.class.pars[param_id]    base += equips.compact.inject(0) {|r, i| r += (i.pars[param_id]+i.params[param_id])}    base += states.compact.inject(0) {|r, i| r += i.pars[param_id] }    if $D13x[:Skill_Lv]      base += skills.compact.inject(0) {|r, i| r += (i.pars[param_id]*      Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_i}    else      base += skills.compact.inject(0) {|r, i| r += i.pars[param_id] }    end    base  endThis code is what is creating the param values (there is also similar code for x/s params / elements / parent state etc, depending on which scripts you are using.)

Then you change the line which checks the state param value and make it read from the actor/battlers hp_rate.. like this...

  #--------------------------------------------------------------------------  # Param Plus  #--------------------------------------------------------------------------  def param_plus(param_id)    base  = super    base += actor.pars[param_id]    base += self.class.pars[param_id]    base += equips.compact.inject(0) {|r, i| r += (i.pars[param_id]+i.params[param_id])}    base += states.compact.inject(0) {|r, i| r += (i.pars[param_id] * hp_rate).to_i }   # << CHANGED LINE HERE    if $D13x[:Skill_Lv]      base += skills.compact.inject(0) {|r, i| r += (i.pars[param_id]*      Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_i}    else      base += skills.compact.inject(0) {|r, i| r += i.pars[param_id] }    end    base  endOf course, this would make every single stat modification state include the hp_rate modification, but what if you only want one state that does this along with other states that just increase stats?

  #--------------------------------------------------------------------------  # Param Plus  #--------------------------------------------------------------------------  def param_plus(param_id)    base  = super    base += actor.pars[param_id]    base += self.class.pars[param_id]    base += equips.compact.inject(0) {|r, i| r += (i.pars[param_id]+i.params[param_id])}    base += param_plus_state_mod(param_id)    if $D13x[:Skill_Lv]      base += skills.compact.inject(0) {|r, i| r += (i.pars[param_id]*      Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_i}    else      base += skills.compact.inject(0) {|r, i| r += i.pars[param_id] }    end    base  end  #--------------------------------------------------------------------------  #  #--------------------------------------------------------------------------  def param_plus_state_mod(param_id)    states.compact.inject(0) do |r, i|      if i.id == 2 # State id 2        r += i.pars[param_id] * hp_rate        next # To goto next state and disregard adding params from code below.      end      if i.id == 3 # State id 3        r += i.pars[param_id] * mp_rate        next # To goto next state and disregard adding params from code below.      end      r += i.pars[param_id]    end  endObviously, you can add to this code for as many states as you want, you wan also easily change the hp_rate for other rates, or your own calculations.

Edit:

I might just update my scripts to accommodate such modifications easier...

until then, if you have any questions, feel free to ask.
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Yes there are ways to do it, not an easy way, but yes, its possible...

I love stat modifications...
if I think you can easely put this kind of modification by script no?

(event it is pretty harsh to do but script it seem not so much hard)
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
if I think you can easely put this kind of modification by script no?

(event it is pretty harsh to do but script it seem not so much hard)
Lol I already edited to give explicit instruction on a how-to code this into a project and will probably update to include the feature :D
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Hum okai Just question like that why did you use Base? (I never saw this myself in rgss ) so i am pretty curious of his utility...
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
base is just the name i decided to use for this particular local variable. its only use as a place marker for the stat value before each modification takes place.

I noticed that it shows in blue on this site due to the code highlighting, but it doesnt in rpgm script editor, just standard black text p
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
ho okai it mistake me a little xD...

and I never used next but I guess is for force to go to a next part hum?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
yea, next just moves onto the next object in the array. Just to avoid adding the param value  * hp rate then adding the param value on top. I like using next. Very usefull )
 

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
Yes there are ways to do it, not an easy way, but yes, its possible...

I love stat modifications...

For an example of how you would do this, as that will probably help...

Step 1 - Download THIS script and any other param mod scripts of mine you want to use, along with my core script.

Step 2 - Find all instances of the code within the script that looks like this...

  #--------------------------------------------------------------------------  # Param Plus  #--------------------------------------------------------------------------  def param_plus(param_id)    base  = super    base += actor.pars[param_id]    base += self.class.pars[param_id]    base += equips.compact.inject(0) {|r, i| r += (i.pars[param_id]+i.params[param_id])}    base += states.compact.inject(0) {|r, i| r += i.pars[param_id] }    if $D13x[:Skill_Lv]      base += skills.compact.inject(0) {|r, i| r += (i.pars[param_id]*      Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_i}    else      base += skills.compact.inject(0) {|r, i| r += i.pars[param_id] }    end    base  endThis code is what is creating the param values (there is also similar code for x/s params / elements / parent state etc, depending on which scripts you are using.)

Then you change the line which checks the state param value and make it read from the actor/battlers hp_rate.. like this...

  #--------------------------------------------------------------------------  # Param Plus  #--------------------------------------------------------------------------  def param_plus(param_id)    base  = super    base += actor.pars[param_id]    base += self.class.pars[param_id]    base += equips.compact.inject(0) {|r, i| r += (i.pars[param_id]+i.params[param_id])}    base += states.compact.inject(0) {|r, i| r += (i.pars[param_id] * hp_rate).to_i }   # << CHANGED LINE HERE    if $D13x[:Skill_Lv]      base += skills.compact.inject(0) {|r, i| r += (i.pars[param_id]*      Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_i}    else      base += skills.compact.inject(0) {|r, i| r += i.pars[param_id] }    end    base  endOf course, this would make every single stat modification state include the hp_rate modification, but what if you only want one state that does this along with other states that just increase stats?

  #--------------------------------------------------------------------------  # Param Plus  #--------------------------------------------------------------------------  def param_plus(param_id)    base  = super    base += actor.pars[param_id]    base += self.class.pars[param_id]    base += equips.compact.inject(0) {|r, i| r += (i.pars[param_id]+i.params[param_id])}    base += param_plus_state_mod(param_id)    if $D13x[:Skill_Lv]      base += skills.compact.inject(0) {|r, i| r += (i.pars[param_id]*      Skill_Levels::Exp_Set[i.exp_set][@skills_lv[i.id]][2] ).to_i}    else      base += skills.compact.inject(0) {|r, i| r += i.pars[param_id] }    end    base  end  #--------------------------------------------------------------------------  #  #--------------------------------------------------------------------------  def param_plus_state_mod(param_id)    states.compact.inject(0) do |r, i|      if i.id == 2 # State id 2        r += i.pars[param_id] * hp_rate        next # To goto next state and disregard adding params from code below.      end      if i.id == 3 # State id 3        r += i.pars[param_id] * mp_rate        next # To goto next state and disregard adding params from code below.      end      r += i.pars[param_id]    end  endObviously, you can add to this code for as many states as you want, you wan also easily change the hp_rate for other rates, or your own calculations.

Edit:

I might just update my scripts to accommodate such modifications easier...

until then, if you have any questions, feel free to ask.
Erm, would you be kind and give me a demo for those scripts...? I almost don't understand how it works...
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
you can find a master demo on my blog which has all of my scripts within it, but im not gonna make one just for this issue sorry. Im generally very busy :p
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
If you have made the modifications stated above, whenever you add the notetag

<stat: value>   # eg. <mhp: 100> the value states, ie, 100, will be multiplied by the actors hp_rate.
So, if you wanted to increase the HP by 1 for every 1% HP the actor has, you would use...

<mhp: 100>
If you wanted the HP to increase by 5 for every 1% hp you would use...

<mhp: 500>
hope that helps :)
 

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
If you have made the modifications stated above, whenever you add the notetag

<stat: value>   # eg. <mhp: 100>the value states, ie, 100, will be multiplied by the actors hp_rate.
So, if you wanted to increase the HP by 1 for every 1% HP the actor has, you would use...

<mhp: 100>If you wanted the HP to increase by 5 for every 1% hp you would use...

<mhp: 500>hope that helps :)
Thank you! It's really a big help!

Ah, excuse me, but when i use your stastic control original, it works normally, but when i use your modified one, the game will crash with "stack level too deep" popped up when ever i tried to add that state. 
 
Last edited by a moderator:

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
The most common cause of the stack level error is when you have two versions of the same script. Are you sure that there is only one copy of the script in your project?
 

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
The most common cause of the stack level error is when you have two versions of the same script. Are you sure that there is only one copy of the script in your project?
I've made a new project, added only two script: your core and your stastic, but it still have "stack level too deep".
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
I have no idea why thats happening.

I am a little busy right now, but I will look into that later today - I will also update the stat control script to just do this, that way it will be done correctly and there will be no need for anyone to modify the code to make it do this :)
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,513
Reaction score
3,202
First Language
Binary
Primarily Uses
RMMZ
Ok, sorry for the delay. I have been very busy the past few days.

Anyway. I made the update to the script...

LINK

Once you have pasted the new script into your project, put the following snippet into a new script page BELOW the stat control script.

#===============================================================================#                      http://dekitarpg.wordpress.com/                         #===============================================================================module HP_Rate_Stat_Mods#===============================================================================  #-----------------------------------------------------------------------------  # CUSTOMIZABLE SECTION !!  #-----------------------------------------------------------------------------  def self.get_state_param_values(state,param_id,battler)    # // Returns value * hp rate is state is id 2    return state.pars[param_id] * battler.hp_rate if state.id == 2    # // Returns value * mmp rate if state id is 3    return state.pars[param_id] * battler.mp_rate if state.id == 3    # // Returns par value * hp rate if state id is 4 and param id is 0 (MHP)    return state.pars[param_id] * battler.hp_rate if state.id == 4 && param_id == 0    # // Returns normal pars value.    return state.pars[param_id]  end  #-----------------------------------------------------------------------------  # CUSTOMIZABLE SECTION !!  #-----------------------------------------------------------------------------end#===============================================================================#                       END OF CUSTOMIZATION SECTION#===============================================================================#                      http://dekitarpg.wordpress.com/                         #===============================================================================class Game_Actor#===============================================================================  #-----------------------------------------------------------------------------  # Param Plus [states]  #-----------------------------------------------------------------------------  def param_plus_states_pars(param_id)    states.compact.inject(0) do |value,state|      value += HP_Rate_Stat_Mods.get_state_param_values(state,param_id,self)    end  end  #-----------------------------------------------------------------------------  #  #-----------------------------------------------------------------------------end#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # Param Plus [states]  #-----------------------------------------------------------------------------  def param_plus_states_pars(param_id)    states.compact.inject(0) do |value,state|      value += HP_Rate_Stat_Mods.get_state_param_values(state,param_id,self)    end  end  #-----------------------------------------------------------------------------  #  #-----------------------------------------------------------------------------end#===============================================================================#                      http://dekitarpg.wordpress.com/                         #===============================================================================
There should be enough documentation in there for you to be able to get it fully working ^_^
 

Kuro Neko

Veteran
Veteran
Joined
Sep 26, 2013
Messages
173
Reaction score
15
First Language
English
Primarily Uses
Ok, sorry for the delay. I have been very busy the past few days.

Anyway. I made the update to the script...

LINK

Once you have pasted the new script into your project, put the following snippet into a new script page BELOW the stat control script.

#===============================================================================#                      http://dekitarpg.wordpress.com/                         #===============================================================================module HP_Rate_Stat_Mods#===============================================================================  #-----------------------------------------------------------------------------  # CUSTOMIZABLE SECTION !!  #-----------------------------------------------------------------------------  def self.get_state_param_values(state,param_id,battler)    # // Returns value * hp rate is state is id 2    return state.pars[param_id] * battler.hp_rate if state.id == 2    # // Returns value * mmp rate if state id is 3    return state.pars[param_id] * battler.mp_rate if state.id == 3    # // Returns par value * hp rate if state id is 4 and param id is 0 (MHP)    return state.pars[param_id] * battler.hp_rate if state.id == 4 && param_id == 0    # // Returns normal pars value.    return state.pars[param_id]  end  #-----------------------------------------------------------------------------  # CUSTOMIZABLE SECTION !!  #-----------------------------------------------------------------------------end#===============================================================================#                       END OF CUSTOMIZATION SECTION#===============================================================================#                      http://dekitarpg.wordpress.com/                         #===============================================================================class Game_Actor#===============================================================================  #-----------------------------------------------------------------------------  # Param Plus [states]  #-----------------------------------------------------------------------------  def param_plus_states_pars(param_id)    states.compact.inject(0) do |value,state|      value += HP_Rate_Stat_Mods.get_state_param_values(state,param_id,self)    end  end  #-----------------------------------------------------------------------------  #  #-----------------------------------------------------------------------------end#===============================================================================class Game_Enemy#===============================================================================  #-----------------------------------------------------------------------------  # Param Plus [states]  #-----------------------------------------------------------------------------  def param_plus_states_pars(param_id)    states.compact.inject(0) do |value,state|      value += HP_Rate_Stat_Mods.get_state_param_values(state,param_id,self)    end  end  #-----------------------------------------------------------------------------  #  #-----------------------------------------------------------------------------end#===============================================================================#                      http://dekitarpg.wordpress.com/                         #===============================================================================There should be enough documentation in there for you to be able to get it fully working ^_^
Excuse me if i'm wrong, but i have to use your core script, your new stastic control and this hp stat mods should be put in a script page under stastic control. And, i've to edit the 

return state.pars[param_id] * battler.hp_rate if state.id == 2with the state ID that need to be synchro with target's HP, am i wrong? I've tested this in a new project like this:

- Edit that part to: 

return state.pars[param_id] * battler.hp_rate if state.id == 25- Make a state 25 with "<mmp: 100>" in that skill's notebox

- Make a skill will add state 25 to the user

And... tested, but everytime i add that state to a target, the game will crash with "stack level too deep". I wonder if i'm using it wrong...
 

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

Latest Threads

Latest Posts

Latest Profile Posts

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
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,015
Members
137,563
Latest member
MinyakaAeon
Top