summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Stats.cpp3
-rw-r--r--src/Stats.h1
-rw-r--r--src/entities/Ped.cpp180
-rw-r--r--src/entities/Ped.h28
4 files changed, 201 insertions, 11 deletions
diff --git a/src/Stats.cpp b/src/Stats.cpp
index d7816f36..8537137e 100644
--- a/src/Stats.cpp
+++ b/src/Stats.cpp
@@ -1,4 +1,5 @@
#include "common.h"
#include "Stats.h"
-Int32 &CStats::DaysPassed = *(Int32*)0x8F2BB8; \ No newline at end of file
+Int32 &CStats::DaysPassed = *(Int32*)0x8F2BB8;
+Int32 &CStats::HeadShots = *(Int32*)0x8F647C; \ No newline at end of file
diff --git a/src/Stats.h b/src/Stats.h
index b82497b5..398999dc 100644
--- a/src/Stats.h
+++ b/src/Stats.h
@@ -4,4 +4,5 @@ class CStats
{
public:
static Int32 &DaysPassed;
+ static Int32 &HeadShots;
}; \ No newline at end of file
diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp
index b4b980e5..00e7ecb7 100644
--- a/src/entities/Ped.cpp
+++ b/src/entities/Ped.cpp
@@ -2,17 +2,21 @@
#include "patcher.h"
#include "Ped.h"
#include "Pools.h"
+#include <render\Particle.h>
+#include <render\ParticleMgr.h>
+#include <Stats.h>
Bool &CPed::bNastyLimbsCheat = *(Bool*)0x95CD44;
Bool &CPed::bPedCheat2 = *(Bool*)0x95CD5A;
Bool &CPed::bPedCheat3 = *(Bool*)0x95CD59;
-
+
void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); }
void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); }
WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); }
WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); }
-WRAPPER void CPed::SetLookFlag(CEntity* to, bool set) { EAXJMP(0x4C6460); }
+WRAPPER void CPed::SetDie(AnimationId anim, float arg1, float arg2) { EAXJMP(0x4D37D0); }
+WRAPPER void CPed::SpawnFlyingComponent(int, signed char) { EAXJMP(0x4EB060); }
static char ObjectiveText[34][28] = {
"No Obj",
@@ -186,7 +190,7 @@ CPed::AddWeaponModel(int id)
if (id != -1) {
atm = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance();
RwFrameDestroy(RpAtomicGetFrame(atm));
- RpAtomicSetFrame(atm, m_pFrames[PED_HANDR]->frame);
+ RpAtomicSetFrame(atm, GetNodeFrame(PED_HANDR));
RpClumpAddAtomic((RpClump*)m_rwObject, atm);
m_wepModelID = id;
}
@@ -210,7 +214,7 @@ CPed::AimGun()
}
CPed::Say(0x74);
- m_ped_flagB40 = m_pedIK.PointGunAtPosition(&vector);
+ m_ped_flagB2 = m_pedIK.PointGunAtPosition(&vector);
if (m_pPedFight != m_pSeekTarget) {
CPed::SetLookFlag(m_pSeekTarget, 1);
}
@@ -222,11 +226,177 @@ CPed::AimGun()
newFlag = m_pedIK.PointGunInDirection(m_fLookDirection, 0.0);
}
- m_ped_flagB40 = newFlag;
+ m_ped_flagB2 = newFlag;
+ }
+}
+
+
+// After I finished this I realized it's only for SCM opcode...
+void
+CPed::ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer)
+{
+ CVector pos2 = CVector(
+ pos.x,
+ pos.y,
+ pos.z + 0.1
+ );
+
+ if (!CPed::IsPlayer() || evenOnPlayer)
+ {
+ ++CStats::HeadShots;
+
+ // yes. decompiled by hand.
+ if (m_nPedState != PED_PASSENGER || m_nPedState != PED_TAXI_PASSENGER) {
+ CPed::SetDie(ANIM_KO_SHOT_FRONT1, 4.0, 0.0);
+ }
+
+ m_ped_flagC20 = 1;
+ m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 150;
+
+ CParticle::AddParticle(PARTICLE_TEST, pos2,
+ CVector(
+ 0.0,
+ 0.0,
+ 0.0
+ ), NULL, 0.2f, 0, 0, 0, 0);
+
+ if (CEntity::GetIsOnScreen())
+ {
+ for(int i=0; i<0x20; i++) {
+ CParticle::AddParticle(PARTICLE_BLOOD_SMALL,
+ pos2,
+ CVector(
+ 0.0,
+ 0.0,
+ 0.03
+ ), NULL, 0.0f, 0, 0, 0, 0);
+ }
+
+ for (int i = 0; i < 0x10; i++) {
+ CParticle::AddParticle(PARTICLE_DEBRIS2,
+ pos2,
+ CVector(
+ 0.0,
+ 0.0,
+ 0.0099999998
+ ), NULL, 0.0f, 0, 0, 0, 0);
+ }
+ }
+ }
+}
+
+void
+CPed::RemoveBodyPart(PedNode nodeId, char arg4)
+{
+ RwFrame *frame;
+ RwFrame *fp;
+ RwV3d zero;
+
+ frame = GetNodeFrame(nodeId);
+ if (frame)
+ {
+ if (CGame::nastyGame)
+ {
+ if (nodeId != PED_HEAD)
+ CPed::SpawnFlyingComponent(nodeId, arg4);
+
+ RecurseFrameChildrenVisibilityCB(frame, 0);
+ zero.x = 0.0;
+ zero.z = 0.0;
+ zero.y = 0.0;
+ for (fp = RwFrameGetParent(frame); fp; fp = RwFrameGetParent(frame))
+ RwV3dTransformPoints(&zero, &zero, 1, &fp->modelling);
+
+ if (CEntity::GetIsOnScreen())
+ {
+ CParticle::AddParticle(PARTICLE_TEST, zero,
+ CVector(
+ 0.0,
+ 0.0,
+ 0.0
+ ), NULL, 0.2f, 0, 0, 0, 0);
+
+ for (int i = 0; i < 0x10; i++) {
+ CParticle::AddParticle(PARTICLE_BLOOD_SMALL,
+ zero,
+ CVector(
+ 0.0,
+ 0.0,
+ 0.03
+ ), NULL, 0.0f, 0, 0, 0, 0);
+ }
+ }
+ m_ped_flagC20 = 1;
+ m_bodyPartBleeding = nodeId;
+ }
+ }
+ else
+ {
+ printf("Trying to remove ped component");
+ }
+}
+
+RwObject*
+CPed::SetPedAtomicVisibilityCB(RwObject *object, void *data)
+{
+ RwObject *result = object;
+ if (!data)
+ object->flags = 0;
+
+ return result;
+}
+
+RwFrame*
+CPed::RecurseFrameChildrenVisibilityCB(RwFrame *frame, void *data)
+{
+ RwFrameForAllObjects(frame, SetPedAtomicVisibilityCB, data);
+ RwFrameForAllChildren(frame, RecurseFrameChildrenVisibilityCB, 0);
+ return frame;
+}
+
+void
+CPed::SetLookFlag(CPed *to, bool set)
+{
+ if (m_lookTimer < CTimer::GetTimeInMilliseconds())
+ {
+ m_ped_flagA10 = 1;
+ m_ped_flagA40 = 0;
+ m_pPedFight = to;
+ m_pPedFight->RegisterReference((CEntity**)&m_pPedFight);
+ m_fLookDirection = 999999;
+ m_lookTimer = 0;
+ m_ped_flagA20_look = set;
+ if (m_nPedState != PED_DRIVING) {
+ // Resets second right most bit
+ m_pedIK.m_flags &= 0xFFFFFFFD;
+ }
}
}
+void
+CPed::SetLookFlag(float angle, bool set)
+{
+ if (m_lookTimer < CTimer::GetTimeInMilliseconds())
+ {
+ m_ped_flagA10 = 1;
+ m_ped_flagA40 = 0;
+ m_pPedFight = 0;
+ m_fLookDirection = angle;
+ m_lookTimer = 0;
+ m_ped_flagA20_look = set;
+ if (m_nPedState != PED_DRIVING) {
+ // Resets second right most bit
+ m_pedIK.m_flags &= 0xFFFFFFFD;
+ }
+ }
+}
+
+
STARTPATCHES
InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP);
InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP);
+ InjectHook(0x4EB470, &CPed::ApplyHeadShot, PATCH_JUMP);
+ InjectHook(0x4EAEE0, &CPed::RemoveBodyPart, PATCH_JUMP);
+ InjectHook(0x4C6460, (void (CPed::*)(CPed*, bool)) &CPed::SetLookFlag, PATCH_JUMP);
+ InjectHook(0x4C63E0, (void (CPed::*)(float, bool)) &CPed::SetLookFlag, PATCH_JUMP);
ENDPATCHES \ No newline at end of file
diff --git a/src/entities/Ped.h b/src/entities/Ped.h
index b7db77dc..2f0f67f0 100644
--- a/src/entities/Ped.h
+++ b/src/entities/Ped.h
@@ -3,6 +3,7 @@
#include "Physical.h"
#include "Weapon.h"
#include "PedIK.h"
+#include <animation\AnimManager.h>
#include <animation\AnimBlendClumpData.h>
enum {
@@ -94,7 +95,7 @@ public:
uint8 m_ped_flagA4 : 1;
uint8 m_ped_flagA8 : 1;
uint8 m_ped_flagA10 : 1;
- uint8 m_ped_flagA20 : 1;
+ uint8 m_ped_flagA20_look : 1;
uint8 m_ped_flagA40 : 1;
uint8 m_ped_flagA80 : 1;
uint8 m_ped_flagB1 : 1;
@@ -163,14 +164,15 @@ public:
uint8 m_ped_flagI80 : 1;
uint8 stuff10[60];
int32 m_pEventEntity;
- int32 m_fAngleToEvent;
+ float m_fAngleToEvent;
AnimBlendFrameData *m_pFrames[PED_NODE_MAX];
int32 m_animGroup;
int32 m_pVehicleAnim;
CVector2D m_vecAnimMoveDelta;
CVector m_vecOffsetSeek;
CPedIK m_pedIK;
- uint8 stuff1[12];
+ uint8 stuff1[8];
+ int32 m_nPedStateTimer;
int32 m_nPedState;
int32 m_nLastPedState;
int32 m_nMoveState;
@@ -198,7 +200,12 @@ public:
CPed *m_pPedFight;
float m_fLookDirection;
int32 m_wepModelID;
- uint8 stuff9[120];
+ uint32 m_leaveCarTimer;
+ uint32 m_getUpTimer;
+ uint32 m_lookTimer;
+ uint8 stuff9[34];
+ uint8 m_bodyPartBleeding;
+ uint8 stuff11[73];
static void *operator new(size_t);
static void operator delete(void*, size_t);
@@ -209,8 +216,17 @@ public:
void AimGun();
void KillPedWithCar(CVehicle *veh, float impulse);
void Say(uint16 audio);
- void SetLookFlag(CEntity *to, bool set);
+ void SetLookFlag(CPed *to, bool set);
+ void SetLookFlag(float angle, bool set);
+ void SetDie(AnimationId anim, float arg1, float arg2);
+ void ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer);
+ void RemoveBodyPart(PedNode nodeId, char arg4);
+ void SpawnFlyingComponent(int, signed char);
+ static RwObject *SetPedAtomicVisibilityCB(RwObject *object, void *data);
+ static RwFrame *RecurseFrameChildrenVisibilityCB(RwFrame *frame, void *data);
+
CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; }
+ RwFrame* GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; }
static Bool &bNastyLimbsCheat;
static Bool &bPedCheat2;
@@ -223,4 +239,6 @@ static_assert(offsetof(CPed, m_nPedType) == 0x32C, "CPed: error");
static_assert(offsetof(CPed, m_pCollidingEntity) == 0x34C, "CPed: error");
static_assert(offsetof(CPed, m_weapons) == 0x35C, "CPed: error");
static_assert(offsetof(CPed, m_currentWeapon) == 0x498, "CPed: error");
+static_assert(offsetof(CPed, m_lookTimer) == 0x4CC, "CPed: error");
+static_assert(offsetof(CPed, m_bodyPartBleeding) == 0x4F2, "CPed: error");
static_assert(sizeof(CPed) == 0x53C, "CPed: error"); \ No newline at end of file