ReGameDLL_CS/regamedll/dlls/spectator.cpp
s1lentq 3d252fe527 Refactoring and cleanup.
Fixed some critical bugs and typos (carrer_task, tutor, zbot and other)
Added command line option `-bots` to run bots in CS 1.6
Removed the tests demo record/player from myself the project and also dependency of the steam library.
Fixed the progress bar when generating a nav file.
2016-02-23 05:23:45 +06:00

100 lines
1.9 KiB
C++

#include "precompiled.h"
void CBaseSpectator::SpectatorConnect()
{
pev->flags = FL_SPECTATOR;
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
m_pGoalEnt = NULL;
}
void CBaseSpectator::SpectatorDisconnect()
{
;
}
void CBaseSpectator::SpectatorImpulseCommand()
{
static edict_t *pGoal = NULL;
edict_t *pPreviousGoal;
edict_t *pCurrentGoal;
BOOL bFound;
switch (pev->impulse)
{
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;
while (true)
{
pCurrentGoal = FIND_ENTITY_BY_CLASSNAME(pCurrentGoal, "info_player_deathmatch");
// Looped around, failure
if (pCurrentGoal == pPreviousGoal)
{
ALERT(at_console, "Could not find a spawn spot.\n");
break;
}
// Found a non-world entity, set success, otherwise, look for the next one.
if (!FNullEnt(pCurrentGoal))
{
bFound = TRUE;
break;
}
}
// Didn't find a good spot.
if (!bFound)
break;
pGoal = pCurrentGoal;
UTIL_SetOrigin(pev, pGoal->v.origin);
pev->angles = pGoal->v.angles;
pev->fixangle = 0;
break;
}
default:
ALERT(at_console, "Unknown spectator impulse\n");
break;
}
pev->impulse = 0;
}
void CBaseSpectator::SpectatorThink()
{
if (!(pev->flags & FL_SPECTATOR))
{
pev->flags = FL_SPECTATOR;
}
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
if (pev->impulse)
{
SpectatorImpulseCommand();
}
}
void CBaseSpectator::__MAKE_VHOOK(Spawn)()
{
pev->flags = FL_SPECTATOR;
pev->solid = SOLID_NOT;
pev->movetype = MOVETYPE_NOCLIP;
m_pGoalEnt = NULL;
}