Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by msmile042, Jun 13, 2018.
We wont spoonfeed you, just saying..
If you mean hurt in any way, check the EntityDamage event, check if its a player.
Then generate a random number (for example between 0-100) and check if the number is greater/smaller then what ever chance you want..
Then if the chance happens, give speed.
Correct. As a tiny addition, just wanted to mention that I always generate a random double (if you want a chance of 1.5% for example) between 0 and 100. Then, I check if the random number is less than the configured chance. Say I want a monster to drop an item with a 20% drop count, and I generate a random number and it ends with 50; 50 is not less than 20 so it won't drop. If it's below 20, say it ended on 12, it will be lower than 20 and the item will be dropped.
I do it like that too. I think its the "more simple?" option.. I dont like to check it with > .. I dont know why.
Using > wouldn't work though, would it? If your chance was 20% (0.2), and you got a random double from 0.0 to 1.0, it'd be over 0.2 for 80% of the time, which is obviously not right?
I mean checking > 0.8 then, would still be 20%