diff options
Diffstat (limited to '')
-rw-r--r-- | src/weapons/Weapon.cpp | 37 | ||||
-rw-r--r-- | src/weapons/Weapon.h | 10 |
2 files changed, 44 insertions, 3 deletions
diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index fea09245..0c48db6b 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -1,6 +1,41 @@ #include "common.h" #include "patcher.h" #include "Weapon.h" +#include "Timer.h" +#include "WeaponInfo.h" WRAPPER bool CWeapon::Fire(CEntity*, CVector*) { EAXJMP(0x55C380); } -WRAPPER void CWeapon::AddGunshell(CEntity*, CVector const&, CVector2D const&, float) { EAXJMP(0x55F770); }
\ No newline at end of file +WRAPPER void CWeapon::AddGunshell(CEntity*, CVector const&, CVector2D const&, float) { EAXJMP(0x55F770); } + +void +CWeapon::Initialise(eWeaponType type, int ammo) +{ + m_eWeaponType = type; + m_eWeaponState = WEAPONSTATE_READY; + if (ammo > 99999) + m_nAmmoTotal = 99999; + else + m_nAmmoTotal = ammo; + m_nAmmoInClip = 0; + Reload(); + m_nTimer = 0; +} + +void +CWeapon::Reload(void) +{ + if (m_nAmmoTotal == 0) + return; + + CWeaponInfo *info = CWeaponInfo::GetWeaponInfo(m_eWeaponType); + + if (m_nAmmoTotal >= info->m_nAmountofAmmunition) + m_nAmmoInClip = info->m_nAmountofAmmunition; + else + m_nAmmoInClip = m_nAmmoTotal; +} + +STARTPATCHES + InjectHook(0x55C330, &CWeapon::Initialise, PATCH_JUMP); + InjectHook(0x5639D0, &CWeapon::Reload, PATCH_JUMP); +ENDPATCHES
\ No newline at end of file diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index aebcb2c6..7327e1f9 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -45,11 +45,17 @@ class CWeapon public: eWeaponType m_eWeaponType; eWeaponState m_eWeaponState; - int32 m_nAmmoInClip; - int32 m_nAmmoTotal; + uint32 m_nAmmoInClip; + uint32 m_nAmmoTotal; int32 m_nTimer; bool m_bAddRotOffset; + CWeapon() { + m_bAddRotOffset = false; + } + + void Initialise(eWeaponType type, int ammo); + void Reload(void); bool Fire(CEntity*, CVector*); void AddGunshell(CEntity*, CVector const&, CVector2D const&, float); }; |