summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/control')
-rw-r--r--src/control/AutoPilot.cpp2
-rw-r--r--src/control/CarCtrl.cpp2
-rw-r--r--src/control/Garages.cpp12
-rw-r--r--src/control/PathFind.cpp203
-rw-r--r--src/control/PathFind.h33
-rw-r--r--src/control/Replay.cpp10
-rw-r--r--src/control/SceneEdit.cpp1101
-rw-r--r--src/control/SceneEdit.h93
-rw-r--r--src/control/Script.cpp8
9 files changed, 1428 insertions, 36 deletions
diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp
index b5bca21d..65e73e5d 100644
--- a/src/control/AutoPilot.cpp
+++ b/src/control/AutoPilot.cpp
@@ -35,7 +35,7 @@ void CAutoPilot::ModifySpeed(float speed)
m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(uint32)(positionBetweenNodes * m_nTimeToSpendOnCurrentCurve);
#else
- m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nSpeedScaleFactor;
+ m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() - positionBetweenNodes * m_nTimeToSpendOnCurrentCurve;
#endif
}
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index 264f1f3f..197fca63 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -426,7 +426,7 @@ CCarCtrl::GenerateOneRandomCar()
(uint32)((0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve);
#else
pCar->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
- (0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nSpeedScaleFactor;
+ (0.5f + positionBetweenNodes) * pCar->AutoPilot.m_nTimeToSpendOnCurrentCurve;
#endif
CVector directionCurrentLink(directionCurrentLinkX, directionCurrentLinkY, 0.0f);
CVector directionNextLink(directionNextLinkX, directionNextLinkY, 0.0f);
diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp
index d971d453..d187f666 100644
--- a/src/control/Garages.cpp
+++ b/src/control/Garages.cpp
@@ -307,13 +307,13 @@ void CGarage::Update()
CGarages::bCamShouldBeOutisde = true;
}
if (pVehicle) {
- if (IsEntityEntirelyOutside(pVehicle, 0.0f))
+ if (!IsEntityEntirelyOutside(pVehicle, 0.0f))
TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = this;
if (pVehicle->GetModelIndex() == MI_MRWHOOP) {
if (pVehicle->IsWithinArea(
m_fX1 - DISTANCE_FOR_MRWHOOP_HACK,
- m_fX2 + DISTANCE_FOR_MRWHOOP_HACK,
- m_fY1 - DISTANCE_FOR_MRWHOOP_HACK,
+ m_fY1 + DISTANCE_FOR_MRWHOOP_HACK,
+ m_fX2 - DISTANCE_FOR_MRWHOOP_HACK,
m_fY2 + DISTANCE_FOR_MRWHOOP_HACK)) {
TheCamera.pToGarageWeAreIn = this;
CGarages::bCamShouldBeOutisde = true;
@@ -1082,7 +1082,7 @@ void CGarage::Update()
#ifdef FIX_BUGS
bool bCreatedAllCars = false;
#else
- bool bCraetedAllCars;
+ bool bCreatedAllCars;
#endif
switch (m_eGarageType) {
case GARAGE_HIDEOUT_ONE: bCreatedAllCars = RestoreCarsForThisHideout(CGarages::aCarsInSafeHouse1); break;
@@ -2313,6 +2313,10 @@ void CGarages::Load(uint8* buf, uint32 size)
#ifdef FIX_GARAGE_SIZE
VALIDATESAVEBUF(size);
#endif
+
+ MessageEndTime = 0;
+ bCamShouldBeOutisde = false;
+ MessageStartTime = 0;
}
bool
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index 61cd3d4e..9f45c454 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -14,9 +14,8 @@ bool gbShowCarPathsLinks;
CPathFind &ThePaths = *(CPathFind*)0x8F6754;
-WRAPPER bool CPedPath::CalcPedRoute(uint8, CVector, CVector, CVector*, int16*, int16) { EAXJMP(0x42E680); }
-
#define MAX_DIST INT16_MAX-1
+#define MIN_PED_ROUTE_DISTANCE 23.8f
// object flags:
// 1 UseInRoadBlock
@@ -28,6 +27,199 @@ CPathInfoForObject *&InfoForTilePeds = *(CPathInfoForObject**)0x8F1AE4;
CTempDetachedNode *&DetachedNodesCars = *(CTempDetachedNode**)0x8E2824;
CTempDetachedNode *&DetachedNodesPeds = *(CTempDetachedNode**)0x8E28A0;
+bool
+CPedPath::CalcPedRoute(int8 pathType, CVector position, CVector destination, CVector *pointPoses, int16 *pointsFound, int16 maxPoints)
+{
+ *pointsFound = 0;
+ CVector vecDistance = destination - position;
+ if (Abs(vecDistance.x) > MIN_PED_ROUTE_DISTANCE || Abs(vecDistance.y) > MIN_PED_ROUTE_DISTANCE || Abs(vecDistance.z) > MIN_PED_ROUTE_DISTANCE)
+ return false;
+ CVector vecPos = (position + destination) * 0.5f;
+ CVector vecSectorStartPos (vecPos.x - 14.0f, vecPos.y - 14.0f, vecPos.z);
+ CVector2D vecSectorEndPos (vecPos.x + 28.0f, vecPos.x + 28.0f);
+ const int16 nodeStartX = (position.x - vecSectorStartPos.x) / 0.7f;
+ const int16 nodeStartY = (position.y - vecSectorStartPos.y) / 0.7f;
+ const int16 nodeEndX = (destination.x - vecSectorStartPos.x) / 0.7f;
+ const int16 nodeEndY = (destination.y - vecSectorStartPos.y) / 0.7f;
+ if (nodeStartX == nodeEndX && nodeStartY == nodeEndY)
+ return false;
+ CPedPathNode pathNodes[40][40];
+ CPedPathNode pathNodesList[416];
+ for (int32 x = 0; x < 40; x++) {
+ for (int32 y = 0; y < 40; y++) {
+ pathNodes[x][y].bBlockade = false;
+ pathNodes[x][y].id = INT16_MAX;
+ pathNodes[x][y].nodeIdX = x;
+ pathNodes[x][y].nodeIdY = y;
+ }
+ }
+ CWorld::AdvanceCurrentScanCode();
+ if (pathType != ROUTE_NO_BLOCKADE) {
+ const int32 nStartX = max(CWorld::GetSectorIndexX(vecSectorStartPos.x), 0);
+ const int32 nStartY = max(CWorld::GetSectorIndexY(vecSectorStartPos.y), 0);
+ const int32 nEndX = min(CWorld::GetSectorIndexX(vecSectorEndPos.x), NUMSECTORS_X - 1);
+ const int32 nEndY = min(CWorld::GetSectorIndexY(vecSectorEndPos.y), NUMSECTORS_Y - 1);
+ for (int32 y = nStartY; y <= nEndY; y++) {
+ for (int32 x = nStartX; x <= nEndX; x++) {
+ CSector *pSector = CWorld::GetSector(x, y);
+ AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES], pathNodes, &vecSectorStartPos);
+ AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_VEHICLES_OVERLAP], pathNodes, &vecSectorStartPos);
+ AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS], pathNodes, &vecSectorStartPos);
+ AddBlockadeSectorList(pSector->m_lists[ENTITYLIST_OBJECTS_OVERLAP], pathNodes, &vecSectorStartPos);
+ }
+ }
+ }
+ for (int32 i = 0; i < 416; i++) {
+ pathNodesList[i].prev = nil;
+ pathNodesList[i].next = nil;
+ }
+ CPedPathNode *pStartPathNode = &pathNodes[nodeStartX][nodeStartY];
+ CPedPathNode *pEndPathNode = &pathNodes[nodeEndX][nodeEndY];
+ pEndPathNode->bBlockade = false;
+ pEndPathNode->id = 0;
+ pEndPathNode->prev = nil;
+ pEndPathNode->next = pathNodesList;
+ pathNodesList[0].prev = pEndPathNode;
+ int32 pathNodeIndex = 0;
+ CPedPathNode *pPreviousNode = nil;
+ for (; pathNodeIndex < 414; pathNodeIndex++)
+ {
+ pPreviousNode = pathNodesList[pathNodeIndex].prev;
+ while (pPreviousNode && pPreviousNode != pStartPathNode) {
+ const uint8 nodeIdX = pPreviousNode->nodeIdX;
+ const uint8 nodeIdY = pPreviousNode->nodeIdY;
+ if (nodeIdX > 0) {
+ AddNodeToPathList(&pathNodes[nodeIdX - 1][nodeIdY], pathNodeIndex + 5, pathNodesList);
+ if (nodeIdY > 0)
+ AddNodeToPathList(&pathNodes[nodeIdX - 1][nodeIdY - 1], pathNodeIndex + 7, pathNodesList);
+ if (nodeIdY < 39)
+ AddNodeToPathList(&pathNodes[nodeIdX - 1][nodeIdY + 1], pathNodeIndex + 7, pathNodesList);
+ }
+ if (nodeIdX < 39) {
+ AddNodeToPathList(&pathNodes[nodeIdX + 1][nodeIdY], pathNodeIndex + 5, pathNodesList);
+ if (nodeIdY > 0)
+ AddNodeToPathList(&pathNodes[nodeIdX + 1][nodeIdY - 1], pathNodeIndex + 7, pathNodesList);
+ if (nodeIdY < 39)
+ AddNodeToPathList(&pathNodes[nodeIdX + 1][nodeIdY + 1], pathNodeIndex + 7, pathNodesList);
+ }
+ if (nodeIdY > 0)
+ AddNodeToPathList(&pathNodes[nodeIdX][nodeIdY - 1], pathNodeIndex + 5, pathNodesList);
+ if (nodeIdY < 39)
+ AddNodeToPathList(&pathNodes[nodeIdX][nodeIdY + 1], pathNodeIndex + 5, pathNodesList);
+ pPreviousNode = pPreviousNode->prev;
+ if (!pPreviousNode)
+ break;
+ }
+
+ if (pPreviousNode && pPreviousNode == pStartPathNode)
+ break;
+ }
+ if (pathNodeIndex == 414)
+ return false;
+ CPedPathNode *pPathNode = pStartPathNode;
+ for (*pointsFound = 0; pPathNode != pEndPathNode && *pointsFound < maxPoints; ++ *pointsFound) {
+ const uint8 nodeIdX = pPathNode->nodeIdX;
+ const uint8 nodeIdY = pPathNode->nodeIdY;
+ if (nodeIdX > 0 && pathNodes[nodeIdX - 1][nodeIdY].id + 5 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX - 1][nodeIdY];
+ else if (nodeIdX > 39 && pathNodes[nodeIdX + 1][nodeIdY].id + 5 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX + 1][nodeIdY];
+ else if (nodeIdY > 0 && pathNodes[nodeIdX][nodeIdY - 1].id + 5 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX][nodeIdY - 1];
+ else if (nodeIdY > 39 && pathNodes[nodeIdX][nodeIdY + 1].id + 5 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX][nodeIdY + 1];
+ else if (nodeIdX > 0 && nodeIdY > 0 && pathNodes[nodeIdX - 1][nodeIdY - 1].id + 7 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX - 1][nodeIdY - 1];
+ else if (nodeIdX > 0 && nodeIdY < 39 && pathNodes[nodeIdX - 1][nodeIdY + 1].id + 7 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX - 1][nodeIdY + 1];
+ else if (nodeIdX < 39 && nodeIdY > 0 && pathNodes[nodeIdX + 1][nodeIdY - 1].id + 7 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX + 1][nodeIdY - 1];
+ else if (nodeIdX < 39 && nodeIdY < 39 && pathNodes[nodeIdX + 1][nodeIdY + 1].id + 7 == pPathNode->id)
+ pPathNode = &pathNodes[nodeIdX + 1][nodeIdY + 1];
+ pointPoses[*pointsFound] = vecSectorStartPos;
+ pointPoses[*pointsFound].x += pPathNode->nodeIdX * 0.7f;
+ pointPoses[*pointsFound].y += pPathNode->nodeIdY * 0.7f;
+ }
+ return true;
+}
+
+
+void
+CPedPath::AddNodeToPathList(CPedPathNode *pNodeToAdd, int16 id, CPedPathNode *pNodeList)
+{
+ if (!pNodeToAdd->bBlockade && id < pNodeToAdd->id) {
+ if (pNodeToAdd->id != INT16_MAX)
+ RemoveNodeFromList(pNodeToAdd);
+ AddNodeToList(pNodeToAdd, id, pNodeList);
+ }
+}
+
+void
+CPedPath::RemoveNodeFromList(CPedPathNode *pNode)
+{
+ pNode->next->prev = pNode->prev;
+ if (pNode->prev)
+ pNode->prev->next = pNode->next;
+}
+
+void
+CPedPath::AddNodeToList(CPedPathNode *pNode, int16 index, CPedPathNode *pList)
+{
+ pNode->prev = pList[index].prev;
+ pNode->next = &pList[index];
+ if (pList[index].prev)
+ pList[index].prev->next = pNode;
+ pList[index].prev = pNode;
+ pNode->id = index;
+}
+
+void
+CPedPath::AddBlockadeSectorList(CPtrList& list, CPedPathNode(*pathNodes)[40], CVector *pPosition)
+{
+ CPtrNode* listNode = list.first;
+ while (listNode) {
+ CEntity* pEntity = (CEntity*)listNode->item;
+ if (pEntity->m_scanCode != CWorld::GetCurrentScanCode() && pEntity->bUsesCollision) {
+ pEntity->m_scanCode = CWorld::GetCurrentScanCode();
+ AddBlockade(pEntity, pathNodes, pPosition);
+ }
+ listNode = listNode->next;
+ }
+}
+
+void
+CPedPath::AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *pPosition)
+{
+ const CColBox& boundingBox = pEntity->GetColModel()->boundingBox;
+ const float fBoundMaxY = boundingBox.max.y + 0.3f;
+ const float fBoundMinY = boundingBox.min.y - 0.3f;
+ const float fBoundMaxX = boundingBox.max.x + 0.3f;
+ const float fDistanceX = pPosition->x - pEntity->m_matrix.GetPosition().x;
+ const float fDistanceY = pPosition->y - pEntity->m_matrix.GetPosition().y;
+ const float fBoundRadius = pEntity->GetBoundRadius();
+ CVector vecBoundCentre;
+ pEntity->GetBoundCentre(vecBoundCentre);
+ if (vecBoundCentre.x + fBoundRadius >= pPosition->x &&
+ vecBoundCentre.y + fBoundRadius >= pPosition->y &&
+ vecBoundCentre.x - fBoundRadius <= pPosition->x + 28.0f &&
+ vecBoundCentre.y - fBoundRadius <= pPosition->y + 28.0f) {
+ for (int16 x = 0; x < 40; x++) {
+ const float pointX = x * 0.7f + fDistanceX;
+ for (int16 y = 0; y < 40; y++) {
+ if (!pathNodes[x][y].bBlockade) {
+ const float pointY = y * 0.7f + fDistanceY;
+ CVector2D point(pointX, pointY);
+ if (fBoundMaxX > Abs(DotProduct2D(point, pEntity->m_matrix.GetRight()))) {
+ float fDotProduct = DotProduct2D(point, pEntity->m_matrix.GetForward());
+ if (fBoundMaxY > fDotProduct && fBoundMinY < fDotProduct)
+ pathNodes[x][y].bBlockade = true;
+ }
+ }
+ }
+ }
+ }
+}
+
void
CPathFind::Init(void)
{
@@ -1576,6 +1768,13 @@ CPathFind::DisplayPathData(void)
}
STARTPATCHES
+ InjectHook(0x42E680, &CPedPath::CalcPedRoute, PATCH_JUMP);
+ InjectHook(0x42F100, &CPedPath::AddNodeToPathList, PATCH_JUMP);
+ InjectHook(0x42F140, &CPedPath::RemoveNodeFromList, PATCH_JUMP);
+ InjectHook(0x42F160, &CPedPath::AddNodeToList, PATCH_JUMP);
+ InjectHook(0x42F1A0, &CPedPath::AddBlockade, PATCH_JUMP);
+ InjectHook(0x42F420, &CPedPath::AddBlockadeSectorList, PATCH_JUMP);
+
InjectHook(0x4294A0, &CPathFind::Init, PATCH_JUMP);
InjectHook(0x42D580, &CPathFind::AllocatePathFindInfoMem, PATCH_JUMP);
InjectHook(0x429540, &CPathFind::RegisterMapObject, PATCH_JUMP);
diff --git a/src/control/PathFind.h b/src/control/PathFind.h
index 81467cdf..ea88ade6 100644
--- a/src/control/PathFind.h
+++ b/src/control/PathFind.h
@@ -3,11 +3,7 @@
#include "Treadable.h"
class CVehicle;
-
-class CPedPath {
-public:
- static bool CalcPedRoute(uint8, CVector, CVector, CVector*, int16*, int16);
-};
+class CPtrList;
enum
{
@@ -30,6 +26,33 @@ enum
SWITCH_ON = 1,
};
+enum
+{
+ ROUTE_ADD_BLOCKADE = 0,
+ ROUTE_NO_BLOCKADE = 1
+};
+
+struct CPedPathNode
+{
+ bool bBlockade;
+ uint8 nodeIdX;
+ uint8 nodeIdY;
+ int16 id;
+ CPedPathNode* prev;
+ CPedPathNode* next;
+};
+static_assert(sizeof(CPedPathNode) == 0x10, "CPedPathNode: error");
+
+class CPedPath {
+public:
+ static bool CalcPedRoute(int8 pathType, CVector position, CVector destination, CVector *pointPoses, int16 *pointsFound, int16 maxPoints);
+ static void AddNodeToPathList(CPedPathNode *pNodeToAdd, int16 id, CPedPathNode *pNodeList);
+ static void RemoveNodeFromList(CPedPathNode *pNode);
+ static void AddNodeToList(CPedPathNode *pNode, int16 index, CPedPathNode *pList);
+ static void AddBlockade(CEntity *pEntity, CPedPathNode(*pathNodes)[40], CVector *pPosition);
+ static void AddBlockadeSectorList(CPtrList& list, CPedPathNode(*pathNodes)[40], CVector *pPosition);
+};
+
struct CPathNode
{
CVector pos;
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index 97debfdc..c4a1e686 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -1215,7 +1215,7 @@ void CReplay::RestoreStuffFromMem(void)
vehicle->SetModelIndex(mi);
if (mi == MI_DODO){
CAutomobile* dodo = (CAutomobile*)vehicle;
- RpAtomicSetFlags(GetFirstObject(dodo->m_aCarNodes[CAR_WHEEL_LF]), 0);
+ RpAtomicSetFlags((RpAtomic*)GetFirstObject(dodo->m_aCarNodes[CAR_WHEEL_LF]), 0);
CMatrix tmp1;
tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), false);
CMatrix tmp2(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_LF]), false);
@@ -1243,7 +1243,7 @@ void CReplay::RestoreStuffFromMem(void)
vehicle->GetMatrix().Detach();
if (vehicle->m_rwObject){
if (RwObjectGetType(vehicle->m_rwObject) == rpATOMIC){
- RwFrame* frame = RpAtomicGetFrame(vehicle->m_rwObject);
+ RwFrame* frame = RpAtomicGetFrame((RpAtomic*)vehicle->m_rwObject);
RpAtomicDestroy((RpAtomic*)vehicle->m_rwObject);
RwFrameDestroy(frame);
}
@@ -1254,7 +1254,7 @@ void CReplay::RestoreStuffFromMem(void)
int model_id = info->m_wheelId;
if (model_id != -1){
if ((vehicle->m_rwObject = CModelInfo::GetModelInfo(model_id)->CreateInstance())){
- vehicle->GetMatrix().AttachRW(&((RwFrame*)vehicle->m_rwObject->parent)->modelling, false);
+ vehicle->GetMatrix().AttachRW(RwFrameGetMatrix(RpClumpGetFrame((RpClump*)vehicle->m_rwObject)), false);
}
}
}
@@ -1274,7 +1274,7 @@ void CReplay::RestoreStuffFromMem(void)
object->SetModelIndex(mi);
object->GetMatrix().m_attachment = nil;
if (RwObjectGetType(object->m_rwObject) == rpATOMIC)
- object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(object->m_rwObject)), false);
+ object->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)object->m_rwObject)), false);
}
i = CPools::GetDummyPool()->GetSize();
while (--i >= 0) {
@@ -1289,7 +1289,7 @@ void CReplay::RestoreStuffFromMem(void)
dummy->SetModelIndex(mi);
dummy->GetMatrix().m_attachment = nil;
if (RwObjectGetType(dummy->m_rwObject) == rpATOMIC)
- dummy->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame(dummy->m_rwObject)), false);
+ dummy->GetMatrix().AttachRW(RwFrameGetMatrix(RpAtomicGetFrame((RpAtomic*)dummy->m_rwObject)), false);
}
CTimer::SetTimeInMilliseconds(Time1);
CTimer::SetTimeInMillisecondsNonClipped(Time2);
diff --git a/src/control/SceneEdit.cpp b/src/control/SceneEdit.cpp
index 3e55d431..8d804e4d 100644
--- a/src/control/SceneEdit.cpp
+++ b/src/control/SceneEdit.cpp
@@ -2,11 +2,1096 @@
#include "patcher.h"
#include "SceneEdit.h"
-bool &CSceneEdit::m_bEditOn = *(bool*)0x95CD77;
-int32 &CSceneEdit::m_bCameraFollowActor = *(int*)0x940590;
-bool &CSceneEdit::m_bRecording = *(bool*)0x95CD1F;
-CVector &CSceneEdit::m_vecCurrentPosition = *(CVector*)0x943064;
-CVector &CSceneEdit::m_vecCamHeading = *(CVector*)0x942F8C;
-
-WRAPPER void CSceneEdit::Update(void) { EAXJMP(0x585570); }
-WRAPPER void CSceneEdit::Init(void) { EAXJMP(0x585170); }
+#include "Automobile.h"
+#include "Camera.h"
+#include "CarCtrl.h"
+#include "CivilianPed.h"
+#include "FileMgr.h"
+#include "Font.h"
+#include "ModelIndices.h"
+#include "ModelInfo.h"
+#include "Pad.h"
+#include "Ped.h"
+#include "Population.h"
+#include "Text.h"
+#include "Timecycle.h"
+#include "Streaming.h"
+#include "Vehicle.h"
+#include "WeaponInfo.h"
+#include "World.h"
+
+bool CSceneEdit::m_bEditOn;
+int32 CSceneEdit::m_bCameraFollowActor;
+bool CSceneEdit::m_bRecording;
+CVector CSceneEdit::m_vecCurrentPosition;
+CVector CSceneEdit::m_vecCamHeading;
+CVector CSceneEdit::m_vecGotoPosition;
+int32 CSceneEdit::m_nVehicle;
+int32 CSceneEdit::m_nVehicle2;
+int32 CSceneEdit::m_nActor;
+int32 CSceneEdit::m_nActor2;
+int32 CSceneEdit::m_nVehiclemodelId;
+int32 CSceneEdit::m_nPedmodelId;
+int16 CSceneEdit::m_nCurrentMovieCommand;
+int16 CSceneEdit::m_nNumActors;
+int16 CSceneEdit::m_nNumMovieCommands;
+int16 CSceneEdit::m_nCurrentCommand;
+int16 CSceneEdit::m_nCurrentVehicle;
+int16 CSceneEdit::m_nCurrentActor;
+int16 CSceneEdit::m_nWeaponType;
+bool CSceneEdit::m_bCommandActive;
+bool CSceneEdit::m_bActorSelected;
+bool CSceneEdit::m_bActor2Selected;
+bool CSceneEdit::m_bVehicleSelected;
+int16 CSceneEdit::m_nNumVehicles;
+CPed* CSceneEdit::pActors[NUM_ACTORS_IN_MOVIE];
+CVehicle* CSceneEdit::pVehicles[NUM_VEHICLES_IN_MOVIE];
+bool CSceneEdit::m_bDrawGotoArrow;
+CMovieCommand CSceneEdit::Movie[NUM_COMMANDS_IN_MOVIE];
+
+#define SHADOW_OFFSET (2.0f)
+#define ACTION_MESSAGE_X_RIGHT (60.0f)
+#define ACTION_MESSAGE_Y (8.0f)
+#define SELECTED_MESSAGE_X_RIGHT (60.0f)
+#define SELECTED_MESSAGE_Y (248.0f)
+#define COMMAND_NAME_X_RIGHT (60.0f)
+#define COMMAND_NAME_Y (38.0f)
+#define COMMAND_NAME_HEIGHT (16.0f)
+
+#define NUM_COMMANDS_TO_DRAW (9)
+
+static const char* pCommandStrings[] = {
+ "do-nothing", "New Actor", "Move Actor", "Select Actor", "Delete Actor",
+ "New Vehicle", "Move Vehicle", "Select Vehicle", "Delete Vehicle", "Give Weapon",
+ "Goto", "Goto (wait)", "Get In Car", "Get Out Car", "Kill",
+ "Flee", "Wait", "Position Camera", "Set Camera Target", "Select Camera Mode",
+ "Save Movie", "Load Movie", "Play Movie", "END"
+};
+
+static_assert(ARRAY_SIZE(pCommandStrings) == CSceneEdit::MOVIE_TOTAL_COMMANDS, "Scene edit: not all commands have names");
+
+static int32 NextValidModelId(int32 mi, int32 step)
+{
+ int32 result = -1;
+ int32 i = mi;
+ while (result == -1) {
+ i += step;
+ if (i < 0 || i > 5500) {
+ step = -step;
+ continue;
+ }
+ CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(i);
+ CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo;
+ if (!pInfo)
+ continue;
+ if (pInfo->m_type == MITYPE_PED
+#ifdef FIX_BUGS
+ && !(i >= MI_SPECIAL01 && i <= MI_SPECIAL04)
+#endif
+ ||
+ pInfo->m_type == MITYPE_VEHICLE &&
+#ifdef FIX_BUGS
+ (pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BOAT))
+#else // && and || priority failure it seems, also crashes on special models
+ pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BOAT)
+#endif
+ result = i;
+ }
+ return result;
+}
+
+void CSceneEdit::LoadMovie(void)
+{
+ ReInitialise();
+ CFileMgr::SetDir("DATA");
+ int fid = CFileMgr::OpenFile("movie.dat", "r");
+#ifdef FIX_BUGS
+ if (fid >= 0)
+#endif
+ {
+ CFileMgr::Read(fid, (char*)&Movie, sizeof(Movie));
+ CFileMgr::Read(fid, (char*)&m_nNumMovieCommands, sizeof(m_nNumMovieCommands));
+ CFileMgr::CloseFile(fid);
+ }
+ CFileMgr::SetDir("");
+ m_bCommandActive = false;
+}
+
+void CSceneEdit::SaveMovie(void)
+{
+ CFileMgr::SetDir("DATA");
+ int fid = CFileMgr::OpenFileForWriting("movie.dat");
+ if (fid >= 0) {
+ CFileMgr::Write(fid, (char*)&Movie, sizeof(Movie));
+ CFileMgr::Write(fid, (char*)&m_nNumMovieCommands, sizeof(m_nNumMovieCommands));
+ CFileMgr::CloseFile(fid);
+ }
+ CFileMgr::SetDir("");
+ m_bCommandActive = false;
+}
+
+void CSceneEdit::Initialise(void)
+{
+ m_nActor = -1;
+ m_nActor2 = -1;
+ m_nVehicle = -1;
+ m_nVehicle2 = -1;
+ m_nCurrentCommand = MOVIE_NEW_ACTOR;
+ m_nVehiclemodelId = MI_INFERNUS;
+ m_nPedmodelId = MI_MALE01;
+ m_nNumVehicles = 0;
+ m_nNumActors = 0;
+ m_nNumMovieCommands = 0;
+ m_bCommandActive = false;
+ m_bRecording = true;
+ m_bEditOn = false;
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++)
+ pActors[i] = nil;
+ for (int i = 0; i < NUM_VEHICLES_IN_MOVIE; i++)
+ pVehicles[i] = nil;
+ m_vecCamHeading = TheCamera.Cams[TheCamera.ActiveCam].Front;
+ m_vecGotoPosition = CVector(0.0f, 0.0f, 0.0f);
+ m_bCameraFollowActor = false;
+ TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true;
+ m_bDrawGotoArrow = false;
+}
+
+void CSceneEdit::InitPlayback(void)
+{
+ m_nVehiclemodelId = MI_INFERNUS;
+ m_nPedmodelId = MI_MALE01;
+ m_bCommandActive = false;
+ m_nNumActors = 0;
+ m_nNumVehicles = 0;
+ m_nActor = -1;
+ m_nActor2 = -1;
+ m_nVehicle = -1;
+ m_nVehicle2 = -1;
+ TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true;
+ m_vecCamHeading = TheCamera.Cams[TheCamera.ActiveCam].Front;
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pActors[i]) {
+ CPopulation::RemovePed(pActors[i]);
+ pActors[i] = nil;
+ }
+ }
+ m_nCurrentActor = 0;
+ for (int i = 0; i < NUM_VEHICLES_IN_MOVIE; i++) {
+ if (pVehicles[i]) {
+ CWorld::Remove(pVehicles[i]);
+ delete pVehicles[i];
+ pVehicles[i] = nil;
+ }
+ }
+ m_nCurrentVehicle = 0;
+ m_vecGotoPosition = CVector(0.0f, 0.0f, 0.0f);
+ m_nCurrentMovieCommand = MOVIE_DO_NOTHING;
+ m_bDrawGotoArrow = false;
+}
+
+void CSceneEdit::ReInitialise(void)
+{
+ m_nVehiclemodelId = MI_INFERNUS;
+ m_nPedmodelId = MI_MALE01;
+ m_nCurrentCommand = MOVIE_NEW_ACTOR;
+ m_bEditOn = true;
+ m_bRecording = true;
+ m_bCommandActive = false;
+#ifdef FIX_BUGS
+ m_bCameraFollowActor = false;
+ TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true; // not enough...
+#endif
+ m_nActor = -1;
+ m_nActor2 = -1;
+ m_nVehicle = -1;
+ m_nVehicle2 = -1;
+ m_nNumMovieCommands = 0;
+ m_nCurrentMovieCommand = MOVIE_DO_NOTHING;
+ m_nNumActors = 0;
+ m_nNumVehicles = 0;
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pActors[i]) {
+ CPopulation::RemovePed(pActors[i]);
+ pActors[i] = nil;
+ }
+ }
+ for (int i = 0; i < NUM_VEHICLES_IN_MOVIE; i++) {
+ if (pVehicles[i]) {
+ CWorld::Remove(pVehicles[i]);
+ delete pVehicles[i];
+ pVehicles[i] = nil;
+ }
+ }
+ for (int i = 0; i < NUM_COMMANDS_IN_MOVIE; i++) {
+ Movie[i].m_nCommandId = MOVIE_DO_NOTHING;
+ Movie[i].m_vecPosition = CVector(0.0f, 0.0f, 0.0f);
+ Movie[i].m_vecCamera = CVector(0.0f, 0.0f, 0.0f);
+ Movie[i].m_nActorId = -1;
+ Movie[i].m_nActor2Id = -1;
+ Movie[i].m_nVehicleId = -1;
+ Movie[i].m_nModelIndex = 0;
+ }
+ m_vecGotoPosition = CVector(0.0f, 0.0f, 0.0f);
+ m_bDrawGotoArrow = false;
+}
+
+void CSceneEdit::Update(void)
+{
+ if (!m_bEditOn)
+ return;
+ if (m_bRecording)
+ ProcessCommand();
+ else {
+ if (m_bCameraFollowActor && m_nActor != -1) {
+ if (pActors[m_nActor]->bInVehicle)
+ TheCamera.TakeControl(pActors[m_nActor]->m_pMyVehicle, CCam::MODE_BEHINDCAR, JUMP_CUT, CAMCONTROL_SCRIPT);
+ else
+ TheCamera.TakeControl(pActors[m_nActor], CCam::MODE_FOLLOWPED, JUMP_CUT, CAMCONTROL_SCRIPT);
+ }
+ PlayBack();
+ }
+}
+
+void CSceneEdit::Draw(void)
+{
+ char str[200];
+ wchar wstr[200];
+ if (TheCamera.m_WideScreenOn)
+ return;
+#ifndef FIX_BUGS
+ CFont::SetPropOff();
+#endif
+ CFont::SetBackgroundOff();
+ CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
+ CFont::SetCentreOn();
+ CFont::SetRightJustifyOn();
+ CFont::SetRightJustifyWrap(0.0f);
+ CFont::SetBackGroundOnlyTextOff();
+#ifdef FIX_BUGS
+ CFont::SetFontStyle(FONT_BANK);
+ CFont::SetPropOn();
+ CFont::SetDropColor(CRGBA(0, 0, 0, 255));
+ CFont::SetDropShadowPosition(1);
+#else
+ CFont::SetFontStyle(FONT_HEADING);
+ CFont::SetPropOff();
+#endif
+ sprintf(str, "Action");
+ AsciiToUnicode(str, wstr);
+ CFont::SetColor(CRGBA(0, 0, 0, 0));
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(ACTION_MESSAGE_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(ACTION_MESSAGE_Y + SHADOW_OFFSET), wstr);
+ CFont::SetColor(CRGBA(193, 164, 120, 255));
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(ACTION_MESSAGE_X_RIGHT), SCREEN_SCALE_Y(ACTION_MESSAGE_Y), wstr);
+ sprintf(str, "Selected");
+ AsciiToUnicode(str, wstr);
+ CFont::SetColor(CRGBA(0, 0, 0, 0));
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SELECTED_MESSAGE_X_RIGHT - SHADOW_OFFSET), SCREEN_SCALE_Y(SELECTED_MESSAGE_Y + SHADOW_OFFSET), wstr);
+ CFont::SetColor(CRGBA(193, 164, 120, 255));
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(SELECTED_MESSAGE_X_RIGHT), SCREEN_SCALE_Y(SELECTED_MESSAGE_Y), wstr);
+ CFont::SetCentreOff();
+ CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(0.7f));
+#ifdef FIX_BUGS
+ CFont::SetFontStyle(FONT_BANK);
+#else
+ CFont::SetFontStyle(FONT_HEADING);
+#endif
+ CFont::SetColor(CRGBA(0, 0, 0, 0));
+ 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)
+ nCommandDrawn -= (MOVIE_TOTAL_COMMANDS - 1);
+ if (nCommandDrawn <= MOVIE_DO_NOTHING)
+ nCommandDrawn += (MOVIE_TOTAL_COMMANDS - 1);
+ sprintf(str, pCommandStrings[nCommandDrawn]);
+ AsciiToUnicode(str, wstr);
+ CFont::SetColor(CRGBA(0, 0, 0, 0));
+ 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);
+ if (nCommandDrawn == m_nCurrentCommand)
+ CFont::SetColor(CRGBA(156, 91, 40, 255));
+ else
+ CFont::SetColor(CRGBA(193, 164, 120, 255));
+ CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(COMMAND_NAME_X_RIGHT), SCREEN_SCALE_Y(COMMAND_NAME_Y + i * COMMAND_NAME_HEIGHT), wstr);
+ }
+}
+
+void CSceneEdit::ProcessCommand(void)
+{
+ if (!m_bCommandActive) {
+ ClearForNewCommand();
+ if (CPad::GetPad(1)->GetDPadUpJustDown()) {
+ if (--m_nCurrentCommand == MOVIE_DO_NOTHING)
+ m_nCurrentCommand = MOVIE_END;
+ }
+ if (CPad::GetPad(1)->GetDPadDownJustDown()) {
+ if (++m_nCurrentCommand == MOVIE_TOTAL_COMMANDS)
+ m_nCurrentCommand = MOVIE_NEW_ACTOR;
+ }
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ if (m_nCurrentCommand != MOVIE_DO_NOTHING)
+ m_bCommandActive = true;
+ }
+ return;
+ }
+ switch (m_nCurrentCommand) {
+ case MOVIE_DO_NOTHING:
+ m_bCommandActive = false;
+ break;
+ case MOVIE_NEW_ACTOR:
+ if (m_nActor == -1) {
+ if (m_nNumActors == NUM_ACTORS_IN_MOVIE)
+ break;
+ if (!CStreaming::HasModelLoaded(m_nPedmodelId)) {
+ CStreaming::RequestModel(m_nPedmodelId, 0);
+#ifdef FIX_BUGS
+ CStreaming::LoadAllRequestedModels(false); // otherwise gets stuck :(
+#endif
+ break;
+ }
+ CPed* pPed = new CCivilianPed(PEDTYPE_SPECIAL, m_nPedmodelId);
+ pPed->CharCreatedBy = MISSION_CHAR;
+ pPed->GetPosition() = m_vecCurrentPosition;
+ pPed->SetOrientation(0.0f, 0.0f, 0.0f);
+ CWorld::Add(pPed);
+ pPed->bUsesCollision = false;
+ pPed->bAffectedByGravity = false;
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pActors[i] == nil) {
+ m_nActor = i;
+ pActors[i] = pPed;
+ break;
+ }
+ }
+ }
+ else {
+ pActors[m_nActor]->GetPosition() = m_vecCurrentPosition;
+ pActors[m_nActor]->SetOrientation(0.0f, 0.0f, 0.0f);
+ int32 mi = m_nPedmodelId;
+ if (CPad::GetPad(1)->GetLeftShoulder1JustDown())
+ mi = NextValidModelId(m_nPedmodelId, -1);
+ else if (CPad::GetPad(1)->GetRightShoulder1JustDown())
+ mi = NextValidModelId(m_nPedmodelId, 1);
+ if (mi == m_nPedmodelId) {
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ pActors[m_nActor]->bUsesCollision = true;
+ pActors[m_nActor]->bAffectedByGravity = true;
+ ++m_nNumActors;
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_NEW_ACTOR;
+ Movie[m_nNumMovieCommands].m_vecPosition = m_vecCurrentPosition;
+ Movie[m_nNumMovieCommands].m_nModelIndex = m_nPedmodelId;
+ Movie[m_nNumMovieCommands++].m_nActorId = m_nActor;
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ CWorld::Remove(pActors[m_nActor]);
+ delete pActors[m_nActor];
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ }
+ else {
+ m_nPedmodelId = mi;
+ if (pActors[m_nActor]) {
+ CWorld::Remove(pActors[m_nActor]);
+ delete pActors[m_nActor];
+ }
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ }
+ }
+ break;
+ case MOVIE_MOVE_ACTOR:
+ SelectActor();
+ if (m_bCommandActive)
+ break;
+ pActors[m_nActor]->GetPosition() = m_vecCurrentPosition;
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_bCommandActive = false;
+#ifndef FIX_BUGS // why? it crashes, also makes no sense
+ pActors[m_nActor] = nil;
+#endif
+ SelectActor();
+ }
+ break;
+ case MOVIE_SELECT_ACTOR:
+ SelectActor();
+ break;
+ case MOVIE_DELETE_ACTOR:
+ SelectActor();
+ if (m_bActorSelected) {
+ CPopulation::RemovePed(pActors[m_nActor]);
+ m_nCurrentActor = 0;
+ --m_nNumActors;
+#ifdef FIX_BUGS
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+#else
+ m_nActor = -1;
+ pActors[m_nActor] = nil;
+#endif
+ SelectActor();
+ m_bCommandActive = false;
+ }
+ else if (CPad::GetPad(1)->GetCircleJustDown()) {
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_NEW_VEHICLE:
+ if (m_nVehicle == -1) {
+ if (m_nNumVehicles == NUM_VEHICLES_IN_MOVIE)
+ break;
+ if (!CStreaming::HasModelLoaded(m_nVehiclemodelId)) {
+ CStreaming::RequestModel(m_nVehiclemodelId, 0);
+#ifdef FIX_BUGS
+ CStreaming::LoadAllRequestedModels(false); // otherwise gets stuck :(
+#endif
+ break;
+ }
+ CVehicle* pVehicle = new CAutomobile(m_nVehiclemodelId, MISSION_VEHICLE);
+ pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->GetPosition() = m_vecCurrentPosition;
+ pVehicle->SetOrientation(0.0f, 0.0f, 0.0f);
+ CWorld::Add(pVehicle);
+ pVehicle->bUsesCollision = false;
+ pVehicle->bAffectedByGravity = false;
+ for (int i = 0; i < NUM_VEHICLES_IN_MOVIE; i++) {
+ if (pVehicles[i] == nil) {
+ m_nVehicle = i;
+ pVehicles[i] = pVehicle;
+ break;
+ }
+ }
+ }
+ else {
+ pVehicles[m_nVehicle]->GetPosition() = m_vecCurrentPosition;
+ pVehicles[m_nVehicle]->SetOrientation(0.0f, 0.0f, 0.0f);
+ int32 mi = m_nVehiclemodelId;
+ if (CPad::GetPad(1)->GetLeftShoulder1JustDown())
+ mi = NextValidModelId(m_nVehiclemodelId, -1);
+ else if (CPad::GetPad(1)->GetRightShoulder1JustDown())
+ mi = NextValidModelId(m_nVehiclemodelId, 1);
+ if (mi == m_nVehiclemodelId) {
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ pVehicles[m_nVehicle]->bUsesCollision = true;
+ pVehicles[m_nVehicle]->bAffectedByGravity = true;
+ ++m_nNumVehicles;
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_NEW_VEHICLE;
+ Movie[m_nNumMovieCommands].m_vecPosition = m_vecCurrentPosition;
+ Movie[m_nNumMovieCommands].m_nModelIndex = m_nVehiclemodelId;
+ Movie[m_nNumMovieCommands++].m_nVehicleId = m_nVehicle;
+ m_nVehicle = -1;
+ m_bCommandActive = false;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ CWorld::Remove(pVehicles[m_nVehicle]);
+ delete pVehicles[m_nVehicle];
+ pVehicles[m_nVehicle] = nil;
+ m_nVehicle = -1;
+ m_bCommandActive = false;
+ }
+ }
+ else {
+ m_nVehiclemodelId = mi;
+ if (pVehicles[m_nVehicle]) {
+ CWorld::Remove(pVehicles[m_nVehicle]);
+ delete pVehicles[m_nVehicle];
+ }
+ pVehicles[m_nVehicle] = nil;
+ m_nVehicle = -1;
+ }
+ }
+ break;
+ case MOVIE_MOVE_VEHICLE:
+ SelectVehicle();
+ if (m_bCommandActive)
+ break;
+ pVehicles[m_nVehicle]->GetPosition() = m_vecCurrentPosition;
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_bCommandActive = false;
+#ifndef FIX_BUGS // again, why? works wrong
+ pVehicles[m_nVehicle] = nil;
+#endif
+ m_nVehicle = -1;
+ }
+ break;
+ case MOVIE_SELECT_VEHICLE:
+ SelectVehicle();
+ break;
+ case MOVIE_DELETE_VEHICLE:
+ SelectVehicle();
+ if (m_bVehicleSelected) {
+ CWorld::Remove(pVehicles[m_nVehicle]);
+ delete pVehicles[m_nVehicle];
+ m_nCurrentVehicle = 0;
+ --m_nNumVehicles;
+ pVehicles[m_nVehicle] = nil;
+ m_nVehicle = -1;
+ SelectVehicle();
+ m_bCommandActive = false;
+ }
+ else if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pVehicles[m_nVehicle] = nil;
+ m_nVehicle = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_GIVE_WEAPON:
+ if (m_bActorSelected) {
+ if (SelectWeapon()) {
+ m_bCommandActive = false;
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_GIVE_WEAPON;
+ Movie[m_nNumMovieCommands].m_nActorId = m_nActor;
+ Movie[m_nNumMovieCommands++].m_nModelIndex = m_nWeaponType;
+ }
+ }
+ else {
+ SelectActor();
+ m_bCommandActive = true;
+ }
+ break;
+ case MOVIE_GOTO:
+ case MOVIE_GOTO_WAIT:
+ if (!m_bActorSelected) {
+ m_bDrawGotoArrow = true;
+ SelectActor();
+ if (m_nActor == -1)
+ m_bCommandActive = true;
+ }
+ else {
+ m_vecGotoPosition = m_vecCurrentPosition;
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ if (pActors[m_nActor]->bInVehicle) {
+ if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pActors[m_nActor]->m_pMyVehicle, m_vecGotoPosition, false))
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
+ else
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
+ pActors[m_nActor]->m_pMyVehicle->m_status = STATUS_PHYSICS;
+ pActors[m_nActor]->m_pMyVehicle->bEngineOn = true;
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
+ TheCamera.TakeControl(pActors[m_nActor]->m_pMyVehicle, CCam::MODE_BEHINDCAR, JUMP_CUT, CAMCONTROL_SCRIPT);
+ }
+ else {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, m_vecGotoPosition);
+ TheCamera.TakeControl(pActors[m_nActor], CCam::MODE_FOLLOWPED, JUMP_CUT, CAMCONTROL_SCRIPT);
+ }
+ m_bDrawGotoArrow = false;
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_GOTO;
+ Movie[m_nNumMovieCommands].m_nActorId = m_nActor;
+ Movie[m_nNumMovieCommands++].m_vecPosition = m_vecGotoPosition;
+ }
+ if (!m_bDrawGotoArrow) {
+ if (pActors[m_nActor]->bInVehicle && pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission == MISSION_NONE ||
+ !pActors[m_nActor]->bInVehicle && pActors[m_nActor]->m_objective == OBJECTIVE_NONE) {
+ if (pActors[m_nActor]) // if there is something that requires this check the least, it's this one
+ m_vecCamHeading = TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity->GetPosition() - TheCamera.Cams[TheCamera.ActiveCam].Source;
+ m_bCommandActive = false;
+ TheCamera.Cams[TheCamera.ActiveCam].Mode = CCam::MODE_FIGHT_CAM_RUNABOUT;
+ m_vecCurrentPosition = pActors[m_nActor]->GetPosition();
+ pActors[m_nActor]->SetObjective(OBJECTIVE_NONE);
+ if (pActors[m_nActor]->bInVehicle)
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_NONE;
+ }
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ }
+ break;
+ case MOVIE_GET_IN_CAR:
+ if (m_bActorSelected)
+ SelectVehicle();
+ else {
+ SelectActor();
+ if (m_nActor != -1)
+ m_bCommandActive = true;
+ }
+ if (m_bVehicleSelected) {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicles[m_nVehicle]);
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_GET_IN_CAR;
+ Movie[m_nNumMovieCommands].m_nActorId = m_nActor;
+ Movie[m_nNumMovieCommands++].m_nVehicleId = m_nVehicle;
+ m_nVehicle = -1;
+ m_bCommandActive = false;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pVehicles[m_nVehicle] = nil;
+ m_nVehicle = -1;
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_GET_OUT_CAR:
+ SelectActor();
+ if (m_bActorSelected) {
+ if (pActors[m_nActor]->bInVehicle) {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_LEAVE_VEHICLE);
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_GET_OUT_CAR;
+ Movie[m_nNumMovieCommands++].m_nActorId = m_nActor;
+ }
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pVehicles[m_nVehicle] = nil;
+ m_nVehicle = -1;
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_KILL:
+ if (!m_bActorSelected) {
+ SelectActor();
+ m_bCommandActive = true;
+ }
+ else if (!m_bActor2Selected) {
+ SelectActor2();
+ if (m_bActorSelected && m_bActor2Selected && m_nActor != -1 && m_nActor2 != -1 && m_nActor != m_nActor2) {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, pActors[m_nActor2]);
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_KILL;
+ Movie[m_nNumMovieCommands].m_nActorId = m_nActor;
+ Movie[m_nNumMovieCommands++].m_nActor2Id = m_nActor2;
+ m_bCommandActive = false;
+ }
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ pActors[m_nActor2] = nil;
+ m_nActor2 = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_FLEE:
+ if (!m_bActorSelected) {
+ SelectActor();
+ m_bCommandActive = true;
+ }
+ else if (!m_bActor2Selected) {
+ SelectActor2();
+ if (m_bActorSelected && m_bActor2Selected && m_nActor != -1 && m_nActor2 != -1 && m_nActor != m_nActor2) {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pActors[m_nActor2]);
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_FLEE;
+ Movie[m_nNumMovieCommands].m_nActorId = m_nActor;
+ Movie[m_nNumMovieCommands++].m_nActor2Id = m_nActor2;
+ m_bCommandActive = false;
+ }
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ pActors[m_nActor2] = nil;
+ m_nActor2 = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_WAIT:
+ SelectActor();
+ if (m_bActorSelected) {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_IDLE);
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_WAIT;
+ Movie[m_nNumMovieCommands++].m_nActorId = m_nActor;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pActors[m_nActor] = nil;
+ m_nActor = -1;
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_POSITION_CAMERA:
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_POSITION_CAMERA;
+ Movie[m_nNumMovieCommands].m_vecPosition = TheCamera.Cams[TheCamera.ActiveCam].Source;
+ Movie[m_nNumMovieCommands++].m_vecCamera = m_vecCamHeading;
+ m_bCommandActive = false;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ m_bCommandActive = false;
+ }
+ break;
+ case MOVIE_SET_CAMERA_TARGET:
+ if (!m_bActorSelected) {
+ SelectActor();
+ m_bCommandActive = true;
+ }
+ else {
+ TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity = pActors[m_nActor];
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ Movie[m_nNumMovieCommands].m_nCommandId = MOVIE_SET_CAMERA_TARGET;
+ Movie[m_nNumMovieCommands++].m_nActorId = m_nActor;
+ m_bCommandActive = false;
+ }
+ }
+ break;
+ case MOVIE_SELECT_CAMERA_MODE:
+ m_bCommandActive = false;
+ break;
+ case MOVIE_SAVE_MOVIE:
+ SaveMovie();
+ break;
+ case MOVIE_LOAD_MOVIE:
+ LoadMovie();
+ break;
+ case MOVIE_PLAY_MOVIE:
+ InitPlayback();
+ LoadMovie();
+ m_bRecording = false;
+ break;
+ case MOVIE_END:
+ m_bRecording = false;
+ break;
+ default:
+ assert(0);
+ }
+}
+
+void CSceneEdit::PlayBack(void)
+{
+ m_nCurrentCommand = Movie[m_nCurrentMovieCommand].m_nCommandId;
+ if (m_nCurrentMovieCommand >= m_nNumMovieCommands) {
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_nCurrentCommand = MOVIE_DO_NOTHING;
+ m_bRecording = true;
+ ReInitialise();
+ }
+ return;
+ }
+ switch (m_nCurrentCommand) {
+ case MOVIE_DO_NOTHING:
+ case MOVIE_MOVE_ACTOR:
+ case MOVIE_SELECT_ACTOR:
+ case MOVIE_DELETE_ACTOR:
+ case MOVIE_MOVE_VEHICLE:
+ case MOVIE_SELECT_VEHICLE:
+ case MOVIE_DELETE_VEHICLE:
+ break;
+ case MOVIE_NEW_ACTOR:
+ {
+ m_nPedmodelId = Movie[m_nCurrentMovieCommand].m_nModelIndex;
+ m_vecCurrentPosition = Movie[m_nCurrentMovieCommand].m_vecPosition;
+ if (!CStreaming::HasModelLoaded(m_nPedmodelId)) {
+ CStreaming::RequestModel(m_nPedmodelId, 0);
+#ifdef FIX_BUGS
+ CStreaming::LoadAllRequestedModels(false); // otherwise gets stuck :(
+#endif
+ break;
+ }
+ CPed* pPed = new CCivilianPed(PEDTYPE_SPECIAL, m_nPedmodelId);
+ pPed->CharCreatedBy = MISSION_CHAR;
+ CWorld::Add(pPed);
+ pPed->GetPosition() = m_vecCurrentPosition;
+ pPed->SetOrientation(0.0f, 0.0f, 0.0f);
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pActors[i] == nil) {
+ m_nActor = i;
+ pActors[i] = pPed;
+ break;
+ }
+ }
+ m_nNumActors++;
+ m_nCurrentMovieCommand++;
+ break;
+ }
+ case MOVIE_NEW_VEHICLE:
+ {
+ m_nVehiclemodelId = Movie[m_nCurrentMovieCommand].m_nModelIndex;
+ m_vecCurrentPosition = Movie[m_nCurrentMovieCommand].m_vecPosition;
+ if (!CStreaming::HasModelLoaded(m_nVehiclemodelId)) {
+ CStreaming::RequestModel(m_nVehiclemodelId, 0);
+#ifdef FIX_BUGS
+ CStreaming::LoadAllRequestedModels(false); // otherwise gets stuck :(
+#endif
+ break;
+ }
+ CVehicle* pVehicle = new CAutomobile(m_nVehiclemodelId, MISSION_VEHICLE);
+ pVehicle->m_status = STATUS_PHYSICS;
+ pVehicle->GetPosition() = m_vecCurrentPosition;
+ pVehicle->SetOrientation(0.0f, 0.0f, 0.0f);
+ CWorld::Add(pVehicle);
+ for (int i = 0; i < NUM_VEHICLES_IN_MOVIE; i++) {
+ if (pVehicles[i] == nil) {
+ m_nVehicle = i;
+ pVehicles[i] = pVehicle;
+ break;
+ }
+ }
+ m_nNumVehicles++;
+ m_nCurrentMovieCommand++;
+ break;
+ }
+ case MOVIE_GIVE_WEAPON:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ m_nWeaponType = Movie[m_nCurrentMovieCommand].m_nModelIndex;
+ pActors[m_nActor]->GiveWeapon((eWeaponType)m_nWeaponType, 1000);
+ pActors[m_nActor]->AddWeaponModel(CWeaponInfo::GetWeaponInfo(pActors[m_nActor]->GetWeapon()->m_eWeaponType)->m_nModelId);
+ pActors[m_nActor]->SetCurrentWeapon(m_nWeaponType);
+ m_nCurrentMovieCommand++;
+ break;
+ case MOVIE_GOTO:
+ case MOVIE_GOTO_WAIT:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ m_vecGotoPosition = Movie[m_nCurrentMovieCommand].m_vecPosition;
+ if (pActors[m_nActor]->bInVehicle) {
+ if (pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS &&
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission != MISSION_GOTOCOORDS_STRAIGHT) {
+ if ((pActors[m_nActor]->m_pMyVehicle->GetPosition() - m_vecGotoPosition).Magnitude() < 5.0f) {
+ if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(pActors[m_nActor]->m_pMyVehicle, m_vecGotoPosition, false))
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
+ else
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS;
+ pActors[m_nActor]->m_pMyVehicle->m_status = STATUS_PHYSICS;
+ pActors[m_nActor]->m_pMyVehicle->bEngineOn = true;
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed = max(16, pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nCruiseSpeed);
+ pActors[m_nActor]->m_pMyVehicle->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
+ if (m_nCurrentCommand != MOVIE_GOTO_WAIT)
+ ++m_nCurrentMovieCommand;
+ }
+ else
+ ++m_nCurrentMovieCommand;
+ }
+ }
+ else {
+ if (pActors[m_nActor]->m_objective != OBJECTIVE_GOTO_AREA_ON_FOOT) {
+ pActors[m_nActor]->SetObjective(OBJECTIVE_GOTO_AREA_ON_FOOT, m_vecGotoPosition);
+ ++m_nCurrentMovieCommand;
+ }
+ }
+ break;
+ case MOVIE_GET_IN_CAR:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ if (!pActors[m_nActor]->bInVehicle){
+ m_nVehicle = Movie[m_nCurrentMovieCommand].m_nVehicleId;
+ pActors[m_nActor]->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, pVehicles[m_nVehicle]);
+ }
+ else
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_GET_OUT_CAR:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ if (pActors[m_nActor]->bInVehicle)
+ pActors[m_nActor]->SetObjective(OBJECTIVE_LEAVE_VEHICLE);
+ else
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_KILL:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ m_nActor2 = Movie[m_nCurrentMovieCommand].m_nActor2Id;
+ pActors[m_nActor]->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, pActors[m_nActor2]);
+ if (pActors[m_nActor2]->GetPedState() == PED_DEAD)
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_FLEE:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ m_nActor2 = Movie[m_nCurrentMovieCommand].m_nActor2Id;
+ pActors[m_nActor]->SetObjective(OBJECTIVE_FLEE_CHAR_ON_FOOT_ALWAYS, pActors[m_nActor2]);
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_WAIT:
+ m_nActor = Movie[m_nCurrentMovieCommand].m_nActorId;
+ pActors[m_nActor]->SetObjective(OBJECTIVE_IDLE);
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_POSITION_CAMERA:
+ TheCamera.Cams[TheCamera.ActiveCam].Source = Movie[m_nCurrentMovieCommand].m_vecPosition;
+ m_vecCamHeading = Movie[m_nCurrentMovieCommand].m_vecCamera;
+ TheCamera.Cams[TheCamera.ActiveCam].Front = m_vecCamHeading;
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_SET_CAMERA_TARGET:
+ m_bCameraFollowActor = true;
+ TheCamera.Cams[TheCamera.ActiveCam].CamTargetEntity = pActors[Movie[m_nNumMovieCommands].m_nActorId];
+ TheCamera.pTargetEntity = pActors[Movie[m_nNumMovieCommands].m_nActorId];
+ TheCamera.m_bLookingAtPlayer = false;
+ ++m_nCurrentMovieCommand;
+ break;
+ case MOVIE_SELECT_CAMERA_MODE:
+ m_bCommandActive = false; // this is wrong
+ break;
+ }
+}
+
+void CSceneEdit::ClearForNewCommand(void)
+{
+ m_nActor = -1;
+ m_nActor2 = -1;
+ m_nVehicle = -1;
+ m_bActorSelected = false;
+ m_bActor2Selected = false;
+ m_bVehicleSelected = false;
+ m_bDrawGotoArrow = false;
+}
+void CSceneEdit::SelectActor(void)
+{
+ m_bActorSelected = false;
+ if (m_nActor != -1) {
+ if (CPad::GetPad(1)->GetLeftShoulder1JustDown()) {
+ CPed* pPed;
+ do {
+ if (--m_nActor < 0)
+ m_nActor = NUM_ACTORS_IN_MOVIE - 1;
+ pPed = pActors[m_nActor];
+ } while (pPed == nil);
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pPed->GetPosition() - m_vecCamHeading;
+ }
+ else if (CPad::GetPad(1)->GetRightShoulder1JustDown()) {
+ CPed* pPed;
+ do {
+ if (++m_nActor == NUM_ACTORS_IN_MOVIE)
+ m_nActor = 0;
+ pPed = pActors[m_nActor];
+ } while (pPed == nil);
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pPed->GetPosition() - m_vecCamHeading;
+ }
+ m_vecCurrentPosition = pActors[m_nActor]->GetPosition();
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_bActorSelected = true;
+ m_bCommandActive = false;
+ }
+ else if (CPad::GetPad(1)->GetCircleJustDown()) {
+ m_nActor = -1;
+ }
+ }
+ else if (m_nNumActors != 0) {
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pActors[i] != nil) {
+ m_nActor = i;
+ break;
+ }
+ }
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pActors[m_nActor]->GetPosition() - m_vecCamHeading;
+ if (m_nNumActors == 1) {
+ m_bActorSelected = true;
+ m_bCommandActive = false;
+ }
+ }
+ else {
+ m_bCommandActive = false;
+ }
+}
+
+void CSceneEdit::SelectActor2(void)
+{
+ m_bActor2Selected = false;
+ if (m_nNumActors <= 1) {
+ m_bCommandActive = false;
+ return;
+ }
+ if (m_nActor2 != -1) {
+ if (CPad::GetPad(1)->GetLeftShoulder1JustDown()) {
+ CPed* pPed;
+ do {
+ if (--m_nActor2 < 0)
+ m_nActor2 = NUM_ACTORS_IN_MOVIE - 1;
+ pPed = pActors[m_nActor2];
+ } while (pPed == nil || pPed == pActors[m_nActor]);
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pPed->GetPosition() - m_vecCamHeading;
+ }
+ else if (CPad::GetPad(1)->GetRightShoulder1JustDown()) {
+ CPed* pPed;
+ do {
+ if (++m_nActor2 == NUM_ACTORS_IN_MOVIE)
+ m_nActor2 = 0;
+ pPed = pActors[m_nActor2];
+ } while (pPed == nil || pPed == pActors[m_nActor]);
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pPed->GetPosition() - m_vecCamHeading;
+ }
+ m_vecCurrentPosition = pActors[m_nActor2]->GetPosition();
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_bActor2Selected = true;
+ m_bCommandActive = false;
+ }
+ else if (CPad::GetPad(1)->GetCircleJustDown()) {
+ m_nActor2 = -1;
+ }
+ }
+ else {
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pActors[i] != nil && pActors[m_nActor] != pActors[i] ) {
+ m_nActor2 = i;
+ break;
+ }
+ }
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pActors[m_nActor2]->GetPosition() - m_vecCamHeading;
+ }
+}
+
+void CSceneEdit::SelectVehicle(void)
+{
+ m_bVehicleSelected = false;
+ if (m_nVehicle != -1) {
+ if (CPad::GetPad(1)->GetLeftShoulder1JustDown()) {
+ CVehicle* pVehicle;
+ do {
+ if (--m_nVehicle < 0)
+ m_nVehicle = NUM_VEHICLES_IN_MOVIE - 1;
+ pVehicle = pVehicles[m_nVehicle];
+ } while (pVehicle == nil);
+ }
+ else if (CPad::GetPad(1)->GetRightShoulder1JustDown()) {
+ CVehicle* pVehicle;
+ do {
+ if (++m_nVehicle == NUM_VEHICLES_IN_MOVIE)
+ m_nVehicle = 0;
+ pVehicle = pVehicles[m_nVehicle];
+ } while (pVehicle == nil);
+ }
+ m_vecCurrentPosition = pVehicles[m_nVehicle]->GetPosition();
+ TheCamera.Cams[TheCamera.ActiveCam].Source = pVehicles[m_nVehicle]->GetPosition() - m_vecCamHeading;
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_bVehicleSelected = true;
+ m_bCommandActive = false;
+ }
+ else if (CPad::GetPad(1)->GetCircleJustDown()) {
+ m_nVehicle = -1;
+ }
+ }
+ else if (m_nNumVehicles != 0) {
+ for (int i = 0; i < NUM_ACTORS_IN_MOVIE; i++) {
+ if (pVehicles[i] != nil) {
+ m_nVehicle = i;
+ break;
+ }
+ }
+ }
+}
+
+bool CSceneEdit::SelectWeapon(void)
+{
+ if (m_nWeaponType == WEAPONTYPE_UNARMED) {
+ m_nWeaponType = WEAPONTYPE_COLT45;
+ return false;
+ }
+ if (CPad::GetPad(1)->GetLeftShoulder1JustDown()) {
+ if (++m_nWeaponType >= WEAPONTYPE_DETONATOR)
+ m_nWeaponType = WEAPONTYPE_BASEBALLBAT;
+ pActors[m_nActor]->ClearWeapons();
+ pActors[m_nActor]->GiveWeapon((eWeaponType)m_nWeaponType, 1000);
+ pActors[m_nActor]->AddWeaponModel(CWeaponInfo::GetWeaponInfo(pActors[m_nActor]->GetWeapon()->m_eWeaponType)->m_nModelId);
+ pActors[m_nActor]->SetCurrentWeapon(m_nWeaponType);
+ }
+ else if (CPad::GetPad(1)->GetRightShoulder1JustDown()){
+ if (--m_nWeaponType <= WEAPONTYPE_UNARMED)
+ m_nWeaponType = WEAPONTYPE_GRENADE;
+ pActors[m_nActor]->ClearWeapons();
+ pActors[m_nActor]->GiveWeapon((eWeaponType)m_nWeaponType, 1000);
+ pActors[m_nActor]->AddWeaponModel(CWeaponInfo::GetWeaponInfo(pActors[m_nActor]->GetWeapon()->m_eWeaponType)->m_nModelId);
+ pActors[m_nActor]->SetCurrentWeapon(m_nWeaponType);
+ }
+ if (CPad::GetPad(1)->GetTriangleJustDown()) {
+ m_bCommandActive = false;
+ return true;
+ }
+ if (CPad::GetPad(1)->GetCircleJustDown()) {
+ pActors[m_nActor]->ClearWeapons();
+ m_nWeaponType = WEAPONTYPE_UNARMED;
+ m_bCommandActive = false;
+ return false;
+ }
+ return false;
+} \ No newline at end of file
diff --git a/src/control/SceneEdit.h b/src/control/SceneEdit.h
index 0de72c19..6dcefa31 100644
--- a/src/control/SceneEdit.h
+++ b/src/control/SceneEdit.h
@@ -1,14 +1,95 @@
#pragma once
+class CPed;
+class CVehicle;
+
+struct CMovieCommand
+{
+ int32 m_nCommandId;
+ CVector m_vecPosition;
+ CVector m_vecCamera;
+ int16 m_nActorId;
+ int16 m_nActor2Id;
+ int16 m_nVehicleId;
+ int16 m_nModelIndex;
+};
+
class CSceneEdit
{
public:
- static bool &m_bEditOn;
- static int32 &m_bCameraFollowActor;
- static bool &m_bRecording;
- static CVector &m_vecCurrentPosition;
- static CVector &m_vecCamHeading;
+ enum {
+ MOVIE_DO_NOTHING = 0,
+ MOVIE_NEW_ACTOR,
+ MOVIE_MOVE_ACTOR,
+ MOVIE_SELECT_ACTOR,
+ MOVIE_DELETE_ACTOR,
+ MOVIE_NEW_VEHICLE,
+ MOVIE_MOVE_VEHICLE,
+ MOVIE_SELECT_VEHICLE,
+ MOVIE_DELETE_VEHICLE,
+ MOVIE_GIVE_WEAPON,
+ MOVIE_GOTO,
+ MOVIE_GOTO_WAIT,
+ MOVIE_GET_IN_CAR,
+ MOVIE_GET_OUT_CAR,
+ MOVIE_KILL,
+ MOVIE_FLEE,
+ MOVIE_WAIT,
+ MOVIE_POSITION_CAMERA,
+ MOVIE_SET_CAMERA_TARGET,
+ MOVIE_SELECT_CAMERA_MODE,
+ MOVIE_SAVE_MOVIE,
+ MOVIE_LOAD_MOVIE,
+ MOVIE_PLAY_MOVIE,
+ MOVIE_END,
+ MOVIE_TOTAL_COMMANDS
+ };
+ enum {
+ NUM_ACTORS_IN_MOVIE = 5,
+ NUM_VEHICLES_IN_MOVIE = 5,
+ NUM_COMMANDS_IN_MOVIE = 20
+ };
+ static int32 m_bCameraFollowActor;
+ static CVector m_vecCurrentPosition;
+ static CVector m_vecCamHeading;
+ static CVector m_vecGotoPosition;
+ static int32 m_nVehicle;
+ static int32 m_nVehicle2;
+ static int32 m_nActor;
+ static int32 m_nActor2;
+ static int32 m_nVehiclemodelId;
+ static int32 m_nPedmodelId;
+ static int16 m_nCurrentMovieCommand;
+ static int16 m_nCurrentCommand;
+ static int16 m_nCurrentVehicle;
+ static int16 m_nCurrentActor;
+ static bool m_bEditOn;
+ static bool m_bRecording;
+ static bool m_bCommandActive;
+ static bool m_bActorSelected;
+ static bool m_bActor2Selected;
+ static bool m_bVehicleSelected;
+ static int16 m_nNumActors;
+ static int16 m_nNumVehicles;
+ static int16 m_nNumMovieCommands;
+ static int16 m_nWeaponType;
+ static CPed* pActors[NUM_ACTORS_IN_MOVIE];
+ static CVehicle* pVehicles[NUM_VEHICLES_IN_MOVIE];
+ static bool m_bDrawGotoArrow;
+ static CMovieCommand Movie[NUM_COMMANDS_IN_MOVIE];
+ static void LoadMovie(void);
+ static void SaveMovie(void);
+ static void Initialise(void);
+ static void InitPlayback(void);
+ static void ReInitialise(void);
static void Update(void);
- static void Init(void);
+ static void Draw(void);
+ static void ProcessCommand(void);
+ static void PlayBack(void);
+ static void ClearForNewCommand(void);
+ static void SelectActor(void);
+ static void SelectActor2(void);
+ static void SelectVehicle(void);
+ static bool SelectWeapon(void);
};
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 1f085d32..428ac66a 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -9147,7 +9147,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
}
case COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER:
{
- CollectParameters(&m_nIp, 2);
+ CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pVehicle);
CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), false);
@@ -10076,8 +10076,8 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp)
case COMMAND_LOCATE_PLAYER_ON_FOOT_CAR_3D:
result = !pPlayerInfo->m_pPed->bInVehicle;
break;
- case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_2D:
- case COMMAND_LOCATE_PLAYER_IN_CAR_CHAR_3D:
+ case COMMAND_LOCATE_PLAYER_IN_CAR_CAR_2D:
+ case COMMAND_LOCATE_PLAYER_IN_CAR_CAR_3D:
result = pPlayerInfo->m_pPed->bInVehicle;
break;
default:
@@ -11359,7 +11359,7 @@ VALIDATESAVEBUF(size)
void CTheScripts::ClearSpaceForMissionEntity(const CVector& pos, CEntity* pEntity)
{
- static CColPoint aTempColPoints[32];
+ static CColPoint aTempColPoints[MAX_COLLISION_POINTS];
int16 entities = 0;
CEntity* aEntities[16];
CWorld::FindObjectsKindaColliding(pos, pEntity->GetBoundRadius(), false, &entities, 16, aEntities, false, true, true, false, false);