summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/control/Darkel.cpp53
-rw-r--r--src/control/Garages.cpp38
-rw-r--r--src/control/Pickups.cpp4
-rw-r--r--src/control/Replay.cpp39
-rw-r--r--src/control/SceneEdit.cpp36
-rw-r--r--src/control/Script.cpp6
-rw-r--r--src/control/Script.h38
-rw-r--r--src/control/Script3.cpp288
-rw-r--r--src/control/Script4.cpp154
-rw-r--r--src/control/Script5.cpp788
10 files changed, 1260 insertions, 184 deletions
diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp
index afdfcb82..91d2163d 100644
--- a/src/control/Darkel.cpp
+++ b/src/control/Darkel.cpp
@@ -72,13 +72,21 @@ CDarkel::DrawMessages()
{
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
- CFont::SetCentreSize(SCREEN_SCALE_X(610.0f));
+#ifdef FIX_BUGS
+ CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 30));
+#else
+ CFont::SetCentreSize(SCREEN_WIDTH - 30);
+#endif
CFont::SetCentreOn();
CFont::SetPropOn();
uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart;
if (CDarkel::bStandardSoundAndMessages) {
if (timePassedSinceStart >= 3000 && timePassedSinceStart < 11000) {
+#ifdef FIX_BUGS
CFont::SetScale(SCREEN_SCALE_X(1.3f), SCREEN_SCALE_Y(1.3f));
+#else
+ CFont::SetScale(1.3f, 1.3f);
+#endif
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(255, 255, 128, CalcFade(timePassedSinceStart, 3000, 11000)));
CFont::SetFontStyle(FONT_BANK);
@@ -88,7 +96,11 @@ CDarkel::DrawMessages()
}
} else {
if (timePassedSinceStart < 8000) {
+#ifdef FIX_BUGS
CFont::SetScale(SCREEN_SCALE_X(1.3f), SCREEN_SCALE_Y(1.3f));
+#else
+ CFont::SetScale(1.3f, 1.3f);
+#endif
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(255, 255, 128, CalcFade(timePassedSinceStart, 0, 8000)));
CFont::SetFontStyle(FONT_BANK);
@@ -97,7 +109,11 @@ CDarkel::DrawMessages()
}
}
}
+#ifdef FIX_BUGS
CFont::SetScale(SCREEN_SCALE_X(0.75f), SCREEN_SCALE_Y(1.5f));
+#else
+ CFont::SetScale(0.75f, 1.5f);
+#endif
CFont::SetCentreOff();
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
@@ -107,7 +123,15 @@ CDarkel::DrawMessages()
AsciiToUnicode(gString, gUString);
if (timeLeft > 4000 || CTimer::GetFrameCounter() & 1) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(109.0f), gUString);
+#if defined(PS2_HUD) || defined(FIX_BUGS)
+ #ifdef FIX_BUGS
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f - 1.0f), SCREEN_SCALE_Y(108.0f + 1.0f), gUString);
+ #else -
+ CFont::PrintString(SCREEN_WIDTH-(34.0f - 1.0f), 108.0f + 1.0f, gUString);
+ #endif
+#else
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f + 1.0f), SCREEN_SCALE_Y(108.0f + 1.0f), gUString);
+#endif
CFont::SetColor(CRGBA(150, 100, 255, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f), SCREEN_SCALE_Y(108.0f), gUString);
}
@@ -120,7 +144,16 @@ CDarkel::DrawMessages()
#else
#define DARKEL_COUNTER_HEIGHT 128.0f
#endif
- CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT + 1.0f), gUString);
+
+#if defined(PS2_HUD) || defined(FIX_BUGS)
+ #ifdef FIX_BUGS
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f - 1.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT + 1.0f), gUString);
+ #else
+ CFont::PrintString(SCREEN_WIDTH-(34.0f - 1.0f), DARKEL_COUNTER_HEIGHT + 1.0f, gUString);
+ #endif
+#else
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f + 1.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT + 1.0f), gUString);
+#endif
CFont::SetColor(CRGBA(255, 128, 128, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f), SCREEN_SCALE_Y(DARKEL_COUNTER_HEIGHT), gUString);
#undef DARKEL_COUNTER_HEIGHT
@@ -132,13 +165,25 @@ CDarkel::DrawMessages()
uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart;
if (CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart < 5000) {
CFont::SetBackgroundOff();
- CFont::SetCentreSize(SCREEN_SCALE_X(620.0f));
+#ifdef FIX_BUGS
+ CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH - 20));
+#else
+ CFont::SetCentreSize(SCREEN_WIDTH - 20);
+#endif
CFont::SetCentreOn();
+#ifdef FIX_BUGS
CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f));
+#else
+ CFont::SetScale(1.5f, 1.5f);
+#endif
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(128, 255, 128, CalcFade(timePassedSinceStart, 0, 5000)));
CFont::SetFontStyle(FONT_BANK);
+#ifdef FIX_BUGS
int y = SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(25.0f - timePassedSinceStart * 0.01f);
+#else
+ int y = (SCREEN_HEIGHT / 2 + 25) - (timePassedSinceStart * 0.01f);
+#endif
CFont::PrintString(SCREEN_WIDTH / 2, y, TheText.Get("KF_3"));
}
}
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index 07fc0612..418195c7 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -1397,16 +1397,24 @@ void CGarage::RemoveCarsBlockingDoorNotInside()
void CGarages::PrintMessages()
{
if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) {
- CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); // BUG: game doesn't use macro here.
+#ifdef FIX_BUGS
+ CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f));
+#else
+ CFont::SetScale(1.2f, 1.5f);
+#endif
CFont::SetPropOn();
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
- CFont::SetCentreSize(SCREEN_SCALE_X(590.0f));
+#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_BANK));
CFont::SetColor(CRGBA(0, 0, 0, 255));
-#if defined(GTA_PS2) || defined (FIX_BUGS)
+#if defined(PS2_HUD) || defined (FIX_BUGS)
float y_offset = SCREEN_HEIGHT / 3; // THIS is PS2 calculation
#else
float y_offset = SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(84.0f); // This is PC and results in text being written over some HUD elements
@@ -1414,22 +1422,40 @@ void CGarages::PrintMessages()
if (MessageNumberInString2 >= 0) {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
-
+#else
+ CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, y_offset - 40.0f + 2.0f, gUString);
+#endif
CFont::SetColor(CRGBA(89, 115, 150, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
+#else
+ CFont::PrintString(SCREEN_WIDTH / 2, y_offset - 40.0f, gUString);
+#endif
}
else if (MessageNumberInString >= 0) {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString);
-
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
+#else
+ CFont::PrintString(SCREEN_WIDTH / 2 + 2.0f, y_offset - 40.0f + 2.0f, gUString);
+#endif
CFont::SetColor(CRGBA(89, 115, 150, 255));
+
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
+#else
+ CFont::PrintString(SCREEN_WIDTH / 2, y_offset - 40.0f, gUString);
+#endif
}
else {
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(2.0f), TheText.Get(MessageIDString));
-
+#else
+ CFont::PrintString(SCREEN_WIDTH / 2 - 2.0f, y_offset - 2.0f, TheText.Get(MessageIDString));
+#endif
CFont::SetColor(CRGBA(89, 115, 150, 255));
CFont::PrintString(SCREEN_WIDTH / 2, y_offset, TheText.Get(MessageIDString));
}
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp
index 19b3d3a7..857f74ec 100644
--- a/src/control/Pickups.cpp
+++ b/src/control/Pickups.cpp
@@ -964,7 +964,11 @@ CPickups::RenderPickUpText()
float fScaleX = aMessages[i].m_dist.x / 100.0f;
if (fScaleX > MAX_SCALE) fScaleX = MAX_SCALE;
+#ifdef FIX_BUGS
+ CFont::SetScale(SCREEN_SCALE_X(fScaleX), SCREEN_SCALE_Y(fScaleY));
+#else
CFont::SetScale(fScaleX, fScaleY);
+#endif
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_WIDTH);
CFont::SetJustifyOff();
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 4732ba2f..05880162 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1038,10 +1038,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
break;
}
case REPLAYCAMMODE_FIXED:
@@ -1057,10 +1057,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetMatrix().GetUp() = up;
TheCamera.GetMatrix().GetRight() = right;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
+ pm->pos = TheCamera.GetMatrix().GetPosition();
+ pm->at = TheCamera.GetMatrix().GetForward();
+ pm->up = TheCamera.GetMatrix().GetUp();
+ pm->right = TheCamera.GetMatrix().GetRight();
break;
}
default:
@@ -1581,10 +1581,10 @@ void CReplay::ProcessLookAroundCam(void)
TheCamera.GetRight() = right;
TheCamera.SetPosition(camera_pt);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
- pm->pos = *(RwV3d*)&TheCamera.GetPosition();
- pm->at = *(RwV3d*)&TheCamera.GetForward();
- pm->up = *(RwV3d*)&TheCamera.GetUp();
- pm->right = *(RwV3d*)&TheCamera.GetRight();
+ pm->pos = TheCamera.GetPosition();
+ pm->at = TheCamera.GetForward();
+ pm->up = TheCamera.GetUp();
+ pm->right = TheCamera.GetRight();
TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
@@ -1616,13 +1616,20 @@ void CReplay::Display()
TimeCount = (TimeCount + 1) % UINT16_MAX;
if ((TimeCount & 0x20) == 0)
return;
- CFont::SetPropOn();
- CFont::SetBackgroundOff();
+
CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f));
- CFont::SetAlignment(ALIGN_LEFT);
+ CFont::SetJustifyOff();
+ CFont::SetBackgroundOff();
+#ifdef FIX_BUGS
+ CFont::SetCentreSize(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-20));
+#else
+ CFont::SetCentreSize(SCREEN_WIDTH-20);
+#endif
+ CFont::SetCentreOff();
+ CFont::SetPropOn();
CFont::SetColor(CRGBA(255, 255, 200, 200));
CFont::SetFontStyle(FONT_BANK);
if (Mode == MODE_PLAYBACK)
- CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY"));
+ CFont::PrintString(SCREEN_WIDTH/15, SCREEN_HEIGHT/10, TheText.Get("REPLAY"));
}
#endif
diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp
index 8224c1d4..b7623133 100644
--- a/src/control/SceneEdit.cpp
+++ b/src/control/SceneEdit.cpp
@@ -279,24 +279,44 @@ void CSceneEdit::Draw(void)
#endif
sprintf(str, "Action");
AsciiToUnicode(str, wstr);
- CFont::SetColor(CRGBA(0, 0, 0, 0));
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(ACTION_MESSAGE_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(ACTION_MESSAGE_Y + SHADOW_OFFSET), wstr);
+#else
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-ACTION_MESSAGE_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-ACTION_MESSAGE_Y) + SHADOW_OFFSET, wstr);
+#endif
CFont::SetColor(CRGBA(193, 164, 120, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(ACTION_MESSAGE_X_RIGHT), SCREEN_SCALE_Y(ACTION_MESSAGE_Y), wstr);
+#else
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-ACTION_MESSAGE_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-ACTION_MESSAGE_Y), wstr);
+#endif
sprintf(str, "Selected");
AsciiToUnicode(str, wstr);
- CFont::SetColor(CRGBA(0, 0, 0, 0));
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SELECTED_MESSAGE_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(SELECTED_MESSAGE_Y + SHADOW_OFFSET), wstr);
+#else
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-SELECTED_MESSAGE_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-SELECTED_MESSAGE_Y) + SHADOW_OFFSET, wstr);
+#endif
CFont::SetColor(CRGBA(193, 164, 120, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SELECTED_MESSAGE_X_RIGHT), SCREEN_SCALE_Y(SELECTED_MESSAGE_Y), wstr);
+#else
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-SELECTED_MESSAGE_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-SELECTED_MESSAGE_Y), wstr);
+#endif
CFont::SetCentreOff();
+#ifdef FIX_BUGS
CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(0.7f));
+#else
+ CFont::SetScale(0.7f, 0.7f);
+#endif
#ifdef FIX_BUGS
CFont::SetFontStyle(FONT_BANK);
#else
CFont::SetFontStyle(FONT_HEADING);
#endif
- CFont::SetColor(CRGBA(0, 0, 0, 0));
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
for (int i = 0; i < NUM_COMMANDS_TO_DRAW; i++) {
int16 nCommandDrawn = m_nCurrentCommand + i - NUM_COMMANDS_TO_DRAW / 2;
if (nCommandDrawn >= MOVIE_TOTAL_COMMANDS)
@@ -305,13 +325,21 @@ void CSceneEdit::Draw(void)
nCommandDrawn += (MOVIE_TOTAL_COMMANDS - 1);
sprintf(str, "%s", pCommandStrings[nCommandDrawn]);
AsciiToUnicode(str, wstr);
- CFont::SetColor(CRGBA(0, 0, 0, 0));
+ CFont::SetColor(CRGBA(0, 0, 0, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(COMMAND_NAME_Y + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT), wstr);
+#else
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT) + SHADOW_OFFSET, SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + SHADOW_OFFSET + i * COMMAND_NAME_HEIGHT), wstr);
+#endif
if (nCommandDrawn == m_nCurrentCommand)
CFont::SetColor(CRGBA(156, 91, 40, 255));
else
CFont::SetColor(CRGBA(193, 164, 120, 255));
+#ifdef FIX_BUGS
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT), SCREEN_SCALE_Y(COMMAND_NAME_Y + i * COMMAND_NAME_HEIGHT), wstr);
+#else
+ CFont::PrintString(SCREEN_SCALE_X(DEFAULT_SCREEN_WIDTH-COMMAND_NAME_X_RIGHT), SCREEN_SCALE_FROM_BOTTOM(DEFAULT_SCREEN_HEIGHT-COMMAND_NAME_Y) + i * COMMAND_NAME_HEIGHT), wstr);
+#endif
}
}
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 67d2e618..6aa48d81 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -58,7 +58,7 @@ int32 CTheScripts::StoreVehicleIndex;
bool CTheScripts::StoreVehicleWasRandom;
CRunningScript *CTheScripts::pIdleScripts;
CRunningScript *CTheScripts::pActiveScripts;
-uint32 CTheScripts::NextFreeCollectiveIndex;
+int32 CTheScripts::NextFreeCollectiveIndex;
int32 CTheScripts::LastRandomPedId;
uint16 CTheScripts::NumberOfUsedObjects;
bool CTheScripts::bAlreadyRunningAMissionScript;
@@ -1810,8 +1810,8 @@ void CTheScripts::Init()
OnAMissionForContactFlag[i] = 0;
}
for (int i = 0; i < MAX_NUM_COLLECTIVES; i++){
- CollectiveArray[i].index = -1;
- CollectiveArray[i].unk_data = 0;
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
}
NextFreeCollectiveIndex = 0;
LastRandomPedId = -1;
diff --git a/src/control/Script.h b/src/control/Script.h
index 7fc18727..1c4663ce 100644
--- a/src/control/Script.h
+++ b/src/control/Script.h
@@ -1,5 +1,6 @@
#pragma once
#include "common.h"
+#include "Ped.h"
#include "PedType.h"
#include "Text.h"
#include "Sprite2d.h"
@@ -38,6 +39,10 @@ void FlushLog();
#define KEY_LENGTH_IN_SCRIPT 8
+#if GTA_VERSION <= GTA_PS2_160
+#define GTA_SCRIPT_COLLECTIVE
+#endif
+
struct intro_script_rectangle
{
bool m_bIsUsed;
@@ -213,8 +218,8 @@ enum {
struct tCollectiveData
{
- int32 index;
- uint32 unk_data;
+ int32 colIndex;
+ int32 pedIndex;
};
enum {
@@ -286,7 +291,7 @@ class CTheScripts
static bool StoreVehicleWasRandom;
static CRunningScript *pIdleScripts;
static CRunningScript *pActiveScripts;
- static uint32 NextFreeCollectiveIndex;
+ static int32 NextFreeCollectiveIndex;
static int32 LastRandomPedId;
static uint16 NumberOfUsedObjects;
static bool bAlreadyRunningAMissionScript;
@@ -393,6 +398,25 @@ private:
static int32 GetNewUniqueScriptSphereIndex(int32 index);
static void RemoveScriptSphere(int32 index);
+#ifdef GTA_SCRIPT_COLLECTIVE
+ static void AdvanceCollectiveIndex()
+ {
+ if (NextFreeCollectiveIndex == INT32_MAX)
+ NextFreeCollectiveIndex = 0;
+ else
+ NextFreeCollectiveIndex++;
+ }
+
+ static int AddPedsInVehicleToCollective(int);
+ static int AddPedsInAreaToCollective(float, float, float, float);
+ static int FindFreeSlotInCollectiveArray();
+ static void SetObjectiveForAllPedsInCollective(int, eObjective, int16, int16);
+ static void SetObjectiveForAllPedsInCollective(int, eObjective, CVector, float);
+ static void SetObjectiveForAllPedsInCollective(int, eObjective, CVector);
+ static void SetObjectiveForAllPedsInCollective(int, eObjective, void*);
+ static void SetObjectiveForAllPedsInCollective(int, eObjective);
+#endif
+
friend class CRunningScript;
friend class CHud;
friend void CMissionCleanup::Process();
@@ -511,6 +535,14 @@ private:
void CharInAreaCheckCommand(int32, uint32*);
void CarInAreaCheckCommand(int32, uint32*);
+#ifdef GTA_SCRIPT_COLLECTIVE
+ void LocateCollectiveCommand(int32, uint32*);
+ void LocateCollectiveCharCommand(int32, uint32*);
+ void LocateCollectiveCarCommand(int32, uint32*);
+ void LocateCollectivePlayerCommand(int32, uint32*);
+ void CollectiveInAreaCheckCommand(int32, uint32*);
+#endif
+
#ifdef MISSION_REPLAY
bool CanAllowMissionReplay();
#endif
diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp
index 1f1ed537..9a37cb6c 100644
--- a/src/control/Script3.cpp
+++ b/src/control/Script3.cpp
@@ -853,7 +853,12 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_PLAYING);
return 0;
}
- //case COMMAND_SET_COLL_OBJ_NO_OBJ:
+#ifdef GTA_SCRIPT_COLLECTIVE
+ case COMMAND_SET_COLL_OBJ_NO_OBJ:
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_NONE);
+ return 0;
+#endif
default:
script_assert(0);
}
@@ -863,65 +868,314 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
int8 CRunningScript::ProcessCommands600To699(int32 command)
{
switch (command){
- /* Collective commands are not implemented until LCS.
+#ifdef GTA_SCRIPT_COLLECTIVE
case COMMAND_SET_COLL_OBJ_WAIT_ON_FOOT:
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[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);
+ return 0;
case COMMAND_SET_COLL_OBJ_GUARD_SPOT:
+ {
+ CollectParameters(&m_nIp, 4);
+ CVector pos = *(CVector*)&ScriptParams[1];
+ if (pos.z <= MAP_Z_LOW_LIMIT)
+ pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[1];
+ }
+ float infY = *(float*)&ScriptParams[2];
+ float supY = *(float*)&ScriptParams[4];
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[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);
+ return 0;
+ }
case COMMAND_SET_COLL_OBJ_WAIT_IN_CAR:
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ 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);
+ return 0;
+ }
case COMMAND_SET_COLL_OBJ_LEAVE_CAR:
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[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);
+ 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);
+ return 0;
+ }
+ /*
case COMMAND_SET_COLL_OBJ_FOLLOW_CAR_IN_CAR:
case COMMAND_SET_COLL_OBJ_FIRE_AT_OBJECT_FROM_VEHICLE:
case COMMAND_SET_COLL_OBJ_DESTROY_OBJECT:
+ */
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);
+ 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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[1];
+ }
+ float infY = *(float*)&ScriptParams[2];
+ float supY = *(float*)&ScriptParams[4];
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[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);
+ return 0;
+ }
+ /*
case COMMAND_SET_COLL_OBJ_GOTO_AREA_IN_CAR:
case COMMAND_SET_COLL_OBJ_FOLLOW_CAR_ON_FOOT_WITH_OFFSET:
case COMMAND_SET_COLL_OBJ_GUARD_ATTACK:
+ */
case COMMAND_SET_COLL_OBJ_FOLLOW_ROUTE:
+ CollectParameters(&m_nIp, 3);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_FOLLOW_ROUTE, ScriptParams[1], ScriptParams[2]);
+ return 0;
case COMMAND_SET_COLL_OBJ_GOTO_COORD_ON_FOOT:
- case COMMAND_SET_COLL_OBJ_GOTO_COORD_IN_CAR:
+ {
+ 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);
+ 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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[1];
+ }
+ float infY = *(float*)&ScriptParams[2];
+ float supY = *(float*)&ScriptParams[4];
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[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);
+ 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);
+ 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 Z = CWorld::FindGroundZForCoord(X, Y);
+ float radius = *(float*)&ScriptParams[2];
+ ScriptParams[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]);
+ 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]) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ }
+ }
+ return 0;
case COMMAND_IS_COLL_IN_CARS:
+ {
+ CollectParameters(&m_nIp, 1);
+ bool result = true;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ result = false;
+ break;
+ }
+ }
+ UpdateCompareFlag(result);
+ return 0;
+ }
case COMMAND_LOCATE_COLL_ANY_MEANS_2D:
case COMMAND_LOCATE_COLL_ON_FOOT_2D:
case COMMAND_LOCATE_COLL_IN_CAR_2D:
case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D:
case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D:
case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D:
+ LocateCollectiveCommand(command, &m_nIp);
+ return 0;
case COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D:
case COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D:
case COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D:
+ LocateCollectiveCharCommand(command, &m_nIp);
+ return 0;
case COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D:
case COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D:
case COMMAND_LOCATE_COLL_IN_CAR_CAR_2D:
+ LocateCollectiveCarCommand(command, &m_nIp);
+ return 0;
case COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D:
case COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D:
case COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D:
+ LocateCollectivePlayerCommand(command, &m_nIp);
+ return 0;
case COMMAND_IS_COLL_IN_AREA_2D:
case COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D:
case COMMAND_IS_COLL_IN_AREA_IN_CAR_2D:
case COMMAND_IS_COLL_STOPPED_IN_AREA_2D:
case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D:
case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D:
+ CollectiveInAreaCheckCommand(command, &m_nIp);
+ return 0;
case COMMAND_GET_NUMBER_OF_PEDS_IN_COLL:
- */
+ {
+ CollectParameters(&m_nIp, 1);
+ int total = 0;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ total++;
+ }
+ }
+ ScriptParams[0] = total;
+ StoreParameters(&m_nIp, 1);
+ return 0;
+ }
+#endif
case COMMAND_SET_CHAR_HEED_THREATS:
{
CollectParameters(&m_nIp, 2);
@@ -1046,7 +1300,31 @@ int8 CRunningScript::ProcessCommands600To699(int32 command)
pPed->SetObjective(OBJECTIVE_GOTO_AREA_ANY_MEANS, pos, radius);
return 0;
}
- //case COMMAND_SET_COLL_OBJ_GOTO_AREA_ANY_MEANS:
+#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];
+ if (infX > supX) {
+ infX = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[1];
+ }
+ float infY = *(float*)&ScriptParams[2];
+ float supY = *(float*)&ScriptParams[4];
+ if (infY > supY) {
+ infY = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[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);
+ return 0;
+ }
+#endif
case COMMAND_IS_PLAYER_STOPPED:
{
CollectParameters(&m_nIp, 1);
diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp
index 3629bb4b..986e82f8 100644
--- a/src/control/Script4.cpp
+++ b/src/control/Script4.cpp
@@ -244,7 +244,12 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
pPed->SetObjective(OBJECTIVE_CATCH_TRAIN);
return 0;
}
- //case COMMAND_SET_COLL_OBJ_CATCH_TRAIN:
+#ifdef GTA_SCRIPT_COLLECTIVE
+ case COMMAND_SET_COLL_OBJ_CATCH_TRAIN:
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_CATCH_TRAIN);
+ return 0;
+#endif
case COMMAND_SET_PLAYER_NEVER_GETS_TIRED:
{
CollectParameters(&m_nIp, 2);
@@ -1090,7 +1095,12 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
case COMMAND_GIVE_PLAYER_DETONATOR:
CGarages::GivePlayerDetonator();
return 0;
- //case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR:
+#ifdef GTA_SCRIPT_COLLECTIVE
+ case COMMAND_SET_COLL_OBJ_STEAL_ANY_CAR:
+ CollectParameters(&m_nIp, 1);
+ CTheScripts::SetObjectiveForAllPedsInCollective(ScriptParams[0], OBJECTIVE_STEAL_ANY_CAR);
+ return 0;
+#endif
case COMMAND_SET_OBJECT_VELOCITY:
{
CollectParameters(&m_nIp, 4);
@@ -2025,3 +2035,143 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
}
return -1;
}
+
+int32 CTheScripts::GetNewUniqueScriptSphereIndex(int32 index)
+{
+ if (ScriptSphereArray[index].m_Index >= UINT16_MAX - 1)
+ ScriptSphereArray[index].m_Index = 1;
+ else
+ ScriptSphereArray[index].m_Index++;
+ return (uint16)index | ScriptSphereArray[index].m_Index << 16;
+}
+
+int32 CTheScripts::GetActualScriptSphereIndex(int32 index)
+{
+ if (index == -1)
+ return -1;
+ uint16 check = (uint32)index >> 16;
+ uint16 array_idx = index & (0xFFFF);
+ script_assert(array_idx < ARRAY_SIZE(ScriptSphereArray));
+ if (check != ScriptSphereArray[array_idx].m_Index)
+ return -1;
+ return array_idx;
+}
+
+void CTheScripts::DrawScriptSpheres()
+{
+ for (int i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
+ if (ScriptSphereArray[i].m_bInUse)
+ C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, MARKERTYPE_CYLINDER, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius,
+ SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0);
+ }
+}
+
+int32 CTheScripts::AddScriptSphere(int32 id, CVector pos, float radius)
+{
+ int16 i = 0;
+ for (i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
+ if (!ScriptSphereArray[i].m_bInUse)
+ break;
+ }
+#ifdef FIX_BUGS
+ if (i == MAX_NUM_SCRIPT_SPHERES)
+ return -1;
+#endif
+ ScriptSphereArray[i].m_bInUse = true;
+ ScriptSphereArray[i].m_Id = id;
+ ScriptSphereArray[i].m_vecCenter = pos;
+ ScriptSphereArray[i].m_fRadius = radius;
+ return GetNewUniqueScriptSphereIndex(i);
+}
+
+void CTheScripts::RemoveScriptSphere(int32 index)
+{
+ index = GetActualScriptSphereIndex(index);
+ if (index == -1)
+ return;
+ ScriptSphereArray[index].m_bInUse = false;
+ ScriptSphereArray[index].m_Id = 0;
+}
+
+void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model)
+{
+ int i = 0;
+ bool found = false;
+ while (i < MAX_NUM_BUILDING_SWAPS && !found) {
+ if (BuildingSwapArray[i].m_pBuilding == pBuilding)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ if (BuildingSwapArray[i].m_nOldModel == new_model) {
+ BuildingSwapArray[i].m_pBuilding = nil;
+ BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
+ }
+ else {
+ BuildingSwapArray[i].m_nNewModel = new_model;
+ }
+ }
+ else {
+ i = 0;
+ while (i < MAX_NUM_BUILDING_SWAPS && !found) {
+ if (BuildingSwapArray[i].m_pBuilding == nil)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ BuildingSwapArray[i].m_pBuilding = pBuilding;
+ BuildingSwapArray[i].m_nNewModel = new_model;
+ BuildingSwapArray[i].m_nOldModel = old_model;
+ }
+ }
+}
+
+void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove)
+{
+ int i = 0;
+ bool found = false;
+ while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
+ if (InvisibilitySettingArray[i] == pEntity)
+ found = true;
+ else
+ i++;
+ }
+ if (found) {
+ if (remove)
+ InvisibilitySettingArray[i] = nil;
+ }
+ else if (!remove) {
+ i = 0;
+ while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
+ if (InvisibilitySettingArray[i] == nil)
+ found = true;
+ else
+ i++;
+ }
+ if (found)
+ InvisibilitySettingArray[i] = pEntity;
+ }
+}
+
+void CTheScripts::UndoBuildingSwaps()
+{
+ for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
+ if (BuildingSwapArray[i].m_pBuilding) {
+ BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nOldModel);
+ BuildingSwapArray[i].m_pBuilding = nil;
+ BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
+ }
+ }
+}
+
+void CTheScripts::UndoEntityInvisibilitySettings()
+{
+ for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
+ if (InvisibilitySettingArray[i]) {
+ InvisibilitySettingArray[i]->bIsVisible = true;
+ InvisibilitySettingArray[i] = nil;
+ }
+ }
+}
diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp
index 4826192e..c7e190ac 100644
--- a/src/control/Script5.cpp
+++ b/src/control/Script5.cpp
@@ -17,147 +17,6 @@
#include "World.h"
#include "main.h"
-int32 CTheScripts::GetNewUniqueScriptSphereIndex(int32 index)
-{
- if (ScriptSphereArray[index].m_Index >= UINT16_MAX - 1)
- ScriptSphereArray[index].m_Index = 1;
- else
- ScriptSphereArray[index].m_Index++;
- return (uint16)index | ScriptSphereArray[index].m_Index << 16;
-}
-
-int32 CTheScripts::GetActualScriptSphereIndex(int32 index)
-{
- if (index == -1)
- return -1;
- uint16 check = (uint32)index >> 16;
- uint16 array_idx = index & (0xFFFF);
- script_assert(array_idx < ARRAY_SIZE(ScriptSphereArray));
- if (check != ScriptSphereArray[array_idx].m_Index)
- return -1;
- return array_idx;
-}
-
-void CTheScripts::DrawScriptSpheres()
-{
- for (int i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
- if (ScriptSphereArray[i].m_bInUse)
- C3dMarkers::PlaceMarkerSet(ScriptSphereArray[i].m_Id, MARKERTYPE_CYLINDER, ScriptSphereArray[i].m_vecCenter, ScriptSphereArray[i].m_fRadius,
- SPHERE_MARKER_R, SPHERE_MARKER_G, SPHERE_MARKER_B, SPHERE_MARKER_A, SPHERE_MARKER_PULSE_PERIOD, SPHERE_MARKER_PULSE_FRACTION, 0);
- }
-}
-
-int32 CTheScripts::AddScriptSphere(int32 id, CVector pos, float radius)
-{
- int16 i = 0;
- for (i = 0; i < MAX_NUM_SCRIPT_SPHERES; i++) {
- if (!ScriptSphereArray[i].m_bInUse)
- break;
- }
-#ifdef FIX_BUGS
- if (i == MAX_NUM_SCRIPT_SPHERES)
- return -1;
-#endif
- ScriptSphereArray[i].m_bInUse = true;
- ScriptSphereArray[i].m_Id = id;
- ScriptSphereArray[i].m_vecCenter = pos;
- ScriptSphereArray[i].m_fRadius = radius;
- return GetNewUniqueScriptSphereIndex(i);
-}
-
-void CTheScripts::RemoveScriptSphere(int32 index)
-{
- index = GetActualScriptSphereIndex(index);
- if (index == -1)
- return;
- ScriptSphereArray[index].m_bInUse = false;
- ScriptSphereArray[index].m_Id = 0;
-}
-
-void CTheScripts::AddToBuildingSwapArray(CBuilding* pBuilding, int32 old_model, int32 new_model)
-{
- int i = 0;
- bool found = false;
- while (i < MAX_NUM_BUILDING_SWAPS && !found) {
- if (BuildingSwapArray[i].m_pBuilding == pBuilding)
- found = true;
- else
- i++;
- }
- if (found) {
- if (BuildingSwapArray[i].m_nOldModel == new_model) {
- BuildingSwapArray[i].m_pBuilding = nil;
- BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
- }
- else {
- BuildingSwapArray[i].m_nNewModel = new_model;
- }
- }
- else {
- i = 0;
- while (i < MAX_NUM_BUILDING_SWAPS && !found) {
- if (BuildingSwapArray[i].m_pBuilding == nil)
- found = true;
- else
- i++;
- }
- if (found) {
- BuildingSwapArray[i].m_pBuilding = pBuilding;
- BuildingSwapArray[i].m_nNewModel = new_model;
- BuildingSwapArray[i].m_nOldModel = old_model;
- }
- }
-}
-
-void CTheScripts::AddToInvisibilitySwapArray(CEntity* pEntity, bool remove)
-{
- int i = 0;
- bool found = false;
- while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
- if (InvisibilitySettingArray[i] == pEntity)
- found = true;
- else
- i++;
- }
- if (found) {
- if (remove)
- InvisibilitySettingArray[i] = nil;
- }
- else if (!remove) {
- i = 0;
- while (i < MAX_NUM_INVISIBILITY_SETTINGS && !found) {
- if (InvisibilitySettingArray[i] == nil)
- found = true;
- else
- i++;
- }
- if (found)
- InvisibilitySettingArray[i] = pEntity;
- }
-}
-
-void CTheScripts::UndoBuildingSwaps()
-{
- for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) {
- if (BuildingSwapArray[i].m_pBuilding) {
- BuildingSwapArray[i].m_pBuilding->ReplaceWithNewModel(BuildingSwapArray[i].m_nOldModel);
- BuildingSwapArray[i].m_pBuilding = nil;
- BuildingSwapArray[i].m_nOldModel = BuildingSwapArray[i].m_nNewModel = -1;
- }
- }
-}
-
-void CTheScripts::UndoEntityInvisibilitySettings()
-{
- for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++) {
- if (InvisibilitySettingArray[i]) {
- InvisibilitySettingArray[i]->bIsVisible = true;
- InvisibilitySettingArray[i] = nil;
- }
- }
-}
-
-
void CRunningScript::UpdateCompareFlag(bool flag)
{
if (m_bNotFlag)
@@ -1445,6 +1304,487 @@ int16 CRunningScript::GetPadState(uint16 pad, uint16 button)
return 0;
}
+#ifdef GTA_SCRIPT_COLLECTIVE
+void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp)
+{
+ bool b3D, result, debug, decided = false;
+ float X, Y, Z, dX, dY, dZ;
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_2D:
+ case COMMAND_LOCATE_COLL_ON_FOOT_2D:
+ case COMMAND_LOCATE_COLL_IN_CAR_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D:
+ b3D = false;
+ break;
+ default:
+ b3D = true;
+ break;
+ }
+ CollectParameters(pIp, b3D ? 8 : 6);
+ X = *(float*)&ScriptParams[1];
+ Y = *(float*)&ScriptParams[2];
+ if (b3D) {
+ Z = *(float*)&ScriptParams[3];
+ dX = *(float*)&ScriptParams[4];
+ dY = *(float*)&ScriptParams[5];
+ dZ = *(float*)&ScriptParams[6];
+ debug = ScriptParams[7];
+ }
+ else {
+ dX = *(float*)&ScriptParams[3];
+ dY = *(float*)&ScriptParams[4];
+ debug = ScriptParams[5];
+ }
+ result = true;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
+ if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ continue;
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ continue;
+ }
+ CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
+ switch (command) {
+ case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D:
+ if (!CTheScripts::IsPedStopped(pPed)) {
+ result = false;
+ decided = true;
+ }
+ break;
+ default:
+ break;
+ }
+ if (!decided) {
+ 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;
+ }
+ result = false;
+ if (in_area) {
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_ANY_MEANS_2D:
+ result = true;
+ break;
+ case COMMAND_LOCATE_COLL_ON_FOOT_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_ON_FOOT_2D:
+ result = !pPed->bInVehicle;
+ break;
+ case COMMAND_LOCATE_COLL_IN_CAR_2D:
+ case COMMAND_LOCATE_STOPPED_COLL_IN_CAR_2D:
+ result = pPed->bInVehicle;
+ break;
+ default:
+ script_assert(false);
+ break;
+ }
+ }
+ }
+ }
+ 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::LocateCollectiveCharCommand(int32 command, uint32* pIp)
+{
+ bool b3D, result, debug;
+ float X, Y, Z, dX, dY, dZ;
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D:
+ case COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D:
+ case COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D:
+ b3D = false;
+ break;
+ default:
+ b3D = true;
+ break;
+ }
+ CollectParameters(pIp, b3D ? 6 : 5);
+ CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]);
+ script_assert(pTarget);
+ if (pTarget->bInVehicle) {
+ X = pTarget->m_pMyVehicle->GetPosition().x;
+ Y = pTarget->m_pMyVehicle->GetPosition().y;
+ Z = pTarget->m_pMyVehicle->GetPosition().z;
+ }
+ else {
+ X = pTarget->GetPosition().x;
+ Y = pTarget->GetPosition().y;
+ Z = pTarget->GetPosition().z;
+ }
+ dX = *(float*)&ScriptParams[2];
+ dY = *(float*)&ScriptParams[3];
+ if (b3D) {
+ dZ = *(float*)&ScriptParams[4];
+ debug = ScriptParams[5];
+ }
+ else {
+ debug = ScriptParams[4];
+ }
+ result = true;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
+ if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ continue;
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ continue;
+ }
+ CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
+ 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;
+ }
+ result = false;
+ if (in_area) {
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_CHAR_2D:
+ result = true;
+ break;
+ case COMMAND_LOCATE_COLL_ON_FOOT_CHAR_2D:
+ result = !pPed->bInVehicle;
+ break;
+ case COMMAND_LOCATE_COLL_IN_CAR_CHAR_2D:
+ result = pPed->bInVehicle;
+ break;
+ default:
+ script_assert(false);
+ break;
+ }
+ }
+ }
+ 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)
+{
+ bool b3D, result, debug;
+ float X, Y, Z, dX, dY, dZ;
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D:
+ case COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D:
+ case COMMAND_LOCATE_COLL_IN_CAR_CAR_2D:
+ b3D = false;
+ break;
+ default:
+ b3D = true;
+ break;
+ }
+ CollectParameters(pIp, b3D ? 6 : 5);
+ CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ script_assert(pTarget);
+ X = pTarget->GetPosition().x;
+ Y = pTarget->GetPosition().y;
+ Z = pTarget->GetPosition().z;
+ dX = *(float*)&ScriptParams[2];
+ dY = *(float*)&ScriptParams[3];
+ if (b3D) {
+ dZ = *(float*)&ScriptParams[4];
+ debug = ScriptParams[5];
+ }
+ else {
+ debug = ScriptParams[4];
+ }
+ result = true;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
+ if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ continue;
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ continue;
+ }
+ CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
+ 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;
+ }
+ result = false;
+ if (in_area) {
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_CAR_2D:
+ result = true;
+ break;
+ case COMMAND_LOCATE_COLL_ON_FOOT_CAR_2D:
+ result = !pPed->bInVehicle;
+ break;
+ case COMMAND_LOCATE_COLL_IN_CAR_CAR_2D:
+ result = pPed->bInVehicle;
+ break;
+ default:
+ script_assert(false);
+ break;
+ }
+ }
+ }
+ 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)
+{
+ bool b3D, result, debug;
+ float X, Y, Z, dX, dY, dZ;
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D:
+ case COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D:
+ case COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D:
+ b3D = false;
+ break;
+ default:
+ b3D = true;
+ break;
+ }
+ CollectParameters(pIp, b3D ? 6 : 5);
+ CVector pos = CWorld::Players[ScriptParams[1]].GetPos();
+ X = pos.x;
+ Y = pos.y;
+ Z = pos.z;
+ dX = *(float*)&ScriptParams[2];
+ dY = *(float*)&ScriptParams[3];
+ if (b3D) {
+ dZ = *(float*)&ScriptParams[4];
+ debug = ScriptParams[5];
+ }
+ else {
+ debug = ScriptParams[4];
+ }
+ result = true;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
+ if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ continue;
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ continue;
+ }
+ CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
+ 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;
+ }
+ result = false;
+ if (in_area) {
+ switch (command) {
+ case COMMAND_LOCATE_COLL_ANY_MEANS_PLAYER_2D:
+ result = true;
+ break;
+ case COMMAND_LOCATE_COLL_ON_FOOT_PLAYER_2D:
+ result = !pPed->bInVehicle;
+ break;
+ case COMMAND_LOCATE_COLL_IN_CAR_PLAYER_2D:
+ result = pPed->bInVehicle;
+ break;
+ default:
+ script_assert(false);
+ break;
+ }
+ }
+ }
+ 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)
+{
+ bool b3D, result, debug, decided = false;
+ float infX, infY, infZ, supX, supY, supZ;
+ switch (command) {
+ case COMMAND_IS_COLL_IN_AREA_2D:
+ case COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D:
+ case COMMAND_IS_COLL_IN_AREA_IN_CAR_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D:
+ b3D = false;
+ break;
+ default:
+ b3D = true;
+ break;
+ }
+ CollectParameters(pIp, b3D ? 8 : 6);
+ infX = *(float*)&ScriptParams[1];
+ infY = *(float*)&ScriptParams[2];
+ if (b3D) {
+ infZ = *(float*)&ScriptParams[3];
+ supX = *(float*)&ScriptParams[4];
+ supY = *(float*)&ScriptParams[5];
+ supZ = *(float*)&ScriptParams[6];
+ if (infZ > supZ) {
+ infZ = *(float*)&ScriptParams[6];
+ supZ = *(float*)&ScriptParams[3];
+ }
+ debug = ScriptParams[7];
+ }
+ else {
+ supX = *(float*)&ScriptParams[3];
+ supY = *(float*)&ScriptParams[4];
+ debug = ScriptParams[5];
+ }
+ if (infX > supX) {
+ float tmp = infX;
+ infX = supX;
+ supX = tmp;
+ }
+ if (infY > supY) {
+ float tmp = infY;
+ infY = supY;
+ supY = tmp;
+ }
+ result = true;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) {
+ if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex)
+ continue;
+ CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex);
+ if (!pPed) {
+ CTheScripts::CollectiveArray[i].colIndex = -1;
+ CTheScripts::CollectiveArray[i].pedIndex = 0;
+ continue;
+ }
+ CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition();
+ switch (command) {
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D:
+ if (!CTheScripts::IsPedStopped(pPed)) {
+ result = false;
+ decided = true;
+ }
+ break;
+ default:
+ break;
+ }
+ if (!decided) {
+ bool in_area;
+ if (b3D) {
+ in_area = infX <= pos.x &&
+ supX >= pos.x &&
+ infY <= pos.y &&
+ supY >= pos.y &&
+ infZ <= pos.z &&
+ supZ >= pos.z;
+ }
+ else {
+ in_area = infX <= pos.x &&
+ supX >= pos.x &&
+ infY <= pos.y &&
+ supY >= pos.y;
+ }
+ result = false;
+ if (in_area) {
+ switch (command) {
+ case COMMAND_IS_COLL_IN_AREA_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_2D:
+ result = true;
+ break;
+ case COMMAND_IS_COLL_IN_AREA_ON_FOOT_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_ON_FOOT_2D:
+ result = !pPed->bInVehicle;
+ break;
+ case COMMAND_IS_COLL_IN_AREA_IN_CAR_2D:
+ case COMMAND_IS_COLL_STOPPED_IN_AREA_IN_CAR_2D:
+ result = pPed->bInVehicle;
+ break;
+ default:
+ script_assert(false);
+ break;
+ }
+ }
+ }
+ }
+ 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
void CTheScripts::PrintListSizes()
{
@@ -1858,6 +2198,172 @@ void CTheScripts::HighlightImportantAngledArea(uint32 id, float x1, float y1, fl
CShadows::RenderIndicatorShadow(id, 2, gpGoalTex, &center, supX - center.x, 0.0f, 0.0f, center.y - supY, 0);
}
+#ifdef GTA_SCRIPT_COLLECTIVE
+int CTheScripts::AddPedsInVehicleToCollective(int index)
+{
+ int colIndex = NextFreeCollectiveIndex;
+ AdvanceCollectiveIndex();
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(index);
+ script_assert(pVehicle);
+ CPed* pDriver = pVehicle->pDriver;
+ if (pDriver && !pDriver->IsPlayer() && pDriver->CharCreatedBy != MISSION_CHAR && pDriver->m_nPedType != PEDTYPE_COP) {
+ int index = FindFreeSlotInCollectiveArray();
+ if (index > -1) {
+ CollectiveArray[index].colIndex = colIndex;
+ CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pDriver);
+ }
+ }
+ for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) {
+ CPed* pPassenger = pVehicle->pPassengers[i];
+ if (pPassenger && !pPassenger->IsPlayer() && pPassenger->CharCreatedBy != MISSION_CHAR && pPassenger->m_nPedType != PEDTYPE_COP) {
+ int index = FindFreeSlotInCollectiveArray();
+ if (index > -1) {
+ CollectiveArray[index].colIndex = colIndex;
+ CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pPassenger);
+ }
+ }
+ }
+ return colIndex;
+}
+
+int CTheScripts::AddPedsInAreaToCollective(float x, float y, float z, float radius)
+{
+ int16 numFound;
+ CEntity* pEntities[64];
+ int colIndex = NextFreeCollectiveIndex;
+ AdvanceCollectiveIndex();
+ CWorld::FindObjectsInRange(CVector(x, y, z), radius, true, &numFound, 64, pEntities, false, true, true, false, false);
+ for (int16 i = 0; i < numFound; i++) {
+ if (pEntities[i]->GetType() == ENTITY_TYPE_PED) {
+ CPed* pPed = (CPed*)pEntities[i];
+ if (pPed && !pPed->IsPlayer() && pPed->CharCreatedBy != MISSION_CHAR && pPed->m_nPedType != PEDTYPE_COP) {
+ int index = FindFreeSlotInCollectiveArray();
+ if (index > -1) {
+ CollectiveArray[index].colIndex = colIndex;
+ CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pPed);
+ }
+ }
+ }
+ else if (pEntities[i]->GetType() == ENTITY_TYPE_VEHICLE) {
+ CVehicle* pVehicle = (CVehicle*)pEntities[i];
+ CPed* pDriver = pVehicle->pDriver;
+ if (pDriver && !pDriver->IsPlayer() && pDriver->CharCreatedBy != MISSION_CHAR && pDriver->m_nPedType != PEDTYPE_COP) {
+ int index = FindFreeSlotInCollectiveArray();
+ if (index > -1) {
+ CollectiveArray[index].colIndex = colIndex;
+ CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pDriver);
+ }
+ }
+ for (int i = 0; i < pVehicle->m_nNumMaxPassengers; i++) {
+ CPed* pPassenger = pVehicle->pPassengers[i];
+ if (pPassenger && !pPassenger->IsPlayer() && pPassenger->CharCreatedBy != MISSION_CHAR && pPassenger->m_nPedType != PEDTYPE_COP) {
+ int index = FindFreeSlotInCollectiveArray();
+ if (index > -1) {
+ CollectiveArray[index].colIndex = colIndex;
+ CollectiveArray[index].pedIndex = CPools::GetPedPool()->GetIndex(pPassenger);
+ }
+ }
+ }
+ }
+ }
+ return colIndex;
+}
+
+int CTheScripts::FindFreeSlotInCollectiveArray()
+{
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ if (CollectiveArray[i].colIndex == -1)
+ return i;
+ }
+ return -1;
+}
+
+void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, int16 p1, int16 p2)
+{
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ if (CollectiveArray[i].colIndex = colIndex) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
+ if (pPed == nil) {
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(objective, p1, p2);
+ }
+ }
+ }
+}
+
+void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1, float p2)
+{
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ if (CollectiveArray[i].colIndex = colIndex) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
+ if (pPed == nil) {
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(objective, p1, p2);
+ }
+ }
+ }
+}
+
+void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, CVector p1)
+{
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ if (CollectiveArray[i].colIndex = colIndex) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
+ if (pPed == nil) {
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(objective, p1);
+ }
+ }
+ }
+}
+
+void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective, void* p1)
+{
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ if (CollectiveArray[i].colIndex = colIndex) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
+ if (pPed == nil) {
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(objective, p1);
+ }
+ }
+ }
+}
+
+void CTheScripts::SetObjectiveForAllPedsInCollective(int colIndex, eObjective objective)
+{
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ if (CollectiveArray[i].colIndex = colIndex) {
+ CPed* pPed = CPools::GetPedPool()->GetAt(CollectiveArray[i].pedIndex);
+ if (pPed == nil) {
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
+ }
+ else {
+ pPed->bScriptObjectiveCompleted = false;
+ pPed->SetObjective(objective);
+ }
+ }
+ }
+}
+#endif //GTA_SCRIPT_COLLECTIVE
+
bool CTheScripts::IsPedStopped(CPed* pPed)
{
if (pPed->bInVehicle)