Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------- Active Player -------------------
- --- Stop falling.
- function StopFalling () end
- --- Move to a position.
- -- X (number) - The X coordinate
- -- Y (number) - The Y coordinate
- -- Z (number) - The Z coordinate
- -- InstantTurn (boolean) - Whether to instantly turn toward the destination
- function MoveTo (X, Y, Z[, InstantTurn])
- --- Teleport to a position.
- -- X (number) - The X coordinate
- -- Y (number) - The Y coordinate
- -- Z (number) - The Z coordinate
- function Teleport (X, Y, Z)
- --- Registers Lua callbacks for Teleport
- -- before (function) - A callback that is called before EWT teleports your character.
- -- after (function) - A callback that is called after EWT teleports your character.
- function AddTeleportCallbacks(before, after)
- -- Example:
- function myTeleportFunc()
- AddTeleportCallbacks(
- function()
- local beforeX, beforeY, beforeZ = ObjectPosition("player")
- print('Teleported from ' .. beforeX .. ' ' .. beforeY .. ' ' .. beforeZ)
- end,
- function()
- local x, y, z = ObjectPosition("player")
- print('to x ' .. x .. ' ' .. y .. ' ' .. z)
- end
- )
- end
- --- Set the direction that the player is facing (angle in XY).
- -- Direction (number) or Object (string) - The direction in radians or the object
- -- Update (boolean) - Whether to immediately notify the server
- function FaceDirection (Direction[, Update])
- --- Set the maximum angle from the XY plane that the player can move at
- -- Angle (number) - The maximum angle in degrees
- -- Note that the angle must be between 0º and 90º.
- function SetMaximumClimbAngle (Angle)
- ------------------------- Object --------------------------
- if EWT.is80 then
- ObjectType = {
- Object = 0,
- Item = 1,
- Container = 2,
- AzeriteEmpoweredItem = 3,
- AzeriteItem = 4,
- Unit = 5,
- Player = 6,
- ActivePlayer = 7,
- GameObject = 8,
- DynamicObject = 9,
- Corpse = 10,
- AreaTrigger = 11,
- SceneObject = 12,
- ConversationData = 13
- };
- else
- ObjectType = {
- Object = 0,
- Item = 1,
- Container = 2,
- Unit = 3,
- Player = 4,
- GameObject = 5,
- DynamicObject = 6,
- Corpse = 7,
- AreaTrigger = 8,
- SceneObject = 9,
- ConversationData = 10
- };
- end
- -- Don't use this for BFA
- ObjectTypes = {
- None = 0,
- Object = 1,
- Item = 2,
- Container = 4,
- Unit = 8,
- Player = 16,
- GameObject = 32,
- DynamicObject = 64,
- Corpse = 128,
- AreaTrigger = 256,
- SceneObject = 512,
- All = -1
- };
- --- Get an object's pointer.
- -- Object (object) - The object
- -- returns (string or nil) - The pointer as a hexadecimal string prefixed by 0x or nil if the object does not exist.
- -- Note: If the object doesn't exist, for example, ObjectPointer('party1target'), it returns nil.
- -- This API is mainly useful to get the object address of unitIDs like 'target', 'mouseover', etc.
- -- ObjectPointer('0xDEADBEEF') simply returns '0xDEADBEEF' and does NOT check if the address is in the object manager. Don't do this.
- function ObjectPointer (Object)
- --- Get whether an object exists in the object manager.
- -- Object (object) - The object
- -- returns (string or nil) - The pointer as a hexadecimal string prefixed by 0x or nil if the object does not exist.
- -- Note that if the object does not exist in the object manager it is invalid and should not be used.
- -- This API is only useful to check if '0x' strings are *really* valid. In my opinion, it should never be used
- -- if you are properly using GetObjectCount since you will always work with objects that exist.
- -- This API is similar to ObjectPointer, but it checks if the object exists in the object manager.
- -- If you pass a unitID, like ObjectExists('target'), then its performance is the same as ObjectPointer('target').
- -- This API works like UnitIsVisible, but instead of returning boolean, it returns string or nil.
- function ObjectExists (Object)
- --- Get an object's position.
- -- Object (object) - The object
- -- returns (number, number, number) - The X, Y, and Z coordinates
- -- Note: If the object doesn't exist, it returns (nil, nil, nil)
- function ObjectPosition (Object)
- --- Get an object's facing.
- -- Object (object) - The object
- -- returns (number or nil) - The facing (angle in XY) in radians
- -- Note: If the object doesn't exist, it returns nil.
- function ObjectFacing (Object)
- GetObjectFacing = ObjectFacing
- --- Get an object's GUID.
- -- Object (object) - The object
- -- returns (string or nil) - The GUID as a string or nil if the object doesn't exist.
- -- Note: This API is mainly for WoW Classic 1.12.1, because UnitGUID doesn't exist in this version.
- function ObjectGUID (Object)
- --- Get an object's name.
- -- Object (object) - The object
- -- returns (string) - The name
- function ObjectName (Object)
- --- Get an object's type ID.
- -- Object (object) - The object
- -- returns (integer) - The type ID or nil if there is none
- function ObjectID (Object)
- --- Get whether an object is of a type.
- -- Object (object) - The object
- -- Type (ObjectTypes member) - The type
- -- returns (boolean) - Whether the object is of the type
- -- Note: Don't use this for BFA. Use ObjectRawType instead.
- function ObjectIsType (Object, Type)
- --- Get an object's type flags.
- -- Object (object) - The object
- -- returns (integer) - One or more members of the ObjectTypes table combined with bit.bor
- -- Note: Don't use this for BFA. Use ObjectRawType instead.
- function ObjectTypeFlags (Object)
- --- Get an object's type.
- -- Object (object) - The object
- -- returns (integer) - One member of the ObjectType table.
- function ObjectRawType (Object)
- function ObjectIsPlayer(object)
- local type = ObjectRawType(object)
- return type == ObjectType.Player or type == ObjectType.ActivePlayer
- end
- function ObjectIsUnit(object)
- local type = ObjectRawType(object)
- return type == ObjectType.Unit or type == ObjectType.Player or type == ObjectType.ActivePlayer
- end
- function ObjectIsGameObject(object)
- return ObjectRawType(object) == ObjectType.GameObject
- end
- function ObjectIsAreaTrigger(object)
- return ObjectRawType(object) == ObjectType.AreaTrigger
- end
- function GetDistanceBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
- return math.sqrt(math.pow(X2 - X1, 2) + math.pow(Y2 - Y1, 2) + math.pow(Z2 - Z1, 2));
- end
- --- Get the distance between two objects.
- -- Object1 (object) - The first object
- -- Object2 (object) - The second object
- -- returns (number) - The distance
- function GetDistanceBetweenObjects (Object1, Object2)
- --- Get the angles between two objects.
- -- Object1 (object) - The first object
- -- Object2 (object) - The second object
- -- returns (number, number) - The facing (angle in XY) and pitch (angle from XY) from the first object to the second
- function GetAnglesBetweenObjects (Object1, Object2)
- --- Get the position that is between two objects and a specified distance from the first object.
- -- Object1 (object) - The first object
- -- Object2 (object) - The second object
- -- Distance (number) - The distance from the first object
- -- returns (number, number, number) - The X, Y, and Z coordinates
- function GetPositionBetweenObjects (Object1, Object2, Distance)
- function GetPositionFromPosition (X, Y, Z, Distance, AngleXY, AngleXYZ)
- return math.cos(AngleXY) * Distance + X,
- math.sin(AngleXY) * Distance + Y,
- math.sin(AngleXYZ) * Distance + Z;
- end
- function GetAnglesBetweenPositions (X1, Y1, Z1, X2, Y2, Z2)
- return math.atan2(Y2 - Y1, X2 - X1) % (math.pi * 2),
- math.atan((Z1 - Z2) / math.sqrt(math.pow(X1 - X2, 2) + math.pow(Y1 - Y2, 2))) % math.pi;
- end
- function GetPositionBetweenPositions (X1, Y1, Z1, X2, Y2, Z2, DistanceFromPosition1)
- local AngleXY, AngleXYZ = GetAnglesBetweenPositions(X1, Y1, Z1, X2, Y2, Z2);
- return GetPositionFromPosition(X1, Y1, Z1, DistanceFromPosition1, AngleXY, AngleXYZ);
- end
- --- Get whether an object is facing another.
- -- Object1 (object) - The first object
- -- Object2 (object) - The second object
- -- returns (boolean) - Whether the first object is facing the second
- function ObjectIsFacing (Object1, Object2)
- --- Get whether an object is behind another.
- -- Object1 (object) - The first object
- -- Object2 (object) - The second object
- -- returns (boolean) - Whether the first object is behind the second
- function ObjectIsBehind (Object1, Object2)
- --- Get one of an object's descriptors.
- -- Object (object) - The object
- -- Offset (integer) - The descriptor offset
- -- Type (Type member) - The descriptor type
- -- returns (Type) - The descriptor value
- function ObjectDescriptor (Object, Offset, Type)
- --- Get one of an object's fields.
- -- Object (object) - The object
- -- Offset (integer) - The field offset
- -- Type (Type member) - The field type
- -- returns (Type) - The field value
- function ObjectField (Object, Offset, Type)
- --- Interact with Object. Useful for 1.12.1 and 2.4.3 since InteractUnit isn't available in these versions.
- -- Object (object) - The object
- -- returns (boolean) - True if the object is valid, False if not
- function ObjectInteract (Object)
- ------------------------- Object Manager ------------------
- --- Get the number of objects in the object manager and optionally 2 tables with all objects that were updated in the frame.
- -- GetUpdates (boolean) - True to get the tables with the objects that were updated in the frame.
- -- returns (integer, boolean, table, table) - The total number of objects, if the object manager was updated, the added objects and the removed objects.
- -- Note: This should be the first API that you should call before using the other object manager functions.
- -- Ideally, call it once every frame with an OnUpdate frame event.
- -- You can use table.getn or # to get the number of objects in the returned tables.
- function GetObjectCount ([GetUpdates])
- ObjectCount = GetObjectCount
- -- Example:
- local initOM = true
- local myOM = {}
- local myFrame = CreateFrame("Frame")
- myFrame:SetScript("OnUpdate", function ()
- -- The first frame call to GetObjectCount(true) should have total == #added and 'added' will contain all objects.
- -- The next GetObjectCount(true) calls should have only the updated objects.
- local total, updated, added, removed = GetObjectCount(true)
- if initOM then
- initOM = false
- for i = 1,total do
- local thisUnit = GetObjectWithIndex(i) -- thisUnit contains the '0x' string representing the object address
- -- Do something with the unit
- myOM[thisUnit] = 1
- end
- end
- for k,v in pairs(added) do
- -- k - Number = Array index = Don't confuse this with the Object Index used by GetObjectWithIndex. It's not the same thing.
- -- v - String = Object address
- print('Added ' .. v)
- myOM[v] = 1
- if ObjectIsUnit(v) then
- local posX, posY, posZ = ObjectPosition(v)
- end
- end
- for k,v in pairs(removed) do
- print('Removed ' .. v)
- myOM[v] = nil
- end
- local manualCount = 0
- for k,v in pairs(myOM) do
- manualCount = manualCount + 1
- end
- if #added ~= 0 or #removed ~= 0 then
- print('Total ' .. total .. ' ' .. #added .. ' ' .. #removed .. ' Manual ' .. manualCount)
- end
- end);
- --- Get an object in the object manager from its index.
- -- Index (integer) - The one-based index of the object. Starts at 1.
- -- returns (object) - The object
- -- Note: If an object is at index 30, this does NOT mean that in the next frame it will be at index 30 again.
- -- This API isn't really needed if you are properly using GetObjectCount(true).
- function GetObjectWithIndex (Index)
- ObjectWithIndex = GetObjectWithIndex
- --- Get the number of units in the object manager and optionally 2 tables with all units that were updated in the frame.
- -- returns (integer, boolean, table, table) - The total number of units, if the unit manager was updated, the added units and the removed units.
- -- Note: It works like GetObjectCount, but for units, which consist on Units, Players and ActivePlayers.
- function GetUnitCount ([GetUpdates])
- --- Get a unit in the Unit Manager from its index. Unit Manager is a separate table inside the Object manager.
- -- Index (integer) - The one-based index of the object. Starts at 1.
- -- returns (object) - The unit
- -- Note: The index used must be <= GetUnitCount(). This index is NOT the same index used in GetObjectWithIndex.
- function GetUnitWithIndex (Index)
- --- Get an object in the object manager from its pointer.
- -- Pointer (string) - A pointer to the object as a hexadecimal string prefixed by 0x
- -- returns (object) - The object
- -- Note: Avoid using this API. Prefer GetObjectWithIndex instead. It's here only because of backwards compatibility.
- function GetObjectWithPointer (Pointer)
- --- Get an object in the object manager from its GUID.
- -- GUID (string) - The GUID
- -- returns (object) - The object or nil if it is not in the object manager
- function GetObjectWithGUID (GUID)
- --- Gets the active player.
- -- returns (object or nil) - The active player object or nil if it does not exist.
- function GetActivePlayer ()
- --- Gets the active mover.
- -- returns (object or nil) - The active mover object or nil if it does not exist.
- -- Note: This is usually the Active Player. When you get mind controlled, lose control of your character or control
- -- something else, then the Active Mover is different.
- function GetActiveMover ()
- ------------------------- Unit ----------------------------
- --- Get an object's facing direction.
- -- @param Object The object. It must be of type Unit.
- -- @param Object The object.
- -- @param Angle The frontal cone angle in degrees. Default: 180 degrees
- -- @return Boolean. Whether it is facing or not.
- function UnitIsFacing (Object, Object[, Angle]) end
- MovementFlags = {
- Forward = 0x1,
- Backward = 0x2,
- StrafeLeft = 0x4,
- StrafeRight = 0x8,
- TurnLeft = 0x10,
- TurnRight = 0x20,
- PitchUp = 0x40,
- PitchDown = 0x80,
- Walking = 0x100,
- Immobilized = 0x400,
- Falling = 0x800,
- FallingFar = 0x1000,
- Swimming = 0x100000,
- Ascending = 0x200000,
- Descending = 0x400000,
- CanFly = 0x800000,
- Flying = 0x1000000,
- };
- --- Get the unit's movement address.
- -- Unit (unit) - The unit
- -- returns (integer) - The movement struct address
- -- Note: If the object is not a unit, then it returns nil.
- function GetUnitMovement (Unit)
- --- Get the unit's speed.
- -- Unit (unit) - The unit
- -- returns (number) - currentSpeed, groundSpeed, flightSpeed, swimSpeed
- -- Note: If the object is not a unit, then it returns nil.
- -- This API is only available on 1.12.1 and 2.4.3.
- function GetUnitSpeed (Unit)
- --- Get a unit's movement flags.
- -- Unit (unit) - The unit
- -- returns (integer) - The movement flags
- function UnitMovementFlags (Unit)
- --- Set a unit's movement flags.
- -- Unit (unit) - The unit
- -- Flags (number) - The new movement flags
- -- returns (boolean) - True if it worked or some error if not.
- function SetMovementFlags (Unit, Flags)
- --- Send the player's movement state to the server.
- --- returns (boolean) - True if it worked, False if not. It will only fail if there's no player active.
- function SendMovementUpdate ()
- --- Get a unit's bounding radius.
- -- Unit (unit) - The unit
- -- returns (number) - The bounding radius
- function UnitBoundingRadius (Unit)
- --- Get a unit's combat reach.
- -- Unit (unit) - The unit
- -- returns (number) - The combat reach
- function UnitCombatReach (Unit)
- --- Get a unit's target.
- -- Unit (unit) - The unit
- -- returns (unit) - The target or nil if there is none
- function UnitTarget (Unit)
- --- Get an object's creator.
- -- Object (object) - The unit or game object
- -- returns (unit) - The creator or nil if there is none
- function ObjectCreator (Unit)
- UnitCreator = ObjectCreator
- --- Get whether a unit can be looted.
- -- Unit (unit) - The unit
- -- returns (boolean) - Whether the unit can be looted
- function UnitCanBeLooted (Unit)
- --- Get whether a unit can be skinned.
- -- Unit (unit) - The unit
- -- returns (boolean) - Whether the unit can be skinned
- function UnitCanBeSkinned (Unit)
- --- Set a unit's display ID.
- -- Unit (unit) - The unit
- -- DisplayID (integer) - The new display ID
- -- returns (boolean) - Whether the display was changed or not
- -- Note that UnitUpdateModel must be called for the change to be displayed.
- function UnitSetDisplayID (Unit, DisplayID)
- SetDisplayID = UnitSetDisplayID
- -- Sets the unit's mount display ID
- function SetMountDisplayID(Unit, DisplayID)
- -- Set's the unit's item display ID
- function SetVisibleItem(Unit, SlotID, ItemID [, ItemAppearanceModID])
- -- Set's the unit's item enchant ID
- function SetVisibleEnchant(Unit, SlotID, EnchantID)
- --- Update a unit's model.
- -- Unit (unit) - The unit
- function UnitUpdateModel (Unit)
- UpdateModel = UnitUpdateModel
- --- Get the spell IDs being casted or channelled by the unit
- -- Unit (unit) - The unit
- -- returns (number, number, object, object) - (Spell Cast ID, Spell Channel ID, Cast Object, Channel Object)
- -- Note: If no spells are being casted, it returns 0, 0, nil, nil.
- -- 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.
- function UnitCastID (Unit)
- --- Get or set unit pitch.
- -- Unit (unit) - The unit
- -- newPitch (number) - The new pitch
- -- update (boolean) - Whether to immediately notify the server
- -- returns (number) - The unit pitch.
- -- Note: If setting the pitch, it doesnt return anything. Also, pitch returns 0 for other units which aren't the current active mover.
- function UnitPitch (Unit[, newPitch, update])
- ------------------------- World ---------------------------
- HitFlags = {
- M2Collision = 0x1,
- M2Render = 0x2,
- WMOCollision = 0x10,
- WMORender = 0x20,
- Terrain = 0x100,
- WaterWalkableLiquid = 0x10000,
- Liquid = 0x20000,
- EntityCollision = 0x100000,
- };
- --- Perform a raycast between two positions.
- -- StartX (number) - The starting X coordinate
- -- StartY (number) - The starting Y coordinate
- -- StartZ (number) - The starting Z coordinate
- -- EndX (number) - The ending X coordinate
- -- EndY (number) - The ending Y coordinate
- -- EndZ (number) - The ending Z coordinate
- -- Flags (integer) - One or more members of the HitFlags table combined with bit.bor
- -- returns (number, number, number) - The X, Y, and Z coordinates of the hit position, or nil if there was no hit
- -- Note: Be careful with how often you call this API because your FPS can drop a lot.
- function TraceLine (StartX, StartY, StartZ, EndX, EndY, EndZ, Flags)
- --- Get the camera position.
- -- returns (number, number, number) - The X, Y, and Z coordinates of the camera
- function GetCameraPosition ()
- --- Cancel the pending spell if any.
- function CancelPendingSpell ()
- --- Simulate a click at a position in the game-world.
- -- X (number) - The X coordinate
- -- Y (number) - The Y coordinate
- -- Z (number) - The Z coordinate
- -- Right (boolean) - Whether to right click rather than left click
- function ClickPosition (X, Y, Z[, Right])
- CastAtPosition = ClickPosition
- --- Get whether an AoE spell is pending a target.
- -- returns (boolean) - Whether an AoE spell is pending a target
- function IsAoEPending ()
- --- Get the screen coordinates relative from World coordinates
- -- X (number) - The X coordinate.
- -- Y (number) - The Y coordinate.
- -- Z (number) - The Z coordinate.
- -- 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.
- function WorldToScreen (X, Y, Z) end
- --- Return whether the given coordinates are in front of WoW's camera
- -- X (number) - The X coordinate.
- -- Y (number) - The Y coordinate.
- -- Z (number) - The Z coordinate.
- -- returns (boolean) - Whether they are in front or not.
- function IsInFront (X, Y, Z) end
- ------------------------- Hacks ---------------------------
- Hacks = {
- Fly = "Fly",
- Hover = "Hover",
- Climb = "Climb",
- MovingLoot = "MovingLoot",
- WaterWalk = "WaterWalk",
- M2Collision = "M2Collision",
- WMOCollision = "WMOCollision",
- TerrainCollision = "TerrainCollision",
- Zoom = "Zoom",
- AlwaysFacing = "AlwaysFacing",
- NoAutoAway = "NoAutoAway",
- NoSwim = "NoSwim",
- MultiJump = "MultiJump",
- CRZBlocking = "CRZBlocking",
- M2Rendering = "M2Rendering",
- WMORendering = "WMORendering",
- TerrainRendering = "TerrainRendering",
- LiquidRendering = "LiquidRendering",
- CollisionRendering = "CollisionRendering",
- MountainRendering = "MountainRendering",
- DetailsRendering = "DetailsRendering",
- Wireframe = "Wireframe",
- Freeze = "Freeze",
- MovingCast = "MovingCast",
- GoClick = "GoClick",
- UnlockLua = "UnlockLua",
- SimpleUnlock = "SimpleUnlock"
- }
- --- Get whether a hack is enabled.
- -- Hack (Hacks member) - The hack
- -- returns (boolean) - Whether the hack is enabled
- function IsHackEnabled (Hack)
- --- Set whether a hack is enabled.
- -- Hack (Hacks member) - The hack
- -- Enable (boolean) - Whether the hack is to be enabled
- function SetHackEnabled (Hack, Enable)
- SetOptionEnabled = SetHackEnabled
- ------------------------- File ----------------------------
- --- Get the names of the files in a directory.
- -- Path (string) - The path to the files
- -- returns (table) - The file names
- -- Example: "C:\*" would retrieve the names of all of the files in C:\.
- -- Example: "C:\*.dll" would retrieve the names of all of the .dll files in C:\.
- function GetDirectoryFiles (Path)
- --- Get the names of the directories in a directory.
- -- Path (string) - The path to the directories
- -- returns (table) - The directory names
- -- Example: "C:\*" would retrieve the names of all of the directories in C:\.
- -- Example: "C:\Program Files*" would retrieve the names of the program files directories in C:\.
- function GetSubdirectories (Path)
- --- Get the contents of a text file.
- -- Path (string) - The file path
- -- returns (string) - The file contents
- function ReadFile (Path)
- --- Set the contents of or append a text file.
- -- Path (string) - The file path
- -- String (string) - The string to write
- -- Append (boolean) - Whether to append rather than overwrite
- function WriteFile (Path, Contents[, Append])
- --- Get the directory that the hack is in.
- -- @return The directory that the hack is in.
- function GetHackDirectory () end
- GetFireHackDirectory = GetHackDirectory
- --- Get the directory that WoW is in.
- -- returns (string) - The directory that WoW is in
- function GetWoWDirectory ()
- ------------------------- Scripts -------------------------
- --- Load a script from the Scripts folder.
- -- FileName (string) - The script file name
- -- returns - The return values of the script if any
- function LoadScript (FileName)
- --- Get the file name of the currently executing script.
- -- returns (string) - The file name of the currently executing script
- -- Note that this can only be called from within a script.
- function GetScriptName ()
- ------------------------- Callbacks -------------------------
- --- Adds a Lua callback for a sent or received game packet (not a socket packet).
- -- mode (string) - "send" or "recv" to listen to sent/received packets
- -- opcode (number) - The opcode that you want to listen. -1 listens everything.
- -- callback (function) - Your Lua callback
- -- returns string (ID of packet callback which is used by RemovePacketCallback)
- -- Example for 3.3.5 using CMSG_MOVE_JUMP: /script AddPacketCallback("send", 0xBB, function(data) print(data) end)
- -- Note: Packet callbacks persist through Lua reloads so if you lose the ID, you can't remove the filter.
- function AddPacketCallback(mode, opcode, callback)
- -- Removes a Lua callback added by AddPacketCallback
- -- id (string) - The string returned by AddPacketCallback
- -- returns true on success, false if the callback wasn't found.
- function RemovePacketCallback(id)
- -- Add a callback to a Lua table that is called every frame, i.e., every "OnUpdate" WoW frame event.
- -- Callback (function) - The callback
- function AddFrameCallback (Callback)
- --- Add a timer callback.
- -- Interval (number) - The number of seconds between calls
- -- Callback (function) - The callback
- function AddTimerCallback (Interval, Callback)
- --- Add a WoW event callback, i.e., a function that is called on "OnEvent" frame event.
- -- Event (string) - The event name
- -- Callback (function) - The callback
- -- Note that the callback is called with the event arguments.
- function AddEventCallback (Event, Callback)
- ------------------------- Miscellaneous -------------------
- Types = {
- Bool = "bool",
- Char = "char",
- Byte = "byte",
- SByte = "char",
- UByte = "byte",
- Short = "short",
- SShort = "short",
- UShort = "ushort",
- Int = "int",
- SInt = "int",
- UInt = "uint",
- Long = "long",
- SLong = "long",
- ULong = "ulong",
- Float = "float",
- Double = "double",
- String = "string",
- GUID = "guid",
- Vector3 = "vector3"
- };
- --- Open a URL in the default handler for the scheme.
- -- URL (string) - The URL
- function OpenURL (URL)
- --- Download data from a URL using an HTTP GET request.
- -- Host (string) - The host.
- -- URL (string) - The rest of the URL.
- -- Secure (boolean) - Whether to use HTTPS.
- -- OnComplete (function) - A function that is called with the data when the request completes.
- -- OnError (function) - A function that is called with the error message if an error occurs.
- -- Note: Don't use this function. It's deprecated. Use SendHTTPRequest below.
- function DownloadURL (Host, URL, Secure, OnComplete, OnError) end
- --- Send an HTTP or HTTPS request.
- -- URL (string) - The URL to send to
- -- PostData (string) - The post data if any (nil to use a GET request)
- -- OnComplete (body, code, req, res, err) - The function to be called with the response if the request succeeds.
- -- Headers (string) - Headers that should be added to the request. Split with \r\n.
- -- Note: This function doesn't return anything. It's asynchronous. Use the OnComplete callback for that.
- function SendHTTPRequest (URL, PostData, OnComplete [, Headers] )
- Example with some GET authentication + Lua execution:
- SendHTTPRequest('http://someurl.com/auth?username=' .. username .. '&pass=' .. password, nil,
- function(body, code, req, res, err)
- RunScript(body) -- contents that were downloaded
- print(code) -- string - HTTP Response Code
- print(req) -- string - Full HTTP Request
- print(res) -- string - Full HTTP Response
- print(err) -- string - Some internal Socket Error
- end,
- "Authentication: bmljZQ==\r\nX-My-Server: HelloServer\r\nX-My-Client: HelloClient\r\n"
- )
- --- Get a session variable.
- -- Name (string) - The variable name
- -- returns (string) - The value
- function GetSessionVariable (Name)
- --- Set a session variable.
- -- Name (string) - The variable name
- -- Value (string) - The new value
- function SetSessionVariable (Name)
- --- Get whether the game client is the foreground window.
- -- returns (boolean) - Whether the game client is the foreground window
- function IsForeground ()
- --- Get the state of a key.
- -- Key (integer) - The virtual key code
- -- returns (boolean, boolean) - Whether the key is down and whether the key is toggled
- -- Virtual Key Codes: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
- function GetKeyState (Key)
- function GetAsyncKeyState (Key)
- --- Get an offset used by EWT.
- -- Name (string) - The offset name
- -- returns (number) - The offset value if found
- -- Example: GetOffset("FrameScript_RegisterFunction") or GetOffset("CGGameObject_C__Animation") for Fishing bobber animation
- -- On WoWs <= 4.3.4, you use this to get certain descriptors too, like GetOffset("UNIT_FIELD_FLAGS").
- function GetOffset (Name)
- --- Get a WoW descriptor.
- -- Group (string) - The group that the descriptor belongs
- -- Name (string) - The descriptor name
- -- returns (number) - The offset value if found
- -- Example: GetDescriptor("CGObjectData", "Scale") or GetDescriptor("CGPlayerData", "PlayerTitle")
- -- Notes: Descriptor name follows an upper camel case convention, like UpperCamelCase.
- -- For a list of WoW descriptors, check Ownedcore's Info Dump Threads in the Memory Editing Section
- function GetDescriptor (Group, Name)
- return GetOffset(Group .. '__' .. Name)
- end
- --- Create a Timer (useful for WoW versions below Warlords which don't have the C_Timer API)
- -- Duration (number) - The interval in milliseconds of the timer
- -- Callback (function) - The function to be called when the interval ends
- -- NumRuns (number) - Default: 0 (Repeats infinitely). Number of times the callback must be called.
- -- returns (number) - ID of the timer. Returns nil if error.
- -- Example: local timerId = CreateTimer(200, function() print('Test') end)
- -- Note: Timers persist through Lua reloads so if you lose the ID, you can't stop it.
- -- Note: If the Timer already executed all NumRuns, you don't need to call StopTimer.
- function CreateTimer (Duration, Callback[, NumRuns])
- --- Stop a Timer created by CreateTimer
- -- TimerID (number) - The ID of the Timer
- -- returns (boolean) - True if it stopped or error if the timer wasn't found
- -- Notes: Upon calling this function, the Timer is completely destroyed and you must call CreateTimer again.
- -- Example: StopTimer(timerId)
- function StopTimer (TimerID)
- --- Sends a key to WoW's window
- -- Key (number or string) - The key to be sent
- -- Release (boolean) - Whether the key should be released. Default: true
- -- Example: SendKey('2') or SendKey(0x32) or SendKey(50) - Keep in mind the keys are in ASCII
- function SendKey (Key[, Release])
- --- Reads the given memory address.
- -- Address (number) - The address
- -- Type (string) - The type of data (Types table)
- -- returns the requested type of data (guid, string, bool, number, etc)
- function ReadMemory (Address, Type)
- --- Unloads EWT
- function UnloadEWT()
- --------------- DirectX Drawing Functions -------
- --- Draws a DirectX line
- -- startX (number) - The X coordinate of the line start
- -- startY (number) - The Y coordinate of the line start
- -- endX (number) - The X coordinate of the line end
- -- endY (number) - The Y coordinate of the line end
- -- width (number) - The width of the line
- -- return (boolean) - true if it worked, false if not
- function Draw2DLine(startX, startY, endX, endY[, width = 1.0f])
- --- Draws a DirectX line
- -- Object (object) - The origin object (start of line)
- -- Target (object) - The target object (end of line)
- -- width (number) - The width of the line
- -- return (boolean) - true if it worked, false if not
- function Draw2DLine(Object, Target[, width = 1.0f])
- --- Sets the global RGBA color for the next rendering. No need to call this all the time if you
- --- don't change the color often.
- -- red (number) - The Red component
- -- green (number) - The Green component
- -- blue (number) - The Blue component
- -- alpha (number) - The Alpha component
- function SetDrawColor(red, green, blue[, alpha = 1.0f])
- --- Draws a DirectX text
- -- textX (number) - The X coordinate of the text
- -- textY (number) - The Y coordinate of the text
- -- text (number) - The Blue component
- function Draw2DText(textX, textY, text)
- -- Example of how to draw a line to your target
- local f = CreateFrame("Frame")
- f:SetScript("OnUpdate", function (self, event, addon)
- Draw2DLine("player", "target")
- end)
- -- Example of how to draw Tracker Projections and Text using the APIs above:
- local OBJECTTRACKER = {}
- local f = CreateFrame("Frame")
- f:SetScript("OnUpdate", function(self, event, addon)
- local sWidth, sHeight = GetScreenWidth(), GetScreenHeight()
- SetDrawColor(1, 1, 1, 1) -- white
- Draw2DText(sWidth * 0.5, sHeight * 0.5, "THIS IS A TEST")
- local totalObjects = GetObjectCount()
- for i = 1, totalObjects do
- local object = GetObjectWithIndex(i)
- OBJECTTRACKER[object] = CanTrackObject(object)
- end
- local playerX, playerY, playerZ = ObjectPosition("player")
- local camX, camY, camZ = GetCameraPosition()
- for i, v in pairs(OBJECTTRACKER) do
- if v then -- Bool: if the object can be tracked or not
- local targetX, targetY, targetZ = ObjectPosition(i)
- if targetX and targetY and targetZ then
- local arg1 = GetDistanceBetweenPositions(playerX, playerY, playerZ, targetX, targetY, targetZ)
- local arg2 = GetDistanceBetweenPositions(camX, camY, camZ, targetX, targetY, targetZ)
- if arg1 <= arg2 then
- if ObjectIsType(i, ObjectTypes.Unit) then
- local reaction = UnitReaction("player", i)
- if reaction then
- if reaction > 4 then
- if UnitIsPlayer(i) then
- SetDrawColor(0, 0, 1, 1) -- blue
- else
- SetDrawColor(0, 1, 0, 1) -- green
- end
- elseif reaction == 4 then
- SetDrawColor(1, 1, 0, 1) -- yellow
- elseif reaction < 4 then
- SetDrawColor(1, 0, 0, 1) -- red
- end
- else
- SetDrawColor(1, 1, 1, 1) -- white
- end
- else
- SetDrawColor(1, 1, 1, 1) -- white
- end
- local player2DX, player2DY = WorldToScreen_Original(playerX, playerY, playerZ)
- local target2DX, target2DY = WorldToScreen_Original(targetX, targetY, targetZ)
- Draw2DLine(player2DX * sWidth, player2DY * sHeight, target2DX * sWidth, target2DY * sHeight)
- end
- end
- end
- end
- end)
- --------------- LibDraw Drawing Functions -------
- -- For more info, check this https://github.com/MrTheSoulz/NerdPack-Protected/blob/master/external/LibDraw.lua
- LibDraw.Sync(function()
- if UnitExists("target") then
- local playerX, playerY, playerZ = ObjectPosition("player")
- local targetX, targetY, targetZ = ObjectPosition("target")
- local reaction = UnitReaction("player", "target")
- if reaction >= 5 then
- LibDraw.SetColorRaw(0, 1, 0, 1)
- elseif reaction == 4 then
- LibDraw.SetColorRaw(1, 1, 0, 1)
- elseif reaction <= 3 then
- LibDraw.SetColorRaw(1, 0, 0, 1)
- end
- LibDraw.Line(playerX, playerY, playerZ, targetX, targetY, targetZ)
- -- LibDraw.Circle(targetX, targetY, targetZ, 5)
- end
- end)
- LibDraw.Enable(0.01)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement