CDarkel, walkaround fix

This commit is contained in:
eray orçunus 2019-10-05 16:44:03 +03:00
parent cf0edb3eb7
commit aa4e7ad5eb
6 changed files with 227 additions and 173 deletions

View File

@ -2,12 +2,12 @@
#include "patcher.h" #include "patcher.h"
#include "main.h" #include "main.h"
#include "Darkel.h" #include "Darkel.h"
#include "PlayerPed.h"
#include "Timer.h" #include "Timer.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "Population.h" #include "Population.h"
#include "Weapon.h" #include "Weapon.h"
#include "World.h" #include "World.h"
#include "PlayerPed.h"
#include "Stats.h" #include "Stats.h"
#include "Font.h" #include "Font.h"
#include "Text.h" #include "Text.h"
@ -19,105 +19,140 @@ int32 &CDarkel::WeaponType = *(int32*)0x9430F0;
int32 &CDarkel::AmmoInterruptedWeapon = *(int32*)0x8E29C8; int32 &CDarkel::AmmoInterruptedWeapon = *(int32*)0x8E29C8;
int32 &CDarkel::KillsNeeded = *(int32*)0x8F1AB8; int32 &CDarkel::KillsNeeded = *(int32*)0x8F1AB8;
int8 &CDarkel::InterruptedWeapon = *(int8*)0x95CD60; int8 &CDarkel::InterruptedWeapon = *(int8*)0x95CD60;
/*
* bStandardSoundAndMessages is a completely beta thing,
* makes game handle sounds & messages instead of SCM (just like in GTA2)
* but it's never been used in the game. Has unused sliding text when frenzy completed etc.
*/
int8 &CDarkel::bStandardSoundAndMessages = *(int8*)0x95CDB6; int8 &CDarkel::bStandardSoundAndMessages = *(int8*)0x95CDB6;
int8 &CDarkel::bNeedHeadShot = *(int8*)0x95CDCA; int8 &CDarkel::bNeedHeadShot = *(int8*)0x95CDCA;
int8 &CDarkel::bProperKillFrenzy = *(int8*)0x95CD98; int8 &CDarkel::bProperKillFrenzy = *(int8*)0x95CD98;
eKillFrenzyStatus &CDarkel::Status = *(eKillFrenzyStatus*)0x95CCB4; eKillFrenzyStatus &CDarkel::Status = *(eKillFrenzyStatus*)0x95CCB4;
int16 *CDarkel::RegisteredKills = (int16*)0x6EDBE0; uint16 (&CDarkel::RegisteredKills)[NUMDEFAULTMODELS] = *(uint16(*)[NUMDEFAULTMODELS]) * (uintptr*)0x6EDBE0;
int32 &CDarkel::ModelToKill = *(int32*)0x8F2C78; int32 &CDarkel::ModelToKill = *(int32*)0x8F2C78;
int32 &CDarkel::ModelToKill2 = *(int32*)0x885B40; int32 &CDarkel::ModelToKill2 = *(int32*)0x885B40;
int32 &CDarkel::ModelToKill3 = *(int32*)0x885B3C; int32 &CDarkel::ModelToKill3 = *(int32*)0x885B3C;
int32 &CDarkel::ModelToKill4 = *(int32*)0x885B34; int32 &CDarkel::ModelToKill4 = *(int32*)0x885B34;
wchar *CDarkel::pStartMessage = (wchar*)0x8F2C08; wchar *CDarkel::pStartMessage = (wchar*)0x8F2C08;
int32 CDarkel::CalcFade(uint32 time, int32 start, uint32 end) { uint8
CDarkel::CalcFade(uint32 time, uint32 start, uint32 end)
{
if (time >= start && time <= end) { if (time >= start && time <= end) {
if (time >= start + 500) { if (time >= start + 500) {
if (time <= end - 500) if (time <= end - 500)
return 255; return 255;
else else
return 255 * (end - time) / 500; return 255 * (end - time) / 500;
} } else
else
return 255 * (time - start) / 500; return 255 * (time - start) / 500;
} } else
else
return 0; return 0;
} }
// This function has been cleaned up from unused stuff. // Screen positions taken from VC
#if 0 void
WRAPPER void CDarkel::DrawMessages(void) { EAXJMP(0x420920); } CDarkel::DrawMessages()
#else
void CDarkel::DrawMessages()
{ {
bool DisplayTimers = false;
switch (Status) { switch (Status) {
case KILLFRENZY_ONGOING: case KILLFRENZY_ONGOING:
assert(pStartMessage != nil); {
DisplayTimers = true; CFont::SetJustifyOff();
break;
case KILLFRENZY_PASSED:
case KILLFRENZY_FAILED:
DisplayTimers = false;
break;
};
if (DisplayTimers) {
CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetBackGroundOnlyTextOn(); CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(30.0f));
CFont::SetAlignment(ALIGN_RIGHT); CFont::SetCentreOn();
CFont::SetRightJustifyWrap(-SCREEN_WIDTH); CFont::SetPropOn();
CFont::SetFontStyle(FONT_HEADING); uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart;
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); if (CDarkel::bStandardSoundAndMessages) {
if (timePassedSinceStart >= 3000 && timePassedSinceStart < 11000) {
float AlignToHUD = SCREEN_SCALE_X(-10.0f); CFont::SetScale(SCREEN_SCALE_X(1.3f), SCREEN_SCALE_Y(1.3f));
int32 a = (TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)); CFont::SetJustifyOff();
if (CTimer::GetFrameCounter() & 8 || a > 4000) { CFont::SetColor(CRGBA(255, 255, 128, CalcFade(timePassedSinceStart, 3000, 11000)));
sprintf(gString, "%d:%02d", a / 60000, a % 60000 / 1000); CFont::SetFontStyle(FONT_BANK);
AsciiToUnicode(gString, gUString); if (pStartMessage) {
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, pStartMessage);
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) } else {
KillsNeeded = 0; if (timePassedSinceStart < 8000) {
CFont::SetScale(SCREEN_SCALE_X(1.3f), SCREEN_SCALE_Y(1.3f));
sprintf((char *)gString, "%d", KillsNeeded); CFont::SetJustifyOff();
CFont::SetColor(CRGBA(255, 255, 128, CalcFade(timePassedSinceStart, 0, 8000)));
CFont::SetFontStyle(FONT_BANK);
if (pStartMessage) {
CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, pStartMessage);
}
}
}
CFont::SetScale(SCREEN_SCALE_X(0.75f), SCREEN_SCALE_Y(1.5f));
CFont::SetCentreOff();
CFont::SetRightJustifyOn();
CFont::SetFontStyle(FONT_HEADING);
if (CDarkel::TimeLimit >= 0) {
uint32 timeLeft = CDarkel::TimeLimit - (CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart);
sprintf(gString, "%d:%02d", timeLeft / 60000, timeLeft % 60000 / 1000);
AsciiToUnicode(gString, gUString); AsciiToUnicode(gString, gUString);
if (timeLeft > 4000 || CTimer::GetFrameCounter() & 1) {
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(25.0f) + AlignToHUD, SCREEN_SCALE_Y(134.0f), gUString); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(109.0f), gUString);
CFont::SetColor(CRGBA(150, 100, 255, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f), SCREEN_SCALE_Y(108.0f), gUString);
}
}
sprintf(gString, "%d", (CDarkel::KillsNeeded >= 0 ? CDarkel::KillsNeeded : 0));
AsciiToUnicode(gString, gUString);
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(35.0f), SCREEN_SCALE_Y(144.0f), gUString);
CFont::SetColor(CRGBA(255, 128, 128, 255)); CFont::SetColor(CRGBA(255, 128, 128, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) + AlignToHUD, SCREEN_SCALE_Y(132.0f), gUString); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(34.0f), SCREEN_SCALE_Y(143.0f), gUString);
break;
}
case KILLFRENZY_PASSED:
{
if (CDarkel::bStandardSoundAndMessages) {
uint32 timePassedSinceStart = CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart;
if (CTimer::GetTimeInMilliseconds() - CDarkel::TimeOfFrenzyStart < 5000) {
CFont::SetBackgroundOff();
CFont::SetCentreSize(SCREEN_SCALE_FROM_RIGHT(20.0f));
CFont::SetCentreOn();
CFont::SetScale(SCREEN_SCALE_X(1.5f), SCREEN_SCALE_Y(1.5f));
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(128, 255, 128, CalcFade(timePassedSinceStart, 0, 5000)));
CFont::SetFontStyle(FONT_BANK);
int y = SCREEN_HEIGHT / 2 + SCREEN_SCALE_Y(25.0f - timePassedSinceStart * 0.01f);
CFont::PrintString(SCREEN_WIDTH / 2, y, TheText.Get("KF_3"));
}
}
break;
}
default:
break;
} }
} }
#endif
void CDarkel::Init() void
CDarkel::Init()
{ {
Status = KILLFRENZY_NONE; Status = KILLFRENZY_NONE;
} }
int16 CDarkel::QueryModelsKilledByPlayer(int32 modelId) uint16
CDarkel::QueryModelsKilledByPlayer(int32 modelId)
{ {
return RegisteredKills[modelId]; return RegisteredKills[modelId];
} }
bool CDarkel::FrenzyOnGoing() bool
CDarkel::FrenzyOnGoing()
{ {
return Status == KILLFRENZY_ONGOING; return Status == KILLFRENZY_ONGOING;
} }
eKillFrenzyStatus CDarkel::ReadStatus() uint16
CDarkel::ReadStatus()
{ {
return Status; return Status;
} }
@ -141,21 +176,24 @@ void CDarkel::RegisterKillByPlayer(CPed *victim, eWeaponType weapontype, bool he
} }
#endif #endif
void CDarkel::RegisterKillNotByPlayer(CPed* victim, eWeaponType weapontype) void
CDarkel::RegisterKillNotByPlayer(CPed* victim, eWeaponType weapontype)
{ {
++CStats::NumberKillFrenziesPassed; ++CStats::PeopleKilledByOthers;
} }
void CDarkel::ResetModelsKilledByPlayer() void
CDarkel::ResetModelsKilledByPlayer()
{ {
for (int i = 0; i < 200; i++) for (int i = 0; i < NUMDEFAULTMODELS; i++)
RegisteredKills[i] = 0; RegisteredKills[i] = 0;
} }
#if 0 #if 0
WRAPPER void CDarkel::ResetOnPlayerDeath() { EAXJMP(0x420E70); } WRAPPER void CDarkel::ResetOnPlayerDeath() { EAXJMP(0x420E70); }
#else #else
void CDarkel::ResetOnPlayerDeath() void
CDarkel::ResetOnPlayerDeath()
{ {
if (Status != KILLFRENZY_ONGOING) if (Status != KILLFRENZY_ONGOING)
return; return;
@ -164,48 +202,37 @@ void CDarkel::ResetOnPlayerDeath()
Status = KILLFRENZY_FAILED; Status = KILLFRENZY_FAILED;
TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds();
eWeaponType fixedWeapon;
if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) if (WeaponType == WEAPONTYPE_UZI_DRIVEBY)
WeaponType = WEAPONTYPE_UZI; fixedWeapon = WEAPONTYPE_UZI;
else
fixedWeapon = (eWeaponType)WeaponType;
if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { CPlayerPed *player = FindPlayerPed();
FindPlayerPed()->m_nSelectedWepSlot = InterruptedWeapon; if (fixedWeapon < WEAPONTYPE_TOTALWEAPONS) {
CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; player->m_nSelectedWepSlot = InterruptedWeapon;
player->GetWeapon(player->GetWeaponSlot(fixedWeapon)).m_nAmmoTotal = CDarkel::AmmoInterruptedWeapon;
} }
if (FindPlayerVehicle()) { if (FindPlayerVehicle()) {
FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); player->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(player->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; player->m_currentWeapon = player->m_nSelectedWepSlot;
FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); player->MakeChangesForNewWeapon(player->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_nSelectedWepSlot = 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 #endif
#if 0 #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); } WRAPPER void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) { EAXJMP(0x4210E0); }
#else #else
void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot) void
CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot)
{ {
eWeaponType fixedWeapon;
if (weaponType == WEAPONTYPE_UZI_DRIVEBY) if (weaponType == WEAPONTYPE_UZI_DRIVEBY)
weaponType = WEAPONTYPE_UZI; fixedWeapon = WEAPONTYPE_UZI;
else
fixedWeapon = weaponType;
WeaponType = weaponType; WeaponType = weaponType;
Status = KILLFRENZY_ONGOING; Status = KILLFRENZY_ONGOING;
@ -219,8 +246,7 @@ void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32
if (text == TheText.Get("PAGE_00")) { if (text == TheText.Get("PAGE_00")) {
CDarkel::bProperKillFrenzy = 1; CDarkel::bProperKillFrenzy = 1;
CDarkel::pStartMessage = 0; CDarkel::pStartMessage = 0;
} } else
else
bProperKillFrenzy = 0; bProperKillFrenzy = 0;
bStandardSoundAndMessages = standardSound; bStandardSoundAndMessages = standardSound;
@ -229,20 +255,19 @@ void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32
TimeLimit = time; TimeLimit = time;
PreviousTime = time / 1000; PreviousTime = time / 1000;
if (weaponType < WEAPONTYPE_TOTALWEAPONS) { CPlayerPed *player = FindPlayerPed();
InterruptedWeapon = FindPlayerPed()->m_currentWeapon; if (fixedWeapon < WEAPONTYPE_TOTALWEAPONS) {
FindPlayerPed()->GiveWeapon(weaponType, 0); InterruptedWeapon = player->m_currentWeapon;
AmmoInterruptedWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal; player->GiveWeapon(fixedWeapon, 0);
FindPlayerPed()->GiveWeapon(weaponType, 30000); AmmoInterruptedWeapon = player->GetWeapon(player->GetWeaponSlot(fixedWeapon)).m_nAmmoTotal;
FindPlayerPed()->m_nSelectedWepSlot = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; player->GiveWeapon(fixedWeapon, 30000);
FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_nSelectedWepSlot); player->m_nSelectedWepSlot = player->GetWeaponSlot(fixedWeapon);
player->MakeChangesForNewWeapon(player->m_nSelectedWepSlot);
if (FindPlayerVehicle()) { if (FindPlayerVehicle()) {
FindPlayerPed()->m_currentWeapon = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType; player->m_currentWeapon = player->m_nSelectedWepSlot;
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) player->GetWeapon()->m_nAmmoInClip = min(player->GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(player->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
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; player->ClearWeaponTarget();
FindPlayerPed()->ClearWeaponTarget();
} }
} }
if (CDarkel::bStandardSoundAndMessages) if (CDarkel::bStandardSoundAndMessages)
@ -250,13 +275,15 @@ void CDarkel::StartFrenzy(eWeaponType weaponType, int32 time, int16 kill, int32
} }
#endif #endif
void CDarkel::Update() void
CDarkel::Update()
{ {
if (Status != KILLFRENZY_ONGOING) if (Status != KILLFRENZY_ONGOING)
return; return;
int32 FrameTime = TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart); int32 FrameTime = TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart);
if ((TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)) > 0 || TimeLimit < 0) { if ((TimeLimit - (CTimer::GetTimeInMilliseconds() - TimeOfFrenzyStart)) > 0 || TimeLimit < 0) {
DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_ONGOING, FrameTime); DMAudio.PlayFrontEndSound(SOUND_RAMPAGE_ONGOING, FrameTime);
int32 PrevTime = FrameTime / 1000; int32 PrevTime = FrameTime / 1000;
@ -267,24 +294,27 @@ void CDarkel::Update()
PreviousTime = PrevTime; PreviousTime = PrevTime;
} }
} } else {
else {
CPopulation::m_AllRandomPedsThisType = -1; CPopulation::m_AllRandomPedsThisType = -1;
Status = KILLFRENZY_FAILED; Status = KILLFRENZY_FAILED;
TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds(); TimeOfFrenzyStart = CTimer::GetTimeInMilliseconds();
eWeaponType fixedWeapon;
if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) if (WeaponType == WEAPONTYPE_UZI_DRIVEBY)
WeaponType = WEAPONTYPE_UZI; fixedWeapon = WEAPONTYPE_UZI;
else
fixedWeapon = (eWeaponType)WeaponType;
if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { CPlayerPed *player = FindPlayerPed();
FindPlayerPed()->m_nSelectedWepSlot = InterruptedWeapon; if (fixedWeapon < WEAPONTYPE_TOTALWEAPONS) {
CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; player->m_nSelectedWepSlot = InterruptedWeapon;
player->GetWeapon(player->GetWeaponSlot(fixedWeapon)).m_nAmmoTotal = CDarkel::AmmoInterruptedWeapon;
} }
if (FindPlayerVehicle()) { if (FindPlayerVehicle()) {
FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); player->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(player->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; player->m_currentWeapon = player->m_nSelectedWepSlot;
FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); player->MakeChangesForNewWeapon(player->m_currentWeapon);
} }
if (bStandardSoundAndMessages) if (bStandardSoundAndMessages)
@ -302,18 +332,22 @@ void CDarkel::Update()
FindPlayerPed()->m_pWanted->SetWantedLevel(0); FindPlayerPed()->m_pWanted->SetWantedLevel(0);
eWeaponType fixedWeapon;
if (WeaponType == WEAPONTYPE_UZI_DRIVEBY) if (WeaponType == WEAPONTYPE_UZI_DRIVEBY)
WeaponType = WEAPONTYPE_UZI; fixedWeapon = WEAPONTYPE_UZI;
else
fixedWeapon = (eWeaponType)WeaponType;
if (WeaponType < WEAPONTYPE_TOTALWEAPONS) { CPlayerPed* player = FindPlayerPed();
FindPlayerPed()->m_nSelectedWepSlot = InterruptedWeapon; if (fixedWeapon < WEAPONTYPE_TOTALWEAPONS) {
CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal = AmmoInterruptedWeapon; player->m_nSelectedWepSlot = InterruptedWeapon;
player->GetWeapon(player->GetWeaponSlot(fixedWeapon)).m_nAmmoTotal = CDarkel::AmmoInterruptedWeapon;
} }
if (FindPlayerVehicle()) { if (FindPlayerVehicle()) {
FindPlayerPed()->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nModelId); player->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(player->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; player->m_currentWeapon = player->m_nSelectedWepSlot;
FindPlayerPed()->MakeChangesForNewWeapon(FindPlayerPed()->m_currentWeapon); player->MakeChangesForNewWeapon(player->m_currentWeapon);
} }
if (bStandardSoundAndMessages) if (bStandardSoundAndMessages)
@ -322,17 +356,17 @@ void CDarkel::Update()
} }
STARTPATCHES STARTPATCHES
/*InjectHook(0x421380, CDarkel::CalcFade, PATCH_JUMP); 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(0x420650, CDarkel::Init, PATCH_JUMP);
InjectHook(0x421370, CDarkel::QueryModelsKilledByPlayer, PATCH_JUMP); InjectHook(0x420660, CDarkel::Update, PATCH_JUMP);
InjectHook(0x420E60, CDarkel::FrenzyOnGoing, PATCH_JUMP);
InjectHook(0x420E50, CDarkel::ReadStatus, 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(0x420E70, CDarkel::ResetOnPlayerDeath, PATCH_JUMP);
InjectHook(0x4210E0, CDarkel::StartFrenzy, PATCH_JUMP); InjectHook(0x4210E0, CDarkel::StartFrenzy, PATCH_JUMP);
InjectHook(0x420660, CDarkel::Update, PATCH_JUMP);*/ InjectHook(0x421370, CDarkel::QueryModelsKilledByPlayer, PATCH_JUMP);
InjectHook(0x421060, CDarkel::RegisterKillNotByPlayer, PATCH_JUMP);
InjectHook(0x421310, CDarkel::ResetModelsKilledByPlayer, PATCH_JUMP);
InjectHook(0x420920, CDarkel::DrawMessages, PATCH_JUMP);
//InjectHook(0x421070, CDarkel::RegisterCarBlownUpByPlayer, PATCH_JUMP);
//InjectHook(0x420F60, CDarkel::RegisterKillByPlayer, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View File

@ -26,7 +26,7 @@ private:
static int8 &bNeedHeadShot; static int8 &bNeedHeadShot;
static int8 &bProperKillFrenzy; static int8 &bProperKillFrenzy;
static eKillFrenzyStatus &Status; static eKillFrenzyStatus &Status;
static int16 *RegisteredKills; static uint16 (&RegisteredKills)[NUMDEFAULTMODELS];
static int32 &ModelToKill; static int32 &ModelToKill;
static int32 &ModelToKill2; static int32 &ModelToKill2;
static int32 &ModelToKill3; static int32 &ModelToKill3;
@ -34,18 +34,18 @@ private:
static wchar *pStartMessage; static wchar *pStartMessage;
public: public:
static int32 CalcFade(uint32 time, int32 min, uint32 max); static uint8 CalcFade(uint32 time, uint32 min, uint32 max);
static void DrawMessages(void); static void DrawMessages(void);
static bool FrenzyOnGoing(); static bool FrenzyOnGoing();
static void Init(); static void Init();
static int16 QueryModelsKilledByPlayer(int32 modelId); static uint16 QueryModelsKilledByPlayer(int32 modelId);
static eKillFrenzyStatus ReadStatus(); static uint16 ReadStatus();
static void RegisterCarBlownUpByPlayer(CVehicle *vehicle); static void RegisterCarBlownUpByPlayer(CVehicle *vehicle);
static void RegisterKillByPlayer(CPed *victim, eWeaponType weapontype, bool headshot = false); static void RegisterKillByPlayer(CPed *victim, eWeaponType weapontype, bool headshot = false);
static void RegisterKillNotByPlayer(CPed* victim, eWeaponType weapontype); static void RegisterKillNotByPlayer(CPed* victim, eWeaponType weapontype);
static void ResetModelsKilledByPlayer(); static void ResetModelsKilledByPlayer();
static void ResetOnPlayerDeath(); 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 StartFrenzy(eWeaponType weaponType, int32 time, uint16 kill, int32 modelId0, wchar *text, int32 modelId2, int32 modelId3, int32 modelId4, bool standardSound, bool needHeadShot);
static void Update(); static void Update();
}; };

View File

@ -1021,7 +1021,7 @@ CStreaming::RemoveAllUnusedModels(void)
for(i = 0; i < MAXVEHICLESLOADED; i++) for(i = 0; i < MAXVEHICLESLOADED; i++)
RemoveLoadedVehicle(); RemoveLoadedVehicle();
for(i = NUM_DEFAULT_MODELS; i < MODELINFOSIZE; i++){ for(i = NUMDEFAULTMODELS; i < MODELINFOSIZE; i++){
if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED && if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED &&
ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE && ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE &&
CModelInfo::GetModelInfo(i)->m_refCount == 0){ CModelInfo::GetModelInfo(i)->m_refCount == 0){
@ -2408,8 +2408,8 @@ CStreaming::MemoryCardSave(uint8 *buffer, uint32 *length)
{ {
int i; int i;
*length = NUM_DEFAULT_MODELS; *length = NUMDEFAULTMODELS;
for(i = 0; i < NUM_DEFAULT_MODELS; i++) for(i = 0; i < NUMDEFAULTMODELS; i++)
if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED) if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED)
buffer[i] = ms_aInfoForModel[i].m_flags; buffer[i] = ms_aInfoForModel[i].m_flags;
else else
@ -2421,7 +2421,7 @@ CStreaming::MemoryCardLoad(uint8 *buffer, uint32 length)
{ {
uint32 i; uint32 i;
assert(length == NUM_DEFAULT_MODELS); assert(length == NUMDEFAULTMODELS);
for(i = 0; i < length; i++) for(i = 0; i < length; i++)
if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED) if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED)
if(buffer[i] != 0xFF) if(buffer[i] != 0xFF)

View File

@ -32,6 +32,7 @@ enum Config {
NUMDUMMIES = 2802, // 2368 on PS2 NUMDUMMIES = 2802, // 2368 on PS2
NUMAUDIOSCRIPTOBJECTS = 256, NUMAUDIOSCRIPTOBJECTS = 256,
NUMCUTSCENEOBJECTS = 50, NUMCUTSCENEOBJECTS = 50,
NUMDEFAULTMODELS = 200,
NUMTEMPOBJECTS = 30, NUMTEMPOBJECTS = 30,
@ -138,11 +139,25 @@ enum Config {
#endif #endif
#define FIX_BUGS // fix bugs in the game, TODO: use this more #define FIX_BUGS // fix bugs in the game, TODO: use this more
// Pad
#define KANGAROO_CHEAT #define KANGAROO_CHEAT
// Hud
#define ASPECT_RATIO_SCALE #define ASPECT_RATIO_SCALE
// Script
#define USE_DEBUG_SCRIPT_LOADER #define USE_DEBUG_SCRIPT_LOADER
// Vehicles
#define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher #define EXPLODING_AIRTRAIN // can blow up jumbo jet with rocket launcher
#define ANIMATE_PED_COL_MODEL
//#define REMOVE_TREADABLE_PATHFIND //#define REMOVE_TREADABLE_PATHFIND
#define VC_PED_PORTS
// Pickups
//#define MONEY_MESSAGES //#define MONEY_MESSAGES
// Peds
#define ANIMATE_PED_COL_MODEL
#define VC_PED_PORTS
#define NEW_WALK_AROUND_ALGORITHM
#define CANCELLABLE_CAR_ENTER

View File

@ -352,8 +352,6 @@ enum
MI_AIRTRAIN_VLO = 198, MI_AIRTRAIN_VLO = 198,
MI_LOPOLYGUY, MI_LOPOLYGUY,
NUM_DEFAULT_MODELS,
}; };
enum{ enum{

View File

@ -69,9 +69,6 @@ WRAPPER void CPed::SetExitCar(CVehicle*, uint32) { EAXJMP(0x4E1010); }
#define FEET_OFFSET 1.04f #define FEET_OFFSET 1.04f
#define NEW_WALK_AROUND_ALGORITHM
#define CANCELLABLE_CAR_ENTER
CPed *gapTempPedList[50]; CPed *gapTempPedList[50];
uint16 gnNumTempPedList; uint16 gnNumTempPedList;
@ -13506,19 +13503,29 @@ CPed::SetExitTrain(CVehicle* train)
#ifdef NEW_WALK_AROUND_ALGORITHM #ifdef NEW_WALK_AROUND_ALGORITHM
CVector CVector
LocalPosForWalkAround(CVector2D colMin, CVector2D colMax, int walkAround) { LocalPosForWalkAround(CVector2D colMin, CVector2D colMax, int walkAround, uint32 enterDoorNode, bool itsVan) {
switch (walkAround) { switch (walkAround) {
case 0: case 0:
if (enterDoorNode == CAR_DOOR_LF)
return CVector(colMin.x, colMax.y - 1.0f, 0.0f);
case 1: case 1:
return CVector(colMin.x, colMax.y, 0.0f); return CVector(colMin.x, colMax.y, 0.0f);
case 2: case 2:
case 3: case 3:
if (walkAround == 3 && enterDoorNode == CAR_DOOR_RF)
return CVector(colMax.x, colMax.y - 1.0f, 0.0f);
return CVector(colMax.x, colMax.y, 0.0f); return CVector(colMax.x, colMax.y, 0.0f);
case 4: case 4:
if (enterDoorNode == CAR_DOOR_RR && !itsVan)
return CVector(colMax.x, colMin.y + 1.0f, 0.0f);
case 5: case 5:
return CVector(colMax.x, colMin.y, 0.0f); return CVector(colMax.x, colMin.y, 0.0f);
case 6: case 6:
case 7: case 7:
if (walkAround == 7 && enterDoorNode == CAR_DOOR_LR && !itsVan)
return CVector(colMin.x, colMin.y + 1.0f, 0.0f);
return CVector(colMin.x, colMin.y, 0.0f); return CVector(colMin.x, colMin.y, 0.0f);
default: default:
return CVector(0.0f, 0.0f, 0.0f); return CVector(0.0f, 0.0f, 0.0f);
@ -13537,8 +13544,8 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
CVector objColCenter = (objColMin + objColMax) / 2.0f; CVector objColCenter = (objColMin + objColMax) / 2.0f;
CMatrix objMat(obj->GetMatrix()); CMatrix objMat(obj->GetMatrix());
float dirToSet = obj->GetForward().Heading(); float dirToSet = obj->GetForward().Heading();
bool objIsSeekTargetAndVan = false; bool goingToEnterCarAndItsVan = false;
bool objIsSeekTarget = false; bool goingToEnterCar = false;
bool objUpsideDown = false; bool objUpsideDown = false;
float checkIntervalInDist = (objColMax.y - objColMin.y) * 0.1f; float checkIntervalInDist = (objColMax.y - objColMin.y) * 0.1f;
@ -13620,12 +13627,12 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
if (m_pSeekTarget == obj && obj->IsVehicle()) { if (m_pSeekTarget == obj && obj->IsVehicle()) {
if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER if (m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER
|| m_objective == OBJECTIVE_SOLICIT) { || m_objective == OBJECTIVE_SOLICIT) {
objIsSeekTarget = true; goingToEnterCar = true;
if (IsPlayer()) if (IsPlayer())
checkIntervalInTime = 0.0f; checkIntervalInTime = 0.0f;
if (((CVehicle*)obj)->bIsVan) if (((CVehicle*)obj)->bIsVan)
objIsSeekTargetAndVan = true; goingToEnterCarAndItsVan = true;
} }
} }
@ -13671,7 +13678,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
else { else {
CVector tl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMax.y, 0.0f) - GetPosition(); CVector tl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMax.y, 0.0f) - GetPosition();
cornerToGo = tl; cornerToGo = tl;
if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) { if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) {
m_walkAroundType = 1; m_walkAroundType = 1;
} else { } else {
dirToGo = GetLocalDirection(tl); dirToGo = GetLocalDirection(tl);
@ -13705,7 +13712,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
CVector tr = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMax.y, 0.0f) - GetPosition(); CVector tr = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMax.y, 0.0f) - GetPosition();
if (tr.Magnitude2D() < cornerToGo.Magnitude2D()) { if (tr.Magnitude2D() < cornerToGo.Magnitude2D()) {
cornerToGo = tr; cornerToGo = tr;
if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) { if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) {
m_walkAroundType = 2; m_walkAroundType = 2;
} else { } else {
dirToGo = GetLocalDirection(tr); dirToGo = GetLocalDirection(tr);
@ -13740,7 +13747,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
CVector br = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMin.y, 0.0f) - GetPosition(); CVector br = obj->GetMatrix() * CVector(adjustedColMax.x, adjustedColMin.y, 0.0f) - GetPosition();
if (br.Magnitude2D() < cornerToGo.Magnitude2D()) { if (br.Magnitude2D() < cornerToGo.Magnitude2D()) {
cornerToGo = br; cornerToGo = br;
if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) { if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) {
m_walkAroundType = 5; m_walkAroundType = 5;
} else { } else {
dirToGo = GetLocalDirection(br); dirToGo = GetLocalDirection(br);
@ -13775,7 +13782,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
CVector bl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMin.y, 0.0f) - GetPosition(); CVector bl = obj->GetMatrix() * CVector(adjustedColMin.x, adjustedColMin.y, 0.0f) - GetPosition();
if (bl.Magnitude2D() < cornerToGo.Magnitude2D()) { if (bl.Magnitude2D() < cornerToGo.Magnitude2D()) {
cornerToGo = bl; cornerToGo = bl;
if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) { if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) {
m_walkAroundType = 6; m_walkAroundType = 6;
} else { } else {
dirToGo = GetLocalDirection(bl); dirToGo = GetLocalDirection(bl);
@ -13803,7 +13810,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
if (Abs(angleDiffBtwObjCenterAndForward) >= objTopRightHeading) { if (Abs(angleDiffBtwObjCenterAndForward) >= objTopRightHeading) {
if (PI - objTopRightHeading >= Abs(angleDiffBtwObjCenterAndForward)) { if (PI - objTopRightHeading >= Abs(angleDiffBtwObjCenterAndForward)) {
if ((angleDiffBtwObjCenterAndForward <= 0.0f || objUpsideDown) && (angleDiffBtwObjCenterAndForward < 0.0f || !objUpsideDown)) { if ((angleDiffBtwObjCenterAndForward <= 0.0f || objUpsideDown) && (angleDiffBtwObjCenterAndForward < 0.0f || !objUpsideDown)) {
if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) { if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_RF || m_vehEnterType == CAR_DOOR_RR)) {
m_walkAroundType = 0; m_walkAroundType = 0;
} else { } else {
if (CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) >= 0.0f) { if (CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) >= 0.0f) {
@ -13821,7 +13828,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} }
} }
} else { } else {
if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) { if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)) {
m_walkAroundType = 0; m_walkAroundType = 0;
} else { } else {
if (CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) <= 0.0f) { if (CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) <= 0.0f) {
@ -13839,7 +13846,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} }
} }
} }
} else if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) } else if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)
|| CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) < 0.0f) { || CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) < 0.0f) {
if (entityOnTopLeftOfObj == 1 || entityOnTopLeftOfObj && !entityOnTopRightOfObj && !entityOnBottomRightOfObj) { if (entityOnTopLeftOfObj == 1 || entityOnTopLeftOfObj && !entityOnTopRightOfObj && !entityOnBottomRightOfObj) {
m_walkAroundType = 3; m_walkAroundType = 3;
@ -13847,7 +13854,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} else if (entityOnTopRightOfObj == 1 || entityOnTopRightOfObj && !entityOnTopLeftOfObj && !entityOnBottomLeftOfObj) { } else if (entityOnTopRightOfObj == 1 || entityOnTopRightOfObj && !entityOnTopLeftOfObj && !entityOnBottomLeftOfObj) {
m_walkAroundType = 4; m_walkAroundType = 4;
} }
} else if (objIsSeekTarget && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR) } else if (goingToEnterCar && (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR)
|| CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) > 0.0f) { || CGeneral::LimitRadianAngle(m_fRotationDest - angleToFaceObjCenter) > 0.0f) {
if (entityOnBottomLeftOfObj == 1 || entityOnBottomLeftOfObj && !entityOnTopRightOfObj && !entityOnBottomRightOfObj) { if (entityOnBottomLeftOfObj == 1 || entityOnBottomLeftOfObj && !entityOnTopRightOfObj && !entityOnBottomRightOfObj) {
m_walkAroundType = 2; m_walkAroundType = 2;
@ -13880,13 +13887,13 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
nextWalkAround = 7; nextWalkAround = 7;
} }
CVector nextPosToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, nextWalkAround); CVector nextPosToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, nextWalkAround, goingToEnterCar ? m_vehEnterType : 0, goingToEnterCarAndItsVan);
bool nextRouteIsClear = CWorld::GetIsLineOfSightClear(GetPosition(), nextPosToHead, true, true, true, true, true, true, false); bool nextRouteIsClear = CWorld::GetIsLineOfSightClear(GetPosition(), nextPosToHead, true, true, true, true, true, true, false);
if(nextRouteIsClear) if(nextRouteIsClear)
m_walkAroundType = nextWalkAround; m_walkAroundType = nextWalkAround;
else { else {
CVector posToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType); CVector posToHead = objMat * LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType, goingToEnterCar ? m_vehEnterType : 0, goingToEnterCarAndItsVan);
bool currentRouteIsClear = CWorld::GetIsLineOfSightClear(GetPosition(), posToHead, bool currentRouteIsClear = CWorld::GetIsLineOfSightClear(GetPosition(), posToHead,
true, true, true, true, true, true, false); true, true, true, true, true, true, false);
@ -13916,11 +13923,11 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} }
} }
localPosToHead = LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType); localPosToHead = LocalPosForWalkAround(adjustedColMin, adjustedColMax, m_walkAroundType, goingToEnterCar ? m_vehEnterType : 0, goingToEnterCarAndItsVan);
#else #else
if (Abs(angleDiffBtwObjCenterAndForward) < objTopRightHeading) { if (Abs(angleDiffBtwObjCenterAndForward) < objTopRightHeading) {
if (objIsSeekTarget) { if (goingToEnterCar) {
if (objIsSeekTargetAndVan) { if (goingToEnterCarAndItsVan) {
if (m_vehEnterType == CAR_DOOR_LR || m_vehEnterType == CAR_DOOR_RR) if (m_vehEnterType == CAR_DOOR_LR || m_vehEnterType == CAR_DOOR_RR)
return; return;
} }
@ -13953,9 +13960,9 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} else { } else {
if (PI - objTopRightHeading >= Abs(angleDiffBtwObjCenterAndForward)) { if (PI - objTopRightHeading >= Abs(angleDiffBtwObjCenterAndForward)) {
if (angleDiffBtwObjCenterAndForward <= 0.0f) { if (angleDiffBtwObjCenterAndForward <= 0.0f) {
if (!objIsSeekTarget || !objIsSeekTargetAndVan || m_vehEnterType != CAR_DOOR_LR && m_vehEnterType != CAR_DOOR_RR) { if (!goingToEnterCar || !goingToEnterCarAndItsVan || m_vehEnterType != CAR_DOOR_LR && m_vehEnterType != CAR_DOOR_RR) {
if (objIsSeekTarget) { if (goingToEnterCar) {
if (m_vehEnterType == CAR_DOOR_RF || (m_vehEnterType == CAR_DOOR_RR && !objIsSeekTargetAndVan)) if (m_vehEnterType == CAR_DOOR_RF || (m_vehEnterType == CAR_DOOR_RR && !goingToEnterCarAndItsVan))
return; return;
} }
if (m_walkAroundType == 4 || m_walkAroundType == 3 if (m_walkAroundType == 4 || m_walkAroundType == 3
@ -13977,14 +13984,14 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
localPosToHead.z = 0.0f; localPosToHead.z = 0.0f;
localPosToHead.y = adjustedColMin.y; localPosToHead.y = adjustedColMin.y;
} }
} else if (objIsSeekTarget && objIsSeekTargetAndVan && (m_vehEnterType == CAR_DOOR_LR || m_vehEnterType == CAR_DOOR_RR)) { } else if (goingToEnterCar && goingToEnterCarAndItsVan && (m_vehEnterType == CAR_DOOR_LR || m_vehEnterType == CAR_DOOR_RR)) {
m_fRotationDest = CGeneral::LimitRadianAngle(PI + dirToSet); m_fRotationDest = CGeneral::LimitRadianAngle(PI + dirToSet);
localPosToHead.x = adjustedColMin.x; localPosToHead.x = adjustedColMin.x;
localPosToHead.z = 0.0f; localPosToHead.z = 0.0f;
localPosToHead.y = adjustedColMin.y; localPosToHead.y = adjustedColMin.y;
} else { } else {
if (objIsSeekTarget) { if (goingToEnterCar) {
if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR && !objIsSeekTargetAndVan) if (m_vehEnterType == CAR_DOOR_LF || m_vehEnterType == CAR_DOOR_LR && !goingToEnterCarAndItsVan)
return; return;
} }
if (m_walkAroundType == 1 || m_walkAroundType == 2 if (m_walkAroundType == 1 || m_walkAroundType == 2
@ -14002,7 +14009,7 @@ CPed::SetDirectionToWalkAroundObject(CEntity *obj)
} }
} }
} else { } else {
if (objIsSeekTarget && (!objIsSeekTargetAndVan || m_vehEnterType != CAR_DOOR_LR && m_vehEnterType != CAR_DOOR_RR)) { if (goingToEnterCar && (!goingToEnterCarAndItsVan || m_vehEnterType != CAR_DOOR_LR && m_vehEnterType != CAR_DOOR_RR)) {
if (m_vehEnterType != CAR_DOOR_LF && m_vehEnterType != CAR_DOOR_LR && (!entityOnTopRightOfObj || entityOnTopLeftOfObj)) { if (m_vehEnterType != CAR_DOOR_LF && m_vehEnterType != CAR_DOOR_LR && (!entityOnTopRightOfObj || entityOnTopLeftOfObj)) {
m_fRotationDest = CGeneral::LimitRadianAngle(dirToSet - HALFPI); m_fRotationDest = CGeneral::LimitRadianAngle(dirToSet - HALFPI);