Listener for drops of NPC

Hello everyone,

I’m writing a script in which i kill a npc and keep track of the loot. I have the following questions about it:

  1. Is there a listener that notifies you when the loot appears on the ground?
  2. Is there an API where i can get the spawn time or despawn time?

Now i currently do this:

Since i have to wait till the death animation of the target is done, i have to use a threadpool to keep track of multiple loots. What i want to do is keep track of all loot dropped by npc’s that i killed. If possible i also want to render the despawn time on the objects.

Can anyone help me? Thank you.

  1. I’m not actually sure, but personally I’d probably simply wait until I detect that my interacting/last fighting npc hits 0 hitpoints, log the position, then simply store the loot that appears subsequently into a list.
  2. Not to my knowledge, but again, if you know the time that an npc has died/deregistered at, you may be able to calculate when it’s due to respawn. I believe that there’s an algorithm relating to the number of players in a given world that increases/decreases spawn times accordingly. It’s probably posted on rs-wiki or somewhere of the likes, you could use this in conjunction with the death time to calculate the prospective respawn time.

E:/

According to the oswiki, the respawn timers are now uniform across worlds, so you simply determine the time taken for an npc to respawn once, then you could probably use a Map to store npc/spawn data in.

Thank you,
On 1. : Your solution is how i’m currently doing it. But i find it a little bit obnoxious.
On 2. : i mean the despawn time of the drops of npc’s not the npc itself.

Check out ObjectSpawnListener

Oh I see. Well I’m sure that npc drops are a flat 60 second time out?

Is it 60 second until others see it and 120 until it despawns?

That’s what I’ve always believed, yeah.

1 Like