diff options
Diffstat (limited to 'src/peds/PedAI.cpp')
-rw-r--r-- | src/peds/PedAI.cpp | 93 |
1 files changed, 7 insertions, 86 deletions
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp index 8b832670..cf566aba 100644 --- a/src/peds/PedAI.cpp +++ b/src/peds/PedAI.cpp @@ -30,8 +30,6 @@ #include "GameLogic.h" #include "Streaming.h" -//--MIAMI: file done - CVector vecPedCarDoorAnimOffset; CVector vecPedCarDoorLoAnimOffset; CVector vecPedVanRearDoorAnimOffset; @@ -44,7 +42,6 @@ CVector vecPedHarleyBikeJumpRhsAnimOffset; CVector vecPedDirtBikeJumpRhsAnimOffset; CVector vecPedBikeKickAnimOffset; -// --MIAMI: Done void CPed::SetObjectiveTimer(int time) { @@ -55,7 +52,6 @@ CPed::SetObjectiveTimer(int time) } } -// --MIAMI: Done void CPed::SetStoredObjective(void) { @@ -90,7 +86,6 @@ CPed::SetStoredObjective(void) } } -// --MIAMI: Done void CPed::ForceStoredObjective(eObjective objective) { @@ -124,7 +119,6 @@ CPed::ForceStoredObjective(eObjective objective) } } -// --MIAMI: Done bool CPed::IsTemporaryObjective(eObjective objective) { @@ -133,7 +127,6 @@ CPed::IsTemporaryObjective(eObjective objective) objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER; } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj) { @@ -180,7 +173,6 @@ CPed::SetObjective(eObjective newObj) } } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj, void *entity) { @@ -415,7 +407,6 @@ CPed::SetObjective(eObjective newObj, CVector dest, float safeDist) } } -// --MIAMI: Done // Only used in 01E1: SET_CHAR_OBJ_FOLLOW_ROUTE opcode // IDA fails very badly in here, puts a fake loop and ignores SetFollowRoute call... void @@ -448,7 +439,6 @@ CPed::SetObjective(eObjective newObj, int16 routePoint, int16 routeType) } } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj, CVector dest) { @@ -588,7 +578,6 @@ CPed::SetObjective(eObjective newObj, CVector dest) } } -// --MIAMI: Done void CPed::SetObjective(eObjective newObj, float heading, const CVector& pos) { @@ -605,7 +594,6 @@ CPed::SetObjective(eObjective newObj, float heading, const CVector& pos) } } -// --MIAMI: Done void CPed::ClearObjective(void) { @@ -631,7 +619,6 @@ CPed::ClearObjective(void) } } -// --MIAMI: Done void CPed::ClearLeader(void) { @@ -651,7 +638,6 @@ CPed::ClearLeader(void) } } -// --MIAMI: Done void CPed::UpdateFromLeader(void) { @@ -810,7 +796,6 @@ CPed::UpdateFromLeader(void) } } -// --MIAMI: Done void CPed::RestorePreviousObjective(void) { @@ -833,7 +818,6 @@ CPed::RestorePreviousObjective(void) bObjectiveCompleted = false; } -// --MIAMI: Done void CPed::ProcessObjective(void) { @@ -969,7 +953,7 @@ CPed::ProcessObjective(void) m_pMyVehicle->SetStatus(STATUS_PHYSICS); m_pMyVehicle->AutoPilot.m_nPrevRouteNode = 0; if (m_nPedType == PEDTYPE_COP) { - m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->m_nWantedLevel * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity); + m_pMyVehicle->AutoPilot.m_nCruiseSpeed = (FindPlayerPed()->m_pWanted->GetWantedLevel() * 0.1f + 0.6f) * (GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity); m_pMyVehicle->AutoPilot.m_nCarMission = CCarAI::FindPoliceCarMissionForWantedLevel(); } else { m_pMyVehicle->AutoPilot.m_nCruiseSpeed = GAME_SPEED_TO_CARAI_SPEED * m_pMyVehicle->pHandling->Transmission.fMaxCruiseVelocity * 0.8f; @@ -2105,7 +2089,6 @@ CPed::ProcessObjective(void) } } -// --MIAMI: Done void CPed::SetFollowRoute(int16 currentPoint, int16 routeType) { @@ -2118,7 +2101,6 @@ CPed::SetFollowRoute(int16 currentPoint, int16 routeType) m_nextRoutePointPos = CRouteNode::GetPointPosition(GetNextPointOnRoute()); } -// --MIAMI: Done int CPed::GetNextPointOnRoute(void) { @@ -2146,7 +2128,6 @@ CPed::GetNextPointOnRoute(void) return nextPoint; } -// --MIAMI: Done bool CPed::HaveReachedNextPointOnRoute(float distToCountReached) { @@ -2157,7 +2138,6 @@ CPed::HaveReachedNextPointOnRoute(float distToCountReached) return false; } -// --MIAMI: Done bool CPed::CanSeeEntity(CEntity *entity, float threshold) { @@ -2183,7 +2163,6 @@ CPed::CanSeeEntity(CEntity *entity, float threshold) return neededTurn < threshold || TWOPI - threshold < neededTurn; } -// --MIAMI: Done // Only used while deciding which gun ped should switch to, if no ammo left. bool CPed::SelectGunIfArmed(void) @@ -2204,7 +2183,6 @@ CPed::SelectGunIfArmed(void) SetCurrentWeapon(WEAPONTYPE_UNARMED); return false; } -// --MIAMI: Done void CPed::ReactToPointGun(CEntity *entWithGun) { @@ -2289,7 +2267,6 @@ CPed::ReactToPointGun(CEntity *entWithGun) } } -// --MIAMI: Done void CPed::ReactToAttack(CEntity *attacker) { @@ -2362,7 +2339,6 @@ CPed::ReactToAttack(CEntity *attacker) } } -// --MIAMI: Done void CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -2607,7 +2583,6 @@ CPed::PedAnimAlignCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -2827,7 +2802,6 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg) return; } -// --MIAMI: Done void CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -2913,7 +2887,6 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) } } -// --MIAMI: Done void CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -3063,7 +3036,6 @@ CPed::PedAnimGetInCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::PedShuffle(void) { @@ -3079,7 +3051,6 @@ CPed::PedShuffle(void) } } -// --MIAMI: Done void CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -3146,7 +3117,6 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) } } -// --MIAMI: Done void CPed::PedAnimShuffleCB(CAnimBlendAssociation* assoc, void* arg) { @@ -3158,7 +3128,6 @@ CPed::PedAnimShuffleCB(CAnimBlendAssociation* assoc, void* arg) } } -// --MIAMI: Done void CPed::SetFormation(eFormation type) { @@ -3182,7 +3151,6 @@ CPed::SetFormation(eFormation type) m_pedFormation = type; } -// --MIAMI: Done CVector CPed::GetFormationPosition(void) { @@ -3231,7 +3199,6 @@ CPed::GetFormationPosition(void) return m_pedInObjective->GetMatrix() * formationOffset; } -// --MIAMI: Done void CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -3371,11 +3338,11 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg) return; } -// --MIAMI: Done void CPed::LineUpPedWithCar(PedLineUpPhase phase) { bool vehIsUpsideDown = false; + bool stillGettingInOut = false; int vehAnim; float seatPosMult = 0.0f; float currentZ; @@ -3628,8 +3595,8 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) 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); - } else if (neededPos.z <= currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) { - adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f); + } else if (neededPos.z < currentZ && m_pVehicleAnim && vehAnim != ANIM_VAN_CLOSE_L && vehAnim != ANIM_VAN_CLOSE) { + adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f); // Smoothly change ped position neededPos.z = currentZ - (currentZ - neededPos.z) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep); @@ -3647,7 +3614,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) if (m_pVehicleAnim && (vehAnim == ANIM_CAR_GETIN_RHS || vehAnim == ANIM_CAR_GETIN_LOW_RHS || vehAnim == ANIM_CAR_GETIN_LHS || vehAnim == ANIM_CAR_GETIN_LOW_LHS || vehAnim == ANIM_CAR_QJACK || vehAnim == ANIM_VAN_GETIN_L || vehAnim == ANIM_VAN_GETIN)) { - adjustedTimeStep = Min(m_pVehicleAnim->timeStep, 0.1f); + adjustedTimeStep = Max(m_pVehicleAnim->timeStep, 0.1f); // Smoothly change ped position neededPos.z = (neededPos.z - currentZ) / (m_pVehicleAnim->GetTimeLeft() / adjustedTimeStep) + currentZ; @@ -3659,7 +3626,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) } } - bool stillGettingInOut = false; if (CTimer::GetTimeInMilliseconds() < m_nPedStateTimer) stillGettingInOut = veh->m_vehType != VEHICLE_TYPE_BOAT || bOnBoat; @@ -3708,7 +3674,6 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) } -// --MIAMI: Done void CPed::SetCarJack(CVehicle* car) { @@ -3791,7 +3756,6 @@ CPed::SetCarJack(CVehicle* car) SetCarJack_AllClear(car, m_vehDoor, doorFlag); } -// --MIAMI: Done void CPed::SetCarJack_AllClear(CVehicle* car, uint32 doorNode, uint32 doorFlag) { @@ -3834,7 +3798,6 @@ CPed::SetCarJack_AllClear(CVehicle* car, uint32 doorNode, uint32 doorFlag) } } -// --MIAMI: Done void CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack) { @@ -3883,7 +3846,6 @@ CPed::SetBeingDraggedFromCar(CVehicle *veh, uint32 vehEnterType, bool quickJack) veh->m_nGettingOutFlags |= GetCarDoorFlag(m_vehDoor); } -// --MIAMI: Done void CPed::BeingDraggedFromCar(void) { @@ -3949,7 +3911,6 @@ CPed::BeingDraggedFromCar(void) } } -// --MIAMI: Done void CPed::SetEnterCar(CVehicle *car, uint32 unused) { @@ -4026,7 +3987,6 @@ CPed::SetEnterCar(CVehicle *car, uint32 unused) } } -// --MIAMI: Done void CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag) { @@ -4079,7 +4039,6 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag) } } -// --MIAMI: Done void CPed::EnterCar(void) { @@ -4123,7 +4082,6 @@ CPed::EnterCar(void) } } -// --MIAMI: Done void CPed::QuitEnteringCar(void) { @@ -4172,7 +4130,6 @@ CPed::QuitEnteringCar(void) } } -// --MIAMI: Done void CPed::SetExitBoat(CVehicle *boat) { @@ -4181,7 +4138,7 @@ CPed::SetExitBoat(CVehicle *boat) RemoveInCarAnims(); CColModel* boatCol = boat->GetColModel(); if (boat->IsUpsideDown()) { - newPos = { 0.0f, 0.0f, boatCol->boundingBox.min.z }; + newPos = CVector(0.0f, 0.0f, boatCol->boundingBox.min.z); newPos = boat->GetMatrix() * newPos; newPos.z += 1.0f; m_vehDoor = CAR_DOOR_RF; @@ -4230,7 +4187,6 @@ CPed::SetExitBoat(CVehicle *boat) m_vecMoveSpeed = boat->m_vecMoveSpeed; } -// --MIAMI: Done // wantedDoorNode = 0 means that func. will determine it void CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode) @@ -4615,7 +4571,6 @@ CPed::SetExitCar(CVehicle *veh, uint32 wantedDoorNode) } } -// --MIAMI: Done void CPed::ExitCar(void) { @@ -4687,7 +4642,6 @@ CPed::ExitCar(void) } } -// --MIAMI: Done CVector CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component) { @@ -4700,7 +4654,6 @@ CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component) return vehDoorPos; } -// --MIAMI: Done void CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen) { @@ -4769,7 +4722,6 @@ CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen) } } -// --MIAMI: Done bool CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen) { @@ -4853,7 +4805,6 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen) return canEnter; } -// --MIAMI: Done void CPed::GoToNearestDoor(CVehicle *veh) { @@ -4863,7 +4814,6 @@ CPed::GoToNearestDoor(CVehicle *veh) SetMoveState(PEDMOVE_RUN); } -// --MIAMI: Done // Unused void CPed::PedSetGetInCarPositionCB(CAnimBlendAssociation* assoc, void* arg) { @@ -4877,7 +4827,6 @@ void CPed::PedSetGetInCarPositionCB(CAnimBlendAssociation* assoc, void* arg) pPed->SetPosition(position); } -// --MIAMI: Done void CPed::SetAnimOffsetForEnterOrExitVehicle(void) { @@ -5039,7 +4988,6 @@ CPed::SetAnimOffsetForEnterOrExitVehicle(void) CAnimManager::RemoveAnimBlockRef(bikedBlock); } -// --MIAMI: Done void CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void *arg) { @@ -5128,7 +5076,6 @@ CPed::PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *animAssoc, void ped->m_nLastPedState = PED_WANDER_PATH; } -// --MIAMI: Done void CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -5225,7 +5172,6 @@ CPed::PedSetDraggedOutCarPositionCB(CAnimBlendAssociation* animAssoc, void* arg) ped->SetGetUp(); } -// --MIAMI: Done uint8 CPed::GetNearestTrainDoor(CVehicle *train, CVector &doorPos) { @@ -5243,7 +5189,6 @@ CPed::GetNearestTrainDoor(CVehicle *train, CVector &doorPos) return 1; } -// --MIAMI: Done uint8 CPed::GetNearestTrainPedPosition(CVehicle *train, CVector &enterPos) { @@ -5302,7 +5247,6 @@ CPed::GetNearestTrainPedPosition(CVehicle *train, CVector &enterPos) return 1; } -// --MIAMI: Done :D void CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -5452,7 +5396,6 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg) } #endif -// --MIAMI: Done void CPed::RegisterThreatWithGangPeds(CEntity *attacker) { @@ -5516,7 +5459,6 @@ CPed::RegisterThreatWithGangPeds(CEntity *attacker) } } -// --MIAMI: Done // Some helper function which doesn't exist in og game. inline void SelectClosestNodeForSeek(CPed *ped, CPathNode *node, CVector2D closeDist, CVector2D farDist, CPathNode *closeNode, CPathNode *closeNode2, int runCount = 3) @@ -5546,7 +5488,6 @@ SelectClosestNodeForSeek(CPed *ped, CPathNode *node, CVector2D closeDist, CVecto } } -// --MIAMI: Done bool CPed::FindBestCoordsFromNodes(CVector unused, CVector *bestCoords) { @@ -5587,7 +5528,6 @@ CPed::FindBestCoordsFromNodes(CVector unused, CVector *bestCoords) return false; } -// --MIAMI: Done bool CPed::DuckAndCover(void) { @@ -5776,7 +5716,6 @@ CPed::DuckAndCover(void) return false; } -// --MIAMI: Done CVector CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset) { @@ -5824,7 +5763,6 @@ CPed::GetPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset) return veh->GetPosition() + doorPos; } -// --MIAMI: Done CVector CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatPosMult) { @@ -5910,7 +5848,7 @@ CPed::GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float seatP } } -// --MIAMI: Done, but what is this parameter for? +// TODO: what is this parameter for? void CPed::SetDuck(uint32 time, bool sth) { @@ -5936,7 +5874,6 @@ CPed::SetDuck(uint32 time, bool sth) } } -// --MIAMI: Done void CPed::Duck(void) { @@ -5963,7 +5900,6 @@ CPed::Duck(void) } } -// --MIAMI: Done void CPed::ClearDuck(bool clearTimer) { @@ -5986,7 +5922,6 @@ CPed::ClearDuck(bool clearTimer) } } -// --MIAMI: Done void CPed::InformMyGangOfAttack(CEntity *attacker) { @@ -6021,7 +5956,6 @@ CPed::InformMyGangOfAttack(CEntity *attacker) } } -// --MIAMI: Done void CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation* animAssoc, void* arg) { @@ -6044,7 +5978,6 @@ CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation* animAssoc, void* arg) veh->Damage.SetDoorStatus(DOOR_FRONT_LEFT, DOOR_STATUS_OK); } -// --MIAMI: Done void CPed::SetSeekBoatPosition(CVehicle *boat) { @@ -6060,7 +5993,6 @@ CPed::SetSeekBoatPosition(CVehicle *boat) SetPedState(PED_SEEK_IN_BOAT); } -// --MIAMI: Done void CPed::SeekBoatPosition(void) { @@ -6082,7 +6014,6 @@ CPed::SeekBoatPosition(void) RestorePreviousState(); } -// --MIAMI: Done bool CPed::IsRoomToBeCarJacked(void) { @@ -6106,7 +6037,6 @@ CPed::IsRoomToBeCarJacked(void) return false; } -// --MIAMI: Done void CPed::AddInCarAnims(CVehicle* car, bool isDriver) { @@ -6141,7 +6071,6 @@ CPed::AddInCarAnims(CVehicle* car, bool isDriver) StopNonPartialAnims(); } -// --MIAMI: Done void CPed::RemoveDrivebyAnims() { @@ -6169,7 +6098,6 @@ CPed::RemoveDrivebyAnims() animAssoc->blendDelta = -1000.0f; } -// --MIAMI: Done void CPed::RemoveInCarAnims(void) { @@ -6182,7 +6110,6 @@ CPed::RemoveInCarAnims(void) } } -// --MIAMI: Done bool CPed::PositionPedOutOfCollision(void) { @@ -6321,7 +6248,6 @@ CPed::PositionPedOutOfCollision(void) return true; } -// --MIAMI: Done // "Any" means he shouldn't have to be in vehicle. bool CPed::PositionAnyPedOutOfCollision(void) @@ -6377,7 +6303,6 @@ CPed::PositionAnyPedOutOfCollision(void) return true; } -// --MIAMI: Done bool CPed::WarpPedToNearLeaderOffScreen(void) { @@ -6411,7 +6336,6 @@ CPed::WarpPedToNearLeaderOffScreen(void) return teleported; } -// --MIAMI: Done bool CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo) { @@ -6445,7 +6369,6 @@ CPed::WarpPedToNearEntityOffScreen(CEntity *warpTo) return teleported; } -// --MIAMI: Done int32 CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWithTarget) { @@ -6720,7 +6643,6 @@ CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWith return ATTACK_IN_PROGRESS; } -// --MIAMI: Done int32 CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWithTarget) { @@ -6975,7 +6897,6 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith } } -// --MIAMI: Done bool CPed::CanBeDamagedByThisGangMember(CPed* who) { |