CPlayerPed & CMenuManager (#286)

Make Frontend great again!
This commit is contained in:
erorcun 2020-01-07 17:23:09 +03:00 committed by GitHub
parent 18de44e038
commit f9316d9cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1046 additions and 815 deletions

File diff suppressed because it is too large Load Diff

View File

@ -7,8 +7,8 @@
#define MENUHEADER_WIDTH 0.84f
#define MENUHEADER_HEIGHT 1.6f
#define MENUACTION_POS_X 40.0f
#define MENUACTION_POS_Y 37.5f
#define MENUACTION_X_MARGIN 40.0f
#define MENUACTION_POS_Y 60.0f
#define MENUACTION_WIDTH 0.405f
#define MENUACTION_HEIGHT 0.63f
@ -41,7 +41,8 @@
#define MENUDROP_COLOR_A 150
#define MENUDROP_COLOR_SIZE -1
#define MENUSLIDER_X 306.0f
#define MENUSLIDER_X 256.0f
#define MENUSLIDER_UNK 256.0f
enum eLanguages
{
@ -326,7 +327,17 @@ enum eCheckHover
HOVEROPTION_19,
HOVEROPTION_20,
HOVEROPTION_CHANGESKIN,
HOVEROPTION_42 = 42,
HOVEROPTION_INCREASE_BRIGHTNESS = 32,
HOVEROPTION_DECREASE_BRIGHTNESS,
HOVEROPTION_INCREASE_DRAWDIST,
HOVEROPTION_DECREASE_DRAWDIST,
HOVEROPTION_INCREASE_MUSICVOLUME,
HOVEROPTION_DECREASE_MUSICVOLUME,
HOVEROPTION_INCREASE_SFXVOLUME,
HOVEROPTION_DECREASE_SFXVOLUME,
HOVEROPTION_INCREASE_MOUSESENS,
HOVEROPTION_DECREASE_MOUSESENS,
HOVEROPTION_42,
};
enum eMenuColumns
@ -404,7 +415,7 @@ public:
int m_nCurrExOption;
bool m_bSkinsFound;
bool m_bQuitGameNoCD;
char field_452;
bool m_bRenderGameInMenu;
bool m_bSaveMenuActive;
bool m_bLoadingSavedGame;
char field_455;
@ -467,9 +478,11 @@ public:
static bool &m_bShutDownFrontEndRequested;
static bool &m_PrefsAllowNastyGame;
static float &headingYStart;
static float &unkX;
static float &unkY;
static float &menuXYpadding;
static float &actionTextScaleX;
static float &actionTextScaleY;
static int &sthWithButtons;
static int &sthWithButtons2;
public:
static void BuildStatLine(char *text, void *stat, uint8 aFloat, void *stat2);
@ -479,7 +492,7 @@ public:
void CheckSliderMovement(int);
int CostructStatLine(int);
void DisplayHelperText();
float DisplaySlider(float, float, float, float, float, float);
int DisplaySlider(float, float, float, float, float, float);
void DoSettingsBeforeStartingAGame();
void Draw();
void DrawControllerBound(int, int, int, uint8);
@ -487,6 +500,9 @@ public:
void DrawControllerSetupScreen();
void DrawFrontEnd();
void DrawFrontEndNormal();
#ifdef PS2_SAVE_DIALOG
void DrawFrontEndSaveZone();
#endif
void DrawPlayerSetupScreen();
int FadeIn(int alpha);
void FilterOutColorMarkersFromString(uint16, CRGBA &);

View File

@ -4,8 +4,8 @@ const CMenuScreen aScreens[] = {
// MENUPAGE_NONE = 0
{ "", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0, },
// MENUPAGE_STATS = 1
{ "FET_STA", MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2,
// MENUPAGE_STATS = 1 - Both PrintStats and Draw were printing the page name, so deleted the string Draw looked for.
{ ""/*"FET_STA"*/, MENUPAGE_NONE, MENUPAGE_NONE, MENUPAGE_NONE, 5, 2,
MENUACTION_CHANGEMENU, "FEDS_TB", SAVESLOT_NONE, MENUPAGE_NONE,
},
@ -166,12 +166,21 @@ const CMenuScreen aScreens[] = {
MENUACTION_MEMCARDSAVECONFIRM, "JAILB_U", SAVESLOT_NONE, MENUPAGE_NONE,
},
// Unused in PC but anyway
// MENUPAGE_SAVE = 24
#ifdef PS2_SAVE_DIALOG
{ "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0,
MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE,
MENUACTION_CHANGEMENU, "FESZ_SA", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT,
MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE,
},
#else
{ "FET_SG", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0,
MENUACTION_LABEL, "FES_SCG", SAVESLOT_NONE, MENUPAGE_NONE,
MENUACTION_UPDATESAVE, "GMSAVE", SAVESLOT_NONE, MENUPAGE_CHOOSE_SAVE_SLOT,
MENUACTION_UPDATEMEMCARDSAVE, "FESZ_CA", SAVESLOT_NONE, MENUPAGE_NONE,
},
#endif
// MENUPAGE_NO_MEMORY_CARD = 25
{ "FES_NOC", MENUPAGE_DISABLED, MENUPAGE_DISABLED, MENUPAGE_DISABLED, 0, 0,

View File

@ -158,6 +158,9 @@ void COnscreenTimerEntry::ProcessForDisplayClock() {
void COnscreenTimerEntry::ProcessForDisplayCounter() {
uint32 counter = *(uint32*)&CTheScripts::ScriptSpace[m_nCounterOffset];
assert(!m_nType || counter <= 100);
sprintf(m_bCounterBuffer, "%d", counter);
}

View File

@ -152,9 +152,10 @@ enum Config {
// Pad
#define KANGAROO_CHEAT
// Hud & radar
#define ASPECT_RATIO_SCALE
// Hud, frontend and radar
#define ASPECT_RATIO_SCALE // Not just makes everything scale with aspect ratio, also adds support for all aspect ratios
#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC
#define PS2_SAVE_DIALOG // PS2 style save dialog with transparent black box
// Script
#define USE_DEBUG_SCRIPT_LOADER // makes game load main_freeroam.scm by default

View File

@ -141,9 +141,29 @@ Idle(void *arg)
CTimer::Update();
CSprite2d::InitPerFrame();
CFont::InitPerFrame();
// We're basically merging FrontendIdle and Idle (just like TheGame on PS2)
#ifdef PS2_SAVE_DIALOG
// Only exists on PC FrontendIdle, probably some PS2 bug fix
if (FrontEndMenuManager.m_bMenuActive)
CSprite2d::SetRecipNearClip();
if (FrontEndMenuManager.m_bGameNotLoaded) {
CPad::UpdatePads();
FrontEndMenuManager.Process();
} else {
CPointLights::InitPerFrame();
CGame::Process();
DMAudio.Service();
}
if (RsGlobal.quit)
return;
#else
CPointLights::InitPerFrame();
CGame::Process();
DMAudio.Service();
#endif
if(CGame::bDemoMode && CTimer::GetTimeInMilliseconds() > (3*60 + 30)*1000 && !CCutsceneMgr::IsCutsceneProcessing()){
FrontEndMenuManager.m_bStartGameLoading = true;
@ -159,14 +179,16 @@ Idle(void *arg)
if(arg == nil)
return;
if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.field_452 == 1) &&
if((!FrontEndMenuManager.m_bMenuActive || FrontEndMenuManager.m_bRenderGameInMenu) &&
TheCamera.GetScreenFadeStatus() != FADE_2){
#ifdef GTA_PC
// This is from SA, but it's nice for windowed mode
RwV2d pos;
pos.x = SCREEN_WIDTH/2.0f;
pos.y = SCREEN_HEIGHT/2.0f;
RsMouseSetPos(&pos);
if (!FrontEndMenuManager.m_bRenderGameInMenu) {
// This is from SA, but it's nice for windowed mode
RwV2d pos;
pos.x = SCREEN_WIDTH / 2.0f;
pos.y = SCREEN_HEIGHT / 2.0f;
RsMouseSetPos(&pos);
}
#endif
CRenderer::ConstructRenderList();
CRenderer::PreRender();
@ -210,6 +232,10 @@ Idle(void *arg)
return;
}
#ifdef PS2_SAVE_DIALOG
if (FrontEndMenuManager.m_bMenuActive)
DefinedState();
#endif
RenderMenus();
DoFade();
Render2dStuffAfterFade();
@ -228,7 +254,7 @@ FrontendIdle(void)
#endif
CTimer::Update();
CSprite2d::SetRecipNearClip();
CSprite2d::SetRecipNearClip(); // this should be on InitialiseRenderWare according to PS2 asm. seems like a bug fix
CSprite2d::InitPerFrame();
CFont::InitPerFrame();
CPad::UpdatePads();
@ -248,11 +274,11 @@ FrontendIdle(void)
if(!RsCameraBeginUpdate(Scene.camera))
return;
DefinedState();
DefinedState(); // seems redundant, but breaks resolution change.
RenderMenus();
DoFade();
Render2dStuffAfterFade();
CFont::DrawFonts();
// CFont::DrawFonts(); // redundant
DoRWStuffEndOfFrame();
}
@ -744,16 +770,16 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
#ifdef CHATTYSPLASH
// my attempt
static wchar tmpstr[80];
float scale = SCREEN_SCALE_Y(0.8f);
vpos -= 50*scale;
CFont::SetScale(scale, scale);
float yscale = SCREEN_SCALE_Y(0.9f);
vpos -= 45*yscale;
CFont::SetScale(SCREEN_SCALE_X(0.75f), yscale);
CFont::SetPropOn();
CFont::SetRightJustifyOff();
CFont::SetFontStyle(FONT_BANK);
CFont::SetColor(CRGBA(255, 255, 255, 255));
AsciiToUnicode(str1, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
vpos += 25*scale;
vpos += 22*yscale;
AsciiToUnicode(str2, tmpstr);
CFont::PrintString(hpos, vpos, tmpstr);
#endif
@ -999,7 +1025,11 @@ AppEventHandler(RsEvent event, void *param)
case rsFRONTENDIDLE:
{
#ifdef PS2_SAVE_DIALOG
Idle((void*)1);
#else
FrontendIdle();
#endif
return rsEVENTPROCESSED;
}

View File

@ -1,116 +1,117 @@
#include "common.h"
#include "patcher.h"
#include "PlayerPed.h"
#include "Camera.h"
#include "WeaponEffects.h"
#include "ModelIndices.h"
#include "World.h"
#include "RpAnimBlend.h"
#include "General.h"
#include "Pools.h"
CPlayerPed::~CPlayerPed()
{
delete m_pWanted;
}
WRAPPER void CPlayerPed::KeepAreaAroundPlayerClear(void) { EAXJMP(0x4F3460); }
WRAPPER void CPlayerPed::ProcessControl(void) { EAXJMP(0x4EFD90); }
CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
{
m_fMoveSpeed = 0.0f;
SetModelIndex(MI_PLAYER);
SetInitialState();
m_pWanted = new CWanted();
m_pWanted->Initialise();
m_pArrestingCop = nil;
m_currentWeapon = WEAPONTYPE_UNARMED;
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
m_nSpeedTimer = 0;
m_bSpeedTimerFlag = 0;
m_pPointGunAt = nil;
m_nPedState = PED_IDLE;
m_fMaxStamina = 150.0f;
m_fCurrentStamina = m_fMaxStamina;
m_fStaminaProgress = 0.0f;
m_bShouldEvade = 0;
field_1367 = 0;
m_nShotDelay = 0;
field_1376 = 0.0f;
field_1380 = 0;
m_bHasLockOnTarget = false;
m_bCanBeDamaged = true;
m_fWalkAngle = 0.0f;
m_fFPSMoveHeading = 0.0f;
m_nTargettableObjects[0] = m_nTargettableObjects[1] = m_nTargettableObjects[2] = m_nTargettableObjects[3] = -1;
field_1413 = 0;
for (int i = 0; i < 6; i++) {
m_vecSafePos[i] = CVector(0.0f, 0.0f, 0.0f);
m_pPedAtSafePos[i] = nil;
}
}
void CPlayerPed::ClearWeaponTarget()
{
if (m_nPedType == PEDTYPE_PLAYER1) {
m_pPointGunAt = nil;
TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrosshair();
}
ClearPointGunAt();
}
void
CPlayerPed::SetWantedLevel(int32 level)
{
m_pWanted->SetWantedLevel(level);
}
void
CPlayerPed::SetWantedLevelNoDrop(int32 level)
{
m_pWanted->SetWantedLevelNoDrop(level);
}
void
CPlayerPed::MakeObjectTargettable(int32 handle)
{
for (int i = 0; i < ARRAY_SIZE(m_nTargettableObjects); i++) {
if (CPools::GetObjectPool()->GetAt(m_nTargettableObjects[i]) == nil) {
m_nTargettableObjects[i] = handle;
return;
}
}
}
// I don't know the actual purpose of parameter
void
CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)
{
if (m_pedStats->m_temper < 52) {
m_pedStats->m_temper++;
} else {
if (annoyedByPassingEntity) {
if (m_pedStats->m_temper < 55) {
m_pedStats->m_temper++;
} else {
m_pedStats->m_temper = 46;
}
}
}
}
void
CPlayerPed::ClearAdrenaline(void)
{
if (m_bAdrenalineActive && m_nAdrenalineTime != 0) {
m_nAdrenalineTime = 0;
CTimer::SetTimeScale(1.0f);
}
}
#include "common.h"
#include "patcher.h"
#include "PlayerPed.h"
#include "Camera.h"
#include "WeaponEffects.h"
#include "ModelIndices.h"
#include "World.h"
#include "RpAnimBlend.h"
#include "General.h"
#include "Pools.h"
#include "Darkel.h"
CPlayerPed::~CPlayerPed()
{
delete m_pWanted;
}
WRAPPER void CPlayerPed::KeepAreaAroundPlayerClear(void) { EAXJMP(0x4F3460); }
WRAPPER void CPlayerPed::ProcessControl(void) { EAXJMP(0x4EFD90); }
CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
{
m_fMoveSpeed = 0.0f;
SetModelIndex(MI_PLAYER);
SetInitialState();
m_pWanted = new CWanted();
m_pWanted->Initialise();
m_pArrestingCop = nil;
m_currentWeapon = WEAPONTYPE_UNARMED;
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
m_nSpeedTimer = 0;
m_bSpeedTimerFlag = 0;
m_pPointGunAt = nil;
m_nPedState = PED_IDLE;
m_fMaxStamina = 150.0f;
m_fCurrentStamina = m_fMaxStamina;
m_fStaminaProgress = 0.0f;
m_bShouldEvade = 0;
field_1367 = 0;
m_nShotDelay = 0;
field_1376 = 0.0f;
field_1380 = 0;
m_bHasLockOnTarget = false;
m_bCanBeDamaged = true;
m_fWalkAngle = 0.0f;
m_fFPSMoveHeading = 0.0f;
m_nTargettableObjects[0] = m_nTargettableObjects[1] = m_nTargettableObjects[2] = m_nTargettableObjects[3] = -1;
field_1413 = 0;
for (int i = 0; i < 6; i++) {
m_vecSafePos[i] = CVector(0.0f, 0.0f, 0.0f);
m_pPedAtSafePos[i] = nil;
}
}
void CPlayerPed::ClearWeaponTarget()
{
if (m_nPedType == PEDTYPE_PLAYER1) {
m_pPointGunAt = nil;
TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrosshair();
}
ClearPointGunAt();
}
void
CPlayerPed::SetWantedLevel(int32 level)
{
m_pWanted->SetWantedLevel(level);
}
void
CPlayerPed::SetWantedLevelNoDrop(int32 level)
{
m_pWanted->SetWantedLevelNoDrop(level);
}
void
CPlayerPed::MakeObjectTargettable(int32 handle)
{
for (int i = 0; i < ARRAY_SIZE(m_nTargettableObjects); i++) {
if (CPools::GetObjectPool()->GetAt(m_nTargettableObjects[i]) == nil) {
m_nTargettableObjects[i] = handle;
return;
}
}
}
// I don't know the actual purpose of parameter
void
CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)
{
if (m_pedStats->m_temper < 52) {
m_pedStats->m_temper++;
} else {
if (annoyedByPassingEntity) {
if (m_pedStats->m_temper < 55) {
m_pedStats->m_temper++;
} else {
m_pedStats->m_temper = 46;
}
}
}
}
void
CPlayerPed::ClearAdrenaline(void)
{
if (m_bAdrenalineActive && m_nAdrenalineTime != 0) {
m_nAdrenalineTime = 0;
CTimer::SetTimeScale(1.0f);
}
}
CPlayerInfo *
CPlayerPed::GetPlayerInfoForThisPlayerPed()
{
@ -118,8 +119,8 @@ CPlayerPed::GetPlayerInfoForThisPlayerPed()
return &CWorld::Players[0];
return nil;
}
}
void
CPlayerPed::SetupPlayerPed(int32 index)
{
@ -129,21 +130,21 @@ CPlayerPed::SetupPlayerPed(int32 index)
player->SetOrientation(0.0f, 0.0f, 0.0f);
CWorld::Add(player);
player->m_wepAccuracy = 100;
}
player->m_wepAccuracy = 100;
}
void
CPlayerPed::DeactivatePlayerPed(int32 index)
{
CWorld::Remove(CWorld::Players[index].m_pPed);
}
CWorld::Remove(CWorld::Players[index].m_pPed);
}
void
CPlayerPed::ReactivatePlayerPed(int32 index)
{
CWorld::Add(CWorld::Players[index].m_pPed);
}
CWorld::Add(CWorld::Players[index].m_pPed);
}
void
CPlayerPed::UseSprintEnergy(void)
{
@ -158,8 +159,8 @@ CPlayerPed::UseSprintEnergy(void)
if (m_fMaxStamina < 1000.0f)
m_fMaxStamina += 10.0f;
}
}
}
void
CPlayerPed::MakeChangesForNewWeapon(int8 weapon)
{
@ -179,9 +180,9 @@ CPlayerPed::MakeChangesForNewWeapon(int8 weapon)
weaponAnim->SetRun();
weaponAnim->flags |= ASSOC_FADEOUTWHENDONE;
}
TheCamera.ClearPlayerWeaponMode();
}
TheCamera.ClearPlayerWeaponMode();
}
void
CPlayerPed::ReApplyMoveAnims(void)
{
@ -199,8 +200,8 @@ CPlayerPed::ReApplyMoveAnims(void)
}
}
}
}
}
void
CPlayerPed::SetInitialState(void)
{
@ -236,8 +237,8 @@ CPlayerPed::SetInitialState(void)
m_bCanBeDamaged = true;
m_pedStats->m_temper = 50;
m_fWalkAngle = 0.0f;
}
}
void
CPlayerPed::SetRealMoveAnim(void)
{
@ -392,7 +393,9 @@ CPlayerPed::SetRealMoveAnim(void)
curRunAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->blendAmount = 0.0f;
curRunAssoc->blendDelta = 0.0f;
} else if (curSprintAssoc->blendDelta < 0.0f) {
} else if (curSprintAssoc->blendDelta >= 0.0f) {
// Stop sprinting when tired
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
curSprintAssoc->blendDelta = -1.0f;
curRunAssoc->blendDelta = 1.0f;
@ -460,24 +463,240 @@ CPlayerPed::SetRealMoveAnim(void)
curSprintAssoc->speed = 2.0f;
}
}
}
class CPlayerPed_ : public CPlayerPed
{
public:
CPlayerPed* ctor(void) { return ::new (this) CPlayerPed(); }
void dtor(void) { CPlayerPed::~CPlayerPed(); }
void SetMoveAnim_(void) { CPlayerPed::SetMoveAnim(); }
};
STARTPATCHES
InjectHook(0x4EF7E0, &CPlayerPed_::ctor, PATCH_JUMP);
InjectHook(0x4EFB30, &CPlayerPed_::dtor, PATCH_JUMP);
InjectHook(0x4F3760, &CPlayerPed_::SetMoveAnim_, PATCH_JUMP);
InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP);
InjectHook(0x4F3700, &CPlayerPed::AnnoyPlayerPed, PATCH_JUMP);
InjectHook(0x4F36C0, &CPlayerPed::GetPlayerInfoForThisPlayerPed, PATCH_JUMP);
InjectHook(0x4F2560, &CPlayerPed::MakeChangesForNewWeapon, PATCH_JUMP);
InjectHook(0x4F07C0, &CPlayerPed::ReApplyMoveAnims, PATCH_JUMP);
InjectHook(0x4F0880, &CPlayerPed::SetRealMoveAnim, PATCH_JUMP);
ENDPATCHES
}
void
CPlayerPed::RestoreSprintEnergy(float restoreSpeed)
{
if (m_fCurrentStamina < m_fMaxStamina)
m_fCurrentStamina += restoreSpeed * CTimer::GetTimeStep() * 0.5f;
}
bool
CPlayerPed::DoWeaponSmoothSpray(void)
{
if (m_nPedState == PED_ATTACK && !m_pPointGunAt) {
eWeaponType weapon = GetWeapon()->m_eWeaponType;
if (weapon == WEAPONTYPE_FLAMETHROWER || weapon == WEAPONTYPE_COLT45 || weapon == WEAPONTYPE_UZI || weapon == WEAPONTYPE_SHOTGUN ||
weapon == WEAPONTYPE_AK47 || weapon == WEAPONTYPE_M16 || weapon == WEAPONTYPE_HELICANNON)
return true;
}
return false;
}
void
CPlayerPed::DoStuffToGoOnFire(void)
{
if (m_nPedState == PED_SNIPER_MODE)
TheCamera.ClearPlayerWeaponMode();
}
bool
CPlayerPed::DoesTargetHaveToBeBroken(CVector target, CWeapon *weaponUsed)
{
CVector distVec = target - GetPosition();
if (distVec.Magnitude() > CWeaponInfo::GetWeaponInfo(weaponUsed->m_eWeaponType)->m_fRange)
return true;
if (weaponUsed->m_eWeaponType != WEAPONTYPE_SHOTGUN && weaponUsed->m_eWeaponType != WEAPONTYPE_AK47)
return false;
distVec.Normalise();
if (DotProduct(distVec,GetForward()) < 0.4f)
return true;
return false;
}
// Cancels landing anim while running & jumping? I think
void
CPlayerPed::RunningLand(CPad *padUsed)
{
CAnimBlendAssociation *landAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FALL_LAND);
if (landAssoc && landAssoc->currentTime == 0.0f && m_fMoveSpeed > 1.5f
&& padUsed && (padUsed->GetPedWalkLeftRight() != 0.0f || padUsed->GetPedWalkUpDown() != 0.0f)) {
landAssoc->blendDelta = -1000.0f;
landAssoc->flags |= ASSOC_DELETEFADEDOUT;
CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAND)->SetFinishCallback(FinishJumpCB, this);
if (m_nPedState == PED_JUMP)
RestorePreviousState();
}
}
bool
CPlayerPed::IsThisPedAttackingPlayer(CPed *suspect)
{
if (suspect->m_pPointGunAt == this)
return true;
switch (suspect->m_objective) {
case OBJECTIVE_KILL_CHAR_ON_FOOT:
case OBJECTIVE_KILL_CHAR_ANY_MEANS:
if (suspect->m_pedInObjective == this)
return true;
break;
default:
break;
}
return false;
}
void
CPlayerPed::PlayerControlSniper(CPad *padUsed)
{
ProcessWeaponSwitch(padUsed);
TheCamera.PlayerExhaustion = (1.0f - (m_fCurrentStamina - -150.0f) / 300.0f) * 0.9f + 0.1f;
if (!padUsed->GetTarget()) {
RestorePreviousState();
TheCamera.ClearPlayerWeaponMode();
}
if (padUsed->WeaponJustDown()) {
CVector firePos(0.0f, 0.0f, 0.6f);
firePos = GetMatrix() * firePos;
GetWeapon()->Fire(this, &firePos);
}
GetWeapon()->Update(m_audioEntityId);
}
// I think R* also used goto in here.
void
CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
{
if (CDarkel::FrenzyOnGoing())
goto switchDetectDone;
// The fact that m_nSelectedWepSlot is int8 makes below loops circular loop.
if (padUsed->CycleWeaponRightJustDown() && !m_pPointGunAt) {
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON_RUNABOUT
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER_RUNABOUT
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER_RUNABOUT) {
for (m_nSelectedWepSlot = m_currentWeapon + 1; m_nSelectedWepSlot < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; ++m_nSelectedWepSlot) {
if (HasWeapon(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) {
goto switchDetectDone;
}
}
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
}
} else if (padUsed->CycleWeaponLeftJustDown() && !m_pPointGunAt) {
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER) {
for (m_nSelectedWepSlot = m_currentWeapon - 1; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
if (HasWeapon(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) {
goto switchDetectDone;
}
}
m_nSelectedWepSlot = WEAPONTYPE_DETONATOR;
}
} else if (CWeaponInfo::GetWeaponInfo((eWeaponType)m_currentWeapon)->m_eWeaponFire != WEAPON_FIRE_MELEE) {
if (GetWeapon(m_currentWeapon).m_nAmmoTotal <= 0) {
if (TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_SNIPER
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_ROCKETLAUNCHER) {
for (m_nSelectedWepSlot = m_currentWeapon - 1; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && HasWeapon(WEAPONTYPE_BASEBALLBAT)
|| GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != WEAPONTYPE_MOLOTOV && m_nSelectedWepSlot != WEAPONTYPE_GRENADE) {
goto switchDetectDone;
}
}
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
}
}
}
switchDetectDone:
if (m_nSelectedWepSlot != m_currentWeapon) {
if (m_nPedState != PED_ATTACK && m_nPedState != PED_AIM_GUN && m_nPedState != PED_FIGHT)
MakeChangesForNewWeapon(m_nSelectedWepSlot);
}
}
void
CPlayerPed::PlayerControlM16(CPad *padUsed)
{
ProcessWeaponSwitch(padUsed);
TheCamera.PlayerExhaustion = (1.0f - (m_fCurrentStamina - -150.0f) / 300.0f) * 0.9f + 0.1f;
if (!padUsed->GetTarget()) {
RestorePreviousState();
TheCamera.ClearPlayerWeaponMode();
}
if (padUsed->GetWeapon()) {
CVector firePos(0.0f, 0.0f, 0.6f);
firePos = GetMatrix() * firePos;
GetWeapon()->Fire(this, &firePos);
}
GetWeapon()->Update(m_audioEntityId);
}
void
CPlayerPed::PlayerControlFighter(CPad *padUsed)
{
float leftRight = padUsed->GetPedWalkLeftRight();
float upDown = padUsed->GetPedWalkUpDown();
float displacement = sqrt(upDown * upDown + leftRight * leftRight);
if (displacement > 0.0f) {
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
m_takeAStepAfterAttack = displacement > 120.0f;
if (padUsed->GetSprint() && displacement > 60.0f)
bIsAttacking = false;
}
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy && padUsed->JumpJustDown()) {
if (m_bShouldEvade && m_pEvadingFrom) {
SetEvasiveDive((CPhysical*)m_pEvadingFrom, 1);
m_bShouldEvade = false;
m_pEvadingFrom = nil;
} else {
SetJump();
}
}
}
class CPlayerPed_ : public CPlayerPed
{
public:
CPlayerPed* ctor(void) { return ::new (this) CPlayerPed(); }
void dtor(void) { CPlayerPed::~CPlayerPed(); }
void SetMoveAnim_(void) { CPlayerPed::SetMoveAnim(); }
};
STARTPATCHES
InjectHook(0x4EF7E0, &CPlayerPed_::ctor, PATCH_JUMP);
InjectHook(0x4EFB30, &CPlayerPed_::dtor, PATCH_JUMP);
InjectHook(0x4F3760, &CPlayerPed_::SetMoveAnim_, PATCH_JUMP);
InjectHook(0x4F28A0, &CPlayerPed::ClearWeaponTarget, PATCH_JUMP);
InjectHook(0x4F3700, &CPlayerPed::AnnoyPlayerPed, PATCH_JUMP);
InjectHook(0x4F36C0, &CPlayerPed::GetPlayerInfoForThisPlayerPed, PATCH_JUMP);
InjectHook(0x4F2560, &CPlayerPed::MakeChangesForNewWeapon, PATCH_JUMP);
InjectHook(0x4F07C0, &CPlayerPed::ReApplyMoveAnims, PATCH_JUMP);
InjectHook(0x4F0880, &CPlayerPed::SetRealMoveAnim, PATCH_JUMP);
InjectHook(0x4F1810, &CPlayerPed::PlayerControlFighter, PATCH_JUMP);
InjectHook(0x4F1340, &CPlayerPed::RestoreSprintEnergy, PATCH_JUMP);
InjectHook(0x4F1380, &CPlayerPed::DoWeaponSmoothSpray, PATCH_JUMP);
InjectHook(0x4F36E0, &CPlayerPed::DoStuffToGoOnFire, PATCH_JUMP);
InjectHook(0x4F3350, &CPlayerPed::DoesTargetHaveToBeBroken, PATCH_JUMP);
InjectHook(0x4F31D0, &CPlayerPed::RunningLand, PATCH_JUMP);
InjectHook(0x4F2D00, &CPlayerPed::IsThisPedAttackingPlayer, PATCH_JUMP);
InjectHook(0x4F1CF0, &CPlayerPed::PlayerControlSniper, PATCH_JUMP);
InjectHook(0x4F2310, &CPlayerPed::ProcessWeaponSwitch, PATCH_JUMP);
InjectHook(0x4F1DF0, &CPlayerPed::PlayerControlM16, PATCH_JUMP);
ENDPATCHES

View File

@ -2,6 +2,7 @@
#include "Ped.h"
#include "Wanted.h"
#include "Pad.h"
class CPlayerPed : public CPed
{
@ -12,13 +13,13 @@ public:
float m_fCurrentStamina;
float m_fMaxStamina;
float m_fStaminaProgress;
uint8 m_nSelectedWepSlot;
uint8 m_nSelectedWepSlot; // eWeaponType
bool m_bSpeedTimerFlag;
bool m_bShouldEvade;
int8 field_1367;
int32 m_nSpeedTimer;
int32 m_nShotDelay;
float field_1376; // m_fAttackButtonCounter?
float field_1376; // m_fAttackButtonCounter?
int8 field_1380; // bHaveTargetSelected?
int8 field_1381;
int8 field_1382;
@ -56,6 +57,16 @@ public:
void UseSprintEnergy(void);
class CPlayerInfo *GetPlayerInfoForThisPlayerPed();
void SetRealMoveAnim(void);
void RestoreSprintEnergy(float);
bool DoWeaponSmoothSpray(void);
void DoStuffToGoOnFire(void);
bool DoesTargetHaveToBeBroken(CVector, CWeapon*);
void RunningLand(CPad*);
bool IsThisPedAttackingPlayer(CPed*);
void PlayerControlSniper(CPad*);
void PlayerControlM16(CPad*);
void PlayerControlFighter(CPad*);
void ProcessWeaponSwitch(CPad*);
void MakeObjectTargettable(int32);
static void SetupPlayerPed(int32);

View File

@ -123,15 +123,15 @@ CFont::InitPerFrame(void)
void
CFont::PrintChar(float x, float y, uint16 c)
{
if(x <= 0.0f || x >= SCREEN_WIDTH ||
y <= 0.0f || y >= SCREEN_HEIGHT) // BUG: game uses SCREENW again
if(x <= 0.0f || x > SCREEN_WIDTH ||
y <= 0.0f || y > SCREEN_HEIGHT) // BUG: game uses SCREENW again
return;
float w = GetCharacterWidth(c) / 32.0f;
float xoff = c & 0xF;
float yoff = c >> 4;
if(Details.style == 0 || Details.style == 2){
if(Details.style == FONT_BANK || Details.style == FONT_HEADING){
if(Details.dropShadowPosition != 0){
CSprite2d::AddSpriteToBank(Details.bank + Details.style, // BUG: game doesn't add bank
CRect(x + SCREEN_SCALE_X(Details.dropShadowPosition),

View File

@ -41,11 +41,12 @@ enum {
class CFont
{
static CFontDetails &Details;
static int16 Size[3][193];
static int16 &NewLine;
static CSprite2d *Sprite; //[3]
public:
static CFontDetails& Details;
static void Initialise(void);
static void Shutdown(void);
static void InitPerFrame(void);

View File

@ -118,7 +118,7 @@ void CHud::Draw()
bool Mode_RunAround = 0;
bool Mode_FirstPerson = 0;
int32 WeaponType = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_eWeaponType;
int32 WeaponType = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_eWeaponType;
int32 Mode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
if (Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_EDITOR)
@ -130,8 +130,8 @@ void CHud::Draw()
Draw Crosshairs
*/
if (TheCamera.Cams->Using3rdPersonMouseCam() && (!CPad::GetPad(0)->GetLookBehindForPed() || TheCamera.m_bPlayerIsInGarage) || Mode == CCam::MODE_1STPERSON_RUNABOUT) {
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed) {
int32 State = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_nPedState;
if (FindPlayerPed()) {
int32 State = FindPlayerPed()->m_nPedState;
if (State != PED_ENTER_CAR && State != PED_CARJACK) {
if ((WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_M16) || WeaponType == WEAPONTYPE_FLAMETHROWER)
Mode_RunAround = 1;
@ -162,7 +162,7 @@ void CHud::Draw()
float f3rdX = (((TheCamera.m_f3rdPersonCHairMultX - 0.5f) / ((CDraw::GetAspectRatio()) / (DEFAULT_ASPECT_RATIO))) + 0.5f) * SCREEN_WIDTH;
float f3rdY = SCREEN_HEIGHT * TheCamera.m_f3rdPersonCHairMultY + SCREEN_SCALE_Y(-2.0f);
#endif
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed && WeaponType == WEAPONTYPE_M16) {
if (FindPlayerPed() && WeaponType == WEAPONTYPE_M16) {
rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f);
rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f);
rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f);
@ -271,8 +271,8 @@ void CHud::Draw()
DrawAmmo
*/
uint32 AmmoAmount = CWeaponInfo::GetWeaponInfo(FindPlayerPed()->GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition;
uint32 AmmoInClip = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoInClip;
uint32 TotalAmmo = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_weapons[CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_currentWeapon].m_nAmmoTotal;
uint32 AmmoInClip = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_nAmmoInClip;
uint32 TotalAmmo = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_nAmmoTotal;
uint32 Ammo, Clip;
if (AmmoAmount <= 1 || AmmoAmount >= 1000)
@ -342,13 +342,13 @@ void CHud::Draw()
if (m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8
|| m_ItemToFlash != ITEM_HEALTH
|| CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth < 10
|| FindPlayerPed()->m_fHealth < 10
&& CTimer::GetFrameCounter() & 8) {
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth >= 10
|| CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
if (FindPlayerPed()->m_fHealth >= 10
|| FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
AsciiToUnicode("{", sPrintIcon);
sprintf(sTemp, "%03d", (int32)CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fHealth);
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fHealth);
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
@ -372,9 +372,9 @@ void CHud::Draw()
*/
if (m_ItemToFlash == ITEM_ARMOUR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_ARMOUR) {
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fArmour > 1.0f) {
if (FindPlayerPed()->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon);
sprintf(sTemp, "%03d", (int32)CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_fArmour);
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fArmour);
AsciiToUnicode(sTemp, sPrint);
CFont::SetColor(CRGBA(0, 0, 0, 255));
@ -410,8 +410,8 @@ void CHud::Draw()
for (int i = 0; i < 6; i++) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(2.0f + SCREEN_SCALE_FROM_RIGHT(60.0f - 2.0f + 24.0f * i), SCREEN_SCALE_Y(87.0f + 2.0f), sPrintIcon);
if (CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nWantedLevel > i
&& (CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_pWanted->m_nLastWantedLevelChange
if (FindPlayerPed()->m_pWanted->m_nWantedLevel > i
&& (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange
+ 2000 || CTimer::GetFrameCounter() & 4)) {
CFont::SetColor(CRGBA(193, 164, 120, 255));
@ -645,6 +645,11 @@ void CHud::Draw()
if (!CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterProcessed)
CounterOnLastFrame = 0;
#ifdef FIX_BUGS
#define TIMER_RIGHT_OFFSET 34.0f // Taken from VC frenzy timer
#else
#define TIMER_RIGHT_OFFSET 27.0f
#endif
if (CUserDisplay::OnscnTimer.m_bProcessed) {
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerProcessed) {
if (!TimerOnLastFrame)
@ -668,19 +673,19 @@ void CHud::Draw()
CFont::SetPropOff();
CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetColor(CRGBA(186, 101, 50, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f), SCREEN_SCALE_Y(110.0f), sTimer);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer);
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText[0]) {
CFont::SetPropOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
CFont::SetScale(SCREEN_SCALE_X(0.64f), SCREEN_SCALE_Y(1.35f));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
CFont::SetColor(CRGBA(186, 101, 50, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText));
}
}
}
@ -697,8 +702,8 @@ void CHud::Draw()
if (CTimer::GetFrameCounter() & 4 || !CounterFlashTimer) {
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType) {
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(27.0f) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(27.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(27.0f) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer)) / 2 + SCREEN_SCALE_FROM_RIGHT(27.0f + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 80));
CSprite2d::DrawRect(CRect(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(100.0f) / 2 + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(8.0f), SCREEN_SCALE_X(atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer) / 2.0f) + SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET + 50.0f) + SCREEN_SCALE_X(4.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(11.0f) + SCREEN_SCALE_Y(8.0f)), CRGBA(0, 106, 164, 255));
} else {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer);
CFont::SetPropOn();
@ -715,24 +720,25 @@ void CHud::Draw()
CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
CFont::SetColor(CRGBA(0, 106, 164, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f), SCREEN_SCALE_Y(132.0f), sTimer);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer);
}
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) {
CFont::SetPropOn();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
CFont::SetColor(CRGBA(0, 106, 164, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(27.0f) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
}
}
}
}
#undef TIMER_RIGHT_OFFSET
/*
DrawPager

View File

@ -45,7 +45,7 @@ CWeapon::Reload(void)
bool
CWeapon::IsType2Handed(void)
{
return m_eWeaponType >= WEAPONTYPE_SHOTGUN && m_eWeaponType <= WEAPONTYPE_FLAMETHROWER && m_eWeaponType != WEAPONTYPE_ROCKETLAUNCHER;
return m_eWeaponType >= WEAPONTYPE_SHOTGUN && m_eWeaponType <= WEAPONTYPE_FLAMETHROWER && m_eWeaponType != WEAPONTYPE_ROCKETLAUNCHER;
}
bool
@ -88,8 +88,20 @@ CWeapon::HitsGround(CEntity *holder, CVector *firePos, CEntity *aimingTo)
return false;
}
bool
CWeapon::HasWeaponAmmoToBeUsed(void)
{
switch (m_eWeaponType) {
case WEAPONTYPE_UNARMED:
case WEAPONTYPE_BASEBALLBAT:
return true;
default:
return m_nAmmoTotal != 0;
}
}
STARTPATCHES
InjectHook(0x55C330, &CWeapon::Initialise, PATCH_JUMP);
InjectHook(0x5639D0, &CWeapon::Reload, PATCH_JUMP);
InjectHook(0x564890, &CWeapon::HitsGround, PATCH_JUMP);
ENDPATCHES
ENDPATCHES

View File

@ -15,7 +15,8 @@ enum eWeaponType
WEAPONTYPE_MOLOTOV,
WEAPONTYPE_GRENADE,
WEAPONTYPE_DETONATOR,
WEAPONTYPE_TOTAL_INVENTORY_WEAPONS,
WEAPONTYPE_TOTAL_INVENTORY_WEAPONS = 13,
WEAPONTYPE_HELICANNON = 13,
WEAPONTYPE_TOTALWEAPONS,
WEAPONTYPE_ARMOUR,
WEAPONTYPE_RAMMEDBYCAR,
@ -72,6 +73,7 @@ public:
bool IsType2Handed(void);
static void DoTankDoomAiming(CEntity *playerVehicle, CEntity *playerPed, CVector *start, CVector *end);
bool HitsGround(CEntity* holder, CVector* firePos, CEntity* aimingTo);
bool HasWeaponAmmoToBeUsed(void);
static void InitialiseWeapons(void);
static void UpdateWeapons(void);
};