### Create Plugin Menu Options (menu.lua) Source: https://badspacebar.github.io/sdk/docs/examples Defines the user-configurable menu options for the plugin. This includes settings like toggling features and selecting colors, allowing users to customize the plugin's behavior. ```lua local menu = menu('simple_range_draw', 'Range Draw') menu:header('settings', 'Settings') menu:boolean('draw_range', 'Draw Attack Range', true) menu:color('range_color', 'Color', 255, 255, 255, 255) return menu ``` -------------------------------- ### Implement Plugin Logic (main.lua) Source: https://badspacebar.github.io/sdk/docs/examples The main entry point for the plugin's logic. It loads menu configurations and registers callbacks, such as drawing functions, to execute when specific game events occur. ```lua -- Load the menu.lua module local menu = module.load('simple_range_draw', 'menu') -- Register the draw callback cb.add(cb.draw, function() -- Check if the menu option is enabled if menu.draw_range:get() then -- Get the current attack range local range = player.attackRange + player.boundingRadius -- Get the color from the menu local color = menu.range_color:get() -- Draw the circle graphics.draw_circle(player.pos, range, 2, color, 100) end end) print('Simple Range Draw loaded!') ``` -------------------------------- ### Define Plugin Metadata (header.lua) Source: https://badspacebar.github.io/sdk/docs/examples Defines the essential metadata for a Hanbot plugin, including its unique ID, name, and load conditions. This file is crucial for the Hanbot system to recognize and manage the plugin. ```lua return { id = 'simple_range_draw', name = 'Simple Range Draw', load = function() return true -- Always load end, } ``` -------------------------------- ### Hero Status and Stats Source: https://badspacebar.github.io/sdk/docs/objects Functions to get information about a hero's health, abilities, and stats at different levels. ```APIDOC ## Hero Status and Stats ### Description Provides functions to retrieve a hero's base health, ability resource values, and general stats based on level. ### Methods #### `hero:baseHealthForLevel(level)` * **Description**: Returns the base health of the hero for a given level. * **Parameters**: * `level` (number) - The hero's level. * **Return Value**: number - The base health at the specified level. #### `hero:abilityResourceBase(slot)` * **Description**: Returns the base ability resource value (e.g., mana) for a given slot, calculated with level factor. * **Parameters**: * `slot` (number) - The ability resource slot (usually 0 for mana). * **Return Value**: number - The base ability resource value. #### `hero:abilityResourceForLevel(slot, level)` * **Description**: Returns the ability resource value for a specific level. * **Parameters**: * `slot` (number) - The ability resource slot (usually 0 for mana). * `level` (number) - The hero's level. * **Return Value**: number - The ability resource value for the specified level and slot. #### `hero:statForLevel(type, level)` * **Description**: Returns a specific stat of the hero for a given level. * **Parameters**: * `type` (number) - The type of stat to retrieve. * `level` (number) - The hero's level. * **Return Value**: number - The value of the specified stat at the given level. ``` -------------------------------- ### Print a vec2 Vector in Lua Source: https://badspacebar.github.io/sdk/docs/math Provides a simple example of how to print the components of a vec2 vector to the console. This is helpful for debugging and visualizing vector values. ```lua local a = vec2(mousePos.x, mousePos.z) a:print() ``` -------------------------------- ### Get Module Path - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Returns the file system path of a given module ID. This is useful for accessing module-specific resources or configuration files. ```lua local module_path = module.path('my_module') print(module_path) ``` -------------------------------- ### Handle Minion Creation and Deletion with cb.create_minion and cb.delete_minion (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries These examples demonstrate how to handle the creation and deletion of minions using cb.create_minion and cb.delete_minion events. Both callbacks receive a minion object, though properties of the deleted minion object are unsafe to access. ```lua local function on_create_minion(obj) print(obj.name, obj.charName) end local function on_delete_minion(obj) --obj is invalid within the scope of this function, it is dangerous to check obj properties other than .ptr print(obj.ptr) end cb.add(cb.create_minion, on_create_minion) cb.add(cb.delete_minion, on_delete_minion) ``` -------------------------------- ### Get Clipboard Text - Keyboard SDK Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves text currently stored in the system clipboard. Returns the clipboard content as a string on success, or an error message string on failure. ```lua local clipboard_text = keyboard.getClipboardText() print(clipboard_text) ``` -------------------------------- ### Find and Get Buff Information Source: https://badspacebar.github.io/sdk/docs/objects Allows finding a buff on a hero by its FNV hash and retrieving its stack count or a secondary count. It returns a buff object or 0 if the buff is not found. ```lua local ezrealPassiveHash = game.fnvhash("ezrealpassivestacks") local stacks = player:getBuffStacks(ezrealPassiveHash) if stacks > 0 then print("Ezreal passive stacks: " .. stacks) end local buffCount = player:getBuffCount(ezrealPassiveHash) print("Buff count: " .. buffCount) ``` -------------------------------- ### Handle Particle Creation and Deletion with cb.create_particle and cb.delete_particle (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries These examples illustrate handling particle creation and deletion using cb.create_particle and cb.delete_particle events. The create callback provides particle name and coordinates, while the delete callback offers a safe pointer. ```lua local function on_create_particle(obj) print(obj.name, obj.x, obj.z) end local function on_delete_particle(obj) --obj is invalid within the scope of this function, it is dangerous to check obj properties other than .ptr print(obj.ptr) end cb.add(cb.create_particle, on_create_particle) cb.add(cb.delete_particle, on_delete_particle) ``` -------------------------------- ### Get Spell Damage Details Source: https://badspacebar.github.io/sdk/docs/modules Retrieves detailed damage information for a specific spell. It allows specifying spell name, slot, source, target, and whether to include raw spell damage or calculated damage considering resistances and buffs. Examples show how to get damage for various Briar abilities. ```lua local damagelib = module.internal('damagelib') -- Briar print('Passive min', damagelib.get_spell_damage('BriarP', 63, player, g_target, false, 0)) print('Passive max', damagelib.get_spell_damage('BriarP', 63, player, g_target, false, 1)) print('Q', damagelib.get_spell_damage('BriarQ', 0, player, g_target, false, 0)) print('W', damagelib.get_spell_damage('BriarW', 1, player, g_target, false, 0)) print('W2', damagelib.get_spell_damage('BriarWAttackSpell', 1, player, g_target, false, 0)) -- available when W2 ready print('E', damagelib.get_spell_damage('BriarE', 2, player, g_target, false, 0)) print('R', damagelib.get_spell_damage('BriarR', 3, player, g_target, false, 0)) ``` -------------------------------- ### Check for Direct Path and Get Last Reached Position (Lua) Source: https://badspacebar.github.io/sdk/docs/objects This example demonstrates how to check if a direct path exists between two points using `isDirectPath`. It returns a boolean indicating if the path is direct and an array of numbers representing the last reached position. The code logs the x and y coordinates of the last reached position if the path is direct. ```lua local isDirect,lastReachedPos = player.path:isDirectPath(player.pos, mousePos) if isDirect then print('lastReachedPos.x', lastReachedPos[0]) print('lastReachedPos.y', lastReachedPos[1]) end ``` -------------------------------- ### Get Perpendicular vec2 Vector (Left) in Lua Source: https://badspacebar.github.io/sdk/docs/math Demonstrates how to get a perpendicular vec2 vector rotated 90 degrees counter-clockwise (left) relative to the original vector. This is achieved by swapping components and negating one. ```lua local a = mousePos2D-player.pos2D local b = a:norm() local c = b:perp1() c:print() ``` -------------------------------- ### Create Library Directory - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Creates a directory intended for library files within the module system. Returns true on successful creation, false otherwise. ```lua local success = module.create_lib_directory('libs/my_new_libs') print(success) ``` -------------------------------- ### orb.menu.hybrid.key:get() Source: https://badspacebar.github.io/sdk/docs/modules Checks if the hybrid mode is currently active. ```APIDOC ## orb.menu.hybrid.key:get() ### Description Checks if the hybrid mode is currently active. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters None ### Request Example ```lua if orb.menu.hybrid.key:get() then print('Hybrid mode is ON') else print('Hybrid mode is OFF') end ``` ### Response #### Success Response (200) - **boolean** - Returns `true` if hybrid mode is active, `false` otherwise. #### Response Example ```json true ``` ``` -------------------------------- ### Hero Combat and Movement Utilities Source: https://badspacebar.github.io/sdk/docs/objects Functions related to hero's basic attacks, attack delays, and finding passable positions. ```APIDOC ## Hero Combat and Movement Utilities ### Description Provides utility functions for hero's combat capabilities, attack timing, and pathfinding. ### Methods #### `hero:basicAttack(index)` * **Description**: Retrieves the basic attack spell object. * **Parameters**: * `hero` (hero.obj) - The hero object. * `index` (number) - The index of the basic attack spell (-1 for default). * **Return Value**: spell.obj #### `hero:attackDelay()` * **Description**: Returns the current attack delay of the hero. * **Parameters**: * `hero` (hero.obj) - The hero object. * **Return Value**: number #### `hero:attackCastDelay(slot)` * **Description**: Returns the cast delay for a specific spell slot. * **Parameters**: * `hero` (hero.obj) - The hero object. * `spellSlot` (number) - The spell slot index. * **Return Value**: number #### `hero:getPassablePos(to)` * **Description**: Finds the nearest passable position to a target position, considering hero collision. * **Parameters**: * `hero` (hero.obj) - The hero object. * `to` (vec3) - The target position. * **Return Value**: vec3 - The nearest passable position. ``` -------------------------------- ### Create Directory - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Creates a directory specified by a path and associated with a module ID. Returns true on successful creation, false otherwise. ```lua local success = module.create_directory('my_module_id', 'path/to/new/directory') print(success) ``` -------------------------------- ### orb.menu.combat.key:get() Source: https://badspacebar.github.io/sdk/docs/modules Checks if the combat mode is currently active. ```APIDOC ## orb.menu.combat.key:get() ### Description Checks if the combat mode is currently active. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters None ### Request Example ```lua if orb.menu.combat.key:get() then print('Combat mode is ON') else print('Combat mode is OFF') end ``` ### Response #### Success Response (200) - **boolean** - Returns `true` if combat mode is active, `false` otherwise. #### Response Example ```json true ``` ``` -------------------------------- ### Modify Cursor Position with cb.set_cursorpos (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries This example shows how to use the cb.set_cursorpos event to programmatically change the cursor's position. It includes logic to convert world coordinates to screen coordinates. Note that this callback is intended for specific champions and has a recommended alternative. ```lua -- Only works for VelkozR / AurelionSolQ / YuumiQ / NunuW / SionR local function on_cursorpos_change(point) print('[on_cursorpos_change]: ', point[0], point[1]) -- set x and y local v = graphics.world_to_screen(g_target.pos) point[0] = v.x point[1] = v.y end cb.add(cb.set_cursorpos, on_cursorpos_change) ``` -------------------------------- ### Load UI Sprite Source: https://badspacebar.github.io/sdk/docs/libraries Loads a sprite intended for UI elements. It takes the sprite name (path) as a string and returns a texture object. The example demonstrates loading an icon and potentially setting it on a UI element, with a check for successful loading. ```lua local myIcon = graphics.sprite('XXX/menu_icon.png') if myIcon then -- In some PC it will failed load PNG, so need check this myMenu:set('icon', myIcon) end ``` -------------------------------- ### Clipper2: Initialize Library and Enums Source: https://badspacebar.github.io/sdk/docs/math Initializes the Clipper2 library and demonstrates how to access its various enums for clip types, fill rules, join types, and end types. This is a prerequisite for using Clipper2's advanced polygon operations. ```lua local clipper2 = require("clipper2") local PointD = clipper2.PointD local PathD = clipper2.PathD local PathsD = clipper2.PathsD local BooleanOpD = clipper2.BooleanOpD local Enum = clipper2.Enum -- Enums: -- ClipType: -- Enum.ClipType.None -- Enum.ClipType.Intersection -- Enum.ClipType.Union -- Enum.ClipType.Difference -- Enum.ClipType.Xor -- FillRule: -- Enum.FillRule.EvenOdd -- Enum.FillRule.NonZero -- Enum.FillRule.Positive -- Enum.FillRule.Negative -- JoinType: -- Enum.JoinType.Square -- Enum.JoinType.Bevel -- Enum.JoinType.Round -- Enum.JoinType.Miter -- EndType: -- Enum.EndType.Polygon -- Enum.EndType.Joined -- Enum.EndType.Butt -- Enum.EndType.Square -- Enum.EndType.Round ``` -------------------------------- ### orb.menu.last_hit.key:get() Source: https://badspacebar.github.io/sdk/docs/modules Checks if the last hit mode is currently active. ```APIDOC ## orb.menu.last_hit.key:get() ### Description Checks if the last hit mode is currently active. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters None ### Request Example ```lua if orb.menu.last_hit.key:get() then print('Last hit mode is ON') else print('Last hit mode is OFF') end ``` ### Response #### Success Response (200) - **boolean** - Returns `true` if last hit mode is active, `false` otherwise. #### Response Example ```json true ``` ``` -------------------------------- ### Open Library File - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Opens a library file at the specified path with the given mode. Returns a file handle on success, or nil on failure. ```lua local lib_file = module.open_lib_file('libs/my_library.lua', 'r') if lib_file then -- process library file lib_file:close() end ``` -------------------------------- ### orb.menu.lane_clear.key:get() Source: https://badspacebar.github.io/sdk/docs/modules Checks if the lane clear mode is currently active. ```APIDOC ## orb.menu.lane_clear.key:get() ### Description Checks if the lane clear mode is currently active. ### Method N/A (Function Call) ### Endpoint N/A ### Parameters None ### Request Example ```lua if orb.menu.lane_clear.key:get() then print('Lane clear mode is ON') else print('Lane clear mode is OFF') end ``` ### Response #### Success Response (200) - **boolean** - Returns `true` if lane clear mode is active, `false` otherwise. #### Response Example ```json true ``` ``` -------------------------------- ### Inhibitor Object Documentation Source: https://badspacebar.github.io/sdk/docs/objects Documentation for the inhibitor object, detailing its properties and methods for checking target validity. ```APIDOC ## inhib.obj ### Properties * `number` inhib.type * `number` inhib.index * `number` inhib.team * `number` inhib.networkID * `number` inhib.networkID32 * `string` inhib.name * `number` inhib.x * `number` inhib.y * `number` inhib.z * `vec3` inhib.pos * `vec2` inhib.pos2D * `boolean` inhib.isOnScreen * `number` inhib.selectionHeight * `number` inhib.selectionRadius * `number` inhib.boundingRadius * `number` inhib.overrideCollisionRadius * `number` inhib.pathfindingCollisionRadius * `vec3` inhib.minBoundingBox * `vec3` inhib.maxBoundingBox * `boolean` inhib.isDead * `boolean` inhib.isAlive * `boolean` inhib.isVisible * `number` inhib.deathTime * `number` inhib.health * `number` inhib.maxHealth * `number` inhib.allShield * `boolean` inhib.isTargetable * `number` inhib.isTargetableToTeamFlags ### inhib:isValidTarget(range) #### Parameters `inhib.obj` inhib `number` range, optional #### Return Value `bool` Returns whether this is valid target to self or not ``` -------------------------------- ### Combat Position Management Source: https://badspacebar.github.io/sdk/docs/modules APIs for getting and setting the combat position. ```APIDOC ## orb.combat.get_pos() ### Description Gets the current combat position. ### Method GET ### Endpoint `/orb/combat/get_pos` ### Parameters None ### Response #### Success Response (200) - **position** (object) - The current combat position. ## orb.combat.set_pos(t) ### Description Sets the combat position. ### Method POST ### Endpoint `/orb/combat/set_pos` ### Parameters #### Request Body - **t** (object) - The position object to set. ### Request Example ```lua local orb = module.internal('orb') local new_position = get_some_position() orb.combat.set_pos(new_position) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure. ``` -------------------------------- ### Create Menu Instance Source: https://badspacebar.github.io/sdk/docs/libraries Creates a new menu instance with a unique variable name, display text, and an optional group identifier. Returns the menu instance object. ```lua local myMenu = menu('example_menu', 'Example Menu') ``` -------------------------------- ### Combat Target Management Source: https://badspacebar.github.io/sdk/docs/modules APIs for getting and setting the combat target. ```APIDOC ## orb.combat.get_target() ### Description Gets the current combat target. ### Method GET ### Endpoint `/orb/combat/get_target` ### Parameters None ### Response #### Success Response (200) - **target** (object) - The current combat target. ## orb.combat.set_target(t) ### Description Sets the combat target. ### Method POST ### Endpoint `/orb/combat/set_target` ### Parameters #### Request Body - **t** (object) - The target object to set. ### Request Example ```lua local orb = module.internal('orb') local new_target = get_some_target() orb.combat.set_target(new_target) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure. ``` -------------------------------- ### Combat Active State Source: https://badspacebar.github.io/sdk/docs/modules APIs for getting and setting the combat active state. ```APIDOC ## orb.combat.get_active() ### Description Gets the current active state of the combat module. ### Method GET ### Endpoint `/orb/combat/get_active` ### Parameters None ### Response #### Success Response (200) - **active** (boolean) - True if combat is active, false otherwise. ## orb.combat.set_active(t) ### Description Sets the active state of the combat module. ### Method POST ### Endpoint `/orb/combat/set_active` ### Parameters #### Request Body - **t** (boolean) - The active state to set (true or false). ### Request Example ```lua local orb = module.internal('orb') orb.combat.set_active(true) ``` ### Response #### Success Response (200) - **status** (string) - Indicates success or failure. ``` -------------------------------- ### Easy Download File - Network SDK Source: https://badspacebar.github.io/sdk/docs/libraries Initiates an asynchronous file download from a URI. A callback function is executed upon completion of the download. ```lua local function download_callback(success) print('Download finished:', success) end network.easy_download(download_callback, 'http://example.com/file.txt', 'local/path/file.txt') ``` -------------------------------- ### Get Screen Height Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the current height of the game screen in pixels. Returns a number. ```lua graphics.height() ``` -------------------------------- ### Nexus Object Documentation Source: https://badspacebar.github.io/sdk/docs/objects Documentation for the nexus object, outlining its properties related to health, visibility, and targetability. ```APIDOC ## nexus.obj ### Properties * `string` nexus.name * `boolean` nexus.isOnScreen * `boolean` nexus.isDead * `boolean` nexus.isAlive * `boolean` nexus.isVisible * `boolean` nexus.isTargetable * `vec3` nexus.pos * `vec2` nexus.pos2D * `number` nexus.team * `number` nexus.type * `number` nexus.x * `number` nexus.y * `number` nexus.z * `number` nexus.health * `number` nexus.maxHealth * `number` nexus.allShield * `number` nexus.isTargetableToTeamFlags ``` -------------------------------- ### Get Screen Width Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the current width of the game screen in pixels. Returns a number. ```lua graphics.width() ``` -------------------------------- ### Clipper Library Initialization (Lua) Source: https://badspacebar.github.io/sdk/docs/math Initializes and accesses components of the clipper library. This library is used for polygon clipping operations and requires explicit loading before use. It provides access to polygon creation, manipulation functions, and enumeration values for clipping types and fill rules. ```lua local clip = module.internal('clipper') local polygon = clip.polygon local polygons = clip.polygons local clipper = clip.clipper local clipper_enum = clip.enum ``` -------------------------------- ### Get Screen Resolution Source: https://badspacebar.github.io/sdk/docs/libraries Returns the screen resolution as a 2D vector (vec2) containing width and height. ```lua graphics.res() ``` -------------------------------- ### Get Current Font Name Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the name of the currently active font used for rendering text. Returns a string. ```lua graphics.get_font() ``` -------------------------------- ### Turret Object Documentation Source: https://badspacebar.github.io/sdk/docs/objects Detailed documentation for the turret object, including its properties and methods for interacting with turret-related game mechanics. ```APIDOC ## turret.obj ### Properties * `string` turret.name * `string` turret.charName * `boolean` turret.isOnScreen * `boolean` turret.isDead * `boolean` turret.isAlive * `boolean` turret.isVisible * `boolean` turret.isTargetable * `vec3` turret.pos * `vec3` turret.direction * `vec2` turret.pos2D * `vec2` turret.barPos * `vec2` turret.direction2D * `path.obj` turret.path * `spell.obj` turret.activeSpell * `table` turret.buff * `number` turret.networkID * `number` turret.networkID32 * `number` turret.team * `number` turret.x * `number` turret.y * `number` turret.z * `number` turret.selectionHeight * `number` turret.selectionRadius * `number` turret.boundingRadius * `number` turret.overrideCollisionRadius * `number` turret.pathfindingCollisionRadius * `vec3` turret.minBoundingBox * `vec3` turret.maxBoundingBox * `number` turret.deathTime * `number` turret.health * `number` turret.maxHealth * `number` turret.mana * `number` turret.maxMana * `number` turret.allShield * `number` turret.isTargetableToTeamFlags * `number` turret.baseAttackDamage * `number` turret.baseAd > alias of `baseAttackDamage` * `number` turret.bonusAd * `number` turret.totalAd > The TotalAttackDamage * `number` turret.totalAp > The TotalAbilityPower * `number` turret.armor * `number` turret.spellBlock * `number` turret.attackSpeedMod * `number` turret.flatPhysicalDamageMod * `number` turret.percentPhysicalDamageMod * `number` turret.flatMagicDamageMod * `number` turret.percentMagicDamageMod * `number` turret.healthRegenRate * `number` turret.bonusArmor * `number` turret.bonusSpellBlock * `number` turret.baseAbilityDamage * `number` turret.parRegenRate * `number` turret.attackRange * `number` turret.flatMagicReduction * `number` turret.percentMagicReduction * `number` turret.flatArmorPenetration * `number` turret.percentArmorPenetration * `number` turret.flatMagicPenetration * `number` turret.percentMagicPenetration * `number` turret.percentBonusArmorPenetration * `number` turret.percentBonusMagicPenetration * `number` turret.physicalLethality * `number` turret.magicLethality * `number` turret.baseHealthRegenRate * `number` turret.secondaryARBaseRegenRateRep * `number` turret.flatBaseAttackDamageMod * `number` turret.percentBaseAttackDamageMod * `number` turret.baseAttackDamageSansPercentScale * `number` turret.exp * `number` turret.par * `number` turret.maxPar * `number` turret.parEnabled * `number` turret.physicalDamagePercentageModifier * `number` turret.magicalDamagePercentageModifier * `bool` turret.isMelee * `bool` turret.isRanged * `number` turret.tier > Base=1, Inner=2, Outer=3, NexusRight=4, NexusLeft=5 * `number` turret.lane > Bottom=0, Mid=1, Top=2 ### t:basicAttack(i) #### Parameters `turret.obj` t `number` i #### Return Value `spell.obj` returns the turrets basic attack ### t:isPlayingAnimation(animationNameHash) #### Parameters `turret.obj` t `number` animationNameHash #### Return Value `boolean` ### t:attackDelay() #### Parameters `turret.obj` t #### Return Value `number` ### t:attackCastDelay(slot) #### Parameters `turret.obj` t `number` spellSlot #### Return Value `number` ### t:isValidTarget(range) #### Parameters `turret.obj` t `number` range, optional #### Return Value `bool` Returns whether this is valid target to self or not ``` -------------------------------- ### Player Movement and Actions Source: https://badspacebar.github.io/sdk/docs/objects This section details player actions such as moving, attacking, stopping, selecting, and interacting with objects. ```APIDOC ## Player Movement and Actions ### Description Provides functions for controlling player movement, initiating attacks, stopping actions, selecting targets, and interacting with game objects. ### Methods #### `player:move(v1)` * **Description**: Moves the player character to a specified vector position. * **Parameters**: * `player` (hero.obj) - The player object. * `v1` (vec3) - The target vector position. * **Return Value**: void #### `player:attackmove(v1)` * **Description**: Commands the player to perform an attack-move to a specified vector position. * **Parameters**: * `player` (hero.obj) - The player object. * `v1` (vec3) - The target vector position. * **Return Value**: void #### `player:altmove(v1)` * **Description**: Performs an alternative movement action to a specified vector position. * **Parameters**: * `player` (hero.obj) - The player object. * `v1` (vec3) - The target vector position. * **Return Value**: void #### `player:attack(obj)` * **Description**: Initiates a standard attack on a target object. * **Parameters**: * `player` (hero.obj) - The player object. * `obj` (obj) - The target object to attack. * **Return Value**: void #### `player:altattack(obj)` * **Description**: Initiates an alternative attack on a target object. * **Parameters**: * `player` (hero.obj) - The player object. * `obj` (obj) - The target object to attack. * **Return Value**: void #### `player:stop()` * **Description**: Stops the player's current action. * **Parameters**: * `player` (hero.obj) - The player object. * **Return Value**: void #### `player:select(n)` * **Description**: Selects a specific player or unit based on an index. * **Parameters**: * `player` (hero.obj) - The player object. * `n` (number) - The index of the player/unit to select. * **Return Value**: void #### `player:interact(obj)` * **Description**: Makes the player interact with a specified object. * **Parameters**: * `player` (hero.obj) - The player object. * `obj` (obj) - The object to interact with. * **Return Value**: void ``` -------------------------------- ### Get Current Game Type (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns a string indicating the type of game being played (e.g., 'Custom', 'Ranked'). ```lua local type = game.type print('Current game type: ' .. type) ``` -------------------------------- ### Get Current Game Mode (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns a string representing the current game mode (e.g., 'FFA', '2v2'). ```lua local mode = game.mode print('Current game mode: ' .. mode) ``` -------------------------------- ### Create Script Directory - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Creates a directory specifically for scripts within the module system. Returns true on success, false on failure. ```lua local success = module.create_script_directory('scripts/my_new_scripts') print(success) ``` -------------------------------- ### Player Spell and Item Management Source: https://badspacebar.github.io/sdk/docs/objects Functions for leveling up spells and buying items. ```APIDOC ## Player Spell and Item Management ### Description Provides functions for managing player spells and purchasing items. ### Methods #### `player:levelSpell(slot)` * **Description**: Levels up a specific spell. * **Parameters**: * `player` (hero.obj) - The player object. * `slot` (number) - The spell slot to level up. * **Return Value**: void #### `player:buyItem(itemID)` * **Description**: Purchases an item using its ID. * **Parameters**: * `player` (hero.obj) - The player object. * `itemID` (number) - The ID of the item to buy. * **Return Value**: void ``` -------------------------------- ### Get Current Map ID (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns a numerical identifier for the current map being played. Useful for map-specific logic. ```lua local map_id = game.mapID print('Current map ID: ' .. map_id) ``` -------------------------------- ### Get Current Game Version (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns the current version of the game as a string. This is useful for compatibility checks or logging. ```lua local version = game.version print('Game version: ' .. version) ``` -------------------------------- ### Clipper2: Create PathD Object Source: https://badspacebar.github.io/sdk/docs/math Shows how to create a new double-precision path (polygon) object in Clipper2. It illustrates creating an empty path and a path initialized with a set of points. ```lua -- Create empty path local path = PathD() -- Create path with initial points local p1 = PointD(0, 0) local p2 = PointD(100, 0) local p3 = PointD(50, 100) local path = PathD(p1, p2, p3) ``` -------------------------------- ### Open Script File - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Opens a script file at the specified path with the given mode. Returns a file handle on success, or nil on failure. ```lua local script_file = module.open_script_file('scripts/my_script.lua', 'r') if script_file then -- process script file script_file:close() end ``` -------------------------------- ### Calculate Length of a seg2 Segment Source: https://badspacebar.github.io/sdk/docs/math Computes the length of a 2D line segment defined by its start and end points. ```Lua local segment_length = my_segment:len() ``` -------------------------------- ### Get Player Object in Lua Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the player's character object. This object contains properties like character name. ```lua print(player.charName) ``` -------------------------------- ### Create and Print vec3 Vectors in Lua Source: https://badspacebar.github.io/sdk/docs/math Demonstrates how to create vec3 vectors using three numbers or by cloning an existing vec3. It also shows how to print the vector's components. ```lua local a = vec3(player.x, player.y, player.z) local b = vec3(a) a:print() b:print() ``` -------------------------------- ### Open File Handle - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Opens a file associated with a module ID at a given path and mode ('r' for read, 'w' for write, etc.). Returns a file handle on success, or nil on failure. ```lua local file_handle = module.open_file('my_module_id', 'data/config.json', 'r') if file_handle then local content = file_handle:read('*a') print(content) file_handle:close() end ``` -------------------------------- ### Get Game Phase Index Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the current phase index of the game. This is a string value representing the current game mode. ```lua game.modePhaseIndex() ``` -------------------------------- ### Clipper2: Create PointD Object Source: https://badspacebar.github.io/sdk/docs/math Demonstrates the creation of a new double-precision point object using the PointD constructor in Clipper2. This is fundamental for defining polygon vertices. ```lua local point = PointD(100.5, 200.7) ``` -------------------------------- ### Calculate Path Positions and Draw Circles (Lua) Source: https://badspacebar.github.io/sdk/docs/objects This code snippet shows how to calculate path positions using `calcPos` and draw circles at these positions. It takes a `vec3` as input and returns an array of `vec3` path points. The example iterates through the returned points and draws a circle at each one. ```lua cb.add(cb.draw, function() local p, n = player.path:calcPos(mousePos) for i = 0, n - 1 do graphics.draw_circle(p[i], 15, 2, 0xffffffff, 3) end end) ``` -------------------------------- ### Get Current Game Time (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns the current elapsed time in the game, usually in seconds. This can be used for timing events or animations. ```lua local current_time = game.time print('Current game time: ' .. current_time) ``` -------------------------------- ### Get Current Cursor Position (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the current cursor position, typically in 2D screen coordinates. Returns a vec2 object. ```lua local cursor_pos = game.cursorPos print('Cursor position: ' .. cursor_pos.x .. ', ' .. cursor_pos.y) ``` -------------------------------- ### Configure Shard Header with File Names (Lua) Source: https://badspacebar.github.io/sdk/docs/shards This Lua code snippet demonstrates how to configure the `header.lua` file for Hanbot shards. It includes defining unique IDs, names, author, description, and a list of files to be included in the shard. It also shows how to specify the shard type and a load function for conditional loading. ```lua local isCN = hanbot and hanbot.language == 1 local supported = { Ashe = true, Lux = true, } return { id = "some_unique_name", name = isCN and "你好" or "Hello", author = "aaa", description = [[]], shard = { 'main', 'spells/q', }, -- menu will be loaded by this order: "Orbwalker" / "Evade" / "Utility" / "Other" / "Champion" type = "Champion", -- if this shard is a champion plugin -- current shard will not be loaded when "load" return failed. load = function () return supported[player.charName] end } ``` -------------------------------- ### Get Terrain Height at Coordinates (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the terrain height at a given X and Z coordinate. This is useful for understanding the 3D landscape. ```lua local height = navmesh.getTerrainHeight(100, 200) print('Terrain height at (100, 200): ' .. height) ``` -------------------------------- ### Create and Print vec2 Vectors in Lua Source: https://badspacebar.github.io/sdk/docs/math Demonstrates how to create vec2 vectors using two numbers or by cloning an existing vec2. It also shows how to print the vector's components. ```lua local a = vec2(player.x, player.z) local b = vec2(a) a:print() b:print() ``` -------------------------------- ### Create Shard Directory - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Creates a directory designated for shard files within the module system. Returns true on successful creation, false on failure. ```lua local success = module.create_shard_directory('shards/my_new_shards') print(success) ``` -------------------------------- ### Get Network Latency - Network SDK Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the current game network latency in seconds. This value indicates the round-trip time for network packets. ```lua local latency = network.latency print(latency) ``` -------------------------------- ### Get Currently Selected Game Object (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns the game object that is currently selected by the player. Returns an object or nil if nothing is selected. ```lua local selected_obj = game.selectedTarget if selected_obj then print('Selected target: ' .. selected_obj.name) else print('No target selected.') end ``` -------------------------------- ### Get Current Camera Position (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns the current position of the game camera in 3D world coordinates. This is useful for context-aware game logic. ```lua local cam_pos = game.cameraPos print('Camera position: ' .. cam_pos.x .. ', ' .. cam_pos.y .. ', ' .. cam_pos.z) ``` -------------------------------- ### Complex Boolean Operations with Clipper2 Library Source: https://badspacebar.github.io/sdk/docs/math This example demonstrates complex boolean operations using the clipper2 library, specifically performing a union on multiple overlapping circles and then creating an offset of the resulting shape. It requires the 'clipper2' module to be required. The function returns 1 on success. ```lua local clipper2 = require("clipper2") -- Create multiple overlapping circles local function create_circle(center_x, center_y, radius, segments) local path = clipper2.PathD() for i = 0, segments - 1 do local angle = i * 2 * math.pi / segments local x = center_x + radius * math.cos(angle) local y = center_y + radius * math.sin(angle) path:Add(x, y) end return path end local function on_draw() local subjects = clipper2.PathsD() local clips = clipper2.PathsD() local solution = clipper2.PathsD() -- Create overlapping circles local circle1 = create_circle(100, 100, 50, 32) local circle2 = create_circle(150, 100, 50, 32) local circle3 = create_circle(125, 150, 50, 32) subjects:Add(circle1) clips:Add(circle2) clips:Add(circle3) -- Perform union operation local result = clipper2.BooleanOpD( clipper2.Enum.ClipType.Union, clipper2.Enum.FillRule.NonZero, subjects, clips, solution, 2, false ) if result == 1 then -- Draw the unified shape for i = 0, solution:ChildCount() - 1 do local path = solution:Childs(i) path:Draw2D(3, 0xFF00FFFF) end -- Create offset version local offset_solution = solution:Offset(10, clipper2.Enum.JoinType.Round) for i = 0, offset_solution:ChildCount() - 1 do local path = offset_solution:Childs(i) path:Draw2D(1, 0xFFFF0000) end end end cb.add(cb.draw, on_draw) ``` -------------------------------- ### Get Current Mouse Position (3D) (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves the current 3D coordinates of the mouse cursor in the game world. Returns a vec3 object. ```lua local mouse_world_pos = game.mousePos print('Mouse world position: ' .. mouse_world_pos.x .. ', ' .. mouse_world_pos.y .. ', ' .. mouse_world_pos.z) ``` -------------------------------- ### Turret Object Methods Source: https://badspacebar.github.io/sdk/docs/objects Provides methods for interacting with turret objects, including performing basic attacks, checking animation states, and querying attack delays. These functions are essential for implementing turret-related game logic. ```lua -- Methods for turret.obj -- t:basicAttack(i): spell.obj -- t:isPlayingAnimation(animationNameHash): boolean -- t:attackDelay(): number -- t:attackCastDelay(slot): number -- t:isValidTarget(range): bool ``` -------------------------------- ### Calculate Spell Damage using Lua Source: https://badspacebar.github.io/sdk/docs/objects Demonstrates how to calculate spell damage using the `calculate` method of a `spell_slot` object in Lua. It shows how to obtain spell calculation hashes and apply them to different spells, including champion-specific examples like Jhin and Aatrox. ```lua -- Jhin Example: -- https://raw.communitydragon.org/13.15/game/data/characters/jhin/jhin.bin.json -- JhinW: ["Characters/Jhin/Spells/JhinRAbility/JhinW"].mSpell.mSpellCalculations -- JhinR: ["Characters/Jhin/Spells/JhinRAbility/JhinR"].mSpell.mSpellCalculations local calcHashW = game.fnvhash('TotalDamage') local rawDamageW = player:spellSlot(0):calculate(0, calcHashW) local calcHashR = game.fnvhash('DamageCalc') local rawDamageR = player:spellSlot(3):calculate(0, calcHashR) -- AatroxQ Example: -- The `spellSlot(0).name` could be "AatroxQ"/"AatroxQ2"/"AatroxQ3" -- We need use "AatroxQ" to calculate the damage. local QDamage = game.fnvhash('QDamage') local AatroxQ = game.spellhash('AatroxQ') local rawDamageQ1 = player:spellSlot(0):calculate(AatroxQ, QDamage) local rawDamageQ2 = player:spellSlot(0):calculate(AatroxQ, QDamage) * 1.25 local rawDamageQ3 = player:spellSlot(0):calculate(AatroxQ, QDamage) * 1.25 * 1.25 ``` -------------------------------- ### Get Time Until Next Attack Source: https://badspacebar.github.io/sdk/docs/modules Returns the remaining time in seconds until the player can issue their next attack. This is useful for timing attack sequences. ```lua local orb = module.internal('orb') local function on_tick() local time_left = orb.core.time_to_next_attack() print('Time until next attack: ' .. time_left .. 's') end cb.add(cb.tick, on_tick) ``` -------------------------------- ### Minion Basic Attack Method Source: https://badspacebar.github.io/sdk/docs/objects This method allows initiating a basic attack for a minion. It takes an index to specify the attack, with -1 defaulting to the standard auto-attack spell. It returns the spell object associated with the basic attack. ```lua function m:basicAttack(index) -- Parameters: -- m: minion.obj -- index: number, -1 to get the default AA spell -- Return Value: -- spell.obj returns the minions basic attack end ``` -------------------------------- ### Player Attack Functions Source: https://badspacebar.github.io/sdk/docs/objects Functions for initiating attacks. 'player:attack' targets a specific object, while 'player:altattack' might trigger an alternative attack mode. Both functions return void. ```lua player:attack(obj) player:altattack(obj) ``` -------------------------------- ### Get Internal Module - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Retrieves an internal module by its name. If the module is not loaded, it attempts to load it. This is typically used for core SDK modules. ```lua local orb = module.internal('orb') ``` -------------------------------- ### Hero Inventory and Item Information Source: https://badspacebar.github.io/sdk/docs/objects Provides access to hero's inventory and item details. 'hero:inventorySlot' returns an inventory_slot.obj for a specified slot, and 'hero:itemID' returns the item ID for a given inventory slot. ```lua hero:inventorySlot(slot) hero:itemID(slot) ``` -------------------------------- ### Get Hovered Game Target Source: https://badspacebar.github.io/sdk/docs/libraries Identifies the game object currently under the mouse cursor based on X and Y coordinates. Returns an object representing the hovered target. ```lua game.getHoveredTarget(mouseX, mouseY) ``` -------------------------------- ### Get Currently Hovered Game Object (Lua) Source: https://badspacebar.github.io/sdk/docs/libraries Returns the game object that the mouse cursor is currently hovering over. Returns an object or nil if no object is hovered. ```lua local hovered_obj = game.hoveredTarget if hovered_obj then print('Hovered target: ' .. hovered_obj.name) else print('No target hovered.') end ``` -------------------------------- ### Open Shard File - Module SDK Source: https://badspacebar.github.io/sdk/docs/libraries Opens a shard file at the specified path with the given mode. Returns a file handle on success, or nil on failure. ```lua local shard_file = module.open_shard_file('shards/my_shard.lua', 'r') if shard_file then -- process shard file shard_file:close() end ```