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.

115 lines
2.6 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.
*
****/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
class CAirtank : public CGrenade
{
void Spawn( void );
void Precache( void );
void EXPORT TankThink( void );
void EXPORT TankTouch( CBaseEntity *pOther );
8 years ago
int BloodColor( void ) { return DONT_BLEED; };
7 years ago
void Killed( entvars_t *pevAttacker, int iGib );
8 years ago
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
7 years ago
static TYPEDESCRIPTION m_SaveData[];
8 years ago
int m_state;
7 years ago
};
LINK_ENTITY_TO_CLASS( item_airtank, CAirtank )
7 years ago
8 years ago
TYPEDESCRIPTION CAirtank::m_SaveData[] =
7 years ago
{
DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CAirtank, CGrenade )
7 years ago
8 years ago
void CAirtank::Spawn( void )
7 years ago
{
8 years ago
Precache();
7 years ago
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
8 years ago
SET_MODEL( ENT( pev ), "models/w_oxygen.mdl" );
UTIL_SetSize( pev, Vector( -16, -16, 0), Vector( 16, 16, 36 ) );
7 years ago
UTIL_SetOrigin( this, pev->origin );
9 years ago
SetTouch( &CAirtank::TankTouch );
SetThink( &CAirtank::TankThink );
7 years ago
pev->flags |= FL_MONSTER;
8 years ago
pev->takedamage = DAMAGE_YES;
pev->health = 20;
pev->dmg = 50;
m_state = 1;
7 years ago
}
void CAirtank::Precache( void )
{
8 years ago
PRECACHE_MODEL( "models/w_oxygen.mdl" );
PRECACHE_SOUND( "doors/aliendoor3.wav" );
7 years ago
}
8 years ago
void CAirtank::Killed( entvars_t *pevAttacker, int iGib )
7 years ago
{
pev->owner = ENT( pevAttacker );
// UNDONE: this should make a big bubble cloud, not an explosion
Explode( pev->origin, Vector( 0, 0, -1 ) );
}
void CAirtank::TankThink( void )
{
// Fire trigger
m_state = 1;
SUB_UseTargets( this, USE_TOGGLE, 0 );
}
void CAirtank::TankTouch( CBaseEntity *pOther )
{
8 years ago
if( !pOther->IsPlayer() )
7 years ago
return;
8 years ago
if( !m_state )
7 years ago
{
// "no oxygen" sound
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM );
7 years ago
return;
}
8 years ago
7 years ago
// give player 12 more seconds of air
pOther->pev->air_finished = gpGlobals->time + 12;
// suit recharge sound
8 years ago
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM );
7 years ago
// recharge airtank in 30 seconds
SetNextThink( 30 );
m_state = 0;
SUB_UseTargets( this, USE_TOGGLE, 1 );
}