Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Sailing quality-of-life for charting, navigation, facilities, and more.
## Menu Entry Swaps
- Sails At Helm Only: Deprioritizes sail interaction options when you’re not at the helm.
- Prioritize Cargo Hold: Prioritizes clicking the Cargo Hold over nearby objects to make it easier to open.
- Lock to Helm During Trials: Deprioritizes non-movement facilities while sailing through Barracuda Trials.

## Sea Charting
- Highlight Sea Charting Locations: Highlights nearby chartable locations.
Expand Down
43 changes: 24 additions & 19 deletions src/main/java/com/duckblade/osrs/sailing/SailingConfig.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.duckblade.osrs.sailing;

import java.awt.Color;
import java.util.Set;

import com.duckblade.osrs.sailing.features.barracudatrials.locktohelm.LockToHelmFilter;
import net.runelite.client.config.Alpha;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
Expand Down Expand Up @@ -443,18 +446,6 @@ default boolean prioritizeCargoHold()
return true;
}

@ConfigItem(
keyName = "hideStopNavigatingDuringTrials",
name = "Deprio Stop-navigating During BT",
description = "Deprioritizes the 'Stop-navigating' and 'Escape' option while you are in a Barracuda Trial.",
section = SECTION_MES,
position = 3
)
default boolean hideStopNavigatingDuringTrials()
{
return true;
}

enum ShowChartsMode
{
NONE,
Expand Down Expand Up @@ -587,12 +578,26 @@ default boolean chartingMermaidSolver()
return true;
}

String LOCK_PLAYER_TO_HELM = "lockToHelmDuringTrials";
@ConfigItem(
keyName = LOCK_PLAYER_TO_HELM,
name = "Lock to Helm",
description = "Hides actions unrelated to the trial or selected movement facilities. " +
"Selecting \"Disabled\" turns this feature off.",
section = SECTION_BARRACUDA_TRIALS,
position = 1
)
default Set<LockToHelmFilter> lockToHelmFilter()
{
return Set.of(LockToHelmFilter.WIND_GALE_CATCHER, LockToHelmFilter.CRYSTAL_EXTRACTOR);
}

@ConfigItem(
keyName = "barracudaHighlightLostCrates",
name = "Highlight Crates",
description = "Highlight lost crates that need to be collected during Barracuda Trials.",
section = SECTION_BARRACUDA_TRIALS,
position = 1
position = 2
)
default boolean barracudaHighlightLostCrates()
{
Expand All @@ -604,7 +609,7 @@ default boolean barracudaHighlightLostCrates()
name = "Crate Colour",
description = "The colour to highlight lost crates.",
section = SECTION_BARRACUDA_TRIALS,
position = 2
position = 3
)
@Alpha
default Color barracudaHighlightLostCratesColour()
Expand All @@ -617,7 +622,7 @@ default Color barracudaHighlightLostCratesColour()
name = "Hide Portal Transitions",
description = "Hide the transition animation when taking a portal in The Gwenith Glide.",
section = SECTION_BARRACUDA_TRIALS,
position = 3
position = 4
)
default boolean barracudaHidePortalTransitions()
{
Expand All @@ -629,7 +634,7 @@ default boolean barracudaHidePortalTransitions()
name = "TT: Show Rum Target",
description = "Show whether you have rum/need to drop-off rum in the Tempor Tantrum course.",
section = SECTION_BARRACUDA_TRIALS,
position = 4
position = 5
)
default boolean barracudaTemporTantrumShowRumTarget()
{
Expand All @@ -641,7 +646,7 @@ default boolean barracudaTemporTantrumShowRumTarget()
name = "JJ: Show Toady Targets",
description = "Show which outcrops need toadies thrown at them in the Jubbly Jive course.",
section = SECTION_BARRACUDA_TRIALS,
position = 5
position = 6
)
default boolean barracudaJubblyJiveShowToadyTargets()
{
Expand All @@ -653,7 +658,7 @@ default boolean barracudaJubblyJiveShowToadyTargets()
name = "Splits Chat Message",
description = "Post Barracuda Trials split times to chat.",
section = SECTION_BARRACUDA_TRIALS,
position = 6
position = 7
)
default boolean barracudaSplitsChatMessage()
{
Expand All @@ -665,7 +670,7 @@ default boolean barracudaSplitsChatMessage()
name = "Splits Overlay Panel",
description = "Show an overlay panel with Barracuda Trials split times.",
section = SECTION_BARRACUDA_TRIALS,
position = 7
position = 8
)
default boolean barracudaSplitsOverlayPanel()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package com.duckblade.osrs.sailing.features.barracudatrials.locktohelm;

import com.duckblade.osrs.sailing.SailingConfig;
import com.duckblade.osrs.sailing.features.util.SailingUtil;
import com.duckblade.osrs.sailing.model.BarracudaTrialTier;
import com.duckblade.osrs.sailing.model.SailTier;
import com.duckblade.osrs.sailing.model.WindFacilityTier;
import com.duckblade.osrs.sailing.module.PluginLifecycleComponent;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.Client;
import net.runelite.api.MenuAction;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.ConfigChanged;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.inject.Inject;
import javax.inject.Singleton;

@Slf4j
@Singleton
public class LockToHelmDuringTrials
implements PluginLifecycleComponent
{

private final Client client;
private final SailingConfig config;
private Set<Integer> clickableObjects;
private Set<LockToHelmFilter> lockToHelmFilters;

@Inject
public LockToHelmDuringTrials(Client client, SailingConfig config)
{
this.client = client;
this.config = config;
this.lockToHelmFilters = config.lockToHelmFilter();
this.clickableObjects = reloadClickableObjects();
}

private Set<Integer> reloadClickableObjects()
{
return Stream.of(
Arrays.stream(BarracudaTrialTier.values())
.map(BarracudaTrialTier::getGameObjectIds)
.flatMapToInt(Arrays::stream),
Arrays.stream(SailTier.values())
.map(SailTier::getGameObjectIds)
.flatMapToInt(Arrays::stream),
Arrays.stream(WindFacilityTier.getWindFacilityObjectIDs(WindFacilityTier.WIND_CATCHER, WindFacilityTier.GALE_CATCHER))
.filter(s -> lockToHelmFilters.contains(LockToHelmFilter.WIND_GALE_CATCHER)),
Arrays.stream(WindFacilityTier.CRYSTAL_EXTRACTOR.getGameObjectIds())
.filter(s -> lockToHelmFilters.contains(LockToHelmFilter.CRYSTAL_EXTRACTOR))
)
.flatMapToInt(s -> s)
.boxed()
.collect(Collectors.toUnmodifiableSet());
}

@Subscribe
public void onConfigChanged(ConfigChanged e)
{
if (isEnabled(config) && SailingConfig.LOCK_PLAYER_TO_HELM.equals(e.getKey()))
{
log.info("{}: {} -> {}", e.getKey(), e.getOldValue(), e.getNewValue());
lockToHelmFilters = config.lockToHelmFilter();
clickableObjects = reloadClickableObjects();
}
}

@Subscribe(priority = -99)
public void onMenuEntryAdded(MenuEntryAdded e)
{
if (!SailingUtil.isInBarracudaTrialAndAtHelm(client))
{
return;
}

if (e.getMenuEntry().getType() != MenuAction.SET_HEADING)
{
if (!clickableObjects.contains(e.getIdentifier()))
{
e.getMenuEntry().setDeprioritized(true);
}
}
}

@Override
public boolean isEnabled(SailingConfig config)
{
return !config.lockToHelmFilter().contains(LockToHelmFilter.DISABLED);
}

@Override
public void startUp()
{
lockToHelmFilters = config.lockToHelmFilter();
clickableObjects = reloadClickableObjects();
log.info("{}: {}", this.getClass().getSimpleName(), lockToHelmFilters);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.duckblade.osrs.sailing.features.barracudatrials.locktohelm;

import com.duckblade.osrs.sailing.model.WindFacilityTier;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public enum LockToHelmFilter
{
DISABLED(new int[] {})
{
@Override
public final String toString()
{
return "Disabled";
}
},

WIND_GALE_CATCHER(WindFacilityTier.getWindFacilityObjectIDs(WindFacilityTier.WIND_CATCHER, WindFacilityTier.GALE_CATCHER))
{
@Override
public final String toString()
{
return "Wind/Gale Catcher";
}
},

CRYSTAL_EXTRACTOR(WindFacilityTier.CRYSTAL_EXTRACTOR.getGameObjectIds())
{
@Override
public String toString()
{
return "Crystal Extractor";
}
};

@Getter
private final int[] facility;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class SailingUtil
3 // 3? confirm sloop?
);
public static final int ACCOUNT_TYPE_UIM = 2;
public static final int SAILING_BOAT_FACILITY_LOCKEDIN_HELM = 3;

@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public static boolean isSailing(Client client)
Expand All @@ -33,6 +34,13 @@ public static boolean isSailing(Client client)
!client.getLocalPlayer().getWorldView().isTopLevel();
}

public static boolean isInBarracudaTrialAndAtHelm(Client client)
{
return isSailing(client)
&& client.getVarbitValue(VarbitID.SAILING_BT_IN_TRIAL) > 0
&& client.getVarbitValue(VarbitID.SAILING_BOAT_FACILITY_LOCKEDIN) == SAILING_BOAT_FACILITY_LOCKEDIN_HELM;
}

public static boolean isUim(Client client)
{
return client.getVarbitValue(VarbitID.IRONMAN) == ACCOUNT_TYPE_UIM;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.duckblade.osrs.sailing.model;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import net.runelite.api.gameval.NpcID;
import net.runelite.api.gameval.ObjectID;

@RequiredArgsConstructor
@Getter
public enum BarracudaTrialTier
{

TEMPOR_TANTRUM(
new int[]{
ObjectID.SAILING_BT_SCOREBOARD_TEMPOR_TANTRUM,
ObjectID.SAILING_BT_TEMPOR_TANTRUM_NORTH_LOC_PARENT,
ObjectID.SAILING_BT_TEMPOR_TANTRUM_SOUTH_LOC_PARENT,
}
),
JUBBLY_JIVE(
new int[]{
ObjectID.SAILING_BT_SCOREBOARD_JUBBLY_JIVE,
ObjectID.SAILING_BT_JUBBLY_JIVE_TOAD_SUPPLIES_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_0_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_1_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_2_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_3_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_4_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_5_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_6_PARENT,
ObjectID.SAILING_BT_JUBBLY_JIVE_PILLAR_CLICKBOX_7_PARENT,
}
),
GWENITH_GLIDE(
new int[]{
ObjectID.SAILING_BT_SCOREBOARD_GWENITH_GLIDE,
ObjectID.SAILING_BOAT_STEERING_KANDARIN_1X3_CRYSTALLISED,
ObjectID.SAILING_BOAT_STEERING_KANDARIN_2X5_CRYSTALLISED,
ObjectID.SAILING_BOAT_STEERING_KANDARIN_3X8_CRYSTALLISED,
NpcID.SAILING_BT_GWENITH_GLIDE_CRYSTAL_STEERING_HEADBAR_NPC
}
),
;

private final int[] gameObjectIds;

}
Loading