diff options
Diffstat (limited to 'src/weapons')
-rw-r--r-- | src/weapons/ShotInfo.cpp | 6 | ||||
-rw-r--r-- | src/weapons/Weapon.cpp | 4 | ||||
-rw-r--r-- | src/weapons/WeaponInfo.cpp | 33 | ||||
-rw-r--r-- | src/weapons/WeaponInfo.h | 53 |
4 files changed, 35 insertions, 61 deletions
diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp index ae7b9d2d..a03ed16f 100644 --- a/src/weapons/ShotInfo.cpp +++ b/src/weapons/ShotInfo.cpp @@ -78,7 +78,7 @@ CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos, gaShotInfo[slot].m_areaAffected.z += CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)]; } gaShotInfo[slot].m_areaAffected.Normalise(); - if (weaponInfo->m_bRandSpeed) + if (weaponInfo->IsFlagSet(WEAPONFLAG_RAND_SPEED)) gaShotInfo[slot].m_areaAffected *= CShotInfo::ms_afRandTable[CGeneral::GetRandomNumber() % ARRAY_SIZE(ms_afRandTable)] + weaponInfo->m_fSpeed; else gaShotInfo[slot].m_areaAffected *= weaponInfo->m_fSpeed; @@ -119,10 +119,10 @@ CShotInfo::Update() shot.m_inUse = false; } - if (weaponInfo->m_bSlowsDown) + if (weaponInfo->IsFlagSet(WEAPONFLAG_SLOWS_DOWN)) shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE - if (weaponInfo->m_bExpands) + if (weaponInfo->IsFlagSet(WEAPONFLAG_EXPANDS)) shot.m_radius += 0.075f * CTimer::GetTimeStep(); shot.m_startPos += CTimer::GetTimeStep() * shot.m_areaAffected; diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 2435d544..e2213399 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -499,7 +499,7 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource) bool collided = false; if (victimPed->m_nPedState == PED_DRIVING && (m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE - || info->m_bFightMode)) + || info->IsFlagSet(WEAPONFLAG_FIGHTMODE))) continue; float victimPedRadius = victimPed->GetBoundRadius() + info->m_fRadius; @@ -1008,7 +1008,7 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) target.y += rotOffset.y * info->m_fRange; CParticle::HandleShootableBirdsStuff(shooter, *fireSource); - if (shooter->IsPed() && ((CPed*)shooter)->bDoomAim && (shooter != FindPlayerPed() || !info->m_bCanAim)) + if (shooter->IsPed() && ((CPed*)shooter)->bDoomAim && (shooter != FindPlayerPed() || !info->IsFlagSet(WEAPONFLAG_CANAIM))) { CWeapon::DoDoomAiming(shooter, fireSource, &target); } diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index 4a61e42c..30c6c8cb 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -129,12 +129,8 @@ CWeaponInfo::Initialise(void) ms_apWeaponInfos[i].m_fAnim2LoopEnd = 0.0f; ms_apWeaponInfos[i].m_fAnim2FrameFire = 0.0f; ms_apWeaponInfos[i].m_fAnimBreakout = 0.0f; - ms_apWeaponInfos[i].m_bUseGravity = 1; - ms_apWeaponInfos[i].m_bSlowsDown = 1; - ms_apWeaponInfos[i].m_bRandSpeed = 1; - ms_apWeaponInfos[i].m_bExpands = 1; - ms_apWeaponInfos[i].m_bExplodes = 1; - ms_apWeaponInfos[i].m_nWeaponSlot = 0; + ms_apWeaponInfos[i].m_Flags = WEAPONFLAG_USE_GRAVITY | WEAPONFLAG_SLOWS_DOWN | WEAPONFLAG_RAND_SPEED | WEAPONFLAG_EXPANDS | WEAPONFLAG_EXPLODES; + ms_apWeaponInfos[i].m_nWeaponSlot = WEAPONSLOT_UNARMED; } debug("Loading weapon data...\n"); LoadWeaponData(); @@ -246,30 +242,7 @@ CWeaponInfo::LoadWeaponData(void) ms_apWeaponInfos[weaponType].m_fAnimBreakout = animBreakout / 30.0f; ms_apWeaponInfos[weaponType].m_nModelId = modelId; ms_apWeaponInfos[weaponType].m_nModel2Id = modelId2; - - ms_apWeaponInfos[weaponType].m_bUseGravity = flags & 1; - ms_apWeaponInfos[weaponType].m_bSlowsDown = (flags >> 1) & 1; - ms_apWeaponInfos[weaponType].m_bDissipates = (flags >> 2) & 1; - ms_apWeaponInfos[weaponType].m_bRandSpeed = (flags >> 3) & 1; - ms_apWeaponInfos[weaponType].m_bExpands = (flags >> 4) & 1; - ms_apWeaponInfos[weaponType].m_bExplodes = (flags >> 5) & 1; - ms_apWeaponInfos[weaponType].m_bCanAim = (flags >> 6) & 1; - ms_apWeaponInfos[weaponType].m_bCanAimWithArm = (flags >> 7) & 1; - ms_apWeaponInfos[weaponType].m_b1stPerson = (flags >> 8) & 1; - ms_apWeaponInfos[weaponType].m_bHeavy = (flags >> 9) & 1; - ms_apWeaponInfos[weaponType].m_bThrow = (flags >> 10) & 1; - ms_apWeaponInfos[weaponType].m_bReloadLoop2Start = (flags >> 11) & 1; - ms_apWeaponInfos[weaponType].m_bUse2nd = (flags >> 12) & 1; - ms_apWeaponInfos[weaponType].m_bGround2nd = (flags >> 13) & 1; - ms_apWeaponInfos[weaponType].m_bFinish3rd = (flags >> 14) & 1; - ms_apWeaponInfos[weaponType].m_bReload = (flags >> 15) & 1; - ms_apWeaponInfos[weaponType].m_bFightMode = (flags >> 16) & 1; - ms_apWeaponInfos[weaponType].m_bCrouchFire = (flags >> 17) & 1; - ms_apWeaponInfos[weaponType].m_bCop3rd = (flags >> 18) & 1; - ms_apWeaponInfos[weaponType].m_bGround3rd = (flags >> 19) & 1; - ms_apWeaponInfos[weaponType].m_bPartialAttack = (flags >> 20) & 1; - ms_apWeaponInfos[weaponType].m_bAnimDetonate = (flags >> 21) & 1; - + ms_apWeaponInfos[weaponType].m_Flags = flags; ms_apWeaponInfos[weaponType].m_nWeaponSlot = weaponSlot; if (animLoopEnd < 98.0f && weaponType != WEAPONTYPE_FLAMETHROWER && !CWeapon::IsShotgun(weaponType)) diff --git a/src/weapons/WeaponInfo.h b/src/weapons/WeaponInfo.h index 6e09e9f2..0f53dded 100644 --- a/src/weapons/WeaponInfo.h +++ b/src/weapons/WeaponInfo.h @@ -4,7 +4,31 @@ #include "AnimationId.h" #include "WeaponType.h" -enum AssocGroupId; +enum +{ + WEAPONFLAG_USE_GRAVITY = 1, + WEAPONFLAG_SLOWS_DOWN = 1 << 1, + WEAPONFLAG_DISSIPATES = 1 << 2, + WEAPONFLAG_RAND_SPEED = 1 << 3, + WEAPONFLAG_EXPANDS = 1 << 4, + WEAPONFLAG_EXPLODES = 1 << 5, + WEAPONFLAG_CANAIM = 1 << 6, + WEAPONFLAG_CANAIM_WITHARM = 1 << 7, + WEAPONFLAG_1ST_PERSON = 1 << 8, + WEAPONFLAG_HEAVY = 1 << 9, + WEAPONFLAG_THROW = 1 << 10, + WEAPONFLAG_RELOAD_LOOP2START = 1 << 11, + WEAPONFLAG_USE_2ND = 1 << 12, + WEAPONFLAG_GROUND_2ND = 1 << 13, + WEAPONFLAG_FINISH_3RD = 1 << 14, + WEAPONFLAG_RELOAD = 1 << 15, + WEAPONFLAG_FIGHTMODE = 1 << 16, + WEAPONFLAG_CROUCHFIRE = 1 << 17, + WEAPONFLAG_COP3_RD = 1 << 18, + WEAPONFLAG_GROUND_3RD = 1 << 19, + WEAPONFLAG_PARTIALATTACK = 1 << 20, + WEAPONFLAG_ANIMDETONATE = 1 << 21, +}; class CWeaponInfo { static CWeaponInfo ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS]; @@ -34,31 +58,7 @@ public: float m_fAnimBreakout; int32 m_nModelId; int32 m_nModel2Id; - // flags - uint8 m_bUseGravity : 1; - uint8 m_bSlowsDown : 1; - uint8 m_bDissipates : 1; - uint8 m_bRandSpeed : 1; - uint8 m_bExpands : 1; - uint8 m_bExplodes : 1; - uint8 m_bCanAim : 1; - uint8 m_bCanAimWithArm : 1; - - uint8 m_b1stPerson : 1; - uint8 m_bHeavy : 1; - uint8 m_bThrow : 1; - uint8 m_bReloadLoop2Start : 1; - uint8 m_bUse2nd : 1; - uint8 m_bGround2nd : 1; - uint8 m_bFinish3rd : 1; - uint8 m_bReload : 1; - - uint8 m_bFightMode : 1; - uint8 m_bCrouchFire : 1; - uint8 m_bCop3rd : 1; - uint8 m_bGround3rd : 1; - uint8 m_bPartialAttack : 1; - uint8 m_bAnimDetonate : 1; + uint32 m_Flags; uint32 m_nWeaponSlot; @@ -69,6 +69,7 @@ public: static eWeaponType FindWeaponType(char *name); static void Shutdown(void); static bool IsWeaponSlotAmmoMergeable(uint32 slot) { return slot == WEAPONSLOT_SHOTGUN || slot == WEAPONSLOT_SUBMACHINEGUN || slot == WEAPONSLOT_RIFLE; } + bool IsFlagSet(uint32 flag) const { return (m_Flags & flag) != 0; } }; VALIDATE_SIZE(CWeaponInfo, 0x64); |