Last active
May 12, 2017 11:36
-
-
Save StinkyTwitch/7dcf9dc33e513fd3453ee0d0ea2f525b to your computer and use it in GitHub Desktop.
OLD FH Feral PvP Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Druid Feral Rotation (PvP)-- | |
--Created By Mhswarior-- | |
-- Constants-- | |
UPDATE_INTERVAL = math.random(.2,.4) -- in seconds | |
LAST_UPDATE = GetTime() | |
EmpoweredRip = false | |
EmpoweredRake = false | |
InitFrame = CreateFrame("Frame") | |
InitFrame:SetScript("OnUpdate", InitFrameUpdate) | |
print("Started Combat Routine") | |
function InitFrameUpdate(self, elapsed) | |
local t = GetTime() | |
if LAST_UPDATE + UPDATE_INTERVAL < t then | |
LAST_UPDATE = t | |
CombatRoutine() | |
end | |
end | |
--Combat Routine-- | |
function CombatRoutine() | |
--Buff Logic-- | |
--Cat Form (Done)-- | |
if not UnitBuff("player", "Cat Form") and CanCastSpell("Cat Form") then | |
CastSpellByName("Cat Form", "player") | |
return true | |
end | |
--Prowl (Done)-- | |
if not UnitBuff("player","Prowl") and UnitBuff("player","Cat Form") and CanCastSpell("Prowl") and not UnitAffectingCombat("player") then | |
CastSpellByName("Prowl", "player") | |
return true | |
end | |
--GCD Check-- | |
if CanCastSpell("Rejuvenation") then | |
--Get Enemies in melee range-- | |
local hostilePlayers, hostilePlayerCount = GetHostilePlayersInRange(8) | |
--Get Friendlies in healing range-- | |
local friendlyPlayers, friendlyPlayerCount = GetFriendlyPlayersInRange(40) | |
--Healing Logic-- | |
--Swiftmend (Done)-- | |
if PlayerHealthPercent() <= 35 and CanCastSpell("Swiftmend") and not UnitBuff("player","Prowl") then | |
CastSpellByName("Swiftmend","player") | |
return true | |
end | |
--Rejuvenation (Done but only casts on self)-- | |
if PlayerHealthPercent() <= 75 and not UnitBuff("player", "Rejuvenation") and not UnitBuff("player","Prowl") then | |
CastSpellByName("Rejuvenation","player") | |
return true | |
end | |
--Healing Touch (Done but only casts on self)-- | |
if PlayerHealthPercent() <= 90 and GetUnitSpeed("player") == 0 and hostilePlayerCount == 0 and not UnitBuff("player","Prowl") then | |
CastSpellByName("Healing Touch","player") | |
return true | |
end | |
--Healing Logic-- | |
--Predatory Swiftness (Done)-- | |
if UnitBuff("player", "Predatory Swiftness") and CanCastSpell("Healing Touch") then | |
local PredatorySwiftnessTimeLeft = select(7,UnitBuff("player","Predatory Swiftness")) | |
if PredatorySwiftnessTimeLeft-GetTime() <= 2.5 then | |
CastSpellByName("Healing Touch", "player") | |
return true | |
end | |
if PlayerHealthPercent() <= 70 then | |
CastSpellByName("Healing Touch","player") | |
return true | |
end | |
if friendlyPlayerCount >= 1 and HealthPercent(friendlyPlayers[1]) <= 70 then | |
CastSpellByName("Healing Touch",friendlyPlayers[1]) | |
return true | |
end | |
end | |
--Buff Logic-- | |
--CombatLogic-- | |
if IsSpellInRange("Shred","target") then | |
--Tiger's Fury (Done)-- | |
if UnitPower("player",3) <= 40 and not UnitBuff("player","Berserk") and CanCastSpell("Tiger's Fury") then | |
CastSpellByName("Tiger's Fury","player") | |
return true | |
end | |
if UnitPower("player",3) <= 90 and UnitBuff("player","Berserk") and CanCastSpell("Tiger's Fury") then | |
CastSpellByName("Tiger's Fury", "player") | |
return true | |
end | |
--Rip Check (Done)-- | |
if UnitDebuff("target","Rip") then | |
local RipTimeLeft = select(7,UnitDebuff("target","Rip")) | |
if TargetHealthPercent() <= 25 and RipTimeLeft-GetTime() <= 7.2 and CanCastSpell("Ferocious Bite") and UnitPower("player",4) == 5 then | |
CastSpellByName("Ferocious Bite", "target") | |
return true | |
end | |
if RipTimeLeft-GetTime() <= 7.2 and CanCastSpell("Rip") and UnitPower("player",4) == 5 then | |
CastSpellByName("Rip","target") | |
return true | |
end | |
end | |
--Rake Check (Done)-- | |
if UnitDebuff("target", "Rake") then | |
local RakeTimeLeft = select(7,UnitDebuff("target","Rake")) | |
if RakeTimeLeft-GetTime() <= 2.5 and CanCastSpell("Rake") then | |
CastSpellByName("Rake", "target") | |
return true | |
end | |
end | |
--Super Ferocious Bite Priority (Done)-- | |
if TargetHealthPercent() <= 40 and UnitBuff("player","Tiger's Fury") and UnitPower("player",3) >= 50 and UnitPower("player",4) == 5 and CanCastSpell("Ferocious Bite") then | |
CastSpellByName("Ferocious Bite", "target") | |
return true | |
end | |
--Rip Priority (Done)-- | |
if not UnitDebuff("target", "Rip") and UnitPower("player",4) == 5 and CanCastSpell("Rip") then | |
CastSpellByName("Rip", "target") | |
return true | |
end | |
--Ferocious Bite Priority (Done)-- | |
if UnitPower("player",4)== 5 and CanCastSpell("Ferocious Bite") then | |
CastSpellByID(22568,"target") | |
return true | |
end | |
--Rake Priority (Done)-- | |
if not UnitDebuff("target","Rake") and CanCastSpell("Rake") then | |
CastSpellByName("Rake","target") | |
return true | |
end | |
--Brutal Slash Priority (Done)-- | |
local BrutalSlashCharges = select(1,GetSpellCharges("Brutal Slash")) | |
if BrutalSlashCharges ~= nil then | |
if BrutalSlashCharges >= 1 and UnitBuff("player", "Tiger's Fury") and UnitPower("player",4) ~= 5 then | |
CastSpellByName("Brutal Slash","target") | |
return true | |
end | |
if BrutalSlashCharges >= 3 and UnitPower("player",4) ~=5 then | |
CastSpellByName("Brutal Slash","target") | |
return true | |
end | |
end | |
--Shred Priority (Done)-- | |
if CanCastSpell("Shred") and UnitPower("player",4) ~=5 then | |
CastSpellByName("Shred","target") | |
return true | |
end | |
end | |
else | |
return | |
end | |
end | |
--General Functions-- | |
-- Get a list of hostile player objects both in range and los | |
-- sorted by their health ascending, i.e. index 1 has less hp than index 2 | |
function GetHostilePlayersInRange(range) | |
hostilePlayers = {} | |
count = 0 | |
for i = 1, GetObjectCount() do | |
local obj = GetObjectWithIndex(i) | |
-- check if the object is an enemy player | |
if ObjectIsType(obj, ObjectTypes.Player) and UnitIsEnemy("player", obj) and not UnitIsDeadOrGhost(obj) and InLOS("player", obj) then | |
-- check if the object is in range | |
if GetDistanceBetweenObjects("player", obj) <= range then | |
hostilePlayers[#hostilePlayers + 1] = obj | |
count = count + 1 | |
end | |
end | |
end | |
table.sort(hostilePlayers, function(a, b) | |
return UnitHealth(a) < UnitHealth(b) | |
end) | |
return hostilePlayers, count | |
end | |
-- Get a list of friendly player objects both in range and los | |
-- sorted by their health ascending, i.e. index 1 has less hp than index 2 | |
function GetFriendlyPlayersInRange(range) | |
friendlyPlayers = {} | |
count = 0 | |
for i = 1, GetObjectCount() do | |
local obj = GetObjectWithIndex(i) | |
-- check if the object is an enemy player | |
if ObjectIsType(obj, ObjectTypes.Player) and UnitIsFriend("player", obj) and not UnitIsDeadOrGhost(obj) and InLOS("player", obj) then | |
-- check if the object is in range | |
if GetDistanceBetweenObjects("player", obj) <= range then | |
friendlyPlayers[#friendlyPlayers + 1] = obj | |
count = count + 1 | |
end | |
end | |
end | |
table.sort(friendlyPlayers, function(a, b) | |
return UnitHealth(a) < UnitHealth(b) | |
end) | |
return friendlyPlayers, count | |
end | |
-- Check if obj has the debuff from the player | |
function ObjectHasDebuff(obj, debuff) | |
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitDebuff(obj, debuff) | |
if name and unitCaster == "player" then | |
return true | |
end | |
return false | |
end | |
-- Checks if the player can cast a spell (gcd, cooldown, etc) | |
function CanCastSpell(spellName) | |
return (select(2, GetSpellCooldown(spellName)) == 0) | |
-- | |
end | |
-- Get target health percent | |
function TargetHealthPercent() | |
return (UnitHealth("target") / UnitHealthMax("target") * 100) | |
-- | |
end | |
-- Get player health percent | |
function PlayerHealthPercent() | |
return (UnitHealth("player") / UnitHealthMax("player") * 100) | |
-- | |
end | |
-- Get Object health percet | |
function HealthPercent(obj) | |
return (UnitHealth(obj) / UnitHealthMax(obj) * 100) | |
-- | |
end | |
-- Check line of sight | |
function InLOS(obj1, obj2) | |
local x1, y1, z1 = ObjectPosition(obj1) | |
local x2, y2, z2 = ObjectPosition(obj2) | |
if not TraceLine(x1, y1, z1+2.25, x2, y2, z2+2.25, bit.bor(0x10, 0x100)) then | |
return true | |
end | |
return false | |
end | |
-- Check facing | |
function IsPlayerFacing(obj) | |
local x1, y1, _ = ObjectPosition("player") | |
local x2, y2, _ = ObjectPosition(obj) | |
local playerFacing = ObjectFacing("player") | |
local deltaAngle = atan2(y1 - y2, x1 - x2) - deg(playerFacing) | |
if deltaAngle < 0 then | |
deltaAangle = deltaAngle + 360 | |
end | |
if deltaAngle > 120 and deltaAngle < 240 then | |
return true | |
end | |
return false | |
end | |
-- Face object | |
function FaceObject(obj) | |
local x1, y1, z1 = ObjectPosition("player") | |
local x2, y2, z2 = ObjectPosition(obj) | |
local angle = rad(atan2(y2 - y1, x2 - x1)) | |
if angle < 0 then | |
local angleFace = rad(atan2(y2 - y1, x2 - x1) + 360) | |
FaceDirection(angleFace) | |
else | |
FaceDirection(angle) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment