· 8 years ago · Jul 22, 2018, 04:36 AM
1------------------------------------------------------------------
2-- ATTENTION: These are the API functions currently implemented
3-- in EWT. The documentation is a copy from FireHack because the
4-- idea is EWT to mirror FireHack's API. If you need an API that
5-- is missing here or an API isn't behaving properly, let me know!
6-- FireHack API: https://firehack.io/api/
7------------------------------------------------------------------
8
9
10------------------------- Active Player -------------------
11
12--- Stop falling.
13function StopFalling () end
14
15--- Move to a position.
16-- X (number) - The X coordinate
17-- Y (number) - The Y coordinate
18-- Z (number) - The Z coordinate
19-- InstantTurn (boolean) - Whether to instantly turn toward the destination
20function MoveTo (X, Y, Z[, InstantTurn])
21
22--- Teleport to a position.
23-- X (number) - The X coordinate
24-- Y (number) - The Y coordinate
25-- Z (number) - The Z coordinate
26function Teleport (X, Y, Z)
27
28--- Registers Lua callbacks for Teleport
29-- before (function) - A callback that is called before EWT teleports your character.
30-- after (function) - A callback that is called after EWT teleports your character.
31function AddTeleportCallbacks(before, after)
32-- Example:
33function myTeleportFunc()
34 AddTeleportCallbacks(
35 function()
36 local beforeX, beforeY, beforeZ = ObjectPosition("player")
37 print('Teleported from ' .. beforeX .. ' ' .. beforeY .. ' ' .. beforeZ)
38 end,
39 function()
40 local x, y, z = ObjectPosition("player")
41 print('to x ' .. x .. ' ' .. y .. ' ' .. z)
42 end
43 )
44end
45
46--- Set the direction that the player is facing (angle in XY).
47-- Direction (number) or Object (string) - The direction in radians or the object
48-- Update (boolean) - Whether to immediately notify the server
49function FaceDirection (Direction[, Update])
50
51--- Set the maximum angle from the XY plane that the player can move at
52-- Angle (number) - The maximum angle in degrees
53-- Note that the angle must be between 0º and 90º.
54function SetMaximumClimbAngle (Angle)
55
56------------------------- Object --------------------------
57
58ObjectType = {
59 Object,
60 Item,
61 Container,
62 Unit,
63 Player,
64 GameObject,
65 DynamicObject,
66 Corpse,
67 AreaTrigger,
68 SceneObject,
69 All,
70}
71
72ObjectTypes = {
73 None = 0x0,
74 Object = 0x1,
75 Item = 0x2,
76 Container = 0x4,
77 Unit = 0x8,
78 Player = 0x10,
79 GameObject = 0x20,
80 DynamicObject = 0x40,
81 Corpse = 0x80,
82 AreaTrigger = 0x100,
83 SceneObject = 0x200,
84 All = 0xFFFFFFFF,
85};
86
87--- Get an object's pointer.
88-- Object (object) - The object
89-- returns (string) - The pointer as a hexadecimal string prefixed by 0x
90function ObjectPointer (Object)
91
92--- Get an object's position.
93-- Object (object) - The object
94-- returns (number, number, number) - The X, Y, and Z coordinates
95function ObjectPosition (Object)
96
97--- Get an object's facing.
98-- Object (object) - The object
99-- returns (number) - The facing (angle in XY) in radians
100function ObjectFacing (Object)
101GetObjectFacing = ObjectFacing
102
103--- Get an object's GUID.
104-- Object (object) - The object
105-- returns (string) - The GUID
106function ObjectGUID (Object)
107
108--- Get whether an object exists in the object manager.
109-- Object (object) - The object
110-- returns (boolean) - Whether the object exists in the object manager
111-- Note that if the object does not exist in the object manager it is invalid.
112function ObjectExists (Object)
113
114--- Get an object's name.
115-- Object (object) - The object
116-- returns (string) - The name
117function ObjectName (Object)
118
119--- Get whether an object is of a type.
120-- Object (object) - The object
121-- Type (ObjectType member) - The type
122-- returns (boolean) - Whether the object is of the type
123function ObjectIsType (Object, Type)
124
125--- Get an object's type ID.
126-- Object (object) - The object
127-- returns (integer) - The type ID or nil if there is none
128function ObjectID (Object)
129
130--- Get an object's type flags.
131-- Object (object) - The object
132-- returns (integer) - One or more members of the ObjectType table combined with bit.bor
133function ObjectTypeFlags (Object)
134ObjectType = ObjectTypeFlags
135
136--- Get the distance between two objects.
137-- Object1 (object) - The first object
138-- Object2 (object) - The second object
139-- returns (number) - The distance
140function GetDistanceBetweenObjects (Object1, Object2)
141
142--- Get the angles between two objects.
143-- Object1 (object) - The first object
144-- Object2 (object) - The second object
145-- returns (number, number) - The facing (angle in XY) and pitch (angle from XY) from the first object to the second
146function GetAnglesBetweenObjects (Object1, Object2)
147
148--- Get the position that is between two objects and a specified distance from the first object.
149-- Object1 (object) - The first object
150-- Object2 (object) - The second object
151-- Distance (number) - The distance from the first object
152-- returns (number, number, number) - The X, Y, and Z coordinates
153function GetPositionBetweenObjects (Object1, Object2, Distance)
154
155--- Get whether an object is facing another.
156-- Object1 (object) - The first object
157-- Object2 (object) - The second object
158-- returns (boolean) - Whether the first object is facing the second
159function ObjectIsFacing (Object1, Object2)
160
161--- Get whether an object is behind another.
162-- Object1 (object) - The first object
163-- Object2 (object) - The second object
164-- returns (boolean) - Whether the first object is behind the second
165function ObjectIsBehind (Object1, Object2)
166
167--- Get one of an object's descriptors.
168-- Object (object) - The object
169-- Offset (integer) - The descriptor offset
170-- Type (Type member) - The descriptor type
171-- returns (Type) - The descriptor value
172function ObjectDescriptor (Object, Offset, Type)
173
174--- Get one of an object's fields.
175-- Object (object) - The object
176-- Offset (integer) - The field offset
177-- Type (Type member) - The field type
178-- returns (Type) - The field value
179function ObjectField (Object, Offset, Type)
180
181--- Interact with Object. Useful for 1.12.1 and 2.4.3 since InteractUnit isn't available in these versions.
182-- Object (object) - The object
183-- returns (boolean) - True if the object is valid, False if not
184function ObjectInteract (Object)
185
186------------------------- Object Manager ------------------
187
188--- Get the number of objects in the object manager.
189-- returns (integer) - The number of objects in the object manager
190function GetObjectCount ()
191ObjectCount = GetObjectCount
192
193--- Get an object in the object manager from its index.
194-- Index (integer) - The one-based index of the object
195-- returns (object) - The object
196function GetObjectWithIndex (Index)
197ObjectWithIndex = GetObjectWithIndex
198
199--- Get an object in the object manager from its pointer.
200-- Pointer (string) - A pointer to the object as a hexadecimal string prefixed by 0x
201-- returns (object) - The object
202function GetObjectWithPointer (Pointer)
203
204--- Get an object in the object manager from its GUID.
205-- GUID (string) - The GUID
206-- returns (object) - The object or nil if it does not in the object manager
207function GetObjectWithGUID (GUID)
208
209--- Gets the active player.
210-- returns (object) - The active player object.
211function GetActivePlayer ()
212
213--- Gets the active mover.
214-- returns (object) - The active mover object.
215-- Note: This is usually the Active Player. When you get mind controlled, lose control of your character or control
216-- something else, then the Active Mover is different.
217function GetActiveMover ()
218
219------------------------- Unit ----------------------------
220
221--- Get an object's facing direction.
222-- @param Object The object. It must be of type Unit.
223-- @param Object The object.
224-- @param Angle The frontal cone angle in degrees. Default: 180 degrees
225-- @return Boolean. Whether it is facing or not.
226function UnitIsFacing (Object, Object[, Angle]) end
227
228MovementFlags = {
229 Forward = 0x1,
230 Backward = 0x2,
231 StrafeLeft = 0x4,
232 StrafeRight = 0x8,
233 TurnLeft = 0x10,
234 TurnRight = 0x20,
235 PitchUp = 0x40,
236 PitchDown = 0x80,
237 Walking = 0x100,
238 Immobilized = 0x400,
239 Falling = 0x800,
240 FallingFar = 0x1000,
241 Swimming = 0x100000,
242 Ascending = 0x200000,
243 Descending = 0x400000,
244 CanFly = 0x800000,
245 Flying = 0x1000000,
246};
247
248--- Get a unit's movement flags.
249-- Unit (unit) - The unit
250-- returns (integer) - The movement flags
251function UnitMovementFlags (Unit)
252
253--- Set a unit's movement flags.
254-- Unit (unit) - The unit
255-- Flags (number) - The new movement flags
256-- returns (boolean) - True if it worked or some error if not.
257function SetMovementFlags (Unit, Flags)
258
259--- Send the player's movement state to the server.
260--- returns (boolean) - True if it worked, False if not. It will only fail if there's no player active.
261function SendMovementUpdate ()
262
263--- Get a unit's bounding radius.
264-- Unit (unit) - The unit
265-- returns (number) - The bounding radius
266function UnitBoundingRadius (Unit)
267
268--- Get a unit's combat reach.
269-- Unit (unit) - The unit
270-- returns (number) - The combat reach
271function UnitCombatReach (Unit)
272
273--- Get a unit's target.
274-- Unit (unit) - The unit
275-- returns (unit) - The target or nil if there is none
276function UnitTarget (Unit)
277
278--- Get an object's creator.
279-- Object (object) - The unit or game object
280-- returns (unit) - The creator or nil if there is none
281function ObjectCreator (Unit)
282UnitCreator = ObjectCreator
283
284--- Get whether a unit can be looted.
285-- Unit (unit) - The unit
286-- returns (boolean) - Whether the unit can be looted
287function UnitCanBeLooted (Unit)
288
289--- Get whether a unit can be skinned.
290-- Unit (unit) - The unit
291-- returns (boolean) - Whether the unit can be skinned
292function UnitCanBeSkinned (Unit)
293
294--- Set a unit's display ID.
295-- Unit (unit) - The unit
296-- DisplayID (integer) - The new display ID
297-- returns (boolean) - Whether the display was changed or not
298-- Note that UnitUpdateModel must be called for the change to be displayed.
299function UnitSetDisplayID (Unit, DisplayID)
300SetDisplayID = UnitSetDisplayID
301
302--- Update a unit's model.
303-- Unit (unit) - The unit
304function UnitUpdateModel (Unit)
305UpdateModel = UnitUpdateModel
306
307--- Get the spell IDs being casted or channelled by the unit
308-- Unit (unit) - The unit
309-- returns (number, number, object, object) - (Spell Cast ID, Spell Channel ID, Cast Object, Channel Object)
310-- Note: If no spells are being casted, it returns 0, 0, 0x00000000, 0x00000000. On certain WoW expansions,
311-- the Cast Object and Channel Object arent erased after cast. So you must always check if CastID and ChannelID arent 0.
312function UnitCastID (Unit)
313
314--- Get or set unit pitch.
315-- Unit (unit) - The unit
316-- newPitch (number) - The new pitch
317-- update (boolean) - Whether to immediately notify the server
318-- returns (number) - The unit pitch.
319-- Note: If setting the pitch, it doesnt return anything. Also, pitch returns 0 for other units which aren't the current active mover.
320function UnitPitch (Unit[, newPitch, update])
321
322------------------------- World ---------------------------
323
324HitFlags = {
325 M2Collision = 0x1,
326 M2Render = 0x2,
327 WMOCollision = 0x10,
328 WMORender = 0x20,
329 Terrain = 0x100,
330 WaterWalkableLiquid = 0x10000,
331 Liquid = 0x20000,
332 EntityCollision = 0x100000,
333};
334
335--- Perform a raycast between two positions.
336-- StartX (number) - The starting X coordinate
337-- StartY (number) - The starting Y coordinate
338-- StartZ (number) - The starting Z coordinate
339-- EndX (number) - The ending X coordinate
340-- EndY (number) - The ending Y coordinate
341-- EndZ (number) - The ending Z coordinate
342-- Flags (integer) - One or more members of the HitFlags table combined with bit.bor
343-- returns (number, number, number) - The X, Y, and Z coordinates of the hit position, or nil if there was no hit
344function TraceLine (StartX, StartY, StartZ, EndX, EndY, EndZ, Flags)
345
346--- Get the camera position.
347-- returns (number, number, number) - The X, Y, and Z coordinates of the camera
348function GetCameraPosition ()
349
350--- Cancel the pending spell if any.
351function CancelPendingSpell ()
352
353--- Simulate a click at a position in the game-world.
354-- X (number) - The X coordinate
355-- Y (number) - The Y coordinate
356-- Z (number) - The Z coordinate
357-- Right (boolean) - Whether to right click rather than left click
358function ClickPosition (X, Y, Z[, Right])
359CastAtPosition = ClickPosition
360
361--- Get whether an AoE spell is pending a target.
362-- returns (boolean) - Whether an AoE spell is pending a target
363function IsAoEPending ()
364
365--- Get the screen coordinates relative from World coordinates
366-- X (number) - The X coordinate.
367-- Y (number) - The Y coordinate.
368-- Z (number) - The Z coordinate.
369-- returns (number, number, boolean) - The X and Y screen coordinates for the XYZ coordinates and whether they are in front of the camera or not.
370function WorldToScreen (X, Y, Z) end
371
372--- Return whether the given coordinates are in front of WoW's camera
373-- X (number) - The X coordinate.
374-- Y (number) - The Y coordinate.
375-- Z (number) - The Z coordinate.
376-- returns (boolean) - Whether they are in front or not.
377function IsInFront (X, Y, Z) end
378
379------------------------- Hacks ---------------------------
380
381Hacks = {
382 Fly = "Fly",
383 Hover = "Hover",
384 Climb = "Climb",
385 MovingLoot = "MovingLoot",
386 WaterWalk = "WaterWalk",
387 M2Collision = "M2Collision",
388 WMOCollision = "WMOCollision",
389 TerrainCollision = "TerrainCollision",
390 Zoom = "Zoom",
391 AlwaysFacing = "AlwaysFacing",
392 NoAutoAway = "NoAutoAway",
393 NoSwim = "NoSwim",
394 MultiJump = "MultiJump",
395 CRZBlocking = "CRZBlocking",
396 M2Rendering = "M2Rendering",
397 WMORendering = "WMORendering",
398 TerrainRendering = "TerrainRendering",
399 LiquidRendering = "LiquidRendering",
400 CollisionRendering = "CollisionRendering",
401 MountainRendering = "MountainRendering",
402 DetailsRendering = "DetailsRendering",
403 Wireframe = "Wireframe",
404 Freeze = "Freeze",
405 MovingCast = "MovingCast",
406 GoClick = "GoClick",
407 UnlockLua = "UnlockLua",
408 SimpleUnlock = "SimpleUnlock"
409}
410
411--- Get whether a hack is enabled.
412-- Hack (Hacks member) - The hack
413-- returns (boolean) - Whether the hack is enabled
414function IsHackEnabled (Hack)
415
416--- Set whether a hack is enabled.
417-- Hack (Hacks member) - The hack
418-- Enable (boolean) - Whether the hack is to be enabled
419function SetHackEnabled (Hack, Enable)
420SetOptionEnabled = SetHackEnabled
421
422------------------------- File ----------------------------
423
424--- Get the names of the files in a directory.
425-- Path (string) - The path to the files
426-- returns (table) - The file names
427-- Example: "C:\*" would retrieve the names of all of the files in C:\.
428-- Example: "C:\*.dll" would retrieve the names of all of the .dll files in C:\.
429function GetDirectoryFiles (Path)
430
431--- Get the names of the directories in a directory.
432-- Path (string) - The path to the directories
433-- returns (table) - The directory names
434-- Example: "C:\*" would retrieve the names of all of the directories in C:\.
435-- Example: "C:\Program Files*" would retrieve the names of the program files directories in C:\.
436function GetSubdirectories (Path)
437
438--- Get the contents of a text file.
439-- Path (string) - The file path
440-- returns (string) - The file contents
441function ReadFile (Path)
442
443--- Set the contents of or append a text file.
444-- Path (string) - The file path
445-- String (string) - The string to write
446-- Append (boolean) - Whether to append rather than overwrite
447function WriteFile (Path, Contents[, Append])
448
449--- Get the directory that the hack is in.
450-- @return The directory that the hack is in.
451function GetHackDirectory () end
452GetFireHackDirectory = GetHackDirectory
453
454--- Get the directory that WoW is in.
455-- returns (string) - The directory that WoW is in
456function GetWoWDirectory ()
457
458------------------------- Scripts -------------------------
459
460--- Load a script from the Scripts folder.
461-- FileName (string) - The script file name
462-- returns - The return values of the script if any
463function LoadScript (FileName)
464
465--- Get the file name of the currently executing script.
466-- returns (string) - The file name of the currently executing script
467-- Note that this can only be called from within a script.
468function GetScriptName ()
469
470------------------------- Callbacks -------------------------
471
472--- Adds a Lua callback for a sent or received game packet (not a socket packet).
473-- mode (string) - "send" or "recv" to listen to sent/received packets
474-- opcode (number) - The opcode that you want to listen. -1 listens everything.
475-- callback (function) - Your Lua callback
476-- returns string (ID of packet callback which is used by RemovePacketCallback)
477-- Example for 3.3.5 using CMSG_MOVE_JUMP: /script AddPacketCallback("send", 0xBB, function(data) print(data) end)
478-- Note: Packet callbacks persist through Lua reloads so if you lose the ID, you can't remove the filter.
479function AddPacketCallback(mode, opcode, callback)
480
481-- Removes a Lua callback added by AddPacketCallback
482-- id (string) - The string returned by AddPacketCallback
483-- returns true on success, false if the callback wasn't found.
484function RemovePacketCallback(id)
485
486
487-- Add a callback to a Lua table that is called every frame, i.e., every "OnUpdate" WoW frame event.
488-- Callback (function) - The callback
489function AddFrameCallback (Callback)
490
491--- Add a timer callback.
492-- Interval (number) - The number of seconds between calls
493-- Callback (function) - The callback
494function AddTimerCallback (Interval, Callback)
495
496--- Add a WoW event callback, i.e., a function that is called on "OnEvent" frame event.
497-- Event (string) - The event name
498-- Callback (function) - The callback
499-- Note that the callback is called with the event arguments.
500function AddEventCallback (Event, Callback)
501
502------------------------- Miscellaneous -------------------
503
504Types = {
505 Bool = "bool",
506 Char = "char",
507 Byte = "byte",
508 SByte = "char",
509 UByte = "byte",
510 Short = "short",
511 SShort = "short",
512 UShort = "ushort",
513 Int = "int",
514 SInt = "int",
515 UInt = "uint",
516 Long = "long",
517 SLong = "long",
518 ULong = "ulong",
519 Float = "float",
520 Double = "double",
521 String = "string",
522 GUID = "guid",
523};
524
525--- Open a URL in the default handler for the scheme.
526-- URL (string) - The URL
527function OpenURL (URL)
528
529--- Download data from a URL using an HTTP GET request.
530-- Host (string) - The host.
531-- URL (string) - The rest of the URL.
532-- Secure (boolean) - Whether to use HTTPS.
533-- OnComplete (function) - A function that is called with the data when the request completes.
534-- OnError (function) - A function that is called with the error message if an error occurs.
535function DownloadURL (Host, URL, Secure, OnComplete, OnError) end
536
537--- Send an HTTP or HTTPS request.
538-- URL (string) - The URL to send to
539-- PostData (string) - The post data if any (nil to use a GET request)
540-- OnComplete (function) - The function to be called with the response if the request succeeds
541-- OnError (function) - The function to be called with the error message if the request fails
542function SendHTTPRequest (URL, PostData, OnComplete, OnError)
543
544--- Get a session variable.
545-- Name (string) - The variable name
546-- returns (string) - The value
547function GetSessionVariable (Name)
548
549--- Set a session variable.
550-- Name (string) - The variable name
551-- Value (string) - The new value
552function SetSessionVariable (Name)
553
554--- Get whether the game client is the foreground window.
555-- returns (boolean) - Whether the game client is the foreground window
556function IsForeground ()
557
558--- Get the state of a key.
559-- Key (integer) - The virtual key code
560-- returns (boolean, boolean) - Whether the key is down and whether the key is toggled
561-- Virtual Key Codes: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
562function GetKeyState (Key)
563
564--- Get an offset used by EWT
565-- Name (string) - The offset name
566-- returns (number) - The offset value if found
567-- Example: GetOffset("FrameScript_RegisterFunction") or GetOffset("CGGameObject_C__Animation") for Fishing bobber animation
568function GetOffset (Name)
569
570--- Get a WoW descriptor. This i
571-- Group (string) - The group that the descriptor belongs
572-- Name (string) - The descriptor name
573-- returns (number) - The offset value if found
574-- Example: GetDescriptor("CGObjectData", "Scale") or GetDescriptor("CGPlayerData", "PlayerTitle")
575-- Notes: Descriptor name follows an upper camel case convention, like UpperCamelCase.
576-- For a list of WoW descriptors, check Ownedcore's Info Dump Threads in the Memory Editing Section
577function GetDescriptor (Group, Name)
578 return GetOffset(Group .. '__' .. Name)
579end
580
581--- Create a Timer (useful for WoW versions below Warlords which don't have the C_Timer API)
582-- Duration (number) - The interval in milliseconds of the timer
583-- Callback (function) - The function to be called when the interval ends
584-- NumRuns (number) - Default: 0 (Repeats infinitely). Number of times the callback must be called.
585-- returns (number) - ID of the timer. Returns nil if error.
586-- Example: local timerId = CreateTimer(200, function() print('Test') end)
587-- Note: Timers persist through Lua reloads so if you lose the ID, you can't stop it.
588-- Note: If the Timer already executed all NumRuns, you don't need to call StopTimer.
589function CreateTimer (Duration, Callback[, NumRuns])
590
591--- Stop a Timer created by CreateTimer
592-- TimerID (number) - The ID of the Timer
593-- returns (boolean) - True if it stopped or error if the timer wasn't found
594-- Notes: Upon calling this function, the Timer is completely destroyed and you must call CreateTimer again.
595-- Example: StopTimer(timerId)
596function StopTimer (TimerID)
597
598--- Sends a key to WoW's window
599-- Key (number or string) - The key to be sent
600-- Release (boolean) - Whether the key should be released. Default: true
601-- Example: SendKey('2') or SendKey(0x32) or SendKey(50) - Keep in mind the keys are in ASCII
602function SendKey (Key[, Release])
603
604--- Unloads EWT
605function UnloadEWT()
606
607
608--------------- DirectX Drawing Functions -------
609
610--- Draws a DirectX line
611-- startX (number) - The X coordinate of the line start
612-- startY (number) - The Y coordinate of the line start
613-- endX (number) - The X coordinate of the line end
614-- endY (number) - The Y coordinate of the line end
615-- width (number) - The width of the line
616-- return (boolean) - true if it worked, false if not
617function Draw2DLine(startX, startY, endX, endY[, width = 1.0f])
618
619--- Draws a DirectX line
620-- Object (object) - The origin object (start of line)
621-- Target (object) - The target object (end of line)
622-- width (number) - The width of the line
623-- return (boolean) - true if it worked, false if not
624function Draw2DLine(Object, Target[, width = 1.0f])
625
626--- Sets the global RGBA color for the next rendering. No need to call this all the time if you
627--- don't change the color often.
628-- red (number) - The Red component
629-- green (number) - The Green component
630-- blue (number) - The Blue component
631-- alpha (number) - The Alpha component
632function SetDrawColor(red, green, blue[, alpha = 1.0f])
633
634--- Draws a DirectX text
635-- textX (number) - The X coordinate of the text
636-- textY (number) - The Y coordinate of the text
637-- text (number) - The Blue component
638function Draw2DText(textX, textY, text)
639
640-- Example of how to draw a line to your target
641local f = CreateFrame("Frame")
642f:SetScript("OnUpdate", function (self, event, addon)
643 Draw2DLine("player", "target")
644end)
645
646-- Example of how to draw Tracker Projections and Text using the APIs above:
647local OBJECTTRACKER = {}
648local f = CreateFrame("Frame")
649f:SetScript("OnUpdate", function (self, event, addon)
650 local sWidth, sHeight = GetScreenWidth(), GetScreenHeight()
651 SetDrawColor(1, 1, 1, 1) -- white
652 Draw2DText(sWidth * 0.5, sHeight * 0.5, 'THIS IS A TEST')
653 local totalObjects = ObjectCount()
654 for i = 1, totalObjects do
655 local object = ObjectWithIndex(i)
656 OBJECTTRACKER[object] = CanTrackObject(object)
657 end
658 local playerX, playerY, playerZ = ObjectPosition("player")
659 local camX, camY, camZ = GetCameraPosition()
660 for i,v in pairs(OBJECTTRACKER) do
661 if v then -- Bool: if the object can be tracked or not
662 local targetX, targetY, targetZ = ObjectPosition(i)
663 if targetX and targetY and targetZ then
664 local arg1 = GetDistanceBetweenPositions(playerX, playerY, playerZ, targetX, targetY, targetZ)
665 local arg2 = GetDistanceBetweenPositions(camX, camY, camZ, targetX, targetY, targetZ)
666 if arg1 <= arg2 then
667 if ObjectIsType(i, ObjectTypes.Unit) then
668 local reaction = UnitReaction("player", i)
669 if reaction then
670 if reaction > 4 then
671 if UnitIsPlayer(i) then
672 SetDrawColor(0, 0, 1, 1) -- blue
673 else
674 SetDrawColor(0, 1, 0, 1) -- green
675 end
676 elseif reaction == 4 then
677 SetDrawColor(1, 1, 0, 1) -- yellow
678 elseif reaction < 4 then
679 SetDrawColor(1, 0, 0, 1) -- red
680 end
681 else
682 SetDrawColor(1, 1, 1, 1) -- white
683 end
684 else
685 SetDrawColor(1, 1, 1, 1) -- white
686 end
687 local player2DX, player2DY = WorldToScreen_Original(playerX, playerY, playerZ)
688 local target2DX, target2DY = WorldToScreen_Original(targetX, targetY, targetZ)
689 Draw2DLine(player2DX * sWidth, player2DY * sHeight, target2DX * sWidth, target2DY * sHeight)
690 end
691 end
692 end
693 end
694
695end)