summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-12-14 08:47:07 +0100
committerSergeanur <s.anureev@yandex.ua>2020-12-14 08:47:07 +0100
commitf42a01f653c860b5df3cfdbe34cc37f25dc3c36a (patch)
treebc6a09f0a1ca0fafbf1e53b4c8e60b581281c0c4
parentMerge branch 'master' of https://github.com/GTAmodding/re3 (diff)
downloadre3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.tar
re3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.tar.gz
re3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.tar.bz2
re3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.tar.lz
re3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.tar.xz
re3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.tar.zst
re3-f42a01f653c860b5df3cfdbe34cc37f25dc3c36a.zip
-rw-r--r--src/control/RoadBlocks.cpp3
-rw-r--r--src/peds/CopPed.cpp7
-rw-r--r--src/peds/Ped.h7
-rw-r--r--src/peds/PedAI.cpp19
-rw-r--r--src/peds/PlayerPed.cpp16
5 files changed, 20 insertions, 32 deletions
diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp
index 1496b307..170c5ff8 100644
--- a/src/control/RoadBlocks.cpp
+++ b/src/control/RoadBlocks.cpp
@@ -90,8 +90,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
pCopPed->m_nRoadblockNode = roadBlockNode;
pCopPed->bCrouchWhenShooting = roadBlockType != 2;
if (pEntityToAttack) {
- pCopPed->m_pPointGunAt = pEntityToAttack;
- pEntityToAttack->RegisterReference(&pCopPed->m_pPointGunAt);
+ pCopPed->SetWeaponLockOnTarget(pEntityToAttack);
pCopPed->SetAttack(pEntityToAttack);
}
pCopPed->m_pMyVehicle = pVehicle;
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index d9f55559..de7b8ad2 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -69,7 +69,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
field_1364 = -1;
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
// VC also initializes in here, but as nil
#ifdef FIX_BUGS
@@ -472,10 +472,7 @@ CCopPed::CopAI(void)
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);
-
+ SetWeaponLockOnTarget(playerOrHisVeh);
SetAttack(playerOrHisVeh);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000));
}
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index f8e619d7..0e398b25 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -863,6 +863,13 @@ public:
SetMoveState(PEDMOVE_WALK);
}
+ inline void SetWeaponLockOnTarget(CEntity *target)
+ {
+ m_pPointGunAt = (CPed *)target;
+ if(target)
+ ((CEntity *)target)->RegisterReference(&m_pPointGunAt);
+ }
+
// Using this to abstract nodes of skinned and non-skinned meshes
CVector GetNodePosition(int32 node)
{
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index f1d16119..5eaf8cd8 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -620,9 +620,7 @@ CPed::UpdateFromLeader(void)
m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget);
TurnBody();
if (m_attackTimer < CTimer::GetTimeInMilliseconds() && !GetWeapon()->IsTypeMelee()) {
- m_pPointGunAt = m_threatEntity;
- if (m_threatEntity)
- m_threatEntity->RegisterReference((CEntity **) &m_pPointGunAt);
+ SetWeaponLockOnTarget(m_threatEntity);
SetAttack(m_threatEntity);
}
}
@@ -1026,10 +1024,7 @@ CPed::ProcessObjective(void)
CWorld::bIncludeDeadPeds = false;
if (foundEnt == vehOfTarget) {
SetAttack(vehOfTarget);
- m_pPointGunAt = vehOfTarget;
- if (vehOfTarget)
- vehOfTarget->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(vehOfTarget);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc <= m_distanceToCountSeekDone) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(200, 500));
@@ -1162,10 +1157,7 @@ CPed::ProcessObjective(void)
CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_pedInObjective) {
SetAttack(m_pedInObjective);
- m_pPointGunAt = m_pedInObjective;
- if (m_pedInObjective)
- m_pedInObjective->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(m_pedInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500.0f, 2000.0f));
int time;
@@ -1551,10 +1543,7 @@ CPed::ProcessObjective(void)
CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_carInObjective) {
SetAttack(m_carInObjective);
- m_pPointGunAt = m_carInObjective;
- if (m_pPointGunAt)
- m_pPointGunAt->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(m_carInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc > 10.0f && !bKindaStayInSamePlace) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000));
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index f23aa378..ef9cf201 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -47,8 +47,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
m_nSpeedTimer = 0;
m_bSpeedTimerFlag = false;
- m_pPointGunAt = nil;
- m_nPedState = PED_IDLE;
+ SetWeaponLockOnTarget(nil);
+ SetPedState(PED_IDLE);
#ifndef FIX_BUGS
m_fCurrentStamina = m_fMaxStamina = 150.0f;
#endif
@@ -73,7 +73,7 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
void CPlayerPed::ClearWeaponTarget()
{
if (m_nPedType == PEDTYPE_PLAYER1) {
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrossHair();
}
@@ -875,9 +875,7 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft)
if (!nextTarget)
return false;
- m_pPointGunAt = nextTarget;
- if (nextTarget)
- nextTarget->RegisterReference((CEntity**)&m_pPointGunAt);
+ SetWeaponLockOnTarget(nextTarget);
SetPointGunAt(nextTarget);
return true;
}
@@ -891,7 +889,7 @@ CPlayerPed::FindWeaponLockOnTarget(void)
if (m_pPointGunAt) {
CVector distVec = m_pPointGunAt->GetPosition() - GetPosition();
if (distVec.Magnitude2D() > weaponRange) {
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
return false;
} else {
return true;
@@ -922,9 +920,7 @@ CPlayerPed::FindWeaponLockOnTarget(void)
if (!nextTarget)
return false;
- m_pPointGunAt = nextTarget;
- if (nextTarget)
- nextTarget->RegisterReference((CEntity**)&m_pPointGunAt);
+ SetWeaponLockOnTarget(nextTarget);
SetPointGunAt(nextTarget);
return true;
}