Add equality overload for Unit,Item,Aura pass through refreshable/cachable objects

pull/1/head
4n0n 2 years ago
parent 3c4abd406d
commit 98d46b6b42
  1. 46
      scripts/subtlety.lua
  2. 13
      src/Aura/Aura.lua
  3. 5
      src/Cacheable/Cacheable.lua
  4. 5
      src/Item/Item.lua
  5. 100
      src/MythicPlusUtils/MythicPlusUtils.lua
  6. 5
      src/Refreshable/Refreshable.lua
  7. 5
      src/Spell/Spell.lua
  8. 7
      src/Unit/Unit.lua

@ -775,6 +775,7 @@ local GrandMelee = Bastion.SpellBook:GetSpell(193358)
local Broadside = Bastion.SpellBook:GetSpell(193356)
local TrueBearing = Bastion.SpellBook:GetSpell(193359)
local RuthlessPrecision = Bastion.SpellBook:GetSpell(193357)
local DeviousStratagem = Bastion.SpellBook:GetSpell(193531)
local SkullAndCrossbones = Bastion.SpellBook:GetSpell(199603)
local ShadowFocus = Bastion.SpellBook:GetSpell(108209)
local BuriedTreasure = Bastion.SpellBook:GetSpell(199600)
@ -1109,7 +1110,7 @@ DefaultAPL:AddVariable(
'snd_condition',
function()
return Player:GetAuras():FindMy(SliceAndDice):IsUp() or
Player:GetEnemies(10) >= Player:GetComboPointsMax()
Player:GetEnemies(10) >= ConsumeCPMax()
end
)
@ -1206,7 +1207,7 @@ DefaultAPL:AddAPL(
DefaultAPL:AddSpell(
SliceAndDice:CastableIf(
function(self)
return self:IsKnownAndUsable() and Player:GetEnemies(10) < Player:GetComboPointsMax() and
return self:IsKnownAndUsable() and Player:GetEnemies(10) < ConsumeCPMax() and
Player:GetAuras():FindMy(SliceAndDice):GetRemainingTime() < Player:GetGCD() and
Player:GetAuras():FindMy(SliceAndDice):GetRemainingTime() > 6 and
Player:GetComboPoints() >= 4
@ -1257,7 +1258,7 @@ DefaultAPL:AddAPL(
DefaultAPL:AddAPL(
FinishAPL,
function()
return DefaultAPL:GetVariable('effective_combo_points') >= Player:GetComboPointsMax()
return DefaultAPL:GetVariable('effective_combo_points') >= ConsumeCPMax()
end
)
@ -1345,9 +1346,9 @@ BuildAPL:AddSpell(
BuildAPL:AddVariable(
'anima_helper',
function()
return not EchoingReprimand:IsKnown() or (not (DefaultAPL:GetVariable('is_next_cp_animacharged') and
return not EchoingReprimand:IsKnown() or ((not (DefaultAPL:GetVariable('is_next_cp_animacharged') and
(Player:GetTimeToShurikenTornado(3) < 0.5 or Player:GetTimeToShurikenTornado(4) < 1) and
Player:GetPower() < 60))
Player:GetPower() < 60)))
end
)
@ -1387,7 +1388,8 @@ CDsAPL:AddSpell(
CDsAPL:AddSpell(
SymbolsOfDeath:CastableIf(
function(self)
return self:IsKnownAndUsable() and Player:GetAuras():FindMy(ShurikenTornado):IsUp() and
return Player:IsAffectingCombat() and self:IsKnownAndUsable() and
Player:GetAuras():FindMy(ShurikenTornado):IsUp() and
Player:GetAuras():FindMy(ShurikenTornado):GetRemainingTime() <= 3.5
end
):SetTarget(Player)
@ -1590,6 +1592,16 @@ FinishAPL:AddVariable(
end
)
-- return ( cp + 1 ) * p()->buffs.slice_and_dice->data().duration();
function GetTriggeredDuration()
return (Player:GetComboPoints() + 1) * 6
end
-- return p()->buffs.slice_and_dice->remains() < get_triggered_duration( as<int>( p()->current_effective_cp( false ) ) ) * 0.3;
function Refreshable(aura, target)
return target:GetAuras():FindMy(aura):GetRemainingTime() < GetTriggeredDuration() * 0.3
end
-- actions.finish+=/slice_and_dice,if=!variable.premed_snd_condition&spell_targets.shuriken_storm<6&!buff.shadow_dance.up&buff.slice_and_dice.remains<fight_remains&refreshable
FinishAPL:AddSpell(
SliceAndDice:CastableIf(
@ -1598,7 +1610,7 @@ FinishAPL:AddSpell(
Player:GetEnemies(10) < 6 and
not Player:GetAuras():FindMy(ShadowDanceAura):IsUp() and
Player:GetAuras():FindMy(SliceAndDice):GetRemainingTime() < Target:TimeToDie() and
Player:GetAuras():FindMy(SliceAndDice):GetRemainingTime() < 6
Refreshable(SliceAndDice, Player)
end
):SetTarget(Player)
)
@ -1637,7 +1649,7 @@ FinishAPL:AddSpell(
(not DefaultAPL:GetVariable('skip_rupture') or
DefaultAPL:GetVariable('priority_rotation')) and
Target:TimeToDie() - Target:GetAuras():FindMy(Rupture):GetRemainingTime() > 6 and
Target:GetAuras():FindMy(Rupture):GetRemainingTime() < 6
Refreshable(Rupture, Target)
end
):SetTarget(Target)
)
@ -1694,7 +1706,7 @@ FinishAPL:AddSpell(
not DefaultAPL:GetVariable('priority_rotation') and
Player:GetEnemies(10) >= 2 and
RuptureTarget:TimeToDie() >= (2 * Player:GetComboPoints()) and
RuptureTarget:GetAuras():FindMy(Rupture):GetRemainingTime() < 6
Refreshable(Rupture, RuptureTarget)
end
):SetTarget(RuptureTarget)
)
@ -1901,11 +1913,25 @@ StealthedAPL:AddSpell(
):SetTarget(Target)
)
--[[
double consume_cp_max() const
{
return COMBO_POINT_MAX + as<double>( talent.rogue.deeper_stratagem->effectN( 2 ).base_value() +
talent.outlaw.devious_stratagem->effectN( 2 ).base_value() +
talent.subtlety.secret_stratagem->effectN( 2 ).base_value() );
}
]]
function ConsumeCPMax()
return 5 + (DeeperStratagem:IsKnownAndUsable() and 1 or 0) + (DeviousStratagem:IsKnownAndUsable() and 1 or 0) +
(SecretStratagem:IsKnownAndUsable() and 1 or 0)
end
-- actions.stealthed+=/call_action_list,name=finish,if=variable.effective_combo_points>=cp_max_spend
StealthedAPL:AddAPL(
FinishAPL,
function(self)
return DefaultAPL:GetVariable('effective_combo_points') >= Player:GetComboPointsMax()
return DefaultAPL:GetVariable('effective_combo_points') >= ConsumeCPMax()
end
)

@ -18,6 +18,19 @@ function Aura:__index(k)
return response
end
-- Equals
function Aura:__eq(other)
if getmetatable(other) == Aura then
return self:GetSpell():GetID() == other:GetSpell():GetID()
end
if getmetatable(other) == Bastion.Spell then
return self:GetSpell():GetID() == other:GetID()
end
return false
end
function Aura:__tostring()
return "Bastion.__Aura(" .. self:GetSpell():GetID() .. ")" .. " - " .. (self:GetName() or "''")
end

@ -5,7 +5,10 @@ local Tinkr, Bastion = ...
local Cacheable = {
cache = nil,
callback = nil,
value = nil
value = nil,
__eq = function(self, other)
return self.value.__eq(self.value, other)
end
}
-- On index check the cache to be valid and return the value or reconstruct the value and return it

@ -30,6 +30,11 @@ function Item:__index(k)
return response
end
-- Equals
function Item:__eq(other)
return self:GetID() == other:GetID()
end
-- tostring
function Item:__tostring()
return "Bastion.__Item(" .. self:GetID() .. ")" .. " - " .. self:GetName()

@ -14,70 +14,70 @@ function MythicPlusUtils:New()
self.random = math.random(1000000, 9999999)
self.kickList = {
-- Algeth'ar Academy
[396812] = true,
[388392] = true,
[388863] = true,
[388862] = true,
[377389] = true,
[388623] = true,
[396640] = true,
[387975] = true,
[387843] = true,
[396812] = true, -- https://www.wowhead.com/spell=396812/mystic-blast
[388392] = true, -- https://www.wowhead.com/spell=388392/monotonous-lecture
[388863] = true, -- https://www.wowhead.com/spell=388863/mana-void
[388862] = true, -- https://www.wowhead.com/spell=388862/surge
[377389] = true, -- https://www.wowhead.com/spell=377389/call-of-the-flock
[388623] = true, -- https://www.wowhead.com/spell=388623/branch-out
[396640] = true, -- https://www.wowhead.com/spell=396640/healing-touch
[387975] = true, -- https://www.wowhead.com/spell=387975/arcane-missiles
[387843] = true, -- https://www.wowhead.com/spell=387843/astral-bomb
-- Court of Stars
[211401] = true,
[207980] = true,
[208165] = true,
[207881] = true,
[209413] = true,
[211401] = true, -- https://wowhead.com/spell=211401
[207980] = true, -- https://wowhead.com/spell=207980
[208165] = true, -- https://wowhead.com/spell=208165
[207881] = true, -- https://wowhead.com/spell=207881
[209413] = true, -- https://wowhead.com/spell=209413
-- Halls of Valor
[198595] = true,
[198959] = true,
[215433] = true,
[192288] = true,
[199726] = true,
[198750] = true,
[198595] = true, -- https://wowhead.com/spell=198595
[198959] = true, -- https://wowhead.com/spell=198959
[215433] = true, -- https://wowhead.com/spell=215433
[192288] = true, -- https://wowhead.com/spell=192288
[199726] = true, -- https://wowhead.com/spell=199726
[198750] = true, -- https://wowhead.com/spell=198750
-- Ruby Life Pools
[372749] = true,
[373803] = true,
[373017] = true,
[392398] = true,
[392451] = true,
[385310] = true,
[372749] = true, -- https://wowhead.com/spell=372749
[373803] = true, -- https://wowhead.com/spell=373803
[373017] = true, -- https://wowhead.com/spell=373017
[392398] = true, -- https://wowhead.com/spell=392398
[392451] = true, -- https://wowhead.com/spell=392451
[385310] = true, -- https://wowhead.com/spell=385310
-- Shadowmoon Burial Grounds
[152818] = true,
[156776] = true,
[156722] = true,
[398206] = true,
[153524] = true,
[156718] = true,
[152818] = true, -- https://wowhead.com/spell=152818
[156776] = true, -- https://wowhead.com/spell=156776
[156722] = true, -- https://wowhead.com/spell=156722
[398206] = true, -- https://wowhead.com/spell=398206
[153524] = true, -- https://wowhead.com/spell=153524
[156718] = true, -- https://wowhead.com/spell=156718
-- Temple of the Jade Serpent
[397888] = true,
[395859] = true,
[396073] = true,
[397914] = true,
[397888] = true, -- https://wowhead.com/spell=397888
[395859] = true, -- https://wowhead.com/spell=395859
[396073] = true, -- https://wowhead.com/spell=396073
[397914] = true, -- https://wowhead.com/spell=397914
-- The Azure Vault
[375602] = true,
[387564] = true,
[373932] = true,
[386546] = true,
[389804] = true,
[377488] = true,
[377503] = true,
[375602] = true, -- https://wowhead.com/spell=375602
[387564] = true, -- https://wowhead.com/spell=387564
[373932] = true, -- https://wowhead.com/spell=373932
[386546] = true, -- https://wowhead.com/spell=386546
[389804] = true, -- https://wowhead.com/spell=389804
[377488] = true, -- https://wowhead.com/spell=377488
[377503] = true, -- https://wowhead.com/spell=377503
-- NO
[384365] = true,
[386012] = true,
[386024] = true,
[387411] = true,
[387606] = true,
[373395] = true,
[376725] = true,
[384365] = true, -- https://wowhead.com/spell=384365
[386012] = true, -- https://wowhead.com/spell=386012
[386024] = true, -- https://wowhead.com/spell=386024
[387411] = true, -- https://wowhead.com/spell=387411
[387606] = true, -- https://wowhead.com/spell=387606
[373395] = true, -- https://wowhead.com/spell=373395
[376725] = true, -- https://wowhead.com/spell=376725
}
Bastion.EventManager:RegisterWoWEvent('UNIT_AURA', function(unit, auras)

@ -5,7 +5,10 @@ local Tinkr, Bastion = ...
local Refreshable = {
cache = nil,
callback = nil,
value = nil
value = nil,
__eq = function(self, other)
return self.value.__eq(self.value, other)
end
}
-- On index check the cache to be valid and return the value or reconstruct the value and return it

@ -31,6 +31,11 @@ function Spell:__index(k)
return response
end
-- Equals
function Spell:__eq(other)
return self:GetID() == other:GetID()
end
-- tostring
function Spell:__tostring()
return "Bastion.__Spell(" .. self:GetID() .. ")" .. " - " .. self:GetName()

@ -28,6 +28,11 @@ function Unit:__index(k)
return response
end
-- Equals
function Unit:__eq(other)
return UnitIsUnit(self.unit, other.unit)
end
-- tostring
function Unit:__tostring()
return "Bastion.__Unit(" .. tostring(self.unit) .. ")" .. " - " .. (self:GetName() or '')
@ -219,7 +224,7 @@ end
-- Get if the unit is affecting combat
function Unit:IsAffectingCombat()
return UnitAffectingCombat('player', self.unit)
return UnitAffectingCombat(self.unit)
end
-- Get the units class id

Loading…
Cancel
Save