Hi there everyone.
I was trying to make certain types of weapon able to absorb/gain MP everytime their physical attack successfully hit the target, pretty much in the same fashion of Dragon Quest XI, where mage weapons can absorb MP in the same way.
I was wondering if you got any idea or suggestion to help me.
Thank you very much!
quickest, cheapest fix:
don't assign a default attack, instead assign a specific no-mp-stealing attack for warriors, and another mp-stealing attack for wizards.
add that one attack to the sword, and add a common event after-attack to that attack.
handle all your math through that common event.
I use that script a lot, and have found it very straightforward.
Having assigned the relevant skill to the actor, you would then achieve what you want through the damage formula. There is a question, however. Do you want this attack to only drain MP or do you want it to drain MP and do HP damage?
Having the MP drain = a percentage of the damage dealt is a bit more tricky. That is because your formula must end with the damage. Therefore you have to apply the MP parts before the actual damage, so you have to juggle the damage part very exactly, you couldn't just a a.attack * 4 - b.def *2 type of formula. I don't know that that can be done in a way that allows the skill to function accurately across a range of enemies with varying DEF stats and an actor whose ATK will change over time and/or with gear.
Okay, here is the basic logic for a drain MP and damage HP skill.
Set damage type to HP damage
a.mp+=b.mp/5; b.mp-=b.mp/5; damage formula here
The first expression gives the actor a percentage of the enemy's MP. The second reduces the enemy's MP by that amount. The third part is where you specify the calculation of the damage.
I do know of a way of dealing MP damage and draining a percentage of that, but not for when it's HP damage.
If you want to deal a specific amount of MP instead of a percentage, then the formula would be (using 10MP as an example)
a.mp+=10; b.mp-=10; damage formula here
Of course, you could do a bit of a combination on this. You could have the actor gaining a specific amount while the enemy loses a percentage (or the other way round), so then it would look like this
a.mp+=10; b.mp-=b.mp/5; damage formula here
Ah, just had a thought.
The percentage formula I've given is for 20% of actual MP. If you want it to be a percentage of maximum MP, then it would be b.mmp
You're basically creating a local variable called dam and using that to store the damage formula; you can call it whatever you want, e.g. x, as long as it isn't already an existing method (e.g. things like def, atk, if). It needs to be short for sake of the damage formula. But this might be more information than you care about, haha.