diff options
Diffstat (limited to 'src/control/Script8.cpp')
-rw-r--r-- | src/control/Script8.cpp | 615 |
1 files changed, 399 insertions, 216 deletions
diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 2d1ccdf4..6c7cbe91 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -4,7 +4,7 @@ #include "ScriptCommands.h" #include "DMAudio.h" -#if ((defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) && defined MORE_LANGUAGES) +#ifdef MORE_LANGUAGES #include "Frontend.h" #endif #include "GameLogic.h" @@ -12,13 +12,10 @@ #ifdef MISSION_REPLAY #include "GenericGameStorage.h" #endif -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) -#include "General.h" -#include "maths.h" -#endif #include "Hud.h" #include "Pad.h" #include "PedAttractor.h" +#include "Pickups.h" #include "Population.h" #include "Pools.h" #include "RpAnimBlend.h" @@ -29,19 +26,20 @@ #include "World.h" #include "Zones.h" +// LCS: file done except TODOs (also check commented out strings) + int8 CRunningScript::ProcessCommands1400To1499(int32 command) { switch (command) { case COMMAND_REGISTER_VIGILANTE_LEVEL: CollectParameters(&m_nIp, 1); - CStats::RegisterLevelVigilanteMission(ScriptParams[0]); + CStats::RegisterLevelVigilanteMission(GET_INTEGER_PARAM(0)); return 0; case COMMAND_CLEAR_ALL_CHAR_ANIMS: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - script_assert(pPed); - if (!pPed->bInVehicle) { + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (pPed && pPed->GetPedState() != PED_DRIVING && pPed->GetPedState() != PED_AIM_GUN) { pPed->m_pVehicleAnim = nil; pPed->RestartNonPartialAnims(); RpAnimBlendClumpRemoveAllAssociations(pPed->GetClump()); @@ -62,7 +60,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE: CollectParameters(&m_nIp, 2); - CGarages::SetMaxNumStoredCarsForGarage(ScriptParams[0], ScriptParams[1]); + CGarages::SetMaxNumStoredCarsForGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_WANTED_STARS_ARE_FLASHING: { @@ -72,25 +70,25 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_SET_ALLOW_HURRICANES: CollectParameters(&m_nIp, 1); - CStats::NoMoreHurricanes = ScriptParams[0]; + CStats::NoMoreHurricanes = GET_INTEGER_PARAM(0); return 0; case COMMAND_PLAY_ANNOUNCEMENT: { CollectParameters(&m_nIp, 1); - DMAudio.PlayRadioAnnouncement(ScriptParams[0] + STREAMED_SOUND_ANNOUNCE_BRIDGE_CLOSED); + DMAudio.PlayRadioAnnouncement(GET_INTEGER_PARAM(0) + STREAMED_SOUND_NEWS_A); return 0; } case COMMAND_SET_PLAYER_IS_IN_STADIUM: { CollectParameters(&m_nIp, 1); - CTheScripts::bPlayerIsInTheStatium = ScriptParams[0]; + CTheScripts::bPlayerIsInTheStatium = GET_INTEGER_PARAM(0); return 0; } case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - ScriptParams[0] = pPlayerInfo->m_pPed->m_nLastBusFareCollected; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + SET_INTEGER_PARAM(0, pPlayerInfo->m_pPed->m_nLastBusFareCollected); pPlayerInfo->m_pPed->m_nLastBusFareCollected = 0; StoreParameters(&m_nIp, 1); return 0; @@ -98,11 +96,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); - ScriptParams[0] = 0; + SET_INTEGER_PARAM(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 if (pEffect) { @@ -111,7 +109,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) if ((pPed->GetPosition() - pos).MagnitudeSqr() < SQR(20.0f)) { if (GetPedAttractorManager()->HasEmptySlot(pEffect) && GetPedAttractorManager()->IsApproachable(pEffect, pVehicle->GetMatrix(), 0, pPed)) { if (GetPedAttractorManager()->RegisterPedWithAttractor(pPed, pEffect, pVehicle->GetMatrix())) - ScriptParams[0] = 1; + SET_INTEGER_PARAM(0, 1); } } } @@ -121,16 +119,17 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_DISPLAY_RADAR: CollectParameters(&m_nIp, 1); - CHud::m_HideRadar = ScriptParams[0] == 0; + CHud::m_HideRadar = GET_INTEGER_PARAM(0) == 0; + // on PS2 two flags are set, on mobile none return 0; case COMMAND_REGISTER_BEST_POSITION: CollectParameters(&m_nIp, 2); - CStats::RegisterBestPosition(ScriptParams[0], ScriptParams[1]); + CStats::RegisterBestPosition(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_IS_PLAYER_IN_INFO_ZONE: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; char key[KEY_LENGTH_IN_SCRIPT]; memset(key, 0, KEY_LENGTH_IN_SCRIPT); CTheScripts::ReadTextLabelFromScript(&m_nIp, key); @@ -143,7 +142,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); if (pPed->m_attractor) GetPedAttractorManager()->DeRegisterPed(pPed, pPed->m_attractor); @@ -155,7 +154,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_HAS_CHAR_ATTEMPTED_ATTRACTOR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bHasAlreadyUsedAttractor); return 0; @@ -163,9 +162,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_SET_LOAD_COLLISION_FOR_CAR_FLAG: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pVehicle->bDontLoadCollision = false; if (m_bMissionFlag) { CWorld::Remove(pVehicle); @@ -186,9 +185,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_SET_LOAD_COLLISION_FOR_CHAR_FLAG: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pPed->bDontLoadCollision = false; if (m_bMissionFlag) { CWorld::Remove(pPed); @@ -210,31 +209,31 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_ADD_BIG_GUN_FLASH: { CollectParameters(&m_nIp, 6); - CWeapon::AddGunFlashBigGuns(*(CVector*)&ScriptParams[0], *(CVector*)&ScriptParams[3]); + CWeapon::AddGunFlashBigGuns(GET_VECTOR_PARAM(0), GET_VECTOR_PARAM(3)); return 0; } case COMMAND_HAS_CHAR_BOUGHT_ICE_CREAM: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bBoughtIceCream); return 0; } case COMMAND_GET_PROGRESS_PERCENTAGE: - *(float*)&ScriptParams[0] = CStats::GetPercentageProgress(); + SET_FLOAT_PARAM(0, CStats::GetPercentageProgress()); StoreParameters(&m_nIp, 1); return 0; case COMMAND_SET_SHORTCUT_PICKUP_POINT: { CollectParameters(&m_nIp, 4); - CGameLogic::AddShortCutPointAfterDeath(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]); + CGameLogic::AddShortCutPointAfterDeath(GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3)); return 0; } case COMMAND_SET_SHORTCUT_DROPOFF_POINT_FOR_MISSION: { CollectParameters(&m_nIp, 4); - CGameLogic::AddShortCutDropOffPointForMission(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]); + CGameLogic::AddShortCutDropOffPointForMission(GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3)); return 0; } case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA: @@ -242,10 +241,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) CollectParameters(&m_nIp, 7); int ped_handle = -1; CVector pos = FindPlayerCoors(); - float x1 = *(float*)&ScriptParams[0]; - float y1 = *(float*)&ScriptParams[1]; - float x2 = *(float*)&ScriptParams[2]; - float y2 = *(float*)&ScriptParams[3]; + float x1 = GET_FLOAT_PARAM(0); + float y1 = GET_FLOAT_PARAM(1); + float x2 = GET_FLOAT_PARAM(2); + float y2 = GET_FLOAT_PARAM(3); int i = CPools::GetPedPool()->GetSize(); while (--i && ped_handle == -1) { CPed* pPed = CPools::GetPedPool()->GetSlot(i); @@ -267,7 +266,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) continue; if (pPed->m_attractor) continue; - if (!ThisIsAValidRandomPed(pPed->m_nPedType, ScriptParams[4], ScriptParams[5], ScriptParams[6])) + if (!ThisIsAValidRandomPed(pPed->m_nPedType, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6))) continue; if (pPed->bIsLeader || pPed->m_leader) continue; @@ -285,7 +284,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR); } - ScriptParams[0] = ped_handle; + SET_INTEGER_PARAM(0, ped_handle); StoreParameters(&m_nIp, 1); return 0; } @@ -294,10 +293,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 4); 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]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(3); while (i--) { CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) @@ -309,22 +308,23 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS: CollectParameters(&m_nIp, 2); - CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + ScriptParams[0]), !!ScriptParams[1]); + CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + GET_INTEGER_PARAM(0)), !!GET_INTEGER_PARAM(1)); return 0; case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bHeldHostageInCar = ScriptParams[1]; + pPed->bHeldHostageInCar = GET_INTEGER_PARAM(1); + pPed->b1A4_2 = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_VEHICLE_TO_FADE_IN: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), ScriptParams[1]); + CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), GET_INTEGER_PARAM(1)); return 0; } case COMMAND_REGISTER_ODDJOB_MISSION_PASSED: @@ -336,7 +336,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_IS_PLAYER_IN_SHORTCUT_TAXI: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle == CGameLogic::pShortCutTaxi); return 0; @@ -344,7 +344,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_IS_CHAR_DUCKING: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_STD_DUCK_DOWN) != nil); return 0; @@ -352,24 +352,24 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI: { CollectParameters(&m_nIp, 3); - CObject* pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pHeli = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); bool found = false; float waterLevel = -1000.0f; CVector pos = pHeli->GetPosition(); - float radius = *(float*)&ScriptParams[1]; + float radius = GET_FLOAT_PARAM(1); float ground = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &found); if (!CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false)) waterLevel = 0.0f; if (waterLevel > ground) ground = waterLevel; - if (ScriptParams[2] > 8) - ScriptParams[2] = 8; - CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, ScriptParams[2]); + if (GET_INTEGER_PARAM(2) > 8) + SET_INTEGER_PARAM(2, 8); + CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, GET_INTEGER_PARAM(2)); return 0; } case COMMAND_REGISTER_FIRE_LEVEL: CollectParameters(&m_nIp, 1); - CStats::RegisterLevelFireMission(ScriptParams[0]); + CStats::RegisterLevelFireMission(GET_INTEGER_PARAM(0)); return 0; case COMMAND_IS_AUSTRALIAN_GAME: UpdateCompareFlag(false); // should we make some check? @@ -377,14 +377,13 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_DISARM_CAR_BOMB: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle->m_bombType != CARBOMB_NONE) { pVehicle->m_bombType = CARBOMB_NONE; pVehicle->m_pBombRigger = nil; } return 0; } -#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) case COMMAND_IS_JAPANESE_GAME: #ifdef MORE_LANGUAGES UpdateCompareFlag(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_JAPANESE); @@ -394,220 +393,404 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) UpdateCompareFlag(false); #endif return 0; -#elif (!defined GTA_PS2) - case COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED: + case COMMAND_1442: + CollectParameters(&m_nIp, 4); + return 0; + //case COMMAND_1443: + case COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS: { - script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); - uint16 var = CTheScripts::Read2BytesFromScript(&m_nIp); - CollectParameters(&m_nIp, 1); - //CUserDisplay::OnscnTimer.SetCounterFlashWhenFirstDisplayed(var, ScriptParams[0]); + CollectParameters(&m_nIp, 4); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float X2 = GET_FLOAT_PARAM(2); + float Y2 = GET_FLOAT_PARAM(3); + float fDistance = Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)); + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; } -#endif -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - case COMMAND_SHUFFLE_CARD_DECKS: + case COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS: { - CollectParameters(&m_nIp, 1); - script_assert(ScriptParams[0] >= 0 && ScriptParams[0] <= 6); - for (int i = 0; i < CARDS_IN_STACK; i++) - CTheScripts::CardStack[i] = 0; - int16 seq[CARDS_IN_STACK]; - for (int i = 0; i < MAX_DECKS * CARDS_IN_DECK; i++) - seq[i] = i; - int cards_left = CARDS_IN_DECK * ScriptParams[0]; - for (int k = 1; k < CARDS_IN_DECK + 1; k++) { - for (int deck = 0; deck < ScriptParams[0]; deck++) { - int index = CGeneral::GetRandomNumberInRange(0, cards_left); - CTheScripts::CardStack[seq[index]] = k; - for (int l = index; l < cards_left; l++) { - if (l + 1 < CARDS_IN_STACK) - seq[l] = seq[l + 1]; - else - seq[l] = 0; - } - --cards_left; - } - } - CTheScripts::CardStackPosition = 0; + CollectParameters(&m_nIp, 6); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float Z1 = GET_FLOAT_PARAM(2); + float X2 = GET_FLOAT_PARAM(3); + float Y2 = GET_FLOAT_PARAM(4); + float Z2 = GET_FLOAT_PARAM(5); + float fDistance = Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2) + (Z1 - Z2) * (Z1 - Z2)); + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; } - case COMMAND_FETCH_NEXT_CARD: + case COMMAND_DOT_PRODUCT_2D: { - if (CTheScripts::CardStack[CTheScripts::CardStackPosition] == 0) - CTheScripts::CardStackPosition = 0; - ScriptParams[0] = CTheScripts::CardStack[CTheScripts::CardStackPosition++]; - if (CTheScripts::CardStackPosition == CARDS_IN_DECK * MAX_DECKS) - CTheScripts::CardStackPosition = 0; + CollectParameters(&m_nIp, 4); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float X2 = GET_FLOAT_PARAM(2); + float Y2 = GET_FLOAT_PARAM(3); + float fDistance = X1 * X2 + Y1 * Y2; + SET_FLOAT_PARAM(0, fDistance); StoreParameters(&m_nIp, 1); return 0; } - case COMMAND_GET_OBJECT_VELOCITY: + case COMMAND_DOT_PRODUCT_3D: { - CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - *(CVector*)&ScriptParams[0] = GAME_SPEED_TO_METERS_PER_SECOND * pObject->GetMoveSpeed(); - StoreParameters(&m_nIp, 3); + CollectParameters(&m_nIp, 6); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float Z1 = GET_FLOAT_PARAM(2); + float X2 = GET_FLOAT_PARAM(3); + float Y2 = GET_FLOAT_PARAM(4); + float Z2 = GET_FLOAT_PARAM(5); + float fDistance = X1 * X2 + Y1 * Y2 + Z1 * Z2; + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; } - case COMMAND_IS_DEBUG_CAMERA_ON: - UpdateCompareFlag(TheCamera.WorldViewerBeingUsed); + case COMMAND_DEBUG_PRINT_WITH_1_FLOAT: return 0; - case COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY: + case COMMAND_DEBUG_PRINT_WITH_2_FLOATS: + return 0; + case COMMAND_DEBUG_PRINT_WITH_3_FLOATS: + return 0; + case COMMAND_GET_PAD_BUTTON_STATE: { - CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CVector newSpeed = pObject->GetTurnSpeed() + *(CVector*)&ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND; - if (pObject->bIsStatic) { - pObject->SetIsStatic(false); - pObject->AddToMovingList(); + CollectParameters(&m_nIp, 1); + switch (GET_INTEGER_PARAM(0)) { + case 0: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetOddJobTrigger()); break; + case 1: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetBrake()); break; + case 2: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSteeringLeftRight()); break; + case 3: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSteeringUpDown()); break; + case 4: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunLeftRight()); break; + case 5: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunUpDown()); break; + case 6: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetPedWalkLeftRight()); break; + case 7: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetPedWalkUpDown()); break; + case 8: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookLeft()); break; + case 9: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookRight()); break; + case 10: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookBehindForCar()); break; + case 11: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookBehindForPed()); break; + case 12: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetHorn()); break; + case 13: SET_INTEGER_PARAM(0, CPad::GetPad(0)->HornJustDown()); break; + case 14: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunFired()); break; + case 15: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CarGunJustDown()); break; + case 16: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetHandBrake()); break; + case 17: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetBrake()); break; + case 18: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetExitVehicle()); break; + case 19: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ExitVehicleJustDown()); break; + case 20: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetWeapon()); break; + case 21: SET_INTEGER_PARAM(0, CPad::GetPad(0)->WeaponJustDown()); break; + case 22: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetAccelerate()); break; + case 23: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleCameraModeUpJustDown()); break; + case 24: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleWeaponLeftJustDown()); break; + case 25: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleWeaponRightJustDown()); break; + case 26: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetTarget()); break; + case 27: SET_INTEGER_PARAM(0, CPad::GetPad(0)->TargetJustDown()); break; + case 28: SET_INTEGER_PARAM(0, CPad::GetPad(0)->JumpJustDown()); break; + case 29: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSprint()); break; + case 30: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ShiftTargetLeftJustDown()); break; + case 31: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ForceCameraBehindPlayer()); break; + case 32: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperZoomIn()); break; + case 33: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperZoomOut()); break; + case 34: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperModeLookLeftRight()); break; + case 35: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperModeLookUpDown()); break; + case 36: SET_INTEGER_PARAM(0, CPad::GetPad(0)->LookAroundLeftRight()); break; + case 37: SET_INTEGER_PARAM(0, CPad::GetPad(0)->LookAroundUpDown()); break; + case 38: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiLeft()); break; + case 39: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiRight()); break; + case 40: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiUp()); break; + case 41: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiDown()); break; + case 42: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiSelect()); break; + case 43: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiBack()); break; + case 44: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSkipCutscene()); if (GET_INTEGER_PARAM(0)) TheCamera.m_bIgnoreFadingStuffForMusic = false; break; // spectacular hack } - pObject->SetTurnSpeed(newSpeed.x, newSpeed.y, newSpeed.z); + StoreParameters(&m_nIp, 1); return 0; } - case COMMAND_SET_OBJECT_ROTATION_VELOCITY: + case COMMAND_SET_NAVIGATION_ARROW: { - CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CVector newSpeed = *(CVector*)&ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND; - if (pObject->bIsStatic) { - pObject->SetIsStatic(false); - pObject->AddToMovingList(); - } - pObject->SetTurnSpeed(newSpeed.x, newSpeed.y, newSpeed.z); + CollectParameters(&m_nIp, 3); + // cNavArrow::SetTarget(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(0)); // TODO, although it's unused return 0; } - case COMMAND_IS_OBJECT_STATIC: + case COMMAND_CLEAR_NAVIGATION_ARROW: { - CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - UpdateCompareFlag(pObject->GetIsStatic()); + // cNavArrow::ClearTarget(); // TODO, although it's unused return 0; } - case COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS: + case COMMAND_CALL: + case COMMAND_CALLNOT: { - CollectParameters(&m_nIp, 4); - CVector2D v1 = *(CVector2D*)&ScriptParams[0]; - CVector2D v2 = *(CVector2D*)&ScriptParams[2]; - float c = DotProduct2D(v1, v2) / (v1.Magnitude() * v2.Magnitude()); -#ifdef FIX_BUGS // command is a SA leftover where it was fixed to this - *(float*)&ScriptParams[0] = RADTODEG(Acos(c)); -#else - *(float*)&ScriptParams[0] = Acos(c); -#endif + m_anStack[m_nStackPointer++] = m_nIp | BIT(STACKVALUE_IS_FUNCTION_CALL_BIT) | ((command == COMMAND_CALLNOT) ? BIT(STACKVALUE_INVERT_RETURN_BIT) : 0); + uint8 nInputParams = CTheScripts::Read1ByteFromScript(&m_nIp); + uint8 nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + uint8 nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp); + uint32 nIPBeforeParameters = m_nIp; + CollectParameters(&m_nIp, 1); + if (nInputParams) + CollectParameters(&m_nIp, nInputParams, &m_anLocalVariables[m_nLocalsPointer + nLocalsOffset]); + m_nLocalsPointer += nLocalsOffset; + m_anStack[m_nStackPointer - 1] |= (m_nIp - nIPBeforeParameters) << STACKVALUE_IP_PARAMS_OFFSET; + if (GET_INTEGER_PARAM(0) < 0) + m_nIp = CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0); + else + m_nIp = GET_INTEGER_PARAM(0); return 0; } - case COMMAND_DO_2D_RECTANGLES_COLLIDE: + case COMMAND_IS_CAR_AUTOMOBILE: { - CollectParameters(&m_nIp, 8); - float infX1 = *(float*)&ScriptParams[0] - *(float*)&ScriptParams[2] * 0.5; // NB: not float - float supX1 = *(float*)&ScriptParams[0] + *(float*)&ScriptParams[2] * 0.5; - float infX2 = *(float*)&ScriptParams[4] - *(float*)&ScriptParams[6] * 0.5; - float supX2 = *(float*)&ScriptParams[4] + *(float*)&ScriptParams[6] * 0.5; - float infY1 = *(float*)&ScriptParams[1] - *(float*)&ScriptParams[3] * 0.5; - float supY1 = *(float*)&ScriptParams[1] + *(float*)&ScriptParams[3] * 0.5; - float infY2 = *(float*)&ScriptParams[5] - *(float*)&ScriptParams[7] * 0.5; - float supY2 = *(float*)&ScriptParams[5] + *(float*)&ScriptParams[7] * 0.5; - bool collide = true; - if (infY2 > supY1) - collide = false; - if (infY1 > supY2) - collide = false; - if (infX2 > supX1) - collide = false; - if (infX1 > supX2) - collide = false; - UpdateCompareFlag(collide); + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_FIRST_VEHICLE && pVehicle->GetModelIndex() < MI_FERRY); return 0; } - case COMMAND_GET_OBJECT_ROTATION_VELOCITY: + case COMMAND_IS_CAR_BIKE: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - *(CVector*)&ScriptParams[0] = pObject->GetTurnSpeed() * GAME_SPEED_TO_METERS_PER_SECOND; - StoreParameters(&m_nIp, 3); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_ANGEL && pVehicle->GetModelIndex() <= MI_SANCHEZ); return 0; } - case COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY: + return 0; + case COMMAND_IS_CAR_PLANE: { - CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CVector vecAddition = *(CVector*)&ScriptParams[1] * CTimer::GetTimeStep() / GAME_SPEED_TO_METERS_PER_SECOND; - if (!pObject->bIsStatic) { - CVector vecCurrSpeed = pObject->GetSpeed(); - vecCurrSpeed.Normalise(); - if (vecCurrSpeed.z != 1.0) { // NB: not float! - CVector vx = CrossProduct(vecCurrSpeed, CVector(0.0f, 0.0f, 1.0f)); - vx.Normalise(); - CVector vz = CrossProduct(vx, vecCurrSpeed); - vz.Normalise(); - CVector vecNewSpeed = pObject->GetSpeed() + vecAddition.x * vx + vecAddition.y * vecCurrSpeed + vecAddition.z * vecCurrSpeed; - if (pObject->bIsStatic) { - pObject->SetIsStatic(false); - pObject->AddToMovingList(); - } - pObject->SetMoveSpeed(vecNewSpeed); - } - } + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_AIRTRAIN && pVehicle->GetModelIndex() <= MI_DEADDODO); return 0; } - case COMMAND_GET_OBJECT_SPEED: + case COMMAND_IS_CAR_HELI: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - *(float*)&ScriptParams[0] = pObject->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND; - StoreParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_ESCAPE && pVehicle->GetModelIndex() <= MI_CHOPPER); return 0; } +#ifdef FIX_BUGS + case COMMAND_1476: // they DO have it in script + return 0; #endif -#if (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - case COMMAND_IS_MISSION_SKIP: -#ifdef MISSION_REPLAY - ScriptParams[0] = MissionSkipLevel; -#else - ScriptParams[0] = 0; -#endif + case COMMAND_RETURN_IF_TRUE: + if (m_bCondResult) { + ReturnFromGosubOrFunction(); + } + return 0; + case COMMAND_RETURN_TRUE_IF_TRUE: + if (m_bCondResult) { + UpdateCompareFlag(false); + ReturnFromGosubOrFunction(); + } + return 0; + case COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bOnlyAllowedToSitBehind = GET_INTEGER_PARAM(1); + return 0; + } + case COMMAND_SET_RC_HELI_HEIGHT_LIMIT: + CollectParameters(&m_nIp, 1); + // CVehicle::rcHeliHeightLimit = GET_FLOAT_PARAM(0); // TODO + return 0; + case COMMAND_CREATE_SCRIPT_CORONA: + { + CollectParameters(&m_nIp, 9); + base::cSList<script_corona>::tSItem* pCorona = new base::cSList<script_corona>::tSItem(); + pCorona->item.x = GET_FLOAT_PARAM(0); + pCorona->item.y = GET_FLOAT_PARAM(1); + pCorona->item.z = GET_FLOAT_PARAM(2); + pCorona->item.id = CTheScripts::NextScriptCoronaID++; + if (pCorona->item.z <= MAP_Z_LOW_LIMIT) + pCorona->item.z = CWorld::FindGroundZForCoord(pCorona->item.x, pCorona->item.y); + pCorona->item.size = GET_FLOAT_PARAM(3); + pCorona->item.r = GET_INTEGER_PARAM(6); + pCorona->item.g = GET_INTEGER_PARAM(7); + pCorona->item.b = GET_INTEGER_PARAM(8); + pCorona->item.type = GET_INTEGER_PARAM(4); + pCorona->item.flareType = GET_INTEGER_PARAM(5); + SET_INTEGER_PARAM(0, pCorona->item.id); + CTheScripts::mCoronas.Insert(pCorona); StoreParameters(&m_nIp, 1); return 0; - case COMMAND_SET_IN_AMMUNATION: + } + case COMMAND_REMOVE_SCRIPT_CORONA: + { CollectParameters(&m_nIp, 1); -#ifdef MISSION_REPLAY - IsInAmmunation = ScriptParams[0]; -#endif + for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) { + if (i->item.id == GET_INTEGER_PARAM(0)) { + CTheScripts::mCoronas.Remove(i); + delete i; + break; + } + } return 0; - case COMMAND_DO_SAVE_GAME: + } + case COMMAND_IS_BOAT_IN_WATER: + { CollectParameters(&m_nIp, 1); -#ifdef MISSION_REPLAY - SaveGameForPause(ScriptParams[0]); -#endif + CBoat* pVehicle = (CBoat*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle && pVehicle->IsBoat()); + UpdateCompareFlag(pVehicle->bBoatInWater); return 0; - case COMMAND_IS_RETRY: -#ifdef MISSION_REPLAY - if (strcmp(m_abScriptName, "porno4") != 0) - ScriptParams[0] = AllowMissionReplay; -#ifdef FIX_BUGS - else - ScriptParams[0] = gbTryingPorn4Again; -#else - else if (gbTryingPorn4Again) - ScriptParams[0] = 1; -#endif -#else - ScriptParams[0] = 0; + } + case COMMAND_IS_CAR_DRIVER_BEING_JACKED: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->bIsBeingCarJacked); + return 0; + } + case COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bOnlyAllowedToSitInFront = GET_INTEGER_PARAM(1); + return 0; + } + case COMMAND_SET_CAR_TILTED_BY_CHAR: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + script_assert(pVehicle); + pVehicle->ApplyTurnForce(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(-0.8f, -1.2f)* pPed->m_fMass, + pPed->GetPosition().x - pVehicle->GetPosition().x, pPed->GetPosition().y - pVehicle->GetPosition().y, 0.0f); + DMAudio.PlayOneShot(pVehicle->m_audioEntityId, SOUND_CAR_JERK, 0.0f); + return 0; + } + case COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA: + { + CollectParameters(&m_nIp, 4); + float X = GET_FLOAT_PARAM(0); + float Y = GET_FLOAT_PARAM(1); + float Z = GET_FLOAT_PARAM(2); + float radius = GET_FLOAT_PARAM(3); + int model = -1; + bool found = false; + for (uint32 i = 0; i < NUMPICKUPS; i++) { + CPickup* pPickup = &CPickups::aPickUps[i]; + if (pPickup->m_eType != PICKUP_NONE) { + CVector fDist = pPickup->m_vecPos - CVector(X, Y, Z); +#ifndef FIX_BUGS // this breaks ALL pickups! + pPickup->m_eModelIndex = 4; #endif + if (fDist.Magnitude() < radius && pPickup->m_pObject) { + found = true; + model = CPickups::WeaponForModel(pPickup->m_pObject->GetModelIndex()); + } + } + } + SET_INTEGER_PARAM(0, model); StoreParameters(&m_nIp, 1); + } + case COMMAND_IS_PLAYER_USING_FIRST_PERSON_WEAPON_CAMERA: + CollectParameters(&m_nIp, 1); + UpdateCompareFlag(TheCamera.Using1stPersonWeaponMode()); return 0; - case COMMAND_DUMMY: + //case COMMAND_1489: + //case COMMAND_1490: + //case COMMAND_1491: + case COMMAND_SET_DEBUG_MENU_ACTIVE: + CollectParameters(&m_nIp, 1); + // this sets two values on PS2, but not on mobile - TODO? return 0; -#endif -#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - // it is unknown what these commands do but they don't take parameters - case COMMAND_MARK_CUTSCENE_START: + case COMMAND_SET_DRAW_HUD: + CollectParameters(&m_nIp, 1); + CHud::m_Wants_To_Draw_Hud = (GET_INTEGER_PARAM(0) != 0); return 0; - case COMMAND_MARK_CUTSCENE_END: + case COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS: + { + CollectParameters(&m_nIp, 4); + int ped_handle = -1; + CVector pos = FindPlayerCoors(); + float x1 = GET_FLOAT_PARAM(0); + float y1 = GET_FLOAT_PARAM(1); + float x2 = GET_FLOAT_PARAM(2); + float y2 = GET_FLOAT_PARAM(3); + int i = CPools::GetPedPool()->GetSize(); + while (--i && ped_handle == -1) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + if (!pPed) + continue; + if (pPed->bRemoveFromWorld) + continue; + if (pPed->bFadeOut) + continue; + if (pPed->m_nWaitState != WAITSTATE_FALSE) + continue; + if (!pPed->IsWithinArea(x1, y1, x2, y2)) + continue; + if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z) + continue; + if (pos.z + PED_FIND_Z_OFFSET < pPed->GetPosition().z) + continue; + ped_handle = CPools::GetPedPool()->GetIndex(pPed); + CTheScripts::LastRandomPedId = ped_handle; + pPed->CharCreatedBy = MISSION_CHAR; + pPed->bRespondsToThreats = false; + ++CPopulation::ms_nTotalMissionPeds; + if (m_bIsMissionScript) + CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR); + } + SET_INTEGER_PARAM(0, ped_handle); + StoreParameters(&m_nIp, 1); return 0; - case COMMAND_CUTSCENE_SCROLL: + } + case COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE: + { + CollectParameters(&m_nIp, 4); + int handle = -1; + uint32 i = CPools::GetVehiclePool()->GetSize(); + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(3); + while (i-- && handle == -1) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (!pVehicle) + continue; + if (!pVehicle->IsWithinArea(infX, infY, supX, supY)) + continue; + handle = CPools::GetVehiclePool()->GetIndex(pVehicle); + } + SET_INTEGER_PARAM(0, handle); + StoreParameters(&m_nIp, 1); return 0; + } + case COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + if (!pVehicle) + printf("STORE_CAR_COLLIDED_WITH_NO_SAVE - Car doesn\'t exist\n"); + else { + if (pVehicle->m_pLastDamageEntity == nil) + SET_INTEGER_PARAM(0, -1); + else { + // what they are doing is not very safe as m_pLastDamageEntity doesn't have to be CVehicle +#ifdef FIX_BUGS + if (!pVehicle->m_pLastDamageEntity->IsVehicle()) { + SET_INTEGER_PARAM(0, -1); + } + else #endif + { + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex((CVehicle*)pVehicle->m_pLastDamageEntity)); + pVehicle->m_pLastDamageEntity = nil; + } + } + } + StoreParameters(&m_nIp, 1); + return 0; + } default: script_assert(0); } |