autoRun(integer repetitionDelay, function scriptFunction)
Will run the provided function in scriptFunction parameter every miliseconds amount provided in repetitionDelay parameter.
For example:
local function spamTalk()
talk("spam")
end
autoRun(2000, spamTalk)
This will run spamTalk function every 2000 miliseconds(time is counted from the end of function execution)
TIME
integer nowMs()
Returns current time in milliseconds. Useful for measuring time. Example:
local start = nowMs()
someTimeConsumingFunction()
local now2 = nowMs()
local timeElapsed = now2 - start
PLAYER STATE
integer getPlayerHppc()
Returns your character's current hp in percentage (for example if your character has 700hp out of 1000 it will return 70)
integer getHp()
Returns the current health points
integer getMaxHp()
Returns the MAX health points
integer getPlayerMppc()
Returns your character's current mana in percentage (for example if your character has 700mp out of 1000 it will return 70)
integer getMana()
Returns the current mana points
integer 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.
string or NIL getSelfName()
Will return NIL, when character is offline. Otherwise will return the name of your character.
integer 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(integer 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)
integer getSelfOutfitId()
Will return id of current outfit.
integer getSoul()
Will return current soul.
integer getSkillLevel(integer 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
ITEMS
equipItem(integer itemSlot, integer itemId, integer 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(integer 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
integer getInventoryItemId(integer itemSlotId)
Returns id of an item which player has equiped. 0 indicates empty
useItem(integer itemId)
Will try to use item which player has in one of his backpacks with a chosen itemId
usePosition(integer x, integer y, integer z)
Will use the item at position x, y, z
moveItemToContainerWithId(integer containerId, integer movedItemId)
Will move item with provided id (movedItemId) to a open container with id (containerId)
useInventoryItemOnNearbyGroundItem(integer itemFromInventoryId, integer 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.
useInventoryItemOnNearbyGroundItem2(integer itemFromInventoryId, integer groundItemId)
This one requires open backpack with wanted item. Works the same as useInventoryItemOnNearbyGroundItem. Use it when useInventoryItemOnNearbyGroundItem doesn't work.
useInventoryItemOnNearbyGroundItems(integer itemFromInventoryId, integer groundItemId)
Same as useInventoryItemOnNearbyGroundItem but will try to use on all nearby items instead of one.
useInventoryItemOnNearbyGroundItems2(integer itemFromInventoryId, integer groundItemId)
Same as useInventoryItemOnNearbyGroundItem2 but will try to use on all nearby items instead of one.
useInventoryItemOnThing(integer itemId, Thing thing)
Will make your character use item on provided Thing(creature, item)
useInventoryItemOnThing2(integer itemId, Thing thing)
Will make your character use item on provided Thing(creature, item). Requires backpack to be open with inventory item. Use it when useInventoryItemOnThing doesn't work.
useNearbyGroundItem(integer groundItemId)
Will make your character use item with id(groundItemId) withing 1 sqm.
integer getItemCount(integer itemId)
Will return the amount of items that are visible in opened containers
useInventoryItemOnInventoryItem(integer itemFromInventoryId, integer 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(integer itemFromInventoryId, integer 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
collectNearbyGroundItem(integer containerId, integer groundItemId)
Will take ground item with provided id(groundItemId) within 1 sqm of the character to a open container with id (containerId)
dropItem(integer itemId, integer itemCount)
Drops item under your character.
THING - creature or item
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.
CREATURE
attack(Creature creatureToAttack)
Will attack creatureToAttack.
integer countScreenCreatures(string 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
Thing{} getScreenPlayers()
Will return array with all visible players on the same floor.
Thing{} getScreenMonsters()
Will return array with all visible monsters on the same floor.
integer getScreenMonstersCountInRange(integer range)
Will return amount of monsters within range
integer getScreenPlayersCountInRange(integer range)
Will return amount of players within range (excluding yourself)
string getCreatureName(Creature wantedCreature)
Will return the name of wanted creature.
integer getCreatureHppc(Creature wantedCreature)
Will return percentage of current hp of the wanted creature.
integer getPartyShield(Creature wantedCreature)
Will return the id of party shield icon for specified creature (wanted creature parameter)
integer getSkull(Creature wantedCreature)
Will return the id of wanted creature skull icon
integer getOutfitId(Creature creature)
Will return id of creature's outfit
setOutfit(Creature creature, integer outfitId)
Will set the outfit of creature to provided outfitId
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
integer 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
OTHER
sendKey(string hotkey)
Will simulate key press. Available keys:
a) F1 - F12 keys
b) alphabetical keys (A-Z)
talk(string message)
Will send a message on default channel
move(integer 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(string name)
Returns creature, which is visible on screen and has provided name. Returns NIL if such creature isn't visible on the screen
useThingPosition(Thing thing)
Uses tile on the thing's position. The thing may be one of the following a creature or an item on the floor
goToLabel(string labelName)
Will make cavebot jump to waypoint which is labeled by provided labelName
integer getKilledMonstersCount(string 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(string monsterName)
Will reset kill count for provided monster. It is useful after you complete a task.
acceptParty(string{} 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(string{} 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(integer miliseconds)
Will pause the script for provided miliseconds time.
setChaseMode(integer mode)
Will change the chase mode. 0 - stand, 1 - chase
foreachMessage(function 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:
string msg.content - the content of message
string or NIL msg.sender - the sender of message
integer or NIL msg.level - the level of sender
integer msg.mode - the mode of message (all modes will be provided in further section)
integer or NIL msg.channel - the id of message channel (the id may change depending on which channel is open)
integer or NIL msg.x - x position of the message
integer or NIL msg.y - y position of the message
integer or NIL msg.z - z position of the message
msg modes(some may be unused) The number corresponds to the msg.mode value integer:
- MessageSay
- MessageWhisper
- MessageYell
- MessageGamemasterPrivateFrom
- 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(string fileName)
Will play .wav file from Alarms directory
setGlobal(string globalName, string or integer 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
string or integer or NIL getGlobalstring 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(string fileName, string 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(string message)
Will send a message on npc channel
tradeTalk(string 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(integer mode, integer channelId, string 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 manuall to talk on wanted chat
cancelAttack()
Will stop attacking the current target
turn(integer 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
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.
integer 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(string 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(integer itemId)
Will make your character mapclick near the ground item with itemId.
integer countGroundItems()
Will return the amount of ground items currently visible by the player.
enableScript(string 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(string 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.
SPELLCASTING
enableSpellcasting(bool enable)
Will enable or disable spellcasting for currently active tab(PVE or PVP) depending on enable parameter(true - enable, false - disable)
forceOffensiveSpell(string spellName, integer 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(string spellName, integer time)
Same as forceOffensiveSpell but for supportive spellcasting rotation.
bool areSpellRangeConditionsMet(string spellName)
Checks if spell with spellName is defined in currently active spellcasting and checks if area/range requirements are met.
bool areSpellRangeConditionsMetForCreature(string 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(string 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(string spellName, integer time)
Same as forceOffensiveSpell but for item rotation