Merge branch 'miami' of github.com:GTAmodding/re3 into miami

This commit is contained in:
aap 2020-05-19 21:42:16 +02:00
commit c623ec8a2d
19 changed files with 821 additions and 316 deletions

View File

@ -49,6 +49,16 @@ uint16 AmmoForWeapon[20] = { 0, 1, 45, 125, 25, 150, 300, 25, 5, 250, 5, 5, 0, 5
uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS] = { uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS] = {
0, 0,
1, 1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
4, 4,
4, 4,
4, 4,
@ -70,16 +80,20 @@ uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS] = {
uint16 CostOfWeapon[20] = { 0, 10, 250, 800, 1500, 3000, 5000, 10000, 25000, 25000, 2000, 2000, 0, 50000, 0, 3000, 0, 0, 0, 0 }; uint16 CostOfWeapon[20] = { 0, 10, 250, 800, 1500, 3000, 5000, 10000, 25000, 25000, 2000, 2000, 0, 50000, 0, 3000, 0, 0, 0, 0 };
// TODO(Miami): Those are all placeholders!! // TODO(Miami): Those are all placeholders!!
uint8 aWeaponReds[] = { 0, 255, 0, 128, 255, 255, 0, 255, 0, 128, 128, 255, uint8 aWeaponReds[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 0, 128, 255, 255, 0, 255, 0, 128, 128, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 128, 0, 255, 0 }; 255, 128, 0, 255, 0 };
uint8 aWeaponGreens[] = { 0, 0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255, uint8 aWeaponGreens[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 255, 0, 255, 0 }; 0, 255, 0, 255, 0 };
uint8 aWeaponBlues[] = { 0, 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, uint8 aWeaponBlues[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 128, 255, 0, 0 }; 0, 128, 255, 0, 0 };
float aWeaponScale[] = { 1.0f, 1.0f, 2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, float aWeaponScale[] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
2.0f, 1.5f, 1.0f, 1.0f, 1.5f, 1.0f, 2.0f, 1.0f, 2.0f, 2.5f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f, 1.0f }; 1.0f, 1.0f, 1.0f, 1.0f };

View File

@ -10382,8 +10382,20 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
{ {
switch (command) { switch (command) {
case COMMAND_SET_CHAR_CAN_BE_DAMAGED_BY_MEMBERS_OF_GANG: case COMMAND_SET_CHAR_CAN_BE_DAMAGED_BY_MEMBERS_OF_GANG:
{
CollectParameters(&m_nIp, 3);
CPed *pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]);
uint8 flag = 1 << (uint8)ScriptParams[1];
if (ScriptParams[2])
pTarget->m_gangFlags |= flag;
else
pTarget->m_gangFlags &= ~flag;
return 0;
}
case COMMAND_LOAD_AND_LAUNCH_MISSION_EXCLUSIVE: case COMMAND_LOAD_AND_LAUNCH_MISSION_EXCLUSIVE:
case COMMAND_IS_MISSION_AUDIO_PLAYING: case COMMAND_IS_MISSION_AUDIO_PLAYING:
assert(0);
case COMMAND_CREATE_LOCKED_PROPERTY_PICKUP: case COMMAND_CREATE_LOCKED_PROPERTY_PICKUP:
{ {
CollectParameters(&m_nIp, 3); CollectParameters(&m_nIp, 3);

View File

@ -22,10 +22,12 @@ enum eEventType
EVENT_PED_SET_ON_FIRE, EVENT_PED_SET_ON_FIRE,
EVENT_COP_SET_ON_FIRE, EVENT_COP_SET_ON_FIRE,
EVENT_CAR_SET_ON_FIRE, EVENT_CAR_SET_ON_FIRE,
EVENT_ASSAULT_NASTYWEAPON, // not sure EVENT_ASSAULT_NASTYWEAPON,
EVENT_ASSAULT_NASTYWEAPON_POLICE,
EVENT_ICECREAM, EVENT_ICECREAM,
EVENT_ATM, EVENT_ATM,
EVENT_SHOPSTALL, // used on graffitis EVENT_SHOPSTALL,
EVENT_SHOPWINDOW,
EVENT_LAST_EVENT EVENT_LAST_EVENT
}; };

View File

@ -1337,8 +1337,7 @@ CStreaming::LoadInitialPeds(void)
void void
CStreaming::LoadInitialWeapons(void) CStreaming::LoadInitialWeapons(void)
{ {
// TODO(Miami): Enable when weapons have been ported CStreaming::RequestModel(MI_NIGHTSTICK, STREAMFLAGS_DONT_REMOVE);
//CStreaming::RequestModel(MI_NIGHTSTICK, STREAMFLAGS_DONT_REMOVE);
CStreaming::RequestModel(MI_MISSILE, STREAMFLAGS_DONT_REMOVE); CStreaming::RequestModel(MI_MISSILE, STREAMFLAGS_DONT_REMOVE);
} }

View File

@ -46,7 +46,7 @@ public:
float m_fDistanceTravelled; float m_fDistanceTravelled;
// damaged piece // damaged piece
float m_fDamageImpulse; float m_fDamageImpulse; // fCollisionPower
CEntity *m_pDamageEntity; CEntity *m_pDamageEntity;
CVector m_vecDamageNormal; CVector m_vecDamageNormal;
int16 m_nDamagePieceType; int16 m_nDamagePieceType;

View File

@ -302,6 +302,7 @@ enum
MI_TRAIN = -1, MI_TRAIN = -1,
MI_DODO = -2, MI_DODO = -2,
MI_NIGHTSTICK = 262,
MI_BASEBALL_BAT = 264, MI_BASEBALL_BAT = 264,
MI_GRENADE = 270, MI_GRENADE = 270,
MI_MOLOTOV = 272, MI_MOLOTOV = 272,

View File

@ -23,7 +23,7 @@ CCopPed::CCopPed(eCopType copType, int32 modifier) : CPed(PEDTYPE_COP)
switch (copType) { switch (copType) {
case COP_STREET: case COP_STREET:
SetModelIndex(MI_COP); SetModelIndex(MI_COP);
// GiveWeapon(WEAPONTYPE_NIGHTSTICK, 1000, true); // TODO(Miami) GiveWeapon(WEAPONTYPE_NIGHTSTICK, 1000, true);
GiveDelayedWeapon(WEAPONTYPE_COLT45, 1000); GiveDelayedWeapon(WEAPONTYPE_COLT45, 1000);
m_currentWeapon = WEAPONTYPE_UNARMED; m_currentWeapon = WEAPONTYPE_UNARMED;
m_fArmour = 0.0f; m_fArmour = 0.0f;

View File

@ -36,7 +36,7 @@ void CGangs::Initialise(void)
SetGangVehicleModel(GANG_BIKER, MI_ANGEL); SetGangVehicleModel(GANG_BIKER, MI_ANGEL);
SetGangVehicleModel(GANG_PLAYER, -1); SetGangVehicleModel(GANG_PLAYER, -1);
SetGangVehicleModel(GANG_GOLFER, MI_CADDY); SetGangVehicleModel(GANG_GOLFER, MI_CADDY);
//SetGangWeapons(GANG_GOLFER, WEAPONTYPE_GOLFCLUB, WEAPONTYPE_GOLFCLUB); // TODO(MIAMI) SetGangWeapons(GANG_GOLFER, WEAPONTYPE_GOLFCLUB, WEAPONTYPE_GOLFCLUB);
#ifdef FIX_BUGS #ifdef FIX_BUGS
for (int i = 0; i < NUM_GANGS; i++) for (int i = 0; i < NUM_GANGS; i++)
SetGangPedModelOverride(i, -1); SetGangPedModelOverride(i, -1);

View File

@ -116,32 +116,8 @@ uint16 nPlayerInComboMove;
RpClump *flyingClumpTemp; RpClump *flyingClumpTemp;
// This is beta fistfite.dat array. Not used anymore since they're being fetched from fistfite.dat.
FightMove tFightMoves[NUM_FIGHTMOVES] = { FightMove tFightMoves[NUM_FIGHTMOVES] = {
{NUM_ANIMS, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0}, // TODO(Miami)
{ANIM_PUNCH_R, 0.2f, 8.0f / 30.0f, 0.0f, 0.3f, HITLEVEL_HIGH, 1, 0},
{ANIM_FIGHT_IDLE, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_FIGHT_SH_F, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_FIGHT_KNEE, 4.0f / 30.0f, 0.2f, 0.0f, 0.6f, HITLEVEL_LOW, 2, 0},
{ANIM_FIGHT_HEAD, 4.0f / 30.0f, 0.2f, 0.0f, 0.7f, HITLEVEL_HIGH, 3, 0},
{ANIM_FIGHT_PUNCH, 4.0f / 30.0f, 7.0f / 30.0f, 10.0f / 30.0f, 0.4f, HITLEVEL_HIGH, 1, 0},
{ANIM_FIGHT_LHOOK, 8.0f / 30.0f, 10.0f / 30.0f, 0.0f, 0.4f, HITLEVEL_HIGH, 3, 0},
{ANIM_FIGHT_KICK, 8.0f / 30.0f, 10.0f / 30.0f, 0.0f, 0.5, HITLEVEL_MEDIUM, 2, 0},
{ANIM_FIGHT_LONGKICK, 8.0f / 30.0f, 10.0f / 30.0f, 0.0f, 0.5, HITLEVEL_MEDIUM, 4, 0},
{ANIM_FIGHT_ROUNDHOUSE, 8.0f / 30.0f, 10.0f / 30.0f, 0.0f, 0.6f, HITLEVEL_MEDIUM, 4, 0},
{ANIM_FIGHT_BODYBLOW, 5.0f / 30.0f, 7.0f / 30.0f, 0.0f, 0.35f, HITLEVEL_LOW, 2, 0},
{ANIM_KICK_FLOOR, 10.0f / 30.0f, 14.0f / 30.0f, 0.0f, 0.4f, HITLEVEL_GROUND, 1, 0},
{ANIM_HIT_FRONT, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_BACK, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_RIGHT, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_LEFT, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_BODYBLOW, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_CHEST, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_HEAD, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_WALK, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_FLOOR_HIT, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_HIT_BEHIND, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
{ANIM_FIGHT2_IDLE, 0.0f, 0.0f, 0.0f, 0.0f, HITLEVEL_NULL, 0, 0},
}; };
uint16 CPed::nThreatReactionRangeMultiplier = 1; uint16 CPed::nThreatReactionRangeMultiplier = 1;
@ -623,6 +599,8 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
bSomeVCflag1 = false; bSomeVCflag1 = false;
#endif #endif
m_gangFlags = 0xFF;
bReachedAttractorHeadingTarget = false; bReachedAttractorHeadingTarget = false;
bTurnedAroundOnAttractor = false; bTurnedAroundOnAttractor = false;
bCarPassenger = false; bCarPassenger = false;
@ -665,9 +643,16 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
GiveWeapon(WEAPONTYPE_UNARMED, 0, true); GiveWeapon(WEAPONTYPE_UNARMED, 0, true);
m_wepAccuracy = 60; m_wepAccuracy = 60;
m_lastWepDam = -1; m_lastWepDam = -1;
m_lastDamEntity = nil;
m_attachedTo = nil;
m_attachWepAmmo = 0;
m_collPoly.valid = false; m_collPoly.valid = false;
m_fCollisionSpeed = 0.0f; m_fCollisionSpeed = 0.0f;
m_wepModelID = -1; m_wepModelID = -1;
uint16 random = CGeneral::GetRandomNumber();
m_nPedMoney = random % 25;
if (m_nPedMoney == 23)
m_nPedMoney = 400;
#ifdef PED_SKIN #ifdef PED_SKIN
m_pWeaponModel = nil; m_pWeaponModel = nil;
#endif #endif
@ -1182,7 +1167,7 @@ CPed::FinishedReloadCB(CAnimBlendAssociation *reloadAssoc, void *arg)
if (ped->bIsDucking && ped->bCrouchWhenShooting) { if (ped->bIsDucking && ped->bCrouchWhenShooting) {
CAnimBlendAssociation *crouchFireAssoc = nil; CAnimBlendAssociation *crouchFireAssoc = nil;
if (!!weapon->m_bCrouchFire) { if (!!weapon->m_bCrouchFire) {
crouchFireAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), ANIM_WEAPON_CROUCHFIRE); crouchFireAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchFireAnim(weapon));
} }
if (!!weapon->m_bReload && reloadAssoc) { if (!!weapon->m_bReload && reloadAssoc) {
if (reloadAssoc->animId == GetCrouchReloadAnim(weapon) && !crouchFireAssoc) { if (reloadAssoc->animId == GetCrouchReloadAnim(weapon) && !crouchFireAssoc) {
@ -1221,7 +1206,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon)); reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon));
} }
if (currentWeapon->m_bCrouchFire && attackAssoc) { if (currentWeapon->m_bCrouchFire && attackAssoc) {
if (attackAssoc->animId == ANIM_WEAPON_CROUCHFIRE && !reloadAnimAssoc) { if (attackAssoc->animId == GetCrouchFireAnim(currentWeapon) && !reloadAnimAssoc) {
newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f); newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f);
newAnim->SetCurrentTime(newAnim->hierarchy->totalLength); newAnim->SetCurrentTime(newAnim->hierarchy->totalLength);
newAnim->flags &= ~ASSOC_RUNNING; newAnim->flags &= ~ASSOC_RUNNING;
@ -1247,7 +1232,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon)); reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon));
} }
if (currentWeapon->m_bCrouchFire && attackAssoc) { if (currentWeapon->m_bCrouchFire && attackAssoc) {
if (attackAssoc->animId == ANIM_WEAPON_CROUCHFIRE && !reloadAnimAssoc) { if (attackAssoc->animId == GetCrouchFireAnim(currentWeapon) && !reloadAnimAssoc) {
newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f); newAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f);
newAnim->SetCurrentTime(newAnim->hierarchy->totalLength); newAnim->SetCurrentTime(newAnim->hierarchy->totalLength);
newAnim->flags &= ~ASSOC_RUNNING; newAnim->flags &= ~ASSOC_RUNNING;
@ -1275,15 +1260,6 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg)
newAnim->SetFinishCallback(FinishedAttackCB, ped); newAnim->SetFinishCallback(FinishedAttackCB, ped);
} }
} else { } else {
// TODO(Miami): Remove this block when fighting has been ported
if (attackAssoc && attackAssoc->animId == ANIM_FIGHT_PPUNCH && currentWeapon->m_AnimToPlay == ASSOCGRP_STD)
{
attackAssoc->blendDelta = -8.0f;
attackAssoc->flags |= ASSOC_DELETEFADEDOUT;
ped->ClearAttack();
return;
}
if (attackAssoc && attackAssoc->animId == ANIM_MELEE_ATTACK && currentWeapon->m_AnimToPlay == ASSOCGRP_UNARMED) if (attackAssoc && attackAssoc->animId == ANIM_MELEE_ATTACK && currentWeapon->m_AnimToPlay == ASSOCGRP_UNARMED)
{ {
attackAssoc->blendDelta = -8.0f; attackAssoc->blendDelta = -8.0f;
@ -1342,7 +1318,7 @@ CPed::Attack(void)
if (bIsDucking) { if (bIsDucking) {
if (!!ourWeapon->m_bCrouchFire && bCrouchWhenShooting) { if (!!ourWeapon->m_bCrouchFire && bCrouchWhenShooting) {
weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHFIRE); weaponAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(ourWeapon));
if (weaponAnimAssoc) { if (weaponAnimAssoc) {
animLoopStart = ourWeapon->m_fAnim2LoopStart; animLoopStart = ourWeapon->m_fAnim2LoopStart;
animLoopEnd = ourWeapon->m_fAnim2LoopEnd; animLoopEnd = ourWeapon->m_fAnim2LoopEnd;
@ -1395,7 +1371,6 @@ CPed::Attack(void)
meleeAttackStarted = true; meleeAttackStarted = true;
switch ( ourWeapon->m_AnimToPlay ) { switch ( ourWeapon->m_AnimToPlay ) {
case ASSOCGRP_STD: // TODO(Miami): Remove that when weapons ported
case ASSOCGRP_UNARMED: case ASSOCGRP_UNARMED:
case ASSOCGRP_SCREWDRIVER: case ASSOCGRP_SCREWDRIVER:
case ASSOCGRP_KNIFE: case ASSOCGRP_KNIFE:
@ -1436,7 +1411,7 @@ CPed::Attack(void)
if (attackShouldContinue) { if (attackShouldContinue) {
if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) { if (ourWeaponFire != WEAPON_FIRE_PROJECTILE || !IsPlayer() || ((CPlayerPed*)this)->m_bHaveTargetSelected) {
if (bCrouchWhenShooting && bIsDucking && !!ourWeapon->m_bCrouchFire) { if (bCrouchWhenShooting && bIsDucking && !!ourWeapon->m_bCrouchFire) {
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, ANIM_WEAPON_CROUCHFIRE, 8.0f); weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, GetCrouchFireAnim(ourWeapon), 8.0f);
} else if(!!ourWeapon->m_bUse2nd && CGeneral::GetRandomNumber() & 1){ } else if(!!ourWeapon->m_bUse2nd && CGeneral::GetRandomNumber() & 1){
weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, ANIM_WEAPON_FIRE_2ND, 8.0f); weaponAnimAssoc = CAnimManager::BlendAnimation(GetClump(), ourWeapon->m_AnimToPlay, ANIM_WEAPON_FIRE_2ND, 8.0f);
@ -1498,9 +1473,7 @@ CPed::Attack(void)
if (ourWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE) { if (ourWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE) {
firePos = GetMatrix() * firePos; firePos = GetMatrix() * firePos;
} else { } else {
// TODO(Miami): Remove ANIM_KICK_FLOOR when fighting is done TransformToNode(firePos, (weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_2ND && ourWeapon->m_AnimToPlay == ASSOCGRP_UNARMED) ? PED_FOOTR : PED_HANDR);
TransformToNode(firePos, (weaponAnimAssoc->animId == ANIM_KICK_FLOOR ||
weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_2ND && ourWeapon->m_AnimToPlay == ASSOCGRP_UNARMED) ? PED_FOOTR : PED_HANDR);
} }
GetWeapon()->Fire(this, &firePos); GetWeapon()->Fire(this, &firePos);
@ -1520,10 +1493,8 @@ CPed::Attack(void)
damagerType = m_pDamageEntity->GetType(); damagerType = m_pDamageEntity->GetType();
} }
switch (ourWeapon->m_AnimToPlay) { switch (ourWeapon->m_AnimToPlay) {
case ASSOCGRP_STD: // TODO(Miami): Remove after fighting done
case ASSOCGRP_UNARMED: case ASSOCGRP_UNARMED:
if (weaponAnimAssoc->animId == ANIM_FIGHT_PPUNCH || // TODO(Miami): Remove after fighting done if (weaponAnimAssoc->animId == ANIM_MELEE_ATTACK || weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_START) {
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_PUNCH_39, 0.0f);
#else #else
@ -1782,15 +1753,19 @@ CPed::SetCurrentWeapon(int slot)
} }
} }
// --MIAMI: TODO when weapons got converted // --MIAMI: Done
// Only used while deciding which gun ped should switch to, if no ammo left. // Only used while deciding which gun ped should switch to, if no ammo left.
bool bool
CPed::SelectGunIfArmed(void) CPed::SelectGunIfArmed(void)
{ {
for (int i = 0; i < m_maxWeaponTypeAllowed; i++) { for (int i = 0; i < TOTAL_WEAPON_SLOTS; i++) {
if (GetWeapon(i).m_nAmmoTotal > 0) { if (GetWeapon(i).m_nAmmoTotal > 0) {
eWeaponType weaponType = GetWeapon(i).m_eWeaponType; eWeaponType weaponType = GetWeapon(i).m_eWeaponType;
if (weaponType >= WEAPONTYPE_COLT45 && weaponType != WEAPONTYPE_M16 && weaponType <= WEAPONTYPE_FLAMETHROWER) {
// 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_ROCKETLAUNCHER || weaponType == WEAPONTYPE_FLAMETHROWER || weaponType == WEAPONTYPE_SNIPERRIFLE) {
SetCurrentWeapon(i); SetCurrentWeapon(i);
return true; return true;
} }
@ -1800,39 +1775,54 @@ CPed::SelectGunIfArmed(void)
return false; return false;
} }
// --MIAMI: Done
void void
CPed::Duck(void) CPed::Duck(void)
{ {
if (CTimer::GetTimeInMilliseconds() > m_duckTimer) if (CTimer::GetTimeInMilliseconds() > m_duckTimer)
ClearDuck(); ClearDuck();
else if (bIsDucking && bCrouchWhenShooting) {
CWeaponInfo *weapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
CAnimBlendAssociation *attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCH);
if (!attackAssoc) {
if(!!weapon->m_bCrouchFire)
attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon));
}
if (!attackAssoc) {
if(!!weapon->m_bReload)
attackAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(weapon));
}
if (!attackAssoc) {
bIsDucking = false;
}
}
} }
// --MIAMI: Done
void void
CPed::ClearDuck(void) CPed::ClearDuck(bool clearTimer)
{ {
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_DOWN); CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_DOWN);
if (!animAssoc) { if (!animAssoc) {
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_LOW); animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_LOW);
if (!animAssoc) {
bIsDucking = false;
return;
}
} }
if (!bCrouchWhenShooting) if (!animAssoc) {
return; animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCH);
}
if (m_nPedState != PED_ATTACK && m_nPedState != PED_AIM_GUN) if (animAssoc) {
return; animAssoc->flags |= ASSOC_DELETEFADEDOUT;
animAssoc->blendDelta = -4.0f;
}
bIsDucking = false;
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_RBLOCK_CSHOOT); if (clearTimer) {
if (!animAssoc || animAssoc->blendDelta < 0.0f) { m_duckTimer = 0;
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_RBLOCK_CSHOOT, 4.0f);
} }
} }
// --MIAMI: Done except commented thing // --MIAMI: Done
void void
CPed::ClearPointGunAt(void) CPed::ClearPointGunAt(void)
{ {
@ -1853,7 +1843,7 @@ CPed::ClearPointGunAt(void)
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE); animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE);
if (!animAssoc || animAssoc->blendDelta < 0.0f) { if (!animAssoc || animAssoc->blendDelta < 0.0f) {
if (!!weaponInfo->m_bCrouchFire) { if (!!weaponInfo->m_bCrouchFire) {
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHFIRE); animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weaponInfo));
} }
} }
if (animAssoc) { if (animAssoc) {
@ -2692,7 +2682,7 @@ CPed::SetModelIndex(uint32 mi)
m_animGroup = (AssocGroupId) modelInfo->m_animGroup; m_animGroup = (AssocGroupId) modelInfo->m_animGroup;
CAnimManager::AddAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE); CAnimManager::AddAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE);
// TODO(Miami): This is something inlined for sure // TODO(Miami): This is inlined CanUseTorsoWhenLooking
bool canUseMyBody = false; bool canUseMyBody = false;
if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) { if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) {
if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN) if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN)
@ -2716,7 +2706,13 @@ CPed::SetModelIndex(uint32 mi)
void void
CPed::RemoveLighting(bool reset) CPed::RemoveLighting(bool reset)
{ {
CRenderer::RemoveVehiclePedLights(this, reset); if (!bRenderScorched) {
CRenderer::RemoveVehiclePedLights(this, reset);
if (reset)
ReSetAmbientAndDirectionalColours();
}
SetAmbientColours();
DeActivateDirectional();
} }
bool bool
@ -2781,14 +2777,15 @@ CPed::WorkOutHeadingForMovingFirstPerson(float offset)
angle = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown); angle = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown);
} else { } else {
if (leftRight < 0.0f) if (leftRight < 0.0f)
angle = 0.5f * PI; angle = HALFPI;
else if (leftRight > 0.0f) else if (leftRight > 0.0f)
angle = -0.5f * PI; angle = -HALFPI;
} }
return CGeneral::LimitRadianAngle(offset + angle); return CGeneral::LimitRadianAngle(offset + angle);
} }
// --MIAMI: Done
void void
CPed::CalculateNewVelocity(void) CPed::CalculateNewVelocity(void)
{ {
@ -2803,9 +2800,6 @@ CPed::CalculateNewVelocity(void)
limitedRotDest -= 2 * PI; limitedRotDest -= 2 * PI;
} }
if (IsPlayer() && m_nPedState == PED_ATTACK)
headAmount /= 4.0f;
float neededTurn = limitedRotDest - m_fRotationCur; float neededTurn = limitedRotDest - m_fRotationCur;
if (neededTurn <= headAmount) { if (neededTurn <= headAmount) {
if (neededTurn > (-headAmount)) if (neededTurn > (-headAmount))
@ -2829,8 +2823,12 @@ CPed::CalculateNewVelocity(void)
} }
if ((!TheCamera.Cams[TheCamera.ActiveCam].GetWeaponFirstPersonOn() && !TheCamera.Cams[0].Using3rdPersonMouseCam()) if ((!TheCamera.Cams[TheCamera.ActiveCam].GetWeaponFirstPersonOn() && !TheCamera.Cams[0].Using3rdPersonMouseCam())
|| FindPlayerPed() != this || !CanStrafeOrMouseControl()) || FindPlayerPed() != this || !CanStrafeOrMouseControl()) {
if (FindPlayerPed() == this)
FindPlayerPed()->m_fWalkAngle = 0.0f;
return; return;
}
float walkAngle = WorkOutHeadingForMovingFirstPerson(m_fRotationCur); float walkAngle = WorkOutHeadingForMovingFirstPerson(m_fRotationCur);
float pedSpeed = m_moved.Magnitude(); float pedSpeed = m_moved.Magnitude();
@ -2850,16 +2848,13 @@ CPed::CalculateNewVelocity(void)
CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_STANCE); CAnimBlendAssociation *idleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_STANCE);
CAnimBlendAssociation *fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); CAnimBlendAssociation *fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
#ifdef VC_PED_PORTS
if(!fightAssoc) if(!fightAssoc)
fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED); fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED);
// There is one more anim in VC. if(!fightAssoc)
fightAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHRELOAD);
if ((!idleAssoc || idleAssoc->blendAmount < 0.5f) && !fightAssoc && !bIsDucking) { if ((!idleAssoc || idleAssoc->blendAmount < 0.5f) && !fightAssoc && !bIsDucking) {
#else
if ((!idleAssoc || idleAssoc->blendAmount < 0.5f) && !fightAssoc) {
#endif
LimbOrientation newUpperLegs; LimbOrientation newUpperLegs;
newUpperLegs.yaw = localWalkAngle; newUpperLegs.yaw = localWalkAngle;
@ -3943,7 +3938,7 @@ CPed::ClearAttackByRemovingAnim(void)
if (!weaponAssoc) { if (!weaponAssoc) {
if (!!weapon->m_bCrouchFire) if (!!weapon->m_bCrouchFire)
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHFIRE); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weapon));
} }
if (!weaponAssoc) { if (!weaponAssoc) {
if(!!weapon->m_bFinish3rd) if(!!weapon->m_bFinish3rd)
@ -4915,7 +4910,7 @@ CPed::SetPointGunAt(CEntity *to)
if (bCrouchWhenShooting && bIsDucking) { if (bCrouchWhenShooting && bIsDucking) {
if (!!curWeapon->m_bCrouchFire) { if (!!curWeapon->m_bCrouchFire) {
aimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHFIRE); aimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(curWeapon));
} }
} else { } else {
aimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE); aimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE);
@ -4924,7 +4919,7 @@ CPed::SetPointGunAt(CEntity *to)
if (!aimAssoc || aimAssoc->blendDelta < 0.0f) { if (!aimAssoc || aimAssoc->blendDelta < 0.0f) {
if (bCrouchWhenShooting && bIsDucking) { if (bCrouchWhenShooting && bIsDucking) {
if (!!curWeapon->m_bCrouchFire) { if (!!curWeapon->m_bCrouchFire) {
aimAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_WEAPON_CROUCHFIRE, 4.0f); aimAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, GetCrouchFireAnim(curWeapon), 4.0f);
} }
} else { } else {
aimAssoc = CAnimManager::AddAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_WEAPON_FIRE); aimAssoc = CAnimManager::AddAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_WEAPON_FIRE);
@ -5196,7 +5191,7 @@ CPed::SetAttack(CEntity *victim)
} }
// TODO(Miami): Brass knuckles // TODO(Miami): Brass knuckles
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED || curWeapon->m_bFightMode /* || GetWeapon()->m_eWeaponType == WEAPONTYPE_BRASSKNUCKLES */) { if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED || curWeapon->m_bFightMode || GetWeapon()->m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE) {
if (IsPlayer() || if (IsPlayer() ||
(m_nPedState != PED_FIGHT && m_nMoveState != PEDMOVE_NONE && m_nMoveState != PEDMOVE_STILL (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->m_bPartialAttack)) {
@ -5208,10 +5203,7 @@ CPed::SetAttack(CEntity *victim)
m_nPedState = PED_ATTACK; m_nPedState = PED_ATTACK;
bIsAttacking = false; bIsAttacking = false;
// TODO(Miami): Revert when fighting got ported CAnimBlendAssociation *animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f);
animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay,
GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED ? ANIM_FIGHT_PPUNCH : ANIM_MELEE_ATTACK_START, 8.0f);
// CAnimBlendAssociation *animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_MELEE_ATTACK_START, 8.0f);
animAssoc->SetRun(); animAssoc->SetRun();
if (animAssoc->currentTime == animAssoc->hierarchy->totalLength) if (animAssoc->currentTime == animAssoc->hierarchy->totalLength)
animAssoc->SetCurrentTime(0.0f); animAssoc->SetCurrentTime(0.0f);
@ -5315,13 +5307,13 @@ CPed::SetAttack(CEntity *victim)
m_nPedState = PED_ATTACK; 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(), ANIM_WEAPON_CROUCHFIRE); CAnimBlendAssociation* curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(curWeapon));
if (curMoveAssoc) { if (curMoveAssoc) {
if (strcmp(CAnimManager::GetAnimAssociation(curWeapon->m_AnimToPlay, ANIM_WEAPON_CROUCHFIRE)->hierarchy->name, curMoveAssoc->hierarchy->name) != 0) { if (strcmp(CAnimManager::GetAnimAssociation(curWeapon->m_AnimToPlay, GetCrouchFireAnim(curWeapon))->hierarchy->name, curMoveAssoc->hierarchy->name) != 0) {
delete curMoveAssoc; delete curMoveAssoc;
} }
} }
animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, ANIM_WEAPON_CROUCHFIRE, 8.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), curWeapon->m_AnimToPlay, GetCrouchFireAnim(curWeapon), 8.0f);
} else { } else {
float animDelta = 8.0f; float animDelta = 8.0f;
if (curWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE) if (curWeapon->m_eWeaponFire == WEAPON_FIRE_MELEE)
@ -5441,10 +5433,11 @@ CPed::StartFightAttack(uint8 buttonPressure)
nPlayerInComboMove = 0; nPlayerInComboMove = 0;
} }
// --MIAMI: Done
void void
CPed::LoadFightData(void) CPed::LoadFightData(void)
{ {
float startFireTime, endFireTime, comboFollowOnTime, strikeRadius; float startFireTime, endFireTime, comboFollowOnTime, strikeRadius, extendReachMultiplier;
int damage, flags; int damage, flags;
char line[256], moveName[32], animName[32], hitLevel; char line[256], moveName[32], animName[32], hitLevel;
int moveId = 0; int moveId = 0;
@ -5473,12 +5466,13 @@ CPed::LoadFightData(void)
sscanf( sscanf(
&line[lp], &line[lp],
"%s %f %f %f %f %c %s %d %d", "%s %f %f %f %f %f %c %s %d %d",
moveName, moveName,
&startFireTime, &startFireTime,
&endFireTime, &endFireTime,
&comboFollowOnTime, &comboFollowOnTime,
&strikeRadius, &strikeRadius,
&extendReachMultiplier,
&hitLevel, &hitLevel,
animName, animName,
&damage, &damage,
@ -5491,6 +5485,7 @@ CPed::LoadFightData(void)
tFightMoves[moveId].endFireTime = endFireTime / 30.0f; tFightMoves[moveId].endFireTime = endFireTime / 30.0f;
tFightMoves[moveId].comboFollowOnTime = comboFollowOnTime / 30.0f; tFightMoves[moveId].comboFollowOnTime = comboFollowOnTime / 30.0f;
tFightMoves[moveId].strikeRadius = strikeRadius; tFightMoves[moveId].strikeRadius = strikeRadius;
tFightMoves[moveId].extendReachMultiplier = extendReachMultiplier;
tFightMoves[moveId].damage = damage; tFightMoves[moveId].damage = damage;
tFightMoves[moveId].flags = flags; tFightMoves[moveId].flags = flags;
@ -5514,11 +5509,14 @@ CPed::LoadFightData(void)
break; break;
} }
if (strncmp(animName, "null", 4) != 0) { if (strncmp(animName, "default", 8) != 0) {
animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, animName); if (strncmp(animName, "null", 5) != 0) {
tFightMoves[moveId].animId = (AnimationId)animAssoc->animId; animAssoc = CAnimManager::GetAnimAssociation(ASSOCGRP_STD, animName);
} else { tFightMoves[moveId].animId = (AnimationId)animAssoc->animId;
tFightMoves[moveId].animId = ANIM_WALK; }
else {
tFightMoves[moveId].animId = ANIM_WALK;
}
} }
moveId++; moveId++;
} }
@ -5611,6 +5609,7 @@ CPed::FightStrike(CVector &touchedNodePos)
damageMult *= m_pedStats->m_attackStrength; damageMult *= m_pedStats->m_attackStrength;
} }
/*
// Change direction if we used kick. // Change direction if we used kick.
if (m_lastFightMove == FIGHTMOVE_KICK) { if (m_lastFightMove == FIGHTMOVE_KICK) {
if (CGeneral::GetRandomNumber() & 1) { if (CGeneral::GetRandomNumber() & 1) {
@ -5618,7 +5617,7 @@ CPed::FightStrike(CVector &touchedNodePos)
if (direction > 3) if (direction > 3)
direction -= 4; direction -= 4;
} }
} } */
nearPed->ReactToAttack(this); nearPed->ReactToAttack(this);
// Mostly unused. if > 5, ANIM_HIT_WALK will be run, that's it. // Mostly unused. if > 5, ANIM_HIT_WALK will be run, that's it.
@ -6358,6 +6357,7 @@ CPed::CollideWithPed(CPed *collideWith)
} }
} }
// --MIAMI: Done except commented thing
void void
CPed::CreateDeadPedMoney(void) CPed::CreateDeadPedMoney(void)
{ {
@ -6365,29 +6365,31 @@ CPed::CreateDeadPedMoney(void)
return; return;
int skin = GetModelIndex(); int skin = GetModelIndex();
// TODO(Miami): New flag
if ((skin >= MI_COP && skin <= MI_FIREMAN) || CharCreatedBy == MISSION_CHAR || bInVehicle) if ((skin >= MI_COP && skin <= MI_FIREMAN) || CharCreatedBy == MISSION_CHAR || bInVehicle)
return; return;
int money = CGeneral::GetRandomNumber() % 60; int money = m_nPedMoney;
if (money < 10) if (money < 10)
return; return;
if (money == 43) CVector pickupPos = GetPosition();
money = 700; bool found;
int pickupCount = money / 40 + 1; int pickupCount = Min(money / 20 + 1, 7);
int moneyPerPickup = money / pickupCount; int moneyPerPickup = money / pickupCount;
for(int i = 0; i < pickupCount; i++) { for(int i = 0; i < pickupCount; i++) {
// (CGeneral::GetRandomNumber() % 256) * PI / 128 gives a float up to something TWOPI-ish. // (CGeneral::GetRandomNumber() % 256) * PI / 128 gives a float up to something TWOPI-ish.
float pickupX = 1.5f * Sin((CGeneral::GetRandomNumber() % 256) * PI / 128) + GetPosition().x; pickupPos.x += 1.5f * Sin((CGeneral::GetRandomNumber() % 256) * PI / 128);
float pickupY = 1.5f * Cos((CGeneral::GetRandomNumber() % 256) * PI / 128) + GetPosition().y; pickupPos.y += 1.5f * Cos((CGeneral::GetRandomNumber() % 256) * PI / 128);
bool found = false; pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
float groundZ = CWorld::FindGroundZFor3DCoord(pickupX, pickupY, GetPosition().z, &found) + 0.5f;
if (found) { if (found) {
CPickups::GenerateNewOne(CVector(pickupX, pickupY, groundZ), MI_MONEY, PICKUP_MONEY, moneyPerPickup + (CGeneral::GetRandomNumber() & 7)); CPickups::GenerateNewOne(CVector(pickupPos.x, pickupPos.y, pickupPos.z), MI_MONEY, PICKUP_MONEY, moneyPerPickup + (CGeneral::GetRandomNumber() & 3));
} }
} }
m_nPedMoney = 0;
} }
void void
@ -6558,13 +6560,6 @@ CPed::RemoveWeaponAnims(int unused, float animDelta)
CAnimBlendAssociation *weaponAssoc; CAnimBlendAssociation *weaponAssoc;
//CWeaponInfo::GetWeaponInfo(unused); //CWeaponInfo::GetWeaponInfo(unused);
// TODO(Miami): Remove when fighting got ported
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_PPUNCH);
if (weaponAssoc) {
weaponAssoc->blendDelta = animDelta;
weaponAssoc->flags |= ASSOC_DELETEFADEDOUT;
}
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE);
if (weaponAssoc) { if (weaponAssoc) {
weaponAssoc->blendDelta = animDelta; weaponAssoc->blendDelta = animDelta;
@ -6725,6 +6720,7 @@ CPed::DoesLOSBulletHitPed(CColPoint &colPoint)
return retVal; return retVal;
} }
// TODO(Miami): Ducking doesn't work, fix this
bool bool
CPed::DuckAndCover(void) CPed::DuckAndCover(void)
{ {
@ -6742,9 +6738,11 @@ CPed::DuckAndCover(void)
SetAimFlag(m_pedInObjective); SetAimFlag(m_pedInObjective);
} else { } else {
bCrouchWhenShooting = false;
bKindaStayInSamePlace = false; bKindaStayInSamePlace = false;
bIsDucking = false; if (bIsDucking)
ClearDuck(true);
bCrouchWhenShooting = false;
bDuckAndCover = false; bDuckAndCover = false;
m_headingRate = 10.0f; m_headingRate = 10.0f;
m_duckAndCoverTimer = CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(20000,30000); m_duckAndCoverTimer = CTimer::GetTimeInMilliseconds() + CGeneral::GetRandomNumberInRange(20000,30000);
@ -6757,8 +6755,11 @@ CPed::DuckAndCover(void)
bool justDucked = false; bool justDucked = false;
CVehicle *foundVeh = nil; CVehicle *foundVeh = nil;
float maxDist = 225.0f; float maxDist = 225.0f;
bIsDucking = false; if (bIsDucking)
ClearDuck(true);
bCrouchWhenShooting = false; bCrouchWhenShooting = false;
if (CTimer::GetTimeInMilliseconds() > m_leaveCarTimer) { if (CTimer::GetTimeInMilliseconds() > m_leaveCarTimer) {
CVector pos = GetPosition(); CVector pos = GetPosition();
int16 lastVehicle; int16 lastVehicle;
@ -7147,13 +7148,9 @@ CPed::Fight(void)
case FIGHTMOVE_KNEE: case FIGHTMOVE_KNEE:
TransformToNode(touchingNodePos, PED_LOWERLEGR); TransformToNode(touchingNodePos, PED_LOWERLEGR);
break; break;
case FIGHTMOVE_HEADBUTT:
TransformToNode(touchingNodePos, PED_HEAD);
break;
case FIGHTMOVE_PUNCHJAB: case FIGHTMOVE_PUNCHJAB:
TransformToNode(touchingNodePos, PED_HANDL); TransformToNode(touchingNodePos, PED_HANDL);
break; break;
case FIGHTMOVE_KICK:
case FIGHTMOVE_LONGKICK: case FIGHTMOVE_LONGKICK:
case FIGHTMOVE_ROUNDHOUSE: case FIGHTMOVE_ROUNDHOUSE:
case FIGHTMOVE_GROUNDKICK: case FIGHTMOVE_GROUNDKICK:
@ -7214,12 +7211,12 @@ CPed::Fight(void)
canRoundhouse = false; canRoundhouse = false;
punchOnly = false; punchOnly = false;
canKick = true; canKick = true;
nextFightMove = (m_fightButtonPressure > 190 ? FIGHTMOVE_HEADBUTT : FIGHTMOVE_KNEE); nextFightMove = (m_fightButtonPressure > 190 ? FIGHTMOVE_BODYBLOW : FIGHTMOVE_KNEE);
hasShoppingBags = false; hasShoppingBags = false;
canKneeHead = true; canKneeHead = true;
nPlayerInComboMove = 0; nPlayerInComboMove = 0;
} else { } else {
nextFightMove = (m_fightButtonPressure > 120 ? FIGHTMOVE_HEADBUTT : FIGHTMOVE_KNEE); nextFightMove = (m_fightButtonPressure > 120 ? FIGHTMOVE_BODYBLOW : FIGHTMOVE_KNEE);
uint16 pedFeatures = m_pedStats->m_flags; uint16 pedFeatures = m_pedStats->m_flags;
punchOnly = pedFeatures & STAT_PUNCH_ONLY; punchOnly = pedFeatures & STAT_PUNCH_ONLY;
canRoundhouse = pedFeatures & STAT_CAN_ROUNDHOUSE; canRoundhouse = pedFeatures & STAT_CAN_ROUNDHOUSE;
@ -7258,7 +7255,7 @@ CPed::Fight(void)
&& neededTurn < DEGTORAD(35.0f) && neededTurn < DEGTORAD(35.0f)
&& (canKick || hasShoppingBags)) { && (canKick || hasShoppingBags)) {
nextFightMove = FIGHTMOVE_KICK; nextFightMove = FIGHTMOVE_LONGKICK;
if (hasShoppingBags) { if (hasShoppingBags) {
nextFightMove = FIGHTMOVE_ROUNDHOUSE; nextFightMove = FIGHTMOVE_ROUNDHOUSE;
} else if (canRoundhouse && CGeneral::GetRandomNumber() & 1) { } else if (canRoundhouse && CGeneral::GetRandomNumber() & 1) {
@ -7351,7 +7348,7 @@ CPed::Fight(void)
if (fightingPedDist >= 1.3f) { if (fightingPedDist >= 1.3f) {
if (fightingPedDist < 1.7f && canKick) { if (fightingPedDist < 1.7f && canKick) {
nextFightMove = FIGHTMOVE_KICK; nextFightMove = FIGHTMOVE_LONGKICK;
if (canRoundhouse && CGeneral::GetRandomNumber() & 1) if (canRoundhouse && CGeneral::GetRandomNumber() & 1)
nextFightMove = FIGHTMOVE_ROUNDHOUSE; nextFightMove = FIGHTMOVE_ROUNDHOUSE;
@ -9328,7 +9325,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
void void
CPed::Look(void) CPed::Look(void)
{ {
// UNUSED: This is a perfectly empty function. TurnBody();
} }
bool bool
@ -11269,6 +11266,7 @@ CPed::SetInTheAir(void)
void void
CPed::RestoreHeadPosition(void) CPed::RestoreHeadPosition(void)
{ {
// TODO(Miami): This is inlined CanUseTorsoWhenLooking
bool canUseMyBody = false; bool canUseMyBody = false;
if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) { if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) {
if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN) if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN)
@ -11298,7 +11296,7 @@ CPed::PointGunAt(void)
CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE); CAnimBlendAssociation *weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_FIRE);
if (!weaponAssoc || weaponAssoc->blendDelta < 0.0f) { if (!weaponAssoc || weaponAssoc->blendDelta < 0.0f) {
if (!!weaponInfo->m_bCrouchFire) { if (!!weaponInfo->m_bCrouchFire) {
weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHFIRE); weaponAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchFireAnim(weaponInfo));
animLoopStart = weaponInfo->m_fAnim2LoopStart; animLoopStart = weaponInfo->m_fAnim2LoopStart;
} }
} }
@ -15626,19 +15624,22 @@ CPed::SetEnterTrain(CVehicle *train, uint32 unused)
} }
#endif #endif
// --MIAMI: Done, but what is this parameter for?
void void
CPed::SetDuck(uint32 time) CPed::SetDuck(uint32 time, bool sth)
{ {
if (bIsDucking || CTimer::GetTimeInMilliseconds() <= m_duckTimer) if (bIsDucking || CTimer::GetTimeInMilliseconds() <= m_duckTimer && !sth) {
return; if (sth && CTimer::GetTimeInMilliseconds() + time > m_duckTimer)
if (bCrouchWhenShooting && (m_nPedState == PED_ATTACK || m_nPedState == PED_AIM_GUN)) {
CAnimBlendAssociation *duckAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_LOW);
if (!duckAssoc || duckAssoc->blendDelta < 0.0f) {
CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_DUCK_LOW, 4.0f);
bIsDucking = true;
m_duckTimer = CTimer::GetTimeInMilliseconds() + time; m_duckTimer = CTimer::GetTimeInMilliseconds() + time;
} return;
}
CAnimBlendAssociation *duckAssoc;
if (bCrouchWhenShooting) {
duckAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 4.0f);
duckAssoc->flags &= ~ASSOC_FADEOUTWHENDONE;
bIsDucking = true;
m_duckTimer = CTimer::GetTimeInMilliseconds() + time;
} else { } else {
CAnimBlendAssociation *duckAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_DOWN); CAnimBlendAssociation *duckAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_DOWN);
if (!duckAssoc || duckAssoc->blendDelta < 0.0f) { if (!duckAssoc || duckAssoc->blendDelta < 0.0f) {
@ -18561,7 +18562,7 @@ CPed::ClearFollowPath()
m_nCurPathNode = 0; m_nCurPathNode = 0;
} }
// --MIAMI: Done // --MIAMI: Done except bikes
void void
CPed::AddInCarAnims(CVehicle* car, bool isDriver) CPed::AddInCarAnims(CVehicle* car, bool isDriver)
{ {
@ -18601,6 +18602,12 @@ CPed::AddInCarAnims(CVehicle* car, bool isDriver)
StopNonPartialAnims(); StopNonPartialAnims();
} }
bool
CPed::CanBeDamagedByThisGangMember(CPed* who)
{
return m_gangFlags & (1 << (uint8)(who->m_nPedType - PEDTYPE_GANG1));
}
bool bool
IsPedPointerValid_NotInWorld(CPed* pPed) IsPedPointerValid_NotInWorld(CPed* pPed)
{ {
@ -18624,4 +18631,4 @@ IsPedPointerValid(CPed* pPed)
if (pPed->bInVehicle && pPed->m_pMyVehicle) if (pPed->bInVehicle && pPed->m_pMyVehicle)
return IsEntityPointerValid(pPed->m_pMyVehicle); return IsEntityPointerValid(pPed->m_pMyVehicle);
return pPed->m_entryInfoList.first || pPed == FindPlayerPed(); return pPed->m_entryInfoList.first || pPed == FindPlayerPed();
} }

View File

@ -79,11 +79,11 @@ struct FightMove
float endFireTime; float endFireTime;
float comboFollowOnTime; float comboFollowOnTime;
float strikeRadius; float strikeRadius;
float extendReachMultiplier;
uint8 hitLevel; // FightMoveHitLevel uint8 hitLevel; // FightMoveHitLevel
uint8 damage; uint8 damage;
uint8 flags; uint8 flags;
}; };
VALIDATE_SIZE(FightMove, 0x18);
// TODO: This is eFightState on mobile. // TODO: This is eFightState on mobile.
enum PedFightMoves enum PedFightMoves
@ -94,13 +94,21 @@ enum PedFightMoves
FIGHTMOVE_IDLE, FIGHTMOVE_IDLE,
FIGHTMOVE_SHUFFLE_F, FIGHTMOVE_SHUFFLE_F,
FIGHTMOVE_KNEE, FIGHTMOVE_KNEE,
FIGHTMOVE_HEADBUTT,
FIGHTMOVE_PUNCHJAB,
FIGHTMOVE_PUNCHHOOK, FIGHTMOVE_PUNCHHOOK,
FIGHTMOVE_KICK, FIGHTMOVE_PUNCHJAB,
FIGHTMOVE_PUNCH,
FIGHTMOVE_BODYBLOW = FIGHTMOVE_PUNCH,
FIGHTMOVE_LONGKICK, FIGHTMOVE_LONGKICK,
FIGHTMOVE_ROUNDHOUSE, FIGHTMOVE_ROUNDHOUSE,
FIGHTMOVE_BODYBLOW, // Directionals
FIGHTMOVE_FWDLEFT,
FIGHTMOVE_FWDRIGHT,
FIGHTMOVE_BACKKICK,
FIGHTMOVE_BACKFLIP,
FIGHTMOVE_BACKLEFT,
FIGHTMOVE_BACKRIGHT,
FIGHTMOVE_RIGHTSWEEP,
// Special
FIGHTMOVE_GROUNDKICK, FIGHTMOVE_GROUNDKICK,
// Opponent // Opponent
FIGHTMOVE_HITFRONT, FIGHTMOVE_HITFRONT,
@ -113,6 +121,9 @@ enum PedFightMoves
FIGHTMOVE_HITBIGSTEP, FIGHTMOVE_HITBIGSTEP,
FIGHTMOVE_HITONFLOOR, FIGHTMOVE_HITONFLOOR,
FIGHTMOVE_HITBEHIND, FIGHTMOVE_HITBEHIND,
FIGHTMOVE_MELEE1,
FIGHTMOVE_MELEE2,
FIGHTMOVE_MELEE3,
FIGHTMOVE_IDLE2NORM, FIGHTMOVE_IDLE2NORM,
NUM_FIGHTMOVES NUM_FIGHTMOVES
}; };
@ -435,6 +446,7 @@ public:
uint32 bMiamiViceCop : 1; // 0x155 0x20 uint32 bMiamiViceCop : 1; // 0x155 0x20
uint32 bDeadPedInFrontOfCar : 1; // 0x156 0x40 uint32 bDeadPedInFrontOfCar : 1; // 0x156 0x40
uint8 m_gangFlags;
uint8 CharCreatedBy; uint8 CharCreatedBy;
eObjective m_objective; eObjective m_objective;
eObjective m_prevObjective; eObjective m_prevObjective;
@ -557,7 +569,7 @@ public:
int8 m_bodyPartBleeding; // PedNode, but -1 if there isn't int8 m_bodyPartBleeding; // PedNode, but -1 if there isn't
CPed *m_nearPeds[10]; CPed *m_nearPeds[10];
uint16 m_numNearPeds; uint16 m_numNearPeds;
uint16 m_pedMoney; uint16 m_nPedMoney;
int8 m_lastWepDam; int8 m_lastWepDam;
CEntity *m_lastDamEntity; CEntity *m_lastDamEntity;
CEntity *m_attachedTo; CEntity *m_attachedTo;
@ -620,7 +632,7 @@ public:
void SetCurrentWeapon(eWeaponType weaponType); void SetCurrentWeapon(eWeaponType weaponType);
void SetCurrentWeapon(int weapon); void SetCurrentWeapon(int weapon);
void Duck(void); void Duck(void);
void ClearDuck(void); void ClearDuck(bool = false);
void ClearPointGunAt(void); void ClearPointGunAt(void);
void BeingDraggedFromCar(void); void BeingDraggedFromCar(void);
void RestartNonPartialAnims(void); void RestartNonPartialAnims(void);
@ -648,7 +660,7 @@ public:
void ClearChat(void); void ClearChat(void);
void InformMyGangOfAttack(CEntity*); void InformMyGangOfAttack(CEntity*);
void ReactToAttack(CEntity*); void ReactToAttack(CEntity*);
void SetDuck(uint32); void SetDuck(uint32, bool = false);
void RegisterThreatWithGangPeds(CEntity*); void RegisterThreatWithGangPeds(CEntity*);
bool TurnBody(void); bool TurnBody(void);
void Chat(void); void Chat(void);
@ -777,6 +789,7 @@ public:
void GiveDelayedWeapon(eWeaponType weapon, uint32 ammo); void GiveDelayedWeapon(eWeaponType weapon, uint32 ammo);
void RequestDelayedWeapon(); void RequestDelayedWeapon();
void AddInCarAnims(CVehicle* car, bool isDriver); void AddInCarAnims(CVehicle* car, bool isDriver);
bool CanBeDamagedByThisGangMember(CPed*);
// Static methods // Static methods
static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset); static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset);
@ -877,7 +890,7 @@ public:
bool Dead(void) { return m_nPedState == PED_DEAD; } bool Dead(void) { return m_nPedState == PED_DEAD; }
bool Dying(void) { return m_nPedState == PED_DIE; } bool Dying(void) { return m_nPedState == PED_DIE; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD || m_nWaitState == WAITSTATE_SUN_BATHE_IDLE; } bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool Driving(void) { return m_nPedState == PED_DRIVING; } bool Driving(void) { return m_nPedState == PED_DRIVING; }
bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state. bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state.
@ -895,10 +908,6 @@ public:
// My names. Inlined in VC // My names. Inlined in VC
AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) { AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) {
// TODO(Miami): Revert that when weapons got ported
if (weapon->m_AnimToPlay == ASSOCGRP_STD)
return ANIM_FIGHT_PPUNCH;
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
@ -906,14 +915,10 @@ public:
} }
static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) { static AnimationId GetFireAnimGround(CWeaponInfo* weapon, bool kickFloorIfNone = true) {
// TODO(Miami): Revert that when weapons got ported
if (weapon->m_AnimToPlay == ASSOCGRP_STD)
return ANIM_KICK_FLOOR;
if (!!weapon->m_bGround2nd) if (!!weapon->m_bGround2nd)
return ANIM_WEAPON_CROUCHFIRE; return ANIM_WEAPON_CROUCHFIRE;
else if (!!weapon->m_bGround3rd) else if (!!weapon->m_bGround3rd)
return ANIM_WEAPON_SPECIAL; return ANIM_WEAPON_FIRE_3RD;
else if (kickFloorIfNone) else if (kickFloorIfNone)
return ANIM_KICK_FLOOR; return ANIM_KICK_FLOOR;
else else
@ -921,10 +926,6 @@ public:
} }
static AnimationId GetPrimaryFireAnim(CWeaponInfo* weapon) { 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) if (weapon->m_bAnimDetonate)
return ANIM_BOMBER; return ANIM_BOMBER;
else else
@ -938,6 +939,13 @@ public:
return (AnimationId)0; return (AnimationId)0;
} }
static AnimationId GetCrouchFireAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bCrouchFire)
return ANIM_WEAPON_CROUCHFIRE;
else
return (AnimationId)0;
}
static AnimationId GetReloadAnim(CWeaponInfo* weapon) { static AnimationId GetReloadAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bReload) if (!!weapon->m_bReload)
return ANIM_WEAPON_RELOAD; return ANIM_WEAPON_RELOAD;

View File

@ -12,7 +12,7 @@ const int gcMaxSizeOfPizzaQueue = 5;
const int gcMaxSizeOfShelterQueue = 5; const int gcMaxSizeOfShelterQueue = 5;
const int gcMaxSizeOfIceCreamQueue = 1; const int gcMaxSizeOfIceCreamQueue = 1;
//--MIAMI: file done, except TODO(MIAMI) //--MIAMI: file done
std::vector<CVector> CPedShelterAttractor::ms_displacements; std::vector<CVector> CPedShelterAttractor::ms_displacements;
@ -167,19 +167,15 @@ CPedAttractor::CPedAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 ma
void CPedPizzaAttractor::UpdatePedStateOnDeparture(CPed* pPed) const void CPedPizzaAttractor::UpdatePedStateOnDeparture(CPed* pPed) const
{ {
/* TODO(MIAMI): uncomment
if (pPed->m_nPedMoney > 10) if (pPed->m_nPedMoney > 10)
pPed->m_nPedMoney -= 10; pPed->m_nPedMoney -= 10;
else else
pPed->m_nPedMoney = 0; pPed->m_nPedMoney = 0;
*/
} }
void CPedAtmAttractor::UpdatePedStateOnDeparture(CPed* pPed) const void CPedAtmAttractor::UpdatePedStateOnDeparture(CPed* pPed) const
{ {
/* TODO(MIAMI): uncomment
pPed->m_nPedMoney += 20 * CGeneral::GetRandomNumberInRange(1, 51); pPed->m_nPedMoney += 20 * CGeneral::GetRandomNumberInRange(1, 51);
*/
}; };
float CPedAttractor::ComputeDeltaHeading() const float CPedAttractor::ComputeDeltaHeading() const

View File

@ -1088,6 +1088,7 @@ CPlayerPed::ProcessAnimGroups(void)
} }
} }
// TODO(Miami): Hella TODO
void void
CPlayerPed::ProcessPlayerWeapon(CPad *padUsed) CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
{ {
@ -1099,8 +1100,9 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
} }
if (!m_pFire) { if (!m_pFire) {
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER || if (GetWeapon()->m_eWeaponType == WEAPONTYPE_ROCKETLAUNCHER ||
GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) { GetWeapon()->m_eWeaponType == WEAPONTYPE_SNIPERRIFLE || GetWeapon()->m_eWeaponType == WEAPONTYPE_M16 ||
if (padUsed->TargetJustDown()) { GetWeapon()->m_eWeaponType == WEAPONTYPE_AK47) {
if (padUsed->TargetJustDown() || TheCamera.m_bJustJumpedOutOf1stPersonBecauseOfTarget) {
SetStoredState(); SetStoredState();
m_nPedState = PED_SNIPER_MODE; m_nPedState = PED_SNIPER_MODE;
#ifdef FREE_CAM #ifdef FREE_CAM
@ -1134,7 +1136,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
else else
#endif #endif
SetAttack(m_pPointGunAt); SetAttack(m_pPointGunAt);
} else if (m_currentWeapon != WEAPONTYPE_UNARMED) { } else {
if (m_nPedState == PED_ATTACK) { if (m_nPedState == PED_ATTACK) {
if (padUsed->WeaponJustDown()) { if (padUsed->WeaponJustDown()) {
m_bHaveTargetSelected = true; m_bHaveTargetSelected = true;
@ -1145,12 +1147,19 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fAttackButtonCounter = 0.0f; m_fAttackButtonCounter = 0.0f;
m_bHaveTargetSelected = false; m_bHaveTargetSelected = false;
} }
SetAttack(nil); if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED && GetWeapon()->m_eWeaponType != WEAPONTYPE_BRASSKNUCKLE &&
} else if (padUsed->WeaponJustDown()) { !weaponInfo->m_bFightMode) {
if (m_fMoveSpeed < 1.0f)
StartFightAttack(padUsed->GetWeapon()); if (GetWeapon()->m_eWeaponType != WEAPONTYPE_DETONATOR && GetWeapon()->m_eWeaponType != WEAPONTYPE_DETONATOR_GRENADE ||
else padUsed->WeaponJustDown())
SetAttack(nil);
SetAttack(nil);
} else if (padUsed->WeaponJustDown()) {
if (m_fMoveSpeed < 1.0f || m_nPedState == PED_FIGHT)
StartFightAttack(padUsed->GetWeapon());
else
SetAttack(nil);
}
} }
} }
} else { } else {
@ -1185,7 +1194,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
#endif #endif
} else { } else {
m_fRotationDest = limitedCam; m_fRotationDest = limitedCam;
m_headingRate = 50.0f; m_headingRate = 12.5f;
// Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly) // Anim. fix for shotgun, ak47 and m16 (we must finish rot. it quickly)
if (weaponInfo->m_bCanAim && padUsed->WeaponJustDown()) { if (weaponInfo->m_bCanAim && padUsed->WeaponJustDown()) {

View File

@ -461,17 +461,16 @@ CPopulation::AddPed(ePedType pedType, uint32 miOrCopType, CVector const &coors,
if (ms_bGivePedsWeapons) { if (ms_bGivePedsWeapons) {
eWeaponType weapon; eWeaponType weapon;
// TODO(Miami): Look here when weapons have been ported
switch (CGeneral::GetRandomNumber() & 3) { switch (CGeneral::GetRandomNumber() & 3) {
case 0: case 0:
weapon = WEAPONTYPE_COLT45; weapon = WEAPONTYPE_COLT45;
break; break;
case 1: case 1:
//weapon = WEAPONTYPE_NIGHTSTICK; weapon = WEAPONTYPE_NIGHTSTICK;
//break; break;
case 2: case 2:
//weapon = WEAPONTYPE_GOLFCLUB; weapon = WEAPONTYPE_GOLFCLUB;
//break; break;
case 3: case 3:
weapon = WEAPONTYPE_TEC9; weapon = WEAPONTYPE_TEC9;
break; break;
@ -1079,8 +1078,7 @@ CPopulation::AddDeadPedInFrontOfCar(const CVector& pos, CVehicle* pCulprit)
return nil; return nil;
CPed* pPed = CPopulation::AddPed(PEDTYPE_CIVMALE, MI_MALE01, pos); // TODO(MIAMI): 4th parameter CPed* pPed = CPopulation::AddPed(PEDTYPE_CIVMALE, MI_MALE01, pos); // TODO(MIAMI): 4th parameter
pPed->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f); pPed->SetDie(ANIM_KO_SHOT_FRONT1, 4.0f, 0.0f);
//TODO(MIAMI): uncomment pPed->m_nPedMoney = 0;
//pPed->m_nPedMoney = 0;
pPed->bDeadPedInFrontOfCar = true; pPed->bDeadPedInFrontOfCar = true;
pPed->m_vehicleInAccident = pCulprit; pPed->m_vehicleInAccident = pCulprit;
pCulprit->RegisterReference((CEntity**)&pPed->m_vehicleInAccident); pCulprit->RegisterReference((CEntity**)&pPed->m_vehicleInAccident);
@ -1094,7 +1092,7 @@ CPopulation::AddDeadPedInFrontOfCar(const CVector& pos, CVehicle* pCulprit)
} }
} }
} }
CColPoint colpts[32]; CColPoint colpts[MAX_COLLISION_POINTS];
if (CCollision::ProcessColModels(pCulprit->GetMatrix(), *pCulprit->GetColModel(), pPed->GetMatrix(), *pPed->GetColModel(), colpts, nil, nil)) { if (CCollision::ProcessColModels(pCulprit->GetMatrix(), *pCulprit->GetColModel(), pPed->GetMatrix(), *pPed->GetColModel(), colpts, nil, nil)) {
CWorld::Remove(pPed); CWorld::Remove(pPed);
delete pPed; delete pPed;

View File

@ -88,6 +88,21 @@ float CHud::PagerXOffset;
int16 CHud::PagerTimer; int16 CHud::PagerTimer;
int16 CHud::PagerOn; int16 CHud::PagerOn;
uint32 CHud::m_WantedFadeTimer;
uint32 CHud::m_WantedState;
uint32 CHud::m_WantedTimer;
uint32 CHud::m_EnergyLostFadeTimer;
uint32 CHud::m_EnergyLostState;
uint32 CHud::m_EnergyLostTimer;
uint32 CHud::m_DisplayScoreFadeTimer;
uint32 CHud::m_DisplayScoreState;
uint32 CHud::m_DisplayScoreTimer;
uint32 CHud::m_WeaponFadeTimer;
uint32 CHud::m_WeaponState;
uint32 CHud::m_WeaponTimer;
uint32 CHud::m_LastDisplayScore;
CSprite2d CHud::Sprites[NUM_HUD_SPRITES]; CSprite2d CHud::Sprites[NUM_HUD_SPRITES];
struct struct
@ -125,6 +140,10 @@ RwTexture *gpRocketSightTex;
void CHud::Draw() void CHud::Draw()
{ {
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERNEAREST);
RwRenderStateSet(rwRENDERSTATETEXTUREADDRESS, (void*)rwTEXTUREADDRESSCLAMP);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
// disable hud via second controller // disable hud via second controller
if (CPad::GetPad(1)->GetStartJustDown()) if (CPad::GetPad(1)->GetStartJustDown())
m_Wants_To_Draw_Hud = !m_Wants_To_Draw_Hud; m_Wants_To_Draw_Hud = !m_Wants_To_Draw_Hud;
@ -136,22 +155,29 @@ void CHud::Draw()
bool DrawCrossHair = 0; bool DrawCrossHair = 0;
bool DrawCrossHairPC = 0; bool DrawCrossHairPC = 0;
int32 WeaponType = FindPlayerPed()->m_weapons[FindPlayerPed()->m_currentWeapon].m_eWeaponType; CPlayerPed *playerPed = FindPlayerPed();
eWeaponType WeaponType = playerPed->GetWeapon()->m_eWeaponType;
int32 Mode = TheCamera.Cams[TheCamera.ActiveCam].Mode; int32 Mode = TheCamera.Cams[TheCamera.ActiveCam].Mode;
if (Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_HELICANNON_1STPERSON) // TODO(Miami): New cam mode
DrawCrossHair = 1; if ((Mode == CCam::MODE_SNIPER || Mode == CCam::MODE_ROCKETLAUNCHER || Mode == CCam::MODE_M16_1STPERSON || Mode == CCam::MODE_HELICANNON_1STPERSON/* || Mode == 46*/)
if (Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || Mode == CCam::MODE_SNIPER_RUNABOUT) && playerPed && !playerPed->GetWeapon()->IsTypeMelee())
DrawCrossHairPC = 1; DrawCrossHair = true;
/* if (Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_ROCKETLAUNCHER_RUNABOUT || Mode == CCam::MODE_SNIPER_RUNABOUT)
Draw Crosshairs DrawCrossHairPC = true;
*/ if (TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam() && (!CPad::GetPad(0)->GetLookBehindForPed() || TheCamera.m_bPlayerIsInGarage)
if (TheCamera.Cams[TheCamera.ActiveCam].Using3rdPersonMouseCam() && || Mode == CCam::MODE_1STPERSON_RUNABOUT) {
(!CPad::GetPad(0)->GetLookBehindForPed() || TheCamera.m_bPlayerIsInGarage) || Mode == CCam::MODE_1STPERSON_RUNABOUT) { if (playerPed) {
if (FindPlayerPed() && !FindPlayerPed()->EnteringCar()) { if (playerPed->m_nPedState != PED_ENTER_CAR && playerPed->m_nPedState != PED_CARJACK) {
if ((WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_M16) || WeaponType == WEAPONTYPE_FLAMETHROWER)
DrawCrossHairPC = 1; // TODO(Miami): Uncomment
if (WeaponType >= WEAPONTYPE_COLT45 && WeaponType <= WEAPONTYPE_AK47
/*|| WeaponType == WEAPONTYPE_M60 || || WeaponType == WEAPONTYPE_MINIGUN */
|| WeaponType == WEAPONTYPE_FLAMETHROWER) {
DrawCrossHairPC = 1;
}
}
} }
} }
@ -171,7 +197,8 @@ void CHud::Draw()
#ifdef ASPECT_RATIO_SCALE #ifdef ASPECT_RATIO_SCALE
f3rdY -= SCREEN_SCALE_Y(2.0f); f3rdY -= SCREEN_SCALE_Y(2.0f);
#endif #endif
if (FindPlayerPed() && WeaponType == WEAPONTYPE_M16) { // TODO(Miami): M60
if (playerPed && (WeaponType == WEAPONTYPE_M16 || WeaponType == WEAPONTYPE_AK47/* || WeaponType == WEAPONTYPE_M60*/)) {
rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f); rect.left = f3rdX - SCREEN_SCALE_X(32.0f * 0.6f);
rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f); rect.top = f3rdY - SCREEN_SCALE_Y(32.0f * 0.6f);
rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f); rect.right = f3rdX + SCREEN_SCALE_X(32.0f * 0.6f);
@ -187,8 +214,7 @@ void CHud::Draw()
Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); Sprites[HUD_SITEM16].Draw(CRect(rect), CRGBA(255, 255, 255, 255));
} }
} } else {
else {
if (Mode == CCam::MODE_M16_1STPERSON || if (Mode == CCam::MODE_M16_1STPERSON ||
Mode == CCam::MODE_M16_1STPERSON_RUNABOUT || Mode == CCam::MODE_M16_1STPERSON_RUNABOUT ||
Mode == CCam::MODE_HELICANNON_1STPERSON) { Mode == CCam::MODE_HELICANNON_1STPERSON) {
@ -215,8 +241,11 @@ void CHud::Draw()
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRocketSightTex)); RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwTextureGetRaster(gpRocketSightTex));
CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255); CSprite::RenderOneXLUSprite(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, 1.0f, SCREEN_SCALE_X(40.0f), SCREEN_SCALE_Y(40.0f), (100.0f * fMultBright), (200.0f * fMultBright), (100.0f * fMultBright), 255, 1.0f, 255);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
} }
else { else {
// TODO(Miami)
// Sniper // Sniper
rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f); rect.left = (SCREEN_WIDTH / 2) - SCREEN_SCALE_X(210.0f);
rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f); rect.top = (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(210.0f);
@ -243,9 +272,9 @@ void CHud::Draw()
Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255)); Sprites[HUD_SITESNIPER].Draw(CRect(rect), CRGBA(255, 255, 255, 255));
} }
} }
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void *)rwFILTERLINEAR);
RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA); RwRenderStateSet(rwRENDERSTATESRCBLEND, (void *)rwBLENDSRCALPHA);
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA); RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVSRCALPHA);
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
} }
else { else {
SpriteBrightness = 0; SpriteBrightness = 0;
@ -254,34 +283,48 @@ void CHud::Draw()
/* /*
DrawMoneyCounter DrawMoneyCounter
*/ */
wchar sPrint[16]; wchar sPrint[16];
wchar sPrintIcon[16]; wchar sPrintIcon[16];
char sTemp[16]; char sTemp[16];
float alpha;
sprintf(sTemp, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney); if (m_LastDisplayScore == CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney) {
AsciiToUnicode(sTemp, sPrint); alpha = CHud::DrawFadeState(HUD_SCORE_FADING, 0);
} else {
alpha = CHud::DrawFadeState(HUD_SCORE_FADING, 1);
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
}
if (m_DisplayScoreState != FADED_OUT) {
sprintf(sTemp, "$%08d", CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney);
AsciiToUnicode(sTemp, sPrint);
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
CFont::SetBackGroundOnlyTextOff(); CFont::SetBackGroundOnlyTextOff();
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONT_HEADING);
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, alpha));
MONEY_COLOR.a = alpha;
CFont::SetColor(MONEY_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f), SCREEN_SCALE_Y(43.0f + 2.0f), sPrint); // TODO(Miami): m_nHudMode
//if (CMenuManager.m_nHudMode)
CFont::SetColor(MONEY_COLOR); {
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint);
}
}
/* /*
DrawAmmo DrawAmmo
*/ */
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType); CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo((eWeaponType)WeaponType);
CWeapon *weapon = FindPlayerPed()->GetWeapon(); CWeapon *weapon = playerPed->GetWeapon();
uint32 AmmoAmount = weaponInfo->m_nAmountofAmmunition; uint32 AmmoAmount = weaponInfo->m_nAmountofAmmunition;
uint32 AmmoInClip = weapon->m_nAmmoInClip; uint32 AmmoInClip = weapon->m_nAmmoInClip;
uint32 TotalAmmo = weapon->m_nAmmoTotal; uint32 TotalAmmo = weapon->m_nAmmoTotal;
@ -347,14 +390,15 @@ void CHud::Draw()
} }
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f)); CFont::SetScale(SCREEN_SCALE_X(0.5f), SCREEN_SCALE_Y(0.8f));
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetCentreOn(); CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_SCALE_X(640.0f)); CFont::SetCentreSize(SCREEN_SCALE_X(640.0f));
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetDropShadowPosition(0);
CFont::SetFontStyle(FONT_BANK); CFont::SetFontStyle(FONT_BANK);
if (!CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { if (Min(9999, TotalAmmo - AmmoInClip) != 9999 && !CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) {
CFont::SetDropShadowPosition(2); CFont::SetDropShadowPosition(2);
CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetColor(AMMO_COLOR); CFont::SetColor(AMMO_COLOR);
@ -366,7 +410,7 @@ void CHud::Draw()
DrawHealth DrawHealth
*/ */
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
@ -376,16 +420,16 @@ void CHud::Draw()
if (m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8 if (m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8
|| m_ItemToFlash != ITEM_HEALTH || m_ItemToFlash != ITEM_HEALTH
|| FindPlayerPed()->m_fHealth < 10 || playerPed->m_fHealth < 10
&& CTimer::GetFrameCounter() & 8) { && CTimer::GetFrameCounter() & 8) {
if (FindPlayerPed()->m_fHealth >= 10 if (playerPed->m_fHealth >= 10
|| FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) { || playerPed->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
AsciiToUnicode("{", sPrintIcon); AsciiToUnicode("{", sPrintIcon);
#ifdef FIX_BUGS #ifdef FIX_BUGS
sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fHealth + 0.5f)); sprintf(sTemp, "%03d", int32(playerPed->m_fHealth + 0.5f));
#else #else
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fHealth); sprintf(sTemp, "%03d", (int32)playerPed->m_fHealth);
#endif #endif
AsciiToUnicode(sTemp, sPrint); AsciiToUnicode(sTemp, sPrint);
@ -409,13 +453,13 @@ void CHud::Draw()
DrawArmour DrawArmour
*/ */
if (m_ItemToFlash == ITEM_ARMOUR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_ARMOUR) { if (m_ItemToFlash == ITEM_ARMOUR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_ARMOUR) {
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
if (FindPlayerPed()->m_fArmour > 1.0f) { if (playerPed->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon); AsciiToUnicode("[", sPrintIcon);
#ifdef FIX_BUGS #ifdef FIX_BUGS
sprintf(sTemp, "%03d", int32(FindPlayerPed()->m_fArmour + 0.5f)); sprintf(sTemp, "%03d", int32(playerPed->m_fArmour + 0.5f));
#else #else
sprintf(sTemp, "%03d", (int32)FindPlayerPed()->m_fArmour); sprintf(sTemp, "%03d", (int32)playerPed->m_fArmour);
#endif #endif
AsciiToUnicode(sTemp, sPrint); AsciiToUnicode(sTemp, sPrint);
@ -440,30 +484,33 @@ void CHud::Draw()
DrawWantedLevel DrawWantedLevel
*/ */
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.7f), SCREEN_SCALE_Y(1.25f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONT_HEADING);
CFont::SetDropShadowPosition(2); // TODO(Miami): Remove that, VC keeps that open above
AsciiToUnicode("]", sPrintIcon); AsciiToUnicode("]", sPrintIcon);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
CFont::SetColor(CRGBA(0, 0, 0, 255)); if (playerPed->m_pWanted->m_nWantedLevel > i
CFont::PrintString(2.0f + SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f + 2.0f), sPrintIcon); && (CTimer::GetTimeInMilliseconds() > playerPed->m_pWanted->m_nLastWantedLevelChange
if (FindPlayerPed()->m_pWanted->m_nWantedLevel > i
&& (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange
+ 2000 || CTimer::GetFrameCounter() & 4)) { + 2000 || CTimer::GetFrameCounter() & 4)) {
CFont::SetColor(WANTED_COLOR); CFont::SetColor(WANTED_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon);
}else{
// TODO(Miami): There is one more condition in here
}else if (playerPed->m_pWanted->m_nWantedLevel <= i) {
CFont::SetColor(NOTWANTED_COLOR); CFont::SetColor(NOTWANTED_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon);
} }
} }
CFont::SetDropShadowPosition(0); // TODO(Miami): Remove that, VC keeps that open
/* /*
DrawZoneName DrawZoneName
*/ */
@ -675,7 +722,7 @@ void CHud::Draw()
CFont::SetJustifyOff(); CFont::SetJustifyOff();
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetBackGroundOnlyTextOff(); CFont::SetBackGroundOnlyTextOff();
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONT_HEADING);
@ -724,7 +771,7 @@ void CHud::Draw()
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerBuffer, sTimer); AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerBuffer, sTimer);
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING)); CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
@ -732,7 +779,7 @@ void CHud::Draw()
CFont::SetBackGroundOnlyTextOn(); CFont::SetBackGroundOnlyTextOn();
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), sTimer);
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetColor(TIMER_COLOR); CFont::SetColor(TIMER_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer);
@ -764,7 +811,7 @@ void CHud::Draw()
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetCentreOff(); CFont::SetCentreOff();
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(0.0f); CFont::SetRightJustifyWrap(0.0f);
@ -790,7 +837,7 @@ void CHud::Draw()
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) { if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText[0]) {
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); CFont::SetScale(SCREEN_SCALE_X(HUD_TEXT_SCALE_X), SCREEN_SCALE_Y(HUD_TEXT_SCALE_Y));
CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f) + SCREEN_SCALE_Y(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText));
@ -1456,6 +1503,21 @@ void CHud::Initialise()
PagerSoundPlayed = 0; PagerSoundPlayed = 0;
PagerXOffset = 150.0f; PagerXOffset = 150.0f;
m_WantedFadeTimer = 0;
m_WantedState = FADE_DISABLED;
m_WantedTimer = 0;
m_EnergyLostFadeTimer = 0;
m_EnergyLostState = FADE_DISABLED;
m_EnergyLostTimer = 0;
m_DisplayScoreFadeTimer = 0;
m_DisplayScoreState = FADE_DISABLED;
m_DisplayScoreTimer = 0;
m_WeaponFadeTimer = 0;
m_WeaponState = FADE_DISABLED;
m_WeaponTimer = 0;
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
CTxdStore::PopCurrentTxd(); CTxdStore::PopCurrentTxd();
} }
@ -1479,6 +1541,21 @@ void CHud::ReInitialise() {
PagerTimer = 0; PagerTimer = 0;
PagerSoundPlayed = 0; PagerSoundPlayed = 0;
PagerXOffset = 150.0f; PagerXOffset = 150.0f;
m_WantedFadeTimer = 0;
m_WantedState = FADE_DISABLED;
m_WantedTimer = 0;
m_EnergyLostFadeTimer = 0;
m_EnergyLostState = FADE_DISABLED;
m_EnergyLostTimer = 0;
m_DisplayScoreFadeTimer = 0;
m_DisplayScoreState = FADE_DISABLED;
m_DisplayScoreTimer = 0;
m_WeaponFadeTimer = 0;
m_WeaponState = FADE_DISABLED;
m_WeaponTimer = 0;
m_LastDisplayScore = CWorld::Players[CWorld::PlayerInFocus].m_nVisibleMoney;
} }
wchar LastBigMessage[6][128]; wchar LastBigMessage[6][128];
@ -1575,3 +1652,106 @@ void CHud::Shutdown()
int HudTXD = CTxdStore::FindTxdSlot("hud"); int HudTXD = CTxdStore::FindTxdSlot("hud");
CTxdStore::RemoveTxdSlot(HudTXD); CTxdStore::RemoveTxdSlot(HudTXD);
} }
float CHud::DrawFadeState(DRAW_FADE_STATE fadingElement, int forceFadingIn)
{
float alpha = 255.0f;
uint32 operation, timer;
int32 fadeTimer;
switch (fadingElement) {
case HUD_WANTED_FADING:
fadeTimer = m_WantedFadeTimer;
operation = m_WantedState;
timer = m_WantedTimer;
break;
case HUD_ENERGY_FADING:
fadeTimer = m_EnergyLostFadeTimer;
operation = m_EnergyLostState;
timer = m_EnergyLostTimer;
break;
case HUD_SCORE_FADING:
fadeTimer = m_DisplayScoreFadeTimer;
operation = m_DisplayScoreState;
timer = m_DisplayScoreTimer;
break;
case HUD_WEAPON_FADING:
fadeTimer = m_WeaponFadeTimer;
operation = m_WeaponState;
timer = m_WeaponTimer;
break;
default:
break;
}
if (forceFadingIn) {
switch (operation) {
case FADED_OUT:
fadeTimer = 0;
case START_FADE_OUT:
case FADING_OUT:
timer = 5;
operation = FADING_IN;
break;
default:
break;
}
}
if (operation != FADED_OUT && operation != FADE_DISABLED) {
switch (operation) {
case START_FADE_OUT:
fadeTimer = 1000;
alpha = 255.0f;
if (timer > 10000) {
fadeTimer = 3000;
operation = FADING_OUT;
}
break;
case FADING_IN:
fadeTimer += CTimer::GetTimeStepInMilliseconds();
if (fadeTimer > 1000.0f) {
operation = START_FADE_OUT;
fadeTimer = 1000;
}
alpha = fadeTimer / 1000.0f * 255.0f;
break;
case FADING_OUT:
fadeTimer -= CTimer::GetTimeStepInMilliseconds();
if (fadeTimer < 0.0f) {
fadeTimer = 0;
operation = FADED_OUT;
}
alpha = fadeTimer / 1000.0f * 255.0f;
break;
default:
break;
}
timer += CTimer::GetTimeStepInMilliseconds();
}
switch (fadingElement) {
case HUD_WANTED_FADING:
m_WantedFadeTimer = fadeTimer;
m_WantedState = operation;
m_WantedTimer = timer;
break;
case HUD_ENERGY_FADING:
m_EnergyLostFadeTimer = fadeTimer;
m_EnergyLostState = operation;
m_EnergyLostTimer = timer;
break;
case HUD_SCORE_FADING:
m_DisplayScoreFadeTimer = fadeTimer;
m_DisplayScoreState = operation;
m_DisplayScoreTimer = timer;
break;
case HUD_WEAPON_FADING:
m_WeaponFadeTimer = fadeTimer;
m_WeaponState = operation;
m_WeaponTimer = timer;
break;
default:
break;
}
return clamp(alpha, 0.0f, 255.0f);
}

View File

@ -9,6 +9,25 @@ enum eItems
ITEM_RADAR = 8 ITEM_RADAR = 8
}; };
// Thanks for vague name, R*
enum DRAW_FADE_STATE
{
HUD_WANTED_FADING = 0,
HUD_ENERGY_FADING,
HUD_SCORE_FADING,
HUD_WEAPON_FADING,
};
// My name
enum eFadeOperation
{
FADED_OUT = 0,
START_FADE_OUT,
FADING_IN,
FADING_OUT,
FADE_DISABLED = 5,
};
enum eSprites enum eSprites
{ {
HUD_FIST, HUD_FIST,
@ -32,6 +51,10 @@ enum eSprites
NUM_HUD_SPRITES, NUM_HUD_SPRITES,
}; };
// TODO(Miami): Make those 0.7f - 1.25f once fonts have been ported
#define HUD_TEXT_SCALE_X 0.8f
#define HUD_TEXT_SCALE_Y 1.35f
class CHud class CHud
{ {
public: public:
@ -82,6 +105,21 @@ public:
static int16 PagerTimer; static int16 PagerTimer;
static int16 PagerOn; static int16 PagerOn;
static uint32 m_WantedFadeTimer;
static uint32 m_WantedState;
static uint32 m_WantedTimer;
static uint32 m_EnergyLostFadeTimer;
static uint32 m_EnergyLostState;
static uint32 m_EnergyLostTimer;
static uint32 m_DisplayScoreFadeTimer;
static uint32 m_DisplayScoreState;
static uint32 m_DisplayScoreTimer;
static uint32 m_WeaponFadeTimer;
static uint32 m_WeaponState;
static uint32 m_WeaponTimer;
static uint32 m_LastDisplayScore;
public: public:
static void Draw(); static void Draw();
static void DrawAfterFade(); static void DrawAfterFade();
@ -95,4 +133,5 @@ public:
static void SetVehicleName(wchar *name); static void SetVehicleName(wchar *name);
static void SetZoneName(wchar *name); static void SetZoneName(wchar *name);
static void Shutdown(); static void Shutdown();
static float DrawFadeState(DRAW_FADE_STATE, int);
}; };

View File

@ -207,6 +207,7 @@ public:
float m_fMapObjectHeightBehind; // rear Z? float m_fMapObjectHeightBehind; // rear Z?
eCarLock m_nDoorLock; eCarLock m_nDoorLock;
int8 m_nLastWeaponDamage; // see eWeaponType, -1 if no damage int8 m_nLastWeaponDamage; // see eWeaponType, -1 if no damage
CEntity *m_pLastDamageEntity;
int8 m_nRadioStation; int8 m_nRadioStation;
uint8 m_bRainAudioCounter; uint8 m_bRainAudioCounter;
uint8 m_bRainSamplesCounter; uint8 m_bRainSamplesCounter;

View File

@ -36,7 +36,17 @@
uint16 gReloadSampleTime[WEAPONTYPE_LAST_WEAPONTYPE] = uint16 gReloadSampleTime[WEAPONTYPE_LAST_WEAPONTYPE] =
{ {
0, // UNARMED 0, // UNARMED
0, // BASEBALLBAT 0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, // GRENADE 0, // GRENADE
0, // DETONATEGRENADE 0, // DETONATEGRENADE
0, // MOLOTOV 0, // MOLOTOV
@ -156,6 +166,7 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
return false; return false;
bool fired; bool fired;
bool addFireRateAsDelay = true;
if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE ) if ( GetInfo()->m_eWeaponFire != WEAPON_FIRE_MELEE )
{ {
@ -166,6 +177,7 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
{ {
case WEAPONTYPE_SHOTGUN: case WEAPONTYPE_SHOTGUN:
{ {
addFireRateAsDelay = true;
fired = FireShotgun(shooter, source); fired = FireShotgun(shooter, source);
break; break;
@ -181,13 +193,13 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
case WEAPONTYPE_HELICANNON: case WEAPONTYPE_HELICANNON:
{ {
if ((TheCamera.PlayerWeaponMode.Mode == CCam::MODE_HELICANNON_1STPERSON || TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON) if ((TheCamera.PlayerWeaponMode.Mode == CCam::MODE_HELICANNON_1STPERSON || TheCamera.PlayerWeaponMode.Mode == CCam::MODE_M16_1STPERSON)
&& shooter == FindPlayerPed()) && shooter == FindPlayerPed()) {
{ addFireRateAsDelay = false;
fired = FireM16_1stPerson(shooter); fired = FireM16_1stPerson(shooter);
} } else {
else addFireRateAsDelay = true;
fired = FireInstantHit(shooter, source); fired = FireInstantHit(shooter, source);
}
break; break;
} }
@ -267,54 +279,58 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
} }
} }
if ( fired ) if (fired)
{ {
bool isPlayer = false; bool isPlayer = false;
if ( shooter->IsPed() ) if (shooter->IsPed())
{ {
CPed *shooterPed = (CPed*)shooter; CPed* shooterPed = (CPed*)shooter;
shooterPed->bIsShooting = true; shooterPed->bIsShooting = true;
if ( shooterPed->IsPlayer() ) if (shooterPed->IsPlayer())
isPlayer = true; isPlayer = true;
DMAudio.PlayOneShot(shooterPed->m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f); DMAudio.PlayOneShot(shooterPed->m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f);
} }
if ( m_nAmmoInClip > 0 ) if (m_nAmmoInClip > 0)
m_nAmmoInClip--; m_nAmmoInClip--;
if ( m_nAmmoTotal > 0 && (m_nAmmoTotal < 25000 || isPlayer) && (!isPlayer || CStats::GetPercentageProgress() < 100.0f || m_eWeaponType == WEAPONTYPE_DETONATOR)) if (m_nAmmoTotal > 0 && (m_nAmmoTotal < 25000 || isPlayer) && (!isPlayer || CStats::GetPercentageProgress() < 100.0f || m_eWeaponType == WEAPONTYPE_DETONATOR))
m_nAmmoTotal--; m_nAmmoTotal--;
if ( m_eWeaponState == WEAPONSTATE_READY && m_eWeaponType == WEAPONTYPE_FLAMETHROWER ) if (m_eWeaponState == WEAPONSTATE_READY && m_eWeaponType == WEAPONTYPE_FLAMETHROWER)
DMAudio.PlayOneShot(((CPhysical*)shooter)->m_audioEntityId, SOUND_WEAPON_FLAMETHROWER_FIRE, 0.0f); DMAudio.PlayOneShot(((CPhysical*)shooter)->m_audioEntityId, SOUND_WEAPON_FLAMETHROWER_FIRE, 0.0f);
m_eWeaponState = WEAPONSTATE_FIRING; m_eWeaponState = WEAPONSTATE_FIRING;
}
if ( m_nAmmoInClip == 0 ) if (m_nAmmoInClip == 0)
{
if ( m_nAmmoTotal == 0 )
return true;
m_eWeaponState = WEAPONSTATE_RELOADING;
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
if ( shooter == FindPlayerPed() )
{ {
if ( CWorld::Players[CWorld::PlayerInFocus].m_bFastReload ) if (m_nAmmoTotal == 0)
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload / 4; return true;
m_eWeaponState = WEAPONSTATE_RELOADING;
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
if (shooter == FindPlayerPed())
{
if (CWorld::Players[CWorld::PlayerInFocus].m_bFastReload)
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload / 4;
}
return true;
} }
return true; if (addFireRateAsDelay)
} m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nFiringRate;
else
m_nTimer = CTimer::GetTimeInMilliseconds();
m_nTimer = CTimer::GetTimeInMilliseconds() + 1000; if (shooter == FindPlayerPed())
if ( shooter == FindPlayerPed() ) CStats::RoundsFiredByPlayer++;
CStats::RoundsFiredByPlayer++; }
} }
else else
{ {
@ -322,9 +338,15 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource)
{ {
m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload; m_nTimer = CTimer::GetTimeInMilliseconds() + GetInfo()->m_nReload;
m_eWeaponState = WEAPONSTATE_FIRING; m_eWeaponState = WEAPONSTATE_FIRING;
#ifndef AUDIO_NOT_READY
if (shooter->IsPed() && m_eWeaponType != WEAPONTYPE_CHAINSAW)
{
DMAudio.PlayOneShot(((CPed*)shooter)->m_audioEntityId, 188, m_eWeaponType << 8);
}
#endif
} }
FireMelee(shooter, *source); fired = FireMelee(shooter, *source);
} }
if ( m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BASEBALLBAT ) if ( m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BASEBALLBAT )
@ -372,7 +394,7 @@ CWeapon::FireFromCar(CVehicle *shooter, bool left)
return true; return true;
} }
// --MIAMI: Just a few lines is done // --MIAMI: Done, except commented things
bool bool
CWeapon::FireMelee(CEntity *shooter, CVector &fireSource) CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
{ {
@ -386,18 +408,31 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
CPed *shooterPed = (CPed*)shooter; CPed *shooterPed = (CPed*)shooter;
if (shooterPed == FindPlayerPed()) {
if (m_eWeaponType == WEAPONTYPE_GOLFCLUB || m_eWeaponType == WEAPONTYPE_NIGHTSTICK ||
(m_eWeaponType >= WEAPONTYPE_BASEBALLBAT && m_eWeaponType <= WEAPONTYPE_CHAINSAW)) {
// TODO(Miami): BreakGlassPhysically
if (m_eWeaponType == WEAPONTYPE_CHAINSAW) {
CEventList::RegisterEvent(EVENT_GUNSHOT, EVENT_ENTITY_PED, FindPlayerPed(), FindPlayerPed(), 1000);
}
}
}
int damageEntityRegistered = 0;
for ( int32 i = 0; i < shooterPed->m_numNearPeds; i++ ) for ( int32 i = 0; i < shooterPed->m_numNearPeds; i++ )
{ {
CPed *victimPed = shooterPed->m_nearPeds[i]; CPed *victimPed = shooterPed->m_nearPeds[i];
ASSERT(victimPed!=nil); ASSERT(victimPed!=nil);
if ( (victimPed->m_nPedType != shooterPed->m_nPedType || victimPed == shooterPed->m_pSeekTarget) if ( (victimPed->m_nPedType != shooterPed->m_nPedType || victimPed == shooterPed->m_pSeekTarget)
&& victimPed != shooterPed->m_leader || !(CGeneral::GetRandomNumber() & 31) ) && victimPed != shooterPed->m_leader || !(CGeneral::GetRandomNumber() & 31)
&& (!shooterPed->IsGangMember() || victimPed->CanBeDamagedByThisGangMember(shooterPed)) )
{ {
bool collided = false; bool collided = false;
// TODO(Miami) if (victimPed->m_nPedState == PED_DRIVING && (m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE
if (victimPed->m_nPedState == PED_DRIVING && (m_eWeaponType == WEAPONTYPE_UNARMED /*|| m_eWeaponType == WEAPONTYPE_BRASSKNUCKLES*/
|| info->m_bFightMode)) || info->m_bFightMode))
continue; continue;
@ -451,65 +486,115 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
int32 localDir = victimPed->GetLocalDirection(posOffset); int32 localDir = victimPed->GetLocalDirection(posOffset);
bool isBat = m_eWeaponType == WEAPONTYPE_BASEBALLBAT; bool isHeavy = m_eWeaponType >= WEAPONTYPE_GOLFCLUB && m_eWeaponType <= WEAPONTYPE_KATANA && m_eWeaponType != WEAPONTYPE_HAMMER;
if (shooterPed->m_fDamageImpulse == 0.0f) {
shooterPed->m_pDamageEntity = victimPed;
victimPed->RegisterReference(&shooterPed->m_pDamageEntity);
}
damageEntityRegistered = 3;
// TODO(Miami): Bike
if ( !victimPed->DyingOrDead() ) if ( !victimPed->DyingOrDead() )
victimPed->ReactToAttack(shooterPed); victimPed->ReactToAttack(shooterPed);
uint8 hitLevel = HITLEVEL_HIGH; uint8 hitLevel = HITLEVEL_HIGH;
if ( isBat && victimPed->OnGround() ) if ( isHeavy && (victimPed->OnGround() || victimPed->m_nWaitState == WAITSTATE_SUN_BATHE_IDLE))
hitLevel = HITLEVEL_GROUND; hitLevel = HITLEVEL_GROUND;
victimPed->StartFightDefend(localDir, hitLevel, 10); victimPed->StartFightDefend(localDir, hitLevel, 10);
if ( !victimPed->DyingOrDead() ) if ( !victimPed->DyingOrDead() )
{ {
if ( shooterPed->IsPlayer() && isBat && anim2Playing ) if ( shooterPed->IsPlayer() && isHeavy && anim2Playing )
victimPed->InflictDamage(shooterPed, m_eWeaponType, 100.0f, PEDPIECE_TORSO, localDir); victimPed->InflictDamage(shooterPed, m_eWeaponType, 100.0f, PEDPIECE_TORSO, localDir);
else if ( shooterPed->IsPlayer() && ((CPlayerPed*)shooterPed)->m_bAdrenalineActive ) else if ( shooterPed->IsPlayer() && ((CPlayerPed*)shooterPed)->m_bAdrenalineActive )
victimPed->InflictDamage(shooterPed, m_eWeaponType, 3.5f*info->m_nDamage, PEDPIECE_TORSO, localDir); victimPed->InflictDamage(shooterPed, m_eWeaponType, 3.5f*info->m_nDamage, PEDPIECE_TORSO, localDir);
else else
{ {
if ( victimPed->IsPlayer() && isBat ) // wtf, it's not fair if ( victimPed->IsPlayer() && isHeavy ) // wtf, it's not fair
victimPed->InflictDamage(shooterPed, m_eWeaponType, 2.0f*info->m_nDamage, PEDPIECE_TORSO, localDir); victimPed->InflictDamage(shooterPed, m_eWeaponType, 2.0f*info->m_nDamage, PEDPIECE_TORSO, localDir);
else else
victimPed->InflictDamage(shooterPed, m_eWeaponType, info->m_nDamage, PEDPIECE_TORSO, localDir); victimPed->InflictDamage(shooterPed, m_eWeaponType, info->m_nDamage, PEDPIECE_TORSO, localDir);
} }
} }
if ( CGame::nastyGame ) if ( CGame::nastyGame && victimPed->GetIsOnScreen() )
{ {
if ( victimPed->GetIsOnScreen() ) CVector dir = collisionDist * RecipSqrt(1.0f, 10.0f*collisionDist.MagnitudeSqr());
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
if ( isHeavy )
{ {
CVector dir = collisionDist * RecipSqrt(1.0f, 10.0f*collisionDist.MagnitudeSqr()); dir.x += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
dir.y += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir); CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
if ( isBat ) dir.x += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
dir.y += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
}
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
{
if (victimPed->m_nPedState != PED_DEAD && !((CTimer::GetFrameCounter() + 17) & 1)
|| victimPed->m_nPedState == PED_DEAD && !((CTimer::GetFrameCounter() + 17) & 3))
{ {
dir.x += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f); CParticle::AddParticle(PARTICLE_TEST, bloodPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.2f);
dir.y += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
dir.x += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
dir.y += CGeneral::GetRandomNumberInRange(-0.05f, 0.05f);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, dir);
} }
CVector newDir(dir);
newDir.z += 0.2f;
CParticle::AddParticle(PARTICLE_BLOOD_SMALL, bloodPos, newDir);
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, newDir);
newDir.z = dir.z + 0.1f;
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, newDir);
newDir.x = 0.0f;
newDir.y = 0.0f;
newDir.z = 0.01f;
CParticle::AddParticle(PARTICLE_DEBRIS2, bloodPos, newDir);
// TODO(Miami): New particle
/*
v116.z = 0.0;
v116.x = CGeneral::GetRandomNumberInRange(-0.15f, 0.15f);
v116.y = CGeneral::GetRandomNumberInRange(0.1f, 0.35f);
v115.x = CGeneral::GetRandomNumberInRange(SCREEN_STRETCH_X(50.0f), SCREEN_STRETCH_FROM_RIGHT(50.0f));
v115.z = 1.0;
v115.y = CGeneral::GetRandomNumberInRange(SCREEN_STRETCH_Y(50.0f), SCREEN_STRETCH_FROM_BOTTOM(50.0f));
CParticle::AddParticle(41, v115, v116, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.15f),
CRGBA(0, 0, 0, 0), 0, 0, CGeneral::GetRandomNumber() & 1, 0);
*/
}
if (info->m_AnimToPlay == ASSOCGRP_KNIFE)
{
dir.x += 0.1f * shooterPed->GetUp().x + 0.05f * shooterPed->GetRight().x;
dir.y += 0.1f * shooterPed->GetUp().y + 0.05f * shooterPed->GetRight().y;
dir.z += 0.1f * shooterPed->GetUp().z + 0.05f * shooterPed->GetRight().z;
CParticle::AddParticle(PARTICLE_BLOOD_SPURT, bloodPos, dir);
CParticle::AddParticle(PARTICLE_BLOOD_SPURT, bloodPos, dir);
CParticle::AddParticle(PARTICLE_BLOOD_SPURT, bloodPos, dir);
} }
} }
if ( !victimPed->OnGround() ) if ( !victimPed->OnGround() )
{ {
if ( victimPed->m_fHealth > 0.0f if ( victimPed->m_fHealth > 0.0f
&& (victimPed->m_fHealth < 20.0f && victimPedHealth > 20.0f || isBat && !victimPed->IsPlayer()) ) && (victimPed->m_fHealth < 30.0f && victimPedHealth > 20.0f ||
(isHeavy || m_eWeaponType == WEAPONTYPE_BRASSKNUCKLE) && !victimPed->IsPlayer()) )
{ {
posOffset.Normalise(); posOffset.Normalise();
victimPed->bIsStanding = false; victimPed->bIsStanding = false;
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 3.0f); if(m_eWeaponType == WEAPONTYPE_CHAINSAW)
victimPed->ApplyMoveForce(posOffset.x*-2.0f, posOffset.y*-2.0f, 2.0f);
else
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 3.0f);
if ( isBat && victimPed->IsPlayer() ) if ( isHeavy && victimPed->IsPlayer() )
victimPed->SetFall(3000, AnimationId(ANIM_KO_SKID_FRONT + localDir), false); victimPed->SetFall(3000, AnimationId(ANIM_KO_SKID_FRONT + localDir), false);
else else
victimPed->SetFall(1500, AnimationId(ANIM_KO_SKID_FRONT + localDir), false); victimPed->SetFall(1500, AnimationId(ANIM_KO_SKID_FRONT + localDir), false);
@ -522,21 +607,152 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource)
{ {
posOffset.Normalise(); posOffset.Normalise();
victimPed->bIsStanding = false; victimPed->bIsStanding = false;
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 3.0f); if(m_eWeaponType == WEAPONTYPE_CHAINSAW)
victimPed->ApplyMoveForce(posOffset.x*-1.0f, posOffset.y*-1.0f, 1.0f);
else
victimPed->ApplyMoveForce(posOffset.x*-5.0f, posOffset.y*-5.0f, 3.0f);
} }
m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT; m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT;
if ( victimPed->m_nPedType == PEDTYPE_COP ) if (m_eWeaponType != WEAPONTYPE_KNIFE && m_eWeaponType != WEAPONTYPE_MACHETE
CEventList::RegisterEvent(EVENT_ASSAULT_POLICE, EVENT_ENTITY_PED, victimPed, shooterPed, 2000); && m_eWeaponType != WEAPONTYPE_KATANA && m_eWeaponType != WEAPONTYPE_CHAINSAW) {
else
CEventList::RegisterEvent(EVENT_ASSAULT, EVENT_ENTITY_PED, victimPed, shooterPed, 2000); if (victimPed->m_nPedType == PEDTYPE_COP)
CEventList::RegisterEvent(EVENT_ASSAULT_POLICE, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
else
CEventList::RegisterEvent(EVENT_ASSAULT, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
} else {
if (victimPed->m_nPedType == PEDTYPE_COP)
CEventList::RegisterEvent(EVENT_ASSAULT_NASTYWEAPON_POLICE, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
else
CEventList::RegisterEvent(EVENT_ASSAULT_NASTYWEAPON, EVENT_ENTITY_PED, victimPed, shooterPed, 2000);
}
} }
} }
} }
} }
} }
} }
CVehicle *nearVeh = (CVehicle*)CWorld::TestSphereAgainstWorld(fireSource, info->m_fRadius, nil, false, true, false, false, false, false);
if (nearVeh && nearVeh->IsCar())
{
CAutomobile *nearCar = (CAutomobile*)nearVeh;
m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT;
if (shooterPed == FindPlayerPed())
{
if (nearCar->IsLawEnforcementVehicle())
{
FindPlayerPed()->SetWantedLevelNoDrop(1);
}
CEventList::RegisterEvent(EVENT_ASSAULT, EVENT_ENTITY_VEHICLE, nearCar, shooterPed, 2000);
}
float oldHealth = nearCar->m_fHealth;
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
{
for(int i=0; i<4; i++) {
CParticle::AddParticle(PARTICLE_SPARK_SMALL, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.3f));
CParticle::AddParticle(PARTICLE_SPARK, gaTempSphereColPoints[0].point, gaTempSphereColPoints[0].normal * 0.1f);
}
}
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
{
nearCar->VehicleDamage(info->m_nDamage * (0.00075f * nearCar->pHandling->fMass), gaTempSphereColPoints[0].pieceB);
// TODO(Miami): Particle not in III
// CParticle::AddParticle(81, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.0f), 0, 0.0f, 0, 0, 0, 0);
}
else
{
nearCar->VehicleDamage(info->m_nDamage* (0.00075f * nearCar->pHandling->fMass), gaTempSphereColPoints[0].pieceB);
}
if (nearCar->m_fHealth < oldHealth)
{
nearCar->m_nLastWeaponDamage = m_eWeaponType;
nearCar->m_pLastDamageEntity = shooterPed;
}
if (shooterPed->m_fDamageImpulse == 0.0f)
{
shooterPed->m_pDamageEntity = nearCar;
nearCar->RegisterReference(&shooterPed->m_pDamageEntity);
}
damageEntityRegistered = 2;
if (FindPlayerPed()->GetWeapon() == this && nearCar->VehicleCreatedBy != MISSION_VEHICLE)
{
if (nearCar->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_PLOUGH_THROUGH
&& (CGeneral::GetRandomTrueFalse() || nearCar->AutoPilot.m_nCarMission != MISSION_CRUISE))
{
int leaveCarDelay = 200;
CPed *driver = nearCar->pDriver;
if (driver && driver->CharCreatedBy != MISSION_CHAR)
{
if (driver->m_pedStats->m_temper <= driver->m_pedStats->m_fear)
{
driver->SetObjective(OBJECTIVE_FLEE_TILL_SAFE);
}
else
{
driver->SetObjective(OBJECTIVE_KILL_CHAR_ON_FOOT, FindPlayerPed());
driver->m_objectiveTimer = CTimer::GetTimeInMilliseconds() + 10000;
driver->m_prevObjective = OBJECTIVE_KILL_CHAR_ON_FOOT;
}
driver->m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + 200;
leaveCarDelay = 400;
}
for (int j = 0; j < nearCar->m_nNumPassengers; ++j)
{
CPed *passenger = nearCar->pPassengers[j];
if (passenger && passenger->CharCreatedBy != MISSION_CHAR)
{
nearCar->pPassengers[j]->SetObjective(OBJECTIVE_FLEE_TILL_SAFE);
passenger->m_leaveCarTimer = CTimer::GetTimeInMilliseconds() + leaveCarDelay;
leaveCarDelay += 200;
}
}
}
else
{
CPed *driver = nearCar->pDriver;
if (driver)
{
if (driver->m_objective != OBJECTIVE_LEAVE_VEHICLE && driver->m_objective != OBJECTIVE_KILL_CHAR_ON_FOOT &&
driver->m_objective != OBJECTIVE_FLEE_TILL_SAFE)
{
if (nearCar->AutoPilot.m_nDrivingStyle != DRIVINGSTYLE_PLOUGH_THROUGH)
nearCar->AutoPilot.m_nCruiseSpeed = nearCar->AutoPilot.m_nCruiseSpeed * 1.5f;
nearCar->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_PLOUGH_THROUGH;
}
}
}
}
}
if (m_eWeaponType == WEAPONTYPE_CHAINSAW)
{
CEntity *nearStatic = (CObject*)CWorld::TestSphereAgainstWorld(fireSource, info->m_fRadius, nil, true, false, false, true, false, false);
if (nearStatic)
{
for(int i=0; i < 4; i++) {
CParticle::AddParticle(PARTICLE_SPARK_SMALL, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.3f), 0, 0.0f, 0, 0, 0, 0);
CParticle::AddParticle(PARTICLE_SPARK, gaTempSphereColPoints[0].point, 0.1f * gaTempSphereColPoints[0].normal, 0, 0.0f, 0, 0, 0, 0);
}
// TODO(Miami): Particle not in III
//CParticle::AddParticle(81, gaTempSphereColPoints[0].point, CVector(0.0f, 0.0f, 0.0f), 0, 0.0f, 0, 0, 0, 0);
if (!damageEntityRegistered)
{
m_eWeaponState = WEAPONSTATE_MELEE_MADECONTACT;
if (shooterPed->m_fDamageImpulse == 0.0f)
{
shooterPed->m_pDamageEntity = nearStatic;
nearStatic->RegisterReference(&shooterPed->m_pDamageEntity);
}
}
if (nearStatic->IsObject() && ((CObject*)nearStatic)->m_nCollisionDamageEffect >= DAMAGE_EFFECT_SMASH_COMPLETELY)
((CObject*)nearStatic)->ObjectDamage(200.0f);
}
}
return true; return true;
} }
@ -2239,13 +2455,17 @@ FireOneInstantHitRound(CVector *source, CVector *target, int32 damage)
bool bool
CWeapon::IsTypeMelee(void) CWeapon::IsTypeMelee(void)
{ {
return m_eWeaponType == WEAPONTYPE_UNARMED || m_eWeaponType == WEAPONTYPE_BASEBALLBAT; return CWeaponInfo::GetWeaponInfo(m_eWeaponType)->m_eWeaponFire == WEAPON_FIRE_MELEE;
} }
bool bool
CWeapon::IsType2Handed(void) CWeapon::IsType2Handed(void)
{ {
return m_eWeaponType >= WEAPONTYPE_SHOTGUN && m_eWeaponType <= WEAPONTYPE_FLAMETHROWER && m_eWeaponType != WEAPONTYPE_ROCKETLAUNCHER; // TODO(Miami): Uncomment
return m_eWeaponType == WEAPONTYPE_FLAMETHROWER || m_eWeaponType == WEAPONTYPE_HELICANNON || /* m_eWeaponType == WEAPONTYPE_M60 */
m_eWeaponType == WEAPONTYPE_M16 ||
(m_eWeaponType >= WEAPONTYPE_SHOTGUN && m_eWeaponType < WEAPONTYPE_TEC9) || // Shotguns
m_eWeaponType == WEAPONTYPE_AK47 || m_eWeaponType == WEAPONTYPE_SNIPERRIFLE /*|| m_eWeaponType == WEAPONTYPE_LASERSCOPE*/;
} }
void void

View File

@ -11,7 +11,7 @@
// Yeah... // Yeah...
int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] = { int32 CWeaponInfo::ms_aMaxAmmoForWeapon[WEAPONTYPE_TOTALWEAPONS] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
}; };
CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS]; CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
@ -19,7 +19,17 @@ CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS];
// --MIAMI: Todo // --MIAMI: Todo
static char ms_aWeaponNames[][32] = { static char ms_aWeaponNames[][32] = {
"Unarmed", "Unarmed",
"BrassKnuckle",
"ScrewDriver",
"GolfClub",
"NightStick",
"Knife",
"BaseballBat", "BaseballBat",
"Hammer",
"Cleaver",
"Machete",
"Katana",
"Chainsaw",
"Grenade", "Grenade",
"DetonateGrenade", "DetonateGrenade",
"Molotov", "Molotov",
@ -61,8 +71,7 @@ CWeaponInfo::Initialise(void)
ms_apWeaponInfos[i].m_fLifespan = 0.0f; ms_apWeaponInfos[i].m_fLifespan = 0.0f;
ms_apWeaponInfos[i].m_fSpread = 0.0f; ms_apWeaponInfos[i].m_fSpread = 0.0f;
ms_apWeaponInfos[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f); ms_apWeaponInfos[i].m_vecFireOffset = CVector(0.0f, 0.0f, 0.0f);
// TODO(Miami): ASSOCGRP_UNARMED ms_apWeaponInfos[i].m_AnimToPlay = ASSOCGRP_UNARMED;
ms_apWeaponInfos[i].m_AnimToPlay = ASSOCGRP_STD;
ms_apWeaponInfos[i].m_fAnimLoopStart = 0.0f; ms_apWeaponInfos[i].m_fAnimLoopStart = 0.0f;
ms_apWeaponInfos[i].m_fAnimLoopEnd = 0.0f; ms_apWeaponInfos[i].m_fAnimLoopEnd = 0.0f;
ms_apWeaponInfos[i].m_fAnimFrameFire = 0.0f; ms_apWeaponInfos[i].m_fAnimFrameFire = 0.0f;

View File

@ -4,7 +4,17 @@
enum eWeaponType enum eWeaponType
{ {
WEAPONTYPE_UNARMED, WEAPONTYPE_UNARMED,
WEAPONTYPE_BRASSKNUCKLE,
WEAPONTYPE_SCREWDRIVER,
WEAPONTYPE_GOLFCLUB,
WEAPONTYPE_NIGHTSTICK,
WEAPONTYPE_KNIFE,
WEAPONTYPE_BASEBALLBAT, WEAPONTYPE_BASEBALLBAT,
WEAPONTYPE_HAMMER,
WEAPONTYPE_CLEAVER,
WEAPONTYPE_MACHETE,
WEAPONTYPE_KATANA,
WEAPONTYPE_CHAINSAW,
WEAPONTYPE_GRENADE, WEAPONTYPE_GRENADE,
WEAPONTYPE_DETONATOR_GRENADE, WEAPONTYPE_DETONATOR_GRENADE,
WEAPONTYPE_MOLOTOV, WEAPONTYPE_MOLOTOV,