summaryrefslogtreecommitdiffstats
path: root/src/weapons/Weapon.cpp
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2019-06-30 23:50:40 +0200
committereray orçunus <erayorcunus@gmail.com>2019-07-01 01:48:09 +0200
commitce28a6d298408513866716d00dcd16ed8ef5f285 (patch)
tree81e83f4689238683112b4776006262bfdbc88506 /src/weapons/Weapon.cpp
parentMerge branch 'master' of git://github.com/GTAmodding/re3 into erorcun (diff)
downloadre3-ce28a6d298408513866716d00dcd16ed8ef5f285.tar
re3-ce28a6d298408513866716d00dcd16ed8ef5f285.tar.gz
re3-ce28a6d298408513866716d00dcd16ed8ef5f285.tar.bz2
re3-ce28a6d298408513866716d00dcd16ed8ef5f285.tar.lz
re3-ce28a6d298408513866716d00dcd16ed8ef5f285.tar.xz
re3-ce28a6d298408513866716d00dcd16ed8ef5f285.tar.zst
re3-ce28a6d298408513866716d00dcd16ed8ef5f285.zip
Diffstat (limited to 'src/weapons/Weapon.cpp')
-rw-r--r--src/weapons/Weapon.cpp37
1 files changed, 36 insertions, 1 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