mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
205 lines
5.9 KiB
Lua
205 lines
5.9 KiB
Lua
--[[
|
|
Author: Dennis Werner Garske (DWG) / brian / Mewtiny
|
|
License: MIT License
|
|
]]
|
|
local _G = _G or getfenv(0)
|
|
local CleveRoids = _G.CleveRoids or {}
|
|
|
|
SLASH_PETATTACK1 = "/petattack"
|
|
|
|
SlashCmdList.PETATTACK = function(msg) CleveRoids.DoPetAction(PetAttack, msg); end
|
|
|
|
SLASH_PETFOLLOW1 = "/petfollow"
|
|
|
|
SlashCmdList.PETFOLLOW = function(msg) CleveRoids.DoPetAction(PetFollow, msg); end
|
|
|
|
SLASH_PETWAIT1 = "/petwait"
|
|
|
|
SlashCmdList.PETWAIT = function(msg) CleveRoids.DoPetAction(PetWait, msg); end
|
|
|
|
SLASH_PETPASSIVE1 = "/petpassive"
|
|
|
|
SlashCmdList.PETPASSIVE = function(msg) CleveRoids.DoPetAction(PetPassiveMode, msg); end
|
|
|
|
SLASH_PETAGGRESSIVE1 = "/petaggressive"
|
|
|
|
SlashCmdList.PETAGGRESSIVE = function(msg) CleveRoids.DoPetAction(PetAggressiveMode, msg); end
|
|
|
|
SLASH_PETDEFENSIVE1 = "/petdefensive"
|
|
|
|
SlashCmdList.PETDEFENSIVE = function(msg) CleveRoids.DoPetAction(PetDefensiveMode, msg); end
|
|
|
|
SLASH_RELOAD1 = "/rl"
|
|
|
|
SlashCmdList.RELOAD = function() ReloadUI(); end
|
|
|
|
SLASH_USE1 = "/use"
|
|
|
|
SlashCmdList.USE = CleveRoids.DoUse
|
|
|
|
SLASH_EQUIP1 = "/equip"
|
|
|
|
SlashCmdList.EQUIP = CleveRoids.DoUse
|
|
-- take back supermacro and pfUI /equip
|
|
SlashCmdList.SMEQUIP = CleveRoids.DoUse
|
|
SlashCmdList.PFEQUIP = CleveRoids.DoUse
|
|
|
|
SLASH_EQUIPMH1 = "/equipmh"
|
|
SlashCmdList.EQUIPMH = CleveRoids.DoEquipMainhand
|
|
|
|
SLASH_EQUIPOH1 = "/equipoh"
|
|
SlashCmdList.EQUIPOH = CleveRoids.DoEquipOffhand
|
|
|
|
SLASH_UNSHIFT1 = "/unshift"
|
|
|
|
SlashCmdList.UNSHIFT = CleveRoids.DoUnshift
|
|
|
|
SLASH_UNQUEUE1 = "/unqueue"
|
|
SlashCmdList.UNQUEUE = SpellStopCasting
|
|
|
|
-- TODO make this conditional too
|
|
SLASH_CANCELAURA1 = "/cancelaura"
|
|
SLASH_CANCELAURA2 = "/unbuff"
|
|
|
|
SlashCmdList.CANCELAURA = CleveRoids.DoConditionalCancelAura
|
|
|
|
-- Define original implementations before hooking them.
|
|
-- This ensures we have a fallback for non-conditional use.
|
|
local StartAttack = function(msg)
|
|
if not UnitExists("target") or UnitIsDead("target") then TargetNearestEnemy() end
|
|
if not CleveRoids.CurrentSpell.autoAttack and not CleveRoids.CurrentSpell.autoAttackLock and UnitExists("target") and UnitCanAttack("player","target") then
|
|
CleveRoids.CurrentSpell.autoAttackLock = true
|
|
CleveRoids.autoAttackLockElapsed = GetTime()
|
|
AttackTarget()
|
|
end
|
|
end
|
|
|
|
local StopAttack = function(msg)
|
|
if CleveRoids.CurrentSpell.autoAttack and UnitExists("target") then
|
|
AttackTarget()
|
|
CleveRoids.CurrentSpell.autoAttack = false
|
|
end
|
|
end
|
|
|
|
-- Register slash commands and assign original handlers.
|
|
-- These will be hooked immediately after.
|
|
SLASH_STARTATTACK1 = "/startattack"
|
|
SlashCmdList.STARTATTACK = StartAttack
|
|
|
|
SLASH_STOPATTACK1 = "/stopattack"
|
|
SlashCmdList.STOPATTACK = StopAttack
|
|
|
|
SLASH_STOPCASTING1 = "/stopcasting"
|
|
SlashCmdList.STOPCASTING = SpellStopCasting
|
|
|
|
----------------------------------
|
|
-- HOOK DEFINITIONS START
|
|
----------------------------------
|
|
|
|
-- /startattack hook
|
|
CleveRoids.Hooks.STARTATTACK_SlashCmd = SlashCmdList.STARTATTACK
|
|
SlashCmdList.STARTATTACK = function(msg)
|
|
msg = msg or ""
|
|
if string.find(msg, "%[") then
|
|
CleveRoids.DoConditionalStartAttack(msg)
|
|
else
|
|
CleveRoids.Hooks.STARTATTACK_SlashCmd(msg)
|
|
end
|
|
end
|
|
|
|
-- /stopattack hook
|
|
CleveRoids.Hooks.STOPATTACK_SlashCmd = SlashCmdList.STOPATTACK
|
|
SlashCmdList.STOPATTACK = function(msg)
|
|
msg = msg or ""
|
|
if string.find(msg, "%[") then
|
|
-- If conditionals are present, let the function handle it.
|
|
-- It will only stop the attack if the conditions are met.
|
|
CleveRoids.DoConditionalStopAttack(msg)
|
|
else
|
|
-- If no conditionals, run the original command.
|
|
CleveRoids.Hooks.STOPATTACK_SlashCmd(msg)
|
|
end
|
|
end
|
|
|
|
-- /stopcasting hook
|
|
CleveRoids.Hooks.STOPCASTING_SlashCmd = SlashCmdList.STOPCASTING
|
|
SlashCmdList.STOPCASTING = function(msg)
|
|
msg = msg or ""
|
|
if string.find(msg, "%[") then
|
|
-- If conditionals are present, let the function handle it.
|
|
-- It will only stop the cast if the conditions are met.
|
|
CleveRoids.DoConditionalStopCasting(msg)
|
|
else
|
|
-- If no conditionals, run the original command.
|
|
CleveRoids.Hooks.STOPCASTING_SlashCmd()
|
|
end
|
|
end
|
|
|
|
CleveRoids.Hooks.UNQUEUE_SlashCmd = SlashCmdList.UNQUEUE
|
|
SlashCmdList.UNQUEUE = function(msg)
|
|
msg = msg or ""
|
|
if string.find(msg, "%[") then
|
|
-- If conditionals are present, let the function handle it.
|
|
CleveRoids.DoConditionalStopCasting(msg)
|
|
else
|
|
-- If no conditionals, run the original command.
|
|
CleveRoids.Hooks.UNQUEUE_SlashCmd()
|
|
end
|
|
end
|
|
|
|
-- /cast hook
|
|
CleveRoids.Hooks.CAST_SlashCmd = SlashCmdList.CAST
|
|
SlashCmdList.CAST = function(msg)
|
|
if msg and string.find(msg, "[%[%?!~{]") then
|
|
CleveRoids.DoCast(msg)
|
|
else
|
|
CleveRoids.Hooks.CAST_SlashCmd(msg)
|
|
end
|
|
end
|
|
|
|
CleveRoids.Hooks.TARGET_SlashCmd = SlashCmdList.TARGET
|
|
CleveRoids.TARGET_SlashCmd = function(msg)
|
|
tmsg = CleveRoids.Trim(msg)
|
|
|
|
if tmsg ~= "" and not string.find(tmsg, "%[") and not string.find(tmsg, "@") then
|
|
CleveRoids.Hooks.TARGET_SlashCmd(tmsg)
|
|
return
|
|
end
|
|
|
|
if CleveRoids.DoTarget(tmsg) then
|
|
if UnitExists("target") then
|
|
return
|
|
end
|
|
end
|
|
CleveRoids.Hooks.TARGET_SlashCmd(msg)
|
|
end
|
|
SlashCmdList.TARGET = CleveRoids.TARGET_SlashCmd
|
|
|
|
|
|
SLASH_CASTSEQUENCE1 = "/castsequence"
|
|
SlashCmdList.CASTSEQUENCE = function(msg)
|
|
msg = CleveRoids.Trim(msg)
|
|
local sequence = CleveRoids.GetSequence(msg)
|
|
if not sequence then return end
|
|
-- if not sequence.active then return end
|
|
|
|
CleveRoids.DoCastSequence(sequence)
|
|
end
|
|
|
|
|
|
SLASH_RUNMACRO1 = "/runmacro"
|
|
SlashCmdList.RUNMACRO = function(msg)
|
|
return CleveRoids.ExecuteMacroByName(CleveRoids.Trim(msg))
|
|
end
|
|
|
|
SLASH_RETARGET1 = "/retarget"
|
|
SlashCmdList.RETARGET = function(msg)
|
|
CleveRoids.DoRetarget()
|
|
end
|
|
|
|
SLASH_STOPMACRO1 = "/stopmacro"
|
|
SlashCmdList.STOPMACRO = function(msg)
|
|
CleveRoids.DoStopMacro(msg)
|
|
end
|
|
|