In this example: A specific actor gets an absorbtion barrier worth 10% of the actor's Max HP when delivering the killing blow to an enemy.
The barrier will activate whenever an enemy is killed, unless one is already active.
Required Plugins:
http://www.yanfly.moe/wiki/Core_Engine_VisuStella_MZ
http://www.yanfly.moe/wiki/Battle_Core_VisuStella_MZ
http://www.yanfly.moe/wiki/Anti-Damage_Barriers_VisuStella_MZ
If you haven't already, make sure you have @Trihan 's Global Passive State in place.
(Most people have this as a base already, as it's an amazing base and required for specific tips & tricks; as well as new ones you can make yourself.
There are other ways to get this effect to work without the global if you are really against it-- in this example, we will use it.)
Trihan's Yanfly Tips & Tricks for Visustella
Before you begin, prepare 3 States, 1 Variable and 1 Skill:
In this Example I will use:
State (32): Global Passive
State (34): Kill Barrier Wait
State (35): Auto Kill Barrier
Variable (5): Temporary Variable 5
Skill (5): Kill Absorbtion
Setup global passive.
Code:
<JS Pre-Start Battle>
user._killCount = user._killCount || 0;
user._assistCount = user._assistCount || 0;
user._deathCount = user._deathCount || 0;
</JS Pre-Start Battle>
<JS Post-Damage As User>
if (target.hp <= 0) {
user._killCount = (user._killCount || 0) + 1;
// add assist for each other living party member
$gameParty.battleMembers().forEach(member =>
member !== user && member.hp > 0 ? member._assistCount = (member._assistCount || 0) + 1 : member
);
}
</JS Post-Damage As User>
<JS Post-Damage As Target>
if (target.hp <= 0) {
target._deathCount = (target._deathCount || 0) + 1;
}
</JS Post-Damage As Target>
Plugin Manager > VisuMZ_1_SkillsStatesCore > Passive States > List > Global Passives
Once your Global State(32) is setup, create a passive state(34) that will be checking for they kill and activating the barrier.
Code:
<JS Pre-Damage>
$gameVariables.setValue(5, user._killCount);
</JS Pre-Damage>
<JS Pre-End Action>
if (user.isStateAffected(35)) {
}
else {
if (!$gameTroop.isAllDead()) {
if (user._killCount > $gameVariables.value(5)) {
user.forceAction(5, user);
user._tpbChargeTime = 0;
}
$gameVariables.setValue(5, user._killCount);
}};
</JS Pre-End Action>
Make sure to link the passive state to the actor.
Code:
<Passive State: 34>
Create a skill(5) that activates the barrier state.
Activates state(35)
The state, when active, activates the barrier
Code:
<Physical Absorb Barrier: Math.round(user.mhp * 0.1)>