Skip to content

Commit

Permalink
Update EmoteStep.java
Browse files Browse the repository at this point in the history
Add Shrug, Cheer, and Yes emotes, add animationids.
  • Loading branch information
PsycloneTM committed Feb 3, 2025
1 parent 980d991 commit 760b7e5
Showing 1 changed file with 99 additions and 8 deletions.
107 changes: 99 additions & 8 deletions src/main/java/com/questhelper/steps/EmoteStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,126 @@
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import net.runelite.api.Player;
import net.runelite.api.ScriptID;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.widgets.ComponentID;
import net.runelite.api.widgets.Widget;
import net.runelite.client.eventbus.Subscribe;

public class EmoteStep extends DetailedQuestStep
{
private boolean hasScrolled;
private final QuestEmote emote;
private List<QuestEmote> emoteSequence;
private int currentEmoteIndex;
private final WorldPoint requiredLocation;
private static final int LOCATION_TOLERANCE = 1;

public EmoteStep(QuestHelper questHelper, QuestEmote emote, String text, Requirement... requirements)
{
super(questHelper, text, requirements);
this.emote = emote;
this.emoteSequence = new ArrayList<>();
this.emoteSequence.add(emote);
this.currentEmoteIndex = 0;
this.requiredLocation = null;
}

public EmoteStep(QuestHelper questHelper, QuestEmote emote, WorldPoint worldPoint, String text, Requirement... requirements)
{
super(questHelper, worldPoint, text, requirements);
this.emote = emote;
this.emoteSequence = new ArrayList<>();
this.emoteSequence.add(emote);
this.currentEmoteIndex = 0;
this.requiredLocation = worldPoint;
}

public EmoteStep(QuestHelper questHelper, QuestEmote emote, String text, Requirement... requirements)
public EmoteStep(QuestHelper questHelper, List<QuestEmote> emoteSequence, WorldPoint worldPoint, String text, Requirement... requirements)
{
super(questHelper, text, requirements);
this.emote = emote;
super(questHelper, worldPoint, text, requirements);
this.emote = emoteSequence.get(0);
this.emoteSequence = emoteSequence;
this.currentEmoteIndex = 0;
this.requiredLocation = worldPoint;
}

@Subscribe
public void onAnimationChanged(AnimationChanged event)
{
if (!(event.getActor() instanceof Player))
{
return;
}

Player player = (Player) event.getActor();
if (player != client.getLocalPlayer())
{
return;
}

QuestEmote currentEmote = getCurrentEmote();
if (currentEmote != null && player.getAnimation() == currentEmote.getAnimationId())
{
if (isPlayerInCorrectLocation(player))
{
nextEmote();
}
}
}

private boolean isPlayerInCorrectLocation(Player player)
{
if (requiredLocation == null)
{
return true;
}

WorldPoint playerLocation = player.getWorldLocation();
return playerLocation.distanceTo(requiredLocation) <= LOCATION_TOLERANCE;
}

public QuestEmote getCurrentEmote()
{
if (currentEmoteIndex >= emoteSequence.size())
{
return null;
}
return emoteSequence.get(currentEmoteIndex);
}

public void nextEmote()
{
if (currentEmoteIndex < emoteSequence.size() - 1)
{
currentEmoteIndex++;
hasScrolled = false;
}
}

public void resetEmotes()
{
currentEmoteIndex = 0;
hasScrolled = false;
}

@Override
public void makeWidgetOverlayHint(Graphics2D graphics, QuestHelperPlugin plugin)
{
super.makeWidgetOverlayHint(graphics, plugin);

Widget emoteContainer = client.getWidget(ComponentID.EMOTES_EMOTE_CONTAINER);
QuestEmote currentEmote = getCurrentEmote();
if (currentEmote == null)
{
return;
}

if (emoteContainer == null || emoteContainer.isHidden())
Widget emoteContainer = client.getWidget(ComponentID.EMOTES_EMOTE_CONTAINER);
if (emoteContainer == null || emoteContainer.isHidden())
{
return;
}
Expand All @@ -78,7 +168,7 @@ public void makeWidgetOverlayHint(Graphics2D graphics, QuestHelperPlugin plugin)

for (Widget emoteWidget : emoteContainer.getDynamicChildren())
{
if (emoteWidget.getSpriteId() == emote.getSpriteId())
if (emoteWidget.getSpriteId() == currentEmote.getSpriteId())
{
finalEmoteWidget = emoteWidget;
graphics.setColor(new Color(questHelper.getConfig().targetOverlayColor().getRed(),
Expand Down Expand Up @@ -119,9 +209,10 @@ void scrollToWidget(Widget widget)
@Override
protected void setupIcon()
{
if (emote.getSpriteId() != -1 && icon == null)
QuestEmote currentEmote = getCurrentEmote();
if (currentEmote != null && currentEmote.getSpriteId() != -1 && icon == null)
{
BufferedImage emoteImage = spriteManager.getSprite(emote.getSpriteId(), 0);
BufferedImage emoteImage = spriteManager.getSprite(currentEmote.getSpriteId(), 0);
if (emoteImage != null)
{
icon = IconOverlay.createIconImage(emoteImage);
Expand Down

0 comments on commit 760b7e5

Please sign in to comment.