summaryrefslogtreecommitdiffstats
path: root/src/control/Script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/control/Script.cpp')
-rw-r--r--src/control/Script.cpp1505
1 files changed, 964 insertions, 541 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp
index 4b70a678..536055fa 100644
--- a/src/control/Script.cpp
+++ b/src/control/Script.cpp
@@ -11,6 +11,7 @@
#include "CivilianPed.h"
#include "Clock.h"
#include "CopPed.h"
+#include "Coronas.h"
#include "Debug.h"
#include "DMAudio.h"
#include "EmergencyPed.h"
@@ -49,16 +50,19 @@
#include "Timecycle.h"
#include "TxdStore.h"
#include "Bike.h"
+#include "smallHeap.h"
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
#include <stdarg.h>
#endif
-uint8 CTheScripts::ScriptSpace[SIZE_SCRIPT_SPACE];
+//--LCS: file done except TODOs and command table
+uint8* CTheScripts::ScriptSpace;
CRunningScript CTheScripts::ScriptsArray[MAX_NUM_SCRIPTS];
intro_text_line CTheScripts::IntroTextLines[MAX_NUM_INTRO_TEXT_LINES];
intro_script_rectangle CTheScripts::IntroRectangles[MAX_NUM_INTRO_RECTANGLES];
CSprite2d CTheScripts::ScriptSprites[MAX_NUM_SCRIPT_SRPITES];
script_sphere_struct CTheScripts::ScriptSphereArray[MAX_NUM_SCRIPT_SPHERES];
+tCollectiveData CTheScripts::CollectiveArray[MAX_NUM_COLLECTIVES];
tUsedObject CTheScripts::UsedObjectArray[MAX_NUM_USED_OBJECTS];
int32 CTheScripts::MultiScriptArray[MAX_NUM_MISSION_SCRIPTS];
tBuildingSwap CTheScripts::BuildingSwapArray[MAX_NUM_BUILDING_SWAPS];
@@ -94,10 +98,19 @@ uint32 CTheScripts::LastMissionPassedTime;
uint16 CTheScripts::NumberOfExclusiveMissionScripts;
bool CTheScripts::bPlayerHasMetDebbieHarry;
bool CTheScripts::bPlayerIsInTheStatium;
-#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
-int16 CTheScripts::CardStack[CARDS_IN_DECK * MAX_DECKS];
-int16 CTheScripts::CardStackPosition;
-#endif
+int CTheScripts::AllowedCollision[MAX_ALLOWED_COLLISIONS];
+int CTheScripts::FSDestroyedFlag;
+short* CTheScripts::SavedVarIndices;
+int CTheScripts::NumSaveVars;
+int gScriptsFile = -1;
+int CTheScripts::NextProcessId = 1;
+bool CTheScripts::InTheScripts;
+CRunningScript* pCurrent;
+uint16 CTheScripts::NumTrueGlobals;
+uint16 CTheScripts::MostGlobals;
+CVector gVectorSetInLua;
+int CTheScripts::NextScriptCoronaID;
+base::cSList<script_corona> CTheScripts::mCoronas;
#ifdef MISSION_REPLAY
@@ -354,6 +367,11 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_WHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_WHILENOT, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_ENDWHILE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_214, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_215, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_216, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_217, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_218, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_ANDOR, INPUT_ARGUMENTS(ARGTYPE_ANDOR,), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_LAUNCH_MISSION, INPUT_ARGUMENTS(ARGTYPE_LABEL,), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_MISSION_HAS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
@@ -408,7 +426,7 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_ADD_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_IS_SCORE_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
REGISTER_COMMAND(COMMAND_STORE_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_ALTER_WANTED_LEVEL_NO_DROP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_IS_WANTED_LEVEL_GREATER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
@@ -1216,7 +1234,7 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_IS_CAR_PASSENGER_SEAT_FREE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
REGISTER_COMMAND(COMMAND_GET_CHAR_IN_CAR_PASSENGER_SEAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
REGISTER_COMMAND(COMMAND_SET_CHAR_IS_CHRIS_CRIMINAL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_START_CREDITS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_START_CREDITS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_STOP_CREDITS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_ARE_CREDITS_FINISHED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
REGISTER_COMMAND(COMMAND_CREATE_SINGLE_PARTICLE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
@@ -1304,7 +1322,7 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_SHUT_CHAR_UP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_SET_ENABLE_RC_DETONATE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_SET_CAR_RANDOM_ROUTE_SEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_IS_ANY_PICKUP_AT_COORDS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_ANY_PICKUP_AT_COORDS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
REGISTER_COMMAND(COMMAND_GET_FIRST_PICKUP_COORDS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
REGISTER_COMMAND(COMMAND_GET_NEXT_PICKUP_COORDS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
REGISTER_COMMAND(COMMAND_REMOVE_ALL_CHAR_WEAPONS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
@@ -1576,39 +1594,222 @@ const tScriptCommandData commands[] = {
REGISTER_COMMAND(COMMAND_REGISTER_FIRE_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
REGISTER_COMMAND(COMMAND_IS_AUSTRALIAN_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
REGISTER_COMMAND(COMMAND_DISARM_CAR_BOMB, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
-#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT)
REGISTER_COMMAND(COMMAND_IS_JAPANESE_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
-#elif (!defined GTA_PS2)
- REGISTER_COMMAND(COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
-#endif
-#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
- REGISTER_COMMAND(COMMAND_SHUFFLE_CARD_DECKS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_FETCH_NEXT_CARD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_GET_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_IS_DEBUG_CAMERA_ON, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
- REGISTER_COMMAND(COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_SET_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_IS_OBJECT_STATIC, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
- REGISTER_COMMAND(COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_DO_2D_RECTANGLES_COLLIDE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
- REGISTER_COMMAND(COMMAND_GET_OBJECT_ROTATION_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_GET_OBJECT_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
-#endif
-#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT)
- REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_START, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_END, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_CUTSCENE_SCROLL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
-#elif (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
- REGISTER_COMMAND(COMMAND_IS_MISSION_SKIP, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_SET_IN_AMMUNATION, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_DO_SAVE_GAME, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_IS_RETRY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
- REGISTER_COMMAND(COMMAND_DUMMY, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_START, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_MARK_CUTSCENE_END, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
- REGISTER_COMMAND(COMMAND_CUTSCENE_SCROLL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
-#endif
+ REGISTER_COMMAND(COMMAND_1442, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1443, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DOT_PRODUCT_2D, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DOT_PRODUCT_3D, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DEBUG_PRINT_WITH_1_FLOAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DEBUG_PRINT_WITH_2_FLOATS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DEBUG_PRINT_WITH_3_FLOATS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_PAD_BUTTON_STATE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_NAVIGATION_ARROW, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CLEAR_NAVIGATION_ARROW, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CALL, INPUT_ARGUMENTS(ARGTYPE_FUNCTION, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CALLNOT, INPUT_ARGUMENTS(ARGTYPE_FUNCTION, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CAR_AUTOMOBILE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CAR_BIKE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CAR_PLANE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CAR_HELI, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_1460, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1461, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1462, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1463, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1464, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1465, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1466, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1467, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1468, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1469, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1470, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1471, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1472, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1473, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1474, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1475, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1476, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_RETURN_IF_TRUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_RETURN_TRUE_IF_TRUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_RC_HELI_HEIGHT_LIMIT, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CREATE_SCRIPT_CORONA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REMOVE_SCRIPT_CORONA, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_BOAT_IN_WATER, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CAR_DRIVER_BEING_JACKED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CAR_TILTED_BY_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_PLAYER_USING_FIRST_PERSON_WEAPON_CAMERA, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_1489, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1490, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1491, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_DEBUG_MENU_ACTIVE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_DRAW_HUD, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DISABLE_FERRY_PATH, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ENABLE_FERRY_PATH, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_CLOSEST_DOCKED_FERRY, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_OPEN_FERRY_DOOR, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CLOSE_FERRY_DOOR, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_FERRY_DOOR_OPEN, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_FERRY_DOOR_CLOSED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SKIP_FERRY_TO_NEXT_DOCK, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_DROPS_WEAPONS_ON_DEATH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CHAR_CROUCHING, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_FERRY_BOARDING_SPACE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_FERRY_HEADING, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_FERRIES_ENABLED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_COMPLETE_FERRY_DOOR_MOVEMENT, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_OVERRIDE_CAR_REMOTE_CONTROL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CANCEL_REMOTE_MODE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_CAR_SOLD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_WITH_CAR_SALES, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_BRIDGE_STATE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_OBJECT_TURN_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_OBJECT_MASS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_HAS_CUTSCENE_LOADED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_UNIQUE_JUMPS_FOUND, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_HIDDEN_PACKAGES_COLLECTED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_BIKE_SOLD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_WITH_BIKE_SALES, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_PACKAGE_SMUGGLED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_SMUGGLER_WASTED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_FASTEST_SMUGGLING_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_DIVE_FROM_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_WRECK_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_IN_COACH, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_COLLECTING_TRASH, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_HITMAN_KILLED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_GUARDIAN_ANGEL_MISSION_PASSED, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_GUARDIAN_ANGEL_JUSTICE_DISHED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_BEST_BANDIT_LAP_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_BEST_BANDIT_POSITION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_MOST_TIME_LEFT_TRAIN_RACE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_TRAIN_CASH_EARNED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_FASTEST_HELI_RACE_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_BEST_HELI_RACE_POSITION, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_OUTFIT_CHANGE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_STREET_RACE_FASTEST_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_STREET_RACE_FASTEST_LAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_STREET_RACE_BEST_POSITION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_HAS_OBJECT_BEEN_DAMAGED_BY_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_CLEAR_OBJECT_LAST_WEAPON_DAMAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CAR_TURN_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CAR_MOVE_SPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_OBJECT_PROOFS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_CAMERA_PED_ZOOM_INDICATOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CAMERA_PED_ZOOM_INDICATOR, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_CAR_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CAR_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_DEBUG_MENU_ON, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_OPEN_VAN_BACK_DOORS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_CHAR_THREAT_CHAR, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_FREEZE_PED_ZOOM_SWITCH, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_OBJECT_RENDERED_DAMAGED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_RANDOM_CAR_IN_AREA_NO_SAVE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_PLAYER_MADE_SAFE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_IF_FREE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_E3_BUILD, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_DECLARE_FORT_STAUNTON_DESTROYED_FLAG, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CLEAR_BIG_MESSAGES, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CLEAR_AREA_OF_OBJECTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_LOAD_NON_STANDARD_PED_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_UNLOAD_NON_STANDARD_PED_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1566, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_BUILD_WORLD_GEOMETRY, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_STORE_BUILDING_SWAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_MULTIPLAYER_ACTIVE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_MULTIPLAYER_MODE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_MULTIPLAYER_SCRIPT_DONE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_MULTIPLAYER_SERVER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_MULTIPLAYER_TEAM_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_MULTIPLAYER_TEAM_ID, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DOES_SHORTCUT_TAXI_EXIST, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_ONSCREEN_TIMER_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_ONSCREEN_TIMER_BACKGROUND_COLOUR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REMOVE_CAR_BOOT, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_POINT_3D_MARKER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_VECTOR_FROM_MULTIPLAYER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_STRING, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS, INPUT_ARGUMENTS(ARGTYPE_STRING, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SWITCH_FERRY_COLLISION, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_MAX_HEALTH, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_SHOOT_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_ATTACK_TIMER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_HELI_ROTOR_BLADES_FULLSPEED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CRUSHER_REWARD_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SWAP_BUILDINGS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_STREAM_BUILDING_SWAPS, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_WORLD_STREAMING_COMPLETE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SWAP_TO_STREAMED_SECTOR, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_ATTACKS_PLAYER_WITH_COPS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_FACE_PLANT_DISTANCE, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_MAX_SECONDS_ON_CARNAGE_LEFT, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_MAX_KILLS_ON_RC_TRIAD, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_HIGHEST_LEVEL_SLASH_TV, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_WITH_SLASH_TV, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_TOTAL_KILLS_ON_SLASH_TV, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_NOODLES_DELIVERED, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_SCRAPYARD_CHALLENGE_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_9MM_MAYHEM_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_SCOOTER_SHOOTER_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_MONEY_MADE_FROM_TOURIST, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_TOURISTS_TAKEN_TO_SPOTS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_EXPORTED_CARS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_TOTAL_EXPORT_CARS, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_DIRT_BIKE_FASTEST_LAP, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_DIRT_BIKE_FASTEST_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_DIRT_BIKE_AIR_TIME, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_ARROW_3D_MARKER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_NOW_OVERRIDE_FADE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_PICKUP_VALUE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_PICKUP_VALUE, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_DEVELOPER, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_DEVELOPER_FLAG, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_WICHITA_WIPEOUT_SCORE, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ATTACH_OBJECT_TO_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DETACH_OBJECT_FROM_CAR, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_PAD_STICKS_MULTIPLIER, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_SUBTITLE_NOW, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_SUBTITLE_NOW_OVERRIDE_FADE, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_SUBTITLE_NOW_NO_BRIEF, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_WITH_NUMBER_NOW_NO_BRIEF, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_ANGLE_BETWEEN_POINTS, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_OVERRIDE_CHAR_MOVE_ANIM, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_1627, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ENABLE_EMERGENCY_VEHICLES, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_ADD_UNLOCKED_COSTUME, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CLEAR_MULTIPLAYER_SPLASH_SCREEN, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_WITH_2_NUMBERS_NOW_NO_BRIEF, INPUT_ARGUMENTS(ARGTYPE_STRING, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_OBJECT_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_OBJECT_ORIENTATION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_CHANGE_ONSCREEN_COUNTER_PREFIX, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_STORE_PLAYER_OUTFIT, INPUT_ARGUMENTS(ARGTYPE_STRING, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_STRING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_STRING, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_PLAYER_CURRENT_WEAPON_AMMO_IN_CLIP, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_WAIT_STATE_REPEAT, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_BEST_TIME_GOGO_FAGGIO, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_LOCK_GARAGE, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_FINAL_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_ALLOWED_COLLISION, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_REGISTER_GUARDIAN_ANGEL_LEVEL, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DISPLAY_ONSCREEN_TIMER_WITH_NUMBER_AND_2_STRINGS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_STRING, ARGTYPE_STRING, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_GET_PLAYER_STORED_WEAPON, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(ARGTYPE_INT, ), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_DISABLE_PAUSE_MENU, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_IS_CHANNEL_PLAYING, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), true, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CLOCK_EVENT_WARNING, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_EXTRA_COLOUR_LIGHT_DIRECTION, INPUT_ARGUMENTS(ARGTYPE_FLOAT, ARGTYPE_FLOAT, ARGTYPE_FLOAT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CHAR_CAN_BE_TARGETTED_BY_LEADER, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_HELP_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_HELP_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_PRINT_HELP_FOREVER_ALWAYS_NO_BRIEF, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_SET_CAR_IS_REWARD, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
+ REGISTER_COMMAND(COMMAND_FREEZE_ALL_PLAYER_FOLLOWERS, INPUT_ARGUMENTS(ARGTYPE_INT, ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""),
};
#undef REGISTER_COMMAND
#undef INPUT_ARGUMENTS
@@ -1681,6 +1882,23 @@ cleanup_entity_struct* CMissionCleanup::FindFree()
return nil;
}
+void SleepThisPed(cleanup_entity_struct* pCleanup, CPed* pPed)
+{
+ printf("*** SLEEPING PED %i %i\n", pCleanup->id, pPed->GetModelIndex());
+ if (!pPed->GetIsStatic())
+ pPed->RemoveFromMovingList();
+ pPed->bIsStaticWaitingForCollision = true;
+}
+
+void WakeThisPed(cleanup_entity_struct* pCleanup, CPed* pPed)
+{
+ printf("*** WAKING UP PED %i %i\n", pCleanup->id, pPed->GetModelIndex());
+ pPed->bIsStaticWaitingForCollision = false;
+ if (!pPed->bIsStatic)
+ pPed->AddToMovingList();
+
+}
+
void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
{
cleanup_entity_struct* pNew = FindFree();
@@ -1750,46 +1968,100 @@ void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObjects()
{
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id);
if (pVehicle) {
- if (pVehicle->bIsStaticWaitingForCollision) {
- if (CColStore::HasCollisionLoaded(pVehicle->GetPosition())) {
- pVehicle->bIsStaticWaitingForCollision = false;
+ eLevelName level = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition());
+ if (level == LEVEL_GENERIC)
+ level = CGame::currLevel;
+ if (!CColStore::HasCollisionLoaded(level)) {
+ if (!pVehicle->bIsStaticWaitingForCollision) {
+ if (!pVehicle->IsHeli() && !pVehicle->IsPlane() && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI &&
+ pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE) {
+ printf("*** SLEEPING VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex());
if (!pVehicle->GetIsStatic())
- pVehicle->AddToMovingList();
+ pVehicle->RemoveFromMovingList();
+ pVehicle->bIsStaticWaitingForCollision = true;
+ }
}
}
- }
- break;
- }
- case CLEANUP_CHAR:
- {
- CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
- if (pPed) {
- if (pPed->bIsStaticWaitingForCollision) {
- if (CColStore::HasCollisionLoaded(pPed->GetPosition())) {
- pPed->bIsStaticWaitingForCollision = false;
- if (!pPed->GetIsStatic())
- pPed->AddToMovingList();
+ else {
+ if (pVehicle->bIsStaticWaitingForCollision) {
+ printf("*** WAKING UP VEHICLE %i %i\n", m_sEntities[i].id, pVehicle->GetModelIndex());
+ pVehicle->bIsStaticWaitingForCollision = false;
+ if (!pVehicle->bIsStatic)
+ pVehicle->AddToMovingList();
}
}
}
- break;
}
+ break;
case CLEANUP_OBJECT:
- {
CObject* pObject = CPools::GetObjectPool()->GetAt(m_sEntities[i].id);
if (pObject) {
- if (pObject->bIsStaticWaitingForCollision) {
- if (CColStore::HasCollisionLoaded(pObject->GetPosition())) {
- pObject->bIsStaticWaitingForCollision = false;
+ eLevelName level = CTheZones::GetLevelFromPosition(&pObject->GetPosition());
+ if (level == LEVEL_GENERIC)
+ level = CGame::currLevel;
+ if (!CColStore::HasCollisionLoaded(level)) {
+ if (!pObject->bIsStaticWaitingForCollision) {
if (!pObject->GetIsStatic())
+ pObject->RemoveFromMovingList();
+ pObject->bIsStaticWaitingForCollision = true;
+ }
+ }
+ else {
+ if (pObject->bIsStaticWaitingForCollision) {
+ pObject->bIsStaticWaitingForCollision = false;
+ if (!pObject->bIsStatic)
pObject->AddToMovingList();
}
}
}
- break;
}
- default:
- break;
+ }
+ for (int i = 0; i < MAX_CLEANUP; i++) {
+ switch (m_sEntities[i].type) {
+ case CLEANUP_CHAR:
+ {
+ CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
+ if (pPed) {
+ eLevelName level = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
+ if (level == LEVEL_GENERIC)
+ level = CGame::currLevel;
+ if (!pPed->bIsStaticWaitingForCollision) {
+ if (pPed->bInVehicle) {
+ if (pPed->m_pMyVehicle->GetIsStatic()) {
+ SleepThisPed(&m_sEntities[i], pPed);
+ continue;
+ }
+ }
+ if (!CColStore::HasCollisionLoaded(level)) {
+ if (pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() ||
+ pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic())
+ SleepThisPed(&m_sEntities[i], pPed);
+ }
+ }
+ else {
+ if (!pPed->bInVehicle) {
+ if (CColStore::HasCollisionLoaded(level)) {
+ if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() ||
+ pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()))
+ WakeThisPed(&m_sEntities[i], pPed);
+ }
+ }
+ else {
+ if (!pPed->m_pMyVehicle->GetIsStatic()) {
+ WakeThisPed(&m_sEntities[i], pPed);
+ continue;
+ }
+ if (CColStore::HasCollisionLoaded(level)) {
+ if (!(pPed->bInVehicle && pPed->m_pMyVehicle->GetIsStatic() ||
+ pPed->m_attachedTo && pPed->m_attachedTo->GetIsStatic()))
+ WakeThisPed(&m_sEntities[i], pPed);
+ }
+ }
+ }
+
+ }
+ }
+ break;
}
}
}
@@ -1801,6 +2073,8 @@ void CMissionCleanup::Process()
CCarCtrl::CarDensityMultiplier = 1.0f;
CPed::nThreatReactionRangeMultiplier = 1;
CPed::nEnterCarRangeMultiplier = 1;
+ for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++)
+ CTheScripts::AllowedCollision[i] = 0;
FindPlayerPed()->m_pWanted->m_fCrimeSensitivity = 1.0f;
CRoadBlocks::ClearScriptRoadBlocks();
CRouteNode::Initialise();
@@ -1808,20 +2082,19 @@ void CMissionCleanup::Process()
TheCamera.Restore();
TheCamera.SetWideScreenOff();
CSpecialFX::bLiftCam = false;
- CSpecialFX::bVideoCam = false;
- CTimeCycle::StopExtraColour(0);
+ // TODO(LCS): CHud::m_ClockEventWarningMinutes = 0;
+ // TODO(LCS): CHud::m_ClockEventFlashTimer = 0;
+ CTimeCycle::StopExtraColour(0); // TODO: thiscall
for (int i = 0; i < MISSION_AUDIO_SLOTS; i++)
DMAudio.ClearMissionAudio(i);
CWeather::ReleaseWeather();
for (int i = 0; i < NUM_OF_SPECIAL_CHARS; i++)
CStreaming::SetMissionDoesntRequireSpecialChar(i);
- for (int i = 0; i < NUM_OF_CUTSCENE_OBJECTS; i++)
- CStreaming::SetMissionDoesntRequireModel(MI_CUTOBJ01 + i);
CStreaming::ms_disableStreaming = false;
- CHud::m_ItemToFlash = -1;
- CHud::SetHelpMessage(nil, false);
+ if (CHud::m_ItemToFlash != ITEM_ARMOUR && CHud::m_ItemToFlash != ITEM_HEALTH)
+ CHud::m_ItemToFlash = -1;
+ CHud::SetHelpMessage(nil, false); // nil, false, false, true TODO(LCS)
CUserDisplay::OnscnTimer.m_bDisabled = false;
- CTheScripts::RemoveScriptTextureDictionary();
CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByCops = false;
CWorld::Players[0].m_pPed->m_pWanted->m_bIgnoredByEveryone = false;
CWorld::Players[0].MakePlayerSafe(false);
@@ -1829,10 +2102,11 @@ void CMissionCleanup::Process()
CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0;
CPad::GetPad(0)->SetDrunkInputDelay(0);
CWorld::Players[0].m_bDriveByAllowed = true;
+ CPad::GetPad(0)->unk_B4 = 1.0f;
+ CPad::GetPad(0)->unk_B8 = 0.5f;
DMAudio.ShutUpPlayerTalking(FALSE);
CVehicle::bDisableRemoteDetonation = false;
CVehicle::bDisableRemoteDetonationOnContact = false;
- CGameLogic::ClearShortCut();
CTheScripts::RiotIntensity = 0;
CTheScripts::StoreVehicleIndex = -1;
CTheScripts::StoreVehicleWasRandom = true;
@@ -1868,6 +2142,10 @@ void CMissionCleanup::Process()
}
RemoveEntityFromList(m_sEntities[i].id, m_sEntities[i].type);
}
+ for (int i = 1; i < NUMSTREAMINFO; i++) {
+ if (CStreaming::IsScriptOwnedModel(i))
+ CStreaming::SetMissionDoesntRequireModel(i);
+ }
#ifdef SECUROM
if ((myrand() & 3) == 2){
// if pirated game
@@ -1896,7 +2174,7 @@ bool CUpsideDownCarCheck::IsCarUpsideDown(int32 id)
bool CUpsideDownCarCheck::IsCarUpsideDown(CVehicle* pVehicle)
{
- assert(pVehicle);
+ script_assert(pVehicle);
return pVehicle->GetUp().z <= UPSIDEDOWN_UP_THRESHOLD &&
pVehicle->GetMoveSpeed().Magnitude() < UPSIDEDOWN_MOVE_SPEED_THRESHOLD &&
pVehicle->GetTurnSpeed().Magnitude() < UPSIDEDOWN_TURN_SPEED_THRESHOLD;
@@ -2035,109 +2313,157 @@ bool CStuckCarCheck::HasCarBeenStuckForAWhile(int32 id)
return false;
}
-void CRunningScript::CollectParameters(uint32* pIp, int16 total)
+void CRunningScript::CollectParameters(uint32* pIp, int16 total, int* pParameters)
{
- for (int16 i = 0; i < total; i++){
- uint16 varIndex;
+ while (total--){
switch (CTheScripts::Read1ByteFromScript(pIp))
{
- case ARGUMENT_INT32:
- case ARGUMENT_FLOAT:
- ScriptParams[i] = CTheScripts::Read4BytesFromScript(pIp);
+ case ARGUMENT_END:
+ return;
+ case ARGUMENT_INT_ZERO:
+ *pParameters = 0;
+ break;
+ case ARGUMENT_FLOAT_ZERO:
+ *pParameters = 0;
break;
- case ARGUMENT_GLOBALVAR:
- varIndex = CTheScripts::Read2BytesFromScript(pIp);
- script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace());
- ScriptParams[i] = *((int32*)&CTheScripts::ScriptSpace[varIndex]);
+ case ARGUMENT_FLOAT_1BYTE:
+ *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24;
break;
- case ARGUMENT_LOCALVAR:
- varIndex = CTheScripts::Read2BytesFromScript(pIp);
- script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables));
- ScriptParams[i] = m_anLocalVariables[varIndex];
+ case ARGUMENT_FLOAT_2BYTES:
+ *pParameters = (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16;
+ break;
+ case ARGUMENT_FLOAT_3BYTES:
+ *pParameters = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8;
+ *pParameters |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16;
+ break;
+ case ARGUMENT_INT32:
+ case ARGUMENT_FLOAT:
+ *pParameters = CTheScripts::Read4BytesFromScript(pIp);
break;
case ARGUMENT_INT8:
- ScriptParams[i] = CTheScripts::Read1ByteFromScript(pIp);
+ *pParameters = CTheScripts::Read1ByteFromScript(pIp);
break;
case ARGUMENT_INT16:
- ScriptParams[i] = CTheScripts::Read2BytesFromScript(pIp);
+ *pParameters = CTheScripts::Read2BytesFromScript(pIp);
break;
default:
- script_assert(0);
+ *pIp -= 1;
+ *pParameters = *GetPointerToScriptVariable(pIp, 0);
break;
}
+ pParameters++;
}
}
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
-int CRunningScript::CollectParameterForDebug(char* buf, bool& var)
+int32* GetPointerToScriptVariableForDebug(CRunningScript* pScript, uint32* pIp, char* buf)
{
- uint16 varIndex;
char tmpstr[24];
+ uint8 type = CTheScripts::Read1ByteFromScript(pIp);
+ if (type >= ARGUMENT_GLOBAL_ARRAY) {
+ uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp);
+ uint8 index_id = CTheScripts::Read1ByteFromScript(pIp);
+ uint8 size = CTheScripts::Read1ByteFromScript(pIp);
+ script_assert(size > 0);
+ script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size);
+ uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1);
+ sprintf(tmpstr, " $%d[%d@ (%d)]", ((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index_in_block, index_id, pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id]);
+ strcat(buf, tmpstr);
+ return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index + index_in_block)];
+ }
+ else if (type >= ARGUMENT_GLOBAL) {
+ uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp);
+ sprintf(tmpstr, " $%d", ((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block);
+ strcat(buf, tmpstr);
+ return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block)];
+ }
+ else if (type >= ARGUMENT_LOCAL_ARRAY) {
+ uint8 index_id = CTheScripts::Read1ByteFromScript(pIp);
+ uint8 size = CTheScripts::Read1ByteFromScript(pIp);
+ script_assert(size > 0);
+ script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size);
+ uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1);
+ sprintf(tmpstr, " %d@[%d@ (%d)]", (type - ARGUMENT_LOCAL_ARRAY), index_id, pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id]);
+ strcat(buf, tmpstr);
+ return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL_ARRAY) + index];
+ }
+ else if (type >= ARGUMENT_LOCAL) {
+ sprintf(tmpstr, " %d@", (type - ARGUMENT_LOCAL));
+ strcat(buf, tmpstr);
+ return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)];
+ }
+ else if (type >= ARGUMENT_TIMER) {
+ sprintf(tmpstr, " TIMER%d@", (type - ARGUMENT_TIMER));
+ strcat(buf, tmpstr);
+ return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)]; // why 8?
+ }
+ script_assert(false && "wrong type for variable");
+ return nil;
+}
+
+int CRunningScript::CollectParameterForDebug(char* buf, bool& var)
+{
var = false;
+ int tmp;
switch (CTheScripts::Read1ByteFromScript(&m_nIp))
{
+ case ARGUMENT_END:
+ return 0; // TODO(LCS)
+ case ARGUMENT_INT_ZERO:
+ return 0;
+ case ARGUMENT_FLOAT_ZERO:
+ return 0;
+ case ARGUMENT_FLOAT_1BYTE:
+ return (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 24;
+ case ARGUMENT_FLOAT_2BYTES:
+ return (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16;
+ case ARGUMENT_FLOAT_3BYTES:
+ tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(&m_nIp) << 8;
+ tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(&m_nIp) << 16;
+ return tmp;
case ARGUMENT_INT32:
case ARGUMENT_FLOAT:
return CTheScripts::Read4BytesFromScript(&m_nIp);
- case ARGUMENT_GLOBALVAR:
- varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
- script_assert(varIndex >= 8 && varIndex < CTheScripts::GetSizeOfVariableSpace());
- var = true;
- sprintf(tmpstr, " $%d", varIndex / 4);
- strcat(buf, tmpstr);
- return *((int32*)&CTheScripts::ScriptSpace[varIndex]);
- case ARGUMENT_LOCALVAR:
- varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
- script_assert(varIndex >= 0 && varIndex < ARRAY_SIZE(m_anLocalVariables));
- var = true;
- sprintf(tmpstr, " %d@", varIndex);
- strcat(buf, tmpstr);
- return m_anLocalVariables[varIndex];
case ARGUMENT_INT8:
return CTheScripts::Read1ByteFromScript(&m_nIp);
case ARGUMENT_INT16:
return CTheScripts::Read2BytesFromScript(&m_nIp);
default:
- PrintToLog("%s - script assertion failed in CollectParameterForDebug", buf);
- script_assert(0);
- break;
+ var = true;
+ --m_nIp;
+ return *GetPointerToScriptVariableForDebug(this, &m_nIp, buf);
}
return 0;
}
void CRunningScript::GetStoredParameterForDebug(char* buf)
{
- uint16 varIndex;
- char tmpstr[24];
- switch (CTheScripts::Read1ByteFromScript(&m_nIp)) {
- case ARGUMENT_GLOBALVAR:
- varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
- sprintf(tmpstr, " $%d", varIndex / 4);
- strcat(buf, tmpstr);
- break;
- case ARGUMENT_LOCALVAR:
- varIndex = CTheScripts::Read2BytesFromScript(&m_nIp);
- sprintf(tmpstr, " %d@", varIndex);
- strcat(buf, tmpstr);
- break;
- default:
- PrintToLog("%s - script_assertion failed in GetStoredParameterForDebug", buf);
- script_assert(0);
- }
+ GetPointerToScriptVariableForDebug(this, &m_nIp, buf);
}
#endif
int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
{
uint32* pIp = &ip;
+ int tmp;
switch (CTheScripts::Read1ByteFromScript(pIp))
{
+ case ARGUMENT_END:
+ return 0; // TODO(LCS)
+ case ARGUMENT_INT_ZERO:
+ return 0;
+ case ARGUMENT_FLOAT_ZERO:
+ return 0;
+ case ARGUMENT_FLOAT_1BYTE:
+ return (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 24;
+ case ARGUMENT_FLOAT_2BYTES:
+ return (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16;
+ case ARGUMENT_FLOAT_3BYTES:
+ tmp = (uint32)(uint8)CTheScripts::Read1ByteFromScript(pIp) << 8;
+ tmp |= (uint32)(uint16)CTheScripts::Read2BytesFromScript(pIp) << 16;
+ return tmp;
case ARGUMENT_INT32:
return CTheScripts::Read4BytesFromScript(pIp);
- case ARGUMENT_GLOBALVAR:
- return *((int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)]);
- case ARGUMENT_LOCALVAR:
- return m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
case ARGUMENT_INT8:
return CTheScripts::Read1ByteFromScript(pIp);
case ARGUMENT_INT16:
@@ -2145,7 +2471,8 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
case ARGUMENT_FLOAT:
return CTheScripts::Read4BytesFromScript(pIp);
default:
- script_assert(0);
+ (*pIp)--;
+ return *GetPointerToScriptVariable(pIp, 0);
}
return -1;
}
@@ -2153,38 +2480,61 @@ int32 CRunningScript::CollectNextParameterWithoutIncreasingPC(uint32 ip)
void CRunningScript::StoreParameters(uint32* pIp, int16 number)
{
for (int16 i = 0; i < number; i++){
- switch (CTheScripts::Read1ByteFromScript(pIp)) {
- case ARGUMENT_GLOBALVAR:
- *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
- break;
- case ARGUMENT_LOCALVAR:
- m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)] = ScriptParams[i];
- break;
- default:
- script_assert(0);
- }
+ *GetPointerToScriptVariable(pIp, 0) = ScriptParams[i];
}
}
+int32* GetPointerToScriptVariable(CRunningScript* pScript, uint32* pIp)
+{
+ uint8 type = CTheScripts::Read1ByteFromScript(pIp);
+ if (type >= ARGUMENT_GLOBAL_ARRAY) {
+ uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp);
+ uint8 index_id = CTheScripts::Read1ByteFromScript(pIp);
+ uint8 size = CTheScripts::Read1ByteFromScript(pIp);
+ script_assert(size > 0);
+ script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size);
+ uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1);
+ return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL_ARRAY) << 8) + index + index_in_block)];
+ }
+ else if (type >= ARGUMENT_GLOBAL) {
+ uint8 index_in_block = CTheScripts::Read1ByteFromScript(pIp);
+ return (int32*)&CTheScripts::ScriptSpace[4 * (((int)(type - ARGUMENT_GLOBAL) << 8) + index_in_block)];
+ }
+ else if (type >= ARGUMENT_LOCAL_ARRAY) {
+ uint8 index_id = CTheScripts::Read1ByteFromScript(pIp);
+ uint8 size = CTheScripts::Read1ByteFromScript(pIp);
+ script_assert(size > 0);
+ script_assert(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id] < size);
+ uint8 index = Min(pScript->m_anLocalVariables[pScript->m_nLocalsPointer + index_id], size - 1);
+ return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL_ARRAY) + index];
+ }
+ else if (type >= ARGUMENT_LOCAL) {
+ return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)];
+ }
+ else if (type >= ARGUMENT_TIMER) {
+ return &pScript->m_anLocalVariables[NUM_LOCAL_VARS + 8 + (type - ARGUMENT_TIMER)];
+ }
+ script_assert(false && "wrong type for variable");
+ return &pScript->m_anLocalVariables[pScript->m_nLocalsPointer + (type - ARGUMENT_LOCAL)];
+}
+
int32 *CRunningScript::GetPointerToScriptVariable(uint32* pIp, int16 type)
{
- switch (CTheScripts::Read1ByteFromScript(pIp))
- {
- case ARGUMENT_GLOBALVAR:
- script_assert(type == VAR_GLOBAL);
- return (int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(pIp)];
- case ARGUMENT_LOCALVAR:
- script_assert(type == VAR_LOCAL);
- return &m_anLocalVariables[CTheScripts::Read2BytesFromScript(pIp)];
- default:
- script_assert(0);
+ return ::GetPointerToScriptVariable(this, pIp);
+}
+
+int CTheScripts::GetSaveVarIndex(int var)
+{
+ for (int i = 0; i < NumSaveVars; i++) {
+ if (SavedVarIndices[i] == var)
+ return i;
}
- return nil;
+ return -1;
}
void CRunningScript::Init()
{
- strcpy(m_abScriptName, "noname");
+ sprintf(m_abScriptName, "id%02i", m_nId);
next = prev = nil;
SetIP(0);
for (int i = 0; i < MAX_STACK_DEPTH; i++)
@@ -2195,13 +2545,28 @@ void CRunningScript::Init()
m_bCondResult = false;
m_bIsMissionScript = false;
m_bSkipWakeTime = false;
- for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++)
+ for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++)
m_anLocalVariables[i] = 0;
m_nAndOrState = 0;
m_bNotFlag = false;
m_bDeatharrestEnabled = true;
m_bDeatharrestExecuted = false;
m_bMissionFlag = false;
+ m_nLocalsPointer = 0;
+}
+
+void CTheScripts::Shutdown()
+{
+ if (gScriptsFile != -1) {
+ CFileMgr::CloseFile(gScriptsFile);
+ gScriptsFile = -1;
+ }
+ if (ScriptSpace) {
+ base::cMainMemoryManager::Instance()->Free(ScriptSpace);
+ ScriptSpace = nil;
+ FSDestroyedFlag = false;
+ OnAMissionFlag = 0;
+ }
}
#ifdef USE_DEBUG_SCRIPT_LOADER
@@ -2224,17 +2589,17 @@ int open_script()
#endif
switch (scriptToLoad) {
case 0: scriptfile = "main.scm"; break;
- case 1: scriptfile = "freeroam_miami.scm"; break;
+ case 1: scriptfile = "freeroam_lcs.scm"; break;
case 2: scriptfile = "main_d.scm"; break;
}
return CFileMgr::OpenFile(scriptfile, "rb");
}
#endif
-void CTheScripts::Init()
+bool CTheScripts::Init(bool loaddata)
{
- for (int i = 0; i < SIZE_SCRIPT_SPACE; i++)
- ScriptSpace[i] = 0;
+ bool retval = false;
+ printf("CTheScripts::Init\n");
pActiveScripts = pIdleScripts = nil;
for (int i = 0; i < MAX_NUM_SCRIPTS; i++){
ScriptsArray[i].Init();
@@ -2243,25 +2608,47 @@ void CTheScripts::Init()
MissionCleanUp.Init();
UpsideDownCars.Init();
StuckCars.Init();
- CFileMgr::SetDir("data");
-#ifdef USE_DEBUG_SCRIPT_LOADER
- int mainf = open_script();
-#else
- int mainf = CFileMgr::OpenFile("main.scm", "rb");
-#endif
- CFileMgr::Read(mainf, (char*)ScriptSpace, SIZE_MAIN_SCRIPT);
- CFileMgr::CloseFile(mainf);
- CFileMgr::SetDir("");
StoreVehicleIndex = -1;
StoreVehicleWasRandom = true;
OnAMissionFlag = 0;
LastMissionPassedTime = (uint32)-1;
+ for (int i = 0; i < MAX_NUM_COLLECTIVES; i++) {
+ CollectiveArray[i].colIndex = -1;
+ CollectiveArray[i].pedIndex = 0;
+ }
+ NextFreeCollectiveIndex = 0;
LastRandomPedId = -1;
for (int i = 0; i < MAX_NUM_USED_OBJECTS; i++){
memset(&UsedObjectArray[i].name, 0, sizeof(UsedObjectArray[i].name));
UsedObjectArray[i].index = 0;
}
+#if defined FIX_BUGS || (!defined GTA_PS2 && !defined GTA_PSP)
+ for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i;) {
+ base::cSList<script_corona>::tSItem* next = i->next;
+ delete i;
+ i = next;
+ }
+ CTheScripts::mCoronas.first = nil;
+#endif
NumberOfUsedObjects = 0;
+ if (ScriptSpace)
+ Shutdown();
+ CFileMgr::SetDir("DATA");
+#ifdef USE_DEBUG_SCRIPT_LOADER
+ int mainf = open_script();
+#else
+ int mainf = CFileMgr::OpenFile("main.scm", "rb");
+#endif
+ CFileMgr::Read(mainf, (char*)&MainScriptSize, sizeof(MainScriptSize));
+ int nLargestMissionSize = 0;
+ CFileMgr::Read(mainf, (char*)&nLargestMissionSize, sizeof(nLargestMissionSize));
+ if (!cSmallHeap::msInstance.IsLocked())
+ cSmallHeap::msInstance.Lock();
+ ScriptSpace = (uint8*)base::cMainMemoryManager::Instance()->Allocate(MainScriptSize + nLargestMissionSize);
+ memset(ScriptSpace, 0, MainScriptSize + nLargestMissionSize);
+ CFileMgr::Read(mainf, (char*)ScriptSpace, MainScriptSize);
+ gScriptsFile = mainf;
+ CFileMgr::SetDir("");
ReadObjectNamesFromScript();
UpdateObjectIndices();
bAlreadyRunningAMissionScript = false;
@@ -2271,11 +2658,10 @@ void CTheScripts::Init()
NumberOfExclusiveMissionScripts = 0;
NumberOfMissionScripts = 0;
LargestMissionScriptSize = 0;
- MainScriptSize = 0;
ReadMultiScriptFileOffsetsFromScript();
FailCurrentMission = 0;
DbgFlag = false;
- NumScriptDebugLines = 0;
+ //NumScriptDebugLines = 0;
RiotIntensity = 0;
bPlayerHasMetDebbieHarry = false;
bPlayerIsInTheStatium = false;
@@ -2299,7 +2685,7 @@ void CTheScripts::Init()
IntroRectangles[i].m_sColor = CRGBA(255, 255, 255, 255);
}
NumberOfIntroRectanglesThisFrame = 0;
- RemoveScriptTextureDictionary();
+ //RemoveScriptTextureDictionary(); // TODO(LCS) - probably not needed
for (int i = 0; i < MAX_NUM_BUILDING_SWAPS; i++){
BuildingSwapArray[i].m_pBuilding = nil;
BuildingSwapArray[i].m_nNewModel = -1;
@@ -2307,6 +2693,12 @@ void CTheScripts::Init()
}
for (int i = 0; i < MAX_NUM_INVISIBILITY_SETTINGS; i++)
InvisibilitySettingArray[i] = nil;
+ if (loaddata) {
+ printf("loaddata = true\n");
+ //retval = GenericLoad(); // TODO
+ }
+ for (int i = 0; i < MAX_ALLOWED_COLLISIONS; i++)
+ AllowedCollision[i] = 0;
#if defined USE_ADVANCED_SCRIPT_DEBUG_OUTPUT && SCRIPT_LOG_FILE_LEVEL == 2
CFileMgr::SetDirMyDocuments();
@@ -2317,8 +2709,10 @@ void CTheScripts::Init()
PrintToLog(init_msg);
CFileMgr::SetDir("");
#endif
+ return retval;
}
+/*
void CTheScripts::RemoveScriptTextureDictionary()
{
for (int i = 0; i < ARRAY_SIZE(CTheScripts::ScriptSprites); i++)
@@ -2327,6 +2721,7 @@ void CTheScripts::RemoveScriptTextureDictionary()
if (slot != -1)
CTxdStore::RemoveTxd(slot);
}
+*/
void CRunningScript::RemoveScriptFromList(CRunningScript** ppScript)
{
@@ -2352,6 +2747,7 @@ CRunningScript* CTheScripts::StartNewScript(uint32 ip)
CRunningScript* pNew = pIdleScripts;
script_assert(pNew);
pNew->RemoveScriptFromList(&pIdleScripts);
+ pNew->m_nId = NextProcessId++;
pNew->Init();
pNew->SetIP(ip);
pNew->AddScriptToList(&pActiveScripts);
@@ -2363,6 +2759,8 @@ void CTheScripts::Process()
{
if (CReplay::IsPlayingBack())
return;
+ if (!ScriptSpace)
+ return;
CommandsExecuted = 0;
ScriptsUpdated = 0;
float timeStep = CTimer::GetTimeStepInMilliseconds();
@@ -2434,6 +2832,7 @@ void CTheScripts::Process()
#endif
CRunningScript* script = pActiveScripts;
+ InTheScripts = true;
while (script != nil){
CRunningScript* next = script->GetNext();
++ScriptsUpdated;
@@ -2443,6 +2842,11 @@ void CTheScripts::Process()
if (script && !script->m_bIsActive)
script = nil;
}
+ InTheScripts = false;
+ for (base::cSList<script_corona>::tSItem* i = CTheScripts::mCoronas.first; i; i = i->next) {
+ CCoronas::RegisterCorona((uint32)(uintptr)i, i->item.r, i->item.g, i->item.b, 255, CVector(i->item.x, i->item.y, i->item.z),
+ -i->item.size, 450.0f, i->item.type, i->item.flareType, 1, 0, 0, 0.0f);
+ }
DbgFlag = false;
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
PrintToLog("Script processing done, ScriptsUpdated: %d, CommandsExecuted: %d\n", ScriptsUpdated, CommandsExecuted);
@@ -2468,6 +2872,7 @@ void CRunningScript::Process()
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
PrintToLog("\n\nProcessing script %s (id %d)\n\n", m_abScriptName, this - CTheScripts::ScriptsArray);
#endif
+ pCurrent = this;
if (m_bIsMissionScript)
DoDeatharrestCheck();
if (m_bMissionFlag && CTheScripts::FailCurrentMission == 1 && m_nStackPointer == 1)
@@ -2500,34 +2905,59 @@ int8 CRunningScript::ProcessOneCommand()
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
char commandInfo[1024];
uint32 ip = m_nIp;
+ uint8 nInputParams;
+ uint8 nOutputParameters;
+ uint8 nLocalsOffset;
if (command < ARRAY_SIZE(commands)) {
script_assert(commands[command].id == command);
m_nIp -= 2;
- sprintf(commandInfo, m_nIp >= SIZE_MAIN_SCRIPT ? "M<%5d> " : "<%6d> ", m_nIp >= SIZE_MAIN_SCRIPT ? m_nIp - SIZE_MAIN_SCRIPT : m_nIp);
+ sprintf(commandInfo, m_nIp >= CTheScripts::MainScriptSize ? "M<%5d> " : "<%6d> ", m_nIp >= CTheScripts::MainScriptSize ? m_nIp - CTheScripts::MainScriptSize : m_nIp);
m_nIp += 2;
if (m_bNotFlag)
strcat(commandInfo, "NOT ");
if (commands[command].position == -1)
strcat(commandInfo, commands[command].name + sizeof("COMMAND_") - 1);
- for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) {
+ if (commands[command].input[0] == ARGTYPE_FUNCTION) {
char tmp[32];
bool var = false;
- int value;
- switch (commands[command].input[i]) {
- case ARGTYPE_INT:
- case ARGTYPE_PED_HANDLE:
- case ARGTYPE_VEHICLE_HANDLE:
- case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break;
- case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break;
- case ARGTYPE_STRING: sprintf(tmp, " '%s'", (const char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += KEY_LENGTH_IN_SCRIPT; break;
- case ARGTYPE_LABEL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); break;
- case ARGTYPE_BOOL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s)" : " %s", value ? "TRUE" : "FALSE"); break;
- case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value + 1) % 10, value / 10 == 0 ? "AND" : "OR"); break;
- default: script_assert(0);
- }
+ nInputParams = CTheScripts::Read1ByteFromScript(&m_nIp);
+ nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp);
+ nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp);
+ int value = CollectParameterForDebug(commandInfo, var);
+ sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value));
strcat(commandInfo, tmp);
- if (commands[command].position == i)
- strcat(commandInfo, commands[command].name_override);
+ strcat(commandInfo, "{");
+ for (int i = 0; i < nInputParams; i++) {
+ if (i != 0)
+ strcat(commandInfo, ", ");
+ value = CollectParameterForDebug(commandInfo, var);
+ sprintf(tmp, var ? "(%d)" : "%d", value);
+ strcat(commandInfo, tmp);
+
+ }
+ strcat(commandInfo, "}");
+ }
+ else {
+ for (int i = 0; commands[command].input[i] != ARGTYPE_NONE; i++) {
+ char tmp[32];
+ bool var = false;
+ int value;
+ switch (commands[command].input[i]) {
+ case ARGTYPE_INT:
+ case ARGTYPE_PED_HANDLE:
+ case ARGTYPE_VEHICLE_HANDLE:
+ case ARGTYPE_OBJECT_HANDLE: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%d)" : " %d", value); break;
+ case ARGTYPE_FLOAT: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%.3f)" : " %.3f", *(float*)&value); break;
+ case ARGTYPE_STRING: sprintf(tmp, " '%s'", (const char*)&CTheScripts::ScriptSpace[m_nIp]); m_nIp += KEY_LENGTH_IN_SCRIPT; break;
+ case ARGTYPE_LABEL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s(%d))" : " %s(%d)", value >= 0 ? "G" : "L", abs(value)); break;
+ case ARGTYPE_BOOL: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, var ? " (%s)" : " %s", value ? "TRUE" : "FALSE"); break;
+ case ARGTYPE_ANDOR: value = CollectParameterForDebug(commandInfo, var); sprintf(tmp, " %d %ss", (value) % 10, value / 10 == 0 ? "AND" : "OR"); break;
+ default: script_assert(0);
+ }
+ strcat(commandInfo, tmp);
+ if (commands[command].position == i)
+ strcat(commandInfo, commands[command].name_override);
+ }
}
uint32 t = m_nIp;
m_nIp = ip;
@@ -2538,32 +2968,38 @@ int8 CRunningScript::ProcessOneCommand()
retval = ProcessCommands0To99(command);
else if (command < 200)
retval = ProcessCommands100To199(command);
- else if (command < 300)
+ else if (command < 305)
retval = ProcessCommands200To299(command);
- else if (command < 400)
+ else if (command < 405)
retval = ProcessCommands300To399(command);
- else if (command < 500)
+ else if (command < 505)
retval = ProcessCommands400To499(command);
- else if (command < 600)
+ else if (command < 605)
retval = ProcessCommands500To599(command);
- else if (command < 700)
+ else if (command < 705)
retval = ProcessCommands600To699(command);
- else if (command < 800)
+ else if (command < 805)
retval = ProcessCommands700To799(command);
- else if (command < 900)
+ else if (command < 905)
retval = ProcessCommands800To899(command);
- else if (command < 1000)
+ else if (command < 1005)
retval = ProcessCommands900To999(command);
- else if (command < 1100)
+ else if (command < 1105)
retval = ProcessCommands1000To1099(command);
- else if (command < 1200)
+ else if (command < 1205)
retval = ProcessCommands1100To1199(command);
- else if (command < 1300)
+ else if (command < 1305)
retval = ProcessCommands1200To1299(command);
- else if (command < 1400)
+ else if (command < 1405)
retval = ProcessCommands1300To1399(command);
- else if (command < 1500)
+ else if (command < 1497)
retval = ProcessCommands1400To1499(command);
+ else if (command < 1600)
+ retval = ProcessCommands1500To1599(command);
+ else if (command < 1700)
+ retval = ProcessCommands1600To1699(command);
+ else
+ script_assert(false);
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
if (command < ARRAY_SIZE(commands)) {
if (commands[command].cond || commands[command].output[0] != ARGTYPE_NONE) {
@@ -2573,15 +3009,17 @@ int8 CRunningScript::ProcessOneCommand()
uint32 t = m_nIp;
m_nIp = ip;
ip = t;
- for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) {
- char tmp[32];
- switch (commands[command].output[i]) {
- case ARGTYPE_INT:
- case ARGTYPE_PED_HANDLE:
- case ARGTYPE_VEHICLE_HANDLE:
- case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break;
- case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break;
- default: script_assert(0 && "Script only returns INTs and FLOATs");
+ if (commands[command].input[0] != ARGTYPE_FUNCTION) {
+ for (int i = 0; commands[command].output[i] != ARGTYPE_NONE; i++) {
+ char tmp[32];
+ switch (commands[command].output[i]) {
+ case ARGTYPE_INT:
+ case ARGTYPE_PED_HANDLE:
+ case ARGTYPE_VEHICLE_HANDLE:
+ case ARGTYPE_OBJECT_HANDLE: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%d)", ScriptParams[i]); strcat(commandInfo, tmp); break;
+ case ARGTYPE_FLOAT: GetStoredParameterForDebug(commandInfo); sprintf(tmp, " (%8.3f)", *(float*)&ScriptParams[i]); strcat(commandInfo, tmp); break;
+ default: script_assert(0 && "Script only returns INTs and FLOATs");
+ }
}
}
m_nIp = ip;
@@ -2610,16 +3048,18 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
float *fScriptVar1;
int *nScriptVar1;
switch (command) {
+ /*
case COMMAND_NOP:
return 0;
+ */
case COMMAND_WAIT:
CollectParameters(&m_nIp, 1);
- m_nWakeTime = CTimer::GetTimeInMilliseconds() + ScriptParams[0];
+ m_nWakeTime = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(0);
m_bSkipWakeTime = false;
return 1;
case COMMAND_GOTO:
CollectParameters(&m_nIp, 1);
- SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]);
+ SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0));
/* Known issue: GOTO to 0. It might have been "better" to use > instead of >= */
/* simply because it never makes sense to jump to start of the script */
/* but jumping to start of a custom mission is an issue for simple mission-like scripts */
@@ -2628,174 +3068,174 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
return 0;
case COMMAND_SHAKE_CAM:
CollectParameters(&m_nIp, 1);
- CamShakeNoPos(&TheCamera, ScriptParams[0] / 1000.0f);
+ CamShakeNoPos(&TheCamera, GET_INTEGER_PARAM(0) / 1000.0f);
return 0;
case COMMAND_SET_VAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *ptr = ScriptParams[0];
+ *ptr = GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_SET_VAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr = *(float*)&ScriptParams[0];
+ *(float*)ptr = GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_SET_LVAR_INT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *ptr = ScriptParams[0];
+ *ptr = GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_SET_LVAR_FLOAT:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr = *(float*)&ScriptParams[0];
+ *(float*)ptr = GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_ADD_VAL_TO_INT_VAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *ptr += ScriptParams[0];
+ *ptr += GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_ADD_VAL_TO_FLOAT_VAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr += *(float*)&ScriptParams[0];
+ *(float*)ptr += GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_ADD_VAL_TO_INT_LVAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *ptr += ScriptParams[0];
+ *ptr += GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_ADD_VAL_TO_FLOAT_LVAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr += *(float*)&ScriptParams[0];
+ *(float*)ptr += GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_SUB_VAL_FROM_INT_VAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *ptr -= ScriptParams[0];
+ *ptr -= GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_SUB_VAL_FROM_FLOAT_VAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr -= *(float*)&ScriptParams[0];
+ *(float*)ptr -= GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_SUB_VAL_FROM_INT_LVAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *ptr -= ScriptParams[0];
+ *ptr -= GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_SUB_VAL_FROM_FLOAT_LVAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr -= *(float*)&ScriptParams[0];
+ *(float*)ptr -= GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_MULT_INT_VAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *ptr *= ScriptParams[0];
+ *ptr *= GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_MULT_FLOAT_VAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr *= *(float*)&ScriptParams[0];
+ *(float*)ptr *= GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_MULT_INT_LVAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *ptr *= ScriptParams[0];
+ *ptr *= GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_MULT_FLOAT_LVAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr *= *(float*)&ScriptParams[0];
+ *(float*)ptr *= GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_DIV_INT_VAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *ptr /= ScriptParams[0];
+ *ptr /= GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_DIV_FLOAT_VAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr /= *(float*)&ScriptParams[0];
+ *(float*)ptr /= GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_DIV_INT_LVAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *ptr /= ScriptParams[0];
+ *ptr /= GET_INTEGER_PARAM(0);
return 0;
}
case COMMAND_DIV_FLOAT_LVAR_BY_VAL:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr /= *(float*)&ScriptParams[0];
+ *(float*)ptr /= GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_IS_INT_VAR_GREATER_THAN_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*ptr > ScriptParams[0]);
+ UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0));
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_THAN_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*ptr > ScriptParams[0]);
+ UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_THAN_INT_VAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
- UpdateCompareFlag(ScriptParams[0] > *ptr);
+ UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr);
return 0;
}
case COMMAND_IS_NUMBER_GREATER_THAN_INT_LVAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
- UpdateCompareFlag(ScriptParams[0] > *ptr);
+ UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr);
return 0;
}
case COMMAND_IS_INT_VAR_GREATER_THAN_INT_VAR:
@@ -2830,28 +3270,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*(float*)ptr > *(float*)&ScriptParams[0]);
+ UpdateCompareFlag(*(float*)ptr > GET_FLOAT_PARAM(0));
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_THAN_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*(float*)ptr > *(float*)&ScriptParams[0]);
+ UpdateCompareFlag(*(float*)ptr > GET_FLOAT_PARAM(0));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_VAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
- UpdateCompareFlag(*(float*)&ScriptParams[0] > *(float*)ptr);
+ UpdateCompareFlag(GET_FLOAT_PARAM(0) > *(float*)ptr);
return 0;
}
case COMMAND_IS_NUMBER_GREATER_THAN_FLOAT_LVAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
- UpdateCompareFlag(*(float*)&ScriptParams[0] > *(float*)ptr);
+ UpdateCompareFlag(GET_FLOAT_PARAM(0) > *(float*)ptr);
return 0;
}
case COMMAND_IS_FLOAT_VAR_GREATER_THAN_FLOAT_VAR:
@@ -2886,28 +3326,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*ptr >= ScriptParams[0]);
+ UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0));
return 0;
}
case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*ptr >= ScriptParams[0]);
+ UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_VAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
- UpdateCompareFlag(ScriptParams[0] >= *ptr);
+ UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr);
return 0;
}
case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_INT_LVAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
- UpdateCompareFlag(ScriptParams[0] >= *ptr);
+ UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr);
return 0;
}
case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_INT_VAR:
@@ -2942,28 +3382,28 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*(float*)ptr >= *(float*)&ScriptParams[0]);
+ UpdateCompareFlag(*(float*)ptr >= GET_FLOAT_PARAM(0));
return 0;
}
case COMMAND_IS_FLOAT_LVAR_GREATER_OR_EQUAL_TO_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*(float*)ptr >= *(float*)&ScriptParams[0]);
+ UpdateCompareFlag(*(float*)ptr >= GET_FLOAT_PARAM(0));
return 0;
}
case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_VAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
- UpdateCompareFlag(*(float*)&ScriptParams[0] >= *(float*)ptr);
+ UpdateCompareFlag(GET_FLOAT_PARAM(0) >= *(float*)ptr);
return 0;
}
case COMMAND_IS_NUMBER_GREATER_OR_EQUAL_TO_FLOAT_LVAR:
{
CollectParameters(&m_nIp, 1);
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
- UpdateCompareFlag(*(float*)&ScriptParams[0] >= *(float*)ptr);
+ UpdateCompareFlag(GET_FLOAT_PARAM(0) >= *(float*)ptr);
return 0;
}
case COMMAND_IS_FLOAT_VAR_GREATER_OR_EQUAL_TO_FLOAT_VAR:
@@ -2998,14 +3438,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*ptr == ScriptParams[0]);
+ UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0));
return 0;
}
case COMMAND_IS_INT_LVAR_EQUAL_TO_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*ptr == ScriptParams[0]);
+ UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0));
return 0;
}
case COMMAND_IS_INT_VAR_EQUAL_TO_INT_VAR:
@@ -3038,14 +3478,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*(float*)ptr == *(float*)&ScriptParams[0]);
+ UpdateCompareFlag(*(float*)ptr == GET_FLOAT_PARAM(0));
return 0;
}
case COMMAND_IS_FLOAT_LVAR_EQUAL_TO_NUMBER:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(*(float*)ptr == *(float*)&ScriptParams[0]);
+ UpdateCompareFlag(*(float*)ptr == GET_FLOAT_PARAM(0));
return 0;
}
case COMMAND_IS_FLOAT_VAR_EQUAL_TO_FLOAT_VAR:
@@ -3074,17 +3514,15 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
//case COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_VAR:
//case COMMAND_IS_FLOAT_LVAR_NOT_EQUAL_TO_FLOAT_LVAR:
//case COMMAND_IS_FLOAT_VAR_NOT_EQUAL_TO_FLOAT_LVAR:
- /*
case COMMAND_GOTO_IF_TRUE:
CollectParameters(&m_nIp, 1);
if (m_bCondResult)
- SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]);
+ SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0));
return 0;
- */
case COMMAND_GOTO_IF_FALSE:
CollectParameters(&m_nIp, 1);
if (!m_bCondResult)
- SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]);
+ SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0));
/* Check COMMAND_GOTO note. */
return 0;
case COMMAND_TERMINATE_THIS_SCRIPT:
@@ -3110,47 +3548,19 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
case COMMAND_START_NEW_SCRIPT:
{
CollectParameters(&m_nIp, 1);
- script_assert(ScriptParams[0] >= 0);
- CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]);
- pNew->m_bIsActive = true;
- int8 type = CTheScripts::Read1ByteFromScript(&m_nIp);
- float tmp;
- for (int i = 0; type != ARGUMENT_END; type = CTheScripts::Read1ByteFromScript(&m_nIp), i++) {
- switch (type) {
- case ARGUMENT_INT32:
- pNew->m_anLocalVariables[i] = CTheScripts::Read4BytesFromScript(&m_nIp);
- break;
- case ARGUMENT_GLOBALVAR:
- pNew->m_anLocalVariables[i] = *(int32*)&CTheScripts::ScriptSpace[(uint16)CTheScripts::Read2BytesFromScript(&m_nIp)];
- break;
- case ARGUMENT_LOCALVAR:
- pNew->m_anLocalVariables[i] = m_anLocalVariables[CTheScripts::Read2BytesFromScript(&m_nIp)];
- break;
- case ARGUMENT_INT8:
- pNew->m_anLocalVariables[i] = CTheScripts::Read1ByteFromScript(&m_nIp);
- break;
- case ARGUMENT_INT16:
- pNew->m_anLocalVariables[i] = CTheScripts::Read2BytesFromScript(&m_nIp);
- break;
- case ARGUMENT_FLOAT:
- tmp = CTheScripts::ReadFloatFromScript(&m_nIp);
- pNew->m_anLocalVariables[i] = *(int32*)&tmp;
- break;
- default:
- break;
- }
- }
+ script_assert(GET_INTEGER_PARAM(0) >= 0);
+ CRunningScript* pNew = CTheScripts::StartNewScript(GET_INTEGER_PARAM(0));
+ CollectParameters(&m_nIp, NUM_LOCAL_VARS, pNew->m_anLocalVariables);
return 0;
}
case COMMAND_GOSUB:
CollectParameters(&m_nIp, 1);
script_assert(m_nStackPointer < MAX_STACK_DEPTH);
m_anStack[m_nStackPointer++] = m_nIp;
- SetIP(ScriptParams[0] >= 0 ? ScriptParams[0] : SIZE_MAIN_SCRIPT - ScriptParams[0]);
+ SetIP(GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0));
return 0;
case COMMAND_RETURN:
- script_assert(m_nStackPointer > 0); /* No more SSU */
- SetIP(m_anStack[--m_nStackPointer]);
+ ReturnFromGosubOrFunction();
return 0;
case COMMAND_LINE:
CollectParameters(&m_nIp, 6);
@@ -3159,7 +3569,7 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
case COMMAND_CREATE_PLAYER:
{
CollectParameters(&m_nIp, 4);
- int32 index = ScriptParams[0];
+ int32 index = GET_INTEGER_PARAM(0);
script_assert(index < NUMPLAYERS);
printf("&&&&&&&&&&&&&Creating player: %d\n", index);
if (!CStreaming::HasModelLoaded(MI_PLAYER)) {
@@ -3169,14 +3579,14 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
CPlayerPed::SetupPlayerPed(index);
CWorld::Players[index].m_pPed->CharCreatedBy = MISSION_CHAR;
CPlayerPed::DeactivatePlayerPed(index);
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += CWorld::Players[index].m_pPed->GetDistanceFromCentreOfMassToBaseOfModel();
CWorld::Players[index].m_pPed->SetPosition(pos);
CTheScripts::ClearSpaceForMissionEntity(pos, CWorld::Players[index].m_pPed);
CPlayerPed::ReactivatePlayerPed(index);
- ScriptParams[0] = index;
+ SET_INTEGER_PARAM(0, index);
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -3184,23 +3594,23 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
{
CVector pos;
CollectParameters(&m_nIp, 1);
- if (CWorld::Players[ScriptParams[0]].m_pPed->bInVehicle)
- pos = CWorld::Players[ScriptParams[0]].m_pPed->m_pMyVehicle->GetPosition();
+ if (CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->bInVehicle && CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pMyVehicle)
+ pos = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pMyVehicle->GetPosition();
else
- pos = CWorld::Players[ScriptParams[0]].m_pPed->GetPosition();
- *(CVector*)&ScriptParams[0] = pos;
+ pos = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GetPosition();
+ SET_VECTOR_PARAM(0, pos);
StoreParameters(&m_nIp, 3);
return 0;
}
case COMMAND_SET_PLAYER_COORDINATES:
{
CollectParameters(&m_nIp, 4);
- CVector pos = *(CVector*)&ScriptParams[1];
- int index = ScriptParams[0];
+ CVector pos = GET_VECTOR_PARAM(1);
+ int index = GET_INTEGER_PARAM(0);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
CPlayerPed* ped = CWorld::Players[index].m_pPed;
- if (ped->bInVehicle) {
+ if (ped->bInVehicle && ped->m_pMyVehicle) {
pos.z += ped->m_pMyVehicle->GetDistanceFromCentreOfMassToBaseOfModel();
ped->m_pMyVehicle->Teleport(pos); // removed dumb stuff that was present here
CTheScripts::ClearSpaceForMissionEntity(pos, ped->m_pMyVehicle);
@@ -3248,39 +3658,43 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
case COMMAND_IS_PLAYER_IN_AREA_2D:
{
CollectParameters(&m_nIp, 6);
- CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed;
- float x1 = *(float*)&ScriptParams[1];
- float y1 = *(float*)&ScriptParams[2];
- float x2 = *(float*)&ScriptParams[3];
- float y2 = *(float*)&ScriptParams[4];
+ CPlayerPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
+ float x1 = GET_FLOAT_PARAM(1);
+ float y1 = GET_FLOAT_PARAM(2);
+ float x2 = GET_FLOAT_PARAM(3);
+ float y2 = GET_FLOAT_PARAM(4);
if (!ped->bInVehicle)
UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2));
else
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2));
- if (ScriptParams[5])
+ if (GET_INTEGER_PARAM(5))
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
+ */
return 0;
}
case COMMAND_IS_PLAYER_IN_AREA_3D:
{
CollectParameters(&m_nIp, 8);
- CPlayerPed* ped = CWorld::Players[ScriptParams[0]].m_pPed;
- float x1 = *(float*)&ScriptParams[1];
- float y1 = *(float*)&ScriptParams[2];
- float z1 = *(float*)&ScriptParams[3];
- float x2 = *(float*)&ScriptParams[4];
- float y2 = *(float*)&ScriptParams[5];
- float z2 = *(float*)&ScriptParams[6];
+ CPlayerPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
+ float x1 = GET_FLOAT_PARAM(1);
+ float y1 = GET_FLOAT_PARAM(2);
+ float z1 = GET_FLOAT_PARAM(3);
+ float x2 = GET_FLOAT_PARAM(4);
+ float y2 = GET_FLOAT_PARAM(5);
+ float z2 = GET_FLOAT_PARAM(6);
if (ped->bInVehicle)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2));
- if (ScriptParams[7])
+ if (GET_INTEGER_PARAM(7))
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
+ /*
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
+ */
return 0;
}
case COMMAND_ADD_INT_VAR_TO_INT_VAR:
@@ -3427,33 +3841,25 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0];
+ *(float*)ptr += CTimer::GetTimeStep() * GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_ADD_TIMED_VAL_TO_FLOAT_LVAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr += CTimer::GetTimeStep() * *(float*)&ScriptParams[0];
+ *(float*)ptr += CTimer::GetTimeStep() * GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
-#ifdef FIX_BUGS
case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
-#else
- case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR:
-#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
-#ifdef FIX_BUGS
case COMMAND_ADD_TIMED_FLOAT_LVAR_TO_FLOAT_VAR:
-#else
- case COMMAND_ADD_TIMED_FLOAT_VAR_TO_FLOAT_LVAR:
-#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 += CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -3465,33 +3871,25 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0];
+ *(float*)ptr -= CTimer::GetTimeStep() * GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_SUB_TIMED_VAL_FROM_FLOAT_LVAR:
{
int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
CollectParameters(&m_nIp, 1);
- *(float*)ptr -= CTimer::GetTimeStep() * *(float*)&ScriptParams[0];
+ *(float*)ptr -= CTimer::GetTimeStep() * GET_FLOAT_PARAM(0);
return 0;
}
case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_VAR:
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
-#ifdef FIX_BUGS // in SA it was fixed by reversing their order in enum
case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
-#else
- case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR:
-#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
return 0;
-#ifdef FIX_BUGS
case COMMAND_SUB_TIMED_FLOAT_LVAR_FROM_FLOAT_VAR:
-#else
- case COMMAND_SUB_TIMED_FLOAT_VAR_FROM_FLOAT_LVAR:
-#endif
fScriptVar1 = (float*)GetPointerToScriptVariable(&m_nIp, VAR_LOCAL);
*fScriptVar1 -= CTimer::GetTimeStep() * *(float*)GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL);
return 0;
@@ -3640,46 +4038,46 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_CREATE_CHAR:
{
CollectParameters(&m_nIp, 5);
- switch (ScriptParams[1]) {
+ switch (GET_INTEGER_PARAM(1)) {
case MI_COP:
- if (ScriptParams[0] == PEDTYPE_COP)
- ScriptParams[1] = COP_STREET;
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(1, COP_STREET);
break;
case MI_SWAT:
- if (ScriptParams[0] == PEDTYPE_COP)
- ScriptParams[1] = COP_SWAT;
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(1, COP_SWAT);
break;
case MI_FBI:
- if (ScriptParams[0] == PEDTYPE_COP)
- ScriptParams[1] = COP_FBI;
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(1, COP_FBI);
break;
case MI_ARMY:
- if (ScriptParams[0] == PEDTYPE_COP)
- ScriptParams[1] = COP_ARMY;
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(1, COP_ARMY);
break;
case MI_MEDIC:
- if (ScriptParams[0] == PEDTYPE_EMERGENCY)
- ScriptParams[1] = PEDTYPE_EMERGENCY;
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_EMERGENCY)
+ SET_INTEGER_PARAM(1, PEDTYPE_EMERGENCY);
break;
case MI_FIREMAN:
- if (ScriptParams[0] == PEDTYPE_FIREMAN)
- ScriptParams[1] = PEDTYPE_FIREMAN;
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_FIREMAN)
+ SET_INTEGER_PARAM(1, PEDTYPE_FIREMAN);
break;
default:
break;
}
CPed* ped;
- if (ScriptParams[0] == PEDTYPE_COP)
- ped = new CCopPed((eCopType)ScriptParams[1]);
- else if (ScriptParams[0] == PEDTYPE_EMERGENCY || ScriptParams[0] == PEDTYPE_FIREMAN)
- ped = new CEmergencyPed(ScriptParams[1]);
+ if (GET_INTEGER_PARAM(0) == PEDTYPE_COP)
+ ped = new CCopPed((eCopType)GET_INTEGER_PARAM(1));
+ else if (GET_INTEGER_PARAM(0) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(0) == PEDTYPE_FIREMAN)
+ ped = new CEmergencyPed(GET_INTEGER_PARAM(1));
else
- ped = new CCivilianPed((ePedType)ScriptParams[0], ScriptParams[1]);
+ ped = new CCivilianPed((ePedType)GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
ped->CharCreatedBy = MISSION_CHAR;
ped->bRespondsToThreats = false;
ped->bAllowMedicsToReviveMe = false;
ped->bIsPlayerFriend = false;
- CVector pos = *(CVector*)&ScriptParams[2];
+ CVector pos = GET_VECTOR_PARAM(2);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += 1.0f;
@@ -3691,29 +4089,29 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
CWorld::Add(ped);
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
CPopulation::ms_nTotalMissionPeds++;
- ScriptParams[0] = CPools::GetPedPool()->GetIndex(ped);
+ SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(ped));
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR);
return 0;
}
case COMMAND_DELETE_CHAR:
{
CollectParameters(&m_nIp, 1);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
CTheScripts::RemoveThisPed(ped);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CHAR);
return 0;
}
case COMMAND_CHAR_WANDER_DIR:
{
CollectParameters(&m_nIp, 2);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
ped->ClearAll();
- int8 path = ScriptParams[1];
- if (ScriptParams[1] < 0 || ScriptParams[1] > 7)
+ int8 path = GET_INTEGER_PARAM(1);
+ if (GET_INTEGER_PARAM(1) < 0 || GET_INTEGER_PARAM(1) > 7)
// Max number GetRandomNumberInRange returns is max-1
#ifdef FIX_BUGS
path = CGeneral::GetRandomNumberInRange(0, 8);
@@ -3728,19 +4126,19 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_CHAR_FOLLOW_PATH:
{
CollectParameters(&m_nIp, 6);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
if (ped->GetPedState() == PED_ATTACK || ped->GetPedState() == PED_FIGHT || !ped->IsPedInControl())
return 0;
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
- float radius = *(float*)&ScriptParams[4];
+ float radius = GET_FLOAT_PARAM(4);
eMoveState state;
- switch (ScriptParams[5]) {
+ switch (GET_INTEGER_PARAM(5)) {
case 0: state = PEDMOVE_WALK; break;
case 1: state = PEDMOVE_RUN; break;
- default: assert(0);
+ default: state = PEDMOVE_WALK; break;
}
ped->ClearAll();
ped->m_pathNodeTimer = 0;
@@ -3750,7 +4148,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_CHAR_SET_IDLE:
{
CollectParameters(&m_nIp, 1);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
ped->bScriptObjectiveCompleted = false;
ped->SetObjective(OBJECTIVE_WAIT_ON_FOOT);
@@ -3759,7 +4157,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_GET_CHAR_COORDINATES:
{
CollectParameters(&m_nIp, 1);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
CVehicle* vehicle;
CVector pos;
@@ -3772,21 +4170,21 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
pos = vehicle->GetPosition();
else
pos = ped->GetPosition();
- *(CVector*)&ScriptParams[0] = pos;
+ SET_VECTOR_PARAM(0, pos);
StoreParameters(&m_nIp, 3);
return 0;
}
case COMMAND_SET_CHAR_COORDINATES:
{
CollectParameters(&m_nIp, 4);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
CVehicle* vehicle;
if (ped->bInVehicle)
vehicle = ped->m_pMyVehicle;
else
vehicle = nil;
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
// removed dumb stuff again
@@ -3809,72 +4207,74 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
}
return 0;
}
- /*
case COMMAND_IS_CHAR_STILL_ALIVE:
{
CollectParameters(&m_nIp, 1);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
- UpdateCompareFlag(ped && ped->GetPedState() != PED_DEAD && ped->GetPedState() != PED_DIE);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
+ UpdateCompareFlag(ped && !ped->DyingOrDead());
return 0;
}
- */
case COMMAND_IS_CHAR_IN_AREA_2D:
{
CollectParameters(&m_nIp, 6);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
CVehicle* vehicle;
if (ped->bInVehicle)
vehicle = ped->m_pMyVehicle;
else
vehicle = nil;
- float x1 = *(float*)&ScriptParams[1];
- float y1 = *(float*)&ScriptParams[2];
- float x2 = *(float*)&ScriptParams[3];
- float y2 = *(float*)&ScriptParams[4];
+ float x1 = GET_FLOAT_PARAM(1);
+ float y1 = GET_FLOAT_PARAM(2);
+ float x2 = GET_FLOAT_PARAM(3);
+ float y2 = GET_FLOAT_PARAM(4);
if (vehicle)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2));
else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2));
- if (ScriptParams[5])
+ if (GET_INTEGER_PARAM(5))
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
+ */
return 0;
}
case COMMAND_IS_CHAR_IN_AREA_3D:
{
CollectParameters(&m_nIp, 8);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
CVehicle* vehicle;
if (ped->bInVehicle)
vehicle = ped->m_pMyVehicle;
else
vehicle = nil;
- float x1 = *(float*)&ScriptParams[1];
- float y1 = *(float*)&ScriptParams[2];
- float z1 = *(float*)&ScriptParams[3];
- float x2 = *(float*)&ScriptParams[4];
- float y2 = *(float*)&ScriptParams[5];
- float z2 = *(float*)&ScriptParams[6];
+ float x1 = GET_FLOAT_PARAM(1);
+ float y1 = GET_FLOAT_PARAM(2);
+ float z1 = GET_FLOAT_PARAM(3);
+ float x2 = GET_FLOAT_PARAM(4);
+ float y2 = GET_FLOAT_PARAM(5);
+ float z2 = GET_FLOAT_PARAM(6);
if (vehicle)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2));
- if (ScriptParams[7])
+ if (GET_INTEGER_PARAM(7))
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
+ /*
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
+ */
return 0;
}
case COMMAND_CREATE_CAR:
{
CollectParameters(&m_nIp, 4);
int32 handle;
- if (CModelInfo::IsBoatModel(ScriptParams[0])) {
- CBoat* boat = new CBoat(ScriptParams[0], MISSION_VEHICLE);
- CVector pos = *(CVector*)&ScriptParams[1];
+ if (CModelInfo::IsBoatModel(GET_INTEGER_PARAM(0))) {
+ CBoat* boat = new CBoat(GET_INTEGER_PARAM(0), MISSION_VEHICLE);
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += boat->GetDistanceFromCentreOfMassToBaseOfModel();
@@ -3893,13 +4293,13 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
else {
CVehicle* car;
- if (!CModelInfo::IsBikeModel(ScriptParams[0]))
- car = new CAutomobile(ScriptParams[0], MISSION_VEHICLE);
+ if (!CModelInfo::IsBikeModel(GET_INTEGER_PARAM(0)))
+ car = new CAutomobile(GET_INTEGER_PARAM(0), MISSION_VEHICLE);
else {
- car = new CBike(ScriptParams[0], MISSION_VEHICLE);
+ car = new CBike(GET_INTEGER_PARAM(0), MISSION_VEHICLE);
((CBike*)(car))->bIsStanding = true;
}
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
@@ -3914,14 +4314,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
car->AutoPilot.m_nCurrentLane = car->AutoPilot.m_nNextLane = 0;
car->bEngineOn = false;
- car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
+ car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos); // TODO: gpTheZones
car->bHasBeenOwnedByPlayer = true;
if (m_bIsMissionScript)
car->bIsStaticWaitingForCollision = true;
CWorld::Add(car);
handle = CPools::GetVehiclePool()->GetIndex(car);
}
- ScriptParams[0] = handle;
+ SET_INTEGER_PARAM(0, handle);
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
CTheScripts::MissionCleanUp.AddEntityToList(handle, CLEANUP_CAR);
@@ -3930,25 +4330,26 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_DELETE_CAR:
{
CollectParameters(&m_nIp, 1);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
if (car) {
CWorld::Remove(car);
CWorld::RemoveReferencesToDeletedObject(car);
delete car;
}
if (m_bIsMissionScript)
- CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_CAR);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_CAR);
return 0;
}
case COMMAND_CAR_GOTO_COORDINATES:
{
CollectParameters(&m_nIp, 4);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
+ uint8 nOldMission = car->AutoPilot.m_nCarMission;
if (CCarCtrl::JoinCarWithRoadSystemGotoCoors(car, pos, false))
car->AutoPilot.m_nCarMission = MISSION_GOTOCOORDS_STRAIGHT;
else
@@ -3956,13 +4357,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
car->SetStatus(STATUS_PHYSICS);
car->bEngineOn = true;
car->AutoPilot.m_nCruiseSpeed = Max(1, car->AutoPilot.m_nCruiseSpeed);
- car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
+ if (nOldMission != car->AutoPilot.m_nCarMission)
+ car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
return 0;
}
case COMMAND_CAR_WANDER_RANDOMLY:
{
CollectParameters(&m_nIp, 1);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
CCarCtrl::JoinCarWithRoadSystem(car);
car->AutoPilot.m_nCarMission = MISSION_CRUISE;
@@ -3974,7 +4376,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_CAR_SET_IDLE:
{
CollectParameters(&m_nIp, 1);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
car->AutoPilot.m_nCarMission = MISSION_NONE;
return 0;
@@ -3982,18 +4384,18 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_GET_CAR_COORDINATES:
{
CollectParameters(&m_nIp, 1);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
- *(CVector*)&ScriptParams[0] = car->GetPosition();
+ SET_VECTOR_PARAM(0, car->GetPosition());
StoreParameters(&m_nIp, 3);
return 0;
}
case COMMAND_SET_CAR_COORDINATES:
{
CollectParameters(&m_nIp, 4);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
@@ -4039,80 +4441,84 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
}
return 0;
}
- /*
case COMMAND_IS_CAR_STILL_ALIVE:
{
CollectParameters(&m_nIp, 1);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
UpdateCompareFlag(car && car->GetStatus() != STATUS_WRECKED && (car->IsBoat() || !car->bIsInWater));
return 0;
}
- */
case COMMAND_SET_CAR_CRUISE_SPEED:
{
CollectParameters(&m_nIp, 2);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
#if defined MISSION_REPLAY && defined SIMPLIER_MISSIONS
- car->AutoPilot.m_nCruiseSpeed = *(float*)&ScriptParams[1];
+ car->AutoPilot.m_nCruiseSpeed = GET_FLOAT_PARAM(1);
if (missionRetryScriptIndex == 40 && car->GetModelIndex() == MI_CHEETAH) // Turismo
car->AutoPilot.m_nCruiseSpeed = 8 * car->AutoPilot.m_nCruiseSpeed / 10;
car->AutoPilot.m_nCruiseSpeed = Min(car->AutoPilot.m_nCruiseSpeed, 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity);
#else
- car->AutoPilot.m_nCruiseSpeed = Min(*(float*)&ScriptParams[1], 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity);
+ car->AutoPilot.m_nCruiseSpeed = Min(GET_FLOAT_PARAM(1), 60.0f * car->pHandling->Transmission.fMaxCruiseVelocity);
#endif
return 0;
}
case COMMAND_SET_CAR_DRIVING_STYLE:
{
CollectParameters(&m_nIp, 2);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
- car->AutoPilot.m_nDrivingStyle = (uint8)ScriptParams[1];
+ car->AutoPilot.m_nDrivingStyle = (uint8)GET_INTEGER_PARAM(1);
return 0;
}
case COMMAND_SET_CAR_MISSION:
{
CollectParameters(&m_nIp, 2);
- CVehicle* car = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* car = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(car);
- car->AutoPilot.m_nCarMission = (uint8)ScriptParams[1];
- car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
+ if ((uint8)GET_INTEGER_PARAM(1) != car->AutoPilot.m_nCarMission) {
+ car->AutoPilot.m_nCarMission = (uint8)GET_INTEGER_PARAM(1);
+ car->AutoPilot.m_nAntiReverseTimer = CTimer::GetTimeInMilliseconds();
+ }
car->bEngineOn = true;
return 0;
}
case COMMAND_IS_CAR_IN_AREA_2D:
{
CollectParameters(&m_nIp, 6);
- CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(vehicle);
- float x1 = *(float*)&ScriptParams[1];
- float y1 = *(float*)&ScriptParams[2];
- float x2 = *(float*)&ScriptParams[3];
- float y2 = *(float*)&ScriptParams[4];
+ float x1 = GET_FLOAT_PARAM(1);
+ float y1 = GET_FLOAT_PARAM(2);
+ float x2 = GET_FLOAT_PARAM(3);
+ float y2 = GET_FLOAT_PARAM(4);
UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2));
- if (ScriptParams[5])
+ if (GET_INTEGER_PARAM(5))
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
+ /*
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
+ */
return 0;
}
case COMMAND_IS_CAR_IN_AREA_3D:
{
CollectParameters(&m_nIp, 8);
- CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* vehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(vehicle);
- float x1 = *(float*)&ScriptParams[1];
- float y1 = *(float*)&ScriptParams[2];
- float z1 = *(float*)&ScriptParams[3];
- float x2 = *(float*)&ScriptParams[4];
- float y2 = *(float*)&ScriptParams[5];
- float z2 = *(float*)&ScriptParams[6];
+ float x1 = GET_FLOAT_PARAM(1);
+ float y1 = GET_FLOAT_PARAM(2);
+ float z1 = GET_FLOAT_PARAM(3);
+ float x2 = GET_FLOAT_PARAM(4);
+ float y2 = GET_FLOAT_PARAM(5);
+ float z2 = GET_FLOAT_PARAM(6);
UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
- if (ScriptParams[7])
+ if (GET_INTEGER_PARAM(7))
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
+ /*
if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
+ */
return 0;
}
case COMMAND_SPECIAL_0:
@@ -4133,56 +4539,54 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
AllowMissionReplay = 1;
#endif
CollectParameters(&m_nIp, 2);
- CMessages::AddBigMessage(key, ScriptParams[0], ScriptParams[1] - 1);
+ CMessages::AddBigMessage(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1) - 1);
return 0;
}
case COMMAND_PRINT:
{
wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
- CMessages::AddMessage(key, ScriptParams[0], ScriptParams[1]);
+ CMessages::AddMessage(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
}
case COMMAND_PRINT_NOW:
{
wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
- CMessages::AddMessageJumpQ(key, ScriptParams[0], ScriptParams[1]);
+ CMessages::AddMessageJumpQ(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
}
- /*
case COMMAND_PRINT_SOON:
{
wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp);
CollectParameters(&m_nIp, 2);
- CMessages::AddMessageSoon(key, ScriptParams[0], ScriptParams[1]);
+ CMessages::AddMessageSoon(key, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
}
- */
case COMMAND_CLEAR_PRINTS:
CMessages::ClearMessages();
return 0;
case COMMAND_GET_TIME_OF_DAY:
- ScriptParams[0] = CClock::GetHours();
- ScriptParams[1] = CClock::GetMinutes();
+ SET_INTEGER_PARAM(0, CClock::GetHours());
+ SET_INTEGER_PARAM(1, CClock::GetMinutes());
StoreParameters(&m_nIp, 2);
return 0;
case COMMAND_SET_TIME_OF_DAY:
CollectParameters(&m_nIp, 2);
- CClock::SetGameClock(ScriptParams[0], ScriptParams[1]);
+ CClock::SetGameClock(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1));
return 0;
case COMMAND_GET_MINUTES_TO_TIME_OF_DAY:
CollectParameters(&m_nIp, 2);
- ScriptParams[0] = CClock::GetGameClockMinutesUntil(ScriptParams[0], ScriptParams[1]);
+ SET_INTEGER_PARAM(0, CClock::GetGameClockMinutesUntil(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)));
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_IS_POINT_ON_SCREEN:
{
CollectParameters(&m_nIp, 4);
- CVector pos = *(CVector*)&ScriptParams[0];
+ CVector pos = GET_VECTOR_PARAM(0);
if (pos.z <= -100)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
- UpdateCompareFlag(TheCamera.IsSphereVisible(pos, *(float*)&ScriptParams[3]));
+ UpdateCompareFlag(TheCamera.IsSphereVisible(pos, GET_FLOAT_PARAM(3)));
return 0;
}
case COMMAND_DEBUG_ON:
@@ -4191,14 +4595,14 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
case COMMAND_DEBUG_OFF:
CTheScripts::DbgFlag = false;
return 0;
- /*
case COMMAND_RETURN_TRUE:
UpdateCompareFlag(true);
+ ReturnFromGosubOrFunction();
return 0;
case COMMAND_RETURN_FALSE:
UpdateCompareFlag(false);
+ ReturnFromGosubOrFunction();
return 0;
- */
//case COMMAND_VAR_INT:
default:
script_assert(0);
@@ -4225,18 +4629,21 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_WHILE:
case COMMAND_WHILENOT:
case COMMAND_ENDWHILE:
+ case COMMAND_214:
+ case COMMAND_215:
+ case COMMAND_216:
+ case COMMAND_217:
+ case COMMAND_218:
*/
case COMMAND_ANDOR:
CollectParameters(&m_nIp, 1);
- m_nAndOrState = ScriptParams[0];
+ m_nAndOrState = GET_INTEGER_PARAM(0);
if (m_nAndOrState == ANDOR_NONE){
m_bCondResult = false; // pointless
}else if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8){
m_bCondResult = true;
- m_nAndOrState++;
}else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8){
m_bCondResult = false;
- m_nAndOrState++;
}else{
script_assert(0 && "COMMAND_ANDOR: invalid ANDOR state");
}
@@ -4244,7 +4651,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_LAUNCH_MISSION:
{
CollectParameters(&m_nIp, 1);
- CRunningScript* pNew = CTheScripts::StartNewScript(ScriptParams[0]);
+ CRunningScript* pNew = CTheScripts::StartNewScript(GET_INTEGER_PARAM(0));
pNew->m_bIsMissionScript = true;
return 0;
}
@@ -4258,7 +4665,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_STORE_CAR_CHAR_IS_IN:
{
CollectParameters(&m_nIp, 1);
- CPed* ped = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* ped = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(ped);
CVehicle* pCurrent = nil;
if (ped->bInVehicle) {
@@ -4303,14 +4710,14 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
break;
}
}
- ScriptParams[0] = CTheScripts::StoreVehicleIndex;
+ SET_INTEGER_PARAM(0, CTheScripts::StoreVehicleIndex);
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_STORE_CAR_PLAYER_IS_IN:
{
CollectParameters(&m_nIp, 1);
- CPed* ped = CWorld::Players[ScriptParams[0]].m_pPed;
+ CPed* ped = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
script_assert(ped);
if (!ped->bInVehicle)
return 0; // No value written to output variable
@@ -4354,15 +4761,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
break;
}
}
- ScriptParams[0] = CTheScripts::StoreVehicleIndex;
+ SET_INTEGER_PARAM(0, CTheScripts::StoreVehicleIndex);
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_IS_CHAR_IN_CAR:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
- CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
+ CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
CVehicle* pActualVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil;
UpdateCompareFlag(pActualVehicle && pActualVehicle == pCheckedVehicle);
return 0;
@@ -4370,51 +4777,51 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_IS_PLAYER_IN_CAR:
{
CollectParameters(&m_nIp, 2);
- CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
- CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ CVehicle* pCheckedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1));
+ CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle == pCheckedVehicle);
return 0;
}
case COMMAND_IS_CHAR_IN_MODEL:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
CVehicle* pActualVehicle = pPed->bInVehicle ? pPed->m_pMyVehicle : nil;
- UpdateCompareFlag(pActualVehicle && pActualVehicle->GetModelIndex() == ScriptParams[1]);
+ UpdateCompareFlag(pActualVehicle && pActualVehicle->GetModelIndex() == GET_INTEGER_PARAM(1));
return 0;
}
case COMMAND_IS_PLAYER_IN_MODEL:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
- UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetModelIndex() == ScriptParams[1]);
+ CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
+ UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetModelIndex() == GET_INTEGER_PARAM(1));
return 0;
}
case COMMAND_IS_CHAR_IN_ANY_CAR:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle);
return 0;
}
case COMMAND_IS_PLAYER_IN_ANY_CAR:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
+ CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed;
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle);
return 0;
}
case COMMAND_IS_BUTTON_PRESSED:
{
CollectParameters(&m_nIp, 2);
- UpdateCompareFlag(GetPadState(ScriptParams[0], ScriptParams[1]) != 0);
+ UpdateCompareFlag(GetPadState(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)) != 0);
return 0;
}
/*
case COMMAND_GET_PAD_STATE:
{
CollectParameters(&m_nIp, 1);
- ScriptParams[0] = GetPadState(ScriptParams[0], ScriptParams[1]);
+ SET_INTEGER_PARAM(0, GetPadState(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)));
StoreParameters(&m_nIp, 1);
return 0;
}
@@ -4474,10 +4881,10 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_CREATE_OBJECT:
{
CollectParameters(&m_nIp, 4);
- int mi = ScriptParams[0] >= 0 ? ScriptParams[0] : CTheScripts::UsedObjectArray[-ScriptParams[0]].index;
+ int mi = GET_INTEGER_PARAM(0) >= 0 ? GET_INTEGER_PARAM(0) : CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(0)].index;
CObject* pObj = new CObject(mi, false);
pObj->ObjectCreatedBy = MISSION_OBJECT;
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += pObj->GetDistanceFromCentreOfMassToBaseOfModel();
@@ -4485,73 +4892,72 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pObj->SetOrientation(0.0f, 0.0f, 0.0f);
pObj->GetMatrix().UpdateRW();
pObj->UpdateRwFrame();
- CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(mi);
- if (pModelInfo->IsBuilding() && ((CSimpleModelInfo*)pModelInfo)->m_isBigBuilding)
- pObj->SetupBigBuilding();
CTheScripts::ClearSpaceForMissionEntity(pos, pObj);
CWorld::Add(pObj);
- ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObj);
+ SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pObj));
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT);
return 0;
}
case COMMAND_DELETE_OBJECT:
{
CollectParameters(&m_nIp, 1);
- CObject* pObj = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
+ CObject* pObj = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0));
if (pObj){
CWorld::Remove(pObj);
CWorld::RemoveReferencesToDeletedObject(pObj);
delete pObj;
}
if (m_bIsMissionScript)
- CTheScripts::MissionCleanUp.RemoveEntityFromList(ScriptParams[0], CLEANUP_OBJECT);
+ CTheScripts::MissionCleanUp.RemoveEntityFromList(GET_INTEGER_PARAM(0), CLEANUP_OBJECT);
return 0;
}
case COMMAND_ADD_SCORE:
CollectParameters(&m_nIp, 2);
- CWorld::Players[ScriptParams[0]].m_nMoney += ScriptParams[1];
- if (CWorld::Players[ScriptParams[0]].m_nMoney < 0)
- CWorld::Players[ScriptParams[0]].m_nMoney = 0;
+ CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney += GET_INTEGER_PARAM(1);
+ if (CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney < 0)
+ CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney = 0;
return 0;
case COMMAND_IS_SCORE_GREATER:
CollectParameters(&m_nIp, 2);
- UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_nMoney > ScriptParams[1]);
+ UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney > GET_INTEGER_PARAM(1));
return 0;
case COMMAND_STORE_SCORE:
CollectParameters(&m_nIp, 1);
- ScriptParams[0] = CWorld::Players[ScriptParams[0]].m_nMoney;
+ SET_INTEGER_PARAM(0, CWorld::Players[GET_INTEGER_PARAM(0)].m_nMoney);
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_GIVE_REMOTE_CONTROLLED_CAR_TO_PLAYER:
{
CollectParameters(&m_nIp, 5);
- CVector pos = *(CVector*)&ScriptParams[1];
+ CVector pos = GET_VECTOR_PARAM(1);
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
- CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(*(float*)&ScriptParams[4]), MI_RCBANDIT);
+ CVehicle* pVehicle = CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), MI_RCBANDIT);
+ SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle));
+ StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_ALTER_WANTED_LEVEL:
CollectParameters(&m_nIp, 2);
- CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevel(ScriptParams[1]);
+ CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevel(GET_INTEGER_PARAM(1));
return 0;
case COMMAND_ALTER_WANTED_LEVEL_NO_DROP:
CollectParameters(&m_nIp, 2);
- CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevelNoDrop(ScriptParams[1]);
+ CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevelNoDrop(GET_INTEGER_PARAM(1));
return 0;
case COMMAND_IS_WANTED_LEVEL_GREATER:
CollectParameters(&m_nIp, 2);
- UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->m_pWanted->GetWantedLevel() > ScriptParams[1]);
+ UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->m_pWanted->GetWantedLevel() > GET_INTEGER_PARAM(1));
return 0;
case COMMAND_CLEAR_WANTED_LEVEL:
CollectParameters(&m_nIp, 1);
- CWorld::Players[ScriptParams[0]].m_pPed->SetWantedLevel(0);
+ CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->SetWantedLevel(0);
return 0;
case COMMAND_SET_DEATHARREST_STATE:
CollectParameters(&m_nIp, 1);
- m_bDeatharrestEnabled = (ScriptParams[0] == 1);
+ m_bDeatharrestEnabled = (GET_INTEGER_PARAM(0) == 1);
return 0;
case COMMAND_HAS_DEATHARREST_BEEN_EXECUTED:
UpdateCompareFlag(m_bDeatharrestExecuted);
@@ -4560,51 +4966,54 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_ADD_AMMO_TO_PLAYER:
{
CollectParameters(&m_nIp, 3);
- CWorld::Players[ScriptParams[0]].m_pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]);
+ CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GrantAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2));
return 0;
}
*/
case COMMAND_ADD_AMMO_TO_CHAR:
{
CollectParameters(&m_nIp, 3);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- pPed->GrantAmmo((eWeaponType)ScriptParams[1], ScriptParams[2]);
+ pPed->GrantAmmo((eWeaponType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2));
return 0;
}
//case COMMAND_ADD_AMMO_TO_CAR:
- //case COMMAND_IS_PLAYER_STILL_ALIVE:
+ case COMMAND_IS_PLAYER_STILL_ALIVE:
+ CollectParameters(&m_nIp, 1);
+ UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState != WBSTATE_WASTED);
+ return 0;
case COMMAND_IS_PLAYER_DEAD:
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_WBState == WBSTATE_WASTED);
+ UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_WBState == WBSTATE_WASTED);
return 0;
case COMMAND_IS_CHAR_DEAD:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
- UpdateCompareFlag(!pPed || pPed->DyingOrDead());
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
+ UpdateCompareFlag(!pPed || pPed->DyingOrDead() || pPed->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE);
return 0;
}
case COMMAND_IS_CAR_DEAD:
{
CollectParameters(&m_nIp, 1);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
UpdateCompareFlag(!pVehicle || pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->bIsDrowning);
return 0;
}
case COMMAND_SET_CHAR_THREAT_SEARCH:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- pPed->m_fearFlags |= ScriptParams[1];
+ pPed->m_fearFlags |= GET_INTEGER_PARAM(1);
return 0;
}
//case COMMAND_SET_CHAR_THREAT_REACTION:
case COMMAND_SET_CHAR_OBJ_NO_OBJ:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
pPed->bScriptObjectiveCompleted = false;
pPed->ClearObjective();
@@ -4617,7 +5026,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_IS_PLAYER_IN_ZONE:
{
CollectParameters(&m_nIp, 1);
- CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
+ CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)];
char label[12];
CTheScripts::ReadTextLabelFromScript(&m_nIp, label);
int zoneToCheck = CTheZones::FindZoneByLabelAndReturnIndex(label, ZONE_DEFAULT);
@@ -4630,15 +5039,15 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
}
case COMMAND_IS_PLAYER_PRESSING_HORN:
CollectParameters(&m_nIp, 1);
- UpdateCompareFlag(CWorld::Players[ScriptParams[0]].m_pPed->GetPedState() == PED_DRIVING &&
- CPad::GetPad(ScriptParams[0])->GetHorn());
+ UpdateCompareFlag(CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed->GetPedState() == PED_DRIVING &&
+ CPad::GetPad(GET_INTEGER_PARAM(0))->GetHorn());
return 0;
case COMMAND_HAS_CHAR_SPOTTED_PLAYER:
{
CollectParameters(&m_nIp, 2);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
- UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[ScriptParams[1]].m_pPed));
+ UpdateCompareFlag(pPed->OurPedCanSeeThisOne(CWorld::Players[GET_INTEGER_PARAM(1)].m_pPed));
return 0;
}
//case COMMAND_ORDER_CHAR_TO_BACKDOOR:
@@ -4646,7 +5055,7 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_IS_CHAR_OBJECTIVE_PASSED:
{
CollectParameters(&m_nIp, 1);
- CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
+ CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pPed);
UpdateCompareFlag(pPed->bScriptObjectiveCompleted);
return 0;
@@ -4658,43 +5067,43 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
case COMMAND_CREATE_CHAR_INSIDE_CAR:
{
CollectParameters(&m_nIp, 3);
- CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
+ CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0));
script_assert(pVehicle);
- switch (ScriptParams[2]) {
+ switch (GET_INTEGER_PARAM(2)) {
case MI_COP:
- if (ScriptParams[1] == PEDTYPE_COP)
- ScriptParams[2] = COP_STREET;
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(2, COP_STREET);
break;
case MI_SWAT:
- if (ScriptParams[1] == PEDTYPE_COP)
- ScriptParams[2] = COP_SWAT;
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(2, COP_SWAT);
break;
case MI_FBI:
- if (ScriptParams[1] == PEDTYPE_COP)
- ScriptParams[2] = COP_FBI;
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(2, COP_FBI);
break;
case MI_ARMY:
- if (ScriptParams[1] == PEDTYPE_COP)
- ScriptParams[2] = COP_ARMY;
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_COP)
+ SET_INTEGER_PARAM(2, COP_ARMY);
break;
case MI_MEDIC:
- if (ScriptParams[1] == PEDTYPE_EMERGENCY)
- ScriptParams[2] = PEDTYPE_EMERGENCY;
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY)
+ SET_INTEGER_PARAM(2, PEDTYPE_EMERGENCY);
break;
case MI_FIREMAN:
- if (ScriptParams[1] == PEDTYPE_FIREMAN)
- ScriptParams[2] = PEDTYPE_FIREMAN;
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN)
+ SET_INTEGER_PARAM(2, PEDTYPE_FIREMAN);
break;
default:
break;
}
CPed* pPed;
- if (ScriptParams[1] == PEDTYPE_COP)
- pPed = new CCopPed((eCopType)ScriptParams[2]);
- else if (ScriptParams[1] == PEDTYPE_EMERGENCY || ScriptParams[1] == PEDTYPE_FIREMAN)
- pPed = new CEmergencyPed(ScriptParams[2]);
+ if (GET_INTEGER_PARAM(1) == PEDTYPE_COP)
+ pPed = new CCopPed((eCopType)GET_INTEGER_PARAM(2));
+ else if (GET_INTEGER_PARAM(1) == PEDTYPE_EMERGENCY || GET_INTEGER_PARAM(1) == PEDTYPE_FIREMAN)
+ pPed = new CEmergencyPed(GET_INTEGER_PARAM(2));
else
- pPed = new CCivilianPed((ePedType)ScriptParams[1], ScriptParams[2]);
+ pPed = new CCivilianPed((ePedType)GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2));
pPed->CharCreatedBy = MISSION_CHAR;
pPed->bRespondsToThreats = false;
pPed->bAllowMedicsToReviveMe = false;
@@ -4704,7 +5113,6 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pPed->SetPosition(pVehicle->GetPosition());
pPed->SetOrientation(0.0f, 0.0f, 0.0f);
pPed->SetPedState(PED_DRIVING);
- CPopulation::ms_nTotalMissionPeds++;
script_assert(!pVehicle->pDriver);
pVehicle->pDriver = pPed;
pVehicle->pDriver->RegisterReference((CEntity**)&pVehicle->pDriver);
@@ -4719,17 +5127,18 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
pPed->AddInCarAnims(pVehicle, true);
pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition());
CWorld::Add(pPed);
- ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed);
+ CPopulation::ms_nTotalMissionPeds++;
+ SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed));
StoreParameters(&m_nIp, 1);
if (m_bIsMissionScript)
- CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR);
+ CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR);
return 0;
}
case COMMAND_WARP_PLAYER_FROM_CAR_TO_COORD:
{
CollectParameters(&m_nIp, 4);
- CVector pos = *(CVector*)&ScriptParams[1];
- CPlayerInfo* pPlayer = &CWorld::Players[ScriptParams[0]];
+ CVector pos = GET_VECTOR_PARAM(1);
+ CPlayerInfo* pPlayer = &CWorld::Players[GET_INTEGER_PARAM(0)];
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
if (pPlayer->m_pPed->bInVehicle){
@@ -4772,6 +5181,24 @@ int8 CRunningScript::ProcessCommands200To299(int32 command)
return -1;
}
+void CRunningScript::ReturnFromGosubOrFunction()
+{
+ uint32 val = m_nIp = m_anStack[--m_nStackPointer];
+ if (!(m_nIp & BIT(STACKVALUE_IS_FUNCTION_CALL_BIT)))
+ return;
+ if (m_nIp & BIT(STACKVALUE_INVERT_RETURN_BIT))
+ m_bCondResult = !m_bCondResult;
+ m_nIp = m_nIp & STACKVALUE_IP_MASK;
+ uint8 nInputParameters = CTheScripts::Read1ByteFromScript(&m_nIp);
+ uint8 nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp);
+ uint8 nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp);
+ for (int i = 0; i < nOutputParameters; i++)
+ ScriptParams[i] = m_anLocalVariables[m_nLocalsPointer + nInputParameters + i];
+ m_nIp += val >> STACKVALUE_IP_PARAMS_OFFSET;
+ m_nLocalsPointer -= nLocalsOffset;
+ StoreParameters(&m_nIp, nOutputParameters);
+}
+
#ifdef MISSION_REPLAY
bool CRunningScript::CanAllowMissionReplay()
@@ -4842,23 +5269,19 @@ CTheScripts::SwitchToMission(int32 mission)
CStats::LastMissionPassedName[0] = '\0';
#endif
CTimer::Suspend();
- int offset = CTheScripts::MultiScriptArray[mission];
-#ifdef USE_DEBUG_SCRIPT_LOADER
- CFileMgr::ChangeDir("\\data\\");
- int handle = CFileMgr::OpenFile(scriptfile, "rb");
- CFileMgr::ChangeDir("\\");
-#else
- CFileMgr::ChangeDir("\\");
- int handle = CFileMgr::OpenFile("data\\main.scm", "rb");
-#endif
- CFileMgr::Seek(handle, offset, 0);
- CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[SIZE_MAIN_SCRIPT], SIZE_MISSION_SCRIPT);
- CFileMgr::CloseFile(handle);
- CRunningScript* pMissionScript = CTheScripts::StartNewScript(SIZE_MAIN_SCRIPT);
+ int offset = CTheScripts::MultiScriptArray[mission] + 8;
+ int size = CTheScripts::MultiScriptArray[mission + 1] - CTheScripts::MultiScriptArray[mission];
+ if (size <= 0)
+ size = CTheScripts::LargestMissionScriptSize;
+ CFileMgr::Seek(gScriptsFile, offset, 0);
+ CFileMgr::Read(gScriptsFile, (const char*)&CTheScripts::ScriptSpace[CTheScripts::MainScriptSize], size);
+ CRunningScript* pMissionScript = CTheScripts::StartNewScript(CTheScripts::MainScriptSize);
CTimer::Resume();
pMissionScript->m_bIsMissionScript = true;
pMissionScript->m_bMissionFlag = true;
CTheScripts::bAlreadyRunningAMissionScript = true;
+ memset(&CTheScripts::ScriptSpace[CTheScripts::NumTrueGlobals * 4 + 8], 0, CTheScripts::MostGlobals * 4);
CGameLogic::ClearShortCut();
+ pMissionScript->Process();
}
#endif