1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 09:50:00 +00:00
This commit is contained in:
eray orçunus 2019-08-23 01:44:38 +03:00
parent ed9ab6c55f
commit e5df72a1e9
8 changed files with 764 additions and 127 deletions

View file

@ -22,13 +22,12 @@ enum eEventType
EVENT_PED_SET_ON_FIRE, EVENT_PED_SET_ON_FIRE,
EVENT_COP_SET_ON_FIRE, EVENT_COP_SET_ON_FIRE,
EVENT_CAR_SET_ON_FIRE, EVENT_CAR_SET_ON_FIRE,
EVENT_ASSAULT_NASTYWEAPON, EVENT_ASSAULT_NASTYWEAPON, // not sure
EVENT_ASSAULT_NASTYWEAPON_POLICE,
EVENT_ICECREAM, EVENT_ICECREAM,
EVENT_ATM, EVENT_ATM,
EVENT_SHOPSTALL, EVENT_SHOPSTALL, // used on graffitis
EVENT_SHOPWINDOW, EVENT_SHOPWINDOW,
EVENT_LAST_EVENT EVENT_LAST_EVENT // may be above one
}; };
enum eEventEntity enum eEventEntity

View file

@ -212,6 +212,7 @@ public:
} }
void SetRotate(float xAngle, float yAngle, float zAngle); void SetRotate(float xAngle, float yAngle, float zAngle);
void Rotate(float x, float y, float z); void Rotate(float x, float y, float z);
void RotateX(float x);
void Reorthogonalise(void); void Reorthogonalise(void);
void CopyOnlyMatrix(CMatrix *other){ void CopyOnlyMatrix(CMatrix *other){

View file

@ -40,6 +40,12 @@ CMatrix::Rotate(float x, float y, float z)
*this = rot * *this; *this = rot * *this;
} }
void
CMatrix::RotateX(float x)
{
Rotate(x, 0.0f, 0.0f);
}
void void
CMatrix::Reorthogonalise(void) CMatrix::Reorthogonalise(void)
{ {

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,7 @@
#include "WeaponInfo.h" #include "WeaponInfo.h"
#include "Fire.h" #include "Fire.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "EventList.h"
struct CPathNode; struct CPathNode;
@ -258,7 +259,7 @@ public:
uint8 bIsAttacking : 1; // doesn't reset after fist fight, also stores (CTimer::GetTimeInMilliseconds() < m_lastHitTime) uint8 bIsAttacking : 1; // doesn't reset after fist fight, also stores (CTimer::GetTimeInMilliseconds() < m_lastHitTime)
uint8 bIsPointingGunAt : 1; uint8 bIsPointingGunAt : 1;
uint8 bIsLooking : 1; uint8 bIsLooking : 1;
uint8 m_ped_flagA20 : 1; // "look" method? - probably missing in SA uint8 bKeepTryingToLook : 1; // if we can't look somewhere due to unreachable angles
uint8 bIsRestoringLook : 1; uint8 bIsRestoringLook : 1;
uint8 bIsAimingGun : 1; uint8 bIsAimingGun : 1;
@ -278,10 +279,10 @@ public:
uint8 bUpdateAnimHeading : 1; uint8 bUpdateAnimHeading : 1;
uint8 bBodyPartJustCameOff : 1; uint8 bBodyPartJustCameOff : 1;
uint8 m_ped_flagC40 : 1; uint8 m_ped_flagC40 : 1;
uint8 m_ped_flagC80 : 1; uint8 bFindNewNodeAfterStateRestore : 1;
uint8 m_ped_flagD1 : 1; uint8 m_ped_flagD1 : 1; // so far only used for reaction type to fire/explosion
uint8 m_ped_flagD2 : 1; // seen an event uint8 m_ped_flagD2 : 1; // set when event has been seen
uint8 m_ped_flagD4 : 1; uint8 m_ped_flagD4 : 1;
uint8 m_ped_flagD8 : 1; uint8 m_ped_flagD8 : 1;
uint8 bIsPedDieAnimPlaying : 1; uint8 bIsPedDieAnimPlaying : 1;
@ -303,7 +304,7 @@ public:
uint8 m_ped_flagF4 : 1; uint8 m_ped_flagF4 : 1;
uint8 m_ped_flagF8 : 1; uint8 m_ped_flagF8 : 1;
uint8 bWillBeQuickJacked : 1; uint8 bWillBeQuickJacked : 1;
uint8 m_ped_flagF20 : 1; uint8 m_ped_flagF20 : 1; // set when couldn't open locked car door
uint8 m_ped_flagF40 : 1; uint8 m_ped_flagF40 : 1;
uint8 bDuckAndCover : 1; uint8 bDuckAndCover : 1;
@ -329,7 +330,7 @@ public:
uint8 bNoCriticalHits : 1; // if set, limbs won't came off uint8 bNoCriticalHits : 1; // if set, limbs won't came off
uint8 m_ped_flagI4 : 1; uint8 m_ped_flagI4 : 1;
uint8 bHasAlreadyBeenRecorded : 1; uint8 bHasAlreadyBeenRecorded : 1;
uint8 bIsFell : 1; uint8 bFallenDown : 1;
uint8 m_ped_flagI20 : 1; uint8 m_ped_flagI20 : 1;
uint8 m_ped_flagI40 : 1; uint8 m_ped_flagI40 : 1;
uint8 m_ped_flagI80 : 1; uint8 m_ped_flagI80 : 1;
@ -367,7 +368,7 @@ public:
int32 m_nPrevMoveState; int32 m_nPrevMoveState;
eWaitState m_nWaitState; eWaitState m_nWaitState;
uint32 m_nWaitTimer; uint32 m_nWaitTimer;
void *m_pPathNodesStates[8]; // seems unused void *m_pPathNodesStates[8]; // seems unused, probably leftover from VC
CVector2D m_stPathNodeStates[10]; CVector2D m_stPathNodeStates[10];
uint16 m_nPathNodes; uint16 m_nPathNodes;
int16 m_nCurPathNode; int16 m_nCurPathNode;
@ -601,7 +602,7 @@ public:
void LineUpPedWithTrain(void); void LineUpPedWithTrain(void);
void ExitCar(void); void ExitCar(void);
void Fight(void); void Fight(void);
bool FindBestCoordsFromNodes(CVector unused, CVector* a6); bool FindBestCoordsFromNodes(CVector, CVector*);
void Wait(void); void Wait(void);
void ProcessObjective(void); void ProcessObjective(void);
bool SeekFollowingPath(CVector*); bool SeekFollowingPath(CVector*);
@ -614,13 +615,20 @@ public:
uint8 GetPedRadioCategory(uint32); uint8 GetPedRadioCategory(uint32);
int GetWeaponSlot(eWeaponType); int GetWeaponSlot(eWeaponType);
void GoToNearestDoor(CVehicle*); void GoToNearestDoor(CVehicle*);
bool HaveReachedNextPointOnRoute(float a2); bool HaveReachedNextPointOnRoute(float);
void Idle(void); void Idle(void);
void InTheAir(void); void InTheAir(void);
void SetLanding(void); void SetLanding(void);
void InvestigateEvent(void); void InvestigateEvent(void);
bool IsPedDoingDriveByShooting(void); bool IsPedDoingDriveByShooting(void);
bool IsRoomToBeCarJacked(void); bool IsRoomToBeCarJacked(void);
void SetInvestigateEvent(eEventType, CVector2D, float, uint16, float);
bool LookForInterestingNodes(void);
void LookForSexyCars(void);
void LookForSexyPeds(void);
void Mug(void);
void MoveHeadToLook(void);
void Pause(void);
// Static methods // Static methods
static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset); static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset);

View file

@ -2,14 +2,16 @@
#include "patcher.h" #include "patcher.h"
#include "PedIK.h" #include "PedIK.h"
#include "Ped.h" #include "Ped.h"
#include "General.h"
WRAPPER bool CPedIK::PointGunInDirection(float phi, float theta) { EAXJMP(0x4ED9B0); } WRAPPER bool CPedIK::PointGunInDirection(float phi, float theta) { EAXJMP(0x4ED9B0); }
WRAPPER bool CPedIK::PointGunAtPosition(CVector *position) { EAXJMP(0x4ED920); } WRAPPER bool CPedIK::PointGunAtPosition(CVector *position) { EAXJMP(0x4ED920); }
WRAPPER void CPedIK::ExtractYawAndPitchLocal(RwMatrixTag*, float*, float*) { EAXJMP(0x4ED2C0); } WRAPPER void CPedIK::ExtractYawAndPitchLocal(RwMatrixTag*, float*, float*) { EAXJMP(0x4ED2C0); }
WRAPPER void CPedIK::ExtractYawAndPitchWorld(RwMatrixTag*, float*, float*) { EAXJMP(0x4ED140); } WRAPPER void CPedIK::ExtractYawAndPitchWorld(RwMatrixTag*, float*, float*) { EAXJMP(0x4ED140); }
// TODO: Hardcoded into exe, reverse it. // TODO: These are hardcoded into exe, reverse it.
LimbMovementInfo &CPedIK::ms_torsoInfo = *(LimbMovementInfo*)0x5F9F8C; LimbMovementInfo &CPedIK::ms_torsoInfo = *(LimbMovementInfo*)0x5F9F8C;
LimbMovementInfo &CPedIK::ms_headInfo = *(LimbMovementInfo*)0x5F9F5C;
CPedIK::CPedIK(CPed *ped) CPedIK::CPedIK(CPed *ped)
{ {
@ -105,10 +107,10 @@ CPedIK::GetWorldMatrix(RwFrame *source, RwMatrix *destination)
return destination; return destination;
} }
uint32 LimbMoveStatus
CPedIK::MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, LimbMovementInfo &moveInfo) CPedIK::MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, LimbMovementInfo &moveInfo)
{ {
int result = 1; LimbMoveStatus result = ONE_ANGLE_COULDNT_BE_SET_EXACTLY;
// phi // phi
@ -120,11 +122,12 @@ CPedIK::MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, Limb
if (Abs(limb.phi - approxPhi) < moveInfo.yawD) { if (Abs(limb.phi - approxPhi) < moveInfo.yawD) {
limb.phi = approxPhi; limb.phi = approxPhi;
result = 2; result = ANGLES_SET_EXACTLY;
} }
if (limb.phi > moveInfo.maxYaw || limb.phi < moveInfo.minYaw) { if (limb.phi > moveInfo.maxYaw || limb.phi < moveInfo.minYaw) {
limb.phi = clamp(limb.phi, moveInfo.minYaw, moveInfo.maxYaw); limb.phi = clamp(limb.phi, moveInfo.minYaw, moveInfo.maxYaw);
result = 0; result = ANGLES_SET_TO_MAX;
} }
// theta // theta
@ -138,11 +141,11 @@ CPedIK::MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, Limb
if (Abs(limb.theta - approxTheta) < moveInfo.pitchD) if (Abs(limb.theta - approxTheta) < moveInfo.pitchD)
limb.theta = approxTheta; limb.theta = approxTheta;
else else
result = 1; result = ONE_ANGLE_COULDNT_BE_SET_EXACTLY;
if (limb.theta > moveInfo.maxPitch || limb.theta < moveInfo.minPitch) { if (limb.theta > moveInfo.maxPitch || limb.theta < moveInfo.minPitch) {
limb.theta = clamp(limb.theta, moveInfo.minPitch, moveInfo.maxPitch); limb.theta = clamp(limb.theta, moveInfo.minPitch, moveInfo.maxPitch);
result = 0; result = ANGLES_SET_TO_MAX;
} }
return result; return result;
} }
@ -150,9 +153,71 @@ CPedIK::MoveLimb(LimbOrientation &limb, float approxPhi, float approxTheta, Limb
bool bool
CPedIK::RestoreGunPosn(void) CPedIK::RestoreGunPosn(void)
{ {
int limbStatus = MoveLimb(m_torsoOrient, 0.0f, 0.0f, ms_torsoInfo); LimbMoveStatus limbStatus = MoveLimb(m_torsoOrient, 0.0f, 0.0f, ms_torsoInfo);
RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false); RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
return limbStatus == 2; return limbStatus == ANGLES_SET_EXACTLY;
}
bool
CPedIK::LookInDirection(float phi, float theta)
{
bool success = true;
AnimBlendFrameData *frameData = m_ped->m_pFrames[PED_HEAD];
RwFrame *frame = frameData->frame;
RwMatrix *frameMat = RwFrameGetMatrix(frame);
if (!(frameData->flag & AnimBlendFrameData::IGNORE_ROTATION)) {
frameData->flag |= AnimBlendFrameData::IGNORE_ROTATION;
CPedIK::ExtractYawAndPitchLocal(frameMat, &m_headOrient.phi, &m_headOrient.theta);
}
RwMatrix *worldMat = RwMatrixCreate();
worldMat = CPedIK::GetWorldMatrix(RwFrameGetParent(frame), worldMat);
float alpha, beta;
CPedIK::ExtractYawAndPitchWorld(worldMat, &alpha, &beta);
RwMatrixDestroy(worldMat);
alpha += m_torsoOrient.phi;
float neededPhiTurn = CGeneral::LimitRadianAngle(phi - alpha);
beta *= cos(neededPhiTurn);
float neededThetaTurn = CGeneral::LimitRadianAngle(theta - beta);
LimbMoveStatus headStatus = CPedIK::MoveLimb(m_headOrient, neededPhiTurn, neededThetaTurn, ms_headInfo);
if (headStatus == ANGLES_SET_TO_MAX)
success = false;
if (headStatus != ANGLES_SET_EXACTLY && !(m_flags & LOOKING)) {
float remainingTurn = CGeneral::LimitRadianAngle(phi - m_ped->m_fRotationCur);
if (CPedIK::MoveLimb(m_torsoOrient, remainingTurn, theta, ms_torsoInfo))
success = true;
}
CMatrix nextFrame = CMatrix(frameMat);
CVector framePos = nextFrame.GetPosition();
nextFrame.SetRotateZ(m_headOrient.theta);
nextFrame.RotateX(m_headOrient.phi);
nextFrame.GetPosition() += framePos;
nextFrame.UpdateRW();
if (!(m_flags & LOOKING))
RotateTorso(m_ped->m_pFrames[PED_MID], &m_torsoOrient, false);
return success;
}
bool
CPedIK::LookAtPosition(CVector const &pos)
{
float phiToFace = CGeneral::GetRadianAngleBetweenPoints(
pos.x, pos.y,
m_ped->GetPosition().x, m_ped->GetPosition().y);
float thetaToFace = CGeneral::GetRadianAngleBetweenPoints(
pos.z, (m_ped->GetPosition() - pos).Magnitude2D(),
m_ped->GetPosition().z, 0.0f);
return LookInDirection(phiToFace, thetaToFace);
} }
STARTPATCHES STARTPATCHES
@ -161,4 +226,6 @@ STARTPATCHES
InjectHook(0x4EDDB0, &CPedIK::RotateTorso, PATCH_JUMP); InjectHook(0x4EDDB0, &CPedIK::RotateTorso, PATCH_JUMP);
InjectHook(0x4ED440, &CPedIK::MoveLimb, PATCH_JUMP); InjectHook(0x4ED440, &CPedIK::MoveLimb, PATCH_JUMP);
InjectHook(0x4EDD70, &CPedIK::RestoreGunPosn, PATCH_JUMP); InjectHook(0x4EDD70, &CPedIK::RestoreGunPosn, PATCH_JUMP);
InjectHook(0x4ED620, &CPedIK::LookInDirection, PATCH_JUMP);
InjectHook(0x4ED590, &CPedIK::LookAtPosition, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View file

@ -18,16 +18,21 @@ struct LimbMovementInfo {
float pitchD; float pitchD;
}; };
enum LimbMoveStatus {
ANGLES_SET_TO_MAX, // because given angles were unreachable
ONE_ANGLE_COULDNT_BE_SET_EXACTLY, // because it can't be reached in a jiffy
ANGLES_SET_EXACTLY
};
class CPed; class CPed;
class CPedIK class CPedIK
{ {
public: public:
// TODO
enum { enum {
FLAG_1 = 1, FLAG_1 = 1,
FLAG_2 = 2, // related to looking somewhere LOOKING = 2,
FLAG_4 = 4, // aims with arm AIMS_WITH_ARM = 4,
}; };
CPed *m_ped; CPed *m_ped;
@ -38,6 +43,7 @@ public:
int32 m_flags; int32 m_flags;
static LimbMovementInfo &ms_torsoInfo; static LimbMovementInfo &ms_torsoInfo;
static LimbMovementInfo &ms_headInfo;
CPedIK(CPed *ped); CPedIK(CPed *ped);
bool PointGunInDirection(float phi, float theta); bool PointGunInDirection(float phi, float theta);
@ -47,7 +53,9 @@ public:
void RotateTorso(AnimBlendFrameData* animBlend, LimbOrientation* limb, bool changeRoll); void RotateTorso(AnimBlendFrameData* animBlend, LimbOrientation* limb, bool changeRoll);
void ExtractYawAndPitchLocal(RwMatrixTag*, float*, float*); void ExtractYawAndPitchLocal(RwMatrixTag*, float*, float*);
void ExtractYawAndPitchWorld(RwMatrixTag*, float*, float*); void ExtractYawAndPitchWorld(RwMatrixTag*, float*, float*);
uint32 MoveLimb(LimbOrientation &a1, float a2, float a3, LimbMovementInfo &a4); LimbMoveStatus MoveLimb(LimbOrientation &a1, float a2, float a3, LimbMovementInfo &a4);
bool RestoreGunPosn(void); bool RestoreGunPosn(void);
bool LookInDirection(float phi, float theta);
bool LookAtPosition(CVector const& pos);
}; };
static_assert(sizeof(CPedIK) == 0x28, "CPedIK: error"); static_assert(sizeof(CPedIK) == 0x28, "CPedIK: error");

View file

@ -57,8 +57,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
void CPlayerPed::ClearWeaponTarget() void CPlayerPed::ClearWeaponTarget()
{ {
if (!m_nPedType) { if (m_nPedType == PEDTYPE_PLAYER1) {
m_pPointGunAt = 0; m_pPointGunAt = nil;
TheCamera.ClearPlayerWeaponMode(); TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrosshair(); CWeaponEffects::ClearCrosshair();
} }
@ -79,12 +79,12 @@ CPlayerPed::SetWantedLevelNoDrop(int32 level)
// I don't know the actual purpose of parameter // I don't know the actual purpose of parameter
void void
CPlayerPed::AnnoyPlayerPed(bool itsPolice) CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)
{ {
if (m_pedStats->m_temper < 52) { if (m_pedStats->m_temper < 52) {
m_pedStats->m_temper++; m_pedStats->m_temper++;
} else { } else {
if (itsPolice) { if (annoyedByPassingEntity) {
if (m_pedStats->m_temper < 55) { if (m_pedStats->m_temper < 55) {
m_pedStats->m_temper++; m_pedStats->m_temper++;
} else { } else {