autoRun($int repetitionDelay, $func scriptFunction)
Will run the provided function in scriptFunction parameter every milliseconds amount provided in repetitionDelay parameter.
For example:
local function spamTalk()
talk("spam")
end
autoRun(2000, spamTalk)
This will run spamTalk function every 2000 milliseconds(time is counted from the end of function execution)
print($str textToPrint)
Will display the text on console. You can use it to debug scripts or to read game state informations.
$int nowMs()
Returns current time in milliseconds. Useful for measuring time. Example:
local start = nowMs()
someTimeConsumingFunction()
local now2 = nowMs()
local timeElapsed = now2 - start
$int getPlayerHppc()
Returns your character's current hp in percentage (for example if your character has 700hp out of 1000 it will return 70)
$int getHp()
Returns the current health points
$int getMaxHp()
Returns the MAX health points
$int getPlayerMppc()
Returns your character's current mana in percentage (for example if your character has 700mp out of 1000 it will return 70)
$int getMana()
Returns the current mana points
$int getMaxMana()
Returns the MAX mana points
$bool isHasted()
Will return true if your character is hasted. Otherwise returns false
$table{x, y, z} getSelfPosition()
Will return x=65535, y=65535, z=255 when character is offline. Otherwise will return table with values: x, y, z.
For example: local pos = getSelfPosition(). If you want to access x position then you should use pos.x etc.
$str or $nil getSelfName()
Will return NIL, when character is offline. Otherwise will return the name of your character.
$int getPlayerStates()
Will returns number representing the state of your character (paralyzed, hasted, in combat etc.)
These states are written in single integer and each bit contains information if the state is on or off.
For example if your character is in combat it means that first least significant bit is on.
So if your character only had in combat state, the function would return 1.
Let's asume hasted is second least significant bit, if our character only had hasted state this function would return 2.
Since states are represented as bits in returned value if your character is hasted and in combat this function would return 3 (2 for hasted bit and + 1 for combat bit)
$bool playerHasState($int state)
Will return true if the player has specified state. For example if we assume number 2 represents hasted state, then to check if your character is hasted you should Use
playerHasState(2)
$int getSelfOutfitId()
Will return id of current outfit.
$int getSoul()
Will return current soul.
$int getSkillLevel($int skillId)
Returns the current level of a skill (fishing, sword etc.). SkillId parameter is a number assigned uniquely to each skill.
For example fist fighting is usually 1, so getSkillLevel(1) would return fist fighting skill level.
Some servers can have different values for the same skill
$int getStamina()
Returns the stamina (in minutes). E.g 42:00 is 42 hours by 60 minutes = 2520
$int getCapacity()
Returns the current capacity of player.
$int getExperience()
Returns experience
$int getItemStackSize($item item)
Returns stack size of given item. E.g 100 arrows in backpack is one item with stack size of: 100
equipItem($int itemSlot, $int itemId, $int itemsAmount)
Will equip item with chosen itemId from open containers to chosen itemSlot. If item has less count than specified it will be equiped anyways
unequip($int itemSlotId)
Will unequip item from equipment to one of open containers.
Possible itemSlotId values:
helmet - 1 or HELMET_SLOT
necklace - 2 or NECKLACE_SLOT
backpack - 3 or BP_SLOT
armor - 4 or ARMOR_SLOT
leftHand - 5 or LEFT_HAND_SLOT
rightHand - 6 or RIGHT_HAND_SLOT
legs - 7 or LEGS_SLOT
boots - 8 or BOOTS_SLOT
ring - 9 or RING_SLOT
ammo - 10 or AMMO_SLOT
$int getInventoryItemId($int itemSlotId)
Returns id of an item which player has equiped. 0 indicates empty
$item getInventoryItem($int itemSlotId)
Returns an item which player has equiped.
$item getTopUseItem($int x, $int y, $int z)
Returns usable item on top of provided position (water and other ground tiles are counted as top usable item)
$thing getTopMoveThing($int x, $int y, $int z)
Returns movable thing on top of provided position
moveItem($item itemToMove, $int x, $int y, $int z)
Moves item to given position
useItem($int itemId)
Will try to use item which player has in one of his backpacks with a chosen itemId. In a way it simulated an 8.0 tibia hotkey use so player can use item with backpack closed
useItem($item item)
Uses an item
useItemInContainer($int itemId)
Will try to use item which is present in open containers
openItemInContainer($int itemId)
Will try to open item which is present in open containers
usePosition($int x, $int y, $int z)
Will use the item at position x, y, z
$bool moveItemToContainerWithId($int containerId, $int movedItemId)
Will move item with provided id (movedItemId) to a open container with id (containerId).
Returns true if bot found aproperiate items and tried to move. False otherwise
$bool useInventoryItemOnNearbyGroundItem($int itemFromInventoryId, $int groundItemId)
Will try to use item which character has in one of his bps with id(itemFromInventoryId) on the groundItem with id(groundItemId) withing 1 sqm
Returns true if bot found aproperiate items and tried to use on ground item. False otherwise
$bool useItemFromOpenContainerOnNearbyGroundItem($int itemFromInventoryId, $int groundItemId)
This one requires open backpack with wanted item. Simulates useWith from backpack on the ground.
Returns true if bot found aproperiate items and tried to use on ground item. False otherwise
useInventoryItemOnNearbyGroundItems($int itemFromInventoryId, $int groundItemId)
Same as useInventoryItemOnNearbyGroundItem but will try to use on all nearby items instead of one.
useItemFromOpenContainerOnNearbyGroundItems($int itemFromInventoryId, $int groundItemId)
Same as useItemFromOpenContainerOnNearbyGroundItem but will try to use on all nearby items instead of one.
useInventoryItemOnThing($int itemId, $thing thing)
Will make your character use item on provided Thing(creature, item)
useItemFromOpenContainerOnThing($int itemId, $thing thing)
Will make your character use item on provided Thing(creature, item). Requires backpack to be open with inventory item (this is like doing use with from backpack on a sqm with given item/creature).
useItemWithSubtypeFromOpenContainerOnThing($int itemId, $int subtype, $thing thing)
Will make your character use item on provided Thing(creature, item). Requires backpack to be open with inventory item (this is like doing use with from backpack on a sqm with given item/creature).
useItemFromOpenContainerOnSelf($int itemId)
Uses item on yourself. Requires backpack to be open with inventory item (this is like doing use with from backpack on self).
useItemFromOpenContainerOnPosition($int itemId, $int x, $int y, $int z)
Uses item on position. Requires backpack to be open with inventory item.
useItemWithSubtypeFromOpenContainerOnSelf($int itemId, $int subtype)
Uses item with given subtype on yourself. Requires backpack to be open with inventory item (this is like doing use with from backpack on self).
On some server manafluid has the same id as life fluid. But they have differnt subtype. Using this function you can avoid problem of bot trying to use empty vials.
useManafluidOnSelf()
Will use mana fluid from backpack on your character (works as if you clicked use with on your character). Supports only 7.4 and 8.0 mana fluids
useLifefluidOnSelf()
Will use life fluid from backpack on your character (works as if you clicked use with on your character). Supports only 7.4 and 8.0 life fluids
useNearbyGroundItem($int groundItemId)
Will make your character use item with id(groundItemId) withing 1 sqm.
$int getItemCount($int itemId)
Will return the amount of items that are visible in opened containers
useInventoryItemOnInventoryItem($int itemFromInventoryId, $int otherInventoryItemId)
Will try to use item which character has in one of his bps with id(itemFromInventoryId) on the item with id(otherInventoryItemId) in any of open backpacks
useInventoryItemOnInventoryItem2($int itemFromInventoryId, $int groundItemId)
Will try to use item which character has in one of his bps with id(itemFromInventoryId) on the item with id(otherInventoryItemId) in any of open backpacks.
Please use this version if useInventoryItemOnInventoryItem doesn't work
useEquippedItemOnThing($int itemSlot, $thing thing)
Uses the item that is equipped on provided itemSlot on a thing. A thing is an item or a creature. For itemSlots navigate to equipItem section.
useItemOnMostMonsters($int itemId, $int range, $int runeAoe)
Uses the item (itemId) on most monsters within range. runeAoe can either be:
0 or RUNE_GFB
1 or RUNE_Fireball
Example: useItemOnMostMonsters(3191, 7, RUNE_GFB)
crosshairUse($int itemId, $int subtype)
Turns cursor into crosshair that will use item with given itemId and subtype on left click if it was found in open container.
collectNearbyGroundItem($int containerId, $int groundItemId)
Will take ground item with provided id(groundItemId) within 1 sqm of the character to a open container with id (containerId)
collectNearbyGroundItemMoveCorpses($int containerId, $int groundItemId)
Will take ground item with provided id(groundItemId) within 1 sqm of the character to a open container with id (containerId). If the ground item is covered by corpse or any other item the item will be moved to player position first
collectGroundItem($int containerId, $int groundItemId)
Will take ground item with provided id(groundItemId) from distance
dropItem($int itemId, $int itemCount)
Drops item under your character.
$bool isContainer($item item)
Returns true if item is a container. Otherwise returns false
buyItem($int itemId, $int subtype, $int amount)
Buys item from NPC window when it is open
sellItem($int itemId, $int subtype, $int amount)
Sells item from NPC window when it is open
$int getId($thing thing)
Returns id of a thing (itemId for item, unique creatureId fo creatures)
$table{x, y, z} getPosition($thing thing)
Will return x=65535, y=65535, z=255 when thing argument is invalid. Otherwise will return table with values: x, y, z.
attack($creature creatureToAttack)
Will attack creatureToAttack.
$int countScreenCreatures($str pattern)
Will return the amount of creatures that have a name which contains the pattern.
For example monsterName is Dragon. countScreenCreatures("Drag") will count Dragons as well as any other monster which has Drag in it's name.
So if there are Dragon Lords and Dragons the countScreenCreatures("Drag") will count both of them
$creature{} getScreenPlayers()
Will return array with all visible players on the same floor.
$creature{} getScreenMonsters()
Will return array with all visible monsters on the same floor.
$creature{} getCreaturesMultiFloor()
Will return array with all visible creatures on all aware floors (includes your character).
$int getScreenMonstersCountInRange($int range)
Will return amount of monsters within range
$int getScreenPlayersCountInRange($int range)
Will return amount of players within range (excluding yourself)
$str getCreatureName($creature wantedCreature)
Will return the name of wanted creature.
$int getCreatureHppc($creature wantedCreature)
Will return percentage of current hp of the wanted creature.
$int getPartyShield($creature wantedCreature)
Will return the id of party shield icon for specified creature (wanted creature parameter)
$int getSkull($creature wantedCreature)
Will return the id of wanted creature skull icon
$int getEmblem($creature wantedCreature)
Returns id of creature emblem (e.g warmode emblems)
$int getType($creature wantedCreature)
Returns type of a creature (from game server source code: 0 - player, 1 - monster, 2 - npc, 3 - summon own, 4 - summon other)
$int getOutfitId($creature creature)
Will return id of creature's outfit
setOutfit($creature creature, $int outfitId)
Will set the outfit of creature to provided outfitId
mapClick($int x, $int y, $int z)
Makes mapclick on given position
mapClickChase($creature chasedCreature)
Will send mapclick on sqm which is closest to the chasedCreature
$bool isMonster($creature creature)
Returns true if creature is a monster. Otherwise returns false
$bool isPlayer($creature creature)
Returns true if creature is a player. Otherwise returns false
$int getDirection($creature creature)
Returns a number which corresponds to the direction that a creature is facing
0 or DIR_NORTH - north
1 or DIR_EAST - east
2 or DIR_SOUTH - south
3 or DIR_WEST - west
4 or DIR_NE - north east
5 or DIR_SE - south east
6 or DIR_SW - south west
7 or DIR_NW - north west
$container{} getOpenContainers()
Will return array with all open containers
$item{} getItems($container container)
Will return array of items that are inside the container.
$item or $nil getContainerItem($container container)
Returns an item associated with the container. Returns NIL if invalid container was passed.
moveItemToContainer($item item, $container container, $int count)
Moves item to first available slot in the container. Count bigger than 1 affects stackable items. E.g if you have 50 arrows you can use count 35 to move just 35 arrows from that stack.
open($item item, $container parentContainer)
Opens an item in the same window. The item must be present in parentContainer. E.g it can open bag in a bag.
openInNewWindow($item item)
Opens an item in the new window.
closeContainer($container container)
Closes container.
openParentContainer($container container)
Simulates clicking up arrow in container (opens the parent container).
printEffects()
Displays currently visible effects and their positions on the console.
$table{x, y, z} or $nil findEffectPosition($int effectId)
Returns position of effect if it is currently visible. If no effect is visible then returns nil.
sendKey($str hotkey)
Will simulate key press. Available keys:
a) F1 - F12 keys
b) alphabetical keys (A-Z)
c) special keys ("Enter", "Left", "Right", "Up", "Down")
talk($str message)
Will send a message on default channel
move($int direction)
Will move your character to one of following directions:
0 or DIR_NORTH- north
1 or DIR_EAST - east
2 or DIR_SOUTH - south
3 or DIR_WEST - west
4 or DIR_NE - north east
5 or DIR_SE - south east
6 or DIR_SW - south west
7 or DIR_NW - north west
$creature or $nil getCreatureByName($str name)
Returns creature, which is visible on screen and has provided name. Returns NIL if such creature isn't visible on the screen
goToLabel($str labelName)
Will make cavebot jump to waypoint which is labeled by provided labelName
$int getKilledMonstersCount($str monsterName)
This function only works when Hunt is started in HuntFrame. It will return the amount of monsters you have killed. This works based on loot of a MOB_NAME message so please remember about leaving the party
resetKilledMonstersCount($str monsterName)
Will reset kill count for provided monster. It is useful after you complete a task.
acceptParty($str{} partyLeaders)
Will accept party from player whose name is specified in partyLeaders. For example: acceptParty({"Leader1, Big Ben"})
Whenever Leader1 or Big Ben invite you to the party you will accept the invite.
partyInvite($str{} partyMemberNamesToInvite)
Will invite a player present in the partyMemberNamesToInvite if he isn't in the party. For example: partyInvite({"Bob", "Elite Maciek"})
Whenever Bob or Elite Maciek is visible on screen, he will be invited to the party.
sleep($int milliseconds)
Will pause the script for provided milliseconds time.
setChaseMode($int mode)
Will change the chase mode. 0 - stand, 1 - chase
foreachMessage($func functionHandlingNewMessage)
Will call functionHandlingNewMessage everytime new message was sent to the client.
For example:
local function alarm(msg)
if msg.content == "Are you botting?" and msg.sender == "GM Antibot" then
playSound("botcheck.wav")
end
end
foreachMessage(alarm)
msg parameter has the following attributes:
$str msg.content - the content of message
$str or $nil msg.sender - the sender of message
$int or $nil msg.level - the level of sender
$int msg.mode - the mode of message (all modes will be provided in further section)
$int or $nil msg.channel - the id of message channel (the id may change depending on which channel is open)
$int or $nil msg.x - x position of the message
$int or $nil msg.y - y position of the message
$int or $nil msg.z - z position of the message
msg modes(some may be unused) The number corresponds to the msg.mode value $int:
- MessageSay
- MessageWhisper
- MessageYell
- PrivateFrom
- MessagePrivateTo
- MessageChannelManagement
- MessageChannel
- MessageChannelHighlight
- MessageSpell
- MessageNpcFrom
- MessageNpcTo
- MessageGamemasterBroadcast
- MessageGamemasterChannel
- MessageGamemasterPrivateFrom
- MessageGamemasterPrivateTo
- MessageLogin
- MessageWarning
- MessageGame
- MessageFailure
- MessageLook
- MessageDamageDealed
- MessageDamageReceived
- MessageHeal
- MessageExp
- MessageDamageOthers
- MessageHealOthers
- MessageExpOthers
- MessageStatus
- MessageLoot
- MessageTradeNpc
- MessageGuild
- MessagePartyManagement
- MessageParty
- MessageBarkLow
- MessageBarkLoud
- MessageReport
- MessageHotkeyUse
- MessageTutorialHint
- MessageThankyou
- MessageMarket
- MessageMana
- MessageMonsterYell
- MessageMonsterSay
- MessageRed
- MessageBlue
- MessageRVRChannel
- MessageRVRAnswer
- MessageRVRContinue
- MessageGameHighlight
- MessageNpcFromStartBlock
playSound($str fileName)
Will play .wav file from Alarms directory
setGlobal($str globalName, $str or $int data)
Will store value(data parameter) in global storage of name(globalName). The global storage can be used to share data in between scripts/cavebot
$str or $int or $nil getGlobal($str globalName)
Will return value from global storage which was previoused saved by setGlobal. If no global was set then NIL will be returned
flashWindow()
Will flash the current game window
writeToFile($str fileName, $str content)
Will the content to the file specified in fileName relative to the bot directory. It means that if fileName is "logs.txt", then a file logs.txt will be created in bot directory
If you want to enter newLine then use "\n". For example writeToFile("test message\n", "logs.txt")
npcTalk($str message)
Will send a message on npc channel
tradeTalk($str message)
Will send a message on trade channel. May not work on some server because they have different channelId. Use talkChannel function in such case
talkChannel($int mode, $int channelId, $str message)
Will send a message on specified channel with specified mode. Useful because some servers have different channelId for game chat. Therefore you can adjust channelIds manually to talk on wanted chat
talkPrivate($str receiver, $str message)
Sends a private message to receiver.
cancelAttack()
Will stop attacking the current target
turn($int direction)
Will make your character turn to one of following directions:
0 or DIR_NORTH- north
1 or DIR_EAST - east
2 or DIR_SOUTH - south
3 or DIR_WEST - west
allowWalk($int itemId)
Makes the item walkable. The cavebot and targetings will be able to move through these items.
disallowWalk($int itemId)
Makes the item NOT walkable. The cavebot and targetings will NOT move through these items.
enableTargeting($bool on)
Will enable or disable (on - true will enable, or - false will disable) main's frame targeting.
If you switch to pvp tab it will work only for pvp targeting (likewise for pve).
enableCavebotTargeting($bool on)
Will enable or disable (on - true will enable, or - false will disable) cavebot targeting.
$creature or $nil getAttackingCreature()
Will return creature which is currently being attacked (also known as targeted) or NIL if no creature is currently attacked.
hideOrShowMainWindow()
Hides the main bot window if it is shown. Shows the main bot window if it is hidden.
$int or $nil getDistanceFromThing($thing wantedThing)
Will return distance from wantedThing. When player is offline it returns NIL. When thing is on different floor it also returns NIL.
loadWaypoints($str fileName)
Will load waypoints from Cavebot directory
stackItems()
Will stack items in open containers
shutdownPc()
Will shutdown your PC
xlog()
Will show login screen. The character is still online
enableFollowWaypoints($bool on)
Will enable or disable (on - true will enable, or - false will disable) following waypoints. Cavebot scripts and targeting will work.
Reenabling cavebot in GUI will enable it back
reachGroundItem($int itemId)
Will make your character mapclick near the ground item with itemId.
$int countGroundItems($int itemId)
Will return the amount of ground items currently visible by the player with given id
enableScript($str scriptName, $bool on)
Turn on (on = false) or off (on = false) all scripts which have name equal to provided scriptName.
IMPORTANT: You cannot make script disable itself. In such case the script will hang and will not be recoverable.
enableCavebotScript($str scriptName, $bool on)
Turn on (on = false) or off (on = false) all cavebot scripts which have name equal to provided scriptName.
IMPORTANT: You cannot make script disable itself. In such case the script will hang and will not be recoverable.
enableBot($bool on)
Turn on (on = false) or off (on = false) all most of bot functionalities (except extras, hunt and hotkeys)
enableFishing($bool on)
Turn on (on = false) or off (on = false) fishing in extras frame. NOTE: if extras is off then this won't have an effect!
enableSpellcasting($bool enable)
Will enable or disable spellcasting for currently active tab(PVE or PVP) depending on enable parameter(true - enable, false - disable)
forceOffensiveSpell($str spellName, $int time)
Will pause offensive spellcasting rotation and only try to use the spell with spellName parameter for specifiec amount of time(time parameter in miliseconds).
The chosen spell will use pre and post casts delay as well condition to see if it should be used.
Good usage: For example our character has 3 spells which are casted one after another for best DPS. However we also have special spells which we don't use very often.
In order to use this special spell on demand we can create hotkey: forceOffensiveSpell("Stun", 1100). Now if we click this hotkey multiple times the spell should be cast
and later on the character will fallback to using the offensive rotation.
Using forceOffensiveSpell("MW", 1100) is a special invokation for disabling offensive rotation. It is worth on some servers which have magic walls which share cooldown.
For example you could have F3 hotkey with mwall crosshair + F3 hotkey in the bot with forceOffensiveSpell("MW", 1100) so the wall can be used ASAP.
forceSupportiveSpell($str spellName, $int time)
Same as forceOffensiveSpell but for supportive spellcasting rotation.
$bool areSpellRangeConditionsMet($str spellName)
Checks if spell with spellName is defined in currently active spellcasting and checks if area/range requirements are met.
$bool areSpellRangeConditionsMetForCreature($str spellName, $creature creature)
Checks if spell with spellName is defined in currently active spellcasting and checks if area/range requirements are met for a given creature.
castSpell($str spellName)
If spell with spellName is defined in currently active spellcasting it will use this spell and apply all required actions (like auto turn)
ITEMS FRAME
forceItemUse($str spellName, $int time)
Same as forceOffensiveSpell but for item rotation