1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 19:50:00 +00:00

gangs, script and replay fixes

This commit is contained in:
Nikolay Korolev 2020-05-16 17:00:40 +03:00
parent 40ee29fb99
commit e3291b0cb1
10 changed files with 156 additions and 67 deletions

View file

@ -889,8 +889,7 @@ CCarCtrl::ChoosePoliceCarModel(void)
int32 int32
CCarCtrl::ChooseGangCarModel(int32 gang) CCarCtrl::ChooseGangCarModel(int32 gang)
{ {
if (CStreaming::HasModelLoaded(MI_GANG01 + 2 * gang) && if (CGangs::HaveGangModelsLoaded(gang))
CStreaming::HasModelLoaded(MI_GANG01+1 + 2 * gang))
return CGangs::GetGangVehicleModel(gang); return CGangs::GetGangVehicleModel(gang);
return -1; return -1;
} }

View file

@ -39,19 +39,19 @@ public:
WORKERBOAT, WORKERBOAT,
COPS, COPS,
MAFIA, CUBAN,
TRIAD, HAITIAN,
DIABLO, STREET,
YAKUZA, DIAZ,
YARDIE, BIKER,
COLOMB, SECURITY,
NINES, PLAYER,
GANG8, GOLFERS,
GANG9, GANG9,
COPS_BOAT, COPS_BOAT,
FIRST_CAR_RATING = NORMAL, FIRST_CAR_RATING = NORMAL,
FIRST_BOAT_RATING = LEISUREBOAT, FIRST_BOAT_RATING = LEISUREBOAT,
FIRST_GANG_CAR_RATING = MAFIA, FIRST_GANG_CAR_RATING = CUBAN,
NUM_CAR_CLASSES = MOTORBIKE - FIRST_CAR_RATING + 1, NUM_CAR_CLASSES = MOTORBIKE - FIRST_CAR_RATING + 1,
NUM_BOAT_CLASSES = WORKERBOAT - FIRST_BOAT_RATING + 1, NUM_BOAT_CLASSES = WORKERBOAT - FIRST_BOAT_RATING + 1,
NUM_GANG_CAR_CLASSES = GANG9 - FIRST_GANG_CAR_RATING + 1, NUM_GANG_CAR_CLASSES = GANG9 - FIRST_GANG_CAR_RATING + 1,

View file

@ -511,8 +511,12 @@ void CReplay::ProcessPedUpdate(CPed *ped, float interpolation, CAddressInReplayB
} }
RetrievePedAnimation(ped, &pp->anim_state); RetrievePedAnimation(ped, &pp->anim_state);
ped->RemoveWeaponModel(-1); ped->RemoveWeaponModel(-1);
if (pp->weapon_model != (uint8)-1) if (pp->weapon_model != (uint16)-1) {
if (CStreaming::HasModelLoaded(pp->weapon_model))
ped->AddWeaponModel(pp->weapon_model); ped->AddWeaponModel(pp->weapon_model);
else
CStreaming::RequestModel(pp->weapon_model, 0);
}
CWorld::Remove(ped); CWorld::Remove(ped);
CWorld::Add(ped); CWorld::Add(ped);
buffer->m_nOffset += sizeof(tPedUpdatePacket); buffer->m_nOffset += sizeof(tPedUpdatePacket);
@ -1220,6 +1224,16 @@ void CReplay::RestoreStuffFromMem(void)
ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped); ped->m_audioEntityId = DMAudio.CreateEntity(AUDIOTYPE_PHYSICAL, ped);
DMAudio.SetEntityStatus(ped->m_audioEntityId, true); DMAudio.SetEntityStatus(ped->m_audioEntityId, true);
CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false); CPopulation::UpdatePedCount((ePedType)ped->m_nPedType, false);
for (int j = 0; j < TOTAL_WEAPON_SLOTS; j++) {
int mi1 = CWeaponInfo::GetWeaponInfo(ped->m_weapons[j].m_eWeaponType)->m_nModelId;
if (mi1 != -1)
CStreaming::RequestModel(mi1, STREAMFLAGS_DEPENDENCY);
int mi2 = CWeaponInfo::GetWeaponInfo(ped->m_weapons[j].m_eWeaponType)->m_nModel2Id;
if (mi2 != -1)
CStreaming::RequestModel(mi2, STREAMFLAGS_DEPENDENCY);
CStreaming::LoadAllRequestedModels(false);
ped->m_weapons[j].Initialise(ped->m_weapons[j].m_eWeaponType, ped->m_weapons[j].m_nAmmoTotal);
}
if (ped->m_wepModelID >= 0) if (ped->m_wepModelID >= 0)
ped->AddWeaponModel(ped->m_wepModelID); ped->AddWeaponModel(ped->m_wepModelID);
} }

View file

@ -176,7 +176,7 @@ class CReplay
CStoredAnimationState anim_state; CStoredAnimationState anim_state;
CCompressedMatrixNotAligned matrix; CCompressedMatrixNotAligned matrix;
int8 assoc_group_id; int8 assoc_group_id;
uint8 weapon_model; uint16 weapon_model;
}; };
VALIDATE_SIZE(tPedUpdatePacket, 40); VALIDATE_SIZE(tPedUpdatePacket, 40);

View file

@ -4723,8 +4723,6 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
float supX = *(float*)&ScriptParams[5]; float supX = *(float*)&ScriptParams[5];
float supY = *(float*)&ScriptParams[6]; float supY = *(float*)&ScriptParams[6];
float supZ = *(float*)&ScriptParams[7]; float supZ = *(float*)&ScriptParams[7];
// TODO(MIAMI): new 2 parameters, requires CGarage change
ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, (eGarageType)ScriptParams[8], 0); ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, (eGarageType)ScriptParams[8], 0);
StoreParameters(&m_nIp, 1); StoreParameters(&m_nIp, 1);
return 0; return 0;
@ -4740,7 +4738,6 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
float supX = *(float*)&ScriptParams[5]; float supX = *(float*)&ScriptParams[5];
float supY = *(float*)&ScriptParams[6]; float supY = *(float*)&ScriptParams[6];
float supZ = *(float*)&ScriptParams[7]; float supZ = *(float*)&ScriptParams[7];
// TODO(MIAMI): new 2 parameters, requires CGarage change
ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, (eGarageType)ScriptParams[8], ScriptParams[9]); ScriptParams[0] = CGarages::AddOne(infX, infY, infZ, X2, Y2, supX, supY, supZ, (eGarageType)ScriptParams[8], ScriptParams[9]);
StoreParameters(&m_nIp, 1); StoreParameters(&m_nIp, 1);
return 0; return 0;
@ -5010,7 +5007,10 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
//case COMMAND_SET_GANG_ATTITUDE: //case COMMAND_SET_GANG_ATTITUDE:
//case COMMAND_SET_GANG_GANG_ATTITUDE: //case COMMAND_SET_GANG_GANG_ATTITUDE:
//case COMMAND_SET_GANG_PLAYER_ATTITUDE: //case COMMAND_SET_GANG_PLAYER_ATTITUDE:
//case COMMAND_SET_GANG_PED_MODELS: case COMMAND_SET_GANG_PED_MODELS:
CollectParameters(&m_nIp, 3);
CGangs::SetGangPedModels(ScriptParams[0], ScriptParams[1], ScriptParams[2]);
return 0;
case COMMAND_SET_GANG_CAR_MODEL: case COMMAND_SET_GANG_CAR_MODEL:
CollectParameters(&m_nIp, 2); CollectParameters(&m_nIp, 2);
CGangs::SetGangVehicleModel(ScriptParams[0], ScriptParams[1]); CGangs::SetGangVehicleModel(ScriptParams[0], ScriptParams[1]);
@ -10087,7 +10087,14 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_ENSURE_PLAYER_HAS_DRIVE_BY_WEAPON: case COMMAND_ENSURE_PLAYER_HAS_DRIVE_BY_WEAPON:
case COMMAND_MAKE_HELI_COME_CRASHING_DOWN: case COMMAND_MAKE_HELI_COME_CRASHING_DOWN:
case COMMAND_ADD_EXPLOSION_NO_SOUND: case COMMAND_ADD_EXPLOSION_NO_SOUND:
assert(0);
case COMMAND_SET_OBJECT_AREA_VISIBLE: case COMMAND_SET_OBJECT_AREA_VISIBLE:
{
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
pObject->m_area = ScriptParams[1];
return 0;
}
case COMMAND_WAS_VEHICLE_EVER_POLICE: case COMMAND_WAS_VEHICLE_EVER_POLICE:
case COMMAND_SET_CHAR_NEVER_TARGETTED: case COMMAND_SET_CHAR_NEVER_TARGETTED:
case COMMAND_LOAD_UNCOMPRESSED_ANIM: case COMMAND_LOAD_UNCOMPRESSED_ANIM:
@ -10156,7 +10163,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA: case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA:
case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_ZONE: case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_ZONE:
case COMMAND_UNLOCK_ALL_CAR_DOORS_IN_AREA: case COMMAND_UNLOCK_ALL_CAR_DOORS_IN_AREA:
assert(0);
case COMMAND_SET_GANG_ATTACK_PLAYER_WITH_COPS: 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: case COMMAND_SET_CHAR_FRIGHTENED_IN_JACKED_CAR:
case COMMAND_SET_VEHICLE_TO_FADE_IN: case COMMAND_SET_VEHICLE_TO_FADE_IN:
case COMMAND_REGISTER_ODDJOB_MISSION_PASSED: case COMMAND_REGISTER_ODDJOB_MISSION_PASSED:

View file

@ -1524,26 +1524,26 @@ CStreaming::StreamZoneModels(const CVector &pos)
bit = 1<<i; bit = 1<<i;
if(gangsToLoad & bit && (ms_loadedGangs & bit) == 0){ if(gangsToLoad & bit && (ms_loadedGangs & bit) == 0){
RequestModel(MI_GANG01 + i*2, STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangPedModel1(i), STREAMFLAGS_DEPENDENCY);
RequestModel(MI_GANG01 + i*2 + 1, STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangPedModel2(i), STREAMFLAGS_DEPENDENCY);
ms_loadedGangs |= bit; ms_loadedGangs |= bit;
}else if((gangsToLoad & bit) == 0 && ms_loadedGangs & bit){ }else if((gangsToLoad & bit) == 0 && ms_loadedGangs & bit){
SetModelIsDeletable(MI_GANG01 + i*2); SetModelIsDeletable(CGangs::GetGangPedModel1(i));
SetModelIsDeletable(MI_GANG01 + i*2 + 1); SetModelIsDeletable(CGangs::GetGangPedModel2(i));
SetModelTxdIsDeletable(MI_GANG01 + i*2); SetModelTxdIsDeletable(CGangs::GetGangPedModel1(i));
SetModelTxdIsDeletable(MI_GANG01 + i*2 + 1); SetModelTxdIsDeletable(CGangs::GetGangPedModel2(i));
ms_loadedGangs &= ~bit; ms_loadedGangs &= ~bit;
} }
// TODO(MIAMI): check this // TODO(MIAMI): check this
if(CGangs::GetGangInfo(i)->m_nVehicleMI < 0) if(CGangs::GetGangVehicleModel(i) < 0)
continue; continue;
if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){ if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){
RequestModel(CGangs::GetGangInfo(i)->m_nVehicleMI, STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangVehicleModel(i), STREAMFLAGS_DEPENDENCY);
}else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){ }else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){
SetModelIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelIsDeletable(CGangs::GetGangVehicleModel(i));
SetModelTxdIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelTxdIsDeletable(CGangs::GetGangVehicleModel(i));
} }
} }
ms_loadedGangCars = gangCarsToLoad; ms_loadedGangCars = gangCarsToLoad;
@ -1563,10 +1563,10 @@ CStreaming::RemoveCurrentZonesModels(void)
} }
for(i = 0; i < NUM_GANGS; i++){ for(i = 0; i < NUM_GANGS; i++){
SetModelIsDeletable(MI_GANG01 + i*2); SetModelIsDeletable(CGangs::GetGangPedModel1(i));
SetModelIsDeletable(MI_GANG01 + i*2 + 1); SetModelIsDeletable(CGangs::GetGangPedModel2(i));
if(CGangs::GetGangInfo(i)->m_nVehicleMI != -1) if(CGangs::GetGangVehicleModel(i) != -1)
SetModelIsDeletable(CGangs::GetGangInfo(i)->m_nVehicleMI); SetModelIsDeletable(CGangs::GetGangVehicleModel(i));
} }
ms_currentPedGrp = -1; ms_currentPedGrp = -1;

View file

@ -180,8 +180,25 @@ enum
MI_MALE01, MI_MALE01,
MI_TAXI_D = 28, // HMOCA MI_TAXI_D = 28, // HMOCA
MI_GANG01 = 83, // CBa
MI_VICE1 = 97, MI_WFOGO = 63,
MI_WMOGO = 64,
MI_CBA = 83,
MI_CBB,
MI_HNA,
MI_HNB,
MI_SGA,
MI_SGB,
MI_CLA,
MI_CLB,
MI_GDA,
MI_GDB,
MI_BKA,
MI_BKB,
MI_PGA,
MI_PGB,
MI_VICE1,
MI_VICE2, MI_VICE2,
MI_VICE3, MI_VICE3,
MI_VICE4, MI_VICE4,

View file

@ -2,12 +2,17 @@
#include "ModelIndices.h" #include "ModelIndices.h"
#include "Gangs.h" #include "Gangs.h"
#include "General.h"
#include "Streaming.h"
#include "Weapon.h" #include "Weapon.h"
CGangInfo CGangs::Gang[NUM_GANGS]; CGangInfo CGangs::Gang[NUM_GANGS];
bool CGangs::GangAttackWithCops[NUM_GANGS];
CGangInfo::CGangInfo() : CGangInfo::CGangInfo() :
m_nVehicleMI(MI_BUS), m_nVehicleMI(-1),
m_nPedModel1MI(-1),
m_nPedModel2MI(-1),
m_nPedModelOverride(-1), m_nPedModelOverride(-1),
m_Weapon1(WEAPONTYPE_UNARMED), m_Weapon1(WEAPONTYPE_UNARMED),
m_Weapon2(WEAPONTYPE_UNARMED) m_Weapon2(WEAPONTYPE_UNARMED)
@ -15,21 +20,63 @@ CGangInfo::CGangInfo() :
void CGangs::Initialise(void) void CGangs::Initialise(void)
{ {
Gang[GANG_MAFIA].m_nVehicleMI = -1; SetGangPedModels(GANG_CUBAN, MI_CBA, MI_CBB);
Gang[GANG_TRIAD].m_nVehicleMI = -1; SetGangPedModels(GANG_HAITIAN, MI_HNA, MI_HNB);
Gang[GANG_DIABLOS].m_nVehicleMI = -1; SetGangPedModels(GANG_STREET, MI_SGA, MI_SGB);
Gang[GANG_YAKUZA].m_nVehicleMI = -1; SetGangPedModels(GANG_DIAZ, MI_CLA, MI_CLB);
Gang[GANG_YARDIE].m_nVehicleMI = -1; SetGangPedModels(GANG_SECURITY, MI_GDA, MI_GDB);
Gang[GANG_COLUMB].m_nVehicleMI = -1; SetGangPedModels(GANG_BIKER, MI_BKA, MI_BKB);
Gang[GANG_HOODS].m_nVehicleMI = -1; SetGangPedModels(GANG_PLAYER, MI_PGA, MI_PGB);
Gang[GANG_7].m_nVehicleMI = -1; SetGangPedModels(GANG_GOLFER, MI_WFOGO, MI_WMOGO);
Gang[GANG_8].m_nVehicleMI = -1; SetGangVehicleModel(GANG_CUBAN, MI_CUBAN);
SetGangVehicleModel(GANG_HAITIAN, MI_VOODOO);
SetGangVehicleModel(GANG_STREET, MI_GANGBUR);
SetGangVehicleModel(GANG_DIAZ, -1);
SetGangVehicleModel(GANG_SECURITY, -1);
SetGangVehicleModel(GANG_BIKER, MI_ANGEL);
SetGangVehicleModel(GANG_PLAYER, -1);
SetGangVehicleModel(GANG_GOLFER, MI_CADDY);
//SetGangWeapons(GANG_GOLFER, WEAPONTYPE_GOLFCLUB, WEAPONTYPE_GOLFCLUB); // TODO(MIAMI)
#ifdef FIX_BUGS #ifdef FIX_BUGS
for (int i = 0; i < NUM_GANGS; i++) for (int i = 0; i < NUM_GANGS; i++)
Gang[i].m_nPedModelOverride = -1; SetGangPedModelOverride(i, -1);
#endif #endif
} }
bool CGangs::HaveGangModelsLoaded(int16 gang)
{
CGangInfo* pGangInfo = GetGangInfo(gang);
return CStreaming::HasModelLoaded(pGangInfo->m_nPedModel1MI) && CStreaming::HasModelLoaded(pGangInfo->m_nPedModel2MI);
}
void CGangs::SetGangPedModels(int16 gang, int32 mi1, int32 mi2)
{
GetGangInfo(gang)->m_nPedModel1MI = mi1;
GetGangInfo(gang)->m_nPedModel2MI = mi2;
}
void CGangs::SetWillAttackPlayerWithCops(ePedType type, bool will)
{
if (type >= PEDTYPE_GANG1 && type <= PEDTYPE_GANG9)
GangAttackWithCops[type - PEDTYPE_GANG1] = will;
}
bool CGangs::GetWillAttackPlayerWithCops(ePedType type)
{
if (type >= PEDTYPE_GANG1 && type <= PEDTYPE_GANG9)
return GangAttackWithCops[type - PEDTYPE_GANG1];
return false;
}
int32 CGangs::ChooseGangPedModel(int16 gang)
{
CGangInfo* pGangInfo = GetGangInfo(gang);
if (pGangInfo->m_nPedModelOverride != -1 || CGeneral::GetRandomTrueFalse())
return pGangInfo->m_nPedModel1MI;
else
return pGangInfo->m_nPedModel2MI;
}
void CGangs::SetGangVehicleModel(int16 gang, int32 model) void CGangs::SetGangVehicleModel(int16 gang, int32 model)
{ {
GetGangInfo(gang)->m_nVehicleMI = model; GetGangInfo(gang)->m_nVehicleMI = model;

View file

@ -1,8 +1,12 @@
#pragma once #pragma once
#include "PedType.h"
struct CGangInfo struct CGangInfo
{ {
int32 m_nVehicleMI; int32 m_nVehicleMI;
int32 m_nPedModel1MI;
int32 m_nPedModel2MI;
int8 m_nPedModelOverride; int8 m_nPedModelOverride;
int32 m_Weapon1; int32 m_Weapon1;
int32 m_Weapon2; int32 m_Weapon2;
@ -13,15 +17,15 @@ struct CGangInfo
VALIDATE_SIZE(CGangInfo, 0x10); VALIDATE_SIZE(CGangInfo, 0x10);
enum { enum {
GANG_MAFIA = 0, GANG_CUBAN = 0,
GANG_TRIAD, GANG_HAITIAN,
GANG_DIABLOS, GANG_STREET,
GANG_YAKUZA, GANG_DIAZ,
GANG_YARDIE, GANG_SECURITY,
GANG_COLUMB, GANG_BIKER,
GANG_HOODS, GANG_PLAYER,
GANG_7, GANG_GOLFER,
GANG_8, GANG_9,
NUM_GANGS NUM_GANGS
}; };
@ -36,9 +40,18 @@ public:
static void SaveAllGangData(uint8 *, uint32 *); static void SaveAllGangData(uint8 *, uint32 *);
static void LoadAllGangData(uint8 *, uint32); static void LoadAllGangData(uint8 *, uint32);
static void SetGangPedModels(int16, int32, int32);
static void SetWillAttackPlayerWithCops(ePedType type, bool will);
static bool GetWillAttackPlayerWithCops(ePedType type);
static int32 ChooseGangPedModel(int16);
static bool HaveGangModelsLoaded(int16 gang);
static int32 GetGangPedModel1(int16 gang) { return Gang[gang].m_nPedModel1MI; }
static int32 GetGangPedModel2(int16 gang) { return Gang[gang].m_nPedModel2MI; }
static int32 GetGangVehicleModel(int16 gang) { return Gang[gang].m_nVehicleMI; } static int32 GetGangVehicleModel(int16 gang) { return Gang[gang].m_nVehicleMI; }
static CGangInfo *GetGangInfo(int16 gang) { return &Gang[gang]; } static CGangInfo *GetGangInfo(int16 gang) { return &Gang[gang]; }
private: private:
static CGangInfo Gang[NUM_GANGS]; static CGangInfo Gang[NUM_GANGS];
static bool GangAttackWithCops[NUM_GANGS];
}; };

View file

@ -329,19 +329,7 @@ CPopulation::UpdatePedCount(ePedType pedType, bool decrease)
int int
CPopulation::ChooseGangOccupation(int gangId) CPopulation::ChooseGangOccupation(int gangId)
{ {
int8 modelOverride = CGangs::GetGangPedModelOverride(gangId); return CGangs::ChooseGangPedModel(gangId);
// All gangs have 2 models
int firstGangModel = 2 * gangId + MI_GANG01;
// GetRandomNumberInRange never returns max. value
if (modelOverride == -1)
return CGeneral::GetRandomNumberInRange(firstGangModel, firstGangModel + 2);
if (modelOverride != 0)
return firstGangModel + 1;
else
return firstGangModel;
} }
//--MIAMI: done //--MIAMI: done