Ped, Weapon and fixes

This commit is contained in:
eray orçunus 2020-06-17 21:24:59 +03:00
parent e9d5d42ea9
commit e44704dc82
8 changed files with 329 additions and 238 deletions

View file

@ -3215,7 +3215,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
} }
break; break;
case SOUND_FIGHT_PUNCH_33: case SOUND_FIGHT_37:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_nFrequency = 18000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3235,7 +3235,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_KICK_34: case SOUND_FIGHT_38:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_nFrequency = 16500;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3255,7 +3255,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_HEADBUTT_35: case SOUND_FIGHT_39:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_1;
m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_nFrequency = 20000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3275,7 +3275,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_PUNCH_36: case SOUND_FIGHT_40:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2;
m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_nFrequency = 18000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3295,7 +3295,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_PUNCH_37: case SOUND_FIGHT_41:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2;
m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_nFrequency = 16500;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3315,7 +3315,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_CLOSE_PUNCH_38: case SOUND_FIGHT_42:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_2;
m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_nFrequency = 20000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3335,7 +3335,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_PUNCH_39: case SOUND_FIGHT_43:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4;
m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_nFrequency = 18000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3355,7 +3355,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40: case SOUND_FIGHT_44:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4;
m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_nFrequency = 16500;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3375,7 +3375,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_PUNCH_41: case SOUND_FIGHT_45:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_4;
m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_nFrequency = 20000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3395,7 +3395,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_PUNCH_FROM_BEHIND_42: case SOUND_FIGHT_46:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5;
m_sQueueSample.m_nFrequency = 18000; m_sQueueSample.m_nFrequency = 18000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3415,7 +3415,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_KNEE_OR_KICK_43: case SOUND_FIGHT_47:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5;
m_sQueueSample.m_nFrequency = 16500; m_sQueueSample.m_nFrequency = 16500;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;
@ -3435,7 +3435,7 @@ cAudioManager::ProcessPedOneShots(cPedParams *params)
m_sQueueSample.m_bReleasingSoundFlag = true; m_sQueueSample.m_bReleasingSoundFlag = true;
m_sQueueSample.m_bRequireReflection = true; m_sQueueSample.m_bRequireReflection = true;
break; break;
case SOUND_FIGHT_KICK_44: case SOUND_FIGHT_48:
m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5; m_sQueueSample.m_nSampleIndex = SFX_FIGHT_5;
m_sQueueSample.m_nFrequency = 20000; m_sQueueSample.m_nFrequency = 20000;
m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN; m_sQueueSample.m_nBankIndex = SAMPLEBANK_MAIN;

View file

@ -39,21 +39,21 @@ enum eSound : uint16
SOUND_STEP_END, SOUND_STEP_END,
SOUND_FALL_LAND, SOUND_FALL_LAND,
SOUND_FALL_COLLAPSE, SOUND_FALL_COLLAPSE,
SOUND_FIGHT_PUNCH_33, SOUND_FIGHT_37,
SOUND_FIGHT_KICK_34, SOUND_FIGHT_38,
SOUND_FIGHT_HEADBUTT_35, SOUND_FIGHT_39,
SOUND_FIGHT_PUNCH_36, SOUND_FIGHT_40,
SOUND_FIGHT_PUNCH_37, SOUND_FIGHT_41,
SOUND_FIGHT_CLOSE_PUNCH_38, SOUND_FIGHT_42,
SOUND_FIGHT_PUNCH_39, SOUND_FIGHT_43,
SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40, SOUND_FIGHT_44,
SOUND_FIGHT_PUNCH_41, SOUND_FIGHT_45,
SOUND_FIGHT_PUNCH_FROM_BEHIND_42, SOUND_FIGHT_46,
SOUND_FIGHT_KNEE_OR_KICK_43, SOUND_FIGHT_47,
SOUND_FIGHT_KICK_44, SOUND_FIGHT_48,
SOUND_49, SOUND_49,
SOUND_WEAPON_BAT_ATTACK, SOUND_WEAPON_BAT_ATTACK,
SOUND_WEAPON_UNK_MELEE_ATTACK, SOUND_WEAPON_KNIFE_ATTACK,
SOUND_WEAPON_CHAINSAW_ATTACK, SOUND_WEAPON_CHAINSAW_ATTACK,
SOUND_WEAPON_CHAINSAW_IDLE, SOUND_WEAPON_CHAINSAW_IDLE,
SOUND_WEAPON_CHAINSAW_MADECONTACT, SOUND_WEAPON_CHAINSAW_MADECONTACT,

View file

@ -111,9 +111,14 @@ static void(*CBArray[])(CAnimBlendAssociation*, void*) =
nil, &CPed::PedGetupCB, &CPed::PedStaggerCB, &CPed::PedEvadeCB, &CPed::FinishDieAnimCB, nil, &CPed::PedGetupCB, &CPed::PedStaggerCB, &CPed::PedEvadeCB, &CPed::FinishDieAnimCB,
&CPed::FinishedWaitCB, &CPed::FinishLaunchCB, &CPed::FinishHitHeadCB, &CPed::PedAnimGetInCB, &CPed::PedAnimDoorOpenCB, &CPed::FinishedWaitCB, &CPed::FinishLaunchCB, &CPed::FinishHitHeadCB, &CPed::PedAnimGetInCB, &CPed::PedAnimDoorOpenCB,
&CPed::PedAnimPullPedOutCB, &CPed::PedAnimDoorCloseCB, &CPed::PedSetInCarCB, &CPed::PedSetOutCarCB, &CPed::PedAnimAlignCB, &CPed::PedAnimPullPedOutCB, &CPed::PedAnimDoorCloseCB, &CPed::PedSetInCarCB, &CPed::PedSetOutCarCB, &CPed::PedAnimAlignCB,
&CPed::PedSetDraggedOutCarCB, &CPed::PedAnimStepOutCarCB, &CPed::PedSetInTrainCB, &CPed::PedSetOutTrainCB, &CPed::FinishedAttackCB, &CPed::PedSetDraggedOutCarCB, &CPed::PedAnimStepOutCarCB, &CPed::PedSetInTrainCB,
#ifdef GTA_TRAIN
&CPed::PedSetOutTrainCB,
#endif
&CPed::FinishedAttackCB,
&CPed::FinishFightMoveCB, &PhonePutDownCB, &PhonePickUpCB, &CPed::PedAnimDoorCloseRollingCB, &CPed::FinishJumpCB, &CPed::FinishFightMoveCB, &PhonePutDownCB, &PhonePickUpCB, &CPed::PedAnimDoorCloseRollingCB, &CPed::FinishJumpCB,
&CPed::PedLandCB, &FinishFuckUCB, &CPed::RestoreHeadingRateCB, &CPed::PedSetQuickDraggedOutCarPositionCB, &CPed::PedSetDraggedOutCarPositionCB &CPed::PedLandCB, &CPed::RestoreHeadingRateCB, &CPed::PedSetQuickDraggedOutCarPositionCB, &CPed::PedSetDraggedOutCarPositionCB,
&CPed::FinishedReloadCB, &StartTalkingOnMobileCB, &FinishTalkingOnMobileCB
}; };
static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*)) static uint8 FindCBFunctionID(void(*f)(CAnimBlendAssociation*, void*))

View file

@ -10876,7 +10876,6 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
} }
case COMMAND_POP_CAR_BOOT: case COMMAND_POP_CAR_BOOT:
{ {
CollectParameters(&m_nIp, 1);
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]); CAutomobile* pCar = (CAutomobile*)CPools::GetVehiclePool()->GetAt(ScriptParams[0]);
assert(pCar&& pCar->IsCar()); assert(pCar&& pCar->IsCar());

View file

@ -627,11 +627,17 @@ CheckForPedsOnGroundToAttack(CPed *attacker, CPed **pedOnGround)
return stateToReturn; return stateToReturn;
} }
// --MIAMI: Done
bool bool
CPed::IsPlayer(void) CPed::IsPlayer(void)
{ {
#if 0
return m_nPedType == PEDTYPE_PLAYER1; // Original
#else
// We still have those in enum, so let's also check for them.
return m_nPedType == PEDTYPE_PLAYER1 || m_nPedType == PEDTYPE_PLAYER2 || return m_nPedType == PEDTYPE_PLAYER1 || m_nPedType == PEDTYPE_PLAYER2 ||
m_nPedType == PEDTYPE_PLAYER3 || m_nPedType == PEDTYPE_PLAYER4; m_nPedType == PEDTYPE_PLAYER3 || m_nPedType == PEDTYPE_PLAYER4;
#endif
} }
// --MIAMI: Done // --MIAMI: Done
@ -1351,9 +1357,9 @@ CPed::Attack(void)
case ASSOCGRP_UNARMED: case ASSOCGRP_UNARMED:
if (weaponAnimAssoc->animId == ANIM_MELEE_ATTACK || weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_START) { if (weaponAnimAssoc->animId == ANIM_MELEE_ATTACK || weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_START) {
#ifdef AUDIO_NOT_READY #ifdef AUDIO_NOT_READY
DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_PUNCH_39, 0.0f); DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_46, 0.0f);
#else #else
DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_PUNCH_39, (damagerType | (ourWeaponType << 8))); DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_46, (damagerType | (ourWeaponType << 8)));
#endif #endif
} }
break; break;
@ -3656,6 +3662,7 @@ CPed::CheckAroundForPossibleCollisions(void)
} }
} }
// --MIAMI: Done
bool bool
CPed::MakePhonecall(void) CPed::MakePhonecall(void)
{ {
@ -5395,7 +5402,7 @@ CPed::SetAttack(CEntity *victim)
void void
CPed::StartFightAttack(uint8 buttonPressure) CPed::StartFightAttack(uint8 buttonPressure)
{ {
if (!IsPedInControl() || m_attackTimer > CTimer::GetTimeInMilliseconds()) if (!IsPedInControl() || (m_attackTimer > CTimer::GetTimeInMilliseconds() && buttonPressure != 0))
return; return;
if (m_nPedState == PED_FIGHT) { if (m_nPedState == PED_FIGHT) {
@ -5407,7 +5414,7 @@ CPed::StartFightAttack(uint8 buttonPressure)
SetStoredState(); SetStoredState();
if (m_nWaitState != WAITSTATE_FALSE) { if (m_nWaitState != WAITSTATE_FALSE) {
m_nWaitState = WAITSTATE_FALSE; ClearWaitState();
RestoreHeadingRate(); RestoreHeadingRate();
} }
@ -5546,8 +5553,7 @@ CPed::LoadFightData(void)
if (strncmp(animName, "null", 5) != 0) { if (strncmp(animName, "null", 5) != 0) {
animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, animName); animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, animName);
tFightMoves[moveId].animId = (AnimationId)animAssoc->animId; tFightMoves[moveId].animId = (AnimationId)animAssoc->animId;
} } else {
else {
tFightMoves[moveId].animId = ANIM_WALK; tFightMoves[moveId].animId = ANIM_WALK;
} }
} }
@ -6113,49 +6119,67 @@ CPed::SetWaitState(eWaitState state, void *time)
m_nWaitState = state; m_nWaitState = state;
} }
// --MIAMI: Done
void void
CPed::PlayHitSound(CPed *hitTo) CPed::PlayHitSound(CPed *hitTo)
{ {
// That was very complicated to reverse for me... // That was very complicated to reverse for me...
// First index is our fight move ID (from 1 to 12, total 12), second is the one of we fight with (from 13 to 22, total 10). // First index is our fight move ID (from 1 to 17, total 17), second is the one of we fight with (from 18 to 27, total 10).
enum { enum {
S33 = SOUND_FIGHT_PUNCH_33, S37 = SOUND_FIGHT_37,
S34 = SOUND_FIGHT_KICK_34, S38 = SOUND_FIGHT_38,
S35 = SOUND_FIGHT_HEADBUTT_35, S39 = SOUND_FIGHT_39,
S36 = SOUND_FIGHT_PUNCH_36, S40 = SOUND_FIGHT_40,
S37 = SOUND_FIGHT_PUNCH_37, S41 = SOUND_FIGHT_41,
S38 = SOUND_FIGHT_CLOSE_PUNCH_38, S42 = SOUND_FIGHT_42,
S39 = SOUND_FIGHT_PUNCH_39, S43 = SOUND_FIGHT_43,
S40 = SOUND_FIGHT_PUNCH_OR_KICK_BELOW_40 , S44 = SOUND_FIGHT_44,
S41 = SOUND_FIGHT_PUNCH_41, S45 = SOUND_FIGHT_45,
S42 = SOUND_FIGHT_PUNCH_FROM_BEHIND_42, S46 = SOUND_FIGHT_46,
S43 = SOUND_FIGHT_KNEE_OR_KICK_43, S47 = SOUND_FIGHT_47,
S44 = SOUND_FIGHT_KICK_44, S48 = SOUND_FIGHT_48,
NO_SND = SOUND_NO_SOUND NO_SND = SOUND_NO_SOUND
}; };
uint16 hitSoundsByFightMoves[12][10] = { const uint16 hitSoundsByFightMoves[17][10] = {
{S39,S42,S43,S43,S39,S39,S39,S39,S39,S42}, { S37, S46, S41, S41, S46, S46, S40, S41, S43, S40 },
{NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND}, { NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND },
{NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND,NO_SND}, { NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND, NO_SND },
{S39,S39,S39,S39,S33,S43,S39,S39,S39,S39}, { S46, S46, S46, S46, S37, S47, S37, S38, S43, S38 },
{S39,S39,S39,S39,S35,S39,S38,S38,S39,S39}, { S46, S46, S46, S46, S46, S46, S40, S41, S43, S46 },
{S39,S39,S39,S39,S33,S39,S41,S36,S39,S39}, { S46, S46, S46, S46, S46, S46, S40, S41, S43, S40 },
{S39,S39,S39,S39,S37,S40,S38,S38,S39,S39}, { S46, S46, S46, S46, S46, S46, S40, S41, S43, S40 },
{S39,S39,S39,S39,S34,S43,S44,S37,S39,S39}, { S46, S46, S37, S46, S37, S47, S40, S47, S43, S37 },
{S39,S39,S39,S39,S34,S43,S44,S37,S39,S39}, { S46, S46, S46, S46, S46, S46, S43, S44, S43, S43 },
{S39,S39,S39,S39,S34,S43,S44,S37,S39,S40}, { S37, S46, S46, S46, S38, S47, S40, S38, S43, S46 },
{S39,S39,S39,S39,S33,S39,S41,S37,S39,S40}, { S46, S37, S46, S37, S39, S46, S40, S39, S43, S37 },
{S39,S39,S39,S39,S39,S39,S39,S39,S33,S33} { S46, S37, S46, S46, S38, S47, S40, S38, S43, S46 },
{ S37, S37, S46, S46, S38, S47, S48, S38, S43, S37 },
{ S46, S46, S46, S46, S37, S46, S40, S38, S43, S46 },
{ S46, S46, S46, S37, S39, S46, S40, S39, S43, S46 },
{ S37, S46, S46, S46, S37, S46, S40, S37, S43, S46 },
{ S43, S43, S43, S43, S43, S43, S43, S43, S43, S43 }
}; };
// This is why first dimension is between FightMove 1 and 12. eWeaponType weapon = GetWeapon()->m_eWeaponType;
if (m_lastFightMove == FIGHTMOVE_NULL || m_lastFightMove >= FIGHTMOVE_HITFRONT) CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(weapon);
if (weaponInfo->m_AnimToPlay == ASSOCGRP_KNIFE) {
if (m_lastFightMove >= FIGHTMOVE_MELEE1) {
if (m_lastFightMove == FIGHTMOVE_MELEE3) {
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, (weapon << 8) | 3);
} else {
DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_KNIFE_ATTACK, (weapon << 8) | 3);
}
return;
}
}
// This is why first dimension is between FightMove 1 and 17.
if (m_lastFightMove <= FIGHTMOVE_NULL || m_lastFightMove >= FIGHTMOVE_HITFRONT)
return; return;
uint16 soundId; uint16 soundId;
// And this is why second dimension is between 13 and 22. // And this is why second dimension is between 18 and 27.
if (hitTo->m_lastFightMove <= FIGHTMOVE_GROUNDKICK || hitTo->m_lastFightMove >= FIGHTMOVE_IDLE2NORM) { if (hitTo->m_lastFightMove <= FIGHTMOVE_GROUNDKICK || hitTo->m_lastFightMove >= FIGHTMOVE_IDLE2NORM) {
if (hitTo->m_nPedState == PED_DEAD || hitTo->UseGroundColModel()) { if (hitTo->m_nPedState == PED_DEAD || hitTo->UseGroundColModel()) {
@ -6168,7 +6192,7 @@ CPed::PlayHitSound(CPed *hitTo)
} }
if (soundId != NO_SND) if (soundId != NO_SND)
DMAudio.PlayOneShot(m_audioEntityId, soundId, 0.0f); DMAudio.PlayOneShot(m_audioEntityId, soundId, (weapon << 8) | 3);
} }
// --MIAMI: Done // --MIAMI: Done
@ -6372,7 +6396,7 @@ CPed::CollideWithPed(CPed *collideWith)
animAssoc->flags |= ASSOC_FADEOUTWHENDONE; animAssoc->flags |= ASSOC_FADEOUTWHENDONE;
collideWith->m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 1000; collideWith->m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 1000;
if (m_nPedState == PED_ATTACK) if (m_nPedState == PED_ATTACK)
DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_PUNCH_39, 0.0f); DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_46, 0.0f);
} }
} else { } else {
// We're at his right side // We're at his right side
@ -8436,7 +8460,7 @@ CPed::Seek(void)
neededTurn = TWOPI - neededTurn; neededTurn = TWOPI - neededTurn;
if (neededTurn > HALFPI) { if (neededTurn > HALFPI) {
if (seekPosDist >= 1.0 && neededTurn <= DEGTORAD(135.0f)) { if (seekPosDist >= 1.0f && neededTurn <= DEGTORAD(135.0f)) {
if (seekPosDist < 2.0f) if (seekPosDist < 2.0f)
nextMove = PEDMOVE_WALK; nextMove = PEDMOVE_WALK;
} else { } else {
@ -8446,7 +8470,7 @@ CPed::Seek(void)
} }
if (((m_nPedState == PED_FLEE_POS || m_nPedState == PED_FLEE_ENTITY) && m_nMoveState < nextMove) if (((m_nPedState == PED_FLEE_POS || m_nPedState == PED_FLEE_ENTITY) && m_nMoveState < nextMove)
|| (m_nPedState != PED_FLEE_POS && m_nPedState != PED_FLEE_ENTITY && m_objective != OBJECTIVE_GOTO_CHAR_ON_FOOT && m_nWaitState == WAITSTATE_FALSE)) { || (m_nPedState != PED_FLEE_POS && m_nPedState != PED_FLEE_ENTITY && m_nPedState != PED_FOLLOW_PATH && m_objective != OBJECTIVE_GOTO_CHAR_ON_FOOT && m_nWaitState == WAITSTATE_FALSE)) {
SetMoveState(nextMove); SetMoveState(nextMove);
} }
@ -8686,7 +8710,7 @@ void
CPed::FollowPath(void) CPed::FollowPath(void)
{ {
m_pCurPathNode = m_pathNodesToGo[m_nCurPathNodeId]; m_pCurPathNode = m_pathNodesToGo[m_nCurPathNodeId];
if (m_pathNodeTimer && CTimer::GetTimeInMilliseconds() > m_pathNodeTimer) { if (m_pathNodeTimer != 0 && CTimer::GetTimeInMilliseconds() > m_pathNodeTimer) {
RestorePreviousState(); RestorePreviousState();
ClearFollowPath(); ClearFollowPath();
m_pathNodeTimer = 0; m_pathNodeTimer = 0;
@ -8838,6 +8862,7 @@ CPed::GetNearestDoor(CVehicle *veh, CVector &posToOpen)
} }
} }
// --MIAMI: Done
bool bool
CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen) CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen)
{ {
@ -8860,7 +8885,22 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen)
CVector2D lrPosDist(999.0f, 999.0f); CVector2D lrPosDist(999.0f, 999.0f);
CVector2D rrPosDist(999.0f, 999.0f); CVector2D rrPosDist(999.0f, 999.0f);
if (veh->IsBike()) {
if (!veh->pPassengers[0] if (!veh->pPassengers[0]
&& !(veh->m_nGettingInFlags & CAR_DOOR_FLAG_LR)
&& veh->IsRoomForPedToLeaveCar(CAR_DOOR_LR, nil)) {
lrPos = GetPositionToOpenCarDoor(veh, CAR_DOOR_LR);
canEnter = true;
lrPosDist = lrPos - GetPosition();
}
if (!veh->pPassengers[0]
&& !(veh->m_nGettingInFlags & CAR_DOOR_FLAG_RR)
&& veh->IsRoomForPedToLeaveCar(CAR_DOOR_RR, nil)) {
rrPos = GetPositionToOpenCarDoor(veh, CAR_DOOR_RR);
canEnter = true;
rrPosDist = rrPos - GetPosition();
}
} else if (!veh->pPassengers[0]
&& !(veh->m_nGettingInFlags & CAR_DOOR_FLAG_RF) && !(veh->m_nGettingInFlags & CAR_DOOR_FLAG_RF)
&& veh->IsRoomForPedToLeaveCar(CAR_DOOR_RF, nil)) { && veh->IsRoomForPedToLeaveCar(CAR_DOOR_RF, nil)) {
@ -8868,6 +8908,7 @@ CPed::GetNearestPassengerDoor(CVehicle *veh, CVector &posToOpen)
canEnter = true; canEnter = true;
rfPosDist = rfPos - GetPosition(); rfPosDist = rfPos - GetPosition();
} }
if (vehModel->m_numDoors == 4) { if (vehModel->m_numDoors == 4) {
if (!veh->pPassengers[1] if (!veh->pPassengers[1]
&& !(veh->m_nGettingInFlags & CAR_DOOR_FLAG_LR) && !(veh->m_nGettingInFlags & CAR_DOOR_FLAG_LR)
@ -9426,6 +9467,7 @@ CPed::InvestigateEvent(void)
} }
} }
// --MIAMI: Done
bool bool
CPed::IsPedDoingDriveByShooting(void) CPed::IsPedDoingDriveByShooting(void)
{ {
@ -10024,6 +10066,7 @@ CPed::Mug(void)
} }
} }
// --MIAMI: Done
void void
CPed::MoveHeadToLook(void) CPed::MoveHeadToLook(void)
{ {
@ -10031,38 +10074,13 @@ CPed::MoveHeadToLook(void)
if (m_lookTimer && CTimer::GetTimeInMilliseconds() > m_lookTimer) { if (m_lookTimer && CTimer::GetTimeInMilliseconds() > m_lookTimer) {
ClearLookFlag(); ClearLookFlag();
} else if (m_nPedState == PED_DRIVING) {
m_pedIK.m_flags |= CPedIK::LOOKAROUND_HEAD_ONLY;
} }
if (bIsLooking || bIsRestoringLook)
if (!CanUseTorsoWhenLooking())
m_pedIK.m_flags |= CPedIK::LOOKAROUND_HEAD_ONLY;
if (m_pLookTarget) { if (m_pLookTarget) {
if (!bShakeFist && GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED) {
CAnimBlendAssociation *fuckUAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FUCKU);
if (fuckUAssoc) {
float animTime = fuckUAssoc->currentTime;
if (animTime > 4.0f / 30.0f && animTime - fuckUAssoc->timeStep > 4.0f / 30.0f) {
bool lookingToCop = false;
if (m_pLookTarget->GetModelIndex() == MI_POLICE
|| m_pLookTarget->IsPed() && ((CPed*)m_pLookTarget)->m_nPedType == PEDTYPE_COP) {
lookingToCop = true;
}
if (IsPlayer() && (m_pedStats->m_temper >= 52 || lookingToCop)) {
AddWeaponModel(MI_FINGERS);
((CPlayerPed*)this)->AnnoyPlayerPed(true);
} else if ((CGeneral::GetRandomNumber() & 3) == 0) {
AddWeaponModel(MI_FINGERS);
}
}
}
}
if (m_pLookTarget->IsPed()) { 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 { } else {
@ -10079,6 +10097,9 @@ CPed::MoveHeadToLook(void)
if (!bShakeFist || bIsAimingGun || bIsRestoringGun) if (!bShakeFist || bIsAimingGun || bIsRestoringGun)
return; return;
if (m_nPedState == PED_ANSWER_MOBILE)
return;
if (m_lookTimer - CTimer::GetTimeInMilliseconds() >= 1000) if (m_lookTimer - CTimer::GetTimeInMilliseconds() >= 1000)
return; return;
@ -10119,8 +10140,6 @@ CPed::MoveHeadToLook(void)
if (newAssoc) { if (newAssoc) {
newAssoc->flags |= ASSOC_FADEOUTWHENDONE; newAssoc->flags |= ASSOC_FADEOUTWHENDONE;
newAssoc->flags |= ASSOC_DELETEFADEDOUT; newAssoc->flags |= ASSOC_DELETEFADEDOUT;
if (newAssoc->animId == ANIM_FUCKU)
newAssoc->SetDeleteCallback(FinishFuckUCB, this);
} }
} }
bShakeFist = false; bShakeFist = false;
@ -10140,15 +10159,6 @@ CPed::MoveHeadToLook(void)
} }
} }
void
FinishFuckUCB(CAnimBlendAssociation *animAssoc, void *arg)
{
CPed *ped = (CPed*)arg;
if (animAssoc->animId == ANIM_FUCKU && ped->GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED)
ped->RemoveWeaponModel(0);
}
// --MIAMI: Done // --MIAMI: Done
void void
CPed::Pause(void) CPed::Pause(void)
@ -11751,6 +11761,7 @@ CPed::PointGunAt(void)
} }
} }
// --MIAMI: Done
void void
CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg) CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
{ {
@ -11779,22 +11790,16 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
if (veh->Damage.GetDoorStatus(door) == DOOR_STATUS_SMASHED) if (veh->Damage.GetDoorStatus(door) == DOOR_STATUS_SMASHED)
veh->Damage.SetDoorStatus(door, DOOR_STATUS_OK); veh->Damage.SetDoorStatus(door, DOOR_STATUS_OK);
if (door == DOOR_FRONT_LEFT || ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || veh->bIsBus) { if (door == DOOR_FRONT_LEFT || ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER || veh->bIsBus || veh->m_nNumMaxPassengers == 0) {
PedSetInCarCB(nil, ped); PedSetInCarCB(nil, ped);
} else if (ped->m_vehEnterType == CAR_DOOR_RF } else if (ped->m_vehEnterType == CAR_DOOR_RF
&& (veh->m_nGettingInFlags & CAR_DOOR_FLAG_LF || && (veh->m_nGettingInFlags & CAR_DOOR_FLAG_LF ||
(veh->pDriver != nil && (veh->pDriver != nil &&
(veh->pDriver->m_objective != OBJECTIVE_LEAVE_VEHICLE (veh->pDriver->m_objective != OBJECTIVE_LEAVE_VEHICLE
#ifdef VC_PED_PORTS
&& veh->pDriver->m_objective != OBJECTIVE_LEAVE_CAR_AND_DIE && veh->pDriver->m_objective != OBJECTIVE_LEAVE_CAR_AND_DIE
#endif
|| !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) { || !veh->IsRoomForPedToLeaveCar(CAR_DOOR_LF, nil))))) {
if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER if (ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER || ped->m_nPedState == PED_CARJACK)
#ifdef VC_PED_PORTS
|| ped->m_nPedState == PED_CARJACK
#endif
)
veh->bIsBeingCarJacked = false; veh->bIsBeingCarJacked = false;
ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER; ped->m_objective = OBJECTIVE_ENTER_CAR_AS_PASSENGER;
@ -11818,14 +11823,12 @@ CPed::PedAnimDoorCloseCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->m_pVehicleAnim->SetFinishCallback(PedSetInCarCB, ped); ped->m_pVehicleAnim->SetFinishCallback(PedSetInCarCB, ped);
} }
} else { } else if (ped->m_nPedState != PED_DRIVING) {
#ifdef VC_PED_PORTS
if (ped->m_nPedState != PED_DRIVING)
#endif
ped->QuitEnteringCar(); ped->QuitEnteringCar();
} }
} }
// --MIAMI: Done
void void
CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation* animAssoc, void* arg) CPed::PedAnimDoorCloseRollingCB(CAnimBlendAssociation* animAssoc, void* arg)
{ {
@ -11872,10 +11875,26 @@ CPed::PedAnimDoorOpenCB(CAnimBlendAssociation* animAssoc, void* arg)
eDoors door; eDoors door;
CPed *pedInSeat = nil; CPed *pedInSeat = nil;
switch (ped->m_vehEnterType) { switch (ped->m_vehEnterType) {
case CAR_DOOR_RF: door = DOOR_FRONT_RIGHT; pedInSeat = veh->pPassengers[0]; break; case CAR_DOOR_RF:
case CAR_DOOR_RR: door = DOOR_REAR_RIGHT; pedInSeat = veh->pPassengers[2]; break; door = DOOR_FRONT_RIGHT;
case CAR_DOOR_LF: door = DOOR_FRONT_LEFT; pedInSeat = veh->pDriver; break; pedInSeat = veh->pPassengers[0];
case CAR_DOOR_LR: door = DOOR_REAR_LEFT; pedInSeat = veh->pPassengers[1]; break; if (!veh->pPassengers[0] && ped->m_objective == OBJECTIVE_ENTER_CAR_AS_DRIVER)
pedInSeat = veh->pDriver;
break;
case CAR_DOOR_RR:
door = DOOR_REAR_RIGHT;
pedInSeat = veh->pPassengers[2];
break;
case CAR_DOOR_LF:
door = DOOR_FRONT_LEFT;
pedInSeat = veh->pDriver;
if (veh->bIsBus && ped->m_objective == OBJECTIVE_ENTER_CAR_AS_PASSENGER)
pedInSeat = nil;
break;
case CAR_DOOR_LR:
door = DOOR_REAR_LEFT;
pedInSeat = veh->pPassengers[1];
break;
default: assert(0); default: assert(0);
} }
@ -12868,6 +12887,7 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->bChangedSeat = true; ped->bChangedSeat = true;
} }
// --MIAMI: Done :D
void void
CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg) CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg)
{ {
@ -12878,7 +12898,7 @@ CPed::PedSetInTrainCB(CAnimBlendAssociation* animAssoc, void* arg)
return; return;
ped->bInVehicle = true; ped->bInVehicle = true;
ped->m_nPedState = PED_DRIVING; ped->SetPedState(PED_DRIVING);
ped->RestorePreviousObjective(); ped->RestorePreviousObjective();
ped->SetMoveState(PEDMOVE_STILL); ped->SetMoveState(PEDMOVE_STILL);
veh->AddPassenger(ped); veh->AddPassenger(ped);
@ -13269,6 +13289,7 @@ CPed::RemoveWeaponWhenEnteringVehicle(void)
} }
} }
#ifdef GTA_TRAIN
void void
CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg) CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg)
{ {
@ -13297,6 +13318,7 @@ CPed::PedSetOutTrainCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->SetHeading(ped->m_fRotationCur); ped->SetHeading(ped->m_fRotationCur);
veh->RemovePassenger(ped); veh->RemovePassenger(ped);
} }
#endif
bool bool
CPed::PlacePedOnDryLand(void) CPed::PlacePedOnDryLand(void)
@ -15203,14 +15225,11 @@ CPed::SetSeekCar(CVehicle *car, uint32 doorNode)
} }
// --MIAMI: Done
void void
CPed::SetSeekBoatPosition(CVehicle *boat) CPed::SetSeekBoatPosition(CVehicle *boat)
{ {
if (m_nPedState == PED_SEEK_IN_BOAT || boat->pDriver if (m_nPedState == PED_SEEK_IN_BOAT || boat->pDriver || !IsPedInControl())
#ifdef VC_PED_PORTS
|| !IsPedInControl()
#endif
)
return; return;
SetStoredState(); SetStoredState();
@ -15219,7 +15238,7 @@ CPed::SetSeekBoatPosition(CVehicle *boat)
m_pMyVehicle = boat; m_pMyVehicle = boat;
m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle); m_pMyVehicle->RegisterReference((CEntity **) &m_pMyVehicle);
m_distanceToCountSeekDone = 0.5f; m_distanceToCountSeekDone = 0.5f;
m_nPedState = PED_SEEK_IN_BOAT; SetPedState(PED_SEEK_IN_BOAT);
} }
#ifdef GTA_TRAIN #ifdef GTA_TRAIN
@ -16201,6 +16220,7 @@ CPed::SetDuck(uint32 time, bool sth)
} }
} }
// --MIAMI: Done
void void
CPed::SeekBoatPosition(void) CPed::SeekBoatPosition(void)
{ {
@ -16643,7 +16663,7 @@ CPed::SetFollowPathStatic(void)
return true; return true;
} else { } else {
ThePaths.DoPathSearch(PATH_PED, GetPosition(), -1, m_followPathDestPos, m_pathNodesToGo, &m_nNumPathNodes, ThePaths.DoPathSearch(PATH_PED, GetPosition(), -1, m_followPathDestPos, m_pathNodesToGo, &m_nNumPathNodes,
ARRAY_SIZE(m_pathNodesToGo), nil, nil, 999999.0f, -1); ARRAY_SIZE(m_pathNodesToGo), nil, nil, 999999.9f, -1);
if (m_nNumPathNodes != 0) { if (m_nNumPathNodes != 0) {
if (m_nNumPathNodes > 0 && m_pathNodesToGo[0] != m_pCurPathNode) { if (m_nNumPathNodes > 0 && m_pathNodesToGo[0] != m_pCurPathNode) {

View file

@ -346,9 +346,7 @@ enum eMoveState {
PEDMOVE_NONE, PEDMOVE_NONE,
PEDMOVE_STILL, PEDMOVE_STILL,
PEDMOVE_WALK, PEDMOVE_WALK,
PEDMOVE_JOG,
PEDMOVE_UNK,
PEDMOVE_RUN, PEDMOVE_RUN,
PEDMOVE_SPRINT, PEDMOVE_SPRINT,
}; };
@ -400,7 +398,7 @@ public:
uint32 bScriptObjectiveCompleted : 1; uint32 bScriptObjectiveCompleted : 1;
uint32 bKindaStayInSamePlace : 1; uint32 bKindaStayInSamePlace : 1;
uint32 bBeingChasedByPolice : 1; // Unused VC leftover. Should've been set for criminal/gang members uint32 bBeingChasedByPolice : 1;
uint32 bNotAllowedToDuck : 1; uint32 bNotAllowedToDuck : 1;
uint32 bCrouchWhenShooting : 1; uint32 bCrouchWhenShooting : 1;
uint32 bIsDucking : 1; uint32 bIsDucking : 1;
@ -883,7 +881,9 @@ public:
static void PedSetDraggedOutCarCB(CAnimBlendAssociation *assoc, void *arg); static void PedSetDraggedOutCarCB(CAnimBlendAssociation *assoc, void *arg);
static void PedAnimStepOutCarCB(CAnimBlendAssociation *assoc, void *arg); static void PedAnimStepOutCarCB(CAnimBlendAssociation *assoc, void *arg);
static void PedSetInTrainCB(CAnimBlendAssociation *assoc, void *arg); static void PedSetInTrainCB(CAnimBlendAssociation *assoc, void *arg);
static void PedSetOutTrainCB(CAnimBlendAssociation *assoc, void *arg); // TODO(Miami): Should be under GTA_TRAIN #ifdef GTA_TRAIN
static void PedSetOutTrainCB(CAnimBlendAssociation *assoc, void *arg);
#endif
static void FinishedAttackCB(CAnimBlendAssociation *assoc, void *arg); static void FinishedAttackCB(CAnimBlendAssociation *assoc, void *arg);
static void FinishedReloadCB(CAnimBlendAssociation *assoc, void *arg); static void FinishedReloadCB(CAnimBlendAssociation *assoc, void *arg);
static void FinishFightMoveCB(CAnimBlendAssociation *assoc, void *arg); static void FinishFightMoveCB(CAnimBlendAssociation *assoc, void *arg);
@ -940,7 +940,6 @@ public:
CObject *SpawnFlyingComponent(int, int8); CObject *SpawnFlyingComponent(int, int8);
void SetCarJack_AllClear(CVehicle*, uint32, uint32); void SetCarJack_AllClear(CVehicle*, uint32, uint32);
bool CanPedJumpThis(CEntity*, CVector*); bool CanPedJumpThis(CEntity*, CVector*);
void SetNewAttraction(CPedAttractor* pAttractor, const CVector& pos, float, float, int); void SetNewAttraction(CPedAttractor* pAttractor, const CVector& pos, float, float, int);
void ClearWaitState(void); void ClearWaitState(void);
void Undress(const char*); void Undress(const char*);
@ -1113,7 +1112,6 @@ public:
void FinishTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg); void FinishTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg);
void StartTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg); void StartTalkingOnMobileCB(CAnimBlendAssociation* assoc, void* arg);
void FinishFuckUCB(CAnimBlendAssociation *assoc, void *arg);
void PlayRandomAnimationsFromAnimBlock(CPed* ped, AssocGroupId animGroup, uint32 first, uint32 amount); void PlayRandomAnimationsFromAnimBlock(CPed* ped, AssocGroupId animGroup, uint32 first, uint32 amount);
// TODO(Miami): Change those when Ped struct is done // TODO(Miami): Change those when Ped struct is done

View file

@ -5136,6 +5136,9 @@ CAutomobile::ProcessSwingingDoor(int32 component, eDoors door)
if(Damage.GetDoorStatus(door) != DOOR_STATUS_SWINGING) if(Damage.GetDoorStatus(door) != DOOR_STATUS_SWINGING)
return; return;
if (m_aCarNodes[component] == nil)
return;
CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component])); CMatrix mat(RwFrameGetMatrix(m_aCarNodes[component]));
CVector pos = mat.GetPosition(); CVector pos = mat.GetPosition();
float axes[3] = { 0.0f, 0.0f, 0.0f }; float axes[3] = { 0.0f, 0.0f, 0.0f };

View file

@ -1150,6 +1150,7 @@ CWeapon::AddGunshell(CEntity *shooter, CVector const &source, CVector2D const &d
} }
} }
// --MIAMI: Done?
void void
CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim, CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
CVector *source, CVector *target, CColPoint *point, CVector2D ahead) CVector *source, CVector *target, CColPoint *point, CVector2D ahead)
@ -1163,26 +1164,68 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
if ( victim ) if ( victim )
{ {
if (shooter)
{
if (shooter && shooter->IsPed() && ((CPed*)shooter)->m_attachedTo == victim)
return;
if (shooter->IsPed() && !((CPed*)shooter)->IsPlayer())
{
CPed* shooterPed = (CPed*)shooter;
CEntity* guyWePointGun = shooterPed->m_pPointGunAt;
if (guyWePointGun)
{
if (victim != guyWePointGun)
{
float distWithAim = (guyWePointGun->GetPosition() - shooter->GetPosition()).Magnitude();
float distWithBullet = (point->point - shooter->GetPosition()).Magnitude();
if (distWithAim > 0.1f && distWithBullet > 0.1f)
{
// Normalize
CVector aimDir = (guyWePointGun->GetPosition() - shooter->GetPosition()) * (1.0f / distWithAim);
CVector bulletDir = (point->point - shooter->GetPosition()) * (1.0f / distWithBullet);
float dotProd = DotProduct(aimDir, bulletDir);
float aimAndBulletAngle;
if (dotProd <= 0.35f)
aimAndBulletAngle = PI;
else
aimAndBulletAngle = Acos(dotProd);
if (aimAndBulletAngle <= DEGTORAD(45.0f) && (aimAndBulletAngle <= DEGTORAD(15.0f) || distWithBullet / distWithAim >= 0.75f) && distWithBullet / distWithAim >= 0.99f)
{
shooterPed->bObstacleShowedUpDuringKillObjective = false;
shooterPed->m_shotTime = 0;
}
else
{
shooterPed->bObstacleShowedUpDuringKillObjective = true;
shooterPed->m_shootTimer = 0;
shooterPed->m_shotTime = CTimer::GetTimeInMilliseconds();
if (distWithAim < 10.0f)
shooterPed->SetAttackTimer(1500);
else
shooterPed->SetAttackTimer(3000);
}
}
}
}
}
}
CGlass::WasGlassHitByBullet(victim, point->point); CGlass::WasGlassHitByBullet(victim, point->point);
CVector traceTarget = point->point; CVector traceTarget = point->point;
CBulletTraces::AddTrace(source, &traceTarget); CBulletTraces::AddTrace(source, &traceTarget);
if ( shooter != nil ) if (victim->IsPed() && shooter->IsVehicle() && ((CVehicle*)shooter)->pDriver)
{ shooter = ((CVehicle*)shooter)->pDriver;
if ( shooter == FindPlayerPed() )
{
if ( victim->IsPed() || victim->IsVehicle() )
CStats::InstantHitsHitByPlayer++;
}
}
if ( victim->IsPed() && ((CPed*)shooter)->m_nPedType != ((CPed*)victim)->m_nPedType || ((CPed*)shooter)->m_nPedType == PEDTYPE_PLAYER2 ) if ( victim->IsPed() && shooter->IsPed() &&
(((CPed*)shooter)->m_nPedType != ((CPed*)victim)->m_nPedType || ((CPed*)shooter)->m_nPedType == PEDTYPE_PLAYER2 ||
!((CPed*)shooter)->IsGangMember() && ((CPed*)shooter)->m_nPedType != PEDTYPE_COP))
{ {
CPed *victimPed = (CPed *)victim; CPed *victimPed = (CPed *)victim;
if ( !victimPed->OnGround() && victim != shooter ) if ( !victimPed->DyingOrDead() && victim != shooter )
{
if ( victimPed->DoesLOSBulletHitPed(*point) )
{ {
CVector pos = victimPed->GetPosition(); CVector pos = victimPed->GetPosition();
@ -1197,8 +1240,8 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
} }
else else
{ {
if ( IsShotgun(m_eWeaponType) || m_eWeaponType == WEAPONTYPE_HELICANNON if ( victimPed->bCanBeShotInVehicle && (IsShotgun(m_eWeaponType) ||
|| m_eWeaponType == WEAPONTYPE_M60 || m_eWeaponType == WEAPONTYPE_PYTHON) (!victimPed->IsPlayer() && (m_eWeaponType == WEAPONTYPE_HELICANNON || m_eWeaponType == WEAPONTYPE_M60 || m_eWeaponType == WEAPONTYPE_PYTHON))))
{ {
posOffset.Normalise(); posOffset.Normalise();
victimPed->bIsStanding = false; victimPed->bIsStanding = false;
@ -1213,7 +1256,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
if ( victimPed->IsPlayer() ) if ( victimPed->IsPlayer() )
{ {
CPlayerPed *victimPlayer = (CPlayerPed *)victimPed; CPlayerPed *victimPlayer = (CPlayerPed *)victimPed;
if ( victimPlayer->m_nHitAnimDelayTimer < CTimer::GetTimeInMilliseconds() ) if ( victimPlayer->m_nHitAnimDelayTimer < CTimer::GetTimeInMilliseconds() && victimPed->m_nPedState != PED_DRIVING )
{ {
victimPed->ClearAttackByRemovingAnim(); victimPed->ClearAttackByRemovingAnim();
@ -1263,6 +1306,12 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
for ( uint8 i = 0; i < bloodAmount; i++ ) for ( uint8 i = 0; i < bloodAmount; i++ )
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point->point, dir); CParticle::AddParticle(PARTICLE_BLOOD_SMALL, point->point, dir);
} }
if (m_eWeaponType == WEAPONTYPE_MINIGUN)
{
CParticle::AddParticle(PARTICLE_TEST, point->point, CVector(0.f, 0.f, 0.f), nil, 0.f, 0, 0, 0, 0);
CParticle::AddParticle(PARTICLE_TEST, point->point + CVector(0.2f, -0.2f, 0.f), CVector(0.f, 0.f, 0.f), nil, 0.f, 0, 0, 0, 0);
CParticle::AddParticle(PARTICLE_TEST, point->point + CVector(-0.2f, 0.2f, 0.f), CVector(0.f, 0.f, 0.f), nil, 0.f, 0, 0, 0, 0);
} }
} }
} }
@ -1308,8 +1357,7 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
#ifndef FIX_BUGS #ifndef FIX_BUGS
CVector dist = point->point - (*source); CVector dist = point->point - (*source);
CVector offset = dist - Max(0.2f * dist.Magnitude(), 2.0f) * CVector(ahead.x, ahead.y, 0.0f); CVector smokePos = point->point - Max(0.1f * dist.Magnitude(), 0.2f) / dist.Magnitude();
CVector smokePos = *source + offset;
#else #else
CVector smokePos = point->point; CVector smokePos = point->point;
#endif // !FIX_BUGS #endif // !FIX_BUGS
@ -1324,20 +1372,30 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
} }
case ENTITY_TYPE_VEHICLE: case ENTITY_TYPE_VEHICLE:
{ {
((CVehicle *)victim)->InflictDamage(shooter, m_eWeaponType, info->m_nDamage, point->point); if (point->pieceB >= SURFACE_LAMP_POST && point->pieceB <= SURFACE_METAL_CHAIN_FENCE) {
((CVehicle*)victim)->BurstTyre(point->pieceB, true);
for ( int32 i = 0; i < 16; i++ ) for (int32 i = 0; i < 4; i++)
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal*0.05f); CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, point->point, point->normal * 0.05f);
}
else
{
((CVehicle*)victim)->InflictDamage(shooter, m_eWeaponType, info->m_nDamage);
for (int32 i = 0; i < 16; i++)
CParticle::AddParticle(PARTICLE_SPARK, point->point, point->normal * 0.05f);
#ifndef FIX_BUGS #ifndef FIX_BUGS
CVector dist = point->point - (*source); CVector dist = point.point - (*fireSource);
CVector offset = dist - Max(0.2f*dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f); CVector offset = dist - Max(0.2f * dist.Magnitude(), 0.5f) * CVector(ahead.x, ahead.y, 0.0f);
CVector smokePos = *source + offset; CVector smokePos = *fireSource + offset;
#else #else
CVector smokePos = point->point; CVector smokePos = point->point;
#endif // !FIX_BUGS #endif
CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f)); CParticle::AddParticle(PARTICLE_BULLETHIT_SMOKE, smokePos, CVector(0.0f, 0.0f, 0.0f));
}
if ( shooter->IsPed() ) if ( shooter->IsPed() )
{ {
@ -1362,19 +1420,23 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
CObject *victimObject = (CObject *)victim; CObject *victimObject = (CObject *)victim;
if ( !victimObject->bInfiniteMass ) if ( !victimObject->bInfiniteMass && victimObject->m_fCollisionDamageMultiplier < 99.9f)
{ {
if ( victimObject->IsStatic() && victimObject->m_fUprootLimit <= 0.0f ) bool notStatic = !victimObject->IsStatic();
if (notStatic && victimObject->m_fUprootLimit <= 0.0f)
{ {
victimObject->bIsStatic = false; victimObject->bIsStatic = false;
victimObject->AddToMovingList(); victimObject->AddToMovingList();
} }
if ( !victimObject->IsStatic()) notStatic = !victimObject->IsStatic();
if (!notStatic)
{ {
CVector moveForce = point->normal*-4.0f; CVector moveForce = point->normal * -4.0f;
victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); victimObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);
} }
} else if (victimObject->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY) {
victimObject->ObjectDamage(50.f);
} }
break; break;
@ -1392,17 +1454,20 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
} }
case ENTITY_TYPE_VEHICLE: case ENTITY_TYPE_VEHICLE:
{ {
CStats::InstantHitsHitByPlayer++;
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f); DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f);
break; break;
} }
case ENTITY_TYPE_PED: case ENTITY_TYPE_PED:
{ {
CStats::InstantHitsHitByPlayer++;
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f); DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f);
((CPed*)victim)->Say(SOUND_PED_BULLET_HIT); ((CPed*)victim)->Say(SOUND_PED_BULLET_HIT);
break; break;
} }
case ENTITY_TYPE_OBJECT: case ENTITY_TYPE_OBJECT:
{ {
CStats::InstantHitsHitByPlayer++;
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point->point); PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point->point);
break; break;
} }
@ -1596,10 +1661,10 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
shooterPed->bObstacleShowedUpDuringKillObjective = true; shooterPed->bObstacleShowedUpDuringKillObjective = true;
shooterPed->m_shootTimer = 0; shooterPed->m_shootTimer = 0;
shooterPed->m_shotTime = CTimer::GetTimeInMilliseconds(); shooterPed->m_shotTime = CTimer::GetTimeInMilliseconds();
if (distWithAim >= 10.0f) if (distWithAim < 10.0f)
shooterPed->SetAttackTimer(3000);
else
shooterPed->SetAttackTimer(1500); shooterPed->SetAttackTimer(1500);
else
shooterPed->SetAttackTimer(3000);
} }
} }
} }
@ -1785,7 +1850,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
case ENTITY_TYPE_VEHICLE: case ENTITY_TYPE_VEHICLE:
{ {
if (!statUpdated) { if (!statUpdated) {
//CStats::NumBulletsHit++; // TODO(Miami): Stats CStats::InstantHitsHitByPlayer++;
statUpdated = true; statUpdated = true;
} }
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f); DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_VEHICLE, 1.0f);
@ -1794,7 +1859,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
case ENTITY_TYPE_PED: case ENTITY_TYPE_PED:
{ {
if (!statUpdated) { if (!statUpdated) {
//CStats::NumBulletsHit++; // TODO(Miami): Stats CStats::InstantHitsHitByPlayer++;
statUpdated = true; statUpdated = true;
} }
DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f); DMAudio.PlayOneShot(((CPhysical*)victim)->m_audioEntityId, SOUND_WEAPON_HIT_PED, 1.0f);
@ -1804,7 +1869,7 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
case ENTITY_TYPE_OBJECT: case ENTITY_TYPE_OBJECT:
{ {
if (!statUpdated) { if (!statUpdated) {
//CStats::NumBulletsHit++; // TODO(Miami): Stats CStats::InstantHitsHitByPlayer++;
statUpdated = true; statUpdated = true;
} }
PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point.point); PlayOneShotScriptObject(SCRIPT_SOUND_BULLET_HIT_GROUND_2, point.point);
@ -2776,6 +2841,7 @@ CWeapon::HitsGround(CEntity *holder, CVector *fireSource, CEntity *aimingTo)
return false; return false;
} }
// --MIAMI: Done
void void
CWeapon::BlowUpExplosiveThings(CEntity *thing) CWeapon::BlowUpExplosiveThings(CEntity *thing)
{ {
@ -2783,14 +2849,14 @@ CWeapon::BlowUpExplosiveThings(CEntity *thing)
{ {
CObject *object = (CObject*)thing; CObject *object = (CObject*)thing;
int32 mi = object->GetModelIndex(); int32 mi = object->GetModelIndex();
if ( IsExplosiveThingModel(mi) && !object->bHasBeenDamaged ) if ( IsExplosiveThingModel(mi) && !object->bHasBeenDamaged && object->IsObject() )
{ {
object->bHasBeenDamaged = true; object->bHasBeenDamaged = true;
CExplosion::AddExplosion(object, FindPlayerPed(), EXPLOSION_BARREL, object->GetPosition()+CVector(0.0f,0.0f,0.5f), 100); CExplosion::AddExplosion(object, FindPlayerPed(), EXPLOSION_BARREL, object->GetPosition()+CVector(0.0f,0.0f,0.5f), 100);
if ( MI_EXPLODINGBARREL == mi ) if ( MI_EXPLODINGBARREL == mi )
object->m_vecMoveSpeed.z += 0.75f; object->m_vecMoveSpeed.z += 0.55f;
else else
object->m_vecMoveSpeed.z += 0.45f; object->m_vecMoveSpeed.z += 0.45f;