diff options
-rw-r--r-- | src/control/Replay.h | 4 | ||||
-rw-r--r-- | src/control/Script.cpp | 72 | ||||
-rw-r--r-- | src/control/Script.h | 40 | ||||
-rw-r--r-- | src/control/Script10.cpp | 213 | ||||
-rw-r--r-- | src/control/Script3.cpp | 6 | ||||
-rw-r--r-- | src/control/Script4.cpp | 2 | ||||
-rw-r--r-- | src/control/Script5.cpp | 590 | ||||
-rw-r--r-- | src/control/Script6.cpp | 751 | ||||
-rw-r--r-- | src/control/Script7.cpp | 599 | ||||
-rw-r--r-- | src/control/Script8.cpp | 1074 | ||||
-rw-r--r-- | src/control/Script9.cpp | 338 | ||||
-rw-r--r-- | src/control/ScriptCommands.h | 64 | ||||
-rw-r--r-- | src/core/Pad.h | 10 | ||||
-rw-r--r-- | src/core/Radar.cpp | 2 | ||||
-rw-r--r-- | src/core/main.cpp | 2 | ||||
-rw-r--r-- | src/peds/Ped.cpp | 75 | ||||
-rw-r--r-- | src/peds/Ped.h | 49 | ||||
-rw-r--r-- | src/render/Hud.cpp | 2 | ||||
-rw-r--r-- | src/render/Hud.h | 2 |
19 files changed, 2231 insertions, 1664 deletions
diff --git a/src/control/Replay.h b/src/control/Replay.h index 5dd8b651..98e02577 100644 --- a/src/control/Replay.h +++ b/src/control/Replay.h @@ -46,7 +46,7 @@ enum { struct CStoredDetailedAnimationState { - uint8 aAnimId[NUM_MAIN_ANIMS_IN_REPLAY]; + uint16 aAnimId[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aCurTime[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aSpeed[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aBlendAmount[NUM_MAIN_ANIMS_IN_REPLAY]; @@ -54,7 +54,7 @@ struct CStoredDetailedAnimationState uint8 aFunctionCallbackID[NUM_MAIN_ANIMS_IN_REPLAY]; uint16 aFlags[NUM_MAIN_ANIMS_IN_REPLAY]; uint8 aGroupId[NUM_MAIN_ANIMS_IN_REPLAY]; - uint8 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; + uint16 aAnimId2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aCurTime2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aSpeed2[NUM_PARTIAL_ANIMS_IN_REPLAY]; uint8 aBlendAmount2[NUM_PARTIAL_ANIMS_IN_REPLAY]; diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 038eff6d..0f32f873 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1231,7 +1231,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, ""), @@ -1319,7 +1319,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, ""), @@ -1592,24 +1592,24 @@ const tScriptCommandData commands[] = { 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, ""), REGISTER_COMMAND(COMMAND_IS_JAPANESE_GAME, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), true, -1, ""), - REGISTER_COMMAND(COMMAND_1442, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + 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_1444, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1445, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1446, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1447, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1448, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1449, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1450, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1451, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1452, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1453, 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_NOTCALL, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1456, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1457, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1458, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1459, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_CALLNOT, INPUT_ARGUMENTS(), 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, ""), @@ -1627,26 +1627,26 @@ const tScriptCommandData commands[] = { 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_1477, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1478, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1479, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1480, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1481, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1482, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1483, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1484, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1485, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1486, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1487, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1488, 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_USING_FIRST_PERSON_WEAPON_CAMERA, INPUT_ARGUMENTS(), 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(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1492, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1493, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1494, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1495, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), - REGISTER_COMMAND(COMMAND_1496, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_1491, INPUT_ARGUMENTS(ARGTYPE_INT, ), OUTPUT_ARGUMENTS(), false, -1, ""), + REGISTER_COMMAND(COMMAND_SET_DEBUG_MENU_ACTUVE, 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(), false, -1, ""), REGISTER_COMMAND(COMMAND_1497, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_1498, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), REGISTER_COMMAND(COMMAND_1499, INPUT_ARGUMENTS(), OUTPUT_ARGUMENTS(), false, -1, ""), diff --git a/src/control/Script.h b/src/control/Script.h index 233e00e5..5c31625f 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -360,11 +360,13 @@ public: static void UndoBuildingSwaps(); static void UndoEntityInvisibilitySettings(); + /* static void ScriptDebugLine3D(float x1, float y1, float z1, float x2, float y2, float z2, uint32 col, uint32 col2); static void RenderTheScriptDebugLines(); + */ static void SaveAllScripts(uint8*, uint32*); - static void LoadAllScripts(uint8*, uint32); + static bool LoadAllScripts(uint8*, uint32); static bool IsDebugOn() { return DbgFlag; }; static void InvertDebugFlag() { DbgFlag = !DbgFlag; } @@ -420,10 +422,12 @@ public: static void DrawScriptSpheres(); static void HighlightImportantArea(uint32, float, float, float, float, float); static void HighlightImportantAngledArea(uint32, float, float, float, float, float, float, float, float, float); + /* static void DrawDebugSquare(float, float, float, float); static void DrawDebugAngledSquare(float, float, float, float, float, float, float, float); static void DrawDebugCube(float, float, float, float, float, float); static void DrawDebugAngledCube(float, float, float, float, float, float, float, float, float, float); + */ static void AddToInvisibilitySwapArray(CEntity*, bool); static void AddToBuildingSwapArray(CBuilding*, int32, int32); @@ -432,7 +436,7 @@ public: static int32 AddScriptSphere(int32 id, CVector pos, float radius); static int32 GetNewUniqueScriptSphereIndex(int32 index); static void RemoveScriptSphere(int32 index); - static void RemoveScriptTextureDictionary(); + //static void RemoveScriptTextureDictionary(); public: static void RemoveThisPed(CPed* pPed); @@ -504,7 +508,7 @@ class CRunningScript public: CRunningScript* next; CRunningScript* prev; - int m_nId; + int32 m_nId; char m_abScriptName[8]; uint32 m_nIp; uint32 m_anStack[MAX_STACK_DEPTH]; @@ -549,7 +553,33 @@ public: int8 ProcessOneCommand(); void DoDeatharrestCheck(); - void UpdateCompareFlag(bool); + void UpdateCompareFlag(bool flag) + { + if (m_bNotFlag) + flag = !flag; + if (m_nAndOrState == ANDOR_NONE) { + m_bCondResult = flag; + return; + } + if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { + m_bCondResult &= flag; + if (m_nAndOrState == ANDS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8) { + m_bCondResult |= flag; + if (m_nAndOrState == ORS_1) { + m_nAndOrState = ANDOR_NONE; + return; + } + } + else { + return; + } + m_nAndOrState--; + } int16 GetPadState(uint16, uint16); int8 ProcessCommands0To99(int32); @@ -570,6 +600,7 @@ public: int8 ProcessCommands1500To1599(int32); int8 ProcessCommands1600To1699(int32); + uint32 CollectLocateParameters(uint32*, bool); void LocatePlayerCommand(int32, uint32*); void LocatePlayerCharCommand(int32, uint32*); void LocatePlayerCarCommand(int32, uint32*); @@ -608,6 +639,7 @@ public: bool ThisIsAValidRandomCop(uint32 mi, int cop, int swat, int fbi, int army, int miami); bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal); bool CheckDamagedWeaponType(int32 actual, int32 type); + void ReturnFromGosubOrFunction(); }; diff --git a/src/control/Script10.cpp b/src/control/Script10.cpp new file mode 100644 index 00000000..d558727e --- /dev/null +++ b/src/control/Script10.cpp @@ -0,0 +1,213 @@ +#include "common.h" + +#include "Script.h" +#include "ScriptCommands.h" + +#include "PlayerPed.h" +#include "World.h" + +int8 CRunningScript::ProcessCommands1600To1699(int32 command) +{ + switch (command) { + case COMMAND_1600: + script_assert(false); + return 0; + case COMMAND_1601: + script_assert(false); + return 0; + case COMMAND_1602: + script_assert(false); + return 0; + case COMMAND_1603: + script_assert(false); + return 0; + case COMMAND_1604: + script_assert(false); + return 0; + case COMMAND_1605: + script_assert(false); + return 0; + case COMMAND_1606: + script_assert(false); + return 0; + case COMMAND_1607: + CollectParameters(&m_nIp, 1); + // TODO (SET_TOTAL_CARS_FOR_EXPORT) + return 0; + case COMMAND_1608: + script_assert(false); + return 0; + case COMMAND_1609: + script_assert(false); + return 0; + case COMMAND_1610: + script_assert(false); + return 0; + case COMMAND_1611: + script_assert(false); + return 0; + case COMMAND_1612: + script_assert(false); + return 0; + case COMMAND_1613: + script_assert(false); + return 0; + case COMMAND_1614: + script_assert(false); + return 0; + case COMMAND_1615: + // TODO (GET_DEVELOPER_FLAG?) + UpdateCompareFlag(false); + return 0; + case COMMAND_1616: + // TODO (SET_DEVELOPER_FLAG) + return 0; + case COMMAND_1617: + script_assert(false); + return 0; + case COMMAND_1618: + script_assert(false); + return 0; + case COMMAND_1619: + script_assert(false); + return 0; + case COMMAND_1620: + script_assert(false); + return 0; + case COMMAND_1621: + { + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 2); + // TODO (SET_SUBTITLE_TEXT) + return 0; + } + case COMMAND_1622: + script_assert(false); + return 0; + case COMMAND_1623: + script_assert(false); + return 0; + case COMMAND_1624: + script_assert(false); + return 0; + case COMMAND_1625: + script_assert(false); + return 0; + case COMMAND_1626: + script_assert(false); + return 0; + case COMMAND_1627: + script_assert(false); + return 0; + case COMMAND_1628: + script_assert(false); + return 0; + case COMMAND_1629: + script_assert(false); + return 0; + case COMMAND_1630: + script_assert(false); + return 0; + case COMMAND_1631: + script_assert(false); + return 0; + case COMMAND_1632: + script_assert(false); + return 0; + case COMMAND_1633: + script_assert(false); + return 0; + case COMMAND_1634: + script_assert(false); + return 0; + case COMMAND_1635: + { + char tmp[12]; // TODO + CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); + m_nIp += KEY_LENGTH_IN_SCRIPT; + // TODO (CHANGE_STORED_PLAYER_OUTFIT?) + return 0; + } + case COMMAND_1636: + script_assert(false); + return 0; + case COMMAND_1637: + script_assert(false); + return 0; + case COMMAND_1638: + script_assert(false); + return 0; + case COMMAND_1639: + script_assert(false); + return 0; + case COMMAND_1640: + CollectParameters(&m_nIp, 2); + // TODO (LOCK_GARAGE?) + return 0; + case COMMAND_1641: + // TODO + UpdateCompareFlag(true); + return 0; + case COMMAND_1642: + script_assert(false); + return 0; + case COMMAND_1643: + script_assert(false); + return 0; + case COMMAND_1644: + script_assert(false); + return 0; + case COMMAND_1645: + { + CollectParameters(&m_nIp, 1); + // TODO (GET_STORED_WEAPON?) + CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + script_assert(pPed); + ScriptParams[0] = pPed->m_storedWeapon; + StoreParameters(&m_nIp, 1); + return 0; + } + case COMMAND_1646: + CollectParameters(&m_nIp, 1); + // TODO (DISABLE_PAUSE_MENU?) + return 0; + case COMMAND_1647: + CollectParameters(&m_nIp, 1); + // TODO (IS_CHANNEL_PLAYING?) + UpdateCompareFlag(false); + return 0; + case COMMAND_1648: + CollectParameters(&m_nIp, 3); + // TODO (SET_CLOCK_EVENT_WARNING); + return 0; + case COMMAND_1649: + CollectParameters(&m_nIp, 3); + // TODO (SET_EXTRA_COLOUR_DIRECTION) + return 0; + case COMMAND_1650: + script_assert(false); + return 0; + case COMMAND_1651: + script_assert(false); + return 0; + case COMMAND_1652: + script_assert(false); + return 0; + case COMMAND_1653: + script_assert(false); + return 0; + case COMMAND_1654: + script_assert(false); + return 0; + case COMMAND_1655: + script_assert(false); + return 0; + case COMMAND_1656: + CollectParameters(&m_nIp, 2); + // TODO (?) + return 0; + default: + script_assert(0); + } + return -1; +}
\ No newline at end of file diff --git a/src/control/Script3.cpp b/src/control/Script3.cpp index 88df935f..1bb4f12c 100644 --- a/src/control/Script3.cpp +++ b/src/control/Script3.cpp @@ -36,6 +36,8 @@ #include "GameLogic.h" #include "Bike.h" +// LCS: file done except TODOs + int8 CRunningScript::ProcessCommands500To599(int32 command) { switch (command) { @@ -1740,8 +1742,10 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CHAR_SHOOTING_IN_AREA: @@ -1756,8 +1760,10 @@ int8 CRunningScript::ProcessCommands700To799(int32 command) UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); if (GET_INTEGER_PARAM(5)) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) CTheScripts::DrawDebugSquare(x1, y1, x2, y2); + */ return 0; } case COMMAND_IS_CURRENT_PLAYER_WEAPON: diff --git a/src/control/Script4.cpp b/src/control/Script4.cpp index 12eb179c..ba845ad8 100644 --- a/src/control/Script4.cpp +++ b/src/control/Script4.cpp @@ -40,6 +40,8 @@ #include "Zones.h" #include "Bike.h" +// LCS: file done except TODOs + #ifdef FIX_BUGS static bool IsSlideObjectUsedWrongByScript(const CVector& posTarget, const CVector& slideBy) { diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp index c0e3ecad..65e85779 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -17,32 +17,20 @@ #include "World.h" #include "main.h" -void CRunningScript::UpdateCompareFlag(bool flag) +// LCS: file done except TODOs + +uint32 CRunningScript::CollectLocateParameters(uint32* pIp, bool b3D) { - if (m_bNotFlag) - flag = !flag; - if (m_nAndOrState == ANDOR_NONE) { - m_bCondResult = flag; - return; - } - if (m_nAndOrState >= ANDS_1 && m_nAndOrState <= ANDS_8) { - m_bCondResult &= flag; - if (m_nAndOrState == ANDS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - } - else if (m_nAndOrState >= ORS_1 && m_nAndOrState <= ORS_8) { - m_bCondResult |= flag; - if (m_nAndOrState == ORS_1) { - m_nAndOrState = ANDOR_NONE; - return; - } - } - else { - return; - } - m_nAndOrState--; + CollectParameters(pIp, 1); + uint32 id = (uintptr)this + (*pIp - 16); + uint32 ip = *pIp; + uint8 type = CTheScripts::Read1ByteFromScript(&ip); + if (type >= ARGUMENT_LOCAL) { + ip--; + id = (uint32)GetPointerToScriptVariable(&ip, 0); + } + CollectParameters(pIp, b3D ? 7 : 5, &(ScriptParams[1])); + return id; } void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) @@ -62,8 +50,8 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + uint32 id = CollectLocateParameters(pIp, b3D); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; switch (command) { case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_2D: case COMMAND_LOCATE_STOPPED_PLAYER_ANY_MEANS_3D: @@ -79,37 +67,23 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) default: break; } - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } + CVector pos = pPlayerInfo->GetPos(); if (!decided) { - CVector pos = pPlayerInfo->GetPos(); result = false; - bool in_area; - if (b3D) { - in_area = X - dX <= pos.x && - X + dX >= pos.x && - Y - dY <= pos.y && - Y + dY >= pos.y && - Z - dZ <= pos.z && - Z + dZ >= pos.z; - } else { - in_area = X - dX <= pos.x && - X + dX >= pos.x && - Y - dY <= pos.y && - Y + dY >= pos.y; - } - if (in_area) { + if (Abs(pos.x - X) < dX && Abs(pos.y - Y) < dY && (!b3D || Abs(pos.z - Z) < dZ)) { switch (command) { case COMMAND_LOCATE_PLAYER_ANY_MEANS_2D: case COMMAND_LOCATE_PLAYER_ANY_MEANS_3D: @@ -136,14 +110,16 @@ void CRunningScript::LocatePlayerCommand(int32 command, uint32* pIp) } } UpdateCompareFlag(result); - if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + if (debug && Abs(pos.x - X) < 80.0f && Abs(pos.y - Y) < 80.0f) + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) @@ -161,8 +137,8 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPlayerInfo->GetPos(); if (pTarget->bInVehicle) { @@ -174,14 +150,14 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; } - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -225,12 +201,14 @@ void CRunningScript::LocatePlayerCharCommand(int32 command, uint32* pIp) #else CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : MAP_Z_LOW_LIMIT); #endif + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) @@ -248,21 +226,21 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPlayerInfo->GetPos(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -302,12 +280,14 @@ void CRunningScript::LocatePlayerCarCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) @@ -327,8 +307,8 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos = pPed->InVehicle() ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); switch (command) { @@ -346,19 +326,19 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) default: break; } - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (!decided) { result = false; @@ -405,13 +385,15 @@ void CRunningScript::LocateCharCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) @@ -429,9 +411,9 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); if (pTarget->bInVehicle) { @@ -444,14 +426,14 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; } - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -495,12 +477,14 @@ void CRunningScript::LocateCharCharCommand(int32 command, uint32* pIp) #else CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dX, b3D ? Z : MAP_Z_LOW_LIMIT); #endif + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) @@ -518,22 +502,22 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -573,12 +557,14 @@ void CRunningScript::LocateCharCarCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) @@ -596,22 +582,22 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pTarget = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); CVector pos = pPed->bInVehicle ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = false; bool in_area; @@ -651,12 +637,14 @@ void CRunningScript::LocateCharObjectCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) @@ -672,8 +660,8 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CVector pos = pVehicle->GetPosition(); switch (command) { @@ -687,19 +675,19 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) default: break; } - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (!decided) { result = false; @@ -722,13 +710,15 @@ void CRunningScript::LocateCarCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp) @@ -743,23 +733,23 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CVector pos = pObject->GetPosition(); - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } result = false; bool in_area; @@ -780,13 +770,15 @@ void CRunningScript::LocateObjectCommand(int32 command, uint32* pIp) result = in_area; UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp) @@ -802,30 +794,32 @@ void CRunningScript::LocateSniperBulletCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 7 : 5); - X = *(float*)&ScriptParams[0]; - Y = *(float*)&ScriptParams[1]; + X = GET_FLOAT_PARAM(0); + Y = GET_FLOAT_PARAM(1); if (b3D) { - Z = *(float*)&ScriptParams[2]; - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - dZ = *(float*)&ScriptParams[5]; - debug = ScriptParams[6]; + Z = GET_FLOAT_PARAM(2); + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + dZ = GET_FLOAT_PARAM(5); + debug = GET_INTEGER_PARAM(6); } else { - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; - debug = ScriptParams[4]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); + debug = GET_INTEGER_PARAM(4); } result = CBulletInfo::TestForSniperBullet(X - dX, X + dX, Y - dY, Y + dY, b3D ? Z - dZ : -1000.0f, b3D ? Z + dZ : 1000.0f); UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) @@ -845,8 +839,8 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + uint32 id = CollectLocateParameters(pIp, b3D); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; switch (command) { case COMMAND_IS_PLAYER_STOPPED_IN_AREA_3D: case COMMAND_IS_PLAYER_STOPPED_IN_AREA_ON_FOOT_3D: @@ -862,23 +856,23 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -937,12 +931,14 @@ void CRunningScript::PlayerInAreaCheckCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) @@ -963,7 +959,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 9 : 7); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; switch (command) { case COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_3D: case COMMAND_IS_PLAYER_STOPPED_IN_ANGLED_AREA_ON_FOOT_3D: @@ -979,25 +975,25 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - side2length = *(float*)&ScriptParams[7]; - debug = ScriptParams[8]; + side2length = GET_FLOAT_PARAM(7); + debug = GET_INTEGER_PARAM(8); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - side2length = *(float*)&ScriptParams[5]; - debug = ScriptParams[6]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + side2length = GET_FLOAT_PARAM(5); + debug = GET_INTEGER_PARAM(6); } float initAngle = CGeneral::GetRadianAngleBetweenPoints(infX, infY, supX, supY) + HALFPI; while (initAngle < 0.0f) @@ -1060,6 +1056,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) if (debug) CTheScripts::HighlightImportantAngledArea((uintptr)this + m_nIp, infX, infY, supX, supY, rotatedSupX, rotatedSupY, rotatedInfX, rotatedInfY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugAngledCube(infX, infY, infZ, supX, supY, supZ, @@ -1068,6 +1065,7 @@ void CRunningScript::PlayerInAngledAreaCheckCommand(int32 command, uint32* pIp) CTheScripts::DrawDebugAngledSquare(infX, infY, supX, supY, rotatedSupX, rotatedSupY, rotatedInfX, rotatedInfY); } + */ } void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) @@ -1087,8 +1085,8 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos = pPed->InVehicle() ? pPed->m_pMyVehicle->GetPosition() : pPed->GetPosition(); switch (command) { @@ -1106,23 +1104,23 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1179,13 +1177,15 @@ void CRunningScript::CharInAreaCheckCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) @@ -1201,8 +1201,8 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CVector pos = pVehicle->GetPosition(); switch (command) { @@ -1216,23 +1216,23 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) default: break; } - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1277,13 +1277,15 @@ void CRunningScript::CarInAreaCheckCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp) @@ -1298,27 +1300,27 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp) b3D = false; break; } - CollectParameters(pIp, b3D ? 8 : 6); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + uint32 id = CollectLocateParameters(pIp, b3D); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CVector pos = pObject->GetPosition(); - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1359,13 +1361,15 @@ void CRunningScript::ObjectInAreaCheckCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } void CRunningScript::DoDeatharrestCheck() @@ -1386,7 +1390,8 @@ void CRunningScript::DoDeatharrestCheck() script_assert(m_nStackPointer > 0); while (m_nStackPointer > 1) --m_nStackPointer; - m_nIp = m_anStack[--m_nStackPointer]; + ReturnFromGosubOrFunction(); + m_nLocalsPointer = 0; CMessages::ClearSmallMessagesOnly(); *(int32*)&CTheScripts::ScriptSpace[CTheScripts::OnAMissionFlag] = 0; m_bDeatharrestExecuted = true; @@ -1440,24 +1445,24 @@ void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp) b3D = true; break; } - CollectParameters(pIp, b3D ? 8 : 6); - X = *(float*)&ScriptParams[1]; - Y = *(float*)&ScriptParams[2]; + uint32 id = CollectLocateParameters(pIp, b3D); + X = GET_FLOAT_PARAM(1); + Y = GET_FLOAT_PARAM(2); if (b3D) { - Z = *(float*)&ScriptParams[3]; - dX = *(float*)&ScriptParams[4]; - dY = *(float*)&ScriptParams[5]; - dZ = *(float*)&ScriptParams[6]; - debug = ScriptParams[7]; + Z = GET_FLOAT_PARAM(3); + dX = GET_FLOAT_PARAM(4); + dY = GET_FLOAT_PARAM(5); + dZ = GET_FLOAT_PARAM(6); + debug = GET_INTEGER_PARAM(7); } else { - dX = *(float*)&ScriptParams[3]; - dY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dX = GET_FLOAT_PARAM(3); + dY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1518,13 +1523,15 @@ void CRunningScript::LocateCollectiveCommand(int32 command, uint32* pIp) } UpdateCompareFlag(result); if (debug) - CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + CTheScripts::HighlightImportantArea(id, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) @@ -1542,7 +1549,7 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); if (pTarget->bInVehicle) { X = pTarget->m_pMyVehicle->GetPosition().x; @@ -1554,18 +1561,18 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; } - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1610,12 +1617,14 @@ void CRunningScript::LocateCollectiveCharCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) @@ -1633,23 +1642,23 @@ void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pTarget = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); X = pTarget->GetPosition().x; Y = pTarget->GetPosition().y; Z = pTarget->GetPosition().z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1694,12 +1703,14 @@ void CRunningScript::LocateCollectiveCarCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) @@ -1717,22 +1728,22 @@ void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 6 : 5); - CVector pos = CWorld::Players[ScriptParams[1]].GetPos(); + CVector pos = CWorld::Players[GET_INTEGER_PARAM(1)].GetPos(); X = pos.x; Y = pos.y; Z = pos.z; - dX = *(float*)&ScriptParams[2]; - dY = *(float*)&ScriptParams[3]; + dX = GET_FLOAT_PARAM(2); + dY = GET_FLOAT_PARAM(3); if (b3D) { - dZ = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + dZ = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } else { - debug = ScriptParams[4]; + debug = GET_INTEGER_PARAM(4); } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1777,12 +1788,14 @@ void CRunningScript::LocateCollectivePlayerCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, X - dX, Y - dY, X + dX, Y + dY, b3D ? Z : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(X - dX, Y - dY, Z - dZ, X + dX, Y + dY, Z + dZ); else CTheScripts::DrawDebugSquare(X - dX, Y - dY, X + dX, Y + dY); } + */ } void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) @@ -1803,23 +1816,23 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) break; } CollectParameters(pIp, b3D ? 8 : 6); - infX = *(float*)&ScriptParams[1]; - infY = *(float*)&ScriptParams[2]; + infX = GET_FLOAT_PARAM(1); + infY = GET_FLOAT_PARAM(2); if (b3D) { - infZ = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[6]; + infZ = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(6); if (infZ > supZ) { - infZ = *(float*)&ScriptParams[6]; - supZ = *(float*)&ScriptParams[3]; + infZ = GET_FLOAT_PARAM(6); + supZ = GET_FLOAT_PARAM(3); } - debug = ScriptParams[7]; + debug = GET_INTEGER_PARAM(7); } else { - supX = *(float*)&ScriptParams[3]; - supY = *(float*)&ScriptParams[4]; - debug = ScriptParams[5]; + supX = GET_FLOAT_PARAM(3); + supY = GET_FLOAT_PARAM(4); + debug = GET_INTEGER_PARAM(5); } if (infX > supX) { float tmp = infX; @@ -1833,7 +1846,7 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) } result = true; for (int i = 0; i < MAX_NUM_COLLECTIVES && result; i++) { - if (ScriptParams[0] != CTheScripts::CollectiveArray[i].colIndex) + if (GET_INTEGER_PARAM(0) != CTheScripts::CollectiveArray[i].colIndex) continue; CPed* pPed = CPools::GetPedPool()->GetAt(CTheScripts::CollectiveArray[i].pedIndex); if (!pPed) { @@ -1895,12 +1908,14 @@ void CRunningScript::CollectiveInAreaCheckCommand(int32 command, uint32* pIp) UpdateCompareFlag(result); if (debug) CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, infX, infY, supX, supY, b3D ? (infZ + supZ) / 2 : MAP_Z_LOW_LIMIT); + /* if (CTheScripts::DbgFlag) { if (b3D) CTheScripts::DrawDebugCube(infX, infY, infZ, supX, supY, supZ); else CTheScripts::DrawDebugSquare(infX, infY, supX, supY); } + */ } #endif @@ -1987,8 +2002,9 @@ void CTheScripts::PrintListSizes() debug("active: %d, idle: %d", active, idle); } -uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255 +//uint32 DbgLineColour = 0x0000FFFF; // r = 0, g = 0, b = 255, a = 255 +/* void CTheScripts::DrawDebugSquare(float infX, float infY, float supX, float supY) { CColPoint tmpCP; @@ -2095,6 +2111,7 @@ void CTheScripts::RenderTheScriptDebugLines() NumScriptDebugLines = 0; RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)0); } +*/ #define SCRIPT_DATA_SIZE sizeof(CTheScripts::OnAMissionFlag) +\ 4 * sizeof(uint32) * MAX_NUM_BUILDING_SWAPS + 2 * sizeof(uint32) * MAX_NUM_INVISIBILITY_SETTINGS + 5 * sizeof(uint32) @@ -2118,6 +2135,9 @@ INITSAVEBUF WriteSaveBuf(buf, script_data_size); WriteSaveBuf(buf, OnAMissionFlag); WriteSaveBuf(buf, LastMissionPassedTime); + for (uint32 i = 0; i < MAX_NUM_COLLECTIVES; i++) + WriteSaveBuf(buf, CollectiveArray[i]); + WriteSaveBuf(buf, NextFreeCollectiveIndex); for (uint32 i = 0; i < MAX_NUM_BUILDING_SWAPS; i++) { CBuilding* pBuilding = BuildingSwapArray[i].m_pBuilding; uint32 type, handle; @@ -2179,14 +2199,26 @@ INITSAVEBUF VALIDATESAVEBUF(*size) } -void CTheScripts::LoadAllScripts(uint8* buf, uint32 size) +// TODO: I don't really understand how script loading works, so I leave it the VC way for now. +bool CTheScripts::LoadAllScripts(uint8* buf, uint32 size) { - Init(); + Init(); // TODO: in LCS CTheScripts::Init call GenericLoad, which then calls LoadAllScripts INITSAVEBUF CheckSaveHeader(buf, 'S', 'C', 'R', '\0', size - SAVE_HEADER_SIZE); uint32 varSpace = ReadSaveBuf<uint32>(buf); - for (uint32 i = 0; i < varSpace; i++) - ScriptSpace[i] = ReadSaveBuf<uint8>(buf); + if (*(int32*)&ScriptSpace[0] != *(int32*)&buf[0] || *(int32*)&ScriptSpace[4] != *(int32*)&buf[4]) { + printf("\n===================================================\nSave Game Mismatch!!!\n"); + return false; + } + for (uint32 i = 0; i < varSpace; i++) { // this is not exactly what function does + if (i < 8) + ScriptSpace[i] = ReadSaveBuf<uint8>(buf); + else if (GetSaveVarIndex(i / 4 * 4) != -1) + ScriptSpace[i] = ReadSaveBuf<uint8>(buf); + else + ReadSaveBuf<uint8>(buf); + } + // everything else is... gone? TODO script_assert(ReadSaveBuf<uint32>(buf) == SCRIPT_DATA_SIZE); OnAMissionFlag = ReadSaveBuf<uint32>(buf); LastMissionPassedTime = ReadSaveBuf<uint32>(buf); @@ -2246,6 +2278,7 @@ INITSAVEBUF uint32 runningScripts = ReadSaveBuf<uint32>(buf); for (uint32 i = 0; i < runningScripts; i++) StartNewScript(0)->Load(buf); + return true; VALIDATESAVEBUF(size) } @@ -2255,6 +2288,7 @@ void CRunningScript::Save(uint8*& buf) { #ifdef COMPATIBLE_SAVES SkipSaveBuf(buf, 8); + WriteSaveBuf<int32>(buf, m_nId); for (int i = 0; i < 8; i++) WriteSaveBuf<char>(buf, m_abScriptName[i]); WriteSaveBuf<uint32>(buf, m_nIp); @@ -2266,10 +2300,11 @@ void CRunningScript::Save(uint8*& buf) WriteSaveBuf<uint16>(buf, m_nStackPointer); SkipSaveBuf(buf, 2); #ifdef CHECK_STRUCT_SIZES - static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18"); + static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 106"); #endif - for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) + for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++) WriteSaveBuf<int32>(buf, m_anLocalVariables[i]); + WriteSaveBuf<int32>(buf, m_nLocalsPointer); WriteSaveBuf<bool>(buf, m_bIsActive); WriteSaveBuf<bool>(buf, m_bCondResult); WriteSaveBuf<bool>(buf, m_bIsMissionScript); @@ -2290,6 +2325,7 @@ void CRunningScript::Load(uint8*& buf) { #ifdef COMPATIBLE_SAVES SkipSaveBuf(buf, 8); + m_nId = ReadSaveBuf<int32>(buf); for (int i = 0; i < 8; i++) m_abScriptName[i] = ReadSaveBuf<char>(buf); m_nIp = ReadSaveBuf<uint32>(buf); @@ -2301,10 +2337,11 @@ void CRunningScript::Load(uint8*& buf) m_nStackPointer = ReadSaveBuf<uint16>(buf); SkipSaveBuf(buf, 2); #ifdef CHECK_STRUCT_SIZES - static_assert(NUM_LOCAL_VARS + NUM_TIMERS == 18, "Compatibility loss: NUM_LOCAL_VARS + NUM_TIMERS != 18"); + static_assert(NUM_LOCAL_VARS + 8 + NUM_TIMERS == 106, "Compatibility loss: NUM_LOCAL_VARS + 8 + NUM_TIMERS != 106"); #endif - for (int i = 0; i < NUM_LOCAL_VARS + NUM_TIMERS; i++) + for (int i = 0; i < NUM_LOCAL_VARS + 8 + NUM_TIMERS; i++) m_anLocalVariables[i] = ReadSaveBuf<int32>(buf); + m_nLocalsPointer = ReadSaveBuf<int32>(buf); m_bIsActive = ReadSaveBuf<bool>(buf); m_bCondResult = ReadSaveBuf<bool>(buf); m_bIsMissionScript = ReadSaveBuf<bool>(buf); @@ -2683,8 +2720,14 @@ void CTheScripts::CleanUpThisPed(CPed* pPed) } else { if (pPed->m_pMyVehicle->m_vehType == VEHICLE_TYPE_CAR) { - pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle); - pPed->bWanderPathAfterExitingCar = true; + if ((pPed->m_fHealth < 1.0f && !pPed->IsPedHeadAbovePos(-0.3f)) || pPed->bBodyPartJustCameOff) { + pPed->SetObjective(OBJECTIVE_LEAVE_CAR_AND_DIE, pPed->m_pMyVehicle); + pPed->bWanderPathAfterExitingCar = false; + } + else { + pPed->SetObjective(OBJECTIVE_LEAVE_CAR, pPed->m_pMyVehicle); + pPed->bWanderPathAfterExitingCar = true; + } } } } @@ -2697,6 +2740,7 @@ void CTheScripts::CleanUpThisPed(CPed* pPed) flees = true; } pPed->ClearObjective(); + pPed->SetWaitState(WAITSTATE_FALSE, nil); // third parameter is 0 TODO? pPed->bRespondsToThreats = true; pPed->bScriptObjectiveCompleted = false; pPed->bKindaStayInSamePlace = false; @@ -2741,7 +2785,7 @@ void CTheScripts::ReadObjectNamesFromScript() int32 varSpace = GetSizeOfVariableSpace(); uint32 ip = varSpace + 8; NumSaveVars = Read4BytesFromScript(&ip); - SavedVarIndices = (short*)&ScriptParams[ip]; + SavedVarIndices = (short*)&ScriptSpace[ip]; ip += 2 * NumSaveVars; NumberOfUsedObjects = Read2BytesFromScript(&ip); ip += 2; diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp index 3a03ea9b..acc84c31 100644 --- a/src/control/Script6.cpp +++ b/src/control/Script6.cpp @@ -17,6 +17,7 @@ #ifdef MISSION_REPLAY #include "GenericGameStorage.h" #endif +#include "Hud.h" #include "Messages.h" #include "Pad.h" #include "Particle.h" @@ -38,6 +39,8 @@ #include "Pickups.h" #include "Fluff.h" +// LCS: file done except TODOs + #ifdef USE_DEBUG_SCRIPT_LOADER extern const char* scriptfile; #endif @@ -86,38 +89,37 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_IN_CONTROL: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed->IsPedInControl()); return 0; } case COMMAND_SET_GENERATE_CARS_AROUND_CAMERA: CollectParameters(&m_nIp, 1); - CCarCtrl::bCarsGeneratedAroundCamera = (ScriptParams[0] != 0); + CCarCtrl::bCarsGeneratedAroundCamera = (GET_INTEGER_PARAM(0) != 0); return 0; case COMMAND_CLEAR_SMALL_PRINTS: CMessages::ClearSmallMessagesOnly(); + //CHud::ClearSmallMessages(); // TODO return 0; - /* case COMMAND_HAS_MILITARY_CRANE_COLLECTED_ALL_CARS: UpdateCompareFlag(CCranes::HaveAllCarsBeenCollectedByMilitaryCrane()); return 0; - */ case COMMAND_SET_UPSIDEDOWN_CAR_NOT_DAMAGED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; - pCar->bNotDamagedUpsideDown = (ScriptParams[1] != 0); + pCar->bNotDamagedUpsideDown = (GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_CAN_PLAYER_START_MISSION: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPlayerPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPlayerPed); - UpdateCompareFlag(pPlayerPed->IsPedInControl() || pPlayerPed->m_nPedState == PED_DRIVING); + UpdateCompareFlag(pPlayerPed->CanStartMission() || pPlayerPed->m_nPedState == PED_DRIVING); return 0; } case COMMAND_MAKE_PLAYER_SAFE_FOR_CUTSCENE: @@ -127,46 +129,46 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) AllowMissionReplay = 0; SaveGameForPause(3); #endif - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - CPad::GetPad(ScriptParams[0])->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE); + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + CPad::GetPad(GET_INTEGER_PARAM(0))->SetDisablePlayerControls(PLAYERCONTROL_CUTSCENE); pPlayerInfo->MakePlayerSafe(true); CCutsceneMgr::StartCutsceneProcessing(); return 0; } case COMMAND_USE_TEXT_COMMANDS: CollectParameters(&m_nIp, 1); - CTheScripts::UseTextCommands = (ScriptParams[0] != 0) ? 2 : 1; + CTheScripts::UseTextCommands = (GET_INTEGER_PARAM(0) != 0) ? 2 : 1; return 0; case COMMAND_SET_THREAT_FOR_PED_TYPE: CollectParameters(&m_nIp, 2); - CPedType::AddThreat(ScriptParams[0], ScriptParams[1]); + CPedType::AddThreat(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_CLEAR_THREAT_FOR_PED_TYPE: CollectParameters(&m_nIp, 2); - CPedType::RemoveThreat(ScriptParams[0], ScriptParams[1]); + CPedType::RemoveThreat(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_GET_CAR_COLOURS: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->m_currentColour1; - ScriptParams[1] = pVehicle->m_currentColour2; + SET_INTEGER_PARAM(0, pVehicle->m_currentColour1); + SET_INTEGER_PARAM(1, pVehicle->m_currentColour2); StoreParameters(&m_nIp, 2); return 0; } case COMMAND_SET_ALL_CARS_CAN_BE_DAMAGED: CollectParameters(&m_nIp, 1); - CWorld::SetAllCarsCanBeDamaged(ScriptParams[0] != 0); - if (!ScriptParams[0]) + CWorld::SetAllCarsCanBeDamaged(GET_INTEGER_PARAM(0) != 0); + if (!GET_INTEGER_PARAM(0)) CWorld::ExtinguishAllCarFiresInArea(FindPlayerCoors(), 4000.0f); return 0; case COMMAND_SET_CAR_CAN_BE_DAMAGED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - pVehicle->bCanBeDamaged = ScriptParams[1] != 0; - if (!ScriptParams[1]) + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + pVehicle->bCanBeDamaged = GET_INTEGER_PARAM(1) != 0; + if (!GET_INTEGER_PARAM(1)) pVehicle->ExtinguishCarFire(); return 0; } @@ -176,7 +178,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); CTimer::Stop(); - CGame::currLevel = (eLevelName)ScriptParams[0]; + CGame::currLevel = (eLevelName)GET_INTEGER_PARAM(0); ISLAND_LOADING_IS(LOW) { CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); @@ -192,18 +194,18 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; } case COMMAND_GET_BODY_CAST_HEALTH: - // ScriptParams[0] = CObject::nBodyCastHealth; + // SET_INTEGER_PARAM(0, CObject::nBodyCastHealth); // StoreParameters(&m_nIp, 1); return 0; */ case COMMAND_SET_CHARS_CHATTING: { CollectParameters(&m_nIp, 3); - CPed* pPed1 = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pPed2 = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed1 = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pPed2 = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pPed1 && pPed2); - pPed1->SetChat(pPed2, ScriptParams[2]); - pPed2->SetChat(pPed1, ScriptParams[2]); + pPed1->SetChat(pPed2, GET_INTEGER_PARAM(2)); + pPed2->SetChat(pPed1, GET_INTEGER_PARAM(2)); return 0; } //case COMMAND_MAKE_PLAYER_SAFE: @@ -211,9 +213,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CAR_STAYS_IN_CURRENT_LEVEL: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - if (ScriptParams[1]) + if (GET_INTEGER_PARAM(1)) pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); else pVehicle->m_nZoneLevel = LEVEL_GENERIC; @@ -222,9 +224,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CHAR_STAYS_IN_CURRENT_LEVEL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) + if (GET_INTEGER_PARAM(1)) pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); else pPed->m_nZoneLevel = LEVEL_GENERIC; @@ -234,16 +236,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_DRUNK_INPUT_DELAY: { CollectParameters(&m_nIp, 2); - assert(ScriptParams[1] < CPad::DRUNK_STEERING_BUFFER_SIZE); - CPad::GetPad(ScriptParams[0])->SetDrunkInputDelay(ScriptParams[1]); + assert(GET_INTEGER_PARAM(1) < CPad::DRUNK_STEERING_BUFFER_SIZE); + CPad::GetPad(GET_INTEGER_PARAM(0))->SetDrunkInputDelay(GET_INTEGER_PARAM(1)); return 0; } case COMMAND_SET_CHAR_MONEY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_nPedMoney = ScriptParams[1]; + pPed->m_nPedMoney = GET_INTEGER_PARAM(1); pPed->bMoneyHasBeenGivenByScript = true; return 0; } @@ -251,10 +253,10 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_OFFSET_FROM_OBJECT_IN_WORLD_COORDS: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CVector result = Multiply3x3(pObject->GetMatrix(), *(CVector*)&ScriptParams[1]) + pObject->GetPosition(); - *(CVector*)&ScriptParams[0] = result; + CVector result = Multiply3x3(pObject->GetMatrix(), GET_VECTOR_PARAM(1)) + pObject->GetPosition(); + SET_VECTOR_PARAM(0, result); StoreParameters(&m_nIp, 3); return 0; } @@ -266,34 +268,34 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; case COMMAND_REGISTER_AMBULANCE_LEVEL: CollectParameters(&m_nIp, 1); - CStats::RegisterLevelAmbulanceMission(ScriptParams[0]); + CStats::RegisterLevelAmbulanceMission(GET_INTEGER_PARAM(0)); return 0; case COMMAND_REGISTER_FIRE_EXTINGUISHED: CStats::AnotherFireExtinguished(); return 0; case COMMAND_TURN_PHONE_ON: CollectParameters(&m_nIp, 1); - gPhoneInfo.m_aPhones[ScriptParams[0]].m_nState = PHONE_STATE_9; + gPhoneInfo.m_aPhones[GET_INTEGER_PARAM(0)].m_nState = PHONE_STATE_9; return 0; /* case COMMAND_REGISTER_LONGEST_DODO_FLIGHT: CollectParameters(&m_nIp, 1); - CStats::RegisterLongestFlightInDodo(ScriptParams[0]); + CStats::RegisterLongestFlightInDodo(GET_INTEGER_PARAM(0)); return 0; */ case COMMAND_GET_OFFSET_FROM_CAR_IN_WORLD_COORDS: { CollectParameters(&m_nIp, 4); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVector result = Multiply3x3(pVehicle->GetMatrix(), *(CVector*)&ScriptParams[1]) + pVehicle->GetPosition(); - *(CVector*)&ScriptParams[0] = result; + CVector result = Multiply3x3(pVehicle->GetMatrix(), GET_VECTOR_PARAM(1)) + pVehicle->GetPosition(); + SET_VECTOR_PARAM(0, result); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_SET_TOTAL_NUMBER_OF_KILL_FRENZIES: CollectParameters(&m_nIp, 1); - CStats::SetTotalNumberKillFrenzies(ScriptParams[0]); + CStats::SetTotalNumberKillFrenzies(GET_INTEGER_PARAM(0)); return 0; case COMMAND_BLOW_UP_RC_BUGGY: CWorld::Players[CWorld::PlayerInFocus].BlowUpRCBuggy(true); @@ -301,7 +303,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) /* case COMMAND_REMOVE_CAR_FROM_CHASE: CollectParameters(&m_nIp, 1); - CRecordDataForChase::RemoveCarFromChase(ScriptParams[0]); + CRecordDataForChase::RemoveCarFromChase(GET_INTEGER_PARAM(0)); return 0; */ case COMMAND_IS_FRENCH_GAME: @@ -312,57 +314,57 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; case COMMAND_CLEAR_MISSION_AUDIO: CollectParameters(&m_nIp, 1); - DMAudio.ClearMissionAudio(ScriptParams[0] - 1); + DMAudio.ClearMissionAudio(GET_INTEGER_PARAM(0) - 1); return 0; /* case COMMAND_SET_FADE_IN_AFTER_NEXT_ARREST: CollectParameters(&m_nIp, 1); - CRestart::bFadeInAfterNextArrest = !!ScriptParams[0]; + CRestart::bFadeInAfterNextArrest = !!GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_FADE_IN_AFTER_NEXT_DEATH: CollectParameters(&m_nIp, 1); - CRestart::bFadeInAfterNextDeath = !!ScriptParams[0]; + CRestart::bFadeInAfterNextDeath = !!GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_GANG_PED_MODEL_PREFERENCE: CollectParameters(&m_nIp, 2); - CGangs::SetGangPedModelOverride(ScriptParams[0], ScriptParams[1]); + CGangs::SetGangPedModelOverride(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; */ case COMMAND_SET_CHAR_USE_PEDNODE_SEEK: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) + if (GET_INTEGER_PARAM(1)) pPed->m_pNextPathNode = nil; - pPed->bUsePedNodeSeek = !!ScriptParams[1]; + pPed->bUsePedNodeSeek = !!GET_INTEGER_PARAM(1); return 0; } /* case COMMAND_SWITCH_VEHICLE_WEAPONS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bGunSwitchedOff = !ScriptParams[1]; + pVehicle->bGunSwitchedOff = !GET_INTEGER_PARAM(1); return 0; } + */ case COMMAND_SET_GET_OUT_OF_JAIL_FREE: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_bGetOutOfJailFree = !!ScriptParams[1]; + CWorld::Players[GET_INTEGER_PARAM(0)].m_bGetOutOfJailFree = !!GET_INTEGER_PARAM(1); return 0; - */ case COMMAND_SET_FREE_HEALTH_CARE: CollectParameters(&m_nIp, 2); - CWorld::Players[ScriptParams[0]].m_bGetOutOfHospitalFree = !!ScriptParams[1]; + CWorld::Players[GET_INTEGER_PARAM(0)].m_bGetOutOfHospitalFree = !!GET_INTEGER_PARAM(1); return 0; /* case COMMAND_IS_CAR_DOOR_CLOSED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(!pVehicle->IsDoorMissing((eDoors)ScriptParams[1]) && pVehicle->IsDoorClosed((eDoors)ScriptParams[1])); + UpdateCompareFlag(!pVehicle->IsDoorMissing((eDoors)GET_INTEGER_PARAM(1)) && pVehicle->IsDoorClosed((eDoors)GET_INTEGER_PARAM(1))); return 0; } */ @@ -373,18 +375,18 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CollectParameters(&m_nIp, 1); if (CTheScripts::NumberOfExclusiveMissionScripts > 0) { - if (ScriptParams[0] < UINT16_MAX - 1) + if (GET_INTEGER_PARAM(0) < UINT16_MAX - 1) return 0; - ScriptParams[0] = UINT16_MAX - ScriptParams[0]; + SET_INTEGER_PARAM(0, UINT16_MAX - GET_INTEGER_PARAM(0)); } #ifdef MISSION_REPLAY - missionRetryScriptIndex = ScriptParams[0]; + missionRetryScriptIndex = GET_INTEGER_PARAM(0); if (missionRetryScriptIndex == 19) CStats::LastMissionPassedName[0] = '\0'; #endif CTimer::Suspend(); - int offset = CTheScripts::MultiScriptArray[ScriptParams[0]] + 8; - int size = CTheScripts::MultiScriptArray[ScriptParams[0] + 1] - CTheScripts::MultiScriptArray[ScriptParams[0]]; + int offset = CTheScripts::MultiScriptArray[GET_INTEGER_PARAM(0)] + 8; + int size = CTheScripts::MultiScriptArray[GET_INTEGER_PARAM(0) + 1] - CTheScripts::MultiScriptArray[GET_INTEGER_PARAM(0)]; if (size <= 0) size = CTheScripts::LargestMissionScriptSize; CFileMgr::Seek(gScriptsFile, offset, 0); @@ -401,20 +403,20 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_OBJECT_DRAW_LAST: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bDrawLast = !!ScriptParams[1]; + pObject->bDrawLast = !!GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_AMMO_IN_PLAYER_WEAPON: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - ScriptParams[0] = 0; + SET_INTEGER_PARAM(0, 0); for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - if (pPed->GetWeapon(i).m_eWeaponType == (eWeaponType)ScriptParams[1]) - ScriptParams[0] = pPed->GetWeapon(i).m_nAmmoTotal; + if (pPed->GetWeapon(i).m_eWeaponType == (eWeaponType)GET_INTEGER_PARAM(1)) + SET_INTEGER_PARAM(0, pPed->GetWeapon(i).m_nAmmoTotal); } StoreParameters(&m_nIp, 1); return 0; @@ -423,83 +425,69 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_AMMO_IN_CHAR_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CWeapon* pWeaponSlot = &pPed->m_weapons[ScriptParams[1]]; - if (pWeaponSlot->m_eWeaponType == (eWeaponType)ScriptParams[1]) - ScriptParams[0] = pWeaponSlot->m_nAmmoTotal; + CWeapon* pWeaponSlot = &pPed->m_weapons[GET_INTEGER_PARAM(1)]; + if (pWeaponSlot->m_eWeaponType == (eWeaponType)GET_INTEGER_PARAM(1)) + SET_INTEGER_PARAM(0, pWeaponSlot->m_nAmmoTotal); else - ScriptParams[0] = 0; + SET_INTEGER_PARAM(0, 0); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_REGISTER_KILL_FRENZY_PASSED: CStats::AnotherKillFrenzyPassed(); return 0; + */ case COMMAND_SET_CHAR_SAY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - switch (ScriptParams[1]) { - case SCRIPT_SOUND_CHUNKY_RUN_SHOUT: - pPed->Say(SOUND_PED_FLEE_RUN); - break; - case SCRIPT_SOUND_SECURITY_GUARD_AWAY_SHOUT: - pPed->Say(SOUND_PED_FLEE_RUN); - break; - case SCRIPT_SOUND_SWAT_PED_SHOUT: - pPed->Say(SOUND_PED_PURSUIT_SWAT); - break; - case SCRIPT_SOUND_AMMUNATION_CHAT_1: - pPed->Say(SOUND_AMMUNATION_WELCOME_1); - break; - case SCRIPT_SOUND_AMMUNATION_CHAT_2: - pPed->Say(SOUND_AMMUNATION_WELCOME_2); - break; - case SCRIPT_SOUND_AMMUNATION_CHAT_3: - pPed->Say(SOUND_AMMUNATION_WELCOME_3); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + switch (GET_INTEGER_PARAM(1)) { + case 15: + pPed->Say(0x93); // TODO break; default: break; } return 0; } - */ case COMMAND_SET_NEAR_CLIP: CollectParameters(&m_nIp, 1); - TheCamera.SetNearClipScript(*(float*)&ScriptParams[0]); + TheCamera.SetNearClipScript(GET_FLOAT_PARAM(0)); return 0; case COMMAND_SET_RADIO_CHANNEL: CollectParameters(&m_nIp, 2); - DMAudio.SetRadioChannel(ScriptParams[0], ScriptParams[1]); + // if (base::cSingleton<cCustomSoundTrack>::Instance()->unk()) - TODO on PS2, but it's not on mobile + DMAudio.SetRadioChannel(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; /* case COMMAND_OVERRIDE_HOSPITAL_LEVEL: CollectParameters(&m_nIp, 1); - CRestart::OverrideHospitalLevel = ScriptParams[0]; + CRestart::OverrideHospitalLevel = GET_INTEGER_PARAM(0); return 0; case COMMAND_OVERRIDE_POLICE_STATION_LEVEL: CollectParameters(&m_nIp, 1); - CRestart::OverridePoliceStationLevel = ScriptParams[0]; + CRestart::OverridePoliceStationLevel = GET_INTEGER_PARAM(0); return 0; case COMMAND_FORCE_RAIN: CollectParameters(&m_nIp, 1); - CWeather::bScriptsForceRain = !!ScriptParams[0]; + CWeather::bScriptsForceRain = !!GET_INTEGER_PARAM(0); return 0; + */ case COMMAND_DOES_GARAGE_CONTAIN_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); - UpdateCompareFlag(CGarages::IsThisCarWithinGarageArea(ScriptParams[0], pVehicle)); + UpdateCompareFlag(CGarages::IsThisCarWithinGarageArea(GET_INTEGER_PARAM(0), pVehicle)); return 0; } - */ case COMMAND_SET_CAR_TRACTION: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); - float fTraction = *(float*)&ScriptParams[1]; + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + float fTraction = GET_FLOAT_PARAM(1); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR || pVehicle->m_vehType == VEHICLE_TYPE_BIKE); if (pVehicle->m_vehType == VEHICLE_TYPE_CAR) ((CAutomobile*)pVehicle)->m_fTraction = fTraction; @@ -517,32 +505,32 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_CONVERT_METRES_TO_FEET: { CollectParameters(&m_nIp, 1); - float fMeterValue = *(float*)&ScriptParams[0]; + float fMeterValue = GET_FLOAT_PARAM(0); float fFeetValue = fMeterValue / METERS_IN_FOOT; - *(float*)&ScriptParams[0] = fFeetValue; + SET_FLOAT_PARAM(0, fFeetValue); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_MARK_ROADS_BETWEEN_LEVELS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.MarkRoadsBetweenLevelsInArea(infX, supX, infY, supY, infZ, supZ); return 0; @@ -550,23 +538,23 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_MARK_PED_ROADS_BETWEEN_LEVELS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } ThePaths.PedMarkRoadsBetweenLevelsInArea(infX, supX, infY, supY, infZ, supZ); return 0; @@ -574,98 +562,112 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CAR_AVOID_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_bStayInCurrentLevel = !!ScriptParams[1]; + pVehicle->AutoPilot.m_bStayInCurrentLevel = !!GET_INTEGER_PARAM(1); return 0; } /* case COMMAND_SET_CHAR_AVOID_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pPed); // not implemented return 0; } case COMMAND_IS_THREAT_FOR_PED_TYPE: CollectParameters(&m_nIp, 2); - UpdateCompareFlag(CPedType::IsThreat(ScriptParams[0], ScriptParams[1])); + UpdateCompareFlag(CPedType::IsThreat(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1))); return 0; */ case COMMAND_CLEAR_AREA_OF_CHARS: { CollectParameters(&m_nIp, 6); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float infZ = *(float*)&ScriptParams[2]; - float supX = *(float*)&ScriptParams[3]; - float supY = *(float*)&ScriptParams[4]; - float supZ = *(float*)&ScriptParams[5]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float infZ = GET_FLOAT_PARAM(2); + float supX = GET_FLOAT_PARAM(3); + float supY = GET_FLOAT_PARAM(4); + float supZ = GET_FLOAT_PARAM(5); if (infX > supX) { - infX = *(float*)&ScriptParams[3]; - supX = *(float*)&ScriptParams[0]; + infX = GET_FLOAT_PARAM(3); + supX = GET_FLOAT_PARAM(0); } if (infY > supY) { - infY = *(float*)&ScriptParams[4]; - supY = *(float*)&ScriptParams[1]; + infY = GET_FLOAT_PARAM(4); + supY = GET_FLOAT_PARAM(1); } if (infZ > supZ) { - infZ = *(float*)&ScriptParams[5]; - supZ = *(float*)&ScriptParams[2]; + infZ = GET_FLOAT_PARAM(5); + supZ = GET_FLOAT_PARAM(2); } CWorld::ClearPedsFromArea(infX, infY, infZ, supX, supY, supZ); return 0; } case COMMAND_SET_TOTAL_NUMBER_OF_MISSIONS: CollectParameters(&m_nIp, 1); - CStats::SetTotalNumberMissions(CGame::germanGame ? ScriptParams[0] - 2 : ScriptParams[0]); + CStats::SetTotalNumberMissions(CGame::germanGame ? GET_INTEGER_PARAM(0) - 2 : GET_INTEGER_PARAM(0)); return 0; case COMMAND_CONVERT_METRES_TO_FEET_INT: CollectParameters(&m_nIp, 1); - ScriptParams[0] *= FEET_IN_METER; + GET_INTEGER_PARAM(0) *= FEET_IN_METER; StoreParameters(&m_nIp, 1); return 0; case COMMAND_REGISTER_FASTEST_TIME: CollectParameters(&m_nIp, 2); - CStats::RegisterFastestTime(ScriptParams[0], ScriptParams[1]); + CStats::RegisterFastestTime(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_REGISTER_HIGHEST_SCORE: CollectParameters(&m_nIp, 2); - CStats::RegisterHighestScore(ScriptParams[0], ScriptParams[1]); + CStats::RegisterHighestScore(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; - //case COMMAND_WARP_CHAR_INTO_CAR_AS_PASSENGER: + case COMMAND_WARP_CHAR_INTO_CAR_AS_PASSENGER: + { + CollectParameters(&m_nIp, 3); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + script_assert(pPed); + script_assert(pVehicle); + if (GET_INTEGER_PARAM(2) < 0) + pPed->WarpPedIntoCarAsPassenger(pVehicle, GET_INTEGER_PARAM(2)); + else { + script_assert(GET_INTEGER_PARAM(1) >= 0 && GET_INTEGER_PARAM(1) < ARRAY_SIZE(pVehicle->pPassengers)); + pPed->WarpPedIntoCarAsPassenger(pVehicle, GET_INTEGER_PARAM(2)); + } + return 0; + + } case COMMAND_IS_CAR_PASSENGER_SEAT_FREE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - UpdateCompareFlag(ScriptParams[1] < pVehicle->m_nNumMaxPassengers && pVehicle->pPassengers[ScriptParams[1]] == nil); + UpdateCompareFlag(GET_INTEGER_PARAM(1) < pVehicle->m_nNumMaxPassengers && pVehicle->pPassengers[GET_INTEGER_PARAM(1)] == nil); return 0; } - /* case COMMAND_GET_CHAR_IN_CAR_PASSENGER_SEAT: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - script_assert(ScriptParams[1] >= 0 && ScriptParams[1] < ARRAY_SIZE(pVehicle->pPassengers)); - CPed* pPassenger = pVehicle->pPassengers[ScriptParams[1]]; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPassenger); + script_assert(GET_INTEGER_PARAM(1) >= 0 && GET_INTEGER_PARAM(1) < ARRAY_SIZE(pVehicle->pPassengers)); + CPed* pPassenger = pVehicle->pPassengers[GET_INTEGER_PARAM(1)]; + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPassenger)); StoreParameters(&m_nIp, 1); return 0; } - */ case COMMAND_SET_CHAR_IS_CHRIS_CRIMINAL: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bChrisCriminal = !!ScriptParams[1]; + pPed->bChrisCriminal = !!GET_INTEGER_PARAM(1); return 0; } case COMMAND_START_CREDITS: - CCredits::Start(); + CollectParameters(&m_nIp, 1); + CCredits::Start(); // TODO: CCredits::Start(GET_INTEGER_PARAM(0)) return 0; case COMMAND_STOP_CREDITS: CCredits::Stop(); @@ -675,16 +677,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) return 0; case COMMAND_CREATE_SINGLE_PARTICLE: CollectParameters(&m_nIp, 8); - CParticle::AddParticle((tParticleType)ScriptParams[0], *(CVector*)&ScriptParams[1], - *(CVector*)&ScriptParams[4], nil, *(float*)&ScriptParams[7], 0, 0, 0, 0); + CParticle::AddParticle((tParticleType)GET_INTEGER_PARAM(0), GET_VECTOR_PARAM(1), + GET_VECTOR_PARAM(4), nil, GET_FLOAT_PARAM(7), 0, 0, 0, 0); return 0; /* case COMMAND_SET_CHAR_IGNORE_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) + if (GET_INTEGER_PARAM(1)) pPed->m_nZoneLevel = LEVEL_IGNORE; else pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); @@ -693,11 +695,11 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_CHASE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CRecordDataForChase::TurnChaseCarIntoScriptCar(ScriptParams[0]); - ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); + CVehicle* pVehicle = CRecordDataForChase::TurnChaseCarIntoScriptCar(GET_INTEGER_PARAM(0)); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CAR); return 0; } case COMMAND_START_BOAT_FOAM_ANIMATION: @@ -706,7 +708,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_UPDATE_BOAT_FOAM_ANIMATION: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CSpecialParticleStuff::UpdateBoatFoamAnimation(&pObject->GetMatrix()); return 0; @@ -714,12 +716,12 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) */ case COMMAND_SET_MUSIC_DOES_FADE: CollectParameters(&m_nIp, 1); - TheCamera.m_bIgnoreFadingStuffForMusic = (ScriptParams[0] == 0); + TheCamera.m_bIgnoreFadingStuffForMusic = (GET_INTEGER_PARAM(0) == 0); return 0; /* case COMMAND_SET_INTRO_IS_PLAYING: CollectParameters(&m_nIp, 1); - if (ScriptParams[0]) { + if (GET_INTEGER_PARAM(0)) { CGame::playingIntro = true; CStreaming::RemoveCurrentZonesModels(); } else { @@ -731,17 +733,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CStreaming::LoadAllRequestedModels(false); } return 0; - */ case COMMAND_SET_PLAYER_HOOKER: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - if (ScriptParams[1] < 0) { + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + if (GET_INTEGER_PARAM(1) < 0) { pPlayerInfo->m_pHooker = nil; pPlayerInfo->m_nNextSexFrequencyUpdateTime = 0; pPlayerInfo->m_nNextSexMoneyUpdateTime = 0; } else { - CPed* pHooker = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pHooker = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pHooker); pPlayerInfo->m_pHooker = (CCivilianPed*)pHooker; pPlayerInfo->m_nSexFrequency = 1000; @@ -750,8 +751,10 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) } return 0; } + */ case COMMAND_PLAY_END_OF_GAME_TUNE: - DMAudio.PlayPreloadedCutSceneMusic(); + DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND); + DMAudio.PlayFrontEndTrack(STREAMED_SOUND_CUTSCENE_FINALE, 1); // third parameter is 1 return 0; case COMMAND_STOP_END_OF_GAME_TUNE: DMAudio.StopCutSceneMusic(); @@ -760,25 +763,25 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_GET_CAR_MODEL: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - ScriptParams[0] = pVehicle->GetModelIndex(); + SET_INTEGER_PARAM(0, pVehicle->GetModelIndex()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_PLAYER_SITTING_IN_CAR: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR && pPed->m_pMyVehicle == pVehicle); return 0; } case COMMAND_IS_PLAYER_SITTING_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR); return 0; @@ -786,7 +789,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) /* case COMMAND_SET_SCRIPT_FIRE_AUDIO: CollectParameters(&m_nIp, 2); - gFireManager.SetScriptFireAudio(ScriptParams[0], !!ScriptParams[1]); + gFireManager.SetScriptFireAudio(GET_INTEGER_PARAM(0), !!GET_INTEGER_PARAM(1)); return 0; */ case COMMAND_ARE_ANY_CAR_CHEATS_ACTIVATED: @@ -795,16 +798,16 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_SET_CHAR_SUFFERS_CRITICAL_HITS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bNoCriticalHits = (ScriptParams[1] == 0); + pPed->bNoCriticalHits = (GET_INTEGER_PARAM(1) == 0); return 0; } /* case COMMAND_IS_PLAYER_LIFTING_A_PHONE: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_MAKE_CALL); return 0; @@ -813,9 +816,9 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_SITTING_IN_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR && pPed->m_pMyVehicle == pVehicle); return 0; @@ -823,7 +826,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_SITTING_IN_ANY_CAR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->GetPedState() == PED_DRIVING && pPed->m_objective != OBJECTIVE_LEAVE_CAR); return 0; @@ -831,7 +834,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_PLAYER_ON_FOOT: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(!pPed->bInVehicle && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); @@ -840,7 +843,7 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) case COMMAND_IS_CHAR_ON_FOOT: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(!pPed->bInVehicle && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_PASSENGER && pPed->m_objective != OBJECTIVE_ENTER_CAR_AS_DRIVER); @@ -860,7 +863,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_LOAD_COLLISION_WITH_SCREEN: CollectParameters(&m_nIp, 1); CTimer::Stop(); - CGame::currLevel = (eLevelName)ScriptParams[0]; + CGame::currLevel = (eLevelName)GET_INTEGER_PARAM(0); if (CGame::currLevel != CCollision::ms_collisionInMemory) { ISLAND_LOADING_IS(LOW) { @@ -904,9 +907,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_CAR_IGNORE_LEVEL_TRANSITIONS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - if (ScriptParams[1]) + if (GET_INTEGER_PARAM(1)) pVehicle->m_nZoneLevel = LEVEL_IGNORE; else pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); @@ -915,61 +918,55 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_MAKE_CRAIGS_CAR_A_BIT_STRONGER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); script_assert(pVehicle->m_vehType == VEHICLE_TYPE_CAR); CAutomobile* pCar = (CAutomobile*)pVehicle; - pCar->bMoreResistantToDamage = ScriptParams[1]; + pCar->bMoreResistantToDamage = GET_INTEGER_PARAM(1); return 0; } */ case COMMAND_SET_JAMES_CAR_ON_PATH_TO_PLAYER: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CCarCtrl::JoinCarWithRoadSystemGotoCoors(pVehicle, FindPlayerCoors(), false); return 0; } case COMMAND_LOAD_END_OF_GAME_TUNE: - DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE); - printf("Start preload end of game audio\n"); - DMAudio.PreloadCutSceneMusic(STREAMED_SOUND_CUTSCENE_FINALE); - printf("End preload end of game audio\n"); return 0; - /* case COMMAND_ENABLE_PLAYER_CONTROL_CAMERA: CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CAMERA); return 0; - */ case COMMAND_SET_OBJECT_ROTATION: { CollectParameters(&m_nIp, 4); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); CWorld::Remove(pObject); pObject->SetOrientation( - DEGTORAD(*(float*)&ScriptParams[1]), - DEGTORAD(*(float*)&ScriptParams[2]), - DEGTORAD(*(float*)&ScriptParams[3])); + DEGTORAD(GET_FLOAT_PARAM(1)), + DEGTORAD(GET_FLOAT_PARAM(2)), + DEGTORAD(GET_FLOAT_PARAM(3))); pObject->GetMatrix().UpdateRW(); pObject->UpdateRwFrame(); CWorld::Add(pObject); return 0; } case COMMAND_GET_DEBUG_CAMERA_COORDINATES: - *(CVector*)&ScriptParams[0] = TheCamera.Cams[2].Source; + SET_VECTOR_PARAM(0, TheCamera.Cams[2].Source); StoreParameters(&m_nIp, 3); return 0; /* case COMMAND_GET_DEBUG_CAMERA_FRONT_VECTOR: - *(CVector*)&ScriptParams[0] = TheCamera.Cams[2].Front; + SET_VECTOR_PARAM(0, TheCamera.Cams[2].Front); StoreParameters(&m_nIp, 3); return 0; case COMMAND_IS_PLAYER_TARGETTING_ANY_CHAR: { CollectParameters(&m_nIp, 1); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); CEntity* pTarget = pPed->m_pPointGunAt; UpdateCompareFlag(pTarget && pTarget->IsPed()); @@ -979,13 +976,13 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_PLAYER_TARGETTING_CHAR: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CPed* pTestedPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTestedPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTestedPed); CEntity* pTarget = pPed->m_pPointGunAt; bool bTargetting = pTarget && pTarget->IsPed() && pTarget == pTestedPed; - // PC shit +#ifdef GTA_PC static int nCounter = 0; nCounter = Max(0, nCounter - 1); if (!pPed->GetWeapon()->IsTypeMelee() && !bTargetting) { @@ -1012,22 +1009,50 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) } } } +#endif UpdateCompareFlag(bTargetting); return 0; } - /* case COMMAND_IS_PLAYER_TARGETTING_OBJECT: { CollectParameters(&m_nIp, 2); - CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPlayerPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CObject* pTestedObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pTestedObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTestedObject); CEntity* pTarget = pPed->m_pPointGunAt; - UpdateCompareFlag(pTarget && pTarget->IsObject() && pTarget == pTestedObject); + bool bTargetting = pTarget && pTarget->IsObject() && pTarget == pTestedObject; +#ifdef GTA_PC // we will never know if section is real + static int nCounter = 0; + nCounter = Max(0, nCounter - 1); + if (!pPed->GetWeapon()->IsTypeMelee() && !bTargetting) { + if ((pTestedObject->GetPosition() - TheCamera.GetPosition()).Magnitude() < 10.0f) { + CVector vTestedPos(pTestedObject->GetPosition().x, pTestedObject->GetPosition().y, pTestedObject->GetPosition().z); + CVector vScreenPos; + float w, h; + if (CSprite::CalcScreenCoors(vTestedPos, &vScreenPos, &w, &h, false)) { + CVector2D vCrosshairPosition(CCamera::m_f3rdPersonCHairMultX * RsGlobal.maximumWidth, CCamera::m_f3rdPersonCHairMultY * RsGlobal.maximumHeight); + float fScreenDistance = ((CVector2D)vScreenPos - vCrosshairPosition).Magnitude(); + if (SCREEN_STRETCH_X(0.45f) > fScreenDistance / w) { + CColPoint point; + CEntity* entity; + if (!CWorld::ProcessLineOfSight(TheCamera.GetPosition() + 2.0f * TheCamera.GetForward(), + vTestedPos, point, entity, true, true, true, true, true, false) || + entity == pTestedObject) { + nCounter += 2; + if (nCounter > 20) { + bTargetting = true; + nCounter = 20; + } + } + } + } + } + } + UpdateCompareFlag(bTargetting); +#endif return 0; } - */ case COMMAND_TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME: { CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); @@ -1049,10 +1074,10 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = GET_FLOAT_PARAM(0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = GET_FLOAT_PARAM(1); CollectParameters(&m_nIp, 1); - CMessages::InsertNumberInString(text, ScriptParams[0], -1, -1, -1, -1, -1, + CMessages::InsertNumberInString(text, GET_INTEGER_PARAM(0), -1, -1, -1, -1, -1, CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame++].m_Text); return 0; } @@ -1060,10 +1085,10 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { CollectParameters(&m_nIp, 2); wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = *(float*)&ScriptParams[0]; - CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = *(float*)&ScriptParams[1]; + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtX = GET_FLOAT_PARAM(0); + CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame].m_fAtY = GET_FLOAT_PARAM(1); CollectParameters(&m_nIp, 2); - CMessages::InsertNumberInString(text, ScriptParams[0], ScriptParams[1], -1, -1, -1, -1, + CMessages::InsertNumberInString(text, GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1), -1, -1, -1, -1, CTheScripts::IntroTextLines[CTheScripts::NumberOfIntroTextLinesThisFrame++].m_Text); return 0; } @@ -1075,11 +1100,11 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) return 0; /* CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float range = *(float*)&ScriptParams[3]; - int mi = ScriptParams[4] < 0 ? CTheScripts::UsedObjectArray[-ScriptParams[4]].index : ScriptParams[4]; + float range = GET_FLOAT_PARAM(3); + int mi = GET_INTEGER_PARAM(4) < 0 ? CTheScripts::UsedObjectArray[-GET_INTEGER_PARAM(4)].index : GET_INTEGER_PARAM(4); int16 total; CEntity* apEntities[16]; CWorld::FindObjectsOfTypeInRange(mi, pos, range, true, &total, 16, apEntities, false, false, false, true, true); @@ -1111,9 +1136,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) script_assert(pClosestEntity->IsObject()); CObject* pObject = (CObject*)pClosestEntity; pObject->ObjectCreatedBy = MISSION_OBJECT; - ScriptParams[0] = CPools::GetObjectPool()->GetIndex(pObject); + SET_INTEGER_PARAM(0, CPools::GetObjectPool()->GetIndex(pObject)); } else { - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); } StoreParameters(&m_nIp, 1); return 0; @@ -1123,11 +1148,11 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_PLACE_OBJECT_RELATIVE_TO_OBJECT: { CollectParameters(&m_nIp, 5); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - CObject* pTarget = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject* pTarget = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTarget); - CVector offset = *(CVector*)&ScriptParams[2]; + CVector offset = GET_VECTOR_PARAM(2); CPhysical::PlacePhysicalRelativeToOtherPhysical(pTarget, pObject, offset); return 0; } @@ -1135,79 +1160,81 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_ALL_OCCUPANTS_OF_CAR_LEAVE_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CCarAI::TellOccupantsToLeaveCar(pVehicle); return 0; } case COMMAND_SET_INTERPOLATION_PARAMETERS: CollectParameters(&m_nIp, 2); - TheCamera.SetParametersForScriptInterpolation(*(float*)&ScriptParams[0], 100.0f - *(float*)&ScriptParams[0], ScriptParams[1]); + TheCamera.SetParametersForScriptInterpolation(GET_FLOAT_PARAM(0), 100.0f - GET_FLOAT_PARAM(0), GET_INTEGER_PARAM(1)); return 0; /* case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING_TOWARDS_POINT: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float destX = *(float*)&ScriptParams[3]; - float destY = *(float*)&ScriptParams[4]; + float destX = GET_FLOAT_PARAM(3); + float destY = GET_FLOAT_PARAM(4); int32 nid = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true); CPathNode* pNode = &ThePaths.m_pathNodes[nid]; - *(CVector*)&ScriptParams[0] = pNode->GetPosition(); - *(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, true); + SET_VECTOR_PARAM(0, pNode->GetPosition()); + SET_FLOAT_PARAM(3, ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, true)); StoreParameters(&m_nIp, 4); return 0; } case COMMAND_GET_CLOSEST_CAR_NODE_WITH_HEADING_AWAY_POINT: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - float destX = *(float*)&ScriptParams[3]; - float destY = *(float*)&ScriptParams[4]; + float destX = GET_FLOAT_PARAM(3); + float destY = GET_FLOAT_PARAM(4); int32 nid = ThePaths.FindNodeClosestToCoors(pos, 0, 999999.9f, true, true); CPathNode* pNode = &ThePaths.m_pathNodes[nid]; - *(CVector*)&ScriptParams[0] = pNode->GetPosition(); - *(float*)&ScriptParams[3] = ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, false); + SET_VECTOR_PARAM(0, pNode->GetPosition()); + SET_FLOAT_PARAM(3, ThePaths.FindNodeOrientationForCarPlacementFacingDestination(nid, destX, destY, false)); StoreParameters(&m_nIp, 4); return 0; } */ case COMMAND_GET_DEBUG_CAMERA_POINT_AT: - *(CVector*)&ScriptParams[0] = TheCamera.Cams[2].Source + TheCamera.Cams[2].Front; + SET_VECTOR_PARAM(0, TheCamera.Cams[2].Source + TheCamera.Cams[2].Front); StoreParameters(&m_nIp, 3); return 0; case COMMAND_ATTACH_CHAR_TO_CAR: { CollectParameters(&m_nIp, 8); - CPed *pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); - pPed->AttachPedToEntity(pVehicle, *(CVector*)&ScriptParams[2], ScriptParams[5], DEGTORAD(*(float*)&ScriptParams[6]), (eWeaponType)ScriptParams[7]); + CPed *pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + pPed->AttachPedToEntity(pVehicle, GET_VECTOR_PARAM(2), GET_INTEGER_PARAM(5), DEGTORAD(GET_FLOAT_PARAM(6)), (eWeaponType)GET_INTEGER_PARAM(7)); return 0; } case COMMAND_DETACH_CHAR_FROM_CAR: { CollectParameters(&m_nIp, 1); - CPed *pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - if (pPed && pPed->m_attachedTo) + CPed *pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (pPed && pPed->m_attachedTo) { pPed->DettachPedFromEntity(); + pPed->bIsAimingGun = false; + } return 0; } case COMMAND_SET_CAR_CHANGE_LANE: // for some reason changed in SA { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_bStayInFastLane = !ScriptParams[1]; + pVehicle->AutoPilot.m_bStayInFastLane = !GET_INTEGER_PARAM(1); return 0; } case COMMAND_CLEAR_CHAR_LAST_WEAPON_DAMAGE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); if (pPed) pPed->m_lastWepDam = -1; else @@ -1217,7 +1244,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_CLEAR_CAR_LAST_WEAPON_DAMAGE: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle) pVehicle->m_nLastWeaponDamage = -1; else @@ -1229,10 +1256,10 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) CollectParameters(&m_nIp, 9); int ped_handle = -1; CVector pos = FindPlayerCoors(); - float x1 = *(float*)&ScriptParams[0]; - float y1 = *(float*)&ScriptParams[1]; - float x2 = *(float*)&ScriptParams[2]; - float y2 = *(float*)&ScriptParams[3]; + float x1 = GET_FLOAT_PARAM(0); + float y1 = GET_FLOAT_PARAM(1); + float x2 = GET_FLOAT_PARAM(2); + float y2 = GET_FLOAT_PARAM(3); int i = CPools::GetPedPool()->GetSize(); while (--i && ped_handle == -1) { CPed* pPed = CPools::GetPedPool()->GetSlot(i); @@ -1242,7 +1269,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) continue; if (pPed->m_nPedType != PEDTYPE_COP) continue; - if (!ThisIsAValidRandomCop(pPed->GetModelIndex(), ScriptParams[4], ScriptParams[5], ScriptParams[6], ScriptParams[7], ScriptParams[8])) + if (!ThisIsAValidRandomCop(pPed->GetModelIndex(), GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8))) continue; if (pPed->CharCreatedBy != RANDOM_CHAR) continue; @@ -1268,7 +1295,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR); } - ScriptParams[0] = ped_handle; + SET_INTEGER_PARAM(0, ped_handle); StoreParameters(&m_nIp, 1); return 0; } @@ -1316,7 +1343,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR); } - ScriptParams[0] = ped_handle; + SET_INTEGER_PARAM(0, ped_handle); StoreParameters(&m_nIp, 1); return 0; } @@ -1324,9 +1351,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_CHAR_OBJ_FLEE_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_FLEE_CAR, pVehicle); @@ -1335,20 +1362,20 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_GET_DRIVER_OF_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); CPed* pDriver = pVehicle->pDriver; if (pDriver) - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pDriver); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pDriver)); else - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_NUMBER_OF_FOLLOWERS: { CollectParameters(&m_nIp, 1); - CPed* pLeader = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pLeader = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pLeader); int total = 0; int i = CPools::GetPedPool()->GetSize(); @@ -1359,34 +1386,34 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) if (pPed->m_leader == pLeader) total++; } - ScriptParams[0] = total; + SET_INTEGER_PARAM(0, total); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GIVE_REMOTE_CONTROLLED_MODEL_TO_PLAYER: { CollectParameters(&m_nIp, 6); - CVector pos = *(CVector*)&ScriptParams[1]; + CVector pos = GET_VECTOR_PARAM(1); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(*(float*)&ScriptParams[4]), ScriptParams[5]); + CRemote::GivePlayerRemoteControlledCar(pos.x, pos.y, pos.z, DEGTORAD(GET_FLOAT_PARAM(4)), GET_INTEGER_PARAM(5)); return 0; } case COMMAND_GET_CURRENT_PLAYER_WEAPON: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - ScriptParams[0] = pPed->GetWeapon()->m_eWeaponType; + SET_INTEGER_PARAM(0, pPed->GetWeapon()->m_eWeaponType); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_CURRENT_CHAR_WEAPON: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->GetWeapon()->m_eWeaponType; + SET_INTEGER_PARAM(0, pPed->GetWeapon()->m_eWeaponType); StoreParameters(&m_nIp, 1); return 0; } @@ -1401,36 +1428,36 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_SET_CAR_TEMP_ACTION: { CollectParameters(&m_nIp, 3); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_nTempAction = (uint8)ScriptParams[1]; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[2]; + pVehicle->AutoPilot.m_nTempAction = (uint8)GET_INTEGER_PARAM(1); + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(2); return 0; } /* case COMMAND_SET_CAR_HANDBRAKE_TURN_RIGHT: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKETURNRIGHT; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CAR_HANDBRAKE_STOP: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); pVehicle->AutoPilot.m_nTempAction = TEMPACT_HANDBRAKESTRAIGHT; - pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + ScriptParams[1]; + pVehicle->AutoPilot.m_nTimeTempAction = CTimer::GetTimeInMilliseconds() + GET_INTEGER_PARAM(1); return 0; } */ case COMMAND_IS_CHAR_ON_ANY_BIKE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle&& pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE); return 0; @@ -1440,16 +1467,16 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_LOCATE_SNIPER_BULLET_3D: LocateSniperBulletCommand(command, &m_nIp); return 0; - */ case COMMAND_GET_NUMBER_OF_SEATS_IN_MODEL: CollectParameters(&m_nIp, 1); - ScriptParams[0] = CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(ScriptParams[0]) + 1; + SET_INTEGER_PARAM(0, CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(GET_INTEGER_PARAM(0)) + 1); StoreParameters(&m_nIp, 1); return 0; + */ case COMMAND_IS_PLAYER_ON_ANY_BIKE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BIKE); return 0; @@ -1458,7 +1485,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CHAR_LYING_DOWN: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bFallenDown); return 0; @@ -1467,9 +1494,9 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_CAN_CHAR_SEE_DEAD_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - int pedtype = ScriptParams[1]; + int pedtype = GET_INTEGER_PARAM(1); bool can = false; for (int i = 0; i < pPed->m_numNearPeds; i++) { CPed* pTestPed = pPed->m_nearPeds[i]; @@ -1481,69 +1508,75 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) } case COMMAND_SET_ENTER_CAR_RANGE_MULTIPLIER: CollectParameters(&m_nIp, 1); - CPed::nEnterCarRangeMultiplier = *(float*)&ScriptParams[0]; + CPed::nEnterCarRangeMultiplier = GET_FLOAT_PARAM(0); return 0; case COMMAND_SET_THREAT_REACTION_RANGE_MULTIPLIER: CollectParameters(&m_nIp, 1); - CPed::nThreatReactionRangeMultiplier = *(float*)&ScriptParams[0]; + CPed::nThreatReactionRangeMultiplier = GET_FLOAT_PARAM(0); + if (CPed::nThreatReactionRangeMultiplier < 1) + CPed::nThreatReactionRangeMultiplier = 1; return 0; case COMMAND_SET_CHAR_CEASE_ATTACK_TIMER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->m_ceaseAttackTimer = ScriptParams[1]; + pPed->m_ceaseAttackTimer = GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_REMOTE_CONTROLLED_CAR: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CWorld::Players[ScriptParams[0]].m_pRemoteVehicle; + CVehicle* pVehicle = CWorld::Players[GET_INTEGER_PARAM(0)].m_pRemoteVehicle; if (pVehicle) - ScriptParams[0] = CPools::GetVehiclePool()->GetIndex(pVehicle); + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex(pVehicle)); else - ScriptParams[0] = -1; + SET_INTEGER_PARAM(0, -1); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_PC_VERSION: +#ifdef GTA_PC UpdateCompareFlag(true); +#else + UpdateCompareFlag(false); +#endif return 0; //case COMMAND_REPLAY: //case COMMAND_IS_REPLAY_PLAYING: case COMMAND_IS_MODEL_AVAILABLE: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CModelInfo::GetModelInfo(ScriptParams[0]) != nil); + UpdateCompareFlag(CModelInfo::GetModelInfo(GET_INTEGER_PARAM(0)) != nil); return 0; case COMMAND_SHUT_CHAR_UP: CollectParameters(&m_nIp, 2); - DMAudio.SetPedTalkingStatus(CPools::GetPedPool()->GetAt(ScriptParams[0]), ScriptParams[1] == 0); + DMAudio.SetPedTalkingStatus(CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)), GET_INTEGER_PARAM(1) == 0); return 0; case COMMAND_SET_ENABLE_RC_DETONATE: CollectParameters(&m_nIp, 1); - CVehicle::bDisableRemoteDetonation = !ScriptParams[0]; + CVehicle::bDisableRemoteDetonation = !GET_INTEGER_PARAM(0); return 0; case COMMAND_SET_CAR_RANDOM_ROUTE_SEED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->m_nRouteSeed = ScriptParams[1]; + pVehicle->m_nRouteSeed = GET_INTEGER_PARAM(1); return 0; } case COMMAND_IS_ANY_PICKUP_AT_COORDS: { - CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; - CRunningScript::UpdateCompareFlag(CPickups::TestForPickupsInBubble(pos, 0.5f)); + CollectParameters(&m_nIp, 4); + CVector pos = GET_VECTOR_PARAM(0); + CRunningScript::UpdateCompareFlag(CPickups::TestForPickupsInBubble(pos, GET_FLOAT_PARAM(3))); return 0; } - case COMMAND_GET_FIRST_PICKUP_COORDS: - case COMMAND_GET_NEXT_PICKUP_COORDS: + //case COMMAND_GET_FIRST_PICKUP_COORDS: + //case COMMAND_GET_NEXT_PICKUP_COORDS: case COMMAND_REMOVE_ALL_CHAR_WEAPONS: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->ClearWeapons(); return 0; @@ -1551,11 +1584,26 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_HAS_PLAYER_GOT_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; + script_assert(pPed); + bool bFound = false; + for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { + if (pPed->GetWeapon(i).m_eWeaponType == GET_INTEGER_PARAM(1)) { + bFound = true; + break; + } + } + UpdateCompareFlag(bFound); + return 0; + } + case COMMAND_HAS_CHAR_GOT_WEAPON: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); bool bFound = false; for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - if (pPed->GetWeapon(i).m_eWeaponType == ScriptParams[1]) { + if (pPed->GetWeapon(i).m_eWeaponType == GET_INTEGER_PARAM(1)) { bFound = true; break; } @@ -1563,31 +1611,30 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) UpdateCompareFlag(bFound); return 0; } - //case COMMAND_HAS_CHAR_GOT_WEAPON: //case COMMAND_IS_PLAYER_FACING_CHAR: case COMMAND_SET_TANK_DETONATE_CARS: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle && pVehicle->m_vehType == VEHICLE_TYPE_CAR); - ((CAutomobile*)pVehicle)->bTankDetonateCars = ScriptParams[1]; + ((CAutomobile*)pVehicle)->bTankDetonateCars = GET_INTEGER_PARAM(1); return 0; } case COMMAND_GET_POSITION_OF_ANALOGUE_STICKS: { CollectParameters(&m_nIp, 1); - CPad* pPad = CPad::GetPad(ScriptParams[0]); - ScriptParams[0] = pPad->NewState.LeftStickX; - ScriptParams[1] = pPad->NewState.LeftStickY; - ScriptParams[2] = pPad->NewState.RightStickX; - ScriptParams[3] = pPad->NewState.RightStickY; + CPad* pPad = CPad::GetPad(GET_INTEGER_PARAM(0)); + SET_INTEGER_PARAM(0, pPad->NewState.LeftStickX); + SET_INTEGER_PARAM(1, pPad->NewState.LeftStickY); + SET_INTEGER_PARAM(2, pPad->NewState.RightStickX); + SET_INTEGER_PARAM(3, pPad->NewState.RightStickY); StoreParameters(&m_nIp, 4); return 0; } case COMMAND_IS_CAR_ON_FIRE: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); bool bOnFire = false; if (pVehicle->m_pCarFire) @@ -1602,35 +1649,35 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CAR_TYRE_BURST: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); bool bIsBurst = false; CBike* pBike = (CBike*)pVehicle; if (pVehicle->IsBike()) { - if (ScriptParams[1] == 4) { + if (GET_INTEGER_PARAM(1) == 4) { for (int i = 0; i < 2; i++) { if (pBike->m_wheelStatus[i] == WHEEL_STATUS_BURST) bIsBurst = true; } } else { - if (ScriptParams[1] == 2) - ScriptParams[1] = 0; - if (ScriptParams[1] == 3) - ScriptParams[1] = 1; - bIsBurst = pBike->m_wheelStatus[ScriptParams[1]] == WHEEL_STATUS_BURST; + if (GET_INTEGER_PARAM(1) == 2) + SET_INTEGER_PARAM(1, 0); + if (GET_INTEGER_PARAM(1) == 3) + SET_INTEGER_PARAM(1, 1); + bIsBurst = pBike->m_wheelStatus[GET_INTEGER_PARAM(1)] == WHEEL_STATUS_BURST; } } else { CAutomobile* pCar = (CAutomobile*)pVehicle; - if (ScriptParams[1] == 4) { + if (GET_INTEGER_PARAM(1) == 4) { for (int i = 0; i < 4; i++) { if (pCar->Damage.GetWheelStatus(i) == WHEEL_STATUS_BURST) bIsBurst = true; } } else - bIsBurst = pCar->Damage.GetWheelStatus(ScriptParams[1] == WHEEL_STATUS_BURST); + bIsBurst = pCar->Damage.GetWheelStatus(GET_INTEGER_PARAM(1) == WHEEL_STATUS_BURST); } UpdateCompareFlag(bIsBurst); return 0; @@ -1646,85 +1693,85 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) while (counter < 3 && CScriptPaths::aArray[counter].m_state != SCRIPT_PATH_DISABLED) { counter++; } - CScriptPaths::aArray[counter].InitialiseOne(ScriptParams[0], *(float*)&ScriptParams[1]); - ScriptParams[0] = counter; + CScriptPaths::aArray[counter].InitialiseOne(GET_INTEGER_PARAM(0), GET_FLOAT_PARAM(1)); + SET_INTEGER_PARAM(0, counter); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_START_OBJECT_ON_PATH: { CollectParameters(&m_nIp, 2); - CObject *pObj = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject *pObj = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); assert(pObj); - CScriptPaths::aArray[ScriptParams[1]].SetObjectToControl(pObj); + CScriptPaths::aArray[GET_INTEGER_PARAM(1)].SetObjectToControl(pObj); return 0; } case COMMAND_SET_OBJECT_PATH_SPEED: { CollectParameters(&m_nIp, 2); - CScriptPaths::aArray[ScriptParams[0]].m_fSpeed = *(float*)&ScriptParams[1]; + CScriptPaths::aArray[GET_INTEGER_PARAM(0)].m_fSpeed = GET_FLOAT_PARAM(1); return 0; } case COMMAND_SET_OBJECT_PATH_POSITION: { CollectParameters(&m_nIp, 2); - CScriptPaths::aArray[ScriptParams[0]].m_fPosition = *(float*)&ScriptParams[1]; + CScriptPaths::aArray[GET_INTEGER_PARAM(0)].m_fPosition = GET_FLOAT_PARAM(1); return 0; } //case COMMAND_GET_OBJECT_DISTANCE_ALONG_PATH: case COMMAND_CLEAR_OBJECT_PATH: { CollectParameters(&m_nIp, 1); - CScriptPaths::aArray[ScriptParams[0]].Clear(); + CScriptPaths::aArray[GET_INTEGER_PARAM(0)].Clear(); return 0; } case COMMAND_HELI_GOTO_COORDS: { CollectParameters(&m_nIp, 5); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle && pVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); - ((CAutomobile*)pVehicle)->TellHeliToGoToCoors(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], ScriptParams[4]); + ((CAutomobile*)pVehicle)->TellHeliToGoToCoors(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4)); return 0; } case COMMAND_IS_INT_VAR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr == ScriptParams[0]); + UpdateCompareFlag(*ptr == GET_INTEGER_PARAM(0)); return 0; } case COMMAND_GET_DEAD_CHAR_PICKUP_COORDS: { CollectParameters(&m_nIp, 1); - CPed *pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed *pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); CVector pos; pTarget->CreateDeadPedPickupCoors(&pos.x, &pos.y, &pos.z); - *(CVector*)&ScriptParams[0] = pos; + SET_VECTOR_PARAM(0, pos); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_CREATE_PROTECTION_PICKUP: { CollectParameters(&m_nIp, 5); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_REVENUE, PICKUP_ASSET_REVENUE, ScriptParams[3], ScriptParams[4]); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_REVENUE, PICKUP_ASSET_REVENUE, GET_INTEGER_PARAM(3), GET_INTEGER_PARAM(4))); // TODO: gpModelIndices StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_CHAR_IN_ANY_BOAT: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT); return 0; @@ -1732,7 +1779,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_PLAYER_IN_ANY_BOAT: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_BOAT); return 0; @@ -1740,7 +1787,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CHAR_IN_ANY_HELI: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); return 0; @@ -1748,7 +1795,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_PLAYER_IN_ANY_HELI: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); return 0; @@ -1756,7 +1803,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CHAR_IN_ANY_PLANE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE); return 0; @@ -1764,7 +1811,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_PLAYER_IN_ANY_PLANE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI); return 0; @@ -1772,7 +1819,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_IS_CHAR_IN_WATER: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed && pPed->bIsInWater); return 0; } @@ -1780,14 +1827,14 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_LVAR_INT_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - *ptr = ScriptParams[0]; + *ptr = GET_INTEGER_PARAM(0); return 0; } default: diff --git a/src/control/Script7.cpp b/src/control/Script7.cpp index f7694055..cddda5e9 100644 --- a/src/control/Script7.cpp +++ b/src/control/Script7.cpp @@ -13,6 +13,7 @@ #include "General.h" #include "Glass.h" #include "Fluff.h" +#include "KeyGen.h" #include "Hud.h" #include "MBlur.h" #include "Pad.h" @@ -31,6 +32,8 @@ #include "World.h" #include "Zones.h" +// LCS: file done except TODOs + int8 CRunningScript::ProcessCommands1200To1299(int32 command) { switch (command) { @@ -38,66 +41,66 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_THAN_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr > ScriptParams[0]); + UpdateCompareFlag(*ptr > GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_CONSTANT_GREATER_THAN_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_CONSTANT_GREATER_THAN_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] > *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) > *ptr); return 0; } case COMMAND_IS_INT_VAR_GREATER_OR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_INT_LVAR_GREATER_OR_EQUAL_TO_CONSTANT: { int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); CollectParameters(&m_nIp, 1); - UpdateCompareFlag(*ptr >= ScriptParams[0]); + UpdateCompareFlag(*ptr >= GET_INTEGER_PARAM(0)); return 0; } case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_VAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_IS_CONSTANT_GREATER_OR_EQUAL_TO_INT_LVAR: { CollectParameters(&m_nIp, 1); int32* ptr = GetPointerToScriptVariable(&m_nIp, VAR_LOCAL); - UpdateCompareFlag(ScriptParams[0] >= *ptr); + UpdateCompareFlag(GET_INTEGER_PARAM(0) >= *ptr); return 0; } case COMMAND_GET_CHAR_WEAPON_IN_SLOT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->GetWeapon(ScriptParams[1] - 1).m_eWeaponType; - ScriptParams[1] = pPed->GetWeapon(ScriptParams[1] - 1).m_nAmmoTotal; - ScriptParams[2] = CPickups::ModelForWeapon((eWeaponType)ScriptParams[0]); + SET_INTEGER_PARAM(0, pPed->GetWeapon(GET_INTEGER_PARAM(1) - 1).m_eWeaponType); + SET_INTEGER_PARAM(1, pPed->GetWeapon(GET_INTEGER_PARAM(1) - 1).m_nAmmoTotal); + SET_INTEGER_PARAM(2, CPickups::ModelForWeapon((eWeaponType)GET_INTEGER_PARAM(0))); StoreParameters(&m_nIp, 3); return 0; } @@ -106,16 +109,16 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CollectParameters(&m_nIp, 5); int node1, node2; float angle; - ThePaths.FindNodePairClosestToCoors(*(CVector*)&ScriptParams[0], PATH_CAR, &node1, &node2, &angle, - *(float*)&ScriptParams[3], *(float*)&ScriptParams[4], true, true); + ThePaths.FindNodePairClosestToCoors(GET_VECTOR_PARAM(0), PATH_CAR, &node1, &node2, &angle, + GET_FLOAT_PARAM(3), GET_FLOAT_PARAM(4), true, true); if (node1 == -1) { for (int i = 0; i < 7; i++) ScriptParams[i] = 0; } else { - *(CVector*)&ScriptParams[0] = ThePaths.FindNodeCoorsForScript(node1); - *(CVector*)&ScriptParams[3] = ThePaths.FindNodeCoorsForScript(node2); - *(float*)&ScriptParams[6] = angle; + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(node1)); + SET_VECTOR_PARAM(3, ThePaths.FindNodeCoorsForScript(node2)); + SET_FLOAT_PARAM(6, angle); } StoreParameters(&m_nIp, 7); return 0; @@ -123,9 +126,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CAR_FORWARD_SPEED: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - float speed = *(float*)&ScriptParams[1] / GAME_SPEED_TO_CARAI_SPEED; + float speed = GET_FLOAT_PARAM(1) / GAME_SPEED_TO_CARAI_SPEED; pVehicle->SetMoveSpeed(pVehicle->GetForward() * speed); if (pVehicle->IsRealHeli() && pVehicle->IsCar()) ((CAutomobile*)pVehicle)->m_aWheelSpeed[1] = 0.22f; @@ -133,8 +136,8 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) } case COMMAND_SET_AREA_VISIBLE: CollectParameters(&m_nIp, 1); - CGame::currArea = ScriptParams[0]; - CStreaming::RemoveBuildingsNotInArea(ScriptParams[0]); + CGame::currArea = GET_INTEGER_PARAM(0); + CStreaming::RemoveBuildingsNotInArea(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_CUTSCENE_ANIM_TO_LOOP: { @@ -147,28 +150,28 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_MARK_CAR_AS_CONVOY_CAR: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bPartOfConvoy = ScriptParams[1]; + pVehicle->bPartOfConvoy = GET_INTEGER_PARAM(1); return 0; } case COMMAND_RESET_HAVOC_CAUSED_BY_PLAYER: { CollectParameters(&m_nIp, 1); - CWorld::Players[ScriptParams[0]].m_nHavocLevel = 0; + CWorld::Players[GET_INTEGER_PARAM(0)].m_nHavocLevel = 0; return 0; } case COMMAND_GET_HAVOC_CAUSED_BY_PLAYER: { CollectParameters(&m_nIp, 1); - ScriptParams[0] = CWorld::Players[ScriptParams[0]].m_nHavocLevel; + SET_INTEGER_PARAM(0, CWorld::Players[GET_INTEGER_PARAM(0)].m_nHavocLevel); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CREATE_SCRIPT_ROADBLOCK: { CollectParameters(&m_nIp, 6); - CRoadBlocks::RegisterScriptRoadBlock(*(CVector*)&ScriptParams[0], *(CVector*)&ScriptParams[3]); + CRoadBlocks::RegisterScriptRoadBlock(GET_VECTOR_PARAM(0), GET_VECTOR_PARAM(3)); return 0; } case COMMAND_CLEAR_ALL_SCRIPT_ROADBLOCKS: @@ -179,9 +182,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CHAR_OBJ_WALK_TO_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTargetPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_GOTO_CHAR_ON_FOOT_WALKING, pTargetPed); @@ -191,17 +194,17 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_GET_OFFSET_FROM_CHAR_IN_WORLD_COORDS: { CollectParameters(&m_nIp, 4); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVector result = Multiply3x3(pPed->GetMatrix(), *(CVector*)&ScriptParams[1]) + pPed->GetPosition(); - *(CVector*)&ScriptParams[0] = result; + CVector result = Multiply3x3(pPed->GetMatrix(), GET_VECTOR_PARAM(1)) + pPed->GetPosition(); + SET_VECTOR_PARAM(0, result); StoreParameters(&m_nIp, 3); return 0; } case COMMAND_HAS_CHAR_BEEN_PHOTOGRAPHED: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); bool result = false; if (pPed->bHasBeenPhotographed) { @@ -214,9 +217,9 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CHAR_OBJ_AIM_GUN_AT_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CPed* pTargetPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pTargetPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pTargetPed); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_AIM_GUN_AT, pTargetPed); @@ -225,14 +228,21 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SWITCH_SECURITY_CAMERA: { CollectParameters(&m_nIp, 1); - CSpecialFX::bVideoCam = ScriptParams[0] != 0; + if (GET_INTEGER_PARAM(0) != 0) { + // TheCamera.MBlur.? = 3; TODO(LCS) + CSpecialFX::bVideoCam = true; + } + else { + // TheCamera.MBlur.Reset(); + CSpecialFX::bVideoCam = false; + } return 0; } //case COMMAND_IS_CHAR_IN_FLYING_VEHICLE: case COMMAND_IS_PLAYER_IN_FLYING_VEHICLE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && (pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI || pPed->m_pMyVehicle->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE)); return 0; @@ -244,27 +254,27 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_COORD: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetShortRangeCoordBlip(BLIP_COORD, pos, 5, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[3]); - ScriptParams[0] = id; + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(3)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_ADD_MONEY_SPENT_ON_CLOTHES: CollectParameters(&m_nIp, 1); - CStats::MoneySpentOnFashion(ScriptParams[0]); + //CStats::MoneySpentOnFashion(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_HELI_ORIENTATION: { CollectParameters(&m_nIp, 2); - CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); - float fAngle = DEGTORAD(*(float*)&ScriptParams[1] - 90.0f); + float fAngle = DEGTORAD(GET_FLOAT_PARAM(1) - 90.0f); while (fAngle < 0.0f) fAngle += TWOPI; while (fAngle > TWOPI) @@ -275,7 +285,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CLEAR_HELI_ORIENTATION: { CollectParameters(&m_nIp, 1); - CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); pHeli->ClearHeliOrientation(); return 0; @@ -283,66 +293,75 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_PLANE_GOTO_COORDS: { CollectParameters(&m_nIp, 5); - CAutomobile* pPlane = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pPlane = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPlane && pPlane->IsCar() && pPlane->IsRealPlane()); - pPlane->TellPlaneToGoToCoors(*(float*)&ScriptParams[1], *(float*)&ScriptParams[2], *(float*)&ScriptParams[3], ScriptParams[4]); + pPlane->TellPlaneToGoToCoors(GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2), GET_FLOAT_PARAM(3), GET_INTEGER_PARAM(4)); return 0; } case COMMAND_GET_NTH_CLOSEST_CAR_NODE: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); + if (pos.z <= MAP_Z_LOW_LIMIT) + pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(ThePaths.FindNthNodeClosestToCoors(pos, 0, 999999.9f, true, true, GET_INTEGER_PARAM(3) - 1))); + StoreParameters(&m_nIp, 3); + return 0; + } + case COMMAND_GET_NTH_CLOSEST_CHAR_NODE: + { + CollectParameters(&m_nIp, 4); + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - *(CVector*)&ScriptParams[0] = ThePaths.FindNodeCoorsForScript(ThePaths.FindNthNodeClosestToCoors(pos, 0, 999999.9f, true, true, ScriptParams[3] - 1)); + SET_VECTOR_PARAM(0, ThePaths.FindNodeCoorsForScript(ThePaths.FindNthNodeClosestToCoors(pos, 1, 999999.9f, true, true, GET_INTEGER_PARAM(3) - 1))); StoreParameters(&m_nIp, 3); return 0; } - //case COMMAND_GET_NTH_CLOSEST_CHAR_NODE: case COMMAND_DRAW_WEAPONSHOP_CORONA: { CollectParameters(&m_nIp, 9); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); - CCoronas::RegisterCorona((uintptr)this + m_nIp, ScriptParams[6], ScriptParams[7], ScriptParams[8], 255, pos, *(float*)&ScriptParams[3], - 150.0f, ScriptParams[4], ScriptParams[5], 1, 0, 0, 0.0f, false, 0.2f); + CCoronas::RegisterCorona((uintptr)this + m_nIp, GET_INTEGER_PARAM(6), GET_INTEGER_PARAM(7), GET_INTEGER_PARAM(8), 255, pos, -GET_FLOAT_PARAM(3), + 150.0f, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), 1, 0, 0, 0.0f, false, 0.2f); return 0; } case COMMAND_SET_ENABLE_RC_DETONATE_ON_CONTACT: { CollectParameters(&m_nIp, 1); - CVehicle::bDisableRemoteDetonationOnContact = (ScriptParams[0] == 0); + CVehicle::bDisableRemoteDetonationOnContact = (GET_INTEGER_PARAM(0) == 0); return 0; } case COMMAND_FREEZE_CHAR_POSITION: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIsFrozen = ScriptParams[1]; + pPed->bIsFrozen = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CHAR_DROWNS_IN_WATER: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bDrownsInWater = ScriptParams[1]; + pPed->bDrownsInWater = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_OBJECT_RECORDS_COLLISIONS: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bUseCollisionRecords = ScriptParams[1]; + pObject->bUseCollisionRecords = GET_INTEGER_PARAM(1); return 0; } case COMMAND_HAS_OBJECT_COLLIDED_WITH_ANYTHING: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(pObject->m_nCollisionRecords != 0); return 0; @@ -352,13 +371,15 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CWorld::Players[CWorld::PlayerInFocus].BlowUpRCBuggy(false); return 0; } - //case COMMAND_HAS_PHOTOGRAPH_BEEN_TAKEN: + case COMMAND_HAS_PHOTOGRAPH_BEEN_TAKEN: + UpdateCompareFlag(CWeapon::bPhotographHasBeenTaken); + return 0; case COMMAND_GET_CHAR_ARMOUR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - ScriptParams[0] = pPed->m_fArmour; + SET_INTEGER_PARAM(0, pPed->m_fArmour); StoreParameters(&m_nIp, 1); return 0; } @@ -366,23 +387,23 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_HELI_STABILISER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bHeliMinimumTilt = ScriptParams[1]; + pVehicle->bHeliMinimumTilt = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CAR_STRAIGHT_LINE_DISTANCE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->AutoPilot.m_nSwitchDistance = ScriptParams[1]; + pVehicle->AutoPilot.m_nSwitchDistance = GET_INTEGER_PARAM(1); return 0; } case COMMAND_POP_CAR_BOOT: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pCar&& pCar->IsCar()); pCar->PopBoot(); return 0; @@ -390,21 +411,21 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SHUT_PLAYER_UP: { CollectParameters(&m_nIp, 2); - DMAudio.ShutUpPlayerTalking(!!ScriptParams[1]); + DMAudio.ShutUpPlayerTalking(!!GET_INTEGER_PARAM(1)); return 0; } case COMMAND_SET_PLAYER_MOOD: { CollectParameters(&m_nIp, 3); - DMAudio.SetPlayersMood(ScriptParams[1], ScriptParams[2]); + DMAudio.SetPlayersMood(GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_REQUEST_COLLISION: { CollectParameters(&m_nIp, 2); CVector2D pos; - pos.x = *(float*)&ScriptParams[0]; - pos.y = *(float*)&ScriptParams[1]; + pos.x = GET_FLOAT_PARAM(0); + pos.y = GET_FLOAT_PARAM(1); CColStore::RequestCollision(pos); return 0; } @@ -415,7 +436,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_IS_OBJECT_IN_WATER: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(pObject->bIsInWater); return 0; @@ -428,11 +449,11 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CHAR_CROUCH: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pPed->bIsDucking = true; - pPed->SetDuck(ScriptParams[2], true); + pPed->SetDuck(GET_INTEGER_PARAM(2), true); } else { pPed->ClearDuck(true); @@ -460,7 +481,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) return 0; } while (zone >= 0) { - CTheZones::SetZoneCivilianCarInfo(zone, ScriptParams[0], carDensities, boatDensities); + CTheZones::SetZoneCivilianCarInfo(zone, GET_INTEGER_PARAM(0), carDensities, boatDensities); zone = CTheZones::FindNextZoneByLabelAndReturnIndex(label, ZONE_INFO); } return 0; @@ -470,7 +491,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; - CStreaming::RequestAnim(CAnimManager::GetAnimationBlockIndex(key), STREAMFLAGS_SCRIPTOWNED); + CStreaming::RequestAnim(CAnimManager::GetAnimationBlockIndex(key), (m_bIsMissionScript ? STREAMFLAGS_SCRIPTOWNED : STREAMFLAGS_AMBIENT_SCRIPT_OWNED)); return 0; } case COMMAND_HAS_ANIMATION_LOADED: @@ -487,12 +508,13 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; CStreaming::RemoveAnim(CAnimManager::GetAnimationBlockIndex(key)); + // + empty function on PS2 return 0; } case COMMAND_IS_CHAR_WAITING_FOR_WORLD_COLLISION: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bIsStaticWaitingForCollision); return 0; @@ -500,40 +522,42 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_IS_CAR_WAITING_FOR_WORLD_COLLISION: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); UpdateCompareFlag(pVehicle->bIsStaticWaitingForCollision); return 0; } + /* case COMMAND_IS_OBJECT_WAITING_FOR_WORLD_COLLISION: { CollectParameters(&m_nIp, 1); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); UpdateCompareFlag(pObject->bIsStaticWaitingForCollision); return 0; } + */ case COMMAND_SET_CHAR_SHUFFLE_INTO_DRIVERS_SEAT: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); pPed->PedShuffle(); return 0; } case COMMAND_ATTACH_CHAR_TO_OBJECT: { CollectParameters(&m_nIp, 8); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[1]); - pPed->AttachPedToEntity(pObject, *(CVector*)&ScriptParams[2], ScriptParams[5], DEGTORAD(ScriptParams[6]), (eWeaponType)ScriptParams[7]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); + pPed->AttachPedToEntity(pObject, GET_VECTOR_PARAM(2), GET_INTEGER_PARAM(5), DEGTORAD(GET_INTEGER_PARAM(6)), (eWeaponType)GET_INTEGER_PARAM(7)); return 0; } case COMMAND_SET_CHAR_AS_PLAYER_FRIEND: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIsPlayerFriend = ScriptParams[2]; + pPed->bIsPlayerFriend = GET_INTEGER_PARAM(2); return 0; } //case COMMAND_DISPLAY_NTH_ONSCREEN_COUNTER: @@ -546,41 +570,53 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) wchar* text = TheText.Get((char*)&CTheScripts::ScriptSpace[m_nIp]); // ??? strncpy(onscreen_str, (char*)&CTheScripts::ScriptSpace[m_nIp], KEY_LENGTH_IN_SCRIPT); m_nIp += KEY_LENGTH_IN_SCRIPT; - CUserDisplay::OnscnTimer.AddCounter(var, ScriptParams[0], onscreen_str, ScriptParams[1] - 1); + CUserDisplay::OnscnTimer.AddCounter(var, GET_INTEGER_PARAM(0), onscreen_str, GET_INTEGER_PARAM(1) - 1); // TODO: last params are -1, nil, 0 return 0; } case COMMAND_ADD_SET_PIECE: { CollectParameters(&m_nIp, 13); - CSetPieces::AddOne(ScriptParams[0], - *(CVector2D*)&ScriptParams[1], *(CVector2D*)&ScriptParams[3], - *(CVector2D*)&ScriptParams[5], *(CVector2D*)&ScriptParams[7], - *(CVector2D*)&ScriptParams[9], *(CVector2D*)&ScriptParams[11]); + float fTriggerInfX = GET_FLOAT_PARAM(1); + float fTriggerInfY = GET_FLOAT_PARAM(2); + float fTriggerSupX = GET_FLOAT_PARAM(3); + float fTriggerSupY = GET_FLOAT_PARAM(4); + float fSpawn1X = GET_FLOAT_PARAM(5); + float fSpawn1Y = GET_FLOAT_PARAM(6); + float fTarget1X = GET_FLOAT_PARAM(7); + float fTarget1Y = GET_FLOAT_PARAM(8); + float fSpawn2X = GET_FLOAT_PARAM(9); + float fSpawn2Y = GET_FLOAT_PARAM(10); + float fTarget2X = GET_FLOAT_PARAM(11); + float fTarget2Y = GET_FLOAT_PARAM(12); + CSetPieces::AddOne(GET_INTEGER_PARAM(0), + CVector2D(fTriggerInfX, fTriggerInfY), CVector2D(fTriggerSupX, fTriggerSupY), + CVector2D(fSpawn1X, fSpawn1Y), CVector2D(fTarget1X, fTarget1Y), + CVector2D(fSpawn2X, fSpawn2Y), CVector2D(fTarget2X, fTarget2Y)); return 0; } case COMMAND_SET_EXTRA_COLOURS: { CollectParameters(&m_nIp, 2); - CTimeCycle::StartExtraColour(ScriptParams[0]-1, ScriptParams[1] != 0); + CTimeCycle::StartExtraColour(GET_INTEGER_PARAM(0)-1, GET_INTEGER_PARAM(1) != 0); return 0; } case COMMAND_CLEAR_EXTRA_COLOURS: { CollectParameters(&m_nIp, 1); - CTimeCycle::StopExtraColour(ScriptParams[0]); + CTimeCycle::StopExtraColour(GET_INTEGER_PARAM(0)); return 0; } //case COMMAND_CLOSE_CAR_BOOT: case COMMAND_GET_WHEELIE_STATS: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - ScriptParams[0] = pPlayerInfo->m_nLastTimeCarSpentOnTwoWheels; - *(float*)&ScriptParams[1] = pPlayerInfo->m_nLastDistanceCarTravelledOnTwoWheels; - ScriptParams[2] = pPlayerInfo->m_nLastTimeSpentOnWheelie; - *(float*)&ScriptParams[3] = pPlayerInfo->m_nLastDistanceTravelledOnWheelie; - ScriptParams[4] = pPlayerInfo->m_nLastTimeSpentOnStoppie; - *(float*)&ScriptParams[5] = pPlayerInfo->m_nLastDistanceTravelledOnStoppie; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + SET_INTEGER_PARAM(0, pPlayerInfo->m_nLastTimeCarSpentOnTwoWheels); + SET_FLOAT_PARAM(1, pPlayerInfo->m_nLastDistanceCarTravelledOnTwoWheels); + SET_INTEGER_PARAM(2, pPlayerInfo->m_nLastTimeSpentOnWheelie); + SET_FLOAT_PARAM(3, pPlayerInfo->m_nLastDistanceTravelledOnWheelie); + SET_INTEGER_PARAM(4, pPlayerInfo->m_nLastTimeSpentOnStoppie); + SET_FLOAT_PARAM(5, pPlayerInfo->m_nLastDistanceTravelledOnStoppie); StoreParameters(&m_nIp, 6); pPlayerInfo->m_nLastTimeCarSpentOnTwoWheels = 0; pPlayerInfo->m_nLastDistanceCarTravelledOnTwoWheels = 0.0f; @@ -594,23 +630,23 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_BURST_CAR_TYRE: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle->IsBike()) { - if (ScriptParams[1] == 2) - ScriptParams[1] = 0; - else if (ScriptParams[1] == 3) - ScriptParams[1] = 1; - pVehicle->BurstTyre(ScriptParams[1], true); + if (GET_INTEGER_PARAM(1) == 2) + SET_INTEGER_PARAM(1, 0); + else if (GET_INTEGER_PARAM(1) == 3) + SET_INTEGER_PARAM(1, 1); + pVehicle->BurstTyre(GET_INTEGER_PARAM(1), true); } else { - pVehicle->BurstTyre(ScriptParams[1], true); + pVehicle->BurstTyre(GET_INTEGER_PARAM(1), true); } return 0; } case COMMAND_IS_CHAR_OBJ_NO_OBJ: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->m_prevObjective == OBJECTIVE_NONE && pPed->m_objective == OBJECTIVE_NONE); return 0; @@ -623,26 +659,26 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; for (int i = 0; i < KEY_LENGTH_IN_SCRIPT; i++) key[i] = tolower(key[i]); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - UpdateCompareFlag(strcmp(key, CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetModelName()) == 0); + UpdateCompareFlag(CModelInfo::GetModelInfo(pPed->GetModelIndex())->GetNameHashKey() == CKeyGen::GetUppercaseKey(key)); return 0; } case COMMAND_SET_PLAYER_CAN_DO_DRIVE_BY: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_bDriveByAllowed = ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_bDriveByAllowed = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_CHAR_OBJ_SPRINT_TO_COORD: { CollectParameters(&m_nIp, 3); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); CVector pos; - pos.x = *(float*)&ScriptParams[1]; - pos.y = *(float*)&ScriptParams[2]; + pos.x = GET_FLOAT_PARAM(1); + pos.y = GET_FLOAT_PARAM(2); pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pPed->bScriptObjectiveCompleted = false; pPed->SetObjective(OBJECTIVE_SPRINT_TO_AREA, pos); @@ -651,7 +687,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CREATE_SWAT_ROPE: { CollectParameters(&m_nIp, 3); - CRopes::CreateRopeWithSwatComingDown(*(CVector*)&ScriptParams[0]); + CRopes::CreateRopeWithSwatComingDown(GET_VECTOR_PARAM(0)); return 0; } //case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA: @@ -659,19 +695,19 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SET_CAR_MODEL_COMPONENTS: { CollectParameters(&m_nIp, 3); - CVehicleModelInfo::SetComponentsToUse(ScriptParams[1], ScriptParams[2]); + CVehicleModelInfo::SetComponentsToUse(GET_INTEGER_PARAM(1), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_SWITCH_LIFT_CAMERA: { CollectParameters(&m_nIp, 1); - CSpecialFX::bLiftCam = ScriptParams[0] != 0; + CSpecialFX::bLiftCam = GET_INTEGER_PARAM(0) != 0; return 0; } case COMMAND_CLOSE_ALL_CAR_DOORS: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pCar&& pCar->IsCar()); pCar->CloseAllDoors(); return 0; @@ -679,21 +715,25 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_GET_DISTANCE_BETWEEN_COORDS_2D: { CollectParameters(&m_nIp, 4); - *(float*)&ScriptParams[0] = (*(CVector2D*)&ScriptParams[0] - *(CVector2D*)&ScriptParams[2]).Magnitude(); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float X2 = GET_FLOAT_PARAM(2); + float Y2 = GET_FLOAT_PARAM(3); + SET_FLOAT_PARAM(0, (CVector2D(X1, Y1) - CVector2D(X2, Y2)).Magnitude()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_GET_DISTANCE_BETWEEN_COORDS_3D: { CollectParameters(&m_nIp, 6); - *(float*)&ScriptParams[0] = (*(CVector*)&ScriptParams[0] - *(CVector*)&ScriptParams[3]).Magnitude(); + SET_FLOAT_PARAM(0, (GET_VECTOR_PARAM(0) - GET_VECTOR_PARAM(3)).Magnitude()); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_POP_CAR_BOOT_USING_PHYSICS: { CollectParameters(&m_nIp, 1); - CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pCar && pCar->IsCar()); pCar->PopBootUsingPhysics(); return 0; @@ -702,7 +742,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_IS_CHAR_LEAVING_VEHICLE_TO_DIE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE); return 0; @@ -710,25 +750,29 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_SORT_OUT_OBJECT_COLLISION_WITH_CAR: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->m_pCollidingEntity = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + pObject->m_pCollidingEntity = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); return 0; } //case COMMAND_GET_MAX_WANTED_LEVEL: case COMMAND_IS_CHAR_WANDER_PATH_CLEAR: { CollectParameters(&m_nIp, 5); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - UpdateCompareFlag(CWorld::IsWanderPathClear(pPed->GetPosition(), *(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3], 4)); + UpdateCompareFlag(CWorld::IsWanderPathClear(pPed->GetPosition(), GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3), 4)); return 0; } //case COMMAND_PRINT_HELP_WITH_NUMBER: case COMMAND_PRINT_HELP_FOREVER: { wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - CHud::SetHelpMessage(text, false, true); + CHud::SetHelpMessage(text, false, true); // + true + if (text != CHud::gLastPrintForeverString) { + CHud::gLastPrintForeverString = text; + DMAudio.PlayFrontEndSound(SOUND_HUD_SOUND, 0); + } return 0; } //case COMMAND_PRINT_HELP_FOREVER_WITH_NUMBER: @@ -744,10 +788,10 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_CAN_BE_DAMAGED_BY_MEMBERS_OF_GANG: { CollectParameters(&m_nIp, 3); - CPed* pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pTarget = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pTarget); - uint8 flag = 1 << (uint8)ScriptParams[1]; - if (ScriptParams[2]) + uint8 flag = 1 << (uint8)GET_INTEGER_PARAM(1); + if (GET_INTEGER_PARAM(2)) pTarget->m_gangFlags |= flag; else pTarget->m_gangFlags &= ~flag; @@ -760,7 +804,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_CREATE_LOCKED_PROPERTY_PICKUP: { CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; char key[KEY_LENGTH_IN_SCRIPT]; @@ -768,14 +812,14 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; // TheText.Get(key); CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY, PICKUP_PROPERTY_LOCKED, 0, 0, false, key); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY, PICKUP_PROPERTY_LOCKED, 0, 0, false, key)); // TODO: gpModelIndices StoreParameters(&m_nIp, 1); return 0; } case COMMAND_CREATE_FORSALE_PROPERTY_PICKUP: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; char key[KEY_LENGTH_IN_SCRIPT]; @@ -783,24 +827,24 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) m_nIp += KEY_LENGTH_IN_SCRIPT; // TheText.Get(key); CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY_FORSALE, PICKUP_PROPERTY_FORSALE, ScriptParams[3], 0, false, key); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY_FORSALE, PICKUP_PROPERTY_FORSALE, GET_INTEGER_PARAM(3), 0, false, key)); // TODO: gpModelIndices StoreParameters(&m_nIp, 1); return 0; } case COMMAND_FREEZE_CAR_POSITION: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bIsFrozen = ScriptParams[1]; - pVehicle->bInfiniteMass = ScriptParams[1]; + pVehicle->bIsFrozen = GET_INTEGER_PARAM(1); + pVehicle->bInfiniteMass = GET_INTEGER_PARAM(1); return 0; } case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CHAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CPed* pTestedPed = CPools::GetPedPool()->GetAt(ScriptParams[1]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pTestedPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); bool result = false; if (pPed) { if (pPed->m_lastDamEntity) { @@ -814,21 +858,75 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) UpdateCompareFlag(result); return 0; } - //case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CAR: - //case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CHAR: - //case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CAR: + case COMMAND_HAS_CHAR_BEEN_DAMAGED_BY_CAR: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pTestedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + bool result = false; + if (pPed) { + if (pPed->m_lastDamEntity) { + if (pPed->m_lastDamEntity == pTestedVehicle) + result = true; + } + } + else + debug("HAS_CHAR_BEEN_DAMAGED_BY_CAR - Character doesn't exist\n"); + UpdateCompareFlag(result); + return 0; + } + case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CHAR: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pTestedPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + bool result = false; + if (pVehicle) { + if (pVehicle->m_pLastDamageEntity) { + if (pVehicle->m_pLastDamageEntity == pTestedPed) + result = true; + if (pTestedPed->bInVehicle && pVehicle->m_pLastDamageEntity == pTestedPed->m_pMyVehicle) + result = true; + } + } + else + debug("HAS_CAR_BEEN_DAMAGED_BY_CHAR - Car doesn't exist\n"); + UpdateCompareFlag(result); + return 0; + } + case COMMAND_HAS_CAR_BEEN_DAMAGED_BY_CAR: + { + CollectParameters(&m_nIp, 2); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CVehicle* pTestedVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); + bool result = false; + if (pVehicle) { + if (pVehicle->m_pLastDamageEntity) { + if (pVehicle->m_pLastDamageEntity == pTestedVehicle) + result = true; + } + } + else + debug("HAS_CAR_BEEN_DAMAGED_BY_CAR - First car doesn't exist\n"); + UpdateCompareFlag(result); + return 0; + } case COMMAND_GET_RADIO_CHANNEL: { - // TODO - ScriptParams[0] = -1; + uint8 radio = DMAudio.GetRadioInCar(); + if (radio < NUM_RADIOS || radio == STREAMED_SOUND_MISSION_COMPLETED) + SET_INTEGER_PARAM(0, radio); + else + SET_INTEGER_PARAM(0, -1); StoreParameters(&m_nIp, 1); + return 0; } //case COMMAND_DISPLAY_TEXT_WITH_3_NUMBERS: //case COMMAND_IS_CAR_DROWNING_IN_WATER: case COMMAND_IS_CHAR_DROWNING_IN_WATER: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); UpdateCompareFlag(pPed && pPed->bIsDrowning); return 0; } @@ -842,7 +940,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CollectParameters(&m_nIp, 3); bool shattered = false; - if ( CGlass::HasGlassBeenShatteredAtCoors(*(float*)&ScriptParams[0], *(float*)&ScriptParams[1], *(float*)&ScriptParams[2]) ) + if ( CGlass::HasGlassBeenShatteredAtCoors(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(1), GET_FLOAT_PARAM(2)) ) shattered = true; UpdateCompareFlag(shattered); @@ -851,14 +949,14 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_BONE: { CollectParameters(&m_nIp, 3); - CCutsceneMgr::AttachObjectToBone(CPools::GetObjectPool()->GetAt(ScriptParams[0]), CPools::GetObjectPool()->GetAt(ScriptParams[1]), ScriptParams[2]); + CCutsceneMgr::AttachObjectToBone(CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)), CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)), GET_INTEGER_PARAM(2)); return 0; } case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_COMPONENT: { CollectParameters(&m_nIp, 2); - CObject *obj1 = CPools::GetObjectPool()->GetAt(ScriptParams[0]); - CObject *obj2 = CPools::GetObjectPool()->GetAt(ScriptParams[1]); + CObject *obj1 = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); + CObject *obj2 = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(1)); char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); @@ -870,26 +968,26 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_STAY_IN_CAR_WHEN_JACKED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bStayInCarOnJack = ScriptParams[1]; + pPed->bStayInCarOnJack = GET_INTEGER_PARAM(1); return 0; } //case COMMAND_IS_MISSION_AUDIO_LOADING: case COMMAND_ADD_MONEY_SPENT_ON_WEAPONS: CollectParameters(&m_nIp, 1); - CStats::MoneySpentOnWeapons(ScriptParams[0]); + CStats::MoneySpentOnWeapons(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_MONEY_SPENT_ON_PROPERTY: CollectParameters(&m_nIp, 1); - CStats::MoneySpentOnProperty(ScriptParams[0]); + //CStats::MoneySpentOnProperty(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_ADD_MONEY_SPENT_ON_AUTO_PAINTING: case COMMAND_SET_CHAR_ANSWERING_MOBILE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - if (ScriptParams[1]) + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (GET_INTEGER_PARAM(1)) pPed->SetAnswerMobile(); else pPed->ClearAnswerMobile(); @@ -898,8 +996,8 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_PLAYER_DRUNKENNESS: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_pPed->m_nDrunkenness = ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_pPed->m_nDrunkenness = GET_INTEGER_PARAM(1); pPlayerInfo->m_pPed->m_nFadeDrunkenness = 0; if (pPlayerInfo->m_pPed->m_nDrunkenness == 0) CMBlur::ClearDrunkBlur(); @@ -911,21 +1009,21 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) //case COMMAND_ADD_LOAN_SHARK_VISITS: case COMMAND_ADD_STORES_KNOCKED_OFF: CollectParameters(&m_nIp, 1); - CStats::NumOfStoresKnockedOff(ScriptParams[0]); + //CStats::NumOfStoresKnockedOff(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_ADD_MOVIE_STUNTS: case COMMAND_ADD_NUMBER_OF_ASSASSINATIONS: CollectParameters(&m_nIp, 1); - CStats::NumOfAssassinations(ScriptParams[0]); + //CStats::NumOfAssassinations(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_PIZZAS_DELIVERED: CollectParameters(&m_nIp, 1); - CStats::NumOfPizzasDelivered(ScriptParams[0]); + CStats::NumOfPizzasDelivered(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_ADD_GARBAGE_PICKUPS: case COMMAND_ADD_ICE_CREAMS_SOLD: CollectParameters(&m_nIp, 1); - CStats::NumOfIceCreamSold(ScriptParams[0]); + CStats::NumOfIceCreamSold(GET_INTEGER_PARAM(0)); return 0; //case COMMAND_SET_TOP_SHOOTING_RANGE_SCORE: //case COMMAND_ADD_SHOOTING_RANGE_RANK: @@ -935,15 +1033,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_IN_PLAYERS_GROUP_CAN_FIGHT: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bDontFight = !ScriptParams[1]; + pPed->bDontFight = !GET_INTEGER_PARAM(1); return 0; } case COMMAND_CLEAR_CHAR_WAIT_STATE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->ClearWaitState(); return 0; @@ -953,17 +1051,17 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CollectParameters(&m_nIp, 5); int handle = -1; uint32 i = CPools::GetVehiclePool()->GetSize(); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float supX = *(float*)&ScriptParams[2]; - float supY = *(float*)&ScriptParams[3]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(3); while (i--) { CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) continue; if (pVehicle->GetVehicleAppearance() != VEHICLE_APPEARANCE_CAR && pVehicle->GetVehicleAppearance() != VEHICLE_APPEARANCE_BIKE) continue; - if (ScriptParams[4] != pVehicle->GetModelIndex() && ScriptParams[4] >= 0) + if (GET_INTEGER_PARAM(4) != pVehicle->GetModelIndex() && GET_INTEGER_PARAM(4) >= 0) continue; if (pVehicle->VehicleCreatedBy != RANDOM_VEHICLE) continue; @@ -971,30 +1069,30 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) continue; handle = CPools::GetVehiclePool()->GetIndex(pVehicle); } - ScriptParams[0] = handle; + SET_INTEGER_PARAM(0, handle); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_SET_CAN_BURST_CAR_TYRES: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - pVehicle->bTyresDontBurst = !ScriptParams[1]; + pVehicle->bTyresDontBurst = !GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_PLAYER_AUTO_AIM: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - pPed->bDoomAim = ScriptParams[1]; + pPed->bDoomAim = GET_INTEGER_PARAM(1); return 0; } case COMMAND_FIRE_HUNTER_GUN: { CollectParameters(&m_nIp, 1); - CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle *pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (CTimer::GetTimeInMilliseconds() > pVehicle->m_nGunFiringTime + 150) { CWeapon gun(WEAPONTYPE_HELICANNON, 5000); CVector worldGunPos = (pVehicle->GetMatrix() * vecHunterGunPos) + (CTimer::GetTimeStep() * pVehicle->m_vecMoveSpeed); @@ -1007,15 +1105,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) } case COMMAND_SET_PROPERTY_AS_OWNED: CollectParameters(&m_nIp, 1); - CStats::AddPropertyAsOwned(ScriptParams[0]); + CStats::AddPropertyAsOwned(GET_INTEGER_PARAM(0)); return 0; case COMMAND_ADD_BLOOD_RING_KILLS: CollectParameters(&m_nIp, 1); - CStats::AddNumBloodRingKills(ScriptParams[0]); + CStats::AddNumBloodRingKills(GET_INTEGER_PARAM(0)); return 0; case COMMAND_SET_LONGEST_TIME_IN_BLOOD_RING: CollectParameters(&m_nIp, 1); - CStats::LongestTimeInBloodRing(ScriptParams[0]); + CStats::LongestTimeInBloodRing(GET_INTEGER_PARAM(0)); return 0; case COMMAND_REMOVE_EVERYTHING_FOR_HUGE_CUTSCENE: { @@ -1025,9 +1123,9 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_IS_PLAYER_TOUCHING_VEHICLE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); CPhysical* pTestedEntity = pPed; if (pPed->bInVehicle && pPed->m_pMyVehicle) pTestedEntity = pPed->m_pMyVehicle; @@ -1038,15 +1136,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_CHECK_FOR_PED_MODEL_AROUND_PLAYER: { CollectParameters(&m_nIp, 6); - CVector d1 = CWorld::Players[ScriptParams[0]].GetPos() - *(CVector*)&ScriptParams[1]; - CVector d2 = CWorld::Players[ScriptParams[0]].GetPos() + *(CVector*)&ScriptParams[1]; + CVector d1 = CWorld::Players[GET_INTEGER_PARAM(0)].GetPos() - GET_VECTOR_PARAM(1); + CVector d2 = CWorld::Players[GET_INTEGER_PARAM(0)].GetPos() + GET_VECTOR_PARAM(1); int i = CPools::GetPedPool()->GetSize(); bool result = false; while (i--) { CPed* pPed = CPools::GetPedPool()->GetSlot(i); if (!pPed) continue; - if (ScriptParams[4] != pPed->GetModelIndex() && ScriptParams[5] != pPed->GetModelIndex()) + if (GET_INTEGER_PARAM(4) != pPed->GetModelIndex() && GET_INTEGER_PARAM(5) != pPed->GetModelIndex()) continue; if (pPed->IsWithinArea(d1.x, d1.y, d1.z, d2.x, d2.y, d2.z)) result = true; @@ -1057,7 +1155,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_CLEAR_CHAR_FOLLOW_PATH: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); if (pPed->GetPedState() == PED_FOLLOW_PATH) { pPed->RestorePreviousState(); @@ -1068,15 +1166,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_CAN_BE_SHOT_IN_VEHICLE: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bCanBeShotInVehicle = ScriptParams[1]; + pPed->bCanBeShotInVehicle = GET_INTEGER_PARAM(1); return 0; } case COMMAND_ATTACH_CUTSCENE_OBJECT_TO_VEHICLE: { CollectParameters(&m_nIp, 2); - CCutsceneMgr::AttachObjectToParent(CPools::GetObjectPool()->GetAt(ScriptParams[0]), CPools::GetVehiclePool()->GetAt(ScriptParams[1])); + CCutsceneMgr::AttachObjectToParent(CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)), CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1))); return 0; } case COMMAND_LOAD_MISSION_TEXT: @@ -1090,39 +1188,48 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_TONIGHTS_EVENT: { CollectParameters(&m_nIp, 1); - CScrollBar::TonightsEvent = ScriptParams[0]; + CScrollBar::TonightsEvent = GET_INTEGER_PARAM(0); return 0; } case COMMAND_CLEAR_CHAR_LAST_DAMAGE_ENTITY: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); if (pPed) pPed->m_lastDamEntity = nil; else debug("CLEAR_CHAR_LAST_DAMAGE_ENTITY - Character doesn't exist\n"); return 0; } - //case COMMAND_CLEAR_CAR_LAST_DAMAGE_ENTITY: + case COMMAND_CLEAR_CAR_LAST_DAMAGE_ENTITY: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + if (pVehicle) + pVehicle->m_pLastDamageEntity = nil; + else + debug("CLEAR_CAR_LAST_DAMAGE_ENTITY - Car doesn't exist\n"); + return 0; + } case COMMAND_FREEZE_OBJECT_POSITION: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->bIsFrozen = ScriptParams[1]; - pObject->bInfiniteMass = ScriptParams[1]; + pObject->bIsFrozen = GET_INTEGER_PARAM(1); + pObject->bInfiniteMass = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_PLAYER_HAS_MET_DEBBIE_HARRY: { CollectParameters(&m_nIp, 1); - CTheScripts::bPlayerHasMetDebbieHarry = ScriptParams[0]; + CTheScripts::bPlayerHasMetDebbieHarry = GET_INTEGER_PARAM(0); return 0; } case COMMAND_SET_RIOT_INTENSITY: { CollectParameters(&m_nIp, 1); - CTheScripts::RiotIntensity = ScriptParams[0]; + CTheScripts::RiotIntensity = GET_INTEGER_PARAM(0); return 0; } //case COMMAND_IS_CAR_IN_ANGLED_AREA_2D: @@ -1132,27 +1239,28 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) { CollectParameters(&m_nIp, 8); CGameLogic::SetUpShortCut( - *(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3], - *(CVector*)&ScriptParams[4], *(float*)&ScriptParams[7]); + GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3), + GET_VECTOR_PARAM(4), GET_FLOAT_PARAM(7)); return 0; } case COMMAND_CLEAR_TAXI_SHORTCUT: CGameLogic::ClearShortCut(); + CGameLogic::RemoveShortCutDropOffPointForMission(); return 0; //case COMMAND_SET_CHAR_OBJ_GOTO_CAR_ON_FOOT: //case COMMAND_GET_CLOSEST_WATER_NODE: case COMMAND_ADD_PORN_LEAFLET_TO_RUBBISH: CollectParameters(&m_nIp, 1); - CStats::PamphletMissionPassed = ScriptParams[0]; + CStats::PamphletMissionPassed = GET_INTEGER_PARAM(0); return 0; case COMMAND_CREATE_CLOTHES_PICKUP: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_CLOTHES, PICKUP_ON_STREET, ScriptParams[3]); + SET_INTEGER_PARAM(0, CPickups::GenerateNewOne(pos, MI_PICKUP_CLOTHES, PICKUP_ON_STREET, GET_INTEGER_PARAM(3))); // TODO: gpModelIndices StoreParameters(&m_nIp, 1); return 0; } @@ -1160,30 +1268,32 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_MAKE_PLAYER_FIRE_PROOF: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_bFireproof = ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_bFireproof = GET_INTEGER_PARAM(1); return 0; } case COMMAND_INCREASE_PLAYER_MAX_HEALTH: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_nMaxHealth += ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_nMaxHealth += GET_INTEGER_PARAM(1); pPlayerInfo->m_pPed->m_fHealth = pPlayerInfo->m_nMaxHealth; + CHud::m_ItemToFlash = ITEM_HEALTH; return 0; } case COMMAND_INCREASE_PLAYER_MAX_ARMOUR: { CollectParameters(&m_nIp, 2); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - pPlayerInfo->m_nMaxArmour += ScriptParams[1]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + pPlayerInfo->m_nMaxArmour += GET_INTEGER_PARAM(1); pPlayerInfo->m_pPed->m_fArmour = pPlayerInfo->m_nMaxArmour; + CHud::m_ItemToFlash = ITEM_ARMOUR; return 0; } case COMMAND_CREATE_RANDOM_CHAR_AS_DRIVER: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); CPed* pPed = CPopulation::AddPedInCar(pVehicle, true); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; @@ -1205,16 +1315,16 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) pVehicle->bEngineOn = true; pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); CPopulation::ms_nTotalMissionPeds++; - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_CREATE_RANDOM_CHAR_AS_PASSENGER: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); CPed* pPed = CPopulation::AddPedInCar(pVehicle, false); pPed->CharCreatedBy = MISSION_CHAR; pPed->bRespondsToThreats = false; @@ -1226,8 +1336,8 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) pPed->SetOrientation(0.0f, 0.0f, 0.0f); CPopulation::ms_nTotalMissionPeds++; pVehicle->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pVehicle->GetPosition()); - if (ScriptParams[1] >= 0) - pVehicle->AddPassenger(pPed, ScriptParams[1]); + if (GET_INTEGER_PARAM(1) >= 0) + pVehicle->AddPassenger(pPed, GET_INTEGER_PARAM(1)); else pVehicle->AddPassenger(pPed); @@ -1235,32 +1345,32 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) pPed->m_pMyVehicle->RegisterReference((CEntity**)&pPed->m_pMyVehicle); pPed->bInVehicle = true; pPed->SetPedState(PED_DRIVING); - ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); + SET_INTEGER_PARAM(0, CPools::GetPedPool()->GetIndex(pPed)); StoreParameters(&m_nIp, 1); if (m_bIsMissionScript) - CTheScripts::MissionCleanUp.AddEntityToList(ScriptParams[0], CLEANUP_CHAR); + CTheScripts::MissionCleanUp.AddEntityToList(GET_INTEGER_PARAM(0), CLEANUP_CHAR); return 0; } case COMMAND_SET_CHAR_IGNORE_THREATS_BEHIND_OBJECTS: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bIgnoreThreatsBehindObjects = ScriptParams[1]; + pPed->bIgnoreThreatsBehindObjects = GET_INTEGER_PARAM(1); return 0; } case COMMAND_ENSURE_PLAYER_HAS_DRIVE_BY_WEAPON: { CollectParameters(&m_nIp, 2); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); if (pPed->bInVehicle) { if (pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_eWeaponType) { - if (pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_nAmmoTotal < ScriptParams[1]) - pPed->SetAmmo(pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_eWeaponType, ScriptParams[1]); + if (pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_nAmmoTotal < GET_INTEGER_PARAM(1)) + pPed->SetAmmo(pPed->GetWeapon(WEAPONSLOT_SUBMACHINEGUN).m_eWeaponType, GET_INTEGER_PARAM(1)); } else { - pPed->GiveWeapon(WEAPONTYPE_UZI, ScriptParams[1], true); + pPed->GiveWeapon(WEAPONTYPE_UZI, GET_INTEGER_PARAM(1), true); if (pPed->m_storedWeapon == WEAPONTYPE_UNIDENTIFIED) pPed->m_storedWeapon = pPed->GetWeapon()->m_eWeaponType; pPed->SetCurrentWeapon(WEAPONTYPE_UZI); @@ -1271,7 +1381,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_MAKE_HELI_COME_CRASHING_DOWN: { CollectParameters(&m_nIp, 1); - CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CAutomobile* pHeli = (CAutomobile*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pHeli && pHeli->IsCar() && pHeli->IsRealHeli()); pHeli->bHeliDestroyed = true; return 0; @@ -1279,24 +1389,24 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_ADD_EXPLOSION_NO_SOUND: { CollectParameters(&m_nIp, 4); - CExplosion::AddExplosion(nil, nil, (eExplosionType)ScriptParams[3], *(CVector*)&ScriptParams[0], 0, false); + CExplosion::AddExplosion(nil, nil, (eExplosionType)GET_INTEGER_PARAM(3), GET_VECTOR_PARAM(0), 0, false); return 0; } case COMMAND_SET_OBJECT_AREA_VISIBLE: { CollectParameters(&m_nIp, 2); - CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pObject = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pObject); - pObject->m_area = ScriptParams[1]; + pObject->m_area = GET_INTEGER_PARAM(1); return 0; } //case COMMAND_WAS_VEHICLE_EVER_POLICE: case COMMAND_SET_CHAR_NEVER_TARGETTED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bNeverEverTargetThisPed = ScriptParams[1]; + pPed->bNeverEverTargetThisPed = GET_INTEGER_PARAM(1); return 0; } case COMMAND_LOAD_UNCOMPRESSED_ANIM: @@ -1315,7 +1425,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_CHAR_CROUCH_WHEN_THREATENED: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); pPed->bCrouchWhenScared = true; return 0; @@ -1323,7 +1433,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_IS_CHAR_IN_ANY_POLICE_VEHICLE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle->IsLawEnforcementVehicle() && @@ -1332,17 +1442,20 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) } case COMMAND_DOES_CHAR_EXIST: CollectParameters(&m_nIp, 1); - UpdateCompareFlag(CPools::GetPedPool()->GetAt(ScriptParams[0]) != 0); + UpdateCompareFlag(CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)) != 0); return 0; case COMMAND_DOES_VEHICLE_EXIST: { - // TODO CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); bool bExist = false; if (pVehicle) { - int index = CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pVehicle); - bExist = (index >= 0 && index <= NUMVEHICLES); // TODO: FIX_BUGS + int index = GET_INTEGER_PARAM(0) >> 8; +#ifdef FIX_BUGS + bExist = (index >= 0 && index < NUMVEHICLES); // epic fail +#else + bExist = (index > 0 && index < NUMVEHICLES); +#endif } UpdateCompareFlag(bExist); return 0; @@ -1351,20 +1464,20 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_ADD_SHORT_RANGE_SPRITE_BLIP_FOR_CONTACT_POINT: { CollectParameters(&m_nIp, 4); - CVector pos = *(CVector*)&ScriptParams[0]; + CVector pos = GET_VECTOR_PARAM(0); if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); CRadar::GetActualBlipArrayIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); int id = CRadar::SetShortRangeCoordBlip(BLIP_COORD, pos, 2, BLIP_DISPLAY_BOTH); - CRadar::SetBlipSprite(id, ScriptParams[3]); - ScriptParams[0] = id; + CRadar::SetBlipSprite(id, GET_INTEGER_PARAM(3)); + SET_INTEGER_PARAM(0, id); StoreParameters(&m_nIp, 1); return 0; } case COMMAND_IS_CHAR_STUCK: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->m_nWaitState == WAITSTATE_STUCK); return 0; @@ -1372,15 +1485,15 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_ALL_TAXIS_HAVE_NITRO: { CollectParameters(&m_nIp, 1); - CVehicle::bAllTaxisHaveNitro = ScriptParams[0] != 0; + CVehicle::bAllTaxisHaveNitro = GET_INTEGER_PARAM(0) != 0; return 0; } case COMMAND_SET_CHAR_STOP_SHOOT_DONT_SEEK_ENTITY: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pPed->bKindaStayInSamePlace = true; pPed->bStopAndShoot = true; } @@ -1394,9 +1507,9 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_FREEZE_CAR_POSITION_AND_DONT_LOAD_COLLISION: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pVehicle->bIsFrozen = true; pVehicle->bInfiniteMass = true; if (m_bIsMissionScript) { diff --git a/src/control/Script8.cpp b/src/control/Script8.cpp index afa213f2..6de73b82 100644 --- a/src/control/Script8.cpp +++ b/src/control/Script8.cpp @@ -4,7 +4,7 @@ #include "ScriptCommands.h" #include "DMAudio.h" -#if ((defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) && defined MORE_LANGUAGES) +#ifdef MORE_LANGUAGES #include "Frontend.h" #endif #include "GameLogic.h" @@ -12,13 +12,10 @@ #ifdef MISSION_REPLAY #include "GenericGameStorage.h" #endif -#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT) -#include "General.h" -#include "maths.h" -#endif #include "Hud.h" #include "Pad.h" #include "PedAttractor.h" +#include "Pickups.h" #include "Population.h" #include "Pools.h" #include "RpAnimBlend.h" @@ -34,14 +31,13 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) switch (command) { case COMMAND_REGISTER_VIGILANTE_LEVEL: CollectParameters(&m_nIp, 1); - CStats::RegisterLevelVigilanteMission(ScriptParams[0]); + CStats::RegisterLevelVigilanteMission(GET_INTEGER_PARAM(0)); return 0; case COMMAND_CLEAR_ALL_CHAR_ANIMS: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); - script_assert(pPed); - if (!pPed->bInVehicle) { + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + if (pPed && pPed->GetPedState() != PED_DRIVING && !pPed->GetPedState() != PED_AIM_GUN) { pPed->m_pVehicleAnim = nil; pPed->RestartNonPartialAnims(); RpAnimBlendClumpRemoveAllAssociations(pPed->GetClump()); @@ -62,7 +58,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE: CollectParameters(&m_nIp, 2); - CGarages::SetMaxNumStoredCarsForGarage(ScriptParams[0], ScriptParams[1]); + CGarages::SetMaxNumStoredCarsForGarage(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_WANTED_STARS_ARE_FLASHING: { @@ -72,25 +68,25 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_SET_ALLOW_HURRICANES: CollectParameters(&m_nIp, 1); - CStats::NoMoreHurricanes = ScriptParams[0]; + CStats::NoMoreHurricanes = GET_INTEGER_PARAM(0); return 0; case COMMAND_PLAY_ANNOUNCEMENT: { CollectParameters(&m_nIp, 1); - DMAudio.PlayRadioAnnouncement(ScriptParams[0] + STREAMED_SOUND_NEWS_A); + DMAudio.PlayRadioAnnouncement(GET_INTEGER_PARAM(0) + STREAMED_SOUND_NEWS_A); return 0; } case COMMAND_SET_PLAYER_IS_IN_STADIUM: { CollectParameters(&m_nIp, 1); - CTheScripts::bPlayerIsInTheStatium = ScriptParams[0]; + CTheScripts::bPlayerIsInTheStatium = GET_INTEGER_PARAM(0); return 0; } case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; - ScriptParams[0] = pPlayerInfo->m_pPed->m_nLastBusFareCollected; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; + SET_INTEGER_PARAM(0, pPlayerInfo->m_pPed->m_nLastBusFareCollected); pPlayerInfo->m_pPed->m_nLastBusFareCollected = 0; StoreParameters(&m_nIp, 1); return 0; @@ -98,11 +94,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(1)); script_assert(pVehicle); - ScriptParams[0] = 0; + SET_INTEGER_PARAM(0, 0); if (pPed->m_objective == OBJECTIVE_NONE && !pPed->bHasAlreadyUsedAttractor) { C2dEffect* pEffect = (C2dEffect*)GetPedAttractorManager()->GetEffectForIceCreamVan(pVehicle, pPed->GetPosition()); // has to be casted, because inner methods are const if (pEffect) { @@ -111,7 +107,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) if ((pPed->GetPosition() - pos).MagnitudeSqr() < SQR(20.0f)) { if (GetPedAttractorManager()->HasEmptySlot(pEffect) && GetPedAttractorManager()->IsApproachable(pEffect, pVehicle->GetMatrix(), 0, pPed)) { if (GetPedAttractorManager()->RegisterPedWithAttractor(pPed, pEffect, pVehicle->GetMatrix())) - ScriptParams[0] = 1; + SET_INTEGER_PARAM(0, 1); } } } @@ -121,16 +117,17 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_DISPLAY_RADAR: CollectParameters(&m_nIp, 1); - CHud::m_HideRadar = ScriptParams[0] == 0; + CHud::m_HideRadar = GET_INTEGER_PARAM(0) == 0; + // on PS2 two flags are set, on mobile none return 0; case COMMAND_REGISTER_BEST_POSITION: CollectParameters(&m_nIp, 2); - CStats::RegisterBestPosition(ScriptParams[0], ScriptParams[1]); + CStats::RegisterBestPosition(GET_INTEGER_PARAM(0), GET_INTEGER_PARAM(1)); return 0; case COMMAND_IS_PLAYER_IN_INFO_ZONE: { CollectParameters(&m_nIp, 1); - CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + CPlayerInfo* pPlayerInfo = &CWorld::Players[GET_INTEGER_PARAM(0)]; char key[KEY_LENGTH_IN_SCRIPT]; memset(key, 0, KEY_LENGTH_IN_SCRIPT); CTheScripts::ReadTextLabelFromScript(&m_nIp, key); @@ -143,7 +140,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); if (pPed->m_attractor) GetPedAttractorManager()->DeRegisterPed(pPed, pPed->m_attractor); @@ -155,7 +152,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_HAS_CHAR_ATTEMPTED_ATTRACTOR: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bHasAlreadyUsedAttractor); return 0; @@ -163,9 +160,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_SET_LOAD_COLLISION_FOR_CAR_FLAG: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pVehicle->bDontLoadCollision = false; if (m_bMissionFlag) { CWorld::Remove(pVehicle); @@ -186,9 +183,9 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_SET_LOAD_COLLISION_FOR_CHAR_FLAG: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - if (ScriptParams[1]) { + if (GET_INTEGER_PARAM(1)) { pPed->bDontLoadCollision = false; if (m_bMissionFlag) { CWorld::Remove(pPed); @@ -210,31 +207,31 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_ADD_BIG_GUN_FLASH: { CollectParameters(&m_nIp, 6); - CWeapon::AddGunFlashBigGuns(*(CVector*)&ScriptParams[0], *(CVector*)&ScriptParams[3]); + CWeapon::AddGunFlashBigGuns(GET_VECTOR_PARAM(0), GET_VECTOR_PARAM(3)); return 0; } case COMMAND_HAS_CHAR_BOUGHT_ICE_CREAM: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(pPed->bBoughtIceCream); return 0; } case COMMAND_GET_PROGRESS_PERCENTAGE: - *(float*)&ScriptParams[0] = CStats::GetPercentageProgress(); + SET_FLOAT_PARAM(0, CStats::GetPercentageProgress()); StoreParameters(&m_nIp, 1); return 0; case COMMAND_SET_SHORTCUT_PICKUP_POINT: { CollectParameters(&m_nIp, 4); - CGameLogic::AddShortCutPointAfterDeath(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]); + CGameLogic::AddShortCutPointAfterDeath(GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3)); return 0; } case COMMAND_SET_SHORTCUT_DROPOFF_POINT_FOR_MISSION: { CollectParameters(&m_nIp, 4); - CGameLogic::AddShortCutDropOffPointForMission(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]); + CGameLogic::AddShortCutDropOffPointForMission(GET_VECTOR_PARAM(0), GET_FLOAT_PARAM(3)); return 0; } case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA: @@ -242,10 +239,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) CollectParameters(&m_nIp, 7); int ped_handle = -1; CVector pos = FindPlayerCoors(); - float x1 = *(float*)&ScriptParams[0]; - float y1 = *(float*)&ScriptParams[1]; - float x2 = *(float*)&ScriptParams[2]; - float y2 = *(float*)&ScriptParams[3]; + float x1 = GET_FLOAT_PARAM(0); + float y1 = GET_FLOAT_PARAM(1); + float x2 = GET_FLOAT_PARAM(2); + float y2 = GET_FLOAT_PARAM(3); int i = CPools::GetPedPool()->GetSize(); while (--i && ped_handle == -1) { CPed* pPed = CPools::GetPedPool()->GetSlot(i); @@ -267,7 +264,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) continue; if (pPed->m_attractor) continue; - if (!ThisIsAValidRandomPed(pPed->m_nPedType, ScriptParams[4], ScriptParams[5], ScriptParams[6])) + if (!ThisIsAValidRandomPed(pPed->m_nPedType, GET_INTEGER_PARAM(4), GET_INTEGER_PARAM(5), GET_INTEGER_PARAM(6))) continue; if (pPed->bIsLeader || pPed->m_leader) continue; @@ -285,7 +282,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) if (m_bIsMissionScript) CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR); } - ScriptParams[0] = ped_handle; + SET_INTEGER_PARAM(0, ped_handle); StoreParameters(&m_nIp, 1); return 0; } @@ -294,10 +291,10 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) { CollectParameters(&m_nIp, 4); uint32 i = CPools::GetVehiclePool()->GetSize(); - float infX = *(float*)&ScriptParams[0]; - float infY = *(float*)&ScriptParams[1]; - float supX = *(float*)&ScriptParams[2]; - float supY = *(float*)&ScriptParams[3]; + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(3); while (i--) { CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); if (!pVehicle) @@ -309,22 +306,23 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) } case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS: CollectParameters(&m_nIp, 2); - CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + ScriptParams[0]), !!ScriptParams[1]); + CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + GET_INTEGER_PARAM(0)), !!GET_INTEGER_PARAM(1)); return 0; case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR: { CollectParameters(&m_nIp, 2); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); - pPed->bHeldHostageInCar = ScriptParams[1]; + pPed->bHeldHostageInCar = GET_INTEGER_PARAM(1); + pPed->b1A4_2 = GET_INTEGER_PARAM(1); return 0; } case COMMAND_SET_VEHICLE_TO_FADE_IN: { CollectParameters(&m_nIp, 2); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pVehicle); - CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), ScriptParams[1]); + CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), GET_INTEGER_PARAM(1)); return 0; } case COMMAND_REGISTER_ODDJOB_MISSION_PASSED: @@ -336,7 +334,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_IS_PLAYER_IN_SHORTCUT_TAXI: { CollectParameters(&m_nIp, 1); - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; + CPed* pPed = CWorld::Players[GET_INTEGER_PARAM(0)].m_pPed; script_assert(pPed); UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle == CGameLogic::pShortCutTaxi); return 0; @@ -344,7 +342,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_IS_CHAR_DUCKING: { CollectParameters(&m_nIp, 1); - CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); script_assert(pPed); UpdateCompareFlag(RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_DUCK_DOWN) != nil); return 0; @@ -352,24 +350,24 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI: { CollectParameters(&m_nIp, 3); - CObject* pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + CObject* pHeli = CPools::GetObjectPool()->GetAt(GET_INTEGER_PARAM(0)); bool found = false; float waterLevel = -1000.0f; CVector pos = pHeli->GetPosition(); - float radius = *(float*)&ScriptParams[1]; + float radius = GET_FLOAT_PARAM(1); float ground = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &found); if (!CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false)) waterLevel = 0.0f; if (waterLevel > ground) ground = waterLevel; - if (ScriptParams[2] > 8) - ScriptParams[2] = 8; - CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, ScriptParams[2]); + if (GET_INTEGER_PARAM(2) > 8) + SET_INTEGER_PARAM(2, 8); + CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, GET_INTEGER_PARAM(2)); return 0; } case COMMAND_REGISTER_FIRE_LEVEL: CollectParameters(&m_nIp, 1); - CStats::RegisterLevelFireMission(ScriptParams[0]); + CStats::RegisterLevelFireMission(GET_INTEGER_PARAM(0)); return 0; case COMMAND_IS_AUSTRALIAN_GAME: UpdateCompareFlag(false); // should we make some check? @@ -377,7 +375,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_DISARM_CAR_BOMB: { CollectParameters(&m_nIp, 1); - CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); if (pVehicle->m_bombType != CARBOMB_NONE) { pVehicle->m_bombType = CARBOMB_NONE; pVehicle->m_pBombRigger = nil; @@ -394,48 +392,135 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) #endif return 0; case COMMAND_1442: - script_assert(false); - return 0; - case COMMAND_1443: - script_assert(false); + CollectParameters(&m_nIp, 4); return 0; - case COMMAND_1444: - script_assert(false); + //case COMMAND_1443: + case COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS: + { + CollectParameters(&m_nIp, 4); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float X2 = GET_FLOAT_PARAM(2); + float Y2 = GET_FLOAT_PARAM(3); + float fDistance = Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2)); + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; - case COMMAND_1445: - script_assert(false); + } + case COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS: + { + CollectParameters(&m_nIp, 6); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float Z1 = GET_FLOAT_PARAM(2); + float X2 = GET_FLOAT_PARAM(3); + float Y2 = GET_FLOAT_PARAM(4); + float Z2 = GET_FLOAT_PARAM(5); + float fDistance = Sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2) + (Z1 - Z2) * (Z1 - Z2)); + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; - case COMMAND_1446: - script_assert(false); + } + case COMMAND_DOT_PRODUCT_2D: + { + CollectParameters(&m_nIp, 4); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float X2 = GET_FLOAT_PARAM(2); + float Y2 = GET_FLOAT_PARAM(3); + float fDistance = X1 * X2 + Y1 * Y2; + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; - case COMMAND_1447: - script_assert(false); + } + case COMMAND_DOT_PRODUCT_3D: + { + CollectParameters(&m_nIp, 4); + float X1 = GET_FLOAT_PARAM(0); + float Y1 = GET_FLOAT_PARAM(1); + float Z1 = GET_FLOAT_PARAM(2); + float X2 = GET_FLOAT_PARAM(3); + float Y2 = GET_FLOAT_PARAM(4); + float Z2 = GET_FLOAT_PARAM(5); + float fDistance = X1 * X2 + Y1 * Y2 + Z1 * Z2; + SET_FLOAT_PARAM(0, fDistance); + StoreParameters(&m_nIp, 1); return 0; - case COMMAND_1448: - script_assert(false); + } + case COMMAND_DEBUG_PRINT_WITH_1_FLOAT: return 0; - case COMMAND_1449: - script_assert(false); + case COMMAND_DEBUG_PRINT_WITH_2_FLOATS: return 0; - case COMMAND_1450: - script_assert(false); + case COMMAND_DEBUG_PRINT_WITH_3_FLOATS: return 0; - case COMMAND_1451: + case COMMAND_GET_PAD_BUTTON_STATE: + { CollectParameters(&m_nIp, 1); - // TODO (GET_PAD_BUTTON_STATE) - ScriptParams[0] = 0; + switch (GET_INTEGER_PARAM(0)) { + case 0: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetOddJobTrigger()); break; + case 1: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetBrake()); break; + case 2: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSteeringLeftRight()); break; + case 3: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSteeringUpDown()); break; + case 4: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunLeftRight()); break; + case 5: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunUpDown()); break; + case 6: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetPedWalkLeftRight()); break; + case 7: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetPedWalkUpDown()); break; + case 8: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookLeft()); break; + case 9: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookRight()); break; + case 10: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookBehindForCar()); break; + case 11: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetLookBehindForPed()); break; + case 12: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetHorn()); break; + case 13: SET_INTEGER_PARAM(0, CPad::GetPad(0)->HornJustDown()); break; + case 14: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetCarGunFired()); break; + case 15: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CarGunJustDown()); break; + case 16: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetHandBrake()); break; + case 17: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetBrake()); break; + case 18: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetExitVehicle()); break; + case 19: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ExitVehicleJustDown()); break; + case 20: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetWeapon()); break; + case 21: SET_INTEGER_PARAM(0, CPad::GetPad(0)->WeaponJustDown()); break; + case 22: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetAccelerate()); break; + case 23: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleCameraModeUpJustDown()); break; + case 24: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleWeaponLeftJustDown()); break; + case 25: SET_INTEGER_PARAM(0, CPad::GetPad(0)->CycleWeaponRightJustDown()); break; + case 26: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetTarget()); break; + case 27: SET_INTEGER_PARAM(0, CPad::GetPad(0)->TargetJustDown()); break; + case 28: SET_INTEGER_PARAM(0, CPad::GetPad(0)->JumpJustDown()); break; + case 29: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSprint()); break; + case 30: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ShiftTargetLeftJustDown()); break; + case 31: SET_INTEGER_PARAM(0, CPad::GetPad(0)->ForceCameraBehindPlayer()); break; + case 32: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperZoomIn()); break; + case 33: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperZoomOut()); break; + case 34: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperModeLookLeftRight()); break; + case 35: SET_INTEGER_PARAM(0, CPad::GetPad(0)->SniperModeLookUpDown()); break; + case 36: SET_INTEGER_PARAM(0, CPad::GetPad(0)->LookAroundLeftRight()); break; + case 37: SET_INTEGER_PARAM(0, CPad::GetPad(0)->LookAroundUpDown()); break; + case 38: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiLeft()); break; + case 39: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiRight()); break; + case 40: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiUp()); break; + case 41: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiDown()); break; + case 42: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiSelect()); break; + case 43: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GuiBack()); break; + case 44: SET_INTEGER_PARAM(0, CPad::GetPad(0)->GetSkipCutscene()); if (GET_INTEGER_PARAM(0)) TheCamera.m_bIgnoreFadingStuffForMusic = false; break; // spectacular hack + } StoreParameters(&m_nIp, 1); return 0; - case COMMAND_1452: - script_assert(false); + } + case COMMAND_SET_NAVIGATION_ARROW: + { + CollectParameters(&m_nIp, 3); + // cNavArrow::SetTarget(GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(0), GET_FLOAT_PARAM(0)); // TODO, although it's unused return 0; - case COMMAND_1453: - script_assert(false); + } + case COMMAND_CLEAR_NAVIGATION_ARROW: + { + // cNavArrow::ClearTarget(); // TODO, although it's unused return 0; + } case COMMAND_CALL: - case COMMAND_NOTCALL: + case COMMAND_CALLNOT: { - m_anStack[m_nStackPointer++] = m_nIp | BIT(STACKVALUE_IS_FUNCTION_CALL_BIT) | ((command == COMMAND_NOTCALL) ? BIT(STACKVALUE_INVERT_RETURN_BIT) : 0); + m_anStack[m_nStackPointer++] = m_nIp | BIT(STACKVALUE_IS_FUNCTION_CALL_BIT) | ((command == COMMAND_CALLNOT) ? BIT(STACKVALUE_INVERT_RETURN_BIT) : 0); uint8 nInputParams = CTheScripts::Read1ByteFromScript(&m_nIp); uint8 nOutputParameters = CTheScripts::Read1ByteFromScript(&m_nIp); uint8 nLocalsOffset = CTheScripts::Read1ByteFromScript(&m_nIp); @@ -445,676 +530,245 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) CollectParameters(&m_nIp, nInputParams, &m_anLocalVariables[m_nLocalsPointer + nLocalsOffset]); m_nLocalsPointer += nLocalsOffset; m_anStack[m_nStackPointer - 1] |= (m_nIp - nIPBeforeParameters) << STACKVALUE_IP_PARAMS_OFFSET; - if (ScriptParams[0] < 0) - m_nIp = CTheScripts::MainScriptSize - ScriptParams[0]; + if (GET_INTEGER_PARAM(0) < 0) + m_nIp = CTheScripts::MainScriptSize - GET_INTEGER_PARAM(0); else - m_nIp = ScriptParams[0]; + m_nIp = GET_INTEGER_PARAM(0); return 0; } - case COMMAND_1456: - script_assert(false); - return 0; - case COMMAND_1457: - script_assert(false); - return 0; - case COMMAND_1458: - script_assert(false); - return 0; - case COMMAND_1459: - script_assert(false); - return 0; - case COMMAND_1460: - script_assert(false); - return 0; - case COMMAND_1461: - script_assert(false); - return 0; - case COMMAND_1462: - script_assert(false); - return 0; - case COMMAND_1463: - script_assert(false); - return 0; - case COMMAND_1464: - script_assert(false); - return 0; - case COMMAND_1465: - script_assert(false); - return 0; - case COMMAND_1466: - script_assert(false); - return 0; - case COMMAND_1467: - script_assert(false); - return 0; - case COMMAND_1468: - script_assert(false); - return 0; - case COMMAND_1469: - script_assert(false); - return 0; - case COMMAND_1470: - script_assert(false); - return 0; - case COMMAND_1471: - script_assert(false); - return 0; - case COMMAND_1472: - script_assert(false); - return 0; - case COMMAND_1473: - script_assert(false); - return 0; - case COMMAND_1474: - script_assert(false); - return 0; - case COMMAND_1475: - script_assert(false); - return 0; - case COMMAND_1476: - script_assert(false); - return 0; - case COMMAND_1477: - script_assert(false); - return 0; - case COMMAND_1478: - script_assert(false); - return 0; - case COMMAND_1479: - CollectParameters(&m_nIp, 2); - // TODO (SET_CHAR_ONLY_ENTER_BACK_DOOR) - return 0; - case COMMAND_1480: - script_assert(false); - return 0; - case COMMAND_1481: - script_assert(false); - return 0; - case COMMAND_1482: - script_assert(false); - return 0; - case COMMAND_1483: - script_assert(false); - return 0; - case COMMAND_1484: - script_assert(false); - return 0; - case COMMAND_1485: - script_assert(false); - return 0; - case COMMAND_1486: - script_assert(false); - return 0; - case COMMAND_1487: - script_assert(false); - return 0; - case COMMAND_1488: - script_assert(false); - return 0; - case COMMAND_1489: - script_assert(false); - return 0; - case COMMAND_1490: - script_assert(false); - return 0; - case COMMAND_1491: - script_assert(false); - return 0; - case COMMAND_1492: - script_assert(false); - return 0; - case COMMAND_1493: - script_assert(false); - return 0; - case COMMAND_1494: - script_assert(false); - return 0; - case COMMAND_1495: - script_assert(false); - return 0; - case COMMAND_1496: - script_assert(false); - return 0; - case COMMAND_1497: - script_assert(false); - return 0; - case COMMAND_1498: - script_assert(false); - return 0; - case COMMAND_1499: - script_assert(false); + case COMMAND_IS_CAR_AUTOMOBILE: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_FIRST_VEHICLE && pVehicle->GetModelIndex() < MI_FERRY); return 0; - default: - script_assert(0); } - return -1; -} - -int8 CRunningScript::ProcessCommands1500To1599(int32 command) -{ - switch (command) { - case COMMAND_1500: - script_assert(false); - return 0; - case COMMAND_1501: - script_assert(false); - return 0; - case COMMAND_1502: - script_assert(false); - return 0; - case COMMAND_1503: - script_assert(false); - return 0; - case COMMAND_1504: - script_assert(false); - return 0; - case COMMAND_1505: - script_assert(false); - return 0; - case COMMAND_1506: - script_assert(false); - return 0; - case COMMAND_1507: - script_assert(false); - return 0; - case COMMAND_1508: - script_assert(false); - return 0; - case COMMAND_1509: - script_assert(false); - return 0; - case COMMAND_1510: - script_assert(false); - return 0; - case COMMAND_1511: - script_assert(false); - return 0; - case COMMAND_1512: - script_assert(false); - return 0; - case COMMAND_1513: - script_assert(false); - return 0; - case COMMAND_1514: - script_assert(false); - return 0; - case COMMAND_1515: - script_assert(false); - return 0; - case COMMAND_1516: - script_assert(false); - return 0; - case COMMAND_1517: - script_assert(false); + case COMMAND_IS_CAR_BIKE: + { + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_ANGEL && pVehicle->GetModelIndex() <= MI_SANCHEZ); return 0; - case COMMAND_1518: - // TODO (?) - UpdateCompareFlag(true); + } return 0; - case COMMAND_1519: + case COMMAND_IS_CAR_PLANE: + { CollectParameters(&m_nIp, 1); - // TODO (SET_NUMBER_USJ_FOUND?) + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_AIRTRAIN && pVehicle->GetModelIndex() <= MI_DEADDODO); return 0; - case COMMAND_1520: + } + case COMMAND_IS_CAR_HELI: + { CollectParameters(&m_nIp, 1); - // TODO (SET_TOTAL_HIDDEN_PACKAGES?) - return 0; - case COMMAND_1521: - script_assert(false); - return 0; - case COMMAND_1522: - script_assert(false); - return 0; - case COMMAND_1523: - script_assert(false); - return 0; - case COMMAND_1524: - script_assert(false); - return 0; - case COMMAND_1525: - script_assert(false); - return 0; - case COMMAND_1526: - script_assert(false); - return 0; - case COMMAND_1527: - script_assert(false); - return 0; - case COMMAND_1528: - script_assert(false); - return 0; - case COMMAND_1529: - script_assert(false); - return 0; - case COMMAND_1530: - script_assert(false); - return 0; - case COMMAND_1531: - script_assert(false); - return 0; - case COMMAND_1532: - script_assert(false); - return 0; - case COMMAND_1533: - script_assert(false); - return 0; - case COMMAND_1534: - script_assert(false); - return 0; - case COMMAND_1535: - script_assert(false); - return 0; - case COMMAND_1536: - script_assert(false); - return 0; - case COMMAND_1537: - script_assert(false); - return 0; - case COMMAND_1538: - script_assert(false); - return 0; - case COMMAND_1539: - //TODO (REGISTER_OUTFIT_CHANGE) - return 0; - case COMMAND_1540: - script_assert(false); - return 0; - case COMMAND_1541: - script_assert(false); - return 0; - case COMMAND_1542: - script_assert(false); - return 0; - case COMMAND_1543: - script_assert(false); - return 0; - case COMMAND_1544: - script_assert(false); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->GetModelIndex() >= MI_ESCAPE && pVehicle->GetModelIndex() <= MI_CHOPPER); return 0; - case COMMAND_1545: - script_assert(false); + } +#ifdef FIX_BUGS + case COMMAND_1476: // they DO have it in script return 0; - case COMMAND_1546: - script_assert(false); +#endif + case COMMAND_RETURN_IF_TRUE: + if (m_bCondResult) { + ReturnFromGosubOrFunction(); + } return 0; - case COMMAND_1547: - script_assert(false); + case COMMAND_RETURN_TRUE_IF_TRUE: + if (m_bCondResult) { + UpdateCompareFlag(false); + ReturnFromGosubOrFunction(); + } return 0; - case COMMAND_1548: - // TODO (GET_ONFOOT_CAMERA_MODE) - ScriptParams[0] = 0; - StoreParameters(&m_nIp, 1); + case COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND: + { + CollectParameters(&m_nIp, 2); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bOnlyAllowedToSitBehind = GET_INTEGER_PARAM(1); return 0; - case COMMAND_1549: + } + case COMMAND_SET_RC_HELI_HEIGHT_LIMIT: CollectParameters(&m_nIp, 1); - // TODO (SET_ONFOOT_CAMERA_MODE?) - return 0; - case COMMAND_1550: - script_assert(false); + // CVehicle::rcHeliHeightLimit = GET_FLOAT_PARAM(0); // TODO return 0; - case COMMAND_1551: - script_assert(false); - return 0; - case COMMAND_1552: - script_assert(false); - return 0; - case COMMAND_1553: - script_assert(false); - return 0; - case COMMAND_1554: - script_assert(false); - return 0; - case COMMAND_1555: + case COMMAND_CREATE_SCRIPT_CORONA: + { + CollectParameters(&m_nIp, 9); + static bool bShowed = false; + if (!bShowed) { + debug("CREATE_SCRIPT_CORONA not implemented"); + bShowed = true; + } + SET_INTEGER_PARAM(0, -1); + StoreParameters(&m_nIp, 1); + } + case COMMAND_REMOVE_SCRIPT_CORONA: CollectParameters(&m_nIp, 1); - // TODO (FREEZE_ONFOOT_CAMERA_MODE?) - return 0; - case COMMAND_1556: - script_assert(false); - return 0; - case COMMAND_1557: - script_assert(false); - return 0; - case COMMAND_1558: - UpdateCompareFlag(false); // TODO return 0; - case COMMAND_1559: - script_assert(false); - return 0; - case COMMAND_1560: - // TODO (IS_E3_BUILD?) - UpdateCompareFlag(false); - return 0; - case COMMAND_1561: - // TODO (check, SET_FS_DESTROYED_FLAG) - CTheScripts::FSDestroyedFlag = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - (int32*)CTheScripts::ScriptSpace; - return 0; - case COMMAND_1562: - script_assert(false); - return 0; - case COMMAND_1563: - script_assert(false); - return 0; - case COMMAND_1564: - script_assert(false); - return 0; - case COMMAND_1565: - script_assert(false); - return 0; - case COMMAND_1566: - script_assert(false); - return 0; - case COMMAND_1567: + case COMMAND_IS_BOAT_IN_WATER: + { CollectParameters(&m_nIp, 1); - // TODO (BUILD_WORLD_GEOMETRY) - return 0; - case COMMAND_1568: - script_assert(false); - return 0; - case COMMAND_1569: - // TODO (IS_MULTIPLAYER_ACTIVE?) - UpdateCompareFlag(false); - return 0; - case COMMAND_1570: - script_assert(false); - return 0; - case COMMAND_1571: - script_assert(false); - return 0; - case COMMAND_1572: - script_assert(false); - return 0; - case COMMAND_1573: - script_assert(false); - return 0; - case COMMAND_1574: - script_assert(false); - return 0; - case COMMAND_1575: - script_assert(false); + CBoat* pVehicle = (CBoat*)CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle && pVehicle->IsBoat()); + UpdateCompareFlag(pVehicle->bBoatInWater); return 0; - case COMMAND_1576: - script_assert(false); - return 0; - case COMMAND_1577: - script_assert(false); - return 0; - case COMMAND_1578: - script_assert(false); - return 0; - case COMMAND_1579: - script_assert(false); - return 0; - case COMMAND_1580: - script_assert(false); - return 0; - case COMMAND_1581: + } + case COMMAND_IS_CAR_DRIVER_BEING_JACKED: { - // TODO (SET_HELP_MESSAGE?) - wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + CollectParameters(&m_nIp, 1); + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pVehicle); + UpdateCompareFlag(pVehicle->bIsBeingCarJacked); return 0; } - case COMMAND_1582: - script_assert(false); - return 0; - case COMMAND_1583: - script_assert(false); - return 0; - case COMMAND_1584: - script_assert(false); - return 0; - case COMMAND_1585: - script_assert(false); - return 0; - case COMMAND_1586: - script_assert(false); - return 0; - case COMMAND_1587: - script_assert(false); - return 0; - case COMMAND_1588: - script_assert(false); - return 0; - case COMMAND_1589: + case COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT: + { CollectParameters(&m_nIp, 2); - // TODO (SWAP_BUILDING?) - return 0; - case COMMAND_1590: - script_assert(false); - return 0; - case COMMAND_1591: - script_assert(false); - return 0; - case COMMAND_1592: - script_assert(false); - return 0; - case COMMAND_1593: - script_assert(false); - return 0; - case COMMAND_1594: - script_assert(false); - return 0; - case COMMAND_1595: - script_assert(false); - return 0; - case COMMAND_1596: - script_assert(false); - return 0; - case COMMAND_1597: - script_assert(false); - return 0; - case COMMAND_1598: - script_assert(false); - return 0; - case COMMAND_1599: - script_assert(false); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(0)); + script_assert(pPed); + pPed->bOnlyAllowedToSitInFront = GET_INTEGER_PARAM(1); return 0; - default: - script_assert(0); } - return -1; -} - -int8 CRunningScript::ProcessCommands1600To1699(int32 command) -{ - switch (command) { - case COMMAND_1600: - script_assert(false); - return 0; - case COMMAND_1601: - script_assert(false); - return 0; - case COMMAND_1602: - script_assert(false); - return 0; - case COMMAND_1603: - script_assert(false); - return 0; - case COMMAND_1604: - script_assert(false); - return 0; - case COMMAND_1605: - script_assert(false); - return 0; - case COMMAND_1606: - script_assert(false); - return 0; - case COMMAND_1607: - CollectParameters(&m_nIp, 1); - // TODO (SET_TOTAL_CARS_FOR_EXPORT) - return 0; - case COMMAND_1608: - script_assert(false); - return 0; - case COMMAND_1609: - script_assert(false); - return 0; - case COMMAND_1610: - script_assert(false); - return 0; - case COMMAND_1611: - script_assert(false); - return 0; - case COMMAND_1612: - script_assert(false); - return 0; - case COMMAND_1613: - script_assert(false); - return 0; - case COMMAND_1614: - script_assert(false); - return 0; - case COMMAND_1615: - // TODO (GET_DEVELOPER_FLAG?) - UpdateCompareFlag(false); - return 0; - case COMMAND_1616: - // TODO (SET_DEVELOPER_FLAG) - return 0; - case COMMAND_1617: - script_assert(false); - return 0; - case COMMAND_1618: - script_assert(false); - return 0; - case COMMAND_1619: - script_assert(false); - return 0; - case COMMAND_1620: - script_assert(false); - return 0; - case COMMAND_1621: + case COMMAND_SET_CAR_TILTED_BY_CHAR: { - wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); CollectParameters(&m_nIp, 2); - // TODO (SET_SUBTITLE_TEXT) + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + CPed* pPed = CPools::GetPedPool()->GetAt(GET_INTEGER_PARAM(1)); + script_assert(pVehicle); + pVehicle->ApplyTurnForce(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(-0.8f, -1.2f)* pPed->m_fMass, + pPed->GetPosition().x - pVehicle->GetPosition().x, pPed->GetPosition().y - pVehicle->GetPosition().y, 0.0f); + DMAudio.PlayOneShot(pVehicle->m_audioEntityId, SOUND_CAR_JERK, 0.0f); return 0; } - case COMMAND_1622: - script_assert(false); - return 0; - case COMMAND_1623: - script_assert(false); - return 0; - case COMMAND_1624: - script_assert(false); - return 0; - case COMMAND_1625: - script_assert(false); - return 0; - case COMMAND_1626: - script_assert(false); - return 0; - case COMMAND_1627: - script_assert(false); - return 0; - case COMMAND_1628: - script_assert(false); - return 0; - case COMMAND_1629: - script_assert(false); - return 0; - case COMMAND_1630: - script_assert(false); - return 0; - case COMMAND_1631: - script_assert(false); - return 0; - case COMMAND_1632: - script_assert(false); - return 0; - case COMMAND_1633: - script_assert(false); - return 0; - case COMMAND_1634: - script_assert(false); - return 0; - case COMMAND_1635: + case COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA: { - char tmp[12]; // TODO - CTheScripts::ReadTextLabelFromScript(&m_nIp, tmp); - m_nIp += KEY_LENGTH_IN_SCRIPT; - // TODO (CHANGE_STORED_PLAYER_OUTFIT?) - return 0; + CollectParameters(&m_nIp, 4); + float X = GET_FLOAT_PARAM(0); + float Y = GET_FLOAT_PARAM(1); + float Z = GET_FLOAT_PARAM(2); + float radius = GET_FLOAT_PARAM(3); + int model = -1; + bool found = false; + for (uint32 i = 0; i < NUMPICKUPS; i++) { + CPickup* pPickup = &CPickups::aPickUps[i]; + if (pPickup->m_eType != PICKUP_NONE) { + CVector fDist = pPickup->m_vecPos - CVector(X, Y, Z); +#ifndef FIX_BUGS // this breaks ALL pickups! + pPickup->m_eModelIndex = 4; +#endif + if (fDist.Magnitude() < radius && pPickup->m_pObject) { + found = true; + model = CPickups::WeaponForModel(pPickup->m_pObject->GetModelIndex()); + } + } + } + SET_INTEGER_PARAM(0, model); + StoreParameters(&m_nIp, 1); } - case COMMAND_1636: - script_assert(false); - return 0; - case COMMAND_1637: - script_assert(false); - return 0; - case COMMAND_1638: - script_assert(false); + case COMMAND_IS_USING_FIRST_PERSON_WEAPON_CAMERA: + UpdateCompareFlag(TheCamera.Using1stPersonWeaponMode()); return 0; - case COMMAND_1639: - script_assert(false); - return 0; - case COMMAND_1640: - CollectParameters(&m_nIp, 2); - // TODO (LOCK_GARAGE?) - return 0; - case COMMAND_1641: - // TODO - UpdateCompareFlag(true); - return 0; - case COMMAND_1642: - script_assert(false); - return 0; - case COMMAND_1643: - script_assert(false); + //case COMMAND_1489: + //case COMMAND_1490: + //case COMMAND_1491: + case COMMAND_SET_DEBUG_MENU_ACTUVE: + CollectParameters(&m_nIp, 1); + // this sets two values on PS2, but not on mobile - TODO? return 0; - case COMMAND_1644: - script_assert(false); + case COMMAND_SET_DRAW_HUD: + CollectParameters(&m_nIp, 1); + CHud::m_Wants_To_Draw_Hud = (GET_INTEGER_PARAM(0) != 0); return 0; - case COMMAND_1645: + case COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS: { - CollectParameters(&m_nIp, 1); - // TODO (GET_STORED_WEAPON?) - CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed; - script_assert(pPed); - ScriptParams[0] = pPed->m_storedWeapon; + CollectParameters(&m_nIp, 4); + int ped_handle = -1; + CVector pos = FindPlayerCoors(); + float x1 = GET_FLOAT_PARAM(0); + float y1 = GET_FLOAT_PARAM(1); + float x2 = GET_FLOAT_PARAM(2); + float y2 = GET_FLOAT_PARAM(3); + int i = CPools::GetPedPool()->GetSize(); + while (--i && ped_handle == -1) { + CPed* pPed = CPools::GetPedPool()->GetSlot(i); + if (!pPed) + continue; + if (pPed->bRemoveFromWorld) + continue; + if (pPed->bFadeOut) + continue; + if (pPed->m_nWaitState != WAITSTATE_FALSE) + continue; + if (!pPed->IsWithinArea(x1, y1, x2, y2)) + continue; + if (pos.z - PED_FIND_Z_OFFSET > pPed->GetPosition().z) + continue; + if (pos.z + PED_FIND_Z_OFFSET < pPed->GetPosition().z) + continue; + ped_handle = CPools::GetPedPool()->GetIndex(pPed); + CTheScripts::LastRandomPedId = ped_handle; + pPed->CharCreatedBy = MISSION_CHAR; + pPed->bRespondsToThreats = false; + ++CPopulation::ms_nTotalMissionPeds; + if (m_bIsMissionScript) + CTheScripts::MissionCleanUp.AddEntityToList(ped_handle, CLEANUP_CHAR); + } + SET_INTEGER_PARAM(0, ped_handle); StoreParameters(&m_nIp, 1); return 0; } - case COMMAND_1646: - CollectParameters(&m_nIp, 1); - // TODO (DISABLE_PAUSE_MENU?) + case COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE: + { + CollectParameters(&m_nIp, 4); + int handle = -1; + uint32 i = CPools::GetVehiclePool()->GetSize(); + float infX = GET_FLOAT_PARAM(0); + float infY = GET_FLOAT_PARAM(1); + float supX = GET_FLOAT_PARAM(2); + float supY = GET_FLOAT_PARAM(3); + while (i-- && handle == -1) { + CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); + if (!pVehicle) + continue; + if (!pVehicle->IsWithinArea(infX, infY, supX, supY)) + continue; + handle = CPools::GetVehiclePool()->GetIndex(pVehicle); + } + SET_INTEGER_PARAM(0, handle); + StoreParameters(&m_nIp, 1); return 0; - case COMMAND_1647: + } + case COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE: + { CollectParameters(&m_nIp, 1); - // TODO (IS_CHANNEL_PLAYING?) - UpdateCompareFlag(false); - return 0; - case COMMAND_1648: - CollectParameters(&m_nIp, 3); - // TODO (SET_CLOCK_EVENT_WARNING); - return 0; - case COMMAND_1649: - CollectParameters(&m_nIp, 3); - // TODO (SET_EXTRA_COLOUR_DIRECTION) - return 0; - case COMMAND_1650: - script_assert(false); - return 0; - case COMMAND_1651: - script_assert(false); - return 0; - case COMMAND_1652: - script_assert(false); - return 0; - case COMMAND_1653: - script_assert(false); - return 0; - case COMMAND_1654: - script_assert(false); - return 0; - case COMMAND_1655: - script_assert(false); - return 0; - case COMMAND_1656: - CollectParameters(&m_nIp, 2); - // TODO (?) + CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(GET_INTEGER_PARAM(0)); + if (!pVehicle) + printf("STORE_CAR_COLLIDED_WITH_NO_SAVE - Car doesn\'t exist\n"); + else { + if (pVehicle->m_pLastDamageEntity == nil) + SET_INTEGER_PARAM(0, -1); + else { + // what they are doing is not very safe as m_pLastDamageEntity doesn't have to be CVehicle +#ifdef FIX_BUGS + if (!pVehicle->m_pLastDamageEntity->IsVehicle()) { + SET_INTEGER_PARAM(0, -1); + } + else +#endif + { + SET_INTEGER_PARAM(0, CPools::GetVehiclePool()->GetIndex((CVehicle*)pVehicle->m_pLastDamageEntity)); + pVehicle->m_pLastDamageEntity = nil; + } + } + } return 0; + } default: script_assert(0); } diff --git a/src/control/Script9.cpp b/src/control/Script9.cpp new file mode 100644 index 00000000..1bd4f99d --- /dev/null +++ b/src/control/Script9.cpp @@ -0,0 +1,338 @@ +#include "common.h" + +#include "Script.h" +#include "ScriptCommands.h" + +int8 CRunningScript::ProcessCommands1500To1599(int32 command) +{ + switch (command) { + case COMMAND_1497: + script_assert(false); + return 0; + case COMMAND_1498: + script_assert(false); + return 0; + case COMMAND_1499: + script_assert(false); + return 0; + case COMMAND_1500: + script_assert(false); + return 0; + case COMMAND_1501: + script_assert(false); + return 0; + case COMMAND_1502: + script_assert(false); + return 0; + case COMMAND_1503: + script_assert(false); + return 0; + case COMMAND_1504: + script_assert(false); + return 0; + case COMMAND_1505: + script_assert(false); + return 0; + case COMMAND_1506: + script_assert(false); + return 0; + case COMMAND_1507: + script_assert(false); + return 0; + case COMMAND_1508: + script_assert(false); + return 0; + case COMMAND_1509: + script_assert(false); + return 0; + case COMMAND_1510: + script_assert(false); + return 0; + case COMMAND_1511: + script_assert(false); + return 0; + case COMMAND_1512: + script_assert(false); + return 0; + case COMMAND_1513: + script_assert(false); + return 0; + case COMMAND_1514: + script_assert(false); + return 0; + case COMMAND_1515: + script_assert(false); + return 0; + case COMMAND_1516: + script_assert(false); + return 0; + case COMMAND_1517: + script_assert(false); + return 0; + case COMMAND_1518: + // TODO (?) + UpdateCompareFlag(true); + return 0; + case COMMAND_1519: + CollectParameters(&m_nIp, 1); + // TODO (SET_NUMBER_USJ_FOUND?) + return 0; + case COMMAND_1520: + CollectParameters(&m_nIp, 1); + // TODO (SET_TOTAL_HIDDEN_PACKAGES?) + return 0; + case COMMAND_1521: + script_assert(false); + return 0; + case COMMAND_1522: + script_assert(false); + return 0; + case COMMAND_1523: + script_assert(false); + return 0; + case COMMAND_1524: + script_assert(false); + return 0; + case COMMAND_1525: + script_assert(false); + return 0; + case COMMAND_1526: + script_assert(false); + return 0; + case COMMAND_1527: + script_assert(false); + return 0; + case COMMAND_1528: + script_assert(false); + return 0; + case COMMAND_1529: + script_assert(false); + return 0; + case COMMAND_1530: + script_assert(false); + return 0; + case COMMAND_1531: + script_assert(false); + return 0; + case COMMAND_1532: + script_assert(false); + return 0; + case COMMAND_1533: + script_assert(false); + return 0; + case COMMAND_1534: + script_assert(false); + return 0; + case COMMAND_1535: + script_assert(false); + return 0; + case COMMAND_1536: + script_assert(false); + return 0; + case COMMAND_1537: + script_assert(false); + return 0; + case COMMAND_1538: + script_assert(false); + return 0; + case COMMAND_1539: + //TODO (REGISTER_OUTFIT_CHANGE) + return 0; + case COMMAND_1540: + script_assert(false); + return 0; + case COMMAND_1541: + script_assert(false); + return 0; + case COMMAND_1542: + script_assert(false); + return 0; + case COMMAND_1543: + script_assert(false); + return 0; + case COMMAND_1544: + script_assert(false); + return 0; + case COMMAND_1545: + script_assert(false); + return 0; + case COMMAND_1546: + script_assert(false); + return 0; + case COMMAND_1547: + script_assert(false); + return 0; + case COMMAND_1548: + // TODO (GET_ONFOOT_CAMERA_MODE) + ScriptParams[0] = 0; + StoreParameters(&m_nIp, 1); + return 0; + case COMMAND_1549: + CollectParameters(&m_nIp, 1); + // TODO (SET_ONFOOT_CAMERA_MODE?) + return 0; + case COMMAND_1550: + script_assert(false); + return 0; + case COMMAND_1551: + script_assert(false); + return 0; + case COMMAND_1552: + script_assert(false); + return 0; + case COMMAND_1553: + script_assert(false); + return 0; + case COMMAND_1554: + script_assert(false); + return 0; + case COMMAND_1555: + CollectParameters(&m_nIp, 1); + // TODO (FREEZE_ONFOOT_CAMERA_MODE?) + return 0; + case COMMAND_1556: + script_assert(false); + return 0; + case COMMAND_1557: + script_assert(false); + return 0; + case COMMAND_1558: + UpdateCompareFlag(false); + // TODO + return 0; + case COMMAND_1559: + script_assert(false); + return 0; + case COMMAND_1560: + // TODO (IS_E3_BUILD?) + UpdateCompareFlag(false); + return 0; + case COMMAND_1561: + // TODO (check, SET_FS_DESTROYED_FLAG) + CTheScripts::FSDestroyedFlag = GetPointerToScriptVariable(&m_nIp, VAR_GLOBAL) - (int32*)CTheScripts::ScriptSpace; + return 0; + case COMMAND_1562: + script_assert(false); + return 0; + case COMMAND_1563: + script_assert(false); + return 0; + case COMMAND_1564: + script_assert(false); + return 0; + case COMMAND_1565: + script_assert(false); + return 0; + case COMMAND_1566: + script_assert(false); + return 0; + case COMMAND_1567: + CollectParameters(&m_nIp, 1); + // TODO (BUILD_WORLD_GEOMETRY) + return 0; + case COMMAND_1568: + script_assert(false); + return 0; + case COMMAND_1569: + // TODO (IS_MULTIPLAYER_ACTIVE?) + UpdateCompareFlag(false); + return 0; + case COMMAND_1570: + script_assert(false); + return 0; + case COMMAND_1571: + script_assert(false); + return 0; + case COMMAND_1572: + script_assert(false); + return 0; + case COMMAND_1573: + script_assert(false); + return 0; + case COMMAND_1574: + script_assert(false); + return 0; + case COMMAND_1575: + script_assert(false); + return 0; + case COMMAND_1576: + script_assert(false); + return 0; + case COMMAND_1577: + script_assert(false); + return 0; + case COMMAND_1578: + script_assert(false); + return 0; + case COMMAND_1579: + script_assert(false); + return 0; + case COMMAND_1580: + script_assert(false); + return 0; + case COMMAND_1581: + { + // TODO (SET_HELP_MESSAGE?) + wchar* key = CTheScripts::GetTextByKeyFromScript(&m_nIp); + return 0; + } + case COMMAND_1582: + script_assert(false); + return 0; + case COMMAND_1583: + script_assert(false); + return 0; + case COMMAND_1584: + script_assert(false); + return 0; + case COMMAND_1585: + script_assert(false); + return 0; + case COMMAND_1586: + script_assert(false); + return 0; + case COMMAND_1587: + script_assert(false); + return 0; + case COMMAND_1588: + script_assert(false); + return 0; + case COMMAND_1589: + CollectParameters(&m_nIp, 2); + // TODO (SWAP_BUILDING?) + return 0; + case COMMAND_1590: + script_assert(false); + return 0; + case COMMAND_1591: + script_assert(false); + return 0; + case COMMAND_1592: + script_assert(false); + return 0; + case COMMAND_1593: + script_assert(false); + return 0; + case COMMAND_1594: + script_assert(false); + return 0; + case COMMAND_1595: + script_assert(false); + return 0; + case COMMAND_1596: + script_assert(false); + return 0; + case COMMAND_1597: + script_assert(false); + return 0; + case COMMAND_1598: + script_assert(false); + return 0; + case COMMAND_1599: + script_assert(false); + return 0; + default: + script_assert(0); + } + return -1; +}
\ No newline at end of file diff --git a/src/control/ScriptCommands.h b/src/control/ScriptCommands.h index 105fa82f..e6bea785 100644 --- a/src/control/ScriptCommands.h +++ b/src/control/ScriptCommands.h @@ -1445,22 +1445,22 @@ enum { COMMAND_IS_JAPANESE_GAME, COMMAND_1442, COMMAND_1443, - COMMAND_1444, - COMMAND_1445, - COMMAND_1446, - COMMAND_1447, - COMMAND_1448, - COMMAND_1449, - COMMAND_1450, - COMMAND_1451, - COMMAND_1452, - COMMAND_1453, + COMMAND_GET_DISTANCE_BETWEEN_2D_POINTS, + COMMAND_GET_DISTANCE_BETWEEN_3D_POINTS, + COMMAND_DOT_PRODUCT_2D, + COMMAND_DOT_PRODUCT_3D, + COMMAND_DEBUG_PRINT_WITH_1_FLOAT, + COMMAND_DEBUG_PRINT_WITH_2_FLOATS, + COMMAND_DEBUG_PRINT_WITH_3_FLOATS, + COMMAND_GET_PAD_BUTTON_STATE, + COMMAND_SET_NAVIGATION_ARROW, + COMMAND_CLEAR_NAVIGATION_ARROW, COMMAND_CALL, - COMMAND_NOTCALL, - COMMAND_1456, - COMMAND_1457, - COMMAND_1458, - COMMAND_1459, + COMMAND_CALLNOT, + COMMAND_IS_CAR_AUTOMOBILE, + COMMAND_IS_CAR_BIKE, + COMMAND_IS_CAR_PLANE, + COMMAND_IS_CAR_HELI, COMMAND_1460, COMMAND_1461, COMMAND_1462, @@ -1478,26 +1478,26 @@ enum { COMMAND_1474, COMMAND_1475, COMMAND_1476, - COMMAND_1477, - COMMAND_1478, - COMMAND_1479, - COMMAND_1480, - COMMAND_1481, - COMMAND_1482, - COMMAND_1483, - COMMAND_1484, - COMMAND_1485, - COMMAND_1486, - COMMAND_1487, - COMMAND_1488, + COMMAND_RETURN_IF_TRUE, + COMMAND_RETURN_TRUE_IF_TRUE, + COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_BEHIND, + COMMAND_SET_RC_HELI_HEIGHT_LIMIT, + COMMAND_CREATE_SCRIPT_CORONA, + COMMAND_REMOVE_SCRIPT_CORONA, + COMMAND_IS_BOAT_IN_WATER, + COMMAND_IS_CAR_DRIVER_BEING_JACKED, + COMMAND_SET_CHAR_ONLY_ALLOWED_TO_SIT_IN_FRONT, + COMMAND_SET_CAR_TILTED_BY_CHAR, + COMMAND_GET_WEAPON_TYPE_FOR_PICKUP_IN_AREA, + COMMAND_IS_USING_FIRST_PERSON_WEAPON_CAMERA, COMMAND_1489, COMMAND_1490, COMMAND_1491, - COMMAND_1492, - COMMAND_1493, - COMMAND_1494, - COMMAND_1495, - COMMAND_1496, + COMMAND_SET_DEBUG_MENU_ACTUVE, + COMMAND_SET_DRAW_HUD, + COMMAND_GET_RANDOM_CHAR_IN_AREA_NO_CHECKS, + COMMAND_GET_RANDOM_CAR_IN_AREA_NO_CHECKS_NO_SAVE, + COMMAND_STORE_CAR_COLLIDED_WITH_NO_SAVE, COMMAND_1497, COMMAND_1498, COMMAND_1499, diff --git a/src/core/Pad.h b/src/core/Pad.h index 3a4f54b3..a3634134 100644 --- a/src/core/Pad.h +++ b/src/core/Pad.h @@ -277,6 +277,16 @@ public: uint32 InputHowLongAgo(void); void SetDrunkInputDelay(int32 delay) { DrunkDrivingBufferUsed = delay; } + // TODO(LCS): properly, this is just to get some estimation for script + int16 GetOddJobTrigger() { return GetRightShockJustDown(); } + int16 GuiLeft() { return GetAnaloguePadLeft() || GetDPadLeftJustDown(); } + int16 GuiRight() { return GetAnaloguePadRight() || GetDPadRightJustDown(); } + int16 GuiUp() { return GetAnaloguePadUp() || GetDPadUpJustDown(); } + int16 GuiDown() { return GetAnaloguePadDown() || GetDPadDownJustDown(); } + int16 GuiSelect() { return GetSelect(); } + int16 GuiBack() { return GetStart(); } + int16 GetSkipCutscene() { return GetCrossJustDown(); } + #ifdef XINPUT void AffectFromXinput(uint32 pad); #endif diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index d9802acc..b7787627 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -1129,6 +1129,7 @@ void CRadar::SetRadarMarkerState(int32 counter, bool flag) } void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) { + /* float f1 = radius * 1.4f; float f2 = radius * 0.5f; CVector p1, p2; @@ -1148,6 +1149,7 @@ void CRadar::ShowRadarMarker(CVector pos, uint32 color, float radius) { p1 = pos - TheCamera.GetRight()*f1; p2 = pos - TheCamera.GetRight()*f2; CTheScripts::ScriptDebugLine3D(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z, color, color); + */ } void CRadar::ShowRadarTrace(float x, float y, uint32 size, uint8 red, uint8 green, uint8 blue, uint8 alpha) diff --git a/src/core/main.cpp b/src/core/main.cpp index 7f73c311..3632807c 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -1275,7 +1275,7 @@ RenderScene(void) void RenderDebugShit(void) { - CTheScripts::RenderTheScriptDebugLines(); + //CTheScripts::RenderTheScriptDebugLines(); #ifndef FINAL if(gbShowCollisionLines) CRenderer::RenderCollisionLines(); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index f5123b39..8be58d66 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -9447,8 +9447,10 @@ CPed::SetRadioStation(void) // --MIAMI: Done void -CPed::WarpPedIntoCar(CVehicle *car) +CPed::WarpPedIntoCar(CVehicle *car) // LCS TODO: remove passenger logic { + if (GetPedState() == PED_FACE_PHONE) + QuitEnteringCar(); bInVehicle = true; m_pMyVehicle = car; m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle); @@ -9513,6 +9515,77 @@ CPed::WarpPedIntoCar(CVehicle *car) bChangedSeat = true; } +void +CPed::WarpPedIntoCarAsPassenger(CVehicle* pVehicle, int32 position) +{ + if (GetPedState() == PED_FACE_PHONE) + QuitEnteringCar(); + bInVehicle = true; + m_pMyVehicle = pVehicle; + m_pMyVehicle->RegisterReference((CEntity**)&m_pMyVehicle); + m_carInObjective = pVehicle; + m_carInObjective->RegisterReference((CEntity**)&m_carInObjective); + SetPedState(PED_DRIVING); // TODO: this is PED_PASSENGER, but it needs to have some logic applied first + bUsesCollision = false; + bIsInTheAir = false; + bVehExitWillBeInstant = true; + if (pVehicle->IsBike() && !pVehicle->pPassengers[0]) { + pVehicle->pPassengers[0] = this; + pVehicle->pPassengers[0]->RegisterReference((CEntity**)&pVehicle->pPassengers[0]); + } + if (position >= 0) { + if (!pVehicle->pPassengers[position]) { + pVehicle->pPassengers[position] = this; + pVehicle->pPassengers[position]->RegisterReference((CEntity**)&pVehicle->pPassengers[position]); + } + } + else { + for (int i = 0; i < 4; i++) { + if (!pVehicle->pPassengers[i]) { + pVehicle->pPassengers[i] = this; + pVehicle->pPassengers[i]->RegisterReference((CEntity**)&pVehicle->pPassengers[i]); + break; + } + } + } + + if (IsPlayer()) { + pVehicle->SetStatus(STATUS_PLAYER); + AudioManager.PlayerJustGotInCar(); + CCarCtrl::RegisterVehicleOfInterest(pVehicle); + } + else { + pVehicle->SetStatus(STATUS_PHYSICS); + } + + CWorld::Remove(this); + SetPosition(pVehicle->GetPosition()); + CWorld::Add(this); + + if (pVehicle->bIsAmbulanceOnDuty) { + pVehicle->bIsAmbulanceOnDuty = false; + --CCarCtrl::NumAmbulancesOnDuty; + } + if (pVehicle->bIsFireTruckOnDuty) { + pVehicle->bIsFireTruckOnDuty = false; + --CCarCtrl::NumFiretrucksOnDuty; + } + if (!pVehicle->bEngineOn) { + pVehicle->bEngineOn = true; + DMAudio.PlayOneShot(pVehicle->m_audioEntityId, SOUND_CAR_ENGINE_START, 1.0f); + } + + RpAnimBlendClumpSetBlendDeltas(GetClump(), ASSOC_PARTIAL, -1000.0f); + + AddInCarAnims(pVehicle, pVehicle->pDriver == this); + RemoveWeaponWhenEnteringVehicle(); + + if (pVehicle->bIsBus) + bRenderPedInCar = false; + + bChangedSeat = true; +} + // --MIAMI: Done bool CPed::HasAttractor(void) diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 242a86f2..9c77b596 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -406,7 +406,7 @@ public: float m_fCollisionSpeed; // cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CPed.h from R* - uint32 bIsStanding : 1; + uint32 bIsStanding : 1; // 0x194 on PS2, 0x1A4 on android uint32 bWasStanding : 1; uint32 bIsAttacking : 1; // doesn't reset after fist fight uint32 bIsPointingGunAt : 1; @@ -499,7 +499,7 @@ public: uint32 bIsDrowning : 1; uint32 bDrownsInWater : 1; uint32 bWaitForLeaderToComeCloser : 1; - uint32 bHeldHostageInCar : 1; + uint32 bHeldHostageInCar : 1; // one flag was added somewhere after this one (TODO: figure out where and which) uint32 bIsPlayerFriend : 1; uint32 bHeadStuckInCollision : 1; uint32 bDeadPedInFrontOfCar : 1; @@ -512,7 +512,7 @@ public: uint32 bMakeFleeScream : 1; uint32 bPushedAlongByCar : 1; uint32 bRemoveMeWhenIGotIntoCar : 1; - uint32 bIgnoreThreatsBehindObjects : 1; + uint32 bIgnoreThreatsBehindObjects : 1; // one flag was added somewhere before this one (TODO: figure out where and which) uint32 bNeverEverTargetThisPed : 1; uint32 bCrouchWhenScared : 1; @@ -523,8 +523,8 @@ public: uint32 bDonePositionOutOfCollision : 1; uint32 bCanAttackPlayerWithCops : 1; // 1A1_1 on PS2 - uint32 b1A1_2 : 1; - uint32 b1A1_4 : 1; + uint32 bOnlyAllowedToSitBehind : 1; + uint32 bOnlyAllowedToSitInFront : 1; uint32 b1A1_8 : 1; uint32 b1A1_10 : 1; uint32 b1A1_20 : 1; @@ -534,11 +534,29 @@ public: uint32 m_ped_flagI80 : 1; // KANGAROO_CHEAT define makes use of this as cheat toggle #endif - uint8 m_gangFlags; - uint8 m_unused15D; // these 3 can't be padding but had to actually have been members ... - uint8 m_unused15E; - uint8 m_unused15F; - uint8 CharCreatedBy; + uint16 m_gangFlags; // <- this one is uint16 + + uint8 b1A4_1 : 1; + uint8 b1A4_2 : 1; + uint8 b1A4_4 : 1; + uint8 b1A4_8 : 1; + uint8 b1A4_10 : 1; + uint8 b1A4_20 : 1; + uint8 b1A4_40 : 1; + uint8 b1A4_80 : 1; + + uint8 b1A5_1 : 1; + uint8 b1A5_2 : 1; + uint8 b1A5_4 : 1; + uint8 b1A5_8 : 1; + uint8 b1A5_10 : 1; + uint8 b1A5_20 : 1; + uint8 b1A5_40 : 1; + uint8 b1A5_80 : 1; + + uint8 unk_1A6; // <- init with 100 in constructor + + uint8 CharCreatedBy; // 1AC eObjective m_objective; eObjective m_prevObjective; CPed *m_pedInObjective; @@ -888,6 +906,7 @@ public: void SetSolicit(uint32 time); void ScanForInterestingStuff(void); void WarpPedIntoCar(CVehicle*); + void WarpPedIntoCarAsPassenger(CVehicle*, int32); void SetCarJack(CVehicle*); bool WarpPedToNearLeaderOffScreen(void); void Solicit(void); @@ -1042,6 +1061,16 @@ public: { return m_pMyVehicle != nil && ((CEntity*)m_pMyVehicle)->GetStatus() != STATUS_WRECKED; } + bool CanStartMission() // used in CAN_PLAYER_START_MISSION and can looks like inlined function + { + if (m_nPedState >= PED_WANDER_RANGE && m_nPedState < PED_STATES_NO_AI && m_nPedState != PED_ANSWER_MOBILE) + return false; + if (m_nPedState >= PED_JUMP && m_nPedState < PED_STATES_NO_ST) + return false; + if (m_nPedState >= PED_ENTER_TRAIN && m_nPedState < PED_DEPLOY_STINGER) + return false; + return !bIsInTheAir && !bIsLanding && m_fHealth > 0.0f; + } // My names. Inlined in VC AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) { diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index f3181fa8..e896b871 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -130,6 +130,8 @@ uint32 CHud::m_LastTimeEnergyLost; CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; +wchar* CHud::gLastPrintForeverString; + struct { const char *name; diff --git a/src/render/Hud.h b/src/render/Hud.h index 354f2438..831c8e0d 100644 --- a/src/render/Hud.h +++ b/src/render/Hud.h @@ -118,6 +118,8 @@ public: static uint32 m_LastWeapon; static uint32 m_LastTimeEnergyLost; + static wchar* gLastPrintForeverString; + public: static void Draw(); static void DrawAfterFade(); |