From 9fed0c040c482bac8cba688e7564c8e8dfe23b30 Mon Sep 17 00:00:00 2001 From: _AG Date: Thu, 4 Jul 2019 22:31:21 +0200 Subject: Darkel/Wanted update. --- src/Camera.cpp | 9 ++ src/Camera.h | 1 + src/Stats.cpp | 9 +- src/Stats.h | 4 + src/Wanted.cpp | 93 +++++++++++++ src/Wanted.h | 12 +- src/control/Darkel.cpp | 314 ++++++++++++++++++++++++++++++++++++++++++- src/control/Darkel.h | 39 +++++- src/entities/Ped.cpp | 9 +- src/entities/Ped.h | 3 +- src/entities/PlayerPed.cpp | 16 ++- src/entities/PlayerPed.h | 1 + src/render/WeaponEffects.cpp | 7 + src/render/WeaponEffects.h | 14 ++ src/weapons/Weapon.h | 18 ++- src/weapons/WeaponInfo.cpp | 6 +- 16 files changed, 531 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/Camera.cpp b/src/Camera.cpp index d7ee398b..735ff4a2 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -136,6 +136,15 @@ CCamera::RenderMotionBlur(void) m_motionBlur, m_BlurType, m_imotionBlurAddAlpha); } +void +CCamera::ClearPlayerWeaponMode() +{ + PlayerWeaponMode.Mode = 0; + PlayerWeaponMode.MaxZoom = 1; + PlayerWeaponMode.MinZoom = -1; + PlayerWeaponMode.Duration = 0.0f; +} + /* * diff --git a/src/Camera.h b/src/Camera.h index 84c3060b..db5fff46 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -457,6 +457,7 @@ int m_iModeObbeCamIsInForCar; void SetMotionBlur(int r, int g, int b, int a, int type); void SetMotionBlurAlpha(int a); void RenderMotionBlur(void); + void ClearPlayerWeaponMode(); void CalculateDerivedValues(void); void DrawBordersForWideScreen(void); diff --git a/src/Stats.cpp b/src/Stats.cpp index 5256b0cf..7db6e795 100644 --- a/src/Stats.cpp +++ b/src/Stats.cpp @@ -2,4 +2,11 @@ #include "Stats.h" int32 &CStats::DaysPassed = *(int32*)0x8F2BB8; -int32 &CStats::HeadShots = *(int32*)0x8F647C; \ No newline at end of file +int32 &CStats::HeadShots = *(int32*)0x8F647C; +int32 &CStats::NumberKillFrenziesPassed = *(int32*)0x8E287C; +int32 &CStats::PeopleKilledByOthers = *(int32*)0x8E2C50; + +void CStats::AnotherKillFrenzyPassed() +{ + ++NumberKillFrenziesPassed; +} diff --git a/src/Stats.h b/src/Stats.h index 4508e8a8..eff4af1d 100644 --- a/src/Stats.h +++ b/src/Stats.h @@ -5,4 +5,8 @@ class CStats public: static int32 &DaysPassed; static int32 &HeadShots; + static int32 &NumberKillFrenziesPassed; + static int32 &PeopleKilledByOthers; + + static void AnotherKillFrenzyPassed(); }; \ No newline at end of file diff --git a/src/Wanted.cpp b/src/Wanted.cpp index ece68e64..21853308 100644 --- a/src/Wanted.cpp +++ b/src/Wanted.cpp @@ -2,6 +2,8 @@ #include "patcher.h" #include "Wanted.h" +int32 &CWanted::MaximumWantedLevel = *(int32*)0x5F7714; + bool CWanted::AreSwatRequired() { return m_nWantedLevel >= 4; @@ -33,4 +35,95 @@ int CWanted::NumOfHelisRequired() default: return 0; }; +} + +void CWanted::SetWantedLevel(int32 level) +{ + ClearQdCrimes(); + switch (level) { + case NOTWANTED: + m_nChaos = 0; + break; + case WANTEDLEVEL_1: + m_nChaos = 60; + break; + case WANTEDLEVEL_2: + m_nChaos = 220; + break; + case WANTEDLEVEL_3: + m_nChaos = 420; + break; + case WANTEDLEVEL_4: + m_nChaos = 820; + break; + case WANTEDLEVEL_5: + m_nChaos = 1620; + break; + case WANTEDLEVEL_6: + m_nChaos = 3220; + break; + default: + if (level > MaximumWantedLevel) + m_nChaos = MaximumWantedLevel; + break; + } + UpdateWantedLevel(); +} + +void CWanted::ClearQdCrimes() +{ + for (int i = 0; i < 16; i++) { + m_sCrimes[i].m_eCrimeType = CRIME_NONE; + }; +} + +void CWanted::UpdateWantedLevel() +{ + int32 CurrWantedLevel = m_nWantedLevel; + + if (m_nChaos >= 0 && m_nChaos < 40) { + m_nWantedLevel = NOTWANTED; + m_MaximumLawEnforcerVehicles = 0; + m_MaxCops = 0; + m_RoadblockDensity = 0; + } + else if (m_nChaos >= 40 && m_nChaos < 200) { + m_nWantedLevel = WANTEDLEVEL_1; + m_MaximumLawEnforcerVehicles = 1; + m_MaxCops = 1; + m_RoadblockDensity = 0; + } + else if (m_nChaos >= 200 && m_nChaos < 400) { + m_nWantedLevel = WANTEDLEVEL_2; + m_MaximumLawEnforcerVehicles = 2; + m_MaxCops = 3; + m_RoadblockDensity = 0; + } + else if (m_nChaos >= 400 && m_nChaos < 800) { + m_nWantedLevel = WANTEDLEVEL_3; + m_MaximumLawEnforcerVehicles = 2; + m_MaxCops = 4; + m_RoadblockDensity = 4; + } + else if (m_nChaos >= 800 && m_nChaos < 1600) { + m_nWantedLevel = WANTEDLEVEL_4; + m_MaximumLawEnforcerVehicles = 2; + m_MaxCops = 6; + m_RoadblockDensity = 8; + } + else if (m_nChaos >= 1600 && m_nChaos < 3200) { + m_nWantedLevel = WANTEDLEVEL_5; + m_MaximumLawEnforcerVehicles = 3; + m_MaxCops = 8; + m_RoadblockDensity = 10; + } + else if (m_nChaos >= 3200) { + m_nWantedLevel = WANTEDLEVEL_6; + m_MaximumLawEnforcerVehicles = 3; + m_MaxCops = 10; + m_RoadblockDensity = 12; + } + + if (CurrWantedLevel != m_nWantedLevel) + m_nLastWantedLevelChange = CTimer::GetTimeInMilliseconds(); } \ No newline at end of file diff --git a/src/Wanted.h b/src/Wanted.h index aafa9ac0..d14bb905 100644 --- a/src/Wanted.h +++ b/src/Wanted.h @@ -20,11 +20,11 @@ public: int32 m_nLastUpdateTime; int32 m_nLastWantedLevelChange; float m_fCrimeSensitivity; - uint8 m_bCurrentCops; - uint8 m_bMaxCops; - uint8 m_bMaximumLawEnforcerVehicles; + uint8 m_CurrentCops; + uint8 m_MaxCops; + uint8 m_MaximumLawEnforcerVehicles; int8 field_19; - int16 m_wRoadblockDensity; + int16 m_RoadblockDensity; uint8 m_IsIgnoredByCops : 1; uint8 m_IsIgnoredByEveryOne : 1; uint8 m_IsSwatRequired : 1; @@ -34,12 +34,16 @@ public: int32 m_nWantedLevel; CCrime m_sCrimes[16]; CCopPed *m_pCops[10]; + static int32 &MaximumWantedLevel; public: bool AreSwatRequired(); bool AreFbiRequired(); bool AreArmyRequired(); int NumOfHelisRequired(); + void SetWantedLevel(int32); + void ClearQdCrimes(); + void UpdateWantedLevel(); }; static_assert(sizeof(CWanted) == 0x204, "CWanted: error"); diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp index 32d975e0..931884fc 100644 --- a/src/control/Darkel.cpp +++ b/src/control/Darkel.cpp @@ -1,12 +1,320 @@ #include "common.h" #include "patcher.h" +#include "main.h" #include "Darkel.h" +#include "Timer.h" +#include "DMAudio.h" +#include "Population.h" +#include "Weapon.h" +#include "World.h" +#include "PlayerPed.h" +#include "Stats.h" +#include "Font.h" +#include "Text.h" +int32 &CDarkel::TimeLimit = *(int32*)0x885BAC; +int32 &CDarkel::PreviousTime = *(int32*)0x885B00; +int32 &CDarkel::TimeOfFrenzyStart = *(int32*)0x9430D8; +int32 &CDarkel::WeaponType = *(int32*)0x9430F0; +int32 &CDarkel::AmmoInterruptedWeapon = *(int32*)0x8E29C8; +int32 &CDarkel::KillsNeeded = *(int32*)0x8F1AB8; +int8 &CDarkel::InterruptedWeapon = *(int8*)0x95CD60; +int8 &CDarkel::bStandardSoundAndMessages = *(int8*)0x95CDB6; +int8 &CDarkel::bNeedHeadShot = *(int8*)0x95CDCA; +int8 &CDarkel::bProperKillFrenzy = *(int8*)0x95CD98; +eKillFrenzyStatus &CDarkel::Status = *(eKillFrenzyStatus*)0x95CCB4; +int16 *CDarkel::RegisteredKills = (int16*)0x6EDBE0; +int32 &CDarkel::ModelToKill = *(int32*)0x8F2C78; +int32 &CDarkel::ModelToKill2 = *(int32*)0x885B40; +int32 &CDarkel::ModelToKill3 = *(int32*)0x885B3C; +int32 &CDarkel::ModelToKill4 = *(int32*)0x885B34; +wchar *CDarkel::pStartMessage = (wchar*)0x8F2C08; + +int32 CDarkel::CalcFade(uint32 time, int32 min, uint32 max) { + if (time >= min && time <= max) { + if (time >= min + 500) { + if (time <= max - 500) + return -1; + else + return 255 * (max - time) / 500; + } + else + return 255 * (time - min) / 500; + } + else + return 0; +} + + +#if 0 WRAPPER void CDarkel::DrawMessages(void) { EAXJMP(0x420920); } +#else +void CDarkel::DrawMessages() +{ + bool DisplayTimers = false; + + switch (Status) { + case KILLFRENZY_ONGOING: + DisplayTimers = true; + break; + case KILLFRENZY_PASSED: + case KILLFRENZY_FAILED: + DisplayTimers = false; + break; + }; + + if (DisplayTimers) { + CFont::SetPropOn(); + CFont::SetBackgroundOff(); + CFont::SetBackGroundOnlyTextOn(); + CFont::SetAlignment(ALIGN_RIGHT); + CFont::SetRightJustifyWrap(-SCREEN_WIDTH); + CFont::SetFontStyle(FONT_HEADING); + CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); + + float AlignToHUD = SCREEN_SCALE_X(-10.0f); + int32 a = (TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)); + if (CTimer::GetFrameCounter() & 8 || a > 4000) { + sprintf(gString, "%d:%02d", a / 60000, a % 60000 / 1000); + AsciiToUnicode(gString, gUString); + CFont::SetColor(CRGBA(0, 0, 0, 255)); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(25.0f) + AlignToHUD, SCREEN_SCALE_Y(112.0f), gUString); + + CFont::SetColor(CRGBA(150, 100, 255, 255)); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) + AlignToHUD, SCREEN_SCALE_Y(110.0f), gUString); + } + + if (KillsNeeded <= 0) + KillsNeeded = 0; + + sprintf((char *)gString, "%d", KillsNeeded); + AsciiToUnicode(gString, gUString); + + CFont::SetColor(CRGBA(0, 0, 0, 255)); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(25.0f) + AlignToHUD, SCREEN_SCALE_Y(134.0f), gUString); + + CFont::SetColor(CRGBA(255, 128, 128, 255)); + CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) + AlignToHUD, SCREEN_SCALE_Y(132.0f), gUString); + } +} +#endif + +void CDarkel::Init() +{ + Status = KILLFRENZY_INIT; +} + +int16 CDarkel::QueryModelsKilledByPlayer(int32 modelId) +{ + return RegisteredKills[modelId]; +} -bool CDarkel::Status = *(bool*)0x95CCB4; bool CDarkel::FrenzyOnGoing() { - return Status == 1; -} \ No newline at end of file + return Status == KILLFRENZY_ONGOING; +} + + +eKillFrenzyStatus CDarkel::ReadStatus() +{ + return Status; +} + +int32 CDarkel::RegisterCarBlownUpByPlayer(eKillFrenzyStatus status) +{ + return 0; +} + +void CDarkel::RegisterKillByPlayer(int32 modelid, eWeaponType weapontype, bool flag) +{ + + +} + +void CDarkel::RegisterKillNotByPlayer() +{ + ++CStats::NumberKillFrenziesPassed; +} + +void CDarkel::ResetModelsKilledByPlayer() +{ + for (int i = 0; i < 200; i++) { + for (int j = 0; j < 8; j++) + RegisteredKills[i + j] = 0; + }; +} + +void CDarkel::ResetOnPlayerDeath() +{ + eWeaponType &EWeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + int32 &CurrentWeapon = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId; + int32 &CurrentDarkelWeapon = CDarkel::WeaponType; + uint32 &TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; + + if (Status == KILLFRENZY_ONGOING) { + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_FAILED; + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + CurrentDarkelWeapon = WEAPONTYPE_UZI; + + if (CurrentDarkelWeapon < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + TotalAmmo = AmmoInterruptedWeapon; + } + + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CurrentWeapon); + FindPlayerPed()->m_currentWeapon = EWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); + } + } +} + +#if 0 +WRAPPER void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) { EAXJMP(0x4210E0); } +#else +void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) +{ + eWeaponType &EWeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + uint32 &TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; + uint32 &AmmoInClip = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip; + + if (weaponType == WEAPONTYPE_UZI_DRIVEBY) + weaponType = WEAPONTYPE_UZI; + + WeaponType = weaponType; + Status = KILLFRENZY_ONGOING; + KillsNeeded = kill; + ModelToKill = modelId0; + ModelToKill2 = modelId2; + ModelToKill3 = modelId3; + ModelToKill4 = modelId4; + pStartMessage = text; + + if (text == TheText.Get("PAGE_00")) { + CDarkel::bProperKillFrenzy = 1; + CDarkel::pStartMessage = 0; + } + else + bProperKillFrenzy = 0; + + bStandardSoundAndMessages = standardSound; + bNeedHeadShot = needHeadShot; + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + TimeLimit = time; + PreviousTime = time / 1000; + + if (weaponType < WEAPONTYPE_TOTALWEAPONS) { + InterruptedWeapon = FindPlayerPed()->m_currentWeapon; + FindPlayerPed()->GiveWeapon(weaponType, 0); + AmmoInterruptedWeapon = TotalAmmo; + FindPlayerPed()->GiveWeapon(weaponType, 30000); + FindPlayerPed()->m_bWeaponSlot = EWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_bWeaponSlot); + + if (FindPlayerVehicle()) { + FindPlayerPed()->m_currentWeapon = EWeaponType; + if (TotalAmmo <= AmmoInClip) + AmmoInClip = TotalAmmo; + + FindPlayerPed()->ClearWeaponTarget(); + } + } + if (CDarkel::bStandardSoundAndMessages) + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_START, 0); +} +#endif + +void CDarkel::Update() +{ + eWeaponType &EWeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + int32 &CurrentWeapon = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId; + int32 &CurrentDarkelWeapon = CDarkel::WeaponType; + uint32 &TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; + + if (Status == KILLFRENZY_ONGOING) { + int32 FrameTime = TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart); + if ((TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)) > 0 || TimeLimit < 0) { + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_ONGOING, FrameTime); + + int32 PrevTime = FrameTime / 1000; + + if (PrevTime != PreviousTime) { + if (PreviousTime < 12) + DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, PrevTime); + PreviousTime = PrevTime; + } + + } + else { + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_FAILED; + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + CurrentDarkelWeapon = WEAPONTYPE_UZI; + + if (CurrentDarkelWeapon < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + TotalAmmo = AmmoInterruptedWeapon; + } + + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CurrentWeapon); + FindPlayerPed()->m_currentWeapon = EWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); + } + + if (bStandardSoundAndMessages) + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_FAILED, 0); + } + + if (KillsNeeded <= 0) { + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_PASSED; + + if (bProperKillFrenzy) + CStats::AnotherKillFrenzyPassed(); + + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + + FindPlayerPed()->m_pWanted->SetWantedLevel(NOTWANTED); + + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + CurrentDarkelWeapon = WEAPONTYPE_UZI; + + if (CurrentDarkelWeapon < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + TotalAmmo = AmmoInterruptedWeapon; + } + + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CurrentWeapon); + FindPlayerPed()->m_currentWeapon = EWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); + } + + if (bStandardSoundAndMessages) + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_PASSED, 0); + } + } +} + +STARTPATCHES + /*InjectHook(0x421380, CDarkel::CalcFade, PATCH_JUMP); + InjectHook(0x420920, CDarkel::DrawMessages, PATCH_JUMP); + InjectHook(0x420E60, CDarkel::FrenzyOnGoing, PATCH_JUMP); + InjectHook(0x420650, CDarkel::Init, PATCH_JUMP); + InjectHook(0x421370, CDarkel::QueryModelsKilledByPlayer, PATCH_JUMP); + InjectHook(0x420E50, CDarkel::ReadStatus, PATCH_JUMP); + InjectHook(0x421070, CDarkel::RegisterCarBlownUpByPlayer, PATCH_JUMP); + InjectHook(0x420F60, CDarkel::RegisterKillByPlayer, PATCH_JUMP); + InjectHook(0x421060, CDarkel::RegisterKillNotByPlayer, PATCH_JUMP); + InjectHook(0x421310, CDarkel::ResetModelsKilledByPlayer, PATCH_JUMP); + InjectHook(0x420E70, CDarkel::ResetOnPlayerDeath, PATCH_JUMP); + InjectHook(0x4210E0, CDarkel::StartFrenzy, PATCH_JUMP); + InjectHook(0x420660, CDarkel::Update, PATCH_JUMP);*/ +ENDPATCHES \ No newline at end of file diff --git a/src/control/Darkel.h b/src/control/Darkel.h index ed78d4e1..905f5497 100644 --- a/src/control/Darkel.h +++ b/src/control/Darkel.h @@ -1,11 +1,48 @@ #pragma once +#include "Weapon.h" + +enum eKillFrenzyStatus +{ + KILLFRENZY_INIT, + KILLFRENZY_ONGOING, + KILLFRENZY_PASSED, + KILLFRENZY_FAILED, +}; class CDarkel { private: - static bool Status; + static int32 &TimeLimit; + static int32 &PreviousTime; + static int32 &TimeOfFrenzyStart; + static int32 &WeaponType; + static int32 &AmmoInterruptedWeapon; + static int32 &KillsNeeded; + static int8 &InterruptedWeapon; + static int8 &bStandardSoundAndMessages; + static int8 &bNeedHeadShot; + static int8 &bProperKillFrenzy; + static eKillFrenzyStatus &Status; + static int16 *RegisteredKills; + static int32 &ModelToKill; + static int32 &ModelToKill2; + static int32 &ModelToKill3; + static int32 &ModelToKill4; + static wchar *pStartMessage; public: + static int32 CalcFade(uint32 time, int32 min, uint32 max); static void DrawMessages(void); static bool FrenzyOnGoing(); + static void Init(); + static int16 QueryModelsKilledByPlayer(int32 modelId); + static eKillFrenzyStatus ReadStatus(); + static int32 RegisterCarBlownUpByPlayer(eKillFrenzyStatus status); + static void RegisterKillByPlayer(int32 modelid, eWeaponType weapontype, bool flag); + static void RegisterKillNotByPlayer(); + static void ResetModelsKilledByPlayer(); + static void ResetOnPlayerDeath(); + static void StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot); + static void Update(); + }; diff --git a/src/entities/Ped.cpp b/src/entities/Ped.cpp index 9e1836c2..2e51a5c1 100644 --- a/src/entities/Ped.cpp +++ b/src/entities/Ped.cpp @@ -39,6 +39,7 @@ WRAPPER void CPed::PreRender(void) { EAXJMP(0x4CFDD0); } WRAPPER void CPed::Render(void) { EAXJMP(0x4D03F0); } WRAPPER int32 CPed::ProcessEntityCollision(CEntity*, CColPoint*) { EAXJMP(0x4CBB30); } WRAPPER void CPed::SetMoveAnim(void) { EAXJMP(0x4C5A40); } +WRAPPER void CPed::MakeChangesForNewWeapon(int8) { EAXJMP(0x4F2560); } bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44; bool &CPed::bPedCheat2 = *(bool*)0x95CD5A; @@ -461,9 +462,9 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) } m_maxWeaponTypeAllowed = 0; m_currentWeapon = 0; - m_storedWeapon = NO_STORED_WEAPON; + m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; - for(int i = 0; i < NUM_PED_WEAPONTYPES; i++) + for(int i = 0; i < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; i++) { CWeapon &weapon = GetWeapon(i); weapon.m_eWeaponType = WEAPONTYPE_UNARMED; @@ -1445,9 +1446,9 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) // Only uzi can be used on cars, so previous weapon was stored if (ped->IsPlayer() && weaponType == WEAPONTYPE_UZI) { - if (ped->m_storedWeapon != NO_STORED_WEAPON) { + if (ped->m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { ped->SetCurrentWeapon(ped->m_storedWeapon); - ped->m_storedWeapon = NO_STORED_WEAPON; + ped->m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; } } else { ped->AddWeaponModel(CWeaponInfo::GetWeaponInfo(weaponType)->m_nModelId); diff --git a/src/entities/Ped.h b/src/entities/Ped.h index 558ec9c1..4367dc61 100644 --- a/src/entities/Ped.h +++ b/src/entities/Ped.h @@ -324,7 +324,7 @@ public: uint8 pad_351[3]; uint32 m_timerUnused; CEntity *m_targetUnused; - CWeapon m_weapons[NUM_PED_WEAPONTYPES]; + CWeapon m_weapons[WEAPONTYPE_TOTAL_INVENTORY_WEAPONS]; eWeaponType m_storedWeapon; uint8 m_currentWeapon; // eWeaponType uint8 m_maxWeaponTypeAllowed; // eWeaponType @@ -427,6 +427,7 @@ public: bool CanSeeEntity(CEntity*, float); void RestorePreviousObjective(void); void SetObjective(eObjective, void*); + void MakeChangesForNewWeapon(int8); // Static methods static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset); diff --git a/src/entities/PlayerPed.cpp b/src/entities/PlayerPed.cpp index 2d67d5b2..7eb01db0 100644 --- a/src/entities/PlayerPed.cpp +++ b/src/entities/PlayerPed.cpp @@ -1,6 +1,8 @@ #include "common.h" #include "patcher.h" #include "PlayerPed.h" +#include "Camera.h" +#include "WeaponEffects.h" CPlayerPed::~CPlayerPed() { @@ -9,6 +11,18 @@ CPlayerPed::~CPlayerPed() WRAPPER void CPlayerPed::ReApplyMoveAnims(void) { EAXJMP(0x4F07C0); } +void CPlayerPed::ClearWeaponTarget() +{ + if (!m_nPedType) { + m_pPointGunAt = 0; + TheCamera.ClearPlayerWeaponMode(); + CWeaponEffects::ClearCrosshair(); + } + ClearPointGunAt(); +} + STARTPATCHES - InjectHook(0x4EFB30, &CPlayerPed::dtor, PATCH_JUMP); +InjectHook(0x4EFB30, &CPlayerPed::dtor, PATCH_JUMP); +InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP); + ENDPATCHES \ No newline at end of file diff --git a/src/entities/PlayerPed.h b/src/entities/PlayerPed.h index 15ad74a6..4f325da3 100644 --- a/src/entities/PlayerPed.h +++ b/src/entities/PlayerPed.h @@ -43,6 +43,7 @@ public: void dtor(void) { this->CPlayerPed::~CPlayerPed(); } void ReApplyMoveAnims(void); + void ClearWeaponTarget(); }; static_assert(sizeof(CPlayerPed) == 0x5F0, "CPlayerPed: error"); diff --git a/src/render/WeaponEffects.cpp b/src/render/WeaponEffects.cpp index a1a6d25a..e062da07 100644 --- a/src/render/WeaponEffects.cpp +++ b/src/render/WeaponEffects.cpp @@ -3,3 +3,10 @@ #include "WeaponEffects.h" WRAPPER void CWeaponEffects::Render(void) { EAXJMP(0x564D70); } + +CWeaponEffects &gCrossHair = *(CWeaponEffects*)0x6503BC; + +void CWeaponEffects::ClearCrosshair() +{ + gCrossHair.m_bCrosshair = false; +} diff --git a/src/render/WeaponEffects.h b/src/render/WeaponEffects.h index 63c8fd7d..7176c26d 100644 --- a/src/render/WeaponEffects.h +++ b/src/render/WeaponEffects.h @@ -2,6 +2,20 @@ class CWeaponEffects { +public: + bool m_bCrosshair; + int8 gap_1[3]; + CVector m_vecPos; + int8 field_16; + int8 field_17; + int8 field_18; + int8 field_19; + float field_20; + int32 field_24; + RwTexture *m_pTexture; + RwRaster *m_pRaster; + public: static void Render(void); + static void ClearCrosshair(); }; diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index 8cb435ce..a8a5d9b3 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -1,9 +1,9 @@ #pragma once #include "Entity.h" -enum eWeaponType : uint32 +enum eWeaponType { - WEAPONTYPE_UNARMED = 0, + WEAPONTYPE_UNARMED, WEAPONTYPE_BASEBALLBAT, WEAPONTYPE_COLT45, WEAPONTYPE_UZI, @@ -16,10 +16,16 @@ enum eWeaponType : uint32 WEAPONTYPE_MOLOTOV, WEAPONTYPE_GRENADE, WEAPONTYPE_DETONATOR, - NUM_PED_WEAPONTYPES = 13, - WEAPONTYPE_HELICANNON = 13, - NUM_WEAPONTYPES, - NO_STORED_WEAPON = 22 + WEAPONTYPE_TOTAL_INVENTORY_WEAPONS, + WEAPONTYPE_TOTALWEAPONS, + WEAPONTYPE_ARMOUR, + WEAPONTYPE_RAMMEDBYCAR, + WEAPONTYPE_RUNOVERBYCAR, + WEAPONTYPE_EXPLOSION, + WEAPONTYPE_UZI_DRIVEBY, + WEAPONTYPE_WATER, + WEAPONTYPE_FALL_DAMAGE, + WEAPONTYPE_UNIDENTIFIED, }; enum eWeaponFire { diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index 5be18c3c..6884d347 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -6,7 +6,7 @@ #include "AnimBlendAssociation.h" //CWeaponInfo (&CWeaponInfo::ms_apWeaponInfos)[14] = * (CWeaponInfo(*)[14]) * (uintptr*)0x6503EC; -CWeaponInfo CWeaponInfo::ms_apWeaponInfos[NUM_WEAPONTYPES]; +CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS]; static char ms_aWeaponNames[][32] = { "Unarmed", @@ -34,7 +34,7 @@ void CWeaponInfo::Initialise(void) { debug("Initialising CWeaponInfo...\n"); - for (int i = 0; i < NUM_WEAPONTYPES; i++) { + for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) { ms_apWeaponInfos[i].m_eWeaponFire = WEAPON_FIRE_INSTANT_HIT; ms_apWeaponInfos[i].m_AnimToPlay = ANIM_PUNCH_R; ms_apWeaponInfos[i].m_Anim2ToPlay = NUM_ANIMS; @@ -176,7 +176,7 @@ CWeaponInfo::LoadWeaponData(void) eWeaponType CWeaponInfo::FindWeaponType(char *name) { - for (int i = 0; i < NUM_WEAPONTYPES; i++) { + for (int i = 0; i < WEAPONTYPE_TOTALWEAPONS; i++) { if (strcmp(ms_aWeaponNames[i], name) == 0) { return static_cast(i); } -- cgit v1.2.3 From 29767c19645d88827b799908f4595123e6c27ede Mon Sep 17 00:00:00 2001 From: _AG Date: Sun, 7 Jul 2019 09:13:04 +0200 Subject: Lil update. --- src/Stats.h | 1 + src/control/Darkel.cpp | 209 ++++++++++++++++++++++++++----------------------- src/control/Darkel.h | 2 +- 3 files changed, 115 insertions(+), 97 deletions(-) (limited to 'src') diff --git a/src/Stats.h b/src/Stats.h index eff4af1d..38e8d5be 100644 --- a/src/Stats.h +++ b/src/Stats.h @@ -8,5 +8,6 @@ public: static int32 &NumberKillFrenziesPassed; static int32 &PeopleKilledByOthers; +public: static void AnotherKillFrenzyPassed(); }; \ No newline at end of file diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp index 931884fc..ab55c4d4 100644 --- a/src/control/Darkel.cpp +++ b/src/control/Darkel.cpp @@ -30,22 +30,22 @@ int32 &CDarkel::ModelToKill3 = *(int32*)0x885B3C; int32 &CDarkel::ModelToKill4 = *(int32*)0x885B34; wchar *CDarkel::pStartMessage = (wchar*)0x8F2C08; -int32 CDarkel::CalcFade(uint32 time, int32 min, uint32 max) { - if (time >= min && time <= max) { - if (time >= min + 500) { - if (time <= max - 500) - return -1; +int32 CDarkel::CalcFade(uint32 time, int32 start, uint32 end) { + if (time >= start && time <= end) { + if (time >= start + 500) { + if (time <= end - 500) + return 0; else - return 255 * (max - time) / 500; + return 255 * (end - time) / 500; } else - return 255 * (time - min) / 500; + return 255 * (time - start) / 500; } else return 0; } - +// This function has been cleaned up from unused stuff. #if 0 WRAPPER void CDarkel::DrawMessages(void) { EAXJMP(0x420920); } #else @@ -101,7 +101,7 @@ void CDarkel::DrawMessages() void CDarkel::Init() { - Status = KILLFRENZY_INIT; + Status = KILLFRENZY_NONE; } int16 CDarkel::QueryModelsKilledByPlayer(int32 modelId) @@ -121,16 +121,24 @@ eKillFrenzyStatus CDarkel::ReadStatus() return Status; } +#if 1 +WRAPPER int32 CDarkel::RegisterCarBlownUpByPlayer(eKillFrenzyStatus status) { EAXJMP(0x421070); } +#else int32 CDarkel::RegisterCarBlownUpByPlayer(eKillFrenzyStatus status) { return 0; } +#endif +#if 1 +WRAPPER void CDarkel::RegisterKillByPlayer(int32 modelid, eWeaponType weapontype, bool flag) { EAXJMP(0x420F60); } +#else void CDarkel::RegisterKillByPlayer(int32 modelid, eWeaponType weapontype, bool flag) { } +#endif void CDarkel::RegisterKillNotByPlayer() { @@ -139,49 +147,62 @@ void CDarkel::RegisterKillNotByPlayer() void CDarkel::ResetModelsKilledByPlayer() { - for (int i = 0; i < 200; i++) { - for (int j = 0; j < 8; j++) - RegisteredKills[i + j] = 0; - }; + for (int i = 0; i < 200; i++) + RegisteredKills[i] = 0; } +#if 0 +WRAPPER void CDarkel::ResetOnPlayerDeath() { EAXJMP(0x420E70); } +#else void CDarkel::ResetOnPlayerDeath() { - eWeaponType &EWeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; - int32 &CurrentWeapon = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId; - int32 &CurrentDarkelWeapon = CDarkel::WeaponType; - uint32 &TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; + if (Status != KILLFRENZY_ONGOING) + return; - if (Status == KILLFRENZY_ONGOING) { - CPopulation::m_AllRandomPedsThisType = -1; - Status = KILLFRENZY_FAILED; - TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_FAILED; + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); - if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) - CurrentDarkelWeapon = WEAPONTYPE_UZI; + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + WeaponType = WEAPONTYPE_UZI; - if (CurrentDarkelWeapon < WEAPONTYPE_TOTALWEAPONS) { - FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; - TotalAmmo = AmmoInterruptedWeapon; - } + if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; + } - if (FindPlayerVehicle()) { - FindPlayerPed()->RemoveWeaponModel(CurrentWeapon); - FindPlayerPed()->m_currentWeapon = EWeaponType; - FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); - } + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); + FindPlayerPed()->m_currentWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); + } + + + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_FAILED; + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + WeaponType = WEAPONTYPE_UZI; + + if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; + } + + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); + FindPlayerPed()->m_currentWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); } } +#endif #if 0 WRAPPER void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) { EAXJMP(0x4210E0); } #else void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) { - eWeaponType &EWeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; - uint32 &TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; - uint32 &AmmoInClip = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip; - if (weaponType == WEAPONTYPE_UZI_DRIVEBY) weaponType = WEAPONTYPE_UZI; @@ -210,15 +231,15 @@ void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 if (weaponType < WEAPONTYPE_TOTALWEAPONS) { InterruptedWeapon = FindPlayerPed()->m_currentWeapon; FindPlayerPed()->GiveWeapon(weaponType, 0); - AmmoInterruptedWeapon = TotalAmmo; + AmmoInterruptedWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; FindPlayerPed()->GiveWeapon(weaponType, 30000); - FindPlayerPed()->m_bWeaponSlot = EWeaponType; + FindPlayerPed()->m_bWeaponSlot = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_bWeaponSlot); if (FindPlayerVehicle()) { - FindPlayerPed()->m_currentWeapon = EWeaponType; - if (TotalAmmo <= AmmoInClip) - AmmoInClip = TotalAmmo; + FindPlayerPed()->m_currentWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal <= CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip) + CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; FindPlayerPed()->ClearWeaponTarget(); } @@ -230,76 +251,72 @@ void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 void CDarkel::Update() { - eWeaponType &EWeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; - int32 &CurrentWeapon = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId; - int32 &CurrentDarkelWeapon = CDarkel::WeaponType; - uint32 &TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; + if (Status != KILLFRENZY_ONGOING) + return; - if (Status == KILLFRENZY_ONGOING) { - int32 FrameTime = TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart); - if ((TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)) > 0 || TimeLimit < 0) { - DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_ONGOING, FrameTime); + int32 FrameTime = TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart); + if ((TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)) > 0 || TimeLimit < 0) { + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_ONGOING, FrameTime); - int32 PrevTime = FrameTime / 1000; + int32 PrevTime = FrameTime / 1000; - if (PrevTime != PreviousTime) { - if (PreviousTime < 12) - DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, PrevTime); - PreviousTime = PrevTime; - } + if (PrevTime != PreviousTime) { + if (PreviousTime < 12) + DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, PrevTime); + PreviousTime = PrevTime; + } + } + else { + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_FAILED; + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + WeaponType = WEAPONTYPE_UZI; + + if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; } - else { - CPopulation::m_AllRandomPedsThisType = -1; - Status = KILLFRENZY_FAILED; - TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); - - if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) - CurrentDarkelWeapon = WEAPONTYPE_UZI; - - if (CurrentDarkelWeapon < WEAPONTYPE_TOTALWEAPONS) { - FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; - TotalAmmo = AmmoInterruptedWeapon; - } - - if (FindPlayerVehicle()) { - FindPlayerPed()->RemoveWeaponModel(CurrentWeapon); - FindPlayerPed()->m_currentWeapon = EWeaponType; - FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); - } - - if (bStandardSoundAndMessages) - DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_FAILED, 0); + + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); + FindPlayerPed()->m_currentWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); } - if (KillsNeeded <= 0) { - CPopulation::m_AllRandomPedsThisType = -1; - Status = KILLFRENZY_PASSED; + if (bStandardSoundAndMessages) + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_FAILED, 0); + } - if (bProperKillFrenzy) - CStats::AnotherKillFrenzyPassed(); + if (KillsNeeded <= 0) { + CPopulation::m_AllRandomPedsThisType = -1; + Status = KILLFRENZY_PASSED; - TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); + if (bProperKillFrenzy) + CStats::AnotherKillFrenzyPassed(); - FindPlayerPed()->m_pWanted->SetWantedLevel(NOTWANTED); + TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); - if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) - CurrentDarkelWeapon = WEAPONTYPE_UZI; + FindPlayerPed()->m_pWanted->SetWantedLevel(NOTWANTED); - if (CurrentDarkelWeapon < WEAPONTYPE_TOTALWEAPONS) { - FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; - TotalAmmo = AmmoInterruptedWeapon; - } + if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) + WeaponType = WEAPONTYPE_UZI; - if (FindPlayerVehicle()) { - FindPlayerPed()->RemoveWeaponModel(CurrentWeapon); - FindPlayerPed()->m_currentWeapon = EWeaponType; - FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); - } + if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { + FindPlayerPed()->m_bWeaponSlot = InterruptedWeapon; + CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; + } - if (bStandardSoundAndMessages) - DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_PASSED, 0); + if (FindPlayerVehicle()) { + FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); + FindPlayerPed()->m_currentWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; + FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); } + + if (bStandardSoundAndMessages) + DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_PASSED, 0); } } diff --git a/src/control/Darkel.h b/src/control/Darkel.h index 905f5497..da1df24a 100644 --- a/src/control/Darkel.h +++ b/src/control/Darkel.h @@ -3,7 +3,7 @@ enum eKillFrenzyStatus { - KILLFRENZY_INIT, + KILLFRENZY_NONE, KILLFRENZY_ONGOING, KILLFRENZY_PASSED, KILLFRENZY_FAILED, -- cgit v1.2.3 From 0c34fb1bb2239b1433719bb410b71e0c28840c85 Mon Sep 17 00:00:00 2001 From: _AG Date: Sun, 7 Jul 2019 15:26:55 +0200 Subject: blah --- src/core/Stats.h | 2 +- src/peds/Ped.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core/Stats.h b/src/core/Stats.h index a5670020..30058a59 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -5,7 +5,7 @@ class CStats public: static int32 &DaysPassed; static int32 &HeadShots; - static bool& CommercialPassed; + static bool& CommercialPassed; static int32 &NumberKillFrenziesPassed; static int32 &PeopleKilledByOthers; diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index e4cc848e..016fea2f 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -2702,9 +2702,9 @@ CPed::QuitEnteringCar(void) bUsesCollision = true; if (IsPlayer() && GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI) { - if (IsPlayer() && m_storedWeapon != NO_STORED_WEAPON) { + if (IsPlayer() && m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { SetCurrentWeapon(m_storedWeapon); - m_storedWeapon = NO_STORED_WEAPON; + m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; } } else { CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); -- cgit v1.2.3 From 439f371fc346ca797faf013b4098b52c92a1481e Mon Sep 17 00:00:00 2001 From: _AG Date: Sun, 7 Jul 2019 20:59:49 +0200 Subject: Darkel is bored. --- src/control/Darkel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/control/Darkel.cpp b/src/control/Darkel.cpp index ab55c4d4..f050a540 100644 --- a/src/control/Darkel.cpp +++ b/src/control/Darkel.cpp @@ -34,7 +34,7 @@ int32 CDarkel::CalcFade(uint32 time, int32 start, uint32 end) { if (time >= start && time <= end) { if (time >= start + 500) { if (time <= end - 500) - return 0; + return 255; else return 255 * (end - time) / 500; } @@ -55,6 +55,7 @@ void CDarkel::DrawMessages() switch (Status) { case KILLFRENZY_ONGOING: + assert(pStartMessage != nil); DisplayTimers = true; break; case KILLFRENZY_PASSED: -- cgit v1.2.3