From e854f4fc64db993facb64e2ffa3841898af06cfe Mon Sep 17 00:00:00 2001 From: 4n0n <4n0n@tinkr.site> Date: Tue, 31 Jan 2023 13:35:18 -0600 Subject: [PATCH] Updates, fixes, changes --- scripts/subtlety.lua | 139 ++++++++++++++++++++---- src/MythicPlusUtils/MythicPlusUtils.lua | 51 ++++++++- src/Unit/Unit.lua | 12 +- src/_bastion.lua | 7 ++ 4 files changed, 186 insertions(+), 23 deletions(-) diff --git a/scripts/subtlety.lua b/scripts/subtlety.lua index a41c7b5..2889b36 100644 --- a/scripts/subtlety.lua +++ b/scripts/subtlety.lua @@ -853,7 +853,6 @@ local DarkMoonRime = Bastion.ItemBook:GetItem(198477) local AlgetharsPuzzleBox = Bastion.ItemBook:GetItem(193701) local RimeCards = { - One = Bastion.SpellBook:GetSpell(382844), Two = Bastion.SpellBook:GetSpell(382845), Three = Bastion.SpellBook:GetSpell(382846), Four = Bastion.SpellBook:GetSpell(382847), @@ -861,6 +860,7 @@ local RimeCards = { Six = Bastion.SpellBook:GetSpell(382849), Seven = Bastion.SpellBook:GetSpell(382850), Eight = Bastion.SpellBook:GetSpell(382851), + Ace = Bastion.SpellBook:GetSpell(382844), } local PurgeTarget = Bastion.UnitManager:CreateCustomUnit('purge', function(unit) @@ -879,7 +879,7 @@ local PurgeTarget = Bastion.UnitManager:CreateCustomUnit('purge', function(unit) return false end - if unit:GetAuras():HasAnyStealableAura() then + if unit:GetAuras():HasAnyStealableAura() and Shiv:IsInRange(unit) then purge = unit return true end @@ -991,6 +991,96 @@ local RuptureTarget = Bastion.UnitManager:CreateCustomUnit('rupture', function() return target end) +local function GetRimeDuration(topCard) + -- // card order is [ 2 3 4 5 6 7 8 A ] + + if topCard == RimeCards.Two then + return 0 + elseif topCard == RimeCards.Three then + return 1 + elseif topCard == RimeCards.Four then + return 2 + elseif topCard == RimeCards.Five then + return 3 + elseif topCard == RimeCards.Six then + return 4 + elseif topCard == RimeCards.Seven then + return 5 + elseif topCard == RimeCards.Eight then + return 6 + elseif topCard == RimeCards.Ace then + return 7 + end + + return 0 +end + +local function GetRimeTopCard() + local topCard = nil + + if Player:GetAuras():FindMy(RimeCards.Ace):IsUp() then + topCard = RimeCards.Ace + elseif Player:GetAuras():FindMy(RimeCards.Two):IsUp() then + topCard = RimeCards.Two + elseif Player:GetAuras():FindMy(RimeCards.Three):IsUp() then + topCard = RimeCards.Three + elseif Player:GetAuras():FindMy(RimeCards.Four):IsUp() then + topCard = RimeCards.Four + elseif Player:GetAuras():FindMy(RimeCards.Five):IsUp() then + topCard = RimeCards.Five + elseif Player:GetAuras():FindMy(RimeCards.Six):IsUp() then + topCard = RimeCards.Six + elseif Player:GetAuras():FindMy(RimeCards.Seven):IsUp() then + topCard = RimeCards.Seven + elseif Player:GetAuras():FindMy(RimeCards.Eight):IsUp() then + topCard = RimeCards.Eight + end + + return topCard +end + +local function HasRimeCard() + return GetRimeTopCard() ~= nil +end + +local RimeTarget = Bastion.UnitManager:CreateCustomUnit('rime', function() + local target = nil + + Bastion.UnitManager:EnumEnemies(function(unit) + if unit:IsDead() then + return false + end + + if not Player:CanSee(unit) then + return false + end + + if not Player:InMelee(unit) then + return false + end + + if not Player:IsFacing(unit) then + return false + end + + if not unit:IsBoss() and Player:GetEnemies(10) < 3 then + return false + end + + if HasRimeCard() and DarkMoonRime:IsEquippedAndUsable() and + (unit:TimeToDie() < GetRimeDuration(GetRimeTopCard()) - 0.5 or unit:IsBoss()) then + target = unit + return true + end + end) + + if target == nil then + target = None + end + + return target +end) + local DefaultAPL = Bastion.APL:New('default') local CDsAPL = Bastion.APL:New('cds') local StealthedAPL = Bastion.APL:New('stealthed') @@ -1017,7 +1107,7 @@ ItemsAPL:AddItem( ItemsAPL:AddSpell( TricksOfTheTrade:CastableIf(function(self) - return Tank:Exists() and self:IsKnownAndUsable() and + return Tank:Exists() and Target:Exists() and self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() and Player:IsTanking(Target) end):SetTarget(Tank) @@ -1059,20 +1149,13 @@ ItemsAPL:AddItem( end):SetTarget(Player) ) -ItemsAPL:AddItem( +-- Since we are sniping soon to die targets with rime we can put it in the default APL since we want burst damage +DefaultAPL:AddItem( DarkMoonRime:UsableIf(function(self) - return Target:Exists() and Player:InMelee(Target) and self:IsEquippedAndUsable() and + return RimeTarget:Exists() and Player:InMelee(RimeTarget) and self:IsEquippedAndUsable() and not Player:IsCastingOrChanneling() and (Player:GetMeleeAttackers() > 2 or Target:IsBoss()) and - (Player:GetAuras():FindMy(RimeCards.One):IsUp() or - Player:GetAuras():FindMy(RimeCards.Two):IsUp() or - Player:GetAuras():FindMy(RimeCards.Three):IsUp() or - Player:GetAuras():FindMy(RimeCards.Four):IsUp() or - Player:GetAuras():FindMy(RimeCards.Five):IsUp() or - Player:GetAuras():FindMy(RimeCards.Six):IsUp() or - Player:GetAuras():FindMy(RimeCards.Seven):IsUp() or - Player:GetAuras():FindMy(RimeCards.Eight):IsUp() - ) - end):SetTarget(Target) + HasRimeCard() + end):SetTarget(RimeTarget) ) -- # Executed every time the actor is available. @@ -1097,6 +1180,23 @@ DefaultAPL:AddSpell( end):SetTarget(KickTarget) ) +DefaultAPL:AddSpell( + KidneyShot:CastableIf(function(self) + return KickTarget:Exists() and self:IsInRange(KickTarget) and + self:IsKnownAndUsable() and + not Player:IsCastingOrChanneling() and Player:IsFacing(Target) + end):SetTarget(KickTarget) +) + +-- Purge +DefaultAPL:AddSpell( + Shiv:CastableIf(function(self) + return PurgeTarget:Exists() and + self:IsKnownAndUsable() and + not Player:IsCastingOrChanneling() and Player:IsFacing(Target) + end):SetTarget(PurgeTarget) +) + -- double consume_cp_max() const -- { -- return COMBO_POINT_MAX + as( talent.rogue.deeper_stratagem->effectN( 2 ).base_value() + @@ -1330,13 +1430,14 @@ DefaultAPL:AddSpell( ) -- # Builders --- actions.build=shuriken_storm,if=spell_targets>=2+(buff.lingering_shadow.remains>=6|buff.perforated_veins.up) +-- actions.build=shuriken_storm,if=spell_targets>=2+(talent.gloomblade&buff.lingering_shadow.remains>=6|buff.perforated_veins.up) BuildAPL:AddSpell( ShurikenStorm:CastableIf( function(self) - return self:IsKnownAndUsable() and - Player:GetEnemies(10) >= 2 + ((Player:GetAuras():FindMy(LingeringShadow):GetRemainingTime() >= 6 or - Player:GetAuras():FindMy(PerforatedVeins):IsUp()) and 1 or 0) + return self:IsKnownAndUsable() and self:IsInRange(Target) and + Player:GetEnemies(10) >= 2 + ((Gloomblade:IsKnown() and + (Player:GetAuras():FindMy(LingeringShadow):GetRemainingTime() >= 6 or + Player:GetAuras():FindMy(PerforatedVeins):IsUp())) and 1 or 0) end ):SetTarget(Target) ) diff --git a/src/MythicPlusUtils/MythicPlusUtils.lua b/src/MythicPlusUtils/MythicPlusUtils.lua index 60784dc..dbafc79 100644 --- a/src/MythicPlusUtils/MythicPlusUtils.lua +++ b/src/MythicPlusUtils/MythicPlusUtils.lua @@ -3,7 +3,11 @@ local Tinkr, Bastion = ... ---@class MythicPlusUtils local MythicPlusUtils = { debuffLogging = false, - random = '' + castLogging = false, + random = '', + loggedCasts = {}, + loggedDebuffs = {}, + kickList = {}, } MythicPlusUtils.__index = MythicPlusUtils @@ -91,7 +95,8 @@ function MythicPlusUtils:New() if #addedAuras > 0 then for i = 1, #addedAuras do local aura = Bastion.Aura:CreateFromUnitAuraInfo(addedAuras[i]) - if not aura:IsBuff() then + + if not self.loggedDebuffs[aura:GetSpell():GetID()] and not aura:IsBuff() then WriteFile('bastion-MPlusDebuffs-' .. self.random .. '.lua', [[ AuraName: ]] .. aura:GetName() .. [[ AuraID: ]] .. aura:GetSpell():GetID() .. "\n" .. [[ @@ -102,6 +107,44 @@ function MythicPlusUtils:New() end end) + Bastion.EventManager:RegisterWoWEvent('UNIT_SPELLCAST_START', function(unitTarget, castGUID, spellID) + if not self.castLogging then + return + end + + if self.loggedCasts[spellID] then + return + end + + local name = GetSpellInfo(spellID) + + self.loggedCasts[spellID] = true + + WriteFile('bastion-MPlusCasts-' .. self.random .. '.lua', [[ + CastName: ]] .. name .. [[ + CastID: ]] .. spellID .. "\n" .. [[ + ]], true) + end) + + Bastion.EventManager:RegisterWoWEvent('UNIT_SPELLCAST_CHANNEL_START', function(unitTarget, castGUID, spellID) + if not self.castLogging then + return + end + + if self.loggedCasts[spellID] then + return + end + + local name = GetSpellInfo(spellID) + + self.loggedCasts[spellID] = true + + WriteFile('bastion-MPlusCasts-' .. self.random .. '.lua', [[ + CastName: ]] .. name .. [[ + CastID: ]] .. spellID .. "\n" .. [[ + ]], true) + end) + return self end @@ -109,6 +152,10 @@ function MythicPlusUtils:ToggleDebuffLogging() self.debuffLogging = not self.debuffLogging end +function MythicPlusUtils:ToggleCastLogging() + self.castLogging = not self.castLogging +end + function MythicPlusUtils:CastingCriticalKick(unit, percent) local castingSpell = unit:GetCastingOrChannelingSpell() diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 86cb043..af14a78 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -286,12 +286,20 @@ function Unit:CanSee(unit) local ah = ObjectHeight(self:GetOMToken()) local attx, atty, attz = GetUnitAttachmentPosition(unit.unit, 34) + if not attx or not ax then + return false + end + + if not ah then + return false + end + if (ax == 0 and ay == 0 and az == 0) or (attx == 0 and atty == 0 and attz == 0) then return true end if not attx or not ax then - return true + return false end local x, y, z = TraceLine(ax, ay, az + ah, attx, atty, attz, losFlag) @@ -483,7 +491,7 @@ function Unit:IsFacing(unit) local x, y, z = ObjectPosition(self:GetOMToken()) local x2, y2, z2 = ObjectPosition(unit.unit) - if not x or not x2 then + if not x or not x2 or not rot then return false end diff --git a/src/_bastion.lua b/src/_bastion.lua index 1e2aaef..f701f55 100644 --- a/src/_bastion.lua +++ b/src/_bastion.lua @@ -216,9 +216,16 @@ Command:Register('mplus', 'Toggle m+ module on/off', function(args) return end + if cmd == 'casts' then + Bastion.MythicPlusUtils:ToggleCastLogging() + Bastion:Print("Cast logging", Bastion.MythicPlusUtils.castLogging and "enabled" or "disabled") + return + end + Bastion:Print("[MythicPlusUtils] Unknown command") Bastion:Print("Available commands:") Bastion:Print("debuffs") + Bastion:Print("casts") end) local files = ListFiles("scripts/bastion/scripts")