# Help! Random States in Damage Formula or Yanfly Buff/state Core

#### Nerdboy

##### Veteran
hi im trying to create a curse skill that randomly picks 1 out of 6 types of states. but im having trouble with it. none of my code works in the damage formula box.

example.

no errors but no state is applied. the code to me looks right but maybe its syntax got wrong idk. please help.

ive also tried using yanfly's buff state core using lunatic mode. but it pops up error messages when i enter a similiar but slighty different code then above.

Last edited by a moderator:

#### shockra

##### Slightly Crazy Programmer
Are you using if statements?  If not, that's the problem.  It's hard to determine much without seeing the code you used.  Post the lunatic mode code you used and maybe we can figure out the problem.

#### Andar

##### Veteran
That code doesn't look right to me, because no matter what, you never used the x if that is exactly the code you placed, because all x is used in are assignments, there isn't a single if or any comparison using x (which would be x===2, not x=2)

That said, why using X at all?

Such a code will require you to have the states in a consequitive ID-sequence in the database, but ordering them is easier than placing half a dozen if-sequences in the damage formula.

Last edited by a moderator:

#### Nerdboy

##### Veteran
thank you ANDAR!!! that code works like a charm!

I spent hours trying to figure this out.

#### Nerdboy

##### Veteran
if anyone wants the code for it. this skill i  call "Plague". it inflicts 5 types of states at random. and hits all enemies.

x = Math.floor(Math.randomInt(5) + 1); if (x === 1) {b.addState(46);} if (x === 2) {b.addState(47);} if (x === 3) {b.addState(49);} if (x === 4) {b.addState(50);} if (x === 5) {b.addState(51);}

im having so much fun with Math.randomInt here's another skill called, "Roulette". it adds a random multiplier with luck as its base damage type from 1-100 minus 0-25 of enemies luck stat. very fun skill to use.

a.luk * (Math.floor(Math.randomInt(100) + 1)) - b.luk * (Math.floor(Math.randomInt(25)));

### Latest Profile Posts

And the beginning of a nearly complete grid system dawns.

I want to add a thin pixel border around the entire region. Like across all blue highlights that connect and red attack highlights that connect.
--- Remake ---

Hero: Hey,look! Some Artist will Remake us to 3D!
M.Knight: Really? Then i hope they make me so Cool & Handsome
Heroine: I hope they make me Cute & Sexy,too
(6 Months Later,The 3D Model Are Revealed With Unexpected Yet Horrible Model)
Hero: (Spit The Water)
M.Knight: What the Hell?!
Heroine: I'm Dissapointed...
my battle system is REALLY coming together. I can already see strategies between 2 of my party members forming lol. helps that battles are 2 at a time. but the combo of these two is really fun.
@taarna23's status just made me realise I haven't had any scam calls since that guy who hung up on me before he even began reading his script. How quiet it's been ... they were pretty much the only people who ever called!