RMMV Deal DMG back from last 3 turns?

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
404
Reaction score
60
First Language
English
Primarily Uses
Im trying to make a skill that checks how much damage you took in the last 3 turns and inflicts that to all enemies.
I was using UNDO global passive to keep track but I cannot figure out the math or formula to make this happen.

Using this in my skill
Code:
<Pre-Damage Eval>
var revenge = (user._undoHp3 - user.hp) + (user._undoHp2 - user.hp) + (user._undoHp1 - user.hp);
value = Math.floor(revenge);
</Pre-Damage Eval>
 

Kartoff

Villager
Member
Joined
Sep 21, 2020
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
I remember seeing a Yanfly tips and tricks video on something similar to this (works like the move "Bide" in Pokemon). Check this out, I'm sure it could be adapted to your situation!
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
404
Reaction score
60
First Language
English
Primarily Uses
I remember seeing a Yanfly tips and tricks video on something similar to this (works like the move "Bide" in Pokemon). Check this out, I'm sure it could be adapted to your situation!
Thanks! I saw that but I don't know how to adapt it, because its a passive and not an activated state. It could be any 3 consecutive turns. It's checking and keeping track only of the last 3 turns.
 

Kartoff

Villager
Member
Joined
Sep 21, 2020
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
All right, please bear with me as my solution involves utilizing four parts of the database: skills, states, common events, and troop events. It will center around Yanfly's "Bide" tips and tricks code, with a modification I made to ensure that there is a 3-turn damage cap. My solution is probably not the most efficient one out there, as that would probably require more complex scripting with less eventing, but if you're okay with my solution, here is how it goes:

First, you'd want to create your Skill. It's not meant to do anything other than to "release" your revenge state.

1.png


Then, on to the state itself. This is where we implement and modify Yanfly's "Bide" code in the notebox section. My modification involves adding a counter variable that increases by 1 each time the user takes damage if the counter has not yet reached past 3. Code below the picture.

2.png


Code:
<Custom Apply Effect>
// Upon applying Bide, set the Bide damage to 0.
user._bide = 0;
counts = 0;
</Custom Apply Effect>

<Custom Respond Effect>
// Check if the target took any HP damage. + Add DAMAGE CAP to 3 turns
if (target.result().hpDamage > 0 && counts <= 3) {
  // If the target did, raise the Bide damage by the HP damage taken.
  target._bide += target.result().hpDamage;
  counts += 1;
}
</Custom Respond Effect>

<Custom Remove Effect>
// Check if the party is in battle.
if ($gameParty.inBattle()) {
// Play animation 97 on the user.
user.startAnimation(97);
// Calculate the damage. The damage dealt is equal to 2x Bide damage.
var damage = Math.ceil(user._bide * 2);
// Get the group of alive enemies.
var enemies = user.opponentsUnit().aliveMembers();
// Loop through each of the enemies.
for (var i = 0; i < enemies.length; ++i) {
  // Get the enemy.
  var enemy = enemies[i];
  // Play animation 107 on the enemy.
  enemy.startAnimation(107);
  // Make the enemy take damage.
  enemy.gainHp(-damage);
  // Prompt the enemy's damage popup.
  enemy.startDamagePopup();
  // Clear the results of the enemy taking damage.
  enemy.clearResult();
  // Check if the enemy is dead.
  if (enemy.isDead()) {
    // If the enemy is dead, make it collapse.
    enemy.performCollapse();
  }
}
// Reset the Bide damage value.
user._bide = 0;
counts = 0
} // Check if the party is in battle.
</Custom Remove Effect>



After, we create a Common Event that will run at the end of every turn (which will go in Troop Events). This will refresh the user's "Revenge" state, allowing him to use it again and again throughout the battle. If you can make this work with Yanfly's Passive States, you could perhaps get rid of these steps. However, I wasn't able to make it work in the limited time that I had making this, so my apologies for that.


3.png4.png


Let me know how it goes, and goodluck with your project!
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
404
Reaction score
60
First Language
English
Primarily Uses
All right, please bear with me as my solution involves utilizing four parts of the database: skills, states, common events, and troop events. It will center around Yanfly's "Bide" tips and tricks code, with a modification I made to ensure that there is a 3-turn damage cap. My solution is probably not the most efficient one out there, as that would probably require more complex scripting with less eventing, but if you're okay with my solution, here is how it goes:

First, you'd want to create your Skill. It's not meant to do anything other than to "release" your revenge state.

View attachment 161624


Then, on to the state itself. This is where we implement and modify Yanfly's "Bide" code in the notebox section. My modification involves adding a counter variable that increases by 1 each time the user takes damage if the counter has not yet reached past 3. Code below the picture.

View attachment 161625


Code:
<Custom Apply Effect>
// Upon applying Bide, set the Bide damage to 0.
user._bide = 0;
counts = 0;
</Custom Apply Effect>

<Custom Respond Effect>
// Check if the target took any HP damage. + Add DAMAGE CAP to 3 turns
if (target.result().hpDamage > 0 && counts <= 3) {
  // If the target did, raise the Bide damage by the HP damage taken.
  target._bide += target.result().hpDamage;
  counts += 1;
}
</Custom Respond Effect>

<Custom Remove Effect>
// Check if the party is in battle.
if ($gameParty.inBattle()) {
// Play animation 97 on the user.
user.startAnimation(97);
// Calculate the damage. The damage dealt is equal to 2x Bide damage.
var damage = Math.ceil(user._bide * 2);
// Get the group of alive enemies.
var enemies = user.opponentsUnit().aliveMembers();
// Loop through each of the enemies.
for (var i = 0; i < enemies.length; ++i) {
  // Get the enemy.
  var enemy = enemies[i];
  // Play animation 107 on the enemy.
  enemy.startAnimation(107);
  // Make the enemy take damage.
  enemy.gainHp(-damage);
  // Prompt the enemy's damage popup.
  enemy.startDamagePopup();
  // Clear the results of the enemy taking damage.
  enemy.clearResult();
  // Check if the enemy is dead.
  if (enemy.isDead()) {
    // If the enemy is dead, make it collapse.
    enemy.performCollapse();
  }
}
// Reset the Bide damage value.
user._bide = 0;
counts = 0
} // Check if the party is in battle.
</Custom Remove Effect>



After, we create a Common Event that will run at the end of every turn (which will go in Troop Events). This will refresh the user's "Revenge" state, allowing him to use it again and again throughout the battle. If you can make this work with Yanfly's Passive States, you could perhaps get rid of these steps. However, I wasn't able to make it work in the limited time that I had making this, so my apologies for that.


View attachment 161626View attachment 161627


Let me know how it goes, and goodluck with your project!
Wow first off thank you so much for the time and the detailed approach!

Im not worried about re-applying the skill since I can just put a cool down for at least 3 turns, with the addition of a passive skill that on battle start gives the user revenge state and on action end checks if revenge affects user if not adds revenge.

However that would only work with at least a 6 turn cooldown because the state only keeps track of the dmg done when it is active.
If I use revenge on turn 3, it will work as ended but if I use it again on turn 5, it will only take in account the last 2 turns (4/5) and not the last 3.

Also it looks like your bind modification will stop keeping track after the count hits 3, so if I take 10 dmg,20 dmg, 30dmg all in one turn from different enemies the count will hit 3 and cap at 60. The following turns nothing will be added. The skill becomes reflects the last 3 sources of dmg or pretty much bind lol.
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
404
Reaction score
60
First Language
English
Primarily Uses
@Kartoff I think I figured it out thought, looking at what you did it inspired me!


A global state for the actor
Code:
<Custom Battle Effect>
// When a new battle starts, up to three turns of information regarding the HP of the actor will be stored.
user._revengeHp3 = 0;
user._revengeHp2 = 0;
user._revengeHp1 = 0;
user._revengeHp0 = 0;
</Custom Battle Effect>

<Custom Respond Effect>
// Check if the target took any HP damage. + Add DAMAGE CAP to 3 turns
if (target.result().hpDamage > 0) {
  // If the target did, raise the Bide damage by the HP damage taken.
  target._revengeHp0 += target.result().hpDamage;
}
</Custom Respond Effect>

<Custom Turn End Effect>
// At the end of each turn, apply the information of the previous turn to keep it up to date.
user._revengeHp3 = user._revengeHp2;
user._revengeHp2 = user._revengeHp1;
user._revengeHp1 = user._revengeHp0;
user._revengeHp0 = 0;
</Custom Turn End Effect>

The skill itself
Code:
<Pre-Damage Eval>
var revenge = (user._revengeHp3 + user._revengeHp2 + user._revengeHp1);
value = Math.floor(revenge);
</Pre-Damage Eval>
 

Kartoff

Villager
Member
Joined
Sep 21, 2020
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
You're welcome! Glad I helped in one way or the other!
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Woke up on an awful nightmare of being banned here because some mod didn't liked me in a super-heroes freeform round robin RP where I used throwing normal hammer as power and it was qualified being too OP. XD Nice to read you all guys. Will not wait next nightmares.
Staring at all the RPG Maker versions I have and realizing that my project has been a long time coming. But, I finally feel like I have the knowledge and experience to make it into something good.
We're almost done with the jam game! :D
I get scam calls all the time so today I gave them a piece of my mind. They hung up on me. Sweet revenge.

Forum statistics

Threads
104,321
Messages
1,005,560
Members
135,844
Latest member
andrewshetty123
Top