mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-11-28 03:54:15 +01:00
Merge pull request #516 from Nick007J/miami
miami (script + other) stuff
This commit is contained in:
commit
03cecb6f1c
@ -146,7 +146,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
case MISSION_BLOCKPLAYER_CLOSE:
|
case MISSION_BLOCKPLAYER_CLOSE:
|
||||||
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
if (FindSwitchDistanceFar(pVehicle) >= (FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() ||
|
||||||
pVehicle->AutoPilot.m_bIgnorePathfinding) {
|
pVehicle->AutoPilot.m_bIgnorePathfinding) {
|
||||||
if (FindPlayerVehicle() && FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f)
|
if (FindPlayerVehicle() && FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.04f)
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
pVehicle->m_nTimeBlocked += CTimer::GetTimeStepInMilliseconds();
|
pVehicle->m_nTimeBlocked += CTimer::GetTimeStepInMilliseconds();
|
||||||
#else
|
#else
|
||||||
@ -155,7 +155,7 @@ void CCarAI::UpdateCarAI(CVehicle* pVehicle)
|
|||||||
else
|
else
|
||||||
pVehicle->m_nTimeBlocked = 0;
|
pVehicle->m_nTimeBlocked = 0;
|
||||||
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
|
if (!FindPlayerVehicle() || FindPlayerVehicle()->IsUpsideDown() ||
|
||||||
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.05f && pVehicle->m_nTimeBlocked > TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING) {
|
FindPlayerVehicle()->GetMoveSpeed().Magnitude() < 0.04f && pVehicle->m_nTimeBlocked > TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING) {
|
||||||
if (pVehicle->bIsLawEnforcer &&
|
if (pVehicle->bIsLawEnforcer &&
|
||||||
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
|
(pVehicle->GetModelIndex() != MI_RHINO || pVehicle->m_randomSeed > 10000) &&
|
||||||
(FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
|
(FindPlayerCoors() - pVehicle->GetPosition()).Magnitude2D() < 10.0f) {
|
||||||
|
@ -90,14 +90,16 @@ uint32 aCarsToKeepTime[MAX_CARS_TO_KEEP];
|
|||||||
void
|
void
|
||||||
CCarCtrl::GenerateRandomCars()
|
CCarCtrl::GenerateRandomCars()
|
||||||
{
|
{
|
||||||
if (CCutsceneMgr::IsRunning())
|
if (CCutsceneMgr::IsRunning()) {
|
||||||
|
CountDownToCarsAtStart = 2;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (NumRandomCars < 30){
|
if (NumRandomCars < 30){
|
||||||
if (CountDownToCarsAtStart == 0){
|
if (CountDownToCarsAtStart == 0){
|
||||||
GenerateOneRandomCar();
|
GenerateOneRandomCar();
|
||||||
}
|
}
|
||||||
else if (--CountDownToCarsAtStart == 0) {
|
else if (--CountDownToCarsAtStart == 0) {
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
GenerateOneRandomCar();
|
GenerateOneRandomCar();
|
||||||
CTheCarGenerators::GenerateEvenIfPlayerIsCloseCounter = 20;
|
CTheCarGenerators::GenerateEvenIfPlayerIsCloseCounter = 20;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "CarGen.h"
|
#include "CarGen.h"
|
||||||
#include "CivilianPed.h"
|
#include "CivilianPed.h"
|
||||||
#include "Clock.h"
|
#include "Clock.h"
|
||||||
|
#include "ColStore.h"
|
||||||
#include "CopPed.h"
|
#include "CopPed.h"
|
||||||
#include "Coronas.h"
|
#include "Coronas.h"
|
||||||
#include "Cranes.h"
|
#include "Cranes.h"
|
||||||
@ -170,10 +171,46 @@ void CMissionCleanup::AddEntityToList(int32 id, uint8 type)
|
|||||||
m_nCount++;
|
m_nCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void PossiblyWakeThisEntity(CPhysical* pEntity)
|
||||||
|
{
|
||||||
|
if (!pEntity->bIsStaticWaitingForCollision)
|
||||||
|
return;
|
||||||
|
if (CColStore::HasCollisionLoaded(pEntity->GetPosition())) {
|
||||||
|
pEntity->bIsStaticWaitingForCollision = false;
|
||||||
|
if (!pEntity->IsStatic())
|
||||||
|
pEntity->AddToMovingList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
|
void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < MAX_CLEANUP; i++){
|
for (int i = 0; i < MAX_CLEANUP; i++){
|
||||||
if (m_sEntities[i].type == type && m_sEntities[i].id == id){
|
if (m_sEntities[i].type == type && m_sEntities[i].id == id){
|
||||||
|
switch (m_sEntities[i].type) {
|
||||||
|
case CLEANUP_CAR:
|
||||||
|
{
|
||||||
|
CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (v)
|
||||||
|
PossiblyWakeThisEntity(v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLEANUP_CHAR:
|
||||||
|
{
|
||||||
|
CPed* p = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (p)
|
||||||
|
PossiblyWakeThisEntity(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLEANUP_OBJECT:
|
||||||
|
{
|
||||||
|
CObject* o = CPools::GetObjectPool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (o)
|
||||||
|
PossiblyWakeThisEntity(o);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
m_sEntities[i].id = 0;
|
m_sEntities[i].id = 0;
|
||||||
m_sEntities[i].type = CLEANUP_UNUSED;
|
m_sEntities[i].type = CLEANUP_UNUSED;
|
||||||
m_nCount--;
|
m_nCount--;
|
||||||
@ -181,6 +218,52 @@ void CMissionCleanup::RemoveEntityFromList(int32 id, uint8 type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMissionCleanup::CheckIfCollisionHasLoadedForMissionObject()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < MAX_CLEANUP; i++) {
|
||||||
|
switch (m_sEntities[i].type) {
|
||||||
|
case CLEANUP_CAR:
|
||||||
|
{
|
||||||
|
CVehicle* v = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (v)
|
||||||
|
PossiblyWakeThisEntity(v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLEANUP_CHAR:
|
||||||
|
{
|
||||||
|
CPed* p = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (p)
|
||||||
|
PossiblyWakeThisEntity(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CLEANUP_OBJECT:
|
||||||
|
{
|
||||||
|
CObject* o = CPools::GetObjectPool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (o)
|
||||||
|
PossiblyWakeThisEntity(o);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CPhysical* CMissionCleanup::DoesThisEntityWaitForCollision(int i)
|
||||||
|
{
|
||||||
|
if (m_sEntities[i].type == CLEANUP_CAR) {
|
||||||
|
CVehicle* pVehicle = CPools::GetVehiclePool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (pVehicle && pVehicle->GetStatus() != STATUS_WRECKED)
|
||||||
|
return pVehicle;
|
||||||
|
}
|
||||||
|
else if (m_sEntities[i].type == CLEANUP_CHAR) {
|
||||||
|
CPed* pPed = CPools::GetPedPool()->GetAt(m_sEntities[i].id);
|
||||||
|
if (pPed && !pPed->DyingOrDead())
|
||||||
|
return pPed;
|
||||||
|
}
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
void CMissionCleanup::Process()
|
void CMissionCleanup::Process()
|
||||||
{
|
{
|
||||||
CPopulation::m_AllRandomPedsThisType = -1;
|
CPopulation::m_AllRandomPedsThisType = -1;
|
||||||
@ -646,6 +729,7 @@ void CTheScripts::Process()
|
|||||||
float timeStep = CTimer::GetTimeStepInMilliseconds();
|
float timeStep = CTimer::GetTimeStepInMilliseconds();
|
||||||
UpsideDownCars.UpdateTimers();
|
UpsideDownCars.UpdateTimers();
|
||||||
StuckCars.Process();
|
StuckCars.Process();
|
||||||
|
MissionCleanup.CheckIfCollisionHasLoadedForMissionObject();
|
||||||
DrawScriptSpheres();
|
DrawScriptSpheres();
|
||||||
if (FailCurrentMission)
|
if (FailCurrentMission)
|
||||||
--FailCurrentMission;
|
--FailCurrentMission;
|
||||||
@ -1728,6 +1812,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
|
|||||||
ped->SetPosition(pos);
|
ped->SetPosition(pos);
|
||||||
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
||||||
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
||||||
|
if (m_bIsMissionScript)
|
||||||
|
ped->bIsStaticWaitingForCollision = true;
|
||||||
CWorld::Add(ped);
|
CWorld::Add(ped);
|
||||||
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
CPopulation::ms_nTotalMissionPeds++;
|
CPopulation::ms_nTotalMissionPeds++;
|
||||||
@ -1946,6 +2032,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
|
|||||||
boat->AutoPilot.m_nCarMission = MISSION_NONE;
|
boat->AutoPilot.m_nCarMission = MISSION_NONE;
|
||||||
boat->AutoPilot.m_nTempAction = TEMPACT_NONE; /* Animation ID? */
|
boat->AutoPilot.m_nTempAction = TEMPACT_NONE; /* Animation ID? */
|
||||||
boat->AutoPilot.m_nCruiseSpeed = boat->AutoPilot.m_fMaxTrafficSpeed = 20.0f;
|
boat->AutoPilot.m_nCruiseSpeed = boat->AutoPilot.m_fMaxTrafficSpeed = 20.0f;
|
||||||
|
if (m_bIsMissionScript)
|
||||||
|
boat->bIsStaticWaitingForCollision = true;
|
||||||
CWorld::Add(boat);
|
CWorld::Add(boat);
|
||||||
handle = CPools::GetVehiclePool()->GetIndex(boat);
|
handle = CPools::GetVehiclePool()->GetIndex(boat);
|
||||||
}
|
}
|
||||||
@ -1970,6 +2058,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
|
|||||||
car->bEngineOn = false;
|
car->bEngineOn = false;
|
||||||
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
car->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
car->bHasBeenOwnedByPlayer = true;
|
car->bHasBeenOwnedByPlayer = true;
|
||||||
|
if (m_bIsMissionScript)
|
||||||
|
car->bIsStaticWaitingForCollision = true;
|
||||||
CWorld::Add(car);
|
CWorld::Add(car);
|
||||||
handle = CPools::GetVehiclePool()->GetIndex(car);
|
handle = CPools::GetVehiclePool()->GetIndex(car);
|
||||||
}
|
}
|
||||||
@ -7324,6 +7414,8 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
|
|||||||
ped->SetPosition(pos);
|
ped->SetPosition(pos);
|
||||||
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
ped->SetOrientation(0.0f, 0.0f, 0.0f);
|
||||||
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
CTheScripts::ClearSpaceForMissionEntity(pos, ped);
|
||||||
|
if (m_bIsMissionScript)
|
||||||
|
ped->bIsStaticWaitingForCollision = true;
|
||||||
CWorld::Add(ped);
|
CWorld::Add(ped);
|
||||||
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
ped->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pos);
|
||||||
CPopulation::ms_nTotalMissionPeds++;
|
CPopulation::ms_nTotalMissionPeds++;
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
class CEntity;
|
class CEntity;
|
||||||
class CBuilding;
|
class CBuilding;
|
||||||
|
class CPhysical;
|
||||||
class CVehicle;
|
class CVehicle;
|
||||||
class CPed;
|
class CPed;
|
||||||
class CObject;
|
class CObject;
|
||||||
@ -131,6 +132,8 @@ public:
|
|||||||
void AddEntityToList(int32, uint8);
|
void AddEntityToList(int32, uint8);
|
||||||
void RemoveEntityFromList(int32, uint8);
|
void RemoveEntityFromList(int32, uint8);
|
||||||
void Process();
|
void Process();
|
||||||
|
void CheckIfCollisionHasLoadedForMissionObject();
|
||||||
|
CPhysical* DoesThisEntityWaitForCollision(int i);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CUpsideDownCarCheckEntry
|
struct CUpsideDownCarCheckEntry
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "Frontend.h"
|
#include "Frontend.h"
|
||||||
|
#include "Physical.h"
|
||||||
#include "ColStore.h"
|
#include "ColStore.h"
|
||||||
|
|
||||||
CPool<ColDef,ColDef> *CColStore::ms_pColPool;
|
CPool<ColDef,ColDef> *CColStore::ms_pColPool;
|
||||||
@ -174,7 +175,13 @@ CColStore::LoadCollision(const CVector2D &pos)
|
|||||||
CGeneral::faststrcmp(GetColName(i), "yacht") == 0){
|
CGeneral::faststrcmp(GetColName(i), "yacht") == 0){
|
||||||
wantThisOne = true;
|
wantThisOne = true;
|
||||||
}else{
|
}else{
|
||||||
// TODO: check mission cleanup list
|
for (int j = 0; j < MAX_CLEANUP; j++) {
|
||||||
|
CPhysical* pEntity = CTheScripts::MissionCleanup.DoesThisEntityWaitForCollision(j);
|
||||||
|
if (pEntity /* !pEntity->bDontLoadCollision && !pEntity->bIsFrozen */) {
|
||||||
|
if (GetBoundingBox(i).IsPointInside(pEntity->GetPosition(), -80.0f))
|
||||||
|
wantThisOne = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(wantThisOne)
|
if(wantThisOne)
|
||||||
@ -221,7 +228,7 @@ CColStore::HasCollisionLoaded(const CVector2D &pos)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(i = 1; i < COLSTORESIZE; i++)
|
for(i = 1; i < COLSTORESIZE; i++)
|
||||||
if(GetSlot(i) && GetBoundingBox(i).IsPointInside(pos, -110.0f) &&
|
if(GetSlot(i) && GetBoundingBox(i).IsPointInside(pos, -115.0f) &&
|
||||||
!GetSlot(i)->isLoaded)
|
!GetSlot(i)->isLoaded)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -74,6 +74,8 @@ CEntity::CEntity(void)
|
|||||||
bDistanceFade = false;
|
bDistanceFade = false;
|
||||||
m_flagE2 = false;
|
m_flagE2 = false;
|
||||||
|
|
||||||
|
bIsStaticWaitingForCollision = false;
|
||||||
|
|
||||||
m_scanCode = 0;
|
m_scanCode = 0;
|
||||||
m_modelIndex = -1;
|
m_modelIndex = -1;
|
||||||
m_rwObject = nil;
|
m_rwObject = nil;
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
// flagsE
|
// flagsE
|
||||||
uint32 m_flagE2 : 1;
|
uint32 m_flagE2 : 1;
|
||||||
// TODO(MIAMI)
|
// TODO(MIAMI)
|
||||||
|
uint32 bIsStaticWaitingForCollision : 1; // this is used by script created entities - they are static until the collision is loaded below them
|
||||||
|
|
||||||
uint16 m_scanCode;
|
uint16 m_scanCode;
|
||||||
uint16 m_randomSeed;
|
uint16 m_randomSeed;
|
||||||
@ -98,7 +99,7 @@ public:
|
|||||||
eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
|
eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
|
||||||
void SetStatus(eEntityStatus status) { m_status = status; }
|
void SetStatus(eEntityStatus status) { m_status = status; }
|
||||||
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
|
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
|
||||||
bool IsStatic(void) { return bIsStatic; }
|
bool IsStatic(void) { return bIsStatic || bIsStaticWaitingForCollision; }
|
||||||
#ifdef COMPATIBLE_SAVES
|
#ifdef COMPATIBLE_SAVES
|
||||||
void SaveEntityFlags(uint8*& buf);
|
void SaveEntityFlags(uint8*& buf);
|
||||||
void LoadEntityFlags(uint8*& buf);
|
void LoadEntityFlags(uint8*& buf);
|
||||||
|
@ -218,6 +218,7 @@ CPhysical::GetBoundRect(void)
|
|||||||
void
|
void
|
||||||
CPhysical::AddToMovingList(void)
|
CPhysical::AddToMovingList(void)
|
||||||
{
|
{
|
||||||
|
if (!bIsStaticWaitingForCollision)
|
||||||
m_movingListNode = CWorld::GetMovingEntityList().InsertItem(this);
|
m_movingListNode = CWorld::GetMovingEntityList().InsertItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user