summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
Diffstat (limited to 'src/peds')
-rw-r--r--src/peds/CivilianPed.cpp2
-rw-r--r--src/peds/CopPed.cpp206
-rw-r--r--src/peds/CopPed.h4
-rw-r--r--src/peds/EmergencyPed.cpp1
-rw-r--r--src/peds/Ped.cpp12
-rw-r--r--src/peds/Ped.h11
-rw-r--r--src/peds/PedIK.cpp2
-rw-r--r--src/peds/PedIK.h3
-rw-r--r--src/peds/PedPlacement.cpp1
-rw-r--r--src/peds/PedPlacement.h2
-rw-r--r--src/peds/PlayerPed.cpp5
-rw-r--r--src/peds/PlayerPed.h6
-rw-r--r--src/peds/Population.cpp10
-rw-r--r--src/peds/Population.h4
14 files changed, 238 insertions, 31 deletions
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index 2e6166be..533d7c98 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -4,6 +4,8 @@
#include "Phones.h"
#include "General.h"
#include "PlayerPed.h"
+#include "Wanted.h"
+#include "DMAudio.h"
#include "World.h"
#include "Vehicle.h"
#include "SurfaceTable.h"
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index 94acac05..b5812136 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -3,15 +3,19 @@
#include "World.h"
#include "PlayerPed.h"
#include "CopPed.h"
+#include "Wanted.h"
+#include "DMAudio.h"
#include "ModelIndices.h"
#include "Vehicle.h"
#include "RpAnimBlend.h"
+#include "AnimBlendAssociation.h"
#include "General.h"
#include "ZoneCull.h"
#include "PathFind.h"
#include "RoadBlocks.h"
-
-WRAPPER void CCopPed::ProcessControl() { EAXJMP(0x4C1400); }
+#include "CarCtrl.h"
+#include "Renderer.h"
+#include "Camera.h"
CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
{
@@ -62,12 +66,12 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
field_1356 = 0;
m_attackTimer = 0;
m_bBeatingSuspect = false;
- m_bZoneDisabledButClose = false;
+ m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
field_1364 = -1;
m_pPointGunAt = nil;
- // VC also initializes in here, but it keeps object
+ // VC also initializes in here, but as nil
#ifdef FIX_BUGS
m_wRoadblockNode = -1;
#endif
@@ -171,7 +175,7 @@ CCopPed::ClearPursuit(void)
bIsRunning = false;
bNotAllowedToDuck = false;
bKindaStayInSamePlace = false;
- m_bZoneDisabledButClose = false;
+ m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
ClearObjective();
if (IsPedInControl()) {
@@ -213,7 +217,7 @@ CCopPed::SetPursuit(bool ignoreCopLimit)
SetObjectiveTimer(0);
bNotAllowedToDuck = true;
bIsRunning = true;
- m_bZoneDisabledButClose = false;
+ m_bStopAndShootDisabledZone = false;
}
}
}
@@ -315,13 +319,15 @@ CCopPed::CopAI(void)
m_prevObjective = OBJECTIVE_NONE;
m_nLastPedState = PED_NONE;
SetAttackTimer(0);
+
+ // Safe distance for disabled zone? Or to just make game easier?
if (m_fDistanceToTarget > 15.0f)
- m_bZoneDisabledButClose = true;
+ m_bStopAndShootDisabledZone = true;
}
} else if (m_bZoneDisabled && !CCullZones::NoPolice()) {
m_bZoneDisabled = false;
m_bIsDisabledCop = false;
- m_bZoneDisabledButClose = false;
+ m_bStopAndShootDisabledZone = false;
bKindaStayInSamePlace = false;
bCrouchWhenShooting = false;
bDuckAndCover = false;
@@ -524,7 +530,7 @@ CCopPed::CopAI(void)
if (!anotherCopChasesHim) {
SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, nearPed);
nearPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, this);
- nearPed->m_ped_flagE2 = true;
+ nearPed->bBeingChasedByPolice = true;
return;
}
}
@@ -551,6 +557,186 @@ CCopPed::CopAI(void)
}
}
+void
+CCopPed::ProcessControl(void)
+{
+ if (m_nZoneLevel > LEVEL_NONE && m_nZoneLevel != CCollision::ms_collisionInMemory)
+ return;
+
+ CPed::ProcessControl();
+ if (bWasPostponed)
+ return;
+
+ if (m_nPedState == PED_DEAD) {
+ ClearPursuit();
+ m_objective = OBJECTIVE_NONE;
+ return;
+ }
+ if (m_nPedState == PED_DIE)
+ return;
+
+ if (m_nPedState == PED_ARREST_PLAYER) {
+ ArrestPlayer();
+ return;
+ }
+ GetWeapon()->Update(m_audioEntityId);
+ if (m_moved.Magnitude() > 0.0f)
+ Avoid();
+
+ CPhysical *playerOrHisVeh = FindPlayerVehicle() ? (CPhysical*)FindPlayerVehicle() : (CPhysical*)FindPlayerPed();
+ CPlayerPed *player = FindPlayerPed();
+
+ m_fDistanceToTarget = (playerOrHisVeh->GetPosition() - GetPosition()).Magnitude();
+ if (player->m_nPedState == PED_ARRESTED || player->DyingOrDead()) {
+ if (m_fDistanceToTarget < 5.0f) {
+ SetArrestPlayer(player);
+ return;
+ }
+ if (IsPedInControl())
+ SetIdle();
+ }
+ if (m_bIsInPursuit) {
+ if (player->m_nPedState != PED_ARRESTED && !player->DyingOrDead()) {
+ switch (m_nCopType) {
+ case COP_FBI:
+ Say(SOUND_PED_PURSUIT_FBI);
+ break;
+ case COP_SWAT:
+ Say(SOUND_PED_PURSUIT_SWAT);
+ break;
+ case COP_ARMY:
+ Say(SOUND_PED_PURSUIT_ARMY);
+ break;
+ default:
+ Say(SOUND_PED_PURSUIT_COP);
+ break;
+ }
+ }
+ }
+
+ if (IsPedInControl()) {
+ CopAI();
+ /* switch (m_nCopType)
+ {
+ case COP_FBI:
+ CopAI();
+ break;
+ case COP_SWAT:
+ CopAI();
+ break;
+ case COP_ARMY:
+ CopAI();
+ break;
+ default:
+ CopAI();
+ break;
+ } */
+ } else if (InVehicle()) {
+ if (m_pMyVehicle->pDriver == this && m_pMyVehicle->AutoPilot.m_nCarMission == MISSION_NONE &&
+ CanPedDriveOff() && m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE) {
+
+ CCarCtrl::JoinCarWithRoadSystem(m_pMyVehicle);
+ m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
+ m_pMyVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
+ m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 17;
+ }
+ }
+ if (IsPedInControl() || m_nPedState == PED_DRIVING)
+ ScanForCrimes();
+
+ // They may have used goto to jump here in case of PED_ATTACK.
+ if (m_nPedState == PED_IDLE || m_nPedState == PED_ATTACK) {
+ if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT &&
+ player && player->EnteringCar() && m_fDistanceToTarget < 1.3f) {
+ SetArrestPlayer(player);
+ }
+ } else {
+ if (m_nPedState == PED_SEEK_POS) {
+ if (player->m_nPedState == PED_ARRESTED) {
+ SetIdle();
+ SetLookFlag(player, false);
+ SetLookTimer(1000);
+ RestorePreviousObjective();
+ } else {
+ if (player->m_pMyVehicle && player->m_pMyVehicle->m_nNumGettingIn != 0) {
+ // This is 1.3f when arresting in car without seeking first (in above)
+#if defined(VC_PED_PORTS) || defined(FIX_BUGS)
+ m_distanceToCountSeekDone = 1.3f;
+#else
+ m_distanceToCountSeekDone = 2.0f;
+#endif
+ }
+
+ if (bDuckAndCover) {
+ if (!bNotAllowedToDuck && Seek()) {
+ SetMoveState(PEDMOVE_STILL);
+ SetMoveAnim();
+ SetPointGunAt(m_pedInObjective);
+ }
+ } else if (Seek()) {
+ CVehicle *playerVeh = FindPlayerVehicle();
+ if (!playerVeh && player && player->EnteringCar()) {
+ SetArrestPlayer(player);
+ } else if (1.5f + GetPosition().z <= m_vecSeekPos.z || GetPosition().z - 0.3f >= m_vecSeekPos.z) {
+ SetMoveState(PEDMOVE_STILL);
+ } else if (playerVeh && playerVeh->CanPedEnterCar() && playerVeh->m_nNumGettingIn == 0) {
+ SetCarJack(playerVeh);
+ }
+ }
+ }
+ } else if (m_nPedState == PED_SEEK_ENTITY) {
+ if (!m_pSeekTarget) {
+ RestorePreviousState();
+ } else {
+ m_vecSeekPos = m_pSeekTarget->GetPosition();
+ if (Seek()) {
+ if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT && m_fDistanceToTarget < 2.5f && player) {
+ if (player->m_nPedState == PED_ARRESTED || player->m_nPedState == PED_ENTER_CAR ||
+ (player->m_nPedState == PED_CARJACK && m_fDistanceToTarget < 1.3f)) {
+ SetArrestPlayer(player);
+ } else
+ RestorePreviousState();
+ } else {
+ RestorePreviousState();
+ }
+
+ }
+ }
+ }
+ }
+ if (!m_bStopAndShootDisabledZone)
+ return;
+
+ bool dontShoot = false;
+ if (GetIsOnScreen() && CRenderer::IsEntityCullZoneVisible(this)) {
+ if (((CTimer::GetFrameCounter() + m_randomSeed) & 0x1F) == 17) {
+ CEntity *foundBuilding = nil;
+ CColPoint foundCol;
+ CVector lookPos = GetPosition() + CVector(0.0f, 0.0f, 0.7f);
+ CVector camPos = TheCamera.GetGameCamPosition();
+ CWorld::ProcessLineOfSight(camPos, lookPos, foundCol, foundBuilding,
+ true, false, false, false, false, false, false);
+
+ // He's at least 15.0 far, in disabled zone, collided into somewhere (that's why m_bStopAndShootDisabledZone set),
+ // and now has building on front of him. He's stupid, we don't need him.
+ if (foundBuilding) {
+ FlagToDestroyWhenNextProcessed();
+ dontShoot = true;
+ }
+ }
+ } else {
+ FlagToDestroyWhenNextProcessed();
+ dontShoot = true;
+ }
+
+ if (!dontShoot) {
+ bStopAndShoot = true;
+ bKindaStayInSamePlace = true;
+ bIsPointingGunAt = true;
+ SetAttack(m_pedInObjective);
+ }
+}
+
#include <new>
class CCopPed_ : public CCopPed
@@ -558,11 +744,13 @@ 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);
diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h
index 142be56a..625cae49 100644
--- a/src/peds/CopPed.h
+++ b/src/peds/CopPed.h
@@ -17,10 +17,10 @@ public:
int8 field_1343;
float m_fDistanceToTarget;
int8 m_bIsInPursuit;
- int8 m_bIsDisabledCop; // What disabled cop actually is?
+ int8 m_bIsDisabledCop;
int8 field_1350;
bool m_bBeatingSuspect;
- int8 m_bZoneDisabledButClose;
+ int8 m_bStopAndShootDisabledZone;
int8 m_bZoneDisabled;
int8 field_1354;
int8 field_1355;
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index 0d27a532..3a5067e7 100644
--- a/src/peds/EmergencyPed.cpp
+++ b/src/peds/EmergencyPed.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "EmergencyPed.h"
+#include "DMAudio.h"
#include "ModelIndices.h"
#include "Vehicle.h"
#include "Fire.h"
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 05cac3a7..8b83d976 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -7,13 +7,21 @@
#include "World.h"
#include "RpAnimBlend.h"
#include "Ped.h"
+#include "Wanted.h"
#include "PlayerPed.h"
+#include "PedType.h"
+#include "AnimBlendClumpData.h"
+#include "AnimBlendAssociation.h"
+#include "Fire.h"
+#include "DMAudio.h"
#include "General.h"
#include "SurfaceTable.h"
#include "VisibilityPlugins.h"
#include "AudioManager.h"
#include "HandlingMgr.h"
#include "Replay.h"
+#include "Camera.h"
+#include "Radar.h"
#include "PedPlacement.h"
#include "Shadows.h"
#include "Weather.h"
@@ -552,7 +560,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
bScriptObjectiveCompleted = false;
bKindaStayInSamePlace = false;
- m_ped_flagE2 = false;
+ bBeingChasedByPolice = false;
bNotAllowedToDuck = false;
bCrouchWhenShooting = false;
bIsDucking = false;
@@ -9597,7 +9605,7 @@ CPed::ProcessControl(void)
float neededTurnToCriminal = angleToLookCriminal - angleToFace;
if (neededTurnToCriminal > DEGTORAD(150.0f) && neededTurnToCriminal < DEGTORAD(210.0f)) {
- ((CCopPed*)this)->m_bZoneDisabledButClose = true;
+ ((CCopPed*)this)->m_bStopAndShootDisabledZone = true;
}
}
}
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index a19dc9f0..2edd5d68 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -3,14 +3,9 @@
#include "Physical.h"
#include "Weapon.h"
#include "PedStats.h"
-#include "PedType.h"
#include "PedIK.h"
#include "AnimManager.h"
-#include "AnimBlendClumpData.h"
-#include "AnimBlendAssociation.h"
#include "WeaponInfo.h"
-#include "Fire.h"
-#include "DMAudio.h"
#include "EventList.h"
#define FEET_OFFSET 1.04f
@@ -19,6 +14,10 @@
struct CPathNode;
class CAccident;
class CObject;
+class CFire;
+struct AnimBlendFrameData;
+class CAnimBlendAssociation;
+enum eCrimeType;
struct PedAudioData
{
@@ -339,7 +338,7 @@ public:
uint8 bScriptObjectiveCompleted : 1;
uint8 bKindaStayInSamePlace : 1;
- uint8 m_ped_flagE2 : 1; // bBeingChasedByPolice?
+ uint8 bBeingChasedByPolice : 1; // Unused VC leftover. Should've been set for criminal/gang members
uint8 bNotAllowedToDuck : 1;
uint8 bCrouchWhenShooting : 1;
uint8 bIsDucking : 1;
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index 38ab429e..cc4b0dd0 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -80,7 +80,7 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c
}
void
-CPedIK::GetComponentPosition(RwV3d *pos, PedNode node)
+CPedIK::GetComponentPosition(RwV3d *pos, uint32 node)
{
RwFrame *f;
RwMatrix *mat;
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index dc3f8dda..df9017f3 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -1,6 +1,5 @@
#pragma once
#include "common.h"
-#include "PedModelInfo.h"
#include "AnimBlendClumpData.h"
struct LimbOrientation
@@ -52,7 +51,7 @@ public:
bool PointGunInDirection(float phi, float theta);
bool PointGunInDirectionUsingArm(float phi, float theta);
bool PointGunAtPosition(CVector const& position);
- void GetComponentPosition(RwV3d *pos, PedNode node);
+ void GetComponentPosition(RwV3d *pos, uint32 node);
static RwMatrix *GetWorldMatrix(RwFrame *source, RwMatrix *destination);
void RotateTorso(AnimBlendFrameData* animBlend, LimbOrientation* limb, bool changeRoll);
void ExtractYawAndPitchLocal(RwMatrixTag *mat, float *yaw, float *pitch);
diff --git a/src/peds/PedPlacement.cpp b/src/peds/PedPlacement.cpp
index b22e1d58..e5f6a077 100644
--- a/src/peds/PedPlacement.cpp
+++ b/src/peds/PedPlacement.cpp
@@ -1,5 +1,6 @@
#include "common.h"
#include "patcher.h"
+#include "Ped.h"
#include "PedPlacement.h"
#include "World.h"
diff --git a/src/peds/PedPlacement.h b/src/peds/PedPlacement.h
index b1b5be93..6ba4ae71 100644
--- a/src/peds/PedPlacement.h
+++ b/src/peds/PedPlacement.h
@@ -1,7 +1,5 @@
#pragma once
-#include "Ped.h"
-
class CPedPlacement {
public:
static void FindZCoorForPed(CVector* pos);
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 49d0183e..5275f716 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -1,11 +1,16 @@
#include "common.h"
#include "patcher.h"
#include "PlayerPed.h"
+#include "Wanted.h"
+#include "Fire.h"
+#include "DMAudio.h"
+#include "Pad.h"
#include "Camera.h"
#include "WeaponEffects.h"
#include "ModelIndices.h"
#include "World.h"
#include "RpAnimBlend.h"
+#include "AnimBlendAssociation.h"
#include "General.h"
#include "Pools.h"
#include "Darkel.h"
diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h
index b27cd983..c139bbbc 100644
--- a/src/peds/PlayerPed.h
+++ b/src/peds/PlayerPed.h
@@ -1,8 +1,10 @@
#pragma once
#include "Ped.h"
-#include "Wanted.h"
-#include "Pad.h"
+
+class CPad;
+class CCopPed;
+class CWanted;
class CPlayerPed : public CPed
{
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index 6b674dd3..3bf81066 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -4,6 +4,8 @@
#include "General.h"
#include "World.h"
#include "Population.h"
+#include "CopPed.h"
+#include "Wanted.h"
#include "FileMgr.h"
#include "Gangs.h"
#include "ModelIndices.h"
@@ -11,6 +13,7 @@
#include "CivilianPed.h"
#include "EmergencyPed.h"
#include "Replay.h"
+#include "Camera.h"
#include "CutsceneMgr.h"
#include "CarCtrl.h"
#include "IniFile.h"
@@ -110,7 +113,8 @@ CPopulation::ChooseCivilianOccupation(int32 group)
return ms_pPedGroups[group].models[CGeneral::GetRandomNumberInRange(0, NUMMODELSPERPEDGROUP)];
}
-eCopType
+// returns eCopType
+int32
CPopulation::ChoosePolicePedOccupation()
{
CGeneral::GetRandomNumber();
@@ -512,9 +516,9 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors)
uint32 weapon;
if (CGeneral::GetRandomNumberInRange(0, 100) >= 50)
- weapon = ped->GiveWeapon(CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon2, 25001);
+ weapon = ped->GiveWeapon((eWeaponType)CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon2, 25001);
else
- weapon = ped->GiveWeapon(CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon1, 25001);
+ weapon = ped->GiveWeapon((eWeaponType)CGangs::GetGangInfo(pedType - PEDTYPE_GANG1)->m_Weapon1, 25001);
ped->SetCurrentWeapon(weapon);
return ped;
}
diff --git a/src/peds/Population.h b/src/peds/Population.h
index b299c0a1..f9e6c3b7 100644
--- a/src/peds/Population.h
+++ b/src/peds/Population.h
@@ -2,11 +2,11 @@
#include "Game.h"
#include "PedType.h"
-#include "CopPed.h"
class CPed;
class CVehicle;
class CDummyObject;
+class CObject;
struct PedGroup
{
@@ -71,7 +71,7 @@ public:
static bool IsPointInSafeZone(CVector *coors);
static void RemovePed(CPed *ent);
static int32 ChooseCivilianOccupation(int32);
- static eCopType ChoosePolicePedOccupation();
+ static int32 ChoosePolicePedOccupation();
static int32 ChooseGangOccupation(int);
static void FindCollisionZoneForCoors(CVector*, int*, eLevelName*);
static void FindClosestZoneForCoors(CVector*, int*, eLevelName, eLevelName);