summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2019-06-18 14:55:39 +0200
committereray orçunus <erayorcunus@gmail.com>2019-06-18 22:01:03 +0200
commitc9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa (patch)
treee12607035cf235f3d71979ba006b4a69bba31564 /src/entities
parentMerge branch 'master' of git://github.com/GTAmodding/re3 (diff)
downloadre3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.tar
re3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.tar.gz
re3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.tar.bz2
re3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.tar.lz
re3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.tar.xz
re3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.tar.zst
re3-c9f6e7bf83dcef53f13de9e24fa9c6113cf1f0fa.zip
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/Ped.cpp20
-rw-r--r--src/entities/Ped.h2
2 files changed, 10 insertions, 12 deletions
diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp
index f6d9f4b2..12528b20 100644
--- a/src/entities/Ped.cpp
+++ b/src/entities/Ped.cpp
@@ -401,7 +401,7 @@ CPed::Avoid(void) {
int8 temper;
int moveState;
CPed* nearestPed;
- float rate;
+ float walkAngle;
float distance;
temper = m_pedStats->m_temper;
@@ -416,19 +416,17 @@ CPed::Avoid(void) {
&& (CPedType::ms_apPedType[nearestPed->m_nPedType]->m_Type.IntValue
& CPedType::ms_apPedType[this->m_nPedType]->m_Avoid.IntValue)) {
- CVector2D pedAngleRatio(
- cos(RADTODEG(m_fRotationCur) / RADTODEG(1)),
- -sin(RADTODEG(m_fRotationCur) / RADTODEG(1))
- );
-
- // sin^2 + cos^2 must always return 1, and it does return... so what's the point?
- rate = 1.0f / pedAngleRatio.Magnitude();
-
// Further codes checks whether the distance between us and ped will be equal or below 1.0, if we walk up to him by 1.25 meters.
// If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else.
+
+ walkAngle = RADTODEG(m_fRotationCur) / RADTODEG(1);
+
+ // Original code was multiplying sin/cos with the number below, which is pointless because it's always 1.
+ // ratio = 1.0f / sqrt(sin*sin + cos*cos);
+
CVector2D walkedUpToPed(
- nearestPed->GetPosition().x - (1.25 * (pedAngleRatio.y * rate) + GetPosition().x),
- nearestPed->GetPosition().y - (1.25 * (pedAngleRatio.x * rate) + GetPosition().y)
+ nearestPed->GetPosition().x - (1.25 * -sin(walkAngle) + GetPosition().x),
+ nearestPed->GetPosition().y - (1.25 * cos(walkAngle) + GetPosition().y)
);
distance = walkedUpToPed.Magnitude();
diff --git a/src/entities/Ped.h b/src/entities/Ped.h
index 7496ee67..f9e46dae 100644
--- a/src/entities/Ped.h
+++ b/src/entities/Ped.h
@@ -3,10 +3,10 @@
#include "Physical.h"
#include "Weapon.h"
#include "PedIK.h"
+#include "PedStats.h"
#include "AnimManager.h"
#include "AnimBlendClumpData.h"
-struct PedStat;
struct CPathNode;
enum {