- Fixed: WeaponGiver did not give half ammo when dropped.

SVN r4238 (trunk)
This commit is contained in:
Randy Heit 2013-04-30 03:07:39 +00:00
parent 5dc034c2ed
commit ecdde24bda
2 changed files with 35 additions and 4 deletions

View file

@ -730,10 +730,41 @@ bool AWeaponGiver::TryPickup(AActor *&toucher)
master = weap = static_cast<AWeapon*>(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;

View file

@ -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<AWeapon *>(inv)->AmmoGive1 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive1, dropammofactor);
static_cast<AWeapon *>(inv)->AmmoGive2 = FixedMul(static_cast<AWeapon *>(inv)->AmmoGive2, dropammofactor);
inv->ItemFlags|=flagmask;
inv->ItemFlags |= flagmask;
}
else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))
{