- Added Gez's dropammofactor submission with some necessary changes. Also merged

redundant ammo multiplication code from P_DropItem and ADehackedPickup::TryPickup.
- Restricted native action function definitions to zdoom.pk3.


SVN r1123 (trunk)
This commit is contained in:
Christoph Oelckers 2008-08-07 08:18:48 +00:00
commit 0ad1bfe87e
9 changed files with 82 additions and 34 deletions

View file

@ -2378,14 +2378,64 @@ void A_XXScream (AActor *actor)
}
}
//---------------------------------------------------------------------------
//
// Modifies the drop amount of this item according to the current skill's
// settings (also called by ADehackedPickup::TryPickup)
//
//---------------------------------------------------------------------------
void ModifyDropAmount(AInventory *inv, int dropamount)
{
int flagmask = IF_IGNORESKILL;
fixed_t dropammofactor = G_SkillProperty(SKILLP_DropAmmoFactor);
// Default drop amount is half of regular amount * regular ammo multiplication
if (dropammofactor == -1)
{
dropammofactor = FRACUNIT/2;
flagmask = 0;
}
if (dropamount > 0)
{
if (flagmask != 0 && inv->IsKindOf(RUNTIME_CLASS(AAmmo)))
{
inv->Amount = FixedMul(dropamount, dropammofactor);
inv->ItemFlags |= IF_IGNORESKILL;
}
else
{
inv->Amount = dropamount;
}
}
else if (inv->IsKindOf (RUNTIME_CLASS(AAmmo)))
{
// Half ammo when dropped by bad guys.
inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, FixedMul(inv->Amount, dropammofactor)));
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;
}
else if (inv->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))
{
// For weapons and ammo modified by Dehacked we need to flag the item.
static_cast<ADehackedPickup *>(inv)->droppedbymonster = true;
}
}
//---------------------------------------------------------------------------
//
// PROC P_DropItem
//
//---------------------------------------------------------------------------
CVAR(Int, sv_dropstyle, 0, CVAR_SERVERINFO | CVAR_ARCHIVE);
AInventory *P_DropItem (AActor *source, const PClass *type, int special, int chance)
AInventory *P_DropItem (AActor *source, const PClass *type, int dropamount, int chance)
{
if (type != NULL && pr_dropitem() <= chance)
{
@ -2413,36 +2463,18 @@ AInventory *P_DropItem (AActor *source, const PClass *type, int special, int cha
if (mo->IsKindOf (RUNTIME_CLASS(AInventory)))
{
AInventory * inv = static_cast<AInventory *>(mo);
if (special > 0)
{
inv->Amount = special;
}
else if (mo->IsKindOf (RUNTIME_CLASS(AAmmo)))
{
// Half ammo when dropped by bad guys.
inv->Amount = inv->GetClass()->Meta.GetMetaInt (AIMETA_DropAmount, MAX(1, inv->Amount / 2 ));
}
else if (mo->IsKindOf (RUNTIME_CLASS(AWeapon)))
{
// The same goes for ammo from a weapon.
static_cast<AWeapon *>(mo)->AmmoGive1 /= 2;
static_cast<AWeapon *>(mo)->AmmoGive2 /= 2;
}
else if (mo->IsKindOf (RUNTIME_CLASS(ADehackedPickup)))
{
// For weapons and ammo modified by Dehacked we need to flag the item.
static_cast<ADehackedPickup *>(mo)->droppedbymonster = true;
}
ModifyDropAmount(inv, dropamount);
if (inv->SpecialDropAction (source))
{
return NULL;
}
return inv;
}
if (!(i_compatflags & COMPATF_NOTOSSDROPS))
{
P_TossItem (mo);
}
return static_cast<AInventory *>(mo);
// we can't really return an AInventory pointer to a non-inventory item here, can we?
}
return NULL;
}