Merge branch 'miami' into lcs-dev

This commit is contained in:
Nikolay Korolev
2021-01-01 13:21:42 +03:00
603 changed files with 117632 additions and 327000 deletions

View File

@ -109,9 +109,9 @@ void CAutoPilot::Load(uint8*& buf)
m_nNextDirection = ReadSaveBuf<int8>(buf);
m_nCurrentLane = ReadSaveBuf<int8>(buf);
m_nNextLane = ReadSaveBuf<int8>(buf);
m_nDrivingStyle = (eCarDrivingStyle)ReadSaveBuf<uint8>(buf);
m_nCarMission = (eCarMission)ReadSaveBuf<uint8>(buf);
m_nTempAction = (eCarTempAction)ReadSaveBuf<uint8>(buf);
m_nDrivingStyle = ReadSaveBuf<uint8>(buf);
m_nCarMission = ReadSaveBuf<uint8>(buf);
m_nTempAction = ReadSaveBuf<uint8>(buf);
m_nTimeTempAction = ReadSaveBuf<uint32>(buf);
m_fMaxTrafficSpeed = ReadSaveBuf<float>(buf);
m_nCruiseSpeed = ReadSaveBuf<uint8>(buf);

View File

@ -4,7 +4,7 @@
class CVehicle;
struct CPathNode;
enum eCarMission : uint8
enum eCarMission
{
MISSION_NONE,
MISSION_CRUISE,
@ -35,7 +35,7 @@ enum eCarMission : uint8
MISSION_BLOCKPLAYER_FORWARDANDBACK
};
enum eCarTempAction : uint8
enum eCarTempAction
{
TEMPACT_NONE,
TEMPACT_WAIT,
@ -50,7 +50,7 @@ enum eCarTempAction : uint8
TEMPACT_SWERVERIGHT
};
enum eCarDrivingStyle : uint8
enum eCarDrivingStyle
{
DRIVINGSTYLE_STOP_FOR_CARS,
DRIVINGSTYLE_SLOW_DOWN_FOR_CARS,
@ -76,9 +76,9 @@ public:
int8 m_nNextDirection;
int8 m_nCurrentLane;
int8 m_nNextLane;
eCarDrivingStyle m_nDrivingStyle;
eCarMission m_nCarMission;
eCarTempAction m_nTempAction;
uint8 m_nDrivingStyle;
uint8 m_nCarMission;
uint8 m_nTempAction;
uint32 m_nTimeTempAction;
float m_fMaxTrafficSpeed;
uint8 m_nCruiseSpeed;

View File

@ -647,7 +647,7 @@ void CCarAI::TellCarToBlockOtherCar(CVehicle* pVehicle, CVehicle* pTarget)
pVehicle->AutoPilot.m_nCruiseSpeed = Max(6, pVehicle->AutoPilot.m_nCruiseSpeed);
}
eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
uint8 CCarAI::FindPoliceCarMissionForWantedLevel()
{
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel){
case 0:
@ -661,7 +661,7 @@ eCarMission CCarAI::FindPoliceCarMissionForWantedLevel()
}
}
eCarMission CCarAI::FindPoliceBoatMissionForWantedLevel()
uint8 CCarAI::FindPoliceBoatMissionForWantedLevel()
{
switch (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel) {
case 0:

View File

@ -22,8 +22,8 @@ public:
static void TellOccupantsToFleeCar(CVehicle*);
static void TellCarToRamOtherCar(CVehicle*, CVehicle*);
static void TellCarToBlockOtherCar(CVehicle*, CVehicle*);
static eCarMission FindPoliceCarMissionForWantedLevel();
static eCarMission FindPoliceBoatMissionForWantedLevel();
static uint8 FindPoliceCarMissionForWantedLevel();
static uint8 FindPoliceBoatMissionForWantedLevel();
static int32 FindPoliceCarSpeedForWantedLevel(CVehicle*);
static void MellowOutChaseSpeed(CVehicle*);
static void MellowOutChaseSpeedBoat(CVehicle*);

View File

@ -464,6 +464,11 @@ CCarCtrl::GenerateOneRandomCar()
pVehicle->GetRight() = CVector(forwardY, -forwardX, 0.0f);
pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);
float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
#ifdef FIX_BUGS
CCarPathLink* pCurrentLink;
CCarPathLink* pNextLink;
@ -474,11 +479,6 @@ CCarCtrl::GenerateOneRandomCar()
float directionNextLinkX;
float directionNextLinkY;
if (positionBetweenNodes < 0.5f) {
float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
positionOnCurrentLinkIncludingLane = CVector(
@ -508,11 +508,6 @@ CCarCtrl::GenerateOneRandomCar()
pVehicle->AutoPilot.m_nTimeEnteredCurve = CTimer::GetTimeInMilliseconds() -
(uint32)((positionBetweenNodes - 0.5f) * pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve);
float currentPathLinkForwardX = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirX();
float currentPathLinkForwardY = pVehicle->AutoPilot.m_nCurrentDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo].GetDirY();
float nextPathLinkForwardX = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirX();
float nextPathLinkForwardY = pVehicle->AutoPilot.m_nNextDirection * ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo].GetDirY();
pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
positionOnCurrentLinkIncludingLane = CVector(
@ -1917,7 +1912,6 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
}
if (pVehicle->AutoPilot.m_bStayInFastLane)
pVehicle->AutoPilot.m_nNextLane = 0;
#ifdef FIX_BUGS
CVector positionOnCurrentLinkIncludingLane(
pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH)
#ifdef FIX_BUGS
@ -1932,16 +1926,6 @@ void CCarCtrl::PickNextNodeRandomly(CVehicle* pVehicle)
#endif
,pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
#else
CVector positionOnCurrentLinkIncludingLane(
pCurLink->GetX() + ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH),
pCurLink->GetY() - ((pVehicle->AutoPilot.m_nCurrentLane + pCurLink->OneWayLaneOffset()) * LANE_WIDTH) * currentPathLinkForwardX,
0.0f);
CVector positionOnNextLinkIncludingLane(
pNextLink->GetX() + ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardY,
pNextLink->GetY() - ((pVehicle->AutoPilot.m_nNextLane + pNextLink->OneWayLaneOffset()) * LANE_WIDTH) * nextPathLinkForwardX,
0.0f);
#endif
float directionCurrentLinkX = pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection;
float directionCurrentLinkY = pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection;
float directionNextLinkX = pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection;
@ -2898,7 +2882,13 @@ void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerv
case DRIVINGSTYLE_STOP_FOR_CARS:
case DRIVINGSTYLE_SLOW_DOWN_FOR_CARS:
case DRIVINGSTYLE_STOP_FOR_CARS_IGNORE_LIGHTS:
speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle) / pVehicle->AutoPilot.m_nCruiseSpeed;
speedStyleMultiplier = FindMaximumSpeedForThisCarInTraffic(pVehicle);
#ifdef FIX_BUGS
if (pVehicle->AutoPilot.GetCruiseSpeed() != 0)
speedStyleMultiplier /= pVehicle->AutoPilot.GetCruiseSpeed();
#else
speedStyleMultiplier /= pVehicle->AutoPilot.m_nCruiseSpeed;
#endif
break;
default:
speedStyleMultiplier = 1.0f;
@ -3242,7 +3232,7 @@ void CCarCtrl::GenerateEmergencyServicesCar(void)
float distance = 30.0f;
CFire* pNearestFire = gFireManager.FindNearestFire(FindPlayerCoors(), &distance);
if (pNearestFire) {
if (CountCarsOfType(MI_FIRETRUCK) < 2 && CTimer::GetTimeInMilliseconds() > LastTimeFireTruckCreated + 30000){
if (CountCarsOfType(MI_FIRETRUCK) < 2 && CTimer::GetTimeInMilliseconds() > LastTimeFireTruckCreated + 35000){
CStreaming::RequestModel(MI_FIRETRUCK, STREAMFLAGS_DEPENDENCY);
CStreaming::RequestModel(MI_FIREMAN, STREAMFLAGS_DONT_REMOVE);
if (CStreaming::HasModelLoaded(MI_FIRETRUCK) && CStreaming::HasModelLoaded(MI_FIREMAN)){

View File

@ -16,7 +16,7 @@
#include "Vehicle.h"
#include "GameLogic.h"
//--MIAMI: file done except TODO
//--MIAMI: file done
#define FRENZY_ANY_PED -1
#define FRENZY_ANY_CAR -2
@ -295,11 +295,16 @@ CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 mode
CPlayerPed *player = FindPlayerPed();
if (fixedWeapon < WEAPONTYPE_TOTALWEAPONS) {
InterruptedWeaponSelected = player->GetWeapon()->m_eWeaponType;
#if (defined FIX_BUGS || !defined GTA_PS2)
player->RemoveWeaponAnims(InterruptedWeaponSelected, -1000.0f);
#endif
InterruptedWeaponType = player->GetWeapon(player->GetWeaponSlot(fixedWeapon)).m_eWeaponType;
AmmoInterruptedWeapon = player->GetWeapon(player->GetWeaponSlot(fixedWeapon)).m_nAmmoTotal;
if (InterruptedWeaponType)
CModelInfo::GetModelInfo(CWeaponInfo::GetWeaponInfo((eWeaponType)InterruptedWeaponType)->m_nModelId)->AddRef();
#if (!defined FIX_BUGS && defined GTA_PS2)
player->RemoveWeaponAnims(InterruptedWeaponSelected, -1000.0f);
#endif
player->GiveWeapon(fixedWeapon, 30000);
player->SetCurrentWeapon(fixedWeapon);
player->MakeChangesForNewWeapon(player->m_nSelectedWepSlot);
@ -403,6 +408,6 @@ CDarkel::DealWithWeaponChangeAtEndOfFrenzy()
FindPlayerPed()->m_nSelectedWepSlot = WEAPONSLOT_UNARMED;
player->SetCurrentWeapon(FindPlayerPed()->m_nSelectedWepSlot);
player->MakeChangesForNewWeapon(player->m_currentWeapon);
//player->RemoveDriveByAnims(); // TODO(MIAMI)
player->RemoveDrivebyAnims();
}
}

View File

@ -29,6 +29,7 @@
#include "ColStore.h"
#include "Automobile.h"
#include "MBlur.h"
#include "screendroplets.h"
uint8 CGameLogic::ActivePlayers;
uint8 CGameLogic::ShortCutState;
@ -153,6 +154,9 @@ CGameLogic::Update()
}
}
CEventList::Initialise();
#ifdef SCREEN_DROPLETS
ScreenDroplets::Initialise();
#endif
CMessages::ClearMessages();
CCarCtrl::ClearInterestingVehicleList();
CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1);
@ -259,6 +263,9 @@ CGameLogic::Update()
}
}
CEventList::Initialise();
#ifdef SCREEN_DROPLETS
ScreenDroplets::Initialise();
#endif
CMessages::ClearMessages();
CCarCtrl::ClearInterestingVehicleList();
CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1);
@ -311,6 +318,9 @@ CGameLogic::Update()
}
}
CEventList::Initialise();
#ifdef SCREEN_DROPLETS
ScreenDroplets::Initialise();
#endif
CMessages::ClearMessages();
CCarCtrl::ClearInterestingVehicleList();
CWorld::ClearExcitingStuffFromArea(pPlayerInfo.GetPos(), 4000.0f, 1);

View File

@ -4,9 +4,7 @@
#include "main.h"
#include "Bike.h"
#ifdef FIX_BUGS
#include "Boat.h"
#endif
#include "DMAudio.h"
#include "General.h"
#include "Font.h"
@ -47,7 +45,7 @@
// Distances
#define DISTANCE_TO_CALL_OFF_CHASE (10.0f)
#define DISTANCE_FOR_MRWHOOP_HACK (4.0f)
#define DISTANCE_FOR_MRWHOOP_HACK (0.5f)
#define DISTANCE_TO_ACTIVATE_GARAGE (8.0f)
#define DISTANCE_TO_ACTIVATE_KEEPCAR_GARAGE (17.0f)
#define DISTANCE_TO_CLOSE_MISSION_GARAGE (30.0f)
@ -126,8 +124,8 @@ uint32 CGarages::MessageEndTime;
uint32 CGarages::NumGarages;
bool CGarages::PlayerInGarage;
int32 CGarages::PoliceCarsCollected;
CStoredCar CGarages::aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][CGarages::MAX_NUM_CARS_IN_HIDEOUT_GARAGE];
int32 CGarages::AudioEntity = AEHANDLE_NONE;
CStoredCar CGarages::aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_CARS];
int32 hGarages = AEHANDLE_NONE;
CGarage CGarages::aGarages[NUM_GARAGES];
bool CGarages::bCamShouldBeOutisde;
@ -148,41 +146,47 @@ void CGarages::Init(void)
for (int i = 0; i < TOTAL_COLLECTCARS_GARAGES; i++)
CarTypesCollected[i] = 0;
LastTimeHelpMessage = 0;
for (int i = 0; i < TOTAL_HIDEOUT_GARAGES; i++) {
for (int j = 0; j < MAX_NUM_CARS_IN_HIDEOUT_GARAGE; j++)
aCarsInSafeHouses[i][j].Init();
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
for (int j = 0; j < TOTAL_HIDEOUT_GARAGES; j++)
aCarsInSafeHouses[j][i].Init();
}
AudioEntity = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1);
if (AudioEntity >= 0)
DMAudio.SetEntityStatus(AudioEntity, 1);
hGarages = DMAudio.CreateEntity(AUDIOTYPE_GARAGE, (void*)1);
if (hGarages >= 0)
DMAudio.SetEntityStatus(hGarages, true);
}
void CGarages::Shutdown(void)
{
NumGarages = 0;
if (AudioEntity < 0)
if (hGarages < 0)
return;
DMAudio.DestroyEntity(AudioEntity);
AudioEntity = AEHANDLE_NONE;
DMAudio.DestroyEntity(hGarages);
hGarages = AEHANDLE_NONE;
}
void CGarages::Update(void)
{
static int GarageToBeTidied = 0;
#ifndef PS2
static uint32 GarageToBeTidied = 0;
if (CReplay::IsPlayingBack())
return;
#endif
bCamShouldBeOutisde = false;
TheCamera.pToGarageWeAreIn = nil;
TheCamera.pToGarageWeAreInForHackAvoidFirstPerson = nil;
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
if (aGarages[i].IsUsed())
aGarages[i].Update();
}
if ((CTimer::GetFrameCounter() & 0xF) != 0xC)
return;
#ifdef FIX_BUGS
if (++GarageToBeTidied >= NumGarages)
#else
if (++GarageToBeTidied >= NUM_GARAGES)
#endif
GarageToBeTidied = 0;
if (!aGarages[GarageToBeTidied].IsUsed())
return;
@ -192,7 +196,7 @@ void CGarages::Update(void)
aGarages[GarageToBeTidied].TidyUpGarage();
}
int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X3, float Y3, float Z2, eGarageType type, int32 targetId)
int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X3, float Y3, float Z2, uint8 type, int32 targetId)
{
if (NumGarages >= NUM_GARAGES) {
assert(0);
@ -293,7 +297,7 @@ int16 CGarages::AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X
return NumGarages++;
}
void CGarages::ChangeGarageType(int16 garage, eGarageType type, int32 mi)
void CGarages::ChangeGarageType(int16 garage, uint8 type, int32 mi)
{
CGarage* pGarage = &aGarages[garage];
pGarage->m_eGarageType = type;
@ -339,6 +343,43 @@ void CGarage::Update()
}
if (m_bDeactivated && m_eGarageState == GS_FULLYCLOSED)
return;
if (m_bRotatedDoor) {
#ifdef GTA_PS2
if (m_eGarageState == GS_OPENING) {
if (m_pDoor1) {
if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor1)
m_pDoor1->bUsesCollision = false;
}
if (m_pDoor2) {
if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor2)
m_pDoor2->bUsesCollision = false;
}
}
else if (m_eGarageState == GS_OPENED) {
if (m_pDoor1)
m_pDoor1->bUsesCollision = true;
if (m_pDoor2)
m_pDoor2->bUsesCollision = true;
}
#else
if (m_eGarageState == GS_OPENING || m_eGarageState == GS_OPENED) {
if (m_pDoor1) {
if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor1 || FindPlayerPed()->GetPedState() == PED_JUMP || FindPlayerPed()->GetPedState() == PED_FALL || !FindPlayerPed()->bIsStanding)
m_pDoor1->bUsesCollision = false;
}
if (m_pDoor2) {
if (FindPlayerPed()->m_pCurrentPhysSurface == m_pDoor2 || FindPlayerPed()->GetPedState() == PED_JUMP || FindPlayerPed()->GetPedState() == PED_FALL || !FindPlayerPed()->bIsStanding)
m_pDoor2->bUsesCollision = false;
}
}
else {
if (m_pDoor1)
m_pDoor1->bUsesCollision = true;
if (m_pDoor2)
m_pDoor2->bUsesCollision = true;
}
#endif
}
switch (m_eGarageType) {
case GARAGE_RESPRAY:
switch (m_eGarageState) {
@ -378,7 +419,7 @@ void CGarage::Update()
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_RESPRAY;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
CStats::CheckPointReachedSuccessfully();
}
UpdateDoorsHeight();
@ -482,7 +523,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENEDCONTAINSCAR;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -526,7 +567,7 @@ void CGarage::Update()
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
m_nTimeToStartAction = CTimer::GetTimeInMilliseconds() + TIME_TO_SETUP_BOMB;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
UpdateDoorsHeight();
if (m_eGarageType == GARAGE_BOMBSHOP3)
@ -539,14 +580,18 @@ void CGarage::Update()
case GARAGE_BOMBSHOP1: DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB1_SET, 1); break;
case GARAGE_BOMBSHOP2: DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB2_SET, 1); break;
case GARAGE_BOMBSHOP3: DMAudio.PlayFrontEndSound(SOUND_GARAGE_BOMB3_SET, 1); break;
default: break;
}
m_eGarageState = GS_OPENING;
if (!CGarages::BombsAreFree)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney = Max(0, CWorld::Players[CWorld::PlayerInFocus].m_nMoney - BOMB_PRICE);
if (FindPlayerVehicle() && (FindPlayerVehicle()->IsCar() || FindPlayerVehicle()->IsBike())) {
#if (!defined GTA_PS2 || defined FIX_BUGS)
FindPlayerVehicle()->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType);
FindPlayerVehicle()->m_pBombRigger = FindPlayerPed();
#else // PS2 version contained a bug: CBike was casted to CAutomobile, but due to coincidence it didn't corrupt memory
((CAutomobile*)(FindPlayerVehicle()))->m_bombType = CGarages::GetBombTypeForGarageType(m_eGarageType);
((CAutomobile*)(FindPlayerVehicle()))->m_pBombRigger = FindPlayerPed();
#endif
if (m_eGarageType == GARAGE_BOMBSHOP3)
CGarages::GivePlayerDetonator();
CStats::KgsOfExplosivesUsed += KGS_OF_EXPLOSIVES_IN_BOMB;
@ -584,7 +629,6 @@ void CGarage::Update()
case GARAGE_BOMBSHOP3:
CHud::SetHelpMessage(TheText.Get("GA_8"), false); // Use the detonator to activate the bomb.
break;
default: break;
}
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = false;
@ -598,7 +642,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENEDCONTAINSCAR;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -616,13 +660,17 @@ void CGarage::Update()
switch (m_eGarageState) {
case GS_OPENED:
if (((CVector2D)FindPlayerCoors() - CVector2D(GetGarageCenterX(), GetGarageCenterY())).MagnitudeSqr() > SQR(DISTANCE_TO_CLOSE_MISSION_GARAGE)) {
if ((CTimer::GetFrameCounter() & 0x1F) == 0 && !IsAnyOtherCarTouchingGarage(nil)) {
if ((CTimer::GetFrameCounter() & 0x1F) == 0
#ifndef GTA_PS2
&& (!m_pTarget || IsEntityTouching3D(m_pTarget))
#endif
) {
m_eGarageState = GS_CLOSING;
m_bClosingWithoutTargetCar = true;
}
}
else if (!FindPlayerVehicle() && m_pTarget && IsEntityEntirelyInside3D(m_pTarget, 0.0f) &&
!IsAnyOtherCarTouchingGarage(m_pTarget) && IsEntityEntirelyOutside(FindPlayerPed(), 2.0f)) {
IsEntityEntirelyOutside(FindPlayerVehicle() ? (CEntity*)FindPlayerVehicle() : (CEntity*)FindPlayerPed(), 2.0f)) {
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_GARAGE);
FindPlayerPed()->m_pWanted->m_bIgnoredByCops = true;
m_eGarageState = GS_CLOSING;
@ -634,7 +682,7 @@ void CGarage::Update()
ThrowCarsNearDoorOutOfGarage(m_pTarget);
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_bClosingWithoutTargetCar)
m_eGarageState = GS_FULLYCLOSED;
else {
@ -664,7 +712,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -717,7 +765,7 @@ void CGarage::Update()
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_pTarget) {
MarkThisCarAsCollectedForCraig(m_pTarget->GetModelIndex());
DestroyVehicleAndDriverAndPassengers(m_pTarget);
@ -757,7 +805,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -778,7 +826,7 @@ void CGarage::Update()
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
if (!IsGarageEmpty())
m_eGarageState = GS_OPENING;
@ -789,7 +837,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -823,7 +871,7 @@ void CGarage::Update()
ThrowCarsNearDoorOutOfGarage(m_pTarget);
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
if (m_bClosingWithoutTargetCar)
m_eGarageState = GS_FULLYCLOSED;
else {
@ -852,7 +900,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -872,7 +920,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -892,7 +940,7 @@ void CGarage::Update()
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -900,7 +948,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -932,8 +980,8 @@ void CGarage::Update()
// Close car doors either if player is far, or if he is in vehicle and garage is full,
// or if player is very very far so that we can remove whatever is blocking garage door without him noticing
if ((distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_IN_CAR) ||
!FindPlayerVehicle() && distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_ON_FOOT) &&
!IsAnyCarBlockingDoor()))
!FindPlayerVehicle() && distance > SQR(DISTANCE_TO_CLOSE_HIDEOUT_GARAGE_ON_FOOT)) &&
!IsAnyCarBlockingDoor())
m_eGarageState = GS_CLOSING;
else if (FindPlayerVehicle() &&
CountCarsWithCenterPointWithinGarage(FindPlayerVehicle()) >=
@ -951,7 +999,7 @@ void CGarage::Update()
if (!IsPlayerOutsideGarage())
m_eGarageState = GS_OPENING;
else if (m_fDoorPos == 0.0f) {
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
m_eGarageState = GS_FULLYCLOSED;
StoreAndRemoveCarsForThisHideout(CGarages::aCarsInSafeHouses[CGarages::FindSafeHouseIndexForGarageType(m_eGarageType)], NUM_GARAGE_STORED_CARS);
}
@ -982,7 +1030,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + HIDEOUT_DOOR_SPEED_COEFFICIENT * (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -1009,7 +1057,7 @@ void CGarage::Update()
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -1025,7 +1073,7 @@ void CGarage::Update()
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -1036,8 +1084,8 @@ void CGarage::Update()
break;
}
break;
//case GARAGE_COLLECTORSITEMS:
//case GARAGE_60SECONDS:
//case GARAGE_COLLECTORSITEMS:
//case GARAGE_60SECONDS:
case GARAGE_FOR_SCRIPT_TO_OPEN_FOR_CAR:
switch (m_eGarageState) {
case GS_OPENED:
@ -1046,20 +1094,23 @@ void CGarage::Update()
m_eGarageState = GS_CLOSING;
m_bClosingWithoutTargetCar = false;
}
break;
case GS_CLOSING:
m_fDoorPos = Max(0.0f, m_fDoorPos - (m_bRotatedDoor ? ROTATED_DOOR_CLOSE_SPEED : DEFAULT_DOOR_CLOSE_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == 0.0f) {
m_eGarageState = GS_FULLYCLOSED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_CLOSED, 1.0f);
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_GARAGE);
}
UpdateDoorsHeight();
break;
case GS_FULLYCLOSED:
break;
case GS_OPENING:
m_fDoorPos = Min(m_fDoorHeight, m_fDoorPos + (m_bRotatedDoor ? ROTATED_DOOR_OPEN_SPEED : DEFAULT_DOOR_OPEN_SPEED) * CTimer::GetTimeStep());
if (m_fDoorPos == m_fDoorHeight) {
m_eGarageState = GS_OPENED;
DMAudio.PlayOneShot(CGarages::AudioEntity, SOUND_GARAGE_DOOR_OPENED, 1.0f);
DMAudio.PlayOneShot(hGarages, SOUND_GARAGE_DOOR_OPENED, 1.0f);
}
UpdateDoorsHeight();
break;
@ -1074,28 +1125,6 @@ void CGarage::Update()
}
}
void CGarage::ThrowCarsNearDoorOutOfGarage(CVehicle* pException)
{
uint32 i = CPools::GetVehiclePool()->GetSize();
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || pVehicle == pException)
continue;
if (!IsEntityTouching3D(pVehicle))
continue;
CColModel* pColModel = pVehicle->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (!IsPointInsideGarage(pos, 0.0f)) {
CVector vecDirectionAway(pVehicle->GetPosition().x - GetGarageCenterX(), pVehicle->GetPosition().y - GetGarageCenterY(), 0.0f);
vecDirectionAway.Normalise();
pVehicle->AddToMoveSpeed(vecDirectionAway * CTimer::GetTimeStepInSeconds());
}
}
}
}
bool CGarage::IsStaticPlayerCarEntirelyInside()
{
if (!FindPlayerVehicle())
@ -1160,7 +1189,7 @@ bool CGarage::IsPointInsideGarage(CVector pos, float m_fMargin)
return true;
}
bool CGarage::IsEntityEntirelyInside3D(CEntity * pEntity, float fMargin)
bool CGarage::IsEntityEntirelyInside3D(CEntity* pEntity, float fMargin)
{
if (pEntity->GetPosition().x < m_fInfX - fMargin || pEntity->GetPosition().x > m_fSupX + fMargin ||
pEntity->GetPosition().y < m_fInfY - fMargin || pEntity->GetPosition().y > m_fSupY + fMargin ||
@ -1212,12 +1241,12 @@ bool CGarage::IsPlayerOutsideGarage()
return IsEntityEntirelyOutside(FindPlayerPed(), 0.0f);
}
bool CGarage::IsEntityTouching3D(CEntity * pEntity)
bool CGarage::IsEntityTouching3D(CEntity* pEntity)
{
float radius = pEntity->GetBoundRadius();
if (pEntity->GetPosition().x - radius < m_fInfX || pEntity->GetPosition().x + radius > m_fSupX ||
pEntity->GetPosition().y - radius < m_fInfY || pEntity->GetPosition().y + radius > m_fSupY ||
pEntity->GetPosition().z - radius < m_fInfZ || pEntity->GetPosition().z + radius > m_fSupZ)
if (m_fInfX - radius > pEntity->GetPosition().x || m_fSupX + radius < pEntity->GetPosition().x ||
m_fInfY - radius > pEntity->GetPosition().y || m_fSupY + radius < pEntity->GetPosition().y ||
m_fInfZ - radius > pEntity->GetPosition().z || m_fSupZ + radius < pEntity->GetPosition().z)
return false;
CColModel* pColModel = pEntity->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
@ -1261,6 +1290,28 @@ bool CGarage::IsAnyOtherCarTouchingGarage(CVehicle * pException)
return false;
}
void CGarage::ThrowCarsNearDoorOutOfGarage(CVehicle* pException)
{
uint32 i = CPools::GetVehiclePool()->GetSize();
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || pVehicle == pException)
continue;
if (!IsEntityTouching3D(pVehicle))
continue;
CColModel* pColModel = pVehicle->GetColModel();
for (int i = 0; i < pColModel->numSpheres; i++) {
CVector pos = pVehicle->GetMatrix() * pColModel->spheres[i].center;
float radius = pColModel->spheres[i].radius;
if (!IsPointInsideGarage(pos, 0.0f)) {
CVector vecDirectionAway(pVehicle->GetPosition().x - GetGarageCenterX(), pVehicle->GetPosition().y - GetGarageCenterY(), 0.0f);
vecDirectionAway.Normalise();
pVehicle->AddToMoveSpeed(vecDirectionAway * CTimer::GetTimeStepInSeconds());
}
}
}
}
bool CGarage::IsAnyOtherPedTouchingGarage(CPed * pException)
{
uint32 i = CPools::GetPedPool()->GetSize();
@ -1328,7 +1379,9 @@ void CGarage::RemoveCarsBlockingDoorNotInside()
if (!pVehicle->bIsLocked && pVehicle->CanBeDeleted()) {
CWorld::Remove(pVehicle);
delete pVehicle;
return; // WHY?
#ifndef FIX_BUGS
return;
#endif
}
}
}
@ -1337,43 +1390,34 @@ void CGarage::RemoveCarsBlockingDoorNotInside()
void CGarages::PrintMessages()
{
if (CTimer::GetTimeInMilliseconds() > MessageStartTime && CTimer::GetTimeInMilliseconds() < MessageEndTime) {
CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f)); // BUG: game doesn't use macro here.
CFont::DrawFonts();
CFont::SetScale(SCREEN_SCALE_X(1.2f), SCREEN_SCALE_Y(1.5f));
CFont::SetPropOn();
CFont::SetJustifyOff();
CFont::SetBackgroundOff();
CFont::SetCentreSize(SCREEN_SCALE_X(590.0f));
CFont::SetCentreOn();
CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetColor(CRGBA(27, 89, 130, 255));
CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, 255));
#if defined(PS2) || defined (FIX_BUGS)
float y_offset = SCREEN_HEIGHT / 3; // THIS is PS2 calculation
#if defined(GTA_PS2) || defined (FIX_BUGS)
float y_offset = SCREEN_HEIGHT / 3 - SCREEN_SCALE_Y(40.0f); // THIS is PS2 calculation
#else
float y_offset = SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(84.0f); // This is PC and results in text being written over some HUD elements
#endif
if (MessageNumberInString2 < 0) {
if (MessageNumberInString < 0) {
CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(2.0f), TheText.Get(MessageIDString));
CFont::SetColor(CRGBA(27, 89, 130, 255));
CFont::PrintString(SCREEN_WIDTH / 2, y_offset, TheText.Get(MessageIDString));
}
else {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString);
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
CFont::SetColor(CRGBA(27, 89, 130, 255));
CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
}
if (MessageNumberInString2 >= 0) {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(30.0f), gUString);
}
else if (MessageNumberInString >= 0) {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, -1, -1, -1, -1, -1, gUString);
CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(30.0f), gUString);
}
else {
CMessages::InsertNumberInString(TheText.Get(MessageIDString), MessageNumberInString, MessageNumberInString2, -1, -1, -1, -1, gUString);
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), y_offset - SCREEN_SCALE_Y(40.0f) + SCREEN_SCALE_Y(2.0f), gUString);
CFont::SetColor(CRGBA(27, 89, 130, 255));
CFont::PrintString(SCREEN_WIDTH / 2, y_offset - SCREEN_SCALE_Y(40.0f), gUString);
CFont::PrintString(SCREEN_WIDTH / 2, y_offset, TheText.Get(MessageIDString));
}
}
}
@ -1390,7 +1434,9 @@ bool CGarages::IsCarSprayable(CVehicle * pVehicle)
case MI_BARRACKS:
case MI_DODO:
case MI_COACH:
#ifndef GTA_PS2
case MI_FBIRANCH:
#endif
return false;
default:
break;
@ -1462,41 +1508,54 @@ void CGarage::UpdateCrusherShake(float X, float Y)
m_pDoor2->GetMatrix().GetPosition().y -= Y;
}
// This is dumb but there is no way to avoid goto. What was there originally even?
static bool DoINeedToRefreshPointer(CEntity * pDoor, bool bIsDummy, uint8 nIndex)
{
bool bNeedToFindDoorEntities = false;
if (pDoor) {
if (bIsDummy) {
if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex((CDummy*)pDoor)))
return true;
if (nIndex != (CPools::GetDummyPool()->GetIndex((CDummy*)pDoor) & 0x7F))
bNeedToFindDoorEntities = true;
if (!CGarages::IsModelIndexADoor(pDoor->GetModelIndex()))
return true;
}
else {
if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex((CObject*)pDoor)))
return true;
if (nIndex != (CPools::GetObjectPool()->GetIndex((CObject*)pDoor) & 0x7F))
bNeedToFindDoorEntities = true;
if (!CGarages::IsModelIndexADoor(pDoor->GetModelIndex()))
return true;
}
}
return bNeedToFindDoorEntities;
}
void CGarage::RefreshDoorPointers(bool bCreate)
{
bool bNeedToFindDoorEntities = true;
if (!bCreate && !m_bRecreateDoorOnNextRefresh)
bNeedToFindDoorEntities = false;
bool bNeedToFindDoorEntities = bCreate || m_bRecreateDoorOnNextRefresh;
m_bRecreateDoorOnNextRefresh = false;
if (DoINeedToRefreshPointer(m_pDoor1, m_bDoor1IsDummy, m_bDoor1PoolIndex))
bNeedToFindDoorEntities = true;
if (DoINeedToRefreshPointer(m_pDoor2, m_bDoor2IsDummy, m_bDoor2PoolIndex))
bNeedToFindDoorEntities = true;
if (m_pDoor1) {
if (m_bDoor1IsDummy) {
if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)m_pDoor1)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor1PoolIndex != (CPools::GetDummyPool()->GetIndex((CDummy*)m_pDoor1) & 0x7F))
bNeedToFindDoorEntities = true;
if (!CGarages::IsModelIndexADoor(m_pDoor1->GetModelIndex()))
bNeedToFindDoorEntities = true;
}
}
else {
if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)m_pDoor1)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor1PoolIndex != (CPools::GetObjectPool()->GetIndex((CObject*)m_pDoor1) & 0x7F))
bNeedToFindDoorEntities = true;
if (!CGarages::IsModelIndexADoor(m_pDoor1->GetModelIndex()))
bNeedToFindDoorEntities = true;
}
}
}
if (m_pDoor2) {
if (m_bDoor2IsDummy) {
if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)m_pDoor2)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor2PoolIndex != (CPools::GetDummyPool()->GetIndex((CDummy*)m_pDoor2) & 0x7F))
bNeedToFindDoorEntities = true;
if (!CGarages::IsModelIndexADoor(m_pDoor2->GetModelIndex()))
bNeedToFindDoorEntities = true;
}
}
else {
if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)m_pDoor2)))
bNeedToFindDoorEntities = true;
else {
if (m_bDoor2PoolIndex != (CPools::GetObjectPool()->GetIndex((CObject*)m_pDoor2) & 0x7F))
bNeedToFindDoorEntities = true;
if (!CGarages::IsModelIndexADoor(m_pDoor2->GetModelIndex()))
bNeedToFindDoorEntities = true;
}
}
}
if (bNeedToFindDoorEntities)
FindDoorsEntities();
}
@ -1520,7 +1579,7 @@ void CGarages::TriggerMessage(const char* text, int16 num1, uint16 time, int16 n
MessageNumberInString2 = num2;
}
void CGarages::SetTargetCarForMissonGarage(int16 garage, CVehicle * pVehicle)
void CGarages::SetTargetCarForMissonGarage(int16 garage, CVehicle* pVehicle)
{
assert(garage >= 0 && garage < NUM_GARAGES);
if (pVehicle) {
@ -1663,10 +1722,10 @@ void CGarage::FindDoorsEntities()
{
m_pDoor1 = nil;
m_pDoor2 = nil;
int xstart = Max(0, CWorld::GetSectorIndexX(m_fInfX));
int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(m_fSupX));
int ystart = Max(0, CWorld::GetSectorIndexY(m_fInfY));
int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(m_fSupY));
int xstart = Max(0, CWorld::GetSectorIndexX(GetGarageCenterX() - 100.0f));
int xend = Min(NUMSECTORS_X - 1, CWorld::GetSectorIndexX(GetGarageCenterX() + 100.0f));
int ystart = Max(0, CWorld::GetSectorIndexY(GetGarageCenterY() - 100.0f));
int yend = Min(NUMSECTORS_Y - 1, CWorld::GetSectorIndexY(GetGarageCenterY() + 100.0f));
assert(xstart <= xend);
assert(ystart <= yend);
@ -1779,8 +1838,8 @@ void CStoredCar::StoreCar(CVehicle* pVehicle)
m_bExplosionproof = pVehicle->bExplosionProof;
m_bCollisionproof = pVehicle->bCollisionProof;
m_bMeleeproof = pVehicle->bMeleeProof;
if (pVehicle->IsCar())
m_nCarBombType = ((CAutomobile*)pVehicle)->m_bombType;
if (pVehicle->IsCar() || pVehicle->IsBike())
m_nCarBombType = ((CAutomobile*)pVehicle)->m_bombType; // NB: cast to CAutomobile is original behaviour
}
CVehicle* CStoredCar::RestoreCar()
@ -1817,9 +1876,7 @@ CVehicle* CStoredCar::RestoreCar()
pVehicle->m_currentColour2 = m_nSecondaryColor;
pVehicle->m_nRadioStation = m_nRadioStation;
pVehicle->bFreebies = false;
#ifdef FIX_BUGS
if (pVehicle->IsCar())
#endif
{
((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType;
#ifdef FIX_BUGS
@ -1882,7 +1939,11 @@ bool CGarage::RestoreCarsForThisHideout(CStoredCar* aCars)
bool CGarages::IsPointInAGarageCameraZone(CVector point)
{
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
switch (aGarages[i].m_eGarageType) {
case GARAGE_NONE:
break;
@ -1909,8 +1970,13 @@ bool CGarages::CameraShouldBeOutside()
void CGarages::GivePlayerDetonator()
{
FindPlayerPed()->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
FindPlayerPed()->GetWeapon(FindPlayerPed()->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
CPlayerPed* pPed = FindPlayerPed();
int slot = CWeaponInfo::GetWeaponInfo(WEAPONTYPE_DETONATOR)->m_nWeaponSlot;
pPed->GiveWeapon(WEAPONTYPE_DETONATOR, 1);
pPed->GetWeapon(pPed->GetWeaponSlot(WEAPONTYPE_DETONATOR)).m_eWeaponState = WEAPONSTATE_READY;
pPed->m_nSelectedWepSlot = slot;
if (pPed->m_storedWeapon != WEAPONTYPE_UNIDENTIFIED)
pPed->m_storedWeapon = WEAPONTYPE_DETONATOR;
}
float CGarages::FindDoorHeightForMI(int32 mi)
@ -1923,12 +1989,12 @@ void CGarage::TidyUpGarage()
uint32 i = CPools::GetVehiclePool()->GetSize();
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || !pVehicle->IsCar())
continue;
if (IsPointInsideGarage(pVehicle->GetPosition())) {
if (pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->GetUp().z < 0.5f) {
CWorld::Remove(pVehicle);
delete pVehicle;
if (pVehicle && (pVehicle->IsCar() || pVehicle->IsBike())) {
if (IsPointInsideGarage(pVehicle->GetPosition())) {
if (pVehicle->GetStatus() == STATUS_WRECKED || pVehicle->GetUp().z < 0.5f) {
CWorld::Remove(pVehicle);
delete pVehicle;
}
}
}
}
@ -1939,9 +2005,9 @@ void CGarage::TidyUpGarageClose()
uint32 i = CPools::GetVehiclePool()->GetSize();
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle || !pVehicle->IsCar())
if (!pVehicle)
continue;
if (!pVehicle->IsCar() || pVehicle->GetStatus() != STATUS_WRECKED || !IsEntityTouching3D(pVehicle))
if ((!pVehicle->IsCar() && !pVehicle->IsBike()) || pVehicle->GetStatus() != STATUS_WRECKED || !IsEntityTouching3D(pVehicle))
continue;
bool bRemove = false;
if (m_eGarageState != GS_FULLYCLOSED) {
@ -1966,7 +2032,11 @@ void CGarage::TidyUpGarageClose()
void CGarages::PlayerArrestedOrDied()
{
static int GarageToBeTidied = 0; // lol
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
if (aGarages[i].m_eGarageType != GARAGE_NONE)
aGarages[i].PlayerArrestedOrDied();
}
@ -2061,20 +2131,24 @@ void CGarage::CenterCarInGarage(CVehicle* pVehicle)
void CGarages::CloseHideOutGaragesBeforeSave()
{
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
if (!IsThisGarageTypeSafehouse(aGarages[i].m_eGarageType))
continue;
if (aGarages[i].m_eGarageState != GS_FULLYCLOSED) {
aGarages[i].m_eGarageState = GS_FULLYCLOSED;
aGarages[i].StoreAndRemoveCarsForThisHideout(aCarsInSafeHouses[FindSafeHouseIndexForGarageType(aGarages[i].m_eGarageType)], NUM_GARAGE_STORED_CARS);
aGarages[i].RemoveCarsBlockingDoorNotInside();
aGarages[i].m_fDoorPos = 0.0f;
aGarages[i].UpdateDoorsHeight();
}
aGarages[i].m_fDoorPos = 0.0f;
aGarages[i].UpdateDoorsHeight();
}
}
int32 CGarages::CountCarsInHideoutGarage(eGarageType type)
int32 CGarages::CountCarsInHideoutGarage(uint8 type)
{
int32 total = 0;
for (int i = 0; i < NUM_GARAGE_STORED_CARS; i++) {
@ -2085,11 +2159,24 @@ int32 CGarages::CountCarsInHideoutGarage(eGarageType type)
bool CGarages::IsPointWithinHideOutGarage(Const CVector& point)
{
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
switch (aGarages[i].m_eGarageType) {
case GARAGE_HIDEOUT_ONE:
case GARAGE_HIDEOUT_TWO:
case GARAGE_HIDEOUT_THREE:
case GARAGE_HIDEOUT_FOUR:
case GARAGE_HIDEOUT_FIVE:
case GARAGE_HIDEOUT_SIX:
case GARAGE_HIDEOUT_SEVEN:
case GARAGE_HIDEOUT_EIGHT:
case GARAGE_HIDEOUT_NINE:
case GARAGE_HIDEOUT_TEN:
case GARAGE_HIDEOUT_ELEVEN:
case GARAGE_HIDEOUT_TWELVE:
if (aGarages[i].IsPointInsideGarage(point))
return true;
default: break;
@ -2100,7 +2187,11 @@ bool CGarages::IsPointWithinHideOutGarage(Const CVector& point)
bool CGarages::IsPointWithinAnyGarage(Const CVector& point)
{
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
switch (aGarages[i].m_eGarageType) {
case GARAGE_NONE:
continue;
@ -2114,7 +2205,11 @@ bool CGarages::IsPointWithinAnyGarage(Const CVector& point)
void CGarages::SetAllDoorsBackToOriginalHeight()
{
#ifdef FIX_BUGS
for (uint32 i = 0; i < NumGarages; i++) {
#else
for (int i = 0; i < NUM_GARAGES; i++) {
#endif
switch (aGarages[i].m_eGarageType) {
case GARAGE_NONE:
continue;

View File

@ -7,7 +7,7 @@
class CVehicle;
class CCamera;
enum eGarageState : int8
enum eGarageState
{
GS_FULLYCLOSED,
GS_OPENED,
@ -18,7 +18,7 @@ enum eGarageState : int8
GS_AFTERDROPOFF,
};
enum eGarageType : int8
enum eGarageType
{
GARAGE_NONE,
GARAGE_MISSION,
@ -93,8 +93,8 @@ VALIDATE_SIZE(CStoredCar, 0x28);
class CGarage
{
eGarageType m_eGarageType;
eGarageState m_eGarageState;
uint8 m_eGarageType;
uint8 m_eGarageState;
uint8 m_nMaxStoredCars;
bool field_2; // unused
bool m_bClosingWithoutTargetCar;
@ -148,8 +148,8 @@ class CGarage
return Abs(TheCamera.GetPosition().x - GetGarageCenterX()) > SWITCH_GARAGE_DISTANCE_CLOSE ||
Abs(TheCamera.GetPosition().y - GetGarageCenterY()) > SWITCH_GARAGE_DISTANCE_CLOSE;
#else
return Abs(TheCamera.GetPosition().x - m_fX1) > SWITCH_GARAGE_DISTANCE_CLOSE ||
Abs(TheCamera.GetPosition().y - m_fY1) > SWITCH_GARAGE_DISTANCE_CLOSE;
return Abs(TheCamera.GetPosition().x - m_fInfX) > SWITCH_GARAGE_DISTANCE_CLOSE ||
Abs(TheCamera.GetPosition().y - m_fInfY) > SWITCH_GARAGE_DISTANCE_CLOSE;
#endif
}
void TidyUpGarageClose();
@ -187,7 +187,7 @@ class CGarage
bool IsPointInsideGarage(CVector, float);
void ThrowCarsNearDoorOutOfGarage(CVehicle*);
int32 FindMaxNumStoredCarsForGarage() { return Max(NUM_GARAGE_STORED_CARS, m_nMaxStoredCars); }
int32 FindMaxNumStoredCarsForGarage() { return Min(NUM_GARAGE_STORED_CARS, m_nMaxStoredCars); }
friend class CGarages;
friend class cAudioManager;
@ -198,7 +198,6 @@ class CGarages
{
enum {
MESSAGE_LENGTH = 8,
MAX_NUM_CARS_IN_HIDEOUT_GARAGE = 4
};
static int32 BankVansCollected;
static bool BombsAreFree;
@ -216,8 +215,7 @@ class CGarages
static bool PlayerInGarage;
static int32 PoliceCarsCollected;
static CGarage aGarages[NUM_GARAGES];
static CStoredCar aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][MAX_NUM_CARS_IN_HIDEOUT_GARAGE];
static int32 AudioEntity;
static CStoredCar aCarsInSafeHouses[TOTAL_HIDEOUT_GARAGES][NUM_GARAGE_STORED_CARS];
static bool bCamShouldBeOutisde;
public:
@ -227,8 +225,8 @@ public:
#endif
static void Update(void);
static int16 AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X3, float Y3, float Z2, eGarageType type, int32 targetId);
static void ChangeGarageType(int16, eGarageType, int32);
static int16 AddOne(float X1, float Y1, float Z1, float X2, float Y2, float X3, float Y3, float Z2, uint8 type, int32 targetId);
static void ChangeGarageType(int16, uint8, int32);
static void PrintMessages(void);
static void TriggerMessage(const char* text, int16, uint16 time, int16);
static void SetTargetCarForMissonGarage(int16, CVehicle*);
@ -265,9 +263,9 @@ private:
static bool IsCarSprayable(CVehicle*);
static float FindDoorHeightForMI(int32);
static void CloseHideOutGaragesBeforeSave(void);
static int32 CountCarsInHideoutGarage(eGarageType);
static int32 GetBombTypeForGarageType(eGarageType type) { return type - GARAGE_BOMBSHOP1 + 1; }
static int32 GetCarsCollectedIndexForGarageType(eGarageType type)
static int32 CountCarsInHideoutGarage(uint8);
static int32 GetBombTypeForGarageType(uint8 type) { return type - GARAGE_BOMBSHOP1 + 1; }
static int32 GetCarsCollectedIndexForGarageType(uint8 type)
{
switch (type) {
case GARAGE_COLLECTCARS_1: return 0;
@ -278,7 +276,7 @@ private:
}
return 0;
}
static int32 FindSafeHouseIndexForGarageType(eGarageType type)
static int32 FindSafeHouseIndexForGarageType(uint8 type)
{
switch (type) {
case GARAGE_HIDEOUT_ONE: return 0;
@ -296,7 +294,7 @@ private:
}
return -1;
}
static bool IsThisGarageTypeSafehouse(eGarageType type) { return FindSafeHouseIndexForGarageType(type) >= 0; }
static bool IsThisGarageTypeSafehouse(uint8 type) { return FindSafeHouseIndexForGarageType(type) >= 0; }
friend class cAudioManager;
friend class CReplay;

87
src/control/NameGrid.cpp Normal file
View File

@ -0,0 +1,87 @@
#include "common.h"
#include "NameGrid.h"
// TODO: reverse mobile code
CPlayerName::CPlayerName()
{
// TODO
}
void
CPlayerName::DisplayName(int)
{
// TODO
}
CRow::CRow()
{
// TODO
}
void
CRow::SetLetter(int, wchar *)
{
// TODO
}
CGrid::CGrid()
{
// TODO
}
void
CGrid::ProcessAnyLeftJustDown()
{
unk_int2--;
}
void
CGrid::ProcessAnyRightJustDown()
{
unk_int2++;
}
void
CGrid::ProcessAnyUpJustDown()
{
unk_int1--;
}
void
CGrid::ProcessAnyDownJustDown()
{
unk_int1++;
}
void
CGrid::AllDoneMakePlayerName()
{
// TODO
}
void
CGrid::ProcessDPadCrossJustDown()
{
// TODO
}
void
CGrid::DisplayGrid()
{
// TODO
}
void
CGrid::ProcessControllerInput()
{
// TODO
}
void
CGrid::Process()
{
ProcessControllerInput();
DisplayGrid();
playerName.DisplayName(2 * playerName.unk_4c);
}

53
src/control/NameGrid.h Normal file
View File

@ -0,0 +1,53 @@
#pragma once
// TODO: reverse mobile code
class CPlayerName
{
friend class CGrid;
float x;
float y;
wchar unk_8[34];
int unk_4c;
public:
CPlayerName();
void DisplayName(int);
};
class CRow
{
friend class CGrid;
int unk_0;
int unk_4;
wchar unk_8[20];
int unk_30;
public:
CRow();
void SetLetter(int, wchar *);
};
class CGrid
{
CRow rows[5];
int unk_int1;
int unk_int2;
int unk_int3;
float unk_float1;
float unk_float2;
CPlayerName playerName;
char unk2[4];
char unk3[4];
public:
CGrid();
void ProcessAnyLeftJustDown();
void ProcessAnyRightJustDown();
void ProcessAnyUpJustDown();
void ProcessAnyDownJustDown();
void AllDoneMakePlayerName();
void ProcessDPadCrossJustDown();
void DisplayGrid();
void ProcessControllerInput();
void Process();
};

View File

@ -286,6 +286,8 @@ CPathFind::AllocatePathFindInfoMem(int16 numPathGroups)
DetachedInfoForTilePeds = new CPathInfoForObject[12*NUMDETACHED_PEDS];
memset(DetachedInfoForTilePeds, 0, 12*NUMDETACHED_PEDS*sizeof(CPathInfoForObject));
delete[] TempExternalNodes;
TempExternalNodes = nil;
TempExternalNodes = new CTempNodeExternal[NUMTEMPEXTERNALNODES];
memset(TempExternalNodes, 0, NUMTEMPEXTERNALNODES*sizeof(CTempNodeExternal));
NumTempExternalNodes = 0;
@ -1766,10 +1768,18 @@ CPathFind::TestCoorsCloseness(CVector target, uint8 type, CVector start)
DoPathSearch(type, start, -1, target, pNodeList, &DummyResult, 32, nil, &dist, 999999.88f, -1);
else
DoPathSearch(type, start, -1, target, nil, &DummyResult2, 0, nil, &dist, 50.0f, -1);
#ifdef FIX_BUGS
// dist has GenerationDistMultiplier as a factor, so our reference dist should have it too
if(type == PATH_CAR)
return dist < 150.0f*TheCamera.GenerationDistMultiplier;
else
return dist < 100.0f*TheCamera.GenerationDistMultiplier;
#else
if(type == PATH_CAR)
return dist < 150.0f;
else
return dist < 100.0f;
#endif
}
void

View File

@ -58,7 +58,7 @@ CPhoneInfo::Update(void)
} else {
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_PHONE);
if (player->m_nPedState == PED_MAKE_CALL)
player->m_nPedState = PED_IDLE;
player->SetPedState(PED_IDLE);
}
}
bool notInCar;
@ -105,7 +105,7 @@ CPhoneInfo::Update(void)
player->m_fRotationCur = angleToFace;
player->m_fRotationDest = angleToFace;
player->SetHeading(angleToFace);
player->m_nPedState = PED_MAKE_CALL;
player->SetPedState(PED_MAKE_CALL);
CPad::GetPad(0)->SetDisablePlayerControls(PLAYERCONTROL_PHONE);
TheCamera.SetWideScreenOn();
playerInfo->MakePlayerSafe(true);
@ -308,7 +308,7 @@ INITSAVEBUF
// Convert entity pointer to building pool index while saving
if (phone->m_pEntity) {
phone->m_pEntity = (CEntity*) (CPools::GetBuildingPool()->GetJustIndex((CBuilding*)phone->m_pEntity) + 1);
phone->m_pEntity = (CEntity*) (CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert((CBuilding*)phone->m_pEntity) + 1);
}
}
VALIDATESAVEBUF(*size)
@ -333,7 +333,7 @@ PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg)
ped->bUpdateAnimHeading = true;
if (ped->m_nPedState == PED_MAKE_CALL)
ped->m_nPedState = PED_IDLE;
ped->SetPedState(PED_IDLE);
}
void

View File

@ -140,18 +140,12 @@ ModifyStringLabelForControlSetting(char *str)
}
}
inline bool
IsWeaponSlotAmmoMergeable(uint32 slot)
{
return slot == WEAPONSLOT_SHOTGUN || slot == WEAPONSLOT_SUBMACHINEGUN || slot == WEAPONSLOT_RIFLE;
}
void
CPickup::ExtractAmmoFromPickup(CPlayerPed *player)
{
eWeaponType weaponType = CPickups::WeaponForModel(m_pObject->GetModelIndex());
if (m_eType == PICKUP_IN_SHOP || !IsWeaponSlotAmmoMergeable(CWeaponInfo::GetWeaponInfo(weaponType)->m_nWeaponSlot))
if (m_eType == PICKUP_IN_SHOP || !CWeaponInfo::IsWeaponSlotAmmoMergeable(CWeaponInfo::GetWeaponInfo(weaponType)->m_nWeaponSlot))
return;
uint32 ammo = m_nQuantity;
@ -374,14 +368,14 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
eWeaponType plrWeaponSlot = FindPlayerPed()->GetWeapon(slot).m_eWeaponType;
if (plrWeaponSlot != weaponType) {
if (CStreaming::ms_aInfoForModel[m_pObject->GetModelIndex()].m_loadState == STREAMSTATE_LOADED) {
if (plrWeaponSlot == WEAPONTYPE_UNARMED || (FindPlayerPed()->GetWeapon(slot).m_nAmmoTotal == 0 && !IsWeaponSlotAmmoMergeable(slot))) {
if (plrWeaponSlot == WEAPONTYPE_UNARMED || (FindPlayerPed()->GetWeapon(slot).m_nAmmoTotal == 0 && !CWeaponInfo::IsWeaponSlotAmmoMergeable(slot))) {
if (CTimer::GetTimeInMilliseconds() - FindPlayerPed()->m_nPadDownPressedInMilliseconds < 1500) {
CPickups::PlayerOnWeaponPickup = 6;
isPickupTouched = false;
}
} else {
CPickups::PlayerOnWeaponPickup = 6;
if (IsWeaponSlotAmmoMergeable(slot)) {
if (CWeaponInfo::IsWeaponSlotAmmoMergeable(slot)) {
if (m_eType == PICKUP_ONCE_TIMEOUT || m_eType == PICKUP_ONCE || m_eType == PICKUP_ON_STREET) {
ExtractAmmoFromPickup(player);
FindPlayerPed()->GetWeapon(slot).Reload();
@ -602,7 +596,10 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
bool explode = false;
if (CTimer::GetTimeInMilliseconds() > m_nTimer)
explode = true;
else {// added else here since vehicle lookup is useless
#ifdef FIX_BUGS
else// added else here since vehicle lookup is useless
#endif
{
for (int32 i = CPools::GetVehiclePool()->GetSize()-1; i >= 0; i--) {
CVehicle *vehicle = CPools::GetVehiclePool()->GetSlot(i);
if (vehicle != nil && vehicle->IsSphereTouchingVehicle(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z, 1.5f)) {
@ -625,11 +622,11 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
m_pObject->GetMatrix().UpdateRW();
m_pObject->UpdateRwFrame();
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0) && waterLevel >= m_pObject->GetPosition().z)
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false) && waterLevel >= m_pObject->GetPosition().z)
m_eType = PICKUP_FLOATINGPACKAGE_FLOATING;
break;
case PICKUP_FLOATINGPACKAGE_FLOATING:
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, 0))
if (CWaterLevel::GetWaterLevel(m_pObject->GetPosition().x, m_pObject->GetPosition().y, m_pObject->GetPosition().z + 5.0f, &waterLevel, false))
m_pObject->GetMatrix().GetPosition().z = waterLevel;
m_pObject->GetMatrix().UpdateRW();
@ -858,7 +855,7 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan
if (slot >= NUMPICKUPS) return -1;
aPickUps[slot].m_eType = (ePickupType)type;
aPickUps[slot].m_eType = type;
aPickUps[slot].m_bRemoved = false;
aPickUps[slot].m_nQuantity = quantity;
aPickUps[slot].m_nMoneySpeed = rate;
@ -1384,7 +1381,7 @@ void
CPickups::RemoveAllPickupsOfACertainWeaponGroupWithNoAmmo(eWeaponType weaponType)
{
uint32 weaponSlot = CWeaponInfo::GetWeaponInfo(weaponType)->m_nWeaponSlot;
if (IsWeaponSlotAmmoMergeable(weaponSlot)) {
if (CWeaponInfo::IsWeaponSlotAmmoMergeable(weaponSlot)) {
for (int slot = 0; slot < NUMPICKUPS; slot++) {
if (aPickUps[slot].m_eType == PICKUP_ONCE || aPickUps[slot].m_eType == PICKUP_ONCE_TIMEOUT || aPickUps[slot].m_eType == PICKUP_ONCE_TIMEOUT_SLOW) {
if (aPickUps[slot].m_pObject) {
@ -1464,9 +1461,9 @@ INITSAVEBUF
CPickup *buf_pickup = WriteSaveBuf(buf, aPickUps[i]);
if (buf_pickup->m_eType != PICKUP_NONE) {
if (buf_pickup->m_pObject != nil)
buf_pickup->m_pObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex(buf_pickup->m_pObject) + 1);
buf_pickup->m_pObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(buf_pickup->m_pObject) + 1);
if (buf_pickup->m_pExtraObject != nil)
buf_pickup->m_pExtraObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex(buf_pickup->m_pExtraObject) + 1);
buf_pickup->m_pExtraObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(buf_pickup->m_pExtraObject) + 1);
}
}
@ -1578,3 +1575,102 @@ void
CPacManPickups::ResetPowerPillsCarriedByPlayer()
{
}
// --MIAMI: Done
void
CPed::CreateDeadPedMoney(void)
{
if (!CGame::nastyGame)
return;
int mi = GetModelIndex();
if ((mi >= MI_COP && mi <= MI_FIREMAN) || (CharCreatedBy == MISSION_CHAR && !bMoneyHasBeenGivenByScript) || bInVehicle)
return;
int money = m_nPedMoney;
if (money < 10)
return;
CVector pickupPos = GetPosition();
CPickups::CreateSomeMoney(pickupPos, money);
m_nPedMoney = 0;
}
// --MIAMI: Done
void
CPed::CreateDeadPedWeaponPickups(void)
{
CVector pickupPos;
if (bInVehicle)
return;
for(int i = 0; i < TOTAL_WEAPON_SLOTS; i++) {
eWeaponType weapon = GetWeapon(i).m_eWeaponType;
int weaponAmmo = GetWeapon(i).m_nAmmoTotal;
if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || (weaponAmmo == 0 && !GetWeapon(i).IsTypeMelee()))
continue;
int quantity = Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon] / 2);
CreateDeadPedPickupCoors(&pickupPos.x, &pickupPos.y, &pickupPos.z);
pickupPos.z += 0.3f;
if (!CPickups::TryToMerge_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, quantity, false)) {
CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, quantity));
}
}
ClearWeapons();
}
// --MIAMI: Done
void
CPed::CreateDeadPedPickupCoors(float *x, float *y, float *z)
{
bool found = false;
CVector pickupPos;
#define NUMBER_OF_ATTEMPTS 32
for (int i = 0; i < NUMBER_OF_ATTEMPTS; i++) {
pickupPos = GetPosition();
pickupPos.x = 1.5f * Sin((CGeneral::GetRandomNumber() % 256)/256.0f * TWOPI) + GetPosition().x;
pickupPos.y = 1.5f * Cos((CGeneral::GetRandomNumber() % 256)/256.0f * TWOPI) + GetPosition().y;
pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
if (!found)
continue;
CVector pedPos = GetPosition();
pedPos.z += 0.3f;
CVector pedToPickup = pickupPos - pedPos;
float distance = pedToPickup.Magnitude();
// outer edge of pickup
distance = (distance + 0.4f) / distance;
CVector pickupPos2 = pedPos;
pickupPos2 += distance * pedToPickup;
if ((pickupPos - FindPlayerCoors()).Magnitude2D() > 2.0f || i > NUMBER_OF_ATTEMPTS / 2) {
if (i > NUMBER_OF_ATTEMPTS / 2 || !CPickups::TestForPickupsInBubble(pickupPos, 1.3f)) {
if (CWorld::GetIsLineOfSightClear(pickupPos2, pedPos,
true, i < NUMBER_OF_ATTEMPTS / 2, false, i < NUMBER_OF_ATTEMPTS / 2, false, false, false)) {
if (i > NUMBER_OF_ATTEMPTS / 2 || !CWorld::TestSphereAgainstWorld(pickupPos, 1.2f, nil, false, true, false, false, false, false)) {
*x = pickupPos.x;
*y = pickupPos.y;
*z = pickupPos.z;
return;
}
}
}
}
}
*x = GetPosition().x;
*y = GetPosition().y;
*z = GetPosition().z + 0.4f;
#undef NUMBER_OF_ATTEMPTS
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "Weapon.h"
enum ePickupType : uint8
enum ePickupType
{
PICKUP_NONE = 0,
PICKUP_IN_SHOP,
@ -43,7 +43,7 @@ public:
int16 m_eModelIndex;
uint16 m_nIndex;
char m_sTextKey[8];
ePickupType m_eType;
uint8 m_eType;
bool m_bRemoved;
uint8 m_bWasAmmoCollected:1;
uint8 m_bWasControlMessageShown:1;

View File

@ -57,9 +57,7 @@ public:
static void RestoreInfoForMatrix(CMatrix&, CCarStateEachFrame*);
static void RestoreInfoForCar(CAutomobile*, CCarStateEachFrame*, bool);
static void ProcessControlCars(void);
#if (defined(GTA_PS2) || defined(FIX_BUGS))
static bool ShouldThisPadBeLeftAlone(uint8 pad);
#endif
static void GiveUsACar(int32, CVector, float, CAutomobile**, uint8, uint8);
static void StartChaseScene(float);
static void CleanUpChaseScene(void);

View File

@ -1,5 +1,5 @@
#include "common.h"
#ifdef GTA_REPLAY
#include "AnimBlendAssocGroup.h"
#include "AnimBlendAssociation.h"
#include "Bike.h"
@ -794,10 +794,19 @@ void CReplay::StoreBikeUpdate(CVehicle* vehicle, int id)
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
vp->acceleration = vehicle->m_fGasPedal * 100.0f;
#ifdef FIX_BUGS // originally it's undefined behaviour - different fields are copied on PC and mobile
for (int i = 0; i < 2; i++)
vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i];
for (int i = 0; i < 2; i++)
vp->wheel_rotation[i + 2] = 128.0f / PI * bike->m_aWheelSpeed[i];
for (int i = 0; i < 4; i++)
vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i];
#else
for (int i = 0; i < 4; i++) {
vp->wheel_susp_dist[i] = 50.0f * bike->m_aSuspensionSpringRatio[i];
vp->wheel_rotation[i] = 128.0f / PI * bike->m_aWheelRotation[i];
}
#endif
vp->velocityX = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().y));
vp->velocityZ = 8000.0f * Max(-4.0f, Min(4.0f, vehicle->GetMoveSpeed().z));
@ -902,12 +911,19 @@ void CReplay::ProcessBikeUpdate(CVehicle* vehicle, float interpolation, CAddress
vehicle->m_vecMoveSpeed = CVector(vp->velocityX / 8000.0f, vp->velocityY / 8000.0f, vp->velocityZ / 8000.0f);
vehicle->m_fSteerAngle = vp->wheel_state / 50.0f;
vehicle->bEngineOn = true;
#ifdef FIX_BUGS
for (int i = 0; i < 2; i++)
bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI);
for (int i = 0; i < 2; i++)
bike->m_aWheelSpeed[i] = vp->wheel_rotation[i + 2] / (128.0f / PI);
for (int i = 0; i < 4; i++)
bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
#else
for (int i = 0; i < 4; i++) {
bike->m_aSuspensionSpringRatio[i] = vp->wheel_susp_dist[i] / 50.0f;
bike->m_aWheelRotation[i] = vp->wheel_rotation[i] / (128.0f / PI);
// NB: technically last assignment overflows - there are 2 wheels of bike
// however it saves two useful fields; this looks like unrolled loop, not sequential assignments
}
#endif
bike->m_fLeanLRAngle = vp->lean_angle / 50.0f;
bike->m_fWheelAngle = vp->wheel_angle / 50.0f;
bike->bLeanMatrixClean = false;
@ -1218,10 +1234,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetUp() = CVector(0.0f, 1.0f, 0.0f);
TheCamera.GetRight() = CVector(1.0f, 0.0f, 0.0f);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)&TheCamera.GetPosition();
pm->at = *(RwV3d*)&TheCamera.GetForward();
pm->up = *(RwV3d*)&TheCamera.GetUp();
pm->right = *(RwV3d*)&TheCamera.GetRight();
pm->pos = TheCamera.GetPosition();
pm->at = TheCamera.GetForward();
pm->up = TheCamera.GetUp();
pm->right = TheCamera.GetRight();
break;
}
case REPLAYCAMMODE_FIXED:
@ -1237,10 +1253,10 @@ void CReplay::ProcessReplayCamera(void)
TheCamera.GetMatrix().GetUp() = up;
TheCamera.GetMatrix().GetRight() = right;
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)&TheCamera.GetMatrix().GetPosition();
pm->at = *(RwV3d*)&TheCamera.GetMatrix().GetForward();
pm->up = *(RwV3d*)&TheCamera.GetMatrix().GetUp();
pm->right = *(RwV3d*)&TheCamera.GetMatrix().GetRight();
pm->pos = TheCamera.GetMatrix().GetPosition();
pm->at = TheCamera.GetMatrix().GetForward();
pm->up = TheCamera.GetMatrix().GetUp();
pm->right = TheCamera.GetMatrix().GetRight();
break;
}
default:
@ -1447,7 +1463,7 @@ void CReplay::RestoreStuffFromMem(void)
ped->m_rwObject = nil;
ped->m_modelIndex = -1;
ped->SetModelIndex(mi);
ped->m_pVehicleAnim = 0;
ped->m_pVehicleAnim = nil;
ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false);
@ -1840,10 +1856,10 @@ void CReplay::ProcessLookAroundCam(void)
TheCamera.GetRight() = right;
TheCamera.SetPosition(camera_pt);
RwMatrix* pm = RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera));
pm->pos = *(RwV3d*)&TheCamera.GetPosition();
pm->at = *(RwV3d*)&TheCamera.GetForward();
pm->up = *(RwV3d*)&TheCamera.GetUp();
pm->right = *(RwV3d*)&TheCamera.GetRight();
pm->pos = TheCamera.GetPosition();
pm->at = TheCamera.GetForward();
pm->up = TheCamera.GetUp();
pm->right = TheCamera.GetRight();
TheCamera.CalculateDerivedValues();
RwMatrixUpdate(RwFrameGetMatrix(RwCameraGetFrame(TheCamera.m_pRwCamera)));
RwFrameUpdateObjects(RwCameraGetFrame(TheCamera.m_pRwCamera));
@ -1887,3 +1903,4 @@ void CReplay::Display()
if (Mode == MODE_PLAYBACK)
CFont::PrintString(SCREEN_SCALE_X(63.5f), SCREEN_SCALE_Y(30.0f), TheText.Get("REPLAY"));
}
#endif

View File

@ -66,6 +66,12 @@ struct CStoredDetailedAnimationState
void PlayReplayFromHD(void);
#ifdef GTA_REPLAY
#define REPLAY_STUB
#else
#define REPLAY_STUB {}
#endif
class CReplay
{
enum {
@ -362,21 +368,25 @@ private:
#endif
public:
static void Init(void);
static void DisableReplays(void);
static void EnableReplays(void);
static void Update(void);
static void FinishPlayback(void);
static void EmptyReplayBuffer(void);
static void Display(void);
static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene);
static void StreamAllNecessaryCarsAndPeds(void);
static bool ShouldStandardCameraBeProcessed(void);
static void Init(void) REPLAY_STUB;
static void DisableReplays(void) REPLAY_STUB;
static void EnableReplays(void) REPLAY_STUB;
static void Update(void) REPLAY_STUB;
static void FinishPlayback(void) REPLAY_STUB;
static void EmptyReplayBuffer(void) REPLAY_STUB;
static void Display(void) REPLAY_STUB;
static void TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float cam_z, bool load_scene) REPLAY_STUB;
static void StreamAllNecessaryCarsAndPeds(void) REPLAY_STUB;
static void RecordParticle(tParticleType type, CVector const& vecPos, CVector const& vecDir, float fSize, RwRGBA const& color) REPLAY_STUB;
#ifndef GTA_REPLAY
static bool ShouldStandardCameraBeProcessed(void) { return true; }
static bool IsPlayingBack() { return false; }
static bool IsPlayingBackFromFile() { return false; }
#else
static bool ShouldStandardCameraBeProcessed(void);
static bool IsPlayingBack() { return Mode == MODE_PLAYBACK; }
static bool IsPlayingBackFromFile() { return bPlayingBackFromFile; }
static void RecordParticle(tParticleType type, CVector const& vecPos, CVector const& vecDir, float fSize, RwRGBA const& color);
private:
static void RecordThisFrame(void);
static void StorePedUpdate(CPed *ped, int id);
@ -407,4 +417,5 @@ private:
/* Absolute nonsense, but how could this function end up being outside of class? */
friend void PlayReplayFromHD(void);
#endif
};

View File

@ -83,7 +83,7 @@ CRestart::FindClosestHospitalRestartPoint(const CVector &pos, CVector *outPos, f
}
eLevelName curlevel = CTheZones::GetLevelFromPosition(&pos);
float fMinDist = 16000000.0f;
float fMinDist = SQR(4000.0f);
int closestPoint = NUM_RESTART_POINTS;
// find closest point on this level
@ -130,7 +130,7 @@ CRestart::FindClosestPoliceRestartPoint(const CVector &pos, CVector *outPos, flo
}
eLevelName curlevel = CTheZones::GetLevelFromPosition(&pos);
float fMinDist = 16000000.0f;
float fMinDist = SQR(4000.0f);
int closestPoint = NUM_RESTART_POINTS;
// find closest point on this level

View File

@ -97,11 +97,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
pCopPed->m_nRoadblockVeh->RegisterReference((CEntity**)&pCopPed->m_nRoadblockVeh);
pCopPed->bCrouchWhenShooting = roadBlockType == 2 ? false : true;
if (pEntityToAttack) {
if (pCopPed->m_pPointGunAt)
pCopPed->m_pPointGunAt->CleanUpOldReference(&pCopPed->m_pPointGunAt);
pCopPed->m_pPointGunAt = pEntityToAttack;
if (pEntityToAttack)
pEntityToAttack->RegisterReference(&pCopPed->m_pPointGunAt);
pCopPed->SetWeaponLockOnTarget(pEntityToAttack);
pCopPed->SetAttack(pEntityToAttack);
}
pCopPed->m_pMyVehicle = pVehicle;

View File

@ -1,7 +1,7 @@
#include "common.h"
#include "SceneEdit.h"
#ifdef GTA_SCENE_EDIT
#include "Automobile.h"
#include "Camera.h"
#include "CarCtrl.h"
@ -1098,3 +1098,4 @@ bool CSceneEdit::SelectWeapon(void)
}
return false;
}
#endif

View File

@ -1,5 +1,5 @@
#pragma once
#ifdef GTA_SCENE_EDIT
class CPed;
class CVehicle;
@ -93,3 +93,4 @@ public:
static void SelectVehicle(void);
static bool SelectWeapon(void);
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,15 @@ class CPlayerInfo;
class CRunningScript;
#define KEY_LENGTH_IN_SCRIPT 8
extern int32 ScriptParams[32];
void FlushLog();
#define script_assert(_Expression) FlushLog(); assert(_Expression);
#define PICKUP_PLACEMENT_OFFSET 0.5f
#define PED_FIND_Z_OFFSET 5.0f
#define COP_PED_FIND_Z_OFFSET 10.0f
#define SPHERE_MARKER_R 252
#define SPHERE_MARKER_G 138
#define SPHERE_MARKER_B 242
@ -22,6 +30,16 @@ class CRunningScript;
#define SPHERE_MARKER_PULSE_PERIOD 2048
#define SPHERE_MARKER_PULSE_FRACTION 0.1f
#ifdef USE_PRECISE_MEASUREMENT_CONVERTION
#define METERS_IN_FOOT 0.3048f
#define FEET_IN_METER 3.28084f
#else
#define METERS_IN_FOOT 0.3f
#define FEET_IN_METER 3.33f
#endif
#define KEY_LENGTH_IN_SCRIPT 8
struct intro_script_rectangle
{
bool m_bIsUsed;
@ -288,6 +306,15 @@ class CTheScripts
static uint16 ScriptsUpdated;
static uint32 LastMissionPassedTime;
static uint16 NumberOfExclusiveMissionScripts;
#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
#define CARDS_IN_SUIT (13)
#define NUM_SUITS (4)
#define MAX_DECKS (6)
#define CARDS_IN_DECK (CARDS_IN_SUIT * NUM_SUITS)
#define CARDS_IN_STACK (CARDS_IN_DECK * MAX_DECKS)
static int16 CardStack[CARDS_IN_STACK];
static int16 CardStackPosition;
#endif
public:
static bool bPlayerIsInTheStatium;
static uint8 RiotIntensity;
@ -516,28 +543,7 @@ private:
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal) {
switch (pedtype) {
case PEDTYPE_CIVMALE:
case PEDTYPE_CIVFEMALE:
return civ;
case PEDTYPE_GANG1:
case PEDTYPE_GANG2:
case PEDTYPE_GANG3:
case PEDTYPE_GANG4:
case PEDTYPE_GANG5:
case PEDTYPE_GANG6:
case PEDTYPE_GANG7:
case PEDTYPE_GANG8:
case PEDTYPE_GANG9:
return gang;
case PEDTYPE_CRIMINAL:
case PEDTYPE_PROSTITUTE:
return criminal;
default:
return false;
}
}
bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal);
bool CheckDamagedWeaponType(int32 actual, int32 type);
@ -550,12 +556,16 @@ private:
extern int scriptToLoad;
#endif
#ifdef MISSION_REPLAY
static_assert(false, "Mission replay is not supported");
extern int AllowMissionReplay;
extern uint32 WaitForMissionActivate;
extern uint32 WaitForSave;
extern uint32 MissionStartTime;
extern int missionRetryScriptIndex;
extern bool doingMissionRetry;
extern bool gbTryingPorn4Again;
extern int IsInAmmunation;
extern int MissionSkipLevel;
uint32 AddExtraDeathDelay();
void RetryMission(int, int);

1558
src/control/Script2.cpp Normal file

File diff suppressed because it is too large Load Diff

2134
src/control/Script3.cpp Normal file

File diff suppressed because it is too large Load Diff

2334
src/control/Script4.cpp Normal file

File diff suppressed because it is too large Load Diff

2072
src/control/Script5.cpp Normal file

File diff suppressed because it is too large Load Diff

1803
src/control/Script6.cpp Normal file

File diff suppressed because it is too large Load Diff

1402
src/control/Script7.cpp Normal file

File diff suppressed because it is too large Load Diff

613
src/control/Script8.cpp Normal file
View File

@ -0,0 +1,613 @@
#include "common.h"
#include "Script.h"
#include "ScriptCommands.h"
#include "DMAudio.h"
#if ((defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT) && defined MORE_LANGUAGES)
#include "Frontend.h"
#endif
#include "GameLogic.h"
#include "Garages.h"
#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 "Population.h"
#include "Pools.h"
#include "RpAnimBlend.h"
#include "Stats.h"
#include "VisibilityPlugins.h"
#include "Wanted.h"
#include "WaterLevel.h"
#include "World.h"
#include "Zones.h"
int8 CRunningScript::ProcessCommands1400To1499(int32 command)
{
switch (command) {
case COMMAND_REGISTER_VIGILANTE_LEVEL:
CollectParameters(&m_nIp, 1);
CStats::RegisterLevelVigilanteMission(ScriptParams[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) {
pPed->m_pVehicleAnim = nil;
pPed->RestartNonPartialAnims();
RpAnimBlendClumpRemoveAllAssociations(pPed->GetClump());
pPed->SetPedState(PED_IDLE);
pPed->SetMoveState(PEDMOVE_STILL);
pPed->m_nLastPedState = PED_NONE;
pPed->ClearAimFlag();
pPed->ClearLookFlag();
pPed->bIsPointingGunAt = false;
if (pPed->IsPlayer())
((CPlayerPed*)pPed)->m_fMoveSpeed = 0.0f;
else
pPed->m_nStoredMoveState = PEDMOVE_STILL;
CAnimManager::AddAnimation(pPed->GetClump(), pPed->m_animGroup, ANIM_IDLE_STANCE);
pPed->bIsPedDieAnimPlaying = false;
}
return 0;
}
case COMMAND_SET_MAXIMUM_NUMBER_OF_CARS_IN_GARAGE:
CollectParameters(&m_nIp, 2);
CGarages::SetMaxNumStoredCarsForGarage(ScriptParams[0], ScriptParams[1]);
return 0;
case COMMAND_WANTED_STARS_ARE_FLASHING:
{
CWanted *pWanted = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted;
UpdateCompareFlag(pWanted->m_nMinWantedLevel - pWanted->m_nWantedLevel > 0);
return 0;
}
case COMMAND_SET_ALLOW_HURRICANES:
CollectParameters(&m_nIp, 1);
CStats::NoMoreHurricanes = ScriptParams[0];
return 0;
case COMMAND_PLAY_ANNOUNCEMENT:
{
CollectParameters(&m_nIp, 1);
DMAudio.PlayRadioAnnouncement(ScriptParams[0] + STREAMED_SOUND_ANNOUNCE_BRIDGE_CLOSED);
return 0;
}
case COMMAND_SET_PLAYER_IS_IN_STADIUM:
{
CollectParameters(&m_nIp, 1);
CTheScripts::bPlayerIsInTheStatium = ScriptParams[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;
pPlayerInfo->m_pPed->m_nLastBusFareCollected = 0;
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM:
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[1]);
script_assert(pVehicle);
ScriptParams[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) {
CVector pos;
CPedAttractorManager::ComputeEffectPos(pEffect, pVehicle->GetMatrix(), pos);
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;
}
}
}
}
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_DISPLAY_RADAR:
CollectParameters(&m_nIp, 1);
CHud::m_HideRadar = ScriptParams[0] == 0;
return 0;
case COMMAND_REGISTER_BEST_POSITION:
CollectParameters(&m_nIp, 2);
CStats::RegisterBestPosition(ScriptParams[0], ScriptParams[1]);
return 0;
case COMMAND_IS_PLAYER_IN_INFO_ZONE:
{
CollectParameters(&m_nIp, 1);
CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
char key[KEY_LENGTH_IN_SCRIPT];
memset(key, 0, KEY_LENGTH_IN_SCRIPT);
CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
m_nIp += KEY_LENGTH_IN_SCRIPT;
CVector pos = pPlayerInfo->GetPos();
CZone *infoZone = CTheZones::FindInformationZoneForPosition(&pos);
UpdateCompareFlag(strncmp(key, infoZone->name, 8) == 0); // original code doesn't seem to be using strncmp in here and compare 2 ints instead
return 0;
}
case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE:
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
if (pPed->m_attractor)
GetPedAttractorManager()->DeRegisterPed(pPed, pPed->m_attractor);
return 0;
}
case COMMAND_IS_IN_CAR_FIRE_BUTTON_PRESSED:
UpdateCompareFlag(CPad::GetPad(0)->GetCarGunFired());
return 0;
case COMMAND_HAS_CHAR_ATTEMPTED_ATTRACTOR:
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
UpdateCompareFlag(pPed->bHasAlreadyUsedAttractor);
return 0;
}
case COMMAND_SET_LOAD_COLLISION_FOR_CAR_FLAG:
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pVehicle);
if (ScriptParams[1]) {
pVehicle->bDontLoadCollision = false;
if (m_bMissionFlag) {
CWorld::Remove(pVehicle);
pVehicle->bIsStaticWaitingForCollision = true;
CWorld::Add(pVehicle);
}
}
else {
pVehicle->bDontLoadCollision = true;
if (pVehicle->bIsStaticWaitingForCollision) {
pVehicle->bIsStaticWaitingForCollision = false;
if (!pVehicle->GetIsStatic())
pVehicle->AddToMovingList();
}
}
return 0;
}
case COMMAND_SET_LOAD_COLLISION_FOR_CHAR_FLAG:
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
if (ScriptParams[1]) {
pPed->bDontLoadCollision = false;
if (m_bMissionFlag) {
CWorld::Remove(pPed);
pPed->bIsStaticWaitingForCollision = true;
CWorld::Add(pPed);
}
}
else {
pPed->bDontLoadCollision = true;
if (pPed->bIsStaticWaitingForCollision) {
pPed->bIsStaticWaitingForCollision = false;
if (!pPed->GetIsStatic())
pPed->AddToMovingList();
}
}
return 0;
}
//case COMMAND_SET_LOAD_COLLISION_FOR_OBJECT_FLAG:
case COMMAND_ADD_BIG_GUN_FLASH:
{
CollectParameters(&m_nIp, 6);
CWeapon::AddGunFlashBigGuns(*(CVector*)&ScriptParams[0], *(CVector*)&ScriptParams[3]);
return 0;
}
case COMMAND_HAS_CHAR_BOUGHT_ICE_CREAM:
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
UpdateCompareFlag(pPed->bBoughtIceCream);
return 0;
}
case COMMAND_GET_PROGRESS_PERCENTAGE:
*(float*)&ScriptParams[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]);
return 0;
}
case COMMAND_SET_SHORTCUT_DROPOFF_POINT_FOR_MISSION:
{
CollectParameters(&m_nIp, 4);
CGameLogic::AddShortCutDropOffPointForMission(*(CVector*)&ScriptParams[0], *(float*)&ScriptParams[3]);
return 0;
}
case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA:
{
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];
int i = CPools::GetPedPool()->GetSize();
while (--i && ped_handle == -1) {
CPed* pPed = CPools::GetPedPool()->GetSlot(i);
if (!pPed)
continue;
if (CTheScripts::LastRandomPedId == CPools::GetPedPool()->GetIndex(pPed))
continue;
if (pPed->CharCreatedBy != RANDOM_CHAR)
continue;
if (!pPed->IsPedInControl())
continue;
if (pPed->bRemoveFromWorld)
continue;
if (pPed->bFadeOut)
continue;
if (pPed->m_nWaitState != WAITSTATE_FALSE)
continue;
if (pPed->bHasAlreadyUsedAttractor)
continue;
if (pPed->m_attractor)
continue;
if (!ThisIsAValidRandomPed(pPed->m_nPedType, ScriptParams[4], ScriptParams[5], ScriptParams[6]))
continue;
if (pPed->bIsLeader || pPed->m_leader)
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);
}
ScriptParams[0] = ped_handle;
StoreParameters(&m_nIp, 1);
return 0;
}
//case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_ZONE:
case COMMAND_UNLOCK_ALL_CAR_DOORS_IN_AREA:
{
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];
while (i--) {
CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i);
if (!pVehicle)
continue;
if (pVehicle->IsWithinArea(infX, infY, supX, supY))
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
}
return 0;
}
case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS:
CollectParameters(&m_nIp, 2);
CGangs::SetWillAttackPlayerWithCops((ePedType)((int)PEDTYPE_GANG1 + ScriptParams[0]), !!ScriptParams[1]);
return 0;
case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR:
{
CollectParameters(&m_nIp, 2);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
pPed->bHeldHostageInCar = ScriptParams[1];
return 0;
}
case COMMAND_SET_VEHICLE_TO_FADE_IN:
{
CollectParameters(&m_nIp, 2);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
script_assert(pVehicle);
CVisibilityPlugins::SetClumpAlpha(pVehicle->GetClump(), ScriptParams[1]);
return 0;
}
case COMMAND_REGISTER_ODDJOB_MISSION_PASSED:
++CStats::MissionsPassed;
CStats::CheckPointReachedSuccessfully();
CTheScripts::LastMissionPassedTime = CTimer::GetTimeInMilliseconds();
CGameLogic::RemoveShortCutDropOffPointForMission();
return 0;
case COMMAND_IS_PLAYER_IN_SHORTCUT_TAXI:
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
script_assert(pPed);
UpdateCompareFlag(pPed->bInVehicle && pPed->m_pMyVehicle && pPed->m_pMyVehicle == CGameLogic::pShortCutTaxi);
return 0;
}
case COMMAND_IS_CHAR_DUCKING:
{
CollectParameters(&m_nIp, 1);
CPed* pPed = CPools::GetPedPool()->GetAt(ScriptParams[0]);
script_assert(pPed);
UpdateCompareFlag(RpAnimBlendClumpGetAssociation(pPed->GetClump(), ANIM_DUCK_DOWN) != nil);
return 0;
}
case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI:
{
CollectParameters(&m_nIp, 3);
CObject *pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
bool found = false;
float waterLevel = -1000.0f;
CVector pos = pHeli->GetPosition();
float radius = *(float*)&ScriptParams[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]);
return 0;
}
case COMMAND_REGISTER_FIRE_LEVEL:
CollectParameters(&m_nIp, 1);
CStats::RegisterLevelFireMission(ScriptParams[0]);
return 0;
case COMMAND_IS_AUSTRALIAN_GAME:
UpdateCompareFlag(false); // should we make some check?
return 0;
case COMMAND_DISARM_CAR_BOMB:
{
CollectParameters(&m_nIp, 1);
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
if (pVehicle->m_bombType != CARBOMB_NONE) {
pVehicle->m_bombType = CARBOMB_NONE;
pVehicle->m_pBombRigger = nil;
}
return 0;
}
#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT)
case COMMAND_IS_JAPANESE_GAME:
#ifdef MORE_LANGUAGES
UpdateCompareFlag(FrontEndMenuManager.m_PrefsLanguage == LANGUAGE_JAPANESE);
#elif (defined GTAVC_JP_PATCH)
UpdateCompareFlag(true);
#else
UpdateCompareFlag(false);
#endif
return 0;
#elif (!defined GTA_PS2)
case COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED:
script_assert(CTheScripts::ScriptSpace[m_nIp++] == ARGUMENT_GLOBALVAR);
uint16 var = CTheScripts::Read2BytesFromScript(&m_nIp);
CollectParameters(&m_nIp, 1);
//CUserDisplay::OnscnTimer.SetCounterFlashWhenFirstDisplayed(var, ScriptParams[0]);
break;
#endif
#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
case COMMAND_SHUFFLE_CARD_DECKS:
{
CollectParameters(&m_nIp, 1);
script_assert(ScriptParams[0] >= 0 && ScriptParams[0] <= 6);
for (int i = 0; i < CARDS_IN_STACK; i++)
CTheScripts::CardStack[i] = 0;
int16 seq[CARDS_IN_STACK];
for (int i = 0; i < MAX_DECKS * CARDS_IN_DECK; i++)
seq[i] = i;
int cards_left = CARDS_IN_DECK * ScriptParams[0];
for (int k = 1; k < CARDS_IN_DECK + 1; k++) {
for (int deck = 0; deck < ScriptParams[0]; deck++) {
int index = CGeneral::GetRandomNumberInRange(0, cards_left);
CTheScripts::CardStack[seq[index]] = k;
for (int l = index; l < cards_left; l++) {
if (l + 1 < CARDS_IN_STACK)
seq[l] = seq[l + 1];
else
seq[l] = 0;
}
--cards_left;
}
}
CTheScripts::CardStackPosition = 0;
return 0;
}
case COMMAND_FETCH_NEXT_CARD:
{
if (CTheScripts::CardStack[CTheScripts::CardStackPosition] == 0)
CTheScripts::CardStackPosition = 0;
ScriptParams[0] = CTheScripts::CardStack[CTheScripts::CardStackPosition++];
if (CTheScripts::CardStackPosition == CARDS_IN_DECK * MAX_DECKS)
CTheScripts::CardStackPosition = 0;
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_GET_OBJECT_VELOCITY:
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
*(CVector*)ScriptParams[0] = GAME_SPEED_TO_METERS_PER_SECOND * pObject->GetMoveSpeed();
StoreParameters(&m_nIp, 3);
return 0;
}
case COMMAND_IS_DEBUG_CAMERA_ON:
UpdateCompareFlag(TheCamera.WorldViewerBeingUsed);
return 0;
case COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY:
{
CollectParameters(&m_nIp, 4);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
CVector newSpeed = pObject->GetTurnSpeed() + *(CVector*)ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND;
if (pObject->bIsStatic) {
pObject->SetIsStatic(false);
pObject->AddToMovingList();
}
pObject->SetTurnSpeed(newSpeed.x, newSpeed.y, newSpeed.z);
return 0;
}
case COMMAND_SET_OBJECT_ROTATION_VELOCITY:
{
CollectParameters(&m_nIp, 4);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
CVector newSpeed = *(CVector*)ScriptParams[1] / GAME_SPEED_TO_METERS_PER_SECOND;
if (pObject->bIsStatic) {
pObject->SetIsStatic(false);
pObject->AddToMovingList();
}
pObject->SetTurnSpeed(newSpeed.x, newSpeed.y, newSpeed.z);
return 0;
}
case COMMAND_IS_OBJECT_STATIC:
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
UpdateCompareFlag(pObject->GetIsStatic());
return 0;
}
case COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS:
{
CollectParameters(&m_nIp, 4);
CVector2D v1 = *(CVector2D*)ScriptParams[0];
CVector2D v2 = *(CVector2D*)ScriptParams[2];
float c = DotProduct2D(v1, v2) / (v1.Magnitude() * v2.Magnitude());
#ifdef FIX_BUGS // command is a SA leftover where it was fixed to this
*(float*)ScriptParams[0] = RADTODEG(Acos(c));
#else
*(float*)ScriptParams[0] = Acos(c);
#endif
return 0;
}
case COMMAND_DO_2D_RECTANGLES_COLLIDE:
{
CollectParameters(&m_nIp, 8);
float infX1 = *(float*)&ScriptParams[0] - *(float*)&ScriptParams[2] * 0.5; // NB: not float
float supX1 = *(float*)&ScriptParams[0] + *(float*)&ScriptParams[2] * 0.5;
float infX2 = *(float*)&ScriptParams[4] - *(float*)&ScriptParams[6] * 0.5;
float supX2 = *(float*)&ScriptParams[4] + *(float*)&ScriptParams[6] * 0.5;
float infY1 = *(float*)&ScriptParams[1] - *(float*)&ScriptParams[3] * 0.5;
float supY1 = *(float*)&ScriptParams[1] + *(float*)&ScriptParams[3] * 0.5;
float infY2 = *(float*)&ScriptParams[5] - *(float*)&ScriptParams[7] * 0.5;
float supY2 = *(float*)&ScriptParams[5] + *(float*)&ScriptParams[7] * 0.5;
bool collide = true;
if (infY2 > supY1)
collide = false;
if (infY1 > supY2)
collide = false;
if (infX2 > supX1)
collide = false;
if (infX1 > supX2)
collide = false;
UpdateCompareFlag(collide);
return 0;
}
case COMMAND_GET_OBJECT_ROTATION_VELOCITY:
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
*(CVector*)ScriptParams[0] = pObject->GetTurnSpeed() * GAME_SPEED_TO_METERS_PER_SECOND;
StoreParameters(&m_nIp, 3);
return 0;
}
case COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY:
{
CollectParameters(&m_nIp, 4);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
CVector vecAddition = *(CVector*)&ScriptParams[1] * CTimer::GetTimeStep() / GAME_SPEED_TO_METERS_PER_SECOND;
if (!pObject->bIsStatic) {
CVector vecCurrSpeed = pObject->GetSpeed();
vecCurrSpeed.Normalise();
if (vecCurrSpeed.z != 1.0) { // NB: not float!
CVector vx = CrossProduct(vecCurrSpeed, CVector(0.0f, 0.0f, 1.0f));
vx.Normalise();
CVector vz = CrossProduct(vx, vecCurrSpeed);
vz.Normalise();
CVector vecNewSpeed = pObject->GetSpeed() + vecAddition.x * vx + vecAddition.y * vecCurrSpeed + vecAddition.z * vecCurrSpeed;
if (pObject->bIsStatic) {
pObject->SetIsStatic(false);
pObject->AddToMovingList();
}
pObject->SetMoveSpeed(vecNewSpeed);
}
}
return 0;
}
case COMMAND_GET_OBJECT_SPEED:
{
CollectParameters(&m_nIp, 1);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
*(float*)ScriptParams[0] = pObject->GetMoveSpeed().Magnitude() * GAME_SPEED_TO_METERS_PER_SECOND;
StoreParameters(&m_nIp, 1);
return 0;
}
#endif
#if (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
case COMMAND_IS_MISSION_SKIP:
#ifdef MISSION_REPLAY
ScriptParams[0] = MissionSkipLevel;
#else
ScriptParams[0] = 0;
#endif
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_SET_IN_AMMUNATION:
CollectParameters(&m_nIp, 1);
#ifdef MISSION_REPLAY
IsInAmmunation = ScriptParams[0];
#endif
return 0;
case COMMAND_DO_SAVE_GAME:
CollectParameters(&m_nIp, 1);
#ifdef MISSION_REPLAY
SaveGameForPause(ScriptParams[0]);
#endif
return 0;
case COMMAND_IS_RETRY:
#ifdef MISSION_REPLAY
if (strcmp(m_abScriptName, "porno4") != 0)
ScriptParams[0] = AllowMissionReplay;
#ifdef FIX_BUGS
else
ScriptParams[0] = gbTryingPorn4Again;
#else
else if (gbTryingPorn4Again)
ScriptParams[0] = 1;
#endif
#else
ScriptParams[0] = 0;
#endif
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_DUMMY:
return 0;
#endif
#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
// it is unknown what these commands do but they don't take parameters
case COMMAND_MARK_CUTSCENE_START:
return 0;
case COMMAND_MARK_CUTSCENE_END:
return 0;
case COMMAND_CUTSCENE_SCROLL:
return 0;
#endif
default:
script_assert(0);
}
return -1;
}

View File

@ -1437,6 +1437,39 @@ enum {
COMMAND_REGISTER_FIRE_LEVEL,
COMMAND_IS_AUSTRALIAN_GAME,
COMMAND_DISARM_CAR_BOMB,
#if (defined GTAVC_JP_PATCH || defined SUPPORT_JAPANESE_SCRIPT)
COMMAND_IS_JAPANESE_GAME,
#elif (!defined GTA_PS2)
COMMAND_SET_ONSCREEN_COUNTER_FLASH_WHEN_FIRST_DISPLAYED,
#endif
#if (defined GTA_PC && !defined GTAVC_JP_PATCH || defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT || defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
COMMAND_SHUFFLE_CARD_DECKS,
COMMAND_FETCH_NEXT_CARD,
COMMAND_GET_OBJECT_VELOCITY,
COMMAND_IS_DEBUG_CAMERA_ON,
COMMAND_ADD_TO_OBJECT_ROTATION_VELOCITY,
COMMAND_SET_OBJECT_ROTATION_VELOCITY,
COMMAND_IS_OBJECT_STATIC,
COMMAND_GET_ANGLE_BETWEEN_2D_VECTORS,
COMMAND_DO_2D_RECTANGLES_COLLIDE,
COMMAND_GET_OBJECT_ROTATION_VELOCITY,
COMMAND_ADD_VELOCITY_RELATIVE_TO_OBJECT_VELOCITY,
COMMAND_GET_OBJECT_SPEED,
#endif
#if (defined GTA_XBOX || defined SUPPORT_XBOX_SCRIPT)
COMMAND_MARK_CUTSCENE_START,
COMMAND_MARK_CUTSCENE_END,
COMMAND_CUTSCENE_SCROLL,
#elif (defined GTA_MOBILE || defined SUPPORT_MOBILE_SCRIPT)
COMMAND_IS_MISSION_SKIP,
COMMAND_SET_IN_AMMUNATION,
COMMAND_DO_SAVE_GAME,
COMMAND_IS_RETRY,
COMMAND_DUMMY,
COMMAND_MARK_CUTSCENE_START,
COMMAND_MARK_CUTSCENE_END,
COMMAND_CUTSCENE_SCROLL,
#endif
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
LAST_SCRIPT_COMMAND
#endif

View File

@ -29,7 +29,7 @@ void CSetPieces::AddOne(uint8 type, CVector2D vTriggerInf, CVector2D vTriggerSup
{
if (NumSetPieces >= NUM_SETPIECES)
return;
aSetPieces[NumSetPieces].m_nType = (eSetPieceType)type;
aSetPieces[NumSetPieces].m_nType = type;
aSetPieces[NumSetPieces].m_vTriggerInf.x = Min(vTriggerInf.x, vTriggerSup.x);
aSetPieces[NumSetPieces].m_vTriggerInf.y = Min(vTriggerInf.y, vTriggerSup.y);
aSetPieces[NumSetPieces].m_vTriggerSup.x = Max(vTriggerInf.x, vTriggerSup.x);

View File

@ -5,7 +5,7 @@
class CVehicle;
class CCopPed;
enum eSetPieceType : uint8
enum eSetPieceType
{
SETPIECE_NONE = 0,
SETPIECE_TWOCOPCARSINALLEY,
@ -20,7 +20,7 @@ enum eSetPieceType : uint8
class CSetPiece
{
public:
eSetPieceType m_nType;
uint8 m_nType;
uint32 m_nLastTimeCreated;
CVector2D m_vTriggerInf;
CVector2D m_vTriggerSup;