Permalink
Browse files

Add new weapon flag: NoFriendlyFire

Prevents this weapon from causing friendly
fire from splash damage.
  • Loading branch information...
perim committed Dec 3, 2017
1 parent e36ebcf commit d75ccdea67fb48f41b370a0c15cea3b6703f344e
Showing with 18 additions and 0 deletions.
  1. +5 −0 src/projectile.cpp
  2. +4 −0 src/stats.cpp
  3. +9 −0 src/statsdef.h
View
@@ -1172,6 +1172,11 @@ static void proj_ImpactFunc(PROJECTILE *psObj)
continue; // Don't hit main target twice.
}
if (psObj->psSource && psObj->psSource->player == psCurr->player && psStats->flags.test(WEAPON_FLAG_NO_FRIENDLY_FIRE))
{
continue; // this weapon does not do friendly damage
}
bool bTargetInAir = false;
bool useSphere = false;
bool damageable = true;
View
@@ -526,6 +526,10 @@ bool loadWeaponStats(const char *pFileName)
{
psStats->surfaceToAir |= SHOOT_IN_AIR;
}
if (flags.contains("NoFriendlyFire", Qt::CaseInsensitive))
{
psStats->flags.set(WEAPON_FLAG_NO_FRIENDLY_FIRE, true);
}
//set the weapon sounds to default value
psStats->iAudioFireID = NO_SOUND;
View
@@ -28,6 +28,7 @@ struct iIMDShape;
#include <vector>
#include <algorithm>
#include <bitset>
/* The different types of droid */
// NOTE, if you add to, or change this list then you'll need
@@ -103,6 +104,12 @@ enum COMPONENT_TYPE
COMP_NUMCOMPONENTS, /** The number of enumerators in this enum. */
};
enum WEAPON_FLAGS
{
WEAPON_FLAG_NO_FRIENDLY_FIRE,
WEAPON_FLAG_COUNT
};
/**
* LOC used for holding locations for Sensors and ECM's
*/
@@ -411,6 +418,8 @@ struct WEAPON_STATS : public COMPONENT_STATS
bool penetrate; ///< flag to indicate whether pentrate droid or not
int distanceExtensionFactor; ///< max extra distance a projectile can travel if misses target
std::bitset<WEAPON_FLAG_COUNT> flags;
/* Graphics control stats */
UDWORD radiusLife; ///< How long a blast radius is visible
UDWORD numExplosions; ///< The number of explosions per shot

0 comments on commit d75ccde

Please sign in to comment.