summaryrefslogtreecommitdiff
path: root/src/baseq2/g_func.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/baseq2/g_func.c')
-rw-r--r--src/baseq2/g_func.c1007
1 files changed, 447 insertions, 560 deletions
diff --git a/src/baseq2/g_func.c b/src/baseq2/g_func.c
index d49a477..06c8671 100644
--- a/src/baseq2/g_func.c
+++ b/src/baseq2/g_func.c
@@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
@@ -73,65 +73,57 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// Support routines for movement (changes in origin using velocity)
//
-void Move_Done (edict_t *ent)
+void Move_Done(edict_t *ent)
{
- VectorClear (ent->velocity);
- ent->moveinfo.endfunc (ent);
+ VectorClear(ent->velocity);
+ ent->moveinfo.endfunc(ent);
}
-void Move_Final (edict_t *ent)
+void Move_Final(edict_t *ent)
{
- if (ent->moveinfo.remaining_distance == 0)
- {
- Move_Done (ent);
+ if (ent->moveinfo.remaining_distance == 0) {
+ Move_Done(ent);
return;
}
- VectorScale (ent->moveinfo.dir, ent->moveinfo.remaining_distance / FRAMETIME, ent->velocity);
+ VectorScale(ent->moveinfo.dir, ent->moveinfo.remaining_distance / FRAMETIME, ent->velocity);
ent->think = Move_Done;
ent->nextthink = level.time + FRAMETIME;
}
-void Move_Begin (edict_t *ent)
+void Move_Begin(edict_t *ent)
{
float frames;
- if ((ent->moveinfo.speed * FRAMETIME) >= ent->moveinfo.remaining_distance)
- {
- Move_Final (ent);
+ if ((ent->moveinfo.speed * FRAMETIME) >= ent->moveinfo.remaining_distance) {
+ Move_Final(ent);
return;
}
- VectorScale (ent->moveinfo.dir, ent->moveinfo.speed, ent->velocity);
+ VectorScale(ent->moveinfo.dir, ent->moveinfo.speed, ent->velocity);
frames = floor((ent->moveinfo.remaining_distance / ent->moveinfo.speed) / FRAMETIME);
ent->moveinfo.remaining_distance -= frames * ent->moveinfo.speed * FRAMETIME;
ent->nextthink = level.time + (frames * FRAMETIME);
ent->think = Move_Final;
}
-void Think_AccelMove (edict_t *ent);
+void Think_AccelMove(edict_t *ent);
-void Move_Calc (edict_t *ent, vec3_t dest, void(*func)(edict_t*))
+void Move_Calc(edict_t *ent, vec3_t dest, void(*func)(edict_t*))
{
- VectorClear (ent->velocity);
- VectorSubtract (dest, ent->s.origin, ent->moveinfo.dir);
- ent->moveinfo.remaining_distance = VectorNormalize (ent->moveinfo.dir);
+ VectorClear(ent->velocity);
+ VectorSubtract(dest, ent->s.origin, ent->moveinfo.dir);
+ ent->moveinfo.remaining_distance = VectorNormalize(ent->moveinfo.dir);
ent->moveinfo.endfunc = func;
- if (ent->moveinfo.speed == ent->moveinfo.accel && ent->moveinfo.speed == ent->moveinfo.decel)
- {
- if (level.current_entity == ((ent->flags & FL_TEAMSLAVE) ? ent->teammaster : ent))
- {
- Move_Begin (ent);
- }
- else
- {
+ if (ent->moveinfo.speed == ent->moveinfo.accel && ent->moveinfo.speed == ent->moveinfo.decel) {
+ if (level.current_entity == ((ent->flags & FL_TEAMSLAVE) ? ent->teammaster : ent)) {
+ Move_Begin(ent);
+ } else {
ent->nextthink = level.time + FRAMETIME;
ent->think = Move_Begin;
}
- }
- else
- {
+ } else {
// accelerative
ent->moveinfo.current_speed = 0;
ent->think = Think_AccelMove;
@@ -144,34 +136,33 @@ void Move_Calc (edict_t *ent, vec3_t dest, void(*func)(edict_t*))
// Support routines for angular movement (changes in angle using avelocity)
//
-void AngleMove_Done (edict_t *ent)
+void AngleMove_Done(edict_t *ent)
{
- VectorClear (ent->avelocity);
- ent->moveinfo.endfunc (ent);
+ VectorClear(ent->avelocity);
+ ent->moveinfo.endfunc(ent);
}
-void AngleMove_Final (edict_t *ent)
+void AngleMove_Final(edict_t *ent)
{
vec3_t move;
if (ent->moveinfo.state == STATE_UP)
- VectorSubtract (ent->moveinfo.end_angles, ent->s.angles, move);
+ VectorSubtract(ent->moveinfo.end_angles, ent->s.angles, move);
else
- VectorSubtract (ent->moveinfo.start_angles, ent->s.angles, move);
+ VectorSubtract(ent->moveinfo.start_angles, ent->s.angles, move);
- if (VectorCompare (move, vec3_origin))
- {
- AngleMove_Done (ent);
+ if (VectorCompare(move, vec3_origin)) {
+ AngleMove_Done(ent);
return;
}
- VectorScale (move, 1.0/FRAMETIME, ent->avelocity);
+ VectorScale(move, 1.0 / FRAMETIME, ent->avelocity);
ent->think = AngleMove_Done;
ent->nextthink = level.time + FRAMETIME;
}
-void AngleMove_Begin (edict_t *ent)
+void AngleMove_Begin(edict_t *ent)
{
vec3_t destdelta;
float len;
@@ -180,42 +171,38 @@ void AngleMove_Begin (edict_t *ent)
// set destdelta to the vector needed to move
if (ent->moveinfo.state == STATE_UP)
- VectorSubtract (ent->moveinfo.end_angles, ent->s.angles, destdelta);
+ VectorSubtract(ent->moveinfo.end_angles, ent->s.angles, destdelta);
else
- VectorSubtract (ent->moveinfo.start_angles, ent->s.angles, destdelta);
-
+ VectorSubtract(ent->moveinfo.start_angles, ent->s.angles, destdelta);
+
// calculate length of vector
- len = VectorLength (destdelta);
-
+ len = VectorLength(destdelta);
+
// divide by speed to get time to reach dest
traveltime = len / ent->moveinfo.speed;
- if (traveltime < FRAMETIME)
- {
- AngleMove_Final (ent);
+ if (traveltime < FRAMETIME) {
+ AngleMove_Final(ent);
return;
}
frames = floor(traveltime / FRAMETIME);
// scale the destdelta vector by the time spent traveling to get velocity
- VectorScale (destdelta, 1.0 / traveltime, ent->avelocity);
+ VectorScale(destdelta, 1.0 / traveltime, ent->avelocity);
// set nextthink to trigger a think when dest is reached
ent->nextthink = level.time + frames * FRAMETIME;
ent->think = AngleMove_Final;
}
-void AngleMove_Calc (edict_t *ent, void(*func)(edict_t*))
+void AngleMove_Calc(edict_t *ent, void(*func)(edict_t*))
{
- VectorClear (ent->avelocity);
+ VectorClear(ent->avelocity);
ent->moveinfo.endfunc = func;
- if (level.current_entity == ((ent->flags & FL_TEAMSLAVE) ? ent->teammaster : ent))
- {
- AngleMove_Begin (ent);
- }
- else
- {
+ if (level.current_entity == ((ent->flags & FL_TEAMSLAVE) ? ent->teammaster : ent)) {
+ AngleMove_Begin(ent);
+ } else {
ent->nextthink = level.time + FRAMETIME;
ent->think = AngleMove_Begin;
}
@@ -239,36 +226,31 @@ void plat_CalcAcceleratedMove(moveinfo_t *moveinfo)
moveinfo->move_speed = moveinfo->speed;
- if (moveinfo->remaining_distance < moveinfo->accel)
- {
+ if (moveinfo->remaining_distance < moveinfo->accel) {
moveinfo->current_speed = moveinfo->remaining_distance;
return;
}
- accel_dist = AccelerationDistance (moveinfo->speed, moveinfo->accel);
- decel_dist = AccelerationDistance (moveinfo->speed, moveinfo->decel);
+ accel_dist = AccelerationDistance(moveinfo->speed, moveinfo->accel);
+ decel_dist = AccelerationDistance(moveinfo->speed, moveinfo->decel);
- if ((moveinfo->remaining_distance - accel_dist - decel_dist) < 0)
- {
+ if ((moveinfo->remaining_distance - accel_dist - decel_dist) < 0) {
float f;
f = (moveinfo->accel + moveinfo->decel) / (moveinfo->accel * moveinfo->decel);
moveinfo->move_speed = (-2 + sqrt(4 - 4 * f * (-2 * moveinfo->remaining_distance))) / (2 * f);
- decel_dist = AccelerationDistance (moveinfo->move_speed, moveinfo->decel);
+ decel_dist = AccelerationDistance(moveinfo->move_speed, moveinfo->decel);
}
moveinfo->decel_distance = decel_dist;
};
-void plat_Accelerate (moveinfo_t *moveinfo)
+void plat_Accelerate(moveinfo_t *moveinfo)
{
// are we decelerating?
- if (moveinfo->remaining_distance <= moveinfo->decel_distance)
- {
- if (moveinfo->remaining_distance < moveinfo->decel_distance)
- {
- if (moveinfo->next_speed)
- {
+ if (moveinfo->remaining_distance <= moveinfo->decel_distance) {
+ if (moveinfo->remaining_distance < moveinfo->decel_distance) {
+ if (moveinfo->next_speed) {
moveinfo->current_speed = moveinfo->next_speed;
moveinfo->next_speed = 0;
return;
@@ -281,8 +263,7 @@ void plat_Accelerate (moveinfo_t *moveinfo)
// are we at full speed and need to start decelerating during this move?
if (moveinfo->current_speed == moveinfo->move_speed)
- if ((moveinfo->remaining_distance - moveinfo->current_speed) < moveinfo->decel_distance)
- {
+ if ((moveinfo->remaining_distance - moveinfo->current_speed) < moveinfo->decel_distance) {
float p1_distance;
float p2_distance;
float distance;
@@ -296,8 +277,7 @@ void plat_Accelerate (moveinfo_t *moveinfo)
}
// are we accelerating?
- if (moveinfo->current_speed < moveinfo->speed)
- {
+ if (moveinfo->current_speed < moveinfo->speed) {
float old_speed;
float p1_distance;
float p1_speed;
@@ -331,36 +311,34 @@ void plat_Accelerate (moveinfo_t *moveinfo)
return;
};
-void Think_AccelMove (edict_t *ent)
+void Think_AccelMove(edict_t *ent)
{
ent->moveinfo.remaining_distance -= ent->moveinfo.current_speed;
if (ent->moveinfo.current_speed == 0) // starting or blocked
plat_CalcAcceleratedMove(&ent->moveinfo);
- plat_Accelerate (&ent->moveinfo);
+ plat_Accelerate(&ent->moveinfo);
// will the entire move complete on next frame?
- if (ent->moveinfo.remaining_distance <= ent->moveinfo.current_speed)
- {
- Move_Final (ent);
+ if (ent->moveinfo.remaining_distance <= ent->moveinfo.current_speed) {
+ Move_Final(ent);
return;
}
- VectorScale (ent->moveinfo.dir, ent->moveinfo.current_speed*10, ent->velocity);
+ VectorScale(ent->moveinfo.dir, ent->moveinfo.current_speed * 10, ent->velocity);
ent->nextthink = level.time + FRAMETIME;
ent->think = Think_AccelMove;
}
-void plat_go_down (edict_t *ent);
+void plat_go_down(edict_t *ent);
-void plat_hit_top (edict_t *ent)
+void plat_hit_top(edict_t *ent)
{
- if (!(ent->flags & FL_TEAMSLAVE))
- {
+ if (!(ent->flags & FL_TEAMSLAVE)) {
if (ent->moveinfo.sound_end)
- gi.sound (ent, CHAN_NO_PHS_ADD+CHAN_VOICE, ent->moveinfo.sound_end, 1, ATTN_STATIC, 0);
+ gi.sound(ent, CHAN_NO_PHS_ADD + CHAN_VOICE, ent->moveinfo.sound_end, 1, ATTN_STATIC, 0);
ent->s.sound = 0;
}
ent->moveinfo.state = STATE_TOP;
@@ -369,99 +347,95 @@ void plat_hit_top (edict_t *ent)
ent->nextthink = level.time + 3;
}
-void plat_hit_bottom (edict_t *ent)
+void plat_hit_bottom(edict_t *ent)
{
- if (!(ent->flags & FL_TEAMSLAVE))
- {
+ if (!(ent->flags & FL_TEAMSLAVE)) {
if (ent->moveinfo.sound_end)
- gi.sound (ent, CHAN_NO_PHS_ADD+CHAN_VOICE, ent->moveinfo.sound_end, 1, ATTN_STATIC, 0);
+ gi.sound(ent, CHAN_NO_PHS_ADD + CHAN_VOICE, ent->moveinfo.sound_end, 1, ATTN_STATIC, 0);
ent->s.sound = 0;
}
ent->moveinfo.state = STATE_BOTTOM;
}
-void plat_go_down (edict_t *ent)
+void plat_go_down(edict_t *ent)
{
- if (!(ent->flags & FL_TEAMSLAVE))
- {
+ if (!(ent->flags & FL_TEAMSLAVE)) {
if (ent->moveinfo.sound_start)
- gi.sound (ent, CHAN_NO_PHS_ADD+CHAN_VOICE, ent->moveinfo.sound_start, 1, ATTN_STATIC, 0);
+ gi.sound(ent, CHAN_NO_PHS_ADD + CHAN_VOICE, ent->moveinfo.sound_start, 1, ATTN_STATIC, 0);
ent->s.sound = ent->moveinfo.sound_middle;
}
ent->moveinfo.state = STATE_DOWN;
- Move_Calc (ent, ent->moveinfo.end_origin, plat_hit_bottom);
+ Move_Calc(ent, ent->moveinfo.end_origin, plat_hit_bottom);
}
-void plat_go_up (edict_t *ent)
+void plat_go_up(edict_t *ent)
{
- if (!(ent->flags & FL_TEAMSLAVE))
- {
+ if (!(ent->flags & FL_TEAMSLAVE)) {
if (ent->moveinfo.sound_start)
- gi.sound (ent, CHAN_NO_PHS_ADD+CHAN_VOICE, ent->moveinfo.sound_start, 1, ATTN_STATIC, 0);
+ gi.sound(ent, CHAN_NO_PHS_ADD + CHAN_VOICE, ent->moveinfo.sound_start, 1, ATTN_STATIC, 0);
ent->s.sound = ent->moveinfo.sound_middle;
}
ent->moveinfo.state = STATE_UP;
- Move_Calc (ent, ent->moveinfo.start_origin, plat_hit_top);
+ Move_Calc(ent, ent->moveinfo.start_origin, plat_hit_top);
}
-void plat_blocked (edict_t *self, edict_t *other)
+void plat_blocked(edict_t *self, edict_t *other)
{
- if (!(other->svflags & SVF_MONSTER) && (!other->client) )
- {
+ if (!(other->svflags & SVF_MONSTER) && (!other->client)) {
// give it a chance to go away on it's own terms (like gibs)
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
- BecomeExplosion1 (other);
+ BecomeExplosion1(other);
return;
}
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
if (self->moveinfo.state == STATE_UP)
- plat_go_down (self);
+ plat_go_down(self);
else if (self->moveinfo.state == STATE_DOWN)
- plat_go_up (self);
+ plat_go_up(self);
}
-void Use_Plat (edict_t *ent, edict_t *other, edict_t *activator)
-{
+void Use_Plat(edict_t *ent, edict_t *other, edict_t *activator)
+{
if (ent->think)
return; // already down
- plat_go_down (ent);
+ plat_go_down(ent);
}
-void Touch_Plat_Center (edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
+void Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (!other->client)
return;
-
+
if (other->health <= 0)
return;
ent = ent->enemy; // now point at the plat, not the trigger
if (ent->moveinfo.state == STATE_BOTTOM)
- plat_go_up (ent);
+ plat_go_up(ent);
else if (ent->moveinfo.state == STATE_TOP)
ent->nextthink = level.time + 1; // the player is still on the plat, so delay going down
}
-void plat_spawn_inside_trigger (edict_t *ent)
+void plat_spawn_inside_trigger(edict_t *ent)
{
edict_t *trigger;
vec3_t tmin, tmax;
//
// middle trigger
-//
+//
trigger = G_Spawn();
trigger->touch = Touch_Plat_Center;
trigger->movetype = MOVETYPE_NONE;
trigger->solid = SOLID_TRIGGER;
trigger->enemy = ent;
-
+
tmin[0] = ent->mins[0] + 25;
tmin[1] = ent->mins[1] + 25;
tmin[2] = ent->mins[2];
@@ -474,22 +448,20 @@ void plat_spawn_inside_trigger (edict_t *ent)
if (ent->spawnflags & PLAT_LOW_TRIGGER)
tmax[2] = tmin[2] + 8;
-
- if (tmax[0] - tmin[0] <= 0)
- {
- tmin[0] = (ent->mins[0] + ent->maxs[0]) *0.5;
+
+ if (tmax[0] - tmin[0] <= 0) {
+ tmin[0] = (ent->mins[0] + ent->maxs[0]) * 0.5;
tmax[0] = tmin[0] + 1;
}
- if (tmax[1] - tmin[1] <= 0)
- {
- tmin[1] = (ent->mins[1] + ent->maxs[1]) *0.5;
+ if (tmax[1] - tmin[1] <= 0) {
+ tmin[1] = (ent->mins[1] + ent->maxs[1]) * 0.5;
tmax[1] = tmin[1] + 1;
}
-
- VectorCopy (tmin, trigger->mins);
- VectorCopy (tmax, trigger->maxs);
- gi.linkentity (trigger);
+ VectorCopy(tmin, trigger->mins);
+ VectorCopy(tmax, trigger->maxs);
+
+ gi.linkentity(trigger);
}
@@ -510,13 +482,13 @@ Set "sounds" to one of the following:
1) base fast
2) chain slow
*/
-void SP_func_plat (edict_t *ent)
+void SP_func_plat(edict_t *ent)
{
- VectorClear (ent->s.angles);
+ VectorClear(ent->s.angles);
ent->solid = SOLID_BSP;
ent->movetype = MOVETYPE_PUSH;
- gi.setmodel (ent, ent->model);
+ gi.setmodel(ent, ent->model);
ent->blocked = plat_blocked;
@@ -542,8 +514,8 @@ void SP_func_plat (edict_t *ent)
st.lip = 8;
// pos1 is the top position, pos2 is the bottom
- VectorCopy (ent->s.origin, ent->pos1);
- VectorCopy (ent->s.origin, ent->pos2);
+ VectorCopy(ent->s.origin, ent->pos1);
+ VectorCopy(ent->s.origin, ent->pos2);
if (st.height)
ent->pos2[2] -= st.height;
else
@@ -551,16 +523,13 @@ void SP_func_plat (edict_t *ent)
ent->use = Use_Plat;
- plat_spawn_inside_trigger (ent); // the "start moving" trigger
+ plat_spawn_inside_trigger(ent); // the "start moving" trigger
- if (ent->targetname)
- {
+ if (ent->targetname) {
ent->moveinfo.state = STATE_UP;
- }
- else
- {
- VectorCopy (ent->pos2, ent->s.origin);
- gi.linkentity (ent);
+ } else {
+ VectorCopy(ent->pos2, ent->s.origin);
+ gi.linkentity(ent);
ent->moveinfo.state = STATE_BOTTOM;
}
@@ -568,14 +537,14 @@ void SP_func_plat (edict_t *ent)
ent->moveinfo.accel = ent->accel;
ent->moveinfo.decel = ent->decel;
ent->moveinfo.wait = ent->wait;
- VectorCopy (ent->pos1, ent->moveinfo.start_origin);
- VectorCopy (ent->s.angles, ent->moveinfo.start_angles);
- VectorCopy (ent->pos2, ent->moveinfo.end_origin);
- VectorCopy (ent->s.angles, ent->moveinfo.end_angles);
+ VectorCopy(ent->pos1, ent->moveinfo.start_origin);
+ VectorCopy(ent->s.angles, ent->moveinfo.start_angles);
+ VectorCopy(ent->pos2, ent->moveinfo.end_origin);
+ VectorCopy(ent->s.angles, ent->moveinfo.end_angles);
- ent->moveinfo.sound_start = gi.soundindex ("plats/pt1_strt.wav");
- ent->moveinfo.sound_middle = gi.soundindex ("plats/pt1_mid.wav");
- ent->moveinfo.sound_end = gi.soundindex ("plats/pt1_end.wav");
+ ent->moveinfo.sound_start = gi.soundindex("plats/pt1_strt.wav");
+ ent->moveinfo.sound_middle = gi.soundindex("plats/pt1_mid.wav");
+ ent->moveinfo.sound_end = gi.soundindex("plats/pt1_end.wav");
}
//====================================================================
@@ -592,35 +561,32 @@ REVERSE will cause the it to rotate in the opposite direction.
STOP mean it will stop moving instead of pushing entities
*/
-void rotating_blocked (edict_t *self, edict_t *other)
+void rotating_blocked(edict_t *self, edict_t *other)
{
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
}
-void rotating_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
+void rotating_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (self->avelocity[0] || self->avelocity[1] || self->avelocity[2])
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
}
-void rotating_use (edict_t *self, edict_t *other, edict_t *activator)
+void rotating_use(edict_t *self, edict_t *other, edict_t *activator)
{
- if (!VectorCompare (self->avelocity, vec3_origin))
- {
+ if (!VectorCompare(self->avelocity, vec3_origin)) {
self->s.sound = 0;
- VectorClear (self->avelocity);
+ VectorClear(self->avelocity);
self->touch = NULL;
- }
- else
- {
+ } else {
self->s.sound = self->moveinfo.sound_middle;
- VectorScale (self->movedir, self->speed, self->avelocity);
+ VectorScale(self->movedir, self->speed, self->avelocity);
if (self->spawnflags & 16)
self->touch = rotating_touch;
}
}
-void SP_func_rotating (edict_t *ent)
+void SP_func_rotating(edict_t *ent)
{
ent->solid = SOLID_BSP;
if (ent->spawnflags & 32)
@@ -639,7 +605,7 @@ void SP_func_rotating (edict_t *ent)
// check for reverse rotation
if (ent->spawnflags & 2)
- VectorNegate (ent->movedir, ent->movedir);
+ VectorNegate(ent->movedir, ent->movedir);
if (!ent->speed)
ent->speed = 100;
@@ -653,15 +619,15 @@ void SP_func_rotating (edict_t *ent)
ent->blocked = rotating_blocked;
if (ent->spawnflags & 1)
- ent->use (ent, NULL, NULL);
+ ent->use(ent, NULL, NULL);
if (ent->spawnflags & 64)
ent->s.effects |= EF_ANIM_ALL;
if (ent->spawnflags & 128)
ent->s.effects |= EF_ANIM_ALLFAST;
- gi.setmodel (ent, ent->model);
- gi.linkentity (ent);
+ gi.setmodel(ent, ent->model);
+ gi.linkentity(ent);
}
/*
@@ -689,18 +655,18 @@ When a button is touched, it moves some distance in the direction of it's angle,
5) in-out
*/
-void button_done (edict_t *self)
+void button_done(edict_t *self)
{
self->moveinfo.state = STATE_BOTTOM;
self->s.effects &= ~EF_ANIM23;
self->s.effects |= EF_ANIM01;
}
-void button_return (edict_t *self)
+void button_return(edict_t *self)
{
self->moveinfo.state = STATE_DOWN;
- Move_Calc (self, self->moveinfo.start_origin, button_done);
+ Move_Calc(self, self->moveinfo.start_origin, button_done);
self->s.frame = 0;
@@ -708,39 +674,38 @@ void button_return (edict_t *self)
self->takedamage = DAMAGE_YES;
}
-void button_wait (edict_t *self)
+void button_wait(edict_t *self)
{
self->moveinfo.state = STATE_TOP;
self->s.effects &= ~EF_ANIM01;
self->s.effects |= EF_ANIM23;
- G_UseTargets (self, self->activator);
+ G_UseTargets(self, self->activator);
self->s.frame = 1;
- if (self->moveinfo.wait >= 0)
- {
+ if (self->moveinfo.wait >= 0) {
self->nextthink = level.time + self->moveinfo.wait;
self->think = button_return;
}
}
-void button_fire (edict_t *self)
+void button_fire(edict_t *self)
{
if (self->moveinfo.state == STATE_UP || self->moveinfo.state == STATE_TOP)
return;
self->moveinfo.state = STATE_UP;
if (self->moveinfo.sound_start && !(self->flags & FL_TEAMSLAVE))
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
- Move_Calc (self, self->moveinfo.end_origin, button_wait);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
+ Move_Calc(self, self->moveinfo.end_origin, button_wait);
}
-void button_use (edict_t *self, edict_t *other, edict_t *activator)
+void button_use(edict_t *self, edict_t *other, edict_t *activator)
{
self->activator = activator;
- button_fire (self);
+ button_fire(self);
}
-void button_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
+void button_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (!other->client)
return;
@@ -749,30 +714,30 @@ void button_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *s
return;
self->activator = other;
- button_fire (self);
+ button_fire(self);
}
-void button_killed (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
+void button_killed(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
self->activator = attacker;
self->health = self->max_health;
self->takedamage = DAMAGE_NO;
- button_fire (self);
+ button_fire(self);
}
-void SP_func_button (edict_t *ent)
+void SP_func_button(edict_t *ent)
{
vec3_t abs_movedir;
float dist;
- G_SetMovedir (ent->s.angles, ent->movedir);
+ G_SetMovedir(ent->s.angles, ent->movedir);
ent->movetype = MOVETYPE_STOP;
ent->solid = SOLID_BSP;
- gi.setmodel (ent, ent->model);
+ gi.setmodel(ent, ent->model);
if (ent->sounds != 1)
- ent->moveinfo.sound_start = gi.soundindex ("switches/butn2.wav");
-
+ ent->moveinfo.sound_start = gi.soundindex("switches/butn2.wav");
+
if (!ent->speed)
ent->speed = 40;
if (!ent->accel)
@@ -785,23 +750,21 @@ void SP_func_button (edict_t *ent)
if (!st.lip)
st.lip = 4;
- VectorCopy (ent->s.origin, ent->pos1);
+ VectorCopy(ent->s.origin, ent->pos1);
abs_movedir[0] = fabs(ent->movedir[0]);
abs_movedir[1] = fabs(ent->movedir[1]);
abs_movedir[2] = fabs(ent->movedir[2]);
dist = abs_movedir[0] * ent->size[0] + abs_movedir[1] * ent->size[1] + abs_movedir[2] * ent->size[2] - st.lip;
- VectorMA (ent->pos1, dist, ent->movedir, ent->pos2);
+ VectorMA(ent->pos1, dist, ent->movedir, ent->pos2);
ent->use = button_use;
ent->s.effects |= EF_ANIM01;
- if (ent->health)
- {
+ if (ent->health) {
ent->max_health = ent->health;
ent->die = button_killed;
ent->takedamage = DAMAGE_YES;
- }
- else if (! ent->targetname)
+ } else if (! ent->targetname)
ent->touch = button_touch;
ent->moveinfo.state = STATE_BOTTOM;
@@ -810,12 +773,12 @@ void SP_func_button (edict_t *ent)
ent->moveinfo.accel = ent->accel;
ent->moveinfo.decel = ent->decel;
ent->moveinfo.wait = ent->wait;
- VectorCopy (ent->pos1, ent->moveinfo.start_origin);
- VectorCopy (ent->s.angles, ent->moveinfo.start_angles);
- VectorCopy (ent->pos2, ent->moveinfo.end_origin);
- VectorCopy (ent->s.angles, ent->moveinfo.end_angles);
+ VectorCopy(ent->pos1, ent->moveinfo.start_origin);
+ VectorCopy(ent->s.angles, ent->moveinfo.start_angles);
+ VectorCopy(ent->pos2, ent->moveinfo.end_origin);
+ VectorCopy(ent->s.angles, ent->moveinfo.end_angles);
- gi.linkentity (ent);
+ gi.linkentity(ent);
}
/*
@@ -849,135 +812,123 @@ NOMONSTER monsters will not trigger this door
4) heavy
*/
-void door_use_areaportals (edict_t *self, qboolean open)
+void door_use_areaportals(edict_t *self, qboolean open)
{
edict_t *t = NULL;
if (!self->target)
return;
- while ((t = G_Find (t, FOFS(targetname), self->target)))
- {
- if (Q_stricmp(t->classname, "func_areaportal") == 0)
- {
- gi.SetAreaPortalState (t->style, open);
+ while ((t = G_Find(t, FOFS(targetname), self->target))) {
+ if (Q_stricmp(t->classname, "func_areaportal") == 0) {
+ gi.SetAreaPortalState(t->style, open);
}
}
}
-void door_go_down (edict_t *self);
+void door_go_down(edict_t *self);
-void door_hit_top (edict_t *self)
+void door_hit_top(edict_t *self)
{
- if (!(self->flags & FL_TEAMSLAVE))
- {
+ if (!(self->flags & FL_TEAMSLAVE)) {
if (self->moveinfo.sound_end)
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_end, 1, ATTN_STATIC, 0);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_end, 1, ATTN_STATIC, 0);
self->s.sound = 0;
}
self->moveinfo.state = STATE_TOP;
if (self->spawnflags & DOOR_TOGGLE)
return;
- if (self->moveinfo.wait >= 0)
- {
+ if (self->moveinfo.wait >= 0) {
self->think = door_go_down;
self->nextthink = level.time + self->moveinfo.wait;
}
}
-void door_hit_bottom (edict_t *self)
+void door_hit_bottom(edict_t *self)
{
- if (!(self->flags & FL_TEAMSLAVE))
- {
+ if (!(self->flags & FL_TEAMSLAVE)) {
if (self->moveinfo.sound_end)
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_end, 1, ATTN_STATIC, 0);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_end, 1, ATTN_STATIC, 0);
self->s.sound = 0;
}
self->moveinfo.state = STATE_BOTTOM;
- door_use_areaportals (self, qfalse);
+ door_use_areaportals(self, qfalse);
}
-void door_go_down (edict_t *self)
+void door_go_down(edict_t *self)
{
- if (!(self->flags & FL_TEAMSLAVE))
- {
+ if (!(self->flags & FL_TEAMSLAVE)) {
if (self->moveinfo.sound_start)
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
self->s.sound = self->moveinfo.sound_middle;
}
- if (self->max_health)
- {
+ if (self->max_health) {
self->takedamage = DAMAGE_YES;
self->health = self->max_health;
}
-
+
self->moveinfo.state = STATE_DOWN;
if (strcmp(self->classname, "func_door") == 0)
- Move_Calc (self, self->moveinfo.start_origin, door_hit_bottom);
+ Move_Calc(self, self->moveinfo.start_origin, door_hit_bottom);
else if (strcmp(self->classname, "func_door_rotating") == 0)
- AngleMove_Calc (self, door_hit_bottom);
+ AngleMove_Calc(self, door_hit_bottom);
}
-void door_go_up (edict_t *self, edict_t *activator)
+void door_go_up(edict_t *self, edict_t *activator)
{
if (self->moveinfo.state == STATE_UP)
return; // already going up
- if (self->moveinfo.state == STATE_TOP)
- { // reset top wait time
+ if (self->moveinfo.state == STATE_TOP) {
+ // reset top wait time
if (self->moveinfo.wait >= 0)
self->nextthink = level.time + self->moveinfo.wait;
return;
}
-
- if (!(self->flags & FL_TEAMSLAVE))
- {
+
+ if (!(self->flags & FL_TEAMSLAVE)) {
if (self->moveinfo.sound_start)
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
self->s.sound = self->moveinfo.sound_middle;
}
self->moveinfo.state = STATE_UP;
if (strcmp(self->classname, "func_door") == 0)
- Move_Calc (self, self->moveinfo.end_origin, door_hit_top);
+ Move_Calc(self, self->moveinfo.end_origin, door_hit_top);
else if (strcmp(self->classname, "func_door_rotating") == 0)
- AngleMove_Calc (self, door_hit_top);
+ AngleMove_Calc(self, door_hit_top);
- G_UseTargets (self, activator);
- door_use_areaportals (self, qtrue);
+ G_UseTargets(self, activator);
+ door_use_areaportals(self, qtrue);
}
-void door_use (edict_t *self, edict_t *other, edict_t *activator)
+void door_use(edict_t *self, edict_t *other, edict_t *activator)
{
edict_t *ent;
if (self->flags & FL_TEAMSLAVE)
return;
- if (self->spawnflags & DOOR_TOGGLE)
- {
- if (self->moveinfo.state == STATE_UP || self->moveinfo.state == STATE_TOP)
- {
+ if (self->spawnflags & DOOR_TOGGLE) {
+ if (self->moveinfo.state == STATE_UP || self->moveinfo.state == STATE_TOP) {
// trigger all paired doors
- for (ent = self ; ent ; ent = ent->teamchain)
- {
+ for (ent = self ; ent ; ent = ent->teamchain) {
ent->message = NULL;
ent->touch = NULL;
- door_go_down (ent);
+ door_go_down(ent);
}
return;
}
}
-
+
// trigger all paired doors
- for (ent = self ; ent ; ent = ent->teamchain)
- {
+ for (ent = self ; ent ; ent = ent->teamchain) {
ent->message = NULL;
ent->touch = NULL;
- door_go_up (ent, activator);
+ door_go_up(ent, activator);
}
};
-void Touch_DoorTrigger (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
+void Touch_DoorTrigger(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (other->health <= 0)
return;
@@ -992,10 +943,10 @@ void Touch_DoorTrigger (edict_t *self, edict_t *other, cplane_t *plane, csurface
return;
self->touch_debounce_time = level.time + 1.0;
- door_use (self->owner, other, other);
+ door_use(self->owner, other, other);
}
-void Think_CalcMoveSpeed (edict_t *self)
+void Think_CalcMoveSpeed(edict_t *self)
{
edict_t *ent;
float min;
@@ -1009,8 +960,7 @@ void Think_CalcMoveSpeed (edict_t *self)
// find the smallest distance any member of the team will be moving
min = fabs(self->moveinfo.distance);
- for (ent = self->teamchain; ent; ent = ent->teamchain)
- {
+ for (ent = self->teamchain; ent; ent = ent->teamchain) {
dist = fabs(ent->moveinfo.distance);
if (dist < min)
min = dist;
@@ -1019,8 +969,7 @@ void Think_CalcMoveSpeed (edict_t *self)
time = min / self->moveinfo.speed;
// adjust speeds so they will all complete at the same time
- for (ent = self; ent; ent = ent->teamchain)
- {
+ for (ent = self; ent; ent = ent->teamchain) {
newspeed = fabs(ent->moveinfo.distance) / time;
ratio = newspeed / ent->moveinfo.speed;
if (ent->moveinfo.accel == ent->moveinfo.speed)
@@ -1035,7 +984,7 @@ void Think_CalcMoveSpeed (edict_t *self)
}
}
-void Think_SpawnDoorTrigger (edict_t *ent)
+void Think_SpawnDoorTrigger(edict_t *ent)
{
edict_t *other;
vec3_t mins, maxs;
@@ -1043,51 +992,49 @@ void Think_SpawnDoorTrigger (edict_t *ent)
if (ent->flags & FL_TEAMSLAVE)
return; // only the team leader spawns a trigger
- VectorCopy (ent->absmin, mins);
- VectorCopy (ent->absmax, maxs);
+ VectorCopy(ent->absmin, mins);
+ VectorCopy(ent->absmax, maxs);
- for (other = ent->teamchain ; other ; other=other->teamchain)
- {
- AddPointToBounds (other->absmin, mins, maxs);
- AddPointToBounds (other->absmax, mins, maxs);
+ for (other = ent->teamchain ; other ; other = other->teamchain) {
+ AddPointToBounds(other->absmin, mins, maxs);
+ AddPointToBounds(other->absmax, mins, maxs);
}
- // expand
+ // expand
mins[0] -= 60;
mins[1] -= 60;
maxs[0] += 60;
maxs[1] += 60;
- other = G_Spawn ();
- VectorCopy (mins, other->mins);
- VectorCopy (maxs, other->maxs);
+ other = G_Spawn();
+ VectorCopy(mins, other->mins);
+ VectorCopy(maxs, other->maxs);
other->owner = ent;
other->solid = SOLID_TRIGGER;
other->movetype = MOVETYPE_NONE;
other->touch = Touch_DoorTrigger;
- gi.linkentity (other);
+ gi.linkentity(other);
if (ent->spawnflags & DOOR_START_OPEN)
- door_use_areaportals (ent, qtrue);
+ door_use_areaportals(ent, qtrue);
- Think_CalcMoveSpeed (ent);
+ Think_CalcMoveSpeed(ent);
}
-void door_blocked (edict_t *self, edict_t *other)
+void door_blocked(edict_t *self, edict_t *other)
{
edict_t *ent;
- if (!(other->svflags & SVF_MONSTER) && (!other->client) )
- {
+ if (!(other->svflags & SVF_MONSTER) && (!other->client)) {
// give it a chance to go away on it's own terms (like gibs)
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
- BecomeExplosion1 (other);
+ BecomeExplosion1(other);
return;
}
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
if (self->spawnflags & DOOR_CRUSHER)
return;
@@ -1095,34 +1042,29 @@ void door_blocked (edict_t *self, edict_t *other)
// if a door has a negative wait, it would never come back if blocked,
// so let it just squash the object to death real fast
- if (self->moveinfo.wait >= 0)
- {
- if (self->moveinfo.state == STATE_DOWN)
- {
+ if (self->moveinfo.wait >= 0) {
+ if (self->moveinfo.state == STATE_DOWN) {
for (ent = self->teammaster ; ent ; ent = ent->teamchain)
- door_go_up (ent, ent->activator);
- }
- else
- {
+ door_go_up(ent, ent->activator);
+ } else {
for (ent = self->teammaster ; ent ; ent = ent->teamchain)
- door_go_down (ent);
+ door_go_down(ent);
}
}
}
-void door_killed (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
+void door_killed(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
edict_t *ent;
- for (ent = self->teammaster ; ent ; ent = ent->teamchain)
- {
+ for (ent = self->teammaster ; ent ; ent = ent->teamchain) {
ent->health = ent->max_health;
ent->takedamage = DAMAGE_NO;
}
- door_use (self->teammaster, attacker, attacker);
+ door_use(self->teammaster, attacker, attacker);
}
-void door_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
+void door_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
{
if (!other->client)
return;
@@ -1131,29 +1073,28 @@ void door_touch (edict_t *self, edict_t *other, cplane_t *plane, csurface_t *sur
return;
self->touch_debounce_time = level.time + 5.0;
- gi.centerprintf (other, "%s", self->message);
- gi.sound (other, CHAN_AUTO, gi.soundindex ("misc/talk1.wav"), 1, ATTN_NORM, 0);
+ gi.centerprintf(other, "%s", self->message);
+ gi.sound(other, CHAN_AUTO, gi.soundindex("misc/talk1.wav"), 1, ATTN_NORM, 0);
}
-void SP_func_door (edict_t *ent)
+void SP_func_door(edict_t *ent)
{
vec3_t abs_movedir;
- if (ent->sounds != 1)
- {
- ent->moveinfo.sound_start = gi.soundindex ("doors/dr1_strt.wav");
- ent->moveinfo.sound_middle = gi.soundindex ("doors/dr1_mid.wav");
- ent->moveinfo.sound_end = gi.soundindex ("doors/dr1_end.wav");
+ if (ent->sounds != 1) {
+ ent->moveinfo.sound_start = gi.soundindex("doors/dr1_strt.wav");
+ ent->moveinfo.sound_middle = gi.soundindex("doors/dr1_mid.wav");
+ ent->moveinfo.sound_end = gi.soundindex("doors/dr1_end.wav");
}
- G_SetMovedir (ent->s.angles, ent->movedir);
+ G_SetMovedir(ent->s.angles, ent->movedir);
ent->movetype = MOVETYPE_PUSH;
ent->solid = SOLID_BSP;
- gi.setmodel (ent, ent->model);
+ gi.setmodel(ent, ent->model);
ent->blocked = door_blocked;
ent->use = door_use;
-
+
if (!ent->speed)
ent->speed = 100;
if (deathmatch->value)
@@ -1172,43 +1113,39 @@ void SP_func_door (edict_t *ent)
ent->dmg = 2;
// calculate second position
- VectorCopy (ent->s.origin, ent->pos1);
+ VectorCopy(ent->s.origin, ent->pos1);
abs_movedir[0] = fabs(ent->movedir[0]);
abs_movedir[1] = fabs(ent->movedir[1]);
abs_movedir[2] = fabs(ent->movedir[2]);
ent->moveinfo.distance = abs_movedir[0] * ent->size[0] + abs_movedir[1] * ent->size[1] + abs_movedir[2] * ent->size[2] - st.lip;
- VectorMA (ent->pos1, ent->moveinfo.distance, ent->movedir, ent->pos2);
+ VectorMA(ent->pos1, ent->moveinfo.distance, ent->movedir, ent->pos2);
// if it starts open, switch the positions
- if (ent->spawnflags & DOOR_START_OPEN)
- {
- VectorCopy (ent->pos2, ent->s.origin);
- VectorCopy (ent->pos1, ent->pos2);
- VectorCopy (ent->s.origin, ent->pos1);
+ if (ent->spawnflags & DOOR_START_OPEN) {
+ VectorCopy(ent->pos2, ent->s.origin);
+ VectorCopy(ent->pos1, ent->pos2);
+ VectorCopy(ent->s.origin, ent->pos1);
}
ent->moveinfo.state = STATE_BOTTOM;
- if (ent->health)
- {
+ if (ent->health) {
ent->takedamage = DAMAGE_YES;
ent->die = door_killed;
ent->max_health = ent->health;
- }
- else if (ent->targetname && ent->message)
- {
- gi.soundindex ("misc/talk.wav");
+ } else if (ent->targetname && ent->message) {
+ gi.soundindex("misc/talk.wav");
ent->touch = door_touch;
}
-
+
ent->moveinfo.speed = ent->speed;
ent->moveinfo.accel = ent->accel;
ent->moveinfo.decel = ent->decel;
ent->moveinfo.wait = ent->wait;
- VectorCopy (ent->pos1, ent->moveinfo.start_origin);
- VectorCopy (ent->s.angles, ent->moveinfo.start_angles);
- VectorCopy (ent->pos2, ent->moveinfo.end_origin);
- VectorCopy (ent->s.angles, ent->moveinfo.end_angles);
+ VectorCopy(ent->pos1, ent->moveinfo.start_origin);
+ VectorCopy(ent->s.angles, ent->moveinfo.start_angles);
+ VectorCopy(ent->pos2, ent->moveinfo.end_origin);
+ VectorCopy(ent->s.angles, ent->moveinfo.end_angles);
if (ent->spawnflags & 16)
ent->s.effects |= EF_ANIM_ALL;
@@ -1219,7 +1156,7 @@ void SP_func_door (edict_t *ent)
if (!ent->team)
ent->teammaster = ent;
- gi.linkentity (ent);
+ gi.linkentity(ent);
ent->nextthink = level.time + FRAMETIME;
if (ent->health || ent->targetname)
@@ -1258,9 +1195,9 @@ REVERSE will cause the door to rotate in the opposite direction.
4) heavy
*/
-void SP_func_door_rotating (edict_t *ent)
+void SP_func_door_rotating(edict_t *ent)
{
- VectorClear (ent->s.angles);
+ VectorClear(ent->s.angles);
// set the axis of rotation
VectorClear(ent->movedir);
@@ -1273,21 +1210,20 @@ void SP_func_door_rotating (edict_t *ent)
// check for reverse rotation
if (ent->spawnflags & DOOR_REVERSE)
- VectorNegate (ent->movedir, ent->movedir);
+ VectorNegate(ent->movedir, ent->movedir);
- if (!st.distance)
- {
+ if (!st.distance) {
gi.dprintf("%s at %s with no distance set\n", ent->classname, vtos(ent->s.origin));
st.distance = 90;
}
- VectorCopy (ent->s.angles, ent->pos1);
- VectorMA (ent->s.angles, st.distance, ent->movedir, ent->pos2);
+ VectorCopy(ent->s.angles, ent->pos1);
+ VectorMA(ent->s.angles, st.distance, ent->movedir, ent->pos2);
ent->moveinfo.distance = st.distance;
ent->movetype = MOVETYPE_PUSH;
ent->solid = SOLID_BSP;
- gi.setmodel (ent, ent->model);
+ gi.setmodel(ent, ent->model);
ent->blocked = door_blocked;
ent->use = door_use;
@@ -1304,32 +1240,28 @@ void SP_func_door_rotating (edict_t *ent)
if (!ent->dmg)
ent->dmg = 2;
- if (ent->sounds != 1)
- {
- ent->moveinfo.sound_start = gi.soundindex ("doors/dr1_strt.wav");
- ent->moveinfo.sound_middle = gi.soundindex ("doors/dr1_mid.wav");
- ent->moveinfo.sound_end = gi.soundindex ("doors/dr1_end.wav");
+ if (ent->sounds != 1) {
+ ent->moveinfo.sound_start = gi.soundindex("doors/dr1_strt.wav");
+ ent->moveinfo.sound_middle = gi.soundindex("doors/dr1_mid.wav");
+ ent->moveinfo.sound_end = gi.soundindex("doors/dr1_end.wav");
}
// if it starts open, switch the positions
- if (ent->spawnflags & DOOR_START_OPEN)
- {
- VectorCopy (ent->pos2, ent->s.angles);
- VectorCopy (ent->pos1, ent->pos2);
- VectorCopy (ent->s.angles, ent->pos1);
- VectorNegate (ent->movedir, ent->movedir);
+ if (ent->spawnflags & DOOR_START_OPEN) {
+ VectorCopy(ent->pos2, ent->s.angles);
+ VectorCopy(ent->pos1, ent->pos2);
+ VectorCopy(ent->s.angles, ent->pos1);
+ VectorNegate(ent->movedir, ent->movedir);
}
- if (ent->health)
- {
+ if (ent->health) {
ent->takedamage = DAMAGE_YES;
ent->die = door_killed;
ent->max_health = ent->health;
}
-
- if (ent->targetname && ent->message)
- {
- gi.soundindex ("misc/talk.wav");
+
+ if (ent->targetname && ent->message) {
+ gi.soundindex("misc/talk.wav");
ent->touch = door_touch;
}
@@ -1338,10 +1270,10 @@ void SP_func_door_rotating (edict_t *ent)
ent->moveinfo.accel = ent->accel;
ent->moveinfo.decel = ent->decel;
ent->moveinfo.wait = ent->wait;
- VectorCopy (ent->s.origin, ent->moveinfo.start_origin);
- VectorCopy (ent->pos1, ent->moveinfo.start_angles);
- VectorCopy (ent->s.origin, ent->moveinfo.end_origin);
- VectorCopy (ent->pos2, ent->moveinfo.end_angles);
+ VectorCopy(ent->s.origin, ent->moveinfo.start_origin);
+ VectorCopy(ent->pos1, ent->moveinfo.start_angles);
+ VectorCopy(ent->s.origin, ent->moveinfo.end_origin);
+ VectorCopy(ent->pos2, ent->moveinfo.end_angles);
if (ent->spawnflags & 16)
ent->s.effects |= EF_ANIM_ALL;
@@ -1350,7 +1282,7 @@ void SP_func_door_rotating (edict_t *ent)
if (!ent->team)
ent->teammaster = ent;
- gi.linkentity (ent);
+ gi.linkentity(ent);
ent->nextthink = level.time + FRAMETIME;
if (ent->health || ent->targetname)
@@ -1375,51 +1307,49 @@ START_OPEN causes the water to move to its destination when spawned and operate
2) lava
*/
-void SP_func_water (edict_t *self)
+void SP_func_water(edict_t *self)
{
vec3_t abs_movedir;
- G_SetMovedir (self->s.angles, self->movedir);
+ G_SetMovedir(self->s.angles, self->movedir);
self->movetype = MOVETYPE_PUSH;
self->solid = SOLID_BSP;
- gi.setmodel (self, self->model);
+ gi.setmodel(self, self->model);
- switch (self->sounds)
- {
- default:
- break;
+ switch (self->sounds) {
+ default:
+ break;
- case 1: // water
- self->moveinfo.sound_start = gi.soundindex ("world/mov_watr.wav");
- self->moveinfo.sound_end = gi.soundindex ("world/stp_watr.wav");
- break;
+ case 1: // water
+ self->moveinfo.sound_start = gi.soundindex("world/mov_watr.wav");
+ self->moveinfo.sound_end = gi.soundindex("world/stp_watr.wav");
+ break;
- case 2: // lava
- self->moveinfo.sound_start = gi.soundindex ("world/mov_watr.wav");
- self->moveinfo.sound_end = gi.soundindex ("world/stp_watr.wav");
- break;
+ case 2: // lava
+ self->moveinfo.sound_start = gi.soundindex("world/mov_watr.wav");
+ self->moveinfo.sound_end = gi.soundindex("world/stp_watr.wav");
+ break;
}
// calculate second position
- VectorCopy (self->s.origin, self->pos1);
+ VectorCopy(self->s.origin, self->pos1);
abs_movedir[0] = fabs(self->movedir[0]);
abs_movedir[1] = fabs(self->movedir[1]);
abs_movedir[2] = fabs(self->movedir[2]);
self->moveinfo.distance = abs_movedir[0] * self->size[0] + abs_movedir[1] * self->size[1] + abs_movedir[2] * self->size[2] - st.lip;
- VectorMA (self->pos1, self->moveinfo.distance, self->movedir, self->pos2);
+ VectorMA(self->pos1, self->moveinfo.distance, self->movedir, self->pos2);
// if it starts open, switch the positions
- if (self->spawnflags & DOOR_START_OPEN)
- {
- VectorCopy (self->pos2, self->s.origin);
- VectorCopy (self->pos1, self->pos2);
- VectorCopy (self->s.origin, self->pos1);
+ if (self->spawnflags & DOOR_START_OPEN) {
+ VectorCopy(self->pos2, self->s.origin);
+ VectorCopy(self->pos1, self->pos2);
+ VectorCopy(self->s.origin, self->pos1);
}
- VectorCopy (self->pos1, self->moveinfo.start_origin);
- VectorCopy (self->s.angles, self->moveinfo.start_angles);
- VectorCopy (self->pos2, self->moveinfo.end_origin);
- VectorCopy (self->s.angles, self->moveinfo.end_angles);
+ VectorCopy(self->pos1, self->moveinfo.start_origin);
+ VectorCopy(self->s.angles, self->moveinfo.start_angles);
+ VectorCopy(self->pos2, self->moveinfo.end_origin);
+ VectorCopy(self->s.angles, self->moveinfo.end_angles);
self->moveinfo.state = STATE_BOTTOM;
@@ -1438,7 +1368,7 @@ void SP_func_water (edict_t *self)
self->classname = "func_door";
- gi.linkentity (self);
+ gi.linkentity(self);
}
@@ -1456,17 +1386,16 @@ dmg default 2
noise looping sound to play when the train is in motion
*/
-void train_next (edict_t *self);
+void train_next(edict_t *self);
-void train_blocked (edict_t *self, edict_t *other)
+void train_blocked(edict_t *self, edict_t *other)
{
- if (!(other->svflags & SVF_MONSTER) && (!other->client) )
- {
+ if (!(other->svflags & SVF_MONSTER) && (!other->client)) {
// give it a chance to go away on it's own terms (like gibs)
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
- BecomeExplosion1 (other);
+ BecomeExplosion1(other);
return;
}
@@ -1476,20 +1405,19 @@ void train_blocked (edict_t *self, edict_t *other)
if (!self->dmg)
return;
self->touch_debounce_time = level.time + 0.5;
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
}
-void train_wait (edict_t *self)
+void train_wait(edict_t *self)
{
- if (self->target_ent->pathtarget)
- {
+ if (self->target_ent->pathtarget) {
char *savetarget;
edict_t *ent;
ent = self->target_ent;
savetarget = ent->target;
ent->target = ent->pathtarget;
- G_UseTargets (ent, self->activator);
+ G_UseTargets(ent, self->activator);
ent->target = savetarget;
// make sure we didn't get killed by a killtarget
@@ -1497,36 +1425,29 @@ void train_wait (edict_t *self)
return;
}
- if (self->moveinfo.wait)
- {
- if (self->moveinfo.wait > 0)
- {
+ if (self->moveinfo.wait) {
+ if (self->moveinfo.wait > 0) {
self->nextthink = level.time + self->moveinfo.wait;
self->think = train_next;
- }
- else if (self->spawnflags & TRAIN_TOGGLE) // && wait < 0
- {
- train_next (self);
+ } else if (self->spawnflags & TRAIN_TOGGLE) { // && wait < 0
+ train_next(self);
self->spawnflags &= ~TRAIN_START_ON;
- VectorClear (self->velocity);
+ VectorClear(self->velocity);
self->nextthink = 0;
}
- if (!(self->flags & FL_TEAMSLAVE))
- {
+ if (!(self->flags & FL_TEAMSLAVE)) {
if (self->moveinfo.sound_end)
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_end, 1, ATTN_STATIC, 0);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_end, 1, ATTN_STATIC, 0);
self->s.sound = 0;
}
+ } else {
+ train_next(self);
}
- else
- {
- train_next (self);
- }
-
+
}
-void train_next (edict_t *self)
+void train_next(edict_t *self)
{
edict_t *ent;
vec3_t dest;
@@ -1534,116 +1455,105 @@ void train_next (edict_t *self)
first = qtrue;
again:
- if (!self->target)
- {
+ if (!self->target) {
// gi.dprintf ("train_next: no next target\n");
return;
}
- ent = G_PickTarget (self->target);
- if (!ent)
- {
- gi.dprintf ("train_next: bad target %s\n", self->target);
+ ent = G_PickTarget(self->target);
+ if (!ent) {
+ gi.dprintf("train_next: bad target %s\n", self->target);
return;
}
self->target = ent->target;
// check for a teleport path_corner
- if (ent->spawnflags & 1)
- {
- if (!first)
- {
- gi.dprintf ("connected teleport path_corners, see %s at %s\n", ent->classname, vtos(ent->s.origin));
+ if (ent->spawnflags & 1) {
+ if (!first) {
+ gi.dprintf("connected teleport path_corners, see %s at %s\n", ent->classname, vtos(ent->s.origin));
return;
}
first = qfalse;
- VectorSubtract (ent->s.origin, self->mins, self->s.origin);
- VectorCopy (self->s.origin, self->s.old_origin);
+ VectorSubtract(ent->s.origin, self->mins, self->s.origin);
+ VectorCopy(self->s.origin, self->s.old_origin);
self->s.event = EV_OTHER_TELEPORT;
- gi.linkentity (self);
+ gi.linkentity(self);
goto again;
}
self->moveinfo.wait = ent->wait;
self->target_ent = ent;
- if (!(self->flags & FL_TEAMSLAVE))
- {
+ if (!(self->flags & FL_TEAMSLAVE)) {
if (self->moveinfo.sound_start)
- gi.sound (self, CHAN_NO_PHS_ADD+CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
+ gi.sound(self, CHAN_NO_PHS_ADD + CHAN_VOICE, self->moveinfo.sound_start, 1, ATTN_STATIC, 0);
self->s.sound = self->moveinfo.sound_middle;
}
- VectorSubtract (ent->s.origin, self->mins, dest);
+ VectorSubtract(ent->s.origin, self->mins, dest);
self->moveinfo.state = STATE_TOP;
- VectorCopy (self->s.origin, self->moveinfo.start_origin);
- VectorCopy (dest, self->moveinfo.end_origin);
- Move_Calc (self, dest, train_wait);
+ VectorCopy(self->s.origin, self->moveinfo.start_origin);
+ VectorCopy(dest, self->moveinfo.end_origin);
+ Move_Calc(self, dest, train_wait);
self->spawnflags |= TRAIN_START_ON;
}
-void train_resume (edict_t *self)
+void train_resume(edict_t *self)
{
edict_t *ent;
vec3_t dest;
ent = self->target_ent;
- VectorSubtract (ent->s.origin, self->mins, dest);
+ VectorSubtract(ent->s.origin, self->mins, dest);
self->moveinfo.state = STATE_TOP;
- VectorCopy (self->s.origin, self->moveinfo.start_origin);
- VectorCopy (dest, self->moveinfo.end_origin);
- Move_Calc (self, dest, train_wait);
+ VectorCopy(self->s.origin, self->moveinfo.start_origin);
+ VectorCopy(dest, self->moveinfo.end_origin);
+ Move_Calc(self, dest, train_wait);
self->spawnflags |= TRAIN_START_ON;
}
-void func_train_find (edict_t *self)
+void func_train_find(edict_t *self)
{
edict_t *ent;
- if (!self->target)
- {
- gi.dprintf ("train_find: no target\n");
+ if (!self->target) {
+ gi.dprintf("train_find: no target\n");
return;
}
- ent = G_PickTarget (self->target);
- if (!ent)
- {
- gi.dprintf ("train_find: target %s not found\n", self->target);
+ ent = G_PickTarget(self->target);
+ if (!ent) {
+ gi.dprintf("train_find: target %s not found\n", self->target);
return;
}
self->target = ent->target;
- VectorSubtract (ent->s.origin, self->mins, self->s.origin);
- gi.linkentity (self);
+ VectorSubtract(ent->s.origin, self->mins, self->s.origin);
+ gi.linkentity(self);
// if not triggered, start immediately
if (!self->targetname)
self->spawnflags |= TRAIN_START_ON;
- if (self->spawnflags & TRAIN_START_ON)
- {
+ if (self->spawnflags & TRAIN_START_ON) {
self->nextthink = level.time + FRAMETIME;
self->think = train_next;
self->activator = self;
}
}
-void train_use (edict_t *self, edict_t *other, edict_t *activator)
+void train_use(edict_t *self, edict_t *other, edict_t *activator)
{
self->activator = activator;
- if (self->spawnflags & TRAIN_START_ON)
- {
+ if (self->spawnflags & TRAIN_START_ON) {
if (!(self->spawnflags & TRAIN_TOGGLE))
return;
self->spawnflags &= ~TRAIN_START_ON;
- VectorClear (self->velocity);
+ VectorClear(self->velocity);
self->nextthink = 0;
- }
- else
- {
+ } else {
if (self->target_ent)
train_resume(self);
else
@@ -1651,24 +1561,23 @@ void train_use (edict_t *self, edict_t *other, edict_t *activator)
}
}
-void SP_func_train (edict_t *self)
+void SP_func_train(edict_t *self)
{
self->movetype = MOVETYPE_PUSH;
- VectorClear (self->s.angles);
+ VectorClear(self->s.angles);
self->blocked = train_blocked;
if (self->spawnflags & TRAIN_BLOCK_STOPS)
self->dmg = 0;
- else
- {
+ else {
if (!self->dmg)
self->dmg = 100;
}
self->solid = SOLID_BSP;
- gi.setmodel (self, self->model);
+ gi.setmodel(self, self->model);
if (st.noise)
- self->moveinfo.sound_middle = gi.soundindex (st.noise);
+ self->moveinfo.sound_middle = gi.soundindex(st.noise);
if (!self->speed)
self->speed = 100;
@@ -1678,66 +1587,57 @@ void SP_func_train (edict_t *self)
self->use = train_use;
- gi.linkentity (self);
+ gi.linkentity(self);
- if (self->target)
- {
+ if (self->target) {
// start trains on the second frame, to make sure their targets have had
// a chance to spawn
self->nextthink = level.time + FRAMETIME;
self->think = func_train_find;
- }
- else
- {
- gi.dprintf ("func_train without a target at %s\n", vtos(self->absmin));
+ } else {
+ gi.dprintf("func_train without a target at %s\n", vtos(self->absmin));
}
}
/*QUAKED trigger_elevator (0.3 0.1 0.6) (-8 -8 -8) (8 8 8)
*/
-void trigger_elevator_use (edict_t *self, edict_t *other, edict_t *activator)
+void trigger_elevator_use(edict_t *self, edict_t *other, edict_t *activator)
{
edict_t *target;
- if (self->movetarget->nextthink)
- {
+ if (self->movetarget->nextthink) {
// gi.dprintf("elevator busy\n");
return;
}
- if (!other->pathtarget)
- {
+ if (!other->pathtarget) {
gi.dprintf("elevator used with no pathtarget\n");
return;
}
- target = G_PickTarget (other->pathtarget);
- if (!target)
- {
+ target = G_PickTarget(other->pathtarget);
+ if (!target) {
gi.dprintf("elevator used with bad pathtarget: %s\n", other->pathtarget);
return;
}
self->movetarget->target_ent = target;
- train_resume (self->movetarget);
+ train_resume(self->movetarget);
}
-void trigger_elevator_init (edict_t *self)
+void trigger_elevator_init(edict_t *self)
{
- if (!self->target)
- {
+ if (!self->target) {
gi.dprintf("trigger_elevator has no target\n");
return;
}
- self->movetarget = G_PickTarget (self->target);
- if (!self->movetarget)
- {
+ self->movetarget = G_PickTarget(self->target);
+ if (!self->movetarget) {
gi.dprintf("trigger_elevator unable to find target %s\n", self->target);
return;
}
- if (strcmp(self->movetarget->classname, "func_train") != 0)
- {
+ if (strcmp(self->movetarget->classname, "func_train") != 0) {
gi.dprintf("trigger_elevator target %s is not a train\n", self->target);
return;
}
@@ -1747,7 +1647,7 @@ void trigger_elevator_init (edict_t *self)
}
-void SP_trigger_elevator (edict_t *self)
+void SP_trigger_elevator(edict_t *self)
{
self->think = trigger_elevator_init;
self->nextthink = level.time + FRAMETIME;
@@ -1768,19 +1668,18 @@ so, the basic time between firing is a random time between
These can used but not touched.
*/
-void func_timer_think (edict_t *self)
+void func_timer_think(edict_t *self)
{
- G_UseTargets (self, self->activator);
+ G_UseTargets(self, self->activator);
self->nextthink = level.time + self->wait + crandom() * self->random;
}
-void func_timer_use (edict_t *self, edict_t *other, edict_t *activator)
+void func_timer_use(edict_t *self, edict_t *other, edict_t *activator)
{
self->activator = activator;
// if on, turn it off
- if (self->nextthink)
- {
+ if (self->nextthink) {
self->nextthink = 0;
return;
}
@@ -1789,10 +1688,10 @@ void func_timer_use (edict_t *self, edict_t *other, edict_t *activator)
if (self->delay)
self->nextthink = level.time + self->delay;
else
- func_timer_think (self);
+ func_timer_think(self);
}
-void SP_func_timer (edict_t *self)
+void SP_func_timer(edict_t *self)
{
if (!self->wait)
self->wait = 1.0;
@@ -1800,14 +1699,12 @@ void SP_func_timer (edict_t *self)
self->use = func_timer_use;
self->think = func_timer_think;
- if (self->random >= self->wait)
- {
+ if (self->random >= self->wait) {
self->random = self->wait - FRAMETIME;
gi.dprintf("func_timer at %s has random >= wait\n", vtos(self->s.origin));
}
- if (self->spawnflags & 1)
- {
+ if (self->spawnflags & 1) {
self->nextthink = level.time + 1.0 + st.pausetime + self->delay + self->wait + crandom() * self->random;
self->activator = self;
}
@@ -1822,15 +1719,12 @@ The brush should be have a surface with at least one current content enabled.
speed default 100
*/
-void func_conveyor_use (edict_t *self, edict_t *other, edict_t *activator)
+void func_conveyor_use(edict_t *self, edict_t *other, edict_t *activator)
{
- if (self->spawnflags & 1)
- {
+ if (self->spawnflags & 1) {
self->speed = 0;
self->spawnflags &= ~1;
- }
- else
- {
+ } else {
self->speed = self->count;
self->spawnflags |= 1;
}
@@ -1839,22 +1733,21 @@ void func_conveyor_use (edict_t *self, edict_t *other, edict_t *activator)
self->count = 0;
}
-void SP_func_conveyor (edict_t *self)
+void SP_func_conveyor(edict_t *self)
{
if (!self->speed)
self->speed = 100;
- if (!(self->spawnflags & 1))
- {
+ if (!(self->spawnflags & 1)) {
self->count = self->speed;
self->speed = 0;
}
self->use = func_conveyor_use;
- gi.setmodel (self, self->model);
+ gi.setmodel(self, self->model);
self->solid = SOLID_BSP;
- gi.linkentity (self);
+ gi.linkentity(self);
}
@@ -1875,36 +1768,36 @@ always_shoot door is shootebale even if targeted
#define SECRET_1ST_LEFT 2
#define SECRET_1ST_DOWN 4
-void door_secret_move1 (edict_t *self);
-void door_secret_move2 (edict_t *self);
-void door_secret_move3 (edict_t *self);
-void door_secret_move4 (edict_t *self);
-void door_secret_move5 (edict_t *self);
-void door_secret_move6 (edict_t *self);
-void door_secret_done (edict_t *self);
+void door_secret_move1(edict_t *self);
+void door_secret_move2(edict_t *self);
+void door_secret_move3(edict_t *self);
+void door_secret_move4(edict_t *self);
+void door_secret_move5(edict_t *self);
+void door_secret_move6(edict_t *self);
+void door_secret_done(edict_t *self);
-void door_secret_use (edict_t *self, edict_t *other, edict_t *activator)
+void door_secret_use(edict_t *self, edict_t *other, edict_t *activator)
{
// make sure we're not already moving
if (!VectorCompare(self->s.origin, vec3_origin))
return;
- Move_Calc (self, self->pos1, door_secret_move1);
- door_use_areaportals (self, qtrue);
+ Move_Calc(self, self->pos1, door_secret_move1);
+ door_use_areaportals(self, qtrue);
}
-void door_secret_move1 (edict_t *self)
+void door_secret_move1(edict_t *self)
{
self->nextthink = level.time + 1.0;
self->think = door_secret_move2;
}
-void door_secret_move2 (edict_t *self)
+void door_secret_move2(edict_t *self)
{
- Move_Calc (self, self->pos2, door_secret_move3);
+ Move_Calc(self, self->pos2, door_secret_move3);
}
-void door_secret_move3 (edict_t *self)
+void door_secret_move3(edict_t *self)
{
if (self->wait == -1)
return;
@@ -1912,41 +1805,39 @@ void door_secret_move3 (edict_t *self)
self->think = door_secret_move4;
}
-void door_secret_move4 (edict_t *self)
+void door_secret_move4(edict_t *self)
{
- Move_Calc (self, self->pos1, door_secret_move5);
+ Move_Calc(self, self->pos1, door_secret_move5);
}
-void door_secret_move5 (edict_t *self)
+void door_secret_move5(edict_t *self)
{
self->nextthink = level.time + 1.0;
self->think = door_secret_move6;
}
-void door_secret_move6 (edict_t *self)
+void door_secret_move6(edict_t *self)
{
- Move_Calc (self, vec3_origin, door_secret_done);
+ Move_Calc(self, vec3_origin, door_secret_done);
}
-void door_secret_done (edict_t *self)
+void door_secret_done(edict_t *self)
{
- if (!(self->targetname) || (self->spawnflags & SECRET_ALWAYS_SHOOT))
- {
+ if (!(self->targetname) || (self->spawnflags & SECRET_ALWAYS_SHOOT)) {
self->health = 0;
self->takedamage = DAMAGE_YES;
}
- door_use_areaportals (self, qfalse);
+ door_use_areaportals(self, qfalse);
}
-void door_secret_blocked (edict_t *self, edict_t *other)
+void door_secret_blocked(edict_t *self, edict_t *other)
{
- if (!(other->svflags & SVF_MONSTER) && (!other->client) )
- {
+ if (!(other->svflags & SVF_MONSTER) && (!other->client)) {
// give it a chance to go away on it's own terms (like gibs)
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, 100000, 1, 0, MOD_CRUSH);
// if it's still there, nuke it
if (other)
- BecomeExplosion1 (other);
+ BecomeExplosion1(other);
return;
}
@@ -1954,35 +1845,34 @@ void door_secret_blocked (edict_t *self, edict_t *other)
return;
self->touch_debounce_time = level.time + 0.5;
- T_Damage (other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
+ T_Damage(other, self, self, vec3_origin, other->s.origin, vec3_origin, self->dmg, 1, 0, MOD_CRUSH);
}
-void door_secret_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
+void door_secret_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
{
self->takedamage = DAMAGE_NO;
- door_secret_use (self, attacker, attacker);
+ door_secret_use(self, attacker, attacker);
}
-void SP_func_door_secret (edict_t *ent)
+void SP_func_door_secret(edict_t *ent)
{
vec3_t forward, right, up;
float side;
float width;
float length;
- ent->moveinfo.sound_start = gi.soundindex ("doors/dr1_strt.wav");
- ent->moveinfo.sound_middle = gi.soundindex ("doors/dr1_mid.wav");
- ent->moveinfo.sound_end = gi.soundindex ("doors/dr1_end.wav");
+ ent->moveinfo.sound_start = gi.soundindex("doors/dr1_strt.wav");
+ ent->moveinfo.sound_middle = gi.soundindex("doors/dr1_mid.wav");
+ ent->moveinfo.sound_end = gi.soundindex("doors/dr1_end.wav");
ent->movetype = MOVETYPE_PUSH;
ent->solid = SOLID_BSP;
- gi.setmodel (ent, ent->model);
+ gi.setmodel(ent, ent->model);
ent->blocked = door_secret_blocked;
ent->use = door_secret_use;
- if (!(ent->targetname) || (ent->spawnflags & SECRET_ALWAYS_SHOOT))
- {
+ if (!(ent->targetname) || (ent->spawnflags & SECRET_ALWAYS_SHOOT)) {
ent->health = 0;
ent->takedamage = DAMAGE_YES;
ent->die = door_secret_die;
@@ -1995,12 +1885,12 @@ void SP_func_door_secret (edict_t *ent)
ent->wait = 5;
ent->moveinfo.accel =
- ent->moveinfo.decel =
- ent->moveinfo.speed = 50;
+ ent->moveinfo.decel =
+ ent->moveinfo.speed = 50;
// calculate positions
- AngleVectors (ent->s.angles, forward, right, up);
- VectorClear (ent->s.angles);
+ AngleVectors(ent->s.angles, forward, right, up);
+ VectorClear(ent->s.angles);
side = 1.0 - (ent->spawnflags & SECRET_1ST_LEFT);
if (ent->spawnflags & SECRET_1ST_DOWN)
width = fabs(DotProduct(up, ent->size));
@@ -2008,40 +1898,37 @@ void SP_func_door_secret (edict_t *ent)
width = fabs(DotProduct(right, ent->size));
length = fabs(DotProduct(forward, ent->size));
if (ent->spawnflags & SECRET_1ST_DOWN)
- VectorMA (ent->s.origin, -1 * width, up, ent->pos1);
+ VectorMA(ent->s.origin, -1 * width, up, ent->pos1);
else
- VectorMA (ent->s.origin, side * width, right, ent->pos1);
- VectorMA (ent->pos1, length, forward, ent->pos2);
+ VectorMA(ent->s.origin, side * width, right, ent->pos1);
+ VectorMA(ent->pos1, length, forward, ent->pos2);
- if (ent->health)
- {
+ if (ent->health) {
ent->takedamage = DAMAGE_YES;
ent->die = door_killed;
ent->max_health = ent->health;
- }
- else if (ent->targetname && ent->message)
- {
- gi.soundindex ("misc/talk.wav");
+ } else if (ent->targetname && ent->message) {
+ gi.soundindex("misc/talk.wav");
ent->touch = door_touch;
}
-
+
ent->classname = "func_door";
- gi.linkentity (ent);
+ gi.linkentity(ent);
}
/*QUAKED func_killbox (1 0 0) ?
Kills everything inside when fired, irrespective of protection.
*/
-void use_killbox (edict_t *self, edict_t *other, edict_t *activator)
+void use_killbox(edict_t *self, edict_t *other, edict_t *activator)
{
- KillBox (self);
+ KillBox(self);
}
-void SP_func_killbox (edict_t *ent)
+void SP_func_killbox(edict_t *ent)
{
- gi.setmodel (ent, ent->model);
+ gi.setmodel(ent, ent->model);
ent->use = use_killbox;
ent->svflags = SVF_NOCLIENT;
}