Cleanup weapon class

Added ShowInfo, SetItemSlot and SetIdleState
This commit is contained in:
smallmodel 2023-08-12 00:10:47 +02:00
parent ddac42e21e
commit a175ea27d7
No known key found for this signature in database
GPG key ID: A96F163ED4891440
2 changed files with 3206 additions and 3678 deletions

File diff suppressed because it is too large Load diff

View file

@ -155,7 +155,6 @@ protected:
float min_charge_time[MAX_FIREMODES]; // The min amount of time the weapon may be charged. float min_charge_time[MAX_FIREMODES]; // The min amount of time the weapon may be charged.
meansOfDeath_t meansofdeath[MAX_FIREMODES]; // The means of death for this mode meansOfDeath_t meansofdeath[MAX_FIREMODES]; // The means of death for this mode
qboolean loopfire[MAX_FIREMODES]; // The weapon loopfires and will not idle when shooting qboolean loopfire[MAX_FIREMODES]; // The weapon loopfires and will not idle when shooting
int action_level_increment[MAX_FIREMODES]; // Increments the action level everytime the weapon is fired
str worldhitspawn[MAX_FIREMODES]; // The models to spawn when the weapon strikes the world str worldhitspawn[MAX_FIREMODES]; // The models to spawn when the weapon strikes the world
int tracerfrequency[MAX_FIREMODES]; int tracerfrequency[MAX_FIREMODES];
int tracercount[MAX_FIREMODES]; int tracercount[MAX_FIREMODES];
@ -206,6 +205,9 @@ protected:
qboolean m_bSecondaryAmmoInHud; qboolean m_bSecondaryAmmoInHud;
public: public:
//
// Stats variables
//
int m_iNumShotsFired; int m_iNumShotsFired;
int m_iNumHits; int m_iNumHits;
int m_iNumHeadShots; int m_iNumHeadShots;
@ -218,18 +220,26 @@ public:
AIRanges mAIRange; AIRanges mAIRange;
SafePtr<Entity> aim_target; SafePtr<Entity> aim_target;
protected:
friend class Player;
friend class PlayerBot;
friend class Sentient;
void SetMaxRangeEvent(Event *ev); void SetMaxRangeEvent(Event *ev);
void SetMinRangeEvent(Event *ev); void SetMinRangeEvent(Event *ev);
void SetSecondaryAmmo(const char *type, int amount, int startamount); void SetSecondaryAmmo(const char *type, int amount, int startamount);
friend class Player;
void DetachGun(void); void DetachGun(void);
void AttachGun(weaponhand_t hand, qboolean holstering = qfalse); void AttachGun(weaponhand_t hand, qboolean holstering = qfalse);
qboolean IsSecondaryWeapon(void);
void PickupWeapon(Event *ev); void PickupWeapon(Event *ev);
void DoneRaising(Event *ev); void DoneRaising(Event *ev);
void DoneFiring(Event *ev); void DoneFiring(Event *ev);
void Idle(Event *ev); void Idle(Event *ev);
void IdleInit(Event *ev); void IdleInit(Event* ev);
qboolean CheckReload(firemode_t mode); void FillAmmoClip(Event* ev);
void EmptyAmmoClip(Event* ev);
void AddToAmmoClip(Event* ev);
void DoneReloading(Event *ev); void DoneReloading(Event *ev);
void ApplyFireKickback(const Vector& org, float kickback); void ApplyFireKickback(const Vector& org, float kickback);
void SetAimAnim(Event *ev); void SetAimAnim(Event *ev);
@ -240,15 +250,15 @@ public:
void SetProjectile(Event *ev); void SetProjectile(Event *ev);
void SetDMProjectile(Event *ev); void SetDMProjectile(Event *ev);
void SetBulletDamage(Event *ev); void SetBulletDamage(Event *ev);
void SetBulletLarge(Event *ev); void SetBulletLarge(Event *ev); // Added in 2.0
void SetTracerSpeed(Event *ev); void SetTracerSpeed(Event *ev); // Added in 2.0
void SetDMBulletDamage(Event *ev); void SetDMBulletDamage(Event *ev);
void SetBulletRange(Event *ev); void SetBulletRange(Event *ev);
void SetDMBulletRange(Event *ev); void SetDMBulletRange(Event *ev);
void SetBulletKnockback(Event *ev); void SetBulletKnockback(Event *ev);
void SetDMBulletKnockback(Event *ev); void SetDMBulletKnockback(Event *ev);
void SetBulletThroughWood(Event *ev); void SetBulletThroughWood(Event *ev); // Added in 2.0
void SetBulletThroughMetal(Event *ev); void SetBulletThroughMetal(Event *ev); // Added in 2.0
void SetBulletCount(Event *ev); void SetBulletCount(Event *ev);
void SetDMBulletCount(Event *ev); void SetDMBulletCount(Event *ev);
void SetBulletSpread(Event *ev); void SetBulletSpread(Event *ev);
@ -259,11 +269,12 @@ public:
void SetDMFireSpreadMult(Event *ev); void SetDMFireSpreadMult(Event *ev);
void SetTracerFrequency(Event *ev); void SetTracerFrequency(Event *ev);
void SetAutoPutaway(Event *ev); void SetAutoPutaway(Event *ev);
void SetRange(Event *ev); void SetRange(Event* ev);
void SetSpecialMove(Event *ev); void SetWeaponType(Event* ev);
void SetUseNoAmmo(Event *ev); void SetWeaponGroup(Event* ev);
void SetUseNoAmmo(Event* ev);
void MainAttachToTag(Event* ev);
void OffHandAttachToTag(Event *ev); void OffHandAttachToTag(Event *ev);
void MainAttachToTag(Event *ev);
void HolsterAttachToTag(Event *ev); void HolsterAttachToTag(Event *ev);
void SetHolsterOffset(Event *ev); void SetHolsterOffset(Event *ev);
void SetHolsterAngles(Event *ev); void SetHolsterAngles(Event *ev);
@ -272,51 +283,48 @@ public:
void SetViewKick(Event *ev); void SetViewKick(Event *ev);
void SetMovementSpeed(Event *ev); void SetMovementSpeed(Event *ev);
void SetDMMovementSpeed(Event *ev); void SetDMMovementSpeed(Event *ev);
void SetMaxFireMovement(Event *ev); void SetMaxFireMovement(Event *ev); // Added in 2.0
void SetZoomMovement(Event *ev); void SetZoomMovement(Event *ev); // Added in 2.0
void EventAmmoPickupSound(Event *ev); void EventAmmoPickupSound(Event *ev);
void EventNoAmmoSound(Event *ev); void EventNoAmmoSound(Event *ev);
void EventMaxMovementSound(Event *ev); void EventMaxMovementSound(Event *ev); // Added in 2.0
//====
// Added in 2.0
void SetNumFireAnims(Event *ev); void SetNumFireAnims(Event *ev);
void SetWeaponSubtype(Event *ev); void SetWeaponSubtype(Event *ev);
void SetCookTime(Event *ev); void SetCookTime(Event *ev);
void SetCurrentFireAnim(Event *ev); void SetCurrentFireAnim(Event *ev);
void SetSecondaryAmmoInHud(Event *ev); void SetSecondaryAmmoInHud(Event* ev);
void SetWeaponGroup(Event *ev); //====
void SetWeaponType(Event *ev); virtual void ShowInfo(float fDot, float fDist);
void EventClipAdd(Event *ev);
void EventClipEmpty(Event *ev);
void EventClipFill(Event *ev);
float GetBulletRange(firemode_t firemode);
public: public:
CLASS_PROTOTYPE(Weapon); CLASS_PROTOTYPE(Weapon);
Weapon(); Weapon();
Weapon(const char *file); Weapon(const char* file);
~Weapon(); ~Weapon();
void Delete(void) override; void Delete(void) override;
Listener *GetScriptOwner(void) override;
int GetRank(void); int GetRank(void);
int GetOrder(void); int GetOrder(void);
int GetWeaponClass(void) const { return weapon_class; }; int GetWeaponClass(void) const;
const_str GetWeaponGroup(void) const { return m_csWeaponGroup; }; const_str GetWeaponGroup(void) const;
void SetItemSlot(int slot);
void SetRank(int order, int rank); void SetRank(int order, int rank);
void SetRankEvent(Event *ev); void SetRankEvent(Event *ev);
float GetMaxRange(void); float GetMaxRange(void);
float GetMinRange(void); float GetMinRange(void);
inline qboolean GetPutaway(void) { return putaway; }; qboolean GetPutaway(void);
inline void SetPutAway(qboolean p) { putaway = p; }; void SetPutAway(qboolean p);
void SetMaxRange(float val); void SetMaxRange(float val);
void SetMinRange(float val); void SetMinRange(float val);
qboolean IsSecondaryWeapon(void);
void ForceIdle(void); void ForceIdle(void);
virtual qboolean SetWeaponAnim(const char *anim, Event *ev = NULL); virtual qboolean SetWeaponAnim(const char *anim, Event *ev = NULL);
qboolean SetWeaponAnim(const char *anim, Event &ev); qboolean SetWeaponAnim(const char *anim, Event &ev);
@ -333,15 +341,14 @@ public:
int GetMaxAmmo(firemode_t mode); int GetMaxAmmo(firemode_t mode);
str GetAmmoType(firemode_t mode); str GetAmmoType(firemode_t mode);
firetype_t GetFireType(firemode_t mode); firetype_t GetFireType(firemode_t mode);
firemode_t GetFireMode(void);
void SetAmmoType(Event *ev); void SetAmmoType(Event *ev);
void SetAmmoAmount(int amount, firemode_t mode); void SetAmmoAmount(int amount, firemode_t mode);
void UseAmmo(int amount, firemode_t mode); void UseAmmo(int amount, firemode_t mode);
void SetAmmoClipSize(Event *ev); void SetAmmoClipSize(Event *ev);
void SetAmmoInClip(Event *ev); void SetAmmoInClip(Event *ev);
void SetShareClip(Event *ev); void SetShareClip(Event *ev);
void SetTagBarrel(const char* tagBarrel); void SetTagBarrel(const char* tagBarrel); // Added in 2.0
str GetTagBarrel() const; str GetTagBarrel() const; // Added in 2.0
void SetModels(const char *world, const char *view); void SetModels(const char *world, const char *view);
void SetOwner(Sentient *ent) override; void SetOwner(Sentient *ent) override;
void SetMaxChargeTime(Event *ev); void SetMaxChargeTime(Event *ev);
@ -352,18 +359,24 @@ public:
qboolean UnlimitedAmmo(firemode_t mode); qboolean UnlimitedAmmo(firemode_t mode);
qboolean HasAmmo(firemode_t mode); qboolean HasAmmo(firemode_t mode);
qboolean HasAmmoInClip(firemode_t mode); qboolean HasAmmoInClip(firemode_t mode);
qboolean IsSemiAuto(void);
int GetClipSize(firemode_t mode); int GetClipSize(firemode_t mode);
qboolean CheckReload(firemode_t mode);
qboolean ShouldReload(void);
void SetShouldReload(qboolean should_reload);
void StartReloading(void);
qboolean ReadyToFire(firemode_t mode, qboolean playsound = qtrue); qboolean ReadyToFire(firemode_t mode, qboolean playsound = qtrue);
qboolean MuzzleClear(void); qboolean MuzzleClear(void);
void PutAway(void); void PutAway(void);
qboolean Drop(void) override; qboolean Drop(void) override;
void Fire(firemode_t mode); void Fire(firemode_t mode);
void Charge(firemode_t mode); void Charge(firemode_t mode);
void OnOverCookedWarning(Event *ev); void OnOverCookedWarning(Event *ev); // Added in 2.0
void OnOverCooked(Event *ev); void OnOverCooked(Event *ev); // Added in 2.0
void ReleaseFire(firemode_t mode, float chargetime); void ReleaseFire(firemode_t mode, float chargetime);
const char* GetFireAnim() const; const char* GetFireAnim() const; // Added in 2.0
void ClientFireDone(void); void ClientFireDone(void);
qboolean Removable(void) override; qboolean Removable(void) override;
qboolean Pickupable(Entity *other) override; qboolean Pickupable(Entity *other) override;
@ -374,19 +387,15 @@ public:
Vector *position, Vector *forward = NULL, Vector *right = NULL, Vector *up = NULL, Vector *vBarrelPos = NULL Vector *position, Vector *forward = NULL, Vector *right = NULL, Vector *up = NULL, Vector *vBarrelPos = NULL
); );
qboolean AutoChange(void); qboolean AutoChange(void);
int ClipAmmo(firemode_t mode); int ClipAmmo(firemode_t mode);
void ProcessWeaponCommandsEvent(Event *ev); qboolean IsDroppable(void);
qboolean IsDroppable(void);
float FireDelay(firemode_t mode); float FireDelay(firemode_t mode);
void EventSetFireDelay(Event *ev); void SetFireDelay(Event *ev);
void EventSetDMFireDelay(Event *ev); void SetDMFireDelay(Event* ev);
qboolean HasCrosshair() { return crosshair; } weaponstate_t GetState(void);
int ActionLevelIncrement(firemode_t mode);
void SetActionLevelIncrement(Event *ev);
weaponstate_t GetState(void);
void ForceState(weaponstate_t state); void ForceState(weaponstate_t state);
void NotDroppableEvent(Event *ev); void NotDroppableEvent(Event *ev);
void GiveStartingAmmoToOwner(Event *ev); void GiveStartingAmmoToOwner(Event *ev);
void AutoAim(Event *ev); void AutoAim(Event *ev);
@ -397,37 +406,43 @@ public:
void AttachToHand(Event *ev); void AttachToHand(Event *ev);
void SetCantPartialReload(Event *ev); void SetCantPartialReload(Event *ev);
void SetDMCantPartialReload(Event *ev); void SetDMCantPartialReload(Event *ev);
void AddAdditionalStartAmmo(Event *ev); void AddAdditionalStartAmmo(Event *ev); // Added in 2.0
void AddStartItem(Event *ev); void AddStartItem(Event *ev); // Added in 2.0
void SetQuiet(Event *ev); void SetQuiet(Event *ev);
void SetLoopFire(Event *ev); void SetLoopFire(Event *ev);
inline virtual void SpecialFireProjectile( virtual void SpecialFireProjectile(
Vector pos, Vector forward, Vector right, Vector up, Entity *owner, str projectileModel, float charge_fraction Vector pos, Vector forward, Vector right, Vector up, Entity *owner, str projectileModel, float charge_fraction
) {}; );
void AttachToHolster(weaponhand_t hand);
virtual bool IsCarryableTurret();
inline str GetCurrentAttachToTag(void) { return current_attachToTag; }; void AttachToHolster(weaponhand_t hand);
str GetCurrentAttachToTag(void);
inline void SetCurrentAttachToTag(str s) { current_attachToTag = s; }; void SetCurrentAttachToTag(str s);
str GetHolsterTag(void);
inline str GetHolsterTag(void) { return holster_attachToTag; }; qboolean GetUseNoAmmo(void);
inline qboolean GetUseNoAmmo(void) { return use_no_ammo; };
int GetZoom(void); int GetZoom(void);
qboolean GetAutoZoom(void); qboolean GetAutoZoom(void);
void SetMeansOfDeath(Event *ev); void SetMeansOfDeath(Event *ev);
meansOfDeath_t GetMeansOfDeath(firemode_t mode); meansOfDeath_t GetMeansOfDeath(firemode_t mode);
void SetAimTarget(Entity *); void SetAimTarget(Entity*);
qboolean ShouldReload(void); void SetIdleState(int state); // Added in 2.0
void SetShouldReload(qboolean should_reload);
void StartReloading(void);
void WorldHitSpawn(firemode_t mode, Vector org, Vector angles, float life); void WorldHitSpawn(firemode_t mode, Vector org, Vector angles, float life);
void MakeNoise(Event *ev); void MakeNoise(Event *ev);
void FallingAngleAdjust(Event *ev); void FallingAngleAdjust(Event *ev);
qboolean GetUseCrosshair() const; float GetMovementSpeed() const;
qboolean GetUseCrosshair() const;
virtual bool IsCarryableTurret(); // Added in 2.0
void Archive(Archiver &arc) override; void Archive(Archiver &arc) override;
//
// Added in openmohaa
//
Listener* GetScriptOwner(void) override;
float GetBulletRange(firemode_t firemode);
firemode_t GetFireMode(void);
qboolean IsSemiAuto(void);
}; };
inline void Weapon::Archive(Archiver& arc) inline void Weapon::Archive(Archiver& arc)