Skip to content

Commit

Permalink
bosstimer: add araxxor
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Aug 28, 2024
1 parent b9b5f4d commit 528d8a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ItemID;
import net.runelite.api.NpcID;
import net.runelite.client.util.RSTimeUnit;

@Getter
enum Boss
{
GENERAL_GRAARDOR(NpcID.GENERAL_GRAARDOR, 90, ChronoUnit.SECONDS, ItemID.PET_GENERAL_GRAARDOR),
Expand Down Expand Up @@ -69,13 +71,17 @@ enum Boss
ZALCANO(NpcID.ZALCANO_9050, 21600, ChronoUnit.MILLIS, ItemID.SMOLCANO),
PHANTOM_MUSPAH(NpcID.PHANTOM_MUSPAH_12080, 50, RSTimeUnit.GAME_TICKS, ItemID.MUPHIN),
THE_LEVIATHAN(NpcID.THE_LEVIATHAN, 30, RSTimeUnit.GAME_TICKS, ItemID.LILVIATHAN),
// Harvestable Araxxor is not marked dead so that it is always interactable and visible,
// but we still want the respawn timer to show when it despawns.
ARAXXOR(NpcID.ARAXXOR_13669, 15, RSTimeUnit.GAME_TICKS, ItemID.NID, true),
;

private static final Map<Integer, Boss> bosses;

private final int id;
private final Duration spawnTime;
private final int itemSpriteId;
private final boolean ignoreDead;

static
{
Expand All @@ -91,27 +97,18 @@ enum Boss

Boss(int id, long period, TemporalUnit unit, int itemSpriteId)
{
this.id = id;
this.spawnTime = Duration.of(period, unit);
this.itemSpriteId = itemSpriteId;
}

public int getId()
{
return id;
this(id, period, unit, itemSpriteId, false);
}

public Duration getSpawnTime()
Boss(int id, long period, TemporalUnit unit, int itemSpriteId, boolean ignoreDead)
{
return spawnTime;
}

public int getItemSpriteId()
{
return itemSpriteId;
this.id = id;
this.spawnTime = Duration.of(period, unit);
this.itemSpriteId = itemSpriteId;
this.ignoreDead = ignoreDead;
}

public static Boss find(int id)
static Boss find(int id)
{
return bosses.get(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,17 @@ protected void shutDown() throws Exception
public void onNpcDespawned(NpcDespawned npcDespawned)
{
NPC npc = npcDespawned.getNpc();
Boss boss = Boss.find(npc.getId());

if (!npcUtil.isDying(npc))
{
return;
}

int npcId = npc.getId();

Boss boss = Boss.find(npcId);

if (boss == null)
if (boss == null || (!boss.isIgnoreDead() && !npcUtil.isDying(npc)))
{
return;
}

// remove existing timer
infoBoxManager.removeIf(t -> t instanceof RespawnTimer && ((RespawnTimer) t).getBoss() == boss);

log.debug("Creating spawn timer for {} ({} seconds)", npc.getName(), boss.getSpawnTime());
log.debug("Creating spawn timer for {} ({})", npc.getName(), boss.getSpawnTime());

RespawnTimer timer = new RespawnTimer(boss, itemManager.getImage(boss.getItemSpriteId()), this);
timer.setTooltip(npc.getName());
Expand Down

0 comments on commit 528d8a1

Please sign in to comment.