Jump to content
  • 0
Sign in to follow this  
karyuuouji

RGN on Script

Question

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

4 answers to this question

Recommended Posts

  • 0

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()

Share this post


Link to post
Share on other sites
  • 0

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...
 

Share this post


Link to post
Share on other sites
  • 0

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... 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.