summaryrefslogtreecommitdiffstats
path: root/src/peds/Ped.cpp
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-05-23 19:07:30 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-05-23 19:07:30 +0200
commit2966be41ba98906126b68cd780ff81bdf644c72f (patch)
tree04f057aea609a4a36f744aa77324626a592ef010 /src/peds/Ped.cpp
parentset pieces (diff)
parentMerge branch 'miami' of https://github.com/GTAmodding/re3 into miami (diff)
downloadre3-2966be41ba98906126b68cd780ff81bdf644c72f.tar
re3-2966be41ba98906126b68cd780ff81bdf644c72f.tar.gz
re3-2966be41ba98906126b68cd780ff81bdf644c72f.tar.bz2
re3-2966be41ba98906126b68cd780ff81bdf644c72f.tar.lz
re3-2966be41ba98906126b68cd780ff81bdf644c72f.tar.xz
re3-2966be41ba98906126b68cd780ff81bdf644c72f.tar.zst
re3-2966be41ba98906126b68cd780ff81bdf644c72f.zip
Diffstat (limited to 'src/peds/Ped.cpp')
-rw-r--r--src/peds/Ped.cpp100
1 files changed, 39 insertions, 61 deletions
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index 512edf9a..7eb2491b 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -386,6 +386,8 @@ CPed::~CPed(void)
}
if (m_pFire)
m_pFire->Extinguish();
+
+ ClearWeapons();
if (bCarPassenger)
CPopulation::ms_nTotalCarPassengerPeds--;
if (bMiamiViceCop)
@@ -409,10 +411,11 @@ CPed::FlagToDestroyWhenNextProcessed(void)
}
bInVehicle = false;
m_pMyVehicle = nil;
+
if (CharCreatedBy == MISSION_CHAR)
- m_nPedState = PED_DEAD;
+ SetPedState(PED_DEAD);
else
- m_nPedState = PED_NONE;
+ SetPedState(PED_NONE);
m_pVehicleAnim = nil;
}
@@ -686,7 +689,7 @@ CPed::GiveWeapon(eWeaponType weaponType, uint32 ammo, bool unused)
if (m_weapons[slot].m_eWeaponType == weaponType) {
GetWeapon(slot).m_nAmmoTotal += ammo;
- if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
+ if (weaponType < WEAPONTYPE_TOTALWEAPONS && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
// Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1.
GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], GetWeapon(slot).m_nAmmoTotal);
@@ -885,9 +888,8 @@ CPed::AddWeaponModel(int id)
CModelInfo::GetModelInfo(id)->AddRef();
m_wepModelID = id;
- // TODO(Miami)
- // if (IsPlayer() && id == MI_MINIGUN)
- // ((CPlayerPed*)this)->m_pMinigunTopAtomic = (RpAtomic*)CModelInfo::GetModelInfo(MI_MINIGUN2)->CreateInstance();
+ if (IsPlayer() && id == MI_MINIGUN)
+ ((CPlayerPed*)this)->m_pMinigunTopAtomic = (RpAtomic*)CModelInfo::GetModelInfo(MI_MINIGUN2)->CreateInstance();
}
}
@@ -899,7 +901,7 @@ CPed::AimGun(void)
if (m_pSeekTarget) {
if (m_pSeekTarget->IsPed()) {
- ((CPed*)m_pSeekTarget)->m_pedIK.GetComponentPosition(&pos, PED_MID);
+ ((CPed*)m_pSeekTarget)->m_pedIK.GetComponentPosition(pos, PED_MID);
vector = pos;
} else {
vector = m_pSeekTarget->GetPosition();
@@ -1508,9 +1510,8 @@ CPed::Attack(void)
GetWeapon()->Fire(this, &firePos);
- // TODO(Miami): Teargas
- if (ourWeaponType == WEAPONTYPE_MOLOTOV || ourWeaponType == WEAPONTYPE_GRENADE || ourWeaponType == WEAPONTYPE_DETONATOR_GRENADE
- /* ourWeaponType == WEAPONTYPE_TEARGAS*/) {
+ if (ourWeaponType == WEAPONTYPE_MOLOTOV || ourWeaponType == WEAPONTYPE_GRENADE || ourWeaponType == WEAPONTYPE_DETONATOR_GRENADE ||
+ ourWeaponType == WEAPONTYPE_TEARGAS) {
RemoveWeaponModel(ourWeapon->m_nModelId);
}
if (!GetWeapon()->m_nAmmoTotal && ourWeaponFire != WEAPON_FIRE_MELEE && FindPlayerPed() != this) {
@@ -1650,10 +1651,10 @@ CPed::Attack(void)
case WEAPONTYPE_MP5:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
break;
- case WEAPONTYPE_AK47:
+ case WEAPONTYPE_RUGER:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f);
break;
- case WEAPONTYPE_M16:
+ case WEAPONTYPE_M4:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f);
break;
default:
@@ -1668,7 +1669,7 @@ CPed::Attack(void)
if (weaponAnimTime - 2.0f * weaponAnimAssoc->timeStep <= animLoopEnd
&& (bIsAttacking || CTimer::GetTimeInMilliseconds() < m_shootTimer)
&& (GetWeapon()->m_eWeaponState != WEAPONSTATE_RELOADING
- /* || GetWeapon()->m_nWeaponType == WEAPONTYPE_MINIGUN */)) { // TODO(Miami): Minigun
+ || GetWeapon()->m_eWeaponType == WEAPONTYPE_MINIGUN)) {
PedOnGroundState pedOnGroundState;
if (ourWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE &&
@@ -1716,10 +1717,10 @@ CPed::Attack(void)
case WEAPONTYPE_MP5:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f);
break;
- case WEAPONTYPE_AK47:
+ case WEAPONTYPE_RUGER:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f);
break;
- case WEAPONTYPE_M16:
+ case WEAPONTYPE_M4:
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f);
break;
default:
@@ -1765,8 +1766,7 @@ CPed::RemoveWeaponModel(int modelId)
#endif
RwFrameForAllObjects(m_pFrames[PED_HANDR]->frame,RemoveAllModelCB,nil);
- // TODO(Miami): Minigun
- if (IsPlayer() && (modelId == -1 /* || modelId == MI_MINIGUN)*/)) {
+ if (IsPlayer() && (modelId == -1 || modelId == MI_MINIGUN)) {
RpAtomic* &atm = ((CPlayerPed*)this)->m_pMinigunTopAtomic;
if (atm) {
RwFrame *frm = RpAtomicGetFrame(atm);
@@ -1819,7 +1819,7 @@ CPed::SelectGunIfArmed(void)
// First condition checks for Pistol, Python and Shotguns
if ((weaponType >= WEAPONTYPE_COLT45 && weaponType < WEAPONTYPE_TEC9) ||
- weaponType == WEAPONTYPE_UZI || weaponType == WEAPONTYPE_M16 || weaponType == WEAPONTYPE_MP5 ||
+ weaponType == WEAPONTYPE_UZI || weaponType == WEAPONTYPE_M4 || weaponType == WEAPONTYPE_MP5 ||
weaponType == WEAPONTYPE_ROCKETLAUNCHER || weaponType == WEAPONTYPE_FLAMETHROWER || weaponType == WEAPONTYPE_SNIPERRIFLE) {
SetCurrentWeapon(i);
return true;
@@ -1888,10 +1888,7 @@ CPed::ClearPointGunAt(void)
ClearAimFlag();
bIsPointingGunAt = false;
if (m_nPedState == PED_AIM_GUN || m_nPedState == PED_ATTACK) {
-
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
- m_nPedState = PED_IDLE;
+ SetPedState(PED_IDLE);
RestorePreviousState();
}
weaponInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
@@ -4279,16 +4276,19 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
break;
case WEAPONTYPE_COLT45:
case WEAPONTYPE_SHOTGUN:
- // TODO(Miami): Shotguns
+ case WEAPONTYPE_STUBBY_SHOTGUN:
+ case WEAPONTYPE_SPAS12_SHOTGUN:
case WEAPONTYPE_TEC9:
case WEAPONTYPE_UZI:
case WEAPONTYPE_SILENCED_INGRAM:
case WEAPONTYPE_MP5:
- case WEAPONTYPE_M16:
- case WEAPONTYPE_AK47:
+ case WEAPONTYPE_M4:
+ case WEAPONTYPE_RUGER:
case WEAPONTYPE_SNIPERRIFLE:
+ case WEAPONTYPE_LASERSCOPE:
+ case WEAPONTYPE_M60:
+ case WEAPONTYPE_MINIGUN:
case WEAPONTYPE_UZI_DRIVEBY:
- // TODO(Miami): Laserscope, M60, Minigun
if (bBulletProof)
return false;
@@ -4296,8 +4296,8 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
bool dontRemoveLimb;
if (IsPlayer() || bNoCriticalHits)
dontRemoveLimb = true;
- else if (method != WEAPONTYPE_M16 && method != WEAPONTYPE_AK47 && method != WEAPONTYPE_SNIPERRIFLE
- /* method != WEAPONTYPE_LASERSCOPE */) { // TODO(Miami): Laserscope
+ else if (method != WEAPONTYPE_M4 && method != WEAPONTYPE_RUGER && method != WEAPONTYPE_SNIPERRIFLE &&
+ method != WEAPONTYPE_LASERSCOPE) {
if (method == WEAPONTYPE_SHOTGUN)
dontRemoveLimb = CGeneral::GetRandomNumber() & 7;
else
@@ -4651,10 +4651,7 @@ CPed::SetGetUp(void)
}
if (m_nPedState != PED_GETUP) {
SetStoredState();
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
-
- m_nPedState = PED_GETUP;
+ SetPedState(PED_GETUP);
}
CVehicle *collidingVeh = (CVehicle*)m_pCollidingEntity;
@@ -4971,10 +4968,7 @@ CPed::SetPointGunAt(CEntity *to)
if (m_nPedState != PED_ATTACK)
SetStoredState();
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
-
- m_nPedState = PED_AIM_GUN;
+ SetPedState(PED_AIM_GUN);
bIsPointingGunAt = true;
SetMoveState(PEDMOVE_NONE);
@@ -5013,7 +5007,7 @@ CPed::SetAmmo(eWeaponType weaponType, uint32 ammo)
return;
GetWeapon(slot).m_nAmmoTotal = ammo;
- if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
+ if (weaponType < WEAPONTYPE_TOTALWEAPONS && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
// Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1.
GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], GetWeapon(slot).m_nAmmoTotal);
@@ -5038,7 +5032,7 @@ CPed::GrantAmmo(eWeaponType weaponType, uint32 ammo)
return;
GetWeapon(slot).m_nAmmoTotal += ammo;
- if (weaponType < WEAPONTYPE_LAST_WEAPONTYPE && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
+ if (weaponType < WEAPONTYPE_TOTALWEAPONS && weaponType > WEAPONTYPE_UNARMED && CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType] >= 0) {
// Looks like abandoned idea. This block never runs, ms_aMaxAmmoForWeapon is always -1.
GetWeapon(slot).m_nAmmoTotal = Min(CWeaponInfo::ms_aMaxAmmoForWeapon[weaponType], GetWeapon(slot).m_nAmmoTotal);
@@ -5268,10 +5262,7 @@ CPed::SetAttack(CEntity *victim)
&& !(m_pedStats->m_flags & STAT_SHOPPING_BAGS) && curWeapon->m_bPartialAttack)) {
if (m_nPedState != PED_ATTACK) {
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
-
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
bIsAttacking = false;
CAnimBlendAssociation *animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f);
@@ -5292,10 +5283,7 @@ CPed::SetAttack(CEntity *victim)
m_nMoveState == PEDMOVE_WALK || m_nMoveState == PEDMOVE_RUN)) {
if (m_nPedState != PED_ATTACK) {
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
-
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
bIsAttacking = false;
CAnimBlendAssociation* animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f);
animAssoc->SetRun();
@@ -5372,10 +5360,7 @@ CPed::SetAttack(CEntity *victim)
if (m_nPedState != PED_AIM_GUN)
SetStoredState();
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
-
- m_nPedState = PED_ATTACK;
+ SetPedState(PED_ATTACK);
SetMoveState(PEDMOVE_NONE);
if (bCrouchWhenShooting && bIsDucking && !!curWeapon->m_bCrouchFire) {
CAnimBlendAssociation* curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(curWeapon));
@@ -6658,10 +6643,7 @@ CPed::SetDead(void)
if (m_nPedState == PED_DRIVING)
bIsVisible = false;
- if (m_nPedState == PED_FOLLOW_PATH)
- ClearFollowPath();
-
- m_nPedState = PED_DEAD;
+ SetPedState(PED_DEAD);
m_pVehicleAnim = nil;
m_pCollidingEntity = nil;
@@ -6712,11 +6694,7 @@ CPed::SetSeek(CVector pos, float distanceToCountDone)
|| (m_nPedState == PED_SEEK_POS && m_vecSeekPos.x == pos.x && m_vecSeekPos.y == pos.y))
return;
- if (GetWeapon()->m_eWeaponType == WEAPONTYPE_M16
- || GetWeapon()->m_eWeaponType == WEAPONTYPE_AK47
- || GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE
- || GetWeapon()->m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER
- || GetWeapon()->m_eWeaponType == WEAPONTYPE_SHOTGUN) {
+ if (!CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bCanAimWithArm) {
ClearPointGunAt();
}
@@ -9735,7 +9713,7 @@ CPed::MoveHeadToLook(void)
}
if (m_pLookTarget->IsPed()) {
- ((CPed*)m_pLookTarget)->m_pedIK.GetComponentPosition((RwV3d*) &lookPos, PED_MID);
+ ((CPed*)m_pLookTarget)->m_pedIK.GetComponentPosition((RwV3d)lookPos, PED_MID);
} else {
lookPos = m_pLookTarget->GetPosition();
}
@@ -13697,7 +13675,7 @@ CPed::ProcessObjective(void)
CVector target;
CVector ourHead = GetMatrix() * CVector(0.5f, 0.0f, 0.6f);
if (m_pedInObjective->IsPed())
- m_pedInObjective->m_pedIK.GetComponentPosition((RwV3d*)&target, PED_MID);
+ m_pedInObjective->m_pedIK.GetComponentPosition((RwV3d)target, PED_MID);
else
target = m_pedInObjective->GetPosition();