A.I. Main Page

Warzone 2100 scripting tutorial Lesson 1

This tutorial is aimed to the beginners, those who already have experience in programming probably can figure everything out on their own.

In this scripting tutorial we are going to learn the basics of Warzone scripting and I will try to show you how simple this scripting language really is.

Ok, a script, what is it? A script is a simple text file with commands, that a game (Warzone in this case) understands and executes for you.

Warzone scripts are located in "Warzone 2100\multiplay\skirmish" folder. Now go to your "Warzone 2100\multiplay\skirmish" directory and take a look at the files located in it. You will see that some files have .slo extension and other files .vlo extension. All WZ scripts consist of two files: a .slo and a .vlo file. Both files are needed in order for the script to be executed, otherwise WZ will not be able to run the scripts when the game starts. These two files have a different purpose, however.

Now take a look at the file names. There are PlayerX.slo and PlayerX.vlo files, X represents player number (0-7). Each PlayerX.slo and PlayerX.vlo file represents a player in the game. There are 8 players in WZ and WZ attaches 1 script to each player. These are main AI (Artificial Intelligence) files, this is the 'brain' of WZ. The commands from these PlayerX files is what making AI units do something in the game, if they were empty, AI wouldn't do anything, just sit still. So, as you can see it all depends on you, what and how the AI will act.

Now take a look at 2 other very interesting files, rules.slo and rules.vlo. If you use Warzone Starter, you will probably recognize the names of the files. WZS uses modified versions of these files (again, a .slo and a .vlo file together make 1 script) to create "Human vs. AIs" and "Human + AI Partner" rules. You might be wondering how these files are different from the PlayerX files (which are AI files, as you remember). Well, rules' files content applies to all the players in the same way, the commands contained in these slo and vlo files are not directly 'attached' to any player, these files have some general information, that affects the gameplay. For example, you know that, when you start the game, all players have the same technology available, depending on the tech level, this technology is given to the players by the rules files. It is just easier, when you have all the general game rules in 1 file you can easily edit.

Ok, these are the main files you will need for scripting, there are some other files, but they are less important.

Now you know that PlayerX files make each player (player 0-7) do something in the game, they are like brain for each AI player. And rules files hold some general rules, that are player independent, like starting technology, victory condition etc. Sounds not that difficult at this point, right?

All we had now was theory, what we will do now, will be some practice.

Important: if you use WZS, start it now, deactivate all MODs (we don't want them to interfere) then go to the 'AI' tab and select 'Original 1.10' for all 8 players. Do the same with rules, select 'Original 1.10 rules'. Now Press 'Apply' button. Your playerX snd rules.slo/rules.vlo files now contain 1.10 AI data. And now (this is important!) select "Don't change" for all AIs and especially for rules. This will prevent WZS from overwriting the script files when you start WZ or press 'Apply' button.

 

Open rules.slo file (.slo files are usually more interesting for editing, as they contain the main script data, .vlo files only contain some data, that a slo file needs for the script). Ok, open it and now press ctrl-f and search for this text: setPowerLevel(1300,playnum);

You will find it only at 1 place in the text. As you may guess it has something to do with the power in the game. This line sets the amount of power a player has. In this particular case this command is executed when the game starts and it sets the starting power of each player. If you start a no-bases game, you get 1300 start-up power. In 'bases' or 'advanced bases' every player has 2500 power. So what we have here is the starting power of a 'no bases' game, yes this is where it is set, nowhere else.

Now replace 1300 with something that will cover all your building needs when you start the game. For example make it 5000. This is how the entire line should look like:

setPowerLevel(5000,playnum);

Save changes. Now start Warzone (again, make sure you have no MODs enabled and rules is set to "Don't change" in WZS, if you use it). Select 'No bases' T1 game, select any map, select any player you want and launch the game. Voila! You have just edited a WZ script. It was pretty easy, wasn't it? Just open a text file, change 1300 to 5000 and you get 5000 power when the game starts.

This is it for this time. What you can do now is to try to learn something on your own. This is how I personally learned WZ scripting. I made a copy of the script I was going to play with and started editing stuff in it, in very slow steps. I was going through the scripts and edited something, which sounded rather clear to me, when I thought I knew what it was for, saved the script, started the game and looked at the results. If I got an error message, I just replaced modified scripts with original files. With time I understood how it works, and when this moment comes you will be amazed how simple WZ scripts really are.

Lesson 2