summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
Diffstat (limited to 'src/peds')
-rw-r--r--src/peds/CivilianPed.cpp13
-rw-r--r--src/peds/CivilianPed.h7
-rw-r--r--src/peds/CopPed.cpp10
-rw-r--r--src/peds/CopPed.h1
-rw-r--r--src/peds/EmergencyPed.cpp10
-rw-r--r--src/peds/EmergencyPed.h2
-rw-r--r--src/peds/Ped.cpp149
-rw-r--r--src/peds/Ped.h72
-rw-r--r--src/peds/PedIK.cpp6
-rw-r--r--src/peds/PlayerPed.cpp39
-rw-r--r--src/peds/PlayerPed.h8
11 files changed, 199 insertions, 118 deletions
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index a4881e71..cf8a0580 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -13,7 +13,14 @@ CCivilianPed::CCivilianPed(int pedtype, int mi) : CPed(pedtype)
}
}
+class CCivilianPed_ : public CCivilianPed
+{
+public:
+ CCivilianPed *ctor(int pedtype, int mi) { return ::new (this) CCivilianPed(pedtype, mi); };
+ void dtor(void) { CCivilianPed::~CCivilianPed(); }
+};
+
STARTPATCHES
- InjectHook(0x4BFF30, &CCivilianPed::ctor, PATCH_JUMP);
- InjectHook(0x4BFFC0, &CCivilianPed::dtor, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
+ InjectHook(0x4BFF30, &CCivilianPed_::ctor, PATCH_JUMP);
+ InjectHook(0x4BFFC0, &CCivilianPed_::dtor, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/peds/CivilianPed.h b/src/peds/CivilianPed.h
index 8d004ad7..14859a5c 100644
--- a/src/peds/CivilianPed.h
+++ b/src/peds/CivilianPed.h
@@ -6,11 +6,8 @@ class CCivilianPed : public CPed
{
public:
CCivilianPed(int, int);
- virtual ~CCivilianPed(void) { }
+ ~CCivilianPed(void) { }
- virtual void ProcessControl(void);
-
- CCivilianPed *ctor(int pedtype, int mi) { return ::new (this) CCivilianPed(pedtype, mi); };
- void dtor(void) { this->CCivilianPed::~CCivilianPed(); }
+ void ProcessControl(void);
};
static_assert(sizeof(CCivilianPed) == 0x53C, "CCivilianPed: error");
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index 041185ee..0ac0473f 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -9,6 +9,12 @@ CCopPed::~CCopPed()
WRAPPER void CCopPed::ClearPursuit(void) { EAXJMP(0x4C28C0); }
+class CCopPed_ : public CCopPed
+{
+public:
+ void dtor(void) { CCopPed::~CCopPed(); }
+};
+
STARTPATCHES
- InjectHook(0x4C13E0, &CCopPed::dtor, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
+ InjectHook(0x4C13E0, &CCopPed_::dtor, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h
index b938dfc2..5827f9bc 100644
--- a/src/peds/CopPed.h
+++ b/src/peds/CopPed.h
@@ -65,7 +65,6 @@ public:
int8 field_1367;
~CCopPed();
- void dtor(void) { this->CCopPed::~CCopPed(); }
void ClearPursuit(void);
};
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index 7b847896..664bd6f6 100644
--- a/src/peds/EmergencyPed.cpp
+++ b/src/peds/EmergencyPed.cpp
@@ -2,6 +2,12 @@
#include "patcher.h"
#include "EmergencyPed.h"
+class CEmergencyPed_ : public CEmergencyPed
+{
+public:
+ void dtor(void) { CEmergencyPed::~CEmergencyPed(); }
+};
+
STARTPATCHES
-InjectHook(0x4C2EF0, &CEmergencyPed::dtor, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
+ InjectHook(0x4C2EF0, &CEmergencyPed_::dtor, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/peds/EmergencyPed.h b/src/peds/EmergencyPed.h
index fa07f3ee..f21996e8 100644
--- a/src/peds/EmergencyPed.h
+++ b/src/peds/EmergencyPed.h
@@ -7,7 +7,5 @@ class CEmergencyPed : public CPed
public:
// 0x53C
uint8 stuff[24];
-
- void dtor(void) { this->CEmergencyPed::~CEmergencyPed(); }
};
static_assert(sizeof(CEmergencyPed) == 0x554, "CEmergencyPed: error");
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 80ef53ee..4ad4ac1b 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -10,6 +10,7 @@
#include "Ped.h"
#include "PlayerPed.h"
#include "General.h"
+#include "SurfaceTable.h"
#include "VisibilityPlugins.h"
#include "AudioManager.h"
#include "HandlingMgr.h"
@@ -23,10 +24,12 @@
#include "Lights.h"
#include "PointLights.h"
#include "Pad.h"
+#include "Phones.h"
WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); }
WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); }
WRAPPER void CPed::SetDie(AnimationId anim, float arg1, float arg2) { EAXJMP(0x4D37D0); }
+WRAPPER void CPed::SetDead(void) { EAXJMP(0x4D3970); }
WRAPPER void CPed::SpawnFlyingComponent(int, int8) { EAXJMP(0x4EB060); }
WRAPPER void CPed::RestorePreviousState(void) { EAXJMP(0x4C5E30); }
WRAPPER void CPed::ClearAttack(void) { EAXJMP(0x4E6790); }
@@ -41,6 +44,8 @@ WRAPPER void CPed::SetMoveAnim(void) { EAXJMP(0x4C5A40); }
WRAPPER void CPed::SetFollowRoute(int16, int16) { EAXJMP(0x4DD690); }
WRAPPER void CPed::SetDuck(uint32) { EAXJMP(0x4E4920); }
WRAPPER void CPed::RegisterThreatWithGangPeds(CEntity*) { EAXJMP(0x4E3870); }
+WRAPPER void CPed::MakeChangesForNewWeapon(int8) { EAXJMP(0x4F2560); }
+WRAPPER bool CPed::Seek(void) { EAXJMP(0x4D1640); }
bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44;
bool &CPed::bPedCheat2 = *(bool*)0x95CD5A;
@@ -62,7 +67,7 @@ CPed::~CPed(void)
CWorld::Remove(this);
CRadar::ClearBlipForEntity(BLIP_CHAR, CPools::GetPedPool()->GetIndex(this));
if (bInVehicle && m_pMyVehicle){
- uint8 door_flag = GetVehEnterExitFlag(m_vehEnterType);
+ uint8 door_flag = GetVehDoorFlag(m_vehEnterType);
if (m_pMyVehicle->pDriver == this)
m_pMyVehicle->pDriver = nil;
else {
@@ -308,7 +313,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_fRotationCur = 0.0f;
m_headingRate = 15.0f;
m_fRotationDest = 0.0f;
- m_vehEnterType = VEHICLE_ENTER_FRONT_LEFT;
+ m_vehEnterType = CAR_DOOR_LF;
m_walkAroundType = 0;
m_pCurrentPhysSurface = nil;
m_vecOffsetFromPhysSurface = CVector(0.0f, 0.0f, 0.0f);
@@ -429,7 +434,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_ped_flagI1 = false;
m_ped_flagI2 = false;
m_ped_flagI4 = false;
- bRecordedForReplay = false;
+ bHasAlreadyBeenRecorded = false;
m_ped_flagI10 = false;
#ifdef KANGAROO_CHEAT
m_ped_flagI80 = false;
@@ -456,9 +461,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
}
m_maxWeaponTypeAllowed = 0;
m_currentWeapon = 0;
- m_storedWeapon = NO_STORED_WEAPON;
+ m_storedWeapon = WEAPONTYPE_UNIDENTIFIED;
- for(int i = 0; i < NUM_PED_WEAPONTYPES; i++)
+ for(int i = 0; i < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; i++)
{
CWeapon &weapon = GetWeapon(i);
weapon.m_eWeaponType = WEAPONTYPE_UNARMED;
@@ -546,7 +551,7 @@ CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround)
angleToFace = CGeneral::LimitRadianAngle(angleToFace);
player->m_fRotationCur = CGeneral::LimitRadianAngle(player->m_fRotationCur);
- angleDiff = fabs(angleToFace - player->m_fRotationCur);
+ angleDiff = Abs(angleToFace - player->m_fRotationCur);
if (angleDiff > PI)
angleDiff = 2 * PI - angleDiff;
@@ -668,7 +673,7 @@ CPed::AimGun(void)
vector.y = pos.y;
vector.z = pos.z;
} else {
- vector = *(m_pSeekTarget->GetPosition());
+ vector = m_pSeekTarget->GetPosition();
}
Say(SOUND_PED_ATTACK);
@@ -867,7 +872,7 @@ CPed::Avoid(void)
// If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else.
// Game converts from radians to degress and back again here, doesn't make much sense
- CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur));
+ CVector2D forward(-Sin(m_fRotationCur), Cos(m_fRotationCur));
forward.Normalise(); // this is kinda pointless
// Move forward 1.25 meters
@@ -1333,7 +1338,7 @@ CPed::BeingDraggedFromCar(void)
if (animAssoc)
animAssoc->blendDelta = -1000.0f;
- if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) {
+ if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
if (m_ped_flagF10) {
enterAnim = ANIM_CAR_QJACKED;
} else if (m_pMyVehicle->bLowVehicle) {
@@ -1341,7 +1346,7 @@ CPed::BeingDraggedFromCar(void)
} else {
enterAnim = ANIM_CAR_JACKED_LHS;
}
- } else if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) {
+ } else if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
if (m_pMyVehicle->bLowVehicle)
enterAnim = ANIM_CAR_LJACKED_RHS;
else
@@ -1388,14 +1393,14 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
if (ped->m_nPedState != PED_ARRESTED) {
ped->m_nLastPedState = PED_NONE;
if (dragAssoc)
- dragAssoc->blendDelta = -1000.0;
+ dragAssoc->blendDelta = -1000.0f;
}
ped->RestartNonPartialAnims();
ped->m_pVehicleAnim = nil;
ped->m_pSeekTarget = nil;
vehicle = ped->m_pMyVehicle;
- vehicle->m_nGettingOutFlags &= ~GetVehEnterExitFlag(ped->m_vehEnterType);
+ vehicle->m_nGettingOutFlags &= ~GetVehDoorFlag(ped->m_vehEnterType);
if (vehicle->pDriver == ped) {
vehicle->RemoveDriver();
@@ -1427,9 +1432,9 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
// Only uzi can be used on cars, so previous weapon was stored
if (ped->IsPlayer() && weaponType == WEAPONTYPE_UZI) {
- if (ped->m_storedWeapon != NO_STORED_WEAPON) {
+ if (ped->m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) {
ped->SetCurrentWeapon(ped->m_storedWeapon);
- ped->m_storedWeapon = NO_STORED_WEAPON;
+ ped->m_storedWeapon = WEAPONTYPE_UNIDENTIFIED;
}
} else {
ped->AddWeaponModel(CWeaponInfo::GetWeaponInfo(weaponType)->m_nModelId);
@@ -1447,7 +1452,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
float seatOffset;
vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(veh->m_modelIndex);
- if (veh->bIsVan && (enterType == VEHICLE_ENTER_REAR_LEFT || enterType == VEHICLE_ENTER_REAR_RIGHT)) {
+ if (veh->bIsVan && (enterType == CAR_DOOR_LR || enterType == CAR_DOOR_RR)) {
seatOffset = 0.0f;
vehDoorOffset = offsetToOpenVanDoor;
} else {
@@ -1460,7 +1465,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
}
switch (enterType) {
- case VEHICLE_ENTER_FRONT_RIGHT:
+ case CAR_DOOR_RF:
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
else
@@ -1470,13 +1475,13 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
vehDoorOffset.x = -vehDoorOffset.x;
break;
- case VEHICLE_ENTER_REAR_RIGHT:
+ case CAR_DOOR_RR:
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS];
vehDoorPos.x += seatOffset;
vehDoorOffset.x = -vehDoorOffset.x;
break;
- case VEHICLE_ENTER_FRONT_LEFT:
+ case CAR_DOOR_LF:
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
else
@@ -1485,7 +1490,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
vehDoorPos.x = -(vehDoorPos.x + seatOffset);
break;
- case VEHICLE_ENTER_REAR_LEFT:
+ case CAR_DOOR_LR:
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS];
vehDoorPos.x = -(vehDoorPos.x + seatOffset);
break;
@@ -1539,7 +1544,7 @@ CPed::GetPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType,
GetLocalPositionToOpenCarDoor(output, veh, enterType, offset);
doorPos = Multiply3x3(vehMat, *output);
- *output = *veh->GetPosition() + doorPos;
+ *output = veh->GetPosition() + doorPos;
}
void
@@ -1583,7 +1588,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
if (veh->GetUp().z <= -0.8f)
vehIsUpsideDown = true;
- if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) {
+ if (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR) {
if (vehIsUpsideDown) {
m_fRotationDest = -PI + veh->GetForward().Heading();
} else if (veh->bIsBus) {
@@ -1591,7 +1596,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
} else {
m_fRotationDest = veh->GetForward().Heading();
}
- } else if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) {
+ } else if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) {
if (vehIsUpsideDown) {
m_fRotationDest = veh->GetForward().Heading();
} else if (veh->bIsBus) {
@@ -1658,7 +1663,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
CVector neededPos;
if (phase == LINE_UP_TO_CAR_2) {
- neededPos = *GetPosition();
+ neededPos = GetPosition();
} else {
GetPositionToOpenCarDoor(&neededPos, veh, m_vehEnterType, seatPosMult);
}
@@ -1762,7 +1767,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
CMatrix vehDoorMat(veh->GetMatrix());
GetLocalPositionToOpenCarDoor(&output, veh, m_vehEnterType, 0.0f);
- *vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output);
+ vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output);
GetMatrix() = vehDoorMat;
}
@@ -1771,12 +1776,12 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase)
static void
particleProduceFootDust(CPed *ped, CVector *pos, float size, int times)
{
- switch (ped->m_nLastCollType)
+ switch (ped->m_nSurfaceTouched)
{
- case 1: // somewhere hard
- case 3: // soft dirt
- case 5: // pavement
- case 18:// sand
+ case SURFACE_TARMAC:
+ case SURFACE_DIRT:
+ case SURFACE_PAVEMENT:
+ case SURFACE_SAND:
for (int i = 0; i < times; ++i) {
CVector adjustedPos = *pos;
adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
@@ -1878,7 +1883,7 @@ CPed::PlayFootSteps(void)
}
}
- if (m_nLastCollType == 19) { // Water
+ if (m_nSurfaceTouched == SURFACE_PUDDLE) {
float pedSpeed = CVector2D(m_vecMoveSpeed).Magnitude();
if (pedSpeed > 0.03f && CTimer::GetFrameCounter() % 2 == 0 && pedSpeed > 0.13f) {
float particleSize = pedSpeed * 2.0f;
@@ -2054,6 +2059,7 @@ CPed::SetupLighting(void)
{
ActivateDirectional();
SetAmbientColoursForPedsCarsAndObjects();
+
if (bRenderScorched) {
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
} else {
@@ -2086,7 +2092,7 @@ CPed::CalculateNewOrientation(void)
if (CReplay::IsPlayingBack() || !IsPedInControl())
return;
- CVector pos = *GetPosition();
+ CVector pos = GetPosition();
GetMatrix().SetRotate(0.0f, 0.0f, m_fRotationCur);
@@ -2145,10 +2151,10 @@ CPed::CalculateNewVelocity(void)
}
}
- CVector2D forward(sin(m_fRotationCur), cos(m_fRotationCur));
+ CVector2D forward(Sin(m_fRotationCur), Cos(m_fRotationCur));
- m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * cos(m_fRotationCur)) + -sin(m_fRotationCur) * m_vecAnimMoveDelta.y;
- m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * sin(m_fRotationCur));
+ m_moved.x = CrossProduct2D(m_vecAnimMoveDelta, forward); // (m_vecAnimMoveDelta.x * Cos(m_fRotationCur)) + -Sin(m_fRotationCur) * m_vecAnimMoveDelta.y;
+ m_moved.y = DotProduct2D(m_vecAnimMoveDelta, forward); // m_vecAnimMoveDelta.y* Cos(m_fRotationCur) + (m_vecAnimMoveDelta.x * Sin(m_fRotationCur));
if (CTimer::GetTimeStep() >= 0.01f) {
m_moved = m_moved * (1 / CTimer::GetTimeStep());
@@ -2173,7 +2179,7 @@ CPed::CalculateNewVelocity(void)
// Interestingly this part is responsible for diagonal walking.
if (localWalkAngle > -DEGTORAD(50.0f) && localWalkAngle < DEGTORAD(50.0f)) {
TheCamera.Cams[TheCamera.ActiveCam].m_fPlayerVelocity = pedSpeed;
- m_moved = CVector2D(-sin(walkAngle), cos(walkAngle)) * pedSpeed;
+ m_moved = CVector2D(-Sin(walkAngle), Cos(walkAngle)) * pedSpeed;
}
CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_IDLE_STANCE);
@@ -2233,7 +2239,7 @@ CPed::CanPedDriveOff(void)
bool
CPed::CanPedJumpThis(int32 unused)
{
- CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur));
+ CVector2D forward(-Sin(m_fRotationCur), Cos(m_fRotationCur));
CVector pos = GetPosition();
// wat?
CVector forwardPos(
@@ -2270,7 +2276,7 @@ CPed::CanSeeEntity(CEntity *entity, float threshold)
else if (ourAngle > 2 * PI)
ourAngle -= 2 * PI;
- float neededTurn = fabs(neededAngle - ourAngle);
+ float neededTurn = Abs(neededAngle - ourAngle);
return neededTurn < threshold || 2 * PI - threshold < neededTurn;
}
@@ -2695,15 +2701,15 @@ CPed::QuitEnteringCar(void)
if (veh->m_nNumGettingIn != 0)
veh->m_nNumGettingIn--;
- veh->m_nGettingInFlags = GetVehEnterExitFlag(m_vehEnterType);
+ veh->m_nGettingInFlags = ~GetVehDoorFlag(m_vehEnterType);
}
bUsesCollision = true;
if (IsPlayer() && GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI) {
- if (IsPlayer() && m_storedWeapon != NO_STORED_WEAPON) {
+ if (IsPlayer() && m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) {
SetCurrentWeapon(m_storedWeapon);
- m_storedWeapon = NO_STORED_WEAPON;
+ m_storedWeapon = WEAPONTYPE_UNIDENTIFIED;
}
} else {
CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
@@ -2805,7 +2811,7 @@ CPed::TurnBody(void)
float neededTurn = currentRot - limitedLookDir;
m_fRotationDest = limitedLookDir;
- if (fabs(neededTurn) > 0.05f) {
+ if (Abs(neededTurn) > 0.05f) {
doneSmoothly = false;
currentRot -= neededTurn * 0.2f;
}
@@ -2868,6 +2874,38 @@ CPed::Chat(void)
}
}
+void
+CPed::CheckAroundForPossibleCollisions(void)
+{
+ CVector ourCentre, objCentre;
+ CEntity *objects[8];
+ int16 maxObject;
+
+ if (CTimer::GetTimeInMilliseconds() <= m_nPedStateTimer)
+ return;
+
+ GetBoundCentre(ourCentre);
+
+ CWorld::FindObjectsInRange(ourCentre, 10.0f, true, &maxObject, 6, objects, false, true, false, true, false);
+ for (int i = 0; i < maxObject; i++) {
+ CEntity *object = objects[i];
+ if (field_31C) {
+ if (gPhoneInfo.PhoneAtThisPosition(object->GetPosition()))
+ break;
+ }
+ object->GetBoundCentre(objCentre);
+ float radius = object->GetBoundRadius();
+ if (radius > 4.5f || radius < 1.0f)
+ radius = 1.0f;
+
+ // According to code, developers gave up calculating Z diff. later.
+ float diff = CVector(ourCentre - objCentre).MagnitudeSqr2D();
+
+ if (sq(radius + 1.0f) > diff)
+ m_fRotationDest += DEGTORAD(22.5f);
+ }
+}
+
WRAPPER void CPed::PedGetupCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE810); }
WRAPPER void CPed::PedStaggerCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8D0); }
WRAPPER void CPed::PedEvadeCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D36E0); }
@@ -2892,9 +2930,28 @@ WRAPPER void CPed::PedLandCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0
WRAPPER void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4C6580); }
WRAPPER void CPed::RestoreHeadingRateCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D6550); }
+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); }
+};
+
STARTPATCHES
- InjectHook(0x4C41C0, &CPed::ctor, PATCH_JUMP);
- InjectHook(0x4C50D0, &CPed::dtor, PATCH_JUMP);
+ 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(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP);
InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP);
InjectHook(0x4EB470, &CPed::ApplyHeadShot, PATCH_JUMP);
@@ -2925,11 +2982,6 @@ STARTPATCHES
InjectHook(0x4CC6C0, &CPed::PlayFootSteps, PATCH_JUMP);
InjectHook(0x4C5350, &CPed::BuildPedLists, PATCH_JUMP);
InjectHook(0x4CF9B0, &CPed::GiveWeapon, 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(0x4C7EA0, &CPed::CalculateNewOrientation, PATCH_JUMP);
InjectHook(0x4C78F0, &CPed::WorkOutHeadingForMovingFirstPerson, PATCH_JUMP);
InjectHook(0x4C73F0, &CPed::CalculateNewVelocity, PATCH_JUMP);
@@ -2946,4 +2998,5 @@ STARTPATCHES
InjectHook(0x4D3C80, &CPed::ClearChat, PATCH_JUMP);
InjectHook(0x4D1390, &CPed::TurnBody, PATCH_JUMP);
InjectHook(0x4D3AC0, &CPed::Chat, PATCH_JUMP);
+ InjectHook(0x4D0490, &CPed::CheckAroundForPossibleCollisions, PATCH_JUMP);
ENDPATCHES
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 95731e15..cd7d88af 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -13,7 +13,7 @@
struct CPathNode;
-enum eWaitState : uint32 {
+enum eWaitState {
WAITSTATE_FALSE,
WAITSTATE_TRAFFIC_LIGHTS,
WAITSTATE_CROSS_ROAD,
@@ -76,13 +76,6 @@ enum eObjective : uint32 {
OBJECTIVE_35
};
-enum eVehEnter : uint16 {
- VEHICLE_ENTER_FRONT_RIGHT = 11,
- VEHICLE_ENTER_REAR_RIGHT = 12,
- VEHICLE_ENTER_FRONT_LEFT = 15,
- VEHICLE_ENTER_REAR_LEFT = 16,
-};
-
enum {
RANDOM_CHAR = 1,
MISSION_CHAR,
@@ -258,7 +251,7 @@ public:
uint8 m_ped_flagI1 : 1;
uint8 m_ped_flagI2 : 1;
uint8 m_ped_flagI4 : 1;
- uint8 bRecordedForReplay : 1;
+ uint8 bHasAlreadyBeenRecorded : 1;
uint8 m_ped_flagI10 : 1;
uint8 m_ped_flagI20 : 1;
uint8 m_ped_flagI40 : 1;
@@ -299,10 +292,10 @@ public:
int32 m_nPrevActionState;
eWaitState m_nWaitState;
uint32 m_nWaitTimer;
- void *m_pPathNodesStates[8];
+ void *m_pPathNodesStates[8]; // seems unused
CVector2D m_stPathNodeStates[10];
uint16 m_nPathNodes;
- uint8 m_nCurPathNode;
+ int16 m_nCurPathNode;
int8 m_nPathState;
private:
int8 _pad2B5[3];
@@ -321,7 +314,7 @@ public:
float m_fRotationCur;
float m_fRotationDest;
float m_headingRate;
- eVehEnter m_vehEnterType;
+ uint16 m_vehEnterType;
uint16 m_walkAroundType;
CEntity *m_pCurrentPhysSurface;
CVector m_vecOffsetFromPhysSurface;
@@ -331,7 +324,7 @@ public:
CVehicle *m_pMyVehicle;
bool bInVehicle;
uint8 pad_315[3];
- uint32 field_318;
+ float field_318;
uint8 field_31C;
uint8 field_31D;
int16 m_phoneId;
@@ -351,7 +344,7 @@ public:
uint8 pad_351[3];
uint32 m_timerUnused;
CEntity *m_targetUnused;
- CWeapon m_weapons[NUM_PED_WEAPONTYPES];
+ CWeapon m_weapons[WEAPONTYPE_TOTAL_INVENTORY_WEAPONS];
eWeaponType m_storedWeapon;
uint8 m_currentWeapon; // eWeaponType
uint8 m_maxWeaponTypeAllowed; // eWeaponType
@@ -399,21 +392,19 @@ public:
static void operator delete(void*, int);
CPed(uint32 pedType);
- virtual ~CPed(void);
-
- virtual void SetModelIndex(uint32 mi);
- virtual void ProcessControl(void);
- virtual void Teleport(CVector);
- virtual void PreRender(void);
- virtual void Render(void);
- virtual bool SetupLighting(void);
- virtual void RemoveLighting(bool);
- virtual void FlagToDestroyWhenNextProcessed(void);
- virtual int32 ProcessEntityCollision(CEntity*, CColPoint*);
- virtual void SetMoveAnim(void);
+ ~CPed(void);
+
+ void SetModelIndex(uint32 mi);
+ void ProcessControl(void);
+ void Teleport(CVector);
+ void PreRender(void);
+ void Render(void);
+ bool SetupLighting(void);
+ void RemoveLighting(bool);
+ void FlagToDestroyWhenNextProcessed(void);
+ int32 ProcessEntityCollision(CEntity*, CColPoint*);
- CPed* ctor(uint32 pedType) { return ::new (this) CPed(pedType); }
- void dtor(void) { this->CPed::~CPed(); }
+ virtual void SetMoveAnim(void);
void AddWeaponModel(int id);
void AimGun(void);
@@ -423,6 +414,7 @@ public:
void SetLookFlag(float direction, bool unknown);
void SetLookTimer(int time);
void SetDie(AnimationId anim, float arg1, float arg2);
+ void SetDead(void);
void ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer);
void RemoveBodyPart(PedNode nodeId, int8 unknown);
void SpawnFlyingComponent(int, int8 unknown);
@@ -465,6 +457,9 @@ public:
void RegisterThreatWithGangPeds(CEntity*);
bool TurnBody(void);
void Chat(void);
+ void MakeChangesForNewWeapon(int8);
+ void CheckAroundForPossibleCollisions(void);
+ bool Seek(void);
// Static methods
static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset);
@@ -526,30 +521,9 @@ public:
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; }
- static uint8 GetVehEnterExitFlag(eVehEnter vehEnter) {
- switch (vehEnter) {
- case VEHICLE_ENTER_FRONT_RIGHT:
- return 4;
- case VEHICLE_ENTER_REAR_RIGHT:
- return 8;
- case VEHICLE_ENTER_FRONT_LEFT:
- return 1;
- case VEHICLE_ENTER_REAR_LEFT:
- return 2;
- default:
- return 0;
- }
- }
PedState GetPedState(void) { return m_nPedState; }
void SetPedState(PedState state) { m_nPedState = state; }
- // to make patching virtual functions possible
- 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); }
-
// set by 0482:set_threat_reaction_range_multiplier opcode
static uint16 &distanceMultToCountPedNear;
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index b9baf49c..9b3f401f 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -34,8 +34,8 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c
// rotation == 0 -> looking in y direction
// left? vector
- float c = cos(m_ped->m_fRotationCur);
- float s = sin(m_ped->m_fRotationCur);
+ 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);
@@ -51,7 +51,7 @@ CPedIK::RotateTorso(AnimBlendFrameData *animBlend, LimbOrientation *limb, bool c
float dotProduct = DotProduct(mat->at, inversedForward);
if(dotProduct > 1.0f) dotProduct = 1.0f;
if(dotProduct < -1.0f) dotProduct = -1.0f;
- float alpha = acos(dotProduct);
+ float alpha = Acos(dotProduct);
if(mat->at.z < 0.0f)
alpha = -alpha;
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index 2d67d5b2..4b484a7f 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -1,6 +1,8 @@
#include "common.h"
#include "patcher.h"
#include "PlayerPed.h"
+#include "Camera.h"
+#include "WeaponEffects.h"
CPlayerPed::~CPlayerPed()
{
@@ -8,7 +10,40 @@ CPlayerPed::~CPlayerPed()
}
WRAPPER void CPlayerPed::ReApplyMoveAnims(void) { EAXJMP(0x4F07C0); }
+WRAPPER void CPlayerPed::SetupPlayerPed(int32) { EAXJMP(0x4EFB60); }
+WRAPPER void CPlayerPed::DeactivatePlayerPed(int32) { EAXJMP(0x4EFC00); }
+WRAPPER void CPlayerPed::ReactivatePlayerPed(int32) { EAXJMP(0x4EFC20); }
+
+void CPlayerPed::ClearWeaponTarget()
+{
+ if (!m_nPedType) {
+ m_pPointGunAt = 0;
+ TheCamera.ClearPlayerWeaponMode();
+ CWeaponEffects::ClearCrosshair();
+ }
+ ClearPointGunAt();
+}
+
+void
+CPlayerPed::SetWantedLevel(int32 level)
+{
+ m_pWanted->SetWantedLevel(level);
+}
+
+void
+CPlayerPed::SetWantedLevelNoDrop(int32 level)
+{
+ m_pWanted->SetWantedLevelNoDrop(level);
+}
+
+
+class CPlayerPed_ : public CPlayerPed
+{
+public:
+ void dtor(void) { CPlayerPed::~CPlayerPed(); }
+};
STARTPATCHES
- InjectHook(0x4EFB30, &CPlayerPed::dtor, PATCH_JUMP);
-ENDPATCHES \ No newline at end of file
+ InjectHook(0x4EFB30, &CPlayerPed_::dtor, PATCH_JUMP);
+ InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/peds/PlayerPed.h b/src/peds/PlayerPed.h
index 15ad74a6..51a45203 100644
--- a/src/peds/PlayerPed.h
+++ b/src/peds/PlayerPed.h
@@ -41,8 +41,14 @@ public:
~CPlayerPed();
- void dtor(void) { this->CPlayerPed::~CPlayerPed(); }
void ReApplyMoveAnims(void);
+ void ClearWeaponTarget();
+ void SetWantedLevel(int32 level);
+ void SetWantedLevelNoDrop(int32 level);
+
+ static void SetupPlayerPed(int32);
+ static void DeactivatePlayerPed(int32);
+ static void ReactivatePlayerPed(int32);
};
static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error");