people playing: 41, servers online: 12, games played: 142,000,000 Top Player: Karstnator

  Toribash Community » Help » Tutorials
Register FAQ General Rules Community
Reply
 
Thread Tools Display Modes
Old May 5, 2007   #1
Capt_Zeroth
Member
 
Brown Belt
Join Date: Jul 2006
Posts: 213



mIRC: Battle Script v1
_________________________________________________
IRC Scripts
How To Make A Fighting Script
_________________________________________________
_________________________________________________
Table of Contents:
1. Introduction
2. What is mIRC? What are Scripts?
3. The Basics
4. Variables
5. If-Else Statements
6. Loading External Txt Files
7. Timers
8. The Battle Script v1 Code
9. Conclusion
_________________________________________________
1. Introduction

Ever been in an IRC chat room and feel you need to fire missiles at a particularly annoying individual? Well, the focus of this tutorial is to lighten your typing load with a simple script. Actually, this tutorial will go through multiple scripting commands, and other concepts including: Aliases, variables, loading external files, if-else statements, simple math functions, and timers. This tutorial will only cover the basics, though, and only what is necessary to code the Battle Script. None the less, it will include a great deal of information to beginners. The Battle Script v1 starts a battle with your target. You then load externally a weapon and dmg points, which is then subtracted from the current enemy health. When they die, if you are an OP, you will de-OP them and then kick them from the chat room! Read on, toribashers!

2. What is mIRC? What are Scripts?

Well, if you don't know what IRC or mIRC is, you shouldn't be reading this. But, since I do have pity on poor uneducated people, I'll tell you. IRC (Internet Relay Chat) is a popular chat method. It is virtually lag free and some IRC clients support "scripts". One IRC client that supports scripts is mIRC. To get mIRC and get into the toribash chat room, read this tutorial.

3. The Basics

After you have set up mIRC, its time to move onto basic scripts. You should know how to use color in chat for this tutorial. First, press ctrl+R or press the Script Editor button (image 1) to open the Script Editor. Click on the Aliases tab.


You should see a lines of code here. Ignore them and skip a few lines under them. Type the following code:
Code:
/test /say This is a test!
Press OK and enter "/test" into the window. You should say "This is a test!". This is basically what scripting is. Its a short-cut word. Lets move onto some more scripting commands.

Open the Aliases window (ctrl+R) and try replacing the previous test with this:
Code:
/test /say $1 is cool. | /say $2 is ugly!
Enter into the chat box "/test Capt_Zeroth Veb". You may change Capt_Zeroth and Veb to any 2 names. As you see, $1 is replaced with Capt_Zeroth, as $2 is replaced with Veb. Here is a little bit extra: If you edit the code to have two $'s in front of the numbers, it will require two names or else the code will not execute. Also, writing it as "$1-" will make $1 equal to anything typed after "/test" regardless of spaces or punctuation.

4. Variables

Another function of mIRC scripting is the ability to store data as a variable, allowing you to load it anytime into your scripts. First open up the Aliases tab (Ctrl+R) and replace "/test" with the following:
Code:
/setvar /set -e %testvar $$1- /test /say %testvar is my test variable. /decrease /dec %testvar $1
Press OK and enter "/setvar Twenty Seven". Now, enter "/test". Notice how "/set -e %testvar $$1-" creates a new variable under the Variables tab and sets it to what ever you types as $$1-. When you typed "/test" it replaced %testvar in the code with the variable you set. Also, placing -e in front of the variable makes it so that when you exit mIRC, the variable is deleted. It is not necessary to place the -e. Now, if you enter “/decrease <number>” and then enter “/test”, it decreases the variable by your number. Notice if you do not enter a number, it does not subtract properly.

5. If-Else Statements

"If-Else" statements check to see if a statement is true or not, and if it is (or isn't), it runs a command. Put this into your Aliases:
Code:
/test if (# != #toribash) /join #toribash
If you are in the chat room #toribash, exit it. (Make sure you are logged onto the server irc.quakenet.org) Now, enter "/test". This code checks to see if you are in #toribash or not. If you aren't, it brings you into it. The code "(# != #toribash)" takes "#" (the current channel) and sees if it it "!=" (not equal to) "#toribash". If # is not equal to #toribash, it runs the command "/join #toribash" to bring you into the chat room.

Lets try something more advanced. This includes the if-else statement. Put this code in your Aliases:
Code:
/test { if (($1 > 0) && ($1 < 10)) { if ($1 < 5) /say Number is less than five else /say Number is greater than five } else /say Number is out of bounds }
Now, press OK and enter "/test <any number, letter, or character>". This code determines whether the number you input is greater or less than 10, or it its not a number at all. It then returns one of 3 things. Disecting the code:
Code:
/test { if (($1 > 0) && ($1 < 10)) {
Notice on the first line is a curly bracket {. The { indicates that there are multiple lines to the code, that it has multiple functions to carry out. The first line is similar. If the number you input is greater than 0 and if it is less than 10 (meaning it must be a number to continue), do the following function:
Code:
if ($1 < 5) /say Number is less than five else /say Number is greater than five }
Now it checks to see if the number inputed is less than 5. If it is, you say so. If it is not leas than five, (meaning greater than 5), you say so. On the next line, is a closing curly bracket }. This means that from the previous { to this } is one function to be carried out at once.
The last part of the script:
Code:
else /say Number is out of bounds }
Now if what you input is not even a number, it would not have gotten past the 2nd line and would have gone straight here: If the input is not greater than or less than 5, it is not a number, and so you say "Number is out of bounds".
Got that? Its okay if you don't, we won’t need to go that complex in the Battle Script.

6. Loading External Txt Files

One of the final concepts you will need to know before pulling it all together is loading an external text file. Lets try a simple code into the aliases:
Code:
/test /say $read(quotes.txt)
Press OK. Now, in the same folder that mIRC.exe is in, make a new .txt file called "quotes.txt". Put a few quotes or something on a few lines of the file and save it. Now, enter "/test" into mIRC. It will load a random line from quotes.txt.

7. Timers

Timers can be used to do a function at a specific interval a certain amount of times. Try putting this code in the Aliases and pressing OK:
Code:
/test /timer1 3 5 /say Hello!
Upon entering “/test”, the code will repeat 3 times, once every 5 seconds, you say “Hello!” You may use the following syntax to make your own simple timer:
Code:
/timer[N/name] [time] <repetitions> <interval> <command>
8. The Battle Script v1 Code

You made it this far, now its time to pull it all together make a Battle Script. First put the following code in your Aliases:
Code:
// Battle Script v1 /sb { /set -e %enemy $$1 /set -e %health $$2 * Capt_Zeroth prepares for battle with $1! | /say Health set to $2 } /attack { /set -e %hit $read(hit.txt) /dec -e %health %hit if (%health <= 0) { %health = DEAD! /timer1 1 5 /kick # %enemy DEAD! } * Capt_Zeroth $read(weapons.txt) %enemy - %hit dmg ~ total HP: %health } // End Battle Script
Now press OK. Here’s a quick explanation of each part of the code:
Code:
/sb { /set -e %enemy $$1 /set -e %health $$2 * Capt_Zeroth prepares for battle with $1! | /say Health set to $2 }
When you type “/sb <enemy name> <starting health>”, It creates 2 variables: Enemy name and Health. You then say “<Your name> prepares for battle with <enemy>! Health set to <health>”.
Code:
/attack { /set -e %hit $read(hit.txt) /dec -e %health %hit
This section creates a variable called %hit that will be your damage points. It reads a random hit point from hit.txt (next step) It also subtracts the health by that hit damage.
Code:
if (%health <= 0) { %health = DEAD! /timer1 1 5 /kick # %enemy DEAD! }
Now it tests to see if the health is equal to or lesser than 0. If so, makes health say “DEAD!” This is so there is no negative health. Also, if health is less than or equal to 0, it creates a 1 repetition 5 second timer. After 5 seconds (so he may see his death attack), if you are an OP, kick your enemy from the chat room!

You’re not quite done yet, though. Now make a new .txt file called "weapons.txt" and save it in the mIRC directory. Inside of it put the following:
Code:
arms lazer gun and fires at prepares buckets of butter and launches them at arms the missiles and fires them at bakes pie and launches at primes rocket launchers and fires at focuses mana and fires magic missiles at t3h h4x0r l04dz H4X b0mb and launches it at
These will be the weapons that are chosen randomly and loaded externally. You can add more weapons by simply adding a new line of text.

Now, create another .txt file called “hit.txt” and save it also in the mIRC directory. Inside, put the following:
Code:
11 10 9 8 7 6 5 4 3 2 1 0
These will be all possible damage amounts. If a .txt file's first line begins with a number, create another line before that with the total number of lines. In this case, 11. Do not edit this txt file. It can severely screw up the code.

9. Conclusion

Congratulations, you should be done and working! Remember, you can only attack one person at once. Perhaps in future versions, multiple enemies will be possible. If you have any problems, just post here.

This is my first real script, I hope you like it. If you want to have fun battling, try creating your own chat room and OP you and your opponent. Take turns battling it out, and the loser is kicked!

Don’t forget, feel free to use, abuse, or mutilate this code. Maybe you could make some advancements on it.

PS. A lot of people find this script annoying, and it can be. If you want to battle, try channel #battletothedeath. Also, be careful you don't get auto-kicked because of "excess flood"!

[EDIT] It seems some computers have trouble coping the color codes. The source is attached below with colors! Read README.txt for quick instructions!
Capt_Zeroth is offline   Reply With Quote
Old May 5, 2007   #2
skinnydude908
Ugly Member
 
6th Dan Black Belt
Join Date: Nov 2006
Posts: 633



Re: mIRC: Battle Script v1
zawsomley zawsome! (now to read it, i stole his code before :P)

EDIT: WOW! what a tutorial! when you have the battle script done, go into "#battletothedeath".
Hi
skinnydude908 is offline   Reply With Quote
Old May 5, 2007   #3
Capt_Zeroth
Member
 
Brown Belt
Join Date: Jul 2006
Posts: 213



mIRC: Battle Script v1
Yah, its a long read, but if you already know about scripting, skip to section 8 for the real stuff.
Capt_Zeroth is offline   Reply With Quote
Old May 5, 2007   #4
clownhunter
Member
 
2nd Dan Black Belt
Join Date: Sep 2006
Posts: 330



Re: mIRC: Battle Script v1
I love U
omfg I sell muzik: http://forum.toribash.com/showthread.php?t=80455

<veb> I want to see me giving hampa a bj
<veb> :D
<clownhunter> http://clothing.sitesled.com/How_veb...e_is_today.rpl
clownhunter is offline   Reply With Quote
Old May 5, 2007   #5
?ishi
nanaaaa nanananana na na
 
Master Belt
Join Date: Aug 2006
Posts: 5,689
Clan: [T]



Re: mIRC: Battle Script v1
Now I have the 1000th post... dont double post :@


[T]
#hi


ishi is offline   Reply With Quote
Old May 5, 2007   #6
Ari_Old
Member
 
Brown Belt
Join Date: Jan 2007
Posts: 367



Re: mIRC: Battle Script v1
I've put the scripts on.
Bu how I attack someone?
When I type /test it says:
Twenty-seven is my test variable.
Ari_Old is offline   Reply With Quote
Old May 5, 2007   #7
ADTerminal
Senior Member
 
Black Belt
Join Date: Nov 2006
Posts: 574



Re: mIRC: Battle Script v1
Read the first post
User was infracted for this signature. (Useless signature)
ADTerminal is offline   Reply With Quote
Old May 5, 2007   #8
Ducky
I am your Goddess.
 
3rd Dan Black Belt
Join Date: Sep 2006
Posts: 1,972
Clan: bncy



Re: mIRC: Battle Script v1
Me and Ishi are manipulating this script to give it an rpg feel for #superbattlerpg. I've already done Undead, Orc, Elf and Dragon scripts and Ishi has his Dungeon Master script.

We hope you don't mind we're manipulating the script :/

When we're done (Including all 5 races planned, and 3 subclasses plus a channel bot (Not L, we already have L) to record levels, hp etc.) we'll release everything publicly and give you credit in the readme. Kay? =D
<ducky> The game.
<siku> ducky: i didnt know this was 2005 and 4chan
<siku> sorry, i hate the game and you should shut the fuck up about that retarded bullshit
<siku> you should link us to awesome and edgy motivational pics next or maybe pedobear
<siku> inb4 rep needs toriprime or vip lmao rofl that /b/ is grate
<siku> is this the part where you educate me on memes, further showcasing your amazing 4chan findings
<siku> word x is a meme lmao rofl
<+veb> someone make ducky smod
Ducky is offline   Reply With Quote
Old May 5, 2007   #9
Capt_Zeroth
Member
 
Brown Belt
Join Date: Jul 2006
Posts: 213



Re: mIRC: Battle Script v1
1) To start the battle, type "/sb <enemy> <health>". Now type "/attack". Ta da!

2) Sounds great, Ducky. I'd love to help, but for some random reason, I was just G-lined because I supposedly have a Trojan on my computer. After a scan on all computers on my network using IRC, I found no viruses. I'm trying to work it all out, so until then, good luck!
Capt_Zeroth is offline   Reply With Quote
Old May 5, 2007   #10
Ducky
I am your Goddess.
 
3rd Dan Black Belt
Join Date: Sep 2006
Posts: 1,972
Clan: bncy



Re: mIRC: Battle Script v1
Hmm, that sucks D: Well once it's fixed make sure you drop by into #superbattlerpg to see our progress =D
<ducky> The game.
<siku> ducky: i didnt know this was 2005 and 4chan
<siku> sorry, i hate the game and you should shut the fuck up about that retarded bullshit
<siku> you should link us to awesome and edgy motivational pics next or maybe pedobear
<siku> inb4 rep needs toriprime or vip lmao rofl that /b/ is grate
<siku> is this the part where you educate me on memes, further showcasing your amazing 4chan findings
<siku> word x is a meme lmao rofl
<+veb> someone make ducky smod
Ducky is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:36 AM.




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
ragdoll fighting game physics fighting game ragdoll fighting physics funmotion joints martial arts karate pc mac free game turn based game