Advertisement
Guest User

Untitled

a guest
Mar 7th, 2019
1,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.40 KB | None | 0 0
  1. ------------------------- Active Player -------------------
  2.  
  3. --- Stop falling.
  4. function StopFalling () end
  5.  
  6. --- Move to a position.
  7. -- X (number) - The X coordinate
  8. -- Y (number) - The Y coordinate
  9. -- Z (number) - The Z coordinate
  10. -- InstantTurn (boolean) - Whether to instantly turn toward the destination
  11. function MoveTo (X, Y, Z[, InstantTurn])
  12.  
  13. --- Teleport to a position.
  14. -- X (number) - The X coordinate
  15. -- Y (number) - The Y coordinate
  16. -- Z (number) - The Z coordinate
  17. function Teleport (X, Y, Z)
  18.  
  19. --- Registers Lua callbacks for Teleport
  20. -- before (function) - A callback that is called before EWT teleports your character.
  21. -- after (function) - A callback that is called after EWT teleports your character.
  22. function AddTeleportCallbacks(before, after)
  23. -- Example:
  24. function myTeleportFunc()
  25. AddTeleportCallbacks(
  26. function()
  27. local beforeX, beforeY, beforeZ = ObjectPosition("player")
  28. print('Teleported from ' .. beforeX .. ' ' .. beforeY .. ' ' .. beforeZ)
  29. end,
  30. function()
  31. local x, y, z = ObjectPosition("player")
  32. print('to x ' .. x .. ' ' .. y .. ' ' .. z)
  33. end
  34. )
  35. end
  36.  
  37. --- Set the direction that the player is facing (angle in XY).
  38. -- Direction (number) or Object (string) - The direction in radians or the object
  39. -- Update (boolean) - Whether to immediately notify the server
  40. function FaceDirection (Direction[, Update])
  41.  
  42. --- Set the maximum angle from the XY plane that the player can move at
  43. -- Angle (number) - The maximum angle in degrees
  44. -- Note that the angle must be between 0º and 90º.
  45. function SetMaximumClimbAngle (Angle)
  46.  
  47. ------------------------- Object --------------------------
  48.  
  49. if EWT.is80 then
  50. ObjectType = {
  51. Object = 0,
  52. Item = 1,
  53. Container = 2,
  54. AzeriteEmpoweredItem = 3,
  55. AzeriteItem = 4,
  56. Unit = 5,
  57. Player = 6,
  58. ActivePlayer = 7,
  59. GameObject = 8,
  60. DynamicObject = 9,
  61. Corpse = 10,
  62. AreaTrigger = 11,
  63. SceneObject = 12,
  64. ConversationData = 13
  65. };
  66. else
  67. ObjectType = {
  68. Object = 0,
  69. Item = 1,
  70. Container = 2,
  71. Unit = 3,
  72. Player = 4,
  73. GameObject = 5,
  74. DynamicObject = 6,
  75. Corpse = 7,
  76. AreaTrigger = 8,
  77. SceneObject = 9,
  78. ConversationData = 10
  79. };
  80. end
  81.  
  82. -- Don't use this for BFA
  83. ObjectTypes = {
  84. None = 0,
  85. Object = 1,
  86. Item = 2,
  87. Container = 4,
  88. Unit = 8,
  89. Player = 16,
  90. GameObject = 32,
  91. DynamicObject = 64,
  92. Corpse = 128,
  93. AreaTrigger = 256,
  94. SceneObject = 512,
  95. All = -1
  96. };
  97.  
  98. --- Get an object's pointer.
  99. -- Object (object) - The object
  100. -- returns (string or nil) - The pointer as a hexadecimal string prefixed by 0x or nil if the object does not exist.
  101. -- Note: If the object doesn't exist, for example, ObjectPointer('party1target'), it returns nil.
  102. -- This API is mainly useful to get the object address of unitIDs like 'target', 'mouseover', etc.
  103. -- ObjectPointer('0xDEADBEEF') simply returns '0xDEADBEEF' and does NOT check if the address is in the object manager. Don't do this.
  104. function ObjectPointer (Object)
  105.  
  106. --- Get whether an object exists in the object manager.
  107. -- Object (object) - The object
  108. -- returns (string or nil) - The pointer as a hexadecimal string prefixed by 0x or nil if the object does not exist.
  109. -- Note that if the object does not exist in the object manager it is invalid and should not be used.
  110. -- This API is only useful to check if '0x' strings are *really* valid. In my opinion, it should never be used
  111. -- if you are properly using GetObjectCount since you will always work with objects that exist.
  112. -- This API is similar to ObjectPointer, but it checks if the object exists in the object manager.
  113. -- If you pass a unitID, like ObjectExists('target'), then its performance is the same as ObjectPointer('target').
  114. -- This API works like UnitIsVisible, but instead of returning boolean, it returns string or nil.
  115. function ObjectExists (Object)
  116.  
  117. --- Get an object's position.
  118. -- Object (object) - The object
  119. -- returns (number, number, number) - The X, Y, and Z coordinates
  120. -- Note: If the object doesn't exist, it returns (nil, nil, nil)
  121. function ObjectPosition (Object)
  122.  
  123. --- Get an object's facing.
  124. -- Object (object) - The object
  125. -- returns (number or nil) - The facing (angle in XY) in radians
  126. -- Note: If the object doesn't exist, it returns nil.
  127. function ObjectFacing (Object)
  128. GetObjectFacing = ObjectFacing
  129.  
  130. --- Get an object's GUID.
  131. -- Object (object) - The object
  132. -- returns (string or nil) - The GUID as a string or nil if the object doesn't exist.
  133. -- Note: This API is mainly for WoW Classic 1.12.1, because UnitGUID doesn't exist in this version.
  134. function ObjectGUID (Object)
  135.  
  136. --- Get an object's name.
  137. -- Object (object) - The object
  138. -- returns (string) - The name
  139. function ObjectName (Object)
  140.  
  141. --- Get an object's type ID.
  142. -- Object (object) - The object
  143. -- returns (integer) - The type ID or nil if there is none
  144. function ObjectID (Object)
  145.  
  146. --- Get whether an object is of a type.
  147. -- Object (object) - The object
  148. -- Type (ObjectTypes member) - The type
  149. -- returns (boolean) - Whether the object is of the type
  150. -- Note: Don't use this for BFA. Use ObjectRawType instead.
  151. function ObjectIsType (Object, Type)
  152.  
  153. --- Get an object's type flags.
  154. -- Object (object) - The object
  155. -- returns (integer) - One or more members of the ObjectTypes table combined with bit.bor
  156. -- Note: Don't use this for BFA. Use ObjectRawType instead.
  157. function ObjectTypeFlags (Object)
  158.  
  159. --- Get an object's type.
  160. -- Object (object) - The object
  161. -- returns (integer) - One member of the ObjectType table.
  162. function ObjectRawType (Object)
  163.  
  164. function ObjectIsPlayer(object)
  165. local type = ObjectRawType(object)
  166. return type == ObjectType.Player or type == ObjectType.ActivePlayer
  167. end
  168.  
  169. function ObjectIsUnit(object)
  170. local type = ObjectRawType(object)
  171. return type == ObjectType.Unit or type == ObjectType.Player or type == ObjectType.ActivePlayer
  172. end
  173.  
  174. function ObjectIsGameObject(object)
  175. return ObjectRawType(object) == ObjectType.GameObject
  176. end
  177.  
  178. function ObjectIsAreaTrigger(object)
  179. return ObjectRawType(object) == ObjectType.AreaTrigger
  180. end
  181.  
  182. function GetDistanceBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
  183. return math.sqrt(math.pow(X2 - X1, 2) + math.pow(Y2 - Y1, 2) + math.pow(Z2 - Z1, 2));
  184. end
  185.  
  186. --- Get the distance between two objects.
  187. -- Object1 (object) - The first object
  188. -- Object2 (object) - The second object
  189. -- returns (number) - The distance
  190. function GetDistanceBetweenObjects (Object1, Object2)
  191.  
  192. --- Get the angles between two objects.
  193. -- Object1 (object) - The first object
  194. -- Object2 (object) - The second object
  195. -- returns (number, number) - The facing (angle in XY) and pitch (angle from XY) from the first object to the second
  196. function GetAnglesBetweenObjects (Object1, Object2)
  197.  
  198. --- Get the position that is between two objects and a specified distance from the first object.
  199. -- Object1 (object) - The first object
  200. -- Object2 (object) - The second object
  201. -- Distance (number) - The distance from the first object
  202. -- returns (number, number, number) - The X, Y, and Z coordinates
  203. function GetPositionBetweenObjects (Object1, Object2, Distance)
  204.  
  205. function GetPositionFromPosition (X, Y, Z, Distance, AngleXY, AngleXYZ)
  206. return math.cos(AngleXY) * Distance + X,
  207. math.sin(AngleXY) * Distance + Y,
  208. math.sin(AngleXYZ) * Distance + Z;
  209. end
  210.  
  211. function GetAnglesBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
  212. return math.atan2(Y2 - Y1, X2 - X1) % (math.pi * 2),
  213. math.atan((Z1 - Z2) / math.sqrt(math.pow(X1 - X2, 2) + math.pow(Y1 - Y2, 2))) % math.pi;
  214. end
  215.  
  216. function GetPositionBetweenPositions (X1, Y1, Z1, X2, Y2, Z2, DistanceFromPosition1)
  217. local AngleXY, AngleXYZ = GetAnglesBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
  218. return GetPositionFromPosition(X1, Y1, Z1, DistanceFromPosition1, AngleXY, AngleXYZ);
  219. end
  220.  
  221. --- Get whether an object is facing another.
  222. -- Object1 (object) - The first object
  223. -- Object2 (object) - The second object
  224. -- returns (boolean) - Whether the first object is facing the second
  225. function ObjectIsFacing (Object1, Object2)
  226.  
  227. --- Get whether an object is behind another.
  228. -- Object1 (object) - The first object
  229. -- Object2 (object) - The second object
  230. -- returns (boolean) - Whether the first object is behind the second
  231. function ObjectIsBehind (Object1, Object2)
  232.  
  233. --- Get one of an object's descriptors.
  234. -- Object (object) - The object
  235. -- Offset (integer) - The descriptor offset
  236. -- Type (Type member) - The descriptor type
  237. -- returns (Type) - The descriptor value
  238. function ObjectDescriptor (Object, Offset, Type)
  239.  
  240. --- Get one of an object's fields.
  241. -- Object (object) - The object
  242. -- Offset (integer) - The field offset
  243. -- Type (Type member) - The field type
  244. -- returns (Type) - The field value
  245. function ObjectField (Object, Offset, Type)
  246.  
  247. --- Interact with Object. Useful for 1.12.1 and 2.4.3 since InteractUnit isn't available in these versions.
  248. -- Object (object) - The object
  249. -- returns (boolean) - True if the object is valid, False if not
  250. function ObjectInteract (Object)
  251.  
  252. ------------------------- Object Manager ------------------
  253.  
  254. --- Get the number of objects in the object manager and optionally 2 tables with all objects that were updated in the frame.
  255. -- GetUpdates (boolean) - True to get the tables with the objects that were updated in the frame.
  256. -- returns (integer, boolean, table, table) - The total number of objects, if the object manager was updated, the added objects and the removed objects.
  257. -- Note: This should be the first API that you should call before using the other object manager functions.
  258. -- Ideally, call it once every frame with an OnUpdate frame event.
  259. -- You can use table.getn or # to get the number of objects in the returned tables.
  260. function GetObjectCount ([GetUpdates])
  261. ObjectCount = GetObjectCount
  262.  
  263. -- Example:
  264. local initOM = true
  265. local myOM = {}
  266. local myFrame = CreateFrame("Frame")
  267. myFrame:SetScript("OnUpdate", function ()
  268. -- The first frame call to GetObjectCount(true) should have total == #added and 'added' will contain all objects.
  269. -- The next GetObjectCount(true) calls should have only the updated objects.
  270. local total, updated, added, removed = GetObjectCount(true)
  271. if initOM then
  272. initOM = false
  273. for i = 1,total do
  274. local thisUnit = GetObjectWithIndex(i) -- thisUnit contains the '0x' string representing the object address
  275. -- Do something with the unit
  276. myOM[thisUnit] = 1
  277. end
  278. end
  279. for k,v in pairs(added) do
  280. -- k - Number = Array index = Don't confuse this with the Object Index used by GetObjectWithIndex. It's not the same thing.
  281. -- v - String = Object address
  282. print('Added ' .. v)
  283. myOM[v] = 1
  284. if ObjectIsUnit(v) then
  285. local posX, posY, posZ = ObjectPosition(v)
  286. end
  287. end
  288. for k,v in pairs(removed) do
  289. print('Removed ' .. v)
  290. myOM[v] = nil
  291. end
  292. local manualCount = 0
  293. for k,v in pairs(myOM) do
  294. manualCount = manualCount + 1
  295. end
  296. if #added ~= 0 or #removed ~= 0 then
  297. print('Total ' .. total .. ' ' .. #added .. ' ' .. #removed .. ' Manual ' .. manualCount)
  298. end
  299. end);
  300.  
  301. --- Get an object in the object manager from its index.
  302. -- Index (integer) - The one-based index of the object. Starts at 1.
  303. -- returns (object) - The object
  304. -- Note: If an object is at index 30, this does NOT mean that in the next frame it will be at index 30 again.
  305. -- This API isn't really needed if you are properly using GetObjectCount(true).
  306. function GetObjectWithIndex (Index)
  307. ObjectWithIndex = GetObjectWithIndex
  308.  
  309. --- Get the number of units in the object manager and optionally 2 tables with all units that were updated in the frame.
  310. -- returns (integer, boolean, table, table) - The total number of units, if the unit manager was updated, the added units and the removed units.
  311. -- Note: It works like GetObjectCount, but for units, which consist on Units, Players and ActivePlayers.
  312. function GetUnitCount ([GetUpdates])
  313.  
  314. --- Get a unit in the Unit Manager from its index. Unit Manager is a separate table inside the Object manager.
  315. -- Index (integer) - The one-based index of the object. Starts at 1.
  316. -- returns (object) - The unit
  317. -- Note: The index used must be <= GetUnitCount(). This index is NOT the same index used in GetObjectWithIndex.
  318. function GetUnitWithIndex (Index)
  319.  
  320. --- Get an object in the object manager from its pointer.
  321. -- Pointer (string) - A pointer to the object as a hexadecimal string prefixed by 0x
  322. -- returns (object) - The object
  323. -- Note: Avoid using this API. Prefer GetObjectWithIndex instead. It's here only because of backwards compatibility.
  324. function GetObjectWithPointer (Pointer)
  325.  
  326. --- Get an object in the object manager from its GUID.
  327. -- GUID (string) - The GUID
  328. -- returns (object) - The object or nil if it is not in the object manager
  329. function GetObjectWithGUID (GUID)
  330.  
  331. --- Gets the active player.
  332. -- returns (object or nil) - The active player object or nil if it does not exist.
  333. function GetActivePlayer ()
  334.  
  335. --- Gets the active mover.
  336. -- returns (object or nil) - The active mover object or nil if it does not exist.
  337. -- Note: This is usually the Active Player. When you get mind controlled, lose control of your character or control
  338. -- something else, then the Active Mover is different.
  339. function GetActiveMover ()
  340.  
  341. ------------------------- Unit ----------------------------
  342.  
  343. --- Get an object's facing direction.
  344. -- @param Object The object. It must be of type Unit.
  345. -- @param Object The object.
  346. -- @param Angle The frontal cone angle in degrees. Default: 180 degrees
  347. -- @return Boolean. Whether it is facing or not.
  348. function UnitIsFacing (Object, Object[, Angle]) end
  349.  
  350. MovementFlags = {
  351. Forward = 0x1,
  352. Backward = 0x2,
  353. StrafeLeft = 0x4,
  354. StrafeRight = 0x8,
  355. TurnLeft = 0x10,
  356. TurnRight = 0x20,
  357. PitchUp = 0x40,
  358. PitchDown = 0x80,
  359. Walking = 0x100,
  360. Immobilized = 0x400,
  361. Falling = 0x800,
  362. FallingFar = 0x1000,
  363. Swimming = 0x100000,
  364. Ascending = 0x200000,
  365. Descending = 0x400000,
  366. CanFly = 0x800000,
  367. Flying = 0x1000000,
  368. };
  369.  
  370. --- Get the unit's movement address.
  371. -- Unit (unit) - The unit
  372. -- returns (integer) - The movement struct address
  373. -- Note: If the object is not a unit, then it returns nil.
  374. function GetUnitMovement (Unit)
  375.  
  376. --- Get the unit's speed.
  377. -- Unit (unit) - The unit
  378. -- returns (number) - currentSpeed, groundSpeed, flightSpeed, swimSpeed
  379. -- Note: If the object is not a unit, then it returns nil.
  380. -- This API is only available on 1.12.1 and 2.4.3.
  381. function GetUnitSpeed (Unit)
  382.  
  383. --- Get a unit's movement flags.
  384. -- Unit (unit) - The unit
  385. -- returns (integer) - The movement flags
  386. function UnitMovementFlags (Unit)
  387.  
  388. --- Set a unit's movement flags.
  389. -- Unit (unit) - The unit
  390. -- Flags (number) - The new movement flags
  391. -- returns (boolean) - True if it worked or some error if not.
  392. function SetMovementFlags (Unit, Flags)
  393.  
  394. --- Send the player's movement state to the server.
  395. --- returns (boolean) - True if it worked, False if not. It will only fail if there's no player active.
  396. function SendMovementUpdate ()
  397.  
  398. --- Get a unit's bounding radius.
  399. -- Unit (unit) - The unit
  400. -- returns (number) - The bounding radius
  401. function UnitBoundingRadius (Unit)
  402.  
  403. --- Get a unit's combat reach.
  404. -- Unit (unit) - The unit
  405. -- returns (number) - The combat reach
  406. function UnitCombatReach (Unit)
  407.  
  408. --- Get a unit's target.
  409. -- Unit (unit) - The unit
  410. -- returns (unit) - The target or nil if there is none
  411. function UnitTarget (Unit)
  412.  
  413. --- Get an object's creator.
  414. -- Object (object) - The unit or game object
  415. -- returns (unit) - The creator or nil if there is none
  416. function ObjectCreator (Unit)
  417. UnitCreator = ObjectCreator
  418.  
  419. --- Get whether a unit can be looted.
  420. -- Unit (unit) - The unit
  421. -- returns (boolean) - Whether the unit can be looted
  422. function UnitCanBeLooted (Unit)
  423.  
  424. --- Get whether a unit can be skinned.
  425. -- Unit (unit) - The unit
  426. -- returns (boolean) - Whether the unit can be skinned
  427. function UnitCanBeSkinned (Unit)
  428.  
  429. --- Set a unit's display ID.
  430. -- Unit (unit) - The unit
  431. -- DisplayID (integer) - The new display ID
  432. -- returns (boolean) - Whether the display was changed or not
  433. -- Note that UnitUpdateModel must be called for the change to be displayed.
  434. function UnitSetDisplayID (Unit, DisplayID)
  435. SetDisplayID = UnitSetDisplayID
  436.  
  437. -- Sets the unit's mount display ID
  438. function SetMountDisplayID(Unit, DisplayID)
  439.  
  440. -- Set's the unit's item display ID
  441. function SetVisibleItem(Unit, SlotID, ItemID [, ItemAppearanceModID])
  442.  
  443. -- Set's the unit's item enchant ID
  444. function SetVisibleEnchant(Unit, SlotID, EnchantID)
  445.  
  446. --- Update a unit's model.
  447. -- Unit (unit) - The unit
  448. function UnitUpdateModel (Unit)
  449. UpdateModel = UnitUpdateModel
  450.  
  451. --- Get the spell IDs being casted or channelled by the unit
  452. -- Unit (unit) - The unit
  453. -- returns (number, number, object, object) - (Spell Cast ID, Spell Channel ID, Cast Object, Channel Object)
  454. -- Note: If no spells are being casted, it returns 0, 0, nil, nil.
  455. -- On certain WoW expansions, the Cast Object and Channel Object arent erased after cast. So you must always check if CastID and ChannelID arent 0.
  456. function UnitCastID (Unit)
  457.  
  458. --- Get or set unit pitch.
  459. -- Unit (unit) - The unit
  460. -- newPitch (number) - The new pitch
  461. -- update (boolean) - Whether to immediately notify the server
  462. -- returns (number) - The unit pitch.
  463. -- Note: If setting the pitch, it doesnt return anything. Also, pitch returns 0 for other units which aren't the current active mover.
  464. function UnitPitch (Unit[, newPitch, update])
  465.  
  466. ------------------------- World ---------------------------
  467.  
  468. HitFlags = {
  469. M2Collision = 0x1,
  470. M2Render = 0x2,
  471. WMOCollision = 0x10,
  472. WMORender = 0x20,
  473. Terrain = 0x100,
  474. WaterWalkableLiquid = 0x10000,
  475. Liquid = 0x20000,
  476. EntityCollision = 0x100000,
  477. };
  478.  
  479. --- Perform a raycast between two positions.
  480. -- StartX (number) - The starting X coordinate
  481. -- StartY (number) - The starting Y coordinate
  482. -- StartZ (number) - The starting Z coordinate
  483. -- EndX (number) - The ending X coordinate
  484. -- EndY (number) - The ending Y coordinate
  485. -- EndZ (number) - The ending Z coordinate
  486. -- Flags (integer) - One or more members of the HitFlags table combined with bit.bor
  487. -- returns (number, number, number) - The X, Y, and Z coordinates of the hit position, or nil if there was no hit
  488. -- Note: Be careful with how often you call this API because your FPS can drop a lot.
  489. function TraceLine (StartX, StartY, StartZ, EndX, EndY, EndZ, Flags)
  490.  
  491. --- Get the camera position.
  492. -- returns (number, number, number) - The X, Y, and Z coordinates of the camera
  493. function GetCameraPosition ()
  494.  
  495. --- Cancel the pending spell if any.
  496. function CancelPendingSpell ()
  497.  
  498. --- Simulate a click at a position in the game-world.
  499. -- X (number) - The X coordinate
  500. -- Y (number) - The Y coordinate
  501. -- Z (number) - The Z coordinate
  502. -- Right (boolean) - Whether to right click rather than left click
  503. function ClickPosition (X, Y, Z[, Right])
  504. CastAtPosition = ClickPosition
  505.  
  506. --- Get whether an AoE spell is pending a target.
  507. -- returns (boolean) - Whether an AoE spell is pending a target
  508. function IsAoEPending ()
  509.  
  510. --- Get the screen coordinates relative from World coordinates
  511. -- X (number) - The X coordinate.
  512. -- Y (number) - The Y coordinate.
  513. -- Z (number) - The Z coordinate.
  514. -- returns (number, number, boolean) - The X and Y screen coordinates for the XYZ coordinates and
  515. -- whether they are in front of the camera or not.
  516. function WorldToScreen (X, Y, Z) end
  517.  
  518. --- Return whether the given coordinates are in front of WoW's camera
  519. -- X (number) - The X coordinate.
  520. -- Y (number) - The Y coordinate.
  521. -- Z (number) - The Z coordinate.
  522. -- returns (boolean) - Whether they are in front or not.
  523. function IsInFront (X, Y, Z) end
  524.  
  525. ------------------------- Hacks ---------------------------
  526.  
  527. Hacks = {
  528. Fly = "Fly",
  529. Hover = "Hover",
  530. Climb = "Climb",
  531. MovingLoot = "MovingLoot",
  532. WaterWalk = "WaterWalk",
  533. M2Collision = "M2Collision",
  534. WMOCollision = "WMOCollision",
  535. TerrainCollision = "TerrainCollision",
  536. Zoom = "Zoom",
  537. AlwaysFacing = "AlwaysFacing",
  538. NoAutoAway = "NoAutoAway",
  539. NoSwim = "NoSwim",
  540. MultiJump = "MultiJump",
  541. CRZBlocking = "CRZBlocking",
  542. M2Rendering = "M2Rendering",
  543. WMORendering = "WMORendering",
  544. TerrainRendering = "TerrainRendering",
  545. LiquidRendering = "LiquidRendering",
  546. CollisionRendering = "CollisionRendering",
  547. MountainRendering = "MountainRendering",
  548. DetailsRendering = "DetailsRendering",
  549. Wireframe = "Wireframe",
  550. Freeze = "Freeze",
  551. MovingCast = "MovingCast",
  552. GoClick = "GoClick",
  553. UnlockLua = "UnlockLua",
  554. SimpleUnlock = "SimpleUnlock"
  555. }
  556.  
  557. --- Get whether a hack is enabled.
  558. -- Hack (Hacks member) - The hack
  559. -- returns (boolean) - Whether the hack is enabled
  560. function IsHackEnabled (Hack)
  561.  
  562. --- Set whether a hack is enabled.
  563. -- Hack (Hacks member) - The hack
  564. -- Enable (boolean) - Whether the hack is to be enabled
  565. function SetHackEnabled (Hack, Enable)
  566. SetOptionEnabled = SetHackEnabled
  567.  
  568. ------------------------- File ----------------------------
  569.  
  570. --- Get the names of the files in a directory.
  571. -- Path (string) - The path to the files
  572. -- returns (table) - The file names
  573. -- Example: "C:\*" would retrieve the names of all of the files in C:\.
  574. -- Example: "C:\*.dll" would retrieve the names of all of the .dll files in C:\.
  575. function GetDirectoryFiles (Path)
  576.  
  577. --- Get the names of the directories in a directory.
  578. -- Path (string) - The path to the directories
  579. -- returns (table) - The directory names
  580. -- Example: "C:\*" would retrieve the names of all of the directories in C:\.
  581. -- Example: "C:\Program Files*" would retrieve the names of the program files directories in C:\.
  582. function GetSubdirectories (Path)
  583.  
  584. --- Get the contents of a text file.
  585. -- Path (string) - The file path
  586. -- returns (string) - The file contents
  587. function ReadFile (Path)
  588.  
  589. --- Set the contents of or append a text file.
  590. -- Path (string) - The file path
  591. -- String (string) - The string to write
  592. -- Append (boolean) - Whether to append rather than overwrite
  593. function WriteFile (Path, Contents[, Append])
  594.  
  595. --- Get the directory that the hack is in.
  596. -- @return The directory that the hack is in.
  597. function GetHackDirectory () end
  598. GetFireHackDirectory = GetHackDirectory
  599.  
  600. --- Get the directory that WoW is in.
  601. -- returns (string) - The directory that WoW is in
  602. function GetWoWDirectory ()
  603.  
  604. ------------------------- Scripts -------------------------
  605.  
  606. --- Load a script from the Scripts folder.
  607. -- FileName (string) - The script file name
  608. -- returns - The return values of the script if any
  609. function LoadScript (FileName)
  610.  
  611. --- Get the file name of the currently executing script.
  612. -- returns (string) - The file name of the currently executing script
  613. -- Note that this can only be called from within a script.
  614. function GetScriptName ()
  615.  
  616. ------------------------- Callbacks -------------------------
  617.  
  618. --- Adds a Lua callback for a sent or received game packet (not a socket packet).
  619. -- mode (string) - "send" or "recv" to listen to sent/received packets
  620. -- opcode (number) - The opcode that you want to listen. -1 listens everything.
  621. -- callback (function) - Your Lua callback
  622. -- returns string (ID of packet callback which is used by RemovePacketCallback)
  623. -- Example for 3.3.5 using CMSG_MOVE_JUMP: /script AddPacketCallback("send", 0xBB, function(data) print(data) end)
  624. -- Note: Packet callbacks persist through Lua reloads so if you lose the ID, you can't remove the filter.
  625. function AddPacketCallback(mode, opcode, callback)
  626.  
  627. -- Removes a Lua callback added by AddPacketCallback
  628. -- id (string) - The string returned by AddPacketCallback
  629. -- returns true on success, false if the callback wasn't found.
  630. function RemovePacketCallback(id)
  631.  
  632.  
  633. -- Add a callback to a Lua table that is called every frame, i.e., every "OnUpdate" WoW frame event.
  634. -- Callback (function) - The callback
  635. function AddFrameCallback (Callback)
  636.  
  637. --- Add a timer callback.
  638. -- Interval (number) - The number of seconds between calls
  639. -- Callback (function) - The callback
  640. function AddTimerCallback (Interval, Callback)
  641.  
  642. --- Add a WoW event callback, i.e., a function that is called on "OnEvent" frame event.
  643. -- Event (string) - The event name
  644. -- Callback (function) - The callback
  645. -- Note that the callback is called with the event arguments.
  646. function AddEventCallback (Event, Callback)
  647.  
  648. ------------------------- Miscellaneous -------------------
  649.  
  650. Types = {
  651. Bool = "bool",
  652. Char = "char",
  653. Byte = "byte",
  654. SByte = "char",
  655. UByte = "byte",
  656. Short = "short",
  657. SShort = "short",
  658. UShort = "ushort",
  659. Int = "int",
  660. SInt = "int",
  661. UInt = "uint",
  662. Long = "long",
  663. SLong = "long",
  664. ULong = "ulong",
  665. Float = "float",
  666. Double = "double",
  667. String = "string",
  668. GUID = "guid",
  669. Vector3 = "vector3"
  670. };
  671.  
  672. --- Open a URL in the default handler for the scheme.
  673. -- URL (string) - The URL
  674. function OpenURL (URL)
  675.  
  676. --- Download data from a URL using an HTTP GET request.
  677. -- Host (string) - The host.
  678. -- URL (string) - The rest of the URL.
  679. -- Secure (boolean) - Whether to use HTTPS.
  680. -- OnComplete (function) - A function that is called with the data when the request completes.
  681. -- OnError (function) - A function that is called with the error message if an error occurs.
  682. -- Note: Don't use this function. It's deprecated. Use SendHTTPRequest below.
  683. function DownloadURL (Host, URL, Secure, OnComplete, OnError) end
  684.  
  685. --- Send an HTTP or HTTPS request.
  686. -- URL (string) - The URL to send to
  687. -- PostData (string) - The post data if any (nil to use a GET request)
  688. -- OnComplete (body, code, req, res, err) - The function to be called with the response if the request succeeds.
  689. -- Headers (string) - Headers that should be added to the request. Split with \r\n.
  690. -- Note: This function doesn't return anything. It's asynchronous. Use the OnComplete callback for that.
  691. function SendHTTPRequest (URL, PostData, OnComplete [, Headers] )
  692. Example with some GET authentication + Lua execution:
  693.  
  694. SendHTTPRequest('http://someurl.com/auth?username=' .. username .. '&pass=' .. password, nil,
  695. function(body, code, req, res, err)
  696. RunScript(body) -- contents that were downloaded
  697. print(code) -- string - HTTP Response Code
  698. print(req) -- string - Full HTTP Request
  699. print(res) -- string - Full HTTP Response
  700. print(err) -- string - Some internal Socket Error
  701. end,
  702. "Authentication: bmljZQ==\r\nX-My-Server: HelloServer\r\nX-My-Client: HelloClient\r\n"
  703. )
  704.  
  705. --- Get a session variable.
  706. -- Name (string) - The variable name
  707. -- returns (string) - The value
  708. function GetSessionVariable (Name)
  709.  
  710. --- Set a session variable.
  711. -- Name (string) - The variable name
  712. -- Value (string) - The new value
  713. function SetSessionVariable (Name)
  714.  
  715. --- Get whether the game client is the foreground window.
  716. -- returns (boolean) - Whether the game client is the foreground window
  717. function IsForeground ()
  718.  
  719. --- Get the state of a key.
  720. -- Key (integer) - The virtual key code
  721. -- returns (boolean, boolean) - Whether the key is down and whether the key is toggled
  722. -- Virtual Key Codes: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  723. function GetKeyState (Key)
  724. function GetAsyncKeyState (Key)
  725.  
  726. --- Get an offset used by EWT.
  727. -- Name (string) - The offset name
  728. -- returns (number) - The offset value if found
  729. -- Example: GetOffset("FrameScript_RegisterFunction") or GetOffset("CGGameObject_C__Animation") for Fishing bobber animation
  730. -- On WoWs <= 4.3.4, you use this to get certain descriptors too, like GetOffset("UNIT_FIELD_FLAGS").
  731. function GetOffset (Name)
  732.  
  733. --- Get a WoW descriptor.
  734. -- Group (string) - The group that the descriptor belongs
  735. -- Name (string) - The descriptor name
  736. -- returns (number) - The offset value if found
  737. -- Example: GetDescriptor("CGObjectData", "Scale") or GetDescriptor("CGPlayerData", "PlayerTitle")
  738. -- Notes: Descriptor name follows an upper camel case convention, like UpperCamelCase.
  739. -- For a list of WoW descriptors, check Ownedcore's Info Dump Threads in the Memory Editing Section
  740. function GetDescriptor (Group, Name)
  741. return GetOffset(Group .. '__' .. Name)
  742. end
  743.  
  744. --- Create a Timer (useful for WoW versions below Warlords which don't have the C_Timer API)
  745. -- Duration (number) - The interval in milliseconds of the timer
  746. -- Callback (function) - The function to be called when the interval ends
  747. -- NumRuns (number) - Default: 0 (Repeats infinitely). Number of times the callback must be called.
  748. -- returns (number) - ID of the timer. Returns nil if error.
  749. -- Example: local timerId = CreateTimer(200, function() print('Test') end)
  750. -- Note: Timers persist through Lua reloads so if you lose the ID, you can't stop it.
  751. -- Note: If the Timer already executed all NumRuns, you don't need to call StopTimer.
  752. function CreateTimer (Duration, Callback[, NumRuns])
  753.  
  754. --- Stop a Timer created by CreateTimer
  755. -- TimerID (number) - The ID of the Timer
  756. -- returns (boolean) - True if it stopped or error if the timer wasn't found
  757. -- Notes: Upon calling this function, the Timer is completely destroyed and you must call CreateTimer again.
  758. -- Example: StopTimer(timerId)
  759. function StopTimer (TimerID)
  760.  
  761. --- Sends a key to WoW's window
  762. -- Key (number or string) - The key to be sent
  763. -- Release (boolean) - Whether the key should be released. Default: true
  764. -- Example: SendKey('2') or SendKey(0x32) or SendKey(50) - Keep in mind the keys are in ASCII
  765. function SendKey (Key[, Release])
  766.  
  767. --- Reads the given memory address.
  768. -- Address (number) - The address
  769. -- Type (string) - The type of data (Types table)
  770. -- returns the requested type of data (guid, string, bool, number, etc)
  771. function ReadMemory (Address, Type)
  772.  
  773. --- Unloads EWT
  774. function UnloadEWT()
  775.  
  776.  
  777. --------------- DirectX Drawing Functions -------
  778.  
  779. --- Draws a DirectX line
  780. -- startX (number) - The X coordinate of the line start
  781. -- startY (number) - The Y coordinate of the line start
  782. -- endX (number) - The X coordinate of the line end
  783. -- endY (number) - The Y coordinate of the line end
  784. -- width (number) - The width of the line
  785. -- return (boolean) - true if it worked, false if not
  786. function Draw2DLine(startX, startY, endX, endY[, width = 1.0f])
  787.  
  788. --- Draws a DirectX line
  789. -- Object (object) - The origin object (start of line)
  790. -- Target (object) - The target object (end of line)
  791. -- width (number) - The width of the line
  792. -- return (boolean) - true if it worked, false if not
  793. function Draw2DLine(Object, Target[, width = 1.0f])
  794.  
  795. --- Sets the global RGBA color for the next rendering. No need to call this all the time if you
  796. --- don't change the color often.
  797. -- red (number) - The Red component
  798. -- green (number) - The Green component
  799. -- blue (number) - The Blue component
  800. -- alpha (number) - The Alpha component
  801. function SetDrawColor(red, green, blue[, alpha = 1.0f])
  802.  
  803. --- Draws a DirectX text
  804. -- textX (number) - The X coordinate of the text
  805. -- textY (number) - The Y coordinate of the text
  806. -- text (number) - The Blue component
  807. function Draw2DText(textX, textY, text)
  808.  
  809. -- Example of how to draw a line to your target
  810. local f = CreateFrame("Frame")
  811. f:SetScript("OnUpdate", function (self, event, addon)
  812. Draw2DLine("player", "target")
  813. end)
  814.  
  815. -- Example of how to draw Tracker Projections and Text using the APIs above:
  816. local OBJECTTRACKER = {}
  817. local f = CreateFrame("Frame")
  818. f:SetScript("OnUpdate", function(self, event, addon)
  819. local sWidth, sHeight = GetScreenWidth(), GetScreenHeight()
  820. SetDrawColor(1, 1, 1, 1) -- white
  821. Draw2DText(sWidth * 0.5, sHeight * 0.5, "THIS IS A TEST")
  822. local totalObjects = GetObjectCount()
  823. for i = 1, totalObjects do
  824. local object = GetObjectWithIndex(i)
  825. OBJECTTRACKER[object] = CanTrackObject(object)
  826. end
  827. local playerX, playerY, playerZ = ObjectPosition("player")
  828. local camX, camY, camZ = GetCameraPosition()
  829. for i, v in pairs(OBJECTTRACKER) do
  830. if v then -- Bool: if the object can be tracked or not
  831. local targetX, targetY, targetZ = ObjectPosition(i)
  832. if targetX and targetY and targetZ then
  833. local arg1 = GetDistanceBetweenPositions(playerX, playerY, playerZ, targetX, targetY, targetZ)
  834. local arg2 = GetDistanceBetweenPositions(camX, camY, camZ, targetX, targetY, targetZ)
  835. if arg1 <= arg2 then
  836. if ObjectIsType(i, ObjectTypes.Unit) then
  837. local reaction = UnitReaction("player", i)
  838. if reaction then
  839. if reaction > 4 then
  840. if UnitIsPlayer(i) then
  841. SetDrawColor(0, 0, 1, 1) -- blue
  842. else
  843. SetDrawColor(0, 1, 0, 1) -- green
  844. end
  845. elseif reaction == 4 then
  846. SetDrawColor(1, 1, 0, 1) -- yellow
  847. elseif reaction < 4 then
  848. SetDrawColor(1, 0, 0, 1) -- red
  849. end
  850. else
  851. SetDrawColor(1, 1, 1, 1) -- white
  852. end
  853. else
  854. SetDrawColor(1, 1, 1, 1) -- white
  855. end
  856. local player2DX, player2DY = WorldToScreen_Original(playerX, playerY, playerZ)
  857. local target2DX, target2DY = WorldToScreen_Original(targetX, targetY, targetZ)
  858. Draw2DLine(player2DX * sWidth, player2DY * sHeight, target2DX * sWidth, target2DY * sHeight)
  859. end
  860. end
  861. end
  862. end
  863. end)
  864.  
  865.  
  866. --------------- LibDraw Drawing Functions -------
  867. -- For more info, check this https://github.com/MrTheSoulz/NerdPack-Protected/blob/master/external/LibDraw.lua
  868.  
  869. LibDraw.Sync(function()
  870. if UnitExists("target") then
  871. local playerX, playerY, playerZ = ObjectPosition("player")
  872. local targetX, targetY, targetZ = ObjectPosition("target")
  873. local reaction = UnitReaction("player", "target")
  874. if reaction >= 5 then
  875. LibDraw.SetColorRaw(0, 1, 0, 1)
  876. elseif reaction == 4 then
  877. LibDraw.SetColorRaw(1, 1, 0, 1)
  878. elseif reaction <= 3 then
  879. LibDraw.SetColorRaw(1, 0, 0, 1)
  880. end
  881. LibDraw.Line(playerX, playerY, playerZ, targetX, targetY, targetZ)
  882. -- LibDraw.Circle(targetX, targetY, targetZ, 5)
  883. end
  884. end)
  885. LibDraw.Enable(0.01)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement