Battle Action Exp

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.

Download

Plugin: download here (right-click, save as)

Addons

  • Battle Exp Popup – example plugin showing how you can display exp gained in battle.

Patches

  • 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.

Installation

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.

Usage

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:

battleActionExp2

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

This means

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.

Examples

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:

b.result()

From there, you can ask for the HP Damage:

b.result().hpDamage

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

You may also like...

78 Responses

  1. Djfyyh says:

    buy clozapine 100mg pill – ramipril 10mg usa pepcid 40mg over the counter

  2. Ixivlm says:

    buy zidovudine 300 mg sale – biaxsig canada zyloprim 300mg generic

  3. Cskdfp says:

    glucophage 1000mg for sale – order lincocin 500 mg buy lincomycin medication

  4. Icjupa says:

    lasix price – atacand 8mg generic captopril usa

  5. Gbmpik says:

    buy generic acillin online buy generic amoxicillin purchase amoxicillin

  6. Nnejoj says:

    metronidazole 400mg pill – cheap amoxicillin generic buy azithromycin 250mg pill

  7. Aqabmn says:

    price of stromectol – buy sumycin pill order tetracycline 500mg online

  8. Updonu says:

    order valacyclovir 1000mg pill – buy valacyclovir 500mg sale zovirax 800mg generic

  9. Dricuo says:

    buy ciprofloxacin 500mg for sale – order doxycycline pills erythromycin ca

  10. Pgadms says:

    buy metronidazole 200mg – buy cleocin 150mg pill azithromycin tablet

  11. Delmer says:

    Very quickly this website will be famous amid all blogging viewers, due to it’s good posts

  12. Ayumi says:

    Hi! I could have sworn I’ve been to this website before
    but after reading through some of the post I realized it’s new to me.
    Anyways, I’m definitely glad I found it and I’ll be
    book-marking and checking back often!

  13. Terrelle says:

    Have you ever considered about adding a little bit more
    than just your articles? I mean, what you say is valuable and everything.
    Nevertheless imagine if you added some great pictures or videos to
    give your posts more, “pop”! Your content is
    excellent but with images and clips, this site could undeniably be one of the most beneficial in its field.
    Good blog!

  14. Coley says:

    Your style is so unique compared to other folks I have read stuff from.

    Many thanks for posting when you’ve got the opportunity, Guess I will just bookmark this blog.

  15. Alechia says:

    Hello, this weekend is pleasant designed
    for me, since this moment i am reading this fantastic informative post here at my residence.

  16. Amberlyn says:

    I am really loving the theme/design of your web site. Do you ever run into any
    web browser compatibility problems? A number of my blog visitors have complained about my website not working correctly in Explorer but looks
    great in Safari. Do you have any advice to help fix this problem?

  17. Dashon says:

    Please let me know if you’re looking for a author for your weblog.
    You have some really good articles and I believe I would be a good asset.

    If you ever want to take some of the load off, I’d absolutely love to write some material for your
    blog in exchange for a link back to mine.
    Please send me an e-mail if interested. Cheers!

  18. Jayson says:

    Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why waste your intelligence
    on just posting videos to your site when you could be giving us something enlightening to read?

  19. Keyon says:

    Magnificent beat ! I wish to apprentice even as you amend your
    site, how can i subscribe for a weblog site?
    The account helped me a appropriate deal. I had been a little bit
    familiar of this your broadcast offered vivid clear idea

  20. Chaney says:

    I am really loving the theme/design of your site. Do you
    ever run into any browser compatibility issues? A couple of my blog audience have complained about my blog not operating
    correctly in Explorer but looks great in Firefox. Do you have any solutions
    to help fix this problem?

  21. Signe says:

    My partner and I absolutely love your blog and find a lot of your post’s to be just what I’m looking for.

    Does one offer guest writers to write content for you personally?
    I wouldn’t mind composing a post or elaborating on some of the subjects you write related to here.
    Again, awesome site!

  22. Ketura says:

    Howdy! I know this is somewhat off topic but I was wondering which blog platform are you using for this website?
    I’m getting tired of WordPress because I’ve had problems with hackers and I’m
    looking at alternatives for another platform. I would
    be great if you could point me in the direction of a good platform.

  23. Emilyanne says:

    I visited multiple blogs but the audio quality for audio songs present at this website
    is really fabulous.

  24. Juleen says:

    Excellent post however I was wondering if you could write
    a litte more on this subject? I’d be very thankful if you could elaborate a little bit further.
    Bless you!

  25. Tanecia says:

    Hi there to every one, it’s truly a pleasant for me to go
    to see this website, it includes priceless Information.

  26. Isidro says:

    What’s up to every body, it’s my first go to see of this blog; this
    blog contains remarkable and genuinely excellent information in support of visitors.

  27. Chaston says:

    Good article! We are linking to this particularly great article
    on our site. Keep up the good writing.

  28. Mai says:

    Oh my goodness! Incredible article dude! Many thanks, However I am having problems with your RSS.
    I don’t know why I am unable to join it. Is there anyone else having the same RSS issues?
    Anyone who knows the answer will you kindly respond?
    Thanx!!

  29. Ddsxzm says:

    order ciprofloxacin online – buy cipro for sale augmentin for sale

  30. Pmrhsf says:

    buy ciprofloxacin 500mg generic – buy generic ciprofloxacin augmentin 1000mg for sale

  31. Quintell says:

    Excellent post. I’m facing a few of these issues as well..

  32. Alie says:

    Hey I know this is off topic but I was wondering if you
    knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have some experience with
    something like this. Please let me know if you run into
    anything. I truly enjoy reading your blog and I look forward to your new updates.

  33. Fawn says:

    It is appropriate time to make a few plans for the long run and it’s time to be happy.
    I have read this submit and if I may I wish to recommend you some interesting issues or advice.

    Perhaps you can write subsequent articles referring
    to this article. I wish to learn more issues approximately it!

  34. Tariq says:

    Hi there, I would like to subscribe for this blog to take newest updates, so where
    can i do it please assist.

  35. Kavitha says:

    Heya i am for the first time here. I found this board and I
    to find It really helpful & it helped me out much.
    I hope to give something back and help others like you helped me.

  36. Aisa says:

    Excellent way of describing, and nice post to get facts
    concerning my presentation subject, which i am going to present in university.

  37. Eulanda says:

    Wow! Finally I got a webpage from where I know how to in fact get useful data concerning my study and knowledge.

  38. Oddpri says:

    lipitor 80mg generic order generic atorvastatin 40mg buy lipitor online

  39. Here is the most current code I am using.

    Math.round(b.isEnemy() ? (b.result().hpDamage / b.mhp) * b.exp() + ((b.level – a.level) * (b.exp() * 0.12)) : 0)

    It rounds exp to a whole number, and if enemy level is higher or lower than character, it adjusts amount of exp given by 20% per level difference.

  40. I made some code for my new in development game combining Himes original code, and some comment section code, its working so I thought I would share it.

    It gives exp per damage of max hp and changes exp amount based upon difference of level of the actor and the enemy (Note you will need to partner this plugin with himes enemy levels plugin for this code to work)

    b.isEnemy() ? (b.result().hpDamage / b.mhp) * b.exp() + ((b.level – a.level) * (b.exp() * 0.15)) : 0

  41. Hime, Is there a way to only display exp gained up to 0.00 im getting like 0.0000000 and its a bit much, can you help?

  42. Sweet says:

    If you use YEP_InstantCast and level during an ‘Instant Cast’ attack the game stalls at that point. You can’t take any further actions or anything. Any thoughts or recommendations?

    Thanks in advance

  43. Crackerwood says:

    Hello. First of all, it’s a great script. The problem is that it doesn’t work well in me. I have troops or when a monster dies another one. So the script doesn’t take into account party b.isdead or it works perfectly. I can’t send a version of my project because I’m not in France, so I’m limited by the Internet. I can just say that I use mostly yanfly scripts. If anybody had an idea. Thank you very much.

  44. Krystal says:

    Okay so the forum is poinltess to ask on at this point so I’m gonna ask on here and pray I get a reply:

    Is there a way to make it so that exp is distributed AFTER combat(at the end) still with this plugin?

    Since I’m not very code savy I’m unsure of how to do this if its even possible and the reason I ask is because there will be instances where I want the actor to gain exp AFTER battle instead of during.

  45. Wonder Spirit says:

    It sometimes gives a long decimal when receiving exp based on damage

  46. RHER says:

    Can it accumulate a ExpWeight (no Exp) during battle and it defines enemy Exp piece in the end?

    Example:

    .

    You & I

    VS

    Dungger

    .

    You attack –> +3 weight

    I heal –> +2 weight

    You attack –> +3 weight

    I attack –> +3 weight

    Dungger dead

    .

    Dungger Exp = 1000

    You: 6/11 –> Exp +545

    I: 5/11 –> Exp +455

  47. ktnh says:

    Hello. Loving the this plugin.

    I used this parameter,,

    b.isEnemy() && b.isDead() ? b.exp() : 0

    But, when you knock down with continuous attack, experience value is obtained many times.
    ex) 1000exp 1000exp 1000exp 1000exp..

    Is there a solution?

    • Hime says:

      Unfortunately, I am not sure how to check for whether a damage is part of the same action, or a different action.
      There may be a situation where someone wants each consecutive hit to count for exp as well.

      It may be necessary to change the exp formula.

  48. resi says:

    I have a huge issue with your plugin and Victory Aftermath.
    Everything is in order as it should, but more often than not there always seems to be a lockup that you really have to wait through before any exp is showed as being earned. It’s really hampering the game and I would really love to use your plugin plus Victory Aftermath but it just doesn’t want to cooperate.

    If you can help, it would be appreciated

  49. Iqus says:

    Hi Hime! This plugin is amazing!

    I was trying to make it a passive effect, so those who have a certain state ON will gain experience per hit but those who doesn’t are not getting experience at all, I tried this but when I access the Status Menu the game cannot process the exp that was gained by the non-affected battlers. Any suggestion as how to do this? This is the code I used:

    a.isStateAffected(8) ? b.isEnemy() ? Math.ceil((Math.min(b.result().hpDamage, b.hp) / b.mhp) * b.exp()) : 0 : b.exp

    • Iqus says:

      After a while I realized that that formula wouldn’t work, I’m trying this one now, but there will be no exp for those who do not have the state for some reason:

      a.isStateAffected(8) ? b.isEnemy() ? Math.ceil((Math.min(b.result().hpDamage, b.hp) / b.mhp) * b.exp()) : 0 : b.isEnemy() && b.isDead() ? b.exp() : 0

      • Hime says:

        Your logic as it is written means

        1. If state 8 is applied, then gain exp if target is an enemy, and 0 otherwise.
        2. If state 8 is not applied, and if target dies, then you gain all of the enemy’s exp

        So basically you want it so that if the state isn’t applied, the actor should gain exp normally when the enemy dies?

  50. Dynelf says:

    Would it be too hard to make an add-on that allows you to play an animation if a character levels up during battle?

  51. Hernan says:

    Hello I really love this and want to say thanks for your work. I have a question, when a pj “miss” the attack, he/she wins exp. ¿How can I turn off the exp for miss?

    • Hime says:

      What is the exp gain based on? You might want to check if damage was dealt. Something like including this condition in the formula:

      b.result().hpDamage > 0

  52. Lucas says:

    It doesn’t work with Yanfly’s Aftermath plugin. Even with the Fix provided. Instead, when I add the fix at the end of both plugins(yanfly’s and this one) it gives me a RangeError: Maximum stack call exceeded.
    Is there someway to fix this?

    • Hime says:

      I just tried it with aftermath and it works fine for me. If you have other plugins installed you’ll need to figure out which one is causing the problem.

      • Lucas says:

        Just to make sure I’m adding it right. I have to add the fix after all the code, right? Even after the closing braces, right?

        I’m using almost all Yanfly’s plugins and some of yours.

        • Hime says:

          The fix isn’t for the range error problem. You should create a new project to see if the two plugins work together.

          • Lucas says:

            Yeah, I know. However, the console says the error is in the Image of the error

            Am I doing anything wrong? The console says the error is in your code. I don’t know why. Even if I disable all my other plugins, it continues to give me this error. I tried to create a new project, I tried to disable everything. I let enabled the core plugins and yours, yet, it continues to give this error every single time.

            So… Either the fix is wrong, or I copy/pasted it wrong or I don’t know. I’m running MV 1.3.1. Everything works fine except when I put your “fix” in both Yanfly’s and yours. I don’t get it. 🙁

          • Hime says:

            Set up the plugin in this project and see if the same error occurs. If it doesn’t, upgrade it to 1.3.1 and then test it again.
            If the error occurs, send it to me and I will take a look.

          • Lucas says:

            I got it to work. I just didn’t add anything to Yanfly’s plugin whatsoever. No error and XP showing up mid-battle and also popping up.

            This was the mistake all along. I added the fix code under both plugins, as it is stated in this website, but it didn’t need to be that way. I only added the fix to your plugin and everything is great.

            Thanks for every help and everything. Really appreciate it.

            Also, one question. My EXP keep showing up like “20.333333333” or “8.6666667” or “0.67748347”.

            Is there a way to show only Integer numbers and not Float ones? It’s really annoying to see so many numbers at once, also the letter become so small due to this many numbers.

            Is there a fix for this?
            Thanks in advance.

          • Lucas says:

            Any advice on that exp float number issue?

          • Hime says:

            Use Math.round( YOUR_FORMULA ) to round the exp off to an integer.

  53. Jeysonmcfly says:

    Is it possible that you could use this plugin to where they gain the XP during the battle by like… killing pawn enemies and then level up and are able to now use a new skill because say… they reached level 20, which was the prerequisite for learning a new skill?

  54. kovak says:

    can’t i make the user get XP by simply perform an action?

  55. Gambitben says:

    If I have a plugin that adds levels to monsters, how could the formula be so if the monster is lvl 3 and the actor lvl 5, X ammount of xp would be substracted?

    Loving the plugin, with that tweak I would use it.

    • Hime says:

      You could for example say something like (assuming level is how you access the level property)
      b.isEnemy() && b.isDead() ? b.exp() + ((b.level - a.level) * (b.exp() * 0.1)) : 0

      Which is basically (EXP + BONUS). The bonus can be positive or negative.
      In our case, we add or subtract 10% depending on their level difference.

      So if enemy was level 3 and actor was level 5, then the difference between enemy and actor is -2. Multiplied by 10% of enemy’s EXP, that means the attacker will gain only 80% of the EXP they would have originally obtained if the level was the same.

      Depending on how complex the calculation is, you might introduce a plugin that will handle level difference calculations for you, and then plug that into the formula.

Leave a Reply to Jeysonmcfly Cancel reply

Your email address will not be published. Required fields are marked *