I want there to be a 50% chance of getting a number. Example: A character has 100 Damage but will have about 50% that deals 200 Damage. It is similar to the critical rate in the League of Legends.
Asked
Active
Viewed 1,235 times
-3
-
1Please improve the problem description. – U. Windl May 06 '19 at 13:01
-
1**if (Math.random() > 0.5)** – Organis May 06 '19 at 13:06
-
Example: A character, each attack will usually deal 100 damage but will have 50% to inflict 200 damage. Ie: in 100 attacks there will be 50 times 100 Damage and 50 times 200 Damage. I'm from Vietnam so I'm not good at English. Wish you sympathize. – Thịnh Phú May 06 '19 at 13:12
1 Answers
1
I added a variable instead of just simply declaring if (Math.random()), so you can see WHERE the critical chance is happening, the variable is not necessary
var critchance:Number = 0;
saidcharacterHP-=100;
critchance = Math.random();
if (critchance>0.5)
{
saidcharacterHP-=100;
}

Koden
- 353
- 1
- 13