diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-04-14 19:10:39 +0200 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-04-14 19:10:39 +0200 |
commit | f2c78e4bfb631de9f02d37d6b64af721b280cf8c (patch) | |
tree | 3d75fc97c042efb64ebd1fc999af1a301adbb709 /src/peds | |
parent | scene edit (diff) | |
parent | RwMatFX support with linked RW libs (diff) | |
download | re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.tar re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.tar.gz re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.tar.bz2 re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.tar.lz re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.tar.xz re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.tar.zst re3-f2c78e4bfb631de9f02d37d6b64af721b280cf8c.zip |
Diffstat (limited to 'src/peds')
-rw-r--r-- | src/peds/Gangs.cpp | 87 | ||||
-rw-r--r-- | src/peds/Gangs.h | 44 | ||||
-rw-r--r-- | src/peds/Population.cpp | 81 | ||||
-rw-r--r-- | src/peds/Population.h | 54 |
4 files changed, 206 insertions, 60 deletions
diff --git a/src/peds/Gangs.cpp b/src/peds/Gangs.cpp new file mode 100644 index 00000000..c67fe599 --- /dev/null +++ b/src/peds/Gangs.cpp @@ -0,0 +1,87 @@ +#include "common.h" +#include "patcher.h" +#include "ModelIndices.h" +#include "Gangs.h" +#include "Weapon.h" + +CGangInfo CGangs::Gang[NUM_GANGS]; + +CGangInfo::CGangInfo() : + m_nVehicleMI(MI_BUS), + m_nPedModelOverride(-1), + m_Weapon1(WEAPONTYPE_UNARMED), + m_Weapon2(WEAPONTYPE_UNARMED) +{} + +void CGangs::Initialise(void) +{ + Gang[GANG_MAFIA].m_nVehicleMI = MI_MAFIA; + Gang[GANG_TRIAD].m_nVehicleMI = MI_BELLYUP; + Gang[GANG_DIABLOS].m_nVehicleMI = MI_DIABLOS; + Gang[GANG_YAKUZA].m_nVehicleMI = MI_YAKUZA; + Gang[GANG_YARDIE].m_nVehicleMI = MI_YARDIE; + Gang[GANG_COLUMB].m_nVehicleMI = MI_COLUMB; + Gang[GANG_HOODS].m_nVehicleMI = MI_HOODS; + Gang[GANG_7].m_nVehicleMI = -1; + Gang[GANG_8].m_nVehicleMI = -1; +#ifdef FIX_BUGS + for (int i = 0; i < NUM_GANGS; i++) + Gang[i].m_nPedModelOverride = -1; +#endif +} + +void CGangs::SetGangVehicleModel(int16 gang, int32 model) +{ + GetGangInfo(gang)->m_nVehicleMI = model; +} + +void CGangs::SetGangWeapons(int16 gang, int32 weapon1, int32 weapon2) +{ + CGangInfo *gi = GetGangInfo(gang); + gi->m_Weapon1 = weapon1; + gi->m_Weapon2 = weapon2; +} + +void CGangs::SetGangPedModelOverride(int16 gang, int8 ovrd) +{ + GetGangInfo(gang)->m_nPedModelOverride = ovrd; +} + +int8 CGangs::GetGangPedModelOverride(int16 gang) +{ + return GetGangInfo(gang)->m_nPedModelOverride; +} + +void CGangs::SaveAllGangData(uint8 *buf, uint32 *size) +{ +INITSAVEBUF + + *size = SAVE_HEADER_SIZE + sizeof(Gang); + WriteSaveHeader(buf, 'G','N','G','\0', *size - SAVE_HEADER_SIZE); + for (int i = 0; i < NUM_GANGS; i++) + WriteSaveBuf(buf, Gang[i]); + +VALIDATESAVEBUF(*size); +} + +void CGangs::LoadAllGangData(uint8 *buf, uint32 size) +{ + Initialise(); + +INITSAVEBUF + CheckSaveHeader(buf, 'G','N','G','\0', size - SAVE_HEADER_SIZE); + + for (int i = 0; i < NUM_GANGS; i++) + Gang[i] = ReadSaveBuf<CGangInfo>(buf); +VALIDATESAVEBUF(size); +} + +STARTPATCHES + InjectHook(0x4C3FB0, CGangs::Initialise, PATCH_JUMP); + InjectHook(0x4C4010, CGangs::SetGangVehicleModel, PATCH_JUMP); + InjectHook(0x4C4030, CGangs::SetGangWeapons, PATCH_JUMP); + InjectHook(0x4C4050, CGangs::SetGangPedModelOverride, PATCH_JUMP); + InjectHook(0x4C4070, CGangs::GetGangPedModelOverride, PATCH_JUMP); + InjectHook(0x4C4080, CGangs::SaveAllGangData, PATCH_JUMP); + InjectHook(0x4C4100, CGangs::LoadAllGangData, PATCH_JUMP); +ENDPATCHES diff --git a/src/peds/Gangs.h b/src/peds/Gangs.h new file mode 100644 index 00000000..dd7a7f93 --- /dev/null +++ b/src/peds/Gangs.h @@ -0,0 +1,44 @@ +#pragma once + +struct CGangInfo +{ + int32 m_nVehicleMI; + int8 m_nPedModelOverride; + int32 m_Weapon1; + int32 m_Weapon2; + + CGangInfo(); +}; + +static_assert(sizeof(CGangInfo) == 0x10, "CGangInfo: error"); + +enum { + GANG_MAFIA = 0, + GANG_TRIAD, + GANG_DIABLOS, + GANG_YAKUZA, + GANG_YARDIE, + GANG_COLUMB, + GANG_HOODS, + GANG_7, + GANG_8, + NUM_GANGS +}; + +class CGangs +{ +public: + static void Initialise(void); + static void SetGangVehicleModel(int16, int32); + static void SetGangWeapons(int16, int32, int32); + static void SetGangPedModelOverride(int16, int8); + static int8 GetGangPedModelOverride(int16); + static void SaveAllGangData(uint8 *, uint32 *); + static void LoadAllGangData(uint8 *, uint32); + + static int32 GetGangVehicleModel(int16 gang) { return Gang[gang].m_nVehicleMI; } + static CGangInfo *GetGangInfo(int16 gang) { return &Gang[gang]; } + +private: + static CGangInfo Gang[NUM_GANGS]; +}; diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index dfa61584..6959487f 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -29,39 +29,54 @@ #define PED_REMOVE_DIST (MIN_CREATION_DIST + CREATION_RANGE + 1.0f) #define PED_REMOVE_DIST_SPECIAL (MIN_CREATION_DIST + CREATION_RANGE + 15.0f) // for peds with bCullExtraFarAway flag -// TO-DO: These are hard-coded, reverse them. -// More clearly they're transition areas between zones. -RegenerationPoint (&aSafeZones)[8] = *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578; - -//PedGroup (&CPopulation::ms_pPedGroups)[NUMPEDGROUPS] = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248; -PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; -bool &CPopulation::ms_bGivePedsWeapons = *(bool*)0x95CCF6; -int32 &CPopulation::m_AllRandomPedsThisType = *(int32*)0x5FA570; -float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C; -uint32 &CPopulation::ms_nTotalMissionPeds = *(uint32*)0x8F5F70; -int32 &CPopulation::MaxNumberOfPedsInUse = *(int32*)0x5FA574; -uint32& CPopulation::ms_nNumCivMale = *(uint32*)0x8F2548; -uint32& CPopulation::ms_nNumCivFemale = *(uint32*)0x8F5F44; -uint32& CPopulation::ms_nNumCop = *(uint32*)0x885AFC; -bool& CPopulation::bZoneChangeHasHappened = *(bool*)0x95CD79; -uint32& CPopulation::ms_nNumEmergency = *(uint32*)0x94071C; -int8& CPopulation::m_CountDownToPedsAtStart = *(int8*)0x95CD4F; -uint32& CPopulation::ms_nNumGang1 = *(uint32*)0x8F1B1C; -uint32& CPopulation::ms_nNumGang2 = *(uint32*)0x8F1B14; -uint32& CPopulation::ms_nTotalPeds = *(uint32*)0x95CB50; -uint32& CPopulation::ms_nNumGang3 = *(uint32*)0x8F2548; -uint32& CPopulation::ms_nTotalGangPeds = *(uint32*)0x885AF0; -uint32& CPopulation::ms_nNumGang4 = *(uint32*)0x8F1B2C; -uint32& CPopulation::ms_nTotalCivPeds = *(uint32*)0x8F2C3C; -uint32& CPopulation::ms_nNumGang5 = *(uint32*)0x8F1B30; -uint32& CPopulation::ms_nNumDummy = *(uint32*)0x8F1A98; -uint32& CPopulation::ms_nNumGang6 = *(uint32*)0x8F1B20; -uint32& CPopulation::ms_nNumGang9 = *(uint32*)0x8F1B10; -uint32& CPopulation::ms_nNumGang7 = *(uint32*)0x8F1B28; -uint32& CPopulation::ms_nNumGang8 = *(uint32*)0x8F1B0C; -CVector &CPopulation::RegenerationPoint_a = *(CVector*)0x8E2AA4; -CVector &CPopulation::RegenerationPoint_b = *(CVector*)0x8E2A98; -CVector &CPopulation::RegenerationForward = *(CVector*)0x8F1AD4; +// Transition areas between zones +const RegenerationPoint aSafeZones[] = { + { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 400.0f, 814.0f, -954.0f, -903.0f, 30.0f, 100.0f, + CVector(790.0f, -917.0f, 39.0f), CVector(775.0f, -921.0f, 39.0f), CVector(424.0f, -942.0f, 38.0f), CVector(439.0f, -938.0f, 38.0f) }, + { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 555.0f, 711.0f, 118.0f, 186.0f, -30.0f, -10.0f, + CVector(698.0f, 182.0f, -20.0f), CVector(681.0f, 178.0f, -20.0f), CVector(586.0f, 144.0f, -20.0f), CVector(577.0f, 135.0f, -20.0f) }, + { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 26.0f, 44.0f, 124.0f, 87.0f, 20.0f, 6.0f, + CVector(736.0f, -117.0f, -13.0f), CVector(730.0f, -115.0f, -13.0f), CVector(635.0f, -93.0f, -12.5f), CVector(650.0f, -89.0f, -12.5f) }, + { LEVEL_INDUSTRIAL, LEVEL_COMMERCIAL, 45.0f, 34.0f, 780.0f, 750.0f, 25.0f, 6.0f, + CVector(729.0f, -764.0f, -18.0f), CVector(720.0f, -769.0f, -17.0f), CVector(652.0f, -774.0f, -10.5f), CVector(659.0f, -770.0f, -10.5f) }, + { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 532.0f, 136.0f, 668.0f, 599.0f, 4.0f, 0.0f, + CVector(-172.0f, -619.0f, 44.0f), CVector(-183.0f, -623.0f, 44.0f), CVector(-511.0f, -645.0f, 41.0f), CVector(-493.0f, -639.0f, 41.5f) }, + { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 325.0f, 175.0f, 7.0f, 5.0f, 30.0f, 10.0f, + CVector(-185.0f, 40.8f, -20.5f), CVector(-202.0f, 37.0f, -20.5f), CVector(-315.0f, 65.5f, -20.5f), CVector(-306.0f, 62.4f, -20.5f) }, + { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 410.0f, 310.0f, 1055.0f, 1030.0f, 20.0f, 6.0f, + CVector(-321.0f, -1043.0f, -13.2f), CVector(-328.0f, -1045.0f, -13.2f), CVector(-398.0f, -1044.0f, -13.5f), CVector(-390.0f, -1040.5f, -13.5f) }, + { LEVEL_COMMERCIAL, LEVEL_SUBURBAN, 425.0f, 280.0f, 471.0f, 447.0f, 20.0f, 5.0f, + CVector(-292.0f, -457.0f, -11.6f), CVector(-310.0f, -461.0f, -11.6f), CVector(-413.0f, -461.0f, -11.5f), CVector(-399.0f, -457.0f, -11.3f) } +}; // *(RegenerationPoint(*)[8]) * (uintptr*)0x5FA578; + +PedGroup CPopulation::ms_pPedGroups[NUMPEDGROUPS]; // = *(PedGroup(*)[NUMPEDGROUPS]) * (uintptr*)0x6E9248; +bool CPopulation::ms_bGivePedsWeapons; // = *(bool*)0x95CCF6; +int32 CPopulation::m_AllRandomPedsThisType = -1; // = *(int32*)0x5FA570; +float CPopulation::PedDensityMultiplier = 1.0f; // = *(float*)0x5FA56C; +uint32 CPopulation::ms_nTotalMissionPeds; // = *(uint32*)0x8F5F70; +int32 CPopulation::MaxNumberOfPedsInUse = 25; // *(int32*)0x5FA574; +uint32 CPopulation::ms_nNumCivMale; // = *(uint32*)0x8F2548; +uint32 CPopulation::ms_nNumCivFemale; // = *(uint32*)0x8F5F44; +uint32 CPopulation::ms_nNumCop; // = *(uint32*)0x885AFC; +bool CPopulation::bZoneChangeHasHappened; // = *(bool*)0x95CD79; +uint32 CPopulation::ms_nNumEmergency; // = *(uint32*)0x94071C; +int8 CPopulation::m_CountDownToPedsAtStart; // = *(int8*)0x95CD4F; +uint32 CPopulation::ms_nNumGang1; // = *(uint32*)0x8F1B1C; +uint32 CPopulation::ms_nNumGang2; // = *(uint32*)0x8F1B14; +uint32 CPopulation::ms_nTotalPeds; // = *(uint32*)0x95CB50; +uint32 CPopulation::ms_nNumGang3; // = *(uint32*)0x8F2548; +uint32 CPopulation::ms_nTotalGangPeds; // = *(uint32*)0x885AF0; +uint32 CPopulation::ms_nNumGang4; // = *(uint32*)0x8F1B2C; +uint32 CPopulation::ms_nTotalCivPeds; // = *(uint32*)0x8F2C3C; +uint32 CPopulation::ms_nNumGang5; // = *(uint32*)0x8F1B30; +uint32 CPopulation::ms_nNumDummy; // = *(uint32*)0x8F1A98; +uint32 CPopulation::ms_nNumGang6; // = *(uint32*)0x8F1B20; +uint32 CPopulation::ms_nNumGang9; // = *(uint32*)0x8F1B10; +uint32 CPopulation::ms_nNumGang7; // = *(uint32*)0x8F1B28; +uint32 CPopulation::ms_nNumGang8; // = *(uint32*)0x8F1B0C; +CVector CPopulation::RegenerationPoint_a; // = *(CVector*)0x8E2AA4; +CVector CPopulation::RegenerationPoint_b; // = *(CVector*)0x8E2A98; +CVector CPopulation::RegenerationForward; // = *(CVector*)0x8F1AD4; void CPopulation::Initialise() diff --git a/src/peds/Population.h b/src/peds/Population.h index f9e6c3b7..aa8129c0 100644 --- a/src/peds/Population.h +++ b/src/peds/Population.h @@ -34,33 +34,33 @@ class CPopulation { public: static PedGroup ms_pPedGroups[NUMPEDGROUPS]; - static bool &ms_bGivePedsWeapons; - static int32 &m_AllRandomPedsThisType; - static float &PedDensityMultiplier; - static uint32 &ms_nTotalMissionPeds; - static int32 &MaxNumberOfPedsInUse; - static uint32& ms_nNumCivMale; - static uint32 &ms_nNumCivFemale; - static uint32 &ms_nNumCop; - static bool &bZoneChangeHasHappened; - static uint32 &ms_nNumEmergency; - static int8& m_CountDownToPedsAtStart; - static uint32& ms_nNumGang1; - static uint32& ms_nNumGang2; - static uint32& ms_nTotalPeds; - static uint32& ms_nNumGang3; - static uint32& ms_nTotalGangPeds; - static uint32& ms_nNumGang4; - static uint32& ms_nTotalCivPeds; - static uint32& ms_nNumGang5; - static uint32& ms_nNumDummy; - static uint32& ms_nNumGang6; - static uint32& ms_nNumGang9; - static uint32& ms_nNumGang7; - static uint32& ms_nNumGang8; - static CVector& RegenerationPoint_a; - static CVector& RegenerationPoint_b; - static CVector& RegenerationForward; + static bool ms_bGivePedsWeapons; + static int32 m_AllRandomPedsThisType; + static float PedDensityMultiplier; + static uint32 ms_nTotalMissionPeds; + static int32 MaxNumberOfPedsInUse; + static uint32 ms_nNumCivMale; + static uint32 ms_nNumCivFemale; + static uint32 ms_nNumCop; + static bool bZoneChangeHasHappened; + static uint32 ms_nNumEmergency; + static int8 m_CountDownToPedsAtStart; + static uint32 ms_nNumGang1; + static uint32 ms_nNumGang2; + static uint32 ms_nTotalPeds; + static uint32 ms_nNumGang3; + static uint32 ms_nTotalGangPeds; + static uint32 ms_nNumGang4; + static uint32 ms_nTotalCivPeds; + static uint32 ms_nNumGang5; + static uint32 ms_nNumDummy; + static uint32 ms_nNumGang6; + static uint32 ms_nNumGang9; + static uint32 ms_nNumGang7; + static uint32 ms_nNumGang8; + static CVector RegenerationPoint_a; + static CVector RegenerationPoint_b; + static CVector RegenerationForward; static void Initialise(); static void Update(void); |