From dcfb50374d6ad23b937f3e05d14f33297e539f07 Mon Sep 17 00:00:00 2001 From: 4n0n <4n0n@tinkr.site> Date: Mon, 16 Jan 2023 21:24:47 -0600 Subject: [PATCH] Update nameplate enumeration, need to figure out a way to prevent it from breaking if nameplatenum is not where the units are (1,2,3 fall off, 4,5 stay nameplate4-5 --- scripts/outlaw.lua | 33 +++++++++++++++++++++++++++++---- src/APL/APL.lua | 18 ++++++++++++++++++ src/Item/Item.lua | 2 +- src/Unit/Unit.lua | 16 ++++++++++++++-- src/UnitManager/UnitManager.lua | 2 +- 5 files changed, 63 insertions(+), 8 deletions(-) diff --git a/scripts/outlaw.lua b/scripts/outlaw.lua index dde12aa..95fd7cd 100644 --- a/scripts/outlaw.lua +++ b/scripts/outlaw.lua @@ -35,6 +35,10 @@ local MarkedForDeath = Bastion.SpellBook:GetSpell(137619) local CrimsonVial = Bastion.SpellBook:GetSpell(185311) local Shiv = Bastion.SpellBook:GetSpell(5938) local KidneyShot = Bastion.SpellBook:GetSpell(408) +local InstantPoison = Bastion.SpellBook:GetSpell(315584) +local AtrophicPosion = Bastion.SpellBook:GetSpell(381637) + +local IrideusFragment = Bastion.ItemBook:GetItem(193743) local PurgeTarget = Bastion.UnitManager:CreateCustomUnit('purge', function(unit) local purge = nil @@ -138,6 +142,29 @@ SpecialAPL:AddSpell( end):SetTarget(PurgeTarget) ) +SpecialAPL:AddSpell( + InstantPoison:CastableIf(function(self) + return self:IsKnownAndUsable() and + not Player:IsCastingOrChanneling() and + not Player:GetAuras():FindMy(InstantPoison):IsUp() and not Player:IsMoving() + end):SetTarget(Player) +) + +SpecialAPL:AddSpell( + AtrophicPosion:CastableIf(function(self) + return self:IsKnownAndUsable() and + not Player:IsCastingOrChanneling() and + not Player:GetAuras():FindMy(AtrophicPosion):IsUp() and not Player:IsMoving() + end):SetTarget(Player) +) + +SpecialAPL:AddItem( + IrideusFragment:UsableIf(function(self) + return self:IsEquippedAndUsable() and + not Player:IsCastingOrChanneling() and (Player:GetMeleeAttackers() > 2 or Target:IsBoss()) + end):SetTarget(Player) +) + -- Adrenaline Rush on cooldown. DefaultAPL:AddSpell( AdrenalineRush:CastableIf(function(self) @@ -169,8 +196,7 @@ DefaultAPL:AddSpell( if Player:GetAuras():FindMy(TrueBearing):IsUp() then numBuffs = numBuffs + 1 end - return Target:Exists() and Player:InMelee(Target) and - self:IsKnownAndUsable() and + return self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() and ((not Player:GetAuras():FindMy(Broadside):IsUp() and not Player:GetAuras():FindMy(TrueBearing):IsUp()) or numBuffs < 2) @@ -321,8 +347,7 @@ AOEAPL:AddSpell( if Player:GetAuras():FindMy(TrueBearing):IsUp() then numBuffs = numBuffs + 1 end - return Target:Exists() and Player:InMelee(Target) and - self:IsKnownAndUsable() and + return self:IsKnownAndUsable() and not Player:IsCastingOrChanneling() and ((not Player:GetAuras():FindMy(Broadside):IsUp() and not Player:GetAuras():FindMy(TrueBearing):IsUp()) or numBuffs < 2) diff --git a/src/APL/APL.lua b/src/APL/APL.lua index 697afd4..0338752 100644 --- a/src/APL/APL.lua +++ b/src/APL/APL.lua @@ -37,6 +37,14 @@ function APL:AddSpell(spell, condition) table.insert(self.apl, { spell = spell, condition = condition, castableFunc = castableFunc, target = target }) end +-- Add an item to the APL +function APL:AddItem(item, condition) + local usableFunc = item.UsableIfFunc + local target = item:GetTarget() + + table.insert(self.apl, { item = item, condition = condition, usableFunc = usableFunc, target = target }) +end + -- Add an APL to the APL (for sub APLs) function APL:AddAPL(apl, condition) table.insert(self.apl, { apl = apl, condition = condition }) @@ -61,6 +69,16 @@ function APL:Execute() -- print("Bastion: APL:Execute: No condition for spell " .. actor.spell:GetName()) actor.spell:CastableIf(actor.castableFunc):Cast(actor.target) end + if actor.item then + if actor.condition then + -- print("Bastion: APL:Execute: Condition for spell " .. actor.spell:GetName()) + actor.item:UsableIf(actor.usableFunc):Cast(actor.target, + actor.condition) + end + + -- print("Bastion: APL:Execute: No condition for spell " .. actor.spell:GetName()) + actor.item:UsableIf(actor.usableFunc):Cast(actor.target) + end if actor.action then -- print("Bastion: APL:Execute: Executing action " .. actor.action) actor.cb(self) diff --git a/src/Item/Item.lua b/src/Item/Item.lua index 19e511b..01ddde8 100644 --- a/src/Item/Item.lua +++ b/src/Item/Item.lua @@ -148,7 +148,7 @@ function Item:Usable() return self:GetUsableFunction()(self) end - return self:IsKnownAndUsable() + return self:IsEquippedAndUsable() end -- Set a script to check if the Item is Usable diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index 65ac3a0..8ecf1aa 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -144,7 +144,7 @@ end -- IsEnemy function Unit:IsEnemy() - return UnitCanAttack("player", self.unit) and (UnitIsPVP("player") or not UnitIsPlayer(self.unit)) + return UnitCanAttack("player", self.unit) end -- Is the unit a hostile unit @@ -154,7 +154,19 @@ end -- Is the unit a boss function Unit:IsBoss() - return UnitClassification(self.unit) == "worldboss" + if UnitClassification(self.unit) == "worldboss" then + return true + end + + for i = 1, 5 do + local bossGUID = UnitGUID("boss" .. i) + + if self:GetGUID() == bossGUID then + return true + end + end + + return false end -- Is the unit a target diff --git a/src/UnitManager/UnitManager.lua b/src/UnitManager/UnitManager.lua index daeeabb..df19ace 100644 --- a/src/UnitManager/UnitManager.lua +++ b/src/UnitManager/UnitManager.lua @@ -234,7 +234,7 @@ end -- Enum enemies (nameplates) function UnitManager:EnumNameplates(cb) - local n = GetNumNameplates() + local n = 30 for i = 1, n do local unit = self:Get('nameplate' .. i) if unit:IsValid() then