RMMV Damage Formula - ideas and help

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,521
Reaction score
1,413
First Language
English
Primarily Uses
RMMV
Aesica - It does simplify things though.. and yeah I think MAT is 4, starting from 0,(mhp,mmp,atk,def,mat,mdf,agi,luk) I think is the param order. And actually, on my current project all my actual damage formulas are inside scripts, and I just call them via the damage formula supplying necessary parameters. I personally like that approach, easier to write long codes there instead of the formula box
I thought about that, but I have a ton of skills already, however in retrospect, maybe I should've because if I ever decide to change my damage formula (99.9% sure I won't, though, I'm quite happy with it) then I'll have a lot of skill review to do.

Guanto - That plugin code is pretty nice, it takes the weapon parameter (ATK by default but you can change it via supplying the 2nd parameter when u call it from the formula box), and if theres no weapon it simply returns the atk of the user
Close, although in retrospect, maybe it would've been better to have it key off the actor's atk (or other stat) if iLength comes up 0. Easily fixed in just a moment though.

In its current form, it "returns the total atk value of all equipped weapons, or 0 if no weapon is equipped. If the caller is an enemy, return its atk."

Edit: Updated it to work like so: "returns the total of a given stat on all equipped weapons (atk by default) or the user's total atk value if no weapon is equipped OR if the caller is an enemy."
 
Last edited:

Guanto

Auteur
Veteran
Joined
Jul 18, 2018
Messages
111
Reaction score
10
First Language
English
Primarily Uses
RMMV
Well well well.

So I do like this, and as mentioned I wont be using "plugins" per se (stuff made with fancy flexible user parameter boxes and aliases) but I will for sure be using my own, project specific, js files much like Engr. describes his use of damage formulas.

At the same time, I cannot believe what it takes, vs what I thought it, and apparently what it used to, take.

a gory mess of errors
BTW I'm going to start using this line.

And Engr, you figured out how to hotlink the user names... do tell?

EDIT:

Code:
/*
* @plugindesc Get Weapon Power
* @author Aesica
* @help For use in damage formula:  Aesica.Misc.getWeaponPower(actor, stat?)
* - actor: Typically a or b, thus:  Aesica.Misc.getWeaponPower(a)
* - stat?: Optional parameter id, defaults to ATK if left blank
*/
var Aesica = Aesica || {};
Aesica.Misc = Aesica.Misc || {};
(function()
{
   Aesica.Misc.getWeaponPower = function(a, statId=2)
   {
       var params = ["mhp","mmp","atk","def","mat","mdf","agi","luk"];
       var weapons, i, iLength, result = 0;
       if (a.isActor())
       {
           weapons = a.weapons();
           iLength = weapons.length;
           for (i = 0; i < iLength; i++)
           {
               result += weapons[i].params[statId];
           }
           if (iLength < 1) result = a[params[statId]];
       }
       else
       {
           result = a[params[statId]];
       }
       return result;
   }
})();
Wait... thinking out loud...

Remember I would only want to use a weapons ATK sans base ATK if a certain weapon was equipped (I originally mentioned projectile weapons, like "gun") and I would just control that through the skills 'required' weapon feature - meaning - we wouldn't have to check if a weapon was equipped, we know it is or the skill couldn't be used, so we just gotta suck the damage from that weapon we know is being used and ignore the users base ATK. So I think in this case the script may be even less involved? (AKA we already know he has a weapon so just grab its atk).

Attack skills that don't use a missile weapon (or whatever, a weapon that doesn't utilize a characters physical strength in my mind) simple get a more traditional damage formula.

The flipside of this (a problem that didnt occur to me when first bringing this up) is when using a "normal attack". If I called this script and the character had a sword (an instance where I want to include the base ATK) -- would the script see he has a weapon and ignore the base ATK, even though for this instance we want it? To make matters worse if the character was using "normal attack" and did have a "gun" we would again want to exclude base ATK. Ugh.
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You will only call that plugin's function if you want it to ignore base ATK.

Now if you're gonna make a skill that is usable with any weapon type but depending on the weapon might need to use only weapon atk (like if equipped with gun vs with sword) the plugin won't do it right now.

To do that, you'd need to have a check of the equipped weapon type to differientiate what would happen.

as for the hotlink I just do @Username, but after posting I edit it to remove the @.. The actual code was ["user=id"]name["/user"]
 

Aesica

undefined
Veteran
Joined
May 12, 2018
Messages
1,521
Reaction score
1,413
First Language
English
Primarily Uses
RMMV
Remember I would only want to use a weapons ATK sans base ATK if a certain weapon was equipped (I originally mentioned projectile weapons, like "gun") and I would just control that through the skills 'required' weapon feature - meaning - we wouldn't have to check if a weapon was equipped, we know it is or the skill couldn't be used, so we just gotta suck the damage from that weapon we know is being used and ignore the users base ATK. So I think in this case the script may be even less involved? (AKA we already know he has a weapon so just grab its atk).
As I said originally, you could get away with using a.weapons()[0].atk in the damage formula, but again, that's rather volatile for all the reasons already mentioned, and it requires the weapon to be equipped in the very first slot, no dual guns or gun + ammo combinations allowed. The plugin function call I made prevents those sorts of mishaps from happening.

The flipside of this (a problem that didnt occur to me when first bringing this up) is when using a "normal attack". If I called this script and the character had a sword (an instance where I want to include the base ATK) -- would the script see he has a weapon and ignore the base ATK, even though for this instance we want it? To make matters worse if the character was using "normal attack" and did have a "gun" we would again want to exclude base ATK. Ugh.
If you want guns and swords to behave differently via the "Attack" command, then you'll need to create a new skill with the intended damage formula. Let's call it "Shoot" and instead of referencing a.atk, it'd reference a.weapons()[0].atk in its damage formula. Next, you'll have to script something that checks the equipped weapon type and, if it's a gun or whatever, it'll need to have the Attack command reference your newly created skill instead of the default attack skill.
 

Guanto

Auteur
Veteran
Joined
Jul 18, 2018
Messages
111
Reaction score
10
First Language
English
Primarily Uses
RMMV
Now if you're gonna make a skill that is usable with any weapon type
Well I wouldn't make that skill, it's built in (normal attack). And I completely forgot how it would hose this when asking my question.

To do that, you'd need to have a check of the equipped weapon type to differientiate what would happen.
you'll have to script something that checks the equipped weapon type
Great minds...

it'll need to have the Attack command reference your newly created skill instead of the default attack skill.
Guessing there is not a straight forward way to have the vanilla attack command reference a skill of my choosing.

as for the hotlink I just do @Username, but after posting I edit it to remove the @.. The actual code was ["user=id"]name["/user"]
Thank you both Engr. Adiktuzmiko and Aesica
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Most people would probably use a weapon attack plugin which allows you to set what skill will be used as "attack" for each weapon.

or you can just make the initial damage formula check the weapon type and use make it return the correct formula

The benefit of the weapon attack plugin though is that since ur using a different attack skill per weapon, you can also make them have different effects in case you actually need it.

If you choose to go the weapon attack plugin route then that's not in the scope of this thread anymore and any questions for that should be in a new thread.
 

udime123

Director of Fate
Veteran
Joined
Mar 29, 2018
Messages
98
Reaction score
14
First Language
English
Primarily Uses
RMMV
So... I'm trying to do something that sounds pretty simple, but while trying to accomplish it I've been tearing my hair out for a couple hours now, and after searching the internet for a while, I can't seem to find any indicators of how to do this, even though it feels pretty simple.

So, I have a skill, let's call it Gauss, which deals (v[n] + a.mat * .75 - b.mdf *1) damage, and it hits twice. It sounds like a pretty weak skill, but the intended gimmick is that you use other skills to boost its raw power, which is what v[n] is for.

Other skills boost v[n] by certain amounts, with the intention of adding damage equal to v[n] times the number of hits the skill in question deals. The problem is, Gauss is dealing 0 damage, and after doing some troubleshooting, the skill used to boost v[n] (I'll nickname it "Orbit") isn't doing as intended. I've tried two methods of increasing v[n]. The first is using a Note to call a common event that basically redefines v[n]'s value. Doing that crashed my game whenever the skill was used.
The second method was to try to use the Damage Formula Box for Orbit to see if using it would redefine the variable. Instead, I received damage equal to the variable (which makes sense).

So obviously I'm doing something wrong, but I don't know how to fix it. There's really two problems here: making the variable directly impact Gauss's damage formula, and making Orbit directly change the value of v[n]. Do you guys know what to do?
 

SwiftSign

Veteran
Veteran
Joined
Aug 5, 2015
Messages
184
Reaction score
45
First Language
English
Primarily Uses
RMMV
@udime123
Orbit should have "Call Common Event" and this should set the Variable to the necessary number. Make sure you're using 'set' - or, if you're using 'add/sub/multiply/etc.' make sure that the variable is set to 0 prior to the battle/skill being used.

Then it should be fine. If you're still having difficulties post some screenshots and stats for your attacker and defender. From "a.mat * .75 - b.mdf" it looks like it might be doing 0 straight off, so maybe your variable isn't set high enough to counter that.
 

udime123

Director of Fate
Veteran
Joined
Mar 29, 2018
Messages
98
Reaction score
14
First Language
English
Primarily Uses
RMMV
@udime123
Orbit should have "Call Common Event" and this should set the Variable to the necessary number. Make sure you're using 'set' - or, if you're using 'add/sub/multiply/etc.' make sure that the variable is set to 0 prior to the battle/skill being used.

Then it should be fine. If you're still having difficulties post some screenshots and stats for your attacker and defender. From "a.mat * .75 - b.mdf" it looks like it might be doing 0 straight off, so maybe your variable isn't set high enough to counter that.
After fixing the common event, it does deal about as much damage as I expected after using Orbit. With variance at 0, it deals exactly 29 damage for each hit. The weird thing is, though, without using Orbit first, Gauss deals 0 damage per hit. Orbit sets the variable to 10, so why isn't the unbuffed attack dealing 19 damage per hit?
 

SwiftSign

Veteran
Veteran
Joined
Aug 5, 2015
Messages
184
Reaction score
45
First Language
English
Primarily Uses
RMMV
That’ll be the variable messing things up. If you don’t set the variable to zero it won’t have a true value and therefore will mess up your formula.
 

udime123

Director of Fate
Veteran
Joined
Mar 29, 2018
Messages
98
Reaction score
14
First Language
English
Primarily Uses
RMMV
That’ll be the variable messing things up. If you don’t set the variable to zero it won’t have a true value and therefore will mess up your formula.
Gotcha, so I need to define the starting variable even if I'm using Set. Thanks for the help!
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
@udime123 - since your formula uses v[n], if that variable doesnt have a value yet (meaning its probably returning null), it would then cause an error since your formula will be null + some value (which isnt allowed, hence returns an error), and with the way the damage formula is enclosed in an error catch clause, if it ever encounters any error, it immediately returns 0 as the damage

Also just to explain why you got damaged when you tried using the formula box to set the variable, its because the engine takes whatever return value your formula has as damage. If you want to use the formula box to set a variable, you'd need to make it return 0 after. So something like

Code:
 set variable value; 0;
 

Hjaldrbjorn

Warper
Member
Joined
Aug 14, 2018
Messages
2
Reaction score
0
First Language
English
Primarily Uses
RMMV
Being a fan of low number (I hate it when I see 10's of thiusands or millioms and seeing several hundered at level 3 bugs me to no end) i keep low stats, in most my games, characters start with only 12-16 in a stat. To valculate a normal attack, I do something around a.atk*.80 - b.def*.3
I also use equipmemt that offers a % reduction in physical damage, especially if it is supposed to be "plate" it will offer armour and physical reduction.
In my current game, 184atk vs 185 defense with a 26% reduction will do about 80dmg
 

udime123

Director of Fate
Veteran
Joined
Mar 29, 2018
Messages
98
Reaction score
14
First Language
English
Primarily Uses
RMMV
Being a fan of low number (I hate it when I see 10's of thiusands or millioms and seeing several hundered at level 3 bugs me to no end) i keep low stats, in most my games, characters start with only 12-16 in a stat. To valculate a normal attack, I do something around a.atk*.80 - b.def*.3
I also use equipmemt that offers a % reduction in physical damage, especially if it is supposed to be "plate" it will offer armour and physical reduction.
In my current game, 184atk vs 185 defense with a 26% reduction will do about 80dmg
I'm all for low numbers, but I'm not really sure this is the ideal way to go about it. Having the basic attack multiplier be less than 1.0 makes the attack stat feel arbitrary. After all, why not just make the stat itself lower and keep the multiplier higher? That way, each number is actually relevant as opposed to having arbitrary stat increases that make less than one point of difference to damage.

On an extreme note, for really low numbers, I suppose you could go with no multiplier at all. Taking an extreme example, most characters in Paper Mario deal very little damage, where 5 is considered a ridiculous number. You could easily set the formula to be (a.atk-b.def) and have the base def of every enemy set to 1, increasing it for bulkier enemies, while the base attack would go no higher than 4. It's very extreme, but that's definitely one way to go about low numbers.

(Edit) I'd like to add that obviously there is a place for multipliers that are less than 1.0, such as if the stat is not the main source of damage or if the attack is intentionally designed to be weaker than average. I'm mainly arguing that the main attack formula shouldn't be low.
 

AlecWallace

Warper
Member
Joined
Nov 29, 2018
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMV
I am working on a formula to incorporate normal hits, critical hits, and Critical Failures. Is there any way to use an “ else if” or “elif” to add additional conditions?
Ex:
H=math.randomInt(20)+1; if (H===1) {a.atk*.1} else if (H===20) {a.atk*2} else {a.atk}
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
I am working on a formula to incorporate normal hits, critical hits, and Critical Failures. Is there any way to use an “ else if” or “elif” to add additional conditions?
Ex:
H=math.randomInt(20)+1; if (H===1) {a.atk*.1} else if (H===20) {a.atk*2} else {a.atk}
It ought to work but if you want to work with values lesser than 1 and more than 0 you should use 1/10.
As far as i know .1 would do nothing and you would get 0.
Nevermind just tested it, it seems to work.
I never knew. This is good to know.
Do you know Yanfly?
This is one of his plugins its what i use and works for me"http://yanfly.moe/2015/11/07/yep-25-damage-core/"
 
Last edited:

AlecWallace

Warper
Member
Joined
Nov 29, 2018
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMV
It ought to work but if you want to work with values lesser than 1 and more than 0 you should use 1/10.
As far as i know .1 would do nothing and you would get 0.
Nevermind just tested it, it seems to work.
I never knew. This is good to know.
Do you know Yanfly?
This is one of his plugins its what i use and works for me"http://yanfly.moe/2015/11/07/yep-25-damage-core/"
Awesome! The nested if was what I was really curious about. Thanks for testing it for me!
 

jetboost

Veteran
Veteran
Joined
Sep 29, 2016
Messages
84
Reaction score
26
First Language
Dutch
Primarily Uses
RMMV
Awesome! The nested if was what I was really curious about. Thanks for testing it for me!
No problem had the program open and learned something myself the only error i encountered was the m from math not being an M.
 

Confodere

Villager
Member
Joined
Oct 10, 2012
Messages
24
Reaction score
27
First Language
German
Primarily Uses
RMMV
Hey there. Ive would like to implement a skill that copies the targets state to the user. However, not just one certain state, but all that are available. So if the target has for example a health regen state it copies that and when the target has a shield state it copies that over to the user.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 3)

Latest Threads

Latest Posts

Latest Profile Posts

grief... lol... I keep seeing request for MZ versions of MV plugins. this is why I haven't moved over and just MZ for my MV project.
Egg-sitting minigame is coming along nicely. Are you a bad enough dino to keep all these raptor eggs warm?

I forgot to post the animated version of the previous map I was working on. I'm still arguing with myself on if I like the stark blue ground better than the undergrowth ground used on the waterfall map. Hmm...
now that fmod is free for indie(<200k revenue), it would be interesting to see someone add fmod support for rpg maker
Can't say I can't promise progress on a project just yet. But I can say I had fun databasing tonight. :)

Forum statistics

Threads
105,802
Messages
1,016,574
Members
137,496
Latest member
sulthorne
Top