commit 54b91324c9224742fb9d48c6527357136cdb94c4 Author: devhc Date: Sun May 8 23:37:43 2011 +0200 change setviewpos to work as it sounds like setviewpos now precisely puts the player's view origin to the specified coordinates, and does not spit the player forward; it now optionally takes yaw and pitch arguments for this, setviewpos takes ps->viewheight into account when teleporting the player; TeleportPlayer() now takes an addition float argument specifying how fast spit the player forward, currently it's called with 0 only from the setviewpos function diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index f3818b1..1797f13 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1564,24 +1564,32 @@ void Cmd_SetViewpos_f( gentity_t *ent ) char buffer[ MAX_TOKEN_CHARS ]; int i; - if( trap_Argc( ) != 5 ) + if( trap_Argc( ) < 4 ) { - trap_SendServerCommand( ent-g_entities, "print \"usage: setviewpos x y z yaw\n\"" ); + trap_SendServerCommand( ent-g_entities, "print \"usage: setviewpos [ []]\n\"" ); return; } - VectorClear( angles ); - for( i = 0; i < 3; i++ ) { trap_Argv( i + 1, buffer, sizeof( buffer ) ); origin[ i ] = atof( buffer ); } + origin[ 2 ] -= ent->client->ps.viewheight; + + VectorCopy( ent->client->ps.viewangles, angles ); + angles[ ROLL ] = 0; - trap_Argv( 4, buffer, sizeof( buffer ) ); - angles[ YAW ] = atof( buffer ); + if( trap_Argc() >= 5 ) { + trap_Argv( 4, buffer, sizeof( buffer ) ); + angles[ YAW ] = atof( buffer ); + if( trap_Argc() >= 6 ) { + trap_Argv( 5, buffer, sizeof( buffer ) ); + angles[ PITCH ] = atof( buffer ); + } + } - TeleportPlayer( ent, origin, angles ); + TeleportPlayer( ent, origin, angles, 0.0f ); } #define AS_OVER_RT3 ((ALIENSENSE_RANGE*0.5f)/M_ROOT3) diff --git a/src/game/g_local.h b/src/game/g_local.h index e11d31a..5107324 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -923,7 +923,7 @@ void G_Checktrigger_stages( team_t team, stage_t stage ); // // g_misc.c // -void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ); +void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles, float speed ); // // g_weapon.c diff --git a/src/game/g_misc.c b/src/game/g_misc.c index 0572684..2f46033 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -70,19 +70,24 @@ TELEPORTERS ================================================================================= */ -void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles ) +void TeleportPlayer( gentity_t *player, vec3_t origin, vec3_t angles, float speed ) { // unlink to make sure it can't possibly interfere with G_KillBox trap_UnlinkEntity( player ); VectorCopy( origin, player->client->ps.origin ); - player->client->ps.origin[ 2 ] += 1; + player->client->ps.groundEntityNum = ENTITYNUM_NONE; + player->client->ps.stats[ STAT_STATE ] &= ~SS_GRABBED; - // spit the player out - AngleVectors( angles, player->client->ps.velocity, NULL, NULL ); - VectorScale( player->client->ps.velocity, 400, player->client->ps.velocity ); - player->client->ps.pm_time = 160; // hold time - player->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + if( speed != 0.0f ) + { + AngleVectors( angles, player->client->ps.velocity, NULL, NULL ); + VectorScale( player->client->ps.velocity, 400, player->client->ps.velocity ); + player->client->ps.pm_time = 160; // duration of loss of control + player->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + } + else + VectorClear( player->client->ps.velocity ); // toggle the teleport bit so the client knows to not lerp player->client->ps.eFlags ^= EF_TELEPORT_BIT; diff --git a/src/game/g_mover.c b/src/game/g_mover.c index c081e9e..b2b8ada 100644 --- a/src/game/g_mover.c +++ b/src/game/g_mover.c @@ -1177,7 +1177,7 @@ static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_ } vectoangles( dir, angles ); - TeleportPlayer( other, origin, angles ); + TeleportPlayer( other, origin, angles, 400.0f ); } diff --git a/src/game/g_target.c b/src/game/g_target.c index a3be4ff..38198ed 100644 --- a/src/game/g_target.c +++ b/src/game/g_target.c @@ -211,7 +211,7 @@ void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activa return; } - TeleportPlayer( activator, dest->s.origin, dest->s.angles ); + TeleportPlayer( activator, dest->s.origin, dest->s.angles, 400.0f ); } /*QUAKED target_teleporter (1 0 0) (-8 -8 -8) (8 8 8) diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c index 15ef714..5935565 100644 --- a/src/game/g_trigger.c +++ b/src/game/g_trigger.c @@ -295,7 +295,7 @@ void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace return; } - TeleportPlayer( other, dest->s.origin, dest->s.angles ); + TeleportPlayer( other, dest->s.origin, dest->s.angles, 400.0f ); } /*