TibiaBot NG Scripting Guide
Scripting Guide: Making your character say something
Things you will learn in this section:
How to make your character say something using a script
Scripts made in this section:
Heal poison by saying "exana pox"
Use haste when you aren't hasting"
Heal yourself with a spell when your health gets below a certain value
Lets start this guide by doing something we do when making programs... The first thing you will learn is a script to make your character say "Hello World". I find that to learn how to script you must look at others scripts. Here is the first script.
Try it out and watch.. Your character will say Hello world once. If you want your character to say Hello world repeatedly add "while not terminated do" before begin. So the script would look like this.
Try that script out. It will say Hello world repeatedly without stopping. You will get muted because it doesn't pause in between saying Hello world. If you want a delay so you don't get muted add "sleep(2000);" Your script will know look like this, it will say Hello World repeatedly and not get muted.
Now that we know about how to make our character say something, lets see if we can make our first useful script. Lets make a script that says exana pox when you are posioned. First we will start out will our hello world script.
Step 1:Change 'Hello World" to exana pox
Step 2:We want this script to check if we are poisoned. So we add "if self.poisoned then" Which means If you are poisoned then it will do the next line of code.
Step 3: We want this script to be working all the time not just once so we put "while not terminated do" in the code.
Step 4:We need to add how much mana we need so that it doesn't try to use the spell with no mana. So we put "if self.mana >= 30 then" That means if your mana is above or equal to 30 then it will execute the next line of code.
Step 5:Add Sleep(100); at the end so the client doesn't lag. Last but not least we need to "Update the world".
Now you have a working script that says exana pox when you are posioned.
Using this script as a base there are many useful scripts you can make. Here is an example and the steps to make some. We will use our exana pox script as a base and make a script that says "utani hur" when you aren't hasting (when you don't have haste on).
Step 1:Change "if self.poisoned then" to "if not self.hasting then" This means if you are not hasting then execute the next line of code.
Step 2:Change the mana from 30 (The mana required for exana pox) to 60 (The mana required for haste).
Step 3: Then change "exana pox" to "utani hur" and you have yourself a script that casts the spell haste when you are not hasting. Also add Sleep(100); at the end to prevent the client from lagging.
There it is a working script that casts haste when you are not hasting.
This time I will show you how to make a healing script. Use the exana pox script as a base again. This time I will use something called a constant. Using a constant is useful when you reuse the same number or variable over and over so if you want to change the number or variable you just have to change one thing not every single thing.
Step 1:Make a constant with the word const and put the health you want to heal at, the mana the spell takes, and the spell you want to use
Step 2: Change "if self.poisoned then" to "if self.health is <= MinHealth then" This means if your health is under or equal to the MinHealth then it will execute the next line.
Step 3: Change "if self.mana" >= 30 then" to "if self.mana >= ManaNeeded" That means if your mana is above or equal to the ManaNeeded then it will execute the next line.
Step 4: Change ('exana pox') to (HealingSpell) You don't need the ' marks around HealingSpell because they are around exura.
Now you have a script that says exura when your health is equal to or lower than 300. If you want to heal at a different health just change the MinHealth value and if you want to use a different spell change the HealingSpell and ManaNeeded values.
Things you will learn in this section:
How to make your character say something using a script
Scripts made in this section:
Heal poison by saying "exana pox"
Use haste when you aren't hasting"
Heal yourself with a spell when your health gets below a certain value
Lets start this guide by doing something we do when making programs... The first thing you will learn is a script to make your character say "Hello World". I find that to learn how to script you must look at others scripts. Here is the first script.
PHP Code:
begin
self.say('Hello world');
end;
PHP Code:
while not terminated do
begin
self.say('Hello World');
end;
PHP Code:
while not terminated do
begin
self.say('Hello World');
sleep(2000);
end;
PHP Code:
begin
self.say('Hello World');
end;
PHP Code:
begin
self.say('exana pox');
end;
PHP Code:
begin
if self.poisoned then
self.say('exana pox');
end;
PHP Code:
while not terminated do
begin
if self.poisoned then
self.say('exana pox');
end;
PHP Code:
while not terminated do
begin
if self.poisoned then
if self.mana >= 30 then
self.say('exana pox');
end;
PHP Code:
while not terminated do
begin
UpdateWorld;
if self.poisoned then
if self.mana >= 30 then
self.say('exana pox');
Sleep(100);
end;
Using this script as a base there are many useful scripts you can make. Here is an example and the steps to make some. We will use our exana pox script as a base and make a script that says "utani hur" when you aren't hasting (when you don't have haste on).
PHP Code:
while not terminated do
begin
UpdateWorld;
if self.poisoned then
if self.mana >= 30 then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
while not terminated do
begin
UpdateWorld;
if not self.hasting then
if self.mana >= 30 then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
while not terminated do
begin
UpdateWorld;
if not self.hasting then
if self.mana >= 60 then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
while not terminated do
begin
UpdateWorld;
if not self.hasting then
if self.mana >= 60 then
self.say('utani hur');
Sleep(100);
end;
There it is a working script that casts haste when you are not hasting.
This time I will show you how to make a healing script. Use the exana pox script as a base again. This time I will use something called a constant. Using a constant is useful when you reuse the same number or variable over and over so if you want to change the number or variable you just have to change one thing not every single thing.
PHP Code:
while not terminated do
begin
UpdateWorld;
if self.poisoned then
if self.mana >= 30 then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
Const
MinHealth = 300
ManaNeeded = 20
HealingSpell = 'exura'
while not terminated do
begin
UpdateWorld;
if self.poisoned then
if self.mana >= 30 then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
Const
MinHealth = 300
ManaNeeded = 20
HealingSpell = 'exura'
while not terminated do
begin
UpdateWorld;
if self.health <= MinHealth then
if self.mana >= 30 then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
Const
MinHealth = 300
ManaNeeded = 20
HealingSpell = 'exura'
while not terminated do
begin
UpdateWorld;
if self.health <= MinHealth then
if self.mana >= ManaNeeded then
self.say('exana pox');
Sleep(100);
end;
PHP Code:
Const
MinHealth = 300
ManaNeeded = 20
HealingSpell = 'exura'
while not terminated do
begin
UpdateWorld;
if self.health <= MinHealth then
if self.mana >= ManaNeeded then
self.say(HealingSpell);
Sleep(100);
end;
TibiaBot NG Code Library
OK ... in every large programming software, we find Libraries, Functions, Methods and Ready to use code
this is very helpful for beginners programmers -like me- as well as professional programmers
