summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-04-26 21:03:15 +0200
committerSergeanur <s.anureev@yandex.ua>2020-04-26 21:03:15 +0200
commitf0890b11122291a22d6a65f349281cf1aed49bd0 (patch)
tree3b418b522c5fd097abac916693e59808ea4f5b4f /src/peds
parentMore japanese (diff)
parentRemove little hack (diff)
downloadre3-f0890b11122291a22d6a65f349281cf1aed49bd0.tar
re3-f0890b11122291a22d6a65f349281cf1aed49bd0.tar.gz
re3-f0890b11122291a22d6a65f349281cf1aed49bd0.tar.bz2
re3-f0890b11122291a22d6a65f349281cf1aed49bd0.tar.lz
re3-f0890b11122291a22d6a65f349281cf1aed49bd0.tar.xz
re3-f0890b11122291a22d6a65f349281cf1aed49bd0.tar.zst
re3-f0890b11122291a22d6a65f349281cf1aed49bd0.zip
Diffstat (limited to 'src/peds')
-rw-r--r--src/peds/CivilianPed.cpp28
-rw-r--r--src/peds/CivilianPed.h2
-rw-r--r--src/peds/CopPed.cpp35
-rw-r--r--src/peds/CopPed.h19
-rw-r--r--src/peds/EmergencyPed.cpp19
-rw-r--r--src/peds/EmergencyPed.h7
-rw-r--r--src/peds/Gangs.cpp12
-rw-r--r--src/peds/Ped.cpp802
-rw-r--r--src/peds/Ped.h256
-rw-r--r--src/peds/PedIK.cpp447
-rw-r--r--src/peds/PedIK.h2
-rw-r--r--src/peds/PedPlacement.cpp9
-rw-r--r--src/peds/PedRoutes.cpp4
-rw-r--r--src/peds/PedStats.cpp10
-rw-r--r--src/peds/PedType.cpp13
-rw-r--r--src/peds/PedType.h2
-rw-r--r--src/peds/PlayerPed.cpp65
-rw-r--r--src/peds/PlayerPed.h13
-rw-r--r--src/peds/Population.cpp97
19 files changed, 975 insertions, 867 deletions
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index a9e0580e..2dee0397 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "CivilianPed.h"
#include "Phones.h"
#include "General.h"
@@ -318,12 +318,12 @@ CCivilianPed::ProcessControl(void)
if (CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= 10 && playerSexFrequency > 250) {
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + playerSexFrequency;
if (playerSexFrequency >= 350) {
- CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = max(250, playerSexFrequency - 30);
+ CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = Max(250, playerSexFrequency - 30);
} else {
- CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = max(250, playerSexFrequency - 10);
+ CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = Max(250, playerSexFrequency - 10);
}
- m_pMyVehicle->pDriver->m_fHealth = min(125.0f, 1.0f + m_pMyVehicle->pDriver->m_fHealth);
+ m_pMyVehicle->pDriver->m_fHealth = Min(125.0f, 1.0f + m_pMyVehicle->pDriver->m_fHealth);
if (CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency == 250)
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + 3000;
} else {
@@ -357,7 +357,7 @@ CCivilianPed::ProcessControl(void)
if (playerMoney <= 1) {
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = 250;
} else {
- CWorld::Players[CWorld::PlayerInFocus].m_nMoney = max(0, playerMoney - 1);
+ CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, playerMoney - 1);
}
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexMoneyUpdateTime = CTimer::GetTimeInMilliseconds() + 1000;
}
@@ -376,21 +376,3 @@ CCivilianPed::ProcessControl(void)
if (m_moved.Magnitude() > 0.0f)
Avoid();
}
-
-#include <new>
-
-class CCivilianPed_ : public CCivilianPed
-{
-public:
- CCivilianPed *ctor(ePedType pedtype, uint32 mi) { return ::new (this) CCivilianPed(pedtype, mi); };
- void dtor(void) { CCivilianPed::~CCivilianPed(); }
- void ProcessControl_(void) { CCivilianPed::ProcessControl(); }
-};
-
-STARTPATCHES
- InjectHook(0x4BFF30, &CCivilianPed_::ctor, PATCH_JUMP);
- InjectHook(0x4BFFC0, &CCivilianPed_::dtor, PATCH_JUMP);
- InjectHook(0x4BFFE0, &CCivilianPed_::ProcessControl_, PATCH_JUMP);
-
- InjectHook(0x4C07A0, &CCivilianPed::CivilianAI, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/CivilianPed.h b/src/peds/CivilianPed.h
index 6082c6ab..88d034c8 100644
--- a/src/peds/CivilianPed.h
+++ b/src/peds/CivilianPed.h
@@ -11,4 +11,6 @@ public:
void CivilianAI(void);
void ProcessControl(void);
};
+#ifndef PED_SKIN
static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error");
+#endif
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index b5812136..3fc8b8ca 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "World.h"
#include "PlayerPed.h"
#include "CopPed.h"
@@ -63,7 +63,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
m_bIsInPursuit = false;
field_1350 = 1;
m_bIsDisabledCop = false;
- field_1356 = 0;
+ m_fAbseilPos = 0.0f;
m_attackTimer = 0;
m_bBeatingSuspect = false;
m_bStopAndShootDisabledZone = false;
@@ -153,7 +153,7 @@ CCopPed::ClearPursuit(void)
return;
m_bIsInPursuit = false;
- for (int i = 0; i < max(wanted->m_MaxCops, wanted->m_CurrentCops); ++i) {
+ for (int i = 0; i < Max(wanted->m_MaxCops, wanted->m_CurrentCops); ++i) {
if (!foundMyself && wanted->m_pCops[i] == this) {
wanted->m_pCops[i] = nil;
--wanted->m_CurrentCops;
@@ -342,7 +342,7 @@ CCopPed::CopAI(void)
int oldCopNum = wanted->m_CurrentCops;
int maxCops = wanted->m_MaxCops;
- for (int i = 0; i < max(maxCops, oldCopNum); i++) {
+ for (int i = 0; i < Max(maxCops, oldCopNum); i++) {
CCopPed *cop = wanted->m_pCops[i];
if (cop && cop->m_fDistanceToTarget > copFarthestToTargetDist) {
copFarthestToTargetDist = cop->m_fDistanceToTarget;
@@ -465,8 +465,7 @@ CCopPed::CopAI(void)
if (m_fDistanceToTarget < weaponRange) {
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
CVector gunPos = weaponInfo->m_vecFireOffset;
- for (RwFrame *i = GetNodeFrame(PED_HANDR); i; i = RwFrameGetParent(i))
- RwV3dTransformPoints((RwV3d*)&gunPos, (RwV3d*)&gunPos, 1, RwFrameGetMatrix(i));
+ TransformToNode(gunPos, PED_HANDR);
CColPoint foundCol;
CEntity *foundEnt;
@@ -668,11 +667,13 @@ CCopPed::ProcessControl(void)
}
if (bDuckAndCover) {
+#if !defined(GTA3_1_1_PATCH) && !defined(VC_PED_PORTS)
if (!bNotAllowedToDuck && Seek()) {
SetMoveState(PEDMOVE_STILL);
SetMoveAnim();
SetPointGunAt(m_pedInObjective);
}
+#endif
} else if (Seek()) {
CVehicle *playerVeh = FindPlayerVehicle();
if (!playerVeh && player && player->EnteringCar()) {
@@ -736,25 +737,3 @@ CCopPed::ProcessControl(void)
SetAttack(m_pedInObjective);
}
}
-
-#include <new>
-
-class CCopPed_ : public CCopPed
-{
-public:
- CCopPed *ctor(eCopType type) { return ::new (this) CCopPed(type); };
- void dtor(void) { CCopPed::~CCopPed(); }
- void ProcessControl_(void) { CCopPed::ProcessControl(); }
-};
-
-STARTPATCHES
- InjectHook(0x4C11B0, &CCopPed_::ctor, PATCH_JUMP);
- InjectHook(0x4C13E0, &CCopPed_::dtor, PATCH_JUMP);
- InjectHook(0x4C1400, &CCopPed_::ProcessControl_, PATCH_JUMP);
- InjectHook(0x4C28C0, &CCopPed::ClearPursuit, PATCH_JUMP);
- InjectHook(0x4C2B00, &CCopPed::SetArrestPlayer, PATCH_JUMP);
- InjectHook(0x4C27D0, &CCopPed::SetPursuit, PATCH_JUMP);
- InjectHook(0x4C2C90, &CCopPed::ArrestPlayer, PATCH_JUMP);
- InjectHook(0x4C26A0, &CCopPed::ScanForCrimes, PATCH_JUMP);
- InjectHook(0x4C1B50, &CCopPed::CopAI, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h
index 625cae49..e9780035 100644
--- a/src/peds/CopPed.h
+++ b/src/peds/CopPed.h
@@ -13,23 +13,16 @@ class CCopPed : public CPed
{
public:
int16 m_wRoadblockNode;
- int8 field_1342;
- int8 field_1343;
float m_fDistanceToTarget;
- int8 m_bIsInPursuit;
- int8 m_bIsDisabledCop;
+ bool m_bIsInPursuit;
+ bool m_bIsDisabledCop;
int8 field_1350;
bool m_bBeatingSuspect;
- int8 m_bStopAndShootDisabledZone;
- int8 m_bZoneDisabled;
- int8 field_1354;
- int8 field_1355;
- int32 field_1356;
+ bool m_bStopAndShootDisabledZone;
+ bool m_bZoneDisabled;
+ float m_fAbseilPos; // VC leftover, unused
eCopType m_nCopType;
int8 field_1364;
- int8 field_1365;
- int8 field_1366;
- int8 field_1367;
CCopPed(eCopType);
~CCopPed();
@@ -43,4 +36,6 @@ public:
void CopAI(void);
};
+#ifndef PED_SKIN
static_assert(sizeof(CCopPed) == 0x558, "CCopPed: error");
+#endif
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index 3a5067e7..7229ed3f 100644
--- a/src/peds/EmergencyPed.cpp
+++ b/src/peds/EmergencyPed.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "EmergencyPed.h"
#include "DMAudio.h"
#include "ModelIndices.h"
@@ -413,20 +413,3 @@ CEmergencyPed::MedicAI(void)
}
}
}
-
-#include <new>
-
-class CEmergencyPed_ : public CEmergencyPed
-{
-public:
- CEmergencyPed* ctor(int pedtype) { return ::new (this) CEmergencyPed(pedtype); };
- void dtor(void) { CEmergencyPed::~CEmergencyPed(); }
- void ProcessControl_(void) { CEmergencyPed::ProcessControl(); }
-};
-
-STARTPATCHES
- InjectHook(0x4C2E40, &CEmergencyPed_::ctor, PATCH_JUMP);
- InjectHook(0x4C2EF0, &CEmergencyPed_::dtor, PATCH_JUMP);
- InjectHook(0x4C2F10, &CEmergencyPed_::ProcessControl_, PATCH_JUMP);
- InjectHook(0x4C3EC0, &CEmergencyPed::InRange, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/EmergencyPed.h b/src/peds/EmergencyPed.h
index 5693e908..6d3dac79 100644
--- a/src/peds/EmergencyPed.h
+++ b/src/peds/EmergencyPed.h
@@ -22,13 +22,12 @@ enum EmergencyPedState
class CEmergencyPed : public CPed
{
public:
- // 0x53C
CPed *m_pRevivedPed;
EmergencyPedState m_nEmergencyPedState;
CAccident *m_pAttendedAccident;
CFire *m_pAttendedFire;
- bool m_bStartedToCPR; // set but unused(?)
- int32 field_1360; // also something for medics, unused(?)
+ bool m_bStartedToCPR; // set but unused
+ int32 field_1360; // set to 0 but unused
CEmergencyPed(uint32);
~CEmergencyPed() { }
@@ -37,4 +36,6 @@ public:
void FiremanAI(void);
void MedicAI(void);
};
+#ifndef PED_SKIN
static_assert(sizeof(CEmergencyPed) == 0x554, "CEmergencyPed: error");
+#endif
diff --git a/src/peds/Gangs.cpp b/src/peds/Gangs.cpp
index c67fe599..8859e61e 100644
--- a/src/peds/Gangs.cpp
+++ b/src/peds/Gangs.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "ModelIndices.h"
#include "Gangs.h"
#include "Weapon.h"
@@ -75,13 +75,3 @@ INITSAVEBUF
Gang[i] = ReadSaveBuf<CGangInfo>(buf);
VALIDATESAVEBUF(size);
}
-
-STARTPATCHES
- InjectHook(0x4C3FB0, CGangs::Initialise, PATCH_JUMP);
- InjectHook(0x4C4010, CGangs::SetGangVehicleModel, PATCH_JUMP);
- InjectHook(0x4C4030, CGangs::SetGangWeapons, PATCH_JUMP);
- InjectHook(0x4C4050, CGangs::SetGangPedModelOverride, PATCH_JUMP);
- InjectHook(0x4C4070, CGangs::GetGangPedModelOverride, PATCH_JUMP);
- InjectHook(0x4C4080, CGangs::SaveAllGangData, PATCH_JUMP);
- InjectHook(0x4C4100, CGangs::LoadAllGangData, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index cee2b323..dcb167f0 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -1,11 +1,12 @@
#include "common.h"
-#include "patcher.h"
+
#include "main.h"
#include "Pools.h"
#include "Particle.h"
#include "Stats.h"
#include "World.h"
#include "RpAnimBlend.h"
+#include "Bones.h"
#include "Ped.h"
#include "Wanted.h"
#include "PlayerPed.h"
@@ -62,7 +63,7 @@
CPed *gapTempPedList[50];
uint16 gnNumTempPedList;
-CColPoint &aTempPedColPts = *(CColPoint*)0x62DB14;
+CColPoint aTempPedColPts[MAX_COLLISION_POINTS];
// Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL)
PedAudioData CommentWaitTime[39] = {
@@ -106,8 +107,6 @@ PedAudioData CommentWaitTime[39] = {
{1000, 1000, 1000, 1000},
{1000, 1000, 5000, 5000},
};
-// *(CPedAudioData(*)[39]) * (uintptr*)0x5F94C4;
-
uint16 nPlayerInComboMove;
RpClump *flyingClumpTemp;
@@ -139,10 +138,9 @@ FightMove tFightMoves[NUM_FIGHTMOVES] = {
{ANIM_HIT_BEHIND, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_FIGHT2_IDLE, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
};
-// *(FightMove(*)[NUM_FIGHTMOVES])* (uintptr*)0x5F9844;
-uint16 &CPed::nThreatReactionRangeMultiplier = *(uint16*)0x5F8C98;
-uint16 &CPed::nEnterCarRangeMultiplier = *(uint16*)0x5F8C94;
+uint16 CPed::nThreatReactionRangeMultiplier = 1;
+uint16 CPed::nEnterCarRangeMultiplier = 1;
CVector vecPedCarDoorAnimOffset;
CVector vecPedCarDoorLoAnimOffset;
@@ -151,9 +149,9 @@ CVector vecPedQuickDraggedOutCarAnimOffset;
CVector vecPedDraggedOutCarAnimOffset;
CVector vecPedTrainDoorAnimOffset;
-bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44;
-bool &CPed::bPedCheat2 = *(bool*)0x95CD5A;
-bool &CPed::bPedCheat3 = *(bool*)0x95CD59;
+bool CPed::bNastyLimbsCheat;
+bool CPed::bPedCheat2;
+bool CPed::bPedCheat3;
CVector2D CPed::ms_vec2DFleePosition;
void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); }
@@ -347,15 +345,15 @@ CPed::DebugRenderOnePedText(void)
bitAbove.z += 2.0f;
if (CSprite::CalcScreenCoors(bitAbove, &screenCoords, &width, &height, true)) {
- float lineHeight = SCREEN_SCALE_Y(min(height/100.0f, 0.7f) * 22.0f);
+ float lineHeight = SCREEN_SCALE_Y(Min(height/100.0f, 0.7f) * 22.0f);
DefinedState();
CFont::SetPropOn();
CFont::SetBackgroundOn();
// Originally both of them were being divided by 60.0f.
- float xScale = min(width / 240.0f, 0.7f);
- float yScale = min(height / 80.0f, 0.7f);
+ float xScale = Min(width / 240.0f, 0.7f);
+ float yScale = Min(height / 80.0f, 0.7f);
CFont::SetScale(SCREEN_SCALE_X(xScale), SCREEN_SCALE_Y(yScale));
CFont::SetCentreOn();
@@ -645,6 +643,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_collPoly.valid = false;
m_fCollisionSpeed = 0.0f;
m_wepModelID = -1;
+#ifdef PED_SKIN
+ m_pWeaponModel = nil;
+#endif
CPopulation::UpdatePedCount((ePedType)m_nPedType, false);
}
@@ -821,10 +822,17 @@ CPed::AddWeaponModel(int id)
RpAtomic *atm;
if (id != -1) {
- atm = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance();
- RwFrameDestroy(RpAtomicGetFrame(atm));
- RpAtomicSetFrame(atm, GetNodeFrame(PED_HANDR));
- RpClumpAddAtomic(GetClump(), atm);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump()))
+ m_pWeaponModel = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance();
+ else
+#endif
+ {
+ atm = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance();
+ RwFrameDestroy(RpAtomicGetFrame(atm));
+ RpAtomicSetFrame(atm, m_pFrames[PED_HANDR]->frame);
+ RpClumpAddAtomic(GetClump(), atm);
+ }
m_wepModelID = id;
}
}
@@ -918,25 +926,28 @@ void
CPed::RemoveBodyPart(PedNode nodeId, int8 direction)
{
RwFrame *frame;
- RwV3d pos;
+ CVector pos;
- frame = GetNodeFrame(nodeId);
+ frame = m_pFrames[nodeId]->frame;
if (frame) {
if (CGame::nastyGame) {
+#ifdef PED_SKIN
+ if(!IsClumpSkinned(GetClump()))
+#endif
+ {
#ifdef TOGGLEABLE_BETA_FEATURES
- if (bPopHeadsOnHeadshot || nodeId != PED_HEAD)
+ if (bPopHeadsOnHeadshot || nodeId != PED_HEAD)
#else
- if (nodeId != PED_HEAD)
+ if (nodeId != PED_HEAD)
#endif
- SpawnFlyingComponent(nodeId, direction);
+ SpawnFlyingComponent(nodeId, direction);
- RecurseFrameChildrenVisibilityCB(frame, nil);
+ RecurseFrameChildrenVisibilityCB(frame, nil);
+ }
pos.x = 0.0f;
pos.y = 0.0f;
pos.z = 0.0f;
-
- for (; frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints(&pos, &pos, 1, RwFrameGetMatrix(frame));
+ TransformToNode(pos, PED_HEAD);
if (CEntity::GetIsOnScreen()) {
CParticle::AddParticle(PARTICLE_TEST, pos,
@@ -1105,10 +1116,7 @@ CPed::ClearLookFlag(void) {
bool
CPed::IsPedHeadAbovePos(float zOffset)
{
- RwMatrix mat;
-
- CPedIK::GetWorldMatrix(GetNodeFrame(PED_HEAD), &mat);
- return zOffset + GetPosition().z < RwMatrixGetPos(&mat)->z;
+ return zOffset + GetPosition().z < GetNodePosition(PED_HEAD).z;
}
void
@@ -1161,7 +1169,6 @@ CPed::Attack(void)
CAnimBlendAssociation *weaponAnimAssoc;
int32 weaponAnim;
float animStart;
- RwFrame *frame;
eWeaponType ourWeaponType;
float weaponAnimTime;
eWeaponFire ourWeaponFire;
@@ -1231,7 +1238,7 @@ CPed::Attack(void)
weaponAnimAssoc->SetCurrentTime(0.0f);
if (IsPlayer()) {
- ((CPlayerPed*)this)->field_1376 = 0.0f;
+ ((CPlayerPed*)this)->m_fAttackButtonCounter = 0.0f;
((CPlayerPed*)this)->m_bHaveTargetSelected = false;
}
}
@@ -1263,13 +1270,7 @@ CPed::Attack(void)
firePos = GetMatrix() * firePos;
} else if (ourWeaponType != WEAPONTYPE_UNARMED) {
- if (weaponAnimAssoc->animId == ANIM_KICK_FLOOR)
- frame = GetNodeFrame(PED_FOOTR);
- else
- frame = GetNodeFrame(PED_HANDR);
-
- for (; frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints((RwV3d*)firePos, (RwV3d*)firePos, 1, RwFrameGetMatrix(frame));
+ TransformToNode(firePos, weaponAnimAssoc->animId == ANIM_KICK_FLOOR ? PED_FOOTR : PED_HANDR);
} else {
firePos = GetMatrix() * firePos;
}
@@ -1317,8 +1318,7 @@ CPed::Attack(void)
firePos = ourWeapon->m_vecFireOffset;
if (weaponAnimTime > 1.0f && weaponAnimTime - weaponAnimAssoc->timeStep <= 1.0f && weaponAnimAssoc->IsRunning()) {
- for (frame = GetNodeFrame(PED_HANDR); frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints((RwV3d*)firePos, (RwV3d*)firePos, 1, RwFrameGetMatrix(frame));
+ TransformToNode(firePos, PED_HANDR);
CVector gunshellPos(
firePos.x - 0.6f * GetForward().x,
@@ -1418,7 +1418,17 @@ void
CPed::RemoveWeaponModel(int modelId)
{
// modelId is not used!! This function just removes the current weapon.
- RwFrameForAllObjects(GetNodeFrame(PED_HANDR),RemoveAllModelCB,nil);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+ if(m_pWeaponModel){
+ RwFrame *frm = RpAtomicGetFrame(m_pWeaponModel);
+ RpAtomicDestroy(m_pWeaponModel);
+ RwFrameDestroy(frm);
+ m_pWeaponModel = nil;
+ }
+ }else
+#endif
+ RwFrameForAllObjects(m_pFrames[PED_HANDR]->frame,RemoveAllModelCB,nil);
m_wepModelID = -1;
}
@@ -1626,6 +1636,15 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
if (ped->IsPlayer())
AudioManager.PlayerJustLeftCar();
+#ifdef VC_PED_PORTS
+ if (ped->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) {
+ dragAssoc->SetDeleteCallback(PedSetDraggedOutCarPositionCB, ped);
+ ped->m_fHealth = 0.0f;
+ ped->SetDie(ANIM_FLOOR_HIT, 1000.0f, 0.5f);
+ return;
+ }
+#endif
+
if (quickJackedAssoc) {
dragAssoc->SetDeleteCallback(PedSetQuickDraggedOutCarPositionCB, ped);
} else {
@@ -1831,7 +1850,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
case ANIM_VAN_GETIN:
#ifdef VC_PED_PORTS
multExtractedFromAnim = true;
- zBlend = max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.3f, 0.0f) / (1.0f - 0.3f);
+ zBlend = Max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.3f, 0.0f) / (1.0f - 0.3f);
// fall through
#endif
case ANIM_CAR_QJACKED:
@@ -1842,7 +1861,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
#ifdef VC_PED_PORTS
if (!multExtractedFromAnim) {
multExtractedFromAnim = true;
- zBlend = max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.5f, 0.0f) / (1.0f - 0.5f);
+ zBlend = Max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.5f, 0.0f) / (1.0f - 0.5f);
}
// fall through
#endif
@@ -1857,7 +1876,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
#ifdef VC_PED_PORTS
if (veh && veh->IsCar() && veh->bIsBus) {
multExtractedFromAnimBus = true;
- zBlend = min(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength, 0.5f) / 0.5f;
+ zBlend = Min(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength, 0.5f) / 0.5f;
}
// fall through
#endif
@@ -1937,7 +1956,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
neededPos.z = autoZPos.z;
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
} else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
- adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f);
+ adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep);
@@ -1959,12 +1978,12 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (m_pVehicleAnim &&
(vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS
|| vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) {
- adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f);
+ adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f);
// Smoothly change ped position
neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ;
} else if (EnteringCar()) {
- neededPos.z = max(currentZ, autoZPos.z);
+ neededPos.z = Max(currentZ, autoZPos.z);
}
#ifdef VC_PED_PORTS
}
@@ -2013,7 +2032,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
}
static void
-particleProduceFootDust(CPed *ped, CVector *pos, float size, int times)
+particleProduceFootDust(CPed *ped, CVector const &pos, float size, int times)
{
switch (ped->m_nSurfaceTouched)
{
@@ -2022,7 +2041,7 @@ particleProduceFootDust(CPed *ped, CVector *pos, float size, int times)
case SURFACE_PAVEMENT:
case SURFACE_SAND:
for (int i = 0; i < times; ++i) {
- CVector adjustedPos = *pos;
+ CVector adjustedPos = pos;
adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
adjustedPos.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
CParticle::AddParticle(PARTICLE_PEDFOOT_DUST, adjustedPos, CVector(0.0f, 0.0f, 0.0f), nil, size, CRGBA(0, 0, 0, 0), 0, 0, 0, 0);
@@ -2034,16 +2053,27 @@ particleProduceFootDust(CPed *ped, CVector *pos, float size, int times)
}
static void
-particleProduceFootSplash(CPed *ped, CVector *pos, float size, int times)
+particleProduceFootSplash(CPed *ped, CVector const &pos, float size, int times)
{
+#ifdef PC_PARTICLE
for (int i = 0; i < times; i++) {
- CVector adjustedPos = *pos;
+ CVector adjustedPos = pos;
adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
adjustedPos.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
CVector direction = ped->GetForward() * -0.05f;
CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, adjustedPos, direction, nil, size, CRGBA(32, 32, 32, 32), 0, 0, CGeneral::GetRandomNumber() & 1, 200);
}
+#else
+ for ( int32 i = 0; i < times; i++ )
+ {
+ CVector adjustedPos = pos;
+ adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
+ adjustedPos.y += CGeneral::GetRandomNumberInRange(-0.2f, 0.2f);
+
+ CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, adjustedPos, CVector(0.0f, 0.0f, 0.0f), nil, size, CRGBA(0, 0, 0, 0), 0, 0, CGeneral::GetRandomNumber() & 1, 200);
+ }
+#endif
}
void
@@ -2074,6 +2104,40 @@ CPed::PlayFootSteps(void)
}
}
+#ifdef GTA_PS2_STUFF
+ CAnimBlendAssociation *runStopAsoc = NULL;
+
+ if ( IsPlayer() )
+ {
+ runStopAsoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_RUN_STOP);
+
+ if ( runStopAsoc == NULL )
+ runStopAsoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_RUN_STOP_R);
+ }
+
+ if ( runStopAsoc != NULL && runStopAsoc->blendAmount > 0.1f )
+ {
+ {
+ CVector pos(0.0f, 0.0f, 0.0f);
+ TransformToNode(pos, PED_FOOTL);
+
+ pos.z -= 0.1f;
+ pos += GetForward()*0.2f;
+ particleProduceFootDust(this, pos, 0.02f, 1);
+ }
+
+ {
+ CVector pos(0.0f, 0.0f, 0.0f);
+ TransformToNode(pos, PED_FOOTR);
+
+ pos.z -= 0.1f;
+ pos += GetForward()*0.2f;
+ particleProduceFootDust(this, pos, 0.02f, 1);
+ }
+ }
+#endif
+
+
if (walkRunAssoc && walkRunAssocBlend > 0.5f && idleAssocBlend < 1.0f) {
float stepStart = 1 / 15.0f;
float stepEnd = walkRunAssoc->hierarchy->totalLength / 2.0f + stepStart;
@@ -2088,9 +2152,7 @@ CPed::PlayFootSteps(void)
if (stepPart != 0) {
DMAudio.PlayOneShot(m_audioEntityId, stepPart == 1 ? SOUND_STEP_START : SOUND_STEP_END, 1.0f);
CVector footPos(0.0f, 0.0f, 0.0f);
-
- for (RwFrame *frame = GetNodeFrame(stepPart == 1 ? PED_FOOTL : PED_FOOTR); frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints(footPos, footPos, 1, RwFrameGetMatrix(frame));
+ TransformToNode(footPos, stepPart == 1 ? PED_FOOTL : PED_FOOTR);
CVector forward = GetForward();
@@ -2115,9 +2177,15 @@ CPed::PlayFootSteps(void)
}
if (CWeather::Rain <= 0.1f || CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) {
if(IsPlayer())
- particleProduceFootDust(this, &footPos, 0.0f, 4);
- } else if(stepPart == 2) {
- particleProduceFootSplash(this, &footPos, 0.15f, 4);
+ particleProduceFootDust(this, footPos, 0.0f, 4);
+ }
+#ifdef PC_PARTICLE
+ else if(stepPart == 2)
+#else
+ else
+#endif
+ {
+ particleProduceFootSplash(this, footPos, 0.15f, 4);
}
}
}
@@ -2125,6 +2193,7 @@ CPed::PlayFootSteps(void)
if (m_nSurfaceTouched == SURFACE_PUDDLE) {
float pedSpeed = CVector2D(m_vecMoveSpeed).Magnitude();
if (pedSpeed > 0.03f && CTimer::GetFrameCounter() % 2 == 0 && pedSpeed > 0.13f) {
+#ifdef PC_PARTICLE
float particleSize = pedSpeed * 2.0f;
if (particleSize < 0.25f)
@@ -2143,6 +2212,12 @@ CPed::PlayFootSteps(void)
particleDir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.05f);
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, particlePos, particleDir, nil, particleSize, CRGBA(255,255,255,255), 0, 0, 0, 0);
+#else
+ CVector particlePos = (GetPosition() - 0.3f * GetUp()) + GetForward()*0.3f;
+ CVector particleDir = m_vecMoveSpeed * 0.45f;
+ particleDir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.05f);
+ CParticle::AddParticle(PARTICLE_PED_SPLASH, particlePos-CVector(0.0f, 0.0f, 1.2f), particleDir, nil, 0.0f, CRGBA(155, 185, 155, 255));
+#endif
}
}
}
@@ -2244,7 +2319,7 @@ CPed::BuildPedLists(void)
if (nThreatReactionRangeMultiplier * 30.0f > dist) {
gapTempPedList[gnNumTempPedList] = ped;
gnNumTempPedList++;
- assert(gnNumTempPedList < ARRAYSIZE(gapTempPedList));
+ assert(gnNumTempPedList < ARRAY_SIZE(gapTempPedList));
}
}
}
@@ -2284,6 +2359,11 @@ CPed::SetModelIndex(uint32 mi)
// This is a mistake by R*, velocity is CVector, whereas m_vecAnimMoveDelta is CVector2D.
(*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity = (CVector*) &m_vecAnimMoveDelta;
+
+#ifdef PED_SKIN
+ if(modelInfo->GetHitColModel() == nil)
+ modelInfo->CreateHitColModelSkinned(GetClump());
+#endif
}
void
@@ -2443,9 +2523,31 @@ CPed::CalculateNewVelocity(void)
}
if (newUpperLegs.phi > -DEGTORAD(50.0f) && newUpperLegs.phi < DEGTORAD(50.0f)) {
- newUpperLegs.theta = 0.0f;
- m_pedIK.RotateTorso(m_pFrames[PED_UPPERLEGL], &newUpperLegs, false);
- m_pedIK.RotateTorso(m_pFrames[PED_UPPERLEGR], &newUpperLegs, false);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+/*
+ // this looks shit
+ newUpperLegs.theta = 0.0f;
+ RwV3d axis = { -1.0f, 0.0f, 0.0f };
+ RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &axis, RADTODEG(newUpperLegs.phi), rwCOMBINEPRECONCAT);
+ RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &axis, RADTODEG(newUpperLegs.phi), rwCOMBINEPRECONCAT);
+*/
+ newUpperLegs.theta = 0.1f;
+ RwV3d Xaxis = { 1.0f, 0.0f, 0.0f };
+ RwV3d Zaxis = { 0.0f, 0.0f, 1.0f };
+ RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &Zaxis, RADTODEG(newUpperLegs.theta), rwCOMBINEPOSTCONCAT);
+ RtQuatRotate(&m_pFrames[PED_UPPERLEGL]->hanimFrame->q, &Xaxis, RADTODEG(newUpperLegs.phi), rwCOMBINEPOSTCONCAT);
+ RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &Zaxis, RADTODEG(newUpperLegs.theta), rwCOMBINEPOSTCONCAT);
+ RtQuatRotate(&m_pFrames[PED_UPPERLEGR]->hanimFrame->q, &Xaxis, RADTODEG(newUpperLegs.phi), rwCOMBINEPOSTCONCAT);
+
+ bDontAcceptIKLookAts = true;
+ }else
+#endif
+ {
+ newUpperLegs.theta = 0.0f;
+ m_pedIK.RotateTorso(m_pFrames[PED_UPPERLEGL], &newUpperLegs, false);
+ m_pedIK.RotateTorso(m_pFrames[PED_UPPERLEGR], &newUpperLegs, false);
+ }
}
}
}
@@ -2505,7 +2607,7 @@ CPed::CanPedJumpThis(CEntity *unused, CVector *damageNormal = nil)
CVector invDamageNormal(-damageNormal->x, -damageNormal->y, 0.0f);
invDamageNormal *= 1.0f / collPower;
CVector estimatedJumpDist = invDamageNormal + collPower * invDamageNormal * ourCol->spheres->radius;
- forwardOffset = estimatedJumpDist * min(2.0f / collPower, 4.0f);
+ forwardOffset = estimatedJumpDist * Min(2.0f / collPower, 4.0f);
}
} else {
pos.z -= 0.15f;
@@ -3032,7 +3134,6 @@ CPed::QuitEnteringCar(void)
if (animAssoc) {
animAssoc->blendDelta = -4.0f;
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
- animAssoc = m_pVehicleAnim;
animAssoc->flags &= ~ASSOC_RUNNING;
}
} else
@@ -3041,7 +3142,11 @@ CPed::QuitEnteringCar(void)
m_pVehicleAnim = nil;
if (veh) {
+#ifdef VC_PED_PORTS
+ if (veh->AutoPilot.m_nCruiseSpeed == 0 && veh->VehicleCreatedBy == RANDOM_VEHICLE)
+#else
if (veh->AutoPilot.m_nCruiseSpeed == 0)
+#endif
veh->AutoPilot.m_nCruiseSpeed = 17;
}
}
@@ -4140,10 +4245,10 @@ CPed::SetGetUp(void)
CVehicle *veh = (CVehicle*)CPedPlacement::IsPositionClearOfCars(&GetPosition());
if (veh && veh->m_vehType != VEHICLE_TYPE_BIKE ||
collidingVeh && collidingVeh->IsVehicle() && collidingVeh->m_vehType != VEHICLE_TYPE_BIKE
- && ((CTimer::GetFrameCounter() + m_randomSeed % 256 + 5) % 8
+ && ((uint8)(CTimer::GetFrameCounter() + m_randomSeed + 5) % 8
|| CCollision::ProcessColModels(GetMatrix(), *CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(),
collidingVeh->GetMatrix(), *CModelInfo::GetModelInfo(collidingVeh->m_modelIndex)->GetColModel(),
- &aTempPedColPts, nil, nil) > 0)) {
+ aTempPedColPts, nil, nil) > 0)) {
bGetUpAnimStarted = false;
if (IsPlayer())
@@ -5041,6 +5146,12 @@ CPed::FightStrike(CVector &touchedNodePos)
// He can beat us
if (sq(maxDistanceToBeBeaten) > potentialAttackDistance.MagnitudeSqr()) {
+#ifdef PED_SKIN
+ // Have to animate a skinned clump because the initial col model is useless
+ if(IsClumpSkinned(GetClump()))
+ ourCol = ((CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex))->AnimatePedColModelSkinned(GetClump());
+ else
+#endif
if (nearPed->m_nPedState == PED_FALL
|| nearPed->m_nPedState == PED_DEAD || nearPed->m_nPedState == PED_DIE
|| !nearPed->IsPedHeadAbovePos(-0.3f)) {
@@ -5146,12 +5257,12 @@ CPed::FightStrike(CVector &touchedNodePos)
float moveMult;
if (m_lastFightMove == FIGHTMOVE_GROUNDKICK) {
- moveMult = min(damageMult * 0.6f, 4.0f);
+ moveMult = Min(damageMult * 0.6f, 4.0f);
} else {
if (nearPed->m_nPedState != PED_DIE || damageMult >= 20) {
moveMult = damageMult;
} else {
- moveMult = min(damageMult * 2.0f, 14.0f);
+ moveMult = Min(damageMult * 2.0f, 14.0f);
}
}
@@ -5189,7 +5300,7 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl)
}
if (extraTime == -1) {
- m_getUpTimer = -1;
+ m_getUpTimer = UINT32_MAX;
} else if (fallAssoc) {
if (IsPlayer()) {
m_getUpTimer = 1000.0f * fallAssoc->hierarchy->totalLength
@@ -5875,7 +5986,7 @@ CPed::CreateDeadPedWeaponPickups(void)
pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
}
if (found)
- CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
+ CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
}
ClearWeapons();
}
@@ -5884,7 +5995,7 @@ void
CPed::SetAttackTimer(uint32 time)
{
if (CTimer::GetTimeInMilliseconds() > m_attackTimer)
- m_attackTimer = max(m_shootTimer, CTimer::GetTimeInMilliseconds()) + time;
+ m_attackTimer = Max(m_shootTimer, CTimer::GetTimeInMilliseconds()) + time;
}
void
@@ -6076,11 +6187,9 @@ CPed::Die(void)
uint8
CPed::DoesLOSBulletHitPed(CColPoint &colPoint)
{
- RwMatrix mat;
uint8 retVal = 2;
- CPedIK::GetWorldMatrix(GetNodeFrame(PED_HEAD), &mat);
- float headZ = RwMatrixGetPos(&mat)->z;
+ float headZ = GetNodePosition(PED_HEAD).z;
if (m_nPedState == PED_FALL)
retVal = 1;
@@ -6451,7 +6560,7 @@ CPed::ExitCar(void)
void
CPed::Fall(void)
{
- if (m_getUpTimer != -1 && CTimer::GetTimeInMilliseconds() > m_getUpTimer
+ if (m_getUpTimer != UINT32_MAX && CTimer::GetTimeInMilliseconds() > m_getUpTimer
#ifdef VC_PED_PORTS
&& bIsStanding
#endif
@@ -6502,37 +6611,32 @@ CPed::Fight(void)
if (curMove.hitLevel != HITLEVEL_NULL && animTime > curMove.startFireTime && animTime <= curMove.endFireTime && m_fightState >= FIGHTSTATE_NO_MOVE) {
CVector touchingNodePos(0.0f, 0.0f, 0.0f);
- RwFrame *touchingFrame = nil;
switch (m_lastFightMove) {
case FIGHTMOVE_STDPUNCH:
case FIGHTMOVE_PUNCHHOOK:
case FIGHTMOVE_BODYBLOW:
- touchingFrame = GetNodeFrame(PED_HANDR);
+ TransformToNode(touchingNodePos, PED_HANDR);
break;
case FIGHTMOVE_IDLE:
case FIGHTMOVE_SHUFFLE_F:
break;
case FIGHTMOVE_KNEE:
- touchingFrame = GetNodeFrame(PED_LOWERLEGR);
+ TransformToNode(touchingNodePos, PED_LOWERLEGR);
break;
case FIGHTMOVE_HEADBUTT:
- touchingFrame = GetNodeFrame(PED_HEAD);
+ TransformToNode(touchingNodePos, PED_HEAD);
break;
case FIGHTMOVE_PUNCHJAB:
- touchingFrame = GetNodeFrame(PED_HANDL);
+ TransformToNode(touchingNodePos, PED_HANDL);
break;
case FIGHTMOVE_KICK:
case FIGHTMOVE_LONGKICK:
case FIGHTMOVE_ROUNDHOUSE:
case FIGHTMOVE_GROUNDKICK:
- touchingFrame = GetNodeFrame(PED_FOOTR);
+ TransformToNode(touchingNodePos, PED_FOOTR);
break;
}
- while (touchingFrame) {
- RwV3dTransformPoints(touchingNodePos, touchingNodePos, 1, RwFrameGetMatrix(touchingFrame));
- touchingFrame = RwFrameGetParent(touchingFrame);
- }
if (m_lastFightMove == FIGHTMOVE_PUNCHJAB) {
touchingNodePos += 0.1f * GetForward();
@@ -7014,8 +7118,7 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg)
if (ped->bDoBloodyFootprints) {
CVector bloodPos(0.0f, 0.0f, 0.0f);
- for (RwFrame *i = ped->GetNodeFrame(PED_FOOTL); i; i = RwFrameGetParent(i))
- RwV3dTransformPoints(bloodPos, bloodPos, 1, RwFrameGetMatrix(i));
+ ped->TransformToNode(bloodPos, PED_FOOTL);
bloodPos.z -= 0.1f;
bloodPos += 0.2f * ped->GetForward();
@@ -7028,8 +7131,7 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg)
255, 255, 0, 0, 4.0f, 3000, 1.0f);
bloodPos = CVector(0.0f, 0.0f, 0.0f);
- for (RwFrame *j = ped->GetNodeFrame(PED_FOOTR); j; j = RwFrameGetParent(j))
- RwV3dTransformPoints(bloodPos, bloodPos, 1, RwFrameGetMatrix(j));
+ ped->TransformToNode(bloodPos, PED_FOOTR);
bloodPos.z -= 0.1f;
bloodPos += 0.2f * ped->GetForward();
@@ -8667,7 +8769,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
distVec.Normalise();
#ifdef VC_PED_PORTS
- distVec *= min(car->m_fMass / 1400.0f, 1.0f);
+ distVec *= Min(car->m_fMass / 1400.0f, 1.0f);
#endif
car->ApplyMoveForce(distVec * -100.0f);
Say(SOUND_PED_DEFEND);
@@ -8700,7 +8802,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
m_vecMoveSpeed.z = 0.0f;
distVec.Normalise();
#ifdef VC_PED_PORTS
- distVec *= min(car->m_fMass / 1400.0f, 1.0f);
+ distVec *= Min(car->m_fMass / 1400.0f, 1.0f);
#endif
car->ApplyMoveForce(distVec * -60.0f);
Say(SOUND_PED_DEFEND);
@@ -9182,8 +9284,11 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->QuitEnteringCar();
return;
}
- bool itsVan = veh->bIsVan;
- bool itsBus = veh->bIsBus;
+ bool itsVan = !!veh->bIsVan;
+ bool itsBus = !!veh->bIsBus;
+#ifdef FIX_BUGS
+ bool itsLow = !!veh->bLowVehicle;
+#endif
eDoors enterDoor;
AnimationId enterAnim;
@@ -9218,6 +9323,10 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg)
enterAnim = ANIM_VAN_GETIN;
} else if (itsBus) {
enterAnim = ANIM_COACH_IN_R;
+#ifdef FIX_BUGS
+ } else if (itsLow) {
+ enterAnim = ANIM_CAR_GETIN_LOW_RHS;
+#endif
} else {
enterAnim = ANIM_CAR_GETIN_RHS;
}
@@ -9225,6 +9334,10 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg)
enterAnim = ANIM_VAN_GETIN_L;
} else if (itsBus) {
enterAnim = ANIM_COACH_IN_L;
+#ifdef FIX_BUGS
+ } else if (itsLow) {
+ enterAnim = ANIM_CAR_GETIN_LOW_LHS;
+#endif
} else {
enterAnim = ANIM_CAR_GETIN_LHS;
}
@@ -10007,7 +10120,7 @@ CPed::ProcessControl(void)
CVector offsetToCheck;
m_nPedStateTimer++;
- float adjustedTs = max(CTimer::GetTimeStep(), 0.01f);
+ float adjustedTs = Max(CTimer::GetTimeStep(), 0.01f);
CPad *pad0 = CPad::GetPad(0);
if ((m_nPedStateTimer <= 50.0f / (4.0f * adjustedTs) || m_nPedStateTimer * 0.01f <= forceDir.MagnitudeSqr())
@@ -10031,7 +10144,7 @@ CPed::ProcessControl(void)
CColPoint obstacleForFlying, obstacleForFlyingOtherDir;
// Check is there any room for being knocked up in reverse direction of force
- if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlying, foundEnt, true, false, false, false, false, false, false)) {
+ if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlying, foundEnt, true, false, false, false, false, false, nil)) {
obstacleForFlyingZ = obstacleForFlying.point.z;
} else {
obstacleForFlyingZ = 500.0f;
@@ -10040,7 +10153,7 @@ CPed::ProcessControl(void)
posToCheck = GetPosition() - offsetToCheck;
// Now check for direction of force this time
- if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlyingOtherDir, foundEnt, true, false, false, false, false, false, false)) {
+ if (CWorld::ProcessVerticalLine(posToCheck, -20.0f, obstacleForFlyingOtherDir, foundEnt, true, false, false, false, false, false, nil)) {
obstacleForFlyingOtherDirZ = obstacleForFlyingOtherDir.point.z;
} else {
obstacleForFlyingOtherDirZ = 501.0f;
@@ -10160,7 +10273,7 @@ CPed::ProcessControl(void)
offsetToCheck = GetPosition();
offsetToCheck.z += 0.5f;
- if (CWorld::ProcessVerticalLine(offsetToCheck, GetPosition().z - FEET_OFFSET, foundCol, foundEnt, true, true, false, true, false, false, false)) {
+ if (CWorld::ProcessVerticalLine(offsetToCheck, GetPosition().z - FEET_OFFSET, foundCol, foundEnt, true, true, false, true, false, false, nil)) {
#ifdef VC_PED_PORTS
if (!bSomeVCflag1 || FEET_OFFSET + foundCol.point.z < GetPosition().z) {
GetPosition().z = FEET_OFFSET + foundCol.point.z;
@@ -10666,7 +10779,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
return;
if (ped->EnteringCar()) {
- bool isLow = veh->bLowVehicle;
+ bool isLow = !!veh->bLowVehicle;
if (!veh->bIsBus)
veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_CLOSEDOOR_LHS, 1.0f);
@@ -10694,7 +10807,11 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif
|| !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) {
- if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
+ if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER
+#ifdef VC_PED_PORTS
+ || ped->m_nPedState == PED_CARJACK
+#endif
+ )
veh->bIsBeingCarJacked = false;
ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER;
@@ -10719,7 +10836,10 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->m_pVehicleAnim->SetFinishCallback(PedSetInCarCB, ped);
}
} else {
- ped->QuitEnteringCar();
+#ifdef VC_PED_PORTS
+ if (ped->m_nPedState != PED_DRIVING)
+#endif
+ ped->QuitEnteringCar();
}
}
@@ -10790,6 +10910,11 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
}
}
}
+#ifdef CANCELLABLE_CAR_ENTER
+ if (!veh->IsDoorMissing(door) && veh->CanPedOpenLocks(ped) && veh->IsCar()) {
+ ((CAutomobile*)veh)->Damage.SetDoorStatus(door, DOOR_STATUS_SWINGING);
+ }
+#endif
ped->QuitEnteringCar();
ped->RestorePreviousObjective();
ped->bCancelEnteringCar = false;
@@ -11004,7 +11129,10 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
return;
if (!ped->EnteringCar()) {
- ped->QuitEnteringCar();
+#ifdef VC_PED_PORTS
+ if(ped->m_nPedState != PED_DRIVING)
+#endif
+ ped->QuitEnteringCar();
return;
}
@@ -11030,9 +11158,9 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
PedSetInCarCB(nil, ped);
return;
}
- bool isVan = veh->bIsVan;
- bool isBus = veh->bIsBus;
- bool isLow = veh->bLowVehicle;
+ bool isVan = !!veh->bIsVan;
+ bool isBus = !!veh->bIsBus;
+ bool isLow = !!veh->bLowVehicle;
eDoors enterDoor;
switch (ped->m_vehEnterType) {
case CAR_DOOR_RF:
@@ -11147,7 +11275,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
if (!ped->IsNotInWreckedVehicle())
return;
- bool isLow = veh->bLowVehicle;
+ bool isLow = !!veh->bLowVehicle;
int padNo;
if (ped->IsPlayer()) {
@@ -11429,7 +11557,9 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
CMatrix pedMat(ped->GetMatrix());
CVector posAfterBeingDragged = Multiply3x3(pedMat, (itsRearDoor ? -vecPedDraggedOutCarAnimOffset : vecPedDraggedOutCarAnimOffset));
posAfterBeingDragged += ped->GetPosition();
+#ifndef VC_PED_PORTS
posAfterBeingDragged.z += 1.0f;
+#endif
CPedPlacement::FindZCoorForPed(&posAfterBeingDragged);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
ped->GetPosition() = posAfterBeingDragged;
@@ -11479,17 +11609,26 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
&& ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && driver
&& driver->IsPlayer() && !CTheScripts::IsPlayerOnAMission()) {
+#ifndef VC_PED_PORTS
if (CGeneral::GetRandomNumber() & 1)
ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, driver);
else
+#endif
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, ped->m_pMyVehicle);
} else {
- ped->m_nPedState = PED_NONE;
- ped->m_nLastPedState = PED_NONE;
- ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 10000);
- ped->bUsePedNodeSeek = true;
- ped->m_pNextPathNode = nil;
+#ifdef VC_PED_PORTS
+ if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear && ped->CharCreatedBy != MISSION_CHAR
+ && ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && !driver
+ && FindPlayerPed()->m_carInObjective == ped->m_pMyVehicle && !CTheScripts::IsPlayerOnAMission())
+ ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, ped->m_pMyVehicle);
+ else
+#endif
+ {
+ ped->m_nPedState = PED_NONE;
+ ped->m_nLastPedState = PED_NONE;
+ ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000);
+ }
}
ped->SetGetUp();
}
@@ -12199,7 +12338,7 @@ CPed::PlacePedOnDryLand(void)
CVector posToCheck = 0.5f * potentialGroundDist + gaTempSphereColPoints[0].point;
posToCheck.z = 3.0f + waterLevel;
- if (CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, false)) {
+ if (CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, nil)) {
foundColZ = foundCol.point.z;
if (foundColZ >= waterLevel) {
posToCheck.z = 0.8f + foundColZ;
@@ -12213,7 +12352,7 @@ CPed::PlacePedOnDryLand(void)
posToCheck = 5.0f * potentialGroundDist + GetPosition();
posToCheck.z = 3.0f + waterLevel;
- if (!CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, false))
+ if (!CWorld::ProcessVerticalLine(posToCheck, waterLevel - 1.0f, foundCol, foundEnt, true, true, false, true, false, false, nil))
return false;
foundColZ = foundCol.point.z;
@@ -12292,24 +12431,36 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void
ped->Say(SOUND_PED_FLEE_RUN);
}
} else {
- if (ped->m_pedStats->m_temper <= ped->m_pedStats->m_fear
- || ped->CharCreatedBy == MISSION_CHAR || veh->VehicleCreatedBy == MISSION_VEHICLE
- || !veh->pDriver || !veh->pDriver->IsPlayer()
- || CTheScripts::IsPlayerOnAMission()) {
+ if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear
+ && ped->CharCreatedBy != MISSION_CHAR && veh->VehicleCreatedBy != MISSION_VEHICLE
+ && veh->pDriver && veh->pDriver->IsPlayer()
+ && !CTheScripts::IsPlayerOnAMission()) {
- ped->SetFlee(veh->GetPosition(), 10000);
- ped->bUsePedNodeSeek = true;
- ped->m_pNextPathNode = nil;
- if (CGeneral::GetRandomNumber() & 1 || ped->m_pedStats->m_fear > 70) {
- ped->SetMoveState(PEDMOVE_SPRINT);
- ped->Say(SOUND_PED_FLEE_SPRINT);
- } else {
- ped->Say(SOUND_PED_FLEE_RUN);
+#ifndef VC_PED_PORTS
+ if (CGeneral::GetRandomNumber() < MYRAND_MAX / 2) {
+ ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, veh->pDriver);
+ } else
+#endif
+ ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, veh);
+
+ } else {
+#ifdef VC_PED_PORTS
+ if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear && ped->CharCreatedBy != MISSION_CHAR
+ && ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && !veh->pDriver
+ && FindPlayerPed()->m_carInObjective == ped->m_pMyVehicle && !CTheScripts::IsPlayerOnAMission())
+ ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, veh);
+ else
+#endif
+ {
+ ped->SetFindPathAndFlee(veh->GetPosition(), 10000);
+ if (CGeneral::GetRandomNumber() & 1 || ped->m_pedStats->m_fear > 70) {
+ ped->SetMoveState(PEDMOVE_SPRINT);
+ ped->Say(SOUND_PED_FLEE_SPRINT);
+ } else {
+ ped->Say(SOUND_PED_FLEE_RUN);
+ }
}
- } else if (CGeneral::GetRandomNumber() < 0x3FFF) {
- ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, veh->pDriver);
- } else
- ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, veh);
+ }
}
}
if (ped->m_nLastPedState == PED_IDLE)
@@ -12521,8 +12672,66 @@ CPed::Render(void)
if (!bInVehicle || m_nPedState == PED_EXIT_CAR || m_nPedState == PED_DRAG_FROM_CAR ||
bRenderPedInCar && sq(25.0f * TheCamera.LODDistMultiplier) >= (TheCamera.GetPosition() - GetPosition()).MagnitudeSqr()) {
CEntity::Render();
+
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+ renderLimb(PED_HEAD);
+ renderLimb(PED_HANDL);
+ renderLimb(PED_HANDR);
+ }
+ if(m_pWeaponModel && IsClumpSkinned(GetClump())){
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ int idx = RpHAnimIDGetIndex(hier, m_pFrames[PED_HANDR]->nodeID);
+ RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
+ RwFrame *frame = RpAtomicGetFrame(m_pWeaponModel);
+ *RwFrameGetMatrix(frame) = *mat;
+ RwFrameUpdateObjects(frame);
+ RpAtomicRender(m_pWeaponModel);
+ }
+#endif
+ }
+}
+
+#ifdef PED_SKIN
+static RpMaterial*
+SetLimbAlphaCB(RpMaterial *material, void *data)
+{
+ ((RwRGBA*)RpMaterialGetColor(material))->alpha = *(uint8*)data;
+ return material;
+}
+
+void
+CPed::renderLimb(int node)
+{
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ int idx = RpHAnimIDGetIndex(hier, m_pFrames[node]->nodeID);
+ RwMatrix *mat = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
+ CPedModelInfo *mi = (CPedModelInfo*)CModelInfo::GetModelInfo(m_modelIndex);
+ RpAtomic *atomic;
+ switch(node){
+ case PED_HEAD:
+ atomic = mi->getHead();
+ break;
+ case PED_HANDL:
+ atomic = mi->getLeftHand();
+ break;
+ case PED_HANDR:
+ atomic = mi->getRightHand();
+ break;
+ default:
+ return;
}
+ if(atomic == nil)
+ return;
+
+ RwFrame *frame = RpAtomicGetFrame(atomic);
+ *RwFrameGetMatrix(frame) = *mat;
+ RwFrameUpdateObjects(frame);
+ int alpha = CVisibilityPlugins::GetClumpAlpha(GetClump());
+ RpGeometryForAllMaterials(RpAtomicGetGeometry(atomic), SetLimbAlphaCB, &alpha);
+ RpAtomicRender(atomic);
}
+#endif
void
CPed::ProcessObjective(void)
@@ -13700,7 +13909,12 @@ CPed::ProcessObjective(void)
// fall through
case OBJECTIVE_LEAVE_VEHICLE:
if (CTimer::GetTimeInMilliseconds() > m_leaveCarTimer) {
- if (InVehicle()) {
+ if (InVehicle()
+#ifdef VC_PED_PORTS
+ && (FindPlayerPed() != this || !CPad::GetPad(0)->GetAccelerate()
+ || bBusJacked)
+#endif
+ ) {
if (m_nPedState != PED_EXIT_CAR && m_nPedState != PED_DRAG_FROM_CAR && m_nPedState != PED_EXIT_TRAIN
&& (m_nPedType != PEDTYPE_COP
#ifdef VC_PED_PORTS
@@ -13912,9 +14126,9 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
CVector2D adjustedColMin(objColMin.x - 0.35f, objColMin.y - 0.35f);
CVector2D adjustedColMax(objColMax.x + 0.35f, objColMax.y + 0.35f);
- checkIntervalInDist = max(checkIntervalInDist, 0.5f);
- checkIntervalInDist = min(checkIntervalInDist, (objColMax.z - objColMin.z) / 2.0f);
- checkIntervalInDist = min(checkIntervalInDist, (adjustedColMax.x - adjustedColMin.x) / 2.0f);
+ checkIntervalInDist = Max(checkIntervalInDist, 0.5f);
+ checkIntervalInDist = Min(checkIntervalInDist, (objColMax.z - objColMin.z) / 2.0f);
+ checkIntervalInDist = Min(checkIntervalInDist, (adjustedColMax.x - adjustedColMin.x) / 2.0f);
if (objMat.GetUp().z < 0.0f)
objUpsideDown = true;
@@ -14445,7 +14659,8 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
if (collidingEnt->IsVehicle() && ((CVehicle*)collidingEnt)->IsBoat())
collidedWithBoat = true;
- if (!field_EF && !m_phy_flagA80
+ // ofc we're not vehicle
+ if (!m_bIsVehicleBeingShifted && !m_phy_flagA80
#ifdef VC_PED_PORTS
&& !collidingEnt->IsPed()
#endif
@@ -14585,7 +14800,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2);
}
} else {
- float damage = 100.0f * max(speed - 0.25f, 0.0f);
+ float damage = 100.0f * Max(speed - 0.25f, 0.0f);
float damage2 = damage;
if (m_vecMoveSpeed.z < -0.25f)
damage += (-0.25f - m_vecMoveSpeed.z) * 150.0f;
@@ -14663,8 +14878,8 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
#ifdef VC_PED_PORTS
} else {
float speed = m_vecMoveSpeed.Magnitude2D();
- sphereNormal.x = -m_vecMoveSpeed.x / max(0.001f, speed);
- sphereNormal.y = -m_vecMoveSpeed.y / max(0.001f, speed);
+ sphereNormal.x = -m_vecMoveSpeed.x / Max(0.001f, speed);
+ sphereNormal.y = -m_vecMoveSpeed.y / Max(0.001f, speed);
GetPosition().z -= 0.05f;
bSomeVCflag1 = true;
}
@@ -14933,12 +15148,26 @@ CPed::PreRender(void)
CTimeCycle::m_fShadowFrontX[CTimeCycle::m_CurrentStoredValue], CTimeCycle::m_fShadowFrontY[CTimeCycle::m_CurrentStoredValue],
CTimeCycle::m_fShadowSideX[CTimeCycle::m_CurrentStoredValue], CTimeCycle::m_fShadowSideY[CTimeCycle::m_CurrentStoredValue]);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+ UpdateRpHAnim();
+
+ if(bBodyPartJustCameOff && m_bodyPartBleeding == PED_HEAD){
+ // scale head to 0 if shot off
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ int32 idx = RpHAnimIDGetIndex(hier, ConvertPedNode2BoneTag(PED_HEAD));
+ RwMatrix *head = &RpHAnimHierarchyGetMatrixArray(hier)[idx];
+ RwV3d zero = { 0.0f, 0.0f, 0.0f };
+ RwMatrixScale(head, &zero, rwCOMBINEPRECONCAT);
+ }
+ }
+#endif
+
if (bBodyPartJustCameOff && bIsPedDieAnimPlaying && m_bodyPartBleeding != -1 && (CTimer::GetFrameCounter() & 7) > 3) {
CVector bloodDir(0.0f, 0.0f, 0.0f);
CVector bloodPos(0.0f, 0.0f, 0.0f);
- for (RwFrame *frame = GetNodeFrame(m_bodyPartBleeding); frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints(bloodPos, bloodPos, 1, RwFrameGetMatrix(frame));
+ TransformToNode(bloodPos, m_bodyPartBleeding);
switch (m_bodyPartBleeding) {
case PED_HEAD:
@@ -15029,7 +15258,7 @@ CPed::ProcessBuoyancy(void)
bTouchingWater = true;
CEntity *entity;
CColPoint point;
- if (CWorld::ProcessVerticalLine(GetPosition(), GetPosition().z - 3.0f, point, entity, false, true, false, false, false, false, false)
+ if (CWorld::ProcessVerticalLine(GetPosition(), GetPosition().z - 3.0f, point, entity, false, true, false, false, false, false, nil)
&& entity->IsVehicle() && ((CVehicle*)entity)->IsBoat()) {
bIsInWater = false;
return;
@@ -15050,7 +15279,11 @@ CPed::ProcessBuoyancy(void)
bIsInTheAir = false;
}
pos.z = pos.z - 0.8f;
+#ifdef PC_PARTICLE
CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, pos, CVector(0.0f, 0.0f, 0.0f), 0.0f, 50, color, true);
+#else
+ CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, pos, CVector(0.0f, 0.0f, 0.0f), 0.0f, 50, CRGBA(0, 0, 0, 0), true);
+#endif
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
m_nPedState = PED_IDLE;
return;
@@ -15079,6 +15312,7 @@ CPed::ProcessBuoyancy(void)
} else {
m_vecMoveSpeed.z = -0.01f;
DMAudio.PlayOneShot(m_audioEntityId, SOUND_SPLASH, 0.0f);
+#ifdef PC_PARTICLE
CVector aBitForward = 2.2f * m_vecMoveSpeed + GetPosition();
float level = 0.0f;
if (CWaterLevel::GetWaterLevel(aBitForward, &level, false))
@@ -15087,6 +15321,18 @@ CPed::ProcessBuoyancy(void)
CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, aBitForward, CVector(0.0f, 0.0f, 0.1f), 0.0f, 200, color, true);
nGenerateRaindrops = CTimer::GetTimeInMilliseconds() + 80;
nGenerateWaterCircles = CTimer::GetTimeInMilliseconds() + 100;
+#else
+ CVector aBitForward = 1.6f * m_vecMoveSpeed + GetPosition();
+ float level = 0.0f;
+ if (CWaterLevel::GetWaterLevel(aBitForward, &level, false))
+ aBitForward.z = level + 0.5f;
+
+ CVector vel = m_vecMoveSpeed * 0.1f;
+ vel.z = 0.18f;
+ CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, aBitForward, vel, 0.0f, 350, CRGBA(0, 0, 0, 0), true);
+ nGenerateRaindrops = CTimer::GetTimeInMilliseconds() + 300;
+ nGenerateWaterCircles = CTimer::GetTimeInMilliseconds() + 60;
+#endif
}
}
} else
@@ -15103,9 +15349,15 @@ CPed::ProcessBuoyancy(void)
if (pos.z != 0.0f) {
nGenerateWaterCircles = 0;
for(int i = 0; i < 4; i++) {
+#ifdef PC_PARTICLE
pos.x += CGeneral::GetRandomNumberInRange(-0.75f, 0.75f);
pos.y += CGeneral::GetRandomNumberInRange(-0.75f, 0.75f);
CParticle::AddParticle(PARTICLE_RAIN_SPLASH_BIGGROW, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, 0, 0, 0, 0);
+#else
+ pos.x += CGeneral::GetRandomNumberInRange(-2.5f, 2.5f);
+ pos.y += CGeneral::GetRandomNumberInRange(-2.5f, 2.5f);
+ CParticle::AddParticle(PARTICLE_RAIN_SPLASH_BIGGROW, pos+CVector(0.0f, 0.0f, 1.0f), CVector(0.0f, 0.0f, 0.0f));
+#endif
}
}
}
@@ -15117,9 +15369,17 @@ CPed::ProcessBuoyancy(void)
pos.z = level;
if (pos.z >= 0.0f) {
+#ifdef PC_PARTICLE
pos.z += 0.25f;
+#else
+ pos.z += 0.5f;
+#endif
nGenerateRaindrops = 0;
+#ifdef PC_PARTICLE
CParticleObject::AddObject(POBJECT_SPLASHES_AROUND, pos, CVector(0.0f, 0.0f, 0.0f), 4.5f, 1500, CRGBA(0,0,0,0), true);
+#else
+ CParticleObject::AddObject(POBJECT_SPLASHES_AROUND, pos, CVector(0.0f, 0.0f, 0.0f), 4.5f, 2500, CRGBA(0,0,0,0), true);
+#endif
}
}
}
@@ -15212,7 +15472,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
{
uint32 optedDoorNode = wantedDoorNode;
bool teleportNeeded = false;
- bool isLow = veh->bLowVehicle;
+ bool isLow = !!veh->bLowVehicle;
if (!veh->CanPedExitCar()) {
if (veh->pDriver && !veh->pDriver->IsPlayer()) {
veh->AutoPilot.m_nCruiseSpeed = 0;
@@ -15406,7 +15666,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, true, false, false, true, false, nil))
foundColZ2 = foundCol.point.z;
- zForPed = max(foundColZ, foundColZ2);
+ zForPed = Max(foundColZ, foundColZ2);
if (zForPed > -99.0f)
GetPosition().z = FEET_OFFSET + zForPed;
@@ -16053,11 +16313,10 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
}
}
if (CGame::nastyGame) {
- RwMatrix headMat;
- CPedIK::GetWorldMatrix(GetNodeFrame(PED_HEAD), &headMat);
+ CVector headPos = GetNodePosition(PED_HEAD);
for(int i = 0; i < 4; ++i) {
CVector bloodDir(0.0f, 0.0f, 0.1f);
- CVector bloodPos = headMat.pos - 0.2f * GetForward();
+ CVector bloodPos = headPos - 0.2f * GetForward();
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, bloodDir, nil, 0.0f, 0, 0, 0, 0);
}
}
@@ -16629,6 +16888,10 @@ CPed::SpawnFlyingComponent(int pedNode, int8 direction)
if (CObject::nNoTempObjects >= NUMTEMPOBJECTS)
return nil;
+#ifdef PED_SKIN
+ assert(!IsClumpSkinned(GetClump()));
+#endif
+
CObject *obj = new CObject();
if (!obj)
return nil;
@@ -16636,12 +16899,12 @@ CPed::SpawnFlyingComponent(int pedNode, int8 direction)
RwFrame *frame = RwFrameCreate();
RpClump *clump = RpClumpCreate();
RpClumpSetFrame(clump, frame);
- RwMatrix *matrix = RwFrameGetLTM(GetNodeFrame(pedNode));
+ RwMatrix *matrix = RwFrameGetLTM(m_pFrames[pedNode]->frame);
*RwFrameGetMatrix(frame) = *matrix;
flyingClumpTemp = clump;
- RwFrameForAllObjects(GetNodeFrame(pedNode), CloneAtomicToFrameCB, frame);
- RwFrameForAllChildren(GetNodeFrame(pedNode), RecurseFrameChildrenToCloneCB, frame);
+ RwFrameForAllObjects(m_pFrames[pedNode]->frame, CloneAtomicToFrameCB, frame);
+ RwFrameForAllChildren(m_pFrames[pedNode]->frame, RecurseFrameChildrenToCloneCB, frame);
flyingClumpTemp = nil;
switch (pedNode) {
case PED_HEAD:
@@ -17005,7 +17268,7 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
// Because buses have stairs
if (!m_pMyVehicle->bIsBus)
- zDiff = max(0.0f, doorOpenPos.z - GetPosition().z);
+ zDiff = Max(0.0f, doorOpenPos.z - GetPosition().z);
m_vecOffsetSeek = doorOpenPos - GetPosition();
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600;
@@ -17156,7 +17419,7 @@ CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo)
CVector appropriatePos = GetPosition();
CVector zCorrectedPos = appropriatePos;
- int tryCount = min(10, halfOfDist);
+ int tryCount = Min(10, halfOfDist);
for (int i = 0; i < tryCount; ++i) {
appropriatePos += halfNormalizedDist;
CPedPlacement::FindZCoorForPed(&zCorrectedPos);
@@ -17190,7 +17453,7 @@ CPed::WarpPedToNearLeaderOffScreen(void)
CVector appropriatePos = GetPosition();
CVector zCorrectedPos = appropriatePos;
- int tryCount = min(10, halfOfDist);
+ int tryCount = Min(10, halfOfDist);
for (int i = 0; i < tryCount; ++i) {
appropriatePos += halfNormalizedDist;
CPedPlacement::FindZCoorForPed(&zCorrectedPos);
@@ -17232,7 +17495,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
car->m_nGettingInFlags |= doorFlag;
m_vecOffsetSeek = carEnterPos - GetPosition();
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600;
- float zDiff = max(0.0f, carEnterPos.z - GetPosition().z);
+ float zDiff = Max(0.0f, carEnterPos.z - GetPosition().z);
bUsesCollision = false;
if (zDiff > 4.4f) {
@@ -17469,240 +17732,3 @@ CPed::SetExitBoat(CVehicle *boat)
// Not there in VC.
CWaterLevel::FreeBoatWakeArray();
}
-
-#include <new>
-
-class CPed_ : public CPed
-{
-public:
- CPed *ctor(uint32 pedType) { return ::new (this) CPed(pedType); }
- void dtor(void) { CPed::~CPed(); }
-
- void SetModelIndex_(uint32 mi) { CPed::SetModelIndex(mi); }
- void FlagToDestroyWhenNextProcessed_(void) { CPed::FlagToDestroyWhenNextProcessed(); }
- bool SetupLighting_(void) { return CPed::SetupLighting(); }
- void RemoveLighting_(bool reset) { CPed::RemoveLighting(reset); }
- void Teleport_(CVector pos) { CPed::Teleport(pos); }
- void ProcessControl_(void) { CPed::ProcessControl(); }
- void Render_(void) { CPed::Render(); }
- void PreRender_(void) { CPed::PreRender(); }
- int32 ProcessEntityCollision_(CEntity *collidingEnt, CColPoint *collidingPoints) { return CPed::ProcessEntityCollision(collidingEnt, collidingPoints); }
- void SetMoveAnim_(void) { CPed::SetMoveAnim(); }
-};
-
-STARTPATCHES
- InjectHook(0x4C41C0, &CPed_::ctor, PATCH_JUMP);
- InjectHook(0x4C50D0, &CPed_::dtor, PATCH_JUMP);
- InjectHook(0x4C52A0, &CPed_::SetModelIndex_, PATCH_JUMP);
- InjectHook(0x4D6570, &CPed_::FlagToDestroyWhenNextProcessed_, PATCH_JUMP);
- InjectHook(0x4A7D30, &CPed_::SetupLighting_, PATCH_JUMP);
- InjectHook(0x4A7DC0, &CPed_::RemoveLighting_, PATCH_JUMP);
- InjectHook(0x4D3E70, &CPed_::Teleport_, PATCH_JUMP);
- InjectHook(0x4C8910, &CPed_::ProcessControl_, PATCH_JUMP);
- InjectHook(0x4D03F0, &CPed_::Render_, PATCH_JUMP);
- InjectHook(0x4CBB30, &CPed_::ProcessEntityCollision_, PATCH_JUMP);
- InjectHook(0x4CFDD0, &CPed_::PreRender_, PATCH_JUMP);
- InjectHook(0x4C5A40, &CPed_::SetMoveAnim_, PATCH_JUMP);
-
- 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::*)(CEntity*, bool)) &CPed::SetLookFlag, PATCH_JUMP);
- InjectHook(0x4C63E0, (void (CPed::*)(float, bool)) &CPed::SetLookFlag, PATCH_JUMP);
- InjectHook(0x4D12E0, &CPed::SetLookTimer, PATCH_JUMP);
- InjectHook(0x4C5700, &CPed::OurPedCanSeeThisOne, PATCH_JUMP);
- InjectHook(0x4D2BB0, &CPed::Avoid, PATCH_JUMP);
- InjectHook(0x4C6A50, &CPed::ClearAimFlag, PATCH_JUMP);
- InjectHook(0x4C64F0, &CPed::ClearLookFlag, PATCH_JUMP);
- InjectHook(0x4EB670, &CPed::IsPedHeadAbovePos, PATCH_JUMP);
- InjectHook(0x4E68A0, &CPed::FinishedAttackCB, PATCH_JUMP);
- InjectHook(0x4E5BD0, &CheckForPedsOnGroundToAttack, PATCH_JUMP);
- InjectHook(0x4E6BA0, &CPed::Attack, PATCH_JUMP);
- InjectHook(0x4CF980, &CPed::RemoveWeaponModel, PATCH_JUMP);
- InjectHook(0x4CFA60, &CPed::SetCurrentWeapon, PATCH_JUMP);
- InjectHook(0x4E4A10, &CPed::Duck, PATCH_JUMP);
- InjectHook(0x4E4A30, &CPed::ClearDuck, PATCH_JUMP);
- InjectHook(0x4E6180, &CPed::ClearPointGunAt, PATCH_JUMP);
- InjectHook(0x4E07D0, &CPed::BeingDraggedFromCar, PATCH_JUMP);
- InjectHook(0x4CF000, &CPed::PedSetDraggedOutCarCB, PATCH_JUMP);
- InjectHook(0x4C5D80, &CPed::RestartNonPartialAnims, PATCH_JUMP);
- InjectHook(0x4E4730, &CPed::GetLocalPositionToOpenCarDoor, PATCH_JUMP);
- InjectHook(0x4E4660, (CVector (*)(CVehicle*, uint32, float)) CPed::GetPositionToOpenCarDoor, PATCH_JUMP);
- InjectHook(0x4E1A30, (CVector (*)(CVehicle*, uint32)) CPed::GetPositionToOpenCarDoor, PATCH_JUMP);
- InjectHook(0x4DF940, &CPed::LineUpPedWithCar, PATCH_JUMP);
- InjectHook(0x4CC6C0, &CPed::PlayFootSteps, PATCH_JUMP);
- InjectHook(0x4C5350, &CPed::BuildPedLists, PATCH_JUMP);
- InjectHook(0x4CF9B0, &CPed::GiveWeapon, PATCH_JUMP);
- InjectHook(0x4C7EA0, &CPed::CalculateNewOrientation, PATCH_JUMP);
- InjectHook(0x4C78F0, &CPed::WorkOutHeadingForMovingFirstPerson, PATCH_JUMP);
- InjectHook(0x4C73F0, &CPed::CalculateNewVelocity, PATCH_JUMP);
- InjectHook(0x4DD820, &CPed::CanSeeEntity, PATCH_JUMP);
- InjectHook(0x4D9460, &CPed::RestorePreviousObjective, PATCH_JUMP);
- InjectHook(0x4D82C0, (void (CPed::*)(eObjective)) &CPed::SetObjective, PATCH_JUMP);
- InjectHook(0x4D83E0, (void (CPed::*)(eObjective, void*)) &CPed::SetObjective, PATCH_JUMP);
- InjectHook(0x4D89A0, (void (CPed::*)(eObjective, int16, int16)) &CPed::SetObjective, PATCH_JUMP);
- InjectHook(0x4D8A90, (void (CPed::*)(eObjective, CVector)) &CPed::SetObjective, PATCH_JUMP);
- InjectHook(0x4D8770, (void (CPed::*)(eObjective, CVector, float)) &CPed::SetObjective, PATCH_JUMP);
- InjectHook(0x4DDEC0, &CPed::ReactToAttack, PATCH_JUMP);
- InjectHook(0x4D0600, &CPed::SetIdle, PATCH_JUMP);
- InjectHook(0x4E0E00, &CPed::QuitEnteringCar, PATCH_JUMP);
- InjectHook(0x4E4AD0, &CPed::InformMyGangOfAttack, PATCH_JUMP);
- InjectHook(0x4D3C80, &CPed::ClearChat, PATCH_JUMP);
- InjectHook(0x4D1390, &CPed::TurnBody, PATCH_JUMP);
- InjectHook(0x4D3AC0, &CPed::Chat, PATCH_JUMP);
- InjectHook(0x4D0490, &CPed::CheckAroundForPossibleCollisions, PATCH_JUMP);
- InjectHook(0x4D3E20, &CPed::MakePhonecall, PATCH_JUMP);
- InjectHook(0x4D3CC0, &CPed::FacePhone, PATCH_JUMP);
- InjectHook(0x4D4860, &CPed::CheckForDeadPeds, PATCH_JUMP);
- InjectHook(0x4D4650, &CPed::CheckForExplosions, PATCH_JUMP);
- InjectHook(0x4D47D0, &CPed::CheckForGunShots, PATCH_JUMP);
- InjectHook(0x4E6990, &CPed::CheckForPointBlankPeds, PATCH_JUMP);
- InjectHook(0x4D0BE0, &CPed::CheckIfInTheAir, PATCH_JUMP);
- InjectHook(0x4C7F20, &CPed::ClearAll, PATCH_JUMP);
- InjectHook(0x4E6790, &CPed::ClearAttack, PATCH_JUMP);
- InjectHook(0x4E67F0, &CPed::ClearAttackByRemovingAnim, PATCH_JUMP);
- InjectHook(0x4D37D0, &CPed::SetDie, PATCH_JUMP);
- InjectHook(0x4C5D50, &CPed::StopNonPartialAnims, PATCH_JUMP);
- InjectHook(0x4C5DB0, &CPed::SetStoredState, PATCH_JUMP);
- InjectHook(0x4EA420, &CPed::InflictDamage, PATCH_JUMP);
- InjectHook(0x4D1EA0, &CPed::ClearFlee, PATCH_JUMP);
- InjectHook(0x4D0BB0, &CPed::ClearFall, PATCH_JUMP);
- InjectHook(0x4D0F20, &CPed::SetGetUp, PATCH_JUMP);
- InjectHook(0x4D6550, &CPed::RestoreHeadingRateCB, PATCH_JUMP);
- InjectHook(0x4C5E30, &CPed::RestorePreviousState, PATCH_JUMP);
- InjectHook(0x4E5F70, &CPed::SetPointGunAt, PATCH_JUMP);
- InjectHook(0x4D2750, &CPed::SetWanderPath, PATCH_JUMP);
- InjectHook(0x4D30C0, &CPed::SetEvasiveStep, PATCH_JUMP);
- InjectHook(0x4EA360, &CPed::ClearInvestigateEvent, PATCH_JUMP);
- InjectHook(0x4D8E80, &CPed::ClearLeader, PATCH_JUMP);
- InjectHook(0x4D1360, &CPed::ClearLook, PATCH_JUMP);
- InjectHook(0x4D8DF0, &CPed::ClearObjective, PATCH_JUMP);
- InjectHook(0x4D0970, &CPed::ClearPause, PATCH_JUMP);
- InjectHook(0x4D1620, &CPed::ClearSeek, PATCH_JUMP);
- InjectHook(0x4CFB70, &CPed::ClearWeapons, PATCH_JUMP);
- InjectHook(0x4C6BB0, &CPed::RestoreGunPosition, PATCH_JUMP);
- InjectHook(0x4D6540, &CPed::RestoreHeadingRate, PATCH_JUMP);
- InjectHook(0x4C69E0, (void (CPed::*)(CEntity*)) &CPed::SetAimFlag, PATCH_JUMP);
- InjectHook(0x4C6960, (void (CPed::*)(float)) &CPed::SetAimFlag, PATCH_JUMP);
- InjectHook(0x4CFAD0, &CPed::GrantAmmo, PATCH_JUMP);
- InjectHook(0x4CFB20, &CPed::SetAmmo, PATCH_JUMP);
- InjectHook(0x4D33A0, &CPed::SetEvasiveDive, PATCH_JUMP);
- InjectHook(0x4D09B0, &CPed::SetFall, PATCH_JUMP);
- InjectHook(0x4E6220, &CPed::SetAttack, PATCH_JUMP);
- InjectHook(0x4E7530, &CPed::StartFightAttack, PATCH_JUMP);
- InjectHook(0x4E8EC0, &CPed::FightStrike, PATCH_JUMP);
- InjectHook(0x4CCE20, &CPed::GetLocalDirection, PATCH_JUMP);
- InjectHook(0x4E8E20, &CPed::PlayHitSound, PATCH_JUMP);
- InjectHook(0x4E5A10, &CPed::Say, PATCH_JUMP);
- InjectHook(0x4D58D0, &CPed::SetWaitState, PATCH_JUMP);
- InjectHook(0x4D1D70, (void (CPed::*)(CEntity*, int)) &CPed::SetFlee, PATCH_JUMP);
- InjectHook(0x4D1C40, (void (CPed::*)(CVector2D const &, int)) &CPed::SetFlee, PATCH_JUMP);
- InjectHook(0x4EB9A0, &CPed::CollideWithPed, PATCH_JUMP);
- InjectHook(0x433490, &CPed::CreateDeadPedMoney, PATCH_JUMP);
- InjectHook(0x433660, &CPed::CreateDeadPedWeaponPickups, PATCH_JUMP);
- InjectHook(0x4D3970, &CPed::SetDead, PATCH_JUMP);
- InjectHook(0x53CDF0, &CPed::DeadPedMakesTyresBloody, PATCH_JUMP);
- InjectHook(0x4E0640, &CPed::SetBeingDraggedFromCar, PATCH_JUMP);
- InjectHook(0x4D1300, &CPed::SetAttackTimer, PATCH_JUMP);
- InjectHook(0x4D6950, &CPed::SetBuyIceCream, PATCH_JUMP);
- InjectHook(0x4D3A60, &CPed::SetChat, PATCH_JUMP);
- InjectHook(0x4D14B0, (void (CPed::*)(CVector, float)) &CPed::SetSeek, PATCH_JUMP);
- InjectHook(0x4D15A0, (void (CPed::*)(CEntity*, float)) &CPed::SetSeek, PATCH_JUMP);
- InjectHook(0x4EB5C0, &CPed::DoesLOSBulletHitPed, PATCH_JUMP);
- InjectHook(0x4E3EC0, &CPed::DuckAndCover, PATCH_JUMP);
- InjectHook(0x4E8D30, &CPed::EndFight, PATCH_JUMP);
- InjectHook(0x4E0D30, &CPed::EnterCar, PATCH_JUMP);
- InjectHook(0x4E2E50, &CPed::GetNearestTrainPedPosition, PATCH_JUMP);
- InjectHook(0x4E2D70, &CPed::GetNearestTrainDoor, PATCH_JUMP);
- InjectHook(0x4E33D0, &CPed::LineUpPedWithTrain, PATCH_JUMP);
- InjectHook(0x4E18D0, &CPed::ExitCar, PATCH_JUMP);
- InjectHook(0x4E7EE0, &CPed::Fight, PATCH_JUMP);
- InjectHook(0x4D3950, &CPed::FinishDieAnimCB, PATCH_JUMP);
- InjectHook(0x4E9830, &CPed::FinishFightMoveCB, PATCH_JUMP);
- InjectHook(0x4D7A80, &CPed::FinishHitHeadCB, PATCH_JUMP);
- InjectHook(0x4D7A50, &CPed::FinishJumpCB, PATCH_JUMP);
- InjectHook(0x4D7490, &CPed::FinishLaunchCB, PATCH_JUMP);
- InjectHook(0x4D6520, &CPed::FinishedWaitCB, PATCH_JUMP);
- InjectHook(0x4D5D80, &CPed::Wait, PATCH_JUMP);
- InjectHook(0x4E3A90, &CPed::FindBestCoordsFromNodes, PATCH_JUMP);
- InjectHook(0x4D2E70, &CPed::SeekFollowingPath, PATCH_JUMP);
- InjectHook(0x4D1640, &CPed::Seek, PATCH_JUMP);
- InjectHook(0x4D3020, &CPed::FollowPath, PATCH_JUMP);
- InjectHook(0x4D1ED0, &CPed::Flee, PATCH_JUMP);
- InjectHook(0x4E1CF0, &CPed::GetNearestDoor, PATCH_JUMP);
- InjectHook(0x4DF420, &CPed::GetFormationPosition, PATCH_JUMP);
- InjectHook(0x4E1F30, &CPed::GetNearestPassengerDoor, PATCH_JUMP);
- InjectHook(0x4D0690, &CPed::Idle, PATCH_JUMP);
- InjectHook(0x4DD720, &CPed::GetNextPointOnRoute, PATCH_JUMP);
- InjectHook(0x4D7B50, &CPed::GetPedRadioCategory, PATCH_JUMP);
- InjectHook(0x4CFA40, &CPed::GetWeaponSlot, PATCH_JUMP);
- InjectHook(0x4E2220, &CPed::GoToNearestDoor, PATCH_JUMP);
- InjectHook(0x4DD7B0, &CPed::HaveReachedNextPointOnRoute, PATCH_JUMP);
- InjectHook(0x4D0D10, &CPed::InTheAir, PATCH_JUMP);
- InjectHook(0x4C5270, &CPed::Initialise, PATCH_JUMP);
- InjectHook(0x4D0E40, &CPed::SetLanding, PATCH_JUMP);
- InjectHook(0x4E9B50, &CPed::InvestigateEvent, PATCH_JUMP);
- InjectHook(0x564BB0, &CPed::IsPedDoingDriveByShooting, PATCH_JUMP);
- InjectHook(0x4E4D90, &CPed::IsRoomToBeCarJacked, PATCH_JUMP);
- InjectHook(0x4EC430, &CPed::KillPedWithCar, PATCH_JUMP);
- InjectHook(0x4E9A80, &CPed::SetInvestigateEvent, PATCH_JUMP);
- InjectHook(0x4D5040, &CPed::LookForInterestingNodes, PATCH_JUMP);
- InjectHook(0x4D4F50, &CPed::LookForSexyCars, PATCH_JUMP);
- InjectHook(0x4D4DF0, &CPed::LookForSexyPeds, PATCH_JUMP);
- InjectHook(0x53CFD0, &CPed::MakeTyresMuddySectorList, PATCH_JUMP);
- InjectHook(0x4C6580, &FinishFuckUCB, PATCH_JUMP);
- InjectHook(0x4D11D0, &CPed::Mug, PATCH_JUMP);
- InjectHook(0x4DE130, &CPed::PedAnimAlignCB, PATCH_JUMP);
- InjectHook(0x4D0980, &CPed::Pause, PATCH_JUMP);
- InjectHook(0x4C65B0, &CPed::MoveHeadToLook, PATCH_JUMP);
- InjectHook(0x4DF1B0, &CPed::PedAnimDoorCloseCB, PATCH_JUMP);
- InjectHook(0x4E4B90, &CPed::PedAnimDoorCloseRollingCB, PATCH_JUMP);
- InjectHook(0x4DE500, &CPed::PedAnimDoorOpenCB, PATCH_JUMP);
- InjectHook(0x4D73D0, &CPed::SetJump, PATCH_JUMP);
- InjectHook(0x4E4E20, &CPed::RemoveInCarAnims, PATCH_JUMP);
- InjectHook(0x4DEC80, &CPed::PedAnimGetInCB, PATCH_JUMP);
- InjectHook(0x4DEAF0, &CPed::PedAnimPullPedOutCB, PATCH_JUMP);
- InjectHook(0x4DF5C0, &CPed::PedAnimStepOutCarCB, PATCH_JUMP);
- InjectHook(0x4D36E0, &CPed::PedEvadeCB, PATCH_JUMP);
- InjectHook(0x4CE810, &CPed::PedGetupCB, PATCH_JUMP);
- InjectHook(0x4CE8A0, &CPed::PedLandCB, PATCH_JUMP);
- InjectHook(0x4E2920, &CPed::PedSetDraggedOutCarPositionCB, PATCH_JUMP);
- InjectHook(0x4CF220, &CPed::PedSetInCarCB, PATCH_JUMP);
- InjectHook(0x4E3290, &CPed::PedSetInTrainCB, PATCH_JUMP);
- InjectHook(0x4C10C0, &CPed::RunToReportCrime, PATCH_JUMP);
- InjectHook(0x4E3870, &CPed::RegisterThreatWithGangPeds, PATCH_JUMP);
- InjectHook(0x4DD980, &CPed::ReactToPointGun, PATCH_JUMP);
- InjectHook(0x4CE8F0, &CPed::PedSetOutCarCB, PATCH_JUMP);
- InjectHook(0x4E36E0, &CPed::PedSetOutTrainCB, PATCH_JUMP);
- InjectHook(0x4EB6E0, &CPed::PlacePedOnDryLand, PATCH_JUMP);
- InjectHook(0x4E2480, &CPed::PedSetQuickDraggedOutCarPositionCB, PATCH_JUMP);
- InjectHook(0x4E4F30, &CPed::PositionPedOutOfCollision, PATCH_JUMP);
- InjectHook(0x4D6A00, &CPed::PossiblyFindBetterPosToSeekCar, PATCH_JUMP);
- InjectHook(0x4D94E0, &CPed::ProcessObjective, PATCH_JUMP);
- InjectHook(0x4CCEB0, &CPed::SetDirectionToWalkAroundObject, PATCH_JUMP);
- InjectHook(0x4DF3E0, &CPed::SetFormation, PATCH_JUMP);
- InjectHook(0x4C7340, &CPed::WillChat, PATCH_JUMP);
- InjectHook(0x4E32D0, &CPed::SetEnterTrain, PATCH_JUMP);
- InjectHook(0x4E4920, &CPed::SetDuck, PATCH_JUMP);
- InjectHook(0x4E0920, &CPed::SetEnterCar, PATCH_JUMP);
- InjectHook(0x4D7BC0, &CPed::SetRadioStation, PATCH_JUMP);
- InjectHook(0x4C7FF0, &CPed::ProcessBuoyancy, PATCH_JUMP);
- InjectHook(0x4D6620, &CPed::SetSolicit, PATCH_JUMP);
- InjectHook(0x4D2EA0, &CPed::SetFollowPath, PATCH_JUMP);
- InjectHook(0x4E1010, &CPed::SetExitCar, PATCH_JUMP);
- InjectHook(0x4C5FE0, &CPed::ScanForThreats, PATCH_JUMP);
- InjectHook(0x4C6C10, &CPed::ScanForInterestingStuff, PATCH_JUMP);
- InjectHook(0x4D3F90, &CPed::SeekCar, PATCH_JUMP);
- InjectHook(0x4E5870, &CPed::ServiceTalking, PATCH_JUMP);
- InjectHook(0x4E7780, &CPed::StartFightDefend, PATCH_JUMP);
- InjectHook(0x4D8F30, &CPed::UpdateFromLeader, PATCH_JUMP);
- InjectHook(0x4D4970, &CPed::SetPedPositionInCar, PATCH_JUMP);
- InjectHook(0x4D7D20, &CPed::WarpPedIntoCar, PATCH_JUMP);
- InjectHook(0x4E0A40, &CPed::SetEnterCar_AllClear, PATCH_JUMP);
- InjectHook(0x4D28D0, &CPed::WanderPath, PATCH_JUMP);
- InjectHook(0x4E5570, &CPed::WarpPedToNearEntityOffScreen, PATCH_JUMP);
- InjectHook(0x4E52A0, &CPed::WarpPedToNearLeaderOffScreen, PATCH_JUMP);
- InjectHook(0x4E0220, &CPed::SetCarJack, PATCH_JUMP);
- InjectHook(0x4D6780, &CPed::Solicit, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 2edd5d68..f4caafd8 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -1,12 +1,14 @@
#pragma once
+#include "RwHelper.h"
+#include "AnimManager.h"
+#include "Crime.h"
+#include "EventList.h"
+#include "PedIK.h"
+#include "PedStats.h"
#include "Physical.h"
#include "Weapon.h"
-#include "PedStats.h"
-#include "PedIK.h"
-#include "AnimManager.h"
#include "WeaponInfo.h"
-#include "EventList.h"
#define FEET_OFFSET 1.04f
#define CHECK_NEARBY_THINGS_MAX_DIST 15.0f
@@ -17,7 +19,6 @@ class CObject;
class CFire;
struct AnimBlendFrameData;
class CAnimBlendAssociation;
-enum eCrimeType;
struct PedAudioData
{
@@ -301,95 +302,94 @@ public:
float m_fCollisionSpeed;
// cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CPed.h from R*
- uint8 bIsStanding : 1;
- uint8 m_ped_flagA2 : 1; // bWasStanding?
- uint8 bIsAttacking : 1; // doesn't reset after fist fight
- uint8 bIsPointingGunAt : 1;
- uint8 bIsLooking : 1;
- uint8 bKeepTryingToLook : 1; // if we can't look somewhere due to unreachable angles
- uint8 bIsRestoringLook : 1;
- uint8 bIsAimingGun : 1;
-
- uint8 bIsRestoringGun : 1;
- uint8 bCanPointGunAtTarget : 1;
- uint8 bIsTalking : 1;
- uint8 bIsInTheAir : 1;
- uint8 bIsLanding : 1;
- uint8 bIsRunning : 1; // on some conditions
- uint8 bHitSomethingLastFrame : 1;
- uint8 bVehEnterDoorIsBlocked : 1; // because someone else enters/exits from there
-
- uint8 bCanPedEnterSeekedCar : 1;
- uint8 bRespondsToThreats : 1;
- uint8 bRenderPedInCar : 1;
- uint8 bChangedSeat : 1;
- uint8 bUpdateAnimHeading : 1;
- uint8 bBodyPartJustCameOff : 1;
- uint8 bIsShooting : 1;
- uint8 bFindNewNodeAfterStateRestore : 1;
-
- uint8 bHasACamera : 1; // does ped possess a camera to document accidents involves fire/explosion
- uint8 bGonnaInvestigateEvent : 1;
- uint8 bPedIsBleeding : 1;
- uint8 bStopAndShoot : 1; // Ped cannot reach target to attack with fist, need to use gun
- uint8 bIsPedDieAnimPlaying : 1;
- uint8 bUsePedNodeSeek : 1;
- uint8 bObjectiveCompleted : 1;
- uint8 bScriptObjectiveCompleted : 1;
-
- uint8 bKindaStayInSamePlace : 1;
- uint8 bBeingChasedByPolice : 1; // Unused VC leftover. Should've been set for criminal/gang members
- uint8 bNotAllowedToDuck : 1;
- uint8 bCrouchWhenShooting : 1;
- uint8 bIsDucking : 1;
- uint8 bGetUpAnimStarted : 1;
- uint8 bDoBloodyFootprints : 1;
- uint8 bFleeAfterExitingCar : 1;
-
- uint8 bWanderPathAfterExitingCar : 1;
- uint8 bIsLeader : 1;
- uint8 bDontDragMeOutCar : 1; // unfinished feature
- uint8 m_ped_flagF8 : 1;
- uint8 bWillBeQuickJacked : 1;
- uint8 bCancelEnteringCar : 1; // after door is opened or couldn't be opened due to it's locked
- uint8 bObstacleShowedUpDuringKillObjective : 1;
- uint8 bDuckAndCover : 1;
-
- uint8 bStillOnValidPoly : 1; // set if the polygon the ped is on is still valid for collision
- uint8 bAllowMedicsToReviveMe : 1;
- uint8 bResetWalkAnims : 1;
- uint8 bStartWanderPathOnFoot : 1; // exits the car if he's in it, reset after path found
- uint8 bOnBoat : 1; // not just driver, may be just standing
- uint8 bBusJacked : 1;
- uint8 bGonnaKillTheCarJacker : 1; // only set when car is jacked from right door and when arrested by police
- uint8 bFadeOut : 1;
-
- uint8 bKnockedUpIntoAir : 1; // has ped been knocked up into the air by a car collision
- uint8 bHitSteepSlope : 1; // has ped collided/is standing on a steep slope (surface type)
- uint8 bCullExtraFarAway : 1; // special ped only gets culled if it's extra far away (for roadblocks)
- uint8 bClearObjective : 1;
- uint8 bTryingToReachDryLand : 1; // has ped just exited boat and trying to get to dry land
- uint8 bCollidedWithMyVehicle : 1;
- uint8 bRichFromMugging : 1; // ped has lots of cash cause they've been mugging people
- uint8 bChrisCriminal : 1; // Is a criminal as killed during Chris' police mission (should be counted as such)
-
- uint8 bShakeFist : 1; // test shake hand at look entity
- uint8 bNoCriticalHits : 1; // if set, limbs won't came off
- uint8 bVehExitWillBeInstant : 1;
- uint8 bHasAlreadyBeenRecorded : 1;
- uint8 bFallenDown : 1;
+ uint32 bIsStanding : 1;
+ uint32 m_ped_flagA2 : 1; // bWasStanding?
+ uint32 bIsAttacking : 1; // doesn't reset after fist fight
+ uint32 bIsPointingGunAt : 1;
+ uint32 bIsLooking : 1;
+ uint32 bKeepTryingToLook : 1; // if we can't look somewhere due to unreachable angles
+ uint32 bIsRestoringLook : 1;
+ uint32 bIsAimingGun : 1;
+
+ uint32 bIsRestoringGun : 1;
+ uint32 bCanPointGunAtTarget : 1;
+ uint32 bIsTalking : 1;
+ uint32 bIsInTheAir : 1;
+ uint32 bIsLanding : 1;
+ uint32 bIsRunning : 1; // on some conditions
+ uint32 bHitSomethingLastFrame : 1;
+ uint32 bVehEnterDoorIsBlocked : 1; // because someone else enters/exits from there
+
+ uint32 bCanPedEnterSeekedCar : 1;
+ uint32 bRespondsToThreats : 1;
+ uint32 bRenderPedInCar : 1;
+ uint32 bChangedSeat : 1;
+ uint32 bUpdateAnimHeading : 1;
+ uint32 bBodyPartJustCameOff : 1;
+ uint32 bIsShooting : 1;
+ uint32 bFindNewNodeAfterStateRestore : 1;
+
+ uint32 bHasACamera : 1; // does ped possess a camera to document accidents involves fire/explosion
+ uint32 bGonnaInvestigateEvent : 1;
+ uint32 bPedIsBleeding : 1;
+ uint32 bStopAndShoot : 1; // Ped cannot reach target to attack with fist, need to use gun
+ uint32 bIsPedDieAnimPlaying : 1;
+ uint32 bUsePedNodeSeek : 1;
+ uint32 bObjectiveCompleted : 1;
+ uint32 bScriptObjectiveCompleted : 1;
+
+ uint32 bKindaStayInSamePlace : 1;
+ uint32 bBeingChasedByPolice : 1; // Unused VC leftover. Should've been set for criminal/gang members
+ uint32 bNotAllowedToDuck : 1;
+ uint32 bCrouchWhenShooting : 1;
+ uint32 bIsDucking : 1;
+ uint32 bGetUpAnimStarted : 1;
+ uint32 bDoBloodyFootprints : 1;
+ uint32 bFleeAfterExitingCar : 1;
+
+ uint32 bWanderPathAfterExitingCar : 1;
+ uint32 bIsLeader : 1;
+ uint32 bDontDragMeOutCar : 1; // unfinished feature
+ uint32 m_ped_flagF8 : 1;
+ uint32 bWillBeQuickJacked : 1;
+ uint32 bCancelEnteringCar : 1; // after door is opened or couldn't be opened due to it's locked
+ uint32 bObstacleShowedUpDuringKillObjective : 1;
+ uint32 bDuckAndCover : 1;
+
+ uint32 bStillOnValidPoly : 1; // set if the polygon the ped is on is still valid for collision
+ uint32 bAllowMedicsToReviveMe : 1;
+ uint32 bResetWalkAnims : 1;
+ uint32 bStartWanderPathOnFoot : 1; // exits the car if he's in it, reset after path found
+ uint32 bOnBoat : 1; // not just driver, may be just standing
+ uint32 bBusJacked : 1;
+ uint32 bGonnaKillTheCarJacker : 1; // only set when car is jacked from right door and when arrested by police
+ uint32 bFadeOut : 1;
+
+ uint32 bKnockedUpIntoAir : 1; // has ped been knocked up into the air by a car collision
+ uint32 bHitSteepSlope : 1; // has ped collided/is standing on a steep slope (surface type)
+ uint32 bCullExtraFarAway : 1; // special ped only gets culled if it's extra far away (for roadblocks)
+ uint32 bClearObjective : 1;
+ uint32 bTryingToReachDryLand : 1; // has ped just exited boat and trying to get to dry land
+ uint32 bCollidedWithMyVehicle : 1;
+ uint32 bRichFromMugging : 1; // ped has lots of cash cause they've been mugging people
+ uint32 bChrisCriminal : 1; // Is a criminal as killed during Chris' police mission (should be counted as such)
+
+ uint32 bShakeFist : 1; // test shake hand at look entity
+ uint32 bNoCriticalHits : 1; // if set, limbs won't came off
+ uint32 bVehExitWillBeInstant : 1;
+ uint32 bHasAlreadyBeenRecorded : 1;
+ uint32 bFallenDown : 1;
#ifdef VC_PED_PORTS
- uint8 bSomeVCflag1 : 1;
-#else
- uint8 m_ped_flagI20 : 1;
+ uint32 bSomeVCflag1 : 1;
#endif
- uint8 m_ped_flagI40 : 1; // bMakePedsRunToPhonesToReportCrimes makes use of this as runover by car indicator
- uint8 m_ped_flagI80 : 1; // KANGAROO_CHEAT define makes use of this as cheat toggle
+#ifdef PED_SKIN
+ uint32 bDontAcceptIKLookAts : 1; // TODO: find uses of this
+#endif
+ // our own flags
+ uint32 m_ped_flagI40 : 1; // bMakePedsRunToPhonesToReportCrimes makes use of this as runover by car indicator
+ uint32 m_ped_flagI80 : 1; // KANGAROO_CHEAT define makes use of this as cheat toggle
- uint8 stuff10[3];
uint8 CharCreatedBy;
- uint8 field_161;
- uint8 pad_162[2];
eObjective m_objective;
eObjective m_prevObjective;
CPed *m_pedInObjective;
@@ -404,6 +404,10 @@ public:
CEntity* m_pEventEntity;
float m_fAngleToEvent;
AnimBlendFrameData *m_pFrames[PED_NODE_MAX];
+#ifdef PED_SKIN
+ // stored inside the clump with non-skin ped
+ RpAtomic *m_pWeaponModel;
+#endif
AssocGroupId m_animGroup;
CAnimBlendAssociation *m_pVehicleAnim;
CVector2D m_vecAnimMoveDelta;
@@ -424,8 +428,6 @@ public:
uint16 m_nPathNodes;
int16 m_nCurPathNode;
int8 m_nPathDir;
-private:
- int8 _pad2B5[3];
public:
CPathNode *m_pLastPathNode;
CPathNode *m_pNextPathNode;
@@ -436,12 +438,11 @@ public:
int16 m_routePointsPassed;
int16 m_routeType; // See PedRouteType
int16 m_routePointsBeingPassed;
- uint16 field_2D2;
CVector2D m_moved;
float m_fRotationCur;
float m_fRotationDest;
float m_headingRate;
- uint16 m_vehEnterType; // TODO: this is more like a door, not a type
+ uint16 m_vehEnterType;
int16 m_walkAroundType;
CPhysical *m_pCurrentPhysSurface;
CVector m_vecOffsetFromPhysSurface;
@@ -450,10 +451,8 @@ public:
CEntity *m_pSeekTarget;
CVehicle *m_pMyVehicle;
bool bInVehicle;
- uint8 pad_315[3];
float m_distanceToCountSeekDone;
bool bRunningToPhone;
- uint8 field_31D;
int16 m_phoneId;
eCrimeType m_crimeToReportOnPhone;
uint32 m_phoneTalkTimer;
@@ -468,7 +467,6 @@ public:
uint32 m_collidingThingTimer;
CEntity *m_pCollidingEntity;
uint8 m_stateUnused;
- uint8 pad_351[3];
uint32 m_timerUnused;
CVector2D *m_wanderRangeBounds; // array with 2 CVector2D (actually unused CRange2D class) - unused
CWeapon m_weapons[WEAPONTYPE_TOTAL_INVENTORY_WEAPONS];
@@ -483,7 +481,6 @@ public:
uint8 m_fightButtonPressure;
FightState m_fightState;
bool m_takeAStepAfterAttack;
- uint8 pad_4B3;
CFire *m_pFire;
CEntity *m_pLookTarget;
float m_fLookDirection;
@@ -502,11 +499,9 @@ public:
uint8 m_panicCounter;
bool m_deadBleeding;
int8 m_bodyPartBleeding; // PedNode, but -1 if there isn't
- uint8 m_field_4F3;
CPed *m_nearPeds[10];
uint16 m_numNearPeds;
int8 m_lastWepDam;
- uint8 pad_51F;
uint32 m_lastSoundStart;
uint32 m_soundStart;
uint16 m_lastQueuedSound;
@@ -742,7 +737,6 @@ public:
static void PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *assoc, void *arg);
static void PedSetDraggedOutCarPositionCB(CAnimBlendAssociation *assoc, void *arg);
- // functions that I see unnecessary to hook
bool IsPlayer(void);
bool UseGroundColModel(void);
bool CanSetPedState(void);
@@ -792,11 +786,15 @@ public:
bool HasWeapon(uint8 weaponType) { return m_weapons[weaponType].m_eWeaponType == weaponType; }
CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; }
CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; }
- RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; }
PedState GetPedState(void) { return m_nPedState; }
void SetPedState(PedState state) { m_nPedState = state; }
+ bool Dead(void) { return m_nPedState == PED_DEAD; }
+ bool Dying(void) { return m_nPedState == PED_DIE; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
+ bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
+
+ bool Driving(void) { return m_nPedState == PED_DRIVING; }
bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state.
bool EnteringCar(void) { return m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK; }
@@ -822,15 +820,53 @@ public:
SetMoveState(PEDMOVE_WALK);
}
+ // Using this to abstract nodes of skinned and non-skinned meshes
+ CVector GetNodePosition(int32 node)
+ {
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+ RwV3d pos = { 0.0f, 0.0f, 0.0f };
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ int32 idx = RpHAnimIDGetIndex(hier, m_pFrames[node]->nodeID);
+ RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
+ // this is just stupid
+ //RwV3dTransformPoints(&pos, &pos, 1, &mats[idx]);
+ pos = mats[idx].pos;
+ return pos;
+ }else
+#endif
+ {
+ RwMatrix mat;
+ CPedIK::GetWorldMatrix(m_pFrames[node]->frame, &mat);
+ return mat.pos;
+ }
+ }
+ void TransformToNode(CVector &pos, int32 node)
+ {
+#ifdef PED_SKIN
+ if(IsClumpSkinned(GetClump())){
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
+ int32 idx = RpHAnimIDGetIndex(hier, m_pFrames[node]->nodeID);
+ RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
+ RwV3dTransformPoints((RwV3d*)&pos, (RwV3d*)&pos, 1, &mats[idx]);
+ }else
+#endif
+ {
+ RwFrame *frame;
+ for (frame = m_pFrames[node]->frame; frame; frame = RwFrameGetParent(frame))
+ RwV3dTransformPoints((RwV3d*)&pos, (RwV3d*)&pos, 1, RwFrameGetMatrix(frame));
+ }
+ }
+
// set by 0482:set_threat_reaction_range_multiplier opcode
- static uint16 &nThreatReactionRangeMultiplier;
+ static uint16 nThreatReactionRangeMultiplier;
// set by 0481:set_enter_car_range_multiplier opcode
- static uint16 &nEnterCarRangeMultiplier;
+ static uint16 nEnterCarRangeMultiplier;
- static bool &bNastyLimbsCheat;
- static bool &bPedCheat2;
- static bool &bPedCheat3;
+ static bool bNastyLimbsCheat;
+ static bool bPedCheat2;
+ static bool bPedCheat3;
static CVector2D ms_vec2DFleePosition;
#ifdef TOGGLEABLE_BETA_FEATURES
@@ -843,6 +879,10 @@ public:
static void SwitchDebugDisplay(void);
void DebugRenderOnePedText(void);
#endif
+
+#ifdef PED_SKIN
+ void renderLimb(int node);
+#endif
};
class cPedParams
@@ -856,6 +896,7 @@ public:
void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg);
+#ifndef PED_SKIN
static_assert(offsetof(CPed, m_nPedState) == 0x224, "CPed: error");
static_assert(offsetof(CPed, m_pCurSurface) == 0x2FC, "CPed: error");
static_assert(offsetof(CPed, m_pMyVehicle) == 0x310, "CPed: error");
@@ -868,3 +909,4 @@ static_assert(offsetof(CPed, m_bodyPartBleeding) == 0x4F2, "CPed: error");
static_assert(offsetof(CPed, m_pedInObjective) == 0x16C, "CPed: error");
static_assert(offsetof(CPed, m_pEventEntity) == 0x19C, "CPed: error");
static_assert(sizeof(CPed) == 0x53C, "CPed: error");
+#endif
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index 8e450ee6..3db3dc0f 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -1,5 +1,6 @@
#include "common.h"
-#include "patcher.h"
+
+#include "Bones.h"
#include "Camera.h"
#include "PedIK.h"
#include "Ped.h"
@@ -12,6 +13,10 @@ LimbMovementInfo CPedIK::ms_headRestoreInfo = { DEGTORAD(90.0f), DEGTORAD(-90.0f
LimbMovementInfo CPedIK::ms_upperArmInfo = { DEGTORAD(20.0f), DEGTORAD(-100.0f), DEGTORAD(20.0f), DEGTORAD(70.0f), DEGTORAD(-70.0f), DEGTORAD(10.0f) };
LimbMovementInfo CPedIK::ms_lowerArmInfo = { DEGTORAD(80.0f), DEGTORAD(0.0f), DEGTORAD(20.0f), DEGTORAD(90.0f), DEGTORAD(-90.0f), DEGTORAD(5.0f) };
+const RwV3d XaxisIK = { 1.0f, 0.0f, 0.0f};
+const RwV3d YaxisIK = { 0.0f, 1.0f, 0.0f};
+const RwV3d ZaxisIK = { 0.0f, 0.0f, 1.0f};
+
CPedIK::CPedIK(CPed *ped)
{
m_ped = ped;
@@ -26,57 +31,104 @@ CPedIK::CPedIK(CPed *ped)
m_lowerArmOrient.theta = 0.0f;
}
+#ifdef PED_SKIN
+inline RwMatrix*
+GetComponentMatrix(CPed *ped, int32 node)
+{
+ RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(ped->GetClump());
+ int idx = RpHAnimIDGetIndex(hier, ped->m_pFrames[node]->nodeID);
+ RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
+ return &mats[idx];
+}
+#endif
+
void
-CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool changeRoll)
+CPedIK::RotateTorso(AnimBlendFrameData *node, LimbOrientation *limb, bool changeRoll)
{
- RwFrame *f = animBlend->frame;
- RwMatrix *mat = CPedIK::GetWorldMatrix(RwFrameGetParent(f), RwMatrixCreate());
-
- RwV3d upVector = { mat->right.z, mat->up.z, mat->at.z };
- RwV3d rightVector;
- RwV3d pos = RwFrameGetMatrix(f)->pos;
-
- // rotation == 0 -> looking in y direction
- // left? vector
- float c = Cos(m_ped->m_fRotationCur);
- float s = Sin(m_ped->m_fRotationCur);
- rightVector.x = -(c*mat->right.x + s*mat->right.y);
- rightVector.y = -(c*mat->up.x + s*mat->up.y);
- rightVector.z = -(c*mat->at.x + s*mat->at.y);
-
- if(changeRoll){
- // Used when aiming only involves over the legs.(canAimWithArm)
- // Automatically changes roll(forward rotation) axis of the parts above upper legs while moving, based on position of upper legs.
- // Not noticeable in normal conditions...
-
- RwV3d forwardVector;
- CVector inversedForward = CrossProduct(CVector(0.0f, 0.0f, 1.0f), mat->up);
- inversedForward.Normalise();
- float dotProduct = DotProduct(mat->at, inversedForward);
- if(dotProduct > 1.0f) dotProduct = 1.0f;
- if(dotProduct < -1.0f) dotProduct = -1.0f;
- float alpha = Acos(dotProduct);
-
- if(mat->at.z < 0.0f)
- alpha = -alpha;
-
- forwardVector.x = s * mat->right.x - c * mat->right.y;
- forwardVector.y = s * mat->up.x - c * mat->up.y;
- forwardVector.z = s * mat->at.x - c * mat->at.y;
-
- float curYaw, curPitch;
- CPedIK::ExtractYawAndPitchWorld(mat, &curYaw, &curPitch);
- RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->theta), rwCOMBINEPOSTCONCAT);
- RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->phi - (curYaw - m_ped->m_fRotationCur)), rwCOMBINEPOSTCONCAT);
- RwMatrixRotate(RwFrameGetMatrix(f), &forwardVector, RADTODEG(alpha), rwCOMBINEPOSTCONCAT);
- }else{
- // pitch
- RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->theta), rwCOMBINEPOSTCONCAT);
- // yaw
- RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->phi), rwCOMBINEPOSTCONCAT);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ RtQuat *q = &node->hanimFrame->q;
+#ifndef FIX_BUGS
+ // this is what the game does (also VC), but it does not look great
+ RtQuatRotate(q, &XaxisIK, RADTODEG(limb->phi), rwCOMBINEPRECONCAT);
+ RtQuatRotate(q, &ZaxisIK, RADTODEG(limb->theta), rwCOMBINEPRECONCAT); // pitch
+#else
+ // copied the code from the non-skinned case
+ // this seems to work ok
+
+ // We can't get the parent matrix of an hanim frame but
+ // this function is always called with PED_MID, so we know the parent frame.
+ // Trouble is that PED_MID is "Smid" on PS2/PC but BONE_torso on mobile/xbox...
+ // so this doesn't exactly do what we'd like anyway
+ RwMatrix *mat = GetComponentMatrix(m_ped, PED_MID);
+
+ RwV3d vec1, vec2;
+ vec1.x = mat->right.z;
+ vec1.y = mat->up.z;
+ vec1.z = mat->at.z;
+ float c = Cos(m_ped->m_fRotationCur);
+ float s = Sin(m_ped->m_fRotationCur);
+ vec2.x = -(c*mat->right.x + s*mat->right.y);
+ vec2.y = -(c*mat->up.x + s*mat->up.y);
+ vec2.z = -(c*mat->at.x + s*mat->at.y);
+
+ // Not sure what exactly to do here
+ RtQuatRotate(q, &vec1, RADTODEG(limb->phi), rwCOMBINEPRECONCAT);
+ RtQuatRotate(q, &vec2, RADTODEG(limb->theta), rwCOMBINEPRECONCAT);
+#endif
+ m_ped->bDontAcceptIKLookAts = true;
+ }else
+#endif
+ {
+ RwFrame *f = node->frame;
+ RwMatrix *mat = GetWorldMatrix(RwFrameGetParent(f), RwMatrixCreate());
+
+ RwV3d upVector = { mat->right.z, mat->up.z, mat->at.z };
+ RwV3d rightVector;
+ RwV3d pos = RwFrameGetMatrix(f)->pos;
+
+ // rotation == 0 -> looking in y direction
+ // left? vector
+ float c = Cos(m_ped->m_fRotationCur);
+ float s = Sin(m_ped->m_fRotationCur);
+ rightVector.x = -(c*mat->right.x + s*mat->right.y);
+ rightVector.y = -(c*mat->up.x + s*mat->up.y);
+ rightVector.z = -(c*mat->at.x + s*mat->at.y);
+
+ if(changeRoll){
+ // Used when aiming only involves over the legs.(canAimWithArm)
+ // Automatically changes roll(forward rotation) axis of the parts above upper legs while moving, based on position of upper legs.
+ // Not noticeable in normal conditions...
+
+ RwV3d forwardVector;
+ CVector inversedForward = CrossProduct(CVector(0.0f, 0.0f, 1.0f), mat->up);
+ inversedForward.Normalise();
+ float dotProduct = DotProduct(mat->at, inversedForward);
+ if(dotProduct > 1.0f) dotProduct = 1.0f;
+ if(dotProduct < -1.0f) dotProduct = -1.0f;
+ float alpha = Acos(dotProduct);
+
+ if(mat->at.z < 0.0f)
+ alpha = -alpha;
+
+ forwardVector.x = s * mat->right.x - c * mat->right.y;
+ forwardVector.y = s * mat->up.x - c * mat->up.y;
+ forwardVector.z = s * mat->at.x - c * mat->at.y;
+
+ float curYaw, curPitch;
+ ExtractYawAndPitchWorld(mat, &curYaw, &curPitch);
+ RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->theta), rwCOMBINEPOSTCONCAT);
+ RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->phi - (curYaw - m_ped->m_fRotationCur)), rwCOMBINEPOSTCONCAT);
+ RwMatrixRotate(RwFrameGetMatrix(f), &forwardVector, RADTODEG(alpha), rwCOMBINEPOSTCONCAT);
+ }else{
+ // pitch
+ RwMatrixRotate(RwFrameGetMatrix(f), &rightVector, RADTODEG(limb->theta), rwCOMBINEPOSTCONCAT);
+ // yaw
+ RwMatrixRotate(RwFrameGetMatrix(f), &upVector, RADTODEG(limb->phi), rwCOMBINEPOSTCONCAT);
+ }
+ RwFrameGetMatrix(f)->pos = pos;
+ RwMatrixDestroy(mat);
}
- RwFrameGetMatrix(f)->pos = pos;
- RwMatrixDestroy(mat);
}
void
@@ -85,12 +137,24 @@ CPedIK::GetComponentPosition(RwV3d *pos, uint32 node)
RwFrame *f;
RwMatrix *mat;
- f = m_ped->GetNodeFrame(node);
- mat = RwFrameGetMatrix(f);
- *pos = mat->pos;
-
- for (f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
- RwV3dTransformPoints(pos, pos, 1, RwFrameGetMatrix(f));
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ pos->x = 0.0f;
+ pos->y = 0.0f;
+ pos->z = 0.0f;
+ mat = GetComponentMatrix(m_ped, node);
+ // could just copy the position out of the matrix...
+ RwV3dTransformPoints(pos, pos, 1, mat);
+ }else
+#endif
+ {
+ f = m_ped->m_pFrames[node]->frame;
+ mat = RwFrameGetMatrix(f);
+ *pos = mat->pos;
+
+ for (f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
+ RwV3dTransformPoints(pos, pos, 1, RwFrameGetMatrix(f));
+ }
}
RwMatrix*
@@ -157,50 +221,94 @@ CPedIK::RestoreGunPosn(void)
return limbStatus == ANGLES_SET_EXACTLY;
}
+#ifdef PED_SKIN
+void
+CPedIK::RotateHead(void)
+{
+ RtQuat *q = &m_ped->m_pFrames[PED_HEAD]->hanimFrame->q;
+ RtQuatRotate(q, &XaxisIK, RADTODEG(m_headOrient.phi), rwCOMBINEREPLACE);
+ RtQuatRotate(q, &ZaxisIK, RADTODEG(m_headOrient.theta), rwCOMBINEPOSTCONCAT);
+ m_ped->bDontAcceptIKLookAts = true;
+}
+#endif
+
bool
CPedIK::LookInDirection(float phi, float theta)
{
bool success = true;
- RwFrame *frame = m_ped->GetNodeFrame(PED_HEAD);
- RwMatrix *frameMat = RwFrameGetMatrix(frame);
+ float yaw, pitch;
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ if (!(m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION)) {
+ m_ped->m_pFrames[PED_HEAD]->flag |= AnimBlendFrameData::IGNORE_ROTATION;
+ ExtractYawAndPitchLocalSkinned(m_ped->m_pFrames[PED_HEAD], &m_headOrient.phi, &m_headOrient.theta);
+ }
- if (!(m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION)) {
- m_ped->m_pFrames[PED_HEAD]->flag |= AnimBlendFrameData::IGNORE_ROTATION;
- CPedIK::ExtractYawAndPitchLocal(frameMat, &m_headOrient.phi, &m_headOrient.theta);
- }
+ // parent of head is torso
+ RwMatrix worldMat = *GetComponentMatrix(m_ped, BONE_torso);
+ ExtractYawAndPitchWorld(&worldMat, &yaw, &pitch);
+
+ LimbMoveStatus headStatus = MoveLimb(m_headOrient, CGeneral::LimitRadianAngle(phi - yaw),
+ CGeneral::LimitRadianAngle(DEGTORAD(10.0f)), ms_headInfo);
+ if (headStatus == ANGLES_SET_TO_MAX)
+ success = false;
+
+ if (headStatus != ANGLES_SET_EXACTLY){
+ if (!(m_flags & LOOKAROUND_HEAD_ONLY)){
+ if (MoveLimb(m_torsoOrient, CGeneral::LimitRadianAngle(phi), theta, ms_torsoInfo))
+ success = true;
+ }else{
+ RotateHead();
+ return success;
+ }
+ }
- RwMatrix *worldMat = RwMatrixCreate();
- worldMat = CPedIK::GetWorldMatrix(RwFrameGetParent(frame), worldMat);
+ if (!(m_flags & LOOKAROUND_HEAD_ONLY))
+ RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
+ RotateHead();
+ }else
+#endif
+ {
+ RwFrame *frame = m_ped->m_pFrames[PED_HEAD]->frame;
+ RwMatrix *frameMat = RwFrameGetMatrix(frame);
+
+ if (!(m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION)) {
+ m_ped->m_pFrames[PED_HEAD]->flag |= AnimBlendFrameData::IGNORE_ROTATION;
+ ExtractYawAndPitchLocal(frameMat, &m_headOrient.phi, &m_headOrient.theta);
+ }
- float alpha, beta;
- CPedIK::ExtractYawAndPitchWorld(worldMat, &alpha, &beta);
- RwMatrixDestroy(worldMat);
+ RwMatrix *worldMat = RwMatrixCreate();
+ worldMat = GetWorldMatrix(RwFrameGetParent(frame), worldMat);
- alpha += m_torsoOrient.phi;
- float neededPhiTurn = CGeneral::LimitRadianAngle(phi - alpha);
- beta *= cos(neededPhiTurn);
+ ExtractYawAndPitchWorld(worldMat, &yaw, &pitch);
+ RwMatrixDestroy(worldMat);
- float neededThetaTurn = CGeneral::LimitRadianAngle(theta - beta);
- LimbMoveStatus headStatus = CPedIK::MoveLimb(m_headOrient, neededPhiTurn, neededThetaTurn, ms_headInfo);
- if (headStatus == ANGLES_SET_TO_MAX)
- success = false;
+ yaw += m_torsoOrient.phi;
+ float neededPhiTurn = CGeneral::LimitRadianAngle(phi - yaw);
+ pitch *= Cos(neededPhiTurn);
- if (headStatus != ANGLES_SET_EXACTLY && !(m_flags & LOOKAROUND_HEAD_ONLY)) {
- float remainingTurn = CGeneral::LimitRadianAngle(phi - m_ped->m_fRotationCur);
- if (CPedIK::MoveLimb(m_torsoOrient, remainingTurn, theta, ms_torsoInfo))
- success = true;
- }
- CMatrix nextFrame = CMatrix(frameMat);
- CVector framePos = nextFrame.GetPosition();
+ float neededThetaTurn = CGeneral::LimitRadianAngle(theta - pitch);
+ LimbMoveStatus headStatus = MoveLimb(m_headOrient, neededPhiTurn, neededThetaTurn, ms_headInfo);
+ if (headStatus == ANGLES_SET_TO_MAX)
+ success = false;
- nextFrame.SetRotateZ(m_headOrient.theta);
- nextFrame.RotateX(m_headOrient.phi);
- nextFrame.GetPosition() += framePos;
- nextFrame.UpdateRW();
+ if (headStatus != ANGLES_SET_EXACTLY && !(m_flags & LOOKAROUND_HEAD_ONLY)) {
+ float remainingTurn = CGeneral::LimitRadianAngle(phi - m_ped->m_fRotationCur);
+ if (MoveLimb(m_torsoOrient, remainingTurn, theta, ms_torsoInfo))
+ success = true;
+ }
+ CMatrix nextFrame = CMatrix(frameMat);
+ CVector framePos = nextFrame.GetPosition();
- if (!(m_flags & LOOKAROUND_HEAD_ONLY))
- RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
+ nextFrame.SetRotateZ(m_headOrient.theta);
+ nextFrame.RotateX(m_headOrient.phi);
+ nextFrame.GetPosition() += framePos;
+ nextFrame.UpdateRW();
+ if (!(m_flags & LOOKAROUND_HEAD_ONLY))
+ RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
+
+ }
return success;
}
@@ -234,10 +342,24 @@ CPedIK::PointGunInDirection(float phi, float theta)
if (m_flags & AIMS_WITH_ARM && m_torsoOrient.phi * m_upperArmOrient.phi < 0.0f)
MoveLimb(m_torsoOrient, 0.0f, m_torsoOrient.theta, ms_torsoInfo);
} else {
- RwMatrix *matrix = GetWorldMatrix(RwFrameGetParent(m_ped->GetNodeFrame(PED_UPPERARMR)), RwMatrixCreate());
+ // Unused code
+ RwMatrix *matrix;
float yaw, pitch;
- ExtractYawAndPitchWorld(matrix, &yaw, &pitch);
- RwMatrixDestroy(matrix);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ matrix = RwMatrixCreate();
+ *matrix = *GetComponentMatrix(m_ped, PED_UPPERARMR);
+ ExtractYawAndPitchWorld(matrix, &yaw, &pitch);
+ RwMatrixDestroy(matrix);
+ }else
+#endif
+ {
+ matrix = GetWorldMatrix(RwFrameGetParent(m_ped->m_pFrames[PED_UPPERARMR]->frame), RwMatrixCreate());
+ ExtractYawAndPitchWorld(matrix, &yaw, &pitch);
+ RwMatrixDestroy(matrix);
+ }
+ //
+
LimbMoveStatus status = MoveLimb(m_torsoOrient, angle, theta, ms_torsoInfo);
if (status == ANGLES_SET_TO_MAX)
result = false;
@@ -255,24 +377,56 @@ bool
CPedIK::PointGunInDirectionUsingArm(float phi, float theta)
{
bool result = false;
- RwFrame *frame = m_ped->GetNodeFrame(PED_UPPERARMR);
- RwMatrix *matrix = GetWorldMatrix(RwFrameGetParent(frame), RwMatrixCreate());
-
- RwV3d upVector = { matrix->right.z, matrix->up.z, matrix->at.z };
+ RwV3d upVector; // only for non-skinned
+ RwMatrix *matrix;
float yaw, pitch;
- ExtractYawAndPitchWorld(matrix, &yaw, &pitch);
- RwMatrixDestroy(matrix);
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ matrix = RwMatrixCreate();
+ *matrix = *GetComponentMatrix(m_ped, PED_UPPERARMR);
+ ExtractYawAndPitchWorld(matrix, &yaw, &pitch);
+ RwMatrixDestroy(matrix);
+ }else
+#endif
+ {
+ RwFrame *frame = m_ped->m_pFrames[PED_UPPERARMR]->frame;
+ matrix = GetWorldMatrix(RwFrameGetParent(frame), RwMatrixCreate());
+
+ // with PED_SKIN this is actually done below (with a memory leak)
+ upVector.x = matrix->right.z;
+ upVector.y = matrix->up.z;
+ upVector.z = matrix->at.z;
+
+ ExtractYawAndPitchWorld(matrix, &yaw, &pitch);
+ RwMatrixDestroy(matrix);
+ }
RwV3d rightVector = { 0.0f, 0.0f, 1.0f };
RwV3d forwardVector = { 1.0f, 0.0f, 0.0f };
- float uaPhi = phi - m_torsoOrient.phi - DEGTORAD(15.0f);
- LimbMoveStatus uaStatus = MoveLimb(m_upperArmOrient, uaPhi, CGeneral::LimitRadianAngle(theta - pitch), ms_upperArmInfo);
+ float uaPhi, uaTheta;
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ uaPhi = phi;
+ uaTheta = theta + DEGTORAD(10.0f);
+ }else
+#endif
+ {
+ uaPhi = phi - m_torsoOrient.phi - DEGTORAD(15.0f);
+ uaTheta = CGeneral::LimitRadianAngle(theta - pitch);
+ }
+ LimbMoveStatus uaStatus = MoveLimb(m_upperArmOrient, uaPhi, uaTheta, ms_upperArmInfo);
if (uaStatus == ANGLES_SET_EXACTLY) {
m_flags |= GUN_POINTED_SUCCESSFULLY;
result = true;
}
+
+#ifdef PED_SKIN
+ // this code is completely missing on xbox & android, but we can keep it with the check
+ // TODO? implement it for skinned geometry?
+ if(!IsClumpSkinned(m_ped->GetClump()))
+#endif
if (uaStatus == ANGLES_SET_TO_MAX) {
float laPhi = uaPhi - m_upperArmOrient.phi;
@@ -286,17 +440,29 @@ CPedIK::PointGunInDirectionUsingArm(float phi, float theta)
m_flags |= GUN_POINTED_SUCCESSFULLY;
result = true;
}
- RwFrame *child = GetFirstChild(frame);
+ RwFrame *child = GetFirstChild(m_ped->m_pFrames[PED_UPPERARMR]->frame);
RwV3d pos = RwFrameGetMatrix(child)->pos;
RwMatrixRotate(RwFrameGetMatrix(child), &forwardVector, RADTODEG(m_lowerArmOrient.theta), rwCOMBINEPOSTCONCAT);
RwMatrixRotate(RwFrameGetMatrix(child), &rightVector, RADTODEG(-m_lowerArmOrient.phi), rwCOMBINEPOSTCONCAT);
RwFrameGetMatrix(child)->pos = pos;
}
- RwV3d pos = RwFrameGetMatrix(frame)->pos;
- RwMatrixRotate(RwFrameGetMatrix(frame), &rightVector, RADTODEG(m_upperArmOrient.theta), rwCOMBINEPOSTCONCAT);
- RwMatrixRotate(RwFrameGetMatrix(frame), &upVector, RADTODEG(m_upperArmOrient.phi), rwCOMBINEPOSTCONCAT);
- RwFrameGetMatrix(frame)->pos = pos;
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ RtQuat *q = &m_ped->m_pFrames[PED_UPPERARMR]->hanimFrame->q;
+ RtQuatRotate(q, &XaxisIK, RADTODEG(m_upperArmOrient.phi), rwCOMBINEPOSTCONCAT);
+ RtQuatRotate(q, &ZaxisIK, RADTODEG(m_upperArmOrient.theta), rwCOMBINEPOSTCONCAT);
+ m_ped->bDontAcceptIKLookAts = true;
+ }else
+#endif
+ {
+ RwFrame *frame = m_ped->m_pFrames[PED_UPPERARMR]->frame;
+ // with PED_SKIN we're also getting upVector here
+ RwV3d pos = RwFrameGetMatrix(frame)->pos;
+ RwMatrixRotate(RwFrameGetMatrix(frame), &rightVector, RADTODEG(m_upperArmOrient.theta), rwCOMBINEPOSTCONCAT);
+ RwMatrixRotate(RwFrameGetMatrix(frame), &upVector, RADTODEG(m_upperArmOrient.phi), rwCOMBINEPOSTCONCAT);
+ RwFrameGetMatrix(frame)->pos = pos;
+ }
return result;
}
@@ -314,28 +480,42 @@ bool
CPedIK::RestoreLookAt(void)
{
bool result = false;
- RwMatrix *mat = RwFrameGetMatrix(m_ped->GetNodeFrame(PED_HEAD));
- if (m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION) {
- m_ped->m_pFrames[PED_HEAD]->flag &= (~AnimBlendFrameData::IGNORE_ROTATION);
- } else {
- float yaw, pitch;
- ExtractYawAndPitchLocal(mat, &yaw, &pitch);
- if (MoveLimb(m_headOrient, yaw, pitch, ms_headRestoreInfo) == ANGLES_SET_EXACTLY)
- result = true;
- }
+ float yaw, pitch;
- CMatrix matrix(mat);
- CVector pos = matrix.GetPosition();
- matrix.SetRotateZ(m_headOrient.theta);
- matrix.RotateX(m_headOrient.phi);
- matrix.Translate(pos);
- matrix.UpdateRW();
+#ifdef PED_SKIN
+ if(IsClumpSkinned(m_ped->GetClump())){
+ if (m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION) {
+ m_ped->m_pFrames[PED_HEAD]->flag &= (~AnimBlendFrameData::IGNORE_ROTATION);
+ } else {
+ ExtractYawAndPitchLocalSkinned(m_ped->m_pFrames[PED_HEAD], &yaw, &pitch);
+ if (MoveLimb(m_headOrient, yaw, pitch, ms_headRestoreInfo) == ANGLES_SET_EXACTLY)
+ result = true;
+ }
+ RotateHead();
+ }else
+#endif
+ {
+ RwMatrix *mat = RwFrameGetMatrix(m_ped->m_pFrames[PED_HEAD]->frame);
+ if (m_ped->m_pFrames[PED_HEAD]->flag & AnimBlendFrameData::IGNORE_ROTATION) {
+ m_ped->m_pFrames[PED_HEAD]->flag &= (~AnimBlendFrameData::IGNORE_ROTATION);
+ } else {
+ ExtractYawAndPitchLocal(mat, &yaw, &pitch);
+ if (MoveLimb(m_headOrient, yaw, pitch, ms_headRestoreInfo) == ANGLES_SET_EXACTLY)
+ result = true;
+ }
- if (!(m_flags & LOOKAROUND_HEAD_ONLY))
+ CMatrix matrix(mat);
+ CVector pos = matrix.GetPosition();
+ matrix.SetRotateZ(m_headOrient.theta);
+ matrix.RotateX(m_headOrient.phi);
+ matrix.Translate(pos);
+ matrix.UpdateRW();
+ }
+ if (!(m_flags & LOOKAROUND_HEAD_ONLY)){
MoveLimb(m_torsoOrient, 0.0f, 0.0f, ms_torsoInfo);
- if (!(m_flags & LOOKAROUND_HEAD_ONLY))
- RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
-
+ if (!(m_flags & LOOKAROUND_HEAD_ONLY))
+ RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
+ }
return result;
}
@@ -363,18 +543,13 @@ CPedIK::ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch)
if (mat->up.x > 0.0f) *pitch = -*pitch;
}
-STARTPATCHES
- InjectHook(0x4ED0F0, &CPedIK::GetComponentPosition, PATCH_JUMP);
- InjectHook(0x4ED060, &CPedIK::GetWorldMatrix, PATCH_JUMP);
- InjectHook(0x4EDDB0, &CPedIK::RotateTorso, PATCH_JUMP);
- InjectHook(0x4ED440, &CPedIK::MoveLimb, PATCH_JUMP);
- InjectHook(0x4EDD70, &CPedIK::RestoreGunPosn, PATCH_JUMP);
- InjectHook(0x4ED620, &CPedIK::LookInDirection, PATCH_JUMP);
- InjectHook(0x4ED590, &CPedIK::LookAtPosition, PATCH_JUMP);
- InjectHook(0x4ED9B0, &CPedIK::PointGunInDirection, PATCH_JUMP);
- InjectHook(0x4EDB20, &CPedIK::PointGunInDirectionUsingArm, PATCH_JUMP);
- InjectHook(0x4ED920, &CPedIK::PointGunAtPosition, PATCH_JUMP);
- InjectHook(0x4ED810, &CPedIK::RestoreLookAt, PATCH_JUMP);
- InjectHook(0x4ED140, &CPedIK::ExtractYawAndPitchWorld, PATCH_JUMP);
- InjectHook(0x4ED2C0, &CPedIK::ExtractYawAndPitchLocal, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
+#ifdef PED_SKIN
+void
+CPedIK::ExtractYawAndPitchLocalSkinned(AnimBlendFrameData *node, float *yaw, float *pitch)
+{
+ RwMatrix *mat = RwMatrixCreate();
+ RtQuatConvertToMatrix(&node->hanimFrame->q, mat);
+ ExtractYawAndPitchLocal(mat, yaw, pitch);
+ RwMatrixDestroy(mat);
+}
+#endif
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index 7b82d1ac..fd9e4702 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -55,9 +55,11 @@ public:
static RwMatrix *GetWorldMatrix(RwFrame *source, RwMatrix *destination);
void RotateTorso(AnimBlendFrameData* animBlend, LimbOrientation* limb, bool changeRoll);
void ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch);
+ void ExtractYawAndPitchLocalSkinned(AnimBlendFrameData *node, float *yaw, float *pitch);
void ExtractYawAndPitchWorld(RwMatrix *mat, float *yaw, float *pitch);
LimbMoveStatus MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, LimbMovementInfo &moveInfo);
bool RestoreGunPosn(void);
+ void RotateHead(void);
bool LookInDirection(float phi, float theta);
bool LookAtPosition(CVector const& pos);
bool RestoreLookAt(void);
diff --git a/src/peds/PedPlacement.cpp b/src/peds/PedPlacement.cpp
index e5f6a077..8b8b3dfa 100644
--- a/src/peds/PedPlacement.cpp
+++ b/src/peds/PedPlacement.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "Ped.h"
#include "PedPlacement.h"
#include "World.h"
@@ -30,7 +30,7 @@ CPedPlacement::FindZCoorForPed(CVector* pos)
if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, nil))
foundColZ2 = foundCol.point.z;
- zForPed = max(foundColZ, foundColZ2);
+ zForPed = Max(foundColZ, foundColZ2);
if (zForPed > -99.0f)
pos->z = FEET_OFFSET + zForPed;
@@ -49,8 +49,3 @@ CPedPlacement::IsPositionClearForPed(CVector* pos)
CWorld::FindObjectsKindaColliding(*pos, 0.75f, true, &count, 2, nil, false, true, true, false, false);
return count == 0;
}
-
-STARTPATCHES
- InjectHook(0x4EE340, &CPedPlacement::FindZCoorForPed, PATCH_JUMP);
- InjectHook(0x4EE310, &CPedPlacement::IsPositionClearOfCars, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/PedRoutes.cpp b/src/peds/PedRoutes.cpp
index 3bc17002..3ff080e6 100644
--- a/src/peds/PedRoutes.cpp
+++ b/src/peds/PedRoutes.cpp
@@ -1,9 +1,9 @@
#include "common.h"
-#include "patcher.h"
+
#include "main.h"
#include "PedRoutes.h"
-CRouteNode (&gaRoutes)[NUMPEDROUTES] = *(CRouteNode(*)[NUMPEDROUTES]) * (uintptr*)0x62E090;
+CRouteNode gaRoutes[NUMPEDROUTES];
void
CRouteNode::Initialise()
diff --git a/src/peds/PedStats.cpp b/src/peds/PedStats.cpp
index 147f11e2..06e39039 100644
--- a/src/peds/PedStats.cpp
+++ b/src/peds/PedStats.cpp
@@ -1,10 +1,9 @@
#include "common.h"
-#include "patcher.h"
+
#include "General.h"
#include "FileMgr.h"
#include "PedStats.h"
-//CPedStats *(&CPedStats::ms_apPedStats)[NUM_PEDSTATS] = *(CPedStats *(*)[NUM_PEDSTATS]) *(uintptr*)0x9404D4;
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
void
@@ -117,10 +116,3 @@ CPedStats::GetPedStatType(char *name)
return NUM_PEDSTATS;
}
-
-STARTPATCHES
- InjectHook(0x4EF460, &CPedStats::Initialise, PATCH_JUMP);
- InjectHook(0x4EF540, &CPedStats::Shutdown, PATCH_JUMP);
- InjectHook(0x4EF580, &CPedStats::LoadPedStats, PATCH_JUMP);
- InjectHook(0x4EF780, &CPedStats::GetPedStatType, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/PedType.cpp b/src/peds/PedType.cpp
index 4c9d6b3f..8bf4c6e1 100644
--- a/src/peds/PedType.cpp
+++ b/src/peds/PedType.cpp
@@ -1,9 +1,9 @@
#include "common.h"
-#include "patcher.h"
+
#include "FileMgr.h"
#include "PedType.h"
-CPedType *(&CPedType::ms_apPedType)[NUM_PEDTYPES] = *(CPedType *(*)[NUM_PEDTYPES]) *(uintptr*)0x941594;
+CPedType *CPedType::ms_apPedType[NUM_PEDTYPES];
void
CPedType::Initialise(void)
@@ -202,12 +202,3 @@ INITSAVEBUF
*ms_apPedType[i] = ReadSaveBuf<CPedType>(buf);
VALIDATESAVEBUF(size)
}
-
-STARTPATCHES
- InjectHook(0x4EE7E0, &CPedType::Initialise, PATCH_JUMP);
- InjectHook(0x4EE890, &CPedType::Shutdown, PATCH_JUMP);
- InjectHook(0x4EEC10, &CPedType::FindPedType, PATCH_JUMP);
- InjectHook(0x4EEF40, &CPedType::FindPedFlag, PATCH_JUMP);
- InjectHook(0x4EF320, &CPedType::Save, PATCH_JUMP);
- InjectHook(0x4EF3D0, &CPedType::Load, PATCH_JUMP);
-ENDPATCHES
diff --git a/src/peds/PedType.h b/src/peds/PedType.h
index 3d927df5..c0c72550 100644
--- a/src/peds/PedType.h
+++ b/src/peds/PedType.h
@@ -71,7 +71,7 @@ class CPedType
uint32 m_threats;
uint32 m_avoid;
- static CPedType *(&ms_apPedType)[NUM_PEDTYPES];
+ static CPedType *ms_apPedType[NUM_PEDTYPES];
public:
static void Initialise(void);
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index ccc0a43a..664fff18 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -1,5 +1,6 @@
#include "common.h"
-#include "patcher.h"
+
+#include "RwHelper.h"
#include "PlayerPed.h"
#include "Wanted.h"
#include "Fire.h"
@@ -43,8 +44,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_fStaminaProgress = 0.0f;
m_nEvadeAmount = 0;
field_1367 = 0;
- m_nShotDelay = 0;
- field_1376 = 0.0f;
+ m_nHitAnimDelayTimer = 0;
+ m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false;
m_bHasLockOnTarget = false;
m_bCanBeDamaged = true;
@@ -135,6 +136,9 @@ CPlayerPed::SetupPlayerPed(int32 index)
{
CPlayerPed *player = new CPlayerPed();
CWorld::Players[index].m_pPed = player;
+#ifdef FIX_BUGS
+ player->RegisterReference((CEntity**)&CWorld::Players[index].m_pPed);
+#endif
player->SetOrientation(0.0f, 0.0f, 0.0f);
@@ -179,7 +183,7 @@ CPlayerPed::MakeChangesForNewWeapon(int8 weapon)
}
SetCurrentWeapon(weapon);
- GetWeapon()->m_nAmmoInClip = min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
+ GetWeapon()->m_nAmmoInClip = Min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAim))
ClearWeaponTarget();
@@ -696,7 +700,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
#else
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
#endif
- m_fMoveSpeed = min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
+ m_fMoveSpeed = Min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
} else {
m_fMoveSpeed = 0.0f;
}
@@ -1024,10 +1028,10 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (padUsed->WeaponJustDown()) {
m_bHaveTargetSelected = true;
} else if (!m_bHaveTargetSelected) {
- field_1376 += CTimer::GetTimeStepNonClipped();
+ m_fAttackButtonCounter += CTimer::GetTimeStepNonClipped();
}
} else {
- field_1376 = 0.0f;
+ m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false;
}
SetAttack(nil);
@@ -1183,7 +1187,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
float maxAcc = 0.07f * CTimer::GetTimeStep();
- m_fMoveSpeed = min(padMoveInGameUnit, m_fMoveSpeed + maxAcc);
+ m_fMoveSpeed = Min(padMoveInGameUnit, m_fMoveSpeed + maxAcc);
} else {
m_fMoveSpeed = 0.0f;
@@ -1403,7 +1407,7 @@ CPlayerPed::ProcessControl(void)
if (bVehEnterDoorIsBlocked || bKindaStayInSamePlace) {
m_fMoveSpeed = 0.0f;
} else {
- m_fMoveSpeed = min(2.0f, 2.0f * (m_vecSeekPos - GetPosition()).Magnitude2D());
+ m_fMoveSpeed = Min(2.0f, 2.0f * (m_vecSeekPos - GetPosition()).Magnitude2D());
}
if (padUsed && !padUsed->ArePlayerControlsDisabled()) {
if (padUsed->GetTarget() || padUsed->GetLeftStickXJustDown() || padUsed->GetLeftStickYJustDown() ||
@@ -1494,42 +1498,9 @@ CPlayerPed::ProcessControl(void)
m_nSpeedTimer = 0;
m_bSpeedTimerFlag = false;
}
-}
-#include <new>
-
-class CPlayerPed_ : public CPlayerPed
-{
-public:
- CPlayerPed* ctor(void) { return ::new (this) CPlayerPed(); }
- void dtor(void) { CPlayerPed::~CPlayerPed(); }
- void SetMoveAnim_(void) { CPlayerPed::SetMoveAnim(); }
- void ProcessControl_(void) { CPlayerPed::ProcessControl(); }
-};
-
-STARTPATCHES
- InjectHook(0x4EF7E0, &CPlayerPed_::ctor, PATCH_JUMP);
- InjectHook(0x4EFB30, &CPlayerPed_::dtor, PATCH_JUMP);
- InjectHook(0x4F3760, &CPlayerPed_::SetMoveAnim_, PATCH_JUMP);
- InjectHook(0x4EFD90, &CPlayerPed_::ProcessControl_, PATCH_JUMP);
- InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP);
- InjectHook(0x4F3700, &CPlayerPed::AnnoyPlayerPed, PATCH_JUMP);
- InjectHook(0x4F36C0, &CPlayerPed::GetPlayerInfoForThisPlayerPed, PATCH_JUMP);
- InjectHook(0x4F2560, &CPlayerPed::MakeChangesForNewWeapon, PATCH_JUMP);
- InjectHook(0x4F07C0, &CPlayerPed::ReApplyMoveAnims, PATCH_JUMP);
- InjectHook(0x4F0880, &CPlayerPed::SetRealMoveAnim, PATCH_JUMP);
- InjectHook(0x4F1810, &CPlayerPed::PlayerControlFighter, PATCH_JUMP);
- InjectHook(0x4F1340, &CPlayerPed::RestoreSprintEnergy, PATCH_JUMP);
- InjectHook(0x4F1380, &CPlayerPed::DoWeaponSmoothSpray, PATCH_JUMP);
- InjectHook(0x4F36E0, &CPlayerPed::DoStuffToGoOnFire, PATCH_JUMP);
- InjectHook(0x4F3350, &CPlayerPed::DoesTargetHaveToBeBroken, PATCH_JUMP);
- InjectHook(0x4F31D0, &CPlayerPed::RunningLand, PATCH_JUMP);
- InjectHook(0x4F2D00, &CPlayerPed::IsThisPedAttackingPlayer, PATCH_JUMP);
- InjectHook(0x4F1CF0, &CPlayerPed::PlayerControlSniper, PATCH_JUMP);
- InjectHook(0x4F2310, &CPlayerPed::ProcessWeaponSwitch, PATCH_JUMP);
- InjectHook(0x4F1DF0, &CPlayerPed::PlayerControlM16, PATCH_JUMP);
- InjectHook(0x4F3460, &CPlayerPed::KeepAreaAroundPlayerClear, PATCH_JUMP);
- InjectHook(0x4F1970, &CPlayerPed::PlayerControl1stPersonRunAround, PATCH_JUMP);
- InjectHook(0x4F1EF0, &CPlayerPed::ProcessPlayerWeapon, PATCH_JUMP);
- InjectHook(0x4F2640, &CPlayerPed::ProcessAnimGroups, PATCH_JUMP);
-ENDPATCHES
+#ifdef PED_SKIN
+ if (!bIsVisible && IsClumpSkinned(GetClump()))
+ UpdateRpHAnim();
+#endif
+}
diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h
index c139bbbc..b8bd57e4 100644
--- a/src/peds/PlayerPed.h
+++ b/src/peds/PlayerPed.h
@@ -20,23 +20,16 @@ public:
uint8 m_nEvadeAmount;
int8 field_1367;
uint32 m_nSpeedTimer;
- int32 m_nShotDelay;
- float field_1376; // m_fAttackButtonCounter?
+ uint32 m_nHitAnimDelayTimer;
+ float m_fAttackButtonCounter;
bool m_bHaveTargetSelected; // may have better name
- int8 field_1381;
- int8 field_1382;
- int8 field_1383;
CEntity *m_pEvadingFrom; // is this CPhysical?
int32 m_nTargettableObjects[4];
bool m_bAdrenalineActive;
bool m_bHasLockOnTarget;
- int8 field_1406;
- int8 field_1407;
uint32 m_nAdrenalineTime;
bool m_bCanBeDamaged;
int8 field_1413;
- int8 field_1414;
- int8 field_1415;
CVector m_vecSafePos[6]; // safe places from the player, for example behind a tree
CPed *m_pPedAtSafePos[6];
float m_fWalkAngle;
@@ -84,4 +77,6 @@ public:
static void ReactivatePlayerPed(int32);
};
+#ifndef PED_SKIN
static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error");
+#endif
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index 6959487f..cd89a05d 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -1,5 +1,5 @@
#include "common.h"
-#include "patcher.h"
+
#include "Game.h"
#include "General.h"
#include "World.h"
@@ -35,48 +35,48 @@ const RegenerationPoint aSafeZones[] = {
CVector(790.0f, -917.0f, 39.0f), CVector(775.0f, -921.0f, 39.0f), CVector(424.0f, -942.0f, 38.0f), CVector(439.0f, -938.0f, 38.0f) },
{ LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 555.0f, 711.0f, 118.0f, 186.0f, -30.0f, -10.0f,
CVector(698.0f, 182.0f, -20.0f), CVector(681.0f, 178.0f, -20.0f), CVector(586.0f, 144.0f, -20.0f), CVector(577.0f, 135.0f, -20.0f) },
- { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 26.0f, 44.0f, 124.0f, 87.0f, 20.0f, 6.0f,
+ { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 626.0f, 744.0f, -124.0f, -87.0f, -20.0f, -6.0f,
CVector(736.0f, -117.0f, -13.0f), CVector(730.0f, -115.0f, -13.0f), CVector(635.0f, -93.0f, -12.5f), CVector(650.0f, -89.0f, -12.5f) },
- { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 45.0f, 34.0f, 780.0f, 750.0f, 25.0f, 6.0f,
+ { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 645.0f, 734.0f, -780.0f, -750.0f, -25.0f, -6.0f,
CVector(729.0f, -764.0f, -18.0f), CVector(720.0f, -769.0f, -17.0f), CVector(652.0f, -774.0f, -10.5f), CVector(659.0f, -770.0f, -10.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 532.0f, 136.0f, 668.0f, 599.0f, 4.0f, 0.0f,
+ { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -532.0f, -136.0f, -668.0f, -599.0f, 34.0f, 60.0f,
CVector(-172.0f, -619.0f, 44.0f), CVector(-183.0f, -623.0f, 44.0f), CVector(-511.0f, -645.0f, 41.0f), CVector(-493.0f, -639.0f, 41.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 325.0f, 175.0f, 7.0f, 5.0f, 30.0f, 10.0f,
+ { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -325.0f, -175.0f, 27.0f, 75.0f, -30.0f, -10.0f,
CVector(-185.0f, 40.8f, -20.5f), CVector(-202.0f, 37.0f, -20.5f), CVector(-315.0f, 65.5f, -20.5f), CVector(-306.0f, 62.4f, -20.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 410.0f, 310.0f, 1055.0f, 1030.0f, 20.0f, 6.0f,
+ { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -410.0f, -310.0f, -1055.0f, -1030.0f, -20.0f, -6.0f,
CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f) },
- { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 425.0f, 280.0f, 471.0f, 447.0f, 20.0f, 5.0f,
+ { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, -425.0f, -280.0f, -471.0f, -447.0f, -20.0f, -5.0f,
CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f) }
-}; // *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578;
-
-PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; // = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248;
-bool CPopulation::ms_bGivePedsWeapons; // = *(bool*)0x95CCF6;
-int32 CPopulation::m_AllRandomPedsThisType = -1; // = *(int32*)0x5FA570;
-float CPopulation::PedDensityMultiplier = 1.0f; // = *(float*)0x5FA56C;
-uint32 CPopulation::ms_nTotalMissionPeds; // = *(uint32*)0x8F5F70;
-int32 CPopulation::MaxNumberOfPedsInUse = 25; // *(int32*)0x5FA574;
-uint32 CPopulation::ms_nNumCivMale; // = *(uint32*)0x8F2548;
-uint32 CPopulation::ms_nNumCivFemale; // = *(uint32*)0x8F5F44;
-uint32 CPopulation::ms_nNumCop; // = *(uint32*)0x885AFC;
-bool CPopulation::bZoneChangeHasHappened; // = *(bool*)0x95CD79;
-uint32 CPopulation::ms_nNumEmergency; // = *(uint32*)0x94071C;
-int8 CPopulation::m_CountDownToPedsAtStart; // = *(int8*)0x95CD4F;
-uint32 CPopulation::ms_nNumGang1; // = *(uint32*)0x8F1B1C;
-uint32 CPopulation::ms_nNumGang2; // = *(uint32*)0x8F1B14;
-uint32 CPopulation::ms_nTotalPeds; // = *(uint32*)0x95CB50;
-uint32 CPopulation::ms_nNumGang3; // = *(uint32*)0x8F2548;
-uint32 CPopulation::ms_nTotalGangPeds; // = *(uint32*)0x885AF0;
-uint32 CPopulation::ms_nNumGang4; // = *(uint32*)0x8F1B2C;
-uint32 CPopulation::ms_nTotalCivPeds; // = *(uint32*)0x8F2C3C;
-uint32 CPopulation::ms_nNumGang5; // = *(uint32*)0x8F1B30;
-uint32 CPopulation::ms_nNumDummy; // = *(uint32*)0x8F1A98;
-uint32 CPopulation::ms_nNumGang6; // = *(uint32*)0x8F1B20;
-uint32 CPopulation::ms_nNumGang9; // = *(uint32*)0x8F1B10;
-uint32 CPopulation::ms_nNumGang7; // = *(uint32*)0x8F1B28;
-uint32 CPopulation::ms_nNumGang8; // = *(uint32*)0x8F1B0C;
-CVector CPopulation::RegenerationPoint_a; // = *(CVector*)0x8E2AA4;
-CVector CPopulation::RegenerationPoint_b; // = *(CVector*)0x8E2A98;
-CVector CPopulation::RegenerationForward; // = *(CVector*)0x8F1AD4;
+};
+
+PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS];
+bool CPopulation::ms_bGivePedsWeapons;
+int32 CPopulation::m_AllRandomPedsThisType = -1;
+float CPopulation::PedDensityMultiplier = 1.0f;
+uint32 CPopulation::ms_nTotalMissionPeds;
+int32 CPopulation::MaxNumberOfPedsInUse = 25;
+uint32 CPopulation::ms_nNumCivMale;
+uint32 CPopulation::ms_nNumCivFemale;
+uint32 CPopulation::ms_nNumCop;
+bool CPopulation::bZoneChangeHasHappened;
+uint32 CPopulation::ms_nNumEmergency;
+int8 CPopulation::m_CountDownToPedsAtStart;
+uint32 CPopulation::ms_nNumGang1;
+uint32 CPopulation::ms_nNumGang2;
+uint32 CPopulation::ms_nTotalPeds;
+uint32 CPopulation::ms_nNumGang3;
+uint32 CPopulation::ms_nTotalGangPeds;
+uint32 CPopulation::ms_nNumGang4;
+uint32 CPopulation::ms_nTotalCivPeds;
+uint32 CPopulation::ms_nNumGang5;
+uint32 CPopulation::ms_nNumDummy;
+uint32 CPopulation::ms_nNumGang6;
+uint32 CPopulation::ms_nNumGang9;
+uint32 CPopulation::ms_nNumGang7;
+uint32 CPopulation::ms_nNumGang8;
+CVector CPopulation::RegenerationPoint_a;
+CVector CPopulation::RegenerationPoint_b;
+CVector CPopulation::RegenerationForward;
void
CPopulation::Initialise()
@@ -595,7 +595,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
}
// Yeah, float
float maxPossiblePedsForArea = (zoneInfo.pedDensity + zoneInfo.carDensity) * playerInfo->m_fRoadDensity * PedDensityMultiplier * CIniFile::PedNumberMultiplier;
- maxPossiblePedsForArea = min(maxPossiblePedsForArea, MaxNumberOfPedsInUse);
+ maxPossiblePedsForArea = Min(maxPossiblePedsForArea, MaxNumberOfPedsInUse);
if (ms_nTotalPeds < maxPossiblePedsForArea || addCop) {
int decisionThreshold = CGeneral::GetRandomNumberInRange(0, 1000);
@@ -703,7 +703,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
if (!foundGround)
return;
- generatedCoors.z = max(generatedCoors.z, groundZ);
+ generatedCoors.z = Max(generatedCoors.z, groundZ);
}
bool farEnoughToAdd = true;
CMatrix mat(TheCamera.GetCameraMatrix());
@@ -1050,7 +1050,7 @@ CPopulation::TestSafeForRealObject(CDummyObject *dummy)
if (maxY >= NUMSECTORS_Y) maxY = NUMSECTORS_Y;
#endif
- static CColPoint aTempColPoints;
+ static CColPoint aTempColPoints[MAX_COLLISION_POINTS];
for (int curY = minY; curY <= maxY; curY++) {
for (int curX = minX; curX <= maxX; curX++) {
@@ -1061,7 +1061,7 @@ CPopulation::TestSafeForRealObject(CDummyObject *dummy)
if (veh->m_scanCode != CWorld::GetCurrentScanCode()) {
if (veh->GetIsTouching(colCentre, colRadius)) {
veh->m_scanCode = CWorld::GetCurrentScanCode();
- if (CCollision::ProcessColModels(dummy->GetMatrix(), *dummyCol, veh->GetMatrix(), *veh->GetColModel(), &aTempColPoints, nil, nil) > 0)
+ if (CCollision::ProcessColModels(dummy->GetMatrix(), *dummyCol, veh->GetMatrix(), *veh->GetColModel(), aTempColPoints, nil, nil) > 0)
return false;
}
}
@@ -1072,7 +1072,7 @@ CPopulation::TestSafeForRealObject(CDummyObject *dummy)
if (veh->m_scanCode != CWorld::GetCurrentScanCode()) {
if (veh->GetIsTouching(colCentre, colRadius)) {
veh->m_scanCode = CWorld::GetCurrentScanCode();
- if (CCollision::ProcessColModels(dummy->GetMatrix(), *dummyCol, veh->GetMatrix(), *veh->GetColModel(), &aTempColPoints, nil, nil) > 0)
+ if (CCollision::ProcessColModels(dummy->GetMatrix(), *dummyCol, veh->GetMatrix(), *veh->GetColModel(), aTempColPoints, nil, nil) > 0)
return false;
}
}
@@ -1180,16 +1180,3 @@ CPopulation::ManagePopulation(void)
}
}
}
-
-STARTPATCHES
- InjectHook(0x4F3770, &CPopulation::Initialise, PATCH_JUMP);
- InjectHook(0x4F5780, &CPopulation::ChooseGangOccupation, PATCH_JUMP);
- InjectHook(0x4F6200, &CPopulation::DealWithZoneChange, PATCH_JUMP);
- InjectHook(0x4F6010, &CPopulation::FindCollisionZoneForCoors, PATCH_JUMP);
- InjectHook(0x4F6410, &CPopulation::PedCreationDistMultiplier, PATCH_JUMP);
- InjectHook(0x4F5280, &CPopulation::AddPed, PATCH_JUMP);
- InjectHook(0x4F4470, &CPopulation::ConvertToRealObject, PATCH_JUMP);
- InjectHook(0x4F4690, &CPopulation::TestRoomForDummyObject, PATCH_JUMP);
- InjectHook(0x4F45A0, &CPopulation::ConvertToDummyObject, PATCH_JUMP);
- InjectHook(0x4F4410, &CPopulation::ConvertAllObjectsToDummyObjects, PATCH_JUMP);
-ENDPATCHES