123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- #ifndef __GAME_WEAPON_H__
- #define __GAME_WEAPON_H__
- #include "PredictedValue.h"
- extern const idEventDef EV_Weapon_State;
- typedef enum {
- WP_READY,
- WP_OUTOFAMMO,
- WP_RELOAD,
- WP_HOLSTERED,
- WP_RISING,
- WP_LOWERING
- } weaponStatus_t;
- typedef int ammo_t;
- static const int AMMO_NUMTYPES = 16;
- class idPlayer;
- static const int LIGHTID_WORLD_MUZZLE_FLASH = 1;
- static const int LIGHTID_VIEW_MUZZLE_FLASH = 100;
- class idMoveableItem;
- typedef struct {
- char name[64];
- char particlename[128];
- bool active;
- int startTime;
- jointHandle_t joint;
- bool smoke;
- const idDeclParticle* particle;
- idFuncEmitter* emitter;
- } WeaponParticle_t;
- typedef struct {
- char name[64];
- bool active;
- int startTime;
- jointHandle_t joint;
- int lightHandle;
- renderLight_t light;
- } WeaponLight_t;
- class idWeapon : public idAnimatedEntity {
- public:
- CLASS_PROTOTYPE( idWeapon );
- idWeapon();
- virtual ~idWeapon();
-
- void Spawn();
- void SetOwner( idPlayer *owner );
- idPlayer* GetOwner();
- virtual bool ShouldConstructScriptObjectAtSpawn() const;
- void SetFlashlightOwner( idPlayer *owner );
- static void CacheWeapon( const char *weaponName );
-
- void Save( idSaveGame *savefile ) const;
- void Restore( idRestoreGame *savefile );
-
- void Clear();
- void GetWeaponDef( const char *objectname, int ammoinclip );
- bool IsLinked();
- bool IsWorldModelReady();
-
- const char * Icon() const;
- void UpdateGUI();
- const char * PdaIcon() const;
- const char * DisplayName() const;
- const char * Description() const;
- virtual void SetModel( const char *modelname );
- bool GetGlobalJointTransform( bool viewModel, const jointHandle_t jointHandle, idVec3 &offset, idMat3 &axis );
- void SetPushVelocity( const idVec3 &pushVelocity );
- bool UpdateSkin();
-
- void Think();
- void Raise();
- void PutAway();
- void Reload();
- void LowerWeapon();
- void RaiseWeapon();
- void HideWeapon();
- void ShowWeapon();
- void HideWorldModel();
- void ShowWorldModel();
- void OwnerDied();
- void BeginAttack();
- void EndAttack();
- bool IsReady() const;
- bool IsReloading() const;
- bool IsHolstered() const;
- bool ShowCrosshair() const;
- idEntity * DropItem( const idVec3 &velocity, int activateDelay, int removeDelay, bool died );
- bool CanDrop() const;
- void WeaponStolen();
- void ForceAmmoInClip();
- weaponStatus_t GetStatus() { return status; };
-
- virtual idThread * ConstructScriptObject();
- virtual void DeconstructScriptObject();
- void SetState( const char *statename, int blendFrames );
- void UpdateScript();
- void EnterCinematic();
- void ExitCinematic();
- void NetCatchup();
-
- void PresentWeapon( bool showViewModel );
- int GetZoomFov();
- void GetWeaponAngleOffsets( int *average, float *scale, float *max );
- void GetWeaponTimeOffsets( float *time, float *scale );
- bool BloodSplat( float size );
- void SetIsPlayerFlashlight( bool bl ) { isPlayerFlashlight = bl; }
- void FlashlightOn();
- void FlashlightOff();
-
- static ammo_t GetAmmoNumForName( const char *ammoname );
- static const char *GetAmmoNameForNum( ammo_t ammonum );
- static const char *GetAmmoPickupNameForNum( ammo_t ammonum );
- ammo_t GetAmmoType() const;
- int AmmoAvailable() const;
- int AmmoInClip() const;
- void ResetAmmoClip();
- int ClipSize() const;
- int LowAmmo() const;
- int AmmoRequired() const;
- int AmmoCount() const;
- int GetGrabberState() const;
-
- idAnimatedEntity * GetWorldModel() { return worldModel.GetEntity(); }
- virtual void WriteToSnapshot( idBitMsg &msg ) const;
- virtual void ReadFromSnapshot( const idBitMsg &msg );
- enum {
- EVENT_RELOAD = idEntity::EVENT_MAXEVENTS,
- EVENT_ENDRELOAD,
- EVENT_CHANGESKIN,
- EVENT_MAXEVENTS
- };
- virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
- virtual void ClientPredictionThink();
- virtual void ClientThink( const int curTime, const float fraction, const bool predict );
- void MuzzleFlashLight();
- void RemoveMuzzleFlashlight();
-
-
-
- bool GetMuzzlePositionWithHacks( idVec3 & origin, idMat3 & axis );
- void GetProjectileLaunchOriginAndAxis( idVec3 & origin, idMat3 & axis );
- const idDeclEntityDef * GetDeclEntityDef() { return weaponDef; }
- friend class idPlayer;
- private:
-
- idScriptBool WEAPON_ATTACK;
- idScriptBool WEAPON_RELOAD;
- idScriptBool WEAPON_NETRELOAD;
- idScriptBool WEAPON_NETENDRELOAD;
- idScriptBool WEAPON_NETFIRING;
- idScriptBool WEAPON_RAISEWEAPON;
- idScriptBool WEAPON_LOWERWEAPON;
- weaponStatus_t status;
- idThread * thread;
- idStr state;
- idStr idealState;
- int animBlendFrames;
- int animDoneTime;
- bool isLinked;
- bool isPlayerFlashlight;
-
- idEntity *projectileEnt;
- idPlayer * owner;
- idEntityPtr<idAnimatedEntity> worldModel;
-
- int hideTime;
- float hideDistance;
- int hideStartTime;
- float hideStart;
- float hideEnd;
- float hideOffset;
- bool hide;
- bool disabled;
-
- int berserk;
-
- idVec3 playerViewOrigin;
- idMat3 playerViewAxis;
-
- idVec3 viewWeaponOrigin;
- idMat3 viewWeaponAxis;
-
-
- idVec3 muzzleOrigin;
- idMat3 muzzleAxis;
- idVec3 pushVelocity;
-
-
-
- const idDeclEntityDef * weaponDef;
- const idDeclEntityDef * meleeDef;
- idDict projectileDict;
- float meleeDistance;
- idStr meleeDefName;
- idDict brassDict;
- int brassDelay;
- idStr icon;
- idStr pdaIcon;
- idStr displayName;
- idStr itemDesc;
-
- renderLight_t guiLight;
- int guiLightHandle;
-
- renderLight_t muzzleFlash;
- int muzzleFlashHandle;
- renderLight_t worldMuzzleFlash;
- int worldMuzzleFlashHandle;
- float fraccos;
- float fraccos2;
- idVec3 flashColor;
- int muzzleFlashEnd;
- int flashTime;
- bool lightOn;
- bool silent_fire;
- bool allowDrop;
-
- bool hasBloodSplat;
-
- int kick_endtime;
- int muzzle_kick_time;
- int muzzle_kick_maxtime;
- idAngles muzzle_kick_angles;
- idVec3 muzzle_kick_offset;
-
- ammo_t ammoType;
- int ammoRequired;
- int clipSize;
- idPredictedValue< int > ammoClip;
- int lowAmmo;
- bool powerAmmo;
-
-
- bool isFiring;
-
- int zoomFov;
-
- jointHandle_t barrelJointView;
- jointHandle_t flashJointView;
- jointHandle_t ejectJointView;
- jointHandle_t guiLightJointView;
- jointHandle_t ventLightJointView;
- jointHandle_t flashJointWorld;
- jointHandle_t barrelJointWorld;
- jointHandle_t ejectJointWorld;
- jointHandle_t smokeJointView;
- idHashTable<WeaponParticle_t> weaponParticles;
- idHashTable<WeaponLight_t> weaponLights;
-
- const idSoundShader * sndHum;
-
- const idDeclParticle * weaponSmoke;
- int weaponSmokeStartTime;
- bool continuousSmoke;
- const idDeclParticle * strikeSmoke;
- int strikeSmokeStartTime;
- idVec3 strikePos;
- idMat3 strikeAxis;
- int nextStrikeFx;
-
- bool nozzleFx;
-
- int nozzleFxFade;
- int lastAttack;
- renderLight_t nozzleGlow;
- int nozzleGlowHandle;
- idVec3 nozzleGlowColor;
- const idMaterial * nozzleGlowShader;
- float nozzleGlowRadius;
-
- int weaponAngleOffsetAverages;
- float weaponAngleOffsetScale;
- float weaponAngleOffsetMax;
- float weaponOffsetTime;
- float weaponOffsetScale;
-
- void AlertMonsters();
-
- void InitWorldModel( const idDeclEntityDef *def );
- void MuzzleRise( idVec3 &origin, idMat3 &axis );
- void UpdateNozzleFx();
- void UpdateFlashPosition();
-
- void Event_Clear();
- void Event_GetOwner();
- void Event_WeaponState( const char *statename, int blendFrames );
- void Event_SetWeaponStatus( float newStatus );
- void Event_WeaponReady();
- void Event_WeaponOutOfAmmo();
- void Event_WeaponReloading();
- void Event_WeaponHolstered();
- void Event_WeaponRising();
- void Event_WeaponLowering();
- void Event_UseAmmo( int amount );
- void Event_AddToClip( int amount );
- void Event_AmmoInClip();
- void Event_AmmoAvailable();
- void Event_TotalAmmoCount();
- void Event_ClipSize();
- void Event_PlayAnim( int channel, const char *animname );
- void Event_PlayCycle( int channel, const char *animname );
- void Event_AnimDone( int channel, int blendFrames );
- void Event_SetBlendFrames( int channel, int blendFrames );
- void Event_GetBlendFrames( int channel );
- void Event_Next();
- void Event_SetSkin( const char *skinname );
- void Event_Flashlight( int enable );
- void Event_GetLightParm( int parmnum );
- void Event_SetLightParm( int parmnum, float value );
- void Event_SetLightParms( float parm0, float parm1, float parm2, float parm3 );
- void Event_LaunchProjectiles( int num_projectiles, float spread, float fuseOffset, float launchPower, float dmgPower );
- void Event_CreateProjectile();
- void Event_EjectBrass();
- void Event_Melee();
- void Event_GetWorldModel();
- void Event_AllowDrop( int allow );
- void Event_AutoReload();
- void Event_NetReload();
- void Event_IsInvisible();
- void Event_NetEndReload();
- idGrabber grabber;
- int grabberState;
- void Event_Grabber( int enable );
- void Event_GrabberHasTarget();
- void Event_GrabberSetGrabDistance( float dist );
- void Event_LaunchProjectilesEllipse( int num_projectiles, float spreada, float spreadb, float fuseOffset, float power );
- void Event_LaunchPowerup( const char* powerup, float duration, int useAmmo );
- void Event_StartWeaponSmoke();
- void Event_StopWeaponSmoke();
- void Event_StartWeaponParticle( const char* name);
- void Event_StopWeaponParticle( const char* name);
- void Event_StartWeaponLight( const char* name);
- void Event_StopWeaponLight( const char* name);
- };
- ID_INLINE bool idWeapon::IsLinked() {
- return isLinked;
- }
- ID_INLINE bool idWeapon::IsWorldModelReady() {
- return ( worldModel.GetEntity() != NULL );
- }
- ID_INLINE idPlayer* idWeapon::GetOwner() {
- return owner;
- }
- #endif
|