Page 1 of 3

Questions about scripting

Posted: Sun Apr 20, 2003 4:48 pm
by Stevie D
Here's the contents of the readme that comes with the FO2 mapper in the path ...\Fallout2_Mapper\scripts:
You must have a C preprocessor in order to build the Fallout 2 scripts!
-----------------------------------------------------------------------

When the Fallout/Fallout2 script compiler was made, it did not support
a preprocessing pass. When the scriptors requested support for preprocessor
statements such as #define, we decided the easiest way to provide them with
what they wanted was to just use the Watcom preprocessor that we all had
sitting on our machines already. It only took a few minutes to cook up a
batch file that would preprocess a script file using Watcom and then compile
it using our script compiler. This saved us a lot of time versus rewriting
the script compiler to have a built-in preprocessor.

Although we used the Watcom 10.x and 11.0 preprocessor, pretty much any C
preprocessor should work. Keep in mind that Watcom 11 was released over 6
years ago. Newer C preprocessors are probably far more strict about adhering
to the C language standards than Watcom was back then. Using a newer
preprocessor may generate warnings or errors that wouldn't have shown up
using Watcom 11.0.

I have updated the batch files to support either the Watcom or Microsoft
Visual C/C++ 6.0 preprocessors. You will have to edit p.bat to make
sure the correct line is uncommented for the preprocessor you are using.

If you do not have access to either of these tools, there is a group in
the process of making the Watcom compiler available for download as an open
source product. See http://www.openwatcom.org. At the time of this
writing, release candidate 2 was available for download. Another free
compiler that might work is lcc-win32. It is available for download from
http://www.cs.virginia.edu/~lcc-win32/ . I have _not_ tested building the
scripts with lcc-win32. Based on my experience getting things to work
between Watcom and MSVC, it is likely that the scripts will need some
massaging to get them to work with lcc-win32.

Please note that since we used Watcom during development, that is the only
one that I can claim will produce the correct output for the scripts. The
others should work just fine, but I make no promises.

These are not neccessarily the scripts that shipped with Fallout 2!
-------------------------------------------------------------------

I have done my best to put together something close to the scripts that
shipped with Fallout 2. However, the source for the scripts was not very
well organized and it was difficult to piece together all of the backups into
something I could claim was 'it'. For many of the scripts found here, the
output files generated by the script compiler are not identical to those that
shipped with the game. I have no idea if they are newer or older than what
shipped with the game. I only know that they are different.

You may also notice that there are many compiled script files that shipped
with Fallout 2 for which there is no source here. Fallout 2 shipped with many
compiled script files that were not used by the game. Some of those files are
left over from Fallout 1. Others were used for testing, renamed or cut from
the game before it shipped.


Enjoy!
Chris Jones
1/30/03
Right. So:

1) What has scripting to do with the editor? In other words, what can and can't we do with the editor alone, without altering the scripting in the way this readme talks about?

2) I wouldn't know a C preprocessor if it came up and hit me in the face. In fact, pretty much all of this Readme is gibberish to me. Does what the editor can do mean we won't need the C preprocessor or will making really advanced maps mean we'll need to get involved in this sort of stuff too?

Posted: Sun Apr 20, 2003 5:18 pm
by Jargo
The C preprocesor is only neded if you want to use predefined (in header *.h files) macros in your script. If not you can use only compiler like this:
dos4gw compile script_name.ssl

Posted: Sun Apr 20, 2003 6:16 pm
by Stevie D
Jargo wrote:The C preprocesor is only neded if you want to use predefined (in header *.h files) macros in your script. If not you can use only compiler like this:
dos4gw compile script_name.ssl
OK, thanks. I'd better come back to this when I've messed around with it first hand a bit more.

Posted: Sun Apr 20, 2003 7:02 pm
by Stevie D
OK, I've had a look through the .doc that came with the editor. It's got sections explaining what the functions in the file and tools tabs do, in the drop-down hidden menu bar at the top of the editor screen. What it hasn't got are explanations of the functions within the scripts tab.

Here's a list of them, plus some of my guesses as to what they do. Can someone who knows more correct what I've written plus fill in where I've left anything important out, please:

* List all scripts
I'm guessing the green text that shows up over various areas map when I hit this represent spatial scripts as below.

* Set Start Hex (try saying that after ten pints!)
I notice that when you go into game-mode that your PC 'dummy' is always right in the middle of where you had the screen centred in the editor, when you hit F8. I'd thought that Set Start Hex would fix the starting position of the character to the hex you click on, but the dummy PC is still plonked where you'd centred your screen.

Having said that, when I returned to editor mode, the screen was now centred where I'd hit Set Start Hex.

Would the proper game dump the PC where I'd used the Set Start Hex whenever he entered the map?

* Place Spatial Script
Is this a script that only applies to one area, or item? As opposed to a 'global' script, so to speak, that applies to the whole map.

* Delete Spatial Script
I would have thought this would have been more straight forward. But I used List all Scripts as above, to show all the spatial script(?) tags, then I selected Delete Spatial Script, but wasn't able to use that to select or delete any of those green tags before they disappeared.

* Delete *ALL* Spatial SCRIPTS!
Right, this one pretty much proves wrong my theory that the green tags shown by List all Scripts are Spatial Scripts. I ran Delete *ALL* Spatial SCRIPTS! and then List all Scripts again, and the green tags were still there on the map.

Create Script
This is where I thought the editor would let me into some sort of mad script editing thing. But when I clicked on it, nothing happened, and there's sweet FA about it in the editor readme .doc thing, either. Can anyone shed any light?

Set Map Script
I'd have thought this option would let you select a 'global' script for the entire map (you know, day/night cycle; ambient sfx etc.) But all the scripts that come up in the next menu have descriptions which make me think they're for very localised effects and events. Things like 'Whiny person asks to fix the well'.

Show Map Script
This seems to work hand-in-hand with Set Map Script. When I used the above function and changed the map script, the file name shown by Show Map Script was the one I'd chosen.

Well, that about sums up all of my fumblings with scripting so far. Any and all help would be appreciated and the juiciest bits get to go in the stickies at the top of the forum.

Posted: Sun Apr 20, 2003 7:44 pm
by Temaperacl
Stevie D wrote: * List all scripts
I'm guessing the green text that shows up over various areas map when I hit this represent spatial scripts as below.
The text lists all scripts in the map, including those attached to objects.
* Place Spatial Script
Is this a script that only applies to one area, or item? As opposed to a 'global' script, so to speak, that applies to the whole map.
This is a script that is essentially attached to a hex and triggers when an object enters the radius specified. (I haven't tested this type of script, but according to the documentation, it triggers regardless of the type of item that enters the radius, so the script will have to check the type of object itself.)
Set Map Script
I'd have thought this option would let you select a 'global' script for the entire map (you know, day/night cycle; ambient sfx etc.) But all the scripts that come up in the next menu have descriptions which make me think they're for very localised effects and events. Things like 'Whiny person asks to fix the well'.
You just need to scroll down farther- There are map scripts in the list. The main difference between types of scripts is how they are used and what they have within them- there might be implentation limits that would prohibit it, but there isn't any reason (based on the scripting language itself) why a script couldn't be a map script, a spatial script, and a critter script all at once (Not that I'm suggesting doing that).

Posted: Sun Apr 20, 2003 11:53 pm
by Stevie D
* Place Spatial Script
Is this a script that only applies to one area, or item? As opposed to a 'global' script, so to speak, that applies to the whole map.
This is a script that is essentially attached to a hex and triggers when an object enters the radius specified. (I haven't tested this type of script, but according to the documentation, it triggers regardless of the type of item that enters the radius, so the script will have to check the type of object itself.)
Hmm... strange that 'Delete *ALL* Spatial SCRIPTS!' didn't get rid of them. Do we know if that function is broken? Not that it's particularly useful.

Here's a few more Qs I've got jotted down if anyone'd be kind enough to answer 'em:

* I've been mucking about with the main town map of Klamath. When I F8 it to go into game-mode, why are all the doors trapped, doing 15+ damage when I open them?

* What do the batch files do in the ...\Fallout2 Mapper\scripts subfolders do?

* The Mapper script files open up fine in Wordpad. If I make alterations to them, then save them, is there anything else I have to do (compile them, or something) or is that it?

* There's no *.SSL files nor any ...\script folders in the main FO2 game directories. How do we import our altered scripts into the main game?

Posted: Mon Apr 21, 2003 12:58 am
by Red
Stevie D wrote:Hmm... strange that 'Delete *ALL* Spatial SCRIPTS!' didn't get rid of them. Do we know if that function is broken? Not that it's particularly useful.
Teh fuction works jsut fine, it's jsut that you don't kwno the difference between a script attached to a proto and a spatial script... The spacial scripts are only "attached" to a Hex and are triggered when you enter it's defined radius. Since they aren't attached to anything they needed special comamdns to toy with them and one of those commands is to delete them all.
* I've been mucking about with the main town map of Klamath. When I F8 it to go into game-mode, why are all the doors trapped, doing 15+ damage when I open them?
No idea and will need to get investigated... though aren't all those doors normally open?[/quote]No idea... I'm guessing the game itself initiliazes the doors differently then when you try it in the editor as the editor isn't 100% like the game though it makes it easy to test dialogs. Check the scripts themeselves to see what happens :)
* What do the batch files do in the ...\Fallout2 Mapper\scripts subfolders do?
- P.bat compiles a script. You need to edit it to support the proper precompiler.
- buildall.bat compiles all scripts
- Each directory has it's own ".bat" which compiles all the files contained in itself (buildall uses those batch file to compile everything).
* The Mapper script files open up fine in Wordpad. If I make alterations to them, then save them, is there anything else I have to do (compile them, or something) or is that it?
You need to compiler them, then take the INT file and slap it into fallout2/data/scripts. Remember though that the scripts included in the editor AREN'T necessarely the latest (or even right) ones at all since they took them from an old backup which had it's share of problems.
* There's no *.SSL files nor any ...\script folders in the main FO2 game directories. How do we import our altered scripts into the main game?
See previous anwser. Fallout uses the compiler INT files, not the SSL files.

The "Create script" button doesn't seem to do anything. IMHO it was a function which was meant to load a script editor of some kind for BIS which was either removed for this release or never implimented.

Posted: Mon Apr 21, 2003 4:31 am
by Stevie D
Red wrote:]Teh fuction works jsut fine, it's jsut that you don't kwno the difference between a script attached to a proto and a spatial script... The spacial scripts are only "attached" to a Hex and are triggered when you enter it's defined radius. Since they aren't attached to anything they needed special comamdns to toy with them and one of those commands is to delete them all.
Sorry, can you just clarify there... The proto scripts are the ones that aren't attached to anything etc?
- P.bat compiles a script. You need to edit it to support the proper precompiler.
- buildall.bat compiles all scripts
- Each directory has it's own ".bat" which compiles all the files contained in itself (buildall uses those batch file to compile everything).
I'm really lost here. If you don't mind sparing the time, could you please give as much detail as you can about what the three programs do, and how to use them?

It's not just for me, mate, I want to get something concrete together for the FAQ so we can draw in as many potential mappers as possible. People as tech jargon phobic as me, too. ;)

For instance:

* What's a precompiler and where can I find it?

* Does buildall.bat do the job of all the .bats in the subdirectories at once? (Although taking a lot more time about it, I notice)

* Do I just need to double-click on the .bat compilers for them to do all the work and convert the script files in their directories into the .INT file?

* Where do the .bat compilers save the finished .INT file?

* I've just noticed that I haven't got a fallout2/data/scripts path at the moment. I'm assuming that it'll appear if I unpack all the data in the master.dat file into my main .../fallout2/ path. Is that what I need to do? (I'm not so stupid I won't make multiple backups of the current files, btw ;))

Posted: Mon Apr 21, 2003 4:57 am
by Red
Stevie D wrote:* What's a precompiler and where can I find it?
A precompiler parses data (ie: the SSL code) and allows you to redifine text, and include other files in the first one.
Example:
#define GVAR_MY_STUFF 33
would assign to the text GVAR_MY_STUFF the number 33 (well, technically it owuld replace it before compiling).

Precompilers are usually an integral part of C compilers. SSL scripts were originally designed with Watcom C which is now available free here: http://www.openwatcom.org

You could use most any C/C++ precompiler though, such as Microsoft's Visaul Studio (which is what I use).
* Does buildall.bat do the job of all the .bats in the subdirectories at once? (Although taking a lot more time about it, I notice)
Yes and no. The final effect is that it does that, however how it works is that it actually calls each directories' main compilation batch file (so if you remove it from the secondary bat file it wouldn't compile with buildall), This is technicalities though, for you the answer is probably simply yes :P
* Do I just need to double-click on the .bat compilers for them to do all the work and convert the script files in their directories into the .INT file?
Given you've installed Watcom/MSVC and it's in the path, and you've updated p.bat to use the proper precompiler, then yes.
* Where do the .bat compilers save the finished .INT file?
They're no compilers... They're "batch files" which call the compiler with the proper parameters to compile the SSL files into INTs. I don't know where they're actually saved but my guess owuld be right beside the SSL (ie: in the same directory).
* I've just noticed that I haven't got a fallout2/data/scripts path at the moment. I'm assuming that it'll appear if I unpack all the data in the master.dat file into my main .../fallout2/ path. Is that what I need to do? (I'm not so stupid I won't make multiple backups of the current files, btw ;))
Yes... Will you do that goddamnit! Everytime you're like "ooh, it's not there" and we're "it's in the master.dat". No decent modder works without the DAT files uncompressed. [as a note, I work wihtout the DAT files altogether, though I don't recommend that to the average user].

Posted: Mon Apr 21, 2003 12:14 pm
by ColJack
Stevie D wrote: Sorry, can you just clarify there... The proto scripts are the ones that aren't attached to anything etc?
scripts come in 5 flavours..

1. proto scripts. these are the default scripts that are assigned to the prototype objects. if you just select a door and plonk it into your game, the door will work because it has the default script of being able to open..

2. instance scripts. these are scripts that you can assign to a critter/item once it is placed on your map, and replaces the default script. so for instance you can change the script of a door you placed so that the door is locked, jammed, can be blown up, has a trap on it and so on.

3. spatial scripts. These are placed on the ground and look for when an object enters the set radius of it, a good example is the lifts in the vault, and so on.

4. ai scripts. these set the default behaviour of a critter and their general reaction to certain things, like you shooting them, do they run away, or stand and fight, or charge at you and so on.

5. map scripts. not sure but i think this is where the quests are set for the map, and where it checks for things like your car.


set start hex is used to indicate where the player should "spawn" if he enters the area direct from the world map, or if the map script or other linked map's exit grid doesn't specify a hex to start on.

Posted: Mon Apr 21, 2003 6:57 pm
by Red
ai scripts aren't scripts though, they're just settings.

As for the map scripts, they're used for two things mainly, though more can be done: set the exported/imported vars, but mostly handle how the map works out (reacts to the time passing by changing the light level and such).

Posted: Mon Apr 21, 2003 7:05 pm
by ColJack
Red wrote:ai scripts aren't scripts though, they're just settings.

As for the map scripts, they're used for two things: set the exported/imported vars, but mostly handle how the map works out (reacts to the time passing by changing the light level and such).
then why can i set the ai script of a placed super mutant to, lets say for arguments sake, a brahmin?

fancy making me a blank map script to use on my map that replaces artemple?
you seem comfortable with them..
the one for artemple forces you to a certain startpoint, and starts you as a tribal.
I changed it to the script for the village, and it runs the vsuit movie and gives me the suit, but i don't want the movie to play..

Posted: Mon Apr 21, 2003 7:21 pm
by Jargo
you can't get the jumpsuit and pipboy in any other way than playing this movie (it looks like it is hardcoded)

Posted: Mon Apr 21, 2003 7:27 pm
by Red
ColJack wrote:then why can i set the ai script of a placed super mutant to, lets say for arguments sake, a brahmin?
Because you can. Check ai.txt in data/data and combatai.msg in data/text/english/game

I'll check the artemple script... though I think Jargo's got the thing nailed. Best alternative might be to make an "empty" movie, if we can even do that.

Posted: Wed Apr 23, 2003 12:47 pm
by ColJack
the script for both artemple and arvillag contain a call to a process called initial_inventory.

and the call to run the movie is right before this in the arvillag script..
i'm asuming that calling the movie might give you the vsuit, but it could just as easily be a variable set in the arvillage script..

here is the contents of the arvillag script..

procedure map_enter_p_proc begin
variable new_exp;

if (map_first_run) then begin
play_gmovie(VSUIT_MOVIE);
display_msg(mstr(100));
call Initial_Inven;
inc_general_rep(REP_BONUS_ARROYO_FINISH_TEST_CAVES);
set_global_var(GVAR_TOWN_REP_ARROYO,global_var(GVAR_TOWN_REP_ARROYO)+REP_BONUS_ARROYO_FINISH_TEST_CAVES);
display_msg(g_mstr(1009));
if (global_var(GVAR_START_ARROYO_TRIAL) == TRIAL_NONE) then begin
set_global_var(GVAR_START_ARROYO_TRIAL,TRIAL_SNEAK);
new_exp:=EXP_ARROYO_TEMPLE+EXP_ARROYO_TEMPLE_SNEAK;
give_xp(new_exp);
end
else if (global_var(GVAR_START_ARROYO_TRIAL) == TRIAL_TALK) then begin
new_exp:=EXP_ARROYO_TEMPLE+EXP_ARROYO_TEMPLE_TALK;
give_xp(new_exp);
end
else begin
give_xp(EXP_ARROYO_TEMPLE);

it looks like it might be the line " inc_general_rep(REP_BONUS_ARROYO_FINISH_TEST_CAVES)"


since i'm not a coder, i'm going to leave the exploration to you guys.

Posted: Wed Apr 23, 2003 4:16 pm
by Red
Initial_Inv is atually just an empty procedure defined which does nothing.
It was probably put in there so that eventually people could code in some funky fnuction to add basic inventory but it ended up not being done.

As for the inc_general_rep, I admit I never actually looked into it and it indeed could do more then meets the eye, however I assumed that it just increased your reputation in Arroyo (since you don't have the pipboy yet it's hard to check really :P)

As for it being given at the exit of the other map, that`s not it since when you start the game somewhere else then the artempl.map (use the Ctrl-R save trick), as soon as you enter the main village ap you get the movie and the suit.

Posted: Thu Apr 24, 2003 5:05 am
by Temaperacl
Red wrote:Initial_Inv is atually just an empty procedure defined which does nothing.
It was probably put in there so that eventually people could code in some funky fnuction to add basic inventory but it ended up not being done.
Or it may have just been left-over from Fallout 1 where it was used to determine the characters initial inventory..

Posted: Thu Apr 24, 2003 5:27 am
by Red
That was part of what I meant actually :D

Posted: Sat Apr 26, 2003 2:59 pm
by ColJack
Red wrote:Initial_Inv is atually just an empty procedure defined which does nothing.
It was probably put in there so that eventually people could code in some funky fnuction to add basic inventory but it ended up not being done.

As for the inc_general_rep, I admit I never actually looked into it and it indeed could do more then meets the eye, however I assumed that it just increased your reputation in Arroyo (since you don't have the pipboy yet it's hard to check really :P)

As for it being given at the exit of the other map, that`s not it since when you start the game somewhere else then the artempl.map (use the Ctrl-R save trick), as soon as you enter the main village ap you get the movie and the suit.
I never said it was given at the EXIT to the other map, i said it looks like it might be given as part of the play_gmovie(VSUIT_MOVIE) call.

Ive looked into the inc_general_rep idea, and it indeed does only increase your rep in arroyo.

display_msg(g_mstr(100)); not sure what this does, the only message that appears when you first enter the map (after the vsuit movie ) is "you find yourself in arroyo, the village of your birth" or something like that, but i thought that was done in a .msg file for all of the maps.. ?
and then the "you gained 600 exp points" which is triggered by the give_xp(new_exp); line.

the call to Initial_Inven is on all map scripts ( well it was on all of the ones i've looked at ) and is where you can auto give the player items when they enter the map, like the spear at the arroyo temple entrance.

getting the vaultsuit may well be hard coded to trigger when the vsuit movie plays..

anyone care to make me a "blank" map script with just the display_msg(mstr(100)); line in it?? and another with just the play_gmovie(VSUIT_MOVIE); line in it, to see if it is either of those lines.?

as i said, i'm not a coder, and don't want to start being one just yet..
( i really must finish that book "learn C in 21 days".. i started reading it 6 years ago and got bored with it, although i did get the basics.. )

Posted: Sat Apr 26, 2003 7:23 pm
by Red
ColJack wrote:I never said it was given at the EXIT to the other map, i said it looks like it might be given as part of the play_gmovie(VSUIT_MOVIE) call.
Nor was I. I was just explaining my logic in deducing where the trigger might be and layed it out in public for others to agree or disagree with.
display_msg(g_mstr(100)); not sure what this does, the only message that appears when you first enter the map (after the vsuit movie ) is "you find yourself in arroyo, the village of your birth" or something like that, but i thought that was done in a .msg file for all of the maps.. ?
and then the "you gained 600 exp points" which is triggered by the give_xp(new_exp); line.[quotet]mstr() retrieves a string from the file specified in NAME (at the top of the script). g_mstr a little lower takes it always from generic.msg.
the call to Initial_Inven is on all map scripts ( well it was on all of the ones i've looked at ) and is where you can auto give the player items when they enter the map, like the spear at the arroyo temple entrance.
Yeah... could be used for pretty much anything, and given you don't use it except in Artemple, you could remove the whole thing from all other scripts.
getting the vaultsuit may well be hard coded to trigger when the vsuit movie plays..
Could be hardcoded in pretty much any event, though we know it's one called in arvillag as I specified above.
anyone care to make me a "blank" map script with just the display_msg(mstr(100)); line in it?? and another with just the play_gmovie(VSUIT_MOVIE); line in it, to see if it is either of those lines.?
I'll eventually get to it, if no one preceeds me of course.
as i said, i'm not a coder, and don't want to start being one just yet..
( i really must finish that book "learn C in 21 days".. i started reading it 6 years ago and got bored with it, although i did get the basics.. )
Funnt thing though is that the script doesn't use C, it just uses it's precompiler (which as you can then conclude isn't really an inherent part of C. Although both are linked together like brothers... or something). Basically you lneed to learn the basic principles (begin end ({} in C), if statments, loops (for/with), procedure and function calls. If you already know that then jsut pay attention to the macros (#define and #include statments though #include obviously isn't a macro).