IWeapon

Interface to implement a Weapon class

C++
struct IWeapon {
};
File

IWeapon.h

IWeapon::~IWeapon Destructor
C++
virtual ~IWeapon();
IWeapon::ActivateTarget Method
C++
virtual void ActivateTarget(bool activate) = 0;
IWeapon::AddEventListener Method
C++
virtual void AddEventListener(IWeaponEventListener * pListener, const char * who) = 0;
IWeapon::AddFiredRocket Method
C++
virtual void AddFiredRocket() = 0;
IWeapon::AIUseEyeOffset Method
C++
virtual bool AIUseEyeOffset() const = 0;
IWeapon::AIUseOverrideOffset Method
C++
virtual bool AIUseOverrideOffset(EStance stance, float lean, float peekOver, Vec3& offset) const = 0;
IWeapon::ApplyActorRecoil Method
C++
virtual bool ApplyActorRecoil() const = 0;
IWeapon::AutoDrop Method
C++
virtual void AutoDrop() = 0;
IWeapon::CanFire Method

Determines if the weapon can shoot

C++
virtual bool CanFire() const = 0;
IWeapon::CanMeleeAttack Method

Determines if the weapon can perform a melee attack

C++
virtual bool CanMeleeAttack() const = 0;
See Also
IWeapon::CanReload Method

Determines if the weapon can reload

C++
virtual bool CanReload() const = 0;
IWeapon::CanStopFire Method

Query to know if it's allowed to stop firing

C++
virtual bool CanStopFire() const = 0;
IWeapon::CanZoom Method

Determines if the weapon can zoom

C++
virtual bool CanZoom() const = 0;
IWeapon::ChangeFireMode Method

Toggles to the next fire mode

C++
virtual void ChangeFireMode() = 0;
IWeapon::EndChangeFireMode Method
C++
virtual void EndChangeFireMode() = 0;
IWeapon::ExitZoom Method

Requests the weapon to immediately stops its zoom mode

C++
virtual void ExitZoom(bool force = false) = 0;
IWeapon::GetAimLocation Method
C++
virtual Vec3& GetAimLocation() = 0;
IWeapon::GetAIWeaponDescriptor Method
C++
virtual const AIWeaponDescriptor& GetAIWeaponDescriptor() const = 0;
IWeapon::GetAmmoCount Method

Retrieves the ammunition count

C++
virtual int GetAmmoCount(IEntityClass* pAmmoType) const = 0;
Parameters
Parameters
Description
IEntityClass* pAmmoType
EntityClass pointer of the ammo type
Returns

The ammo count if the type was properly specified, or 0 if the specified ammo type wasn't found

See Also
IWeapon::GetAttachmentsAtHelper Method
C++
virtual void GetAttachmentsAtHelper(const char * helper, CCryFixedStringListT<5, 30> & rAttachments) = 0;
IWeapon::GetCurrentFireMode Method

Retrieves the index of the current fire mode

C++
virtual int GetCurrentFireMode() const = 0;
IWeapon::GetCurrentZoomMode Method

Retrieves the index of the current zoom mode

C++
virtual int GetCurrentZoomMode() const = 0;
IWeapon::GetDestination Method

Retrieves the destination position

C++
virtual const Vec3& GetDestination() = 0;
IWeapon::GetFireAlternation Method
C++
virtual bool GetFireAlternation() = 0;
IWeapon::GetFireMode Method (char *)

Retrieves a specified fire mode, by name

C++
virtual IFireMode * GetFireMode(const char * name) const = 0;
Parameters
Parameters
Description
const char * name
name of the specified fire mode
IWeapon::GetFireMode Method (int)

Retrieves a specified fire mode, by index

C++
virtual IFireMode * GetFireMode(int idx) const = 0;
Parameters
Parameters
Description
int idx
index of the specified fire mode
See Also
IWeapon::GetFireModeIdx Method

Retrieves the index for a specified fire mode

C++
virtual int GetFireModeIdx(const char * name) const = 0;
Parameters
Parameters
Description
const char * name
name of the specified fire mode
IWeapon::GetFiringDir Method

Retrieves the firing direction

C++
virtual Vec3 GetFiringDir(const Vec3 & probableHit, const Vec3& firingPos) const = 0;
Parameters
Parameters
Description
const Vec3& firingPos
the firing position
Remarks

It's important to pass the firing position in order to get an accurate firing direction.

See Also
IWeapon::GetFiringLocator Method
C++
virtual IWeaponFiringLocator * GetFiringLocator() const = 0;
IWeapon::GetFiringPos Method

Retrieves the firing position

C++
virtual Vec3 GetFiringPos(const Vec3 & probableHit) const = 0;
See Also
IWeapon::GetHeldEntityId Method
C++
virtual EntityId GetHeldEntityId() const = 0;
IWeapon::GetHostId Method

Retrieves the EntityId of the host

C++
virtual EntityId GetHostId() const = 0;
IWeapon::GetInventoryAmmoCount Method
C++
virtual int GetInventoryAmmoCount(IEntityClass* pAmmoType) const = 0;
IWeapon::GetMaxZoomSteps Method
C++
virtual int GetMaxZoomSteps() = 0;
IWeapon::GetMeleeFireMode Method
C++
virtual IFireMode * GetMeleeFireMode() const = 0;
IWeapon::GetNumOfFireModes Method

Retrieves the fire mode count

C++
virtual int GetNumOfFireModes() const = 0;
IWeapon::GetScopePosition Method
C++
virtual bool GetScopePosition(Vec3& pos) = 0;
IWeapon::GetTargetLocation Method
C++
virtual Vec3& GetTargetLocation() = 0;
IWeapon::GetZoomMode Method (char *)

Retrieves a specified zoom mode, by name

C++
virtual IZoomMode * GetZoomMode(const char * name) const = 0;
Parameters
Parameters
Description
const char * name
name of the specified zoom mode
IWeapon::GetZoomMode Method (int)

Retrieves a specified zoom mode, by index

C++
virtual IZoomMode * GetZoomMode(int idx) const = 0;
Parameters
Parameters
Description
int idx
index of the specified zoom mode
See Also

GetNumOfZoomModes, GetZoomModeIdx

IWeapon::GetZoomState Method
C++
virtual EZoomState GetZoomState() const = 0;
IWeapon::HasAttachmentAtHelper Method
C++
virtual bool HasAttachmentAtHelper(const char * helper) = 0;
IWeapon::IsReloading Method
C++
virtual bool IsReloading(bool includePending = true) const = 0;
IWeapon::IsRippedOff Method
C++
virtual bool IsRippedOff() const = 0;
IWeapon::IsServerSpawn Method
C++
virtual bool IsServerSpawn(IEntityClass* pAmmoType) const = 0;
IWeapon::IsSwitchingFireMode Method
C++
virtual bool IsSwitchingFireMode() = 0;
Description

virtual void RaiseWeapon(bool raise, bool faster = false) = 0; virtual void LowerWeapon(bool lower) = 0; virtual bool IsWeaponRaised() const = 0; virtual bool IsWeaponLowered() = 0;

IWeapon::IsTargetOn Method
C++
virtual bool IsTargetOn() = 0;
IWeapon::IsValidAssistTarget Method
C++
virtual bool IsValidAssistTarget(IEntity * pEntity, IEntity * pSelf, bool includeVehicles = false) = 0;
IWeapon::IsZoomed Method
C++
virtual bool IsZoomed() const = 0;
IWeapon::IsZoomingInOrOut Method
C++
virtual bool IsZoomingInOrOut() const = 0;
IWeapon::LowAmmo Method

Determines if the weapon is low on ammunition based on the passed threshold

C++
virtual bool LowAmmo(float thresholdPerCent) const = 0;
Parameters
Parameters
Description
float thresholdPerCent
Percentage of ammo under which low ammo is true
IWeapon::MeleeAttack Method

Performs a melee attack

C++
virtual void MeleeAttack(bool bShort = false) = 0;
Parameters
Parameters
Description
bool bShort = false
"short" melee, whatever that means (e.g. melee while standing, rather than moving towards the enemy)
See Also
IWeapon::OnAction Method

Receives an action from the client

C++
virtual void OnAction(EntityId actorId, const ActionId& actionId, int activationMode, float value) = 0;
Parameters
Parameters
Description
EntityId actorId
EntityId of the actor who sent the action
const ActionId& actionId
'name' of the action performed
int activationMode
one of the activation mode defined in EActionActivationMode
float value
value which quantified the action performed
IWeapon::OnEndReload Method
C++
virtual void OnEndReload(EntityId shooterId, IEntityClass* pAmmoType) = 0;
IWeapon::OnMelee Method
C++
virtual void OnMelee(EntityId shooterId) = 0;
IWeapon::OnOutOfAmmo Method
C++
virtual void OnOutOfAmmo(IEntityClass* pAmmoType) = 0;
IWeapon::OnReadyToFire Method
C++
virtual void OnReadyToFire() = 0;
IWeapon::OnShoot Method
C++
virtual void OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 & pos, const Vec3 & dir, const Vec3 & vel) = 0;
IWeapon::OnStartReload Method
C++
virtual void OnStartReload(EntityId shooterId, IEntityClass* pAmmoType) = 0;
IWeapon::OnStartTargetting Method
C++
virtual void OnStartTargetting(IWeapon * pWeapon) = 0;
IWeapon::OnStopTargetting Method
C++
virtual void OnStopTargetting(IWeapon * pWeapon) = 0;
IWeapon::OnZoomIn Method
C++
virtual void OnZoomIn() = 0;
IWeapon::OnZoomOut Method
C++
virtual void OnZoomOut() = 0;
IWeapon::OutOfAmmo Method

Determines if the weapon has no more ammunition

C++
virtual bool OutOfAmmo(bool allFireModes) const = 0;
Parameters
Parameters
Description
bool allFireModes
Unless this option is enabled, the ammunition status will only be applicable for the current firemode
IWeapon::OutOfAmmoTypes Method

Determines if the weapon has no more ammunition, including all ammo types

C++
virtual bool OutOfAmmoTypes() const = 0;
IWeapon::PredictProjectileHit Method
C++
virtual bool PredictProjectileHit(IPhysicalEntity * pShooter, const Vec3 & pos, const Vec3 & dir, const Vec3 & velocity, float speed, Vec3& predictedPosOut, float& projectileSpeedOut, Vec3* pTrajectoryPositions = 0, unsigned int* trajectorySizeInOut = 0, float timeStep = 0.24f, Vec3* pTrajectoryVelocities = 0, const bool predictionForAI = false) const = 0;
IWeapon::Query Method

Query some weapon actions, info Patameters query - Query Id param - In/Out param, specific for each query

C++
virtual bool Query(EWeaponQuery query, const void* param = NULL) = 0;
IWeapon::Reload Method

Performs reloading of the weapon

C++
virtual void Reload(bool force = false) = 0;
Parameters
Parameters
Description
bool force = false
when enabled, this will force the weapon to reload even if some conditions could normally block this from happening
See Also
IWeapon::RemoveEventListener Method
C++
virtual void RemoveEventListener(IWeaponEventListener * pListener) = 0;
IWeapon::RequestCancelReload Method
C++
virtual void RequestCancelReload() = 0;
IWeapon::RequestMeleeAttack Method
C++
virtual void RequestMeleeAttack(bool weaponMelee, const Vec3 & pos, const Vec3 & dir) = 0;
IWeapon::RequestReload Method
C++
virtual void RequestReload() = 0;
IWeapon::RequestShoot Method
C++
virtual void RequestShoot(IEntityClass* pAmmoType, const Vec3 & pos, const Vec3 & dir, const Vec3 & vel, const Vec3 & hit, float extra, int predictionHandle, bool forceExtended) = 0;
Description

virtual bool IsLamAttached() = 0; virtual bool IsFlashlightAttached() = 0; virtual void ActivateLamLaser(bool activate, bool aiRequest = true) = 0; virtual void ActivateLamLight(bool activate, bool aiRequest = true) = 0; virtual bool IsLamLaserActivated() = 0; virtual bool IsLamLightActivated() = 0;

IWeapon::RequestStartFire Method
C++
virtual void RequestStartFire() = 0;
IWeapon::RequestStartMeleeAttack Method
C++
virtual void RequestStartMeleeAttack(bool weaponMelee, bool boostedAttack, int8 attackIndex = -1) = 0;
IWeapon::RequestStopFire Method
C++
virtual void RequestStopFire() = 0;
IWeapon::SaveWeaponPosition Method
C++
virtual void SaveWeaponPosition();
Description

FIX ME: = 0;

IWeapon::SendEndReload Method
C++
virtual void SendEndReload() = 0;
Description

virtual IItem* GetIItem() = 0;

IWeapon::SendMusicLogicEvent Method
C++
virtual void SendMusicLogicEvent(EMusicLogicEvents event) = 0;
IWeapon::SetAimLocation Method
C++
virtual void SetAimLocation(Vec3 & location) = 0;
IWeapon::SetAmmoCount Method

Sets the ammunition count

C++
virtual void SetAmmoCount(IEntityClass* pAmmoType, int count) = 0;
Parameters
Parameters
Description
IEntityClass* pAmmoType
EntityClass pointer of the ammo type
int count
Specifies the desired ammo count
See Also
IWeapon::SetCurrentFireMode Method (char *)

Sets the fire mode, by name

C++
virtual void SetCurrentFireMode(const char * name) = 0;
Parameters
Parameters
Description
const char * name
name of the requested fire mode
IWeapon::SetCurrentFireMode Method (int)

Sets the fire mode, by index

C++
virtual void SetCurrentFireMode(int idx) = 0;
Parameters
Parameters
Description
int idx
index of the requested fire mode
IWeapon::SetCurrentZoomMode Method (char *)

Sets the zoom mode, by name

C++
virtual void SetCurrentZoomMode(const char * name) = 0;
Parameters
Parameters
Description
const char * name
name of the requested zoom mode
IWeapon::SetCurrentZoomMode Method (int)

Sets the zoom mode, by index

C++
virtual void SetCurrentZoomMode(int idx) = 0;
Parameters
Parameters
Description
int idx
index of the requested zoom mode
IWeapon::SetDestination Method

Sets the position of the destination target

C++
virtual void SetDestination(const Vec3& pos) = 0;
Parameters
Parameters
Description
const Vec3& pos
position in world space
IWeapon::SetDestinationEntity Method

Sets an entity as the destination target

C++
virtual void SetDestinationEntity(EntityId targetId) = 0;
Parameters
Parameters
Description
pos
position in world space
IWeapon::SetFireAlternation Method
C++
virtual void SetFireAlternation(bool fireAlt) = 0;
IWeapon::SetFiringLocator Method
C++
virtual void SetFiringLocator(IWeaponFiringLocator * pLocator) = 0;
IWeapon::SetHostId Method

Sets the host of the weapon

C++
virtual void SetHostId(EntityId hostId) = 0;
Parameters
Parameters
Description
EntityId hostId
EntityId of the host
Description

The host of the weapon can be any entity which the weapon is child of. For example, the cannon of the tank has the tank as an host.

See Also
IWeapon::SetInventoryAmmoCount Method
C++
virtual void SetInventoryAmmoCount(IEntityClass* pAmmoType, int count) = 0;
IWeapon::SetTargetLocation Method
C++
virtual void SetTargetLocation(Vec3 & location) = 0;
IWeapon::SpawnAmmo Method
C++
virtual CProjectile * SpawnAmmo(IEntityClass* pAmmoType, bool remote = false) = 0;
IWeapon::StartChangeFireMode Method
C++
virtual void StartChangeFireMode() = 0;
IWeapon::StartFire Method ()

Requests the weapon to start firing

C++
virtual void StartFire() = 0;
See Also
IWeapon::StartFire Method (SProjectileLaunchParams&)

Requests the weapon to start firing, using specific projectile launch params

C++
virtual void StartFire(const SProjectileLaunchParams& launchParams) = 0;
See Also
IWeapon::StartZoom Method

Requests the weapon to start its zoom mode

C++
virtual void StartZoom(EntityId shooterId, int zoomed = 1) = 0;
Parameters
Parameters
Description
EntityId shooterId
EntityId of the actor who uses this weapon.
See Also
IWeapon::StopFire Method

Requests the weapon to stop firing

C++
virtual void StopFire() = 0;
IWeapon::StopZoom Method

Requests the weapon to stops its zoom mode

C++
virtual void StopZoom(EntityId shooterId) = 0;
Parameters
Parameters
Description
EntityId shooterId
EntityId of the actor who uses this weapon.