Game Dev Contest
Join in on the Game Development contest with over $300 in prizes!
Banner Creation Contest!
Help the community out by creating your own version of the banner, and potentially having that as the main banner!
Resources
Check out our resources :D
Upgrade your account
Help out the community, and keep the website running and fully up to date by donating! :D

Damage Formulas 101 (MV Edition)

GO TO ADMIN PANEL > ADD-ONS AND INSTALL ABSTRACT SIDEBAR TO SEE FORUMS AND SIDEBAR
Status
Not open for further replies.

Mr. Trivel

Adventurer
Joined
Jan 16, 2016
Messages
198
Points
197
RM Skill
Programmer
Damage Formulas 101
MV Edition

You probably wondered how to make a skill do more damage against enemies with a state, or heal more if player has a state, or deal exactly half of enemy's HP. And so on.

All of that and more can be done through custom damage formula.



Basics:

Type - sets what does the formula damage or heal.
None - Nothing, no damage will be dealt.
HP Damage - HP will be damaged
MP Damage - MP will be damaged
HP Recover - HP will be restored
MP Recover - MP will be restored
HP Drain - Deals damage to enemy HP and restores that much HP for attacker
MP Drain - Deals damage to enemy MP and restores that much MP for attacker

Element - Sets which element to use. Normal attack - means will use same element as weapon.

Variance - How will damage fluctuate. E.g. If skill formula says it deals 100 damage and variance is 20%, the skill will deal between 80 and 120 damage.

Critical - Can skill critically hit, dealing increased damage by 300%.

And now, the actual fun part - formulas!
It decides how much damage will opponent take or ally will heal.

Let's dissect one of basic formulas that come with RPG Maker MV - Fire
100 + a.mat * 2 - b.mdf * 2

What do things like a and b mean?
a - attacker
b - defender
So if Actor Glasses were to cast Fire on a Slime. a would be Glasses and b would be Slime.

Meaning the takes double of Glasses mat (Magic Attack) parameter and subtracts double of Slime's mdf (Magic Defense) parameter and adds that to the 100 in the beginning ofthe formula.
E.g. Glasses has 100 mat and Slime has 20 mdf. If we were to convert fomula using those numbers, we'd have - 100 + 100*2 - 20*2, after calculation we see with those parameters Fire would deal 260 damage if there were no variance.

But only last number in the formula deals damage. If you had 2 lines of formula. (semicolon ; tells where line ends for the program)
E.g. a.atk; a.atk*2
Only a.atk*2 would be calculated for damage.

Are there more letters other than a and b for the formulas?
Yes. There are variables. Which are used like this: v[ID]. ID - index of the variable.
So you could have a skill that gets stronger the higher variable is.
E.g. v[10] * 2 - b.def * 3

Is there a way to make skill even more complex, e.g. if some variable is over 100, deal extra damage?
Yes, in that case we can use if else statements.
How if else statement looks:
Code:
if (statement)
{
   formula1;
}
else
{
   formula2;
}
But how to write it to the damage formula? It only has 1 line!
Just write everything together~
Code:
if (statement) { formula1; } else { formula2; }
E.g.:
Code:
if (v[10] > 100) { a.atk*4 - b.def*2 } else { a.atk*2 - b.def*2 }
Which can be shortened to this if you're using only 1 line of formula.
Code:
if (statement)
   formula1;
else
   formula2;
E.g.:
Code:
if (v[10] > 100) a.atk*4 - b.def*2; else a.atk*2 - b.def*2;
And you can shorten it even further using ternary operator (my favorite one):
statement ? formula1 : formula2;
E.g.:
Code:
v[10] > 100 ? a.atk*4 - b.def*2 : a.atk*2 - b.def*2;
Symbols for statements:
> - more than
< - less than
>= more than or equal to
<= less than or equal to
=== equal to
&& and
|| or
!== not equal
! not

Examples:
v[10] > 100 ? 1000 : 100; (If variable 10 is more than 100, it'll deal 1000 damage, else it'll only deal 100)

v[10] < 100 ? 1000 : 100; (If variable 10 is less than 100, it'll deal 1000 damage, else, it'll only deal 100)

v[10] >== 100 ? 1000 : 100; (If variable is 100 or more, it'll deal 1000 damage, else it'll only deal 100)

v[10] <== 100 ? 1000 : 100; (If variable is 100 or less, it'll deal 1000 damage, else it'll only deal 100)

v[10] === 100 ? 1000: 100; (If variable is equal to 100, it'll deal 1000 damage, else it'll only deal 100)

v[10] > 50 && v[11] >== 25 ? 1000 : 100; (If variable 10 is more than 50 and variable 11 is 25 or more, it'll deal 1000 damage, else it'll only deal 100)

v[10] > 50 || v[11] > 50 ? 1000 : 100; (If variable 10 is more than 50 or variable 11 is more than 50 then it'll deal 1000 damage, it'll only deal 100)

v[10] !== 100 ? 1000 : 100; (If variable 10 is not equal to 100, it'll deal 1000 damage else it'll only deal 100)

What about parameters to use for a and b?
Here's a whole list of them:

Current: (All flat numbers, e.g.: 900, 999, 11)
level - current level (Actor only by default)
hp - current hp
mp - current mp
tp - current tp

Params: (All flat numbers, e.g.: 1337, 7331, 156)
mhp - max hp
mmp - max MP
atk - attack
def - defence
mat - magic attack
mdf - magic defence
agi - agility
luk - luck

XParams: (All decimal numbers symbolizing percent, e.g. 1.0, 0.5, 0.75, 2.44 would be 100%, 50%, 75%, 244%)
hit - Hit rate
eva - Evasion rate
cri - Critical rate
cev - Critical evasion rate
mev - Magic evasion rate
mrf - Magic reflection rate
cnt - Counter attack rate
hrg - HP regeneration rate
mrg - MP regeneration rate
trg - TP regeneration rate

SParams:(All decimal numbers symbolizing percent, e.g. 1.0, 0.5, 0.75, 2.44 would be 100%, 50%, 75%, 244%)
tgr - Target Rate
grd - Guard effect rate
rec - Recovery effect rate
pha - Pharmacology
mcr - MP Cost rate
tcr - TP Charge rate
pdr - Physical damage rate
mdr - Magical damage rate
fdr - Floor damage rate
exr - Experience rate

How about changing HP/MP/TP?
gainHp(value) - restores HP by value
gainMp(value) - restores MP by value
gainTp(value) - restores TP by value

setHp(hp) - sets HP to value
setMp(mp) - sets MP to value
setTp(tp) - sets TP to value
E.g. a.setHp(a.mhp)
E.g. a.setHp(a.hp + 100)

clearTp() - sets TP to 0


What about advanced stuff where you can influence formulas with states?
We got all that!
isStateAffected(stateId) - checks if battler has state inflicted to them.
E.g. b.isStateAffected(10) ? 10000 : 1;

isDeathStateAffected() - checks if battler has death state inflicted to them.
E.g. b.isDeathStateAffected() ? 10000 : 1;

resetStateCounts(stateId) - refreshes how long state will last for the battler
if (b.isStateAffected(10)) b.resetStateCounts(10); 100

updateStateTurns() - shortens all states on battler by 1 turn
b.updateStateTurns(); 100

addState(stateId) - adds state to the battler
if (!b.isStateAffected(10)) b.addState(10); 100

isStateAddable(stateId) - checks if state can be added to the battler
c=100; if (b.isStateAddable(10)) b.addState(10); else c=4000; c

removeState(stateId) - removes state from the battler
if (a.isStateAffected(10)) a.removeState(10); 0



What about buffs? Can we buff and debuff battlers?
Yes!
addBuff(paramId, turns) - adds a buff for a parameter
a.addBuff(0, 3); b.def*10

addDebuff(paramId, turns) - adds a debuff for a parameter
b.addDebuff(2, 10); 9999

removeBuff(paramId) - removes a buff or debuff from a battler
removeAllBuffs() - removes all buffs and debuffs from a battler

Parameter IDs
0 - Max HP
1 - Max MP
2 - Attack
3 - Defence
4 - Magic Attack
5 - Magic Defence
6 - Agility
7 - Luck

General Battler Stuff
die() - kills the battler
b.die(); 0

revive() - revives the battler
a.revive(); 1000

paramBase(paramId) - gets base parameter
a.paramBase(3)*10 - b.def*2

paramPlus(paramId) - gets the bonus of parameter
a.paramPlus(3)*2 - b.def*2

paramMax(paramId) - gets max possible value of parameter
b.paramMax(0)

elementRate(elementId) - checks element rate of the battler (rate being decimal numbers representing %)
b.elementRate(10) >== 0.5 ? 10000 : a.mat*4;

isStateResist(stateId) - checks whether the battler resists state
c=0; b.isStateResist(10) ? c+=2000 : b.addState(10); c

isSkillTypeSealed(stypeId) - checks if battler's skill type is sealed
isSkillSealed(skillId) - checks if battler's skill is sealed
isEquipTypeSealed(etypeId) - checks if battler's equip type is sealed
isDualWield() - checks if battler can dual wield
isGuard() - checks if battler is guarding
recoverAll() - removes all states, restores HP and MP to max

hpRate() - checks HP rate of battler
mpRate() - checks MP rate of battler
tpRate() - checks TP rate of battler
b.hpRate() < 0.5 ? b.hp-1 : 100;

isActor() - checks if battler is actor
isEnemy() - checks if battler is enemy
escape() - escapes from battle
b.escape() (makes enemy run away)

consumeItem(item) - eat up an item
a.consumeItem($dataItems[15]); 100



For actor only:
currentExp() - current EXP
currentLevelExp() - EXP needed for current level
nextLevelExp() - EXP needed for next level
nextRequiredExp() - EXP left until next level
maxLevel() - max level of actor
isMaxlevel() - is actor max level (true/false)
hasWeapon() - is actor wielding a weapon (true/false)
hasArmor() - is actor wearing any armor (true/false)
clearEquipments() - unequip everything actor is wearing
isClass(gameClass) - checks if actor is of a class (gameClass - $dataClasses[ID])
hasNoWeapons() - checks if actor doesn't have any weapons
levelUp() - levels actor up
levelDown() - level actor down
gainExp(exp) - gives actor exp
learnSkill(skillId) - makes actor learn a skill
forgetSkill(skillId) - makes actor forget a skill
isLearnedSkill(skillId) - checks if actor has a skill learned
actorId() - returns Actor's ID


For enemy only:
enemyId() - returns Enemy's ID

What about Math? Can we use Math methods inside the formula?
Yup, you totally can.

Math.random() - returns a random number between 0 and 1 (0 <= n < 1)
Math.min(numbers) - returns a minimum number from provided numbers.
E.g. Math.min(10, 50, 40, 200) - would return 10.

Math.max(numbers) - returns a maximum number from provided numbers.
E.g. Math.max(10, 50, 40, 200) - would return 200.

Math.round(number) - rounds a number to nearest integer.
Math.ceil(number) - rounds the number up to nearest integer.
Math.floor(number) - rounds the number down to nearest integer.

Math.rand() returns a number between 0 and 1, but can we get a random number between 1 and 100? Or 5 and 200?
No problem:

Math.floor(Math.random()*100)+1
^ That would return a number between 1 and 100. If we didn't add 1 at the end, it'd only return a number between 0 and 99.

But that's a lot of text? Could we simplify somehow?
Thankfully, there's a method in rpg_core.js that adds Math.randomInt(max);
So we can write the same using:
Math.randomInt(100)+1

If you have any questions, feel free to ask or discuss various ways to make specific skills.
 

Ren

NPC
Joined
May 27, 2016
Messages
3
Points
1
RM Skill
Writer
First of this is great! This explains alot but im having a slight issue, im creating a character that uses both atk and mat for his formula but i cant figure it out here's the formula i used

a.atk * 4 + 100 a.mat * 2 - b.def * 2 - b.mdf *

I figured if i just mash the 2 formulas together it'll work, it does not! dmg calculation is 0
 

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
First of this is great! This explains alot but im having a slight issue, im creating a character that uses both atk and mat for his formula but i cant figure it out here's the formula i used

a.atk * 4 + 100 a.mat * 2 - b.def * 2 - b.mdf *

I figured if i just mash the 2 formulas together it'll work, it does not! dmg calculation is 0
Mashing two formulas together won't do anything. Think of the fourmula you're trying to make as
a math problem.
If we replace x = a.atk and y =a.mat and z = b.def and w = b.mdf

you'll end up having this :
x*4 + 100 y * 2 - z * 2 - w *

This fourmula makes no sense what so ever.

So my question for you is, what do you want the damage to based of off? (eg a.atk * 4 means that the users atk times four will be what the damage is, not counting any variance)

Also BTW I''m shocked rpg maker didn't just crashed on you as the fourmula you gave is incomplete (ends on a math symbol eg "*") , which literally means you've multiplied by nothing which for most programs is incomprehensible.
 

Ren

NPC
Joined
May 27, 2016
Messages
3
Points
1
RM Skill
Writer
Mashing two formulas together won't do anything. Think of the fourmula you're trying to make as
a math problem.
If we replace x = a.atk and y =a.mat and z = b.def and w = b.mdf

you'll end up having this :
x*4 + 100 y * 2 - z * 2 - w *

This fourmula makes no sense what so ever.

So my question for you is, what do you want the damage to based of off? (eg a.atk * 4 means that the users atk times four will be what the damage is, not counting any variance)

Also BTW I''m shocked rpg maker didn't just crashed on you as the fourmula you gave is incomplete (ends on a math symbol eg "*") , which literally means you've multiplied by nothing which for most programs is incomprehensible.
a.atk * 4 + 100 a.mat * 2 - b.def * 2 - b.mdf * 2 is what its suppose to be, that was just a bad paste.

I want the dmg to be based off atk as well as mat so that its an attack that does 2 types of dmg. So against enemies with high def it still does mat dmg and vice versa. So for starters the standard a.atk* 4 and 100 a.mat* 2 is fine, balancing wise.
 

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
Two forumulas for you to try:

1. a.atk * 4 + 100 + a.mat * 2 - b.def * 2 - b.mdf * 2

What this fourmula means is
Users atk times 4 plus 100 plus user's magic attack times two minus target's defense times 2 minus targets magic defense times 2.

or this :

2. if (b.def > b.mdf) { a.mat * 4 + 100 - b.mdf * 2 ;} else if (b.def < b.mdf ) { a.atk * 4 + 100 - 2 * b.def ;} else { a.atk * 4 + 100 + a.mat * 2 - b.def * 2 - b.mdf * 2 ;}

This is similar to the the other fourmula but it checks if the enemy's def is more than, less than or equal to their magic defense, and then uses a different formula accordingly. I gave you this one as you said you wanted this to still do high damage even if the enemy has a high defense or magic defense.

Oh and the what this formula means is:

if target's defense is greater than it's magic defense, then use this fourmula for damage: the user's magic attack times 4 plus 100 minus 2 times the target's magic defense. Else if the target's defense is less than it's magic defense, then use this fourmula for damage : the user's attack times 4 plus 100 minus 2 times the targets defense. Else if neither of the other two were true and thus the target's defense is equal to it's magic defense then use the same fourmula as the number #1 for damage.
Hopefully this helps and let me know if you need more help! :).
 

Aosha

NPC
Joined
Jun 4, 2016
Messages
5
Points
1
This helped out me a lot. Something I've now tried to do but still haven't figured out:
There is a skill I want to do "a.mat * 5 - b.mdf *2" damage if the actor using it is affected by state 44, and 0 damage otherwise.
Thus far I've made it a skill that only shows up when under state 44, but I'd actually like to make it a skill gained from level ups. And with what I've been able to do (other than completely locking the spell's existence behind the state) I've always only managed to make it do either 0 damage always, or full damage always.
Another (not as important) thing I've been attempting to do is a skill with almost the same damage calculation (a.mat * 4 - b.mdf * 2) and the same "only do damage under state 44" thing as the one above, but so that it would also refresh the state (44) when under it. Thus far the solution has been "skill only exists under state 44, and using skill applies 44 again". It works well enough, but I'd still like to change it to a skill gained from leveling up, in which case that wouldn't really work any more.
This seems to be beyond my abilities with MV, so help would be appreciated. Sorry if I didn't explain what I'm trying to do properly, and thank you in advance.
 

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
This helped out me a lot. Something I've now tried to do but still haven't figured out:
There is a skill I want to do "a.mat * 5 - b.mdf *2" damage if the actor using it is affected by state 44, and 0 damage otherwise.
Thus far I've made it a skill that only shows up when under state 44, but I'd actually like to make it a skill gained from level ups. And with what I've been able to do (other than completely locking the spell's existence behind the state) I've always only managed to make it do either 0 damage always, or full damage always.
Another (not as important) thing I've been attempting to do is a skill with almost the same damage calculation (a.mat * 4 - b.mdf * 2) and the same "only do damage under state 44" thing as the one above, but so that it would also refresh the state (44) when under it. Thus far the solution has been "skill only exists under state 44, and using skill applies 44 again". It works well enough, but I'd still like to change it to a skill gained from leveling up, in which case that wouldn't really work any more.
This seems to be beyond my abilities with MV, so help would be appreciated. Sorry if I didn't explain what I'm trying to do properly, and thank you in advance.
To Refresh:
if (a.isStateAffected(44)){b.gainHp (-1*(a.mat*2-b.mdf*2)); a.resetStateCounts(44);} else {0;}
Assuming you want HP damage, If you want MP damage, rename Hp to Mp.


What do you mean you want a skill gained from level ups? like do you want it to be more powerful with each level? or something else?
 

Aosha

NPC
Joined
Jun 4, 2016
Messages
5
Points
1
To Refresh:
if (a.isStateAffected(44)){b.gainHp (-1*(a.mat*2-b.mdf*2)); a.resetStateCounts(44);} else {0;}
Assuming you want HP damage, If you want MP damage, rename Hp to Mp.


What do you mean you want a skill gained from level ups? like do you want it to be more powerful with each level? or something else?
Thanks a lot! I got it working exactly how I wanted! The calculation you provided didn't quite work as is, but once I changed "{b.gainHp (-1*(a.mat*2-b.mdf*2)); a.resetStateCounts(44);}" into "{a.resetStateCounts(44); a.mat*2-b.mdf*2}" it started doing exactly what I intended (after a while I remembered that the damage calculation has to be there after everything else). I think I learned quite a bit from this that I can put to use later on. Again, thanks a lot.

By "skill I get from a level up", I mean roughly this: (here skill B is the one I was having trouble figuring out)
"At level 56 you learn skill A, which applies state 44. State 44 increases some parameters like magic attack slightly. At level 58 you learn skill B, which you can use to refresh the duration of state 44 while also doing damage."
And then at level 60 you'd learn the other skill that does more damage but does not cause the refresh.
For reference, I'm trying to recreate the abilities used in FinalFantasyXIV for practice/fun, and the group of skills I was trying to do here was how Enochian, Blizzard IV and Fire IV behave in that game.
 

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
I'm so glad it helped!:D.
To enable skill learning assume no plugins are affecting skill learning:
Under Classes, Select the class you want to learn these skills.
Go to skills to learn, then in the empty space under it. A new window should pop up, for skill A, set the level to 56, and make sure the level selected is skill A (By default it shows Level:1 and Skill:Attack). And do the same for skill B, just change the label.
 

Companion Wulf

Lone Wolf
Sponsor
Joined
Oct 24, 2015
Messages
615
Points
224
RM Skill
Writer
Very very useful. This is something I've yet to dive into, but I'm almost ready to. This'll come in handy!
 

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
Very very useful. This is something I've yet to dive into, but I'm almost ready to. This'll come in handy!
Yeah, it is. It's on three different fourms so I make sure when I'm working on skills or plugins that can use this short hand, I have an window open with this on it.
 

Aosha

NPC
Joined
Jun 4, 2016
Messages
5
Points
1
I'm so glad it helped!:D.
To enable skill learning assume no plugins are affecting skill learning:
Under Classes, Select the class you want to learn these skills.
Go to skills to learn, then in the empty space under it. A new window should pop up, for skill A, set the level to 56, and make sure the level selected is skill A (By default it shows Level:1 and Skill:Attack). And do the same for skill B, just change the label.
I do already know how to designate skills to be learned through level up, I was just saying I wanted this as a level up skill as a reasoning for why I didn't want it to behave the way I had it set up until then. I've completed the learnsets for two classes already before I ran into this wall here, after all. Anyways, good of you to explain that as well, I'm still such a beginner it would be no wonder if I hadn't figured that out :P

Next up on my agenda is monk, which is basically entirely made up of "if (a.isStateAffected(1)){{a.addState(2); a.removeState(1); [damage calculation];} else {0;}" rinse and repeat for every skill. So good thing I did this first, or I'd be completely stuck with a whole class :)


Now, another problem I seem to have encountered is trying to make a skill that only hurts an enemy that has less than 10% health. Thus far it looks something like this: "if (hpcheck){200+a.atk*2-b.def*2;} else; {0;}". For that hpcheck I've been trying different things, starting with (b.hp<b.mhp*0.1) and (b.hp*10<b.mhp), but nothing has worked thus far. To me those look like something that should work, but being the beginner I am there's probably some simple mistake somewhere.
 
Last edited:

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
I do already know how to designate skills to be learned through level up, I was just saying I wanted this as a level up skill as a reasoning for why I didn't want it to behave the way I had it set up until then. I've completed the learnsets for two classes already before I ran into this wall here, after all. Anyways, good of you to explain that as well, I'm still such a beginner it would be no wonder if I hadn't figured that out :P

Next up on my agenda is monk, which is basically entirely made up of "if (a.isStateAffected(1)){{a.addState(2); a.removeState(1); [damage calculation];} else {0;}" rinse and repeat for every skill. So good thing I did this first, or I'd be completely stuck with a whole class :)


Now, another problem I seem to have encountered is trying to make a skill that only hurts an enemy that has less than 10% health. Thus far it looks something like this: "if (hpcheck){200+a.atk*2-b.def*2;} else; {0;}". For that hpcheck I've been trying different things, starting with (b.hp<b.mhp*0.1) and (b.hp*10<b.mhp), but nothing has worked thus far. To me those look like something that should work, but being the beginner I am there's probably some simple mistake somewhere.
This should work:

if(b.hp < (b.mhp*0.1)){200+a.atk*2-b.def*2;} else {0;}
 

Aosha

NPC
Joined
Jun 4, 2016
Messages
5
Points
1
This should work:

if(b.hp < (b.mhp*0.1)){200+a.atk*2-b.def*2;} else {0;}
Oh hey it worked! I was certain I'd tried that exact setup already, but I must have been missing something, like the ( ) around b.mhp*o.1, or the spaces around < (if those are necessary). Cheers!
[doublepost=1465163093,1465142633][/doublepost]I'm just not gonna stop bugging you am I... Now that I'm thinking about the states needed to use skillls: what if I wanted a skill to require 2 states instead of 1? I made a test skill (and called it "science"), and tried something along the lines of "if ((a.isStateAffected(1)) && (a.isStateAffected(2))){100+a.atk*2-b.def*2} else {o;}" (1 and 2 being skills I could just slap on easily for testing) with a few variations here and there on different tries. Not that I really know what I was doing with that, that's just how I'd guessed it could work based on the first post here...
 

Zarsla

Villager
Joined
Dec 25, 2015
Messages
40
Points
48
RM Skill
Programmer
Oh hey it worked! I was certain I'd tried that exact setup already, but I must have been missing something, like the ( ) around b.mhp*o.1, or the spaces around < (if those are necessary). Cheers!
[doublepost=1465163093,1465142633][/doublepost]I'm just not gonna stop bugging you am I... Now that I'm thinking about the states needed to use skillls: what if I wanted a skill to require 2 states instead of 1? I made a test skill (and called it "science"), and tried something along the lines of "if ((a.isStateAffected(1)) && (a.isStateAffected(2))){100+a.atk*2-b.def*2} else {o;}" (1 and 2 being skills I could just slap on easily for testing) with a few variations here and there on different tries. Not that I really know what I was doing with that, that's just how I'd guessed it could work based on the first post here...
It seems okay, I just remove the parnthesis:
if (a.isStateAffected(1)&&a.isStateAffected(2)){100+a.atk*2-b.def*2;} else {o;}
 

Aosha

NPC
Joined
Jun 4, 2016
Messages
5
Points
1
It seems okay, I just remove the parnthesis:
if (a.isStateAffected(1)&&a.isStateAffected(2)){100+a.atk*2-b.def*2;} else {o;}
So it turns out there can be too many parenthesis... Guess I need to get used to that :P Thanks!
 

Ren

NPC
Joined
May 27, 2016
Messages
3
Points
1
RM Skill
Writer
Two forumulas for you to try:

1. a.atk * 4 + 100 + a.mat * 2 - b.def * 2 - b.mdf * 2

What this fourmula means is
Users atk times 4 plus 100 plus user's magic attack times two minus target's defense times 2 minus targets magic defense times 2.

or this :

2. if (b.def > b.mdf) { a.mat * 4 + 100 - b.mdf * 2 ;} else if (b.def < b.mdf ) { a.atk * 4 + 100 - 2 * b.def ;} else { a.atk * 4 + 100 + a.mat * 2 - b.def * 2 - b.mdf * 2 ;}

This is similar to the the other fourmula but it checks if the enemy's def is more than, less than or equal to their magic defense, and then uses a different formula accordingly. I gave you this one as you said you wanted this to still do high damage even if the enemy has a high defense or magic defense.

Oh and the what this formula means is:

if target's defense is greater than it's magic defense, then use this fourmula for damage: the user's magic attack times 4 plus 100 minus 2 times the target's magic defense. Else if the target's defense is less than it's magic defense, then use this fourmula for damage : the user's attack times 4 plus 100 minus 2 times the targets defense. Else if neither of the other two were true and thus the target's defense is equal to it's magic defense then use the same fourmula as the number #1 for damage.
Hopefully this helps and let me know if you need more help! :).
Sorry its taken me so long to repply ive been busy with boring stuff like life :P. Thank you very much for this ive tried both formulas but i think i'll stick with the first one for simplicities sake however the second formula might come in handy at some point. once again thx :)
 

Saruteku

NPC
Joined
Jun 6, 2016
Messages
23
Points
2
RM Skill
Gamer
How would I get the GainHP/TP/MP commands to work? In my case I have a passive called Alcoholic which if the item is alcohol it gives them boosted benifets, but I can't change anything but what the skill is for. My command is:

b.isStateAffected(43) ? b.gainHp(400) b.gainMp(400) b.gainTp(400) : b.gainHp(200) b.gainMp(200) b.gainTp(200);

and it always comes out to 0. I tried a few differant ways but it probably just better to ask.
 

hbn

Villager
Joined
Jul 20, 2016
Messages
56
Points
39
RM Skill
Gamer
Great work at explaining this. Just wondering how some of the general battle stuff works though. Does that mean it'll be possible to make an enemy use only a certain skill on a certain target (like say a character's HP is critical, you can tell it to use a finisher against that character, or say if there are buffs applied, you can tell the enemy to cast a dispel?

Or is that just for making certain skills have different damage formulas based on states, etc?
 

Saruteku

NPC
Joined
Jun 6, 2016
Messages
23
Points
2
RM Skill
Gamer
Great work at explaining this. Just wondering how some of the general battle stuff works though. Does that mean it'll be possible to make an enemy use only a certain skill on a certain target (like say a character's HP is critical, you can tell it to use a finisher against that character, or say if there are buffs applied, you can tell the enemy to cast a dispel?

Or is that just for making certain skills have different damage formulas based on states, etc?
Damage formulas are only considered after an attack has chosen it's target and been initiated, it doesn't choose who gets attacked. For what you're talking about you need to try building up a monster's AI. The best way to do what you're looking for is probably Yanfly's Battle AI Core (http://yanfly.moe/2015/10/19/yep-16-battle-a-i-core/). I haven't started using it myself, but considering how Yanfly's scripts are it should work out great.
 
Status
Not open for further replies.
Top