1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-13 00:39:16 +00:00

CPed and CCivilianPed funcs done

This commit is contained in:
eray orçunus 2020-09-23 23:29:56 +03:00
parent 288f99d507
commit dbc458a4d7
7 changed files with 718 additions and 432 deletions

View file

@ -351,6 +351,18 @@ enum
MI_BLOODRA,
MI_BLOODRB,
MI_VICECHEE,
// 3 available vehicle slots in here
MI_LAST_VEHICLE = 239,
MI_CAR_DOOR = 240,
MI_CAR_BUMPER,
MI_CAR_PANEL,
MI_CAR_BONNET,
MI_CAR_BOOT,
MI_CAR_WHEEL,
MI_BODYPARTA,
MI_BODYPARTB,
// HACK
MI_TRAIN = -1,
MI_DODO = -2,
@ -398,15 +410,6 @@ enum
MI_CUTOBJ04,
MI_CUTOBJ05,
MI_CAR_DOOR = 240,
MI_CAR_BUMPER,
MI_CAR_PANEL,
MI_CAR_BONNET,
MI_CAR_BOOT,
MI_CAR_WHEEL,
MI_BODYPARTA,
MI_BODYPARTB,
MI_AIRTRAIN_VLO = 257,
MI_MOBILE = 258,

View file

@ -12,13 +12,33 @@
#include "Weather.h"
#include "PedAttractor.h"
#include "Object.h"
#include "CarCtrl.h"
#ifndef _WIN32
#include <float.h>
#endif
// --MIAMI: Done
CCivilianPed::CCivilianPed(ePedType pedtype, uint32 mi) : CPed(pedtype)
{
SetModelIndex(mi);
for (int i = 0; i < ARRAY_SIZE(m_nearPeds); i++) {
m_nearPeds[i] = nil;
}
m_bLookForVacantCars = false;
if (pedtype == PEDTYPE_CRIMINAL)
m_bLookForVacantCars = true;
m_nLookForVacantCarsCounter = 0;
m_bJustStoleACar = false;
m_bStealCarEvenIfThereIsSomeoneInIt = false;
for (int i = 0; i < ARRAY_SIZE(m_nStealWishList); i++) {
uint32 randomCarModel = CGeneral::GetRandomNumberInRange(MI_LANDSTAL, MI_LAST_VEHICLE + 1);
if (CModelInfo::IsCarModel(randomCarModel) || CModelInfo::IsBikeModel(randomCarModel))
m_nStealWishList[i] = randomCarModel;
else
m_nStealWishList[i] = MI_CHEETAH;
}
m_nAttractorCycleState = 0;
m_bAttractorUnk = (CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < 1.25f);
}
@ -384,7 +404,7 @@ CCivilianPed::ProcessControl(void)
CivilianAI();
if (CharCreatedBy == RANDOM_CHAR) {
// TODO(Miami): EnterVacantNearbyCars();
EnterVacantNearbyCars();
UseNearbyAttractors();
}
@ -483,3 +503,83 @@ bool CCivilianPed::IsAttractedTo(int8 type)
}
return false;
}
// --MIAMI: Done
void
CCivilianPed::EnterVacantNearbyCars(void)
{
if (!m_bLookForVacantCars)
return;
if (m_bJustStoleACar && bInVehicle && m_carInObjective == m_pMyVehicle) {
m_bJustStoleACar = false;
m_pMyVehicle->SetStatus(STATUS_PHYSICS);
m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE;
m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 10;
m_pMyVehicle->bEngineOn = true;
} else if (!bHasAlreadyStoleACar) {
if (m_nLookForVacantCarsCounter == 8) {
m_nLookForVacantCarsCounter = 0;
if (IsPedInControl() && m_objective == OBJECTIVE_NONE) {
CVehicle *foundCar = nil;
float closestDist = FLT_MAX;
int minX = CWorld::GetSectorIndexX(GetPosition().x - 10.0f);
if (minX < 0) minX = 0;
int minY = CWorld::GetSectorIndexY(GetPosition().y - 10.0f);
if (minY < 0) minY = 0;
int maxX = CWorld::GetSectorIndexX(GetPosition().x + 10.0f);
if (maxX > NUMSECTORS_X - 1) maxX = NUMSECTORS_X - 1;
int maxY = CWorld::GetSectorIndexY(GetPosition().y + 10.0f);
if (maxY > NUMSECTORS_Y - 1) maxY = NUMSECTORS_Y - 1;
for (int curY = minY; curY <= maxY; curY++) {
for (int curX = minX; curX <= maxX; curX++) {
CSector* sector = CWorld::GetSector(curX, curY);
for (CPtrNode* node = sector->m_lists[ENTITYLIST_VEHICLES].first; node; node = node->next) {
CVehicle* veh = (CVehicle*)node->item;
if (veh && veh->IsCar()) {
// Looks like PARKED_VEHICLE condition isn't there in Mobile.
if (veh->VehicleCreatedBy == RANDOM_VEHICLE || veh->VehicleCreatedBy == PARKED_VEHICLE) {
if (IsOnStealWishList(veh->GetModelIndex()) && !veh->IsLawEnforcementVehicle()
&& (m_bStealCarEvenIfThereIsSomeoneInIt || !veh->pDriver && !veh->m_nNumPassengers)
&& !veh->m_nNumGettingIn && !veh->m_nGettingInFlags && !veh->m_nGettingOutFlags
&& !veh->m_pCarFire && veh->m_fHealth > 800.0f
&& !veh->IsUpsideDown() && !veh->IsOnItsSide() && veh->CanPedEnterCar()) {
float dist = (GetPosition() - veh->GetPosition()).MagnitudeSqr();
if (dist < sq(10.0f) && dist < closestDist && veh->IsClearToDriveAway()) {
foundCar = veh;
closestDist = dist;
}
}
}
}
}
}
}
if (foundCar) {
m_bJustStoleACar = true;
bHasAlreadyStoleACar = true;
CCarCtrl::JoinCarWithRoadSystem(foundCar);
SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, foundCar);
SetObjectiveTimer(10000);
}
}
} else {
++m_nLookForVacantCarsCounter;
}
}
}
bool
CCivilianPed::IsOnStealWishList(int32 model)
{
for (int i = 0; i < ARRAY_SIZE(m_nStealWishList); i++) {
if (model == m_nStealWishList[i]) {
return true;
}
}
return false;
}

View file

@ -4,6 +4,11 @@
class CCivilianPed : public CPed
{
bool m_bLookForVacantCars;
uint32 m_nLookForVacantCarsCounter;
bool m_bStealCarEvenIfThereIsSomeoneInIt; // unused
bool m_bJustStoleACar;
uint32 m_nStealWishList[16];
bool m_bAttractorUnk;
int32 m_nAttractorCycleState;
public:
@ -15,6 +20,8 @@ public:
void UseNearbyAttractors(void);
void FindNearbyAttractorsSectorList(CPtrList&, float&, C2dEffect*&, CEntity*&);
bool IsAttractedTo(int8);
void EnterVacantNearbyCars(void);
bool IsOnStealWishList(int32);
};
#ifndef PED_SKIN
VALIDATE_SIZE(CCivilianPed, 0x53C);

File diff suppressed because it is too large Load diff

View file

@ -458,7 +458,7 @@ public:
uint32 bTurnedAroundOnAttractor : 1;
uint32 bHasAlreadyUsedAttractor : 1;
uint32 b155_2 : 1;
uint32 bHasAlreadyStoleACar : 1;
uint32 bCarPassenger : 1;
uint32 bFleeWhenStanding : 1;
uint32 bGotUpOfMyOwnAccord : 1;
@ -468,7 +468,7 @@ public:
uint32 bIsDrowning : 1;
uint32 bDrownsInWater : 1;
uint32 b156_4 : 1;
uint32 bWaitForLeaderToComeCloser : 1;
uint32 bHeldHostageInCar : 1;
uint32 bIsPlayerFriend : 1;
uint32 bHeadStuckInCollision : 1;
@ -809,7 +809,6 @@ public:
void GetNearestDoor(CVehicle*, CVector&);
bool GetNearestPassengerDoor(CVehicle*, CVector&);
int GetNextPointOnRoute(void);
uint8 GetPedRadioCategory(uint32);
int GetWeaponSlot(eWeaponType);
bool CanWeRunAndFireWithWeapon(void);
void GoToNearestDoor(CVehicle*);
@ -966,6 +965,8 @@ public:
void Dress(void);
int32 KillCharOnFootMelee(CVector&, CVector&, CVector&);
int32 KillCharOnFootArmed(CVector&, CVector&, CVector&);
void SetLook(CEntity* to);
void SetLook(float direction);
bool HasWeaponSlot(uint8 slot) { return m_weapons[slot].m_eWeaponType != WEAPONTYPE_UNARMED; }
CWeapon& GetWeapon(uint8 slot) { return m_weapons[slot]; }

View file

@ -16,7 +16,7 @@ enum ePedType
PEDTYPE_GANG4,
PEDTYPE_GANG5,
PEDTYPE_GANG6,
PEDTYPE_GANG7,
PEDTYPE_GANG7, // Vercetti gang
PEDTYPE_GANG8,
PEDTYPE_GANG9,
PEDTYPE_EMERGENCY,

View file

@ -134,7 +134,23 @@ public:
void ReduceHornCounter(void);
};
// These functions and function names are made up
inline int8 GetBikeDoorFlag(int32 carnode) {
switch (carnode) {
case CAR_DOOR_RR:
case CAR_DOOR_LR:
return CAR_DOOR_FLAG_RR | CAR_DOOR_FLAG_LR;
case CAR_DOOR_RF:
case CAR_DOOR_LF:
return CAR_DOOR_FLAG_RF | CAR_DOOR_FLAG_LF;
default:
return CAR_DOOR_FLAG_UNKNOWN;
}
}
// for m_nGettingOutFlags
inline int8 GetBikeDoorFlagInclJumpInFromFront(int32 carnode) {
switch (carnode) {
case CAR_DOOR_RR:
case CAR_DOOR_LR: