diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 4be7100a8..6c68990d1 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -359,7 +359,17 @@ enum WIF_BOT_BFG = 1<<28, // this is a BFG }; -#define S_LIGHTDONE 0 +class AWeaponGiver : public AWeapon +{ + DECLARE_CLASS(AWeaponGiver, AWeapon) + +public: + bool TryPickup(AActor *&toucher); + void Serialize(FArchive &arc); + + fixed_t DropAmmoFactor; +}; + // Health is some item that gives the player health when picked up. class AHealth : public AInventory diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index 23cc08e82..b6c4e1116 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -705,16 +705,17 @@ FState *AWeapon::GetZoomState () /* Weapon giver ***********************************************************/ -class AWeaponGiver : public AWeapon -{ - DECLARE_CLASS(AWeaponGiver, AWeapon) - -public: - bool TryPickup(AActor *&toucher); -}; - IMPLEMENT_CLASS(AWeaponGiver) +void AWeaponGiver::Serialize(FArchive &arc) +{ + Super::Serialize(arc); + if (SaveVersion >= 4246) + { + arc << DropAmmoFactor; + } +} + bool AWeaponGiver::TryPickup(AActor *&toucher) { FDropItem *di = GetDropItems(); @@ -734,36 +735,15 @@ bool AWeaponGiver::TryPickup(AActor *&toucher) weap->ItemFlags &= ~IF_ALWAYSPICKUP; // use the flag of this item only. weap->flags = (weap->flags & ~MF_DROPPED) | (this->flags & MF_DROPPED); - // 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 our ammo gives are non-negative, transfer them to the real weapon. + if (AmmoGive1 >= 0) weap->AmmoGive1 = AmmoGive1; + if (AmmoGive2 >= 0) weap->AmmoGive2 = AmmoGive2; - if (AmmoGive1 < 0) + // If DropAmmoFactor is non-negative, modify the given ammo amounts. + if (DropAmmoFactor > 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->AmmoGive1 = FixedMul(weap->AmmoGive1, DropAmmoFactor); + weap->AmmoGive2 = FixedMul(weap->AmmoGive2, DropAmmoFactor); } weap->BecomeItem(); } diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 75453386e..70b80e7fb 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -3025,6 +3025,11 @@ void ModifyDropAmount(AInventory *inv, int dropamount) inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, FixedMul(inv->Amount, dropammofactor))); inv->ItemFlags |= flagmask; } + else if (inv->IsKindOf (RUNTIME_CLASS(AWeaponGiver))) + { + static_cast(inv)->DropAmmoFactor = dropammofactor; + inv->ItemFlags |= flagmask; + } else if (inv->IsKindOf (RUNTIME_CLASS(AWeapon))) { // The same goes for ammo from a weapon.