Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Weapon Class Reference

#include <Weapon.h>

Inherits MemoryPoolObject, and Snapshot.

Public Member Functions

Bool fireWeapon (const Object *source, Object *target, ObjectID *projectileID=NULL)
 
Bool fireWeapon (const Object *source, const Coord3D *pos, ObjectID *projectileID=NULL)
 
void fireProjectileDetonationWeapon (const Object *source, Object *target, WeaponBonusConditionFlags extraBonusFlags, Bool inflictDamage=TRUE)
 
void fireProjectileDetonationWeapon (const Object *source, const Coord3D *pos, WeaponBonusConditionFlags extraBonusFlags, Bool inflictDamage=TRUE)
 
void preFireWeapon (const Object *source, const Object *victim)
 
ObjectforceFireWeapon (const Object *source, const Coord3D *pos)
 
Real estimateWeaponDamage (const Object *source, const Object *target)
 
Real estimateWeaponDamage (const Object *source, const Coord3D *pos)
 
void onWeaponBonusChange (const Object *source)
 Our Object's weapon bonus changed, so we need to update to reflect that instead of waiting.
 
Bool isWithinAttackRange (const Object *source, const Object *target) const
 
Bool isWithinAttackRange (const Object *source, const Coord3D *pos) const
 
Bool isTooClose (const Object *source, const Object *target) const
 
Bool isTooClose (const Object *source, const Coord3D *pos) const
 
Bool isGoalPosWithinAttackRange (const Object *source, const Coord3D *goalPos, const Object *target, const Coord3D *targetPos) const
 
Bool isSourceObjectWithGoalPositionWithinAttackRange (const Object *source, const Coord3D *goalPos, const Object *target, const Coord3D *targetPos) const
 
Bool computeApproachTarget (const Object *source, const Object *target, const Coord3D *pos, Real angleOffset, Coord3D &approachTargetPos) const
 
void loadAmmoNow (const Object *source)
 
void reloadAmmo (const Object *source)
 
WeaponStatus getStatus () const
 
UnsignedInt getPossibleNextShotFrame () const
 Some AI needs to know when the soonest I can possibly next shoot. Bonuses have been figured into this number already.
 
UnsignedInt getPreAttackFinishedFrame () const
 
UnsignedInt getLastReloadStartedFrame () const
 
Real getPercentReadyToFire () const
 
void setPossibleNextShotFrame (UnsignedInt frameNum)
 
void setPreAttackFinishedFrame (UnsignedInt frameNum)
 
void setLastReloadStartedFrame (UnsignedInt frameNum)
 
void transferNextShotStatsFrom (const Weapon &weapon)
 
Real getAttackRange (const Object *source) const
 
Real getAttackDistance (const Object *source, const Object *victim, const Coord3D *victimPos) const
 
void newProjectileFired (const Object *sourceObj, const Object *projectile, const Object *victimObj, const Coord3D *victimPos)
 I just made this projectile and may need to keep track of it.
 
Bool isLaser () const
 
void createLaser (const Object *sourceObj, const Object *victimObj, const Coord3D *victimPos)
 
const WeaponTemplategetTemplate () const
 
WeaponSlotType getWeaponSlot () const
 
AsciiString getName () const
 
UnsignedInt getLastShotFrame () const
 frame a shot was last fired on
 
UnsignedInt getRemainingAmmo () const
 
WeaponReloadType getReloadType () const
 
Bool getAutoReloadsClip () const
 
Real getAimDelta () const
 
Real getScatterRadius () const
 
Real getScatterTargetScalar () const
 
Int getAntiMask () const
 
Bool isCapableOfFollowingWaypoint () const
 
Int getContinuousFireOneShotsNeeded () const
 
Int getContinuousFireTwoShotsNeeded () const
 
UnsignedInt getContinuousFireCoastFrames () const
 
UnsignedInt getAutoReloadWhenIdleFrames () const
 
const AudioEventRTSgetFireSound () const
 
UnsignedInt getFireSoundLoopTime () const
 
DamageType getDamageType () const
 
DeathType getDeathType () const
 
Real getContinueAttackRange () const
 
Bool isShowsAmmoPips () const
 
Int getClipSize () const
 
Bool isContactWeapon () const
 
Int getClipReloadTime (const Object *source) const
 
Real getPrimaryDamageRadius (const Object *source) const
 
Int getPreAttackDelay (const Object *source, const Object *victim) const
 
Bool isDamageWeapon () const
 
Bool isPitchLimited () const
 
Bool isWithinTargetPitch (const Object *source, const Object *victim) const
 
void setLeechRangeActive (Bool active)
 
Bool hasLeechRange () const
 
void setMaxShotCount (Int maxShots)
 
Int getMaxShotCount () const
 
Bool isClearFiringLineOfSightTerrain (const Object *source, const Object *victim) const
 
Bool isClearFiringLineOfSightTerrain (const Object *source, const Coord3D &victimPos) const
 
Bool isClearGoalFiringLineOfSightTerrain (const Object *source, const Coord3D &goalPos, const Object *victim) const
 
Bool isClearGoalFiringLineOfSightTerrain (const Object *source, const Coord3D &goalPos, const Coord3D &victimPos) const
 
void setClipPercentFull (Real percent, Bool allowReduction)
 
UnsignedInt getSuspendFXFrame (void) const
 
- Public Member Functions inherited from MemoryPoolObject
void deleteInstance ()
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 

Static Public Member Functions

static void calcProjectileLaunchPosition (const Object *launcher, WeaponSlotType wslot, Int specificBarrelToUse, Matrix3D &worldTransform, Coord3D &worldPos)
 
static void positionProjectileForLaunch (Object *projectile, const Object *launcher, WeaponSlotType wslot, Int specificBarrelToUse)
 

Protected Member Functions

virtual void crc (Xfer *xfer)
 run the "light" crc check on this data structure
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess (void)
 
 Weapon (const WeaponTemplate *tmpl, WeaponSlotType wslot)
 
Bool privateFireWeapon (const Object *sourceObj, Object *victimObj, const Coord3D *victimPos, Bool isProjectileDetonation, Bool ignoreRanges, WeaponBonusConditionFlags extraBonusFlags, ObjectID *projectileID, Bool inflictDamage)
 
Real estimateWeaponDamage (const Object *sourceObj, const Object *victimObj, const Coord3D *victimPos)
 
void reloadWithBonus (const Object *source, const WeaponBonus &bonus, Bool loadInstantly)
 
void processRequestAssistance (const Object *requestingObject, Object *victimObject)
 Weapons can call for extra attacks from nearby objects.
 
void getFiringLineOfSightOrigin (const Object *source, Coord3D &origin) const
 
void computeBonus (const Object *source, WeaponBonusConditionFlags extraBonusFlags, WeaponBonus &bonus) const
 
void rebuildScatterTargets ()
 
- Protected Member Functions inherited from MemoryPoolObject
virtual ~MemoryPoolObject ()
 
void * operator new (size_t s)
 
void operator delete (void *p)
 
virtual MemoryPoolgetObjectMemoryPool ()=0
 

Friends

class WeaponStore
 

Detailed Description

Definition at line 564 of file Weapon.h.

Constructor & Destructor Documentation

◆ Weapon()

Weapon::Weapon ( const WeaponTemplate * tmpl,
WeaponSlotType wslot )
protected

Definition at line 1748 of file Weapon.cpp.

Member Function Documentation

◆ calcProjectileLaunchPosition()

void Weapon::calcProjectileLaunchPosition ( const Object * launcher,
WeaponSlotType wslot,
Int specificBarrelToUse,
Matrix3D & worldTransform,
Coord3D & worldPos )
static

Definition at line 2937 of file Weapon.cpp.

◆ computeApproachTarget()

Bool Weapon::computeApproachTarget ( const Object * source,
const Object * target,
const Coord3D * pos,
Real angleOffset,
Coord3D & approachTargetPos ) const

Compute a target position from which 'source' can target 'target'. Note that this doesn't guarantee that source can actually move to the location, it just guarantees that the target position is plausibly within attack range. returns TRUE if the source's current pos is already close enough (in which case that current pos is stuffed into the return arg).

Todo
  • make sure we can get to the approach position.

Definition at line 2001 of file Weapon.cpp.

◆ computeBonus()

void Weapon::computeBonus ( const Object * source,
WeaponBonusConditionFlags extraBonusFlags,
WeaponBonus & bonus ) const
protected

Definition at line 1821 of file Weapon.cpp.

◆ crc()

void Weapon::crc ( Xfer * xfer)
protectedvirtual

run the "light" crc check on this data structure

Implements Snapshot.

Definition at line 3161 of file Weapon.cpp.

◆ createLaser()

void Weapon::createLaser ( const Object * sourceObj,
const Object * victimObj,
const Coord3D * victimPos )

Definition at line 2442 of file Weapon.cpp.

◆ estimateWeaponDamage() [1/3]

Real Weapon::estimateWeaponDamage ( const Object * source,
const Coord3D * pos )
inline

Definition at line 616 of file Weapon.h.

◆ estimateWeaponDamage() [2/3]

Real Weapon::estimateWeaponDamage ( const Object * source,
const Object * target )
inline

return the estimate damage that would be done to the given target, taking bonuses, armor, etc into account. (this isn't guaranteed to be 100% accurate; it is intended to be used to decide which weapon should be used when a unit has multiple weapons.) Note that it DOES NOT take weapon range into account – it ASSUMES that the victim is within range!

Definition at line 611 of file Weapon.h.

◆ estimateWeaponDamage() [3/3]

Real Weapon::estimateWeaponDamage ( const Object * sourceObj,
const Object * victimObj,
const Coord3D * victimPos )
protected

Definition at line 2395 of file Weapon.cpp.

◆ fireProjectileDetonationWeapon() [1/2]

void Weapon::fireProjectileDetonationWeapon ( const Object * source,
const Coord3D * pos,
WeaponBonusConditionFlags extraBonusFlags,
Bool inflictDamage = TRUE )

Definition at line 2738 of file Weapon.cpp.

◆ fireProjectileDetonationWeapon() [2/2]

void Weapon::fireProjectileDetonationWeapon ( const Object * source,
Object * target,
WeaponBonusConditionFlags extraBonusFlags,
Bool inflictDamage = TRUE )

Definition at line 2731 of file Weapon.cpp.

◆ fireWeapon() [1/2]

Bool Weapon::fireWeapon ( const Object * source,
const Coord3D * pos,
ObjectID * projectileID = NULL )

Definition at line 2724 of file Weapon.cpp.

◆ fireWeapon() [2/2]

Bool Weapon::fireWeapon ( const Object * source,
Object * target,
ObjectID * projectileID = NULL )

Definition at line 2716 of file Weapon.cpp.

◆ forceFireWeapon()

Object * Weapon::forceFireWeapon ( const Object * source,
const Coord3D * pos )

Definition at line 2747 of file Weapon.cpp.

◆ getAimDelta()

Real Weapon::getAimDelta ( ) const
inline

Definition at line 693 of file Weapon.h.

◆ getAntiMask()

Int Weapon::getAntiMask ( ) const
inline

Definition at line 696 of file Weapon.h.

◆ getAttackDistance()

Real Weapon::getAttackDistance ( const Object * source,
const Object * victim,
const Coord3D * victimPos ) const

Definition at line 2376 of file Weapon.cpp.

◆ getAttackRange()

Real Weapon::getAttackRange ( const Object * source) const

Definition at line 2360 of file Weapon.cpp.

◆ getAutoReloadsClip()

Bool Weapon::getAutoReloadsClip ( ) const
inline

Definition at line 692 of file Weapon.h.

◆ getAutoReloadWhenIdleFrames()

UnsignedInt Weapon::getAutoReloadWhenIdleFrames ( ) const
inline

Definition at line 701 of file Weapon.h.

◆ getClipReloadTime()

Int Weapon::getClipReloadTime ( const Object * source) const

Definition at line 1861 of file Weapon.cpp.

◆ getClipSize()

Int Weapon::getClipSize ( ) const
inline

Definition at line 708 of file Weapon.h.

◆ getContinueAttackRange()

Real Weapon::getContinueAttackRange ( ) const
inline

Definition at line 706 of file Weapon.h.

◆ getContinuousFireCoastFrames()

UnsignedInt Weapon::getContinuousFireCoastFrames ( ) const
inline

Definition at line 700 of file Weapon.h.

◆ getContinuousFireOneShotsNeeded()

Int Weapon::getContinuousFireOneShotsNeeded ( ) const
inline

Definition at line 698 of file Weapon.h.

◆ getContinuousFireTwoShotsNeeded()

Int Weapon::getContinuousFireTwoShotsNeeded ( ) const
inline

Definition at line 699 of file Weapon.h.

◆ getDamageType()

DamageType Weapon::getDamageType ( ) const
inline

Definition at line 704 of file Weapon.h.

◆ getDeathType()

DeathType Weapon::getDeathType ( ) const
inline

Definition at line 705 of file Weapon.h.

◆ getFireSound()

const AudioEventRTS & Weapon::getFireSound ( ) const
inline

Definition at line 702 of file Weapon.h.

◆ getFireSoundLoopTime()

UnsignedInt Weapon::getFireSoundLoopTime ( ) const
inline

Definition at line 703 of file Weapon.h.

◆ getFiringLineOfSightOrigin()

void Weapon::getFiringLineOfSightOrigin ( const Object * source,
Coord3D & origin ) const
protected

Definition at line 3058 of file Weapon.cpp.

◆ getLastReloadStartedFrame()

UnsignedInt Weapon::getLastReloadStartedFrame ( ) const
inline

Definition at line 660 of file Weapon.h.

◆ getLastShotFrame()

UnsignedInt Weapon::getLastShotFrame ( ) const
inline

frame a shot was last fired on

Definition at line 688 of file Weapon.h.

◆ getMaxShotCount()

Int Weapon::getMaxShotCount ( ) const
inline

Definition at line 731 of file Weapon.h.

◆ getName()

AsciiString Weapon::getName ( ) const
inline

Definition at line 687 of file Weapon.h.

◆ getPercentReadyToFire()

Real Weapon::getPercentReadyToFire ( ) const

Definition at line 2315 of file Weapon.cpp.

◆ getPossibleNextShotFrame()

UnsignedInt Weapon::getPossibleNextShotFrame ( ) const
inline

Some AI needs to know when the soonest I can possibly next shoot. Bonuses have been figured into this number already.

Definition at line 658 of file Weapon.h.

◆ getPreAttackDelay()

Int Weapon::getPreAttackDelay ( const Object * source,
const Object * victim ) const

Definition at line 2844 of file Weapon.cpp.

◆ getPreAttackFinishedFrame()

UnsignedInt Weapon::getPreAttackFinishedFrame ( ) const
inline

Definition at line 659 of file Weapon.h.

◆ getPrimaryDamageRadius()

Real Weapon::getPrimaryDamageRadius ( const Object * source) const

Definition at line 2805 of file Weapon.cpp.

◆ getReloadType()

WeaponReloadType Weapon::getReloadType ( ) const
inline

Definition at line 691 of file Weapon.h.

◆ getRemainingAmmo()

UnsignedInt Weapon::getRemainingAmmo ( ) const
inline

Definition at line 690 of file Weapon.h.

◆ getScatterRadius()

Real Weapon::getScatterRadius ( ) const
inline

Definition at line 694 of file Weapon.h.

◆ getScatterTargetScalar()

Real Weapon::getScatterTargetScalar ( ) const
inline

Definition at line 695 of file Weapon.h.

◆ getStatus()

WeaponStatus Weapon::getStatus ( ) const

Definition at line 2760 of file Weapon.cpp.

◆ getSuspendFXFrame()

UnsignedInt Weapon::getSuspendFXFrame ( void ) const
inline

Definition at line 760 of file Weapon.h.

◆ getTemplate()

const WeaponTemplate * Weapon::getTemplate ( ) const
inline

Definition at line 685 of file Weapon.h.

◆ getWeaponSlot()

WeaponSlotType Weapon::getWeaponSlot ( ) const
inline

Definition at line 686 of file Weapon.h.

◆ hasLeechRange()

Bool Weapon::hasLeechRange ( ) const
inline

Definition at line 728 of file Weapon.h.

◆ isCapableOfFollowingWaypoint()

Bool Weapon::isCapableOfFollowingWaypoint ( ) const
inline

Definition at line 697 of file Weapon.h.

◆ isClearFiringLineOfSightTerrain() [1/2]

Bool Weapon::isClearFiringLineOfSightTerrain ( const Object * source,
const Coord3D & victimPos ) const

Definition at line 3107 of file Weapon.cpp.

◆ isClearFiringLineOfSightTerrain() [2/2]

Bool Weapon::isClearFiringLineOfSightTerrain ( const Object * source,
const Object * victim ) const

Definition at line 3090 of file Weapon.cpp.

◆ isClearGoalFiringLineOfSightTerrain() [1/2]

Bool Weapon::isClearGoalFiringLineOfSightTerrain ( const Object * source,
const Coord3D & goalPos,
const Coord3D & victimPos ) const

Determine whether if source was at goalPos whether it would have clear line of sight.

Definition at line 3134 of file Weapon.cpp.

◆ isClearGoalFiringLineOfSightTerrain() [2/2]

Bool Weapon::isClearGoalFiringLineOfSightTerrain ( const Object * source,
const Coord3D & goalPos,
const Object * victim ) const

Determine whether if source was at goalPos whether it would have clear line of sight.

Definition at line 3120 of file Weapon.cpp.

◆ isContactWeapon()

Bool Weapon::isContactWeapon ( ) const
inline

Definition at line 710 of file Weapon.h.

◆ isDamageWeapon()

Bool Weapon::isDamageWeapon ( ) const

Definition at line 2813 of file Weapon.cpp.

◆ isGoalPosWithinAttackRange()

Bool Weapon::isGoalPosWithinAttackRange ( const Object * source,
const Coord3D * goalPos,
const Object * target,
const Coord3D * targetPos ) const

Definition at line 2265 of file Weapon.cpp.

◆ isLaser()

Bool Weapon::isLaser ( ) const
inline

Definition at line 682 of file Weapon.h.

◆ isPitchLimited()

Bool Weapon::isPitchLimited ( ) const
inline

Definition at line 720 of file Weapon.h.

◆ isShowsAmmoPips()

Bool Weapon::isShowsAmmoPips ( ) const
inline

Definition at line 707 of file Weapon.h.

◆ isSourceObjectWithGoalPositionWithinAttackRange()

Bool Weapon::isSourceObjectWithGoalPositionWithinAttackRange ( const Object * source,
const Coord3D * goalPos,
const Object * target,
const Coord3D * targetPos ) const

Definition at line 2134 of file Weapon.cpp.

◆ isTooClose() [1/2]

Bool Weapon::isTooClose ( const Object * source,
const Coord3D * pos ) const

Definition at line 2250 of file Weapon.cpp.

◆ isTooClose() [2/2]

Bool Weapon::isTooClose ( const Object * source,
const Object * target ) const

Definition at line 2235 of file Weapon.cpp.

◆ isWithinAttackRange() [1/2]

Bool Weapon::isWithinAttackRange ( const Object * source,
const Coord3D * pos ) const

Definition at line 2159 of file Weapon.cpp.

◆ isWithinAttackRange() [2/2]

Bool Weapon::isWithinAttackRange ( const Object * source,
const Object * target ) const

return true if the target is within attack range, false otherwise.

Definition at line 2176 of file Weapon.cpp.

◆ isWithinTargetPitch()

Bool Weapon::isWithinTargetPitch ( const Object * source,
const Object * victim ) const

Definition at line 2779 of file Weapon.cpp.

◆ loadAmmoNow()

void Weapon::loadAmmoNow ( const Object * source)

note that "load" makes the ammo instantly available, while "reload" keeps the weapon in the RELOADING state until the clip-reload-time is up. Normally you should use "load" only for newly-created units, who presumably come into existence with fully loaded weapons.

Definition at line 1844 of file Weapon.cpp.

◆ loadPostProcess()

void Weapon::loadPostProcess ( void )
protectedvirtual

Load post process

Implements Snapshot.

Definition at line 3471 of file Weapon.cpp.

◆ newProjectileFired()

void Weapon::newProjectileFired ( const Object * sourceObj,
const Object * projectile,
const Object * victimObj,
const Coord3D * victimPos )

I just made this projectile and may need to keep track of it.

Definition at line 2412 of file Weapon.cpp.

◆ onWeaponBonusChange()

void Weapon::onWeaponBonusChange ( const Object * source)

Our Object's weapon bonus changed, so we need to update to reflect that instead of waiting.

Definition at line 1959 of file Weapon.cpp.

◆ positionProjectileForLaunch()

void Weapon::positionProjectileForLaunch ( Object * projectile,
const Object * launcher,
WeaponSlotType wslot,
Int specificBarrelToUse )
static

Definition at line 3020 of file Weapon.cpp.

◆ preFireWeapon()

void Weapon::preFireWeapon ( const Object * source,
const Object * victim )

Definition at line 2701 of file Weapon.cpp.

◆ privateFireWeapon()

Bool Weapon::privateFireWeapon ( const Object * sourceObj,
Object * victimObj,
const Coord3D * victimPos,
Bool isProjectileDetonation,
Bool ignoreRanges,
WeaponBonusConditionFlags extraBonusFlags,
ObjectID * projectileID,
Bool inflictDamage )
protected

Definition at line 2481 of file Weapon.cpp.

◆ processRequestAssistance()

void Weapon::processRequestAssistance ( const Object * requestingObject,
Object * victimObject )
protected

Weapons can call for extra attacks from nearby objects.

Definition at line 2920 of file Weapon.cpp.

◆ rebuildScatterTargets()

void Weapon::rebuildScatterTargets ( )
protected

Definition at line 1888 of file Weapon.cpp.

◆ reloadAmmo()

void Weapon::reloadAmmo ( const Object * source)

Definition at line 1852 of file Weapon.cpp.

◆ reloadWithBonus()

void Weapon::reloadWithBonus ( const Object * source,
const WeaponBonus & bonus,
Bool loadInstantly )
protected

Definition at line 1901 of file Weapon.cpp.

◆ setClipPercentFull()

void Weapon::setClipPercentFull ( Real percent,
Bool allowReduction )

special purpose call for jets in airfields: directly set the ammoinclip to a certain percentage full (note that percent=1.0 is full, NOT percent=100.0!). this will end up with status as READY_TO_FIRE or OUT_OF_AMMO, but never RELOADING_CLIP!

Definition at line 1869 of file Weapon.cpp.

◆ setLastReloadStartedFrame()

void Weapon::setLastReloadStartedFrame ( UnsignedInt frameNum)
inline

Definition at line 666 of file Weapon.h.

◆ setLeechRangeActive()

void Weapon::setLeechRangeActive ( Bool active)
inline

Definition at line 727 of file Weapon.h.

◆ setMaxShotCount()

void Weapon::setMaxShotCount ( Int maxShots)
inline

Definition at line 730 of file Weapon.h.

◆ setPossibleNextShotFrame()

void Weapon::setPossibleNextShotFrame ( UnsignedInt frameNum)
inline

Definition at line 664 of file Weapon.h.

◆ setPreAttackFinishedFrame()

void Weapon::setPreAttackFinishedFrame ( UnsignedInt frameNum)
inline

Definition at line 665 of file Weapon.h.

◆ transferNextShotStatsFrom()

void Weapon::transferNextShotStatsFrom ( const Weapon & weapon)

Definition at line 3151 of file Weapon.cpp.

◆ xfer()

void Weapon::xfer ( Xfer * xfer)
protectedvirtual

Xfer Version Info: 1: Initial version

Implements Snapshot.

Definition at line 3365 of file Weapon.cpp.

Friends And Related Symbol Documentation

◆ WeaponStore

friend class WeaponStore
friend

Definition at line 567 of file Weapon.h.


The documentation for this class was generated from the following files: