Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions src/main/java/dinkplugin/DinkPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.runelite.api.events.WidgetClosed;
import net.runelite.api.events.WidgetLoaded;
import net.runelite.api.events.WorldChanged;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.gameval.NpcID;
import net.runelite.client.RuneLite;
import net.runelite.client.chat.ChatMessageManager;
Expand Down Expand Up @@ -318,6 +319,11 @@ public void onInteractingChanged(InteractingChanged event) {
deathNotifier.onInteraction(event);
}

@Subscribe
public void onAnimationChanged(AnimationChanged event) {
deathNotifier.onAnimationChanged(event);
}

@Subscribe
public void onScriptPreFired(ScriptPreFired event) {
collectionNotifier.onScript(event.getScriptId());
Expand Down
38 changes: 27 additions & 11 deletions src/main/java/dinkplugin/DinkPluginConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1210,14 +1210,30 @@ default boolean deathEmbedKeptItems() {
return false;
}

@ConfigItem(
keyName = "notifyOnAnim",
name = "Notify on Death Animation",
description = "When enabled, the death notifier fires when the player performs a death animation, <br/>" +
"instead of firing upon the player reaching 0 hp.<br/>" +
"This prevents false positives in rare cases in which the player reaches 0 hp but doesn't die, <br/>" +
"at the cost of a slightly delayed notification and screenshot.",
position = 43,
Comment thread
iProdigy marked this conversation as resolved.
Outdated
section = deathSection
)

Comment thread
iProdigy marked this conversation as resolved.
Outdated
default boolean notifyOnAnim() {
return false;
}

@ConfigItem(
keyName = "deathIgnoreSafe",
name = "Ignore Safe Deaths",
description = "Whether deaths in safe areas should be ignored.<br/>" +
"Exceptions to this rule can be configured below",
position = 43,
position = 44,
section = deathSection
)

Comment thread
iProdigy marked this conversation as resolved.
Outdated
default boolean deathIgnoreSafe() {
return true;
}
Expand All @@ -1227,7 +1243,7 @@ default boolean deathIgnoreSafe() {
name = "Safe Exceptions",
description = "Safe deaths that should trigger notifications even when 'Ignore Safe Deaths' is enabled.<br/>" +
"Hold Control while clicking on the options to select multiple exceptions",
position = 44,
position = 45,
section = deathSection
)
default Set<ExceptionalDeath> deathSafeExceptions() {
Expand All @@ -1240,7 +1256,7 @@ default Set<ExceptionalDeath> deathSafeExceptions() {
description = "User-specified, comma-separated Region IDs where deaths should be ignored.<br/>" +
"Use the '::dinkregion' chat command or an online map to obtain the region IDs.<br/>" +
"For example, Prifddinas spans 12894, 12895, 13150, 13151",
position = 45,
position = 46,
section = deathSection
)
default String deathIgnoredRegions() {
Expand All @@ -1252,7 +1268,7 @@ default String deathIgnoredRegions() {
name = "Min Lost Value",
description = "The minimum value of the lost items for a notification to be sent.<br/>" +
"This setting does not apply for safe deaths",
position = 46,
position = 47,
section = deathSection
)
default int deathMinValue() {
Expand All @@ -1265,7 +1281,7 @@ default int deathMinValue() {
description = "The message to be sent through the webhook.<br/>" +
"Use %USERNAME% to insert your username<br/>" +
"Use %VALUELOST% to insert the GE value of the stuff you lost",
position = 47,
position = 48,
section = deathSection
)
default String deathNotifyMessage() {
Expand All @@ -1276,7 +1292,7 @@ default String deathNotifyMessage() {
keyName = "deathNotifPvpEnabled",
name = "Distinguish PvP deaths",
description = "Should the plugin use a different message for dying in PvP?",
position = 48,
position = 49,
section = deathSection
)
default boolean deathNotifPvpEnabled() {
Expand All @@ -1290,7 +1306,7 @@ default boolean deathNotifPvpEnabled() {
"Use %PKER% to insert the killer<br/>" +
"Use %USERNAME% to insert your username<br/>" +
"Use %VALUELOST% to insert the GE value of the stuff you lost",
position = 49,
position = 50,
section = deathSection
)
default String deathNotifPvpMessage() {
Expand All @@ -1301,7 +1317,7 @@ default String deathNotifPvpMessage() {
keyName = "slayerEnabled",
name = "Enable Slayer",
description = "Enable notifications for when you complete a slayer task",
position = 50,
position = 51,
section = slayerSection
)
default boolean notifySlayer() {
Expand All @@ -1312,7 +1328,7 @@ default boolean notifySlayer() {
keyName = "slayerSendImage",
name = "Send Image",
description = "Send image with the notification",
position = 51,
position = 52,
section = slayerSection
)
default boolean slayerSendImage() {
Expand All @@ -1323,7 +1339,7 @@ default boolean slayerSendImage() {
keyName = "slayerPointThreshold",
name = "Min Slayer Points",
description = "The minimum slayer task points to warrant a notification",
position = 52,
position = 53,
section = slayerSection
)
default int slayerPointThreshold() {
Expand All @@ -1338,7 +1354,7 @@ default int slayerPointThreshold() {
"Use %TASK% to insert your task<br/>" +
"Use %POINTS% to show how many points you obtained<br/>" +
"Use %TASKCOUNT% to show how many tasks you have completed",
position = 53,
position = 54,
section = slayerSection
)
default String slayerNotifyMessage() {
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/dinkplugin/notifiers/DeathNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import net.runelite.api.Prayer;
import net.runelite.api.SkullIcon;
import net.runelite.api.events.ActorDeath;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.InteractingChanged;
import net.runelite.api.events.ScriptPreFired;
import net.runelite.api.gameval.ItemID;
Expand All @@ -46,6 +47,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
Expand All @@ -56,6 +58,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;


Comment thread
iProdigy marked this conversation as resolved.
Outdated
@Slf4j
@Singleton
public class DeathNotifier extends BaseNotifier {
Expand All @@ -68,6 +71,14 @@ public class DeathNotifier extends BaseNotifier {

private static final String FORTIS_DOOM_MSG = "You have been doomed!";

private static final Integer DEFAULT_DEATH_ANIM_ID = 836;

private static final Integer TRAILBLAZER_RELOADED_DEATH_ANIM_ID = 10629;

private static final Integer RAGING_ECHOES_DEATH_ANIM_ID = 11902;

private static final Set<Integer> DEATH_ANIM_IDS = Set.of(DEFAULT_DEATH_ANIM_ID, TRAILBLAZER_RELOADED_DEATH_ANIM_ID, RAGING_ECHOES_DEATH_ANIM_ID);
Comment thread
zneix marked this conversation as resolved.
Outdated

/**
* @see <a href="https://github.com/Joshua-F/cs2-scripts/blob/master/scripts/%5Bclientscript,tob_hud_portal%5D.cs2">CS2 Reference</a>
*/
Expand Down Expand Up @@ -146,13 +157,23 @@ public void onConfigChanged(String key, String value) {
public void onActorDeath(ActorDeath actor) {
boolean self = client.getLocalPlayer() == actor.getActor();

if (self && isEnabled())
if (self && isEnabled() && !config.notifyOnAnim())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not critical for this PR but: if we wanted to avoid delayed screenshot, we could capture now & use later (or destroy if unused for x ticks)

handleNotify(null);

if (self || actor.getActor() == lastTarget.get())
lastTarget = new WeakReference<>(null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if self and config.notifyOnAnim(), we don't want to clear lastTarget since the animation event comes later. then we can clear lastTarget from within onAnimationChanged

one remaining concern is interactions might change between time of ActorDeath & AnimationChanged, so killer detection may also be worse

}

public void onAnimationChanged(AnimationChanged animationChanged) {
Actor actor = animationChanged.getActor();
boolean self = actor == client.getLocalPlayer();
boolean isDeath = DEATH_ANIM_IDS.contains(actor.getAnimation());

if(self && isDeath && isEnabled() && config.notifyOnAnim()) {
handleNotify(null);
}
}

public void onGameMessage(String message) {
var player = client.getLocalPlayer();
if (message.equals(FORTIS_DOOM_MSG) && player.getHealthRatio() > 0 && WorldUtils.getLocation(client, player).getRegionID() == WorldUtils.FORTIS_REGION && isEnabled()) {
Expand Down