From 014a790bb09a0d7401607be204f13198bcdb9d33 Mon Sep 17 00:00:00 2001 From: Michel Pauwels Date: Sat, 8 Nov 2025 15:33:34 +0100 Subject: [PATCH 1/2] feat(Emotes): initial emote functionality --- osrs/interfaces/gametabs/emotes.simba | 99 ++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/osrs/interfaces/gametabs/emotes.simba b/osrs/interfaces/gametabs/emotes.simba index 5c3f499d..c1373ecf 100644 --- a/osrs/interfaces/gametabs/emotes.simba +++ b/osrs/interfaces/gametabs/emotes.simba @@ -2,13 +2,110 @@ {$INCLUDE_ONCE WaspLib/osrs.simba} type + ERSEmote = ( + YES, NO, BOW, ANGRY, + THINK, WAVE, SHRUG, CHEER, + BECKON, LAUGH, JUMP_FOR_JOY, YAWN, + DANCE, JIG, SPIN, HEADBANG, + CRY, BLOW_KISS, PANIC, RASPBERRY, + CLAP, SALUTE, GOBLIN_BOW, GOBLIN_SALUTE, + GLASS_BOX, CLIMB_ROPE, LEAN, GLASS_WALL, + IDEA, STAMP, FLAP, SLAP_HEAD, + ZOMBIE_WALK, ZOMBIE_DANCE, SCARED, RABBIT_HOP, + SIT_UP, PUSH_UP, STAR_JUMP, JOG, + FLEX, ZOMBIE_HAND, HYPERMOBILE_DRINKER, SKILL_CAPE, + AIR_GUITAR, URI_TRANSFORM, SMOOTH_DANCE, CRAZY_DANCE, + PREMIER_SHIELD, EXPLORE, RELIC_UNLOCK, PARTY, + TRICK, FORTIS_SALUTE, SIT_DOWN, CRAB_DANCE + ); + TRSEmotes = record + Scroll: TRSScrollBar; Slots: TBoxArray; end; procedure TRSEmotes.SetupGameTab(); +var + i: Integer; +begin + with GameTab.Bounds do + begin + Self.Scroll.Area.X1 := X1; + Self.Scroll.Area.Y1 := Y1 + 1; + Self.Scroll.Area.X2 := X2-14; + Self.Scroll.Area.Y2 := Y2; + end; + + Self.Scroll.Setup(); + + Self.Slots := TBoxArray.Create(GameTab.TopLeft.Offset(0, 5), 4, 14, 40, 47, [1,2]); +end; + +(* +## Emotes.IsOpen +```pascal +function TRSEmotes.IsOpen(): Boolean; +``` +Returns true if the Emotes tab is open. + +Example: +```pascal +WriteLn Emotes.IsOpen(); +``` +*) +function TRSEmotes.IsOpen(): Boolean; begin - //TODO... + Result := GameTabs.IsOpen(ERSGameTab.EMOTES); +end; + +(* +## Magic.Open +```pascal +function TRSEmotes.Open(): Boolean; +``` +Attempts to open the magic tab. + +Example: +```pascal +Emotes.Open(); +``` +*) +function TRSEmotes.Open(): Boolean; +begin + Result := GameTabs.Open(ERSGameTab.EMOTES); +end; + +function TRSEmotes._GetOffset(): Integer; +begin + Result := -Round(Self.Scroll.GetLevel() * 4.3); +end; + +function TRSEmotes.GetSlots(): TBoxArray; +var + i: Integer; +begin + Result := Self.Slots.Offset([0, Self._GetOffset()]); + + for i := High(Result) downto 0 do + begin + if Self.Scroll.Area.Contains([Result[i].X1, Result[i].Y1]) or + Self.Scroll.Area.Contains([Result[i].X2, Result[i].Y2]) then + begin + Self.Scroll.Area.Clip(Result[i]); + Continue; + end; + + Delete(Result, i, 1); + end; +end; + +function TRSEmotes.Find(emote: ERSEmote; out bounds: TBox): Boolean; +begin + bounds := Self.GetSlots[emote]; + Result := Self.Scroll.Area.Contains([bounds.X1, bounds.Y1]) or + Self.Scroll.Area.Contains([bounds.X2, bounds.Y2]); + + if Result then bounds.Clip(Self.Scroll.Area); end; var From e8ca84cf567b6594f4c7489ae71e142133701d7b Mon Sep 17 00:00:00 2001 From: Michel Date: Sat, 8 Nov 2025 19:45:05 +0100 Subject: [PATCH 2/2] feat(Emotes): update emote functionality with expanded emote list and simplified handling --- osrs/interfaces/gametabs/emotes.simba | 106 ++++++++++++++++++-------- 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/osrs/interfaces/gametabs/emotes.simba b/osrs/interfaces/gametabs/emotes.simba index c1373ecf..88a722a0 100644 --- a/osrs/interfaces/gametabs/emotes.simba +++ b/osrs/interfaces/gametabs/emotes.simba @@ -1,7 +1,30 @@ {$DEFINE WL_EMOTES_INCLUDED} {$INCLUDE_ONCE WaspLib/osrs.simba} +const + ERSEmoteUpText: TStringArray =[ + 'Yes','No','Bow','Angry', + 'Think','Wave','Shrug','Cheer', + 'Beckon','Laugh','Jump for Joy','Yawn', + 'Dance','Jig','Spin','Headbang', + 'Cry','Blow Kiss','Panic','Raspberry', + 'Clap','Salute','Goblin Bow','Goblin Salute', + 'Glass Box','Climb Rope','Lean','Glass Wall', + 'Idea','Stamp','Flap','Slap Head', + 'Zombie Walk','Zombie Dance','Scared','Rabbit Hop', + 'Sit up','Push up','Star jump','Jog', + 'Flex','Zombie Hand','Hypermobile Drinker','Skill Cape', + 'Air Guitar','Uri transform','Smooth dance','Crazy dance', + 'Premier Shield','Explore','Relic unlock','Party', + 'Trick','Fortis Salute','Sit down','Crab dance' + ]; + type + TRSEmotes = record + Scroll: TRSScrollBar; + Slots: TBoxArray; + end; + ERSEmote = ( YES, NO, BOW, ANGRY, THINK, WAVE, SHRUG, CHEER, @@ -19,11 +42,6 @@ type TRICK, FORTIS_SALUTE, SIT_DOWN, CRAB_DANCE ); - TRSEmotes = record - Scroll: TRSScrollBar; - Slots: TBoxArray; - end; - procedure TRSEmotes.SetupGameTab(); var i: Integer; @@ -36,9 +54,11 @@ begin Self.Scroll.Area.Y2 := Y2; end; - Self.Scroll.Setup(); - Self.Slots := TBoxArray.Create(GameTab.TopLeft.Offset(0, 5), 4, 14, 40, 47, [1,2]); + for i := 0 to High(Self.Slots) do + Self.Slots[i] := Self.Slots[i].Expand(-5); //shrink boxes because calculating scrolling is not linear. + + Self.Scroll.Setup(); end; (* @@ -59,11 +79,11 @@ begin end; (* -## Magic.Open +## Emotes.Open ```pascal function TRSEmotes.Open(): Boolean; ``` -Attempts to open the magic tab. +Attempts to open the emotes tab. Example: ```pascal @@ -75,38 +95,62 @@ begin Result := GameTabs.Open(ERSGameTab.EMOTES); end; -function TRSEmotes._GetOffset(): Integer; -begin - Result := -Round(Self.Scroll.GetLevel() * 4.3); -end; +(* +## Emotes.UseEmote +```pascal +function TRSEmotes.UseEmote(emote: ERSEmote): Boolean; +``` +Attempts to use the specified emote. Returns true if we succeed. -function TRSEmotes.GetSlots(): TBoxArray; +Example: +```pascal +WriteLn Emotes.UseEmote(ERSEmote.DANCE); +``` +*) +function TRSEmotes.UseEmote(emote: ERSEmote): Boolean; var - i: Integer; + scrollLevel: Integer; + box: TBox; + upText: String; + attempts: Integer; begin - Result := Self.Slots.Offset([0, Self._GetOffset()]); + Result := False; + if not Self.Open() then Exit; - for i := High(Result) downto 0 do + upText := ERSEmoteUpText[emote]; + if upText = '' then Exit; + + scrollLevel := Round((Ord(emote) div 4) / 13.0 * 100); + if scrollLevel > 100 then scrollLevel := 100; + + attempts := 0; + while (attempts < 5) and (not Result) do begin - if Self.Scroll.Area.Contains([Result[i].X1, Result[i].Y1]) or - Self.Scroll.Area.Contains([Result[i].X2, Result[i].Y2]) then + Self.Scroll.SetLevel(scrollLevel); + Biometrics.Sleep(40, 60); + + box := Self.Slots[emote].Offset([0, -Round(Self.Scroll.GetLevel() * 4.3)]); + + if Self.Scroll.Area.Contains([box.X1, box.Y1]) or + Self.Scroll.Area.Contains([box.X2, box.Y2]) then begin - Self.Scroll.Area.Clip(Result[i]); - Continue; + box.Clip(Self.Scroll.Area); + if Target.HasColor($27383F, 0, 1, box) then + Exit; + + Mouse.Move(box, True); + if MainScreen.IsUpText(upText) then + begin + Mouse.Click(box, EMouseButton.LEFT); + Result := True; + Break; + end; end; - Delete(Result, i, 1); + Inc(attempts); + Biometrics.Sleep(120, 180); end; end; -function TRSEmotes.Find(emote: ERSEmote; out bounds: TBox): Boolean; -begin - bounds := Self.GetSlots[emote]; - Result := Self.Scroll.Area.Contains([bounds.X1, bounds.Y1]) or - Self.Scroll.Area.Contains([bounds.X2, bounds.Y2]); - - if Result then bounds.Clip(Self.Scroll.Area); -end; - var Emotes: TRSEmotes;