diff options
author | aap <aap@papnet.eu> | 2019-07-10 15:06:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-10 15:06:08 +0200 |
commit | 80e0409d6a1bfd002b98af8d598ec940b6d6facb (patch) | |
tree | 5e0a6dcdbf8f1566974c0514986ab7b61e5c067a /src/peds | |
parent | fixed COMMAND_IS_PLAYER_IN_AREA_3D (diff) | |
parent | Merge branch 'master' of git://github.com/GTAmodding/re3 into erorcun (diff) | |
download | re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.tar re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.tar.gz re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.tar.bz2 re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.tar.lz re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.tar.xz re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.tar.zst re3-80e0409d6a1bfd002b98af8d598ec940b6d6facb.zip |
Diffstat (limited to 'src/peds')
-rw-r--r-- | src/peds/Ped.cpp | 40 | ||||
-rw-r--r-- | src/peds/Ped.h | 11 |
2 files changed, 44 insertions, 7 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 28cb8823..8ebe456f 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -24,6 +24,7 @@ #include "Lights.h" #include "PointLights.h" #include "Pad.h" +#include "Phones.h" WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); } WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); } @@ -44,6 +45,7 @@ WRAPPER void CPed::SetFollowRoute(int16, int16) { EAXJMP(0x4DD690); } WRAPPER void CPed::SetDuck(uint32) { EAXJMP(0x4E4920); } WRAPPER void CPed::RegisterThreatWithGangPeds(CEntity*) { EAXJMP(0x4E3870); } WRAPPER void CPed::MakeChangesForNewWeapon(int8) { EAXJMP(0x4F2560); } +WRAPPER bool CPed::Seek(void) { EAXJMP(0x4D1640); } bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44; bool &CPed::bPedCheat2 = *(bool*)0x95CD5A; @@ -1391,7 +1393,7 @@ CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg) if (ped->m_nPedState != PED_ARRESTED) { ped->m_nLastPedState = PED_NONE; if (dragAssoc) - dragAssoc->blendDelta = -1000.0; + dragAssoc->blendDelta = -1000.0f; } ped->RestartNonPartialAnims(); ped->m_pVehicleAnim = nil; @@ -2057,6 +2059,7 @@ CPed::SetupLighting(void) { ActivateDirectional(); SetAmbientColoursForPedsCarsAndObjects(); + if (bRenderScorched) { WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f); } else { @@ -2698,7 +2701,7 @@ CPed::QuitEnteringCar(void) if (veh->m_nNumGettingIn != 0) veh->m_nNumGettingIn--; - veh->m_nGettingInFlags = GetVehDoorFlag(m_vehEnterType); + veh->m_nGettingInFlags = ~GetVehDoorFlag(m_vehEnterType); } bUsesCollision = true; @@ -2871,6 +2874,38 @@ CPed::Chat(void) } } +void +CPed::CheckAroundForPossibleCollisions(void) +{ + CVector ourCentre, objCentre; + CEntity *objects[8]; + int16 maxObject; + + if (CTimer::GetTimeInMilliseconds() <= m_nPedStateTimer) + return; + + GetBoundCentre(ourCentre); + + CWorld::FindObjectsInRange(ourCentre, 10.0f, true, &maxObject, 6, objects, false, true, false, true, false); + for (int i = 0; i < maxObject; i++) { + CEntity *object = objects[i]; + if (field_31C) { + if (gPhoneInfo.PhoneAtThisPosition(object->GetPosition())) + break; + } + object->GetBoundCentre(objCentre); + float radius = object->GetBoundRadius(); + if (radius > 4.5f || radius < 1.0f) + radius = 1.0f; + + // According to code, developers gave up calculating Z diff. later. + float diff = CVector(ourCentre - objCentre).MagnitudeSqr2D(); + + if (sq(radius + 1.0f) > diff) + m_fRotationDest += DEGTORAD(22.5f); + } +} + 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); } @@ -2963,4 +2998,5 @@ STARTPATCHES InjectHook(0x4D3C80, &CPed::ClearChat, PATCH_JUMP); InjectHook(0x4D1390, &CPed::TurnBody, PATCH_JUMP); InjectHook(0x4D3AC0, &CPed::Chat, PATCH_JUMP); + InjectHook(0x4D0490, &CPed::CheckAroundForPossibleCollisions, PATCH_JUMP); ENDPATCHES diff --git a/src/peds/Ped.h b/src/peds/Ped.h index f48c30ba..cd7d88af 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -13,7 +13,7 @@ struct CPathNode; -enum eWaitState : uint32 { +enum eWaitState { WAITSTATE_FALSE, WAITSTATE_TRAFFIC_LIGHTS, WAITSTATE_CROSS_ROAD, @@ -292,10 +292,10 @@ public: int32 m_nPrevActionState; eWaitState m_nWaitState; uint32 m_nWaitTimer; - void *m_pPathNodesStates[8]; + void *m_pPathNodesStates[8]; // seems unused CVector2D m_stPathNodeStates[10]; uint16 m_nPathNodes; - uint8 m_nCurPathNode; + int16 m_nCurPathNode; int8 m_nPathState; private: int8 _pad2B5[3]; @@ -324,7 +324,7 @@ public: CVehicle *m_pMyVehicle; bool bInVehicle; uint8 pad_315[3]; - uint32 field_318; + float field_318; uint8 field_31C; uint8 field_31D; int16 m_phoneId; @@ -458,7 +458,8 @@ public: bool TurnBody(void); void Chat(void); void MakeChangesForNewWeapon(int8); - + void CheckAroundForPossibleCollisions(void); + bool Seek(void); // Static methods static void GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset); |