summaryrefslogtreecommitdiffstats
path: root/src/control/Script7.cpp
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2021-01-17 14:03:37 +0100
committerNikolay Korolev <nickvnuk@gmail.com>2021-01-17 14:03:37 +0100
commit4703ec5164acd169f4ce315a0f035bc6ab554f0b (patch)
treedfe39174e824f5dd4055b86ea3df845f434e134d /src/control/Script7.cpp
parentMerge remote-tracking branch 'upstream/lcs' into lcs (diff)
downloadre3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.tar
re3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.tar.gz
re3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.tar.bz2
re3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.tar.lz
re3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.tar.xz
re3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.tar.zst
re3-4703ec5164acd169f4ce315a0f035bc6ab554f0b.zip
Diffstat (limited to '')
-rw-r--r--src/control/Script7.cpp599
1 files changed, 356 insertions, 243 deletions
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) {