From ecdde24bda45b3f4243224c5c7cd47eec64ead7f Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 30 Apr 2013 03:07:39 +0000 Subject: [PATCH] - Fixed: WeaponGiver did not give half ammo when dropped. SVN r4238 (trunk) --- src/g_shared/a_weapons.cpp | 35 +++++++++++++++++++++++++++++++++-- src/p_enemy.cpp | 4 ++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 24d6a545d..23cc08e82 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -730,10 +730,41 @@ bool AWeaponGiver::TryPickup(AActor *&toucher) master = weap = static_cast(Spawn(di->Name, 0, 0, 0, NO_REPLACE)); if (weap != NULL) { + fixed_t dropammofactor; weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only. weap->flags = (weap->flags & ~MF_DROPPED) | (this->flags & MF_DROPPED); - if (AmmoGive1 >= 0) weap->AmmoGive1 = AmmoGive1; - if (AmmoGive2 >= 0) weap->AmmoGive2 = AmmoGive2; + + // If we're not overriding the ammo given amounts, then apply dropped + // item modifications if needed. + if (weap->flags & MF_DROPPED) + { + dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor); + if (dropammofactor < 0) + { + dropammofactor = FRACUNIT/2; + } + } + else + { + dropammofactor = FRACUNIT; + } + + if (AmmoGive1 < 0) + { + weap->AmmoGive1 = FixedMul(weap->AmmoGive1, dropammofactor); + } + else + { + weap->AmmoGive1 = AmmoGive1; + } + if (AmmoGive2 < 0) + { + weap->AmmoGive2 = FixedMul(weap->AmmoGive2, dropammofactor); + } + else + { + weap->AmmoGive2 = AmmoGive2; + } weap->BecomeItem(); } else return false; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index dc96eb8ac..75453386e 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -3023,14 +3023,14 @@ void ModifyDropAmount(AInventory *inv, int dropamount) { // Half ammo when dropped by bad guys. inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, FixedMul(inv->Amount, dropammofactor))); - inv->ItemFlags|=flagmask; + inv->ItemFlags |= flagmask; } else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon))) { // The same goes for ammo from a weapon. static_cast(inv)->AmmoGive1 = FixedMul(static_cast(inv)->AmmoGive1, dropammofactor); static_cast(inv)->AmmoGive2 = FixedMul(static_cast(inv)->AmmoGive2, dropammofactor); - inv->ItemFlags|=flagmask; + inv->ItemFlags |= flagmask; } else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup))) {