Is there anyway to make a state that will change target's stats depend on how much target's HP percentage?
Change stat depend on HP percentage
● ARCHIVED · READ-ONLY
-
-
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. -
if I think you can easely put this kind of modification by script no?Yes there are ways to do it, not an easy way, but yes, its possible...
I love stat modifications...
(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 :Dif 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) -
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...
-
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 -
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? -
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 )
-
Erm, would you be kind and give me a demo for those scripts...? I almost don't understand how it works...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. -
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
-
Excuse me, but http://dekitarpg.wordpress.com/2013/03/14/d13x-statistic-control/ is this your blog? 'cause i can't find any demo in this.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
-
yep thats the page.
Follow the link below:
http://dekitarpg.wordpress.com/d13x-engine/
Its at the top of the page under "Demo's" :) -
So... with your modified stastic control, what should i write on state's notebox to make a state that will increase target's every stat by 1 point for every 1% lost HP?yep thats the page.
Follow the link below:
http://dekitarpg.wordpress.com/d13x-engine/
Its at the top of the page under "Demo's" :) -
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!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 :)
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. -
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".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 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 :) -
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 theOk, 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 ^_^
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...