New Modder-wannabe [Scripting tutorial by TryKos on page 2]

Discuss the creation and scripting of new fan-made games and mods for the Fallout series of games.
User avatar
ColJack
Vault Scion
Vault Scion
Posts: 175
Joined: Sat Apr 19, 2003 8:01 pm
Contact:

Post by ColJack »

how do you get on with scripting if you keep making spelling mistakes?? :-)
you must spend hours looking for the one instance where you misspelled the name of a variable or function call.. :-)

damn it.. my smilies havent loaded again... ADMIN!!.. sort it out.. all i see is the crying one.... :cry:

that was ment as a light hearted joke, not a derisive comment about your typing skills...

although, i did lol at the fact you made spelling mistakes in the post pointing out you keep making spelling mistakes..... :-)
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

Heh, case of point... I always make tons of mistakes if I don't proof-read, which is something I often skip altogether.

And indeed my programming somtimes suffers from my bad spelling...

Mixing a O and a 0, a 1 and an l... These are the evil ones since you don't see it at first glance.
...
User avatar
ColJack
Vault Scion
Vault Scion
Posts: 175
Joined: Sat Apr 19, 2003 8:01 pm
Contact:

Post by ColJack »

yeah.. they really should put a slash through the zero in the fonts... make it a lot easier.. and maybe have the option to have numbers in a different colour..?
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

Most IDEs put number in colour - however only when the number is a number (as opposed to a part in a variable name). Most of the times that mistake will happen in variable names, since it's easyly noticeable when you screw up writing a number.

One of the worst things for typo-prone programmers is self-declaring variables. Quite frankly most programmers loathe it wether typo-prone or not.
Suppose this VB code:

Code: Select all

bleat0=1
if bleatO=1 then
  DoSomething
End if
You run it, it compiles but doesn't execute DoSomething. So you debug it, you check bleat0 and it's value is indeed set to 1, so you start wondering wether the damn compiler is screwy; until you find the typo. BleatO is instantiated as a Variant of of Null value which if compared to a number is 0.

Thankfull there's the "Option Explicit" line you can add to your VB code to avoid stuff like that.
...
User avatar
DarkUnderlord
Paragon
Paragon
Posts: 2372
Joined: Wed May 01, 2002 7:21 pm
Location: I've got a problem with my Goggomobil. Goggo-mobil. G-O-G-G-O. Yeah, 1954. Yeah, no not the Dart.
Contact:

Post by DarkUnderlord »

ColJack wrote:damn it.. my smilies havent loaded again... ADMIN!!.. sort it out.. all i see is the crying one.... :cry:
There's no problem, that's the only smilie there is.
ImageImageImageImageImageImageImage
User avatar
burgermeister01
SDF!
SDF!
Posts: 20
Joined: Wed Apr 23, 2003 10:46 pm
Location: Rockford, IL

Post by burgermeister01 »

Hey, Red, my friend is gonna bring me msdev on a disk tomorrow, so if you could please please give me some instructions on what to do once I have it, that would be great. Believe me man, if I knew you in real life, I would kiss your feet in gratitude for any help you can give me. Or I would wash your car, or something equivelant to that. But yea......please help me.
My mantra: "Please for the love of God, just work..."
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

Check this out:

http://www.duckandcover.net/forums/view ... 7528#87528

1 year ago.

This is what I currently use to precompile my scripts. I'm not using the batch file since I plan on making a proper one for myself, and ideally have it compatible with win9x which is a major pain in the ass.
  • Make sure the msdev bin is in your path
  • Go into the SSL's directory you want to compile
  • Run that commmand in the URL above
  • Run

    Code: Select all

    ../dos4gw ../compiler <script>.i
    Note the ".i". The batch files provides this weird workaround renaming it to a temp file. This isn't needed...
...
User avatar
burgermeister01
SDF!
SDF!
Posts: 20
Joined: Wed Apr 23, 2003 10:46 pm
Location: Rockford, IL

For curiosity's sake

Post by burgermeister01 »

Hey, thanks Red, I appreciate that. I'm still at school right now, so I can't try out your instructions yet, but I'm kind of curious. That long command you referred me to, what does all that actually mean?Or is there some list you could show me with all of those switches so I could just see for myself (since you hate typing, apparently)?
My mantra: "Please for the love of God, just work..."
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

There are probably a bunch of options which are totally useless, basically I slapped as many as I though were useful (and relevant, no point in putting optimization flags...) until it actually processed a KA scripts.

Also remember this is for Visual Studio 7 so some options might differ.

for help just type: cl /?

Code: Select all

/Fx merge injected code to file
/D<name>&#123;=|#&#125;<text> define macro
/C don't strip comments
/u remove all predefined macros
/P preprocess to file
/TP compile all files as .cpp
/Fx: Not quite sure what that was but I put it in just in case.
/D: Defines macros (and can assign values). I set __DEBUG here because the KA scripts used __DEBUG to impliment their debug messages.
/C: Leaves the comments. You might want to turn this on to save space/time, however it becomes harder to debug -- and only saves space/time while compiling/preprocessing, so unless you have very little space or a very slow computer there's hardly any reason to remove the comments.
/u: Removes the normal C macros which are normally used when you compile (Like TRUE and FALSE in msdev)
/P: VERY important, makes the .i file instead of the .obj file :)
/TP: Forces C++ parsing. I beleive there are additional macro controls (or predefined macros removed by /u anyway -- like templates for example) for C++. This used them. I suggest you force C instead of C++. This was put in to tell the preprocessor how to process it as otherwise it complained. So I suggest putting /TC instead, which forces normal C. I put C++ since I wanted to test stuff out, but well, I don't even know what to test :P.
...
User avatar
burgermeister01
SDF!
SDF!
Posts: 20
Joined: Wed Apr 23, 2003 10:46 pm
Location: Rockford, IL

Post by burgermeister01 »

Okay Red, I'm getting really close now. I followed your instuctions the best I could, but what happens is when i do this

Code: Select all

D&#58;\msdev\Common\MSDev98\Bin\dos4gw compile %SCjerkey.i
I get an error message reading: scjerkey cannot be found. I have tried all sorts of different spellings and such, so it's that cannot be it. What could I be doing wrong? I have a pretty good idea its that im doing something wrong with visual studio, because the .i file says its size is zero. I'm guessing I'm messing up the first instruction you gave me because I'm not sure what you mean by "make sure msdev bin is in your path". What do you mean? When I was trying to get ruby to work for this, I remember the readme file said I had to add a line called set path to autoexec.bat, so that's what i inferred you meant. Am I wrong there?
My mantra: "Please for the love of God, just work..."
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

First make sure cl is in your path (that's the bit about the bin). Run "cl" and you should get a message along the lines

Code: Select all

Microsoft &#40;R&#41; 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
Copyright &#40;C&#41; Microsoft Corporation 1984-2001. All rights reserved.

usage&#58; cl &#91; option... &#93; filename... &#91; /link linkoption... &#93;
If this works then you can precompile.

Go into the SSL directory where you want to compile your script and type the above mentioned line to prcompile - here modified with comments I posted there too:

Code: Select all

CL /P /C /Fx /u /TC <script>.SSL
This should generate the <script>.i file. Note that this directory should be in a subdirectory like the others, NOT beside the compiler.exe, otherwise you'd need to change the #includes to point to the proper path.

Hargh [stuff removed because it was too complicated and I'm a crappy teacher which can't explain stuff simply]

Go into one of the scripts directories (say BASE) and put your SSL file here. Run

Code: Select all

..\dos4gw ..\compile yourscript.i
and it should work.
...
User avatar
burgermeister01
SDF!
SDF!
Posts: 20
Joined: Wed Apr 23, 2003 10:46 pm
Location: Rockford, IL

I want to die

Post by burgermeister01 »

I'm getting closer......to killing myself in frustration! At first, I ran cl and I saw that for some reason it was using watcom, so i say 'hmm.....thats not right, oh well lets try it anyways'. so i go to the next step and i did actually manage to get a .i file with a real size, but in the process i got error messages saying that the defined .h files could not be found......also the only switch watcomb didnt support was /u. I'm guessing that had something to do with it. Anyways once, I got the .i file, despite the error messages I tried compiling it anyways. That didn't work at all mainly because I'm really confused on your instructions. So then I say, 'shit this isnt working', so I uninstalled watcom, restarted my computer, and now cl does nothing at all. This is the line I have in autoexec.bat

Code: Select all

SET PATH=D&#58;\msdev\Common\MSDev98\Bin
. What is wrong with that? The next question, why it can't find the .h files I'm guessing will fix itself once msdev is actually working. The final question that still boggles me is what the hell is up with that last command? you have two sets of ../ does that mean that i have to give the path to each of those programs??

Now, I know I'm getting ahead of myself but this is soemthing I asked awhile back and was never addressed, but once I do actually have the goddamned .int file, how do I get it, and the corresponding .msg file back into the master.dat?

I'm sorry I'm so retarded about this Red, and I thank you for helping me. I don't think you're a bad teacher, it's just that I'm a visual learner and its kind of hard to show me how to do this over the internet you know. This whole mess wouldnt even exist if they would actually teach me how to do this stuff in my c++ class......but instead we get to spend like the whole year fucking around with those idiotic matricies in an out-of-date IDE arggg!!
My mantra: "Please for the love of God, just work..."
User avatar
burgermeister01
SDF!
SDF!
Posts: 20
Joined: Wed Apr 23, 2003 10:46 pm
Location: Rockford, IL

btw

Post by burgermeister01 »

It might not hurt to add the fact that when I was unzipping all this visual studio 6 stuff, i guess my friend's cd was scratced or something, because the copy process halted with an error at about 70% of the way through. I looked at the files though, and they seemed pretty disconnected from one another, and msdev was there so I figured maybe I got all that i needed. Am i wrong? Could I be missing vital files that are prohibiting it from working?
My mantra: "Please for the love of God, just work..."
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Re: I want to die

Post by Red »

burgermeister01 wrote:This is the line I have in autoexec.bat

Code: Select all

SET PATH=D&#58;\msdev\Common\MSDev98\Bin
. What is wrong with that?
Nothing, that's perfect actually
The next question, why it can't find the .h files I'm guessing will fix itself once msdev is actually working.
The problem isn't that your msdev is b0rk, it's that it can't find the headers. Let me put some more emphasis on the fact that you NEED TO GO INTO A SUBDIRETORY under SCRIPTS, like SCRIPTS/MAPS or something. Otherwise the inlcuded headers specified in the file will be wrong. You could always fix them in the file but I think you should keep closer to the originals as much as possible until you have a better understand of how this works
The final question that still boggles me is what the hell is up with that last command? you have two sets of ../ does that mean that i have to give the path to each of those programs??
That's absolutely corret. You need to specify the path to both apps and this in relation to the directory I keep telling you to be in.
Now, I know I'm getting ahead of myself but this is soemthing I asked awhile back and was never addressed, but once I do actually have the goddamned .int file, how do I get it, and the corresponding .msg file back into the master.dat?
Ideally you don't want to add this to master.dat. You'll either make your own new DAT file and use FAME/ModRunner or supply a fresh patch000.dat or supply the raw files. Obviously while in testing stages you'll rather use the last approach: the raw files, as it's much easyer. Put your .INT into fallout2/data/scripts. Make sure you've extracted scripts.lst from patch000.dat in data/scripts and update SCRIPTS.LST with your new script. Also extract srcname from patch000.dat or master.dat (can't remember which is the correct one, if you find it in patch000.dat use that one, otherwise use master.dat) in data/text/english/game. Update that too. Run the editor, select/add a critter to the map (which you again previously extracted), make his script point to your new script, save the map. I'm not sure about this part but you might need to rename patch000.dat before you run the game and possibly editor, as it might use the script.lst from patch000.dat instead of the one you put in the Fallout2/data/scripts directory. So rename it to patch000.bak or something (just make sure NOT to name it patch002.dat -- ie changing just the number -- as the game will check to find any patchNNN.dat - well, technically it only looks for pair numbers for some reason...)


For Watcom, well, you'll have to look at the precompiler options. Chances are that you've not told it to JUST precompile, which you need to do as otherwise it'll try to compile to an OBJ or an EXE which isn't something you want since you're aiming to compile into an INT script...
The options are obviously quite different form msdev and Watcom.
...
User avatar
TryKos
Scarf-wearing n00b
Scarf-wearing n00b
Posts: 28
Joined: Sun Apr 27, 2003 8:14 pm
Location: Russia
Contact:

About BIS compiler and Watcom preproc

Post by TryKos »

Hi there, guys.
I've decided to put my 2 cents about script compiling with BIS compiler here.

Step 1. Get OpenWatcom preprocesson from OpenWatcom site. URL is: http://www.openwatcom.com/ftp/zips/c_nt.zip (850 Kb only, and no need for megatonn MSVC installations at all! Thanks to ABel, who pointed this out). (If you on Win98/Me see Issues below).

Step 2. Unzip contents of downloaded archive into any temp directory, then cut/paste all files from "temp/binnt" to your "Fallout 2 Mapper/scripts" folder. There must be wcc.exe, wcc386.exe and 2 dll's with same names.

Step 3. Open file "P.bat" from "Fallout 2 Mapper/scripts" in Notepad, find string "@rem Watcom 11 users uncomment the following line:" and make next string look like that: "@..\wcc386.exe temp.c /pc /fo=temp.i /w4"
Find string "@rem The path in the following two lines should point to the Fallout 2 folder:" and edit next two strings to point on your Fallout2 folder. This is path to folder, where your compiled scripts will be placed.
(I'm personally don't wanted to immediately replace existed scripts with compiled ones, so I'm created folder "CompiledBIS", and edited this strings to
"@md D:\FalloutStuff\CompiledBIS
@copy temp.int D:\FalloutStuff\CompiledBIS\%1.int")

Step 4. Edit any script from "scripts\something" folder and save it there.

Step 5. Run file with extension .bat from within folder, where your edited script lies. (If you want to compile only one script - look in this file and make your own, its quite easy). It will compile all scripts from this folder, place results in folder, which you choose in Step 3, and output any errors in "err.log" file.

Step 6. Copy your compiled scripts to "Fallout2\data\scripts" directory.

Step 7. Run the game and look, how your modified script screw it all 8)

Possibly issues:
1. Im not perfectly sure, that Watcom preproc binaries will work on Win98/Me systems (judge from their "nt" filename parts). It works perfectly on XP, and I havent heard about any troubles yet. If not, maybe DOS version of preproc helps you http://www.openwatcom.com/ftp/zips/c_doswin.zip (another 880 Kb).

2. BE WARNED! Source files, shipped with editor, are from version 1.0 of Fallout 2. So, if you blindly compile any file from editor and stuck it into game - be ready for full spectre of 1.0 glitches (missing car and so on).
Check first, if script, that you want to modify, present in patch000.dat. If it there - bad luck, you must learn&use Noid compiler/decompiler (its not so hard thing to do 8) ). If not - 99% probability that all be alright.

Hope this helps anyone. And sorry for my bad English.
In this world there are two kinds of people, my friend...those with Power of Moon Prism, and those who dig. You dig.
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Re: About BIS compiler and Watcom preproc

Post by Red »

TryKos wrote:2. BE WARNED! Source files, shipped with editor, are from version 1.0 of Fallout 2. So, if you blindly compile any file from editor and stuck it into game - be ready for full spectre of 1.0 glitches (missing car and so on).
Check first, if script, that you want to modify, present in patch000.dat. If it there - bad luck, you must learn&use Noid compiler/decompiler (its not so hard thing to do 8) ). If not - 99% probability that all be alright.

Hope this helps anyone. And sorry for my bad English.
The warnign is a good one, however read the docs better, it mentions they were gathered up as well as they could from the backups. Which means it might PREDATE Fallout2, or include patches... We'd need to compare all the compile binaries to be really sure... You done that?
...
User avatar
TryKos
Scarf-wearing n00b
Scarf-wearing n00b
Posts: 28
Joined: Sun Apr 27, 2003 8:14 pm
Location: Russia
Contact:

Quick research results

Post by TryKos »

To Red - You got me here 8)
*TryKos got critical hit in glasses and collapses in shame*

No, I dont compare them all, but I perfectly sure that car scripts are old (Im decompiled them and compared very throughly), and headers files (at least Define.H) dont include 4 new 'metarule3' commands, which used in 1.02 scripts.
----------------
Skipped half-hour
----------------
And now I'm done binary comparison (by FAR plugin) of editor binaries (10 minutes to compile all on Athlon 1700 8) ) and game 1.0 and patch 1.2 binaries.
You were right. Among 1448 game 1.0 scripts were 279 different from compiled editor scripts. But this also includes 250 Fallout 1 and debugging scripts (they not included in scripts.lst), so we have only 29 differing scripts, one of them (ZILCKDOR.int) are identical to patch 1.02 ZILCKDOR script (kinda little gift 8) ).
So, we have only 28 editor scripts that are sure differing from 1.0 and 1.02 scripts. List see below. (28 = about 2 percent of total 1246 editor scripts, so my prediction about 99% success rate wasnt all wrong 8) )

List of editor scripts, which DIFFERENT from game 1.0 and game patch 1.02 scripts:
------------------
AHELDER.int
AHHAKUN.int
COWBOMB.int
DCADDICT.int
DCBILLY.int
DCCUSTMR.int
DCFRED.int
DCORPHAN.int
DCREBECC.int
DCSLAVE.int
DCSLVRUN.int
DCSTORY1.int
DCSTORY2.int
DCVIC.int
DEPOLV1.int
DIBONES.int
DIDIARY.int
DIFLKBOX.int
DISLVCRT.int
DIVICTBL.int
GCLENNY.int
HCMARCUS.int
HSCELLDR.int
KCSULIK.int
NHMYRON.int
QCSECBOT.int
SHTANDI.int
ZCSLAVE.int
------------------------------
End list.

So to my warning in previous post you must add this: If script, which you want to modify, is NOT in patch000.dat and NOT listed above, then you can modify, compile and use it without fear of old glitches. Otherwice, you must extract it from patch000.dat (if it here) or master.dat (if not), decompile it and then modify as you like.
In this world there are two kinds of people, my friend...those with Power of Moon Prism, and those who dig. You dig.
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

Actually, it's more complicated then that since we don't even know the files given with the editor are EVEN 1.0...
...
User avatar
Stevie D
Wanderer
Wanderer
Posts: 427
Joined: Mon Aug 05, 2002 3:31 am
Location: Devon, UK
Contact:

Post by Stevie D »

TryKos, this script compiling tutorial looks great! Once you've thrashed out all the issues with Red in this thread, can you please post a finished version in the FAQ Contribution thread and, if you're happy with the idea, I'll bung it in the FAQ sticky.

Good stuff - this is the next stage I was looking to tackle...
User avatar
TryKos
Scarf-wearing n00b
Scarf-wearing n00b
Posts: 28
Joined: Sun Apr 27, 2003 8:14 pm
Location: Russia
Contact:

Post by TryKos »

Actually, it's more complicated then that since we don't even know the files given with the editor are EVEN 1.0...
Hmmm.... or my English bad, or my explanatory abilities dropped to zero...

I compiled ALL editor scripts and made BINARY comparison (i.e. byte by byte) with game scripts 1.0. And except aforementioned 29 scripts, other editor scripts binaries are IDENTICAL with game 1.0 scripts binaries. This fact dont convince you that editor scripts IS version 1.0? (except 29 of cource).

To Stevie D Glad to hear that my post has some sense. 8) Ill do so, once Red! confirm or deny my reasonings.
In this world there are two kinds of people, my friend...those with Power of Moon Prism, and those who dig. You dig.
Post Reply