Merge pull request #458 from erorcun/erorcun

Ped fixes and ref removal
This commit is contained in:
erorcun 2020-04-17 07:04:58 +03:00 committed by GitHub
commit de18bdc5d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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", "Draw hud", (int8*)&CHud::m_Wants_To_Draw_Hud, nil);
DebugMenuAddVarBool8("Debug", "Edit on", (int8*)&CSceneEdit::m_bEditOn, 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); DebugMenuAddVar("Debug", "Engine Status", &engineStatus, nil, 1, 0, 226, nil);
DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus); DebugMenuAddCmd("Debug", "Set Engine Status", SetEngineStatus);
DebugMenuAddCmd("Debug", "Fix Car", FixCar); 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 Peds", (int8*)&gbDontRenderPeds, nil);
DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil); DebugMenuAddVarBool8("Debug", "Don't render Vehicles", (int8*)&gbDontRenderVehicles, nil);
DebugMenuAddVarBool8("Debug", "Don't render Objects", (int8*)&gbDontRenderObjects, 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 #ifdef TOGGLEABLE_BETA_FEATURES
DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil); DebugMenuAddVarBool8("Debug", "Toggle banned particles", (int8*)&CParticle::bEnableBannedParticles, nil);
DebugMenuAddVarBool8("Debug", "Toggle popping heads on headshot", (int8*)&CPed::bPopHeadsOnHeadshot, 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()) if (ped->IsPlayer())
AudioManager.PlayerJustLeftCar(); 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) { if (quickJackedAssoc) {
dragAssoc->SetDeleteCallback(PedSetQuickDraggedOutCarPositionCB, ped); dragAssoc->SetDeleteCallback(PedSetQuickDraggedOutCarPositionCB, ped);
} else { } else {
@ -5186,7 +5195,7 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl)
} }
if (extraTime == -1) { if (extraTime == -1) {
m_getUpTimer = -1; m_getUpTimer = UINT32_MAX;
} else if (fallAssoc) { } else if (fallAssoc) {
if (IsPlayer()) { if (IsPlayer()) {
m_getUpTimer = 1000.0f * fallAssoc->hierarchy->totalLength m_getUpTimer = 1000.0f * fallAssoc->hierarchy->totalLength
@ -6448,7 +6457,7 @@ CPed::ExitCar(void)
void void
CPed::Fall(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 #ifdef VC_PED_PORTS
&& bIsStanding && bIsStanding
#endif #endif
@ -10663,7 +10672,7 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
return; return;
if (ped->EnteringCar()) { if (ped->EnteringCar()) {
bool isLow = veh->bLowVehicle; bool isLow = !!veh->bLowVehicle;
if (!veh->bIsBus) if (!veh->bIsBus)
veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_CLOSEDOOR_LHS, 1.0f); veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_CLOSEDOOR_LHS, 1.0f);
@ -10691,7 +10700,11 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
#endif #endif
|| !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) { || !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; veh->bIsBeingCarJacked = false;
ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER; ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER;
@ -11027,9 +11040,9 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
PedSetInCarCB(nil, ped); PedSetInCarCB(nil, ped);
return; return;
} }
bool isVan = veh->bIsVan; bool isVan = !!veh->bIsVan;
bool isBus = veh->bIsBus; bool isBus = !!veh->bIsBus;
bool isLow = veh->bLowVehicle; bool isLow = !!veh->bLowVehicle;
eDoors enterDoor; eDoors enterDoor;
switch (ped->m_vehEnterType) { switch (ped->m_vehEnterType) {
case CAR_DOOR_RF: case CAR_DOOR_RF:
@ -11144,7 +11157,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
if (!ped->IsNotInWreckedVehicle()) if (!ped->IsNotInWreckedVehicle())
return; return;
bool isLow = veh->bLowVehicle; bool isLow = !!veh->bLowVehicle;
int padNo; int padNo;
if (ped->IsPlayer()) { if (ped->IsPlayer()) {
@ -11426,7 +11439,9 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
CMatrix pedMat(ped->GetMatrix()); CMatrix pedMat(ped->GetMatrix());
CVector posAfterBeingDragged = Multiply3x3(pedMat, (itsRearDoor ? -vecPedDraggedOutCarAnimOffset : vecPedDraggedOutCarAnimOffset)); CVector posAfterBeingDragged = Multiply3x3(pedMat, (itsRearDoor ? -vecPedDraggedOutCarAnimOffset : vecPedDraggedOutCarAnimOffset));
posAfterBeingDragged += ped->GetPosition(); posAfterBeingDragged += ped->GetPosition();
#ifndef VC_PED_PORTS
posAfterBeingDragged.z += 1.0f; posAfterBeingDragged.z += 1.0f;
#endif
CPedPlacement::FindZCoorForPed(&posAfterBeingDragged); CPedPlacement::FindZCoorForPed(&posAfterBeingDragged);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
ped->GetPosition() = posAfterBeingDragged; ped->GetPosition() = posAfterBeingDragged;
@ -11476,17 +11491,26 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
&& ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && driver && ped->m_pMyVehicle->VehicleCreatedBy != MISSION_VEHICLE && driver
&& driver->IsPlayer() && !CTheScripts::IsPlayerOnAMission()) { && driver->IsPlayer() && !CTheScripts::IsPlayerOnAMission()) {
#ifndef VC_PED_PORTS
if (CGeneral::GetRandomNumber() & 1) if (CGeneral::GetRandomNumber() & 1)
ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, driver); ped->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, driver);
else else
#endif
ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, ped->m_pMyVehicle); ped->SetObjective(OBJECTIVE_ENTER_CAR_AS_DRIVER, ped->m_pMyVehicle);
} else { } 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_nPedState = PED_NONE;
ped->m_nLastPedState = PED_NONE; ped->m_nLastPedState = PED_NONE;
ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 10000); ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000);
ped->bUsePedNodeSeek = true; }
ped->m_pNextPathNode = nil;
} }
ped->SetGetUp(); ped->SetGetUp();
} }
@ -12289,24 +12313,36 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void
ped->Say(SOUND_PED_FLEE_RUN); ped->Say(SOUND_PED_FLEE_RUN);
} }
} else { } else {
if (ped->m_pedStats->m_temper <= ped->m_pedStats->m_fear if (ped->m_pedStats->m_temper > ped->m_pedStats->m_fear
|| ped->CharCreatedBy == MISSION_CHAR || veh->VehicleCreatedBy == MISSION_VEHICLE && ped->CharCreatedBy != MISSION_CHAR && veh->VehicleCreatedBy != MISSION_VEHICLE
|| !veh->pDriver || !veh->pDriver->IsPlayer() && veh->pDriver && veh->pDriver->IsPlayer()
|| CTheScripts::IsPlayerOnAMission()) { && !CTheScripts::IsPlayerOnAMission()) {
ped->SetFlee(veh->GetPosition(), 10000); #ifndef VC_PED_PORTS
ped->bUsePedNodeSeek = true; if (CGeneral::GetRandomNumber() < MYRAND_MAX / 2) {
ped->m_pNextPathNode = nil; 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) { if (CGeneral::GetRandomNumber() & 1 || ped->m_pedStats->m_fear > 70) {
ped->SetMoveState(PEDMOVE_SPRINT); ped->SetMoveState(PEDMOVE_SPRINT);
ped->Say(SOUND_PED_FLEE_SPRINT); ped->Say(SOUND_PED_FLEE_SPRINT);
} else { } else {
ped->Say(SOUND_PED_FLEE_RUN); 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) if (ped->m_nLastPedState == PED_IDLE)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@
#define CONSOLE_Y_POS (10.0f) #define CONSOLE_Y_POS (10.0f)
#define CONSOLE_LINE_HEIGHT (12.0f) #define CONSOLE_LINE_HEIGHT (12.0f)
CConsole &TheConsole = *(CConsole*)0x8F6498; CConsole TheConsole;
void void
CConsole::AddLine(char *s, uint8 r, uint8 g, uint8 b) 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; } 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::LightsMult = 1.0f;
float &CCoronas::SunScreenX = *(float*)0x8F4358; float CCoronas::SunScreenX;
float &CCoronas::SunScreenY = *(float*)0x8F4354; float CCoronas::SunScreenY;
bool &CCoronas::bSmallMoon = *(bool*)0x95CD49; bool CCoronas::bSmallMoon;
bool &CCoronas::SunBlockedByClouds = *(bool*)0x95CD73; bool CCoronas::SunBlockedByClouds;
int &CCoronas::bChangeBrightnessImmediately = *(int*)0x8E2C30; int CCoronas::bChangeBrightnessImmediately;
CRegisteredCorona *CCoronas::aCoronas = (CRegisteredCorona*)0x72E518; CRegisteredCorona CCoronas::aCoronas[NUMCORONAS];
const char aCoronaSpriteNames[][32] = { const char aCoronaSpriteNames[][32] = {
"coronastar", "coronastar",

View File

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