Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Damage Formulas 101 (MV Edition)

Status
Not open for further replies.

Luninareph

Villager
Xy$
0.00
I'm terribly sorry, but I can't seem to figure out how to create this specific formula I want for the life of me.

The attack is intended to inflict Slow on the target, unless the target already has Slow inflicted, in which case the attack inflicts Stop. I've tried several different formulae, but all of them either crash the game or just do nothing. Does anybody know how to create such an attack?
 

Dad3353

Praised Adventurer
Far from expert, but this should work...

if (!b.isStateAffected(Slow)) b.addState(Stop); b.addState(Slow)

... which translates to 'If b has State Slow, inflict Stop, otherwise inflict Slow'
Substitute your own State ID's for 'Slow' and 'Stop'. Try it..?
 

Luninareph

Villager
Xy$
0.00
I'm afraid that doesn't work; it causes the game to crash ("Failed to execute 'createLinearGradient' on 'CanvasRenderingContext2D': float parameter 3 is non-finite"). I think this happens because there's no damage in that formula, but I'm not sure how to successfully add damage at the end of it.
 

Dad3353

Praised Adventurer
Sorry, wrong formula (but it should work without an error message; it won't do what you asked for, that's all...).
Try this...

b.isStateAffected(5) ? b.addState(6): b.addState(5)

I've just tested it, and it works. My Database doesn't have 'Slow' or Stop', so the numbers used are those for 'Silence' (5...) and 'Blind' (6...). Change the numbers to the ID's for the States Slow and Stop in your database.

I should add that I don't use plug-ins, and the error message you show may refer to a 'Hit' display that I don't have. If you must have a 'Damage' statement in your formula, maybe add ';0' at the end (that's 'semicolon zero'...). That will inflict Damage of 0, which can be displayed, perhaps..?
 
Last edited:

Luninareph

Villager
Xy$
0.00
It works!!!

b.isStateAffected(65) ? b.addState(32): b.addState(65); 0

I don't know which plugin caused it to need a damage portion, but without the ';0' it crashed again, but with the ';0' it was completely successful! Thank you so much! :D
 
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.
You're getting a 0 out of that formula because of a syntax error. You can't call those functions like that because the things in between the ? and the : are supposed to be expressions. Also, I don't believe that the gainX methods return a value, so if you could call those methods like that you still wouldn't get a number back. The correct way to do this would be to use an if statement instead of a ternary operator (e.g. ? : ).

So, it would go something like this:
Code:
if b.isStateAffected(43) { b.gainHp(400); b.gainMp(400);  b.gainTp(400) } else { b.gainHp(400); b.gainMp(400); b.gainTp(400) }
This would properly increase the HP, MP, and TP of the target, but this would sill end up with a 0 since you aren't producing a number. Considering that you're using gainHp, I'm going to assume this is a healing skill, in which case gainHp is redundant as the number the formula gives is the amount of HP healed.

Try this:
Code:
var heal = b.isStateAffected(43) ? 400 : 200; b.gainMp(heal); b.gainTp(heal); heal
PS. Are the code tags in an unreadable light grey on white text box for anyone else?

EDIT:
It works!!!

b.isStateAffected(65) ? b.addState(32): b.addState(65); 0

I don't know which plugin caused it to need a damage portion, but without the ';0' it crashed again, but with the ';0' it was completely successful! Thank you so much! :D
Please don't use the ternary operator like this. The ternary operator returns one of two values depends on the truth of the value it is applied to. It is not an if statement and it only works here by complete accident. That's part of why you needed to add a ;0 to the end. Since the addState method doesn't return a value.

Please write this as if (b.isStateAffected(65)) { b.addState(32) } else { b.addState(65) }; 0
 
Last edited:

Luninareph

Villager
Xy$
0.00
Please don't use the ternary operator like this. The ternary operator returns one of two values depends on the truth of the value it is applied to. It is not an if statement and it only works here by complete accident. That's part of why you needed to add a ;0 to the end. Since the addState method doesn't return a value.

Please write this as if b.isStateAffected(65) { b.addState(32) } else { b.addState(65) }; 0
Apologies, but this formula didn't work. It didn't crash the game, but it didn't apply any states, either. It's entirely possible I copied it incorrectly or you made an unintentional mistake, but I put it in my playtest and it didn't work.
 
Apologies, but this formula didn't work. It didn't crash the game, but it didn't apply any states, either. It's entirely possible I copied it incorrectly or you made an unintentional mistake, but I put it in my playtest and it didn't work.
Yeah, sorry. I forgot the parentheses.

if (b.isStateAffected(65)) { b.addState(32) } else { b.addState(65) }; 0
 

Luninareph

Villager
Xy$
0.00
Yeah, sorry. I forgot the parentheses.

if (b.isStateAffected(65)) { b.addState(32) } else { b.addState(65) }; 0
All right, that worked! I have absolutely no idea what makes it more "correct" or "elegant" than Dad3353's formula, but if you say it's less likely to bite me later, I'll happily use it! Thank you very much :)
 

Dad3353

Praised Adventurer
All right, that worked! I have absolutely no idea what makes it more "correct" or "elegant" than Dad3353's formula, but if you say it's less likely to bite me later, I'll happily use it! Thank you very much :)
I concur wholeheartedly with Nobody_1707, in that his formula will work in all circumstances, whereas my (too hastily cobbled up...) version only works in limited cases, one of which was the case in the original post. I, too, am learning (the hard way..!) the intricacies to js syntax; sometimes I'm luckier than on other occasions, this being a case in point. We're all moving forward, that's the main thing.
 
Well shoot, everyone else is getting help, I want some help too!

I am looking for the way to put the Weapon Attack Parameter in the formula box. Near as I could find was 'a.weapons.at(1).params.at(2)'
but that....nothing. a.weapons[0].atk, also nothing...I even tried to look at peoples plugins and shoplift that way....nothing.

Someone give me a hand?
 

hbn

Towns Guard
Xy$
0.00
To do so you'd need a plugin. There is Bobstah's Custom Stat's which I'm using but important note, it doesn't work for initial equips. You add a note tag such as <CustomStat: wepdmg+x> to the note section of your weapon. Add <CustomStat: wepdmg=0> to all your actors page and add a.wepdmg to the formula and it should work. It just ignores it when that equipment is an initial equip, for it to work you'll have to equip them through an event. He was meant to be in the process of rewriting the plugin to fix issues like that but he's been inactive for a few months.

How VX/MV works is that you have one attribute that is combined between your character and their equipment. To split them you will need a plugin that can create attributes.
 
AHA! paramBase(2) is the Attack before equip, so....(a.atk-a.paramBase(2)) yields what I need. Long winded but functional

paramBase(0) is MaxHP
paramBase(1) is MaxMP
paramBase(2) is Attack
paramBase(3) is Defense
paramBase(4) is Magic Attack
paramBase(5) is Magic Defense
paramBase(6) is Agility
paramBase(7) is Luck

I was going to use Math.round((a.atk-a.paramBase(2))) to get a random number based on the attack on the weapon, but not sure if that would fit what I am doing....maybe some weapons
 
Love it. I've been scratching my head. This helps alot.
But I would like some help on this:

b.addDebuff(3, 10) ; 9999

this seems to do 9999 dmg and debuff unknown amount on defense for 10 turns. Not quite what i'm looking for.

i would like to control via formula the amount of debuff. also if I lose the 9999 bit and don't put anything, i see a "0" pop up for dmg. This amount is fine as i only meant for debuff, not damage. How do i get rid of the "0"?

As i would like to control the debuff amount with a variable: b.addDebuff(3, 10) by v[x]% of b.def amount.
is there a way?
 

Zephyrim

Villager
Xy$
0.00
Yo! So I'm adding a skill into the game which kills an enemy when it's HP is 15% or less, and heals the user for half the enemy's MHP.

So far I have this:
if (b.hp <= (b.mhp*0.15)) b.hp; else 0;

But I'd like to know where/how to add the "gainHp(b.mhp*0.5)" into it. I know some basic JS and would assume in an expanded form it'd be something like:

if (b.hp <= (b.mhp*0.15)){
b.hp;
gainHp(b.mhp*0.5);
}else{
0;
}

So would I just do this:
if (b.hp <= (b.mhp*0.15)) b.hp; gainHp(b.mhp*0.5); else 0;

???
 
Hello everyone .. I'm trying to create an assassination move. One that counts the number of unique states on a target and deals damage for every one. So far I have tried counting the number of states with common event conditionals .. That doesn't work because I can't specify an actor's current target. Theoretically I could mage a skill that does damage for all states on enemy 1 - 8 .. or even all enemies. But not the focus of the actor's skill .. I have also tried this formula.

(b.isStateAffected(4) ? r = a.atk * 5: r = a.atk * 1) + (b.isStateAffected(8) ? r = a.atk * 5: r = a.atk * 1) + (b.isStateAffected(9) ? r = a.atk * 5: r = a.atk * 1)

To check for three states to test the principle. But the damage output is always zero .. which i think is mv's way of doing a shoulder shrug.
 
Status
Not open for further replies.
Top