Long overdue tenebrae2 progs update :)
This commit is contained in:
parent
e5a55b2f7e
commit
f295f7ec3a
7 changed files with 3690 additions and 3699 deletions
|
@ -943,10 +943,8 @@ void() PlayerPreThink =
|
|||
|
||||
if (!self.flashlight) {
|
||||
self.flashlight = spawn ();
|
||||
|
||||
setmodel(self.flashlight, "progs/w_light.spr");
|
||||
self.flashlight.velocity = '0 0 0';
|
||||
|
||||
setmodel(self.flashlight, "progs/flashlight.spr");
|
||||
self.flashlight.style = 0;
|
||||
self.flashlight.skin = 24;
|
||||
self.flashlight.color = '1 1 1';
|
||||
|
@ -957,6 +955,7 @@ void() PlayerPreThink =
|
|||
flatforward = normalize(v_forward);
|
||||
flatforward_z = 0;
|
||||
source = self.origin + flatforward * 20;
|
||||
source_z = source_z + 20;
|
||||
setorigin(self.flashlight, source);
|
||||
// traceline (source, source + v_forward*4096, FALSE, self);
|
||||
// setorigin(self.flashlight, trace_endpos - v_forward*100);
|
||||
|
|
486
statics.qc
486
statics.qc
|
@ -1,244 +1,244 @@
|
|||
void() next_frame =
|
||||
{
|
||||
if (self.frame < self.button1){
|
||||
self.frame = self.frame + 1;
|
||||
} else {
|
||||
self.frame = self.button0;
|
||||
}
|
||||
self.nextthink = time + 0.1;
|
||||
self.think = next_frame;
|
||||
};
|
||||
|
||||
/*
|
||||
Put any model in the map
|
||||
|
||||
model = filename of model to have
|
||||
|
||||
If button0 and 1 are set it loops the frames:
|
||||
button0 = startframe to play
|
||||
button1 = endframe to play
|
||||
|
||||
If target is set it follows the path defined by the target path_corner ents.
|
||||
noise and noise1 then define the noises to play during movement.
|
||||
button0 & 1 dont work when target is set.
|
||||
*/
|
||||
void() misc_model =
|
||||
{
|
||||
precache_model (self.model);
|
||||
setmodel (self, self.model);
|
||||
self.solid = SOLID_NOT;
|
||||
|
||||
if (self.target) {
|
||||
if (!self.speed)
|
||||
self.speed = 100;
|
||||
self.cnt = 1;
|
||||
self.solid = SOLID_NOT;
|
||||
self.movetype = MOVETYPE_FAKEPUSH;
|
||||
self.blocked = train_blocked;
|
||||
self.use = train_use;
|
||||
if (!self.noise) self.noise = "misc/null.wav";
|
||||
if (!self.noise1) self.noise1 = "misc/null.wav";
|
||||
precache_sound (self.noise);
|
||||
precache_sound (self.noise1);
|
||||
setsize (self, self.mins , self.maxs);
|
||||
setorigin (self, self.origin);
|
||||
|
||||
// start trains on the second frame, to make sure their targets have had
|
||||
// a chance to spawn
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
self.think = func_train_find;
|
||||
return;
|
||||
}
|
||||
|
||||
//if (!self.button0){
|
||||
// if (!self.noise4) {
|
||||
// makestatic(self);
|
||||
// }
|
||||
//} else {
|
||||
if (self.button0) {
|
||||
self.think = next_frame;
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
self.frame = self.button0;
|
||||
}
|
||||
//}
|
||||
self.solid = SOLID_NOT;
|
||||
if (self.target)
|
||||
self.movetype = MOVETYPE_FAKEPUSH;
|
||||
else
|
||||
self.movetype = MOVETYPE_NONE;
|
||||
};
|
||||
|
||||
void() static_brush =
|
||||
{
|
||||
//static_brush == compatibility with old tenebrae maps
|
||||
misc_model();
|
||||
};
|
||||
|
||||
void() rotateengine_use =
|
||||
{
|
||||
local entity targ;
|
||||
|
||||
|
||||
targ = find (world, noise4, self.target);
|
||||
if (targ)
|
||||
if (self.state == STATE_TOP) {
|
||||
targ.avelocity = '0 0 0';
|
||||
self.state = STATE_DOWN;
|
||||
} else {
|
||||
targ.avelocity = self.avelocity;
|
||||
self.state = STATE_TOP;
|
||||
}
|
||||
else objerror("No target found");
|
||||
|
||||
};
|
||||
|
||||
void() misc_rotateengine =
|
||||
{
|
||||
self.use = rotateengine_use;
|
||||
self.state = STATE_DOWN;
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is spinning out
|
||||
*/
|
||||
void () fan_turnoff = {
|
||||
|
||||
local float reached;
|
||||
|
||||
if (self.state == STATE_TOP) {
|
||||
reached = 1;
|
||||
if (self.avelocity_x > 0) {
|
||||
self.avelocity_x = self.avelocity_x - self.waitmin;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_y > 0) {
|
||||
self.avelocity_y = self.avelocity_y - self.waitmin;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_z > 0) {
|
||||
self.avelocity_z = self.avelocity_z - self.waitmin;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (reached == 0) {
|
||||
self.nextthink = time + 0.1;
|
||||
} else {
|
||||
self.state = STATE_DOWN;
|
||||
self.avelocity = '0 0 0';
|
||||
self.nextthink = time + 100000;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is starting up
|
||||
*/
|
||||
void () fan_turnon = {
|
||||
|
||||
local float reached;
|
||||
self.state = STATE_TOP;
|
||||
|
||||
reached = 1;
|
||||
if (self.avelocity_x < self.dest_x) {
|
||||
self.avelocity_x = self.avelocity_x + self.waitmax;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_y < self.dest_y) {
|
||||
self.avelocity_y = self.avelocity_y + self.waitmax;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_z < self.dest_z) {
|
||||
self.avelocity_z = self.avelocity_z + self.waitmax;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
//We are at the top speed stop thinking
|
||||
if (reached == 1) {
|
||||
self.nextthink = time + 100000;
|
||||
} else {
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is toggled
|
||||
*/
|
||||
void () fan_use =
|
||||
{
|
||||
//shootable and destroyed?
|
||||
if (self.max_health) {
|
||||
if (self.health <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (self.state == STATE_TOP) {
|
||||
self.think = fan_turnoff;
|
||||
self.nextthink = time + 0.1;
|
||||
} else {
|
||||
self.think = fan_turnon;
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is shot
|
||||
*/
|
||||
void () fan_die =
|
||||
{
|
||||
if (self.state == STATE_TOP) {
|
||||
self.think = fan_turnoff;
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Put a fan in the map. A is any model that spins, it spins slowly up until it reaches max speed.
|
||||
It can be turned on/ off by triggering. It can be shot out.
|
||||
model = name of the fan model
|
||||
avelocity = rotation speed around the 3 axis (0 90 0)
|
||||
health = how long it takes to destroy. (zero is indestuctible)
|
||||
waitmin = spin down speed (default 5)
|
||||
waitmax = spin up speed (default 5)
|
||||
if spawnlfags 1 is set it starts disabled
|
||||
*/
|
||||
void() misc_fan =
|
||||
{
|
||||
precache_model (self.model);
|
||||
setmodel (self, self.model);
|
||||
self.solid = SOLID_SLIDEBOX;
|
||||
|
||||
if (self.health)
|
||||
{
|
||||
self.max_health = self.health;
|
||||
self.th_die = fan_die;
|
||||
self.takedamage = DAMAGE_YES;
|
||||
} else {
|
||||
self.max_health = 0;
|
||||
}
|
||||
|
||||
self.dest = self.avelocity;
|
||||
self.think = fan_turnon;
|
||||
self.nextthink = time + 100000;
|
||||
self.use = fan_use;
|
||||
self.state = STATE_TOP;
|
||||
|
||||
//start off?
|
||||
if (self.spawnflags & 1) {
|
||||
self.avelocity = '0 0 0';
|
||||
}
|
||||
|
||||
if (!self.waitmin)
|
||||
self.waitmin = 5;
|
||||
|
||||
if (!self.waitmax)
|
||||
self.waitmax = 5;
|
||||
|
||||
setsize(self, self.mins, self.maxs);
|
||||
self.movetype = MOVETYPE_FAKEPUSH;
|
||||
void() next_frame =
|
||||
{
|
||||
if (self.frame < self.button1){
|
||||
self.frame = self.frame + 1;
|
||||
} else {
|
||||
self.frame = self.button0;
|
||||
}
|
||||
self.nextthink = time + 0.1;
|
||||
self.think = next_frame;
|
||||
};
|
||||
|
||||
/*
|
||||
Put any model in the map
|
||||
|
||||
model = filename of model to have
|
||||
|
||||
If button0 and 1 are set it loops the frames:
|
||||
button0 = startframe to play
|
||||
button1 = endframe to play
|
||||
|
||||
If target is set it follows the path defined by the target path_corner ents.
|
||||
noise and noise1 then define the noises to play during movement.
|
||||
button0 & 1 dont work when target is set.
|
||||
*/
|
||||
void() misc_model =
|
||||
{
|
||||
precache_model (self.model);
|
||||
setmodel (self, self.model);
|
||||
self.solid = SOLID_NOT;
|
||||
|
||||
if (self.target) {
|
||||
if (!self.speed)
|
||||
self.speed = 100;
|
||||
self.cnt = 1;
|
||||
self.solid = SOLID_NOT;
|
||||
self.movetype = MOVETYPE_FAKEPUSH;
|
||||
self.blocked = train_blocked;
|
||||
self.use = train_use;
|
||||
if (!self.noise) self.noise = "misc/null.wav";
|
||||
if (!self.noise1) self.noise1 = "misc/null.wav";
|
||||
precache_sound (self.noise);
|
||||
precache_sound (self.noise1);
|
||||
setsize (self, self.mins , self.maxs);
|
||||
setorigin (self, self.origin);
|
||||
|
||||
// start trains on the second frame, to make sure their targets have had
|
||||
// a chance to spawn
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
self.think = func_train_find;
|
||||
return;
|
||||
}
|
||||
|
||||
//if (!self.button0){
|
||||
// if (!self.noise4) {
|
||||
// makestatic(self);
|
||||
// }
|
||||
//} else {
|
||||
if (self.button1) {
|
||||
self.think = next_frame;
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
self.frame = self.button0;
|
||||
}
|
||||
//}
|
||||
self.solid = SOLID_NOT;
|
||||
if (self.target)
|
||||
self.movetype = MOVETYPE_FAKEPUSH;
|
||||
else
|
||||
self.movetype = MOVETYPE_NONE;
|
||||
};
|
||||
|
||||
void() static_brush =
|
||||
{
|
||||
//static_brush == compatibility with old tenebrae maps
|
||||
misc_model();
|
||||
};
|
||||
|
||||
void() rotateengine_use =
|
||||
{
|
||||
local entity targ;
|
||||
|
||||
|
||||
targ = find (world, noise4, self.target);
|
||||
if (targ)
|
||||
if (self.state == STATE_TOP) {
|
||||
targ.avelocity = '0 0 0';
|
||||
self.state = STATE_DOWN;
|
||||
} else {
|
||||
targ.avelocity = self.avelocity;
|
||||
self.state = STATE_TOP;
|
||||
}
|
||||
else objerror("No target found");
|
||||
|
||||
};
|
||||
|
||||
void() misc_rotateengine =
|
||||
{
|
||||
self.use = rotateengine_use;
|
||||
self.state = STATE_DOWN;
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is spinning out
|
||||
*/
|
||||
void () fan_turnoff = {
|
||||
|
||||
local float reached;
|
||||
|
||||
if (self.state == STATE_TOP) {
|
||||
reached = 1;
|
||||
if (self.avelocity_x > 0) {
|
||||
self.avelocity_x = self.avelocity_x - self.waitmin;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_y > 0) {
|
||||
self.avelocity_y = self.avelocity_y - self.waitmin;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_z > 0) {
|
||||
self.avelocity_z = self.avelocity_z - self.waitmin;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (reached == 0) {
|
||||
self.nextthink = time + 0.1;
|
||||
} else {
|
||||
self.state = STATE_DOWN;
|
||||
self.avelocity = '0 0 0';
|
||||
self.nextthink = time + 100000;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is starting up
|
||||
*/
|
||||
void () fan_turnon = {
|
||||
|
||||
local float reached;
|
||||
self.state = STATE_TOP;
|
||||
|
||||
reached = 1;
|
||||
if (self.avelocity_x < self.dest_x) {
|
||||
self.avelocity_x = self.avelocity_x + self.waitmax;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_y < self.dest_y) {
|
||||
self.avelocity_y = self.avelocity_y + self.waitmax;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
if (self.avelocity_z < self.dest_z) {
|
||||
self.avelocity_z = self.avelocity_z + self.waitmax;
|
||||
reached = 0;
|
||||
}
|
||||
|
||||
//We are at the top speed stop thinking
|
||||
if (reached == 1) {
|
||||
self.nextthink = time + 100000;
|
||||
} else {
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is toggled
|
||||
*/
|
||||
void () fan_use =
|
||||
{
|
||||
//shootable and destroyed?
|
||||
if (self.max_health) {
|
||||
if (self.health <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (self.state == STATE_TOP) {
|
||||
self.think = fan_turnoff;
|
||||
self.nextthink = time + 0.1;
|
||||
} else {
|
||||
self.think = fan_turnon;
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
The fan is shot
|
||||
*/
|
||||
void () fan_die =
|
||||
{
|
||||
if (self.state == STATE_TOP) {
|
||||
self.think = fan_turnoff;
|
||||
self.nextthink = time + 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Put a fan in the map. A is any model that spins, it spins slowly up until it reaches max speed.
|
||||
It can be turned on/ off by triggering. It can be shot out.
|
||||
model = name of the fan model
|
||||
avelocity = rotation speed around the 3 axis (0 90 0)
|
||||
health = how long it takes to destroy. (zero is indestuctible)
|
||||
waitmin = spin down speed (default 5)
|
||||
waitmax = spin up speed (default 5)
|
||||
if spawnlfags 1 is set it starts disabled
|
||||
*/
|
||||
void() misc_fan =
|
||||
{
|
||||
precache_model (self.model);
|
||||
setmodel (self, self.model);
|
||||
self.solid = SOLID_SLIDEBOX;
|
||||
|
||||
if (self.health)
|
||||
{
|
||||
self.max_health = self.health;
|
||||
self.th_die = fan_die;
|
||||
self.takedamage = DAMAGE_YES;
|
||||
} else {
|
||||
self.max_health = 0;
|
||||
}
|
||||
|
||||
self.dest = self.avelocity;
|
||||
self.think = fan_turnon;
|
||||
self.nextthink = time + 100000;
|
||||
self.use = fan_use;
|
||||
self.state = STATE_TOP;
|
||||
|
||||
//start off?
|
||||
if (self.spawnflags & 1) {
|
||||
self.avelocity = '0 0 0';
|
||||
}
|
||||
|
||||
if (!self.waitmin)
|
||||
self.waitmin = 5;
|
||||
|
||||
if (!self.waitmax)
|
||||
self.waitmax = 5;
|
||||
|
||||
setsize(self, self.mins, self.maxs);
|
||||
self.movetype = MOVETYPE_FAKEPUSH;
|
||||
};
|
669
subs.qc
669
subs.qc
|
@ -1,343 +1,328 @@
|
|||
|
||||
|
||||
void() SUB_Null = {};
|
||||
|
||||
void() SUB_Remove = {remove(self);};
|
||||
|
||||
|
||||
/*
|
||||
QuakeEd only writes a single float for angles (bad idea), so up and down are
|
||||
just constant angles.
|
||||
*/
|
||||
vector() SetMovedir =
|
||||
{
|
||||
if (self.angles == '0 -1 0')
|
||||
self.movedir = '0 0 1';
|
||||
else if (self.angles == '0 -2 0')
|
||||
self.movedir = '0 0 -1';
|
||||
else
|
||||
{
|
||||
makevectors (self.angles);
|
||||
self.movedir = v_forward;
|
||||
}
|
||||
|
||||
self.angles = '0 0 0';
|
||||
};
|
||||
|
||||
/*
|
||||
================
|
||||
InitTrigger
|
||||
================
|
||||
*/
|
||||
void() InitTrigger =
|
||||
{
|
||||
// trigger angles are used for one-way touches. An angle of 0 is assumed
|
||||
// to mean no restrictions, so use a yaw of 360 instead.
|
||||
if (self.angles != '0 0 0')
|
||||
SetMovedir ();
|
||||
self.solid = SOLID_TRIGGER;
|
||||
setmodel (self, self.model); // set size and link into world
|
||||
self.movetype = MOVETYPE_NONE;
|
||||
self.modelindex = 0;
|
||||
self.model = "";
|
||||
};
|
||||
|
||||
/*
|
||||
=============
|
||||
SUB_CalcMove
|
||||
|
||||
calculate self.velocity and self.nextthink to reach dest from
|
||||
self.origin traveling at speed
|
||||
===============
|
||||
*/
|
||||
void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt =
|
||||
{
|
||||
local entity stemp;
|
||||
stemp = self;
|
||||
self = ent;
|
||||
|
||||
SUB_CalcMove (tdest, tspeed, func);
|
||||
self = stemp;
|
||||
};
|
||||
|
||||
void(vector tdest, float tspeed, void() func) SUB_CalcMove =
|
||||
{
|
||||
local vector vdestdelta;
|
||||
local float len, traveltime;
|
||||
|
||||
if (!tspeed)
|
||||
objerror("No speed is defined!");
|
||||
|
||||
self.think1 = func;
|
||||
self.finaldest = tdest;
|
||||
self.think = SUB_CalcMoveDone;
|
||||
|
||||
if (tdest == self.origin)
|
||||
{
|
||||
self.velocity = '0 0 0';
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
return;
|
||||
}
|
||||
|
||||
// set destdelta to the vector needed to move
|
||||
vdestdelta = tdest - self.origin;
|
||||
|
||||
// calculate length of vector
|
||||
len = vlen (vdestdelta);
|
||||
|
||||
// divide by speed to get time to reach dest
|
||||
traveltime = len / tspeed;
|
||||
|
||||
if (traveltime < 0.1)
|
||||
{
|
||||
self.velocity = '0 0 0';
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
return;
|
||||
}
|
||||
|
||||
// set nextthink to trigger a think when dest is reached
|
||||
self.nextthink = self.ltime + traveltime;
|
||||
|
||||
// scale the destdelta vector by the time spent traveling to get velocity
|
||||
self.velocity = vdestdelta * (1/traveltime); // qcc won't take vec/float
|
||||
};
|
||||
|
||||
/*
|
||||
============
|
||||
After moving, set origin to exact final destination
|
||||
============
|
||||
*/
|
||||
void() SUB_CalcMoveDone =
|
||||
{
|
||||
setorigin(self, self.finaldest);
|
||||
self.velocity = '0 0 0';
|
||||
self.nextthink = -1;
|
||||
if (self.think1)
|
||||
self.think1();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
SUB_CalcAngleMove
|
||||
|
||||
calculate self.avelocity and self.nextthink to reach destangle from
|
||||
self.angles rotating
|
||||
|
||||
The calling function should make sure self.think is valid
|
||||
===============
|
||||
*/
|
||||
void(entity ent, vector destangle, float tspeed, void() func) SUB_CalcAngleMoveEnt =
|
||||
{
|
||||
local entity stemp;
|
||||
stemp = self;
|
||||
self = ent;
|
||||
SUB_CalcAngleMove (destangle, tspeed, func);
|
||||
self = stemp;
|
||||
};
|
||||
|
||||
void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove =
|
||||
{
|
||||
local vector destdelta;
|
||||
local float len, traveltime;
|
||||
|
||||
if (!tspeed)
|
||||
objerror("No speed is defined!");
|
||||
|
||||
// set destdelta to the vector needed to move
|
||||
destdelta = destangle - self.angles;
|
||||
|
||||
// calculate length of vector
|
||||
len = vlen (destdelta);
|
||||
|
||||
// divide by speed to get time to reach dest
|
||||
traveltime = len / tspeed;
|
||||
|
||||
// set nextthink to trigger a think when dest is reached
|
||||
self.nextthink = self.ltime + traveltime;
|
||||
|
||||
// scale the destdelta vector by the time spent traveling to get velocity
|
||||
self.avelocity = destdelta * (1 / traveltime);
|
||||
|
||||
self.think1 = func;
|
||||
self.finalangle = destangle;
|
||||
self.think = SUB_CalcAngleMoveDone;
|
||||
};
|
||||
|
||||
/*
|
||||
============
|
||||
After rotating, set angle to exact final angle
|
||||
============
|
||||
*/
|
||||
void() SUB_CalcAngleMoveDone =
|
||||
{
|
||||
self.angles = self.finalangle;
|
||||
self.avelocity = '0 0 0';
|
||||
self.nextthink = -1;
|
||||
if (self.think1)
|
||||
self.think1();
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void() DelayThink =
|
||||
{
|
||||
activator = self.enemy;
|
||||
SUB_UseTargets ();
|
||||
remove(self);
|
||||
};
|
||||
|
||||
/*
|
||||
==============================
|
||||
SUB_UseTargets
|
||||
|
||||
the global "activator" should be set to the entity that initiated the firing.
|
||||
|
||||
If self.delay is set, a DelayedUse entity will be created that will actually
|
||||
do the SUB_UseTargets after that many seconds have passed.
|
||||
|
||||
Centerprints any self.message to the activator.
|
||||
|
||||
Removes all entities with a targetname that match self.killtarget,
|
||||
and removes them, so some events can remove other triggers.
|
||||
|
||||
Search for (string)targetname in all entities that
|
||||
match (string)self.target and call their .use function
|
||||
|
||||
==============================
|
||||
*/
|
||||
void() SUB_UseTargets =
|
||||
{
|
||||
local entity t, stemp, otemp, act;
|
||||
|
||||
//
|
||||
// check for a delay
|
||||
//
|
||||
if (self.delay)
|
||||
{
|
||||
// create a temp object to fire at a later time
|
||||
t = spawn();
|
||||
t.classname = "DelayedUse";
|
||||
t.nextthink = time + self.delay;
|
||||
t.think = DelayThink;
|
||||
t.enemy = activator;
|
||||
t.message = self.message;
|
||||
t.killtarget = self.killtarget;
|
||||
t.target = self.target;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// print the message
|
||||
//
|
||||
if (activator.classname == "player" && self.message != "")
|
||||
{
|
||||
centerprint (activator, self.message);
|
||||
if (!self.noise)
|
||||
sound (activator, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM);
|
||||
}
|
||||
|
||||
//
|
||||
// kill the killtagets
|
||||
//
|
||||
if (self.killtarget)
|
||||
{
|
||||
t = world;
|
||||
do
|
||||
{
|
||||
t = find (t, targetname, self.killtarget);
|
||||
if (!t)
|
||||
return;
|
||||
remove (t);
|
||||
} while ( 1 );
|
||||
}
|
||||
|
||||
//
|
||||
// fire targets
|
||||
//
|
||||
if (self.target)
|
||||
{
|
||||
act = activator;
|
||||
t = world;
|
||||
do
|
||||
{
|
||||
t = find (t, targetname, self.target);
|
||||
if (!t)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stemp = self;
|
||||
otemp = other;
|
||||
self = t;
|
||||
other = stemp;
|
||||
if (self.use != SUB_Null)
|
||||
{
|
||||
if (self.use)
|
||||
self.use ();
|
||||
}
|
||||
self = stemp;
|
||||
other = otemp;
|
||||
activator = act;
|
||||
} while ( 1 );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
in nightmare mode, all attack_finished times become 0
|
||||
some monsters refire twice automatically
|
||||
|
||||
*/
|
||||
|
||||
void(float normal) SUB_AttackFinished =
|
||||
{
|
||||
self.cnt = 0; // refire count for nightmare
|
||||
if (skill != 3)
|
||||
self.attack_finished = time + normal;
|
||||
};
|
||||
|
||||
float (entity targ) visible;
|
||||
|
||||
void (void() thinkst) SUB_CheckRefire =
|
||||
{
|
||||
if (skill != 3)
|
||||
return;
|
||||
if (self.cnt == 1)
|
||||
return;
|
||||
if (!visible (self.enemy))
|
||||
return;
|
||||
self.cnt = 1;
|
||||
self.think = thinkst;
|
||||
};
|
||||
|
||||
//PENTA: new particle support
|
||||
void (entity ent, float pcount, string effectname) SUB_BasicEmitter =
|
||||
{
|
||||
WriteByte (MSG_BROADCAST, SVC_BASICEMITTER);
|
||||
WriteCoord (MSG_BROADCAST, ent.origin_x);
|
||||
WriteCoord (MSG_BROADCAST, ent.origin_y);
|
||||
WriteCoord (MSG_BROADCAST, ent.origin_z);
|
||||
WriteByte (MSG_BROADCAST, pcount);
|
||||
WriteString(MSG_BROADCAST, effectname);
|
||||
};
|
||||
|
||||
//PENTA: new particle support
|
||||
void (entity ent, float pcount, float tick, float life, string effectname) SUB_ExtendedEmitter =
|
||||
{
|
||||
WriteByte (MSG_BROADCAST, SVC_EXTENDEDEMITTER);
|
||||
WriteCoord (MSG_BROADCAST, ent.origin_x);
|
||||
WriteCoord (MSG_BROADCAST, ent.origin_y);
|
||||
WriteCoord (MSG_BROADCAST, ent.origin_z);
|
||||
WriteCoord (MSG_BROADCAST, ent.velocity_x);
|
||||
WriteCoord (MSG_BROADCAST, ent.velocity_y);
|
||||
WriteCoord (MSG_BROADCAST, ent.velocity_z);
|
||||
WriteByte (MSG_BROADCAST, pcount);
|
||||
WriteLong (MSG_BROADCAST, life*100);
|
||||
WriteLong (MSG_BROADCAST, tick*100);
|
||||
WriteString(MSG_BROADCAST, effectname);
|
||||
|
||||
|
||||
void() SUB_Null = {};
|
||||
|
||||
void() SUB_Remove = {remove(self);};
|
||||
|
||||
|
||||
/*
|
||||
QuakeEd only writes a single float for angles (bad idea), so up and down are
|
||||
just constant angles.
|
||||
*/
|
||||
vector() SetMovedir =
|
||||
{
|
||||
if (self.angles == '0 -1 0')
|
||||
self.movedir = '0 0 1';
|
||||
else if (self.angles == '0 -2 0')
|
||||
self.movedir = '0 0 -1';
|
||||
else
|
||||
{
|
||||
makevectors (self.angles);
|
||||
self.movedir = v_forward;
|
||||
}
|
||||
|
||||
self.angles = '0 0 0';
|
||||
};
|
||||
|
||||
/*
|
||||
================
|
||||
InitTrigger
|
||||
================
|
||||
*/
|
||||
void() InitTrigger =
|
||||
{
|
||||
// trigger angles are used for one-way touches. An angle of 0 is assumed
|
||||
// to mean no restrictions, so use a yaw of 360 instead.
|
||||
if (self.angles != '0 0 0')
|
||||
SetMovedir ();
|
||||
self.solid = SOLID_TRIGGER;
|
||||
setmodel (self, self.model); // set size and link into world
|
||||
self.movetype = MOVETYPE_NONE;
|
||||
self.modelindex = 0;
|
||||
self.model = "";
|
||||
};
|
||||
|
||||
/*
|
||||
=============
|
||||
SUB_CalcMove
|
||||
|
||||
calculate self.velocity and self.nextthink to reach dest from
|
||||
self.origin traveling at speed
|
||||
===============
|
||||
*/
|
||||
void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt =
|
||||
{
|
||||
local entity stemp;
|
||||
stemp = self;
|
||||
self = ent;
|
||||
|
||||
SUB_CalcMove (tdest, tspeed, func);
|
||||
self = stemp;
|
||||
};
|
||||
|
||||
void(vector tdest, float tspeed, void() func) SUB_CalcMove =
|
||||
{
|
||||
local vector vdestdelta;
|
||||
local float len, traveltime;
|
||||
|
||||
if (!tspeed)
|
||||
objerror("No speed is defined!");
|
||||
|
||||
self.think1 = func;
|
||||
self.finaldest = tdest;
|
||||
self.think = SUB_CalcMoveDone;
|
||||
|
||||
if (tdest == self.origin)
|
||||
{
|
||||
self.velocity = '0 0 0';
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
return;
|
||||
}
|
||||
|
||||
// set destdelta to the vector needed to move
|
||||
vdestdelta = tdest - self.origin;
|
||||
|
||||
// calculate length of vector
|
||||
len = vlen (vdestdelta);
|
||||
|
||||
// divide by speed to get time to reach dest
|
||||
traveltime = len / tspeed;
|
||||
|
||||
if (traveltime < 0.1)
|
||||
{
|
||||
self.velocity = '0 0 0';
|
||||
self.nextthink = self.ltime + 0.1;
|
||||
return;
|
||||
}
|
||||
|
||||
// set nextthink to trigger a think when dest is reached
|
||||
self.nextthink = self.ltime + traveltime;
|
||||
|
||||
// scale the destdelta vector by the time spent traveling to get velocity
|
||||
self.velocity = vdestdelta * (1/traveltime); // qcc won't take vec/float
|
||||
};
|
||||
|
||||
/*
|
||||
============
|
||||
After moving, set origin to exact final destination
|
||||
============
|
||||
*/
|
||||
void() SUB_CalcMoveDone =
|
||||
{
|
||||
setorigin(self, self.finaldest);
|
||||
self.velocity = '0 0 0';
|
||||
self.nextthink = -1;
|
||||
if (self.think1)
|
||||
self.think1();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
SUB_CalcAngleMove
|
||||
|
||||
calculate self.avelocity and self.nextthink to reach destangle from
|
||||
self.angles rotating
|
||||
|
||||
The calling function should make sure self.think is valid
|
||||
===============
|
||||
*/
|
||||
void(entity ent, vector destangle, float tspeed, void() func) SUB_CalcAngleMoveEnt =
|
||||
{
|
||||
local entity stemp;
|
||||
stemp = self;
|
||||
self = ent;
|
||||
SUB_CalcAngleMove (destangle, tspeed, func);
|
||||
self = stemp;
|
||||
};
|
||||
|
||||
void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove =
|
||||
{
|
||||
local vector destdelta;
|
||||
local float len, traveltime;
|
||||
|
||||
if (!tspeed)
|
||||
objerror("No speed is defined!");
|
||||
|
||||
// set destdelta to the vector needed to move
|
||||
destdelta = destangle - self.angles;
|
||||
|
||||
// calculate length of vector
|
||||
len = vlen (destdelta);
|
||||
|
||||
// divide by speed to get time to reach dest
|
||||
traveltime = len / tspeed;
|
||||
|
||||
// set nextthink to trigger a think when dest is reached
|
||||
self.nextthink = self.ltime + traveltime;
|
||||
|
||||
// scale the destdelta vector by the time spent traveling to get velocity
|
||||
self.avelocity = destdelta * (1 / traveltime);
|
||||
|
||||
self.think1 = func;
|
||||
self.finalangle = destangle;
|
||||
self.think = SUB_CalcAngleMoveDone;
|
||||
};
|
||||
|
||||
/*
|
||||
============
|
||||
After rotating, set angle to exact final angle
|
||||
============
|
||||
*/
|
||||
void() SUB_CalcAngleMoveDone =
|
||||
{
|
||||
self.angles = self.finalangle;
|
||||
self.avelocity = '0 0 0';
|
||||
self.nextthink = -1;
|
||||
if (self.think1)
|
||||
self.think1();
|
||||
};
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void() DelayThink =
|
||||
{
|
||||
activator = self.enemy;
|
||||
SUB_UseTargets ();
|
||||
remove(self);
|
||||
};
|
||||
|
||||
/*
|
||||
==============================
|
||||
SUB_UseTargets
|
||||
|
||||
the global "activator" should be set to the entity that initiated the firing.
|
||||
|
||||
If self.delay is set, a DelayedUse entity will be created that will actually
|
||||
do the SUB_UseTargets after that many seconds have passed.
|
||||
|
||||
Centerprints any self.message to the activator.
|
||||
|
||||
Removes all entities with a targetname that match self.killtarget,
|
||||
and removes them, so some events can remove other triggers.
|
||||
|
||||
Search for (string)targetname in all entities that
|
||||
match (string)self.target and call their .use function
|
||||
|
||||
==============================
|
||||
*/
|
||||
void() SUB_UseTargets =
|
||||
{
|
||||
local entity t, stemp, otemp, act;
|
||||
|
||||
//
|
||||
// check for a delay
|
||||
//
|
||||
if (self.delay)
|
||||
{
|
||||
// create a temp object to fire at a later time
|
||||
t = spawn();
|
||||
t.classname = "DelayedUse";
|
||||
t.nextthink = time + self.delay;
|
||||
t.think = DelayThink;
|
||||
t.enemy = activator;
|
||||
t.message = self.message;
|
||||
t.killtarget = self.killtarget;
|
||||
t.target = self.target;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// print the message
|
||||
//
|
||||
if (activator.classname == "player" && self.message != "")
|
||||
{
|
||||
centerprint (activator, self.message);
|
||||
if (!self.noise)
|
||||
sound (activator, CHAN_VOICE, "misc/talk.wav", 1, ATTN_NORM);
|
||||
}
|
||||
|
||||
//
|
||||
// kill the killtagets
|
||||
//
|
||||
if (self.killtarget)
|
||||
{
|
||||
t = world;
|
||||
do
|
||||
{
|
||||
t = find (t, targetname, self.killtarget);
|
||||
if (!t)
|
||||
return;
|
||||
remove (t);
|
||||
} while ( 1 );
|
||||
}
|
||||
|
||||
//
|
||||
// fire targets
|
||||
//
|
||||
if (self.target)
|
||||
{
|
||||
act = activator;
|
||||
t = world;
|
||||
do
|
||||
{
|
||||
t = find (t, targetname, self.target);
|
||||
if (!t)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stemp = self;
|
||||
otemp = other;
|
||||
self = t;
|
||||
other = stemp;
|
||||
if (self.use != SUB_Null)
|
||||
{
|
||||
if (self.use)
|
||||
self.use ();
|
||||
}
|
||||
self = stemp;
|
||||
other = otemp;
|
||||
activator = act;
|
||||
} while ( 1 );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
in nightmare mode, all attack_finished times become 0
|
||||
some monsters refire twice automatically
|
||||
|
||||
*/
|
||||
|
||||
void(float normal) SUB_AttackFinished =
|
||||
{
|
||||
self.cnt = 0; // refire count for nightmare
|
||||
if (skill != 3)
|
||||
self.attack_finished = time + normal;
|
||||
};
|
||||
|
||||
float (entity targ) visible;
|
||||
|
||||
void (void() thinkst) SUB_CheckRefire =
|
||||
{
|
||||
if (skill != 3)
|
||||
return;
|
||||
if (self.cnt == 1)
|
||||
return;
|
||||
if (!visible (self.enemy))
|
||||
return;
|
||||
self.cnt = 1;
|
||||
self.think = thinkst;
|
||||
};
|
||||
|
||||
//PENTA: new particle support, Fix don't overflow network packets when user spawns to much particles
|
||||
void (entity ent, float pcount, string effectname) SUB_BasicEmitter =
|
||||
{
|
||||
BasicEmitter(ent.origin, pcount, effectname);
|
||||
};
|
||||
|
||||
//PENTA: new particle support
|
||||
void (entity ent, float pcount, float tick, float life, string effectname) SUB_ExtendedEmitter =
|
||||
{
|
||||
ExtendedEmitter(ent.origin, ent.velocity, pcount, tick, life, effectname);
|
||||
};
|
2845
weapons.qc
2845
weapons.qc
File diff suppressed because it is too large
Load diff
2
world.qc
2
world.qc
|
@ -287,7 +287,7 @@ void() worldspawn =
|
|||
precache_model ("progs/zom_gib.mdl");
|
||||
|
||||
precache_model ("progs/v_light.mdl");
|
||||
|
||||
precache_model ("progs/flashlight.spr");
|
||||
|
||||
//
|
||||
// Setup light animation tables. 'a' is total darkness, 'z' is maxbright.
|
||||
|
|
Loading…
Reference in a new issue