Files
HL2Overcharged/game/shared/basecombatweapon_shared.h
2025-05-21 21:20:08 +03:00

947 lines
37 KiB
C++
Raw Permalink Blame History

//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//===========================================================================//
#ifndef COMBATWEAPON_SHARED_H
#define COMBATWEAPON_SHARED_H
#ifdef _WIN32
#pragma once
#endif
#include "sharedInterface.h"
#include "vphysics_interface.h"
#include "predictable_entity.h"
#include "soundflags.h"
#include "weapon_parse.h"
#include "baseviewmodel_shared.h"
#include "weapon_proficiency.h"
#include "utlmap.h"
#include <array>
#if defined( CLIENT_DLL )
#include "c_muzzleflash_effect.h"//OverCharged
#include "c_ar2_muzzleflash_effect.h"//OverCharged
#include "c_ar2_middle_muzzleflash_effect.h"//OverCharged
#include "dlight.h"
#else
#include "soundenvelope.h"
#include "Sprite.h"
#include "te_effect_dispatch.h"
#include "particle_parse.h"
#include "in_buttons.h"
#endif
#if defined( CLIENT_DLL )
#define CBaseCombatWeapon C_BaseCombatWeapon
#endif
// Hacky
#if defined ( TF_CLIENT_DLL ) || defined ( TF_DLL )
#include "econ_entity.h"
#endif // TF_CLIENT_DLL || TF_DLL
#if !defined( CLIENT_DLL )
extern void OnBaseCombatWeaponCreated(CBaseCombatWeapon *);
extern void OnBaseCombatWeaponDestroyed(CBaseCombatWeapon *);
void *SendProxy_SendLocalWeaponDataTable(const SendProp *pProp, const void *pStruct, const void *pVarData, CSendProxyRecipients *pRecipients, int objectID);
#endif
class CBasePlayer;
class CBaseCombatCharacter;
class IPhysicsConstraint;
class CUserCmd;
// How many times to display altfire hud hints (per weapon)
#define WEAPON_ALTFIRE_HUD_HINT_COUNT 1
#define WEAPON_RELOAD_HUD_HINT_COUNT 1
//Start with a constraint in place (don't drop to floor)
#define SF_WEAPON_START_CONSTRAINED (1<<0)
#define SF_WEAPON_NO_PLAYER_PICKUP (1<<1)
#define SF_WEAPON_NO_PHYSCANNON_PUNT (1<<2)
//Percent
#define CLIP_PERC_THRESHOLD 0.75f
// Put this in your derived class definition to declare it's activity table
// UNDONE: Cascade these?
#define DECLARE_ACTTABLE() static acttable_t m_acttable[];\
acttable_t *ActivityList( void );\
int ActivityListCount( void );
// You also need to include the activity table itself in your class' implementation:
// e.g.
// acttable_t CWeaponStunstick::m_acttable[] =
// {
// { ACT_MELEE_ATTACK1, ACT_MELEE_ATTACK_SWING, TRUE },
// };
//
// The stunstick overrides the ACT_MELEE_ATTACK1 activity, replacing it with ACT_MELEE_ATTACK_SWING.
// This animation is required for this weapon's operation.
//
// Put this after your derived class' definition to implement the accessors for the
// activity table.
// UNDONE: Cascade these?
#define IMPLEMENT_ACTTABLE(className) \
acttable_t *className::ActivityList( void ) { return m_acttable; } \
int className::ActivityListCount( void ) { return ARRAYSIZE(m_acttable); } \
typedef struct
{
int baseAct;
int weaponAct;
bool required;
} acttable_t;
class CHudTexture;
class Color;
namespace vgui2
{
typedef unsigned long HFont;
}
// -----------------------------------------
// Vector cones
// -----------------------------------------
// VECTOR_CONE_PRECALCULATED - this resolves to vec3_origin, but adds some
// context indicating that the person writing the code is not allowing
// FireBullets() to modify the direction of the shot because the shot direction
// being passed into the function has already been modified by another piece of
// code and should be fired as specified. See GetActualShotTrajectory().
// NOTE: The way these are calculated is that each component == sin (degrees/2)
#define VECTOR_CONE_PRECALCULATED vec3_origin
#define VECTOR_CONE_0DEGREES Vector( 0.00001, 0.00001, 0.00001 )//OverCharged
#define VECTOR_CONE_1DEGREES Vector( 0.00873, 0.00873, 0.00873 )
#define VECTOR_CONE_2DEGREES Vector( 0.01745, 0.01745, 0.01745 )
#define VECTOR_CONE_3DEGREES Vector( 0.02618, 0.02618, 0.02618 )
#define VECTOR_CONE_4DEGREES Vector( 0.03490, 0.03490, 0.03490 )
#define VECTOR_CONE_5DEGREES Vector( 0.04362, 0.04362, 0.04362 )
#define VECTOR_CONE_6DEGREES Vector( 0.05234, 0.05234, 0.05234 )
#define VECTOR_CONE_7DEGREES Vector( 0.06105, 0.06105, 0.06105 )
#define VECTOR_CONE_8DEGREES Vector( 0.06976, 0.06976, 0.06976 )
#define VECTOR_CONE_9DEGREES Vector( 0.07846, 0.07846, 0.07846 )
#define VECTOR_CONE_10DEGREES Vector( 0.08716, 0.08716, 0.08716 )
#define VECTOR_CONE_15DEGREES Vector( 0.13053, 0.13053, 0.13053 )
#define VECTOR_CONE_20DEGREES Vector( 0.17365, 0.17365, 0.17365 )
//-----------------------------------------------------------------------------
// Purpose: Base weapon class, shared on client and server
//-----------------------------------------------------------------------------
#if defined USES_ECON_ITEMS
#define BASECOMBATWEAPON_DERIVED_FROM CEconEntity
#else
#define BASECOMBATWEAPON_DERIVED_FROM CBaseAnimating
#endif
//-----------------------------------------------------------------------------
// Collect trace attacks for weapons that fire multiple projectiles per attack that also penetrate
//-----------------------------------------------------------------------------
class CDmgAccumulator
{
public:
CDmgAccumulator(void);
~CDmgAccumulator();
#ifdef GAME_DLL
virtual void Start(void) { m_bActive = true; }
virtual void AccumulateMultiDamage(const CTakeDamageInfo &info, CBaseEntity *pEntity);
virtual void Process(void);
private:
CTakeDamageInfo m_updatedInfo;
CUtlMap< int, CTakeDamageInfo > m_TargetsDmgInfo;
#endif // GAME_DLL
private:
bool m_bActive;
};
enum BEAM_FIRESTATE { FIRE_NONE, FIRE_STARTUP, FIRE_LOOP, FIRE_END };
//-----------------------------------------------------------------------------
// Purpose: Client side rep of CBaseTFCombatWeapon
//-----------------------------------------------------------------------------
// Hacky
class CBaseCombatWeapon : public BASECOMBATWEAPON_DERIVED_FROM
{
public:
DECLARE_CLASS(CBaseCombatWeapon, BASECOMBATWEAPON_DERIVED_FROM);
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
CBaseCombatWeapon();
virtual ~CBaseCombatWeapon();
virtual bool IsBaseCombatWeapon(void) const { return true; }
virtual CBaseCombatWeapon *MyCombatWeaponPointer(void) { return this; }
// A derived weapon class should return true here so that weapon sounds, etc, can
// apply the proper filter
virtual bool IsPredicted(void) const { return false; }
bool CanDrop(void);
/*{
#if !defined( CLIENT_DLL )
if (GetOwner() && GetOwner()->IsPlayer() && GetOwner()->IsAlive())
{
CBasePlayer *pPlayer = ToBasePlayer(GetOwner());
if (!pPlayer)
return false;
if ((pPlayer->m_nButtons & IN_ATTACK) || (pPlayer->m_nButtons & IN_ATTACK2))
return false;
}
#endif
return true;
}*///OverCharged
virtual void Spawn(void);
virtual void Precache(void);
//TracersOrdinates *pStructOrdinates;
void MakeTracer(const Vector &vecTracerSrc, const trace_t &tr, int iTracerType);
void MakeTracerHolded(const Vector &vecTracerSrc, const trace_t &tr, int iTracerType);
// Subtypes are used to manage multiple weapons of the same type on the player.
virtual int GetSubType(void) { return m_iSubType; }
virtual void SetSubType(int iType) { m_iSubType = iType; }
virtual void Equip(CBaseCombatCharacter *pOwner);
virtual void Drop(const Vector &vecVelocity);
virtual int UpdateClientData(CBasePlayer *pPlayer);
virtual bool IsAllowedToSwitch(void);
virtual bool CanBeSelected(void);
virtual bool VisibleInWeaponSelection(void);
virtual bool HasAmmo(void);
// Weapon Pickup For Player
virtual void SetPickupTouch(void);
virtual void DefaultTouch(CBaseEntity *pOther); // default weapon touch
virtual void GiveTo(CBaseEntity *pOther);
// HUD Hints
virtual bool ShouldDisplayAltFireHUDHint();
virtual void DisplayAltFireHudHint();
virtual void RescindAltFireHudHint(); ///< undisplay the hud hint and pretend it never showed.
virtual bool ShouldDisplayReloadHUDHint();
virtual void DisplayReloadHudHint();
virtual void RescindReloadHudHint();
// Weapon client handling
virtual void SetViewModelIndex(int index = 0);
virtual bool SendWeaponAnim(int iActivity);
virtual void SendViewModelAnim(int nSequence);
float GetViewModelSequenceDuration(); // Return how long the current view model sequence is.
bool IsViewModelSequenceFinished(void); // Returns if the viewmodel's current animation is finished
/*virtual void ProcessAnimationEvents(void);
bool m_bWeaponIsLoweredSpeed;
float TimerSpeed;
virtual void ProcessAnimationEventsWall(void);
bool m_bWeaponIsLoweredWall;
float TimerWall;*/
//OVR new functionality
void OnIronSight();
void OffIronSight();
bool IsIronSighted();
void OnScopeSight();
void OffScopeSight();
bool IsScopeSighted();
bool IsNearWall();
void WallClip(CBasePlayer *pPlayer);
virtual void CheckZoomToggle(CBasePlayer *pPlayer);
virtual void ToggleZoom(CBasePlayer *pPlayer, bool state);
virtual bool IsWeaponZoomed() { return ScopeSightState; }
virtual bool CanWeaponIdle(CBasePlayer *pOwner);
virtual void SetupWeapon(CBasePlayer *pOwner);
virtual void SetupAmmo();
virtual void AddMuzzleFlash();
virtual void RemoveMuzzleFlash();
virtual bool CanInspect(CBasePlayer *pOwner);
virtual void CheckAdmireAnimations(CBasePlayer *pOwner);
virtual void CheckScopeZoomState(CBasePlayer *pOwner);
virtual void CheckReloadState(CBasePlayer *pOwner);
virtual void CheckReloadShotgun();
virtual void PrimaryAttackShotgun();
virtual void PrimaryAttackHolding(CBaseCombatWeapon *pWeapon);
virtual void FireClientPrimaryAttack();
virtual void FireClientSecondaryAttack();
virtual void FireClientDelayedAttack();
virtual void SecondaryAttackShotgun();
virtual bool StartReloadShotgun();
virtual bool ReloadShotgun();
virtual void FinishReloadShotgun(bool reloadFromEmpty);
virtual void PumpShotgun();
virtual void DryFire(bool bSecondary = false);
virtual bool DeployGrenade();
virtual void PullUpGrenade(bool down);
virtual void ReleaseGrenade(bool secondary);
virtual void ReinitializeLoopSound(const char *sample);
virtual void CreateLoopSound(const char *sample);
virtual void DestroyLoopSound();
virtual void StartLoopSound();
virtual void StopLoopSound();
virtual int NumShots(void) const;//OverCharged
virtual int GetSecondaryAttachment();
virtual void CheckSilencer(CBasePlayer *pOwner);
virtual void RechargeAmmo();
bool UsesSecondaryAmmoType() const;
int GetMaxAmmoCountForRecharge();
int GetAmmoCountForRecharge();
void RemoveRechargedAmmo();
void AddRechargedAmmo();
virtual void RemoveAmmo(int ammoType, int count = 0);
Activity SetIdleActivity(bool lowering = false);
inline bool HasOwner() { return (bool)(GetOwner() != NULL); };
inline bool EnabledHoldingFire() { return holdingFire; };
inline void EnableHoldingFire(bool val) { holdingFire = val; };
void SetClientVectors(Vector TrVec, Vector muzVec);
void SetClientAngles(QAngle muzAng);
const Vector &GetClientTracerVector();
const Vector &GetClientMuzzleVector();
const QAngle &GetClientMuzzleAngles();
#ifndef CLIENT_DLL
inline bool isPlayingLoopingSound() { return m_pLoopSound != NULL; };
#endif
CNetworkVar(bool, m_bShouldDrawWeaponBloodOverlay);
CNetworkVar(int, m_iWeaponBloodOverlayDetailFrame);
CNetworkVar(bool, m_bEnableMainLaser);
CNetworkVar(bool, m_bIsFiring);
CNetworkVar(bool, m_bWeaponBlockWall);
CNetworkVar(bool, m_bIsInPrimaryAttack);
CNetworkVar(bool, m_bNeedPump);
CNetworkVar(bool, m_bSilenced);
CNetworkVar(bool, PumpAfterTwoBarrels);
CNetworkVar(bool, reloadFromEmpty);
CNetworkVar(bool, EnableLaser);
CNetworkVar(bool, EnableLaserInterrupt);
CNetworkVar(bool, m_bFirstEquip);
CNetworkVar(bool, wasburstFire);
CNetworkVar(bool, switched);
CNetworkVar(bool, letViewModelBob);
CNetworkVar(bool, clipNearWall);
CNetworkVar(int, m_iShotgunReloadState);
CNetworkVar(int, IronSightState);
CNetworkVar(bool, ScopeSightState);
CNetworkVar(bool, wasInIronSighted);
CNetworkVar(bool, m_bShouldBeLowered);
CNetworkVar(int, bg);
CNetworkVar(int, bgV);
CNetworkVar(int, iMuzzle);
CNetworkVar(int, m_bFireMode);
CNetworkVar(int, burstFireCount);
CNetworkVar(int, m_bZoomLevel);
CNetworkVar(int, m_iMuzzleFlashState);
CNetworkVar(float, m_flHolsterTime);
CNetworkVar(float, m_flNextSilencer);
CNetworkVar(float, m_flNextShotgunReload);
CNetworkVar(float, m_flNextInspectAnimation);
CNetworkVar(float, m_flNextAmmoRegen);
CNetworkVar(float, m_flNextAmmoRemove);
CNetworkVar(float, distanceToWall);
float m_flNextLowerTime;
float m_flNextWallClipTime;
CNetworkString(nameOfFireMode, 255);
CNetworkVector(tr_endPos);
//#ifndef CLIENT_DLL
int iVMSkin;
//#endif
void SetPickableDelay(bool ownerIsPlayer = true);
bool Pickable;
float m_flNextPick;
WeaponType thisType;
CUtlVector<string_t> allWeapons;
CUtlVector<CBaseCombatWeapon*> allObjectWeapons;
bool m_bZoomUpped;
bool scoped;
bool _enabledLaser;
bool blockToAmmoRegen;
int m_bFireModeCounter;
int m_bFireModes[3];
int m_bFireModesSize;
float m_flNextSwitchTime;
float m_flNextLaserSwitchTime;
//float m_flNextRemoveAmmo;
//float m_flAmmoRemoveDelay;
BEAM_FIRESTATE m_BeamFireState;
CUtlVector<Activity> attackActivites;
//std::array<Activity, 102> attackActivites;
bool GetOwnerIsRunning();
inline bool IsInReload()
{
return m_iShotgunReloadState || m_bInReload || m_bReloadComplete;
}
#ifndef CLIENT_DLL
CSoundPatch *m_pLoopSound;
CSoundEnvelopeController *m_pLoopSoundController;
float soundInitialVolume;
float soundInitialPitch;
//float m_flNextSilencer;
#endif
virtual void SetViewModel();
void SetVMBodyGroup(int iGroup, int iValue);
virtual bool HasWeaponIdleTimeElapsed(void);
virtual void SetWeaponIdleTime(float time);
virtual float GetWeaponIdleTime(void);
// Weapon selection
virtual bool HasAnyAmmo(void); // Returns true is weapon has ammo
virtual bool HasPrimaryAmmo(void); // Returns true is weapon has ammo
virtual bool HasSecondaryAmmo(void); // Returns true is weapon has ammo
bool UsesPrimaryAmmo(void); // returns true if the weapon actually uses primary ammo
bool UsesSecondaryAmmo(void); // returns true if the weapon actually uses secondary ammo
void GiveDefaultAmmo(void);
bool IsClippedAmmo(void);
virtual bool CanHolster(void);// { return TRUE; }; // returns true if the weapon can be holstered
virtual bool DefaultDeploy(char *szViewModel, char *szWeaponModel, int iActivity, char *szAnimExt);
virtual bool CanDeploy(void) { return true; } // return true if the weapon's allowed to deploy
virtual void SetSkin(int skinNum, bool noSuit = false);
virtual void RandomizeSkin(int iRange);
virtual bool Deploy(void); // returns true is deploy was successful
virtual bool FirstDeploy(int iActivity);
virtual bool Holster(CBaseCombatWeapon *pSwitchingTo = NULL);
virtual CBaseCombatWeapon *GetLastWeapon(void) { return this; }
virtual void SetWeaponVisible(bool visible);
virtual bool IsWeaponVisible(void);
virtual bool ReloadOrSwitchWeapons(void);
virtual void OnActiveStateChanged(int iOldState) { return; }
virtual bool HolsterOnDetach() { return false; }
virtual bool IsHolstered() { return /*false;*/ IsEffectActive(EF_NODRAW); }
virtual bool IsGrenade();
virtual void Detach() {}
// Weapon behaviour
virtual void SwitchFiringModes(void); // called each frame by the player PostThink
virtual void SwitchLaserGuidance(CBasePlayer *pOwner); // called each frame by the player PostThink
virtual void StartLaserEffects(CBasePlayer *pOwner);
virtual void StopLaserEffects(CBasePlayer *pOwner);
virtual void UpdatePenaltyTime(void);
virtual void ItemPreFrame(void); // called each frame by the player PreThink
virtual void ItemPostFrame(void); // called each frame by the player PostThink
virtual void ItemBusyFrame(void); // called each frame by the player PostThink, if the player's not ready to attack yet
virtual void ItemHolsterFrame(void);// {}; // called each frame by the player PreThink, if the weapon is holstered
virtual bool WeaponShouldBeLowered(void);
virtual void CheckLowering();
virtual void WeaponIdle(void); // called when no buttons pressed
void UpdateHandleFireOnEmpty();
virtual void HandleFireOnEmpty(bool bSecondary = false); // Called when they have the attack button down
void HandleBurstFire(bool bPressedOnce = false);
void HandleSingleFire();
virtual bool ShouldBlockPrimaryFire() { return false; }
#ifdef CLIENT_DLL
virtual void CreateMove(float flInputSampleTime, CUserCmd *pCmd, const QAngle &vecOldViewAngles) {}
virtual int CalcOverrideModelIndex() OVERRIDE;
#endif
//virtual bool IsWeaponZoomed() { return false; } // Is this weapon in its 'zoomed in' mode?
// bool m_bExpSighted; //ADDED
// Reloading
virtual void CheckReload(void);
virtual void FinishReload(void);
virtual void AbortReload(void);
virtual bool Reload(void);
bool DefaultReload(int iClipSize1, int iClipSize2, int iActivity);
bool DefaultReloadEmpty(int iClipSize1, int iClipSize2, int iActivity);
bool ReloadsSingly(void) const;
virtual bool AutoFiresFullClip(void) { return false; }
virtual bool CanOverload(void) { return false; }
virtual void UpdateAutoFire(void);
// Weapon firing
virtual void PrimaryAttack(void);
void PrimaryAttackPostUpdate(void);
// do "+ATTACK"
virtual void SecondaryAttack(void) {}; // do "+ATTACK2"
virtual void SecondaryAttackEffects();
virtual void DelayedAttackEffects();
virtual void FireMode(void) { return; } // do "+FIREMODE"
bool IsBehindTarget(CBaseEntity *pTarget); // BriJee: Overcharged check enemy's back
// Firing animations
virtual Activity GetPrimaryAttackActivity(void);
virtual Activity GetSecondaryAttackActivity(void);
virtual Activity GetDrawActivity(void);
Activity GetHolsterActivity(void);
virtual float GetDefaultAnimSpeed(void) { return 1.0; }
bool IsNonAttachmentActivity(Activity Act);
// Bullet launch information
virtual int GetBulletType(void);
virtual const Vector& GetBulletSpread(void);
virtual const Vector& GetBulletSpreadHolded(void);
virtual Vector GetBulletSpread(WeaponProficiency_t proficiency) { return GetBulletSpread(); }
virtual float GetSpreadBias(WeaponProficiency_t proficiency) { return 1.0; }
virtual float GetFireRate(void);
virtual int GetMinBurst();// { return 1; }
virtual int GetMaxBurst();// { return 1; }
virtual float GetMinRestTime() { return 0.3; }
virtual float GetMaxRestTime() { return 0.6; }
virtual int GetRandomBurst() { return random->RandomInt(GetMinBurst(), GetMaxBurst()); }
virtual void WeaponSound(WeaponSound_t sound_type, float soundtime = 0.0f);
virtual void StopWeaponSound(WeaponSound_t sound_type);
virtual const WeaponProficiencyInfo_t *GetProficiencyValues();
// Autoaim
virtual float GetMaxAutoAimDeflection() { return 0.99f; }
virtual float WeaponAutoAimScale() { return 1.0f; } // allows a weapon to influence the perceived size of the target's autoaim radius.
// TF Sprinting functions
virtual bool StartSprinting(void) { return false; };
virtual bool StopSprinting(void) { return false; };
// TF Injury functions
virtual float GetDamage(float flDistance, int iLocation) { return 0.0; };
virtual void SetActivity(Activity act, float duration);
inline void SetActivity(Activity eActivity) { m_Activity = eActivity; }
inline Activity GetActivity(void) { return m_Activity; }
virtual void AddViewKick(void); // Add in the view kick for the weapon
virtual char *GetDeathNoticeName(void); // Get the string to print death notices with
CBaseCombatCharacter *GetOwner() const;
void SetOwner(CBaseCombatCharacter *owner);
virtual void OnPickedUp(CBaseCombatCharacter *pNewOwner);
virtual void AddViewmodelBob(CBaseViewModel *viewmodel, Vector &origin, QAngle &angles, float bobScale) {};
virtual void AddViewmodelBobRUN(CBaseViewModel *viewmodelR, Vector &origin, QAngle &angles) {};
virtual float CalcViewmodelBob(void) { return 0.0f; };
// Returns information about the various control panels
virtual void GetControlPanelInfo(int nPanelIndex, const char *&pPanelName);
virtual void GetControlPanelClassName(int nPanelIndex, const char *&pPanelName);
virtual bool ShouldShowControlPanels(void) { return true; }
void Lock(float lockTime, CBaseEntity *pLocker);
bool IsLocked(CBaseEntity *pAsker);
//All weapons can be picked up by NPCs by default
virtual bool CanBePickedUpByNPCs(void);// { return true; }
virtual int GetSkinOverride() const { return -1; }
public:
// Weapon info accessors for data in the weapon's data file
const FileWeaponInfo_t &GetWpnData(void) const;
virtual const char *GetViewModel(int viewmodelindex = 0) const;
virtual const char *GetAdditionalViewModel(int viewmodelindex = 0) const;
virtual const char *GetWorldModel(void) const;
virtual const char *GetAnimPrefix(void) const;
virtual int GetMaxClip1(void) const;
virtual int GetMaxClip2(void) const;
virtual int GetDefaultClip1(void) const;
virtual int GetDefaultClip2(void) const;
virtual int GetWeight(void) const;
virtual bool AllowsAutoSwitchTo(void) const;
virtual bool AllowsAutoSwitchFrom(void) const;
virtual int GetWeaponFlags(void) const;
virtual int GetSlot(void) const;
virtual int GetPosition(void) const;
virtual char const *GetName(void) const;
virtual char const *GetPrintName(void) const;
virtual char const *GetShootSound(int iIndex) const;
virtual int GetRumbleEffect() const;
virtual bool UsesClipsForAmmo1(void) const;
virtual bool UsesClipsForAmmo2(void) const;
bool IsMeleeWeapon() const;
virtual int GetMaxFOV(void) const; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FOV <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//OverCharged
virtual float FlashLifeTime(void) const;//OverCharged
virtual int FlashType(void) const;//OverCharged
virtual int MuzzleFlashTypeIndex(void) const;//OverCharged
virtual int MuzzleSecondaryFlashTypeIndex(void) const;//OverCharged
virtual int MuzzleTracerTypeNpcIndex(void) const;//OverCharged
virtual string_t MuzzleTracerType(int index) const;//OverCharged
virtual string_t MuzzleTracerNpcType(int index) const;//OverCharged
virtual string_t MuzzleFlashType(int index) const;//OverCharged
virtual string_t MuzzleSecondaryFlashType(int index) const;//OverCharged
virtual string_t MuzzleFlashType(void) const;//OverCharged
//virtual string_t MuzzleFlashTransparentType(void) const;//OverCharged
virtual string_t MuzzleSecondaryFlashType(void) const;//OverCharged
virtual float GetFireRate(void) const;//OverCharged
virtual string_t WeaponShellModel(void) const;//OverCharged
virtual string_t WeaponShellBounceSound(void) const;//OverCharged
virtual string_t WeaponShellHitSound(void) const;//OverCharged
virtual string_t WeaponShellParticle(void) const;//OverCharged
virtual string_t WeaponZoomUpSound(void) const;//OverCharged
virtual int WeaponGetWaterLevel(void);//OverCharged
// virtual int FlashLightType(void) const;//OverCharged
// virtual int FlashLightTypeNPC(void) const;//OverCharged
// virtual int TracerType(void) const;//OverCharged
// derive this function if you mod uses encrypted weapon info files
virtual const unsigned char *GetEncryptionKey(void);
virtual int GetPrimaryAmmoType(void) const { return m_iPrimaryAmmoType; }
virtual int GetSecondaryAmmoType(void) const { return m_iSecondaryAmmoType; }
virtual int Clip1() { return m_iClip1; }
virtual int Clip2() { return m_iClip2; }
// Ammo quantity queries for weapons that do not use clips. These are only
// used to determine how much ammo is in a weapon that does not have an owner.
// That is, a weapon that's on the ground for the player to get ammo out of.
int GetPrimaryAmmoCount() { return m_iPrimaryAmmoCount; }
void SetPrimaryAmmoCount(int count) { m_iPrimaryAmmoCount = count; }
int GetSecondaryAmmoCount() { return m_iSecondaryAmmoCount; }
void SetSecondaryAmmoCount(int count) { m_iSecondaryAmmoCount = count; }
virtual CHudTexture const *GetSpriteActive(void) const;
virtual CHudTexture const *GetSpriteInactive(void) const;
virtual CHudTexture const *GetSpriteAmmo(void) const;
virtual CHudTexture const *GetSpriteAmmo2(void) const;
virtual CHudTexture const *GetSpriteCrosshair(void) const;
virtual CHudTexture const *GetSpriteAutoaim(void) const;
virtual CHudTexture const *GetSpriteZoomedCrosshair(void) const;
virtual CHudTexture const *GetSpriteZoomedAutoaim(void) const;
virtual Activity ActivityOverride(Activity baseAct, bool *pRequired);
virtual acttable_t* ActivityList(void) { return NULL; }
virtual int ActivityListCount(void) { return 0; }
virtual void Activate(void);
virtual bool ShouldUseLargeViewModelVROverride() { return false; }
public:
// Server Only Methods
#if !defined( CLIENT_DLL )
DECLARE_DATADESC();
virtual void FallInit(void); // prepare to fall to the ground
virtual void FallThink(void); // make the weapon fall to the ground after spawning
// Weapon spawning
bool IsConstrained() { return m_pConstraint != NULL; }
bool IsInBadPosition(void); // Is weapon in bad position to pickup?
bool RepositionWeapon(void); // Attempts to reposition the weapon in a location where it can be
virtual void Materialize(void); // make a weapon visible and tangible
void AttemptToMaterialize(void); // see if the game rules will let the weapon become visible and tangible
virtual void CheckRespawn(void); // see if this weapon should respawn after being picked up
CBaseEntity *Respawn(void); // copy a weapon
static int GetAvailableWeaponsInBox(CBaseCombatWeapon **pList, int listMax, const Vector &mins, const Vector &maxs);
// Weapon dropping / destruction
virtual void Delete(void);
void DestroyItem(void);
virtual void Kill(void);
virtual int CapabilitiesGet(void) { return 0; }
virtual int ObjectCaps(void);
bool IsRemoveable() { return m_bRemoveable; }
void SetRemoveable(bool bRemoveable) { m_bRemoveable = bRemoveable; }
// Returns bits for weapon conditions
virtual bool WeaponLOSCondition(const Vector &ownerPos, const Vector &targetPos, bool bSetConditions);
virtual int WeaponRangeAttack1Condition(float flDot, float flDist);
virtual int WeaponRangeAttack2Condition(float flDot, float flDist);
virtual int WeaponMeleeAttack1Condition(float flDot, float flDist);
virtual int WeaponMeleeAttack2Condition(float flDot, float flDist);
//NPC Fire cap
virtual void FireNPCPrimaryAttack(CBaseCombatCharacter *pOperator, bool bUseWeaponAngles);
virtual void FireNPCPrimaryAttackShotgun(CBaseCombatCharacter *pOperator, bool bUseWeaponAngles);
virtual void Operator_NPCFire(CBaseCombatCharacter *pOperator, bool bSecondary);
virtual void Operator_FrameUpdate(CBaseCombatCharacter *pOperator);
virtual void Operator_HandleAnimEvent(animevent_t *pEvent, CBaseCombatCharacter *pOperator);
virtual void MagOut(void);
void ShellOut(animevent_t *pEvent);
virtual void Operator_ForceNPCFire(CBaseCombatCharacter *pOperator, bool bSecondary) { return; }
// NOTE: This should never be called when a character is operating the weapon. Animation events should be
// routed through the character, and then back into CharacterAnimEvent()
void HandleAnimEvent(animevent_t *pEvent);
virtual int UpdateTransmitState(void);
void InputHideWeapon(inputdata_t &inputdata);
void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
virtual CDmgAccumulator *GetDmgAccumulator(void) { return NULL; }
bool DoOnceMPS = true;
// Client only methods
#else
virtual void BoneMergeFastCullBloat(Vector &localMins, Vector &localMaxs, const Vector &thisEntityMins, const Vector &thisEntityMaxs) const;
virtual bool OnFireEvent(C_BaseViewModel *pViewModel, const Vector& origin, const QAngle& angles, int event, const char *options)
{
#if defined USES_ECON_ITEMS
return BaseClass::OnFireEvent(pViewModel, origin, angles, event, options);
#else
return false;
#endif
}
// Should this object cast shadows?
virtual ShadowType_t ShadowCastType();
virtual void SetDormant(bool bDormant);
virtual void OnDataChanged(DataUpdateType_t updateType);
virtual void OnRestore();
virtual void UpdateMuzzleFlash(C_BasePlayer *pPlayer, C_BaseCombatWeapon *pCurWeapon);
/*virtual void SetMuzzleFlashActiveInternalCallBack(C_BasePlayer *pPlayer, C_BaseCombatWeapon *pWeap);
virtual void SetMuzzleFlashDeactiveInternalCallBack(C_BasePlayer *pPlayer, C_BaseCombatWeapon *pWeap);*/
virtual void SetMuzzleFlashActive(C_BasePlayer *pPlayer, C_BaseCombatWeapon *pCurWeapon);
virtual void SetMuzzleFlashDeactive(C_BaseCombatWeapon *pCurWeapon);
virtual void RestartParticleEffect(void) {}
virtual void Redraw(void);
virtual void ViewModelDrawn(CBaseViewModel *pViewModel);
// Get the position that bullets are seen coming out. Note: the returned values are different
// for first person and third person.
bool GetShootPosition(Vector &vOrigin, QAngle &vAngles);
virtual void DrawCrosshair(void);
virtual bool ShouldDrawCrosshair(void) { return true; }
// Weapon state checking
virtual bool IsCarriedByLocalPlayer(void);
virtual bool ShouldDrawUsingViewModel(void);
virtual bool IsActiveByLocalPlayer(void);
bool IsBeingCarried() const;
// Is the carrier alive?
bool IsCarrierAlive() const;
// Returns the aiment render origin + angles
virtual int DrawModel(int flags);
virtual bool ShouldDraw(void);
virtual bool ShouldDrawPickup(void);
virtual void HandleInput(void) { return; };
virtual void OverrideMouseInput(float *x, float *y) { return; };
virtual int KeyInput(int down, ButtonCode_t keynum, const char *pszCurrentBinding) { return 1; }
virtual bool AddLookShift(void) { return true; };
virtual void GetViewmodelBoneControllers(C_BaseViewModel *pViewModel, float controllers[MAXSTUDIOBONECTRLS]) { return; }
virtual void NotifyShouldTransmit(ShouldTransmitState_t state);
WEAPON_FILE_INFO_HANDLE GetWeaponFileInfoHandle() { return m_hWeaponFileInfo; }
virtual int GetWorldModelIndex(void);
virtual void GetToolRecordingState(KeyValues *msg);
virtual void GetWeaponCrosshairScale(float &flScale) { flScale = 1.f; }
#if !defined USES_ECON_ITEMS
// Viewmodel overriding
virtual bool ViewModel_IsTransparent(void) { return IsTransparent(); }
virtual bool ViewModel_IsUsingFBTexture(void) { return UsesPowerOfTwoFrameBufferTexture(); }
virtual bool IsOverridingViewmodel(void) { return false; };
virtual int DrawOverriddenViewmodel(C_BaseViewModel *pViewmodel, int flags) { return 0; };
bool WantsToOverrideViewmodelAttachments(void) { return false; }
#endif
bool ReinitializeMuzzleFlash;
bool IsMuzzleFlashActive;
bool IsMuzzleFlashComplete;
float m_flNextMuzzleFlashTime;
float m_flMuzzleFlashRoll;
// Player Other Muzzle flash
C_MuzzleflashEffect *m_M;
// Player AR2 MuzzleFlash
C_Ar2_MuzzleflashEffect *m_Ar2_M;
// Player AR2Middle MuzzleFlash
C_Ar2_Middle_MuzzleflashEffect *m_Ar2_MM;
#endif // End client-only methods
virtual bool CanLower(void) { return false; }
virtual bool Ready(void) { return false; }
virtual bool Lower(void) { return false; }
virtual void HideThink(void);
virtual bool CanReload(void);
private:
typedef CHandle< CBaseCombatCharacter > CBaseCombatCharacterHandle;
CNetworkVar(CBaseCombatCharacterHandle, m_hOwner); // Player carrying this weapon
bool ChangeOnce = true;
int indexT;
int indexTN;
char nameT2[256];
char nameTN2[256];
const char *nameT;
const char *nameTN;
float m_flSoonestPrimaryAttack;
float m_flAccuracyPenalty;
bool holdingFire;
void UploadDataScript(void);
Vector m_vTracerMuzzleVector;
Vector m_vMuzzleVector;
QAngle m_vMuzzleAngle;
protected:
#if defined ( TF_CLIENT_DLL ) || defined ( TF_DLL )
// Regulate crit frequency to reduce client-side seed hacking
void AddToCritBucket(float flAmount);
void RemoveFromCritBucket(float flAmount) { m_flCritTokenBucket -= flAmount; }
bool IsAllowedToWithdrawFromCritBucket(float flDamage);
float m_flCritTokenBucket;
int m_nCritChecks;
int m_nCritSeedRequests;
#endif // TF
bool m_bLowered2; // Whether the viewmodel is raised or lowered
float m_flRaiseTime2; // If lowered, the time we should raise the viewmodel
int m_nShotsFired; // Number of consecutive shots fired
float m_flLastAttackTime;
void WeaponEmitSound(const char *m_sName, const Vector &m_vOrigin);
public:
#ifndef CLIENT_DLL
CHandle<CSprite> m_hLaserMuzzleSprite;
#endif
// Networked fields
CNetworkVar(int, m_nViewModelIndex);
// Weapon firing
CNetworkVar(float, m_flNextPrimaryAttack); // soonest time ItemPostFrame will call PrimaryAttack
CNetworkVar(float, m_flNextSecondaryAttack); // soonest time ItemPostFrame will call SecondaryAttack
CNetworkVar(float, m_flTimeWeaponIdle); // soonest time ItemPostFrame will call WeaponIdle
// Weapon state
CNetworkVar(bool, m_bInReload);
//bool m_bInReload; // Are we in the middle of a reload;
int m_bReloadComplete;
bool m_bFireOnEmpty; // True when the gun is empty and the player is still holding down the attack key(s)
bool m_bFiringWholeClip; // Are we in the middle of firing the whole clip;
// Weapon art
CNetworkVar(int, m_iViewModelIndex);
CNetworkVar(int, m_iWorldModelIndex);
// Sounds
float m_flNextEmptySoundTime; // delay on empty sound playing
Activity GetIdealActivity(void) { return m_IdealActivity; }
int GetIdealSequence(void) { return m_nIdealSequence; }
bool SetIdealActivity(Activity ideal);
void MaintainIdealActivity(void);
private:
Activity m_Activity;
int m_nIdealSequence;
Activity m_IdealActivity;
bool m_bRemoveable;
int m_iPrimaryAmmoCount;
int m_iSecondaryAmmoCount;
float m_wSequence;
float m_wSequence2;
public:
IMPLEMENT_NETWORK_VAR_FOR_DERIVED(m_nNextThinkTick);
int WeaponState() const { return m_iState; }
// Weapon data
CNetworkVar(int, m_iState); // See WEAPON_* definition
string_t m_iszName; // Classname of this weapon.
CNetworkVar(int, m_iPrimaryAmmoType); // "primary" ammo index into the ammo info array
CNetworkVar(int, m_iSecondaryAmmoType); // "secondary" ammo index into the ammo info array
CNetworkVar(int, m_iClip1); // number of shots left in the primary weapon clip, -1 it not used
CNetworkVar(int, m_iClip2); // number of shots left in the secondary weapon clip, -1 it not used
bool m_bFiresUnderwater; // true if this weapon can fire underwater
bool m_bAltFiresUnderwater; // true if this weapon can fire underwater
float m_fMinRange1; // What's the closest this weapon can be used?
float m_fMinRange2; // What's the closest this weapon can be used?
float m_fMaxRange1; // What's the furthest this weapon can be used?
float m_fMaxRange2; // What's the furthest this weapon can be used?
bool m_bReloadsSingly; // True if this weapon reloads 1 round at a time
float m_fFireDuration; // The amount of time that the weapon has sustained firing
int m_iSubType;
float m_flUnlockTime;
EHANDLE m_hLocker; // Who locked this weapon.
CNetworkVar(bool, m_bFlipViewModel);
IPhysicsConstraint *GetConstraint() { return m_pConstraint; }
private:
WEAPON_FILE_INFO_HANDLE m_hWeaponFileInfo;
IPhysicsConstraint *m_pConstraint;
int m_iAltFireHudHintCount; // How many times has this weapon displayed its alt-fire HUD hint?
int m_iReloadHudHintCount; // How many times has this weapon displayed its reload HUD hint?
bool m_bAltFireHudHintDisplayed; // Have we displayed an alt-fire HUD hint since this weapon was deployed?
bool m_bReloadHudHintDisplayed; // Have we displayed a reload HUD hint since this weapon was deployed?
float m_flHudHintPollTime; // When to poll the weapon again for whether it should display a hud hint.
float m_flHudHintMinDisplayTime; // if the hint is squelched before this, reset my counter so we'll display it again.
// Server only
#if !defined( CLIENT_DLL )
// Outputs
protected:
COutputEvent m_OnPlayerUse; // Fired when the player uses the weapon.
COutputEvent m_OnPlayerPickup; // Fired when the player picks up the weapon.
COutputEvent m_OnNPCPickup; // Fired when an NPC picks up the weapon.
COutputEvent m_OnCacheInteraction; // For awarding lambda cache achievements in HL2 on 360. See .FGD file for details
#else // Client .dll only
bool m_bJustRestored;
// Allow weapons resource to access m_hWeaponFileInfo directly
friend class WeaponsResource;
protected:
int m_iOldState;
#endif // End Client .dll only
};
CBaseCombatWeapon* GetGlobalWeaponEntity();
#endif // COMBATWEAPON_SHARED_H