1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 10:40:00 +00:00

CPed fixes

Signed-off-by: eray orçunus <erayorcunus@gmail.com>
This commit is contained in:
eray orçunus 2019-06-18 15:34:27 +03:00
parent e45689373d
commit 4ed6e86db1
4 changed files with 30 additions and 32 deletions

View file

@ -339,7 +339,7 @@ CPed::SetLookFlag(CPed *to, bool set)
m_lookTimer = 0; m_lookTimer = 0;
m_ped_flagA20_look = set; m_ped_flagA20_look = set;
if (m_nPedState != PED_DRIVING) { if (m_nPedState != PED_DRIVING) {
m_pedIK.m_flags &= ~CPedIK::FLAG_4; m_pedIK.m_flags &= ~CPedIK::FLAG_2;
} }
} }
} }
@ -355,7 +355,7 @@ CPed::SetLookFlag(float angle, bool set)
m_lookTimer = 0; m_lookTimer = 0;
m_ped_flagA20_look = set; m_ped_flagA20_look = set;
if (m_nPedState != PED_DRIVING) { if (m_nPedState != PED_DRIVING) {
m_pedIK.m_flags &= ~CPedIK::FLAG_4; m_pedIK.m_flags &= ~CPedIK::FLAG_2;
} }
} }
} }
@ -371,8 +371,6 @@ CPed::SetLookTimer(int time)
bool bool
CPed::OurPedCanSeeThisOne(CEntity* who) CPed::OurPedCanSeeThisOne(CEntity* who)
{ {
float xDiff;
float yDiff;
float distance; float distance;
CColPoint colpoint; CColPoint colpoint;
CEntity* ent; CEntity* ent;
@ -382,13 +380,15 @@ CPed::OurPedCanSeeThisOne(CEntity* who)
ourPos = this->GetPosition(); ourPos = this->GetPosition();
itsPos = who->GetPosition(); itsPos = who->GetPosition();
xDiff = itsPos.x - ourPos.x; CVector2D posDiff(
yDiff = itsPos.y - ourPos.y; itsPos.x - ourPos.x,
itsPos.y - ourPos.y
);
if ((yDiff * this->GetUp().y) + (xDiff * this->GetUp().x) < 0.0f) if ((posDiff.y * this->GetForward().y) + (posDiff.x * this->GetForward().x) < 0.0f)
return 0; return 0;
distance = sqrt(yDiff * yDiff + xDiff * xDiff); distance = posDiff.Magnitude();
if (distance < 40.0f) if (distance < 40.0f)
return 0; return 0;
@ -402,13 +402,8 @@ CPed::Avoid(void) {
int8 temper; int8 temper;
int moveState; int moveState;
CPed* nearestPed; CPed* nearestPed;
float sinValue; float rate;
float cosValue; float distance;
float someRate;
float someY;
float someX;
float someDistance;
float simplifiedAngle;
temper = m_pedStats->m_temper; temper = m_pedStats->m_temper;
if ((temper <= m_pedStats->m_fear || temper <= 50) && CTimer::GetTimeInMilliseconds() > m_nPedStateTimer) { if ((temper <= m_pedStats->m_fear || temper <= 50) && CTimer::GetTimeInMilliseconds() > m_nPedStateTimer) {
@ -422,24 +417,24 @@ CPed::Avoid(void) {
&& (CPedType::ms_apPedType[nearestPed->m_nPedType]->m_Type.IntValue && (CPedType::ms_apPedType[nearestPed->m_nPedType]->m_Type.IntValue
& CPedType::ms_apPedType[this->m_nPedType]->m_Avoid.IntValue)) { & CPedType::ms_apPedType[this->m_nPedType]->m_Avoid.IntValue)) {
simplifiedAngle = RADTODEG(m_fRotationCur) / RADTODEG(1); CVector2D pedAngleRatio(
sinValue = -sin(simplifiedAngle); cos(RADTODEG(m_fRotationCur) / RADTODEG(1)),
cosValue = cos(simplifiedAngle); -sin(RADTODEG(m_fRotationCur) / RADTODEG(1))
);
// sin^2 + cos^2 must always return 1, and it does return... so what's the point? // sin^2 + cos^2 must always return 1, and it does return... so what's the point?
someRate = 1.0f / sqrt(cosValue * cosValue + sinValue * sinValue); 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. // 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. // If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else.
someY = nearestPed->GetPosition().y CVector2D walkedUpToPed(
- (1.25 * (cosValue * someRate) nearestPed->GetPosition().x - (1.25 * (pedAngleRatio.y * rate) + GetPosition().x),
+ GetPosition().y); nearestPed->GetPosition().y - (1.25 * (pedAngleRatio.x * rate) + GetPosition().y)
someX = nearestPed->GetPosition().x );
- (1.25 * (sinValue * someRate)
+ GetPosition().x);
someDistance = sqrt(someY * someY + someX * someX);
if (someDistance <= 1.0f && CPed::OurPedCanSeeThisOne((CEntity*)nearestPed)) { distance = walkedUpToPed.Magnitude();
if (distance <= 1.0f && CPed::OurPedCanSeeThisOne((CEntity*)nearestPed)) {
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() m_nPedStateTimer = CTimer::GetTimeInMilliseconds()
+ 500 + (m_randomSeed + 3 * CTimer::GetFrameCounter()) + 500 + (m_randomSeed + 3 * CTimer::GetFrameCounter())
% 1000 / 5; % 1000 / 5;

View file

@ -95,7 +95,7 @@ public:
float m_fCollisionSpeed; float m_fCollisionSpeed;
uint8 m_ped_flagA1 : 1; uint8 m_ped_flagA1 : 1;
uint8 m_ped_flagA2 : 1; uint8 m_ped_flagA2 : 1;
uint8 m_ped_flagA4 : 1; uint8 m_ped_flagA4 : 1; // stores (CTimer::GetTimeInMilliseconds() < m_lastHitTime)
uint8 m_ped_flagA8 : 1; uint8 m_ped_flagA8 : 1;
uint8 m_ped_flagA10 : 1; // set when A20 just changed? uint8 m_ped_flagA10 : 1; // set when A20 just changed?
uint8 m_ped_flagA20_look : 1; uint8 m_ped_flagA20_look : 1;
@ -129,7 +129,7 @@ public:
uint8 m_ped_flagE2 : 1; uint8 m_ped_flagE2 : 1;
uint8 m_ped_flagE4 : 1; uint8 m_ped_flagE4 : 1;
uint8 m_ped_flagE8 : 1; uint8 m_ped_flagE8 : 1;
uint8 m_ped_flagE10 : 1; uint8 m_ped_flagE10 : 1; // can't attack if it's set
uint8 m_ped_flagE20 : 1; uint8 m_ped_flagE20 : 1;
uint8 m_ped_flagE40 : 1; uint8 m_ped_flagE40 : 1;
uint8 m_ped_flagE80 : 1; uint8 m_ped_flagE80 : 1;
@ -228,7 +228,10 @@ public:
uint32 m_leaveCarTimer; uint32 m_leaveCarTimer;
uint32 m_getUpTimer; uint32 m_getUpTimer;
uint32 m_lookTimer; uint32 m_lookTimer;
uint8 stuff9[34]; uint32 m_standardTimer;
uint32 m_attackTimer;
uint32 m_lastHitTime;
uint8 stuff9[22];
uint8 m_bodyPartBleeding; uint8 m_bodyPartBleeding;
uint8 m_field_4F3; uint8 m_field_4F3;
CPed *m_nearPeds[10]; CPed *m_nearPeds[10];

View file

@ -16,7 +16,7 @@ public:
enum { enum {
FLAG_1, FLAG_1,
FLAG_2, FLAG_2,
FLAG_4, FLAG_4, // aims with arm
}; };
CPed* m_ped; CPed* m_ped;

View file

@ -19,7 +19,7 @@ public:
int32 m_nSpeedTimer; int32 m_nSpeedTimer;
int32 m_nShotDelay; int32 m_nShotDelay;
float field_1376; float field_1376;
int8 field_1380; int8 field_1380; // set if can't attack, why?
int8 field_1381; int8 field_1381;
int8 field_1382; int8 field_1382;
int8 field_1383; int8 field_1383;