summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-01-03 17:48:13 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2020-01-03 17:48:13 +0100
commit0723dade768ad6118db00c7bb908f39949fb7970 (patch)
treea477b1f04fe92af9619cb8495518691aa409abba /src/control
parentbug fixes (diff)
downloadre3-0723dade768ad6118db00c7bb908f39949fb7970.tar
re3-0723dade768ad6118db00c7bb908f39949fb7970.tar.gz
re3-0723dade768ad6118db00c7bb908f39949fb7970.tar.bz2
re3-0723dade768ad6118db00c7bb908f39949fb7970.tar.lz
re3-0723dade768ad6118db00c7bb908f39949fb7970.tar.xz
re3-0723dade768ad6118db00c7bb908f39949fb7970.tar.zst
re3-0723dade768ad6118db00c7bb908f39949fb7970.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/CarCtrl.cpp2
-rw-r--r--src/control/CarCtrl.h1
-rw-r--r--src/control/Garages.cpp25
-rw-r--r--src/control/Garages.h111
-rw-r--r--src/control/Population.cpp7
-rw-r--r--src/control/Population.h1
-rw-r--r--src/control/Record.cpp4
-rw-r--r--src/control/Record.h2
-rw-r--r--src/control/Script.cpp1246
-rw-r--r--src/control/Script.h3
10 files changed, 1273 insertions, 129 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index cf77b5a4..80cb8211 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -953,7 +953,7 @@ void CCarCtrl::SlowCarDownForPedsSectorList(CPtrList& lst, CVehicle* pVehicle, f
if (visibilityAngle > PI)
visibilityAngle = TWOPI - visibilityAngle;
if (visibilityAngle < HALFPI || pVehicle->m_nCarHornTimer){
- /* if ped sees the danger of if car horn is on */
+ /* if ped sees the danger or if car horn is on */
pPed->SetFlee(pVehicle, 2000);
pPed->bUsePedNodeSeek = false;
pPed->SetMoveState(PEDMOVE_RUN);
diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h
index 44634e39..925552b5 100644
--- a/src/control/CarCtrl.h
+++ b/src/control/CarCtrl.h
@@ -4,6 +4,7 @@
#include "Vehicle.h"
#define GAME_SPEED_TO_METERS_PER_SECOND 50.0f
+#define METERS_PER_SECOND_TO_GAME_SPEED (1.0f / GAME_SPEED_TO_METERS_PER_SECOND)
#define GAME_SPEED_TO_CARAI_SPEED 60.0f
#define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index ca1dae1b..dc77a154 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -6,7 +6,9 @@
#include "Timer.h"
#include "Font.h"
#include "Messages.h"
+#include "PlayerPed.h"
#include "Text.h"
+#include "World.h"
int32 &CGarages::BankVansCollected = *(int32 *)0x8F1B34;
bool &CGarages::BombsAreFree = *(bool *)0x95CD7A;
@@ -25,6 +27,8 @@ bool &CGarages::PlayerInGarage = *(bool *)0x95CD83;
int32 &CGarages::PoliceCarsCollected = *(int32 *)0x941444;
uint32 &CGarages::GarageToBeTidied = *(uint32 *)0x623570;
+CGarage(&CGarages::Garages)[NUM_GARAGES] = *(CGarage(*)[NUM_GARAGES])(uintptr*)0x72BCD0;
+
WRAPPER void CGarages::Init(void) { EAXJMP(0x421C60); }
WRAPPER void CGarages::Update(void) { EAXJMP(0x421E40); }
@@ -86,8 +90,27 @@ int32 CGarages::QueryCarsCollected(int16 garage)
return 0;
}
+void CGarages::GivePlayerDetonator()
+{
+ FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
+ FindPlayerPed()->m_weapons[FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)].m_eWeaponState = WEAPONSTATE_READY;
+}
+
WRAPPER bool CGarages::HasThisCarBeenCollected(int16 garage, uint8 id) { EAXJMP(0x426D50); }
-WRAPPER void CGarages::ChangeGarageType(int16 garage, int8 type) { EAXJMP(0x4222A0); }
+WRAPPER void CGarages::ChangeGarageType(int16 garage, eGarageType type) { EAXJMP(0x4222A0); }
+WRAPPER bool CGarages::HasResprayHappened(int16 garage) { EAXJMP(0x4274F0); }
+
+void CGarage::OpenThisGarage()
+{
+ if (m_eGarageState == GS_FULLYCLOSED || m_eGarageState == GS_CLOSING || m_eGarageState == GS_CLOSEDCONTAINSCAR)
+ m_eGarageState = GS_OPENING;
+}
+
+void CGarage::CloseThisGarage()
+{
+ if (m_eGarageState == GS_OPENED || m_eGarageState == GS_OPENING)
+ m_eGarageState = GS_CLOSING;
+}
#if 0
WRAPPER void CGarages::PrintMessages(void) { EAXJMP(0x426310); }
diff --git a/src/control/Garages.h b/src/control/Garages.h
index f9421ae8..945922fe 100644
--- a/src/control/Garages.h
+++ b/src/control/Garages.h
@@ -1,7 +1,113 @@
#pragma once
+#include "Automobile.h"
+#include "audio_enums.h"
+#include "config.h"
class CVehicle;
+enum eGarageState : int8
+{
+ GS_FULLYCLOSED,
+ GS_OPENED,
+ GS_CLOSING,
+ GS_OPENING,
+ GS_OPENEDCONTAINSCAR,
+ GS_CLOSEDCONTAINSCAR,
+ GS_AFTERDROPOFF,
+};
+
+enum eGarageType : int8
+{
+ GARAGE_NONE,
+ GARAGE_MISSION,
+ GARAGE_BOMBSHOP1,
+ GARAGE_BOMBSHOP2,
+ GARAGE_BOMBSHOP3,
+ GARAGE_RESPRAY,
+ GARAGE_COLLECTORSITEMS,
+ GARAGE_COLLECTSPECIFICCARS,
+ GARAGE_COLLECTCARS_1,
+ GARAGE_COLLECTCARS_2,
+ GARAGE_COLLECTCARS_3,
+ GARAGE_FORCARTOCOMEOUTOF,
+ GARAGE_60SECONDS,
+ GARAGE_CRUSHER,
+ GARAGE_MISSION_KEEPCAR,
+ GARAGE_FOR_SCRIPT_TO_OPEN,
+ GARAGE_HIDEOUT_ONE,
+ GARAGE_HIDEOUT_TWO,
+ GARAGE_HIDEOUT_THREE,
+ GARAGE_FOR_SCRIPT_TO_OPEN_AND_CLOSE,
+ GARAGE_KEEPS_OPENING_FOR_SPECIFIC_CAR,
+ GARAGE_MISSION_KEEPCAR_REMAINCLOSED,
+};
+
+class CStoredCar
+{
+ 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;
+ int8 m_nPrimaryColor;
+ int8 m_nSecondaryColor;
+ int8 m_nRadioStation;
+ int8 m_nVariationA;
+ int8 m_nVariationB;
+ int8 m_nCarBombType;
+};
+
+static_assert(sizeof(CStoredCar) == 0x28, "CStoredCar");
+
+class CGarage
+{
+ eGarageType m_eGarageType;
+ eGarageState m_eGarageState;
+ char field_2;
+ char m_bClosingWithoutTargetCar;
+ char m_bDeactivated;
+ char m_bResprayHappened;
+ char field_6;
+ char field_7;
+ int m_nTargetModelIndex;
+ CEntity *m_pDoor1;
+ CEntity *m_pDoor2;
+ char m_bDoor1PoolIndex;
+ char m_bDoor2PoolIndex;
+ char m_bIsDoor1Object;
+ char m_bIsDoor2Object;
+ char field_24;
+ char m_bRotatedDoor;
+ char m_bCameraFollowsPlayer;
+ char field_27;
+ CVector m_vecInf;
+ CVector m_vecSup;
+ float m_fDoorPos;
+ float m_fDoorHeight;
+ float m_fDoor1X;
+ float m_fDoor1Y;
+ float m_fDoor2X;
+ float m_fDoor2Y;
+ float m_fDoor1Z;
+ float m_fDoor2Z;
+ int m_nDoorOpenTime;
+ char m_bCollectedCarsState;
+ char field_89;
+ char field_90;
+ char field_91;
+ CVehicle *m_pTarget;
+ int field_96;
+ CStoredCar m_sStoredCar;
+public:
+ void OpenThisGarage();
+ void CloseThisGarage();
+};
+
+static_assert(sizeof(CGarage) == 140, "CGarage");
+
class CGarages
{
public:
@@ -21,6 +127,7 @@ public:
static bool &PlayerInGarage;
static int32 &PoliceCarsCollected;
static uint32 &GarageToBeTidied;
+ static CGarage(&Garages)[NUM_GARAGES];
public:
static bool IsModelIndexADoor(uint32 id);
@@ -39,5 +146,7 @@ public:
static void DeActivateGarage(int16);
static int32 QueryCarsCollected(int16);
static bool HasThisCarBeenCollected(int16, uint8);
- static void ChangeGarageType(int16, int8); //TODO: eGarageType
+ static void ChangeGarageType(int16, eGarageType);
+ static bool HasResprayHappened(int16);
+ static void GivePlayerDetonator();
};
diff --git a/src/control/Population.cpp b/src/control/Population.cpp
index a98721ac..d7e32dbf 100644
--- a/src/control/Population.cpp
+++ b/src/control/Population.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "Game.h"
+#include "General.h"
#include "World.h"
#include "Entity.h"
#include "Population.h"
@@ -79,6 +80,12 @@ CPopulation::RemovePed(CEntity* ent)
delete ent;
}
+int32
+CPopulation::ChooseCivilianOccupation(int32 group)
+{
+ return ms_pPedGroups[group].models[CGeneral::GetRandomNumberInRange(0, 8)];
+}
+
STARTPATCHES
InjectHook(0x4F3770, CPopulation::Initialise, PATCH_JUMP);
ENDPATCHES \ No newline at end of file
diff --git a/src/control/Population.h b/src/control/Population.h
index 006e6104..572d6f58 100644
--- a/src/control/Population.h
+++ b/src/control/Population.h
@@ -47,4 +47,5 @@ public:
static CPed *AddPedInCar(CVehicle *vehicle);
static bool IsPointInSafeZone(CVector *coors);
static void RemovePed(CEntity* ent);
+ static int32 ChooseCivilianOccupation(int32);
};
diff --git a/src/control/Record.cpp b/src/control/Record.cpp
index 802ca516..9db9dea1 100644
--- a/src/control/Record.cpp
+++ b/src/control/Record.cpp
@@ -10,4 +10,6 @@ WRAPPER void CRecordDataForGame::SaveOrRetrieveDataForThisFrame(void) { EAXJMP(0
WRAPPER void CRecordDataForChase::SaveOrRetrieveDataForThisFrame(void) { EAXJMP(0x4347F0); }
WRAPPER void CRecordDataForChase::ProcessControlCars(void) { EAXJMP(0x435540); }
-WRAPPER void CRecordDataForChase::SaveOrRetrieveCarPositions(void) { EAXJMP(0x434B20); } \ No newline at end of file
+WRAPPER void CRecordDataForChase::SaveOrRetrieveCarPositions(void) { EAXJMP(0x434B20); }
+WRAPPER void CRecordDataForChase::StartChaseScene(float) { EAXJMP(0x435690); }
+WRAPPER void CRecordDataForChase::CleanUpChaseScene() { EAXJMP(0x4357C0); }
diff --git a/src/control/Record.h b/src/control/Record.h
index 9f396c96..f36c2fd2 100644
--- a/src/control/Record.h
+++ b/src/control/Record.h
@@ -14,6 +14,8 @@ public:
static void SaveOrRetrieveDataForThisFrame(void);
static void ProcessControlCars(void);
static void SaveOrRetrieveCarPositions(void);
+ static void StartChaseScene(float);
+ static void CleanUpChaseScene();
};
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index d1e0f048..34d22897 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -5,7 +5,9 @@
#include "ScriptCommands.h"
#include "Boat.h"
+#include "BulletInfo.h"
#include "Camera.h"
+#include "CarAI.h"
#include "CarCtrl.h"
#include "CarGen.h"
#include "CivilianPed.h"
@@ -32,12 +34,14 @@
#include "PedRoutes.h"
#include "Phones.h"
#include "Pickups.h"
+#include "Plane.h"
#include "PlayerInfo.h"
#include "PlayerPed.h"
#include "PointLights.h"
#include "Pools.h"
#include "Population.h"
#include "ProjectileInfo.h"
+#include "Record.h"
#include "Remote.h"
#include "Restart.h"
#include "Replay.h"
@@ -51,6 +55,9 @@
#include "World.h"
#include "Zones.h"
+#define PICKUP_PLACEMENT_OFFSET 0.5f
+#define PED_FIND_Z_OFFSET 5.0f
+
uint8 (&CTheScripts::ScriptSpace)[SIZE_SCRIPT_SPACE] = *(uint8(*)[SIZE_SCRIPT_SPACE])*(uintptr*)0x74B248;
CRunningScript(&CTheScripts::ScriptsArray)[MAX_NUM_SCRIPTS] = *(CRunningScript(*)[MAX_NUM_SCRIPTS])*(uintptr*)0x6F5C08;
int32(&CTheScripts::BaseBriefIdForContact)[MAX_NUM_CONTACTS] = *(int32(*)[MAX_NUM_CONTACTS])*(uintptr*)0x880200;
@@ -1269,7 +1276,7 @@ int8 CRunningScript::ProcessCommandsFrom0To99(int32 command)
CWorld::Players[index].m_pPed->CharCreatedBy = MISSION_CHAR;
CPlayerPed::DeactivatePlayerPed(index);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ 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->GetPosition() = pos;
@@ -1296,7 +1303,7 @@ int8 CRunningScript::ProcessCommandsFrom0To99(int32 command)
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[1];
int index = ScriptParams[0];
- if (pos.z <= -100.0f)
+ 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) {
@@ -1319,18 +1326,17 @@ int8 CRunningScript::ProcessCommandsFrom0To99(int32 command)
{
CollectParameters(&m_nIp, 6);
CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed;
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
if (!ped->bInVehicle)
UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2));
else
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
- CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f);
+ CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0;
@@ -1339,13 +1345,12 @@ int8 CRunningScript::ProcessCommandsFrom0To99(int32 command)
{
CollectParameters(&m_nIp, 8);
CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed;
- float x1, y1, z1, x2, y2, z2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- z1 = *(float*)&ScriptParams[3];
- x2 = *(float*)&ScriptParams[4];
- y2 = *(float*)&ScriptParams[5];
- z2 = *(float*)&ScriptParams[6];
+ 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];
if (ped->bInVehicle)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
else
@@ -1728,7 +1733,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
ped->bRespondsToThreats = false;
ped->bAllowMedicsToReviveMe = false;
CVector pos = *(CVector*)&ScriptParams[2];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += 1.0f;
ped->GetPosition() = pos;
@@ -1790,7 +1795,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(ped);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
ped->ClearAll();
ped->SetFollowPath(pos);
@@ -1836,7 +1841,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
else
vehicle = nil;
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
/* The following block was once again written
* by someone not familiar with virtual functions.
@@ -1867,7 +1872,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
* assert(ped);
* CEntity* entityToMove = ped->bInVehicle ? ped->m_pMyVehicle : ped;
* CVector pos = *(CVector*)&ScriptParams[1];
- * if (pos.z <= -100.0f)
+ * if (pos.z <= MAP_Z_LOW_LIMIT)
* pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
* pos.z += entityToMove->GetDistanceFromCentreOfMassToBaseOfModel();
* entityToMove->Teleport(pos);
@@ -1893,18 +1898,17 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
vehicle = ped->m_pMyVehicle;
else
vehicle = nil;
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
if (vehicle)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2));
else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
- CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f);
+ CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0;
@@ -1919,13 +1923,12 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
vehicle = ped->m_pMyVehicle;
else
vehicle = nil;
- float x1, y1, z1, x2, y2, z2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- z1 = *(float*)&ScriptParams[3];
- x2 = *(float*)&ScriptParams[4];
- y2 = *(float*)&ScriptParams[5];
- z2 = *(float*)&ScriptParams[6];
+ 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];
if (vehicle)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
else
@@ -1944,7 +1947,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
if (CModelInfo::IsBoatModel(ScriptParams[0])) {
CBoat* boat = new CBoat(ScriptParams[0], MISSION_VEHICLE);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += boat->GetDistanceFromCentreOfMassToBaseOfModel();
boat->GetPosition() = pos;
@@ -1962,7 +1965,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
if (!CModelInfo::IsBikeModel(ScriptParams[0]))
car = new CAutomobile(ScriptParams[0], MISSION_VEHICLE);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
car->GetPosition() = pos;
@@ -2006,7 +2009,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(car);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, pos, false))
@@ -2054,7 +2057,7 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(car);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
car->bIsStatic = false;
@@ -2137,15 +2140,14 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CollectParameters(&m_nIp, 6);
CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(vehicle);
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
- CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f);
+ CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0;
@@ -2155,13 +2157,12 @@ int8 CRunningScript::ProcessCommandsFrom100To199(int32 command)
CollectParameters(&m_nIp, 8);
CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(vehicle);
- float x1, y1, z1, x2, y2, z2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- z1 = *(float*)&ScriptParams[3];
- x2 = *(float*)&ScriptParams[4];
- y2 = *(float*)&ScriptParams[5];
- z2 = *(float*)&ScriptParams[6];
+ 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];
UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7])
return 0;
@@ -2547,7 +2548,7 @@ int8 CRunningScript::ProcessCommandsFrom200To299(int32 command)
CObject* pObj = new CObject(mi, false);
pObj->ObjectCreatedBy = MISSION_OBJECT;
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += pObj->GetDistanceFromCentreOfMassToBaseOfModel();
pObj->GetPosition() = pos;
@@ -2592,7 +2593,7 @@ int8 CRunningScript::ProcessCommandsFrom200To299(int32 command)
{
CollectParameters(&m_nIp, 5);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ 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);
return 0;
@@ -2801,7 +2802,7 @@ int8 CRunningScript::ProcessCommandsFrom200To299(int32 command)
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[1];
CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
if (pPlayer->m_pPed->bInVehicle){
assert(pPlayer->m_pPed->m_pMyVehicle);
@@ -2900,16 +2901,15 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
CollectParameters(&m_nIp, 6);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(pVehicle->m_status == STATUS_WRECKED &&
pVehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
- CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f);
+ CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0;
@@ -2919,13 +2919,12 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
CollectParameters(&m_nIp, 8);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
- float x1, y1, z1, x2, y2, z2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- z1 = *(float*)&ScriptParams[3];
- x2 = *(float*)&ScriptParams[4];
- y2 = *(float*)&ScriptParams[5];
- z2 = *(float*)&ScriptParams[6];
+ 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];
UpdateCompareFlag(pVehicle->m_status == STATUS_WRECKED &&
pVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7])
@@ -3146,7 +3145,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
TheCamera.TakeControlNoEntity(pos, ScriptParams[3], 1);
return 0;
@@ -3200,7 +3199,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
{
CollectParameters(&m_nIp, 5);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
// Useless call
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
@@ -3228,7 +3227,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
float angle = *(float*)&ScriptParams[3];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CRestart::AddHospitalRestartPoint(pos, angle);
return 0;
@@ -3238,7 +3237,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
float angle = *(float*)&ScriptParams[3];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CRestart::AddPoliceRestartPoint(pos, angle);
return 0;
@@ -3248,7 +3247,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
float angle = *(float*)&ScriptParams[3];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CRestart::OverrideNextRestart(pos, angle);
return 0;
@@ -3477,7 +3476,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
// Useless call
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
@@ -3491,7 +3490,7 @@ int8 CRunningScript::ProcessCommandsFrom300To399(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
// Useless call
CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
@@ -3629,7 +3628,7 @@ int8 CRunningScript::ProcessCommandsFrom400To499(int32 command)
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pPed->bScriptObjectiveCompleted = false;
pPed->SetObjective(OBJECTIVE_GUARD_SPOT, pos);
@@ -3794,7 +3793,7 @@ int8 CRunningScript::ProcessCommandsFrom400To499(int32 command)
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pObject->Teleport(pos);
CTheScripts::ClearSpaceForMissionEntity(pos, pObject);
@@ -4574,9 +4573,8 @@ int8 CRunningScript::ProcessCommandsFrom500To599(int32 command)
if (model < 0)
model = CTheScripts::UsedObjectArray[-model].index;
CVector pos = *(CVector*)&ScriptParams[2];
- if (pos.z <= -100.0f)
- pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + 0.5f;
- // unused?
+ 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);
StoreParameters(&m_nIp, 1);
@@ -5118,7 +5116,7 @@ int8 CRunningScript::ProcessCommandsFrom500To599(int32 command)
{
CollectParameters(&m_nIp, 9);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CCoronas::RegisterCorona((uint32)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);
@@ -5149,7 +5147,7 @@ int8 CRunningScript::ProcessCommandsFrom500To599(int32 command)
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CRestart::OverrideNextRestart(pos, *(float*)&ScriptParams[3]);
if (CWorld::Players[CWorld::PlayerInFocus].m_WBState != WBSTATE_PLAYING) //TODO: enum
@@ -5308,7 +5306,7 @@ int8 CRunningScript::ProcessCommandsFrom600To699(int32 command)
CObject* pObj = new CObject(mi, false);
; pObj->ObjectCreatedBy = MISSION_OBJECT;
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pObj->GetPosition() = pos;
pObj->SetOrientation(0.0f, 0.0f, 0.0f);
@@ -5381,7 +5379,7 @@ int8 CRunningScript::ProcessCommandsFrom600To699(int32 command)
{
CollectParameters(&m_nIp, 5);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= 100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CParticleObject::AddObject(ScriptParams[0], pos, ScriptParams[4] != 0);
return 0;
@@ -5433,7 +5431,7 @@ int8 CRunningScript::ProcessCommandsFrom600To699(int32 command)
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ 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);
@@ -5446,7 +5444,7 @@ int8 CRunningScript::ProcessCommandsFrom600To699(int32 command)
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ 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);
@@ -5559,7 +5557,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ 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)];
*(CVector*)&ScriptParams[0] = pNode->pos;
@@ -5570,7 +5568,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CPathNode* pNode = &ThePaths.m_pathNodes[ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f)];
*(CVector*)&ScriptParams[0] = pNode->pos;
@@ -5583,7 +5581,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += pVehicle->GetDistanceFromCentreOfMassToBaseOfModel();
if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, pos, false))
@@ -5614,7 +5612,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 5);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CPacManPickups::StartPacManScramble(pos, *(float*)&ScriptParams[3], ScriptParams[4]);
return 0;
@@ -5671,7 +5669,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
ScriptParams[0] = gFireManager.StartScriptFire(pos, nil, 0.8f, 1);
StoreParameters(&m_nIp, 1);
@@ -5701,7 +5699,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
assert(pVehicle->m_vehType == VEHICLE_TYPE_BOAT);
CBoat* pBoat = (CBoat*)pVehicle;
CVector pos = *(CVector*)&ScriptParams[1];
- if (pos.z <= -100.0f)
+ 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;
pBoat->AutoPilot.m_vecDestinationCoors = pos;
@@ -5728,15 +5726,14 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
CollectParameters(&m_nIp, 6);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
- CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f);
+ CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0;
@@ -5746,15 +5743,14 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
CollectParameters(&m_nIp, 6);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
assert(pPed);
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5])
return 0;
- CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, -100.0f);
+ CTheScripts::HighlightImportantArea((uint32)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0;
@@ -5782,7 +5778,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
+ if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CPacManPickups::GenerateOnePMPickUp(pos);
return 0;
@@ -5801,11 +5797,10 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
CollectParameters(&m_nIp, 4);
int ped_handle = -1;
CVector pos = FindPlayerCoors();
- float x1, y1, x2, y2;
- x1 = *(float*)&ScriptParams[1];
- y1 = *(float*)&ScriptParams[2];
- x2 = *(float*)&ScriptParams[3];
- y2 = *(float*)&ScriptParams[4];
+ float x1 = *(float*)&ScriptParams[1];
+ float y1 = *(float*)&ScriptParams[2];
+ float x2 = *(float*)&ScriptParams[3];
+ float y2 = *(float*)&ScriptParams[4];
int i = CPools::GetPedPool()->GetSize();
while (--i && ped_handle == -1){
CPed* pPed = CPools::GetPedPool()->GetSlot(i);
@@ -5829,9 +5824,9 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
continue;
if (!pPed->IsWithinArea(x1, y1, x2, y2))
continue;
- if (pos.z - 5.0f > pPed->GetPosition().z)
+ if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
continue;
- if (pos.z + 5.0f < pPed->GetPosition().z)
+ if (pos.z + PED_FIND_Z_OFFSET < pPed->GetPosition().z)
continue;
ped_handle = CPools::GetPedPool()->GetIndex(pPed);
CTheScripts::LastRandomPedId = ped_handle;
@@ -5878,9 +5873,9 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
continue;
if (!CTheZones::PointLiesWithinZone(pPed->GetPosition(), pZone))
continue;
- if (pos.z - 5.0f > pPed->GetPosition().z)
+ if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z)
continue;
- if (pos.z + 5.0f < pPed->GetPosition().z)
+ if (pos.z + PED_FIND_Z_OFFSET < pPed->GetPosition().z)
continue;
ped_handle = CPools::GetPedPool()->GetIndex(pPed);
CTheScripts::LastRandomPedId = ped_handle;
@@ -5922,8 +5917,8 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
- pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + 0.5f;
+ 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]);
StoreParameters(&m_nIp, 1);
@@ -5993,8 +5988,8 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
- pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + 0.5f;
+ 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);
return 0;
}
@@ -6058,8 +6053,8 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
- pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + 0.5f;
+ 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);
return 0;
}
@@ -6067,8 +6062,8 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
{
CollectParameters(&m_nIp, 3);
CVector pos = *(CVector*)&ScriptParams[0];
- if (pos.z <= -100.0f)
- pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + 0.5f;
+ 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);
return 0;
}
@@ -6144,7 +6139,7 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
}
case COMMAND_CHANGE_GARAGE_TYPE:
CollectParameters(&m_nIp, 2);
- CGarages::ChangeGarageType(ScriptParams[0], ScriptParams[1]);
+ CGarages::ChangeGarageType(ScriptParams[0], (eGarageType)ScriptParams[1]);
return 0;
case COMMAND_ACTIVATE_CRUSHER_CRANE:
{
@@ -6400,112 +6395,1085 @@ int8 CRunningScript::ProcessCommandsFrom700To799(int32 command)
}
#endif
-#if 1
+#if 0
WRAPPER int8 CRunningScript::ProcessCommandsFrom800To899(int32 command) { EAXJMP(0x448240); }
#else
int8 CRunningScript::ProcessCommandsFrom800To899(int32 command)
{
+ CMatrix tmp_matrix;
switch (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;
+ assert(pPed);
+ assert(pLeader);
+ UpdateCompareFlag(pPed->m_leader == pLeader);
+ return 0;
+ }
case COMMAND_EXPLODE_CHAR_HEAD:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ if (pPed->m_nPedState == PED_DRIVING) {
+ pPed->SetDead();
+ if (!pPed->IsPlayer())
+ pPed->FlagToDestroyWhenNextProcessed();
+ }
+ else if (CGame::nastyGame && pPed->IsPedInControl()) {
+ RwMatrix tmp_rw;
+ CPedIK::GetWorldMatrix(pPed->m_pFrames[PED_HEAD]->frame, &tmp_rw);
+ pPed->ApplyHeadShot(WEAPONTYPE_SNIPERRIFLE, tmp_rw.pos, true);
+ }
+ else {
+ pPed->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
+ }
+ return 0;
+ }
case COMMAND_EXPLODE_PLAYER_HEAD:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ assert(pPed);
+ if (CGame::nastyGame) {
+ RwMatrix tmp_rw;
+ CPedIK::GetWorldMatrix(pPed->m_pFrames[PED_HEAD]->frame, &tmp_rw);
+ pPed->ApplyHeadShot(WEAPONTYPE_SNIPERRIFLE, tmp_rw.pos, true);
+ }
+ else {
+ pPed->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
+ }
+ return 0;
+ }
case COMMAND_ANCHOR_BOAT:
+ {
+ CollectParameters(&m_nIp, 2);
+ CBoat* pBoat = (CBoat*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pBoat && pBoat->m_vehType == VEHICLE_TYPE_BOAT);
+ pBoat->m_bIsAnchored = (ScriptParams[1] == 0);
+ return 0;
+ }
case COMMAND_SET_ZONE_GROUP:
+ {
+ char zone[8];
+ CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
+ m_nIp += 8;
+ CollectParameters(&m_nIp, 2);
+ int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone);
+ if (zone_id < 0) {
+ printf("Couldn't find zone - %s\n", zone);
+ return 0;
+ }
+ CTheZones::SetPedGroup(zone_id, ScriptParams[0], ScriptParams[1]);
+ return 0;
+ }
case COMMAND_START_CAR_FIRE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ ScriptParams[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]);
+ assert(pPed);
+ ScriptParams[0] = gFireManager.StartScriptFire(pPed->GetPosition(), pPed, 0.8f, 1);
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
case COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_AREA:
+ {
+ 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];
+ while (i--) {
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
+ if (!pVehicle)
+ continue;
+ if (ScriptParams[4] != pVehicle->GetModelIndex() && ScriptParams[4] >= 0)
+ continue;
+ if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE)
+ continue;
+ if (!pVehicle->IsWithinArea(infX, infY, supX, supY))
+ continue;
+ handle = CPools::GetVehiclePool()->GetIndex(pVehicle);
+ pVehicle->VehicleCreatedBy = MISSION_VEHICLE;
+ ++CCarCtrl::NumMissionCars;
+ --CCarCtrl::NumRandomCars;
+ if (m_bIsMissionScript)
+ CTheScripts::MissionCleanup.AddEntityToList(handle, CLEANUP_CAR);
+ }
+ ScriptParams[0] = handle;
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
case COMMAND_GET_RANDOM_CAR_OF_TYPE_IN_ZONE:
+ {
+ char zone[8];
+ CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
+ int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone);
+ if (zone_id != -1)
+ m_nIp += 8;
+ CZone* pZone = CTheZones::GetZone(zone_id);
+ CollectParameters(&m_nIp, 1);
+ int handle = -1;
+ uint32 i = CPools::GetVehiclePool()->GetSize();
+ while (i--) {
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
+ if (!pVehicle)
+ continue;
+ if (ScriptParams[0] != pVehicle->GetModelIndex() && ScriptParams[0] >= 0)
+ continue;
+ if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE)
+ continue;
+ if (!CTheZones::PointLiesWithinZone(pVehicle->GetPosition(), pZone))
+ continue;
+ handle = CPools::GetVehiclePool()->GetIndex(pVehicle);
+ pVehicle->VehicleCreatedBy = MISSION_VEHICLE;
+ ++CCarCtrl::NumMissionCars;
+ --CCarCtrl::NumRandomCars;
+ if (m_bIsMissionScript)
+ CTheScripts::MissionCleanup.AddEntityToList(handle, CLEANUP_CAR);
+ }
+ ScriptParams[0] = handle;
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
case COMMAND_HAS_RESPRAY_HAPPENED:
+ {
+ CollectParameters(&m_nIp, 1);
+ UpdateCompareFlag(CGarages::HasResprayHappened(ScriptParams[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]);
+ else if (TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_CAM_ON_A_STRING)
+ TheCamera.SetZoomValueCamStringScript(ScriptParams[0]);
+ return 0;
+ }
case COMMAND_CREATE_PICKUP_WITH_AMMO:
+ {
+ CollectParameters(&m_nIp, 6);
+ int16 model = ScriptParams[0];
+ if (model < 0)
+ model = CTheScripts::UsedObjectArray[-model].index;
+ CVector pos = *(CVector*)&ScriptParams[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]);
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
case COMMAND_SET_CAR_RAM_CAR:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ assert(pTarget);
+ CCarAI::TellCarToRamOtherCar(pVehicle, pTarget);
+ return 0;
+ }
case COMMAND_SET_CAR_BLOCK_CAR:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ assert(pTarget);
+ CCarAI::TellCarToBlockOtherCar(pVehicle, pTarget);
+ return 0;
+ }
case COMMAND_SET_CHAR_OBJ_CATCH_TRAIN:
- case COMMAND_SET_COLL_OBJ_CATCH_TRAIN:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(OBJECTIVE_CATCH_TRAIN);
+ return 0;
+ }
+ //case COMMAND_SET_COLL_OBJ_CATCH_TRAIN:
case COMMAND_SET_PLAYER_NEVER_GETS_TIRED:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
+ pPlayer->m_bInfiniteSprint = (ScriptParams[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);
+ return 0;
+ }
case COMMAND_SET_CHAR_BLEEDING:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->bPedIsBleeding = (ScriptParams[1] != 0);
+ return 0;
+ }
case COMMAND_SET_CAR_FUNNY_SUSPENSION:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ // no action
+ return 0;
+ }
case COMMAND_SET_CAR_BIG_WHEELS:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR);
+ CAutomobile* pCar = (CAutomobile*)pVehicle;
+ pCar->bBigWheels = (ScriptParams[1] != 0);
+ return 0;
+ }
case COMMAND_SET_FREE_RESPRAYS:
+ CollectParameters(&m_nIp, 1);
+ CGarages::RespraysAreFree = (ScriptParams[0] != 0);
+ return 0;
case COMMAND_SET_PLAYER_VISIBLE:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ assert(pPed);
+ pPed->bIsVisible = (ScriptParams[1] != 0);
+ return 0;
+ }
case COMMAND_SET_CHAR_VISIBLE:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->bIsVisible = (ScriptParams[1] != 0);
+ return 0;
+ }
case COMMAND_SET_CAR_VISIBLE:
+ {
+ CollectParameters(&m_nIp, 2);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ pVehicle->bIsVisible = (ScriptParams[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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[0];
+ }
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[1];
+ }
+ if (infZ > supZ) {
+ infZ = *(float*)&ScriptParams[5];
+ supZ = *(float*)&ScriptParams[2];
+ }
+ int16 total;
+ CWorld::FindObjectsIntersectingCube(CVector(infX, infY, infZ), CVector(supX, supY, supZ), &total, 2, nil,
+ ScriptParams[7], ScriptParams[8], ScriptParams[9], ScriptParams[10], ScriptParams[11]);
+ UpdateCompareFlag(total > 0);
+ return 0;
+ }
case COMMAND_START_DRUG_RUN:
+ CPlane::CreateIncomingCesna();
+ return 0;
case COMMAND_HAS_DRUG_RUN_BEEN_COMPLETED:
+ UpdateCompareFlag(CPlane::HasCesnaLanded());
+ return 0;
case COMMAND_HAS_DRUG_PLANE_BEEN_SHOT_DOWN:
+ UpdateCompareFlag(CPlane::HasCesnaBeenDestroyed());
+ return 0;
case COMMAND_SAVE_PLAYER_FROM_FIRES:
+ CollectParameters(&m_nIp, 1);
+ gFireManager.ExtinguishPoint(CWorld::Players[ScriptParams[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];
+ uint16 len = CMessages::GetWideStringLength(text);
+ for (uint16 i = 0; i < len; i++)
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_Text[i] = text[i];
+ for (uint16 i = len; i < SCRIPT_TEXT_MAX_LENGTH; i++)
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_Text[i] = 0;
+ ++CTheScripts::NumberOfIntroTextLinesThisFrame;
+ return 0;
+ }
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];
+ 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]);
+ return 0;
+ }
case COMMAND_SET_TEXT_JUSTIFY:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bJustify = (ScriptParams[0] != 0);
+ return 0;
+ }
case COMMAND_SET_TEXT_CENTRE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bCentered = (ScriptParams[0] != 0);
+ return 0;
+ }
case COMMAND_SET_TEXT_WRAPX:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fWrapX = *(float*)&ScriptParams[0];
+ return 0;
+ }
case COMMAND_SET_TEXT_CENTRE_SIZE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fCenterSize = *(float*)&ScriptParams[0];
+ return 0;
+ }
case COMMAND_SET_TEXT_BACKGROUND:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bBackground = (ScriptParams[0] != 0);
+ return 0;
+ }
case COMMAND_SET_TEXT_BACKGROUND_COLOUR:
+ {
+ CollectParameters(&m_nIp, 4);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_sBackgroundColor =
+ CRGBA(ScriptParams[0], ScriptParams[1], ScriptParams[2], ScriptParams[3]);
+ return 0;
+ }
case COMMAND_SET_TEXT_BACKGROUND_ONLY_TEXT:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bBackgroundOnly = (ScriptParams[0] != 0);
+ return 0;
+ }
case COMMAND_SET_TEXT_PROPORTIONAL:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_bTextProportional = (ScriptParams[0] != 0);
+ return 0;
+ }
case COMMAND_SET_TEXT_FONT:
+ {
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_nFont = ScriptParams[0];
+ return 0;
+ }
case COMMAND_INDUSTRIAL_PASSED:
+ CStats::IndustrialPassed = true;
+ DMAudio.PlayRadioAnnouncement(13); //TODO: enum?
+ return 0;
case COMMAND_COMMERCIAL_PASSED:
+ CStats::CommercialPassed = true;
+ DMAudio.PlayRadioAnnouncement(14); //TODO: enum?
+ return 0;
case COMMAND_SUBURBAN_PASSED:
+ CStats::SuburbanPassed = true;
+ return 0;
case COMMAND_ROTATE_OBJECT:
+ {
+ CollectParameters(&m_nIp, 4);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ assert(pObject);
+ float heading = LimitAngleOnCircle(
+ RADTODEG(Atan2(-pObject->GetForward().x, pObject->GetForward().y)));
+ float headingTarget = *(float*)&ScriptParams[1];
+ float rotateBy = *(float*)&ScriptParams[2];
+ if (headingTarget == heading) { // using direct comparasion here is fine
+ UpdateCompareFlag(true);
+ return 0;
+ }
+ float angleClockwise = LimitAngleOnCircle(headingTarget - heading);
+ float angleCounterclockwise = LimitAngleOnCircle(heading - headingTarget);
+ float newHeading;
+ if (angleClockwise < angleCounterclockwise)
+ newHeading = rotateBy < angleClockwise ? heading + rotateBy : headingTarget;
+ else
+ newHeading = rotateBy < angleCounterclockwise ? heading - rotateBy : headingTarget;
+ bool obstacleInPath = false;
+ if (ScriptParams[3]) {
+ CVector pos = pObject->GetPosition();
+ tmp_matrix.SetRotateZ(DEGTORAD(newHeading));
+ tmp_matrix.GetPosition() += pos;
+ CColModel* pColModel = pObject->GetColModel();
+ CVector cp1 = tmp_matrix * pColModel->boundingBox.min;
+ CVector cp2 = tmp_matrix * CVector(pColModel->boundingBox.max.x, pColModel->boundingBox.min.y, pColModel->boundingBox.min.z);
+ CVector cp3 = tmp_matrix * CVector(pColModel->boundingBox.min.x, pColModel->boundingBox.max.y, pColModel->boundingBox.min.z);
+ CVector cp4 = tmp_matrix * CVector(pColModel->boundingBox.min.x, pColModel->boundingBox.min.y, pColModel->boundingBox.max.z);
+ int16 collisions;
+ CWorld::FindObjectsIntersectingAngledCollisionBox(pColModel->boundingBox, tmp_matrix, pos,
+ min(cp1.x, min(cp2.x, min(cp3.x, cp4.x))),
+ min(cp1.y, min(cp2.y, min(cp3.y, cp4.y))),
+ max(cp1.x, max(cp2.x, max(cp3.x, cp4.x))),
+ max(cp1.y, max(cp2.y, max(cp3.y, cp4.y))),
+ &collisions, 2, nil, false, true, true, false, false);
+ if (collisions > 0)
+ obstacleInPath = true;
+ }
+ if (obstacleInPath) {
+ UpdateCompareFlag(true);
+ return 0;
+ }
+ pObject->SetHeading(DEGTORAD(newHeading));
+ pObject->GetMatrix().UpdateRW();
+ pObject->UpdateRwFrame();
+ UpdateCompareFlag(newHeading == headingTarget); // using direct comparasion here is fine
+ return 0;
+ }
case COMMAND_SLIDE_OBJECT:
+ {
+ CollectParameters(&m_nIp, 8);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ assert(pObject);
+ CVector pos = pObject->GetPosition();
+ CVector posTarget = *(CVector*)&ScriptParams[1];
+ CVector slideBy = *(CVector*)&ScriptParams[4];
+ if (posTarget == pos) { // using direct comparasion here is fine
+ UpdateCompareFlag(true);
+ return 0;
+ }
+ CVector posDiff = pos - posTarget;
+ CVector newPosition;
+ if (posDiff.x < 0)
+ newPosition.x = -posDiff.x < slideBy.x ? posTarget.x : pos.x + slideBy.x;
+ else
+ newPosition.x = posDiff.x < slideBy.x ? posTarget.x : pos.x - slideBy.x;
+ if (posDiff.y < 0)
+ newPosition.y = -posDiff.y < slideBy.y ? posTarget.y : pos.y + slideBy.y;
+ else
+ newPosition.y = posDiff.y < slideBy.y ? posTarget.y : pos.y - slideBy.y;
+ if (posDiff.z < 0)
+ newPosition.z = -posDiff.z < slideBy.z ? posTarget.z : pos.z + slideBy.z;
+ else
+ newPosition.z = posDiff.z < slideBy.z ? posTarget.z : pos.z - slideBy.z;
+ bool obstacleInPath = false;
+ if (ScriptParams[7]) {
+ tmp_matrix = pObject->GetMatrix();
+ tmp_matrix.GetPosition() = newPosition;
+ CColModel* pColModel = pObject->GetColModel();
+ CVector cp1 = tmp_matrix * pColModel->boundingBox.min;
+ CVector cp2 = tmp_matrix * CVector(pColModel->boundingBox.max.x, pColModel->boundingBox.min.y, pColModel->boundingBox.min.z);
+ CVector cp3 = tmp_matrix * CVector(pColModel->boundingBox.min.x, pColModel->boundingBox.max.y, pColModel->boundingBox.min.z);
+ CVector cp4 = tmp_matrix * CVector(pColModel->boundingBox.min.x, pColModel->boundingBox.min.y, pColModel->boundingBox.max.z);
+ int16 collisions;
+ CWorld::FindObjectsIntersectingAngledCollisionBox(pColModel->boundingBox, tmp_matrix, pos,
+ min(cp1.x, min(cp2.x, min(cp3.x, cp4.x))),
+ min(cp1.y, min(cp2.y, min(cp3.y, cp4.y))),
+ max(cp1.x, max(cp2.x, max(cp3.x, cp4.x))),
+ max(cp1.y, max(cp2.y, max(cp3.y, cp4.y))),
+ &collisions, 2, nil, false, true, true, false, false);
+ if (collisions > 0)
+ obstacleInPath = true;
+ }
+ if (obstacleInPath) {
+ UpdateCompareFlag(true);
+ return 0;
+ }
+ pObject->Teleport(newPosition);
+ UpdateCompareFlag(newPosition == posTarget); // using direct comparasion here is fine
+ return 0;
+ }
case COMMAND_REMOVE_CHAR_ELEGANTLY:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ if (pPed && pPed->CharCreatedBy == MISSION_CHAR){
+ CWorld::RemoveReferencesToDeletedObject(pPed);
+ if (pPed->bInVehicle){
+ if (pPed->m_pMyVehicle){
+ if (pPed == pPed->m_pMyVehicle->pDriver){
+ pPed->m_pMyVehicle->RemoveDriver();
+ pPed->m_pMyVehicle->m_status = STATUS_ABANDONED;
+ if (pPed->m_pMyVehicle->m_nDoorLock == CARLOCK_LOCKED_INITIALLY)
+ pPed->m_pMyVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
+ if (pPed->m_nPedType == PEDTYPE_COP && pPed->m_pMyVehicle->IsLawEnforcementVehicle())
+ pPed->m_pMyVehicle->ChangeLawEnforcerState(0);
+ }else{
+ pPed->m_pMyVehicle->RemovePassenger(pPed);
+ }
+ }
+ delete pPed;
+ --CPopulation::ms_nTotalMissionPeds;
+ }else{
+ pPed->CharCreatedBy = RANDOM_CHAR;
+ pPed->bRespondsToThreats = true;
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->ClearLeader();
+ --CPopulation::ms_nTotalMissionPeds;
+ pPed->bFadeOut = true;
+ }
+ }
+ if (m_bIsMissionScript)
+ CTheScripts::MissionCleanup.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
+ return 0;
+ }
case COMMAND_SET_CHAR_STAY_IN_SAME_PLACE:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->bKindaStayInSamePlace = (ScriptParams[1] != 0);
+ return 0;
+ }
case COMMAND_IS_NASTY_GAME:
+ UpdateCompareFlag(CGame::nastyGame);
+ return 0;
case COMMAND_UNDRESS_CHAR:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ char name[8];
+ CTheScripts::ReadTextLabelFromScript(&m_nIp, name);
+ for (int i = 0; i < 8; i++)
+ name[i] = tolower(name[i]);
+ int mi = pPed->GetModelIndex();
+ pPed->DeleteRwObject();
+ if (pPed->IsPlayer())
+ mi = 0;
+ CStreaming::RequestSpecialModel(mi, name, STREAMFLAGS_DEPENDENCY | STREAMFLAGS_SCRIPTOWNED);
+ m_nIp += 8;
+ CWorld::Remove(pPed);
+ return 0;
+ }
case COMMAND_DRESS_CHAR:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ int mi = pPed->GetModelIndex();
+ pPed->m_modelIndex = -1;
+ pPed->SetModelIndex(mi);
+ CWorld::Add(pPed);
+ return 0;
+ }
case COMMAND_START_CHASE_SCENE:
+ CollectParameters(&m_nIp, 1);
+ CTimer::Suspend();
+ CStreaming::DeleteAllRwObjects();
+ CRecordDataForChase::StartChaseScene(*(float*)&ScriptParams[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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[4];
+ supX = *(float*)&ScriptParams[1];
+ }
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[5];
+ supY = *(float*)&ScriptParams[2];
+ }
+ if (infZ > supZ) {
+ infZ = *(float*)&ScriptParams[6];
+ supZ = *(float*)&ScriptParams[3];
+ }
+ UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0],
+ infX, supX, infY, supY, infZ, supZ));
+ return 0;
+ }
case COMMAND_IS_EXPLOSION_IN_ZONE:
+ {
+ CollectParameters(&m_nIp, 1);
+ char zone[8];
+ CTheScripts::ReadTextLabelFromScript(&m_nIp, zone);
+ int zone_id = CTheZones::FindZoneByLabelAndReturnIndex(zone);
+ if (zone_id != -1)
+ m_nIp += 8;
+ CZone* pZone = CTheZones::GetZone(zone_id);
+ UpdateCompareFlag(CExplosion::TestForExplosionInArea((eExplosionType)ScriptParams[0],
+ pZone->minx, pZone->maxx, pZone->miny, pZone->maxy, pZone->minz, pZone->maxz));
+ return 0;
+ }
case COMMAND_START_DRUG_DROP_OFF:
+ CPlane::CreateDropOffCesna();
+ return 0;
case COMMAND_HAS_DROP_OFF_PLANE_BEEN_SHOT_DOWN:
+ UpdateCompareFlag(CPlane::HasDropOffCesnaBeenShotDown());
+ return 0;
case COMMAND_FIND_DROP_OFF_PLANE_COORDINATES:
+ {
+ CVector pos = CPlane::FindDropOffCesnaCoordinates();
+ *(CVector*)&ScriptParams[0] = pos;
+ StoreParameters(&m_nIp, 3);
+ return 0;
+ }
case COMMAND_CREATE_FLOATING_PACKAGE:
+ {
+ CollectParameters(&m_nIp, 3);
+ CVector pos = *(CVector*)&ScriptParams[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);
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
case COMMAND_PLACE_OBJECT_RELATIVE_TO_CAR:
+ {
+ CollectParameters(&m_nIp, 5);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ assert(pObject);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ assert(pVehicle);
+ CVector offset = *(CVector*)&ScriptParams[2];
+ CPhysical::PlacePhysicalRelativeToOtherPhysical(pVehicle, pObject, offset);
+ return 0;
+ }
case COMMAND_MAKE_OBJECT_TARGETTABLE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ assert(pObject);
+ CPlayerPed* pPlayerPed = CWorld::Players[CWorld::PlayerInFocus].m_pPed;
+ assert(pPlayerPed);
+ pPlayerPed->MakeObjectTargettable(ScriptParams[0]);
+ return 0;
+ }
case COMMAND_ADD_ARMOUR_TO_PLAYER:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ assert(pPlayerPed);
+ pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f);
+ return 0;
+ }
case COMMAND_ADD_ARMOUR_TO_CHAR:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->m_fArmour = clamp(pPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f);
+ return 0;
+ }
case COMMAND_OPEN_GARAGE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CGarages::Garages[ScriptParams[0]].OpenThisGarage();
+ return 0;
+ }
case COMMAND_CLOSE_GARAGE:
+ {
+ CollectParameters(&m_nIp, 1);
+ CGarages::Garages[ScriptParams[0]].CloseThisGarage();
+ return 0;
+ }
case COMMAND_WARP_CHAR_FROM_CAR_TO_COORD:
+ {
+ CollectParameters(&m_nIp, 4);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ CVector pos = *(CVector*)&ScriptParams[1];
+ if (pos.z <= MAP_Z_LOW_LIMIT)
+ pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
+ if (pPed->bInVehicle){
+ if (pPed->m_pMyVehicle->bIsBus)
+ pPed->bRenderPedInCar = true;
+ if (pPed->m_pMyVehicle->pDriver == pPed){
+ pPed->m_pMyVehicle->RemoveDriver();
+ pPed->m_pMyVehicle->m_status = STATUS_ABANDONED;
+ pPed->m_pMyVehicle->bEngineOn = false;
+ pPed->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = 0;
+ }else{
+ pPed->m_pMyVehicle->RemovePassenger(pPed);
+ }
+ pPed->m_pMyVehicle->SetMoveSpeed(0.0f, 0.0f, -0.00001f);
+ pPed->m_pMyVehicle->SetTurnSpeed(0.0f, 0.0f, 0.0f);
+ }
+ pPed->bInVehicle = false;
+ pPed->m_pMyVehicle = nil;
+ pPed->SetPedState(PED_IDLE);
+ pPed->m_nLastPedState = PED_NONE;
+ pPed->bUsesCollision = true;
+ pPed->SetMoveSpeed(0.0f, 0.0f, 0.0f);
+ pPed->AddWeaponModel(CWeaponInfo::GetWeaponInfo(pPed->m_weapons[pPed->m_currentWeapon].m_eWeaponType)->m_nModelId);
+ pPed->RemoveInCarAnims();
+ if (pPed->m_pVehicleAnim)
+ pPed->m_pVehicleAnim->blendDelta = -1000.0f;
+ pPed->m_pVehicleAnim = nil;
+ pPed->RestartNonPartialAnims();
+ pPed->SetMoveState(PEDMOVE_NONE);
+ CAnimManager::BlendAnimation(pPed->GetClump(), pPed->m_animGroup, ANIM_IDLE_STANCE, 100.0f);
+ pos.z += pPed->GetDistanceFromCentreOfMassToBaseOfModel();
+ pPed->Teleport(pos);
+ CTheScripts::ClearSpaceForMissionEntity(pos, pPed);
+ return 0;
+ }
case COMMAND_SET_VISIBILITY_OF_CLOSEST_OBJECT_OF_TYPE:
+ {
+ 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 range = *(float*)&ScriptParams[3];
+ int mi = ScriptParams[4] < 0 ? CTheScripts::UsedObjectArray[-ScriptParams[4]].index : ScriptParams[4];
+ int16 total;
+ CEntity* apEntities[16];
+ CWorld::FindObjectsOfTypeInRange(mi, pos, range, true, &total, 16, apEntities, true, false, false, true, true);
+ if (total == 0)
+ CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(LEVEL_NONE), pos, range, true, &total, 16, apEntities);
+ if (total == 0)
+ CWorld::FindObjectsOfTypeInRangeSectorList(mi, CWorld::GetBigBuildingList(CTheZones::FindZoneForPoint(pos)), pos, range, true, &total, 16, apEntities);
+ CEntity* pClosestEntity = nil;
+ float min_dist = 2 * range;
+ 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) {
+ pClosestEntity->bIsVisible = (ScriptParams[5] != 0);
+ CTheScripts::AddToInvisibilitySwapArray(pClosestEntity, ScriptParams[5] != 0);
+ }
+ return 0;
+ }
case COMMAND_HAS_CHAR_SPOTTED_CHAR:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]);
+ 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]);
+ assert(pPed);
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(OBJECTIVE_HAIL_TAXI);
+ return 0;
+ }
case COMMAND_HAS_OBJECT_BEEN_DAMAGED:
+ {
+ CollectParameters(&m_nIp, 1);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ assert(pObject);
+ UpdateCompareFlag(pObject->bHasBeenDamaged || !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);
+ 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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[4];
+ supX = *(float*)&ScriptParams[2];
+ }
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[5];
+ supY = *(float*)&ScriptParams[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]);
+ return 0;
+ }
case COMMAND_WARP_PLAYER_INTO_CAR:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ assert(pPed);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ assert(pVehicle);
+ pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle);
+ pPed->WarpPedIntoCar(pVehicle);
+ return 0;
+ }
case COMMAND_WARP_CHAR_INTO_CAR:
- case COMMAND_SWITCH_CAR_RADIO:
- case COMMAND_SET_AUDIO_STREAM:
+ {
+ CollectParameters(&m_nIp, 2);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ assert(pVehicle);
+ pPed->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicle);
+ pPed->WarpPedIntoCar(pVehicle);
+ return 0;
+ }
+ //case COMMAND_SWITCH_CAR_RADIO:
+ //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);
+ 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);
+ 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);
+ 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);
+ 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]);
+ return 0;
+ }
case COMMAND_SET_CHAR_WAIT_STATE:
+ {
+ CollectParameters(&m_nIp, 3);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->SetWaitState((eWaitState)ScriptParams[1], ScriptParams[2] >= 0 ? &ScriptParams[2] : nil);
+ return 0;
+ }
case COMMAND_SET_CAMERA_BEHIND_PLAYER:
+ TheCamera.SetCameraDirectlyBehindForFollowPed_CamOnAString();
+ return 0;
case COMMAND_SET_MOTION_BLUR:
+ CollectParameters(&m_nIp, 1);
+ TheCamera.SetMotionBlur(0, 0, 0, 0, ScriptParams[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);
+ return 0;
+ }
case COMMAND_CREATE_RANDOM_CHAR:
+ {
+ CollectParameters(&m_nIp, 3);
+ CZoneInfo zoneinfo;
+ CTheZones::GetZoneInfoForTimeOfDay(&CWorld::Players[CWorld::PlayerInFocus].GetPos(), &zoneinfo);
+ int mi;
+ int pedtype = PEDTYPE_COP;
+ int attempt = 0;
+ while (pedtype != PEDTYPE_CIVMALE && pedtype != PEDTYPE_CIVFEMALE && attempt < 5) {
+ mi = CPopulation::ChooseCivilianOccupation(zoneinfo.pedGroup);
+ if (CModelInfo::GetModelInfo(mi)->GetRwObject())
+ pedtype = ((CPedModelInfo*)(CModelInfo::GetModelInfo(mi)))->m_pedType;
+ attempt++;
+ }
+ if (!CModelInfo::GetModelInfo(mi)->GetRwObject()) {
+ mi = MI_MALE01;
+ pedtype = ((CPedModelInfo*)(CModelInfo::GetModelInfo(mi)))->m_pedType;
+ }
+ CPed* ped = new CCivilianPed(pedtype, mi);
+ ped->CharCreatedBy = MISSION_CHAR;
+ ped->bRespondsToThreats = false;
+ ped->bAllowMedicsToReviveMe = false;
+ CVector pos = *(CVector*)&ScriptParams[0];
+ if (pos.z <= MAP_Z_LOW_LIMIT)
+ pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
+ pos.z += 1.0f;
+ ped->GetPosition() = pos;
+ ped->SetOrientation(0.0f, 0.0f, 0.0f);
+ CTheScripts::ClearSpaceForMissionEntity(pos, ped);
+ CWorld::Add(ped);
+ ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(pos);
+ CPopulation::ms_nTotalMissionPeds++;
+ ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
+ StoreParameters(&m_nIp, 1);
+ if (m_bIsMissionScript)
+ CTheScripts::MissionCleanup.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ return 0;
+ }
case COMMAND_SET_CHAR_OBJ_STEAL_ANY_CAR:
+ {
+ CollectParameters(&m_nIp, 1);
+ CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ assert(pPed);
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(OBJECTIVE_STEAL_ANY_CAR);
+ return 0;
+ }
case COMMAND_SET_2_REPEATED_PHONE_MESSAGES:
+ {
+ 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);
+ return 0;
+ }
case COMMAND_SET_2_PHONE_MESSAGES:
+ {
+ 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);
+ return 0;
+ }
case COMMAND_SET_3_REPEATED_PHONE_MESSAGES:
+ {
+ CollectParameters(&m_nIp, 1);
+ 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);
+ return 0;
+ }
case COMMAND_SET_3_PHONE_MESSAGES:
+ {
+ CollectParameters(&m_nIp, 1);
+ 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);
+ return 0;
+ }
case COMMAND_SET_4_REPEATED_PHONE_MESSAGES:
+ {
+ CollectParameters(&m_nIp, 1);
+ wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
+ 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);
+ return 0;
+ }
case COMMAND_SET_4_PHONE_MESSAGES:
+ {
+ CollectParameters(&m_nIp, 1);
+ wchar* text1 = CTheScripts::GetTextByKeyFromScript(&m_nIp);
+ 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);
+ 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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[0];
+ }
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[1];
+ }
+ if (infZ > supZ) {
+ infZ = *(float*)&ScriptParams[5];
+ supZ = *(float*)&ScriptParams[2];
+ }
+ UpdateCompareFlag(CBulletInfo::TestForSniperBullet(infX, supX, infY, supY, infZ, supZ));
+ return 0;
+ }
case COMMAND_GIVE_PLAYER_DETONATOR:
- case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR:
+ CGarages::GivePlayerDetonator();
+ return 0;
+ //case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR:
case COMMAND_SET_OBJECT_VELOCITY:
+ {
+ CollectParameters(&m_nIp, 4);
+ CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ assert(pObject);
+ pObject->SetMoveSpeed(*(CVector*)&ScriptParams[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]);
+ assert(pObject);
+ pObject->bUsesCollision = (ScriptParams[1] != 0);
+ return 0;
+ }
case COMMAND_IS_ICECREAM_JINGLE_ON:
+ {
+ CollectParameters(&m_nIp, 1);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ assert(pVehicle);
+ // Adding this check to correspond to command name.
+ // All original game scripts always assume that the vehicle is actually Mr. Whoopee,
+ // but maybe there are mods that use it as "is horn activated"?
+ assert(pVehicle->GetModelIndex() == MI_MRWHOOP);
+ UpdateCompareFlag(pVehicle->m_bSirenOrAlarm);
+ return 0;
+ }
default:
assert(0);
}
@@ -6840,6 +7808,34 @@ bool CTheScripts::IsVehicleStopped(CVehicle* pVehicle)
return 0.01f * CTimer::GetTimeStep() >= pVehicle->m_fDistanceTravelled;
}
+void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove)
+{
+ int i = 0;
+ bool found = false;
+ while (i < 20 && !found) {
+ if (InvisibilitySettingArray[i] == pEntity)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ if (remove)
+ InvisibilitySettingArray[i] = nil;
+ }
+ else if (!remove) {
+ int j = 0;
+ while (i < 20 && !found) {
+ if (InvisibilitySettingArray[i] == nil)
+ found = false;
+ else
+ i++;
+ }
+ if (found)
+ InvisibilitySettingArray[i] = pEntity;
+ }
+
+}
+
WRAPPER void CRunningScript::LocatePlayerCommand(int32, uint32*) { EAXJMP(0x44FE10); }
WRAPPER void CRunningScript::LocatePlayerCharCommand(int32, uint32*) { EAXJMP(0x4501E0); }
WRAPPER void CRunningScript::LocatePlayerCarCommand(int32, uint32*) { EAXJMP(0x450540); }
diff --git a/src/control/Script.h b/src/control/Script.h
index fa8344ae..b47764fc 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -114,6 +114,8 @@ public:
}
}
+ float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
+
void CollectParameters(uint32*, int16);
int32 CollectNextParameterWithoutIncreasingPC(uint32);
int32* GetPointerToScriptVariable(uint32*, int16);
@@ -374,6 +376,7 @@ public:
static void HighlightImportantArea(uint32, float, float, float, float, float);
static void DrawDebugSquare(float, float, float, float);
static void DrawDebugCube(float, float, float, float, float, float);
+ static void AddToInvisibilitySwapArray(CEntity*, bool);
static int32 Read4BytesFromScript(uint32* pIp){
int32 retval = 0;