summaryrefslogtreecommitdiff
path: root/src/game/g_misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_misc.c')
-rw-r--r--src/game/g_misc.c121
1 files changed, 71 insertions, 50 deletions
diff --git a/src/game/g_misc.c b/src/game/g_misc.c
index 3562a142..eac7f2f0 100644
--- a/src/game/g_misc.c
+++ b/src/game/g_misc.c
@@ -26,7 +26,8 @@ Used to group brushes together just for editor convenience. They are turned int
/*QUAKED info_camp (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for calculations in the utilities (spotlights, etc), but removed during gameplay.
*/
-void SP_info_camp( gentity_t *self ) {
+void SP_info_camp( gentity_t *self )
+{
G_SetOrigin( self, self->s.origin );
}
@@ -34,7 +35,8 @@ void SP_info_camp( gentity_t *self ) {
/*QUAKED info_null (0 0.5 0) (-4 -4 -4) (4 4 4)
Used as a positional target for calculations in the utilities (spotlights, etc), but removed during gameplay.
*/
-void SP_info_null( gentity_t *self ) {
+void SP_info_null( gentity_t *self )
+{
G_FreeEntity( self );
}
@@ -43,7 +45,8 @@ void SP_info_null( gentity_t *self ) {
Used as a positional target for in-game calculation, like jumppad targets.
target_position does the same thing
*/
-void SP_info_notnull( gentity_t *self ){
+void SP_info_notnull( gentity_t *self )
+{
G_SetOrigin( self, self->s.origin );
}
@@ -55,7 +58,8 @@ Linear checbox gives linear falloff instead of inverse square
Lights pointed at a target will be spotlights.
"radius" overrides the default 64 unit radius of a spotlight at the target point.
*/
-void SP_light( gentity_t *self ) {
+void SP_light( gentity_t *self )
+{
G_FreeEntity( self );
}
@@ -69,12 +73,14 @@ TELEPORTERS
=================================================================================
*/
-void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
+void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles )
+{
gentity_t *tent;
// use temp events at source and destination to prevent the effect
// from getting dropped by a second player event
- if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( player->client->sess.sessionTeam != TEAM_SPECTATOR )
+ {
tent = G_TempEntity( player->client->ps.origin, EV_PLAYER_TELEPORT_OUT );
tent->s.clientNum = player->s.clientNum;
@@ -83,10 +89,10 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
}
// unlink to make sure it can't possibly interfere with G_KillBox
- trap_UnlinkEntity (player);
+ trap_UnlinkEntity( player );
- VectorCopy ( origin, player->client->ps.origin );
- player->client->ps.origin[2] += 1;
+ VectorCopy( origin, player->client->ps.origin );
+ player->client->ps.origin[ 2 ] += 1;
// spit the player out
AngleVectors( angles, player->client->ps.velocity, NULL, NULL );
@@ -101,9 +107,8 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
SetClientViewAngle( player, angles );
// kill anything at the destination
- if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
- G_KillBox (player);
- }
+ if( player->client->sess.sessionTeam != TEAM_SPECTATOR )
+ G_KillBox( player );
// save results of pmove
BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
@@ -111,9 +116,8 @@ void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) {
// use the precise origin for linking
VectorCopy( player->client->ps.origin, player->r.currentOrigin );
- if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
+ if( player->client->sess.sessionTeam != TEAM_SPECTATOR )
trap_LinkEntity (player);
- }
}
@@ -122,7 +126,8 @@ Point teleporters at these.
Now that we don't have teleport destination pads, this is just
an info_notnull
*/
-void SP_misc_teleporter_dest( gentity_t *ent ) {
+void SP_misc_teleporter_dest( gentity_t *ent )
+{
}
@@ -131,8 +136,8 @@ void SP_misc_teleporter_dest( gentity_t *ent ) {
/*QUAKED misc_model (1 0 0) (-16 -16 -16) (16 16 16)
"model" arbitrary .md3 file to display
*/
-void SP_misc_model( gentity_t *ent ) {
-
+void SP_misc_model( gentity_t *ent )
+{
#if 0
ent->s.modelindex = G_ModelIndex( ent->model );
VectorSet (ent->mins, -16, -16, -16);
@@ -148,13 +153,15 @@ void SP_misc_model( gentity_t *ent ) {
//===========================================================
-void locateCamera( gentity_t *ent ) {
+void locateCamera( gentity_t *ent )
+{
vec3_t dir;
gentity_t *target;
gentity_t *owner;
owner = G_PickTarget( ent->target );
- if ( !owner ) {
+ if( !owner )
+ {
G_Printf( "Couldn't find target for misc_partal_surface\n" );
G_FreeEntity( ent );
return;
@@ -162,20 +169,19 @@ void locateCamera( gentity_t *ent ) {
ent->r.ownerNum = owner->s.number;
// frame holds the rotate speed
- if ( owner->spawnflags & 1 ) {
+ if( owner->spawnflags & 1 )
ent->s.frame = 25;
- } else if ( owner->spawnflags & 2 ) {
+ else if( owner->spawnflags & 2 )
ent->s.frame = 75;
- }
// swing camera ?
- if ( owner->spawnflags & 4 ) {
+ if( owner->spawnflags & 4 )
+ {
// set to 0 for no rotation at all
ent->s.powerups = 0;
}
- else {
+ else
ent->s.powerups = 1;
- }
// clientNum holds the rotate offset
ent->s.clientNum = owner->s.clientNum;
@@ -184,12 +190,13 @@ void locateCamera( gentity_t *ent ) {
// see if the portal_camera has a target
target = G_PickTarget( owner->target );
- if ( target ) {
+ if( target )
+ {
VectorSubtract( target->s.origin, owner->s.origin, dir );
VectorNormalize( dir );
- } else {
- G_SetMovedir( owner->s.angles, dir );
}
+ else
+ G_SetMovedir( owner->s.angles, dir );
ent->s.eventParm = DirToByte( dir );
}
@@ -198,17 +205,21 @@ void locateCamera( gentity_t *ent ) {
The portal surface nearest this entity will show a view from the targeted misc_portal_camera, or a mirror view if untargeted.
This must be within 64 world units of the surface!
*/
-void SP_misc_portal_surface(gentity_t *ent) {
+void SP_misc_portal_surface( gentity_t *ent )
+{
VectorClear( ent->r.mins );
VectorClear( ent->r.maxs );
- trap_LinkEntity (ent);
+ trap_LinkEntity( ent );
ent->r.svFlags = SVF_PORTAL;
ent->s.eType = ET_PORTAL;
- if ( !ent->target ) {
+ if( !ent->target )
+ {
VectorCopy( ent->s.origin, ent->s.origin2 );
- } else {
+ }
+ else
+ {
ent->think = locateCamera;
ent->nextthink = level.time + 100;
}
@@ -219,16 +230,17 @@ void SP_misc_portal_surface(gentity_t *ent) {
The target for a misc_portal_director. You can set either angles or target another entity to determine the direction of view.
"roll" an angle modifier to orient the camera around the target vector;
*/
-void SP_misc_portal_camera(gentity_t *ent) {
+void SP_misc_portal_camera( gentity_t *ent )
+{
float roll;
VectorClear( ent->r.mins );
VectorClear( ent->r.maxs );
- trap_LinkEntity (ent);
+ trap_LinkEntity( ent );
G_SpawnFloat( "roll", "0", &roll );
- ent->s.clientNum = roll/360.0 * 256;
+ ent->s.clientNum = roll / 360.0f * 256;
}
/*
@@ -239,27 +251,29 @@ void SP_misc_portal_camera(gentity_t *ent) {
======================================================================
*/
-void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
+void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator )
+{
vec3_t dir;
- float deg;
+ float deg;
vec3_t up, right;
// see if we have a target
- if ( ent->enemy ) {
+ if( ent->enemy )
+ {
VectorSubtract( ent->enemy->r.currentOrigin, ent->s.origin, dir );
VectorNormalize( dir );
- } else {
- VectorCopy( ent->movedir, dir );
}
+ else
+ VectorCopy( ent->movedir, dir );
// randomize a bit
PerpendicularVector( up, dir );
CrossProduct( up, dir, right );
- deg = crandom() * ent->random;
+ deg = crandom( ) * ent->random;
VectorMA( dir, deg, up, dir );
- deg = crandom() * ent->random;
+ deg = crandom( ) * ent->random;
VectorMA( dir, deg, right, dir );
VectorNormalize( dir );
@@ -277,13 +291,15 @@ void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
}
-static void InitShooter_Finish( gentity_t *ent ) {
+static void InitShooter_Finish( gentity_t *ent )
+{
ent->enemy = G_PickTarget( ent->target );
ent->think = 0;
ent->nextthink = 0;
}
-void InitShooter( gentity_t *ent, int weapon ) {
+void InitShooter( gentity_t *ent, int weapon )
+{
ent->use = Use_Shooter;
ent->s.weapon = weapon;
@@ -291,15 +307,17 @@ void InitShooter( gentity_t *ent, int weapon ) {
G_SetMovedir( ent->s.angles, ent->movedir );
- if ( !ent->random ) {
+ if( !ent->random )
ent->random = 1.0;
- }
+
ent->random = sin( M_PI * ent->random / 180 );
// target might be a moving object, so we can't set movedir for it
- if ( ent->target ) {
+ if( ent->target )
+ {
ent->think = InitShooter_Finish;
ent->nextthink = level.time + 500;
}
+
trap_LinkEntity( ent );
}
@@ -307,7 +325,8 @@ void InitShooter( gentity_t *ent, int weapon ) {
Fires at either the target or the current direction.
"random" the number of degrees of deviance from the taget. (1.0 default)
*/
-void SP_shooter_rocket( gentity_t *ent ) {
+void SP_shooter_rocket( gentity_t *ent )
+{
//InitShooter( ent, WP_ROCKET_LAUNCHER );
}
@@ -315,7 +334,8 @@ void SP_shooter_rocket( gentity_t *ent ) {
Fires at either the target or the current direction.
"random" is the number of degrees of deviance from the taget. (1.0 default)
*/
-void SP_shooter_plasma( gentity_t *ent ) {
+void SP_shooter_plasma( gentity_t *ent )
+{
//InitShooter( ent, WP_PLASMAGUN);
}
@@ -323,7 +343,8 @@ void SP_shooter_plasma( gentity_t *ent ) {
Fires at either the target or the current direction.
"random" is the number of degrees of deviance from the taget. (1.0 default)
*/
-void SP_shooter_grenade( gentity_t *ent ) {
+void SP_shooter_grenade( gentity_t *ent )
+{
//InitShooter( ent, WP_GRENADE_LAUNCHER);
}