how to make something have a 'chance'
Sort-of new to scripting, I know a good bit though.
I'm looking to learn how to make things have a chance of happening, such as the RTD plugin. I checked out RTD source but it's pretty jam packed with stuff I'm not familiar with. I'm hoping somebody nice would like to explain this to me ;) -PvtSmith |
Re: how to make something have a 'chance'
Just generate a random num and check for a constant value. Getting a number from 1 to 100,for example, and checking if it is 1,would give you a 1/100 or a 1% chance.
Use random_num() for this. |
Re: how to make something have a 'chance'
I suggest random 0-10000 and check if less than 100 for 1% chance
or random float from 0 to 1 and check the percent directly |
Re: how to make something have a 'chance'
Quote:
You could do,for example, random_num(1,400) and check if it's equal to one, or random_num(1,800) and check if its <= 2. Which one is easier to figure out? |
Re: how to make something have a 'chance'
I like using this method:
Code:
|
Re: how to make something have a 'chance'
Quote:
But no need to worry if it's not in a loop, PreThink or a heavy used task. |
Re: how to make something have a 'chance'
From PokeMod
Code:
Chance(id) |
Re: how to make something have a 'chance'
Quote:
|
Re: how to make something have a 'chance'
So using Exo's method, would this work?
Code:
/* Plugin generated by AMXX-Studio */ |
Re: how to make something have a 'chance'
Quote:
|
| All times are GMT -4. The time now is 03:07. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.