summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-05-04 18:51:56 +0200
committerGitHub <noreply@github.com>2020-05-04 18:51:56 +0200
commit3554ec58bb41f322dda5699d6b485b47038debda (patch)
tree9426c3e7397ec950589d4787c95dfcbf47524a91 /src/peds
parentfixed fog color for librw (diff)
parentGTA_ZONECULL define (diff)
downloadre3-3554ec58bb41f322dda5699d6b485b47038debda.tar
re3-3554ec58bb41f322dda5699d6b485b47038debda.tar.gz
re3-3554ec58bb41f322dda5699d6b485b47038debda.tar.bz2
re3-3554ec58bb41f322dda5699d6b485b47038debda.tar.lz
re3-3554ec58bb41f322dda5699d6b485b47038debda.tar.xz
re3-3554ec58bb41f322dda5699d6b485b47038debda.tar.zst
re3-3554ec58bb41f322dda5699d6b485b47038debda.zip
Diffstat (limited to '')
-rw-r--r--src/peds/CopPed.cpp20
-rw-r--r--src/peds/CopPed.h2
-rw-r--r--src/peds/Ped.cpp40
3 files changed, 34 insertions, 28 deletions
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index 7cea902d..8bfd807f 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -73,7 +73,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
// VC also initializes in here, but as nil
#ifdef FIX_BUGS
- m_wRoadblockNode = -1;
+ m_nRoadblockNode = -1;
#endif
}
@@ -305,9 +305,9 @@ CCopPed::CopAI(void)
m_bZoneDisabled = true;
m_bIsDisabledCop = true;
#ifdef FIX_BUGS
- m_wRoadblockNode = -1;
+ m_nRoadblockNode = -1;
#else
- m_wRoadblockNode = 0;
+ m_nRoadblockNode = 0;
#endif
bKindaStayInSamePlace = true;
bIsRunning = false;
@@ -424,9 +424,15 @@ CCopPed::CopAI(void)
// 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]];
+ if (m_nRoadblockNode != -1) {
+#ifndef MIAMI
+ CTreadable *roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_nRoadblockNode]];
dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), GetPosition() - roadBlockRoad->GetPosition());
+#else
+ // TODO: check this, i'm only getting this compile here....
+ CPathNode *roadBlockNode = &ThePaths.m_pathNodes[CRoadBlocks::RoadBlockNodes[m_nRoadblockNode]];
+ dotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockNode->GetPosition(), GetPosition() - roadBlockNode->GetPosition());
+#endif
} else
dotProd = -1.0f;
@@ -437,10 +443,10 @@ CCopPed::CopAI(void)
float copRoadDotProd, targetRoadDotProd;
#else
float copRoadDotProd = 1.0f, targetRoadDotProd = 1.0f;
- if (m_wRoadblockNode != -1)
+ if (m_nRoadblockNode != -1)
#endif
{
- CTreadable* roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_wRoadblockNode]];
+ CTreadable* roadBlockRoad = ThePaths.m_mapObjects[CRoadBlocks::RoadBlockObjects[m_nRoadblockNode]];
CVector2D roadFwd = roadBlockRoad->GetForward();
copRoadDotProd = DotProduct2D(GetPosition() - roadBlockRoad->GetPosition(), roadFwd);
targetRoadDotProd = DotProduct2D(playerOrHisVeh->GetPosition() - roadBlockRoad->GetPosition(), roadFwd);
diff --git a/src/peds/CopPed.h b/src/peds/CopPed.h
index e9780035..d63aef06 100644
--- a/src/peds/CopPed.h
+++ b/src/peds/CopPed.h
@@ -12,7 +12,7 @@ enum eCopType
class CCopPed : public CPed
{
public:
- int16 m_wRoadblockNode;
+ int16 m_nRoadblockNode;
float m_fDistanceToTarget;
bool m_bIsInPursuit;
bool m_bIsDisabledCop;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index e7972541..cfd50a5d 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -4504,7 +4504,7 @@ CPed::RestorePreviousState(void)
bIsRunning = false;
if (!bFindNewNodeAfterStateRestore) {
if (m_pNextPathNode) {
- CVector diff = m_pNextPathNode->pos - GetPosition();
+ CVector diff = m_pNextPathNode->GetPosition() - GetPosition();
if (diff.MagnitudeSqr() < sq(7.0f)) {
SetMoveState(PEDMOVE_WALK);
break;
@@ -6925,10 +6925,10 @@ SelectClosestNodeForSeek(CPed *ped, CPathNode *node, CVector2D closeDist, CVecto
{
for (int i = 0; i < node->numLinks; i++) {
- CPathNode *testNode = &ThePaths.m_pathNodes[ThePaths.m_connections[i + node->firstLink]];
+ CPathNode *testNode = &ThePaths.m_pathNodes[ThePaths.ConnectedNode(i + node->firstLink)];
if (testNode && testNode != closeNode && testNode != closeNode2) {
- CVector2D posDiff(ped->m_vecSeekPos - testNode->pos);
+ CVector2D posDiff(ped->m_vecSeekPos - testNode->GetPosition());
float dist = posDiff.MagnitudeSqr();
if (farDist.MagnitudeSqr() > dist) {
@@ -6969,16 +6969,16 @@ CPed::FindBestCoordsFromNodes(CVector unused, CVector *bestCoords)
CVector2D seekPosDist (m_vecSeekPos - ourPos);
CPathNode *closestNode = &ThePaths.m_pathNodes[closestNodeId];
- CVector2D closeDist(m_vecSeekPos - closestNode->pos);
+ CVector2D closeDist(m_vecSeekPos - closestNode->GetPosition());
SelectClosestNodeForSeek(this, closestNode, closeDist, seekPosDist, closestNode, nil);
// Above function decided that going to the next node is more logical than seeking the object.
if (m_pNextPathNode) {
- CVector pathToNextNode = m_pNextPathNode->pos - ourPos;
+ CVector pathToNextNode = m_pNextPathNode->GetPosition() - ourPos;
if (pathToNextNode.MagnitudeSqr2D() < seekPosDist.MagnitudeSqr()) {
- *bestCoords = m_pNextPathNode->pos;
+ *bestCoords = m_pNextPathNode->GetPosition();
return true;
}
m_pNextPathNode = nil;
@@ -7671,7 +7671,7 @@ CPed::Flee(void)
}
if (m_pNextPathNode) {
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
if (m_nMoveState == PEDMOVE_RUN)
bIsRunning = true;
@@ -9653,17 +9653,17 @@ CPed::ProcessControl(void)
if (m_nPedState == PED_WANDER_PATH) {
m_pNextPathNode = &ThePaths.m_pathNodes[closestNodeId];
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
- m_pNextPathNode->pos.x, m_pNextPathNode->pos.y,
+ m_pNextPathNode->GetX(), m_pNextPathNode->GetY(),
GetPosition().x, GetPosition().y);
} else {
- if (ThePaths.m_pathNodes[closestNodeId].pos.x == 0.0f
- || ThePaths.m_pathNodes[closestNodeId].pos.y == 0.0f) {
+ if (ThePaths.m_pathNodes[closestNodeId].GetX() == 0.0f
+ || ThePaths.m_pathNodes[closestNodeId].GetY() == 0.0f) {
posToHead = (3.0f * m_vecDamageNormal) + GetPosition();
posToHead.x += (CGeneral::GetRandomNumber() % 512) / 250.0f - 1.0f;
posToHead.y += (CGeneral::GetRandomNumber() % 512) / 250.0f - 1.0f;
} else {
- posToHead.x = ThePaths.m_pathNodes[closestNodeId].pos.x;
- posToHead.y = ThePaths.m_pathNodes[closestNodeId].pos.y;
+ posToHead.x = ThePaths.m_pathNodes[closestNodeId].GetX();
+ posToHead.y = ThePaths.m_pathNodes[closestNodeId].GetY();
}
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
posToHead.x, posToHead.y,
@@ -9674,12 +9674,12 @@ CPed::ProcessControl(void)
}
} else {
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
- ThePaths.m_pathNodes[closestNodeId].pos.x,
- ThePaths.m_pathNodes[closestNodeId].pos.y,
+ ThePaths.m_pathNodes[closestNodeId].GetX(),
+ ThePaths.m_pathNodes[closestNodeId].GetY(),
GetPosition().x,
GetPosition().y);
- CVector2D distToNode = ThePaths.m_pathNodes[closestNodeId].pos - GetPosition();
+ CVector2D distToNode = ThePaths.m_pathNodes[closestNodeId].GetPosition() - GetPosition();
CVector2D distToSeekPos = m_vecSeekPos - GetPosition();
if (DotProduct2D(distToNode, distToSeekPos) < 0.0f) {
@@ -12904,7 +12904,7 @@ CPed::ProcessObjective(void)
if (closestNode >= 0) {
int16 colliding;
CWorld::FindObjectsKindaColliding(
- ThePaths.m_pathNodes[closestNode].pos, 10.0f, true, &colliding, 2, nil, false, true, true, false, false);
+ ThePaths.m_pathNodes[closestNode].GetPosition(), 10.0f, true, &colliding, 2, nil, false, true, true, false, false);
if (!colliding) {
CZoneInfo zoneInfo;
int chosenCarClass;
@@ -12912,7 +12912,7 @@ CPed::ProcessObjective(void)
int chosenModel = CCarCtrl::ChooseModel(&zoneInfo, &ourPos, &chosenCarClass);
CAutomobile *newVeh = new CAutomobile(chosenModel, RANDOM_VEHICLE);
if (newVeh) {
- newVeh->GetPosition() = ThePaths.m_pathNodes[closestNode].pos;
+ newVeh->GetPosition() = ThePaths.m_pathNodes[closestNode].GetPosition();
newVeh->GetPosition().z += 4.0f;
newVeh->SetHeading(DEGTORAD(200.0f));
newVeh->SetStatus(STATUS_ABANDONED);
@@ -13112,7 +13112,7 @@ CPed::ProcessObjective(void)
FindBestCoordsFromNodes(m_vecSeekPos, &bestCoords);
if (m_pNextPathNode)
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else {
@@ -13666,7 +13666,7 @@ CPed::ProcessObjective(void)
FindBestCoordsFromNodes(m_vecSeekPos, &bestCoords);
if (m_pNextPathNode)
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
}
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
}
@@ -17324,7 +17324,7 @@ CPed::WanderPath(void)
if (m_nMoveState == PEDMOVE_STILL || m_nMoveState == PEDMOVE_NONE)
SetMoveState(PEDMOVE_WALK);
}
- m_vecSeekPos = m_pNextPathNode->pos;
+ m_vecSeekPos = m_pNextPathNode->GetPosition();
m_vecSeekPos.z += 1.0f;
// Only returns true when ped is stuck(not stopped) I think, then we should assign new direction or wait state to him.