summaryrefslogtreecommitdiffstats
path: root/src/peds
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/peds/CivilianPed.cpp8
-rw-r--r--src/peds/CopPed.cpp15
-rw-r--r--src/peds/EmergencyPed.cpp30
-rw-r--r--src/peds/Ped.cpp101
-rw-r--r--src/peds/Ped.h21
-rw-r--r--src/peds/PedAI.cpp162
-rw-r--r--src/peds/PedFight.cpp20
-rw-r--r--src/peds/PedIK.cpp14
-rw-r--r--src/peds/PedIK.h2
-rw-r--r--src/peds/PlayerPed.cpp165
-rw-r--r--src/peds/Population.cpp6
11 files changed, 235 insertions, 309 deletions
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index 401d2e67..a2f44357 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -274,7 +274,7 @@ CCivilianPed::ProcessControl(void)
} else {
crimeReporters[m_phoneId] = this;
m_facePhoneStart = true;
- m_nPedState = PED_FACE_PHONE;
+ SetPedState(PED_FACE_PHONE);
}
#else
} else if (bRunningToPhone) {
@@ -283,7 +283,7 @@ CCivilianPed::ProcessControl(void)
m_phoneId = -1;
} else {
gPhoneInfo.m_aPhones[m_phoneId].m_nState = PHONE_STATE_REPORTING_CRIME;
- m_nPedState = PED_FACE_PHONE;
+ SetPedState(PED_FACE_PHONE);
}
#endif
} else if (m_objective != OBJECTIVE_KILL_CHAR_ANY_MEANS && m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT) {
@@ -305,7 +305,7 @@ CCivilianPed::ProcessControl(void)
break;
case PED_FACE_PHONE:
if (FacePhone())
- m_nPedState = PED_MAKE_CALL;
+ SetPedState(PED_MAKE_CALL);
break;
case PED_MAKE_CALL:
if (MakePhonecall())
@@ -331,7 +331,7 @@ CCivilianPed::ProcessControl(void)
for (int j = 0; j < m_numNearPeds; ++j) {
CPed *nearPed = m_nearPeds[j];
if (nearPed->m_nPedType == m_nPedType && nearPed->m_nPedState == PED_WANDER_PATH) {
- nearPed->m_nPedState = PED_UNKNOWN;
+ nearPed->SetPedState(PED_UNKNOWN);
}
}
}
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index d9f55559..e518fae4 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -69,7 +69,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
m_bStopAndShootDisabledZone = false;
m_bZoneDisabled = false;
field_1364 = -1;
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
// VC also initializes in here, but as nil
#ifdef FIX_BUGS
@@ -114,14 +114,14 @@ CCopPed::SetArrestPlayer(CPed *player)
} else if (player->m_nPedState != PED_DIE && player->m_nPedState != PED_DEAD && player->m_nPedState != PED_ARRESTED) {
player->m_nLastPedState = player->m_nPedState;
- player->m_nPedState = PED_ARRESTED;
+ player->SetPedState(PED_ARRESTED);
FindPlayerPed()->m_bCanBeDamaged = false;
((CPlayerPed*)player)->m_pArrestingCop = this;
this->RegisterReference((CEntity**) &((CPlayerPed*)player)->m_pArrestingCop);
}
- m_nPedState = PED_ARREST_PLAYER;
+ SetPedState(PED_ARREST_PLAYER);
SetObjective(OBJECTIVE_NONE);
m_prevObjective = OBJECTIVE_NONE;
bIsPointingGunAt = false;
@@ -229,7 +229,7 @@ CCopPed::ArrestPlayer(void)
CPed *suspect = (CPed*)m_pSeekTarget;
if (suspect) {
if (suspect->CanSetPedState())
- suspect->m_nPedState = PED_ARRESTED;
+ suspect->SetPedState(PED_ARRESTED);
if (suspect->bInVehicle && m_pMyVehicle && suspect->m_pMyVehicle == m_pMyVehicle) {
@@ -244,7 +244,7 @@ CCopPed::ArrestPlayer(void)
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_ARREST_GUN, 4.0f);
CVector suspMidPos;
- suspect->m_pedIK.GetComponentPosition((RwV3d*)suspMidPos, PED_MID);
+ suspect->m_pedIK.GetComponentPosition(suspMidPos, PED_MID);
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(suspMidPos.x, suspMidPos.y,
GetPosition().x, GetPosition().y);
@@ -472,10 +472,7 @@ CCopPed::CopAI(void)
if (!CWorld::ProcessLineOfSight(gunPos, playerOrHisVeh->GetPosition(), foundCol, foundEnt,
false, true, false, false, true, false, false)
|| foundEnt && foundEnt == playerOrHisVeh) {
- m_pPointGunAt = playerOrHisVeh;
- if (playerOrHisVeh)
- playerOrHisVeh->RegisterReference((CEntity**) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(playerOrHisVeh);
SetAttack(playerOrHisVeh);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000));
}
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index 8d6999c3..9f87c12b 100644
--- a/src/peds/EmergencyPed.cpp
+++ b/src/peds/EmergencyPed.cpp
@@ -100,7 +100,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_READY:
nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist);
if (nearestFire) {
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetSeek(nearestFire->m_vecPos, 1.0f);
SetMoveState(PEDMOVE_RUN);
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
@@ -114,7 +114,7 @@ CEmergencyPed::FiremanAI(void)
case EMERGENCY_PED_DETERMINE_NEXT_STATE:
nearestFire = gFireManager.FindNearestFire(GetPosition(), &fireDist);
if (nearestFire && nearestFire != m_pAttendedFire) {
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetSeek(nearestFire->m_vecPos, 1.0f);
SetMoveState(PEDMOVE_RUN);
#ifdef FIX_BUGS
@@ -160,7 +160,7 @@ CEmergencyPed::FiremanAI(void)
#endif
--m_pAttendedFire->m_nFiremenPuttingOut;
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetWanderPath(CGeneral::GetRandomNumber() & 7);
m_pAttendedFire = nil;
m_nEmergencyPedState = EMERGENCY_PED_READY;
@@ -234,8 +234,8 @@ CEmergencyPed::MedicAI(void)
if (nearestAccident) {
m_pRevivedPed = nearestAccident->m_pVictim;
m_pRevivedPed->RegisterReference((CEntity**)&m_pRevivedPed);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
SetSeek((headPos + midPos) * 0.5f, 1.0f);
SetObjective(OBJECTIVE_NONE);
bIsRunning = true;
@@ -274,8 +274,8 @@ CEmergencyPed::MedicAI(void)
m_nEmergencyPedState = EMERGENCY_PED_STOP;
break;
}
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
SetSeek((headPos + midPos) * 0.5f, nearestAccident->m_nMedicsPerformingCPR * 0.5f + 1.0f);
SetObjective(OBJECTIVE_NONE);
bIsRunning = true;
@@ -307,7 +307,7 @@ CEmergencyPed::MedicAI(void)
} else {
m_pRevivedPed->m_bloodyFootprintCountOrDeathTime = CTimer::GetTimeInMilliseconds();
SetMoveState(PEDMOVE_STILL);
- m_nPedState = PED_CPR;
+ SetPedState(PED_CPR);
m_nLastPedState = PED_CPR;
SetLookFlag(m_pRevivedPed, 0);
SetLookTimer(500);
@@ -329,8 +329,8 @@ CEmergencyPed::MedicAI(void)
if (!m_pRevivedPed || m_pRevivedPed->m_fHealth > 0.0f)
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
else {
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
midPos = (headPos + midPos) * 0.5f;
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(
midPos.x, midPos.y,
@@ -351,8 +351,8 @@ CEmergencyPed::MedicAI(void)
m_nEmergencyPedState = EMERGENCY_PED_DETERMINE_NEXT_STATE;
break;
}
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&midPos, PED_MID);
- m_pRevivedPed->m_pedIK.GetComponentPosition((RwV3d*)&headPos, PED_HEAD);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(midPos, PED_MID);
+ m_pRevivedPed->m_pedIK.GetComponentPosition(headPos, PED_HEAD);
midPos = (headPos + midPos) * 0.5f;
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(
midPos.x, midPos.y,
@@ -366,12 +366,12 @@ CEmergencyPed::MedicAI(void)
break;
}
m_nEmergencyPedState = EMERGENCY_PED_STOP_CPR;
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
SetMoveState(PEDMOVE_WALK);
m_pVehicleAnim = nil;
if (!m_pRevivedPed->bBodyPartJustCameOff) {
m_pRevivedPed->m_fHealth = 100.0f;
- m_pRevivedPed->m_nPedState = PED_NONE;
+ m_pRevivedPed->SetPedState(PED_NONE);
m_pRevivedPed->m_nLastPedState = PED_WANDER_PATH;
m_pRevivedPed->SetGetUp();
m_pRevivedPed->bUsesCollision = true;
@@ -400,7 +400,7 @@ CEmergencyPed::MedicAI(void)
break;
case EMERGENCY_PED_STOP:
m_bStartedToCPR = false;
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
if (m_pAttendedAccident) {
m_pAttendedAccident->m_pVictim = nil;
--m_pAttendedAccident->m_nMedicsAttending;
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index c41c1f0c..df78902f 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -641,7 +641,7 @@ CPed::RestorePreviousState(void)
return;
if (InVehicle()) {
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
m_nLastPedState = PED_NONE;
} else {
if (m_nLastPedState == PED_NONE) {
@@ -658,7 +658,7 @@ CPed::RestorePreviousState(void)
SetIdle();
break;
case PED_WANDER_PATH:
- m_nPedState = PED_WANDER_PATH;
+ SetPedState(PED_WANDER_PATH);
bIsRunning = false;
if (bFindNewNodeAfterStateRestore) {
if (m_pNextPathNode) {
@@ -672,7 +672,7 @@ CPed::RestorePreviousState(void)
SetWanderPath(CGeneral::GetRandomNumber() & 7);
break;
default:
- m_nPedState = m_nLastPedState;
+ SetPedState(m_nLastPedState);
SetMoveState((eMoveState) m_nPrevMoveState);
break;
}
@@ -960,7 +960,7 @@ CPed::MoveHeadToLook(void)
}
if (m_pLookTarget->IsPed()) {
- ((CPed*)m_pLookTarget)->m_pedIK.GetComponentPosition((RwV3d*) &lookPos, PED_MID);
+ ((CPed*)m_pLookTarget)->m_pedIK.GetComponentPosition(lookPos, PED_MID);
} else {
lookPos = m_pLookTarget->GetPosition();
}
@@ -1511,8 +1511,8 @@ CPed::ClearAll(void)
if (!IsPedInControl() && m_nPedState != PED_DEAD)
return;
- m_nPedState = PED_NONE;
- m_nMoveState = PEDMOVE_NONE;
+ SetPedState(PED_NONE);
+ SetMoveState(PEDMOVE_NONE);
m_pSeekTarget = nil;
m_vecSeekPos = CVector(0.0f, 0.0f, 0.0f);
m_fleeFromPosX = 0.0f;
@@ -1585,7 +1585,7 @@ CPed::ProcessBuoyancy(void)
CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, pos, CVector(0.0f, 0.0f, 0.0f), 0.0f, 50, CRGBA(0, 0, 0, 0), true);
#endif
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
return;
}
}
@@ -2692,36 +2692,6 @@ CPed::ProcessControl(void)
case PED_WANDER_PATH:
WanderPath();
break;
- case PED_SEEK_POS:
- case PED_SEEK_ENTITY:
- case PED_PURSUE:
- case PED_SNIPER_MODE:
- case PED_ROCKET_MODE:
- case PED_DUMMY:
- case PED_FACE_PHONE:
- case PED_MAKE_CALL:
- case PED_MUG:
- case PED_AI_CONTROL:
- case PED_FOLLOW_ROUTE:
- case PED_CPR:
- case PED_SOLICIT:
- case PED_BUY_ICECREAM:
- case PED_STEP_AWAY:
- case PED_UNKNOWN:
- case PED_STATES_NO_AI:
- case PED_JUMP:
- case PED_STAGGER:
- case PED_DIVE_AWAY:
- case PED_STATES_NO_ST:
- case PED_ARREST_PLAYER:
- case PED_PASSENGER:
- case PED_TAXI_PASSENGER:
- case PED_OPEN_DOOR:
- case PED_DEAD:
- case PED_DRAG_FROM_CAR:
- case PED_EXIT_CAR:
- case PED_STEAL_CAR:
- break;
case PED_ENTER_CAR:
case PED_CARJACK:
{
@@ -4467,7 +4437,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
if (!veh->bEngineOn)
veh->bEngineOn = true;
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
ped->StopNonPartialAnims();
return;
}
@@ -4512,7 +4482,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) {
if (ped->m_nPedState == PED_CARJACK) {
veh->AddPassenger(ped, 0);
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective();
ped->SetObjective(OBJECTIVE_LEAVE_CAR, veh);
} else if (veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR) {
@@ -4552,7 +4522,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
veh->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
veh->AutoPilot.m_nCruiseSpeed = 25;
}
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER) {
if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
@@ -4580,7 +4550,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
break;
}
}
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
if (ped->m_prevObjective == OBJECTIVE_RUN_TO_AREA || ped->m_prevObjective == OBJECTIVE_GOTO_CHAR_ON_FOOT || ped->m_prevObjective == OBJECTIVE_KILL_CHAR_ON_FOOT)
ped->m_prevObjective = OBJECTIVE_NONE;
@@ -4967,7 +4937,7 @@ CPed::SetIdle(void)
m_nLastPedState = PED_NONE;
#endif
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
SetMoveState(PEDMOVE_STILL);
}
if (m_nWaitState == WAITSTATE_FALSE) {
@@ -5055,7 +5025,7 @@ CPed::SetFall(int extraTime, AnimationId animId, uint8 evenIfNotInControl)
ClearLookFlag();
ClearAimFlag();
SetStoredState();
- m_nPedState = PED_FALL;
+ SetPedState(PED_FALL);
CAnimBlendAssociation *fallAssoc = RpAnimBlendClumpGetAssociation(GetClump(), animId);
if (fallAssoc) {
@@ -5220,7 +5190,7 @@ CPed::SetGetUp(void)
}
if (m_nPedState != PED_GETUP) {
SetStoredState();
- m_nPedState = PED_GETUP;
+ SetPedState(PED_GETUP);
}
CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity;
@@ -5375,7 +5345,7 @@ CPed::SetSeek(CVector pos, float distanceToCountDone)
if (m_nPedState != PED_SEEK_POS)
SetStoredState();
- m_nPedState = PED_SEEK_POS;
+ SetPedState(PED_SEEK_POS);
m_distanceToCountSeekDone = distanceToCountDone;
m_vecSeekPos = pos;
}
@@ -5395,7 +5365,7 @@ CPed::SetSeek(CEntity *seeking, float distanceToCountDone)
if (m_nPedState != PED_SEEK_ENTITY)
SetStoredState();
- m_nPedState = PED_SEEK_ENTITY;
+ SetPedState(PED_SEEK_ENTITY);
m_distanceToCountSeekDone = distanceToCountDone;
m_pSeekTarget = seeking;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
@@ -5572,7 +5542,7 @@ CPed::SetFlee(CVector2D const &from, int time)
if (m_nPedState != PED_FLEE_ENTITY) {
SetStoredState();
- m_nPedState = PED_FLEE_POS;
+ SetPedState(PED_FLEE_POS);
SetMoveState(PEDMOVE_RUN);
m_fleeFromPosX = from.x;
m_fleeFromPosY = from.y;
@@ -5601,7 +5571,7 @@ CPed::SetFlee(CEntity *fleeFrom, int time)
return;
SetStoredState();
- m_nPedState = PED_FLEE_ENTITY;
+ SetPedState(PED_FLEE_ENTITY);
bUsePedNodeSeek = true;
SetMoveState(PEDMOVE_RUN);
m_fleeFrom = fleeFrom;
@@ -5862,7 +5832,7 @@ CPed::SetWanderPath(int8 pathStateDest)
// We did it, save next path state and return true
m_nPathDir = nextPathState;
- m_nPedState = PED_WANDER_PATH;
+ SetPedState(PED_WANDER_PATH);
SetMoveState(PEDMOVE_WALK);
bIsRunning = false;
return true;
@@ -6047,7 +6017,7 @@ CPed::SetFollowPath(CVector dest)
return false;
SetStoredState();
- m_nPedState = PED_FOLLOW_PATH;
+ SetPedState(PED_FOLLOW_PATH);
SetMoveState(PEDMOVE_WALK);
return true;
}
@@ -6150,7 +6120,7 @@ CPed::SetEvasiveStep(CEntity *reason, uint8 animType)
m_fRotationCur = CGeneral::LimitRadianAngle(angleToFace);
ClearAimFlag();
SetStoredState();
- m_nPedState = PED_STEP_AWAY;
+ SetPedState(PED_STEP_AWAY);
}
}
}
@@ -6247,13 +6217,13 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump)
animAssoc->flags &= ~ASSOC_DELETEFADEDOUT;
animAssoc->SetFinishCallback(PedEvadeCB, this);
SetStoredState();
- m_nPedState = PED_STEP_AWAY;
+ SetPedState(PED_STEP_AWAY);
} else {
m_fRotationCur = angleToFace;
ClearLookFlag();
ClearAimFlag();
SetStoredState();
- m_nPedState = PED_DIVE_AWAY;
+ SetPedState(PED_DIVE_AWAY);
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_EV_DIVE, 8.0f);
animAssoc->SetFinishCallback(PedEvadeCB, this);
}
@@ -6291,7 +6261,7 @@ CPed::PedEvadeCB(CAnimBlendAssociation* animAssoc, void* arg)
if (ped->m_nPedState == PED_DIVE_AWAY)
{
ped->m_getUpTimer = CTimer::GetTimeInMilliseconds() + 1;
- ped->m_nPedState = PED_FALL;
+ ped->SetPedState(PED_FALL);
}
animAssoc->flags &= ~ASSOC_FADEOUTWHENDONE;
animAssoc->flags |= ASSOC_DELETEFADEDOUT;
@@ -6342,7 +6312,7 @@ CPed::SetDie(AnimationId animId, float delta, float speed)
QuitEnteringCar();
}
- m_nPedState = PED_DIE;
+ SetPedState(PED_DIE);
if (animId == NUM_ANIMS) {
bIsPedDieAnimPlaying = false;
} else {
@@ -6384,7 +6354,7 @@ CPed::SetDead(void)
if (m_nPedState == PED_DRIVING)
bIsVisible = false;
- m_nPedState = PED_DEAD;
+ SetPedState(PED_DEAD);
m_pVehicleAnim = nil;
m_pCollidingEntity = nil;
@@ -6417,7 +6387,7 @@ CPed::SetChat(CEntity *chatWith, uint32 time)
if(m_nPedState != PED_CHAT)
SetStoredState();
- m_nPedState = PED_CHAT;
+ SetPedState(PED_CHAT);
SetMoveState(PEDMOVE_STILL);
#if defined VC_PED_PORTS || defined FIX_BUGS
m_lookTimer = 0;
@@ -6658,7 +6628,7 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode)
// m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
m_vehEnterType = doorNode;
m_distanceToCountSeekDone = 0.5f;
- m_nPedState = PED_SEEK_CAR;
+ SetPedState(PED_SEEK_CAR);
}
@@ -7683,10 +7653,11 @@ CPed::FlagToDestroyWhenNextProcessed(void)
}
bInVehicle = false;
m_pMyVehicle = nil;
+
if (CharCreatedBy == MISSION_CHAR)
- m_nPedState = PED_DEAD;
+ SetPedState(PED_DEAD);
else
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
m_pVehicleAnim = nil;
}
@@ -7710,7 +7681,7 @@ CPed::SetSolicit(uint32 time)
if(!m_carInObjective->bIsVan && !m_carInObjective->bIsBus)
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_HOOKERTALK, 4.0f);
- m_nPedState = PED_SOLICIT;
+ SetPedState(PED_SOLICIT);
}
}
}
@@ -7769,7 +7740,7 @@ CPed::SetBuyIceCream(void)
// Simulating BuyIceCream
CPed* driver = m_carInObjective->pDriver;
if (driver) {
- m_nPedState = PED_BUY_ICECREAM;
+ SetPedState(PED_BUY_ICECREAM);
bFindNewNodeAfterStateRestore = true;
SetObjectiveTimer(8000);
SetChat(driver, 8000);
@@ -7783,7 +7754,7 @@ CPed::SetBuyIceCream(void)
if (Abs(m_fRotationDest - m_fRotationCur) < HALFPI) {
m_standardTimer = CTimer::GetTimeInMilliseconds() + 3000;
- m_nPedState = PED_BUY_ICECREAM;
+ SetPedState(PED_BUY_ICECREAM);
}
}
@@ -7985,7 +7956,7 @@ CPed::SetJump(void)
#endif
(m_nSurfaceTouched != SURFACE_STEEP_CLIFF || DotProduct(GetForward(), m_vecDamageNormal) >= 0.0f)) {
SetStoredState();
- m_nPedState = PED_JUMP;
+ SetPedState(PED_JUMP);
CAnimBlendAssociation *jumpAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_JUMP_LAUNCH, 8.0f);
jumpAssoc->SetFinishCallback(FinishLaunchCB, this);
m_fRotationDest = m_fRotationCur;
@@ -8287,7 +8258,7 @@ CPed::WarpPedIntoCar(CVehicle *car)
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_carInObjective = car;
m_carInObjective->RegisterReference((CEntity **) &m_carInObjective);
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
bUsesCollision = false;
bIsInTheAir = false;
bVehExitWillBeInstant = true;
diff --git a/src/peds/Ped.h b/src/peds/Ped.h
index a3d4997d..d27853d6 100644
--- a/src/peds/Ped.h
+++ b/src/peds/Ped.h
@@ -43,7 +43,7 @@ enum eFormation
FORMATION_FRONT
};
-enum FightState : int8 {
+enum FightState {
FIGHTSTATE_MOVE_FINISHED = -2,
FIGHTSTATE_JUST_ATTACKED,
FIGHTSTATE_NO_MOVE,
@@ -153,7 +153,7 @@ enum eWaitState {
WAITSTATE_FINISH_FLEE
};
-enum eObjective : uint32 {
+enum eObjective {
OBJECTIVE_NONE,
OBJECTIVE_WAIT_ON_FOOT,
OBJECTIVE_FLEE_ON_FOOT_TILL_SAFE,
@@ -212,7 +212,7 @@ enum PedOnGroundState {
PED_DEAD_ON_THE_FLOOR
};
-enum PointBlankNecessity : uint8 {
+enum PointBlankNecessity {
NO_POINT_BLANK_PED,
POINT_BLANK_FOR_WANTED_PED,
POINT_BLANK_FOR_SOMEONE_ELSE
@@ -484,7 +484,7 @@ public:
CVector m_vecHitLastPos;
uint32 m_curFightMove;
uint8 m_fightButtonPressure;
- FightState m_fightState;
+ int8 m_fightState;
bool m_takeAStepAfterAttack;
CFire *m_pFire;
CEntity *m_pLookTarget;
@@ -598,7 +598,7 @@ public:
#endif
bool CheckForExplosions(CVector2D &area);
CPed *CheckForGunShots(void);
- PointBlankNecessity CheckForPointBlankPeds(CPed*);
+ uint8 CheckForPointBlankPeds(CPed*);
bool CheckIfInTheAir(void);
void ClearAll(void);
void SetPointGunAt(CEntity*);
@@ -863,6 +863,13 @@ public:
SetMoveState(PEDMOVE_WALK);
}
+ inline void SetWeaponLockOnTarget(CEntity *target)
+ {
+ m_pPointGunAt = (CPed *)target;
+ if(target)
+ ((CEntity *)target)->RegisterReference(&m_pPointGunAt);
+ }
+
// Using this to abstract nodes of skinned and non-skinned meshes
CVector GetNodePosition(int32 node)
{
@@ -891,13 +898,13 @@ public:
RpHAnimHierarchy *hier = GetAnimHierarchyFromSkinClump(GetClump());
int32 idx = RpHAnimIDGetIndex(hier, m_pFrames[node]->nodeID);
RwMatrix *mats = RpHAnimHierarchyGetMatrixArray(hier);
- RwV3dTransformPoints((RwV3d*)&pos, (RwV3d*)&pos, 1, &mats[idx]);
+ RwV3dTransformPoints(&pos, &pos, 1, &mats[idx]);
}else
#endif
{
RwFrame *frame;
for (frame = m_pFrames[node]->frame; frame; frame = RwFrameGetParent(frame))
- RwV3dTransformPoints((RwV3d*)&pos, (RwV3d*)&pos, 1, RwFrameGetMatrix(frame));
+ RwV3dTransformPoints(&pos, &pos, 1, RwFrameGetMatrix(frame));
}
}
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index 38303473..a747c684 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -620,9 +620,7 @@ CPed::UpdateFromLeader(void)
m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget);
TurnBody();
if (m_attackTimer < CTimer::GetTimeInMilliseconds() && !GetWeapon()->IsTypeMelee()) {
- m_pPointGunAt = m_threatEntity;
- if (m_threatEntity)
- m_threatEntity->RegisterReference((CEntity **) &m_pPointGunAt);
+ SetWeaponLockOnTarget(m_threatEntity);
SetAttack(m_threatEntity);
}
}
@@ -811,10 +809,10 @@ CPed::ProcessObjective(void)
break;
}
case OBJECTIVE_WAIT_IN_CAR:
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
break;
case OBJECTIVE_WAIT_IN_CAR_THEN_GET_OUT:
- m_nPedState = PED_DRIVING;
+ SetPedState(PED_DRIVING);
break;
case OBJECTIVE_KILL_CHAR_ANY_MEANS:
{
@@ -972,9 +970,9 @@ CPed::ProcessObjective(void)
}
CWeaponInfo *wepInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
float wepRange = wepInfo->m_fRange;
- float wepRangeAdjusted;
+ float maxDistToKeep;
if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) {
- wepRangeAdjusted = wepRange / 3.0f;
+ maxDistToKeep = wepRange / 3.0f;
} else {
if (m_nPedState == PED_FIGHT) {
if (!IsPlayer() && !(m_pedStats->m_flags & STAT_CAN_KICK))
@@ -982,10 +980,10 @@ CPed::ProcessObjective(void)
} else {
wepRange = 1.3f;
}
- wepRangeAdjusted = wepRange;
+ maxDistToKeep = wepRange;
}
- if (m_pedInObjective->m_getUpTimer > CTimer::GetTimeInMilliseconds() && wepRangeAdjusted < 2.5f) {
- wepRangeAdjusted = 2.5f;
+ if (m_pedInObjective->m_getUpTimer > CTimer::GetTimeInMilliseconds() && maxDistToKeep < 2.5f) {
+ maxDistToKeep = 2.5f;
}
if (m_pedInObjective->IsPlayer() && m_nPedType != PEDTYPE_COP
&& CharCreatedBy != MISSION_CHAR && FindPlayerPed()->m_pWanted->m_CurrentCops) {
@@ -1015,21 +1013,18 @@ CPed::ProcessObjective(void)
// I hope so
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
CVector maxShotPos = vehOfTarget->GetPosition() - ourHead;
- maxShotPos.Normalise();
- maxShotPos = maxShotPos * wepInfo->m_fRange + ourHead;
+ maxShotPos *= wepInfo->m_fRange / maxShotPos.Magnitude();
+ maxShotPos += ourHead;
- CWorld::bIncludeDeadPeds = true;
CColPoint foundCol;
CEntity *foundEnt;
- CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt,
- true, true, true, true, false, true, false);
+
+ CWorld::bIncludeDeadPeds = true;
+ CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt, true, true, true, true, false, true, false);
CWorld::bIncludeDeadPeds = false;
if (foundEnt == vehOfTarget) {
SetAttack(vehOfTarget);
- m_pPointGunAt = vehOfTarget;
- if (vehOfTarget)
- vehOfTarget->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(vehOfTarget);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc <= m_distanceToCountSeekDone) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(200, 500));
@@ -1038,8 +1033,7 @@ CPed::ProcessObjective(void)
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000));
}
}
- }
- else if (m_nPedState != PED_ATTACK && !bKindaStayInSamePlace && !killPlayerInNoPoliceZone) {
+ } else if (m_nPedState != PED_ATTACK && !bKindaStayInSamePlace && !killPlayerInNoPoliceZone) {
if (vehOfTarget) {
if (m_nPedType == PEDTYPE_COP || vehOfTarget->bIsBus) {
GoToNearestDoor(vehOfTarget);
@@ -1086,7 +1080,7 @@ CPed::ProcessObjective(void)
|| distWithTargetSc > m_distanceToCountSeekDone && !CanSeeEntity(m_pedInObjective)) {
if (m_pedInObjective->EnteringCar())
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
if (bUsePedNodeSeek) {
CVector bestCoords(0.0f, 0.0f, 0.0f);
@@ -1100,7 +1094,7 @@ CPed::ProcessObjective(void)
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else {
- SetSeek(m_pedInObjective, wepRangeAdjusted);
+ SetSeek(m_pedInObjective, maxDistToKeep);
}
bCrouchWhenShooting = false;
if (m_pedInObjective->m_pCurrentPhysSurface && distWithTargetSc < 5.0f) {
@@ -1147,32 +1141,27 @@ CPed::ProcessObjective(void)
CVector target;
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
if (m_pedInObjective->IsPed())
- m_pedInObjective->m_pedIK.GetComponentPosition((RwV3d*)&target, PED_MID);
+ m_pedInObjective->m_pedIK.GetComponentPosition(target, PED_MID);
else
target = m_pedInObjective->GetPosition();
target -= ourHead;
- target.Normalise();
- target = target * wepInfo->m_fRange + ourHead;
+ target *= wepInfo->m_fRange / target.Magnitude();
+ target += ourHead;
- CWorld::bIncludeDeadPeds = true;
- CEntity *foundEnt = nil;
CColPoint foundCol;
+ CEntity *foundEnt = nil;
- CWorld::ProcessLineOfSight(
- ourHead, target, foundCol, foundEnt,
- true, true, true, false, true, false);
- CWorld::bIncludeDeadPeds = 0;
+ CWorld::bIncludeDeadPeds = true;
+ CWorld::ProcessLineOfSight(ourHead, target, foundCol, foundEnt, true, true, true, true, false, true, false);
+ CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_pedInObjective) {
SetAttack(m_pedInObjective);
- m_pPointGunAt = m_pedInObjective;
- if (m_pedInObjective)
- m_pedInObjective->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(m_pedInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500.0f, 2000.0f));
int time;
- if (distWithTargetSc <= wepRangeAdjusted)
+ if (distWithTargetSc <= maxDistToKeep)
time = CGeneral::GetRandomNumberInRange(100.0f, 500.0f);
else
time = CGeneral::GetRandomNumberInRange(1500.0f, 3000.0f);
@@ -1180,25 +1169,27 @@ CPed::ProcessObjective(void)
SetAttackTimer(time);
bObstacleShowedUpDuringKillObjective = false;
- } else if (foundEnt) {
- if (foundEnt->IsPed()) {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(500.0f, 1000.0f));
- bObstacleShowedUpDuringKillObjective = false;
- } else {
- if (foundEnt->IsObject()) {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(200.0f, 400.0f));
- bObstacleShowedUpDuringKillObjective = true;
- } else if (foundEnt->IsVehicle()) {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(400.0f, 600.0f));
- bObstacleShowedUpDuringKillObjective = true;
+ } else {
+ if (foundEnt) {
+ if (foundEnt->IsPed()) {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(500.0f, 1000.0f));
+ bObstacleShowedUpDuringKillObjective = false;
} else {
- SetAttackTimer(CGeneral::GetRandomNumberInRange(700.0f, 1200.0f));
- bObstacleShowedUpDuringKillObjective = true;
+ if (foundEnt->IsObject()) {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(200.0f, 400.0f));
+ bObstacleShowedUpDuringKillObjective = true;
+ } else if (foundEnt->IsVehicle()) {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(400.0f, 600.0f));
+ bObstacleShowedUpDuringKillObjective = true;
+ } else {
+ SetAttackTimer(CGeneral::GetRandomNumberInRange(700.0f, 1200.0f));
+ bObstacleShowedUpDuringKillObjective = true;
+ }
}
- }
- m_fleeFrom = foundEnt;
- m_fleeFrom->RegisterReference((CEntity**) &m_fleeFrom);
+ m_fleeFrom = foundEnt;
+ m_fleeFrom->RegisterReference((CEntity**) &m_fleeFrom);
+ }
SetPointGunAt(m_pedInObjective);
}
}
@@ -1230,17 +1221,17 @@ CPed::ProcessObjective(void)
if (m_nPedType == PEDTYPE_COP) {
if (GetWeapon()->m_eWeaponType > WEAPONTYPE_COLT45
|| m_fleeFrom && m_fleeFrom->IsObject()) {
- wepRangeAdjusted = 6.0f;
+ maxDistToKeep = 6.0f;
} else if (m_fleeFrom && m_fleeFrom->IsVehicle()) {
- wepRangeAdjusted = 4.0f;
+ maxDistToKeep = 4.0f;
} else {
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
}
} else {
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
}
}
- if (distWithTargetSc <= wepRangeAdjusted) {
+ if (distWithTargetSc <= maxDistToKeep) {
SetMoveState(PEDMOVE_STILL);
bIsPointingGunAt = true;
if (m_nPedState != PED_AIM_GUN && !bDuckAndCover) {
@@ -1251,7 +1242,7 @@ CPed::ProcessObjective(void)
if (m_nPedState != PED_SEEK_ENTITY && m_nPedState != PED_SEEK_POS
&& !bStopAndShoot && !killPlayerInNoPoliceZone && !bKindaStayInSamePlace) {
Say(SOUND_PED_ATTACK);
- SetSeek(m_pedInObjective, wepRangeAdjusted);
+ SetSeek(m_pedInObjective, maxDistToKeep);
bIsRunning = true;
}
}
@@ -1541,21 +1532,18 @@ CPed::ProcessObjective(void)
// I hope so
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
CVector maxShotPos = m_carInObjective->GetPosition() - ourHead;
- maxShotPos.Normalise();
- maxShotPos = maxShotPos * wepInfo->m_fRange + ourHead;
+ maxShotPos *= wepInfo->m_fRange / maxShotPos.Magnitude();
+ maxShotPos += ourHead;
- CWorld::bIncludeDeadPeds = true;
CColPoint foundCol;
CEntity *foundEnt;
- CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt,
- true, true, true, true, false, true, false);
+
+ CWorld::bIncludeDeadPeds = true;
+ CWorld::ProcessLineOfSight(ourHead, maxShotPos, foundCol, foundEnt, true, true, true, true, false, true, false);
CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_carInObjective) {
SetAttack(m_carInObjective);
- m_pPointGunAt = m_carInObjective;
- if (m_pPointGunAt)
- m_pPointGunAt->RegisterReference((CEntity **) &m_pPointGunAt);
-
+ SetWeaponLockOnTarget(m_carInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc > 10.0f && !bKindaStayInSamePlace) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000));
@@ -2629,7 +2617,7 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg)
if (ped->IsPlayer() && ped->bGonnaKillTheCarJacker && ((CPlayerPed*)ped)->m_pArrestingCop) {
PedSetInCarCB(nil, ped);
ped->m_nLastPedState = ped->m_nPedState;
- ped->m_nPedState = PED_ARRESTED;
+ ped->SetPedState(PED_ARRESTED);
ped->bGonnaKillTheCarJacker = false;
if (veh) {
veh->m_nNumGettingIn = 0;
@@ -2990,9 +2978,15 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg)
}
if (ped->bFleeAfterExitingCar || ped->bGonnaKillTheCarJacker) {
- // POTENTIAL BUG? Why DOOR_FRONT_LEFT instead of door variable? or vice versa?
+#ifdef FIX_BUGS
+ if (!veh->IsDoorMissing(door))
+ ((CAutomobile*)veh)->Damage.SetDoorStatus(door, DOOR_STATUS_SWINGING);
+ PedSetOutCarCB(nil, ped);
+ return;
+#else
if (!veh->IsDoorMissing(door))
((CAutomobile*)veh)->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_SWINGING);
+#endif
} else {
switch (door) {
case DOOR_FRONT_LEFT:
@@ -3346,7 +3340,7 @@ CPed::SetCarJack_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity**)&m_pSeekTarget);
- m_nPedState = PED_CARJACK;
+ SetPedState(PED_CARJACK);
car->bIsBeingCarJacked = true;
m_pMyVehicle = (CVehicle*)m_pSeekTarget;
m_pMyVehicle->RegisterReference((CEntity**)&m_pMyVehicle);
@@ -3393,7 +3387,7 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack)
SetMoveState(PEDMOVE_NONE);
LineUpPedWithCar(LINE_UP_TO_CAR_START);
m_pVehicleAnim = nil;
- m_nPedState = PED_DRAG_FROM_CAR;
+ SetPedState(PED_DRAG_FROM_CAR);
bChangedSeat = false;
bWillBeQuickJacked = quickJack;
@@ -3518,7 +3512,7 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag)
m_pSeekTarget = car;
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
m_vehEnterType = doorNode;
- m_nPedState = PED_ENTER_CAR;
+ SetPedState(PED_ENTER_CAR);
if (m_vehEnterType == CAR_DOOR_RF && m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER && car->m_vehType != VEHICLE_TYPE_BIKE) {
car->bIsBeingCarJacked = true;
}
@@ -3680,14 +3674,14 @@ void
CPed::SetExitBoat(CVehicle *boat)
{
#ifndef VC_PED_PORTS
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
CVector firstPos = GetPosition();
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 100.0f);
if (boat->GetModelIndex() == MI_SPEEDER && boat->IsUpsideDown()) {
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_CRAWLOUT_RHS, 8.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutCarCB, this);
m_vehEnterType = CAR_DOOR_RF;
- m_nPedState = PED_EXIT_CAR;
+ SetPedState(PED_EXIT_CAR);
} else {
m_vehEnterType = CAR_DOOR_RF;
PedSetOutCarCB(nil, this);
@@ -3700,7 +3694,7 @@ CPed::SetExitBoat(CVehicle *boat)
m_vecMoveSpeed = boat->m_vecMoveSpeed;
bTryingToReachDryLand = true;
#else
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
CVector newPos = GetPosition();
RemoveInCarAnims();
CColModel* boatCol = boat->GetColModel();
@@ -3927,7 +3921,7 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode)
m_pSeekTarget = veh;
m_pSeekTarget->RegisterReference((CEntity**) &m_pSeekTarget);
m_vehEnterType = optedDoorNode;
- m_nPedState = PED_EXIT_CAR;
+ SetPedState(PED_EXIT_CAR);
if (m_pVehicleAnim && m_pVehicleAnim->flags & ASSOC_PARTIAL)
m_pVehicleAnim->blendDelta = -1000.0f;
SetMoveState(PEDMOVE_NONE);
@@ -4475,7 +4469,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
ped->bGonnaKillTheCarJacker = false;
if (!ped->m_pedInObjective || !(CGeneral::GetRandomNumber() & 1)) {
if (!driver || driver == ped || driver->IsPlayer() && CTheScripts::IsPlayerOnAMission()) {
- ped->m_nPedState = PED_NONE;
+ ped->SetPedState(PED_NONE);
ped->m_nLastPedState = PED_NONE;
ped->SetFlee(ped->m_pMyVehicle->GetPosition(), 4000);
} else {
@@ -4504,7 +4498,7 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg)
else
#endif
{
- ped->m_nPedState = PED_NONE;
+ ped->SetPedState(PED_NONE);
ped->m_nLastPedState = PED_NONE;
ped->SetFindPathAndFlee(ped->m_pMyVehicle->GetPosition(), 10000);
}
@@ -4597,7 +4591,7 @@ CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg)
return;
ped->bInVehicle = true;
- ped->m_nPedState = PED_DRIVING;
+ ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL);
veh->AddPassenger(ped);
@@ -4618,7 +4612,7 @@ CPed::SetEnterTrain(CVehicle *train, uint32 unused)
m_pMyVehicle = train;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
- m_nPedState = PED_ENTER_TRAIN;
+ SetPedState(PED_ENTER_TRAIN);
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETIN, 4.0f);
m_pVehicleAnim->SetFinishCallback(PedSetInTrainCB, this);
bUsesCollision = false;
@@ -4692,7 +4686,7 @@ CPed::SetExitTrain(CVehicle* train)
CVector exitPos;
GetNearestTrainPedPosition(train, exitPos);
*/
- m_nPedState = PED_EXIT_TRAIN;
+ SetPedState(PED_EXIT_TRAIN);
m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_TRAIN_GETOUT, 4.0f);
m_pVehicleAnim->SetFinishCallback(PedSetOutTrainCB, this);
bUsesCollision = false;
@@ -4718,7 +4712,7 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->bUsesCollision = true;
ped->m_pVehicleAnim = nil;
ped->bInVehicle = false;
- ped->m_nPedState = PED_IDLE;
+ ped->SetPedState(PED_IDLE);
ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL);
@@ -5186,7 +5180,7 @@ CPed::SetSeekBoatPosition(CVehicle *boat)
m_pMyVehicle = boat;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_distanceToCountSeekDone = 0.5f;
- m_nPedState = PED_SEEK_IN_BOAT;
+ SetPedState(PED_SEEK_IN_BOAT);
}
void
diff --git a/src/peds/PedFight.cpp b/src/peds/PedFight.cpp
index 21310aaa..b57364d8 100644
--- a/src/peds/PedFight.cpp
+++ b/src/peds/PedFight.cpp
@@ -164,7 +164,7 @@ CPed::SetPointGunAt(CEntity *to)
if (m_nPedState != PED_ATTACK)
SetStoredState();
- m_nPedState = PED_AIM_GUN;
+ SetPedState(PED_AIM_GUN);
bIsPointingGunAt = true;
CWeaponInfo *curWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
SetMoveState(PEDMOVE_NONE);
@@ -222,7 +222,7 @@ CPed::ClearPointGunAt(void)
RestorePreviousState();
#else
if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) {
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
RestorePreviousState();
}
#endif
@@ -281,7 +281,7 @@ CPed::SetAttack(CEntity *victim)
(m_nPedState != PED_FIGHT && m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL && !(m_pedStats->m_flags & STAT_SHOPPING_BAGS))) {
if (m_nPedState != PED_ATTACK) {
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
bIsAttacking = false;
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, curWeapon->m_AnimToPlay, 8.0f);
animAssoc->SetRun();
@@ -329,7 +329,7 @@ CPed::SetAttack(CEntity *victim)
if (IsPlayer())
CPad::GetPad(0)->ResetAverageWeapon();
- PointBlankNecessity pointBlankStatus;
+ uint8 pointBlankStatus;
if ((curWeapon->m_eWeaponFire == WEAPON_FIRE_INSTANT_HIT || GetWeapon()->m_eWeaponType == WEAPONTYPE_FLAMETHROWER)
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON
&& TheCamera.PlayerWeaponMode.Mode != CCam::MODE_M16_1STPERSON_RUNABOUT
@@ -348,7 +348,7 @@ CPed::SetAttack(CEntity *victim)
if (m_nPedState != PED_AIM_GUN)
SetStoredState();
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
SetMoveState(PEDMOVE_NONE);
if (bCrouchWhenShooting) {
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_RBLOCK_CSHOOT, 4.0f);
@@ -475,7 +475,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
ped->ClearAttack();
}
-PointBlankNecessity
+uint8
CPed::CheckForPointBlankPeds(CPed *pedToVerify)
{
float pbDistance = 1.1f;
@@ -786,7 +786,7 @@ CPed::StartFightAttack(uint8 buttonPressure)
RestoreHeadingRate();
}
- m_nPedState = PED_FIGHT;
+ SetPedState(PED_FIGHT);
m_fightButtonPressure = 0;
RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT);
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START);
@@ -1062,7 +1062,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
m_nWaitState = WAITSTATE_FALSE;
RestoreHeadingRate();
}
- m_nPedState = PED_FIGHT;
+ SetPedState(PED_FIGHT);
m_fightButtonPressure = 0;
RpAnimBlendClumpRemoveAssociations(GetClump(), ASSOC_REPEAT);
CAnimBlendAssociation *walkStartAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WALK_START);
@@ -1690,7 +1690,7 @@ CPed::FightStrike(CVector &touchedNodePos)
if (m_fightState == FIGHTSTATE_NO_MOVE)
m_fightState = FIGHTSTATE_1;
- m_vecHitLastPos = *touchedNodePos;
+ m_vecHitLastPos = touchedNodePos;
return false;
}
@@ -1796,7 +1796,7 @@ CPed::SetInvestigateEvent(eEventType event, CVector2D pos, float distanceToCount
SetStoredState();
bFindNewNodeAfterStateRestore = false;
- m_nPedState = PED_INVESTIGATE;
+ SetPedState(PED_INVESTIGATE);
m_standardTimer = CTimer::GetTimeInMilliseconds() + time;
m_eventType = event;
m_eventOrThreat = pos;
diff --git a/src/peds/PedIK.cpp b/src/peds/PedIK.cpp
index ebd41296..8bace9a0 100644
--- a/src/peds/PedIK.cpp
+++ b/src/peds/PedIK.cpp
@@ -137,28 +137,28 @@ CPedIK::RotateTorso(AnimBlendFrameData *node, LimbOrientation *limb, bool change
}
void
-CPedIK::GetComponentPosition(RwV3d *pos, uint32 node)
+CPedIK::GetComponentPosition(RwV3d &pos, uint32 node)
{
RwFrame *f;
RwMatrix *mat;
#ifdef PED_SKIN
if(IsClumpSkinned(m_ped->GetClump())){
- pos->x = 0.0f;
- pos->y = 0.0f;
- pos->z = 0.0f;
+ pos.x = 0.0f;
+ pos.y = 0.0f;
+ pos.z = 0.0f;
mat = GetComponentMatrix(m_ped, node);
// could just copy the position out of the matrix...
- RwV3dTransformPoints(pos, pos, 1, mat);
+ RwV3dTransformPoints(&pos, &pos, 1, mat);
}else
#endif
{
f = m_ped->m_pFrames[node]->frame;
mat = RwFrameGetMatrix(f);
- *pos = mat->pos;
+ pos = mat->pos;
for (f = RwFrameGetParent(f); f; f = RwFrameGetParent(f))
- RwV3dTransformPoints(pos, pos, 1, RwFrameGetMatrix(f));
+ RwV3dTransformPoints(&pos, &pos, 1, RwFrameGetMatrix(f));
}
}
diff --git a/src/peds/PedIK.h b/src/peds/PedIK.h
index e91d7c06..4eeef6f0 100644
--- a/src/peds/PedIK.h
+++ b/src/peds/PedIK.h
@@ -51,7 +51,7 @@ public:
bool PointGunInDirection(float targetYaw, float targetPitch);
bool PointGunInDirectionUsingArm(float targetYaw, float targetPitch);
bool PointGunAtPosition(CVector const& position);
- void GetComponentPosition(RwV3d *pos, uint32 node);
+ void GetComponentPosition(RwV3d &pos, uint32 node);
static RwMatrix *GetWorldMatrix(RwFrame *source, RwMatrix *destination);
void RotateTorso(AnimBlendFrameData* animBlend, LimbOrientation* limb, bool changeRoll);
void ExtractYawAndPitchLocal(RwMatrix *mat, float *yaw, float *pitch);
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index fa865aec..8a6adbeb 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -47,8 +47,8 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_nSelectedWepSlot = WEAPONTYPE_UNARMED;
m_nSpeedTimer = 0;
m_bSpeedTimerFlag = false;
- m_pPointGunAt = nil;
- m_nPedState = PED_IDLE;
+ SetWeaponLockOnTarget(nil);
+ SetPedState(PED_IDLE);
#ifndef FIX_BUGS
m_fCurrentStamina = m_fMaxStamina = 150.0f;
#endif
@@ -73,7 +73,7 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
void CPlayerPed::ClearWeaponTarget()
{
if (m_nPedType == PEDTYPE_PLAYER1) {
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrossHair();
}
@@ -113,14 +113,10 @@ CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)
{
if (m_pedStats->m_temper < 52) {
m_pedStats->m_temper++;
- } else {
- if (annoyedByPassingEntity) {
- if (m_pedStats->m_temper < 55) {
- m_pedStats->m_temper++;
- } else {
- m_pedStats->m_temper = 46;
- }
- }
+ } else if (annoyedByPassingEntity && m_pedStats->m_temper < 55) {
+ m_pedStats->m_temper++;
+ } else if (annoyedByPassingEntity) {
+ m_pedStats->m_temper = 46;
}
}
@@ -215,7 +211,7 @@ CPlayerPed::ReApplyMoveAnims(void)
for(int i = 0; i < ARRAY_SIZE(moveAnims); i++) {
CAnimBlendAssociation *curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), moveAnims[i]);
if (curMoveAssoc) {
- if (strcmp(CAnimManager::GetAnimAssociation(m_animGroup, moveAnims[i])->hierarchy->name, curMoveAssoc->hierarchy->name) != 0) {
+ if (CGeneral::faststrcmp(CAnimManager::GetAnimAssociation(m_animGroup, moveAnims[i])->hierarchy->name, curMoveAssoc->hierarchy->name)) {
CAnimBlendAssociation *newMoveAssoc = CAnimManager::AddAnimation(GetClump(), m_animGroup, moveAnims[i]);
newMoveAssoc->blendDelta = curMoveAssoc->blendDelta;
newMoveAssoc->blendAmount = curMoveAssoc->blendAmount;
@@ -248,7 +244,7 @@ CPlayerPed::SetInitialState(void)
if (m_pFire)
m_pFire->Extinguish();
RpAnimBlendClumpRemoveAllAssociations(GetClump());
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
SetMoveState(PEDMOVE_STILL);
m_nLastPedState = PED_NONE;
m_animGroup = ASSOCGRP_PLAYER;
@@ -288,7 +284,7 @@ CPlayerPed::SetRealMoveAnim(void)
if (!curIdleAssoc)
curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
- if ((!curRunStopAssoc || !(curRunStopAssoc->IsRunning())) && (!curRunStopRAssoc || !(curRunStopRAssoc->IsRunning()))) {
+ if (!((curRunStopAssoc && curRunStopAssoc->IsRunning()) || (curRunStopRAssoc && curRunStopRAssoc->IsRunning()))) {
if (curRunStopAssoc && curRunStopAssoc->blendDelta >= 0.0f || curRunStopRAssoc && curRunStopRAssoc->blendDelta >= 0.0f) {
if (curRunStopAssoc) {
@@ -340,8 +336,8 @@ CPlayerPed::SetRealMoveAnim(void)
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 4.0f);
}
}
-
m_nMoveState = PEDMOVE_STILL;
+
} else {
if (curIdleAssoc) {
if (curWalkStartAssoc) {
@@ -394,6 +390,7 @@ CPlayerPed::SetRealMoveAnim(void)
}
if (curSprintAssoc && (m_nMoveState != PEDMOVE_SPRINT || m_fMoveSpeed < 0.4f)) {
+ // Stop sprinting in various conditions
if (curSprintAssoc->blendAmount == 0.0f) {
curSprintAssoc->blendDelta = -1000.0f;
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
@@ -417,8 +414,8 @@ CPlayerPed::SetRealMoveAnim(void)
curRunAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->blendAmount = 0.0f;
curRunAssoc->blendDelta = 0.0f;
- } else if (curSprintAssoc->blendDelta >= 0.0f) {
+ } else if (curSprintAssoc->blendDelta >= 0.0f) {
// Stop sprinting when tired
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
curSprintAssoc->blendDelta = -1.0f;
@@ -428,7 +425,9 @@ CPlayerPed::SetRealMoveAnim(void)
curSprintAssoc->blendDelta = -8.0f;
curRunAssoc->blendDelta = 8.0f;
}
+
} else if (curWalkStartAssoc) {
+ // Walk start and walk/run shouldn't run at the same time
curWalkAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->flags &= ~ASSOC_RUNNING;
curWalkAssoc->blendAmount = 0.0f;
@@ -436,11 +435,13 @@ CPlayerPed::SetRealMoveAnim(void)
} else if (m_nMoveState == PEDMOVE_SPRINT) {
if (curSprintAssoc) {
+ // We have anim, do it
if (curSprintAssoc->blendDelta < 0.0f) {
curSprintAssoc->blendDelta = 2.0f;
curRunAssoc->blendDelta = -2.0f;
}
} else {
+ // Transition between run-sprint
curWalkAssoc->blendAmount = 0.0f;
curRunAssoc->blendAmount = 1.0f;
curSprintAssoc = CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_SPRINT, 2.0f);
@@ -703,14 +704,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
float padMove = CVector2D(leftRight, upDown).Magnitude();
float padMoveInGameUnit = padMove / PAD_MOVE_TO_GAME_WORLD_MOVE;
if (padMoveInGameUnit > 0.0f) {
-#ifdef FREE_CAM
- if (!CCamera::bFreeCam)
- m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
- else
- m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
-#else
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
-#endif
m_fMoveSpeed = Min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
} else {
m_fMoveSpeed = 0.0f;
@@ -718,8 +712,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
if (m_nPedState == PED_JUMP) {
if (bIsInTheAir) {
- if (bUsesCollision && !bHitSteepSlope &&
- (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
+ if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
&& m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) {
float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O
@@ -730,8 +723,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
m_fMoveSpeed = 0.0f;
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
- && padUsed->GetSprint()) {
+ if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
@@ -856,10 +848,9 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft)
{
CEntity *nextTarget = nil;
float weaponRange = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_fRange;
- // nextTarget = nil;
+ // nextTarget = nil; // duplicate
float lastCloseness = -10000.0f;
- // unused
- // CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
+ // CGeneral::GetATanOfXY(GetForward().x, GetForward().y); // unused
CVector distVec = previousTarget->GetPosition() - GetPosition();
float referenceBeta = CGeneral::GetATanOfXY(distVec.x, distVec.y);
@@ -884,9 +875,7 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft)
if (!nextTarget)
return false;
- m_pPointGunAt = nextTarget;
- if (nextTarget)
- nextTarget->RegisterReference((CEntity**)&m_pPointGunAt);
+ SetWeaponLockOnTarget(nextTarget);
SetPointGunAt(nextTarget);
return true;
}
@@ -900,14 +889,14 @@ CPlayerPed::FindWeaponLockOnTarget(void)
if (m_pPointGunAt) {
CVector distVec = m_pPointGunAt->GetPosition() - GetPosition();
if (distVec.Magnitude2D() > weaponRange) {
- m_pPointGunAt = nil;
+ SetWeaponLockOnTarget(nil);
return false;
} else {
return true;
}
}
- // nextTarget = nil;
+ // nextTarget = nil; // duplicate
float lastCloseness = -10000.0f;
float referenceBeta = CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
for (int h = CPools::GetPedPool()->GetSize() - 1; h >= 0; h--) {
@@ -931,9 +920,7 @@ CPlayerPed::FindWeaponLockOnTarget(void)
if (!nextTarget)
return false;
- m_pPointGunAt = nextTarget;
- if (nextTarget)
- nextTarget->RegisterReference((CEntity**)&m_pPointGunAt);
+ SetWeaponLockOnTarget(nextTarget);
SetPointGunAt(nextTarget);
return true;
}
@@ -1002,7 +989,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) {
if (padUsed->TargetJustDown()) {
SetStoredState();
- m_nPedState = PED_SNIPER_MODE;
+ SetPedState(PED_SNIPER_MODE);
#ifdef FREE_CAM
if (CCamera::bFreeCam && TheCamera.Cams[0].Using3rdPersonMouseCam()) {
m_fRotationCur = CGeneral::LimitRadianAngle(-TheCamera.Orientation);
@@ -1105,7 +1092,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
}
}
- } else if (weaponInfo->m_bCanAimWithArm)
+ } else if (weaponInfo->m_bCanAimWithArm && m_nPedState != PED_ATTACK)
ClearPointGunAt();
}
}
@@ -1159,7 +1146,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
#else
CVector markPos;
if (m_pPointGunAt->IsPed()) {
- ((CPed*)m_pPointGunAt)->m_pedIK.GetComponentPosition((RwV3d*)markPos, PED_MID);
+ ((CPed*)m_pPointGunAt)->m_pedIK.GetComponentPosition(markPos, PED_MID);
} else {
markPos = m_pPointGunAt->GetPosition();
}
@@ -1212,8 +1199,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
if (m_nPedState == PED_JUMP) {
if (bIsInTheAir) {
- if (bUsesCollision && !bHitSteepSlope &&
- (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
+ if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
&& m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) {
float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O
@@ -1225,8 +1211,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
- && padUsed->GetSprint()) {
+ if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
@@ -1291,25 +1276,26 @@ CPlayerPed::ProcessControl(void)
if (m_nPedState == PED_DRIVING && m_objective != OBJECTIVE_LEAVE_CAR) {
if (m_pMyVehicle->IsCar() && ((CAutomobile*)m_pMyVehicle)->Damage.GetDoorStatus(DOOR_FRONT_LEFT) == DOOR_STATUS_SWINGING) {
CAnimBlendAssociation *rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR);
- if (!rollDoorAssoc) {
- rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR_LOW);
- }
-
- // These comparisons are wrong, they return uint16
- if (m_pMyVehicle->m_nGettingOutFlags & CAR_DOOR_FLAG_LF || rollDoorAssoc || padUsed
- && (padUsed->GetAccelerate() != 0.0f || padUsed->GetSteeringLeftRight() != 0.0f
- || padUsed->GetBrake() != 0.0f)) {
+ if (m_pMyVehicle->m_nGettingOutFlags & CAR_DOOR_FLAG_LF || rollDoorAssoc || (rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR_LOW))) {
if (rollDoorAssoc)
m_pMyVehicle->ProcessOpenDoor(CAR_DOOR_LF, ANIM_CAR_ROLLDOOR, rollDoorAssoc->currentTime);
+
} else {
- m_pMyVehicle->m_nGettingOutFlags |= CAR_DOOR_FLAG_LF;
- if (m_pMyVehicle->bLowVehicle)
- rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR_LOW);
- else
- rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR);
+ // These comparisons are wrong, they return uint16
+ if (padUsed && (padUsed->GetAccelerate() != 0.0f || padUsed->GetSteeringLeftRight() != 0.0f || padUsed->GetBrake() != 0.0f)) {
+ if (rollDoorAssoc)
+ m_pMyVehicle->ProcessOpenDoor(CAR_DOOR_LF, ANIM_CAR_ROLLDOOR, rollDoorAssoc->currentTime);
- rollDoorAssoc->SetFinishCallback(PedAnimDoorCloseRollingCB, this);
+ } else {
+ m_pMyVehicle->m_nGettingOutFlags |= CAR_DOOR_FLAG_LF;
+ if (m_pMyVehicle->bLowVehicle)
+ rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR_LOW);
+ else
+ rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR);
+
+ rollDoorAssoc->SetFinishCallback(PedAnimDoorCloseRollingCB, this);
+ }
}
}
return;
@@ -1338,12 +1324,18 @@ CPlayerPed::ProcessControl(void)
case PED_FIGHT:
case PED_AIM_GUN:
if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) {
- if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
+ if (TheCamera.Cams[0].Using3rdPersonMouseCam()
+#ifdef FREE_CAM
+ && !CCamera::bFreeCam
+#endif
+ ) {
if (padUsed)
PlayerControl1stPersonRunAround(padUsed);
+
} else if (m_nPedState == PED_FIGHT) {
if (padUsed)
PlayerControlFighter(padUsed);
+
} else if (padUsed) {
PlayerControlZelda(padUsed);
}
@@ -1351,41 +1343,6 @@ CPlayerPed::ProcessControl(void)
if (IsPedInControl() && padUsed)
ProcessPlayerWeapon(padUsed);
break;
- case PED_LOOK_ENTITY:
- case PED_LOOK_HEADING:
- case PED_WANDER_RANGE:
- case PED_WANDER_PATH:
- case PED_PURSUE:
- case PED_FOLLOW_PATH:
- case PED_ROCKET_MODE:
- case PED_DUMMY:
- case PED_PAUSE:
- case PED_FACE_PHONE:
- case PED_MAKE_CALL:
- case PED_CHAT:
- case PED_MUG:
- case PED_AI_CONTROL:
- case PED_FOLLOW_ROUTE:
- case PED_CPR:
- case PED_SOLICIT:
- case PED_BUY_ICECREAM:
- case PED_INVESTIGATE:
- case PED_STEP_AWAY:
- case PED_ON_FIRE:
- case PED_UNKNOWN:
- case PED_STATES_NO_AI:
- case PED_STAGGER:
- case PED_DIVE_AWAY:
- case PED_STATES_NO_ST:
- case PED_ARREST_PLAYER:
- case PED_DRIVING:
- case PED_PASSENGER:
- case PED_TAXI_PASSENGER:
- case PED_OPEN_DOOR:
- case PED_DIE:
- case PED_DEAD:
- case PED_HANDS_UP:
- break;
case PED_SEEK_ENTITY:
m_vecSeekPos = m_pSeekTarget->GetPosition();
@@ -1415,6 +1372,7 @@ CPlayerPed::ProcessControl(void)
if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) {
if (padUsed)
PlayerControlM16(padUsed);
+
} else if (padUsed) {
PlayerControlSniper(padUsed);
}
@@ -1464,6 +1422,8 @@ CPlayerPed::ProcessControl(void)
if (m_nLastPedState == PED_DRAG_FROM_CAR && m_pVehicleAnim)
BeingDraggedFromCar();
break;
+ default:
+ break;
}
if (padUsed && IsPedShootable()) {
ProcessWeaponSwitch(padUsed);
@@ -1477,20 +1437,17 @@ CPlayerPed::ProcessControl(void)
m_lookTimer = 0;
float camAngle = CGeneral::LimitRadianAngle(TheCamera.Cams[TheCamera.ActiveCam].Front.Heading());
float angleBetweenPlayerAndCam = Abs(camAngle - m_fRotationCur);
- if (m_nPedState != PED_ATTACK
- && angleBetweenPlayerAndCam > DEGTORAD(30.0f) && angleBetweenPlayerAndCam < DEGTORAD(330.0f)) {
+ if (m_nPedState != PED_ATTACK && angleBetweenPlayerAndCam > DEGTORAD(30.0f) && angleBetweenPlayerAndCam < DEGTORAD(330.0f)) {
if (angleBetweenPlayerAndCam > DEGTORAD(150.0f) && angleBetweenPlayerAndCam < DEGTORAD(210.0f)) {
float rightTurnAngle = CGeneral::LimitRadianAngle(m_fRotationCur - DEGTORAD(150.0f));
float leftTurnAngle = CGeneral::LimitRadianAngle(DEGTORAD(150.0f) + m_fRotationCur);
- if (m_fLookDirection != 999999.0f) {
- if (Abs(rightTurnAngle - m_fLookDirection) < Abs(leftTurnAngle - m_fLookDirection))
- camAngle = rightTurnAngle;
- else
- camAngle = leftTurnAngle;
- } else {
+ if (m_fLookDirection == 999999.0f)
camAngle = rightTurnAngle;
- }
+ else if (Abs(rightTurnAngle - m_fLookDirection) < Abs(leftTurnAngle - m_fLookDirection))
+ camAngle = rightTurnAngle;
+ else
+ camAngle = leftTurnAngle;
}
SetLookFlag(camAngle, true);
SetLookTimer(CTimer::GetTimeStepInMilliseconds() * 5.0f);
diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp
index b3eaf471..5dbde649 100644
--- a/src/peds/Population.cpp
+++ b/src/peds/Population.cpp
@@ -718,10 +718,10 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree
if (i != 0) {
// Gang member
newPed->SetLeader(gangLeader);
-#ifndef FIX_BUGS
+#if !defined(FIX_BUGS) && GTA_VERSION >= GTA3_PC_10
// seems to be a miami leftover (this code is not on PS2) but gang peds end up just being frozen
- newPed->m_nPedState = PED_UNKNOWN;
- gangLeader->m_nPedState = PED_UNKNOWN;
+ newPed->SetPedState(PED_UNKNOWN);
+ gangLeader->SetPedState(PED_UNKNOWN);
newPed->m_fRotationCur = CGeneral::GetRadianAngleBetweenPoints(
gangLeader->GetPosition().x, gangLeader->GetPosition().y,
newPed->GetPosition().x, newPed->GetPosition().y);