mirror of
https://github.com/YGGverse/hlsdk-portable.git
synced 2025-03-13 05:51:19 +00:00
Fix weapons save, change weapons options
This commit is contained in:
parent
987f1d1189
commit
b3a2f1cbd5
20
dlls/ar2.cpp
20
dlls/ar2.cpp
@ -16,6 +16,7 @@
|
||||
#include "gamerules.h"
|
||||
#include "game.h"
|
||||
#include "customweapons.h"
|
||||
#include "unpredictedweapon.h"
|
||||
|
||||
#define AR2_BEAM_SPRITE "sprites/xbeam1.spr"
|
||||
enum AR2_e
|
||||
@ -30,7 +31,7 @@ enum AR2_e
|
||||
AR2_FIRE3,
|
||||
};
|
||||
|
||||
class CAR2 : public CBasePlayerWeapon
|
||||
class CAR2 : public CBasePlayerWeaponU
|
||||
{
|
||||
public:
|
||||
void Spawn(void);
|
||||
@ -50,13 +51,6 @@ public:
|
||||
void WeaponIdle(void);
|
||||
float m_flNextAnimTime;
|
||||
int m_iShell;
|
||||
|
||||
virtual BOOL UseDecrement(void)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(weapon_ar2, CAR2);
|
||||
@ -394,6 +388,11 @@ int CAR2::SecondaryAmmoIndex(void)
|
||||
|
||||
void CAR2::Spawn()
|
||||
{
|
||||
if( !cvar_allow_ar2.value )
|
||||
{
|
||||
pev->flags = FL_KILLME;
|
||||
return;
|
||||
}
|
||||
pev->classname = MAKE_STRING("weapon_ar2");
|
||||
Precache();
|
||||
SET_MODEL(ENT(pev), "models/w_ar2.mdl");
|
||||
@ -407,6 +406,8 @@ void CAR2::Spawn()
|
||||
|
||||
void CAR2::Precache(void)
|
||||
{
|
||||
if( !cvar_allow_ar2.value )
|
||||
return;
|
||||
PRECACHE_MODEL("models/v_ar2.mdl");
|
||||
PRECACHE_MODEL("models/w_ar2.mdl");
|
||||
PRECACHE_MODEL("models/p_ar2.mdl");
|
||||
@ -426,6 +427,7 @@ void CAR2::Precache(void)
|
||||
PRECACHE_SOUND("ar2launch.wav");
|
||||
|
||||
PRECACHE_SOUND("weapons/357_cock1.wav");
|
||||
PRECACHE_GENERIC("sprites/weapon_ar2.txt");
|
||||
|
||||
}
|
||||
|
||||
@ -458,6 +460,8 @@ int CAR2::GetItemInfo(ItemInfo *p)
|
||||
|
||||
int CAR2::AddToPlayer(CBasePlayer *pPlayer)
|
||||
{
|
||||
if( !cvar_allow_ar2.value )
|
||||
return FALSE;
|
||||
if (CBasePlayerWeapon::AddToPlayer(pPlayer))
|
||||
{
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nodes.h"
|
||||
#include "player.h"
|
||||
#include "customweapons.h"
|
||||
#include "unpredictedweapon.h"
|
||||
|
||||
#define BIG_COCK_WEIGHT 21
|
||||
|
||||
@ -30,7 +31,7 @@ enum glock_e {
|
||||
GLOCK_ADD_SILENCER
|
||||
};
|
||||
|
||||
class CBig_Cock : public CBasePlayerWeapon
|
||||
class CBig_Cock : public CBasePlayerWeaponU
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
@ -58,6 +59,11 @@ LINK_ENTITY_TO_CLASS(weapon_90mhandcock, CBig_Cock);
|
||||
|
||||
void CBig_Cock::Spawn()
|
||||
{
|
||||
if( !cvar_allow_bigcock.value )
|
||||
{
|
||||
pev->flags = FL_KILLME;
|
||||
return;
|
||||
}
|
||||
pev->classname = MAKE_STRING("weapon_big_cock"); // hack to allow for old names
|
||||
Precache( );
|
||||
m_iId = WEAPON_BIG_COCK;
|
||||
@ -71,6 +77,8 @@ void CBig_Cock::Spawn()
|
||||
|
||||
void CBig_Cock::Precache(void)
|
||||
{
|
||||
if( !cvar_allow_bigcock.value )
|
||||
return;
|
||||
PRECACHE_MODEL("models/v_9mmcockgunn.mdl");
|
||||
PRECACHE_MODEL("models/w_9mmcockgunn.mdl");
|
||||
PRECACHE_MODEL("models/p_9mmcockgunn.mdl");
|
||||
@ -86,6 +94,7 @@ void CBig_Cock::Precache(void)
|
||||
|
||||
m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" );
|
||||
m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" );
|
||||
PRECACHE_GENERIC("sprites/weapon_big_cock.txt");
|
||||
}
|
||||
|
||||
int CBig_Cock::GetItemInfo(ItemInfo *p)
|
||||
@ -294,7 +303,7 @@ void CBig_Cock::WeaponIdle(void)
|
||||
class CGlockAmmo : public CBasePlayerAmmo
|
||||
{
|
||||
void Spawn( void )
|
||||
{
|
||||
{
|
||||
Precache( );
|
||||
SET_MODEL(ENT(pev), "models/w_9mmclip.mdl");
|
||||
CBasePlayerAmmo::Spawn( );
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "sprite.h"
|
||||
#include "com_model.h"
|
||||
#include "customweapons.h"
|
||||
#include "unpredictedweapon.h"
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
#define BOLT_AIR_VELOCITY 2700
|
||||
@ -32,7 +33,7 @@
|
||||
|
||||
class CGateOfBabylonSpawner;
|
||||
#define MAX_SPAWNERS 7
|
||||
class CGateOfBabylon : public CBasePlayerWeapon
|
||||
class CGateOfBabylon : public CBasePlayerWeaponU
|
||||
{
|
||||
public:
|
||||
void Spawn( void );
|
||||
@ -53,16 +54,7 @@ public:
|
||||
void Reload( void );
|
||||
void WeaponIdle( void );
|
||||
|
||||
virtual BOOL UseDecrement( void )
|
||||
{
|
||||
//#if defined( CLIENT_WEAPONS )
|
||||
// return ;
|
||||
//#else
|
||||
return false;
|
||||
//#endif
|
||||
}
|
||||
|
||||
CGateOfBabylonSpawner *m_pSpawners[MAX_SPAWNERS];
|
||||
EHANDLE m_pSpawners[MAX_SPAWNERS];
|
||||
bool IntersectOtherSpawner( CGateOfBabylonSpawner *spawner );
|
||||
|
||||
private:
|
||||
@ -147,6 +139,11 @@ CGateOfBabylonBolt *CGateOfBabylonBolt::BoltCreate( void )
|
||||
|
||||
void CGateOfBabylonBolt::Spawn()
|
||||
{
|
||||
if( !cvar_allow_gateofbabylon.value )
|
||||
{
|
||||
pev->flags = FL_KILLME;
|
||||
return;
|
||||
}
|
||||
Precache();
|
||||
pev->movetype = MOVETYPE_FLY;
|
||||
pev->solid = SOLID_BBOX;
|
||||
@ -167,6 +164,10 @@ void CGateOfBabylonBolt::Spawn()
|
||||
|
||||
void CGateOfBabylonBolt::Precache()
|
||||
{
|
||||
if( !cvar_allow_gateofbabylon.value )
|
||||
{
|
||||
return;
|
||||
}
|
||||
PRECACHE_MODEL( "models/w_crowbar.mdl" );
|
||||
PRECACHE_SOUND( "weapons/xbow_hitbod1.wav" );
|
||||
PRECACHE_SOUND( "weapons/xbow_hitbod2.wav" );
|
||||
@ -174,6 +175,7 @@ void CGateOfBabylonBolt::Precache()
|
||||
PRECACHE_SOUND( "weapons/xbow_hit1.wav" );
|
||||
PRECACHE_SOUND( "fvox/beep.wav" );
|
||||
m_iTrail = PRECACHE_MODEL( "sprites/lgtning.spr" );
|
||||
PRECACHE_GENERIC("sprites/weapon_gateofbabylon.txt");
|
||||
}
|
||||
|
||||
void CGateOfBabylonBolt::RemoveThink( void )
|
||||
@ -466,6 +468,13 @@ CGateOfBabylonSpawner *CGateOfBabylonSpawner::CreateSpawner(
|
||||
bool CGateOfBabylonSpawner::FireBolts( void )
|
||||
{
|
||||
TraceResult tr;
|
||||
|
||||
if( !m_pGates )
|
||||
{
|
||||
pev->flags = FL_KILLME;
|
||||
return false;
|
||||
}
|
||||
|
||||
CBasePlayer *pPlayer = m_pGates->m_pPlayer;
|
||||
|
||||
if( m_flNextNPThrow > gpGlobals->time )
|
||||
@ -530,21 +539,18 @@ TYPEDESCRIPTION CGateOfBabylonSpawner::m_SaveData[] =
|
||||
DEFINE_FIELD( CGateOfBabylonSpawner, m_vecOffset, FIELD_VECTOR ),
|
||||
DEFINE_FIELD( CGateOfBabylonSpawner, m_flNextNPThrow, FIELD_TIME ),
|
||||
DEFINE_FIELD( CGateOfBabylonSpawner, m_flLastTimeAnim, FIELD_TIME ),
|
||||
DEFINE_FIELD( CGateOfBabylonSpawner, m_pGates, FIELD_CLASSPTR )
|
||||
DEFINE_FIELD( CGateOfBabylonSpawner, m_pGates, FIELD_EHANDLE )
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CGateOfBabylonSpawner, CBaseEntity );
|
||||
|
||||
TYPEDESCRIPTION CGateOfBabylon::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD( CBasePlayerWeapon, m_flNextPrimaryAttack, FIELD_TIME ),
|
||||
DEFINE_FIELD( CBasePlayerWeapon, m_flNextSecondaryAttack, FIELD_TIME ),
|
||||
DEFINE_FIELD( CBasePlayerWeapon, m_flTimeWeaponIdle, FIELD_TIME ),
|
||||
DEFINE_FIELD( CGateOfBabylon, m_iSpawnerCount, FIELD_INTEGER ),
|
||||
DEFINE_ARRAY( CGateOfBabylon, m_pSpawners, FIELD_CLASSPTR, MAX_SPAWNERS )
|
||||
DEFINE_ARRAY( CGateOfBabylon, m_pSpawners, FIELD_EHANDLE, MAX_SPAWNERS )
|
||||
};
|
||||
|
||||
IMPLEMENT_SAVERESTORE( CGateOfBabylon, CBasePlayerWeapon );
|
||||
IMPLEMENT_SAVERESTORE( CGateOfBabylon, CBasePlayerWeaponU );
|
||||
|
||||
|
||||
int CGateOfBabylon::ObjectCaps()
|
||||
@ -564,6 +570,10 @@ void CGateOfBabylon::Spawn()
|
||||
|
||||
int CGateOfBabylon::AddToPlayer( CBasePlayer *pPlayer )
|
||||
{
|
||||
if( !cvar_allow_gateofbabylon.value )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
||||
{
|
||||
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
||||
@ -638,7 +648,7 @@ void CGateOfBabylon::PrimaryAttack( void )
|
||||
|
||||
if( m_pSpawners[i] )
|
||||
{
|
||||
fire = m_pSpawners[i]->FireBolts();
|
||||
fire = ((CGateOfBabylonSpawner *)((CBaseEntity*)m_pSpawners[i]))->FireBolts();
|
||||
}
|
||||
} while( !fire && j++ < m_iSpawnerCount); // give up after some retries
|
||||
|
||||
@ -728,7 +738,7 @@ bool CGateOfBabylon::IntersectOtherSpawner( CGateOfBabylonSpawner *spawner )
|
||||
{
|
||||
for( int i = 0; i < m_iSpawnerCount; i++ )
|
||||
{
|
||||
CGateOfBabylonSpawner *o = m_pSpawners[i];
|
||||
CGateOfBabylonSpawner *o = (CGateOfBabylonSpawner *)(CBaseEntity*)m_pSpawners[i];
|
||||
|
||||
if( spawner == o || !o )
|
||||
continue;
|
||||
|
@ -17,6 +17,7 @@ Created by Solexid
|
||||
#include "customentity.h"
|
||||
#include "gamerules.h"
|
||||
#include "customweapons.h"
|
||||
#include "unpredictedweapon.h"
|
||||
|
||||
#define GRAV_BEAM_SPRITE_PRIMARY_VOLUME 30
|
||||
#define GRAV_BEAM_SPRITE "sprites/xbeam3.spr"
|
||||
@ -40,7 +41,7 @@ enum gauss_e {
|
||||
};
|
||||
|
||||
|
||||
class CGravGun : public CBasePlayerWeapon
|
||||
class CGravGun : public CBasePlayerWeaponU
|
||||
{
|
||||
public:
|
||||
|
||||
@ -87,11 +88,6 @@ public:
|
||||
CBeam *m_pNoise;
|
||||
CSprite *m_pSprite;
|
||||
|
||||
virtual BOOL UseDecrement(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
float m_shootTime;
|
||||
GRAV_FIREMODE m_fireMode;
|
||||
@ -104,7 +100,12 @@ LINK_ENTITY_TO_CLASS(weapon_gravgun, CGravGun);
|
||||
|
||||
void CGravGun::Spawn()
|
||||
{
|
||||
pev->classname = MAKE_STRING("weapon_gravgun"); // hack to allow for old names
|
||||
if( !cvar_allow_gravgun.value )
|
||||
{
|
||||
pev->flags = FL_KILLME;
|
||||
return;
|
||||
}
|
||||
pev->classname = MAKE_STRING("weapon_gravgun");
|
||||
Precache();
|
||||
m_iId = WEAPON_GRAVGUN;
|
||||
SET_MODEL(ENT(pev), "models/w_gravcannon.mdl");
|
||||
@ -142,6 +143,8 @@ Vector CGravGun::PredictTarget(float length)
|
||||
|
||||
void CGravGun::Precache(void)
|
||||
{
|
||||
if( !cvar_allow_gravgun.value )
|
||||
return;
|
||||
PRECACHE_MODEL("models/w_gravcannon.mdl");
|
||||
PRECACHE_MODEL("models/v_gravcannon.mdl");
|
||||
PRECACHE_MODEL("models/p_gravcannon.mdl");
|
||||
@ -158,6 +161,7 @@ void CGravGun::Precache(void)
|
||||
PRECACHE_MODEL("sprites/hotglow.spr");
|
||||
|
||||
PRECACHE_SOUND("weapons/357_cock1.wav");
|
||||
PRECACHE_GENERIC("sprites/weapon_gravgun.txt");
|
||||
|
||||
}
|
||||
|
||||
@ -172,6 +176,9 @@ BOOL CGravGun::Deploy(void)
|
||||
|
||||
int CGravGun::AddToPlayer(CBasePlayer *pPlayer)
|
||||
{
|
||||
if( !cvar_allow_gravgun.value )
|
||||
return FALSE;
|
||||
|
||||
if (CBasePlayerWeapon::AddToPlayer(pPlayer))
|
||||
{
|
||||
MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev);
|
||||
|
@ -4,13 +4,17 @@
|
||||
#include "gravgunmod.h"
|
||||
#include "player.h"
|
||||
#include "coop_util.h"
|
||||
#include "gamerules.h"
|
||||
|
||||
|
||||
cvar_t cvar_allow_gravgun = { "mp_allow_gravgun","1", FCVAR_SERVER };
|
||||
cvar_t cvar_allow_gravgun = { "mp_allow_gravgun","2", FCVAR_SERVER };
|
||||
cvar_t cvar_allow_ar2 = { "mp_allow_ar2","0", FCVAR_SERVER };
|
||||
cvar_t cvar_ar2_mp5 = { "mp_ar2_mp5","0", FCVAR_SERVER };
|
||||
cvar_t cvar_ar2_balls = { "mp_ar2_balls","0", FCVAR_SERVER };
|
||||
cvar_t cvar_ar2_bullets = { "mp_ar2_bullets","0", FCVAR_SERVER };
|
||||
cvar_t cvar_allow_bigcock = { "mp_allow_bigcock","0", FCVAR_SERVER };
|
||||
cvar_t cvar_allow_gateofbabylon = { "mp_allow_gateofbabylon","0", FCVAR_SERVER };
|
||||
|
||||
cvar_t cvar_wresptime = { "mp_wresptime","20", FCVAR_SERVER };
|
||||
cvar_t cvar_iresptime = { "mp_iresptime","30", FCVAR_SERVER };
|
||||
cvar_t cvar_gibtime = { "mp_gibtime","250", FCVAR_SERVER };
|
||||
@ -109,6 +113,8 @@ void GGM_RegisterCVars( void )
|
||||
CVAR_REGISTER( &cvar_ar2_mp5 );
|
||||
CVAR_REGISTER( &cvar_ar2_bullets );
|
||||
CVAR_REGISTER( &cvar_ar2_balls );
|
||||
CVAR_REGISTER( &cvar_allow_bigcock );
|
||||
CVAR_REGISTER( &cvar_allow_gateofbabylon );
|
||||
CVAR_REGISTER( &cvar_wresptime );
|
||||
CVAR_REGISTER( &cvar_iresptime );
|
||||
CVAR_REGISTER( &cvar_gibtime );
|
||||
@ -314,7 +320,7 @@ void GGM_ClientPutinServer(edict_t *pEntity, CBasePlayer *pPlayer)
|
||||
void GGM_ClientFirstSpawn(CBasePlayer *pPlayer)
|
||||
{
|
||||
// AGHL-like spectator
|
||||
if( mp_spectator.value )
|
||||
if( mp_spectator.value && g_pGameRules->IsMultiplayer() )
|
||||
{
|
||||
pPlayer->RemoveAllItems( TRUE );
|
||||
UTIL_BecomeSpectator( pPlayer );
|
||||
|
@ -7,6 +7,8 @@ extern cvar_t cvar_allow_ar2;
|
||||
extern cvar_t cvar_ar2_mp5;
|
||||
extern cvar_t cvar_ar2_bullets;
|
||||
extern cvar_t cvar_ar2_balls;
|
||||
extern cvar_t cvar_allow_bigcock;
|
||||
extern cvar_t cvar_allow_gateofbabylon;
|
||||
extern cvar_t cvar_wresptime;
|
||||
extern cvar_t cvar_iresptime;
|
||||
|
||||
|
@ -647,19 +647,24 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
|
||||
{
|
||||
pPlayer->GiveNamedItem( "weapon_crowbar" );
|
||||
pPlayer->GiveNamedItem( "weapon_9mmhandgun" );
|
||||
if( cvar_allow_gravgun.value)
|
||||
pPlayer->GiveNamedItem( "weapon_gravgun" );
|
||||
if( cvar_allow_ar2.value )
|
||||
pPlayer->GiveNamedItem( "weapon_ar2" );
|
||||
if( !cvar_ar2_mp5.value )
|
||||
{
|
||||
pPlayer->GiveAmmo( cvar_ar2_bullets.value, "AR2", 120 );
|
||||
pPlayer->GiveAmmo( cvar_ar2_balls.value, "AR2grenades", 3 );
|
||||
}
|
||||
pPlayer->GiveAmmo( 68, "9mm", _9MM_MAX_CARRY );// 4 full reloads
|
||||
|
||||
}
|
||||
if(mp_coop_changelevel.value)
|
||||
|
||||
if( (int)cvar_allow_gravgun.value == 2 )
|
||||
pPlayer->GiveNamedItem( "weapon_gravgun" );
|
||||
if( (int)cvar_allow_ar2.value == 2 )
|
||||
pPlayer->GiveNamedItem( "weapon_ar2" );
|
||||
if( !cvar_ar2_mp5.value )
|
||||
{
|
||||
pPlayer->GiveAmmo( cvar_ar2_bullets.value, "AR2", 120 );
|
||||
pPlayer->GiveAmmo( cvar_ar2_balls.value, "AR2grenades", 3 );
|
||||
}
|
||||
if( (int)cvar_allow_bigcock.value == 2 )
|
||||
pPlayer->GiveNamedItem( "weapon_big_cock" );
|
||||
if( (int)cvar_allow_gateofbabylon.value == 2 )
|
||||
pPlayer->GiveNamedItem( "weapon_gateofbabylon" );
|
||||
|
||||
if( mp_coop_changelevel.value )
|
||||
{
|
||||
// pPlayer->GiveNamedItem( "item_suit" );
|
||||
g_WeaponList.GiveToPlayer(pPlayer);
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "weapons.h"
|
||||
|
||||
class CBasePlayerWeaponU: CBasePlayerWeapon
|
||||
class CBasePlayerWeaponU: public CBasePlayerWeapon
|
||||
{
|
||||
public:
|
||||
virtual int Save( CSave &save );
|
||||
|
@ -355,10 +355,14 @@ void W_Precache( void )
|
||||
// hornetgun
|
||||
UTIL_PrecacheOtherWeapon( "weapon_hornetgun" );
|
||||
#endif
|
||||
UTIL_PrecacheOtherWeapon( "weapon_gravgun" );
|
||||
UTIL_PrecacheOtherWeapon( "weapon_ar2" );
|
||||
UTIL_PrecacheOtherWeapon( "weapon_big_cock" );
|
||||
UTIL_PrecacheOtherWeapon( "weapon_gateofbabylon" );
|
||||
if( cvar_allow_gravgun.value )
|
||||
UTIL_PrecacheOtherWeapon( "weapon_gravgun" );
|
||||
if( cvar_allow_ar2.value )
|
||||
UTIL_PrecacheOtherWeapon( "weapon_ar2" );
|
||||
if( cvar_allow_bigcock.value )
|
||||
UTIL_PrecacheOtherWeapon( "weapon_big_cock" );
|
||||
if( cvar_allow_gateofbabylon.value )
|
||||
UTIL_PrecacheOtherWeapon( "weapon_gateofbabylon" );
|
||||
|
||||
|
||||
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
||||
|
Loading…
x
Reference in New Issue
Block a user