1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 12:40:00 +00:00

Weapon fixes

This commit is contained in:
eray orçunus 2020-05-16 15:07:09 +03:00
parent 793a6a6d7e
commit 40ee29fb99
7 changed files with 59 additions and 31 deletions

View file

@ -679,7 +679,7 @@ CPed::GiveWeapon(eWeaponType weaponType, uint32 ammo, bool unused)
if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) { if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
// Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1. // Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1.
GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], (int32) GetWeapon(slot).m_nAmmoTotal); GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], GetWeapon(slot).m_nAmmoTotal);
} else { } else {
GetWeapon(slot).m_nAmmoTotal = Min(99999, GetWeapon(slot).m_nAmmoTotal); GetWeapon(slot).m_nAmmoTotal = Min(99999, GetWeapon(slot).m_nAmmoTotal);
} }
@ -1187,7 +1187,7 @@ CPed::FinishedReloadCB(CAnimBlendAssociation *reloadAssoc, void *arg)
} }
} else if (weapon->m_bReloadLoop2Start && ped->bIsAttacking) { } else if (weapon->m_bReloadLoop2Start && ped->bIsAttacking) {
CAnimBlendAssociation *fireAssoc = CAnimBlendAssociation *fireAssoc =
CAnimManager::BlendAnimation(ped->GetClump(), weapon->m_AnimToPlay, weapon->m_bAnimDetonate ? ANIM_BOMBER : ANIM_WEAPON_FIRE, 8.0f); CAnimManager::BlendAnimation(ped->GetClump(), weapon->m_AnimToPlay, GetPrimaryFireAnim(weapon), 8.0f);
fireAssoc->SetFinishCallback(FinishedAttackCB, ped); fireAssoc->SetFinishCallback(FinishedAttackCB, ped);
fireAssoc->SetRun(); fireAssoc->SetRun();
if (fireAssoc->currentTime != reloadAssoc->hierarchy->totalLength) { if (fireAssoc->currentTime != reloadAssoc->hierarchy->totalLength) {
@ -1302,6 +1302,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
} }
} }
// --MIAMI: Done
void void
CPed::Attack(void) CPed::Attack(void)
{ {
@ -3874,12 +3875,7 @@ CPed::ClearAttackByRemovingAnim(void)
return; return;
CWeaponInfo *weapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); CWeaponInfo *weapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), weapon->m_bAnimDetonate ? ANIM_BOMBER : ANIM_WEAPON_FIRE); CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetPrimaryFireAnim(weapon));
// TODO(Miami): Remove when fighting got ported
if (!weaponAssoc) {
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_PPUNCH);
}
if (!weaponAssoc) { if (!weaponAssoc) {
if (!!weapon->m_bCrouchFire) if (!!weapon->m_bCrouchFire)
@ -4882,15 +4878,15 @@ CPed::SetAmmo(eWeaponType weaponType, uint32 ammo)
if (slot == -1) if (slot == -1)
return; return;
GetWeapon(slot).m_nAmmoTotal += ammo; GetWeapon(slot).m_nAmmoTotal = ammo;
if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) { if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
// Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1. // Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1.
GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], (int32)GetWeapon(slot).m_nAmmoTotal); GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], GetWeapon(slot).m_nAmmoTotal);
} else { } else {
GetWeapon(slot).m_nAmmoTotal = Min(99999, GetWeapon(slot).m_nAmmoTotal); GetWeapon(slot).m_nAmmoTotal = Min(99999, GetWeapon(slot).m_nAmmoTotal);
} }
uint32 newClip = GetWeapon(slot).m_nAmmoTotal; int32 newClip = GetWeapon(slot).m_nAmmoTotal;
if (newClip >= GetWeapon(slot).m_nAmmoInClip) if (newClip >= GetWeapon(slot).m_nAmmoInClip)
newClip = GetWeapon(slot).m_nAmmoInClip; newClip = GetWeapon(slot).m_nAmmoInClip;
GetWeapon(slot).m_nAmmoInClip = newClip; GetWeapon(slot).m_nAmmoInClip = newClip;
@ -4911,7 +4907,7 @@ CPed::GrantAmmo(eWeaponType weaponType, uint32 ammo)
if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) { if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
// Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1. // Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1.
GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], (int32)GetWeapon(slot).m_nAmmoTotal); GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], GetWeapon(slot).m_nAmmoTotal);
} else { } else {
GetWeapon(slot).m_nAmmoTotal = Min(99999, GetWeapon(slot).m_nAmmoTotal); GetWeapon(slot).m_nAmmoTotal = Min(99999, GetWeapon(slot).m_nAmmoTotal);
} }
@ -6341,7 +6337,7 @@ CPed::CreateDeadPedWeaponPickups(void)
eWeaponType weapon = GetWeapon(i).m_eWeaponType; eWeaponType weapon = GetWeapon(i).m_eWeaponType;
int weaponAmmo = GetWeapon(i).m_nAmmoTotal; int weaponAmmo = GetWeapon(i).m_nAmmoTotal;
if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || weaponAmmo == 0) if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || (weaponAmmo == 0 && !GetWeapon(i).IsTypeMelee()))
continue; continue;
angleToPed = i * 1.75f; angleToPed = i * 1.75f;

View file

@ -704,6 +704,7 @@ public:
void RemoveWeaponAnims(int, float); void RemoveWeaponAnims(int, float);
void CreateDeadPedMoney(void); void CreateDeadPedMoney(void);
void CreateDeadPedWeaponPickups(void); void CreateDeadPedWeaponPickups(void);
// void CreateDeadPedPickupCoors(float *x, float *y, float *z);
void SetAttackTimer(uint32); void SetAttackTimer(uint32);
void SetBeingDraggedFromCar(CVehicle*, uint32, bool); void SetBeingDraggedFromCar(CVehicle*, uint32, bool);
void SetRadioStation(void); void SetRadioStation(void);
@ -899,7 +900,7 @@ public:
if (m_nPedType == PEDTYPE_COP && !!weapon->m_bCop3rd) if (m_nPedType == PEDTYPE_COP && !!weapon->m_bCop3rd)
return ANIM_WEAPON_FIRE_3RD; return ANIM_WEAPON_FIRE_3RD;
else else
return weapon->m_bAnimDetonate ? ANIM_BOMBER : ANIM_WEAPON_FIRE; return GetPrimaryFireAnim(weapon);
} }
static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) { static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) {
@ -916,6 +917,17 @@ public:
else else
return (AnimationId)0; return (AnimationId)0;
} }
static AnimationId GetPrimaryFireAnim(CWeaponInfo* weapon) {
// TODO(Miami): Revert that when weapons got ported
if (weapon->m_AnimToPlay == ASSOCGRP_STD)
return ANIM_FIGHT_PPUNCH;
if (weapon->m_bAnimDetonate)
return ANIM_BOMBER;
else
return ANIM_WEAPON_FIRE;
}
// -- // --
// My additions, because there were many, many instances of that. // My additions, because there were many, many instances of that.

View file

@ -293,9 +293,12 @@ bool
CPedIK::PointGunAtPosition(CVector const& position) CPedIK::PointGunAtPosition(CVector const& position)
{ {
// TODO(MIAMI): special cases for some weapons // TODO(MIAMI): special cases for some weapons
RwV3d armPos;
GetComponentPosition(&armPos, PED_UPPERARMR);
return PointGunInDirection( return PointGunInDirection(
CGeneral::GetRadianAngleBetweenPoints(position.x, position.y, m_ped->GetPosition().x, m_ped->GetPosition().y), CGeneral::GetRadianAngleBetweenPoints(position.x, position.y, m_ped->GetPosition().x, m_ped->GetPosition().y),
CGeneral::GetRadianAngleBetweenPoints(position.z, Distance2D(m_ped->GetPosition(), position.x, position.y), m_ped->GetPosition().z, 0.0f)); CGeneral::GetRadianAngleBetweenPoints(position.z, Distance2D(m_ped->GetPosition(), position.x, position.y), armPos.z, 0.0f));
} }
bool bool

View file

@ -92,6 +92,11 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
void CPlayerPed::ClearWeaponTarget() void CPlayerPed::ClearWeaponTarget()
{ {
if (m_nPedType == PEDTYPE_PLAYER1) { if (m_nPedType == PEDTYPE_PLAYER1) {
// TODO(Miami)
// if (m_pPointGunAt)
// m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = nil; m_pPointGunAt = nil;
TheCamera.ClearPlayerWeaponMode(); TheCamera.ClearPlayerWeaponMode();
CWeaponEffects::ClearCrossHair(); CWeaponEffects::ClearCrossHair();
@ -213,13 +218,15 @@ CPlayerPed::MakeChangesForNewWeapon(eWeaponType weapon)
TheCamera.ClearPlayerWeaponMode(); TheCamera.ClearPlayerWeaponMode();
} }
SetCurrentWeapon(weapon); SetCurrentWeapon(weapon);
m_nSelectedWepSlot = m_currentWeapon;
GetWeapon()->m_nAmmoInClip = Min(GetWeapon()->m_nAmmoTotal, CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nAmountofAmmunition); 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)->m_bCanAim))
ClearWeaponTarget(); ClearWeaponTarget();
CAnimBlendAssociation* weaponAnim = RpAnimBlendClumpGetAssociation(GetClump(), CWeaponInfo::GetWeaponInfo(WEAPONTYPE_SNIPERRIFLE)->m_bAnimDetonate ? 62 : 205); // WEAPONTYPE_SNIPERRIFLE? Wut?
CAnimBlendAssociation* weaponAnim = RpAnimBlendClumpGetAssociation(GetClump(), GetPrimaryFireAnim(CWeaponInfo::GetWeaponInfo(WEAPONTYPE_SNIPERRIFLE)));
if (weaponAnim) { if (weaponAnim) {
weaponAnim->SetRun(); weaponAnim->SetRun();
weaponAnim->flags |= ASSOC_FADEOUTWHENDONE; weaponAnim->flags |= ASSOC_FADEOUTWHENDONE;
@ -666,7 +673,10 @@ CPlayerPed::ProcessWeaponSwitch(CPad *padUsed)
for (m_nSelectedWepSlot = m_currentWeapon - 1; ; --m_nSelectedWepSlot) { for (m_nSelectedWepSlot = m_currentWeapon - 1; ; --m_nSelectedWepSlot) {
if (m_nSelectedWepSlot < 0) if (m_nSelectedWepSlot < 0)
m_nSelectedWepSlot = 9; m_nSelectedWepSlot = TOTAL_WEAPON_SLOTS - 1;
if (m_nSelectedWepSlot == 0)
break;
if (HasWeaponSlot(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) { if (HasWeaponSlot(m_nSelectedWepSlot) && GetWeapon(m_nSelectedWepSlot).HasWeaponAmmoToBeUsed()) {
break; break;
@ -690,11 +700,16 @@ spentAmmoCheck:
else else
m_nSelectedWepSlot = 2; m_nSelectedWepSlot = 2;
// BUG: m_nSelectedWepSlot is slot in VC but they compared against weapon types, lol.
for (; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) { for (; m_nSelectedWepSlot >= 0; --m_nSelectedWepSlot) {
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && GetWeapon(6).m_eWeaponType == WEAPONTYPE_BASEBALLBAT
// BUG: m_nSelectedWepSlot and GetWeapon(..) takes slot in VC but they compared them against weapon types in whole condition! jeez
#ifdef FIX_BUGS
if (m_nSelectedWepSlot == 1 || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 && m_nSelectedWepSlot != 2) {
#else
if (m_nSelectedWepSlot == WEAPONTYPE_BASEBALLBAT && GetWeapon(WEAPONTYPE_BASEBALLBAT).m_eWeaponType == WEAPONTYPE_BASEBALLBAT
|| GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0 || GetWeapon(m_nSelectedWepSlot).m_nAmmoTotal > 0
/*&& m_nSelectedWepSlot != WEAPONTYPE_MOLOTOV && m_nSelectedWepSlot != WEAPONTYPE_GRENADE && m_nSelectedWepSlot != WEAPONTYPE_TEARGAS */) { && m_nSelectedWepSlot != WEAPONTYPE_MOLOTOV && m_nSelectedWepSlot != WEAPONTYPE_GRENADE && m_nSelectedWepSlot != WEAPONTYPE_TEARGAS) {
#endif
goto switchDetectDone; goto switchDetectDone;
} }
} }
@ -1152,7 +1167,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) { m_nSelectedWepSlot == m_currentWeapon && m_nMoveState != PEDMOVE_SPRINT) {
// Weapons except throwable and melee ones // Weapons except throwable and melee ones
if (weaponInfo->m_bCanAim || weaponInfo->m_b1stPerson || weaponInfo->m_bExpands) { if (weaponInfo->m_nWeaponSlot > 2) {
if ((padUsed->GetTarget() && weaponInfo->m_bCanAimWithArm) || padUsed->GetWeapon()) { if ((padUsed->GetTarget() && weaponInfo->m_bCanAimWithArm) || padUsed->GetWeapon()) {
float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation); float limitedCam = CGeneral::LimitRadianAngle(-TheCamera.Orientation);

View file

@ -2312,13 +2312,15 @@ CWeapon::BlowUpExplosiveThings(CEntity *thing)
bool bool
CWeapon::HasWeaponAmmoToBeUsed(void) CWeapon::HasWeaponAmmoToBeUsed(void)
{ {
switch (m_eWeaponType) { // FIX: This is better (not bug tho)
case WEAPONTYPE_UNARMED: #if 0
case WEAPONTYPE_BASEBALLBAT: if (m_eWeaponType <= WEAPONTYPE_CHAINSAW)
#else
if (CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_eWeaponFire == WEAPON_FIRE_MELEE)
#endif
return true; return true;
default: else
return m_nAmmoTotal != 0; return m_nAmmoTotal != 0;
}
} }
bool bool

View file

@ -16,8 +16,8 @@ class CWeapon
public: public:
eWeaponType m_eWeaponType; eWeaponType m_eWeaponType;
eWeaponState m_eWeaponState; eWeaponState m_eWeaponState;
uint32 m_nAmmoInClip; int32 m_nAmmoInClip;
uint32 m_nAmmoTotal; int32 m_nAmmoTotal;
uint32 m_nTimer; uint32 m_nTimer;
bool m_bAddRotOffset; bool m_bAddRotOffset;

View file

@ -14,7 +14,7 @@ public:
float m_fRange; float m_fRange;
uint32 m_nFiringRate; uint32 m_nFiringRate;
uint32 m_nReload; uint32 m_nReload;
uint32 m_nAmountofAmmunition; int32 m_nAmountofAmmunition;
uint32 m_nDamage; uint32 m_nDamage;
float m_fSpeed; float m_fSpeed;
float m_fRadius; float m_fRadius;