npc indicators: Fix long respawn timer bug

By killing a monster which has a known respawn timer and leaving its
respawn area (by walking away or teleporting) and returning to it some
time after it has respawned, the plugin can erroneously overwrite its
respawn time with a much longer one. This commit fixes that issue by
assuming that the lower of the observed respawn time and the previously
recorded respawn time is the correct one.
This commit is contained in:
Jordan Atwood
2019-06-27 22:43:44 -07:00
parent 8ee3e483f4
commit 1a7aa4666b

View File

@@ -548,7 +548,16 @@ public class NpcIndicatorsPlugin extends Plugin
if (mn.getDiedOnTick() != -1)
{
mn.setRespawnTime(client.getTickCount() + 1 - mn.getDiedOnTick());
final int respawnTime = client.getTickCount() + 1 - mn.getDiedOnTick();
// By killing a monster and leaving the area before seeing it again, an erroneously lengthy
// respawn time can be recorded. Thus, if the respawn time is already set and is greater than
// the observed time, assume that the lower observed respawn time is correct.
if (mn.getRespawnTime() == -1 || respawnTime < mn.getRespawnTime())
{
mn.setRespawnTime(respawnTime);
}
mn.setDiedOnTick(-1);
}