summaryrefslogtreecommitdiffstats
path: root/src/entities
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
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 'src/entities')
-rw-r--r--src/entities/Ped.cpp39
-rw-r--r--src/entities/Ped.h6
-rw-r--r--src/entities/PedIK.cpp8
3 files changed, 30 insertions, 23 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;
diff --git a/src/entities/Ped.h b/src/entities/Ped.h
index 572ed17d..92fa32c1 100644
--- a/src/entities/Ped.h
+++ b/src/entities/Ped.h
@@ -382,7 +382,7 @@ public:
bool IsPointerValid(void);
void SortPeds(CPed**, int, int);
void BuildPedLists(void);
- void GiveWeapon(eWeaponType weaponType, uint32 ammo);
+ uint32 GiveWeapon(eWeaponType weaponType, uint32 ammo);
void SetPedStats(ePedStats);
static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset);
static void GetPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float seatPosMult);
@@ -416,8 +416,8 @@ public:
static void PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *assoc, void *arg);
static void PedSetDraggedOutCarPositionCB(CAnimBlendAssociation *assoc, void *arg);
- inline bool HasWeapon(uint32 weaponType) { return m_weapons[weaponType].m_eWeaponType == weaponType; }
- inline CWeapon *GetWeapon(uint32 weaponType) { return &m_weapons[weaponType]; }
+ inline bool HasWeapon(uint8 weaponType) { return m_weapons[weaponType].m_eWeaponType == weaponType; }
+ inline CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; }
inline CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; }
inline RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; }
diff --git a/src/entities/PedIK.cpp b/src/entities/PedIK.cpp
index 9d688ff9..fa773bbf 100644
--- a/src/entities/PedIK.cpp
+++ b/src/entities/PedIK.cpp
@@ -27,11 +27,11 @@ CPedIK::GetComponentPosition(RwV3d *pos, PedNode node)
RwMatrix *mat;
f = m_ped->GetNodeFrame(node);
- mat = &f->modelling;
+ mat = RwFrameGetMatrix(f);
*pos = mat->pos;
for (f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
- RwV3dTransformPoints(pos, pos, 1, &f->modelling);
+ RwV3dTransformPoints(pos, pos, 1, RwFrameGetMatrix(f));
}
RwMatrix*
@@ -39,10 +39,10 @@ CPedIK::GetWorldMatrix(RwFrame *source, RwMatrix *destination)
{
RwFrame *i;
- *destination = source->modelling;
+ *destination = *RwFrameGetMatrix(source);
for (i = RwFrameGetParent(source); i; i = RwFrameGetParent(i))
- RwMatrixTransform(destination, &i->modelling, rwCOMBINEPOSTCONCAT);
+ RwMatrixTransform(destination, RwFrameGetMatrix(i), rwCOMBINEPOSTCONCAT);
return destination;
}