summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
Diffstat (limited to 'src/peds')
-rw-r--r--src/peds/Ped.cpp75
-rw-r--r--src/peds/Ped.h54
-rw-r--r--src/peds/PedAI.cpp2
3 files changed, 118 insertions, 13 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index f5123b39..8be58d66 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -9447,8 +9447,10 @@ CPed::SetRadioStation(void)
// --MIAMI: Done
void
-CPed::WarpPedIntoCar(CVehicle *car)
+CPed::WarpPedIntoCar(CVehicle *car) // LCS TODO: remove passenger logic
{
+ if (GetPedState() == PED_FACE_PHONE)
+ QuitEnteringCar();
bInVehicle = true;
m_pMyVehicle = car;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
@@ -9513,6 +9515,77 @@ CPed::WarpPedIntoCar(CVehicle *car)
bChangedSeat = true;
}
+void
+CPed::WarpPedIntoCarAsPassenger(CVehicle* pVehicle, int32 position)
+{
+ if (GetPedState() == PED_FACE_PHONE)
+ QuitEnteringCar();
+ bInVehicle = true;
+ m_pMyVehicle = pVehicle;
+ m_pMyVehicle->RegisterReference((CEntity**)&m_pMyVehicle);
+ m_carInObjective = pVehicle;
+ m_carInObjective->RegisterReference((CEntity**)&m_carInObjective);
+ SetPedState(PED_DRIVING); // TODO: this is PED_PASSENGER, but it needs to have some logic applied first
+ bUsesCollision = false;
+ bIsInTheAir = false;
+ bVehExitWillBeInstant = true;
+ if (pVehicle->IsBike() && !pVehicle->pPassengers[0]) {
+ pVehicle->pPassengers[0] = this;
+ pVehicle->pPassengers[0]->RegisterReference((CEntity**)&pVehicle->pPassengers[0]);
+ }
+ if (position >= 0) {
+ if (!pVehicle->pPassengers[position]) {
+ pVehicle->pPassengers[position] = this;
+ pVehicle->pPassengers[position]->RegisterReference((CEntity**)&pVehicle->pPassengers[position]);
+ }
+ }
+ else {
+ for (int i = 0; i < 4; i++) {
+ if (!pVehicle->pPassengers[i]) {
+ pVehicle->pPassengers[i] = this;
+ pVehicle->pPassengers[i]->RegisterReference((CEntity**)&pVehicle->pPassengers[i]);
+ break;
+ }
+ }
+ }
+
+ if (IsPlayer()) {
+ pVehicle->SetStatus(STATUS_PLAYER);
+ AudioManager.PlayerJustGotInCar();
+ CCarCtrl::RegisterVehicleOfInterest(pVehicle);
+ }
+ else {
+ pVehicle->SetStatus(STATUS_PHYSICS);
+ }
+
+ CWorld::Remove(this);
+ SetPosition(pVehicle->GetPosition());
+ CWorld::Add(this);
+
+ if (pVehicle->bIsAmbulanceOnDuty) {
+ pVehicle->bIsAmbulanceOnDuty = false;
+ --CCarCtrl::NumAmbulancesOnDuty;
+ }
+ if (pVehicle->bIsFireTruckOnDuty) {
+ pVehicle->bIsFireTruckOnDuty = false;
+ --CCarCtrl::NumFiretrucksOnDuty;
+ }
+ if (!pVehicle->bEngineOn) {
+ pVehicle->bEngineOn = true;
+ DMAudio.PlayOneShot(pVehicle->m_audioEntityId, SOUND_CAR_ENGINE_START, 1.0f);
+ }
+
+ RpAnimBlendClumpSetBlendDeltas(GetClump(), ASSOC_PARTIAL, -1000.0f);
+
+ AddInCarAnims(pVehicle, pVehicle->pDriver == this);
+ RemoveWeaponWhenEnteringVehicle();
+
+ if (pVehicle->bIsBus)
+ bRenderPedInCar = false;
+
+ bChangedSeat = true;
+}
+
// --MIAMI: Done
bool
CPed::HasAttractor(void)
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 242a86f2..1acd571b 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -406,7 +406,7 @@ public:
float m_fCollisionSpeed;
// cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CPed.h from R*
- uint32 bIsStanding : 1;
+ uint32 bIsStanding : 1; // 0x194 on PS2, 0x1A4 on android
uint32 bWasStanding : 1;
uint32 bIsAttacking : 1; // doesn't reset after fist fight
uint32 bIsPointingGunAt : 1;
@@ -499,7 +499,7 @@ public:
uint32 bIsDrowning : 1;
uint32 bDrownsInWater : 1;
uint32 bWaitForLeaderToComeCloser : 1;
- uint32 bHeldHostageInCar : 1;
+ uint32 bHeldHostageInCar : 1; // one flag was added somewhere after this one (TODO: figure out where and which)
uint32 bIsPlayerFriend : 1;
uint32 bHeadStuckInCollision : 1;
uint32 bDeadPedInFrontOfCar : 1;
@@ -512,7 +512,7 @@ public:
uint32 bMakeFleeScream : 1;
uint32 bPushedAlongByCar : 1;
uint32 bRemoveMeWhenIGotIntoCar : 1;
- uint32 bIgnoreThreatsBehindObjects : 1;
+ uint32 bIgnoreThreatsBehindObjects : 1; // one flag was added somewhere before this one (TODO: figure out where and which)
uint32 bNeverEverTargetThisPed : 1;
uint32 bCrouchWhenScared : 1;
@@ -523,22 +523,40 @@ public:
uint32 bDonePositionOutOfCollision : 1;
uint32 bCanAttackPlayerWithCops : 1; // 1A1_1 on PS2
- uint32 b1A1_2 : 1;
- uint32 b1A1_4 : 1;
+ uint32 bOnlyAllowedToSitBehind : 1;
+ uint32 bOnlyAllowedToSitInFront : 1;
uint32 b1A1_8 : 1;
uint32 b1A1_10 : 1;
- uint32 b1A1_20 : 1;
+ uint32 bOverrideMoveAnim : 1;
#ifdef KANGAROO_CHEAT
// our own flags
uint32 m_ped_flagI80 : 1; // KANGAROO_CHEAT define makes use of this as cheat toggle
#endif
- uint8 m_gangFlags;
- uint8 m_unused15D; // these 3 can't be padding but had to actually have been members ...
- uint8 m_unused15E;
- uint8 m_unused15F;
- uint8 CharCreatedBy;
+ uint16 m_gangFlags; // <- this one is uint16
+
+ uint8 bDropsWeaponsOnDeath : 1;
+ uint8 b1A4_2 : 1;
+ uint8 bAttacksPlayerWithCops : 1;
+ uint8 b1A4_8 : 1;
+ uint8 b1A4_10 : 1;
+ uint8 b1A4_20 : 1;
+ uint8 b1A4_40 : 1;
+ uint8 b1A4_80 : 1;
+
+ uint8 bCanBeTargettedByLeader : 1;
+ uint8 b1A5_2 : 1;
+ uint8 b1A5_4 : 1;
+ uint8 b1A5_8 : 1;
+ uint8 b1A5_10 : 1;
+ uint8 b1A5_20 : 1;
+ uint8 b1A5_40 : 1;
+ uint8 b1A5_80 : 1;
+
+ uint8 unk_1A6; // <- init with 100 in constructor
+
+ uint8 CharCreatedBy; // 1AC
eObjective m_objective;
eObjective m_prevObjective;
CPed *m_pedInObjective;
@@ -587,6 +605,8 @@ public:
float m_fHealth;
float m_fArmour;
uint32 m_nExtendedRangeTimer;
+ uint32 m_nScriptShootTimer;
+ uint32 m_nScriptAttackTimer;
int16 m_routeLastPoint;
uint16 m_routeStartPoint;
int16 m_routePointsPassed;
@@ -686,6 +706,7 @@ public:
uint32 m_lastComment;
CVector m_vecSpotToGuard;
float m_radiusToGuard;
+ float m_fMaxHealth;
static void *operator new(size_t);
static void *operator new(size_t, int);
@@ -888,6 +909,7 @@ public:
void SetSolicit(uint32 time);
void ScanForInterestingStuff(void);
void WarpPedIntoCar(CVehicle*);
+ void WarpPedIntoCarAsPassenger(CVehicle*, int32);
void SetCarJack(CVehicle*);
bool WarpPedToNearLeaderOffScreen(void);
void Solicit(void);
@@ -1042,6 +1064,16 @@ public:
{
return m_pMyVehicle != nil && ((CEntity*)m_pMyVehicle)->GetStatus() != STATUS_WRECKED;
}
+ bool CanStartMission() // used in CAN_PLAYER_START_MISSION and can looks like inlined function
+ {
+ if (m_nPedState >= PED_WANDER_RANGE && m_nPedState < PED_STATES_NO_AI && m_nPedState != PED_ANSWER_MOBILE)
+ return false;
+ if (m_nPedState >= PED_JUMP && m_nPedState < PED_STATES_NO_ST)
+ return false;
+ if (m_nPedState >= PED_ENTER_TRAIN && m_nPedState < PED_DEPLOY_STINGER)
+ return false;
+ return !bIsInTheAir && !bIsLanding && m_fHealth > 0.0f;
+ }
// My names. Inlined in VC
AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) {
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index cd1befd9..8b832670 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -6487,7 +6487,7 @@ CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWith
}
}
if (m_pedInObjective->IsPlayer() && m_nPedType != PEDTYPE_COP
- && CharCreatedBy != MISSION_CHAR && FindPlayerPed()->m_pWanted->m_CurrentCops != 0) {
+ && CharCreatedBy != MISSION_CHAR && FindPlayerPed()->m_pWanted->m_CurrentCops != 0/* TODO: && !bAttacksPlayerWithCops*/) {
SetObjective(OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE);
return CANT_ATTACK;