FAKK2 Editing
/ home / game - view / fakked.ritual.com / tutorial01

NOTE: If you are familiar to SiNScript this tutorial might be a small waste of your time. If unsure, download the tutorial01.zip file and take a look at the script file. If anything baffles you, come back here and read the full tutorial to learn more about FAKK2 scripting.

Before we begin, those of you who wish to modify FAKK2 should extract the contents of the .pk3 files into their respective directories. If you have software that can "upzip" .zip files (WinZip is recommended) rename your *.pk3 files to Zip files. You can find the .pk3 files in your /fakk directory. After unzipping everything, rename the pak*Zip files to pak*.pk3 so it's back to the way you found it. Remember kiddies, return things to the way they were when you found them!

  • Warning: This will make FAKK2 take up over 1gig of harddrive space. Trust me, it'll be worth it. :)

Finally, the first tutorial for FAKK2. Download the tutorial01.zip file I have provided that will be discussed as I go through this tutorial. Once that is downloaded, upzip all the three files into your /fakk/maps directory. You should have:

tutorial01.bsp - the .bsp file that contains the geometry and entities
tutorial01.map -
the source file
tutorial01.scr
- the script file

Once you have the files unzipped, run FAKK2 and at the main menu hit the tilda key or which ever you have bound to that gives you access to the console. At the console type in "devmap tutorial01". Devmap is always good for level designers because it allows you to use quite useful commands such as "r_speeds 1".

That map will load it will begin to execute the script. After the level designer tool box at the bottom of the screen appears, bring up the console and type in, "editscript". This will bring up a notepad like utility within FAKK2 that is very handy when writing scripts. You can check out the comments I have made which explain what each part of the script is doing, however in not as much detail as I plan to go through here. So lets get to it, I'll post the script contents below minus all the comments.

start:
setcvar g_playermodel julie
$player model julie.tik
waitForPlayer

thread Main_StartUp_Thread

Main_Startup_Thread:

fadein 2 0 0 0 20
wait 2
fadeout 4 0 0 0 1
wait 4
fadein 4 0 0 0 1
wait 4
goto Print_Information_Thread01
end

Print_Information_Thread01:

//about center
locprint 230 240 "Welcome to my... box,\nmortal Human.\n -BrushBoy"
wait 4
goto Print_Information_Thread02
end

Print_Information_Thread02:

//lower left
locprint 0 0 "0 0"
wait 4
goto Print_Information_Thread03
end

Print_Information_Thread03:

//upper right
locprint 570 360 "570 360"
wait 4
goto Print_Information_Thread04
end

Print_Information_Thread04:

//lower right
locprint 580 0 "580 0"
wait 4
goto Print_Information_Thread05
end

Print_Information_Thread05:

//upper left
locprint 32 360 "32 360"
wait 4
goto Do_Odd_Things
end

Do_Odd_Things:

stuffcmd "pushmenu leveldesign"
end

Lets look at the general setup section first -

start:
setcvar g_playermodel Julie
$player model julie.tik
waitForPlayer

thread Main_Startup_Thread

All scripts need to start with the "start" word followed by the colon. This lets the game know where to start reading and executing the contents of the script file.

On the next line we are setting the player model to "Julie" which is the default, so I assume that if you don't specify this, it will be selected anyway instead of crashing the game. I might as well try that out now. Yeah, you can completely omit the "setcvar g_playermodel Julie" and "$player model julie.tik" lines and still have the game work. However, if you want to change the player model that you play as, you need to specify it within the script. I'm gonna try and play as a Creeper now. Or maybe an Eden Cow. NOPE, FAKK2 shutdown it's internal server complaining of a Event Overflow. It suggested I turn on g_showevents. I guess this would give me messages saying which events were being executed throughout playing the game but nothing showed up. That would be really useful if we can figure out how to make it work. Back to the tutorial. During the game of FAKK2 we were blessed with seeing Julie change into four different outfits through out the game.

The different models you can specify for Julie:

  • setcvar g_playermodel Julie
    $player model julie.tik

  • setcvar g_playermodel Julie_torn
    $player model Julie_torn.tik

  • setcvar g_playermodel Julie_swamp
    $player model Julie_swamp.tik

  • setcvar g_playermodel Julie_leather
    $player model Julie_leather.tik

Continuing with the script (I need sleep pronto). The waitForPlayer is essential, without it, the game can't execute any in game events that deal with moving geometry, triggering entities, and whatever else is essential to game play.

"thread Main_Startup_Thread" declares that I have a thread by the name of "Main_Startup_Thread". To use this thread I need to type it else where in my script and append a colon to the end. Once the code processes the above line it will scan the script file for "Main_Startup_Thread:" and then begin to process it's block of code WHILE still executing the rest of the code up top just after the line "thread Main_Startup_Thread". This is essential to understand because with the threads, you can have the game executing many blocks of code simultaneously. An example would be, one thread that plays random sounds the entire time you play the level. Another thread will make characters move from waypoint to waypoint randomly. Each of these situations are happening in real time at the same time because multiple threads are being processed simultaneously. Awesome eh?

Kick a$$, onto the next section of code -

Main_Startup_Thread:

fadein 2 0 0 0 20
wait 2
fadeout 4 0 0 0 1
wait 4
fadein 4 0 0 0 1
wait 4
goto Print_Information_Thread01
end

The first line, "Main_Startup_Thread:" is the header indicating that below it, is the code that belongs to the "Main_Startup_Thread" that was called in the section before.

fadein and fadeout <time> <red> <green> <blue> <alpha mode>. Fadein will start from black and reveal the game screen, while fadeout will start from the game screen and fade gradually to black.

wait <wait time in seconds> will halt execution of that one thread for the specified period of time. You can use floating or integer values such as 0.5 or 10

goto <threadname> will I _believe_ start a completely new thread, begin executing it while continuing with it's own code in parallel. Do correct me if I'm wrong all you expert "SiN-ful Scripters".

end Simply stops execution of the script. The Node rocks. I just read that the end command is purty darn important so don't forget to add this to each and every thread, or else it won't work at all. There may be times when the script is looping endlessly and therefore never reaches the last command "end", so you may think that it's not needed, but it is. When in doubt, add "end" to the last line of your thread.

Next thread to examine -

Print_Information_Thread01:

//about center
locprint 230 240 "Welcome to my... box,\nmortal Human.\n -BrushBoy"
wait 4
goto Print_Information_Thread02
end

locprint <xoffset> <yoffset> <stuffToPrint> This relates to location based printing of text. Might be cool for a comic book style cinematic.

Also, the "\n" means a new line of text to appear. Just don't get carried away and start printing paragraphs from your favorite childrens fairy tail.

The rest has been covered in this and the remaining threads so I will jump to the last one -

Do_Odd_Things:

stuffcmd "pushmenu leveldesign"
end

stuffcmd <arg1> [arg2] [arg3] [arg4] [arg5] [arg6] This had me jumping for joy. "stuffcmd" allows you to execute server side commands through the script. I have forced the "leveldesign" menu to appear on the screen using this command. The leveldesign menu is an excellent tool to use while playtesting your maps. I will probably go over it's functions in a later tutorial.

One last thing to mention is how to write comments in your script file. Like most languages, the use of two // will indicate the text following it to be ignored by the script, thus allowing you to type in notes or threatening messages for those to try to steal blocks of code while looking through your script file. It's very useful and if you plan on working with a team you should comment each and every line of your script so that someone can easily figure out what it is you are trying to accomplish. Another use for the double slashes (or is it backslashes?) is to easily identify and label the sections of code within in a script. There is no correct format of using the double slashes, just find something that works for you. You can do something like;

//--------------------
//-----------------
//-------------[
//---------[[[[
My_Main_Startup_Thread
//---------[[[[
//-------------[
//-----------------
//---------------------

which is pretty darn lame in my opinion, but ya know, whatever floats your boat.

Ok, I hope this rocked your world world or something. Feel free to edit the script file and play around with the commands. Tomorrow I hope to post a tutorial on how to add the wonderfully orgasm causing sky backdrops that one often encounters while playing FAKK2.

-BrushBaron