1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-06-18 11:23:13 +00:00

Weapon flags changed from bit fields to bit mask (R* vision)

This commit is contained in:
Sergeanur 2020-12-26 14:22:02 +02:00
parent 688e277e89
commit c9c447e7a9
8 changed files with 116 additions and 133 deletions

View file

@ -1183,7 +1183,7 @@ CPed::SetAimFlag(float angle)
if (bIsDucking)
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm)
if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM;
else
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
@ -1273,7 +1273,7 @@ CPed::RestoreGunPosition(void)
bool
CPed::CanWeRunAndFireWithWeapon(void)
{
return CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm;
return CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM);
}
// --MIAMI: Done
@ -5597,7 +5597,7 @@ CPed::SetSeek(CVector pos, float distanceToCountDone)
|| (m_nPedState == PED_SEEK_POS && m_vecSeekPos.x == pos.x && m_vecSeekPos.y == pos.y) || m_nPedState == PED_FOLLOW_PATH)
return;
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm) {
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) {
ClearPointGunAt();
}

View file

@ -1002,23 +1002,23 @@ public:
// My names. Inlined in VC
AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) {
if (m_nPedType == PEDTYPE_COP && !!weapon->m_bCop3rd)
if (m_nPedType == PEDTYPE_COP && weapon->IsFlagSet(WEAPONFLAG_COP3_RD))
return ANIM_WEAPON_FIRE_3RD;
else
return GetPrimaryFireAnim(weapon);
}
static AnimationId Get3rdFireAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bCop3rd)
if (weapon->IsFlagSet(WEAPONFLAG_COP3_RD))
return ANIM_WEAPON_FIRE_3RD;
else
return (AnimationId)0;
}
static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) {
if (!!weapon->m_bGround2nd)
if (weapon->IsFlagSet(WEAPONFLAG_GROUND_2ND))
return ANIM_WEAPON_CROUCHFIRE;
else if (!!weapon->m_bGround3rd)
else if (weapon->IsFlagSet(WEAPONFLAG_GROUND_3RD))
return ANIM_WEAPON_FIRE_3RD;
else if (kickFloorIfNone)
return ANIM_KICK_FLOOR;
@ -1027,60 +1027,68 @@ public:
}
static AnimationId GetPrimaryFireAnim(CWeaponInfo* weapon) {
if (weapon->m_bAnimDetonate)
if (weapon->IsFlagSet(WEAPONFLAG_ANIMDETONATE))
return ANIM_BOMBER;
else
return ANIM_WEAPON_FIRE;
}
static AnimationId GetCrouchReloadAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bReload)
if (weapon->IsFlagSet(WEAPONFLAG_RELOAD))
return ANIM_WEAPON_CROUCHRELOAD;
else
return (AnimationId)0;
}
static AnimationId GetCrouchFireAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bCrouchFire)
if (weapon->IsFlagSet(WEAPONFLAG_CROUCHFIRE))
return ANIM_WEAPON_CROUCHFIRE;
else
return (AnimationId)0;
}
static AnimationId GetReloadAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bReload)
if (weapon->IsFlagSet(WEAPONFLAG_RELOAD))
return ANIM_WEAPON_RELOAD;
else
return (AnimationId)0;
}
static AnimationId GetFightIdleWithMeleeAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bFightMode)
if (weapon->IsFlagSet(WEAPONFLAG_FIGHTMODE))
return ANIM_MELEE_IDLE_FIGHTMODE;
else
return (AnimationId)0;
}
static AnimationId GetFinishingAttackAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bFinish3rd)
if (weapon->IsFlagSet(WEAPONFLAG_FINISH_3RD))
return ANIM_MELEE_ATTACK_FINISH;
else
return (AnimationId)0;
}
static AnimationId GetSecondFireAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bUse2nd)
if (weapon->IsFlagSet(WEAPONFLAG_USE_2ND))
return ANIM_WEAPON_FIRE_2ND; // or ANIM_MELEE_ATTACK_2ND
else
return (AnimationId)0;
}
static AnimationId GetMeleeStartAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bPartialAttack)
if (weapon->IsFlagSet(WEAPONFLAG_PARTIALATTACK))
return ANIM_MELEE_ATTACK_START;
else
return (AnimationId)0;
}
static AnimationId GetThrowAnim(CWeaponInfo *weapon)
{
if (weapon->IsFlagSet(WEAPONFLAG_THROW))
return ANIM_THROWABLE_START_THROW;
else
return (AnimationId)0;
}
// --
// My additions, because there were many, many instances of that.

View file

@ -210,7 +210,7 @@ CPed::PointGunAt(void)
float animLoopStart = weaponInfo->m_fAnimLoopStart;
CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE);
if (!weaponAssoc || weaponAssoc->blendDelta < 0.0f) {
if (!!weaponInfo->m_bCrouchFire) {
if (weaponInfo->IsFlagSet(WEAPONFLAG_CROUCHFIRE)) {
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weaponInfo));
animLoopStart = weaponInfo->m_fAnim2LoopStart;
}
@ -223,7 +223,7 @@ CPed::PointGunAt(void)
if (bIsDucking)
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
if (weaponInfo->m_bCanAimWithArm)
if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM;
else
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
@ -247,7 +247,7 @@ CPed::ClearPointGunAt(void)
weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE);
if (!animAssoc || animAssoc->blendDelta < 0.0f) {
if (!!weaponInfo->m_bCrouchFire) {
if (weaponInfo->IsFlagSet(WEAPONFLAG_CROUCHFIRE)) {
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weaponInfo));
}
}
@ -271,7 +271,7 @@ CPed::SetAttack(CEntity *victim)
if (m_attackTimer > CTimer::GetTimeInMilliseconds() || m_nWaitState == WAITSTATE_SURPRISE || (bIsDucking && !bCrouchWhenShooting))
return;
if (curWeapon->m_bReload &&
if (curWeapon->IsFlagSet(WEAPONFLAG_RELOAD) &&
(RpAnimBlendClumpGetAssociation(GetClump(), GetReloadAnim(curWeapon)) || RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(curWeapon)))) {
if (!IsPlayer() || m_nPedState != PED_ATTACK || ((CPlayerPed*)this)->m_bHaveTargetSelected)
bIsAttacking = false;
@ -281,10 +281,10 @@ CPed::SetAttack(CEntity *victim)
return;
}
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED || curWeapon->m_bFightMode || GetWeapon()->m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE) {
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED || curWeapon->IsFlagSet(WEAPONFLAG_FIGHTMODE) || GetWeapon()->m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE) {
if (IsPlayer() ||
(m_nPedState != PED_FIGHT && m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL
&& !(m_pedStats->m_flags & STAT_SHOPPING_BAGS) && curWeapon->m_bPartialAttack)) {
&& !(m_pedStats->m_flags & STAT_SHOPPING_BAGS) && curWeapon->IsFlagSet(WEAPONFLAG_PARTIALATTACK))) {
if (m_nPedState != PED_ATTACK) {
SetPedState(PED_ATTACK);
@ -303,7 +303,7 @@ CPed::SetAttack(CEntity *victim)
return;
}
if (curWeapon->m_bPartialAttack &&
if (curWeapon->IsFlagSet(WEAPONFLAG_PARTIALATTACK) &&
(IsPlayer() && ((CPlayerPed*)this)->m_fMoveSpeed >= 1.0f ||
m_nMoveState == PEDMOVE_WALK || m_nMoveState == PEDMOVE_RUN)) {
@ -326,7 +326,7 @@ CPed::SetAttack(CEntity *victim)
if (m_pSeekTarget)
m_pSeekTarget->RegisterReference((CEntity **) &m_pSeekTarget);
if (curWeapon->m_bCanAim) {
if (curWeapon->IsFlagSet(WEAPONFLAG_CANAIM)) {
CVector aimPos = GetRight() * 0.1f + GetForward() * 0.2f + GetPosition();
aimPos += GetUp() * 0.35f;
CEntity *obstacle = CWorld::TestSphereAgainstWorld(aimPos, 0.2f, nil, true, false, false, true, false, false);
@ -354,7 +354,7 @@ CPed::SetAttack(CEntity *victim)
} else if (this == FindPlayerPed() && TheCamera.Cams[0].Using3rdPersonMouseCam()) {
SetAimFlag(m_fRotationCur);
((CPlayerPed*)this)->m_fFPSMoveHeading = TheCamera.Find3rdPersonQuickAimPitch();
} else if (curWeapon->m_bCanAimWithArm) {
} else if (curWeapon->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM)) {
SetAimFlag(m_fRotationCur);
}
}
@ -380,7 +380,7 @@ CPed::SetAttack(CEntity *victim)
if (pointBlankStatus == POINT_BLANK_FOR_WANTED_PED || !victimPed && (IsPlayer() || !m_carInObjective))
StartFightAttack(200);
} else {
if (!curWeapon->m_bCanAim)
if (!curWeapon->IsFlagSet(WEAPONFLAG_CANAIM))
m_pSeekTarget = nil;
if (m_nPedState != PED_AIM_GUN)
@ -388,7 +388,7 @@ CPed::SetAttack(CEntity *victim)
SetPedState(PED_ATTACK);
SetMoveState(PEDMOVE_NONE);
if (bCrouchWhenShooting && bIsDucking && !!curWeapon->m_bCrouchFire) {
if (bCrouchWhenShooting && bIsDucking && curWeapon->IsFlagSet(WEAPONFLAG_CROUCHFIRE)) {
CAnimBlendAssociation* curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(curWeapon));
if (curMoveAssoc) {
if (strcmp(CAnimManager::GetAnimAssociation(curWeapon->m_AnimToPlay, GetCrouchFireAnim(curWeapon))->hierarchy->name, curMoveAssoc->hierarchy->name) != 0) {
@ -402,9 +402,9 @@ CPed::SetAttack(CEntity *victim)
animDelta = 1000.0f;
AnimationId fireAnim;
if (curWeapon->m_bThrow)
if (curWeapon->IsFlagSet(WEAPONFLAG_THROW))
fireAnim = ANIM_THROWABLE_START_THROW;
else if (CGame::nastyGame && (curWeapon->m_bGround2nd || curWeapon->m_bGround3rd)) {
else if (CGame::nastyGame && (curWeapon->IsFlagSet(WEAPONFLAG_GROUND_2ND) || curWeapon->IsFlagSet(WEAPONFLAG_GROUND_3RD))) {
PedOnGroundState pedOnGround = CheckForPedsOnGroundToAttack(this, nil);
if (pedOnGround > PED_IN_FRONT_OF_ATTACKER || pedOnGround == NO_PED && bIsStanding && m_pCurSurface && m_pCurSurface->IsVehicle()) {
fireAnim = GetFireAnimGround(curWeapon, false);
@ -589,17 +589,17 @@ CPed::FinishedReloadCB(CAnimBlendAssociation *reloadAssoc, void *arg)
if (ped->bIsDucking && ped->bCrouchWhenShooting) {
CAnimBlendAssociation *crouchFireAssoc = nil;
if (!!weapon->m_bCrouchFire) {
if (weapon->IsFlagSet(WEAPONFLAG_CROUCHFIRE)) {
crouchFireAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchFireAnim(weapon));
}
if (!!weapon->m_bReload && reloadAssoc) {
if (weapon->IsFlagSet(WEAPONFLAG_RELOAD) && reloadAssoc) {
if (reloadAssoc->animId == GetCrouchReloadAnim(weapon) && !crouchFireAssoc) {
CAnimBlendAssociation *crouchAssoc = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f);
crouchAssoc->SetCurrentTime(crouchAssoc->hierarchy->totalLength);
crouchAssoc->flags &= ~ASSOC_RUNNING;
}
}
} else if (weapon->m_bReloadLoop2Start && ped->bIsAttacking) {
} else if (weapon->IsFlagSet(WEAPONFLAG_RELOAD_LOOP2START) && ped->bIsAttacking) {
CAnimBlendAssociation *fireAssoc =
CAnimManager::BlendAnimation(ped->GetClump(), weapon->m_AnimToPlay, GetPrimaryFireAnim(weapon), 8.0f);
fireAssoc->SetFinishCallback(FinishedAttackCB, ped);
@ -677,7 +677,7 @@ CPed::Attack(void)
ourWeapon = CWeaponInfo::GetWeaponInfo(ourWeaponType);
ourWeaponFire = ourWeapon->m_eWeaponFire;
weaponAnimAssoc = nil;
attackShouldContinue = bIsAttacking;
attackShouldContinue = !!bIsAttacking;
reloadAnimAssoc = nil;
throwAssoc = nil;
animLoopStart = ourWeapon->m_fAnimLoopStart;
@ -686,7 +686,7 @@ CPed::Attack(void)
weaponAnim = ourWeapon->m_AnimToPlay;
if (bIsDucking) {
if (!!ourWeapon->m_bCrouchFire && bCrouchWhenShooting) {
if(GetCrouchFireAnim(ourWeapon) && bCrouchWhenShooting) {
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(ourWeapon));
if (weaponAnimAssoc) {
animLoopStart = ourWeapon->m_fAnim2LoopStart;
@ -704,11 +704,11 @@ CPed::Attack(void)
}
}
if (ourWeapon->m_bReload) {
if (GetReloadAnim(ourWeapon)) {
reloadAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetReloadAnim(ourWeapon));
}
if (!!ourWeapon->m_bReload && !reloadAnimAssoc) {
if (GetCrouchReloadAnim(ourWeapon) && !reloadAnimAssoc) {
reloadAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(ourWeapon));
}
@ -724,8 +724,8 @@ CPed::Attack(void)
reloadAnimAssoc->blendDelta = -8.0f;
}
if (!!ourWeapon->m_bThrow) {
throwAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_THROWABLE_START_THROW);
if (GetThrowAnim(ourWeapon)) {
throwAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetThrowAnim(ourWeapon));
}
if ( CTimer::GetTimeInMilliseconds() < m_shootTimer )
@ -733,8 +733,8 @@ CPed::Attack(void)
bool meleeAttackStarted = false;
if ( !weaponAnimAssoc ) {
if (!!ourWeapon->m_bPartialAttack) {
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_MELEE_ATTACK_START);
if (GetMeleeStartAnim(ourWeapon)) {
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetMeleeStartAnim(ourWeapon));
if ( weaponAnimAssoc ) {
if ( IsPlayer() )
meleeAttackStarted = true;
@ -757,7 +757,7 @@ CPed::Attack(void)
}
}
if (!weaponAnimAssoc) {
if (!!ourWeapon->m_bUse2nd) {
if (GetSecondFireAnim(ourWeapon)) {
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetSecondFireAnim(ourWeapon));
if (weaponAnimAssoc) {
animLoopStart = ourWeapon->m_fAnim2LoopStart;
@ -779,14 +779,15 @@ CPed::Attack(void)
if (!throwAssoc) {
if (attackShouldContinue) {
if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) {
if (bCrouchWhenShooting && bIsDucking && !!ourWeapon->m_bCrouchFire) {
if (bCrouchWhenShooting && bIsDucking && GetCrouchFireAnim(ourWeapon)) {
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetCrouchFireAnim(ourWeapon), 8.0f);
} else if(GetSecondFireAnim(ourWeapon) && CGeneral::GetRandomNumber() & 1){
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetSecondFireAnim(ourWeapon), 8.0f);
} else if (!CGame::nastyGame || (!ourWeapon->m_bGround2nd && !ourWeapon->m_bGround3rd) ||
ourWeaponFire != WEAPON_FIRE_MELEE || CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
} else if(!CGame::nastyGame || ourWeaponFire != WEAPON_FIRE_MELEE ||
GetFireAnimGround(ourWeapon) ||
CheckForPedsOnGroundToAttack(this, nil) < PED_ON_THE_FLOOR) {
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetFireAnimNotDucking(ourWeapon), 8.0f);
@ -824,7 +825,7 @@ CPed::Attack(void)
float animStart = animLoopStart * 0.4f;
weaponAnimTime = weaponAnimAssoc->currentTime;
if (weaponAnimTime > animStart && weaponAnimTime - weaponAnimAssoc->timeStep <= animStart) {
if (!bIsDucking && !(m_nPedType == PEDTYPE_COP && ourWeapon->m_bCop3rd && weaponAnimAssoc->animId == ANIM_WEAPON_FIRE_3RD) && ourWeapon->m_bCanAimWithArm)
if (!bIsDucking && !GetFireAnimNotDucking(ourWeapon) && ourWeapon->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
m_pedIK.m_flags |= CPedIK::AIMS_WITH_ARM;
else
m_pedIK.m_flags &= ~CPedIK::AIMS_WITH_ARM;
@ -860,7 +861,7 @@ CPed::Attack(void)
if (ourWeaponType == WEAPONTYPE_MOLOTOV || ourWeaponType == WEAPONTYPE_GRENADE || ourWeaponType == WEAPONTYPE_DETONATOR_GRENADE ||
ourWeaponType == WEAPONTYPE_TEARGAS) {
RemoveWeaponModel(ourWeapon->m_nModelId);
RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nModelId);
}
if (!GetWeapon()->m_nAmmoTotal && ourWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
SelectGunIfArmed();
@ -921,9 +922,9 @@ CPed::Attack(void)
if (ourWeapon->m_eWeaponFire == WEAPON_FIRE_INSTANT_HIT && ourWeapon->m_AnimToPlay == ASSOCGRP_SHOTGUN) {
weaponAnimTime = weaponAnimAssoc->currentTime;
firePos = ourWeapon->m_vecFireOffset;
if (weaponAnimTime > 1.0f && weaponAnimTime - weaponAnimAssoc->timeStep <= 1.0f && weaponAnimAssoc->IsRunning()) {
firePos = ourWeapon->m_vecFireOffset;
TransformToNode(firePos, PED_HANDR);
CVector gunshellPos(
@ -971,7 +972,7 @@ CPed::Attack(void)
// Anim loop end, either start the loop again or finish the attack
if (weaponAnimTime > animLoopEnd || !weaponAnimAssoc->IsRunning() && ourWeaponFire != WEAPON_FIRE_PROJECTILE) {
if (GetWeapon()->m_eWeaponState == WEAPONSTATE_RELOADING) {
if (ourWeapon->m_bReload && !reloadAnimAssoc) {
if (ourWeapon->IsFlagSet(WEAPONFLAG_RELOAD) && !reloadAnimAssoc) {
if (!CWorld::Players[CWorld::PlayerInFocus].m_bFastReload) {
CAnimBlendAssociation *newReloadAssoc;
if (bIsDucking) {
@ -1010,14 +1011,14 @@ CPed::Attack(void)
if (weaponAnimAssoc->animId == fireAnim)
weaponAnimAssoc->SetCurrentTime(0.1f);
else {
if (fireAnim) {
if (GetFireAnimGround(ourWeapon, false)) {
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, fireAnim, 8.0f);
} else {
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_KICK_FLOOR, 8.0f);
}
}
weaponAnimAssoc->SetFinishCallback(FinishedAttackCB, this);
} else if (!!ourWeapon->m_bUse2nd) {
} else if (GetSecondFireAnim(ourWeapon)) {
if (weaponAnimAssoc->animId == GetSecondFireAnim(ourWeapon)) {
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, ANIM_WEAPON_FIRE, 8.0f);
} else {
@ -1333,7 +1334,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
m_fightButtonPressure = 0;
} else if (IsPlayer() && GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED && GetWeapon()->m_eWeaponType != WEAPONTYPE_BRASSKNUCKLE &&
!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bFightMode) {
!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_FIGHTMODE)) {
CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f);
moveAssoc->SetCurrentTime(0.0f);
moveAssoc->speed = 1.2f;
@ -1401,7 +1402,7 @@ CPed::Fight(void)
eWeaponType weapon = GetWeapon()->m_eWeaponType;
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(weapon);
if (weaponInfo->m_bFightMode && weapon != WEAPONTYPE_UNARMED) {
if (weaponInfo->IsFlagSet(WEAPONFLAG_FIGHTMODE) && weapon != WEAPONTYPE_UNARMED) {
fightWithWeapon = true;
tFightMoves[FIGHTMOVE_MELEE1].startFireTime = weaponInfo->m_fAnimFrameFire;
tFightMoves[FIGHTMOVE_MELEE1].endFireTime = weaponInfo->m_fAnimLoopEnd;
@ -1650,9 +1651,9 @@ CPed::ChooseAttackAI(uint8 buttonPressure, bool fightWithWeapon)
if (m_pedInObjective->OnGroundOrGettingUp()) {
if (CGame::nastyGame && dist < 1.2f && !m_pedInObjective->IsPlayer()
&& (m_pedInObjective->m_nPedState == PED_DEAD || !m_pedInObjective->IsPedHeadAbovePos(-0.3f))) {
if (weaponInfo->m_bGround2nd)
if (weaponInfo->IsFlagSet(WEAPONFLAG_GROUND_2ND))
return FIGHTMOVE_MELEE2;
if (weaponInfo->m_bGround3rd)
if (weaponInfo->IsFlagSet(WEAPONFLAG_GROUND_3RD))
return FIGHTMOVE_MELEE3;
return FIGHTMOVE_GROUNDKICK;
@ -1880,9 +1881,9 @@ CPed::ChooseAttackPlayer(uint8 buttonPressure, bool fightWithWeapon)
Say(SOUND_PED_ATTACK);
} else if (groundAttackAlivePed || groundAttackDeadPed) {
if (fightWithWeapon && weaponInfo->m_bGround2nd) {
if (fightWithWeapon && weaponInfo->IsFlagSet(WEAPONFLAG_GROUND_2ND)) {
choosenMove = FIGHTMOVE_MELEE2;
} else if (fightWithWeapon && weaponInfo->m_bGround3rd) {
} else if (fightWithWeapon && weaponInfo->IsFlagSet(WEAPONFLAG_GROUND_3RD)) {
choosenMove = FIGHTMOVE_MELEE3;
} else {
choosenMove = FIGHTMOVE_GROUNDKICK;
@ -2166,7 +2167,7 @@ CPed::FightHitPed(CPed *victim, CVector &touchPoint, CVector &dir, int16 piece)
bool fightingWithWeapon = false;
int damageMult = tFightMoves[m_curFightMove].damage * ((CGeneral::GetRandomNumber() & 1) + 2) + 1;
if (weaponInfo->m_bFightMode) {
if (weaponInfo->IsFlagSet(WEAPONFLAG_FIGHTMODE)) {
fightingWithWeapon = true;
if (m_curFightMove >= FIGHTMOVE_MELEE1) {
damageMult = weaponInfo->m_nDamage;

View file

@ -228,7 +228,7 @@ CPlayerPed::MakeChangesForNewWeapon(eWeaponType weapon)
GetWeapon()->m_nAmmoInClip = Min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition);
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAim))
if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM))
ClearWeaponTarget();
// WEAPONTYPE_SNIPERRIFLE? Wut?
@ -855,7 +855,7 @@ CPlayerPed::PlayerControlFighter(CPad *padUsed)
bIsAttacking = false;
}
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy && padUsed->JumpJustDown()) {
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->JumpJustDown()) {
if (m_nEvadeAmount != 0 && m_pEvadingFrom) {
SetEvasiveDive((CPhysical*)m_pEvadingFrom, 1);
m_nEvadeAmount = 0;
@ -900,13 +900,13 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
return;
}
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
SetRealMoveAnim();
if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) &&
if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY)) &&
padUsed->JumpJustDown() && m_nPedState != PED_JUMP) {
ClearAttack();
@ -1034,14 +1034,14 @@ CPlayerPed::CanIKReachThisTarget(CVector target, CWeapon* weapon, bool zRotImpor
float angleToFace = CGeneral::GetRadianAngleBetweenPoints(target.x, target.y, GetPosition().x, GetPosition().y);
float angleDiff = CGeneral::LimitRadianAngle(angleToFace - m_fRotationCur);
return (!zRotImportant || CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_bCanAimWithArm || Abs(angleDiff) <= HALFPI) &&
(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_bCanAimWithArm || Abs(target.z - GetPosition().z) <= (target - GetPosition()).Magnitude2D());
return (!zRotImportant || CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM) || Abs(angleDiff) <= HALFPI) &&
(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM) || Abs(target.z - GetPosition().z) <= (target - GetPosition()).Magnitude2D());
}
void
CPlayerPed::RotatePlayerToTrackTarget(void)
{
if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm)
if (CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))
return;
float angleToFace = CGeneral::GetRadianAngleBetweenPoints(
@ -1250,7 +1250,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
bCrouchWhenShooting = false;
}
if(weaponInfo->m_bCanAim)
if(weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM))
m_wepAccuracy = 95;
else
m_wepAccuracy = 100;
@ -1310,7 +1310,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_bHaveTargetSelected = false;
}
if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED && GetWeapon()->m_eWeaponType != WEAPONTYPE_BRASSKNUCKLE &&
!weaponInfo->m_bFightMode) {
!weaponInfo->IsFlagSet(WEAPONFLAG_FIGHTMODE)) {
if (GetWeapon()->m_eWeaponType != WEAPONTYPE_DETONATOR && GetWeapon()->m_eWeaponType != WEAPONTYPE_DETONATOR_GRENADE ||
padUsed->WeaponJustDown())
@ -1342,7 +1342,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
if (CCamera::m_bUseMouse3rdPerson && CCamera::bFreeCam &&
m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
#define CAN_AIM_WITH_ARM (weaponInfo->m_bCanAimWithArm && !bIsDucking && !bCrouchWhenShooting)
#define CAN_AIM_WITH_ARM (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM) && !bIsDucking && !bCrouchWhenShooting)
// Weapons except throwable and melee ones
if (weaponInfo->m_nWeaponSlot > 2) {
if ((padUsed->GetTarget() && CAN_AIM_WITH_ARM) || padUsed->GetWeapon()) {
@ -1365,7 +1365,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_headingRate = 12.5f;
// Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly)
if (weaponInfo->m_bCanAim && padUsed->WeaponJustDown()) {
if (weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM) && padUsed->WeaponJustDown()) {
m_fRotationCur = CGeneral::LimitRadianAngle(m_fRotationCur);
float limitedRotDest = m_fRotationDest;
@ -1392,7 +1392,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
}
#endif
if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT && !TheCamera.Using1stPersonWeaponMode() && weaponInfo->m_bCanAim) {
if (padUsed->GetTarget() && m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT && !TheCamera.Using1stPersonWeaponMode() && weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM)) {
if (m_pPointGunAt) {
// what??
if (!m_pPointGunAt
@ -1415,7 +1415,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
return;
}
if (CPlayerPed::DoesTargetHaveToBeBroken(m_pPointGunAt->GetPosition(), GetWeapon()) ||
(!bCanPointGunAtTarget && !weaponInfo->m_bCanAimWithArm)) { // this line isn't on Mobile, idk why
(!bCanPointGunAtTarget && !weaponInfo->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM))) { // this line isn't on Mobile, idk why
ClearWeaponTarget();
return;
}
@ -1460,7 +1460,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
bool
CPlayerPed::MovementDisabledBecauseOfTargeting(void)
{
return m_pPointGunAt && !CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm;
return m_pPointGunAt && !CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_CANAIM_WITHARM);
}
// --MIAMI: Done
@ -1521,7 +1521,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
return;
}
if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY) && padUsed->GetSprint()) {
if (!m_pCurrentPhysSurface || (!m_pCurrentPhysSurface->bInfiniteMass || m_pCurrentPhysSurface->m_phy_flagA08))
m_nMoveState = PEDMOVE_SPRINT;
}
@ -1529,7 +1529,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
if (m_nPedState != PED_FIGHT)
SetRealMoveAnim();
if (!bIsInTheAir && !(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
if (!bIsInTheAir && !CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->IsFlagSet(WEAPONFLAG_HEAVY)
&& padUsed->JumpJustDown() && m_nPedState != PED_JUMP) {
ClearAttack();
ClearWeaponTarget();

View file

@ -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;

View file

@ -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);
}

View file

@ -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))

View file

@ -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);