Issues with damage formula's

Hello everyone, i've been having a lot of trouble with damage formulas.


I want to make certain attacks more complex, including things such as random chance for high damage, dice rolls during skill calculation, etc.


i tried making a skill do bonus damage if a variable is a certain number (the skill activates a common event that makes that variable a random number from 1-7)


if v[1] == 7; a.luk * 5; else; a.atk * 3; end;


That was my formula, but it doesn't seem to do any damage.


If anyone can offer assistance i'd be grateful, and if there's an advanced skill formula guide for MV anywhere around here i'd love to have a look at it.


Thank you very much.
$gameVariables.value(x)


is the correct way to get a variable's value in the damage formula box. Replace x with the id of the variable you want to pull.


Edit: if you're populating the variable via a common event attached to the skill, you're going to have an empty variable. Common events don't run until after the damage formula runs. You'd need a formula along the lines of

Code:
var n = Math.floor((Math.random() * 7) + 1); $gameVariables.setValue(x, n); $gameVariables.value(x)
@Kenen


i tried replacing my old variable formula with 


if $gameVariables.value(1) == 7; a.luk * 6; else; a.atk * 3; end;


and the damage is still coming up as 0 whenever i test it.
See my edited post.
@Kenen


Im still having trouble, sorry for all the questions.


i changed the formula to 


var n = Math.floor((Math.random() * 7) + 1); if n == 7; a.luk * 6; else; a.atk * 3; end;


so in theory it should be calling to check the n value after the random integer is rolled, but i keep getting 0 damage no matter what.


I'm new to damage formulas so im sorry if this is simple and i'm just not understanding it.
Try this one:


v[1] == 7 ? a.luk*6 : a.atk*3;


Also, make sure the skill is set to deal HP damage, or it won't hurt the opponent otherwise.
@LightningLord2


Thank you! it worked. I was wondering if there was a place i could find all the syntax for damage formula coding. If i had a resource in front of me to work with it'd be great.


Also, could you explain what exactly was wrong with my syntax before? Yours look drastically different from my previous one.
The code is Javascript there are lots of resources for it,


http://www.tutorialspoint.com/javascript/javascript_operators.htm


is one.


As for what you can put in a damage formula its pretty much anything, but here are the usual ones.


https://docs.google.com/spreadsheets/d/1N5jG2xN_K6ker0GOhQkk2sTCiJg9V08OOXqi9N6mVyo/edit?pref=2&pli=1#gid=949662942

Original thread: https://forums.rpgmakerweb.com/threads/issues-with-damage-formulas.63846/