1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-28 18:35:29 +00:00

Cleanup and one needed function

This commit is contained in:
eray orçunus 2020-05-23 18:04:33 +03:00
parent 5357957fe1
commit c3b41d79a2
4 changed files with 32 additions and 44 deletions

View file

@ -386,6 +386,8 @@ CPed::~CPed(void)
} }
if (m_pFire) if (m_pFire)
m_pFire->Extinguish(); m_pFire->Extinguish();
ClearWeapons();
if (bCarPassenger) if (bCarPassenger)
CPopulation::ms_nTotalCarPassengerPeds--; CPopulation::ms_nTotalCarPassengerPeds--;
if (bMiamiViceCop) if (bMiamiViceCop)
@ -409,10 +411,11 @@ CPed::FlagToDestroyWhenNextProcessed(void)
} }
bInVehicle = false; bInVehicle = false;
m_pMyVehicle = nil; m_pMyVehicle = nil;
if (CharCreatedBy == MISSION_CHAR) if (CharCreatedBy == MISSION_CHAR)
m_nPedState = PED_DEAD; SetPedState(PED_DEAD);
else else
m_nPedState = PED_NONE; SetPedState(PED_NONE);
m_pVehicleAnim = nil; m_pVehicleAnim = nil;
} }
@ -1884,10 +1887,7 @@ CPed::ClearPointGunAt(void)
ClearAimFlag(); ClearAimFlag();
bIsPointingGunAt = false; bIsPointingGunAt = false;
if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) { if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) {
SetPedState(PED_IDLE);
if (m_nPedState == PED_FOLLOW_PATH)
ClearFollowPath();
m_nPedState = PED_IDLE;
RestorePreviousState(); RestorePreviousState();
} }
weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
@ -4650,10 +4650,7 @@ CPed::SetGetUp(void)
} }
if (m_nPedState != PED_GETUP) { if (m_nPedState != PED_GETUP) {
SetStoredState(); SetStoredState();
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_GETUP);
ClearFollowPath();
m_nPedState = PED_GETUP;
} }
CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity; CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity;
@ -4970,10 +4967,7 @@ CPed::SetPointGunAt(CEntity *to)
if (m_nPedState != PED_ATTACK) if (m_nPedState != PED_ATTACK)
SetStoredState(); SetStoredState();
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_AIM_GUN);
ClearFollowPath();
m_nPedState = PED_AIM_GUN;
bIsPointingGunAt = true; bIsPointingGunAt = true;
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
@ -5267,10 +5261,7 @@ CPed::SetAttack(CEntity *victim)
&& !(m_pedStats->m_flags & STAT_SHOPPING_BAGS) && curWeapon->m_bPartialAttack)) { && !(m_pedStats->m_flags & STAT_SHOPPING_BAGS) && curWeapon->m_bPartialAttack)) {
if (m_nPedState != PED_ATTACK) { if (m_nPedState != PED_ATTACK) {
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_ATTACK);
ClearFollowPath();
m_nPedState = PED_ATTACK;
bIsAttacking = false; bIsAttacking = false;
CAnimBlendAssociation *animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f); CAnimBlendAssociation *animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f);
@ -5291,10 +5282,7 @@ CPed::SetAttack(CEntity *victim)
m_nMoveState == PEDMOVE_WALK || m_nMoveState == PEDMOVE_RUN)) { m_nMoveState == PEDMOVE_WALK || m_nMoveState == PEDMOVE_RUN)) {
if (m_nPedState != PED_ATTACK) { if (m_nPedState != PED_ATTACK) {
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_ATTACK);
ClearFollowPath();
m_nPedState = PED_ATTACK;
bIsAttacking = false; bIsAttacking = false;
CAnimBlendAssociation* animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f); CAnimBlendAssociation* animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f);
animAssoc->SetRun(); animAssoc->SetRun();
@ -5371,10 +5359,7 @@ CPed::SetAttack(CEntity *victim)
if (m_nPedState != PED_AIM_GUN) if (m_nPedState != PED_AIM_GUN)
SetStoredState(); SetStoredState();
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_ATTACK);
ClearFollowPath();
m_nPedState = PED_ATTACK;
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
if (bCrouchWhenShooting && bIsDucking && !!curWeapon->m_bCrouchFire) { if (bCrouchWhenShooting && bIsDucking && !!curWeapon->m_bCrouchFire) {
CAnimBlendAssociation* curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(curWeapon)); CAnimBlendAssociation* curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(curWeapon));
@ -6657,10 +6642,7 @@ CPed::SetDead(void)
if (m_nPedState == PED_DRIVING) if (m_nPedState == PED_DRIVING)
bIsVisible = false; bIsVisible = false;
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_DEAD);
ClearFollowPath();
m_nPedState = PED_DEAD;
m_pVehicleAnim = nil; m_pVehicleAnim = nil;
m_pCollidingEntity = nil; m_pCollidingEntity = nil;

View file

@ -47,19 +47,12 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_nSpeedTimer = 0; m_nSpeedTimer = 0;
m_bSpeedTimerFlag = false; m_bSpeedTimerFlag = false;
// This should be something inlined
// TODO(Miami) // TODO(Miami)
// if (pPointGunAt) // if (pPointGunAt)
// m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt); // m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = nil; m_pPointGunAt = nil;
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_IDLE);
ClearFollowPath();
// TODO(Miami)
// This should be something inlined
m_nPedState = PED_IDLE;
m_fMaxStamina = 150.0f; m_fMaxStamina = 150.0f;
m_fCurrentStamina = m_fMaxStamina; m_fCurrentStamina = m_fMaxStamina;
m_fStaminaProgress = 0.0f; m_fStaminaProgress = 0.0f;
@ -290,10 +283,7 @@ CPlayerPed::SetInitialState(void)
m_pFire->Extinguish(); m_pFire->Extinguish();
RpAnimBlendClumpRemoveAllAssociations(GetClump()); RpAnimBlendClumpRemoveAllAssociations(GetClump());
if (m_nPedState == PED_FOLLOW_PATH) SetPedState(PED_IDLE);
ClearFollowPath();
m_nPedState = PED_IDLE;
SetMoveState(PEDMOVE_STILL); SetMoveState(PEDMOVE_STILL);
m_nLastPedState = PED_NONE; m_nLastPedState = PED_NONE;
m_animGroup = ASSOCGRP_PLAYER; m_animGroup = ASSOCGRP_PLAYER;
@ -1626,6 +1616,21 @@ CPlayerPed::ProcessControl(void)
#endif #endif
} }
bool
CPlayerPed::DoesPlayerWantNewWeapon(eWeaponType weapon, bool onlyIfSlotIsEmpty)
{
uint32 slot = CWeaponInfo::GetWeaponInfo(weapon)->m_nWeaponSlot;
if (!HasWeaponSlot(slot) || GetWeapon(slot).m_eWeaponType == weapon)
return true;
if (onlyIfSlotIsEmpty)
return false;
// Check if he's using that slot right now.
return m_nPedState != PED_ATTACK && m_nPedState != PED_AIM_GUN || slot != m_currentWeapon;
}
#ifdef COMPATIBLE_SAVES #ifdef COMPATIBLE_SAVES
#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipSaveBuf(buf, sizeof(data)); #define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipSaveBuf(buf, sizeof(data));
#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipSaveBuf(buf, sizeof(data)); #define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipSaveBuf(buf, sizeof(data));

View file

@ -82,6 +82,7 @@ public:
void ProcessAnimGroups(void); void ProcessAnimGroups(void);
void ProcessPlayerWeapon(CPad*); void ProcessPlayerWeapon(CPad*);
void PlayerControlZelda(CPad*); void PlayerControlZelda(CPad*);
bool DoesPlayerWantNewWeapon(eWeaponType, bool);
static void SetupPlayerPed(int32); static void SetupPlayerPed(int32);
static void DeactivatePlayerPed(int32); static void DeactivatePlayerPed(int32);

View file

@ -1597,7 +1597,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
if ( CGame::nastyGame ) if ( CGame::nastyGame )
{ {
uint8 bloodAmount = 8; uint8 bloodAmount = 8;
if ( m_eWeaponType == WEAPONTYPE_SHOTGUN || m_eWeaponType == WEAPONTYPE_SPAS12_SHOTGUN || m_eWeaponType == WEAPONTYPE_STUBBY_SHOTGUN) if ( IsShotgun(m_eWeaponType) )
bloodAmount = 32; bloodAmount = 32;
CVector dir = (point.point - victim->GetPosition()) * 0.01f; CVector dir = (point.point - victim->GetPosition()) * 0.01f;