feat(leftclickcast): Left-Click Cast plugin#389
Merged
chsami merged 13 commits intochsami:developmentfrom Apr 16, 2026
Merged
Conversation
Yellow [P] prefix in the #FFFF00 color family, matching the existing HTML-wrapped prefix convention.
Wraps every target-castable MagicAction (autocast Strike->Surge, ancient Rush/Burst/Blitz/Barrage, non-autocast combat, Arceuus offensives, utility target spells) behind a minimal display-name shape for the plugin config dropdown.
Three items: enabled (master switch), spell (PertTargetSpell dropdown, default Fire Strike), requireMagicWeapon (staff gate).
onMenuEntryAdded inserts a Cast entry above the Attack entry for attackable NPCs, gated by the enabled flag, a non-null configured spell, and (optionally) a magic-weapon equip check via varbit 357. Cast is dispatched through Rs2Magic.castOn off-thread via CompletableFuture because Global.sleepUntil is a no-op on the client thread and would otherwise silently drop the cast.
Covers purpose, config reference, limitations (no rune or spellbook auto-management, staff-only default, PvP out of scope), and the full supported-spells list.
net.runelite.api.Varbits is @deprecated in favor of gameval identifier classes. Same varbit (357), no behavior change.
Two bugs found during manual verification: 1. The static weapon-type set (22/23/26/27) from the design doc was wrong — real STAFF value (at least on this client) is 18. Replaced with a runtime check that reads the weapon's attack-style struct via EnumID.WEAPON_STYLES + ParamID.ATTACK_STYLE_NAME and flags the weapon as magic if any style is Casting or Defensive Casting. Mirrors core AttackStylesPlugin and auto-covers future weapons. 2. Mutating the Attack entry inside onMenuEntryAdded did not survive the game's menu sort pass — entries of type RUNELITE get sorted below NPC_* entries, so left-click kept firing Attack/Walk-Here. Moved the mutation to onPostMenuSort (fires after the sort) and swap the entry to the tail of the array — tail slot is the left-click action in RuneLite's menu model.
Scan loop now accepts Attack entries on either NPCs or Players. Dispatch wraps NPCs in Rs2NpcModel; raw Player is passed through, which Rs2Magic.castOn handles via its instanceof Player branch.
Adds five `@ConfigItem` spell slots, each with a corresponding Keybind, grouped under "Spell Slots" and "Hotkeys" config sections. A `HotkeyListener` per slot is registered on startUp and unregistered on shutDown; pressing a bound hotkey sets the in-memory active slot and (optionally) posts a chat message with the new spell's display name. The menu-sort hot path now reads the active slot's spell instead of the legacy single `spell` key. The legacy `spell` key remains defined so existing configs aren't invalidated, and is migrated into `slot1Spell` on startUp when slot 1 is still at its default — existing users keep their choice without manual action. Active slot is session-local and resets to slot 1 on every startUp. Bumps plugin version to 1.1.0.
Replaces the async Rs2Magic.castOn pipeline (tab switch + 150-300ms sleep + sleepUntil(isWidgetSelected) + NPC interact) with two synchronous client.menuAction calls fired back-to-back: one WIDGET_TARGET to select the spell client-side, one WIDGET_TARGET_ON_NPC / WIDGET_TARGET_ON_PLAYER to dispatch it on the hovered target. Both packets queue on the same event-loop tick, so the server processes selection and cast on the same game tick — indistinguishable from "I pre-selected the spell and clicked the target". Falls back to Rs2Magic.castOn when the spellbook widget (group 218) isn't loaded yet (first cast after login without opening Magic tab), nudging Rs2Tab.switchTo(InterfaceTab.MAGIC) so subsequent clicks take the fast path. Also falls back when the selected spell isn't on the active spellbook (modern vs. ancients mismatch). Bumps plugin version to 1.2.0.
Adds an `Enable/Disable Hotkey` config item at the top of the Hotkeys section. Pressing the hotkey flips `config.enabled()` and posts an `ExternalPluginsChanged` event so the open MicrobotConfigPanel rebuilds and the inner Enabled checkbox visually flips in sync — the panel otherwise doesn't subscribe to ConfigChanged for individual checkbox refresh. Renames `activeSlotChatMessage` → `chatFeedback` and uses it as a single gate for all plugin chat output. Both checkbox clicks and the toggle hotkey route through a shared `@Subscribe onConfigChanged` handler, so they emit the same chat message via one code path. Materializes `@ConfigItem` defaults to storage on `startUp` via `configManager.setDefaultConfiguration(config, false)`. Without this, MicrobotConfigPanel's checkbox lookup returns null for newly added keys (`parseBoolean(null) → false`) while the proxy returns the @configitem default, leaving the UI and runtime out of sync. Bumps plugin version to 1.3.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Left-Click Cast plugin (
PluginConstants.PERT). It replaces the left-click Attack option on attackable NPCs and Players (wilderness / PvP) with a preconfigured Cast Spell action, dispatched via two same-tickmenuActionpackets for a zero-delay feel (fallback toRs2Magic.castOnif the spellbook widget isn't loaded yet).ExternalPluginsChanged.EnumID.WEAPON_STYLES+ParamID.ATTACK_STYLE_NAMEto detect casting-capable weapons, mirroring coreAttackStylesPluginlogic.Also adds the
PERTauthor prefix toPluginConstants.Plugin version:
1.3.0,minClientVersion: 2.0.13.Test plan
./gradlew -PpluginList=LeftClickCastPlugin buildsucceeds (producesLeftClickCastPlugin-1.3.0.jar)../gradlew test)../gradlew runDebug— left-click cast fires as a single motion on NPCs and Players; slot hotkeys swap the active spell mid-fight; enable-toggle hotkey flips the config panel checkbox; chat feedback toggle gates both event types.spellconfig key migrates intoslot1Spellon startup when a non-default value is present.