Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/main/java/io/blert/challenges/inferno/InfernoNpc.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package io.blert.challenges.inferno;

import io.blert.core.Hitpoints;
import io.blert.core.NpcAttack;
import java.util.Optional;
import lombok.Getter;
Expand Down Expand Up @@ -105,6 +106,23 @@ boolean isPillar() {
return this == ROCKY_SUPPORT;
}

boolean isResurrectable() {
switch (this) {
case BAT:
case BLOB:
case MELEER:
case RANGER:
case MAGER:
return true;
default:
return false;
}
}

Hitpoints resurrectedHitpoints() {
return new Hitpoints((hitpoints + 1) / 2, hitpoints);
}

@SafeVarargs
InfernoNpc(int id, int hitpoints, Pair<Integer, NpcAttack>... attacks) {
this.id = id;
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/io/blert/challenges/inferno/WaveDataTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,16 @@ protected void start() {
}

// NPC spawn events are typically received before the wave start message,
// so capture any NPCs that are already present.
client.getTopLevelWorldView().npcs().stream().forEach(npc -> {
InfernoNpc.withId(npc.getId())
.filter(inf -> !inf.isPillar())
.ifPresent(infernoNpc -> addTrackedNpc(
new BasicTrackedNpc(npc, generateRoomId(npc), new Hitpoints(infernoNpc.getHitpoints()))));
});
// so capture any NPCs that are already present, ignoring those already
// captured during NOT_STARTED.
client.getTopLevelWorldView().npcs().stream()
.filter(npc -> getTrackedNpcs().getByNpc(npc).isEmpty())
.forEach(npc -> {
InfernoNpc.withId(npc.getId())
.filter(inf -> !inf.isPillar())
.ifPresent(infernoNpc -> addTrackedNpc(new BasicTrackedNpc(
npc, generateRoomId(npc), new Hitpoints(infernoNpc.getHitpoints()))));
});
}

@Override
Expand All @@ -88,8 +91,12 @@ protected Optional<? extends TrackedNpc> onNpcSpawn(NpcSpawned event) {
// Pillars are managed by the challenge itself.
return Optional.empty();
}
return Optional.of(new BasicTrackedNpc(
event.getNpc(), generateRoomId(event.getNpc()), new Hitpoints(npc.getHitpoints())));

Hitpoints hitpoints = getTick() > 0 && wave <= 66 && npc.isResurrectable()
? npc.resurrectedHitpoints()
: new Hitpoints(npc.getHitpoints());
Comment thread
frolv marked this conversation as resolved.

return Optional.of(new BasicTrackedNpc(event.getNpc(), generateRoomId(event.getNpc()), hitpoints));
});
}

Expand Down
Loading