Merge pull request #1 from GTAmodding/miami

Miami
This commit is contained in:
Fire_Head
2020-08-27 20:35:14 +03:00
committed by GitHub
258 changed files with 9348 additions and 71142 deletions

View File

@ -81,6 +81,9 @@
#define OFFSCREEN_DESPAWN_RANGE (40.0f)
#define EXTENDED_RANGE_DESPAWN_MULTIPLIER (1.5f)
//--MIAMI: file done
bool CCarCtrl::bMadDriversCheat;
int CCarCtrl::NumLawEnforcerCars;
int CCarCtrl::NumAmbulancesOnDuty;
int CCarCtrl::NumFiretrucksOnDuty;
@ -158,7 +161,7 @@ CCarCtrl::GenerateOneRandomCar()
carModel = ChoosePoliceCarModel();
}else{
carModel = ChooseModel(&zone, &vecTargetPos, &carClass);
if (carClass == COPS && pWanted->m_nWantedLevel >= 1 || carModel < 0)
if (carModel == -1 || (carClass == COPS && pWanted->m_nWantedLevel >= 1))
/* All cop spawns with wanted level are handled by condition above. */
/* In particular it means that cop cars never spawn if player has wanted level of 1. */
return;
@ -664,7 +667,7 @@ CCarCtrl::GenerateOneRandomCar()
nMadDrivers = 6;
break;
}
if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers /* TODO(MIAMI): || mad drivers cheat */) {
if ((CGeneral::GetRandomNumber() & 0x7F) < nMadDrivers || bMadDriversCheat) {
pVehicle->SetStatus(STATUS_PHYSICS);
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
pVehicle->AutoPilot.m_nCruiseSpeed += 10;
@ -758,7 +761,8 @@ CCarCtrl::ChooseCarRating(CZoneInfo* pZoneInfo)
int32
CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) {
int32 model = -1;
for (int i = 0; i < 10 && (model == -1 || !CStreaming::HasModelLoaded(model)); i++) {
int32 i;
for (i = 10; i > 0 && (model == -1 || !CStreaming::HasModelLoaded(model)); i--) {
int rnd = CGeneral::GetRandomNumberInRange(0, 1000);
if (rnd < pZone->copThreshold) {
@ -767,9 +771,9 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) {
continue;
}
int j;
int32 j;
for (j = 0; j < NUM_GANG_CAR_CLASSES; j++) {
if (rnd < pZone->gangThreshold[i]) {
if (rnd < pZone->gangThreshold[j]) {
*pClass = j + FIRST_GANG_CAR_RATING;
model = ChooseGangCarModel(j);
break;
@ -782,6 +786,8 @@ CCarCtrl::ChooseModel(CZoneInfo* pZone, CVector* pPos, int* pClass) {
*pClass = ChooseCarRating(pZone);
model = ChooseCarModel(*pClass);
}
if (i == 0)
return -1;
return model;
}
@ -950,6 +956,10 @@ CCarCtrl::RemoveCarsIfThePoolGetsFull(void)
void
CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle)
{
#ifdef FIX_BUGS
if (pVehicle->bIsLocked)
return;
#endif
CVector vecPlayerPos = FindPlayerCentreOfWorld(CWorld::PlayerInFocus);
/* BUG: this variable is initialized only in if-block below but can be used outside of it. */
if (!IsThisVehicleInteresting(pVehicle) && !pVehicle->bIsLocked &&
@ -2515,7 +2525,7 @@ void CCarCtrl::SteerAICarWithPhysics_OnlyMission(CVehicle* pVehicle, float* pSwe
SteerAIBoatWithPhysicsAttackingPlayer(pVehicle, pSwerve, pAccel, pBrake, pHandbrake);
return;
case MISSION_PLANE_FLYTOCOORS:
//SteerAIPlaneTowardsTargetCoors((CAutomobile*)pVehicle);
SteerAIPlaneTowardsTargetCoors((CAutomobile*)pVehicle);
return;
case MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1:
SteerAICarWithPhysicsHeadingForTarget(pVehicle, nil,
@ -2737,6 +2747,51 @@ void CCarCtrl::SteerAIHeliTowardsTargetCoors(CAutomobile* pHeli)
pHeli->GetMatrix().GetUp() = up;
}
void CCarCtrl::SteerAIPlaneTowardsTargetCoors(CAutomobile* pPlane)
{
CVector2D vecToTarget = pPlane->AutoPilot.m_vecDestinationCoors - pPlane->GetPosition();
float fForwardZ = (pPlane->AutoPilot.m_vecDestinationCoors.z - pPlane->GetPosition().z) / vecToTarget.Magnitude();
fForwardZ = clamp(fForwardZ, -0.3f, 0.3f);
float angle = CGeneral::GetATanOfXY(vecToTarget.x, vecToTarget.y);
while (angle > TWOPI)
angle -= TWOPI;
float difference = LimitRadianAngle(angle - pPlane->m_fOrientation);
float steer = difference > 0.0f ? 0.04f : -0.04f;
if (Abs(difference) < 0.2f)
steer *= 5.0f * Abs(difference);
pPlane->m_fPlaneSteer *= Pow(0.96f, CTimer::GetTimeStep());
float steerChange = steer - pPlane->m_fPlaneSteer;
float maxChange = 0.003f * CTimer::GetTimeStep();
if (Abs(steerChange) < maxChange)
pPlane->m_fPlaneSteer = steer;
else if (steerChange < 0.0f)
pPlane->m_fPlaneSteer -= maxChange;
else
pPlane->m_fPlaneSteer += maxChange;
pPlane->m_fOrientation += pPlane->m_fPlaneSteer * CTimer::GetTimeStep();
CVector up(0.0f, 0.0f, 1.0f);
up.Normalise();
CVector forward(Cos(pPlane->m_fOrientation), Sin(pPlane->m_fOrientation), fForwardZ);
forward.Normalise();
CVector right = CrossProduct(forward, up);
right.z -= 5.0f * pPlane->m_fPlaneSteer;
right.Normalise();
up = CrossProduct(forward, right);
up.Normalise();
right = CrossProduct(forward, up);
pPlane->GetMatrix().GetRight() = right;
pPlane->GetMatrix().GetForward() = forward;
pPlane->GetMatrix().GetUp() = up;
float newSplit = 1.0f - Pow(0.95f, CTimer::GetTimeStep());
float oldSplit = 1.0f - newSplit;
#ifdef FIX_BUGS
pPlane->m_vecMoveSpeed = pPlane->m_vecMoveSpeed * oldSplit + pPlane->AutoPilot.GetCruiseSpeed() * 0.01f * forward * newSplit;
#else
pPlane->m_vecMoveSpeed = pPlane->m_vecMoveSpeed * oldSplit + pPlane->AutoPilot.m_nCruiseSpeed * 0.01f * forward * newSplit;
#endif
pPlane->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
}
void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
{
CVector2D forward = pVehicle->GetForward();

View File

@ -145,6 +145,7 @@ public:
return angle;
}
static bool bMadDriversCheat;
static int32 NumLawEnforcerCars;
static int32 NumAmbulancesOnDuty;
static int32 NumFiretrucksOnDuty;

View File

@ -32,9 +32,9 @@ int8 CDarkel::InterruptedWeapon;
* makes game handle sounds & messages instead of SCM (just like in GTA2)
* but it's never been used in the game. Has unused sliding text when frenzy completed etc.
*/
int8 CDarkel::bStandardSoundAndMessages;
int8 CDarkel::bNeedHeadShot;
int8 CDarkel::bProperKillFrenzy;
bool CDarkel::bStandardSoundAndMessages;
bool CDarkel::bNeedHeadShot;
bool CDarkel::bProperKillFrenzy;
uint16 CDarkel::Status;
uint16 CDarkel::RegisteredKills[NUM_DEFAULT_MODELS];
int32 CDarkel::ModelToKill;

View File

@ -24,9 +24,9 @@ private:
static int32 AmmoInterruptedWeapon;
static int32 KillsNeeded;
static int8 InterruptedWeapon;
static int8 bStandardSoundAndMessages;
static int8 bNeedHeadShot;
static int8 bProperKillFrenzy;
static bool bStandardSoundAndMessages;
static bool bNeedHeadShot;
static bool bProperKillFrenzy;
static uint16 Status;
static uint16 RegisteredKills[NUM_DEFAULT_MODELS];
static int32 ModelToKill;

View File

@ -28,6 +28,7 @@
#include "Particle.h"
#include "ColStore.h"
#include "Automobile.h"
#include "MBlur.h"
uint8 CGameLogic::ActivePlayers;
uint8 CGameLogic::ShortCutState;
@ -343,7 +344,10 @@ CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed *pPlayerPed, CVector
pPlayerPed->bIsVisible = true;
pPlayerPed->m_bloodyFootprintCountOrDeathTime = 0;
pPlayerPed->bDoBloodyFootprints = false;
//TODO(MIAMI): clear drunk stuff
pPlayerPed->m_nDrunkenness = 0;
pPlayerPed->m_nFadeDrunkenness = 0;
CMBlur::ClearDrunkBlur();
pPlayerPed->m_nDrunkCountdown = 0;
pPlayerPed->ClearAdrenaline();
pPlayerPed->m_fCurrentStamina = pPlayerPed->m_fMaxStamina;
if (pPlayerPed->m_pFire)
@ -368,7 +372,7 @@ CGameLogic::RestorePlayerStuffDuringResurrection(CPlayerPed *pPlayerPed, CVector
CWorld::ClearExcitingStuffFromArea(pos, 4000.0, 1);
pPlayerPed->RestoreHeadingRate();
CGame::currArea = AREA_MAIN_MAP;
//CStreaming::RemoveBuildingsNotInArea(0); // TODO(MIAMI)
CStreaming::RemoveBuildingsNotInArea(0);
TheCamera.SetCameraDirectlyInFrontForFollowPed_CamOnAString();
TheCamera.Restore();
CReferences::RemoveReferencesToPlayer();

View File

@ -1324,7 +1324,7 @@ void CGarage::RemoveCarsBlockingDoorNotInside()
if (!IsEntityTouching3D(pVehicle))
continue;
if (!IsPointInsideGarage(pVehicle->GetPosition())) {
if (pVehicle->bIsLocked && pVehicle->CanBeDeleted()) {
if (!pVehicle->bIsLocked && pVehicle->CanBeDeleted()) {
CWorld::Remove(pVehicle);
delete pVehicle;
return; // WHY?
@ -1817,8 +1817,9 @@ CVehicle* CStoredCar::RestoreCar()
pVehicle->m_nRadioStation = m_nRadioStation;
pVehicle->bFreebies = false;
#ifdef FIX_BUGS
((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType;
if (pVehicle->IsCar())
#endif
((CAutomobile*)pVehicle)->m_bombType = m_nCarBombType;
pVehicle->bHasBeenOwnedByPlayer = true;
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
pVehicle->bBulletProof = m_bBulletproof;

View File

@ -9,6 +9,8 @@
#include "PlayerInfo.h"
#include "Vehicle.h"
//--MIAMI: file done
void
CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uint16 model)
{
@ -35,17 +37,24 @@ CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uin
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = car;
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle);
TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAMCONTROL_SCRIPT);
if (car->GetVehicleAppearance() == VEHICLE_APPEARANCE_PLANE || car->GetVehicleAppearance() == VEHICLE_APPEARANCE_HELI) {
TheCamera.TakeControl(car, CCam::MODE_CAM_ON_A_STRING, INTERPOLATION, CAMCONTROL_SCRIPT);
TheCamera.SetZoomValueCamStringScript(0);
} else
TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAMCONTROL_SCRIPT);
}
void
CRemote::TakeRemoteControlledCarFromPlayer(void)
CRemote::TakeRemoteControlledCarFromPlayer(bool blowUp)
{
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->VehicleCreatedBy = RANDOM_VEHICLE;
CCarCtrl::NumMissionCars--;
CCarCtrl::NumRandomCars++;
if (CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->VehicleCreatedBy == MISSION_VEHICLE) {
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->VehicleCreatedBy = RANDOM_VEHICLE;
CCarCtrl::NumMissionCars--;
CCarCtrl::NumRandomCars++;
}
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->bIsLocked = false;
CWorld::Players[CWorld::PlayerInFocus].m_nTimeLostRemoteCar = CTimer::GetTimeInMilliseconds();
CWorld::Players[CWorld::PlayerInFocus].m_bInRemoteMode = true;
CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->bRemoveFromWorld = true;
CWorld::Players[CWorld::PlayerInFocus].field_D5 = blowUp;
CWorld::Players[CWorld::PlayerInFocus].field_D6 = true;
}

View File

@ -4,5 +4,5 @@ class CRemote
{
public:
static void GivePlayerRemoteControlledCar(float, float, float, float, uint16);
static void TakeRemoteControlledCarFromPlayer(void);
static void TakeRemoteControlledCarFromPlayer(bool blowUp = true);
};

View File

@ -39,6 +39,7 @@
#include "Text.h"
#include "Camera.h"
#include "Radar.h"
#include "Fluff.h"
uint8 CReplay::Mode;
CAddressInReplayBuffer CReplay::Record;
@ -229,7 +230,7 @@ void CReplay::EnableReplays(void)
void PlayReplayFromHD(void);
void CReplay::Update(void)
{
if (CCutsceneMgr::IsCutsceneProcessing() || CTimer::GetIsPaused())
if (CCutsceneMgr::IsCutsceneProcessing() || CTimer::GetIsPaused() || CScriptPaths::IsOneActive())
return;
switch (Mode){
case MODE_RECORD:
@ -1175,6 +1176,7 @@ void CReplay::StoreStuffInMem(void)
if (ped)
StoreDetailedPedAnimation(ped, &pPedAnims[i]);
}
CScriptPaths::Save_ForReplay();
}
void CReplay::RestoreStuffFromMem(void)
@ -1351,6 +1353,7 @@ void CReplay::RestoreStuffFromMem(void)
}
delete[] pPedAnims;
pPedAnims = nil;
CScriptPaths::Load_ForReplay();
DMAudio.ChangeMusicMode(MUSICMODE_FRONTEND);
DMAudio.SetRadioInCar(OldRadioStation);
DMAudio.ChangeMusicMode(MUSICMODE_GAME);

File diff suppressed because it is too large Load Diff

View File

@ -374,10 +374,10 @@ private:
static int32 GetNewUniqueScriptSphereIndex(int32 index);
static void RemoveScriptSphere(int32 index);
static void RemoveScriptTextureDictionary();
public:
static void RemoveThisPed(CPed* pPed);
#ifdef MISSION_SWITCHER
public:
static void SwitchToMission(int32 mission);
#endif