2007-09-04 22:00:00 +02:00
|
|
|
/*
|
|
|
|
+==================+
|
|
|
|
|FUNC_TRAIN.QC |
|
|
|
|
+==================+=====================================================================+
|
|
|
|
|Description;
|
|
|
|
|This file handles the func_train map entity;
|
|
|
|
+========================================================================================+
|
|
|
|
*/
|
|
|
|
|
|
|
|
//DEFINITIONS FOR FILE;
|
|
|
|
void() func_train_next; //[func_train.qc]
|
|
|
|
//END DEFS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNC_TRAIN_WAIT();
|
|
|
|
|
|
|
|
Desciption;
|
|
|
|
Called after the train has reached its target.
|
|
|
|
If the train has the 'wait' field set on its spawn it waits the alloted time then finds its next target.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void() func_train_wait =
|
|
|
|
{
|
2007-09-16 22:00:00 +02:00
|
|
|
if (pev->wait)
|
2007-09-04 22:00:00 +02:00
|
|
|
{
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->nextthink = time + pev->wait;
|
|
|
|
//sound (pev, CHAN_VOICE, pev->noise, 1, ATTN_NORM);
|
2007-09-04 22:00:00 +02:00
|
|
|
}
|
|
|
|
else
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->nextthink = time + 0.1;
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->think = func_train_next;
|
2007-09-04 22:00:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNC_TRAIN_NEXT();
|
|
|
|
|
|
|
|
Desciption;
|
|
|
|
Finds the trains next target;
|
|
|
|
Then sets it moving in its direction;
|
|
|
|
*/
|
|
|
|
|
|
|
|
void() func_train_next =
|
|
|
|
{
|
|
|
|
local entity targ;
|
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
targ = find (world, targetname, pev->target);
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->target = targ.target;
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
if (!pev->target)
|
2007-09-04 22:00:00 +02:00
|
|
|
objerror ("train_next: no next target");
|
|
|
|
|
|
|
|
if (targ.wait)
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->wait = targ.wait;
|
2007-09-04 22:00:00 +02:00
|
|
|
else
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->wait = 0;
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
//sound (pev, CHAN_VOICE, pev->noise1, 1, ATTN_NORM);
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
func_mover_move (targ.origin - pev->mins, pev->speed, func_train_wait);
|
2007-09-04 22:00:00 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNC_TRAIN_FIND();
|
|
|
|
|
|
|
|
Desciption;
|
|
|
|
Called on spawning, this function finds the trains first target and sets the trains origin and hence starting position to it. Then calls FUNC_TRAIN_NEXT();
|
|
|
|
*/
|
|
|
|
|
|
|
|
void() func_train_find =
|
|
|
|
{
|
|
|
|
local entity targ;
|
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
targ = find (world, targetname, pev->target);
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->target = targ.target;
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
setorigin (pev, targ.origin - pev->mins);
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
if (!pev->targetname) // not triggered, so start immediately
|
2007-09-04 22:00:00 +02:00
|
|
|
{
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->nextthink = time + 0.1;
|
|
|
|
pev->think = func_train_next;
|
2007-09-04 22:00:00 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNC_TRAIN_USE();
|
|
|
|
|
|
|
|
Desciption;
|
|
|
|
The use function for trains;
|
|
|
|
If targeted the train starts moving then cannot be used/targetted again;
|
|
|
|
*/
|
|
|
|
|
|
|
|
void() func_train_use =
|
|
|
|
{
|
2007-09-16 22:00:00 +02:00
|
|
|
if(pev->touched == FALSE)
|
2007-09-04 22:00:00 +02:00
|
|
|
{
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->touched = TRUE;
|
|
|
|
pev->nextthink = time + 0.1;
|
|
|
|
pev->think = func_train_next;
|
2007-09-04 22:00:00 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
FUNC_TRAIN();
|
|
|
|
|
|
|
|
Desciption;
|
|
|
|
The spawning function for the map entity func_train;
|
|
|
|
*/
|
|
|
|
|
|
|
|
void() func_train =
|
|
|
|
{
|
|
|
|
func_setup();
|
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
setsize (pev, pev->mins , pev->maxs);
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->classname = "train";
|
2007-09-04 22:00:00 +02:00
|
|
|
|
|
|
|
//func_train defaults;
|
2007-09-16 22:00:00 +02:00
|
|
|
if (!pev->speed)
|
|
|
|
pev->speed = 100;
|
|
|
|
if (!pev->target)
|
2007-09-04 22:00:00 +02:00
|
|
|
objerror ("func_train without a target");
|
2007-09-16 22:00:00 +02:00
|
|
|
if (!pev->dmg)
|
|
|
|
pev->dmg = 2;
|
2007-09-04 22:00:00 +02:00
|
|
|
|
2007-09-16 22:00:00 +02:00
|
|
|
pev->nextthink = time + 0.1;
|
|
|
|
pev->think = func_train_find;
|
2007-09-04 22:00:00 +02:00
|
|
|
};
|
|
|
|
|