Formulas Implemented + Random
![thespis721](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hey guys,
I saw how to add mathematical formulas using the expression editor, however, I have a an implementation question. Let's say I want to have it that you click a button and that runs a formula that comes up with a number. From that number, I want to be able to allow that to be the percentage chance that a hit is made. Kind of a D&D, 100 sided dice rolling kind of element, but it be completely under the hood. Any idea how to do that? I've been staring at this for days and I just can't figure it out.
Also, bonus question: Where can I use this on an IF statement. Such as, if "If there is a hit, then run formula attribute-attribute=number" and then random dice roll that?
I really appreciate the help, guys.
I saw how to add mathematical formulas using the expression editor, however, I have a an implementation question. Let's say I want to have it that you click a button and that runs a formula that comes up with a number. From that number, I want to be able to allow that to be the percentage chance that a hit is made. Kind of a D&D, 100 sided dice rolling kind of element, but it be completely under the hood. Any idea how to do that? I've been staring at this for days and I just can't figure it out.
Also, bonus question: Where can I use this on an IF statement. Such as, if "If there is a hit, then run formula attribute-attribute=number" and then random dice roll that?
I really appreciate the help, guys.
Comments
I implemented a system where when the player finishes a level (so, *if* gamelevelfinished = true) I give the player a percentage of his score added to the score:
Change attribute percentagescore to (random (.1,1)*gamescore)
Change attribute gamescore to gamescore+percentagescore
To display the percentage I put in a display behaviour that says:
Display (percentagescore/gamescore)*100
Hope that points you in the right direction - like I say, I'm no maths whiz!
Cheers,
QS
EDIT - for the bonus question, you could (in my example) use:
If player hits enemy
AND (percentagescore/gamerscore)*100 > 50
Then HIT enemy
Otherwise
MISS enemy
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
QS
EDIT - just tried that, and it works better
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io