- Joined
- Mar 12, 2016
- Messages
- 14
- Reaction score
- 5
- First Language
- English
- Primarily Uses
- RMMV
Summary: I am looking to create states that will procure when Hit Points, Magic Points, and Technical Points reach certain levels for both actors and enemies in the hope of creating a type of juggling act for players as they have to watch and maintain a balance between each. If any one of these three indicator reaches zero, the actor or enemy dies. It appears to me that this may require some plugins, and more than likely a good amount of JavaScript.
Details:
State types:
Solution:
-----------------------
-----------------------
*Personal Note: I am a beginner when it comes to RMMV, Javascript and forums, but I am willing to learn. So if I make a mistake kindly let me know so I can do something to change it. Also, I ask that, if you give me advice, you take simple steps in explaining what I should do.
From what I can tell, the community here is amazing, and I hope to become a part of it.
Details:
State types:
- Buff
- Regeneration
- Dying
- Dead
- Current HP/MP/TP equals Max HP/MP/TP
- HP Buff - Attack and Defense are Doubled
- MP Buff - Magic Attack and Magic Defense are Doubled
- TP Buff - Luck and Agility are Doubled
- Current HP/MP/TP is less than 100% and more than 10% of Max HP/MP/TP
- HP Regeneration - HP recover at a rate of 1% of Max HP at the end of each turn
- MP Regeneration - MP recover at a rate of 1% of Max MP at the end of each turn
- TP Regeneration - TP recover at a rate of 1% of Max TP at the end of each turn
- Current HP/MP/TP is less than or equal to 10% and more than 0% of Max HP/MP/TP
- Bleed State - HP will be lost at a rate of 1% of Max HP at the end of each turn
- Limbo State - MP will be lost at a rate of 1% of Max MP at the end of each turn
- Exhaustion State - TP will be lost at a rate of 1% of Max TP at the end of each turn
- Bleed State - HP will be lost at a rate of 1% of Max HP at the end of each turn
- Current HP/MP/TP equals 0
- Death State - If HP, MP, or TP reaches 0, the target will recieve the 'death' state; any remaining HP, MP, or TP will also be reduced to 0.
Solution:
-----------------------
Thankfully I received some help from Fuguma (not sure where to find his ID number to link his name to the post), who did a fantastic job putting the code together. Fugama's page: https://forums.rpgmakerweb.com/index.php?members/fugama.38947/
With his permission I would like to share it:
Instructions:
- This plugin will require Yanfly's Core Engine plugin, Buffs & States Core plugin, and Auto Passive States plugin
- Create the Buffs and Debuffs that will be used (The max amount that can be used is 9; 3 per stat bar)
- Create a new state (this will be the auto passive state), but leave the icon blank, and leave the other settings alone.
- Add the 'HP/MP/TP Dependant States' code into the Notetag
- Input the State IDs of the Buffs and Debuffs into the Notetag; there are 2 locations to fill out
Code://list the states you want for each type from full bar, to under 10% bar. ex if state 31 is your full HP buff and 33 is your < 10% debuff : var hpList = [31, 32, 33]; var mpList = []; var hpList = []; var tpList = [];- Go into the Auto Passive States plugin and add the new passive state's ID to the Global list
Code:<custom battle effect> user.gainTp(user.maxTp()); //list the states you want for each type from full bar, to under 10% bar. ex if state 31 is your full HP buff and 33 is your < 10% debuff : var hpList = [31, 32, 33]; var mpList = []; var hpList = []; var tpList = []; //end of fill variables, touch the rest at your own risk var mpPercent = Math.floor((user.mp * 100)/user.mmp); var hpPercent = Math.floor((user.hp * 100)/user.mhp); var tpPercent = Math.floor((user.tp * 100)/user.maxTp()); //MP //first state check if (mpPercent >= 100 && !user.isStateAffected(mpList[0])){ for (num in mpList){ var num = mpList[num] if (num !== mpList[0]) user.removeState(num); } user.addState(mpList[0]) } //second state check if (mpPercent < 100 && mpPercent > 10 && !user.isStateAffected(mpList[1])){ for (num in mpList){ var num = mpList[num] if (num !== mpList[1]) user.removeState(num); } user.addState(mpList[1]) } //third state check if (mpPercent <= 10 && mpPercent > 0 && !user.isStateAffected(mpList[2])){ for (num in mpList){ var num = mpList[num] if (num !== mpList[2]) user.removeState(num); } user.addState(mpList[2]) } // 0 state check if (mpPercent <= 0){ user.gainTp(-user.tp); user.gainMp(-user.mp); user.gainHp(-user.hp); } //HP //first state check if (hpPercent === 100 && !user.isStateAffected(hpList[0])){ for (num in hpList){ var num = hpList[num]; if (num !== hpList[0]) user.removeState(num); } user.addState(hpList[0]) } //second state check if (hpPercent < 100 && hpPercent > 10 && !user.isStateAffected(hpList[1])){ for (num in hpList){ var num = hpList[num]; if (num !== hpList[1]) user.removeState(num); } user.addState(hpList[1]) } //third state check if (hpPercent <= 10 && hpPercent > 0 && !user.isStateAffected(hpList[2])){ for (num in hpList){ var num = hpList[num]; if (num !== hpList[2]) user.removeState(num); } user.addState(hpList[2]) } // 0 state check if (hpPercent <= 0){ user.gainTp(-user.tp); user.gainMp(-user.mp); user.gainHp(-user.hp); } //TP //first state check if (tpPercent === 100 && !user.isStateAffected(tpList[0])){ for (num in tpList){ var num = tpList[num] if (num !== tpList[0]) user.removeState(num); } user.addState(tpList[0]) } //second state check if (tpPercent < 100 && tpPercent > 10 && !user.isStateAffected(tpList[1])){ for (num in tpList){ var num = tpList[num] if (num !== tpList[1]) user.removeState(num); } user.addState(tpList[1]) } //third state check if (tpPercent <= 10 && tpPercent > 0 && !user.isStateAffected(tpList[2])){ for (num in tpList){ var num = tpList[num] if (num !== tpList[2]) user.removeState(num); } user.addState(tpList[2]) } // 0 state check if (tpPercent <= 0){ user.gainTp(-user.tp); user.gainMp(-user.mp); user.gainHp(-user.hp); } <custom battle effect> <custom turn end effect> //list the states you want for each type from full bar, to under 10% bar. ex if state 31 is your full HP buff and 33 is your < 10% debuff : var hpList = [31, 32, 33]; var mpList = []; var hpList = []; var tpList = []; //end of fill variables, touch the rest at your own risk var mpPercent = Math.floor((user.mp * 100)/user.mmp); var hpPercent = Math.floor((user.hp * 100)/user.mhp); var tpPercent = Math.floor((user.tp * 100)/user.maxTp()); //MP //first state check if (mpPercent >= 100 && !user.isStateAffected(mpList[0])){ for (num in mpList){ var num = mpList[num] if (num !== mpList[0]) user.removeState(num); } user.addState(mpList[0]) } //second state check if (mpPercent < 100 && mpPercent > 10 && !user.isStateAffected(mpList[1])){ for (num in mpList){ var num = mpList[num] if (num !== mpList[1]) user.removeState(num); } user.addState(mpList[1]) } //third state check if (mpPercent <= 10 && mpPercent > 0 && !user.isStateAffected(mpList[2])){ for (num in mpList){ var num = mpList[num] if (num !== mpList[2]) user.removeState(num); } user.addState(mpList[2]) } // 0 state check if (mpPercent <= 0){ user.gainTp(-user.tp); user.gainMp(-user.mp); user.gainHp(-user.hp); } //HP //first state check if (hpPercent === 100 && !user.isStateAffected(hpList[0])){ for (num in hpList){ var num = hpList[num]; if (num !== hpList[0]) user.removeState(num); } user.addState(hpList[0]) } //second state check if (hpPercent < 100 && hpPercent > 10 && !user.isStateAffected(hpList[1])){ for (num in hpList){ var num = hpList[num]; if (num !== hpList[1]) user.removeState(num); } user.addState(hpList[1]) } //third state check if (hpPercent <= 10 && hpPercent > 0 && !user.isStateAffected(hpList[2])){ for (num in hpList){ var num = hpList[num]; if (num !== hpList[2]) user.removeState(num); } user.addState(hpList[2]) } // 0 state check if (hpPercent <= 0){ user.gainTp(-user.tp); user.gainMp(-user.mp); user.gainHp(-user.hp); } //TP //first state check if (tpPercent === 100 && !user.isStateAffected(tpList[0])){ for (num in tpList){ var num = tpList[num] if (num !== tpList[0]) user.removeState(num); } user.addState(tpList[0]) } //second state check if (tpPercent < 100 && tpPercent > 10 && !user.isStateAffected(tpList[1])){ for (num in tpList){ var num = tpList[num] if (num !== tpList[1]) user.removeState(num); } user.addState(tpList[1]) } //third state check if (tpPercent <= 10 && tpPercent > 0 && !user.isStateAffected(tpList[2])){ for (num in tpList){ var num = tpList[num] if (num !== tpList[2]) user.removeState(num); } user.addState(tpList[2]) } // 0 state check if (tpPercent <= 0){ user.gainTp(-user.tp); user.gainMp(-user.mp); user.gainHp(-user.hp); } </custom turn end effect>
Notes:
- Since the code works with percentages, if an enemy or actor has 0 MP as their starting/default MP, then it doesn't kill them, which is neat if you want to create a mana-less character
- This code also makes all enemies and actors start off the battle with max TP due to this code segment:
Code:user.gainTp(user.maxTp());
And with that, I would say that this request has been completed, and the forum can be closed.
It seems to me that that the death state can remain as just one state for all three stats (HP/MP/TP). I was thinking that using HimeWorks' plugin "Progressive States" ( https://forums.rpgmakerweb.com/index.php?threads/progressive-states.50970/ ) for the 'Dying' states could work by having "Bleed", "Limbo" and "Exhaustion" turn into the 'Death' state when their associate stat finally hits 0. However, it might be easier just to have some JavaScript that uses if-then statements and set them up as follows:
Example:
if target.hp = target.mhp (then statement)
if target.hp < target. mhp (and statement) target.hp > target.mhp*0.1 (then statement)
if target.hp <= target.mhp*0.1 (and statement) target.hp != 0 (then statement)
if target.hp == 0 (then statement)
---------------------------------
In addition to everything else, I run into one particular issue: TP. I want TP to act more like MP, or in other words, a stamina bar. I added Yanfly's "Enhanced TP" (http://yanfly.moe/2016/01/08/yep-55-enhanced-tp/) to help make it act more like MP, but I had some issues. By default, RMMV has TP randomly generate at the beginning of a battle, but in order for TP to act like MP I cannot have that, so I changed the settings within the plugin to generate 0 TP at the start of the battle, and I allowed for TP to be preserved, allowing any remaining points to carry over once the battle is done. Then I noticed that 1) a new game will result in the actors having 0 TP to begin with and 2) enemies have 0 TP at the beginning of battle's. If I am to have a death state for having 0 TP, this creates a serious issue that would either mean an instant game over upon starting a new game, and if actors had any TP, enemies would instantly die once a battle starts.
Is there a way to change the starting TP so that it starts off at max, just like MP?
Example:
if target.hp = target.mhp (then statement)
if target.hp < target. mhp (and statement) target.hp > target.mhp*0.1 (then statement)
if target.hp <= target.mhp*0.1 (and statement) target.hp != 0 (then statement)
if target.hp == 0 (then statement)
---------------------------------
In addition to everything else, I run into one particular issue: TP. I want TP to act more like MP, or in other words, a stamina bar. I added Yanfly's "Enhanced TP" (http://yanfly.moe/2016/01/08/yep-55-enhanced-tp/) to help make it act more like MP, but I had some issues. By default, RMMV has TP randomly generate at the beginning of a battle, but in order for TP to act like MP I cannot have that, so I changed the settings within the plugin to generate 0 TP at the start of the battle, and I allowed for TP to be preserved, allowing any remaining points to carry over once the battle is done. Then I noticed that 1) a new game will result in the actors having 0 TP to begin with and 2) enemies have 0 TP at the beginning of battle's. If I am to have a death state for having 0 TP, this creates a serious issue that would either mean an instant game over upon starting a new game, and if actors had any TP, enemies would instantly die once a battle starts.
Is there a way to change the starting TP so that it starts off at max, just like MP?
In my attempt to create something like what I outlined above, I tried to use some plugins from Yanfly and Hime, and then add in what I needed through "Lunatic Mode" or JavaScript.
Before I had a clearer picture of what I wanted to do with states, I worked to create a constant state of MP Regeneration for actors and enemies. I tried to accomplish this through the use of Yanfly's "Auto Passive States" plugin ( http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/ ). I created a state, added a trait of 10% MP regeneration. I don't think it worked, so I removed the trait. I then added Yanfly's "Buff States Core" plugin ( http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/ ), and the following in the notes:
<Custom Turn End Effect>
user.gainMp(1);
</Custom Turn End Effect>
<Passive Condition: MP Below 100%>
This seemed to work, so I moved on to add another death state (one apart from the default "knockout") that would become applicable once the user's MP became 0. I copied the 'Knockout' state, then made it removable after 3 turns, added it to the auto passive states, and I added the following in the Notes so it would activate once MP became 0:
<Passive Condition: MP Below 1>
<Show Turns>
With this setup (the MP regen state, and the MP death state) I hoped that at 100% MP the regen would be off, below 100% it would be on, and at 0 MP the actor would have the death state. At 100%, no states were present, below 100% regen turned on, and at 0 MP the death state would activate, but the death state would immediately go away at the end of the turn because the regen state was still active, thus bringing MP to 1 and turning off the death state.
At this point I realized I needed a way to turn off regeneration once the death state kicked in, so I added Hime's plugin "Overriding states" ( https://forums.rpgmakerweb.com/index.php?threads/overriding-states.50889/ ) and put the following into the notes:
<override state: x>
'x' was the state ID of the MP regen. However, since both states were auto passive states, this did not remove or override the regen state.
Before I had a clearer picture of what I wanted to do with states, I worked to create a constant state of MP Regeneration for actors and enemies. I tried to accomplish this through the use of Yanfly's "Auto Passive States" plugin ( http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/ ). I created a state, added a trait of 10% MP regeneration. I don't think it worked, so I removed the trait. I then added Yanfly's "Buff States Core" plugin ( http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/ ), and the following in the notes:
<Custom Turn End Effect>
user.gainMp(1);
</Custom Turn End Effect>
<Passive Condition: MP Below 100%>
This seemed to work, so I moved on to add another death state (one apart from the default "knockout") that would become applicable once the user's MP became 0. I copied the 'Knockout' state, then made it removable after 3 turns, added it to the auto passive states, and I added the following in the Notes so it would activate once MP became 0:
<Passive Condition: MP Below 1>
<Show Turns>
With this setup (the MP regen state, and the MP death state) I hoped that at 100% MP the regen would be off, below 100% it would be on, and at 0 MP the actor would have the death state. At 100%, no states were present, below 100% regen turned on, and at 0 MP the death state would activate, but the death state would immediately go away at the end of the turn because the regen state was still active, thus bringing MP to 1 and turning off the death state.
At this point I realized I needed a way to turn off regeneration once the death state kicked in, so I added Hime's plugin "Overriding states" ( https://forums.rpgmakerweb.com/index.php?threads/overriding-states.50889/ ) and put the following into the notes:
<override state: x>
'x' was the state ID of the MP regen. However, since both states were auto passive states, this did not remove or override the regen state.
*Personal Note: I am a beginner when it comes to RMMV, Javascript and forums, but I am willing to learn. So if I make a mistake kindly let me know so I can do something to change it. Also, I ask that, if you give me advice, you take simple steps in explaining what I should do.
From what I can tell, the community here is amazing, and I hope to become a part of it.
Last edited:

