- Added Weapon.MinSelectionAmmo1 and Weapon.MinSelectionAmmo2 to exclude weapons from autoselection

even if they have enough ammo to be used.

SVN r4203 (trunk)
This commit is contained in:
Randy Heit 2013-03-24 02:25:12 +00:00
parent 449bf216fa
commit 324b13c89b
4 changed files with 29 additions and 0 deletions

View file

@ -264,6 +264,7 @@ public:
const PClass *ProjectileType; // Projectile used by primary attack
const PClass *AltProjectileType; // Projectile used by alternate attack
int SelectionOrder; // Lower-numbered weapons get picked first
int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo
fixed_t MoveCombatDist; // Used by bots, but do they *really* need it?
int ReloadCounter; // For A_CheckForReload
int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha)

View file

@ -65,6 +65,10 @@ void AWeapon::Serialize (FArchive &arc)
}
arc << FOVScale
<< Crosshair;
if (SaveVersion >= 4203)
{
arc << MinSelAmmo1 << MinSelAmmo2;
}
}
//===========================================================================

View file

@ -766,6 +766,12 @@ AWeapon *APlayerPawn::BestWeapon (const PClass *ammotype)
!weap->CheckAmmo (AWeapon::PrimaryFire, false))
continue;
// Don't select if if there isn't enough ammo as determined by the weapon's author.
if (weap->MinSelAmmo1 > 0 && (weap->Ammo1 == NULL || weap->Ammo1->Amount < weap->MinSelAmmo1))
continue;
if (weap->MinSelAmmo2 > 0 && (weap->Ammo2 == NULL || weap->Ammo2->Amount < weap->MinSelAmmo2))
continue;
// This weapon is usable!
bestOrder = weap->SelectionOrder;
bestMatch = weap;

View file

@ -1739,6 +1739,24 @@ DEFINE_CLASS_PROPERTY(selectionorder, I, Weapon)
defaults->SelectionOrder = i;
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(minselectionammo1, I, Weapon)
{
PROP_INT_PARM(i, 0);
defaults->MinSelAmmo1 = i;
}
//==========================================================================
//
//==========================================================================
DEFINE_CLASS_PROPERTY(minselectionammo2, I, Weapon)
{
PROP_INT_PARM(i, 0);
defaults->MinSelAmmo2 = i;
}
//==========================================================================
//
//==========================================================================