From 43fb59e356651950912ac1c980448a771c53d935 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Tue, 24 Mar 2020 17:24:47 +0100 Subject: [PATCH 01/18] Update Fire.h --- src/core/Fire.h | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/core/Fire.h b/src/core/Fire.h index 624bf608..9afcf1b0 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -7,18 +7,22 @@ class CFire public: bool m_bIsOngoing; bool m_bIsScriptFire; - bool m_bPropogationFlag; + bool m_bPropagationFlag; bool m_bAudioSet; CVector m_vecPos; CEntity *m_pEntity; CEntity *m_pSource; - int m_nExtinguishTime; - int m_nStartTime; - int field_20; - int field_24; + uint32 m_nExtinguishTime; + uint32 m_nStartTime; + int32 field_20; + uint32 field_24; uint32 m_nFiremenPuttingOut; - float field_2C; + float m_fStrength; + CFire(); + ~CFire(); + void ProcessFire(void); + void ReportThisFire(void); void Extinguish(void); }; @@ -27,20 +31,21 @@ class CFireManager enum { MAX_FIREMEN_ATTENDING = 2, }; - uint32 m_nTotalFires; public: + uint32 m_nTotalFires; CFire m_aFires[NUM_FIRES]; - void StartFire(CEntity *entityOnFire, CEntity *culprit, float, uint32); - void StartFire(CVector, float, uint8); + void StartFire(CVector pos, float size, bool propagation); + void StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation); void Update(void); - CFire *FindFurthestFire_NeverMindFireMen(CVector coors, float, float); - CFire *FindNearestFire(CVector, float*); + CFire *FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange); + CFire *FindNearestFire(CVector vecPos, float *pDistance); + CFire *GetNextFreeFire(void); uint32 GetTotalActiveFires() const; - void ExtinguishPoint(CVector, float); - int32 StartScriptFire(const CVector& pos, CEntity* culprit, float, uint8); - bool IsScriptFireExtinguish(int16); - void RemoveScriptFire(int16); + void ExtinguishPoint(CVector point, float range); + int32 StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation); + bool IsScriptFireExtinguish(int16 index); void RemoveAllScriptFires(void); - void SetScriptFireAudio(int16, bool); + void RemoveScriptFire(int16 index); + void SetScriptFireAudio(int16 index, bool state); }; extern CFireManager &gFireManager; From 1680d11dae8c1169d756756ad44f685c7766af17 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Tue, 24 Mar 2020 17:25:14 +0100 Subject: [PATCH 02/18] Update Fire.h --- src/core/Fire.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Fire.h b/src/core/Fire.h index 9afcf1b0..89ab9a9f 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -40,7 +40,7 @@ public: CFire *FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange); CFire *FindNearestFire(CVector vecPos, float *pDistance); CFire *GetNextFreeFire(void); - uint32 GetTotalActiveFires() const; + uint32 GetTotalActiveFires(void) const; void ExtinguishPoint(CVector point, float range); int32 StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation); bool IsScriptFireExtinguish(int16 index); From c03bae46ea4c9cc57a9b2ecf8da41f42b994bcf0 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Tue, 24 Mar 2020 18:12:53 +0100 Subject: [PATCH 03/18] Update Fire.cpp --- src/core/Fire.cpp | 436 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 420 insertions(+), 16 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index f83ad2c8..d53c8fc7 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -1,19 +1,299 @@ #include "common.h" #include "patcher.h" +#include "Vector.h" +#include "PlayerPed.h" +#include "Entity.h" +#include "PointLights.h" +#include "Particle.h" +#include "Timer.h" +#include "Vehicle.h" +#include "Shadows.h" +#include "Automobile.h" +#include "World.h" +#include "General.h" +#include "EventList.h" +#include "DamageManager.h" +#include "Ped.h" #include "Fire.h" CFireManager &gFireManager = *(CFireManager*)0x8F31D0; -WRAPPER void CFire::Extinguish(void) { EAXJMP(0x479D40); } -WRAPPER void CFireManager::Update(void) { EAXJMP(0x479310); } -WRAPPER CFire* CFireManager::FindFurthestFire_NeverMindFireMen(CVector coors, float, float) { EAXJMP(0x479430); } - -uint32 CFireManager::GetTotalActiveFires() const +CFire::CFire(void) { - return m_nTotalFires; + m_bIsOngoing = 0; + m_bIsScriptFire = 0; + m_bPropagationFlag = 1; + m_bAudioSet = 1; + m_vecPos = CVector(0.0f, 0.0f, 0.0f); + m_pEntity = 0; + m_pSource = 0; + m_nFiremenPuttingOut = 0; + m_nExtinguishTime = 0; + m_nStartTime = 0; + field_20 = 1; + field_24 = 0; + m_fStrength = 0.8f; } -CFire* CFireManager::FindNearestFire(CVector vecPos, float* pDistance) +CFire::~CFire(void) {} + +class CFire_ : public CFire { +public: + void ctor() { ::new(this) CFire(); } + void dtor() { CFire::CFire(); } +}; + +void +CFire::ProcessFire(void) +{ + float fDamagePlayer; + float fDamagePeds; + float fDamageVehicle; + CVehicle *pCurrentVehicle; + char nRandNumber; + float fGreen; + float fRed; + CVector lightpos; + CVector firePos; + CVector vecProduct; + + CEntity *pCurrentEntity = (CPed *)m_pEntity; + CPed *ped = (CPed *)pCurrentEntity; + + if (m_pEntity) { + m_vecPos = m_pEntity->GetPosition(); + + if (((CPed *)m_pEntity)->IsPed()) { + if (ped->m_pFire != this) { + Extinguish(); + return; + } + if (ped->m_nMoveState != PEDMOVE_RUN) + m_vecPos.z -= 1.0f; + + if (ped->bInVehicle && ped->m_pMyVehicle) { + if (ped->m_pMyVehicle->IsCar()) + ped->m_pMyVehicle->m_fHealth = 75.0f; + } else if (pCurrentEntity == (CPed *)FindPlayerPed()) { + fDamagePlayer = 1.2f * CTimer::GetTimeStep(); + + ((CPlayerPed *)pCurrentEntity)->InflictDamage( + (CPlayerPed *)m_pSource, WEAPONTYPE_FLAMETHROWER, + fDamagePlayer, PEDPIECE_TORSO, 0); + } else { + fDamagePeds = 1.2f * CTimer::GetTimeStep(); + + if (((CPlayerPed *)pCurrentEntity)->InflictDamage( + (CPlayerPed *)m_pSource, WEAPONTYPE_FLAMETHROWER, + fDamagePeds, PEDPIECE_TORSO, 0)) + + pCurrentEntity->bRenderScorched = true; + } + } else if (pCurrentEntity->IsVehicle()) { + CVehicle *pCurrentVehicle = (CVehicle*)m_pEntity; + + if (pCurrentVehicle->m_pCarFire != this) { + Extinguish(); + return; + } + if (!m_bIsScriptFire) { + fDamageVehicle = 1.2f * CTimer::GetTimeStep(); + pCurrentVehicle->InflictDamage((CVehicle *)m_pSource, WEAPONTYPE_FLAMETHROWER, fDamageVehicle); + } + } + } + if (!FindPlayerVehicle() && !FindPlayerPed()->m_pFire && !(FindPlayerPed()->bFireProof) + && ((FindPlayerPed()->GetPosition() - m_vecPos).MagnitudeSqr() < 2.0f)) { + FindPlayerPed()->DoStuffToGoOnFire(); + gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1); + } + if (CTimer::m_snTimeInMilliseconds > field_24) { /* set to 0 when a newfire starts, related to time */ + field_24 = CTimer::m_snTimeInMilliseconds + 80; + firePos = m_vecPos; + pCurrentVehicle = (CVehicle *)m_pEntity; + + if (pCurrentVehicle && pCurrentVehicle->IsVehicle() && (pCurrentVehicle->IsCar())) { + CVehicleModelInfo *mi = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(pCurrentVehicle->GetModelIndex())); + CVector ModelInfo = mi->m_positions[CAR_POS_HEADLIGHTS]; + ModelInfo = m_pEntity->GetMatrix() * ModelInfo; + + firePos.x = ModelInfo.x; + firePos.y = ModelInfo.y; + firePos.z = ModelInfo.z + 0.15f; + } + + CParticle::AddParticle(PARTICLE_CARFLAME, firePos, + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.0125f, 0.1f) * m_fStrength), + 0, m_fStrength, 0, 0, 0, 0); + + rand(); rand(); rand(); /* unsure why these three rands are called */ + + CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, firePos, + CVector(0.0f, 0.0f, 0.0f), 0, 0.0, 0, 0, 0, 0); + } + if (CTimer::m_snTimeInMilliseconds < m_nExtinguishTime || m_bIsScriptFire) { + if (CTimer::m_snTimeInMilliseconds > m_nStartTime) + m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + + nRandNumber = rand() & 127; + + lightpos.x = m_vecPos.x; + lightpos.y = m_vecPos.y; + lightpos.z = m_vecPos.z + 5.0f; + + if (!m_pEntity) { + CShadows::StoreStaticShadow((uint32)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, + 7.0, 0.0, 0.0, -7.0, 0, nRandNumber / 2, nRandNumber / 2, + 0, 10.0, 1.0, 40.0, 0, 0.0); + } + fGreen = nRandNumber / 128; + fRed = nRandNumber / 128; + + CPointLights::AddLight(0, m_vecPos, CVector(0.0f, 0.0f, 0.0f), + 12.0, fRed, fGreen, 0, 0, 0); + } else { + Extinguish(); + } +} + +void +CFire::ReportThisFire(void) +{ + gFireManager.m_nTotalFires++; + CEventList::RegisterEvent(EVENT_FIRE, m_vecPos, 1000); +} + +void +CFire::Extinguish(void) +{ + CPed *pCurrentEntity; + + if (m_bIsOngoing) { + if (!m_bIsScriptFire) + gFireManager.m_nTotalFires--; + + m_nExtinguishTime = 0; + m_bIsOngoing = false; + pCurrentEntity = (CPed *)m_pEntity; + + if (pCurrentEntity) { + if (pCurrentEntity->IsObject()) { + pCurrentEntity->RestorePreviousState(); + pCurrentEntity->m_pFire = 0; + } else if (pCurrentEntity->IsPed()) { + pCurrentEntity->m_vecOffsetSeek.x = 0.0; + } + m_pEntity = nil; + } + } +} + +void +CFireManager::StartFire(CVector pos, float size, bool propagation) +{ + CFire *pCurrentFire = GetNextFreeFire(); + + if (pCurrentFire) { + pCurrentFire->m_bIsOngoing = true; + pCurrentFire->m_bIsScriptFire = false; + pCurrentFire->m_bPropagationFlag = propagation; + pCurrentFire->m_bAudioSet = true; + pCurrentFire->m_vecPos = pos; + pCurrentFire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 10000; + pCurrentFire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + pCurrentFire->m_pEntity = nil; + pCurrentFire->m_pSource = nil; + pCurrentFire->field_24 = 0; + pCurrentFire->ReportThisFire(); + pCurrentFire->m_fStrength = size; + } +} + +void +CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation) +{ + CPed *ped = (CPed *)entityOnFire; + CVehicle *veh = (CVehicle *)entityOnFire; + CFire *fire = GetNextFreeFire(); + + if (!fire) + return; + if (entityOnFire->IsPed() && (ped->m_pFire || !ped->IsPedInControl())) { + return; + } else if (entityOnFire->IsVehicle() && veh->m_pCarFire || veh->IsCar() && ((CAutomobile *)veh)->Damage.GetEngineStatus() >= 225) { + return; + } + + if (entityOnFire->IsPed()) { + ped->m_pFire = fire; + if (ped != FindPlayerPed()) { + if (fleeFrom) { + ped->SetFlee(fleeFrom, 10000); + } else { + ped->SetFlee(ped->GetPosition(), 10000); + ped->m_fleeFrom = nil; + } + ped->bDrawLast = false; + ped->SetMoveState(PEDMOVE_SPRINT); + ped->SetMoveAnim(); + ped->m_nPedState = PED_ON_FIRE; + } + if (fleeFrom) { + if (ped->m_nPedType == PEDTYPE_COP) { + CEventList::RegisterEvent(EVENT_COP_SET_ON_FIRE, EVENT_ENTITY_PED, + entityOnFire, (CPed *)fleeFrom, 10000); + } else { + CEventList::RegisterEvent(EVENT_PED_SET_ON_FIRE, EVENT_ENTITY_PED, + entityOnFire, (CPed *)fleeFrom, 10000); + } + } + } else { + if (entityOnFire->IsVehicle()) { + veh->m_pCarFire = fire; + if (fleeFrom) { + CEventList::RegisterEvent(EVENT_CAR_SET_ON_FIRE, EVENT_ENTITY_VEHICLE, + entityOnFire, (CPed *)fleeFrom, 10000); + } + } + } + + fire->m_bIsOngoing = true; + fire->m_bIsScriptFire = false; + fire->m_vecPos = ped->GetPosition(); + + if (entityOnFire && entityOnFire->IsPed() && ped->IsPlayer()) { + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 3333; + } else if (entityOnFire->IsVehicle()) { + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + + 4000 + (signed int)((double)(unsigned __int16)rand() * 0.000030517578 * 1000.0f); //this needs to be simplified + } else { + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + + 10000 + (signed int)((double)(unsigned __int16)rand() * 0.000030517578 * 1000.0f); + } + fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_pEntity = entityOnFire; + entityOnFire->RegisterReference(&fire->m_pEntity); + fire->m_pSource = fleeFrom; + if (fleeFrom) + fleeFrom->RegisterReference(&fire->m_pSource); + fire->ReportThisFire(); + fire->field_24 = 0; + fire->m_fStrength = strength; + fire->m_bPropagationFlag = propagation; + fire->m_bAudioSet = true; +} + +void +CFireManager::Update(void) +{ + for (int i = 0; i < NUM_FIRES; i++) { + if (m_aFires[i].m_bIsOngoing) + m_aFires[i].ProcessFire(); + } +} + +CFire * +CFireManager::FindNearestFire(CVector vecPos, float *pDistance) { for (int i = 0; i < MAX_FIREMEN_ATTENDING; i++) { int fireId = -1; @@ -38,6 +318,44 @@ CFire* CFireManager::FindNearestFire(CVector vecPos, float* pDistance) return nil; } +CFire * +CFireManager::FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange) +{ + int furthestFire = -1; + float lastFireDist = 0.0; + float fireDist; + + for (int i = 0; i < NUM_FIRES; i++) { + if (m_aFires[i].m_bIsOngoing && !m_aFires[i].m_bIsScriptFire) { + fireDist = (m_aFires[i].m_vecPos - coords).Magnitude2D(); + if (fireDist > minRange && fireDist < maxRange && fireDist > lastFireDist) { + lastFireDist = fireDist; + furthestFire = i; + } + } + } + if (furthestFire == -1) + return nil; + else + return &m_aFires[furthestFire]; +} + +CFire * +CFireManager::GetNextFreeFire(void) +{ + for (int i = 0; i < NUM_FIRES; i++) { + if (!m_aFires[i].m_bIsOngoing && !m_aFires[i].m_bIsScriptFire) + return &m_aFires[i]; + } + return nil; +} + +uint32 +CFireManager::GetTotalActiveFires(void) const +{ + return m_nTotalFires; +} + void CFireManager::ExtinguishPoint(CVector point, float range) { @@ -49,16 +367,102 @@ CFireManager::ExtinguishPoint(CVector point, float range) } } -WRAPPER void CFireManager::StartFire(CEntity *entityOnFire, CEntity *culprit, float, uint32) { EAXJMP(0x479590); } -WRAPPER void CFireManager::StartFire(CVector, float, uint8) { EAXJMP(0x479500); } -WRAPPER int32 CFireManager::StartScriptFire(const CVector& pos, CEntity* culprit, float, uint8) { EAXJMP(0x479E60); } -WRAPPER bool CFireManager::IsScriptFireExtinguish(int16) { EAXJMP(0x479FC0); } -WRAPPER void CFireManager::RemoveScriptFire(int16) { EAXJMP(0x479FE0); } -WRAPPER void CFireManager::RemoveAllScriptFires(void) { EAXJMP(0x47A000); } -WRAPPER void CFireManager::SetScriptFireAudio(int16, bool) { EAXJMP(0x47A040); } +int32 +CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation) +{ + CFire *fire; + CPed *ped = (CPed *)target; + CVehicle *veh = (CVehicle *)target; + + if (target) { + if (target->IsPed()) { + if (ped->m_pFire) + ped->m_pFire->Extinguish(); + } else if (target->IsVehicle()) { + if (veh->m_pCarFire) + veh->m_pCarFire->Extinguish(); + if (veh->IsCar() && ((CAutomobile *)veh)->Damage.GetEngineStatus() >= 225) { + ((CAutomobile *)veh)->Damage.SetEngineStatus(215); + } + } + } + + fire = GetNextFreeFire(); + fire->m_bIsOngoing = true; + fire->m_bIsScriptFire = true; + fire->m_bPropagationFlag = propagation; + fire->m_bAudioSet = true; + fire->m_vecPos = pos; + fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_pEntity = target; + + if (target) + target->RegisterReference(&fire->m_pEntity); + fire->m_pSource = nil; + fire->field_24 = 0; + fire->m_fStrength = strength; + if (target) { + if (target->IsPed()) { + ped->m_pFire = fire; + if (target != (CVehicle *)FindPlayerPed()) { + CVector2D pos = target->GetPosition(); + ped->SetFlee(pos, 10000); + ped->SetMoveAnim(); + ped->m_nPedState = PED_ON_FIRE; + } + } else if (target->IsVehicle()) { + veh->m_pCarFire = fire; + } + } + return fire - m_aFires; +} + +bool +CFireManager::IsScriptFireExtinguish(int16 index) +{ + return (!m_aFires[index].m_bIsOngoing) ? true : false; +} + +void +CFireManager::RemoveAllScriptFires(void) +{ + for (int i = 0; i < NUM_FIRES; i++) { + if (m_aFires[i].m_bIsScriptFire) { + m_aFires[i].Extinguish(); + m_aFires[i].m_bIsScriptFire = false; + } + } +} + +void +CFireManager::RemoveScriptFire(int16 index) +{ + m_aFires[index].Extinguish(); + m_aFires[index].m_bIsScriptFire = false; +} + +void +CFireManager::SetScriptFireAudio(int16 index, bool state) +{ + m_aFires[index].m_bAudioSet = state; +} STARTPATCHES - InjectHook(0x479DB0, &CFireManager::ExtinguishPoint, PATCH_JUMP); + InjectHook(0x479220, &CFire_::ctor, PATCH_JUMP); + InjectHook(0x479280, &CFire_::dtor, PATCH_JUMP); + InjectHook(0x4798D0, &CFire::ProcessFire, PATCH_JUMP); + InjectHook(0x4798B0, &CFire::ReportThisFire, PATCH_JUMP); + InjectHook(0x479D40, &CFire::Extinguish, PATCH_JUMP); + InjectHook(0x479500, (void(CFireManager::*)(CVector pos, float size, bool propagation))&CFireManager::StartFire, PATCH_JUMP); + InjectHook(0x479590, (void(CFireManager::*)(CEntity *, CEntity *, float, bool))&CFireManager::StartFire, PATCH_JUMP); + InjectHook(0x479310, &CFireManager::Update, PATCH_JUMP); + InjectHook(0x479430, &CFireManager::FindFurthestFire_NeverMindFireMen, PATCH_JUMP); InjectHook(0x479340, &CFireManager::FindNearestFire, PATCH_JUMP); + InjectHook(0x4792E0, &CFireManager::GetNextFreeFire, PATCH_JUMP); + InjectHook(0x479DB0, &CFireManager::ExtinguishPoint, PATCH_JUMP); + InjectHook(0x479E60, &CFireManager::StartScriptFire, PATCH_JUMP); + InjectHook(0x479FC0, &CFireManager::IsScriptFireExtinguish, PATCH_JUMP); + InjectHook(0x47A000, &CFireManager::RemoveAllScriptFires, PATCH_JUMP); + InjectHook(0x479FE0, &CFireManager::RemoveScriptFire, PATCH_JUMP); + InjectHook(0x47A040, &CFireManager::SetScriptFireAudio, PATCH_JUMP); ENDPATCHES - From ea9e45fcda8468896ed156ae306bf50ad31acdaa Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:00:38 +0100 Subject: [PATCH 04/18] Update Fire.cpp --- src/core/Fire.cpp | 238 +++++++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 121 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index d53c8fc7..f46137f2 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -18,12 +18,12 @@ CFireManager &gFireManager = *(CFireManager*)0x8F31D0; -CFire::CFire(void) +CFire::CFire() { - m_bIsOngoing = 0; - m_bIsScriptFire = 0; - m_bPropagationFlag = 1; - m_bAudioSet = 1; + m_bIsOngoing = false; + m_bIsScriptFire = false; + m_bPropagationFlag = true; + m_bAudioSet = true; m_vecPos = CVector(0.0f, 0.0f, 0.0f); m_pEntity = 0; m_pSource = 0; @@ -35,7 +35,7 @@ CFire::CFire(void) m_fStrength = 0.8f; } -CFire::~CFire(void) {} +CFire::~CFire() {} class CFire_ : public CFire { public: @@ -49,16 +49,13 @@ CFire::ProcessFire(void) float fDamagePlayer; float fDamagePeds; float fDamageVehicle; - CVehicle *pCurrentVehicle; - char nRandNumber; + int8 nRandNumber; float fGreen; float fRed; CVector lightpos; CVector firePos; - CVector vecProduct; - - CEntity *pCurrentEntity = (CPed *)m_pEntity; - CPed *ped = (CPed *)pCurrentEntity; + CPed *ped = (CPed *)m_pEntity; + CVehicle *veh = (CVehicle*)m_pEntity; if (m_pEntity) { m_vecPos = m_pEntity->GetPosition(); @@ -70,35 +67,32 @@ CFire::ProcessFire(void) } if (ped->m_nMoveState != PEDMOVE_RUN) m_vecPos.z -= 1.0f; - if (ped->bInVehicle && ped->m_pMyVehicle) { if (ped->m_pMyVehicle->IsCar()) ped->m_pMyVehicle->m_fHealth = 75.0f; - } else if (pCurrentEntity == (CPed *)FindPlayerPed()) { + } else if (m_pEntity == (CPed *)FindPlayerPed()) { fDamagePlayer = 1.2f * CTimer::GetTimeStep(); - ((CPlayerPed *)pCurrentEntity)->InflictDamage( + ((CPlayerPed *)m_pEntity)->InflictDamage( (CPlayerPed *)m_pSource, WEAPONTYPE_FLAMETHROWER, fDamagePlayer, PEDPIECE_TORSO, 0); } else { fDamagePeds = 1.2f * CTimer::GetTimeStep(); - if (((CPlayerPed *)pCurrentEntity)->InflictDamage( + if (((CPlayerPed *)m_pEntity)->InflictDamage( (CPlayerPed *)m_pSource, WEAPONTYPE_FLAMETHROWER, - fDamagePeds, PEDPIECE_TORSO, 0)) - - pCurrentEntity->bRenderScorched = true; + fDamagePeds, PEDPIECE_TORSO, 0)) { + m_pEntity->bRenderScorched = true; + } } - } else if (pCurrentEntity->IsVehicle()) { - CVehicle *pCurrentVehicle = (CVehicle*)m_pEntity; - - if (pCurrentVehicle->m_pCarFire != this) { + } else if (m_pEntity->IsVehicle()) { + if (veh->m_pCarFire != this) { Extinguish(); return; } if (!m_bIsScriptFire) { fDamageVehicle = 1.2f * CTimer::GetTimeStep(); - pCurrentVehicle->InflictDamage((CVehicle *)m_pSource, WEAPONTYPE_FLAMETHROWER, fDamageVehicle); + veh->InflictDamage((CVehicle *)m_pSource, WEAPONTYPE_FLAMETHROWER, fDamageVehicle); } } } @@ -110,10 +104,9 @@ CFire::ProcessFire(void) if (CTimer::m_snTimeInMilliseconds > field_24) { /* set to 0 when a newfire starts, related to time */ field_24 = CTimer::m_snTimeInMilliseconds + 80; firePos = m_vecPos; - pCurrentVehicle = (CVehicle *)m_pEntity; - if (pCurrentVehicle && pCurrentVehicle->IsVehicle() && (pCurrentVehicle->IsCar())) { - CVehicleModelInfo *mi = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(pCurrentVehicle->GetModelIndex())); + if (veh && veh->IsVehicle() && veh->IsCar()) { + CVehicleModelInfo *mi = ((CVehicleModelInfo*)CModelInfo::GetModelInfo(veh->GetModelIndex())); CVector ModelInfo = mi->m_positions[CAR_POS_HEADLIGHTS]; ModelInfo = m_pEntity->GetMatrix() * ModelInfo; @@ -124,7 +117,7 @@ CFire::ProcessFire(void) CParticle::AddParticle(PARTICLE_CARFLAME, firePos, CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.0125f, 0.1f) * m_fStrength), - 0, m_fStrength, 0, 0, 0, 0); + 0, m_fStrength, 0, 0, 0, 0); rand(); rand(); rand(); /* unsure why these three rands are called */ @@ -135,8 +128,7 @@ CFire::ProcessFire(void) if (CTimer::m_snTimeInMilliseconds > m_nStartTime) m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; - nRandNumber = rand() & 127; - + nRandNumber = CGeneral::GetRandomNumber(); lightpos.x = m_vecPos.x; lightpos.y = m_vecPos.y; lightpos.z = m_vecPos.z + 5.0f; @@ -166,22 +158,19 @@ CFire::ReportThisFire(void) void CFire::Extinguish(void) { - CPed *pCurrentEntity; - if (m_bIsOngoing) { if (!m_bIsScriptFire) gFireManager.m_nTotalFires--; m_nExtinguishTime = 0; m_bIsOngoing = false; - pCurrentEntity = (CPed *)m_pEntity; - if (pCurrentEntity) { - if (pCurrentEntity->IsObject()) { - pCurrentEntity->RestorePreviousState(); - pCurrentEntity->m_pFire = 0; - } else if (pCurrentEntity->IsPed()) { - pCurrentEntity->m_vecOffsetSeek.x = 0.0; + if (m_pEntity) { + if (m_pEntity->IsPed()) { + ((CPed *)m_pEntity)->RestorePreviousState(); + ((CPed *)m_pEntity)->m_pFire = 0; + } else if (m_pEntity->IsVehicle()) { + ((CVehicle *)m_pEntity)->m_pCarFire = nil; } m_pEntity = nil; } @@ -191,96 +180,104 @@ CFire::Extinguish(void) void CFireManager::StartFire(CVector pos, float size, bool propagation) { - CFire *pCurrentFire = GetNextFreeFire(); + CFire *fire = GetNextFreeFire(); - if (pCurrentFire) { - pCurrentFire->m_bIsOngoing = true; - pCurrentFire->m_bIsScriptFire = false; - pCurrentFire->m_bPropagationFlag = propagation; - pCurrentFire->m_bAudioSet = true; - pCurrentFire->m_vecPos = pos; - pCurrentFire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 10000; - pCurrentFire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; - pCurrentFire->m_pEntity = nil; - pCurrentFire->m_pSource = nil; - pCurrentFire->field_24 = 0; - pCurrentFire->ReportThisFire(); - pCurrentFire->m_fStrength = size; + if (fire) { + fire->m_bIsOngoing = true; + fire->m_bIsScriptFire = false; + fire->m_bPropagationFlag = propagation; + fire->m_bAudioSet = true; + fire->m_vecPos = pos; + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 10000; + fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_pEntity = nil; + fire->m_pSource = nil; + fire->field_24 = 0; + fire->ReportThisFire(); + fire->m_fStrength = size; } } -void +CFire * CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation) { CPed *ped = (CPed *)entityOnFire; CVehicle *veh = (CVehicle *)entityOnFire; - CFire *fire = GetNextFreeFire(); - - if (!fire) - return; - if (entityOnFire->IsPed() && (ped->m_pFire || !ped->IsPedInControl())) { - return; - } else if (entityOnFire->IsVehicle() && veh->m_pCarFire || veh->IsCar() && ((CAutomobile *)veh)->Damage.GetEngineStatus() >= 225) { - return; - } - + if (entityOnFire->IsPed()) { - ped->m_pFire = fire; - if (ped != FindPlayerPed()) { - if (fleeFrom) { - ped->SetFlee(fleeFrom, 10000); - } else { - ped->SetFlee(ped->GetPosition(), 10000); - ped->m_fleeFrom = nil; - } - ped->bDrawLast = false; - ped->SetMoveState(PEDMOVE_SPRINT); - ped->SetMoveAnim(); - ped->m_nPedState = PED_ON_FIRE; - } - if (fleeFrom) { - if (ped->m_nPedType == PEDTYPE_COP) { - CEventList::RegisterEvent(EVENT_COP_SET_ON_FIRE, EVENT_ENTITY_PED, - entityOnFire, (CPed *)fleeFrom, 10000); - } else { - CEventList::RegisterEvent(EVENT_PED_SET_ON_FIRE, EVENT_ENTITY_PED, - entityOnFire, (CPed *)fleeFrom, 10000); - } - } - } else { - if (entityOnFire->IsVehicle()) { - veh->m_pCarFire = fire; - if (fleeFrom) { - CEventList::RegisterEvent(EVENT_CAR_SET_ON_FIRE, EVENT_ENTITY_VEHICLE, - entityOnFire, (CPed *)fleeFrom, 10000); - } - } - } - - fire->m_bIsOngoing = true; - fire->m_bIsScriptFire = false; - fire->m_vecPos = ped->GetPosition(); - - if (entityOnFire && entityOnFire->IsPed() && ped->IsPlayer()) { - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 3333; + if (ped->m_pFire) + return nil; + if (!ped->IsPedInControl()) + return nil; } else if (entityOnFire->IsVehicle()) { - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds - + 4000 + (signed int)((double)(unsigned __int16)rand() * 0.000030517578 * 1000.0f); //this needs to be simplified - } else { - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds - + 10000 + (signed int)((double)(unsigned __int16)rand() * 0.000030517578 * 1000.0f); + if (veh->m_pCarFire) + return nil; + if (veh->IsCar() && ((CAutomobile *)veh)->Damage.GetEngineStatus() >= 225) + return nil; } - fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; - fire->m_pEntity = entityOnFire; - entityOnFire->RegisterReference(&fire->m_pEntity); - fire->m_pSource = fleeFrom; - if (fleeFrom) - fleeFrom->RegisterReference(&fire->m_pSource); - fire->ReportThisFire(); - fire->field_24 = 0; - fire->m_fStrength = strength; - fire->m_bPropagationFlag = propagation; - fire->m_bAudioSet = true; + CFire *fire = GetNextFreeFire(); + + if (fire) { + if (entityOnFire->IsPed()) { + ped->m_pFire = fire; + if (ped != FindPlayerPed()) { + if (fleeFrom) { + ped->SetFlee(fleeFrom, 10000); + } else { + CVector2D pos = entityOnFire->GetPosition(); + ped->SetFlee(pos, 10000); + ped->m_fleeFrom = nil; + } + ped->bDrawLast = false; + ped->SetMoveState(PEDMOVE_SPRINT); + ped->SetMoveAnim(); + ped->m_nPedState = PED_ON_FIRE; + } + if (fleeFrom) { + if (ped->m_nPedType == PEDTYPE_COP) { + CEventList::RegisterEvent(EVENT_COP_SET_ON_FIRE, EVENT_ENTITY_PED, + entityOnFire, (CPed *)fleeFrom, 10000); + } else { + CEventList::RegisterEvent(EVENT_PED_SET_ON_FIRE, EVENT_ENTITY_PED, + entityOnFire, (CPed *)fleeFrom, 10000); + } + } + } else { + if (entityOnFire->IsVehicle()) { + veh->m_pCarFire = fire; + if (fleeFrom) { + CEventList::RegisterEvent(EVENT_CAR_SET_ON_FIRE, EVENT_ENTITY_VEHICLE, + entityOnFire, (CPed *)fleeFrom, 10000); + } + } + } + + fire->m_bIsOngoing = true; + fire->m_bIsScriptFire = false; + fire->m_vecPos = entityOnFire->GetPosition(); + + if (entityOnFire && entityOnFire->IsPed() && ped->IsPlayer()) { + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 3333; + } else if (entityOnFire->IsVehicle()) { + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + CGeneral::GetRandomNumberInRange(4000, 5000); + } else { + fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + CGeneral::GetRandomNumberInRange(10000, 11000); + } + fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_pEntity = entityOnFire; + + entityOnFire->RegisterReference(&fire->m_pEntity); + fire->m_pSource = fleeFrom; + + if (fleeFrom) + fleeFrom->RegisterReference(&fire->m_pSource); + fire->ReportThisFire(); + fire->field_24 = 0; + fire->m_fStrength = strength; + fire->m_bPropagationFlag = propagation; + fire->m_bAudioSet = true; + } + return fire; } void @@ -292,8 +289,7 @@ CFireManager::Update(void) } } -CFire * -CFireManager::FindNearestFire(CVector vecPos, float *pDistance) +CFire* CFireManager::FindNearestFire(CVector vecPos, float *pDistance) { for (int i = 0; i < MAX_FIREMEN_ATTENDING; i++) { int fireId = -1; @@ -454,7 +450,7 @@ STARTPATCHES InjectHook(0x4798B0, &CFire::ReportThisFire, PATCH_JUMP); InjectHook(0x479D40, &CFire::Extinguish, PATCH_JUMP); InjectHook(0x479500, (void(CFireManager::*)(CVector pos, float size, bool propagation))&CFireManager::StartFire, PATCH_JUMP); - InjectHook(0x479590, (void(CFireManager::*)(CEntity *, CEntity *, float, bool))&CFireManager::StartFire, PATCH_JUMP); + InjectHook(0x479590, (CFire *(CFireManager::*)(CEntity *, CEntity *, float, bool))&CFireManager::StartFire, PATCH_JUMP); InjectHook(0x479310, &CFireManager::Update, PATCH_JUMP); InjectHook(0x479430, &CFireManager::FindFurthestFire_NeverMindFireMen, PATCH_JUMP); InjectHook(0x479340, &CFireManager::FindNearestFire, PATCH_JUMP); From 834f4f6d4c423683bf78e388418a260094c7bf21 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:01:10 +0100 Subject: [PATCH 05/18] Update Fire.h --- src/core/Fire.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/Fire.h b/src/core/Fire.h index 89ab9a9f..aa65fb8f 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -14,7 +14,7 @@ public: CEntity *m_pSource; uint32 m_nExtinguishTime; uint32 m_nStartTime; - int32 field_20; + int field_20; uint32 field_24; uint32 m_nFiremenPuttingOut; float m_fStrength; @@ -35,12 +35,12 @@ public: uint32 m_nTotalFires; CFire m_aFires[NUM_FIRES]; void StartFire(CVector pos, float size, bool propagation); - void StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation); + CFire *StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength, bool propagation); void Update(void); CFire *FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange); CFire *FindNearestFire(CVector vecPos, float *pDistance); CFire *GetNextFreeFire(void); - uint32 GetTotalActiveFires(void) const; + uint32 GetTotalActiveFires() const; void ExtinguishPoint(CVector point, float range); int32 StartScriptFire(const CVector &pos, CEntity *target, float strength, bool propagation); bool IsScriptFireExtinguish(int16 index); From 0605e704ca63d1cf57cb0f5e2c9d2dc0b18e0249 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:01:38 +0100 Subject: [PATCH 06/18] Update Fire.h --- src/core/Fire.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Fire.h b/src/core/Fire.h index aa65fb8f..e6c7dd7d 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -14,7 +14,7 @@ public: CEntity *m_pSource; uint32 m_nExtinguishTime; uint32 m_nStartTime; - int field_20; + int32 field_20; uint32 field_24; uint32 m_nFiremenPuttingOut; float m_fStrength; From e22ce9404c146daf90e5f32921cf9b043101e56a Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:07:07 +0100 Subject: [PATCH 07/18] Update Fire.cpp --- src/core/Fire.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index f46137f2..95856a0f 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -37,12 +37,6 @@ CFire::CFire() CFire::~CFire() {} -class CFire_ : public CFire { -public: - void ctor() { ::new(this) CFire(); } - void dtor() { CFire::CFire(); } -}; - void CFire::ProcessFire(void) { @@ -444,8 +438,6 @@ CFireManager::SetScriptFireAudio(int16 index, bool state) } STARTPATCHES - InjectHook(0x479220, &CFire_::ctor, PATCH_JUMP); - InjectHook(0x479280, &CFire_::dtor, PATCH_JUMP); InjectHook(0x4798D0, &CFire::ProcessFire, PATCH_JUMP); InjectHook(0x4798B0, &CFire::ReportThisFire, PATCH_JUMP); InjectHook(0x479D40, &CFire::Extinguish, PATCH_JUMP); From 08e1c869a4b8a91859f46d739f1d9a802500c677 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:09:27 +0100 Subject: [PATCH 08/18] renamed field_24 to m_nNextTimeToAddFlames --- src/core/Fire.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Fire.h b/src/core/Fire.h index e6c7dd7d..a4599d11 100644 --- a/src/core/Fire.h +++ b/src/core/Fire.h @@ -15,7 +15,7 @@ public: uint32 m_nExtinguishTime; uint32 m_nStartTime; int32 field_20; - uint32 field_24; + uint32 m_nNextTimeToAddFlames; uint32 m_nFiremenPuttingOut; float m_fStrength; From 96802f9b95219bc7ea9869d0ec1178ff6d4193c3 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:13:06 +0100 Subject: [PATCH 09/18] Update Fire.cpp --- src/core/Fire.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 95856a0f..e6756884 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -31,7 +31,7 @@ CFire::CFire() m_nExtinguishTime = 0; m_nStartTime = 0; field_20 = 1; - field_24 = 0; + m_nNextTimeToAddFlames = 0; m_fStrength = 0.8f; } @@ -95,8 +95,8 @@ CFire::ProcessFire(void) FindPlayerPed()->DoStuffToGoOnFire(); gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1); } - if (CTimer::m_snTimeInMilliseconds > field_24) { /* set to 0 when a newfire starts, related to time */ - field_24 = CTimer::m_snTimeInMilliseconds + 80; + if (CTimer::m_snTimeInMilliseconds > m_nNextTimeToAddFlames) { + m_nNextTimeToAddFlames = CTimer::m_snTimeInMilliseconds + 80; firePos = m_vecPos; if (veh && veh->IsVehicle() && veh->IsCar()) { @@ -122,7 +122,7 @@ CFire::ProcessFire(void) if (CTimer::m_snTimeInMilliseconds > m_nStartTime) m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; - nRandNumber = CGeneral::GetRandomNumber(); + nRandNumber = CGeneral::GetRandomNumber() & 127; lightpos.x = m_vecPos.x; lightpos.y = m_vecPos.y; lightpos.z = m_vecPos.z + 5.0f; @@ -162,7 +162,7 @@ CFire::Extinguish(void) if (m_pEntity) { if (m_pEntity->IsPed()) { ((CPed *)m_pEntity)->RestorePreviousState(); - ((CPed *)m_pEntity)->m_pFire = 0; + ((CPed *)m_pEntity)->m_pFire = nil; } else if (m_pEntity->IsVehicle()) { ((CVehicle *)m_pEntity)->m_pCarFire = nil; } @@ -186,7 +186,7 @@ CFireManager::StartFire(CVector pos, float size, bool propagation) fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; fire->m_pEntity = nil; fire->m_pSource = nil; - fire->field_24 = 0; + fire->m_nNextTimeToAddFlames = 0; fire->ReportThisFire(); fire->m_fStrength = size; } From c3841fe5b48f3b1c567d03273a2ea23bacac89ca Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 21:24:32 +0100 Subject: [PATCH 10/18] m_snTimeInMilliseconds to GetTimeInMilliseconds() --- src/core/Fire.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index e6756884..05c4fe96 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -95,8 +95,8 @@ CFire::ProcessFire(void) FindPlayerPed()->DoStuffToGoOnFire(); gFireManager.StartFire(FindPlayerPed(), m_pSource, 0.8f, 1); } - if (CTimer::m_snTimeInMilliseconds > m_nNextTimeToAddFlames) { - m_nNextTimeToAddFlames = CTimer::m_snTimeInMilliseconds + 80; + if (CTimer::GetTimeInMilliseconds() > m_nNextTimeToAddFlames) { + m_nNextTimeToAddFlames = CTimer::GetTimeInMilliseconds() + 80; firePos = m_vecPos; if (veh && veh->IsVehicle() && veh->IsCar()) { @@ -118,9 +118,9 @@ CFire::ProcessFire(void) CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, firePos, CVector(0.0f, 0.0f, 0.0f), 0, 0.0, 0, 0, 0, 0); } - if (CTimer::m_snTimeInMilliseconds < m_nExtinguishTime || m_bIsScriptFire) { - if (CTimer::m_snTimeInMilliseconds > m_nStartTime) - m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + if (CTimer::GetTimeInMilliseconds() < m_nExtinguishTime || m_bIsScriptFire) { + if (CTimer::GetTimeInMilliseconds() > m_nStartTime) + m_nStartTime = CTimer::GetTimeInMilliseconds() + 400; nRandNumber = CGeneral::GetRandomNumber() & 127; lightpos.x = m_vecPos.x; @@ -182,8 +182,8 @@ CFireManager::StartFire(CVector pos, float size, bool propagation) fire->m_bPropagationFlag = propagation; fire->m_bAudioSet = true; fire->m_vecPos = pos; - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 10000; - fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_nExtinguishTime = CTimer::GetTimeInMilliseconds() + 10000; + fire->m_nStartTime = CTimer::GetTimeInMilliseconds() + 400; fire->m_pEntity = nil; fire->m_pSource = nil; fire->m_nNextTimeToAddFlames = 0; @@ -251,13 +251,13 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength fire->m_vecPos = entityOnFire->GetPosition(); if (entityOnFire && entityOnFire->IsPed() && ped->IsPlayer()) { - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + 3333; + fire->m_nExtinguishTime = CTimer::GetTimeInMilliseconds() + 3333; } else if (entityOnFire->IsVehicle()) { - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + CGeneral::GetRandomNumberInRange(4000, 5000); + fire->m_nExtinguishTime = CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(4000, 5000); } else { - fire->m_nExtinguishTime = CTimer::m_snTimeInMilliseconds + CGeneral::GetRandomNumberInRange(10000, 11000); + fire->m_nExtinguishTime = CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(10000, 11000); } - fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_nStartTime = CTimer::GetTimeInMilliseconds() + 400; fire->m_pEntity = entityOnFire; entityOnFire->RegisterReference(&fire->m_pEntity); @@ -383,7 +383,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt fire->m_bPropagationFlag = propagation; fire->m_bAudioSet = true; fire->m_vecPos = pos; - fire->m_nStartTime = CTimer::m_snTimeInMilliseconds + 400; + fire->m_nStartTime = CTimer::GetTimeInMilliseconds() + 400; fire->m_pEntity = target; if (target) From 09af0bcaf8a8b9648a95a89bf2fbab3c1f6b54c8 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 22:54:14 +0100 Subject: [PATCH 11/18] Update Fire.cpp --- src/core/Fire.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 05c4fe96..13d53d03 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -266,7 +266,7 @@ CFireManager::StartFire(CEntity *entityOnFire, CEntity *fleeFrom, float strength if (fleeFrom) fleeFrom->RegisterReference(&fire->m_pSource); fire->ReportThisFire(); - fire->field_24 = 0; + fire->m_nNextTimeToAddFlames = 0; fire->m_fStrength = strength; fire->m_bPropagationFlag = propagation; fire->m_bAudioSet = true; @@ -389,7 +389,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt if (target) target->RegisterReference(&fire->m_pEntity); fire->m_pSource = nil; - fire->field_24 = 0; + fire->m_nNextTimeToAddFlames = 0; fire->m_fStrength = strength; if (target) { if (target->IsPed()) { From 93a4bc31fa767df0460d1e66e97f30c863cdc1bf Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 22:57:34 +0100 Subject: [PATCH 12/18] added wrapper for InflictDamage() --- src/vehicles/Vehicle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 90848d6c..6aa12841 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -32,6 +32,7 @@ void CVehicle::operator delete(void *p, int handle) { CPools::GetVehiclePool()-> WRAPPER bool CVehicle::ShufflePassengersToMakeSpace(void) { EAXJMP(0x5528A0); } // or Weapon.cpp? WRAPPER void FireOneInstantHitRound(CVector *shotSource, CVector *shotTarget, int32 damage) { EAXJMP(0x563B00); } +WRAPPER void CVehicle::InflictDamage(CVehicle *damagedBy, uint32 weaponType, float damage) { EAXJMP(0x551950); } CVehicle::CVehicle(uint8 CreatedBy) { From be2aca47cfa84626ded8c140e5f8cf4af5f1a055 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 22:58:20 +0100 Subject: [PATCH 13/18] added InflictDamage() declaration --- src/vehicles/Vehicle.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index bd8df694..68b7b2ca 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -266,6 +266,7 @@ public: void ProcessCarAlarm(void); bool IsSphereTouchingVehicle(float sx, float sy, float sz, float radius); bool ShufflePassengersToMakeSpace(void); + void InflictDamage(CEntity *damagedBy, uint32 weaponType, float damage); bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; } CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); } From a66db9efcb5d3245248ac4b5b9accfe8e6b99768 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Wed, 25 Mar 2020 23:01:22 +0100 Subject: [PATCH 14/18] Update Fire.cpp --- src/core/Fire.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 13d53d03..864c2509 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -25,8 +25,8 @@ CFire::CFire() m_bPropagationFlag = true; m_bAudioSet = true; m_vecPos = CVector(0.0f, 0.0f, 0.0f); - m_pEntity = 0; - m_pSource = 0; + m_pEntity = nil; + m_pSource = nil; m_nFiremenPuttingOut = 0; m_nExtinguishTime = 0; m_nStartTime = 0; From 0e9101594031fb9468d639ab6e4b57449cd8997c Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Thu, 26 Mar 2020 14:19:55 +0100 Subject: [PATCH 15/18] Update Vehicle.cpp --- src/vehicles/Vehicle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index 6aa12841..ac0da52c 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -32,7 +32,7 @@ void CVehicle::operator delete(void *p, int handle) { CPools::GetVehiclePool()-> WRAPPER bool CVehicle::ShufflePassengersToMakeSpace(void) { EAXJMP(0x5528A0); } // or Weapon.cpp? WRAPPER void FireOneInstantHitRound(CVector *shotSource, CVector *shotTarget, int32 damage) { EAXJMP(0x563B00); } -WRAPPER void CVehicle::InflictDamage(CVehicle *damagedBy, uint32 weaponType, float damage) { EAXJMP(0x551950); } +WRAPPER void CVehicle::InflictDamage(CEntity *damagedBy, uint32 weaponType, float damage) { EAXJMP(0x551950); } CVehicle::CVehicle(uint8 CreatedBy) { From edc92a7bcc6a2ddf1e29815e4696d9be0420bae1 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Thu, 26 Mar 2020 17:00:58 +0100 Subject: [PATCH 16/18] Update Fire.cpp --- src/core/Fire.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 864c2509..ef9b08bd 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -410,7 +410,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt bool CFireManager::IsScriptFireExtinguish(int16 index) { - return (!m_aFires[index].m_bIsOngoing) ? true : false; + return m_aFires[index].m_bIsOngoing ? false : true; } void From 853b2d0c7890b5a0bb33617b33574086a0fe2b81 Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Thu, 26 Mar 2020 17:05:01 +0100 Subject: [PATCH 17/18] Update Fire.cpp --- src/core/Fire.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index ef9b08bd..63442787 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -410,7 +410,7 @@ CFireManager::StartScriptFire(const CVector &pos, CEntity *target, float strengt bool CFireManager::IsScriptFireExtinguish(int16 index) { - return m_aFires[index].m_bIsOngoing ? false : true; + return !m_aFires[index].m_bIsOngoing; } void From 79822e3f7c1c0255f9b0dad2d874d88a1c2b2c3f Mon Sep 17 00:00:00 2001 From: blingu <36486731+blingu@users.noreply.github.com> Date: Thu, 26 Mar 2020 17:11:04 +0100 Subject: [PATCH 18/18] Update Fire.cpp --- src/core/Fire.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/Fire.cpp b/src/core/Fire.cpp index 63442787..c98c808d 100644 --- a/src/core/Fire.cpp +++ b/src/core/Fire.cpp @@ -116,7 +116,7 @@ CFire::ProcessFire(void) rand(); rand(); rand(); /* unsure why these three rands are called */ CParticle::AddParticle(PARTICLE_CARFLAME_SMOKE, firePos, - CVector(0.0f, 0.0f, 0.0f), 0, 0.0, 0, 0, 0, 0); + CVector(0.0f, 0.0f, 0.0f), 0, 0.0f, 0, 0, 0, 0); } if (CTimer::GetTimeInMilliseconds() < m_nExtinguishTime || m_bIsScriptFire) { if (CTimer::GetTimeInMilliseconds() > m_nStartTime) @@ -129,14 +129,14 @@ CFire::ProcessFire(void) if (!m_pEntity) { CShadows::StoreStaticShadow((uint32)this, SHADOWTYPE_ADDITIVE, gpShadowExplosionTex, &lightpos, - 7.0, 0.0, 0.0, -7.0, 0, nRandNumber / 2, nRandNumber / 2, - 0, 10.0, 1.0, 40.0, 0, 0.0); + 7.0f, 0.0f, 0.0f, -7.0f, 0, nRandNumber / 2, nRandNumber / 2, + 0, 10.0f, 1.0f, 40.0f, 0, 0.0f); } fGreen = nRandNumber / 128; fRed = nRandNumber / 128; CPointLights::AddLight(0, m_vecPos, CVector(0.0f, 0.0f, 0.0f), - 12.0, fRed, fGreen, 0, 0, 0); + 12.0f, fRed, fGreen, 0, 0, 0); } else { Extinguish(); } @@ -312,7 +312,7 @@ CFire * CFireManager::FindFurthestFire_NeverMindFireMen(CVector coords, float minRange, float maxRange) { int furthestFire = -1; - float lastFireDist = 0.0; + float lastFireDist = 0.0f; float fireDist; for (int i = 0; i < NUM_FIRES; i++) {