diff options
Diffstat (limited to 'src/control/Script.cpp')
-rw-r--r-- | src/control/Script.cpp | 593 |
1 files changed, 483 insertions, 110 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index a274c289..58222317 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -13,6 +13,7 @@ #include "CarGen.h" #include "CivilianPed.h" #include "Clock.h" +#include "ColStore.h" #include "CopPed.h" #include "Coronas.h" #include "Cranes.h" @@ -170,10 +171,46 @@ void CMissionCleanup::AddEntityToList(int32 id, uint8 type) m_nCount++; } +static void PossiblyWakeThisEntity(CPhysical* pEntity) +{ + if (!pEntity->bIsStaticWaitingForCollision) + return; + if (CColStore::HasCollisionLoaded(pEntity->GetPosition())) { + pEntity->bIsStaticWaitingForCollision = false; + if (!pEntity->IsStatic()) + pEntity->AddToMovingList(); + } +} + void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type) { for (int i = 0; i < MAX_CLEANUP; i++){ if (m_sEntities[i].type == type && m_sEntities[i].id == id){ + switch (m_sEntities[i].type) { + case CLEANUP_CAR: + { + CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); + if (v) + PossiblyWakeThisEntity(v); + break; + } + case CLEANUP_CHAR: + { + CPed* p = CPools::GetPedPool()->GetAt(m_sEntities[i].id); + if (p) + PossiblyWakeThisEntity(p); + break; + } + case CLEANUP_OBJECT: + { + CObject* o = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); + if (o) + PossiblyWakeThisEntity(o); + break; + } + default: + break; + } m_sEntities[i].id = 0; m_sEntities[i].type = CLEANUP_UNUSED; m_nCount--; @@ -181,6 +218,52 @@ void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type) } } +void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObject() +{ + for (int i = 0; i < MAX_CLEANUP; i++) { + switch (m_sEntities[i].type) { + case CLEANUP_CAR: + { + CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); + if (v) + PossiblyWakeThisEntity(v); + break; + } + case CLEANUP_CHAR: + { + CPed* p = CPools::GetPedPool()->GetAt(m_sEntities[i].id); + if (p) + PossiblyWakeThisEntity(p); + break; + } + case CLEANUP_OBJECT: + { + CObject* o = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); + if (o) + PossiblyWakeThisEntity(o); + break; + } + default: + break; + } + } +} + +CPhysical* CMissionCleanup::DoesThisEntityWaitForCollision(int i) +{ + if (m_sEntities[i].type == CLEANUP_CAR) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); + if (pVehicle && pVehicle->GetStatus() != STATUS_WRECKED) + return pVehicle; + } + else if (m_sEntities[i].type == CLEANUP_CHAR) { + CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id); + if (pPed && !pPed->DyingOrDead()) + return pPed; + } + return nil; +} + void CMissionCleanup::Process() { CPopulation::m_AllRandomPedsThisType = -1; @@ -506,7 +589,7 @@ void CRunningScript::Init() #ifdef USE_DEBUG_SCRIPT_LOADER int open_script() { - static int scriptToLoad = 0; + static int scriptToLoad = 1; if (GetAsyncKeyState('G') & 0x8000) scriptToLoad = 0; @@ -517,7 +600,7 @@ int open_script() switch (scriptToLoad) { case 0: return CFileMgr::OpenFile("main.scm", "rb"); - case 1: return CFileMgr::OpenFile("main_freeroam.scm", "rb"); + case 1: return CFileMgr::OpenFile("freeroam_miami.scm", "rb"); case 2: return CFileMgr::OpenFile("main_d.scm", "rb"); } return CFileMgr::OpenFile("main.scm", "rb"); @@ -646,6 +729,7 @@ void CTheScripts::Process() float timeStep = CTimer::GetTimeStepInMilliseconds(); UpsideDownCars.UpdateTimers(); StuckCars.Process(); + MissionCleanup.CheckIfCollisionHasLoadedForMissionObject(); DrawScriptSpheres(); if (FailCurrentMission) --FailCurrentMission; @@ -736,15 +820,16 @@ int8 CRunningScript::ProcessOneCommand() return ProcessCommands800To899(command); if (command < 1000) return ProcessCommands900To999(command); -#ifdef GTA_PS2 - if (command < 1200) - return ProcessCommands1000To1099(command); -#else if (command < 1100) return ProcessCommands1000To1099(command); if (command < 1200) return ProcessCommands1100To1199(command); -#endif + if (command < 1300) + return ProcessCommands1200To1299(command); + if (command < 1400) + return ProcessCommands1300To1399(command); + if (command < 1500) + return ProcessCommands1400To1499(command); return -1; } @@ -1728,6 +1813,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) ped->SetPosition(pos); ped->SetOrientation(0.0f, 0.0f, 0.0f); CTheScripts::ClearSpaceForMissionEntity(pos, ped); + if (m_bIsMissionScript) + ped->bIsStaticWaitingForCollision = true; CWorld::Add(ped); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); CPopulation::ms_nTotalMissionPeds++; @@ -1946,6 +2033,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) boat->AutoPilot.m_nCarMission = MISSION_NONE; boat->AutoPilot.m_nTempAction = TEMPACT_NONE; /* Animation ID? */ boat->AutoPilot.m_nCruiseSpeed = boat->AutoPilot.m_fMaxTrafficSpeed = 20.0f; + if (m_bIsMissionScript) + boat->bIsStaticWaitingForCollision = true; CWorld::Add(boat); handle = CPools::GetVehiclePool()->GetIndex(boat); } @@ -1970,6 +2059,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->bEngineOn = false; car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); car->bHasBeenOwnedByPlayer = true; + if (m_bIsMissionScript) + car->bIsStaticWaitingForCollision = true; CWorld::Add(car); handle = CPools::GetVehiclePool()->GetIndex(car); } @@ -2669,11 +2760,11 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; char label[12]; CTheScripts::ReadTextLabelFromScript(&m_nIp, label); - int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label); + int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT); if (zoneToCheck != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; /* why only if zone != 1? */ CVector pos = pPlayer->GetPos(); - CZone* pZone = CTheZones::GetZone(zoneToCheck); + CZone* pZone = CTheZones::GetNavigationZone(zoneToCheck); UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, pZone)); return 0; } @@ -3001,7 +3092,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) CTheScripts::ReadTextLabelFromScript(&m_nIp, label); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 16); - int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); + int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); if (zone < 0) { debug("Couldn't find zone - %s\n", label); return 0; @@ -3022,41 +3113,17 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) assert(pPed); char label[12]; CTheScripts::ReadTextLabelFromScript(&m_nIp, label); - int zone = CTheZones::FindZoneByLabelAndReturnIndex(label); + int zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT); if (zone != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); - UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, CTheZones::GetZone(zone))); + UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, CTheZones::GetNavigationZone(zone))); return 0; } + /* Not implemented. case COMMAND_SET_CAR_DENSITY: - { - char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); - int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); - m_nIp += 8; - CollectParameters(&m_nIp, 2); - if (zone < 0) { - debug("Couldn't find zone - %s\n", label); - return 0; - } - CTheZones::SetCarDensity(zone, ScriptParams[0], ScriptParams[1]); - return 0; - } case COMMAND_SET_PED_DENSITY: - { - char label[12]; - CTheScripts::ReadTextLabelFromScript(&m_nIp, label); - int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); - m_nIp += KEY_LENGTH_IN_SCRIPT; - CollectParameters(&m_nIp, 2); - if (zone < 0) { - debug("Couldn't find zone - %s\n", label); - return 0; - } - CTheZones::SetPedDensity(zone, ScriptParams[0], ScriptParams[1]); - return 0; - } + */ case COMMAND_POINT_CAMERA_AT_PLAYER: { CollectParameters(&m_nIp, 3); @@ -3092,7 +3159,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) CTheScripts::ReadTextLabelFromScript(&m_nIp, label); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 10); - int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label); + int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); if (zone < 0) { debug("Couldn't find zone - %s\n", label); return 0; @@ -5279,8 +5346,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) CollectParameters(&m_nIp, 1); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); assert(pVehicle); - int mi = pVehicle->GetModelIndex(); - UpdateCompareFlag(mi == MI_TAXI || mi == MI_CABBIE || mi == MI_BORGNINE); + UpdateCompareFlag(pVehicle->IsTaxi()); return 0; } case COMMAND_UNLOAD_SPECIAL_CHARACTER: @@ -5853,10 +5919,10 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { char zone[KEY_LENGTH_IN_SCRIPT]; strncpy(zone, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); - int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone); + int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT); if (nZone != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; - CZone* pZone = CTheZones::GetZone(nZone); + CZone* pZone = CTheZones::GetNavigationZone(nZone); int ped_handle = -1; CVector pos = FindPlayerCoors(); int i = CPools::GetPedPool()->GetSize(); @@ -6461,7 +6527,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); m_nIp += KEY_LENGTH_IN_SCRIPT; CollectParameters(&m_nIp, 2); - int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); + int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_INFO); if (zone_id < 0) { printf("Couldn't find zone - %s\n", zone); return 0; @@ -6521,10 +6587,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { char zone[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); - int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); +// TODO(MIAMI): just getting this to compile with new argument + int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT); if (zone_id != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; - CZone* pZone = CTheZones::GetZone(zone_id); + CZone* pZone = CTheZones::GetNavigationZone(zone_id); CollectParameters(&m_nIp, 1); int handle = -1; uint32 i = CPools::GetVehiclePool()->GetSize(); @@ -7027,10 +7094,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 1); char zone[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, zone); - int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone); +// TODO(MIAMI): just getting this to compile with new argument + int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT); if (zone_id != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; - CZone* pZone = CTheZones::GetZone(zone_id); + CZone* pZone = CTheZones::GetNavigationZone(zone_id); UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0], pZone->minx, pZone->maxx, pZone->miny, pZone->maxy, pZone->minz, pZone->maxz)); return 0; @@ -7162,7 +7230,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) if (total == 0) CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(LEVEL_NONE), pos, range, true, &total, 16, apEntities); if (total == 0) - CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(CTheZones::FindZoneForPoint(pos)), pos, range, true, &total, 16, apEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(CTheZones::GetLevelFromPosition(&pos)), pos, range, true, &total, 16, apEntities); CEntity* pClosestEntity = nil; float min_dist = 2.0f * range; for (int i = 0; i < total; i++) { @@ -7346,6 +7414,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) ped->SetPosition(pos); ped->SetOrientation(0.0f, 0.0f, 0.0f); CTheScripts::ClearSpaceForMissionEntity(pos, ped); + if (m_bIsMissionScript) + ped->bIsStaticWaitingForCollision = true; CWorld::Add(ped); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); CPopulation::ms_nTotalMissionPeds++; @@ -7914,7 +7984,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) if (total == 0) CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_NONE), pos, radius, true, &total, 16, apEntities); if (total == 0) - CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(CTheZones::FindZoneForPoint(pos)), pos, radius, true, &total, 16, apEntities); + CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(CTheZones::GetLevelFromPosition(&pos)), pos, radius, true, &total, 16, apEntities); CEntity* pClosestEntity = nil; float min_dist = 2.0f * radius; for (int i = 0; i < total; i++) { @@ -8088,7 +8158,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_FBICAR: case MI_MRWHOOP: case MI_BFINJECT: - case MI_CORPSE: + // case MI_CORPSE: case MI_POLICE: case MI_ENFORCER: case MI_SECURICA: @@ -8101,27 +8171,27 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_DODO: case MI_COACH: case MI_RCBANDIT: - case MI_BELLYUP: - case MI_MRWONGS: - case MI_MAFIA: - case MI_YARDIE: - case MI_YAKUZA: - case MI_DIABLOS: - case MI_COLUMB: - case MI_HOODS: + // case MI_BELLYUP: + // case MI_MRWONGS: + // case MI_MAFIA: + case MI_VOODOO: + // case MI_YAKUZA: + // case MI_DIABLOS: + // case MI_COLUMB: + // case MI_HOODS: case MI_AIRTRAIN: case MI_DEADDODO: case MI_SPEEDER: case MI_REEFER: - case MI_PANLANT: + // case MI_PANLANT: case MI_FLATBED: case MI_YANKEE: - case MI_ESCAPE: - case MI_BORGNINE: - case MI_TOYZ: - case MI_GHOST: - case MI_MIAMI_RCBARON: - case MI_MIAMI_RCRAIDER: + // case MI_ESCAPE: + case MI_ZEBRA: + case MI_TOPFUN: + // case MI_GHOST: + case MI_RCBARON: + case MI_RCRAIDER: model = -1; break; case MI_IDAHO: @@ -8131,21 +8201,21 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_PATRIOT: case MI_MANANA: case MI_INFERNUS: - case MI_BLISTA: + // case MI_BLISTA: case MI_PONY: case MI_CHEETAH: case MI_MOONBEAM: case MI_ESPERANT: case MI_TAXI: - case MI_KURUMA: + case MI_WASHING: case MI_BOBCAT: case MI_BANSHEE: case MI_CABBIE: case MI_STALLION: case MI_RUMPO: - case 151: - case 152: - case 153: +// case 151: +// case 152: +// case 153: break; default: printf("CREATE_RANDOM_CAR_FOR_CAR_PARK - Unknown car model %d\n", CStreaming::ms_vehiclesLoaded[index]); @@ -8342,10 +8412,15 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) ScriptParams[0] = CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages; StoreParameters(&m_nIp, 1); return 0; - case COMMAND_REGISTER_EL_BURRO_TIME: + case COMMAND_SET_CHAR_OBJ_LEAVE_ANY_CAR: + { CollectParameters(&m_nIp, 1); - CStats::RegisterElBurroTime(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + assert(pPed); + pPed->bScriptObjectiveCompleted = false; + pPed->SetObjective(OBJECTIVE_LEAVE_VEHICLE, pPed->m_pMyVehicle); return 0; + } case COMMAND_SET_SPRITES_DRAW_BEFORE_FADE: CollectParameters(&m_nIp, 1); CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_bBeforeFade = ScriptParams[0] != 0; @@ -8520,21 +8595,17 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) pPed->m_nZoneLevel = LEVEL_NONE; return 0; } - case COMMAND_REGISTER_4X4_ONE_TIME: - CollectParameters(&m_nIp, 1); - CStats::Register4x4OneTime(ScriptParams[0]); + case COMMAND_SET_DRUNK_INPUT_DELAY: + assert(0 && "SET_DRUNK_INPUT_DELAY not yet implemented"); return 0; - case COMMAND_REGISTER_4X4_TWO_TIME: - CollectParameters(&m_nIp, 1); - CStats::Register4x4TwoTime(ScriptParams[0]); + case COMMAND_SET_CHAR_MONEY: + assert(0 && "SET_CHAR_MONEY not yet implemented"); return 0; - case COMMAND_REGISTER_4X4_THREE_TIME: - CollectParameters(&m_nIp, 1); - CStats::Register4x4ThreeTime(ScriptParams[0]); + case COMMAND_INCREASE_CHAR_MONEY: + assert(0 && "INCREASE_CHAR_MONEY not yet implemented"); return 0; - case COMMAND_REGISTER_4X4_MAYHEM_TIME: - CollectParameters(&m_nIp, 1); - CStats::Register4x4MayhemTime(ScriptParams[0]); + case COMMAND_GET_OFFSET_FROM_OBJECT_IN_WORLD_COORDS: + assert(0 && "GET_OFFSET_FROM_OBJECT_IN_WORLD_COORDS not yet implemented"); return 0; case COMMAND_REGISTER_LIFE_SAVED: CStats::AnotherLifeSavedWithAmbulance(); @@ -8557,9 +8628,8 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CollectParameters(&m_nIp, 1); CStats::RegisterLongestFlightInDodo(ScriptParams[0]); return 0; - case COMMAND_REGISTER_DEFUSE_BOMB_TIME: - CollectParameters(&m_nIp, 1); - CStats::RegisterTimeTakenDefuseMission(ScriptParams[0]); + case COMMAND_GET_OFFSET_FROM_CAR_IN_WORLD_COORDS: + assert(0 && "GET_OFFSET_FROM_CAR_IN_WORLD_COORDS not yet implemented"); return 0; case COMMAND_SET_TOTAL_NUMBER_OF_KILL_FRENZIES: CollectParameters(&m_nIp, 1); @@ -9072,7 +9142,6 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); return 0; } -#ifndef GTA_PS2 default: assert(0); } @@ -9083,7 +9152,6 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { char tmp[48]; switch (command) { -#endif case COMMAND_LOAD_COLLISION_WITH_SCREEN: CollectParameters(&m_nIp, 1); CTimer::Stop(); @@ -9149,9 +9217,6 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA: CPad::GetPad(0)->DisablePlayerControls &= PLAYERCONTROL_DISABLED_1; return 0; -#ifndef GTA_PS2 - // To be precise, on PS2 previous handlers were in 1000-1099 function - // These are "beta" VC commands (with bugs) case COMMAND_SET_OBJECT_ROTATION: { CollectParameters(&m_nIp, 4); @@ -9440,10 +9505,11 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { char zone[KEY_LENGTH_IN_SCRIPT]; strncpy(zone, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); - int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone); +// TODO(MIAMI): just getting this to compile with new argument + int nZone = CTheZones::FindZoneByLabelAndReturnIndex(zone, ZONE_DEFAULT); if (nZone != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; - CZone* pZone = CTheZones::GetZone(nZone); + CZone* pZone = CTheZones::GetNavigationZone(nZone); int ped_handle = -1; CVector pos = FindPlayerCoors(); int i = CPools::GetPedPool()->GetSize(); @@ -9560,13 +9626,13 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_LOCATE_CHAR_IN_CAR_OBJECT_3D: LocateCharObjectCommand(command, &m_nIp); return 0; - case COMMAND_SET_CAR_HANDBRAKE_TURN_LEFT: // this will be changed in final VC version to a more general SET_TEMP_ACTION + case COMMAND_SET_CAR_TEMP_ACTION: { - CollectParameters(&m_nIp, 2); + CollectParameters(&m_nIp, 3); CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); assert(pVehicle); - pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKETURNLEFT; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; + pVehicle->AutoPilot.m_nTempAction = (eCarTempAction)ScriptParams[1]; + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[2]; return 0; } case COMMAND_SET_CAR_HANDBRAKE_TURN_RIGHT: @@ -9637,23 +9703,330 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) } case COMMAND_SET_ENTER_CAR_RANGE_MULTIPLIER: CollectParameters(&m_nIp, 1); -#ifdef FIX_BUGS CPed::nEnterCarRangeMultiplier = *(float*)&ScriptParams[0]; -#else - CPed::nEnterCarRangeMultiplier = (float)ScriptParams[0]; -#endif return 0; -#endif -#ifndef GTA3_1_1_PATCH case COMMAND_SET_THREAT_REACTION_RANGE_MULTIPLIER: CollectParameters(&m_nIp, 1); -#ifdef FIX_BUGS CPed::nThreatReactionRangeMultiplier = *(float*)&ScriptParams[0]; -#else - CPed::nThreatReactionRangeMultiplier = (float)ScriptParams[0]; -#endif return 0; -#endif + case COMMAND_SET_CHAR_CEASE_ATTACK_TIMER: + case COMMAND_GET_REMOTE_CONTROLLED_CAR: + case COMMAND_IS_PC_VERSION: + case COMMAND_REPLAY: + case COMMAND_IS_REPLAY_PLAYING: + case COMMAND_IS_MODEL_AVAILABLE: + case COMMAND_SHUT_CHAR_UP: + case COMMAND_SET_ENABLE_RC_DETONATE: + case COMMAND_SET_CAR_RANDOM_ROUTE_SEED: + case COMMAND_IS_ANY_PICKUP_AT_COORDS: + case COMMAND_GET_FIRST_PICKUP_COORDS: + case COMMAND_GET_NEXT_PICKUP_COORDS: + case COMMAND_REMOVE_ALL_CHAR_WEAPONS: + case COMMAND_HAS_PLAYER_GOT_WEAPON: + case COMMAND_HAS_CHAR_GOT_WEAPON: + case COMMAND_IS_PLAYER_FACING_CHAR: + case COMMAND_SET_TANK_DETONATE_CARS: + case COMMAND_GET_POSITION_OF_ANALOGUE_STICKS: + case COMMAND_IS_CAR_ON_FIRE: + case COMMAND_IS_CAR_TYRE_BURST: + case COMMAND_SET_CAR_DRIVE_STRAIGHT_AHEAD: + case COMMAND_SET_CAR_WAIT: + case COMMAND_IS_PLAYER_STANDING_ON_A_VEHICLE: + case COMMAND_IS_PLAYER_FOOT_DOWN: + case COMMAND_IS_CHAR_FOOT_DOWN: + case COMMAND_INITIALISE_OBJECT_PATH: + case COMMAND_START_OBJECT_ON_PATH: + case COMMAND_SET_OBJECT_PATH_SPEED: + case COMMAND_SET_OBJECT_PATH_POSITION: + case COMMAND_GET_OBJECT_DISTANCE_ALONG_PATH: + case COMMAND_CLEAR_OBJECT_PATH: + case COMMAND_HELI_GOTO_COORDS: + case COMMAND_IS_INT_VAR_EQUAL_TO_CONSTANT: + case COMMAND_IS_INT_LVAR_EQUAL_TO_CONSTANT: + case COMMAND_GET_DEAD_CHAR_PICKUP_COORDS: + case COMMAND_CREATE_PROTECTION_PICKUP: + case COMMAND_IS_CHAR_IN_ANY_BOAT: + case COMMAND_IS_PLAYER_IN_ANY_BOAT: + case COMMAND_IS_CHAR_IN_ANY_HELI: + case COMMAND_IS_PLAYER_IN_ANY_HELI: + case COMMAND_IS_CHAR_IN_ANY_PLANE: + case COMMAND_IS_PLAYER_IN_ANY_PLANE: + case COMMAND_IS_CHAR_IN_WATER: + case COMMAND_SET_VAR_INT_TO_CONSTANT: + case COMMAND_SET_LVAR_INT_TO_CONSTANT: + default: + assert(0); + } + return -1; +} + + +int8 CRunningScript::ProcessCommands1200To1299(int32 command) +{ + switch (command) { + case COMMAND_IS_INT_VAR_GREATER_THAN_CONSTANT: + case COMMAND_IS_INT_LVAR_GREATER_THAN_CONSTANT: + case COMMAND_IS_CONSTANT_GREATER_THAN_INT_VAR: + case COMMAND_IS_CONSTANT_GREATER_THAN_INT_LVAR: + case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT: + case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT: + case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR: + case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR: + case COMMAND_GET_CHAR_WEAPON_IN_SLOT: + case COMMAND_GET_CLOSEST_STRAIGHT_ROAD: + case COMMAND_SET_CAR_FORWARD_SPEED: + case COMMAND_SET_AREA_VISIBLE: + case COMMAND_SET_CUTSCENE_ANIM_TO_LOOP: + case COMMAND_MARK_CAR_AS_CONVOY_CAR: + case COMMAND_RESET_HAVOC_CAUSED_BY_PLAYER: + case COMMAND_GET_HAVOC_CAUSED_BY_PLAYER: + case COMMAND_CREATE_SCRIPT_ROADBLOCK: + case COMMAND_CLEAR_ALL_SCRIPT_ROADBLOCKS: + case COMMAND_SET_CHAR_OBJ_WALK_TO_CHAR: + case COMMAND_IS_PICKUP_IN_ZONE: + case COMMAND_GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS: + case COMMAND_HAS_CHAR_BEEN_PHOTOGRAPHED: + case COMMAND_SET_CHAR_OBJ_AIM_GUN_AT_CHAR: + case COMMAND_SWITCH_SECURITY_CAMERA: + case COMMAND_IS_CHAR_IN_FLYING_VEHICLE: + case COMMAND_IS_PLAYER_IN_FLYING_VEHICLE: + case COMMAND_HAS_SONY_CD_BEEN_READ: + case COMMAND_GET_NUMBER_OF_SONY_CDS_READ: + case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_COORD_OLD: + case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_COORD: + case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_COORD: + case COMMAND_ADD_MONEY_SPENT_ON_CLOTHES: + case COMMAND_SET_HELI_ORIENTATION: + case COMMAND_CLEAR_HELI_ORIENTATION: + case COMMAND_PLANE_GOTO_COORDS: + case COMMAND_GET_NTH_CLOSEST_CAR_NODE: + case COMMAND_GET_NTH_CLOSEST_CHAR_NODE: + case COMMAND_DRAW_WEAPONSHOP_CORONA: + case COMMAND_SET_ENABLE_RC_DETONATE_ON_CONTACT: + case COMMAND_FREEZE_CHAR_POSITION: + case COMMAND_SET_CHAR_DROWNS_IN_WATER: + case COMMAND_SET_OBJECT_RECORDS_COLLISIONS: + case COMMAND_HAS_OBJECT_COLLIDED_WITH_ANYTHING: + case COMMAND_REMOVE_RC_BUGGY: + case COMMAND_HAS_PHOTOGRAPH_BEEN_TAKEN: + case COMMAND_GET_CHAR_ARMOUR: + case COMMAND_SET_CHAR_ARMOUR: + case COMMAND_SET_HELI_STABILISER: + case COMMAND_SET_CAR_STRAIGHT_LINE_DISTANCE: + case COMMAND_POP_CAR_BOOT: + case COMMAND_SHUT_PLAYER_UP: + case COMMAND_SET_PLAYER_MOOD: + assert(0); + case COMMAND_REQUEST_COLLISION: + { + CollectParameters(&m_nIp, 2); + CVector2D pos; + pos.x = *(float*)&ScriptParams[0]; + pos.y = *(float*)&ScriptParams[1]; + CColStore::RequestCollision(pos); + return 0; + } + case COMMAND_LOCATE_OBJECT_2D: + case COMMAND_LOCATE_OBJECT_3D: + case COMMAND_IS_OBJECT_IN_WATER: + case COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR_EVEN_MISSION_CAR: + case COMMAND_IS_OBJECT_IN_AREA_2D: + case COMMAND_IS_OBJECT_IN_AREA_3D: + case COMMAND_TASK_TOGGLE_DUCK: + case COMMAND_SET_ZONE_CIVILIAN_CAR_INFO: + case COMMAND_REQUEST_ANIMATION: + case COMMAND_HAS_ANIMATION_LOADED: + case COMMAND_REMOVE_ANIMATION: + case COMMAND_IS_CHAR_WAITING_FOR_WORLD_COLLISION: + case COMMAND_IS_CAR_WAITING_FOR_WORLD_COLLISION: + case COMMAND_IS_OBJECT_WAITING_FOR_WORLD_COLLISION: + case COMMAND_SET_CHAR_SHUFFLE_INTO_DRIVERS_SEAT: + case COMMAND_ATTACH_CHAR_TO_OBJECT: + case COMMAND_SET_CHAR_AS_PLAYER_FRIEND: + case COMMAND_DISPLAY_NTH_ONSCREEN_COUNTER: + case COMMAND_DISPLAY_NTH_ONSCREEN_COUNTER_WITH_STRING: + case COMMAND_ADD_SET_PIECE: + case COMMAND_SET_EXTRA_COLOURS: + case COMMAND_CLEAR_EXTRA_COLOURS: + case COMMAND_CLOSE_CAR_BOOT: + case COMMAND_GET_WHEELIE_STATS: + case COMMAND_DISARM_CHAR: + case COMMAND_BURST_CAR_TYRE: + case COMMAND_IS_CHAR_OBJ_NO_OBJ: + case COMMAND_IS_PLAYER_WEARING: + case COMMAND_SET_PLAYER_CAN_DO_DRIVE_BY: + case COMMAND_SET_CHAR_OBJ_SPRINT_TO_COORD: + case COMMAND_CREATE_SWAT_ROPE: + case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA: + case COMMAND_GET_NEAREST_TYRE_TO_POINT: + case COMMAND_SET_CAR_MODEL_COMPONENTS: + case COMMAND_SWITCH_LIFT_CAMERA: + case COMMAND_CLOSE_ALL_CAR_DOORS: + case COMMAND_GET_DISTANCE_BETWEEN_COORDS_2D: + case COMMAND_GET_DISTANCE_BETWEEN_COORDS_3D: + case COMMAND_POP_CAR_BOOT_USING_PHYSICS: + case COMMAND_SET_FIRST_PERSON_WEAPON_CAMERA: + case COMMAND_IS_CHAR_LEAVING_VEHICLE_TO_DIE: + case COMMAND_SORT_OUT_OBJECT_COLLISION_WITH_CAR: + case COMMAND_GET_MAX_WANTED_LEVEL: + case COMMAND_IS_CHAR_WANDER_PATH_CLEAR: + case COMMAND_PRINT_HELP_WITH_NUMBER: + case COMMAND_PRINT_HELP_FOREVER: + case COMMAND_PRINT_HELP_FOREVER_WITH_NUMBER: + default: + assert(0); + } + return -1; +} + +int8 CRunningScript::ProcessCommands1300To1399(int32 command) +{ + switch (command) { + case COMMAND_SET_CHAR_CAN_BE_DAMAGED_BY_MEMBERS_OF_GANG: + case COMMAND_LOAD_AND_LAUNCH_MISSION_EXCLUSIVE: + case COMMAND_IS_MISSION_AUDIO_PLAYING: + case COMMAND_CREATE_LOCKED_PROPERTY_PICKUP: + case COMMAND_CREATE_FORSALE_PROPERTY_PICKUP: + case COMMAND_FREEZE_CAR_POSITION: + case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CHAR: + case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CAR: + case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CHAR: + case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CAR: + case COMMAND_GET_RADIO_CHANNEL: + case COMMAND_DISPLAY_TEXT_WITH_3_NUMBERS: + case COMMAND_IS_CAR_DROWNING_IN_WATER: + case COMMAND_IS_CHAR_DROWNING_IN_WATER: + case COMMAND_DISABLE_CUTSCENE_SHADOWS: + case COMMAND_HAS_GLASS_BEEN_SHATTERED_NEARBY: + case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_BONE: + case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_COMPONENT: + case COMMAND_SET_CHAR_STAY_IN_CAR_WHEN_JACKED: + case COMMAND_IS_MISSION_AUDIO_LOADING: + case COMMAND_ADD_MONEY_SPENT_ON_WEAPONS: + case COMMAND_ADD_MONEY_SPENT_ON_PROPERTY: + case COMMAND_ADD_MONEY_SPENT_ON_AUTO_PAINTING: + case COMMAND_SET_CHAR_ANSWERING_MOBILE: + case COMMAND_SET_PLAYER_DRUNKENNESS: + case COMMAND_GET_PLAYER_DRUNKENNESS: + case COMMAND_SET_PLAYER_DRUG_LEVEL: + case COMMAND_GET_PLAYER_DRUG_LEVEL: + case COMMAND_ADD_LOAN_SHARK_VISITS: + case COMMAND_ADD_STORES_KNOCKED_OFF: + case COMMAND_ADD_MOVIE_STUNTS: + case COMMAND_ADD_NUMBER_OF_ASSASSINATIONS: + case COMMAND_ADD_PIZZAS_DELIVERED: + case COMMAND_ADD_GARBAGE_PICKUPS: + case COMMAND_ADD_ICE_CREAMS_SOLD: + case COMMAND_SET_TOP_SHOOTING_RANGE_SCORE: + case COMMAND_ADD_SHOOTING_RANGE_RANK: + case COMMAND_ADD_MONEY_SPENT_ON_GAMBLING: + case COMMAND_ADD_MONEY_WON_ON_GAMBLING: + case COMMAND_SET_LARGEST_GAMBLING_WIN: + case COMMAND_SET_CHAR_IN_PLAYERS_GROUP_CAN_FIGHT: + case COMMAND_CLEAR_CHAR_WAIT_STATE: + case COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_AREA_NO_SAVE: + case COMMAND_SET_CAN_BURST_CAR_TYRES: + case COMMAND_SET_PLAYER_AUTO_AIM: + case COMMAND_FIRE_HUNTER_GUN: + case COMMAND_SET_PROPERTY_AS_OWNED: + case COMMAND_ADD_BLOOD_RING_KILLS: + case COMMAND_SET_LONGEST_TIME_IN_BLOOD_RING: + case COMMAND_REMOVE_EVERYTHING_FOR_HUGE_CUTSCENE: + case COMMAND_IS_PLAYER_TOUCHING_VEHICLE: + case COMMAND_IS_CHAR_TOUCHING_VEHICLE: + case COMMAND_CHECK_FOR_PED_MODEL_AROUND_PLAYER: + case COMMAND_CLEAR_CHAR_FOLLOW_PATH: + case COMMAND_SET_CHAR_CAN_BE_SHOT_IN_VEHICLE: + case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_VEHICLE: + case COMMAND_LOAD_MISSION_TEXT: + case COMMAND_SET_TONIGHTS_EVENT: + case COMMAND_CLEAR_CHAR_LAST_DAMAGE_ENTITY: + case COMMAND_CLEAR_CAR_LAST_DAMAGE_ENTITY: + case COMMAND_FREEZE_OBJECT_POSITION: + case COMMAND_SET_PLAYER_HAS_MET_DEBBIE_HARRY: + case COMMAND_SET_RIOT_INTENSITY: + case COMMAND_IS_CAR_IN_ANGLED_AREA_2D: + case COMMAND_IS_CAR_IN_ANGLED_AREA_3D: + case COMMAND_REMOVE_WEAPON_FROM_CHAR: + case COMMAND_SET_UP_TAXI_SHORTCUT: + case COMMAND_CLEAR_TAXI_SHORTCUT: + case COMMAND_SET_CHAR_OBJ_GOTO_CAR_ON_FOOT: + case COMMAND_GET_CLOSEST_WATER_NODE: + case COMMAND_ADD_PORN_LEAFLET_TO_RUBBISH: + case COMMAND_CREATE_CLOTHES_PICKUP: + case COMMAND_CHANGE_BLIP_THRESHOLD: + case COMMAND_MAKE_PLAYER_FIRE_PROOF: + case COMMAND_INCREASE_PLAYER_MAX_HEALTH: + case COMMAND_INCREASE_PLAYER_MAX_ARMOUR: + case COMMAND_CREATE_RANDOM_CHAR_AS_DRIVER: + case COMMAND_CREATE_RANDOM_CHAR_AS_PASSENGER: + case COMMAND_SET_CHAR_IGNORE_THREATS_BEHIND_OBJECTS: + case COMMAND_ENSURE_PLAYER_HAS_DRIVE_BY_WEAPON: + case COMMAND_MAKE_HELI_COME_CRASHING_DOWN: + case COMMAND_ADD_EXPLOSION_NO_SOUND: + case COMMAND_SET_OBJECT_AREA_VISIBLE: + case COMMAND_WAS_VEHICLE_EVER_POLICE: + case COMMAND_SET_CHAR_NEVER_TARGETTED: + case COMMAND_LOAD_UNCOMPRESSED_ANIM: + case COMMAND_WAS_CUTSCENE_SKIPPED: + case COMMAND_SET_CHAR_CROUCH_WHEN_THREATENED: + case COMMAND_IS_CHAR_IN_ANY_POLICE_VEHICLE: + case COMMAND_DOES_CHAR_EXIST: + case COMMAND_DOES_VEHICLE_EXIST: + case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_CONTACT_POINT: + case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_CONTACT_POINT: + case COMMAND_IS_CHAR_STUCK: + case COMMAND_SET_ALL_TAXIS_HAVE_NITRO: + case COMMAND_SET_CHAR_STOP_SHOOT_DONT_SEEK_ENTITY: + case COMMAND_FREEZE_CAR_POSITION_AND_DONT_LOAD_COLLISION: + case COMMAND_FREEZE_CHAR_POSITION_AND_DONT_LOAD_COLLISION: + case COMMAND_FREEZE_OBJECT_POSITION_AND_DONT_LOAD_COLLISION: + case COMMAND_SET_FADE_AND_JUMPCUT_AFTER_RC_EXPLOSION: + default: + assert(0); + } + return -1; +} + +int8 CRunningScript::ProcessCommands1400To1499(int32 command) +{ + switch (command) { + case COMMAND_REGISTER_VIGILANTE_LEVEL: + case COMMAND_CLEAR_ALL_CHAR_ANIMS: + case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE: + case COMMAND_WANTED_STARS_ARE_FLASHING: + case COMMAND_SET_ALLOW_HURRICANES: + case COMMAND_PLAY_ANNOUNCEMENT: + case COMMAND_SET_PLAYER_IS_IN_STADIUM: + case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER: + case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM: + case COMMAND_DISPLAY_RADAR: + case COMMAND_REGISTER_BEST_POSITION: + case COMMAND_IS_PLAYER_IN_INFO_ZONE: + case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE: + case COMMAND_IS_IN_CAR_FIRE_BUTTON_PRESSED: + case COMMAND_HAS_CHAR_ATTEMPTED_ATTRACTOR: + case COMMAND_SET_LOAD_COLLISION_FOR_CAR_FLAG: + case COMMAND_SET_LOAD_COLLISION_FOR_CHAR_FLAG: + case COMMAND_SET_LOAD_COLLISION_FOR_OBJECT_FLAG: + case COMMAND_ADD_BIG_GUN_FLASH: + case COMMAND_HAS_CHAR_BOUGHT_ICE_CREAM: + case COMMAND_GET_PROGRESS_PERCENTAGE: + case COMMAND_SET_SHORTCUT_PICKUP_POINT: + case COMMAND_SET_SHORTCUT_DROPOFF_POINT_FOR_MISSION: + case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA: + case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_ZONE: + case COMMAND_UNLOCK_ALL_CAR_DOORS_IN_AREA: + case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS: + case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR: + case COMMAND_SET_VEHICLE_TO_FADE_IN: + case COMMAND_REGISTER_ODDJOB_MISSION_PASSED: + case COMMAND_IS_PLAYER_IN_SHORTCUT_TAXI: + case COMMAND_IS_CHAR_DUCKING: + case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI: + case COMMAND_REGISTER_FIRE_LEVEL: + case COMMAND_IS_AUSTRALIAN_GAME: + case COMMAND_DISARM_CAR_BOMB: default: assert(0); } |