diff options
Diffstat (limited to 'src/control')
34 files changed, 6973 insertions, 3554 deletions
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp index d7c17a68..e52d788d 100644 --- a/src/control/AutoPilot.cpp +++ b/src/control/AutoPilot.cpp @@ -7,6 +7,8 @@ #include "PathFind.h" #include "SaveBuf.h" +//--LCS: file done + void CAutoPilot::ModifySpeed(float speed) { m_fMaxTrafficSpeed = Max(0.01f, speed); diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp index 1e63cf30..c1bf0369 100644 --- a/src/control/Bridge.cpp +++ b/src/control/Bridge.cpp @@ -6,6 +6,8 @@ #include "PathFind.h" #include "Stats.h" +//--LCS: file done except TODO + CEntity *CBridge::pLiftRoad; CEntity *CBridge::pLiftPart; CEntity *CBridge::pWeight; @@ -25,14 +27,14 @@ void CBridge::Init() { #ifdef GTA_BRIDGE FindBridgeEntities(); + State = STATE_BRIDGE_LOCKED; OldLift = -1.0f; if (pLiftPart && pWeight) { DefaultZLiftPart = pLiftPart->GetPosition().z; - DefaultZLiftWeight = pWeight->GetPosition().z; - if (pLiftRoad) DefaultZLiftRoad = pLiftRoad->GetPosition().z; + DefaultZLiftWeight = pWeight->GetPosition().z; ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true); } @@ -49,36 +51,42 @@ void CBridge::Update() float liftHeight; - // Set bridge height and state - if (CStats::CommercialPassed) - { + if (State == STATE_BRIDGE_LOCKED) { + liftHeight = 25.0f; + TimeOfBridgeBecomingOperational = 0; + } + else if (State == STATE_BRIDGE_ALWAYS_UNLOCKED) { + liftHeight = 0.0f; + TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds() - 20001; + } + else { if (TimeOfBridgeBecomingOperational == 0) TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds(); // Time remaining for bridge to become operational - // uint16, so after about a minute it overflows to 0 and the cycle repeats - uint16 timeElapsed = CTimer::GetTimeInMilliseconds() - TimeOfBridgeBecomingOperational; + // this time cycle duration is 0x20000, so ~2:11 + uint32 timeElapsed = (CTimer::GetTimeInMilliseconds() - TimeOfBridgeBecomingOperational) % 0x20000; // Calculate lift part height and bridge state - if (timeElapsed < 10000) + if (timeElapsed < 20000) { State = STATE_LIFT_PART_MOVING_DOWN; - liftHeight = 25.0f - timeElapsed / 10000.0f * 25.0f; + liftHeight = 25.0f - timeElapsed / 20000.0f * 25.0f; } - else if (timeElapsed < 40000) + else if (timeElapsed < 80000) { liftHeight = 0.0f; State = STATE_LIFT_PART_IS_DOWN; } - else if (timeElapsed < 50000) + else if (timeElapsed < 90000) { liftHeight = 0.0f; State = STATE_LIFT_PART_ABOUT_TO_MOVE_UP; } - else if (timeElapsed < 60000) + else if (timeElapsed < 110000) { State = STATE_LIFT_PART_MOVING_UP; - liftHeight = (timeElapsed - 50000) / 10000.0f * 25.0f; + liftHeight = (timeElapsed - 90000) / 20000.0f * 25.0f; } else { @@ -86,12 +94,7 @@ void CBridge::Update() State = STATE_LIFT_PART_IS_UP; } } - else - { - liftHeight = 25.0f; - TimeOfBridgeBecomingOperational = 0; - State = STATE_BRIDGE_LOCKED; - } + // Move bridge part if (liftHeight != OldLift) @@ -112,6 +115,8 @@ void CBridge::Update() OldLift = liftHeight; } + // TODO(LCS): cWorldStream + if (State == STATE_LIFT_PART_ABOUT_TO_MOVE_UP && OldState == STATE_LIFT_PART_IS_DOWN) ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true); else if (State == STATE_LIFT_PART_IS_DOWN && OldState == STATE_LIFT_PART_MOVING_DOWN) @@ -161,3 +166,23 @@ bool CBridge::ThisIsABridgeObjectMovingUp(int index) return false; #endif } + +void CBridge::ForceBridgeState(uint8 state) +{ +#ifdef GTA_BRIDGE + State = state; + switch (state) + { + case STATE_BRIDGE_LOCKED: + case STATE_LIFT_PART_MOVING_DOWN: + case STATE_LIFT_PART_ABOUT_TO_MOVE_UP: + ThePaths.SetLinksBridgeLights(-330.0f, -230.0f, -700.0f, -588.0f, true); + break; + case STATE_BRIDGE_ALWAYS_UNLOCKED: + ThePaths.SetLinksBridgeLights(-330.0f, -230.0f, -700.0f, -588.0f, false); + break; + default: + break; + } +#endif +}
\ No newline at end of file diff --git a/src/control/Bridge.h b/src/control/Bridge.h index c5702629..e639d4c1 100644 --- a/src/control/Bridge.h +++ b/src/control/Bridge.h @@ -8,7 +8,8 @@ enum bridgeStates { STATE_LIFT_PART_MOVING_DOWN, STATE_LIFT_PART_IS_DOWN, STATE_LIFT_PART_ABOUT_TO_MOVE_UP, - STATE_LIFT_PART_MOVING_UP + STATE_LIFT_PART_MOVING_UP, + STATE_BRIDGE_ALWAYS_UNLOCKED }; class CBridge @@ -25,4 +26,5 @@ public: static bool ShouldLightsBeFlashing(); static void FindBridgeEntities(); static bool ThisIsABridgeObjectMovingUp(int); + static void ForceBridgeState(uint8 state); }; diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp index c8230d4d..1ee99b89 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -4,6 +4,7 @@ #include "Accident.h" #include "AutoPilot.h" +#include "Bridge.h" #include "CarCtrl.h" #include "General.h" #include "HandlingMgr.h" @@ -20,6 +21,8 @@ #include "World.h" #include "ZoneCull.h" +//--LCS: file done + #define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle) @@ -72,6 +75,18 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle) case STATUS_PLAYER_DISABLED: break; case STATUS_SIMPLE: + { + if (pVehicle->m_pCurGroundEntity && CBridge::ThisIsABridgeObjectMovingUp(pVehicle->m_pCurGroundEntity->GetModelIndex())) + pVehicle->SetStatus(STATUS_PHYSICS); + CColPoint colPoint; + CEntity* pEntity; + if ((pVehicle->m_randomSeed & 0x3F) == (CTimer::GetFrameCounter() & 0x3F) && + !CWorld::ProcessVerticalLine(pVehicle->GetPosition(), -2.0f, colPoint, pEntity, true, false, false, false, true, false, nil)) { + debug("FLOATING CAR TURNED INTO PHYSICS CAR!\n"); + pVehicle->SetStatus(STATUS_PHYSICS); + } + } + // fallthough case STATUS_PHYSICS: switch (pVehicle->AutoPilot.m_nCarMission) { case MISSION_RAMPLAYER_FARAWAY: diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 6742ccfe..3d82fc1a 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -11,11 +11,13 @@ #include "Cranes.h" #include "Curves.h" #include "CutsceneMgr.h" +#include "Frontend.h" #include "Gangs.h" #include "Game.h" #include "Garages.h" #include "General.h" #include "IniFile.h" +#include "Lines.h" #include "ModelIndices.h" #include "PathFind.h" #include "Ped.h" @@ -37,7 +39,9 @@ #include "Zones.h" #include "Pickups.h" -#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f) +//--LCS: file done except TODO + +#define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f) // apparently POPULATION_CULL_RANGE? TODO: unite with CPopulation #define DISTANCE_TO_SCAN_FOR_DANGER (14.0f) #define DISTANCE_TO_SCAN_FOR_PED_DANGER (11.0f) #define SAFE_DISTANCE_TO_PED (3.0f) @@ -77,12 +81,30 @@ #define DISTANCE_BETWEEN_CAR_AND_DEAD_PED (6.0f) #define PROBABILITY_OF_PASSENGER_IN_VEHICLE (0.125f) -#define ONSCREEN_DESPAWN_RANGE (120.0f) +#ifdef GTA_PSP +#define ONSCREEN_DESPAWN_RANGE (160.0f) #define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (100.0f) -#define REQUEST_ONSCREEN_DISTANCE ((ONSCREEN_DESPAWN_RANGE + MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN) / 2) -#define OFFSCREEN_DESPAWN_RANGE (40.0f) +#define MAX_DISTANCE_FROM_CAMERA_TO_SPAWN_ONSCREEN (82.5f) +#else +#define ONSCREEN_DESPAWN_RANGE (190.0f) +#define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (130.0f) +#define MAX_DISTANCE_FROM_CAMERA_TO_SPAWN_ONSCREEN (105.0f) +#endif + +#define REQUEST_ONSCREEN_DISTANCE (140.0f) +#define OFFSCREEN_DESPAWN_RANGE (60.0f) +#define MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN (40.0f) #define EXTENDED_RANGE_DESPAWN_MULTIPLIER (1.5f) +#ifdef GTA_NETWORK +const int32 CCarCtrl::MultiplayerCarBanks[TOTAL_MULTIPLAYER_CAR_BANKS][CARS_IN_MULTIPLAYER_BANK] = +{ + MI_SANCHEZ, MI_KURUMA, MI_ESPRIT, MI_MULE, MI_DIABLOS, MI_KURUMA, MI_PEREN, MI_STINGER, + MI_PCJ600, MI_BOBCAT, MI_BLISTA, MI_LANDSTAL,MI_SENTINEL,MI_MOONBEAM,MI_MANANA, MI_PEREN, + MI_SANCHEZ2,MI_PCJ600, MI_STALLION,MI_MANANA, MI_LINERUN, MI_RCBANDIT,MI_MRWONGS, MI_STINGER +}; +#endif + bool CCarCtrl::bMadDriversCheat; int CCarCtrl::NumLawEnforcerCars; int CCarCtrl::NumAmbulancesOnDuty; @@ -108,6 +130,15 @@ int32 CCarCtrl::CarFreqArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY]; int32 CCarCtrl::LoadedCarsArray[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY]; CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP]; uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP]; +uint32 CCarCtrl::maxRandomMpCars = 20; +bool CCarCtrl::scriptControlsMpCarLimit = false; + +bool gbEmergencyVehiclesEnabled = true; + +#ifdef GTA_NETWORK // TMP +extern bool gIsMultiplayerGame; +extern int8 nAmbientCarBank; // actually gMultiGame.nAmbientCarBank (TODO) +#endif void CCarCtrl::GenerateRandomCars() @@ -141,31 +172,60 @@ CCarCtrl::GenerateOneRandomCar() CZoneInfo zone; CTheZones::GetZoneInfoForTimeOfDay(&vecTargetPos, &zone); pPlayer->m_nTrafficMultiplier = pPlayer->m_fRoadDensity * zone.carDensity; - if (NumRandomCars >= pPlayer->m_nTrafficMultiplier * CarDensityMultiplier * CIniFile::CarNumberMultiplier) - return; - if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars + NumLawEnforcerCars + NumRandomCars >= MaxNumberOfCarsInUse) - return; +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + // TODO (count number of players within 250 meters from spawn position + int numPlayersClose = 1; + if (NumRandomCars >= pPlayer->m_nTrafficMultiplier * CarDensityMultiplier * CIniFile::CarNumberMultiplier * numPlayersClose) + return; + if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars + NumLawEnforcerCars + NumRandomCars >= MaxNumberOfCarsInUse) + return; + } + else +#endif + { + if (NumRandomCars >= pPlayer->m_nTrafficMultiplier * CarDensityMultiplier * CIniFile::CarNumberMultiplier) + return; + if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars + NumLawEnforcerCars + NumRandomCars >= MaxNumberOfCarsInUse) + return; + } CWanted* pWanted = pPlayer->m_pPed->m_pWanted; int carClass; int carModel; - if (pWanted->GetWantedLevel() > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles && - pWanted->m_CurrentCops < pWanted->m_MaxCops && !CGame::IsInInterior() && ( - pWanted->GetWantedLevel() > 3 || - pWanted->GetWantedLevel() > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 || - pWanted->GetWantedLevel() > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) { - /* Last pWanted->GetWantedLevel() > 1 is unnecessary but I added it for better readability. */ - /* Wouldn't be surprised it was there originally but was optimized out. */ - carClass = COPS; - carModel = ChoosePoliceCarModel(); - }else{ +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { carModel = ChooseModel(&zone, &carClass); - if (carModel == -1 || (carClass == COPS && pWanted->GetWantedLevel() >= 1)) - /* All cop spawns with wanted level are handled by condition above. */ - /* In particular it means that cop cars never spawn if player has wanted level of 1. */ + if (carModel == -1) return; } + else +#endif + { + if (pWanted->GetWantedLevel() > 1 && NumLawEnforcerCars < pWanted->m_MaximumLawEnforcerVehicles && + pWanted->m_CurrentCops < pWanted->m_MaxCops && !CGame::IsInInterior() && ( + pWanted->GetWantedLevel() > 3 || + pWanted->GetWantedLevel() > 2 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 5000 || + pWanted->GetWantedLevel() > 1 && CTimer::GetTimeInMilliseconds() > LastTimeLawEnforcerCreated + 8000)) { + /* Last pWanted->GetWantedLevel() > 1 is unnecessary but I added it for better readability. */ + /* Wouldn't be surprised it was there originally but was optimized out. */ + carClass = COPS; + carModel = ChoosePoliceCarModel(); + } + else { + for (int i = 0; i < 5; i++) { + carModel = ChooseModel(&zone, &carClass); + if (carModel == -1) + return; + if (!(carClass == COPS && pWanted->GetWantedLevel() >= 1)) + /* All cop spawns with wanted level are handled by condition above. */ + /* In particular it means that cop cars never spawn if player has wanted level of 1. */ + break; + } + } + } float frontX, frontY; float preferredDistance, angleLimit; + float requestMultiplier = 1.0f; bool invertAngleLimitTest; CVector spawnPosition; int32 curNodeId, nextNodeId; @@ -185,11 +245,14 @@ CCarCtrl::GenerateOneRandomCar() angleLimit = -1.0f; bTopDownCamera = true; invertAngleLimitTest = true; - preferredDistance = OFFSCREEN_DESPAWN_RANGE + 15.0f; + preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN + 15.0f; /* BUG: testForCollision not initialized in original game. */ testForCollision = false; }else if (!pPlayerVehicle){ /* Player is not in vehicle. */ + requestMultiplier = 13.0f / 20.0f; + if (FrontEndMenuManager.m_PrefsUseWideScreen) // TODO(LCS): static + requestMultiplier *= 4.0f / 3.0f; testForCollision = true; frontX = TheCamera.CamFrontXNorm; frontY = TheCamera.CamFrontYNorm; @@ -199,95 +262,105 @@ CCarCtrl::GenerateOneRandomCar() /* Forward to his current direction (camera direction). */ angleLimit = 0.707f; /* 45 degrees */ invertAngleLimitTest = true; - preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier; + preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier; break; case 1: /* Spawn a vehicle close to player to his side. */ /* Kinda not within camera angle. */ angleLimit = 0.707f; /* 45 degrees */ invertAngleLimitTest = false; - preferredDistance = OFFSCREEN_DESPAWN_RANGE; + preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN; break; } - }else if (fPlayerVehicleSpeed > 0.4f){ /* 72 km/h */ + } + else { + requestMultiplier = 13.0f / 20.0f; + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON && !FrontEndMenuManager.m_PrefsUseWideScreen) + requestMultiplier *= 0.9f; + if (FrontEndMenuManager.m_PrefsUseWideScreen) // TODO(LCS): static + requestMultiplier *= 4.0f / 3.0f; + if (fPlayerVehicleSpeed > 0.4f) { /* 72 km/h */ /* Player is moving fast in vehicle */ /* Prefer spawning vehicles very far away from him. */ - frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed; - frontY = vecPlayerVehicleSpeed.y / fPlayerVehicleSpeed; - testForCollision = false; - switch (CTimer::GetFrameCounter() & 3) { - case 0: - case 1: - /* Spawn a vehicle in a very narrow gap in front of a player */ - angleLimit = 0.85f; /* approx 30 degrees */ - invertAngleLimitTest = true; - preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier; - break; - case 2: - /* Spawn a vehicle relatively far away from player. */ - /* Forward to his current direction (camera direction). */ - angleLimit = 0.707f; /* 45 degrees */ - invertAngleLimitTest = true; - preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier; - break; - case 3: - /* Spawn a vehicle close to player to his side. */ - /* Kinda not within camera angle. */ - angleLimit = 0.707f; /* 45 degrees */ - invertAngleLimitTest = false; - preferredDistance = OFFSCREEN_DESPAWN_RANGE; - break; + frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed; + frontY = vecPlayerVehicleSpeed.y / fPlayerVehicleSpeed; + testForCollision = false; + switch (CTimer::GetFrameCounter() & 3) { + case 0: + case 1: + /* Spawn a vehicle in a very narrow gap in front of a player */ + angleLimit = 0.85f; /* approx 30 degrees */ + invertAngleLimitTest = true; + preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier; + break; + case 2: + /* Spawn a vehicle relatively far away from player. */ + /* Forward to his current direction (camera direction). */ + angleLimit = 0.707f; /* 45 degrees */ + invertAngleLimitTest = true; + preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier; + break; + case 3: + /* Spawn a vehicle close to player to his side. */ + /* Kinda not within camera angle. */ + angleLimit = 0.707f; /* 45 degrees */ + invertAngleLimitTest = false; + preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN; + break; + } } - }else if (fPlayerVehicleSpeed > 0.1f){ /* 18 km/h */ - /* Player is moving moderately fast in vehicle */ - /* Spawn more vehicles to player's side. */ - frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed; - frontY = vecPlayerVehicleSpeed.y / fPlayerVehicleSpeed; - testForCollision = false; - switch (CTimer::GetFrameCounter() & 3) { - case 0: - /* Spawn a vehicle in a very narrow gap in front of a player */ - angleLimit = 0.85f; /* approx 30 degrees */ - invertAngleLimitTest = true; - preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier; - break; - case 1: - /* Spawn a vehicle relatively far away from player. */ - /* Forward to his current direction (camera direction). */ - angleLimit = 0.707f; /* 45 degrees */ - invertAngleLimitTest = true; - preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier; - break; - case 2: - case 3: - /* Spawn a vehicle close to player to his side. */ - /* Kinda not within camera angle. */ - angleLimit = 0.707f; /* 45 degrees */ - invertAngleLimitTest = false; - preferredDistance = OFFSCREEN_DESPAWN_RANGE; - break; + else if (fPlayerVehicleSpeed > 0.1f) { /* 18 km/h */ + /* Player is moving moderately fast in vehicle */ + /* Spawn more vehicles to player's side. */ + frontX = vecPlayerVehicleSpeed.x / fPlayerVehicleSpeed; + frontY = vecPlayerVehicleSpeed.y / fPlayerVehicleSpeed; + testForCollision = false; + switch (CTimer::GetFrameCounter() & 3) { + case 0: + /* Spawn a vehicle in a very narrow gap in front of a player */ + angleLimit = 0.85f; /* approx 30 degrees */ + invertAngleLimitTest = true; + preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier; + break; + case 1: + /* Spawn a vehicle relatively far away from player. */ + /* Forward to his current direction (camera direction). */ + angleLimit = 0.707f; /* 45 degrees */ + invertAngleLimitTest = true; + preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier; + break; + case 2: + case 3: + /* Spawn a vehicle close to player to his side. */ + /* Kinda not within camera angle. */ + angleLimit = 0.707f; /* 45 degrees */ + invertAngleLimitTest = false; + preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN; + break; + } } - }else{ - /* Player is in vehicle but moving very slow. */ - /* Then use camera direction instead of vehicle direction. */ - testForCollision = true; - frontX = TheCamera.CamFrontXNorm; - frontY = TheCamera.CamFrontYNorm; - switch (CTimer::GetFrameCounter() & 1) { - case 0: - /* Spawn a vehicle relatively far away from player. */ - /* Forward to his current direction (camera direction). */ - angleLimit = 0.707f; /* 45 degrees */ - invertAngleLimitTest = true; - preferredDistance = REQUEST_ONSCREEN_DISTANCE * TheCamera.GenerationDistMultiplier; - break; - case 1: - /* Spawn a vehicle close to player to his side. */ - /* Kinda not within camera angle. */ - angleLimit = 0.707f; /* 45 degrees */ - invertAngleLimitTest = false; - preferredDistance = OFFSCREEN_DESPAWN_RANGE; - break; + else { + /* Player is in vehicle but moving very slow. */ + /* Then use camera direction instead of vehicle direction. */ + testForCollision = true; + frontX = TheCamera.CamFrontXNorm; + frontY = TheCamera.CamFrontYNorm; + switch (CTimer::GetFrameCounter() & 1) { + case 0: + /* Spawn a vehicle relatively far away from player. */ + /* Forward to his current direction (camera direction). */ + angleLimit = 0.707f; /* 45 degrees */ + invertAngleLimitTest = true; + preferredDistance = REQUEST_ONSCREEN_DISTANCE * requestMultiplier * TheCamera.GenerationDistMultiplier; + break; + case 1: + /* Spawn a vehicle close to player to his side. */ + /* Kinda not within camera angle. */ + angleLimit = 0.707f; /* 45 degrees */ + invertAngleLimitTest = false; + preferredDistance = MINIMAL_DISTANCE_TO_SPAWN_OFFSCREEN; + break; + } } } if (!ThePaths.GenerateCarCreationCoors(vecTargetPos.x, vecTargetPos.y, frontX, frontY, @@ -297,6 +370,8 @@ CCarCtrl::GenerateOneRandomCar() CPathNode* pCurNode = &ThePaths.m_pathNodes[curNodeId]; CPathNode* pNextNode = &ThePaths.m_pathNodes[nextNodeId]; bool bBoatGenerated = false; + if (!OkToCreateVehicleAtThisPosition(spawnPosition)) + return; if ((CGeneral::GetRandomNumber() & 0xF) > Min(pCurNode->spawnRate, pNextNode->spawnRate)) return; if (pCurNode->bWaterPath) { @@ -346,10 +421,16 @@ CCarCtrl::GenerateOneRandomCar() CVehicle* pVehicle; if (CModelInfo::IsBoatModel(carModel)) pVehicle = new CBoat(carModel, RANDOM_VEHICLE); - else if (CModelInfo::IsBikeModel(carModel)) - pVehicle = new CBike(carModel, RANDOM_VEHICLE); else - pVehicle = new CAutomobile(carModel, RANDOM_VEHICLE); + { + if (CModelInfo::IsBikeModel(carModel)) + pVehicle = new CBike(carModel, RANDOM_VEHICLE); + else + pVehicle = new CAutomobile(carModel, RANDOM_VEHICLE); +#ifdef GTA_NETWORK + // TODO +#endif + } pVehicle->AutoPilot.m_nPrevRouteNode = 0; pVehicle->AutoPilot.m_nCurrentRouteNode = curNodeId; pVehicle->AutoPilot.m_nNextRouteNode = nextNodeId; @@ -367,7 +448,7 @@ CCarCtrl::GenerateOneRandomCar() pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS; pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE; } - if (carModel == MI_FBIRANCH){ + if (carModel == MI_FBICAR){ pVehicle->m_currentColour1 = 0; pVehicle->m_currentColour2 = 0; } @@ -589,6 +670,9 @@ CCarCtrl::GenerateOneRandomCar() break; } CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), 0); +#ifdef GTA_MOBILE + //CVisibilityPlugins::SetObjectDistanceAlpha(pVehicle->GetClump(), 0) // TODO(LCS) +#endif if (!pVehicle->GetIsOnScreen()){ if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > OFFSCREEN_DESPAWN_RANGE * (pVehicle->bExtendedRange ? EXTENDED_RANGE_DESPAWN_MULTIPLIER : 1.0f)) { /* Too far away cars that are not visible aren't needed. */ @@ -596,12 +680,12 @@ CCarCtrl::GenerateOneRandomCar() return; } }else{ - if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * (pVehicle->bExtendedRange ? EXTENDED_RANGE_DESPAWN_MULTIPLIER : 1.0f) * ONSCREEN_DESPAWN_RANGE || - (vecTargetPos - pVehicle->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN) { + if ((vecTargetPos - pVehicle->GetPosition()).Magnitude2D() > TheCamera.GenerationDistMultiplier * requestMultiplier * (pVehicle->bExtendedRange ? EXTENDED_RANGE_DESPAWN_MULTIPLIER : 1.0f) * ONSCREEN_DESPAWN_RANGE || + (vecTargetPos - pVehicle->GetPosition()).Magnitude2D() < TheCamera.GenerationDistMultiplier * requestMultiplier * MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN) { delete pVehicle; return; } - if ((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < 82.5f * TheCamera.GenerationDistMultiplier || bTopDownCamera) { + if ((TheCamera.GetPosition() - pVehicle->GetPosition()).Magnitude2D() < MAX_DISTANCE_FROM_CAMERA_TO_SPAWN_ONSCREEN * requestMultiplier * TheCamera.GenerationDistMultiplier || bTopDownCamera) { delete pVehicle; return; } @@ -635,29 +719,34 @@ CCarCtrl::GenerateOneRandomCar() CCarAI::AddPoliceCarOccupants(pVehicle); else { pVehicle->SetUpDriver(); - int32 passengers = 0; - for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) - passengers += (CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < PROBABILITY_OF_PASSENGER_IN_VEHICLE) ? 1 : 0; - if (CModelInfo::IsCarModel(carModel) && (CModelInfo::GetModelInfo(carModel)->GetAnimFileIndex() == CAnimManager::GetAnimationBlockIndex("van") && passengers >= 1)) - passengers = 1; - for (int i = 0; i < passengers; i++) { - CPed* pPassenger = pVehicle->SetupPassenger(i); - if (pPassenger) { - ++CPopulation::ms_nTotalCarPassengerPeds; - pPassenger->bCarPassenger = true; +#ifdef GTA_NETWORK + if (!gIsMultiplayerGame) +#endif + { + int32 passengers = 0; + for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) + passengers += (CGeneral::GetRandomNumberInRange(0.0f, 1.0f) < PROBABILITY_OF_PASSENGER_IN_VEHICLE) ? 1 : 0; + if (CModelInfo::IsCarModel(carModel) && (CModelInfo::GetModelInfo(carModel)->GetAnimFileIndex() == CAnimManager::GetAnimationBlockIndex("van") && passengers >= 1)) + passengers = 1; + for (int i = 0; i < passengers; i++) { + CPed* pPassenger = pVehicle->SetupPassenger(i); + if (pPassenger) { + ++CPopulation::ms_nTotalCarPassengerPeds; + pPassenger->bCarPassenger = true; + } } } } int nMadDrivers; switch (pVehicle->GetVehicleAppearance()) { case VEHICLE_APPEARANCE_BIKE: - nMadDrivers = 30; + nMadDrivers = 20; break; case VEHICLE_APPEARANCE_BOAT: nMadDrivers = 40; break; default: - nMadDrivers = 6; + nMadDrivers = 3; break; } if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers || bMadDriversCheat) { @@ -714,12 +803,9 @@ CCarCtrl::GenerateOneRandomCar() } } } -} - -bool -CCarCtrl::BoatWithTallMast(int32 mi) -{ - return mi == MI_RIO || mi == MI_TROPIC || mi == MI_MARQUIS; +#ifdef GTA_NETWORK + // TODO +#endif } int32 @@ -755,6 +841,22 @@ int32 CCarCtrl::ChooseModel(CZoneInfo* pZone, int* pClass) { int32 model = -1; int32 i; +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + for (i = 10; i > 0 && (model == -1 || !CStreaming::HasModelLoaded(model)); i--) { + *pClass = ChooseCarRating(pZone); + model = ChooseCarModel(*pClass); + bool found = false; + for (int j = 0; j < 8; j++) { + if (model == MultiplayerCarBanks[nAmbientCarBank][j]) + found = true; + } + if (!found) + model = -1; + } + return model; + } +#endif for (i = 10; i > 0 && (model == -1 || !CStreaming::HasModelLoaded(model)); i--) { int rnd = CGeneral::GetRandomNumberInRange(0, 1000); @@ -781,6 +883,9 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, int* pClass) { } if (i == 0) return -1; + CColModel* pColModel = CModelInfo::GetColModel(model); + if (!pColModel || pColModel->boundingSphere.radius > 20.0f) + return -1; return model; } @@ -941,6 +1046,7 @@ CCarCtrl::RemoveCarsIfThePoolGetsFull(void) } } if (pClosestVehicle) { + debug(":::::::::::\'Nearest removed\' cause pools was full -> NumRandomCars %d\n", NumRandomCars); CWorld::Remove(pClosestVehicle); delete pClosestVehicle; } @@ -963,7 +1069,12 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) return; } float distanceToPlayer = (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D(); - float threshold = OFFSCREEN_DESPAWN_RANGE; + float despawnMultiplier = 1.0f; +#if !defined EXTENDED_OFFSCREEN_DESPAWN_RANGE || defined GTA_PSP + if (FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON && !FrontEndMenuManager.m_PrefsUseWideScreen) + despawnMultiplier = 0.75f; +#endif + float threshold = OFFSCREEN_DESPAWN_RANGE * despawnMultiplier; #ifndef EXTENDED_OFFSCREEN_DESPAWN_RANGE if (pVehicle->GetIsOnScreen() || TheCamera.Cams[TheCamera.ActiveCam].LookingLeft || @@ -979,7 +1090,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) ) #endif { - threshold = ONSCREEN_DESPAWN_RANGE * TheCamera.GenerationDistMultiplier; + threshold = ONSCREEN_DESPAWN_RANGE * despawnMultiplier * TheCamera.GenerationDistMultiplier; } #ifndef EXTENDED_OFFSCREEN_DESPAWN_RANGE if (TheCamera.GetForward().z < -0.9f) @@ -991,6 +1102,14 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) if (pVehicle->GetIsOnScreen()){ pVehicle->bFadeOut = true; }else{ +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + // TODO + if (false) + MultiPlayerRemoveVehicleAndDriver(pVehicle); + return; + } +#endif CWorld::Remove(pVehicle); delete pVehicle; } @@ -1008,10 +1127,33 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) !CTrafficLights::ShouldCarStopForLight(pVehicle, true) && !CTrafficLights::ShouldCarStopForBridge(pVehicle) && !CGarages::IsPointWithinHideOutGarage(pVehicle->GetPosition())){ - CWorld::Remove(pVehicle); - delete pVehicle; +#ifdef GTA_NETWORK + if (!gIsMultiplayerGame) +#endif + { + CWorld::Remove(pVehicle); + delete pVehicle; + return; + } +#ifdef GTA_NETWORK + if (false) // TODO(LCS): figure out condition for mp + MultiPlayerRemoveVehicleAndDriver(pVehicle); +#endif + } +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + if (pVehicle->GetStatus() == STATUS_WRECKED && CTimer::GetLogicalFrameCounter() == pVehicle->m_randomSeed) { + if ((pVehicle->GetPosition() - vecPlayerPos).MagnitudeSqr() > SQR(6.5f)) { + if (pVehicle->GetMoveSpeed().MagnitudeSqr() <= SQR(0.01f)) { + printf("viciously removing dead vehicle"); + CWorld::Remove(pVehicle); + delete pVehicle; + } + } + } return; } +#endif if (pVehicle->GetStatus() == STATUS_WRECKED) { if (pVehicle->m_nTimeOfDeath != 0) { if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nTimeOfDeath + 60000 && @@ -1347,6 +1489,10 @@ void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, pVehicle->AutoPilot.m_bSlowedDownBecauseOfCars = true; *pSpeed = Min(*pSpeed, minProximity * curSpeed); } +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) + return; +#endif if (minProximity >= 0.0f && minProximity < 0.5f && pOtherEntity->IsVehicle() && CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeToStartMission > 15000 && CTimer::GetTimeInMilliseconds() - pOtherVehicle->AutoPilot.m_nTimeToStartMission > 15000){ @@ -1594,16 +1740,12 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float diffToLeftAngle = ABS(diffToLeftAngle); float angleToWeave = lengthToEvade / 2; if (diffToLeftAngle < angleToWeave){ - *pAngleToWeaveLeft = angleBetweenVehicles - angleToWeave; - while (*pAngleToWeaveLeft < -PI) - *pAngleToWeaveLeft += TWOPI; + *pAngleToWeaveLeft = LimitRadianAngle(angleBetweenVehicles - angleToWeave); } float diffToRightAngle = LimitRadianAngle(angleBetweenVehicles - *pAngleToWeaveRight); diffToRightAngle = ABS(diffToRightAngle); if (diffToRightAngle < angleToWeave){ - *pAngleToWeaveRight = angleBetweenVehicles + angleToWeave; - while (*pAngleToWeaveRight > PI) - *pAngleToWeaveRight -= TWOPI; + *pAngleToWeaveRight = LimitRadianAngle(angleBetweenVehicles + angleToWeave); } } @@ -1642,16 +1784,12 @@ void CCarCtrl::WeaveForPed(CEntity* pOtherEntity, CVehicle* pVehicle, float* pAn diffToLeftAngle = ABS(diffToLeftAngle); float angleToWeave = lengthToEvade / 2; if (diffToLeftAngle < angleToWeave) { - *pAngleToWeaveLeft = angleBetweenVehicleAndPed - angleToWeave; - while (*pAngleToWeaveLeft < -PI) - *pAngleToWeaveLeft += TWOPI; + *pAngleToWeaveLeft = LimitRadianAngle(angleBetweenVehicleAndPed - angleToWeave); } float diffToRightAngle = LimitRadianAngle(angleBetweenVehicleAndPed - *pAngleToWeaveRight); diffToRightAngle = ABS(diffToRightAngle); if (diffToRightAngle < angleToWeave) { - *pAngleToWeaveRight = angleBetweenVehicleAndPed + angleToWeave; - while (*pAngleToWeaveRight > PI) - *pAngleToWeaveRight -= TWOPI; + *pAngleToWeaveRight = LimitRadianAngle(angleBetweenVehicleAndPed + angleToWeave); } } @@ -1714,16 +1852,12 @@ void CCarCtrl::WeaveForObject(CEntity* pOtherEntity, CVehicle* pVehicle, float* diffToLeftAngle = ABS(diffToLeftAngle); float angleToWeave = lengthToEvade / 2; if (diffToLeftAngle < angleToWeave) { - *pAngleToWeaveLeft = angleBetweenVehicleAndObject - angleToWeave; - while (*pAngleToWeaveLeft < -PI) - *pAngleToWeaveLeft += TWOPI; + *pAngleToWeaveLeft = LimitRadianAngle(angleBetweenVehicleAndObject - angleToWeave); } float diffToRightAngle = LimitRadianAngle(angleBetweenVehicleAndObject - *pAngleToWeaveRight); diffToRightAngle = ABS(diffToRightAngle); if (diffToRightAngle < angleToWeave) { - *pAngleToWeaveRight = angleBetweenVehicleAndObject + angleToWeave; - while (*pAngleToWeaveRight > PI) - *pAngleToWeaveRight -= TWOPI; + *pAngleToWeaveRight = LimitRadianAngle(angleBetweenVehicleAndObject + angleToWeave); } } @@ -1765,7 +1899,7 @@ bool CCarCtrl::PickNextNodeAccordingStrategy(CVehicle* pVehicle) void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle) { if (pVehicle->m_nRouteSeed) - CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed); + CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++); int32 prevNode = pVehicle->AutoPilot.m_nCurrentRouteNode; int32 curNode = pVehicle->AutoPilot.m_nNextRouteNode; uint8 totalLinks = ThePaths.m_pathNodes[curNode].numLinks; @@ -1851,13 +1985,15 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle) pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode]; if ((!pNextPathNode->bDisabled || pPrevPathNode->bDisabled) && (!pNextPathNode->bBetweenLevels || pPrevPathNode->bBetweenLevels || !pVehicle->AutoPilot.m_bStayInCurrentLevel)) - /* Nice way to exit loop but this will fail because this is used for indexing! */ - nextLink = 1000; + break; } } - if (nextLink < 999) + if (nextLink >= totalLinks) { /* If everything else failed, turn vehicle around */ + nextLink = 0; + debug("Couldn\'t find ANYTHING. Just go back from where we came.\n"); pVehicle->AutoPilot.m_nNextRouteNode = prevNode; + } } pNextPathNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode]; pNextLink = &ThePaths.m_carPathLinks[ThePaths.m_carPathConnections[nextLink + pCurPathNode->firstLink]]; @@ -1970,7 +2106,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t #endif { if (pVehicle->m_nRouteSeed) - CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed); + CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++); int prevNode = pVehicle->AutoPilot.m_nCurrentRouteNode; int curNode = pVehicle->AutoPilot.m_nNextRouteNode; CPathNode* pPrevNode = &ThePaths.m_pathNodes[prevNode]; @@ -1984,7 +2120,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t #else CVector(targetX, targetY, 0.0f), #endif - pTargetNode, &numNodes, 2, pVehicle, &distanceToTargetNode, 999999.9f, -1); + pTargetNode, &numNodes, 2, pVehicle, &distanceToTargetNode, 100.0f, -1); int newNextNode; int nextLink; @@ -2099,14 +2235,14 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t bool CCarCtrl::PickNextNodeToFollowPath(CVehicle* pVehicle) { if (pVehicle->m_nRouteSeed) - CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed); + CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++); int curNode = pVehicle->AutoPilot.m_nNextRouteNode; CPathNode* pCurNode = &ThePaths.m_pathNodes[curNode]; if (pVehicle->AutoPilot.m_nPathFindNodesCount == 0){ ThePaths.DoPathSearch(0, pVehicle->GetPosition(), curNode, pVehicle->AutoPilot.m_vecDestinationCoors, pVehicle->AutoPilot.m_aPathFindNodesInfo, &pVehicle->AutoPilot.m_nPathFindNodesCount, NUM_PATH_NODES_IN_AUTOPILOT, - pVehicle, nil, 999999.9f, -1); + pVehicle, nil, 100.0f, -1); if (pVehicle->AutoPilot.m_nPathFindNodesCount < 2) return true; pVehicle->AutoPilot.RemoveOnePathNode(); @@ -2418,6 +2554,16 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe *pHandbrake = true; return; case MISSION_CRUISE: + if (CTrafficLights::ShouldCarStopForBridge(pVehicle)) { + *pAccel = 0.0f; + *pBrake = 1.0f; + *pHandbrake = true; +#ifdef FIX_BUGS + *pSwerve = 0.0f; +#endif + break; + } + // fallthough case MISSION_RAMPLAYER_FARAWAY: case MISSION_BLOCKPLAYER_FARAWAY: case MISSION_GOTOCOORDS: @@ -2488,11 +2634,19 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe *pHandbrake = false; return; case MISSION_RAMCAR_CLOSE: + if (!pVehicle->AutoPilot.m_pTargetCar) { + debug("NO TARGET VEHICLE FOR MISSION_RAMCAR_CLOSE\n"); + return; + } SteerAICarWithPhysicsHeadingForTarget(pVehicle, pVehicle->AutoPilot.m_pTargetCar, pVehicle->AutoPilot.m_pTargetCar->GetPosition().x, pVehicle->AutoPilot.m_pTargetCar->GetPosition().y, pSwerve, pAccel, pBrake, pHandbrake); return; case MISSION_BLOCKCAR_CLOSE: + if (!pVehicle->AutoPilot.m_pTargetCar) { + debug("NO TARGET VEHICLE FOR MISSION_BLOCKCAR_CLOSE\n"); + return; + } SteerAICarWithPhysicsTryingToBlockTarget(pVehicle, pVehicle->AutoPilot.m_pTargetCar->GetPosition().x, pVehicle->AutoPilot.m_pTargetCar->GetPosition().y, @@ -2501,6 +2655,9 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe pSwerve, pAccel, pBrake, pHandbrake); return; case MISSION_BLOCKCAR_HANDBRAKESTOP: + if (!pVehicle->AutoPilot.m_pTargetCar) { + return; + } SteerAICarWithPhysicsTryingToBlockTarget_Stop(pVehicle, pVehicle->AutoPilot.m_pTargetCar->GetPosition().x, pVehicle->AutoPilot.m_pTargetCar->GetPosition().y, @@ -3109,7 +3266,7 @@ bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle* pVehicle, CVector vecTar { pVehicle->AutoPilot.m_vecDestinationCoors = vecTarget; ThePaths.DoPathSearch(0, pVehicle->GetPosition(), -1, vecTarget, pVehicle->AutoPilot.m_aPathFindNodesInfo, - &pVehicle->AutoPilot.m_nPathFindNodesCount, NUM_PATH_NODES_IN_AUTOPILOT, pVehicle, nil, 999999.9f, -1); + &pVehicle->AutoPilot.m_nPathFindNodesCount, NUM_PATH_NODES_IN_AUTOPILOT, pVehicle, nil, 100.0f, -1); ThePaths.RemoveBadStartNode(pVehicle->GetPosition(), pVehicle->AutoPilot.m_aPathFindNodesInfo, &pVehicle->AutoPilot.m_nPathFindNodesCount); if (pVehicle->AutoPilot.m_nPathFindNodesCount < 2){ @@ -3130,7 +3287,7 @@ bool CCarCtrl::JoinCarWithRoadSystemGotoCoors(CVehicle* pVehicle, CVector vecTar void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle) { if (pVehicle->m_nRouteSeed) - CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed); + CGeneral::SetRandomSeed(pVehicle->m_nRouteSeed++); int nextLink; CPathNode* pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode]; for (nextLink = 0; nextLink < 12; nextLink++) @@ -3168,14 +3325,22 @@ void CCarCtrl::FindLinksToGoWithTheseNodes(CVehicle* pVehicle) void CCarCtrl::GenerateEmergencyServicesCar(void) { +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) + return; +#endif if (FindPlayerPed()->m_pWanted->GetWantedLevel() > 3) return; if (CGame::IsInInterior()) return; +#ifndef GTA_PSP + if (TheCamera.m_WideScreenOn) + return; +#endif if (NumFiretrucksOnDuty + NumAmbulancesOnDuty + NumParkedCars + NumMissionCars + NumLawEnforcerCars + NumRandomCars > MaxNumberOfCarsInUse) return; - if (NumAmbulancesOnDuty == 0){ + if (NumAmbulancesOnDuty == 0 && gbEmergencyVehiclesEnabled){ if (gAccidentManager.CountActiveAccidents() < 2){ if (CStreaming::HasModelLoaded(MI_AMBULAN)) CStreaming::SetModelIsDeletable(MI_MEDIC); @@ -3195,7 +3360,7 @@ void CCarCtrl::GenerateEmergencyServicesCar(void) } } } - if (NumFiretrucksOnDuty == 0){ + if (NumFiretrucksOnDuty == 0 && gbEmergencyVehiclesEnabled){ if (gFireManager.GetTotalActiveFires() < 3){ if (CStreaming::HasModelLoaded(MI_FIRETRUCK)) CStreaming::SetModelIsDeletable(MI_FIREMAN); @@ -3225,6 +3390,10 @@ void CCarCtrl::GenerateEmergencyServicesCar(void) bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos) { +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) + return; +#endif CVector pPlayerPos = FindPlayerCentreOfWorld(CWorld::PlayerInFocus); bool created = false; int attempts = 0; @@ -3290,6 +3459,11 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos) pVehicle->m_bSirenOrAlarm = true; CWorld::Add(pVehicle); printf("CREATED EMERGENCY VEHICLE\n"); +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + // TODO (register car for network) + } +#endif return true; } @@ -3359,6 +3533,22 @@ bool CCarCtrl::MapCouldMoveInThisArea(float x, float y) #endif } +bool +CCarCtrl::BoatWithTallMast(int32 mi) +{ + return mi == MI_RIO || mi == MI_TROPIC || mi == MI_MARQUIS; +} + +bool CCarCtrl::OkToCreateVehicleAtThisPosition(const CVector& pos) +{ +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) { + // TODO + } +#endif + return true; +} + float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type) { switch (type) @@ -3368,3 +3558,64 @@ float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type) } return 1.0f; } + +void CCarCtrl::RenderDebugInfo(CVehicle* pVehicle) +{ + if (!pVehicle->AutoPilot.m_nNextRouteNode || !pVehicle->AutoPilot.m_nCurrentRouteNode) + return; + + CPathNode* pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode]; + CPathNode* pNextNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode]; + CCarPathLink* pCurLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; + CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; + + CVector vCurNodePos(pCurNode->GetPosition()); + vCurNodePos.z += 1.0f; + CVector vNextNodePos(pNextNode->GetPosition()); + vNextNodePos.z += 1.0f; + CVector vCurLinkDir(pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection, pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection, 0.0f); + CVector vNextLinkDir(pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection, pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection, 0.0f); + vCurLinkDir.Normalise(); + vNextLinkDir.Normalise(); + + if (vCurLinkDir.x * vNextLinkDir.x + vCurLinkDir.y * vNextLinkDir.y < 0.5f) { + CVector vCurPos(vCurNodePos); + CVector vCurDir(0.0f, 0.0f, 1.0f); + for (int i = 0; i < 10; i++) { + CVector vPrevPos = vCurPos; + CCurves::CalcCurvePoint(&vCurNodePos, &vNextNodePos, &vCurLinkDir, &vNextLinkDir, i * 0.1f, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve, &vCurPos, &vCurDir); + // Render3DLine(&vCurPos, &vNextPos, CVector(255.0f, 255.0f, 0.0f, 255.0f)); // <- originally this is called, let's reuse stuff we have + // TODO: not drawing :( + CLines::RenderLineWithClipping(vPrevPos.x, vPrevPos.y, vCurNodePos.z, vCurPos.x, vCurPos.y, vNextNodePos.z, 0xFFFF00FF, 0xFFFF00FF); // using NodePos for Z coord cause Curves set it to 0 + } + DefinedState(); + } +} + +void CCarCtrl::SetMultiplayerAmbientCarLimit(uint32 limit) +{ + maxRandomMpCars = limit; +} + +void CCarCtrl::ToggleScriptControlsMpCarLimit(bool toggle) +{ + scriptControlsMpCarLimit = toggle; +} + +void CCarCtrl::MultiPlayerRemoveVehicleAndDriver(CVehicle* pVehicle) +{ + CPed* pDriver = pVehicle->pDriver; + CWorld::Remove(pVehicle); + delete pVehicle; + if (pDriver) { + CWorld::Remove(pDriver); + delete pDriver; + } +} + +void CCarCtrl::Write(base::cRelocatableChunkWriter& writer) +{ + writer.AllocateRaw(CarArrays, sizeof(CarArrays), 4); + writer.AllocateRaw(TotalNumOfCarsOfRating, sizeof(TotalNumOfCarsOfRating), 4, false, true); +} + diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h index 5efbe275..c6796504 100644 --- a/src/control/CarCtrl.h +++ b/src/control/CarCtrl.h @@ -1,6 +1,7 @@ #pragma once #include "PathFind.h" #include "Boat.h" +#include "General.h" #include "Vehicle.h" #define GAME_SPEED_TO_METERS_PER_SECOND 50.0f @@ -16,6 +17,13 @@ enum{ MAX_CAR_MODELS_IN_ARRAY = 25, }; +#ifdef GTA_NETWORK +enum { + TOTAL_MULTIPLAYER_CAR_BANKS = 3, + CARS_IN_MULTIPLAYER_BANK = 8 +}; +#endif + #ifdef FIX_BUGS #define FIX_PATHFIND_BUG #endif @@ -130,6 +138,13 @@ public: static void SteerAIBoatWithPhysicsAttackingPlayer(CVehicle*, float*, float*, float*, bool*); static void SteerAICarBlockingPlayerForwardAndBack(CVehicle*, float*, float*, float*, bool*); + static bool OkToCreateVehicleAtThisPosition(const CVector&); + static void RenderDebugInfo(CVehicle*); + static void SetMultiplayerAmbientCarLimit(uint32); + static void ToggleScriptControlsMpCarLimit(bool); + static void MultiPlayerRemoveVehicleAndDriver(CVehicle*); + static void Write(base::cRelocatableChunkWriter&); + static float GetPositionAlongCurrentCurve(CVehicle* pVehicle) { uint32 timeInCurve = CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeEnteredCurve; @@ -138,11 +153,7 @@ public: static float LimitRadianAngle(float angle) { - while (angle < -PI) - angle += TWOPI; - while (angle > PI) - angle -= TWOPI; - return angle; + return CGeneral::LimitRadianAngle(angle); } static bool bMadDriversCheat; @@ -169,6 +180,15 @@ public: static int32 NumOfLoadedCarsOfRating[TOTAL_CUSTOM_CLASSES]; static int32 CarFreqArrays[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY]; static int32 LoadedCarsArray[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY]; + +#ifdef GTA_NETWORK + static const int32 MultiplayerCarBanks[TOTAL_MULTIPLAYER_CAR_BANKS][CARS_IN_MULTIPLAYER_BANK]; +#endif + + static uint32 maxRandomMpCars; + static bool scriptControlsMpCarLimit; + }; -extern CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP];
\ No newline at end of file +extern CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP]; +extern bool gbEmergencyVehiclesEnabled;
\ No newline at end of file diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp index 5b590440..9b075fb5 100644 --- a/src/control/Curves.cpp +++ b/src/control/Curves.cpp @@ -2,6 +2,8 @@ #include "Curves.h" +//--LCS: file done except TODO + float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y) { CVector2D dir1(dir1X, dir1Y); diff --git a/src/control/GameLogic.cpp b/src/control/GameLogic.cpp index 63c685d1..595845c1 100644 --- a/src/control/GameLogic.cpp +++ b/src/control/GameLogic.cpp @@ -46,6 +46,7 @@ float CGameLogic::AfterDeathStartPointOrientation[NUM_SHORTCUT_START_POINTS]; CVector CGameLogic::ShortCutDropOffForMission; float CGameLogic::ShortCutDropOffOrientationForMission; bool CGameLogic::MissionDropOffReadyToBeUsed; +char CGameLogic::mStoredPlayerOutfit[8] = "plr3"; #define SHORTCUT_TAXI_COST (9) #define TOTAL_BUSTED_AUDIO (28) @@ -89,7 +90,7 @@ CGameLogic::SortOutStreamingAndMemory(const CVector &pos) CStreaming::DeleteRwObjectsAfterDeath(pos); CStreaming::RemoveUnusedModelsInLoadedList(); CGame::DrasticTidyUpMemory(true); - CWorld::Players[CWorld::PlayerInFocus].m_pPed->Undress("player"); + CWorld::Players[CWorld::PlayerInFocus].m_pPed->Undress(mStoredPlayerOutfit); CStreaming::LoadSceneCollision(pos); CStreaming::LoadScene(pos); CWorld::Players[CWorld::PlayerInFocus].m_pPed->Dress(); @@ -102,15 +103,6 @@ CGameLogic::Update() CVector vecRestartPos; float fRestartFloat; -#ifdef MISSION_REPLAY - // what a place to check! - if (gbTryingPorn4Again) { - CRunningScript* pScript = CTheScripts::pActiveScripts; - if (pScript && !CGeneral::faststricmp(pScript->m_abScriptName, "porno4")) - gbTryingPorn4Again = false; - } -#endif - if (CCutsceneMgr::IsCutsceneProcessing()) return; UpdateShortCut(); @@ -401,7 +393,7 @@ CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed *pPlayerPed, CVector CWorld::Add(pPlayerPed); CHud::ResetWastedText(); CStreaming::StreamZoneModels(pos); - clearWaterDrop = true; + //clearWaterDrop = true; } void @@ -428,7 +420,7 @@ CGameLogic::SetUpShortCut(CVector vStartPos, float fStartAngle, CVector vEndPos, ShortCutStartOrientation = fStartAngle; ShortCutDestination = vEndPos; ShortCutDestinationOrientation = fEndAngle; - CStreaming::RequestModel(MI_KAUFMAN, 0); + CStreaming::RequestModel(MI_CABBIE, 0); } void @@ -460,11 +452,11 @@ CGameLogic::UpdateShortCut() { switch (ShortCutState) { case SHORTCUT_INIT: - if (!CStreaming::HasModelLoaded(MI_KAUFMAN)) { - CStreaming::RequestModel(MI_KAUFMAN, 0); + if (!CStreaming::HasModelLoaded(MI_CABBIE)) { + CStreaming::RequestModel(MI_CABBIE, 0); return; } - pShortCutTaxi = new CAutomobile(MI_KAUFMAN, RANDOM_VEHICLE); + pShortCutTaxi = new CAutomobile(MI_CABBIE, RANDOM_VEHICLE); if (!pShortCutTaxi) return; pShortCutTaxi->SetPosition(ShortCutStart); diff --git a/src/control/GameLogic.h b/src/control/GameLogic.h index 9b774cc7..a12b4031 100644 --- a/src/control/GameLogic.h +++ b/src/control/GameLogic.h @@ -48,4 +48,5 @@ public: static CVector ShortCutDropOffForMission; static float ShortCutDropOffOrientationForMission; static bool MissionDropOffReadyToBeUsed; + static char mStoredPlayerOutfit[8]; };
\ No newline at end of file diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index b24c9122..dd9067fc 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -8,6 +8,7 @@ #include "DMAudio.h" #include "General.h" #include "Font.h" +#include "Frontend.h" #include "HandlingMgr.h" #include "Hud.h" #include "Messages.h" @@ -15,7 +16,9 @@ #include "Pad.h" #include "Particle.h" #include "PlayerPed.h" +#include "Radar.h" #include "Replay.h" +#include "Script.h" #include "Stats.h" #include "Streaming.h" #include "Text.h" @@ -26,6 +29,8 @@ #include "VarConsole.h" #include "SaveBuf.h" +//--LCS: file done except TODO + #define ROTATED_DOOR_OPEN_SPEED (0.015f) #define ROTATED_DOOR_CLOSE_SPEED (0.02f) #define DEFAULT_DOOR_OPEN_SPEED (0.035f) @@ -37,7 +42,7 @@ #define RESPRAY_PRICE (100) // Distances -#define DISTANCE_TO_CALL_OFF_CHASE (10.0f) +#define DISTANCE_TO_CALL_OFF_CHASE (50.0f) #define DISTANCE_FOR_MRWHOOP_HACK (0.5f) #define DISTANCE_TO_ACTIVATE_GARAGE (8.0f) #define DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE (17.0f) @@ -94,10 +99,10 @@ const int32 gaCarsToCollectInCraigsGarages[TOTAL_COLLECTCARS_GARAGES][TOTAL_COLLECTCARS_CARS] = { - { MI_LANDSTAL, MI_IDAHO, MI_ESPERANT, MI_STALLION, MI_RANCHER, MI_BLISTAC }, - { MI_SABRE, MI_VIRGO, MI_SENTINEL, MI_STRETCH, MI_WASHING, MI_ADMIRAL }, - { MI_CHEETAH, MI_INFERNUS, MI_BANSHEE, MI_PHEONIX, MI_COMET, MI_STINGER }, - { MI_VOODOO, MI_CUBAN, MI_CADDY, MI_BAGGAGE, MI_MRWHOOP, MI_PIZZABOY } + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, + { MI_HEARSE, MI_FAGGIO, MI_FREEWAY, MI_SPIDER, MI_MANANA, MI_SHELBY, MI_PONTIAC, MI_ESPRIT, MI_HOTROD, MI_PCJ600, MI_SENTINEL, MI_INFERNUS, MI_BANSHEE, MI_PATRIOT, MI_BFINJECT, MI_LANDSTAL }, }; const int32 gaCarsToCollectIn60Seconds[] = { MI_CHEETAH, MI_TAXI, MI_ESPERANT, MI_SENTINEL, MI_IDAHO }; @@ -121,6 +126,7 @@ CStoredCar CGarages::aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_ int32 hGarages = AEHANDLE_NONE; CGarage CGarages::aGarages[NUM_GARAGES]; bool CGarages::bCamShouldBeOutisde; +uint8 CGarages::CrusherRewardMultiplier; #ifndef MASTER bool bPrintNearestObject; @@ -131,6 +137,7 @@ void CGarages::Init(void) #ifndef MASTER VarConsole.Add("Print nearest object", &bPrintNearestObject, true); #endif + CrusherRewardMultiplier = 1; CrushedCarId = -1; NumGarages = 0; MessageEndTime = 0; @@ -211,7 +218,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_fSupX = Max(Max(X1, X2), X3); pGarage->m_fInfY = Min(Min(Min(Y1, Y2), Y3), Y2 + Y3 - Y1); pGarage->m_fSupY = Max(Max(Y1, Y2), Y3); - pGarage->m_vecCorner1 = CVector(X1, Y1, Z1); + pGarage->m_vecCorner1 = CVector2D(X1, Y1); pGarage->m_fInfZ = Z1; pGarage->m_vDir1 = CVector2D(X2 - X1, Y2 - Y1); pGarage->m_vDir2 = CVector2D(X3 - X1, Y3 - Y1); @@ -229,6 +236,22 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_bRecreateDoorOnNextRefresh = false; pGarage->m_bRotatedDoor = false; pGarage->m_bCameraFollowsPlayer = false; + pGarage->m_nTimeToStartAction = 0; + pGarage->field_2 = false; + pGarage->m_nTargetModelIndex = targetId; + pGarage->m_bCollectedCarsState = 0; + pGarage->m_bDeactivated = false; + pGarage->m_bResprayHappened = false; + pGarage->m_bInitialized = false; + pGarage->m_bSSGarageAcceptedVehicle = false; + pGarage->m_bSSGarageStateChanging = false; + pGarage->m_bInitialized = InitDoorGubbins(NumGarages, type); + return NumGarages++; +} + +bool CGarages::InitDoorGubbins(uint32 id, uint8 type) +{ + CGarage* pGarage = &aGarages[id]; pGarage->RefreshDoorPointers(true); if (pGarage->m_pDoor1) { pGarage->m_fDoor1Z = pGarage->m_pDoor1->GetPosition().z; @@ -243,12 +266,6 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->m_fDoorHeight = pGarage->m_pDoor1 ? FindDoorHeightForMI(pGarage->m_pDoor1->GetModelIndex()) : 4.0f; pGarage->m_fDoorPos = 0.0f; pGarage->m_eGarageState = GS_FULLYCLOSED; - pGarage->m_nTimeToStartAction = 0; - pGarage->field_2 = false; - pGarage->m_nTargetModelIndex = targetId; - pGarage->m_bCollectedCarsState = 0; - pGarage->m_bDeactivated = false; - pGarage->m_bResprayHappened = false; switch (type) { case GARAGE_MISSION: case GARAGE_COLLECTORSITEMS: @@ -257,7 +274,6 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X case GARAGE_COLLECTCARS_2: case GARAGE_COLLECTCARS_3: case GARAGE_FORCARTOCOMEOUTOF: - case GARAGE_60SECONDS: case GARAGE_MISSION_KEEPCAR: case GARAGE_FOR_SCRIPT_TO_OPEN: case GARAGE_HIDEOUT_ONE: @@ -284,6 +300,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X case GARAGE_BOMBSHOP2: case GARAGE_BOMBSHOP3: case GARAGE_RESPRAY: + case GARAGE_CRATE_GARAGE: pGarage->m_eGarageState = GS_OPENED; pGarage->m_fDoorPos = pGarage->m_fDoorHeight; break; @@ -298,7 +315,16 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X pGarage->UpdateCrusherAngle(); else pGarage->UpdateDoorsHeight(); - return NumGarages++; + return pGarage->m_fDoorHeight > 0.0f; +} + +void CGarages::SetupAnyGaragesForThisIsland(void) +{ + for (uint32 i = 0; i < NumGarages; i++) { + CGarage* pGarage = &aGarages[i]; + if (!pGarage->m_bInitialized) + pGarage->m_bInitialized = InitDoorGubbins(i, pGarage->m_eGarageType); + } } void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi) @@ -309,8 +335,27 @@ void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi) pGarage->m_eGarageState = GS_FULLYCLOSED; } +void CGarages::LockGarage(int16 garage, bool state) +{ + CGarage* pGarage = &aGarages[garage]; + pGarage->m_bLocked = state; + if (pGarage->m_bLocked) { + pGarage->m_fDoorPos = 0.0f; + pGarage->m_eGarageState = GS_FULLYCLOSED; + pGarage->m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + 2000; + pGarage->UpdateDoorsHeight(); + } + else { + pGarage->m_eGarageState = GS_OPENING; + } +} + void CGarage::Update() { +#ifdef GTA_NETWORK + if (/* gIsMultiplayerGame && */m_eGarageType != GARAGE_CRATE_GARAGE) // TODO(multiplayer) + return; +#endif if (m_eGarageType != GARAGE_CRUSHER) { switch (m_eGarageState) { case GS_FULLYCLOSED: @@ -348,7 +393,7 @@ void CGarage::Update() if (m_bDeactivated && m_eGarageState == GS_FULLYCLOSED) return; if (m_bRotatedDoor) { -#ifdef GTA_PS2 +#if defined GTA_PS2 || defined GTA_PSP if (m_eGarageState == GS_OPENING) { if (m_pDoor1) { if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor1) @@ -432,7 +477,10 @@ void CGarage::Update() #else if (FindPlayerVehicle()) #endif + { ((CAutomobile*)(FindPlayerVehicle()))->m_fFireBlowUpTimer = 0.0f; + FindPlayerVehicle()->m_bGarageTurnedLightsOff = true; + } CWorld::CallOffChaseForArea( m_fInfX - DISTANCE_TO_CALL_OFF_CHASE, m_fInfY - DISTANCE_TO_CALL_OFF_CHASE, @@ -440,6 +488,7 @@ void CGarage::Update() m_fSupY + DISTANCE_TO_CALL_OFF_CHASE); break; case GS_FULLYCLOSED: + m_fDoorPos = 0.0f; if (CTimer::GetTimeInMilliseconds() > m_nTimeToStartAction) { m_eGarageState = GS_OPENING; DMAudio.PlayFrontEndSound(SOUND_GARAGE_OPENING, 1); @@ -474,11 +523,8 @@ void CGarage::Update() FindPlayerVehicle()->GetRight() = -FindPlayerVehicle()->GetRight(); } bChangedColour = false; -#ifdef FIX_BUGS - if (!FindPlayerVehicle()->IsCar() || !((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) { -#else - if (!((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) { -#endif + if ((!FindPlayerVehicle()->IsCar() || !((CAutomobile*)(FindPlayerVehicle()))->bFixedColour) && + (!FindPlayerVehicle()->IsBike() || !((CBike*)(FindPlayerVehicle()))->bFixedColour)) { uint8 colour1, colour2; uint16 attempt; FindPlayerVehicle()->GetModelInfo()->ChooseVehicleColour(colour1, colour2); @@ -491,12 +537,36 @@ void CGarage::Update() FindPlayerVehicle()->m_currentColour1 = colour1; FindPlayerVehicle()->m_currentColour2 = colour2; if (bChangedColour) { + CVector vCorners[] = { + CVector(m_fInfX, m_fInfY, 0.0f), CVector(m_fInfX, m_fSupY, 0.0f), + CVector(m_fSupX, m_fInfY, 0.0f), CVector(m_fSupX, m_fSupY, 0.0f) + }; + CVector vMiddles[] = { + CVector(m_fInfX + (m_fSupX - m_fInfX) / 2, m_fInfY, 0.0f), CVector(m_fInfX, m_fInfY + (m_fSupY - m_fInfY) / 2, 0.0f), + CVector(m_fInfX + (m_fSupX - m_fInfX) / 2, m_fSupY, 0.0f), CVector(m_fSupX, m_fInfY + (m_fSupY - m_fInfY) / 2, 0.0f), + }; + int nClosestCornerToCamera = 0; + int nClosestMiddleToCamera = 0; + for (int i = 1; i < 4; i++) { + if ((vCorners[nClosestCornerToCamera] - TheCamera.GetPosition()).Magnitude() > + (vCorners[i] - TheCamera.GetPosition()).Magnitude()) + nClosestCornerToCamera = i; + if ((vMiddles[nClosestMiddleToCamera] - TheCamera.GetPosition()).Magnitude() > + (vMiddles[i] - TheCamera.GetPosition()).Magnitude()) + nClosestMiddleToCamera = i; + } + CVector vDirectionCenterToMiddle = vMiddles[nClosestMiddleToCamera] - CVector(GetGarageCenterX(), GetGarageCenterY(), 0.0f); + vDirectionCenterToMiddle.Normalise(); + for (int i = 0; i < NUM_PARTICLES_IN_RESPRAY; i++) { - CVector pos; - pos.x = CGeneral::GetRandomNumberInRange(m_fInfX + 0.5f, m_fSupX - 0.5f); - pos.y = CGeneral::GetRandomNumberInRange(m_fInfY + 0.5f, m_fSupY - 0.5f); - pos.z = CGeneral::GetRandomNumberInRange(m_fDoor1Z - 3.0f, m_fDoor1Z + 1.0f); - CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, CVehicleModelInfo::ms_vehicleColourTable[colour1]); + CVector pos(vMiddles[nClosestMiddleToCamera] - vDirectionCenterToMiddle * 0.5f); + CVector dir(CrossProduct(vDirectionCenterToMiddle, CVector(0.0f, 0.0f, 1.0f))); + float fDirMultiplier = (vCorners[nClosestCornerToCamera] - vMiddles[nClosestMiddleToCamera]).Magnitude(); + pos += dir * CGeneral::GetRandomNumberInRange(-1.0f, 1.0f) * fDirMultiplier; // TODO: base::RandomReal? + pos += vDirectionCenterToMiddle * CGeneral::GetRandomNumberInRange(-6.0f, 0.4f); + dir = vDirectionCenterToMiddle * 0.04f; + pos.z = m_fInfZ + CGeneral::GetRandomNumberInRange(-0.4f, 0.0f); + CParticle::AddParticle(PARTICLE_GARAGEPAINT_SPRAY, pos, dir, nil, 0.0f, CVehicleModelInfo::mspInfo->ms_vehicleColourTable[colour1]); } } } @@ -506,8 +576,11 @@ void CGarage::Update() if (!CGarages::RespraysAreFree) { CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - RESPRAY_PRICE); CStats::AutoPaintingBudget += RESPRAY_PRICE; + CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you! + } + else { + CGarages::TriggerMessage("GA_17", -1, 4000, -1); } - CGarages::TriggerMessage("GA_2", -1, 4000, -1); // New engine and paint job. The cops won't recognize you! } else if (bChangedColour) { if (CGeneral::GetRandomTrueFalse()) @@ -532,6 +605,8 @@ void CGarage::Update() UpdateDoorsHeight(); break; case GS_OPENEDCONTAINSCAR: + if (FindPlayerVehicle()) + FindPlayerVehicle()->m_bGarageTurnedLightsOff = false; if (IsPlayerOutsideGarage()) m_eGarageState = GS_OPENED; break; @@ -544,10 +619,32 @@ void CGarage::Update() case GARAGE_BOMBSHOP1: case GARAGE_BOMBSHOP2: case GARAGE_BOMBSHOP3: + if (m_bLocked) { + UpdateDoorsHeight(); + break; + } switch (m_eGarageState) { case GS_OPENED: + UpdateDoorsHeight(); if (IsStaticPlayerCarEntirelyInside()) { - if (!FindPlayerVehicle() || FindPlayerVehicle()->m_bombType) { +#ifndef BOMBS_ON_BIKES + if (FindPlayerVehicle()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) { + CGarages::TriggerMessage("GA_22", -1, 4000, -1); + m_eGarageState = GS_OPENEDCONTAINSCAR; + DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1); + break; + } +#endif + if (!FindPlayerVehicle() +#ifdef FIX_BUGS + || (FindPlayerVehicle()->IsCar() && ((CAutomobile*)FindPlayerVehicle())->m_bombType) +#else + || ((CAutomobile*)FindPlayerVehicle())->m_bombType +#endif +#ifdef BOMBS_ON_BIKES + || (FindPlayerVehicle()->IsBike() && ((CBike*)FindPlayerVehicle())->m_bombType) +#endif + ) { CGarages::TriggerMessage("GA_5", -1, 4000, -1); //"Your car is already fitted with a bomb" m_eGarageState = GS_OPENEDCONTAINSCAR; DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1); @@ -573,6 +670,8 @@ void CGarage::Update() m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB; DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); } + if (FindPlayerVehicle()) + FindPlayerVehicle()->m_bGarageTurnedLightsOff = true; UpdateDoorsHeight(); if (m_eGarageType == GARAGE_BOMBSHOP3) CStreaming::RequestModel(MI_BOMB, STREAMFLAGS_DONT_REMOVE); @@ -589,13 +688,38 @@ void CGarage::Update() if (!CGarages::BombsAreFree) CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE); if (FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike())) { -#if (!defined GTA_PS2 || defined FIX_BUGS) - FindPlayerVehicle()->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType); - FindPlayerVehicle()->m_pBombRigger = FindPlayerPed(); -#else // PS2 version contained a bug: CBike was casted to CAutomobile, but due to coincidence it didn't corrupt memory +#ifdef BOMBS_ON_BIKES + if (FindPlayerVehicle()->IsCar()) { + ((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType); + ((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed(); + } + else { + ((CBike*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType); + ((CBike*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed(); + } +#else ((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType); ((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed(); #endif + // what is this + uint32 i = CPools::GetVehiclePool()->GetSize(); + while (i--) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (pVehicle) { + if (pVehicle->IsCar() && pVehicle->GetStatus() == STATUS_WRECKED) { + CAutomobile* pCar = (CAutomobile*)pVehicle; + pCar->m_pBombRigger = nil; + pCar->m_pBlowUpEntity = nil; + } +#ifdef BOMBS_ON_BIKES + if (pVehicle->IsBike() && pVehicle->GetStatus() == STATUS_WRECKED) { + CBike* pBike = (CBike*)pVehicle; + pBike->m_pBombRigger = nil; + pBike->m_pBlowUpEntity = nil; + } +#endif + } + } if (m_eGarageType == GARAGE_BOMBSHOP3) CGarages::GivePlayerDetonator(); CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB; @@ -634,6 +758,7 @@ void CGarage::Update() CHud::SetHelpMessage(TheText.Get("GA_8"), false); // Use the detonator to activate the bomb. break; } + CGarages::TriggerMessage(CGarages::BombsAreFree ? "GA_24" : "GA_23", -1, 4000, -1); CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE); FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false; } @@ -651,6 +776,8 @@ void CGarage::Update() UpdateDoorsHeight(); break; case GS_OPENEDCONTAINSCAR: + if (FindPlayerVehicle()) + FindPlayerVehicle()->m_bGarageTurnedLightsOff = false; if (IsPlayerOutsideGarage()) m_eGarageState = GS_OPENED; break; @@ -664,16 +791,12 @@ void CGarage::Update() switch (m_eGarageState) { case GS_OPENED: if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) { - if ((CTimer::GetFrameCounter() & 0x1F) == 0 -#ifndef GTA_PS2 - && (!m_pTarget || IsEntityTouching3D(m_pTarget)) -#endif - ) { + if ((CTimer::GetFrameCounter() & 0x1F) == 0 && !IsAnyOtherCarTouchingGarage(nil)) { m_eGarageState = GS_CLOSING; m_bClosingWithoutTargetCar = true; } } - else if (!FindPlayerVehicle() && m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) && + else if (m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) && IsEntityEntirelyOutside(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 2.0f)) { CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE); FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true; @@ -685,7 +808,11 @@ void CGarage::Update() if (m_pTarget) ThrowCarsNearDoorOutOfGarage(m_pTarget); m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep()); - if (m_fDoorPos == 0.0f) { + if (!IsEntityEntirelyOutside(FindPlayerPed(), 1.0f)) { + printf("FIX FOR IE GARAGE TRAPPING PLAYER\n"); + m_eGarageState = GS_OPENING; + } + else if (m_fDoorPos == 0.0f) { DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); if (m_bClosingWithoutTargetCar) m_eGarageState = GS_FULLYCLOSED; @@ -781,22 +908,21 @@ void CGarage::Update() UpdateDoorsHeight(); break; case GS_FULLYCLOSED: + if (CTheScripts::IsPlayerOnAMission()) { + m_pTarget = nil; + break; + } + if (!IsEntityEntirelyOutside(FindPlayerPed(), 0.0f)) { + printf("FIX FOR IE GARAGE TRAPPING PLAYER\n"); + m_eGarageState = GS_OPENING; + } if (FindPlayerVehicle() && CalcSmallestDistToGarageDoorSquared( FindPlayerVehicle()->GetPosition().x, FindPlayerVehicle()->GetPosition().y ) < SQR(DISTANCE_TO_ACTIVATE_GARAGE)) { if (DoesCraigNeedThisCar(FindPlayerVehicle()->GetModelIndex())) { - if (FindPlayerVehicle()->VehicleCreatedBy == MISSION_VEHICLE) - CGarages::TriggerMessage("GA_1A", -1, 5000, -1); // Come back when you're not so busy... - else - m_eGarageState = GS_OPENING; - } - else { - if (HasCraigCollectedThisCar(FindPlayerVehicle()->GetModelIndex())) - CGarages::TriggerMessage("GA_20", -1, 5000, -1); // We got more of these than we can shift. Sorry man, no deal. - else if (FindPlayerSpeed().Magnitude() < MAX_SPEED_TO_SHOW_COLLECTED_MESSAGE) - CGarages::TriggerMessage("GA_19", -1, 5000, -1); // We're not interested in that model. + m_eGarageState = GS_OPENING; } } m_pTarget = nil; @@ -832,6 +958,7 @@ void CGarage::Update() m_eGarageState = GS_FULLYCLOSED; DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); } + UpdateDoorsHeight(); if (!IsGarageEmpty()) m_eGarageState = GS_OPENING; break; @@ -852,8 +979,169 @@ void CGarage::Update() break; } break; + case GARAGE_CRATE_GARAGE: +#ifdef GTA_NETWORK + { + switch (m_eGarageState) { + case GS_OPENED: + if (m_pSSVehicle) { + // if (m_pSSVehicle->GetVehiclePointer() && IsEntityEntirelyInside3D(m_pSSVehicle->GetVehiclePointer()) + { + if (m_pSSTargetCar) + m_pSSTargetCar->CleanUpOldReference((CEntity**)&m_pSSTargetCar); + // m_pSSTargetCar = m_pSSVehicle->GetVehiclePointer(); + m_pSSTargetCar->RegisterReference((CEntity**)&m_pSSTargetCar); + } + // else + { + if (m_pSSTargetCar) + m_pSSTargetCar->CleanUpOldReference((CEntity**)&m_pSSTargetCar); + m_pSSTargetCar = nil; + } + if (m_pSSTargetCar) { + if (!FindPlayerVehicle()/* && m_pSSTargetCar == m_pSSVehicle->GetVehiclePointer() */) + { + if (IsEntityEntirelyOutside(FindPlayerPed(), 6.0f)) { + if (FindPlayerPed()->m_fHealth > 0.0f) { + CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE); + m_eGarageState = GS_CLOSING; + m_bSSGarageStateChanging = true; + } + } + } + } + } + break; + case GS_CLOSING: + m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep()); + if (m_fDoorPos == 0.0f) { + // if (? == m_nSSGarageState) + { + if (m_pSSTargetCar) { + // if (m_pSSVehicle->GetVehiclePointer()) + { + if (IsEntityEntirelyInside3D(/* m_pSSVehicle->GetVehiclePointer() */nil, 0.0f)) { + if (m_pSSTargetCar) + m_pSSTargetCar->CleanUpOldReference((CEntity**)&m_pSSTargetCar); + CWorld::Remove(m_pSSTargetCar); + delete m_pSSTargetCar; + m_pSSTargetCar = nil; + m_pSSVehicle = nil; + m_bSSGarageAcceptedVehicle = true; + printf("Destroying Car Inside Crate....\n"); + } + } + } + } + // TODO: some loop :( + CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE); + m_eGarageState = GS_FULLYCLOSED; + DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); + } + UpdateDoorsHeight(); + if (!IsGarageEmpty()) + m_eGarageState = GS_OPENING; + break; + case GS_FULLYCLOSED: + { + // if (? == m_nSSGarageState) + { + if (CalcDistToGarageRectangleSquared(FindPlayerPed()->GetPosition().x, FindPlayerPed()->GetPosition().y) > SQR(10.0f)) + m_eGarageState = GS_OPENING; + } + break; + } + case GS_OPENING: + m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep()); + if (m_fDoorPos == m_fDoorHeight) { + m_bSSGarageStateChanging = false; + m_eGarageState = GS_OPENED; + DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f); + } + UpdateDoorsHeight(); + break; + } + break; + } +#endif case GARAGE_CRUSHER: + { + switch (m_eGarageState) { + case GS_OPENED: + { + int i = CPools::GetVehiclePool()->GetSize() * (CTimer::GetFrameCounter() % CRUSHER_VEHICLE_TEST_SPAN) / CRUSHER_VEHICLE_TEST_SPAN; + int end = CPools::GetVehiclePool()->GetSize() * (CTimer::GetFrameCounter() % CRUSHER_VEHICLE_TEST_SPAN + 1) / CRUSHER_VEHICLE_TEST_SPAN; + for (; i < end; i++) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (!pVehicle) + continue; + if ((pVehicle->IsCar() || pVehicle->IsBike()) && IsEntityEntirelyInside3D(pVehicle, 0.0f)) { + m_eGarageState = GS_WAITINGFORCAR; + m_pTarget = pVehicle; + m_nTimeCrusherCraneActivated = CTimer::GetTimeInMilliseconds(); + m_pTarget->RegisterReference((CEntity**)&m_pTarget); + } + } + break; + } + case GS_CLOSING: + if (m_pTarget) { + m_fDoorPos = Max(0.0f, m_fDoorPos - CRUSHER_CRANE_SPEED * CTimer::GetTimeStep()); + if (m_fDoorPos < TWOPI / 5) { + m_pTarget->bUsesCollision = false; + m_pTarget->bAffectedByGravity = false; + m_pTarget->SetMoveSpeed(0.0f, 0.0f, 0.0f); + } + else { + m_pTarget->SetMoveSpeed(m_pTarget->GetMoveSpeed() * Pow(0.8f, CTimer::GetTimeStep())); + } + if (m_fDoorPos == 0.0f) { + CGarages::CrushedCarId = CPools::GetVehiclePool()->GetIndex(m_pTarget); + float reward = Min(CRUSHER_MAX_REWARD, CRUSHER_MIN_REWARD + m_pTarget->pHandling->nMonetaryValue * m_pTarget->m_fHealth * CRUSHER_REWARD_COEFFICIENT); + CWorld::Players[CWorld::PlayerInFocus].m_nMoney += reward * CGarages::CrusherRewardMultiplier; + CMessages::AddMessageWithNumber(TheText.Get("CRUSHED"), 5000, 1, reward* CGarages::CrusherRewardMultiplier, -1, -1, -1, -1, -1); + DestroyVehicleAndDriverAndPassengers(m_pTarget); + //++CStats::CarsCrushed; // TODO + m_pTarget = nil; + m_eGarageState = GS_AFTERDROPOFF; + m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_CRUSH_CAR; + DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f); + } + } + else + m_eGarageState = GS_OPENING; + UpdateCrusherAngle(); + break; + case GS_AFTERDROPOFF: + if (CTimer::GetTimeInMilliseconds() <= m_nTimeToStartAction) { + UpdateCrusherShake((myrand() & 0xFF - 128) * 0.0002f, (myrand() & 0xFF - 128) * 0.0002f); + } + else { + UpdateCrusherShake(0.0f, 0.0f); + m_eGarageState = GS_OPENING; + } + break; + case GS_OPENING: + m_fDoorPos = Min(HALFPI, m_fDoorPos + CTimer::GetTimeStep() * CRUSHER_CRANE_SPEED); + if (m_fDoorPos == HALFPI) { + m_eGarageState = GS_OPENED; + DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f); + } + UpdateCrusherAngle(); + break; + case GS_WAITINGFORCAR: + if (m_pTarget) { + if (CTimer::GetTimeInMilliseconds() - m_nTimeCrusherCraneActivated > 3000) + m_eGarageState = GS_CLOSING; + } + break; + default: + break; + } + if (!FindPlayerVehicle() && (CTimer::GetFrameCounter() & 0x1F) == 0x17 && IsEntityEntirelyInside3D(FindPlayerPed(), 0.0f)) + FindPlayerPed()->InflictDamage(nil, WEAPONTYPE_RAMMEDBYCAR, 300.0f, PEDPIECE_TORSO, 0); break; + } case GARAGE_MISSION_KEEPCAR: case GARAGE_MISSION_KEEPCAR_REMAINCLOSED: switch (m_eGarageState) { @@ -1011,7 +1299,10 @@ void CGarage::Update() break; case GS_FULLYCLOSED: { - float distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y); + float distance = INFINITY; + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed) { + distance = CalcDistToGarageRectangleSquared(FindPlayerCoors().x, FindPlayerCoors().y); + } if (distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_ON_FOOT) || distance < SQR(DISTANCE_TO_OPEN_HIDEOUT_GARAGE_IN_CAR) && FindPlayerVehicle()) { if (FindPlayerVehicle() && CGarages::CountCarsInHideoutGarage(m_eGarageType) >= FindMaxNumStoredCarsForGarage()) { @@ -1203,8 +1494,15 @@ bool CGarage::IsEntityEntirelyInside3D(CEntity* pEntity, float fMargin) for (int i = 0; i < pColModel->numSpheres; i++) { CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; float radius = pColModel->spheres[i].radius; - if (!IsPointInsideGarage(pos, fMargin - radius)) - return false; + if (m_eGarageType == GARAGE_CRATE_GARAGE) { + if (pos.x + radius < m_fInfX - fMargin || pos.x - radius > m_fSupX + fMargin || + pos.y + radius < m_fInfY - fMargin || pos.y - radius > m_fSupX + fMargin) + return false; + } + else { + if (!IsPointInsideGarage(pos, fMargin - radius)) + return false; + } } return true; } @@ -1218,12 +1516,23 @@ bool CGarage::IsEntityEntirelyOutside(CEntity * pEntity, float fMargin) for (int i = 0; i < pColModel->numSpheres; i++) { CVector pos = pEntity->GetMatrix() * pColModel->spheres[i].center; float radius = pColModel->spheres[i].radius; - if (IsPointInsideGarage(pos, fMargin + radius)) - return false; + if (m_eGarageType == GARAGE_CRATE_GARAGE) { + if (pos.x + radius > m_fInfX - fMargin && pos.x - radius < m_fSupX + fMargin && + pos.y + radius > m_fInfY - fMargin && pos.y - radius < m_fSupX + fMargin) + return false; + } + else { + if (IsPointInsideGarage(pos, fMargin + radius)) + return false; + } } return true; } +#ifdef GTA_NETWORK +// some CGarage method (0x134E7C) +#endif + bool CGarage::IsGarageEmpty() { int16 num; @@ -1394,23 +1703,20 @@ void CGarage::RemoveCarsBlockingDoorNotInside() void CGarages::PrintMessages() { if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) { + // CRadar::m_FadeDownRadar = true; // TODO CFont::DrawFonts(); - CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); + float x_scale = FrontEndMenuManager.m_PrefsUseWideScreen ? 0.34506f : 0.3834f; + CFont::SetScale(PSP_SCREEN_SCALE_X(x_scale), PSP_SCREEN_SCALE_Y(0.71f)); CFont::SetPropOn(); CFont::SetJustifyOff(); CFont::SetBackgroundOff(); -#ifdef FIX_BUGS - CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 50)); -#else - CFont::SetCentreSize(SCREEN_WIDTH - 50); -#endif CFont::SetCentreOn(); CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetColor(CRGBA(27, 89, 130, 255)); CFont::SetDropShadowPosition(2); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); - - float y_offset = SCREEN_SCALE_Y(140.0f); + CFont::SetCentreSize(PSP_SCREEN_SCALE_X(454.0f)); + float y_offset = PSP_SCREEN_SCALE_Y(170.0f); if (MessageNumberInString2 >= 0) { CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString); @@ -1431,6 +1737,7 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle) switch (pVehicle->GetModelIndex()) { case MI_FIRETRUCK: case MI_AMBULAN: + case MI_FBICAR: case MI_POLICE: case MI_ENFORCER: case MI_BUS: @@ -1438,9 +1745,6 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle) case MI_BARRACKS: case MI_DODO: case MI_COACH: -#ifndef GTA_PS2 - case MI_FBIRANCH: -#endif return false; default: break; @@ -1497,6 +1801,7 @@ void CGarage::UpdateCrusherAngle() void CGarage::UpdateCrusherShake(float X, float Y) { + /* RefreshDoorPointers(false); m_pDoor1->GetMatrix().GetPosition().x += X; m_pDoor1->GetMatrix().GetPosition().y += Y; @@ -1510,6 +1815,7 @@ void CGarage::UpdateCrusherShake(float X, float Y) m_pDoor2->UpdateRwFrame(); m_pDoor2->GetMatrix().GetPosition().x -= X; m_pDoor2->GetMatrix().GetPosition().y -= Y; + */ } void CGarage::RefreshDoorPointers(bool bCreate) @@ -1575,6 +1881,7 @@ void CGarages::TriggerMessage(const char* text, int16 num1, uint16 time, int16 n MessageEndTime = CTimer::GetTimeInMilliseconds() - 500 + time; } else { + CMessages::AddToPreviousBriefArray(TheText.Get(text), -1, -1, -1, -1, -1, -1, nil); strcpy(MessageIDString, text); MessageStartTime = CTimer::GetTimeInMilliseconds(); MessageEndTime = CTimer::GetTimeInMilliseconds() + time; @@ -1620,7 +1927,8 @@ int32 CGarages::QueryCarsCollected(int16 garage) bool CGarages::HasImportExportGarageCollectedThisCar(int16 garage, int8 car) { - return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType)] & (BIT(car)); + uint32 total; + return CarTypesCollected[GetCarsCollectedIndexForGarageType(aGarages[garage].m_eGarageType, total)] & (BIT(car)); } bool CGarages::IsGarageOpen(int16 garage) @@ -1640,8 +1948,9 @@ bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) bool CGarage::DoesCraigNeedThisCar(int32 mi) { - int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); - for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { + uint32 total; + int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType, total); + for (int i = 0; i < total; i++) { if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) return (CGarages::CarTypesCollected[ct] & BIT(i)) == 0; } @@ -1650,9 +1959,10 @@ bool CGarage::DoesCraigNeedThisCar(int32 mi) bool CGarage::HasCraigCollectedThisCar(int32 mi) { - int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); - for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { - if (mi == gaCarsToCollectInCraigsGarages[ct][i] || (gaCarsToCollectInCraigsGarages[ct][i] == MI_CHEETAH && mi == MI_VICECHEE)) + uint32 total; + int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType, total); + for (int i = 0; i < total; i++) { + if (mi == gaCarsToCollectInCraigsGarages[ct][i]) return CGarages::CarTypesCollected[ct] & BIT(i); } return false; @@ -1660,24 +1970,21 @@ bool CGarage::HasCraigCollectedThisCar(int32 mi) bool CGarage::MarkThisCarAsCollectedForCraig(int32 mi) { - int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType); + uint32 total; + int ct = CGarages::GetCarsCollectedIndexForGarageType(m_eGarageType, total); int index; - for (index = 0; index < TOTAL_COLLECTCARS_CARS; index++) { - if (mi == gaCarsToCollectInCraigsGarages[ct][index] || (gaCarsToCollectInCraigsGarages[ct][index] == MI_CHEETAH && mi == MI_VICECHEE)) + for (index = 0; index < total; index++) { + if (mi == gaCarsToCollectInCraigsGarages[ct][index]) break; } - if (index >= TOTAL_COLLECTCARS_CARS) + if (index >= total) return false; CGarages::CarTypesCollected[ct] |= BIT(index); - CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_REWARD; - for (int i = 0; i < TOTAL_COLLECTCARS_CARS; i++) { + for (int i = 0; i < total; i++) { if ((CGarages::CarTypesCollected[ct] & BIT(i)) == 0) { - CGarages::TriggerMessage("GA_13", -1, 5000, -1); // Delivered like a pro. Complete the list and there'll be a bonus for you. return false; } } - CWorld::Players[CWorld::PlayerInFocus].m_nMoney += IMPORT_ALLCARS_REWARD; - CGarages::TriggerMessage("GA_14", -1, 5000, -1); // All the cars. NICE! Here's a little something. return true; } @@ -1745,15 +2052,17 @@ void CGarage::FindDoorsEntities() } } if (m_pDoor1 && m_pDoor2) { - CVector2D vecDoor1ToGarage(m_pDoor1->GetPosition().x - GetGarageCenterX(), m_pDoor1->GetPosition().y - GetGarageCenterY()); - CVector2D vecDoor2ToGarage(m_pDoor2->GetPosition().x - GetGarageCenterX(), m_pDoor2->GetPosition().y - GetGarageCenterY()); - if (DotProduct2D(vecDoor1ToGarage, vecDoor2ToGarage) > 0.0f) { - if (vecDoor1ToGarage.MagnitudeSqr() >= vecDoor2ToGarage.MagnitudeSqr()) { - m_pDoor1 = m_pDoor2; - m_bDoor1IsDummy = m_bDoor2IsDummy; - } - m_pDoor2 = nil; - m_bDoor2IsDummy = false; + if (m_pDoor1->GetModelIndex() != MI_CRUSHERBODY && m_pDoor1->GetModelIndex() != MI_CRUSHERLID) { + CVector2D vecDoor1ToGarage(m_pDoor1->GetPosition().x - GetGarageCenterX(), m_pDoor1->GetPosition().y - GetGarageCenterY()); + CVector2D vecDoor2ToGarage(m_pDoor2->GetPosition().x - GetGarageCenterX(), m_pDoor2->GetPosition().y - GetGarageCenterY()); + if (DotProduct2D(vecDoor1ToGarage, vecDoor2ToGarage) > 0.0f) { + if (vecDoor1ToGarage.MagnitudeSqr() >= vecDoor2ToGarage.MagnitudeSqr()) { + m_pDoor1 = m_pDoor2; + m_bDoor1IsDummy = m_bDoor2IsDummy; + } + m_pDoor2 = nil; + m_bDoor2IsDummy = false; + } } } if (m_pDoor1) @@ -1772,8 +2081,27 @@ void CGarage::FindDoorsEntitiesSectorList(CPtrList& list, bool dummy) pEntity->m_scanCode = CWorld::GetCurrentScanCode(); if (!pEntity || !CGarages::IsModelIndexADoor(pEntity->GetModelIndex())) continue; - if (!IsPointInsideGarage(pEntity->GetPosition(), 2.0f)) + if (Abs(pEntity->GetPosition().x - GetGarageCenterX()) >= 20.0f || + Abs(pEntity->GetPosition().y - GetGarageCenterY()) >= 20.0f) + continue; + if (pEntity->GetModelIndex() == MI_CRUSHERBODY) { + m_pDoor1 = pEntity; + m_bDoor1IsDummy = dummy; + if (dummy) + m_bDoor1PoolIndex = (CPools::GetDummyPool()->GetIndex((CDummy*)pEntity)) & 0x7F; + else + m_bDoor1PoolIndex = (CPools::GetObjectPool()->GetIndex((CObject*)pEntity)) & 0x7F; + continue; + } + if (pEntity->GetModelIndex() == MI_CRUSHERLID) { + m_pDoor2 = pEntity; + m_bDoor2IsDummy = dummy; + if (dummy) + m_bDoor2PoolIndex = (CPools::GetDummyPool()->GetIndex((CDummy*)pEntity)) & 0x7F; + else + m_bDoor2PoolIndex = (CPools::GetObjectPool()->GetIndex((CObject*)pEntity)) & 0x7F; continue; + } if (!m_pDoor1) { m_pDoor1 = pEntity; m_bDoor1IsDummy = dummy; @@ -1830,26 +2158,48 @@ bool CGarages::HasCarBeenCrushed(int32 handle) void CStoredCar::StoreCar(CVehicle* pVehicle) { m_nModelIndex = pVehicle->GetModelIndex(); - m_vecPos = pVehicle->GetPosition(); - m_vecAngle = pVehicle->GetForward(); + m_fPosX = pVehicle->GetPosition().x; + m_fPosY = pVehicle->GetPosition().y; + m_fPosZ = pVehicle->GetPosition().z; + m_fForwardX = pVehicle->GetForward().x; + m_fForwardY = pVehicle->GetForward().y; + m_fForwardZ = pVehicle->GetForward().z; + m_fTractionMultiplier = 1.0f; m_nPrimaryColor = pVehicle->m_currentColour1; m_nSecondaryColor = pVehicle->m_currentColour2; m_nRadioStation = pVehicle->m_nRadioStation; m_nVariationA = pVehicle->m_aExtras[0]; m_nVariationB = pVehicle->m_aExtras[1]; m_nFlags = 0; + if (pVehicle->bRewardVehicle) m_nFlags |= FLAG_REWARD_VEHICLE; if (pVehicle->bBulletProof) m_nFlags |= FLAG_BULLETPROOF; if (pVehicle->bFireProof) m_nFlags |= FLAG_FIREPROOF; if (pVehicle->bExplosionProof) m_nFlags |= FLAG_EXPLOSIONPROOF; if (pVehicle->bCollisionProof) m_nFlags |= FLAG_COLLISIONPROOF; if (pVehicle->bMeleeProof) m_nFlags |= FLAG_MELEEPROOF; - if (pVehicle->IsCar() || pVehicle->IsBike()) - m_nCarBombType = ((CAutomobile*)pVehicle)->m_bombType; // NB: cast to CAutomobile is original behaviour + if (pVehicle->bTyresDontBurst) m_nFlags |= FLAG_TIRES_INVULNERABLE; + if (pVehicle->bTakeLessDamage) m_nFlags |= FLAG_STRONG; + if (pVehicle->bIsHeavy) m_nFlags |= FLAG_HEAVY; + if (pVehicle->IsCar()) { + CAutomobile* pAutomobile = (CAutomobile*)pVehicle; + if (pAutomobile->bFixedColour) m_nFlags |= FLAG_PERMANENT_COLOUR; + if (pAutomobile->m_bombType) m_nFlags |= FLAG_BOMB; + if (pAutomobile->bNotDamagedUpsideDown) m_nFlags |= FLAG_NOT_DAMAGED_UPSIDEDOWN; + m_fTractionMultiplier = pAutomobile->m_fTraction; + } + else if (pVehicle->IsBike()) { + CBike* pBike = (CBike*)pVehicle; + if (pBike->bFixedColour) m_nFlags |= FLAG_PERMANENT_COLOUR; + m_fTractionMultiplier = pBike->m_fTraction; + } } CVehicle* CStoredCar::RestoreCar() { CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY); + uint8 owner = RANDOM_VEHICLE; + if (m_nFlags & FLAG_REWARD_VEHICLE) + owner = MISSION_VEHICLE; if (!CStreaming::HasModelLoaded(m_nModelIndex)) return nil; #ifdef FIX_BUGS @@ -1862,19 +2212,19 @@ CVehicle* CStoredCar::RestoreCar() } CVehicle* pVehicle; if (CModelInfo::IsBoatModel(m_nModelIndex)) - pVehicle = new CBoat(m_nModelIndex, RANDOM_VEHICLE); + pVehicle = new CBoat(m_nModelIndex, owner); else if (CModelInfo::IsBikeModel(m_nModelIndex)) { - CBike* pBike = new CBike(m_nModelIndex, RANDOM_VEHICLE); + CBike* pBike = new CBike(m_nModelIndex, owner); pBike->bIsStanding = true; pVehicle = pBike; } else - pVehicle = new CAutomobile(m_nModelIndex, RANDOM_VEHICLE); - pVehicle->SetPosition(m_vecPos); + pVehicle = new CAutomobile(m_nModelIndex, owner); + pVehicle->SetPosition(m_fPosX, m_fPosY, m_fPosZ); pVehicle->SetStatus(STATUS_ABANDONED); - pVehicle->GetForward() = m_vecAngle; - pVehicle->GetRight() = CVector(m_vecAngle.y, -m_vecAngle.x, 0.0f); + pVehicle->GetForward() = CVector(m_fForwardX, m_fForwardY, m_fForwardZ); + pVehicle->GetRight() = CVector(m_fForwardY, -m_fForwardX, 0.0f); pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f); pVehicle->pDriver = nil; pVehicle->m_currentColour1 = m_nPrimaryColor; @@ -1891,11 +2241,36 @@ CVehicle* CStoredCar::RestoreCar() } pVehicle->bHasBeenOwnedByPlayer = true; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; + if (m_nFlags & FLAG_REWARD_VEHICLE) pVehicle->bRewardVehicle = true; if (m_nFlags & FLAG_BULLETPROOF) pVehicle->bBulletProof = true; if (m_nFlags & FLAG_FIREPROOF) pVehicle->bFireProof = true; if (m_nFlags & FLAG_EXPLOSIONPROOF) pVehicle->bExplosionProof = true; if (m_nFlags & FLAG_COLLISIONPROOF) pVehicle->bCollisionProof = true; if (m_nFlags & FLAG_MELEEPROOF) pVehicle->bMeleeProof = true; + if (m_nFlags & FLAG_TIRES_INVULNERABLE) pVehicle->bTyresDontBurst = true; + if (m_nFlags & FLAG_STRONG) pVehicle->bTakeLessDamage = true; + if (m_nFlags & FLAG_HEAVY) { + pVehicle->bIsHeavy = true; + pVehicle->m_fMass = pVehicle->pHandling->GetMass(); + pVehicle->m_fTurnMass = pVehicle->pHandling->GetTurnMass(); + } + else { + pVehicle->bIsHeavy = false; + pVehicle->m_fMass = pVehicle->pHandling->GetMass() * 3.0f; + pVehicle->m_fTurnMass = pVehicle->pHandling->GetTurnMass() * 5.0f; + } + if (pVehicle->IsCar()) { + CAutomobile* pAutomobile = (CAutomobile*)pVehicle; + if (m_nFlags & FLAG_PERMANENT_COLOUR) pAutomobile->bFixedColour = true; + if (m_nFlags & FLAG_BOMB) pAutomobile->m_bombType = CARBOMB_TIMED; + if (m_nFlags & FLAG_NOT_DAMAGED_UPSIDEDOWN) pAutomobile->bNotDamagedUpsideDown = true; + m_fTractionMultiplier = pAutomobile->m_fTraction; + } + else if (pVehicle->IsBike()) { + CBike* pBike = (CBike*)pVehicle; + if (m_nFlags & FLAG_PERMANENT_COLOUR) pBike->bFixedColour = true; + m_fTractionMultiplier = pBike->m_fTraction; + } return pVehicle; } @@ -1910,13 +2285,23 @@ void CGarage::StoreAndRemoveCarsForThisHideout(CStoredCar* aCars, int32 nMax) if (!pVehicle) continue; if (IsPointInsideGarage(pVehicle->GetPosition())) { - if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE) { - if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f)) - aCars[index++].StoreCar(pVehicle); +#if defined GTA_PS2 || defined GTA_MOBILE + if (pVehicle->GetStatus() == STATUS_WRECKED) { CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle); CWorld::Remove(pVehicle); delete pVehicle; } + else if (pVehicle->m_bombType == CARBOMB_NONE || pVehicle->bRewardVehicle) // <- probably condition looked different +#endif + { + if (pVehicle->VehicleCreatedBy != MISSION_VEHICLE || pVehicle->bRewardVehicle) { + if (index < Max(NUM_GARAGE_STORED_CARS, nMax) && !EntityHasASphereWayOutsideGarage(pVehicle, 1.0f)) + aCars[index++].StoreCar(pVehicle); + CWorld::Players[CWorld::PlayerInFocus].CancelPlayerEnteringCars(pVehicle); + CWorld::Remove(pVehicle); + delete pVehicle; + } + } } } // why? @@ -2067,7 +2452,7 @@ void CGarage::PlayerArrestedOrDied() case GARAGE_COLLECTCARS_2: case GARAGE_COLLECTCARS_3: case GARAGE_FORCARTOCOMEOUTOF: - case GARAGE_60SECONDS: + case GARAGE_CRATE_GARAGE: case GARAGE_MISSION_KEEPCAR: case GARAGE_FOR_SCRIPT_TO_OPEN: case GARAGE_HIDEOUT_ONE: @@ -2254,14 +2639,12 @@ void CGarages::SetAllDoorsBackToOriginalHeight() } } +#define GARAGE_SIZE 208 + void CGarages::Save(uint8 * buf, uint32 * size) { -//INITSAVEBUF - *size = 7876; // for some reason it's not actual size again - //*size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)); -#if !defined THIS_IS_STUPID && defined COMPATIBLE_SAVES - memset(buf + 7340, 0, *size - 7340); // garbage data is written otherwise -#endif +INITSAVEBUF + *size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * GARAGE_SIZE); CloseHideOutGaragesBeforeSave(); WriteSaveBuf(buf, NumGarages); WriteSaveBuf(buf, (uint32)BombsAreFree); @@ -2302,12 +2685,16 @@ void CGarages::Save(uint8 * buf, uint32 * size) WriteSaveBuf(buf, aGarages[i].m_vDir1); WriteSaveBuf(buf, aGarages[i].m_vDir2); WriteSaveBuf(buf, aGarages[i].m_fSupZ); + WriteSaveBuf(buf, aGarages[i].m_vecSSGaragePos); + WriteSaveBuf(buf, aGarages[i].m_fSSGarageAngle); WriteSaveBuf(buf, aGarages[i].m_fDir1Len); WriteSaveBuf(buf, aGarages[i].m_fDir2Len); WriteSaveBuf(buf, aGarages[i].m_fInfX); WriteSaveBuf(buf, aGarages[i].m_fSupX); WriteSaveBuf(buf, aGarages[i].m_fInfY); WriteSaveBuf(buf, aGarages[i].m_fSupY); + WriteSaveBuf(buf, aGarages[i].m_nTimeCrusherCraneActivated); + ZeroSaveBuf(buf, 4); WriteSaveBuf(buf, aGarages[i].m_fDoorPos); WriteSaveBuf(buf, aGarages[i].m_fDoorHeight); WriteSaveBuf(buf, aGarages[i].m_fDoor1X); @@ -2320,33 +2707,26 @@ void CGarages::Save(uint8 * buf, uint32 * size) WriteSaveBuf(buf, aGarages[i].m_bCollectedCarsState); ZeroSaveBuf(buf, 3 + 4); ZeroSaveBuf(buf, sizeof(aGarages[i].m_sStoredCar)); + WriteSaveBuf(buf, aGarages[i].m_bInitialized); + ZeroSaveBuf(buf, 3); +#ifdef GTA_NETWORK + ZeroSaveBuf(buf, 4); +#endif + WriteSaveBuf(buf, aGarages[i].m_bSSGarageAcceptedVehicle); + WriteSaveBuf(buf, aGarages[i].m_bLocked); + WriteSaveBuf(buf, aGarages[i].m_nSSGarageState); + WriteSaveBuf(buf, aGarages[i].m_bSSGarageStateChanging); #else WriteSaveBuf(buf, aGarages[i]); #endif } -//VALIDATESAVEBUF(*size); -} - -const CStoredCar &CStoredCar::operator=(const CStoredCar & other) -{ - m_nModelIndex = other.m_nModelIndex; - m_vecPos = other.m_vecPos; - m_vecAngle = other.m_vecAngle; - m_nFlags = other.m_nFlags; - m_nPrimaryColor = other.m_nPrimaryColor; - m_nSecondaryColor = other.m_nSecondaryColor; - m_nRadioStation = other.m_nRadioStation; - m_nVariationA = other.m_nVariationA; - m_nVariationB = other.m_nVariationB; - m_nCarBombType = other.m_nCarBombType; - return *this; +VALIDATESAVEBUF(*size); } void CGarages::Load(uint8* buf, uint32 size) { -//INITSAVEBUF - assert(size == 7876); - //assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage))); +INITSAVEBUF + assert(size == (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + TOTAL_HIDEOUT_GARAGES * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * GARAGE_SIZE)); CloseHideOutGaragesBeforeSave(); ReadSaveBuf(&NumGarages, buf); int32 tempInt; @@ -2390,12 +2770,16 @@ void CGarages::Load(uint8* buf, uint32 size) ReadSaveBuf(&aGarages[i].m_vDir1, buf); ReadSaveBuf(&aGarages[i].m_vDir2, buf); ReadSaveBuf(&aGarages[i].m_fSupZ, buf); + ReadSaveBuf(&aGarages[i].m_vecSSGaragePos, buf); + ReadSaveBuf(&aGarages[i].m_fSSGarageAngle, buf); ReadSaveBuf(&aGarages[i].m_fDir1Len, buf); ReadSaveBuf(&aGarages[i].m_fDir2Len, buf); ReadSaveBuf(&aGarages[i].m_fInfX, buf); ReadSaveBuf(&aGarages[i].m_fSupX, buf); ReadSaveBuf(&aGarages[i].m_fInfY, buf); ReadSaveBuf(&aGarages[i].m_fSupY, buf); + ReadSaveBuf(&aGarages[i].m_nTimeCrusherCraneActivated, buf); + SkipSaveBuf(buf, 4); ReadSaveBuf(&aGarages[i].m_fDoorPos, buf); ReadSaveBuf(&aGarages[i].m_fDoorHeight, buf); ReadSaveBuf(&aGarages[i].m_fDoor1X, buf); @@ -2408,6 +2792,15 @@ void CGarages::Load(uint8* buf, uint32 size) ReadSaveBuf(&aGarages[i].m_bCollectedCarsState, buf); SkipSaveBuf(buf, 3 + 4); SkipSaveBuf(buf, sizeof(aGarages[i].m_sStoredCar)); + ReadSaveBuf(&aGarages[i].m_bInitialized, buf); + SkipSaveBuf(buf, 3); +#ifdef GTA_NETWORK + SkipSaveBuf(buf, 4); +#endif + ReadSaveBuf(&aGarages[i].m_bSSGarageAcceptedVehicle, buf); + ReadSaveBuf(&aGarages[i].m_bLocked, buf); + ReadSaveBuf(&aGarages[i].m_nSSGarageState, buf); + ReadSaveBuf(&aGarages[i].m_bSSGarageStateChanging, buf); #else ReadSaveBuf(&aGarages[i], buf); #endif @@ -2421,17 +2814,37 @@ void CGarages::Load(uint8* buf, uint32 size) else aGarages[i].UpdateDoorsHeight(); } -//VALIDATESAVEBUF(size); +VALIDATESAVEBUF(size); MessageEndTime = 0; bCamShouldBeOutisde = false; MessageStartTime = 0; + hGarages = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1); + if (hGarages >= 0) + DMAudio.SetEntityStatus(hGarages, TRUE); } bool CGarages::IsModelIndexADoor(uint32 id) { - return id == MI_GARAGEDOOR2 || + return id == MI_GARAGEDOOR1 || + id == MI_GARAGEDOOR17 || + id == MI_GARAGEDOOR27 || + id == MI_GARAGEDOOR28 || + id == MI_GARAGEDOOR29 || + id == MI_GARAGEDOOR30 || + id == MI_GARAGEDOOR31 || + id == MI_GARAGEDOOR32 || + id == MI_GARAGEDOOR33 || + id == MI_GARAGEDOOR34 || + id == MI_GARAGEDOOR35 || + id == MI_GARAGEDOOR36 || + id == MI_GARAGEDOOR37 || + id == MI_GARAGEDOOR38 || + id == MI_GARAGEDOOR39 || + id == MI_CRUSHERBODY || + id == MI_CRUSHERLID || + id == MI_GARAGEDOOR2 || id == MI_GARAGEDOOR3 || id == MI_GARAGEDOOR4 || id == MI_GARAGEDOOR5 || @@ -2453,7 +2866,8 @@ CGarages::IsModelIndexADoor(uint32 id) id == MI_GARAGEDOOR23 || id == MI_GARAGEDOOR24 || id == MI_GARAGEDOOR25 || - id == MI_GARAGEDOOR26; + id == MI_GARAGEDOOR26 || + id == MI_DOOR2_SJL; } void CGarages::StopCarFromBlowingUp(CAutomobile* pCar) @@ -2493,3 +2907,109 @@ bool CGarage::IsPlayerEntirelyInsideGarage() { return IsEntityEntirelyInside3D(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 0.0f); } + +int16 CGarages::AddCrateGarage(CVector pos, float angle) +{ + CMatrix matrix; + matrix.SetUnity(); + matrix.SetRotateZOnly(DEGTORAD(angle)); + CStreaming::RequestModel(MI_CRATE_SJL, STREAMFLAGS_DEPENDENCY); +#ifdef FIX_BUGS + CStreaming::LoadAllRequestedModels(false); +#endif + CObject* pCrate = new CObject(MI_CRATE_SJL, false); + pCrate->ObjectCreatedBy = MISSION_OBJECT; + pCrate->SetPosition(pos); + pCrate->SetOrientation(0.0f, 0.0f, DEGTORAD(angle)); + pCrate->GetMatrix().UpdateRW(); + pCrate->UpdateRwFrame(); + pCrate->bAffectedByGravity = false; + pCrate->m_phy_flagA08 = true; + pCrate->bExplosionProof = true; + pCrate->bIsStatic = false; + + CStreaming::RequestModel(MI_DOOR1_SJL, STREAMFLAGS_DEPENDENCY); +#ifdef FIX_BUGS + CStreaming::LoadAllRequestedModels(false); +#endif + CObject* pDoor1 = new CObject(MI_DOOR1_SJL, false); + pDoor1->ObjectCreatedBy = MISSION_OBJECT; + CVector vDoor1Pos = matrix * CVector(0.0f, 5.64f, 5.168f); + pDoor1->SetPosition(vDoor1Pos); + pDoor1->SetOrientation(0.0f, 0.0f, DEGTORAD(angle)); + pDoor1->GetMatrix().UpdateRW(); + pDoor1->UpdateRwFrame(); + pDoor1->bAffectedByGravity = false; + pDoor1->m_phy_flagA08 = true; + pDoor1->bExplosionProof = true; + pDoor1->bIsStatic = false; + + CStreaming::RequestModel(MI_DOOR2_SJL, STREAMFLAGS_DEPENDENCY); +#ifdef FIX_BUGS + CStreaming::LoadAllRequestedModels(false); +#endif + CObject* pDoor2 = new CObject(MI_DOOR2_SJL, false); + pDoor2->ObjectCreatedBy = MISSION_OBJECT; + CVector vDoor2Pos = matrix * CVector(0.0f, -5.64f, 5.168f); + pDoor2->SetPosition(vDoor2Pos); + pDoor2->SetOrientation(0.0f, 0.0f, DEGTORAD(angle)); + pDoor2->GetMatrix().UpdateRW(); + pDoor2->UpdateRwFrame(); + pDoor2->bAffectedByGravity = false; + pDoor2->m_phy_flagA08 = true; + pDoor2->bExplosionProof = true; + pDoor2->bIsStatic = false; + + CWorld::Add(pCrate); + CWorld::Add(pDoor1); + CWorld::Add(pDoor2); + + CVector corner = matrix * CVector(-3.0f, -3.5f, -0.5f) + pos; + CVector xplane = matrix * CVector(0.0f, 2.0f, 0.0f) + pos; + CVector yplane = matrix * CVector(0.0f, 0.0f, 0.0f) + pos; + + printf("Posttrans Corner[%f][%f][%f] XPlane[%f][%f][%f] YPlane[%f][%f][%f]", + corner.x, corner.y, corner.z, xplane.x, xplane.y, xplane.z, yplane.x, yplane.y, yplane.z); + int16 index = AddOne(corner.x, corner.y, corner.z, xplane.x, xplane.y, yplane.x, yplane.y, pos.z + 4.0f, GARAGE_CRATE_GARAGE, 0); + SetLeaveCameraForThisGarage(index); + CGarage* pGarage = &aGarages[index]; + pGarage->m_bSSGarageAcceptedVehicle = false; + pGarage->m_bSSGarageStateChanging = false; + pGarage->m_vecSSGaragePos = pos; + pGarage->m_fSSGarageAngle = angle; + return index; +} + +#ifdef GTA_NETWORK +void CGarages::RemoveAllCrateGarages() +{ + for (uint32 i = 0; i < NUM_GARAGES; i++) { + CGarage* pGarage = &aGarages[i]; + if (pGarage->m_eGarageType == GARAGE_CRATE_GARAGE) { + pGarage->m_eGarageType = GARAGE_NONE; + pGarage->m_bSSGarageStateChanging = false; + pGarage->m_bSSGarageAcceptedVehicle = false; + pGarage->m_pSSVehicle = nil; + --NumGarages; + } + } +} + +bool CGarages::HasSSGarageAcceptedVehicle(int16 garage) +{ + return aGarages[garage].m_bSSGarageAcceptedVehicle; +} + +void CGarages::SetVehicleForSSGarage(bool state, int16 garage, void* pVehicle) +{ + CGarage* pGarage = &aGarages[garage]; + pGarage->m_pSSVehicle = pVehicle; + pGarage->m_nSSGarageState = state; + pGarage->m_bSSGarageAcceptedVehicle = false; + if (!pVehicle) { + if (pGarage->m_pSSTargetCar) + pGarage->m_pSSTargetCar->CleanUpOldReference((CEntity**)pGarage->m_pSSTargetCar); + pGarage->m_pSSTargetCar = nil; + } +} +#endif diff --git a/src/control/Garages.h b/src/control/Garages.h index 358d404d..5230b657 100644 --- a/src/control/Garages.h +++ b/src/control/Garages.h @@ -15,6 +15,7 @@ enum eGarageState GS_OPENEDCONTAINSCAR, GS_CLOSEDCONTAINSCAR, GS_AFTERDROPOFF, + GS_WAITINGFORCAR }; enum eGarageType @@ -31,7 +32,7 @@ enum eGarageType GARAGE_COLLECTCARS_2, GARAGE_COLLECTCARS_3, GARAGE_FORCARTOCOMEOUTOF, - GARAGE_60SECONDS, + GARAGE_CRATE_GARAGE, GARAGE_CRUSHER, GARAGE_MISSION_KEEPCAR, GARAGE_FOR_SCRIPT_TO_OPEN, @@ -58,7 +59,7 @@ enum { TOTAL_COLLECTCARS_GARAGES = 4, TOTAL_HIDEOUT_GARAGES = 12, - TOTAL_COLLECTCARS_CARS = 6 + TOTAL_COLLECTCARS_CARS = 16 }; class CStoredCar @@ -69,10 +70,22 @@ class CStoredCar FLAG_EXPLOSIONPROOF = 0x4, FLAG_COLLISIONPROOF = 0x8, FLAG_MELEEPROOF = 0x10, + FLAG_TIRES_INVULNERABLE = 0x20, + FLAG_STRONG = 0x40, + FLAG_HEAVY = 0x80, + FLAG_PERMANENT_COLOUR = 0x100, + FLAG_BOMB = 0x200, + FLAG_NOT_DAMAGED_UPSIDEDOWN = 0x400, + FLAG_REWARD_VEHICLE = 0x8000 }; int32 m_nModelIndex; - CVector m_vecPos; - CVector m_vecAngle; + float m_fPosX; + float m_fPosY; + float m_fPosZ; + float m_fForwardX; + float m_fForwardY; + float m_fForwardZ; + float m_fTractionMultiplier; int32 m_nFlags; int8 m_nPrimaryColor; int8 m_nSecondaryColor; @@ -84,7 +97,6 @@ public: void Init() { m_nModelIndex = 0; } void Clear() { m_nModelIndex = 0; } bool HasCar() { return m_nModelIndex != 0; } - const CStoredCar &operator=(const CStoredCar& other); void StoreCar(CVehicle*); CVehicle* RestoreCar(); }; @@ -118,12 +130,16 @@ public: CVector2D m_vDir1; CVector2D m_vDir2; float m_fSupZ; + CVector m_vecSSGaragePos; + float m_fSSGarageAngle; float m_fDir1Len; float m_fDir2Len; float m_fInfX; float m_fSupX; float m_fInfY; float m_fSupY; + uint32 m_nTimeCrusherCraneActivated; + CVehicle* m_pSSTargetCar; float m_fDoorPos; float m_fDoorHeight; float m_fDoor1X; @@ -136,6 +152,14 @@ public: uint8 m_bCollectedCarsState; CVehicle *m_pTarget; CStoredCar m_sStoredCar; // not needed + bool m_bInitialized; +#ifdef GTA_NETWORK + void* m_pSSVehicle; // some multiplayer vehicle structure, +104 == GetVehiclePointer +#endif + bool m_bSSGarageAcceptedVehicle; + bool m_bLocked; + bool m_nSSGarageState; + bool m_bSSGarageStateChanging; void OpenThisGarage(); void CloseThisGarage(); @@ -222,6 +246,7 @@ public: static CGarage aGarages[NUM_GARAGES]; static CStoredCar aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_CARS]; static bool bCamShouldBeOutisde; + static uint8 CrusherRewardMultiplier; static void Init(void); #ifndef PS2 @@ -269,13 +294,13 @@ public: static void CloseHideOutGaragesBeforeSave(void); static int32 CountCarsInHideoutGarage(uint8); static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; } - static int32 GetCarsCollectedIndexForGarageType(uint8 type) + static int32 GetCarsCollectedIndexForGarageType(uint8 type, uint32& total) { switch (type) { - case GARAGE_COLLECTCARS_1: return 0; - case GARAGE_COLLECTCARS_2: return 1; - case GARAGE_COLLECTCARS_3: return 2; - case GARAGE_COLLECTCARS_4: return 3; + case GARAGE_COLLECTCARS_1: total = TOTAL_COLLECTCARS_CARS; return 0; + case GARAGE_COLLECTCARS_2: total = 0; return 1; + case GARAGE_COLLECTCARS_3: total = 0; return 2; + case GARAGE_COLLECTCARS_4: total = 0; return 3; default: assert(0); } return 0; @@ -300,4 +325,15 @@ public: } static bool IsThisGarageTypeSafehouse(uint8 type) { return FindSafeHouseIndexForGarageType(type) >= 0; } + static bool InitDoorGubbins(uint32, uint8); + static void SetupAnyGaragesForThisIsland(void); + static void LockGarage(int16, bool); + static int16 AddCrateGarage(CVector, float); + +#ifdef GTA_NETWORK + static void RemoveAllCrateGarages(); + static bool HasSSGarageAcceptedVehicle(int16 garage); + static void SetVehicleForSSGarage(bool state, int16 garage, void* pVehicle); // void* -> ? +#endif + }; diff --git a/src/control/OnscreenTimer.cpp b/src/control/OnscreenTimer.cpp index 5045c1e0..45c18a7c 100644 --- a/src/control/OnscreenTimer.cpp +++ b/src/control/OnscreenTimer.cpp @@ -9,18 +9,31 @@ #include "OnscreenTimer.h" #include "Camera.h" +CRGBA gbColour(255, 255, 255, 255); +CRGBA gbColour2(255, 255, 255, 255); + void COnscreenTimer::Init() { m_bDisabled = false; for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) { m_sCounters[i].m_nCounterOffset = 0; + m_sCounters[i].m_nTotal = -1; - for(uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText); j++) - m_sCounters[i].m_aCounterText[j] = '\0'; + for (uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText1); j++) { + m_sCounters[i].m_aCounterText1[j] = '\0'; + } + + for (uint32 j = 0; j < ARRAY_SIZE(m_sCounters[0].m_aCounterText2); j++) { + m_sCounters[i].m_aCounterText2[j] = '\0'; + } m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER; + m_sCounters[i].m_nTypeOfTotal = 0; m_sCounters[i].m_bCounterProcessed = false; + m_sCounters[i].m_colour1 = CRGBA(112, 132, 157, 255); + m_sCounters[i].m_colour2 = CRGBA(42, 58, 81, 255); + } for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { m_sClocks[i].m_nClockOffset = 0; @@ -30,6 +43,8 @@ COnscreenTimer::Init() m_sClocks[i].m_bClockProcessed = false; m_sClocks[i].m_bClockGoingDown = true; + m_sClocks[i].m_aClockColour = CRGBA(244, 225, 91, 255); + m_sClocks[i].m_bClockTickThisFrame = false; } } @@ -44,6 +59,10 @@ COnscreenTimer::Process() void COnscreenTimer::ProcessForDisplay() { +#ifdef GTA_NETWORK + if (gIsMultiplayerGame) + return; +#endif if(CHud::m_Wants_To_Draw_Hud) { m_bProcessed = false; for(uint32 i = 0; i < NUMONSCREENCLOCKS; i++) { @@ -71,9 +90,12 @@ COnscreenTimer::ClearCounter(uint32 offset) for(uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) { if(offset == m_sCounters[i].m_nCounterOffset) { m_sCounters[i].m_nCounterOffset = 0; - m_sCounters[i].m_aCounterText[0] = '\0'; + m_sCounters[i].m_aCounterText1[0] = '\0'; + m_sCounters[i].m_aCounterText2[0] = '\0'; + m_sCounters[i].m_nTypeOfTotal = 0; m_sCounters[i].m_nType = COUNTER_DISPLAY_NUMBER; m_sCounters[i].m_bCounterProcessed = false; + m_sCounters[i].m_bAddDollarPrefix = false; } } } @@ -87,22 +109,45 @@ COnscreenTimer::ClearClock(uint32 offset) m_sClocks[i].m_aClockText[0] = '\0'; m_sClocks[i].m_bClockProcessed = false; m_sClocks[i].m_bClockGoingDown = true; + m_sClocks[i].m_bClockTickThisFrame = false; } } void -COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) +COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text1, uint16 pos, int32 total, char* text2, uint16 totalType) { - if (m_sCounters[pos].m_aCounterText[0] != '\0') + if (m_sCounters[pos].m_nCounterOffset) return; m_sCounters[pos].m_nCounterOffset = offset; - if(text) - strncpy(m_sCounters[pos].m_aCounterText, text, ARRAY_SIZE(m_sCounters[0].m_aCounterText)); + m_sCounters[pos].m_nTotal = total; + if(text1) + strncpy(m_sCounters[pos].m_aCounterText1, text1, ARRAY_SIZE(m_sCounters[0].m_aCounterText1)); + else + m_sCounters[pos].m_aCounterText1[0] = '\0'; + + if (text2) + strncpy(m_sCounters[pos].m_aCounterText2, text2, ARRAY_SIZE(m_sCounters[0].m_aCounterText2)); else - m_sCounters[pos].m_aCounterText[0] = '\0'; + m_sCounters[pos].m_aCounterText2[0] = '\0'; + m_sCounters[pos].m_nTypeOfTotal = totalType; m_sCounters[pos].m_nType = type; + m_sCounters[pos].m_bAddDollarPrefix = 0; + + if (gbColour == CRGBA(255, 255, 255, 255)) + m_sCounters[pos].m_colour1 = CRGBA(112, 132, 157, 255); + else { + m_sCounters[pos].m_colour1 = gbColour; + gbColour = CRGBA(255, 255, 255, 255); + } + + if (gbColour == CRGBA(255, 255, 255, 255)) + m_sCounters[pos].m_colour2 = CRGBA(42, 58, 81, 255); + else { + m_sCounters[pos].m_colour2 = gbColour; + gbColour = CRGBA(255, 255, 255, 255); + } } void @@ -112,6 +157,13 @@ COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) if(m_sClocks[i].m_nClockOffset == 0) { m_sClocks[i].m_nClockOffset = offset; m_sClocks[i].m_bClockGoingDown = bGoingDown; + m_sClocks[i].m_bClockTickThisFrame = false; + if (gbColour == CRGBA(255, 255, 255, 255)) + m_sClocks[i].m_aClockColour = CRGBA(244, 225, 91, 255); + else { + m_sClocks[i].m_aClockColour = gbColour; + gbColour = CRGBA(255, 255, 255, 255); + } if(text) strncpy(m_sClocks[i].m_aClockText, text, ARRAY_SIZE(m_sClocks[0].m_aClockText)); else @@ -140,8 +192,12 @@ COnscreenTimerEntry::Process() } else { int32 oldTimeSeconds = oldTime / 1000; - if (oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds && !TheCamera.m_WideScreenOn) { - DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); + if (oldTimeSeconds < 12) { + m_bClockTickThisFrame = false; + if (newTime / 1000 != oldTimeSeconds) { + m_bClockTickThisFrame = true; + DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000); + } } } } @@ -153,7 +209,7 @@ void COnscreenTimerEntry::ProcessForDisplayClock() { uint32 time = *CTheScripts::GetPointerToScriptVariable(m_nClockOffset); - sprintf(m_aClockBuffer, "%02d:%02d", time / 1000 / 60 % 100, + sprintf(m_aClockBuffer, "%d:%02d", time / 1000 / 60 % 100, time / 1000 % 60); } @@ -161,5 +217,28 @@ void COnscreenCounterEntry::ProcessForDisplayCounter() { uint32 counter = *CTheScripts::GetPointerToScriptVariable(m_nCounterOffset); - sprintf(m_aCounterBuffer, "%d", counter); + char prefix[2] = { '\0' }; + if (m_bAddDollarPrefix) + sprintf(prefix, "$"); +#ifdef FIX_BUGS + char suffix[4] = { '\0' }; +#else + char suffix[2] = { '\0' }; +#endif + if (m_nTotal != -1) { + m_nTotal = Min(99, m_nTotal); + sprintf(suffix, "/%d", m_nTotal); + } + sprintf(m_aCounterBuffer, "%s%d%s", prefix, counter, suffix); +} + +void +COnscreenTimer::ChangeCounterPrefix(uint32 offset, bool bChange) +{ + for (uint32 i = 0; i < NUMONSCREENCOUNTERS; i++) { + if (offset == m_sCounters[i].m_nCounterOffset) { + m_sCounters[i].m_bAddDollarPrefix = bChange; + return; + } + } } diff --git a/src/control/OnscreenTimer.h b/src/control/OnscreenTimer.h index 8c049d7d..a175143f 100644 --- a/src/control/OnscreenTimer.h +++ b/src/control/OnscreenTimer.h @@ -1,5 +1,7 @@ #pragma once +#include "common.h" + enum { COUNTER_DISPLAY_NUMBER, @@ -14,27 +16,31 @@ public: char m_aClockBuffer[40]; bool m_bClockProcessed; bool m_bClockGoingDown; + CRGBA m_aClockColour; + bool m_bClockTickThisFrame; void Process(); void ProcessForDisplayClock(); }; -VALIDATE_SIZE(COnscreenTimerEntry, 0x3C); - class COnscreenCounterEntry { public: uint32 m_nCounterOffset; - char m_aCounterText[10]; + int32 m_nTotal; + char m_aCounterText1[10]; + char m_aCounterText2[10]; + uint16 m_nTypeOfTotal; uint16 m_nType; char m_aCounterBuffer[40]; bool m_bCounterProcessed; + CRGBA m_colour1; + CRGBA m_colour2; + bool m_bAddDollarPrefix; void ProcessForDisplayCounter(); }; -VALIDATE_SIZE(COnscreenCounterEntry, 0x3C); - class COnscreenTimer { public: @@ -50,8 +56,12 @@ public: void ClearCounter(uint32 offset); void ClearClock(uint32 offset); - void AddCounter(uint32 offset, uint16 type, char* text, uint16 pos); + void AddCounter(uint32 offset, uint16 type, char* text, uint16 pos, int32, char*, uint16); void AddClock(uint32 offset, char* text, bool bGoingDown); + + void ChangeCounterPrefix(uint32 offset, bool bChange); }; -VALIDATE_SIZE(COnscreenTimer, 0xF4); +extern CRGBA gbColour; +extern CRGBA gbColour2; + diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp index 80d40b45..f9d58687 100644 --- a/src/control/PathFind.cpp +++ b/src/control/PathFind.cpp @@ -1763,18 +1763,18 @@ CPathFind::TestCoorsCloseness(CVector target, uint8 type, CVector start) float dist; if(type == PATH_CAR) - DoPathSearch(type, start, -1, target, pNodeList, &DummyResult, 32, nil, &dist, 999999.88f, -1); + DoPathSearch(type, start, -1, target, pNodeList, &DummyResult, 32, nil, &dist, 170.0f, -1); else DoPathSearch(type, start, -1, target, nil, &DummyResult2, 0, nil, &dist, 50.0f, -1); #ifdef FIX_BUGS // dist has GenerationDistMultiplier as a factor, so our reference dist should have it too if(type == PATH_CAR) - return dist < 150.0f*TheCamera.GenerationDistMultiplier; + return dist < 180.0f*TheCamera.GenerationDistMultiplier; else return dist < 100.0f*TheCamera.GenerationDistMultiplier; #else if(type == PATH_CAR) - return dist < 150.0f; + return dist < 180.0f; else return dist < 100.0f; #endif diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index f6b1a9b9..020083cf 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -709,8 +709,10 @@ bool CPickups::TestForPickupsInBubble(CVector pos, float range) { for (int i = 0; i < NUMPICKUPS; i++) { - if ((aPickUps[i].m_vecPos - pos).Magnitude() < range) - return true; + if (aPickUps[i].m_eType != PICKUP_NONE) { + if ((aPickUps[i].m_vecPos - pos).Magnitude() < range) + return true; + } } return false; } @@ -1739,4 +1741,20 @@ CPed::CreateDeadPedPickupCoors(float *x, float *y, float *z) *y = GetPosition().y; *z = GetPosition().z + 0.4f; #undef NUMBER_OF_ATTEMPTS -}
\ No newline at end of file +} + +float CPickups::GetValue(int index) +{ + int i = GetActualPickupIndex(index); + if (i == -1) + return 0.0f; + return aPickUps[i].m_fRevenue; +} + +void CPickups::SetValue(int index, float value) +{ + int i = GetActualPickupIndex(index); + if (i == -1) + return; + aPickUps[i].m_fRevenue = value; +} diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 0de7f827..fd8b15cd 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -117,6 +117,9 @@ public: static void RemoveAllPickupsOfACertainWeaponGroupWithNoAmmo(eWeaponType); static CPickup *FindPickUpForThisObject(CEntity*); + + static float GetValue(int); + static void SetValue(int, float); }; extern uint16 AmmoForWeapon[WEAPONTYPE_TOTALWEAPONS + 1]; diff --git a/src/control/Remote.cpp b/src/control/Remote.cpp index 047b19f3..dc025549 100644 --- a/src/control/Remote.cpp +++ b/src/control/Remote.cpp @@ -9,7 +9,7 @@ #include "PlayerInfo.h" #include "Vehicle.h" -void +CVehicle* CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uint16 model) { CAutomobile *car = new CAutomobile(model, MISSION_VEHICLE); @@ -40,6 +40,7 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin TheCamera.SetZoomValueCamStringScript(0); } else TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAMCONTROL_SCRIPT); + return car; } void diff --git a/src/control/Remote.h b/src/control/Remote.h index 72cabb7c..4c40dd96 100644 --- a/src/control/Remote.h +++ b/src/control/Remote.h @@ -3,6 +3,6 @@ class CRemote { public: - static void GivePlayerRemoteControlledCar(float, float, float, float, uint16); + static CVehicle* GivePlayerRemoteControlledCar(float, float, float, float, uint16); static void TakeRemoteControlledCarFromPlayer(bool blowUp = true); }; diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index 71b28f7a..8d7dbf85 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -1285,7 +1285,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca DMAudio.SetEffectsFadeVol(0); DMAudio.SetMusicFadeVol(0); CEscalators::Shutdown(); - CWaterCreatures::RemoveAll(); + //CWaterCreatures::RemoveAll(); int current; for (current = 0; current < NUM_REPLAYBUFFERS; current++) if (BufferStatus[current] == REPLAYBUFFER_RECORD) diff --git a/src/control/Replay.h b/src/control/Replay.h index 5dd8b651..98e02577 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -46,7 +46,7 @@ enum { struct CStoredDetailedAnimationState { - uint8 aAnimId[NUM_MAIN_ANIMS_IN_REPLAY]; + uint16 aAnimId[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aCurTime[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aSpeed[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aBlendAmount[NUM_MAIN_ANIMS_IN_REPLAY]; @@ -54,7 +54,7 @@ struct CStoredDetailedAnimationState uint8 aFunctionCallbackID[NUM_MAIN_ANIMS_IN_REPLAY]; uint16 aFlags[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aGroupId[NUM_MAIN_ANIMS_IN_REPLAY]; - uint8 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; + uint16 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aCurTime2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aSpeed2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aBlendAmount2[NUM_PARTIAL_ANIMS_IN_REPLAY]; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index a2dd8512..fc62aab7 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -11,15 +11,14 @@ #include "CivilianPed.h" #include "Clock.h" #include "CopPed.h" +#include "Coronas.h" #include "Debug.h" #include "DMAudio.h" #include "EmergencyPed.h" #include "FileMgr.h" #include "Frontend.h" #include "General.h" -#ifdef MISSION_REPLAY #include "GenericGameStorage.h" -#endif #include "HandlingMgr.h" #include "Heli.h" #include "Hud.h" @@ -49,16 +48,19 @@ #include "Timecycle.h" #include "TxdStore.h" #include "Bike.h" +#include "smallHeap.h" #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #include <stdarg.h> #endif -uint8 CTheScripts::ScriptSpace[SIZE_SCRIPT_SPACE]; +//--LCS: file done except TODOs and command table +uint8* CTheScripts::ScriptSpace; CRunningScript CTheScripts::ScriptsArray[MAX_NUM_SCRIPTS]; intro_text_line CTheScripts::IntroTextLines[MAX_NUM_INTRO_TEXT_LINES]; intro_script_rectangle CTheScripts::IntroRectangles[MAX_NUM_INTRO_RECTANGLES]; CSprite2d CTheScripts::ScriptSprites[MAX_NUM_SCRIPT_SRPITES]; script_sphere_struct CTheScripts::ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES]; +tCollectiveData CTheScripts::CollectiveArray[MAX_NUM_COLLECTIVES]; tUsedObject CTheScripts::UsedObjectArray[MAX_NUM_USED_OBJECTS]; int32 CTheScripts::MultiScriptArray[MAX_NUM_MISSION_SCRIPTS]; tBuildingSwap CTheScripts::BuildingSwapArray[MAX_NUM_BUILDING_SWAPS]; @@ -94,119 +96,87 @@ uint32 CTheScripts::LastMissionPassedTime; uint16 CTheScripts::NumberOfExclusiveMissionScripts; bool CTheScripts::bPlayerHasMetDebbieHarry; bool CTheScripts::bPlayerIsInTheStatium; -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) -int16 CTheScripts::CardStack[CARDS_IN_DECK * MAX_DECKS]; -int16 CTheScripts::CardStackPosition; -#endif +int CTheScripts::AllowedCollision[MAX_ALLOWED_COLLISIONS]; +int CTheScripts::FSDestroyedFlag; +uint16* CTheScripts::SavedVarIndices; +int CTheScripts::NumSaveVars; +int gScriptsFile = -1; +int CTheScripts::NextProcessId = 1; +bool CTheScripts::InTheScripts; +CRunningScript* pCurrent; +uint16 CTheScripts::NumTrueGlobals; +uint16 CTheScripts::MostGlobals; +CVector gVectorSetInLua; +int CTheScripts::NextScriptCoronaID; +base::cSList<script_corona> CTheScripts::mCoronas; #ifdef MISSION_REPLAY -static const char* nonMissionScripts[] = { - "copcar", - "ambulan", - "taxi", - "firetru", - "rampage", - "t4x4_1", - "t4x4_2", - "t4x4_3", - "rc1", - "rc2", - "rc3", - "rc4", - "hj", - "usj", - "mayhem", - "range", - "race", - "pizza", - "rcheli", - "rcplne1", - "rcrace1", - "cokerun", - "buypro1", - "carbuy1", - "buypro2", - "icecut", - "icecre1", - "buypro3", - "buypro4", - "buypro5", - "buypro6", - "buypro7", - "buypro8", - "buypro9", - "buypro10", - "buypro11", - "ovalrng", - "mm", - "kickst", - "heli1sc", - "heli2sc", - "heli3sc", - "heli4sc", - "carpark_1", - "bmx_1", - "bmx_2" -}; - static const char* MissionScripts[] = { - "LAWYER1", - "LAWYER2", - "LAWYER3", - "LAWYER4", - "GENERL1", - "COL2", - "GENERL3", - "COL_4", - "COL_5", - "baron1", - "baron2", - "baron3", - "baron4", - "kent1", - "baron5", - "serg1", - "serg2", - "serg3", - "bankjo1", - "bankjo2", - "bankjo3", - "bankjo4", - "phil1", - "phil2", - "porno1", - "porno2", - "porno3", - "porno4", - "protec1", - "protec2", - "protec3", - "count1", - "count2", - "CAP_1", - "FIN_1", - "bike1", - "bike2", - "bike3", - "rockb1", - "rockb2", - "rockb3", - "cuban1", - "cuban2", - "cuban3", - "cuban4", - "hait1", - "hait2", - "hait3", - "assin1", - "assin2", - "assin3", - "assin4", - "assin5", - "taxwar1", - "taxwar2", - "taxwar3" + "VIC2", + "VIC3", + "VIC4", + "VIC5", + "VIC6", + "VIC7", + "SAL1", + "SAL2", + "SAL3", + "SAL4", + "SAL5", + "SAL6", + "SAL7", + "SAL8", + "JDT1", + "JDT2", + "JDT3", + "JDT4", + "JDT5", + "JDT6", + "JDT7", + "JDT8", + "MAC1", + "MAC2", + "MAC3", + "MAC4", + "MAC5", + "SALS1", + "SALS2", + "SALS3", + "SALS4", + "SALS5", + "SALS6", + "RAYS1", + "RAYS2", + "RAYS3", + "RAYS4", + "RAYS5", + "DONS1", + "DONS2", + "DONS3", + "DONS4", + "DONS5", + "DONS6", + "DONS7", + "NEDS1", + "NEDS2", + "NEDS3", + "NEDS4", + "SALH1", + "SALH2", + "SALH3", + "SALH4", + "SALH5", + "DONH1", + "DONH2", + "DONH3", + "DONH4", + "DONH5", + "DONH6", + "TOSH1", + "TOSH2", + "TOSH3", + "TOSH4" }; int AllowMissionReplay; @@ -223,7 +193,6 @@ int IsInAmmunation; int MissionSkipLevel; #ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT -bool UsingMobileScript; bool AlreadySavedGame; #endif @@ -231,7 +200,7 @@ bool AlreadySavedGame; const uint32 CRunningScript::nSaveStructSize = #ifdef COMPATIBLE_SAVES - 136; + 536; #else sizeof(CRunningScript); #endif @@ -260,6 +229,23 @@ cleanup_entity_struct* CMissionCleanup::FindFree() return nil; } +void SleepThisPed(cleanup_entity_struct* pCleanup, CPed* pPed) +{ + printf("*** SLEEPING PED %i %i\n", pCleanup->id, pPed->GetModelIndex()); + if (!pPed->GetIsStatic()) + pPed->RemoveFromMovingList(); + pPed->bIsStaticWaitingForCollision = true; +} + +void WakeThisPed(cleanup_entity_struct* pCleanup, CPed* pPed) +{ + printf("*** WAKING UP PED %i %i\n", pCleanup->id, pPed->GetModelIndex()); + pPed->bIsStaticWaitingForCollision = false; + if (!pPed->bIsStatic) + pPed->AddToMovingList(); + +} + void CMissionCleanup::AddEntityToList(int32 id, uint8 type) { cleanup_entity_struct* pNew = FindFree(); @@ -329,46 +315,100 @@ void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects() { CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id); if (pVehicle) { - if (pVehicle->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pVehicle->GetPosition())) { - pVehicle->bIsStaticWaitingForCollision = false; + eLevelName level = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!CColStore::HasCollisionLoaded(level)) { + if (!pVehicle->bIsStaticWaitingForCollision) { + if (!pVehicle->IsHeli() && !pVehicle->IsPlane() && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI && + pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE) { + printf("*** SLEEPING VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex()); if (!pVehicle->GetIsStatic()) - pVehicle->AddToMovingList(); + pVehicle->RemoveFromMovingList(); + pVehicle->bIsStaticWaitingForCollision = true; + } } } - } - break; - } - case CLEANUP_CHAR: - { - CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id); - if (pPed) { - if (pPed->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pPed->GetPosition())) { - pPed->bIsStaticWaitingForCollision = false; - if (!pPed->GetIsStatic()) - pPed->AddToMovingList(); + else { + if (pVehicle->bIsStaticWaitingForCollision) { + printf("*** WAKING UP VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex()); + pVehicle->bIsStaticWaitingForCollision = false; + if (!pVehicle->bIsStatic) + pVehicle->AddToMovingList(); } } } - break; } + break; case CLEANUP_OBJECT: - { CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id); if (pObject) { - if (pObject->bIsStaticWaitingForCollision) { - if (CColStore::HasCollisionLoaded(pObject->GetPosition())) { - pObject->bIsStaticWaitingForCollision = false; + eLevelName level = CTheZones::GetLevelFromPosition(&pObject->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!CColStore::HasCollisionLoaded(level)) { + if (!pObject->bIsStaticWaitingForCollision) { if (!pObject->GetIsStatic()) + pObject->RemoveFromMovingList(); + pObject->bIsStaticWaitingForCollision = true; + } + } + else { + if (pObject->bIsStaticWaitingForCollision) { + pObject->bIsStaticWaitingForCollision = false; + if (!pObject->bIsStatic) pObject->AddToMovingList(); } } } - break; } - default: - break; + } + for (int i = 0; i < MAX_CLEANUP; i++) { + switch (m_sEntities[i].type) { + case CLEANUP_CHAR: + { + CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id); + if (pPed) { + eLevelName level = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); + if (level == LEVEL_GENERIC) + level = CGame::currLevel; + if (!pPed->bIsStaticWaitingForCollision) { + if (pPed->bInVehicle) { + if (pPed->m_pMyVehicle->GetIsStatic()) { + SleepThisPed(&m_sEntities[i], pPed); + continue; + } + } + if (!CColStore::HasCollisionLoaded(level)) { + if (pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()) + SleepThisPed(&m_sEntities[i], pPed); + } + } + else { + if (!pPed->bInVehicle) { + if (CColStore::HasCollisionLoaded(level)) { + if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())) + WakeThisPed(&m_sEntities[i], pPed); + } + } + else { + if (!pPed->m_pMyVehicle->GetIsStatic()) { + WakeThisPed(&m_sEntities[i], pPed); + continue; + } + if (CColStore::HasCollisionLoaded(level)) { + if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() || + pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())) + WakeThisPed(&m_sEntities[i], pPed); + } + } + } + + } + } + break; } } } @@ -380,6 +420,8 @@ void CMissionCleanup::Process() CCarCtrl::CarDensityMultiplier = 1.0f; CPed::nThreatReactionRangeMultiplier = 1; CPed::nEnterCarRangeMultiplier = 1; + for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++) + CTheScripts::AllowedCollision[i] = 0; FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f; CRoadBlocks::ClearScriptRoadBlocks(); CRouteNode::Initialise(); @@ -387,20 +429,22 @@ void CMissionCleanup::Process() TheCamera.Restore(); TheCamera.SetWideScreenOff(); CSpecialFX::bLiftCam = false; - CSpecialFX::bVideoCam = false; - CTimeCycle::StopExtraColour(0); + // TODO(LCS): CHud::m_ClockEventWarningMinutes = 0; + // TODO(LCS): CHud::m_ClockEventFlashTimer = 0; + CTimeCycle::StopExtraColour(0); // TODO: thiscall for (int i = 0; i < MISSION_AUDIO_SLOTS; i++) DMAudio.ClearMissionAudio(i); CWeather::ReleaseWeather(); for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++) CStreaming::SetMissionDoesntRequireSpecialChar(i); - for (int i = 0; i < NUM_OF_CUTSCENE_OBJECTS; i++) - CStreaming::SetMissionDoesntRequireModel(MI_CUTOBJ01 + i); - CStreaming::ms_disableStreaming = false; - CHud::m_ItemToFlash = -1; - CHud::SetHelpMessage(nil, false); +#ifdef GTA_NETWORK + if (!gIsMultiplayerGame) +#endif + CStreaming::ms_disableStreaming = false; + if (CHud::m_ItemToFlash != ITEM_ARMOUR && CHud::m_ItemToFlash != ITEM_HEALTH) + CHud::m_ItemToFlash = ITEM_NONE; + CHud::SetHelpMessage(nil, false); // nil, false, false, true TODO(LCS) CUserDisplay::OnscnTimer.m_bDisabled = false; - CTheScripts::RemoveScriptTextureDictionary(); CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByCops = false; CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByEveryone = false; CWorld::Players[0].MakePlayerSafe(false); @@ -408,10 +452,11 @@ void CMissionCleanup::Process() CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0; CPad::GetPad(0)->SetDrunkInputDelay(0); CWorld::Players[0].m_bDriveByAllowed = true; + CPad::GetPad(0)->unk_B4 = 1.0f; + CPad::GetPad(0)->unk_B8 = 0.5f; DMAudio.ShutUpPlayerTalking(FALSE); CVehicle::bDisableRemoteDetonation = false; CVehicle::bDisableRemoteDetonationOnContact = false; - CGameLogic::ClearShortCut(); CTheScripts::RiotIntensity = 0; CTheScripts::StoreVehicleIndex = -1; CTheScripts::StoreVehicleWasRandom = true; @@ -447,6 +492,10 @@ void CMissionCleanup::Process() } RemoveEntityFromList(m_sEntities[i].id, m_sEntities[i].type); } + for (int i = 1; i < MODELINFOSIZE; i++) { + if (CStreaming::IsScriptOwnedModel(i)) + CStreaming::SetMissionDoesntRequireModel(i); + } #ifdef SECUROM if ((myrand() & 3) == 2){ // if pirated game @@ -475,7 +524,7 @@ bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id) bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle) { - assert(pVehicle); + script_assert(pVehicle); return pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD && pVehicle->GetMoveSpeed().Magnitude() < UPSIDEDOWN_MOVE_SPEED_THRESHOLD && pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD; @@ -614,50 +663,71 @@ bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id) return false; } -void CRunningScript::CollectParameters(uint32* pIp, int16 total) +void CRunningScript::CollectParameters(uint32* pIp, int16 total, int* pParameters) { - for (int16 i = 0; i < total; i++){ - uint16 varIndex; + while (total--){ switch (CTheScripts::Read1ByteFromScript(pIp)) { - case ARGUMENT_INT32: - case ARGUMENT_FLOAT: - ScriptParams[i] = CTheScripts::Read4BytesFromScript(pIp); + case ARGUMENT_END: + return; + case ARGUMENT_INT_ZERO: + *pParameters = 0; break; - case ARGUMENT_GLOBALVAR: - varIndex = CTheScripts::Read2BytesFromScript(pIp); - script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); - ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[varIndex]); + case ARGUMENT_FLOAT_ZERO: + *pParameters = 0; break; - case ARGUMENT_LOCALVAR: - varIndex = CTheScripts::Read2BytesFromScript(pIp); - script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); - ScriptParams[i] = m_anLocalVariables[varIndex]; + case ARGUMENT_FLOAT_1BYTE: + *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24; + break; + case ARGUMENT_FLOAT_2BYTES: + *pParameters = (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + break; + case ARGUMENT_FLOAT_3BYTES: + *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8; + *pParameters |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + break; + case ARGUMENT_INT32: + case ARGUMENT_FLOAT: + *pParameters = CTheScripts::Read4BytesFromScript(pIp); break; case ARGUMENT_INT8: - ScriptParams[i] = CTheScripts::Read1ByteFromScript(pIp); + *pParameters = CTheScripts::Read1ByteFromScript(pIp); break; case ARGUMENT_INT16: - ScriptParams[i] = CTheScripts::Read2BytesFromScript(pIp); + *pParameters = CTheScripts::Read2BytesFromScript(pIp); break; default: - script_assert(0); + *pIp -= 1; + *pParameters = *GetPointerToScriptVariable(pIp, 0); break; } + pParameters++; } } + int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) { uint32* pIp = &ip; + int tmp; switch (CTheScripts::Read1ByteFromScript(pIp)) { + case ARGUMENT_END: + return 0; // TODO(LCS) + case ARGUMENT_INT_ZERO: + return 0; + case ARGUMENT_FLOAT_ZERO: + return 0; + case ARGUMENT_FLOAT_1BYTE: + return (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24; + case ARGUMENT_FLOAT_2BYTES: + return (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + case ARGUMENT_FLOAT_3BYTES: + tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8; + tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16; + return tmp; case ARGUMENT_INT32: return CTheScripts::Read4BytesFromScript(pIp); - case ARGUMENT_GLOBALVAR: - return *((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]); - case ARGUMENT_LOCALVAR: - return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; case ARGUMENT_INT8: return CTheScripts::Read1ByteFromScript(pIp); case ARGUMENT_INT16: @@ -665,7 +735,8 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) case ARGUMENT_FLOAT: return CTheScripts::Read4BytesFromScript(pIp); default: - script_assert(0); + (*pIp)--; + return *GetPointerToScriptVariable(pIp, 0); } return -1; } @@ -673,38 +744,61 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip) void CRunningScript::StoreParameters(uint32* pIp, int16 number) { for (int16 i = 0; i < number; i++){ - switch (CTheScripts::Read1ByteFromScript(pIp)) { - case ARGUMENT_GLOBALVAR: - *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; - break; - case ARGUMENT_LOCALVAR: - m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i]; - break; - default: - script_assert(0); - } + *GetPointerToScriptVariable(pIp, 0) = ScriptParams[i]; } } +int32* GetPointerToScriptVariable(CRunningScript* pScript, uint32* pIp) +{ + uint8 type = CTheScripts::Read1ByteFromScript(pIp); + if (type >= ARGUMENT_GLOBAL_ARRAY) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(pIp); + script_assert(size > 0); + script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size); + uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index + index_in_block)]; + } + else if (type >= ARGUMENT_GLOBAL) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block)]; + } + else if (type >= ARGUMENT_LOCAL_ARRAY) { + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(pIp); + script_assert(size > 0); + script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size); + uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1); + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL_ARRAY) + index]; + } + else if (type >= ARGUMENT_LOCAL) { + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)]; + } + else if (type >= ARGUMENT_TIMER) { + return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; + } + script_assert(false && "wrong type for variable"); + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)]; +} + int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type) { - switch (CTheScripts::Read1ByteFromScript(pIp)) - { - case ARGUMENT_GLOBALVAR: - script_assert(type == VAR_GLOBAL); - return (int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]; - case ARGUMENT_LOCALVAR: - script_assert(type == VAR_LOCAL); - return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)]; - default: - script_assert(0); + return ::GetPointerToScriptVariable(this, pIp); +} + +int CTheScripts::GetSaveVarIndex(int var) +{ + for (int i = 0; i < NumSaveVars; i++) { + if (SavedVarIndices[i] == var) + return i; } - return nil; + return -1; } void CRunningScript::Init() { - strcpy(m_abScriptName, "noname"); + sprintf(m_abScriptName, "id%02i", m_nId); next = prev = nil; SetIP(0); for (int i = 0; i < MAX_STACK_DEPTH; i++) @@ -715,13 +809,28 @@ void CRunningScript::Init() m_bCondResult = false; m_bIsMissionScript = false; m_bSkipWakeTime = false; - for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) + for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++) m_anLocalVariables[i] = 0; m_nAndOrState = 0; m_bNotFlag = false; m_bDeatharrestEnabled = true; m_bDeatharrestExecuted = false; m_bMissionFlag = false; + m_nLocalsPointer = 0; +} + +void CTheScripts::Shutdown() +{ + if (gScriptsFile != -1) { + CFileMgr::CloseFile(gScriptsFile); + gScriptsFile = -1; + } + if (ScriptSpace) { + base::cMainMemoryManager::Instance()->Free(ScriptSpace); + ScriptSpace = nil; + FSDestroyedFlag = false; + OnAMissionFlag = 0; + } } #ifdef USE_DEBUG_SCRIPT_LOADER @@ -731,18 +840,18 @@ int CTheScripts::OpenScript() { CFileMgr::ChangeDir("\\"); switch (ScriptToLoad) { - case 0: return CFileMgr::OpenFile("data\\main.scm", "rb"); - case 1: return CFileMgr::OpenFile("data\\freeroam_miami.scm", "rb"); - case 2: return CFileMgr::OpenFile("data\\main_d.scm", "rb"); + case 0: return CFileMgr::OpenFile("DATA\\main.scm", "rb"); + case 1: return CFileMgr::OpenFile("DATA\\freeroam_lcs.scm", "rb"); + case 2: return CFileMgr::OpenFile("DATA\\main_d.scm", "rb"); } - return CFileMgr::OpenFile("data\\main.scm", "rb"); + return CFileMgr::OpenFile("DATA\\main.scm", "rb"); } #endif -void CTheScripts::Init() +bool CTheScripts::Init(bool loaddata) { - for (int i = 0; i < SIZE_SCRIPT_SPACE; i++) - ScriptSpace[i] = 0; + bool retval = false; + printf("CTheScripts::Init\n"); pActiveScripts = pIdleScripts = nil; for (int i = 0; i < MAX_NUM_SCRIPTS; i++){ ScriptsArray[i].Init(); @@ -751,31 +860,52 @@ void CTheScripts::Init() MissionCleanUp.Init(); UpsideDownCars.Init(); StuckCars.Init(); -#ifdef USE_DEBUG_SCRIPT_LOADER - // glfwGetKey doesn't work because of CGame::Initialise is blocking - CPad::UpdatePads(); - if(CPad::GetPad(0)->GetChar('G')) ScriptToLoad = 0; - if(CPad::GetPad(0)->GetChar('R')) ScriptToLoad = 1; - if(CPad::GetPad(0)->GetChar('D')) ScriptToLoad = 2; - - int mainf = OpenScript(); -#else - CFileMgr::SetDir("data"); - int mainf = CFileMgr::OpenFile("main.scm", "rb"); -#endif - CFileMgr::Read(mainf, (char*)ScriptSpace, SIZE_MAIN_SCRIPT); - CFileMgr::CloseFile(mainf); - CFileMgr::SetDir(""); StoreVehicleIndex = -1; StoreVehicleWasRandom = true; OnAMissionFlag = 0; LastMissionPassedTime = (uint32)-1; + for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { + CollectiveArray[i].colIndex = -1; + CollectiveArray[i].pedIndex = 0; + } + NextFreeCollectiveIndex = 0; LastRandomPedId = -1; for (int i = 0; i < MAX_NUM_USED_OBJECTS; i++){ memset(&UsedObjectArray[i].name, 0, sizeof(UsedObjectArray[i].name)); UsedObjectArray[i].index = 0; } +#if defined FIX_BUGS || (!defined GTA_PS2 && !defined GTA_PSP) + for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i;) { + base::cSList<script_corona>::tSItem* next = i->next; + delete i; + i = next; + } + CTheScripts::mCoronas.first = nil; +#endif NumberOfUsedObjects = 0; + if (ScriptSpace) + Shutdown(); +#ifdef USE_DEBUG_SCRIPT_LOADER + // glfwGetKey doesn't work because of CGame::Initialise is blocking + CPad::UpdatePads(); + if (CPad::GetPad(0)->GetChar('G')) ScriptToLoad = 0; + if (CPad::GetPad(0)->GetChar('R')) ScriptToLoad = 1; + if (CPad::GetPad(0)->GetChar('D')) ScriptToLoad = 2; + int mainf = OpenScript(); +#else + CFileMgr::SetDir("DATA"); + int mainf = CFileMgr::OpenFile("main.scm", "rb"); +#endif + CFileMgr::Read(mainf, (char*)&MainScriptSize, sizeof(MainScriptSize)); + int nLargestMissionSize = 0; + CFileMgr::Read(mainf, (char*)&nLargestMissionSize, sizeof(nLargestMissionSize)); + if (!cSmallHeap::msInstance.IsLocked()) + cSmallHeap::msInstance.Lock(); + ScriptSpace = (uint8*)base::cMainMemoryManager::Instance()->Allocate(MainScriptSize + nLargestMissionSize); + memset(ScriptSpace, 0, MainScriptSize + nLargestMissionSize); + CFileMgr::Read(mainf, (char*)ScriptSpace, MainScriptSize); + gScriptsFile = mainf; + CFileMgr::SetDir(""); ReadObjectNamesFromScript(); UpdateObjectIndices(); bAlreadyRunningAMissionScript = false; @@ -785,11 +915,10 @@ void CTheScripts::Init() NumberOfExclusiveMissionScripts = 0; NumberOfMissionScripts = 0; LargestMissionScriptSize = 0; - MainScriptSize = 0; ReadMultiScriptFileOffsetsFromScript(); FailCurrentMission = 0; DbgFlag = false; - NumScriptDebugLines = 0; + //NumScriptDebugLines = 0; RiotIntensity = 0; bPlayerHasMetDebbieHarry = false; bPlayerIsInTheStatium = false; @@ -813,7 +942,7 @@ void CTheScripts::Init() IntroRectangles[i].m_sColor = CRGBA(255, 255, 255, 255); } NumberOfIntroRectanglesThisFrame = 0; - RemoveScriptTextureDictionary(); + //RemoveScriptTextureDictionary(); // TODO(LCS) - probably not needed for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++){ BuildingSwapArray[i].m_pBuilding = nil; BuildingSwapArray[i].m_nNewModel = -1; @@ -821,16 +950,23 @@ void CTheScripts::Init() } for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) InvisibilitySettingArray[i] = nil; + if (loaddata) { + printf("loaddata = true\n"); + retval = GenericLoad(); + } + for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++) + AllowedCollision[i] = 0; #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT LogAfterScriptInitializing(); #endif #ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT - UsingMobileScript = false; AlreadySavedGame = false; #endif + return retval; } +/* void CTheScripts::RemoveScriptTextureDictionary() { for (int i = 0; i < ARRAY_SIZE(CTheScripts::ScriptSprites); i++) @@ -839,6 +975,7 @@ void CTheScripts::RemoveScriptTextureDictionary() if (slot != -1) CTxdStore::RemoveTxd(slot); } +*/ void CRunningScript::RemoveScriptFromList(CRunningScript** ppScript) { @@ -864,6 +1001,7 @@ CRunningScript* CTheScripts::StartNewScript(uint32 ip) CRunningScript* pNew = pIdleScripts; script_assert(pNew); pNew->RemoveScriptFromList(&pIdleScripts); + pNew->m_nId = NextProcessId++; pNew->Init(); pNew->SetIP(ip); pNew->AddScriptToList(&pActiveScripts); @@ -875,6 +1013,8 @@ void CTheScripts::Process() { if (CReplay::IsPlayingBack()) return; + if (!ScriptSpace) + return; CommandsExecuted = 0; ScriptsUpdated = 0; float timeStep = CTimer::GetTimeStepInMilliseconds(); @@ -949,6 +1089,7 @@ void CTheScripts::Process() #endif CRunningScript* script = pActiveScripts; + InTheScripts = true; while (script != nil){ CRunningScript* next = script->GetNext(); ++ScriptsUpdated; @@ -958,6 +1099,11 @@ void CTheScripts::Process() if (script && !script->m_bIsActive) script = nil; } + InTheScripts = false; + for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) { + CCoronas::RegisterCorona((uint32)(uintptr)i, i->item.r, i->item.g, i->item.b, 255, CVector(i->item.x, i->item.y, i->item.z), + -i->item.size, 450.0f, i->item.type, i->item.flareType, 1, 0, 0, 0.0f); + } DbgFlag = false; #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT @@ -980,6 +1126,7 @@ void CRunningScript::Process() #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT LogOnStartProcessing(); #endif + pCurrent = this; if (m_bIsMissionScript) DoDeatharrestCheck(); if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1) @@ -1016,34 +1163,40 @@ int8 CRunningScript::ProcessOneCommand() retval = ProcessCommands0To99(command); else if (command < 200) retval = ProcessCommands100To199(command); - else if (command < 300) + else if (command < 305) retval = ProcessCommands200To299(command); - else if (command < 400) + else if (command < 405) retval = ProcessCommands300To399(command); - else if (command < 500) + else if (command < 505) retval = ProcessCommands400To499(command); - else if (command < 600) + else if (command < 605) retval = ProcessCommands500To599(command); - else if (command < 700) + else if (command < 705) retval = ProcessCommands600To699(command); - else if (command < 800) + else if (command < 805) retval = ProcessCommands700To799(command); - else if (command < 900) + else if (command < 905) retval = ProcessCommands800To899(command); - else if (command < 1000) + else if (command < 1005) retval = ProcessCommands900To999(command); - else if (command < 1100) + else if (command < 1105) retval = ProcessCommands1000To1099(command); - else if (command < 1200) + else if (command < 1205) retval = ProcessCommands1100To1199(command); - else if (command < 1300) + else if (command < 1305) retval = ProcessCommands1200To1299(command); - else if (command < 1400) + else if (command < 1405) retval = ProcessCommands1300To1399(command); - else if (command < 1500) + else if (command < 1497) retval = ProcessCommands1400To1499(command); + else if (command < 1600) + retval = ProcessCommands1500To1599(command); + else if (command < 1700) + retval = ProcessCommands1600To1699(command); + else + script_assert(false); #ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT - if (!AlreadySavedGame) // we need to ignore first "fake" command which actually just saves the game + if (!AlreadySavedGame) #endif { #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT @@ -1064,16 +1217,18 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) float *fScriptVar1; int *nScriptVar1; switch (command) { + /* case COMMAND_NOP: return 0; + */ case COMMAND_WAIT: CollectParameters(&m_nIp, 1); - m_nWakeTime = CTimer::GetTimeInMilliseconds() + ScriptParams[0]; + m_nWakeTime = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(0); m_bSkipWakeTime = false; return 1; case COMMAND_GOTO: CollectParameters(&m_nIp, 1); - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); /* Known issue: GOTO to 0. It might have been "better" to use > instead of >= */ /* simply because it never makes sense to jump to start of the script */ /* but jumping to start of a custom mission is an issue for simple mission-like scripts */ @@ -1082,174 +1237,174 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) return 0; case COMMAND_SHAKE_CAM: CollectParameters(&m_nIp, 1); - CamShakeNoPos(&TheCamera, ScriptParams[0] / 1000.0f); + CamShakeNoPos(&TheCamera, GET_INTEGER_PARAM(0) / 1000.0f); return 0; case COMMAND_SET_VAR_INT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_VAR_FLOAT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr = *(float*)&ScriptParams[0]; + *(float*)ptr = GET_FLOAT_PARAM(0); return 0; } case COMMAND_SET_LVAR_INT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_LVAR_FLOAT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr = *(float*)&ScriptParams[0]; + *(float*)ptr = GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_INT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr += ScriptParams[0]; + *ptr += GET_INTEGER_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_FLOAT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += *(float*)&ScriptParams[0]; + *(float*)ptr += GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_INT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr += ScriptParams[0]; + *ptr += GET_INTEGER_PARAM(0); return 0; } case COMMAND_ADD_VAL_TO_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += *(float*)&ScriptParams[0]; + *(float*)ptr += GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_INT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr -= ScriptParams[0]; + *ptr -= GET_INTEGER_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_FLOAT_VAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= *(float*)&ScriptParams[0]; + *(float*)ptr -= GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_INT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr -= ScriptParams[0]; + *ptr -= GET_INTEGER_PARAM(0); return 0; } case COMMAND_SUB_VAL_FROM_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= *(float*)&ScriptParams[0]; + *(float*)ptr -= GET_FLOAT_PARAM(0); return 0; } case COMMAND_MULT_INT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr *= ScriptParams[0]; + *ptr *= GET_INTEGER_PARAM(0); return 0; } case COMMAND_MULT_FLOAT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr *= *(float*)&ScriptParams[0]; + *(float*)ptr *= GET_FLOAT_PARAM(0); return 0; } case COMMAND_MULT_INT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr *= ScriptParams[0]; + *ptr *= GET_INTEGER_PARAM(0); return 0; } case COMMAND_MULT_FLOAT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr *= *(float*)&ScriptParams[0]; + *(float*)ptr *= GET_FLOAT_PARAM(0); return 0; } case COMMAND_DIV_INT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr /= ScriptParams[0]; + *ptr /= GET_INTEGER_PARAM(0); return 0; } case COMMAND_DIV_FLOAT_VAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr /= *(float*)&ScriptParams[0]; + *(float*)ptr /= GET_FLOAT_PARAM(0); return 0; } case COMMAND_DIV_INT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr /= ScriptParams[0]; + *ptr /= GET_INTEGER_PARAM(0); return 0; } case COMMAND_DIV_FLOAT_LVAR_BY_VAL: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr /= *(float*)&ScriptParams[0]; + *(float*)ptr /= GET_FLOAT_PARAM(0); return 0; } case COMMAND_IS_INT_VAR_GREATER_THAN_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_THAN_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_INT_VAR_GREATER_THAN_INT_VAR: @@ -1284,28 +1439,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr > *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr > GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_LVAR_GREATER_THAN_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr > *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr > GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] > *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) > *(float*)ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] > *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) > *(float*)ptr); return 0; } case COMMAND_IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR: @@ -1340,28 +1495,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR: @@ -1396,28 +1551,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr >= *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr >= GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr >= *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr >= GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] >= *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) >= *(float*)ptr); return 0; } case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(*(float*)&ScriptParams[0] >= *(float*)ptr); + UpdateCompareFlag(GET_FLOAT_PARAM(0) >= *(float*)ptr); return 0; } case COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR: @@ -1452,14 +1607,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_VAR_EQUAL_TO_INT_VAR: @@ -1492,14 +1647,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr == *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr == GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_LVAR_EQUAL_TO_NUMBER: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*(float*)ptr == *(float*)&ScriptParams[0]); + UpdateCompareFlag(*(float*)ptr == GET_FLOAT_PARAM(0)); return 0; } case COMMAND_IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR: @@ -1528,17 +1683,15 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) //case COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR: //case COMMAND_IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR: //case COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR: - /* case COMMAND_GOTO_IF_TRUE: CollectParameters(&m_nIp, 1); if (m_bCondResult) - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); return 0; - */ case COMMAND_GOTO_IF_FALSE: CollectParameters(&m_nIp, 1); if (!m_bCondResult) - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); /* Check COMMAND_GOTO note. */ return 0; case COMMAND_TERMINATE_THIS_SCRIPT: @@ -1564,47 +1717,19 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) case COMMAND_START_NEW_SCRIPT: { CollectParameters(&m_nIp, 1); - script_assert(ScriptParams[0] >= 0); - CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]); - pNew->m_bIsActive = true; - int8 type = CTheScripts::Read1ByteFromScript(&m_nIp); - float tmp; - for (int i = 0; type != ARGUMENT_END; type = CTheScripts::Read1ByteFromScript(&m_nIp), i++) { - switch (type) { - case ARGUMENT_INT32: - pNew->m_anLocalVariables[i] = CTheScripts::Read4BytesFromScript(&m_nIp); - break; - case ARGUMENT_GLOBALVAR: - pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(&m_nIp)]; - break; - case ARGUMENT_LOCALVAR: - pNew->m_anLocalVariables[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(&m_nIp)]; - break; - case ARGUMENT_INT8: - pNew->m_anLocalVariables[i] = CTheScripts::Read1ByteFromScript(&m_nIp); - break; - case ARGUMENT_INT16: - pNew->m_anLocalVariables[i] = CTheScripts::Read2BytesFromScript(&m_nIp); - break; - case ARGUMENT_FLOAT: - tmp = CTheScripts::ReadFloatFromScript(&m_nIp); - pNew->m_anLocalVariables[i] = *(int32*)&tmp; - break; - default: - break; - } - } + script_assert(GET_INTEGER_PARAM(0) >= 0); + CRunningScript* pNew = CTheScripts::StartNewScript(GET_INTEGER_PARAM(0)); + CollectParameters(&m_nIp, NUM_LOCAL_VARS, pNew->m_anLocalVariables); return 0; } case COMMAND_GOSUB: CollectParameters(&m_nIp, 1); script_assert(m_nStackPointer < MAX_STACK_DEPTH); m_anStack[m_nStackPointer++] = m_nIp; - SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]); + SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0)); return 0; case COMMAND_RETURN: - script_assert(m_nStackPointer > 0); /* No more SSU */ - SetIP(m_anStack[--m_nStackPointer]); + ReturnFromGosubOrFunction(); return 0; case COMMAND_LINE: CollectParameters(&m_nIp, 6); @@ -1613,7 +1738,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) case COMMAND_CREATE_PLAYER: { CollectParameters(&m_nIp, 4); - int32 index = ScriptParams[0]; + int32 index = GET_INTEGER_PARAM(0); script_assert(index < NUMPLAYERS); printf("&&&&&&&&&&&&&Creating player: %d\n", index); if (!CStreaming::HasModelLoaded(MI_PLAYER)) { @@ -1623,14 +1748,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) CPlayerPed::SetupPlayerPed(index); CWorld::Players[index].m_pPed->CharCreatedBy = MISSION_CHAR; CPlayerPed::DeactivatePlayerPed(index); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += CWorld::Players[index].m_pPed->GetDistanceFromCentreOfMassToBaseOfModel(); CWorld::Players[index].m_pPed->SetPosition(pos); CTheScripts::ClearSpaceForMissionEntity(pos, CWorld::Players[index].m_pPed); CPlayerPed::ReactivatePlayerPed(index); - ScriptParams[0] = index; + SET_INTEGER_PARAM(0, index); StoreParameters(&m_nIp, 1); return 0; } @@ -1638,23 +1763,23 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) { CVector pos; CollectParameters(&m_nIp, 1); - if (CWorld::Players[ScriptParams[0]].m_pPed->bInVehicle) - pos = CWorld::Players[ScriptParams[0]].m_pPed->m_pMyVehicle->GetPosition(); + if (CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->bInVehicle && CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pMyVehicle) + pos = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pMyVehicle->GetPosition(); else - pos = CWorld::Players[ScriptParams[0]].m_pPed->GetPosition(); - *(CVector*)&ScriptParams[0] = pos; + pos = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GetPosition(); + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_PLAYER_COORDINATES: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[1]; - int index = ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(1); + int index = GET_INTEGER_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CPlayerPed* ped = CWorld::Players[index].m_pPed; - if (ped->bInVehicle) { + if (ped->bInVehicle && ped->m_pMyVehicle) { pos.z += ped->m_pMyVehicle->GetDistanceFromCentreOfMassToBaseOfModel(); ped->m_pMyVehicle->Teleport(pos); // removed dumb stuff that was present here CTheScripts::ClearSpaceForMissionEntity(pos, ped->m_pMyVehicle); @@ -1667,7 +1792,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) if (ped) { // great time to check for (int i = 0; i < ped->m_numNearPeds; i++) { CPed* pTestedPed = ped->m_nearPeds[i]; - if (!pTestedPed || !IsPedPointerValid(pTestedPed)) + if (!pTestedPed || !IsPedPointerValid(pTestedPed) || pTestedPed->bIsFrozen) continue; if (pTestedPed->m_pedInObjective == ped && pTestedPed->m_objective == OBJECTIVE_FOLLOW_CHAR_IN_FORMATION) { CVector vFollowerPos = pTestedPed->GetFormationPosition(); @@ -1680,7 +1805,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) } } } - else if (pTestedPed->m_leader == ped) { + else if (pTestedPed->m_leader == ped && !pTestedPed->bIsFrozen) { CVector vFollowerPos; if (pTestedPed->m_pedFormation) vFollowerPos = pTestedPed->GetFormationPosition(); @@ -1702,39 +1827,43 @@ int8 CRunningScript::ProcessCommands0To99(int32 command) case COMMAND_IS_PLAYER_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + CPlayerPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); if (!ped->bInVehicle) UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); else UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_PLAYER_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + CPlayerPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); if (ped->bInVehicle) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + */ return 0; } case COMMAND_ADD_INT_VAR_TO_INT_VAR: @@ -1881,33 +2010,25 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr += CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr += CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; -#ifdef FIX_BUGS case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: -#else - case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; -#ifdef FIX_BUGS case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR: -#else - case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -1919,33 +2040,25 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr -= CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_TIMED_VAL_FROM_FLOAT_LVAR: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0]; + *(float*)ptr -= CTimer::GetTimeStep() * GET_FLOAT_PARAM(0); return 0; } case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR: fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; -#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: -#else - case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); return 0; -#ifdef FIX_BUGS case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR: -#else - case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR: -#endif fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); *fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); return 0; @@ -2094,46 +2207,46 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CREATE_CHAR: { CollectParameters(&m_nIp, 5); - switch (ScriptParams[1]) { + switch (GET_INTEGER_PARAM(1)) { case MI_COP: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_STREET; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_STREET); break; case MI_SWAT: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_SWAT; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_SWAT); break; case MI_FBI: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_FBI; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_FBI); break; case MI_ARMY: - if (ScriptParams[0] == PEDTYPE_COP) - ScriptParams[1] = COP_ARMY; + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + SET_INTEGER_PARAM(1, COP_ARMY); break; case MI_MEDIC: - if (ScriptParams[0] == PEDTYPE_EMERGENCY) - ScriptParams[1] = PEDTYPE_EMERGENCY; + if (GET_INTEGER_PARAM(0) == PEDTYPE_EMERGENCY) + SET_INTEGER_PARAM(1, PEDTYPE_EMERGENCY); break; case MI_FIREMAN: - if (ScriptParams[0] == PEDTYPE_FIREMAN) - ScriptParams[1] = PEDTYPE_FIREMAN; + if (GET_INTEGER_PARAM(0) == PEDTYPE_FIREMAN) + SET_INTEGER_PARAM(1, PEDTYPE_FIREMAN); break; default: break; } CPed* ped; - if (ScriptParams[0] == PEDTYPE_COP) - ped = new CCopPed((eCopType)ScriptParams[1]); - else if (ScriptParams[0] == PEDTYPE_EMERGENCY || ScriptParams[0] == PEDTYPE_FIREMAN) - ped = new CEmergencyPed(ScriptParams[1]); + if (GET_INTEGER_PARAM(0) == PEDTYPE_COP) + ped = new CCopPed((eCopType)GET_INTEGER_PARAM(1)); + else if (GET_INTEGER_PARAM(0) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(0) == PEDTYPE_FIREMAN) + ped = new CEmergencyPed(GET_INTEGER_PARAM(1)); else - ped = new CCivilianPed((ePedType)ScriptParams[0], ScriptParams[1]); + ped = new CCivilianPed((ePedType)GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); ped->CharCreatedBy = MISSION_CHAR; ped->bRespondsToThreats = false; ped->bAllowMedicsToReviveMe = false; ped->bIsPlayerFriend = false; - CVector pos = *(CVector*)&ScriptParams[2]; + CVector pos = GET_VECTOR_PARAM(2); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += 1.0f; @@ -2145,29 +2258,29 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) CWorld::Add(ped); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); CPopulation::ms_nTotalMissionPeds++; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(ped)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_DELETE_CHAR: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CTheScripts::RemoveThisPed(ped); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_CHAR_WANDER_DIR: { CollectParameters(&m_nIp, 2); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); ped->ClearAll(); - int8 path = ScriptParams[1]; - if (ScriptParams[1] < 0 || ScriptParams[1] > 7) + int8 path = GET_INTEGER_PARAM(1); + if (GET_INTEGER_PARAM(1) < 0 || GET_INTEGER_PARAM(1) > 7) // Max number GetRandomNumberInRange returns is max-1 #ifdef FIX_BUGS path = CGeneral::GetRandomNumberInRange(0, 8); @@ -2182,19 +2295,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CHAR_FOLLOW_PATH: { CollectParameters(&m_nIp, 6); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); if (ped->GetPedState() == PED_ATTACK || ped->GetPedState() == PED_FIGHT || !ped->IsPedInControl()) return 0; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float radius = *(float*)&ScriptParams[4]; + float radius = GET_FLOAT_PARAM(4); eMoveState state; - switch (ScriptParams[5]) { + switch (GET_INTEGER_PARAM(5)) { case 0: state = PEDMOVE_WALK; break; case 1: state = PEDMOVE_RUN; break; - default: assert(0); + default: state = PEDMOVE_WALK; break; } ped->ClearAll(); ped->m_pathNodeTimer = 0; @@ -2204,7 +2317,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CHAR_SET_IDLE: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); ped->bScriptObjectiveCompleted = false; ped->SetObjective(OBJECTIVE_WAIT_ON_FOOT); @@ -2213,7 +2326,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_GET_CHAR_COORDINATES: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; CVector pos; @@ -2226,21 +2339,21 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) pos = vehicle->GetPosition(); else pos = ped->GetPosition(); - *(CVector*)&ScriptParams[0] = pos; + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_CHAR_COORDINATES: { CollectParameters(&m_nIp, 4); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; else vehicle = nil; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); // removed dumb stuff again @@ -2263,72 +2376,74 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) } return 0; } - /* case COMMAND_IS_CHAR_STILL_ALIVE: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); - UpdateCompareFlag(ped && ped->GetPedState() != PED_DEAD && ped->GetPedState() != PED_DIE); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(ped && !ped->DyingOrDead()); return 0; } - */ case COMMAND_IS_CHAR_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; else vehicle = nil; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); if (vehicle) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CHAR_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* vehicle; if (ped->bInVehicle) vehicle = ped->m_pMyVehicle; else vehicle = nil; - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); if (vehicle) UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); else UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + */ return 0; } case COMMAND_CREATE_CAR: { CollectParameters(&m_nIp, 4); int32 handle; - if (CModelInfo::IsBoatModel(ScriptParams[0])) { - CBoat* boat = new CBoat(ScriptParams[0], MISSION_VEHICLE); - CVector pos = *(CVector*)&ScriptParams[1]; + if (CModelInfo::IsBoatModel(GET_INTEGER_PARAM(0))) { + CBoat* boat = new CBoat(GET_INTEGER_PARAM(0), MISSION_VEHICLE); + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += boat->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -2347,13 +2462,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) else { CVehicle* car; - if (!CModelInfo::IsBikeModel(ScriptParams[0])) - car = new CAutomobile(ScriptParams[0], MISSION_VEHICLE); + if (!CModelInfo::IsBikeModel(GET_INTEGER_PARAM(0))) + car = new CAutomobile(GET_INTEGER_PARAM(0), MISSION_VEHICLE); else { - car = new CBike(ScriptParams[0], MISSION_VEHICLE); + car = new CBike(GET_INTEGER_PARAM(0), MISSION_VEHICLE); ((CBike*)(car))->bIsStanding = true; } - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -2368,15 +2483,18 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f; car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0; car->bEngineOn = false; - car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); + car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); // TODO: gpTheZones car->bHasBeenOwnedByPlayer = true; if (m_bIsMissionScript) car->bIsStaticWaitingForCollision = true; CWorld::Add(car); handle = CPools::GetVehiclePool()->GetIndex(car); } - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); +#ifdef GTA_NETWORK + // TODO(LCS): register car +#endif if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR); return 0; @@ -2384,25 +2502,26 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_DELETE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (car) { CWorld::Remove(car); CWorld::RemoveReferencesToDeletedObject(car); delete car; } if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CAR); return 0; } case COMMAND_CAR_GOTO_COORDINATES: { CollectParameters(&m_nIp, 4); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); + uint8 nOldMission = car->AutoPilot.m_nCarMission; if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, pos, false)) car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT; else @@ -2410,13 +2529,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) car->SetStatus(STATUS_PHYSICS); car->bEngineOn = true; car->AutoPilot.m_nCruiseSpeed = Max(1, car->AutoPilot.m_nCruiseSpeed); - car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + if (nOldMission != car->AutoPilot.m_nCarMission) + car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); return 0; } case COMMAND_CAR_WANDER_RANDOMLY: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); CCarCtrl::JoinCarWithRoadSystem(car); car->AutoPilot.m_nCarMission = MISSION_CRUISE; @@ -2428,7 +2548,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_CAR_SET_IDLE: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); car->AutoPilot.m_nCarMission = MISSION_NONE; return 0; @@ -2436,18 +2556,18 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_GET_CAR_COORDINATES: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - *(CVector*)&ScriptParams[0] = car->GetPosition(); + SET_VECTOR_PARAM(0, car->GetPosition()); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_CAR_COORDINATES: { CollectParameters(&m_nIp, 4); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -2493,73 +2613,77 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) } return 0; } - /* case COMMAND_IS_CAR_STILL_ALIVE: { CollectParameters(&m_nIp, 1); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(car && car->GetStatus() != STATUS_WRECKED && (car->IsBoat() || !car->bIsInWater)); return 0; } - */ case COMMAND_SET_CAR_CRUISE_SPEED: { CollectParameters(&m_nIp, 2); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); + car->AutoPilot.m_nCruiseSpeed = Min(GET_FLOAT_PARAM(1), 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity); return 0; } case COMMAND_SET_CAR_DRIVING_STYLE: { CollectParameters(&m_nIp, 2); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - car->AutoPilot.m_nDrivingStyle = (uint8)ScriptParams[1]; + car->AutoPilot.m_nDrivingStyle = (uint8)GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CAR_MISSION: { CollectParameters(&m_nIp, 2); - CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(car); - car->AutoPilot.m_nCarMission = (uint8)ScriptParams[1]; - car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + if ((uint8)GET_INTEGER_PARAM(1) != car->AutoPilot.m_nCarMission) { + car->AutoPilot.m_nCarMission = (uint8)GET_INTEGER_PARAM(1); + car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + } car->bEngineOn = true; return 0; } case COMMAND_IS_CAR_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(vehicle); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CAR_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(vehicle); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); + */ return 0; } case COMMAND_SPECIAL_0: @@ -2584,56 +2708,54 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) } #endif CollectParameters(&m_nIp, 2); - CMessages::AddBigMessage(key, ScriptParams[0], ScriptParams[1] - 1); + CMessages::AddBigMessage(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1) - 1); return 0; } case COMMAND_PRINT: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessage(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; } case COMMAND_PRINT_NOW: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessageJumpQ(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; } - /* case COMMAND_PRINT_SOON: { wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessageSoon(key, ScriptParams[0], ScriptParams[1]); + CMessages::AddMessageSoon(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; } - */ case COMMAND_CLEAR_PRINTS: CMessages::ClearMessages(); return 0; case COMMAND_GET_TIME_OF_DAY: - ScriptParams[0] = CClock::GetHours(); - ScriptParams[1] = CClock::GetMinutes(); + SET_INTEGER_PARAM(0, CClock::GetHours()); + SET_INTEGER_PARAM(1, CClock::GetMinutes()); StoreParameters(&m_nIp, 2); return 0; case COMMAND_SET_TIME_OF_DAY: CollectParameters(&m_nIp, 2); - CClock::SetGameClock(ScriptParams[0], ScriptParams[1]); + CClock::SetGameClock(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_GET_MINUTES_TO_TIME_OF_DAY: CollectParameters(&m_nIp, 2); - ScriptParams[0] = CClock::GetGameClockMinutesUntil(ScriptParams[0], ScriptParams[1]); + SET_INTEGER_PARAM(0, CClock::GetGameClockMinutesUntil(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_IS_POINT_ON_SCREEN: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= -100) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - UpdateCompareFlag(TheCamera.IsSphereVisible(pos, *(float*)&ScriptParams[3])); + UpdateCompareFlag(TheCamera.IsSphereVisible(pos, GET_FLOAT_PARAM(3))); return 0; } case COMMAND_DEBUG_ON: @@ -2642,14 +2764,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command) case COMMAND_DEBUG_OFF: CTheScripts::DbgFlag = false; return 0; - /* case COMMAND_RETURN_TRUE: UpdateCompareFlag(true); + ReturnFromGosubOrFunction(); return 0; case COMMAND_RETURN_FALSE: UpdateCompareFlag(false); + ReturnFromGosubOrFunction(); return 0; - */ //case COMMAND_VAR_INT: default: script_assert(0); @@ -2676,18 +2798,21 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_WHILE: case COMMAND_WHILENOT: case COMMAND_ENDWHILE: + case COMMAND_214: + case COMMAND_215: + case COMMAND_216: + case COMMAND_217: + case COMMAND_218: */ case COMMAND_ANDOR: CollectParameters(&m_nIp, 1); - m_nAndOrState = ScriptParams[0]; + m_nAndOrState = GET_INTEGER_PARAM(0); if (m_nAndOrState == ANDOR_NONE){ m_bCondResult = false; // pointless }else if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8){ m_bCondResult = true; - m_nAndOrState++; }else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8){ m_bCondResult = false; - m_nAndOrState++; }else{ script_assert(0 && "COMMAND_ANDOR: invalid ANDOR state"); } @@ -2695,7 +2820,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_LAUNCH_MISSION: { CollectParameters(&m_nIp, 1); - CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]); + CRunningScript* pNew = CTheScripts::StartNewScript(GET_INTEGER_PARAM(0)); pNew->m_bIsMissionScript = true; return 0; } @@ -2709,7 +2834,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_STORE_CAR_CHAR_IS_IN: { CollectParameters(&m_nIp, 1); - CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(ped); CVehicle* pCurrent = nil; if (ped->bInVehicle) { @@ -2754,14 +2879,14 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) break; } } - ScriptParams[0] = CTheScripts::StoreVehicleIndex; + SET_INTEGER_PARAM(0, CTheScripts::StoreVehicleIndex); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_STORE_CAR_PLAYER_IS_IN: { CollectParameters(&m_nIp, 1); - CPed* ped = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(ped); if (!ped->bInVehicle) return 0; // No value written to output variable @@ -2805,15 +2930,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) break; } } - ScriptParams[0] = CTheScripts::StoreVehicleIndex; + SET_INTEGER_PARAM(0, CTheScripts::StoreVehicleIndex); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_CHAR_IN_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); CVehicle* pActualVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; UpdateCompareFlag(pActualVehicle && pActualVehicle == pCheckedVehicle); return 0; @@ -2821,51 +2946,51 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_IS_PLAYER_IN_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle == pCheckedVehicle); return 0; } case COMMAND_IS_CHAR_IN_MODEL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CVehicle* pActualVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; - UpdateCompareFlag(pActualVehicle && pActualVehicle->GetModelIndex() == ScriptParams[1]); + UpdateCompareFlag(pActualVehicle && pActualVehicle->GetModelIndex() == GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_PLAYER_IN_MODEL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetModelIndex() == ScriptParams[1]); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetModelIndex() == GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_CHAR_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle); return 0; } case COMMAND_IS_PLAYER_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle); return 0; } case COMMAND_IS_BUTTON_PRESSED: { CollectParameters(&m_nIp, 2); - UpdateCompareFlag(GetPadState(ScriptParams[0], ScriptParams[1]) != 0); + UpdateCompareFlag(GetPadState(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)) != 0); return 0; } /* case COMMAND_GET_PAD_STATE: { CollectParameters(&m_nIp, 1); - ScriptParams[0] = GetPadState(ScriptParams[0], ScriptParams[1]); + SET_INTEGER_PARAM(0, GetPadState(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; } @@ -2925,10 +3050,10 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_CREATE_OBJECT: { CollectParameters(&m_nIp, 4); - int mi = ScriptParams[0] >= 0 ? ScriptParams[0] : CTheScripts::UsedObjectArray[-ScriptParams[0]].index; + int mi = GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(0)].index; CObject* pObj = new CObject(mi, false); pObj->ObjectCreatedBy = MISSION_OBJECT; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += pObj->GetDistanceFromCentreOfMassToBaseOfModel(); @@ -2936,73 +3061,74 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pObj->SetOrientation(0.0f, 0.0f, 0.0f); pObj->GetMatrix().UpdateRW(); pObj->UpdateRwFrame(); - CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(mi); - if (pModelInfo->IsBuilding() && ((CSimpleModelInfo*)pModelInfo)->m_isBigBuilding) - pObj->SetupBigBuilding(); CTheScripts::ClearSpaceForMissionEntity(pos, pObj); CWorld::Add(pObj); - ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObj); + SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pObj)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } case COMMAND_DELETE_OBJECT: { CollectParameters(&m_nIp, 1); - CObject* pObj = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + if (GET_INTEGER_PARAM(0) > (NUMOBJECTS + 2) << 8) + return 0; + CObject* pObj = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); if (pObj){ CWorld::Remove(pObj); CWorld::RemoveReferencesToDeletedObject(pObj); delete pObj; } if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } case COMMAND_ADD_SCORE: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_nMoney += ScriptParams[1]; - if (CWorld::Players[ScriptParams[0]].m_nMoney < 0) - CWorld::Players[ScriptParams[0]].m_nMoney = 0; + CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney += GET_INTEGER_PARAM(1); + if (CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney < 0) + CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney = 0; return 0; case COMMAND_IS_SCORE_GREATER: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_nMoney > ScriptParams[1]); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney > GET_INTEGER_PARAM(1)); return 0; case COMMAND_STORE_SCORE: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CWorld::Players[ScriptParams[0]].m_nMoney; + SET_INTEGER_PARAM(0, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney); StoreParameters(&m_nIp, 1); return 0; case COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(*(float*)&ScriptParams[4]), MI_RCBANDIT); + CVehicle* pVehicle = CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), MI_RCBANDIT); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); + StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ALTER_WANTED_LEVEL: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevel(ScriptParams[1]); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevel(GET_INTEGER_PARAM(1)); return 0; case COMMAND_ALTER_WANTED_LEVEL_NO_DROP: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevelNoDrop(ScriptParams[1]); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevelNoDrop(GET_INTEGER_PARAM(1)); return 0; case COMMAND_IS_WANTED_LEVEL_GREATER: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->m_pWanted->GetWantedLevel() > ScriptParams[1]); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pWanted->GetWantedLevel() > GET_INTEGER_PARAM(1)); return 0; case COMMAND_CLEAR_WANTED_LEVEL: CollectParameters(&m_nIp, 1); - CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevel(0); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevel(0); return 0; case COMMAND_SET_DEATHARREST_STATE: CollectParameters(&m_nIp, 1); - m_bDeatharrestEnabled = (ScriptParams[0] == 1); + m_bDeatharrestEnabled = (GET_INTEGER_PARAM(0) == 1); return 0; case COMMAND_HAS_DEATHARREST_BEEN_EXECUTED: UpdateCompareFlag(m_bDeatharrestExecuted); @@ -3011,51 +3137,54 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_ADD_AMMO_TO_PLAYER: { CollectParameters(&m_nIp, 3); - CWorld::Players[ScriptParams[0]].m_pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); + CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GrantAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } */ case COMMAND_ADD_AMMO_TO_CHAR: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); + pPed->GrantAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } //case COMMAND_ADD_AMMO_TO_CAR: - //case COMMAND_IS_PLAYER_STILL_ALIVE: + case COMMAND_IS_PLAYER_STILL_ALIVE: + CollectParameters(&m_nIp, 1); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState != WBSTATE_WASTED); + return 0; case COMMAND_IS_PLAYER_DEAD: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_WASTED); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState == WBSTATE_WASTED); return 0; case COMMAND_IS_CHAR_DEAD: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - UpdateCompareFlag(!pPed || pPed->DyingOrDead()); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(!pPed || pPed->DyingOrDead() || pPed->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE); return 0; } case COMMAND_IS_CAR_DEAD: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(!pVehicle || pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->bIsDrowning); return 0; } case COMMAND_SET_CHAR_THREAT_SEARCH: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_fearFlags |= ScriptParams[1]; + pPed->m_fearFlags |= GET_INTEGER_PARAM(1); return 0; } //case COMMAND_SET_CHAR_THREAT_REACTION: case COMMAND_SET_CHAR_OBJ_NO_OBJ: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->ClearObjective(); @@ -3068,7 +3197,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_IS_PLAYER_IN_ZONE: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; char label[12]; CTheScripts::ReadTextLabelFromScript(&m_nIp, label); int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT); @@ -3081,15 +3210,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) } case COMMAND_IS_PLAYER_PRESSING_HORN: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->GetPedState() == PED_DRIVING && - CPad::GetPad(ScriptParams[0])->GetHorn()); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GetPedState() == PED_DRIVING && + CPad::GetPad(GET_INTEGER_PARAM(0))->GetHorn()); return 0; case COMMAND_HAS_CHAR_SPOTTED_PLAYER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[ScriptParams[1]].m_pPed)); + UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed)); return 0; } #ifdef SUPPORT_GINPUT_SCRIPT @@ -3103,7 +3232,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_IS_CHAR_OBJECTIVE_PASSED: { 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->bScriptObjectiveCompleted); return 0; @@ -3115,43 +3244,43 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) case COMMAND_CREATE_CHAR_INSIDE_CAR: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - switch (ScriptParams[2]) { + switch (GET_INTEGER_PARAM(2)) { case MI_COP: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_STREET; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_STREET); break; case MI_SWAT: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_SWAT; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_SWAT); break; case MI_FBI: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_FBI; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_FBI); break; case MI_ARMY: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_ARMY; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_ARMY); break; case MI_MEDIC: - if (ScriptParams[1] == PEDTYPE_EMERGENCY) - ScriptParams[2] = PEDTYPE_EMERGENCY; + if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY) + SET_INTEGER_PARAM(2, PEDTYPE_EMERGENCY); break; case MI_FIREMAN: - if (ScriptParams[1] == PEDTYPE_FIREMAN) - ScriptParams[2] = PEDTYPE_FIREMAN; + if (GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN) + SET_INTEGER_PARAM(2, PEDTYPE_FIREMAN); break; default: break; } CPed* pPed; - if (ScriptParams[1] == PEDTYPE_COP) - pPed = new CCopPed((eCopType)ScriptParams[2]); - else if (ScriptParams[1] == PEDTYPE_EMERGENCY || ScriptParams[1] == PEDTYPE_FIREMAN) - pPed = new CEmergencyPed(ScriptParams[2]); + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + pPed = new CCopPed((eCopType)GET_INTEGER_PARAM(2)); + else if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN) + pPed = new CEmergencyPed(GET_INTEGER_PARAM(2)); else - pPed = new CCivilianPed((ePedType)ScriptParams[1], ScriptParams[2]); + pPed = new CCivilianPed((ePedType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; pPed->bAllowMedicsToReviveMe = false; @@ -3161,7 +3290,6 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pPed->SetPosition(pVehicle->GetPosition()); pPed->SetOrientation(0.0f, 0.0f, 0.0f); pPed->SetPedState(PED_DRIVING); - CPopulation::ms_nTotalMissionPeds++; script_assert(!pVehicle->pDriver); pVehicle->pDriver = pPed; pVehicle->pDriver->RegisterReference((CEntity**)&pVehicle->pDriver); @@ -3176,17 +3304,18 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pPed->AddInCarAnims(pVehicle, true); pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); CWorld::Add(pPed); - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + CPopulation::ms_nTotalMissionPeds++; + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_WARP_PLAYER_FROM_CAR_TO_COORD: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[1]; - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; + CVector pos = GET_VECTOR_PARAM(1); + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); if (pPlayer->m_pPed->bInVehicle){ @@ -3229,6 +3358,24 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) return -1; } +void CRunningScript::ReturnFromGosubOrFunction() +{ + uint32 val = m_nIp = m_anStack[--m_nStackPointer]; + if (!(m_nIp & BIT(STACKVALUE_IS_FUNCTION_CALL_BIT))) + return; + if (m_nIp & BIT(STACKVALUE_INVERT_RETURN_BIT)) + m_bCondResult = !m_bCondResult; + m_nIp = m_nIp & STACKVALUE_IP_MASK; + uint8 nInputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + uint8 nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + uint8 nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp); + for (int i = 0; i < nOutputParameters; i++) + ScriptParams[i] = m_anLocalVariables[m_nLocalsPointer + nInputParameters + i]; + m_nIp += val >> STACKVALUE_IP_PARAMS_OFFSET; + m_nLocalsPointer -= nLocalsOffset; + StoreParameters(&m_nIp, nOutputParameters); +} + #ifdef MISSION_REPLAY bool CRunningScript::CanAllowMissionReplay() diff --git a/src/control/Script.h b/src/control/Script.h index 7f9a7717..d9a109fd 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -1,7 +1,9 @@ #pragma once -#include "Font.h" +#include "Font.h" +#include "Ped.h" #include "PedType.h" #include "Text.h" +#include "sList.h" #include "Sprite2d.h" class CEntity; @@ -17,7 +19,7 @@ class CRunningScript; extern int32 ScriptParams[32]; void FlushLog(); -#define script_assert(_Expression) FlushLog(); assert(_Expression); +#define script_assert(_Expression) { FlushLog(); assert(_Expression); } #define PICKUP_PLACEMENT_OFFSET (0.5f) #define PED_FIND_Z_OFFSET (5.0f) @@ -28,9 +30,9 @@ void FlushLog(); #define UPSIDEDOWN_TURN_SPEED_THRESHOLD (0.02f) #define UPSIDEDOWN_TIMER_THRESHOLD (1000) -#define SPHERE_MARKER_R (252) -#define SPHERE_MARKER_G (138) -#define SPHERE_MARKER_B (242) +#define SPHERE_MARKER_R (255) +#define SPHERE_MARKER_G (255) +#define SPHERE_MARKER_B (128) #define SPHERE_MARKER_A (228) #define SPHERE_MARKER_PULSE_PERIOD 2048 #define SPHERE_MARKER_PULSE_FRACTION 0.1f @@ -48,6 +50,15 @@ void FlushLog(); #define KEY_LENGTH_IN_SCRIPT (8) //#define GTA_SCRIPT_COLLECTIVE +#define GET_INTEGER_PARAM(i) (ScriptParams[i]) +#define GET_FLOAT_PARAM(i) (*(float*)&ScriptParams[i]) +#define GET_VECTOR_PARAM(i) (CVector(GET_FLOAT_PARAM(i), GET_FLOAT_PARAM(i+1), GET_FLOAT_PARAM(i+2))) + +#define SET_INTEGER_PARAM(i, x) ScriptParams[i] = x +#define SET_FLOAT_PARAM(i, x) *(float*)&ScriptParams[i] = x +#define SET_VECTOR_PARAM(i, v) { *(float*)&ScriptParams[i] = (v).x; *(float*)&ScriptParams[i+1] = (v).y; *(float*)&ScriptParams[i+2] = (v).z; } + +#define GTA_SCRIPT_COLLECTIVE struct intro_script_rectangle { @@ -215,15 +226,33 @@ public: }; enum { + MAX_STACK_DEPTH = 16, + NUM_LOCAL_VARS = 96, + NUM_TIMERS = 2, + NUM_GLOBAL_SLOTS = 26 +}; + +enum { ARGUMENT_END = 0, + ARGUMENT_INT_ZERO, + ARGUMENT_FLOAT_ZERO, + ARGUMENT_FLOAT_1BYTE, + ARGUMENT_FLOAT_2BYTES, + ARGUMENT_FLOAT_3BYTES, ARGUMENT_INT32, - ARGUMENT_GLOBALVAR, - ARGUMENT_LOCALVAR, ARGUMENT_INT8, ARGUMENT_INT16, - ARGUMENT_FLOAT + ARGUMENT_FLOAT, + ARGUMENT_TIMER, + ARGUMENT_LOCAL = ARGUMENT_TIMER + NUM_TIMERS, + ARGUMENT_LOCAL_ARRAY = ARGUMENT_LOCAL + NUM_LOCAL_VARS, + ARGUMENT_GLOBAL = ARGUMENT_LOCAL_ARRAY + NUM_LOCAL_VARS, + ARGUMENT_GLOBAL_ARRAY = ARGUMENT_GLOBAL + NUM_GLOBAL_SLOTS, + MAX_ARGUMENT = ARGUMENT_GLOBAL_ARRAY + NUM_GLOBAL_SLOTS }; +static_assert(MAX_ARGUMENT <= 256, "MAX_ARGUMENT must be less or equal to 256"); + struct tCollectiveData { int32 colIndex; @@ -247,11 +276,18 @@ struct tBuildingSwap int32 m_nOldModel; }; - -enum { - MAX_STACK_DEPTH = 6, - NUM_LOCAL_VARS = 16, - NUM_TIMERS = 2 +struct script_corona +{ + int id; + float x; + float y; + float z; + float size; + uint8 r; + uint8 g; + uint8 b; + int type; + int flareType; }; class CRunningScript @@ -276,14 +312,25 @@ class CRunningScript ORS_8 }; + enum { + STACKVALUE_IP_BITS = 22, + STACKVALUE_INVERT_RETURN_BIT = STACKVALUE_IP_BITS, + STACKVALUE_IS_FUNCTION_CALL_BIT, + STACKVALUE_IP_PARAMS_OFFSET, + + STACKVALUE_IP_MASK = ((1 << STACKVALUE_IP_BITS) - 1) + }; + public: CRunningScript* next; CRunningScript* prev; + int32 m_nId; char m_abScriptName[8]; uint32 m_nIp; uint32 m_anStack[MAX_STACK_DEPTH]; uint16 m_nStackPointer; - int32 m_anLocalVariables[NUM_LOCAL_VARS + NUM_TIMERS]; + int32 m_anLocalVariables[NUM_LOCAL_VARS + 8 + NUM_TIMERS]; // TODO(LCS): figure out why 106 + int32 m_nLocalsPointer; bool m_bIsActive; bool m_bCondResult; bool m_bIsMissionScript; @@ -303,8 +350,8 @@ public: void Load(uint8*& buf); void UpdateTimers(float timeStep) { - m_anLocalVariables[NUM_LOCAL_VARS] += timeStep; - m_anLocalVariables[NUM_LOCAL_VARS + 1] += timeStep; + for (int i = 0; i < NUM_TIMERS; i++) + m_anLocalVariables[NUM_LOCAL_VARS + 8 + i] += timeStep; } void Init(); @@ -315,14 +362,37 @@ public: static const uint32 nSaveStructSize; - void CollectParameters(uint32*, int16); + void CollectParameters(uint32*, int16, int* pParams = (int*)&ScriptParams); int32 CollectNextParameterWithoutIncreasingPC(uint32); int32* GetPointerToScriptVariable(uint32*, int16); void StoreParameters(uint32*, int16); int8 ProcessOneCommand(); void DoDeatharrestCheck(); - void UpdateCompareFlag(bool); + void UpdateCompareFlag(bool flag) + { + if (m_bNotFlag) + flag = !flag; + if (m_nAndOrState == ANDOR_NONE) { + m_bCondResult = flag; + return; + } + if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { + m_bCondResult &= flag; + if (m_nAndOrState == ANDS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + else { + m_bCondResult |= flag; + if (m_nAndOrState <= ORS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + m_nAndOrState--; + } int16 GetPadState(uint16, uint16); int8 ProcessCommands0To99(int32); @@ -340,7 +410,10 @@ public: int8 ProcessCommands1200To1299(int32); int8 ProcessCommands1300To1399(int32); int8 ProcessCommands1400To1499(int32); + int8 ProcessCommands1500To1599(int32); + int8 ProcessCommands1600To1699(int32); + uint32 CollectLocateParameters(uint32*, bool); void LocatePlayerCommand(int32, uint32*); void LocatePlayerCharCommand(int32, uint32*); void LocatePlayerCarCommand(int32, uint32*); @@ -385,9 +458,10 @@ public: bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami); bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal); + bool CheckDamagedWeaponType(int32 actual, int32 type); + + void ReturnFromGosubOrFunction(); - bool CheckDamagedWeaponType(int32 actual, int32 type); - }; @@ -397,37 +471,30 @@ enum { }; enum { -#ifdef PS2 - SIZE_MAIN_SCRIPT = 205512, -#else - SIZE_MAIN_SCRIPT = 225512, -#endif - SIZE_MISSION_SCRIPT = 35000, - SIZE_SCRIPT_SPACE = SIZE_MAIN_SCRIPT + SIZE_MISSION_SCRIPT -}; - -enum { MAX_NUM_SCRIPTS = 128, MAX_NUM_INTRO_TEXT_LINES = 48, MAX_NUM_INTRO_RECTANGLES = 16, MAX_NUM_SCRIPT_SRPITES = 16, MAX_NUM_SCRIPT_SPHERES = 16, - MAX_NUM_USED_OBJECTS = 220, - MAX_NUM_MISSION_SCRIPTS = 120, - MAX_NUM_BUILDING_SWAPS = 25, - MAX_NUM_INVISIBILITY_SETTINGS = 20, - MAX_NUM_STORED_LINES = 1024 + MAX_NUM_COLLECTIVES = 32, + MAX_NUM_USED_OBJECTS = 305, + MAX_NUM_MISSION_SCRIPTS = 150, + MAX_NUM_BUILDING_SWAPS = 80, + MAX_NUM_INVISIBILITY_SETTINGS = 52, + MAX_NUM_STORED_LINES = 1024, + MAX_ALLOWED_COLLISIONS = 2 }; class CTheScripts { public: - static uint8 ScriptSpace[SIZE_SCRIPT_SPACE]; + static uint8* ScriptSpace; static CRunningScript ScriptsArray[MAX_NUM_SCRIPTS]; static intro_text_line IntroTextLines[MAX_NUM_INTRO_TEXT_LINES]; static intro_script_rectangle IntroRectangles[MAX_NUM_INTRO_RECTANGLES]; static CSprite2d ScriptSprites[MAX_NUM_SCRIPT_SRPITES]; static script_sphere_struct ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES]; + static tCollectiveData CollectiveArray[MAX_NUM_COLLECTIVES]; static tUsedObject UsedObjectArray[MAX_NUM_USED_OBJECTS]; static int32 MultiScriptArray[MAX_NUM_MISSION_SCRIPTS]; static tBuildingSwap BuildingSwapArray[MAX_NUM_BUILDING_SWAPS]; @@ -459,20 +526,24 @@ public: static uint16 ScriptsUpdated; static uint32 LastMissionPassedTime; static uint16 NumberOfExclusiveMissionScripts; -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) -#define CARDS_IN_SUIT (13) -#define NUM_SUITS (4) -#define MAX_DECKS (6) -#define CARDS_IN_DECK (CARDS_IN_SUIT * NUM_SUITS) -#define CARDS_IN_STACK (CARDS_IN_DECK * MAX_DECKS) - static int16 CardStack[CARDS_IN_STACK]; - static int16 CardStackPosition; -#endif + static bool bPlayerIsInTheStatium; static uint8 RiotIntensity; static bool bPlayerHasMetDebbieHarry; - static void Init(); + static int AllowedCollision[MAX_ALLOWED_COLLISIONS]; + static uint16* SavedVarIndices; + static int NumSaveVars; + static int FSDestroyedFlag; + static int NextProcessId; + static bool InTheScripts; + static CRunningScript* pCurrent; + static uint16 NumTrueGlobals; + static uint16 MostGlobals; + static base::cSList<script_corona> mCoronas; + static int NextScriptCoronaID; + + static bool Init(bool loaddata = false); static void Process(); static CRunningScript* StartTestScript(); @@ -482,11 +553,13 @@ public: static void UndoBuildingSwaps(); static void UndoEntityInvisibilitySettings(); + /* static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, uint32 col, uint32 col2); static void RenderTheScriptDebugLines(); + */ static void SaveAllScripts(uint8*, uint32*); - static void LoadAllScripts(uint8*, uint32); + static bool LoadAllScripts(uint8*, uint32); static bool IsDebugOn() { return DbgFlag; }; static void InvertDebugFlag() { DbgFlag = !DbgFlag; } @@ -542,10 +615,12 @@ public: static void DrawScriptSpheres(); static void HighlightImportantArea(uint32, float, float, float, float, float); static void HighlightImportantAngledArea(uint32, float, float, float, float, float, float, float, float, float); + /* static void DrawDebugSquare(float, float, float, float); static void DrawDebugAngledSquare(float, float, float, float, float, float, float, float); static void DrawDebugCube(float, float, float, float, float, float); static void DrawDebugAngledCube(float, float, float, float, float, float, float, float, float, float); + */ static void AddToInvisibilitySwapArray(CEntity*, bool); static void AddToBuildingSwapArray(CBuilding*, int32, int32); @@ -554,7 +629,7 @@ public: static int32 AddScriptSphere(int32 id, CVector pos, float radius); static int32 GetNewUniqueScriptSphereIndex(int32 index); static void RemoveScriptSphere(int32 index); - static void RemoveScriptTextureDictionary(); + //static void RemoveScriptTextureDictionary(); public: static void RemoveThisPed(CPed* pPed); @@ -563,6 +638,10 @@ public: static void SwitchToMission(int32 mission); #endif + static int GetSaveVarIndex(int); + static void Shutdown(void); + static void SwapNearestBuildingModel(float, float, float, float, int, int); + #ifdef GTA_SCRIPT_COLLECTIVE static void AdvanceCollectiveIndex() { @@ -585,9 +664,11 @@ public: #ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT static bool MissionSupportsMissionReplay(int index) { - return index >= 3 && index <= 35 || index >= 51 && index <= 65 || index >= 67 && index <= 74 || index >= 83 && index <= 87; + return (index >= 48 && index <= 61) || (index >= 63 && index <= 117); } #endif + static bool IsFortStauntonDestroyed() { return FSDestroyedFlag && *(int32*)&ScriptSpace[FSDestroyedFlag] == 1; } + #ifdef USE_DEBUG_SCRIPT_LOADER static int ScriptToLoad; @@ -601,6 +682,10 @@ public: #endif }; +extern int ScriptParams[32]; + +VALIDATE_SIZE(uStackReturnValue, 4); + #ifdef MISSION_REPLAY extern int AllowMissionReplay; extern uint32 WaitForMissionActivate; @@ -613,7 +698,6 @@ extern int IsInAmmunation; extern int MissionSkipLevel; #ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT -extern bool UsingMobileScript; extern bool AlreadySavedGame; #endif @@ -637,3 +721,7 @@ enum { MISSION_RETRY_STAGE_WAIT_FOR_TIMER_AFTER_RESTART, }; #endif + +extern int gScriptsFile; +extern CVector gVectorSetInLua; + diff --git a/src/control/Script10.cpp b/src/control/Script10.cpp new file mode 100644 index 00000000..ed1a9264 --- /dev/null +++ b/src/control/Script10.cpp @@ -0,0 +1,426 @@ +#include "common.h" + +#include "Script.h" +#include "ScriptCommands.h" + +#include "CarCtrl.h" +#include "DMAudio.h" +#include "Frontend.h" +#include "GameLogic.h" +#include "Garages.h" +#include "General.h" +#include "Hud.h" +#include "Messages.h" +#include "Object.h" +#include "Pad.h" +#include "Pickups.h" +#include "PlayerPed.h" +#include "Pools.h" +#include "Vehicle.h" +#include "SpecialFX.h" +#include "Stats.h" +#include "User.h" +#include "Weather.h" +#include "World.h" + +bool gDeveloperFlag; + +int8 CRunningScript::ProcessCommands1600To1699(int32 command) +{ + switch (command) { + case COMMAND_ADD_NOODLES_DELIVERED: + CollectParameters(&m_nIp, 1); + // CStats::NoodlesDelievered += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_REGISTER_SCRAPYARD_CHALLENGE_SCORE: + CollectParameters(&m_nIp, 1); + //CStats::TopScrapyardChallengeScore = Max(CStats::TopScrapyardChallengeScore, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_9MM_MAYHEM_SCORE: + CollectParameters(&m_nIp, 1); + //CStats::Top9mmMayhemScore = Max(CStats::Top9mmMayhemScore, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_SCOOTER_SHOOTER_SCORE: + CollectParameters(&m_nIp, 1); + //CStats::TopScooterShooterScore = Max(CStats::TopScooterShooterScore, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_ADD_MONEY_MADE_FROM_TOURIST: + CollectParameters(&m_nIp, 1); + // CStats::MoneyMadeFromTourist += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_ADD_TOURISTS_TAKEN_TO_SPOTS: + CollectParameters(&m_nIp, 1); + // CStats::TouristsTakenToSpots += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_ADD_EXPORTED_CARS: + CollectParameters(&m_nIp, 1); + // CStats::NumberOfExportedCars += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_SET_TOTAL_EXPORT_CARS: + CollectParameters(&m_nIp, 1); + // CStats::TotalNumberOfCarExport = GET_INTEGER_PARAM(0); + return 0; + case COMMAND_REGISTER_DIRT_BIKE_FASTEST_LAP: + CollectParameters(&m_nIp, 2); + // CStats::RegisterDirtBikeFastestLap(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_REGISTER_DIRT_BIKE_FASTEST_TIME: + CollectParameters(&m_nIp, 2); + // CStats::RegisterDirtBikeFastestTime(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_REGISTER_DIRT_BIKE_AIR_TIME: + CollectParameters(&m_nIp, 1); + //CStats::DirtBikeMostAir = Max(CStats::DirtBikeMostAir, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_ADD_ARROW_3D_MARKER: + { + uint32 ip = m_nIp; + uint32 id = (uint32)(uintptr)GetPointerToScriptVariable(&ip, 0); + CollectParameters(&m_nIp, 10); + CVector pos = GET_VECTOR_PARAM(0); + CVector dir = GET_VECTOR_PARAM(3); + pos.z += GET_FLOAT_PARAM(9) + 7.0f; + //C3dMarkers::PlaceMarker(id, MARKERTYPE_ARROW, pos, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8), 200, 1, 3.2f, 1, dir, 1.0f, 0, 0); - TODO + return 0; + } + case COMMAND_PRINT_NOW_OVERRIDE_FADE: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); // true, true + return 0; + } + case COMMAND_GET_PICKUP_VALUE: + { + CollectParameters(&m_nIp, 1); + SET_INTEGER_PARAM(0, CPickups::GetValue(GET_INTEGER_PARAM(0))); + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_SET_PICKUP_VALUE: + { + CollectParameters(&m_nIp, 2); + CPickups::SetValue(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + } + case COMMAND_IS_DEVELOPER: +#ifdef GTA_NETWORK + UpdateCompareFlag(gDeveloperFlag || gIsMultiplayerGame); +#else + UpdateCompareFlag(gDeveloperFlag); +#endif + return 0; + case COMMAND_SET_DEVELOPER_FLAG: + CollectParameters(&m_nIp, 1); + gDeveloperFlag = GET_INTEGER_PARAM(0); + return 0; + case COMMAND_REGISTER_WICHITA_WIPEOUT_SCORE: + CollectParameters(&m_nIp, 1); + //CStats::TopWichitaWipeoutScore = Max(CStats::TopWichitaWipeoutScore, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_ATTACH_OBJECT_TO_CAR: + { + CollectParameters(&m_nIp, 5); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + script_assert(pVehicle); + CVector offset = GET_VECTOR_PARAM(2); + // pObject->AttachObjectToEntity(pVehicle, offset); + return 0; + } + case COMMAND_DETACH_OBJECT_FROM_CAR: + { + CollectParameters(&m_nIp, 1); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + // if (pObject && pObject->m_pAttachedTo) + // pObject->DettachObjectFromEntity(); + return 0; + } + case COMMAND_SET_PAD_STICKS_MULTIPLIER: + { + CollectParameters(&m_nIp, 2); + CPad::GetPad(0)->unk_B4 = GET_FLOAT_PARAM(0); + CPad::GetPad(0)->unk_B8 = GET_FLOAT_PARAM(1); + return 0; + } + case COMMAND_PRINT_SUBTITLE_NOW: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + if (FrontEndMenuManager.m_PrefsShowSubtitles) + CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); // false, true + else + CMessages::AddToPreviousBriefArray(key, -1, -1, -1, -1, -1, -1, nil); + return 0; + } + case COMMAND_PRINT_SUBTITLE_NOW_OVERRIDE_FADE: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + if (FrontEndMenuManager.m_PrefsShowSubtitles) + CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); // true, true + else + CMessages::AddToPreviousBriefArray(key, -1, -1, -1, -1, -1, -1, nil); + return 0; + } + case COMMAND_PRINT_SUBTITLE_NOW_NO_BRIEF: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + if (FrontEndMenuManager.m_PrefsShowSubtitles) + CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); // false, false + else + CMessages::AddToPreviousBriefArray(key, -1, -1, -1, -1, -1, -1, nil); + return 0; + } + case COMMAND_PRINT_WITH_NUMBER_NOW_NO_BRIEF: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 3); + CMessages::AddMessageJumpQWithNumber(key, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1); // 0 + return 0; + } + case COMMAND_GET_ANGLE_BETWEEN_POINTS: + { + CollectParameters(&m_nIp, 4); + SET_FLOAT_PARAM(0, CGeneral::GetAngleBetweenPoints(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(3))); + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_OVERRIDE_CHAR_MOVE_ANIM: + { + CollectParameters(&m_nIp, 1); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bOverrideMoveAnim = true; + return 0; + } + case COMMAND_1627: + { + CollectParameters(&m_nIp, 1); + // something related to debug menu, not implemented + return 0; + } + case COMMAND_ENABLE_EMERGENCY_VEHICLES: + { + CollectParameters(&m_nIp, 1); + gbEmergencyVehiclesEnabled = GET_INTEGER_PARAM(0) != 0; + return 0; + } + case COMMAND_ADD_UNLOCKED_COSTUME: + CollectParameters(&m_nIp, 1); + // CStats::AddUnlockedCostume(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_CLEAR_MULTIPLAYER_SPLASH_SCREEN: + // ClearMultiplayerSplashScreen(); + return 0; + case COMMAND_PRINT_WITH_2_NUMBERS_NOW_NO_BRIEF: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 4); + CMessages::AddMessageJumpQWithNumber(key, GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1); // 0 + return 0; + } + case COMMAND_GET_OBJECT_ORIENTATION: + { + CollectParameters(&m_nIp, 1); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + SET_FLOAT_PARAM(1, LimitAngleOnCircle(RADTODEG(Asin(pObject->GetForward().z)))); + SET_FLOAT_PARAM(2, LimitAngleOnCircle(RADTODEG(Atan2(-pObject->GetForward().x, pObject->GetForward().y)))); + SET_FLOAT_PARAM(0, LimitAngleOnCircle(RADTODEG(Atan2(-pObject->GetRight().z, pObject->GetUp().z)))); + StoreParameters(&m_nIp, 3); + return 0; + } + case COMMAND_SET_OBJECT_ORIENTATION: + { + CollectParameters(&m_nIp, 4); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + pObject->SetOrientation(DEGTORAD(GET_FLOAT_PARAM(2)), DEGTORAD(GET_FLOAT_PARAM(1)), DEGTORAD(GET_FLOAT_PARAM(3))); + return 0; + } + case COMMAND_CHANGE_ONSCREEN_COUNTER_PREFIX: + { + uint16 offset = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; + CollectParameters(&m_nIp, 1); + CUserDisplay::OnscnTimer.ChangeCounterPrefix(offset, GET_INTEGER_PARAM(0) != 0); + return 0; + } + case COMMAND_STORE_PLAYER_OUTFIT: + { + char tmp[12]; // TODO + CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); + for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) + CGameLogic::mStoredPlayerOutfit[i] = tmp[i]; + printf("STORED PLAYOUR OUTFIT : %s\n", CGameLogic::mStoredPlayerOutfit); + m_nIp += KEY_LENGTH_IN_SCRIPT; + return 0; + } + case COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_STRING: + { + char onscreen_str1[12]; + uint16 var = (uint8*)GetPointerToScriptVariable(&m_nIp, 0) - CTheScripts::ScriptSpace; + CollectParameters(&m_nIp, 2); + wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + strncpy(onscreen_str1, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); + m_nIp += KEY_LENGTH_IN_SCRIPT; + CUserDisplay::OnscnTimer.AddCounter(var, GET_INTEGER_PARAM(1), onscreen_str1, 0, GET_INTEGER_PARAM(0), nil, 0); + return 0; + } + case COMMAND_SET_PLAYER_CURRENT_WEAPON_AMMO_IN_CLIP: + { + CollectParameters(&m_nIp, 1); + CWeapon* pWeapon = FindPlayerPed()->GetWeapon(); + if (pWeapon && GET_INTEGER_PARAM(0)) + pWeapon->m_nAmmoInClip = GET_INTEGER_PARAM(0); + return 0; + } + case COMMAND_SET_CHAR_WAIT_STATE_REPEAT: + { + CollectParameters(&m_nIp, 3); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (pPed) + pPed->SetWaitState((eWaitState)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2) >= 0 ? &GET_INTEGER_PARAM(2) : nil, true); + return 0; + } + case COMMAND_REGISTER_BEST_TIME_GOGO_FAGGIO: + CollectParameters(&m_nIp, 1); + // CStats::RegisterBestTimeGoGoFaggio(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_LOCK_GARAGE: + CollectParameters(&m_nIp, 2); + CGarages::LockGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_IS_FINAL_GAME: +#ifdef FINAL + UpdateCompareFlag(true); +#else + UpdateCompareFlag(false); +#endif + return 0; + case COMMAND_SET_ALLOWED_COLLISION: + { + CollectParameters(&m_nIp, 2); + CTheScripts::AllowedCollision[0] = GET_INTEGER_PARAM(0); + CTheScripts::AllowedCollision[1] = GET_INTEGER_PARAM(1); + return 0; + } + case COMMAND_REGISTER_GUARDIAN_ANGEL_LEVEL: + CollectParameters(&m_nIp, 3); + //CStats::GuardianAngelHighestLevel_Ind = Max(CStats::GuardianAngelHighestLevel_Ind, GET_INTEGER_PARAM(0)); + //CStats::GuardianAngelHighestLevel_Com = Max(CStats::GuardianAngelHighestLevel_Com, GET_INTEGER_PARAM(1)); + //CStats::GuardianAngelHighestLevel_Sub = Max(CStats::GuardianAngelHighestLevel_Sub, GET_INTEGER_PARAM(2)); + return 0; + case COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_2_STRINGS: + { + char onscreen_str1[12]; + char onscreen_str2[12]; + uint16 var = (uint8*)GetPointerToScriptVariable(&m_nIp, 0) - CTheScripts::ScriptSpace; + CollectParameters(&m_nIp, 3); + wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + strncpy(onscreen_str1, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); + m_nIp += KEY_LENGTH_IN_SCRIPT; + wchar* text2 = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); + strncpy(onscreen_str2, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); + m_nIp += KEY_LENGTH_IN_SCRIPT; + CUserDisplay::OnscnTimer.AddCounter(var, GET_INTEGER_PARAM(1), onscreen_str2, 0, GET_INTEGER_PARAM(0), onscreen_str1, GET_INTEGER_PARAM(2)); + return 0; + } + case COMMAND_GET_PLAYER_STORED_WEAPON: + { + CollectParameters(&m_nIp, 1); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + script_assert(pPed); + SET_INTEGER_PARAM(0, pPed->m_storedWeapon); + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_DISABLE_PAUSE_MENU: + CollectParameters(&m_nIp, 1); + // FrontEndMenuManager.mDisablePauseMenu = GET_INTEGER_PARAM(0) != 0; // TODO: static + member + return 0; + case COMMAND_IS_CHANNEL_PLAYING: + CollectParameters(&m_nIp, 1); + //UpdateCompareFlag(DMAudio.IsChannelPlaying(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(false); + return 0; + case COMMAND_SET_CLOCK_EVENT_WARNING: + CollectParameters(&m_nIp, 3); + /* + if (CHud::m_ClockEventWarningMinutes || GET_INTEGER_PARAMS(2)){ + CHud::m_ClockEventWarningMinutes = GET_INTEGER_PARAMS(2); + CHud::m_ClockEventMinutes = GET_INTEGER_PARAMS(1); + CHud::m_ClockEventHours = GET_INTEGER_PARAMS(0); + CHud::m_ClockEventFlashTimer = 0; + } + */ + return 0; + case COMMAND_SET_EXTRA_COLOUR_LIGHT_DIRECTION: + CollectParameters(&m_nIp, 3); + // CWeather::ExtraColourLightDir = GET_VECTOR_PARAM(0); + // CWeather::ExtraColourLightDir.Normalise(); + return 0; + case COMMAND_SET_CHAR_CAN_BE_TARGETTED_BY_LEADER: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bCanBeTargettedByLeader = GET_INTEGER_PARAM(1) != 0; + return 0; + } + case COMMAND_PRINT_HELP_NO_BRIEF: + { + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CHud::SetHelpMessage(text, false); // + false, false + return 0; + } + case COMMAND_PRINT_HELP_FOREVER_NO_BRIEF: + { + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CHud::SetHelpMessage(text, false, true); // + false + return 0; + } + case COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF: + { + // CHud::mAlwaysAllowHelpText = true; + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CHud::SetHelpMessage(text, false); // + false, false + return 0; + } + case COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF: + { + // CHud::mAlwaysAllowHelpText = true; + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CHud::SetHelpMessage(text, false, true); // + false + return 0; + } + case COMMAND_SET_CAR_IS_REWARD: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + pVehicle->bRewardVehicle = (GET_INTEGER_PARAM(1) != 0); + return 0; + } + case COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS: + { + CollectParameters(&m_nIp, 2); + CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + script_assert(pPlayerPed); + for (int i = 0; i < CPools::GetVehiclePool()->GetSize(); i++) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + if (pPed && IsPedPointerValid(pPed)) { + if (pPed->m_leader == pPlayerPed || (pPed->m_objective == OBJECTIVE_FOLLOW_CHAR_IN_FORMATION && pPed->m_pedInObjective == pPlayerPed)) + pPed->bIsFrozen = (GET_INTEGER_PARAM(1) != 0); + } + } + return 0; + } + default: + script_assert(0); + } + return -1; +}
\ No newline at end of file diff --git a/src/control/Script2.cpp b/src/control/Script2.cpp index 4e7a1c3e..26c1cdde 100644 --- a/src/control/Script2.cpp +++ b/src/control/Script2.cpp @@ -28,6 +28,8 @@ #include "World.h" #include "Zones.h" +// LCS: file done except TODOs + int8 CRunningScript::ProcessCommands300To399(int32 command) { switch (command) { @@ -35,12 +37,10 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) //case COMMAND_SET_PLAYER_INVINCIBLE: //case COMMAND_SET_CHAR_GRAPHIC_TYPE: //case COMMAND_SET_PLAYER_GRAPHIC_TYPE: - /* case COMMAND_HAS_PLAYER_BEEN_ARRESTED: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_BUSTED); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState == WBSTATE_BUSTED); return 0; - */ //case COMMAND_STOP_CHAR_DRIVING: //case COMMAND_KILL_CHAR: //case COMMAND_SET_FAVOURITE_CAR_MODEL_FOR_CHAR: @@ -49,25 +49,25 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_CHANGE_CAR_LOCK: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->m_nDoorLock = (eCarLock)ScriptParams[1]; + pVehicle->m_nDoorLock = (eCarLock)GET_INTEGER_PARAM(1); return 0; } case COMMAND_SHAKE_CAM_WITH_POINT: CollectParameters(&m_nIp, 4); - TheCamera.CamShake(ScriptParams[0] / 1000.0f, - *(float*)&ScriptParams[1], - *(float*)&ScriptParams[2], - *(float*)&ScriptParams[3]); + TheCamera.CamShake(GET_INTEGER_PARAM(0) / 1000.0f, + GET_FLOAT_PARAM(1), + GET_FLOAT_PARAM(2), + GET_FLOAT_PARAM(3)); return 0; */ case COMMAND_IS_CAR_MODEL: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(pVehicle->GetModelIndex() == ScriptParams[1]); + UpdateCompareFlag(pVehicle->GetModelIndex() == GET_INTEGER_PARAM(1)); return 0; } //case COMMAND_IS_CAR_REMAP: @@ -77,15 +77,15 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_IS_CAR_DEAD_IN_AREA_2D: { CollectParameters(&m_nIp, 6); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED && pVehicle->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); @@ -94,17 +94,17 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_IS_CAR_DEAD_IN_AREA_3D: { CollectParameters(&m_nIp, 8); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float z1 = *(float*)&ScriptParams[3]; - float x2 = *(float*)&ScriptParams[4]; - float y2 = *(float*)&ScriptParams[5]; - float z2 = *(float*)&ScriptParams[6]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float z1 = GET_FLOAT_PARAM(3); + float x2 = GET_FLOAT_PARAM(4); + float y2 = GET_FLOAT_PARAM(5); + float z2 = GET_FLOAT_PARAM(6); UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED && pVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); - if (ScriptParams[7]) + if (GET_INTEGER_PARAM(7)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2); if (CTheScripts::DbgFlag) CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); @@ -121,38 +121,45 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) //case COMMAND_SET_CAR_FLAMEPROOF: //case COMMAND_SET_CAR_ROCKETPROOF: //case COMMAND_IS_CARBOMB_ACTIVE: - //case COMMAND_GIVE_CAR_ALARM: + case COMMAND_GIVE_CAR_ALARM: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + pVehicle->m_nAlarmState = -1; + return 0; + } //case COMMAND_PUT_CAR_ON_TRAILER: - /* case COMMAND_IS_CAR_CRUSHED: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CGarages::HasCarBeenCrushed(ScriptParams[0])); + UpdateCompareFlag(CGarages::HasCarBeenCrushed(GET_INTEGER_PARAM(0))); return 0; - */ - //case COMMAND_CREATE_GANG_CAR: + //case COMMAND_CREATE_GANG_CAR: case COMMAND_CREATE_CAR_GENERATOR: { CollectParameters(&m_nIp, 12); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z > MAP_Z_LOW_LIMIT) pos.z += 0.015f; - ScriptParams[0] = CTheCarGenerators::CreateCarGenerator( - pos.x, pos.y, pos.z, *(float*)&ScriptParams[3], - ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], - ScriptParams[8], ScriptParams[9], ScriptParams[10], ScriptParams[11]); + SET_INTEGER_PARAM(0, CTheCarGenerators::CreateCarGenerator( + pos.x, pos.y, pos.z, GET_FLOAT_PARAM(3), + GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), + GET_INTEGER_PARAM(8), GET_INTEGER_PARAM(9), GET_INTEGER_PARAM(10), GET_INTEGER_PARAM(11))); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SWITCH_CAR_GENERATOR: { CollectParameters(&m_nIp, 2); - CCarGenerator* pCarGen = &CTheCarGenerators::CarGeneratorArray[ScriptParams[0]]; - if (ScriptParams[1] == 0){ + CCarGenerator* pCarGen = &CTheCarGenerators::CarGeneratorArray[GET_INTEGER_PARAM(0)]; + if (GET_INTEGER_PARAM(1) == 0) { pCarGen->SwitchOff(); - }else if (ScriptParams[1] <= 100){ + } + else if (GET_INTEGER_PARAM(1) <= 100) { pCarGen->SwitchOn(); - pCarGen->SetUsesRemaining(ScriptParams[1]); - }else{ + pCarGen->SetUsesRemaining(GET_INTEGER_PARAM(1)); + } + else { pCarGen->SwitchOn(); } return 0; @@ -162,40 +169,34 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); - CUserDisplay::Pager.AddMessage(text, ScriptParams[0], ScriptParams[1], ScriptParams[2]); + CUserDisplay::Pager.AddMessage(text, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } */ case COMMAND_DISPLAY_ONSCREEN_TIMER: { - script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); - m_nIp++; - uint16 offset = CTheScripts::Read2BytesFromScript(&m_nIp); + uint16 offset = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; CollectParameters(&m_nIp, 1); - CUserDisplay::OnscnTimer.AddClock(offset, nil, ScriptParams[0] != 0); + CUserDisplay::OnscnTimer.AddClock(offset, nil, GET_INTEGER_PARAM(0) != 0); return 0; } case COMMAND_CLEAR_ONSCREEN_TIMER: { - script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); - m_nIp++; - CUserDisplay::OnscnTimer.ClearClock((uint16)CTheScripts::Read2BytesFromScript(&m_nIp)); + uint16 offset = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; + CUserDisplay::OnscnTimer.ClearClock(offset); return 0; } case COMMAND_DISPLAY_ONSCREEN_COUNTER: { - script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); - m_nIp++; - int16 counter = CTheScripts::Read2BytesFromScript(&m_nIp); + uint16 counter = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; CollectParameters(&m_nIp, 1); - CUserDisplay::OnscnTimer.AddCounter(counter, ScriptParams[0], nil, 0); + CUserDisplay::OnscnTimer.AddCounter(counter, GET_INTEGER_PARAM(0), nil, 0, -1, nil, 0); return 0; } case COMMAND_CLEAR_ONSCREEN_COUNTER: { - script_assert(CTheScripts::ScriptSpace[m_nIp] == ARGUMENT_GLOBALVAR); - m_nIp++; - CUserDisplay::OnscnTimer.ClearCounter((uint16)CTheScripts::Read2BytesFromScript(&m_nIp)); + uint16 counter = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; + CUserDisplay::OnscnTimer.ClearCounter(counter); return 0; } case COMMAND_SET_ZONE_CAR_INFO: @@ -219,7 +220,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) return 0; } while (zone >= 0) { - CTheZones::SetZoneCarInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[11], gangDensities); + CTheZones::SetZoneCarInfo(zone, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(11), gangDensities); zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO); } return 0; @@ -228,7 +229,7 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_IS_CHAR_IN_ZONE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); char label[12]; CTheScripts::ReadTextLabelFromScript(&m_nIp, label); @@ -239,39 +240,70 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) UpdateCompareFlag(CTheZones::PointLiesWithinZone(&pos, CTheZones::GetNavigationZone(zone))); return 0; } - //case COMMAND_SET_CAR_DENSITY: - //case COMMAND_SET_PED_DENSITY: + case COMMAND_SET_CAR_DENSITY: + { + char label[12]; + CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); + m_nIp += 8; + CollectParameters(&m_nIp, 2); + if (zone < 0) { + debug("Couldn't find zone - %s\n", label); + return 0; + } + while (zone >= 0) { + CTheZones::SetCarDensity(zone, ScriptParams[0], ScriptParams[1]); + zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO); + } + return 0; + } + case COMMAND_SET_PED_DENSITY: + { + char label[12]; + CTheScripts::ReadTextLabelFromScript(&m_nIp, label); + int16 zone = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_INFO); + m_nIp += KEY_LENGTH_IN_SCRIPT; + CollectParameters(&m_nIp, 2); + if (zone < 0) { + debug("Couldn't find zone - %s\n", label); + return 0; + } + while (zone >= 0) { + CTheZones::SetPedDensity(zone, ScriptParams[0], ScriptParams[1]); + zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO); + } + return 0; + } case COMMAND_POINT_CAMERA_AT_PLAYER: { CollectParameters(&m_nIp, 3); - // ScriptParams[0] is unused. - TheCamera.TakeControl(nil, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT); + TheCamera.TakeControl(nil, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), CAMCONTROL_SCRIPT); return 0; } case COMMAND_POINT_CAMERA_AT_CAR: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle) - TheCamera.TakeControl(pVehicle, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT); + TheCamera.TakeControl(pVehicle, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), CAMCONTROL_SCRIPT); return 0; } case COMMAND_POINT_CAMERA_AT_CHAR: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); if (pPed) - TheCamera.TakeControl(pPed, ScriptParams[1], ScriptParams[2], CAMCONTROL_SCRIPT); + TheCamera.TakeControl(pPed, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), CAMCONTROL_SCRIPT); return 0; } case COMMAND_RESTORE_CAMERA: TheCamera.Restore(); return 0; - /* - case COMMAND_SHAKE_PAD: - CPad::GetPad(ScriptParams[0])->StartShake(ScriptParams[1], ScriptParams[2]); - return 0; - */ + /* + case COMMAND_SHAKE_PAD: + CPad::GetPad(GET_INTEGER_PARAM(0))->StartShake(GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); + return 0; + */ case COMMAND_SET_ZONE_PED_INFO: { char label[12]; @@ -284,61 +316,61 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) return 0; } while (zone >= 0) { - CTheZones::SetZonePedInfo(zone, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], - ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8], ScriptParams[9], ScriptParams[10], ScriptParams[11]); + CTheZones::SetZonePedInfo(zone, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), + GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8), GET_INTEGER_PARAM(9), GET_INTEGER_PARAM(10), GET_INTEGER_PARAM(11)); zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO); } return 0; } case COMMAND_SET_TIME_SCALE: CollectParameters(&m_nIp, 1); - CTimer::SetTimeScale(*(float*)&ScriptParams[0]); - return 0; - /* - case COMMAND_IS_CAR_IN_AIR: - { - CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - script_assert(pVehicle && pVehicle->IsCar()); - CAutomobile* pCar = (CAutomobile*)pVehicle; - UpdateCompareFlag(pCar->GetAllWheelsOffGround()); - return 0; - } - */ + CTimer::SetTimeScale(GET_FLOAT_PARAM(0)); + return 0; + /* + case COMMAND_IS_CAR_IN_AIR: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle && pVehicle->IsCar()); + CAutomobile* pCar = (CAutomobile*)pVehicle; + UpdateCompareFlag(pCar->GetAllWheelsOffGround()); + return 0; + } + */ case COMMAND_SET_FIXED_CAMERA_POSITION: { CollectParameters(&m_nIp, 6); TheCamera.SetCamPositionForFixedMode( - CVector(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2]), - CVector(*(float*)&ScriptParams[3], *(float*)&ScriptParams[4], *(float*)&ScriptParams[5])); + CVector(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2)), + CVector(GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), GET_FLOAT_PARAM(5))); return 0; } case COMMAND_POINT_CAMERA_AT_POINT: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - TheCamera.TakeControlNoEntity(pos, ScriptParams[3], CAMCONTROL_SCRIPT); + TheCamera.TakeControlNoEntity(pos, GET_INTEGER_PARAM(3), CAMCONTROL_SCRIPT); return 0; } case COMMAND_ADD_BLIP_FOR_CAR_OLD: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CRadar::SetEntityBlip(BLIP_CAR, ScriptParams[0], ScriptParams[1], (eBlipDisplay)ScriptParams[2]); + SET_INTEGER_PARAM(0, CRadar::SetEntityBlip(BLIP_CAR, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), (eBlipDisplay)GET_INTEGER_PARAM(2))); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_BLIP_FOR_CHAR_OLD: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], ScriptParams[1], (eBlipDisplay)ScriptParams[2]); + SET_INTEGER_PARAM(0, CRadar::SetEntityBlip(BLIP_CHAR, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), (eBlipDisplay)GET_INTEGER_PARAM(2))); StoreParameters(&m_nIp, 1); return 0; } @@ -346,57 +378,61 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_ADD_BLIP_FOR_OBJECT_OLD: { CollectParameters(&m_nIp, 3); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], ScriptParams[1], (eBlipDisplay)ScriptParams[2]); + SET_INTEGER_PARAM(0, CRadar::SetEntityBlip(BLIP_OBJECT, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), (eBlipDisplay)GET_INTEGER_PARAM(2))); StoreParameters(&m_nIp, 1); return 0; } */ case COMMAND_REMOVE_BLIP: CollectParameters(&m_nIp, 1); - CRadar::ClearBlip(ScriptParams[0]); + CRadar::ClearBlip(GET_INTEGER_PARAM(0)); return 0; case COMMAND_CHANGE_BLIP_COLOUR: CollectParameters(&m_nIp, 2); - CRadar::ChangeBlipColour(ScriptParams[0], ScriptParams[1]); + CRadar::ChangeBlipColour(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_DIM_BLIP: CollectParameters(&m_nIp, 2); - CRadar::ChangeBlipBrightness(ScriptParams[0], ScriptParams[1]); + CRadar::ChangeBlipBrightness(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_ADD_BLIP_FOR_COORD_OLD: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CRadar::SetCoordBlip(BLIP_COORD, pos, ScriptParams[3], (eBlipDisplay)ScriptParams[4]); + SET_INTEGER_PARAM(0, CRadar::SetCoordBlip(BLIP_COORD, pos, GET_INTEGER_PARAM(3), (eBlipDisplay)GET_INTEGER_PARAM(4))); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CHANGE_BLIP_SCALE: CollectParameters(&m_nIp, 2); - CRadar::ChangeBlipScale(ScriptParams[0], ScriptParams[1]); + CRadar::ChangeBlipScale(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_SET_FADING_COLOUR: CollectParameters(&m_nIp, 3); - TheCamera.SetFadeColour(ScriptParams[0], ScriptParams[1], ScriptParams[2]); + TheCamera.SetFadeColour(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; case COMMAND_DO_FADE: + { + // unknown empty call on PS2, not mobile CollectParameters(&m_nIp, 2); - TheCamera.Fade(ScriptParams[0] / 1000.0f, ScriptParams[1]); + float fFadeTime = GET_INTEGER_PARAM(0); + TheCamera.Fade(fFadeTime > 2 ? fFadeTime / 1000.0f : 0.0f, GET_INTEGER_PARAM(1)); return 0; + } case COMMAND_GET_FADING_STATUS: UpdateCompareFlag(TheCamera.GetFading()); return 0; case COMMAND_ADD_HOSPITAL_RESTART: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; - float angle = *(float*)&ScriptParams[3]; + CVector pos = GET_VECTOR_PARAM(0); + float angle = GET_FLOAT_PARAM(3); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRestart::AddHospitalRestartPoint(pos, angle); @@ -405,8 +441,8 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_ADD_POLICE_RESTART: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; - float angle = *(float*)&ScriptParams[3]; + CVector pos = GET_VECTOR_PARAM(0); + float angle = GET_FLOAT_PARAM(3); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRestart::AddPoliceRestartPoint(pos, angle); @@ -415,8 +451,8 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_OVERRIDE_NEXT_RESTART: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; - float angle = *(float*)&ScriptParams[3]; + CVector pos = GET_VECTOR_PARAM(0); + float angle = GET_FLOAT_PARAM(3); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRestart::OverrideNextRestart(pos, angle); @@ -426,9 +462,9 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_DRAW_SHADOW: { CollectParameters(&m_nIp, 10); - CVector pos = *(CVector*)&ScriptParams[1]; - float angle = *(float*)&ScriptParams[4]; - float length = *(float*)&ScriptParams[5]; + CVector pos = GET_VECTOR_PARAM(1); + float angle = GET_FLOAT_PARAM(4); + float length = GET_FLOAT_PARAM(5); float x, y; if (angle != 0.0f){ y = Cos(angle) * length; @@ -441,40 +477,40 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) float frontY = y; float sideX = y; float sideY = x; - CShadows::StoreShadowToBeRendered(ScriptParams[0], &pos, frontX, frontY, sideX, sideY, - ScriptParams[6], ScriptParams[7], ScriptParams[8], ScriptParams[9]); + CShadows::StoreShadowToBeRendered(GET_INTEGER_PARAM(0), &pos, frontX, frontY, sideX, sideY, + GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8), GET_INTEGER_PARAM(9)); return 0; } */ case COMMAND_GET_PLAYER_HEADING: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; float angle = pPed->bInVehicle ? pPed->m_pMyVehicle->GetForward().Heading() : pPed->GetForward().Heading(); angle = RADTODEG(angle); if (angle < 0.0f) angle += 360.0f; if (angle > 360.0f) angle -= 360.0f; - *(float*)&ScriptParams[0] = angle; + SET_FLOAT_PARAM(0, angle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_PLAYER_HEADING: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); if (pPed->bInVehicle) return 0; - pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(*(float*)&ScriptParams[1]); - pPed->SetHeading(DEGTORAD(*(float*)&ScriptParams[1])); + pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(GET_FLOAT_PARAM(1)); + pPed->SetHeading(DEGTORAD(GET_FLOAT_PARAM(1))); return 0; } case COMMAND_GET_CHAR_HEADING: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); float angle = pPed->bInVehicle ? pPed->m_pMyVehicle->GetForward().Heading() : pPed->GetForward().Heading(); angle = RADTODEG(angle); @@ -482,25 +518,25 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) angle += 360.0f; if (angle > 360.0f) angle -= 360.0f; - *(float*)&ScriptParams[0] = angle; + SET_FLOAT_PARAM(0, angle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CHAR_HEADING: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); if (pPed->bInVehicle) return 0; - pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(*(float*)&ScriptParams[1]); - pPed->SetHeading(DEGTORAD(*(float*)&ScriptParams[1])); + pPed->m_fRotationDest = pPed->m_fRotationCur = DEGTORAD(GET_FLOAT_PARAM(1)); + pPed->SetHeading(DEGTORAD(GET_FLOAT_PARAM(1))); return 0; } case COMMAND_GET_CAR_HEADING: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); float angle = pVehicle->GetForward().Heading(); angle = RADTODEG(angle); @@ -508,22 +544,22 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) angle += 360.0f; if (angle > 360.0f) angle -= 360.0f; - *(float*)&ScriptParams[0] = angle; + SET_FLOAT_PARAM(0, angle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CAR_HEADING: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->SetHeading(DEGTORAD(*(float*)&ScriptParams[1])); + pVehicle->SetHeading(DEGTORAD(GET_FLOAT_PARAM(1))); return 0; } case COMMAND_GET_OBJECT_HEADING: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); float angle = pObject->GetForward().Heading(); angle = RADTODEG(angle); @@ -531,39 +567,39 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) angle += 360.0f; if (angle > 360.0f) angle -= 360.0f; - *(float*)&ScriptParams[0] = angle; + SET_FLOAT_PARAM(0, angle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_OBJECT_HEADING: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CWorld::Remove(pObject); - pObject->SetHeading(DEGTORAD(*(float*)&ScriptParams[1])); + pObject->SetHeading(DEGTORAD(GET_FLOAT_PARAM(1))); pObject->GetMatrix().UpdateRW(); pObject->UpdateRwFrame(); CWorld::Add(pObject); return 0; } - /* case COMMAND_IS_PLAYER_TOUCHING_OBJECT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pObject); CPhysical* pEntityToTest = pPed->bInVehicle ? (CPhysical*)pPed->m_pMyVehicle : pPed; UpdateCompareFlag(pEntityToTest->GetHasCollidedWith(pObject)); return 0; } + /* case COMMAND_IS_CHAR_TOUCHING_OBJECT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pObject); CPhysical* pEntityToTest = pPed->bInVehicle ? (CPhysical*)pPed->m_pMyVehicle : pPed; UpdateCompareFlag(pEntityToTest->GetHasCollidedWith(pObject)); @@ -573,121 +609,119 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_SET_PLAYER_AMMO: { CollectParameters(&m_nIp, 3); - CWorld::Players[0].m_pPed->SetAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); + CWorld::Players[0].m_pPed->SetAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } - /* case COMMAND_SET_CHAR_AMMO: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - pPed->SetAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + pPed->SetAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } - */ //case COMMAND_SET_CAR_AMMO: //case COMMAND_LOAD_CAMERA_SPLINE: //case COMMAND_MOVE_CAMERA_ALONG_SPLINE: //case COMMAND_GET_CAMERA_POSITION_ALONG_SPLINE: case COMMAND_DECLARE_MISSION_FLAG: - CTheScripts::OnAMissionFlag = (uint16)CTheScripts::Read2BytesFromScript(&++m_nIp); + CTheScripts::OnAMissionFlag = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; return 0; case COMMAND_DECLARE_MISSION_FLAG_FOR_CONTACT: return 0; - //case COMMAND_DECLARE_BASE_BRIEF_ID_FOR_CONTACT: + //case COMMAND_DECLARE_BASE_BRIEF_ID_FOR_CONTACT: case COMMAND_IS_PLAYER_HEALTH_GREATER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - UpdateCompareFlag(pPed->m_fHealth > ScriptParams[1]); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + UpdateCompareFlag(pPed->m_fHealth > GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_CHAR_HEALTH_GREATER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(pPed->m_fHealth > ScriptParams[1]); + UpdateCompareFlag(pPed->m_fHealth > GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_CAR_HEALTH_GREATER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(pVehicle->m_fHealth > ScriptParams[1]); + UpdateCompareFlag(pVehicle->m_fHealth > GET_INTEGER_PARAM(1)); return 0; } case COMMAND_ADD_BLIP_FOR_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int handle = CRadar::SetEntityBlip(BLIP_CAR, ScriptParams[0], 0, BLIP_DISPLAY_BOTH); + int handle = CRadar::SetEntityBlip(BLIP_CAR, GET_INTEGER_PARAM(0), 0, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_BLIP_FOR_CHAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int handle = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 1, BLIP_DISPLAY_BOTH); + int handle = CRadar::SetEntityBlip(BLIP_CHAR, GET_INTEGER_PARAM(0), 1, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_BLIP_FOR_OBJECT: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int handle = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 6, BLIP_DISPLAY_BOTH); + int handle = CRadar::SetEntityBlip(BLIP_OBJECT, GET_INTEGER_PARAM(0), 6, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_BLIP_FOR_CONTACT_POINT: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetCoordBlip(BLIP_CONTACT_POINT, pos, 2, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_BLIP_FOR_COORD: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetCoordBlip(BLIP_COORD, pos, 5, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CHANGE_BLIP_DISPLAY: CollectParameters(&m_nIp, 2); - CRadar::ChangeBlipDisplay(ScriptParams[0], (eBlipDisplay)ScriptParams[1]); + CRadar::ChangeBlipDisplay(GET_INTEGER_PARAM(0), (eBlipDisplay)GET_INTEGER_PARAM(1)); return 0; case COMMAND_ADD_ONE_OFF_SOUND: { CollectParameters(&m_nIp, 4); - switch (ScriptParams[3]) { + switch (GET_INTEGER_PARAM(3)) { case SCRIPT_SOUND_PART_MISSION_COMPLETE: DMAudio.PlayFrontEndSound(SOUND_PART_MISSION_COMPLETE, 0); return 0; @@ -712,14 +746,20 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case SCRIPT_SOUND_IMRAN_ARM_BOMB: DMAudio.PlayFrontEndSound(SOUND_AMMUNATION_IMRAN_ARM_BOMB, 0); return 0; + case 0x46: // TODO + DMAudio.PlayFrontEndSound(0xC4, 0); + return 0; + case 0x47: // TODO + DMAudio.PlayFrontEndSound(0xCD, 0); + return 0; default: break; } - if (!DMAudio.IsAudioInitialised()) + if (!DMAudio.IsAudioInitialised()) // LCS doesn't have it. Why? return 0; cAudioScriptObject* obj = new cAudioScriptObject(); - obj->Posn = *(CVector*)&ScriptParams[0]; - obj->AudioId = ScriptParams[3]; + obj->Posn = GET_VECTOR_PARAM(0); + obj->AudioId = GET_INTEGER_PARAM(3); obj->AudioEntity = AEHANDLE_NONE; DMAudio.CreateOneShotScriptObject(obj); return 0; @@ -727,23 +767,23 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_ADD_CONTINUOUS_SOUND: { CollectParameters(&m_nIp, 4); - if (DMAudio.IsAudioInitialised()) { + if (DMAudio.IsAudioInitialised()) { // LCS doesn't have it. Why? cAudioScriptObject* obj = new cAudioScriptObject(); - obj->Posn = *(CVector*)&ScriptParams[0]; - obj->AudioId = ScriptParams[3]; + obj->Posn = GET_VECTOR_PARAM(0); + obj->AudioId = GET_INTEGER_PARAM(3); obj->AudioEntity = DMAudio.CreateLoopingScriptObject(obj); - ScriptParams[0] = CPools::GetAudioScriptObjectPool()->GetIndex(obj); + SET_INTEGER_PARAM(0, CPools::GetAudioScriptObjectPool()->GetIndex(obj)); } else - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_REMOVE_SOUND: { CollectParameters(&m_nIp, 1); - cAudioScriptObject* obj = CPools::GetAudioScriptObjectPool()->GetAt(ScriptParams[0]); - if (!obj){ + cAudioScriptObject* obj = CPools::GetAudioScriptObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + if (!obj) { debug("REMOVE_SOUND - Sound doesn't exist\n"); return 0; } @@ -754,9 +794,9 @@ int8 CRunningScript::ProcessCommands300To399(int32 command) case COMMAND_IS_CAR_STUCK_ON_ROOF: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(CTheScripts::UpsideDownCars.HasCarBeenUpsideDownForAWhile(ScriptParams[0])); + UpdateCompareFlag(CTheScripts::UpsideDownCars.HasCarBeenUpsideDownForAWhile(GET_INTEGER_PARAM(0))); return 0; } default: @@ -771,22 +811,22 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_ADD_UPSIDEDOWN_CAR_CHECK: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CTheScripts::UpsideDownCars.AddCarToCheck(ScriptParams[0]); + CTheScripts::UpsideDownCars.AddCarToCheck(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_REMOVE_UPSIDEDOWN_CAR_CHECK: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - CTheScripts::UpsideDownCars.RemoveCarFromCheck(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CTheScripts::UpsideDownCars.RemoveCarFromCheck(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_SET_CHAR_OBJ_WAIT_ON_FOOT: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_WAIT_ON_FOOT); @@ -795,7 +835,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_ON_FOOT_TILL_SAFE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE); @@ -804,32 +844,31 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_GUARD_SPOT: { CollectParameters(&m_nIp, 4); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GUARD_SPOT, pos); return 0; } - /* case COMMAND_SET_CHAR_OBJ_GUARD_AREA: { CollectParameters(&m_nIp, 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - float infX = *(float*)&ScriptParams[1]; - float infY = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - if (infX > supX){ - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + float infX = GET_FLOAT_PARAM(1); + float infY = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + if (infX > supX) { + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; @@ -843,13 +882,12 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_WAIT_IN_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_WAIT_IN_CAR); return 0; } - */ case COMMAND_IS_PLAYER_IN_AREA_ON_FOOT_2D: case COMMAND_IS_PLAYER_IN_AREA_IN_CAR_2D: case COMMAND_IS_PLAYER_STOPPED_IN_AREA_2D: @@ -887,17 +925,17 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_GIVE_WEAPON_TO_PLAYER: { CollectParameters(&m_nIp, 3); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->m_nSelectedWepSlot = pPed->GiveWeapon((eWeaponType)ScriptParams[1], ScriptParams[2]); + pPed->m_nSelectedWepSlot = pPed->GiveWeapon((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_GIVE_WEAPON_TO_CHAR: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->SetCurrentWeapon(pPed->GiveWeapon((eWeaponType)ScriptParams[1], ScriptParams[2])); + pPed->SetCurrentWeapon(pPed->GiveWeapon((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2))); if (pPed->bInVehicle && pPed->m_pMyVehicle) pPed->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType)->m_nModelId); return 0; @@ -906,23 +944,35 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_PLAYER_CONTROL: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; - if (ScriptParams[1]){ + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; + if (FindPlayerPed()) { + if (FindPlayerPed()->GetPedState() != PED_JUMP) { + FindPlayerPed()->bIsLanding = false; + FindPlayerPed()->bIsInTheAir = false; + } + FindPlayerPed()->RestoreHeadingRate(); + } + if (GET_INTEGER_PARAM(1)) { pPlayer->MakePlayerSafe(false); - if (strcmp(m_abScriptName, "serg1") == 0) // Four Iron - pPlayer->m_pPed->ClearFollowPath(); - }else{ + if (FindPlayerPed()->GetStatus() != PED_DRIVING && !FindPlayerPed()->m_attachedTo) { + // FindPlayerPed()->SetIdleAndResetAnim(); // TODO! + } + } + else { pPlayer->MakePlayerSafe(true); + if (FindPlayerPed()->GetPedState() > PED_STATES_NO_AI && FindPlayerPed()->GetPedState() != PED_DRIVING && TheCamera.GetScreenFadeStatus() == FADE_2) { + // FindPlayerPed()->SetIdleAndResetAnim(); // TODO! + } } return 0; } case COMMAND_FORCE_WEATHER: CollectParameters(&m_nIp, 1); - CWeather::ForceWeather(ScriptParams[0]); + CWeather::ForceWeather(GET_INTEGER_PARAM(0)); return 0; case COMMAND_FORCE_WEATHER_NOW: CollectParameters(&m_nIp, 1); - CWeather::ForceWeatherNow(ScriptParams[0]); + CWeather::ForceWeatherNow(GET_INTEGER_PARAM(0)); return 0; case COMMAND_RELEASE_WEATHER: CWeather::ReleaseWeather(); @@ -930,9 +980,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CURRENT_PLAYER_WEAPON: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++){ - if (pPed->m_weapons[i].m_eWeaponType == ScriptParams[1]) + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { + if (pPed->m_weapons[i].m_eWeaponType == GET_INTEGER_PARAM(1)) pPed->m_nSelectedWepSlot = i; } return 0; @@ -940,9 +990,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CURRENT_CHAR_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - if (pPed->m_weapons[i].m_eWeaponType == ScriptParams[1]) + if (pPed->m_weapons[i].m_eWeaponType == GET_INTEGER_PARAM(1)) pPed->SetCurrentWeapon(i); } return 0; @@ -951,18 +1001,18 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_GET_OBJECT_COORDINATES: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - *(CVector*)&ScriptParams[0] = pObject->GetPosition(); + SET_VECTOR_PARAM(0, pObject->GetPosition()); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_OBJECT_COORDINATES: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pObject->Teleport(pos); @@ -970,13 +1020,13 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) return 0; } case COMMAND_GET_GAME_TIMER: - ScriptParams[0] = CTimer::GetTimeInMilliseconds(); + SET_INTEGER_PARAM(0, CTimer::GetTimeInMilliseconds()); StoreParameters(&m_nIp, 1); return 0; case COMMAND_TURN_CHAR_TO_FACE_COORD: { CollectParameters(&m_nIp, 4); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVehicle* pVehicle; CVector pos; @@ -988,11 +1038,11 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) pos = pVehicle->GetPosition(); else pos = pPed->GetPosition(); - float heading = CGeneral::GetATanOfXY(pos.x - *(float*)&ScriptParams[1], pos.y - *(float*)&ScriptParams[2]); + float heading = CGeneral::GetATanOfXY(pos.x - GET_FLOAT_PARAM(1), pos.y - GET_FLOAT_PARAM(2)); heading += HALFPI; if (heading > TWOPI) heading -= TWOPI; - if (!pVehicle){ + if (!pVehicle) { pPed->m_fRotationCur = heading; pPed->m_fRotationDest = heading; pPed->SetHeading(heading); @@ -1002,7 +1052,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_TURN_PLAYER_TO_FACE_COORD: { CollectParameters(&m_nIp, 4); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); CVehicle* pVehicle; CVector pos; @@ -1014,7 +1064,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) pos = pVehicle->GetPosition(); else pos = pPed->GetPosition(); - float heading = CGeneral::GetATanOfXY(pos.x - *(float*)&ScriptParams[1], pos.y - *(float*)&ScriptParams[2]); + float heading = CGeneral::GetATanOfXY(pos.x - GET_FLOAT_PARAM(1), pos.y - GET_FLOAT_PARAM(2)); heading += HALFPI; if (heading > TWOPI) heading -= TWOPI; @@ -1028,16 +1078,16 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_STORE_WANTED_LEVEL: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - ScriptParams[0] = pPed->m_pWanted->GetWantedLevel(); + SET_INTEGER_PARAM(0, pPed->m_pWanted->GetWantedLevel()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_CAR_STOPPED: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(CTheScripts::IsVehicleStopped(pVehicle)); return 0; @@ -1045,94 +1095,94 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_MARK_CHAR_AS_NO_LONGER_NEEDED: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CTheScripts::CleanUpThisPed(pPed); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_MARK_CAR_AS_NO_LONGER_NEEDED: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); CTheScripts::CleanUpThisVehicle(pVehicle); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CAR); return 0; } case COMMAND_MARK_OBJECT_AS_NO_LONGER_NEEDED: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); CTheScripts::CleanUpThisObject(pObject); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } case COMMAND_DONT_REMOVE_CHAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_DONT_REMOVE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CAR); return 0; } case COMMAND_DONT_REMOVE_OBJECT: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } case COMMAND_CREATE_CHAR_AS_PASSENGER: { CollectParameters(&m_nIp, 4); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - switch (ScriptParams[2]) { + switch (GET_INTEGER_PARAM(2)) { case MI_COP: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_STREET; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_STREET); break; case MI_SWAT: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_SWAT; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_SWAT); break; case MI_FBI: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_FBI; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_FBI); break; case MI_ARMY: - if (ScriptParams[1] == PEDTYPE_COP) - ScriptParams[2] = COP_ARMY; + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + SET_INTEGER_PARAM(2, COP_ARMY); break; case MI_MEDIC: - if (ScriptParams[1] == PEDTYPE_EMERGENCY) - ScriptParams[2] = PEDTYPE_EMERGENCY; + if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY) + SET_INTEGER_PARAM(2, PEDTYPE_EMERGENCY); break; case MI_FIREMAN: - if (ScriptParams[1] == PEDTYPE_FIREMAN) - ScriptParams[2] = PEDTYPE_FIREMAN; + if (GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN) + SET_INTEGER_PARAM(2, PEDTYPE_FIREMAN); break; default: break; } CPed* pPed; - if (ScriptParams[1] == PEDTYPE_COP) - pPed = new CCopPed((eCopType)ScriptParams[2]); - else if (ScriptParams[1] == PEDTYPE_EMERGENCY || ScriptParams[1] == PEDTYPE_FIREMAN) - pPed = new CEmergencyPed(ScriptParams[2]); + if (GET_INTEGER_PARAM(1) == PEDTYPE_COP) + pPed = new CCopPed((eCopType)GET_INTEGER_PARAM(2)); + else if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN) + pPed = new CEmergencyPed(GET_INTEGER_PARAM(2)); else - pPed = new CCivilianPed((ePedType)ScriptParams[1], ScriptParams[2]); + pPed = new CCivilianPed((ePedType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; pPed->bAllowMedicsToReviveMe = false; @@ -1143,8 +1193,8 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) pPed->SetOrientation(0.0f, 0.0f, 0.0f); CPopulation::ms_nTotalMissionPeds++; CWorld::Add(pPed); - if (ScriptParams[3] >= 0) - pVehicle->AddPassenger(pPed, ScriptParams[3]); + if (GET_INTEGER_PARAM(3) >= 0) + pVehicle->AddPassenger(pPed, GET_INTEGER_PARAM(3)); else pVehicle->AddPassenger(pPed); pPed->m_pMyVehicle = pVehicle; @@ -1154,18 +1204,18 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) pPed->bUsesCollision = false; pPed->AddInCarAnims(pVehicle, false); pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_SET_CHAR_OBJ_KILL_CHAR_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, pTarget); return 0; @@ -1173,9 +1223,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_KILL_PLAYER_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTarget = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, pTarget); return 0; @@ -1183,9 +1233,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_KILL_CHAR_ANY_MEANS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ANY_MEANS, pTarget); return 0; @@ -1193,9 +1243,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_KILL_PLAYER_ANY_MEANS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTarget = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_KILL_CHAR_ANY_MEANS, pTarget); return 0; @@ -1204,9 +1254,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_CHAR_ON_FOOT_TILL_SAFE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pTarget); return 0; @@ -1215,9 +1265,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_PLAYER_ON_FOOT_TILL_SAFE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTarget = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pTarget); return 0; @@ -1225,9 +1275,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_CHAR_ON_FOOT_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pTarget); return 0; @@ -1235,9 +1285,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_PLAYER_ON_FOOT_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTarget = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pTarget); return 0; @@ -1245,9 +1295,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_GOTO_CHAR_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT, pTarget); return 0; @@ -1255,9 +1305,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_GOTO_PLAYER_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTarget = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT, pTarget); return 0; @@ -1265,9 +1315,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_LEAVE_CAR: { 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)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pVehicle); return 0; @@ -1275,9 +1325,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_ENTER_CAR_AS_PASSENGER: { 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)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_PASSENGER, pVehicle); return 0; @@ -1285,9 +1335,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_ENTER_CAR_AS_DRIVER: { 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)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); return 0; @@ -1297,9 +1347,9 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_DESTROY_OBJECT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_DESTROY_OBJECT, pObject); return 0; @@ -1307,30 +1357,29 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_DESTROY_CAR: { 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)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_DESTROY_CAR, pVehicle); return 0; } - /* case COMMAND_SET_CHAR_OBJ_GOTO_AREA_ON_FOOT: { CollectParameters(&m_nIp, 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - float infX = *(float*)&ScriptParams[1]; - float infY = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; + float infX = GET_FLOAT_PARAM(1); + float infY = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; @@ -1341,32 +1390,31 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) pPed->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, pos, radius); return 0; } - */ //case COMMAND_SET_CHAR_OBJ_GOTO_AREA_IN_CAR: //case COMMAND_SET_CHAR_OBJ_FOLLOW_CAR_ON_FOOT_WITH_OFFSET: //case COMMAND_SET_CHAR_OBJ_GUARD_ATTACK: case COMMAND_SET_CHAR_AS_LEADER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->SetObjective(OBJECTIVE_SET_LEADER, pTarget); return 0; } case COMMAND_SET_PLAYER_AS_LEADER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTarget = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; pPed->SetObjective(OBJECTIVE_SET_LEADER, pTarget); return 0; } case COMMAND_LEAVE_GROUP: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->ClearLeader(); return 0; @@ -1374,60 +1422,66 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SET_CHAR_OBJ_FOLLOW_ROUTE: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; - pPed->SetObjective(OBJECTIVE_FOLLOW_ROUTE, ScriptParams[1], ScriptParams[2]); + pPed->SetObjective(OBJECTIVE_FOLLOW_ROUTE, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_ADD_ROUTE_POINT: { CollectParameters(&m_nIp, 4); - CRouteNode::AddRoutePoint(ScriptParams[0], *(CVector*)&ScriptParams[1]); + CRouteNode::AddRoutePoint(GET_INTEGER_PARAM(0), GET_VECTOR_PARAM(1)); return 0; } case COMMAND_PRINT_WITH_NUMBER_BIG: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); - CMessages::AddBigMessageWithNumber(text, ScriptParams[1], ScriptParams[2] - 1, ScriptParams[0], -1, -1, -1, -1, -1); + CMessages::AddBigMessageWithNumber(text, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2) - 1, GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_NUMBER: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); - CMessages::AddMessageWithNumber(text, ScriptParams[1], ScriptParams[2], ScriptParams[0], -1, -1, -1, -1, -1); + CMessages::AddMessageWithNumber(text, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1); return 0; } case COMMAND_PRINT_WITH_NUMBER_NOW: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); - CMessages::AddMessageJumpQWithNumber(text, ScriptParams[1], ScriptParams[2], ScriptParams[0], -1, -1, -1, -1, -1); + CMessages::AddMessageJumpQWithNumber(text, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1); // 1 + return 0; + } + case COMMAND_PRINT_WITH_NUMBER_SOON: + { + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 3); + CMessages::AddMessageSoonWithNumber(text, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1); return 0; } - //case COMMAND_PRINT_WITH_NUMBER_SOON: case COMMAND_SWITCH_ROADS_ON: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; - if (infX > supX){ - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); + if (infX > supX) { + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } - if (infY > supY){ - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + if (infY > supY) { + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } - if (infZ > supZ){ - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + if (infZ > supZ) { + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.SwitchRoadsOffInArea(infX, supX, infY, supY, infZ, supZ, false); return 0; @@ -1435,23 +1489,23 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_SWITCH_ROADS_OFF: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.SwitchRoadsOffInArea(infX, supX, infY, supY, infZ, supZ, true); return 0; @@ -1459,85 +1513,83 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_GET_NUMBER_OF_PASSENGERS: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->m_nNumPassengers; + SET_INTEGER_PARAM(0, pVehicle->m_nNumPassengers); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_MAXIMUM_NUMBER_OF_PASSENGERS: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->m_nNumMaxPassengers; + SET_INTEGER_PARAM(0, pVehicle->m_nNumMaxPassengers); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CAR_DENSITY_MULTIPLIER: { CollectParameters(&m_nIp, 1); - CCarCtrl::CarDensityMultiplier = *(float*)&ScriptParams[0]; + CCarCtrl::CarDensityMultiplier = GET_FLOAT_PARAM(0); return 0; } case COMMAND_SET_CAR_HEAVY: { 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] != 0) { + if (GET_INTEGER_PARAM(1) != 0) { pVehicle->bIsHeavy = true; - pVehicle->m_fMass = 3.0f * pVehicle->pHandling->fMass; - pVehicle->m_fTurnMass = 5.0f * pVehicle->pHandling->fTurnMass; + pVehicle->m_fMass = 3.0f * pVehicle->pHandling->fMass; // TODO: tHandlingData::GetMass() + pVehicle->m_fTurnMass = 5.0f * pVehicle->pHandling->fTurnMass; // TODO: tHandlingData::GetTurnMass() } else { pVehicle->bIsHeavy = false; - pVehicle->m_fMass = pVehicle->pHandling->fMass; - pVehicle->m_fTurnMass = pVehicle->pHandling->fTurnMass; + pVehicle->m_fMass = pVehicle->pHandling->fMass; // TODO: tHandlingData::GetMass() + pVehicle->m_fTurnMass = pVehicle->pHandling->fTurnMass; // TODO: tHandlingData::GetTurnMass() } return 0; } case COMMAND_CLEAR_CHAR_THREAT_SEARCH: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->m_fearFlags = 0; return 0; } - /* case COMMAND_ACTIVATE_CRANE: { CollectParameters(&m_nIp, 10); - float infX = *(float*)&ScriptParams[2]; - float infY = *(float*)&ScriptParams[3]; - float supX = *(float*)&ScriptParams[4]; - float supY = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(2); + float infY = GET_FLOAT_PARAM(3); + float supX = GET_FLOAT_PARAM(4); + float supY = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[4]; - supX = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(4); + supX = GET_FLOAT_PARAM(2); } if (infY > supY) { - infY = *(float*)&ScriptParams[5]; - supY = *(float*)&ScriptParams[3]; + infY = GET_FLOAT_PARAM(5); + supY = GET_FLOAT_PARAM(3); } CCranes::ActivateCrane(infX, supX, infY, supY, - *(float*)&ScriptParams[6], *(float*)&ScriptParams[7], *(float*)&ScriptParams[8], - DEGTORAD(*(float*)&ScriptParams[9]), false, false, - *(float*)&ScriptParams[0], *(float*)&ScriptParams[1]); + GET_FLOAT_PARAM(6), GET_FLOAT_PARAM(7), GET_FLOAT_PARAM(8), + DEGTORAD(GET_FLOAT_PARAM(9)), false, false, + GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1)); return 0; } case COMMAND_DEACTIVATE_CRANE: { CollectParameters(&m_nIp, 2); - CCranes::DeActivateCrane(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1]); + CCranes::DeActivateCrane(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1)); return 0; } - */ case COMMAND_SET_MAX_WANTED_LEVEL: { CollectParameters(&m_nIp, 1); - CWanted::SetMaximumWantedLevel(ScriptParams[0]); + CWanted::SetMaximumWantedLevel(GET_INTEGER_PARAM(0)); return 0; } //case COMMAND_SAVE_VAR_INT: @@ -1545,7 +1597,7 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) case COMMAND_IS_CAR_IN_AIR_PROPER: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(pVehicle->m_nCollisionRecords == 0); return 0; diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index f831645e..9d66b4fe 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -6,6 +6,7 @@ #include "Boat.h" #include "CarCtrl.h" #include "Clock.h" +#include "ColStore.h" #include "Coronas.h" #include "Cranes.h" #include "CutsceneMgr.h" @@ -36,23 +37,25 @@ #include "Bike.h" #include "Wanted.h" +// LCS: file done except TODOs + int8 CRunningScript::ProcessCommands500To599(int32 command) { switch (command) { case COMMAND_IS_CAR_UPSIDEDOWN: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(pVehicle->GetUp().z <= -0.97f); + UpdateCompareFlag(pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD); return 0; } case COMMAND_GET_PLAYER_CHAR: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); return 0; } @@ -62,9 +65,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_SET_POLICE_IGNORE_PLAYER: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pPed->m_pWanted->m_bIgnoredByCops = true; CWorld::StopAllLawEnforcersInTheirTracks(); } @@ -78,8 +81,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); - CUserDisplay::Pager.AddMessageWithNumber(text, ScriptParams[0], -1, -1, -1, -1, -1, - ScriptParams[1], ScriptParams[2], ScriptParams[3]); + CUserDisplay::Pager.AddMessageWithNumber(text, GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1, + GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3)); return 0; } */ @@ -87,21 +90,21 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); - CDarkel::StartFrenzy((eWeaponType)ScriptParams[0], ScriptParams[1], ScriptParams[2], - ScriptParams[3], text, ScriptParams[4], ScriptParams[5], - ScriptParams[6], ScriptParams[7] != 0, false); + CDarkel::StartFrenzy((eWeaponType)GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), + GET_INTEGER_PARAM(3), text, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), + GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7) != 0, false); return 0; } case COMMAND_READ_KILL_FRENZY_STATUS: { - ScriptParams[0] = CDarkel::ReadStatus(); + SET_INTEGER_PARAM(0, CDarkel::ReadStatus()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SQRT: { CollectParameters(&m_nIp, 1); - *(float*)&ScriptParams[0] = Sqrt(*(float*)&ScriptParams[0]); + SET_FLOAT_PARAM(0, Sqrt(GET_FLOAT_PARAM(0))); StoreParameters(&m_nIp, 1); return 0; } @@ -123,44 +126,40 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) return 0; case COMMAND_GENERATE_RANDOM_FLOAT_IN_RANGE: CollectParameters(&m_nIp, 2); - *(float*)&ScriptParams[0] = CGeneral::GetRandomNumberInRange(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1]); + SET_FLOAT_PARAM(0, CGeneral::GetRandomNumberInRange(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_GENERATE_RANDOM_INT_IN_RANGE: CollectParameters(&m_nIp, 2); - ScriptParams[0] = CGeneral::GetRandomNumberInRange(ScriptParams[0], ScriptParams[1]); + SET_INTEGER_PARAM(0, CGeneral::GetRandomNumberInRange(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_LOCK_CAR_DOORS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->m_nDoorLock = (eCarLock)ScriptParams[1]; + pVehicle->m_nDoorLock = (eCarLock)GET_INTEGER_PARAM(1); return 0; } case COMMAND_EXPLODE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); + pVehicle->bCanBeDamaged = true; pVehicle->BlowUpCar(nil); return 0; } case COMMAND_ADD_EXPLOSION: CollectParameters(&m_nIp, 4); -#ifdef SIMPLER_MISSIONS - if (!CGeneral::faststricmp(m_abScriptName, "hait2")) - CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, true, 11.25f); - else -#endif - CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, true); + CExplosion::AddExplosion(nil, nil, (eExplosionType)GET_INTEGER_PARAM(3), GET_VECTOR_PARAM(0), 0, true); // last argument is 0 (default? - TODO) return 0; case COMMAND_IS_CAR_UPRIGHT: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(pVehicle->GetUp().z >= 0.0f); return 0; @@ -168,8 +167,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_TURN_CHAR_TO_FACE_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pSourcePed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); CVehicle* pVehicle = pSourcePed->bInVehicle ? pSourcePed->m_pMyVehicle : nil; CVector2D sourcePos = pSourcePed->bInVehicle ? pVehicle->GetPosition() : pSourcePed->GetPosition(); CVector2D targetPos = pTargetPed->bInVehicle ? pTargetPed->m_pMyVehicle->GetPosition() : pTargetPed->GetPosition(); @@ -186,8 +185,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_TURN_CHAR_TO_FACE_PLAYER: { CollectParameters(&m_nIp, 2); - CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pTargetPed = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pSourcePed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pTargetPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; CVehicle* pVehicle = pSourcePed->bInVehicle ? pSourcePed->m_pMyVehicle : nil; CVector2D sourcePos = pSourcePed->bInVehicle ? pVehicle->GetPosition() : pSourcePed->GetPosition(); CVector2D targetPos = pTargetPed->bInVehicle ? pTargetPed->m_pMyVehicle->GetPosition() : pTargetPed->GetPosition(); @@ -204,8 +203,8 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_TURN_PLAYER_TO_FACE_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pSourcePed = CWorld::Players[ScriptParams[0]].m_pPed; - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pSourcePed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); CVehicle* pVehicle = pSourcePed->bInVehicle ? pSourcePed->m_pMyVehicle : nil; CVector2D sourcePos = pSourcePed->bInVehicle ? pVehicle->GetPosition() : pSourcePed->GetPosition(); CVector2D targetPos = pTargetPed->bInVehicle ? pTargetPed->m_pMyVehicle->GetPosition() : pTargetPed->GetPosition(); @@ -222,11 +221,11 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_SET_CHAR_OBJ_GOTO_COORD_ON_FOOT: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector target; - target.x = *(float*)&ScriptParams[1]; - target.y = *(float*)&ScriptParams[2]; + target.x = GET_FLOAT_PARAM(1); + target.y = GET_FLOAT_PARAM(2); target.z = CWorld::FindGroundZForCoord(target.x, target.y); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, target); @@ -236,63 +235,61 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_CREATE_PICKUP: { CollectParameters(&m_nIp, 5); - int16 model = ScriptParams[0]; + int16 model = GET_INTEGER_PARAM(0); if (model < 0) model = CTheScripts::UsedObjectArray[-model].index; - CVector pos = *(CVector*)&ScriptParams[2]; + CVector pos = GET_VECTOR_PARAM(2); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, model, ScriptParams[1], 0); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, model, GET_INTEGER_PARAM(1), 0)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_HAS_PICKUP_BEEN_COLLECTED: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CPickups::IsPickUpPickedUp(ScriptParams[0]) != 0); + UpdateCompareFlag(CPickups::IsPickUpPickedUp(GET_INTEGER_PARAM(0)) != 0); return 0; case COMMAND_REMOVE_PICKUP: CollectParameters(&m_nIp, 1); - CPickups::RemovePickUp(ScriptParams[0]); + CPickups::RemovePickUp(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_TAXI_LIGHTS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); - ((CAutomobile*)pVehicle)->SetTaxiLight(ScriptParams[1] != 0); + ((CAutomobile*)pVehicle)->SetTaxiLight(GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_PRINT_BIG_Q: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddBigMessageQ(text, ScriptParams[0], ScriptParams[1] - 1); + CMessages::AddBigMessageQ(text, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1) - 1); return 0; } - /* case COMMAND_PRINT_WITH_NUMBER_BIG_Q: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 3); - CMessages::AddBigMessageWithNumberQ(text, ScriptParams[1], ScriptParams[2] - 1, - ScriptParams[0], -1, -1, -1, -1, -1); + CMessages::AddBigMessageWithNumberQ(text, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2) - 1, + GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1); return 0; } - */ case COMMAND_SET_GARAGE: { CollectParameters(&m_nIp, 9); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float X2 = *(float*)&ScriptParams[3]; - float Y2 = *(float*)&ScriptParams[4]; - float supX = *(float*)&ScriptParams[5]; - float supY = *(float*)&ScriptParams[6]; - float supZ = *(float*)&ScriptParams[7]; - ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, ScriptParams[8], 0); + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float X2 = GET_FLOAT_PARAM(3); + float Y2 = GET_FLOAT_PARAM(4); + float supX = GET_FLOAT_PARAM(5); + float supY = GET_FLOAT_PARAM(6); + float supZ = GET_FLOAT_PARAM(7); + SET_INTEGER_PARAM(0, CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, GET_INTEGER_PARAM(8), 0)); StoreParameters(&m_nIp, 1); return 0; } @@ -300,15 +297,15 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_SET_GARAGE_WITH_CAR_MODEL: { CollectParameters(&m_nIp, 10); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float X2 = *(float*)&ScriptParams[3]; - float Y2 = *(float*)&ScriptParams[4]; - float supX = *(float*)&ScriptParams[5]; - float supY = *(float*)&ScriptParams[6]; - float supZ = *(float*)&ScriptParams[7]; - ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, ScriptParams[8], ScriptParams[9]); + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float X2 = GET_FLOAT_PARAM(3); + float Y2 = GET_FLOAT_PARAM(4); + float supX = GET_FLOAT_PARAM(5); + float supY = GET_FLOAT_PARAM(6); + float supZ = GET_FLOAT_PARAM(7); + SET_INTEGER_PARAM(0, CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, GET_INTEGER_PARAM(8), GET_INTEGER_PARAM(9))); StoreParameters(&m_nIp, 1); return 0; } @@ -317,34 +314,33 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 2); CVehicle* pTarget; - if (ScriptParams[1] >= 0) { - pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - script_assert(pTarget); + if (GET_INTEGER_PARAM(1) >= 0) { + pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); } else { pTarget = nil; } - CGarages::SetTargetCarForMissonGarage(ScriptParams[0], pTarget); + CGarages::SetTargetCarForMissonGarage(GET_INTEGER_PARAM(0), pTarget); return 0; } case COMMAND_IS_CAR_IN_MISSION_GARAGE: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CGarages::HasCarBeenDroppedOffYet(ScriptParams[0])); + UpdateCompareFlag(CGarages::HasCarBeenDroppedOffYet(GET_INTEGER_PARAM(0))); return 0; -/* case COMMAND_SET_FREE_BOMBS: CollectParameters(&m_nIp, 1); - CGarages::SetFreeBombs(ScriptParams[0] != 0); + CGarages::SetFreeBombs(GET_INTEGER_PARAM(0) != 0); return 0; + /* case COMMAND_SET_POWERPOINT: { CollectParameters(&m_nIp, 7); - float f1 = *(float*)&ScriptParams[0]; - float f2 = *(float*)&ScriptParams[1]; - float f3 = *(float*)&ScriptParams[2]; - float f4 = *(float*)&ScriptParams[3]; - float f5 = *(float*)&ScriptParams[4]; - float f6 = *(float*)&ScriptParams[5]; + float f1 = GET_FLOAT_PARAM(0); + float f2 = GET_FLOAT_PARAM(1); + float f3 = GET_FLOAT_PARAM(2); + float f4 = GET_FLOAT_PARAM(3); + float f5 = GET_FLOAT_PARAM(4); + float f6 = GET_FLOAT_PARAM(5); float temp; if (f1 > f4) { @@ -365,43 +361,52 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) f6 = temp; } - CPowerPoints::GenerateNewOne(f1, f2, f3, f4, f5, f6, *(uint8*)&ScriptParams[6]); + CPowerPoints::GenerateNewOne(f1, f2, f3, f4, f5, f6, *(uint8*)&GET_INTEGER_PARAM(6)); return 0; } case COMMAND_SET_ALL_TAXI_LIGHTS: CollectParameters(&m_nIp, 1); - CAutomobile::SetAllTaxiLights(ScriptParams[0] != 0); + CAutomobile::SetAllTaxiLights(GET_INTEGER_PARAM(0) != 0); return 0; + */ case COMMAND_IS_CAR_ARMED_WITH_ANY_BOMB: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - script_assert(pCar); - script_assert(pCar->m_vehType == VEHICLE_TYPE_CAR); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); +#ifdef FIX_BUGS + if (pVehicle->IsCar()) + UpdateCompareFlag(((CAutomobile*)pVehicle)->m_bombType != 0); + else if (pVehicle->IsBike()) + UpdateCompareFlag(((CBike*)pVehicle)->m_bombType != 0); + else + UpdateCompareFlag(false); +#else + CAutomobile* pCar = (CVehicle*)pVehicle; UpdateCompareFlag(pCar->m_bombType != 0); //TODO: enum +#endif return 0; } - */ case COMMAND_APPLY_BRAKES_TO_PLAYERS_CAR: CollectParameters(&m_nIp, 2); - CPad::GetPad(ScriptParams[0])->bApplyBrakes = (ScriptParams[1] != 0); + CPad::GetPad(GET_INTEGER_PARAM(0))->bApplyBrakes = (GET_INTEGER_PARAM(1) != 0); return 0; case COMMAND_SET_PLAYER_HEALTH: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->m_fHealth = Min(ScriptParams[1], CWorld::Players[ScriptParams[0]].m_nMaxHealth); + pPed->m_fHealth = Min(GET_INTEGER_PARAM(1), CWorld::Players[GET_INTEGER_PARAM(0)].m_nMaxHealth); return 0; } case COMMAND_SET_CHAR_HEALTH: { 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]) { - pPed->m_fHealth = ScriptParams[1]; + if (GET_INTEGER_PARAM(1)) { + pPed->m_fHealth = GET_INTEGER_PARAM(1); } else if (pPed->bInVehicle) { pPed->SetDead(); @@ -409,86 +414,93 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) pPed->FlagToDestroyWhenNextProcessed(); } else { - pPed->SetDie(); + pPed->SetDie(); // last argument = 13 (default? TODO) } return 0; } case COMMAND_SET_CAR_HEALTH: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->m_fHealth = ScriptParams[1]; + pVehicle->m_fHealth = GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_PLAYER_HEALTH: { 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); - ScriptParams[0] = pPed->m_fHealth; + SET_INTEGER_PARAM(0, pPed->m_fHealth); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_CHAR_HEALTH: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->m_fHealth; + SET_INTEGER_PARAM(0, pPed->m_fHealth); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_CAR_HEALTH: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->m_fHealth; + SET_INTEGER_PARAM(0, pVehicle->m_fHealth); StoreParameters(&m_nIp, 1); return 0; } - /* case COMMAND_IS_CAR_ARMED_WITH_BOMB: { CollectParameters(&m_nIp, 2); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - script_assert(pCar); - script_assert(pCar->m_vehType == VEHICLE_TYPE_CAR); - UpdateCompareFlag(pCar->m_bombType == ScriptParams[1]); + CAutomobile* pVehicle = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); +#ifdef FIX_BUGS + if (pVehicle->IsCar()) + UpdateCompareFlag(((CAutomobile*)pVehicle)->m_bombType == GET_INTEGER_PARAM(1)); + else if (pVehicle->IsBike()) + UpdateCompareFlag(((CBike*)pVehicle)->m_bombType == GET_INTEGER_PARAM(1)); + else + UpdateCompareFlag(false); +#else + CAutomobile* pCar = (CVehicle*)pVehicle; + UpdateCompareFlag(pCar->m_bombType != 0); //TODO: enum +#endif return 0; } - */ case COMMAND_CHANGE_CAR_COLOUR: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - if (ScriptParams[1] >= 256 || ScriptParams[2] >= 256) + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + if (GET_INTEGER_PARAM(1) >= 256 || GET_INTEGER_PARAM(2) >= 256) debug("CHANGE_CAR_COLOUR - Colours must be less than %d", 256); - pVehicle->m_currentColour1 = ScriptParams[1]; - pVehicle->m_currentColour2 = ScriptParams[2]; + pVehicle->m_currentColour1 = GET_INTEGER_PARAM(1); + pVehicle->m_currentColour2 = GET_INTEGER_PARAM(2); return 0; } case COMMAND_SWITCH_PED_ROADS_ON: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.SwitchPedRoadsOffInArea(infX, supX, infY, supY, infZ, supZ, false); return 0; @@ -496,23 +508,23 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_SWITCH_PED_ROADS_OFF: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.SwitchPedRoadsOffInArea(infX, supX, infY, supY, infZ, supZ, true); return 0; @@ -520,20 +532,20 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_CHAR_LOOK_AT_CHAR_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pSourcePed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pSourcePed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTargetPed); - pSourcePed->SetLookFlag(pTargetPed, true); + pSourcePed->SetLookFlag(pTargetPed, true, true); pSourcePed->SetLookTimer(60000); return 0; } case COMMAND_CHAR_LOOK_AT_PLAYER_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pSourcePed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pSourcePed); - CPed* pTargetPed = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pTargetPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; script_assert(pTargetPed); pSourcePed->SetLookFlag(pTargetPed, true); pSourcePed->SetLookTimer(60000); @@ -542,9 +554,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_PLAYER_LOOK_AT_CHAR_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pSourcePed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pSourcePed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pSourcePed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTargetPed); pSourcePed->SetLookFlag(pTargetPed, true); pSourcePed->SetLookTimer(60000); @@ -553,7 +565,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_STOP_CHAR_LOOKING: { CollectParameters(&m_nIp, 1); - CPed* pSourcePed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pSourcePed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pSourcePed); pSourcePed->ClearLookFlag(); pSourcePed->bKeepTryingToLook = false; @@ -564,7 +576,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_STOP_PLAYER_LOOKING: { CollectParameters(&m_nIp, 1); - CPed* pSourcePed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pSourcePed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pSourcePed); pSourcePed->ClearLookFlag(); pSourcePed->bKeepTryingToLook = false; @@ -575,7 +587,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) /* case COMMAND_SWITCH_HELICOPTER: CollectParameters(&m_nIp, 1); - CHeli::ActivateHeli(ScriptParams[0] != 0); + CHeli::ActivateHeli(GET_INTEGER_PARAM(0) != 0); return 0; */ //case COMMAND_SET_GANG_ATTITUDE: @@ -583,33 +595,33 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) //case COMMAND_SET_GANG_PLAYER_ATTITUDE: case COMMAND_SET_GANG_PED_MODELS: CollectParameters(&m_nIp, 3); - CGangs::SetGangPedModels(ScriptParams[0], ScriptParams[1], ScriptParams[2]); + CGangs::SetGangPedModels(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; case COMMAND_SET_GANG_CAR_MODEL: CollectParameters(&m_nIp, 2); - CGangs::SetGangVehicleModel(ScriptParams[0], ScriptParams[1]); + CGangs::SetGangVehicleModel(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_SET_GANG_WEAPONS: CollectParameters(&m_nIp, 3); - CGangs::SetGangWeapons(ScriptParams[0], (eWeaponType)ScriptParams[1], (eWeaponType)ScriptParams[2]); + CGangs::SetGangWeapons(GET_INTEGER_PARAM(0), (eWeaponType)GET_INTEGER_PARAM(1), (eWeaponType)GET_INTEGER_PARAM(2)); return 0; /* case COMMAND_SET_CHAR_OBJ_RUN_TO_AREA: { CollectParameters(&m_nIp, 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - float infX = *(float*)&ScriptParams[1]; - float infY = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; + float infX = GET_FLOAT_PARAM(1); + float infY = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; @@ -624,11 +636,11 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_SET_CHAR_OBJ_RUN_TO_COORD: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos; - pos.x = *(float*)&ScriptParams[1]; - pos.y = *(float*)&ScriptParams[2]; + pos.x = GET_FLOAT_PARAM(1); + pos.y = GET_FLOAT_PARAM(2); pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_RUN_TO_AREA, pos); @@ -638,9 +650,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_IS_PLAYER_TOUCHING_OBJECT_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); bool isTouching = false; if (pPed->bInVehicle) isTouching = false; @@ -652,9 +664,9 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) case COMMAND_IS_CHAR_TOUCHING_OBJECT_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); bool isTouching = false; if (pPed->InVehicle()) isTouching = false; @@ -671,119 +683,137 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) strncpy(name, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) name[i] = tolower(name[i]); - CStreaming::RequestSpecialChar(ScriptParams[0] - 1, name, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_SCRIPTOWNED); + CStreaming::RequestSpecialChar(GET_INTEGER_PARAM(0) - 1, name, STREAMFLAGS_DEPENDENCY | (m_bIsMissionScript ? STREAMFLAGS_SCRIPTOWNED : STREAMFLAGS_AMBIENT_SCRIPT_OWNED)); m_nIp += KEY_LENGTH_IN_SCRIPT; return 0; } case COMMAND_HAS_SPECIAL_CHARACTER_LOADED: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CStreaming::HasSpecialCharLoaded(ScriptParams[0] - 1)); + UpdateCompareFlag(CStreaming::HasSpecialCharLoaded(GET_INTEGER_PARAM(0) - 1)); return 0; } /* case COMMAND_FLASH_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bHasBlip = (ScriptParams[1] != 0); + pVehicle->bHasBlip = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_FLASH_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bHasBlip = (ScriptParams[1] != 0); + pPed->bHasBlip = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_FLASH_OBJECT: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bHasBlip = (ScriptParams[1] != 0); + pObject->bHasBlip = (GET_INTEGER_PARAM(1) != 0); return 0; } */ case COMMAND_IS_PLAYER_IN_REMOTE_MODE: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].IsPlayerInRemoteMode()); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].IsPlayerInRemoteMode()); return 0; - /* case COMMAND_ARM_CAR_WITH_BOMB: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); - ((CAutomobile*)pVehicle)->m_bombType = ScriptParams[1]; +#ifdef FIX_BUGS + if (pVehicle->IsCar()) { + ((CAutomobile*)pVehicle)->m_bombType = GET_INTEGER_PARAM(1); + ((CAutomobile*)pVehicle)->m_pBombRigger = FindPlayerPed(); + } + else if (pVehicle->IsBike()) { + ((CBike*)pVehicle)->m_bombType = GET_INTEGER_PARAM(1); + ((CBike*)pVehicle)->m_pBombRigger = FindPlayerPed(); + } +#else + ((CAutomobile*)pVehicle)->m_bombType = GET_INTEGER_PARAM(1); ((CAutomobile*)pVehicle)->m_pBombRigger = FindPlayerPed(); +#endif return 0; } - */ case COMMAND_SET_CHAR_PERSONALITY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->SetPedStats((ePedStats)ScriptParams[1]); + pPed->SetPedStats((ePedStats)GET_INTEGER_PARAM(1)); return 0; } case COMMAND_SET_CUTSCENE_OFFSET: CollectParameters(&m_nIp, 3); - CCutsceneMgr::SetCutsceneOffset(*(CVector*)&ScriptParams[0]); + CCutsceneMgr::SetCutsceneOffset(GET_VECTOR_PARAM(0)); return 0; case COMMAND_SET_ANIM_GROUP_FOR_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_animGroup = (AssocGroupId)ScriptParams[1]; + pPed->m_animGroup = (AssocGroupId)GET_INTEGER_PARAM(1); + pPed->bOverrideMoveAnim = false; return 0; } /* case COMMAND_SET_ANIM_GROUP_FOR_PLAYER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->m_animGroup = (AssocGroupId)ScriptParams[1]; + pPed->m_animGroup = (AssocGroupId)GET_INTEGER_PARAM(1); return 0; } */ case COMMAND_REQUEST_MODEL: { CollectParameters(&m_nIp, 1); - int model = ScriptParams[0]; + int model = GET_INTEGER_PARAM(0); if (model < 0) model = CTheScripts::UsedObjectArray[-model].index; - CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_NOFADE | STREAMFLAGS_SCRIPTOWNED); + CStreaming::RequestModel(model, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_NOFADE | (m_bIsMissionScript ? STREAMFLAGS_SCRIPTOWNED : STREAMFLAGS_AMBIENT_SCRIPT_OWNED)); + if (model == MI_MINIGUN) +#ifdef FIX_BUGS + CStreaming::RequestModel(MI_MINIGUN2, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_NOFADE | (m_bIsMissionScript ? STREAMFLAGS_SCRIPTOWNED : STREAMFLAGS_AMBIENT_SCRIPT_OWNED)); +#else + CStreaming::RequestModel(MI_MINIGUN2, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_NOFADE | STREAMFLAGS_SCRIPTOWNED); +#endif return 0; } case COMMAND_HAS_MODEL_LOADED: { CollectParameters(&m_nIp, 1); - int model = ScriptParams[0]; + int model = GET_INTEGER_PARAM(0); if (model < 0) model = CTheScripts::UsedObjectArray[-model].index; - UpdateCompareFlag(CStreaming::HasModelLoaded(model)); + UpdateCompareFlag(CStreaming::HasModelLoaded(model)/* || cWorldStream::Instance()->pDynamic(model, 0) */); // TODO return 0; } case COMMAND_MARK_MODEL_AS_NO_LONGER_NEEDED: { CollectParameters(&m_nIp, 1); - int model = ScriptParams[0]; + int model = GET_INTEGER_PARAM(0); if (model < 0) model = CTheScripts::UsedObjectArray[-model].index; - CStreaming::SetMissionDoesntRequireModel(model); + if (m_bIsMissionScript) + CStreaming::SetMissionDoesntRequireModel(model); + else + CStreaming::SetAmbientMissionDoesntRequireModel(model); return 0; } case COMMAND_GRAB_PHONE: { CollectParameters(&m_nIp, 2); - ScriptParams[0] = gPhoneInfo.GrabPhone(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1]); + SET_INTEGER_PARAM(0, gPhoneInfo.GrabPhone(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1))); StoreParameters(&m_nIp, 1); return 0; } @@ -792,80 +822,85 @@ int8 CRunningScript::ProcessCommands500To599(int32 command) { CollectParameters(&m_nIp, 1); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text, nil, nil, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_Repeatedly(GET_INTEGER_PARAM(0), text, nil, nil, nil, nil, nil); return 0; } case COMMAND_SET_PHONE_MESSAGE: { CollectParameters(&m_nIp, 1); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text, nil, nil, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), text, nil, nil, nil, nil, nil); return 0; } case COMMAND_HAS_PHONE_DISPLAYED_MESSAGE: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(gPhoneInfo.HasMessageBeenDisplayed(ScriptParams[0])); + UpdateCompareFlag(gPhoneInfo.HasMessageBeenDisplayed(GET_INTEGER_PARAM(0))); return 0; } */ case COMMAND_TURN_PHONE_OFF: { CollectParameters(&m_nIp, 1); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], nil, nil, nil, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), nil, nil, nil, nil, nil, nil); return 0; } case COMMAND_DRAW_CORONA: { + uint32 ip = m_nIp; + int32* ptr = GetPointerToScriptVariable(&ip, 0); CollectParameters(&m_nIp, 9); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CCoronas::RegisterCorona((uintptr)this + m_nIp, ScriptParams[6], ScriptParams[7], ScriptParams[8], - 255, pos, *(float*)&ScriptParams[3], 450.0f, ScriptParams[4], ScriptParams[5], 1, 0, 0, 0.0f); + CCoronas::RegisterCorona((uintptr)ptr, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8), + 255, pos, -GET_FLOAT_PARAM(3), 450.0f, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), 1, 0, 0, 0.0f); return 0; } + /* case COMMAND_DRAW_LIGHT: { CollectParameters(&m_nIp, 6); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); CVector unused(0.0f, 0.0f, 0.0f); - CPointLights::AddLight(0, *(CVector*)&ScriptParams[0], CVector(0.0f, 0.0f, 0.0f), 12.0f, - ScriptParams[3] / 255.0f, ScriptParams[4] / 255.0f, ScriptParams[5] / 255.0f, 0, true); + CPointLights::AddLight(0, GET_VECTOR_PARAM(0), CVector(0.0f, 0.0f, 0.0f), 12.0f, + GET_INTEGER_PARAM(3) / 255.0f, GET_INTEGER_PARAM(4) / 255.0f, GET_INTEGER_PARAM(5) / 255.0f, 0, true); return 0; } - //case COMMAND_STORE_WEATHER: - //case COMMAND_RESTORE_WEATHER: + */ + case COMMAND_STORE_WEATHER: + CWeather::StoreWeatherState(); + return 0; + case COMMAND_RESTORE_WEATHER: + CWeather::RestoreWeatherState(); case COMMAND_STORE_CLOCK: CClock::StoreClock(); return 0; case COMMAND_RESTORE_CLOCK: CClock::RestoreClock(); return 0; - /* case COMMAND_RESTART_CRITICAL_MISSION: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CRestart::OverrideNextRestart(pos, *(float*)&ScriptParams[3]); + CRestart::OverrideNextRestart(pos, GET_FLOAT_PARAM(3)); if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING) printf("RESTART_CRITICAL_MISSION - Player state is not PLAYING\n"); CWorld::Players[CWorld::PlayerInFocus].PlayerFailedCriticalMission(); return 0; } - */ case COMMAND_IS_PLAYER_PLAYING: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_PLAYING); + UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState == WBSTATE_PLAYING); return 0; } #ifdef GTA_SCRIPT_COLLECTIVE case COMMAND_SET_COLL_OBJ_NO_OBJ: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_NONE); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_NONE); return 0; #endif default: @@ -880,134 +915,134 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) #ifdef GTA_SCRIPT_COLLECTIVE case COMMAND_SET_COLL_OBJ_WAIT_ON_FOOT: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_WAIT_ON_FOOT); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_WAIT_ON_FOOT); return 0; case COMMAND_SET_COLL_OBJ_FLEE_ON_FOOT_TILL_SAFE: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE); return 0; case COMMAND_SET_COLL_OBJ_GUARD_SPOT: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GUARD_AREA, pos); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GUARD_AREA, pos); return 0; } case COMMAND_SET_COLL_OBJ_GUARD_AREA: { CollectParameters(&m_nIp, 5); - float infX = *(float*)&ScriptParams[1]; - float supX = *(float*)&ScriptParams[3]; + float infX = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(3); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } - float infY = *(float*)&ScriptParams[2]; - float supY = *(float*)&ScriptParams[4]; + float infY = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(4); if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; pos.y = (infY + supY) / 2; pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); float radius = Max(pos.x - infX, pos.y - infY); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GUARD_AREA, pos, radius); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GUARD_AREA, pos, radius); return 0; } case COMMAND_SET_COLL_OBJ_WAIT_IN_CAR: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_WAIT_IN_CAR); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_WAIT_IN_CAR); return 0; case COMMAND_SET_COLL_OBJ_KILL_CHAR_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ON_FOOT, pPed); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_KILL_CHAR_ON_FOOT, pPed); return 0; } case COMMAND_SET_COLL_OBJ_KILL_PLAYER_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ON_FOOT, pPed); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_KILL_CHAR_ON_FOOT, pPed); return 0; } case COMMAND_SET_COLL_OBJ_KILL_CHAR_ANY_MEANS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ANY_MEANS, pPed); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_KILL_CHAR_ANY_MEANS, pPed); return 0; } case COMMAND_SET_COLL_OBJ_KILL_PLAYER_ANY_MEANS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_KILL_CHAR_ANY_MEANS, pPed); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_KILL_CHAR_ANY_MEANS, pPed); return 0; } case COMMAND_SET_COLL_OBJ_FLEE_CHAR_ON_FOOT_TILL_SAFE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pPed); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pPed); return 0; } case COMMAND_SET_COLL_OBJ_FLEE_PLAYER_ON_FOOT_TILL_SAFE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pPed); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_FLEE_CHAR_ON_FOOT_TILL_SAFE, pPed); return 0; } case COMMAND_SET_COLL_OBJ_FLEE_CHAR_ON_FOOT_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pPed); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pPed); return 0; } case COMMAND_SET_COLL_OBJ_FLEE_PLAYER_ON_FOOT_ALWAYS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pPed); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pPed); return 0; } case COMMAND_SET_COLL_OBJ_GOTO_CHAR_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_CHAR_ON_FOOT, pPed); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GOTO_CHAR_ON_FOOT, pPed); return 0; } case COMMAND_SET_COLL_OBJ_GOTO_PLAYER_ON_FOOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[1]].m_pPed; - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_CHAR_ON_FOOT, pPed); + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GOTO_CHAR_ON_FOOT, pPed); return 0; } case COMMAND_SET_COLL_OBJ_LEAVE_CAR: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_LEAVE_CAR); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_LEAVE_CAR); return 0; case COMMAND_SET_COLL_OBJ_ENTER_CAR_AS_PASSENGER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_ENTER_CAR_AS_PASSENGER, pVehicle); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_ENTER_CAR_AS_PASSENGER, pVehicle); return 0; } case COMMAND_SET_COLL_OBJ_ENTER_CAR_AS_DRIVER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); return 0; } /* @@ -1018,31 +1053,31 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) case COMMAND_SET_COLL_OBJ_DESTROY_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_DESTROY_CAR, pVehicle); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_DESTROY_CAR, pVehicle); return 0; } case COMMAND_SET_COLL_OBJ_GOTO_AREA_ON_FOOT: { CollectParameters(&m_nIp, 5); - float infX = *(float*)&ScriptParams[1]; - float supX = *(float*)&ScriptParams[3]; + float infX = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(3); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } - float infY = *(float*)&ScriptParams[2]; - float supY = *(float*)&ScriptParams[4]; + float infY = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(4); if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; pos.y = (infY + supY) / 2; pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); float radius = Max(pos.x - infX, pos.y - infY); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_AREA_ON_FOOT, pos, radius); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GOTO_AREA_ON_FOOT, pos, radius); return 0; } /* @@ -1052,66 +1087,66 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) */ case COMMAND_SET_COLL_OBJ_FOLLOW_ROUTE: CollectParameters(&m_nIp, 3); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FOLLOW_ROUTE, ScriptParams[1], ScriptParams[2]); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_FOLLOW_ROUTE, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; case COMMAND_SET_COLL_OBJ_GOTO_COORD_ON_FOOT: { CollectParameters(&m_nIp, 3); - CVector pos(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], CWorld::FindGroundZForCoord(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2])); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_AREA_ON_FOOT, pos); + CVector pos(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), CWorld::FindGroundZForCoord(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2))); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GOTO_AREA_ON_FOOT, pos); return 0; } //case COMMAND_SET_COLL_OBJ_GOTO_COORD_IN_CAR: case COMMAND_SET_COLL_OBJ_RUN_TO_AREA: { CollectParameters(&m_nIp, 5); - float infX = *(float*)&ScriptParams[1]; - float supX = *(float*)&ScriptParams[3]; + float infX = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(3); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } - float infY = *(float*)&ScriptParams[2]; - float supY = *(float*)&ScriptParams[4]; + float infY = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(4); if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; pos.y = (infY + supY) / 2; pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); float radius = Max(pos.x - infX, pos.y - infY); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_RUN_TO_AREA, pos, radius); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_RUN_TO_AREA, pos, radius); return 0; } case COMMAND_SET_COLL_OBJ_RUN_TO_COORD: { CollectParameters(&m_nIp, 3); - CVector pos(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], CWorld::FindGroundZForCoord(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2])); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_RUN_TO_AREA, pos); + CVector pos(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), CWorld::FindGroundZForCoord(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2))); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_RUN_TO_AREA, pos); return 0; } case COMMAND_ADD_PEDS_IN_AREA_TO_COLL: { CollectParameters(&m_nIp, 3); - float X = *(float*)&ScriptParams[0]; - float Y = *(float*)&ScriptParams[1]; + float X = GET_FLOAT_PARAM(0); + float Y = GET_FLOAT_PARAM(1); float Z = CWorld::FindGroundZForCoord(X, Y); - float radius = *(float*)&ScriptParams[2]; - ScriptParams[0] = CTheScripts::AddPedsInAreaToCollective(X, Y, Z, radius); + float radius = GET_FLOAT_PARAM(2); + SET_INTEGER_PARAM(0, CTheScripts::AddPedsInAreaToCollective(X, Y, Z, radius)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_PEDS_IN_VEHICLE_TO_COLL: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CTheScripts::AddPedsInVehicleToCollective(ScriptParams[0]); + SET_INTEGER_PARAM(0, CTheScripts::AddPedsInVehicleToCollective(GET_INTEGER_PARAM(0))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_CLEAR_COLL: CollectParameters(&m_nIp, 1); for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) { - if (CTheScripts::CollectiveArray[i].colIndex == ScriptParams[0]) { + if (CTheScripts::CollectiveArray[i].colIndex == GET_INTEGER_PARAM(0)) { CTheScripts::CollectiveArray[i].colIndex = -1; CTheScripts::CollectiveArray[i].pedIndex = 0; } @@ -1180,7 +1215,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) total++; } } - ScriptParams[0] = total; + SET_INTEGER_PARAM(0, total); StoreParameters(&m_nIp, 1); return 0; } @@ -1188,72 +1223,77 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) case COMMAND_SET_CHAR_HEED_THREATS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bRespondsToThreats = (ScriptParams[1] != 0); + pPed->bRespondsToThreats = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_PLAYER_HEED_THREATS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->bRespondsToThreats = (ScriptParams[1] != 0); + pPed->bRespondsToThreats = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_GET_CONTROLLER_MODE: #if defined(GTA_PC) && !defined(DETECT_PAD_INPUT_SWITCH) - ScriptParams[0] = 0; + SET_INTEGER_PARAM(0, 0); #else - ScriptParams[0] = CPad::IsAffectedByController ? CPad::GetPad(0)->Mode : 0; + SET_INTEGER_PARAM(0, CPad::IsAffectedByController ? CPad::GetPad(0)->Mode : 0); #endif StoreParameters(&m_nIp, 1); return 0; case COMMAND_SET_CAN_RESPRAY_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); //assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); // they DO call this for bikes, we don't really want to destroy the structure... #ifdef FIX_BUGS if (pVehicle->m_vehType == VEHICLE_TYPE_CAR) #endif - ((CAutomobile*)pVehicle)->bFixedColour = (ScriptParams[1] == 0); + ((CAutomobile*)pVehicle)->bFixedColour = (GET_INTEGER_PARAM(1) == 0); +#ifdef FIX_BUGS + else if (pVehicle->m_vehType == VEHICLE_TYPE_BIKE) + ((CBike*)pVehicle)->bFixedColour = (GET_INTEGER_PARAM(1) == 0); +#endif return 0; } - /* case COMMAND_IS_TAXI: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(pVehicle->IsTaxi()); return 0; } - */ case COMMAND_UNLOAD_SPECIAL_CHARACTER: CollectParameters(&m_nIp, 1); - CStreaming::SetMissionDoesntRequireSpecialChar(ScriptParams[0] - 1); + if (m_bIsMissionScript) + CStreaming::SetMissionDoesntRequireSpecialChar(GET_INTEGER_PARAM(0) - 1); + else + CStreaming::SetAmbientMissionDoesntRequireSpecialChar(GET_INTEGER_PARAM(0) - 1); return 0; case COMMAND_RESET_NUM_OF_MODELS_KILLED_BY_PLAYER: CDarkel::ResetModelsKilledByPlayer(); return 0; case COMMAND_GET_NUM_OF_MODELS_KILLED_BY_PLAYER: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CDarkel::QueryModelsKilledByPlayer(ScriptParams[0]); + SET_INTEGER_PARAM(0, CDarkel::QueryModelsKilledByPlayer(GET_INTEGER_PARAM(0))); StoreParameters(&m_nIp, 1); return 0; /* case COMMAND_ACTIVATE_GARAGE: CollectParameters(&m_nIp, 1); - CGarages::ActivateGarage(ScriptParams[0]); + CGarages::ActivateGarage(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SWITCH_TAXI_TIMER: { CollectParameters(&m_nIp, 1); - if (ScriptParams[0] != 0){ + if (GET_INTEGER_PARAM(0) != 0){ CWorld::Players[CWorld::PlayerInFocus].m_nUnusedTaxiTimer = CTimer::GetTimeInMilliseconds(); CWorld::Players[CWorld::PlayerInFocus].m_bUnusedTaxiThing = true; }else{ @@ -1265,10 +1305,10 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) case COMMAND_CREATE_OBJECT_NO_OFFSET: { CollectParameters(&m_nIp, 4); - int mi = ScriptParams[0] >= 0 ? ScriptParams[0] : CTheScripts::UsedObjectArray[-ScriptParams[0]].index; + int mi = GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(0)].index; CObject* pObj = new CObject(mi, false); ; pObj->ObjectCreatedBy = MISSION_OBJECT; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pObj->SetPosition(pos); @@ -1280,37 +1320,37 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) pObj->SetupBigBuilding(); CTheScripts::ClearSpaceForMissionEntity(pos, pObj); CWorld::Add(pObj); - ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObj); + SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pObj)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT); return 0; } - /* case COMMAND_IS_BOAT: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); + UpdateCompareFlag(pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT); return 0; } + /* case COMMAND_SET_CHAR_OBJ_GOTO_AREA_ANY_MEANS: { CollectParameters(&m_nIp, 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - float infX = *(float*)&ScriptParams[1]; - float infY = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; + float infX = GET_FLOAT_PARAM(1); + float infY = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; @@ -1321,105 +1361,107 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) pPed->SetObjective(OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius); return 0; } - */ #ifdef GTA_SCRIPT_COLLECTIVE case COMMAND_SET_COLL_OBJ_GOTO_AREA_ANY_MEANS: { CollectParameters(&m_nIp, 5); - float infX = *(float*)&ScriptParams[1]; - float supX = *(float*)&ScriptParams[3]; + float infX = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(3); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(1); } - float infY = *(float*)&ScriptParams[2]; - float supY = *(float*)&ScriptParams[4]; + float infY = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(4); if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(2); } CVector pos; pos.x = (infX + supX) / 2; pos.y = (infY + supY) / 2; pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); float radius = Max(pos.x - infX, pos.y - infY); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius); return 0; } #endif +*/ case COMMAND_IS_PLAYER_STOPPED: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; UpdateCompareFlag(CTheScripts::IsPlayerStopped(pPlayer)); return 0; } - /* case COMMAND_IS_CHAR_STOPPED: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(CTheScripts::IsPedStopped(pPed)); return 0; } case COMMAND_MESSAGE_WAIT: CollectParameters(&m_nIp, 2); - m_nWakeTime = CTimer::GetTimeInMilliseconds() + ScriptParams[0]; - if (ScriptParams[1] != 0) + m_nWakeTime = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(0); + if (GET_INTEGER_PARAM(1) != 0) m_bSkipWakeTime = true; return 1; + /* case COMMAND_ADD_PARTICLE_EFFECT: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CParticleObject::AddObject(ScriptParams[0], pos, ScriptParams[4] != 0); + CParticleObject::AddObject(GET_INTEGER_PARAM(0), pos, GET_INTEGER_PARAM(4) != 0); return 0; } */ case COMMAND_SWITCH_WIDESCREEN: CollectParameters(&m_nIp, 1); - if (ScriptParams[0] != 0) + if (GET_INTEGER_PARAM(0) != 0) TheCamera.SetWideScreenOn(); - else + else { + // TODO(LCS): unknown field TheCamera.SetWideScreenOff(); + } return 0; /* case COMMAND_ADD_SPRITE_BLIP_FOR_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int id = CRadar::SetEntityBlip(BLIP_CAR, ScriptParams[0], 0, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[1]); - ScriptParams[0] = id; + int id = CRadar::SetEntityBlip(BLIP_CAR, GET_INTEGER_PARAM(0), 0, BLIP_DISPLAY_BOTH); + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(1)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_SPRITE_BLIP_FOR_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int id = CRadar::SetEntityBlip(BLIP_CHAR, ScriptParams[0], 1, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[1]); - ScriptParams[0] = id; + int id = CRadar::SetEntityBlip(BLIP_CHAR, GET_INTEGER_PARAM(0), 1, BLIP_DISPLAY_BOTH); + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(1)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_SPRITE_BLIP_FOR_OBJECT: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int id = CRadar::SetEntityBlip(BLIP_OBJECT, ScriptParams[0], 6, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[1]); - ScriptParams[0] = id; + int id = CRadar::SetEntityBlip(BLIP_OBJECT, GET_INTEGER_PARAM(0), 6, BLIP_DISPLAY_BOTH); + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(1)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } @@ -1427,67 +1469,67 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) case COMMAND_ADD_SPRITE_BLIP_FOR_CONTACT_POINT: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetCoordBlip(BLIP_CONTACT_POINT, pos, 2, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[3]); - ScriptParams[0] = id; + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(3)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_SPRITE_BLIP_FOR_COORD: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - int id = CRadar::SetCoordBlip(BLIP_COORD, pos, 5, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[3]); - ScriptParams[0] = id; + int id = CRadar::SetCoordBlip(BLIP_COORD, pos, 4, BLIP_DISPLAY_BOTH); + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(3)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CHAR_ONLY_DAMAGED_BY_PLAYER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bOnlyDamagedByPlayer = (ScriptParams[1] != 0); + pPed->bOnlyDamagedByPlayer = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_CAR_ONLY_DAMAGED_BY_PLAYER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bOnlyDamagedByPlayer = (ScriptParams[1] != 0); + pVehicle->bOnlyDamagedByPlayer = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_CHAR_PROOFS: { CollectParameters(&m_nIp, 6); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bBulletProof = (ScriptParams[1] != 0); - pPed->bFireProof = (ScriptParams[2] != 0); - pPed->bExplosionProof = (ScriptParams[3] != 0); - pPed->bCollisionProof = (ScriptParams[4] != 0); - pPed->bMeleeProof = (ScriptParams[5] != 0); + pPed->bBulletProof = (GET_INTEGER_PARAM(1) != 0); + pPed->bFireProof = (GET_INTEGER_PARAM(2) != 0); + pPed->bExplosionProof = (GET_INTEGER_PARAM(3) != 0); + pPed->bCollisionProof = (GET_INTEGER_PARAM(4) != 0); + pPed->bMeleeProof = (GET_INTEGER_PARAM(5) != 0); return 0; } case COMMAND_SET_CAR_PROOFS: { CollectParameters(&m_nIp, 6); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bBulletProof = (ScriptParams[1] != 0); - pVehicle->bFireProof = (ScriptParams[2] != 0); - pVehicle->bExplosionProof = (ScriptParams[3] != 0); - pVehicle->bCollisionProof = (ScriptParams[4] != 0); - pVehicle->bMeleeProof = (ScriptParams[5] != 0); + pVehicle->bBulletProof = (GET_INTEGER_PARAM(1) != 0); + pVehicle->bFireProof = (GET_INTEGER_PARAM(2) != 0); + pVehicle->bExplosionProof = (GET_INTEGER_PARAM(3) != 0); + pVehicle->bCollisionProof = (GET_INTEGER_PARAM(4) != 0); + pVehicle->bMeleeProof = (GET_INTEGER_PARAM(5) != 0); return 0; } case COMMAND_IS_PLAYER_IN_ANGLED_AREA_2D: @@ -1507,16 +1549,16 @@ int8 CRunningScript::ProcessCommands600To699(int32 command) /* case COMMAND_DEACTIVATE_GARAGE: CollectParameters(&m_nIp, 1); - CGarages::DeActivateGarage(ScriptParams[0]); + CGarages::DeActivateGarage(GET_INTEGER_PARAM(0)); return 0; case COMMAND_GET_NUMBER_OF_CARS_COLLECTED_BY_GARAGE: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CGarages::QueryCarsCollected(ScriptParams[0]); + SET_INTEGER_PARAM(0, CGarages::QueryCarsCollected(GET_INTEGER_PARAM(0))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_HAS_CAR_BEEN_TAKEN_TO_GARAGE: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CGarages::HasThisCarBeenCollected(ScriptParams[0], ScriptParams[1] - 1)); + UpdateCompareFlag(CGarages::HasThisCarBeenCollected(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1) - 1)); return 0; */ default: @@ -1531,54 +1573,55 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) /* case COMMAND_SET_SWAT_REQUIRED: CollectParameters(&m_nIp, 1); - FindPlayerPed()->m_pWanted->m_bSwatRequired = (ScriptParams[0] != 0); + FindPlayerPed()->m_pWanted->m_bSwatRequired = (GET_INTEGER_PARAM(0) != 0); return 0; case COMMAND_SET_FBI_REQUIRED: CollectParameters(&m_nIp, 1); - FindPlayerPed()->m_pWanted->m_bFbiRequired = (ScriptParams[0] != 0); + FindPlayerPed()->m_pWanted->m_bFbiRequired = (GET_INTEGER_PARAM(0) != 0); return 0; case COMMAND_SET_ARMY_REQUIRED: CollectParameters(&m_nIp, 1); - FindPlayerPed()->m_pWanted->m_bArmyRequired = (ScriptParams[0] != 0); + FindPlayerPed()->m_pWanted->m_bArmyRequired = (GET_INTEGER_PARAM(0) != 0); return 0; */ case COMMAND_IS_CAR_IN_WATER: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pVehicle && pVehicle->bIsInWater); return 0; } case COMMAND_GET_CLOSEST_CHAR_NODE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CPathNode* pNode = &ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, 1, 999999.9f, true)]; - *(CVector*)&ScriptParams[0] = pNode->GetPosition(); + CPathNode* pNode = &ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, 1, 800.0f, true)]; + SET_VECTOR_PARAM(0, pNode->GetPosition()); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_GET_CLOSEST_CAR_NODE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - *(CVector*)&ScriptParams[0] = ThePaths.FindNodeCoorsForScript(ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true)); + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(ThePaths.FindNodeClosestToCoors(pos, 0, 800.0f, true, true))); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_CAR_GOTO_COORDINATES_ACCURATE: { CollectParameters(&m_nIp, 4); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += pVehicle->GetDistanceFromCentreOfMassToBaseOfModel(); + uint8 nOldMission = pVehicle->AutoPilot.m_nCarMission; if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, pos, false)) pVehicle->AutoPilot.m_nCarMission = MISSION_GOTO_COORDS_STRAIGHT_ACCURATE; else @@ -1586,19 +1629,20 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) pVehicle->SetStatus(STATUS_PHYSICS); pVehicle->bEngineOn = true; pVehicle->AutoPilot.m_nCruiseSpeed = Max(1, pVehicle->AutoPilot.m_nCruiseSpeed); - pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); + if (nOldMission != pVehicle->AutoPilot.m_nCarMission) + pVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds(); return 0; } /* case COMMAND_START_PACMAN_RACE: CollectParameters(&m_nIp, 1); - CPacManPickups::StartPacManRace(ScriptParams[0]); + CPacManPickups::StartPacManRace(GET_INTEGER_PARAM(0)); return 0; case COMMAND_START_PACMAN_RECORD: CPacManPickups::StartPacManRecord(); return 0; case COMMAND_GET_NUMBER_OF_POWER_PILLS_EATEN: - ScriptParams[0] = CPacManPickups::QueryPowerPillsEatenInRace(); + SET_INTEGER_PARAM(0, CPacManPickups::QueryPowerPillsEatenInRace()); StoreParameters(&m_nIp, 1); return 0; case COMMAND_CLEAR_PACMAN: @@ -1607,14 +1651,14 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_START_PACMAN_SCRAMBLE: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CPacManPickups::StartPacManScramble(pos, *(float*)&ScriptParams[3], ScriptParams[4]); + CPacManPickups::StartPacManScramble(pos, GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4)); return 0; } case COMMAND_GET_NUMBER_OF_POWER_PILLS_CARRIED: - ScriptParams[0] = CPacManPickups::QueryPowerPillsCarriedByPlayer(); + SET_INTEGER_PARAM(0, CPacManPickups::QueryPowerPillsCarriedByPlayer()); StoreParameters(&m_nIp, 1); return 0; case COMMAND_CLEAR_NUMBER_OF_POWER_PILLS_CARRIED: @@ -1624,7 +1668,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_CAR_ON_SCREEN: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(TheCamera.IsSphereVisible(pVehicle->GetBoundCentre(), pVehicle->GetBoundRadius())); return 0; @@ -1632,7 +1676,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_CHAR_ON_SCREEN: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(TheCamera.IsSphereVisible(pPed->GetBoundCentre(), pPed->GetBoundRadius())); return 0; @@ -1640,67 +1684,65 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_OBJECT_ON_SCREEN: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(TheCamera.IsSphereVisible(pObject->GetBoundCentre(), pObject->GetBoundRadius())); return 0; } - /* case COMMAND_GOSUB_FILE: { CollectParameters(&m_nIp, 2); script_assert(m_nStackPointer < MAX_STACK_DEPTH); m_anStack[m_nStackPointer++] = m_nIp; - SetIP(ScriptParams[0]); - // ScriptParams[1] == filename + SetIP(GET_INTEGER_PARAM(0)); + // GET_INTEGER_PARAM(1) == filename return 0; } - */ case COMMAND_GET_GROUND_Z_FOR_3D_COORD: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); bool success; - *(float*)&ScriptParams[0] = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &success); + SET_FLOAT_PARAM(0, CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &success)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_START_SCRIPT_FIRE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - ScriptParams[0] = gFireManager.StartScriptFire(pos, nil, 0.8f, 1); + SET_INTEGER_PARAM(0, gFireManager.StartScriptFire(pos, nil, 0.8f, 1)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_SCRIPT_FIRE_EXTINGUISHED: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(gFireManager.IsScriptFireExtinguish(ScriptParams[0])); + UpdateCompareFlag(gFireManager.IsScriptFireExtinguish(GET_INTEGER_PARAM(0))); return 0; case COMMAND_REMOVE_SCRIPT_FIRE: CollectParameters(&m_nIp, 1); - gFireManager.RemoveScriptFire(ScriptParams[0]); + gFireManager.RemoveScriptFire(GET_INTEGER_PARAM(0)); return 0; /* case COMMAND_SET_COMEDY_CONTROLS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bComedyControls = (ScriptParams[1] != 0); + pVehicle->bComedyControls = (GET_INTEGER_PARAM(1) != 0); return 0; } */ case COMMAND_BOAT_GOTO_COORDS: { CollectParameters(&m_nIp, 4); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); CBoat* pBoat = (CBoat*)pVehicle; - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &pos.z, false); pBoat->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_ASTHECROWSWIMS; @@ -1714,7 +1756,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_BOAT_STOP: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); CBoat* pBoat = (CBoat*)pVehicle; @@ -1727,49 +1769,53 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_PLAYER_SHOOTING_IN_AREA: { CollectParameters(&m_nIp, 6); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CHAR_SHOOTING_IN_AREA: { CollectParameters(&m_nIp, 6); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - float x1 = *(float*)&ScriptParams[1]; - float y1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; + float x1 = GET_FLOAT_PARAM(1); + float y1 = GET_FLOAT_PARAM(2); + float x2 = GET_FLOAT_PARAM(3); + float y2 = GET_FLOAT_PARAM(4); UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); - if (ScriptParams[5]) + if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CURRENT_PLAYER_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - UpdateCompareFlag(ScriptParams[1] == pPed->GetWeapon()->m_eWeaponType); + UpdateCompareFlag(GET_INTEGER_PARAM(1) == pPed->GetWeapon()->m_eWeaponType); return 0; } case COMMAND_IS_CURRENT_CHAR_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(ScriptParams[1] == pPed->GetWeapon()->m_eWeaponType); + UpdateCompareFlag(GET_INTEGER_PARAM(1) == pPed->GetWeapon()->m_eWeaponType); return 0; } /* @@ -1779,7 +1825,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_ADD_POWER_PILL: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CPacManPickups::GenerateOnePMPickUp(pos); @@ -1789,23 +1835,22 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_SET_BOAT_CRUISE_SPEED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT); CBoat* pBoat = (CBoat*)pVehicle; - pBoat->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1]; + pBoat->AutoPilot.m_nCruiseSpeed = GET_FLOAT_PARAM(1); return 0; } - /* case COMMAND_GET_RANDOM_CHAR_IN_AREA: { - CollectParameters(&m_nIp, 4); + 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); @@ -1821,9 +1866,9 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) continue; if (pPed->bFadeOut) continue; -// if (pPed->GetModelIndex() == MI_SCUM_WOM || pPed->GetModelIndex() == MI_SCUM_MAN) -// continue; - if (!ThisIsAValidRandomPed(pPed->m_nPedType)) + if (pPed->m_nWaitState != WAITSTATE_FALSE) + continue; + if (!ThisIsAValidRandomPed(pPed->m_nPedType, GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7))) continue; if (pPed->bIsLeader || pPed->m_leader) continue; @@ -1841,11 +1886,10 @@ int8 CRunningScript::ProcessCommands700To799(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; } - */ case COMMAND_GET_RANDOM_CHAR_IN_ZONE: { char zone[KEY_LENGTH_IN_SCRIPT]; @@ -1874,7 +1918,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) continue; if (pPed->m_nWaitState != WAITSTATE_FALSE) continue; - if (!ThisIsAValidRandomPed(pPed->m_nPedType, ScriptParams[0], ScriptParams[1], ScriptParams[2])) + if (!ThisIsAValidRandomPed(pPed->m_nPedType, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2))) continue; if (pPed->bIsLeader || pPed->m_leader) continue; @@ -1896,14 +1940,14 @@ int8 CRunningScript::ProcessCommands700To799(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; } case COMMAND_IS_PLAYER_IN_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->IsTaxi()); return 0; @@ -1911,7 +1955,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_PLAYER_SHOOTING: { 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->bIsShooting); return 0; @@ -1919,7 +1963,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_CHAR_SHOOTING: { 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->bIsShooting); return 0; @@ -1927,28 +1971,28 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_CREATE_MONEY_PICKUP: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_MONEY, PICKUP_MONEY, ScriptParams[3]); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_MONEY, PICKUP_MONEY, GET_INTEGER_PARAM(3))); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CHAR_ACCURACY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_wepAccuracy = ScriptParams[1]; + pPed->m_wepAccuracy = Min(100, GET_INTEGER_PARAM(1) * 1.25f); return 0; } case COMMAND_GET_CAR_SPEED: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - *(float*)&ScriptParams[0] = pVehicle->GetSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND; + SET_FLOAT_PARAM(0, pVehicle->GetSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND); StoreParameters(&m_nIp, 1); return 0; } @@ -1956,15 +2000,17 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { char name[KEY_LENGTH_IN_SCRIPT]; strncpy(name, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); + // unknown call FUN_29df68(name) on PS2 - not on PSP m_nIp += KEY_LENGTH_IN_SCRIPT; + CColStore::RemoveAllCollision(); CCutsceneMgr::LoadCutsceneData(name); return 0; } case COMMAND_CREATE_CUTSCENE_OBJECT: { CollectParameters(&m_nIp, 1); - CCutsceneObject* pCutObj = CCutsceneMgr::CreateCutsceneObject(ScriptParams[0]); - ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pCutObj); + CCutsceneObject* pCutObj = CCutsceneMgr::CreateCutsceneObject(GET_INTEGER_PARAM(0)); + SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pCutObj)); StoreParameters(&m_nIp, 1); return 0; } @@ -1972,7 +2018,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { CollectParameters(&m_nIp, 1); char name[KEY_LENGTH_IN_SCRIPT]; - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); strncpy(name, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; @@ -1980,16 +2026,23 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) return 0; } case COMMAND_START_CUTSCENE: - CCutsceneMgr::ms_cutsceneLoadStatus = 1; + CCutsceneMgr::StartCutscene(); return 0; case COMMAND_GET_CUTSCENE_TIME: - ScriptParams[0] = CCutsceneMgr::GetCutsceneTimeInMilleseconds(); + SET_INTEGER_PARAM(0, CCutsceneMgr::GetCutsceneTimeInMilleseconds()); StoreParameters(&m_nIp, 1); return 0; case COMMAND_HAS_CUTSCENE_FINISHED: - UpdateCompareFlag(CCutsceneMgr::HasCutsceneFinished()); + { + bool bFinished = CCutsceneMgr::HasCutsceneFinished(); + if (bFinished) + printf("cutscene has now finished\n"); + UpdateCompareFlag(bFinished); return 0; + } case COMMAND_CLEAR_CUTSCENE: + // unknown call on PS2 FUN_29DFA0() - not on PSP + printf("clear cutscene\n"); CCutsceneMgr::DeleteCutsceneData(); return 0; case COMMAND_RESTORE_CAMERA_JUMPCUT: @@ -1998,37 +2051,37 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_CREATE_COLLECTABLE1: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; - CPickups::GenerateNewOne(pos, MI_COLLECTABLE1, PICKUP_COLLECTABLE1, 0); + CPickups::GenerateNewOne(pos, MI_COLLECTABLE1, PICKUP_COLLECTABLE1, 0); // TODO: gpModelIndices return 0; } case COMMAND_SET_COLLECTABLE1_TOTAL: CollectParameters(&m_nIp, 1); - CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages = ScriptParams[0]; + CWorld::Players[CWorld::PlayerInFocus].m_nTotalPackages = GET_INTEGER_PARAM(0); return 0; /* case COMMAND_IS_PROJECTILE_IN_AREA: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } UpdateCompareFlag(CProjectileInfo::IsProjectileInRange(infX, supX, infY, supY, infZ, supZ, false)); if (CTheScripts::DbgFlag) @@ -2038,23 +2091,23 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_DESTROY_PROJECTILES_IN_AREA: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } UpdateCompareFlag(CProjectileInfo::IsProjectileInRange(infX, supX, infY, supY, infZ, supZ, true)); if (CTheScripts::DbgFlag) @@ -2064,7 +2117,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_DROP_MINE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GenerateNewOne(pos, MI_CARMINE, PICKUP_MINE_INACTIVE, 0); @@ -2073,7 +2126,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_DROP_NAUTICAL_MINE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GenerateNewOne(pos, MI_NAUTICALMINE, PICKUP_MINE_INACTIVE, 0); @@ -2083,9 +2136,9 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_CHAR_MODEL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(ScriptParams[1] == pPed->GetModelIndex()); + UpdateCompareFlag(GET_INTEGER_PARAM(1) == pPed->GetModelIndex()); return 0; } case COMMAND_LOAD_SPECIAL_MODEL: @@ -2095,7 +2148,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) strncpy(name, (const char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) name[i] = tolower(name[i]); - CStreaming::RequestSpecialModel(ScriptParams[0], name, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_SCRIPTOWNED); + CStreaming::RequestSpecialModel(GET_INTEGER_PARAM(0), name, STREAMFLAGS_DEPENDENCY | (m_bIsMissionScript ? STREAMFLAGS_SCRIPTOWNED : STREAMFLAGS_AMBIENT_SCRIPT_OWNED)); m_nIp += KEY_LENGTH_IN_SCRIPT; return 0; } @@ -2103,102 +2156,98 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) //case COMMAND_SET_CUTSCENE_HEAD_ANIM: case COMMAND_SIN: CollectParameters(&m_nIp, 1); - *(float*)&ScriptParams[0] = Sin(DEGTORAD(*(float*)&ScriptParams[0])); + SET_FLOAT_PARAM(0, Sin(DEGTORAD(GET_FLOAT_PARAM(0)))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_COS: CollectParameters(&m_nIp, 1); - *(float*)&ScriptParams[0] = Cos(DEGTORAD(*(float*)&ScriptParams[0])); + SET_FLOAT_PARAM(0, Cos(DEGTORAD(GET_FLOAT_PARAM(0)))); StoreParameters(&m_nIp, 1); return 0; case COMMAND_GET_CAR_FORWARD_X: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); float forwardX = pVehicle->GetForward().x / pVehicle->GetForward().Magnitude2D(); - *(float*)&ScriptParams[0] = forwardX; + SET_FLOAT_PARAM(0, forwardX); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_CAR_FORWARD_Y: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); float forwardY = pVehicle->GetForward().y / pVehicle->GetForward().Magnitude2D(); - *(float*)&ScriptParams[0] = forwardY; + SET_FLOAT_PARAM(0, forwardY); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CHANGE_GARAGE_TYPE: CollectParameters(&m_nIp, 2); - CGarages::ChangeGarageType(ScriptParams[0], ScriptParams[1], 0); + CGarages::ChangeGarageType(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), 0); return 0; - /* case COMMAND_ACTIVATE_CRUSHER_CRANE: { CollectParameters(&m_nIp, 10); - float infX = *(float*)&ScriptParams[2]; - float infY = *(float*)&ScriptParams[3]; - float supX = *(float*)&ScriptParams[4]; - float supY = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(2); + float infY = GET_FLOAT_PARAM(3); + float supX = GET_FLOAT_PARAM(4); + float supY = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[4]; - supX = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(4); + supX = GET_FLOAT_PARAM(2); } if (infY > supY) { - infY = *(float*)&ScriptParams[5]; - supY = *(float*)&ScriptParams[3]; + infY = GET_FLOAT_PARAM(5); + supY = GET_FLOAT_PARAM(3); } CCranes::ActivateCrane(infX, supX, infY, supY, - *(float*)&ScriptParams[6], *(float*)&ScriptParams[7], *(float*)&ScriptParams[8], - DEGTORAD(*(float*)&ScriptParams[9]), true, false, - *(float*)&ScriptParams[0], *(float*)&ScriptParams[1]); + GET_FLOAT_PARAM(6), GET_FLOAT_PARAM(7), GET_FLOAT_PARAM(8), + DEGTORAD(GET_FLOAT_PARAM(9)), true, false, + GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1)); return 0; } case COMMAND_PRINT_WITH_2_NUMBERS: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); - CMessages::AddMessageWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); + CMessages::AddMessageWithNumber(text, GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1); return 0; } - */ case COMMAND_PRINT_WITH_2_NUMBERS_NOW: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); - CMessages::AddMessageJumpQWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); + CMessages::AddMessageJumpQWithNumber(text, GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1); return 0; } - /* case COMMAND_PRINT_WITH_2_NUMBERS_SOON: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); - CMessages::AddMessageSoonWithNumber(text, ScriptParams[2], ScriptParams[3], ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); + CMessages::AddMessageSoonWithNumber(text, GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1); return 0; } - */ case COMMAND_PRINT_WITH_3_NUMBERS: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); - CMessages::AddMessageWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); + CMessages::AddMessageWithNumber(text, GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), -1, -1, -1); return 0; } - /* case COMMAND_PRINT_WITH_3_NUMBERS_NOW: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); - CMessages::AddMessageJumpQWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); + CMessages::AddMessageJumpQWithNumber(text, GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), -1, -1, -1); return 0; } + /* case COMMAND_PRINT_WITH_3_NUMBERS_SOON: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); - CMessages::AddMessageSoonWithNumber(text, ScriptParams[3], ScriptParams[4], ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); + CMessages::AddMessageSoonWithNumber(text, GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), -1, -1, -1); return 0; } */ @@ -2206,7 +2255,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); - CMessages::AddMessageWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); + CMessages::AddMessageWithNumber(text, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), -1, -1); return 0; } /* @@ -2214,35 +2263,35 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); - CMessages::AddMessageJumpQWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); + CMessages::AddMessageJumpQWithNumber(text, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), -1, -1); return 0; } case COMMAND_PRINT_WITH_4_NUMBERS_SOON: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); - CMessages::AddMessageSoonWithNumber(text, ScriptParams[4], ScriptParams[5], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); + CMessages::AddMessageSoonWithNumber(text, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), -1, -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); - CMessages::AddMessageWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); + CMessages::AddMessageWithNumber(text, GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS_NOW: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); - CMessages::AddMessageJumpQWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); + CMessages::AddMessageJumpQWithNumber(text, GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS_SOON: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); - CMessages::AddMessageSoonWithNumber(text, ScriptParams[5], ScriptParams[6], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); + CMessages::AddMessageSoonWithNumber(text, GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), -1); return 0; } */ @@ -2250,7 +2299,7 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); - CMessages::AddMessageWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); + CMessages::AddMessageWithNumber(text, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5)); return 0; } /* @@ -2258,71 +2307,69 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); - CMessages::AddMessageJumpQWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); + CMessages::AddMessageJumpQWithNumber(text, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5)); return 0; } case COMMAND_PRINT_WITH_6_NUMBERS_SOON: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); - CMessages::AddMessageSoonWithNumber(text, ScriptParams[6], ScriptParams[7], ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); + CMessages::AddMessageSoonWithNumber(text, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5)); return 0; } + */ case COMMAND_SET_CHAR_OBJ_FOLLOW_CHAR_IN_FORMATION: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FOLLOW_CHAR_IN_FORMATION, pTargetPed); - pPed->SetFormation((eFormation)ScriptParams[2]); + pPed->SetFormation((eFormation)GET_INTEGER_PARAM(2)); return 0; } - */ case COMMAND_PLAYER_MADE_PROGRESS: CollectParameters(&m_nIp, 1); - CStats::ProgressMade += ScriptParams[0]; + CStats::ProgressMade += GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_PROGRESS_TOTAL: CollectParameters(&m_nIp, 1); - CStats::TotalProgressInGame = ScriptParams[0]; - if (CGame::germanGame) - CStats::TotalProgressInGame -= 2; + CStats::TotalProgressInGame = GET_INTEGER_PARAM(0); return 0; case COMMAND_REGISTER_JUMP_DISTANCE: CollectParameters(&m_nIp, 1); - CStats::MaximumJumpDistance = Max(CStats::MaximumJumpDistance, *(float*)&ScriptParams[0]); + CStats::MaximumJumpDistance = Max(CStats::MaximumJumpDistance, GET_FLOAT_PARAM(0)); return 0; case COMMAND_REGISTER_JUMP_HEIGHT: CollectParameters(&m_nIp, 1); - CStats::MaximumJumpHeight = Max(CStats::MaximumJumpHeight, *(float*)&ScriptParams[0]); + CStats::MaximumJumpHeight = Max(CStats::MaximumJumpHeight, GET_FLOAT_PARAM(0)); return 0; case COMMAND_REGISTER_JUMP_FLIPS: CollectParameters(&m_nIp, 1); - CStats::MaximumJumpFlips = Max(CStats::MaximumJumpFlips, ScriptParams[0]); + CStats::MaximumJumpFlips = Max(CStats::MaximumJumpFlips, GET_INTEGER_PARAM(0)); return 0; case COMMAND_REGISTER_JUMP_SPINS: CollectParameters(&m_nIp, 1); - CStats::MaximumJumpSpins = Max(CStats::MaximumJumpSpins, ScriptParams[0]); + CStats::MaximumJumpSpins = Max(CStats::MaximumJumpSpins, GET_INTEGER_PARAM(0)); return 0; case COMMAND_REGISTER_JUMP_STUNT: CollectParameters(&m_nIp, 1); - CStats::BestStuntJump = Max(CStats::BestStuntJump, ScriptParams[0]); + CStats::BestStuntJump = Max(CStats::BestStuntJump, GET_INTEGER_PARAM(0)); return 0; case COMMAND_REGISTER_UNIQUE_JUMP_FOUND: ++CStats::NumberOfUniqueJumpsFound; return 0; case COMMAND_SET_UNIQUE_JUMPS_TOTAL: CollectParameters(&m_nIp, 1); - CStats::TotalNumberOfUniqueJumps = ScriptParams[0]; + CStats::TotalNumberOfUniqueJumps = GET_INTEGER_PARAM(0); return 0; case COMMAND_REGISTER_PASSENGER_DROPPED_OFF_TAXI: ++CStats::PassengersDroppedOffWithTaxi; return 0; case COMMAND_REGISTER_MONEY_MADE_TAXI: CollectParameters(&m_nIp, 1); - CStats::MoneyMadeWithTaxi += ScriptParams[0]; + CStats::MoneyMadeWithTaxi += GET_INTEGER_PARAM(0); return 0; case COMMAND_REGISTER_MISSION_GIVEN: ++CStats::MissionsGiven; @@ -2342,9 +2389,9 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_SET_CHAR_RUNNING: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIsRunning = (ScriptParams[1] != 0); + pPed->bIsRunning = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_REMOVE_ALL_SCRIPT_FIRES: @@ -2354,32 +2401,32 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_FIRST_CAR_COLOUR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(pVehicle->m_currentColour1 == ScriptParams[1]); + UpdateCompareFlag(pVehicle->m_currentColour1 == GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_SECOND_CAR_COLOUR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(pVehicle->m_currentColour2 == ScriptParams[1]); + UpdateCompareFlag(pVehicle->m_currentColour2 == GET_INTEGER_PARAM(1)); return 0; } */ case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); bool result = false; if (!pPed) printf("HAS_CHAR_BEEN_DAMAGED_BY_WEAPON - Character doesn't exist\n"); else { - if (ScriptParams[1] == WEAPONTYPE_ANYMELEE || ScriptParams[1] == WEAPONTYPE_ANYWEAPON) - result = CheckDamagedWeaponType(pPed->m_lastWepDam, ScriptParams[1]); + if (GET_INTEGER_PARAM(1) == WEAPONTYPE_ANYMELEE || GET_INTEGER_PARAM(1) == WEAPONTYPE_ANYWEAPON) + result = CheckDamagedWeaponType(pPed->m_lastWepDam, GET_INTEGER_PARAM(1)); else - result = ScriptParams[1] == pPed->m_lastWepDam; + result = GET_INTEGER_PARAM(1) == pPed->m_lastWepDam; } UpdateCompareFlag(result); return 0; @@ -2387,15 +2434,15 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_WEAPON: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); bool result = false; if (!pVehicle) printf("HAS_CAR_BEEN_DAMAGED_BY_WEAPON - Vehicle doesn't exist\n"); else { - if (ScriptParams[1] == WEAPONTYPE_ANYMELEE || ScriptParams[1] == WEAPONTYPE_ANYWEAPON) - result = CheckDamagedWeaponType(pVehicle->m_nLastWeaponDamage, ScriptParams[1]); + if (GET_INTEGER_PARAM(1) == WEAPONTYPE_ANYMELEE || GET_INTEGER_PARAM(1) == WEAPONTYPE_ANYWEAPON) + result = CheckDamagedWeaponType(pVehicle->m_nLastWeaponDamage, GET_INTEGER_PARAM(1)); else - result = ScriptParams[1] == pVehicle->m_nLastWeaponDamage; + result = GET_INTEGER_PARAM(1) == pVehicle->m_nLastWeaponDamage; } UpdateCompareFlag(result); return 0; @@ -2403,8 +2450,8 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) case COMMAND_IS_CHAR_IN_CHARS_GROUP: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pLeader = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pLeader = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pPed); script_assert(pLeader); UpdateCompareFlag(pPed->m_leader == pLeader && !pPed->bWaitForLeaderToComeCloser); diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 16a4ddae..91c45bf2 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -41,19 +41,12 @@ #include "Bike.h" #include "Wanted.h" +// LCS: file done except TODOs + #ifdef FIX_BUGS static bool IsSlideObjectUsedWrongByScript(const CVector& posTarget, const CVector& slideBy) { - if (posTarget == CVector(-559.476f, 784.807f, 23.279f) && slideBy == CVector(0.0f, 10.0f, 0.0f)) - return true; // G-Spotlight bottom elevator, east side - if (posTarget == CVector(-559.476f, 779.64f, 23.279f) && slideBy == CVector(0.0f, 10.0f, 0.0f)) - return true; // G-Spotlight bottom elevator, west side - if (posTarget == CVector(-553.563f, 790.595f, 97.917f) && slideBy == CVector(0.0f, 10.0f, 0.0f)) - return true; // G-Spotlight top elevator, east side - if (posTarget == CVector(-553.563f, 785.427f, 97.917f) && slideBy == CVector(0.0f, 10.0f, 0.0f)) - return true; // G-Spotlight top elevator, west side - if (posTarget == CVector(-866.689f, -572.095f, 15.573f) && slideBy == CVector(0.0f, 0.0f, 4.5f)) - return true; // Cherry Popper garage door + // TODO? return false; } #endif @@ -65,8 +58,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_IS_CHAR_IN_PLAYERS_GROUP: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pLeader = CWorld::Players[ScriptParams[1]].m_pPed; + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pLeader = CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed; script_assert(pPed); script_assert(pLeader); UpdateCompareFlag(pPed->m_leader == pLeader && !pPed->bWaitForLeaderToComeCloser); @@ -75,7 +68,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_EXPLODE_CHAR_HEAD: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->InflictDamage(nil, WEAPONTYPE_SNIPERRIFLE, 1000.0f, PEDPIECE_HEAD, 0); return 0; @@ -83,7 +76,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_EXPLODE_PLAYER_HEAD: { 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); pPed->InflictDamage(nil, WEAPONTYPE_SNIPERRIFLE, 1000.0f, PEDPIECE_HEAD, 0); return 0; @@ -91,9 +84,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_ANCHOR_BOAT: { CollectParameters(&m_nIp, 2); - CBoat* pBoat = (CBoat*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CBoat* pBoat = (CBoat*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pBoat && pBoat->m_vehType == VEHICLE_TYPE_BOAT); - pBoat->m_bIsAnchored = (ScriptParams[1] != 0); + pBoat->m_bIsAnchored = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_ZONE_GROUP: @@ -108,7 +101,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) return 0; } while (zone_id >= 0) { - CTheZones::SetPedGroup(zone_id, ScriptParams[0], ScriptParams[1]); + CTheZones::SetPedGroup(zone_id, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); zone_id = CTheZones::FindNextZoneByLabelAndReturnIndex(zone, ZONE_INFO); } return 0; @@ -116,18 +109,18 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_START_CAR_FIRE: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = gFireManager.StartScriptFire(pVehicle->GetPosition(), pVehicle, 0.8f, 1); + SET_INTEGER_PARAM(0, gFireManager.StartScriptFire(pVehicle->GetPosition(), pVehicle, 0.8f, 1)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_START_CHAR_FIRE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = gFireManager.StartScriptFire(pPed->GetPosition(), pPed, 0.8f, 1); + SET_INTEGER_PARAM(0, gFireManager.StartScriptFire(pPed->GetPosition(), pPed, 0.8f, 1)); StoreParameters(&m_nIp, 1); return 0; } @@ -136,10 +129,10 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 5); int handle = -1; 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) @@ -148,7 +141,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) continue; if (!pVehicle->bUsesCollision) continue; - if (ScriptParams[4] != pVehicle->GetModelIndex() && ScriptParams[4] >= 0) + if (GET_INTEGER_PARAM(4) != pVehicle->GetModelIndex() && GET_INTEGER_PARAM(4) >= 0) continue; if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE) continue; @@ -161,7 +154,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR); } - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } @@ -181,7 +174,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) continue; - if (ScriptParams[0] != pVehicle->GetModelIndex() && ScriptParams[0] >= 0) + if (GET_INTEGER_PARAM(0) != pVehicle->GetModelIndex() && GET_INTEGER_PARAM(0) >= 0) continue; if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE) continue; @@ -194,7 +187,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR); } - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } @@ -202,38 +195,38 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_HAS_RESPRAY_HAPPENED: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CGarages::HasResprayHappened(ScriptParams[0])); + UpdateCompareFlag(CGarages::HasResprayHappened(GET_INTEGER_PARAM(0))); return 0; } case COMMAND_SET_CAMERA_ZOOM: { CollectParameters(&m_nIp, 1); if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FOLLOWPED) - TheCamera.SetZoomValueFollowPedScript(ScriptParams[0]); + TheCamera.SetZoomValueFollowPedScript(GET_INTEGER_PARAM(0)); else if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_CAM_ON_A_STRING) - TheCamera.SetZoomValueCamStringScript(ScriptParams[0]); + TheCamera.SetZoomValueCamStringScript(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_CREATE_PICKUP_WITH_AMMO: { CollectParameters(&m_nIp, 6); - int16 model = ScriptParams[0]; + int16 model = GET_INTEGER_PARAM(0); if (model < 0) model = CTheScripts::UsedObjectArray[-model].index; - CVector pos = *(CVector*)&ScriptParams[3]; + CVector pos = GET_VECTOR_PARAM(3); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, model, ScriptParams[1], ScriptParams[2]); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, model, GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2))); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CAR_RAM_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CCarAI::TellCarToRamOtherCar(pVehicle, pTarget); return 0; @@ -242,9 +235,9 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SET_CAR_BLOCK_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CCarAI::TellCarToBlockOtherCar(pVehicle, pTarget); return 0; @@ -252,115 +245,112 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SET_CHAR_OBJ_CATCH_TRAIN: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_CATCH_TRAIN); return 0; } - */ #ifdef GTA_SCRIPT_COLLECTIVE case COMMAND_SET_COLL_OBJ_CATCH_TRAIN: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_CATCH_TRAIN); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_CATCH_TRAIN); return 0; #endif + */ case COMMAND_SET_PLAYER_NEVER_GETS_TIRED: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; - pPlayer->m_bInfiniteSprint = (ScriptParams[1] != 0); + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayer->m_bInfiniteSprint = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_PLAYER_FAST_RELOAD: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]]; - pPlayer->m_bFastReload = (ScriptParams[1] != 0); + CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayer->m_bFastReload = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_CHAR_BLEEDING: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bPedIsBleeding = (ScriptParams[1] != 0); + pPed->bPedIsBleeding = (GET_INTEGER_PARAM(1) != 0); return 0; } /* case COMMAND_SET_CAR_FUNNY_SUSPENSION: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); // no action return 0; - } + */ case COMMAND_SET_CAR_BIG_WHEELS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; - pCar->bBigWheels = (ScriptParams[1] != 0); + pCar->bBigWheels = (GET_INTEGER_PARAM(1) != 0); return 0; } - */ case COMMAND_SET_FREE_RESPRAYS: CollectParameters(&m_nIp, 1); - CGarages::SetFreeResprays(ScriptParams[0] != 0); + CGarages::SetFreeResprays(GET_INTEGER_PARAM(0) != 0); return 0; case COMMAND_SET_PLAYER_VISIBLE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->bIsVisible = (ScriptParams[1] != 0); + pPed->bIsVisible = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_SET_CHAR_VISIBLE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIsVisible = (ScriptParams[1] != 0); + pPed->bIsVisible = (GET_INTEGER_PARAM(1) != 0); return 0; } - /* case COMMAND_SET_CAR_VISIBLE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bIsVisible = (ScriptParams[1] != 0); + pVehicle->bIsVisible = (GET_INTEGER_PARAM(1) != 0); return 0; } - */ case COMMAND_IS_AREA_OCCUPIED: { CollectParameters(&m_nIp, 11); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } int16 total; CWorld::FindObjectsIntersectingCube(CVector(infX, infY, infZ), CVector(supX, supY, supZ), &total, 2, nil, - !!ScriptParams[6], !!ScriptParams[7], !!ScriptParams[8], !!ScriptParams[9], !!ScriptParams[10]); + !!GET_INTEGER_PARAM(6), !!GET_INTEGER_PARAM(7), !!GET_INTEGER_PARAM(8), !!GET_INTEGER_PARAM(9), !!GET_INTEGER_PARAM(10)); UpdateCompareFlag(total > 0); return 0; } @@ -376,15 +366,15 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) return 0; case COMMAND_SAVE_PLAYER_FROM_FIRES: CollectParameters(&m_nIp, 1); - gFireManager.ExtinguishPoint(CWorld::Players[ScriptParams[0]].GetPos(), 3.0f); + gFireManager.ExtinguishPoint(CWorld::Players[GET_INTEGER_PARAM(0)].GetPos(), 3.0f); return 0; */ case COMMAND_DISPLAY_TEXT: { CollectParameters(&m_nIp, 2); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = GET_FLOAT_PARAM(0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = GET_FLOAT_PARAM(1); uint16 len = CMessages::GetWideStringLength(text); for (uint16 i = 0; i < len; i++) CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_Text[i] = text[i]; @@ -396,47 +386,47 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SET_TEXT_SCALE: { CollectParameters(&m_nIp, 2); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fScaleX = *(float*)&ScriptParams[0]; - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fScaleY = *(float*)&ScriptParams[1]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fScaleX = GET_FLOAT_PARAM(0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fScaleY = GET_FLOAT_PARAM(1); return 0; } case COMMAND_SET_TEXT_COLOUR: { CollectParameters(&m_nIp, 4); CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_sColor = - CRGBA(ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3]); + CRGBA(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3)); return 0; } case COMMAND_SET_TEXT_JUSTIFY: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bJustify = (ScriptParams[0] != 0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bJustify = (GET_INTEGER_PARAM(0) != 0); return 0; } case COMMAND_SET_TEXT_CENTRE: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bCentered = (ScriptParams[0] != 0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bCentered = (GET_INTEGER_PARAM(0) != 0); return 0; } case COMMAND_SET_TEXT_WRAPX: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fWrapX = *(float*)&ScriptParams[0]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fWrapX = GET_FLOAT_PARAM(0); return 0; } /* case COMMAND_SET_TEXT_CENTRE_SIZE: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fCenterSize = *(float*)&ScriptParams[0]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fCenterSize = GET_FLOAT_PARAM(0); return 0; } */ case COMMAND_SET_TEXT_BACKGROUND: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bBackground = (ScriptParams[0] != 0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bBackground = (GET_INTEGER_PARAM(0) != 0); return 0; } /* @@ -444,53 +434,56 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) { CollectParameters(&m_nIp, 4); CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_sBackgroundColor = - CRGBA(ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3]); + CRGBA(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3)); return 0; } case COMMAND_SET_TEXT_BACKGROUND_ONLY_TEXT: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bBackgroundOnly = (ScriptParams[0] != 0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bBackgroundOnly = (GET_INTEGER_PARAM(0) != 0); return 0; } */ case COMMAND_SET_TEXT_PROPORTIONAL: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bTextProportional = (ScriptParams[0] != 0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bTextProportional = (GET_INTEGER_PARAM(0) != 0); return 0; } /* case COMMAND_SET_TEXT_FONT: { CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_nFont = ScriptParams[0]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_nFont = GET_INTEGER_PARAM(0); return 0; } + */ case COMMAND_INDUSTRIAL_PASSED: - CStats::IndustrialPassed = true; - DMAudio.PlayRadioAnnouncement(STREAMED_SOUND_ANNOUNCE_COMMERCIAL_OPEN); + CollectParameters(&m_nIp, 1); + CStats::IndustrialPassed = GET_INTEGER_PARAM(0); return 0; case COMMAND_COMMERCIAL_PASSED: - CStats::CommercialPassed = true; - DMAudio.PlayRadioAnnouncement(STREAMED_SOUND_ANNOUNCE_SUBURBAN_OPEN); + CollectParameters(&m_nIp, 1); + CStats::CommercialPassed = GET_INTEGER_PARAM(0); return 0; case COMMAND_SUBURBAN_PASSED: - CStats::SuburbanPassed = true; + CollectParameters(&m_nIp, 1); + CStats::SuburbanPassed = GET_INTEGER_PARAM(0); return 0; - */ case COMMAND_ROTATE_OBJECT: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); + float fx = pObject->GetForward().x; + float fy = pObject->GetForward().y; float heading = LimitAngleOnCircle( RADTODEG(Atan2(-pObject->GetForward().x, pObject->GetForward().y))); - float headingTarget = *(float*)&ScriptParams[1]; + float headingTarget = GET_FLOAT_PARAM(1); #ifdef FIX_BUGS - float rotateBy = *(float*)&ScriptParams[2] * CTimer::GetTimeStepFix(); + float rotateBy = GET_FLOAT_PARAM(2) * CTimer::GetTimeStepFix(); #else - float rotateBy = *(float*)&ScriptParams[2]; + float rotateBy = GET_FLOAT_PARAM(2); #endif if (headingTarget == heading) { // using direct comparasion here is fine UpdateCompareFlag(true); @@ -504,7 +497,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) else newHeading = rotateBy < angleCounterclockwise ? heading - rotateBy : headingTarget; bool obstacleInPath = false; - if (ScriptParams[3]) { + if (GET_INTEGER_PARAM(3)) { CVector pos = pObject->GetPosition(); tmp_matrix.SetRotateZ(DEGTORAD(newHeading)); tmp_matrix.GetPosition() += pos; @@ -536,11 +529,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SLIDE_OBJECT: { CollectParameters(&m_nIp, 8); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CVector pos = pObject->GetPosition(); - CVector posTarget = *(CVector*)&ScriptParams[1]; - CVector slideBy = *(CVector*)&ScriptParams[4]; + CVector posTarget = GET_VECTOR_PARAM(1); + CVector slideBy = GET_VECTOR_PARAM(4); #ifdef FIX_BUGS // the check is a hack for original script, where some objects are moved // via SLIDE_OBJECT instead of SET_OBJECT_POSITION @@ -568,7 +561,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) else newPosition.z = posDiff.z < slideBy.z ? posTarget.z : pos.z - slideBy.z; bool obstacleInPath = false; - if (ScriptParams[7]) { + if (GET_INTEGER_PARAM(7)) { tmp_matrix = pObject->GetMatrix(); tmp_matrix.GetPosition() = newPosition; CColModel* pColModel = pObject->GetColModel(); @@ -597,7 +590,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_REMOVE_CHAR_ELEGANTLY: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); if (pPed && pPed->CharCreatedBy == MISSION_CHAR){ CWorld::RemoveReferencesToDeletedObject(pPed); if (pPed->bInVehicle && pPed->m_pMyVehicle) @@ -613,15 +606,15 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) } } if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_SET_CHAR_STAY_IN_SAME_PLACE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bKindaStayInSamePlace = (ScriptParams[1] != 0); + pPed->bKindaStayInSamePlace = (GET_INTEGER_PARAM(1) != 0); return 0; } /* @@ -632,7 +625,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_UNDRESS_CHAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); char name[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, name); @@ -645,7 +638,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_DRESS_CHAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->Dress(); return 0; @@ -655,37 +648,39 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 1); CTimer::Suspend(); CStreaming::DeleteAllRwObjects(); - CRecordDataForChase::StartChaseScene(*(float*)&ScriptParams[0]); + CRecordDataForChase::StartChaseScene(GET_FLOAT_PARAM(0)); CTimer::Resume(); return 0; case COMMAND_STOP_CHASE_SCENE: CRecordDataForChase::CleanUpChaseScene(); return 0; + */ case COMMAND_IS_EXPLOSION_IN_AREA: { CollectParameters(&m_nIp, 7); - float infX = *(float*)&ScriptParams[1]; - float infY = *(float*)&ScriptParams[2]; - float infZ = *(float*)&ScriptParams[3]; - float supX = *(float*)&ScriptParams[4]; - float supY = *(float*)&ScriptParams[5]; - float supZ = *(float*)&ScriptParams[6]; + float infX = GET_FLOAT_PARAM(1); + float infY = GET_FLOAT_PARAM(2); + float infZ = GET_FLOAT_PARAM(3); + float supX = GET_FLOAT_PARAM(4); + float supY = GET_FLOAT_PARAM(5); + float supZ = GET_FLOAT_PARAM(6); if (infX > supX) { - infX = *(float*)&ScriptParams[4]; - supX = *(float*)&ScriptParams[1]; + infX = GET_FLOAT_PARAM(4); + supX = GET_FLOAT_PARAM(1); } if (infY > supY) { - infY = *(float*)&ScriptParams[5]; - supY = *(float*)&ScriptParams[2]; + infY = GET_FLOAT_PARAM(5); + supY = GET_FLOAT_PARAM(2); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0], + UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)GET_INTEGER_PARAM(0), infX, supX, infY, supY, infZ, supZ)); return 0; } + /* case COMMAND_IS_EXPLOSION_IN_ZONE: { CollectParameters(&m_nIp, 1); @@ -695,7 +690,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) if (zone_id != -1) m_nIp += KEY_LENGTH_IN_SCRIPT; CZone* pZone = CTheZones::GetNavigationZone(zone_id); - UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0], + UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)GET_INTEGER_PARAM(0), pZone->minx, pZone->maxx, pZone->miny, pZone->maxy, pZone->minz, pZone->maxz)); return 0; } @@ -708,17 +703,17 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_FIND_DROP_OFF_PLANE_COORDINATES: { CVector pos = CPlane::FindDropOffCesnaCoordinates(); - *(CVector*)&ScriptParams[0] = pos; + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_CREATE_FLOATING_PACKAGE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_FLOATPACKAGE1, PICKUP_FLOATINGPACKAGE, 0); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_FLOATPACKAGE1, PICKUP_FLOATINGPACKAGE, 0)); StoreParameters(&m_nIp, 1); return 0; } @@ -726,58 +721,58 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_PLACE_OBJECT_RELATIVE_TO_CAR: { CollectParameters(&m_nIp, 5); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); - CVector offset = *(CVector*)&ScriptParams[2]; + CVector offset = GET_VECTOR_PARAM(2); CPhysical::PlacePhysicalRelativeToOtherPhysical(pVehicle, pObject, offset); return 0; } case COMMAND_MAKE_OBJECT_TARGETTABLE: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CPlayerPed* pPlayerPed = CWorld::Players[CWorld::PlayerInFocus].m_pPed; script_assert(pPlayerPed); - pPlayerPed->MakeObjectTargettable(ScriptParams[0]); + pPlayerPed->MakeObjectTargettable(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_ADD_ARMOUR_TO_PLAYER: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPlayerPed); - pPlayerPed->m_fArmour = Clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, CWorld::Players[ScriptParams[0]].m_nMaxArmour); + pPlayerPed->m_fArmour = Clamp(pPlayerPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMaxArmour); return 0; } case COMMAND_ADD_ARMOUR_TO_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_fArmour = Clamp(pPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f); + pPed->m_fArmour = Clamp(pPed->m_fArmour + GET_INTEGER_PARAM(1), 0.0f, 100.0f); return 0; } case COMMAND_OPEN_GARAGE: { CollectParameters(&m_nIp, 1); - CGarages::OpenGarage(ScriptParams[0]); + CGarages::OpenGarage(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_CLOSE_GARAGE: { CollectParameters(&m_nIp, 1); - CGarages::CloseGarage(ScriptParams[0]); + CGarages::CloseGarage(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_WARP_CHAR_FROM_CAR_TO_COORD: { CollectParameters(&m_nIp, 4); - CPed *pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed *pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); if (pPed->bInVehicle){ @@ -794,7 +789,22 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) pPed->m_pMyVehicle->RemovePassenger(pPed); } if (pPed->m_vehDoor) { - if (pPed->GetPedState() == PED_EXIT_CAR || pPed->GetPedState() == PED_DRAG_FROM_CAR) { + eDoors door; + switch (pPed->m_vehDoor) { + case CAR_DOOR_LF: + door = DOOR_FRONT_LEFT; + break; + case CAR_DOOR_RF: + door = DOOR_FRONT_RIGHT; + break; + case CAR_DOOR_LR: + door = DOOR_REAR_LEFT; + break; + case CAR_DOOR_RR: + door = DOOR_REAR_RIGHT; + break; + } + if (pPed->GetPedState() == PED_EXIT_CAR || pPed->GetPedState() == PED_DRAG_FROM_CAR || !pPed->m_pMyVehicle->IsDoorClosed(door)) { uint8 flags = 0; if (pPed->m_pMyVehicle->IsBike()) { if (pPed->m_vehDoor == CAR_DOOR_LF || @@ -848,11 +858,11 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_SET_VISIBILITY_OF_CLOSEST_OBJECT_OF_TYPE: { CollectParameters(&m_nIp, 6); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float range = *(float*)&ScriptParams[3]; - int mi = ScriptParams[4] < 0 ? CTheScripts::UsedObjectArray[-ScriptParams[4]].index : ScriptParams[4]; + float range = GET_FLOAT_PARAM(3); + int mi = GET_INTEGER_PARAM(4) < 0 ? CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(4)].index : GET_INTEGER_PARAM(4); int16 total; CEntity* apEntities[16]; CWorld::FindObjectsOfTypeInRange(mi, pos, range, true, &total, 16, apEntities, true, false, false, true, true); @@ -870,27 +880,25 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) } } if (pClosestEntity) { - pClosestEntity->bIsVisible = (ScriptParams[5] != 0); - CTheScripts::AddToInvisibilitySwapArray(pClosestEntity, ScriptParams[5] != 0); + pClosestEntity->bIsVisible = (GET_INTEGER_PARAM(5) != 0); + CTheScripts::AddToInvisibilitySwapArray(pClosestEntity, GET_INTEGER_PARAM(5) != 0); } return 0; } - /* case COMMAND_HAS_CHAR_SPOTTED_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); UpdateCompareFlag(pPed->OurPedCanSeeThisOne(pTarget)); return 0; } - */ case COMMAND_SET_CHAR_OBJ_HAIL_TAXI: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_HAIL_TAXI); @@ -899,110 +907,113 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_HAS_OBJECT_BEEN_DAMAGED: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(pObject->bRenderDamaged || !pObject->bIsVisible); return 0; } - /* case COMMAND_START_KILL_FRENZY_HEADSHOT: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); - CDarkel::StartFrenzy((eWeaponType)ScriptParams[0], ScriptParams[1], ScriptParams[2], - ScriptParams[3], text, ScriptParams[4], ScriptParams[5], - ScriptParams[6], ScriptParams[7] != 0, true); + CDarkel::StartFrenzy((eWeaponType)GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), + GET_INTEGER_PARAM(3), text, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), + GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7) != 0, true); return 0; } case COMMAND_ACTIVATE_MILITARY_CRANE: { CollectParameters(&m_nIp, 10); - float infX = *(float*)&ScriptParams[2]; - float infY = *(float*)&ScriptParams[3]; - float supX = *(float*)&ScriptParams[4]; - float supY = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(2); + float infY = GET_FLOAT_PARAM(3); + float supX = GET_FLOAT_PARAM(4); + float supY = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[4]; - supX = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(4); + supX = GET_FLOAT_PARAM(2); } if (infY > supY) { - infY = *(float*)&ScriptParams[5]; - supY = *(float*)&ScriptParams[3]; + infY = GET_FLOAT_PARAM(5); + supY = GET_FLOAT_PARAM(3); } CCranes::ActivateCrane(infX, supX, infY, supY, - *(float*)&ScriptParams[6], *(float*)&ScriptParams[7], *(float*)&ScriptParams[8], - DEGTORAD(*(float*)&ScriptParams[9]), false, true, - *(float*)&ScriptParams[0], *(float*)&ScriptParams[1]); + GET_FLOAT_PARAM(6), GET_FLOAT_PARAM(7), GET_FLOAT_PARAM(8), + DEGTORAD(GET_FLOAT_PARAM(9)), false, true, + GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1)); return 0; } - */ case COMMAND_WARP_PLAYER_INTO_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); pPed->WarpPedIntoCar(pVehicle); + pPed->RestorePreviousObjective(); return 0; } case COMMAND_WARP_CHAR_INTO_CAR: { 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); pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle); pPed->WarpPedIntoCar(pVehicle); + pPed->RestorePreviousObjective(); return 0; } - //case COMMAND_SWITCH_CAR_RADIO: + case COMMAND_SWITCH_CAR_RADIO: + CollectParameters(&m_nIp, 1); + DMAudio.ChangeMusicMode(GET_INTEGER_PARAM(0)); + return 0; //case COMMAND_SET_AUDIO_STREAM: case COMMAND_PRINT_WITH_2_NUMBERS_BIG: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 4); - CMessages::AddBigMessageWithNumber(text, ScriptParams[2], ScriptParams[3] - 1, ScriptParams[0], ScriptParams[1], -1, -1, -1, -1); + CMessages::AddBigMessageWithNumber(text, GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3) - 1, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1); return 0; } - /* case COMMAND_PRINT_WITH_3_NUMBERS_BIG: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 5); - CMessages::AddBigMessageWithNumber(text, ScriptParams[3], ScriptParams[4] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], -1, -1, -1); + CMessages::AddBigMessageWithNumber(text, GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4) - 1, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), -1, -1, -1); return 0; } + /* case COMMAND_PRINT_WITH_4_NUMBERS_BIG: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 6); - CMessages::AddBigMessageWithNumber(text, ScriptParams[4], ScriptParams[5] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], -1, -1); + CMessages::AddBigMessageWithNumber(text, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5) - 1, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), -1, -1); return 0; } case COMMAND_PRINT_WITH_5_NUMBERS_BIG: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 7); - CMessages::AddBigMessageWithNumber(text, ScriptParams[5], ScriptParams[6] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], -1); + CMessages::AddBigMessageWithNumber(text, GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6) - 1, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), -1); return 0; } case COMMAND_PRINT_WITH_6_NUMBERS_BIG: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 8); - CMessages::AddBigMessageWithNumber(text, ScriptParams[6], ScriptParams[7] - 1, ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3], ScriptParams[4], ScriptParams[5]); + CMessages::AddBigMessageWithNumber(text, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7) - 1, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5)); return 0; } */ case COMMAND_SET_CHAR_WAIT_STATE: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->SetWaitState((eWaitState)ScriptParams[1], ScriptParams[2] >= 0 ? &ScriptParams[2] : nil); + pPed->SetWaitState((eWaitState)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2) >= 0 ? &GET_INTEGER_PARAM(2) : nil); return 0; } case COMMAND_SET_CAMERA_BEHIND_PLAYER: @@ -1011,14 +1022,14 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) /* case COMMAND_SET_MOTION_BLUR: CollectParameters(&m_nIp, 1); - TheCamera.SetMotionBlur(0, 0, 0, 0, ScriptParams[0]); + TheCamera.SetMotionBlur(0, 0, 0, 0, GET_INTEGER_PARAM(0)); return 0; case COMMAND_PRINT_STRING_IN_STRING: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* string = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessageWithString(text, ScriptParams[0], ScriptParams[1], string); + CMessages::AddMessageWithString(text, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), string); return 0; } */ @@ -1045,7 +1056,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) ped->bRespondsToThreats = false; ped->bAllowMedicsToReviveMe = false; ped->bIsPlayerFriend = false; - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z += 1.0f; @@ -1057,16 +1068,16 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CWorld::Add(ped); ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); CPopulation::ms_nTotalMissionPeds++; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(ped)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_STEAL_ANY_CAR); @@ -1078,7 +1089,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 1); wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, nil, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_Repeatedly(GET_INTEGER_PARAM(0), text1, text2, nil, nil, nil, nil); return 0; } case COMMAND_SET_2_PHONE_MESSAGES: @@ -1086,7 +1097,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) CollectParameters(&m_nIp, 1); wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, nil, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), text1, text2, nil, nil, nil, nil); return 0; } case COMMAND_SET_3_REPEATED_PHONE_MESSAGES: @@ -1095,7 +1106,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_Repeatedly(GET_INTEGER_PARAM(0), text1, text2, text3, nil, nil, nil); return 0; } case COMMAND_SET_3_PHONE_MESSAGES: @@ -1104,7 +1115,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, nil, nil, nil); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), text1, text2, text3, nil, nil, nil); return 0; } case COMMAND_SET_4_REPEATED_PHONE_MESSAGES: @@ -1114,7 +1125,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, nil, nil); + gPhoneInfo.SetPhoneMessage_Repeatedly(GET_INTEGER_PARAM(0), text1, text2, text3, text4, nil, nil); return 0; } case COMMAND_SET_4_PHONE_MESSAGES: @@ -1124,30 +1135,30 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) wchar* text2 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, nil, nil); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), text1, text2, text3, text4, nil, nil); return 0; } */ case COMMAND_IS_SNIPER_BULLET_IN_AREA: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } UpdateCompareFlag(CBulletInfo::TestForSniperBullet(infX, supX, infY, supY, infZ, supZ)); return 0; @@ -1156,33 +1167,33 @@ int8 CRunningScript::ProcessCommands800To899(int32 command) case COMMAND_GIVE_PLAYER_DETONATOR: CGarages::GivePlayerDetonator(); return 0; - */ #ifdef GTA_SCRIPT_COLLECTIVE case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR: CollectParameters(&m_nIp, 1); - CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_STEAL_ANY_CAR); + CTheScripts::SetObjectiveForAllPedsInCollective(GET_INTEGER_PARAM(0), OBJECTIVE_STEAL_ANY_CAR); return 0; #endif + */ case COMMAND_SET_OBJECT_VELOCITY: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->SetMoveSpeed(*(CVector*)&ScriptParams[1] * METERS_PER_SECOND_TO_GAME_SPEED); + pObject->SetMoveSpeed(GET_VECTOR_PARAM(1) * METERS_PER_SECOND_TO_GAME_SPEED); return 0; } case COMMAND_SET_OBJECT_COLLISION: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bUsesCollision = (ScriptParams[1] != 0); + pObject->bUsesCollision = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_IS_ICECREAM_JINGLE_ON: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); // Adding this check to correspond to command name. // All original game scripts always assume that the vehicle is actually Mr. Whoopee, @@ -1207,7 +1218,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) wchar* source = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* pstr = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - CMessages::AddMessageJumpQWithString(source, ScriptParams[0], ScriptParams[1], pstr); + CMessages::AddMessageJumpQWithString(source, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), pstr); return 0; } //case COMMAND_PRINT_STRING_IN_STRING_SOON: @@ -1220,7 +1231,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, text5, nil); + gPhoneInfo.SetPhoneMessage_Repeatedly(GET_INTEGER_PARAM(0), text1, text2, text3, text4, text5, nil); return 0; } case COMMAND_SET_5_PHONE_MESSAGES: @@ -1231,7 +1242,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) wchar* text3 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, text5, nil); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), text1, text2, text3, text4, text5, nil); return 0; } case COMMAND_SET_6_REPEATED_PHONE_MESSAGES: @@ -1243,7 +1254,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text6 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_Repeatedly(ScriptParams[0], text1, text2, text3, text4, text5, text6); + gPhoneInfo.SetPhoneMessage_Repeatedly(GET_INTEGER_PARAM(0), text1, text2, text3, text4, text5, text6); return 0; } case COMMAND_SET_6_PHONE_MESSAGES: @@ -1255,19 +1266,19 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) wchar* text4 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text5 = CTheScripts::GetTextByKeyFromScript(&m_nIp); wchar* text6 = CTheScripts::GetTextByKeyFromScript(&m_nIp); - gPhoneInfo.SetPhoneMessage_JustOnce(ScriptParams[0], text1, text2, text3, text4, text5, text6); + gPhoneInfo.SetPhoneMessage_JustOnce(GET_INTEGER_PARAM(0), text1, text2, text3, text4, text5, text6); return 0; } */ case COMMAND_IS_POINT_OBSCURED_BY_A_MISSION_ENTITY: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0] - *(float*)&ScriptParams[3]; - float supX = *(float*)&ScriptParams[0] + *(float*)&ScriptParams[3]; - float infY = *(float*)&ScriptParams[1] - *(float*)&ScriptParams[4]; - float supY = *(float*)&ScriptParams[1] + *(float*)&ScriptParams[4]; - float infZ = *(float*)&ScriptParams[2] - *(float*)&ScriptParams[5]; - float supZ = *(float*)&ScriptParams[2] + *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0) - GET_FLOAT_PARAM(3); + float supX = GET_FLOAT_PARAM(0) + GET_FLOAT_PARAM(3); + float infY = GET_FLOAT_PARAM(1) - GET_FLOAT_PARAM(4); + float supY = GET_FLOAT_PARAM(1) + GET_FLOAT_PARAM(4); + float infZ = GET_FLOAT_PARAM(2) - GET_FLOAT_PARAM(5); + float supZ = GET_FLOAT_PARAM(2) + GET_FLOAT_PARAM(5); if (infX > supX) { float tmp = infX; infX = supX; @@ -1304,19 +1315,20 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_ADD_TO_OBJECT_VELOCITY: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->AddToMoveSpeed(*(CVector*)&ScriptParams[1] * METERS_PER_SECOND_TO_GAME_SPEED); + pObject->AddToMoveSpeed(GET_VECTOR_PARAM(1) * METERS_PER_SECOND_TO_GAME_SPEED); return 0; } + /* case COMMAND_DRAW_SPRITE: { CollectParameters(&m_nIp, 9); CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_bIsUsed = true; - CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_nTextureId = ScriptParams[0] - 1; + CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_nTextureId = GET_INTEGER_PARAM(0) - 1; CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_sRect = CRect( - *(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[1] + *(float*)&ScriptParams[3], *(float*)&ScriptParams[2] + *(float*)&ScriptParams[4]); - CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_sColor = CRGBA(ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8]); + GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(1) + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(2) + GET_FLOAT_PARAM(4)); + CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_sColor = CRGBA(GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8)); CTheScripts::NumberOfIntroRectanglesThisFrame++; return 0; } @@ -1326,8 +1338,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_bIsUsed = true; CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_nTextureId = -1; CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_sRect = CRect( - *(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[0] + *(float*)&ScriptParams[2], *(float*)&ScriptParams[1] + *(float*)&ScriptParams[3]); - CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_sColor = CRGBA(ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7]); + GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(0) + GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(1) + GET_FLOAT_PARAM(3)); + CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_sColor = CRGBA(GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7)); CTheScripts::NumberOfIntroRectanglesThisFrame++; return 0; } @@ -1341,7 +1353,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) int slot = CTxdStore::FindTxdSlot("script"); CTxdStore::PushCurrentTxd(); CTxdStore::SetCurrentTxd(slot); - CTheScripts::ScriptSprites[ScriptParams[0] - 1].SetTexture(str); + CTheScripts::ScriptSprites[GET_INTEGER_PARAM(0) - 1].SetTexture(str); CTxdStore::PopCurrentTxd(); return 0; } @@ -1363,12 +1375,13 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CTheScripts::RemoveScriptTextureDictionary(); return 0; } + */ case COMMAND_SET_OBJECT_DYNAMIC: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { if (pObject->bIsStatic) { pObject->SetIsStatic(false); pObject->AddToMovingList(); @@ -1386,11 +1399,11 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_SET_CHAR_ANIM_SPEED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CAnimBlendAssociation* pAssoc = RpAnimBlendClumpGetFirstAssociation(pPed->GetClump()); if (pAssoc) - pAssoc->speed = *(float*)&ScriptParams[1]; + pAssoc->speed = GET_FLOAT_PARAM(1); return 0; } */ @@ -1398,126 +1411,132 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) { CollectParameters(&m_nIp, 1); DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); - DMAudio.PlayFrontEndTrack(ScriptParams[0] + STREAMED_SOUND_MISSION_COMPLETED - 1, FALSE); + DMAudio.PlayFrontEndTrack(GET_INTEGER_PARAM(0) + STREAMED_SOUND_MISSION_COMPLETED - 1, FALSE); +#ifndef GTA_PSP + //DMAudio.SaveAnnouncementsWhenMissionPassedPlayed(); // TODO! +#endif return 0; } case COMMAND_CLEAR_AREA: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CWorld::ClearExcitingStuffFromArea(pos, *(float*)&ScriptParams[3], ScriptParams[4]); + CWorld::ClearExcitingStuffFromArea(pos, GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4)); +#ifdef GTA_MOBILE + // CPopulation::ms_blockPedCreationForAFrame = true; +#endif return 0; } case COMMAND_FREEZE_ONSCREEN_TIMER: CollectParameters(&m_nIp, 1); - CUserDisplay::OnscnTimer.m_bDisabled = ScriptParams[0] != 0; + CUserDisplay::OnscnTimer.m_bDisabled = GET_INTEGER_PARAM(0) != 0; return 0; case COMMAND_SWITCH_CAR_SIREN: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->m_bSirenOrAlarm = ScriptParams[1] != 0; + pVehicle->m_bSirenOrAlarm = GET_INTEGER_PARAM(1) != 0; return 0; } /* case COMMAND_SWITCH_PED_ROADS_ON_ANGLED: { CollectParameters(&m_nIp, 7); - ThePaths.SwitchRoadsInAngledArea(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2], - *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], *(float*)&ScriptParams[5], *(float*)&ScriptParams[6], 0, 1); + ThePaths.SwitchRoadsInAngledArea(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), GET_FLOAT_PARAM(5), GET_FLOAT_PARAM(6), 0, 1); return 0; } + */ case COMMAND_SWITCH_PED_ROADS_OFF_ANGLED: CollectParameters(&m_nIp, 7); - ThePaths.SwitchRoadsInAngledArea(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2], - *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], *(float*)&ScriptParams[5], *(float*)&ScriptParams[6], 0, 0); + ThePaths.SwitchRoadsInAngledArea(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), GET_FLOAT_PARAM(5), GET_FLOAT_PARAM(6), 0, 0); return 0; + /* case COMMAND_SWITCH_ROADS_ON_ANGLED: CollectParameters(&m_nIp, 7); - ThePaths.SwitchRoadsInAngledArea(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2], - *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], *(float*)&ScriptParams[5], *(float*)&ScriptParams[6], 1, 1); + ThePaths.SwitchRoadsInAngledArea(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), GET_FLOAT_PARAM(5), GET_FLOAT_PARAM(6), 1, 1); return 0; case COMMAND_SWITCH_ROADS_OFF_ANGLED: CollectParameters(&m_nIp, 7); - ThePaths.SwitchRoadsInAngledArea(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2], - *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], *(float*)&ScriptParams[5], *(float*)&ScriptParams[6], 1, 0); + ThePaths.SwitchRoadsInAngledArea(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), GET_FLOAT_PARAM(5), GET_FLOAT_PARAM(6), 1, 0); return 0; - */ + */ case COMMAND_SET_CAR_WATERTIGHT: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); if (pVehicle->IsBike()) { CBike* pBike = (CBike*)pVehicle; - pBike->bWaterTight = ScriptParams[1] != 0; + pBike->bWaterTight = GET_INTEGER_PARAM(1) != 0; } else if (pVehicle->IsCar()) { CAutomobile* pCar = (CAutomobile*)pVehicle; - pCar->bWaterTight = ScriptParams[1] != 0; + pCar->bWaterTight = GET_INTEGER_PARAM(1) != 0; } return 0; } case COMMAND_ADD_MOVING_PARTICLE_EFFECT: { CollectParameters(&m_nIp, 12); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float size = Max(0.0f, *(float*)&ScriptParams[7]); - eParticleObjectType type = (eParticleObjectType)ScriptParams[0]; + float size = Max(0.0f, GET_FLOAT_PARAM(7)); + eParticleObjectType type = (eParticleObjectType)GET_INTEGER_PARAM(0); RwRGBA color; if (type == POBJECT_SMOKE_TRAIL){ color.alpha = -1; - color.red = ScriptParams[8]; - color.green = ScriptParams[9]; - color.blue = ScriptParams[10]; + color.red = GET_INTEGER_PARAM(8); + color.green = GET_INTEGER_PARAM(9); + color.blue = GET_INTEGER_PARAM(10); }else{ color.alpha = color.red = color.blue = color.green = 0; } - CVector target = *(CVector*)&ScriptParams[4]; - CParticleObject::AddObject(type, pos, target, size, ScriptParams[11], color, 1); + CVector target = GET_VECTOR_PARAM(4); + CParticleObject::AddObject(type, pos, target, size, GET_INTEGER_PARAM(11), color, 1); return 0; } case COMMAND_SET_CHAR_CANT_BE_DRAGGED_OUT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bDontDragMeOutCar = ScriptParams[1] != 0; + pPed->bDontDragMeOutCar = GET_INTEGER_PARAM(1) != 0; return 0; } case COMMAND_TURN_CAR_TO_FACE_COORD: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); const CVector& pos = pVehicle->GetPosition(); - float heading = CGeneral::GetATanOfXY(pos.x - *(float*)&ScriptParams[1], pos.y - *(float*)&ScriptParams[2]) + HALFPI; + float heading = CGeneral::GetATanOfXY(pos.x - GET_FLOAT_PARAM(1), pos.y - GET_FLOAT_PARAM(2)) + HALFPI; if (heading > TWOPI) heading -= TWOPI; pVehicle->SetHeading(heading); return 0; } - /* case COMMAND_IS_CRANE_LIFTING_CAR: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[2]); - UpdateCompareFlag(CCranes::IsThisCarPickedUp(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], pVehicle)); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(2)); + UpdateCompareFlag(CCranes::IsThisCarPickedUp(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), pVehicle)); return 0; } - */ case COMMAND_DRAW_SPHERE: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - C3dMarkers::PlaceMarkerSet((uintptr)this + m_nIp, MARKERTYPE_CYLINDER, pos, *(float*)&ScriptParams[3], + C3dMarkers::PlaceMarkerSet((uintptr)this + m_nIp, MARKERTYPE_CYLINDER, pos, GET_FLOAT_PARAM(3), SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0); return 0; @@ -1525,15 +1544,15 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_SET_CAR_STATUS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->SetStatus(ScriptParams[1]); + pVehicle->SetStatus(GET_INTEGER_PARAM(1)); return 0; } case COMMAND_IS_CHAR_MALE: { 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->m_nPedType != PEDTYPE_CIVFEMALE && pPed->m_nPedType != PEDTYPE_PROSTITUTE); return 0; @@ -1551,11 +1570,11 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_CHANGE_GARAGE_TYPE_WITH_CAR_MODEL: { CollectParameters(&m_nIp, 3); - CGarages::ChangeGarageType(ScriptParams[0], ScriptParams[1], ScriptParams[2]); + CGarages::ChangeGarageType(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_FIND_DRUG_PLANE_COORDINATES: - *(CVector*)&ScriptParams[0] = CPlane::FindDrugPlaneCoordinates(); + SET_VECTOR_PARAM(0, CPlane::FindDrugPlaneCoordinates()); StoreParameters(&m_nIp, 3); return 0; */ @@ -1570,33 +1589,33 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) return 0; case COMMAND_POLICE_RADIO_MESSAGE: CollectParameters(&m_nIp, 3); - DMAudio.PlaySuspectLastSeen(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2]); + DMAudio.PlaySuspectLastSeen(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2)); return 0; case COMMAND_SET_CAR_STRONG: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bTakeLessDamage = ScriptParams[1] != 0; + pVehicle->bTakeLessDamage = GET_INTEGER_PARAM(1) != 0; return 0; } case COMMAND_REMOVE_ROUTE: CollectParameters(&m_nIp, 1); - CRouteNode::RemoveRoute(ScriptParams[0]); + CRouteNode::RemoveRoute(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SWITCH_RUBBISH: CollectParameters(&m_nIp, 1); - CRubbish::SetVisibility(ScriptParams[0] != 0); + CRubbish::SetVisibility(GET_INTEGER_PARAM(0) != 0); return 0; case COMMAND_REMOVE_PARTICLE_EFFECTS_IN_AREA: { CollectParameters(&m_nIp, 6); - float x1 = *(float*)&ScriptParams[0]; - float y1 = *(float*)&ScriptParams[1]; - float z1 = *(float*)&ScriptParams[2]; - float x2 = *(float*)&ScriptParams[3]; - float y2 = *(float*)&ScriptParams[4]; - float z2 = *(float*)&ScriptParams[5]; + 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); CParticleObject* tmp = CParticleObject::pCloseListHead; while (tmp) { CParticleObject* next = tmp->m_pNext; @@ -1615,15 +1634,15 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) } case COMMAND_SWITCH_STREAMING: CollectParameters(&m_nIp, 1); - CStreaming::ms_disableStreaming = ScriptParams[0] == 0; + CStreaming::ms_disableStreaming = GET_INTEGER_PARAM(0) == 0; return 0; case COMMAND_IS_GARAGE_OPEN: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CGarages::IsGarageOpen(ScriptParams[0])); + UpdateCompareFlag(CGarages::IsGarageOpen(GET_INTEGER_PARAM(0))); return 0; case COMMAND_IS_GARAGE_CLOSED: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CGarages::IsGarageClosed(ScriptParams[0])); + UpdateCompareFlag(CGarages::IsGarageClosed(GET_INTEGER_PARAM(0))); return 0; /* case COMMAND_START_CATALINA_HELI: @@ -1642,45 +1661,17 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_SWAP_NEAREST_BUILDING_MODEL: { CollectParameters(&m_nIp, 6); - CVector pos = *(CVector*)&ScriptParams[0]; - if (pos.z <= MAP_Z_LOW_LIMIT) - pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float radius = *(float*)&ScriptParams[3]; - int mi1 = ScriptParams[4] >= 0 ? ScriptParams[4] : CTheScripts::UsedObjectArray[-ScriptParams[4]].index; - int mi2 = ScriptParams[5] >= 0 ? ScriptParams[5] : CTheScripts::UsedObjectArray[-ScriptParams[5]].index; - int16 total; - CEntity* apEntities[16]; - CWorld::FindObjectsOfTypeInRange(mi1, pos, radius, true, &total, 16, apEntities, true, false, false, false, false); - if (total == 0) - CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_GENERIC), pos, radius, true, &total, 16, apEntities); - if (total == 0) - 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++) { - float dist = (apEntities[i]->GetPosition() - pos).Magnitude(); - if (dist < min_dist) { - min_dist = dist; - pClosestEntity = apEntities[i]; - } - } - if (!pClosestEntity) { - printf("Failed to find building\n"); - return 0; - } - CBuilding* pReplacedBuilding = ((CBuilding*)pClosestEntity); - pReplacedBuilding->ReplaceWithNewModel(mi2); - CTheScripts::AddToBuildingSwapArray(pReplacedBuilding, mi1, mi2); + CTheScripts::SwapNearestBuildingModel(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5)); return 0; } case COMMAND_SWITCH_WORLD_PROCESSING: CollectParameters(&m_nIp, 1); - CWorld::bProcessCutsceneOnly = ScriptParams[0] == 0; + CWorld::bProcessCutsceneOnly = GET_INTEGER_PARAM(0) == 0; return 0; case COMMAND_REMOVE_ALL_PLAYER_WEAPONS: { 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); pPed->ClearWeapons(); return 0; @@ -1689,7 +1680,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_GRAB_CATALINA_HELI: { CHeli* pHeli = CHeli::FindPointerToCatalinasHeli(); - ScriptParams[0] = pHeli ? CPools::GetVehiclePool()->GetIndex(pHeli) : -1; + SET_INTEGER_PARAM(0, pHeli ? CPools::GetVehiclePool()->GetIndex(pHeli) : -1); StoreParameters(&m_nIp, 1); return 0; } @@ -1697,46 +1688,46 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_CLEAR_AREA_OF_CARS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } CWorld::ClearCarsFromArea(infX, infY, infZ, supX, supY, supZ); return 0; } case COMMAND_SET_ROTATING_GARAGE_DOOR: CollectParameters(&m_nIp, 1); - CGarages::SetGarageDoorToRotate(ScriptParams[0]); + CGarages::SetGarageDoorToRotate(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_SPHERE: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float radius = *(float*)&ScriptParams[3]; + float radius = GET_FLOAT_PARAM(3); CTheScripts::GetActualScriptSphereIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CTheScripts::AddScriptSphere((uintptr)this + m_nIp, pos, radius); + SET_INTEGER_PARAM(0, CTheScripts::AddScriptSphere((uintptr)this + m_nIp, pos, radius)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_REMOVE_SPHERE: CollectParameters(&m_nIp, 1); - CTheScripts::RemoveScriptSphere(ScriptParams[0]); + CTheScripts::RemoveScriptSphere(GET_INTEGER_PARAM(0)); return 0; /* case COMMAND_CATALINA_HELI_FLY_AWAY: @@ -1746,9 +1737,9 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_SET_EVERYONE_IGNORE_PLAYER: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pPed->m_pWanted->m_bIgnoredByEveryone = true; CWorld::StopAllLawEnforcersInTheirTracks(); } @@ -1760,49 +1751,47 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_STORE_CAR_CHAR_IS_IN_NO_SAVE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVehicle* pVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; - ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_STORE_CAR_PLAYER_IS_IN_NO_SAVE: { 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); CVehicle* pVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil; - ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); StoreParameters(&m_nIp, 1); return 0; } /* case COMMAND_IS_PHONE_DISPLAYING_MESSAGE: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(gPhoneInfo.IsMessageBeingDisplayed(ScriptParams[0])); + UpdateCompareFlag(gPhoneInfo.IsMessageBeingDisplayed(GET_INTEGER_PARAM(0))); return 0; */ case COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_STRING: { - script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); - uint16 var = CTheScripts::Read2BytesFromScript(&m_nIp); + uint16 var = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; CollectParameters(&m_nIp, 1); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; - CUserDisplay::OnscnTimer.AddClock(var, onscreen_str, ScriptParams[0] != 0); + CUserDisplay::OnscnTimer.AddClock(var, onscreen_str, GET_INTEGER_PARAM(0) != 0); return 0; } case COMMAND_DISPLAY_ONSCREEN_COUNTER_WITH_STRING: { - script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); - uint16 var = CTheScripts::Read2BytesFromScript(&m_nIp); + uint16 var = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; CollectParameters(&m_nIp, 1); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; - CUserDisplay::OnscnTimer.AddCounter(var, ScriptParams[0], onscreen_str, 0); + CUserDisplay::OnscnTimer.AddCounter(var, GET_INTEGER_PARAM(0), onscreen_str, 0, -1, nil, 0); return 0; } case COMMAND_CREATE_RANDOM_CAR_FOR_CAR_PARK: @@ -1833,6 +1822,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_FBICAR: case MI_MRWHOOP: case MI_BFINJECT: + case MI_HEARSE: case MI_HUNTER: case MI_POLICE: case MI_ENFORCER: @@ -1846,12 +1836,14 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_ANGEL: case MI_COACH: case MI_RCBANDIT: - case MI_ROMERO: case MI_PACKER: case MI_SENTXS: case MI_SQUALO: case MI_SEASPAR: case MI_PIZZABOY: + case MI_NOODLEBOY: + case MI_ANGEL2: + case MI_SANCHEZ2: case MI_GANGBUR: case MI_AIRTRAIN: case MI_DEADDODO: @@ -1861,8 +1853,10 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_FLATBED: case MI_YANKEE: case MI_CADDY: - case MI_ZEBRA: + case MI_BORGNINE: case MI_TOPFUN: + case MI_CAMPVAN: + case MI_BALLOT: case MI_SKIMMER: case MI_RCBARON: case MI_RCRAIDER: @@ -1900,6 +1894,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_BLOODRA: case MI_BLOODRB: case MI_VICECHEE: + case MI_CABBIE: + case MI_MAFIA: model = -1; break; case MI_IDAHO: @@ -1916,7 +1912,6 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case MI_WASHING: case MI_BOBCAT: case MI_BANSHEE: - case MI_CABBIE: case MI_STALLION: case MI_RUMPO: case MI_ADMIRAL: @@ -1951,10 +1946,10 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) } else car = new CAutomobile(model, RANDOM_VEHICLE); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); car->SetPosition(pos); - car->SetHeading(DEGTORAD(*(float*)&ScriptParams[3])); + car->SetHeading(DEGTORAD(GET_FLOAT_PARAM(3))); CTheScripts::ClearSpaceForMissionEntity(pos, car); car->SetStatus(STATUS_ABANDONED); car->bIsLocked = false; @@ -1970,43 +1965,39 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) CWorld::Add(car); return 0; } - /* case COMMAND_IS_COLLISION_IN_MEMORY: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CCollision::ms_collisionInMemory == ScriptParams[0]); + UpdateCompareFlag(CGame::currLevel == GET_INTEGER_PARAM(0)); return 0; - */ case COMMAND_SET_WANTED_MULTIPLIER: CollectParameters(&m_nIp, 1); - FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = *(float*)&ScriptParams[0]; + FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = GET_FLOAT_PARAM(0); return 0; case COMMAND_SET_CAMERA_IN_FRONT_OF_PLAYER: TheCamera.SetCameraDirectlyInFrontForFollowPed_CamOnAString(); return 0; - /* case COMMAND_IS_CAR_VISIBLY_DAMAGED: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(pVehicle->bIsDamaged); return 0; } - */ case COMMAND_DOES_OBJECT_EXIST: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CPools::GetObjectPool()->GetAt(ScriptParams[0])); + UpdateCompareFlag(CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0))); return 0; case COMMAND_LOAD_SCENE: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); #ifdef FIX_BUGS CTimer::Suspend(); #else CTimer::Stop(); #endif - CStreaming::LoadScene(pos); + CStreaming::LoadSceneCollision(pos); #ifdef FIX_BUGS CTimer::Suspend(); #else @@ -2017,20 +2008,20 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_ADD_STUCK_CAR_CHECK: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CTheScripts::StuckCars.AddCarToCheck(ScriptParams[0], *(float*)&ScriptParams[1], ScriptParams[2]); + CTheScripts::StuckCars.AddCarToCheck(GET_INTEGER_PARAM(0), GET_FLOAT_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_REMOVE_STUCK_CAR_CHECK: { CollectParameters(&m_nIp, 1); - CTheScripts::StuckCars.RemoveCarFromCheck(ScriptParams[0]); + CTheScripts::StuckCars.RemoveCarFromCheck(GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_CAR_STUCK: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CTheScripts::StuckCars.HasCarBeenStuckForAWhile(ScriptParams[0])); + UpdateCompareFlag(CTheScripts::StuckCars.HasCarBeenStuckForAWhile(GET_INTEGER_PARAM(0))); return 0; case COMMAND_LOAD_MISSION_AUDIO: { @@ -2039,41 +2030,41 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) str[i] = tolower(str[i]); m_nIp += KEY_LENGTH_IN_SCRIPT; - DMAudio.PreloadMissionAudio(ScriptParams[0] - 1, str); + DMAudio.PreloadMissionAudio(GET_INTEGER_PARAM(0) - 1, str); return 0; } case COMMAND_HAS_MISSION_AUDIO_LOADED: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(DMAudio.GetMissionAudioLoadingStatus(ScriptParams[0] - 1) == 1); + UpdateCompareFlag(DMAudio.GetMissionAudioLoadingStatus(GET_INTEGER_PARAM(0) - 1) == 1); return 0; } case COMMAND_PLAY_MISSION_AUDIO: CollectParameters(&m_nIp, 1); - DMAudio.PlayLoadedMissionAudio(ScriptParams[0] - 1); + DMAudio.PlayLoadedMissionAudio(GET_INTEGER_PARAM(0) - 1); return 0; case COMMAND_HAS_MISSION_AUDIO_FINISHED: { CollectParameters(&m_nIp, 1); - UpdateCompareFlag(DMAudio.IsMissionAudioSampleFinished(ScriptParams[0] - 1)); + UpdateCompareFlag(DMAudio.IsMissionAudioSampleFinished(GET_INTEGER_PARAM(0) - 1)); return 0; } case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); int node = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true); - *(CVector*)&ScriptParams[0] = ThePaths.FindNodeCoorsForScript(node); - *(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacement(node); + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(node)); + SET_FLOAT_PARAM(3, ThePaths.FindNodeOrientationForCarPlacement(node)); StoreParameters(&m_nIp, 4); return 0; } case COMMAND_HAS_IMPORT_GARAGE_SLOT_BEEN_FILLED: { CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CGarages::HasImportExportGarageCollectedThisCar(ScriptParams[0], ScriptParams[1] - 1)); + UpdateCompareFlag(CGarages::HasImportExportGarageCollectedThisCar(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1) - 1)); return 0; } case COMMAND_CLEAR_THIS_PRINT: @@ -2091,8 +2082,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_SET_MISSION_AUDIO_POSITION: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[1]; - DMAudio.SetMissionAudioLocation(ScriptParams[0] - 1, pos.x, pos.y, pos.z); + CVector pos = GET_VECTOR_PARAM(1); + DMAudio.SetMissionAudioLocation(GET_INTEGER_PARAM(0) - 1, pos.x, pos.y, pos.z); return 0; } case COMMAND_ACTIVATE_SAVE_MENU: @@ -2108,15 +2099,15 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) return 0; case COMMAND_NO_SPECIAL_CAMERA_FOR_THIS_GARAGE: CollectParameters(&m_nIp, 1); - CGarages::SetLeaveCameraForThisGarage(ScriptParams[0]); + CGarages::SetLeaveCameraForThisGarage(GET_INTEGER_PARAM(0)); return 0; /* case COMMAND_ADD_BLIP_FOR_PICKUP_OLD: { CollectParameters(&m_nIp, 3); - CObject* pObject = CPickups::aPickUps[CPickups::GetActualPickupIndex(ScriptParams[0])].m_pObject; + CObject* pObject = CPickups::aPickUps[CPickups::GetActualPickupIndex(GET_INTEGER_PARAM(0))].m_pObject; CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CRadar::SetEntityBlip(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(pObject), ScriptParams[1], (eBlipDisplay)ScriptParams[2]); + SET_INTEGER_PARAM(0, CRadar::SetEntityBlip(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(pObject), GET_INTEGER_PARAM(1), (eBlipDisplay)GET_INTEGER_PARAM(2))); StoreParameters(&m_nIp, 1); return 0; } @@ -2124,11 +2115,11 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_ADD_BLIP_FOR_PICKUP: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPickups::aPickUps[CPickups::GetActualPickupIndex(ScriptParams[0])].m_pObject; + CObject* pObject = CPickups::aPickUps[CPickups::GetActualPickupIndex(GET_INTEGER_PARAM(0))].m_pObject; CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetEntityBlip(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(pObject), 6, BLIP_DISPLAY_BOTH); CRadar::ChangeBlipScale(handle, 3); - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } @@ -2136,52 +2127,55 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) case COMMAND_ADD_SPRITE_BLIP_FOR_PICKUP: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPickups::aPickUps[CPickups::GetActualPickupIndex(ScriptParams[0])].m_pObject; + CObject* pObject = CPickups::aPickUps[CPickups::GetActualPickupIndex(GET_INTEGER_PARAM(0))].m_pObject; CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int handle = CRadar::SetEntityBlip(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(pObject), 6, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(handle, ScriptParams[1]); - ScriptParams[0] = handle; + CRadar::SetBlipSprite(handle, GET_INTEGER_PARAM(1)); + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } */ case COMMAND_SET_PED_DENSITY_MULTIPLIER: CollectParameters(&m_nIp, 1); - CPopulation::PedDensityMultiplier = *(float*)&ScriptParams[0]; + CPopulation::PedDensityMultiplier = GET_FLOAT_PARAM(0); return 0; case COMMAND_FORCE_RANDOM_PED_TYPE: CollectParameters(&m_nIp, 1); - CPopulation::m_AllRandomPedsThisType = ScriptParams[0]; + CPopulation::m_AllRandomPedsThisType = GET_INTEGER_PARAM(0); return 0; /* case COMMAND_SET_TEXT_DRAW_BEFORE_FADE: CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bTextBeforeFade = ScriptParams[0] != 0; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bTextBeforeFade = GET_INTEGER_PARAM(0) != 0; return 0; */ case COMMAND_GET_COLLECTABLE1S_COLLECTED: - ScriptParams[0] = CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages; + SET_INTEGER_PARAM(0, CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages); StoreParameters(&m_nIp, 1); return 0; case COMMAND_SET_CHAR_OBJ_LEAVE_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_LEAVE_CAR, 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; + CTheScripts::IntroRectangles[CTheScripts::NumberOfIntroRectanglesThisFrame].m_bBeforeFade = GET_INTEGER_PARAM(0) != 0; return 0; + */ case COMMAND_SET_TEXT_RIGHT_JUSTIFY: CollectParameters(&m_nIp, 1); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bRightJustify = ScriptParams[0] != 0; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bRightJustify = GET_INTEGER_PARAM(0) != 0; return 0; case COMMAND_PRINT_HELP: { + /* maybe will be useful? TODO if (CCamera::m_bUseMouse3rdPerson && ( strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "HELP15") == 0 || strcmp((char*)&CTheScripts::ScriptSpace[m_nIp], "GUN_2A") == 0 || @@ -2190,16 +2184,18 @@ int8 CRunningScript::ProcessCommands900To999(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; return 0; } + */ wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); CHud::SetHelpMessage(text, false); return 0; } case COMMAND_CLEAR_HELP: + //CHud::gLastPrintForeverString = false; TODO CHud::SetHelpMessage(nil, false); return 0; case COMMAND_FLASH_HUD_OBJECT: CollectParameters(&m_nIp, 1); - CHud::m_ItemToFlash = ScriptParams[0]; + CHud::m_ItemToFlash = GET_INTEGER_PARAM(0); return 0; default: script_assert(0); @@ -2264,6 +2260,38 @@ void CTheScripts::RemoveScriptSphere(int32 index) ScriptSphereArray[index].m_Id = 0; } +void CTheScripts::SwapNearestBuildingModel(float x, float y, float z, float radius, int mi1, int mi2) +{ + CVector pos(x, y, z); + if (pos.z <= MAP_Z_LOW_LIMIT) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + if (mi1 < 0) + mi1 = CTheScripts::UsedObjectArray[-mi1].index; + if (mi2 < 0) + mi2 = CTheScripts::UsedObjectArray[-mi2].index; + int16 total; + CEntity* apEntities[16]; + CWorld::FindObjectsOfTypeInRange(mi1, pos, radius, true, &total, 16, apEntities, true, false, false, false, false); + if (total == 0) + CWorld::FindObjectsOfTypeInRangeSectorList(mi1, CWorld::GetBigBuildingList(LEVEL_GENERIC), pos, radius, true, &total, 16, apEntities); + if (total == 0) + 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++) { + float dist = (apEntities[i]->GetPosition() - pos).Magnitude(); + if (dist < min_dist) { + min_dist = dist; + pClosestEntity = apEntities[i]; + } + } + CBuilding* pReplacedBuilding = ((CBuilding*)pClosestEntity); + if (pReplacedBuilding) { + pReplacedBuilding->ReplaceWithNewModel(mi2); + AddToBuildingSwapArray(pReplacedBuilding, mi1, mi2); + } +} + void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model) { int i = 0; diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp index e9f0967e..45952497 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -19,32 +19,20 @@ #include "main.h" #include "SaveBuf.h" -void CRunningScript::UpdateCompareFlag(bool flag) +// LCS: file done except TODOs + +uint32 CRunningScript::CollectLocateParameters(uint32* pIp, bool b3D) { - if (m_bNotFlag) - flag = !flag; - if (m_nAndOrState == ANDOR_NONE) { - m_bCondResult = flag; - return; - } - if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { - m_bCondResult &= flag; - if (m_nAndOrState == ANDS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - } - else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8) { - m_bCondResult |= flag; - if (m_nAndOrState == ORS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - } - else { - return; - } - m_nAndOrState--; + CollectParameters(pIp, 1); + uint32 id = (uintptr)this + (*pIp - 16); + uint32 ip = *pIp; + uint8 type = CTheScripts::Read1ByteFromScript(&ip); + if (type >= ARGUMENT_LOCAL) { + ip--; + id = (uint32)(uintptr)GetPointerToScriptVariable(&ip, 0); + } + CollectParameters(pIp, b3D ? 7 : 5, &(ScriptParams[1])); + return id; } void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) @@ -64,8 +52,8 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + uint32 id = CollectLocateParameters(pIp, b3D); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; switch (command) { case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_2D: case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D: @@ -81,37 +69,23 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) default: break; } - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } + CVector pos = pPlayerInfo->GetPos(); if (!decided) { - CVector pos = pPlayerInfo->GetPos(); result = false; - bool in_area; - if (b3D) { - in_area = X - dX <= pos.x && - X + dX >= pos.x && - Y - dY <= pos.y && - Y + dY >= pos.y && - Z - dZ <= pos.z && - Z + dZ >= pos.z; - } else { - in_area = X - dX <= pos.x && - X + dX >= pos.x && - Y - dY <= pos.y && - Y + dY >= pos.y; - } - if (in_area) { + if (Abs(pos.x - X) < dX && Abs(pos.y - Y) < dY && (!b3D || Abs(pos.z - Z) < dZ)) { switch (command) { case COMMAND_LOCATE_PLAYER_ANY_MEANS_2D: case COMMAND_LOCATE_PLAYER_ANY_MEANS_3D: @@ -138,14 +112,16 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) } } UpdateCompareFlag(result); - if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + if (debug && Abs(pos.x - X) < 80.0f && Abs(pos.y - Y) < 80.0f) + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) @@ -163,8 +139,8 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPlayerInfo->GetPos(); if (pTarget->bInVehicle) { @@ -176,14 +152,14 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; } - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -227,12 +203,14 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) #else CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : MAP_Z_LOW_LIMIT); #endif + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) @@ -250,21 +228,21 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPlayerInfo->GetPos(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -304,12 +282,14 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) @@ -329,8 +309,8 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos = pPed->InVehicle() ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); switch (command) { @@ -348,19 +328,19 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) default: break; } - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (!decided) { result = false; @@ -407,13 +387,15 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) @@ -431,9 +413,9 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); if (pTarget->bInVehicle) { @@ -446,14 +428,14 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; } - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -497,12 +479,14 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) #else CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : MAP_Z_LOW_LIMIT); #endif + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) @@ -520,22 +504,22 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -575,12 +559,14 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) @@ -598,22 +584,22 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pTarget = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -653,12 +639,14 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) @@ -674,8 +662,8 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CVector pos = pVehicle->GetPosition(); switch (command) { @@ -689,19 +677,19 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) default: break; } - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (!decided) { result = false; @@ -724,13 +712,15 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp) @@ -745,23 +735,23 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CVector pos = pObject->GetPosition(); - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } result = false; bool in_area; @@ -782,13 +772,15 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp) result = in_area; UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp) @@ -804,30 +796,32 @@ void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 7 : 5); - X = *(float*)&ScriptParams[0]; - Y = *(float*)&ScriptParams[1]; + X = GET_FLOAT_PARAM(0); + Y = GET_FLOAT_PARAM(1); if (b3D) { - Z = *(float*)&ScriptParams[2]; - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - dZ = *(float*)&ScriptParams[5]; - debug = ScriptParams[6]; + Z = GET_FLOAT_PARAM(2); + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + dZ = GET_FLOAT_PARAM(5); + debug = GET_INTEGER_PARAM(6); } else { - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; - debug = ScriptParams[4]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); + debug = GET_INTEGER_PARAM(4); } result = CBulletInfo::TestForSniperBullet(X - dX, X + dX, Y - dY, Y + dY, b3D ? Z - dZ : -1000.0f, b3D ? Z + dZ : 1000.0f); UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) @@ -847,8 +841,8 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + uint32 id = CollectLocateParameters(pIp, b3D); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; switch (command) { case COMMAND_IS_PLAYER_STOPPED_IN_AREA_3D: case COMMAND_IS_PLAYER_STOPPED_IN_AREA_ON_FOOT_3D: @@ -864,23 +858,23 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -939,12 +933,14 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) @@ -965,7 +961,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 9 : 7); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; switch (command) { case COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_3D: case COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_ON_FOOT_3D: @@ -981,25 +977,25 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - side2length = *(float*)&ScriptParams[7]; - debug = ScriptParams[8]; + side2length = GET_FLOAT_PARAM(7); + debug = GET_INTEGER_PARAM(8); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - side2length = *(float*)&ScriptParams[5]; - debug = ScriptParams[6]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + side2length = GET_FLOAT_PARAM(5); + debug = GET_INTEGER_PARAM(6); } float initAngle = CGeneral::GetRadianAngleBetweenPoints(infX, infY, supX, supY) + HALFPI; while (initAngle < 0.0f) @@ -1062,6 +1058,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) if (debug) CTheScripts::HighlightImportantAngledArea((uintptr)this + m_nIp, infX, infY, supX, supY, rotatedSupX, rotatedSupY, rotatedInfX, rotatedInfY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugAngledCube(infX, infY, infZ, supX, supY, supZ, @@ -1070,6 +1067,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) CTheScripts::DrawDebugAngledSquare(infX, infY, supX, supY, rotatedSupX, rotatedSupY, rotatedInfX, rotatedInfY); } + */ } void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) @@ -1089,8 +1087,8 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos = pPed->InVehicle() ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); switch (command) { @@ -1108,23 +1106,23 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1181,13 +1179,15 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) @@ -1203,8 +1203,8 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CVector pos = pVehicle->GetPosition(); switch (command) { @@ -1218,23 +1218,23 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1279,13 +1279,15 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp) @@ -1300,27 +1302,27 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CVector pos = pObject->GetPosition(); - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1361,13 +1363,15 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::DoDeatharrestCheck() @@ -1390,7 +1394,8 @@ void CRunningScript::DoDeatharrestCheck() script_assert(m_nStackPointer > 0); while (m_nStackPointer > 1) --m_nStackPointer; - m_nIp = m_anStack[--m_nStackPointer]; + ReturnFromGosubOrFunction(); + m_nLocalsPointer = 0; CMessages::ClearSmallMessagesOnly(); *(int32*)&CTheScripts::ScriptSpace[CTheScripts::OnAMissionFlag] = 0; m_bDeatharrestExecuted = true; @@ -1444,24 +1449,24 @@ void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp) b3D = true; break; } - CollectParameters(pIp, b3D ? 8 : 6); - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + uint32 id = CollectLocateParameters(pIp, b3D); + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1522,13 +1527,15 @@ void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) @@ -1546,7 +1553,7 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); if (pTarget->bInVehicle) { X = pTarget->m_pMyVehicle->GetPosition().x; @@ -1558,18 +1565,18 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; } - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1614,12 +1621,14 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) @@ -1637,23 +1646,23 @@ void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1698,12 +1707,14 @@ void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) @@ -1721,22 +1732,22 @@ void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CVector pos = CWorld::Players[ScriptParams[1]].GetPos(); + CVector pos = CWorld::Players[GET_INTEGER_PARAM(1)].GetPos(); X = pos.x; Y = pos.y; Z = pos.z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1781,12 +1792,14 @@ void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) @@ -1807,23 +1820,23 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 8 : 6); - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1837,7 +1850,7 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1899,12 +1912,14 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } #endif @@ -1991,8 +2006,9 @@ void CTheScripts::PrintListSizes() debug("active: %d, idle: %d", active, idle); } -uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255 +//uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255 +/* void CTheScripts::DrawDebugSquare(float infX, float infY, float supX, float supY) { CColPoint tmpCP; @@ -2099,9 +2115,10 @@ void CTheScripts::RenderTheScriptDebugLines() NumScriptDebugLines = 0; RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)0); } +*/ -#define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) +\ - 4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 5 * sizeof(uint32) +#define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) + sizeof(tCollectiveData) * MAX_NUM_COLLECTIVES +\ + 4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 4 * sizeof(uint32) void CTheScripts::SaveAllScripts(uint8* buf, uint32* size) { @@ -2110,7 +2127,7 @@ INITSAVEBUF uint32 runningScripts = 0; for (CRunningScript* pScript = pActiveScripts; pScript; pScript = pScript->GetNext()) runningScripts++; - *size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 3 * sizeof(uint32); + *size = CRunningScript::nSaveStructSize * runningScripts + varSpace + SCRIPT_DATA_SIZE + SAVE_HEADER_SIZE + 5 * sizeof(uint32); WriteSaveHeader(buf, 'S', 'C', 'R', '\0', *size - SAVE_HEADER_SIZE); WriteSaveBuf(buf, varSpace); for (uint32 i = 0; i < varSpace; i++) @@ -2122,6 +2139,9 @@ INITSAVEBUF WriteSaveBuf(buf, script_data_size); WriteSaveBuf(buf, OnAMissionFlag); WriteSaveBuf(buf, LastMissionPassedTime); + for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++) + WriteSaveBuf(buf, CollectiveArray[i]); + WriteSaveBuf(buf, NextFreeCollectiveIndex); for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) { CBuilding* pBuilding = BuildingSwapArray[i].m_pBuilding; uint32 type, handle; @@ -2183,24 +2203,37 @@ INITSAVEBUF VALIDATESAVEBUF(*size) } -void CTheScripts::LoadAllScripts(uint8* buf, uint32 size) +bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size) { - Init(); INITSAVEBUF CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE); uint32 varSpace, type, handle; uint32 tmp; ReadSaveBuf(&varSpace, buf); - for (uint32 i = 0; i < varSpace; i++) - ReadSaveBuf(&ScriptSpace[i], buf); + if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) { + printf("\n===================================================\nSave Game Mismatch!!!\n"); + return false; + } + for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does + if (i < 8) + ReadSaveBuf(&ScriptSpace[i], buf); + else if (GetSaveVarIndex(i / 4 * 4) != -1) + ReadSaveBuf(&ScriptSpace[i], buf); + else + SkipSaveBuf(buf, 1); + } ReadSaveBuf(&tmp, buf); script_assert(tmp == SCRIPT_DATA_SIZE); ReadSaveBuf(&OnAMissionFlag, buf); ReadSaveBuf(&LastMissionPassedTime, buf); + for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++) + ReadSaveBuf(&CollectiveArray[i], buf); + ReadSaveBuf(&NextFreeCollectiveIndex, buf); for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) { ReadSaveBuf(&type, buf); ReadSaveBuf(&handle, buf); + /* switch (type) { case 0: BuildingSwapArray[i].m_pBuilding = nil; @@ -2214,14 +2247,19 @@ INITSAVEBUF default: script_assert(false); } - ReadSaveBuf(&BuildingSwapArray[i].m_nNewModel, buf); - ReadSaveBuf(&BuildingSwapArray[i].m_nOldModel, buf); + */ + /*BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);*/ + /*BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);*/ + SkipSaveBuf(buf, 8); + /* if (BuildingSwapArray[i].m_pBuilding) BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel); + */ } for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) { ReadSaveBuf(&type, buf); ReadSaveBuf(&handle, buf); + /* switch (type) { case 0: InvisibilitySettingArray[i] = nil; @@ -2243,12 +2281,16 @@ INITSAVEBUF } if (InvisibilitySettingArray[i]) InvisibilitySettingArray[i]->bIsVisible = false; + */ } bool tmpBool; ReadSaveBuf(&tmpBool, buf); script_assert(tmpBool == bUsingAMultiScriptFile); - ReadSaveBuf(&bPlayerHasMetDebbieHarry, buf); - SkipSaveBuf(buf, 2); + ///*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf); + //ReadSaveBuf<uint16>(buf); + + SkipSaveBuf(buf, 3); + ReadSaveBuf(&tmp, buf); script_assert(tmp == MainScriptSize); ReadSaveBuf(&tmp, buf); @@ -2261,7 +2303,8 @@ INITSAVEBUF uint32 runningScripts; ReadSaveBuf(&runningScripts, buf); for (uint32 i = 0; i < runningScripts; i++) - StartNewScript(0)->Load(buf); + CRunningScript().Load(buf); + return true; VALIDATESAVEBUF(size) } @@ -2271,6 +2314,7 @@ void CRunningScript::Save(uint8*& buf) { #ifdef COMPATIBLE_SAVES ZeroSaveBuf(buf, 8); + WriteSaveBuf<int32>(buf, m_nId); for (int i = 0; i < 8; i++) WriteSaveBuf(buf, m_abScriptName[i]); WriteSaveBuf(buf, m_nIp); @@ -2282,10 +2326,11 @@ void CRunningScript::Save(uint8*& buf) WriteSaveBuf(buf, m_nStackPointer); ZeroSaveBuf(buf, 2); #ifdef CHECK_STRUCT_SIZES - static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18"); + static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 106"); #endif - for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) + for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++) WriteSaveBuf(buf, m_anLocalVariables[i]); + WriteSaveBuf(buf, m_nLocalsPointer); WriteSaveBuf(buf, m_bIsActive); WriteSaveBuf(buf, m_bCondResult); WriteSaveBuf(buf, m_bIsMissionScript); @@ -2306,6 +2351,7 @@ void CRunningScript::Load(uint8*& buf) { #ifdef COMPATIBLE_SAVES SkipSaveBuf(buf, 8); + ReadSaveBuf(&m_nId, buf); for (int i = 0; i < 8; i++) ReadSaveBuf(&m_abScriptName[i], buf); ReadSaveBuf(&m_nIp, buf); @@ -2317,10 +2363,11 @@ void CRunningScript::Load(uint8*& buf) ReadSaveBuf(&m_nStackPointer, buf); SkipSaveBuf(buf, 2); #ifdef CHECK_STRUCT_SIZES - static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18"); + static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106"); #endif - for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) + for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++) ReadSaveBuf(&m_anLocalVariables[i], buf); + ReadSaveBuf(&m_nLocalsPointer, buf); ReadSaveBuf(&m_bIsActive, buf); ReadSaveBuf(&m_bCondResult, buf); ReadSaveBuf(&m_bIsMissionScript, buf); @@ -2429,7 +2476,7 @@ void CTheScripts::HighlightImportantArea(uint32 id, float x1, float y1, float x2 center.x = (infX + supX) / 2; center.y = (infY + supY) / 2; center.z = (z <= MAP_Z_LOW_LIMIT) ? CWorld::FindGroundZForCoord(center.x, center.y) : z; - CShadows::RenderIndicatorShadow(id, 2, gpGoalTex, ¢er, supX - center.x, 0.0f, 0.0f, center.y - supY, 0); + CShadows::RenderIndicatorShadow(id, 2, nil, ¢er, supX - center.x, 0.0f, 0.0f, center.y - supY, 0); } void CTheScripts::HighlightImportantAngledArea(uint32 id, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float z) @@ -2623,7 +2670,10 @@ void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective ob } else { pPed->bScriptObjectiveCompleted = false; - pPed->SetObjective(objective); + if (objective == OBJECTIVE_LEAVE_CAR) + pPed->SetObjective(objective); + else + pPed->SetObjective(objective, pPed->m_pMyVehicle); } } } @@ -2699,8 +2749,14 @@ void CTheScripts::CleanUpThisPed(CPed* pPed) } else { if (pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_CAR) { - pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle); - pPed->bWanderPathAfterExitingCar = true; + if ((pPed->m_fHealth < 1.0f && !pPed->IsPedHeadAbovePos(-0.3f)) || pPed->bBodyPartJustCameOff) { + pPed->SetObjective(OBJECTIVE_LEAVE_CAR_AND_DIE, pPed->m_pMyVehicle); + pPed->bWanderPathAfterExitingCar = false; + } + else { + pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle); + pPed->bWanderPathAfterExitingCar = true; + } } } } @@ -2713,6 +2769,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed) flees = true; } pPed->ClearObjective(); + pPed->SetWaitState(WAITSTATE_FALSE, nil); pPed->bRespondsToThreats = true; pPed->bScriptObjectiveCompleted = false; pPed->bKindaStayInSamePlace = false; @@ -2756,6 +2813,9 @@ void CTheScripts::ReadObjectNamesFromScript() { int32 varSpace = GetSizeOfVariableSpace(); uint32 ip = varSpace + 8; + NumSaveVars = Read4BytesFromScript(&ip); + SavedVarIndices = (uint16*)&ScriptSpace[ip]; + ip += 2 * NumSaveVars; NumberOfUsedObjects = Read2BytesFromScript(&ip); ip += 2; for (uint16 i = 0; i < NumberOfUsedObjects; i++) { @@ -2767,30 +2827,16 @@ void CTheScripts::ReadObjectNamesFromScript() void CTheScripts::UpdateObjectIndices() { - char name[USED_OBJECT_NAME_LENGTH]; char error[112]; for (int i = 1; i < NumberOfUsedObjects; i++) { - bool found = false; - for (int j = 0; j < MODELINFOSIZE && !found; j++) { - CBaseModelInfo* pModel = CModelInfo::GetModelInfo(j); - if (!pModel) - continue; - strcpy(name, pModel->GetModelName()); -#ifdef FIX_BUGS - for (int k = 0; k < USED_OBJECT_NAME_LENGTH && name[k]; k++) -#else - for (int k = 0; k < USED_OBJECT_NAME_LENGTH; k++) -#endif - name[k] = toupper(name[k]); - if (strcmp(name, UsedObjectArray[i].name) == 0) { - found = true; - UsedObjectArray[i].index = j; - } - } - if (!found) { + UsedObjectArray[i].index = -1; + CModelInfo::GetModelInfo(UsedObjectArray[i].name, &UsedObjectArray[i].index); +#ifndef FINAL + if (UsedObjectArray[i].index == -1) { sprintf(error, "CTheScripts::UpdateObjectIndices - Couldn't find %s", UsedObjectArray[i].name); debug("%s\n", error); } +#endif } } @@ -2800,7 +2846,8 @@ void CTheScripts::ReadMultiScriptFileOffsetsFromScript() uint32 ip = varSpace + 3; int32 objectSize = Read4BytesFromScript(&ip); ip = objectSize + 8; - MainScriptSize = Read4BytesFromScript(&ip); + NumTrueGlobals = Read2BytesFromScript(&ip); + MostGlobals = Read2BytesFromScript(&ip); LargestMissionScriptSize = Read4BytesFromScript(&ip); NumberOfMissionScripts = Read2BytesFromScript(&ip); NumberOfExclusiveMissionScripts = Read2BytesFromScript(&ip); diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp index 8af32f57..2dca5be9 100644 --- a/src/control/Script6.cpp +++ b/src/control/Script6.cpp @@ -17,6 +17,7 @@ #ifdef MISSION_REPLAY #include "GenericGameStorage.h" #endif +#include "Hud.h" #include "Messages.h" #include "Pad.h" #include "Particle.h" @@ -37,6 +38,9 @@ #include "CarAI.h" #include "Pickups.h" #include "Fluff.h" +#include "CustomSoundTrack.h" + +// LCS: file done except TODOs #ifdef USE_DEBUG_SCRIPT_LOADER extern const char* scriptfile; @@ -83,88 +87,88 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { switch (command) { //case COMMAND_FLASH_RADAR_BLIP: - /* case COMMAND_IS_CHAR_IN_CONTROL: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed->IsPedInControl()); return 0; } - */ case COMMAND_SET_GENERATE_CARS_AROUND_CAMERA: CollectParameters(&m_nIp, 1); - CCarCtrl::bCarsGeneratedAroundCamera = (ScriptParams[0] != 0); + CCarCtrl::bCarsGeneratedAroundCamera = (GET_INTEGER_PARAM(0) != 0); return 0; case COMMAND_CLEAR_SMALL_PRINTS: CMessages::ClearSmallMessagesOnly(); + //CHud::ClearSmallMessages(); // TODO return 0; - /* case COMMAND_HAS_MILITARY_CRANE_COLLECTED_ALL_CARS: UpdateCompareFlag(CCranes::HaveAllCarsBeenCollectedByMilitaryCrane()); return 0; - */ case COMMAND_SET_UPSIDEDOWN_CAR_NOT_DAMAGED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); - CAutomobile* pCar = (CAutomobile*)pVehicle; - pCar->bNotDamagedUpsideDown = (ScriptParams[1] != 0); + //assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); + // they call this for bikes again, we don't really want to destroy the structure... +#ifdef FIX_BUGS + if (pVehicle->m_vehType == VEHICLE_TYPE_CAR) +#endif + ((CAutomobile*)pVehicle)->bNotDamagedUpsideDown = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_CAN_PLAYER_START_MISSION: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPlayerPed); - UpdateCompareFlag(pPlayerPed->IsPedInControl() || pPlayerPed->m_nPedState == PED_DRIVING); + UpdateCompareFlag(pPlayerPed->CanStartMission() || pPlayerPed->m_nPedState == PED_DRIVING); return 0; } case COMMAND_MAKE_PLAYER_SAFE_FOR_CUTSCENE: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CPad::GetPad(ScriptParams[0])->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + CPad::GetPad(GET_INTEGER_PARAM(0))->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE); pPlayerInfo->MakePlayerSafe(true); CCutsceneMgr::StartCutsceneProcessing(); return 0; } case COMMAND_USE_TEXT_COMMANDS: CollectParameters(&m_nIp, 1); - CTheScripts::UseTextCommands = (ScriptParams[0] != 0) ? 2 : 1; + CTheScripts::UseTextCommands = (GET_INTEGER_PARAM(0) != 0) ? 2 : 1; return 0; case COMMAND_SET_THREAT_FOR_PED_TYPE: CollectParameters(&m_nIp, 2); - CPedType::AddThreat(ScriptParams[0], ScriptParams[1]); + CPedType::AddThreat(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_CLEAR_THREAT_FOR_PED_TYPE: CollectParameters(&m_nIp, 2); - CPedType::RemoveThreat(ScriptParams[0], ScriptParams[1]); + CPedType::RemoveThreat(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_GET_CAR_COLOURS: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->m_currentColour1; - ScriptParams[1] = pVehicle->m_currentColour2; + SET_INTEGER_PARAM(0, pVehicle->m_currentColour1); + SET_INTEGER_PARAM(1, pVehicle->m_currentColour2); StoreParameters(&m_nIp, 2); return 0; } case COMMAND_SET_ALL_CARS_CAN_BE_DAMAGED: CollectParameters(&m_nIp, 1); - CWorld::SetAllCarsCanBeDamaged(ScriptParams[0] != 0); - if (!ScriptParams[0]) + CWorld::SetAllCarsCanBeDamaged(GET_INTEGER_PARAM(0) != 0); + if (!GET_INTEGER_PARAM(0)) CWorld::ExtinguishAllCarFiresInArea(FindPlayerCoors(), 4000.0f); return 0; case COMMAND_SET_CAR_CAN_BE_DAMAGED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - pVehicle->bCanBeDamaged = ScriptParams[1] != 0; - if (!ScriptParams[1]) + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + pVehicle->bCanBeDamaged = GET_INTEGER_PARAM(1) != 0; + if (!GET_INTEGER_PARAM(1)) pVehicle->ExtinguishCarFire(); return 0; } @@ -174,7 +178,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CTimer::Stop(); - CGame::currLevel = (eLevelName)ScriptParams[0]; + CGame::currLevel = (eLevelName)GET_INTEGER_PARAM(0); ISLAND_LOADING_IS(LOW) { CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); @@ -190,18 +194,18 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; } case COMMAND_GET_BODY_CAST_HEALTH: - // ScriptParams[0] = CObject::nBodyCastHealth; + // SET_INTEGER_PARAM(0, CObject::nBodyCastHealth); // StoreParameters(&m_nIp, 1); return 0; */ case COMMAND_SET_CHARS_CHATTING: { CollectParameters(&m_nIp, 3); - CPed* pPed1 = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pPed2 = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed1 = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pPed2 = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pPed1 && pPed2); - pPed1->SetChat(pPed2, ScriptParams[2]); - pPed2->SetChat(pPed1, ScriptParams[2]); + pPed1->SetChat(pPed2, GET_INTEGER_PARAM(2)); + pPed2->SetChat(pPed1, GET_INTEGER_PARAM(2)); return 0; } //case COMMAND_MAKE_PLAYER_SAFE: @@ -209,9 +213,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CAR_STAYS_IN_CURRENT_LEVEL: { 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->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); else pVehicle->m_nZoneLevel = LEVEL_GENERIC; @@ -220,9 +224,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CHAR_STAYS_IN_CURRENT_LEVEL: { 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->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); else pPed->m_nZoneLevel = LEVEL_GENERIC; @@ -232,16 +236,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_DRUNK_INPUT_DELAY: { CollectParameters(&m_nIp, 2); - assert(ScriptParams[1] < CPad::DRUNK_STEERING_BUFFER_SIZE); - CPad::GetPad(ScriptParams[0])->SetDrunkInputDelay(ScriptParams[1]); + assert(GET_INTEGER_PARAM(1) < CPad::DRUNK_STEERING_BUFFER_SIZE); + CPad::GetPad(GET_INTEGER_PARAM(0))->SetDrunkInputDelay(GET_INTEGER_PARAM(1)); return 0; } case COMMAND_SET_CHAR_MONEY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_nPedMoney = ScriptParams[1]; + pPed->m_nPedMoney = GET_INTEGER_PARAM(1); pPed->bMoneyHasBeenGivenByScript = true; return 0; } @@ -249,10 +253,10 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_OFFSET_FROM_OBJECT_IN_WORLD_COORDS: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CVector result = Multiply3x3(pObject->GetMatrix(), *(CVector*)&ScriptParams[1]) + pObject->GetPosition(); - *(CVector*)&ScriptParams[0] = result; + CVector result = Multiply3x3(pObject->GetMatrix(), GET_VECTOR_PARAM(1)) + pObject->GetPosition(); + SET_VECTOR_PARAM(0, result); StoreParameters(&m_nIp, 3); return 0; } @@ -264,34 +268,34 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; case COMMAND_REGISTER_AMBULANCE_LEVEL: CollectParameters(&m_nIp, 1); - CStats::RegisterLevelAmbulanceMission(ScriptParams[0]); + CStats::RegisterLevelAmbulanceMission(GET_INTEGER_PARAM(0)); return 0; case COMMAND_REGISTER_FIRE_EXTINGUISHED: CStats::AnotherFireExtinguished(); return 0; case COMMAND_TURN_PHONE_ON: CollectParameters(&m_nIp, 1); - gPhoneInfo.m_aPhones[ScriptParams[0]].m_nState = PHONE_STATE_9; + gPhoneInfo.m_aPhones[GET_INTEGER_PARAM(0)].m_nState = PHONE_STATE_9; return 0; /* case COMMAND_REGISTER_LONGEST_DODO_FLIGHT: CollectParameters(&m_nIp, 1); - CStats::RegisterLongestFlightInDodo(ScriptParams[0]); + CStats::RegisterLongestFlightInDodo(GET_INTEGER_PARAM(0)); return 0; */ case COMMAND_GET_OFFSET_FROM_CAR_IN_WORLD_COORDS: { CollectParameters(&m_nIp, 4); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVector result = Multiply3x3(pVehicle->GetMatrix(), *(CVector*)&ScriptParams[1]) + pVehicle->GetPosition(); - *(CVector*)&ScriptParams[0] = result; + CVector result = Multiply3x3(pVehicle->GetMatrix(), GET_VECTOR_PARAM(1)) + pVehicle->GetPosition(); + SET_VECTOR_PARAM(0, result); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_TOTAL_NUMBER_OF_KILL_FRENZIES: CollectParameters(&m_nIp, 1); - CStats::SetTotalNumberKillFrenzies(ScriptParams[0]); + CStats::SetTotalNumberKillFrenzies(GET_INTEGER_PARAM(0)); return 0; case COMMAND_BLOW_UP_RC_BUGGY: CWorld::Players[CWorld::PlayerInFocus].BlowUpRCBuggy(true); @@ -299,7 +303,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) /* case COMMAND_REMOVE_CAR_FROM_CHASE: CollectParameters(&m_nIp, 1); - CRecordDataForChase::RemoveCarFromChase(ScriptParams[0]); + CRecordDataForChase::RemoveCarFromChase(GET_INTEGER_PARAM(0)); return 0; */ case COMMAND_IS_FRENCH_GAME: @@ -310,57 +314,57 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; case COMMAND_CLEAR_MISSION_AUDIO: CollectParameters(&m_nIp, 1); - DMAudio.ClearMissionAudio(ScriptParams[0] - 1); + DMAudio.ClearMissionAudio(GET_INTEGER_PARAM(0) - 1); return 0; /* case COMMAND_SET_FADE_IN_AFTER_NEXT_ARREST: CollectParameters(&m_nIp, 1); - CRestart::bFadeInAfterNextArrest = !!ScriptParams[0]; + CRestart::bFadeInAfterNextArrest = !!GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_FADE_IN_AFTER_NEXT_DEATH: CollectParameters(&m_nIp, 1); - CRestart::bFadeInAfterNextDeath = !!ScriptParams[0]; + CRestart::bFadeInAfterNextDeath = !!GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_GANG_PED_MODEL_PREFERENCE: CollectParameters(&m_nIp, 2); - CGangs::SetGangPedModelOverride(ScriptParams[0], ScriptParams[1]); + CGangs::SetGangPedModelOverride(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; */ case COMMAND_SET_CHAR_USE_PEDNODE_SEEK: { 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->m_pNextPathNode = nil; - pPed->bUsePedNodeSeek = !!ScriptParams[1]; + pPed->bUsePedNodeSeek = !!GET_INTEGER_PARAM(1); return 0; } /* case COMMAND_SWITCH_VEHICLE_WEAPONS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bGunSwitchedOff = !ScriptParams[1]; + pVehicle->bGunSwitchedOff = !GET_INTEGER_PARAM(1); return 0; } + */ case COMMAND_SET_GET_OUT_OF_JAIL_FREE: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_bGetOutOfJailFree = !!ScriptParams[1]; + CWorld::Players[GET_INTEGER_PARAM(0)].m_bGetOutOfJailFree = !!GET_INTEGER_PARAM(1); return 0; - */ case COMMAND_SET_FREE_HEALTH_CARE: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_bGetOutOfHospitalFree = !!ScriptParams[1]; + CWorld::Players[GET_INTEGER_PARAM(0)].m_bGetOutOfHospitalFree = !!GET_INTEGER_PARAM(1); return 0; /* case COMMAND_IS_CAR_DOOR_CLOSED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(!pVehicle->IsDoorMissing((eDoors)ScriptParams[1]) && pVehicle->IsDoorClosed((eDoors)ScriptParams[1])); + UpdateCompareFlag(!pVehicle->IsDoorMissing((eDoors)GET_INTEGER_PARAM(1)) && pVehicle->IsDoorClosed((eDoors)GET_INTEGER_PARAM(1))); return 0; } */ @@ -373,12 +377,15 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) #endif CollectParameters(&m_nIp, 1); - if (CTheScripts::NumberOfExclusiveMissionScripts > 0 && ScriptParams[0] <= UINT16_MAX - 2) - return 0; + if (CTheScripts::NumberOfExclusiveMissionScripts > 0) { + if (GET_INTEGER_PARAM(0) < UINT16_MAX - 1) + return 0; + SET_INTEGER_PARAM(0, UINT16_MAX - GET_INTEGER_PARAM(0)); + } #ifdef MISSION_REPLAY - missionRetryScriptIndex = ScriptParams[0]; + missionRetryScriptIndex = GET_INTEGER_PARAM(0); #ifdef USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT - if (!UsingMobileScript && CTheScripts::MissionSupportsMissionReplay(missionRetryScriptIndex)){ + if (CTheScripts::MissionSupportsMissionReplay(missionRetryScriptIndex)){ if (!AlreadySavedGame) { m_nIp = oldIp - 2; SaveGameForPause(SAVE_TYPE_QUICKSAVE_FOR_SCRIPT); @@ -392,41 +399,38 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) #endif #endif CTimer::Suspend(); - int offset = CTheScripts::MultiScriptArray[ScriptParams[0]]; -#ifdef USE_DEBUG_SCRIPT_LOADER - int handle = CTheScripts::OpenScript(); -#else - CFileMgr::ChangeDir("\\"); - int handle = CFileMgr::OpenFile("data\\main.scm", "rb"); -#endif - CFileMgr::Seek(handle, offset, 0); - CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[SIZE_MAIN_SCRIPT], SIZE_MISSION_SCRIPT); - CFileMgr::CloseFile(handle); - CRunningScript* pMissionScript = CTheScripts::StartNewScript(SIZE_MAIN_SCRIPT); + int offset = CTheScripts::MultiScriptArray[GET_INTEGER_PARAM(0)] + 8; + int size = CTheScripts::MultiScriptArray[GET_INTEGER_PARAM(0) + 1] - CTheScripts::MultiScriptArray[GET_INTEGER_PARAM(0)]; + if (size <= 0) + size = CTheScripts::LargestMissionScriptSize; + CFileMgr::Seek(gScriptsFile, offset, 0); + CFileMgr::Read(gScriptsFile, (const char*)&CTheScripts::ScriptSpace[CTheScripts::MainScriptSize], size); + CRunningScript* pMissionScript = CTheScripts::StartNewScript(CTheScripts::MainScriptSize); CTimer::Resume(); pMissionScript->m_bIsMissionScript = true; pMissionScript->m_bMissionFlag = true; CTheScripts::bAlreadyRunningAMissionScript = true; - CGameLogic::ClearShortCut(); + memset(&CTheScripts::ScriptSpace[CTheScripts::NumTrueGlobals * 4 + 8], 0, CTheScripts::MostGlobals * 4); + pMissionScript->Process(); return 0; } case COMMAND_SET_OBJECT_DRAW_LAST: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bDrawLast = !!ScriptParams[1]; + pObject->bDrawLast = !!GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_AMMO_IN_PLAYER_WEAPON: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - ScriptParams[0] = 0; + SET_INTEGER_PARAM(0, 0); for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - if (pPed->GetWeapon(i).m_eWeaponType == (eWeaponType)ScriptParams[1]) - ScriptParams[0] = pPed->GetWeapon(i).m_nAmmoTotal; + if (pPed->GetWeapon(i).m_eWeaponType == (eWeaponType)GET_INTEGER_PARAM(1)) + SET_INTEGER_PARAM(0, pPed->GetWeapon(i).m_nAmmoTotal); } StoreParameters(&m_nIp, 1); return 0; @@ -435,83 +439,69 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_AMMO_IN_CHAR_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CWeapon* pWeaponSlot = &pPed->m_weapons[ScriptParams[1]]; - if (pWeaponSlot->m_eWeaponType == (eWeaponType)ScriptParams[1]) - ScriptParams[0] = pWeaponSlot->m_nAmmoTotal; + CWeapon* pWeaponSlot = &pPed->m_weapons[GET_INTEGER_PARAM(1)]; + if (pWeaponSlot->m_eWeaponType == (eWeaponType)GET_INTEGER_PARAM(1)) + SET_INTEGER_PARAM(0, pWeaponSlot->m_nAmmoTotal); else - ScriptParams[0] = 0; + SET_INTEGER_PARAM(0, 0); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_REGISTER_KILL_FRENZY_PASSED: CStats::AnotherKillFrenzyPassed(); return 0; + */ case COMMAND_SET_CHAR_SAY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - switch (ScriptParams[1]) { - case SCRIPT_SOUND_CHUNKY_RUN_SHOUT: - pPed->Say(SOUND_PED_FLEE_RUN); - break; - case SCRIPT_SOUND_SECURITY_GUARD_AWAY_SHOUT: - pPed->Say(SOUND_PED_FLEE_RUN); - break; - case SCRIPT_SOUND_SWAT_PED_SHOUT: - pPed->Say(SOUND_PED_PURSUIT_SWAT); - break; - case SCRIPT_SOUND_AMMUNATION_CHAT_1: - pPed->Say(SOUND_AMMUNATION_WELCOME_1); - break; - case SCRIPT_SOUND_AMMUNATION_CHAT_2: - pPed->Say(SOUND_AMMUNATION_WELCOME_2); - break; - case SCRIPT_SOUND_AMMUNATION_CHAT_3: - pPed->Say(SOUND_AMMUNATION_WELCOME_3); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + switch (GET_INTEGER_PARAM(1)) { + case 15: + pPed->Say(0x93); // TODO break; default: break; } return 0; } - */ case COMMAND_SET_NEAR_CLIP: CollectParameters(&m_nIp, 1); - TheCamera.SetNearClipScript(*(float*)&ScriptParams[0]); + TheCamera.SetNearClipScript(GET_FLOAT_PARAM(0)); return 0; case COMMAND_SET_RADIO_CHANNEL: CollectParameters(&m_nIp, 2); - DMAudio.SetRadioChannel(ScriptParams[0], ScriptParams[1]); + if (!cCustomSoundTrack::Instance()->IsPlaying()) + DMAudio.SetRadioChannel(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; /* case COMMAND_OVERRIDE_HOSPITAL_LEVEL: CollectParameters(&m_nIp, 1); - CRestart::OverrideHospitalLevel = ScriptParams[0]; + CRestart::OverrideHospitalLevel = GET_INTEGER_PARAM(0); return 0; case COMMAND_OVERRIDE_POLICE_STATION_LEVEL: CollectParameters(&m_nIp, 1); - CRestart::OverridePoliceStationLevel = ScriptParams[0]; + CRestart::OverridePoliceStationLevel = GET_INTEGER_PARAM(0); return 0; case COMMAND_FORCE_RAIN: CollectParameters(&m_nIp, 1); - CWeather::bScriptsForceRain = !!ScriptParams[0]; + CWeather::bScriptsForceRain = !!GET_INTEGER_PARAM(0); return 0; + */ case COMMAND_DOES_GARAGE_CONTAIN_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); - UpdateCompareFlag(CGarages::IsThisCarWithinGarageArea(ScriptParams[0], pVehicle)); + UpdateCompareFlag(CGarages::IsThisCarWithinGarageArea(GET_INTEGER_PARAM(0), pVehicle)); return 0; } - */ case COMMAND_SET_CAR_TRACTION: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - float fTraction = *(float*)&ScriptParams[1]; + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + float fTraction = GET_FLOAT_PARAM(1); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR || pVehicle->m_vehType == VEHICLE_TYPE_BIKE); if (pVehicle->m_vehType == VEHICLE_TYPE_CAR) ((CAutomobile*)pVehicle)->m_fTraction = fTraction; @@ -529,33 +519,32 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_CONVERT_METRES_TO_FEET: { CollectParameters(&m_nIp, 1); - float fMeterValue = *(float*)&ScriptParams[0]; + float fMeterValue = GET_FLOAT_PARAM(0); float fFeetValue = fMeterValue / METERS_IN_FOOT; - *(float*)&ScriptParams[0] = fFeetValue; + SET_FLOAT_PARAM(0, fFeetValue); StoreParameters(&m_nIp, 1); return 0; } - /* case COMMAND_MARK_ROADS_BETWEEN_LEVELS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.MarkRoadsBetweenLevelsInArea(infX, supX, infY, supY, infZ, supZ); return 0; @@ -563,123 +552,136 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_MARK_PED_ROADS_BETWEEN_LEVELS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.PedMarkRoadsBetweenLevelsInArea(infX, supX, infY, supY, infZ, supZ); return 0; } - */ case COMMAND_SET_CAR_AVOID_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_bStayInCurrentLevel = !!ScriptParams[1]; + pVehicle->AutoPilot.m_bStayInCurrentLevel = !!GET_INTEGER_PARAM(1); return 0; } /* case COMMAND_SET_CHAR_AVOID_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pPed); // not implemented return 0; } case COMMAND_IS_THREAT_FOR_PED_TYPE: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CPedType::IsThreat(ScriptParams[0], ScriptParams[1])); + UpdateCompareFlag(CPedType::IsThreat(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); return 0; */ case COMMAND_CLEAR_AREA_OF_CHARS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } CWorld::ClearPedsFromArea(infX, infY, infZ, supX, supY, supZ); return 0; } case COMMAND_SET_TOTAL_NUMBER_OF_MISSIONS: CollectParameters(&m_nIp, 1); - CStats::SetTotalNumberMissions(CGame::germanGame ? ScriptParams[0] - 2 : ScriptParams[0]); + CStats::SetTotalNumberMissions(CGame::germanGame ? GET_INTEGER_PARAM(0) - 2 : GET_INTEGER_PARAM(0)); return 0; case COMMAND_CONVERT_METRES_TO_FEET_INT: CollectParameters(&m_nIp, 1); - ScriptParams[0] *= FEET_IN_METER; + GET_INTEGER_PARAM(0) *= FEET_IN_METER; StoreParameters(&m_nIp, 1); return 0; case COMMAND_REGISTER_FASTEST_TIME: CollectParameters(&m_nIp, 2); - CStats::RegisterFastestTime(ScriptParams[0], ScriptParams[1]); + CStats::RegisterFastestTime(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_REGISTER_HIGHEST_SCORE: CollectParameters(&m_nIp, 2); - CStats::RegisterHighestScore(ScriptParams[0], ScriptParams[1]); + CStats::RegisterHighestScore(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_WARP_CHAR_INTO_CAR_AS_PASSENGER: + { + CollectParameters(&m_nIp, 3); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + script_assert(pPed); + script_assert(pVehicle); + if (GET_INTEGER_PARAM(2) < 0) + pPed->WarpPedIntoCarAsPassenger(pVehicle, GET_INTEGER_PARAM(2)); + else { + script_assert(GET_INTEGER_PARAM(2) >= 0 && GET_INTEGER_PARAM(2) < ARRAY_SIZE(pVehicle->pPassengers)); + pPed->WarpPedIntoCarAsPassenger(pVehicle, GET_INTEGER_PARAM(2)); + } return 0; - //case COMMAND_WARP_CHAR_INTO_CAR_AS_PASSENGER: + + } case COMMAND_IS_CAR_PASSENGER_SEAT_FREE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(ScriptParams[1] < pVehicle->m_nNumMaxPassengers && pVehicle->pPassengers[ScriptParams[1]] == nil); + UpdateCompareFlag(GET_INTEGER_PARAM(1) < pVehicle->m_nNumMaxPassengers && pVehicle->pPassengers[GET_INTEGER_PARAM(1)] == nil); return 0; } - /* case COMMAND_GET_CHAR_IN_CAR_PASSENGER_SEAT: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - script_assert(ScriptParams[1] >= 0 && ScriptParams[1] < ARRAY_SIZE(pVehicle->pPassengers)); - CPed* pPassenger = pVehicle->pPassengers[ScriptParams[1]]; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPassenger); + script_assert(GET_INTEGER_PARAM(1) >= 0 && GET_INTEGER_PARAM(1) < ARRAY_SIZE(pVehicle->pPassengers)); + CPed* pPassenger = pVehicle->pPassengers[GET_INTEGER_PARAM(1)]; + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPassenger)); StoreParameters(&m_nIp, 1); return 0; } - */ case COMMAND_SET_CHAR_IS_CHRIS_CRIMINAL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bChrisCriminal = !!ScriptParams[1]; + pPed->bChrisCriminal = !!GET_INTEGER_PARAM(1); return 0; } case COMMAND_START_CREDITS: - CCredits::Start(); + CollectParameters(&m_nIp, 1); + CCredits::Start(); // TODO: CCredits::Start(GET_INTEGER_PARAM(0)) return 0; case COMMAND_STOP_CREDITS: CCredits::Stop(); @@ -689,16 +691,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; case COMMAND_CREATE_SINGLE_PARTICLE: CollectParameters(&m_nIp, 8); - CParticle::AddParticle((tParticleType)ScriptParams[0], *(CVector*)&ScriptParams[1], - *(CVector*)&ScriptParams[4], nil, *(float*)&ScriptParams[7], 0, 0, 0, 0); + CParticle::AddParticle((tParticleType)GET_INTEGER_PARAM(0), GET_VECTOR_PARAM(1), + GET_VECTOR_PARAM(4), nil, GET_FLOAT_PARAM(7), 0, 0, 0, 0); return 0; /* case COMMAND_SET_CHAR_IGNORE_LEVEL_TRANSITIONS: { 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->m_nZoneLevel = LEVEL_IGNORE; else pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); @@ -707,11 +709,11 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_CHASE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CRecordDataForChase::TurnChaseCarIntoScriptCar(ScriptParams[0]); - ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); + CVehicle* pVehicle = CRecordDataForChase::TurnChaseCarIntoScriptCar(GET_INTEGER_PARAM(0)); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CAR); return 0; } case COMMAND_START_BOAT_FOAM_ANIMATION: @@ -720,7 +722,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_UPDATE_BOAT_FOAM_ANIMATION: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix()); return 0; @@ -728,12 +730,12 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) */ case COMMAND_SET_MUSIC_DOES_FADE: CollectParameters(&m_nIp, 1); - TheCamera.m_bIgnoreFadingStuffForMusic = (ScriptParams[0] == 0); + TheCamera.m_bIgnoreFadingStuffForMusic = (GET_INTEGER_PARAM(0) == 0); return 0; /* case COMMAND_SET_INTRO_IS_PLAYING: CollectParameters(&m_nIp, 1); - if (ScriptParams[0]) { + if (GET_INTEGER_PARAM(0)) { CGame::playingIntro = true; CStreaming::RemoveCurrentZonesModels(); } else { @@ -745,17 +747,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CStreaming::LoadAllRequestedModels(false); } return 0; - */ case COMMAND_SET_PLAYER_HOOKER: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - if (ScriptParams[1] < 0) { + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + if (GET_INTEGER_PARAM(1) < 0) { pPlayerInfo->m_pHooker = nil; pPlayerInfo->m_nNextSexFrequencyUpdateTime = 0; pPlayerInfo->m_nNextSexMoneyUpdateTime = 0; } else { - CPed* pHooker = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pHooker = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pHooker); pPlayerInfo->m_pHooker = (CCivilianPed*)pHooker; pPlayerInfo->m_nSexFrequency = 1000; @@ -764,8 +765,10 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) } return 0; } + */ case COMMAND_PLAY_END_OF_GAME_TUNE: - DMAudio.PlayPreloadedCutSceneMusic(); + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); + DMAudio.PlayFrontEndTrack(STREAMED_SOUND_CUTSCENE_FINALE, 1); // third parameter is 1 return 0; case COMMAND_STOP_END_OF_GAME_TUNE: DMAudio.StopCutSceneMusic(); @@ -774,25 +777,25 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_CAR_MODEL: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->GetModelIndex(); + SET_INTEGER_PARAM(0, pVehicle->GetModelIndex()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_PLAYER_SITTING_IN_CAR: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR && pPed->m_pMyVehicle == pVehicle); return 0; } case COMMAND_IS_PLAYER_SITTING_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR); return 0; @@ -800,7 +803,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) /* case COMMAND_SET_SCRIPT_FIRE_AUDIO: CollectParameters(&m_nIp, 2); - gFireManager.SetScriptFireAudio(ScriptParams[0], !!ScriptParams[1]); + gFireManager.SetScriptFireAudio(GET_INTEGER_PARAM(0), !!GET_INTEGER_PARAM(1)); return 0; */ case COMMAND_ARE_ANY_CAR_CHEATS_ACTIVATED: @@ -809,16 +812,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CHAR_SUFFERS_CRITICAL_HITS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bNoCriticalHits = (ScriptParams[1] == 0); + pPed->bNoCriticalHits = (GET_INTEGER_PARAM(1) == 0); return 0; } /* case COMMAND_IS_PLAYER_LIFTING_A_PHONE: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_MAKE_CALL); return 0; @@ -827,9 +830,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_SITTING_IN_CAR: { 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); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR && pPed->m_pMyVehicle == pVehicle); return 0; @@ -837,7 +840,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_SITTING_IN_ANY_CAR: { 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->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR); return 0; @@ -845,7 +848,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_PLAYER_ON_FOOT: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(!pPed->bInVehicle && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); @@ -854,7 +857,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_ON_FOOT: { 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->bInVehicle && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); @@ -874,7 +877,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_LOAD_COLLISION_WITH_SCREEN: CollectParameters(&m_nIp, 1); CTimer::Stop(); - CGame::currLevel = (eLevelName)ScriptParams[0]; + CGame::currLevel = (eLevelName)GET_INTEGER_PARAM(0); if (CGame::currLevel != CCollision::ms_collisionInMemory) { ISLAND_LOADING_IS(LOW) { @@ -918,9 +921,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_CAR_IGNORE_LEVEL_TRANSITIONS: { 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->m_nZoneLevel = LEVEL_IGNORE; else pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); @@ -929,61 +932,55 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_MAKE_CRAIGS_CAR_A_BIT_STRONGER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; - pCar->bMoreResistantToDamage = ScriptParams[1]; + pCar->bMoreResistantToDamage = GET_INTEGER_PARAM(1); return 0; } */ case COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), false); return 0; } case COMMAND_LOAD_END_OF_GAME_TUNE: - DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE); - printf("Start preload end of game audio\n"); - DMAudio.PreloadCutSceneMusic(STREAMED_SOUND_CUTSCENE_FINALE); - printf("End preload end of game audio\n"); return 0; - /* case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA: CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA); return 0; - */ case COMMAND_SET_OBJECT_ROTATION: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CWorld::Remove(pObject); pObject->SetOrientation( - DEGTORAD(*(float*)&ScriptParams[1]), - DEGTORAD(*(float*)&ScriptParams[2]), - DEGTORAD(*(float*)&ScriptParams[3])); + DEGTORAD(GET_FLOAT_PARAM(1)), + DEGTORAD(GET_FLOAT_PARAM(2)), + DEGTORAD(GET_FLOAT_PARAM(3))); pObject->GetMatrix().UpdateRW(); pObject->UpdateRwFrame(); CWorld::Add(pObject); return 0; } case COMMAND_GET_DEBUG_CAMERA_COORDINATES: - *(CVector*)&ScriptParams[0] = TheCamera.Cams[2].Source; + SET_VECTOR_PARAM(0, TheCamera.Cams[2].Source); StoreParameters(&m_nIp, 3); return 0; /* case COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR: - *(CVector*)&ScriptParams[0] = TheCamera.Cams[2].Front; + SET_VECTOR_PARAM(0, TheCamera.Cams[2].Front); StoreParameters(&m_nIp, 3); return 0; case COMMAND_IS_PLAYER_TARGETTING_ANY_CHAR: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); CEntity* pTarget = pPed->m_pPointGunAt; UpdateCompareFlag(pTarget && pTarget->IsPed()); @@ -993,13 +990,13 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_PLAYER_TARGETTING_CHAR: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CPed* pTestedPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTestedPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTestedPed); CEntity* pTarget = pPed->m_pPointGunAt; bool bTargetting = pTarget && pTarget->IsPed() && pTarget == pTestedPed; - // PC shit +#ifdef GTA_PC static int nCounter = 0; nCounter = Max(0, nCounter - 1); if (!pPed->GetWeapon()->IsTypeMelee() && !bTargetting) { @@ -1026,22 +1023,50 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) } } } +#endif UpdateCompareFlag(bTargetting); return 0; } - /* case COMMAND_IS_PLAYER_TARGETTING_OBJECT: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CObject* pTestedObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pTestedObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTestedObject); CEntity* pTarget = pPed->m_pPointGunAt; - UpdateCompareFlag(pTarget && pTarget->IsObject() && pTarget == pTestedObject); + bool bTargetting = pTarget && pTarget->IsObject() && pTarget == pTestedObject; +#ifdef GTA_PC // we will never know if section is real + static int nCounter = 0; + nCounter = Max(0, nCounter - 1); + if (!pPed->GetWeapon()->IsTypeMelee() && !bTargetting) { + if ((pTestedObject->GetPosition() - TheCamera.GetPosition()).Magnitude() < 10.0f) { + CVector vTestedPos(pTestedObject->GetPosition().x, pTestedObject->GetPosition().y, pTestedObject->GetPosition().z); + CVector vScreenPos; + float w, h; + if (CSprite::CalcScreenCoors(vTestedPos, &vScreenPos, &w, &h, false)) { + CVector2D vCrosshairPosition(CCamera::m_f3rdPersonCHairMultX * RsGlobal.maximumWidth, CCamera::m_f3rdPersonCHairMultY * RsGlobal.maximumHeight); + float fScreenDistance = ((CVector2D)vScreenPos - vCrosshairPosition).Magnitude(); + if (SCREEN_STRETCH_X(0.45f) > fScreenDistance / w) { + CColPoint point; + CEntity* entity; + if (!CWorld::ProcessLineOfSight(TheCamera.GetPosition() + 2.0f * TheCamera.GetForward(), + vTestedPos, point, entity, true, true, true, true, true, false) || + entity == pTestedObject) { + nCounter += 2; + if (nCounter > 20) { + bTargetting = true; + nCounter = 20; + } + } + } + } + } + } + UpdateCompareFlag(bTargetting); +#endif return 0; } - */ case COMMAND_TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME: { CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); @@ -1063,10 +1088,10 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = GET_FLOAT_PARAM(0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = GET_FLOAT_PARAM(1); CollectParameters(&m_nIp, 1); - CMessages::InsertNumberInString(text, ScriptParams[0], -1, -1, -1, -1, -1, + CMessages::InsertNumberInString(text, GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1, CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame++].m_Text); return 0; } @@ -1074,10 +1099,10 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = GET_FLOAT_PARAM(0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = GET_FLOAT_PARAM(1); CollectParameters(&m_nIp, 2); - CMessages::InsertNumberInString(text, ScriptParams[0], ScriptParams[1], -1, -1, -1, -1, + CMessages::InsertNumberInString(text, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1, CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame++].m_Text); return 0; } @@ -1092,11 +1117,11 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) return 0; /* CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float range = *(float*)&ScriptParams[3]; - int mi = ScriptParams[4] < 0 ? CTheScripts::UsedObjectArray[-ScriptParams[4]].index : ScriptParams[4]; + float range = GET_FLOAT_PARAM(3); + int mi = GET_INTEGER_PARAM(4) < 0 ? CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(4)].index : GET_INTEGER_PARAM(4); int16 total; CEntity* apEntities[16]; CWorld::FindObjectsOfTypeInRange(mi, pos, range, true, &total, 16, apEntities, false, false, false, true, true); @@ -1128,9 +1153,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) script_assert(pClosestEntity->IsObject()); CObject* pObject = (CObject*)pClosestEntity; pObject->ObjectCreatedBy = MISSION_OBJECT; - ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObject); + SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pObject)); } else { - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); } StoreParameters(&m_nIp, 1); return 0; @@ -1140,11 +1165,11 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_PLACE_OBJECT_RELATIVE_TO_OBJECT: { CollectParameters(&m_nIp, 5); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pTarget = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); - CVector offset = *(CVector*)&ScriptParams[2]; + CVector offset = GET_VECTOR_PARAM(2); CPhysical::PlacePhysicalRelativeToOtherPhysical(pTarget, pObject, offset); return 0; } @@ -1152,79 +1177,81 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_ALL_OCCUPANTS_OF_CAR_LEAVE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CCarAI::TellOccupantsToLeaveCar(pVehicle); return 0; } case COMMAND_SET_INTERPOLATION_PARAMETERS: CollectParameters(&m_nIp, 2); - TheCamera.SetParametersForScriptInterpolation(*(float*)&ScriptParams[0], 100.0f - *(float*)&ScriptParams[0], ScriptParams[1]); + TheCamera.SetParametersForScriptInterpolation(GET_FLOAT_PARAM(0), 100.0f - GET_FLOAT_PARAM(0), GET_INTEGER_PARAM(1)); return 0; /* case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING_TOWARDS_POINT: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float destX = *(float*)&ScriptParams[3]; - float destY = *(float*)&ScriptParams[4]; + float destX = GET_FLOAT_PARAM(3); + float destY = GET_FLOAT_PARAM(4); int32 nid = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true); CPathNode* pNode = &ThePaths.m_pathNodes[nid]; - *(CVector*)&ScriptParams[0] = pNode->GetPosition(); - *(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, true); + SET_VECTOR_PARAM(0, pNode->GetPosition()); + SET_FLOAT_PARAM(3, ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, true)); StoreParameters(&m_nIp, 4); return 0; } case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING_AWAY_POINT: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float destX = *(float*)&ScriptParams[3]; - float destY = *(float*)&ScriptParams[4]; + float destX = GET_FLOAT_PARAM(3); + float destY = GET_FLOAT_PARAM(4); int32 nid = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true); CPathNode* pNode = &ThePaths.m_pathNodes[nid]; - *(CVector*)&ScriptParams[0] = pNode->GetPosition(); - *(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, false); + SET_VECTOR_PARAM(0, pNode->GetPosition()); + SET_FLOAT_PARAM(3, ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, false)); StoreParameters(&m_nIp, 4); return 0; } */ case COMMAND_GET_DEBUG_CAMERA_POINT_AT: - *(CVector*)&ScriptParams[0] = TheCamera.Cams[2].Source + TheCamera.Cams[2].Front; + SET_VECTOR_PARAM(0, TheCamera.Cams[2].Source + TheCamera.Cams[2].Front); StoreParameters(&m_nIp, 3); return 0; case COMMAND_ATTACH_CHAR_TO_CAR: { CollectParameters(&m_nIp, 8); - CPed *pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - pPed->AttachPedToEntity(pVehicle, *(CVector*)&ScriptParams[2], ScriptParams[5], DEGTORAD(*(float*)&ScriptParams[6]), (eWeaponType)ScriptParams[7]); + CPed *pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + pPed->AttachPedToEntity(pVehicle, GET_VECTOR_PARAM(2), GET_INTEGER_PARAM(5), DEGTORAD(GET_FLOAT_PARAM(6)), (eWeaponType)GET_INTEGER_PARAM(7)); return 0; } case COMMAND_DETACH_CHAR_FROM_CAR: { CollectParameters(&m_nIp, 1); - CPed *pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - if (pPed && pPed->m_attachedTo) + CPed *pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (pPed && pPed->m_attachedTo) { pPed->DettachPedFromEntity(); + pPed->bIsAimingGun = false; + } return 0; } case COMMAND_SET_CAR_CHANGE_LANE: // for some reason changed in SA { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_bStayInFastLane = !ScriptParams[1]; + pVehicle->AutoPilot.m_bStayInFastLane = !GET_INTEGER_PARAM(1); return 0; } case COMMAND_CLEAR_CHAR_LAST_WEAPON_DAMAGE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); if (pPed) pPed->m_lastWepDam = -1; else @@ -1234,7 +1261,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_CLEAR_CAR_LAST_WEAPON_DAMAGE: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle) pVehicle->m_nLastWeaponDamage = -1; else @@ -1246,10 +1273,10 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) CollectParameters(&m_nIp, 9); 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); @@ -1259,7 +1286,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) continue; if (pPed->m_nPedType != PEDTYPE_COP) continue; - if (!ThisIsAValidRandomCop(pPed->GetModelIndex(), ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8])) + if (!ThisIsAValidRandomCop(pPed->GetModelIndex(), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8))) continue; if (pPed->CharCreatedBy != RANDOM_CHAR) continue; @@ -1285,7 +1312,7 @@ int8 CRunningScript::ProcessCommands1100To1199(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; } @@ -1333,7 +1360,7 @@ int8 CRunningScript::ProcessCommands1100To1199(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; } @@ -1341,9 +1368,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_CAR: { 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); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CAR, pVehicle); @@ -1352,20 +1379,20 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_GET_DRIVER_OF_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CPed* pDriver = pVehicle->pDriver; if (pDriver) - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pDriver); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pDriver)); else - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_NUMBER_OF_FOLLOWERS: { CollectParameters(&m_nIp, 1); - CPed* pLeader = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pLeader = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pLeader); int total = 0; int i = CPools::GetPedPool()->GetSize(); @@ -1376,34 +1403,34 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) if (pPed->m_leader == pLeader) total++; } - ScriptParams[0] = total; + SET_INTEGER_PARAM(0, total); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GIVE_REMOTE_CONTROLLED_MODEL_TO_PLAYER: { CollectParameters(&m_nIp, 6); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(*(float*)&ScriptParams[4]), ScriptParams[5]); + CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), GET_INTEGER_PARAM(5)); return 0; } case COMMAND_GET_CURRENT_PLAYER_WEAPON: { 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); - ScriptParams[0] = pPed->GetWeapon()->m_eWeaponType; + SET_INTEGER_PARAM(0, pPed->GetWeapon()->m_eWeaponType); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_CURRENT_CHAR_WEAPON: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->GetWeapon()->m_eWeaponType; + SET_INTEGER_PARAM(0, pPed->GetWeapon()->m_eWeaponType); StoreParameters(&m_nIp, 1); return 0; } @@ -1418,36 +1445,36 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_CAR_TEMP_ACTION: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_nTempAction = (uint8)ScriptParams[1]; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[2]; + pVehicle->AutoPilot.m_nTempAction = (uint8)GET_INTEGER_PARAM(1); + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(2); return 0; } /* case COMMAND_SET_CAR_HANDBRAKE_TURN_RIGHT: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKETURNRIGHT; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CAR_HANDBRAKE_STOP: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKESTRAIGHT; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(1); return 0; } */ case COMMAND_IS_CHAR_ON_ANY_BIKE: { 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->bInVehicle&& pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE); return 0; @@ -1457,16 +1484,16 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_LOCATE_SNIPER_BULLET_3D: LocateSniperBulletCommand(command, &m_nIp); return 0; - */ case COMMAND_GET_NUMBER_OF_SEATS_IN_MODEL: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(ScriptParams[0]) + 1; + SET_INTEGER_PARAM(0, CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(GET_INTEGER_PARAM(0)) + 1); StoreParameters(&m_nIp, 1); return 0; + */ case COMMAND_IS_PLAYER_ON_ANY_BIKE: { 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->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE); return 0; @@ -1475,7 +1502,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CHAR_LYING_DOWN: { 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->bFallenDown); return 0; @@ -1484,9 +1511,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_CAN_CHAR_SEE_DEAD_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - int pedtype = ScriptParams[1]; + int pedtype = GET_INTEGER_PARAM(1); bool can = false; for (int i = 0; i < pPed->m_numNearPeds; i++) { CPed* pTestPed = pPed->m_nearPeds[i]; @@ -1498,69 +1525,75 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) } case COMMAND_SET_ENTER_CAR_RANGE_MULTIPLIER: CollectParameters(&m_nIp, 1); - CPed::nEnterCarRangeMultiplier = *(float*)&ScriptParams[0]; + CPed::nEnterCarRangeMultiplier = GET_FLOAT_PARAM(0); return 0; case COMMAND_SET_THREAT_REACTION_RANGE_MULTIPLIER: CollectParameters(&m_nIp, 1); - CPed::nThreatReactionRangeMultiplier = *(float*)&ScriptParams[0]; + CPed::nThreatReactionRangeMultiplier = GET_FLOAT_PARAM(0); + if (CPed::nThreatReactionRangeMultiplier < 1) + CPed::nThreatReactionRangeMultiplier = 1; return 0; case COMMAND_SET_CHAR_CEASE_ATTACK_TIMER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_ceaseAttackTimer = ScriptParams[1]; + pPed->m_ceaseAttackTimer = GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_REMOTE_CONTROLLED_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CWorld::Players[ScriptParams[0]].m_pRemoteVehicle; + CVehicle* pVehicle = CWorld::Players[GET_INTEGER_PARAM(0)].m_pRemoteVehicle; if (pVehicle) - ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); else - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_PC_VERSION: +#ifdef GTA_PC UpdateCompareFlag(true); +#else + UpdateCompareFlag(false); +#endif return 0; //case COMMAND_REPLAY: //case COMMAND_IS_REPLAY_PLAYING: case COMMAND_IS_MODEL_AVAILABLE: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CModelInfo::GetModelInfo(ScriptParams[0]) != nil); + UpdateCompareFlag(CModelInfo::GetModelInfo(GET_INTEGER_PARAM(0)) != nil); return 0; case COMMAND_SHUT_CHAR_UP: CollectParameters(&m_nIp, 2); - DMAudio.SetPedTalkingStatus(CPools::GetPedPool()->GetAt(ScriptParams[0]), ScriptParams[1] == 0); + DMAudio.SetPedTalkingStatus(CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)), GET_INTEGER_PARAM(1) == 0); return 0; case COMMAND_SET_ENABLE_RC_DETONATE: CollectParameters(&m_nIp, 1); - CVehicle::bDisableRemoteDetonation = !ScriptParams[0]; + CVehicle::bDisableRemoteDetonation = !GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_CAR_RANDOM_ROUTE_SEED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->m_nRouteSeed = ScriptParams[1]; + pVehicle->m_nRouteSeed = GET_INTEGER_PARAM(1); return 0; } case COMMAND_IS_ANY_PICKUP_AT_COORDS: { - CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; - CRunningScript::UpdateCompareFlag(CPickups::TestForPickupsInBubble(pos, 0.5f)); + CollectParameters(&m_nIp, 4); + CVector pos = GET_VECTOR_PARAM(0); + CRunningScript::UpdateCompareFlag(CPickups::TestForPickupsInBubble(pos, GET_FLOAT_PARAM(3))); return 0; } - case COMMAND_GET_FIRST_PICKUP_COORDS: - case COMMAND_GET_NEXT_PICKUP_COORDS: + //case COMMAND_GET_FIRST_PICKUP_COORDS: + //case COMMAND_GET_NEXT_PICKUP_COORDS: case COMMAND_REMOVE_ALL_CHAR_WEAPONS: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->ClearWeapons(); return 0; @@ -1568,11 +1601,26 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_HAS_PLAYER_GOT_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + script_assert(pPed); + bool bFound = false; + for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { + if (pPed->GetWeapon(i).m_eWeaponType == GET_INTEGER_PARAM(1)) { + bFound = true; + break; + } + } + UpdateCompareFlag(bFound); + return 0; + } + case COMMAND_HAS_CHAR_GOT_WEAPON: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); bool bFound = false; for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - if (pPed->GetWeapon(i).m_eWeaponType == ScriptParams[1]) { + if (pPed->GetWeapon(i).m_eWeaponType == GET_INTEGER_PARAM(1)) { bFound = true; break; } @@ -1580,31 +1628,30 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) UpdateCompareFlag(bFound); return 0; } - //case COMMAND_HAS_CHAR_GOT_WEAPON: //case COMMAND_IS_PLAYER_FACING_CHAR: case COMMAND_SET_TANK_DETONATE_CARS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle && pVehicle->m_vehType == VEHICLE_TYPE_CAR); - ((CAutomobile*)pVehicle)->bTankDetonateCars = ScriptParams[1]; + ((CAutomobile*)pVehicle)->bTankDetonateCars = GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_POSITION_OF_ANALOGUE_STICKS: { CollectParameters(&m_nIp, 1); - CPad* pPad = CPad::GetPad(ScriptParams[0]); - ScriptParams[0] = pPad->NewState.LeftStickX; - ScriptParams[1] = pPad->NewState.LeftStickY; - ScriptParams[2] = pPad->NewState.RightStickX; - ScriptParams[3] = pPad->NewState.RightStickY; + CPad* pPad = CPad::GetPad(GET_INTEGER_PARAM(0)); + SET_INTEGER_PARAM(0, pPad->NewState.LeftStickX); + SET_INTEGER_PARAM(1, pPad->NewState.LeftStickY); + SET_INTEGER_PARAM(2, pPad->NewState.RightStickX); + SET_INTEGER_PARAM(3, pPad->NewState.RightStickY); StoreParameters(&m_nIp, 4); return 0; } case COMMAND_IS_CAR_ON_FIRE: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); bool bOnFire = false; if (pVehicle->m_pCarFire) @@ -1619,35 +1666,35 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CAR_TYRE_BURST: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); bool bIsBurst = false; CBike* pBike = (CBike*)pVehicle; if (pVehicle->IsBike()) { - if (ScriptParams[1] == 4) { + if (GET_INTEGER_PARAM(1) == 4) { for (int i = 0; i < 2; i++) { if (pBike->m_wheelStatus[i] == WHEEL_STATUS_BURST) bIsBurst = true; } } else { - if (ScriptParams[1] == 2) - ScriptParams[1] = 0; - if (ScriptParams[1] == 3) - ScriptParams[1] = 1; - bIsBurst = pBike->m_wheelStatus[ScriptParams[1]] == WHEEL_STATUS_BURST; + if (GET_INTEGER_PARAM(1) == 2) + SET_INTEGER_PARAM(1, 0); + if (GET_INTEGER_PARAM(1) == 3) + SET_INTEGER_PARAM(1, 1); + bIsBurst = pBike->m_wheelStatus[GET_INTEGER_PARAM(1)] == WHEEL_STATUS_BURST; } } else { CAutomobile* pCar = (CAutomobile*)pVehicle; - if (ScriptParams[1] == 4) { + if (GET_INTEGER_PARAM(1) == 4) { for (int i = 0; i < 4; i++) { if (pCar->Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST) bIsBurst = true; } } else - bIsBurst = pCar->Damage.GetWheelStatus(ScriptParams[1] == WHEEL_STATUS_BURST); + bIsBurst = pCar->Damage.GetWheelStatus(GET_INTEGER_PARAM(1) == WHEEL_STATUS_BURST); } UpdateCompareFlag(bIsBurst); return 0; @@ -1663,125 +1710,131 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) while (counter < 3 && CScriptPaths::aArray[counter].m_state != SCRIPT_PATH_DISABLED) { counter++; } - CScriptPaths::aArray[counter].InitialiseOne(ScriptParams[0], *(float*)&ScriptParams[1]); - ScriptParams[0] = counter; + CScriptPaths::aArray[counter].InitialiseOne(GET_INTEGER_PARAM(0), GET_FLOAT_PARAM(1)); + SET_INTEGER_PARAM(0, counter); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_START_OBJECT_ON_PATH: { CollectParameters(&m_nIp, 2); - CObject *pObj = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject *pObj = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); assert(pObj); - CScriptPaths::aArray[ScriptParams[1]].SetObjectToControl(pObj); + CScriptPaths::aArray[GET_INTEGER_PARAM(1)].SetObjectToControl(pObj); return 0; } case COMMAND_SET_OBJECT_PATH_SPEED: { CollectParameters(&m_nIp, 2); - CScriptPaths::aArray[ScriptParams[0]].m_fSpeed = *(float*)&ScriptParams[1]; + CScriptPaths::aArray[GET_INTEGER_PARAM(0)].m_fSpeed = GET_FLOAT_PARAM(1); return 0; } case COMMAND_SET_OBJECT_PATH_POSITION: { CollectParameters(&m_nIp, 2); - CScriptPaths::aArray[ScriptParams[0]].m_fPosition = *(float*)&ScriptParams[1]; + CScriptPaths::aArray[GET_INTEGER_PARAM(0)].m_fPosition = GET_FLOAT_PARAM(1); return 0; } //case COMMAND_GET_OBJECT_DISTANCE_ALONG_PATH: case COMMAND_CLEAR_OBJECT_PATH: { CollectParameters(&m_nIp, 1); - CScriptPaths::aArray[ScriptParams[0]].Clear(); + CScriptPaths::aArray[GET_INTEGER_PARAM(0)].Clear(); return 0; } case COMMAND_HELI_GOTO_COORDS: { CollectParameters(&m_nIp, 5); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); - ((CAutomobile*)pVehicle)->TellHeliToGoToCoors(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], ScriptParams[4]); + ((CAutomobile*)pVehicle)->TellHeliToGoToCoors(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4)); return 0; } case COMMAND_IS_INT_VAR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_GET_DEAD_CHAR_PICKUP_COORDS: { CollectParameters(&m_nIp, 1); - CPed *pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed *pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CVector pos; pTarget->CreateDeadPedPickupCoors(&pos.x, &pos.y, &pos.z); - *(CVector*)&ScriptParams[0] = pos; + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_CREATE_PROTECTION_PICKUP: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_REVENUE, PICKUP_ASSET_REVENUE, ScriptParams[3], ScriptParams[4]); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_REVENUE, PICKUP_ASSET_REVENUE, GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4))); // TODO: gpModelIndices StoreParameters(&m_nIp, 1); return 0; } + /* case COMMAND_IS_CHAR_IN_ANY_BOAT: { 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->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT); return 0; } + */ case COMMAND_IS_PLAYER_IN_ANY_BOAT: { 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->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT); return 0; } + /* case COMMAND_IS_CHAR_IN_ANY_HELI: { 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->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); return 0; } + */ case COMMAND_IS_PLAYER_IN_ANY_HELI: { 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->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); return 0; } + /* case COMMAND_IS_CHAR_IN_ANY_PLANE: { 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->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE); return 0; } + */ case COMMAND_IS_PLAYER_IN_ANY_PLANE: { 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->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); return 0; @@ -1789,7 +1842,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CHAR_IN_WATER: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed && pPed->bIsInWater); return 0; } @@ -1797,14 +1850,14 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_LVAR_INT_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } default: diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp index 71099cc4..fb8e69fe 100644 --- a/src/control/Script7.cpp +++ b/src/control/Script7.cpp @@ -13,6 +13,7 @@ #include "General.h" #include "Glass.h" #include "Fluff.h" +#include "KeyGen.h" #include "Hud.h" #include "MBlur.h" #include "Pad.h" @@ -31,6 +32,8 @@ #include "World.h" #include "Zones.h" +// LCS: file done except TODOs + int8 CRunningScript::ProcessCommands1200To1299(int32 command) { switch (command) { @@ -38,66 +41,66 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_THAN_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_CONSTANT_GREATER_THAN_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_CONSTANT_GREATER_THAN_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_GET_CHAR_WEAPON_IN_SLOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->GetWeapon(ScriptParams[1] - 1).m_eWeaponType; - ScriptParams[1] = pPed->GetWeapon(ScriptParams[1] - 1).m_nAmmoTotal; - ScriptParams[2] = CPickups::ModelForWeapon((eWeaponType)ScriptParams[0]); + SET_INTEGER_PARAM(0, pPed->GetWeapon(GET_INTEGER_PARAM(1) - 1).m_eWeaponType); + SET_INTEGER_PARAM(1, pPed->GetWeapon(GET_INTEGER_PARAM(1) - 1).m_nAmmoTotal); + SET_INTEGER_PARAM(2, CPickups::ModelForWeapon((eWeaponType)GET_INTEGER_PARAM(0))); StoreParameters(&m_nIp, 3); return 0; } @@ -106,16 +109,16 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CollectParameters(&m_nIp, 5); int node1, node2; float angle; - ThePaths.FindNodePairClosestToCoors(*(CVector*)&ScriptParams[0], PATH_CAR, &node1, &node2, &angle, - *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], true, true); + ThePaths.FindNodePairClosestToCoors(GET_VECTOR_PARAM(0), PATH_CAR, &node1, &node2, &angle, + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), true, true); if (node1 == -1) { for (int i = 0; i < 7; i++) ScriptParams[i] = 0; } else { - *(CVector*)&ScriptParams[0] = ThePaths.FindNodeCoorsForScript(node1); - *(CVector*)&ScriptParams[3] = ThePaths.FindNodeCoorsForScript(node2); - *(float*)&ScriptParams[6] = angle; + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(node1)); + SET_VECTOR_PARAM(3, ThePaths.FindNodeCoorsForScript(node2)); + SET_FLOAT_PARAM(6, angle); } StoreParameters(&m_nIp, 7); return 0; @@ -123,9 +126,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CAR_FORWARD_SPEED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - float speed = *(float*)&ScriptParams[1] / GAME_SPEED_TO_CARAI_SPEED; + float speed = GET_FLOAT_PARAM(1) / GAME_SPEED_TO_CARAI_SPEED; pVehicle->SetMoveSpeed(pVehicle->GetForward() * speed); if (pVehicle->IsRealHeli() && pVehicle->IsCar()) ((CAutomobile*)pVehicle)->m_aWheelSpeed[1] = 0.22f; @@ -133,8 +136,8 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) } case COMMAND_SET_AREA_VISIBLE: CollectParameters(&m_nIp, 1); - CGame::currArea = ScriptParams[0]; - CStreaming::RemoveBuildingsNotInArea(ScriptParams[0]); + CGame::currArea = GET_INTEGER_PARAM(0); + CStreaming::RemoveBuildingsNotInArea(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_CUTSCENE_ANIM_TO_LOOP: { @@ -147,28 +150,28 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_MARK_CAR_AS_CONVOY_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bPartOfConvoy = ScriptParams[1]; + pVehicle->bPartOfConvoy = GET_INTEGER_PARAM(1); return 0; } case COMMAND_RESET_HAVOC_CAUSED_BY_PLAYER: { CollectParameters(&m_nIp, 1); - CWorld::Players[ScriptParams[0]].m_nHavocLevel = 0; + CWorld::Players[GET_INTEGER_PARAM(0)].m_nHavocLevel = 0; return 0; } case COMMAND_GET_HAVOC_CAUSED_BY_PLAYER: { CollectParameters(&m_nIp, 1); - ScriptParams[0] = CWorld::Players[ScriptParams[0]].m_nHavocLevel; + SET_INTEGER_PARAM(0, CWorld::Players[GET_INTEGER_PARAM(0)].m_nHavocLevel); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CREATE_SCRIPT_ROADBLOCK: { CollectParameters(&m_nIp, 6); - CRoadBlocks::RegisterScriptRoadBlock(*(CVector*)&ScriptParams[0], *(CVector*)&ScriptParams[3]); + CRoadBlocks::RegisterScriptRoadBlock(GET_VECTOR_PARAM(0), GET_VECTOR_PARAM(3)); return 0; } case COMMAND_CLEAR_ALL_SCRIPT_ROADBLOCKS: @@ -179,9 +182,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CHAR_OBJ_WALK_TO_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTargetPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING, pTargetPed); @@ -191,17 +194,17 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS: { CollectParameters(&m_nIp, 4); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVector result = Multiply3x3(pPed->GetMatrix(), *(CVector*)&ScriptParams[1]) + pPed->GetPosition(); - *(CVector*)&ScriptParams[0] = result; + CVector result = Multiply3x3(pPed->GetMatrix(), GET_VECTOR_PARAM(1)) + pPed->GetPosition(); + SET_VECTOR_PARAM(0, result); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_HAS_CHAR_BEEN_PHOTOGRAPHED: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); bool result = false; if (pPed->bHasBeenPhotographed) { @@ -214,9 +217,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CHAR_OBJ_AIM_GUN_AT_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTargetPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_AIM_GUN_AT, pTargetPed); @@ -225,14 +228,21 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SWITCH_SECURITY_CAMERA: { CollectParameters(&m_nIp, 1); - CSpecialFX::bVideoCam = ScriptParams[0] != 0; + if (GET_INTEGER_PARAM(0) != 0) { + // TheCamera.MBlur.? = 3; TODO(LCS) + CSpecialFX::bVideoCam = true; + } + else { + // TheCamera.MBlur.Reset(); + CSpecialFX::bVideoCam = false; + } return 0; } //case COMMAND_IS_CHAR_IN_FLYING_VEHICLE: case COMMAND_IS_PLAYER_IN_FLYING_VEHICLE: { 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->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI || pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE)); return 0; @@ -244,27 +254,27 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_COORD: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetShortRangeCoordBlip(BLIP_COORD, pos, 5, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[3]); - ScriptParams[0] = id; + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(3)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_MONEY_SPENT_ON_CLOTHES: CollectParameters(&m_nIp, 1); - CStats::MoneySpentOnFashion(ScriptParams[0]); + //CStats::MoneySpentOnFashion(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_HELI_ORIENTATION: { CollectParameters(&m_nIp, 2); - CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); - float fAngle = DEGTORAD(*(float*)&ScriptParams[1] - 90.0f); + float fAngle = DEGTORAD(GET_FLOAT_PARAM(1) - 90.0f); while (fAngle < 0.0f) fAngle += TWOPI; while (fAngle > TWOPI) @@ -275,7 +285,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CLEAR_HELI_ORIENTATION: { CollectParameters(&m_nIp, 1); - CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); pHeli->ClearHeliOrientation(); return 0; @@ -283,66 +293,75 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_PLANE_GOTO_COORDS: { CollectParameters(&m_nIp, 5); - CAutomobile* pPlane = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pPlane = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPlane && pPlane->IsCar() && pPlane->IsRealPlane()); - pPlane->TellPlaneToGoToCoors(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], ScriptParams[4]); + pPlane->TellPlaneToGoToCoors(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4)); return 0; } case COMMAND_GET_NTH_CLOSEST_CAR_NODE: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - *(CVector*)&ScriptParams[0] = ThePaths.FindNodeCoorsForScript(ThePaths.FindNthNodeClosestToCoors(pos, 0, 999999.9f, true, true, ScriptParams[3] - 1)); + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(ThePaths.FindNthNodeClosestToCoors(pos, 0, 999999.9f, true, true, GET_INTEGER_PARAM(3) - 1))); + StoreParameters(&m_nIp, 3); + return 0; + } + case COMMAND_GET_NTH_CLOSEST_CHAR_NODE: + { + CollectParameters(&m_nIp, 4); + CVector pos = GET_VECTOR_PARAM(0); + if (pos.z <= MAP_Z_LOW_LIMIT) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(ThePaths.FindNthNodeClosestToCoors(pos, 1, 999999.9f, true, true, GET_INTEGER_PARAM(3) - 1))); StoreParameters(&m_nIp, 3); return 0; } - //case COMMAND_GET_NTH_CLOSEST_CHAR_NODE: case COMMAND_DRAW_WEAPONSHOP_CORONA: { CollectParameters(&m_nIp, 9); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CCoronas::RegisterCorona((uintptr)this + m_nIp, ScriptParams[6], ScriptParams[7], ScriptParams[8], 255, pos, *(float*)&ScriptParams[3], - 150.0f, ScriptParams[4], ScriptParams[5], 1, 0, 0, 0.0f, false, 0.2f); + CCoronas::RegisterCorona((uintptr)this + m_nIp, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8), 255, pos, -GET_FLOAT_PARAM(3), + 150.0f, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), 1, 0, 0, 0.0f, false, 0.2f); return 0; } case COMMAND_SET_ENABLE_RC_DETONATE_ON_CONTACT: { CollectParameters(&m_nIp, 1); - CVehicle::bDisableRemoteDetonationOnContact = (ScriptParams[0] == 0); + CVehicle::bDisableRemoteDetonationOnContact = (GET_INTEGER_PARAM(0) == 0); return 0; } case COMMAND_FREEZE_CHAR_POSITION: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIsFrozen = ScriptParams[1]; + pPed->bIsFrozen = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CHAR_DROWNS_IN_WATER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bDrownsInWater = ScriptParams[1]; + pPed->bDrownsInWater = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_OBJECT_RECORDS_COLLISIONS: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bUseCollisionRecords = ScriptParams[1]; + pObject->bUseCollisionRecords = GET_INTEGER_PARAM(1); return 0; } case COMMAND_HAS_OBJECT_COLLIDED_WITH_ANYTHING: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(pObject->m_nCollisionRecords != 0); return 0; @@ -352,13 +371,16 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CWorld::Players[CWorld::PlayerInFocus].BlowUpRCBuggy(false); return 0; } - //case COMMAND_HAS_PHOTOGRAPH_BEEN_TAKEN: + case COMMAND_HAS_PHOTOGRAPH_BEEN_TAKEN: + UpdateCompareFlag(CWeapon::bPhotographHasBeenTaken); + CWeapon::bPhotographHasBeenTaken = false; + return 0; case COMMAND_GET_CHAR_ARMOUR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->m_fArmour; + SET_INTEGER_PARAM(0, pPed->m_fArmour); StoreParameters(&m_nIp, 1); return 0; } @@ -366,23 +388,23 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_HELI_STABILISER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bHeliMinimumTilt = ScriptParams[1]; + pVehicle->bHeliMinimumTilt = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CAR_STRAIGHT_LINE_DISTANCE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_nSwitchDistance = ScriptParams[1]; + pVehicle->AutoPilot.m_nSwitchDistance = GET_INTEGER_PARAM(1); return 0; } case COMMAND_POP_CAR_BOOT: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pCar&& pCar->IsCar()); pCar->PopBoot(); return 0; @@ -390,21 +412,22 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SHUT_PLAYER_UP: { CollectParameters(&m_nIp, 2); - DMAudio.ShutUpPlayerTalking(!!ScriptParams[1]); + DMAudio.ShutUpPlayerTalking(!!GET_INTEGER_PARAM(1)); return 0; } case COMMAND_SET_PLAYER_MOOD: { CollectParameters(&m_nIp, 3); - DMAudio.SetPlayersMood(ScriptParams[1], ScriptParams[2]); + DMAudio.SetPlayersMood(GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_REQUEST_COLLISION: { CollectParameters(&m_nIp, 2); - CVector2D pos; - pos.x = *(float*)&ScriptParams[0]; - pos.y = *(float*)&ScriptParams[1]; + CVector pos; + pos.x = GET_FLOAT_PARAM(0); + pos.y = GET_FLOAT_PARAM(1); + pos.z = 0.0f; CColStore::RequestCollision(pos); return 0; } @@ -415,9 +438,8 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_IS_OBJECT_IN_WATER: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - script_assert(pObject); - UpdateCompareFlag(pObject->bIsInWater); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(pObject && pObject->bIsInWater); return 0; } //case COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR_EVEN_MISSION_CAR: @@ -428,11 +450,11 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CHAR_CROUCH: { CollectParameters(&m_nIp, 3); - 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->bCrouchWhenShooting = true; - pPed->SetDuck(ScriptParams[2], true); + pPed->SetDuck(GET_INTEGER_PARAM(2), true); } else { pPed->ClearDuck(true); @@ -460,7 +482,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) return 0; } while (zone >= 0) { - CTheZones::SetZoneCivilianCarInfo(zone, ScriptParams[0], carDensities, boatDensities); + CTheZones::SetZoneCivilianCarInfo(zone, GET_INTEGER_PARAM(0), carDensities, boatDensities); zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO); } return 0; @@ -470,7 +492,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; - CStreaming::RequestAnim(CAnimManager::GetAnimationBlockIndex(key), STREAMFLAGS_SCRIPTOWNED); + CStreaming::RequestAnim(CAnimManager::GetAnimationBlockIndex(key), (m_bIsMissionScript ? STREAMFLAGS_SCRIPTOWNED : STREAMFLAGS_AMBIENT_SCRIPT_OWNED)); return 0; } case COMMAND_HAS_ANIMATION_LOADED: @@ -487,12 +509,13 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; CStreaming::RemoveAnim(CAnimManager::GetAnimationBlockIndex(key)); + // + empty function on PS2 (not PSP) return 0; } case COMMAND_IS_CHAR_WAITING_FOR_WORLD_COLLISION: { 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->bIsStaticWaitingForCollision); return 0; @@ -500,87 +523,101 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_IS_CAR_WAITING_FOR_WORLD_COLLISION: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(pVehicle->bIsStaticWaitingForCollision); return 0; } + /* case COMMAND_IS_OBJECT_WAITING_FOR_WORLD_COLLISION: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(pObject->bIsStaticWaitingForCollision); return 0; } + */ case COMMAND_SET_CHAR_SHUFFLE_INTO_DRIVERS_SEAT: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); pPed->PedShuffle(); return 0; } case COMMAND_ATTACH_CHAR_TO_OBJECT: { CollectParameters(&m_nIp, 8); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - pPed->AttachPedToEntity(pObject, *(CVector*)&ScriptParams[2], ScriptParams[5], DEGTORAD(ScriptParams[6]), (eWeaponType)ScriptParams[7]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); + pPed->AttachPedToEntity(pObject, GET_VECTOR_PARAM(2), GET_INTEGER_PARAM(5), DEGTORAD(GET_INTEGER_PARAM(6)), (eWeaponType)GET_INTEGER_PARAM(7)); return 0; } case COMMAND_SET_CHAR_AS_PLAYER_FRIEND: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIsPlayerFriend = ScriptParams[2]; + pPed->bIsPlayerFriend = GET_INTEGER_PARAM(2); return 0; } //case COMMAND_DISPLAY_NTH_ONSCREEN_COUNTER: case COMMAND_DISPLAY_NTH_ONSCREEN_COUNTER_WITH_STRING: { char onscreen_str[12]; - script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); - uint16 var = CTheScripts::Read2BytesFromScript(&m_nIp); + //script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR); + uint16 var = (uint8*)GetPointerToScriptVariable(&m_nIp, 0) - CTheScripts::ScriptSpace; CollectParameters(&m_nIp, 2); wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; - CUserDisplay::OnscnTimer.AddCounter(var, ScriptParams[0], onscreen_str, ScriptParams[1] - 1); + CUserDisplay::OnscnTimer.AddCounter(var, GET_INTEGER_PARAM(0), onscreen_str, GET_INTEGER_PARAM(1) - 1, -1, nil, 0); return 0; } case COMMAND_ADD_SET_PIECE: { CollectParameters(&m_nIp, 13); - CSetPieces::AddOne(ScriptParams[0], - *(CVector2D*)&ScriptParams[1], *(CVector2D*)&ScriptParams[3], - *(CVector2D*)&ScriptParams[5], *(CVector2D*)&ScriptParams[7], - *(CVector2D*)&ScriptParams[9], *(CVector2D*)&ScriptParams[11]); + float fTriggerInfX = GET_FLOAT_PARAM(1); + float fTriggerInfY = GET_FLOAT_PARAM(2); + float fTriggerSupX = GET_FLOAT_PARAM(3); + float fTriggerSupY = GET_FLOAT_PARAM(4); + float fSpawn1X = GET_FLOAT_PARAM(5); + float fSpawn1Y = GET_FLOAT_PARAM(6); + float fTarget1X = GET_FLOAT_PARAM(7); + float fTarget1Y = GET_FLOAT_PARAM(8); + float fSpawn2X = GET_FLOAT_PARAM(9); + float fSpawn2Y = GET_FLOAT_PARAM(10); + float fTarget2X = GET_FLOAT_PARAM(11); + float fTarget2Y = GET_FLOAT_PARAM(12); + CSetPieces::AddOne(GET_INTEGER_PARAM(0), + CVector2D(fTriggerInfX, fTriggerInfY), CVector2D(fTriggerSupX, fTriggerSupY), + CVector2D(fSpawn1X, fSpawn1Y), CVector2D(fTarget1X, fTarget1Y), + CVector2D(fSpawn2X, fSpawn2Y), CVector2D(fTarget2X, fTarget2Y)); return 0; } case COMMAND_SET_EXTRA_COLOURS: { CollectParameters(&m_nIp, 2); - CTimeCycle::StartExtraColour(ScriptParams[0]-1, ScriptParams[1] != 0); + CTimeCycle::StartExtraColour(GET_INTEGER_PARAM(0)-1, GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_CLEAR_EXTRA_COLOURS: { CollectParameters(&m_nIp, 1); - CTimeCycle::StopExtraColour(ScriptParams[0]); + CTimeCycle::StopExtraColour(GET_INTEGER_PARAM(0)); return 0; } //case COMMAND_CLOSE_CAR_BOOT: case COMMAND_GET_WHEELIE_STATS: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - ScriptParams[0] = pPlayerInfo->m_nLastTimeCarSpentOnTwoWheels; - *(float*)&ScriptParams[1] = pPlayerInfo->m_nLastDistanceCarTravelledOnTwoWheels; - ScriptParams[2] = pPlayerInfo->m_nLastTimeSpentOnWheelie; - *(float*)&ScriptParams[3] = pPlayerInfo->m_nLastDistanceTravelledOnWheelie; - ScriptParams[4] = pPlayerInfo->m_nLastTimeSpentOnStoppie; - *(float*)&ScriptParams[5] = pPlayerInfo->m_nLastDistanceTravelledOnStoppie; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + SET_INTEGER_PARAM(0, pPlayerInfo->m_nLastTimeCarSpentOnTwoWheels); + SET_FLOAT_PARAM(1, pPlayerInfo->m_nLastDistanceCarTravelledOnTwoWheels); + SET_INTEGER_PARAM(2, pPlayerInfo->m_nLastTimeSpentOnWheelie); + SET_FLOAT_PARAM(3, pPlayerInfo->m_nLastDistanceTravelledOnWheelie); + SET_INTEGER_PARAM(4, pPlayerInfo->m_nLastTimeSpentOnStoppie); + SET_FLOAT_PARAM(5, pPlayerInfo->m_nLastDistanceTravelledOnStoppie); StoreParameters(&m_nIp, 6); pPlayerInfo->m_nLastTimeCarSpentOnTwoWheels = 0; pPlayerInfo->m_nLastDistanceCarTravelledOnTwoWheels = 0.0f; @@ -594,23 +631,20 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_BURST_CAR_TYRE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle->IsBike()) { - if (ScriptParams[1] == 2) - ScriptParams[1] = 0; - else if (ScriptParams[1] == 3) - ScriptParams[1] = 1; - pVehicle->BurstTyre(ScriptParams[1], true); - } - else { - pVehicle->BurstTyre(ScriptParams[1], true); + if (GET_INTEGER_PARAM(1) == 2) + SET_INTEGER_PARAM(1, 0); + else if (GET_INTEGER_PARAM(1) == 3) + SET_INTEGER_PARAM(1, 1); } + pVehicle->BurstTyre(GET_INTEGER_PARAM(1), true); return 0; } case COMMAND_IS_CHAR_OBJ_NO_OBJ: { 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->m_prevObjective == OBJECTIVE_NONE && pPed->m_objective == OBJECTIVE_NONE); return 0; @@ -623,26 +657,26 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) key[i] = tolower(key[i]); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - UpdateCompareFlag(strcmp(key, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetModelName()) == 0); + UpdateCompareFlag(CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetNameHashKey() == CKeyGen::GetUppercaseKey(key)); return 0; } case COMMAND_SET_PLAYER_CAN_DO_DRIVE_BY: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_bDriveByAllowed = ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_bDriveByAllowed = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CHAR_OBJ_SPRINT_TO_COORD: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos; - pos.x = *(float*)&ScriptParams[1]; - pos.y = *(float*)&ScriptParams[2]; + pos.x = GET_FLOAT_PARAM(1); + pos.y = GET_FLOAT_PARAM(2); pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_SPRINT_TO_AREA, pos); @@ -651,7 +685,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CREATE_SWAT_ROPE: { CollectParameters(&m_nIp, 3); - CRopes::CreateRopeWithSwatComingDown(*(CVector*)&ScriptParams[0]); + CRopes::CreateRopeWithSwatComingDown(GET_VECTOR_PARAM(0)); return 0; } //case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA: @@ -659,19 +693,19 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CAR_MODEL_COMPONENTS: { CollectParameters(&m_nIp, 3); - CVehicleModelInfo::SetComponentsToUse(ScriptParams[1], ScriptParams[2]); + CVehicleModelInfo::SetComponentsToUse(GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_SWITCH_LIFT_CAMERA: { CollectParameters(&m_nIp, 1); - CSpecialFX::bLiftCam = ScriptParams[0] != 0; + CSpecialFX::bLiftCam = GET_INTEGER_PARAM(0) != 0; return 0; } case COMMAND_CLOSE_ALL_CAR_DOORS: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pCar&& pCar->IsCar()); pCar->CloseAllDoors(); return 0; @@ -679,21 +713,25 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_GET_DISTANCE_BETWEEN_COORDS_2D: { CollectParameters(&m_nIp, 4); - *(float*)&ScriptParams[0] = (*(CVector2D*)&ScriptParams[0] - *(CVector2D*)&ScriptParams[2]).Magnitude(); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float X2 = GET_FLOAT_PARAM(2); + float Y2 = GET_FLOAT_PARAM(3); + SET_FLOAT_PARAM(0, (CVector2D(X1, Y1) - CVector2D(X2, Y2)).Magnitude()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_DISTANCE_BETWEEN_COORDS_3D: { CollectParameters(&m_nIp, 6); - *(float*)&ScriptParams[0] = (*(CVector*)&ScriptParams[0] - *(CVector*)&ScriptParams[3]).Magnitude(); + SET_FLOAT_PARAM(0, (GET_VECTOR_PARAM(0) - GET_VECTOR_PARAM(3)).Magnitude()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_POP_CAR_BOOT_USING_PHYSICS: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pCar && pCar->IsCar()); pCar->PopBootUsingPhysics(); return 0; @@ -702,7 +740,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_IS_CHAR_LEAVING_VEHICLE_TO_DIE: { 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->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE); return 0; @@ -710,25 +748,29 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SORT_OUT_OBJECT_COLLISION_WITH_CAR: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->m_pCollidingEntity = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + pObject->m_pCollidingEntity = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); return 0; } //case COMMAND_GET_MAX_WANTED_LEVEL: case COMMAND_IS_CHAR_WANDER_PATH_CLEAR: { CollectParameters(&m_nIp, 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(CWorld::IsWanderPathClear(pPed->GetPosition(), *(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3], 4)); + UpdateCompareFlag(CWorld::IsWanderPathClear(pPed->GetPosition(), GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3), 4)); return 0; } //case COMMAND_PRINT_HELP_WITH_NUMBER: case COMMAND_PRINT_HELP_FOREVER: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CHud::SetHelpMessage(text, false, true); + CHud::SetHelpMessage(text, false, true); // + true + if (text != CHud::gLastPrintForeverString) { + CHud::gLastPrintForeverString = text; + DMAudio.PlayFrontEndSound(SOUND_HUD, 0); + } return 0; } //case COMMAND_PRINT_HELP_FOREVER_WITH_NUMBER: @@ -744,10 +786,10 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_CAN_BE_DAMAGED_BY_MEMBERS_OF_GANG: { CollectParameters(&m_nIp, 3); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pTarget); - uint8 flag = 1 << (uint8)ScriptParams[1]; - if (ScriptParams[2]) + uint8 flag = 1 << (uint8)GET_INTEGER_PARAM(1); + if (GET_INTEGER_PARAM(2)) pTarget->m_gangFlags |= flag; else pTarget->m_gangFlags &= ~flag; @@ -760,7 +802,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_CREATE_LOCKED_PROPERTY_PICKUP: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; char key[KEY_LENGTH_IN_SCRIPT]; @@ -768,39 +810,39 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; // TheText.Get(key); CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY, PICKUP_PROPERTY_LOCKED, 0, 0, false, key); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY, PICKUP_PROPERTY_LOCKED, 0, 0, false, key)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CREATE_FORSALE_PROPERTY_PICKUP: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; - // TheText.Get(key); + TheText.Get(key); CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY_FORSALE, PICKUP_PROPERTY_FORSALE, ScriptParams[3], 0, false, key); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY_FORSALE, PICKUP_PROPERTY_FORSALE, GET_INTEGER_PARAM(3), 0, false, key)); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_FREEZE_CAR_POSITION: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bIsFrozen = ScriptParams[1]; - pVehicle->bInfiniteMass = ScriptParams[1]; + pVehicle->bIsFrozen = GET_INTEGER_PARAM(1); + pVehicle->bInfiniteMass = GET_INTEGER_PARAM(1); return 0; } case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pTestedPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pTestedPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); bool result = false; if (pPed) { if (pPed->m_lastDamEntity) { @@ -814,16 +856,75 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) UpdateCompareFlag(result); return 0; } - //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_HAS_CHAR_BEEN_DAMAGED_BY_CAR: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pTestedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + bool result = false; + if (pPed) { + if (pPed->m_lastDamEntity) { + if (pPed->m_lastDamEntity == pTestedVehicle) + result = true; + } + } + else + debug("HAS_CHAR_BEEN_DAMAGED_BY_CAR - Character doesn't exist\n"); + UpdateCompareFlag(result); + return 0; + } + case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CHAR: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pTestedPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + bool result = false; + if (pVehicle) { + if (pVehicle->m_pLastDamageEntity) { + if (pVehicle->m_pLastDamageEntity == pTestedPed) + result = true; + if (pTestedPed->bInVehicle && pVehicle->m_pLastDamageEntity == pTestedPed->m_pMyVehicle) + result = true; + } + } + else + debug("HAS_CAR_BEEN_DAMAGED_BY_CHAR - Car doesn't exist\n"); + UpdateCompareFlag(result); + return 0; + } + case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CAR: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pTestedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + bool result = false; + if (pVehicle) { + if (pVehicle->m_pLastDamageEntity) { + if (pVehicle->m_pLastDamageEntity == pTestedVehicle) + result = true; + } + } + else + debug("HAS_CAR_BEEN_DAMAGED_BY_CAR - First car doesn't exist\n"); + UpdateCompareFlag(result); + return 0; + } + case COMMAND_GET_RADIO_CHANNEL: + { + uint8 radio = DMAudio.GetRadioInCar(); + if (radio < NUM_RADIOS || radio == STREAMED_SOUND_MISSION_COMPLETED) + SET_INTEGER_PARAM(0, radio); + else + SET_INTEGER_PARAM(0, -1); + StoreParameters(&m_nIp, 1); + return 0; + } //case COMMAND_DISPLAY_TEXT_WITH_3_NUMBERS: //case COMMAND_IS_CAR_DROWNING_IN_WATER: case COMMAND_IS_CHAR_DROWNING_IN_WATER: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed && pPed->bIsDrowning); return 0; } @@ -837,7 +938,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CollectParameters(&m_nIp, 3); bool shattered = false; - if ( CGlass::HasGlassBeenShatteredAtCoors(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2]) ) + if ( CGlass::HasGlassBeenShatteredAtCoors(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2)) ) shattered = true; UpdateCompareFlag(shattered); @@ -846,14 +947,14 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_BONE: { CollectParameters(&m_nIp, 3); - CCutsceneMgr::AttachObjectToBone(CPools::GetObjectPool()->GetAt(ScriptParams[0]), CPools::GetObjectPool()->GetAt(ScriptParams[1]), ScriptParams[2]); + CCutsceneMgr::AttachObjectToBone(CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)), CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_COMPONENT: { CollectParameters(&m_nIp, 2); - CObject *obj1 = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CObject *obj2 = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject *obj1 = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + CObject *obj2 = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); @@ -865,26 +966,26 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_STAY_IN_CAR_WHEN_JACKED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bStayInCarOnJack = ScriptParams[1]; + pPed->bStayInCarOnJack = GET_INTEGER_PARAM(1); return 0; } //case COMMAND_IS_MISSION_AUDIO_LOADING: case COMMAND_ADD_MONEY_SPENT_ON_WEAPONS: CollectParameters(&m_nIp, 1); - CStats::MoneySpentOnWeapons(ScriptParams[0]); + CStats::MoneySpentOnWeapons(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_MONEY_SPENT_ON_PROPERTY: CollectParameters(&m_nIp, 1); - CStats::MoneySpentOnProperty(ScriptParams[0]); + //CStats::MoneySpentOnProperty(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_ADD_MONEY_SPENT_ON_AUTO_PAINTING: case COMMAND_SET_CHAR_ANSWERING_MOBILE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - if (ScriptParams[1]) + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (GET_INTEGER_PARAM(1)) pPed->SetAnswerMobile(); else pPed->ClearAnswerMobile(); @@ -893,8 +994,8 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_PLAYER_DRUNKENNESS: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_pPed->m_nDrunkenness = ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_pPed->m_nDrunkenness = GET_INTEGER_PARAM(1); pPlayerInfo->m_pPed->m_nFadeDrunkenness = 0; if (pPlayerInfo->m_pPed->m_nDrunkenness == 0) CMBlur::ClearDrunkBlur(); @@ -906,21 +1007,21 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) //case COMMAND_ADD_LOAN_SHARK_VISITS: case COMMAND_ADD_STORES_KNOCKED_OFF: CollectParameters(&m_nIp, 1); - CStats::NumOfStoresKnockedOff(ScriptParams[0]); + //CStats::NumOfStoresKnockedOff(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_ADD_MOVIE_STUNTS: case COMMAND_ADD_NUMBER_OF_ASSASSINATIONS: CollectParameters(&m_nIp, 1); - CStats::NumOfAssassinations(ScriptParams[0]); + //CStats::NumOfAssassinations(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_PIZZAS_DELIVERED: CollectParameters(&m_nIp, 1); - CStats::NumOfPizzasDelivered(ScriptParams[0]); + CStats::NumOfPizzasDelivered(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_ADD_GARBAGE_PICKUPS: case COMMAND_ADD_ICE_CREAMS_SOLD: CollectParameters(&m_nIp, 1); - CStats::NumOfIceCreamSold(ScriptParams[0]); + CStats::NumOfIceCreamSold(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_SET_TOP_SHOOTING_RANGE_SCORE: //case COMMAND_ADD_SHOOTING_RANGE_RANK: @@ -930,15 +1031,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_IN_PLAYERS_GROUP_CAN_FIGHT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bDontFight = !ScriptParams[1]; + pPed->bDontFight = !GET_INTEGER_PARAM(1); return 0; } case COMMAND_CLEAR_CHAR_WAIT_STATE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->ClearWaitState(); return 0; @@ -948,17 +1049,17 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CollectParameters(&m_nIp, 5); int handle = -1; 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) continue; if (pVehicle->GetVehicleAppearance() != VEHICLE_APPEARANCE_CAR && pVehicle->GetVehicleAppearance() != VEHICLE_APPEARANCE_BIKE) continue; - if (ScriptParams[4] != pVehicle->GetModelIndex() && ScriptParams[4] >= 0) + if (GET_INTEGER_PARAM(4) != pVehicle->GetModelIndex() && GET_INTEGER_PARAM(4) >= 0) continue; if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE) continue; @@ -966,30 +1067,30 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) continue; handle = CPools::GetVehiclePool()->GetIndex(pVehicle); } - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CAN_BURST_CAR_TYRES: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bTyresDontBurst = !ScriptParams[1]; + pVehicle->bTyresDontBurst = !GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_PLAYER_AUTO_AIM: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->bDoomAim = ScriptParams[1]; + pPed->bDoomAim = GET_INTEGER_PARAM(1); return 0; } case COMMAND_FIRE_HUNTER_GUN: { CollectParameters(&m_nIp, 1); - CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nGunFiringTime + 150) { CWeapon gun(WEAPONTYPE_HELICANNON, 5000); CVector worldGunPos = (pVehicle->GetMatrix() * vecHunterGunPos) + (CTimer::GetTimeStep() * pVehicle->m_vecMoveSpeed); @@ -1002,27 +1103,27 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) } case COMMAND_SET_PROPERTY_AS_OWNED: CollectParameters(&m_nIp, 1); - CStats::AddPropertyAsOwned(ScriptParams[0]); + CStats::AddPropertyAsOwned(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_BLOOD_RING_KILLS: CollectParameters(&m_nIp, 1); - CStats::AddNumBloodRingKills(ScriptParams[0]); + CStats::AddNumBloodRingKills(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_LONGEST_TIME_IN_BLOOD_RING: CollectParameters(&m_nIp, 1); - CStats::LongestTimeInBloodRing(ScriptParams[0]); + CStats::LongestTimeInBloodRing(GET_INTEGER_PARAM(0)); return 0; case COMMAND_REMOVE_EVERYTHING_FOR_HUGE_CUTSCENE: { - CCutsceneMgr::RemoveEverythingFromTheWorldForTheBiggestFuckoffCutsceneEver(); + //CCutsceneMgr::RemoveEverythingFromTheWorldForTheBiggestFuckoffCutsceneEver(); return 0; } case COMMAND_IS_PLAYER_TOUCHING_VEHICLE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); CPhysical* pTestedEntity = pPed; if (pPed->bInVehicle && pPed->m_pMyVehicle) pTestedEntity = pPed->m_pMyVehicle; @@ -1033,15 +1134,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_CHECK_FOR_PED_MODEL_AROUND_PLAYER: { CollectParameters(&m_nIp, 6); - CVector d1 = CWorld::Players[ScriptParams[0]].GetPos() - *(CVector*)&ScriptParams[1]; - CVector d2 = CWorld::Players[ScriptParams[0]].GetPos() + *(CVector*)&ScriptParams[1]; + CVector d1 = CWorld::Players[GET_INTEGER_PARAM(0)].GetPos() - GET_VECTOR_PARAM(1); + CVector d2 = CWorld::Players[GET_INTEGER_PARAM(0)].GetPos() + GET_VECTOR_PARAM(1); int i = CPools::GetPedPool()->GetSize(); bool result = false; while (i--) { CPed* pPed = CPools::GetPedPool()->GetSlot(i); if (!pPed) continue; - if (ScriptParams[4] != pPed->GetModelIndex() && ScriptParams[5] != pPed->GetModelIndex()) + if (GET_INTEGER_PARAM(4) != pPed->GetModelIndex() && GET_INTEGER_PARAM(5) != pPed->GetModelIndex()) continue; if (pPed->IsWithinArea(d1.x, d1.y, d1.z, d2.x, d2.y, d2.z)) result = true; @@ -1052,7 +1153,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_CLEAR_CHAR_FOLLOW_PATH: { 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->GetPedState() == PED_FOLLOW_PATH) { pPed->RestorePreviousState(); @@ -1063,15 +1164,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_CAN_BE_SHOT_IN_VEHICLE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bCanBeShotInVehicle = ScriptParams[1]; + pPed->bCanBeShotInVehicle = GET_INTEGER_PARAM(1); return 0; } case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_VEHICLE: { CollectParameters(&m_nIp, 2); - CCutsceneMgr::AttachObjectToParent(CPools::GetObjectPool()->GetAt(ScriptParams[0]), CPools::GetVehiclePool()->GetAt(ScriptParams[1])); + CCutsceneMgr::AttachObjectToParent(CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)), CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1))); return 0; } case COMMAND_LOAD_MISSION_TEXT: @@ -1085,39 +1186,48 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_TONIGHTS_EVENT: { CollectParameters(&m_nIp, 1); - CScrollBar::TonightsEvent = ScriptParams[0]; + CScrollBar::TonightsEvent = GET_INTEGER_PARAM(0); return 0; } case COMMAND_CLEAR_CHAR_LAST_DAMAGE_ENTITY: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); if (pPed) pPed->m_lastDamEntity = nil; else debug("CLEAR_CHAR_LAST_DAMAGE_ENTITY - Character doesn't exist\n"); return 0; } - //case COMMAND_CLEAR_CAR_LAST_DAMAGE_ENTITY: + case COMMAND_CLEAR_CAR_LAST_DAMAGE_ENTITY: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + if (pVehicle) + pVehicle->m_pLastDamageEntity = nil; + else + debug("CLEAR_CAR_LAST_DAMAGE_ENTITY - Car doesn't exist\n"); + return 0; + } case COMMAND_FREEZE_OBJECT_POSITION: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bIsFrozen = ScriptParams[1]; - pObject->bInfiniteMass = ScriptParams[1]; + pObject->bIsFrozen = GET_INTEGER_PARAM(1); + pObject->bInfiniteMass = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_PLAYER_HAS_MET_DEBBIE_HARRY: { CollectParameters(&m_nIp, 1); - CTheScripts::bPlayerHasMetDebbieHarry = ScriptParams[0]; + CTheScripts::bPlayerHasMetDebbieHarry = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_RIOT_INTENSITY: { CollectParameters(&m_nIp, 1); - CTheScripts::RiotIntensity = ScriptParams[0]; + CTheScripts::RiotIntensity = GET_INTEGER_PARAM(0); return 0; } //case COMMAND_IS_CAR_IN_ANGLED_AREA_2D: @@ -1127,27 +1237,28 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) { CollectParameters(&m_nIp, 8); CGameLogic::SetUpShortCut( - *(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3], - *(CVector*)&ScriptParams[4], *(float*)&ScriptParams[7]); + GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3), + GET_VECTOR_PARAM(4), GET_FLOAT_PARAM(7)); return 0; } case COMMAND_CLEAR_TAXI_SHORTCUT: CGameLogic::ClearShortCut(); + CGameLogic::RemoveShortCutDropOffPointForMission(); return 0; //case COMMAND_SET_CHAR_OBJ_GOTO_CAR_ON_FOOT: //case COMMAND_GET_CLOSEST_WATER_NODE: case COMMAND_ADD_PORN_LEAFLET_TO_RUBBISH: CollectParameters(&m_nIp, 1); - CStats::PamphletMissionPassed = ScriptParams[0]; + CStats::PamphletMissionPassed = GET_INTEGER_PARAM(0); return 0; case COMMAND_CREATE_CLOTHES_PICKUP: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_CLOTHES, PICKUP_ON_STREET, ScriptParams[3]); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_CLOTHES, PICKUP_ON_STREET, GET_INTEGER_PARAM(3))); // TODO: gpModelIndices StoreParameters(&m_nIp, 1); return 0; } @@ -1155,30 +1266,32 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_MAKE_PLAYER_FIRE_PROOF: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_bFireproof = ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_bFireproof = GET_INTEGER_PARAM(1); return 0; } case COMMAND_INCREASE_PLAYER_MAX_HEALTH: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_nMaxHealth += ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_nMaxHealth += GET_INTEGER_PARAM(1); pPlayerInfo->m_pPed->m_fHealth = pPlayerInfo->m_nMaxHealth; + CHud::m_ItemToFlash = ITEM_HEALTH; return 0; } case COMMAND_INCREASE_PLAYER_MAX_ARMOUR: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_nMaxArmour += ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_nMaxArmour += GET_INTEGER_PARAM(1); pPlayerInfo->m_pPed->m_fArmour = pPlayerInfo->m_nMaxArmour; + CHud::m_ItemToFlash = ITEM_ARMOUR; return 0; } case COMMAND_CREATE_RANDOM_CHAR_AS_DRIVER: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); CPed* pPed = CPopulation::AddPedInCar(pVehicle, true); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; @@ -1200,16 +1313,16 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) pVehicle->bEngineOn = true; pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); CPopulation::ms_nTotalMissionPeds++; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_CREATE_RANDOM_CHAR_AS_PASSENGER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); CPed* pPed = CPopulation::AddPedInCar(pVehicle, false); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; @@ -1221,8 +1334,8 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) pPed->SetOrientation(0.0f, 0.0f, 0.0f); CPopulation::ms_nTotalMissionPeds++; pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); - if (ScriptParams[1] >= 0) - pVehicle->AddPassenger(pPed, ScriptParams[1]); + if (GET_INTEGER_PARAM(1) >= 0) + pVehicle->AddPassenger(pPed, GET_INTEGER_PARAM(1)); else pVehicle->AddPassenger(pPed); @@ -1230,32 +1343,32 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) pPed->m_pMyVehicle->RegisterReference((CEntity**)&pPed->m_pMyVehicle); pPed->bInVehicle = true; pPed->SetPedState(PED_DRIVING); - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_SET_CHAR_IGNORE_THREATS_BEHIND_OBJECTS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIgnoreThreatsBehindObjects = ScriptParams[1]; + pPed->bIgnoreThreatsBehindObjects = GET_INTEGER_PARAM(1); return 0; } case COMMAND_ENSURE_PLAYER_HAS_DRIVE_BY_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); if (pPed->bInVehicle) { if (pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_eWeaponType) { - if (pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_nAmmoTotal < ScriptParams[1]) - pPed->SetAmmo(pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_eWeaponType, ScriptParams[1]); + if (pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_nAmmoTotal < GET_INTEGER_PARAM(1)) + pPed->SetAmmo(pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_eWeaponType, GET_INTEGER_PARAM(1)); } else { - pPed->GiveWeapon(WEAPONTYPE_UZI, ScriptParams[1], true); + pPed->GiveWeapon(WEAPONTYPE_UZI, GET_INTEGER_PARAM(1), true); if (pPed->m_storedWeapon == WEAPONTYPE_UNIDENTIFIED) pPed->m_storedWeapon = pPed->GetWeapon()->m_eWeaponType; pPed->SetCurrentWeapon(WEAPONTYPE_UZI); @@ -1266,7 +1379,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_MAKE_HELI_COME_CRASHING_DOWN: { CollectParameters(&m_nIp, 1); - CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); pHeli->bHeliDestroyed = true; return 0; @@ -1274,24 +1387,24 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_ADD_EXPLOSION_NO_SOUND: { CollectParameters(&m_nIp, 4); - CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, false); + CExplosion::AddExplosion(nil, nil, (eExplosionType)GET_INTEGER_PARAM(3), GET_VECTOR_PARAM(0), 0, false); return 0; } case COMMAND_SET_OBJECT_AREA_VISIBLE: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->m_area = ScriptParams[1]; + pObject->m_area = GET_INTEGER_PARAM(1); return 0; } //case COMMAND_WAS_VEHICLE_EVER_POLICE: case COMMAND_SET_CHAR_NEVER_TARGETTED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bNeverEverTargetThisPed = ScriptParams[1]; + pPed->bNeverEverTargetThisPed = GET_INTEGER_PARAM(1); return 0; } case COMMAND_LOAD_UNCOMPRESSED_ANIM: @@ -1310,7 +1423,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_CROUCH_WHEN_THREATENED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bCrouchWhenScared = true; return 0; @@ -1318,7 +1431,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_IS_CHAR_IN_ANY_POLICE_VEHICLE: { 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->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle->IsLawEnforcementVehicle() && @@ -1327,27 +1440,42 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) } case COMMAND_DOES_CHAR_EXIST: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CPools::GetPedPool()->GetAt(ScriptParams[0]) != 0); + UpdateCompareFlag(CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)) != 0); + return 0; + case COMMAND_DOES_VEHICLE_EXIST: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + bool bExist = false; + if (pVehicle) { + int index = GET_INTEGER_PARAM(0) >> 8; +#ifdef FIX_BUGS + bExist = (index >= 0 && index < NUMVEHICLES); // epic fail +#else + bExist = (index > 0 && index < NUMVEHICLES); +#endif + } + UpdateCompareFlag(bExist); return 0; - //case COMMAND_DOES_VEHICLE_EXIST: + } //case COMMAND_ADD_SHORT_RANGE_BLIP_FOR_CONTACT_POINT: case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_CONTACT_POINT: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetShortRangeCoordBlip(BLIP_COORD, pos, 2, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[3]); - ScriptParams[0] = id; + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(3)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_CHAR_STUCK: { 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->m_nWaitState == WAITSTATE_STUCK); return 0; @@ -1355,15 +1483,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_ALL_TAXIS_HAVE_NITRO: { CollectParameters(&m_nIp, 1); - CVehicle::bAllTaxisHaveNitro = ScriptParams[0] != 0; + CVehicle::bAllTaxisHaveNitro = GET_INTEGER_PARAM(0) != 0; return 0; } case COMMAND_SET_CHAR_STOP_SHOOT_DONT_SEEK_ENTITY: { 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->bKindaStayInSamePlace = true; pPed->bStopAndShoot = true; } @@ -1377,9 +1505,9 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_FREEZE_CAR_POSITION_AND_DONT_LOAD_COLLISION: { 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->bIsFrozen = true; pVehicle->bInfiniteMass = true; if (m_bIsMissionScript) { diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index 98f69737..3955cacb 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -3,8 +3,9 @@ #include "Script.h" #include "ScriptCommands.h" +#include "Bike.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 +13,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 +27,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 +61,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 +71,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 +97,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 +110,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 +120,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 +143,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 +155,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 +163,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 +186,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 +210,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 +242,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 +267,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 +285,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 +294,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 +309,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 +337,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 +345,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 +353,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 +378,23 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_DISARM_CAR_BOMB: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - if (pVehicle->m_bombType != CARBOMB_NONE) { - pVehicle->m_bombType = CARBOMB_NONE; - pVehicle->m_pBombRigger = nil; + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + if (pVehicle->IsCar()) { + if (((CAutomobile*)pVehicle)->m_bombType != CARBOMB_NONE) { + ((CAutomobile*)pVehicle)->m_bombType = CARBOMB_NONE; + ((CAutomobile*)pVehicle)->m_pBombRigger = nil; + } } +#ifdef FIX_BUGS + else if (pVehicle->IsBike()) { + if (((CBike*)pVehicle)->m_bombType != CARBOMB_NONE) { + ((CBike*)pVehicle)->m_bombType = CARBOMB_NONE; + ((CBike*)pVehicle)->m_pBombRigger = nil; + } + } +#endif return 0; } -#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) case COMMAND_IS_JAPANESE_GAME: #ifdef MORE_LANGUAGES UpdateCompareFlag(FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_JAPANESE); @@ -394,223 +404,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_DEBUG_PRINT_WITH_2_FLOATS: return 0; - case COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY: + 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); + 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 USE_MISSION_REPLAY_OVERRIDE_FOR_NON_MOBILE_SCRIPT - UsingMobileScript = true; -#endif -#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 and PSP, 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); } diff --git a/src/control/Script9.cpp b/src/control/Script9.cpp new file mode 100644 index 00000000..875aa96b --- /dev/null +++ b/src/control/Script9.cpp @@ -0,0 +1,781 @@ +#include "common.h" + +#include "Script.h" +#include "ScriptCommands.h" + +#include "Bridge.h" +#include "CarCtrl.h" +#include "Camera.h" +#include "CutsceneMgr.h" +#include "Ferry.h" +#include "Garages.h" +#include "GameLogic.h" +#include "Hud.h" +#include "Messages.h" +#include "Object.h" +#include "OnscreenTimer.h" +#include "Pad.h" +#include "Ped.h" +#include "Pools.h" +#include "Remote.h" +#include "SpecialFX.h" +#include "Stats.h" +#include "Vehicle.h" +#include "World.h" + +// LCS: file done except TODOs (also check commented out strings) + +int8 CRunningScript::ProcessCommands1500To1599(int32 command) +{ + switch (command) { + case COMMAND_DISABLE_FERRY_PATH: + { + CollectParameters(&m_nIp, 1); + CFerry::DissableFerryPath(GET_INTEGER_PARAM(0)); + return 0; + } + case COMMAND_ENABLE_FERRY_PATH: + { + CollectParameters(&m_nIp, 1); + CFerry::EnableFerryPath(GET_INTEGER_PARAM(0)); + return 0; + } + case COMMAND_GET_CLOSEST_DOCKED_FERRY: + { + CollectParameters(&m_nIp, 2); + CFerry* pFerry = CFerry::GetClosestFerry(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1)); + int id = -1; + if (pFerry && pFerry->IsDocked()) + id = pFerry->m_nFerryId; + SET_INTEGER_PARAM(0, id); + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_OPEN_FERRY_DOOR: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + pFerry->OpenDoor(); + return 0; + } + case COMMAND_CLOSE_FERRY_DOOR: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + pFerry->CloseDoor(); + return 0; + } + case COMMAND_IS_FERRY_DOOR_OPEN: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + UpdateCompareFlag(pFerry->IsDoorOpen()); + return 0; + } + case COMMAND_IS_FERRY_DOOR_CLOSED: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + UpdateCompareFlag(pFerry->IsDoorClosed()); + return 0; + } + case COMMAND_SKIP_FERRY_TO_NEXT_DOCK: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + pFerry->SkipFerryToNextDock(); + return 0; + } + case COMMAND_SET_CHAR_DROPS_WEAPONS_ON_DEATH: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bDropsWeaponsOnDeath = (GET_INTEGER_PARAM(1) != 0); + return 0; + } + case COMMAND_IS_CHAR_CROUCHING: + { + CollectParameters(&m_nIp, 1); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + UpdateCompareFlag(pPed->bIsDucking); + return 0; + } + case COMMAND_GET_FERRY_BOARDING_SPACE: + { + CollectParameters(&m_nIp, 4); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + CVector space = pFerry->GetBoardingSpace((CFerry::eSpaceUse)GET_INTEGER_PARAM(1), (CFerry::eSpaceStyle)GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3)); + SET_FLOAT_PARAM(0, space.x); + SET_FLOAT_PARAM(1, space.y); + StoreParameters(&m_nIp, 2); + return 0; + } + case COMMAND_GET_FERRY_HEADING: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + float fHeading = Atan2(-pFerry->GetForward().x, pFerry->GetForward().y); + SET_FLOAT_PARAM(0, fHeading); + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_SET_FERRIES_DISABLED: + { + CollectParameters(&m_nIp, 2); + CFerry::SetFerriesDisabled(GET_INTEGER_PARAM(1)); + return 0; + } + case COMMAND_COMPLETE_FERRY_DOOR_MOVEMENT: + { + CollectParameters(&m_nIp, 1); + CFerry* pFerry = CFerry::GetFerry(GET_INTEGER_PARAM(0)); + script_assert(pFerry); + pFerry->CompleteDorrMovement(); + return 0; + } + case COMMAND_OVERRIDE_CAR_REMOTE_CONTROL: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + pVehicle->SetStatus(STATUS_PLAYER_REMOTE); + CVehicle::bDisableRemoteDetonation = true; + CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = pVehicle; + pVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle); + if (pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI || pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE) { + TheCamera.TakeControl(pVehicle, CCam::MODE_CAM_ON_A_STRING, GET_INTEGER_PARAM(1) ? INTERPOLATION : JUMP_CUT, CAMCONTROL_SCRIPT); + TheCamera.SetZoomValueCamStringScript(0); + } + else { + TheCamera.TakeControl(pVehicle, CCam::MODE_1STPERSON, GET_INTEGER_PARAM(1) ? INTERPOLATION : JUMP_CUT, CAMCONTROL_SCRIPT); + script_assert(pVehicle->IsCar()); + ((CAutomobile*)pVehicle)->Damage.m_bSmashedDoorDoesntClose = true; + } + if (m_bIsMissionScript) + CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CAR); + if (FindPlayerVehicle()) + FindPlayerVehicle()->bCanBeDamaged = false; + return 0; + } + case COMMAND_CANCEL_REMOTE_MODE: + { + if (FindPlayerVehicle()) + FindPlayerVehicle()->bCanBeDamaged = true; + CRemote::TakeRemoteControlledCarFromPlayer(false); + CWorld::Players[CWorld::PlayerInFocus].field_D6 = false; + CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = nil; + TheCamera.Restore(); + return 0; + } + case COMMAND_REGISTER_CAR_SOLD: + // CStats::CarsSold++; + return 0; + case COMMAND_ADD_MONEY_MADE_WITH_CAR_SALES: + CollectParameters(&m_nIp, 1); + // CStats::MoneyMadeWithCarSales += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_SET_BRIDGE_STATE: + { + CollectParameters(&m_nIp, 1); +#ifdef GTA_BRIDGE + /* + * 0 = locked + * 1 = unlocked + * 2 = operational + */ + switch (GET_INTEGER_PARAM(0)) { + case 0: CBridge::ForceBridgeState(STATE_BRIDGE_LOCKED); break; + case 1: CBridge::ForceBridgeState(STATE_BRIDGE_ALWAYS_UNLOCKED); break; + case 2: + if (CBridge::State == STATE_LIFT_PART_IS_DOWN || CBridge::State == STATE_BRIDGE_ALWAYS_UNLOCKED) + CBridge::ForceBridgeState(STATE_LIFT_PART_ABOUT_TO_MOVE_UP); + else + CBridge::ForceBridgeState(STATE_LIFT_PART_MOVING_DOWN); + break; + default: script_assert(false); + } +#endif + return 0; + } + case COMMAND_SET_OBJECT_TURN_SPEED: + { + CollectParameters(&m_nIp, 4); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + CVector vSpeed = GET_VECTOR_PARAM(1) / GAME_SPEED_TO_METERS_PER_SECOND; + pObject->SetTurnSpeed(vSpeed.x, vSpeed.y, vSpeed.z); + return 0; + } + case COMMAND_SET_OBJECT_MASS: + { + CollectParameters(&m_nIp, 4); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + pObject->m_fMass = GET_FLOAT_PARAM(1); + pObject->m_fTurnMass = GET_FLOAT_PARAM(2); + pObject->m_fAirResistance = GET_FLOAT_PARAM(3); + if (pObject->m_fMass < 99998.0f) { + pObject->bInfiniteMass = false; + pObject->m_phy_flagA08 = false; + pObject->bAffectedByGravity = true; + } + else { + pObject->bInfiniteMass = true; + pObject->m_phy_flagA08 = true; + pObject->bAffectedByGravity = false; + } + return 0; + } + case COMMAND_HAS_CUTSCENE_LOADED: + UpdateCompareFlag(CCutsceneMgr::ms_cutsceneLoadStatus == CUTSCENE_LOADED); + return 0; + case COMMAND_SET_UNIQUE_JUMPS_FOUND: + CollectParameters(&m_nIp, 1); + CStats::NumberOfUniqueJumpsFound = GET_INTEGER_PARAM(0); + return 0; + case COMMAND_SET_HIDDEN_PACKAGES_COLLECTED: + CollectParameters(&m_nIp, 1); + CWorld::Players[CWorld::PlayerInFocus].m_nCollectedPackages = GET_INTEGER_PARAM(0); + return 0; + case COMMAND_REGISTER_BIKE_SOLD: + // CStats::BikesSold++; + return 0; + case COMMAND_ADD_MONEY_MADE_WITH_BIKE_SALES: + CollectParameters(&m_nIp, 1); + // CStats::MoneyMadeWithBikeSales += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_REGISTER_PACKAGE_SMUGGLED: + // CStats::PackagesSmuggled++; + return 0; + case COMMAND_REGISTER_SMUGGLER_WASTED: + // CStats::SmugglersWasted++; + return 0; + case COMMAND_REGISTER_FASTEST_SMUGGLING_TIME: + CollectParameters(&m_nIp, 1); + // CStats::RegisterFastestSmugglingTime(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_SET_CHAR_DIVE_FROM_CAR: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + script_assert(pPed); + pPed->bRespondsToThreats = true; + pPed->SetEvasiveDive(pVehicle, 1); + return 0; + } + case COMMAND_WRECK_CAR: + { + CollectParameters(&m_nIp, 1); + CAutomobile* pVehicle = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + script_assert(pVehicle->IsCar()); + pVehicle->m_fHealth = 0.0f; + pVehicle->SetStatus(STATUS_WRECKED); + pVehicle->bRenderScorched = true; + pVehicle->Damage.FuckCarCompletely(); + if (pVehicle->GetModelIndex() != MI_RCBANDIT) { + pVehicle->SetBumperDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT); + pVehicle->SetBumperDamage(CAR_BUMP_REAR, VEHBUMPER_REAR); + pVehicle->SetDoorDamage(CAR_BONNET, DOOR_BONNET); + pVehicle->SetDoorDamage(CAR_BOOT, DOOR_BOOT); + pVehicle->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT); + pVehicle->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT); + pVehicle->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT); + pVehicle->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT); + } + pVehicle->m_bombType = CARBOMB_NONE; + pVehicle->bEngineOn = false; + pVehicle->bLightsOn = false; + pVehicle->m_fHealth = 0.0f; + pVehicle->m_nBombTimer = 0; + pVehicle->m_bSirenOrAlarm = false; + return 0; + } + case COMMAND_ADD_MONEY_MADE_IN_COACH: + CollectParameters(&m_nIp, 1); + // CStats::MoneyMadeInCoach += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_ADD_MONEY_MADE_COLLECTING_TRASH: + CollectParameters(&m_nIp, 1); + // CStats::MoneyMadeCollectingTrash += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_REGISTER_HITMAN_KILLED: + // CStats::HitmenKilled++; + return 0; + case COMMAND_REGISTER_GUARDIAN_ANGEL_MISSION_PASSED: + // CStats::GaurdianAngelMissionsPassed++; + return 0; + case COMMAND_REGISTER_HIGHEST_GUARDIAN_ANGEL_JUSTICE_DISHED: + CollectParameters(&m_nIp, 1); + // CStats::RegisterHighestGaurdianAngelJusticeDished(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_BEST_BANDIT_LAP_TIME: + CollectParameters(&m_nIp, 2); + // CStats::RegisterBestBanditLapTime(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_REGISTER_BEST_BANDIT_POSITION: + CollectParameters(&m_nIp, 2); + // CStats::RegisterBestBanditPosition(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_REGISTER_MOST_TIME_LEFT_TRAIN_RACE: + CollectParameters(&m_nIp, 1); + // CStats::RegisterMostTimeLeftTrainRace(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_HIGHEST_TRAIN_CASH_EARNED: + CollectParameters(&m_nIp, 1); + // CStats::RegisterHighestTrainCashEarned(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_FASTEST_HELI_RACE_TIME: + // CStats::RegisterFastestHeliRaceTime(GET_INTEGER_PARAM(0)); + CollectParameters(&m_nIp, 1); + return 0; + case COMMAND_REGISTER_BEST_HELI_RACE_POSITION: + // CStats::RegisterBestHeliRacePosition(GET_INTEGER_PARAM(0)); + CollectParameters(&m_nIp, 1); + return 0; + case COMMAND_REGISTER_OUTFIT_CHANGE: + // CStats::NumberOutfitChanges++; + return 0; + case COMMAND_REGISTER_STREET_RACE_FASTEST_TIME: + // CStats::RegisterStreetRaceFastestTime(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + CollectParameters(&m_nIp, 2); + return 0; + case COMMAND_REGISTER_STREET_RACE_FASTEST_LAP: + CollectParameters(&m_nIp, 2); + // CStats::RegisterStreetRaceFastestLap(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_REGISTER_STREET_RACE_BEST_POSITION: + CollectParameters(&m_nIp, 2); + // CStats::RegisterStreetRaceBestPosition(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + case COMMAND_HAS_OBJECT_BEEN_DAMAGED_BY_WEAPON: + { + CollectParameters(&m_nIp, 2); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + bool result = false; + if (!pObject) { + printf("HAS_OBJECT_BEEN_DAMAGED_BY_WEAPON - Object doesn\'t exist\n"); + } + else { + if (GET_INTEGER_PARAM(1) == WEAPONTYPE_ANYMELEE || GET_INTEGER_PARAM(1) == WEAPONTYPE_ANYWEAPON) + result = CheckDamagedWeaponType(pObject->m_nLastWeaponToDamage, GET_INTEGER_PARAM(1)); + else + result = GET_INTEGER_PARAM(1) == pObject->m_nLastWeaponToDamage; + } + UpdateCompareFlag(result); + return 0; + } + case COMMAND_CLEAR_OBJECT_LAST_WEAPON_DAMAGE: + { + CollectParameters(&m_nIp, 1); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + if (!pObject) + printf("CLEAR_OBJECT_LAST_WEAPON_DAMAGE - pObject doesn\'t exist"); + else + pObject->m_nLastWeaponToDamage = -1; + return 0; + } + case COMMAND_SET_CAR_TURN_SPEED: + { + CollectParameters(&m_nIp, 4); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + CVector vSpeed = GET_VECTOR_PARAM(1) / GAME_SPEED_TO_METERS_PER_SECOND; + pVehicle->SetTurnSpeed(vSpeed.x, vSpeed.y, vSpeed.z); + return 0; + } + case COMMAND_SET_CAR_MOVE_SPEED: + { + CollectParameters(&m_nIp, 4); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + CVector vSpeed = GET_VECTOR_PARAM(1) / GAME_SPEED_TO_METERS_PER_SECOND; + pVehicle->SetMoveSpeed(vSpeed); + return 0; + } + case COMMAND_SET_OBJECT_PROOFS: + { + CollectParameters(&m_nIp, 6); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + pObject->bBulletProof = (GET_INTEGER_PARAM(1) != 0); + pObject->bFireProof = (GET_INTEGER_PARAM(2) != 0); + pObject->bExplosionProof = (GET_INTEGER_PARAM(3) != 0); + pObject->bCollisionProof = (GET_INTEGER_PARAM(4) != 0); + pObject->bMeleeProof = (GET_INTEGER_PARAM(5) != 0); + return 0; + } + case COMMAND_GET_CAMERA_PED_ZOOM_INDICATOR: + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FOLLOWPED) + SET_INTEGER_PARAM(0, TheCamera.PedZoomIndicator); + else + SET_INTEGER_PARAM(0, -1); + StoreParameters(&m_nIp, 1); + return 0; + case COMMAND_SET_CAMERA_PED_ZOOM_INDICATOR: + CollectParameters(&m_nIp, 1); + if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FOLLOWPED) + TheCamera.PedZoomIndicator = GET_INTEGER_PARAM(0); + return 0; + case COMMAND_GET_CAR_ORIENTATION: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + SET_FLOAT_PARAM(1, LimitAngleOnCircle(RADTODEG(Asin(pVehicle->GetForward().z)))); + SET_FLOAT_PARAM(2, LimitAngleOnCircle(RADTODEG(Atan2(-pVehicle->GetForward().x, pVehicle->GetForward().y)))); + SET_FLOAT_PARAM(0, LimitAngleOnCircle(RADTODEG(Atan2(-pVehicle->GetRight().z, pVehicle->GetUp().z)))); + StoreParameters(&m_nIp, 3); + return 0; + } + case COMMAND_SET_CAR_ORIENTATION: + { + CollectParameters(&m_nIp, 4); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + pVehicle->SetOrientation(DEGTORAD(GET_FLOAT_PARAM(2)), DEGTORAD(GET_FLOAT_PARAM(1)), DEGTORAD(GET_FLOAT_PARAM(3))); + return 0; + } + case COMMAND_IS_DEBUG_MENU_ON: + // on PS2 it's something actual - TODO + UpdateCompareFlag(false); + return 0; + case COMMAND_OPEN_VAN_BACK_DOORS: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + assert(pVehicle); + pVehicle->ProcessOpenDoor(CAR_DOOR_RR, ANIM_STD_VAN_OPEN_DOOR_REAR_RHS, 1.0f); + pVehicle->ProcessOpenDoor(CAR_DOOR_LR, ANIM_STD_VAN_OPEN_DOOR_REAR_LHS, 1.0f); + return 0; + } + case COMMAND_GET_CHAR_THREAT_CHAR: + { + CollectParameters(&m_nIp, 1); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + SET_INTEGER_PARAM(0, 0); + CEntity* pThreat = pPed->m_threatEntity; + if (pThreat && pThreat->IsPed()) + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex((CPed*)pThreat)); + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_FREEZE_PED_ZOOM_SWITCH: + CollectParameters(&m_nIp, 1); + TheCamera.m_bFreezePedZoomSwitch = GET_INTEGER_PARAM(0); + return 0; + case COMMAND_SET_OBJECT_RENDERED_DAMAGED: + { + CollectParameters(&m_nIp, 1); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pObject); + pObject->bRenderDamaged = true; + return 0; + } + case COMMAND_GET_RANDOM_CAR_IN_AREA_NO_SAVE: + { + CollectParameters(&m_nIp, 5); + 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->GetVehicleAppearance() != VEHICLE_APPEARANCE_CAR && pVehicle->GetVehicleAppearance() != VEHICLE_APPEARANCE_BIKE) + continue; +#ifdef FIX_BUGS + if (pVehicle->m_fHealth <= 0.0f) +#else + if (pVehicle->m_fHealth == 0.0f) +#endif + continue; + if (pVehicle->GetModelIndex() != GET_INTEGER_PARAM(4) && GET_INTEGER_PARAM(4) >= 0) + continue; + if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE) + 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_IS_PLAYER_MADE_SAFE: + { + UpdateCompareFlag(CPad::GetPad(0)->IsPlayerControlsDisabledBy(PLAYERCONTROL_PLAYERINFO)); + return 0; + } + case COMMAND_PRINT_IF_FREE: + { + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + //CMessages::AddMessageIfFree(text, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); TODO + return 0; + } + case COMMAND_IS_E3_BUILD: + UpdateCompareFlag(false); + return 0; + case COMMAND_DECLARE_FORT_STAUNTON_DESTROYED_FLAG: + CTheScripts::FSDestroyedFlag = (uint8*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - CTheScripts::ScriptSpace; + return 0; + case COMMAND_CLEAR_BIG_MESSAGES: + //CMessages::ClearBigMessagesOnly(); TODO + //CHud::ClearBigMessagesExcept(2, 2); TODO + CGarages::MessageEndTime = CGarages::MessageStartTime; + return 0; + case COMMAND_CLEAR_AREA_OF_OBJECTS: + { + CollectParameters(&m_nIp, 6); + uint32 i = CPools::GetObjectPool()->GetSize(); + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); + while (i--) { + CObject* pObject = CPools::GetObjectPool()->GetSlot(i); + if (pObject && pObject->CanBeDeleted() && pObject->IsWithinArea(infX, infY, infZ, supX, supY, supZ)) { + pObject->DeleteRwObject(); + CWorld::Remove(pObject); + delete pObject; + } + } + i = CPools::GetDummyPool()->GetSize(); + while (i--) { + CDummy* pDummy = CPools::GetDummyPool()->GetSlot(i); + if (pDummy && pDummy->IsObject() && pDummy->IsWithinArea(infX, infY, infZ, supX, supY, supZ)) { + pDummy->DeleteRwObject(); + CWorld::Remove(pDummy); + delete pDummy; + } + } + return 0; + } + case COMMAND_LOAD_NON_STANDARD_PED_ANIM: + CollectParameters(&m_nIp, 1); + CPed::LoadNonStandardPedAnim((eWaitState)GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_UNLOAD_NON_STANDARD_PED_ANIM: + CollectParameters(&m_nIp, 1); + CPed::UnloadNonStandardPedAnim((eWaitState)GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_1566: + CollectParameters(&m_nIp, 1); + return 0; + case COMMAND_BUILD_WORLD_GEOMETRY: + CollectParameters(&m_nIp, 1); + if (/*gBuildWorldGeom*/ false) { + //base::cWorldGeom::GetInstance()->Build(GET_INTEGER_PARAM(0)); + UpdateCompareFlag(true); + } + else { + UpdateCompareFlag(false); + } + return 0; + case COMMAND_STORE_BUILDING_SWAP: + CollectParameters(&m_nIp, 4); + // base::cWorldGeom::GetInstance()->StoreBuildingSwap(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3) != 0); + return 0; + case COMMAND_IS_MULTIPLAYER_ACTIVE: +#ifdef GTA_NETWORK + UpdateCompareFlag(gIsMultiplayerGame); +#else + UpdateCompareFlag(false); +#endif + return 0; + case COMMAND_GET_MULTIPLAYER_MODE: + SET_INTEGER_PARAM(0, 0); // TODO + StoreParameters(&m_nIp, 1); + return 0; + case COMMAND_MULTIPLAYER_SCRIPT_DONE: + printf("COMMAND_MULTIPLAYER_SCRIPT_DONE\n"); + //gbStartingScriptsFromLua = false; TODO? + return 0; + case COMMAND_IS_MULTIPLAYER_SERVER: + UpdateCompareFlag(false); // TODO? + return 0; + case COMMAND_IS_MULTIPLAYER_TEAM_GAME: + UpdateCompareFlag(false); // TODO? + return 0; + case COMMAND_GET_MULTIPLAYER_TEAM_ID: + SET_INTEGER_PARAM(0, 0); // TODO + StoreParameters(&m_nIp, 1); + return 0; + case COMMAND_DOES_SHORTCUT_TAXI_EXIST: + UpdateCompareFlag(CGameLogic::pShortCutTaxi != nil); + return 0; + case COMMAND_SET_ONSCREEN_TIMER_COLOUR: + CollectParameters(&m_nIp, 4); + gbColour = CRGBA(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3)); + return 0; + case COMMAND_SET_ONSCREEN_TIMER_BACKGROUND_COLOUR: + CollectParameters(&m_nIp, 4); + gbColour2 = CRGBA(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2), GET_INTEGER_PARAM(3)); + return 0; + case COMMAND_REMOVE_CAR_BOOT: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + script_assert(pVehicle->IsCar()); + CAutomobile* pAutomobile = (CAutomobile*)pVehicle; + pAutomobile->Damage.SetDoorStatus(DOOR_BOOT, DOOR_STATUS_MISSING); + pAutomobile->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true); + return 0; + } + case COMMAND_ADD_POINT_3D_MARKER: + { + uint32 ip = m_nIp; + uint32 id = (uint32)(uintptr)GetPointerToScriptVariable(&ip, 0); + static CVector vPreviousLocation; + CollectParameters(&m_nIp, 7); + CVector pos = GET_VECTOR_PARAM(0); + if (pos.z <= MAP_Z_LOW_LIMIT) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + if (vPreviousLocation != pos) { + //C3dMarkers::CopyMarker(id, id - 1, 1, 1); + } + // TODO: 5 is not a valid type + //C3dMarkers::PlaceMarker(id, 5, pos, GET_FLOAT_PARAM(3) * 0.7f, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), 255, 128, 0.0f, 1); // TODO: 0, 100.0f, 1, 0 + vPreviousLocation = pos; + return 0; + } + case COMMAND_GET_VECTOR_FROM_MULTIPLAYER: + SET_VECTOR_PARAM(0, gVectorSetInLua); + StoreParameters(&m_nIp, 3); + return 0; + case COMMAND_PRINT_HELP_ALWAYS: + { + // CHud::mAlwaysAllowHelpText = true; // TODO + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CHud::SetHelpMessage(text, false); // + false, true + return 0; + } + case COMMAND_PRINT_HELP_FOREVER_ALWAYS: + { + // CHud::mAlwaysAllowHelpText = true; // TODO + wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CHud::SetHelpMessage(text, false, true); // + true + return 0; + } + case COMMAND_SWITCH_FERRY_COLLISION: + CollectParameters(&m_nIp, 1); + CFerry::SwitchFerryCollision(GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_SET_CHAR_MAX_HEALTH: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->m_fHealth = GET_INTEGER_PARAM(1); + pPed->m_fMaxHealth = GET_INTEGER_PARAM(1); + return 0; + } + case COMMAND_SET_CHAR_SHOOT_TIMER: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->m_nScriptShootTimer = GET_INTEGER_PARAM(1); + return 0; + } + case COMMAND_SET_CHAR_ATTACK_TIMER: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->m_nScriptAttackTimer = GET_INTEGER_PARAM(1); + return 0; + } + case COMMAND_SET_HELI_ROTOR_BLADES_FULLSPEED: + { + CollectParameters(&m_nIp, 1); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pHeli); + if (pHeli->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI) + pHeli->m_aWheelSpeed[1] = 0.22f; + return 0; + } + case COMMAND_SET_CRUSHER_REWARD_MULTIPLIER: + { + CollectParameters(&m_nIp, 1); + CGarages::CrusherRewardMultiplier = GET_INTEGER_PARAM(0); + return 0; + } + case COMMAND_SWAP_BUILDINGS: + { + CollectParameters(&m_nIp, 2); + // base::cWorldStream::Instance()->SwapBuilding(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); + return 0; + } + case COMMAND_STREAM_BUILDING_SWAPS: + { + // UpdateCompareFlag(base::cWorldStream::Instance()->StreamBuildingSwaps()); + UpdateCompareFlag(true); + return 0; + } + case COMMAND_IS_WORLD_STREAMING_COMPLETE: + { + // UpdateCompareFlag(base::cWorldStream::Instance()->IsStreamingComplet()); + UpdateCompareFlag(true); + return 0; + } + case COMMAND_SWAP_TO_STREAMED_SECTOR: + { + // base::cWorldStream::Instance()->SwapToStreamedSector(); + return 0; + } + case COMMAND_SET_CHAR_ATTACKS_PLAYER_WITH_COPS: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bAttacksPlayerWithCops = (GET_INTEGER_PARAM(1) != 0); + return 0; + } + case COMMAND_REGISTER_FACE_PLANT_DISTANCE: + CollectParameters(&m_nIp, 1); + //CStats::LongestFacePlantDist = Max(CStats::LongestFacePlantDist, GET_FLOAT_PARAM(0)); + return 0; + case COMMAND_REGISTER_MAX_SECONDS_ON_CARNAGE_LEFT: + CollectParameters(&m_nIp, 1); + //CStats::MaxSecondsOnCarnageLeft = Max(CStats::MaxSecondsOnCarnageLeft, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_MAX_KILLS_ON_RC_TRIAD: + CollectParameters(&m_nIp, 1); + //CStats::MaxKillsOnRcTriad = Max(CStats::MaxKillsOnRcTriad, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_REGISTER_HIGHEST_LEVEL_SLASH_TV: + CollectParameters(&m_nIp, 1); + //CStats::HighestLevelSlashTv = Max(CStats::HighestLevelSlashTv, GET_INTEGER_PARAM(0)); + return 0; + case COMMAND_ADD_MONEY_MADE_WITH_SLASH_TV: + CollectParameters(&m_nIp, 1); + //CStats::MoneyMadeWithSlashTv += GET_INTEGER_PARAM(0); + return 0; + case COMMAND_ADD_TOTAL_KILLS_ON_SLASH_TV: + CollectParameters(&m_nIp, 1); + //CStats::TotalKillsOnSlashTV += GET_INTEGER_PARAM(0); + return 0; + default: + script_assert(0); + } + return -1; +}
\ No newline at end of file diff --git a/src/control/ScriptCommands.h b/src/control/ScriptCommands.h index 9cb39e23..ea968697 100644 --- a/src/control/ScriptCommands.h +++ b/src/control/ScriptCommands.h @@ -215,6 +215,11 @@ enum { COMMAND_WHILE, COMMAND_WHILENOT, COMMAND_ENDWHILE, + COMMAND_214, + COMMAND_215, + COMMAND_216, + COMMAND_217, + COMMAND_218, COMMAND_ANDOR, COMMAND_LAUNCH_MISSION, COMMAND_MISSION_HAS_FINISHED, @@ -1441,39 +1446,222 @@ enum { COMMAND_REGISTER_FIRE_LEVEL, COMMAND_IS_AUSTRALIAN_GAME, COMMAND_DISARM_CAR_BOMB, -#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) COMMAND_IS_JAPANESE_GAME, -#elif (!defined GTA_PS2) - COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED, -#endif -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - COMMAND_SHUFFLE_CARD_DECKS, - COMMAND_FETCH_NEXT_CARD, - COMMAND_GET_OBJECT_VELOCITY, - COMMAND_IS_DEBUG_CAMERA_ON, - COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY, - COMMAND_SET_OBJECT_ROTATION_VELOCITY, - COMMAND_IS_OBJECT_STATIC, - COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS, - COMMAND_DO_2D_RECTANGLES_COLLIDE, - COMMAND_GET_OBJECT_ROTATION_VELOCITY, - COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY, - COMMAND_GET_OBJECT_SPEED, -#endif -#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT) - COMMAND_MARK_CUTSCENE_START, - COMMAND_MARK_CUTSCENE_END, - COMMAND_CUTSCENE_SCROLL, -#elif (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - COMMAND_IS_MISSION_SKIP, - COMMAND_SET_IN_AMMUNATION, - COMMAND_DO_SAVE_GAME, - COMMAND_IS_RETRY, - COMMAND_DUMMY, - COMMAND_MARK_CUTSCENE_START, - COMMAND_MARK_CUTSCENE_END, - COMMAND_CUTSCENE_SCROLL, -#endif + COMMAND_1442, + COMMAND_1443, + COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS, + COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS, + COMMAND_DOT_PRODUCT_2D, + COMMAND_DOT_PRODUCT_3D, + COMMAND_DEBUG_PRINT_WITH_1_FLOAT, + COMMAND_DEBUG_PRINT_WITH_2_FLOATS, + COMMAND_DEBUG_PRINT_WITH_3_FLOATS, + COMMAND_GET_PAD_BUTTON_STATE, + COMMAND_SET_NAVIGATION_ARROW, + COMMAND_CLEAR_NAVIGATION_ARROW, + COMMAND_CALL, + COMMAND_CALLNOT, + COMMAND_IS_CAR_AUTOMOBILE, + COMMAND_IS_CAR_BIKE, + COMMAND_IS_CAR_PLANE, + COMMAND_IS_CAR_HELI, + COMMAND_1460, + COMMAND_1461, + COMMAND_1462, + COMMAND_1463, + COMMAND_1464, + COMMAND_1465, + COMMAND_1466, + COMMAND_1467, + COMMAND_1468, + COMMAND_1469, + COMMAND_1470, + COMMAND_1471, + COMMAND_1472, + COMMAND_1473, + COMMAND_1474, + COMMAND_1475, + COMMAND_1476, + COMMAND_RETURN_IF_TRUE, + COMMAND_RETURN_TRUE_IF_TRUE, + COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND, + COMMAND_SET_RC_HELI_HEIGHT_LIMIT, + COMMAND_CREATE_SCRIPT_CORONA, + COMMAND_REMOVE_SCRIPT_CORONA, + COMMAND_IS_BOAT_IN_WATER, + COMMAND_IS_CAR_DRIVER_BEING_JACKED, + COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT, + COMMAND_SET_CAR_TILTED_BY_CHAR, + COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA, + COMMAND_IS_PLAYER_USING_FIRST_PERSON_WEAPON_CAMERA, + COMMAND_1489, + COMMAND_1490, + COMMAND_1491, + COMMAND_SET_DEBUG_MENU_ACTIVE, + COMMAND_SET_DRAW_HUD, + COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS, + COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE, + COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE, + COMMAND_DISABLE_FERRY_PATH, + COMMAND_ENABLE_FERRY_PATH, + COMMAND_GET_CLOSEST_DOCKED_FERRY, + COMMAND_OPEN_FERRY_DOOR, + COMMAND_CLOSE_FERRY_DOOR, + COMMAND_IS_FERRY_DOOR_OPEN, + COMMAND_IS_FERRY_DOOR_CLOSED, + COMMAND_SKIP_FERRY_TO_NEXT_DOCK, + COMMAND_SET_CHAR_DROPS_WEAPONS_ON_DEATH, + COMMAND_IS_CHAR_CROUCHING, + COMMAND_GET_FERRY_BOARDING_SPACE, + COMMAND_GET_FERRY_HEADING, + COMMAND_SET_FERRIES_DISABLED, + COMMAND_COMPLETE_FERRY_DOOR_MOVEMENT, + COMMAND_OVERRIDE_CAR_REMOTE_CONTROL, + COMMAND_CANCEL_REMOTE_MODE, + COMMAND_REGISTER_CAR_SOLD, + COMMAND_ADD_MONEY_MADE_WITH_CAR_SALES, + COMMAND_SET_BRIDGE_STATE, + COMMAND_SET_OBJECT_TURN_SPEED, + COMMAND_SET_OBJECT_MASS, + COMMAND_HAS_CUTSCENE_LOADED, + COMMAND_SET_UNIQUE_JUMPS_FOUND, + COMMAND_SET_HIDDEN_PACKAGES_COLLECTED, + COMMAND_REGISTER_BIKE_SOLD, + COMMAND_ADD_MONEY_MADE_WITH_BIKE_SALES, + COMMAND_REGISTER_PACKAGE_SMUGGLED, + COMMAND_REGISTER_SMUGGLER_WASTED, + COMMAND_REGISTER_FASTEST_SMUGGLING_TIME, + COMMAND_SET_CHAR_DIVE_FROM_CAR, + COMMAND_WRECK_CAR, + COMMAND_ADD_MONEY_MADE_IN_COACH, + COMMAND_ADD_MONEY_MADE_COLLECTING_TRASH, + COMMAND_REGISTER_HITMAN_KILLED, + COMMAND_REGISTER_GUARDIAN_ANGEL_MISSION_PASSED, + COMMAND_REGISTER_HIGHEST_GUARDIAN_ANGEL_JUSTICE_DISHED, + COMMAND_REGISTER_BEST_BANDIT_LAP_TIME, + COMMAND_REGISTER_BEST_BANDIT_POSITION, + COMMAND_REGISTER_MOST_TIME_LEFT_TRAIN_RACE, + COMMAND_REGISTER_HIGHEST_TRAIN_CASH_EARNED, + COMMAND_REGISTER_FASTEST_HELI_RACE_TIME, + COMMAND_REGISTER_BEST_HELI_RACE_POSITION, + COMMAND_REGISTER_OUTFIT_CHANGE, + COMMAND_REGISTER_STREET_RACE_FASTEST_TIME, + COMMAND_REGISTER_STREET_RACE_FASTEST_LAP, + COMMAND_REGISTER_STREET_RACE_BEST_POSITION, + COMMAND_HAS_OBJECT_BEEN_DAMAGED_BY_WEAPON, + COMMAND_CLEAR_OBJECT_LAST_WEAPON_DAMAGE, + COMMAND_SET_CAR_TURN_SPEED, + COMMAND_SET_CAR_MOVE_SPEED, + COMMAND_SET_OBJECT_PROOFS, + COMMAND_GET_CAMERA_PED_ZOOM_INDICATOR, + COMMAND_SET_CAMERA_PED_ZOOM_INDICATOR, + COMMAND_GET_CAR_ORIENTATION, + COMMAND_SET_CAR_ORIENTATION, + COMMAND_IS_DEBUG_MENU_ON, + COMMAND_OPEN_VAN_BACK_DOORS, + COMMAND_GET_CHAR_THREAT_CHAR, + COMMAND_FREEZE_PED_ZOOM_SWITCH, + COMMAND_SET_OBJECT_RENDERED_DAMAGED, + COMMAND_GET_RANDOM_CAR_IN_AREA_NO_SAVE, + COMMAND_IS_PLAYER_MADE_SAFE, + COMMAND_PRINT_IF_FREE, + COMMAND_IS_E3_BUILD, + COMMAND_DECLARE_FORT_STAUNTON_DESTROYED_FLAG, + COMMAND_CLEAR_BIG_MESSAGES, + COMMAND_CLEAR_AREA_OF_OBJECTS, + COMMAND_LOAD_NON_STANDARD_PED_ANIM, + COMMAND_UNLOAD_NON_STANDARD_PED_ANIM, + COMMAND_1566, + COMMAND_BUILD_WORLD_GEOMETRY, + COMMAND_STORE_BUILDING_SWAP, + COMMAND_IS_MULTIPLAYER_ACTIVE, + COMMAND_GET_MULTIPLAYER_MODE, + COMMAND_MULTIPLAYER_SCRIPT_DONE, + COMMAND_IS_MULTIPLAYER_SERVER, + COMMAND_IS_MULTIPLAYER_TEAM_GAME, + COMMAND_GET_MULTIPLAYER_TEAM_ID, + COMMAND_DOES_SHORTCUT_TAXI_EXIST, + COMMAND_SET_ONSCREEN_TIMER_COLOUR, + COMMAND_SET_ONSCREEN_TIMER_BACKGROUND_COLOUR, + COMMAND_REMOVE_CAR_BOOT, + COMMAND_ADD_POINT_3D_MARKER, + COMMAND_GET_VECTOR_FROM_MULTIPLAYER, + COMMAND_PRINT_HELP_ALWAYS, + COMMAND_PRINT_HELP_FOREVER_ALWAYS, + COMMAND_SWITCH_FERRY_COLLISION, + COMMAND_SET_CHAR_MAX_HEALTH, + COMMAND_SET_CHAR_SHOOT_TIMER, + COMMAND_SET_CHAR_ATTACK_TIMER, + COMMAND_SET_HELI_ROTOR_BLADES_FULLSPEED, + COMMAND_SET_CRUSHER_REWARD_MULTIPLIER, + COMMAND_SWAP_BUILDINGS, + COMMAND_STREAM_BUILDING_SWAPS, + COMMAND_IS_WORLD_STREAMING_COMPLETE, + COMMAND_SWAP_TO_STREAMED_SECTOR, + COMMAND_SET_CHAR_ATTACKS_PLAYER_WITH_COPS, + COMMAND_REGISTER_FACE_PLANT_DISTANCE, + COMMAND_REGISTER_MAX_SECONDS_ON_CARNAGE_LEFT, + COMMAND_REGISTER_MAX_KILLS_ON_RC_TRIAD, + COMMAND_REGISTER_HIGHEST_LEVEL_SLASH_TV, + COMMAND_ADD_MONEY_MADE_WITH_SLASH_TV, + COMMAND_ADD_TOTAL_KILLS_ON_SLASH_TV, + COMMAND_ADD_NOODLES_DELIVERED, + COMMAND_REGISTER_SCRAPYARD_CHALLENGE_SCORE, + COMMAND_REGISTER_9MM_MAYHEM_SCORE, + COMMAND_REGISTER_SCOOTER_SHOOTER_SCORE, + COMMAND_ADD_MONEY_MADE_FROM_TOURIST, + COMMAND_ADD_TOURISTS_TAKEN_TO_SPOTS, + COMMAND_ADD_EXPORTED_CARS, + COMMAND_SET_TOTAL_EXPORT_CARS, + COMMAND_REGISTER_DIRT_BIKE_FASTEST_LAP, + COMMAND_REGISTER_DIRT_BIKE_FASTEST_TIME, + COMMAND_REGISTER_DIRT_BIKE_AIR_TIME, + COMMAND_ADD_ARROW_3D_MARKER, + COMMAND_PRINT_NOW_OVERRIDE_FADE, + COMMAND_GET_PICKUP_VALUE, + COMMAND_SET_PICKUP_VALUE, + COMMAND_IS_DEVELOPER, + COMMAND_SET_DEVELOPER_FLAG, + COMMAND_REGISTER_WICHITA_WIPEOUT_SCORE, + COMMAND_ATTACH_OBJECT_TO_CAR, + COMMAND_DETACH_OBJECT_FROM_CAR, + COMMAND_SET_PAD_STICKS_MULTIPLIER, + COMMAND_PRINT_SUBTITLE_NOW, + COMMAND_PRINT_SUBTITLE_NOW_OVERRIDE_FADE, + COMMAND_PRINT_SUBTITLE_NOW_NO_BRIEF, + COMMAND_PRINT_WITH_NUMBER_NOW_NO_BRIEF, + COMMAND_GET_ANGLE_BETWEEN_POINTS, + COMMAND_OVERRIDE_CHAR_MOVE_ANIM, + COMMAND_1627, + COMMAND_ENABLE_EMERGENCY_VEHICLES, + COMMAND_ADD_UNLOCKED_COSTUME, + COMMAND_CLEAR_MULTIPLAYER_SPLASH_SCREEN, + COMMAND_PRINT_WITH_2_NUMBERS_NOW_NO_BRIEF, + COMMAND_GET_OBJECT_ORIENTATION, + COMMAND_SET_OBJECT_ORIENTATION, + COMMAND_CHANGE_ONSCREEN_COUNTER_PREFIX, + COMMAND_STORE_PLAYER_OUTFIT, + COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_STRING, + COMMAND_SET_PLAYER_CURRENT_WEAPON_AMMO_IN_CLIP, + COMMAND_SET_CHAR_WAIT_STATE_REPEAT, + COMMAND_REGISTER_BEST_TIME_GOGO_FAGGIO, + COMMAND_LOCK_GARAGE, + COMMAND_IS_FINAL_GAME, + COMMAND_SET_ALLOWED_COLLISION, + COMMAND_REGISTER_GUARDIAN_ANGEL_LEVEL, + COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_2_STRINGS, + COMMAND_GET_PLAYER_STORED_WEAPON, + COMMAND_DISABLE_PAUSE_MENU, + COMMAND_IS_CHANNEL_PLAYING, + COMMAND_SET_CLOCK_EVENT_WARNING, + COMMAND_SET_EXTRA_COLOUR_LIGHT_DIRECTION, + COMMAND_SET_CHAR_CAN_BE_TARGETTED_BY_LEADER, + COMMAND_PRINT_HELP_NO_BRIEF, + COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, + COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, + COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, + COMMAND_SET_CAR_IS_REWARD, + COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT LAST_SCRIPT_COMMAND #endif @@ -1492,7 +1680,9 @@ enum eScriptArgument ARGTYPE_PED_HANDLE, ARGTYPE_VEHICLE_HANDLE, ARGTYPE_OBJECT_HANDLE, - ARGTYPE_ANDOR + ARGTYPE_ANDOR, + ARGTYPE_LIST, + ARGTYPE_FUNCTION }; struct tScriptCommandData diff --git a/src/control/ScriptDebug.cpp b/src/control/ScriptDebug.cpp index 1ca5f588..fd64b44e 100644 --- a/src/control/ScriptDebug.cpp +++ b/src/control/ScriptDebug.cpp @@ -239,6 +239,11 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_WHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_WHILENOT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ENDWHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_214, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_215, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_216, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_217, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_218, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ANDOR, INPUT_ARGUMENTS(ARGTYPE_ANDOR,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_LAUNCH_MISSION, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_MISSION_HAS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), @@ -293,7 +298,7 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_ADD_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_SCORE_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_STORE_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL_NO_DROP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_WANTED_LEVEL_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), @@ -1105,7 +1110,7 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_IS_CAR_PASSENGER_SEAT_FREE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_GET_CHAR_IN_CAR_PASSENGER_SEAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_CHAR_IS_CHRIS_CRIMINAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_START_CREDITS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_START_CREDITS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_STOP_CREDITS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_ARE_CREDITS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_CREATE_SINGLE_PARTICLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), @@ -1193,7 +1198,7 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_SHUT_CHAR_UP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_ENABLE_RC_DETONATE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_SET_CAR_RANDOM_ROUTE_SEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_ANY_PICKUP_AT_COORDS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_ANY_PICKUP_AT_COORDS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_GET_FIRST_PICKUP_COORDS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), REGISTER_COMMAND(COMMAND_GET_NEXT_PICKUP_COORDS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), REGISTER_COMMAND(COMMAND_REMOVE_ALL_CHAR_WEAPONS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), @@ -1465,39 +1470,222 @@ const tScriptCommandData commands[] = { REGISTER_COMMAND(COMMAND_REGISTER_FIRE_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_IS_AUSTRALIAN_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), REGISTER_COMMAND(COMMAND_DISARM_CAR_BOMB, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), -#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) REGISTER_COMMAND(COMMAND_IS_JAPANESE_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), -#elif (!defined GTA_PS2) - REGISTER_COMMAND(COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), -#endif -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - REGISTER_COMMAND(COMMAND_SHUFFLE_CARD_DECKS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_FETCH_NEXT_CARD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_GET_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_DEBUG_CAMERA_ON, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_OBJECT_STATIC, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_DO_2D_RECTANGLES_COLLIDE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_GET_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_GET_OBJECT_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), -#endif -#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT) - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_START, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_END, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_CUTSCENE_SCROLL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), -#elif (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) - REGISTER_COMMAND(COMMAND_IS_MISSION_SKIP, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_SET_IN_AMMUNATION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_DO_SAVE_GAME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_IS_RETRY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), - REGISTER_COMMAND(COMMAND_DUMMY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_START, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_END, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_CUTSCENE_SCROLL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), -#endif + REGISTER_COMMAND(COMMAND_1442, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1443, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DOT_PRODUCT_2D, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DOT_PRODUCT_3D, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DEBUG_PRINT_WITH_1_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DEBUG_PRINT_WITH_2_FLOATS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DEBUG_PRINT_WITH_3_FLOATS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PAD_BUTTON_STATE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_NAVIGATION_ARROW, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_NAVIGATION_ARROW, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CALL, INPUT_ARGUMENTS(ARGTYPE_FUNCTION,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CALLNOT, INPUT_ARGUMENTS(ARGTYPE_FUNCTION,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_AUTOMOBILE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_BIKE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_PLANE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_HELI, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_1460, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1461, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1462, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1463, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1464, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1465, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1466, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1467, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1468, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1469, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1470, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1471, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1472, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1473, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1474, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1475, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1476, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RETURN_IF_TRUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_RETURN_TRUE_IF_TRUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_RC_HELI_HEIGHT_LIMIT, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CREATE_SCRIPT_CORONA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_SCRIPT_CORONA, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_BOAT_IN_WATER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CAR_DRIVER_BEING_JACKED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_TILTED_BY_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_USING_FIRST_PERSON_WEAPON_CAMERA, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_1489, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1490, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1491, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_DEBUG_MENU_ACTIVE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_DRAW_HUD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISABLE_FERRY_PATH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ENABLE_FERRY_PATH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CLOSEST_DOCKED_FERRY, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_OPEN_FERRY_DOOR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLOSE_FERRY_DOOR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_FERRY_DOOR_OPEN, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_FERRY_DOOR_CLOSED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SKIP_FERRY_TO_NEXT_DOCK, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_DROPS_WEAPONS_ON_DEATH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHAR_CROUCHING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_FERRY_BOARDING_SPACE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_FERRY_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_FERRIES_DISABLED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_COMPLETE_FERRY_DOOR_MOVEMENT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_OVERRIDE_CAR_REMOTE_CONTROL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CANCEL_REMOTE_MODE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_CAR_SOLD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_WITH_CAR_SALES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_BRIDGE_STATE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_TURN_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_MASS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_CUTSCENE_LOADED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_UNIQUE_JUMPS_FOUND, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_HIDDEN_PACKAGES_COLLECTED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_BIKE_SOLD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_WITH_BIKE_SALES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_PACKAGE_SMUGGLED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_SMUGGLER_WASTED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_FASTEST_SMUGGLING_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_DIVE_FROM_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_WRECK_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_IN_COACH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_COLLECTING_TRASH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_HITMAN_KILLED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_GUARDIAN_ANGEL_MISSION_PASSED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_GUARDIAN_ANGEL_JUSTICE_DISHED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_BEST_BANDIT_LAP_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_BEST_BANDIT_POSITION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_MOST_TIME_LEFT_TRAIN_RACE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_TRAIN_CASH_EARNED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_FASTEST_HELI_RACE_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_BEST_HELI_RACE_POSITION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_OUTFIT_CHANGE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_STREET_RACE_FASTEST_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_STREET_RACE_FASTEST_LAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_STREET_RACE_BEST_POSITION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_HAS_OBJECT_BEEN_DAMAGED_BY_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_OBJECT_LAST_WEAPON_DAMAGE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_TURN_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_MOVE_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_PROOFS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAMERA_PED_ZOOM_INDICATOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAMERA_PED_ZOOM_INDICATOR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CAR_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_DEBUG_MENU_ON, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_OPEN_VAN_BACK_DOORS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_CHAR_THREAT_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_FREEZE_PED_ZOOM_SWITCH, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_RENDERED_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_RANDOM_CAR_IN_AREA_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_PLAYER_MADE_SAFE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_IF_FREE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_E3_BUILD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_DECLARE_FORT_STAUNTON_DESTROYED_FLAG, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_BIG_MESSAGES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_AREA_OF_OBJECTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOAD_NON_STANDARD_PED_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_UNLOAD_NON_STANDARD_PED_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1566, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_BUILD_WORLD_GEOMETRY, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_BUILDING_SWAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_MULTIPLAYER_ACTIVE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_MULTIPLAYER_MODE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_MULTIPLAYER_SCRIPT_DONE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_MULTIPLAYER_SERVER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_MULTIPLAYER_TEAM_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_GET_MULTIPLAYER_TEAM_ID, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DOES_SHORTCUT_TAXI_EXIST, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ONSCREEN_TIMER_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ONSCREEN_TIMER_BACKGROUND_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REMOVE_CAR_BOOT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_POINT_3D_MARKER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_VECTOR_FROM_MULTIPLAYER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWITCH_FERRY_COLLISION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_MAX_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_SHOOT_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ATTACK_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_HELI_ROTOR_BLADES_FULLSPEED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CRUSHER_REWARD_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SWAP_BUILDINGS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STREAM_BUILDING_SWAPS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_IS_WORLD_STREAMING_COMPLETE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SWAP_TO_STREAMED_SECTOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_ATTACKS_PLAYER_WITH_COPS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_FACE_PLANT_DISTANCE, INPUT_ARGUMENTS(ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_MAX_SECONDS_ON_CARNAGE_LEFT, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_MAX_KILLS_ON_RC_TRIAD, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_LEVEL_SLASH_TV, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_WITH_SLASH_TV, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_TOTAL_KILLS_ON_SLASH_TV, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_NOODLES_DELIVERED, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_SCRAPYARD_CHALLENGE_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_9MM_MAYHEM_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_SCOOTER_SHOOTER_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_FROM_TOURIST, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_TOURISTS_TAKEN_TO_SPOTS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_EXPORTED_CARS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_TOTAL_EXPORT_CARS, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_DIRT_BIKE_FASTEST_LAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_DIRT_BIKE_FASTEST_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_DIRT_BIKE_AIR_TIME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_ARROW_3D_MARKER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_NOW_OVERRIDE_FADE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PICKUP_VALUE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PICKUP_VALUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_DEVELOPER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_DEVELOPER_FLAG, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_WICHITA_WIPEOUT_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ATTACH_OBJECT_TO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DETACH_OBJECT_FROM_CAR, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PAD_STICKS_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_SUBTITLE_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_SUBTITLE_NOW_OVERRIDE_FADE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_SUBTITLE_NOW_NO_BRIEF, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER_NOW_NO_BRIEF, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_ANGLE_BETWEEN_POINTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_OVERRIDE_CHAR_MOVE_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1627, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ENABLE_EMERGENCY_VEHICLES, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_ADD_UNLOCKED_COSTUME, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CLEAR_MULTIPLAYER_SPLASH_SCREEN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_WITH_2_NUMBERS_NOW_NO_BRIEF, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_OBJECT_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_OBJECT_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CHANGE_ONSCREEN_COUNTER_PREFIX, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_STORE_PLAYER_OUTFIT, INPUT_ARGUMENTS(ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_STRING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_PLAYER_CURRENT_WEAPON_AMMO_IN_CLIP, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_WAIT_STATE_REPEAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_BEST_TIME_GOGO_FAGGIO, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_LOCK_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_FINAL_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_ALLOWED_COLLISION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_REGISTER_GUARDIAN_ANGEL_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_2_STRINGS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_GET_PLAYER_STORED_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(ARGTYPE_INT,), false, -1, ""), + REGISTER_COMMAND(COMMAND_DISABLE_PAUSE_MENU, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_IS_CHANNEL_PLAYING, INPUT_ARGUMENTS(ARGTYPE_INT,), OUTPUT_ARGUMENTS(), true, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CLOCK_EVENT_WARNING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_EXTRA_COLOUR_LIGHT_DIRECTION, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CHAR_CAN_BE_TARGETTED_BY_LEADER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_CAR_IS_REWARD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT,), OUTPUT_ARGUMENTS(), false, -1, ""), }; #undef REGISTER_COMMAND #undef INPUT_ARGUMENTS @@ -1539,62 +1727,89 @@ void FlushLog() #endif } -#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT -int CRunningScript::CollectParameterForDebug(char* buf, bool& var) +int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp, char* buf) { - uint16 varIndex; char tmpstr[24]; + uint8 type = CTheScripts::Read1ByteFromScript(pIp); + if (type >= ARGUMENT_GLOBAL_ARRAY) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(pIp); + script_assert(size > 0); + script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size); + uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1); + sprintf(tmpstr, " $%d[%d@ (%d)]", ((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index_in_block, index_id, pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id]); + strcat(buf, tmpstr); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index + index_in_block)]; + } + else if (type >= ARGUMENT_GLOBAL) { + uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp); + sprintf(tmpstr, " $%d", ((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block); + strcat(buf, tmpstr); + return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block)]; + } + else if (type >= ARGUMENT_LOCAL_ARRAY) { + uint8 index_id = CTheScripts::Read1ByteFromScript(pIp); + uint8 size = CTheScripts::Read1ByteFromScript(pIp); + script_assert(size > 0); + script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size); + uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1); + sprintf(tmpstr, " %d@[%d@ (%d)]", (type - ARGUMENT_LOCAL_ARRAY), index_id, pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id]); + strcat(buf, tmpstr); + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL_ARRAY) + index]; + } + else if (type >= ARGUMENT_LOCAL) { + sprintf(tmpstr, " %d@", (type - ARGUMENT_LOCAL)); + strcat(buf, tmpstr); + return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)]; + } + else if (type >= ARGUMENT_TIMER) { + sprintf(tmpstr, " TIMER%d@", (type - ARGUMENT_TIMER)); + strcat(buf, tmpstr); + return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; // why 8? + } + script_assert(false && "wrong type for variable"); + return nil; +} + +int CRunningScript::CollectParameterForDebug(char* buf, bool& var) +{ var = false; + int tmp; switch (CTheScripts::Read1ByteFromScript(&m_nIp)) { + case ARGUMENT_END: + return 0; // TODO(LCS) + case ARGUMENT_INT_ZERO: + return 0; + case ARGUMENT_FLOAT_ZERO: + return 0; + case ARGUMENT_FLOAT_1BYTE: + return (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 24; + case ARGUMENT_FLOAT_2BYTES: + return (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16; + case ARGUMENT_FLOAT_3BYTES: + tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 8; + tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16; + return tmp; case ARGUMENT_INT32: case ARGUMENT_FLOAT: return CTheScripts::Read4BytesFromScript(&m_nIp); - case ARGUMENT_GLOBALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace()); - var = true; - sprintf(tmpstr, " $%d", varIndex / 4); - strcat(buf, tmpstr); - return *((int32*)&CTheScripts::ScriptSpace[varIndex]); - case ARGUMENT_LOCALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables)); - var = true; - sprintf(tmpstr, " %d@", varIndex); - strcat(buf, tmpstr); - return m_anLocalVariables[varIndex]; case ARGUMENT_INT8: return CTheScripts::Read1ByteFromScript(&m_nIp); case ARGUMENT_INT16: return CTheScripts::Read2BytesFromScript(&m_nIp); default: - PrintToLog("%s - script assertion failed in CollectParameterForDebug", buf); - script_assert(0); - break; + var = true; + --m_nIp; + return *GetPointerToScriptVariableForDebug(this, &m_nIp, buf); } return 0; } void CRunningScript::GetStoredParameterForDebug(char* buf) { - uint16 varIndex; - char tmpstr[24]; - switch (CTheScripts::Read1ByteFromScript(&m_nIp)) { - case ARGUMENT_GLOBALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - sprintf(tmpstr, " $%d", varIndex / 4); - strcat(buf, tmpstr); - break; - case ARGUMENT_LOCALVAR: - varIndex = CTheScripts::Read2BytesFromScript(&m_nIp); - sprintf(tmpstr, " %d@", varIndex); - strcat(buf, tmpstr); - break; - default: - PrintToLog("%s - script_assertion failed in GetStoredParameterForDebug", buf); - script_assert(0); - } + GetPointerToScriptVariableForDebug(this, &m_nIp, buf); } void CTheScripts::LogAfterScriptInitializing() @@ -1641,17 +1856,41 @@ void CRunningScript::LogOnStartProcessing() void CRunningScript::LogBeforeProcessingCommand(int32 command) { storedIp = m_nIp; + uint8 nInputParams; + uint8 nOutputParameters; + uint8 nLocalsOffset; if (command < ARRAY_SIZE(commands)) { script_assert(commands[command].id == command); m_nIp -= 2; - sprintf(commandInfo, m_nIp >= SIZE_MAIN_SCRIPT ? "M<%5d> " : "<%6d> ", m_nIp >= SIZE_MAIN_SCRIPT ? m_nIp - SIZE_MAIN_SCRIPT : m_nIp); + sprintf(commandInfo, m_nIp >= CTheScripts::MainScriptSize ? "M<%5d> " : "<%6d> ", m_nIp >= CTheScripts::MainScriptSize ? m_nIp - CTheScripts::MainScriptSize : m_nIp); m_nIp += 2; if (m_bNotFlag) strcat(commandInfo, "NOT "); if (commands[command].position == -1) strcat(commandInfo, commands[command].name + sizeof("COMMAND_") - 1); + if (commands[command].input[0] == ARGTYPE_FUNCTION) { + char tmp[32]; + bool var = false; + nInputParams = CTheScripts::Read1ByteFromScript(&m_nIp); + nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); + nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp); + int value = CollectParameterForDebug(commandInfo, var); + sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); + strcat(commandInfo, tmp); + strcat(commandInfo, "{"); + for (int i = 0; i < nInputParams; i++) { + if (i != 0) + strcat(commandInfo, ", "); + value = CollectParameterForDebug(commandInfo, var); + sprintf(tmp, var ? "(%d)" : "%d", value); + strcat(commandInfo, tmp); + + } + strcat(commandInfo, "}"); + } + else { for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) { - char tmp[16]; + char tmp[32]; bool var = false; int value; switch (commands[command].input[i]) { @@ -1663,13 +1902,14 @@ void CRunningScript::LogBeforeProcessingCommand(int32 command) case ARGTYPE_STRING: sprintf(tmp, " '%s'", (const char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += KEY_LENGTH_IN_SCRIPT; break; case ARGTYPE_LABEL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); break; case ARGTYPE_BOOL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s)" : " %s", value ? "TRUE" : "FALSE"); break; - case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value + 1) % 10, value / 10 == 0 ? "AND" : "OR"); break; + case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value) % 10, value / 10 == 0 ? "AND" : "OR"); break; default: script_assert(0); } strcat(commandInfo, tmp); if (commands[command].position == i) strcat(commandInfo, commands[command].name_override); } + } uint32 t = m_nIp; m_nIp = storedIp; storedIp = t; @@ -1686,8 +1926,9 @@ void CRunningScript::LogAfterProcessingCommand(int32 command) uint32 t = m_nIp; m_nIp = storedIp; storedIp = t; + if (commands[command].input[0] != ARGTYPE_FUNCTION) { for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) { - char tmp[16]; + char tmp[32]; switch (commands[command].output[i]) { case ARGTYPE_INT: case ARGTYPE_PED_HANDLE: @@ -1697,6 +1938,7 @@ void CRunningScript::LogAfterProcessingCommand(int32 command) default: script_assert(0 && "Script only returns INTs and FLOATs"); } } + } m_nIp = storedIp; } PrintToLog("%s\n", commandInfo); @@ -1710,8 +1952,6 @@ void CRunningScript::LogAfterProcessingCommand(int32 command) } } -#endif - #ifdef MISSION_SWITCHER void CTheScripts::SwitchToMission(int32 mission) @@ -1745,21 +1985,19 @@ CTheScripts::SwitchToMission(int32 mission) #endif #endif CTimer::Suspend(); - int offset = CTheScripts::MultiScriptArray[mission]; -#ifdef USE_DEBUG_SCRIPT_LOADER - int handle = OpenScript(); -#else - CFileMgr::ChangeDir("\\"); - int handle = CFileMgr::OpenFile("data\\main.scm", "rb"); -#endif - CFileMgr::Seek(handle, offset, 0); - CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[SIZE_MAIN_SCRIPT], SIZE_MISSION_SCRIPT); - CFileMgr::CloseFile(handle); - CRunningScript* pMissionScript = CTheScripts::StartNewScript(SIZE_MAIN_SCRIPT); + int offset = CTheScripts::MultiScriptArray[mission] + 8; + int size = CTheScripts::MultiScriptArray[mission + 1] - CTheScripts::MultiScriptArray[mission]; + if (size <= 0) + size = CTheScripts::LargestMissionScriptSize; + CFileMgr::Seek(gScriptsFile, offset, 0); + CFileMgr::Read(gScriptsFile, (const char*)&CTheScripts::ScriptSpace[CTheScripts::MainScriptSize], size); + CRunningScript* pMissionScript = CTheScripts::StartNewScript(CTheScripts::MainScriptSize); CTimer::Resume(); pMissionScript->m_bIsMissionScript = true; pMissionScript->m_bMissionFlag = true; CTheScripts::bAlreadyRunningAMissionScript = true; + memset(&CTheScripts::ScriptSpace[CTheScripts::NumTrueGlobals * 4 + 8], 0, CTheScripts::MostGlobals * 4); CGameLogic::ClearShortCut(); + pMissionScript->Process(); } #endif diff --git a/src/control/TrafficLights.cpp b/src/control/TrafficLights.cpp index e484d3be..a3cba9b9 100644 --- a/src/control/TrafficLights.cpp +++ b/src/control/TrafficLights.cpp @@ -114,6 +114,32 @@ CTrafficLights::DisplayActualLight(CEntity *ent) CBrightLights::RegisterOne(pos1, ent->GetUp(), ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN); CBrightLights::RegisterOne(pos2, ent->GetUp(), -ent->GetRight(), CVector(0.0f, 0.0f, 0.0f), id + BRIGHTLIGHT_TRAFFIC_GREEN); + + // TODO(LCS): check coordinates + static const float top = -0.127f; + static const float bot = -0.539f; + static const float mid = bot + (top - bot) / 3.0f; + static const float left = 1.256f; + static const float right = 0.706f; + phase = CTrafficLights::LightForPeds(); + if (phase == PED_LIGHTS_DONT_WALK) { + CVector p0(2.7f, right, top); + CVector p1(2.7f, left, top); + CVector p2(2.7f, right, mid); + CVector p3(2.7f, left, mid); + CShinyTexts::RegisterOne(ent->GetMatrix() * p0, ent->GetMatrix() * p1, ent->GetMatrix() * p2, ent->GetMatrix() * p3, + 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, + SHINYTEXT_WALK, 255, 0, 0, 60.0f); + } + else if (phase == PED_LIGHTS_WALK || CTimer::GetTimeInMilliseconds() & 0x100) { + CVector p0(2.7f, right, mid); + CVector p1(2.7f, left, mid); + CVector p2(2.7f, right, bot); + CVector p3(2.7f, left, bot); + CShinyTexts::RegisterOne(ent->GetMatrix() * p0, ent->GetMatrix() * p1, ent->GetMatrix() * p2, ent->GetMatrix() * p3, + 1.0f, 0.5f, 0.0f, 0.5f, 1.0f, 1.0f, 0.0f, 1.0f, + SHINYTEXT_WALK, 255, 255, 255, 60.0f); + } } else if (MI_TRAFFICLIGHTS_VERTICAL == m) { CBaseModelInfo* mi = CModelInfo::GetModelInfo(ent->GetModelIndex()); |