A downloadable plugin

Buy Now$3.99 USD or more

Ramza's Weapon Attack Formulas plugin

This is a fairly simple plug and play plugin that makes one major change to the way the battle engine for RMMV works, and has a few little things you can tweak to your liking as well.

This plugin allows you to override the damage formula for the default attack skill, as well as other skills that you tag specifically using a note tag. You override the damage formula either via note tag on a specific weapon, or via the plugin parameters, where you can set an override for a weapon type.

As of Version 1.11 this plugin also supports RMMZ - the newest version of rpgmaker.

But why though?

Glad you asked. Every actor has the default attack skill (unless you use a certain Yanfly plugin, more on that later), and for every actor that skill has the same damage formula. You can use weapons to change the default element of the attack skill, even add effects like poison to it, but you can't change that damage formula at all. What if you have a speedy actor with a pair of knives who wants his agi to affect his default attack skill? How about a mage character whose staff does melee damage based on his m.attack rather than his attack? Well without a plugin, these examples were impossible.

Now, Yanfly has a great plugin to help remedy this problem too, The YEP_WeaponUnleash plugin, but there are a couple of issues with using that plugin for this specific use-case.

  • Skill bloat
    • Each skill that you make for replacing the attack skill takes up space in your database.
    • Each time you update your original attack skill, to add a new trait, new note tags, new action sequences, before/after evals, etc, you must go through and update each of the replaced attack skills as well.
  • Replace attack doesn't properly support dual wielding.
    • Having multiple weapons with replace attack skills on them results only in the first one that is found being used. 
    • This will result in unexpected damage, missing added effects/traits, and incorrect animation(s).

This plugin solves the problems above in the following ways:

  • Because it is simply replacing the formula on the default attack skill, there is only one attack skill to keep track of. You don't need to update a dozen replacement skills when you change one thing about your default attack skill.
  • This plugin was made with (improved) dual wielding in mind, and is capable of updating the damage formula for the skill being used as it's being used, allowing you to dual wield weapons with very different damage formulas seamlessly, especially when used in conjunction with my Dual Wield plugin.

While it was designed with dual wielding in mind, this plugin doesn't have any dependencies, meaning you don't necessarily need the dual wield plugin to make use of it. So go ahead, make that magic staff that hits harder when your m.attack is higher, no other plugins needed!

Plug and Play:

Setup for this plugin is easy, it does most of the heavy lifting in the background, all you need to do is set some damage formulas for weapon types or specific weapons and you're good to go. The damage formula for the basic attack skill is automatically replaced with a weapon damage formula if it exists, which it checks for first on the weapon being used, and then in the plugin parameters for the wtype being wielded. 

If you're dual wielding weapons with weapon attack formulas, only the formula for the weapon in the main hand will be used. If only the offhand weapon has one, it will be used instead. If you're using my dual wield plugin, each weapon swing will use the weapon formula of the weapon being swung for that hit, if one isn't present for a specific weapon, the default attack skill formula will be used instead.

Advanced Use:

The basic attack skill isn't the only skill that can be modified by this plugin. By tagging a skill as a <Weaponskill>, you tell the plugin to sub in the weapon formula in place of the formula for the skill being used. This works the same way as the basic attack skill, and even has some interactions with the skills tags from the dual wield plugin.

Also, your new damage formulas don't need to be only one line anymore. You can define new variables, call new functions, and have access to all of the same values that the normal formula has. A particularly long formula might need a return statement in order to be valid, though.

Note Tags:

<Weapon Formula>
code
code
</Weapon Formula>

Put on a weapon, the code inside the tags replaces the damage formula of the default attack skill, and any other skills you tag with the below tag. New in Version 1.10, this tag can now also be placed on enemies.

<Weaponskill>

This tag notes a skill that will have its damage formula replaced by a weapon formula, if available.

New Function:

With version 1.10 I have added a new function which can be called from the damage formula of any skill. this.weaponFormula() calculates the current custom damage formula of the user, and injects it into the current damage formula. If the attacker doesn't have a custom formula, this function returns 0. 
Additionally, if you feed the function a default formula, instead of 0, it will return that value instead. This allows you to replace part of a damage formula with the custom formula of the attacker, or continue to use a 'default' portion of the formula if the attacker doesn't have a custom formula set. This function must be wrapped in an eval() function in order for it to work correctly, see below:

Example:

eval(this.weaponFormula()) * 2

The above damage formula will return double the attacker's custom formula, or zero if the attacker doesn't have one.

eval(this.weaponFormula(100 + a.mat)) * 2

This is the same formula again, but this time the function is fed a default formula value. This will still return double the attackers custom formula, if he has one, but if he doesn't, it will return 200 + (a.mat * 2)

Plugin Parameters:

The only configurable parameter is used to set up damage formulas for specific weapon types. Weapon type 0 is unarmed. The other numbers correspond to the weapons list in the types tab in your database. You can set a formula for as many or as few weapon types as you like, anything that doesn't have a formula set here, will use the default damage formula as if this plugin wasn't installed.

Terms of Use:

You may:

  • Use this plugin in all of your free and commercial projects, with credit to me, Ramza.
  • Modify this plugin to add or remove features, or compatibility with other plugins, for personal use only.
  • Create and share extensions to this plugin, to add features or compatibility, such that anyone using the extension requires the original plugin.

You may not:

  • Claim ownership of this plugin, or change the header text on it.
  • Directly share this plugin with others, or share modified versions of it.
StatusReleased
CategoryTool
Rating
Rated 4.8 out of 5 stars
(5 total ratings)
AuthorRamza
Tagsbattle, dual-wield, plugin, RPG Maker, Weapons

Purchase

Buy Now$3.99 USD or more

In order to download this plugin you must purchase it at or above the minimum price of $3.99 USD. You will get access to the following files:

Plugin Download 18 kB

Development log

Comments

Log in with itch.io to leave a comment.

How does this work with visustella plugins?

This plugin injects its calculation into the damage formula, so it should be fully compatible with any other plugins that change how damage is calculated, as long as they still use the damage formula box in the database to deal any sort of damage.

Why thank you this makes ultimate weapons much easier

Hello. I'm commenting to inform you that I found a bug with the plugin when using the latest version of your DualWield plugin.

I keep getting an error in the console command that "Ramza.DW.damageCalc" is not a function. It also displays: 

at Window_BattleLog.callNextMethod (rmmz_windows.js:5422:31) 'a.atk * 4 - b.def * 2' 'DAMAGE FORMULA ERROR'

When the DualWield plugin is turn OFF, the WeaponAttackFormulas plugin works perfectly.

Hello there.

I have found and corrected the issue. This plugin does a check during the damage calculation where it checked to see if the project was using the dual wield plugin, by checking if a certain function had been defined. With the latest version of the MZ dual wield plugin, the function it was checking is defined, but the function it calls is not the same, and is not defined anymore.

I changed that check to also make sure the second function was defined already. The update will be uploaded momentarily.

~Ramza

Thank you for your hard work!

Just wanted to ask, if this will work with Galv's Weapon Proficiency plugin? Galv's plugin has a function to use Weapon Proficiency as part of the damage formula.

Good day.

I actually haven't tested these two together, so I don't know 100% if they're compatible.

I think they should work together. This plugin replaces the entire attack skill formula with the one you set on a weapon, and if that should happen to contain a weapon proficiency in it, it should still resolve normally, as it's still in a damage formula. 

If you use the option to conditionally replace part of a skill's damage formula with its weapon attack formula, it should still work the same way, as, it's still inside a damage formula and should still resolve normally.

I can't speak to whether it would work in reverse or not though, so keep that in mind.

~Ramza

Thanks Ramza for the response! Glad to hear that there should, technically speaking, be no conflict.

Hi Ramza, a follow up question, please. Is there a Lunatic mode of sorts to this plugin, e.g., if a player has something equipped, a certain skill, etc., the weapon will have a multiplier to the formula, basically giving maybe 2-5 possible damage formula depending on the conditions met?

(+1)

Hey there.

I'm not sure I'd technically call it a lunatic mode, but the way the formula is evaluated is line by line, like a standard function, so you could conceivably make a very complex formula with if checks that could return different values based on whether or not the user has a state, or a switch is on, or they have a specific item equipped.

<Weapon Formula>
if (a.isStateAffected(26)){
 return a.atk * 4
} else {
 return a.atk * 3
}
</weapon formula>

Would be a very simple example pf this.

~Ramza

thanks!!

(2 edits)

Hey,
I really like this script!

I would like to ask a question. Is it possible to add a additional formula alongside the weapon's formula? From my understanding, the formula gets overwritten no matter what else is put alongside the eval, except multiplication?

For example, a skill that deals [a.mhp*0.1 + eval(this.weaponFormula())] damage. If not, if it's not too much trouble, I'd like to offer it as a suggestion.

(2 edits) (+1)

That feature already exists.

The function you're making reference to is specifically designed to 'inject' the users weapon formula into the damage formula for any skill. The note tag <weaponskill> will completely replace the damage formula with that of the weapon, but eval(this.weaponFormula(altFormula)) should allow the other parts of the formula to modify it just fine. Although, I honestly haven't tested it since the last bug report that it wasn't working correctly with some formulas, so maybe that isn't the case anymore.


You might have to do something like 

var wpn = eval(this.weaponFormula(1)); a.mhp * 0.1 + wpn 

To get it to work correctly. I'll look into it. It's also important to note that enemies do not have weapons, so they will not have a weapon formula, unless you specifically gave them one via a note tag, and this.weaponFormula() has an argument to evaluate an alternate formula if there is no weapon formula present. In the above example it'll return 1 instead. If you don't use this, it'd come back undefined or NaN, which would cause the skill to do zero damage.

Edit:

I tested in a test project with the below formula 

a.mhp * 0.1 + eval(this.weaponFormula())

The weapon formula was set to a.atk, the actor has an atk of 57, and 450 hp. With the skill, he did 102 damage, as expected.

Keep in mind that these formulas don't work in the attack skill, or in any skill that is set as a weaponskill via note tag.

Ah, that's what was tripping me up!
Nothing was happening for the attack skill so I assumed it didn't work for anything else. Just tried it and it works just fine for skills!

I probably would've been confused if it was intended or a bug if I tried it for skills earlier.

Thanks for clearing it up, as it was a huge oversight on my behalf. Looking forward to future scripts!

If you wanted to have something like a weapon unleash could you replace the yanfly plugin with this or would it still be necessary to use the yanfly plugin for something like that? 

What I mean is have the % chance to do a skill that had different effects and animations. 

At this point, weapon unleash isn't something this plugin can do. And the weapon unleash effect from yanfly's weapon unleash plugin is not strictly very compatible with dual wielding.

I'll see what I can do to add a similar feature to this plugin in the future.

Thank you for your quick response. I was just curious as I am trying to keep down the number of plugins I use. All your work is very appreciated! Thanks

(+1)

If I may suggest a small improvement.. or rather two...
1- As you said, this prevents me from having to create many different attack formulas for different weapons. But the formula can only be used for weapons... what about adding a way to set formulas for enemies too? So I can have an enemy with a different formula that still uses the default attack skill? (a way to set the attack animation too would be nice too, but not really that big a deal)
2- Is there a way for me to use the weapon formula only as a value in a skill instead of using the whole damage? For example, a skill that attacks three times with 75% hit chance, but that deals 3/4ths of the default attack as damage... how would I make it still do it with the weapon formula instead of exchanging the whole old formula for it?
(already bought it, by the way)

These are both good suggestions. The first is definitely doable via an update, it shouldn't be too difficult for me to figure out.

The second thing... might sort of be doable right now without an update, but it'd be kind of hacky.

In your damage formula you can get the string which holds the custom formula and eval it as a function. So you could put something in place to check if the user is an actor or not, then check his weapon for a custom formula (if (user.weapons()[0]._customFormula)) and then eval that formula using eval(user.weapons()[0]._customFormula).

A damage formula might look something like this:

var w = (user.isActor() && user.weapons()[0] && user.weapons()[0]._customFormula) ? eval(user.weapons()[0]._customFormula) : (a.atk * 4 - b.def *2); w

Obviously, that's a bit hacky, so I will attempt to come up with a much better way to make it a little easier.

Greetings.

I have updated the plugin to v1.10 and have implemented both of your suggestions. Enemies can now have custom formulas, and I added a new function that you can use to replace a part of a damage formula with the custom weapon formula of the user. Check it out here.

As for swapping out enemy battle animations when they use the default attack, I can't do that as easily, because the damage calculation and the animation happen independently of each other. Specifically, action sequences can call the attack animation before making a damage calculation, so it would show the default animation in that case.

The good news is that YEP_BattleEngineCore already has an enemy note tag to change their default attack animation: <Attack Animation: x>, and since I'm pretty sure you're also using my dual wield plugin, you also already have BattleEngineCore!

Thanks!
I hope more people enjoy them too.
...and I actually never noticed that notetag for battle engine core. Huh.