Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Include/TSEDeviceClassesImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ class CWeaponClass : public CDeviceClass
bool m_bContinuousConsumePerShot; // If a continuous weapon, consume ammunition for every shot in burst
bool m_bOmnidirectional; // Omnidirectional
bool m_bMIRV; // Each shot seeks an independent target
bool m_bNoFireWhenBlind; // Disallow firing this weapon if blinded
bool m_bReportAmmo; // Report count of ammo shot even if not a launcher
int m_iMinFireArc; // Min angle of fire arc (degrees)
int m_iMaxFireArc; // Max angle of fire arc (degrees)
Expand Down
9 changes: 9 additions & 0 deletions TSE/CWeaponClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define MAX_FIRE_ARC_ATTRIB CONSTLIT("maxFireArc")
#define MIN_FIRE_ARC_ATTRIB CONSTLIT("minFireArc")
#define MULTI_TARGET_ATTRIB CONSTLIT("multiTarget")
#define NO_FIRE_WHEN_BLIND_ATTRIB CONSTLIT("noFireWhenBlind")
#define OMNIDIRECTIONAL_ATTRIB CONSTLIT("omnidirectional")
#define POS_ANGLE_ATTRIB CONSTLIT("posAngle")
#define POS_RADIUS_ATTRIB CONSTLIT("posRadius")
Expand Down Expand Up @@ -93,6 +94,7 @@
#define PROPERTY_MAX_DAMAGE CONSTLIT("maxDamage")
#define PROPERTY_MIN_DAMAGE CONSTLIT("minDamage")
#define PROPERTY_MULTI_SHOT CONSTLIT("multiShot")
#define PROPERTY_NO_FIRE_WHEN_BLIND CONSTLIT("noFireWhenBlind")
#define PROPERTY_OMNIDIRECTIONAL CONSTLIT("omnidirectional")
#define PROPERTY_REPEATING CONSTLIT("repeating")
#define PROPERTY_SECONDARY CONSTLIT("secondary")
Expand Down Expand Up @@ -1241,6 +1243,9 @@ bool CWeaponClass::ConsumeAmmo (CItemCtx &ItemCtx, CWeaponFireDesc *pShot, int i
if (pDevice == NULL)
return false;

if (pSource->IsBlind() && m_bNoFireWhenBlind)
return false;

int iAmmoConsumed = FireGetAmmoToConsume(ItemCtx, pShot, iRepeatingCount);

// For repeating weapons, we check at the beginning and consume at the end.
Expand Down Expand Up @@ -1436,6 +1441,7 @@ ALERROR CWeaponClass::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, CI
pWeapon->m_bReportAmmo = pDesc->GetAttributeBool(REPORT_AMMO_ATTRIB);
pWeapon->m_bTargetStationsOnly = pDesc->GetAttributeBool(TARGET_STATIONS_ONLY_ATTRIB);
pWeapon->m_bContinuousConsumePerShot = pDesc->GetAttributeBool(CONTINUOUS_CONSUME_PERSHOT_ATTRIB);
pWeapon->m_bNoFireWhenBlind = pDesc->GetAttributeBool(NO_FIRE_WHEN_BLIND_ATTRIB);


// Configuration
Expand Down Expand Up @@ -2468,6 +2474,9 @@ ICCItem *CWeaponClass::FindAmmoItemProperty (CItemCtx &Ctx, const CItem &Ammo, c
else if (strEquals(sProperty, PROPERTY_MULTI_SHOT))
return CC.CreateBool(m_Configuration != ctSingle);

else if (strEquals(sProperty, PROPERTY_NO_FIRE_WHEN_BLIND))
return CC.CreateBool(m_bNoFireWhenBlind);

else if (strEquals(sProperty, PROPERTY_OMNIDIRECTIONAL))
return CC.CreateBool(GetRotationType(Ctx) == rotOmnidirectional);

Expand Down