In RPG Maker, actors can receive exp by defeating enemies in battle. When all enemies are defeated, the victory processing will occur, and actors will receive exp from the battle.
However, this means that if you were to escape before the battle was over, your actors would not receive any exp even if they defeated some enemies.
This plugin changes the way exp is obtained. Instead of only on battle end, exp is received whenever you perform an action.
For example, if an actor attacks an enemy, exp calculation will occur and if the actor earns exp from that attack, the actor will receive that exp
immediately, and potentially level up on the spot.
Action exp can also be obtained outside of battle, depending on the rules you have set up for your exp calculations.
With this plugin, actors will be rewarded immediately for their actions, which provides you with some additional mechanics that you can use.
Plugin: download here (right-click, save as)
- Battle Exp Popup – example plugin showing how you can display exp gained in battle.
- Patch for Yanfly Victory Aftermath. The exp gained screen will display how much exp was gained in battle. However, the victory aftermath plugin disables level up messages during battle.
Download the plugin and place it in the “plugins” folder in your project’s “js” folder. Then open your Plugin Manager (F10), double-click an empty row, and select the HIME_BattleActionExp plugin.
Once it is in your list of plugins, turn the plugin on.
Global Action Exp Formula
The global formula is used whenever action exp calculations are required and applies to all actions, regardless whether it’s an actor or an enemy. It is defined in the plugin parameters:
The following formula variables are available:
a - user of the action b - target of the action v - game variables s - game switches
By default, you only receive EXP when you defeat the enemy. Here is the formula:
b.isEnemy() && b.isDead() ? b.exp() : 0
IF the target of the action is an enemy, and the target is dead, THEN the amount of EXP gained is equal to the enemy's EXP. OTHERWISE, no EXP
It also means that if an actor targets another actor, no EXP is gained. It is important to check whether the target is an actor or enemy in certain situations, since certain properties may not exist for all battlers.
Let’s say that instead of only receiving exp when an enemy is defeated, you wanted to receive exp based on the amount of damage you deal, as a percentage of the enemy’s exp.
That is to say, if the enemy has 100 HP and gives a total of 100 exp, and you deal 20 damage, then you will receive 20% exp from the enemy, or 20 exp.
To accomplish this, you can retrieve the damage dealt from the action result object for the target:
From there, you can ask for the HP Damage:
To get the ratio, you would take that and divide it by the target’s max HP
b.result().hpDamage / b.mhp
Which would give you the percentage of damage that you dealt relative to the target’s total HP.
Finally, you can multiply this percentage with the enemy’s total EXP, to determine the fraction of EXP that the attacker receives:
(b.result().hpDamage / b.mhp) * b.exp()
Again, because only enemy’s have EXP by default, you may need to check if the target is actually an enemy:
b.isEnemy() ? (b.result().hpDamage / b.mhp) * b.exp() : 0
Which means if you target an actor, you receive no exp.
Now, what happens if the amount of damage you deal is greater than the amount of HP the enemy has left? For example, if you deal 200 damage to an enemy with only 100 HP.
Unfortunately, with this plugin alone, you don’t have access to the enemy’s HP BEFORE the action was applied, but if you had such a plugin, and it stored this information in a property called `oldHp` in the action result, you could say this:
b.isEnemy() ? (Math.min(b.result().hpDamage, b.result().oldHp) / b.mhp) * b.exp() : 0