Merge remote-tracking branch 'origin/miami' into miami

# Conflicts:
#	src/core/config.h
This commit is contained in:
Sergeanur
2020-08-19 23:35:10 +03:00
78 changed files with 3941 additions and 126 deletions

View File

@ -81,6 +81,9 @@
#define OFFSCREEN_DESPAWN_RANGE (40.0f)
#define EXTENDED_RANGE_DESPAWN_MULTIPLIER (1.5f)
//--MIAMI: file done
bool CCarCtrl::bMadDriversCheat;
int CCarCtrl::NumLawEnforcerCars;
int CCarCtrl::NumAmbulancesOnDuty;
int CCarCtrl::NumFiretrucksOnDuty;
@ -664,7 +667,7 @@ CCarCtrl::GenerateOneRandomCar()
nMadDrivers = 6;
break;
}
if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers /* TODO(MIAMI): || mad drivers cheat */) {
if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers || bMadDriversCheat) {
pVehicle->SetStatus(STATUS_PHYSICS);
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
pVehicle->AutoPilot.m_nCruiseSpeed += 10;
@ -2519,7 +2522,7 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
SteerAIBoatWithPhysicsAttackingPlayer(pVehicle, pSwerve, pAccel, pBrake, pHandbrake);
return;
case MISSION_PLANE_FLYTOCOORS:
//SteerAIPlaneTowardsTargetCoors((CAutomobile*)pVehicle);
SteerAIPlaneTowardsTargetCoors((CAutomobile*)pVehicle);
return;
case MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1:
SteerAICarWithPhysicsHeadingForTarget(pVehicle, nil,
@ -2741,6 +2744,51 @@ void CCarCtrl::SteerAIHeliTowardsTargetCoors(CAutomobile* pHeli)
pHeli->GetMatrix().GetUp() = up;
}
void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane)
{
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
float angle = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y);
while (angle > TWOPI)
angle -= TWOPI;
float difference = LimitRadianAngle(angle - pPlane->m_fOrientation);
float steer = difference > 0.0f ? 0.04f : -0.04f;
if (Abs(difference) < 0.2f)
steer *= 5.0f * Abs(difference);
pPlane->m_fPlaneSteer *= Pow(0.96, CTimer::GetTimeStep());
float steerChange = steer - pPlane->m_fPlaneSteer;
float maxChange = 0.003f * CTimer::GetTimeStep();
if (Abs(steerChange) < maxChange)
pPlane->m_fPlaneSteer = steer;
else if (steerChange < 0.0f)
pPlane->m_fPlaneSteer -= maxChange;
else
pPlane->m_fPlaneSteer += maxChange;
pPlane->m_fOrientation += pPlane->m_fPlaneSteer * CTimer::GetTimeStep();
CVector up(0.0f, 0.0f, 1.0f);
up.Normalise();
CVector forward(Cos(pPlane->m_fOrientation), Sin(pPlane->m_fOrientation), fForwardZ);
forward.Normalise();
CVector right = CrossProduct(forward, up);
right.z -= 5.0f * pPlane->m_fPlaneSteer;
right.Normalise();
up = CrossProduct(forward, right);
up.Normalise();
right = CrossProduct(forward, up);
pPlane->GetMatrix().GetRight() = right;
pPlane->GetMatrix().GetForward() = forward;
pPlane->GetMatrix().GetUp() = up;
float newSplit = 1.0f - Pow(0.95, CTimer::GetTimeStep());
float oldSplit = 1.0f - newSplit;
#ifdef FIX_BUGS
pPlane->m_vecMoveSpeed = pPlane->m_vecMoveSpeed * oldSplit + pPlane->AutoPilot.GetCruiseSpeed() * 0.01f * forward * newSplit;
#else
pPlane->m_vecMoveSpeed = pPlane->m_vecMoveSpeed * oldSplit + pPlane->AutoPilot.m_nCruiseSpeed * 0.01f * forward * newSplit;
#endif
pPlane->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}
void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
{
CVector2D forward = pVehicle->GetForward();

View File

@ -145,6 +145,7 @@ public:
return angle;
}
static bool bMadDriversCheat;
static int32 NumLawEnforcerCars;
static int32 NumAmbulancesOnDuty;
static int32 NumFiretrucksOnDuty;

View File

@ -3133,7 +3133,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
CollectParameters(&m_nIp, 4);
int32 index = ScriptParams[0];
assert(index < NUMPLAYERS);
script_assert(index < NUMPLAYERS);
printf("&&&&&&&&&&&&&Creating player: %d\n", index);
if (!CStreaming::HasModelLoaded(MI_PLAYER)) {
CStreaming::RequestSpecialModel(MI_PLAYER, "player", STREAMFLAGS_DONT_REMOVE | STREAMFLAGS_DEPENDENCY);
@ -5174,7 +5174,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
if (pPed->bInVehicle)
return 0;
pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(*(float*)&ScriptParams[1]);
@ -6000,7 +6000,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_DESTROY_OBJECT, pVehicle);
@ -10450,7 +10450,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle);
return 0;
@ -10659,7 +10659,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->m_nPedMoney = ScriptParams[1];
pPed->bMoneyHasBeenGivenByScript = true;
return 0;
@ -10669,7 +10669,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
CollectParameters(&m_nIp, 4);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
CVector result = Multiply3x3(pObject->GetMatrix(), *(CVector*)&ScriptParams[1]) + pObject->GetPosition();
*(CVector*)&ScriptParams[0] = result;
StoreParameters(&m_nIp, 3);
@ -10702,7 +10702,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
CollectParameters(&m_nIp, 4);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
CVector result = Multiply3x3(pVehicle->GetMatrix(), *(CVector*)&ScriptParams[1]) + pVehicle->GetPosition();
*(CVector*)&ScriptParams[0] = result;
StoreParameters(&m_nIp, 3);
@ -11060,7 +11060,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
UpdateCompareFlag(ScriptParams[1] < pVehicle->m_nNumMaxPassengers && pVehicle->pPassengers[ScriptParams[1]] == nil);
return 0;
}
@ -11211,7 +11211,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
return 0;
*/
case COMMAND_ARE_ANY_CAR_CHEATS_ACTIVATED:
UpdateCompareFlag(CVehicle::bAllDodosCheat || CVehicle::bCheat3); // TODO(MIAMI): more cheats!
UpdateCompareFlag(CVehicle::bAllDodosCheat || CVehicle::bCheat3 || CVehicle::bHoverCheat || CVehicle::bCheat8); // TODO(MIAMI): more cheats!
return 0;
case COMMAND_SET_CHAR_SUFFERS_CRITICAL_HITS:
{
@ -11919,7 +11919,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->m_ceaseAttackTimer = ScriptParams[1];
return 0;
}
@ -11955,7 +11955,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
pVehicle->m_nRouteSeed = ScriptParams[1];
return 0;
}
@ -11972,7 +11972,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->ClearWeapons();
return 0;
}
@ -11980,7 +11980,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
bool bFound = false;
for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) {
if (pPed->GetWeapon(i).m_eWeaponType == ScriptParams[1]) {
@ -11997,7 +11997,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle && pVehicle->m_vehType == VEHICLE_TYPE_CAR);
script_assert(pVehicle && pVehicle->m_vehType == VEHICLE_TYPE_CAR);
((CAutomobile*)pVehicle)->bTankDetonateCars = ScriptParams[1];
return 0;
}
@ -12016,7 +12016,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
bool bOnFire = false;
if (pVehicle->m_pCarFire)
bOnFire = true;
@ -12031,7 +12031,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
bool bIsBurst = false;
CBike* pBike = (CBike*)pVehicle;
if (pVehicle->m_vehType == VEHICLE_APPEARANCE_BIKE) {
@ -12104,7 +12104,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 5);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI);
script_assert(pVehicle && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI);
((CAutomobile*)pVehicle)->TellHeliToGoToCoors(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], ScriptParams[4]);
return 0;
}
@ -12147,7 +12147,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT);
return 0;
}
@ -12155,7 +12155,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT);
return 0;
}
@ -12163,7 +12163,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI);
return 0;
}
@ -12171,7 +12171,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI);
return 0;
}
@ -12179,7 +12179,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE);
return 0;
}
@ -12187,7 +12187,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI);
return 0;
}
@ -12282,7 +12282,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
ScriptParams[0] = pPed->GetWeapon(ScriptParams[1]).m_eWeaponType;
ScriptParams[1] = pPed->GetWeapon(ScriptParams[1]).m_nAmmoTotal;
ScriptParams[2] = CPickups::ModelForWeapon((eWeaponType)ScriptParams[0]);
@ -12302,10 +12302,11 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
float speed = *(float*)&ScriptParams[1] / GAME_SPEED_TO_CARAI_SPEED;
pVehicle->SetMoveSpeed(pVehicle->GetForward() * speed);
// TODO(MIAMI): heli hack!
if (pVehicle->IsRealHeli() && pVehicle->IsCar())
((CAutomobile*)pVehicle)->m_aWheelSpeed[1] = 0.22f;
return 0;
}
case COMMAND_SET_AREA_VISIBLE:
@ -12326,7 +12327,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
pVehicle->bPartOfConvoy = ScriptParams[1];
return 0;
}
@ -12358,9 +12359,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]);
assert(pTargetPed);
script_assert(pTargetPed);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING, pTargetPed);
return 0;
@ -12370,7 +12371,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 4);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
CVector result = Multiply3x3(pPed->GetMatrix(), *(CVector*)&ScriptParams[1]) + pPed->GetPosition();
*(CVector*)&ScriptParams[0] = result;
StoreParameters(&m_nIp, 3);
@ -12380,7 +12381,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
bool result = false;
if (pPed->bHasBeenPhotographed) {
result = true;
@ -12393,9 +12394,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]);
assert(pTargetPed);
script_assert(pTargetPed);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_AIM_GUN_AT, pTargetPed);
return 0;
@ -12411,7 +12412,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && (pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI || pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE));
return 0;
}
@ -12441,7 +12442,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
float fAngle = DEGTORAD(*(float*)&ScriptParams[1] - 90.0f);
while (fAngle < 0.0f)
fAngle += TWOPI;
@ -12454,14 +12455,16 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
pHeli->ClearHeliOrientation();
return 0;
}
case COMMAND_PLANE_GOTO_COORDS:
{
CollectParameters(&m_nIp, 5);
debug("PLANE_GOTO_COORS is not implemented\n"); // TODO(MIAMI)
CAutomobile* pPlane = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pPlane && pPlane->IsCar() && pPlane->IsRealPlane());
pPlane->TellPlaneToGoToCoors(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], ScriptParams[4]);
return 0;
}
case COMMAND_GET_NTH_CLOSEST_CAR_NODE:
@ -12493,7 +12496,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bIsFrozen = ScriptParams[1];
return 0;
}
@ -12501,7 +12504,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bDrownsInWater = ScriptParams[1];
return 0;
}
@ -12509,7 +12512,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
pObject->bUseCollisionRecords = ScriptParams[1];
return 0;
}
@ -12517,7 +12520,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
UpdateCompareFlag(pObject->m_nCollisionRecords != 0);
return 0;
}
@ -12531,7 +12534,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
ScriptParams[0] = pPed->m_fArmour;
StoreParameters(&m_nIp, 1);
return 0;
@ -12541,7 +12544,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
pVehicle->bHeliMinimumTilt = ScriptParams[1];
return 0;
}
@ -12549,7 +12552,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
pVehicle->AutoPilot.m_nSwitchDistance = ScriptParams[1];
return 0;
}
@ -12557,7 +12560,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pCar&& pCar->IsCar());
script_assert(pCar&& pCar->IsCar());
pCar->PopBoot();
return 0;
}
@ -12590,7 +12593,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
UpdateCompareFlag(pObject->bIsInWater);
return 0;
}
@ -12603,7 +12606,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 3);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
if (ScriptParams[1]) {
pPed->bIsDucking = true;
pPed->SetDuck(ScriptParams[2], true);
@ -12667,7 +12670,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bIsStaticWaitingForCollision);
return 0;
}
@ -12675,7 +12678,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
UpdateCompareFlag(pVehicle->bIsStaticWaitingForCollision);
return 0;
}
@ -12683,7 +12686,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
UpdateCompareFlag(pObject->bIsStaticWaitingForCollision);
return 0;
}
@ -12706,7 +12709,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 3);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bIsPlayerFriend = ScriptParams[2];
return 0;
}
@ -12714,7 +12717,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_DISPLAY_NTH_ONSCREEN_COUNTER_WITH_STRING:
{
char onscreen_str[12];
assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR);
script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR);
int16 var = CTheScripts::Read2BytesFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ???
@ -12785,7 +12788,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->m_prevObjective == OBJECTIVE_NONE && pPed->m_objective == OBJECTIVE_NONE);
return 0;
}
@ -12798,7 +12801,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++)
key[i] = tolower(key[i]);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(strcmp(key, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetName()) == 0);
return 0;
}
@ -12813,7 +12816,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 3);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
CVector pos;
pos.x = *(float*)&ScriptParams[1];
pos.y = *(float*)&ScriptParams[2];
@ -12846,7 +12849,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pCar&& pCar->IsCar());
script_assert(pCar&& pCar->IsCar());
pCar->CloseAllDoors();
return 0;
}
@ -12868,7 +12871,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pCar && pCar->IsCar());
script_assert(pCar && pCar->IsCar());
pCar->PopBootUsingPhysics();
return 0;
}
@ -12877,7 +12880,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE);
return 0;
}
@ -12885,7 +12888,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 2);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
pObject->m_pCollidingEntity = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
return 0;
}
@ -12894,7 +12897,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
{
CollectParameters(&m_nIp, 5);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(CWorld::IsWanderPathClear(pPed->GetPosition(), *(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3], 4));
return 0;
}
@ -12907,7 +12910,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
}
//case COMMAND_PRINT_HELP_FOREVER_WITH_NUMBER:
default:
assert(0);
script_assert(0);
}
return -1;
}
@ -12919,7 +12922,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 3);
CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pTarget);
script_assert(pTarget);
uint8 flag = 1 << (uint8)ScriptParams[1];
if (ScriptParams[2])
pTarget->m_gangFlags |= flag;
@ -12965,7 +12968,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
pVehicle->bIsFrozen = ScriptParams[1];
return 0;
}
@ -13033,7 +13036,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bStayInCarOnJack = ScriptParams[1];
return 0;
}
@ -13098,7 +13101,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bDontFight = !ScriptParams[1];
return 0;
}
@ -13106,7 +13109,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->ClearWaitState();
return 0;
}
@ -13141,7 +13144,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
pVehicle->bTyresDontBurst = !ScriptParams[1];
return 0;
}
@ -13149,7 +13152,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
pPed->bDoomAim = ScriptParams[1];
return 0;
}
@ -13188,7 +13191,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
CPhysical* pTestedEntity = pPed;
if (pPed->bInVehicle && pPed->m_pMyVehicle)
@ -13220,7 +13223,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
if (pPed->GetPedState() == PED_FOLLOW_PATH) {
pPed->RestorePreviousState();
pPed->ClearFollowPath();
@ -13231,7 +13234,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bCanBeShotInVehicle = ScriptParams[1];
return 0;
}
@ -13270,7 +13273,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
pObject->bIsFrozen = ScriptParams[1];
return 0;
}
@ -13406,7 +13409,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bIgnoreThreatsBehindObjects = ScriptParams[1];
return 0;
}
@ -13414,7 +13417,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
if (pPed->bInVehicle) {
if (pPed->GetWeapon(5).m_eWeaponType) { // TODO(MIAMI): enum
if (pPed->GetWeapon(5).m_nAmmoTotal < ScriptParams[1])
@ -13433,7 +13436,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 1);
CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli());
pHeli->bHeliDestroyed = true;
return 0;
}
@ -13447,7 +13450,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
pObject->m_area = ScriptParams[1];
return 0;
}
@ -13456,7 +13459,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bNeverEverTargetThisPed = ScriptParams[1];
return 0;
}
@ -13477,7 +13480,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
pPed->bCrouchWhenScared = true;
return 0;
}
@ -13485,7 +13488,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle &&
pPed->m_pMyVehicle->IsLawEnforcementVehicle() &&
pPed->m_pMyVehicle->GetModelIndex() != MI_PREDATOR);
@ -13514,7 +13517,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->m_nWaitState == WAITSTATE_STUCK);
return 0;
}
@ -13528,7 +13531,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
if (ScriptParams[1]) {
pPed->bKindaStayInSamePlace = true;
pPed->bStopAndShoot = true;
@ -13544,7 +13547,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
if (ScriptParams[1]) {
pVehicle->bIsFrozen = true;
pVehicle->bInfiniteMass = true;
@ -13564,7 +13567,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
//case COMMAND_FREEZE_OBJECT_POSITION_AND_DONT_LOAD_COLLISION:
//case COMMAND_SET_FADE_AND_JUMPCUT_AFTER_RC_EXPLOSION:
default:
assert(0);
script_assert(0);
}
return -1;
}
@ -13580,7 +13583,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
if (!pPed->bInVehicle) {
pPed->m_pVehicleAnim = nil;
pPed->RestartNonPartialAnims();
@ -13639,9 +13642,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
assert(pVehicle);
script_assert(pVehicle);
ScriptParams[0] = 0;
if (pPed->m_objective == OBJECTIVE_NONE && !pPed->bHasAlreadyUsedAttractor) {
C2dEffect* pEffect = (C2dEffect*)GetPedAttractorManager()->GetEffectForIceCreamVan(pVehicle, pPed->GetPosition()); // has to be casted, because inner methods are const
@ -13683,7 +13686,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
if (pPed->m_attractor)
GetPedAttractorManager()->DeRegisterPed(pPed, pPed->m_attractor);
return 0;
@ -13695,7 +13698,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bHasAlreadyUsedAttractor);
return 0;
}
@ -13703,7 +13706,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
if (ScriptParams[1]) {
pVehicle->bDontLoadCollision = false;
if (m_bMissionFlag) {
@ -13726,7 +13729,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
if (ScriptParams[1]) {
pPed->bDontLoadCollision = false;
if (m_bMissionFlag) {
@ -13756,7 +13759,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bBoughtIceCream);
return 0;
}
@ -13830,20 +13833,39 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
}
//case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_ZONE:
case COMMAND_UNLOCK_ALL_CAR_DOORS_IN_AREA:
{
CollectParameters(&m_nIp, 4);
debug("UNLOCK_ALL_CAR_DOORS_IN_AREA not implemented\n"); // TODO(MIAMI)
uint32 i = CPools::GetVehiclePool()->GetSize();
float infX = *(float*)&ScriptParams[0];
float infY = *(float*)&ScriptParams[1];
float supX = *(float*)&ScriptParams[2];
float supY = *(float*)&ScriptParams[3];
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle)
continue;
if (pVehicle->IsWithinArea(infX, infY, supX, supY))
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
}
return 0;
}
case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS:
CollectParameters(&m_nIp, 2);
CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + ScriptParams[0]), !!ScriptParams[1]);
return 0;
case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR:
assert(0);
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
pPed->bHeldHostageInCar = ScriptParams[1];
return 0;
}
case COMMAND_SET_VEHICLE_TO_FADE_IN:
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
script_assert(pVehicle);
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), ScriptParams[1]);
return 0;
}
@ -13857,7 +13879,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle == CGameLogic::pShortCutTaxi);
return 0;
}
@ -13865,7 +13887,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
script_assert(pPed);
UpdateCompareFlag(RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_DUCK_DOWN) != nil);
return 0;
}
@ -13905,7 +13927,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
return 0;
}
default:
assert(0);
script_assert(0);
}
return -1;
}
@ -14885,7 +14907,7 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp)
}
CollectParameters(pIp, b3D ? 8 : 6);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
CVector pos = pObject->GetPosition();
X = *(float*)&ScriptParams[1];
Y = *(float*)&ScriptParams[2];
@ -15440,7 +15462,7 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp)
}
CollectParameters(pIp, b3D ? 8 : 6);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
script_assert(pObject);
CVector pos = pObject->GetPosition();
infX = *(float*)&ScriptParams[1];
infY = *(float*)&ScriptParams[2];
@ -15493,7 +15515,7 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp)
result = true;
break;
default:
assert(false);
script_assert(false);
break;
}
}