mirror of
https://github.com/GTAmodding/re3.git
synced 2021-02-19 17:49:54 +01:00
implemented some CVehicle functions
This commit is contained in:
parent
d62c616545
commit
396b43cbd4
@ -10,3 +10,4 @@ float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C;
|
||||
|
||||
WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); }
|
||||
WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); }
|
||||
WRAPPER CPed *CPopulation::AddPedInCar(CVehicle *vehicle) { EAXJMP(0x4F5800); }
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "PedType.h"
|
||||
class CPed;
|
||||
class CVehicle;
|
||||
|
||||
struct PedGroup
|
||||
{
|
||||
@ -17,4 +18,5 @@ public:
|
||||
|
||||
static void UpdatePedCount(uint32, bool);
|
||||
static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool);
|
||||
static CPed *AddPedInCar(CVehicle *vehicle);
|
||||
};
|
||||
|
@ -717,7 +717,7 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
|
||||
car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_RR, 3);
|
||||
car->SetDoorDamage(12, CDamageManager::CAR_DOOR_RR, true);
|
||||
}
|
||||
vehicle->m_veh_flagA10 = true;
|
||||
vehicle->bEngineOn = true;
|
||||
if (vehicle->IsCar())
|
||||
((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4;
|
||||
CWorld::Remove(vehicle);
|
||||
|
@ -104,7 +104,7 @@ CPed::FlagToDestroyWhenNextProcessed(void)
|
||||
}
|
||||
bInVehicle = false;
|
||||
m_pMyVehicle = nil;
|
||||
if (m_nCreatedBy == CREATED_BY_SCRIPT)
|
||||
if (CharCreatedBy == MISSION_CHAR)
|
||||
m_nPedState = PED_DEAD;
|
||||
else
|
||||
m_nPedState = PED_NONE;
|
||||
@ -283,7 +283,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
|
||||
m_talkType = 167;
|
||||
m_objective = OBJECTIVE_NONE;
|
||||
m_prevObjective = OBJECTIVE_NONE;
|
||||
m_nCreatedBy = CREATED_BY_RANDOM;
|
||||
CharCreatedBy = RANDOM_CHAR;
|
||||
m_leader = nil;
|
||||
m_pedInObjective = nil;
|
||||
m_carInObjective = nil;
|
||||
@ -1341,13 +1341,13 @@ CPed::BeingDraggedFromCar(void)
|
||||
if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) {
|
||||
if (m_ped_flagF10) {
|
||||
enterAnim = ANIM_CAR_QJACKED;
|
||||
} else if (m_pMyVehicle->bIsLow) {
|
||||
} else if (m_pMyVehicle->bLowVehicle) {
|
||||
enterAnim = ANIM_CAR_LJACKED_LHS;
|
||||
} else {
|
||||
enterAnim = ANIM_CAR_JACKED_LHS;
|
||||
}
|
||||
} else if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) {
|
||||
if (m_pMyVehicle->bIsLow)
|
||||
if (m_pMyVehicle->bLowVehicle)
|
||||
enterAnim = ANIM_CAR_LJACKED_RHS;
|
||||
else
|
||||
enterAnim = ANIM_CAR_JACKED_RHS;
|
||||
@ -1470,7 +1470,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enter
|
||||
vehDoorOffset = offsetToOpenVanDoor;
|
||||
} else {
|
||||
seatOffset = veh->m_handling->fSeatOffsetDistance * seatPosMult;
|
||||
if (veh->bIsLow) {
|
||||
if (veh->bLowVehicle) {
|
||||
vehDoorOffset = offsetToOpenLowCarDoor;
|
||||
} else {
|
||||
vehDoorOffset = offsetToOpenRegularCarDoor;
|
||||
@ -2222,10 +2222,10 @@ CPed::CanBeDeleted(void)
|
||||
if (this->bInVehicle)
|
||||
return false;
|
||||
|
||||
switch (m_nCreatedBy) {
|
||||
case CREATED_BY_RANDOM:
|
||||
switch (CharCreatedBy) {
|
||||
case RANDOM_CHAR:
|
||||
return true;
|
||||
case CREATED_BY_SCRIPT:
|
||||
case MISSION_CHAR:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
@ -2521,7 +2521,7 @@ CPed::SetObjective(eObjective newObj, void *entity)
|
||||
m_vecSeekVehicle = CVector(0.0f, 0.0f, 0.0f);
|
||||
if (newObj == OBJECTIVE_SOLICIT) {
|
||||
m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 10000;
|
||||
} else if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && m_nCreatedBy == CREATED_BY_SCRIPT &&
|
||||
} else if (m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER && CharCreatedBy == MISSION_CHAR &&
|
||||
(m_carInObjective->m_status == STATUS_PLAYER_DISABLED || CPad::GetPad(CWorld::PlayerInFocus)->DisablePlayerControls)) {
|
||||
SetObjectiveTimer(14000);
|
||||
} else {
|
||||
|
@ -60,8 +60,8 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
CREATED_BY_RANDOM = 1,
|
||||
CREATED_BY_SCRIPT
|
||||
RANDOM_CHAR = 1,
|
||||
MISSION_CHAR,
|
||||
};
|
||||
|
||||
enum PedLineUpPhase {
|
||||
@ -130,15 +130,15 @@ enum PedState
|
||||
PED_PASSENGER,
|
||||
PED_TAXI_PASSENGER,
|
||||
PED_OPEN_DOOR,
|
||||
PED_DIE = 48,
|
||||
PED_DEAD = 49,
|
||||
PED_DIE,
|
||||
PED_DEAD,
|
||||
PED_CARJACK,
|
||||
PED_DRAG_FROM_CAR,
|
||||
PED_ENTER_CAR,
|
||||
PED_STEAL_CAR,
|
||||
PED_EXIT_CAR,
|
||||
PED_HANDS_UP,
|
||||
PED_ARRESTED = 56,
|
||||
PED_ARRESTED,
|
||||
};
|
||||
|
||||
enum eMoveState {
|
||||
@ -157,6 +157,8 @@ public:
|
||||
// 0x128
|
||||
CStoredCollPoly m_collPoly;
|
||||
float m_fCollisionSpeed;
|
||||
|
||||
// cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CPed.h from R*
|
||||
uint8 bIsStanding : 1;
|
||||
uint8 m_ped_flagA2 : 1;
|
||||
uint8 m_ped_flagA4 : 1; // stores (CTimer::GetTimeInMilliseconds() < m_lastHitTime)
|
||||
@ -177,7 +179,7 @@ public:
|
||||
|
||||
uint8 m_ped_flagC1 : 1;
|
||||
uint8 m_ped_flagC2 : 1;
|
||||
uint8 m_ped_flagC4 : 1;
|
||||
uint8 m_ped_flagC4 : 1; // false when in bus, bRenderPedInCar?
|
||||
uint8 m_ped_flagC8 : 1;
|
||||
uint8 m_ped_flagC10 : 1;
|
||||
uint8 m_ped_flagC20 : 1; // just left some body part?
|
||||
@ -237,8 +239,9 @@ public:
|
||||
uint8 m_ped_flagI20 : 1;
|
||||
uint8 m_ped_flagI40 : 1;
|
||||
uint8 m_ped_flagI80 : 1;
|
||||
|
||||
uint8 stuff10[3];
|
||||
uint8 m_nCreatedBy;
|
||||
uint8 CharCreatedBy;
|
||||
uint8 field_161;
|
||||
uint8 pad_162[2];
|
||||
eObjective m_objective;
|
||||
@ -487,6 +490,8 @@ public:
|
||||
inline CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; }
|
||||
inline CWeapon *GetWeapon(void) { return &m_weapons[m_currentWeapon]; }
|
||||
inline RwFrame *GetNodeFrame(int nodeId) { return m_pFrames[nodeId]->frame; }
|
||||
PedState GetPedState(void) { return m_nPedState; }
|
||||
void SetPedState(PedState state) { m_nPedState = state; }
|
||||
|
||||
// to make patching virtual functions possible
|
||||
void SetModelIndex_(uint32 mi) { CPed::SetModelIndex(mi); }
|
||||
|
@ -109,9 +109,9 @@ public:
|
||||
// Force actually means Impulse here
|
||||
void ApplyMoveForce(float jx, float jy, float jz);
|
||||
void ApplyMoveForce(const CVector &j) { ApplyMoveForce(j.x, j.y, j.z); }
|
||||
// v(x,y,z) is direction of force, p(x,y,z) is point relative to model center where force is applied
|
||||
void ApplyTurnForce(float jx, float jy, float jz, float rx, float ry, float rz);
|
||||
// v is direction of force, p is point relative to model center where force is applied
|
||||
// j(x,y,z) is direction of force, p(x,y,z) is point relative to model center where force is applied
|
||||
void ApplyTurnForce(float jx, float jy, float jz, float px, float py, float pz);
|
||||
// j is direction of force, p is point relative to model center where force is applied
|
||||
void ApplyTurnForce(const CVector &j, const CVector &p) { ApplyTurnForce(j.x, j.y, j.z, p.x, p.y, p.z); }
|
||||
void ApplyFrictionMoveForce(float jx, float jy, float jz);
|
||||
void ApplyFrictionMoveForce(const CVector &j) { ApplyFrictionMoveForce(j.x, j.y, j.z); }
|
||||
|
@ -1,9 +1,17 @@
|
||||
#include "common.h"
|
||||
#include "main.h"
|
||||
#include "patcher.h"
|
||||
#include "Timer.h"
|
||||
#include "Vehicle.h"
|
||||
#include "Pools.h"
|
||||
#include "HandlingMgr.h"
|
||||
#include "CarCtrl.h"
|
||||
#include "Population.h"
|
||||
#include "ModelIndices.h"
|
||||
#include "World.h"
|
||||
#include "Lights.h"
|
||||
#include "PointLights.h"
|
||||
#include "Renderer.h"
|
||||
#include "DMAudio.h"
|
||||
#include "Radar.h"
|
||||
|
||||
@ -40,30 +48,238 @@ CVehicle::~CVehicle()
|
||||
CCarCtrl::NumAmbulancesOnDuty--;
|
||||
bIsAmbulanceOnDuty = false;
|
||||
}
|
||||
if (bIsFiretruckOnDuty){
|
||||
if (bIsFireTruckOnDuty){
|
||||
CCarCtrl::NumFiretrucksOnDuty--;
|
||||
bIsFiretruckOnDuty = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::IsLawEnforcementVehicle(void)
|
||||
{
|
||||
switch (m_modelIndex) {
|
||||
case MI_FBICAR:
|
||||
case MI_POLICE:
|
||||
case MI_ENFORCER:
|
||||
case MI_PREDATOR:
|
||||
case MI_RHINO:
|
||||
case MI_BARRACKS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
bIsFireTruckOnDuty = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::ChangeLawEnforcerState(bool enable)
|
||||
CVehicle::SetModelIndex(uint32 id)
|
||||
{
|
||||
CEntity::SetModelIndex(id);
|
||||
m_aExtras[0] = CVehicleModelInfo::ms_compsUsed[0];
|
||||
m_aExtras[1] = CVehicleModelInfo::ms_compsUsed[1];
|
||||
m_nNumMaxPassengers = CVehicleModelInfo::GetMaximumNumberOfPassengersFromNumberOfDoors(id);
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::SetupLighting(void)
|
||||
{
|
||||
ActivateDirectional();
|
||||
SetAmbientColoursForPedsCarsAndObjects();
|
||||
|
||||
if(bRenderScorched){
|
||||
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
|
||||
}else{
|
||||
CVector coors = GetPosition();
|
||||
float lighting = CPointLights::GenerateLightsAffectingObject(&coors);
|
||||
if(!bHasBlip && lighting != 1.0f){
|
||||
SetAmbientAndDirectionalColours(lighting);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::RemoveLighting(bool reset)
|
||||
{
|
||||
CRenderer::RemoveVehiclePedLights(this, reset);
|
||||
}
|
||||
|
||||
float
|
||||
CVehicle::GetHeightAboveRoad(void)
|
||||
{
|
||||
return -1.0f * CModelInfo::GetModelInfo(GetModelIndex())->GetColModel()->boundingBox.min.z;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CVehicle::IsLawEnforcementVehicle(void)
|
||||
{
|
||||
switch(GetModelIndex()){
|
||||
case MI_FBICAR:
|
||||
case MI_POLICE:
|
||||
case MI_ENFORCER:
|
||||
case MI_PREDATOR:
|
||||
case MI_RHINO:
|
||||
case MI_BARRACKS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::UsesSiren(uint32 id)
|
||||
{
|
||||
switch(id){
|
||||
case MI_FIRETRUCK:
|
||||
case MI_AMBULAN:
|
||||
case MI_FBICAR:
|
||||
case MI_MRWHOOP:
|
||||
case MI_POLICE:
|
||||
case MI_ENFORCER:
|
||||
case MI_PREDATOR:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::IsVehicleNormal(void)
|
||||
{
|
||||
if(pDriver && m_nNumPassengers == 0 && m_status != STATUS_WRECKED){
|
||||
switch(GetModelIndex())
|
||||
case MI_FIRETRUCK:
|
||||
case MI_AMBULAN:
|
||||
case MI_TAXI:
|
||||
case MI_POLICE:
|
||||
case MI_ENFORCER:
|
||||
case MI_BUS:
|
||||
case MI_RHINO:
|
||||
case MI_BARRACKS:
|
||||
case MI_DODO:
|
||||
case MI_COACH:
|
||||
case MI_CABBIE:
|
||||
case MI_RCBANDIT:
|
||||
case MI_BORGNINE:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::CarHasRoof(void)
|
||||
{
|
||||
if((m_handling->Flags & HANDLING_HAS_NO_ROOF) == 0)
|
||||
return true;
|
||||
if(m_aExtras[0] && m_aExtras[1])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::IsUpsideDown(void)
|
||||
{
|
||||
if(GetUp().z > -0.9f)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::IsOnItsSide(void)
|
||||
{
|
||||
if(GetRight().z < 0.8f && GetRight().z > -0.8f)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::CanBeDeleted(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(m_nNumGettingIn || m_nGettingOutFlags)
|
||||
return false;
|
||||
|
||||
if(pDriver){
|
||||
// This looks like it was inlined
|
||||
if(pDriver->CharCreatedBy == MISSION_CHAR)
|
||||
return false;
|
||||
if(pDriver->GetPedState() != PED_DRIVING &&
|
||||
pDriver->GetPedState() != PED_DEAD)
|
||||
return false;
|
||||
}
|
||||
|
||||
for(i = 0; i < 8; i++){
|
||||
// Same check as above
|
||||
if(pPassengers[i]){
|
||||
if(pPassengers[i]->CharCreatedBy == MISSION_CHAR)
|
||||
return false;
|
||||
if(pPassengers[i]->GetPedState() != PED_DRIVING &&
|
||||
pPassengers[i]->GetPedState() != PED_DEAD)
|
||||
return false;
|
||||
}
|
||||
// and then again... probably because something was inlined
|
||||
if(pPassengers[i]){
|
||||
if(pPassengers[i]->GetPedState() != PED_DRIVING &&
|
||||
pPassengers[i]->GetPedState() != PED_DEAD)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
switch(VehicleCreatedBy){
|
||||
case RANDOM_VEHICLE: return true;
|
||||
case MISSION_VEHICLE: return false;
|
||||
case PARKED_VEHICLE: return true;
|
||||
case PERMANENT_VEHICLE: return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::CanPedOpenLocks(CPed *ped)
|
||||
{
|
||||
if(m_nDoorLock == CARLOCK_LOCKED ||
|
||||
m_nDoorLock == CARLOCK_COP_CAR ||
|
||||
m_nDoorLock == CARLOCK_LOCKED_PLAYER_INSIDE)
|
||||
return false;
|
||||
if(ped->IsPlayer() && m_nDoorLock == CARLOCK_LOCKOUT_PLAYER_ONLY)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::CanPedEnterCar(void)
|
||||
{
|
||||
CVector up = GetUp();
|
||||
// can't enter when car is on side
|
||||
if(up.z > 0.1f || up.z < -0.1f){
|
||||
// also when car is moving too fast
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() > sq(0.2f))
|
||||
return false;
|
||||
if(m_vecTurnSpeed.MagnitudeSqr() > sq(0.2f))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::CanPedExitCar(void)
|
||||
{
|
||||
CVector up = GetUp();
|
||||
if(up.z > 0.1f || up.z < -0.1f){
|
||||
// can't exit when car is moving too fast
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() > 0.005f)
|
||||
return false;
|
||||
// if car is slow enough, check turn speed
|
||||
if(fabs(m_vecTurnSpeed.x) > 0.01f ||
|
||||
fabs(m_vecTurnSpeed.y) > 0.01f ||
|
||||
fabs(m_vecTurnSpeed.z) > 0.01f)
|
||||
return false;
|
||||
return true;
|
||||
}else{
|
||||
// What is this? just > replaced by >= ??
|
||||
|
||||
// can't exit when car is moving too fast
|
||||
if(m_vecMoveSpeed.MagnitudeSqr() >= 0.005f)
|
||||
return false;
|
||||
// if car is slow enough, check turn speed
|
||||
if(fabs(m_vecTurnSpeed.x) >= 0.01f ||
|
||||
fabs(m_vecTurnSpeed.y) >= 0.01f ||
|
||||
fabs(m_vecTurnSpeed.z) >= 0.01f)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::ChangeLawEnforcerState(uint8 enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (!bIsLawEnforcer) {
|
||||
@ -78,6 +294,111 @@ CVehicle::ChangeLawEnforcerState(bool enable)
|
||||
}
|
||||
}
|
||||
|
||||
CPed*
|
||||
CVehicle::SetUpDriver(void)
|
||||
{
|
||||
if(pDriver)
|
||||
return pDriver;
|
||||
if(VehicleCreatedBy != RANDOM_VEHICLE)
|
||||
return nil;
|
||||
|
||||
pDriver = CPopulation::AddPedInCar(this);
|
||||
pDriver->m_pMyVehicle = this;
|
||||
pDriver->m_pMyVehicle->RegisterReference((CEntity**)&pDriver->m_pMyVehicle);
|
||||
pDriver->bInVehicle = true;
|
||||
pDriver->SetPedState(PED_DRIVING);
|
||||
if(bIsBus)
|
||||
pDriver->m_ped_flagC4 = false;
|
||||
return pDriver;
|
||||
}
|
||||
|
||||
CPed*
|
||||
CVehicle::SetupPassenger(int n)
|
||||
{
|
||||
if(pPassengers[n])
|
||||
return pPassengers[n];
|
||||
|
||||
pPassengers[n] = CPopulation::AddPedInCar(this);
|
||||
pPassengers[n]->m_pMyVehicle = this;
|
||||
pPassengers[n]->m_pMyVehicle->RegisterReference((CEntity**)&pPassengers[n]->m_pMyVehicle);
|
||||
pPassengers[n]->bInVehicle = true;
|
||||
pPassengers[n]->SetPedState(PED_DRIVING);
|
||||
if(bIsBus)
|
||||
pPassengers[n]->m_ped_flagC4 = false;
|
||||
return pPassengers[n];
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::SetDriver(CPed *driver)
|
||||
{
|
||||
pDriver = driver;
|
||||
pDriver->RegisterReference((CEntity**)&pDriver);
|
||||
|
||||
if(bFreebies && driver == FindPlayerPed()){
|
||||
if(GetModelIndex() == MI_AMBULAN)
|
||||
FindPlayerPed()->m_fHealth = min(FindPlayerPed()->m_fHealth + 20.0f, 100.0f);
|
||||
else if(GetModelIndex() == MI_TAXI)
|
||||
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25;
|
||||
else if(GetModelIndex() == MI_POLICE)
|
||||
driver->GiveWeapon(WEAPONTYPE_SHOTGUN, 5);
|
||||
else if(GetModelIndex() == MI_ENFORCER)
|
||||
driver->m_fArmour = max(driver->m_fArmour, 100.0f);
|
||||
else if(GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE)
|
||||
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25;
|
||||
bFreebies = false;
|
||||
}
|
||||
|
||||
ApplyTurnForce(0.0f, 0.0f, -0.2f*driver->m_fMass,
|
||||
driver->GetPosition().x - GetPosition().x,
|
||||
driver->GetPosition().y - GetPosition().y,
|
||||
0.0f);
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::AddPassenger(CPed *passenger)
|
||||
{
|
||||
int i;
|
||||
|
||||
ApplyTurnForce(0.0f, 0.0f, -0.2f*passenger->m_fMass,
|
||||
passenger->GetPosition().x - GetPosition().x,
|
||||
passenger->GetPosition().y - GetPosition().y,
|
||||
0.0f);
|
||||
|
||||
for(i = 0; i < m_nNumMaxPassengers; i++)
|
||||
if(pPassengers[i] == nil){
|
||||
pPassengers[i] = passenger;
|
||||
m_nNumPassengers++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::AddPassenger(CPed *passenger, uint8 n)
|
||||
{
|
||||
if(bIsBus)
|
||||
return AddPassenger(passenger);
|
||||
|
||||
ApplyTurnForce(0.0f, 0.0f, -0.2f*passenger->m_fMass,
|
||||
passenger->GetPosition().x - GetPosition().x,
|
||||
passenger->GetPosition().y - GetPosition().y,
|
||||
0.0f);
|
||||
|
||||
if(n < m_nNumMaxPassengers && pPassengers[n] == nil){
|
||||
pPassengers[n] = passenger;
|
||||
m_nNumPassengers++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::RemoveDriver(void)
|
||||
{
|
||||
m_status = STATUS_ABANDONED;
|
||||
pDriver = nil;
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::RemovePassenger(CPed *p)
|
||||
{
|
||||
@ -101,19 +422,68 @@ CVehicle::RemovePassenger(CPed *p)
|
||||
}
|
||||
|
||||
void
|
||||
CVehicle::RemoveDriver(void)
|
||||
CVehicle::ProcessCarAlarm(void)
|
||||
{
|
||||
m_status = STATUS_ABANDONED;
|
||||
pDriver = nil;
|
||||
uint32 step;
|
||||
|
||||
if(m_nAlarmState == 0 || m_nAlarmState == -1)
|
||||
return;
|
||||
|
||||
step = CTimer::GetTimeStep()/50.0f * 1000.0f;
|
||||
if((uint16)m_nAlarmState < step)
|
||||
m_nAlarmState = 0;
|
||||
else
|
||||
m_nAlarmState -= step;
|
||||
}
|
||||
|
||||
bool
|
||||
CVehicle::IsUpsideDown(void)
|
||||
CVehicle::IsSphereTouchingVehicle(float sx, float sy, float sz, float radius)
|
||||
{
|
||||
return GetUp().z <= -0.9f;
|
||||
float x, y, z;
|
||||
// sphere relative to vehicle
|
||||
CVector sph = CVector(sx, sy, sz) - GetPosition();
|
||||
CColModel *colmodel = CModelInfo::GetModelInfo(GetModelIndex())->GetColModel();
|
||||
|
||||
x = DotProduct(sph, GetRight());
|
||||
if(colmodel->boundingBox.min.x - radius > x ||
|
||||
colmodel->boundingBox.max.x + radius < x)
|
||||
return false;
|
||||
y = DotProduct(sph, GetForward());
|
||||
if(colmodel->boundingBox.min.y - radius > y ||
|
||||
colmodel->boundingBox.max.y + radius < y)
|
||||
return false;
|
||||
z = DotProduct(sph, GetUp());
|
||||
if(colmodel->boundingBox.min.z - radius > z ||
|
||||
colmodel->boundingBox.max.z + radius < z)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
STARTPATCHES
|
||||
InjectHook(0x551170, &CVehicle::SetModelIndex_, PATCH_JUMP);
|
||||
InjectHook(0x4A7DD0, &CVehicle::SetupLighting_, PATCH_JUMP);
|
||||
InjectHook(0x4A7E60, &CVehicle::RemoveLighting_, PATCH_JUMP);
|
||||
InjectHook(0x417E60, &CVehicle::GetHeightAboveRoad_, PATCH_JUMP);
|
||||
|
||||
InjectHook(0x552880, &CVehicle::IsLawEnforcementVehicle, PATCH_JUMP);
|
||||
InjectHook(0x552820, &CVehicle::ChangeLawEnforcerState, PATCH_JUMP);
|
||||
InjectHook(0x552200, &CVehicle::UsesSiren, PATCH_JUMP);
|
||||
InjectHook(0x5527E0, &CVehicle::IsVehicleNormal, PATCH_JUMP);
|
||||
InjectHook(0x552B70, &CVehicle::CarHasRoof, PATCH_JUMP);
|
||||
InjectHook(0x552230, &CVehicle::IsUpsideDown, PATCH_JUMP);
|
||||
InjectHook(0x552260, &CVehicle::IsOnItsSide, PATCH_JUMP);
|
||||
InjectHook(0x5511B0, &CVehicle::CanBeDeleted, PATCH_JUMP);
|
||||
InjectHook(0x5522A0, &CVehicle::CanPedOpenLocks, PATCH_JUMP);
|
||||
InjectHook(0x5522F0, &CVehicle::CanPedEnterCar, PATCH_JUMP);
|
||||
InjectHook(0x5523C0, &CVehicle::CanPedExitCar, PATCH_JUMP);
|
||||
InjectHook(0x5520C0, &CVehicle::SetUpDriver, PATCH_JUMP);
|
||||
InjectHook(0x552160, &CVehicle::SetupPassenger, PATCH_JUMP);
|
||||
InjectHook(0x551F20, &CVehicle::SetDriver, PATCH_JUMP);
|
||||
InjectHook(0x551D90, (bool (CVehicle::*)(CPed*))&CVehicle::AddPassenger, PATCH_JUMP);
|
||||
InjectHook(0x551E10, (bool (CVehicle::*)(CPed*,uint8))&CVehicle::AddPassenger, PATCH_JUMP);
|
||||
InjectHook(0x5520A0, &CVehicle::RemoveDriver, PATCH_JUMP);
|
||||
InjectHook(0x551EB0, &CVehicle::RemovePassenger, PATCH_JUMP);
|
||||
InjectHook(0x5525A0, &CVehicle::ProcessCarAlarm, PATCH_JUMP);
|
||||
InjectHook(0x552620, &CVehicle::IsSphereTouchingVehicle, PATCH_JUMP);
|
||||
ENDPATCHES
|
@ -6,6 +6,14 @@ class CPed;
|
||||
class CFire;
|
||||
struct tHandlingData;
|
||||
|
||||
enum {
|
||||
RANDOM_VEHICLE = 1,
|
||||
MISSION_VEHICLE = 2,
|
||||
PARKED_VEHICLE = 3,
|
||||
PERMANENT_VEHICLE = 4,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
GETTING_IN_OUT_FL = 1,
|
||||
GETTING_IN_OUT_RL = 2,
|
||||
@ -13,7 +21,7 @@ enum {
|
||||
GETTING_IN_OUT_RR = 8
|
||||
};
|
||||
|
||||
enum eCarLock : uint8 {
|
||||
enum eCarLock {
|
||||
CARLOCK_NOT_USED,
|
||||
CARLOCK_UNLOCKED,
|
||||
CARLOCK_LOCKED,
|
||||
@ -24,15 +32,21 @@ enum eCarLock : uint8 {
|
||||
CARLOCK_SKIP_SHUT_DOORS
|
||||
};
|
||||
|
||||
enum eDoors {
|
||||
};
|
||||
|
||||
class CVehicle : public CPhysical
|
||||
{
|
||||
public:
|
||||
// 0x128
|
||||
tHandlingData *m_handling;
|
||||
|
||||
// CAutoPilot
|
||||
uint8 stuff1[112];
|
||||
|
||||
uint8 m_currentColour1;
|
||||
uint8 m_currentColour2;
|
||||
uint8 m_anExtras[2];
|
||||
uint8 m_aExtras[2];
|
||||
int16 m_nAlarmState; // m_nWantedStarsOnEnter on DK22
|
||||
int16 m_nMissionValue;
|
||||
CPed *pDriver;
|
||||
@ -48,23 +62,27 @@ public:
|
||||
float m_fSteerAngle;
|
||||
float m_fGasPedal;
|
||||
float m_fBreakPedal;
|
||||
uint8 m_nCreatedBy; // eVehicleCreatedBy
|
||||
uint8 bIsLawEnforcer : 1;
|
||||
uint8 bIsAmbulanceOnDuty : 1;
|
||||
uint8 bIsFiretruckOnDuty : 1;
|
||||
uint8 m_veh_flagA8 : 1;
|
||||
uint8 m_veh_flagA10 : 1;
|
||||
uint8 m_veh_flagA20 : 1;
|
||||
uint8 m_veh_flagA40 : 1;
|
||||
uint8 m_veh_flagA80 : 1;
|
||||
uint8 bIsVan : 1;
|
||||
uint8 bIsBus : 1;
|
||||
uint8 bIsBig : 1;
|
||||
uint8 bIsLow : 1;
|
||||
uint8 VehicleCreatedBy;
|
||||
|
||||
// cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CVehicle.h from R*
|
||||
uint8 bIsLawEnforcer: 1; // Is this guy chasing the player at the moment
|
||||
uint8 bIsAmbulanceOnDuty: 1; // Ambulance trying to get to an accident
|
||||
uint8 bIsFireTruckOnDuty: 1; // Firetruck trying to get to a fire
|
||||
uint8 bIsLocked: 1; // Is this guy locked by the script (cannot be removed)
|
||||
uint8 bEngineOn: 1; // For sound purposes. Parked cars have their engines switched off (so do destroyed cars)
|
||||
uint8 bIsHandbrakeOn: 1; // How's the handbrake doing ?
|
||||
uint8 bLightsOn: 1; // Are the lights switched on ?
|
||||
uint8 bFreebies: 1; // Any freebies left in this vehicle ?
|
||||
|
||||
uint8 bIsVan: 1; // Is this vehicle a van (doors at back of vehicle)
|
||||
uint8 bIsBus: 1; // Is this vehicle a bus
|
||||
uint8 bIsBig: 1; // Is this vehicle a bus
|
||||
uint8 bLowVehicle: 1; // Need this for sporty type cars to use low getting-in/out anims
|
||||
uint8 m_veh_flagB10 : 1;
|
||||
uint8 m_veh_flagB20 : 1;
|
||||
uint8 m_veh_flagB40 : 1;
|
||||
uint8 m_veh_flagB80 : 1;
|
||||
|
||||
uint8 m_veh_flagC1 : 1;
|
||||
uint8 m_veh_flagC2 : 1;
|
||||
uint8 m_veh_flagC4 : 1;
|
||||
@ -73,6 +91,7 @@ public:
|
||||
uint8 m_veh_flagC20 : 1;
|
||||
uint8 m_veh_flagC40 : 1;
|
||||
uint8 m_veh_flagC80 : 1;
|
||||
|
||||
uint8 m_veh_flagD1 : 1;
|
||||
uint8 m_veh_flagD2 : 1;
|
||||
uint8 m_veh_flagD4 : 1;
|
||||
@ -81,8 +100,9 @@ public:
|
||||
uint8 m_veh_flagD20 : 1;
|
||||
uint8 m_veh_flagD40 : 1;
|
||||
uint8 m_veh_flagD80 : 1;
|
||||
|
||||
int8 field_1F9;
|
||||
uint8 m_nAmmoInClip[1]; // Used to make the guns on boat do a reload (20 by default)
|
||||
uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default)
|
||||
int8 field_1FB;
|
||||
int8 field_1FC[4];
|
||||
float m_fHealth; // 1000.0f = full health. 0 -> explode
|
||||
@ -105,6 +125,7 @@ public:
|
||||
int8 field_22D;
|
||||
uint8 m_nSirenOrAlarm;
|
||||
int8 field_22F;
|
||||
// TODO: this is an array
|
||||
CStoredCollPoly m_frontCollPoly; // poly which is under front part of car
|
||||
CStoredCollPoly m_rearCollPoly; // poly which is under rear part of car
|
||||
float m_fSteerRatio;
|
||||
@ -116,8 +137,29 @@ public:
|
||||
static void operator delete(void*, int);
|
||||
|
||||
~CVehicle(void);
|
||||
// from CEntity
|
||||
void SetModelIndex(uint32 i);
|
||||
bool SetupLighting(void);
|
||||
void RemoveLighting(bool);
|
||||
void FlagToDestroyWhenNextProcessed(void) {}
|
||||
|
||||
void dtor(void) { this->CVehicle::~CVehicle(); }
|
||||
virtual void ProcessControlInputs(uint8) {}
|
||||
virtual void GetComponentWorldPosition(int32 component, CVector &pos) {}
|
||||
virtual bool IsComponentPresent(int32 component) { return false; }
|
||||
virtual void SetComponentRotation(int32 component, CVector rotation) {}
|
||||
virtual void OpenDoor(int32, eDoors door, float) {}
|
||||
virtual void ProcessOpenDoor(uint32, uint32, float) {}
|
||||
virtual bool IsDoorReady(eDoors door) { return false; }
|
||||
virtual bool IsDoorFullyOpen(eDoors door) { return false; }
|
||||
virtual bool IsDoorClosed(eDoors door) { return false; }
|
||||
virtual bool IsDoorMissing(eDoors door) { return false; }
|
||||
virtual void RemoveRefsToVehicle(CEntity *ent) {}
|
||||
virtual void BlowUpCar(CEntity *ent) {}
|
||||
virtual bool SetUpWheelColModel(CColModel *colModel) { return false; }
|
||||
virtual void BurstTyre(uint8 tyre) {}
|
||||
virtual bool IsRoomForPedToLeaveCar(uint32, CVector *) { return false;}
|
||||
virtual float GetHeightAboveRoad(void);
|
||||
virtual void PlayCarHorn(void) {}
|
||||
|
||||
bool IsCar(void) { return m_vehType == VEHICLE_TYPE_CAR; }
|
||||
bool IsBoat(void) { return m_vehType == VEHICLE_TYPE_BOAT; }
|
||||
@ -125,10 +167,26 @@ public:
|
||||
bool IsHeli(void) { return m_vehType == VEHICLE_TYPE_HELI; }
|
||||
bool IsPlane(void) { return m_vehType == VEHICLE_TYPE_PLANE; }
|
||||
bool IsLawEnforcementVehicle(void);
|
||||
void ChangeLawEnforcerState(bool enable);
|
||||
void RemovePassenger(CPed *);
|
||||
void RemoveDriver(void);
|
||||
void ChangeLawEnforcerState(uint8 enable);
|
||||
bool UsesSiren(uint32 id);
|
||||
bool IsVehicleNormal(void);
|
||||
bool CarHasRoof(void);
|
||||
bool IsUpsideDown(void);
|
||||
bool IsOnItsSide(void);
|
||||
bool CanBeDeleted(void);
|
||||
bool CanPedOpenLocks(CPed *ped);
|
||||
bool CanPedEnterCar(void);
|
||||
bool CanPedExitCar(void);
|
||||
// do these two actually return something?
|
||||
CPed *SetUpDriver(void);
|
||||
CPed *SetupPassenger(int n);
|
||||
void SetDriver(CPed *driver);
|
||||
bool AddPassenger(CPed *passenger);
|
||||
bool AddPassenger(CPed *passenger, uint8 n);
|
||||
void RemovePassenger(CPed *passenger);
|
||||
void RemoveDriver(void);
|
||||
void ProcessCarAlarm(void);
|
||||
bool IsSphereTouchingVehicle(float sx, float sy, float sz, float radius);
|
||||
|
||||
static bool &bWheelsOnlyCheat;
|
||||
static bool &bAllDodosCheat;
|
||||
@ -136,8 +194,16 @@ public:
|
||||
static bool &bCheat4;
|
||||
static bool &bCheat5;
|
||||
static bool &m_bDisableMouseSteering;
|
||||
|
||||
|
||||
void dtor(void) { CVehicle::~CVehicle(); }
|
||||
void SetModelIndex_(uint32 id) { CVehicle::SetModelIndex(id); }
|
||||
bool SetupLighting_(void) { return CVehicle::SetupLighting(); }
|
||||
void RemoveLighting_(bool reset) { CVehicle::RemoveLighting(reset); }
|
||||
float GetHeightAboveRoad_(void) { return CVehicle::GetHeightAboveRoad(); }
|
||||
};
|
||||
|
||||
static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error");
|
||||
static_assert(offsetof(CVehicle, m_pCurSurface) == 0x1E0, "CVehicle: error");
|
||||
static_assert(offsetof(CVehicle, m_nAlarmState) == 0x1A0, "CVehicle: error");
|
||||
static_assert(offsetof(CVehicle, m_nLastWeaponDamage) == 0x228, "CVehicle: error");
|
||||
|
@ -250,10 +250,9 @@ enum
|
||||
MI_BUSKER2,
|
||||
MI_BUSKER3,
|
||||
MI_BUSKER4,
|
||||
MI_PED87,
|
||||
MI_PED88,
|
||||
MI_PED89,
|
||||
MI_LANDSTAL,
|
||||
// three more peds possible
|
||||
|
||||
MI_LANDSTAL = 90,
|
||||
MI_IDAHO,
|
||||
MI_STINGER,
|
||||
MI_LINERUN,
|
||||
|
Loading…
Reference in New Issue
Block a user