1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 16:00:02 +00:00

Merge pull request #204 from erorcun/erorcun

World and Peds
This commit is contained in:
aap 2019-09-12 10:08:15 +02:00 committed by GitHub
commit 4299e307d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 505 additions and 17 deletions

View file

@ -34,6 +34,7 @@ CAnimBlendAssociation *RpAnimBlendClumpGetMainAssociation_N(RpClump *clump, int
CAnimBlendAssociation *RpAnimBlendClumpGetMainPartialAssociation_N(RpClump *clump, int n);
CAnimBlendAssociation *RpAnimBlendClumpGetFirstAssociation(RpClump *clump, uint32 mask);
CAnimBlendAssociation *RpAnimBlendClumpGetFirstAssociation(RpClump *clump);
void RpAnimBlendClumpUpdateAnimations(RpClump* clump, float timeDelta);
extern CAnimBlendClumpData *&gpAnimBlendClump;

View file

@ -1,6 +1,8 @@
#include "common.h"
#include "patcher.h"
#include "Game.h"
#include "World.h"
#include "Entity.h"
#include "Population.h"
PedGroup *CPopulation::ms_pPedGroups = (PedGroup*)0x6E9248;
@ -14,3 +16,10 @@ 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); }
WRAPPER bool CPopulation::IsPointInSafeZone(CVector *coors) { EAXJMP(0x4F60C0); }
void
CPopulation::RemovePed(CEntity* ent)
{
CWorld::Remove(ent);
delete ent;
}

View file

@ -24,4 +24,5 @@ public:
static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool);
static CPed *AddPedInCar(CVehicle *vehicle);
static bool IsPointInSafeZone(CVector *coors);
static void RemovePed(CEntity* ent);
};

View file

@ -1,6 +1,10 @@
#include "common.h"
#include "patcher.h"
#include "Record.h"
uint16 &CRecordDataForGame::RecordingState = *(uint16*)0x95CC24;
uint8 &CRecordDataForChase::Status = *(uint8*)0x95CDCE;
WRAPPER void CRecordDataForChase::ProcessControlCars(void) { EAXJMP(0x435540); }
WRAPPER void CRecordDataForChase::SaveOrRetrieveCarPositions(void) { EAXJMP(0x434B20); }

View file

@ -6,14 +6,18 @@ enum {
RECORDSTATE_2,
};
class CRecordDataForChase
{
public:
static uint8 &Status;
static void ProcessControlCars(void);
static void SaveOrRetrieveCarPositions(void);
};
class CRecordDataForGame
{
public:
static uint16 &RecordingState;
};
class CRecordDataForChase
{
public:
static uint8 &Status;
};

View file

@ -5,3 +5,4 @@
bool &CCutsceneMgr::ms_running = *(bool*)0x95CCF5;
bool &CCutsceneMgr::ms_cutsceneProcessing = *(bool*)0x95CD9F;
CDirectory *&CCutsceneMgr::ms_pCutsceneDir = *(CDirectory**)0x8F5F88;
CCutsceneObject *(&CCutsceneMgr::ms_pCutsceneObjects)[NUMCUTSCENEOBJECTS] = *(CCutsceneObject*(*)[NUMCUTSCENEOBJECTS]) *(uintptr*) 0x862170;

View file

@ -1,4 +1,5 @@
#pragma once
#include "CutsceneObject.h"
class CDirectory;
@ -6,10 +7,12 @@ class CCutsceneMgr
{
static bool &ms_running;
static bool &ms_cutsceneProcessing;
static CCutsceneObject *(&ms_pCutsceneObjects)[NUMCUTSCENEOBJECTS];
public:
static CDirectory *&ms_pCutsceneDir;
static bool IsRunning(void) { return ms_running; }
static bool IsCutsceneProcessing(void) { return ms_cutsceneProcessing; }
static CCutsceneObject* GetCutsceneObject(int id) { return ms_pCutsceneObjects[id]; }
};

View file

@ -15,6 +15,7 @@ WRAPPER void CMessages::AddMessageJumpQ(wchar* key, uint32 time, uint16 pos) { E
WRAPPER void CMessages::AddMessageSoon(wchar* key, uint32 time, uint16 pos) { EAXJMP(0x529AF0); }
WRAPPER void CMessages::ClearMessages() { EAXJMP(0x529CE0); }
WRAPPER void CMessages::Init() { EAXJMP(0x529310); }
WRAPPER void CMessages::Process() { EAXJMP(0x529580); }
tPreviousBrief *CMessages::PreviousBriefs = (tPreviousBrief *)0x713C08;
tMessage *CMessages::BriefMessages = (tMessage *)0x8786E0;
tBigMessage *CMessages::BIGMessages = (tBigMessage *)0x773628;

View file

@ -47,4 +47,5 @@ public:
static void AddMessageSoon(wchar* key, uint32 time, uint16 pos);
static void ClearMessages();
static void Init();
static void Process();
};

View file

@ -8,6 +8,7 @@
WRAPPER void CPlayerInfo::MakePlayerSafe(bool) { EAXJMP(0x4A1400); }
WRAPPER void CPlayerInfo::LoadPlayerSkin() { EAXJMP(0x4A1700); }
WRAPPER void CPlayerInfo::AwardMoneyForExplosion(CVehicle *vehicle) { EAXJMP(0x4A15F0); }
WRAPPER void CPlayerInfo::Process(void) { EAXJMP(0x49FD30); }
void CPlayerInfo::SetPlayerSkin(char *skin)
{

View file

@ -71,6 +71,7 @@ public:
void AwardMoneyForExplosion(CVehicle *vehicle);
void SetPlayerSkin(char* skin);
CVector& GetPos();
void Process(void);
};
static_assert(sizeof(CPlayerInfo) == 0x13C, "CPlayerInfo: error");

View file

@ -12,6 +12,13 @@
#include "TempColModels.h"
#include "World.h"
#include "ModelIndices.h"
#include "References.h"
#include "CutsceneMgr.h"
#include "Record.h"
#include "RpAnimBlend.h"
#include "Messages.h"
#include "Replay.h"
#include "Population.h"
CPtrList *CWorld::ms_bigBuildingsList = (CPtrList*)0x6FAB60;
CPtrList &CWorld::ms_listMovingEntityPtrs = *(CPtrList*)0x8F433C;
@ -31,7 +38,6 @@ bool &CWorld::bProcessCutsceneOnly = *(bool*)0x95CD8B;
bool &CWorld::bDoingCarCollisions = *(bool*)0x95CD8C;
bool &CWorld::bIncludeCarTyres = *(bool*)0x95CDAA;
WRAPPER void CWorld::Process(void) { EAXJMP(0x4B1A60); }
WRAPPER void CWorld::ShutDown(void) { EAXJMP(0x4AE450); }
WRAPPER void CWorld::RemoveReferencesToDeletedObject(CEntity*) { EAXJMP(0x4B3BF0); }
WRAPPER void CWorld::FindObjectsKindaColliding(const CVector &, float, bool, int16*, int16, CEntity **, bool, bool, bool, bool, bool){ EAXJMP(0x4B2A30); }
@ -930,6 +936,244 @@ FindPlayerHeading(void)
return CWorld::Players[CWorld::PlayerInFocus].m_pPed->GetForward().Heading();
}
void
CWorld::RemoveEntityInsteadOfProcessingIt(CEntity* ent)
{
if (ent->IsPed()) {
if (FindPlayerPed() == ent)
CWorld::Remove(ent);
else
CPopulation::RemovePed(ent);
} else {
CWorld::Remove(ent);
delete ent;
}
}
void
CWorld::RemoveFallenPeds(void)
{
int poolSize = CPools::GetPedPool()->GetSize();
for(int poolIndex = poolSize-1; poolIndex >= 0; poolIndex--) {
CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex);
if (ped) {
if (ped->GetPosition().z < -100.0f) {
if (ped->CharCreatedBy != RANDOM_CHAR || ped->IsPlayer()) {
int closestNode = ThePaths.FindNodeClosestToCoors(ped->GetPosition(), PATH_PED, 999999.9f, false, false);
CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
newPos.z += 2.0f;
ped->Teleport(newPos);
ped->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
} else {
CPopulation::RemovePed(ped);
}
}
}
}
}
void
CWorld::RemoveFallenCars(void)
{
int poolSize = CPools::GetVehiclePool()->GetSize();
for (int poolIndex = poolSize - 1; poolIndex >= 0; poolIndex--) {
CVehicle* veh = CPools::GetVehiclePool()->GetSlot(poolIndex);
if (veh) {
if (veh->GetPosition().z < -100.0f) {
if (veh->VehicleCreatedBy == MISSION_VEHICLE || veh == FindPlayerVehicle() || (veh->pDriver && veh->pDriver->IsPlayer())) {
int closestNode = ThePaths.FindNodeClosestToCoors(veh->GetPosition(), PATH_CAR, 999999.9f, false, false);
CVector newPos = ThePaths.m_pathNodes[closestNode].pos;
newPos.z += 3.0f;
veh->Teleport(newPos);
veh->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
} else if (veh->VehicleCreatedBy == RANDOM_VEHICLE || veh->VehicleCreatedBy == PARKED_VEHICLE) {
CWorld::Remove(veh);
delete veh;
}
}
}
}
}
void
CWorld::Process(void)
{
if (!(CTimer::GetFrameCounter() & 63))
CReferences::PruneAllReferencesInWorld();
if (CWorld::bProcessCutsceneOnly) {
for (int i = 0; i < NUMCUTSCENEOBJECTS; i++) {
CCutsceneObject *csObj = CCutsceneMgr::GetCutsceneObject(i);
if (csObj && csObj->m_entryInfoList.first) {
if (csObj->m_rwObject && RwObjectGetType(csObj->m_rwObject) == rpCLUMP
&& RpAnimBlendClumpGetFirstAssociation(csObj->GetClump())) {
RpAnimBlendClumpUpdateAnimations(csObj->GetClump(), 0.02f * (csObj->m_type == ENTITY_TYPE_OBJECT ? CTimer::GetTimeStepNonClipped() : CTimer::GetTimeStep()));
}
csObj->ProcessControl();
csObj->ProcessCollision();
csObj->GetMatrix().UpdateRW();
csObj->UpdateRwFrame();
}
}
CRecordDataForChase::ProcessControlCars();
CRecordDataForChase::SaveOrRetrieveCarPositions();
} else {
for (CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity*)node->item;
if (movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP
&& RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), 0.02f * (movingEnt->m_type == ENTITY_TYPE_OBJECT ? CTimer::GetTimeStepNonClipped() : CTimer::GetTimeStep()));
}
}
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CPhysical* movingEnt = (CPhysical*)node->item;
if (movingEnt->bRemoveFromWorld) {
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else {
movingEnt->ProcessControl();
if (movingEnt->bIsStatic) {
movingEnt->RemoveFromMovingList();
}
}
}
CWorld::bForceProcessControl = 1;
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CPhysical* movingEnt = (CPhysical*)node->item;
if (movingEnt->bWasPostponed) {
if (movingEnt->bRemoveFromWorld) {
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else {
movingEnt->ProcessControl();
if (movingEnt->bIsStatic) {
movingEnt->RemoveFromMovingList();
}
}
}
}
CWorld::bForceProcessControl = 0;
if (CReplay::IsPlayingBack()) {
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity* movingEnt = (CEntity*)node->item;
movingEnt->bIsInSafePosition = true;
movingEnt->GetMatrix().UpdateRW();
movingEnt->UpdateRwFrame();
}
} else {
CWorld::bNoMoreCollisionTorque = 0;
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity* movingEnt = (CEntity*)node->item;
if (!movingEnt->bIsInSafePosition) {
movingEnt->ProcessCollision();
movingEnt->GetMatrix().UpdateRW();
movingEnt->UpdateRwFrame();
}
}
CWorld::bNoMoreCollisionTorque = 1;
for (int i = 0; i < 4; i++) {
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity* movingEnt = (CEntity*)node->item;
if (!movingEnt->bIsInSafePosition) {
movingEnt->ProcessCollision();
movingEnt->GetMatrix().UpdateRW();
movingEnt->UpdateRwFrame();
}
}
}
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity* movingEnt = (CEntity*)node->item;
if (!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
movingEnt->ProcessCollision();
movingEnt->GetMatrix().UpdateRW();
movingEnt->UpdateRwFrame();
if (!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
}
}
}
CWorld::bSecondShift = 0;
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity* movingEnt = (CEntity*)node->item;
if (!movingEnt->bIsInSafePosition) {
movingEnt->ProcessShift();
movingEnt->GetMatrix().UpdateRW();
movingEnt->UpdateRwFrame();
if (!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
}
}
}
CWorld::bSecondShift = 1;
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CPhysical* movingEnt = (CPhysical*)node->item;
if (!movingEnt->bIsInSafePosition) {
movingEnt->ProcessShift();
movingEnt->GetMatrix().UpdateRW();
movingEnt->UpdateRwFrame();
if (!movingEnt->bIsInSafePosition) {
movingEnt->bIsStuck = true;
if (movingEnt->m_status == STATUS_PLAYER) {
printf("STUCK: Final Step: Player Entity %d Is Stuck\n", movingEnt->m_modelIndex);
movingEnt->m_vecMoveSpeed *= 3.0f;
movingEnt->ApplyMoveSpeed();
movingEnt->ApplyTurnSpeed();
}
}
}
}
}
for (CPtrNode* node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CPed* movingPed = (CPed*)node->item;
if (movingPed->IsPed()) {
if (movingPed->bInVehicle && movingPed->m_nPedState != PED_EXIT_TRAIN
|| movingPed->m_nPedState == PED_ENTER_CAR || movingPed->m_nPedState == PED_CARJACK) {
CVehicle *movingCar = movingPed->m_pMyVehicle;
if (movingCar) {
if (movingCar->IsTrain()) {
movingPed->SetPedPositionInTrain();
} else {
switch (movingPed->m_nPedState) {
case PED_ENTER_CAR:
case PED_CARJACK:
movingPed->EnterCar();
break;
case PED_DRAG_FROM_CAR:
movingPed->BeingDraggedFromCar();
break;
case PED_EXIT_CAR:
movingPed->ExitCar();
break;
case PED_ARRESTED:
if (movingPed->m_nLastPedState == PED_DRAG_FROM_CAR) {
movingPed->BeingDraggedFromCar();
break;
}
// fall through
default:
movingPed->SetPedPositionInCar();
break;
}
}
movingPed->GetMatrix().UpdateRW();
movingPed->UpdateRwFrame();
} else {
movingPed->bInVehicle = false;
movingPed->QuitEnteringCar();
}
}
}
}
CMessages::Process();
Players[PlayerInFocus].Process();
CRecordDataForChase::SaveOrRetrieveCarPositions();
if ((CTimer::GetFrameCounter() & 7) == 1) {
CWorld::RemoveFallenPeds();
} else if ((CTimer::GetFrameCounter() & 7) == 5) {
CWorld::RemoveFallenCars();
}
}
}
STARTPATCHES
InjectHook(0x4AE930, CWorld::Add, PATCH_JUMP);
InjectHook(0x4AE9D0, CWorld::Remove, PATCH_JUMP);
@ -951,4 +1195,6 @@ STARTPATCHES
InjectHook(0x4B3A80, CWorld::FindGroundZForCoord, PATCH_JUMP);
InjectHook(0x4B3AE0, CWorld::FindGroundZFor3DCoord, PATCH_JUMP);
InjectHook(0x4B3B50, CWorld::FindRoofZFor3DCoord, PATCH_JUMP);
InjectHook(0x4B1A60, CWorld::Process, PATCH_JUMP);
ENDPATCHES

View file

@ -114,6 +114,10 @@ public:
static float GetWorldX(int x) { return x*SECTOR_SIZE_X + WORLD_MIN_X; }
static float GetWorldY(int y) { return y*SECTOR_SIZE_Y + WORLD_MIN_Y; }
static void RemoveEntityInsteadOfProcessingIt(CEntity* ent);
static void RemoveFallenPeds();
static void RemoveFallenCars();
static void Initialise();
static void ShutDown();
static void Process();

View file

@ -30,6 +30,7 @@ enum Config {
NUMOBJECTS = 450,
NUMDUMMIES = 2802, // 2368 on PS2
NUMAUDIOSCRIPTOBJECTS = 256,
NUMCUTSCENEOBJECTS = 50,
NUMTEMPOBJECTS = 30,

View file

@ -141,10 +141,9 @@ SpawnCar(int id)
static void
LetThemFollowYou(void) {
CPed* player = (CPed*) FindPlayerPed();
CPed *player = (CPed*) FindPlayerPed();
for (int i = 0; i < player->m_numNearPeds; i++) {
CPed* nearPed = player->m_nearPeds[i];
CPed *nearPed = player->m_nearPeds[i];
if (nearPed && !nearPed->IsPlayer()) {
nearPed->SetObjective(OBJECTIVE_FOLLOW_PED_IN_FORMATION, (void*)player);
nearPed->m_pedFormation = rand() & 7;

View file

@ -2833,7 +2833,7 @@ CPed::ReactToAttack(CEntity *attacker)
SetLookTimer(700);
return;
}
if (IsPedInControl() && (CharCreatedBy != MISSION_CHAR || bRespondsToThreats)) {
CPed *ourLeader = m_leader;
if (ourLeader != attacker && (!ourLeader || FindPlayerPed() != ourLeader)
@ -9534,10 +9534,15 @@ CPed::ProcessControl(void)
if (!IsPlayer() || !m_pVehicleAnim)
break;
CPad *pad = CPad::GetPad(0);
if (pad->ArePlayerControlsDisabled())
break;
int vehAnim = m_pVehicleAnim->animId;
int16 padWalkX = CPad::GetPad(0)->GetPedWalkLeftRight();
int16 padWalkY = CPad::GetPad(0)->GetPedWalkUpDown();
int16 padWalkX = pad->GetPedWalkLeftRight();
int16 padWalkY = pad->GetPedWalkUpDown();
if (Abs(padWalkX) > 0.0f || Abs(padWalkY) > 0.0f) {
if (vehAnim == ANIM_CAR_OPEN_LHS || vehAnim == ANIM_CAR_OPEN_RHS || vehAnim == ANIM_COACH_OPEN_L || vehAnim == ANIM_COACH_OPEN_R ||
vehAnim == ANIM_VAN_OPEN_L || vehAnim == ANIM_VAN_OPEN) {
@ -9970,7 +9975,7 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
}
veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_OPEN_LHS, 1.0f);
if (ped->m_vehEnterType == CAR_DOOR_LF || ped->m_vehEnterType == CAR_DOOR_LR)
if (ped->m_vehEnterType == CAR_DOOR_LF || ped->m_vehEnterType == CAR_DOOR_RF)
isVan = false;
if (ped->m_nPedState != PED_CARJACK || isBus) {
@ -10276,13 +10281,212 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
}
}
void
CPed::SetPedPositionInTrain(void)
{
LineUpPedWithTrain();
}
void
CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg)
{
CPed* ped = (CPed*)arg;
CVehicle* veh = ped->m_pMyVehicle;
if (animAssoc)
animAssoc->blendDelta = -1000.0f;
if (ped->m_nPedState == PED_CARJACK || ped->m_nPedState == PED_ENTER_CAR) {
if (!veh || veh->m_status == STATUS_WRECKED)
return;
bool isLow = veh->bLowVehicle;
int padNo;
if (ped->IsPlayer()) {
switch (ped->m_nPedType) {
case PEDTYPE_PLAYER1:
padNo = 0;
break;
case PEDTYPE_PLAYER2:
padNo = 1;
break;
case PEDTYPE_PLAYER3:
padNo = 2;
break;
case PEDTYPE_PLAYER4:
padNo = 3;
break;
default:
// FIX: that was "break"
return;
}
CPad *pad = CPad::GetPad(padNo);
if (!pad->ArePlayerControlsDisabled()) {
if (pad->GetTarget()
|| pad->NewState.LeftStickX
|| pad->NewState.LeftStickY
|| pad->NewState.DPadUp
|| pad->NewState.DPadDown
|| pad->NewState.DPadLeft
|| pad->NewState.DPadRight) {
ped->QuitEnteringCar();
ped->RestorePreviousObjective();
return;
}
}
}
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
AnimationId animToPlay;
if (ped->m_vehEnterType != CAR_DOOR_LF && ped->m_vehEnterType != CAR_DOOR_LR) {
if (isLow)
animToPlay = ANIM_CAR_GETIN_LOW_RHS;
else
animToPlay = ANIM_CAR_GETIN_RHS;
} else if (isLow) {
animToPlay = ANIM_CAR_GETIN_LOW_LHS;
} else {
animToPlay = ANIM_CAR_GETIN_LHS;
}
ped->m_pVehicleAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, animToPlay);
ped->m_pVehicleAnim->SetFinishCallback(PedAnimGetInCB, ped);
} else {
ped->QuitEnteringCar();
}
} else {
ped->QuitEnteringCar();
}
}
void
CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
{
CPed* ped = (CPed*)arg;
CVehicle* veh = ped->m_pMyVehicle;
if (animAssoc)
animAssoc->blendDelta = -1000.0f;
if (!veh) {
PedSetOutCarCB(nil, ped);
return;
}
veh->m_nStaticFrames = 0;
veh->m_vecMoveSpeed += CVector(0.001f, 0.001f, 0.001f);
veh->m_vecTurnSpeed += CVector(0.001f, 0.001f, 0.001f);
if (!veh->bIsBus)
veh->ProcessOpenDoor(ped->m_vehEnterType, ANIM_CAR_GETOUT_LHS, 1.0f);
// Duplicate and pointless code
if (!veh) {
PedSetOutCarCB(nil, ped);
return;
}
eDoors door;
switch (ped->m_vehEnterType) {
case CAR_DOOR_RF:
door = DOOR_FRONT_RIGHT;
break;
case CAR_DOOR_RR:
door = DOOR_REAR_RIGHT;
break;
case CAR_DOOR_LF:
door = DOOR_FRONT_LEFT;
break;
case CAR_DOOR_LR:
door = DOOR_REAR_LEFT;
break;
default:
break;
}
bool closeDoor = false;
if (!veh->IsDoorMissing(door))
closeDoor = true;
int padNo;
if (ped->IsPlayer()) {
switch (ped->m_nPedType) {
case PEDTYPE_PLAYER1:
padNo = 0;
break;
case PEDTYPE_PLAYER2:
padNo = 1;
break;
case PEDTYPE_PLAYER3:
padNo = 2;
break;
case PEDTYPE_PLAYER4:
padNo = 3;
break;
default:
// FIX: that was "break"
return;
}
CPad* pad = CPad::GetPad(padNo);
bool engineIsIntact = false;
if (veh->IsCar() && ((CAutomobile*)veh)->Damage.GetEngineStatus() >= 225) {
engineIsIntact = true;
}
if (!pad->ArePlayerControlsDisabled() && veh->m_nDoorLock != CARLOCK_FORCE_SHUT_DOORS
&& (pad->GetTarget()
|| pad->NewState.LeftStickX
|| pad->NewState.LeftStickY
|| pad->NewState.DPadUp
|| pad->NewState.DPadDown
|| pad->NewState.DPadLeft
|| pad->NewState.DPadRight)
|| veh->bIsBus
|| veh->m_pCarFire
|| engineIsIntact) {
closeDoor = false;
}
}
if (!closeDoor) {
if (!veh->IsDoorMissing(door) && !veh->bIsBus) {
((CAutomobile*)veh)->Damage.SetDoorStatus(door, DOOR_STATUS_SWINGING);
}
PedSetOutCarCB(nil, ped);
return;
}
if (ped->m_ped_flagE80 || ped->m_ped_flagG40) {
if (!veh->IsDoorMissing(door))
((CAutomobile*)veh)->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_SWINGING);
} else {
switch (door) {
case DOOR_FRONT_LEFT:
ped->m_pVehicleAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_CLOSE_LHS);
break;
case DOOR_FRONT_RIGHT:
ped->m_pVehicleAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_CLOSE_RHS);
break;
case DOOR_REAR_LEFT:
ped->m_pVehicleAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_CLOSE_LHS);
break;
case DOOR_REAR_RIGHT:
ped->m_pVehicleAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_CLOSE_RHS);
break;
default:
break;
}
}
if (ped->m_pVehicleAnim)
ped->m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, ped);
return;
}
WRAPPER void CPed::PedGetupCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE810); }
WRAPPER void CPed::PedStaggerCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8D0); }
WRAPPER void CPed::PedEvadeCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D36E0); }
WRAPPER void CPed::PedAnimPullPedOutCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DEAF0); }
WRAPPER void CPed::PedSetInCarCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CF220); }
WRAPPER void CPed::PedSetOutCarCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8F0); }
WRAPPER void CPed::PedAnimStepOutCarCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DF5C0); }
WRAPPER void CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *dragAssoc, void *arg) { EAXJMP(0x4E2480); }
WRAPPER void CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation *dragAssoc, void *arg) { EAXJMP(0x4E2920); }
WRAPPER void CPed::PedSetInTrainCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4E3290); }
@ -10470,4 +10674,6 @@ STARTPATCHES
InjectHook(0x4D73D0, &CPed::SetJump, PATCH_JUMP);
InjectHook(0x4E4E20, &CPed::RemoveInCarAnims, PATCH_JUMP);
InjectHook(0x4DEC80, &CPed::PedAnimGetInCB, PATCH_JUMP);
InjectHook(0x4DEAF0, &CPed::PedAnimPullPedOutCB, PATCH_JUMP);
InjectHook(0x4DF5C0, &CPed::PedAnimStepOutCarCB, PATCH_JUMP);
ENDPATCHES

View file

@ -714,6 +714,7 @@ public:
void RestoreHeadPosition(void);
void PointGunAt(void);
bool ServiceTalkingWhenDead(void);
void SetPedPositionInTrain(void);
bool HasWeapon(uint8 weaponType) { return m_weapons[weaponType].m_eWeaponType == weaponType; }
CWeapon &GetWeapon(uint8 weaponType) { return m_weapons[weaponType]; }

View file

@ -13,6 +13,8 @@ WRAPPER bool CPedIK::RestoreLookAt(void) { EAXJMP(0x4ED810); }
// TODO: These are hardcoded into exe, reverse it.
LimbMovementInfo &CPedIK::ms_torsoInfo = *(LimbMovementInfo*)0x5F9F8C;
LimbMovementInfo &CPedIK::ms_headInfo = *(LimbMovementInfo*)0x5F9F5C;
LimbMovementInfo &CPedIK::ms_upperArmInfo = *(LimbMovementInfo*)0x5F9FA4;
LimbMovementInfo &CPedIK::ms_lowerArmInfo = *(LimbMovementInfo*)0x5F9FBC;
CPedIK::CPedIK(CPed *ped)
{

View file

@ -31,7 +31,7 @@ class CPedIK
public:
enum {
FLAG_1 = 1,
LOOKING = 2,
LOOKING = 2, // looking while in car?
AIMS_WITH_ARM = 4,
};
@ -44,6 +44,8 @@ public:
static LimbMovementInfo &ms_torsoInfo;
static LimbMovementInfo &ms_headInfo;
static LimbMovementInfo &ms_upperArmInfo;
static LimbMovementInfo &ms_lowerArmInfo;
CPedIK(CPed *ped);
bool PointGunInDirection(float phi, float theta);