Passive Ability: Bloodlust and Magic Sponge

So I want to make 2 passive abilities for specific actors. Here's what I want them to do:

Bloodlust - When an enemy dies, regain [Random: 1-5]% of your maximum HP.

Magic Sponge: When an enemy dies, regain [Random: 1-5]% of your maximum MP.

Can I do this?

By the way, a passive ability is something you don't have to activate yourself.
Maybe via troop events, though it will not always work for the last enemy you KO, plus it will be tricky to do without giving the benefit to all players. You'll probably need a plug-in to pull this off.

Moving to Plug-in Requests. If someone knows a way to do this without a plug-in still post it though.
plus it will be tricky to do without giving the benefit to all players.
Conditiinal branches for each party member in the battle event. It would have to be sevral conditinal branches to check the state inside a conditinal branch that checks if enemy is defeated.
Doe's it have to be a passive ability? If it's a skill then there's a couple of things we can do in the damage formula to achieve this effect.
Yeah, I would just put Troop Events in every single Troop with the Scope 'Battle' (only runs once per battle) and the Condition Enemy X is 0% HP or below. In that event, check whether the person with the appropriate passive is in the party and alive, and if so, grant them the HP or MP. To make sure that it runs even for the last member of the enemy troop, be sure to use Hime's End Phase Triggers plugin.

You may be able to save yourself a lot of time and effort by using Yanfly's Base Troop Events as well. Just make 8 pages in the base troop, one for each slot an enemy could appear in.
I would probably do this using Yanflys Buffs & States Core and make it a state.

Here is an example for the Bloodlust state:
Code:
<Custom Action Start Effect>
   $gameTemp.troopAliveCount = $gameTroop.aliveMembers().length;
</Custom Action Start Effect>
<Custom Action End Effect>
   for(var i = 0; i < $gameTemp.troopAliveCount - $gameTroop.aliveMembers().length; i++){
      var procent = Math.floor(Math.random() * 5 + 1) / 100;     
      var hpAmount = Math.floor(user.mhp * procent);
      user.startDamagePopup();
      user.gainHp(hpAmount);
   }
</Custom Action End Effect>
For the Magic Sponge state just modify it a bit.
Code:
<Custom Action Start Effect>
   $gameTemp.troopAliveCount = $gameTroop.aliveMembers().length;
</Custom Action Start Effect>
<Custom Action End Effect>
   for(var i = 0; i < $gameTemp.troopAliveCount - $gameTroop.aliveMembers().length; i++){
      var procent = Math.floor(Math.random() * 5 + 1) / 100;     
      var mpAmount = Math.floor(user.mmp * procent);
      user.gainMp(mpAmount);
   }
</Custom Action End Effect>
You can then also use Yanfly's Auto Passive States to have specific actors always have the states as appropiate 🙂
I would probably do this using Yanflys Buffs & States Core and make it a state.

Here is an example for the Bloodlust state:
Code:
<Custom Action Start Effect>
   $gameTemp.troopAliveCount = $gameTroop.aliveMembers().length;
</Custom Action Start Effect>
<Custom Action End Effect>
   for(var i = 0; i < $gameTemp.troopAliveCount - $gameTroop.aliveMembers().length; i++){
      var procent = Math.floor(Math.random() * 5 + 1) / 100;    
      var hpAmount = Math.floor(user.mhp * procent);
      user.startDamagePopup();
      user.gainHp(hpAmount);
   }
</Custom Action End Effect>
For the Magic Sponge state just modify it a bit.
Code:
<Custom Action Start Effect>
   $gameTemp.troopAliveCount = $gameTroop.aliveMembers().length;
</Custom Action Start Effect>
<Custom Action End Effect>
   for(var i = 0; i < $gameTemp.troopAliveCount - $gameTroop.aliveMembers().length; i++){
      var procent = Math.floor(Math.random() * 5 + 1) / 100;    
      var mpAmount = Math.floor(user.mmp * procent);
      user.gainMp(mpAmount);
   }
</Custom Action End Effect>
You can then also use Yanfly's Auto Passive States to have specific actors always have the states as appropiate 🙂

Thanks, this works.
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/passive-ability-bloodlust-and-magic-sponge.114296/