Interface to implement a Weapon class
struct IWeapon { };
IWeapon.h
virtual ~IWeapon();
virtual void ActivateTarget(bool activate) = 0;
virtual void AddEventListener(IWeaponEventListener * pListener, const char * who) = 0;
virtual void AddFiredRocket() = 0;
virtual bool AIUseEyeOffset() const = 0;
virtual bool AIUseOverrideOffset(EStance stance, float lean, float peekOver, Vec3& offset) const = 0;
virtual bool ApplyActorRecoil() const = 0;
virtual void AutoDrop() = 0;
Determines if the weapon can shoot
virtual bool CanFire() const = 0;
Determines if the weapon can perform a melee attack
virtual bool CanMeleeAttack() const = 0;
Determines if the weapon can reload
virtual bool CanReload() const = 0;
Query to know if it's allowed to stop firing
virtual bool CanStopFire() const = 0;
Determines if the weapon can zoom
virtual bool CanZoom() const = 0;
Toggles to the next fire mode
virtual void ChangeFireMode() = 0;
virtual void EndChangeFireMode() = 0;
Requests the weapon to immediately stops its zoom mode
virtual void ExitZoom(bool force = false) = 0;
virtual Vec3& GetAimLocation() = 0;
virtual const AIWeaponDescriptor& GetAIWeaponDescriptor() const = 0;
Retrieves the ammunition count
virtual int GetAmmoCount(IEntityClass* pAmmoType) const = 0;
Parameters |
Description |
IEntityClass* pAmmoType |
EntityClass pointer of the ammo type |
The ammo count if the type was properly specified, or 0 if the specified ammo type wasn't found
virtual void GetAttachmentsAtHelper(const char * helper, CCryFixedStringListT<5, 30> & rAttachments) = 0;
Retrieves the index of the current fire mode
virtual int GetCurrentFireMode() const = 0;
Retrieves the index of the current zoom mode
virtual int GetCurrentZoomMode() const = 0;
Retrieves the destination position
virtual const Vec3& GetDestination() = 0;
virtual bool GetFireAlternation() = 0;
Retrieves a specified fire mode, by name
virtual IFireMode * GetFireMode(const char * name) const = 0;
Parameters |
Description |
const char * name |
name of the specified fire mode |
Retrieves a specified fire mode, by index
virtual IFireMode * GetFireMode(int idx) const = 0;
Parameters |
Description |
int idx |
index of the specified fire mode |
Retrieves the index for a specified fire mode
virtual int GetFireModeIdx(const char * name) const = 0;
Parameters |
Description |
const char * name |
name of the specified fire mode |
Retrieves the firing direction
virtual Vec3 GetFiringDir(const Vec3 & probableHit, const Vec3& firingPos) const = 0;
Parameters |
Description |
const Vec3& firingPos |
the firing position |
It's important to pass the firing position in order to get an accurate firing direction.
virtual IWeaponFiringLocator * GetFiringLocator() const = 0;
Retrieves the firing position
virtual Vec3 GetFiringPos(const Vec3 & probableHit) const = 0;
virtual EntityId GetHeldEntityId() const = 0;
Retrieves the EntityId of the host
virtual EntityId GetHostId() const = 0;
virtual int GetInventoryAmmoCount(IEntityClass* pAmmoType) const = 0;
virtual int GetMaxZoomSteps() = 0;
virtual IFireMode * GetMeleeFireMode() const = 0;
Retrieves the fire mode count
virtual int GetNumOfFireModes() const = 0;
virtual bool GetScopePosition(Vec3& pos) = 0;
virtual Vec3& GetTargetLocation() = 0;
Retrieves a specified zoom mode, by name
virtual IZoomMode * GetZoomMode(const char * name) const = 0;
Parameters |
Description |
const char * name |
name of the specified zoom mode |
Retrieves a specified zoom mode, by index
virtual IZoomMode * GetZoomMode(int idx) const = 0;
Parameters |
Description |
int idx |
index of the specified zoom mode |
GetNumOfZoomModes, GetZoomModeIdx
virtual EZoomState GetZoomState() const = 0;
virtual bool HasAttachmentAtHelper(const char * helper) = 0;
virtual bool IsReloading(bool includePending = true) const = 0;
virtual bool IsRippedOff() const = 0;
virtual bool IsServerSpawn(IEntityClass* pAmmoType) const = 0;
virtual bool IsSwitchingFireMode() = 0;
virtual void RaiseWeapon(bool raise, bool faster = false) = 0; virtual void LowerWeapon(bool lower) = 0; virtual bool IsWeaponRaised() const = 0; virtual bool IsWeaponLowered() = 0;
virtual bool IsTargetOn() = 0;
virtual bool IsZoomed() const = 0;
virtual bool IsZoomingInOrOut() const = 0;
Determines if the weapon is low on ammunition based on the passed threshold
virtual bool LowAmmo(float thresholdPerCent) const = 0;
Parameters |
Description |
float thresholdPerCent |
Percentage of ammo under which low ammo is true |
Performs a melee attack
virtual void MeleeAttack(bool bShort = false) = 0;
Parameters |
Description |
bool bShort = false |
"short" melee, whatever that means (e.g. melee while standing, rather than moving towards the enemy) |
Receives an action from the client
virtual void OnAction(EntityId actorId, const ActionId& actionId, int activationMode, float value) = 0;
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 |
virtual void OnEndReload(EntityId shooterId, IEntityClass* pAmmoType) = 0;
virtual void OnMelee(EntityId shooterId) = 0;
virtual void OnOutOfAmmo(IEntityClass* pAmmoType) = 0;
virtual void OnReadyToFire() = 0;
virtual void OnShoot(EntityId shooterId, EntityId ammoId, IEntityClass* pAmmoType, const Vec3 & pos, const Vec3 & dir, const Vec3 & vel) = 0;
virtual void OnStartReload(EntityId shooterId, IEntityClass* pAmmoType) = 0;
virtual void OnStartTargetting(IWeapon * pWeapon) = 0;
virtual void OnStopTargetting(IWeapon * pWeapon) = 0;
virtual void OnZoomIn() = 0;
virtual void OnZoomOut() = 0;
Determines if the weapon has no more ammunition
virtual bool OutOfAmmo(bool allFireModes) const = 0;
Parameters |
Description |
bool allFireModes |
Unless this option is enabled, the ammunition status will only be applicable for the current firemode |
Determines if the weapon has no more ammunition, including all ammo types
virtual bool OutOfAmmoTypes() const = 0;
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;
Query some weapon actions, info Patameters query - Query Id param - In/Out param, specific for each query
virtual bool Query(EWeaponQuery query, const void* param = NULL) = 0;
Performs reloading of the weapon
virtual void Reload(bool force = false) = 0;
Parameters |
Description |
bool force = false |
when enabled, this will force the weapon to reload even if some conditions could normally block this from happening |
virtual void RemoveEventListener(IWeaponEventListener * pListener) = 0;
virtual void RequestCancelReload() = 0;
virtual void RequestMeleeAttack(bool weaponMelee, const Vec3 & pos, const Vec3 & dir) = 0;
virtual void RequestReload() = 0;
virtual void RequestShoot(IEntityClass* pAmmoType, const Vec3 & pos, const Vec3 & dir, const Vec3 & vel, const Vec3 & hit, float extra, int predictionHandle, bool forceExtended) = 0;
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;
virtual void RequestStartFire() = 0;
virtual void RequestStartMeleeAttack(bool weaponMelee, bool boostedAttack, int8 attackIndex = -1) = 0;
virtual void RequestStopFire() = 0;
virtual void SaveWeaponPosition();
FIX ME: = 0;
virtual void SendEndReload() = 0;
virtual IItem* GetIItem() = 0;
virtual void SendMusicLogicEvent(EMusicLogicEvents event) = 0;
virtual void SetAimLocation(Vec3 & location) = 0;
Sets the ammunition count
virtual void SetAmmoCount(IEntityClass* pAmmoType, int count) = 0;
Parameters |
Description |
IEntityClass* pAmmoType |
EntityClass pointer of the ammo type |
int count |
Specifies the desired ammo count |
Sets the fire mode, by name
virtual void SetCurrentFireMode(const char * name) = 0;
Parameters |
Description |
const char * name |
name of the requested fire mode |
Sets the fire mode, by index
virtual void SetCurrentFireMode(int idx) = 0;
Parameters |
Description |
int idx |
index of the requested fire mode |
Sets the zoom mode, by name
virtual void SetCurrentZoomMode(const char * name) = 0;
Parameters |
Description |
const char * name |
name of the requested zoom mode |
Sets the zoom mode, by index
virtual void SetCurrentZoomMode(int idx) = 0;
Parameters |
Description |
int idx |
index of the requested zoom mode |
Sets the position of the destination target
virtual void SetDestination(const Vec3& pos) = 0;
Parameters |
Description |
const Vec3& pos |
position in world space |
Sets an entity as the destination target
virtual void SetDestinationEntity(EntityId targetId) = 0;
Parameters |
Description |
pos |
position in world space |
virtual void SetFireAlternation(bool fireAlt) = 0;
virtual void SetFiringLocator(IWeaponFiringLocator * pLocator) = 0;
Sets the host of the weapon
virtual void SetHostId(EntityId hostId) = 0;
Parameters |
Description |
EntityId hostId |
EntityId of the host |
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.
virtual void SetInventoryAmmoCount(IEntityClass* pAmmoType, int count) = 0;
virtual void SetTargetLocation(Vec3 & location) = 0;
virtual CProjectile * SpawnAmmo(IEntityClass* pAmmoType, bool remote = false) = 0;
virtual void StartChangeFireMode() = 0;
Requests the weapon to start firing
virtual void StartFire() = 0;
Requests the weapon to start firing, using specific projectile launch params
virtual void StartFire(const SProjectileLaunchParams& launchParams) = 0;
Requests the weapon to start its zoom mode
virtual void StartZoom(EntityId shooterId, int zoomed = 1) = 0;
Parameters |
Description |
EntityId shooterId |
EntityId of the actor who uses this weapon. |
Requests the weapon to stop firing
virtual void StopFire() = 0;
Requests the weapon to stops its zoom mode
virtual void StopZoom(EntityId shooterId) = 0;
Parameters |
Description |
EntityId shooterId |
EntityId of the actor who uses this weapon. |