Last active
August 29, 2015 14:14
-
-
Save StinkyTwitch/874e7f10d8319bbaf049 to your computer and use it in GitHub Desktop.
Modified UnitsAroundUnit firehack.lua
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
-- ProbablyEngine Rotations | |
-- Released under modified BSD, see attached LICENSE. | |
-- Functions that require FireHack | |
local SpecialTargets = { | |
-- TRAINING DUMMIES | |
31144, -- Training Dummy - Lvl 80 | |
31146, -- Raider's Training Dummy - Lvl ?? | |
32541, -- Initiate's Training Dummy - Lvl 55 (Scarlet Enclave) | |
32542, -- Disciple's Training Dummy - Lvl 65 | |
32545, -- Initiate's Training Dummy - Lvl 55 | |
32546, -- Ebon Knight's Training Dummy - Lvl 80 | |
32666, -- Training Dummy - Lvl 60 | |
32667, -- Training Dummy - Lvl 70 | |
46647, -- Training Dummy - Lvl 85 | |
60197, -- Scarlet Monastery Dummy | |
67127, -- Training Dummy - Lvl 90 | |
87761, -- Dungeoneer's Training Dummy <Damage> HORDE GARRISON | |
88288, -- Dunteoneer's Training Dummy <Tanking> HORDE GARRISON | |
88289, -- Training Dummy <Healing> HORDE GARRISON | |
88314, -- Dungeoneer's Training Dummy <Tanking> ALLIANCE GARRISON | |
88316, -- Training Dummy <Healing> ALLIANCE GARRISON | |
89078, -- Training Dummy (Garrison) | |
87318, -- Dungeoneer's Training Dummy <Damage> | |
-- WOD DUNGEONS/RAIDS | |
71075, -- Small Illusionary Banshee (Proving Grounds) | |
75966, -- Defiled Spirit (Shadowmoon Burial Grounds) | |
76220, -- Blazing Trickster (Auchindoun Normal) | |
76267, -- Solar Zealot (Skyreach) | |
76518, -- Ritual of Bones (Shadowmoon Burial Grounds) | |
79511, -- Blazing Trickster (Auchindoun Heroic) | |
81638, -- Aqueous Globule (The Everbloom) | |
153792, -- Rallying Banner (UBRS Black Iron Grunt) | |
77252, -- Ore Crate (BRF Oregorger) | |
79504, -- Ore Crate (BRF Oregorger) | |
86644, -- Ore Crate (BRF Oregorger) | |
77665, -- Iron Bomber (BRF Blackhand) | |
} | |
local L = ProbablyEngine.locale.get | |
function ProbablyEngine.protected.FireHack() | |
if FireHack then | |
ProbablyEngine.faceroll.rolling = false | |
local stickyValue = GetCVar("deselectOnClick") | |
ProbablyEngine.pmethod = "FireHack" | |
function SpecialTargetCheck(unit) | |
local unit = unit | |
local count = table.getn(SpecialTargets) | |
if not UnitExists(unit) then | |
return false | |
end | |
if UnitGUID(unit) then | |
targets_guid = tonumber(string.match(UnitGUID(unit), "-(%d+)-%x+$")) | |
else | |
targets_guid = 0 | |
end | |
for i=1, count do | |
if targets_guid == SpecialTargets[i] then | |
return true | |
end | |
end | |
return false | |
end | |
function IterateObjects(callback, ...) | |
local totalObjects = ObjectCount() | |
for i = 1, totalObjects do | |
local object = ObjectWithIndex(i) | |
local _, oType = pcall(ObjectType, object) | |
if bit.band(oType, ...) > 0 then | |
callback(object) | |
end | |
end | |
end | |
function ObjectFromUnitID(unit) | |
local unitGUID = UnitGUID(unit) | |
local totalObjects = ObjectCount() | |
for i = 1, totalObjects do | |
local object = ObjectWithIndex(i) | |
if UnitExists(object) and UnitGUID(object) == unitGUID then | |
return object | |
end | |
end | |
return false | |
end | |
function Distance(a, b) | |
if UnitExists(a) and UnitIsVisible(a) and UnitExists(b) and UnitIsVisible(b) then | |
local _, ax, ay, az = pcall(ObjectPosition, a) | |
local _, bx, by, bz = pcall(ObjectPosition, b) | |
return math.sqrt(((bx-ax)^2) + ((by-ay)^2) + ((bz-az)^2)) - ((UnitCombatReach(a)) + (UnitCombatReach(b))) | |
end | |
return 0 | |
end | |
local uau_cache_time = { } | |
local uau_cache_count = { } | |
local uau_cache_dura = 0.1 | |
function UnitsAroundUnit(unit, distance, ignoreCombat) | |
local uau_cache_time_c = uau_cache_time[unit..distance..tostring(ignoreCombat)] | |
if uau_cache_time_c and ((uau_cache_time_c + uau_cache_dura) > GetTime()) then | |
return uau_cache_count[unit..distance..tostring(ignoreCombat)] | |
end | |
if UnitExists(unit) then | |
local total = 0 | |
local totalObjects = ObjectCount() | |
for i = 1, totalObjects do | |
local object = ObjectWithIndex(i) | |
local _, oType = pcall(ObjectType, object) | |
if bit.band(oType, ObjectTypes.Unit) > 0 then | |
local reaction = UnitReaction("player", object) | |
local combat = UnitAffectingCombat(object) | |
local _, special_target = pcall(SpecialTargetCheck, object) | |
local _, tapped_by_me = pcall(UnitIsTappedByPlayer, object) | |
local _, tapped_by_all = pcall(UnitIsTappedByAllThreatList, object) | |
--if reaction and reaction <= 4 and (ignoreCombat or combat) then | |
if reaction and reaction <= 4 and (ignoreCombat or tapped_by_me or tapped_by_all or special_target) then | |
if Distance(object, unit) <= distance then | |
total = total + 1 | |
end | |
end | |
end | |
end | |
uau_cache_count[unit..distance..tostring(ignoreCombat)] = total | |
uau_cache_time[unit..distance..tostring(ignoreCombat)] = GetTime() | |
return total | |
else | |
return 0 | |
end | |
end | |
function FriendlyUnitsAroundUnit(unit, distance, ignoreCombat) | |
local uau_cache_time_c = uau_cache_time[unit..distance..tostring(ignoreCombat)..'f'] | |
if uau_cache_time_c and ((uau_cache_time_c + uau_cache_dura) > GetTime()) then | |
return uau_cache_count[unit..distance..tostring(ignoreCombat)..'f'] | |
end | |
if UnitExists(unit) then | |
local total = 0 | |
local totalObjects = ObjectCount() | |
for i = 1, totalObjects do | |
local object = ObjectWithIndex(i) | |
local _, oType = pcall(ObjectType, object) | |
if bit.band(oType, ObjectTypes.Unit) > 0 then | |
local reaction = UnitReaction("player", object) | |
local combat = UnitAffectingCombat(object) | |
if reaction and reaction >= 5 and (ignoreCombat or combat) then | |
if Distance(object, unit) <= distance then | |
total = total + 1 | |
end | |
end | |
end | |
end | |
uau_cache_count[unit..distance..tostring(ignoreCombat)..'f'] = total | |
uau_cache_time[unit..distance..tostring(ignoreCombat)..'f'] = GetTime() | |
return total | |
else | |
return 0 | |
end | |
end | |
function FaceUnit(unit) | |
if UnitExists(unit) and UnitIsVisible(unit) then | |
local _, ax, ay, az = pcall(ObjectPosition, 'player') | |
local _, bx, by, bz = pcall(ObjectPosition, unit) | |
local angle = rad(atan2(by - ay, bx - ax)) | |
if angle < 0 then | |
return FaceDirection(rad(atan2(by - ay, bx - ax) + 360)) | |
else | |
return FaceDirection(angle) | |
end | |
end | |
end | |
local losFlags = bit.bor(0x10, 0x100) | |
function LineOfSight(a, b) | |
local _, ax, ay, az = pcall(ObjectPosition, a) | |
local _, bx, by, bz = pcall(ObjectPosition, b) | |
if TraceLine(ax, ay, az+2.25, bx, by, bz+2.25, losFlags) then | |
return false | |
end | |
return true | |
end | |
--[[ | |
function UnitInfront(unit) | |
local aX, aY, aZ = ObjectPosition(unit) | |
local bX, bY, bZ = ObjectPosition('player') | |
local playerFacing = GetPlayerFacing() | |
local facing = math.atan2(bY - aY, bX - aX) % 6.2831853071796 | |
return math.abs( math.abs(playerFacing - facing) - 180 ) < 1.5707963267949 | |
end | |
]] | |
function UnitInfront(unit1, unit2) | |
if not (UnitExists(unit1) and UnitExists(unit2)) then return end | |
local _, x1, y1, _ = pcall(ObjectPosition, unit1) | |
local _, x2, y2, _ = pcall(ObjectPosition, unit2) | |
local facing = ObjectFacing(unit1) | |
local angle = atan2(y1 - y2, x1 - x2) - deg(facing) | |
if angle < 0 then | |
angle = angle + 360 | |
end | |
return (angle > 120 and angle < 240) | |
end | |
function CastGround(spell, target) | |
if UnitExists(target) then | |
local _, x1, y1, z1 = pcall(ObjectPosition, target) | |
CastSpellByName(spell) | |
CastAtPosition(x1, y1, z1) | |
CancelPendingSpell() | |
return | |
end | |
if not ProbablyEngine.timeout.check('groundCast') then | |
ProbablyEngine.timeout.set('groundCast', 0.05, function() | |
Cast(spell) | |
if IsAoEPending() then | |
SetCVar("deselectOnClick", "0") | |
CameraOrSelectOrMoveStart(1) | |
CameraOrSelectOrMoveStop(1) | |
SetCVar("deselectOnClick", "1") | |
SetCVar("deselectOnClick", stickyValue) | |
CancelPendingSpell() | |
end | |
end) | |
end | |
end | |
function Macro(text) | |
return RunMacroText(text) | |
end | |
function UseItem(name, target) | |
return UseItemByName(name, target) | |
end | |
function UseInvItem(slot) | |
return UseInventoryItem(slot) | |
end | |
function Cast(spell, target) | |
if type(spell) == "number" then | |
CastSpellByID(spell, target) | |
else | |
CastSpellByName(spell, target) | |
end | |
end | |
ProbablyEngine.protected.unlocked = true | |
ProbablyEngine.protected.method = "firehack" | |
ProbablyEngine.timer.unregister('detectUnlock') | |
ProbablyEngine.print(L('unlock_firehack')) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment