|
the
tutorial is all here but if you are interested in the example pack and full
POT pack visit FX Outpost. PLease destribute this tutorial and file. if you
got any quesions or comments send em in.
I'll try to explain how to implement the POT entity and how i
meant for it to work.
I modified these files:
g_local.h
g_cmd.c
g_save.c
g_spawn.c
Also there is a new file called g_pot.c, you should have this
file
if you want to implement the entity and the others if you want to look up
what i did. When you look at the .c files "//Demolisher" is where
i begin my modifications and "//End-Demolisher" is when they are
done.
There could be more than one set of these in a file.
First of all lets add all the needed field to the ent and
client strucs.
Add the folowing to g_local.h at about line 870:
(+ means lines added)
vec3_t damage_blend;
vec3_t v_angle; // aiming direction
+
+//Demolisher
+
+ vec3_t
poldo; //old player origin, used
for turning off when the player dies
+ vec3_t
toldview; // old player view
used in Turret_Cmd
+ int
tursnap; //snap
on/off
+ int
tstat; // on/off
POT flag used in POT switch
+ int turmovec; //POT fire on/off
+ int turaction; //used for chosing which way the POT moves
+ int oturaction; //old turaction, used for main POT cmd
+ int
mfire; //POT move
control flag used in move
+
+//End-Demolisher
+
float bobtime; // so off-ground doesn't change it
vec3_t oldviewangles;
These are the client fields i used to control a few proceses
like movement
and on/off status.
Now add the following to g_local.h at about line 962:
(+ means lines added)
char *classname;
int spawnflags;
+
+//Demolisher
+
+ int
fstat; //POT fire
stat
+ int
control; //POT
control, 1 = control
+ int
zoom; //zoom status
+ char
*findrange; //range find
point targetname
+ int
lstat; //laser
status, 1= on, 0 = off
+ int
ldmg; //laser
damage (cannot be zero)
+ char
*dlaser; //dummy laser
target
+ char
*laser; //laser
targetname
+ vec3_t
dangles; //default turret/player
angles to return to
+ int
cview; //custom
viewheight
+ int
fspeed; //custom
firing speed
+ int
fdamage; //custom
firing damage
+ int
fradius; //custom
firing damage radius
+ int
snapa; //snap axis
+ float
zoffset; // yaw offset for POT
+ float
yoffset; // pitch offset for
POT
+ float
xoffset; // bank offset for POT
+ int
mfire; //POT move
control flag used in move
+ int
range; //range
field used in POT control
+ vec3_t
tdpos1, tdpos2; //POT min/max
pos used in turret_move
+ int tdaxis; // POT door axis
+ int turtype; // POT type, 0=regular, 1= door,2 =snap
+ int tdmaxmove; //POT door max angle
+ int tdminmove; //POT door min angle
+ int maxtpitch; //max pitch angle
+ int maxtyaw; //max yaw angle
+ int maxtbank; //max bank angle
+ int mintpitch; //min pitch angle
+ int mintyaw; //min yaw angle
+ int mintbank; //min bank angle
+ int oaxis; //which axis should POT move on
+ float times; //delay
+ int
fire; //used to
chose what to fire
+
+//End- Demolisher
+
float timestamp;
These are the general field for the turret, i tried to comment
on most of
them.
Now that the .h file is done open up g_cmd.c and stick the
main command on the buttom.
Stick the following in g_cmd.c at about line 907(in the client command)
(+ means lines added)
Cmd_Wave_f (ent);
+//Demolisher
+
+ // check if turret switch is active
+ else if (Q_stricmp (cmd,
"turret") == 0)
+ Cmd_Turret_f (ent);
+
+//End-Demolisher
This will handle the on/off and zoom commands.
Now for the map fields, open up g_save.c and stick the
following
at about line 10:
(+ means lines added)
{"spawnflags", FOFS(spawnflags), F_INT},
+//Demolisher
+
+ {"control", FOFS(control), F_INT},
+ {"findrange", FOFS(findrange), F_LSTRING},
+ {"zoom", FOFS(zoom), F_INT},
+ {"laser", FOFS(laser), F_LSTRING},
+ {"dlaser", FOFS(dlaser), F_LSTRING},
+ {"ldmg", FOFS(ldmg), F_INT},
+ {"cview", FOFS(cview), F_INT},
+ {"fradius", FOFS(fradius), F_INT},
+ {"fdamage", FOFS(fdamage), F_INT},
+ {"fspeed", FOFS(fspeed), F_INT},
+ {"snapa", FOFS(snapa), F_INT},
+ {"zoffset", FOFS(zoffset), F_FLOAT},
+ {"yoffset", FOFS(yoffset), F_FLOAT},
+ {"xoffset", FOFS(xoffset), F_FLOAT},
+ {"range", FOFS(range), F_INT},
+ {"times", FOFS(times), F_FLOAT},
+ {"fire", FOFS(fire), F_INT},
+ {"tdaxis", FOFS(tdaxis), F_INT},
+ {"turtype", FOFS(turtype), F_INT},
+ {"tdmaxmove", FOFS(tdmaxmove), F_INT},
+ {"tdminmove", FOFS(tdminmove), F_INT},
+ {"oaxis", FOFS(oaxis), F_INT},
+ {"maxtyaw", FOFS(maxtyaw), F_INT},
+ {"maxtpitch", FOFS(maxtpitch), F_INT},
+ {"maxtbank", FOFS(maxtbank), F_INT},
+ {"mintyaw", FOFS(mintyaw), F_INT},
+ {"mintpitch", FOFS(mintpitch), F_INT},
+ {"mintbank", FOFS(mintbank), F_INT},
+
+//End-Demolisher
+
{"speed", FOFS(speed), F_FLOAT},
There's a lot of map fields because the entity is very
flexible, you could make a
sniper turret with a periscope that fires one bullet of 100 damage or a huge
BFG
hurler.
Now for the last part, the spawning of the entity and range
finder stuff.
Open up g_spawn.c and put the following few lines at about
line 131(by the spawns):
(+ means lines added)
spawn_t spawns[] = {
+//Demolisher
+
+ {"turret", SP_func_rotating},
+
+//End-Demolisher
{"item_health", SP_item_health},
As you can see the whole turret is just a func_rotating beign
manipulated through the main
pot file.
Now for the range finder code, add the following to the end of
both
the single statusbar(about line 683) and dm statusbar(about line 761):
(+ means lines added)
+//Demolisher
+
+// range finder for POT turrets by: demolisher and everyone who helped
+"if 16 "
+" xv 410 "
+" yb -25 "
+" num 4 16"
+" xv 434 "
+" yb -35 "
+" string RANGE "
+"endif "
+
+//End-Demolisher
Last but not least are the additions to p_client.c. These are
so
the turret funcion is run every frame.
Stick the following at about line 1465 near into the deadflag
stuff.
(+ means lines added)
if (ent->deadflag)
{
+//Demolisher
+ //Check if
POT is on
+ if
(ent->client->tstat==2)
+
ent->client->tstat=0;
+
+ //Shut of
POT and run Turret_Move
+
VectorCopy(ent->client->poldo, ent->s.origin); //copy old origin to
current so POT could be turned off
+
ent->client->turaction=10; //set to off
+
Turret_Move(ent);
+
ent->client->turaction=12; //set to snap angles to default
+
Turret_Move(ent);
+//End-Demolisher
client->ps.viewangles[ROLL] = 40;
Also add the following at about line 1488 near the last paste and right
befor the client gets linked(gi.linkentity).
(+ means lines added)
+
VectorCopy (pm.viewangles, client->ps.viewangles);
+ }
+//Demolisher
+
+ //If POT is on, run main cmd function
+ if (ent->client->tstat ==2)
+ Turret_Cmd(ent, ucmd);
+
+ VectorCopy(ent->s.origin, ent->client->poldo);
+
+//End-Demolisher
+
gi.linkentity (ent);
Anyway thats about it, if there are any bugs to report or
comments
send them to: demolisher@planetquake.com
Also, see the usage txt if you want to know how to map your
own turrets.
|