summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-05-17 20:43:11 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-05-17 20:43:11 +0200
commita5b84eb9fe32689f0aee10077854a3652c986c08 (patch)
treec8e5e5c72db293ca86bdadbc023f3997b05df947 /src/peds
parentMerge remote-tracking branch 'upstream/miami' into miami (diff)
downloadre3-a5b84eb9fe32689f0aee10077854a3652c986c08.tar
re3-a5b84eb9fe32689f0aee10077854a3652c986c08.tar.gz
re3-a5b84eb9fe32689f0aee10077854a3652c986c08.tar.bz2
re3-a5b84eb9fe32689f0aee10077854a3652c986c08.tar.lz
re3-a5b84eb9fe32689f0aee10077854a3652c986c08.tar.xz
re3-a5b84eb9fe32689f0aee10077854a3652c986c08.tar.zst
re3-a5b84eb9fe32689f0aee10077854a3652c986c08.zip
Diffstat (limited to 'src/peds')
-rw-r--r--src/peds/Ped.cpp68
-rw-r--r--src/peds/Ped.h5
-rw-r--r--src/peds/Population.cpp4
3 files changed, 43 insertions, 34 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 8da8249e..1d872b9c 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -534,6 +534,8 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
m_fAirResistance = 0.4f / m_fMass;
m_fElasticity = 0.05f;
+ m_ceaseAttackTimer = 0;
+
bIsStanding = false;
bWasStanding = false;
bIsAttacking = false;
@@ -6326,8 +6328,6 @@ CPed::CreateDeadPedMoney(void)
void
CPed::CreateDeadPedWeaponPickups(void)
{
- bool found = false;
- float angleToPed;
CVector pickupPos;
if (bInVehicle)
@@ -6340,34 +6340,10 @@ CPed::CreateDeadPedWeaponPickups(void)
if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || (weaponAmmo == 0 && !GetWeapon(i).IsTypeMelee()))
continue;
- angleToPed = i * 1.75f;
- pickupPos = GetPosition();
- pickupPos.x += 1.5f * Sin(angleToPed);
- pickupPos.y += 1.5f * Cos(angleToPed);
- pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
-
- CVector pedPos = GetPosition();
- pedPos.z += 0.3f;
-
- CVector pedToPickup = pickupPos - pedPos;
- float distance = pedToPickup.Magnitude();
-
- // outer edge of pickup
- distance = (distance + 0.3f) / distance;
- CVector pickupPos2 = pedPos;
- pickupPos2 += distance * pedToPickup;
-
- // pickup must be on ground and line to its edge must be clear
- if (!found || CWorld::GetIsLineOfSightClear(pickupPos2, pedPos, true, false, false, false, false, false, false)) {
- // otherwise try another position (but disregard second check apparently)
- angleToPed += 3.14f;
- pickupPos = GetPosition();
- pickupPos.x += 1.5f * Sin(angleToPed);
- pickupPos.y += 1.5f * Cos(angleToPed);
- pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
- }
- if (found)
- CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
+ CreateDeadPedPickupCoors(&pickupPos.x, &pickupPos.y, &pickupPos.z);
+ pickupPos.z += 0.4f;
+ // TODO(MIAMI): there is more stuff it seems
+ CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
}
ClearWeapons();
}
@@ -18466,4 +18442,36 @@ CPed::ClearFollowPath()
}
m_nPathNodes = 0;
m_nCurPathNode = 0;
+}
+
+void
+CPed::CreateDeadPedPickupCoors(float* x, float* y, float* z)
+{
+ for (int i = 0; i < 32; i++) {
+ CVector pickupPos = GetPosition();
+ pickupPos.x += 1.5f * Sin(CGeneral::GetRandomNumberInRange(0.0f, TWOPI));
+ pickupPos.y += 1.5f * Cos(CGeneral::GetRandomNumberInRange(0.0f, TWOPI));
+ bool found;
+ pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
+ if (!found)
+ continue;
+ CVector vPedPos = GetPosition();
+ vPedPos.z += 0.3f;
+ CVector vTestPos = vPedPos + (pickupPos - vPedPos) * (((pickupPos - vPedPos).Magnitude() + 0.4f) / (pickupPos - vPedPos).Magnitude());
+ if ((vTestPos - FindPlayerCoors()).Magnitude2D() > 2.0f || i > 16) {
+ if (i > 16 || CPickups::TestForPickupsInBubble(pickupPos, 1.3f)) {
+ if (CWorld::GetIsLineOfSightClear(vTestPos, vPedPos, true, i < 16, false, i < 16, false, false)) {
+ if (i > 16 || !CWorld::TestSphereAgainstWorld(pickupPos, 1.2f, nil, false, true, false, false, false, false)) {
+ *x = pickupPos.x;
+ *y = pickupPos.y;
+ *z = pickupPos.z;
+ return;
+ }
+ }
+ }
+ }
+ }
+ *x = GetPosition().x;
+ *y = GetPosition().y;
+ *z = GetPosition().z + 0.4f;
} \ No newline at end of file
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 32557cb6..63e60991 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -209,7 +209,7 @@ enum eObjective : uint32 {
OBJECTIVE_LEAVE_CAR_AND_DIE,
OBJECTIVE_USE_SEAT_ATTRACTOR,
OBJECTIVE_USE_ATM_ATTRACTOR,
- OBJECTIVE_FLEE_CAR, // is it 41?
+ OBJECTIVE_FLEE_CAR,
OBJ_42,
OBJECTIVE_USE_STOP_ATTRACTOR,
OBJECTIVE_USE_PIZZA_ATTRACTOR,
@@ -550,7 +550,7 @@ public:
uint32 m_duckAndCoverTimer;
uint32 m_bloodyFootprintCountOrDeathTime; // Death time when bDoBloodyFootprints is false. Weird decision
uint32 m_shotTime;
- uint32 m_shotTimeAdd;
+ uint32 m_ceaseAttackTimer;
uint8 m_panicCounter;
bool m_deadBleeding;
int8 m_bodyPartBleeding; // PedNode, but -1 if there isn't
@@ -865,6 +865,7 @@ public:
void SetNewAttraction(CPedAttractor* pAttractor, const CVector& pos, float, float, int);
void ClearWaitState(void);
+ void CreateDeadPedPickupCoors(float* x, float* y, float* z);
bool HasWeaponSlot(uint8 slot) { return m_weapons[slot].m_eWeaponType != WEAPONTYPE_UNARMED; }
CWeapon& GetWeapon(uint8 slot) { return m_weapons[slot]; }
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index 1c613acc..9d8d65dd 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -722,7 +722,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
}
CPed*
-CPopulation::AddPedInCar(CVehicle* car, bool isPassenger)
+CPopulation::AddPedInCar(CVehicle* car, bool isDriver)
{
int defaultModel = MI_MALE01;
int miamiViceIndex = 0;
@@ -765,7 +765,7 @@ CPopulation::AddPedInCar(CVehicle* car, bool isPassenger)
case MI_VICECHEE: // TODO(MIAMI): figure out new structure of the function
preferredModel = COP_MIAMIVICE;
pedType = PEDTYPE_COP;
- miamiViceIndex = (isPassenger ? 2 * CCarCtrl::MiamiViceCycle : 2 * CCarCtrl::MiamiViceCycle + 1);
+ miamiViceIndex = (isDriver ? 2 * CCarCtrl::MiamiViceCycle : 2 * CCarCtrl::MiamiViceCycle + 1);
break;
case MI_TAXI:
case MI_CABBIE: