2
0
mirror of https://github.com/FWGS/hlsdk-xash3d synced 2024-11-30 05:51:58 +01:00
hlsdk-xash3d/dlls/airtank.cpp

115 lines
2.6 KiB
C++
Raw Normal View History

2016-06-04 15:24:23 +02:00
/***
*
* 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 );
2016-07-31 15:48:50 +02:00
int BloodColor( void ) { return DONT_BLEED; };
2016-06-04 15:24:23 +02:00
void Killed( entvars_t *pevAttacker, int iGib );
2016-07-31 15:48:50 +02:00
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
2016-06-04 15:24:23 +02:00
static TYPEDESCRIPTION m_SaveData[];
2016-07-31 15:48:50 +02:00
int m_state;
2016-06-04 15:24:23 +02:00
};
LINK_ENTITY_TO_CLASS( item_airtank, CAirtank )
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
TYPEDESCRIPTION CAirtank::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CAirtank, m_state, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CAirtank, CGrenade )
2016-06-04 15:24:23 +02:00
2016-07-31 15:48:50 +02:00
void CAirtank::Spawn( void )
2016-06-04 15:24:23 +02:00
{
2016-07-31 15:48:50 +02:00
Precache();
2016-06-04 15:24:23 +02:00
// motor
pev->movetype = MOVETYPE_FLY;
pev->solid = SOLID_BBOX;
2016-07-31 15:48:50 +02:00
SET_MODEL( ENT( pev ), "models/w_oxygen.mdl" );
UTIL_SetSize( pev, Vector( -16, -16, 0), Vector( 16, 16, 36 ) );
2016-06-04 15:24:23 +02:00
UTIL_SetOrigin( pev, pev->origin );
SetTouch( &CAirtank::TankTouch );
SetThink( &CAirtank::TankThink );
pev->flags |= FL_MONSTER;
2016-07-31 15:48:50 +02:00
pev->takedamage = DAMAGE_YES;
pev->health = 20;
pev->dmg = 50;
m_state = 1;
2016-06-04 15:24:23 +02:00
}
void CAirtank::Precache( void )
{
2016-07-31 15:48:50 +02:00
PRECACHE_MODEL( "models/w_oxygen.mdl" );
PRECACHE_SOUND( "doors/aliendoor3.wav" );
2016-06-04 15:24:23 +02:00
}
2016-07-31 15:48:50 +02:00
void CAirtank::Killed( entvars_t *pevAttacker, int iGib )
2016-06-04 15:24:23 +02:00
{
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 )
{
2016-07-31 15:48:50 +02:00
if( !pOther->IsPlayer() )
2016-06-04 15:24:23 +02:00
return;
2016-07-31 15:48:50 +02:00
if( !m_state )
2016-06-04 15:24:23 +02:00
{
// "no oxygen" sound
2016-07-31 15:48:50 +02:00
EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 1.0, ATTN_NORM );
2016-06-04 15:24:23 +02:00
return;
}
2016-07-31 15:48:50 +02:00
2016-06-04 15:24:23 +02:00
// give player 12 more seconds of air
pOther->pev->air_finished = gpGlobals->time + 12;
// suit recharge sound
2016-07-31 15:48:50 +02:00
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "doors/aliendoor3.wav", 1.0, ATTN_NORM );
2016-06-04 15:24:23 +02:00
// recharge airtank in 30 seconds
pev->nextthink = gpGlobals->time + 30;
m_state = 0;
SUB_UseTargets( this, USE_TOGGLE, 1 );
}