From 453f8c05a4fc2ef03ba1d4f7bac43ba871c52fbd Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 29 Aug 2021 19:32:22 +0300 Subject: script revision p1 --- src/core/Streaming.cpp | 25 ++++++++++++++++++++++++- src/core/Streaming.h | 2 ++ src/core/World.cpp | 38 ++++++++++++++++++++++++++++---------- src/core/config.h | 2 ++ 4 files changed, 56 insertions(+), 11 deletions(-) (limited to 'src/core') diff --git a/src/core/Streaming.cpp b/src/core/Streaming.cpp index f62ff179..9b8f4a66 100644 --- a/src/core/Streaming.cpp +++ b/src/core/Streaming.cpp @@ -1083,6 +1083,12 @@ CStreaming::SetMissionDoesntRequireSpecialChar(int32 id) return SetMissionDoesntRequireModel(id + MI_SPECIAL01); } +void +CStreaming::SetAmbientMissionDoesntRequireSpecialChar(int32 id) +{ + return SetAmbientMissionDoesntRequireModel(id + MI_SPECIAL01); +} + void CStreaming::DecrementRef(int32 id) { @@ -1625,9 +1631,11 @@ CStreaming::SetModelTxdIsDeletable(int32 id) void CStreaming::SetMissionDoesntRequireModel(int32 id) { + if (ms_aInfoForModel[id].m_flags & STREAMFLAGS_SCRIPTOWNED) + printf("SETTING MISSION DOESN'T REQUIRE MODEL %i\n", id); ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_SCRIPTOWNED; if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) && - (ms_aInfoForModel[id].m_flags & STREAMFLAGS_DONT_REMOVE) == 0){ + (ms_aInfoForModel[id].m_flags & (STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_AMBIENT_SCRIPT_OWNED)) == 0){ if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED) RemoveModel(id); else if(ms_aInfoForModel[id].m_next == nil) @@ -1635,6 +1643,21 @@ CStreaming::SetMissionDoesntRequireModel(int32 id) } } +void +CStreaming::SetAmbientMissionDoesntRequireModel(int32 id) +{ + if (ms_aInfoForModel[id].m_flags & STREAMFLAGS_AMBIENT_SCRIPT_OWNED) + printf("SETTING AMBIENT MISSION DOESN'T REQUIRE MODEL %i\n", id); + ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_AMBIENT_SCRIPT_OWNED; + if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) && + (ms_aInfoForModel[id].m_flags & (STREAMFLAGS_DONT_REMOVE|STREAMFLAGS_SCRIPTOWNED)) == 0) { + if (ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED) + RemoveModel(id); + else if (ms_aInfoForModel[id].m_next == nil) + ms_aInfoForModel[id].AddToList(&ms_startLoadedList); + } +} + void CStreaming::LoadInitialPeds(void) { diff --git a/src/core/Streaming.h b/src/core/Streaming.h index b4a634fa..a5a5a4ab 100644 --- a/src/core/Streaming.h +++ b/src/core/Streaming.h @@ -151,6 +151,7 @@ public: static void RequestSpecialChar(int32 charId, const char *modelName, int32 flags); static bool HasSpecialCharLoaded(int32 id); static void SetMissionDoesntRequireSpecialChar(int32 id); + static void SetAmbientMissionDoesntRequireSpecialChar(int32 id); static void DecrementRef(int32 id); static void RemoveModel(int32 id); static void RemoveTxd(int32 id) { RemoveModel(id + STREAM_OFFSET_TXD); } @@ -175,6 +176,7 @@ public: static void SetModelIsDeletable(int32 id); static void SetModelTxdIsDeletable(int32 id); static void SetMissionDoesntRequireModel(int32 id); + static void SetAmbientMissionDoesntRequireModel(int32 id); static void LoadInitialPeds(void); static void LoadInitialWeapons(void); static void LoadInitialVehicles(void); diff --git a/src/core/World.cpp b/src/core/World.cpp index 2de36383..545c0bde 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1,4 +1,5 @@ #include "common.h" +#include "Bike.h" #include "Camera.h" #include "CarCtrl.h" #include "CopPed.h" @@ -2225,19 +2226,36 @@ CWorld::UseDetonator(CEntity *pEntity) { int32 i = CPools::GetVehiclePool()->GetSize(); while(--i >= 0) { -#ifdef FIX_BUGS CVehicle* pVehicle = CPools::GetVehiclePool()->GetSlot(i); -#else - CAutomobile *pVehicle = (CAutomobile *)CPools::GetVehiclePool()->GetSlot(i); +#if defined FIX_BUGS || defined BOMBS_ON_BIKES + if (pVehicle && pVehicle->IsCar()) #endif - if(pVehicle && pVehicle->m_bombType == CARBOMB_REMOTE && - pVehicle->m_pBombRigger == pEntity) { - pVehicle->m_bombType = CARBOMB_NONE; - pVehicle->m_nBombTimer = 500; - pVehicle->m_pBlowUpEntity = pVehicle->m_pBombRigger; - if(pVehicle->m_pBlowUpEntity) - pVehicle->m_pBlowUpEntity->RegisterReference(&pVehicle->m_pBlowUpEntity); + { + CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetSlot(i); + if (pCar && pCar->m_bombType == CARBOMB_REMOTE && + pCar->m_pBombRigger == pEntity) { + pCar->m_bombType = CARBOMB_NONE; + pCar->m_nBombTimer = 500; + pCar->m_pBlowUpEntity = pCar->m_pBombRigger; + if (pCar->m_pBlowUpEntity) + pCar->m_pBlowUpEntity->RegisterReference(&pCar->m_pBlowUpEntity); + } + } +#ifdef BOMBS_ON_BIKES + if (pVehicle && pVehicle->IsBike()) { + { + CBike* pBike = (CBike*)CPools::GetVehiclePool()->GetSlot(i); + if (pBike && pBike->m_bombType == CARBOMB_REMOTE && + pBike->m_pBombRigger == pEntity) { + pBike->m_bombType = CARBOMB_NONE; + pBike->m_nBombTimer = 500; + pBike->m_pBlowUpEntity = pBike->m_pBombRigger; + if (pBike->m_pBlowUpEntity) + pBike->m_pBlowUpEntity->RegisterReference(&pBike->m_pBlowUpEntity); + } + } } +#endif } CProjectileInfo::RemoveDetonatorProjectiles(); } diff --git a/src/core/config.h b/src/core/config.h index 9049fec0..b20f85ae 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -436,6 +436,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually // Vehicles #define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher #define CPLANE_ROTORS // make the rotors of the NPC police heli rotate +#define BOMBS_ON_BIKES // allow player to set bombs on bikes // Pickups //#define MONEY_MESSAGES @@ -463,6 +464,7 @@ static_assert(false, "SUPPORT_XBOX_SCRIPT and SUPPORT_MOBILE_SCRIPT are mutually #define ATTACH_RELEASING_SOUNDS_TO_ENTITIES // sounds would follow ped and vehicles coordinates if not being queued otherwise #define USE_TIME_SCALE_FOR_AUDIO // slow down/speed up sounds according to the speed of the game #define MULTITHREADED_AUDIO // for streams. requires C++11 or later +#define CUSTOM_SOUND_TRACK // LCS PSP feature - TODO #ifdef AUDIO_OPUS #define AUDIO_OAL_USE_OPUS // enable support of opus files -- cgit v1.2.3