summaryrefslogtreecommitdiffstats
path: root/src/entities/Ped.cpp
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-07-02 07:43:00 +0200
committerGitHub <noreply@github.com>2019-07-02 07:43:00 +0200
commitb2d1433392483c3e1faafcf5127885cb425527e0 (patch)
tree477b9853bea245d9cbdaa8700e02ff980abe79d5 /src/entities/Ped.cpp
parentMerge pull request #85 from erorcun/erorcun (diff)
parentKangaroo cheat and bug fixes (diff)
downloadre3-b2d1433392483c3e1faafcf5127885cb425527e0.tar
re3-b2d1433392483c3e1faafcf5127885cb425527e0.tar.gz
re3-b2d1433392483c3e1faafcf5127885cb425527e0.tar.bz2
re3-b2d1433392483c3e1faafcf5127885cb425527e0.tar.lz
re3-b2d1433392483c3e1faafcf5127885cb425527e0.tar.xz
re3-b2d1433392483c3e1faafcf5127885cb425527e0.tar.zst
re3-b2d1433392483c3e1faafcf5127885cb425527e0.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;