karyuuouji 0 Posted May 11, 2017 Hi guys... I am planning on making a script where it simulates dropping of item when a monster is killed, but on a determined percentage... Example: if a monster is killed, there is a 10% change of dropping gold... how do I approach this calculation?I tried using rand() but I am not very confident about it cause I cant place a random seed... Can anyone help me with this? Also, can killedrid determine if the killed mob is a Boss or Mini-Boss? Quote Share this post Link to post Share on other sites
0 meko 170 Posted May 11, 2017 if all you want to do is drop an item, this can be done directly in the mob db about rand() you cannot use a custom seed; Hercules generates its own With killedrid you could get the mob id with getunitdats(UDT_CLASS, killedrid) and then you can get further information with getmonsterinfo() Quote Share this post Link to post Share on other sites
0 karyuuouji 0 Posted May 11, 2017 if I do it in mob_db... then I would edit all monster to drop 1 item... which is very much tedious TBH... so I just make use of the OnNPCKillEvent do simulate the dropping of items (which should be directly to the players inventory)... i searched the script_command in the doc folder but I can't find a command for generating random number with seed... What I want to do specifically is when a monster is killed: - determine if its a Boss, Mini-Boss or just a Normal monster. - generate a random number based on some seed (maybe from time). - based on the result of RNG, if it is bellow the percentage i defined, give an item. I have made a simple code for this but I am not sure if it is the best approach or if can be optimized more.what I did in my scripts:- set an array of Boss monster that I know. - check if the killed monster is in the array. - generate a random number from 0 to 9999 - if the result is <= 999 (which is 10%), give an item - announce the player who received the item and from what monster. I tested my script and it works as expected, but sometimes I think it drop more often than not... Quote Share this post Link to post Share on other sites
0 meko 170 Posted May 11, 2017 It's impossible to have perfect RNG without natural entropy. You'd need a hardware generator for that, and even then they're not always perfect Quote Share this post Link to post Share on other sites
0 karyuuouji 0 Posted May 12, 2017 Will this code suffice? if ((rand(0,10000) -= 999) < 0) { // Emulate the 10% drop chance getitem Gold,1; // Gives gold if the result is 10% } That is the code I used and it works.. maybe I will just stick to this My problem now is determining if the killed mob is a Boss, MiniBoss or Normal monster... Quote Share this post Link to post Share on other sites
Hi guys... I am planning on making a script where it simulates dropping of item when a monster is killed, but on a determined percentage...
Example:
if a monster is killed, there is a 10% change of dropping gold...
how do I approach this calculation?
I tried using rand() but I am not very confident about it cause I cant place a random seed...
Can anyone help me with this?
Also, can killedrid determine if the killed mob is a Boss or Mini-Boss?
Share this post
Link to post
Share on other sites