-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: restructurized source code from plats.cpp
- Loading branch information
1 parent
b43a00c
commit e339f0d
Showing
22 changed files
with
3,619 additions
and
3,308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/*** | ||
* | ||
* 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. | ||
* | ||
****/ | ||
|
||
#include "func_guntarget.h" | ||
|
||
LINK_ENTITY_TO_CLASS( func_guntarget, CGunTarget ); | ||
|
||
BEGIN_DATADESC( CGunTarget ) | ||
DEFINE_FIELD( m_on, FIELD_BOOLEAN ), | ||
DEFINE_FUNCTION( Next ), | ||
DEFINE_FUNCTION( Wait ), | ||
DEFINE_FUNCTION( Start ), | ||
END_DATADESC() | ||
|
||
void CGunTarget::Spawn( void ) | ||
{ | ||
pev->solid = SOLID_BSP; | ||
pev->movetype = MOVETYPE_PUSH; | ||
|
||
m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this ); | ||
SET_MODEL( edict(), GetModel() ); | ||
RelinkEntity( TRUE ); | ||
|
||
if ( pev->speed == 0 ) | ||
pev->speed = 100; | ||
|
||
// Don't take damage until "on" | ||
pev->takedamage = DAMAGE_NO; | ||
pev->flags |= FL_MONSTER; | ||
|
||
m_on = FALSE; | ||
pev->max_health = pev->health; | ||
|
||
if( pev->spawnflags & FGUNTARGET_START_ON ) | ||
{ | ||
SetMoveDone( &CGunTarget::Start ); | ||
SetMoveDoneTime( 0.3 ); | ||
} | ||
} | ||
|
||
void CGunTarget :: Activate( void ) | ||
{ | ||
CBaseEntity *pTarg; | ||
|
||
// now find our next target | ||
pTarg = GetNextTarget(); | ||
|
||
if( pTarg ) | ||
{ | ||
m_hTargetEnt = pTarg; | ||
UTIL_SetOrigin( this, pTarg->GetLocalOrigin() - (pev->mins + pev->maxs) * 0.5 ); | ||
} | ||
} | ||
|
||
void CGunTarget::Start( void ) | ||
{ | ||
Use( this, this, USE_ON, 0 ); | ||
} | ||
|
||
void CGunTarget::Next( void ) | ||
{ | ||
SetThink( NULL ); | ||
|
||
m_hTargetEnt = GetNextTarget(); | ||
CBaseEntity *pTarget = m_hTargetEnt; | ||
|
||
if( !pTarget ) | ||
{ | ||
Stop(); | ||
return; | ||
} | ||
|
||
SetMoveDone( &CGunTarget::Wait ); | ||
LinearMove( pTarget->GetLocalOrigin() - (pev->mins + pev->maxs) * 0.5, pev->speed ); | ||
} | ||
|
||
void CGunTarget::Wait( void ) | ||
{ | ||
CBaseEntity *pTarget = m_hTargetEnt; | ||
|
||
if ( !pTarget ) | ||
{ | ||
Stop(); | ||
return; | ||
} | ||
|
||
// Fire the pass target if there is one | ||
if ( pTarget->pev->message ) | ||
{ | ||
UTIL_FireTargets( STRING(pTarget->pev->message), this, this, USE_TOGGLE, 0 ); | ||
if ( FBitSet( pTarget->pev->spawnflags, SF_CORNER_FIREONCE ) ) | ||
pTarget->pev->message = 0; | ||
} | ||
|
||
m_flWait = pTarget->GetDelay(); | ||
|
||
pev->target = pTarget->pev->target; | ||
SetMoveDone( &CGunTarget::Next ); | ||
|
||
if( m_flWait != 0 ) | ||
{ | ||
// -1 wait will wait forever! | ||
SetMoveDoneTime( m_flWait ); | ||
} | ||
else | ||
{ | ||
Next();// do it RIGHT now! | ||
} | ||
} | ||
|
||
void CGunTarget::Stop( void ) | ||
{ | ||
SetLocalVelocity( g_vecZero ); | ||
SetMoveDoneTime( -1 ); | ||
pev->takedamage = DAMAGE_NO; | ||
} | ||
|
||
int CGunTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) | ||
{ | ||
if ( pev->health > 0 ) | ||
{ | ||
pev->health -= flDamage; | ||
if ( pev->health <= 0 ) | ||
{ | ||
pev->health = 0; | ||
Stop(); | ||
if ( pev->message ) | ||
UTIL_FireTargets( STRING(pev->message), this, this, USE_TOGGLE, 0 ); | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) | ||
{ | ||
if ( !ShouldToggle( useType, m_on ) ) | ||
return; | ||
|
||
if ( m_on ) | ||
{ | ||
Stop(); | ||
} | ||
else | ||
{ | ||
pev->takedamage = DAMAGE_AIM; | ||
m_hTargetEnt = GetNextTarget(); | ||
if ( m_hTargetEnt == NULL ) | ||
return; | ||
pev->health = pev->max_health; | ||
Next(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*** | ||
* | ||
* 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. | ||
* | ||
****/ | ||
|
||
#pragma once | ||
#include "plats.h" | ||
|
||
// ---------------------------------------------------------- | ||
// | ||
// | ||
// pev->speed is the travel speed | ||
// pev->health is current health | ||
// pev->max_health is the amount to reset to each time it starts | ||
|
||
#define FGUNTARGET_START_ON 0x0001 | ||
|
||
class CGunTarget : public CBaseMonster | ||
{ | ||
DECLARE_CLASS( CGunTarget, CBaseMonster ); | ||
public: | ||
void Spawn( void ); | ||
void Activate( void ); | ||
void Next( void ); | ||
void Start( void ); | ||
void Wait( void ); | ||
void Stop( void ); | ||
|
||
int BloodColor( void ) { return DONT_BLEED; } | ||
int Classify( void ) { return CLASS_MACHINE; } | ||
int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); | ||
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); | ||
Vector BodyTarget( const Vector &posSrc ) { return GetAbsOrigin(); } | ||
virtual int ObjectCaps( void ) { return BaseClass :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } | ||
|
||
DECLARE_DATADESC(); | ||
|
||
private: | ||
BOOL m_on; | ||
}; |
Oops, something went wrong.