First Person Shooter Game: Ournal OF Bject Echnology
First Person Shooter Game: Ournal OF Bject Echnology
First Person Shooter Game: Ournal OF Bject Echnology
Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2008
1 IMPORTING A MODEL
Importing a Model is easy and fun! Models can include your character, nonplayer characters, level objects, weapons, health supplies, etc. To make a
working entity in GameStudio, you must first import a 3D model and then
assign functions, or behaviors, to the model. These functions give models
unique properties. For example; if you import a model of an elf, you can
assign player functions to the model that will allow you to control the elf.
Likewise, if you import a health pack, the functions you assign to it will make
the model act like a health pack. Things can get really crazy if you assign
functions to models incorrectly! How funny would it be if you ran into the elf
and it healed you while you controlled the movement of a health pack!
Cite this article as follows: Rex Cason II, Erik Larson, Jonathan Robertson, Jonathan Frisch,
George Trice III, Dr. Lakshmi Prayaga: First Person Shooter Game Journal of Object
Technology,
vol.
7,
no.
1,
January-Februar
2008,
pp.
43
58
http://www.jot.fm/issues/issue_2008_01/column5
1. First open the WED (World Editor Program), and click Object Load
Entity
44
VOL. 7, NO. 1
3. From here, select your model and Click Open (open cbabe.mdl or
warlock.mdl)
VOL. 7, NO. 1
45
4. Notice that cbabe may be outside of your room. To get her within
the room, simply click the Move button (on the toolbar) and drag her
into the room. Be sure to examine all windows to make sure that shes
properly aligned
46
VOL. 7, NO. 1
5. Your model is now inserted into your level. Wow! That was easy! You
can now continue to move this model wherever you want it in your
level. You can resize and rotate it!
VOL. 7, NO. 1
47
2 ASSIGNING A FUNCTION/BEHAVIOR
Once you have the model in your level, you probably want it to do
something. In order for your model to have some sort of properties, you must
assign a function, or Behavior, to the model. To begin with, make sure that
you have assigned a script to the game that you are making. The script,
which is written in a programming language called C-Script, is what contains
all the variables, functions, and other bits of code that will add to making your
game awesome!
Code1.wdl
Open the SED (Script Editor) and copy & paste this code into it. Save the file
as "Code1.wdl" into the work folder (usually under "C:\Program
Files\GStuido6\work")
////////////////////////////////////////////////////////////
//
// Code1.wdl
////////////////////////////////////////////////////////////
//
path = "..\\template"; // path to wdl templates
subdirectory if you are in the Work folder
path = "..\\template_6"; // path to wdl templates_06
subdirectory if you are in the Work folder
////////////////////////////////////////////////////////////
//
include <movement.wdl>;
include <messages.wdl>;
include <doors.wdl>;
include <actors.wdl>;
include <menu.wdl>;
////////////////////////////////////////////////////////////
//
// The engine starts in the resolution given by the follwing
vars.
var video_mode = 8;
//1024x768;
var video_screen = 1;
////////////////////////////////////////////////////////////
//
// The MAIN function is called at game start
string mainLevel_wmb = <StudentGame.wmb>; // the main level
////////////////////////////////////////////////////////////
//
function main()
48
VOL. 7, NO. 1
{
start_game();
}
function start_game
{
render_inflate = 0.5;
anim_walk_dist = 2; // for the girl
anim_run_dist = 5;
walk_or_run = 10;
//// menubar_pan.visible = ON; // makes the menubar panel
invisible
// now load the level
load_level (mainLevel_wmb);
camera.ambient = 0;
camera_solidpass = 1;
through solids
TURB_SPEED = 0; //CG
}
function quit_game
{
exit;
}
ON_ESC quit_game;
////////////////////////////////////////////////////////////
//
// Desc: user controlled player
ACTION
my_player
{
my.fat = off;
my.narrow = on;
my.trigger_range = 24;
my._movemode = _mode_walking;
my._force = 0.75;
my._banking = -0.1;
my.__strafe = on;
my.__bob = on;
my.__trigger = on;
my.__fall = on;
my._health = 100;
ifdef std;
my.shadow = off;
drop_shadow();
ifelse;
// not std
ifdef extra;
my.shadow = off;
drop_shadow();
ifelse;
// not std, not extra
my.shadow = on; // shadow on comm or
above
endif;
VOL. 7, NO. 1
49
endif;
my.scale_x = 1.2;
my.scale_y = 1.2;
my.scale_z = 1.2;
player_walk();
}
50
VOL. 7, NO. 1
2. A pop-up menu entitled Map Properties will appear. As you can see in
the Script Box, no script has been defined. To do this, click the Folder
icon to the right of the Script Box
3. A pop-up menu will open that defaults to the Work Folder. From
here, select the script file (".wdl") that contains the code for your game.
We will use "Code1.wdl"
VOL. 7, NO. 1
51
4. Now you will return to the Map Properties dialog box. As you can see,
the script file is now inside the Script Box
5. Then close this menu out simply by clicking the close button. Clicking
the red X to the right of the Script Box will remove the script you just
added to your game
52
VOL. 7, NO. 1
6. Now select the model that you want to add a Behavior to. When
selected, your model will appear in a red wire frame
VOL. 7, NO. 1
53
8. A pop-up menu will appear. In this menu, you can select the Behavior
that you want your model to have. The Behaviors are described in your
script. For example, if you want your model to be the character that
you play as, choose my_player for a health pack, choose
health_pack, etc. You can customize any Behavior and even create
your own in the script. But for now, simply select my_player and press
OK
9. Your model now has the Behavior that you chose for it! See how easy
and fun that was? You now should have learned all the basic elements
of creating a game. If you want to Build and Run your game, you can
do so now!
54
VOL. 7, NO. 1
2. A pop-up menu will appear that lets you adjust what exactly you want
to compile or update. If youre just doing a quick test, make sure that
your Visibility Calculations and Light Calculations are set to Off and
Low Quality. This will dramatically reduce the time it takes to compile
your game. You shouldnt be able to see a difference between these
settings, and (for productivity purposes) you should wait to turn these
on until you have finished tweaking your game
VOL. 7, NO. 1
55
3. Make sure that the Build Level button is selected and click OK
vary
5. Click the Run button
56
VOL. 7, NO. 1
6. Click the Ok Button once more in the Run Level dialog box
7. Your game will now start! Now how have some fun!
Congratulations you now have all the basic skills to make your own game
using GameStudio! Now begin making your own fun games!
VOL. 7, NO. 1
57
58
VOL. 7, NO. 1