2019-05-19 19:28:10 +00:00
|
|
|
#include "common.h"
|
|
|
|
#include "patcher.h"
|
|
|
|
#include "Pools.h"
|
2019-06-16 18:39:48 +00:00
|
|
|
#include "Particle.h"
|
|
|
|
#include "Stats.h"
|
|
|
|
#include "World.h"
|
2019-06-16 21:12:14 +00:00
|
|
|
#include "DMaudio.h"
|
2019-06-20 11:22:44 +00:00
|
|
|
#include "RpAnimBlend.h"
|
2019-06-16 21:12:14 +00:00
|
|
|
#include "Ped.h"
|
2019-06-20 11:22:44 +00:00
|
|
|
#include "PlayerPed.h"
|
2019-06-17 09:48:42 +00:00
|
|
|
#include "General.h"
|
2019-06-21 18:16:51 +00:00
|
|
|
#include "VisibilityPlugins.h"
|
2019-06-24 14:57:54 +00:00
|
|
|
#include "AudioManager.h"
|
|
|
|
#include "HandlingMgr.h"
|
|
|
|
#include "Replay.h"
|
|
|
|
#include "PedPlacement.h"
|
2019-06-28 16:19:00 +00:00
|
|
|
#include "Shadows.h"
|
|
|
|
#include "Weather.h"
|
|
|
|
#include "CullZones.h"
|
2019-05-19 19:28:10 +00:00
|
|
|
|
2019-06-16 22:16:38 +00:00
|
|
|
bool &CPed::bNastyLimbsCheat = *(bool*)0x95CD44;
|
|
|
|
bool &CPed::bPedCheat2 = *(bool*)0x95CD5A;
|
|
|
|
bool &CPed::bPedCheat3 = *(bool*)0x95CD59;
|
2019-06-15 15:53:25 +00:00
|
|
|
|
2019-06-24 14:57:54 +00:00
|
|
|
CVector &CPed::offsetToOpenRegularCarDoor = *(CVector*)0x62E030;
|
|
|
|
CVector &CPed::offsetToOpenLowCarDoor = *(CVector*)0x62E03C;
|
|
|
|
CVector &CPed::offsetToOpenVanDoor = *(CVector*)0x62E048;
|
|
|
|
|
2019-06-02 15:13:56 +00:00
|
|
|
void *CPed::operator new(size_t sz) { return CPools::GetPedPool()->New(); }
|
|
|
|
void CPed::operator delete(void *p, size_t sz) { CPools::GetPedPool()->Delete((CPed*)p); }
|
2019-05-19 19:28:10 +00:00
|
|
|
|
|
|
|
WRAPPER void CPed::KillPedWithCar(CVehicle *veh, float impulse) { EAXJMP(0x4EC430); }
|
2019-06-16 21:12:14 +00:00
|
|
|
WRAPPER void CPed::Say(uint16 audio) { EAXJMP(0x4E5A10); }
|
2019-06-15 15:53:25 +00:00
|
|
|
WRAPPER void CPed::SetDie(AnimationId anim, float arg1, float arg2) { EAXJMP(0x4D37D0); }
|
2019-06-16 21:12:14 +00:00
|
|
|
WRAPPER void CPed::SpawnFlyingComponent(int, int8) { EAXJMP(0x4EB060); }
|
2019-06-20 11:22:44 +00:00
|
|
|
WRAPPER void CPed::RestorePreviousState(void) { EAXJMP(0x4C5E30); }
|
|
|
|
WRAPPER void CPed::ClearAttack(void) { EAXJMP(0x4E6790); }
|
2019-06-24 14:57:54 +00:00
|
|
|
WRAPPER void CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *dragAssoc, void *arg) { EAXJMP(0x4E2480); }
|
|
|
|
WRAPPER void CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation *dragAssoc, void *arg) { EAXJMP(0x4E2920); }
|
|
|
|
WRAPPER void CPed::SetPedPositionInCar(void) { EAXJMP(0x4D4970); }
|
2019-05-28 06:39:36 +00:00
|
|
|
|
|
|
|
static char ObjectiveText[34][28] = {
|
|
|
|
"No Obj",
|
|
|
|
"Wait on Foot",
|
|
|
|
"Flee on Foot Till Safe",
|
|
|
|
"Guard Spot",
|
|
|
|
"Guard Area",
|
|
|
|
"Wait in Car",
|
|
|
|
"Wait in Car then Getout",
|
|
|
|
"Kill Char on Foot",
|
|
|
|
"Kill Char Any Means",
|
|
|
|
"Flee Char on Foot Till Safe",
|
|
|
|
"Flee Char on Foot Always",
|
|
|
|
"GoTo Char on Foot",
|
|
|
|
"Follow Char in Formation",
|
|
|
|
"Leave Car",
|
|
|
|
"Enter Car as Passenger",
|
|
|
|
"Enter Car as Driver",
|
|
|
|
"Follow Car in Car",
|
|
|
|
"Fire at Obj from Vehicle",
|
|
|
|
"Destroy Obj",
|
|
|
|
"Destroy Car",
|
|
|
|
"GoTo Area Any Means",
|
|
|
|
"GoTo Area on Foot",
|
|
|
|
"Run to Area",
|
|
|
|
"GoTo Area in Car",
|
|
|
|
"Follow Car on Foot Woffset",
|
|
|
|
"Guard Attack",
|
|
|
|
"Set Leader",
|
|
|
|
"Follow Route",
|
|
|
|
"Solicit",
|
|
|
|
"Take Taxi",
|
|
|
|
"Catch Train",
|
|
|
|
"Buy IceCream",
|
|
|
|
"Steal Any Car",
|
|
|
|
"Mug Char",
|
|
|
|
};
|
|
|
|
|
|
|
|
static char StateText[56][18] = {
|
|
|
|
"None", // 1
|
|
|
|
"Idle",
|
|
|
|
"Look Entity",
|
|
|
|
"Look Heading",
|
|
|
|
"Wander Range",
|
|
|
|
"Wander Path",
|
|
|
|
"Seek Pos",
|
|
|
|
"Seek Entity",
|
|
|
|
"Flee Pos",
|
|
|
|
"Flee Entity",
|
|
|
|
"Pursue",
|
|
|
|
"Follow Path",
|
|
|
|
"Sniper Mode",
|
|
|
|
"Rocket Mode",
|
|
|
|
"Dummy",
|
|
|
|
"Pause",
|
|
|
|
"Attack",
|
|
|
|
"Fight",
|
|
|
|
"Face Phone",
|
|
|
|
"Make Call",
|
|
|
|
"Chat",
|
|
|
|
"Mug",
|
|
|
|
"AimGun",
|
|
|
|
"AI Control",
|
|
|
|
"Seek Car",
|
|
|
|
"Seek InBoat",
|
|
|
|
"Follow Route",
|
|
|
|
"C.P.R.",
|
|
|
|
"Solicit",
|
|
|
|
"Buy IceCream",
|
|
|
|
"Investigate",
|
|
|
|
"Step away",
|
|
|
|
"STATES_NO_AI",
|
|
|
|
"On Fire",
|
|
|
|
"Jump",
|
|
|
|
"Fall",
|
|
|
|
"GetUp",
|
|
|
|
"Stagger",
|
|
|
|
"Dive away",
|
|
|
|
"STATES_NO_ST",
|
|
|
|
"Enter Train",
|
|
|
|
"Exit Train",
|
|
|
|
"Arrest Plyr",
|
|
|
|
"Driving",
|
|
|
|
"Passenger",
|
|
|
|
"Taxi Passngr",
|
|
|
|
"Open Door",
|
|
|
|
"Die",
|
|
|
|
"Dead",
|
|
|
|
"CarJack",
|
|
|
|
"Drag fm Car",
|
|
|
|
"Enter Car",
|
|
|
|
"Steal Car",
|
|
|
|
"Exit Car",
|
|
|
|
"Hands Up",
|
|
|
|
"Arrested",
|
|
|
|
};
|
|
|
|
|
|
|
|
static char PersonalityTypeText[32][18] = {
|
|
|
|
"Player",
|
|
|
|
"Cop",
|
|
|
|
"Medic",
|
|
|
|
"Fireman",
|
|
|
|
"Gang 1",
|
|
|
|
"Gang 2",
|
|
|
|
"Gang 3",
|
|
|
|
"Gang 4",
|
|
|
|
"Gang 5",
|
|
|
|
"Gang 6",
|
|
|
|
"Gang 7",
|
|
|
|
"Street Guy",
|
|
|
|
"Suit Guy",
|
|
|
|
"Sensible Guy",
|
|
|
|
"Geek Guy",
|
|
|
|
"Old Guy",
|
|
|
|
"Tough Guy",
|
|
|
|
"Street Girl",
|
|
|
|
"Suit Girl",
|
|
|
|
"Sensible Girl",
|
|
|
|
"Geek Girl",
|
|
|
|
"Old Girl",
|
|
|
|
"Tough Girl",
|
|
|
|
"Tramp",
|
|
|
|
"Tourist",
|
|
|
|
"Prostitute",
|
|
|
|
"Criminal",
|
|
|
|
"Busker",
|
|
|
|
"Taxi Driver",
|
|
|
|
"Psycho",
|
|
|
|
"Steward",
|
|
|
|
"Sports Fan",
|
|
|
|
};
|
|
|
|
|
|
|
|
static char WaitStateText[21][16] = {
|
|
|
|
"No Wait",
|
|
|
|
"Traffic Lights",
|
|
|
|
"Pause CrossRoad",
|
|
|
|
"Look CrossRoad",
|
|
|
|
"Look Ped",
|
|
|
|
"Look Shop",
|
|
|
|
"Look Accident",
|
|
|
|
"FaceOff Gang",
|
|
|
|
"Double Back",
|
|
|
|
"Hit Wall",
|
|
|
|
"Turn 180deg",
|
|
|
|
"Surprised",
|
|
|
|
"Ped Stuck",
|
|
|
|
"Look About",
|
|
|
|
"Play Duck",
|
|
|
|
"Play Cower",
|
|
|
|
"Play Taxi",
|
|
|
|
"Play HandsUp",
|
|
|
|
"Play HandsCower",
|
|
|
|
"Play Chat",
|
|
|
|
"Finish Flee",
|
|
|
|
};
|
|
|
|
|
2019-06-21 18:16:51 +00:00
|
|
|
static RwObject*
|
|
|
|
RemoveAllModelCB(RwObject *object, void *data)
|
|
|
|
{
|
2019-06-24 14:57:54 +00:00
|
|
|
RpAtomic *atomic = (RpAtomic*)object;
|
|
|
|
if (CVisibilityPlugins::GetAtomicModelInfo(atomic)) {
|
2019-06-21 18:16:51 +00:00
|
|
|
RpClumpRemoveAtomic(atomic->clump, atomic);
|
|
|
|
RpAtomicDestroy(atomic);
|
|
|
|
}
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
static PedOnGroundState
|
|
|
|
CheckForPedsOnGroundToAttack(CPlayerPed *player, CPed **pedOnGround)
|
|
|
|
{
|
|
|
|
PedOnGroundState stateToReturn;
|
|
|
|
float angleToFace;
|
|
|
|
CPed *currentPed = nil;
|
|
|
|
PedState currentPedState;
|
|
|
|
CPed *pedOnTheFloor = nil;
|
|
|
|
CPed *deadPed = nil;
|
|
|
|
CPed *pedBelow = nil;
|
|
|
|
bool foundDead = false;
|
|
|
|
bool foundOnTheFloor = false;
|
|
|
|
bool foundBelow = false;
|
|
|
|
float angleDiff;
|
|
|
|
float distance;
|
|
|
|
|
|
|
|
if (!CGame::nastyGame)
|
|
|
|
return NO_PED;
|
|
|
|
|
|
|
|
for (int currentPedId = 0; currentPedId < player->m_numNearPeds; currentPedId++) {
|
|
|
|
|
|
|
|
currentPed = player->m_nearPeds[currentPedId];
|
|
|
|
|
|
|
|
CVector posDifference = currentPed->GetPosition() - player->GetPosition();
|
|
|
|
distance = posDifference.Magnitude();
|
|
|
|
|
|
|
|
if (distance < 2.0f) {
|
|
|
|
angleToFace = CGeneral::GetRadianAngleBetweenPoints(
|
|
|
|
currentPed->GetPosition().x, currentPed->GetPosition().y,
|
|
|
|
player->GetPosition().x, player->GetPosition().y);
|
|
|
|
|
|
|
|
angleToFace = CGeneral::LimitRadianAngle(angleToFace);
|
|
|
|
player->m_fRotationCur = CGeneral::LimitRadianAngle(player->m_fRotationCur);
|
|
|
|
|
|
|
|
angleDiff = fabs(angleToFace - player->m_fRotationCur);
|
|
|
|
|
|
|
|
if (angleDiff > PI)
|
|
|
|
angleDiff = 2 * PI - angleDiff;
|
|
|
|
|
|
|
|
currentPedState = currentPed->m_nPedState;
|
|
|
|
|
|
|
|
if (currentPedState == PED_FALL || currentPedState == PED_GETUP || currentPedState == PED_DIE || currentPedState == PED_DEAD) {
|
|
|
|
if (distance < 2.0f && angleDiff < DEGTORAD(65.0f)) {
|
|
|
|
if (currentPedState == PED_DEAD) {
|
|
|
|
foundDead = 1;
|
|
|
|
if (!deadPed)
|
|
|
|
deadPed = (CPed*)currentPed;
|
2019-06-27 03:30:29 +00:00
|
|
|
} else if (!currentPed->IsPedHeadAbovePos(-0.6f)) {
|
2019-06-20 11:22:44 +00:00
|
|
|
foundOnTheFloor = 1;
|
|
|
|
if (!pedOnTheFloor)
|
|
|
|
pedOnTheFloor = (CPed*)currentPed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ((distance >= 0.8f || angleDiff >= DEGTORAD(75.0f))
|
|
|
|
&& (distance >= 1.3f || angleDiff >= DEGTORAD(55.0f))
|
|
|
|
&& (distance >= 1.7f || angleDiff >= DEGTORAD(35.0f))
|
|
|
|
&& (distance >= 2.0f || angleDiff >= DEGTORAD(30.0f))) {
|
|
|
|
|
|
|
|
if (angleDiff < DEGTORAD(75.0f)) {
|
|
|
|
foundBelow = 1;
|
|
|
|
if (!pedBelow)
|
|
|
|
pedBelow = (CPed*)currentPed;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
foundBelow = 1;
|
|
|
|
pedBelow = (CPed*)currentPed;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (foundOnTheFloor) {
|
|
|
|
currentPed = pedOnTheFloor;
|
|
|
|
stateToReturn = PED_ON_THE_FLOOR;
|
|
|
|
} else if (foundDead) {
|
|
|
|
currentPed = deadPed;
|
|
|
|
stateToReturn = PED_DEAD_ON_THE_FLOOR;
|
|
|
|
} else if (foundBelow) {
|
|
|
|
currentPed = pedBelow;
|
|
|
|
stateToReturn = PED_BELOW_PLAYER;
|
|
|
|
} else {
|
|
|
|
currentPed = nil;
|
|
|
|
stateToReturn = NO_PED;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pedOnGround)
|
|
|
|
* pedOnGround = (CPed*)currentPed;
|
|
|
|
|
|
|
|
return stateToReturn;
|
|
|
|
}
|
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
bool
|
|
|
|
CPed::IsPlayer(void)
|
|
|
|
{
|
|
|
|
return m_nPedType == PEDTYPE_PLAYER1 || m_nPedType== PEDTYPE_PLAYER2 ||
|
|
|
|
m_nPedType == PEDTYPE_PLAYER3 || m_nPedType == PEDTYPE_PLAYER4;
|
|
|
|
}
|
|
|
|
|
2019-05-28 06:39:36 +00:00
|
|
|
bool
|
|
|
|
CPed::UseGroundColModel(void)
|
|
|
|
{
|
|
|
|
return m_nPedState == PED_FALL ||
|
|
|
|
m_nPedState == PED_DIVE_AWAY ||
|
|
|
|
m_nPedState == PED_DIE ||
|
|
|
|
m_nPedState == PED_DEAD;
|
|
|
|
}
|
2019-06-14 12:33:08 +00:00
|
|
|
|
2019-06-24 14:57:54 +00:00
|
|
|
bool
|
|
|
|
CPed::CanSetPedState(void)
|
|
|
|
{
|
|
|
|
return m_nPedState != PED_DIE && m_nPedState != PED_ARRESTED &&
|
2019-06-27 12:01:55 +00:00
|
|
|
m_nPedState != PED_ENTER_CAR && m_nPedState != PED_DEAD && m_nPedState != PED_CARJACK && m_nPedState != PED_STEAL_CAR;
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-14 12:33:08 +00:00
|
|
|
void
|
|
|
|
CPed::AddWeaponModel(int id)
|
|
|
|
{
|
2019-06-20 11:22:44 +00:00
|
|
|
RpAtomic *atm;
|
2019-06-14 12:33:08 +00:00
|
|
|
|
|
|
|
if (id != -1) {
|
|
|
|
atm = (RpAtomic*)CModelInfo::GetModelInfo(id)->CreateInstance();
|
|
|
|
RwFrameDestroy(RpAtomicGetFrame(atm));
|
2019-06-15 15:53:25 +00:00
|
|
|
RpAtomicSetFrame(atm, GetNodeFrame(PED_HANDR));
|
2019-06-14 12:33:08 +00:00
|
|
|
RpClumpAddAtomic((RpClump*)m_rwObject, atm);
|
|
|
|
m_wepModelID = id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-20 11:22:44 +00:00
|
|
|
CPed::AimGun(void)
|
2019-06-14 12:33:08 +00:00
|
|
|
{
|
|
|
|
RwV3d pos;
|
|
|
|
CVector vector;
|
|
|
|
|
|
|
|
if (m_pSeekTarget) {
|
2019-06-27 12:01:55 +00:00
|
|
|
if (m_pSeekTarget->IsPed()) {
|
|
|
|
((CPed*)m_pSeekTarget)->m_pedIK.GetComponentPosition(&pos, PED_TORSO);
|
2019-06-14 12:33:08 +00:00
|
|
|
vector.x = pos.x;
|
|
|
|
vector.y = pos.y;
|
|
|
|
vector.z = pos.z;
|
|
|
|
} else {
|
2019-06-16 18:39:48 +00:00
|
|
|
vector = *(m_pSeekTarget->GetPosition());
|
2019-06-14 12:33:08 +00:00
|
|
|
}
|
2019-06-27 12:01:55 +00:00
|
|
|
Say(SOUND_PED_ATTACK);
|
2019-06-14 12:33:08 +00:00
|
|
|
|
2019-06-19 12:20:50 +00:00
|
|
|
bCanPointGunAtTarget = m_pedIK.PointGunAtPosition(&vector);
|
2019-06-19 12:06:13 +00:00
|
|
|
if (m_pLookTarget != m_pSeekTarget) {
|
2019-06-27 12:01:55 +00:00
|
|
|
SetLookFlag(m_pSeekTarget, 1);
|
2019-06-14 12:33:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2019-06-27 12:01:55 +00:00
|
|
|
if (IsPlayer()) {
|
2019-06-19 12:20:50 +00:00
|
|
|
bCanPointGunAtTarget = m_pedIK.PointGunInDirection(m_fLookDirection, ((CPlayerPed*)this)->m_fFPSMoveHeading);
|
2019-06-14 12:33:08 +00:00
|
|
|
} else {
|
2019-06-19 12:20:50 +00:00
|
|
|
bCanPointGunAtTarget = m_pedIK.PointGunInDirection(m_fLookDirection, 0.0f);
|
2019-06-14 12:33:08 +00:00
|
|
|
}
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::ApplyHeadShot(eWeaponType weaponType, CVector pos, bool evenOnPlayer)
|
|
|
|
{
|
|
|
|
CVector pos2 = CVector(
|
|
|
|
pos.x,
|
|
|
|
pos.y,
|
2019-06-16 18:39:48 +00:00
|
|
|
pos.z + 0.1f
|
2019-06-15 15:53:25 +00:00
|
|
|
);
|
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
if (!CPed::IsPlayer() || evenOnPlayer) {
|
2019-06-15 15:53:25 +00:00
|
|
|
++CStats::HeadShots;
|
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
// BUG: This condition will always return true.
|
2019-06-15 15:53:25 +00:00
|
|
|
if (m_nPedState != PED_PASSENGER || m_nPedState != PED_TAXI_PASSENGER) {
|
2019-06-16 18:39:48 +00:00
|
|
|
CPed::SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
m_ped_flagC20 = true;
|
2019-06-15 15:53:25 +00:00
|
|
|
m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 150;
|
|
|
|
|
|
|
|
CParticle::AddParticle(PARTICLE_TEST, pos2,
|
2019-06-16 21:12:14 +00:00
|
|
|
CVector(0.0f, 0.0f, 0.0f), nil, 0.2f, 0, 0, 0, 0);
|
2019-06-15 15:53:25 +00:00
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
if (CEntity::GetIsOnScreen()) {
|
|
|
|
for(int i=0; i < 32; i++) {
|
2019-06-15 15:53:25 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL,
|
2019-06-16 21:12:14 +00:00
|
|
|
pos2, CVector(0.0f, 0.0f, 0.03f),
|
|
|
|
nil, 0.0f, 0, 0, 0, 0);
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2019-06-15 15:53:25 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_DEBRIS2,
|
2019-06-16 21:12:14 +00:00
|
|
|
pos2,
|
|
|
|
CVector(0.0f, 0.0f, 0.01f),
|
|
|
|
nil, 0.0f, 0, 0, 0, 0);
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-16 21:12:14 +00:00
|
|
|
CPed::RemoveBodyPart(PedNode nodeId, int8 unk)
|
2019-06-15 15:53:25 +00:00
|
|
|
{
|
|
|
|
RwFrame *frame;
|
2019-06-22 23:01:21 +00:00
|
|
|
RwV3d pos;
|
2019-06-15 15:53:25 +00:00
|
|
|
|
|
|
|
frame = GetNodeFrame(nodeId);
|
2019-06-16 18:39:48 +00:00
|
|
|
if (frame) {
|
|
|
|
if (CGame::nastyGame) {
|
2019-06-15 15:53:25 +00:00
|
|
|
if (nodeId != PED_HEAD)
|
2019-06-16 21:12:14 +00:00
|
|
|
CPed::SpawnFlyingComponent(nodeId, unk);
|
2019-06-15 15:53:25 +00:00
|
|
|
|
|
|
|
RecurseFrameChildrenVisibilityCB(frame, 0);
|
2019-06-22 23:01:21 +00:00
|
|
|
pos.x = 0.0f;
|
|
|
|
pos.y = 0.0f;
|
2019-06-24 14:57:54 +00:00
|
|
|
pos.z = 0.0f;
|
|
|
|
|
2019-06-22 23:01:21 +00:00
|
|
|
for (frame = RwFrameGetParent(frame); frame; frame = RwFrameGetParent(frame))
|
|
|
|
RwV3dTransformPoints(&pos, &pos, 1, RwFrameGetMatrix(frame));
|
2019-06-15 15:53:25 +00:00
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
if (CEntity::GetIsOnScreen()) {
|
2019-06-22 23:01:21 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_TEST, pos,
|
2019-06-16 21:12:14 +00:00
|
|
|
CVector(0.0f, 0.0f, 0.0f),
|
|
|
|
nil, 0.2f, 0, 0, 0, 0);
|
2019-06-15 15:53:25 +00:00
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
for (int i = 0; i < 16; i++) {
|
2019-06-15 15:53:25 +00:00
|
|
|
CParticle::AddParticle(PARTICLE_BLOOD_SMALL,
|
2019-06-22 23:01:21 +00:00
|
|
|
pos,
|
2019-06-16 21:12:14 +00:00
|
|
|
CVector(0.0f, 0.0f, 0.03f),
|
|
|
|
nil, 0.0f, 0, 0, 0, 0);
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-20 11:22:44 +00:00
|
|
|
m_ped_flagC20 = true;
|
2019-06-15 15:53:25 +00:00
|
|
|
m_bodyPartBleeding = nodeId;
|
|
|
|
}
|
2019-06-16 18:39:48 +00:00
|
|
|
} else {
|
2019-06-15 15:53:25 +00:00
|
|
|
printf("Trying to remove ped component");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RwObject*
|
|
|
|
CPed::SetPedAtomicVisibilityCB(RwObject *object, void *data)
|
|
|
|
{
|
2019-06-16 21:12:14 +00:00
|
|
|
if (data == 0)
|
2019-06-16 18:39:48 +00:00
|
|
|
RpAtomicSetFlags(object, 0);
|
2019-06-16 21:12:14 +00:00
|
|
|
return object;
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RwFrame*
|
|
|
|
CPed::RecurseFrameChildrenVisibilityCB(RwFrame *frame, void *data)
|
|
|
|
{
|
|
|
|
RwFrameForAllObjects(frame, SetPedAtomicVisibilityCB, data);
|
|
|
|
RwFrameForAllChildren(frame, RecurseFrameChildrenVisibilityCB, 0);
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-06-27 12:01:55 +00:00
|
|
|
CPed::SetLookFlag(CEntity *target, bool unknown)
|
2019-06-15 15:53:25 +00:00
|
|
|
{
|
2019-06-16 18:39:48 +00:00
|
|
|
if (m_lookTimer < CTimer::GetTimeInMilliseconds()) {
|
2019-06-19 12:06:13 +00:00
|
|
|
bIsLooking = true;
|
2019-06-19 12:20:50 +00:00
|
|
|
bIsRestoringLook = false;
|
2019-06-19 12:06:13 +00:00
|
|
|
m_pLookTarget = target;
|
|
|
|
m_pLookTarget->RegisterReference((CEntity**)&m_pLookTarget);
|
2019-06-16 18:39:48 +00:00
|
|
|
m_fLookDirection = 999999.0f;
|
2019-06-15 15:53:25 +00:00
|
|
|
m_lookTimer = 0;
|
2019-06-20 11:22:44 +00:00
|
|
|
m_ped_flagA20 = unknown;
|
2019-06-15 15:53:25 +00:00
|
|
|
if (m_nPedState != PED_DRIVING) {
|
2019-06-18 12:34:27 +00:00
|
|
|
m_pedIK.m_flags &= ~CPedIK::FLAG_2;
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
2019-06-14 12:33:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-15 15:53:25 +00:00
|
|
|
void
|
2019-06-19 12:06:13 +00:00
|
|
|
CPed::SetLookFlag(float direction, bool unknown)
|
2019-06-15 15:53:25 +00:00
|
|
|
{
|
2019-06-16 18:39:48 +00:00
|
|
|
if (m_lookTimer < CTimer::GetTimeInMilliseconds()) {
|
2019-06-19 12:06:13 +00:00
|
|
|
bIsLooking = true;
|
2019-06-19 12:20:50 +00:00
|
|
|
bIsRestoringLook = false;
|
2019-06-19 12:06:13 +00:00
|
|
|
m_pLookTarget = nil;
|
|
|
|
m_fLookDirection = direction;
|
2019-06-15 15:53:25 +00:00
|
|
|
m_lookTimer = 0;
|
2019-06-20 11:22:44 +00:00
|
|
|
m_ped_flagA20 = unknown;
|
2019-06-15 15:53:25 +00:00
|
|
|
if (m_nPedState != PED_DRIVING) {
|
2019-06-18 12:34:27 +00:00
|
|
|
m_pedIK.m_flags &= ~CPedIK::FLAG_2;
|
2019-06-15 15:53:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-16 18:39:48 +00:00
|
|
|
void
|
|
|
|
CPed::SetLookTimer(int time)
|
|
|
|
{
|
|
|
|
if (CTimer::GetTimeInMilliseconds() > m_lookTimer) {
|
|
|
|
m_lookTimer = CTimer::GetTimeInMilliseconds() + time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2019-06-19 12:06:13 +00:00
|
|
|
CPed::OurPedCanSeeThisOne(CEntity *target)
|
2019-06-16 18:39:48 +00:00
|
|
|
{
|
|
|
|
CColPoint colpoint;
|
2019-06-19 12:06:13 +00:00
|
|
|
CEntity *ent;
|
2019-06-16 18:39:48 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
CVector2D dist = CVector2D(target->GetPosition()) - CVector2D(this->GetPosition());
|
2019-06-16 18:39:48 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
// Check if target is behind ped
|
|
|
|
if (DotProduct2D(dist, CVector2D(this->GetForward())) < 0.0f)
|
2019-06-26 09:35:34 +00:00
|
|
|
return false;
|
2019-06-16 18:39:48 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
// Check if target is too far away
|
2019-06-26 09:35:34 +00:00
|
|
|
if (dist.Magnitude() >= 40.0f)
|
|
|
|
return false;
|
2019-06-16 18:39:48 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
// Check line of sight from head
|
|
|
|
CVector headPos = this->GetPosition();
|
|
|
|
headPos.z += 1.0f;
|
|
|
|
return !CWorld::ProcessLineOfSight(headPos, target->GetPosition(), colpoint, ent, true, false, false, false, false, false);
|
2019-06-16 18:39:48 +00:00
|
|
|
}
|
2019-06-15 15:53:25 +00:00
|
|
|
|
2019-06-17 09:48:42 +00:00
|
|
|
void
|
2019-06-19 12:06:13 +00:00
|
|
|
CPed::Avoid(void)
|
|
|
|
{
|
|
|
|
CPed *nearestPed;
|
|
|
|
|
|
|
|
if(m_pedStats->m_temper > m_pedStats->m_fear && m_pedStats->m_temper > 50)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (CTimer::GetTimeInMilliseconds() > m_nPedStateTimer) {
|
|
|
|
|
|
|
|
if (m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL) {
|
2019-06-17 09:48:42 +00:00
|
|
|
nearestPed = m_nearPeds[0];
|
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
if (nearestPed && nearestPed->m_nPedState != PED_DEAD && nearestPed != m_pSeekTarget && nearestPed != m_field_16C) {
|
|
|
|
|
|
|
|
// Check if this ped wants to avoid the nearest one
|
|
|
|
if (CPedType::GetAvoid(this->m_nPedType) & CPedType::GetFlag(nearestPed->m_nPedType)) {
|
2019-06-17 09:48:42 +00:00
|
|
|
|
|
|
|
// Further codes checks whether the distance between us and ped will be equal or below 1.0, if we walk up to him by 1.25 meters.
|
|
|
|
// If so, we want to avoid it, so we turn our body 45 degree and look to somewhere else.
|
2019-06-18 12:55:39 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
// Game converts from radians to degress and back again here, doesn't make much sense
|
|
|
|
CVector2D forward(-sin(m_fRotationCur), cos(m_fRotationCur));
|
|
|
|
forward.Normalise(); // this is kinda pointless
|
2019-06-18 12:55:39 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
// Move forward 1.25 meters
|
|
|
|
CVector2D testPosition = CVector2D(GetPosition()) + forward*1.25f;
|
2019-06-18 12:34:27 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
// Get distance to ped we want to avoid
|
|
|
|
CVector2D distToPed = CVector2D(nearestPed->GetPosition()) - testPosition;
|
2019-06-18 12:34:27 +00:00
|
|
|
|
2019-06-19 12:06:13 +00:00
|
|
|
if (distToPed.Magnitude() <= 1.0f && CPed::OurPedCanSeeThisOne((CEntity*)nearestPed)) {
|
2019-06-17 09:48:42 +00:00
|
|
|
m_nPedStateTimer = CTimer::GetTimeInMilliseconds()
|
|
|
|
+ 500 + (m_randomSeed + 3 * CTimer::GetFrameCounter())
|
|
|
|
% 1000 / 5;
|
|
|
|
|
|
|
|
m_fRotationDest += DEGTORAD(45.0f);
|
2019-06-19 12:06:13 +00:00
|
|
|
if (!bIsLooking) {
|
2019-06-17 09:48:42 +00:00
|
|
|
CPed::SetLookFlag(nearestPed, 0);
|
2019-06-28 16:19:00 +00:00
|
|
|
CPed::SetLookTimer(CGeneral::GetRandomNumberInRange(500, 800));
|
2019-06-17 09:48:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
void
|
|
|
|
CPed::ClearAimFlag(void)
|
|
|
|
{
|
|
|
|
if (bIsAimingGun) {
|
|
|
|
bIsAimingGun = false;
|
|
|
|
bIsRestoringGun = true;
|
|
|
|
m_pedIK.m_flags &= ~CPedIK:: FLAG_4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CPed::IsPlayer())
|
|
|
|
((CPlayerPed*)this)->m_fFPSMoveHeading = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::ClearLookFlag(void) {
|
|
|
|
if (bIsLooking) {
|
|
|
|
bIsLooking = false;
|
|
|
|
bIsRestoringLook = true;
|
|
|
|
m_ped_flagI1 = false;
|
|
|
|
|
|
|
|
m_pedIK.m_flags &= ~CPedIK::FLAG_2;
|
|
|
|
if (CPed::IsPlayer())
|
|
|
|
m_lookTimer = CTimer::GetTimeInMilliseconds() + 2000;
|
|
|
|
else
|
|
|
|
m_lookTimer = CTimer::GetTimeInMilliseconds() + 4000;
|
|
|
|
|
|
|
|
if (m_nPedState == PED_LOOK_HEADING || m_nPedState == PED_LOOK_ENTITY) {
|
|
|
|
CPed::RestorePreviousState();
|
|
|
|
CPed::ClearLookFlag();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
CPed::IsPedHeadAbovePos(float zOffset)
|
|
|
|
{
|
|
|
|
RwMatrix mat;
|
|
|
|
|
|
|
|
CPedIK::GetWorldMatrix(GetNodeFrame(PED_HEAD), &mat);
|
2019-06-26 19:33:58 +00:00
|
|
|
return zOffset + GetPosition().z < RwMatrixGetPos(&mat)->z;
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
|
|
|
|
{
|
|
|
|
CWeaponInfo *currentWeapon;
|
|
|
|
CAnimBlendAssociation *newAnim;
|
|
|
|
CPed *ped = (CPed*)arg;
|
|
|
|
|
|
|
|
if (attackAssoc) {
|
|
|
|
switch (attackAssoc->animId) {
|
|
|
|
case ANIM_WEAPON_START_THROW:
|
2019-06-27 12:01:55 +00:00
|
|
|
if ((!ped->IsPlayer() || ((CPlayerPed*)ped)->field_1380) && ped->IsPlayer()) {
|
2019-06-25 08:40:54 +00:00
|
|
|
attackAssoc->blendDelta = -1000.0f;
|
2019-06-20 11:22:44 +00:00
|
|
|
newAnim = CAnimManager::AddAnimation((RpClump*)ped->m_rwObject, ASSOCGRP_STD, ANIM_WEAPON_THROWU);
|
|
|
|
} else {
|
2019-06-25 08:40:54 +00:00
|
|
|
attackAssoc->blendDelta = -1000.0f;
|
2019-06-20 11:22:44 +00:00
|
|
|
newAnim = CAnimManager::AddAnimation((RpClump*)ped->m_rwObject, ASSOCGRP_STD, ANIM_WEAPON_THROW);
|
|
|
|
}
|
|
|
|
|
2019-06-25 08:40:54 +00:00
|
|
|
newAnim->SetFinishCallback(FinishedAttackCB, ped);
|
|
|
|
return;
|
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
case ANIM_FIGHT_PPUNCH:
|
2019-06-25 08:40:54 +00:00
|
|
|
attackAssoc->blendDelta = -8.0f;
|
2019-06-20 11:22:44 +00:00
|
|
|
attackAssoc->flags |= ASSOC_DELETEFADEDOUT;
|
|
|
|
ped->ClearAttack();
|
2019-06-25 08:40:54 +00:00
|
|
|
return;
|
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
case ANIM_WEAPON_THROW:
|
|
|
|
case ANIM_WEAPON_THROWU:
|
|
|
|
if (ped->GetWeapon()->m_nAmmoTotal > 0) {
|
|
|
|
currentWeapon = CWeaponInfo::GetWeaponInfo(ped->GetWeapon()->m_eWeaponType);
|
|
|
|
ped->AddWeaponModel(currentWeapon->m_nModelId);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-06-25 08:40:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ped->m_ped_flagA4)
|
2019-06-20 11:22:44 +00:00
|
|
|
ped->ClearAttack();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::Attack(void)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *weaponAnimAssoc;
|
|
|
|
int32 weaponAnim;
|
|
|
|
float animStart;
|
2019-06-22 23:01:21 +00:00
|
|
|
RwFrame *frame;
|
2019-06-20 11:22:44 +00:00
|
|
|
eWeaponType ourWeaponType;
|
|
|
|
float weaponAnimTime;
|
|
|
|
eWeaponFire ourWeaponFire;
|
2019-06-28 16:19:00 +00:00
|
|
|
float animLoopEnd;
|
2019-06-20 11:22:44 +00:00
|
|
|
CWeaponInfo *ourWeapon;
|
|
|
|
bool lastReloadWasInFuture;
|
|
|
|
AnimationId reloadAnim;
|
|
|
|
CAnimBlendAssociation *reloadAnimAssoc;
|
|
|
|
float delayBetweenAnimAndFire;
|
|
|
|
CVector firePos;
|
|
|
|
|
|
|
|
ourWeaponType = GetWeapon()->m_eWeaponType;
|
|
|
|
ourWeapon = CWeaponInfo::GetWeaponInfo(ourWeaponType);
|
|
|
|
ourWeaponFire = ourWeapon->m_eWeaponFire;
|
|
|
|
weaponAnimAssoc = RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, ourWeapon->m_AnimToPlay);
|
|
|
|
lastReloadWasInFuture = m_ped_flagA4;
|
2019-06-24 14:57:54 +00:00
|
|
|
reloadAnimAssoc = nil;
|
2019-06-20 11:22:44 +00:00
|
|
|
reloadAnim = NUM_ANIMS;
|
|
|
|
delayBetweenAnimAndFire = ourWeapon->m_fAnimFrameFire;
|
|
|
|
weaponAnim = ourWeapon->m_AnimToPlay;
|
|
|
|
|
|
|
|
if (weaponAnim == ANIM_WEAPON_HGUN_BODY)
|
|
|
|
reloadAnim = ANIM_HGUN_RELOAD;
|
|
|
|
else if (weaponAnim == ANIM_WEAPON_AK_BODY)
|
|
|
|
reloadAnim = ANIM_AK_RELOAD;
|
|
|
|
|
|
|
|
if (reloadAnim != NUM_ANIMS)
|
|
|
|
reloadAnimAssoc = RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, reloadAnim);
|
|
|
|
|
2019-06-28 16:19:00 +00:00
|
|
|
if (bCantFireBecauseCrouched)
|
2019-06-20 11:22:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (reloadAnimAssoc) {
|
|
|
|
if (!CPed::IsPlayer() || ((CPlayerPed*)this)->field_1380)
|
2019-06-24 14:57:54 +00:00
|
|
|
ClearAttack();
|
2019-06-20 11:22:44 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// BUG: We currently don't know any situation this cond. could be true.
|
|
|
|
if (CTimer::GetTimeInMilliseconds() < m_lastHitTime)
|
|
|
|
lastReloadWasInFuture = true;
|
|
|
|
|
|
|
|
if (!weaponAnimAssoc) {
|
2019-06-24 14:57:54 +00:00
|
|
|
weaponAnimAssoc = RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, ourWeapon->m_Anim2ToPlay);
|
|
|
|
delayBetweenAnimAndFire = ourWeapon->m_fAnim2FrameFire;
|
|
|
|
|
|
|
|
// Long throw granade, molotov
|
|
|
|
if (!weaponAnimAssoc && ourWeapon->m_bThrow) {
|
2019-06-20 21:44:06 +00:00
|
|
|
weaponAnimAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_WEAPON_THROWU);
|
2019-06-20 11:22:44 +00:00
|
|
|
delayBetweenAnimAndFire = 0.2f;
|
|
|
|
}
|
2019-06-20 21:44:06 +00:00
|
|
|
}
|
|
|
|
if (weaponAnimAssoc) {
|
2019-06-20 11:22:44 +00:00
|
|
|
animStart = ourWeapon->m_fAnimLoopStart;
|
|
|
|
weaponAnimTime = weaponAnimAssoc->currentTime;
|
|
|
|
if (weaponAnimTime > animStart && weaponAnimTime - weaponAnimAssoc->timeStep <= animStart) {
|
|
|
|
if (ourWeapon->m_bCanAimWithArm)
|
|
|
|
m_pedIK.m_flags |= CPedIK::FLAG_4;
|
|
|
|
else
|
|
|
|
m_pedIK.m_flags &= ~CPedIK::FLAG_4;
|
|
|
|
}
|
2019-06-28 16:19:00 +00:00
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
if (weaponAnimTime <= delayBetweenAnimAndFire || weaponAnimTime - weaponAnimAssoc->timeStep > delayBetweenAnimAndFire || !weaponAnimAssoc->IsRunning()) {
|
|
|
|
if (weaponAnimAssoc->speed < 1.0f)
|
|
|
|
weaponAnimAssoc->speed = 1.0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
firePos = ourWeapon->m_vecFireOffset;
|
|
|
|
if (ourWeaponType == WEAPONTYPE_BASEBALLBAT) {
|
|
|
|
if (weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
|
|
|
|
firePos.z = 0.7f * ourWeapon->m_fRadius - 1.0f;
|
|
|
|
|
|
|
|
firePos = GetMatrix() * firePos;
|
|
|
|
} else if (ourWeaponType != WEAPONTYPE_UNARMED) {
|
|
|
|
if (weaponAnimAssoc->animId == ANIM_KICK_FLOOR)
|
2019-06-22 23:01:21 +00:00
|
|
|
frame = GetNodeFrame(PED_FOOTR);
|
2019-06-20 11:22:44 +00:00
|
|
|
else
|
2019-06-22 23:01:21 +00:00
|
|
|
frame = GetNodeFrame(PED_HANDR);
|
2019-06-20 11:22:44 +00:00
|
|
|
|
2019-06-22 23:01:21 +00:00
|
|
|
for (; frame; frame = RwFrameGetParent(frame))
|
|
|
|
RwV3dTransformPoints((RwV3d*)firePos, (RwV3d*)firePos, 1, RwFrameGetMatrix(frame));
|
2019-06-20 11:22:44 +00:00
|
|
|
} else {
|
|
|
|
firePos = GetMatrix() * firePos;
|
|
|
|
}
|
2019-06-21 18:16:51 +00:00
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
GetWeapon()->Fire(this, &firePos);
|
|
|
|
|
|
|
|
if (ourWeaponType == WEAPONTYPE_MOLOTOV || ourWeaponType == WEAPONTYPE_GRENADE) {
|
|
|
|
RemoveWeaponModel(ourWeapon->m_nModelId);
|
|
|
|
}
|
|
|
|
if (!GetWeapon()->m_nAmmoTotal && ourWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
|
|
|
|
SelectGunIfArmed();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetWeapon()->m_eWeaponState != WEAPONSTATE_MELEE_MADECONTACT) {
|
|
|
|
// If reloading just began, start the animation
|
|
|
|
if (GetWeapon()->m_eWeaponState == WEAPONSTATE_RELOADING && reloadAnim != NUM_ANIMS && !reloadAnimAssoc) {
|
|
|
|
CAnimManager::BlendAnimation((RpClump*) m_rwObject, ASSOCGRP_STD, reloadAnim, 8.0f);
|
2019-06-25 08:40:54 +00:00
|
|
|
ClearLookFlag();
|
|
|
|
ClearAimFlag();
|
2019-06-20 11:22:44 +00:00
|
|
|
m_ped_flagA4 = false;
|
2019-06-24 14:57:54 +00:00
|
|
|
bIsPointingGunAt = false;
|
2019-06-20 11:22:44 +00:00
|
|
|
m_lastHitTime = CTimer::GetTimeInMilliseconds();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2019-06-25 08:40:54 +00:00
|
|
|
if (weaponAnimAssoc->animId == ANIM_WEAPON_BAT_V || weaponAnimAssoc->animId == ANIM_WEAPON_BAT_H) {
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, 1.0f);
|
2019-06-20 11:22:44 +00:00
|
|
|
} else if (weaponAnimAssoc->animId == ANIM_FIGHT_PPUNCH) {
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_PUNCH_ATTACK, 0.0f);
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 16:19:00 +00:00
|
|
|
weaponAnimAssoc->speed = 0.5f;
|
2019-06-20 11:22:44 +00:00
|
|
|
|
|
|
|
// BUG: We currently don't know any situation this cond. could be true.
|
|
|
|
if (m_ped_flagA4 || CTimer::GetTimeInMilliseconds() < m_lastHitTime) {
|
|
|
|
weaponAnimAssoc->callbackType = 0;
|
|
|
|
}
|
|
|
|
}
|
2019-06-21 18:16:51 +00:00
|
|
|
|
|
|
|
lastReloadWasInFuture = false;
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ourWeaponType == WEAPONTYPE_SHOTGUN) {
|
|
|
|
weaponAnimTime = weaponAnimAssoc->currentTime;
|
2019-06-21 18:16:51 +00:00
|
|
|
firePos = ourWeapon->m_vecFireOffset;
|
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
if (weaponAnimTime > 1.0f && weaponAnimTime - weaponAnimAssoc->timeStep <= 1.0f && weaponAnimAssoc->IsRunning()) {
|
2019-06-22 23:01:21 +00:00
|
|
|
for (frame = GetNodeFrame(PED_HANDR); frame; frame = RwFrameGetParent(frame))
|
|
|
|
RwV3dTransformPoints((RwV3d*)firePos, (RwV3d*)firePos, 1, RwFrameGetMatrix(frame));
|
2019-06-20 11:22:44 +00:00
|
|
|
|
|
|
|
CVector gunshellPos(
|
2019-06-21 18:16:51 +00:00
|
|
|
firePos.x - 0.6f * GetForward().x,
|
|
|
|
firePos.y - 0.6f * GetForward().y,
|
|
|
|
firePos.z - 0.15f * GetUp().z
|
2019-06-20 11:22:44 +00:00
|
|
|
);
|
2019-06-21 18:16:51 +00:00
|
|
|
|
2019-06-20 11:22:44 +00:00
|
|
|
CVector2D gunshellRot(
|
|
|
|
GetRight().x,
|
|
|
|
GetRight().y
|
|
|
|
);
|
|
|
|
|
|
|
|
gunshellRot.Normalise();
|
2019-06-21 18:16:51 +00:00
|
|
|
GetWeapon()->AddGunshell(this, gunshellPos, gunshellRot, 0.025f);
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
2019-06-28 16:19:00 +00:00
|
|
|
animLoopEnd = ourWeapon->m_fAnimLoopEnd;
|
2019-06-20 11:22:44 +00:00
|
|
|
if (ourWeaponFire == WEAPON_FIRE_MELEE && weaponAnimAssoc->animId == ourWeapon->m_Anim2ToPlay)
|
2019-06-28 16:19:00 +00:00
|
|
|
animLoopEnd = 0.56f;
|
2019-06-20 11:22:44 +00:00
|
|
|
|
|
|
|
weaponAnimTime = weaponAnimAssoc->currentTime;
|
|
|
|
|
2019-06-28 16:19:00 +00:00
|
|
|
// Anim loop end, either start the loop again or finish the attack
|
|
|
|
if (weaponAnimTime > animLoopEnd || !weaponAnimAssoc->IsRunning() && ourWeaponFire != WEAPON_FIRE_PROJECTILE) {
|
2019-06-20 11:22:44 +00:00
|
|
|
|
2019-06-28 16:19:00 +00:00
|
|
|
if (weaponAnimTime - 2.0f * weaponAnimAssoc->timeStep <= animLoopEnd
|
2019-06-20 11:22:44 +00:00
|
|
|
&& (m_ped_flagA4 || CTimer::GetTimeInMilliseconds() < m_lastHitTime)
|
|
|
|
&& GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING) {
|
|
|
|
|
|
|
|
weaponAnim = weaponAnimAssoc->animId;
|
|
|
|
if (ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(((CPlayerPed*)this), 0) < PED_ON_THE_FLOOR) {
|
|
|
|
if (weaponAnim != ourWeapon->m_Anim2ToPlay || weaponAnim == ANIM_RBLOCK_CSHOOT) {
|
|
|
|
weaponAnimAssoc->Start(ourWeapon->m_fAnimLoopStart);
|
|
|
|
} else {
|
|
|
|
CAnimManager::BlendAnimation((RpClump*) m_rwObject, ASSOCGRP_STD, ourWeapon->m_AnimToPlay, 8.0f);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (weaponAnim == ourWeapon->m_Anim2ToPlay)
|
|
|
|
weaponAnimAssoc->SetCurrentTime(0.1f);
|
|
|
|
else
|
|
|
|
CAnimManager::BlendAnimation((RpClump*) m_rwObject, ASSOCGRP_STD, ourWeapon->m_Anim2ToPlay, 8.0f);
|
|
|
|
}
|
|
|
|
} else {
|
2019-06-25 08:40:54 +00:00
|
|
|
ClearAimFlag();
|
2019-06-20 11:22:44 +00:00
|
|
|
|
|
|
|
// Echoes of bullets, at the end of the attack. (Bug: doesn't play while reloading)
|
2019-06-25 08:40:54 +00:00
|
|
|
if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep <= ourWeapon->m_fAnimLoopEnd) {
|
|
|
|
switch (ourWeaponType) {
|
|
|
|
case WEAPONTYPE_UZI:
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
|
2019-06-25 08:40:54 +00:00
|
|
|
break;
|
|
|
|
case WEAPONTYPE_AK47:
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f);
|
2019-06-25 08:40:54 +00:00
|
|
|
break;
|
|
|
|
case WEAPONTYPE_M16:
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f);
|
2019-06-25 08:40:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fun fact: removing this part leds to reloading flamethrower
|
|
|
|
if (ourWeaponType == WEAPONTYPE_FLAMETHROWER && weaponAnimAssoc->IsRunning()) {
|
|
|
|
weaponAnimAssoc->flags |= ASSOC_DELETEFADEDOUT;
|
|
|
|
weaponAnimAssoc->flags &= ~ASSOC_RUNNING;
|
2019-06-21 18:16:51 +00:00
|
|
|
weaponAnimAssoc->blendDelta = -4.0f;
|
2019-06-20 11:22:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (weaponAnimAssoc->currentTime > delayBetweenAnimAndFire)
|
|
|
|
lastReloadWasInFuture = false;
|
|
|
|
|
|
|
|
m_ped_flagA4 = lastReloadWasInFuture;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastReloadWasInFuture) {
|
|
|
|
if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !CPed::IsPlayer() || ((CPlayerPed*)this)->field_1380) {
|
|
|
|
if (!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(((CPlayerPed*)this), 0) < PED_ON_THE_FLOOR) {
|
|
|
|
weaponAnimAssoc = CAnimManager::BlendAnimation((RpClump*)m_rwObject, ASSOCGRP_STD, ourWeapon->m_AnimToPlay, 8.0f);
|
|
|
|
} else {
|
|
|
|
weaponAnimAssoc = CAnimManager::BlendAnimation((RpClump*)m_rwObject, ASSOCGRP_STD, ourWeapon->m_Anim2ToPlay, 8.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
weaponAnimAssoc->SetFinishCallback(CPed::FinishedAttackCB, this);
|
|
|
|
weaponAnimAssoc->flags |= ASSOC_RUNNING;
|
|
|
|
|
|
|
|
if (weaponAnimAssoc->currentTime == weaponAnimAssoc->hierarchy->totalLength)
|
|
|
|
weaponAnimAssoc->SetCurrentTime(0.0f);
|
|
|
|
|
|
|
|
if (CPed::IsPlayer()) {
|
|
|
|
((CPlayerPed*)this)->field_1376 = 0.0f;
|
|
|
|
((CPlayerPed*)this)->field_1380 = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
CPed::FinishedAttackCB(0, this);
|
|
|
|
}
|
|
|
|
|
2019-06-21 18:16:51 +00:00
|
|
|
void
|
|
|
|
CPed::RemoveWeaponModel(int modelId)
|
|
|
|
{
|
|
|
|
// modelId is not used!! This function just removes the current weapon.
|
|
|
|
RwFrameForAllObjects(GetNodeFrame(PED_HANDR),RemoveAllModelCB,0);
|
|
|
|
m_wepModelID = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::SetCurrentWeapon(eWeaponType weaponType)
|
|
|
|
{
|
2019-06-24 14:57:54 +00:00
|
|
|
CWeaponInfo *weaponInfo;
|
2019-06-21 18:16:51 +00:00
|
|
|
|
|
|
|
if (HasWeapon(weaponType)) {
|
|
|
|
weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
|
|
|
|
RemoveWeaponModel(weaponInfo->m_nModelId);
|
|
|
|
|
|
|
|
m_currentWeapon = weaponType;
|
|
|
|
|
|
|
|
weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
|
|
|
|
AddWeaponModel(weaponInfo->m_nModelId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only used while deciding which gun ped should switch to, if no ammo left.
|
|
|
|
bool
|
|
|
|
CPed::SelectGunIfArmed(void)
|
|
|
|
{
|
|
|
|
eWeaponType weaponType;
|
|
|
|
|
|
|
|
for (int i = 0; i < m_maxWeaponTypeAllowed; i++) {
|
|
|
|
|
|
|
|
if (m_weapons[i].m_nAmmoTotal > 0) {
|
|
|
|
weaponType = m_weapons[i].m_eWeaponType;
|
|
|
|
|
2019-06-25 08:40:54 +00:00
|
|
|
if (weaponType >= WEAPONTYPE_COLT45 && weaponType != WEAPONTYPE_M16 && weaponType <= WEAPONTYPE_FLAMETHROWER) {
|
2019-06-21 18:16:51 +00:00
|
|
|
SetCurrentWeapon(weaponType);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SetCurrentWeapon(WEAPONTYPE_UNARMED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::Duck(void)
|
|
|
|
{
|
|
|
|
if (CTimer::GetTimeInMilliseconds() > m_duckTimer)
|
|
|
|
ClearDuck();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::ClearDuck(void)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *animAssoc;
|
|
|
|
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_DUCK_DOWN);
|
|
|
|
if (!animAssoc)
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_DUCK_LOW);
|
|
|
|
|
|
|
|
if (animAssoc) {
|
|
|
|
|
|
|
|
if (m_ped_flagE8) {
|
|
|
|
|
|
|
|
if (m_nPedState == PED_ATTACK || m_nPedState == PED_AIM_GUN) {
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_RBLOCK_CSHOOT);
|
|
|
|
if (!animAssoc || animAssoc->blendDelta < 0.0f) {
|
|
|
|
CAnimManager::BlendAnimation((RpClump*) m_rwObject, ASSOCGRP_STD, ANIM_RBLOCK_CSHOOT, 4.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else
|
2019-06-28 16:19:00 +00:00
|
|
|
bCantFireBecauseCrouched = false;
|
2019-06-21 18:16:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::ClearPointGunAt(void)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *animAssoc;
|
|
|
|
CWeaponInfo *weaponInfo;
|
|
|
|
|
|
|
|
ClearLookFlag();
|
|
|
|
ClearAimFlag();
|
2019-06-24 14:57:54 +00:00
|
|
|
bIsPointingGunAt = false;
|
2019-06-21 18:16:51 +00:00
|
|
|
if (m_nPedState == PED_AIM_GUN) {
|
|
|
|
RestorePreviousState();
|
|
|
|
weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, weaponInfo->m_AnimToPlay);
|
|
|
|
if (!animAssoc || animAssoc->blendDelta < 0.0f) {
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, weaponInfo->m_Anim2ToPlay);
|
|
|
|
}
|
|
|
|
if (animAssoc) {
|
|
|
|
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
|
|
|
|
animAssoc->blendDelta = -4.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-24 14:57:54 +00:00
|
|
|
void
|
|
|
|
CPed::BeingDraggedFromCar(void)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *animAssoc;
|
|
|
|
AnimationId enterAnim;
|
|
|
|
bool dontRunAnim = false;
|
|
|
|
PedLineUpPhase lineUpType;
|
|
|
|
|
|
|
|
if (!m_pVehicleAnim) {
|
|
|
|
CAnimManager::BlendAnimation((RpClump*) m_rwObject, m_animGroup, ANIM_IDLE_STANCE, 100.0f);
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_CAR_SIT);
|
|
|
|
if (!animAssoc) {
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_CAR_LSIT);
|
|
|
|
if (!animAssoc) {
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_CAR_SITP);
|
|
|
|
if (!animAssoc)
|
|
|
|
animAssoc = RpAnimBlendClumpGetAssociation((RpClump*) m_rwObject, ANIM_CAR_SITPLO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (animAssoc)
|
|
|
|
animAssoc->blendDelta = -1000.0f;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
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)
|
|
|
|
enterAnim = ANIM_CAR_LJACKED_RHS;
|
|
|
|
else
|
|
|
|
enterAnim = ANIM_CAR_JACKED_RHS;
|
|
|
|
} else
|
|
|
|
dontRunAnim = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (!dontRunAnim)
|
|
|
|
m_pVehicleAnim = CAnimManager::AddAnimation((RpClump*) m_rwObject, ASSOCGRP_STD, enterAnim);
|
|
|
|
|
|
|
|
m_pVehicleAnim->SetFinishCallback(PedSetDraggedOutCarCB, this);
|
|
|
|
lineUpType = LINE_UP_TO_CAR_START;
|
|
|
|
} else if (m_pVehicleAnim->currentTime <= 1.4f) {
|
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
lineUpType = LINE_UP_TO_CAR_START;
|
|
|
|
} else {
|
|
|
|
lineUpType = LINE_UP_TO_CAR_2;
|
|
|
|
}
|
|
|
|
|
|
|
|
LineUpPedWithCar(lineUpType);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::RestartNonPartialAnims(void)
|
|
|
|
{
|
2019-06-28 16:19:00 +00:00
|
|
|
CAnimBlendAssociation *assoc;
|
2019-06-24 14:57:54 +00:00
|
|
|
|
|
|
|
for (assoc = RpAnimBlendClumpGetFirstAssociation((RpClump*)m_rwObject); !assoc; assoc = RpAnimBlendGetNextAssociation(assoc)) {
|
|
|
|
if (!assoc->IsPartial())
|
|
|
|
assoc->flags |= ASSOC_RUNNING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::PedSetDraggedOutCarCB(CAnimBlendAssociation *dragAssoc, void *arg)
|
|
|
|
{
|
|
|
|
CAnimBlendAssociation *quickJackedAssoc;
|
|
|
|
CVehicle *vehicle;
|
|
|
|
CPed *ped = (CPed*)arg;
|
|
|
|
eWeaponType weaponType = ped->GetWeapon()->m_eWeaponType;
|
|
|
|
|
|
|
|
quickJackedAssoc = RpAnimBlendClumpGetAssociation((RpClump*) ped->m_rwObject, ANIM_CAR_QJACKED);
|
|
|
|
if (ped->m_nPedState != PED_ARRESTED) {
|
|
|
|
ped->m_nLastPedState = PED_NONE;
|
|
|
|
if (dragAssoc)
|
|
|
|
dragAssoc->blendDelta = -1000.0;
|
|
|
|
}
|
|
|
|
ped->RestartNonPartialAnims();
|
|
|
|
ped->m_pVehicleAnim = nil;
|
|
|
|
ped->m_pSeekTarget = nil;
|
|
|
|
vehicle = ped->m_pMyVehicle;
|
|
|
|
|
2019-06-26 09:19:56 +00:00
|
|
|
switch (ped->m_vehEnterType) {
|
|
|
|
case VEHICLE_ENTER_FRONT_RIGHT:
|
|
|
|
vehicle->m_nGettingOutFlags &= ~GETTING_IN_OUT_FR;
|
|
|
|
break;
|
|
|
|
case VEHICLE_ENTER_REAR_RIGHT:
|
|
|
|
vehicle->m_nGettingOutFlags &= ~GETTING_IN_OUT_RR;
|
|
|
|
break;
|
|
|
|
case VEHICLE_ENTER_FRONT_LEFT:
|
|
|
|
vehicle->m_nGettingOutFlags &= ~GETTING_IN_OUT_FL;
|
|
|
|
break;
|
|
|
|
case VEHICLE_ENTER_REAR_LEFT:
|
|
|
|
vehicle->m_nGettingOutFlags &= ~GETTING_IN_OUT_RL;
|
|
|
|
break;
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (vehicle->pDriver == ped) {
|
|
|
|
vehicle->RemoveDriver();
|
|
|
|
if (vehicle->m_nDoorLock == CARLOCK_COP_CAR)
|
|
|
|
vehicle->m_nDoorLock = CARLOCK_UNLOCKED;
|
|
|
|
|
|
|
|
if (ped->m_nPedType == PEDTYPE_COP && vehicle->IsLawEnforcementVehicle())
|
|
|
|
vehicle->ChangeLawEnforcerState(false);
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < vehicle->m_nNumMaxPassengers; i++) {
|
|
|
|
if (vehicle->pPassengers[i] == ped) {
|
|
|
|
vehicle->pPassengers[i] = nil;
|
|
|
|
vehicle->m_nNumPassengers--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ped->bInVehicle = false;
|
|
|
|
if (ped->IsPlayer())
|
|
|
|
AudioManager.PlayerJustLeftCar();
|
|
|
|
|
|
|
|
if (quickJackedAssoc) {
|
|
|
|
dragAssoc->SetDeleteCallback(PedSetQuickDraggedOutCarPositionCB, ped);
|
|
|
|
} else {
|
|
|
|
dragAssoc->SetDeleteCallback(PedSetDraggedOutCarPositionCB, ped);
|
|
|
|
if (ped->CanSetPedState())
|
|
|
|
CAnimManager::BlendAnimation((RpClump*) ped->m_rwObject, ASSOCGRP_STD, ANIM_GETUP1, 1000.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Only uzi can be used on cars, so previous weapon was stored
|
|
|
|
if (ped->IsPlayer() && weaponType == WEAPONTYPE_UZI) {
|
|
|
|
if (ped->m_storedWeapon != NO_STORED_WEAPON) {
|
|
|
|
ped->SetCurrentWeapon(ped->m_storedWeapon);
|
|
|
|
ped->m_storedWeapon = NO_STORED_WEAPON;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ped->AddWeaponModel(CWeaponInfo::GetWeaponInfo(weaponType)->m_nModelId);
|
|
|
|
}
|
|
|
|
ped->m_nStoredActionState = 0;
|
|
|
|
ped->m_ped_flagI4 = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::GetLocalPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float seatPosMult)
|
|
|
|
{
|
|
|
|
CVehicleModelInfo *vehModel;
|
|
|
|
CVector vehDoorPos;
|
|
|
|
CVector vehDoorOffset;
|
|
|
|
float seatOffset;
|
|
|
|
|
|
|
|
vehModel = (CVehicleModelInfo*) CModelInfo::GetModelInfo(veh->m_modelIndex);
|
|
|
|
if (veh->bIsVan && (enterType == VEHICLE_ENTER_REAR_LEFT || enterType == VEHICLE_ENTER_REAR_RIGHT)) {
|
|
|
|
seatOffset = 0.0f;
|
|
|
|
vehDoorOffset = offsetToOpenVanDoor;
|
|
|
|
} else {
|
|
|
|
seatOffset = veh->m_handling->fSeatOffsetDistance * seatPosMult;
|
|
|
|
if (veh->bIsLow) {
|
|
|
|
vehDoorOffset = offsetToOpenLowCarDoor;
|
|
|
|
} else {
|
|
|
|
vehDoorOffset = offsetToOpenRegularCarDoor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (enterType) {
|
|
|
|
case VEHICLE_ENTER_FRONT_RIGHT:
|
|
|
|
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
|
|
|
|
else
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_FRONT_SEATS];
|
|
|
|
|
|
|
|
vehDoorPos.x += seatOffset;
|
|
|
|
vehDoorOffset.x = -vehDoorOffset.x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VEHICLE_ENTER_REAR_RIGHT:
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS];
|
|
|
|
vehDoorPos.x += seatOffset;
|
|
|
|
vehDoorOffset.x = -vehDoorOffset.x;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VEHICLE_ENTER_FRONT_LEFT:
|
|
|
|
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
|
|
|
|
else
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_FRONT_SEATS];
|
|
|
|
|
|
|
|
vehDoorPos.x = -(vehDoorPos.x + seatOffset);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VEHICLE_ENTER_REAR_LEFT:
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_REAR_SEATS];
|
|
|
|
vehDoorPos.x = -(vehDoorPos.x + seatOffset);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
if (vehModel->m_vehicleType == VEHICLE_TYPE_BOAT)
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_BOAT_RUDDER];
|
|
|
|
else
|
|
|
|
vehDoorPos = vehModel->m_positions[VEHICLE_DUMMY_FRONT_SEATS];
|
|
|
|
|
|
|
|
vehDoorOffset = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
}
|
|
|
|
*output = vehDoorPos - vehDoorOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This function was mostly duplicate of GetLocalPositionToOpenCarDoor, so I've used it.
|
|
|
|
void
|
|
|
|
CPed::GetPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType)
|
|
|
|
{
|
|
|
|
CVector localPos;
|
|
|
|
CVector vehDoorPos;
|
|
|
|
|
|
|
|
GetLocalPositionToOpenCarDoor(&localPos, veh, enterType, 1.0f);
|
|
|
|
vehDoorPos = Multiply3x3(veh->GetMatrix(), localPos) + veh->GetPosition();
|
|
|
|
|
|
|
|
/*
|
|
|
|
// Not used.
|
|
|
|
CVector localVehDoorOffset;
|
|
|
|
|
|
|
|
if (veh->bIsVan && (enterType == VEHICLE_ENTER_REAR_LEFT || enterType == VEHICLE_ENTER_REAR_RIGHT)) {
|
|
|
|
localVehDoorOffset = offsetToOpenVanDoor;
|
|
|
|
} else {
|
|
|
|
if (veh->bIsLow) {
|
|
|
|
localVehDoorOffset = offsetToOpenLowCarDoor;
|
|
|
|
} else {
|
|
|
|
localVehDoorOffset = offsetToOpenRegularCarDoor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vehDoorPosWithoutOffset = Multiply3x3(veh->GetMatrix(), localPos + localVehDoorOffset) + veh->GetPosition();
|
|
|
|
*/
|
|
|
|
*output = vehDoorPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::GetPositionToOpenCarDoor(CVector *output, CVehicle *veh, uint32 enterType, float offset)
|
|
|
|
{
|
|
|
|
CVector doorPos;
|
|
|
|
CMatrix vehMat(veh->GetMatrix());
|
|
|
|
|
|
|
|
GetLocalPositionToOpenCarDoor(output, veh, enterType, offset);
|
|
|
|
doorPos = Multiply3x3(vehMat, *output);
|
|
|
|
|
2019-06-25 08:40:54 +00:00
|
|
|
*output = *veh->GetPosition() + doorPos;
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::LineUpPedWithCar(PedLineUpPhase phase)
|
|
|
|
{
|
|
|
|
bool vehIsUpsideDown = false;
|
|
|
|
int vehAnim;
|
|
|
|
float seatPosMult = 0.0f;
|
|
|
|
float currentZ;
|
|
|
|
float adjustedTimeStep;
|
|
|
|
|
|
|
|
if (CReplay::IsPlayingBack())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!m_ped_flagC8 && phase != LINE_UP_TO_CAR_2) {
|
|
|
|
if (RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, ANIM_CAR_SIT)) {
|
|
|
|
SetPedPositionInCar();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, ANIM_CAR_LSIT)) {
|
|
|
|
SetPedPositionInCar();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, ANIM_CAR_SITP)) {
|
|
|
|
SetPedPositionInCar();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (RpAnimBlendClumpGetAssociation((RpClump*)m_rwObject, ANIM_CAR_SITPLO)) {
|
|
|
|
SetPedPositionInCar();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_ped_flagC8 = 1;
|
|
|
|
}
|
|
|
|
if (phase == LINE_UP_TO_CAR_START) {
|
2019-06-25 08:40:54 +00:00
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
CVehicle *veh = m_pMyVehicle;
|
|
|
|
|
|
|
|
// Not quite right, IsUpsideDown func. checks for <= -0.9f.
|
|
|
|
// Since that function is also used in this file, doesn't this variable indicate upsidedownness?!
|
|
|
|
if (veh->GetUp().z <= -0.8f)
|
|
|
|
vehIsUpsideDown = true;
|
|
|
|
|
|
|
|
if (m_vehEnterType == VEHICLE_ENTER_FRONT_RIGHT || m_vehEnterType == VEHICLE_ENTER_REAR_RIGHT) {
|
|
|
|
if (vehIsUpsideDown) {
|
2019-06-29 09:09:33 +00:00
|
|
|
m_fRotationDest = -PI + veh->GetForward().Heading();
|
2019-06-24 14:57:54 +00:00
|
|
|
} else if (veh->bIsBus) {
|
2019-06-29 09:09:33 +00:00
|
|
|
m_fRotationDest = 0.5 * PI + veh->GetForward().Heading();
|
2019-06-24 14:57:54 +00:00
|
|
|
} else {
|
2019-06-29 11:25:47 +00:00
|
|
|
m_fRotationDest = veh->GetForward().Heading();
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
} else if (m_vehEnterType == VEHICLE_ENTER_FRONT_LEFT || m_vehEnterType == VEHICLE_ENTER_REAR_LEFT) {
|
|
|
|
if (vehIsUpsideDown) {
|
2019-06-29 09:09:33 +00:00
|
|
|
m_fRotationDest = veh->GetForward().Heading();
|
2019-06-24 14:57:54 +00:00
|
|
|
} else if (veh->bIsBus) {
|
2019-06-29 09:09:33 +00:00
|
|
|
m_fRotationDest = -0.5 * PI + veh->GetForward().Heading();
|
2019-06-24 14:57:54 +00:00
|
|
|
} else {
|
2019-06-29 09:09:33 +00:00
|
|
|
m_fRotationDest = veh->GetForward().Heading();
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bInVehicle)
|
|
|
|
seatPosMult = 1.0f;
|
|
|
|
|
|
|
|
if (m_pVehicleAnim) {
|
|
|
|
vehAnim = m_pVehicleAnim->animId;
|
|
|
|
|
|
|
|
switch (vehAnim) {
|
|
|
|
case ANIM_CAR_JACKED_RHS:
|
|
|
|
case ANIM_CAR_LJACKED_RHS:
|
|
|
|
case ANIM_CAR_JACKED_LHS:
|
|
|
|
case ANIM_CAR_LJACKED_LHS:
|
|
|
|
case ANIM_CAR_QJACKED:
|
|
|
|
case ANIM_CAR_GETOUT_LHS:
|
|
|
|
case ANIM_CAR_GETOUT_LOW_LHS:
|
|
|
|
case ANIM_CAR_GETOUT_RHS:
|
|
|
|
case ANIM_CAR_GETOUT_LOW_RHS:
|
|
|
|
case ANIM_CAR_CRAWLOUT_RHS:
|
|
|
|
case ANIM_CAR_CRAWLOUT_RHS2:
|
|
|
|
case ANIM_VAN_GETIN_L:
|
|
|
|
case ANIM_VAN_GETOUT_L:
|
|
|
|
case ANIM_VAN_GETIN:
|
|
|
|
case ANIM_VAN_GETOUT:
|
|
|
|
seatPosMult = m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength;
|
|
|
|
break;
|
|
|
|
case ANIM_CAR_QJACK:
|
|
|
|
case ANIM_CAR_GETIN_LHS:
|
|
|
|
case ANIM_CAR_GETIN_LOW_LHS:
|
|
|
|
case ANIM_CAR_GETIN_RHS:
|
|
|
|
case ANIM_CAR_GETIN_LOW_RHS:
|
|
|
|
case ANIM_DRIVE_BOAT:
|
|
|
|
seatPosMult = m_pVehicleAnim->GetTimeLeft() / m_pVehicleAnim->hierarchy->totalLength;
|
|
|
|
break;
|
|
|
|
case ANIM_CAR_CLOSEDOOR_LHS:
|
|
|
|
case ANIM_CAR_CLOSEDOOR_LOW_LHS:
|
|
|
|
case ANIM_CAR_CLOSEDOOR_RHS:
|
|
|
|
case ANIM_CAR_CLOSEDOOR_LOW_RHS:
|
|
|
|
case ANIM_CAR_SHUFFLE_RHS:
|
|
|
|
case ANIM_CAR_LSHUFFLE_RHS:
|
|
|
|
seatPosMult = 0.0f;
|
|
|
|
break;
|
|
|
|
case ANIM_CAR_CLOSE_LHS:
|
|
|
|
case ANIM_CAR_CLOSE_RHS:
|
|
|
|
case ANIM_COACH_OPEN_L:
|
|
|
|
case ANIM_COACH_OPEN_R:
|
|
|
|
case ANIM_COACH_IN_L:
|
|
|
|
case ANIM_COACH_IN_R:
|
|
|
|
case ANIM_COACH_OUT_L:
|
|
|
|
seatPosMult = 1.0f;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CVector neededPos;
|
|
|
|
|
|
|
|
if (phase == LINE_UP_TO_CAR_2) {
|
2019-06-25 08:40:54 +00:00
|
|
|
neededPos = *GetPosition();
|
2019-06-24 14:57:54 +00:00
|
|
|
} else {
|
|
|
|
GetPositionToOpenCarDoor(&neededPos, veh, m_vehEnterType, seatPosMult);
|
|
|
|
}
|
|
|
|
|
|
|
|
CVector autoZPos = neededPos;
|
|
|
|
|
|
|
|
if (veh->bIsInWater) {
|
|
|
|
if (veh->m_vehType == VEHICLE_TYPE_BOAT && veh->IsUpsideDown())
|
|
|
|
autoZPos.z += 1.0f;
|
|
|
|
} else {
|
|
|
|
CPedPlacement::FindZCoorForPed(&autoZPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (phase == LINE_UP_TO_CAR_END || phase == LINE_UP_TO_CAR_2) {
|
|
|
|
neededPos.z = GetPosition().z;
|
|
|
|
|
2019-06-25 08:40:54 +00:00
|
|
|
// Getting out
|
2019-06-24 14:57:54 +00:00
|
|
|
if (!veh->bIsBus || (veh->bIsBus && vehIsUpsideDown)) {
|
2019-06-25 08:40:54 +00:00
|
|
|
float pedZSpeedOnExit = m_vecMoveSpeed.z - 0.008f * CTimer::GetTimeStep();
|
|
|
|
|
|
|
|
// If we're not in ground at next step, apply animation
|
|
|
|
if (neededPos.z + pedZSpeedOnExit > autoZPos.z) {
|
|
|
|
m_vecMoveSpeed.z = pedZSpeedOnExit;
|
|
|
|
ApplyMoveSpeed();
|
|
|
|
// Removing below line breaks the animation
|
|
|
|
neededPos.z = GetPosition().z;
|
2019-06-24 14:57:54 +00:00
|
|
|
} else {
|
|
|
|
neededPos.z = autoZPos.z;
|
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (autoZPos.z > neededPos.z) {
|
|
|
|
currentZ = GetPosition().z;
|
|
|
|
if (m_pVehicleAnim && vehAnim != ANIM_VAN_GETIN_L && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE && vehAnim != ANIM_VAN_GETIN) {
|
|
|
|
neededPos.z = autoZPos.z;
|
|
|
|
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
2019-06-25 08:40:54 +00:00
|
|
|
} else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) {
|
2019-06-24 14:57:54 +00:00
|
|
|
adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f);
|
|
|
|
|
|
|
|
// Smoothly change ped position
|
|
|
|
neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// We may need to raise up the ped
|
|
|
|
if (phase == LINE_UP_TO_CAR_START) {
|
|
|
|
currentZ = GetPosition().z;
|
|
|
|
|
|
|
|
if (neededPos.z > currentZ) {
|
|
|
|
|
|
|
|
if (m_pVehicleAnim &&
|
2019-06-25 08:40:54 +00:00
|
|
|
(vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS
|
2019-06-24 14:57:54 +00:00
|
|
|
|| vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) {
|
|
|
|
adjustedTimeStep = min(m_pVehicleAnim->timeStep, 0.1f);
|
|
|
|
|
|
|
|
// Smoothly change ped position
|
|
|
|
neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ;
|
|
|
|
} else if (m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK) {
|
|
|
|
neededPos.z = max(currentZ, autoZPos.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// I hope
|
2019-06-25 08:40:54 +00:00
|
|
|
bool stillGettingInOut = false;
|
2019-06-24 14:57:54 +00:00
|
|
|
if (CTimer::GetTimeInMilliseconds() < m_nPedStateTimer)
|
2019-06-25 08:40:54 +00:00
|
|
|
stillGettingInOut = veh->m_vehType != VEHICLE_TYPE_BOAT || m_ped_flagG10;
|
2019-06-24 14:57:54 +00:00
|
|
|
|
2019-06-25 08:40:54 +00:00
|
|
|
if (!stillGettingInOut) {
|
2019-06-24 14:57:54 +00:00
|
|
|
m_fRotationCur = m_fRotationDest;
|
|
|
|
} else {
|
|
|
|
float limitedAngle = CGeneral::LimitRadianAngle(m_fRotationDest);
|
2019-06-26 09:19:56 +00:00
|
|
|
float timeUntilStateChange = (m_nPedStateTimer - CTimer::GetTimeInMilliseconds())/600.0f;
|
2019-06-24 14:57:54 +00:00
|
|
|
|
|
|
|
m_vecOffsetSeek.z = 0.0;
|
|
|
|
if (timeUntilStateChange <= 0.0f) {
|
|
|
|
m_vecOffsetSeek.x = 0.0;
|
|
|
|
m_vecOffsetSeek.y = 0.0;
|
|
|
|
} else {
|
|
|
|
neededPos -= timeUntilStateChange * m_vecOffsetSeek;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limitedAngle >= PI + m_fRotationCur) {
|
|
|
|
limitedAngle -= 2 * PI;
|
|
|
|
} else if (limitedAngle <= m_fRotationCur - PI) {
|
|
|
|
limitedAngle += 2 * PI;
|
|
|
|
}
|
|
|
|
m_fRotationCur -= (m_fRotationCur - limitedAngle) * (1.0f - timeUntilStateChange);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (seatPosMult > 0.2f || vehIsUpsideDown) {
|
2019-06-25 08:40:54 +00:00
|
|
|
GetPosition() = neededPos;
|
|
|
|
|
2019-06-24 14:57:54 +00:00
|
|
|
GetMatrix().SetRotate(0.0f, 0.0f, m_fRotationCur);
|
|
|
|
|
|
|
|
// It will be all 0 after rotate.
|
|
|
|
GetPosition() = neededPos;
|
|
|
|
} else {
|
|
|
|
CVector output;
|
|
|
|
CMatrix vehDoorMat(veh->GetMatrix());
|
|
|
|
|
|
|
|
GetLocalPositionToOpenCarDoor(&output, veh, m_vehEnterType, 0.0f);
|
|
|
|
*vehDoorMat.GetPosition() += Multiply3x3(vehDoorMat, output);
|
|
|
|
GetMatrix() = vehDoorMat;
|
|
|
|
}
|
2019-06-25 08:40:54 +00:00
|
|
|
|
2019-06-24 14:57:54 +00:00
|
|
|
}
|
|
|
|
|
2019-06-28 16:19:00 +00:00
|
|
|
static void
|
|
|
|
particleProduceFootDust(CPed *ped, CVector *pos, float size, int times)
|
|
|
|
{
|
|
|
|
switch (ped->m_nLastCollType)
|
|
|
|
{
|
|
|
|
case 1: // somewhere hard
|
|
|
|
case 3: // soft dirt
|
|
|
|
case 5: // pavement
|
|
|
|
case 18:// sand
|
|
|
|
for (int i = 0; i < times; ++i) {
|
|
|
|
CVector adjustedPos = *pos;
|
|
|
|
adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
adjustedPos.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
CParticle::AddParticle(PARTICLE_PEDFOOT_DUST, adjustedPos, CVector(0.0f, 0.0f, 0.0f), nil, size, CRGBA(0, 0, 0, 0), 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
particleProduceFootSplash(CPed *ped, CVector *pos, float size, int times)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < times; i++) {
|
|
|
|
CVector adjustedPos = *pos;
|
|
|
|
adjustedPos.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
adjustedPos.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f);
|
|
|
|
|
|
|
|
CVector direction = ped->GetForward() * -0.05f;
|
|
|
|
CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, adjustedPos, direction, nil, size, CRGBA(32, 32, 32, 32), 0, 0, CGeneral::GetRandomNumberInRange(0, 1), 200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CPed::PlayFootSteps(void)
|
|
|
|
{
|
|
|
|
if (bDoBloodyFootprints) {
|
|
|
|
if (m_bloodyFootprintCount > 0 && m_bloodyFootprintCount < 300) {
|
|
|
|
m_bloodyFootprintCount--;
|
|
|
|
|
|
|
|
if (m_bloodyFootprintCount == 0)
|
|
|
|
bDoBloodyFootprints = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bIsStanding)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CAnimBlendAssociation *assoc = RpAnimBlendClumpGetFirstAssociation((RpClump*)m_rwObject);
|
|
|
|
CAnimBlendAssociation *walkRunAssoc = nil;
|
|
|
|
float walkRunAssocBlend = 0.0f, idleAssocBlend = 0.0f;
|
|
|
|
|
|
|
|
for (; assoc; assoc = RpAnimBlendGetNextAssociation(assoc)) {
|
|
|
|
if (assoc->flags & ASSOC_FLAG80) {
|
|
|
|
walkRunAssoc = assoc;
|
|
|
|
walkRunAssocBlend += assoc->blendAmount;
|
|
|
|
} else if ((assoc->flags & ASSOC_FLAG200) == 0) {
|
|
|
|
idleAssocBlend += assoc->blendAmount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (walkRunAssoc && walkRunAssocBlend > 0.5f && idleAssocBlend < 1.0f) {
|
|
|
|
float stepStart = 1 / 15.0f;
|
|
|
|
float stepEnd = walkRunAssoc->hierarchy->totalLength / 2.0f + stepStart;
|
|
|
|
float currentTime = walkRunAssoc->currentTime;
|
|
|
|
int stepPart = 0;
|
|
|
|
|
|
|
|
if (currentTime >= stepStart && currentTime - walkRunAssoc->timeStep < stepStart)
|
|
|
|
stepPart = 1;
|
|
|
|
else if (currentTime >= stepEnd && currentTime - walkRunAssoc->timeStep < stepEnd)
|
|
|
|
stepPart = 2;
|
|
|
|
|
|
|
|
if (stepPart != 0) {
|
2019-06-29 09:09:33 +00:00
|
|
|
DMAudio.PlayOneShot(m_audioEntityId, stepPart == 1 ? SOUND_STEP_START : SOUND_STEP_END, 1.0f);
|
2019-06-28 16:19:00 +00:00
|
|
|
CVector footPos(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
|
|
for (RwFrame *frame = GetNodeFrame(stepPart == 1 ? PED_FOOTL : PED_FOOTR); frame; frame = RwFrameGetParent(frame))
|
|
|
|
RwV3dTransformPoints(footPos, footPos, 1, RwFrameGetMatrix(frame));
|
|
|
|
|
|
|
|
CVector forward = GetForward();
|
|
|
|
|
|
|
|
footPos.z -= 0.1f;
|
|
|
|
footPos += 0.2f * forward;
|
|
|
|
|
|
|
|
if (bDoBloodyFootprints) {
|
|
|
|
CVector2D top(forward * 0.26f);
|
|
|
|
CVector2D right(GetRight() * 0.14f);
|
|
|
|
|
|
|
|
CShadows::AddPermanentShadow(1, gpBloodPoolTex, &footPos,
|
|
|
|
top.x, top.y,
|
|
|
|
right.x, right.y,
|
|
|
|
255, 255, 0, 0, 4.0f, 3000.0f, 1.0f);
|
|
|
|
|
|
|
|
if (m_bloodyFootprintCount <= 20) {
|
|
|
|
m_bloodyFootprintCount = 0;
|
|
|
|
bDoBloodyFootprints = false;
|
|
|
|
} else {
|
|
|
|
m_bloodyFootprintCount -= 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (CWeather::Rain <= 0.1f || CCullZones::CamNoRain() || CCullZones::PlayerNoRain()) {
|
|
|
|
if(IsPlayer())
|
|
|
|
particleProduceFootDust(this, &footPos, 0.0f, 4);
|
|
|
|
} else if(stepPart == 2) {
|
|
|
|
particleProduceFootSplash(this, &footPos, 0.15f, 4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_nLastCollType == 19) { // Water
|
|
|
|
float pedSpeed = CVector2D(m_vecMoveSpeed).Magnitude();
|
|
|
|
if (pedSpeed > 0.03f && CTimer::GetFrameCounter() % 2 == 0 && pedSpeed > 0.13f) {
|
|
|
|
float particleSize = pedSpeed * 2.0f;
|
|
|
|
|
|
|
|
if (particleSize < 0.25f)
|
|
|
|
particleSize = 0.25f;
|
|
|
|
|
|
|
|
if (particleSize > 0.75f)
|
|
|
|
particleSize = 0.75f;
|
|
|
|
|
|
|
|
CVector particlePos = GetPosition() + GetForward() * 0.3f;
|
|
|
|
particlePos.z -= 1.2f;
|
|
|
|
|
|
|
|
CVector particleDir = m_vecMoveSpeed * 0.75f;
|
|
|
|
|
|
|
|
particleDir.z = CGeneral::GetRandomNumberInRange(0.01f, 0.03f);
|
|
|
|
CParticle::AddParticle(PARTICLE_PED_SPLASH, particlePos, particleDir, nil, 0.8f * particleSize, CRGBA(155,155,185,128), 0, 0, 0, 0);
|
|
|
|
|
|
|
|
particleDir.z = CGeneral::GetRandomNumberInRange(0.03f, 0.05f);
|
|
|
|
CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, particlePos, particleDir, nil, particleSize, CRGBA(255,255,255,255), 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-24 22:42:23 +00:00
|
|
|
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::FinishDieAnimCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D3950); }
|
|
|
|
WRAPPER void CPed::FinishedWaitCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D6520); }
|
|
|
|
WRAPPER void CPed::FinishLaunchCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D7490); }
|
|
|
|
WRAPPER void CPed::FinishHitHeadCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D7A80); }
|
|
|
|
WRAPPER void CPed::PedAnimGetInCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DEC80); }
|
|
|
|
WRAPPER void CPed::PedAnimDoorOpenCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DE500); }
|
|
|
|
WRAPPER void CPed::PedAnimPullPedOutCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DEAF0); }
|
|
|
|
WRAPPER void CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DF1B0); }
|
|
|
|
WRAPPER void CPed::SetInCarCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CF220); }
|
|
|
|
WRAPPER void CPed::PedSetOutCarCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8F0); }
|
|
|
|
WRAPPER void CPed::PedAnimAlignCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DE130); }
|
|
|
|
WRAPPER void CPed::PedAnimStepOutCarCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4DF5C0); }
|
|
|
|
WRAPPER void CPed::PedSetInTrainCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4E3290); }
|
|
|
|
WRAPPER void CPed::PedSetOutTrainCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4E36E0); }
|
|
|
|
WRAPPER void CPed::FinishFightMoveCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4E9830); }
|
|
|
|
WRAPPER void CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4E4B90); }
|
|
|
|
WRAPPER void CPed::FinishJumpCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D7A50); }
|
|
|
|
WRAPPER void CPed::PedLandCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4CE8A0); }
|
|
|
|
WRAPPER void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4C6620); }
|
|
|
|
WRAPPER void CPed::RestoreHeadingRateCB(CAnimBlendAssociation *assoc, void *arg) { EAXJMP(0x4D6550); }
|
|
|
|
|
2019-06-14 12:33:08 +00:00
|
|
|
STARTPATCHES
|
|
|
|
InjectHook(0x4CF8F0, &CPed::AddWeaponModel, PATCH_JUMP);
|
|
|
|
InjectHook(0x4C6AA0, &CPed::AimGun, PATCH_JUMP);
|
2019-06-15 15:53:25 +00:00
|
|
|
InjectHook(0x4EB470, &CPed::ApplyHeadShot, PATCH_JUMP);
|
|
|
|
InjectHook(0x4EAEE0, &CPed::RemoveBodyPart, PATCH_JUMP);
|
2019-06-27 12:01:55 +00:00
|
|
|
InjectHook(0x4C6460, (void (CPed::*)(CEntity*, bool)) &CPed::SetLookFlag, PATCH_JUMP);
|
2019-06-15 15:53:25 +00:00
|
|
|
InjectHook(0x4C63E0, (void (CPed::*)(float, bool)) &CPed::SetLookFlag, PATCH_JUMP);
|
2019-06-16 18:39:48 +00:00
|
|
|
InjectHook(0x4D12E0, &CPed::SetLookTimer, PATCH_JUMP);
|
|
|
|
InjectHook(0x4C5700, &CPed::OurPedCanSeeThisOne, PATCH_JUMP);
|
2019-06-17 09:48:42 +00:00
|
|
|
InjectHook(0x4D2BB0, &CPed::Avoid, PATCH_JUMP);
|
2019-06-20 11:22:44 +00:00
|
|
|
InjectHook(0x4C6A50, &CPed::ClearAimFlag, PATCH_JUMP);
|
|
|
|
InjectHook(0x4C64F0, &CPed::ClearLookFlag, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E5BD0, &CPed::IsPedHeadAbovePos, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E68A0, &CPed::FinishedAttackCB, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E5BD0, &CheckForPedsOnGroundToAttack, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E6BA0, &CPed::Attack, PATCH_JUMP);
|
2019-06-21 18:16:51 +00:00
|
|
|
InjectHook(0x4CF980, &CPed::RemoveWeaponModel, PATCH_JUMP);
|
|
|
|
InjectHook(0x4CFA60, &CPed::SetCurrentWeapon, PATCH_JUMP);
|
|
|
|
InjectHook(0x4DD920, &CPed::SelectGunIfArmed, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E4A10, &CPed::Duck, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E4A30, &CPed::ClearDuck, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E6180, &CPed::ClearPointGunAt, PATCH_JUMP);
|
2019-06-24 14:57:54 +00:00
|
|
|
InjectHook(0x4E07D0, &CPed::BeingDraggedFromCar, PATCH_JUMP);
|
|
|
|
InjectHook(0x4CF000, &CPed::PedSetDraggedOutCarCB, PATCH_JUMP);
|
|
|
|
InjectHook(0x4C5D80, &CPed::RestartNonPartialAnims, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E4730, &CPed::GetLocalPositionToOpenCarDoor, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E4660, (void (*)(CVector*, CVehicle*, uint32, float)) CPed::GetPositionToOpenCarDoor, PATCH_JUMP);
|
|
|
|
InjectHook(0x4E1A30, (void (*)(CVector*, CVehicle*, uint32)) CPed::GetPositionToOpenCarDoor, PATCH_JUMP);
|
|
|
|
InjectHook(0x4DF940, &CPed::LineUpPedWithCar, PATCH_JUMP);
|
2019-06-28 16:19:00 +00:00
|
|
|
InjectHook(0x4CC6C0, &CPed::PlayFootSteps, PATCH_JUMP);
|
2019-06-16 19:44:05 +00:00
|
|
|
ENDPATCHES
|