Skip to content

Commit

Permalink
agility: add hallowed sepulchre lap tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
raiyni committed Jun 24, 2024
1 parent d341b4c commit 56edc62
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 7 deletions.
5 changes: 5 additions & 0 deletions runelite-api/src/main/java/net/runelite/api/Varbits.java
Original file line number Diff line number Diff line change
Expand Up @@ -889,4 +889,9 @@ public final class Varbits

public static final int SPELLBOOK = 4070;
public static final int SPELLBOOK_SUBMENU = 9730;

/**
* Counts up from 0 while in Sepulchre and doesn't reset until you leave the arena
*/
public static final int SEPULCHRE_TOTAL_TIME = 10393;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import net.runelite.api.Tile;
import net.runelite.api.TileItem;
import net.runelite.api.TileObject;
import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.DecorativeObjectDespawned;
import net.runelite.api.events.DecorativeObjectSpawned;
Expand Down Expand Up @@ -222,11 +223,29 @@ public void onStatChanged(StatChanged statChanged)

log.debug("Gained {} xp at {}", skillGained, client.getLocalPlayer().getWorldLocation());

if (!config.showLapCount())
{
return;
}

// Get course
Courses course = Courses.getCourse(client.getLocalPlayer().getWorldLocation().getRegionID());
if (course == null
|| !config.showLapCount()
|| Arrays.stream(course.getCourseEndWorldPoints()).noneMatch(wp -> wp.equals(client.getLocalPlayer().getWorldLocation())))
if (course == null)
{
if (isInSepulcher())
{
if (session == null || session.getCourse() != Courses.SEPULCHRE)
{
session = new AgilitySession(Courses.SEPULCHRE);
}

session.addFloorXp(skillGained);
}

return;
}

if (Arrays.stream(course.getCourseEndWorldPoints()).noneMatch(wp -> wp.equals(client.getLocalPlayer().getWorldLocation())))
{
return;
}
Expand Down Expand Up @@ -277,7 +296,14 @@ public void onItemDespawned(ItemDespawned itemDespawned)
@Subscribe
public void onGameTick(GameTick tick)
{
if (isInAgilityArena())
if (session != null && session.getCourse() == Courses.SEPULCHRE)
{
if (!isInSepulcher() && session.getFloorXp() > 0)
{
session.incrementLapCount(client, xpTrackerService);
}
}
else if (isInAgilityArena())
{
// Hint arrow has no plane, and always returns the current plane
WorldPoint newTicketPosition = client.getHintArrowPoint();
Expand All @@ -300,6 +326,11 @@ public void onGameTick(GameTick tick)
}
}

private boolean isInSepulcher()
{
return client.getVarbitValue(Varbits.SEPULCHRE_TOTAL_TIME) > 0;
}

private boolean isInAgilityArena()
{
Player local = client.getLocalPlayer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
package net.runelite.client.plugins.agility;

import com.google.common.collect.EvictingQueue;
import java.time.Duration;
import java.time.Instant;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Client;
import net.runelite.api.Skill;
import net.runelite.client.plugins.xptracker.XpTrackerService;
import java.time.Duration;
import java.time.Instant;

@Getter
@Setter
Expand All @@ -43,12 +43,18 @@ class AgilitySession
private int lapsTillGoal;
private final EvictingQueue<Duration> lastLapTimes = EvictingQueue.create(30);
private int lapsPerHour;
private int floorXp;

AgilitySession(Courses course)
{
this.course = course;
}

void addFloorXp(int xp)
{
floorXp += xp;
}

void incrementLapCount(Client client, XpTrackerService xpTrackerService)
{
calculateLapsPerHour();
Expand All @@ -65,6 +71,11 @@ void incrementLapCount(Client client, XpTrackerService xpTrackerService)
// the bonus is not already accounted for in the total exp number in the courses enum
courseTotalExp += Math.min(300 + 8 * client.getRealSkillLevel(Skill.AGILITY), 1000);
}
else if (floorXp > 0)
{
courseTotalExp = floorXp;
floorXp = 0;
}

lapsTillGoal = goalRemainingXp > 0 ? (int) Math.ceil(goalRemainingXp / courseTotalExp) : 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ enum Courses
POLLNIVNEACH(1016.0, 13358, new WorldPoint(3363, 2998, 0)),
RELLEKA(920.0, 10553, new WorldPoint(2653, 3676, 0)),
PRIFDDINAS(1337.0, 12895, new WorldPoint(3240, 6109, 0)),
ARDOUGNE(889.0, 10547, new WorldPoint(2668, 3297, 0));
ARDOUGNE(889.0, 10547, new WorldPoint(2668, 3297, 0)),
SEPULCHRE(-1, -1, new WorldPoint(2400, 5982, 0));

private final static Map<Integer, Courses> coursesByRegion;

Expand Down

0 comments on commit 56edc62

Please sign in to comment.