-
Notifications
You must be signed in to change notification settings - Fork 46
/
fh.lua
executable file
·94 lines (84 loc) · 2.9 KB
/
fh.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
--/click ActionButton1
-- SetCVar("autointeract", "1") -- Enable Click-to-Move -- RunMacroText("/console AutoInteract 1")
-- SetCVar("autointeract", "0") -- Disable Click-to-Move -- RunMacroText("/console AutoInteract 0")
-- reaction = UnitReaction("unit", "unit")
-- 1 - Hated
-- 2 - Hostile
-- 3 - Unfriendly
-- 4 - Neutral
-- 5 - Friendly
-- 6 - Honored
-- 7 - Revered
-- 8 - Exalted
-- TYPE_OBJECT
-- TYPE_ITEM
-- TYPE_CONTAINER
-- TYPE_UNIT
-- TYPE_PLAYER
-- TYPE_GAMEOBJECT
-- TYPE_DYNAMICOBJECT
-- TYPE_CORPSE
-- Object:GetMaxHealth ()
-- Object:GetHealth ()
-- Object:GetName () Returns the object's name. Only available for game objects, units, and players.
-- Object:GetGUID () Returns the object's GUID.
-- Object:CastSpellByName (Name)
-- Casts a spell at the object. If the spell is an area spell, it will be cast at the object's location. Only available for units and players.
-- Object:GetTarget () Returns the object's target Only available for units and players.
-- Object:Target () Targets the object. Only available for units and players.
-- Object:GetGUID () Returns the object's GUID.
-----------------------
-- FUNCTION RAIDSTATUS
-----------------------
-----------------------
-- FUNCTION TEST
-----------------------
fh = {}
fh.FriendUnit = {}
fh.EnemyUnit = {}
fh.RaidStatus = {}
fh.RaidTarget = {}
function fh.groundClick(spell,unit)
if unit == nil then unit = "player" end
local UnitGuid = UnitGUID(unit)
local knownTypes = {[0]="player", [1]="world object", [3]="NPC", [4]="pet", [5]="vehicle"}
if FireHack and UnitGuid ~= nil then
local knownType = tonumber(UnitGuid:sub(5,5), 16) % 8
if (knownTypes[knownType] ~= nil) then
local UnitObject = GetObjectFromGUID(UnitGuid)
UnitObject:CastSpellByName(spell)
end
end
end
-- this is from the PE Addon , thx to phelps
function fh.Distance(a, b)
if UnitExists(a) and UnitIsVisible(a) and UnitExists(b) and UnitIsVisible(b) then
local ax, ay, az = ObjectPosition(a)
local bx, by, bz = ObjectPosition(b)
return math.sqrt(((bx-ax)^2) + ((by-ay)^2) + ((bz-az)^2)) - ((UnitCombatReach(a)) + (UnitCombatReach(b)))
end
return 0
end
function fh.UnitsAroundUnit(unit, distance)
local total = 0
-- for OSX Users it's a little bit dirty since there is no FireHack on OSX.. we need to check for jps.MultiTarget and return a default value
if not FireHack and jps.MultiTarget == true then return 4 end
if not FireHack and jps.MultiTarget == false then return 0 end
if not distance then distance = 10 end
if UnitExists(unit) then
local totalObjects = ObjectCount()
for i = 1, totalObjects do
local object = ObjectWithIndex(i)
if bit.band(ObjectType(object), ObjectTypes.Unit) > 0 then
local reaction = UnitReaction("player", object)
local combat = UnitAffectingCombat(object)
if reaction and reaction <= 4 and combat then
if fh.Distance(object, unit) <= distance then
total = total + 1
end
end
end
end
end
return total
end