Portable Half-Life SDK. GoldSource and Xash3D. Crossplatform.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
3.0 KiB

9 years ago
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
// CBaseSpectator
// YWB: UNDONE
// Spectator functions
//
9 years ago
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "spectator.h"
/*
===========
SpectatorConnect
called when a spectator connects to a server
============
*/
9 years ago
void CBaseSpectator::SpectatorConnect( void )
9 years ago
{
pev->flags = FL_SPECTATOR;
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
9 years ago
m_pGoalEnt = NULL;
}
/*
===========
SpectatorDisconnect
called when a spectator disconnects from a server
============
*/
9 years ago
void CBaseSpectator::SpectatorDisconnect( void )
9 years ago
{
}
/*
================
SpectatorImpulseCommand
Called by SpectatorThink if the spectator entered an impulse
================
*/
9 years ago
void CBaseSpectator::SpectatorImpulseCommand( void )
9 years ago
{
9 years ago
static edict_t *pGoal = NULL;
edict_t *pPreviousGoal;
edict_t *pCurrentGoal;
BOOL bFound;
9 years ago
switch( pev->impulse )
9 years ago
{
case 1:
// teleport the spectator to the next spawn point
// note that if the spectator is tracking, this doesn't do
// much
pPreviousGoal = pGoal;
pCurrentGoal = pGoal;
// Start at the current goal, skip the world, and stop if we looped
// back around
bFound = FALSE;
9 years ago
while( 1 )
9 years ago
{
9 years ago
pCurrentGoal = FIND_ENTITY_BY_CLASSNAME( pCurrentGoal, "info_player_deathmatch" );
9 years ago
// Looped around, failure
9 years ago
if( pCurrentGoal == pPreviousGoal )
9 years ago
{
9 years ago
ALERT( at_console, "Could not find a spawn spot.\n" );
9 years ago
break;
}
// Found a non-world entity, set success, otherwise, look for the next one.
9 years ago
if( !FNullEnt( pCurrentGoal ) )
9 years ago
{
bFound = TRUE;
break;
}
}
9 years ago
if( !bFound ) // Didn't find a good spot.
9 years ago
break;
9 years ago
pGoal = pCurrentGoal;
UTIL_SetOrigin( pev, pGoal->v.origin );
pev->angles = pGoal->v.angles;
pev->fixangle = FALSE;
break;
default:
9 years ago
ALERT( at_console, "Unknown spectator impulse\n" );
9 years ago
break;
}
pev->impulse = 0;
}
/*
================
SpectatorThink
Called every frame after physics are run
================
*/
9 years ago
void CBaseSpectator::SpectatorThink( void )
9 years ago
{
9 years ago
if( !( pev->flags & FL_SPECTATOR ) )
9 years ago
{
pev->flags = FL_SPECTATOR;
}
9 years ago
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
9 years ago
9 years ago
if( pev->impulse )
9 years ago
SpectatorImpulseCommand();
}
/*
===========
Spawn
Called when spectator is initialized:
UNDONE: Is this actually being called because spectators are not allocated in normal fashion?
============
*/
void CBaseSpectator::Spawn()
{
pev->flags = FL_SPECTATOR;
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
9 years ago
m_pGoalEnt = NULL;
}