Checks rewritten

This commit is contained in:
Sergeanur 2019-10-03 23:32:31 +03:00
parent 2cf94348f5
commit 679f7bbcfa
2 changed files with 99 additions and 91 deletions

View File

@ -123,6 +123,18 @@ CPickup::GiveUsAPickUpObject(int32 handle)
return object;
}
bool
CPickup::CanBePickedUp(CPlayerPed *player)
{
assert(m_pObject != nil);
bool cannotBePickedUp =
(m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0)
|| (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame));
return !cannotBePickedUp;
}
bool
CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
{
@ -173,11 +185,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
// if we didn't then we've got nothing to do
if (isPickupTouched) {
if ((m_pObject->GetModelIndex() != MI_PICKUP_BODYARMOUR || player->m_fArmour <= 99.5f)
&& (m_pObject->GetModelIndex() != MI_PICKUP_HEALTH || player->m_fHealth <= 99.5f)
&& (m_pObject->GetModelIndex() != MI_PICKUP_BRIBE || player->m_pWanted->m_nWantedLevel)
&& (m_pObject->GetModelIndex() != MI_PICKUP_KILLFRENZY || !CTheScripts::IsPlayerOnAMission() && !CDarkel::FrenzyOnGoing() && CGame::nastyGame)) {
if (isPickupTouched && CanBePickedUp(player)) {
CPad::GetPad(0)->StartShake(120, 100);
switch (m_eType)
{
@ -208,7 +216,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
DMAudio.PlayFrontEndSound(SOUND_PICKUP_WEAPON, m_pObject->GetModelIndex() - MI_GRENADE);
}
else if (MI_PICKUP_CAMERA == m_pObject->GetModelIndex() && vehicle)
else if (m_pObject->GetModelIndex() == MI_PICKUP_CAMERA && vehicle != nil)
{
DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0);
CPickups::bPickUpcamActivated = true;
@ -275,7 +283,6 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
break;
}
}
}
} else {
switch (m_eType)
{

View File

@ -42,6 +42,7 @@ public:
bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId);
private:
bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; }
inline bool CanBePickedUp(CPlayerPed *player);
void RemoveKeepType();
void Remove();
};