summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/control')
-rw-r--r--src/control/Bridge.cpp20
-rw-r--r--src/control/Bridge.h4
-rw-r--r--src/control/CarAI.cpp13
-rw-r--r--src/control/CarCtrl.cpp343
-rw-r--r--src/control/CarCtrl.h14
-rw-r--r--src/control/GameLogic.cpp13
-rw-r--r--src/control/GameLogic.h1
-rw-r--r--src/control/Garages.cpp729
-rw-r--r--src/control/Garages.h69
-rw-r--r--src/control/PathFind.cpp6
-rw-r--r--src/control/Pickups.cpp18
-rw-r--r--src/control/Pickups.h3
-rw-r--r--src/control/Remote.cpp3
-rw-r--r--src/control/Remote.h2
-rw-r--r--src/control/Replay.cpp2
-rw-r--r--src/control/Replay.h4
-rw-r--r--src/control/Script.cpp1505
-rw-r--r--src/control/Script.h186
-rw-r--r--src/control/Script10.cpp421
-rw-r--r--src/control/Script2.cpp792
-rw-r--r--src/control/Script3.cpp1096
-rw-r--r--src/control/Script4.cpp858
-rw-r--r--src/control/Script5.cpp636
-rw-r--r--src/control/Script6.cpp777
-rw-r--r--src/control/Script7.cpp620
-rw-r--r--src/control/Script8.cpp615
-rw-r--r--src/control/Script9.cpp774
-rw-r--r--src/control/ScriptCommands.h256
-rw-r--r--src/control/TrafficLights.cpp26
29 files changed, 6409 insertions, 3397 deletions
diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp
index 1e63cf30..e7c76a9c 100644
--- a/src/control/Bridge.cpp
+++ b/src/control/Bridge.cpp
@@ -161,3 +161,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 8e79fee1..45652b23 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"
@@ -72,6 +73,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 8db6fd95..b11a23fb 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -11,6 +11,7 @@
#include "Cranes.h"
#include "Curves.h"
#include "CutsceneMgr.h"
+#include "Frontend.h"
#include "Gangs.h"
#include "Game.h"
#include "Garages.h"
@@ -77,10 +78,11 @@
#define DISTANCE_BETWEEN_CAR_AND_DEAD_PED (6.0f)
#define PROBABILITY_OF_PASSENGER_IN_VEHICLE (0.125f)
-#define ONSCREEN_DESPAWN_RANGE (120.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 ONSCREEN_DESPAWN_RANGE (190.0f)
+#define MINIMAL_DISTANCE_TO_SPAWN_ONSCREEN (130.0f)
+#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)
bool CCarCtrl::bMadDriversCheat;
@@ -94,7 +96,7 @@ int32 CCarCtrl::NumRandomCars;
int32 CCarCtrl::NumParkedCars;
int32 CCarCtrl::NumPermanentCars;
int8 CCarCtrl::CountDownToCarsAtStart;
-int32 CCarCtrl::MaxNumberOfCarsInUse = 12;
+int32 CCarCtrl::MaxNumberOfCarsInUse = 30;
uint32 CCarCtrl::LastTimeLawEnforcerCreated;
uint32 CCarCtrl::LastTimeFireTruckCreated;
uint32 CCarCtrl::LastTimeAmbulanceCreated;
@@ -109,6 +111,8 @@ int32 CCarCtrl::LoadedCarsArray[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
CVehicle* apCarsToKeep[MAX_CARS_TO_KEEP];
uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP];
+bool gbEmergencyVehiclesEnabled = true;
+
void
CCarCtrl::GenerateRandomCars()
{
@@ -158,14 +162,19 @@ CCarCtrl::GenerateOneRandomCar()
carClass = COPS;
carModel = ChoosePoliceCarModel();
}else{
- 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. */
- return;
+ 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 +194,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 +211,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 +319,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) {
@@ -596,12 +620,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() < 105.0f * requestMultiplier * TheCamera.GenerationDistMultiplier || bTopDownCamera) {
delete pVehicle;
return;
}
@@ -651,13 +675,13 @@ CCarCtrl::GenerateOneRandomCar()
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) {
@@ -716,12 +740,6 @@ CCarCtrl::GenerateOneRandomCar()
}
}
-bool
-CCarCtrl::BoatWithTallMast(int32 mi)
-{
- return mi == MI_RIO || mi == MI_TROPIC || mi == MI_MARQUIS;
-}
-
int32
CCarCtrl::ChooseBoatModel(int32 rating)
{
@@ -941,6 +959,7 @@ CCarCtrl::RemoveCarsIfThePoolGetsFull(void)
}
}
if (pClosestVehicle) {
+ debug(":::::::::::\'Nearest removed\' cause pools was full -> NumRandomCars %d\n", NumRandomCars);
CWorld::Remove(pClosestVehicle);
delete pClosestVehicle;
}
@@ -963,7 +982,10 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
return;
}
float distanceToPlayer = (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D();
- float threshold = OFFSCREEN_DESPAWN_RANGE;
+ float despawnMultiplier = 1.0f;
+ if (FindPlayerVehicle() && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON && !FrontEndMenuManager.m_PrefsUseWideScreen)
+ despawnMultiplier = 0.75f;
+ float threshold = OFFSCREEN_DESPAWN_RANGE * despawnMultiplier;
if (pVehicle->GetIsOnScreen() ||
TheCamera.Cams[TheCamera.ActiveCam].LookingLeft ||
TheCamera.Cams[TheCamera.ActiveCam].LookingRight ||
@@ -976,7 +998,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
pVehicle->bIsCarParkVehicle ||
CTimer::GetTimeInMilliseconds() < pVehicle->m_nSetPieceExtendedRangeTime
){
- threshold = ONSCREEN_DESPAWN_RANGE * TheCamera.GenerationDistMultiplier;
+ threshold = ONSCREEN_DESPAWN_RANGE * despawnMultiplier * TheCamera.GenerationDistMultiplier;
}
if (TheCamera.GetForward().z < -0.9f)
threshold = 70.0f;
@@ -1569,7 +1591,7 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float
if (pVehicle->AutoPilot.m_nCarMission == MISSION_RAMCAR_CLOSE && pOtherEntity == pVehicle->AutoPilot.m_pTargetCar)
return;
CVector2D vecDiff = pOtherCar->GetPosition() - pVehicle->GetPosition();
- float angleBetweenVehicles = CGeneral::GetATanOfXY(vecDiff.x, vecDiff.y);
+ float angleBetweenVehicles = GetATanOfXY(vecDiff.x, vecDiff.y);
float distance = vecDiff.Magnitude();
if (distance < 1.0f)
return;
@@ -1579,7 +1601,7 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float
return;
CVector2D forward = pVehicle->GetForward();
forward.Normalise();
- float forwardAngle = CGeneral::GetATanOfXY(forward.x, forward.y);
+ float forwardAngle = GetATanOfXY(forward.x, forward.y);
float angleDiff = angleBetweenVehicles - forwardAngle;
float lenProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.y * sin(angleDiff));
float widthProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.x * cos(angleDiff));
@@ -1588,16 +1610,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);
}
}
@@ -1629,23 +1647,19 @@ void CCarCtrl::WeaveForPed(CEntity* pOtherEntity, CVehicle* pVehicle, float* pAn
return;
CPed* pPed = (CPed*)pOtherEntity;
CVector2D vecDiff = pPed->GetPosition() - pVehicle->GetPosition();
- float angleBetweenVehicleAndPed = CGeneral::GetATanOfXY(vecDiff.x, vecDiff.y);
+ float angleBetweenVehicleAndPed = GetATanOfXY(vecDiff.x, vecDiff.y);
float distance = vecDiff.Magnitude();
float lengthToEvade = (WIDTH_COEF_TO_WEAVE_SAFELY * 2 * pVehicle->GetColModel()->boundingBox.max.x + PED_WIDTH_TO_WEAVE) / distance;
float diffToLeftAngle = LimitRadianAngle(angleBetweenVehicleAndPed - *pAngleToWeaveLeft);
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);
}
}
@@ -1701,23 +1715,19 @@ void CCarCtrl::WeaveForObject(CEntity* pOtherEntity, CVehicle* pVehicle, float*
rightCoef * pObject->GetRight() +
forwardCoef * pObject->GetForward() -
pVehicle->GetPosition();
- float angleBetweenVehicleAndObject = CGeneral::GetATanOfXY(vecDiff.x, vecDiff.y);
+ float angleBetweenVehicleAndObject = GetATanOfXY(vecDiff.x, vecDiff.y);
float distance = vecDiff.Magnitude();
float lengthToEvade = (WIDTH_COEF_TO_WEAVE_SAFELY * 2 * pVehicle->GetColModel()->boundingBox.max.x + OBJECT_WIDTH_TO_WEAVE) / distance;
float diffToLeftAngle = LimitRadianAngle(angleBetweenVehicleAndObject - *pAngleToWeaveLeft);
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);
}
}
@@ -1759,7 +1769,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;
@@ -1845,13 +1855,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]];
@@ -1964,7 +1976,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 +1996,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
int nextLink;
if (numNodes != 1 && numNodes != 2 || pTargetNode[0] == pCurNode){
if (numNodes != 2 || pTargetNode[1] == pCurNode) {
- float currentAngle = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
+ float currentAngle = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
nextLink = 0;
float lowestAngleChange = 10.0f;
int numLinks = pCurNode->numLinks;
@@ -1994,7 +2006,7 @@ void CCarCtrl::PickNextNodeToChaseCar(CVehicle* pVehicle, float targetX, float t
if (conNode == prevNode && i > 1)
continue;
CPathNode* pTestNode = &ThePaths.m_pathNodes[conNode];
- float angle = CGeneral::GetATanOfXY(pTestNode->GetX() - pCurNode->GetX(), pTestNode->GetY() - pCurNode->GetY());
+ float angle = GetATanOfXY(pTestNode->GetX() - pCurNode->GetX(), pTestNode->GetY() - pCurNode->GetY());
angle = LimitRadianAngle(angle - currentAngle);
angle = ABS(angle);
if (angle < lowestAngleChange) {
@@ -2412,6 +2424,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:
@@ -2482,11 +2504,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,
@@ -2495,6 +2525,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,
@@ -2572,8 +2605,8 @@ void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CVehicle* pVehicle, float
{
CVector2D forward = pVehicle->GetForward();
forward.Normalise();
- float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
- float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
+ float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
+ float angleForward = GetATanOfXY(forward.x, forward.y);
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
steerAngle = clamp(steerAngle, -DEFAULT_MAX_STEER_ANGLE, DEFAULT_MAX_STEER_ANGLE);
#ifdef FIX_BUGS
@@ -2604,8 +2637,8 @@ void CCarCtrl::SteerAIBoatWithPhysicsAttackingPlayer(CVehicle* pVehicle, float*
CVector2D forward = pVehicle->GetForward();
forward.Normalise();
CVector2D vecToProjection = FindPlayerCoors() + FindPlayerSpeed() * projection * GAME_SPEED_TO_CARAI_SPEED;
- float angleToTarget = CGeneral::GetATanOfXY(vecToProjection.x - pVehicle->GetPosition().x, vecToProjection.y - pVehicle->GetPosition().y);
- float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
+ float angleToTarget = GetATanOfXY(vecToProjection.x - pVehicle->GetPosition().x, vecToProjection.y - pVehicle->GetPosition().y);
+ float angleForward = GetATanOfXY(forward.x, forward.y);
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
#ifdef FIX_BUGS
float speedTarget = pVehicle->AutoPilot.GetCruiseSpeed();
@@ -2693,7 +2726,7 @@ void CCarCtrl::SteerAIHeliTowardsTargetCoors(CAutomobile* pHeli)
if (distanceToTarget < 8.0f && pHeli->m_fHeliOrientation < 0.0f)
ZTurnSpeedTarget = 0.0f;
else {
- float fAngleTarget = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y) + PI;
+ float fAngleTarget = GetATanOfXY(vecToTarget.x, vecToTarget.y) + PI;
if (pHeli->m_fHeliOrientation >= 0.0f)
fAngleTarget = pHeli->m_fHeliOrientation;
fAngleTarget -= pHeli->m_fOrientation;
@@ -2736,7 +2769,7 @@ void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane)
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
- float angle = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y);
+ float angle = GetATanOfXY(vecToTarget.x, vecToTarget.y);
while (angle > TWOPI)
angle -= TWOPI;
float difference = LimitRadianAngle(angle - pPlane->m_fOrientation);
@@ -2833,8 +2866,8 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
projectedPosition.y = positionOnCurrentLinkIncludingLane.y;
}
CVector2D distanceToProjectedPosition = projectedPosition - pVehicle->GetPosition();
- float angleCurrentLink = CGeneral::GetATanOfXY(distanceToProjectedPosition.x, distanceToProjectedPosition.y);
- float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
+ float angleCurrentLink = GetATanOfXY(distanceToProjectedPosition.x, distanceToProjectedPosition.y);
+ float angleForward = GetATanOfXY(forward.x, forward.y);
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
angleCurrentLink = FindAngleToWeaveThroughTraffic(pVehicle, nil, angleCurrentLink, angleForward);
float steerAngle = LimitRadianAngle(angleCurrentLink - angleForward);
@@ -2879,11 +2912,11 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
pCurrentLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurrentLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForward.x);
trajectory -= pVehicle->GetPosition();
float speedAngleMultiplier = FindSpeedMultiplier(
- CGeneral::GetATanOfXY(trajectory.x, trajectory.y) - angleForward,
+ GetATanOfXY(trajectory.x, trajectory.y) - angleForward,
MIN_ANGLE_FOR_SPEED_LIMITING, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
float tmpWideMultiplier = FindSpeedMultiplier(
- CGeneral::GetATanOfXY(currentPathLinkForward.x, currentPathLinkForward.y) -
- CGeneral::GetATanOfXY(nextPathLinkForwardX, nextPathLinkForwardY),
+ GetATanOfXY(currentPathLinkForward.x, currentPathLinkForward.y) -
+ GetATanOfXY(nextPathLinkForwardX, nextPathLinkForwardY),
MIN_ANGLE_FOR_SPEED_LIMITING_BETWEEN_NODES, MAX_ANGLE_FOR_SPEED_LIMITING, MIN_LOWERING_SPEED_COEFFICIENT);
float speedNodesMultiplier;
if (scalarDistanceToNextNode > DISTANCE_TO_NEXT_NODE_TO_CONSIDER_SLOWING_DOWN || pVehicle->AutoPilot.m_nCruiseSpeed < 12)
@@ -2917,8 +2950,8 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
*pHandbrake = false;
CVector2D forward = pVehicle->GetForward();
forward.Normalise();
- float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
- float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
+ float angleToTarget = GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
+ float angleForward = GetATanOfXY(forward.x, forward.y);
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
angleToTarget = FindAngleToWeaveThroughTraffic(pVehicle, pTarget, angleToTarget, angleForward);
float steerAngle = LimitRadianAngle(angleToTarget - angleForward);
@@ -3124,7 +3157,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++)
@@ -3166,10 +3199,12 @@ void CCarCtrl::GenerateEmergencyServicesCar(void)
return;
if (CGame::IsInInterior())
return;
+ if (TheCamera.m_WideScreenOn) // TODO(LCS): verify
+ return;
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);
@@ -3189,7 +3224,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);
@@ -3353,6 +3388,17 @@ 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)
+{
+ return true;
+}
+
float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type)
{
switch (type)
@@ -3362,3 +3408,8 @@ float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type)
}
return 1.0f;
}
+
+void CCarCtrl::RenderDebugInfo(CVehicle*)
+{
+ //TODO(LCS)
+}
diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h
index 5efbe275..edf1f41e 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
@@ -130,6 +131,10 @@ 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 float GetATanOfXY(float x, float y) { float t = CGeneral::GetATanOfXY(x, y); if (t < 0.0f) t += TWOPI; return t; }
+
static float GetPositionAlongCurrentCurve(CVehicle* pVehicle)
{
uint32 timeInCurve = CTimer::GetTimeInMilliseconds() - pVehicle->AutoPilot.m_nTimeEnteredCurve;
@@ -138,11 +143,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;
@@ -171,4 +172,5 @@ public:
static int32 LoadedCarsArray[TOTAL_CUSTOM_CLASSES][MAX_CAR_MODELS_IN_ARRAY];
};
-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/GameLogic.cpp b/src/control/GameLogic.cpp
index 33c40c91..e238a8b3 100644
--- a/src/control/GameLogic.cpp
+++ b/src/control/GameLogic.cpp
@@ -45,6 +45,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)
@@ -88,7 +89,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();
@@ -391,7 +392,7 @@ CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed *pPlayerPed, CVector
CWorld::Add(pPlayerPed);
CHud::ResetWastedText();
CStreaming::StreamZoneModels(pos);
- clearWaterDrop = true;
+ //clearWaterDrop = true;
}
void
@@ -418,7 +419,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
@@ -450,11 +451,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 7cf58d03..c0eac806 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"
@@ -43,7 +46,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)
@@ -100,10 +103,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 };
@@ -127,6 +130,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;
@@ -137,6 +141,7 @@ void CGarages::Init(void)
#ifndef MASTER
VarConsole.Add("Print nearest object", &bPrintNearestObject, true);
#endif
+ CrusherRewardMultiplier = 1;
CrushedCarId = -1;
NumGarages = 0;
MessageEndTime = 0;
@@ -217,7 +222,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);
@@ -235,6 +240,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;
@@ -249,12 +270,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:
@@ -263,7 +278,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:
@@ -290,6 +304,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;
@@ -304,7 +319,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)
@@ -315,8 +339,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:
@@ -354,7 +397,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)
@@ -438,7 +481,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,
@@ -446,6 +492,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);
@@ -480,11 +527,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);
@@ -497,12 +541,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]);
}
}
}
@@ -512,8 +580,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())
@@ -538,6 +609,8 @@ void CGarage::Update()
UpdateDoorsHeight();
break;
case GS_OPENEDCONTAINSCAR:
+ if (FindPlayerVehicle())
+ FindPlayerVehicle()->m_bGarageTurnedLightsOff = false;
if (IsPlayerOutsideGarage())
m_eGarageState = GS_OPENED;
break;
@@ -550,9 +623,20 @@ 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()->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE) {
+ CGarages::TriggerMessage("GA_22", -1, 4000, -1);
+ m_eGarageState = GS_OPENEDCONTAINSCAR;
+ DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB_ALREADY_SET, 1);
+ break;
+ }
if (!FindPlayerVehicle() || FindPlayerVehicle()->m_bombType) {
CGarages::TriggerMessage("GA_5", -1, 4000, -1); //"Your car is already fitted with a bomb"
m_eGarageState = GS_OPENEDCONTAINSCAR;
@@ -579,6 +663,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);
@@ -595,13 +681,25 @@ 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)
+#if (!defined GTA_PS2 || defined FIX_BUGS) // <- this remained in CAutomobile in LCS
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
((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;
+ }
+ }
+ }
if (m_eGarageType == GARAGE_BOMBSHOP3)
CGarages::GivePlayerDetonator();
CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
@@ -640,6 +738,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;
}
@@ -657,6 +756,8 @@ void CGarage::Update()
UpdateDoorsHeight();
break;
case GS_OPENEDCONTAINSCAR:
+ if (FindPlayerVehicle())
+ FindPlayerVehicle()->m_bGarageTurnedLightsOff = false;
if (IsPlayerOutsideGarage())
m_eGarageState = GS_OPENED;
break;
@@ -670,16 +771,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;
@@ -691,7 +788,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;
@@ -787,22 +888,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;
@@ -838,6 +938,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;
@@ -858,8 +959,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) {
@@ -1017,7 +1279,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()) {
@@ -1209,8 +1474,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;
}
@@ -1224,12 +1496,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;
@@ -1400,23 +1683,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);
@@ -1437,6 +1717,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:
@@ -1444,9 +1725,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;
@@ -1503,6 +1781,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;
@@ -1516,6 +1795,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)
@@ -1581,6 +1861,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;
@@ -1626,7 +1907,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)
@@ -1646,8 +1928,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;
}
@@ -1656,9 +1939,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;
@@ -1666,24 +1950,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;
}
@@ -1751,15 +2032,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)
@@ -1778,8 +2061,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;
@@ -1836,25 +2138,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_fPosY = 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_bBulletproof = pVehicle->bBulletProof;
- m_bFireproof = pVehicle->bFireProof;
- m_bExplosionproof = pVehicle->bExplosionProof;
- m_bCollisionproof = pVehicle->bCollisionProof;
- m_bMeleeproof = pVehicle->bMeleeProof;
- if (pVehicle->IsCar() || pVehicle->IsBike())
- m_nCarBombType = ((CAutomobile*)pVehicle)->m_bombType; // NB: cast to CAutomobile is original behaviour
+ 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->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
@@ -1867,19 +2192,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;
@@ -1896,11 +2221,36 @@ CVehicle* CStoredCar::RestoreCar()
}
pVehicle->bHasBeenOwnedByPlayer = true;
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
- pVehicle->bBulletProof = m_bBulletproof;
- pVehicle->bFireProof = m_bFireproof;
- pVehicle->bExplosionProof = m_bExplosionproof;
- pVehicle->bCollisionProof = m_bCollisionproof;
- pVehicle->bMeleeProof = m_bMeleeproof;
+ 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;
}
@@ -1915,13 +2265,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?
@@ -2072,7 +2432,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:
@@ -2262,7 +2622,7 @@ void CGarages::SetAllDoorsBackToOriginalHeight()
void CGarages::Save(uint8 * buf, uint32 * size)
{
//INITSAVEBUF
- *size = 7876; // for some reason it's not actual size again
+ *size = 10692; // 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));
CloseHideOutGaragesBeforeSave();
WriteSaveBuf(buf, NumGarages);
@@ -2284,29 +2644,10 @@ void CGarages::Save(uint8 * buf, uint32 * size)
//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_bBulletproof = other.m_bBulletproof;
- m_bFireproof = other.m_bFireproof;
- m_bExplosionproof = other.m_bExplosionproof;
- m_bCollisionproof = other.m_bCollisionproof;
- m_bMeleeproof = other.m_bMeleeproof;
- 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;
-}
-
void CGarages::Load(uint8* buf, uint32 size)
{
//INITSAVEBUF
- assert(size = 7876);
+ assert(size == 10692);
//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)));
CloseHideOutGaragesBeforeSave();
NumGarages = ReadSaveBuf<uint32>(buf);
@@ -2345,7 +2686,24 @@ void CGarages::Load(uint8* buf, uint32 size)
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 ||
@@ -2367,7 +2725,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)
@@ -2407,3 +2766,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 07d5f712..2ab74606 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,19 +59,34 @@ enum
{
TOTAL_COLLECTCARS_GARAGES = 4,
TOTAL_HIDEOUT_GARAGES = 12,
- TOTAL_COLLECTCARS_CARS = 6
+ TOTAL_COLLECTCARS_CARS = 16
};
class CStoredCar
{
+ enum {
+ FLAG_BULLETPROOF = 0x1,
+ FLAG_FIREPROOF = 0x2,
+ 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;
- int32 m_bBulletproof : 1;
- int32 m_bFireproof : 1;
- int32 m_bExplosionproof : 1;
- int32 m_bCollisionproof : 1;
- int32 m_bMeleeproof : 1;
+ 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;
int8 m_nRadioStation;
@@ -81,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();
};
@@ -115,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;
@@ -133,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();
@@ -219,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
@@ -266,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;
@@ -297,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/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 0428ddae..6d0aa415 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -1683,4 +1683,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 cd612d5d..61345785 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 cb208912..1bf94156 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -11,6 +11,7 @@
#include "CivilianPed.h"
#include "Clock.h"
#include "CopPed.h"
+#include "Coronas.h"
#include "Debug.h"
#include "DMAudio.h"
#include "EmergencyPed.h"
@@ -49,16 +50,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,10 +98,19 @@ 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;
+short* 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
@@ -354,6 +367,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, ""),
@@ -408,7 +426,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, ""),
@@ -1216,7 +1234,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, ""),
@@ -1304,7 +1322,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, ""),
@@ -1576,39 +1594,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_ENABLED, INPUT_ARGUMENTS(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
@@ -1681,6 +1882,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();
@@ -1750,46 +1968,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;
}
}
}
@@ -1801,6 +2073,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();
@@ -1808,20 +2082,19 @@ 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);
+ if (CHud::m_ItemToFlash != ITEM_ARMOUR && CHud::m_ItemToFlash != ITEM_HEALTH)
+ CHud::m_ItemToFlash = -1;
+ 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);
@@ -1829,10 +2102,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(0);
CVehicle::bDisableRemoteDetonation = false;
CVehicle::bDisableRemoteDetonationOnContact = false;
- CGameLogic::ClearShortCut();
CTheScripts::RiotIntensity = 0;
CTheScripts::StoreVehicleIndex = -1;
CTheScripts::StoreVehicleWasRandom = true;
@@ -1868,6 +2142,10 @@ void CMissionCleanup::Process()
}
RemoveEntityFromList(m_sEntities[i].id, m_sEntities[i].type);
}
+ for (int i = 1; i < NUMSTREAMINFO; i++) {
+ if (CStreaming::IsScriptOwnedModel(i))
+ CStreaming::SetMissionDoesntRequireModel(i);
+ }
#ifdef SECUROM
if ((myrand() & 3) == 2){
// if pirated game
@@ -1896,7 +2174,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;
@@ -2035,109 +2313,157 @@ 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_FLOAT_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_1BYTE:
+ *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24;
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_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++;
}
}
#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);
}
#endif
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:
@@ -2145,7 +2471,8 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
case ARGUMENT_FLOAT:
return CTheScripts::Read4BytesFromScript(pIp);
default:
- script_assert(0);
+ (*pIp)--;
+ return *GetPointerToScriptVariable(pIp, 0);
}
return -1;
}
@@ -2153,38 +2480,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++)
@@ -2195,13 +2545,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
@@ -2224,17 +2589,17 @@ int open_script()
#endif
switch (scriptToLoad) {
case 0: scriptfile = "main.scm"; break;
- case 1: scriptfile = "freeroam_miami.scm"; break;
+ case 1: scriptfile = "freeroam_lcs.scm"; break;
case 2: scriptfile = "main_d.scm"; break;
}
return CFileMgr::OpenFile(scriptfile, "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();
@@ -2243,25 +2608,47 @@ void CTheScripts::Init()
MissionCleanUp.Init();
UpsideDownCars.Init();
StuckCars.Init();
- CFileMgr::SetDir("data");
-#ifdef USE_DEBUG_SCRIPT_LOADER
- int mainf = open_script();
-#else
- 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();
+ CFileMgr::SetDir("DATA");
+#ifdef USE_DEBUG_SCRIPT_LOADER
+ int mainf = open_script();
+#else
+ 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;
@@ -2271,11 +2658,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;
@@ -2299,7 +2685,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;
@@ -2307,6 +2693,12 @@ void CTheScripts::Init()
}
for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++)
InvisibilitySettingArray[i] = nil;
+ if (loaddata) {
+ printf("loaddata = true\n");
+ //retval = GenericLoad(); // TODO
+ }
+ for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++)
+ AllowedCollision[i] = 0;
#if defined USE_ADVANCED_SCRIPT_DEBUG_OUTPUT && SCRIPT_LOG_FILE_LEVEL == 2
CFileMgr::SetDirMyDocuments();
@@ -2317,8 +2709,10 @@ void CTheScripts::Init()
PrintToLog(init_msg);
CFileMgr::SetDir("");
#endif
+ return retval;
}
+/*
void CTheScripts::RemoveScriptTextureDictionary()
{
for (int i = 0; i < ARRAY_SIZE(CTheScripts::ScriptSprites); i++)
@@ -2327,6 +2721,7 @@ void CTheScripts::RemoveScriptTextureDictionary()
if (slot != -1)
CTxdStore::RemoveTxd(slot);
}
+*/
void CRunningScript::RemoveScriptFromList(CRunningScript** ppScript)
{
@@ -2352,6 +2747,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);
@@ -2363,6 +2759,8 @@ void CTheScripts::Process()
{
if (CReplay::IsPlayingBack())
return;
+ if (!ScriptSpace)
+ return;
CommandsExecuted = 0;
ScriptsUpdated = 0;
float timeStep = CTimer::GetTimeStepInMilliseconds();
@@ -2434,6 +2832,7 @@ void CTheScripts::Process()
#endif
CRunningScript* script = pActiveScripts;
+ InTheScripts = true;
while (script != nil){
CRunningScript* next = script->GetNext();
++ScriptsUpdated;
@@ -2443,6 +2842,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
PrintToLog("Script processing done, ScriptsUpdated: %d, CommandsExecuted: %d\n", ScriptsUpdated, CommandsExecuted);
@@ -2468,6 +2872,7 @@ void CRunningScript::Process()
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
PrintToLog("\n\nProcessing script %s (id %d)\n\n", m_abScriptName, this - CTheScripts::ScriptsArray);
#endif
+ pCurrent = this;
if (m_bIsMissionScript)
DoDeatharrestCheck();
if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1)
@@ -2500,34 +2905,59 @@ int8 CRunningScript::ProcessOneCommand()
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
char commandInfo[1024];
uint32 ip = 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);
- for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) {
+ if (commands[command].input[0] == ARGTYPE_FUNCTION) {
char tmp[32];
bool var = false;
- int value;
- switch (commands[command].input[i]) {
- case ARGTYPE_INT:
- case ARGTYPE_PED_HANDLE:
- case ARGTYPE_VEHICLE_HANDLE:
- case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break;
- case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break;
- 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;
- default: script_assert(0);
- }
+ 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);
- if (commands[command].position == i)
- strcat(commandInfo, commands[command].name_override);
+ 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[32];
+ bool var = false;
+ int value;
+ switch (commands[command].input[i]) {
+ case ARGTYPE_INT:
+ case ARGTYPE_PED_HANDLE:
+ case ARGTYPE_VEHICLE_HANDLE:
+ case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break;
+ case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break;
+ 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) % 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 = ip;
@@ -2538,32 +2968,38 @@ 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_ADVANCED_SCRIPT_DEBUG_OUTPUT
if (command < ARRAY_SIZE(commands)) {
if (commands[command].cond || commands[command].output[0] != ARGTYPE_NONE) {
@@ -2573,15 +3009,17 @@ int8 CRunningScript::ProcessOneCommand()
uint32 t = m_nIp;
m_nIp = ip;
ip = t;
- for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) {
- char tmp[32];
- switch (commands[command].output[i]) {
- case ARGTYPE_INT:
- case ARGTYPE_PED_HANDLE:
- case ARGTYPE_VEHICLE_HANDLE:
- case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break;
- case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break;
- default: script_assert(0 && "Script only returns INTs and FLOATs");
+ if (commands[command].input[0] != ARGTYPE_FUNCTION) {
+ for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) {
+ char tmp[32];
+ switch (commands[command].output[i]) {
+ case ARGTYPE_INT:
+ case ARGTYPE_PED_HANDLE:
+ case ARGTYPE_VEHICLE_HANDLE:
+ case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break;
+ case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break;
+ default: script_assert(0 && "Script only returns INTs and FLOATs");
+ }
}
}
m_nIp = ip;
@@ -2610,16 +3048,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 */
@@ -2628,174 +3068,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:
@@ -2830,28 +3270,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:
@@ -2886,28 +3326,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:
@@ -2942,28 +3382,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:
@@ -2998,14 +3438,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:
@@ -3038,14 +3478,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:
@@ -3074,17 +3514,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:
@@ -3110,47 +3548,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);
@@ -3159,7 +3569,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)) {
@@ -3169,14 +3579,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;
}
@@ -3184,23 +3594,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);
@@ -3248,39 +3658,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:
@@ -3427,33 +3841,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;
@@ -3465,33 +3871,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;
@@ -3640,46 +4038,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;
@@ -3691,29 +4089,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);
@@ -3728,19 +4126,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;
@@ -3750,7 +4148,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);
@@ -3759,7 +4157,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;
@@ -3772,21 +4170,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
@@ -3809,72 +4207,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();
@@ -3893,13 +4293,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();
@@ -3914,14 +4314,14 @@ 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);
if (m_bIsMissionScript)
CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR);
@@ -3930,25 +4330,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
@@ -3956,13 +4357,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;
@@ -3974,7 +4376,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;
@@ -3982,18 +4384,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();
@@ -4039,80 +4441,84 @@ 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);
#if defined MISSION_REPLAY && defined SIMPLIER_MISSIONS
- car->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1];
+ car->AutoPilot.m_nCruiseSpeed = GET_FLOAT_PARAM(1);
if (missionRetryScriptIndex == 40 && car->GetModelIndex() == MI_CHEETAH) // Turismo
car->AutoPilot.m_nCruiseSpeed = 8 * car->AutoPilot.m_nCruiseSpeed / 10;
car->AutoPilot.m_nCruiseSpeed = Min(car->AutoPilot.m_nCruiseSpeed, 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity);
#else
- 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);
#endif
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:
@@ -4133,56 +4539,54 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
AllowMissionReplay = 1;
#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:
@@ -4191,14 +4595,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);
@@ -4225,18 +4629,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");
}
@@ -4244,7 +4651,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;
}
@@ -4258,7 +4665,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) {
@@ -4303,14 +4710,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
@@ -4354,15 +4761,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;
@@ -4370,51 +4777,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;
}
@@ -4474,10 +4881,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();
@@ -4485,73 +4892,72 @@ 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]);
+ 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);
@@ -4560,51 +4966,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();
@@ -4617,7 +5026,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);
@@ -4630,15 +5039,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;
}
//case COMMAND_ORDER_CHAR_TO_BACKDOOR:
@@ -4646,7 +5055,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;
@@ -4658,43 +5067,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;
@@ -4704,7 +5113,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);
@@ -4719,17 +5127,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){
@@ -4772,6 +5181,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()
@@ -4842,23 +5269,19 @@ CTheScripts::SwitchToMission(int32 mission)
CStats::LastMissionPassedName[0] = '\0';
#endif
CTimer::Suspend();
- int offset = CTheScripts::MultiScriptArray[mission];
-#ifdef USE_DEBUG_SCRIPT_LOADER
- CFileMgr::ChangeDir("\\data\\");
- int handle = CFileMgr::OpenFile(scriptfile, "rb");
- CFileMgr::ChangeDir("\\");
-#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/Script.h b/src/control/Script.h
index 80c05363..8b54f28f 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
@@ -47,7 +49,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 +225,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 +275,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 +311,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 +349,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 +361,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 +409,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*);
@@ -378,9 +450,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);
-
};
@@ -390,37 +463,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];
@@ -452,20 +518,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 short* 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();
@@ -475,11 +545,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; }
@@ -535,10 +607,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);
@@ -547,7 +621,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);
@@ -556,6 +630,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()
{
@@ -575,8 +653,14 @@ public:
static void SetObjectiveForAllPedsInCollective(int, eObjective);
#endif
+ static bool IsFortStauntonDestroyed() { return FSDestroyedFlag && *(int32*)&ScriptSpace[FSDestroyedFlag] == 1; }
+
};
+extern int ScriptParams[32];
+
+VALIDATE_SIZE(uStackReturnValue, 4);
+
#ifdef USE_DEBUG_SCRIPT_LOADER
extern int scriptToLoad;
#endif
@@ -599,3 +683,7 @@ void RetryMission(int, int);
#ifdef USE_DEBUG_SCRIPT_LOADER
extern int scriptToLoad;
#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..ac3961a7
--- /dev/null
+++ b/src/control/Script10.cpp
@@ -0,0 +1,421 @@
+#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)));
+ 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:
+ UpdateCompareFlag(gDeveloperFlag);
+ 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_PARAMS(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); // TODO - second set of data
+ 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(0), GET_INTEGER_PARAM(1) >= 0 ? (void*)GET_INTEGER_PARAM(0) : 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_str1, 0); // TODO - second set of data
+ 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 656973ca..e4c71403 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);
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 acd3988f..64014ac8 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,39 +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);
- 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;
@@ -163,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();
@@ -181,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();
@@ -199,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();
@@ -217,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);
@@ -231,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;
}
@@ -295,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;
}
@@ -312,34 +314,34 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
{
CollectParameters(&m_nIp, 2);
CVehicle* pTarget;
- if (ScriptParams[1] >= 0) {
- pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ if (GET_INTEGER_PARAM(1) >= 0) {
+ pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pTarget);
}
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) {
@@ -360,43 +362,43 @@ 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]);
+ CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pCar);
script_assert(pCar->m_vehType == VEHICLE_TYPE_CAR);
UpdateCompareFlag(pCar->m_bombType != 0); //TODO: enum
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();
@@ -404,86 +406,84 @@ 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]);
+ CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pCar);
script_assert(pCar->m_vehType == VEHICLE_TYPE_CAR);
- UpdateCompareFlag(pCar->m_bombType == ScriptParams[1]);
+ UpdateCompareFlag(pCar->m_bombType == GET_INTEGER_PARAM(1));
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;
@@ -491,23 +491,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;
@@ -515,20 +515,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);
@@ -537,9 +537,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);
@@ -548,7 +548,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;
@@ -559,7 +559,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;
@@ -570,7 +570,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:
@@ -578,33 +578,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;
@@ -619,11 +619,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);
@@ -633,9 +633,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;
@@ -647,9 +647,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;
@@ -666,110 +666,115 @@ 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];
+ ((CAutomobile*)pVehicle)->m_bombType = GET_INTEGER_PARAM(1);
((CAutomobile*)pVehicle)->m_pBombRigger = FindPlayerPed();
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);
@@ -778,7 +783,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
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;
}
@@ -787,80 +792,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:
@@ -875,134 +885,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;
}
/*
@@ -1013,31 +1023,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;
}
/*
@@ -1047,66 +1057,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;
}
@@ -1175,7 +1185,7 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
total++;
}
}
- ScriptParams[0] = total;
+ SET_INTEGER_PARAM(0, total);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -1183,72 +1193,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); // TODO
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{
@@ -1260,10 +1275,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);
@@ -1275,37 +1290,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;
@@ -1316,105 +1331,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: 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;
}
@@ -1422,67 +1439,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:
@@ -1502,16 +1519,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:
@@ -1526,54 +1543,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
@@ -1581,19 +1599,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:
@@ -1602,14 +1621,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:
@@ -1619,7 +1638,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;
@@ -1627,7 +1646,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;
@@ -1635,67 +1654,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;
@@ -1709,7 +1726,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;
@@ -1722,49 +1739,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;
}
/*
@@ -1774,7 +1795,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);
@@ -1784,23 +1805,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);
@@ -1816,9 +1836,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;
@@ -1836,11 +1856,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];
@@ -1869,7 +1888,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;
@@ -1891,14 +1910,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;
@@ -1906,7 +1925,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;
@@ -1914,7 +1933,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;
@@ -1922,28 +1941,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))); // MI_MONEY -> gpModelIndices[...]
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 = 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;
}
@@ -1951,15 +1970,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
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;
}
@@ -1967,7 +1988,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;
@@ -1975,16 +1996,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();
+ printf("clear cutscene\n");
CCutsceneMgr::DeleteCutsceneData();
return 0;
case COMMAND_RESTORE_CAMERA_JUMPCUT:
@@ -1993,37 +2021,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)
@@ -2033,23 +2061,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)
@@ -2059,7 +2087,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);
@@ -2068,7 +2096,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);
@@ -2078,9 +2106,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:
@@ -2090,7 +2118,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;
}
@@ -2098,102 +2126,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;
}
*/
@@ -2201,7 +2225,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;
}
/*
@@ -2209,35 +2233,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;
}
*/
@@ -2245,7 +2269,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;
}
/*
@@ -2253,71 +2277,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;
@@ -2337,9 +2359,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:
@@ -2349,32 +2371,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;
@@ -2382,15 +2404,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;
@@ -2398,8 +2420,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 878278c5..4f443ad2 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){
@@ -848,11 +843,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 +865,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 +892,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 +1007,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 +1041,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 +1053,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 +1074,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 +1082,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 +1091,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 +1100,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 +1110,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 +1120,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 +1152,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 +1203,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 +1216,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 +1227,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 +1239,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 +1251,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 +1300,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 +1323,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 +1338,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 +1360,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 +1384,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 +1396,127 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
{
CollectParameters(&m_nIp, 1);
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
- DMAudio.PlayFrontEndTrack(ScriptParams[0] + STREAMED_SOUND_MISSION_COMPLETED - 1, 0);
+ DMAudio.PlayFrontEndTrack(GET_INTEGER_PARAM(0) + STREAMED_SOUND_MISSION_COMPLETED - 1, 0);
+ //DMAudio.SaveAnnouncementsWhenMissionPassedPlayed(); // TODO!
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));
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){
+ if (type == POBJECT_SMOKE_TRAIL){ // 17 in LCS -- assuming enum is the same
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 +1524,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 +1550,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 +1569,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 +1614,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 +1641,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 +1660,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 +1668,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 +1717,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 +1731,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);
return 0;
}
case COMMAND_CREATE_RANDOM_CAR_FOR_CAR_PARK:
@@ -1821,6 +1790,8 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
continue;
if (CModelInfo::IsCarModel(model) || CModelInfo::IsBikeModel(model)) {
switch (model) {
+ // TODO(LCS): do it right
+ // apparently leeds didn't :lmao:
case MI_LANDSTAL:
case MI_LINERUN:
case MI_RIO:
@@ -1846,13 +1817,13 @@ 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_ROMERO:
+ //case MI_PACKER:
+ //case MI_SENTXS:
case MI_SQUALO:
case MI_SEASPAR:
case MI_PIZZABOY:
- case MI_GANGBUR:
+ //case MI_GANGBUR:
case MI_AIRTRAIN:
case MI_DEADDODO:
case MI_SPEEDER:
@@ -1861,44 +1832,44 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
case MI_FLATBED:
case MI_YANKEE:
case MI_CADDY:
- case MI_ZEBRA:
+ //case MI_ZEBRA:
case MI_TOPFUN:
case MI_SKIMMER:
case MI_RCBARON:
case MI_RCRAIDER:
case MI_SPARROW:
case MI_PATRIOT:
- case MI_LOVEFIST:
+ //case MI_LOVEFIST:
case MI_COASTG:
case MI_DINGHY:
- case MI_HERMES:
- case MI_SABRETUR:
+ //case MI_HERMES:
+ //case MI_SABRETUR:
case MI_PHEONIX:
- case MI_WALTON:
+ //case MI_WALTON:
case MI_COMET:
- case MI_DELUXO:
- case MI_BURRITO:
- case MI_SPAND:
+ //case MI_DELUXO:
+ //case MI_BURRITO:
+ //case MI_SPAND:
case MI_MARQUIS:
case MI_BAGGAGE:
- case MI_KAUFMAN:
+ //case MI_KAUFMAN:
case MI_MAVERICK:
case MI_VCNMAV:
- case MI_RANCHER:
+ //case MI_RANCHER:
case MI_FBIRANCH:
case MI_JETMAX:
- case MI_HOTRING:
+ //case MI_HOTRING:
case MI_SANDKING:
- case MI_BLISTAC:
+ //case MI_BLISTAC:
case MI_POLMAV:
- case MI_BOXVILLE:
- case MI_BENSON:
- case MI_MESA:
+ //case MI_BOXVILLE:
+ //case MI_BENSON:
+ //case MI_MESA:
case MI_RCGOBLIN:
- case MI_HOTRINA:
- case MI_HOTRINB:
- case MI_BLOODRA:
- case MI_BLOODRB:
+ //case MI_HOTRINA:
+ //case MI_HOTRINB:
+ //case MI_BLOODRA:
+ //case MI_BLOODRB:
case MI_VICECHEE:
model = -1;
break;
@@ -1913,23 +1884,23 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
case MI_MOONBEAM:
case MI_ESPERANT:
case MI_TAXI:
- case MI_WASHING:
+ //case MI_WASHING:
case MI_BOBCAT:
case MI_BANSHEE:
- case MI_CABBIE:
+ //case MI_CABBIE:
case MI_STALLION:
case MI_RUMPO:
- case MI_ADMIRAL:
+ //case MI_ADMIRAL:
case MI_PCJ600:
case MI_FAGGIO:
case MI_FREEWAY:
- case MI_GLENDALE:
- case MI_OCEANIC:
+ //case MI_GLENDALE:
+ //case MI_OCEANIC:
case MI_SANCHEZ:
- case MI_SABRE:
- case MI_REGINA:
- case MI_VIRGO:
- case MI_GREENWOO:
+ //case MI_SABRE:
+ //case MI_REGINA:
+ //case MI_VIRGO:
+ //case MI_GREENWOO:
break;
default:
printf("CREATE_RANDOM_CAR_FOR_CAR_PARK - Unknown car model %d\n", CStreaming::ms_vehiclesLoaded[index]);
@@ -1951,10 +1922,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,37 +1941,33 @@ 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
@@ -2017,20 +1984,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 +2006,43 @@ 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);
+ UpdateCompareFlag(true); // TODO
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)); // TODO
+ UpdateCompareFlag(true);
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 +2060,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 +2077,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 +2093,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 +2105,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 +2162,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 +2238,36 @@ 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);
+ 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 1371f2e6..8354492e 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -17,32 +17,20 @@
#include "World.h"
#include "main.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)
@@ -62,8 +50,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:
@@ -79,37 +67,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:
@@ -136,14 +110,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)
@@ -161,8 +137,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) {
@@ -174,14 +150,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;
@@ -225,12 +201,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)
@@ -248,21 +226,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;
@@ -302,12 +280,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)
@@ -327,8 +307,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) {
@@ -346,19 +326,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;
@@ -405,13 +385,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)
@@ -429,9 +411,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) {
@@ -444,14 +426,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;
@@ -495,12 +477,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)
@@ -518,22 +502,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;
@@ -573,12 +557,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)
@@ -596,22 +582,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;
@@ -651,12 +637,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)
@@ -672,8 +660,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) {
@@ -687,19 +675,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;
@@ -722,13 +710,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)
@@ -743,23 +733,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;
@@ -780,13 +770,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)
@@ -802,30 +794,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)
@@ -845,8 +839,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:
@@ -862,23 +856,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;
@@ -937,12 +931,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)
@@ -963,7 +959,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:
@@ -979,25 +975,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)
@@ -1060,6 +1056,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,
@@ -1068,6 +1065,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)
@@ -1087,8 +1085,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) {
@@ -1106,23 +1104,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;
@@ -1179,13 +1177,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)
@@ -1201,8 +1201,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) {
@@ -1216,23 +1216,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;
@@ -1277,13 +1277,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)
@@ -1298,27 +1300,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;
@@ -1359,13 +1361,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()
@@ -1386,7 +1390,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;
@@ -1440,24 +1445,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) {
@@ -1518,13 +1523,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)
@@ -1542,7 +1549,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;
@@ -1554,18 +1561,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) {
@@ -1610,12 +1617,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)
@@ -1633,23 +1642,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) {
@@ -1694,12 +1703,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)
@@ -1717,22 +1728,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) {
@@ -1777,12 +1788,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)
@@ -1803,23 +1816,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;
@@ -1833,7 +1846,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) {
@@ -1895,12 +1908,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
@@ -1987,8 +2002,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;
@@ -2095,6 +2111,7 @@ 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)
@@ -2118,6 +2135,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;
@@ -2179,20 +2199,36 @@ INITSAVEBUF
VALIDATESAVEBUF(*size)
}
-void CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
+// TODO: I don't really understand how script loading works, so I leave it the VC way for now.
+bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size)
{
- Init();
+ Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts
INITSAVEBUF
CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE);
uint32 varSpace = ReadSaveBuf<uint32>(buf);
- for (uint32 i = 0; i < varSpace; i++)
- ScriptSpace[i] = ReadSaveBuf<uint8>(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)
+ ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
+ else if (GetSaveVarIndex(i / 4 * 4) != -1)
+ ScriptSpace[i] = ReadSaveBuf<uint8>(buf);
+ else
+ ReadSaveBuf<uint8>(buf);
+ }
+ // everything else is... gone? TODO
script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE);
OnAMissionFlag = ReadSaveBuf<uint32>(buf);
LastMissionPassedTime = ReadSaveBuf<uint32>(buf);
+ for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++)
+ CollectiveArray[i] = ReadSaveBuf<tCollectiveData>(buf);
+ NextFreeCollectiveIndex = ReadSaveBuf<int32>(buf);
for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
uint32 type = ReadSaveBuf<uint32>(buf);
uint32 handle = ReadSaveBuf<uint32>(buf);
+ /*
switch (type) {
case 0:
BuildingSwapArray[i].m_pBuilding = nil;
@@ -2206,14 +2242,18 @@ INITSAVEBUF
default:
script_assert(false);
}
- BuildingSwapArray[i].m_nNewModel = ReadSaveBuf<uint32>(buf);
- BuildingSwapArray[i].m_nOldModel = ReadSaveBuf<uint32>(buf);
+ */
+ /*BuildingSwapArray[i].m_nNewModel = */ReadSaveBuf<uint32>(buf);
+ /*BuildingSwapArray[i].m_nOldModel = */ReadSaveBuf<uint32>(buf);
+ /*
if (BuildingSwapArray[i].m_pBuilding)
BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nNewModel);
+ */
}
for (uint32 i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
uint32 type = ReadSaveBuf<uint32>(buf);
uint32 handle = ReadSaveBuf<uint32>(buf);
+ /*
switch (type) {
case 0:
InvisibilitySettingArray[i] = nil;
@@ -2235,9 +2275,10 @@ INITSAVEBUF
}
if (InvisibilitySettingArray[i])
InvisibilitySettingArray[i]->bIsVisible = false;
+ */
}
script_assert(ReadSaveBuf<bool>(buf) == bUsingAMultiScriptFile);
- bPlayerHasMetDebbieHarry = ReadSaveBuf<uint8>(buf);
+ /*bPlayerHasMetDebbieHarry = */ReadSaveBuf<uint8>(buf);
ReadSaveBuf<uint16>(buf);
script_assert(ReadSaveBuf<uint32>(buf) == MainScriptSize);
script_assert(ReadSaveBuf<uint32>(buf) == LargestMissionScriptSize);
@@ -2245,7 +2286,9 @@ INITSAVEBUF
script_assert(ReadSaveBuf<uint16>(buf) == NumberOfExclusiveMissionScripts);
uint32 runningScripts = ReadSaveBuf<uint32>(buf);
for (uint32 i = 0; i < runningScripts; i++)
- StartNewScript(0)->Load(buf);
+ CRunningScript().Load(buf);
+ StartTestScript(); // <- tmp hack
+ return true;
VALIDATESAVEBUF(size)
}
@@ -2255,6 +2298,7 @@ void CRunningScript::Save(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
+ WriteSaveBuf<int32>(buf, m_nId);
for (int i = 0; i < 8; i++)
WriteSaveBuf<char>(buf, m_abScriptName[i]);
WriteSaveBuf<uint32>(buf, m_nIp);
@@ -2266,10 +2310,11 @@ void CRunningScript::Save(uint8*& buf)
WriteSaveBuf<uint16>(buf, m_nStackPointer);
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 + 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<int32>(buf, m_anLocalVariables[i]);
+ WriteSaveBuf<int32>(buf, m_nLocalsPointer);
WriteSaveBuf<bool>(buf, m_bIsActive);
WriteSaveBuf<bool>(buf, m_bCondResult);
WriteSaveBuf<bool>(buf, m_bIsMissionScript);
@@ -2290,6 +2335,7 @@ void CRunningScript::Load(uint8*& buf)
{
#ifdef COMPATIBLE_SAVES
SkipSaveBuf(buf, 8);
+ m_nId = ReadSaveBuf<int32>(buf);
for (int i = 0; i < 8; i++)
m_abScriptName[i] = ReadSaveBuf<char>(buf);
m_nIp = ReadSaveBuf<uint32>(buf);
@@ -2301,10 +2347,11 @@ void CRunningScript::Load(uint8*& buf)
m_nStackPointer = ReadSaveBuf<uint16>(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++)
m_anLocalVariables[i] = ReadSaveBuf<int32>(buf);
+ m_nLocalsPointer = ReadSaveBuf<int32>(buf);
m_bIsActive = ReadSaveBuf<bool>(buf);
m_bCondResult = ReadSaveBuf<bool>(buf);
m_bIsMissionScript = ReadSaveBuf<bool>(buf);
@@ -2683,8 +2730,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;
+ }
}
}
}
@@ -2697,6 +2750,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed)
flees = true;
}
pPed->ClearObjective();
+ pPed->SetWaitState(WAITSTATE_FALSE, nil); // third parameter is 0 TODO?
pPed->bRespondsToThreats = true;
pPed->bScriptObjectiveCompleted = false;
pPed->bKindaStayInSamePlace = false;
@@ -2740,6 +2794,9 @@ void CTheScripts::ReadObjectNamesFromScript()
{
int32 varSpace = GetSizeOfVariableSpace();
uint32 ip = varSpace + 8;
+ NumSaveVars = Read4BytesFromScript(&ip);
+ SavedVarIndices = (short*)&ScriptSpace[ip];
+ ip += 2 * NumSaveVars;
NumberOfUsedObjects = Read2BytesFromScript(&ip);
ip += 2;
for (uint16 i = 0; i < NumberOfUsedObjects; i++) {
@@ -2751,30 +2808,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
}
}
@@ -2784,7 +2827,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 4d7121f2..0e1256fd 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"
@@ -38,6 +39,8 @@
#include "Pickups.h"
#include "Fluff.h"
+// LCS: file done except TODOs
+
#ifdef USE_DEBUG_SCRIPT_LOADER
extern const char* scriptfile;
#endif
@@ -83,43 +86,40 @@ 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);
+ pCar->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:
@@ -129,46 +129,46 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
AllowMissionReplay = 0;
SaveGameForPause(3);
#endif
- 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;
}
@@ -178,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);
@@ -194,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:
@@ -213,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;
@@ -224,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;
@@ -236,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;
}
@@ -253,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;
}
@@ -268,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);
@@ -303,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:
@@ -314,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;
}
*/
@@ -374,51 +374,49 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
{
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);
if (missionRetryScriptIndex == 19)
CStats::LastMissionPassedName[0] = '\0';
#endif
CTimer::Suspend();
- int offset = CTheScripts::MultiScriptArray[ScriptParams[0]];
-#ifdef USE_DEBUG_SCRIPT_LOADER
- CFileMgr::ChangeDir("\\data\\");
- int handle = CFileMgr::OpenFile(scriptfile, "rb");
- CFileMgr::ChangeDir("\\");
-#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); // TODO
+ 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;
@@ -427,83 +425,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 (base::cSingleton<cCustomSoundTrack>::Instance()->unk()) - TODO on PS2, but it's not on mobile
+ 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;
@@ -521,33 +505,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;
@@ -555,123 +538,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:
+ 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_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();
@@ -681,16 +677,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());
@@ -699,11 +695,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:
@@ -712,7 +708,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;
@@ -720,12 +716,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 {
@@ -737,17 +733,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;
@@ -756,8 +751,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();
@@ -766,25 +763,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;
@@ -792,7 +789,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:
@@ -801,16 +798,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;
@@ -819,9 +816,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;
@@ -829,7 +826,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;
@@ -837,7 +834,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);
@@ -846,7 +843,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);
@@ -866,7 +863,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)
{
@@ -910,9 +907,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());
@@ -921,61 +918,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());
@@ -985,13 +976,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) {
@@ -1018,22 +1009,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);
@@ -1055,10 +1074,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;
}
@@ -1066,10 +1085,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;
}
@@ -1081,11 +1100,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);
@@ -1117,9 +1136,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;
@@ -1129,11 +1148,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;
}
@@ -1141,79 +1160,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
@@ -1223,7 +1244,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
@@ -1235,10 +1256,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);
@@ -1248,7 +1269,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;
@@ -1274,7 +1295,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;
}
@@ -1322,7 +1343,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;
}
@@ -1330,9 +1351,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);
@@ -1341,20 +1362,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();
@@ -1365,34 +1386,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;
}
@@ -1407,36 +1428,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;
@@ -1446,16 +1467,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;
@@ -1464,7 +1485,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;
@@ -1473,9 +1494,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];
@@ -1487,69 +1508,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;
@@ -1557,11 +1584,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;
}
@@ -1569,31 +1611,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)
@@ -1608,35 +1649,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;
@@ -1652,85 +1693,85 @@ 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;
@@ -1738,7 +1779,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
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;
@@ -1746,7 +1787,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
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;
@@ -1754,7 +1795,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
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;
@@ -1762,7 +1803,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
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;
@@ -1770,7 +1811,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
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;
@@ -1778,7 +1819,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;
}
@@ -1786,14 +1827,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..de389a13 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);
+ 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);
- *(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, 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,15 @@ 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);
+ 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 +387,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 +411,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 +437,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 +449,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 +481,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 +491,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 +508,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
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 +522,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); // TODO: last params are -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 +630,23 @@ 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);
+ 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);
}
else {
- pVehicle->BurstTyre(ScriptParams[1], true);
+ 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 +659,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 +687,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 +695,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 +715,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 +742,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 +750,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 +788,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 +804,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,14 +812,14 @@ 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)); // TODO: gpModelIndices
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];
@@ -783,24 +827,24 @@ 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_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)); // TODO: gpModelIndices
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 +858,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 +940,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 +949,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 +968,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 +996,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 +1009,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 +1033,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 +1051,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 +1069,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 +1105,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 +1136,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 +1155,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 +1166,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 +1188,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 +1239,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 +1268,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 +1315,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 +1336,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 +1345,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 +1381,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 +1389,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 +1425,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 +1433,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 +1442,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:
+ 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_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 +1485,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 +1507,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 56d7ed90..38c28069 100644
--- a/src/control/Script8.cpp
+++ b/src/control/Script8.cpp
@@ -4,7 +4,7 @@
#include "ScriptCommands.h"
#include "DMAudio.h"
-#if ((defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) && defined MORE_LANGUAGES)
+#ifdef MORE_LANGUAGES
#include "Frontend.h"
#endif
#include "GameLogic.h"
@@ -12,13 +12,10 @@
#ifdef MISSION_REPLAY
#include "GenericGameStorage.h"
#endif
-#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
-#include "General.h"
-#include "maths.h"
-#endif
#include "Hud.h"
#include "Pad.h"
#include "PedAttractor.h"
+#include "Pickups.h"
#include "Population.h"
#include "Pools.h"
#include "RpAnimBlend.h"
@@ -29,19 +26,20 @@
#include "World.h"
#include "Zones.h"
+// LCS: file done except TODOs (also check commented out strings)
+
int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
switch (command) {
case COMMAND_REGISTER_VIGILANTE_LEVEL:
CollectParameters(&m_nIp, 1);
- CStats::RegisterLevelVigilanteMission(ScriptParams[0]);
+ CStats::RegisterLevelVigilanteMission(GET_INTEGER_PARAM(0));
return 0;
case COMMAND_CLEAR_ALL_CHAR_ANIMS:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
- script_assert(pPed);
- if (!pPed->bInVehicle) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
+ if (pPed && pPed->GetPedState() != PED_DRIVING && pPed->GetPedState() != PED_AIM_GUN) {
pPed->m_pVehicleAnim = nil;
pPed->RestartNonPartialAnims();
RpAnimBlendClumpRemoveAllAssociations(pPed->GetClump());
@@ -62,7 +60,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
}
case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE:
CollectParameters(&m_nIp, 2);
- CGarages::SetMaxNumStoredCarsForGarage(ScriptParams[0], ScriptParams[1]);
+ CGarages::SetMaxNumStoredCarsForGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
case COMMAND_WANTED_STARS_ARE_FLASHING:
{
@@ -72,25 +70,25 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
}
case COMMAND_SET_ALLOW_HURRICANES:
CollectParameters(&m_nIp, 1);
- CStats::NoMoreHurricanes = ScriptParams[0];
+ CStats::NoMoreHurricanes = GET_INTEGER_PARAM(0);
return 0;
case COMMAND_PLAY_ANNOUNCEMENT:
{
CollectParameters(&m_nIp, 1);
- DMAudio.PlayRadioAnnouncement(ScriptParams[0] + STREAMED_SOUND_ANNOUNCE_BRIDGE_CLOSED);
+ DMAudio.PlayRadioAnnouncement(GET_INTEGER_PARAM(0) + STREAMED_SOUND_NEWS_A);
return 0;
}
case COMMAND_SET_PLAYER_IS_IN_STADIUM:
{
CollectParameters(&m_nIp, 1);
- CTheScripts::bPlayerIsInTheStatium = ScriptParams[0];
+ CTheScripts::bPlayerIsInTheStatium = GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER:
{
CollectParameters(&m_nIp, 1);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
- ScriptParams[0] = pPlayerInfo->m_pPed->m_nLastBusFareCollected;
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
+ SET_INTEGER_PARAM(0, pPlayerInfo->m_pPed->m_nLastBusFareCollected);
pPlayerInfo->m_pPed->m_nLastBusFareCollected = 0;
StoreParameters(&m_nIp, 1);
return 0;
@@ -98,11 +96,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
script_assert(pVehicle);
- ScriptParams[0] = 0;
+ SET_INTEGER_PARAM(0, 0);
if (pPed->m_objective == OBJECTIVE_NONE && !pPed->bHasAlreadyUsedAttractor) {
C2dEffect* pEffect = (C2dEffect*)GetPedAttractorManager()->GetEffectForIceCreamVan(pVehicle, pPed->GetPosition()); // has to be casted, because inner methods are const
if (pEffect) {
@@ -111,7 +109,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
if ((pPed->GetPosition() - pos).MagnitudeSqr() < SQR(20.0f)) {
if (GetPedAttractorManager()->HasEmptySlot(pEffect) && GetPedAttractorManager()->IsApproachable(pEffect, pVehicle->GetMatrix(), 0, pPed)) {
if (GetPedAttractorManager()->RegisterPedWithAttractor(pPed, pEffect, pVehicle->GetMatrix()))
- ScriptParams[0] = 1;
+ SET_INTEGER_PARAM(0, 1);
}
}
}
@@ -121,16 +119,17 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
}
case COMMAND_DISPLAY_RADAR:
CollectParameters(&m_nIp, 1);
- CHud::m_HideRadar = ScriptParams[0] == 0;
+ CHud::m_HideRadar = GET_INTEGER_PARAM(0) == 0;
+ // on PS2 two flags are set, on mobile none
return 0;
case COMMAND_REGISTER_BEST_POSITION:
CollectParameters(&m_nIp, 2);
- CStats::RegisterBestPosition(ScriptParams[0], ScriptParams[1]);
+ CStats::RegisterBestPosition(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
case COMMAND_IS_PLAYER_IN_INFO_ZONE:
{
CollectParameters(&m_nIp, 1);
- CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
+ CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)];
char key[KEY_LENGTH_IN_SCRIPT];
memset(key, 0, KEY_LENGTH_IN_SCRIPT);
CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
@@ -143,7 +142,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
if (pPed->m_attractor)
GetPedAttractorManager()->DeRegisterPed(pPed, pPed->m_attractor);
@@ -155,7 +154,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_HAS_CHAR_ATTEMPTED_ATTRACTOR:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
UpdateCompareFlag(pPed->bHasAlreadyUsedAttractor);
return 0;
@@ -163,9 +162,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_SET_LOAD_COLLISION_FOR_CAR_FLAG:
{
CollectParameters(&m_nIp, 2);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pVehicle);
- if (ScriptParams[1]) {
+ if (GET_INTEGER_PARAM(1)) {
pVehicle->bDontLoadCollision = false;
if (m_bMissionFlag) {
CWorld::Remove(pVehicle);
@@ -186,9 +185,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_SET_LOAD_COLLISION_FOR_CHAR_FLAG:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- if (ScriptParams[1]) {
+ if (GET_INTEGER_PARAM(1)) {
pPed->bDontLoadCollision = false;
if (m_bMissionFlag) {
CWorld::Remove(pPed);
@@ -210,31 +209,31 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_ADD_BIG_GUN_FLASH:
{
CollectParameters(&m_nIp, 6);
- CWeapon::AddGunFlashBigGuns(*(CVector*)&ScriptParams[0], *(CVector*)&ScriptParams[3]);
+ CWeapon::AddGunFlashBigGuns(GET_VECTOR_PARAM(0), GET_VECTOR_PARAM(3));
return 0;
}
case COMMAND_HAS_CHAR_BOUGHT_ICE_CREAM:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
UpdateCompareFlag(pPed->bBoughtIceCream);
return 0;
}
case COMMAND_GET_PROGRESS_PERCENTAGE:
- *(float*)&ScriptParams[0] = CStats::GetPercentageProgress();
+ SET_FLOAT_PARAM(0, CStats::GetPercentageProgress());
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_SET_SHORTCUT_PICKUP_POINT:
{
CollectParameters(&m_nIp, 4);
- CGameLogic::AddShortCutPointAfterDeath(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]);
+ CGameLogic::AddShortCutPointAfterDeath(GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3));
return 0;
}
case COMMAND_SET_SHORTCUT_DROPOFF_POINT_FOR_MISSION:
{
CollectParameters(&m_nIp, 4);
- CGameLogic::AddShortCutDropOffPointForMission(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]);
+ CGameLogic::AddShortCutDropOffPointForMission(GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3));
return 0;
}
case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA:
@@ -242,10 +241,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
CollectParameters(&m_nIp, 7);
int ped_handle = -1;
CVector pos = FindPlayerCoors();
- float x1 = *(float*)&ScriptParams[0];
- float y1 = *(float*)&ScriptParams[1];
- float x2 = *(float*)&ScriptParams[2];
- float y2 = *(float*)&ScriptParams[3];
+ float x1 = GET_FLOAT_PARAM(0);
+ float y1 = GET_FLOAT_PARAM(1);
+ float x2 = GET_FLOAT_PARAM(2);
+ float y2 = GET_FLOAT_PARAM(3);
int i = CPools::GetPedPool()->GetSize();
while (--i && ped_handle == -1) {
CPed* pPed = CPools::GetPedPool()->GetSlot(i);
@@ -267,7 +266,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
continue;
if (pPed->m_attractor)
continue;
- if (!ThisIsAValidRandomPed(pPed->m_nPedType, ScriptParams[4], ScriptParams[5], ScriptParams[6]))
+ if (!ThisIsAValidRandomPed(pPed->m_nPedType, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6)))
continue;
if (pPed->bIsLeader || pPed->m_leader)
continue;
@@ -285,7 +284,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
if (m_bIsMissionScript)
CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR);
}
- ScriptParams[0] = ped_handle;
+ SET_INTEGER_PARAM(0, ped_handle);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -294,10 +293,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
CollectParameters(&m_nIp, 4);
uint32 i = CPools::GetVehiclePool()->GetSize();
- float infX = *(float*)&ScriptParams[0];
- float infY = *(float*)&ScriptParams[1];
- float supX = *(float*)&ScriptParams[2];
- float supY = *(float*)&ScriptParams[3];
+ float infX = GET_FLOAT_PARAM(0);
+ float infY = GET_FLOAT_PARAM(1);
+ float supX = GET_FLOAT_PARAM(2);
+ float supY = GET_FLOAT_PARAM(3);
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle)
@@ -309,22 +308,23 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
}
case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS:
CollectParameters(&m_nIp, 2);
- CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + ScriptParams[0]), !!ScriptParams[1]);
+ CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + GET_INTEGER_PARAM(0)), !!GET_INTEGER_PARAM(1));
return 0;
case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- pPed->bHeldHostageInCar = ScriptParams[1];
+ pPed->bHeldHostageInCar = GET_INTEGER_PARAM(1);
+ pPed->b1A4_2 = GET_INTEGER_PARAM(1);
return 0;
}
case COMMAND_SET_VEHICLE_TO_FADE_IN:
{
CollectParameters(&m_nIp, 2);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pVehicle);
- CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), ScriptParams[1]);
+ CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), GET_INTEGER_PARAM(1));
return 0;
}
case COMMAND_REGISTER_ODDJOB_MISSION_PASSED:
@@ -336,7 +336,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_IS_PLAYER_IN_SHORTCUT_TAXI:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle == CGameLogic::pShortCutTaxi);
return 0;
@@ -344,7 +344,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_IS_CHAR_DUCKING:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
UpdateCompareFlag(RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_STD_DUCK_DOWN) != nil);
return 0;
@@ -352,24 +352,24 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI:
{
CollectParameters(&m_nIp, 3);
- CObject* pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ CObject* pHeli = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0));
bool found = false;
float waterLevel = -1000.0f;
CVector pos = pHeli->GetPosition();
- float radius = *(float*)&ScriptParams[1];
+ float radius = GET_FLOAT_PARAM(1);
float ground = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &found);
if (!CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false))
waterLevel = 0.0f;
if (waterLevel > ground)
ground = waterLevel;
- if (ScriptParams[2] > 8)
- ScriptParams[2] = 8;
- CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, ScriptParams[2]);
+ if (GET_INTEGER_PARAM(2) > 8)
+ SET_INTEGER_PARAM(2, 8);
+ CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, GET_INTEGER_PARAM(2));
return 0;
}
case COMMAND_REGISTER_FIRE_LEVEL:
CollectParameters(&m_nIp, 1);
- CStats::RegisterLevelFireMission(ScriptParams[0]);
+ CStats::RegisterLevelFireMission(GET_INTEGER_PARAM(0));
return 0;
case COMMAND_IS_AUSTRALIAN_GAME:
UpdateCompareFlag(false); // should we make some check?
@@ -377,14 +377,13 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_DISARM_CAR_BOMB:
{
CollectParameters(&m_nIp, 1);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
if (pVehicle->m_bombType != CARBOMB_NONE) {
pVehicle->m_bombType = CARBOMB_NONE;
pVehicle->m_pBombRigger = nil;
}
return 0;
}
-#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT)
case COMMAND_IS_JAPANESE_GAME:
#ifdef MORE_LANGUAGES
UpdateCompareFlag(FrontEndMenuManager.m_PrefsLanguage == CMenuManager::LANGUAGE_JAPANESE);
@@ -394,220 +393,404 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
UpdateCompareFlag(false);
#endif
return 0;
-#elif (!defined GTA_PS2)
- case COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED:
+ case COMMAND_1442:
+ CollectParameters(&m_nIp, 4);
+ return 0;
+ //case COMMAND_1443:
+ case COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS:
{
- script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR);
- uint16 var = CTheScripts::Read2BytesFromScript(&m_nIp);
- CollectParameters(&m_nIp, 1);
- //CUserDisplay::OnscnTimer.SetCounterFlashWhenFirstDisplayed(var, ScriptParams[0]);
+ CollectParameters(&m_nIp, 4);
+ float X1 = GET_FLOAT_PARAM(0);
+ float Y1 = GET_FLOAT_PARAM(1);
+ float X2 = GET_FLOAT_PARAM(2);
+ float Y2 = GET_FLOAT_PARAM(3);
+ float fDistance = Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2));
+ SET_FLOAT_PARAM(0, fDistance);
+ StoreParameters(&m_nIp, 1);
return 0;
}
-#endif
-#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
- case COMMAND_SHUFFLE_CARD_DECKS:
+ case COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS:
{
- CollectParameters(&m_nIp, 1);
- script_assert(ScriptParams[0] >= 0 && ScriptParams[0] <= 6);
- for (int i = 0; i < CARDS_IN_STACK; i++)
- CTheScripts::CardStack[i] = 0;
- int16 seq[CARDS_IN_STACK];
- for (int i = 0; i < MAX_DECKS * CARDS_IN_DECK; i++)
- seq[i] = i;
- int cards_left = CARDS_IN_DECK * ScriptParams[0];
- for (int k = 1; k < CARDS_IN_DECK + 1; k++) {
- for (int deck = 0; deck < ScriptParams[0]; deck++) {
- int index = CGeneral::GetRandomNumberInRange(0, cards_left);
- CTheScripts::CardStack[seq[index]] = k;
- for (int l = index; l < cards_left; l++) {
- if (l + 1 < CARDS_IN_STACK)
- seq[l] = seq[l + 1];
- else
- seq[l] = 0;
- }
- --cards_left;
- }
- }
- CTheScripts::CardStackPosition = 0;
+ CollectParameters(&m_nIp, 6);
+ float X1 = GET_FLOAT_PARAM(0);
+ float Y1 = GET_FLOAT_PARAM(1);
+ float Z1 = GET_FLOAT_PARAM(2);
+ float X2 = GET_FLOAT_PARAM(3);
+ float Y2 = GET_FLOAT_PARAM(4);
+ float Z2 = GET_FLOAT_PARAM(5);
+ float fDistance = Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2) + (Z1 - Z2) * (Z1 - Z2));
+ SET_FLOAT_PARAM(0, fDistance);
+ StoreParameters(&m_nIp, 1);
return 0;
}
- case COMMAND_FETCH_NEXT_CARD:
+ case COMMAND_DOT_PRODUCT_2D:
{
- if (CTheScripts::CardStack[CTheScripts::CardStackPosition] == 0)
- CTheScripts::CardStackPosition = 0;
- ScriptParams[0] = CTheScripts::CardStack[CTheScripts::CardStackPosition++];
- if (CTheScripts::CardStackPosition == CARDS_IN_DECK * MAX_DECKS)
- CTheScripts::CardStackPosition = 0;
+ CollectParameters(&m_nIp, 4);
+ float X1 = GET_FLOAT_PARAM(0);
+ float Y1 = GET_FLOAT_PARAM(1);
+ float X2 = GET_FLOAT_PARAM(2);
+ float Y2 = GET_FLOAT_PARAM(3);
+ float fDistance = X1 * X2 + Y1 * Y2;
+ SET_FLOAT_PARAM(0, fDistance);
StoreParameters(&m_nIp, 1);
return 0;
}
- case COMMAND_GET_OBJECT_VELOCITY:
+ case COMMAND_DOT_PRODUCT_3D:
{
- CollectParameters(&m_nIp, 1);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- *(CVector*)&ScriptParams[0] = GAME_SPEED_TO_METERS_PER_SECOND * pObject->GetMoveSpeed();
- StoreParameters(&m_nIp, 3);
+ CollectParameters(&m_nIp, 6);
+ float X1 = GET_FLOAT_PARAM(0);
+ float Y1 = GET_FLOAT_PARAM(1);
+ float Z1 = GET_FLOAT_PARAM(2);
+ float X2 = GET_FLOAT_PARAM(3);
+ float Y2 = GET_FLOAT_PARAM(4);
+ float Z2 = GET_FLOAT_PARAM(5);
+ float fDistance = X1 * X2 + Y1 * Y2 + Z1 * Z2;
+ SET_FLOAT_PARAM(0, fDistance);
+ StoreParameters(&m_nIp, 1);
return 0;
}
- case COMMAND_IS_DEBUG_CAMERA_ON:
- UpdateCompareFlag(TheCamera.WorldViewerBeingUsed);
+ case COMMAND_DEBUG_PRINT_WITH_1_FLOAT:
return 0;
- case COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY:
+ case COMMAND_DEBUG_PRINT_WITH_2_FLOATS:
+ return 0;
+ case COMMAND_DEBUG_PRINT_WITH_3_FLOATS:
+ return 0;
+ case COMMAND_GET_PAD_BUTTON_STATE:
{
- CollectParameters(&m_nIp, 4);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- CVector newSpeed = pObject->GetTurnSpeed() + *(CVector*)&ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND;
- if (pObject->bIsStatic) {
- pObject->SetIsStatic(false);
- pObject->AddToMovingList();
+ CollectParameters(&m_nIp, 1);
+ switch (GET_INTEGER_PARAM(0)) {
+ case 0: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetOddJobTrigger()); break;
+ case 1: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetBrake()); break;
+ case 2: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSteeringLeftRight()); break;
+ case 3: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSteeringUpDown()); break;
+ case 4: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunLeftRight()); break;
+ case 5: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunUpDown()); break;
+ case 6: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetPedWalkLeftRight()); break;
+ case 7: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetPedWalkUpDown()); break;
+ case 8: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookLeft()); break;
+ case 9: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookRight()); break;
+ case 10: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookBehindForCar()); break;
+ case 11: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookBehindForPed()); break;
+ case 12: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetHorn()); break;
+ case 13: SET_INTEGER_PARAM(0, CPad::GetPad(0)->HornJustDown()); break;
+ case 14: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunFired()); break;
+ case 15: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CarGunJustDown()); break;
+ case 16: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetHandBrake()); break;
+ case 17: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetBrake()); break;
+ case 18: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetExitVehicle()); break;
+ case 19: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ExitVehicleJustDown()); break;
+ case 20: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetWeapon()); break;
+ case 21: SET_INTEGER_PARAM(0, CPad::GetPad(0)->WeaponJustDown()); break;
+ case 22: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetAccelerate()); break;
+ case 23: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleCameraModeUpJustDown()); break;
+ case 24: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleWeaponLeftJustDown()); break;
+ case 25: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleWeaponRightJustDown()); break;
+ case 26: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetTarget()); break;
+ case 27: SET_INTEGER_PARAM(0, CPad::GetPad(0)->TargetJustDown()); break;
+ case 28: SET_INTEGER_PARAM(0, CPad::GetPad(0)->JumpJustDown()); break;
+ case 29: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSprint()); break;
+ case 30: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ShiftTargetLeftJustDown()); break;
+ case 31: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ForceCameraBehindPlayer()); break;
+ case 32: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperZoomIn()); break;
+ case 33: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperZoomOut()); break;
+ case 34: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperModeLookLeftRight()); break;
+ case 35: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperModeLookUpDown()); break;
+ case 36: SET_INTEGER_PARAM(0, CPad::GetPad(0)->LookAroundLeftRight()); break;
+ case 37: SET_INTEGER_PARAM(0, CPad::GetPad(0)->LookAroundUpDown()); break;
+ case 38: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiLeft()); break;
+ case 39: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiRight()); break;
+ case 40: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiUp()); break;
+ case 41: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiDown()); break;
+ case 42: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiSelect()); break;
+ case 43: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiBack()); break;
+ case 44: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSkipCutscene()); if (GET_INTEGER_PARAM(0)) TheCamera.m_bIgnoreFadingStuffForMusic = false; break; // spectacular hack
}
- pObject->SetTurnSpeed(newSpeed.x, newSpeed.y, newSpeed.z);
+ StoreParameters(&m_nIp, 1);
return 0;
}
- case COMMAND_SET_OBJECT_ROTATION_VELOCITY:
+ case COMMAND_SET_NAVIGATION_ARROW:
{
- CollectParameters(&m_nIp, 4);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- CVector newSpeed = *(CVector*)&ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND;
- if (pObject->bIsStatic) {
- pObject->SetIsStatic(false);
- pObject->AddToMovingList();
- }
- pObject->SetTurnSpeed(newSpeed.x, newSpeed.y, newSpeed.z);
+ CollectParameters(&m_nIp, 3);
+ // cNavArrow::SetTarget(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(0)); // TODO, although it's unused
return 0;
}
- case COMMAND_IS_OBJECT_STATIC:
+ case COMMAND_CLEAR_NAVIGATION_ARROW:
{
- CollectParameters(&m_nIp, 1);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- UpdateCompareFlag(pObject->GetIsStatic());
+ // cNavArrow::ClearTarget(); // TODO, although it's unused
return 0;
}
- case COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS:
+ case COMMAND_CALL:
+ case COMMAND_CALLNOT:
{
- CollectParameters(&m_nIp, 4);
- CVector2D v1 = *(CVector2D*)&ScriptParams[0];
- CVector2D v2 = *(CVector2D*)&ScriptParams[2];
- float c = DotProduct2D(v1, v2) / (v1.Magnitude() * v2.Magnitude());
-#ifdef FIX_BUGS // command is a SA leftover where it was fixed to this
- *(float*)&ScriptParams[0] = RADTODEG(Acos(c));
-#else
- *(float*)&ScriptParams[0] = Acos(c);
-#endif
+ m_anStack[m_nStackPointer++] = m_nIp | BIT(STACKVALUE_IS_FUNCTION_CALL_BIT) | ((command == COMMAND_CALLNOT) ? BIT(STACKVALUE_INVERT_RETURN_BIT) : 0);
+ uint8 nInputParams = CTheScripts::Read1ByteFromScript(&m_nIp);
+ uint8 nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp);
+ uint8 nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp);
+ uint32 nIPBeforeParameters = m_nIp;
+ CollectParameters(&m_nIp, 1);
+ if (nInputParams)
+ CollectParameters(&m_nIp, nInputParams, &m_anLocalVariables[m_nLocalsPointer + nLocalsOffset]);
+ m_nLocalsPointer += nLocalsOffset;
+ m_anStack[m_nStackPointer - 1] |= (m_nIp - nIPBeforeParameters) << STACKVALUE_IP_PARAMS_OFFSET;
+ if (GET_INTEGER_PARAM(0) < 0)
+ m_nIp = CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0);
+ else
+ m_nIp = GET_INTEGER_PARAM(0);
return 0;
}
- case COMMAND_DO_2D_RECTANGLES_COLLIDE:
+ case COMMAND_IS_CAR_AUTOMOBILE:
{
- CollectParameters(&m_nIp, 8);
- float infX1 = *(float*)&ScriptParams[0] - *(float*)&ScriptParams[2] * 0.5; // NB: not float
- float supX1 = *(float*)&ScriptParams[0] + *(float*)&ScriptParams[2] * 0.5;
- float infX2 = *(float*)&ScriptParams[4] - *(float*)&ScriptParams[6] * 0.5;
- float supX2 = *(float*)&ScriptParams[4] + *(float*)&ScriptParams[6] * 0.5;
- float infY1 = *(float*)&ScriptParams[1] - *(float*)&ScriptParams[3] * 0.5;
- float supY1 = *(float*)&ScriptParams[1] + *(float*)&ScriptParams[3] * 0.5;
- float infY2 = *(float*)&ScriptParams[5] - *(float*)&ScriptParams[7] * 0.5;
- float supY2 = *(float*)&ScriptParams[5] + *(float*)&ScriptParams[7] * 0.5;
- bool collide = true;
- if (infY2 > supY1)
- collide = false;
- if (infY1 > supY2)
- collide = false;
- if (infX2 > supX1)
- collide = false;
- if (infX1 > supX2)
- collide = false;
- UpdateCompareFlag(collide);
+ CollectParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pVehicle);
+ UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_FIRST_VEHICLE && pVehicle->GetModelIndex() < MI_FERRY);
return 0;
}
- case COMMAND_GET_OBJECT_ROTATION_VELOCITY:
+ case COMMAND_IS_CAR_BIKE:
{
CollectParameters(&m_nIp, 1);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- *(CVector*)&ScriptParams[0] = pObject->GetTurnSpeed() * GAME_SPEED_TO_METERS_PER_SECOND;
- StoreParameters(&m_nIp, 3);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pVehicle);
+ UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_ANGEL && pVehicle->GetModelIndex() <= MI_SANCHEZ);
return 0;
}
- case COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY:
+ return 0;
+ case COMMAND_IS_CAR_PLANE:
{
- CollectParameters(&m_nIp, 4);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- CVector vecAddition = *(CVector*)&ScriptParams[1] * CTimer::GetTimeStep() / GAME_SPEED_TO_METERS_PER_SECOND;
- if (!pObject->bIsStatic) {
- CVector vecCurrSpeed = pObject->GetSpeed();
- vecCurrSpeed.Normalise();
- if (vecCurrSpeed.z != 1.0) { // NB: not float!
- CVector vx = CrossProduct(vecCurrSpeed, CVector(0.0f, 0.0f, 1.0f));
- vx.Normalise();
- CVector vz = CrossProduct(vx, vecCurrSpeed);
- vz.Normalise();
- CVector vecNewSpeed = pObject->GetSpeed() + vecAddition.x * vx + vecAddition.y * vecCurrSpeed + vecAddition.z * vecCurrSpeed;
- if (pObject->bIsStatic) {
- pObject->SetIsStatic(false);
- pObject->AddToMovingList();
- }
- pObject->SetMoveSpeed(vecNewSpeed);
- }
- }
+ CollectParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pVehicle);
+ UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_AIRTRAIN && pVehicle->GetModelIndex() <= MI_DEADDODO);
return 0;
}
- case COMMAND_GET_OBJECT_SPEED:
+ case COMMAND_IS_CAR_HELI:
{
CollectParameters(&m_nIp, 1);
- CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
- *(float*)&ScriptParams[0] = pObject->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND;
- StoreParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pVehicle);
+ UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_ESCAPE && pVehicle->GetModelIndex() <= MI_CHOPPER);
return 0;
}
+#ifdef FIX_BUGS
+ case COMMAND_1476: // they DO have it in script
+ return 0;
#endif
-#if (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
- case COMMAND_IS_MISSION_SKIP:
-#ifdef MISSION_REPLAY
- ScriptParams[0] = MissionSkipLevel;
-#else
- ScriptParams[0] = 0;
-#endif
+ case COMMAND_RETURN_IF_TRUE:
+ if (m_bCondResult) {
+ ReturnFromGosubOrFunction();
+ }
+ return 0;
+ case COMMAND_RETURN_TRUE_IF_TRUE:
+ if (m_bCondResult) {
+ UpdateCompareFlag(false);
+ ReturnFromGosubOrFunction();
+ }
+ return 0;
+ case COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pPed);
+ pPed->bOnlyAllowedToSitBehind = GET_INTEGER_PARAM(1);
+ return 0;
+ }
+ case COMMAND_SET_RC_HELI_HEIGHT_LIMIT:
+ CollectParameters(&m_nIp, 1);
+ // CVehicle::rcHeliHeightLimit = GET_FLOAT_PARAM(0); // TODO
+ return 0;
+ case COMMAND_CREATE_SCRIPT_CORONA:
+ {
+ CollectParameters(&m_nIp, 9);
+ base::cSList<script_corona>::tSItem* pCorona = new base::cSList<script_corona>::tSItem();
+ pCorona->item.x = GET_FLOAT_PARAM(0);
+ pCorona->item.y = GET_FLOAT_PARAM(1);
+ pCorona->item.z = GET_FLOAT_PARAM(2);
+ pCorona->item.id = CTheScripts::NextScriptCoronaID++;
+ if (pCorona->item.z <= MAP_Z_LOW_LIMIT)
+ pCorona->item.z = CWorld::FindGroundZForCoord(pCorona->item.x, pCorona->item.y);
+ pCorona->item.size = GET_FLOAT_PARAM(3);
+ pCorona->item.r = GET_INTEGER_PARAM(6);
+ pCorona->item.g = GET_INTEGER_PARAM(7);
+ pCorona->item.b = GET_INTEGER_PARAM(8);
+ pCorona->item.type = GET_INTEGER_PARAM(4);
+ pCorona->item.flareType = GET_INTEGER_PARAM(5);
+ SET_INTEGER_PARAM(0, pCorona->item.id);
+ CTheScripts::mCoronas.Insert(pCorona);
StoreParameters(&m_nIp, 1);
return 0;
- case COMMAND_SET_IN_AMMUNATION:
+ }
+ case COMMAND_REMOVE_SCRIPT_CORONA:
+ {
CollectParameters(&m_nIp, 1);
-#ifdef MISSION_REPLAY
- IsInAmmunation = ScriptParams[0];
-#endif
+ for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) {
+ if (i->item.id == GET_INTEGER_PARAM(0)) {
+ CTheScripts::mCoronas.Remove(i);
+ delete i;
+ break;
+ }
+ }
return 0;
- case COMMAND_DO_SAVE_GAME:
+ }
+ case COMMAND_IS_BOAT_IN_WATER:
+ {
CollectParameters(&m_nIp, 1);
-#ifdef MISSION_REPLAY
- SaveGameForPause(ScriptParams[0]);
-#endif
+ CBoat* pVehicle = (CBoat*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pVehicle && pVehicle->IsBoat());
+ UpdateCompareFlag(pVehicle->bBoatInWater);
return 0;
- case COMMAND_IS_RETRY:
-#ifdef MISSION_REPLAY
- if (strcmp(m_abScriptName, "porno4") != 0)
- ScriptParams[0] = AllowMissionReplay;
-#ifdef FIX_BUGS
- else
- ScriptParams[0] = gbTryingPorn4Again;
-#else
- else if (gbTryingPorn4Again)
- ScriptParams[0] = 1;
-#endif
-#else
- ScriptParams[0] = 0;
+ }
+ case COMMAND_IS_CAR_DRIVER_BEING_JACKED:
+ {
+ CollectParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pVehicle);
+ UpdateCompareFlag(pVehicle->bIsBeingCarJacked);
+ return 0;
+ }
+ case COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
+ script_assert(pPed);
+ pPed->bOnlyAllowedToSitInFront = GET_INTEGER_PARAM(1);
+ return 0;
+ }
+ case COMMAND_SET_CAR_TILTED_BY_CHAR:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1));
+ script_assert(pVehicle);
+ pVehicle->ApplyTurnForce(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(-0.8f, -1.2f)* pPed->m_fMass,
+ pPed->GetPosition().x - pVehicle->GetPosition().x, pPed->GetPosition().y - pVehicle->GetPosition().y, 0.0f);
+ DMAudio.PlayOneShot(pVehicle->m_audioEntityId, SOUND_CAR_JERK, 0.0f);
+ return 0;
+ }
+ case COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA:
+ {
+ CollectParameters(&m_nIp, 4);
+ float X = GET_FLOAT_PARAM(0);
+ float Y = GET_FLOAT_PARAM(1);
+ float Z = GET_FLOAT_PARAM(2);
+ float radius = GET_FLOAT_PARAM(3);
+ int model = -1;
+ bool found = false;
+ for (uint32 i = 0; i < NUMPICKUPS; i++) {
+ CPickup* pPickup = &CPickups::aPickUps[i];
+ if (pPickup->m_eType != PICKUP_NONE) {
+ CVector fDist = pPickup->m_vecPos - CVector(X, Y, Z);
+#ifndef FIX_BUGS // this breaks ALL pickups!
+ pPickup->m_eModelIndex = 4;
#endif
+ if (fDist.Magnitude() < radius && pPickup->m_pObject) {
+ found = true;
+ model = CPickups::WeaponForModel(pPickup->m_pObject->GetModelIndex());
+ }
+ }
+ }
+ SET_INTEGER_PARAM(0, model);
StoreParameters(&m_nIp, 1);
+ }
+ case COMMAND_IS_PLAYER_USING_FIRST_PERSON_WEAPON_CAMERA:
+ CollectParameters(&m_nIp, 1);
+ UpdateCompareFlag(TheCamera.Using1stPersonWeaponMode());
return 0;
- case COMMAND_DUMMY:
+ //case COMMAND_1489:
+ //case COMMAND_1490:
+ //case COMMAND_1491:
+ case COMMAND_SET_DEBUG_MENU_ACTIVE:
+ CollectParameters(&m_nIp, 1);
+ // this sets two values on PS2, but not on mobile - TODO?
return 0;
-#endif
-#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
- // it is unknown what these commands do but they don't take parameters
- case COMMAND_MARK_CUTSCENE_START:
+ case COMMAND_SET_DRAW_HUD:
+ CollectParameters(&m_nIp, 1);
+ CHud::m_Wants_To_Draw_Hud = (GET_INTEGER_PARAM(0) != 0);
return 0;
- case COMMAND_MARK_CUTSCENE_END:
+ case COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS:
+ {
+ CollectParameters(&m_nIp, 4);
+ int ped_handle = -1;
+ CVector pos = FindPlayerCoors();
+ float x1 = GET_FLOAT_PARAM(0);
+ float y1 = GET_FLOAT_PARAM(1);
+ float x2 = GET_FLOAT_PARAM(2);
+ float y2 = GET_FLOAT_PARAM(3);
+ int i = CPools::GetPedPool()->GetSize();
+ while (--i && ped_handle == -1) {
+ CPed* pPed = CPools::GetPedPool()->GetSlot(i);
+ if (!pPed)
+ continue;
+ if (pPed->bRemoveFromWorld)
+ continue;
+ if (pPed->bFadeOut)
+ continue;
+ if (pPed->m_nWaitState != WAITSTATE_FALSE)
+ continue;
+ if (!pPed->IsWithinArea(x1, y1, x2, y2))
+ continue;
+ if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
+ continue;
+ if (pos.z + PED_FIND_Z_OFFSET < pPed->GetPosition().z)
+ continue;
+ ped_handle = CPools::GetPedPool()->GetIndex(pPed);
+ CTheScripts::LastRandomPedId = ped_handle;
+ pPed->CharCreatedBy = MISSION_CHAR;
+ pPed->bRespondsToThreats = false;
+ ++CPopulation::ms_nTotalMissionPeds;
+ if (m_bIsMissionScript)
+ CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR);
+ }
+ SET_INTEGER_PARAM(0, ped_handle);
+ StoreParameters(&m_nIp, 1);
return 0;
- case COMMAND_CUTSCENE_SCROLL:
+ }
+ case COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE:
+ {
+ CollectParameters(&m_nIp, 4);
+ int handle = -1;
+ uint32 i = CPools::GetVehiclePool()->GetSize();
+ float infX = GET_FLOAT_PARAM(0);
+ float infY = GET_FLOAT_PARAM(1);
+ float supX = GET_FLOAT_PARAM(2);
+ float supY = GET_FLOAT_PARAM(3);
+ while (i-- && handle == -1) {
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
+ if (!pVehicle)
+ continue;
+ if (!pVehicle->IsWithinArea(infX, infY, supX, supY))
+ continue;
+ handle = CPools::GetVehiclePool()->GetIndex(pVehicle);
+ }
+ SET_INTEGER_PARAM(0, handle);
+ StoreParameters(&m_nIp, 1);
return 0;
+ }
+ case COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
+ if (!pVehicle)
+ printf("STORE_CAR_COLLIDED_WITH_NO_SAVE - Car doesn\'t exist\n");
+ else {
+ if (pVehicle->m_pLastDamageEntity == nil)
+ SET_INTEGER_PARAM(0, -1);
+ else {
+ // what they are doing is not very safe as m_pLastDamageEntity doesn't have to be CVehicle
+#ifdef FIX_BUGS
+ if (!pVehicle->m_pLastDamageEntity->IsVehicle()) {
+ SET_INTEGER_PARAM(0, -1);
+ }
+ else
#endif
+ {
+ SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex((CVehicle*)pVehicle->m_pLastDamageEntity));
+ pVehicle->m_pLastDamageEntity = nil;
+ }
+ }
+ }
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
default:
script_assert(0);
}
diff --git a/src/control/Script9.cpp b/src/control/Script9.cpp
new file mode 100644
index 00000000..42851bbc
--- /dev/null
+++ b/src/control/Script9.cpp
@@ -0,0 +1,774 @@
+#include "common.h"
+
+#include "Script.h"
+#include "ScriptCommands.h"
+
+#include "Bridge.h"
+#include "CarCtrl.h"
+#include "Camera.h"
+#include "CutsceneMgr.h"
+#include "Garages.h"
+#include "GameLogic.h"
+#include "Hud.h"
+#include "Messages.h"
+#include "Object.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)); TODO
+ 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->GetId();
+ 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());
+ UpdateCompareFlag(false);
+ 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());
+ UpdateCompareFlag(true);
+ 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);
+ // ? = pFerry->GetBoardingSpace((CFerry::eSpaceUse)GET_INTEGER_PARAMS(1), (CFerry::eSpaceStyle)GET_INTEGER_PARAMS(2), GET_INTEGER_PARAMS(3));
+ SET_FLOAT_PARAM(0, 0.0f);
+ SET_FLOAT_PARAM(1, 0.0f); // TODO
+ 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 = CGeneral::GetATanOfXY(pFerry->GetForward().x, pFerry->GetForward().y);
+ // SET_FLOAT_PARAM(0, fHeading);
+ SET_FLOAT_PARAM(0, 0.0f);
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
+ case COMMAND_SET_FERRIES_ENABLED:
+ {
+ CollectParameters(&m_nIp, 1);
+ // CFerry::SetFerriesEnabled(GET_INTEGER_PARAM(0));
+ return 0;
+ }
+ case COMMAND_COMPLETE_FERRY_DOOR_MOVEMENT:
+ {
+ CollectParameters(&m_nIp, 1);
+ // CFerry::CompleteDorrMovement(GET_INTEGER_PARAM(0));
+ 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:
+ {
+ 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(GET_INTEGER_PARAM(0));
+ return 0;
+ case COMMAND_UNLOAD_NON_STANDARD_PED_ANIM:
+ CollectParameters(&m_nIp, 1);
+ // CPed::UnloadNonStandardPedAnim(SET_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:
+ UpdateCompareFlag(false); // TODO?
+ return 0;
+ case COMMAND_GET_MULTIPLAYER_MODE:
+ SET_INTEGER_PARAM(0, 0); // TODO
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ case COMMAND_MULTIPLAYER_SCRIPT_DONE:
+ //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 9863e852..000f561c 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,
@@ -1437,39 +1442,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_ENABLED,
+ 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
@@ -1488,7 +1676,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/TrafficLights.cpp b/src/control/TrafficLights.cpp
index df0761ab..d8f211d0 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());