summaryrefslogtreecommitdiffstats
path: root/src/entities/Ped.cpp
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2019-07-01 21:46:44 +0200
committereray orçunus <erayorcunus@gmail.com>2019-07-02 05:01:26 +0200
commit27838ae0b2a11d505d669fe4cad6d0372cb650e1 (patch)
tree477b9853bea245d9cbdaa8700e02ff980abe79d5 /src/entities/Ped.cpp
parentCPed fixes (diff)
downloadre3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.tar
re3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.tar.gz
re3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.tar.bz2
re3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.tar.lz
re3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.tar.xz
re3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.tar.zst
re3-27838ae0b2a11d505d669fe4cad6d0372cb650e1.zip
Diffstat (limited to '')
-rw-r--r--src/entities/Ped.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp
index 963454b8..e908f14c 100644
--- a/src/entities/Ped.cpp
+++ b/src/entities/Ped.cpp
@@ -435,6 +435,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_ped_flagI4 = false;
bRecordedForReplay = false;
m_ped_flagI10 = false;
+#ifdef KANGAROO_CHEAT
+ m_ped_flagI80 = false;
+#endif
if ((CGeneral::GetRandomNumber() & 3) == 0)
m_ped_flagD1 = true;
@@ -461,12 +464,12 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
for(int i = 0; i < NUM_PED_WEAPONTYPES; i++)
{
- CWeapon *weapon = GetWeapon(i);
- weapon->m_eWeaponType = WEAPONTYPE_UNARMED;
- weapon->m_eWeaponState = WEAPONSTATE_READY;
- weapon->m_nAmmoInClip = 0;
- weapon->m_nAmmoTotal = 0;
- weapon->m_nTimer = 0;
+ CWeapon &weapon = GetWeapon(i);
+ weapon.m_eWeaponType = WEAPONTYPE_UNARMED;
+ weapon.m_eWeaponState = WEAPONSTATE_READY;
+ weapon.m_nAmmoInClip = 0;
+ weapon.m_nAmmoTotal = 0;
+ weapon.m_nTimer = 0;
}
m_lastHitState = 0;
@@ -479,23 +482,27 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
CPopulation::UpdatePedCount(m_nPedType, false);
}
-void
+uint32
CPed::GiveWeapon(eWeaponType weaponType, uint32 ammo)
{
+ CWeapon &weapon = GetWeapon(weaponType);
+
if (HasWeapon(weaponType)) {
- if (ammo > 99999)
- m_weapons[weaponType].m_nAmmoTotal = 99999;
+ if (weapon.m_nAmmoTotal + ammo > 99999)
+ weapon.m_nAmmoTotal = 99999;
else
- m_weapons[weaponType].m_nAmmoTotal = ammo;
+ weapon.m_nAmmoTotal += ammo;
- m_weapons[weaponType].Reload();
+ weapon.Reload();
} else {
- m_weapons[weaponType].Initialise(weaponType, ammo);
+ weapon.Initialise(weaponType, ammo);
// TODO: It seems game uses this as both weapon count and max WeaponType we have, which is ofcourse erroneous.
m_maxWeaponTypeAllowed++;
}
- if (m_weapons[weaponType].m_eWeaponState == WEAPONSTATE_OUT_OF_AMMO)
- m_weapons[weaponType].m_eWeaponState = WEAPONSTATE_READY;
+ if (weapon.m_eWeaponState == WEAPONSTATE_OUT_OF_AMMO)
+ weapon.m_eWeaponState = WEAPONSTATE_READY;
+
+ return weaponType;
}
static RwObject*
@@ -1227,8 +1234,8 @@ bool
CPed::SelectGunIfArmed(void)
{
for (int i = 0; i < m_maxWeaponTypeAllowed; i++) {
- if (GetWeapon(i)->m_nAmmoTotal > 0) {
- eWeaponType weaponType = GetWeapon(i)->m_eWeaponType;
+ if (GetWeapon(i).m_nAmmoTotal > 0) {
+ eWeaponType weaponType = GetWeapon(i).m_eWeaponType;
if (weaponType >= WEAPONTYPE_COLT45 && weaponType != WEAPONTYPE_M16 && weaponType <= WEAPONTYPE_FLAMETHROWER) {
SetCurrentWeapon(i);
return true;