Sie sind auf Seite 1von 10

RedBot Pro Scripting

Table of Contents:
Page 1 2 3-5 Content Contents Introduction Description A table of contents An introduction to scripting with RedBot Pro, in a way you can understand. Functions Functions can be used to perform actions in game. This contains a comprehensive list of the functions and a brief explanation for how to use them. Variables Variables can be used to obtain information from the client. This contains a comprehensive list of the variables available, and a brief explanation for how to use them. Implementing A guide to implementing these functions and variables in your scripting. Syntax Not yet complete, will include a starter guide to C# syntax, to help you to write scripts properly.

6-7

8-9 -

RedBot Pro Scripting guide by Josh

Page 1

Introduction
Welcome to this guide to scripting with RedBot Pro. Ive been an avid bot user for years now, starting out in the days of MageBombs and Auto RightClickers. I moved on to TibiaAuto, TibiaBot NG, BlackD Proxy, ElfBot NG, NeoBot, XenoBot, and finally RedBot Pro. In my years of experience Ive acquired several skills in bot scripting, including the use of various languages both standard and custom. If youve botted before, chances are you used Lua, XML, or Python. Ill try to use Lua to explain as much as possible, to try make it easier for the majority of readers to understand.

If you wish to share the contents of this document, please acquire permission from Josh at the RedBot Pro forums, or email to XtrmJosh@Gmail.com.

RedBot Pro Scripting guide by Josh

Page 2

Functions
You can consider a function to be many things, usually it is considered to be a trigger, button, or switch. A function is actually something which happens when a trigger, button, or switch is pressed. An example of this is: 1. You press the light switch. 2. Electricity begins to flow to the light bulb. 3. The bulb functions by using the electricity to generate light energy. The same logic applies to programming. 1. You type Say(hi); 2. The bot interprets this into its own code, and sends the message to the Tibia client. 3. Your character says hi. So, lets look at what we can use functions for: Word Actions: Talking to NPCs, players, and casting spells. Movement Actions: Anti Idle, Reach NPCs, and Stepping onto switch plates. Container Actions: Opening containers, closing containers, moving containers. Item Actions: Moving items, Using Items, Trading Items. Trading Actions: Buying Items, Selling Items.

Wow, quite a list, really! So, what are these functions? Well, in RedBot Pro they are available through the help menus, or below. Ill quickly point out a few things: Int = Integer = Number String = Text / numbers. Null = Nothing. Doesnt exist. Command Islocation(optional int range) Wait(int mintime, int maxtime) itemid(string itemname) Explanation Returns true if the script is executed on the SQM of the wpt. Pauses the current script for time (in ms) then resumes after interval. Returns the Id of the item itemname

Value Returned True/false (1/0) Null Int

RedBot Pro Scripting guide by Josh

Page 3

Int Int String Null Null Null Null

Itemcount(int itemid, optional int index) Itemcount(string itemname, optional int index) Itemname(Int itemid) gotolabel(string labelname) closewindows() moveitems(int itemid, int backpackToIndex, optional int count) openitem(int itemid, int backpackFromIndex, optional bool new) openmainbackpack() resizewindows() useitem(int itemid, optional int backpackIndex) useitemon(int idused, int idusedon) Useitemon(int idused, string ground) eatfood() equipitem(int itemid, string locationslot) unequipitem(string locationslot) dropitems(int itemid, optional string ground) pickupitems(optional string ground, optional int amount) flashclient() focusclient() closeclient() pausebot() pausewalking(int timems) playsound(string filename) setcavebot(string onoff) settargeting(string onoff) setlooting(string onoff) setopennextbackpack(string onoff) int maround(int range,

Null Null Null Null Null Null Null Null Null Null Null Null Null Null Null Null Null Null Null Null Int

Returns the amount of the item with itemid in all visible containers, or in the container specified in optional int index. Returns the amount of the item itemname in all visible containers, or in the container specified in optional int index. Returns the name of the item itemid. Sends the cavebot to the waypoint with label labelname. Closes all backpack windows. Moves item itemid to container backpackToIndex, the amount can be optionally specified by amount. Opens the container with id itemid which can be found in container backpackFromIndex. Optionally you can specify true/false in new, to determine if you want to open in a new window. Opens the backpack in your inventory back slot. Resizes all windows to smallest possible size. Uses the item with id itemid, in container backpackIndex. Uses the item idused on the item idusedon. useitemon(1234, "32232, 31234, 7") will use item with id 1234 on the ground at position 32232, 31234, 7. Attempts to eat the first found food item in all containers. Moves item with id itemid to location locationslot. Options appear to be: "rhand", "ring", "belt", lhand, head, back, feet, ammo. Removes the item which is currently in locationslot to backpack 0. Will move item with id itemid to the ground. Will pick up items from the square you are standing on or the square specified in ground, up to amount amount. Makes the client flash in the taskbar. Focuses the client. Closes the client (xlog). Pauses the bot. Pauses the walker for timems milliseconds. Plays the audio file filename. Enables / Disables the cavebot. Enables / Disables the targeting. Enables / Disables the looting. Enables / Disables OpenNextBackpack. This will return the amount of mobs on screen with

RedBot Pro Scripting guide by Josh

Page 4

optional string name) Int Null Null Null Null Null Null Null int paround(int range, optional string name) clearlastonto() mount() dismount() move(string direction) turn(string direction) npcsay(string text) Say(string text)

name name, within range range. If range is 0 then entire screen will be considered. This will return the amount of players on screen with name name, within range range. If range is 0 then entire screen will be considered. Clears the last onto, so items will be looted to first container again. Mounts your current selected mount. Dismounts your current mount. Moves direction. Use N, S, E, W, NE, NW, SE, SW Turns to face direction. Use N, S, W, E. Says text in NPC channel. Says text in Local Channel.

Thats all well and good, showing this list of commands, but they dont make any sense! How can I possibly use this to my advantage? Well, you must learn the ways of scripting. Continue reading, and youll see. Where this table says string, it means that the data replacing the word string should be a string. For instance:

Npcsay(string text) Becomes Npcsay(hi); Some golden rules you might notice, and must follow: 1. Functions are always followed by a semi colon ;, this is like a full stop to C#, it understands it to be the end of a sentence / function. 2. Capital letters are important, and Microsoft Word doesnt like me not using them. Check the RedBot Pro help menu to see exactly what commands have capital letters. 3. Strings are always in inverted commas. For instance: String. This is so the bot recognises it as a string, and not as some code. 4. Integers should NOT be in inverted commas. The bot recognises them as numbers, so dont do it! 5. If a function contains several options (for instance: doAction(string option 1, string option 2, integer option 3) each option must be separated by that comma. The formatting should remain proper too. doAction(string, string 2, 1234) is correctly formatted, dont forget the semicolon!

RedBot Pro Scripting guide by Josh

Page 5

Variables
Do you think of a variable as a container. It contains something. You got a tin in your cupboard? Does it contain beans? Its a variable! The variable holds beans! Simple, right? Well, not really. Its not really like this, though time and time again Ive seen people teach with this method, which I must emphasize now IS WRONG! A variable is like algebra. In algebra you replace numbers with letters, aka 1+2=3 could become a+b=c, where a=1, b=2, and c=3. The thing about C# is, it is a language which uses words, so we cannot simply type words in as they are. Similarly, its easier to pass data like numbers dynamically (quickly, efficiently, and properly) using variables, since the number doesnt have to be obtained from source repeatedly. An example of this is getting your health from Tibia. Its not easy for everyone to know how to use commands like ReadInt32(0x3B0FC, Tibia.BaseAddress) (Thats a bit of code from my own bot, I think the address is wrong though!). Instead, when you type $health, the bot automatically processes this function, and gets your health. Its a simple way of doing it. The main use youll find for variables is to compare them. For instance If your health is under 500, its getting low, maybe you want to heal, so you can compare $health to 500, and if it is less, cast a spell; if ($health < 500) { say(exura); }. It may be hard to believe for some people but this is much easier to do than by writing your own program. It uses less than 5% of the code that my bot uses to do the same thing, and it really is simple. You can create your own variables by typing something like: Variable = 1234; This will make the bot use the number 1234, whenever you type Variable. It is useful for configuring your scripts to always buy a certain amount of manas, and making it easier to change all the places in which you will use this number in your script. Preset variables are set by the bot, and can be used in any script. With these you can get: Character Information: Health, Mana, Cap, etc Location information: Coordinates, Floor. Item Information: Your armor, helmet, amount of manas etc. Game World information: Tiles around you, walkable squares, walls etc.

Before continuing you should understand a few things: The data structure for items is a way of getting information about the particular item easily. If you want to know info on your helmet, you can do $head.id, and to find the amount of items on your head slot you can do $head.count. These data structure parts can be used on any item, grabbed from your inventory or backpacks or even the ground. Its useful for depositing and counting mana potions etc if youre taking them from the depot or a house instead of buying from the shop. Page 6

RedBot Pro Scripting guide by Josh

Bool means Boolean. A Boolean value is either true or false. It refers to a statement. So if you call the variable $battlesigned, it will return true or 1 if you have battle sign, or false or 0 if you dont.

A list of preset variables can be found below: String Int Int Int Int Int Int Int Int Int Int Int Int Int Int Bool Bool Bool Bool Bool Bool Pointe r Pointe r Pointe r Pointe r Pointe r Pointe r Pointe r Pointe r Pointe r Pointe r Bool Bool Int $name (string) $hp (int) $maxhp (int) $mp (int) $maxmp (int) $cap (int) $stamina (int) $soul (int) $exp (int) $level (int) $hppc (int) $mppc (int) $posx (int) $posy (int) $posz (int) $battlesigned (bool) $hasted (bool) $manashielded (bool) $paralyzed (bool) $poisoned (bool) $pzone (bool) $head (pointer) $neck (pointer) $back (pointer) $chest (pointer) $lhand (pointer) $rhand (pointer) $legs (pointer) $feet (pointer) $finger (pointer) $belt (pointer) $conntected $tradeopen $standtime Returns your name as a string Returns your health as an integer Returns your max health as an integer Returns your mana as an integer Returns your max mana as an integer Returns your cap as an integer Returns your stamina as an integer in minutes Returns your soul as an integer Returns your exp as an integer Returns your level as an integer Returns your health percentage as an integer Returns your mana percentage as an integer Returns your position on X (across) Returns your position on Y (up down) Returns your position on Z (floors) True if you have battlesign True if you have haste True if you have mana shield True if you are paralysed True if you are poisoned True if you are in protected zone. Returns the data structure of your head item Returns the data structure of your neck item Returns the data structure of your back item Returns the data structure of your chest item Returns the data structure of your left hand item Returns the data structure of your right hand item Returns the data structure of your legs item Returns the data structure of your feet item Returns the data structure of your finger item Returns the data structure of your belt item Returns true if you are connected to a Tibia server Returns true if you have a trade window open Returns the time in milliseconds that your character has been

RedBot Pro Scripting guide by Josh

Page 7

Int

$lastonto

standing still. Returns the last container which had space during the last moveitemsonto() event.

RedBot Pro Scripting guide by Josh

Page 8

Implementing
Implementing scripts requires several elements, listed below: 1. Planning 2. Consideration 3. Typing 4. Testing

1. Planning
Planning a script requires little effort, but is 100% essential to any scripter. Lets take, for example, a basic healer script. The plan would be something like this; If my health is above 500, do nothing. If my health is below 500, cast Exura. Notice how I considered both if the health is above and below 500. Its always useful to think in this way, consider the opposite of what youre looking for, in case something needs to be adjusted to suit the situation better. This takes us on to consideration.

2. Consideration
Consider all possibilities. If Im under 500hp, is it enough? Do I really want to be casting Exura on 2hp or even less? All things considered, we may want to improve this statement to include some more advanced stuff. After reviewing it, Ive decided this is probably better; If my health is above 500, do nothing. If my health is below 500 and above 200, cast Exura. If my health is below 200, cast Exura Vita. I could go a step further and consider Exura Gran as well, but I feel this is plenty for this example.

3. Typing
Typing your script as above makes it easier to read and understand, typing it out requires a little more knowledge and time. Syntax is important, and you should really learn C# from a C# tutorial, but Ill give a brief example for the purpose of this guide: if (200 < $hp < 500) { say(exura); wait(500); }

RedBot Pro Scripting guide by Josh

Page 9

else if ($hp < 200) { say(exura vita); wait(500); } That is a pretty basic statement, which considers only if health is between 0 to 200, and 200 to 500. The reason I said you should consider if your health is above 500, is in case you want to cast some other spell like exori vis, but dont want it to interfere with casting your healing spells. Its safer to work like this, and far better.

4. Testing
This can only be tested in an action waypoint at the minute, but will soon be added to hotkeys I think. You should try to practise this sort of thing so that when it comes to making your own hotkeys, it will definitely give you a head start when the hotkey system is released!

RedBot Pro Scripting guide by Josh

Page 10

Das könnte Ihnen auch gefallen