Jump to content
  • 0

[source request] item dropped on 'OnNPCKillEvent' label calling


Kurofly

Question


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Hello everyone!

 

I'd like to be able to see which items a player got when he killed a monster but since there's no efficient way to do this via scripting (or so I think) that'd be very nice of you if you could help me doing this via src.

 

I'd like to fill the $@Item_dropped[] array with the items id dropped by the monster before calling the 'OnNPCKillEvent' label. I'd also need to set the '$@Item_dropped_amount' variable to the amount of items dropped to avoid getting items dropped by another monster.

 

I didn't even find the call of that label in the src files so I really need your help ^^

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

Amount? I don't get it. OnNPCKillEvent is called for each mob killed, there can't be an amount higher than 1. Please correct me if I'm wrong.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Thanks for your answer.

 

Yes I know that but I'd like it to fill the array with the items the player got by killing this monster.

$@Item_dropped_amount would be the array size of that array.

Edited by Kurofly
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   13
  • Joined:  06/20/12
  • Last Seen:  

You can use this command to build the array:
 

 
pc_setreg(sd,reference_uid(add_str("@item_dropped"), i),item_id);

You need to find the function where itens are dropped. Start searching from mob_dead on mob.c
Then you put pc_setreg inside the for. To know the array size in script you can simply use getarraysize.
Not sure if the array need to be reseted before built.
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Thanks for that ! I'll try it very soon.

 

I can't use getarraysize because if the previous monster dropped 3 items and the current monster dropped only 2 the third item will count in the getarraysize() even though it was not dropped by that monster.

 

So I either have to delete the array before use or set a global variable to the amount of items dropped by the current monster.


This is really too hard for me xD I tried to look up in mob.c and I think I need to add something here

if(md->lootitem) {
			for(i = 0; i < md->lootitem_count; i++) 
			mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly); 
		}

But I have no experience with source and I don't know what to do, I tried a few things but they all give me errors ^^

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

you wont really get the accurate values...

 

imagine you use AOE Skill to kill MVP .. you try to get the item drops of MVP ... but you end up getting the item list from the slave, because your AOE skills hit the slaves as well right after the mvp died.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

Thanks for your answer as well.

 

In fact I have a party bonus script wich gives drop bonus to grouped players on the same map.

At the same time I have an the rare_drop_announce activated for items  with 1% or less drop rate.

 

I'd have liked to display the value of the bonus the group has, along with the drop announce but I need to find a way to know when a monster drops an item with 1% or less chance.

 

So even if some monster drops are skipped it won't be a big deal, maybe sometimes an announce won't show that's all.

 

I know nothing about src and I just thought setting global variables would be an easy task but if you think there's a better way to do it I'd be glad to hear it  /no1

Link to comment
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.   Paste as plain text instead

  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.

×
×
  • Create New...