### Getting Started Guides Source: https://github.com/darhanger/ni/blob/main/docs/_sidebar.md This section provides essential guides for users new to the Darhanger NI project. It includes a quick start guide for rapid setup, a guide on how to contribute to the project, and a Frequently Asked Questions (FAQ) section to address common queries. ```markdown - [Quick start](getting-started/quickstart.md) - [How to contribute](getting-started/how-to-contribute.md) - [FAQ](getting-started/faq.md) ``` -------------------------------- ### Basic Ni Profile Setup Source: https://github.com/darhanger/ni/blob/main/docs/getting-started/quickstart.md This snippet demonstrates the basic structure for creating a Ni profile. It defines a simple queue and an ability that prints 'Hello' to the console, then bootstraps the profile using `ni.bootstrap.profile`. ```lua local queue = { "Print Hello" }; local abilities = { ["Print Hello"] = function() print("Hello") end }; ni.bootstrap.profile("Warlock_Example", queue, abilities) ``` -------------------------------- ### Dynamic Queue Example Source: https://github.com/darhanger/ni/blob/main/docs/getting-started/quickstart.md This example showcases how to use a dynamic queue in Ni. The queue returned is determined by a condition (`ishelloprinted`), allowing for real-time adjustments to the rotation logic. It also includes two distinct abilities. ```lua local ishelloprinted = false; local queue = { "Print Hello" }; local queue2 = { "Print Hello World" }; local abilities = { ["Print Hello"] = function() ishelloprinted = true print("Hello") end, ["Print Hello World"] = function() ishelloprinted = false print("Hello World") end }; local dynamicqueue = function() if ishelloprinted then return queue end return queue2 end; ni.bootstrap.profile("Warlock_Example", dynamicqueue, abilities) ``` -------------------------------- ### Ni Rotation with Loaded Data Source: https://github.com/darhanger/ni/blob/main/docs/getting-started/quickstart.md This example illustrates how to load external data files using `ni.utils.require` and pass them to `ni.bootstrap.rotation`. It utilizes the `data.example()` function to conditionally print messages based on the player's class. ```lua local data = ni.utils.require("Data_Example"); local queue = { "Print Hello" }; local queue2 = { "Print Hello World" }; local abilities = { ["Print Hello"] = function() if data.example() == "WARLOCK" then print("Hello") return true; end end, ["Print Hello World"] = function() if data.example() ~= "WARLOCK" then print("Hello World") return true; end end }; local dynamicqueue = function() if ni.data.example.ishelloprinted then return queue end return queue2 end; ni.bootstrap.rotation("Warlock_Example", dynamicqueue, abilities, data) ``` -------------------------------- ### Data Sharing with `ni.utils.require` Source: https://github.com/darhanger/ni/blob/main/docs/getting-started/quickstart.md This snippet demonstrates how to share data and functions between Lua files in Ni. It shows how to create a 'Data_Example.lua' file, export functions using a `data` table, and then require and use this data in the main rotation file. ```lua local data = {}; data.example = function() return select(2, UnitClass("player")); end; return data; ``` -------------------------------- ### Get Object Creator GUID Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Retrieves the GUID of the object's creator, if one exists. Returns a string representing the GUID or nil. ```lua local tar = ni.objects["target"]; if tar:exists() then local creator = tar:creator(); if creator then --The object has a creator, and now we have their GUID end end ``` -------------------------------- ### Get Short Unit GUID Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the last 5 characters of a unit's GUID for easier identification. ```lua local shortGuid = ni.unit.shortguid("target") print("Short GUID of the target: " .. shortGuid) ``` -------------------------------- ### Get Units Targeting a Unit Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns a table of all units within range of a specified unit, optionally including friendlies. Each unit entry contains its GUID, name, and distance. ```lua local units = ni.unit.unitstargeting("player") for i = 1, #units do local target = units[i].guid local name = units[i].name local distance = units[i].distance -- Do something with the units targeting the player end ``` -------------------------------- ### Get Unit Information Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves detailed information about a unit, including its position, type, target, and height. ```lua local x, y, z, facing, unittype, target, height = ni.unit.info("target") ``` -------------------------------- ### ni.vars Combat Source: https://github.com/darhanger/ni/blob/main/docs/api/vars.md Variables for tracking combat status, including start time, melee settings, cooldowns, AOE, and casting. ```lua ni.vars.combat.started -- true/false for when player regen enabled/disabled (combat) ni.vars.combat.time -- time since combat started ni.vars.combat.melee -- true/false for deciding movement using follow feature ni.vars.combat.cd -- true/false for cooldown toggle enabled ni.vars.combat.aoe -- true/false for aoe toggle enabled ni.vars.combat.casting -- true/false for spell sent to server ``` -------------------------------- ### Get Unit's Target Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the GUID of the target of a specified unit. Returns nil if the unit does not exist or has no target. ```lua local target = ni.unit.target("player") if target then print("The target GUID is: " .. target) else print("Unit does not exist or has no target.") end ``` -------------------------------- ### Get Player GUID Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Retrieves the Globally Unique Identifier (GUID) of the player as a string. ```lua local playerGUID = ni.player.guid() -- Use playerGUID as needed ``` -------------------------------- ### Get Object Target GUID Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Retrieves the GUID of the object's current target. If the object has no target, it returns '0x0000000000000000'. Returns a string. ```lua local tar = ni.objects["target"]; if tar:exists() then target = tar:target(); if UnitExists(target) then --The object has a target, and now we have their GUID end end ``` -------------------------------- ### Lua ni.function Example Source: https://github.com/darhanger/ni/blob/main/docs/_template.md Demonstrates how to call the ni.function with specified arguments and handle its return values. The function takes three arguments with different type constraints and returns a table and a boolean. ```lua local t, b = ni.function("arg1", "arg2", "arg3") if b then --Do something end ``` -------------------------------- ### Get Unit Creations Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves a table of all creations (totems, pets) associated with a target unit. Returns nil if no creations are found. ```lua local creations = ni.unit.creations("player"); for i = 1, #creations do local creature = creations[i] -- Do something end ``` -------------------------------- ### Object Manager: Get Object GUID Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Retrieves the GUID of an object based on its token, GUID, or name, provided it's within the object manager's scope. Returns the GUID as a string or nil if not found. ```lua local lich_king = ni.objectmanager.objectGUID("The Lich King"); if lich_king ~= nil then --The Lich King is within our memory scope distance, and we now have his GUID to work with on other functions. end ``` -------------------------------- ### Check if Unit is in Preparation Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks if a unit is in preparation mode. It takes a unit identifier (GUID or token) and returns true if in preparation, false otherwise. ```lua if ni.unit.ispreparation("target") then print("The unit is in preparation mode.") end ``` -------------------------------- ### Get Channeling Percentage Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Calculates the percentage of completion for a unit's currently channeled spell. ```lua local channelingPercent = ni.unit.channelpercent("target") print("Channeling percentage of the target: " .. channelingPercent .. "%") ``` -------------------------------- ### Player Shorthand and Buff Example Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Demonstrates how Player API functions can be used as shorthand for Unit API calls, specifically for applying buffs and checking player stats. This highlights the convenience of the Player API for common actions. ```lua ni.player.buff("Life Tap") -- Same as calling ni.unit.buff("player", "Life Tap") ni.player.hp() -- Same as calling ni.unit.hp("player") ``` -------------------------------- ### Get Readable Unit Creature Type Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the human-readable string representation of a unit's creature type. ```lua local type = ni.unit.readablecreaturetype("playerpet") if type == "Demon" then -- Do something end ``` -------------------------------- ### Iterate and Interact with Objects Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Demonstrates iterating through all objects in the `ni.objects` table, filtering by name and creator, and interacting with them based on memory read results. This example specifically targets a 'Fishing Bobber' created by the player. ```lua local playerguid = UnitGUID("player"); for k, v in pairs(ni.objects) do if type(k) ~= "function" and (type(k) == "string" and type(v) == "table") then if v.name == "Fishing Bobber" then local creator = v:creator(); if creator == playerguid then local ptr = ni.memory.objectpointer(v.guid); if ptr then local result = ni.memory.read("byte", ptr, offset); if result == 1 then ni.player.interact(v.guid); return true; end end end end end ``` -------------------------------- ### Get Object Pointer Source: https://github.com/darhanger/ni/blob/main/docs/api/memory.md Returns the memory pointer for a given object, identified by a token or GUID. The pointer can be obtained as a numeric value or a formatted string. This is useful for accessing specific object data in memory. ```lua local ptr = ni.memory.objectpointer("player"); ``` -------------------------------- ### Get Casting Percentage Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Calculates the percentage of completion for a unit's currently casting spell. ```lua local castingPercent = ni.unit.castingpercent("target") print("Casting percentage of the target: " .. castingPercent .. "%") ``` -------------------------------- ### Get Unit Health Percentage Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Calculates and returns the current health of a unit as a percentage. ```lua if ni.unit.hp("target") > 90 then -- Unit has more than 90% hp end ``` -------------------------------- ### Get Debuff Stacks Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Obtains the number of stacks for a specific debuff on a target unit. An optional filter can be applied. ```lua if ni.unit.debuffstacks("target", 1234) < 5 then -- Target has less than 5 stacks of 1234 on them end ``` -------------------------------- ### Get Unit Location Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the X, Y, and Z coordinates of a unit's location. ```lua local x, y, z = ni.unit.location("target"); --Do something with the x, y, and z'second ``` -------------------------------- ### Get Unit Flags Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the static flags associated with a specified unit. Returns a table containing these flags. ```lua local flags = ni.unit.flags("target") print(flags) ``` -------------------------------- ### Get Player Specialization Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Returns a string representing the player's current specialization, determined by talent point allocation. ```lua local spec = ni.player.getspec() if spec == "WarriorProtection" then -- Player is spec'd into Warrior Protection end ``` -------------------------------- ### Find Enemies in Range Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns a table containing all enemies within a specified range of a given unit. Each enemy entry includes their GUID, name, and distance. ```lua local enemies = ni.unit.enemiesinrange("player", 30) for i = 1, #enemies do local target = enemies[i].guid local name = enemies[i].name local distance = enemies[i].distance -- Do something with the enemy target end ``` -------------------------------- ### Object: Get Information Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Retrieves detailed information about an object using the 'info' function. Returns multiple values including position, facing, type, target, and height. Requires the object to exist. ```lua local tar = ni.objects["focus"]; if tar:exists() then local x, y, z, facing, type, target, height = tar:info() if target ~= 0 then --We have the target GUID of the object. end end ``` -------------------------------- ### Get Unit ID Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the unique identifier (ID) for a given unit. ```lua if ni.unit.id("target") == 36597 then -- Unit is Lich King end ``` -------------------------------- ### Get Health Percentage Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Returns the current health of the unit as a percentage (number). ```lua for i = 1, #ni.members do if ni.members[i]:hp() < 20 then -- This member is below 20% health end end ``` -------------------------------- ### Accessing Member Subgroup Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Checks the subgroup number of raid party members. This example demonstrates actions for members in subgroup 1 or 2. ```lua for i = 1, #ni.members do if ni.members[i]:subgroup == 1 or ni.members[i]:subgroup == 2 then -- Do something only for members with 1 and 2 subgroup from raid (10 ppl) end end ``` -------------------------------- ### Check if Unit is Mounted Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Verifies if a unit is mounted. The function accepts a unit identifier (GUID or token) and returns a boolean. ```lua if ni.unit.ismounted("target") then print("The unit is mounted.") end ``` -------------------------------- ### Get Unit Dynamic Flags Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the dynamic flags associated with a specified unit. Returns a table containing these flags. ```lua local dynamicFlags = ni.unit.dynamicflags("target") print(dynamicFlags) ``` -------------------------------- ### Move Player Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Allows the player to move to a specified target or coordinates. The target can be a unit token, GUID, or specific x,y,z coordinates. ```lua ni.player.moveto("target") ``` -------------------------------- ### Check if Unit Can Perform Actions Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Determines if actions can be performed on a given unit. It takes a unit identifier (GUID or token) as input and returns a boolean value. ```lua if ni.unit.canperformaction("target") then print("You can perform actions on this unit.") end ``` -------------------------------- ### Find Friends in Range Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns a table of all friendly units within a specified range of a given unit. Each entry includes the friendly unit's GUID, name, and distance. ```lua local friends = ni.unit.friendsinrange("player", 30) for i = 1, #friends do local target = friends[i].guid local name = friends[i].name local distance = friends[i].distance -- Do something with the friendly target end ``` -------------------------------- ### Check if Unit is Pacified Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Verifies if a unit is pacified. It requires a unit identifier (GUID or token) and returns true if pacified, false otherwise. ```lua if ni.unit.ispacified("target") then print("The unit is pacified.") end ``` -------------------------------- ### Check if Unit is Confused Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks if a unit is currently in a confused state. It requires a unit identifier (GUID or token) and returns true if confused, false otherwise. ```lua if ni.unit.isconfused("target") then print("The unit is confused.") end ``` -------------------------------- ### Get Debuff Timer Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the remaining time of a specific debuff on a target unit. The debuff is identified by its string name. ```lua local remainingTime = ni.unit.debufftypetimer("target", "Magic") print("Remaining time of Magic buff: " .. remainingTime .. " seconds") ``` -------------------------------- ### Get Unit Buff Stacks Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the number of stacks for a specific buff on a unit, identified by name or ID. An optional filter can specify the buff's owner. ```lua if ni.unit.buffstacks("target", 1234) < 5 then -- Target has less than 5 stacks of 1234 on them end ``` -------------------------------- ### Find Enemies in Range with Buff Type Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves a list of enemies within a specified range that possess a particular buff type. Returns a table containing enemy GUID, name, and distance. ```lua local enemies = ni.unit.enemiesinrangewithbufftype("player", 30, "Magic") for i = 1, #enemies do -- Do something with the enemy target with buffs end ``` -------------------------------- ### Check if Unit is Not Attackable Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks if a unit is not attackable. It requires a unit identifier (GUID or token) and returns true if not attackable, false otherwise. ```lua if ni.unit.isnotattackable("target") then print("The unit is not attackable.") end ``` -------------------------------- ### Get Object Location and Facing Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Returns a table containing the object's location (x, y, z) and facing (r). This data can be used for various spatial calculations. ```lua local tar = ni.objects["target"]; if tar:exists() then local location = tar:location(); --Do something with the location.x, location.y, location.z and location.r of the object end ``` -------------------------------- ### Useful Resources Source: https://github.com/darhanger/ni/blob/main/docs/_sidebar.md This section links to external resources relevant to the Darhanger NI project, including PvE and PvP profiles, as well as community servers for interaction and support. ```markdown - [PvE Profiles](https://darhanger.github.io/rotations/) - [PvP Profiles](https://discord.gg/4FC8rwy) - [Project Server](https://discord.gg/ZKFkvrzaU4) ``` -------------------------------- ### Get Unit Power Percentage Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Calculates and returns the current power percentage (e.g., mana, energy) of a unit. An optional type parameter can specify the power type. ```lua if ni.unit.power("target") > 90 then -- Unit has more than 90% power end ``` -------------------------------- ### Check if Unit is Stunned Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Determines if a unit is stunned. It requires a unit identifier (GUID or token) and returns true if stunned, false otherwise. ```lua if ni.unit.isstunned("target") then print("The unit is stunned.") end ``` -------------------------------- ### API Documentation Overview Source: https://github.com/darhanger/ni/blob/main/docs/_sidebar.md This section provides links to detailed API documentation for various modules within the Darhanger NI project. Each link leads to specific documentation for functionalities like Debug, Generic, Healing, Members, Memory, Object Manager, Player, Power, Rune, Spell, Unit, and Vars. ```APIDOC Debug API Documentation: Provides details on debugging functionalities. Generic API Documentation: Covers generic functionalities and utilities. Healing API Documentation: Details the healing mechanics and related functions. Members API Documentation: Information on managing members and their properties. Memory API Documentation: Documentation for memory management and access. Object Manager API Documentation: Details on the object management system. Player API Documentation: Information related to player-specific functionalities. Power API Documentation: Documentation for power systems and mechanics. Rune API Documentation: Details on rune functionalities and usage. Spell API Documentation: Information on spell casting and related systems. Unit API Documentation: Documentation for unit-based functionalities. Vars API Documentation: Details on variable management and access. ``` -------------------------------- ### Get Skill Information Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Retrieves the current skill level for a given profession. The profession can be specified by name or by a spell ID related to the profession. ```lua local skillLevel = ni.player.getskillinfo("Blacksmithing") if skillLevel >= 300 then -- Player's Blacksmithing skill is at least 300 end local skillLevel = ni.player.getskillinfo(GetSpellInfo(7411)) if skillLevel >= 300 then -- Player's Enchanting skill is at least 300 end ``` -------------------------------- ### ni.vars Units Source: https://github.com/darhanger/ni/blob/main/docs/api/vars.md Variables related to unit management, including follow settings and main/off-tank configurations. ```lua ni.vars.units.follow ni.vars.units.followEnabled ni.vars.units.mainTank ni.vars.units.mainTankEnabled ni.vars.units.offTank ni.vars.units.offTankEnabled ``` -------------------------------- ### Supported Read Types Source: https://github.com/darhanger/ni/blob/main/docs/api/memory.md Lists the accepted string arguments for the `read` function, specifying the data type to be read from memory. These types include boolean, byte, string, float, double, various integer sizes, and GUIDs. ```lua "bool" --true/false formatted "byte" --number formatted "string" --string formatted "float" --number formatted "double" --number formatted "int16"/"short" --number formatted "int32"/"int" --number formatted "int64" --string formatted formatted "uint16"/"ushort" --number formatted "uint"/"uint32" --number formatted "uint64"/"GUID" --string formatted ``` -------------------------------- ### ni (v2) Features Overview Source: https://github.com/darhanger/ni/blob/main/docs/README.md This section outlines the key features of the ni (v2) profile framework for World of Warcraft. It details the supported game versions and core functionalities. ```APIDOC ni (v2) Features: - Wrapper for Protected Lua Functions - Anti Warden - Support for 3.3.5, 4.3.4, 5.4.8 only - Party/Raid Support - Object Manager - Ground Spells Support - Healing Engine - Time to Die Calculations - Framework for Top Tier PvE/PvP Profiles ``` -------------------------------- ### Set Player Target Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Sets the player's current target to a specified unit, identified by token or GUID. Can also target specific units like 'focus' or 'party1'. ```lua ni.player.target("focus") -- Sets the player's target to the focus target ni.player.target("party1") -- Sets the player's target to the first party membe ``` -------------------------------- ### Get Unit Raw Power Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Calculates and returns the current raw power value (e.g., mana, energy) of a unit. An optional type parameter can specify the power type. ```lua if ni.unit.powerraw("target") > 10000 then -- Unit has more than 10000 power end ``` -------------------------------- ### Get Buff Type Remaining Time Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the remaining time in seconds for a buff of a given type on a unit. The unit can be specified by token, GUID, or string. ```lua local remainingTime = ni.unit.bufftypetimer("target", "Magic") print("Remaining time of Magic buff: " .. remainingTime .. " seconds") ``` -------------------------------- ### ni.vars Profiles Source: https://github.com/darhanger/ni/blob/main/docs/api/vars.md Variables for managing different profiles, including primary, secondary, active, generic profiles, and their enabled states. ```lua ni.vars.profiles.primary --Name of the primary profile ni.vars.profiles.secondary --Name of the secondary profile ni.vars.profiles.active --Name of the active profile ni.vars.profiles.generic --Name of the generic profile ni.vars.profiles.genericenabled --Generic profile is enabled ni.vars.profiles.interrupt --Interrupt engine is enabled ni.vars.profiles.enabled --Active profile is enabled ni.vars.profiles.useEngine --Enables/Disables the members table ni.vars.profiles.delay --Time to delay the profile execution until (should not be set via the variable itself) ``` -------------------------------- ### Getting Members within Range Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Returns a table containing all members within a specified distance of a given unit. This is useful for proximity-based actions or checks. ```lua local members_around_me = ni.members.inrange("player", 10); --Returns a table of all the members within 10 yards of the player ``` -------------------------------- ### Get Unit Location Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md The location() function returns the unit's current position (x, y, z) and rotation (r) in the game world. It returns four numbers. ```lua for i = 1, #ni.members do local x, y, z, r = ni.members[i]:location() if x and y and z and r then -- The unit's location was successfully retrieved end end ``` -------------------------------- ### Get Unit's Transport Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the GUID of a unit's transport if they are using one (e.g., in a vehicle or on another unit). Returns nil if no transport is found. ```lua local transport = ni.unit.transport("target") if transport then --The target has a transport, maybe we need to kill that instead now? end ``` -------------------------------- ### ni.vars Hotkeys Source: https://github.com/darhanger/ni/blob/main/docs/api/vars.md Variables related to hotkey configurations for various actions. ```lua ni.vars.hotkeys.aoe ni.vars.hotkeys.cd ni.vars.hotkeys.pause ni.vars.hotkeys.custom ``` -------------------------------- ### NI Members: addcustom Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Adds a custom member to the members table. It can optionally take a GUID if not provided, it will be obtained using UnitGUID(unit). After adding, it updates the members table. ```APIDOC addcustom(unit: string, guid: string = nil) unit: The name of the unit to add as a custom member. guid: Optional. The GUID of the unit to add. If not provided, it will be obtained using UnitGUID(unit). Description: Adds a custom member to the members table, creating a new GroupMember object and updating the members table via updatemembers. ``` -------------------------------- ### Power API Documentation Source: https://github.com/darhanger/ni/blob/main/docs/api/power.md Provides detailed information on the ni.power module functions for managing unit power. ```APIDOC ni.power: Functions for managing unit power. current(unit, type): Calculates unit's current power percent. Arguments: - unit: guid|token - type: name|id Returns: number Example: local power = ni.power.current("player") -- 90% currentraw(unit, type): Calculates unit's current power. Arguments: - unit: guid|token - type: name|id Returns: number Example: local power = ni.power.currentraw("player") -- 20000 mana max(unit, type): Calculates unit's maximum power. Arguments: - unit: guid|token - type: name|id Returns: number Example: local maxpower = ni.power.max("target") ismax(unit, type): Checks if unit's power is at its maximum. Arguments: - unit: guid|token - type: name|id Returns: boolean Example: if ni.power.ismax("player") then -- Player's power is at 100% end gettype(t): Retrieves the power type of the specified unit. Arguments: - t: token|guid Returns: number Example: local powerType = ni.power.gettype("player") if powerType == 0 then -- Player is using mana elseif powerType == 1 then -- Player is using rage end Power Types: A table that maps various power types to their corresponding numeric IDs. | Power Type | ID | |------------------|-----| | `mana` | 0 | | `rage` | 1 | | `focus` | 2 | | `energy` | 3 | | `combopoints` | 4 | | `runes` | 5 | | `runicpower` | 6 | | `soulshards` | 7 | | `eclipse` | 8 | | `holy` | 9 | | `alternate` | 10 | | `darkforce` | 11 | | `chi` | 12 | | `shadoworbs` | 13 | | `burningembers` | 14 | | `demonicfury` | 15 | ``` -------------------------------- ### Get Unit Time To Die (TTD) Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the estimated time to die for a unit in seconds. Returns specific values for non-existent, dummy, or units with skipped TTD calculations. ```lua if ni.unit.ttd("target") > 10 then -- Do something end ``` -------------------------------- ### Get Enchantment ID Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Returns the enchantment ID applied to an item equipped in a specified inventory slot. For example, slot 16 typically refers to the main hand weapon. ```lua local enchantId = ni.player.getenchantid(16) -- Gets the enchantment ID for the main hand weapon if enchantId == 2673 then -- Player's main hand weapon has the Crusader enchant end ``` -------------------------------- ### Getting Members within Range and Below HP Threshold Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Returns a table of members who are both within a specified distance of a unit and have a health percentage below a given threshold. This helps in identifying members needing immediate attention. ```lua local members_below = ni.members.inrangebelow("player", 10, 60); --Returns a table of all the members within 10 yards of the player that are below 60% health ``` -------------------------------- ### Object: Get Power Percentage Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Retrieves the current percentage of an object's power (e.g., mana, energy) using the 'power' function. An optional 'type' argument can specify the power type. Requires the object to exist. ```lua local tar = ni.objects["target"]; if tar:exists() and tar:power("mana") >= 80 then --Target has, or has more than, 80% mana end ``` -------------------------------- ### General ni.vars Source: https://github.com/darhanger/ni/blob/main/docs/api/vars.md General variables for ni, including latency, interrupt settings, build version, debug mode, and custom target. ```lua ni.vars.latency -- interval between executing the rotation ni.vars.interrupt -- could be `all` or `wl` or `bl` ni.vars.build -- build version of currently running client ni.vars.debug -- true/false to print when using ni.debug.print ni.vars.customtarget -- token or guid of custom target ``` -------------------------------- ### Object: Access GUID Property Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Accesses the 'guid' variable of an object to retrieve its unique identifier. Requires the object to exist. ```lua local tar = ni.objects["target"]; if tar:exists() then print(tar.guid) --Would print the GUID of the target end ``` -------------------------------- ### Iterating Through Members Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Demonstrates different ways to iterate through the ni.members list, including unsorted, sorted by range, and sorted by range and HP. ```lua for i = 1, #ni.members do ... end ``` ```lua for i = 1, #ni.members.inrange("player", 40) do ... end ``` ```lua for i = 1, #ni.members.sort() do ... end ``` -------------------------------- ### Get Buff Stacks Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Retrieves the number of stacks for a specific buff on a unit. The filter argument can be used to specify if the buff must be EXACTly matched or if it's a buff cast by the PLAYER. If no filter is specified, the first matching buff found is returned. ```lua for i = 1, #ni.members do if ni.members[i]:buffstacks("Earth Shield") < 3 then -- This member has Earth Shield less then 3 stacks end end ``` -------------------------------- ### Docsify Configuration Source: https://github.com/darhanger/ni/blob/main/docs/index.html Configuration object for the docsify static site generator. This includes settings for the site name, logo, repository link, cover page, automatic scrolling, script execution, sidebar loading, heading levels, Google Analytics tracking, and search functionality. ```javascript window.$docsify = { name: "ni (nHub)", logo: 'logo.png height="52px"', repo: "https://github.com/darhanger/ni", coverpage: true, auto2top: true, executeScript: true, loadSidebar: true, maxLevel: 4, subMaxLevel: 3, gtag: [ 'G-C40H56NC3Y', 'UA-275906865-1' ], search: { maxAge: 86400000, paths: "auto", placeholder: "Search api", noData: "No Results", depth: 6, hideOtherSidebarContent: false, namespace: "website-1", alias: { "/.*/\_sidebar.md": "/\_sidebar.md" } } }; ``` -------------------------------- ### Get Maximum Health Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Returns the maximum health of the unit as a number. ```lua for i = 1, #ni.members do local maxHealth = ni.members[i]:hpmax() ... end ``` -------------------------------- ### Run Macro Text Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Executes a given string as if it were typed into the game's macro command line. ```lua ni.player.runtext("/s Hello") -- writes "Hello" to Say channel. ``` -------------------------------- ### Get Raw Health Source: https://github.com/darhanger/ni/blob/main/docs/api/members.md Returns the absolute current health of the unit as a number. ```lua for i = 1, #ni.members do if ni.members[i]:hpraw() < 30000 then -- This member has less then 30000 health end end ``` -------------------------------- ### Reload UI Commands in Lua Source: https://github.com/darhanger/ni/blob/main/docs/getting-started/faq.md These Lua slash commands can be used to reload profiles while a game is running. They offer different levels of verbosity for the reload action. ```lua /reload ui /reload /rl ``` -------------------------------- ### Require Module Loading Source: https://github.com/darhanger/ni/blob/main/docs/api/generic.md A custom 'require' function that loads Lua files from the 'Data' folder or absolute paths. It caches loaded files to prevent multiple loads and returns the loaded content. The '.lua' extension is optional. ```lua local data = ni.utils.require("Example"); --This will load the data file called Example.lua from the data folder into the local variable data print(example.version()); --In the example file there is already a function called "version", so here it would print the version ``` -------------------------------- ### Get Unit Raw Health Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Calculates and returns the current raw health value of a unit. ```lua if ni.unit.hpraw("target") > 20000 then -- Unit has more than 20k hp end ``` -------------------------------- ### Get Unit Combat Reach Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the combat reach of a unit. Defaults to 0 if not specified. ```lua local combatreach = ni.unit.combatreach("player"); -- Would most likely print 1.5 as the combat reach of the player unit ``` -------------------------------- ### Object: Check if Can Assist Source: https://github.com/darhanger/ni/blob/main/docs/api/object-manager.md Determines if an object can assist a specified token or the player if no token is provided. Returns a boolean. Requires the object to exist. ```lua local tar = ni.objects["target"]; if tar:exists() and tar:canassist() then --Object can assist the player (They're friendly). end ``` -------------------------------- ### Unit Combat and Relationship Checks Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Functions to determine combat capabilities and relationships between units. ```APIDOC canattack(tar1: token|guid, tar2: token|guid): boolean Checks if the first unit can attack the second unit. canassist(tar1: token|guid, tar2: token|guid): boolean Checks if the first unit can assist the second unit. isenemy(tar1: token|guid, tar2: token|guid): boolean Checks if the first unit is an enemy of the second unit. isunit(tar1: token|guid, tar2: token|guid): boolean Checks if the first unit is the same as the second unit. ``` -------------------------------- ### Unit Creator Retrieval Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves the creator of a unit, if one exists. ```APIDOC creator(target: guid|token): guid|nil Returns the GUID of the unit's creator, or nil if it has no creator. ``` -------------------------------- ### Get Player Moving Time Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Returns the total time the player has been moving. The returned value is in seconds. ```lua if ni.player.getmovingtime() > 60 then --The player has been moving for more than 60 seconds end ``` -------------------------------- ### Check if Unit is Skinnable Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks if a unit is skinnable. The function takes a unit identifier (GUID or token) and returns a boolean. ```lua if ni.unit.isskinnable("target") then print("The unit is skinnable.") end ``` -------------------------------- ### Ni Spell API Source: https://github.com/darhanger/ni/blob/main/docs/api/spell.md Provides an overview of the available spell-related functions within the Ni library. ```APIDOC bestaoeloc(distance: number, radius: number, friendly?: boolean, minimumcount?: number, inc?: number, zindex_inc?: number): X/Y/Z Calculates the best location for an AoE spell. castharmfulatbest(spell: id|string, distance: number, radius: number, minimumcount?: number, inc?: number, zindex_inc?: number): void Casts a harmful spell at the best location. casthelpfulatbest(spell: id|string, distance: number, radius: number, minimumcount?: number, inc?: number, zindex_inc?: number): void Casts a helpful spell at the best location. castqueue(spell: id|string, target: token|guid): void Queues a spell to be cast on a target. castatqueue(spell: id|string, target: token|guid|mouse): void Queues a spell to be cast on the ground. stopcasting(): void Stops the current casting action. stopchanneling(): void Stops the current channeling action. valid(spell: id|string, target: token|guid, facing?: boolean, los?: boolean, friendly?: boolean): boolean Checks if a spell can be cast on a target. castinterrupt(t: token|guid): void Interrupts a target's casting or channeling. shouldinterrupt(t: token|guid, p?: number): boolean Determines if a target's spell should be interrupted. ``` -------------------------------- ### Check if Unit is Not Selectable Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Determines if a unit is not selectable. The function takes a unit identifier (GUID or token) and returns a boolean. ```lua if ni.unit.isnotselectable("target") then print("The unit is not selectable.") end ``` -------------------------------- ### Log Message to Console Source: https://github.com/darhanger/ni/blob/main/docs/api/debug.md Logs a message to the console within the ni application. An optional boolean parameter can be used to indicate if the message is an error. ```lua ni.debug.log("Test") ``` -------------------------------- ### Check if Unit is Possessed Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Verifies if a unit is possessed. The function requires a unit identifier (GUID or token) and returns a boolean. ```lua if ni.unit.ispossessed("target") then print("The unit is possessed.") end ``` -------------------------------- ### Check Player Item Readiness Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Checks if a specific inventory item is ready for use, meaning the player has the item, it's off cooldown, and can be used. It takes the item's slot ID. ```lua if ni.player.itemready(41119) then -- Player have bomb and can use it end ``` -------------------------------- ### Check Item Equipping Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Verifies if a specific item is currently equipped by the player, identified by its item ID. ```lua if ni.player.hasitemequipped(51378) then -- Player has equipped item Medallion of the Horde end ``` -------------------------------- ### Interact with Unit Source: https://github.com/darhanger/ni/blob/main/docs/api/player.md Initiates an interaction with a specified unit. This can include opening dialogue with NPCs or looting containers. ```lua ni.player.interact("target") ``` -------------------------------- ### Get Spell Cast Time Source: https://github.com/darhanger/ni/blob/main/docs/api/spell.md Calculates the cast time of a specified spell. Accepts spell ID or name. ```lua local casttime = ni.spell.casttime("Immolate") -- 1.25 ``` -------------------------------- ### List Unit Auras Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Retrieves a table containing all auras present on a unit, including their ID and name. This is useful for developers to identify all auras for use with other functions, even those not normally visible to the client. ```lua local auras = ni.unit.auras("target"); for k, v in ipairs(auras) do if v.name == "Crusader Aura" then --The unit has the aura Crusader Aura by name check end if v.ID == 32223 then --The unit has the aura Crusader Aura by ID check end end ``` -------------------------------- ### Check Available Runes Source: https://github.com/darhanger/ni/blob/main/docs/api/rune.md Calculates and returns the total number of runes currently available to the player. This can be used to check if all runes are ready for use. ```lua if ni.rune.available() == 6 then -- Player has all 6 runes available end ``` -------------------------------- ### Check if Unit is Immune Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Verifies if a unit is immune to effects. The function accepts a unit identifier (GUID or token) and returns a boolean. ```lua if ni.unit.isimmune("target") then print("The unit is immune.") end ``` -------------------------------- ### Check if Unit is Fleeing Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks if a unit is currently fleeing. The function requires a unit identifier (GUID or token) and returns a boolean. ```lua if ni.unit.isfleeing("target") then print("The unit is fleeing.") end ``` -------------------------------- ### Get Debuff Duration Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the total duration of a specific buff on a unit, identified by its spell ID. An optional filter can be provided. ```lua local debuffDuration = ni.unit.debuffduration("target", 1234) print("Duration of buff: " .. debuffDuration .. " seconds") ``` -------------------------------- ### Check if Unit is Dummy Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks whether a unit is a dummy unit. ```lua if ni.unit.isdummy("target") then -- Do something end ``` -------------------------------- ### Get Unit Creature Type Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Returns the numerical type of a given unit. This can be used to identify specific creature types, such as demons. ```lua local type = ni.unit.creaturetype("playerpet") if type == 3 then --Our pet is a demon end ``` -------------------------------- ### Check Unit Buffs (AND/OR) Source: https://github.com/darhanger/ni/blob/main/docs/api/unit.md Checks if a unit has multiple buffs, using '&&' for AND logic and '||' for OR logic. Buffs can be specified by name or ID, with an optional filter for the buff's owner. ```lua if ni.unit.buffs("target", "63321&&Fel Armor", "player") then -- Target has both Life Tap and Fel Armor end if ni.unit.buffs("target", "63321||Fel Armor") then -- Target has either Life Tap, or Fel Armor end ``` -------------------------------- ### Get Spell ID by Name Source: https://github.com/darhanger/ni/blob/main/docs/api/spell.md Converts a spell's name into its corresponding ID. Returns nil if the spell does not exist. ```lua local spellid = ni.spell.id("Life Tap") -- 57946 ```