hlsdk-xash3d/dlls/weapons.cpp

1651 lines
44 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.
*
****/
/*
===== weapons.cpp ========================================================
functions governing the selection/use of weapons for players
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "player.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "soundent.h"
#include "decals.h"
#include "gamerules.h"
2016-08-01 13:13:13 +02:00
extern CGraph WorldGraph;
2016-06-04 15:24:23 +02:00
extern int gEvilImpulse101;
#define NOT_USED 255
2016-08-01 13:13:13 +02:00
DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam
DLL_GLOBAL const char *g_pModelNameLaser = "sprites/laserbeam.spr";
DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser beam dot
DLL_GLOBAL short g_sModelIndexFireball;// holds the index for the fireball
DLL_GLOBAL short g_sModelIndexSmoke;// holds the index for the smoke cloud
DLL_GLOBAL short g_sModelIndexWExplosion;// holds the index for the underwater explosion
DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model
DLL_GLOBAL short g_sModelIndexBloodDrop;// holds the sprite index for the initial blood
DLL_GLOBAL short g_sModelIndexBloodSpray;// holds the sprite index for splattered blood
2016-06-04 15:24:23 +02:00
ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
AmmoInfo CBasePlayerItem::AmmoInfoArray[MAX_AMMO_SLOTS];
extern int gmsgCurWeapon;
MULTIDAMAGE gMultiDamage;
#define TRACER_FREQ 4 // Tracers fire every fourth bullet
//=========================================================
// MaxAmmoCarry - pass in a name and this function will tell
// you the maximum amount of that type of ammunition that a
// player can carry.
//=========================================================
int MaxAmmoCarry( int iszName )
{
2016-08-01 13:13:13 +02:00
for( int i = 0; i < MAX_WEAPONS; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( CBasePlayerItem::ItemInfoArray[i].pszAmmo1 && !strcmp( STRING( iszName ), CBasePlayerItem::ItemInfoArray[i].pszAmmo1 ) )
2016-06-04 15:24:23 +02:00
return CBasePlayerItem::ItemInfoArray[i].iMaxAmmo1;
2016-08-01 13:13:13 +02:00
if( CBasePlayerItem::ItemInfoArray[i].pszAmmo2 && !strcmp( STRING( iszName ), CBasePlayerItem::ItemInfoArray[i].pszAmmo2 ) )
2016-06-04 15:24:23 +02:00
return CBasePlayerItem::ItemInfoArray[i].iMaxAmmo2;
}
ALERT( at_console, "MaxAmmoCarry() doesn't recognize '%s'!\n", STRING( iszName ) );
return -1;
}
/*
==============================================================================
MULTI-DAMAGE
Collects multiple small damages into a single damage
==============================================================================
*/
//
// ClearMultiDamage - resets the global multi damage accumulator
//
2016-08-01 13:13:13 +02:00
void ClearMultiDamage( void )
2016-06-04 15:24:23 +02:00
{
gMultiDamage.pEntity = NULL;
2016-08-01 13:13:13 +02:00
gMultiDamage.amount = 0;
2016-06-04 15:24:23 +02:00
gMultiDamage.type = 0;
}
//
// ApplyMultiDamage - inflicts contents of global multi damage register on gMultiDamage.pEntity
//
// GLOBALS USED:
// gMultiDamage
2016-08-01 13:13:13 +02:00
void ApplyMultiDamage( entvars_t *pevInflictor, entvars_t *pevAttacker )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
Vector vecSpot1;//where blood comes from
Vector vecDir;//direction blood should go
TraceResult tr;
2016-08-01 13:13:13 +02:00
if( !gMultiDamage.pEntity )
2016-06-04 15:24:23 +02:00
return;
2016-08-01 13:13:13 +02:00
gMultiDamage.pEntity->TakeDamage( pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type );
2016-06-04 15:24:23 +02:00
}
// GLOBALS USED:
// gMultiDamage
2016-08-01 13:13:13 +02:00
void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( !pEntity )
2016-06-04 15:24:23 +02:00
return;
2016-06-04 15:24:23 +02:00
gMultiDamage.type |= bitsDamageType;
2016-08-01 13:13:13 +02:00
if( pEntity != gMultiDamage.pEntity )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
ApplyMultiDamage( pevInflictor,pevInflictor ); // UNDONE: wrong attacker!
gMultiDamage.pEntity = pEntity;
gMultiDamage.amount = 0;
2016-06-04 15:24:23 +02:00
}
gMultiDamage.amount += flDamage;
}
/*
================
SpawnBlood
================
*/
2016-08-01 13:13:13 +02:00
void SpawnBlood( Vector vecSpot, int bloodColor, float flDamage )
2016-06-04 15:24:23 +02:00
{
UTIL_BloodDrips( vecSpot, g_vecAttackDir, bloodColor, (int)flDamage );
}
int DamageDecal( CBaseEntity *pEntity, int bitsDamageType )
{
2016-08-01 13:13:13 +02:00
if( !pEntity )
return ( DECAL_GUNSHOT1 + RANDOM_LONG( 0, 4 ) );
2016-06-04 15:24:23 +02:00
return pEntity->DamageDecal( bitsDamageType );
}
void DecalGunshot( TraceResult *pTrace, int iBulletType )
{
// Is the entity valid
2016-08-01 13:13:13 +02:00
if( !UTIL_IsValidEntity( pTrace->pHit ) )
2016-06-04 15:24:23 +02:00
return;
2016-08-01 13:13:13 +02:00
if( VARS( pTrace->pHit )->solid == SOLID_BSP || VARS( pTrace->pHit )->movetype == MOVETYPE_PUSHSTEP )
2016-06-04 15:24:23 +02:00
{
CBaseEntity *pEntity = NULL;
// Decal the wall with a gunshot
2016-08-01 13:13:13 +02:00
if( !FNullEnt( pTrace->pHit ) )
pEntity = CBaseEntity::Instance( pTrace->pHit );
2016-06-04 15:24:23 +02:00
switch( iBulletType )
{
case BULLET_PLAYER_9MM:
case BULLET_MONSTER_9MM:
case BULLET_PLAYER_MP5:
case BULLET_MONSTER_MP5:
case BULLET_PLAYER_BUCKSHOT:
case BULLET_PLAYER_357:
default:
// smoke and decal
UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
break;
case BULLET_MONSTER_12MM:
// smoke and decal
UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) );
break;
case BULLET_PLAYER_CROWBAR:
// wall decal
UTIL_DecalTrace( pTrace, DamageDecal( pEntity, DMG_CLUB ) );
break;
}
}
}
//
// EjectBrass - tosses a brass shell from passed origin at passed velocity
//
2016-08-01 13:13:13 +02:00
void EjectBrass( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype )
2016-06-04 15:24:23 +02:00
{
// FIX: when the player shoots, their gun isn't in the same position as it is on the model other players see.
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin );
2016-08-01 13:13:13 +02:00
WRITE_BYTE( TE_MODEL );
WRITE_COORD( vecOrigin.x );
WRITE_COORD( vecOrigin.y );
WRITE_COORD( vecOrigin.z );
WRITE_COORD( vecVelocity.x );
WRITE_COORD( vecVelocity.y );
WRITE_COORD( vecVelocity.z );
2016-06-04 15:24:23 +02:00
WRITE_ANGLE( rotation );
WRITE_SHORT( model );
2016-08-01 13:13:13 +02:00
WRITE_BYTE( soundtype );
WRITE_BYTE( 25 );// 2.5 seconds
2016-06-04 15:24:23 +02:00
MESSAGE_END();
}
#if 0
// UNDONE: This is no longer used?
void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count )
{
MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin );
2016-08-01 13:13:13 +02:00
WRITE_BYTE( TE_EXPLODEMODEL );
2016-06-04 15:24:23 +02:00
WRITE_COORD( vecOrigin.x );
WRITE_COORD( vecOrigin.y );
WRITE_COORD( vecOrigin.z );
WRITE_COORD( speed );
WRITE_SHORT( model );
WRITE_SHORT( count );
2016-08-01 13:13:13 +02:00
WRITE_BYTE( 15 );// 1.5 seconds
2016-06-04 15:24:23 +02:00
MESSAGE_END();
}
#endif
int giAmmoIndex = 0;
// Precaches the ammo and queues the ammo info for sending to clients
void AddAmmoNameToAmmoRegistry( const char *szAmmoname )
{
// make sure it's not already in the registry
2016-08-01 13:13:13 +02:00
for( int i = 0; i < MAX_AMMO_SLOTS; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( !CBasePlayerItem::AmmoInfoArray[i].pszName)
2016-06-04 15:24:23 +02:00
continue;
2016-08-01 13:13:13 +02:00
if( stricmp( CBasePlayerItem::AmmoInfoArray[i].pszName, szAmmoname ) == 0 )
2016-06-04 15:24:23 +02:00
return; // ammo already in registry, just quite
}
giAmmoIndex++;
ASSERT( giAmmoIndex < MAX_AMMO_SLOTS );
2016-08-01 13:13:13 +02:00
if( giAmmoIndex >= MAX_AMMO_SLOTS )
2016-06-04 15:24:23 +02:00
giAmmoIndex = 0;
CBasePlayerItem::AmmoInfoArray[giAmmoIndex].pszName = szAmmoname;
CBasePlayerItem::AmmoInfoArray[giAmmoIndex].iId = giAmmoIndex; // yes, this info is redundant
}
// Precaches the weapon and queues the weapon info for sending to clients
void UTIL_PrecacheOtherWeapon( const char *szClassname )
{
edict_t *pent;
pent = CREATE_NAMED_ENTITY( MAKE_STRING( szClassname ) );
2016-08-01 13:13:13 +02:00
if( FNullEnt( pent ) )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
ALERT( at_console, "NULL Ent in UTIL_PrecacheOtherWeapon\n" );
2016-06-04 15:24:23 +02:00
return;
}
2016-08-01 13:13:13 +02:00
CBaseEntity *pEntity = CBaseEntity::Instance( VARS( pent ) );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( pEntity )
2016-06-04 15:24:23 +02:00
{
2016-08-02 13:59:22 +02:00
ItemInfo II = {0};
2016-08-01 13:13:13 +02:00
pEntity->Precache();
if( ( (CBasePlayerItem*)pEntity )->GetItemInfo( &II ) )
2016-06-04 15:24:23 +02:00
{
CBasePlayerItem::ItemInfoArray[II.iId] = II;
2016-08-01 13:13:13 +02:00
if( II.pszAmmo1 && *II.pszAmmo1 )
2016-06-04 15:24:23 +02:00
{
AddAmmoNameToAmmoRegistry( II.pszAmmo1 );
}
2016-08-01 13:13:13 +02:00
if( II.pszAmmo2 && *II.pszAmmo2 )
2016-06-04 15:24:23 +02:00
{
AddAmmoNameToAmmoRegistry( II.pszAmmo2 );
}
}
}
2016-08-01 13:13:13 +02:00
REMOVE_ENTITY( pent );
2016-06-04 15:24:23 +02:00
}
// called by worldspawn
2016-08-01 13:13:13 +02:00
void W_Precache( void )
2016-06-04 15:24:23 +02:00
{
memset( CBasePlayerItem::ItemInfoArray, 0, sizeof(CBasePlayerItem::ItemInfoArray) );
memset( CBasePlayerItem::AmmoInfoArray, 0, sizeof(CBasePlayerItem::AmmoInfoArray) );
giAmmoIndex = 0;
// custom items...
// common world objects
UTIL_PrecacheOther( "item_suit" );
UTIL_PrecacheOther( "item_healthkit" );
2016-06-04 15:24:23 +02:00
UTIL_PrecacheOther( "item_battery" );
UTIL_PrecacheOther( "item_antidote" );
UTIL_PrecacheOther( "item_security" );
UTIL_PrecacheOther( "item_longjump" );
// shotgun
UTIL_PrecacheOtherWeapon( "weapon_shotgun" );
UTIL_PrecacheOther( "ammo_buckshot" );
// crowbar
UTIL_PrecacheOtherWeapon( "weapon_crowbar" );
// glock
UTIL_PrecacheOtherWeapon( "weapon_9mmhandgun" );
UTIL_PrecacheOther( "ammo_9mmclip" );
// mp5
UTIL_PrecacheOtherWeapon( "weapon_9mmAR" );
UTIL_PrecacheOther( "ammo_9mmAR" );
UTIL_PrecacheOther( "ammo_ARgrenades" );
// 9mm ammo box
UTIL_PrecacheOther( "ammo_9mmbox" );
2021-06-07 16:17:22 +02:00
#if !OEM_BUILD && !HLDEMO_BUILD
2016-06-04 15:24:23 +02:00
// python
UTIL_PrecacheOtherWeapon( "weapon_357" );
UTIL_PrecacheOther( "ammo_357" );
2016-06-04 15:24:23 +02:00
// gauss
UTIL_PrecacheOtherWeapon( "weapon_gauss" );
UTIL_PrecacheOther( "ammo_gaussclip" );
// rpg
UTIL_PrecacheOtherWeapon( "weapon_rpg" );
UTIL_PrecacheOther( "ammo_rpgclip" );
// crossbow
UTIL_PrecacheOtherWeapon( "weapon_crossbow" );
UTIL_PrecacheOther( "ammo_crossbow" );
// egon
UTIL_PrecacheOtherWeapon( "weapon_egon" );
#endif
// tripmine
UTIL_PrecacheOtherWeapon( "weapon_tripmine" );
2021-06-07 16:17:22 +02:00
#if !OEM_BUILD && !HLDEMO_BUILD
2016-06-04 15:24:23 +02:00
// satchel charge
UTIL_PrecacheOtherWeapon( "weapon_satchel" );
#endif
// hand grenade
UTIL_PrecacheOtherWeapon("weapon_handgrenade");
2021-06-07 16:17:22 +02:00
#if !OEM_BUILD && !HLDEMO_BUILD
2016-06-04 15:24:23 +02:00
// squeak grenade
UTIL_PrecacheOtherWeapon( "weapon_snark" );
// hornetgun
UTIL_PrecacheOtherWeapon( "weapon_hornetgun" );
2016-08-01 13:13:13 +02:00
if( g_pGameRules->IsDeathmatch() )
2016-06-04 15:24:23 +02:00
{
UTIL_PrecacheOther( "weaponbox" );// container for dropped deathmatch weapons
}
#endif
2016-08-01 13:13:13 +02:00
g_sModelIndexFireball = PRECACHE_MODEL( "sprites/zerogxplode.spr" );// fireball
g_sModelIndexWExplosion = PRECACHE_MODEL( "sprites/WXplo1.spr" );// underwater fireball
g_sModelIndexSmoke = PRECACHE_MODEL( "sprites/steam1.spr" );// smoke
g_sModelIndexBubbles = PRECACHE_MODEL( "sprites/bubble.spr" );//bubbles
g_sModelIndexBloodSpray = PRECACHE_MODEL( "sprites/bloodspray.spr" ); // initial blood
g_sModelIndexBloodDrop = PRECACHE_MODEL( "sprites/blood.spr" ); // splattered blood
2016-06-04 15:24:23 +02:00
2017-07-23 23:24:55 +02:00
g_sModelIndexLaser = PRECACHE_MODEL( g_pModelNameLaser );
2016-08-01 13:13:13 +02:00
g_sModelIndexLaserDot = PRECACHE_MODEL( "sprites/laserdot.spr" );
2016-06-04 15:24:23 +02:00
// used by explosions
2016-08-01 13:13:13 +02:00
PRECACHE_MODEL( "models/grenade.mdl" );
PRECACHE_MODEL( "sprites/explode1.spr" );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
PRECACHE_SOUND( "weapons/debris1.wav" );// explosion aftermaths
PRECACHE_SOUND( "weapons/debris2.wav" );// explosion aftermaths
PRECACHE_SOUND( "weapons/debris3.wav" );// explosion aftermaths
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
PRECACHE_SOUND( "weapons/grenade_hit1.wav" );//grenade
PRECACHE_SOUND( "weapons/grenade_hit2.wav" );//grenade
PRECACHE_SOUND( "weapons/grenade_hit3.wav" );//grenade
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
PRECACHE_SOUND( "weapons/bullet_hit1.wav" ); // hit by bullet
PRECACHE_SOUND( "weapons/bullet_hit2.wav" ); // hit by bullet
PRECACHE_SOUND( "items/weapondrop1.wav" );// weapon falls to the ground
2016-06-04 15:24:23 +02:00
}
TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CBasePlayerItem, m_pPlayer, FIELD_CLASSPTR ),
DEFINE_FIELD( CBasePlayerItem, m_pNext, FIELD_CLASSPTR ),
//DEFINE_FIELD( CBasePlayerItem, m_fKnown, FIELD_INTEGER ),Reset to zero on load
DEFINE_FIELD( CBasePlayerItem, m_iId, FIELD_INTEGER ),
// DEFINE_FIELD( CBasePlayerItem, m_iIdPrimary, FIELD_INTEGER ),
// DEFINE_FIELD( CBasePlayerItem, m_iIdSecondary, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CBasePlayerItem, CBaseAnimating )
2016-06-04 15:24:23 +02:00
TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
2021-06-07 16:17:22 +02:00
#if CLIENT_WEAPONS
2016-06-04 15:24:23 +02:00
DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_FLOAT ),
DEFINE_FIELD( CBasePlayerWeapon, m_flNextSecondaryAttack, FIELD_FLOAT ),
DEFINE_FIELD( CBasePlayerWeapon, m_flTimeWeaponIdle, FIELD_FLOAT ),
#else // CLIENT_WEAPONS
DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_TIME ),
DEFINE_FIELD( CBasePlayerWeapon, m_flNextSecondaryAttack, FIELD_TIME ),
DEFINE_FIELD( CBasePlayerWeapon, m_flTimeWeaponIdle, FIELD_TIME ),
#endif // CLIENT_WEAPONS
DEFINE_FIELD( CBasePlayerWeapon, m_iPrimaryAmmoType, FIELD_INTEGER ),
DEFINE_FIELD( CBasePlayerWeapon, m_iSecondaryAmmoType, FIELD_INTEGER ),
DEFINE_FIELD( CBasePlayerWeapon, m_iClip, FIELD_INTEGER ),
DEFINE_FIELD( CBasePlayerWeapon, m_iDefaultAmmo, FIELD_INTEGER ),
2016-08-01 13:13:13 +02:00
//DEFINE_FIELD( CBasePlayerWeapon, m_iClientClip, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly
//DEFINE_FIELD( CBasePlayerWeapon, m_iClientWeaponState, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly
2016-06-04 15:24:23 +02:00
};
IMPLEMENT_SAVERESTORE( CBasePlayerWeapon, CBasePlayerItem )
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
void CBasePlayerItem::SetObjectCollisionBox( void )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
pev->absmin = pev->origin + Vector( -24, -24, 0 );
pev->absmax = pev->origin + Vector( 24, 24, 16 );
2016-06-04 15:24:23 +02:00
}
//=========================================================
// Sets up movetype, size, solidtype for a new weapon.
//=========================================================
2016-08-01 13:13:13 +02:00
void CBasePlayerItem::FallInit( void )
2016-06-04 15:24:23 +02:00
{
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_BBOX;
UTIL_SetOrigin( pev, pev->origin );
2016-08-01 13:13:13 +02:00
UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );//pointsize until it lands on the ground.
2016-06-04 15:24:23 +02:00
SetTouch( &CBasePlayerItem::DefaultTouch );
SetThink( &CBasePlayerItem::FallThink );
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
}
//=========================================================
// FallThink - Items that have just spawned run this think
// to catch them when they hit the ground. Once we're sure
// that the object is grounded, we change its solid type
// to trigger and set it in a large box that helps the
// player get it.
//=========================================================
2016-08-01 13:13:13 +02:00
void CBasePlayerItem::FallThink( void )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( pev->flags & FL_ONGROUND )
2016-06-04 15:24:23 +02:00
{
// clatter if we have an owner (i.e., dropped by someone)
// don't clatter if the gun is waiting to respawn (if it's waiting, it is invisible!)
2016-08-01 13:13:13 +02:00
if( !FNullEnt( pev->owner ) )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
int pitch = 95 + RANDOM_LONG( 0, 29 );
EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "items/weapondrop1.wav", 1, ATTN_NORM, 0, pitch );
2016-06-04 15:24:23 +02:00
}
// lie flat
pev->angles.x = 0;
pev->angles.z = 0;
Materialize();
}
}
//=========================================================
// Materialize - make a CBasePlayerItem visible and tangible
//=========================================================
void CBasePlayerItem::Materialize( void )
{
2016-08-01 13:13:13 +02:00
if( pev->effects & EF_NODRAW )
2016-06-04 15:24:23 +02:00
{
// changing from invisible state to visible.
2016-08-01 13:13:13 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 );
2016-06-04 15:24:23 +02:00
pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH;
}
pev->solid = SOLID_TRIGGER;
UTIL_SetOrigin( pev, pev->origin );// link into world.
SetTouch( &CBasePlayerItem::DefaultTouch );
2016-06-04 15:24:23 +02:00
SetThink( NULL );
}
//=========================================================
// AttemptToMaterialize - the item is trying to rematerialize,
// should it do so now or wait longer?
//=========================================================
void CBasePlayerItem::AttemptToMaterialize( void )
{
float time = g_pGameRules->FlWeaponTryRespawn( this );
2016-08-01 13:13:13 +02:00
if( time == 0 )
2016-06-04 15:24:23 +02:00
{
Materialize();
return;
}
pev->nextthink = gpGlobals->time + time;
}
//=========================================================
// CheckRespawn - a player is taking this weapon, should
// it respawn?
//=========================================================
2016-08-01 13:13:13 +02:00
void CBasePlayerItem::CheckRespawn( void )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
switch( g_pGameRules->WeaponShouldRespawn( this ) )
2016-06-04 15:24:23 +02:00
{
case GR_WEAPON_RESPAWN_YES:
Respawn();
break;
case GR_WEAPON_RESPAWN_NO:
return;
break;
}
}
//=========================================================
// Respawn- this item is already in the world, but it is
// invisible and intangible. Make it visible and tangible.
//=========================================================
CBaseEntity* CBasePlayerItem::Respawn( void )
{
// make a copy of this weapon that is invisible and inaccessible to players (no touch function). The weapon spawn/respawn code
// will decide when to make the weapon visible and touchable.
2017-07-23 23:24:55 +02:00
CBaseEntity *pNewWeapon = CBaseEntity::Create( STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( pNewWeapon )
2016-06-04 15:24:23 +02:00
{
pNewWeapon->pev->effects |= EF_NODRAW;// invisible for now
pNewWeapon->SetTouch( NULL );// no touch
pNewWeapon->SetThink( &CBasePlayerItem::AttemptToMaterialize );
2016-08-01 13:13:13 +02:00
DROP_TO_FLOOR( ENT( pev ) );
2016-06-04 15:24:23 +02:00
// not a typo! We want to know when the weapon the player just picked up should respawn! This new entity we created is the replacement,
// but when it should respawn is based on conditions belonging to the weapon that was taken.
pNewWeapon->pev->nextthink = g_pGameRules->FlWeaponRespawnTime( this );
}
else
{
2016-08-01 13:13:13 +02:00
ALERT( at_console, "Respawn failed to create %s!\n", STRING( pev->classname ) );
2016-06-04 15:24:23 +02:00
}
return pNewWeapon;
}
void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther )
{
// if it's not a player, ignore
2016-08-01 13:13:13 +02:00
if( !pOther->IsPlayer() )
2016-06-04 15:24:23 +02:00
return;
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
// can I have this?
2016-08-01 13:13:13 +02:00
if( !g_pGameRules->CanHavePlayerItem( pPlayer, this ) )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( gEvilImpulse101 )
2016-06-04 15:24:23 +02:00
{
UTIL_Remove( this );
}
return;
}
2016-08-01 13:13:13 +02:00
if( pOther->AddPlayerItem( this ) )
2016-06-04 15:24:23 +02:00
{
AttachToPlayer( pPlayer );
2016-08-01 13:13:13 +02:00
EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
}
SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen?
}
BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted )
{
2021-06-07 16:17:22 +02:00
#if CLIENT_WEAPONS
2016-08-01 13:13:13 +02:00
if( !isPredicted )
2016-06-04 15:24:23 +02:00
#else
2016-08-01 13:13:13 +02:00
if( 1 )
2016-06-04 15:24:23 +02:00
#endif
{
return ( attack_time <= curtime ) ? TRUE : FALSE;
}
else
{
2021-02-10 18:21:45 +01:00
return ( (static_cast<int>(::floor(attack_time * 1000.0f)) * 1000.0f) <= 0.0f) ? TRUE : FALSE;
2016-06-04 15:24:23 +02:00
}
}
void CBasePlayerWeapon::ItemPostFrame( void )
{
2016-08-01 13:13:13 +02:00
if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
2016-06-04 15:24:23 +02:00
{
// complete the reload.
2017-10-14 21:57:55 +02:00
int j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
2016-06-04 15:24:23 +02:00
// Add them to the clip
m_iClip += j;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j;
m_pPlayer->TabulateAmmo();
m_fInReload = FALSE;
}
if( !(m_pPlayer->pev->button & IN_ATTACK ) )
{
m_flLastFireTime = 0.0f;
}
2016-08-01 13:13:13 +02:00
if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] )
2016-06-04 15:24:23 +02:00
{
m_fFireOnEmpty = TRUE;
}
m_pPlayer->TabulateAmmo();
SecondaryAttack();
m_pPlayer->pev->button &= ~IN_ATTACK2;
}
2016-08-01 13:13:13 +02:00
else if( ( m_pPlayer->pev->button & IN_ATTACK ) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) )
2016-06-04 15:24:23 +02:00
{
m_fFireOnEmpty = TRUE;
}
m_pPlayer->TabulateAmmo();
PrimaryAttack();
}
2016-08-01 13:13:13 +02:00
else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload )
2016-06-04 15:24:23 +02:00
{
// reload when reload is pressed, or if no buttons are down and weapon is empty.
Reload();
}
2016-08-01 13:13:13 +02:00
else if( !( m_pPlayer->pev->button & ( IN_ATTACK | IN_ATTACK2 ) ) )
2016-06-04 15:24:23 +02:00
{
// no fire buttons down
m_fFireOnEmpty = FALSE;
2019-10-13 13:49:25 +02:00
if( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0f : gpGlobals->time ) )
2016-06-04 15:24:23 +02:00
{
// weapon isn't useable, switch.
2016-08-01 13:13:13 +02:00
if( !( iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY ) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) )
2016-06-04 15:24:23 +02:00
{
2019-10-13 13:49:25 +02:00
m_flNextPrimaryAttack = ( UseDecrement() ? 0.0f : gpGlobals->time ) + 0.3f;
2016-06-04 15:24:23 +02:00
return;
}
}
else
{
// weapon is useable. Reload if empty and weapon has waited as long as it has to after firing
2019-10-13 13:49:25 +02:00
if( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0f : gpGlobals->time ) )
2016-06-04 15:24:23 +02:00
{
Reload();
return;
}
}
2016-08-01 13:13:13 +02:00
WeaponIdle();
2016-06-04 15:24:23 +02:00
return;
}
2016-06-04 15:24:23 +02:00
// catch all
2016-08-01 13:13:13 +02:00
if( ShouldWeaponIdle() )
2016-06-04 15:24:23 +02:00
{
WeaponIdle();
}
}
void CBasePlayerItem::DestroyItem( void )
{
2016-08-01 13:13:13 +02:00
if( m_pPlayer )
2016-06-04 15:24:23 +02:00
{
// if attached to a player, remove.
m_pPlayer->RemovePlayerItem( this, false );
2016-06-04 15:24:23 +02:00
}
2016-08-01 13:13:13 +02:00
Kill();
2016-06-04 15:24:23 +02:00
}
int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer )
{
m_pPlayer = pPlayer;
return TRUE;
}
void CBasePlayerItem::Drop( void )
{
SetTouch( NULL );
2016-08-01 13:13:13 +02:00
SetThink( &CBaseEntity::SUB_Remove );
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
}
void CBasePlayerItem::Kill( void )
{
SetTouch( NULL );
2016-08-01 13:13:13 +02:00
SetThink( &CBaseEntity::SUB_Remove );
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
}
void CBasePlayerItem::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->pev->viewmodel = 0;
m_pPlayer->pev->weaponmodel = 0;
}
2016-08-01 13:13:13 +02:00
void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer )
2016-06-04 15:24:23 +02:00
{
pev->movetype = MOVETYPE_FOLLOW;
pev->solid = SOLID_NOT;
pev->aiment = pPlayer->edict();
pev->effects = EF_NODRAW; // ??
pev->modelindex = 0;// server won't send down to clients if modelindex == 0
pev->model = iStringNull;
pev->owner = pPlayer->edict();
pev->nextthink = 0;// Remove think - prevents futher attempts to materialize
2016-06-04 15:24:23 +02:00
SetTouch( NULL );
SetThink( NULL );
}
// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal
int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal )
{
2016-08-01 13:13:13 +02:00
if( m_iDefaultAmmo )
2016-06-04 15:24:23 +02:00
{
return ExtractAmmo( (CBasePlayerWeapon *)pOriginal );
}
else
{
// a dead player dropped this.
return ExtractClipAmmo( (CBasePlayerWeapon *)pOriginal );
}
}
int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer )
{
int bResult = CBasePlayerItem::AddToPlayer( pPlayer );
2016-08-01 13:13:13 +02:00
pPlayer->pev->weapons |= ( 1 << m_iId );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( !m_iPrimaryAmmoType )
2016-06-04 15:24:23 +02:00
{
m_iPrimaryAmmoType = pPlayer->GetAmmoIndex( pszAmmo1() );
m_iSecondaryAmmoType = pPlayer->GetAmmoIndex( pszAmmo2() );
}
2016-08-01 13:13:13 +02:00
if( bResult )
return AddWeapon();
2016-06-04 15:24:23 +02:00
return FALSE;
}
int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer )
{
BOOL bSend = FALSE;
int state = 0;
2016-08-01 13:13:13 +02:00
if( pPlayer->m_pActiveItem == this )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( pPlayer->m_fOnTarget )
2016-06-04 15:24:23 +02:00
state = WEAPON_IS_ONTARGET;
else
state = 1;
}
// Forcing send of all data!
2016-08-01 13:13:13 +02:00
if( !pPlayer->m_fWeapon )
2016-06-04 15:24:23 +02:00
{
bSend = TRUE;
}
2016-08-01 13:13:13 +02:00
2016-06-04 15:24:23 +02:00
// This is the current or last weapon, so the state will need to be updated
2016-08-01 13:13:13 +02:00
if( this == pPlayer->m_pActiveItem || this == pPlayer->m_pClientActiveItem )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( pPlayer->m_pActiveItem != pPlayer->m_pClientActiveItem )
2016-06-04 15:24:23 +02:00
{
bSend = TRUE;
}
}
// If the ammo, state, or fov has changed, update the weapon
2016-08-01 13:13:13 +02:00
if( m_iClip != m_iClientClip || state != m_iClientWeaponState || pPlayer->m_iFOV != pPlayer->m_iClientFOV )
2016-06-04 15:24:23 +02:00
{
bSend = TRUE;
}
2016-08-01 13:13:13 +02:00
if( bSend )
2016-06-04 15:24:23 +02:00
{
MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev );
WRITE_BYTE( state );
WRITE_BYTE( m_iId );
WRITE_BYTE( m_iClip );
MESSAGE_END();
m_iClientClip = m_iClip;
m_iClientWeaponState = state;
pPlayer->m_fWeapon = TRUE;
}
2016-08-01 13:13:13 +02:00
if( m_pNext )
2016-06-04 15:24:23 +02:00
m_pNext->UpdateClientData( pPlayer );
return 1;
}
void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body )
{
2016-08-01 13:13:13 +02:00
if( UseDecrement() )
2016-06-04 15:24:23 +02:00
skiplocal = 1;
else
skiplocal = 0;
m_pPlayer->pev->weaponanim = iAnim;
2021-06-07 16:17:22 +02:00
#if CLIENT_WEAPONS
2016-08-01 13:13:13 +02:00
if( skiplocal && ENGINE_CANSKIP( m_pPlayer->edict() ) )
2016-06-04 15:24:23 +02:00
return;
#endif
MESSAGE_BEGIN( MSG_ONE, SVC_WEAPONANIM, NULL, m_pPlayer->pev );
2016-08-01 13:13:13 +02:00
WRITE_BYTE( iAnim ); // sequence number
WRITE_BYTE( pev->body ); // weaponmodel bodygroup.
2016-06-04 15:24:23 +02:00
MESSAGE_END();
}
2016-08-01 13:13:13 +02:00
BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry )
2016-06-04 15:24:23 +02:00
{
int iIdAmmo;
2016-08-01 13:13:13 +02:00
if( iMaxClip < 1 )
2016-06-04 15:24:23 +02:00
{
m_iClip = -1;
iIdAmmo = m_pPlayer->GiveAmmo( iCount, szName, iMaxCarry );
}
2016-08-01 13:13:13 +02:00
else if( m_iClip == 0 )
2016-06-04 15:24:23 +02:00
{
int i;
2017-10-14 21:57:55 +02:00
i = Q_min( m_iClip + iCount, iMaxClip ) - m_iClip;
2016-06-04 15:24:23 +02:00
m_iClip += i;
iIdAmmo = m_pPlayer->GiveAmmo( iCount - i, szName, iMaxCarry );
}
else
{
iIdAmmo = m_pPlayer->GiveAmmo( iCount, szName, iMaxCarry );
}
2016-06-04 15:24:23 +02:00
// m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = iMaxCarry; // hack for testing
2016-08-01 13:13:13 +02:00
if( iIdAmmo > 0 )
2016-06-04 15:24:23 +02:00
{
m_iPrimaryAmmoType = iIdAmmo;
2016-08-01 13:13:13 +02:00
if( m_pPlayer->HasPlayerItem( this ) )
2016-06-04 15:24:23 +02:00
{
// play the "got ammo" sound only if we gave some ammo to a player that already had this gun.
// if the player is just getting this gun for the first time, DefaultTouch will play the "picked up gun" sound for us.
2016-08-01 13:13:13 +02:00
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
}
}
return iIdAmmo > 0 ? TRUE : FALSE;
}
2016-08-01 13:13:13 +02:00
BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax )
2016-06-04 15:24:23 +02:00
{
int iIdAmmo;
iIdAmmo = m_pPlayer->GiveAmmo( iCount, szName, iMax );
//m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] = iMax; // hack for testing
2016-08-01 13:13:13 +02:00
if( iIdAmmo > 0 )
2016-06-04 15:24:23 +02:00
{
m_iSecondaryAmmoType = iIdAmmo;
2016-08-01 13:13:13 +02:00
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
2016-06-04 15:24:23 +02:00
}
return iIdAmmo > 0 ? TRUE : FALSE;
}
//=========================================================
// IsUseable - this function determines whether or not a
// weapon is useable by the player in its current state.
// (does it have ammo loaded? do I have any ammo for the
// weapon?, etc)
//=========================================================
2016-08-01 13:13:13 +02:00
BOOL CBasePlayerWeapon::IsUseable( void )
2016-06-04 15:24:23 +02:00
{
if( m_iClip > 0 )
{
return TRUE;
}
// Player has unlimited ammo for this weapon or does not use magazines
if( iMaxAmmo1() == WEAPON_NOCLIP )
2016-06-04 15:24:23 +02:00
{
return TRUE;
}
if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 )
{
return TRUE;
}
if( pszAmmo2() )
{
// Player has unlimited ammo for this weapon or does not use magazines
if( iMaxAmmo2() == WEAPON_NOCLIP )
2016-06-04 15:24:23 +02:00
{
return TRUE;
}
if( m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] > 0 )
{
return TRUE;
2016-06-04 15:24:23 +02:00
}
}
// clip is empty (or nonexistant) and the player has no more ammo of this type.
return FALSE;
2016-06-04 15:24:23 +02:00
}
2016-08-01 13:13:13 +02:00
BOOL CBasePlayerWeapon::CanDeploy( void )
2016-06-04 15:24:23 +02:00
{
BOOL bHasAmmo = 0;
2016-08-01 13:13:13 +02:00
if( !pszAmmo1() )
2016-06-04 15:24:23 +02:00
{
// this weapon doesn't use ammo, can always deploy.
return TRUE;
}
2016-08-01 13:13:13 +02:00
if( pszAmmo1() )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0 );
2016-06-04 15:24:23 +02:00
}
2016-08-01 13:13:13 +02:00
if( pszAmmo2() )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0 );
2016-06-04 15:24:23 +02:00
}
2016-08-01 13:13:13 +02:00
if( m_iClip > 0 )
2016-06-04 15:24:23 +02:00
{
bHasAmmo |= 1;
}
2016-08-01 13:13:13 +02:00
if( !bHasAmmo )
2016-06-04 15:24:23 +02:00
{
return FALSE;
}
return TRUE;
}
2017-07-01 23:36:56 +02:00
BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal /* = 0 */, int body )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( !CanDeploy() )
2016-06-04 15:24:23 +02:00
return FALSE;
m_pPlayer->TabulateAmmo();
2016-08-01 13:13:13 +02:00
m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel );
m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel );
2016-06-04 15:24:23 +02:00
strcpy( m_pPlayer->m_szAnimExtention, szAnimExt );
SendWeaponAnim( iAnim, skiplocal, body );
2019-10-13 13:49:25 +02:00
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f;
m_flLastFireTime = 0.0f;
2016-06-04 15:24:23 +02:00
return TRUE;
}
2016-08-01 13:13:13 +02:00
BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, int body )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
2016-06-04 15:24:23 +02:00
return FALSE;
2017-10-14 21:57:55 +02:00
int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( j == 0 )
2016-06-04 15:24:23 +02:00
return FALSE;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay;
//!!UNDONE -- reload sound goes here !!!
SendWeaponAnim( iAnim, UseDecrement() ? 1 : 0 );
m_fInReload = TRUE;
2019-10-13 13:49:25 +02:00
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0f;
2016-06-04 15:24:23 +02:00
return TRUE;
}
2016-08-01 13:13:13 +02:00
BOOL CBasePlayerWeapon::PlayEmptySound( void )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( m_iPlayEmptySound )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM );
2016-06-04 15:24:23 +02:00
m_iPlayEmptySound = 0;
return 0;
}
return 0;
}
2016-08-01 13:13:13 +02:00
void CBasePlayerWeapon::ResetEmptySound( void )
2016-06-04 15:24:23 +02:00
{
m_iPlayEmptySound = 1;
}
//=========================================================
//=========================================================
int CBasePlayerWeapon::PrimaryAmmoIndex( void )
{
return m_iPrimaryAmmoType;
}
//=========================================================
//=========================================================
int CBasePlayerWeapon::SecondaryAmmoIndex( void )
{
return -1;
}
void CBasePlayerWeapon::Holster( int skiplocal /* = 0 */ )
{
m_fInReload = FALSE; // cancel any reload in progress.
m_pPlayer->pev->viewmodel = 0;
m_pPlayer->pev->weaponmodel = 0;
}
void CBasePlayerAmmo::Spawn( void )
{
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER;
2016-08-01 13:13:13 +02:00
UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 16 ) );
2016-06-04 15:24:23 +02:00
UTIL_SetOrigin( pev, pev->origin );
SetTouch( &CBasePlayerAmmo::DefaultTouch );
}
CBaseEntity* CBasePlayerAmmo::Respawn( void )
{
pev->effects |= EF_NODRAW;
SetTouch( NULL );
UTIL_SetOrigin( pev, g_pGameRules->VecAmmoRespawnSpot( this ) );// move to wherever I'm supposed to repawn.
SetThink( &CBasePlayerAmmo::Materialize );
pev->nextthink = g_pGameRules->FlAmmoRespawnTime( this );
return this;
}
void CBasePlayerAmmo::Materialize( void )
{
2016-08-01 13:13:13 +02:00
if( pev->effects & EF_NODRAW )
2016-06-04 15:24:23 +02:00
{
// changing from invisible state to visible.
2016-08-01 13:13:13 +02:00
EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 );
2016-06-04 15:24:23 +02:00
pev->effects &= ~EF_NODRAW;
pev->effects |= EF_MUZZLEFLASH;
}
SetTouch( &CBasePlayerAmmo::DefaultTouch );
SetThink( NULL );
2016-06-04 15:24:23 +02:00
}
2016-08-01 13:13:13 +02:00
void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( !pOther->IsPlayer() )
2016-06-04 15:24:23 +02:00
{
return;
}
2016-08-01 13:13:13 +02:00
if( AddAmmo( pOther ) )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES )
2016-06-04 15:24:23 +02:00
{
Respawn();
}
else
{
SetTouch( NULL );
2016-08-01 13:13:13 +02:00
SetThink( &CBaseEntity::SUB_Remove );
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
}
}
2016-08-01 13:13:13 +02:00
else if( gEvilImpulse101 )
2016-06-04 15:24:23 +02:00
{
// evil impulse 101 hack, kill always
SetTouch( NULL );
2016-08-01 13:13:13 +02:00
SetThink( &CBaseEntity::SUB_Remove );
2019-10-13 13:49:25 +02:00
pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
}
}
//=========================================================
// called by the new item with the existing item as parameter
//
// if we call ExtractAmmo(), it's because the player is picking up this type of weapon for
// the first time. If it is spawned by the world, m_iDefaultAmmo will have a default ammo amount in it.
// if this is a weapon dropped by a dying player, has 0 m_iDefaultAmmo, which means only the ammo in
// the weapon clip comes along.
//=========================================================
int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon )
{
2017-01-10 10:09:44 +01:00
int iReturn = 0;
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( pszAmmo1() != NULL )
2016-06-04 15:24:23 +02:00
{
// blindly call with m_iDefaultAmmo. It's either going to be a value or zero. If it is zero,
// we only get the ammo in the weapon's clip, which is what we want.
iReturn |= pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, (char *)pszAmmo1(), iMaxClip(), iMaxAmmo1() );
2016-06-04 15:24:23 +02:00
m_iDefaultAmmo = 0;
}
2016-08-01 13:13:13 +02:00
if( pszAmmo2() != NULL )
2016-06-04 15:24:23 +02:00
{
iReturn |= pWeapon->AddSecondaryAmmo( 0, (char *)pszAmmo2(), iMaxAmmo2() );
2016-06-04 15:24:23 +02:00
}
return iReturn;
}
//=========================================================
// called by the new item's class with the existing item as parameter
//=========================================================
int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon )
{
2016-08-01 13:13:13 +02:00
int iAmmo;
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( m_iClip == WEAPON_NOCLIP )
2016-06-04 15:24:23 +02:00
{
iAmmo = 0;// guns with no clips always come empty if they are second-hand
}
else
{
iAmmo = m_iClip;
}
2016-08-01 13:13:13 +02:00
2016-06-04 15:24:23 +02:00
return pWeapon->m_pPlayer->GiveAmmo( iAmmo, (char *)pszAmmo1(), iMaxAmmo1() ); // , &m_iPrimaryAmmoType
}
//=========================================================
// RetireWeapon - no more ammo for this gun, put it away.
//=========================================================
void CBasePlayerWeapon::RetireWeapon( void )
{
// first, no viewmodel at all.
m_pPlayer->pev->viewmodel = iStringNull;
m_pPlayer->pev->weaponmodel = iStringNull;
//m_pPlayer->pev->viewmodelindex = NULL;
if( !g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) )
{
// Another weapon wasn't selected. Get rid of current one
if( m_pPlayer->m_pActiveItem == this )
{
m_pPlayer->ResetAutoaim();
m_pPlayer->m_pActiveItem->Holster();
m_pPlayer->m_pLastItem = NULL;
m_pPlayer->m_pActiveItem = NULL;
}
}
2016-06-04 15:24:23 +02:00
}
//=========================================================================
// GetNextAttackDelay - An accurate way of calcualting the next attack time.
//=========================================================================
float CBasePlayerWeapon::GetNextAttackDelay( float delay )
{
2019-10-13 13:49:25 +02:00
if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1.0f )
{
// At this point, we are assuming that the client has stopped firing
// and we are going to reset our book keeping variables.
m_flLastFireTime = gpGlobals->time;
m_flPrevPrimaryAttack = delay;
}
// calculate the time between this shot and the previous
float flTimeBetweenFires = gpGlobals->time - m_flLastFireTime;
float flCreep = 0.0f;
if( flTimeBetweenFires > 0 )
flCreep = flTimeBetweenFires - m_flPrevPrimaryAttack; // postive or negative
// save the last fire time
m_flLastFireTime = gpGlobals->time;
float flNextAttack = UTIL_WeaponTimeBase() + delay - flCreep;
// we need to remember what the m_flNextPrimaryAttack time is set to for each shot,
// store it as m_flPrevPrimaryAttack.
m_flPrevPrimaryAttack = flNextAttack - UTIL_WeaponTimeBase();
//char szMsg[256];
//_snprintf( szMsg, sizeof(szMsg), "next attack time: %0.4f\n", gpGlobals->time + flNextAttack );
//OutputDebugString( szMsg );
return flNextAttack;
}
2016-06-04 15:24:23 +02:00
//*********************************************************
// weaponbox code:
//*********************************************************
LINK_ENTITY_TO_CLASS( weaponbox, CWeaponBox )
2016-06-04 15:24:23 +02:00
TYPEDESCRIPTION CWeaponBox::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_ARRAY( CWeaponBox, m_rgAmmo, FIELD_INTEGER, MAX_AMMO_SLOTS ),
DEFINE_ARRAY( CWeaponBox, m_rgiszAmmo, FIELD_STRING, MAX_AMMO_SLOTS ),
DEFINE_ARRAY( CWeaponBox, m_rgpPlayerItems, FIELD_CLASSPTR, MAX_ITEM_TYPES ),
DEFINE_FIELD( CWeaponBox, m_cAmmoTypes, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CWeaponBox, CBaseEntity )
2016-06-04 15:24:23 +02:00
//=========================================================
//
//=========================================================
void CWeaponBox::Precache( void )
{
2016-08-01 13:13:13 +02:00
PRECACHE_MODEL( "models/w_weaponbox.mdl" );
2016-06-04 15:24:23 +02:00
}
//=========================================================
//=========================================================
2016-08-01 13:13:13 +02:00
void CWeaponBox::KeyValue( KeyValueData *pkvd )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( m_cAmmoTypes < MAX_AMMO_SLOTS )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
PackAmmo( ALLOC_STRING( pkvd->szKeyName ), atoi( pkvd->szValue ) );
2016-06-04 15:24:23 +02:00
m_cAmmoTypes++;// count this new ammo type.
pkvd->fHandled = TRUE;
}
else
{
2016-08-01 13:13:13 +02:00
ALERT( at_console, "WeaponBox too full! only %d ammotypes allowed\n", MAX_AMMO_SLOTS );
2016-06-04 15:24:23 +02:00
}
}
//=========================================================
// CWeaponBox - Spawn
//=========================================================
void CWeaponBox::Spawn( void )
{
2016-08-01 13:13:13 +02:00
Precache();
2016-06-04 15:24:23 +02:00
pev->movetype = MOVETYPE_TOSS;
pev->solid = SOLID_TRIGGER;
UTIL_SetSize( pev, g_vecZero, g_vecZero );
2016-08-01 13:13:13 +02:00
SET_MODEL( ENT( pev ), "models/w_weaponbox.mdl" );
2016-06-04 15:24:23 +02:00
}
//=========================================================
// CWeaponBox - Kill - the think function that removes the
// box from the world.
//=========================================================
void CWeaponBox::Kill( void )
{
CBasePlayerItem *pWeapon;
int i;
// destroy the weapons
2016-08-01 13:13:13 +02:00
for( i = 0; i < MAX_ITEM_TYPES; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
pWeapon = m_rgpPlayerItems[i];
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
while( pWeapon )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
pWeapon->SetThink( &CBaseEntity::SUB_Remove );
2019-10-13 13:49:25 +02:00
pWeapon->pev->nextthink = gpGlobals->time + 0.1f;
2016-06-04 15:24:23 +02:00
pWeapon = pWeapon->m_pNext;
}
}
// remove the box
UTIL_Remove( this );
}
static const char* IsAmmoForExhaustibleWeapon(const char* ammoName, int& weaponId)
{
for (int i=0; i<MAX_WEAPONS; ++i) {
ItemInfo& II = CBasePlayerItem::ItemInfoArray[i];
if ((II.iFlags & ITEM_FLAG_EXHAUSTIBLE) && II.pszAmmo1 && FStrEq(ammoName, II.pszAmmo1)) {
weaponId = II.iId;
return II.pszName;
}
}
return 0;
}
2016-06-04 15:24:23 +02:00
//=========================================================
// CWeaponBox - Touch: try to add my contents to the toucher
// if the toucher is a player.
//=========================================================
void CWeaponBox::Touch( CBaseEntity *pOther )
{
2016-08-01 13:13:13 +02:00
if( !( pev->flags & FL_ONGROUND ) )
2016-06-04 15:24:23 +02:00
{
return;
}
2016-08-01 13:13:13 +02:00
if( !pOther->IsPlayer() )
2016-06-04 15:24:23 +02:00
{
// only players may touch a weaponbox.
return;
}
2016-08-01 13:13:13 +02:00
if( !pOther->IsAlive() )
2016-06-04 15:24:23 +02:00
{
// no dead guys.
return;
}
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
int i;
// dole out ammo
2016-08-01 13:13:13 +02:00
for( i = 0; i < MAX_AMMO_SLOTS; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( !FStringNull( m_rgiszAmmo[i] ) )
2016-06-04 15:24:23 +02:00
{
// horrific HACK to give player an exhaustible weapon as a real weapon, not just ammo
int exhaustibleWeaponId;
const char* weaponName = IsAmmoForExhaustibleWeapon(STRING(m_rgiszAmmo[i]), exhaustibleWeaponId);
if (weaponName) {
bool foundWeapon = false;
for( int j = 0; j < MAX_ITEM_TYPES && !foundWeapon; j++ )
{
CBasePlayerItem *pPlayerItem = pPlayer->m_rgpPlayerItems[j];
while( pPlayerItem )
{
if (pPlayerItem->m_iId == exhaustibleWeaponId) {
foundWeapon = true;
break;
}
pPlayerItem = pPlayerItem->m_pNext;
}
}
if (!foundWeapon) {
CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)Create(weaponName, pev->origin, pev->angles);
if (weapon) {
weapon->pev->spawnflags |= SF_NORESPAWN;
weapon->m_iDefaultAmmo = 0;
if (pPlayer->AddPlayerItem(weapon)) {
weapon->AttachToPlayer(pPlayer);
}
}
}
}
2016-06-04 15:24:23 +02:00
// there's some ammo of this type.
2017-07-23 23:24:55 +02:00
pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
//ALERT( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING( m_rgiszAmmo[i] ) );
2016-06-04 15:24:23 +02:00
// now empty the ammo from the weaponbox since we just gave it to the player
2016-08-01 13:13:13 +02:00
m_rgiszAmmo[i] = iStringNull;
m_rgAmmo[i] = 0;
2016-06-04 15:24:23 +02:00
}
}
// go through my weapons and try to give the usable ones to the player.
// it's important the the player be given ammo first, so the weapons code doesn't refuse
// to deploy a better weapon that the player may pick up because he has no ammo for it.
2016-08-01 13:13:13 +02:00
for( i = 0; i < MAX_ITEM_TYPES; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( m_rgpPlayerItems[i] )
2016-06-04 15:24:23 +02:00
{
CBasePlayerItem *pItem;
// have at least one weapon in this slot
2016-08-01 13:13:13 +02:00
while( m_rgpPlayerItems[i] )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
//ALERT( at_console, "trying to give %s\n", STRING( m_rgpPlayerItems[i]->pev->classname ) );
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
pItem = m_rgpPlayerItems[i];
m_rgpPlayerItems[i] = m_rgpPlayerItems[i]->m_pNext;// unlink this weapon from the box
2016-06-04 15:24:23 +02:00
2016-08-01 13:13:13 +02:00
if( pPlayer->AddPlayerItem( pItem ) )
2016-06-04 15:24:23 +02:00
{
pItem->AttachToPlayer( pPlayer );
}
}
}
}
EMIT_SOUND( pOther->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
SetTouch( NULL );
UTIL_Remove(this);
}
//=========================================================
// CWeaponBox - PackWeapon: Add this weapon to the box
//=========================================================
BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon )
{
// is one of these weapons already packed in this box?
2016-08-01 13:13:13 +02:00
if( HasWeapon( pWeapon ) )
2016-06-04 15:24:23 +02:00
{
return FALSE;// box can only hold one of each weapon type
}
2016-08-01 13:13:13 +02:00
if( pWeapon->m_pPlayer )
2016-06-04 15:24:23 +02:00
{
if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon, true ) )
2016-06-04 15:24:23 +02:00
{
// failed to unhook the weapon from the player!
return FALSE;
}
}
int iWeaponSlot = pWeapon->iItemSlot();
2016-08-01 13:13:13 +02:00
if( m_rgpPlayerItems[iWeaponSlot] )
2016-06-04 15:24:23 +02:00
{
// there's already one weapon in this slot, so link this into the slot's column
2016-08-01 13:13:13 +02:00
pWeapon->m_pNext = m_rgpPlayerItems[iWeaponSlot];
m_rgpPlayerItems[iWeaponSlot] = pWeapon;
2016-06-04 15:24:23 +02:00
}
else
{
// first weapon we have for this slot
2016-08-01 13:13:13 +02:00
m_rgpPlayerItems[iWeaponSlot] = pWeapon;
2016-06-04 15:24:23 +02:00
pWeapon->m_pNext = NULL;
}
pWeapon->pev->spawnflags |= SF_NORESPAWN;// never respawn
pWeapon->pev->movetype = MOVETYPE_NONE;
pWeapon->pev->solid = SOLID_NOT;
pWeapon->pev->effects = EF_NODRAW;
pWeapon->pev->modelindex = 0;
pWeapon->pev->model = iStringNull;
pWeapon->pev->owner = edict();
pWeapon->SetThink( NULL );// crowbar may be trying to swing again, etc.
pWeapon->SetTouch( NULL );
pWeapon->m_pPlayer = NULL;
2016-08-01 13:13:13 +02:00
//ALERT( at_console, "packed %s\n", STRING( pWeapon->pev->classname ) );
2016-06-04 15:24:23 +02:00
return TRUE;
}
//=========================================================
// CWeaponBox - PackAmmo
//=========================================================
BOOL CWeaponBox::PackAmmo( int iszName, int iCount )
{
int iMaxCarry;
2016-08-01 13:13:13 +02:00
if( FStringNull( iszName ) )
2016-06-04 15:24:23 +02:00
{
// error here
2016-08-01 13:13:13 +02:00
ALERT( at_console, "NULL String in PackAmmo!\n" );
2016-06-04 15:24:23 +02:00
return FALSE;
}
2016-06-04 15:24:23 +02:00
iMaxCarry = MaxAmmoCarry( iszName );
2016-08-01 13:13:13 +02:00
if( iMaxCarry != -1 && iCount > 0 )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
//ALERT( at_console, "Packed %d rounds of %s\n", iCount, STRING( iszName ) );
2017-07-23 23:24:55 +02:00
GiveAmmo( iCount, STRING( iszName ), iMaxCarry );
2016-06-04 15:24:23 +02:00
return TRUE;
}
return FALSE;
}
//=========================================================
// CWeaponBox - GiveAmmo
//=========================================================
2017-06-29 15:56:03 +02:00
int CWeaponBox::GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex/* = NULL*/ )
2016-06-04 15:24:23 +02:00
{
int i;
2016-08-01 13:13:13 +02:00
for( i = 1; i < MAX_AMMO_SLOTS && !FStringNull( m_rgiszAmmo[i] ); i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( stricmp( szName, STRING( m_rgiszAmmo[i] ) ) == 0 )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( pIndex )
2016-06-04 15:24:23 +02:00
*pIndex = i;
2017-10-14 21:57:55 +02:00
int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] );
2016-08-01 13:13:13 +02:00
if( iCount == 0 || iAdd > 0 )
2016-06-04 15:24:23 +02:00
{
m_rgAmmo[i] += iAdd;
return i;
}
return -1;
}
}
2016-08-01 13:13:13 +02:00
if( i < MAX_AMMO_SLOTS )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( pIndex )
2016-06-04 15:24:23 +02:00
*pIndex = i;
m_rgiszAmmo[i] = MAKE_STRING( szName );
m_rgAmmo[i] = iCount;
return i;
}
2016-08-01 13:13:13 +02:00
ALERT( at_console, "out of named ammo slots\n" );
2016-06-04 15:24:23 +02:00
return i;
}
//=========================================================
// CWeaponBox::HasWeapon - is a weapon of this type already
// packed in this box?
//=========================================================
BOOL CWeaponBox::HasWeapon( CBasePlayerItem *pCheckItem )
{
CBasePlayerItem *pItem = m_rgpPlayerItems[pCheckItem->iItemSlot()];
2016-08-01 13:13:13 +02:00
while( pItem )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( FClassnameIs( pItem->pev, STRING( pCheckItem->pev->classname ) ) )
2016-06-04 15:24:23 +02:00
{
return TRUE;
}
pItem = pItem->m_pNext;
}
return FALSE;
}
//=========================================================
// CWeaponBox::IsEmpty - is there anything in this box?
//=========================================================
BOOL CWeaponBox::IsEmpty( void )
{
int i;
2016-08-01 13:13:13 +02:00
for( i = 0; i < MAX_ITEM_TYPES; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( m_rgpPlayerItems[i] )
2016-06-04 15:24:23 +02:00
{
return FALSE;
}
}
2016-08-01 13:13:13 +02:00
for( i = 0; i < MAX_AMMO_SLOTS; i++ )
2016-06-04 15:24:23 +02:00
{
2016-08-01 13:13:13 +02:00
if( !FStringNull( m_rgiszAmmo[i] ) )
2016-06-04 15:24:23 +02:00
{
// still have a bit of this type of ammo
return FALSE;
}
}
return TRUE;
}
//=========================================================
//=========================================================
void CWeaponBox::SetObjectCollisionBox( void )
{
2016-08-01 13:13:13 +02:00
pev->absmin = pev->origin + Vector( -16, -16, 0 );
pev->absmax = pev->origin + Vector( 16, 16, 16 );
2016-06-04 15:24:23 +02:00
}
void CBasePlayerWeapon::PrintState( void )
{
2019-10-13 13:49:25 +02:00
ALERT( at_console, "primary: %f\n", (double)m_flNextPrimaryAttack );
ALERT( at_console, "idle : %f\n", (double)m_flTimeWeaponIdle );
2016-06-04 15:24:23 +02:00
//ALERT( at_console, "nextrl : %f\n", m_flNextReload );
//ALERT( at_console, "nextpum: %f\n", m_flPumpTime );
2016-06-04 15:24:23 +02:00
//ALERT( at_console, "m_frt : %f\n", m_fReloadTime );
2016-06-04 15:24:23 +02:00
ALERT( at_console, "m_finre: %i\n", m_fInReload );
//ALERT( at_console, "m_finsr: %i\n", m_fInSpecialReload );
2016-06-04 15:24:23 +02:00
ALERT( at_console, "m_iclip: %i\n", m_iClip );
}
TYPEDESCRIPTION CRpg::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CRpg, m_fSpotActive, FIELD_INTEGER ),
DEFINE_FIELD( CRpg, m_cActiveRockets, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CRpg, CBasePlayerWeapon )
TYPEDESCRIPTION CRpgRocket::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CRpgRocket, m_flIgniteTime, FIELD_TIME ),
DEFINE_FIELD( CRpgRocket, m_hLauncher, FIELD_EHANDLE ),
2016-06-04 15:24:23 +02:00
};
IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade )
TYPEDESCRIPTION CShotgun::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ),
DEFINE_FIELD( CShotgun, m_fInSpecialReload, FIELD_INTEGER ),
// DEFINE_FIELD( CShotgun, m_iShell, FIELD_INTEGER ),
DEFINE_FIELD( CShotgun, m_flPumpTime, FIELD_TIME ),
};
IMPLEMENT_SAVERESTORE( CShotgun, CBasePlayerWeapon )
TYPEDESCRIPTION CGauss::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
DEFINE_FIELD( CGauss, m_fInAttack, FIELD_INTEGER ),
//DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ),
//DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ),
//DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ),
2016-06-04 15:24:23 +02:00
DEFINE_FIELD( CGauss, m_fPrimaryFire, FIELD_BOOLEAN ),
};
IMPLEMENT_SAVERESTORE( CGauss, CBasePlayerWeapon )
TYPEDESCRIPTION CEgon::m_SaveData[] =
2016-06-04 15:24:23 +02:00
{
//DEFINE_FIELD( CEgon, m_pBeam, FIELD_CLASSPTR ),
//DEFINE_FIELD( CEgon, m_pNoise, FIELD_CLASSPTR ),
//DEFINE_FIELD( CEgon, m_pSprite, FIELD_CLASSPTR ),
2016-06-04 15:24:23 +02:00
DEFINE_FIELD( CEgon, m_shootTime, FIELD_TIME ),
DEFINE_FIELD( CEgon, m_fireState, FIELD_INTEGER ),
DEFINE_FIELD( CEgon, m_fireMode, FIELD_INTEGER ),
DEFINE_FIELD( CEgon, m_shakeTime, FIELD_TIME ),
DEFINE_FIELD( CEgon, m_flAmmoUseTime, FIELD_TIME ),
};
IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon )
2016-06-04 15:24:23 +02:00
TYPEDESCRIPTION CHgun::m_SaveData[] =
{
DEFINE_FIELD( CHgun, m_flRechargeTime, FIELD_TIME ),
2021-12-31 18:03:05 +01:00
DEFINE_FIELD( CHgun, m_iFirePhase, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CHgun, CBasePlayerWeapon )
2016-06-04 15:24:23 +02:00
TYPEDESCRIPTION CSatchel::m_SaveData[] =
{
DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ),
};
IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon )