summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/control/Script.cpp112
-rw-r--r--src/core/Stats.cpp12
-rw-r--r--src/core/Stats.h7
-rw-r--r--src/entities/Physical.cpp2
-rw-r--r--src/peds/Ped.cpp252
-rw-r--r--src/peds/Ped.h25
-rw-r--r--src/vehicles/Bike.cpp26
7 files changed, 264 insertions, 172 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 76264617..686154fa 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -1531,7 +1531,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
CPed* pTestedPed = ped->m_nearPeds[i];
if (!pTestedPed || !IsPedPointerValid(pTestedPed))
continue;
- if (pTestedPed->m_pedInObjective == ped && pTestedPed->m_objective == OBJ_15) {
+ if (pTestedPed->m_pedInObjective == ped && pTestedPed->m_objective == OBJECTIVE_FOLLOW_PED_IN_FORMATION) {
CVector vFollowerPos = pTestedPed->GetFormationPosition();
CTheScripts::ClearSpaceForMissionEntity(vFollowerPos, ped);
bool bFound = false;
@@ -1681,11 +1681,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
- case COMMAND_MULT_INT_LVAR_BY_INT_VAR:
+ case COMMAND_MULT_INT_VAR_BY_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
- case COMMAND_MULT_INT_VAR_BY_INT_LVAR:
+ case COMMAND_MULT_INT_LVAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 *= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -1697,11 +1697,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
- case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR:
+ case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
- case COMMAND_MULT_FLOAT_VAR_BY_FLOAT_LVAR:
+ case COMMAND_MULT_FLOAT_LVAR_BY_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 *= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -1713,11 +1713,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
- case COMMAND_DIV_INT_LVAR_BY_INT_VAR:
+ case COMMAND_DIV_INT_VAR_BY_INT_LVAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
- case COMMAND_DIV_INT_VAR_BY_INT_LVAR:
+ case COMMAND_DIV_INT_LVAR_BY_INT_VAR:
nScriptVar1 = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*nScriptVar1 /= *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -1729,11 +1729,11 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
- case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR:
+ case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
- case COMMAND_DIV_FLOAT_VAR_BY_FLOAT_LVAR:
+ case COMMAND_DIV_FLOAT_LVAR_BY_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 /= *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -1759,11 +1759,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
+#ifdef FIX_BUGS
+ case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
+#else
case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR:
+#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
+#ifdef FIX_BUGS
+ case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR:
+#else
case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
+#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -1789,11 +1797,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
+#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum
+ case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
+#else
case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR:
+#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
+#ifdef FIX_BUGS
+ case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR:
+#else
case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
+#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -1807,13 +1823,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
}
- case COMMAND_SET_LVAR_INT_TO_VAR_INT:
+ case COMMAND_SET_VAR_INT_TO_LVAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
}
- case COMMAND_SET_VAR_INT_TO_LVAR_INT:
+ case COMMAND_SET_LVAR_INT_TO_VAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@@ -1831,13 +1847,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
}
- case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT:
+ case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
}
- case COMMAND_SET_VAR_FLOAT_TO_LVAR_FLOAT:
+ case COMMAND_SET_LVAR_FLOAT_TO_VAR_FLOAT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@@ -1855,13 +1871,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
}
- case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT:
+ case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
}
- case COMMAND_CSET_VAR_INT_TO_LVAR_FLOAT:
+ case COMMAND_CSET_LVAR_INT_TO_VAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@@ -1879,13 +1895,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
}
- case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT:
+ case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
}
- case COMMAND_CSET_VAR_FLOAT_TO_LVAR_INT:
+ case COMMAND_CSET_LVAR_FLOAT_TO_VAR_INT:
{
float* ptr = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*ptr = *GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
@@ -10678,7 +10694,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]);
assert(pTargetPed);
pPed->bScriptObjectiveCompleted = false;
- pPed->SetObjective(OBJECTIVE_FOLLOW_PED_IN_FORMATION, pPed);
+ pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING, pPed);
return 0;
}
//case COMMAND_IS_PICKUP_IN_ZONE:
@@ -10713,8 +10729,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]);
assert(pTargetPed);
pPed->bScriptObjectiveCompleted = false;
- debug("SET_CHAR_OBJ_AIM_GUN_AT_CHAR is not implemented\n");
- //pPed->SetObjective(OBJECTIVE_AIM_GUN_AT_PED, pTargetPed); // TODO(MIAMI) -- when objective is implemented
+ pPed->SetObjective(OBJECTIVE_AIM_GUN_AT_PED, pTargetPed);
return 0;
}
case COMMAND_SWITCH_SECURITY_CAMERA:
@@ -10757,13 +10772,22 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_SET_HELI_ORIENTATION:
{
CollectParameters(&m_nIp, 2);
- debug("SET_HELI_ORIENTATION is not implemented\n"); // TODO(MIAMI);
+ CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
+ float fAngle = DEGTORAD(*(float*)&ScriptParams[1] - 90.0f);
+ while (fAngle < 0.0f)
+ fAngle += TWOPI;
+ while (fAngle > TWOPI)
+ fAngle -= TWOPI;
+ pHeli->SetHeliOrientation(fAngle);
return 0;
}
case COMMAND_CLEAR_HELI_ORIENTATION:
{
CollectParameters(&m_nIp, 1);
- debug("SET_HELI_ORIENTATION is not implemented\n"); // TODO(MIAMI);
+ CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
+ pHeli->ClearHeliOrientation();
return 0;
}
case COMMAND_PLANE_GOTO_COORDS:
@@ -10864,9 +10888,10 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_POP_CAR_BOOT:
{
CollectParameters(&m_nIp, 1);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
- assert(pVehicle);
- debug("POP_CAR_BOOT is not implemented\n"); // TODO(MIAMI)
+ CollectParameters(&m_nIp, 1);
+ CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pCar&& pCar->IsCar());
+ pCar->PopBoot();
return 0;
}
case COMMAND_SHUT_PLAYER_UP:
@@ -11122,14 +11147,13 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
pos.y = *(float*)&ScriptParams[2];
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pPed->bScriptObjectiveCompleted = false;
- debug("SET_CHAR_OBJ_SPRINT_TO_COORD is not implemented\n");
- //pPed->SetObjective(OBJECTIVE_SPRINT_TO_COORD, pos); // TODO(MIAMI) -- when objective is implemented
+ pPed->SetObjective(OBJECTIVE_SPRINT_TO_COORD, pos);
return 0;
}
case COMMAND_CREATE_SWAT_ROPE:
{
CollectParameters(&m_nIp, 3);
- debug("SET_CHAR_OBJ_SPRINT_TO_COORD is not implemented\n");
+ debug("CREATE_SWAT_ROPE is not implemented\n");
return 0;
}
//case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA:
@@ -11149,7 +11173,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_CLOSE_ALL_CAR_DOORS:
{
CollectParameters(&m_nIp, 1);
- debug("CLOSE_ALL_CAR_DOORS is not implemented\n"); // TODO(MIAMI)
+ CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pCar&& pCar->IsCar());
+ pCar->CloseAllDoors();
return 0;
}
case COMMAND_GET_DISTANCE_BETWEEN_COORDS_2D:
@@ -11169,7 +11195,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_POP_CAR_BOOT_USING_PHYSICS:
{
CollectParameters(&m_nIp, 1);
- debug("POP_CAR_BOOT_USING_PHYSICS is not implemented\n"); // TODO(MIAMI)
+ CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pCar && pCar->IsCar());
+ pCar->PopBootUsingPhysics();
return 0;
}
//case COMMAND_SET_FIRST_PERSON_WEAPON_CAMERA:
@@ -11713,7 +11741,9 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_MAKE_HELI_COME_CRASHING_DOWN:
{
CollectParameters(&m_nIp, 1);
- debug("MAKE_HELI_COME_CRASHING_DOWN is not implemented\n");
+ CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
+ pHeli->bHeliDestroyed = true;
return 0;
}
case COMMAND_ADD_EXPLOSION_NO_SOUND:
@@ -11761,18 +11791,18 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
- debug("SET_CHAR_CROUCH_WHEN_THREATENED not implemented, skipping\n");
+ assert(pPed);
+ pPed->bCrouchWhenScared = true;
return 0;
}
case COMMAND_IS_CHAR_IN_ANY_POLICE_VEHICLE:
{
CollectParameters(&m_nIp, 1);
- static bool bShowed = false;
- if (!bShowed) {
- debug("IS_CHAR_IN_ANY_POLICE_VEHICLE not implemented, default to FALSE\n");
- bShowed = true;
- }
- UpdateCompareFlag(false);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle &&
+ pPed->m_pMyVehicle->IsLawEnforcementVehicle() &&
+ pPed->m_pMyVehicle->GetModelIndex() != MI_PREDATOR);
return 0;
}
case COMMAND_DOES_CHAR_EXIST:
@@ -11803,7 +11833,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_SET_ALL_TAXIS_HAVE_NITRO:
{
CollectParameters(&m_nIp, 1);
- debug("SET_ALL_TAXIS_HAVE_NITRO is not implemented\n"); // TODO(MIAMI)
+ CVehicle::bAllTaxisHaveNitro = ScriptParams[0] != 0;
return 0;
}
case COMMAND_SET_CHAR_STOP_SHOOT_DONT_SEEK_ENTITY:
@@ -11900,7 +11930,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_PLAY_ANNOUNCEMENT:
{
CollectParameters(&m_nIp, 1);
- debug("PLAY_ANNOUNCEMENT not implemented, skipping\n");
+ DMAudio.PlayRadioAnnouncement(ScriptParams[0] + STREAMED_SOUND_ANNOUNCE_BRIDGE_CLOSED);
return 0;
}
case COMMAND_SET_PLAYER_IS_IN_STADIUM:
@@ -11942,7 +11972,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
return 0;
case COMMAND_REGISTER_BEST_POSITION:
CollectParameters(&m_nIp, 2);
- debug("REGISTER_BEST_POSITION not implemented\n");
+ CStats::RegisterBestPosition(ScriptParams[0], ScriptParams[1]);
return 0;
case COMMAND_IS_PLAYER_IN_INFO_ZONE:
{
diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp
index 91f583bd..5b590016 100644
--- a/src/core/Stats.cpp
+++ b/src/core/Stats.cpp
@@ -60,6 +60,7 @@ int32 CStats::mmRain;
int32 CStats::CarsCrushed;
int32 CStats::FastestTimes[CStats::TOTAL_FASTEST_TIMES];
int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES];
+int32 CStats::BestPositions[CStats::TOTAL_BEST_POSITIONS];
int32 CStats::PropertyDestroyed;
int32 CStats::Sprayings;
@@ -119,6 +120,8 @@ void CStats::Init()
FastestTimes[i] = 0;
for (int i = 0; i < TOTAL_HIGHEST_SCORES; i++)
HighestScores[i] = 0;
+ for (int i = 0; i < TOTAL_BEST_POSITIONS; i++)
+ BestPositions[i] = INT_MAX;
for (int i = 0; i < NUM_PEDTYPES; i++)
PedsKilledOfThisType[i] = 0;
IndustrialPassed = 0;
@@ -146,6 +149,12 @@ void CStats::RegisterHighestScore(int32 index, int32 score)
HighestScores[index] = Max(HighestScores[index], score);
}
+void CStats::RegisterBestPosition(int32 index, int32 position)
+{
+ assert(index >= 0 && index < TOTAL_BEST_POSITIONS);
+ BestPositions[index] = Min(BestPositions[index], position);
+}
+
void CStats::RegisterElBurroTime(int32 time)
{
ElBurroTime = (ElBurroTime && ElBurroTime < time) ? ElBurroTime : time;
@@ -323,6 +332,7 @@ void CStats::SaveStats(uint8 *buf, uint32 *size)
sizeof(TotalNumberMissions) +
sizeof(FastestTimes) +
sizeof(HighestScores) +
+ sizeof(BestPositions) +
sizeof(KillsSinceLastCheckpoint) +
sizeof(TotalLegitimateKills) +
sizeof(LastMissionPassedName);
@@ -377,6 +387,7 @@ void CStats::SaveStats(uint8 *buf, uint32 *size)
CopyToBuf(buf, TotalNumberMissions);
CopyToBuf(buf, FastestTimes);
CopyToBuf(buf, HighestScores);
+ CopyToBuf(buf, BestPositions);
CopyToBuf(buf, KillsSinceLastCheckpoint);
CopyToBuf(buf, TotalLegitimateKills);
CopyToBuf(buf, LastMissionPassedName);
@@ -440,6 +451,7 @@ void CStats::LoadStats(uint8 *buf, uint32 size)
CopyFromBuf(buf, TotalNumberMissions);
CopyFromBuf(buf, FastestTimes);
CopyFromBuf(buf, HighestScores);
+ CopyFromBuf(buf, BestPositions);
CopyFromBuf(buf, KillsSinceLastCheckpoint);
CopyFromBuf(buf, TotalLegitimateKills);
CopyFromBuf(buf, LastMissionPassedName);
diff --git a/src/core/Stats.h b/src/core/Stats.h
index 33d4ef72..8588fef1 100644
--- a/src/core/Stats.h
+++ b/src/core/Stats.h
@@ -6,8 +6,9 @@ class CStats
{
public:
enum {
- TOTAL_FASTEST_TIMES = 16,
- TOTAL_HIGHEST_SCORES = 16
+ TOTAL_FASTEST_TIMES = 23,
+ TOTAL_HIGHEST_SCORES = 5,
+ TOTAL_BEST_POSITIONS = 1
};
//TODO
static int32 SeagullsKilled;
@@ -65,6 +66,7 @@ public:
static int32 CarsCrushed;
static int32 FastestTimes[TOTAL_FASTEST_TIMES];
static int32 HighestScores[TOTAL_HIGHEST_SCORES];
+ static int32 BestPositions[TOTAL_BEST_POSITIONS];
static int32 PropertyDestroyed;
static int32 Sprayings;
static float AutoPaintingBudget;
@@ -77,6 +79,7 @@ public:
static void Init(void);
static void RegisterFastestTime(int32, int32);
static void RegisterHighestScore(int32, int32);
+ static void RegisterBestPosition(int32, int32);
static void RegisterElBurroTime(int32);
static void Register4x4OneTime(int32);
static void Register4x4TwoTime(int32);
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 090eae6b..12345cc9 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -1610,7 +1610,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
A->bSkipLineCol = true;
}else if(A->IsPed() && Aped->m_pCollidingEntity == B){
skipCollision = true;
- if(!Aped->bKnockedUpIntoAir || Aped->b158_4)
+ if(!Aped->bKnockedUpIntoAir || Aped->bKnockedOffBike)
A->bSkipLineCol = true;
}else if(B->IsPed() && Bped->m_pCollidingEntity == A){
skipCollision = true;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 70e6303e..744ba793 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -2821,14 +2821,13 @@ CPed::CanSeeEntity(CEntity *entity, float threshold = CAN_SEE_ENTITY_ANGLE_THRES
return neededTurn < threshold || TWOPI - threshold < neededTurn;
}
+// --MIAMI: Done
bool
CPed::IsTemporaryObjective(eObjective objective)
{
return objective == OBJECTIVE_LEAVE_VEHICLE || objective == OBJECTIVE_SET_LEADER ||
-#ifdef VC_PED_PORTS
- objective == OBJECTIVE_LEAVE_CAR_AND_DIE ||
-#endif
- objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER;
+ objective == OBJECTIVE_LEAVE_CAR_AND_DIE || objective == OBJECTIVE_ENTER_CAR_AS_DRIVER ||
+ objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER;
}
void
@@ -2837,6 +2836,7 @@ CPed::SetMoveState(eMoveState state)
m_nMoveState = state;
}
+// --MIAMI: Done
void
CPed::SetObjectiveTimer(int time)
{
@@ -2847,6 +2847,7 @@ CPed::SetObjectiveTimer(int time)
}
}
+// --MIAMI: Done
void
CPed::ForceStoredObjective(eObjective objective)
{
@@ -2855,49 +2856,65 @@ CPed::ForceStoredObjective(eObjective objective)
return;
}
- switch (m_objective)
- {
+ switch (m_objective) {
case OBJECTIVE_FLEE_TILL_SAFE:
case OBJECTIVE_KILL_CHAR_ON_FOOT:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS:
case OBJECTIVE_GOTO_CHAR_ON_FOOT:
+ case OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING:
+ case OBJECTIVE_HASSLE_CHAR:
case OBJECTIVE_ENTER_CAR_AS_PASSENGER:
case OBJECTIVE_ENTER_CAR_AS_DRIVER:
case OBJECTIVE_GOTO_AREA_ON_FOOT:
case OBJECTIVE_RUN_TO_AREA:
+ case OBJECTIVE_USE_SEAT_ATTRACTOR:
+ case OBJECTIVE_USE_ATM_ATTRACTOR:
+ case OBJECTIVE_USE_STOP_ATTRACTOR:
+ case OBJECTIVE_USE_PIZZA_ATTRACTOR:
+ case OBJECTIVE_USE_SHELTER_ATTRACTOR:
+ case OBJECTIVE_SPRINT_TO_COORD:
+ case OBJECTIVE_USE_ICECREAM_ATTRACTOR:
return;
default:
m_prevObjective = m_objective;
}
}
+// --MIAMI: Done
void
CPed::SetStoredObjective(void)
{
if (m_objective == m_prevObjective)
return;
- switch (m_objective)
- {
+ switch (m_objective) {
case OBJECTIVE_FLEE_TILL_SAFE:
case OBJECTIVE_KILL_CHAR_ON_FOOT:
case OBJECTIVE_KILL_CHAR_ANY_MEANS:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS:
case OBJECTIVE_GOTO_CHAR_ON_FOOT:
- case OBJECTIVE_FOLLOW_PED_IN_FORMATION:
- case OBJECTIVE_LEAVE_VEHICLE:
+ case OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING:
+ case OBJECTIVE_HASSLE_CHAR:
case OBJECTIVE_ENTER_CAR_AS_PASSENGER:
case OBJECTIVE_ENTER_CAR_AS_DRIVER:
case OBJECTIVE_GOTO_AREA_ON_FOOT:
case OBJECTIVE_RUN_TO_AREA:
+ case OBJECTIVE_USE_SEAT_ATTRACTOR:
+ case OBJECTIVE_USE_ATM_ATTRACTOR:
+ case OBJECTIVE_USE_STOP_ATTRACTOR:
+ case OBJECTIVE_USE_PIZZA_ATTRACTOR:
+ case OBJECTIVE_USE_SHELTER_ATTRACTOR:
+ case OBJECTIVE_SPRINT_TO_COORD:
+ case OBJECTIVE_USE_ICECREAM_ATTRACTOR:
return;
default:
m_prevObjective = m_objective;
}
}
+// --MIAMI: Done
void
CPed::RestorePreviousObjective(void)
{
@@ -2905,10 +2922,7 @@ CPed::RestorePreviousObjective(void)
return;
if (m_objective != OBJECTIVE_LEAVE_VEHICLE && m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER
-#ifdef VC_PED_PORTS
- && m_nPedState != PED_CARJACK
-#endif
- )
+ && m_nPedState != PED_CARJACK)
m_pedInObjective = nil;
if (m_objective == OBJECTIVE_WAIT_IN_CAR_THEN_GETOUT) {
@@ -2932,6 +2946,7 @@ CPed::SetLeader(CEntity *leader)
m_leader->RegisterReference((CEntity **)&m_leader);
}
+// TODO(Miami)
void
CPed::SetObjective(eObjective newObj, void *entity)
{
@@ -2947,7 +2962,6 @@ CPed::SetObjective(eObjective newObj, void *entity)
if (entity == this)
return;
- SetObjectiveTimer(0);
if (m_objective == newObj) {
switch (newObj) {
case OBJECTIVE_KILL_CHAR_ON_FOOT:
@@ -2958,7 +2972,6 @@ CPed::SetObjective(eObjective newObj, void *entity)
case OBJECTIVE_FIGHT_CHAR:
if (m_pedInObjective == entity)
return;
-
break;
case OBJECTIVE_LEAVE_VEHICLE:
case OBJECTIVE_FLEE_CAR:
@@ -2973,12 +2986,14 @@ CPed::SetObjective(eObjective newObj, void *entity)
case OBJECTIVE_BUY_ICE_CREAM:
if (m_carInObjective == entity)
return;
-
break;
case OBJECTIVE_SET_LEADER:
if (m_leader == entity)
return;
-
+ break;
+ case OBJECTIVE_AIM_GUN_AT_PED:
+ if (m_pedInObjective == entity)
+ return;
break;
default:
break;
@@ -2992,9 +3007,8 @@ CPed::SetObjective(eObjective newObj, void *entity)
return;
}
-#ifdef VC_PED_PORTS
ClearPointGunAt();
-#endif
+ m_objectiveTimer = 0;
bObjectiveCompleted = false;
if (!IsTemporaryObjective(m_objective) || IsTemporaryObjective(newObj)) {
if (m_objective != newObj) {
@@ -3028,6 +3042,8 @@ CPed::SetObjective(eObjective newObj, void *entity)
case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS:
case OBJECTIVE_GOTO_CHAR_ON_FOOT:
+ case OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING:
+ case OBJECTIVE_HASSLE_CHAR:
case OBJECTIVE_FIGHT_CHAR:
m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f);
m_pedInObjective = (CPed*)entity;
@@ -3087,6 +3103,10 @@ CPed::SetObjective(eObjective newObj, void *entity)
SetLeader((CEntity*)entity);
RestorePreviousObjective();
break;
+ case OBJECTIVE_AIM_GUN_AT_PED:
+ m_pedInObjective = (CPed*)entity;
+ m_pedInObjective->RegisterReference((CEntity**)&m_pedInObjective);
+ break;
default:
break;
}
@@ -3109,21 +3129,16 @@ CPed::SetIdle(void)
}
}
+// --MIAMI: Done
void
CPed::SetObjective(eObjective newObj)
{
- if (DyingOrDead())
+ if (DyingOrDead() || m_attachedTo)
return;
if (newObj == OBJECTIVE_NONE) {
if ((m_objective == OBJECTIVE_LEAVE_VEHICLE || m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER
-#ifdef VC_PED_PORTS
- || m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE)
- && !IsPlayer()
-#else
- )
-#endif
- && !IsPedInControl()) {
+ || m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) && !IsPlayer() && !IsPedInControl()) {
bStartWanderPathOnFoot = true;
return;
@@ -3200,6 +3215,7 @@ CPed::SetObjective(eObjective newObj, int16 routePoint, int16 routeType)
}
}
+// --MIAMI: Done
void
CPed::ClearChat(void)
{
@@ -3211,6 +3227,11 @@ CPed::ClearChat(void)
bIsTalking = false;
ClearLookFlag();
RestorePreviousState();
+ if (m_objective == OBJECTIVE_BUY_ICE_CREAM) {
+ bBoughtIceCream = true;
+ SetObjective(OBJECTIVE_NONE);
+ SetWanderPath(CGeneral::GetRandomNumberInRange(0, 8));
+ }
}
bool
@@ -3749,7 +3770,8 @@ CPed::ClearAll(void)
bIsPointingGunAt = false;
bRenderPedInCar = true;
bKnockedUpIntoAir = false;
- b158_4 = false;
+ bCrouchWhenScared = false;
+ bKnockedOffBike = false;
m_pCollidingEntity = nil;
}
@@ -4561,28 +4583,23 @@ CPed::ClearLook(void)
ClearLookFlag();
}
+// --MIAMI: Done
void
CPed::ClearObjective(void)
{
if (IsPedInControl() || m_nPedState == PED_DRIVING) {
m_objective = OBJECTIVE_NONE;
-#ifdef VC_PED_PORTS
m_pedInObjective = nil;
m_carInObjective = nil;
-#endif
if (m_nPedState == PED_DRIVING && m_pMyVehicle) {
if (m_pMyVehicle->pDriver != this) {
-#ifdef VC_PED_PORTS
if(!IsPlayer())
-#endif
bWanderPathAfterExitingCar = true;
SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle);
}
-#ifdef VC_PED_PORTS
m_nLastPedState = PED_NONE;
-#endif
} else {
SetIdle();
SetMoveState(PEDMOVE_STILL);
@@ -7038,7 +7055,7 @@ CPed::Fall(void)
CAnimBlendAssociation *firstPartialAssoc;
CAnimBlendAssociation *fallAssoc;
- if (IsPlayer() && (bKnockedUpIntoAir || b158_4) && !bIsStanding) {
+ if (IsPlayer() && (bKnockedUpIntoAir || bKnockedOffBike) && !bIsStanding) {
firstPartialAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_PARTIAL);
// What???
@@ -7066,7 +7083,7 @@ CPed::Fall(void)
} else {
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FALL_BACK, 8.0f);
}
- } else if ((bKnockedUpIntoAir || b158_4) && bIsStanding && !bWasStanding) {
+ } else if ((bKnockedUpIntoAir || bKnockedOffBike) && bIsStanding && !bWasStanding) {
fallAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_BACK);
if (!fallAssoc)
@@ -7074,7 +7091,7 @@ CPed::Fall(void)
if (fallAssoc) {
bKnockedUpIntoAir = false;
- b158_4 = false;
+ bKnockedOffBike = false;
fallAssoc->speed = 3.0f;
if (IsPlayer())
Say(SOUND_PED_LAND);
@@ -7083,7 +7100,7 @@ CPed::Fall(void)
firstPartialAssoc = RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_PARTIAL);
if (firstPartialAssoc && !firstPartialAssoc->IsRunning()) {
bKnockedUpIntoAir = false;
- b158_4 = false;
+ bKnockedOffBike = false;
}
}
}
@@ -8092,7 +8109,9 @@ CPed::Seek(void)
} else if (m_objective != OBJECTIVE_FOLLOW_PED_IN_FORMATION) {
- if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS || m_objective == OBJECTIVE_RUN_TO_AREA || bIsRunning)
+ if (m_objective == OBJECTIVE_SPRINT_TO_COORD)
+ nextMove = PEDMOVE_SPRINT;
+ else if (m_objective == OBJECTIVE_KILL_CHAR_ON_FOOT || m_objective == OBJECTIVE_KILL_CHAR_ANY_MEANS || m_objective == OBJECTIVE_RUN_TO_AREA || bIsRunning)
nextMove = PEDMOVE_RUN;
else
nextMove = PEDMOVE_WALK;
@@ -8114,7 +8133,7 @@ CPed::Seek(void)
}
if (seekPosDist >= distanceToCountItDone) {
- if (bIsRunning)
+ if (bIsRunning && nextMove != PEDMOVE_SPRINT)
nextMove = PEDMOVE_RUN;
if (CTimer::GetTimeInMilliseconds() <= m_nPedStateTimer) {
@@ -8186,7 +8205,9 @@ CPed::Seek(void)
m_actionY = 0;
}
- if (m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT || m_objective == OBJECTIVE_RUN_TO_AREA || m_objective == OBJECTIVE_GOTO_AREA_ANY_MEANS) {
+ if (m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT || m_objective == OBJECTIVE_RUN_TO_AREA || m_objective == OBJECTIVE_SPRINT_TO_COORD ||
+ m_objective == OBJECTIVE_GOTO_AREA_ANY_MEANS) {
+
if (m_pNextPathNode)
m_pNextPathNode = nil;
else
@@ -10332,6 +10353,7 @@ CPed::ProcessControl(void)
&& (!IsPlayer()
|| m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT
|| m_objective == OBJECTIVE_RUN_TO_AREA
+ || m_objective == OBJECTIVE_SPRINT_TO_COORD
|| m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)) {
if (collidingVeh != m_pCurrentPhysSurface || IsPlayer()) {
@@ -11172,7 +11194,7 @@ CPed::ProcessControl(void)
if (!IsPlayer() && m_pMyVehicle->IsBoat()
&& FindPlayerPed()->m_pCurrentPhysSurface == m_pMyVehicle
&& CharCreatedBy != MISSION_CHAR || !bIsPlayerFriend) {
- SetObjective(OBJ_50, FindPlayerPed());
+ SetObjective(OBJECTIVE_KILL_CHAR_ON_BOAT, FindPlayerPed());
Say(SOUND_PED_CAR_JACKED);
}
@@ -12296,10 +12318,11 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
veh->AutoPilot.m_nCruiseSpeed = 25;
}
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
- if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
+ if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT
+ || ped->m_prevObjective == OBJECTIVE_SPRINT_TO_COORD || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
ped->m_prevObjective = OBJECTIVE_NONE;
ped->RestorePreviousObjective();
@@ -12325,7 +12348,8 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
}
}
ped->m_nPedState = PED_DRIVING;
- if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
+ if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT
+ || ped->m_prevObjective == OBJECTIVE_SPRINT_TO_COORD || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
ped->m_prevObjective = OBJECTIVE_NONE;
ped->RestorePreviousObjective();
@@ -12348,6 +12372,13 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
case OBJECTIVE_GOTO_AREA_ANY_MEANS:
case OBJECTIVE_GOTO_AREA_ON_FOOT:
case OBJECTIVE_RUN_TO_AREA:
+ case OBJECTIVE_USE_SEAT_ATTRACTOR:
+ case OBJECTIVE_USE_ATM_ATTRACTOR:
+ case OBJECTIVE_USE_STOP_ATTRACTOR:
+ case OBJECTIVE_USE_PIZZA_ATTRACTOR:
+ case OBJECTIVE_USE_SHELTER_ATTRACTOR:
+ case OBJECTIVE_SPRINT_TO_COORD:
+ case OBJECTIVE_USE_ICECREAM_ATTRACTOR:
break;
default:
ped->SetObjective(OBJECTIVE_NONE);
@@ -13211,8 +13242,8 @@ CPed::ProcessObjective(void)
case OBJECTIVE_FOLLOW_CAR_IN_CAR:
case OBJECTIVE_FIRE_AT_OBJ_FROM_VEHICLE:
case OBJECTIVE_DESTROY_OBJ:
- case OBJECTIVE_26:
- case OBJECTIVE_27:
+ case OBJECTIVE_GOTO_AREA_IN_CAR:
+ case OBJECTIVE_FOLLOW_CAR_ON_FOOT_WITH_OFFSET:
case OBJECTIVE_SET_LEADER:
break;
case OBJECTIVE_IDLE:
@@ -13758,6 +13789,8 @@ CPed::ProcessObjective(void)
break;
}
case OBJECTIVE_GOTO_CHAR_ON_FOOT:
+ case OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING:
+ case OBJECTIVE_HASSLE_CHAR:
{
if (m_pedInObjective) {
float safeDistance = 2.0f;
@@ -13803,6 +13836,8 @@ CPed::ProcessObjective(void)
}
}
}
+ if (m_objective == OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING && m_nMoveState > PEDMOVE_STILL)
+ SetMoveState(PEDMOVE_WALK);
}
} else {
SetObjective(OBJECTIVE_NONE);
@@ -14095,8 +14130,9 @@ CPed::ProcessObjective(void)
}
case OBJECTIVE_GOTO_AREA_ON_FOOT:
case OBJECTIVE_RUN_TO_AREA:
+ case OBJECTIVE_SPRINT_TO_COORD:
{
- if ((m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT || m_objective == OBJECTIVE_RUN_TO_AREA)
+ if ((m_objective == OBJECTIVE_GOTO_AREA_ON_FOOT || m_objective == OBJECTIVE_RUN_TO_AREA || m_objective == OBJECTIVE_SPRINT_TO_COORD)
&& InVehicle()) {
SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle);
} else {
@@ -14111,11 +14147,22 @@ CPed::ProcessObjective(void)
CVector bestCoords(0.0f, 0.0f, 0.0f);
m_vecSeekPos = m_nextRoutePointPos;
- if (!m_pNextPathNode)
- FindBestCoordsFromNodes(m_vecSeekPos, &bestCoords);
+ if (!m_pNextPathNode) {
+ bool found = FindBestCoordsFromNodes(m_vecSeekPos, &bestCoords);
+ if (m_pNextPathNode) {
+ // Because it already does that if it finds better coords.
+ if (!found) {
+ bestCoords = CPathFind::TakeWidthIntoAccountForWandering(m_pNextPathNode, m_randomSeed);
+ }
+ if ((bestCoords - GetPosition()).Magnitude2D() < m_distanceToCountSeekDone) {
+ m_pNextPathNode = nil;
+ bUsePedNodeSeek = false;
+ }
+ }
+ }
if (m_pNextPathNode)
- m_vecSeekPos = m_pNextPathNode->GetPosition();
+ m_vecSeekPos = CPathFind::TakeWidthIntoAccountForWandering(m_pNextPathNode, m_randomSeed);
}
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
}
@@ -14342,13 +14389,18 @@ CPed::ProcessObjective(void)
SetWanderPath(CGeneral::GetRandomNumber() & 7);
}
} else {
-#ifdef VC_PED_PORTS
m_objective = OBJECTIVE_NONE;
-#endif
ClearObjective();
}
- break;
}
+ // fall through
+ case OBJECTIVE_WANDER:
+ if (CTimer::GetTimeInMilliseconds() > m_leaveCarTimer && !bInVehicle) {
+ m_leaveCarTimer = 0;
+ m_objective = OBJECTIVE_NONE;
+ CPed::SetWanderPath(m_nPathDir);
+ }
+ break;
case OBJECTIVE_FLEE_CAR:
if (!bInVehicle && m_nPedState != PED_FLEE_ENTITY && m_pMyVehicle) {
RestorePreviousObjective();
@@ -14382,6 +14434,19 @@ CPed::ProcessObjective(void)
}
}
break;
+ case OBJECTIVE_AIM_GUN_AT_PED:
+ if (m_pedInObjective) {
+ if (!bObstacleShowedUpDuringKillObjective)
+ SetPointGunAt(m_pedInObjective);
+
+ if (m_nMoveState == PEDMOVE_STILL && IsPedInControl()) {
+ SetLookFlag(m_pedInObjective, false); // TODO(Miami): new parameter: false
+ TurnBody();
+ }
+ } else {
+ ClearObjective();
+ }
+ break;
#ifdef VC_PED_PORTS
case OBJECTIVE_LEAVE_CAR_AND_DIE:
{
@@ -17623,6 +17688,7 @@ CPed::WarpPedIntoCar(CVehicle *car)
bChangedSeat = true;
}
+// --MIAMI: Done
void
CPed::SetObjective(eObjective newObj, float heading, const CVector& pos)
{
@@ -17639,6 +17705,7 @@ CPed::SetObjective(eObjective newObj, float heading, const CVector& pos)
}
}
+// --MIAMI: Done
void
CPed::SetObjective(eObjective newObj, CVector dest)
{
@@ -17648,9 +17715,8 @@ CPed::SetObjective(eObjective newObj, CVector dest)
if (m_prevObjective != OBJECTIVE_NONE && m_prevObjective == newObj)
return;
- SetObjectiveTimer(0);
if (m_objective == newObj) {
- if (newObj == OBJECTIVE_GOTO_AREA_ANY_MEANS || newObj == OBJECTIVE_GOTO_AREA_ON_FOOT || newObj == OBJECTIVE_RUN_TO_AREA) {
+ if (newObj == OBJECTIVE_GOTO_AREA_ANY_MEANS || newObj == OBJECTIVE_GOTO_AREA_ON_FOOT || newObj == OBJECTIVE_RUN_TO_AREA || newObj == OBJECTIVE_SPRINT_TO_COORD) {
if (m_nextRoutePointPos == dest)
return;
} else if (newObj == OBJECTIVE_GUARD_SPOT) {
@@ -17659,9 +17725,8 @@ CPed::SetObjective(eObjective newObj, CVector dest)
}
}
-#ifdef VC_PED_PORTS
ClearPointGunAt();
-#endif
+ m_objectiveTimer = 0;
bObjectiveCompleted = false;
switch (newObj) {
case OBJECTIVE_GUARD_SPOT:
@@ -17677,6 +17742,8 @@ CPed::SetObjective(eObjective newObj, CVector dest)
case OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE:
case OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS:
case OBJECTIVE_GOTO_CHAR_ON_FOOT:
+ case OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING:
+ case OBJECTIVE_HASSLE_CHAR:
case OBJECTIVE_FOLLOW_PED_IN_FORMATION:
case OBJECTIVE_LEAVE_VEHICLE:
case OBJECTIVE_ENTER_CAR_AS_PASSENGER:
@@ -17685,6 +17752,27 @@ CPed::SetObjective(eObjective newObj, CVector dest)
case OBJECTIVE_FIRE_AT_OBJ_FROM_VEHICLE:
case OBJECTIVE_DESTROY_OBJ:
case OBJECTIVE_DESTROY_CAR:
+ case OBJECTIVE_GOTO_AREA_IN_CAR:
+ case OBJECTIVE_FOLLOW_CAR_ON_FOOT_WITH_OFFSET:
+ case OBJECTIVE_FIGHT_CHAR:
+ case OBJECTIVE_SET_LEADER:
+ case OBJECTIVE_FOLLOW_ROUTE:
+ case OBJECTIVE_SOLICIT:
+ case OBJECTIVE_HAIL_TAXI:
+ case OBJECTIVE_CATCH_TRAIN:
+ case OBJECTIVE_BUY_ICE_CREAM:
+ case OBJECTIVE_STEAL_ANY_CAR:
+ case OBJECTIVE_STEAL_ANY_MISSION_CAR:
+ case OBJECTIVE_MUG_CHAR:
+ case OBJECTIVE_LEAVE_CAR_AND_DIE:
+ case OBJECTIVE_FLEE_CAR:
+ case OBJECTIVE_SUN_BATHE:
+ case OBJECTIVE_AIM_GUN_AT_PED:
+ case OBJECTIVE_WANDER:
+ case OBJECTIVE_WAIT_FOR_RAIN_TO_END:
+ case OBJECTIVE_KILL_CHAR_ON_BOAT:
+ case OBJECTIVE_SOLICIT_FOOT:
+ case OBJECTIVE_WAIT_FOR_BUS:
break;
case OBJECTIVE_GOTO_AREA_ANY_MEANS:
case OBJECTIVE_GOTO_AREA_ON_FOOT:
@@ -17734,6 +17822,7 @@ CPed::SetObjective(eObjective newObj, CVector dest)
}
break;
case OBJECTIVE_RUN_TO_AREA:
+ case OBJECTIVE_SPRINT_TO_COORD:
bIsRunning = true;
m_pNextPathNode = nil;
m_nextRoutePointPos = dest;
@@ -18148,50 +18237,6 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
}
void
-CPed::SetObjective(eObjective newObj, CVector dest, float safeDist)
-{
- if (DyingOrDead())
- return;
-
- if (m_prevObjective != OBJECTIVE_NONE && m_prevObjective == newObj)
- return;
-
- SetObjectiveTimer(0);
- if (m_objective == newObj) {
- if (newObj == OBJECTIVE_GOTO_AREA_ANY_MEANS || newObj == OBJECTIVE_GOTO_AREA_ON_FOOT || newObj == OBJECTIVE_RUN_TO_AREA) {
- if (m_nextRoutePointPos == dest && m_distanceToCountSeekDone == safeDist)
- return;
- } else if (newObj == OBJECTIVE_GUARD_SPOT) {
- if (m_vecSeekPosEx == dest && m_distanceToCountSeekDoneEx == safeDist)
- return;
- }
- }
-
-#ifdef VC_PED_PORTS
- ClearPointGunAt();
-#endif
- bObjectiveCompleted = false;
- if (IsTemporaryObjective(m_objective)) {
- m_prevObjective = newObj;
- } else {
- if (m_objective != newObj)
- SetStoredObjective();
-
- m_objective = newObj;
- }
-
- if (newObj == OBJECTIVE_GUARD_SPOT) {
- m_vecSeekPosEx = dest;
- m_distanceToCountSeekDoneEx = safeDist;
- } else if (newObj == OBJECTIVE_GOTO_AREA_ANY_MEANS || newObj == OBJECTIVE_GOTO_AREA_ON_FOOT || newObj == OBJECTIVE_RUN_TO_AREA) {
- m_pNextPathNode = nil;
- m_nextRoutePointPos = dest;
- m_vecSeekPos = m_nextRoutePointPos;
- bUsePedNodeSeek = true;
- }
-}
-
-void
CPed::SetCarJack(CVehicle* car)
{
uint8 doorFlag;
@@ -18344,6 +18389,7 @@ CPed::SetExitBoat(CVehicle *boat)
m_vecMoveSpeed = boat->m_vecMoveSpeed;
}
+// --MIAMI: Done
void
CPed::SetNewAttraction(CPedAttractor* pAttractor, const CVector& pos, float heading, float time, int32 qid)
{
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index 8e8e3b75..673c70b0 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -182,7 +182,7 @@ enum eWaitState {
enum eObjective : uint32 {
OBJECTIVE_NONE,
OBJECTIVE_IDLE,
- OBJ_2,
+ OBJECTIVE_IDLE_COP,
OBJECTIVE_FLEE_TILL_SAFE,
OBJECTIVE_GUARD_SPOT,
OBJECTIVE_GUARD_AREA, // not implemented
@@ -193,9 +193,9 @@ enum eObjective : uint32 {
OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE,
OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS,
OBJECTIVE_GOTO_CHAR_ON_FOOT,
+ OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING,
+ OBJECTIVE_HASSLE_CHAR,
OBJECTIVE_FOLLOW_PED_IN_FORMATION,
- OBJ_14,
- OBJ_15,
OBJECTIVE_LEAVE_VEHICLE,
OBJECTIVE_ENTER_CAR_AS_PASSENGER,
OBJECTIVE_ENTER_CAR_AS_DRIVER,
@@ -206,8 +206,8 @@ enum eObjective : uint32 {
OBJECTIVE_GOTO_AREA_ANY_MEANS,
OBJECTIVE_GOTO_AREA_ON_FOOT,
OBJECTIVE_RUN_TO_AREA,
- OBJECTIVE_26, // not implemented
- OBJECTIVE_27, // not implemented
+ OBJECTIVE_GOTO_AREA_IN_CAR, // not implemented
+ OBJECTIVE_FOLLOW_CAR_ON_FOOT_WITH_OFFSET, // not implemented
OBJECTIVE_FIGHT_CHAR,
OBJECTIVE_SET_LEADER,
OBJECTIVE_FOLLOW_ROUTE,
@@ -216,22 +216,22 @@ enum eObjective : uint32 {
OBJECTIVE_CATCH_TRAIN,
OBJECTIVE_BUY_ICE_CREAM,
OBJECTIVE_STEAL_ANY_CAR,
- OBJ_36,
+ OBJECTIVE_STEAL_ANY_MISSION_CAR,
OBJECTIVE_MUG_CHAR,
OBJECTIVE_LEAVE_CAR_AND_DIE,
OBJECTIVE_USE_SEAT_ATTRACTOR,
OBJECTIVE_USE_ATM_ATTRACTOR,
OBJECTIVE_FLEE_CAR,
- OBJ_42,
+ OBJECTIVE_SUN_BATHE,
OBJECTIVE_USE_STOP_ATTRACTOR,
OBJECTIVE_USE_PIZZA_ATTRACTOR,
OBJECTIVE_USE_SHELTER_ATTRACTOR,
OBJECTIVE_AIM_GUN_AT_PED,
- OBJ_47,
+ OBJECTIVE_WANDER,
OBJECTIVE_WAIT_FOR_RAIN_TO_END,
OBJECTIVE_SPRINT_TO_COORD,
- OBJ_50,
- OBJ_51,
+ OBJECTIVE_KILL_CHAR_ON_BOAT,
+ OBJECTIVE_SOLICIT_FOOT,
OBJECTIVE_WAIT_FOR_BUS,
OBJECTIVE_USE_ICECREAM_ATTRACTOR,
OBJECTIVE_PURCHASE_ICECREAM,
@@ -473,8 +473,8 @@ public:
uint32 bIgnoreThreatsBehindObjects : 1;
uint32 bNeverEverTargetThisPed : 1;
- //uint32 b158_2
- uint32 b158_4 : 1;
+ uint32 bCrouchWhenScared : 1;
+ uint32 bKnockedOffBike : 1;
//uint32 b158_8
//uint32 b158_10
uint32 bBoughtIceCream : 1;
@@ -696,7 +696,6 @@ public:
void SetObjective(eObjective);
void SetObjective(eObjective, int16, int16);
void SetObjective(eObjective, CVector);
- void SetObjective(eObjective, CVector, float);
void SetObjective(eObjective, float, const CVector&);
void ClearChat(void);
void InformMyGangOfAttack(CEntity*);
diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp
index 05f088bf..74dd376b 100644
--- a/src/vehicles/Bike.cpp
+++ b/src/vehicles/Bike.cpp
@@ -1351,12 +1351,7 @@ CBike::PreRender(void)
CMatrix mat;
CVector headLightPos = mi->m_positions[CAR_POS_HEADLIGHTS];
-#ifdef FIX_BUGS
- if(GetModelIndex() == MI_FAGGIO || GetModelIndex() == MI_PIZZABOY)
-#else
- if(GetModelIndex() == 152) // this is the bobcat in VC
-#endif
- {
+ if(GetModelIndex() == 152){ // this is the bobcat in VC, but we don't want that effect anyway
mat.SetUnity();
mat.RotateZ(m_fWheelAngle);
mat = m_leanMatrix * mat;
@@ -2447,16 +2442,24 @@ CBike::BurstTyre(uint8 wheel, bool applyForces)
ApplyTurnForce(GetRight() * m_fTurnMass * CGeneral::GetRandomNumberInRange(-0.02f, 0.02f), GetForward());
}
-#ifdef FIX_SIGNIFICANT_BUGS
// This code checks piece types originally so it is never triggered
// as we have converted them to wheel indices above already.
if(pDriver){
+#ifdef FIX_SIGNIFICANT_BUGS
if(wheel == BIKEWHEEL_FRONT && (m_aSuspensionSpringRatioPrev[BIKESUSP_F1] < 1.0f || m_aSuspensionSpringRatioPrev[BIKESUSP_F2] < 1.0f) ||
wheel == BIKEWHEEL_REAR && (m_aSuspensionSpringRatioPrev[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatioPrev[BIKESUSP_R2] < 1.0f)){
+#else
+ if(wheel == CAR_PIECE_WHEEL_LF && (m_aSuspensionSpringRatioPrev[BIKESUSP_F1] < 1.0f || m_aSuspensionSpringRatioPrev[BIKESUSP_F2] < 1.0f) ||
+ wheel == CAR_PIECE_WHEEL_LR && (m_aSuspensionSpringRatioPrev[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatioPrev[BIKESUSP_R2] < 1.0f)){
+#endif
float speedSq = m_vecMoveSpeed.MagnitudeSqr();
if(speedSq > fBikeBurstFallSpeed &&
(GetStatus() != STATUS_PLAYER || speedSq > fBikeBurstFallSpeedPlayer)){
+#ifdef FIX_SIGNIFICANT_BUGS
if(wheel == BIKEWHEEL_FRONT){
+#else
+ if(wheel == CAR_PIECE_WHEEL_LF){
+#endif
KnockOffRider(WEAPONTYPE_RAMMEDBYCAR, 0, pDriver, false);
if(pPassengers[0])
KnockOffRider(WEAPONTYPE_RAMMEDBYCAR, 0, pPassengers[0], false);
@@ -2465,7 +2468,6 @@ CBike::BurstTyre(uint8 wheel, bool applyForces)
}
}
}
-#endif
}
}
@@ -2573,7 +2575,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa
else if(ped->m_pedStats->m_temper <= ped->m_pedStats->m_fear &&
ped->CharCreatedBy != MISSION_CHAR && ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE &&
!CTheScripts::IsPlayerOnAMission()){
- ped->SetObjective(OBJ_47, ped->m_pMyVehicle);
+ ped->SetObjective(OBJECTIVE_WANDER, ped->m_pMyVehicle);
ped->m_nPathDir = CGeneral::GetRandomNumberInRange(0, 8);
}
}else if(ped->m_leader == nil){
@@ -2683,7 +2685,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa
case 3: anim = ANIM_KD_LEFT; break;
}
if(m_nWheelsOnGround == 0)
- ped->b158_4 = true;
+ ped->bKnockedOffBike = true;
break;
}
@@ -2701,7 +2703,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa
case 2: anim = ANIM_KO_SKID_FRONT; break;
case 3: anim = ANIM_KD_LEFT; break;
}
- ped->b158_4 = true;
+ ped->bKnockedOffBike = true;
if(ped->IsPlayer())
ped->Say(SOUND_PED_DAMAGE);
break;
@@ -2743,7 +2745,7 @@ CBike::KnockOffRider(eWeaponType weapon, uint8 direction, CPed *ped, bool bGetBa
}else
ped->GetMatrix().Translate(CVector(0.0f, 0.0f, -2.0f));
ped->m_pCollidingEntity = ped->m_pMyVehicle;
- ped->b158_4 = true;
+ ped->bKnockedOffBike = true;
ped->bHeadStuckInCollision = true;
}else if(weapon == WEAPONTYPE_RAMMEDBYCAR){
if(CWorld::TestSphereAgainstWorld(ped->GetPosition()+CVector(0.0f, 0.0, 1.3f), 0.6f, nil, true, false, false, false, false, false) == nil)