Go to the documentation of this file.
56 #define PLAT_LOW_TRIGGER 1
59 #define STATE_BOTTOM 1
63 #define DOOR_START_OPEN 1
64 #define DOOR_REVERSE 2
65 #define DOOR_CRUSHER 4
66 #define DOOR_NOMONSTER 8
67 #define DOOR_TOGGLE 32
68 #define DOOR_X_AXIS 64
69 #define DOOR_Y_AXIS 128
233 #define AccelerationDistance(target, rate) (target * ((target / rate) + 1) / 2)
292 distance = p1_distance + p2_distance;
322 p1_speed = (old_speed + moveinfo->
move_speed) / 2.0;
323 p2_distance = moveinfo->
move_speed * (1.0 - (p1_distance / p1_speed));
324 distance = p1_distance + p2_distance;
325 moveinfo->
current_speed = (p1_speed * (p1_distance / distance)) + (moveinfo->
move_speed * (p2_distance / distance));
421 if (self->moveinfo.state ==
STATE_UP)
463 trigger->
enemy = ent;
465 tmin[0] = ent->
mins[0] + 25;
466 tmin[1] = ent->
mins[1] + 25;
467 tmin[2] = ent->
mins[2];
469 tmax[0] = ent->
maxs[0] - 25;
470 tmax[1] = ent->
maxs[1] - 25;
471 tmax[2] = ent->
maxs[2] + 8;
476 tmax[2] = tmin[2] + 8;
478 if (tmax[0] - tmin[0] <= 0)
480 tmin[0] = (ent->
mins[0] + ent->
maxs[0]) *0.5;
481 tmax[0] = tmin[0] + 1;
483 if (tmax[1] - tmin[1] <= 0)
485 tmin[1] = (ent->
mins[1] + ent->
maxs[1]) *0.5;
486 tmax[1] = tmin[1] + 1;
602 if (self->avelocity[0] || self->avelocity[1] || self->avelocity[2])
616 self->s.sound =
self->moveinfo.sound_middle;
617 VectorScale (self->movedir, self->speed, self->avelocity);
618 if (self->spawnflags & 16)
719 if (self->moveinfo.wait >= 0)
721 self->nextthink =
level.time +
self->moveinfo.wait;
732 if (self->moveinfo.sound_start && !(self->flags &
FL_TEAMSLAVE))
739 self->activator = activator;
751 self->activator = other;
757 self->activator = attacker;
758 self->
health =
self->max_health;
789 abs_movedir[0] = fabs(ent->
movedir[0]);
790 abs_movedir[1] = fabs(ent->
movedir[1]);
791 abs_movedir[2] = fabs(ent->
movedir[2]);
792 dist = abs_movedir[0] * ent->
size[0] + abs_movedir[1] * ent->
size[1] + abs_movedir[2] * ent->
size[2] -
st.
lip;
859 while ((
t =
G_Find (
t,
FOFS(targetname), self->target)))
861 if (
Q_stricmp(
t->classname,
"func_areaportal") == 0)
874 if (self->moveinfo.sound_end)
881 if (self->moveinfo.wait >= 0)
884 self->nextthink =
level.time +
self->moveinfo.wait;
892 if (self->moveinfo.sound_end)
904 if (self->moveinfo.sound_start)
906 self->s.sound =
self->moveinfo.sound_middle;
908 if (self->max_health)
911 self->health =
self->max_health;
915 if (strcmp(self->classname,
"func_door") == 0)
917 else if (strcmp(self->classname,
"func_door_rotating") == 0)
923 if (self->moveinfo.state ==
STATE_UP)
928 if (self->moveinfo.wait >= 0)
929 self->nextthink =
level.time +
self->moveinfo.wait;
935 if (self->moveinfo.sound_start)
937 self->s.sound =
self->moveinfo.sound_middle;
940 if (strcmp(self->classname,
"func_door") == 0)
942 else if (strcmp(self->classname,
"func_door_rotating") == 0)
961 for (ent =
self ; ent ; ent = ent->
teamchain)
972 for (ent =
self ; ent ; ent = ent->
teamchain)
991 if (
level.time < self->touch_debounce_time)
993 self->touch_debounce_time =
level.time + 1.0;
995 door_use (self->owner, other, other);
1011 min = fabs(self->moveinfo.distance);
1019 time =
min /
self->moveinfo.speed;
1022 for (ent =
self; ent; ent = ent->
teamchain)
1098 if (self->moveinfo.wait >= 0)
1122 door_use (self->teammaster, attacker, attacker);
1130 if (
level.time < self->touch_debounce_time)
1132 self->touch_debounce_time =
level.time + 5.0;
1176 abs_movedir[0] = fabs(ent->
movedir[0]);
1177 abs_movedir[1] = fabs(ent->
movedir[1]);
1178 abs_movedir[2] = fabs(ent->
movedir[2]);
1387 switch (self->sounds)
1393 self->moveinfo.sound_start =
gi.
soundindex (
"world/mov_watr.wav");
1394 self->moveinfo.sound_end =
gi.
soundindex (
"world/stp_watr.wav");
1398 self->moveinfo.sound_start =
gi.
soundindex (
"world/mov_watr.wav");
1399 self->moveinfo.sound_end =
gi.
soundindex (
"world/stp_watr.wav");
1405 abs_movedir[0] = fabs(self->movedir[0]);
1406 abs_movedir[1] = fabs(self->movedir[1]);
1407 abs_movedir[2] = fabs(self->movedir[2]);
1408 self->moveinfo.distance = abs_movedir[0] *
self->size[0] + abs_movedir[1] *
self->size[1] + abs_movedir[2] *
self->size[2] -
st.
lip;
1409 VectorMA (self->pos1, self->moveinfo.distance, self->movedir, self->pos2);
1419 VectorCopy (self->pos1, self->moveinfo.start_origin);
1420 VectorCopy (self->s.angles, self->moveinfo.start_angles);
1421 VectorCopy (self->pos2, self->moveinfo.end_origin);
1422 VectorCopy (self->s.angles, self->moveinfo.end_angles);
1428 self->moveinfo.accel =
self->moveinfo.decel =
self->moveinfo.speed =
self->speed;
1432 self->moveinfo.wait =
self->wait;
1436 if (self->wait == -1)
1439 self->classname =
"func_door";
1445 #define TRAIN_START_ON 1
1446 #define TRAIN_TOGGLE 2
1447 #define TRAIN_BLOCK_STOPS 4
1473 if (
level.time < self->touch_debounce_time)
1478 self->touch_debounce_time =
level.time + 0.5;
1484 if (self->target_ent->pathtarget)
1490 savetarget = ent->
target;
1493 ent->
target = savetarget;
1500 if (self->moveinfo.wait)
1502 if (self->moveinfo.wait > 0)
1504 self->nextthink =
level.time +
self->moveinfo.wait;
1512 self->nextthink = 0;
1517 if (self->moveinfo.sound_end)
1546 gi.
dprintf (
"train_next: bad target %s\n", self->target);
1550 self->target = ent->
target;
1562 VectorCopy (self->s.origin, self->s.old_origin);
1568 self->moveinfo.wait = ent->
wait;
1569 self->target_ent = ent;
1573 if (self->moveinfo.sound_start)
1575 self->s.sound =
self->moveinfo.sound_middle;
1580 VectorCopy (self->s.origin, self->moveinfo.start_origin);
1581 VectorCopy (dest, self->moveinfo.end_origin);
1595 VectorCopy (self->s.origin, self->moveinfo.start_origin);
1596 VectorCopy (dest, self->moveinfo.end_origin);
1613 gi.
dprintf (
"train_find: target %s not found\n", self->target);
1616 self->target = ent->
target;
1622 if (!self->targetname)
1629 self->activator =
self;
1635 self->activator = activator;
1643 self->nextthink = 0;
1647 if (self->target_ent)
1676 self->moveinfo.speed =
self->speed;
1677 self->moveinfo.accel =
self->moveinfo.decel =
self->moveinfo.speed;
1692 gi.
dprintf (
"func_train without a target at %s\n",
vtos(self->absmin));
1703 if (self->movetarget->nextthink)
1711 gi.
dprintf(
"elevator used with no pathtarget\n");
1722 self->movetarget->target_ent = target;
1730 gi.
dprintf(
"trigger_elevator has no target\n");
1734 if (!self->movetarget)
1736 gi.
dprintf(
"trigger_elevator unable to find target %s\n", self->target);
1739 if (strcmp(self->movetarget->classname,
"func_train") != 0)
1741 gi.
dprintf(
"trigger_elevator target %s is not a train\n", self->target);
1774 self->nextthink =
level.time +
self->wait +
crandom() *
self->random;
1779 self->activator = activator;
1782 if (self->nextthink)
1790 self->nextthink =
level.time +
self->delay;
1803 if (self->random >= self->wait)
1806 gi.
dprintf(
"func_timer at %s has random >= wait\n",
vtos(self->s.origin));
1809 if (self->spawnflags & 1)
1812 self->activator =
self;
1827 if (self->spawnflags & 1)
1830 self->spawnflags &= ~1;
1834 self->speed =
self->count;
1835 self->spawnflags |= 1;
1838 if (!(self->spawnflags & 2))
1847 if (!(self->spawnflags & 1))
1849 self->count =
self->speed;
1874 #define SECRET_ALWAYS_SHOOT 1
1875 #define SECRET_1ST_LEFT 2
1876 #define SECRET_1ST_DOWN 4
1898 self->nextthink =
level.time + 1.0;
1909 if (self->wait == -1)
1911 self->nextthink =
level.time +
self->wait;
1922 self->nextthink =
level.time + 1.0;
1953 if (
level.time < self->touch_debounce_time)
1955 self->touch_debounce_time =
level.time + 0.5;
void train_use(edict_t *self, edict_t *other, edict_t *activator)
void SP_func_train(edict_t *self)
void(* dprintf)(char *fmt,...)
void func_train_find(edict_t *self)
void Think_AccelMove(edict_t *ent)
void button_use(edict_t *self, edict_t *other, edict_t *activator)
void door_go_up(edict_t *self, edict_t *activator)
void door_secret_move3(edict_t *self)
void func_timer_think(edict_t *self)
#define VectorSubtract(a, b, c)
void func_conveyor_use(edict_t *self, edict_t *other, edict_t *activator)
void plat_go_down(edict_t *ent)
void button_killed(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
void Use_Plat(edict_t *ent, edict_t *other, edict_t *activator)
void door_secret_die(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
void SP_func_timer(edict_t *self)
void door_secret_move2(edict_t *self)
void plat_Accelerate(moveinfo_t *moveinfo)
void plat_blocked(edict_t *self, edict_t *other)
void plat_CalcAcceleratedMove(moveinfo_t *moveinfo)
void SP_func_rotating(edict_t *ent)
void rotating_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
void SP_func_door_rotating(edict_t *ent)
edict_t * G_Find(edict_t *from, int fieldofs, char *match)
void BecomeExplosion1(edict_t *self)
void train_blocked(edict_t *self, edict_t *other)
void rotating_use(edict_t *self, edict_t *other, edict_t *activator)
struct gclient_s * client
void(* sound)(edict_t *ent, int channel, int soundindex, float volume, float attenuation, float timeofs)
void Move_Calc(edict_t *ent, vec3_t dest, void(*func)(edict_t *))
void(* blocked)(edict_t *self, edict_t *other)
void door_secret_move6(edict_t *self)
void door_use(edict_t *self, edict_t *other, edict_t *activator)
void SP_func_door_secret(edict_t *ent)
void T_Damage(edict_t *targ, edict_t *inflictor, edict_t *attacker, vec3_t dir, vec3_t point, vec3_t normal, int damage, int knockback, int dflags, int mod)
void button_return(edict_t *self)
void door_secret_move4(edict_t *self)
#define TRAIN_BLOCK_STOPS
void button_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
void train_next(edict_t *self)
void train_wait(edict_t *self)
void button_fire(edict_t *self)
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
void button_done(edict_t *self)
void plat_hit_bottom(edict_t *ent)
void door_secret_done(edict_t *self)
void button_wait(edict_t *self)
void SP_func_water(edict_t *self)
void trigger_elevator_use(edict_t *self, edict_t *other, edict_t *activator)
void AngleMove_Calc(edict_t *ent, void(*func)(edict_t *))
void door_use_areaportals(edict_t *self, qboolean open)
void use_killbox(edict_t *self, edict_t *other, edict_t *activator)
void rotating_blocked(edict_t *self, edict_t *other)
void(* SetAreaPortalState)(int portalnum, qboolean open)
int(* soundindex)(char *name)
vec_t VectorLength(vec3_t v)
void door_go_down(edict_t *self)
void(* think)(edict_t *self)
void door_secret_move5(edict_t *self)
void SP_func_door(edict_t *ent)
vec_t VectorNormalize(vec3_t v)
void Touch_DoorTrigger(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
void AngleMove_Final(edict_t *ent)
void Move_Begin(edict_t *ent)
void door_secret_blocked(edict_t *self, edict_t *other)
void SP_func_button(edict_t *ent)
void Think_SpawnDoorTrigger(edict_t *ent)
void door_blocked(edict_t *self, edict_t *other)
void AngleMove_Begin(edict_t *ent)
int Q_stricmp(char *s1, char *s2)
void(* centerprintf)(edict_t *ent, char *fmt,...)
void door_killed(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
void door_hit_top(edict_t *self)
void SP_trigger_elevator(edict_t *self)
void AddPointToBounds(vec3_t v, vec3_t mins, vec3_t maxs)
void door_secret_use(edict_t *self, edict_t *other, edict_t *activator)
void(* setmodel)(edict_t *ent, char *name)
void plat_go_up(edict_t *ent)
void(* endfunc)(edict_t *)
#define SECRET_ALWAYS_SHOOT
void(* use)(edict_t *self, edict_t *other, edict_t *activator)
#define AccelerationDistance(target, rate)
void Move_Final(edict_t *ent)
void SP_func_conveyor(edict_t *self)
void Think_CalcMoveSpeed(edict_t *self)
void G_UseTargets(edict_t *ent, edict_t *activator)
void SP_func_killbox(edict_t *ent)
void VectorMA(vec3_t veca, float scale, vec3_t vecb, vec3_t vecc)
void door_touch(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
void G_SetMovedir(vec3_t angles, vec3_t movedir)
qboolean KillBox(edict_t *ent)
void(* touch)(edict_t *self, edict_t *other, cplane_t *plane, csurface_t *surf)
void AngleMove_Done(edict_t *ent)
void func_timer_use(edict_t *self, edict_t *other, edict_t *activator)
void SP_func_plat(edict_t *ent)
int VectorCompare(vec3_t v1, vec3_t v2)
void plat_spawn_inside_trigger(edict_t *ent)
void Touch_Plat_Center(edict_t *ent, edict_t *other, cplane_t *plane, csurface_t *surf)
void train_resume(edict_t *self)
edict_t * G_PickTarget(char *targetname)
void(* linkentity)(edict_t *ent)
void(* die)(edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
void door_secret_move1(edict_t *self)
void door_hit_bottom(edict_t *self)
#define VectorNegate(a, b)
void trigger_elevator_init(edict_t *self)
void Move_Done(edict_t *ent)
void plat_hit_top(edict_t *ent)