From 324b13c89b3e9a26853dc257240ef3a66e26fdd2 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 24 Mar 2013 02:25:12 +0000 Subject: [PATCH] - Added Weapon.MinSelectionAmmo1 and Weapon.MinSelectionAmmo2 to exclude weapons from autoselection even if they have enough ammo to be used. SVN r4203 (trunk) --- src/g_shared/a_pickups.h | 1 + src/g_shared/a_weapons.cpp | 4 ++++ src/p_user.cpp | 6 ++++++ src/thingdef/thingdef_properties.cpp | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 631a25181..b31d4e288 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -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) diff --git a/src/g_shared/a_weapons.cpp b/src/g_shared/a_weapons.cpp index c5035e416..24d6a545d 100644 --- a/src/g_shared/a_weapons.cpp +++ b/src/g_shared/a_weapons.cpp @@ -65,6 +65,10 @@ void AWeapon::Serialize (FArchive &arc) } arc << FOVScale << Crosshair; + if (SaveVersion >= 4203) + { + arc << MinSelAmmo1 << MinSelAmmo2; + } } //=========================================================================== diff --git a/src/p_user.cpp b/src/p_user.cpp index 132fa4996..47d9ff2ed 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -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; diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 5fc607ca4..482a841a2 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -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; +} + //========================================================================== // //==========================================================================