diff options
Diffstat (limited to 'src/peds/Ped.cpp')
-rw-r--r-- | src/peds/Ped.cpp | 90 |
1 files changed, 62 insertions, 28 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 797262d4..44aaae5b 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -273,7 +273,6 @@ static char WaitStateText[][16] = { }; #ifdef TOGGLEABLE_BETA_FEATURES -bool CPed::bUnusedFightThingOnPlayer = false; bool CPed::bPopHeadsOnHeadshot = false; bool CPed::bMakePedsRunToPhonesToReportCrimes = false; #endif @@ -719,7 +718,7 @@ CheckForPedsOnGroundToAttack(CPed *attacker, CPed **pedOnGround) } if (pedOnGround) - * pedOnGround = currentPed; + *pedOnGround = currentPed; return stateToReturn; } @@ -1068,6 +1067,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg) if (attackAssoc) { switch (attackAssoc->animId) { case ANIM_WEAPON_START_THROW: + // what?! if ((!ped->IsPlayer() || ((CPlayerPed*)ped)->m_bHaveTargetSelected) && ped->IsPlayer()) { attackAssoc->blendDelta = -1000.0f; newAnim = CAnimManager::AddAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_THROWU); @@ -1929,13 +1929,13 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) float limitedDest = CGeneral::LimitRadianAngle(m_fRotationDest); float timeUntilStateChange = (m_nPedStateTimer - CTimer::GetTimeInMilliseconds())/600.0f; - m_vecOffsetSeek.z = 0.0f; if (timeUntilStateChange <= 0.0f) { m_vecOffsetSeek.x = 0.0f; m_vecOffsetSeek.y = 0.0f; - } else { - neededPos -= timeUntilStateChange * m_vecOffsetSeek; } + m_vecOffsetSeek.z = 0.0f; + + neededPos -= timeUntilStateChange * m_vecOffsetSeek; if (PI + m_fRotationCur < limitedDest) { limitedDest -= 2 * PI; @@ -2120,18 +2120,16 @@ CPed::SortPeds(CPed **list, int min, int max) int left = max; int right; for(right = min; right <= left; ){ - // Those 1.0s are my addition to make sure loop always run for first time. - for (float rightDist = middleDist-1.0f; middleDist > rightDist; right++) { + float rightDist, leftDist; + do { rightDiff = GetPosition() - list[right]->GetPosition(); rightDist = rightDiff.Magnitude(); - } - right--; + } while (middleDist > rightDist && ++right); - for (float leftDist = middleDist+1.0f; middleDist < leftDist; left--) { + do { leftDiff = GetPosition() - list[left]->GetPosition(); leftDist = leftDiff.Magnitude(); - } - left++; + } while (middleDist < leftDist && left--); if (right <= left) { CPed *ped = list[right]; @@ -4536,7 +4534,7 @@ CPed::SetEvasiveDive(CPhysical *reason, uint8 onlyRandomJump) } } else { if (IsPlayer()) { - ((CPlayerPed*)this)->m_bShouldEvade = 5; + ((CPlayerPed*)this)->m_nEvadeAmount = 5; ((CPlayerPed*)this)->m_pEvadingFrom = reason; reason->RegisterReference((CEntity**) &((CPlayerPed*)this)->m_pEvadingFrom); return; @@ -4827,10 +4825,6 @@ CPed::StartFightAttack(uint8 buttonPressure) animAssoc->SetFinishCallback(FinishFightMoveCB, this); m_fightState = FIGHTSTATE_NO_MOVE; m_takeAStepAfterAttack = false; -#ifdef TOGGLEABLE_BETA_FEATURES - m_takeAStepAfterAttack = IsPlayer() && bUnusedFightThingOnPlayer; -#endif - bIsAttacking = true; if (IsPlayer()) @@ -11064,6 +11058,7 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) int padNo; if (ped->IsPlayer()) { + // BUG? This will cause crash if m_nPedType is bigger then 1, there are only 2 pads switch (ped->m_nPedType) { case PEDTYPE_PLAYER1: padNo = 0; @@ -11077,9 +11072,6 @@ CPed::PedAnimPullPedOutCB(CAnimBlendAssociation* animAssoc, void* arg) case PEDTYPE_PLAYER4: padNo = 3; break; - default: - // FIX: that was "break" - return; } CPad *pad = CPad::GetPad(padNo); @@ -11179,6 +11171,7 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg) int padNo; if (ped->IsPlayer()) { + // BUG? This will cause crash if m_nPedType is bigger then 1, there are only 2 pads switch (ped->m_nPedType) { case PEDTYPE_PLAYER1: padNo = 0; @@ -11192,9 +11185,6 @@ CPed::PedAnimStepOutCarCB(CAnimBlendAssociation* animAssoc, void* arg) case PEDTYPE_PLAYER4: padNo = 3; break; - default: - // FIX: that was "break" - return; } CPad* pad = CPad::GetPad(padNo); bool engineIsIntact = false; @@ -11421,6 +11411,34 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) if (!veh) return; +#ifdef VC_PED_PORTS + // Situation of entering car as a driver while there is already a driver exiting atm. + CPed *driver = veh->pDriver; + if (driver && driver->m_nPedState == PED_DRIVING && !veh->bIsBus && driver->m_objective == OBJECTIVE_LEAVE_VEHICLE + && (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK)) { + + if (!ped->IsPlayer() && (ped->CharCreatedBy != MISSION_CHAR || driver->IsPlayer())) { + ped->QuitEnteringCar(); + return; + } + if (driver->CharCreatedBy == MISSION_CHAR) { + PedSetOutCarCB(nil, veh->pDriver); + if (driver->m_pMyVehicle) { + driver->PositionPedOutOfCollision(); + } else { + driver->m_pMyVehicle = veh; + driver->PositionPedOutOfCollision(); + driver->m_pMyVehicle = nil; + } + veh->pDriver = nil; + } else { + driver->SetDead(); + driver->FlagToDestroyWhenNextProcessed(); + veh->pDriver = nil; + } + } +#endif + if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead()) return; @@ -11450,7 +11468,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) if (veh->IsBoat()) { if (ped->IsPlayer()) { -#ifdef VC_PED_PORTS +#if defined(FIX_BUGS) || defined(VC_PED_PORTS) CCarCtrl::RegisterVehicleOfInterest(veh); #endif if (veh->m_status == STATUS_SIMPLE) { @@ -11503,7 +11521,10 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) #endif } } - } else if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER) { + } + // This shouldn't happen at all. Passengers can't enter with PED_CARJACK. Even though they did, we shouldn't call AddPassenger in here and SetDriver in below. +#ifndef VC_PED_PORTS + 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; @@ -11513,6 +11534,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) veh->AutoPilot.m_nCruiseSpeed = 17; } } +#endif if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK) { veh->SetDriver(ped); @@ -11576,6 +11598,10 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) ped->m_prevObjective = OBJECTIVE_NONE; ped->RestorePreviousObjective(); +#ifdef VC_PED_PORTS + if(veh->pDriver && ped->CharCreatedBy == RANDOM_CHAR) + veh->AutoPilot.m_nCruiseSpeed = 17; +#endif } veh->m_nGettingInFlags &= ~GetCarDoorFlag(ped->m_vehEnterType); @@ -13102,13 +13128,21 @@ CPed::ProcessObjective(void) m_objectiveTimer = 0; } } + // fall through } case OBJECTIVE_ENTER_CAR_AS_DRIVER: { if (!m_carInObjective || bInVehicle) { - bObjectiveCompleted = true; - bScriptObjectiveCompleted = true; - RestorePreviousState(); +#ifdef VC_PED_PORTS + if (bInVehicle && m_pMyVehicle != m_carInObjective) { + SetExitCar(m_pMyVehicle, 0); + } else +#endif + { + bObjectiveCompleted = true; + bScriptObjectiveCompleted = true; + RestorePreviousState(); + } } else { if (m_leaveCarTimer > CTimer::GetTimeInMilliseconds()) { SetMoveState(PEDMOVE_STILL); |