summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
Diffstat (limited to 'src/peds')
-rw-r--r--src/peds/CivilianPed.cpp4
-rw-r--r--src/peds/CopPed.cpp485
-rw-r--r--src/peds/CopPed.h5
-rw-r--r--src/peds/EmergencyPed.cpp3
-rw-r--r--src/peds/Ped.cpp60
-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.cpp92
-rw-r--r--src/peds/PlayerPed.h6
-rw-r--r--src/peds/Population.cpp12
-rw-r--r--src/peds/Population.h4
14 files changed, 639 insertions, 51 deletions
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index bb61e086..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"
@@ -377,6 +379,8 @@ CCivilianPed::ProcessControl(void)
Avoid();
}
+#include <new>
+
class CCivilianPed_ : public CCivilianPed
{
public:
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index 53ae1747..b5812136 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -3,12 +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"
-
-WRAPPER void CCopPed::ProcessControl() { EAXJMP(0x4C1400); }
+#include "ZoneCull.h"
+#include "PathFind.h"
+#include "RoadBlocks.h"
+#include "CarCtrl.h"
+#include "Renderer.h"
+#include "Camera.h"
CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
{
@@ -58,11 +65,16 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
m_bIsDisabledCop = false;
field_1356 = 0;
m_attackTimer = 0;
- field_1351 = 0;
- m_bZoneDisabledButClose = false;
+ m_bBeatingSuspect = false;
+ m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
field_1364 = -1;
m_pPointGunAt = nil;
+
+ // VC also initializes in here, but as nil
+#ifdef FIX_BUGS
+ m_wRoadblockNode = -1;
+#endif
}
CCopPed::~CCopPed()
@@ -163,7 +175,7 @@ CCopPed::ClearPursuit(void)
bIsRunning = false;
bNotAllowedToDuck = false;
bKindaStayInSamePlace = false;
- m_bZoneDisabledButClose = false;
+ m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
ClearObjective();
if (IsPedInControl()) {
@@ -181,15 +193,15 @@ CCopPed::ClearPursuit(void)
}
}
-// TO-DO: m_MaxCops in for loop may be a bug, check it out after CopAI
+// TODO: I don't know why they needed that parameter.
void
-CCopPed::SetPursuit(bool iMayAlreadyBeInPursuit)
+CCopPed::SetPursuit(bool ignoreCopLimit)
{
CWanted *wanted = FindPlayerPed()->m_pWanted;
if (m_bIsInPursuit || !IsPedInControl())
return;
- if (wanted->m_CurrentCops < wanted->m_MaxCops || iMayAlreadyBeInPursuit) {
+ if (wanted->m_CurrentCops < wanted->m_MaxCops || ignoreCopLimit) {
for (int i = 0; i < wanted->m_MaxCops; ++i) {
if (!wanted->m_pCops[i]) {
m_bIsInPursuit = true;
@@ -205,7 +217,7 @@ CCopPed::SetPursuit(bool iMayAlreadyBeInPursuit)
SetObjectiveTimer(0);
bNotAllowedToDuck = true;
bIsRunning = true;
- m_bZoneDisabledButClose = false;
+ m_bStopAndShootDisabledZone = false;
}
}
}
@@ -275,19 +287,474 @@ CCopPed::ScanForCrimes(void)
}
}
+void
+CCopPed::CopAI(void)
+{
+ CWanted *wanted = FindPlayerPed()->m_pWanted;
+ int wantedLevel = wanted->m_nWantedLevel;
+ CPhysical *playerOrHisVeh = FindPlayerVehicle() ? (CPhysical*)FindPlayerVehicle() : (CPhysical*)FindPlayerPed();
+
+ if (wanted->m_bIgnoredByEveryone || wanted->m_bIgnoredByCops) {
+ if (m_nPedState != PED_ARREST_PLAYER)
+ ClearPursuit();
+
+ return;
+ }
+ if (CCullZones::NoPolice() && m_bIsInPursuit && !m_bIsDisabledCop) {
+ if (bHitSomethingLastFrame) {
+ m_bZoneDisabled = true;
+ m_bIsDisabledCop = true;
+#ifdef FIX_BUGS
+ m_wRoadblockNode = -1;
+#else
+ m_wRoadblockNode = 0;
+#endif
+ bKindaStayInSamePlace = true;
+ bIsRunning = false;
+ bNotAllowedToDuck = false;
+ bCrouchWhenShooting = false;
+ SetIdle();
+ ClearObjective();
+ ClearPursuit();
+ 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_bStopAndShootDisabledZone = true;
+ }
+ } else if (m_bZoneDisabled && !CCullZones::NoPolice()) {
+ m_bZoneDisabled = false;
+ m_bIsDisabledCop = false;
+ m_bStopAndShootDisabledZone = false;
+ bKindaStayInSamePlace = false;
+ bCrouchWhenShooting = false;
+ bDuckAndCover = false;
+ ClearPursuit();
+ }
+ if (wantedLevel > 0) {
+ if (!m_bIsDisabledCop) {
+ if (!m_bIsInPursuit || wanted->m_CurrentCops > wanted->m_MaxCops) {
+ CCopPed *copFarthestToTarget = nil;
+ float copFarthestToTargetDist = m_fDistanceToTarget;
+
+ int oldCopNum = wanted->m_CurrentCops;
+ int maxCops = wanted->m_MaxCops;
+
+ 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;
+ copFarthestToTarget = wanted->m_pCops[i];
+ }
+ }
+
+ if (m_bIsInPursuit) {
+ if (copFarthestToTarget && oldCopNum > maxCops) {
+ if (copFarthestToTarget == this && m_fDistanceToTarget > 10.0f) {
+ ClearPursuit();
+ } else if(copFarthestToTargetDist > 10.0f)
+ copFarthestToTarget->ClearPursuit();
+ }
+ } else {
+ if (oldCopNum < maxCops) {
+ SetPursuit(true);
+ } else {
+ if (m_fDistanceToTarget <= 10.0f || copFarthestToTarget && m_fDistanceToTarget < copFarthestToTargetDist) {
+ if (copFarthestToTarget && copFarthestToTargetDist > 10.0f)
+ copFarthestToTarget->ClearPursuit();
+
+ SetPursuit(true);
+ }
+ }
+ }
+ } else
+ SetPursuit(false);
+
+ if (!m_bIsInPursuit)
+ return;
+
+ if (wantedLevel > 1 && GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED)
+ SetCurrentWeapon(WEAPONTYPE_COLT45);
+ else if (wantedLevel == 1 && GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED && !FindPlayerPed()->m_pCurrentPhysSurface) {
+ // i.e. if player is on top of car, cop will still use colt45.
+ SetCurrentWeapon(WEAPONTYPE_UNARMED);
+ }
+
+ if (FindPlayerVehicle()) {
+ if (m_bBeatingSuspect) {
+ --wanted->m_CopsBeatingSuspect;
+ m_bBeatingSuspect = false;
+ }
+ if (m_fDistanceToTarget * FindPlayerSpeed().Magnitude() > 4.0f)
+ ClearPursuit();
+ }
+ return;
+ }
+ float weaponRange = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_fRange;
+ SetLookFlag(playerOrHisVeh, true);
+ TurnBody();
+ SetCurrentWeapon(WEAPONTYPE_COLT45);
+ if (!bIsDucking) {
+ if (m_attackTimer >= CTimer::GetTimeInMilliseconds()) {
+ if (m_nPedState != PED_ATTACK && m_nPedState != PED_FIGHT && !m_bZoneDisabled) {
+ CVector targetDist = playerOrHisVeh->GetPosition() - GetPosition();
+ if (m_fDistanceToTarget > 30.0f) {
+ CAnimBlendAssociation* crouchShootAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_RBLOCK_CSHOOT);
+ if (crouchShootAssoc)
+ crouchShootAssoc->blendDelta = -1000.0f;
+
+ // Target is coming onto us
+ if (DotProduct(playerOrHisVeh->m_vecMoveSpeed, targetDist) > 0.0f) {
+ m_bIsDisabledCop = false;
+ bKindaStayInSamePlace = false;
+ bNotAllowedToDuck = false;
+ bDuckAndCover = false;
+ SetPursuit(false);
+ SetObjective(OBJECTIVE_KILL_CHAR_ANY_MEANS, FindPlayerPed());
+ }
+ } else if (m_fDistanceToTarget < 5.0f
+ && (!FindPlayerVehicle() || FindPlayerVehicle()->m_vecMoveSpeed.MagnitudeSqr() < sq(1.f/200.f))) {
+ m_bIsDisabledCop = false;
+ bKindaStayInSamePlace = false;
+ bNotAllowedToDuck = false;
+ bDuckAndCover = false;
+ } else {
+ // VC checks for != nil compared to buggy behaviour of III. I check for != -1 here.
+#ifdef VC_PED_PORTS
+ float dotProd;
+ if (m_wRoadblockNode != -1) {
+ CTreadable *roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_wRoadblockNode]];
+ dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), GetPosition() - roadBlockRoad->GetPosition());
+ } else
+ dotProd = -1.0f;
+
+ if(dotProd >= 0.0f) {
+#else
+
+#ifndef FIX_BUGS
+ float copRoadDotProd, targetRoadDotProd;
+#else
+ float copRoadDotProd = 1.0f, targetRoadDotProd = 1.0f;
+ if (m_wRoadblockNode != -1)
+#endif
+ {
+ CTreadable* roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_wRoadblockNode]];
+ CVector2D roadFwd = roadBlockRoad->GetForward();
+ copRoadDotProd = DotProduct2D(GetPosition() - roadBlockRoad->GetPosition(), roadFwd);
+ targetRoadDotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), roadFwd);
+ }
+ // Roadblock may be towards road's fwd or opposite, so check both
+ if ((copRoadDotProd >= 0.0f || targetRoadDotProd >= 0.0f)
+ && (copRoadDotProd <= 0.0f || targetRoadDotProd <= 0.0f)) {
+#endif
+ bIsPointingGunAt = true;
+ } else {
+ m_bIsDisabledCop = false;
+ bKindaStayInSamePlace = false;
+ bNotAllowedToDuck = false;
+ bCrouchWhenShooting = false;
+ bIsDucking = false;
+ bDuckAndCover = false;
+ SetPursuit(false);
+ }
+ }
+ }
+ } else {
+ 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));
+
+ CColPoint foundCol;
+ CEntity *foundEnt;
+ if (!CWorld::ProcessLineOfSight(gunPos, playerOrHisVeh->GetPosition(), foundCol, foundEnt,
+ false, true, false, false, true, false, false)
+ || foundEnt && foundEnt == playerOrHisVeh) {
+ m_pPointGunAt = playerOrHisVeh;
+ if (playerOrHisVeh)
+ playerOrHisVeh->RegisterReference((CEntity**) &m_pPointGunAt);
+
+ SetAttack(playerOrHisVeh);
+ SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000));
+ }
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(100, 300));
+ }
+ SetMoveState(PEDMOVE_STILL);
+ }
+ }
+ } else {
+ if (!m_bIsDisabledCop || m_bZoneDisabled) {
+ if (m_nPedState != PED_AIM_GUN) {
+ if (m_bIsInPursuit)
+ ClearPursuit();
+
+ if (IsPedInControl()) {
+ // Entering the vehicle
+ if (m_pMyVehicle && !bInVehicle) {
+ if (m_pMyVehicle->IsLawEnforcementVehicle()) {
+ if (m_pMyVehicle->pDriver) {
+ if (m_pMyVehicle->pDriver->m_nPedType == PEDTYPE_COP) {
+ if (m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER)
+ SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, m_pMyVehicle);
+ } else if (m_pMyVehicle->pDriver->IsPlayer()) {
+ FindPlayerPed()->SetWantedLevelNoDrop(1);
+ }
+ } else if (m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER) {
+ SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, m_pMyVehicle);
+ }
+ } else {
+ m_pMyVehicle = nil;
+ ClearObjective();
+ SetWanderPath(CGeneral::GetRandomNumber() & 7);
+ }
+ }
+#ifdef VC_PED_PORTS
+ else {
+ if (m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT && CharCreatedBy == RANDOM_CHAR) {
+ for (int i = 0; i < m_numNearPeds; i++) {
+ CPed *nearPed = m_nearPeds[i];
+ if (nearPed->CharCreatedBy == RANDOM_CHAR) {
+ if ((nearPed->m_nPedType == PEDTYPE_CRIMINAL || nearPed->IsGangMember())
+ && nearPed->IsPedInControl()) {
+
+ bool anotherCopChasesHim = false;
+ if (nearPed->m_nPedState == PED_FLEE_ENTITY) {
+ if (nearPed->m_fleeFrom && nearPed->m_fleeFrom->IsPed() &&
+ ((CPed*)nearPed->m_fleeFrom)->m_nPedType == PEDTYPE_COP) {
+ anotherCopChasesHim = true;
+ }
+ }
+ if (!anotherCopChasesHim) {
+ SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, nearPed);
+ nearPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, this);
+ nearPed->bBeingChasedByPolice = true;
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+ }
+ }
+ } else {
+ if (m_bIsInPursuit && m_nPedState != PED_AIM_GUN)
+ ClearPursuit();
+
+ m_bIsDisabledCop = false;
+ bKindaStayInSamePlace = false;
+ bNotAllowedToDuck = false;
+ bCrouchWhenShooting = false;
+ bIsDucking = false;
+ bDuckAndCover = false;
+ if (m_pMyVehicle)
+ SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, m_pMyVehicle);
+ }
+ }
+}
+
+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
{
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 7705eb12..625cae49 100644
--- a/src/peds/CopPed.h
+++ b/src/peds/CopPed.h
@@ -19,8 +19,8 @@ public:
int8 m_bIsInPursuit;
int8 m_bIsDisabledCop;
int8 field_1350;
- int8 field_1351;
- int8 m_bZoneDisabledButClose;
+ bool m_bBeatingSuspect;
+ int8 m_bStopAndShootDisabledZone;
int8 m_bZoneDisabled;
int8 field_1354;
int8 field_1355;
@@ -40,6 +40,7 @@ public:
void SetPursuit(bool);
void ArrestPlayer(void);
void ScanForCrimes(void);
+ void CopAI(void);
};
static_assert(sizeof(CCopPed) == 0x558, "CCopPed: error");
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index ee559f57..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"
@@ -413,6 +414,8 @@ CEmergencyPed::MedicAI(void)
}
}
+#include <new>
+
class CEmergencyPed_ : public CEmergencyPed
{
public:
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index db6b7ee2..54816b1c 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;
@@ -799,6 +807,10 @@ CPed::IsPedInControl(void)
bool
CPed::CanStrafeOrMouseControl(void)
{
+#ifdef FREE_CAM
+ if (CCamera::bFreeCam)
+ return false;
+#endif
return m_nPedState == PED_NONE || m_nPedState == PED_IDLE || m_nPedState == PED_FLEE_POS || m_nPedState == PED_FLEE_ENTITY ||
m_nPedState == PED_ATTACK || m_nPedState == PED_FIGHT || m_nPedState == PED_AIM_GUN || m_nPedState == PED_JUMP;
}
@@ -2720,6 +2732,10 @@ CPed::SetObjective(eObjective newObj, void *entity)
return;
}
+#ifdef VC_PED_PORTS
+ SetObjectiveTimer(0);
+ ClearPointGunAt();
+#endif
bObjectiveCompleted = false;
if (!IsTemporaryObjective(m_objective) || IsTemporaryObjective(newObj)) {
if (m_objective != newObj) {
@@ -3444,8 +3460,12 @@ CPed::ClearAll(void)
m_fleeFrom = nil;
m_fleeTimer = 0;
bUsesCollision = true;
+#ifdef VC_PED_PORTS
+ ClearPointGunAt();
+#else
ClearAimFlag();
ClearLookFlag();
+#endif
bIsPointingGunAt = false;
bRenderPedInCar = true;
bKnockedUpIntoAir = false;
@@ -3603,11 +3623,11 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
if (DyingOrDead())
return false;
- if (!bUsesCollision && method != WEAPONTYPE_WATER)
+ if (!bUsesCollision && method != WEAPONTYPE_DROWNING)
return false;
if (bOnlyDamagedByPlayer && damagedBy != player && damagedBy != FindPlayerVehicle() &&
- method != WEAPONTYPE_WATER && method != WEAPONTYPE_EXPLOSION)
+ method != WEAPONTYPE_DROWNING && method != WEAPONTYPE_EXPLOSION)
return false;
float healthImpact;
@@ -3953,10 +3973,10 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
}
break;
- case WEAPONTYPE_WATER:
+ case WEAPONTYPE_DROWNING:
dieAnim = ANIM_DROWN;
break;
- case WEAPONTYPE_FALL_DAMAGE:
+ case WEAPONTYPE_FALL:
if (bCollisionProof)
return false;
@@ -3982,7 +4002,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
}
- if (m_fArmour != 0.0f && method != WEAPONTYPE_WATER) {
+ if (m_fArmour != 0.0f && method != WEAPONTYPE_DROWNING) {
if (player == this)
CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss = CTimer::GetTimeInMilliseconds();
@@ -4008,7 +4028,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
}
if (bInVehicle) {
- if (method != WEAPONTYPE_WATER) {
+ if (method != WEAPONTYPE_DROWNING) {
#ifdef VC_PED_PORTS
if (m_pMyVehicle) {
if (m_pMyVehicle->IsCar() && m_pMyVehicle->pDriver == this) {
@@ -4075,7 +4095,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
} else {
CDarkel::RegisterKillNotByPlayer(this, method);
}
- if (method == WEAPONTYPE_WATER)
+ if (method == WEAPONTYPE_DROWNING)
bIsInTheAir = false;
return true;
@@ -6968,7 +6988,11 @@ CPed::FinishLaunchCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif
) {
+#ifdef FREE_CAM
+ if (TheCamera.Cams[0].Using3rdPersonMouseCam() && !CCamera::bFreeCam) {
+#else
if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
+#endif
float fpsAngle = ped->WorkOutHeadingForMovingFirstPerson(ped->m_fRotationCur);
ped->m_vecMoveSpeed.x = -velocityFromAnim * Sin(fpsAngle);
ped->m_vecMoveSpeed.y = velocityFromAnim * Cos(fpsAngle);
@@ -9589,7 +9613,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;
}
}
}
@@ -12169,11 +12193,11 @@ CPed::PlacePedOnDryLand(void)
if (!CWorld::TestSphereAgainstWorld(potentialGround, 5.0f, nil, true, false, false, false, false, false))
return false;
- CVector potentialGroundDist = CWorld::ms_testSpherePoint.point - GetPosition();
+ CVector potentialGroundDist = gaTempSphereColPoints[0].point - GetPosition();
potentialGroundDist.z = 0.0f;
potentialGroundDist.Normalise();
- CVector posToCheck = 0.5f * potentialGroundDist + CWorld::ms_testSpherePoint.point;
+ 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)) {
@@ -14559,7 +14583,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
|| m_pCollidingEntity == collidingEnt) {
if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) {
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, 15.0f, PEDPIECE_TORSO, 2);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2);
}
} else {
float damage = 100.0f * max(speed - 0.25f, 0.0f);
@@ -14572,7 +14596,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CVector2D offset = -m_vecMoveSpeed;
dir = GetLocalDirection(offset);
}
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, damage, PEDPIECE_TORSO, dir);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, damage, PEDPIECE_TORSO, dir);
if (IsPlayer() && damage2 > 5.0f)
Say(SOUND_PED_LAND);
}
@@ -14583,7 +14607,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
if (m_vecMoveSpeed.z >= -0.25f && (speedSqr = m_vecMoveSpeed.MagnitudeSqr()) <= sq(0.5f)) {
if (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_FALL) && -0.016f * CTimer::GetTimeStep() > m_vecMoveSpeed.z) {
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, 15.0f, PEDPIECE_TORSO, 2);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, 15.0f, PEDPIECE_TORSO, 2);
}
} else {
if (speedSqr == 0.0f)
@@ -14594,7 +14618,7 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
CVector2D offset = -m_vecMoveSpeed;
dir = GetLocalDirection(offset);
}
- InflictDamage(collidingEnt, WEAPONTYPE_FALL_DAMAGE, 350.0f * sq(speedSqr), PEDPIECE_TORSO, dir);
+ InflictDamage(collidingEnt, WEAPONTYPE_FALL, 350.0f * sq(speedSqr), PEDPIECE_TORSO, dir);
}
}
#endif
@@ -15020,7 +15044,7 @@ CPed::ProcessBuoyancy(void)
CVector pos = GetPosition();
if (PlacePedOnDryLand()) {
if (m_fHealth > 20.0f)
- InflictDamage(nil, WEAPONTYPE_WATER, 15.0f, PEDPIECE_TORSO, false);
+ InflictDamage(nil, WEAPONTYPE_DROWNING, 15.0f, PEDPIECE_TORSO, false);
if (bIsInTheAir) {
RpAnimBlendClumpSetBlendDeltas(GetClump(), ASSOC_PARTIAL, -1000.0f);
@@ -15042,7 +15066,7 @@ CPed::ProcessBuoyancy(void)
m_vecMoveSpeed.y *= speedMult;
m_vecMoveSpeed.z *= speedMult;
bIsStanding = false;
- InflictDamage(nil, WEAPONTYPE_WATER, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
+ InflictDamage(nil, WEAPONTYPE_DROWNING, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
}
if (buoyancyImpulse.z / m_fMass > 0.002f * CTimer::GetTimeStep()) {
if (speedMult == 0.0f) {
@@ -17447,6 +17471,8 @@ CPed::SetExitBoat(CVehicle *boat)
CWaterLevel::FreeBoatWakeArray();
}
+#include <new>
+
class CPed_ : public CPed
{
public:
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 c6580d32..6dbf7687 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"
@@ -60,7 +65,7 @@ void CPlayerPed::ClearWeaponTarget()
TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrossHair();
}
- ClearPointGunAt();
+ ClearPointGunAt();
}
void
@@ -683,7 +688,14 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
float padMove = CVector2D(leftRight, upDown).Magnitude();
float padMoveInGameUnit = padMove / PAD_MOVE_TO_GAME_WORLD_MOVE;
if (padMoveInGameUnit > 0.0f) {
+#ifdef FREE_CAM
+ if (!CCamera::bFreeCam)
+ m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
+ else
+ m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
+#else
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
+#endif
m_fMoveSpeed = min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
} else {
m_fMoveSpeed = 0.0f;
@@ -976,6 +988,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (padUsed->TargetJustDown()) {
SetStoredState();
m_nPedState = PED_SNIPER_MODE;
+#ifdef FREE_CAM
+ if (CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) {
+ m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
+ SetHeading(m_fRotationCur);
+ }
+#endif
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER)
TheCamera.SetNewPlayerWeaponMode(CCam::MODE_ROCKETLAUNCHER, 0, 0);
else if (GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE)
@@ -995,7 +1013,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (padUsed->GetWeapon() && m_nMoveState != PEDMOVE_SPRINT) {
if (m_nSelectedWepSlot == m_currentWeapon) {
if (m_pPointGunAt) {
- SetAttack(m_pPointGunAt);
+#ifdef FREE_CAM
+ if (CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE && m_fMoveSpeed < 1.0f)
+ StartFightAttack(padUsed->GetWeapon());
+ else
+#endif
+ SetAttack(m_pPointGunAt);
} else if (m_currentWeapon != WEAPONTYPE_UNARMED) {
if (m_nPedState == PED_ATTACK) {
if (padUsed->WeaponJustDown()) {
@@ -1022,11 +1045,65 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
bIsAttacking = false;
}
}
+
+#ifdef FREE_CAM
+ // Rotate player/arm when shooting. We don't have auto-rotation anymore
+ if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam &&
+ m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
+
+ // Weapons except throwable and melee ones
+ if (weaponInfo->m_bCanAim || weaponInfo->m_b1stPerson || weaponInfo->m_bExpands) {
+ if ((padUsed->GetTarget() && weaponInfo->m_bCanAimWithArm) || padUsed->GetWeapon()) {
+ float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
+
+ // On this one we can rotate arm.
+ if (weaponInfo->m_bCanAimWithArm) {
+ if (!padUsed->GetWeapon()) { // making this State != ATTACK still stops it after attack. Re-start it immediately!
+ SetPointGunAt(nil);
+ bIsPointingGunAt = false; // to not stop after attack
+ }
+
+ SetLookFlag(limitedCam, true);
+ SetAimFlag(limitedCam);
+#ifdef VC_PED_PORTS
+ SetLookTimer(INT_MAX); // removing this makes head move for real, but I experinced some bugs.
+#endif
+ } else {
+ m_fRotationDest = limitedCam;
+ m_headingRate = 50.0f;
+
+ // Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly)
+ if (weaponInfo->m_bCanAim && padUsed->WeaponJustDown()) {
+ m_fRotationCur = CGeneral::LimitRadianAngle(m_fRotationCur);
+ float limitedRotDest = m_fRotationDest;
+
+ if (m_fRotationCur - PI > m_fRotationDest) {
+ limitedRotDest += 2 * PI;
+ } else if (PI + m_fRotationCur < m_fRotationDest) {
+ limitedRotDest -= 2 * PI;
+ }
+
+ m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
+ }
+ }
+ } else if (weaponInfo->m_bCanAimWithArm)
+ ClearPointGunAt();
+ else
+ RestoreHeadingRate();
+ }
+ }
+#endif
+
if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
if (m_pPointGunAt) {
// what??
if (!m_pPointGunAt
- || CCamera::m_bUseMouse3rdPerson || m_pPointGunAt->IsPed() && ((CPed*)m_pPointGunAt)->bInVehicle) {
+#ifdef FREE_CAM
+ || (!CCamera::bFreeCam && CCamera::m_bUseMouse3rdPerson)
+#else
+ || CCamera::m_bUseMouse3rdPerson
+#endif
+ || m_pPointGunAt->IsPed() && ((CPed*)m_pPointGunAt)->bInVehicle) {
ClearWeaponTarget();
return;
}
@@ -1042,7 +1119,12 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
}
TheCamera.SetNewPlayerWeaponMode(CCam::MODE_SYPHON, 0, 0);
TheCamera.UpdateAimingCoors(m_pPointGunAt->GetPosition());
- } else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) {
+ }
+#ifdef FREE_CAM
+ else if ((CCamera::bFreeCam && weaponInfo->m_eWeaponFire == WEAPON_FIRE_MELEE) || (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson)) {
+#else
+ else if (weaponInfo->m_bCanAim && !CCamera::m_bUseMouse3rdPerson) {
+#endif
if (padUsed->TargetJustDown())
FindWeaponLockOnTarget();
}
@@ -1414,6 +1496,8 @@ CPlayerPed::ProcessControl(void)
}
}
+#include <new>
+
class CPlayerPed_ : public CPlayerPed
{
public:
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 d87764ff..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;
}
@@ -576,7 +580,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);
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);