summaryrefslogtreecommitdiffstats
path: root/src/entities/Ped.cpp
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2019-06-15 17:53:25 +0200
committereray orçunus <erayorcunus@gmail.com>2019-06-15 17:53:25 +0200
commit2f4fc5aaf07aedecf3796bae5a63734f133e19a3 (patch)
tree5d6e2e8c71ea146cc26e81c93355c7aec0f0cc60 /src/entities/Ped.cpp
parentFix duplicate code for PedNode (diff)
downloadre3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.tar
re3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.tar.gz
re3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.tar.bz2
re3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.tar.lz
re3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.tar.xz
re3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.tar.zst
re3-2f4fc5aaf07aedecf3796bae5a63734f133e19a3.zip
Diffstat (limited to '')
-rw-r--r--src/entities/Ped.cpp180
1 files changed, 175 insertions, 5 deletions
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