diff --git a/Versions/Classic/bestride.lua b/Versions/Classic/bestride.lua index b6f6908..a258f51 100644 --- a/Versions/Classic/bestride.lua +++ b/Versions/Classic/bestride.lua @@ -34,3 +34,7 @@ end function BeStride:GetMountInfoByIndex() return nil end + +function BeStride:GetKnownMountFromTarget() + return nil +end diff --git a/Versions/Common/BeStride_Variables.lua b/Versions/Common/BeStride_Variables.lua index 30c0b1f..0074007 100644 --- a/Versions/Common/BeStride_Variables.lua +++ b/Versions/Common/BeStride_Variables.lua @@ -7,6 +7,7 @@ BeStride_Variables = { {name="mount.nodismountwhileflying",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.NoDismountWhileFlying"]}, {name="mount.useflyingmount",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.UseFlyingMount"], dependants = {"mount.forceflyingmount"}}, {name="mount.forceflyingmount",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.ForceFlyingMount"], depends = {"mount.useflyingmount"}}, + {name="mount.copytargetmount",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.CopyTargetMount"]}, {name="mount.prioritizepassenger",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.PrioritizePassenger"]}, {name="mount.noswimming",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.NoSwimming"]}, {name="mount.flyingbroom",element="CheckBox",label=LibStub("AceLocale-3.0"):GetLocale("BeStride")["Settings.FlyingBroom"]}, @@ -94,6 +95,7 @@ defaults = { enablenew = false, --ENABLENEW useflyingmount = false, forceflyingmount = false, --FFM + copytargetmount = true, nodismountwhileflying = false, --NDWF noswimming = false, flyingbroom = false, diff --git a/Versions/Common/logic.mounts.lua b/Versions/Common/logic.mounts.lua index 056b2b2..9769bfd 100644 --- a/Versions/Common/logic.mounts.lua +++ b/Versions/Common/logic.mounts.lua @@ -52,4 +52,12 @@ function BeStride:CheckLoanedMount() end return nil +end + +function BeStride:CanUseTargetsMount() + if (not self:DBGet("settings.mount.copytargetmount")) then return false end + if (self:MovementCheck() or not UnitExists("target")) then return false end + + local spellId, mountId, isUsable = self:GetKnownMountFromTarget() + return isUsable end \ No newline at end of file diff --git a/Versions/Common/mount.lua b/Versions/Common/mount.lua index 5bff02a..658cd84 100644 --- a/Versions/Common/mount.lua +++ b/Versions/Common/mount.lua @@ -1,6 +1,9 @@ function BeStride:Regular() + if self:CanUseTargetsMount() then + self:DismountAndExit() + return self:UseTargetsMount() -- Aspect of the Cheetah is available from level 5 - if self:IsHunterAndSpecial() then + elseif self:IsHunterAndSpecial() then return self:Hunter() -- Check if we are mounted elseif IsMounted() and self:NeedsChauffeur() then @@ -264,3 +267,8 @@ function BeStride:DismountAndExit() Dismount() end end + +function BeStride:UseTargetsMount() + local spellId = self:GetKnownMountFromTarget() + return BeStride_Mount:MountSpell(GetSpellInfo(spellId)) +end diff --git a/Versions/Common/options.lua b/Versions/Common/options.lua index 2abac57..82dc909 100644 --- a/Versions/Common/options.lua +++ b/Versions/Common/options.lua @@ -75,10 +75,18 @@ local optionsTable_Options = { set=function (info,val) BeStride:DBSetSetting(info[#info],val) end, disabled=function(info) return not BeStride:DBGetSetting('mount.useflyingmount') end, }, + ["mount.copytargetmount"]={ + type="toggle", + name=L["Settings.CopyTargetMount"], + order=7, + width="full", + get=function (info) return BeStride:DBGetSetting(info[#info]) end, + set=function (info,val) BeStride:DBSetSetting(info[#info],val) end, + }, special_mounts = { type="group", inline=true, - order=7, + order=8, name=L["GUI.TAB.MountOptions.SpecialMounts"], args={ ["mount.prioritizepassenger"]={ @@ -126,7 +134,7 @@ local optionsTable_Options = { repair_mounts = { type="group", name=L["GUI.TAB.MountOptions.RepairMounts"], - order=8, + order=9, width="full", inline=true, args={ diff --git a/Versions/Mainline/bestride.lua b/Versions/Mainline/bestride.lua index 9c9d0da..f021dfa 100644 --- a/Versions/Mainline/bestride.lua +++ b/Versions/Mainline/bestride.lua @@ -38,4 +38,15 @@ end function BeStride:GetMountInfoByIndex(index) return nil +end + +function BeStride:GetKnownMountFromTarget() + for i=1,40,1 do + local spellId = select(10, UnitBuff("target", i)) + if not spellId then return end + local mountId = C_MountJournal.GetMountFromSpell(spellId) + if mountId ~= nil then + return self:isMountUsable(mountId) + end + end end \ No newline at end of file diff --git a/Versions/Wrath/bestride.lua b/Versions/Wrath/bestride.lua index 3d8eaa9..4a07ddb 100644 --- a/Versions/Wrath/bestride.lua +++ b/Versions/Wrath/bestride.lua @@ -54,4 +54,20 @@ end function BeStride:OverrideConstants() BeStride_Constants.Riding.Flight.Restricted.Continents[113].requires = 54197 +end + +function BeStride:GetKnownMountFromTarget() + local mountIdBySpellId = {} + for i=1,GetNumCompanions("MOUNT"),1 do + local mountID,name,spellID,icon,isSummoned = GetCompanionInfo("MOUNT", i) + mountIdBySpellId[spellID] = mountID + end + -- look for unit aura that matches known AND usable mount ID + for i=1,40,1 do + local spellId = select(10,UnitBuff("target",i)) + if not spellId then return end + if mountIdBySpellId[spellId] ~= nil then + return spellId, mountIdBySpellId[spellId], true + end + end end \ No newline at end of file diff --git a/localization/en-US.lua b/localization/en-US.lua index 33b31e0..c4ca3bc 100644 --- a/localization/en-US.lua +++ b/localization/en-US.lua @@ -64,6 +64,7 @@ L["Settings.RemountAfterDismount"] = "Remount Immediately After Dismounting" L["Settings.NoDismountWhileFlying"] = "Don't dismount while flying. You'll have to land or (if enabled in Blizzard options) cast a spell" L["Settings.UseFlyingMount"] = "Use Flying type mounts even in areas where you cannot fly" L["Settings.ForceFlyingMount"] = "Force Flying type mounts even in areas where you cannot fly" +L["Settings.CopyTargetMount"] = "Attempt to use the same mount as your current target" L["Settings.PrioritizePassenger"] = "Prioritize Passenger Mounts when in group" L["Settings.NoSwimming"] = "Never use underwater mounts even when swimming" L["Settings.FlyingBroom"] = "Always use Flying Broom instead of a normal mount"