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.

149 lines
3.0 KiB

7 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
//
7 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 )
7 years ago
{
pev->flags = FL_SPECTATOR;
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
7 years ago
m_pGoalEnt = NULL;
}
/*
===========
SpectatorDisconnect
called when a spectator disconnects from a server
============
*/
9 years ago
void CBaseSpectator::SpectatorDisconnect( void )
7 years ago
{
}
/*
================
SpectatorImpulseCommand
Called by SpectatorThink if the spectator entered an impulse
================
*/
9 years ago
void CBaseSpectator::SpectatorImpulseCommand( void )
7 years ago
{
9 years ago
static edict_t *pGoal = NULL;
7 years ago
CBaseEntity *pPreviousGoal;
CBaseEntity *pCurrentGoal;
9 years ago
BOOL bFound;
9 years ago
switch( pev->impulse )
7 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 = (CBaseEntity*)GET_PRIVATE(pGoal);
pCurrentGoal = (CBaseEntity*)GET_PRIVATE(pGoal);
// Start at the current goal, skip the world, and stop if we looped back around
bFound = FALSE;
9 years ago
while( 1 )
7 years ago
{
pCurrentGoal = UTIL_FindEntityByClassname(pCurrentGoal, "info_player_deathmatch");
// Looped around, failure
9 years ago
if( pCurrentGoal == pPreviousGoal )
7 years ago
{
9 years ago
ALERT( at_console, "Could not find a spawn spot.\n" );
7 years ago
break;
}
// Found a non-world entity, set success, otherwise, look for the next one.
if ( pCurrentGoal )
{
bFound = TRUE;
break;
}
}
9 years ago
if( !bFound ) // Didn't find a good spot.
7 years ago
break;
7 years ago
pGoal = ENT(pCurrentGoal->pev);
UTIL_SetOrigin( this, pGoal->v.origin );
pev->angles = pGoal->v.angles;
pev->fixangle = FALSE;
break;
default:
9 years ago
ALERT( at_console, "Unknown spectator impulse\n" );
7 years ago
break;
}
pev->impulse = 0;
}
/*
================
SpectatorThink
Called every frame after physics are run
================
*/
9 years ago
void CBaseSpectator::SpectatorThink( void )
7 years ago
{
9 years ago
if( !( pev->flags & FL_SPECTATOR ) )
7 years ago
{
pev->flags = FL_SPECTATOR;
}
9 years ago
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
7 years ago
9 years ago
if( pev->impulse )
7 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;
7 years ago
m_pGoalEnt = NULL;
}