Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

g_misc.c File Reference

#include "g_local.h"

Include dependency graph for g_misc.c:

Include dependency graph

Go to the source code of this file.

Functions

void InitShooter (gentity_t *ent, int weapon)
void InitShooter_Finish (gentity_t *ent)
void locateCamera (gentity_t *ent)
void SP_info_camp (gentity_t *self)
void SP_info_notnull (gentity_t *self)
void SP_info_null (gentity_t *self)
void SP_light (gentity_t *self)
void SP_misc_model (gentity_t *ent)
void SP_misc_portal_camera (gentity_t *ent)
void SP_misc_portal_surface (gentity_t *ent)
void SP_misc_teleporter_dest (gentity_t *ent)
void SP_shooter_grenade (gentity_t *ent)
void SP_shooter_plasma (gentity_t *ent)
void SP_shooter_rocket (gentity_t *ent)
void TeleportPlayer (gentity_t *player, vec3_t origin, vec3_t angles)
void Use_Shooter (gentity_t *ent, gentity_t *other, gentity_t *activator)


Function Documentation

void InitShooter gentity_t ent,
int  weapon
 

Definition at line 295 of file g_misc.c.

References entityState_s::angles, BG_FindItemForWeapon(), G_SetMovedir(), gentity_t, level, M_PI, gentity_s::movedir, gentity_s::nextthink, gentity_s::random, RegisterItem(), gentity_s::s, sin(), gentity_s::target, gentity_s::think, level_locals_t::time, trap_LinkEntity(), gentity_s::use, and entityState_s::weapon.

Referenced by SP_shooter_grenade(), SP_shooter_plasma(), and SP_shooter_rocket().

00295                                                {
00296     ent->use = Use_Shooter;
00297     ent->s.weapon = weapon;
00298 
00299     RegisterItem( BG_FindItemForWeapon( weapon ) );
00300 
00301     G_SetMovedir( ent->s.angles, ent->movedir );
00302 
00303     if ( !ent->random ) {
00304         ent->random = 1.0;
00305     }
00306     ent->random = sin( M_PI * ent->random / 180 );
00307     // target might be a moving object, so we can't set movedir for it
00308     if ( ent->target ) {
00309         ent->think = InitShooter_Finish;
00310         ent->nextthink = level.time + 500;
00311     }
00312     trap_LinkEntity( ent );
00313 }

Here is the call graph for this function:

void InitShooter_Finish gentity_t ent  )  [static]
 

Definition at line 289 of file g_misc.c.

References gentity_s::enemy, G_PickTarget(), gentity_t, gentity_s::nextthink, gentity_s::target, and gentity_s::think.

00289                                                  {
00290     ent->enemy = G_PickTarget( ent->target );
00291     ent->think = 0;
00292     ent->nextthink = 0;
00293 }

Here is the call graph for this function:

void locateCamera gentity_t ent  ) 
 

Definition at line 158 of file g_misc.c.

References entityState_s::angles, entityState_s::clientNum, DirToByte(), entityState_s::eventParm, entityState_s::frame, G_FreeEntity(), G_PickTarget(), G_Printf(), G_SetMovedir(), gentity_t, entityState_s::number, entityState_s::origin, entityState_s::origin2, entityShared_t::ownerNum, entityState_s::powerups, gentity_s::r, gentity_s::s, gentity_s::spawnflags, gentity_s::target, vec3_t, VectorCopy, VectorNormalize(), and VectorSubtract.

00158                                     {
00159     vec3_t      dir;
00160     gentity_t   *target;
00161     gentity_t   *owner;
00162 
00163     owner = G_PickTarget( ent->target );
00164     if ( !owner ) {
00165         G_Printf( "Couldn't find target for misc_partal_surface\n" );
00166         G_FreeEntity( ent );
00167         return;
00168     }
00169     ent->r.ownerNum = owner->s.number;
00170 
00171     // frame holds the rotate speed
00172     if ( owner->spawnflags & 1 ) {
00173         ent->s.frame = 25;
00174     } else if ( owner->spawnflags & 2 ) {
00175         ent->s.frame = 75;
00176     }
00177 
00178     // swing camera ?
00179     if ( owner->spawnflags & 4 ) {
00180         // set to 0 for no rotation at all
00181         ent->s.powerups = 0;
00182     }
00183     else {
00184         ent->s.powerups = 1;
00185     }
00186 
00187     // clientNum holds the rotate offset
00188     ent->s.clientNum = owner->s.clientNum;
00189 
00190     VectorCopy( owner->s.origin, ent->s.origin2 );
00191 
00192     // see if the portal_camera has a target
00193     target = G_PickTarget( owner->target );
00194     if ( target ) {
00195         VectorSubtract( target->s.origin, owner->s.origin, dir );
00196         VectorNormalize( dir );
00197     } else {
00198         G_SetMovedir( owner->s.angles, dir );
00199     }
00200 
00201     ent->s.eventParm = DirToByte( dir );
00202 }

Here is the call graph for this function:

void SP_info_camp gentity_t self  ) 
 

Definition at line 36 of file g_misc.c.

References G_SetOrigin(), gentity_t, entityState_s::origin, and gentity_s::s.

00036                                      {
00037     G_SetOrigin( self, self->s.origin );
00038 }

Here is the call graph for this function:

void SP_info_notnull gentity_t self  ) 
 

Definition at line 53 of file g_misc.c.

References G_SetOrigin(), gentity_t, entityState_s::origin, and gentity_s::s.

00053                                        {
00054     G_SetOrigin( self, self->s.origin );
00055 }

Here is the call graph for this function:

void SP_info_null gentity_t self  ) 
 

Definition at line 44 of file g_misc.c.

References G_FreeEntity(), and gentity_t.

00044                                      {
00045     G_FreeEntity( self );
00046 }

Here is the call graph for this function:

void SP_light gentity_t self  ) 
 

Definition at line 65 of file g_misc.c.

References G_FreeEntity(), and gentity_t.

00065                                  {
00066     G_FreeEntity( self );
00067 }

Here is the call graph for this function:

void SP_misc_model gentity_t ent  ) 
 

Definition at line 141 of file g_misc.c.

References entityState_s::angles, entityState_s::apos, G_FreeEntity(), G_ModelIndex(), G_SetOrigin(), gentity_t, gentity_s::model, entityState_s::modelindex, entityState_s::origin, gentity_s::s, trap_LinkEntity(), trajectory_t::trBase, VectorCopy, and VectorSet.

00141                                      {
00142 
00143 #if 0
00144     ent->s.modelindex = G_ModelIndex( ent->model );
00145     VectorSet (ent->mins, -16, -16, -16);
00146     VectorSet (ent->maxs, 16, 16, 16);
00147     trap_LinkEntity (ent);
00148 
00149     G_SetOrigin( ent, ent->s.origin );
00150     VectorCopy( ent->s.angles, ent->s.apos.trBase );
00151 #else
00152     G_FreeEntity( ent );
00153 #endif
00154 }

Here is the call graph for this function:

void SP_misc_portal_camera gentity_t ent  ) 
 

Definition at line 228 of file g_misc.c.

References entityState_s::clientNum, G_SpawnFloat(), gentity_t, entityShared_t::maxs, entityShared_t::mins, gentity_s::r, gentity_s::s, trap_LinkEntity(), and VectorClear.

00228                                            {
00229     float   roll;
00230 
00231     VectorClear( ent->r.mins );
00232     VectorClear( ent->r.maxs );
00233     trap_LinkEntity (ent);
00234 
00235     G_SpawnFloat( "roll", "0", &roll );
00236 
00237     ent->s.clientNum = roll/360.0 * 256;
00238 }

Here is the call graph for this function:

void SP_misc_portal_surface gentity_t ent  ) 
 

Definition at line 208 of file g_misc.c.

References entityState_s::eType, gentity_t, level, entityShared_t::maxs, entityShared_t::mins, gentity_s::nextthink, entityState_s::origin, entityState_s::origin2, gentity_s::r, gentity_s::s, entityShared_t::svFlags, gentity_s::target, gentity_s::think, level_locals_t::time, trap_LinkEntity(), VectorClear, and VectorCopy.

00208                                             {
00209     VectorClear( ent->r.mins );
00210     VectorClear( ent->r.maxs );
00211     trap_LinkEntity (ent);
00212 
00213     ent->r.svFlags = SVF_PORTAL;
00214     ent->s.eType = ET_PORTAL;
00215 
00216     if ( !ent->target ) {
00217         VectorCopy( ent->s.origin, ent->s.origin2 );
00218     } else {
00219         ent->think = locateCamera;
00220         ent->nextthink = level.time + 100;
00221     }
00222 }

Here is the call graph for this function:

void SP_misc_teleporter_dest gentity_t ent  ) 
 

Definition at line 132 of file g_misc.c.

References gentity_t.

00132                                                {
00133 }

void SP_shooter_grenade gentity_t ent  ) 
 

Definition at line 335 of file g_misc.c.

References gentity_t, InitShooter(), and WP_GRENADE_LAUNCHER.

00335                                           {
00336     InitShooter( ent, WP_GRENADE_LAUNCHER);
00337 }

Here is the call graph for this function:

void SP_shooter_plasma gentity_t ent  ) 
 

Definition at line 327 of file g_misc.c.

References gentity_t, InitShooter(), and WP_PLASMAGUN.

00327                                          {
00328     InitShooter( ent, WP_PLASMAGUN);
00329 }

Here is the call graph for this function:

void SP_shooter_rocket gentity_t ent  ) 
 

Definition at line 319 of file g_misc.c.

References gentity_t, InitShooter(), and WP_ROCKET_LAUNCHER.

00319                                          {
00320     InitShooter( ent, WP_ROCKET_LAUNCHER );
00321 }

Here is the call graph for this function:

void TeleportPlayer gentity_t player,
vec3_t  origin,
vec3_t  angles
 

Definition at line 79 of file g_misc.c.

References AngleVectors(), BG_PlayerStateToEntityState(), gentity_s::client, entityState_s::clientNum, entityShared_t::currentOrigin, playerState_s::eFlags, EV_PLAYER_TELEPORT_IN, EV_PLAYER_TELEPORT_OUT, G_KillBox(), G_TempEntity(), gentity_t, NULL, playerState_s::origin, playerState_s::pm_flags, playerState_s::pm_time, gclient_s::ps, qtrue, gentity_s::r, gentity_s::s, gclient_s::sess, clientSession_t::sessionTeam, SetClientViewAngle(), trap_LinkEntity(), trap_UnlinkEntity(), VectorCopy, VectorScale, and playerState_s::velocity.

Referenced by ClientEvents(), Cmd_SetViewpos_f(), target_teleporter_use(), Touch_DoorTriggerSpectator(), and trigger_teleporter_touch().

00079                                                                        {
00080     gentity_t   *tent;
00081 
00082     // use temp events at source and destination to prevent the effect
00083     // from getting dropped by a second player event
00084     if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
00085         tent = G_TempEntity( player->client->ps.origin, EV_PLAYER_TELEPORT_OUT );
00086         tent->s.clientNum = player->s.clientNum;
00087 
00088         tent = G_TempEntity( origin, EV_PLAYER_TELEPORT_IN );
00089         tent->s.clientNum = player->s.clientNum;
00090     }
00091 
00092     // unlink to make sure it can't possibly interfere with G_KillBox
00093     trap_UnlinkEntity (player);
00094 
00095     VectorCopy ( origin, player->client->ps.origin );
00096     player->client->ps.origin[2] += 1;
00097 
00098     // spit the player out
00099     AngleVectors( angles, player->client->ps.velocity, NULL, NULL );
00100     VectorScale( player->client->ps.velocity, 400, player->client->ps.velocity );
00101     player->client->ps.pm_time = 160;       // hold time
00102     player->client->ps.pm_flags |= PMF_TIME_KNOCKBACK;
00103 
00104     // toggle the teleport bit so the client knows to not lerp
00105     player->client->ps.eFlags ^= EF_TELEPORT_BIT;
00106 
00107     // set angles
00108     SetClientViewAngle( player, angles );
00109 
00110     // kill anything at the destination
00111     if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
00112         G_KillBox (player);
00113     }
00114 
00115     // save results of pmove
00116     BG_PlayerStateToEntityState( &player->client->ps, &player->s, qtrue );
00117 
00118     // use the precise origin for linking
00119     VectorCopy( player->client->ps.origin, player->r.currentOrigin );
00120 
00121     if ( player->client->sess.sessionTeam != TEAM_SPECTATOR ) {
00122         trap_LinkEntity (player);
00123     }
00124 }

Here is the call graph for this function:

void Use_Shooter gentity_t ent,
gentity_t other,
gentity_t activator
 

Definition at line 248 of file g_misc.c.

References crandom, CrossProduct(), entityShared_t::currentOrigin, gentity_s::enemy, EV_FIRE_WEAPON, fire_grenade(), fire_plasma(), fire_rocket(), G_AddEvent(), gentity_t, gentity_s::movedir, entityState_s::origin, PerpendicularVector(), gentity_s::r, gentity_s::random, right, gentity_s::s, up, vec3_t, VectorCopy, VectorMA, VectorNormalize(), VectorSubtract, entityState_s::weapon, WP_GRENADE_LAUNCHER, WP_PLASMAGUN, and WP_ROCKET_LAUNCHER.

00248                                                                            {
00249     vec3_t      dir;
00250     float       deg;
00251     vec3_t      up, right;
00252 
00253     // see if we have a target
00254     if ( ent->enemy ) {
00255         VectorSubtract( ent->enemy->r.currentOrigin, ent->s.origin, dir );
00256         VectorNormalize( dir );
00257     } else {
00258         VectorCopy( ent->movedir, dir );
00259     }
00260 
00261     // randomize a bit
00262     PerpendicularVector( up, dir );
00263     CrossProduct( up, dir, right );
00264 
00265     deg = crandom() * ent->random;
00266     VectorMA( dir, deg, up, dir );
00267 
00268     deg = crandom() * ent->random;
00269     VectorMA( dir, deg, right, dir );
00270 
00271     VectorNormalize( dir );
00272 
00273     switch ( ent->s.weapon ) {
00274     case WP_GRENADE_LAUNCHER:
00275         fire_grenade( ent, ent->s.origin, dir );
00276         break;
00277     case WP_ROCKET_LAUNCHER:
00278         fire_rocket( ent, ent->s.origin, dir );
00279         break;
00280     case WP_PLASMAGUN:
00281         fire_plasma( ent, ent->s.origin, dir );
00282         break;
00283     }
00284 
00285     G_AddEvent( ent, EV_FIRE_WEAPON, 0 );
00286 }

Here is the call graph for this function:


Generated on Thu Aug 25 13:56:03 2005 for Quake III Arena by  doxygen 1.3.9.1