Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class DumbProjectileBehavior : public UpdateModule, public ProjectileUpdateInter
virtual Bool projectileHandleCollision( Object *other );
virtual Bool projectileIsArmed() const { return true; }
virtual ObjectID projectileGetLauncherID() const { return m_launcherID; }
virtual Bool projectileGetLaunchPos(Coord3D& pos) const { if (m_launcherID == INVALID_ID) return false; pos = m_flightPathStart; return true; }
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) {}
virtual void projectileNowJammed() {}
virtual Object* getTargetObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class FreeFallProjectileBehavior : public UpdateModule, public ProjectileUpdateI
virtual Bool projectileHandleCollision( Object *other );
virtual Bool projectileIsArmed() const { return true; }
virtual ObjectID projectileGetLauncherID() const { return m_launcherID; }
virtual Bool projectileGetLaunchPos(Coord3D& pos) const { if (m_launcherID == INVALID_ID) return false; pos = m_launchPos; return true; }
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) {}
virtual void projectileNowJammed() {}
virtual Object* getTargetObject();
Expand All @@ -114,6 +115,7 @@ class FreeFallProjectileBehavior : public UpdateModule, public ProjectileUpdateI
ObjectID m_launcherID; ///< ID of object that launched us (zero if not yet launched)
ObjectID m_victimID; ///< ID of object we are targeting (zero if not yet launched)
Coord3D m_targetPos;
Coord3D m_launchPos; ///< launcher's position at launch time (for DamageFactorAtMaxRange)
const WeaponTemplate* m_detonationWeaponTmpl; ///< weapon to fire at end (or null)
UnsignedInt m_lifespanFrame; ///< if we haven't collided by this frame, blow up anyway
WeaponBonusConditionFlags m_extraBonusFlags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class MissileAIUpdate : public AIUpdateInterface, public ProjectileUpdateInterfa
virtual Bool projectileHandleCollision( Object *other );
virtual Bool projectileIsArmed() const { return m_isArmed; }
virtual ObjectID projectileGetLauncherID() const { return m_launcherID; }
virtual Bool projectileGetLaunchPos(Coord3D& pos) const { if (m_launcherID == INVALID_ID) return false; pos = m_launchPos; return true; }
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ); ///< Number of frames till missile diverts to countermeasures.
virtual void projectileNowJammed();///< We lose our Object target and scatter to the ground
virtual Object* getTargetObject();
Expand Down Expand Up @@ -139,6 +140,7 @@ class MissileAIUpdate : public AIUpdateInterface, public ProjectileUpdateInterfa
Real m_maxAccel;
Coord3D m_originalTargetPos; ///< When firing uphill, we aim high to clear the brow of the hill. jba.
Coord3D m_prevPos;
Coord3D m_launchPos; ///< launcher's position at launch time (for DamageFactorAtMaxRange)
WeaponBonusConditionFlags m_extraBonusFlags;
const WeaponTemplate* m_detonationWeaponTmpl; ///< weapon to fire at end (or null)
const ParticleSystemTemplate* m_exhaustSysTmpl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class NeutronMissileUpdate : public UpdateModule,
virtual void projectileFireAtObjectOrPosition( const Object *victim, const Coord3D *victimPos, const WeaponTemplate *detWeap, const ParticleSystemTemplate* exhaustSysOverride );
virtual Bool projectileIsArmed() const { return m_isArmed; } ///< return true if the missile is armed and ready to explode
virtual ObjectID projectileGetLauncherID() const { return m_launcherID; } ///< Return firer of missile. Returns 0 if not yet fired.
virtual Bool projectileGetLaunchPos(Coord3D& pos) const { if (m_launcherID == INVALID_ID) return false; pos = m_launchPos; return true; } ///< launcher's position at launch time (for DamageFactorAtMaxRange)
virtual Bool projectileHandleCollision( Object *other );
virtual const Coord3D *getVelocity() const { return &m_vel; } ///< get current velocity
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) {}
Expand All @@ -114,6 +115,7 @@ class NeutronMissileUpdate : public UpdateModule,
MissileStateType m_state; ///< the behavior state of the missile
Coord3D m_targetPos; ///< the position of the target
Coord3D m_intermedPos;
Coord3D m_launchPos; ///< launcher's position at launch time (for DamageFactorAtMaxRange)

ObjectID m_launcherID; ///< ID of object that launched us (zero if not yet launched)
WeaponSlotType m_attach_wslot; ///< where to fire the missile from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ class ProjectileUpdateInterface
virtual void projectileFireAtObjectOrPosition( const Object *victim, const Coord3D *victimPos, const WeaponTemplate *detWeap, const ParticleSystemTemplate* exhaustSysOverride ) = 0;
virtual Bool projectileIsArmed() const = 0; ///< return true if the projectile is armed and ready to explode
virtual ObjectID projectileGetLauncherID() const = 0; ///< All projectiles need to keep track of their firer
virtual Bool projectileGetLaunchPos(Coord3D& pos) const { return false; } ///< launcher's position at launch time (for DamageFactorAtMaxRange); returns false if unknown
virtual Bool projectileHandleCollision(Object *other) = 0;
virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) = 0; ///< Number of frames till missile diverts to countermeasures.
virtual void projectileNowJammed() = 0;
Expand Down
17 changes: 15 additions & 2 deletions GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ class WeaponTemplate : public MemoryPoolObject

protected:

// compute the range-based scaling factor (1.0 at point-blank to factorAtMaxRange at attack range)
// for the engagement from 'source' to 'pos'. Uses launch-time position for projectile detonations.
Real computeRangeScaleFactor(const Object* source, const Coord3D* pos, const WeaponBonus& bonus, Real factorAtMaxRange, Bool isProjectileDetonation) const;

// actually deal out the damage.
void dealDamageInternal(ObjectID sourceID, ObjectID victimID, const Coord3D *pos, const WeaponBonus& bonus, Bool isProjectileDetonation) const;
void trimOldHistoricDamage() const;
Expand All @@ -508,6 +512,8 @@ class WeaponTemplate : public MemoryPoolObject
static void parseWeaponBonusSet( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
static void parseScatterTarget( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
static void parseShotDelay( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
static void parsePrimaryDamage( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );
static void parseSecondaryDamage( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ );

static const FieldParse TheWeaponTemplateFieldParseTable[]; ///< the parse table for INI definition

Expand All @@ -516,10 +522,17 @@ class WeaponTemplate : public MemoryPoolObject
AsciiString m_projectileStreamName; ///< Name of object that tracks are stream, if we have one
AsciiString m_laserName; ///< Name of the laser object that persists.
AsciiString m_laserBoneName; ///< Where to put the laser object
Real m_primaryDamage; ///< primary damage amount
Real m_primaryDamage; ///< primary damage amount (nominal/max when variance is used)
Real m_primaryDamageVariance; ///< if nonzero, actual primary damage is randomly reduced by up to this much (from Min:/Max: definition)
Real m_primaryDamageRadius; ///< primary damage radius range
Real m_secondaryDamage; ///< secondary damage amount
Real m_secondaryDamage; ///< secondary damage amount (nominal/max when variance is used)
Real m_secondaryDamageVariance; ///< if nonzero, actual secondary damage is randomly reduced by up to this much (from Min:/Max: definition)
Real m_secondaryDamageRadius; ///< secondary damage radius range
Real m_primaryDamageTaperOff; ///< factor of primary damage applied at the edge of the primary radius (1.0 = no taper)
Real m_secondaryDamageTaperOff; ///< factor of secondary damage applied at the edge of the secondary radius (1.0 = no taper)
Real m_damageFactorAtMaxRange; ///< scales damage based on engagement distance / attack range (1.0 = no scaling)
Real m_radiusFactorAtMaxRange; ///< scales damage radii based on engagement distance / attack range (1.0 = no scaling)
Real m_scatterRadiusFactorAtMaxRange; ///< scales ScatterRadius based on engagement distance / attack range (1.0 = no scaling)
Real m_shockWaveAmount; ///( How much shockwave generated
Real m_shockWaveRadius; ///( How far shockwave effect affects objects
Real m_shockWaveTaperOff; ///( How much shockwave is left at the tip of the shockwave radius
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ FreeFallProjectileBehavior::FreeFallProjectileBehavior(Thing* thing, const Modul
m_launcherID = INVALID_ID;
m_victimID = INVALID_ID;
m_targetPos.zero();
m_launchPos.zero();
m_detonationWeaponTmpl = NULL;
m_lifespanFrame = 0;
m_extraBonusFlags = 0;
Expand Down Expand Up @@ -142,6 +143,8 @@ void FreeFallProjectileBehavior::projectileLaunchAtObjectOrPosition(
DEBUG_ASSERTCRASH(specificBarrelToUse >= 0, ("specificBarrelToUse must now be explicit"));

m_launcherID = launcher ? launcher->getID() : INVALID_ID;
if (launcher)
m_launchPos = *launcher->getPosition();
m_extraBonusFlags = launcher ? launcher->getWeaponBonusCondition() : 0;

if (d->m_applyLauncherBonus && m_extraBonusFlags != 0) {
Expand Down Expand Up @@ -428,7 +431,8 @@ void FreeFallProjectileBehavior::xfer(Xfer* xfer)
{

// version
XferVersion currentVersion = 1;
// 2: Added m_launchPos (for DamageFactorAtMaxRange)
XferVersion currentVersion = 2;
XferVersion version = currentVersion;
xfer->xferVersion(&version, currentVersion);

Expand All @@ -444,6 +448,10 @@ void FreeFallProjectileBehavior::xfer(Xfer* xfer)
// target pos
xfer->xferCoord3D(&m_targetPos);

// launch pos
if (version >= 2)
xfer->xferCoord3D(&m_launchPos);

// weapon template
AsciiString weaponTemplateName = AsciiString::TheEmptyString;
if (m_detonationWeaponTmpl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ MissileAIUpdate::MissileAIUpdate( Thing *thing, const ModuleData* moduleData ) :
m_exhaustID = INVALID_PARTICLE_SYSTEM_ID;
m_extraBonusFlags = 0;
m_originalTargetPos.zero();
m_launchPos.zero();
m_framesTillDecoyed = 0;
m_noDamage = FALSE;
m_isJammed = FALSE;
Expand Down Expand Up @@ -225,6 +226,8 @@ void MissileAIUpdate::projectileLaunchAtObjectOrPosition(
DEBUG_ASSERTCRASH(specificBarrelToUse>=0, ("specificBarrelToUse must now be explicit"));

m_launcherID = launcher ? launcher->getID() : INVALID_ID;
if (launcher)
m_launchPos = *launcher->getPosition();
m_detonationWeaponTmpl = detWeap;
m_extraBonusFlags = launcher ? launcher->getWeaponBonusCondition() : 0;

Expand Down Expand Up @@ -1137,7 +1140,7 @@ void MissileAIUpdate::crc( Xfer *xfer )
void MissileAIUpdate::xfer( Xfer *xfer )
{
// version
const XferVersion currentVersion = 7;
const XferVersion currentVersion = 8;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );

Expand Down Expand Up @@ -1207,6 +1210,11 @@ void MissileAIUpdate::xfer( Xfer *xfer )
{
xfer->xferReal( &m_randomPathDistLeft);
}

if( version >= 8 )
{
xfer->xferCoord3D( &m_launchPos );
}
} // end xfer

// ------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ NeutronMissileUpdate::NeutronMissileUpdate( Thing *thing, const ModuleData* modu

m_targetPos.zero();
m_intermedPos.zero();
m_launchPos.zero();
m_accel.zero();
m_vel.zero();

Expand Down Expand Up @@ -147,6 +148,8 @@ void NeutronMissileUpdate::projectileLaunchAtObjectOrPosition(const Object *vict
DEBUG_ASSERTCRASH(specificBarrelToUse>=0, ("specificBarrelToUse must now be explicit"));

m_launcherID = launcher ? launcher->getID() : INVALID_ID;
if (launcher)
m_launchPos = *launcher->getPosition();
m_attach_wslot = wslot;
m_attach_specificBarrelToUse = specificBarrelToUse;

Expand Down Expand Up @@ -554,7 +557,8 @@ void NeutronMissileUpdate::xfer( Xfer *xfer )
{

// version
XferVersion currentVersion = 1;
// 2: Added m_launchPos (for DamageFactorAtMaxRange)
XferVersion currentVersion = 2;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );

Expand Down Expand Up @@ -606,6 +610,10 @@ void NeutronMissileUpdate::xfer( Xfer *xfer )
// height at launch
xfer->xferReal( &m_heightAtLaunch );

// launch pos
if( version >= 2 )
xfer->xferCoord3D( &m_launchPos );

// decal, if any
m_deliveryDecal.xferRadiusDecal(xfer);

Expand Down
Loading
Loading