实体

武器 CWeapon

Ped 武器槽实例与开火入口

CWeapon.h

挂在 Ped 武器槽上的实例(类型、弹匣、状态)。全局表见 world-stateCWeaponInfo

槽位字段

m_eWeaponType / m_nAmmoInClip / m_nAmmoTotal
eWeaponType m_eWeaponType;
eWeaponState m_nState;
unsigned int m_nAmmoInClip;
unsigned int m_nAmmoTotal;
unsigned int m_nTimeForNextShot;

武器状态枚举

eWeaponState
enum eWeaponState : unsigned int {
    WEAPONSTATE_READY,
    WEAPONSTATE_FIRING,
    WEAPONSTATE_RELOADING,
    WEAPONSTATE_OUT_OF_AMMO,
    WEAPONSTATE_MELEE_MADECONTACT
};

类型判断

IsTypeMelee / IsType2Handed / IsTypeProjectile
bool IsTypeMelee();
bool IsType2Handed();
bool IsTypeProjectile();
bool HasWeaponAmmoToBeUsed();

初始化与装填

Initialise / Reload / Shutdown
void Initialise(eWeaponType weaponType, int ammo, CPed* owner);
void Reload(CPed* owner);
void Shutdown();

开火入口

Fire / FireProjectile / FireInstantHit

参数多,错用易崩。

bool Fire(CEntity* firingEntity, CVector* origin, CVector* muzzlePosn,
    CEntity* targetEntity, CVector* target, CVector* originForDriveBy);
bool FireProjectile(CEntity* firingEntity, CVector* origin,
    CEntity* targetEntity, CVector* target, float force);
bool FireInstantHit(CEntity* firingEntity, CVector* origin, CVector* muzzlePosn,
    CEntity* targetEntity, CVector* target, CVector* originForDriveBy, bool arg6, bool muzzle);
void FireFromCar(CVehicle* vehicle, bool leftSide, bool rightSide);

全局辅助

GenerateDamageEvent / ProcessLineOfSight
static void GenerateDamageEvent(CPed* victim, CEntity* creator, eWeaponType weaponType,
    int damageFactor, ePedPieceTypes pedPiece, int direction);
static bool ProcessLineOfSight(CVector const& startPoint, CVector const& endPoint,
    CColPoint& outColPoint, CEntity*& outEntity, eWeaponType weaponType, CEntity* arg5,
    bool buildings, bool vehicles, bool peds, bool objects, bool dummies, bool arg11, bool doIgnoreCameraCheck);
static bool CanBeUsedFor2Player(eWeaponType weaponType);

与武器表

CWeaponInfo::GetWeaponInfo(type, skill) 改射程 / 伤害等全局。实例弹药在 CWeapon,表在 Info。

On this page