-
[F8] 2 questions about damage dealing using random math
In my current combat system, when the character attacks, I use this script.
Code:
_root.orchp -= random(40);
so he only deals 0-40 damage to the orc.
my question is, I want it to be 20-40 instead of 0-40, also, how can i turn that current attack into a variable so the damage you deal appears above the creatures head?
-
For the second question, put a dynamic text box above the character's head and change your code to something along these lines:
Code:
_root.orchp -= Damage;
Damage = random(40);
As for the question about a minimum number of 20, ask somebody else.
-
Thanks, I got the first one to work, I just used this code
Code:
_root.orchp -= Math.round((Math.random()*20)+30);
-
do your smiles love u?
Code:
_root.orchp -= 20 + random(20);
pretty simple eh
-
Professional Air Guitarist
If you want to display the damage of the attack, first put the value in a variable
PHP Code:
attackDamage = 20+Math.random(20);
Then use that variable to decrement the enemy health and display the number where ever
PHP Code:
_root.orchp -= attackDamage; _root.myTextBox.text = attackDamage+" damage delt!";
Good luck!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|