Ped fixes and ref removal

This commit is contained in:
eray orçunus 2020-04-17 07:01:54 +03:00
parent 435a9ca7f2
commit 425395ad25
12 changed files with 102 additions and 67 deletions

View File

@ -350,6 +350,9 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Debug", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, nil);
#ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);
#endif
DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil);
DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus);
DebugMenuAddCmd("Debug", "Fix Car", FixCar);
@ -374,9 +377,6 @@ DebugMenuPopulate(void)
DebugMenuAddVarBool8("Debug", "Don't render Peds", (int8*)&gbDontRenderPeds, nil);
DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil);
DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, nil);
#ifdef MENU_MAP
DebugMenuAddCmd("Debug", "Teleport to map waypoint", TeleportToWaypoint);
#endif
#ifdef TOGGLEABLE_BETA_FEATURES
DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil);
DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, nil);

View File

@ -1623,6 +1623,15 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
if (ped->IsPlayer())
AudioManager.PlayerJustLeftCar();
#ifdef VC_PED_PORTS
if (ped->m_objective == OBJECTIVE_LEAVE_CAR_AND_DIE) {
dragAssoc->SetDeleteCallback(PedSetDraggedOutCarPositionCB, ped);
ped->m_fHealth = 0.0f;
ped->SetDie(ANIM_FLOOR_HIT, 1000.0f, 0.5f);
return;
}
#endif
if (quickJackedAssoc) {
dragAssoc->SetDeleteCallback(PedSetQuickDraggedOutCarPositionCB, ped);
} else {
@ -5186,7 +5195,7 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl)
}
if (extraTime == -1) {
m_getUpTimer = -1;
m_getUpTimer = UINT32_MAX;
} else if (fallAssoc) {
if (IsPlayer()) {
m_getUpTimer = 1000.0f * fallAssoc->hierarchy->totalLength
@ -6448,7 +6457,7 @@ CPed::ExitCar(void)
void
CPed::Fall(void)
{
if (m_getUpTimer != -1 && CTimer::GetTimeInMilliseconds() > m_getUpTimer
if (m_getUpTimer != UINT32_MAX && CTimer::GetTimeInMilliseconds() > m_getUpTimer
#ifdef VC_PED_PORTS
&& bIsStanding
#endif
@ -10663,7 +10672,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
return;
if (ped->EnteringCar()) {
bool isLow = veh->bLowVehicle;
bool isLow = !!veh->bLowVehicle;
if (!veh->bIsBus)
veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_CLOSEDOOR_LHS, 1.0f);
@ -10691,7 +10700,11 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif
|| !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) {
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER
#ifdef VC_PED_PORTS
|| ped->m_nPedState == PED_CARJACK
#endif
)
veh->bIsBeingCarJacked = false;
ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER;
@ -11027,9 +11040,9 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
PedSetInCarCB(nil, ped);
return;
}
bool isVan = veh->bIsVan;
bool isBus = veh->bIsBus;
bool isLow = veh->bLowVehicle;
bool isVan = !!veh->bIsVan;
bool isBus = !!veh->bIsBus;
bool isLow = !!veh->bLowVehicle;
eDoors enterDoor;
switch (ped->m_vehEnterType) {
case CAR_DOOR_RF:
@ -11144,7 +11157,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
if (!ped->IsNotInWreckedVehicle())
return;
bool isLow = veh->bLowVehicle;
bool isLow = !!veh->bLowVehicle;
int padNo;
if (ped->IsPlayer()) {
@ -11426,7 +11439,9 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
CMatrix pedMat(ped->GetMatrix());
CVector posAfterBeingDragged = Multiply3x3(pedMat, (itsRearDoor ? -vecPedDraggedOutCarAnimOffset : vecPedDraggedOutCarAnimOffset));
posAfterBeingDragged += ped->GetPosition();
#ifndef VC_PED_PORTS
posAfterBeingDragged.z += 1.0f;
#endif
CPedPlacement::FindZCoorForPed(&posAfterBeingDragged);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
ped->GetPosition() = posAfterBeingDragged;
@ -11476,17 +11491,26 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
&& ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && driver
&& driver->IsPlayer() && !CTheScripts::IsPlayerOnAMission()) {
#ifndef VC_PED_PORTS
if (CGeneral::GetRandomNumber() & 1)
ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, driver);
else
#endif
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, ped->m_pMyVehicle);
} else {
#ifdef VC_PED_PORTS
if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear && ped->CharCreatedBy != MISSION_CHAR
&& ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && !driver
&& FindPlayerPed()->m_carInObjective == ped->m_pMyVehicle && !CTheScripts::IsPlayerOnAMission())
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, ped->m_pMyVehicle);
else
#endif
{
ped->m_nPedState = PED_NONE;
ped->m_nLastPedState = PED_NONE;
ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 10000);
ped->bUsePedNodeSeek = true;
ped->m_pNextPathNode = nil;
ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000);
}
}
ped->SetGetUp();
}
@ -12289,24 +12313,36 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void
ped->Say(SOUND_PED_FLEE_RUN);
}
} else {
if (ped->m_pedStats->m_temper <= ped->m_pedStats->m_fear
|| ped->CharCreatedBy == MISSION_CHAR || veh->VehicleCreatedBy == MISSION_VEHICLE
|| !veh->pDriver || !veh->pDriver->IsPlayer()
|| CTheScripts::IsPlayerOnAMission()) {
if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear
&& ped->CharCreatedBy != MISSION_CHAR && veh->VehicleCreatedBy != MISSION_VEHICLE
&& veh->pDriver && veh->pDriver->IsPlayer()
&& !CTheScripts::IsPlayerOnAMission()) {
ped->SetFlee(veh->GetPosition(), 10000);
ped->bUsePedNodeSeek = true;
ped->m_pNextPathNode = nil;
#ifndef VC_PED_PORTS
if (CGeneral::GetRandomNumber() < MYRAND_MAX / 2) {
ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, veh->pDriver);
} else
#endif
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, veh);
} else {
#ifdef VC_PED_PORTS
if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear && ped->CharCreatedBy != MISSION_CHAR
&& ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && !veh->pDriver
&& FindPlayerPed()->m_carInObjective == ped->m_pMyVehicle && !CTheScripts::IsPlayerOnAMission())
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, veh);
else
#endif
{
ped->SetFindPathAndFlee(veh->GetPosition(), 10000);
if (CGeneral::GetRandomNumber() & 1 || ped->m_pedStats->m_fear > 70) {
ped->SetMoveState(PEDMOVE_SPRINT);
ped->Say(SOUND_PED_FLEE_SPRINT);
} else {
ped->Say(SOUND_PED_FLEE_RUN);
}
} else if (CGeneral::GetRandomNumber() < 0x3FFF) {
ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, veh->pDriver);
} else
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, veh);
}
}
}
}
if (ped->m_nLastPedState == PED_IDLE)

View File

@ -3,7 +3,7 @@
#include "main.h"
#include "PedRoutes.h"
CRouteNode (&gaRoutes)[NUMPEDROUTES] = *(CRouteNode(*)[NUMPEDROUTES]) * (uintptr*)0x62E090;
CRouteNode gaRoutes[NUMPEDROUTES];
void
CRouteNode::Initialise()

View File

@ -4,7 +4,6 @@
#include "FileMgr.h"
#include "PedStats.h"
//CPedStats *(&CPedStats::ms_apPedStats)[NUM_PEDSTATS] = *(CPedStats *(*)[NUM_PEDSTATS]) *(uintptr*)0x9404D4;
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
void

View File

@ -3,7 +3,7 @@
#include "FileMgr.h"
#include "PedType.h"
CPedType *(&CPedType::ms_apPedType)[NUM_PEDTYPES] = *(CPedType *(*)[NUM_PEDTYPES]) *(uintptr*)0x941594;
CPedType *CPedType::ms_apPedType[NUM_PEDTYPES];
void
CPedType::Initialise(void)

View File

@ -71,7 +71,7 @@ class CPedType
uint32 m_threats;
uint32 m_avoid;
static CPedType *(&ms_apPedType)[NUM_PEDTYPES];
static CPedType *ms_apPedType[NUM_PEDTYPES];
public:
static void Initialise(void);

View File

@ -16,15 +16,15 @@
#define SMALLSTRIPHEIGHT 4.0f
#define HORIZSTRIPHEIGHT 48.0f
RwTexture **gpCloudTex = (RwTexture**)0x9411C0; //[5];
RwTexture *gpCloudTex[5];
float &CClouds::CloudRotation = *(float*)0x8F5F40;
uint32 &CClouds::IndividualRotation = *(uint32*)0x943078;
float CClouds::CloudRotation;
uint32 CClouds::IndividualRotation;
float &CClouds::ms_cameraRoll = *(float*)0x8F29CC;
float &CClouds::ms_horizonZ = *(float*)0x8F31C0;
CRGBA &CClouds::ms_colourTop = *(CRGBA*)0x94143C;
CRGBA &CClouds::ms_colourBottom = *(CRGBA*)0x8F2C38;
float CClouds::ms_cameraRoll;
float CClouds::ms_horizonZ;
CRGBA CClouds::ms_colourTop;
CRGBA CClouds::ms_colourBottom;
void
CClouds::Init(void)

View File

@ -3,13 +3,13 @@
class CClouds
{
public:
static float &CloudRotation;
static uint32 &IndividualRotation;
static float CloudRotation;
static uint32 IndividualRotation;
static float &ms_cameraRoll;
static float &ms_horizonZ;
static CRGBA &ms_colourTop;
static CRGBA &ms_colourBottom;
static float ms_cameraRoll;
static float ms_horizonZ;
static CRGBA ms_colourTop;
static CRGBA ms_colourBottom;
static void Init(void);
static void Shutdown(void);

View File

@ -9,7 +9,7 @@
#define CONSOLE_Y_POS (10.0f)
#define CONSOLE_LINE_HEIGHT (12.0f)
CConsole &TheConsole = *(CConsole*)0x8F6498;
CConsole TheConsole;
void
CConsole::AddLine(char *s, uint8 r, uint8 g, uint8 b)

View File

@ -22,4 +22,4 @@ public:
void Init() { m_nCurrentLine = 0; m_nLineCount = 0; }
};
extern CConsole &TheConsole;
extern CConsole TheConsole;

View File

@ -48,16 +48,16 @@ FlareDef HeadLightsFlareDef[] = {
};
RwTexture **gpCoronaTexture = (RwTexture**)0x5FAF44; //[9]
RwTexture *gpCoronaTexture[9] = { nil, nil, nil, nil, nil, nil, nil, nil, nil };
float &CCoronas::LightsMult = *(float*)0x5FB088; // 1.0
float &CCoronas::SunScreenX = *(float*)0x8F4358;
float &CCoronas::SunScreenY = *(float*)0x8F4354;
bool &CCoronas::bSmallMoon = *(bool*)0x95CD49;
bool &CCoronas::SunBlockedByClouds = *(bool*)0x95CD73;
int &CCoronas::bChangeBrightnessImmediately = *(int*)0x8E2C30;
float CCoronas::LightsMult = 1.0f;
float CCoronas::SunScreenX;
float CCoronas::SunScreenY;
bool CCoronas::bSmallMoon;
bool CCoronas::SunBlockedByClouds;
int CCoronas::bChangeBrightnessImmediately;
CRegisteredCorona *CCoronas::aCoronas = (CRegisteredCorona*)0x72E518;
CRegisteredCorona CCoronas::aCoronas[NUMCORONAS];
const char aCoronaSpriteNames[][32] = {
"coronastar",

View File

@ -1,6 +1,6 @@
#pragma once
extern RwTexture **gpCoronaTexture; //[9]
extern RwTexture *gpCoronaTexture[9];
struct CRegisteredCorona
{
@ -42,7 +42,7 @@ static_assert(sizeof(CRegisteredCorona) == 0x80, "CRegisteredCorona: error");
class CCoronas
{
static CRegisteredCorona *aCoronas; //[NUMCORONAS];
static CRegisteredCorona aCoronas[NUMCORONAS];
public:
enum {
SUN_CORE = 1,
@ -77,12 +77,12 @@ public:
STREAK_ON,
};
static float &LightsMult;
static float &SunScreenY;
static float &SunScreenX;
static bool &bSmallMoon;
static bool &SunBlockedByClouds;
static int &bChangeBrightnessImmediately;
static float LightsMult;
static float SunScreenY;
static float SunScreenX;
static bool bSmallMoon;
static bool SunBlockedByClouds;
static int bChangeBrightnessImmediately;
static void Init(void);
static void Shutdown(void);