HeroRotation

repository·thewarwithin·Indexed 41 days ago

https://github.com/herotc/hero-rotation

A combat rotation addon for World of Warcraft that provides real-time spell suggestions using Action Priority Lists (APLs). Features include a customizable UI with lock/unlock and resize capabilities, a periodic Pulse mechanism for rotation calculations, and support for various class specializations including Death Knight, Demon Hunter, Druid, Evoker, Hunter, Mage, Monk, Paladin, Priest, Rogue, Shaman, Warlock, and Warrior.

Tokens
1K
Snippets
3
Records
5
Agent score
1%

What's inside HeroRotation

  1. How the HeroRotation Pulse mechanism works

    thewarwithin

    The core logic of the addon runs on a periodic cycle called a Pulse.

    1. Trigger: The HR.Pulse function is called via an OnUpdate script on the MainFrame.
    2. Timing: The pulse occurs after a delay defined by HR.Timer.Pulse. The next pulse is scheduled using GetTime() + HL.Timer.PulseOffset.
    3. Execution: During a pulse, the addon:
      • Resets icons via HR.ResetIcons().
      • Checks if the player is Ready() (not dead, not in a vehicle, etc.).
      • If ready and the addon is enabled (HR.ON()), it resets the HeroCache and executes the current specialization's APL (Action Priority List) via HR.APLs[SpecID]().
    4. Manual Override: You can force a specific delay before the next pulse using HR.ChangePulseTimer(Offset).
    -- Force the next rotation check to happen in 2 seconds
    HR.ChangePulseTimer(2)
  2. Manage HeroRotation UI Lock/Unlock state

    thewarwithin

    The HR.MainFrame provides methods to lock or unlock the user interface, which controls whether the frames are movable and whether they respond to mouse input.

    • HR.MainFrame:Lock(): Disables mouse interaction for all UI frames and prevents the MainFrame and ToggleIconFrame from being moved. Sets HeroRotationDB.Locked to true.
    • HR.MainFrame:Unlock(): Enables mouse interaction for all UI frames and allows the MainFrame and ToggleIconFrame to be moved. Sets HeroRotationDB.Locked to false.
    • HR.MainFrame:ToggleLock(): Toggles between the locked and unlocked states.
    -- To unlock the UI manually
    HR.MainFrame:Unlock()
    
    -- To lock the UI manually
    HR.MainFrame:Lock()
    
    -- To toggle the current state
    HR.MainFrame:ToggleLock()
  3. Determine if the player is ready for rotation suggestions

    thewarwithin

    The HR.Ready() function returns a boolean indicating if the addon should currently be calculating and displaying rotation suggestions.

    By default, readiness depends on HR.GUISettings.General.ShowWhileMounted.

    • If ShowWhileMounted is true: Ready if not dead/ghost and not in a vehicle or pet battle.
    • If ShowWhileMounted is false: Ready if not dead/ghost, not mounted, not in a vehicle, and not in a pet battle.
    • If HR.GUISettings.General.ForceReadyStatus is true: Always returns true.
  4. Resize HeroRotation UI and Buttons

    thewarwithin

    The UI scale can be adjusted programmatically using the following methods on HR.MainFrame. These methods update both the frame sizes and the corresponding settings in HeroRotationDB.GUISettings.

    • HR.MainFrame:ResizeUI(Multiplier): Scales the main icons, small icons, left/suggested icons, and part overlays by the provided Multiplier.
    • HR.MainFrame:ResizeButtons(Multiplier): Scales the toggle icon frame and its buttons by the provided Multiplier.
    -- Scale the entire UI by 1.5x
    HR.MainFrame:ResizeUI(1.5)
    
    -- Scale the buttons by 0.8x
    HR.MainFrame:ResizeButtons(0.8)
  5. Supported Specializations and Class Modules

    thewarwithin

    HeroRotation loads specific class modules based on the player's current SpecID. The mapping is defined in the EnabledRotation table.

    Supported mappings include:

    • Death Knight: HeroRotation_DeathKnight (Specs 250, 251, 252)
    • Demon Hunter: HeroRotation_DemonHunter (Specs 577, 581)
    • Druid: HeroRotation_Druid (Specs 102, 103, 104)
    • Evoker: HeroRotation_Evoker (Specs 1467, 1473)
    • Hunter: HeroRotation_Hunter (Specs 253, 254, 255)
    • Mage: HeroRotation_Mage (Specs 62, 63, 64)
    • Monk: HeroRotation_Monk (Specs 268, 269)
    • Paladin: HeroRotation_Paladin (Specs 66, 70)
    • Priest: HeroRotation_Priest (Spec 258)
    • Rogue: HeroRotation_Rogue (Specs 259, 260, 261)
    • Shaman: HeroRotation_Shaman (Specs 262, 263)
    • Warlock: HeroRotation_Warlock (Specs 265, 266, 267)
    • Warrior: HeroRotation_Warrior (Specs 71, 72, 73)