Deal damage equal to how much health recovered in fight?

TriceratopsX

Veteran
Veteran
Joined
May 2, 2016
Messages
264
Reaction score
404
First Language
English
Primarily Uses
RMMV
Hello, I want to make a skill that damages the enemy equal to how much hp they've recovered throughout the battle, I've checked yanfly's tips and tricks and I didn't see anything like this. (though I admit I might have missed it as I haven't watched all of them) Any and all help is appreciated as always!
 

Traveling Bard

The Bard
Veteran
Joined
Jul 4, 2012
Messages
564
Reaction score
482
First Language
English
Primarily Uses
How much the enemy has recovered during the fight or how much the hero recovered?
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
437
Reaction score
195
First Language
English
Primarily Uses
RMMV
You're a little vague on the exact effect. Is the effect based on how much the target has healed? How much the user has healed? What I can tell you is that to create such an effect, you'll need some way to monitor the amount of healing that's occurred in that battle. If you have Yanfly's Auto Passive States, Skill Core, Damage Core, and Buffs & States Core, such an effect may be possible.

http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/

http://yanfly.moe/2015/11/07/yep-25-damage-core/

http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/

http://yanfly.moe/2015/10/13/yep-8-skill-core/

The video below is for an Undo effect, which has a few common elements with what you're trying to do.


Put altogether, we can do something like this:

For the state:

<Custom Battle Effect>
user._healedAmount = 0;
</Custom Battle Effect>

<Custom Respond Effect>
if (this.isHpEffect() && value < 0) {
target._healedAmount += value;
}
</Custom Respond Effect>

For the skill:

<Damage Formula>
if (target._healedAmount !== undefined) {
value = target._healedAmount;
} else {
value = 0;
}
</Damage Formula>

Try that, but make sure that in the Auto Passives plugin, set the state under Global Passives. That way, everyone automatically gains the state.
 

TriceratopsX

Veteran
Veteran
Joined
May 2, 2016
Messages
264
Reaction score
404
First Language
English
Primarily Uses
RMMV
Oops sorry, I meant specifically how much the target has recovered throughout the battle
 

shockra

Slightly Crazy Programmer
Veteran
Joined
Feb 16, 2016
Messages
437
Reaction score
195
First Language
English
Primarily Uses
RMMV
In that case, the code I posted above should work. Again, make sure that in the Auto Passives plugin page, set the State ID in Global Passives. Otherwise, it won't work correctly.
 

TriceratopsX

Veteran
Veteran
Joined
May 2, 2016
Messages
264
Reaction score
404
First Language
English
Primarily Uses
RMMV
Awesome thanks a lot! This is the last skill I needed for my project.

EDIT: Alright just put the skill together, wanna make sure I didn't royally screw up somehow (wouldn't be the first time I managed to fail simple instructions)

So the states notebox looks like this-
<Custom Battle Effect>

// When a new battle starts, up to three turns of information regarding the HP of the actor will be stored.

user._undoHp0 = user.hp;

user._undoHp1 = user.hp;

user._undoHp2 = user.hp;

user._undoHp3 = user.hp;

</Custom Battle 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._undoHp3 = user._undoHp2;

user._undoHp2 = user._undoHp1;

user._undoHp1 = user._undoHp0;

user._undoHp0 = user.hp;

</Custom Turn End Effect>



<Custom Battle Effect>

user._healedAmount = 0;

</Custom Battle Effect>



<Custom Respond Effect>

if (this.isHpEffect() && value < 0) {

target._healedAmount += value;

}

</Custom Respond Effect>

and the skills notebox looks like this-
<Before Eval>

// This is the state ID of the Undo Deux state.

var undo2 = 19;

// This is the state ID of the Undo Trois state.

var undo3 = 20;

// Check if the user is affected by Undo Trois.

if (user.isStateAffected(undo3)) {

// Then get the range of the target's HP 3 turns ago.

var range = target._undoHp3;

// Check if the user is affected by Undo Deux.

} else if (user.isStateAffected(undo2)) {

// Then get the range of the target's HP 2 turns ago.

var range = target._undoHp2;

// Otherwise...

} else {

// Get the range of the target's HP 1 turn ago.

var range = target._undoHp1;

}

// Get the difference of the target range and the target's current HP.

var hp = range - target.hp;

// Alter the target's HP.

target.gainHp(hp);

// Start the damage popup.

target.startDamagePopup();

// Check if the target is dead.

if (target.isDead()) {

// If the target is dead, make the target collapse.

target.performCollapse();

}

// Clear the target's results.

target.clearResult();

</Before Eval>



<Damage Formula>

if (target._healedAmount !== undefined) {

value = target._healedAmount;

} else {

value = 0;

}

</Damage Formula>

That all correct?
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Don't mind me, just installing a fog machine. :LZSwink:


I can't stop looping this BGM while at work since I began to play PSO2. It just too good for mood booster.
How to post a picture there in the status feed?
So I was at the grocery store trying to reach for some small garbage bags on the top shelf way in the back. Instead of going all the way downstairs to find someone to help me I grabbed a broom and pulled it down. Putting the broom back I said, "Thank you for your service".
S.O.S.--10:16pm......two toddlers still awake....send help...

Forum statistics

Threads
100,423
Messages
975,701
Members
132,080
Latest member
Garycomehome
Top