I again have been racking my brain trying increase the functions of some of my nightbot games such as cast a spell. The original code is not mine but it does function as written
$(user) Casts a Spell on $(touser) it backfires and turns them into a $(eval a=[Bull Frog,Swing Set,Prickly Cactus,Sasquatch,Pumpkin,73 Pinto,Wet Noodle];a[Math.floor(Math.random()*a.length)])!
I was attempting to add a % to cast so say 20% of the time it would WORK and the other 80% of the time it would display one of the backfire results. To which I found a hit or miss code
$(user) Throws a dart at the bullseye $(eval var roll = Math.floor(Math.random() * 100) + 1; if (roll <= 20) { "YOU HIT THE Bulls Eye! GREAT SHOT" } else { "U MISSED. Please try Again" })
and with help here from great people that works as intended...
Now comes the part I just can't seem to get an understanding for. Ideally I want to combine the code from both of these into one function the following is as far as I got after a few days of driving myself batty I thought I would ask here...
Following is my horrible attempt at combining the two codes into a working one...
$(user) Casts a Spell on $(touser) $(eval var roll = Math.floor(Math.random() * 100) + 1; if (roll <= 20) { "The SPELL WORKS and turns $(tuser) into a God/Godess" } else { it backfires and turns $(touser) into a $(eval a=[Bull Frog,Swing Set,Prickly Cactus,Sasquatch,Pumpkin,73 Pinto,Wet Noodle];a[Math.floor(Math.random()*a.length)] })
any help on this is greatly appreciated.
JTS