top of page

R.4 Learning how to Script

All the following information was taken from those 3 links, and some other links, and the credits are to their own creators. Populous scripting needs knowledge, so if you never did something like that, and have 0 programming experience, you should probably not try, or at least read everything carefully before engaging in scripting Populous levels.

 

A Tutorial For Making a Single Player Map 

Here comes a big detailed tutorial on making SP maps. Please report me any errors. Hope it helps! 
Index:

-1: Where & How to start
-Creating ideas
-ALACN's World Editor Introduction
-Script Files Intorduction
-Taking Notes 

-2: Using the World Editor
-Using the World Editor in a More Advanced Way
-Applying What Is On Your Mind to World Editor (Without Scripting)
-Texture Changing
-Triggers and Effects 

-3: Scripting 
-How and Where to Start Scripting
-Advanced Scripting
-Applying What Is On Your Mind to World Editor (With Scripting)
-Syntax Information

-4: Language File 
-How to Open and Edit Language Files
-What Code Refers to Which Message? 

-5: Compiling & Testing 
-How to Compile your Scripts & Dealing With Errors
-How to test your level. 




1: Where & How to Start 

Creating ideas 

At the very first do not ever forget that making levels will take long time. 

Now where should i start? 
This is a question that you are going to answer. According to your skills of computer usage and populous playing, this changes. 
But it is obvious that starting with the "main idea of your map" is the best way.Make a cup coffee yourself (don't blame me if you don't like coffee) 
and sit down on your computer chair. Now here it goes: 

What is a main idea of a map? 
Well the main idea of a map is what you want the player to think when playing the level. Will it be a legendary fight between 4 tribes? 
or a solo shaman play with uberquests? may it be a deathmach between two tribes? I think you got the idea... 

The important part in here is to decide in the borders of "what can be done with these tools i have". For example you cannot make a 
"shaman eats trees and gets bigger and bigger and then creates a new world herself and becomes a god"...No this is nothing. 
As you can guess you're limited to create a map which contians only Pop the beginning script languages and world restrictions. 
However this does not prevent you to create a wonderful campaign set because bullfrog has many script and world features that never been used 

Another part of creating a map idea is calculating your time... 
Think about a map and think about approx. how much time will it take...(you'll be available to do this when you finish the tutorial) 
Note this time down and split it up to hours in a daytime...maybe even to days in a week. 

At first you will be confused even if you obviously know your idea. Because the more you get into the editor, the more possibilites come to your mind. 
This is normal. Getting a little out of your beggining idea is not a big bad thing. In fact it is good. Just try not to leave the borders too much behind 

As final words, create an idea, implement it to populous in your mind, see the visions of the level and calculate your time 

Now you have a work program and lots of things to create. 



ALACN's World editor introduction 

AT THE VERY FIRST: USE GRID!! 
ALACN (god bless him) has created a great 3d world editor for populous: the beginning. In this tutorial we're going to use that program to create levels. 

-The Menu Bar 
Contaıns submenus: File, Edit, Options, 

-The File Menu 
-New, 
-Open, 
-Save, 
-Save as, 
-Export Height Map, Exports the minimap as a BMP.
-Exit 

-The Edit Menu 
-Landscape: Brings the landscape edit brush 
-Objects: Brings a window to deal with onject editing 
-Markers: Brings a little windows to move markers 

-Header, 
-Available Spells/Buildings: Brings a windows to edit spells and buildings that can be used in the level 
-Spells Not Charging: Brings a windows to edit spells that do not start to charge at the beginning of the level 
-Allies: Brings a windows to edit who is allied with who 
-General: Brings a windows to edit level name, which cpscr00** file will be used for the computer,fog of war, god mode and guest spells 
-Object Bank: Brings a windows to decide which object bank will be used in the level 
-Map Texture: Brings a windows to decide which lanpscape texture and sky will be used in the level 

-AI Script, 
-Attributes: As we'll use scripting this part is useless to us. You'd better don't mess this up. 
-Script: Shows a window to allow you compile your written scripts and decompile scripts from their dat files to plain text. 

-Language File: As it says in the menu it converts between text and lang** file. 

-Swap Tribe: this swaps the selected tribes objects with the other one. 

-The Options Menu 
-Object List: Brings the Objects put in the map. 
-Brush: Brings a window to customize your landscape brush 
-Info: Brings a detailed info of your map 
-Hide Objects: As it says... 
-Bounding Box: Shows a wifreframe box around objects 
-Show Markers: if you ask me what is this i kill a cat 
The other remaining: Decide how would you like to view your map. 

Now we know how to use the editor in basic way... 
here are some info you should know too: 

-Hold shift to repeat object adding
-Use shortcuts given (this nearly saves half of the time you'll spend in other way)
-DO smooth your lands
-Use 1 for brush size and 5 for speed and just mess (dip) around to create shores and escape "square mountains"
-Do not put objects too near the shaman
-Put a marker near or on every trigger you put. Even if you don't use, it will help you to define locations for flybys
-Put markers in every base where you think you might need...(e.g. shaman's tower, guarding place, base marker* )
-Put two markers; first one indicates where the ai player stops and regroups before attacking, second one indicates attack marker*
-Note down the markers you put.(which marker to where and which position) 

Now you know information to create a landscape, put the tribes & objects and put some markers on it that you don't know what to do with them. 
Marker part belongs to scripting. 

and in the hell what is a trigger? calm down...this tutorial has other parts too  

* = will be explained later in the tutorial 

Script Files Introduction 

Yes you're here...the nightmare part of populous world making. SCRIPTING 

Don't worry it is not as hard as it seems.When you get the idea it gets pretty much easier. 
Before making an introduction to script files, please remember this: 
********************************************************************** 
This kind of script writing is bad: 

 

EVERY 8192 400
{
IF ( INT_MY_NUM_PEOPLE > 10 && INT_M_BUILDING_WARRIOR_TRAIN > 1 )
{
IF ( INT_MY_NUM_KILLED_BY_BLUE > 5 )
{
SET INT_ATTR_AWAY_SHAMAN 1
DO ATTACK BLUE 6 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 900 INT_SWARM INT_LIGHTNING INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 -1 -1 -1
}
ENDIF
}
ENDIF
}

**********************************************************************This kind of script writing is good:

//----------------------ATTACK CONDITION DEPENDING ON NUMBER OF PEOPLE KILLED BY BLUE AND TIME----------------------//
EVERY 8192 400
{
IF ( INT_MY_NUM_PEOPLE > 10 && INT_M_BUILDING_WARRIOR_TRAIN > 1 )
{
IF ( INT_MY_NUM_KILLED_BY_BLUE > 5 )
{
SET INT_ATTR_AWAY_SHAMAN 1
DO ATTACK BLUE 6 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 900 INT_SWARM INT_LIGHTNING INT_NO_SPECIFIC_SPELL ATTACK_NORMAL 0 -1 -1 -1
}
ENDIF
}
ENDIF
}
//----------------------END OF ATTACK CONDITION ----------------------//

And we are going to use the second one; script writing with comments and taking evereything in borders.Script Files are the brains of computer players. You give commands to the computer when you write something in script file.Shortly; You say, computer does.Computer uses these files to set blue restrictions as well. Something like giving one shot spells at the beginning of game or no blue reincarnation etc...Now you ask "how in the hell i'm going to understand and write in my mind all these syntax..."No you don't need to understand every piece of syntax codes. The easiest way to get on with this is to have a correct syntax sturcture guideand a little brain... When writing scripts only look for a syntax code when the codes you remind aren't enough and you really "NEED a New Code"Don't forget that populous has script files written and you can have look at each of them to understand what did bullfrog do to make something work on a specific level.All the marker stuff goes to scripts too. In scripts when you're going to set an attack for ai you need markers, when telling the shaman to stop somewhere and use spells for defense you need markerswhen using time based or condition based triggers you need markerswhen saying to the computer that "this is your base idiot, do not leave it or expand it" you need markers...umm...well you NEED markers.As final words; Scripts are the brains of the game.Taking NotesDo take notes of many things you did within scripts or within the map,take notes of errors you stumbledtake notes of glitches you encountertake notes of what was the idea of map and things related to that2: Using the World EditorIn a More Advanced WayNow i'm gonna refer creating objects that are connected to triggers or connected together and advanced objects.First...TriggersWhat is a Trigger?Trigger means: activate the objects or effects or anything linked to this thing considering conditions i gave(e.g. worship time, shaman only, library, or even no stone head just trigger* )So with this thing you understood that you can connect some effect or discovery(spell, building or mana) to a trigger and put it in a stone head in some way and when worshipped, shaman gains this discovery or effect...There are two big parts i give to this issue. The easy part (stone heads, vaults of knowledge, obelisks that give a discovery) The hard part (effects, object links, spell links, timed triggers, conditional triggers)Now here's how you give a single shot blast spell to blue shaman...i mean the easy part:-First Open objects menu and then create a new stone head which is listed under scenery.-Make sure it belongs to blue otherwise the discovery will go to an other tribe.-After creating your head, Create a discovery which is listed under general and make it neutral.-Click options.-As you can see you're able to select what you want this discovery to give the player-Now select once (permanent and level will be explained) the first row and then spell in the second row and last select blast from the spell list-The fourth row is to write the amount of mana and is activated when you select mana from the second row.Now we have our discovery part done//-Permanent gives the discovery to the player for the rest of the level...Populous does not use a chace for scripts so you cannot count something on a level and bring theResult to the next level...ı know ı would really want that too but nothing you can do with this -Level does the exact same thing permanent does but it does not turn your stone head to a vault of knowledge. USELESS for SP//Here we go to the trigger part-Again open objects and create a trigger which belongs to neutral and listed under general-Click optionsThis menu is the biggest part of the job...i'll first tell how to make a standard stone head and then explain it in an advanced way.-Select proximity(as default) from the first bar. this means everbody can worship this and this is a stone head.-Cell radius will be set 1 for now.-Pray time is how much game turns(approx. 12 turns for 1 second or vice versa i'm not sure :S ) should player worship this totem.e.g.make it 25-Occurances defines how many times can the head be worshipped-Inactive time is the number that defines the losing time...you know when you leave worshipping it slowly ends....this is that time.-Trigger count means how many people are required to worship this head. (can only go upper than 1 in proximity)-Start inactive COMPLETELY USELESSFOR SP just uncheck it-Create player owned, if cheked the discovery goes only to the player that the stone head belongs to, if not blue can trigger a discovery or effect for green so we check this one for now. -Click links and select the discovery you have created then click link. by doing this you have told the trigger to create a stone head from this scenery item, and give this discovery when they worship.Now we have the trigger part done too.//-Since we use scripts, Timed is useless for us-The same goes to Player Death as well-For shaman AoD it creates a stauette of an angel of death...only worshipped by shaman-Library makes a vault of knowledge.-If you select Shaman Proximity, it makes an obelisk and can only be worshipped by shaman so trigger count MUST be 1-Cell radius indicates the number of discoveries a trigger can contain.//And put all these three together on the same square.Congrats! you have a stone head that gives the worshipper a single shot blast.Applying What Is On Your Mind to World Editor (Without Scripting)-Please Don't take this thread as rules...and don't forget that you're free to do anything with/to anythingi will just give ideas to create a more clear shape on your mind.As we come so far, you know how to make some land with raising and lowering tools and you can put objects and stone heads on it.You might think this will be enough to make a working cool map. Actually yes you're right. However what should you do when you want something special? like, shaman worships a stone head and surprisingly no discovery comes, instead a big earthquake spell crushes her settlement or a big volcanoerupts in greens reinc site maybe a new settlement appears immediately or rises from water etc etc...Please remember this: Everything depends on your mind and main idea on this level...do new blue huts and warrior huts fit your mission?will the player need to worship a totem to open her way to red's base? or putting a volcano discovery totem must create an earthquake when worshipping is done?or is the green too powerful and player needs to worship a totem which erodes all the land green has?...you got the idea.Let's say you think "i should kill blue when green worships this stone head"Now the first thing you must do is to decide how to do that.How this must be?-Eroding land to the sea? does this fit the main idea of the mission you chose? does these kind of land disrupting things usually happen on these lands?-Creating an ancient army of firewarriors belongs to green's very old ancestors? Do green have some story like this?-Calling angels of death to bring destruction?The things is to decide the way to do this and after that you must think about the way you're gonna use triggers.Will this destruction be activated by green worshipping on a totem? or a newly raised totem after the one blue had worshipped.When you decide these two things you'll need to mess a little bit with the editor. Try to create the land and stone heads as in your mind and get readyto finish the triggering process.Now here goes some info to implement what's on your mind to the map:-If you want a stone head raise after worshipping one, create the trigger (with options of course) of the first one and link it to the trigger of the second one.I suppose this one is clear enough-If you want to cast an effect or multiple effects at the same time somewhere on the land, put your effects to the places you want and then link them to the triggerif a trigger is only connected to effects it becomes a totem pole-If you want to rise a land with buildings on it from the sea, you'll need to put the effect called atlantis set and atlantis invoke on the same square on the map and on the land you want to rise-If you want to give player some men and/some settlement on a land that already is there you'll need to put the objects you want to give and link all of them to a trigger.*Triggers can be connected together too. ----------------------------------------------------------AS WE COME SO FAR YOU HAVE LEARNED TO IMPLEMENT %60 OF WHAT IS ON YOUR MIND.----------------------------------------------------------Texture Changing/EditingThis is easy...we're gonna use TedTaycoon's raw editor for texture purposes.Download and Install the program and open itAfter that the program will guide you to the rest. it contains a well written help file too.I'm not so experienced in the texture editing related issues so when i tell you how to export and import the rest is up to youOpen the landscape raw bigf0-X (X is the number or letter)and open the palette file pal0-Xthen just export, make changes in any kind of editor (don't change the plaette or save it and use it as a default after every change u made on the palette) and import.Triggers and Effects.I will not include this part as "this does this" because the help file of the world editor perfectly does this.3: SCRIPTING ( oh god..... X.X)How and Where to Start Scripting...Well we're going to start the hardest part of the game but not the tutorial.As told before scripts are brains of the computer players...The best way to start to examine these brains is to extract their whole codes and try to understand what refers to what ingame in that level...I mean decompile cpscr010.dat to see the first level's dakini computer brain. You might get a little bit confused so first have a look atsyntax descriptions at each of you come across. Remember there's nothing you can learn step by step and clearly perfectly...you'llalways have confusions...and this makes you intelligent. You come across a problem and just work to solve it. A classical Computer Man.The first thing you could try is to change scipts that are active in original game. you might change the number of red people that attacks blue in level 5 depending on time or you might change timed triggers in level 19 or you might even try to deal with flyby things in any level.When you understand some little codes some techniques syntax codes, or even what's going on with what code, proceed to the second part.Try to make exact copies of script codes by writing on a notepad by your own hand. With your own comments too. And try a little implementing the numbers & positions to your own map setting. As final words, try to get on with and understand something when dealing with original script files.Advanced ScriptingYeesss...i can see you're smiling devilishly...This is the hardest part of the tutorial Ok...Let's start.First of all, Decompile one of the scripts(e.g. cpscr015.dat) that are contained in my BETA release of Populous: The Afterward Single Player Project. open it up.This part below contains the codes to set the attributes and restrictions of the computer player at the beginning of the level. 

{
IF ( INT_GAME_TURN == 0 )
{
SET $0 0
DO SET_ATTACK_VARIABLE $0
SET INT_ATTR_ATTACK_PERCENTAGE 64
SET INT_ATTR_AWAY_BRAVE 10
SET INT_ATTR_AWAY_FIREWARRIOR 0
SET INT_ATTR_AWAY_RELIGIOUS 20
SET INT_ATTR_AWAY_SHAMAN 1
SET INT_ATTR_AWAY_SPY 0
SET INT_ATTR_AWAY_WARRIOR 80
SET INT_ATTR_BASE_UNDER_ATTACK_RETREAT 1
SET INT_ATTR_BOAT_HOUSE_BROKEN 0
SET INT_ATTR_COUNT_PREACH_DAMAGE 0
SET INT_ATTR_DEFENSE_RAD_INCR 3
SET INT_ATTR_DONT_AUTO_TRAIN_PREACHERS 0
SET INT_ATTR_DONT_DELETE_USELESS_BOAT_HOUSE 0
SET INT_ATTR_DONT_GROUP_AT_DT 1
SET INT_ATTR_DONT_USE_BOATS 1
SET INT_ATTR_EMPTY_AT_WAYPOINT 0
SET INT_ATTR_ENEMY_SPY_MAX_STAND 255
SET INT_ATTR_EXPANSION 30
SET INT_ATTR_FIGHT_STOP_DISTANCE 10
SET INT_ATTR_GROUP_OPTION 0
SET INT_ATTR_HOUSE_PERCENTAGE 35
SET INT_ATTR_MAX_ATTACKS 15
SET INT_ATTR_MAX_BUILDINGS_ON_GO 20
SET INT_ATTR_MAX_DEFENSIVE_ACTIONS 0
SET INT_ATTR_MAX_SPY_ATTACKS 0
SET INT_ATTR_MAX_TRAIN_AT_ONCE 7
SET INT_ATTR_PEOPLE_PER_BALLOON 0
SET INT_ATTR_PEOPLE_PER_BOAT 0
SET INT_ATTR_PREF_BALLOON_DRIVERS 0
SET INT_ATTR_PREF_BALLOON_HUTS 0
SET INT_ATTR_PREF_BOAT_DRIVERS 0
SET INT_ATTR_PREF_BOAT_HUTS 0
SET INT_ATTR_PREF_FIREWARRIOR_PEOPLE 0
SET INT_ATTR_PREF_FIREWARRIOR_TRAINS 0
SET INT_ATTR_PREF_RELIGIOUS_PEOPLE 0
SET INT_ATTR_PREF_RELIGIOUS_TRAINS 0
SET INT_ATTR_PREF_SPY_PEOPLE 0
SET INT_ATTR_PREF_SPY_TRAINS 0
SET INT_ATTR_PREF_WARRIOR_PEOPLE 0
SET INT_ATTR_PREF_WARRIOR_TRAINS 0
SET INT_ATTR_RANDOM_BUILD_SIDE 1
SET INT_ATTR_RETREAT_VALUE 1
SET INT_ATTR_SHAMEN_BLAST 256
SET INT_ATTR_SPELL_DELAY 0
SET INT_ATTR_SPY_CHECK_FREQUENCY 256
SET INT_ATTR_SPY_DISCOVER_CHANCE 100
SET INT_ATTR_USE_PREACHER_FOR_DEFENCE 1
DO STATE_CONSTRUCT_BUILDING OFF
DO STATE_DEFEND ON
DO FLYBY_ALLOW_INTERRUPT ON
DO STATE_STATE_BRING_NEW_PEOPLE_BACK ON
DO STATE_FETCH_WOOD ON
DO STATE_HOUSE_A_PERSON ON
DO STATE_TRAIN_PEOPLE ON
DO STATE_FETCH_LOST_PEOPLE ON
DO STATE_SHAMAN_GET_WILDS ON
DO SET_REINCARNATION ON
DO SET_AUTO_BUILD ON
DO STATE_AUTO_ATTACK ON
DO STATE_BUILD_VEHICLE OFF
DO STATE_PREACH OFF
DO SET_BASE_RADIUS 15
DO SET_BASE_MARKER 0
DO SET_DEFENCE_RADIUS 7
SET $1 0
SET $2 0
SET $3 0
SET $4 0
SET $5 0
SET $6 0
SET $7 0
SET $8 0
SET $9 0
SET $10 0
SET $11 0
SET $12 0
SET $13 0
SET $14 0
SET $15 0
SET $16 0

IF means if...that's obvious...IF you ask me what this means this time i murder an army of cats XD. Every code that starts with INT is an internal variable which means it changes within the game engine itself.This part below contains the code that says computer player to give up and commands all people to attack blueI don't know why we have this code here but i couldn't make the script clearly run without this code...so i recommend you to leave it as it is 


}
ELSE
{
EVERY 64
{
IF ( INT_MY_NUM_PEOPLE <8> 10 )
{
IF ( INT_M_BUILDING_MEDIUM_HUT < 1 && INT_M_BUILDING_LARGE_HUT < 1 )
{
IF ( INT_M_BUILDING_SMALL_HUT < 1 )
{
DO GIVE_UP_AND_SULK ON
}
ENDIF
}
ENDIF
}
ENDIF

I don't know what these codes mean...i guess it should be the mana costs of the spells computer has. This should be left as it is too. 


IF ( INT_MY_NUM_PEOPLE < 80 )
{
DO SET_BUCKET_USAGE ON
DO SET_BUCKET_COUNT_FOR_SPELL INT_CONVERT 8
DO SET_BUCKET_COUNT_FOR_SPELL INT_SWARM 32
DO SET_BUCKET_COUNT_FOR_SPELL INT_INVISIBILITY 40
DO SET_BUCKET_COUNT_FOR_SPELL INT_SHIELD 48
DO SET_BUCKET_COUNT_FOR_SPELL INT_LAND_BRIDGE 66
DO SET_BUCKET_COUNT_FOR_SPELL INT_LIGHTNING 64
DO SET_BUCKET_COUNT_FOR_SPELL INT_HYPNOTISM 70
DO SET_BUCKET_COUNT_FOR_SPELL INT_TORNADO 72
DO SET_BUCKET_COUNT_FOR_SPELL INT_SWAMP 80
DO SET_BUCKET_COUNT_FOR_SPELL INT_FLATTEN 100
DO SET_BUCKET_COUNT_FOR_SPELL INT_EARTHQUAKE 140
DO SET_BUCKET_COUNT_FOR_SPELL INT_EROSION 168
DO SET_BUCKET_COUNT_FOR_SPELL INT_FIRESTORM 320
DO SET_BUCKET_COUNT_FOR_SPELL INT_ANGEL_OF_DEATH 408
DO SET_BUCKET_COUNT_FOR_SPELL INT_VOLCANO 640
}
ELSE
{
DO SET_BUCKET_USAGE ON
DO SET_BUCKET_COUNT_FOR_SPELL INT_CONVERT 4
DO SET_BUCKET_COUNT_FOR_SPELL INT_SWARM 16
DO SET_BUCKET_COUNT_FOR_SPELL INT_INVISIBILITY 20
DO SET_BUCKET_COUNT_FOR_SPELL INT_SHIELD 24
DO SET_BUCKET_COUNT_FOR_SPELL INT_LAND_BRIDGE 33
DO SET_BUCKET_COUNT_FOR_SPELL INT_LIGHTNING 32
DO SET_BUCKET_COUNT_FOR_SPELL INT_HYPNOTISM 35
DO SET_BUCKET_COUNT_FOR_SPELL INT_TORNADO 36
DO SET_BUCKET_COUNT_FOR_SPELL INT_SWAMP 40
DO SET_BUCKET_COUNT_FOR_SPELL INT_FLATTEN 50
DO SET_BUCKET_COUNT_FOR_SPELL INT_EARTHQUAKE 70
DO SET_BUCKET_COUNT_FOR_SPELL INT_EROSION 84
DO SET_BUCKET_COUNT_FOR_SPELL INT_FIRESTORM 180
DO SET_BUCKET_COUNT_FOR_SPELL INT_ANGEL_OF_DEATH 204
DO SET_BUCKET_COUNT_FOR_SPELL INT_VOLCANO 320
}
ENDIF


//
Any code we're gonna write will go here
\\


}
ENDIF
}
SCRIPT_END

As you can see clearly this is a structure of a script file... any code we'll write will go under ELSE in the main IF at the begining of the file.You have to understand that this kind of file editing is not so acceptable thus some codes may not work even if written correctly...for example i had too much problem with flyby scripting things...that part was a nightmare.Now what can you do with scripts?Simply everything the game engine lets...But at the very first you should understand the variable using techinques.$15$4$mymothermakesreallybadcakes$thisisavariableThese are considered as variables because they contain an $ in front of them.You'll see things in script files like theseSET $4 1SET $22 6this means set $thisvariable to a constant number i give which is 6Why would we want to do this?Well we'll use some conditions that should be cheked every 64 game turns but only must be done once...here we'll need variables that we set.Example:We want red to attack blue once with 4 men of atrributes percentages(see INT_ATTR_AWAY_XXX things)to a random building trying to deal 900 damage using the spells lightning and 2 blasts passing from no specific marker and never do an attack like this when blue prays the stone head positioned in 192 80

//ATTACK CONDITION OF BLUE PRAY HEAD//
EVERY 64
{
IF ( $5 == 0 )
{
DO GET_HEAD_TRIGGER_COUNT 192 80 $4
IF ( $4 == 0 )
{
DO ATTACK BLUE 4 ATTACK_BUILDING INT_NO_SPECIFIC_BUILDING 900 INT_LIGHTNING INT_BLAST INT_BLAST ATTACK_NORMAL 0 -1 -1 -1
SET $5 1
}
ENDIF
}
ENDIF
}
//END OF ATTACK CONDITION OF BLUE PRAY HEAD//

Now here have a look at these codes on a more detailed way:

//ATTACK CONDITION OF BLUE PRAY HEAD//
EVERY 64 -This code says that "every 64 game turns do the things listed below"
{ -This opens the "...things listed below" list
IF ( $5 == 0 ) -if variable $5 is equal to 0 then do the things listed below until you see ENDIF code. this have to be set at the start of the script in the attributes section i referred before.
{
DO GET_HEAD_TRIGGER_COUNT 192 80 $4 -This code means: "count the triggers(occurrances) left in a stone head at indicated position and write the reslut in variable $4)
IF ( $4 == 0 ) -if variable $4 is equal to 0 then do the things listed below until you see ENDIF code
{
DO ATTACK(attack) BLUE(player) 4(number of men) ATTACK_BUILDING(as it is) INT_NO_SPECIFIC_BUILDING(random building) 900(damage)INT_LIGHTNING INT_BLAST INT_BLAST ATTACK_NORMAL(don't know) 0(must be 0) -1(marker 1 which the men will regroup) -1 -1
SET $5 1 (and now set variable $5 to 1 so this code will not be activated again due to the IF)
} -finish the "...things listed below" list
ENDIF -close the second IF
}
ENDIF -close the first IF
} -Close the EVERY
//END OF ATTACK CONDITION OF BLUE PRAY HEAD//



Well as you can see when you examine the codes part by part and then understand it as a whole it is not so hard to put on other codes to the script... 
for example now you know how to write something like this: 

Every xxx game turns try to do "something" depending on the variable i gave or a game variable gave and try to match all the conditions written. When the conditions matched and the "something" is done change one variable and prevent this code to be done again forever. 

If you think you could understand this....you understood Scripting fully!  Because everything can be done ingame using this kind of coding. 
Now after this you only need to know how to use this scripting code technique. Start with writing sample scripts. 

Yea i know it is not as hard as it seems  

I give every script that i used in Populous: The Afterward Project with comment lines and you are free to use those codes as samples. 

Applying What Is On Your Mind to World Editor (With Scripting) 

I'll directly jump to the situation this time. 
When you want to create a situation that perfectly fits the level story and mission, 
you have to think about three main things: 

-Which codes can i use to apply this situation
-Is there any examples of use of this kind of situation
-What will i need in the map related to the script. 

DO NOT EVER THINK "CAN I DO THIS??" because the answer is always yes as you have the easiest ai script structure in the world... 
since it is languaged in fortrand yes you can easily do it. 

First of all just have a little look to the syntax informations to find and note down some of which sounds useful to you. 
and after this decide how frequently should the computer check the conditions of this situation...for example if you want an instant effect 
when blue worships a totem you might want to make EVERY 64 54(the second one is subtracted from the first one... 
pop engine only accepts powers of 2 in game turn codes so if you want a specific number you'll need the second number) 
so the script file will nearly check every second if the conditions match and if it can perform the action you gave... 

And after this you'll gonna decide which variables you'll use. For each code there must be variables you have set before. 
This is something like preparing a meal.you have two main ways to do this. 
You can make everything ready at the beginning and by a little chance of failure you give it to the owen. 
Or 
You can start making and finding the ingredients when needed then by a big chance of failure you give it to the owen 
But what if you can't find the blcakpepper for an hour? it is ruined. 

If there's any kind of this situation used in the original scripts first decompile it and examine the file to find the code refers to what's on your mind 
See how it is used,which codes it depend and on and on.... 

Then start writing... ""AGAIN REMEMBER: USE COMMENT LINES TO KEEP TRACK OF YOUR SCRIPTING."" 
When doing this you might need some positions or markers for some codes like GET_HEAD_TRIGGER_COUNT or GUARD_AT_MARKER 
so the world editor must be running at the same time you're scripting.Thus you can get any position needed from the map or put any marker index to anywhere. 

Syntax Information 

Sorry for this but it will be really big waste of time. 
I will not include code by code due to "there are many sources that give these".So just wiki it you'll find a little text at the bottom of the ai scriptinng page 
which shows you exact meanings of syntaxes and how to use each syntax code. 

Just don't forget this: You don't have to memorize all of them...just keep the page open or download it and look at it when needed. 

4: Language File 

How to Open and Edit Language Files 

The best way is to do this is to export language file to plain text file and then open that file...If you google a little you'll find a useful lang editor owned by "Blue Warrior Hut". When editing lang. files you have only one rule. Do not change the character size of the file...i mean if there are 8345679812365398456 characters in the file (including space) what ever you change the file must contain 8345679812365398456 characters. 

What Code Refers to Which Message? 

No absolute answer to this i could find. But i can tell you the easiest way i know to implement messages in your map. 
In the script file of red or green or yellow (only one of them) create a code that shows a message at the beginning of the game and make this message number xxx 
(72,89,122,150...i think it starts about from 89 and ends about at 222 i'm not sure) which will contian the numbered message in the lang file. and after this compile and run the game to the level you have changed...shortly launch your level. Then see what sentence, words, whole message comes up as you scripted...then go to lang file, find that string and change it...this looks to me the easiest way. 

5: Compiling & Testing 

How to Compile your Scripts and Dealing With Errors 

Script compiling easy...when the world editor gives the message " ! compiling succesful" 
open up the script menu from the menu bar and name a log file in whereever you wish 
select the script plain text you've prepared 
select the script file that it will be compiled (this will be the script file that you've mentioned in the header general options) 

example: 
errors.log
Dakini Script for level 1.txt
cpscr010.dat (as if you have written 10 for the red ai script in the header general options) 

errors.log
Matak level 1
cpscr11.dat (as if you have written 11 for Matak) 


you got the idea... 

Now when doing this at first you'll of course get "Compilation Failed Check the Log File for Details" messages lots of time. Now don't panic. because the log file tells every code errors line by line to you...and writes down the expected code too. So you only need to find the line referred and try to find what makes it not run clearly. 
First of all check if "{" and "}" matches theirself...i mean one opens and one closes so the number must be equal between them.And after checking this have a look if you have mistaken any syntax...if log tells you what's the problem it can be easily done but in some errors world editor stops searching for more errors when found one. 
Sometimes it stop when an error found and does not tell the remaining ones. So don't be afraid of trying more and more and more...because this thing can only work after making it %100 Perfect. 

How to Test Your Level 

The easiest part. Just save your finished map to an original populous level....i recommend you the first level so the save your map (of course after making a backup) to level2001 file. Then go to the game and start from the beginning, your level will launch. 


FINALLY.... 

We are done.. I hope it be useful to you. I tried to tell easiest ways to make a great SP map. Sorry if i'm mistaken in anything or please tell me if you find any information wrong. And if you have any questions or requests just post it in forum so i can easliy answer.

 

 

What is a script?

A script is a set of instructions that Populous: the beginning reads and uses to command the computer controlled players.

Each level can have up to 3 scripts used at once, for each tribe respectively.

A script must also have an accompanying attribute file, which stores the default values for all internal_attribute_variables and the restrictions on buildings/spells similar to a header file used to set default restrictions for the player; I find it easier to simply set them all ON and simply not include them in the script if you do not wish the AI to use them. There is a built-in tool to do this on this scripter.

A script can be as simple as the following:

 

 

{   IF ( INT_MY_NUM_PEOPLE < 10 ) { DO GIVE_UP_AND_SULK ON } ELSE { SET INT_ATTR_EXPANSION 50 } ENDIF   } SCRIPT_END

Populous cannot read that and utilise it to control the AI so you need a compiler to compile it to the correct format, and stored in files such as cpscr010.dat (located in the …Bullfrog\Populous\levels directory)

The compiler we will be using for this tutorial is World Editor’s compiler, and can be found here. This also includes an attribute file editor, but as I have already stated – this is not really necessary. You will also need a plain text editor (such as notepad) to edit the scripts in their decompiled form.

A basic script layout

 

 

  { IF ( INT_GAME_TURN == 0 ) { // set starting attributes   SET INT_ATTR_EXPANSION 50 SET INT_ATTR_MAX_BUILDINGS_ON_GO 5 SET INT_ATTR_HOUSE_PERCENTAGE 20   }

This part is triggered as soon as the level starts (game turn 0)

And is usually used to set up initial attributes and anything else that has to be done immediately on level start.

 

 

  ELSE { // rest of script   DO CONVERT_AT_MARKER 10 DO SPELL_ATTACK INT_ANGEL_OF_DEATH 10 -1   } ENDIF   } SCRIPT_END

Everything else that you need to do is put in this area.

Variables

 

 

INT_GAME_TURN

is an internal game variable and cannot be changed by the script – it is however changed by populous as the game progresses and can still be referenced to in order to trigger things, which is what happens initially at the start of the level with most scripts.

 

 

INT_ATTR_EXPANSION

is an internal attribute variable and can be changed by the script and controls the ai’s behaviour throughout the level. You can tell it is an attribute variable as it starts with INT_ATTR.

To change an attribute you use the SET command like this:

SETInternal_attribute_Variableconstant/user_variable

Exemplar:

 

 

SET INT_ATTR_EXPANSION 10 SET INT_ATTR_EXPANSION $var1

User Variables

There is also another type of variable which you can create yourself, a limit of 64 possible. They start with the dollar sign prefix ($) and may contain indentifiers, constants, internal attribute variables or internal game variables.

Exemplar:

 

 

SET $var1 INT_BLAST SET $var2 INT_MY_NUM_PEOPLE SET $var3 10 SET $var4 INT_M_SPELL_BLAST_COST

This has stored the identifier of the spell Blast in $var1 and could be used in an attack command if necessary.

It also stored the total number of people in $var2 that the tribe (using this script) has currently. A good waste of a variable, as the internal game variable can be referred to directly.

The constant "10" has been stored in $var3, useless really but it is still possible.

The mana cost of one shot of blast is stored in $var4. Another waste of a user variable, unless used cleverly with conditions, that will change the spell cost it is looking for.


Variables must have a name (like above) and start with a $ prefix, they cannot contain spaces and the data they store cannot contain spaces either.

Operators

Operators are used to test whether things are true.

Exemplar:

 

 

IF ( 4 > 3 ) { // do something } ENDIF

In this case, it will always be true, 4 and 3 are constants and unless the laws of the universe change : 4 will always be greater than 3 and thus the code will be executed every game turn.

However, you can use these operators to test variables against variables, or variables against constants/internal game varables.

header 1header 2

 

 

IF ( $var1 > 10 ) { // do something } ENDIF

Code only executed if $var1 is greater than 10

 

 

IF ( $var2 < INT_MY_NUM_PEOPLE ) { // do something } ENDIF

Code only executed if $var2 is less than the number of people in the computer’s tribe

List of operators and their meanings:

  • > greater than

  • < less than

  • >= greater than or equal to

  • <= less than or equal to

  • == equal to (2x =)

  • != not equal to

 

The IF Statement

Basic Conditional Statement

 

 

IF ( 4 > 3 ) { // do something } ENDIF   IF ( $var1 <= 4 ) { // do something } ENDIF

The if statement tests whether certain values are true.

In the first one, if the constant “4” is greater than the constant “3” it will execute whatever is inside the braces { }

The second statement tests whether a variable ($var1) is less than or equal to the constant “4” If it is true it will execute whatever is inside the braces.

All if statements must be contained in brackets Then proceed with an opening brace Then some code e.g.

 

 

SET $var1 2 SET INT_ATTR_EXPANSION 100 DO BUILD_AT 12 13 INT_SMALL_HUT

You can also provide alternatives, in case the initial statement is false e.g.

 

 

IF ( INT_BLUE_PEOPLE < INT_RED_PEOPLE) { DO TRIGGER_THING 1 } ELSE { // do something else } ENDIF

These are done with ELSE commands and must have a closing brace before them } and a new opening brace { , at the very end it must have a closing brace } followed by ENDIF

You can also put more conditional statements inside the ELSE braces, but be sure to close them properly before you close the initial IF statement.

EVERY Statement

This is comparable to a loop in programming, if it was stripped to its basic definition of a neverending loop.

It relies on game turns in populous, 12 game turns equal 1 second. (This can be changed in the debug menu, but that would probably mess things up, so don't change it!).

So if you want something triggering once every minute it is a simple matter of computing the game turns from seconds e.g.

One minute = 60 seconds 60 x 12 = 720

But: EVERY commands must always be a power of 2 number

i.e.

2^12^22^32^42^5

2481632

 

 

EVERY 1024 { // do something }

Example EVERY command, it only needs braces for the actual EVERY statement.

If you did want something executing every 720 game turns, you can use an offset to alter the loop to 720.

 

 

EVERY 1024 304 { // do something }

This subtracts 304 from 1024 to get your final number you desire.

How to combine IF and EVERY statements

The following is an example loop, and some of the contents will trigger only if the conditions are met:

 

 

EVERY 512 { DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 7 1 $wild IF ( $WILD > 0 ) { DO CONVERT_AT_MARKER 1 } ENDIF }

This will be triggered every 42.7 seconds (to 1d.p.) (512/12 = 42.7).

 

 

DO COUNT_PEOPLE_IN_MARKER COUNT_WILD 10 5 $wild

DO COUNT_PEOPLE_IN_MARKER tribe marker radius variable

COUNT_WILD allows it to count the number of neutral people.

It is best to set the radius to around 5 or 7, any larger and there is a greater chance the wildmen will wander outside of the convert(command's) range.

More about converting:

The state command DO STATE_SHAMAN_GET_WILDS ON is useful as until this is turned off, they will continue to check within their INT_ATTR_EXPANSION for wild men, and will convert on their own.

 

 

 

bottom of page