diff --git a/gamefiles/models/menu.txd b/gamefiles/models/menu.txd index 1ffe750e..f617bcf8 100644 Binary files a/gamefiles/models/menu.txd and b/gamefiles/models/menu.txd differ diff --git a/src/animation/AnimBlendAssociation.h b/src/animation/AnimBlendAssociation.h index f6d98fc3..90e0cfd9 100644 --- a/src/animation/AnimBlendAssociation.h +++ b/src/animation/AnimBlendAssociation.h @@ -84,8 +84,7 @@ public: void SetRun(void) { flags |= ASSOC_RUNNING; } - float GetTimeLeft() { return hierarchy->totalLength - currentTime; } - float GetProgress() { return currentTime / hierarchy->totalLength; } + inline float GetTimeLeft() { return hierarchy->totalLength - currentTime; } static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) { return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link)); diff --git a/src/animation/AnimManager.cpp b/src/animation/AnimManager.cpp index e37c0f8e..ed98be1d 100644 --- a/src/animation/AnimManager.cpp +++ b/src/animation/AnimManager.cpp @@ -134,13 +134,13 @@ AnimAssocDesc aStdAnimDescs[] = { { ANIM_DRIVE_LOW_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVEBY_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVEBY_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, - { ANIM_DRIVEBY_LOW_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, - { ANIM_DRIVEBY_LOW_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, + { ANIM_DRIVEBY_L_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, + { ANIM_DRIVEBY_L_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_CAR_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVE_BOAT, ASSOC_DELETEFADEDOUT | ASSOC_DRIVING }, { ANIM_DRIVE_BOAT_L, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_DRIVE_BOAT_R, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, - { ANIM_BOAT_LB, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, + { ANIM_DRIVE_BOAT_BACK, ASSOC_DELETEFADEDOUT | ASSOC_PARTIAL | ASSOC_DRIVING }, { ANIM_BIKE_PICKUP_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_BIKE_PICKUP_L, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, { ANIM_BIKE_PULLUP_R, ASSOC_FADEOUTWHENDONE | ASSOC_PARTIAL }, diff --git a/src/animation/AnimationId.h b/src/animation/AnimationId.h index a84aa3e8..9fe0cb0e 100644 --- a/src/animation/AnimationId.h +++ b/src/animation/AnimationId.h @@ -118,13 +118,13 @@ enum AnimationId ANIM_DRIVE_LOW_R, ANIM_DRIVEBY_L, ANIM_DRIVEBY_R, - ANIM_DRIVEBY_LOW_L, - ANIM_DRIVEBY_LOW_R, + ANIM_DRIVEBY_L_L, // TODO: is this LOW? + ANIM_DRIVEBY_L_R, ANIM_CAR_LB, ANIM_DRIVE_BOAT, ANIM_DRIVE_BOAT_L, ANIM_DRIVE_BOAT_R, - ANIM_BOAT_LB, + ANIM_DRIVE_BOAT_BACK, ANIM_BIKE_PICKUP_R, ANIM_BIKE_PICKUP_L, diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h index ed63a0e2..e696959c 100644 --- a/src/control/CarCtrl.h +++ b/src/control/CarCtrl.h @@ -9,7 +9,6 @@ #define TIME_COPS_WAIT_TO_EXIT_AFTER_STOPPING 2500 class CZoneInfo; -class CAutomobile; enum{ MAX_CARS_TO_KEEP = 2, diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index eb772e13..330b5788 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -44,44 +44,15 @@ uint32 CPickups::StaticCamStartTime; tPickupMessage CPickups::aMessages[NUMPICKUPMESSAGES]; -// TODO(Miami) +// 20 ?! Some Miami leftover? (Originally at 0x5ED8D4) uint16 AmmoForWeapon[20] = { 0, 1, 45, 125, 25, 150, 300, 25, 5, 250, 5, 5, 0, 500, 0, 100, 0, 0, 0, 0 }; -uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS] = { - 0, - 1, - 4, - 4, - 4, - 4, - 34, - 16, - 100, - 60, - 60, - 60, - 60, - 60, - 20, - 4, - 14, - 1, - 400, -}; +uint16 AmmoForWeapon_OnStreet[20] = { 0, 1, 9, 25, 5, 30, 60, 5, 1, 50, 1, 1, 0, 200, 0, 100, 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!! -uint8 aWeaponReds[] = { 0, 255, 0, 128, 255, 255, 0, 255, 0, 128, 128, 255, -255, 255, 255, 255, 255, 255, 255, 255, -255, 128, 0, 255, 0 }; -uint8 aWeaponGreens[] = { 0, 0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255, -255, 255, 255, 255, 255, 255, 255, 255, -0, 255, 0, 255, 0 }; -uint8 aWeaponBlues[] = { 0, 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, -255, 255, 255, 255, 255, 255, 255, 255, -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, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f }; +uint8 aWeaponReds[] = { 255, 0, 128, 255, 255, 0, 255, 0, 128, 128, 255, 255, 128, 0, 255, 0 }; +uint8 aWeaponGreens[] = { 0, 255, 128, 255, 0, 255, 128, 255, 0, 255, 255, 0, 255, 0, 255, 0 }; +uint8 aWeaponBlues[] = { 0, 0, 255, 0, 255, 255, 0, 128, 255, 0, 255, 0, 128, 255, 0, 0 }; +float aWeaponScale[] = { 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 }; void CPickup::RemoveKeepType() @@ -409,30 +380,6 @@ CPickups::Init(void) CollectedPickUpIndex = 0; } -// --MIAMI: Done -bool -CPickups::TestForPickupsInBubble(CVector pos, float range) -{ - for (int i = 0; i < NUMPICKUPS; i++) { - if ((aPickUps[i].m_vecPos - pos).Magnitude() < range) - return true; - } - return false; -} - -// --MIAMI: Done -bool -CPickups::TryToMerge_WeaponType(CVector pos, eWeaponType weapon, uint8 type, uint32 quantity, bool unused) { - for (int i = 0; i < NUMPICKUPS; i++) { - if (aPickUps[i].m_eType == type && aPickUps[i].m_eModelIndex == ModelForWeapon(weapon)) - if ((aPickUps[i].m_vecPos - pos).Magnitude() < 7.5f) { - aPickUps[i].m_nQuantity += quantity; - return true; - } - } - return false; -} - bool CPickups::IsPickUpPickedUp(int32 pickupId) { @@ -614,22 +561,53 @@ CPickups::GetNewUniquePickupIndex(int32 slot) return slot | (aPickUps[slot].m_nIndex << 16); } -// --MIAMI: Done int32 CPickups::ModelForWeapon(eWeaponType weaponType) { - return CWeaponInfo::GetWeaponInfo(weaponType)->m_nModelId; + switch (weaponType) + { + case WEAPONTYPE_BASEBALLBAT: return MI_BASEBALL_BAT; + case WEAPONTYPE_COLT45: return MI_COLT; + case WEAPONTYPE_UZI: return MI_UZI; + case WEAPONTYPE_SHOTGUN: return MI_SHOTGUN; + case WEAPONTYPE_AK47: return MI_AK47; + case WEAPONTYPE_M16: return MI_M16; + case WEAPONTYPE_SNIPERRIFLE: return MI_SNIPER; + case WEAPONTYPE_ROCKETLAUNCHER: return MI_ROCKETLAUNCHER; + case WEAPONTYPE_FLAMETHROWER: return MI_FLAMETHROWER; + case WEAPONTYPE_MOLOTOV: return MI_MOLOTOV; + case WEAPONTYPE_GRENADE: return MI_GRENADE; + default: break; + } + return 0; } -// --MIAMI: Done eWeaponType CPickups::WeaponForModel(int32 model) { if (model == MI_PICKUP_BODYARMOUR) return WEAPONTYPE_ARMOUR; - if (model == MI_PICKUP_HEALTH) return WEAPONTYPE_HEALTH; - if (model == MI_PICKUP_ADRENALINE) return WEAPONTYPE_ARMOUR; - if (model == -1) return WEAPONTYPE_UNARMED; - return (eWeaponType)((CWeaponModelInfo*)CModelInfo::GetModelInfo(model))->GetWeaponInfo(); + switch (model) + { + case MI_GRENADE: return WEAPONTYPE_GRENADE; + case MI_AK47: return WEAPONTYPE_AK47; + case MI_BASEBALL_BAT: return WEAPONTYPE_BASEBALLBAT; + case MI_COLT: return WEAPONTYPE_COLT45; + case MI_MOLOTOV: return WEAPONTYPE_MOLOTOV; + case MI_ROCKETLAUNCHER: return WEAPONTYPE_ROCKETLAUNCHER; + case MI_SHOTGUN: return WEAPONTYPE_SHOTGUN; + case MI_SNIPER: return WEAPONTYPE_SNIPERRIFLE; + case MI_UZI: return WEAPONTYPE_UZI; + case MI_MISSILE: return WEAPONTYPE_UNARMED; + case MI_M16: return WEAPONTYPE_M16; + case MI_FLAMETHROWER: return WEAPONTYPE_FLAMETHROWER; + } + return WEAPONTYPE_UNARMED; +} + +int32 +CPickups::FindColourIndexForWeaponMI(int32 model) +{ + return WeaponForModel(model) - 1; } void @@ -707,15 +685,15 @@ CPickups::DoPickUpEffects(CEntity *entity) int16 colorId; if (entity->GetModelIndex() == MI_PICKUP_ADRENALINE || entity->GetModelIndex() == MI_PICKUP_CAMERA) - colorId = WEAPONTYPE_LAST_WEAPONTYPE; + colorId = 11; else if (entity->GetModelIndex() == MI_PICKUP_BODYARMOUR || entity->GetModelIndex() == MI_PICKUP_BRIBE) - colorId = WEAPONTYPE_LAST_WEAPONTYPE + 1; + colorId = 12; else if (entity->GetModelIndex() == MI_PICKUP_INFO || entity->GetModelIndex() == MI_PICKUP_KILLFRENZY) - colorId = WEAPONTYPE_LAST_WEAPONTYPE + 2; + colorId = 13; else if (entity->GetModelIndex() == MI_PICKUP_HEALTH || entity->GetModelIndex() == MI_PICKUP_BONUS) - colorId = WEAPONTYPE_LAST_WEAPONTYPE + 3; + colorId = 14; else - colorId = WeaponForModel(entity->GetModelIndex()); + colorId = FindColourIndexForWeaponMI(entity->GetModelIndex()); assert(colorId >= 0); diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 79f52a67..2842edfa 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -85,12 +85,11 @@ public: static bool IsPickUpPickedUp(int32 pickupId); static int32 ModelForWeapon(eWeaponType weaponType); static enum eWeaponType WeaponForModel(int32 model); + static int32 FindColourIndexForWeaponMI(int32 model); static int32 GetActualPickupIndex(int32 index); static int32 GetNewUniquePickupIndex(int32 slot); static void PassTime(uint32 time); static bool GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex); - static bool TestForPickupsInBubble(CVector pos, float range); - static bool TryToMerge_WeaponType(CVector pos, eWeaponType weapon, uint8 type, uint32 quantity, bool unused); static void Load(uint8 *buf, uint32 size); static void Save(uint8 *buf, uint32 *size); @@ -104,7 +103,7 @@ public: }; extern uint16 AmmoForWeapon[20]; -extern uint16 AmmoForWeapon_OnStreet[WEAPONTYPE_TOTALWEAPONS]; +extern uint16 AmmoForWeapon_OnStreet[20]; extern uint16 CostOfWeapon[20]; enum ePacmanPickupType diff --git a/src/control/Script.cpp b/src/control/Script.cpp index ee580cbd..f496ed33 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -2901,7 +2901,13 @@ int8 CRunningScript::ProcessCommands200To299(int32 command) pVehicle->AutoPilot.m_nCarMission = MISSION_CRUISE; pVehicle->bEngineOn = true; pPed->bUsesCollision = false; - pPed->AddInCarAnims(pVehicle, true); +#ifdef FIX_BUGS + AnimationId anim = pVehicle->GetDriverAnim(); +#else + AnimationId anim = pVehicle->bLowVehicle ? ANIM_CAR_LSIT : ANIM_CAR_SIT; +#endif + pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f); + pPed->StopNonPartialAnims(); pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); CWorld::Add(pPed); ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); @@ -4074,7 +4080,13 @@ int8 CRunningScript::ProcessCommands400To499(int32 command) pPed->SetPedState(PED_DRIVING); pVehicle->SetStatus(STATUS_PHYSICS); pPed->bUsesCollision = false; - pPed->AddInCarAnims(pVehicle, false); +#ifdef FIX_BUGS + AnimationId anim = pVehicle->GetDriverAnim(); +#else + AnimationId anim = pVehicle->bLowVehicle ? ANIM_CAR_LSIT : ANIM_CAR_SIT; +#endif + pPed->m_pVehicleAnim = CAnimManager::BlendAnimation(pPed->GetClump(), ASSOCGRP_STD, anim, 100.0f); + pPed->StopNonPartialAnims(); pPed->m_nZoneLevel = CTheZones::GetLevelFromPosition(&pPed->GetPosition()); CWorld::Add(pPed); ScriptParams[0] = CPools::GetPedPool()->GetIndex(pPed); @@ -9741,12 +9753,6 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) return 0; } case COMMAND_IS_ANY_PICKUP_AT_COORDS: - { - CollectParameters(&m_nIp, 3); - CVector pos = *(CVector*)&ScriptParams[0]; - CRunningScript::UpdateCompareFlag(CPickups::TestForPickupsInBubble(pos, 0.5f)); - return 0; - } case COMMAND_GET_FIRST_PICKUP_COORDS: case COMMAND_GET_NEXT_PICKUP_COORDS: case COMMAND_REMOVE_ALL_CHAR_WEAPONS: @@ -9771,17 +9777,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) case COMMAND_HELI_GOTO_COORDS: case COMMAND_IS_INT_VAR_EQUAL_TO_CONSTANT: case COMMAND_IS_INT_LVAR_EQUAL_TO_CONSTANT: - assert(0); case COMMAND_GET_DEAD_CHAR_PICKUP_COORDS: - { - CollectParameters(&m_nIp, 1); - CPed *pTarget = CPools::GetPedPool()->GetAt(ScriptParams[0]); - CVector pos; - pTarget->CreateDeadPedPickupCoors(&pos.x, &pos.y, &pos.z); - *(CVector*)&ScriptParams[0] = pos; - StoreParameters(&m_nIp, 3); - return 0; - } case COMMAND_CREATE_PROTECTION_PICKUP: case COMMAND_IS_CHAR_IN_ANY_BOAT: case COMMAND_IS_PLAYER_IN_ANY_BOAT: diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp index 56c83337..d27a98ec 100644 --- a/src/core/Frontend.cpp +++ b/src/core/Frontend.cpp @@ -5536,10 +5536,9 @@ CMenuManager::PrintMap(void) if (mapPoint.y > fMapCenterY - fMapSize && mapPoint.y < fMapCenterY + fMapSize && mapPoint.x > fMapCenterX - fMapSize && mapPoint.x < fMapCenterX + fMapSize) { - // Don't ask me the meanings, I don't know. Found them by trying float diffX = fMapCenterX - fMapSize, diffY = fMapCenterY - fMapSize; - float x = ((mapPoint.x - diffX) / (fMapSize * 2)) * (WORLD_SIZE_X / MENU_MAP_WIDTH_SCALE) - (WORLD_SIZE_X / 2 + MENU_MAP_LEFT_OFFSET * MENU_MAP_LENGTH_UNIT); - float y = (WORLD_SIZE_Y / 2 - MENU_MAP_TOP_OFFSET * MENU_MAP_LENGTH_UNIT) - ((mapPoint.y - diffY) / (fMapSize * 2)) * (WORLD_SIZE_Y / MENU_MAP_HEIGHT_SCALE); + float x = ((mapPoint.x - diffX) / (fMapSize * 2)) * 4000.0f - 2000.0f; + float y = 2000.0f - ((mapPoint.y - diffY) / (fMapSize * 2)) * 4000.0f; CRadar::ToggleTargetMarker(x, y); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SUCCESS, 0); } @@ -5585,8 +5584,7 @@ CMenuManager::PrintMap(void) if (fMapCenterY + fMapSize < SCREEN_HEIGHT - MENU_Y(60.0f)) fMapCenterY = SCREEN_HEIGHT - MENU_Y(60.0f) - fMapSize; - if (fMapCenterY - fMapSize > SCREEN_HEIGHT / 2) - fMapCenterY = SCREEN_HEIGHT / 2 + fMapSize; + fMapCenterY = Min(fMapCenterY, fMapSize); // To not show beyond north border bMenuMapActive = false; @@ -5656,7 +5654,9 @@ CMenuManager::ConstructStatLine(int rowIdx) STAT_LINE("PL_STAT", nil, false, nil); - int percentCompleted = CStats::GetPercentageProgress(); + int percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 : + CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1)); + percentCompleted = Min(percentCompleted, 100); STAT_LINE("PER_COM", &percentCompleted, false, nil); STAT_LINE("NMISON", &CStats::MissionsGiven, false, nil); diff --git a/src/core/PlayerInfo.cpp b/src/core/PlayerInfo.cpp index adf98701..d7b3f0e5 100644 --- a/src/core/PlayerInfo.cpp +++ b/src/core/PlayerInfo.cpp @@ -142,7 +142,6 @@ CPlayerInfo::Clear(void) m_bFastReload = false; m_bGetOutOfJailFree = false; m_bGetOutOfHospitalFree = false; - m_bDriveByAllowed = true; m_nPreviousTimeRewardedForExplosion = 0; m_nExplosionsSinceLastReward = 0; } diff --git a/src/core/PlayerInfo.h b/src/core/PlayerInfo.h index d72d6cfe..c649d49d 100644 --- a/src/core/PlayerInfo.h +++ b/src/core/PlayerInfo.h @@ -54,7 +54,6 @@ public: bool m_bFastReload; bool m_bGetOutOfJailFree; bool m_bGetOutOfHospitalFree; - bool m_bDriveByAllowed; char m_aSkinName[32]; RwTexture *m_pSkinTexture; diff --git a/src/core/Radar.cpp b/src/core/Radar.cpp index 1267896a..5b0d38e8 100644 --- a/src/core/Radar.cpp +++ b/src/core/Radar.cpp @@ -21,87 +21,49 @@ sRadarTrace CRadar::ms_RadarTrace[NUMRADARBLIPS]; CVector2D vec2DRadarOrigin; int32 gRadarTxdIds[64]; +CSprite2d CRadar::AsukaSprite; +CSprite2d CRadar::BombSprite; +CSprite2d CRadar::CatSprite; CSprite2d CRadar::CentreSprite; -CSprite2d CRadar::MapHereSprite; -CSprite2d CRadar::NorthSprite; -CSprite2d CRadar::AverySprite; -CSprite2d CRadar::BikerSprite; -CSprite2d CRadar::CortezSprite; -CSprite2d CRadar::DiazSprite; -CSprite2d CRadar::KentSprite; -CSprite2d CRadar::LawyerSprite; -CSprite2d CRadar::PhilSprite; -CSprite2d CRadar::BikersSprite; -CSprite2d CRadar::BoatyardSprite; -CSprite2d CRadar::MalibuClubSprite; -CSprite2d CRadar::CubansSprite; -CSprite2d CRadar::FilmSprite; -CSprite2d CRadar::GunSprite; -CSprite2d CRadar::HaitiansSprite; -CSprite2d CRadar::HardwareSprite; -CSprite2d CRadar::SaveHouseSprite; -CSprite2d CRadar::StripSprite; +CSprite2d CRadar::CopcarSprite; +CSprite2d CRadar::DonSprite; +CSprite2d CRadar::EightSprite; +CSprite2d CRadar::ElSprite; CSprite2d CRadar::IceSprite; -CSprite2d CRadar::KCabsSprite; -CSprite2d CRadar::LovefistSprite; -CSprite2d CRadar::PrintworksSprite; -CSprite2d CRadar::PropertySprite; -CSprite2d CRadar::SunYardSprite; +CSprite2d CRadar::JoeySprite; +CSprite2d CRadar::KenjiSprite; +CSprite2d CRadar::LizSprite; +CSprite2d CRadar::LuigiSprite; +CSprite2d CRadar::NorthSprite; +CSprite2d CRadar::RaySprite; +CSprite2d CRadar::SalSprite; +CSprite2d CRadar::SaveSprite; CSprite2d CRadar::SpraySprite; -CSprite2d CRadar::TShirtSprite; -CSprite2d CRadar::TommySprite; -CSprite2d CRadar::PhoneSprite; -CSprite2d CRadar::RadioWildstyleSprite; -CSprite2d CRadar::RadioFlashSprite; -CSprite2d CRadar::RadioKChatSprite; -CSprite2d CRadar::RadioFeverSprite; -CSprite2d CRadar::RadioVRockSprite; -CSprite2d CRadar::RadioVCPRSprite; -CSprite2d CRadar::RadioEspantosoSprite; -CSprite2d CRadar::RadioEmotionSprite; -CSprite2d CRadar::RadioWaveSprite; +CSprite2d CRadar::TonySprite; +CSprite2d CRadar::WeaponSprite; CSprite2d *CRadar::RadarSprites[RADAR_SPRITE_COUNT] = { nil, + &AsukaSprite, + &BombSprite, + &CatSprite, &CentreSprite, - &MapHereSprite, - &NorthSprite, - &AverySprite, - &BikerSprite, - &CortezSprite, - &DiazSprite, - &KentSprite, - &LawyerSprite, - &PhilSprite, - &BikersSprite, - &BoatyardSprite, - &MalibuClubSprite, - &CubansSprite, - &FilmSprite, - &GunSprite, - &HaitiansSprite, - &HardwareSprite, - &SaveHouseSprite, - &StripSprite, + &CopcarSprite, + &DonSprite, + &EightSprite, + &ElSprite, &IceSprite, - &KCabsSprite, - &LovefistSprite, - &PrintworksSprite, - &PropertySprite, - &SunYardSprite, + &JoeySprite, + &KenjiSprite, + &LizSprite, + &LuigiSprite, + &NorthSprite, + &RaySprite, + &SalSprite, + &SaveSprite, &SpraySprite, - &TShirtSprite, - &TommySprite, - &PhoneSprite, - &RadioWildstyleSprite, - &RadioFlashSprite, - &RadioKChatSprite, - &RadioFeverSprite, - &RadioVRockSprite, - &RadioVCPRSprite, - &RadioEspantosoSprite, - &RadioEmotionSprite, - &RadioWaveSprite + &TonySprite, + &WeaponSprite }; // Why this doesn't coincide with world coordinates i don't know @@ -125,11 +87,12 @@ static_assert(RADAR_TILE_SIZE == (RADAR_SIZE_Y / RADAR_NUM_TILES), "CRadar: not CRGBA CRadar::ArrowBlipColour1; CRGBA CRadar::ArrowBlipColour2; uint16 CRadar::MapLegendCounter; -int16 CRadar::MapLegendList[NUM_MAP_LEGENDS]; +uint16 CRadar::MapLegendList[NUM_MAP_LEGENDS]; int CRadar::TargetMarkerId = -1; CVector CRadar::TargetMarkerPos; #endif +// taken from VC float CRadar::cachedCos; float CRadar::cachedSin; @@ -310,9 +273,12 @@ void CRadar::ClearBlip(int32 i) if (index != -1) { SetRadarMarkerState(index, false); ms_RadarTrace[index].m_bInUse = false; +#ifndef MENU_MAP + // Ssshhh ms_RadarTrace[index].m_eBlipType = BLIP_NONE; ms_RadarTrace[index].m_eBlipDisplay = BLIP_DISPLAY_NEITHER; ms_RadarTrace[index].m_eRadarSprite = RADAR_SPRITE_NONE; +#endif } } @@ -412,8 +378,9 @@ int CRadar::ClipRadarPoly(CVector2D *poly, const CVector2D *rect) bool CRadar::DisplayThisBlip(int32 counter) { switch (ms_RadarTrace[counter].m_eRadarSprite) { + case RADAR_SPRITE_BOMB: case RADAR_SPRITE_SPRAY: - case RADAR_SPRITE_GUN: + case RADAR_SPRITE_WEAPON: return true; default: return false; @@ -514,6 +481,11 @@ void CRadar::DrawBlips() CEntity *blipEntity = nil; for(int blipId = 0; blipId < NUMRADARBLIPS; blipId++) { +#ifdef MENU_MAP + // A little hack to reuse cleared blips in menu map. hehe + if (!CMenuManager::bMenuMapActive || ms_RadarTrace[blipId].m_eBlipType == BLIP_CAR || + ms_RadarTrace[blipId].m_eBlipType == BLIP_CHAR || ms_RadarTrace[blipId].m_eBlipType == BLIP_OBJECT) +#endif if (!ms_RadarTrace[blipId].m_bInUse) continue; @@ -521,8 +493,8 @@ void CRadar::DrawBlips() case BLIP_CAR: case BLIP_CHAR: case BLIP_OBJECT: - if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE - || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_GUN) { + if (ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE + || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_WEAPON) { switch (ms_RadarTrace[blipId].m_eBlipType) { case BLIP_CAR: @@ -580,8 +552,8 @@ void CRadar::DrawBlips() break; case BLIP_COORD: case BLIP_CONTACT_POINT: - if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE - || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_GUN) + if ((ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_BOMB || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SAVE + || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_SPRAY || ms_RadarTrace[blipId].m_eRadarSprite == RADAR_SPRITE_WEAPON) && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); @@ -631,8 +603,8 @@ void CRadar::DrawBlips() case BLIP_CAR: case BLIP_CHAR: case BLIP_OBJECT: - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE - && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN) { + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_WEAPON) { switch (ms_RadarTrace[blipId].m_eBlipType) { case BLIP_CAR: @@ -700,8 +672,8 @@ void CRadar::DrawBlips() switch (ms_RadarTrace[blipId].m_eBlipType) { case BLIP_COORD: case BLIP_CONTACT_POINT: - if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE - && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_GUN + if (ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_BOMB && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SAVE + && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_SPRAY && ms_RadarTrace[blipId].m_eRadarSprite != RADAR_SPRITE_WEAPON && (ms_RadarTrace[blipId].m_eBlipType != BLIP_CONTACT_POINT || !CTheScripts::IsPlayerOnAMission())) { uint32 color = GetRadarTraceColour(ms_RadarTrace[blipId].m_nColor, ms_RadarTrace[blipId].m_bDim); @@ -1075,45 +1047,26 @@ CRadar::LoadTextures() { CTxdStore::PushCurrentTxd(); CTxdStore::SetCurrentTxd(CTxdStore::FindTxdSlot("hud")); + AsukaSprite.SetTexture("radar_asuka"); + BombSprite.SetTexture("radar_bomb"); + CatSprite.SetTexture("radar_cat"); CentreSprite.SetTexture("radar_centre"); - MapHereSprite.SetTexture("arrow"); + CopcarSprite.SetTexture("radar_copcar"); + DonSprite.SetTexture("radar_don"); + EightSprite.SetTexture("radar_eight"); + ElSprite.SetTexture("radar_el"); + IceSprite.SetTexture("radar_ice"); + JoeySprite.SetTexture("radar_joey"); + KenjiSprite.SetTexture("radar_kenji"); + LizSprite.SetTexture("radar_liz"); + LuigiSprite.SetTexture("radar_luigi"); NorthSprite.SetTexture("radar_north"); - AverySprite.SetTexture("radar_avery"); - BikerSprite.SetTexture("radar_biker"); - CortezSprite.SetTexture("radar_cortez"); - DiazSprite.SetTexture("radar_diaz"); - KentSprite.SetTexture("radar_kent"); - LawyerSprite.SetTexture("radar_lawyer"); - PhilSprite.SetTexture("radar_phil"); - BikersSprite.SetTexture("bikers"); - BoatyardSprite.SetTexture("boatyard"); - MalibuClubSprite.SetTexture("club"); - CubansSprite.SetTexture("cubans"); - FilmSprite.SetTexture("filmstudio"); - GunSprite.SetTexture("gun"); - HaitiansSprite.SetTexture("haitians"); - HardwareSprite.SetTexture("hardware"); - SaveHouseSprite.SetTexture("radar_save"); - StripSprite.SetTexture("radar_strip"); - IceSprite.SetTexture("icecream"); - KCabsSprite.SetTexture("kcabs"); - LovefistSprite.SetTexture("lovefist"); - PrintworksSprite.SetTexture("printworks"); - PropertySprite.SetTexture("property"); - SunYardSprite.SetTexture("SunYard"); - SpraySprite.SetTexture("spray"); - TShirtSprite.SetTexture("tshirt"); - TommySprite.SetTexture("tommy"); - PhoneSprite.SetTexture("phone"); - RadioWildstyleSprite.SetTexture("RWildstyle"); - RadioFlashSprite.SetTexture("RFlash"); - RadioKChatSprite.SetTexture("RKchat"); - RadioFeverSprite.SetTexture("RFever"); - RadioVRockSprite.SetTexture("RVRock"); - RadioVCPRSprite.SetTexture("RVCPR"); - RadioEspantosoSprite.SetTexture("REspantoso"); - RadioEmotionSprite.SetTexture("REmotion"); - RadioWaveSprite.SetTexture("RWave"); + RaySprite.SetTexture("radar_ray"); + SalSprite.SetTexture("radar_sal"); + SaveSprite.SetTexture("radar_save"); + SpraySprite.SetTexture("radar_spray"); + TonySprite.SetTexture("radar_tony"); + WeaponSprite.SetTexture("radar_weapon"); CTxdStore::PopCurrentTxd(); } @@ -1295,45 +1248,26 @@ void CRadar::ShowRadarTraceWithHeight(float x, float y, uint32 size, uint8 red, void CRadar::Shutdown() { + AsukaSprite.Delete(); + BombSprite.Delete(); + CatSprite.Delete(); CentreSprite.Delete(); - MapHereSprite.Delete(); - NorthSprite.Delete(); - AverySprite.Delete(); - BikerSprite.Delete(); - CortezSprite.Delete(); - DiazSprite.Delete(); - KentSprite.Delete(); - LawyerSprite.Delete(); - PhilSprite.Delete(); - BikersSprite.Delete(); - BoatyardSprite.Delete(); - MalibuClubSprite.Delete(); - CubansSprite.Delete(); - FilmSprite.Delete(); - GunSprite.Delete(); - HaitiansSprite.Delete(); - HardwareSprite.Delete(); - SaveHouseSprite.Delete(); - StripSprite.Delete(); + CopcarSprite.Delete(); + DonSprite.Delete(); + EightSprite.Delete(); + ElSprite.Delete(); IceSprite.Delete(); - KCabsSprite.Delete(); - LovefistSprite.Delete(); - PrintworksSprite.Delete(); - PropertySprite.Delete(); - SunYardSprite.Delete(); + JoeySprite.Delete(); + KenjiSprite.Delete(); + LizSprite.Delete(); + LuigiSprite.Delete(); + NorthSprite.Delete(); + RaySprite.Delete(); + SalSprite.Delete(); + SaveSprite.Delete(); SpraySprite.Delete(); - TShirtSprite.Delete(); - TommySprite.Delete(); - PhoneSprite.Delete(); - RadioWildstyleSprite.Delete(); - RadioFlashSprite.Delete(); - RadioKChatSprite.Delete(); - RadioFeverSprite.Delete(); - RadioVRockSprite.Delete(); - RadioVCPRSprite.Delete(); - RadioEspantosoSprite.Delete(); - RadioEmotionSprite.Delete(); - RadioWaveSprite.Delete(); + TonySprite.Delete(); + WeaponSprite.Delete(); RemoveRadarSections(); } @@ -1404,8 +1338,9 @@ void CRadar::TransformRadarPointToScreenSpace(CVector2D &out, const CVector2D &i { #ifdef MENU_MAP if (CMenuManager::bMenuMapActive) { - out.x = (CMenuManager::fMapCenterX - CMenuManager::fMapSize) + (MENU_MAP_LENGTH / 2 + MENU_MAP_LEFT_OFFSET + in.x) * CMenuManager::fMapSize * MENU_MAP_WIDTH_SCALE * 2.0f / MENU_MAP_LENGTH; - out.y = (CMenuManager::fMapCenterY - CMenuManager::fMapSize) + (MENU_MAP_LENGTH / 2 - MENU_MAP_TOP_OFFSET - in.y) * CMenuManager::fMapSize * MENU_MAP_HEIGHT_SCALE * 2.0f / MENU_MAP_LENGTH; + // fMapSize is actually half map size. Radar range is 1000, so if x is -2000, in.x + 2.0f is 0. + out.x = (CMenuManager::fMapCenterX - CMenuManager::fMapSize) + (in.x + 2.0f) * CMenuManager::fMapSize * 2.0f / 4.0f; + out.y = (CMenuManager::fMapCenterY - CMenuManager::fMapSize) + (2.0f - in.y) * CMenuManager::fMapSize * 2.0f / 4.0f; } else #endif { @@ -1493,7 +1428,7 @@ CRadar::InitFrontEndMap() CalculateCachedSinCos(); vec2DRadarOrigin.x = 0.0f; vec2DRadarOrigin.y = 0.0f; - m_radarRange = MENU_MAP_LENGTH_UNIT; // just affects the multiplier in TransformRadarPointToScreenSpace + m_radarRange = 1000.0f; // doesn't mean anything, just affects the calculation in TransformRadarPointToScreenSpace for (int i = 0; i < NUM_MAP_LEGENDS; i++) { MapLegendList[i] = RADAR_SPRITE_NONE; } diff --git a/src/core/Radar.h b/src/core/Radar.h index f68d290c..43c9766a 100644 --- a/src/core/Radar.h +++ b/src/core/Radar.h @@ -1,13 +1,6 @@ #pragma once #include "Sprite2d.h" -#define MENU_MAP_LENGTH_UNIT 1190.0f // in game unit -#define MENU_MAP_WIDTH_SCALE 1.112f // in game unit (originally 1.112494151260504f) -#define MENU_MAP_HEIGHT_SCALE 1.119f // in game unit (originally 1.118714268907563f) -#define MENU_MAP_TOP_OFFSET 0.28f // in length unit defined above - ~333 game unit -#define MENU_MAP_LEFT_OFFSET 0.185f // in length unit defined above - ~220 game unit -#define MENU_MAP_LENGTH (4000.f / MENU_MAP_LENGTH_UNIT) - enum eBlipType { BLIP_NONE, @@ -33,47 +26,27 @@ enum eRadarSprite RADAR_SPRITE_COORD_BLIP = -1, #endif RADAR_SPRITE_NONE = 0, - RADAR_SPRITE_CENTRE, - RADAR_SPRITE_MAP_HERE, - RADAR_SPRITE_NORTH, - RADAR_SPRITE_AVERY, - RADAR_SPRITE_BIKER, - RADAR_SPRITE_CORTEZ, - RADAR_SPRITE_DIAZ, - RADAR_SPRITE_KENT, - RADAR_SPRITE_LAWYER, - RADAR_SPRITE_PHIL, - RADAR_SPRITE_BIKERS, - RADAR_SPRITE_BOATYARD, - RADAR_SPRITE_MALIBU_CLUB, - RADAR_SPRITE_CUBANS, - RADAR_SPRITE_FILM, - RADAR_SPRITE_GUN, - RADAR_SPRITE_HAITIANS, - RADAR_SPRITE_HARDWARE, - RADAR_SPRITE_SAVE, - RADAR_SPRITE_STRIP, - RADAR_SPRITE_ICE, - RADAR_SPRITE_KCABS, - RADAR_SPRITE_LOVEFIST, - RADAR_SPRITE_PRINTWORKS, - RADAR_SPRITE_PROPERTY, - RADAR_SPRITE_SUNYARD, - RADAR_SPRITE_SPRAY, - RADAR_SPRITE_TSHIRT, - RADAR_SPRITE_TOMMY, - RADAR_SPRITE_PHONE, - RADAR_SPRITE_RADIO_WILDSTYLE, - RADAR_SPRITE_RADIO_FLASH, - RADAR_SPRITE_RADIO_KCHAT, - RADAR_SPRITE_RADIO_FEVER, - RADAR_SPRITE_RADIO_VROCK, - RADAR_SPRITE_RADIO_VCPR, - RADAR_SPRITE_RADIO_ESPANTOSO, - RADAR_SPRITE_RADIO_EMOTION, - RADAR_SPRITE_RADIO_WAVE, - - RADAR_SPRITE_COUNT + RADAR_SPRITE_ASUKA = 1, + RADAR_SPRITE_BOMB = 2, + RADAR_SPRITE_CAT = 3, + RADAR_SPRITE_CENTRE = 4, + RADAR_SPRITE_COPCAR = 5, + RADAR_SPRITE_DON = 6, + RADAR_SPRITE_EIGHT = 7, + RADAR_SPRITE_EL = 8, + RADAR_SPRITE_ICE = 9, + RADAR_SPRITE_JOEY = 10, + RADAR_SPRITE_KENJI = 11, + RADAR_SPRITE_LIZ = 12, + RADAR_SPRITE_LUIGI = 13, + RADAR_SPRITE_NORTH = 14, + RADAR_SPRITE_RAY = 15, + RADAR_SPRITE_SAL = 16, + RADAR_SPRITE_SAVE = 17, + RADAR_SPRITE_SPRAY = 18, + RADAR_SPRITE_TONY = 19, + RADAR_SPRITE_WEAPON = 20, + RADAR_SPRITE_COUNT = 21, }; enum @@ -111,53 +84,34 @@ class CRadar public: static float m_radarRange; static sRadarTrace ms_RadarTrace[NUMRADARBLIPS]; + static CSprite2d AsukaSprite; + static CSprite2d BombSprite; + static CSprite2d CatSprite; static CSprite2d CentreSprite; - static CSprite2d MapHereSprite; - static CSprite2d NorthSprite; - static CSprite2d AverySprite; - static CSprite2d BikerSprite; - static CSprite2d CortezSprite; - static CSprite2d DiazSprite; - static CSprite2d KentSprite; - static CSprite2d LawyerSprite; - static CSprite2d PhilSprite; - static CSprite2d BikersSprite; - static CSprite2d BoatyardSprite; - static CSprite2d MalibuClubSprite; - static CSprite2d CubansSprite; - static CSprite2d FilmSprite; - static CSprite2d GunSprite; - static CSprite2d HaitiansSprite; - static CSprite2d HardwareSprite; - static CSprite2d SaveHouseSprite; - static CSprite2d StripSprite; + static CSprite2d CopcarSprite; + static CSprite2d DonSprite; + static CSprite2d EightSprite; + static CSprite2d ElSprite; static CSprite2d IceSprite; - static CSprite2d KCabsSprite; - static CSprite2d LovefistSprite; - static CSprite2d PrintworksSprite; - static CSprite2d PropertySprite; - static CSprite2d SunYardSprite; + static CSprite2d JoeySprite; + static CSprite2d KenjiSprite; + static CSprite2d LizSprite; + static CSprite2d LuigiSprite; + static CSprite2d NorthSprite; + static CSprite2d RaySprite; + static CSprite2d SalSprite; + static CSprite2d SaveSprite; static CSprite2d SpraySprite; - static CSprite2d TShirtSprite; - static CSprite2d TommySprite; - static CSprite2d PhoneSprite; - static CSprite2d RadioWildstyleSprite; - static CSprite2d RadioFlashSprite; - static CSprite2d RadioKChatSprite; - static CSprite2d RadioFeverSprite; - static CSprite2d RadioVRockSprite; - static CSprite2d RadioVCPRSprite; - static CSprite2d RadioEspantosoSprite; - static CSprite2d RadioEmotionSprite; - static CSprite2d RadioWaveSprite; - static CSprite2d *RadarSprites[RADAR_SPRITE_COUNT]; + static CSprite2d TonySprite; + static CSprite2d WeaponSprite; + static CSprite2d *RadarSprites[21]; static float cachedCos; static float cachedSin; #ifdef MENU_MAP #define NUM_MAP_LEGENDS 75 static CRGBA ArrowBlipColour1; static CRGBA ArrowBlipColour2; - static int16 MapLegendList[NUM_MAP_LEGENDS]; + static uint16 MapLegendList[NUM_MAP_LEGENDS]; static uint16 MapLegendCounter; static int TargetMarkerId; static CVector TargetMarkerPos; diff --git a/src/core/Stats.cpp b/src/core/Stats.cpp index ed3943c9..d50be0d5 100644 --- a/src/core/Stats.cpp +++ b/src/core/Stats.cpp @@ -249,14 +249,6 @@ int32 CStats::FindCriminalRatingNumber() return rating; } -float CStats::GetPercentageProgress() -{ - float percentCompleted = (CStats::TotalProgressInGame == 0 ? 0 : - CStats::ProgressMade * 100.0f / (CGame::nastyGame ? CStats::TotalProgressInGame : CStats::TotalProgressInGame - 1.0f)); - - return Min(percentCompleted, 100.0f); -} - void CStats::SaveStats(uint8 *buf, uint32 *size) { CheckPointReachedSuccessfully(); diff --git a/src/core/Stats.h b/src/core/Stats.h index bf5450aa..bf40a5a6 100644 --- a/src/core/Stats.h +++ b/src/core/Stats.h @@ -90,5 +90,4 @@ public: static int32 FindCriminalRatingNumber(); static void SaveStats(uint8 *buf, uint32 *size); static void LoadStats(uint8 *buf, uint32 size); - static float GetPercentageProgress(); }; diff --git a/src/core/World.cpp b/src/core/World.cpp index f6817f8b..ef124c07 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -340,6 +340,21 @@ CWorld::ProcessLineOfSightSectorList(CPtrList &list, const CColLine &line, CColP if(e->IsPed()) { if(e->bUsesCollision || deadPeds && ((CPed *)e)->m_nPedState == PED_DEAD) { colmodel = ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex()))->AnimatePedColModelSkinned(e->GetClump()); +/* this should all be gone, right? + if(((CPed *)e)->UseGroundColModel()) + colmodel = &CTempColModels::ms_colModelPedGroundHit; + else +#ifdef ANIMATE_PED_COL_MODEL + colmodel = CPedModelInfo::AnimatePedColModel( + ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex())) + ->GetHitColModel(), + RpClumpGetFrame(e->GetClump())); +#else + colmodel = + ((CPedModelInfo *)CModelInfo::GetModelInfo(e->GetModelIndex())) + ->GetHitColModel(); +#endif +*/ } else colmodel = nil; diff --git a/src/core/config.h b/src/core/config.h index 30f6b898..83aca235 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -194,7 +194,7 @@ enum Config { #define FIX_BUGS // fixes bugs that we've came across during reversing, TODO: use this more #define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things -#define MORE_LANGUAGES // Add more translations to the game +//#define MORE_LANGUAGES // Add more translations to the game #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define USE_TXD_CDIMAGE // generate and load textures from txd.img #define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number diff --git a/src/core/main.cpp b/src/core/main.cpp index 9b40b81d..dc61f03f 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -81,7 +81,7 @@ RwRGBA gColourTop; bool gameAlreadyInitialised; float NumberOfChunksLoaded; -#define TOTALNUMCHUNKS 95.0f +#define TOTALNUMCHUNKS 73.0f bool g_SlowMode = false; char version_name[64]; @@ -356,7 +356,6 @@ Terminate3D(void) CSprite2d splash; int splashTxdId = -1; -//--MIAMI: done CSprite2d* LoadSplash(const char *name) { @@ -402,23 +401,22 @@ DestroySplashScreen(void) splashTxdId = -1; } -//--MIAMI: done Const char* GetRandomSplashScreen(void) { int index; static int index2 = 0; static char splashName[128]; - static int splashIndex[12] = { - 1, 2, - 3, 4, - 5, 11, - 6, 8, - 9, 10, - 7, 12 + static int splashIndex[24] = { + 25, 22, 4, 13, + 1, 21, 14, 16, + 10, 12, 5, 9, + 11, 18, 3, 2, + 19, 23, 7, 17, + 15, 6, 8, 20 }; - index = splashIndex[2*index2 + CGeneral::GetRandomNumberInRange(0, 2)]; + index = splashIndex[4*index2 + CGeneral::GetRandomNumberInRange(0, 3)]; index2++; if(index2 == 6) index2 = 0; @@ -445,14 +443,17 @@ ResetLoadingScreenBar() NumberOfChunksLoaded = 0.0f; } -//--MIAMI: done +// TODO: compare with PS2 void LoadingScreen(const char *str1, const char *str2, const char *splashscreen) { CSprite2d *splash; #ifndef RANDOMSPLASH - splashscreen = "LOADSC0"; + if(CGame::frenchGame || CGame::germanGame || !CGame::nastyGame) + splashscreen = "mainsc2"; + else + splashscreen = "mainsc1"; #endif splash = LoadSplash(splashscreen); @@ -473,50 +474,36 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen) if(str1){ NumberOfChunksLoaded += 1; -#ifndef RANDOMSPLASH float hpos = SCREEN_SCALE_X(40); - float length = SCREEN_WIDTH - SCREEN_SCALE_X(80); - float top = SCREEN_HEIGHT - SCREEN_SCALE_Y(14); - float bottom = top + SCREEN_SCALE_Y(5); -#else - float hpos = SCREEN_STRETCH_X(40); - float length = SCREEN_STRETCH_X(440); - // this is rather weird - float top = SCREEN_STRETCH_Y(407.4f - 7.0f/3.0f); - float bottom = SCREEN_STRETCH_Y(407.4f + 7.0f/3.0f); -#endif - - CSprite2d::DrawRect(CRect(hpos-1.0f, top-1.0f, hpos+length+1.0f, bottom+1.0f), CRGBA(40, 53, 68, 255)); - - CSprite2d::DrawRect(CRect(hpos, top, hpos+length, bottom), CRGBA(155, 50, 125, 255)); + float length = SCREEN_WIDTH - SCREEN_SCALE_X(100); + float vpos = SCREEN_HEIGHT - SCREEN_SCALE_Y(13); + float height = SCREEN_SCALE_Y(7); + CSprite2d::DrawRect(CRect(hpos, vpos, hpos + length, vpos + height), CRGBA(40, 53, 68, 255)); length *= NumberOfChunksLoaded/TOTALNUMCHUNKS; - CSprite2d::DrawRect(CRect(hpos, top, hpos+length, bottom), CRGBA(255, 150, 225, 255)); + CSprite2d::DrawRect(CRect(hpos, vpos, hpos + length, vpos + height), CRGBA(81, 106, 137, 255)); // this is done by the game but is unused - CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(2), SCREEN_SCALE_Y(2)); CFont::SetPropOn(); CFont::SetRightJustifyOn(); - CFont::SetDropShadowPosition(1); - CFont::SetDropColor(CRGBA(0, 0, 0, 255)); CFont::SetFontStyle(FONT_HEADING); #ifdef CHATTYSPLASH // my attempt static wchar tmpstr[80]; float yscale = SCREEN_SCALE_Y(0.9f); - top -= 45*yscale; + vpos -= 45*yscale; CFont::SetScale(SCREEN_SCALE_X(0.75f), yscale); CFont::SetPropOn(); CFont::SetRightJustifyOff(); CFont::SetFontStyle(FONT_BANK); CFont::SetColor(CRGBA(255, 255, 255, 255)); AsciiToUnicode(str1, tmpstr); - CFont::PrintString(hpos, top, tmpstr); - top += 22*yscale; + CFont::PrintString(hpos, vpos, tmpstr); + vpos += 22*yscale; AsciiToUnicode(str2, tmpstr); - CFont::PrintString(hpos, top, tmpstr); + CFont::PrintString(hpos, vpos, tmpstr); #endif } diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp index b35ddb25..6f8ebcb4 100644 --- a/src/entities/Entity.cpp +++ b/src/entities/Entity.cpp @@ -400,6 +400,22 @@ CEntity::PreRender(void) GetMatrix().UpdateRW(); UpdateRwFrame(); } + }else if(IsPickupModel(GetModelIndex())){ + if(((CObject*)this)->bIsPickup){ + CPickups::DoPickUpEffects(this); + GetMatrix().UpdateRW(); + UpdateRwFrame(); + }else if(GetModelIndex() == MI_GRENADE){ + CMotionBlurStreaks::RegisterStreak((uintptr)this, + 100, 100, 100, + GetPosition() - 0.07f*TheCamera.GetRight(), + GetPosition() + 0.07f*TheCamera.GetRight()); + }else if(GetModelIndex() == MI_MOLOTOV){ + CMotionBlurStreaks::RegisterStreak((uintptr)this, + 0, 100, 0, + GetPosition() - 0.07f*TheCamera.GetRight(), + GetPosition() + 0.07f*TheCamera.GetRight()); + } }else if(GetModelIndex() == MI_MISSILE){ CVector pos = GetPosition(); float flicker = (CGeneral::GetRandomNumber() & 0xF)/(float)0x10; @@ -421,22 +437,7 @@ CEntity::PreRender(void) CCoronas::FLARE_NONE, CCoronas::REFLECTION_ON, CCoronas::LOSCHECK_OFF, CCoronas::STREAK_OFF, 0.0f); }else if(IsGlass(GetModelIndex())){ - if(!((CSimpleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()))->m_isArtistGlass) - PreRenderForGlassWindow(); - }else if (((CObject*)this)->bIsPickup) { - CPickups::DoPickUpEffects(this); - GetMatrix().UpdateRW(); - UpdateRwFrame(); - } else if (GetModelIndex() == MI_GRENADE) { - CMotionBlurStreaks::RegisterStreak((uintptr)this, - 100, 100, 100, - GetPosition() - 0.07f * TheCamera.GetRight(), - GetPosition() + 0.07f * TheCamera.GetRight()); - } else if (GetModelIndex() == MI_MOLOTOV) { - CMotionBlurStreaks::RegisterStreak((uintptr)this, - 0, 100, 0, - GetPosition() - 0.07f * TheCamera.GetRight(), - GetPosition() + 0.07f * TheCamera.GetRight()); + PreRenderForGlassWindow(); } // fall through case ENTITY_TYPE_DUMMY: diff --git a/src/modelinfo/ModelIndices.h b/src/modelinfo/ModelIndices.h index 9846796d..25eb4cf0 100644 --- a/src/modelinfo/ModelIndices.h +++ b/src/modelinfo/ModelIndices.h @@ -412,9 +412,7 @@ enum MI_AK47 = 276, MI_SHOTGUN = 279, MI_M16 = 280, - MI_TEC9 = 281, MI_UZI = 282, - MI_SILENCEDINGRAM = 283, MI_MP5 = 284, MI_SNIPER = 285, MI_ROCKETLAUNCHER = 287, @@ -530,6 +528,29 @@ IsBannerModel(int16 id) id == MI_ITALYBANNER1 || id == MI_CHINALANTERN; } +inline bool +IsPickupModel(int16 id) +{ + return id == MI_GRENADE || + id == MI_AK47 || + id == MI_BASEBALL_BAT || + id == MI_COLT || + id == MI_MOLOTOV || + id == MI_ROCKETLAUNCHER || + id == MI_SHOTGUN || + id == MI_SNIPER || + id == MI_UZI || + id == MI_M16 || + id == MI_FLAMETHROWER || + id == MI_PICKUP_ADRENALINE || + id == MI_PICKUP_BODYARMOUR || + id == MI_PICKUP_INFO || + id == MI_PICKUP_HEALTH || + id == MI_PICKUP_BONUS || + id == MI_PICKUP_BRIBE || + id == MI_PICKUP_KILLFRENZY || + id == MI_PICKUP_CAMERA; +} inline bool IsPolicePedModel(int16 id) diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp index b68b96c0..48785025 100644 --- a/src/peds/CivilianPed.cpp +++ b/src/peds/CivilianPed.cpp @@ -200,7 +200,7 @@ CCivilianPed::ProcessControl(void) if (DyingOrDead()) return; - GetWeapon()->Update(m_audioEntityId, nil); + GetWeapon()->Update(m_audioEntityId); switch (m_nPedState) { case PED_WANDER_RANGE: case PED_WANDER_PATH: diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 578f2454..1affb64d 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -589,7 +589,7 @@ CCopPed::ProcessControl(void) ArrestPlayer(); return; } - GetWeapon()->Update(m_audioEntityId, nil); + GetWeapon()->Update(m_audioEntityId); if (m_moved.Magnitude() > 0.0f) Avoid(); diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp index a62ac76d..04e5dd6a 100644 --- a/src/peds/EmergencyPed.cpp +++ b/src/peds/EmergencyPed.cpp @@ -49,7 +49,7 @@ CEmergencyPed::ProcessControl(void) return; if(!DyingOrDead()) { - GetWeapon()->Update(m_audioEntityId, nil); + GetWeapon()->Update(m_audioEntityId); if (IsPedInControl() && m_moved.Magnitude() > 0.0f) Avoid(); diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index 0eb85f34..8da8249e 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -67,9 +67,6 @@ uint16 gnNumTempPedList; CColPoint aTempPedColPts[MAX_COLLISION_POINTS]; -// TODO(Miami) -#define AUDIO_NOT_READY - // Corresponds to ped sounds (from SOUND_PED_DEATH to SOUND_PED_TAXI_CALL) PedAudioData CommentWaitTime[39] = { {500, 800, 500, 2}, @@ -648,7 +645,6 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) m_maxWeaponTypeAllowed = WEAPONTYPE_UNARMED; m_currentWeapon = WEAPONTYPE_UNARMED; m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; - m_delayedWeapon = WEAPONTYPE_UNIDENTIFIED; for(int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { CWeapon &weapon = GetWeapon(i); @@ -660,7 +656,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this) } m_lastFightMove = FIGHTMOVE_NULL; - GiveWeapon(WEAPONTYPE_UNARMED, 0, true); + GiveWeapon(WEAPONTYPE_UNARMED, 0); m_wepAccuracy = 60; m_lastWepDam = -1; m_collPoly.valid = false; @@ -1183,7 +1179,7 @@ CPed::FinishedReloadCB(CAnimBlendAssociation *reloadAssoc, void *arg) crouchFireAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), ANIM_WEAPON_CROUCHFIRE); } if (!!weapon->m_bReload && reloadAssoc) { - if (reloadAssoc->animId == GetCrouchReloadAnim(weapon) && !crouchFireAssoc) { + if (reloadAssoc->animId == ANIM_WEAPON_CROUCHRELOAD && !crouchFireAssoc) { CAnimBlendAssociation *crouchAssoc = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_WEAPON_CROUCH, 8.0f); crouchAssoc->SetCurrentTime(crouchAssoc->hierarchy->totalLength); crouchAssoc->flags &= ~ASSOC_RUNNING; @@ -1216,7 +1212,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg) if (ped->m_nPedState != PED_ATTACK) { if (ped->bIsDucking && ped->IsPedInControl()) { if (currentWeapon->m_bReload) { - reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon)); + reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), ANIM_WEAPON_CROUCHRELOAD); } if (currentWeapon->m_bCrouchFire && attackAssoc) { if (attackAssoc->animId == ANIM_WEAPON_CROUCHFIRE && !reloadAnimAssoc) { @@ -1242,7 +1238,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg) if (ped->bIsDucking && ped->bCrouchWhenShooting) { if (currentWeapon->m_bReload) { - reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), GetCrouchReloadAnim(currentWeapon)); + reloadAnimAssoc = RpAnimBlendClumpGetAssociation(ped->GetClump(), ANIM_WEAPON_CROUCHRELOAD); } if (currentWeapon->m_bCrouchFire && attackAssoc) { if (attackAssoc->animId == ANIM_WEAPON_CROUCHFIRE && !reloadAnimAssoc) { @@ -1306,7 +1302,7 @@ CPed::FinishedAttackCB(CAnimBlendAssociation *attackAssoc, void *arg) } } -// --MIAMI: Done except melee weapons +// --MIAMI: Done void CPed::Attack(void) { @@ -1358,11 +1354,11 @@ CPed::Attack(void) } if (ourWeapon->m_bReload) { - reloadAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetReloadAnim(ourWeapon)); + reloadAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_RELOAD); } if (!!ourWeapon->m_bReload && !reloadAnimAssoc) { - reloadAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(ourWeapon)); + reloadAnimAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHRELOAD); } if ( reloadAnimAssoc && reloadAnimAssoc->IsRunning() ) { @@ -1522,22 +1518,14 @@ CPed::Attack(void) case ASSOCGRP_UNARMED: if (weaponAnimAssoc->animId == ANIM_FIGHT_PPUNCH || // TODO(Miami): Remove after fighting done weaponAnimAssoc->animId == ANIM_MELEE_ATTACK || weaponAnimAssoc->animId == ANIM_MELEE_ATTACK_START) { -#ifdef AUDIO_NOT_READY - DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_PUNCH_39, 0.0f); -#else DMAudio.PlayOneShot(m_audioEntityId, SOUND_FIGHT_PUNCH_39, (damagerType | (ourWeaponType << 8))); -#endif } break; case ASSOCGRP_KNIFE: case ASSOCGRP_BASEBALLBAT: case ASSOCGRP_GOLFCLUB: case ASSOCGRP_CHAINSAW: -#ifdef AUDIO_NOT_READY - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, 1.0f); -#else DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_BAT_ATTACK, (damagerType | (ourWeaponType << 8))); -#endif break; default: break; @@ -1599,12 +1587,12 @@ CPed::Attack(void) if (bIsDucking) { newReloadAssoc = CAnimManager::BlendAnimation( GetClump(), ourWeapon->m_AnimToPlay, - GetCrouchReloadAnim(ourWeapon), + ANIM_WEAPON_CROUCHRELOAD, 8.0f); } else { newReloadAssoc = CAnimManager::BlendAnimation( GetClump(), ourWeapon->m_AnimToPlay, - GetReloadAnim(ourWeapon), + ANIM_WEAPON_RELOAD, 8.0f); } newReloadAssoc->SetFinishCallback(FinishedReloadCB, this); @@ -1614,26 +1602,7 @@ CPed::Attack(void) bIsAttacking = false; bIsPointingGunAt = false; m_shootTimer = CTimer::GetTimeInMilliseconds(); -#ifdef AUDIO_NOT_READY - switch (ourWeaponType) { - case WEAPONTYPE_UZI: - case WEAPONTYPE_TEC9: - case WEAPONTYPE_SILENCED_INGRAM: - case WEAPONTYPE_MP5: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f); - break; - case WEAPONTYPE_AK47: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f); - break; - case WEAPONTYPE_M16: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f); - break; - default: - break; - } -#else DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, GetWeapon()->m_eWeaponType); -#endif return; } } @@ -1678,28 +1647,10 @@ CPed::Attack(void) ClearAimFlag(); // Echoes of bullets, at the end of the attack. (Bug: doesn't play while reloading) - if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep < animLoopEnd) { - -#ifdef AUDIO_NOT_READY - switch (ourWeaponType) { - case WEAPONTYPE_UZI: - case WEAPONTYPE_TEC9: - case WEAPONTYPE_SILENCED_INGRAM: - case WEAPONTYPE_MP5: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_UZI_BULLET_ECHO, 0.0f); - break; - case WEAPONTYPE_AK47: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, 0.0f); - break; - case WEAPONTYPE_M16: - DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_M16_BULLET_ECHO, 0.0f); - break; - default: - break; - } -#else + if (weaponAnimAssoc->currentTime - weaponAnimAssoc->timeStep < ourWeapon->m_fAnimLoopEnd) { + + // What?! Weapon id as volume?? DMAudio.PlayOneShot(m_audioEntityId, SOUND_WEAPON_AK47_BULLET_ECHO, GetWeapon()->m_eWeaponType); -#endif } // Fun fact: removing this part leds to reloading flamethrower @@ -2182,7 +2133,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) case ANIM_VAN_GETIN: #ifdef VC_PED_PORTS multExtractedFromAnim = true; - zBlend = Max(m_pVehicleAnim->GetProgress() - 0.3f, 0.0f) / (1.0f - 0.3f); + zBlend = Max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.3f, 0.0f) / (1.0f - 0.3f); // fall through #endif case ANIM_CAR_QJACKED: @@ -2193,7 +2144,7 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) #ifdef VC_PED_PORTS if (!multExtractedFromAnim) { multExtractedFromAnim = true; - zBlend = Max(m_pVehicleAnim->GetProgress() - 0.5f, 0.0f) / (1.0f - 0.5f); + zBlend = Max(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength - 0.5f, 0.0f) / (1.0f - 0.5f); } // fall through #endif @@ -2201,14 +2152,14 @@ CPed::LineUpPedWithCar(PedLineUpPhase phase) case ANIM_CAR_CRAWLOUT_RHS2: case ANIM_VAN_GETOUT_L: case ANIM_VAN_GETOUT: - seatPosMult = m_pVehicleAnim->GetProgress(); + seatPosMult = m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength; break; case ANIM_CAR_GETIN_RHS: case ANIM_CAR_GETIN_LHS: #ifdef VC_PED_PORTS if (veh && veh->IsCar() && veh->bIsBus) { multExtractedFromAnimBus = true; - zBlend = Min(m_pVehicleAnim->GetProgress(), 0.5f) / 0.5f; + zBlend = Min(m_pVehicleAnim->currentTime / m_pVehicleAnim->hierarchy->totalLength, 0.5f) / 0.5f; } // fall through #endif @@ -2677,7 +2628,6 @@ CPed::SetPedStats(ePedStats pedStat) m_pedStats = CPedStats::ms_apPedStats[pedStat]; } -// --MIAMI: Done void CPed::SetModelIndex(uint32 mi) { @@ -2690,24 +2640,12 @@ CPed::SetModelIndex(uint32 mi) m_animGroup = (AssocGroupId) modelInfo->m_animGroup; CAnimManager::AddAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE); - // TODO(Miami): This is something inlined for sure - bool canUseMyBody = false; - if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) { - if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN) - canUseMyBody = true; - } - if (!canUseMyBody) - m_pedIK.m_flags |= CPedIK::LOOKAROUND_HEAD_ONLY; - // This is a mistake by R*, velocity is CVector, whereas m_vecAnimMoveDelta is CVector2D. (*RPANIMBLENDCLUMPDATA(m_rwObject))->velocity = (CVector*) &m_vecAnimMoveDelta; #ifdef PED_SKIN if(modelInfo->GetHitColModel() == nil) modelInfo->CreateHitColModelSkinned(GetClump()); - - if (IsClumpSkinned(GetClump())) // condition isn't there in VC - UpdateRpHAnim(); #endif } @@ -4582,9 +4520,6 @@ CPed::SetGetUp(void) } if (m_nPedState != PED_GETUP) { SetStoredState(); - if (m_nPedState == PED_FOLLOW_PATH) - ClearFollowPath(); - m_nPedState = PED_GETUP; } @@ -5184,7 +5119,7 @@ CPed::SetAttack(CEntity *victim) return; if (curWeapon->m_bReload && - (RpAnimBlendClumpGetAssociation(GetClump(), GetReloadAnim(curWeapon)) || RpAnimBlendClumpGetAssociation(GetClump(), GetCrouchReloadAnim(curWeapon)))) { + (RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_RELOAD) || RpAnimBlendClumpGetAssociation(GetClump(), ANIM_WEAPON_CROUCHRELOAD))) { if (!IsPlayer() || m_nPedState != PED_ATTACK || ((CPlayerPed*)this)->m_bHaveTargetSelected) bIsAttacking = false; else @@ -5576,13 +5511,13 @@ CPed::FightStrike(CVector &touchedNodePos) for (int j = 0; j < hisCol->numSpheres; j++) { attackDistance = hisCol->spheres[j].center; attackDistance -= touchedNodePos; - CColSphere *hisPieces = hisCol->spheres; - float maxDistanceToBeat = hisPieces[j].radius + tFightMoves[m_lastFightMove].strikeRadius; + CColSphere *ourPieces = hisCol->spheres; + float maxDistanceToBeat = ourPieces[j].radius + tFightMoves[m_lastFightMove].strikeRadius; // We can beat him too if (sq(maxDistanceToBeat) > attackDistance.MagnitudeSqr()) { pedFound = true; - closestPedPiece = (ePedPieceTypes) hisPieces[j].piece; + closestPedPiece = (ePedPieceTypes) ourPieces[j].piece; break; } } @@ -6389,22 +6324,28 @@ CPed::CreateDeadPedMoney(void) } void -CPed::CreateDeadPedPickupCoors(float *x, float *y, float *z) +CPed::CreateDeadPedWeaponPickups(void) { bool found = false; + float angleToPed; CVector pickupPos; -#define NUMBER_OF_ATTEMPTS 32 - for (int i = 0; i < NUMBER_OF_ATTEMPTS; i++) { + if (bInVehicle) + return; - pickupPos = GetPosition(); - pickupPos.x = 1.5f * Sin((CGeneral::GetRandomNumber() % 256) * PI / 128) + GetPosition().x; - pickupPos.y = 1.5f * Cos((CGeneral::GetRandomNumber() % 256) * PI / 128) + GetPosition().y; - pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f; + for(int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - if (!found) + eWeaponType weapon = GetWeapon(i).m_eWeaponType; + int weaponAmmo = GetWeapon(i).m_nAmmoTotal; + if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || (weaponAmmo == 0 && !GetWeapon(i).IsTypeMelee())) continue; + angleToPed = i * 1.75f; + pickupPos = GetPosition(); + pickupPos.x += 1.5f * Sin(angleToPed); + pickupPos.y += 1.5f * Cos(angleToPed); + pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f; + CVector pedPos = GetPosition(); pedPos.z += 0.3f; @@ -6412,53 +6353,21 @@ CPed::CreateDeadPedPickupCoors(float *x, float *y, float *z) float distance = pedToPickup.Magnitude(); // outer edge of pickup - distance = (distance + 0.4f) / distance; + distance = (distance + 0.3f) / distance; CVector pickupPos2 = pedPos; pickupPos2 += distance * pedToPickup; - if ((pickupPos - FindPlayerCoors()).Magnitude2D() > 2.0f || i > NUMBER_OF_ATTEMPTS / 2) { - - if (i > NUMBER_OF_ATTEMPTS / 2 || !CPickups::TestForPickupsInBubble(pickupPos, 1.3f)) { - - if (CWorld::GetIsLineOfSightClear(pickupPos2, pedPos, - true, i < NUMBER_OF_ATTEMPTS / 2, false, i < NUMBER_OF_ATTEMPTS / 2, false, false, false)) { - - if (i > NUMBER_OF_ATTEMPTS / 2 || !CWorld::TestSphereAgainstWorld(pickupPos, 1.2f, nil, false, true, false, false, false, false)) { - *x = pickupPos.x; - *y = pickupPos.y; - *z = pickupPos.z; - return; - } - } - } - } - } - *x = GetPosition().x; - *y = GetPosition().y; - *z = GetPosition().z + 0.4f; -#undef NUMBER_OF_ATTEMPTS -} - -void -CPed::CreateDeadPedWeaponPickups(void) -{ - CVector pickupPos; - - if (bInVehicle) - return; - - for(int i = 0; i < TOTAL_WEAPON_SLOTS; i++) { - - eWeaponType weapon = GetWeapon(i).m_eWeaponType; - int weaponAmmo = GetWeapon(i).m_nAmmoTotal; - if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || (weaponAmmo == 0 && !GetWeapon(i).IsTypeMelee())) - continue; - - int quantity = Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon] / 2); - CreateDeadPedPickupCoors(&pickupPos.x, &pickupPos.y, &pickupPos.z); - if (!CPickups::TryToMerge_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, quantity, false)) { - CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, quantity)); + // pickup must be on ground and line to its edge must be clear + if (!found || CWorld::GetIsLineOfSightClear(pickupPos2, pedPos, true, false, false, false, false, false, false)) { + // otherwise try another position (but disregard second check apparently) + angleToPed += 3.14f; + pickupPos = GetPosition(); + pickupPos.x += 1.5f * Sin(angleToPed); + pickupPos.y += 1.5f * Cos(angleToPed); + pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f; } + if (found) + CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon])); } ClearWeapons(); } @@ -9036,11 +8945,7 @@ CPed::InvestigateEvent(void) bool CPed::IsPedDoingDriveByShooting(void) { -#ifdef FIX_BUGS if (FindPlayerPed() == this && CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_nWeaponSlot == 5) { -#else - if (FindPlayerPed() == this && GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI) { -#endif if (TheCamera.Cams[TheCamera.ActiveCam].LookingLeft || TheCamera.Cams[TheCamera.ActiveCam].LookingRight) return true; } @@ -10077,8 +9982,11 @@ CPed::ProcessControl(void) if (m_nPedState == PED_FOLLOW_PATH) { if (DotProduct(m_vecDamageNormal, GetForward()) < -0.866f && CanPedJumpThis(collidingEnt, &m_vecDamageNormal)) { SetJump(); + + // Moved break into here, for compatibility with III + break; } - break; + // break; } #endif if (m_pedInObjective && @@ -11049,13 +10957,15 @@ CPed::ProcessControl(void) return; } - if (m_pMyVehicle->pDriver != this) { + if (m_pMyVehicle->pDriver != this || m_pMyVehicle->IsBoat()) { LookForSexyPeds(); LookForSexyCars(); break; } - // TODO(Miami): Start KILL_CHAR_ON_BOAT objective + if (m_pMyVehicle->m_vehType == VEHICLE_TYPE_BIKE || !m_pMyVehicle->pDriver->IsPlayer()) { + break; + } CPad* pad = CPad::GetPad(0); @@ -11085,24 +10995,12 @@ CPed::ProcessControl(void) } } #endif - - // TODO(Miami): This part moved to DriveVehicle in VC float steerAngle = m_pMyVehicle->m_fSteerAngle; CAnimBlendAssociation *lDriveAssoc; CAnimBlendAssociation *rDriveAssoc; CAnimBlendAssociation *lbAssoc; CAnimBlendAssociation *sitAssoc; - if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT)) { - sitAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVE_BOAT); - - if (!sitAssoc || sitAssoc->blendAmount < 1.0f) { - break; - } - - lDriveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVE_BOAT_L); - rDriveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVE_BOAT_R); - lbAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_BOAT_LB); - } else if (m_pMyVehicle->bLowVehicle) { + if (m_pMyVehicle->bLowVehicle) { sitAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_LSIT); if (!sitAssoc || sitAssoc->blendAmount < 1.0f) { @@ -11122,21 +11020,18 @@ CPed::ProcessControl(void) lDriveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVE_L); rDriveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVE_R); lbAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_LB); - } - if (lbAssoc && - TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON - && TheCamera.Cams[TheCamera.ActiveCam].DirectionWasLooking == LOOKING_LEFT) { - lbAssoc->blendDelta = -1000.0f; + if (lbAssoc && + TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON + && TheCamera.Cams[TheCamera.ActiveCam].DirectionWasLooking == LOOKING_LEFT) { + lbAssoc->blendDelta = -1000.0f; + } } CAnimBlendAssociation *driveByAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVEBY_L); + if (!driveByAssoc) driveByAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVEBY_R); - if (!driveByAssoc) - driveByAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVEBY_LOW_L); - if (!driveByAssoc) - driveByAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DRIVEBY_LOW_R); if (m_pMyVehicle->bLowVehicle || m_pMyVehicle->m_fGasPedal >= 0.0f || driveByAssoc) { if (steerAngle == 0.0f || driveByAssoc) { @@ -11151,8 +11046,6 @@ CPed::ProcessControl(void) if (rDriveAssoc) rDriveAssoc->blendAmount = clamp(steerAngle * -100.0f / 61.0f, 0.0f, 1.0f); - else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT)) - CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT_R); else if (m_pMyVehicle->bLowVehicle) CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_LOW_R); else @@ -11164,8 +11057,6 @@ CPed::ProcessControl(void) if (lDriveAssoc) lDriveAssoc->blendAmount = clamp(steerAngle * 100.0f / 61.0f, 0.0f, 1.0f); - else if (m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT)) - CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT_L); else if (m_pMyVehicle->bLowVehicle) CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_LOW_L); else @@ -11178,18 +11069,10 @@ CPed::ProcessControl(void) if ((TheCamera.Cams[TheCamera.ActiveCam].Mode != CCam::MODE_1STPERSON || TheCamera.Cams[TheCamera.ActiveCam].DirectionWasLooking != LOOKING_LEFT) - && (!lbAssoc || lbAssoc->blendAmount < 1.0f && lbAssoc->blendDelta <= 0.0f)) { - - if(m_pMyVehicle->IsBoat() && !(m_pMyVehicle->pHandling->Flags & HANDLING_SIT_IN_BOAT)) - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_BOAT_LB, 4.0f); - else - CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_LB, 4.0f); + && (!lbAssoc || lbAssoc->blendAmount < 1.0f)) { + CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_LB, 4.0f); } } - - // TODO(Miami): This part belongs to DriveVehicle - if (!m_pMyVehicle) - return; break; } case PED_DIE: @@ -11241,8 +11124,7 @@ CPed::ProcessControl(void) } m_pCurrentPhysSurface = nil; } - } else - ServiceTalking(); + } } void @@ -11263,27 +11145,11 @@ CPed::SetInTheAir(void) } -// --MIAMI: Done void CPed::RestoreHeadPosition(void) { - bool canUseMyBody = false; - if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) { - if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN) - canUseMyBody = true; - } - if (!canUseMyBody) - m_pedIK.m_flags |= CPedIK::LOOKAROUND_HEAD_ONLY; - if (m_pedIK.RestoreLookAt()) { bIsRestoringLook = false; - canUseMyBody = false; - if (m_nPedState != PED_DRIVING && m_nPedState != PED_DRAG_FROM_CAR && !bIsDucking) { - if (m_animGroup != ASSOCGRP_SEXYWOMAN && m_animGroup != ASSOCGRP_WOMAN) - canUseMyBody = true; - } - if(canUseMyBody) - m_pedIK.m_flags &= ~CPedIK::LOOKAROUND_HEAD_ONLY; } } @@ -12368,7 +12234,19 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg) ped->SetObjective(OBJECTIVE_NONE); } - ped->AddInCarAnims(veh, veh->pDriver == ped); + if (veh->pDriver == ped) { + if (veh->bLowVehicle) { + ped->m_pVehicleAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_LSIT, 100.0f); + } else { + ped->m_pVehicleAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_SIT, 100.0f); + } + } else if (veh->bLowVehicle) { + ped->m_pVehicleAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_SITPLO, 100.0f); + } else { + ped->m_pVehicleAnim = CAnimManager::BlendAnimation(ped->GetClump(), ASSOCGRP_STD, ANIM_CAR_SITP, 100.0f); + } + + ped->StopNonPartialAnims(); if (veh->bIsBus) ped->bRenderPedInCar = false; @@ -12773,11 +12651,11 @@ CPed::ReplaceWeaponWhenExitingVehicle(void) } } -// --MIAMI: Done +// --MIAMI: Add driveby check, enumarate weapon slots inline void CPed::RemoveWeaponWhenEnteringVehicle(void) { - if (IsPlayer() && HasWeaponSlot(5) && GetWeapon(5).m_nAmmoTotal > 0 && ((CPlayerPed*)this)->GetPlayerInfoForThisPlayerPed()->m_bDriveByAllowed) { + if (IsPlayer() && GetWeapon(5).m_eWeaponType && GetWeapon(5).m_nAmmoTotal > 0) { if (m_storedWeapon == WEAPONTYPE_UNIDENTIFIED) m_storedWeapon = GetWeapon()->m_eWeaponType; SetCurrentWeapon(GetWeapon(5).m_eWeaponType); @@ -14312,7 +14190,7 @@ CPed::ProcessObjective(void) if (reloadAssoc || !m_pedInObjective->IsPedShootable()) { if (reloadAssoc && - (!reloadAssoc->IsRunning() || reloadAssoc->GetProgress() > 0.8f)) { + (!reloadAssoc->IsRunning() || reloadAssoc->currentTime / reloadAssoc->hierarchy->totalLength > 0.8f)) { CAnimBlendAssociation *punchAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_FIGHT_PPUNCH, 8.0f); punchAssoc->flags |= ASSOC_DELETEFADEDOUT; punchAssoc->flags |= ASSOC_FADEOUTWHENDONE; @@ -17651,11 +17529,33 @@ CPed::WarpPedIntoCar(CVehicle *car) DMAudio.PlayOneShot(car->m_audioEntityId, SOUND_CAR_ENGINE_START, 1.0f); } +#ifdef VC_PED_PORTS RpAnimBlendClumpSetBlendDeltas(GetClump(), ASSOC_PARTIAL, -1000.0f); - AddInCarAnims(car, car->pDriver == this); + // VC uses AddInCarAnims but we don't have that + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, car->GetDriverAnim(), 100.0f); RemoveWeaponWhenEnteringVehicle(); +#else + if (car->IsBoat()) { +#ifndef FIX_BUGS + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT, 100.0f); +#else + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, car->GetDriverAnim(), 100.0f); +#endif + CWeaponInfo *ourWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType); + RemoveWeaponModel(ourWeapon->m_nModelId); + } else { + // Because we can use Uzi for drive by + RemoveWeaponWhenEnteringVehicle(); + if (car->bLowVehicle) + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_LSIT, 100.0f); + else + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_SIT, 100.0f); + } +#endif + + StopNonPartialAnims(); if (car->bIsBus) bRenderPedInCar = false; @@ -17937,13 +17837,25 @@ CPed::SetEnterCar_AllClear(CVehicle *car, uint32 doorNode, uint32 doorFlag) m_vecOffsetSeek = doorOpenPos - GetPosition(); m_nPedStateTimer = CTimer::GetTimeInMilliseconds() + 600; if (car->IsBoat()) { - if(car->pHandling->Flags & HANDLING_SIT_IN_BOAT) +#ifdef VC_PED_PORTS + // VC checks for handling flag, but we can't do that + if(car->GetModelIndex() == MI_SPEEDER) m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_SIT, 100.0f); else m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT, 100.0f); PedSetInCarCB(nil, this); bVehExitWillBeInstant = true; +#else + +#ifndef FIX_BUGS + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, ANIM_DRIVE_BOAT, 100.0f); +#else + m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, car->GetDriverAnim(), 100.0f); +#endif + + m_pVehicleAnim->SetFinishCallback(PedSetInCarCB, this); +#endif if (IsPlayer()) CWaterLevel::AllocateBoatWakeArray(); } else { @@ -18506,15 +18418,14 @@ CPed::Load(uint8*& buf) #undef CopyToBuf #endif -// --MIAMI: Done void CPed::GiveDelayedWeapon(eWeaponType weapon, uint32 ammo) { - m_delayedWeapon = weapon; - m_delayedWeaponAmmo = ammo; - if (m_delayedWeapon != WEAPONTYPE_UNIDENTIFIED) { - int modelId1 = CWeaponInfo::GetWeaponInfo(m_delayedWeapon)->m_nModelId; - int modelId2 = CWeaponInfo::GetWeaponInfo(m_delayedWeapon)->m_nModel2Id; + m_storedWeapon = weapon; + m_storedWeaponAmmo = ammo; + if (m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { + int modelId1 = CWeaponInfo::GetWeaponInfo(m_storedWeapon)->m_nModelId; + int modelId2 = CWeaponInfo::GetWeaponInfo(m_storedWeapon)->m_nModel2Id; if (modelId1 != -1) CStreaming::RequestModel(modelId1, STREAMFLAGS_DEPENDENCY); if (modelId2 != -1) @@ -18522,19 +18433,18 @@ CPed::GiveDelayedWeapon(eWeaponType weapon, uint32 ammo) if ((modelId1 == -1 || CStreaming::HasModelLoaded(modelId1)) && (modelId2 == -1 || CStreaming::HasModelLoaded(modelId2))) { - GiveWeapon(m_delayedWeapon, m_delayedWeaponAmmo, true); - m_delayedWeapon = WEAPONTYPE_UNIDENTIFIED; + GiveWeapon(m_storedWeapon, m_storedWeaponAmmo, 1); + m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; } } } -// --MIAMI: Done void CPed::RequestDelayedWeapon() { - if (m_delayedWeapon != WEAPONTYPE_UNIDENTIFIED) { - int modelId1 = CWeaponInfo::GetWeaponInfo(m_delayedWeapon)->m_nModelId; - int modelId2 = CWeaponInfo::GetWeaponInfo(m_delayedWeapon)->m_nModel2Id; + if (m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) { + int modelId1 = CWeaponInfo::GetWeaponInfo(m_storedWeapon)->m_nModelId; + int modelId2 = CWeaponInfo::GetWeaponInfo(m_storedWeapon)->m_nModel2Id; if (modelId1 != -1) CStreaming::RequestModel(modelId1, STREAMFLAGS_DEPENDENCY); if (modelId2 != -1) @@ -18542,13 +18452,12 @@ CPed::RequestDelayedWeapon() if ((modelId1 == -1 || CStreaming::HasModelLoaded(modelId1)) && (modelId2 == -1 || CStreaming::HasModelLoaded(modelId2))) { - GiveWeapon(m_delayedWeapon, m_delayedWeaponAmmo, 1); - m_delayedWeapon = WEAPONTYPE_UNIDENTIFIED; + GiveWeapon(m_storedWeapon, m_storedWeaponAmmo, 1); + m_storedWeapon = WEAPONTYPE_UNIDENTIFIED; } } } -// --MIAMI: Done void CPed::ClearFollowPath() { @@ -18557,44 +18466,4 @@ CPed::ClearFollowPath() } m_nPathNodes = 0; m_nCurPathNode = 0; -} - -// --MIAMI: Done -void -CPed::AddInCarAnims(CVehicle* car, bool isDriver) -{ - AnimationId anim; - AssocGroupId group; - if (car->IsBoat()) { - if (car->pHandling->Flags & HANDLING_SIT_IN_BOAT) { - anim = ANIM_CAR_SIT; - } else { - anim = ANIM_DRIVE_BOAT; - } - group = ASSOCGRP_STD; - } else if (car->IsBike()) { - if (isDriver) { - // TODO(Miami): Bikes - } else { - // TODO(Miami): Bikes - } - } else { - if (isDriver) { - if (car->bLowVehicle) { - anim = ANIM_CAR_LSIT; - } else { - anim = ANIM_CAR_SIT; - } - } else { - if (car->bLowVehicle) { - anim = ANIM_CAR_SITPLO; - } else { - anim = ANIM_CAR_SITP; - } - } - group = ASSOCGRP_STD; - } - m_pVehicleAnim = CAnimManager::BlendAnimation(GetClump(), group, anim, 100.0f); - - StopNonPartialAnims(); } \ No newline at end of file diff --git a/src/peds/Ped.h b/src/peds/Ped.h index 42fec06c..32557cb6 100644 --- a/src/peds/Ped.h +++ b/src/peds/Ped.h @@ -523,8 +523,7 @@ public: CVector2D *m_wanderRangeBounds; // array with 2 CVector2D (actually unused CRange2D class) - unused CWeapon m_weapons[TOTAL_WEAPON_SLOTS]; eWeaponType m_storedWeapon; - eWeaponType m_delayedWeapon; - uint32 m_delayedWeaponAmmo; + uint32 m_storedWeaponAmmo; uint8 m_currentWeapon; // eWeaponType uint8 m_maxWeaponTypeAllowed; // eWeaponType uint8 m_wepSkills; @@ -705,7 +704,7 @@ public: void RemoveWeaponAnims(int, float); void CreateDeadPedMoney(void); void CreateDeadPedWeaponPickups(void); - void CreateDeadPedPickupCoors(float *x, float *y, float *z); +// void CreateDeadPedPickupCoors(float *x, float *y, float *z); void SetAttackTimer(uint32); void SetBeingDraggedFromCar(CVehicle*, uint32, bool); void SetRadioStation(void); @@ -776,7 +775,6 @@ public: void ClearFollowPath(); void GiveDelayedWeapon(eWeaponType weapon, uint32 ammo); void RequestDelayedWeapon(); - void AddInCarAnims(CVehicle* car, bool isDriver); // Static methods static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset); @@ -877,7 +875,7 @@ public: bool Dead(void) { return m_nPedState == PED_DEAD; } bool Dying(void) { return m_nPedState == PED_DIE; } 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 InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state. @@ -893,7 +891,7 @@ public: void RemoveWeaponWhenEnteringVehicle(void); bool IsNotInWreckedVehicle(); - // My names. Inlined in VC + // My addons. Maybe inlined in VC? AnimationId GetFireAnimNotDucking(CWeaponInfo* weapon) { // TODO(Miami): Revert that when weapons got ported if (weapon->m_AnimToPlay == ASSOCGRP_STD) @@ -930,20 +928,6 @@ public: else return ANIM_WEAPON_FIRE; } - - static AnimationId GetCrouchReloadAnim(CWeaponInfo* weapon) { - if (!!weapon->m_bReload) - return ANIM_WEAPON_CROUCHRELOAD; - else - return (AnimationId)0; - } - - static AnimationId GetReloadAnim(CWeaponInfo* weapon) { - if (!!weapon->m_bReload) - return ANIM_WEAPON_RELOAD; - else - return (AnimationId)0; - } // -- // My additions, because there were many, many instances of that. diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp index 69a6d211..826cc9e9 100644 --- a/src/peds/PlayerPed.cpp +++ b/src/peds/PlayerPed.cpp @@ -451,7 +451,7 @@ CPlayerPed::SetRealMoveAnim(void) } else if (curSprintAssoc->blendDelta >= 0.0f || curSprintAssoc->blendAmount >= 0.8f) { if (m_fMoveSpeed < 0.4f) { AnimationId runStopAnim; - if (curSprintAssoc->GetProgress() < 0.5) // double + if (curSprintAssoc->currentTime / curSprintAssoc->hierarchy->totalLength < 0.5) // double runStopAnim = ANIM_RUN_STOP; else runStopAnim = ANIM_RUN_STOP_R; @@ -638,7 +638,7 @@ CPlayerPed::PlayerControlSniper(CPad *padUsed) firePos = GetMatrix() * firePos; GetWeapon()->Fire(this, &firePos); } - GetWeapon()->Update(m_audioEntityId, nil); + GetWeapon()->Update(m_audioEntityId); } // --MIAMI: Made compatible with slots, but still TODO @@ -742,7 +742,7 @@ CPlayerPed::PlayerControlM16(CPad *padUsed) firePos = GetMatrix() * firePos; GetWeapon()->Fire(this, &firePos); } - GetWeapon()->Update(m_audioEntityId, nil); + GetWeapon()->Update(m_audioEntityId); } void @@ -1561,7 +1561,7 @@ CPlayerPed::ProcessControl(void) } if (padUsed && IsPedShootable()) { ProcessWeaponSwitch(padUsed); - GetWeapon()->Update(m_audioEntityId, this); + GetWeapon()->Update(m_audioEntityId); } ProcessAnimGroups(); if (padUsed) { diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 44bedab9..1c613acc 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -722,7 +722,7 @@ CPopulation::AddToPopulation(float minDist, float maxDist, float minDistOffScree } CPed* -CPopulation::AddPedInCar(CVehicle* car, bool isDriver) +CPopulation::AddPedInCar(CVehicle* car, bool isPassenger) { int defaultModel = MI_MALE01; int miamiViceIndex = 0; @@ -765,7 +765,7 @@ CPopulation::AddPedInCar(CVehicle* car, bool isDriver) case MI_VICECHEE: // TODO(MIAMI): figure out new structure of the function preferredModel = COP_MIAMIVICE; pedType = PEDTYPE_COP; - miamiViceIndex = (isDriver ? 2 * CCarCtrl::MiamiViceCycle : 2 * CCarCtrl::MiamiViceCycle + 1); + miamiViceIndex = (isPassenger ? 2 * CCarCtrl::MiamiViceCycle : 2 * CCarCtrl::MiamiViceCycle + 1); break; case MI_TAXI: case MI_CABBIE: @@ -816,11 +816,29 @@ CPopulation::AddPedInCar(CVehicle* car, bool isDriver) CPed *newPed = CPopulation::AddPed((ePedType)pedType, preferredModel, car->GetPosition(), miamiViceIndex); newPed->bUsesCollision = false; - if (newPed->GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) { + // what?? + if (pedType != PEDTYPE_COP) { + newPed->SetCurrentWeapon(WEAPONTYPE_COLT45); newPed->RemoveWeaponModel(CWeaponInfo::GetWeaponInfo(newPed->GetWeapon()->m_eWeaponType)->m_nModelId); } + /* + // Miami leftover + if (car->m_vehType == VEHICLE_TYPE_BIKE) { + newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, *((CBike*)car + 308h), 100.0f); + } else */ - newPed->AddInCarAnims(car, isDriver); + // FIX: Make peds comfortable while driving car/boat +#ifdef FIX_BUGS + { + newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, car->GetDriverAnim(), 100.0f); + } +#else + { + newPed->m_pVehicleAnim = CAnimManager::BlendAnimation(newPed->GetClump(), ASSOCGRP_STD, ANIM_CAR_SIT, 100.0f); + } +#endif + + newPed->StopNonPartialAnims(); return newPed; } diff --git a/src/peds/Population.h b/src/peds/Population.h index ae4aa44c..20d6e567 100644 --- a/src/peds/Population.h +++ b/src/peds/Population.h @@ -70,7 +70,7 @@ public: static void LoadPedGroups(); static void UpdatePedCount(ePedType, bool); static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool); - static CPed *AddPedInCar(CVehicle *car, bool isDriver); + static CPed *AddPedInCar(CVehicle *car, bool isPassenger); static bool IsPointInSafeZone(CVector *coors); static void RemovePed(CPed *ent); static int32 ChooseCivilianOccupation(int32); diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp index 6a8e6f9a..e06cc143 100644 --- a/src/render/Hud.cpp +++ b/src/render/Hud.cpp @@ -21,28 +21,6 @@ #include "User.h" #include "World.h" -// Game has colors inlined in code. -// For easier modification we collect them here: -CRGBA MONEY_COLOR(0, 207, 133, 255); -CRGBA AMMO_COLOR(255, 150, 225, 255); -CRGBA HEALTH_COLOR(255, 150, 225, 255); -CRGBA ARMOUR_COLOR(185, 185, 185, 255); -CRGBA NOTWANTED_COLOR(27, 89, 130, 255); -CRGBA WANTED_COLOR_FLASH(62, 141, 181, 255); -CRGBA WANTED_COLOR(97, 194, 247, 255); -CRGBA ZONE_COLOR(45, 155, 90, 255); -CRGBA VEHICLE_COLOR(97, 194, 247, 255); -CRGBA CLOCK_COLOR(97, 194, 247, 255); -CRGBA TIMER_COLOR(97, 194, 247, 255); -CRGBA COUNTER_COLOR(97, 194, 247, 255); -CRGBA PAGER_COLOR(32, 162, 66, 205); -CRGBA RADARDISC_COLOR(255, 255, 255, 255); -CRGBA BIGMESSAGE_COLOR(85, 119, 133, 255); -CRGBA WASTEDBUSTED_COLOR(170, 123, 87, 255); -CRGBA ODDJOB_COLOR(89, 115, 150, 255); -CRGBA ODDJOB2_COLOR(156, 91, 40, 255); -CRGBA MISSIONTITLE_COLOR(220, 172, 2, 255); - wchar CHud::m_HelpMessage[256]; wchar CHud::m_LastHelpMessage[256]; uint32 CHud::m_HelpMessageState; @@ -274,7 +252,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f - 2.0f), SCREEN_SCALE_Y(43.0f + 2.0f), sPrint); - CFont::SetColor(MONEY_COLOR); + CFont::SetColor(CRGBA(89, 115, 150, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(43.0f), sPrint); /* @@ -357,7 +335,7 @@ void CHud::Draw() if (!CDarkel::FrenzyOnGoing() && weaponInfo->m_nWeaponSlot > 1 && weapon->m_eWeaponType != WEAPONTYPE_DETONATOR) { CFont::SetDropShadowPosition(2); CFont::SetDropColor(CRGBA(0, 0, 0, 255)); - CFont::SetColor(AMMO_COLOR); + CFont::SetColor(CRGBA(255, 150, 225, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(90.0f), sPrint); CFont::SetDropShadowPosition(0); } @@ -395,7 +373,7 @@ void CHud::Draw() if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4) { CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(164.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrintIcon); } - CFont::SetColor(HEALTH_COLOR); + CFont::SetColor(CRGBA(186, 101, 50, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f), SCREEN_SCALE_Y(65.0f), sPrint); @@ -426,7 +404,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(234.0f - 2.0f), SCREEN_SCALE_Y(65.0f + 2.0f), sPrintIcon); } - CFont::SetColor(ARMOUR_COLOR); + CFont::SetColor(CRGBA(124, 140, 95, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint); @@ -456,10 +434,7 @@ void CHud::Draw() && (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange + 2000 || CTimer::GetFrameCounter() & 4)) { - CFont::SetColor(WANTED_COLOR); - CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); - }else{ - CFont::SetColor(NOTWANTED_COLOR); + CFont::SetColor(CRGBA(193, 164, 120, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(110.0f + 23.0f * i), SCREEN_SCALE_Y(87.0f), sPrintIcon); } } @@ -553,7 +528,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, fZoneAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f) + SCREEN_SCALE_Y(1.0f), m_ZoneToPrint); - CFont::SetColor(CRGBA(ZONE_COLOR.r, ZONE_COLOR.g, ZONE_COLOR.b, fZoneAlpha)); + CFont::SetColor(CRGBA(152, 154, 82, fZoneAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(30.0f), m_ZoneToPrint); } } @@ -647,7 +622,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, fVehicleAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f) + SCREEN_SCALE_X(1.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f) + SCREEN_SCALE_Y(1.0f), m_pVehicleNameToPrint); - CFont::SetColor(CRGBA(VEHICLE_COLOR.r, VEHICLE_COLOR.g, VEHICLE_COLOR.b, fVehicleAlpha)); + CFont::SetColor(CRGBA(194, 165, 120, fVehicleAlpha)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(32.0f), SCREEN_SCALE_FROM_BOTTOM(55.0f), m_pVehicleNameToPrint); } } @@ -679,7 +654,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), sPrint); - CFont::SetColor(CLOCK_COLOR); + CFont::SetColor(CRGBA(194, 165, 120, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(111.0f), SCREEN_SCALE_Y(22.0f), sPrint); /* @@ -723,7 +698,7 @@ void CHud::Draw() 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::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f)); - CFont::SetColor(TIMER_COLOR); + CFont::SetColor(CRGBA(186, 101, 50, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(110.0f), sTimer); if (CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText[0]) { @@ -732,7 +707,7 @@ void CHud::Draw() CFont::SetScale(SCREEN_SCALE_X(0.64f), SCREEN_SCALE_Y(1.35f)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(110.0f) + SCREEN_SCALE_Y(2.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); - CFont::SetColor(TIMER_COLOR); + CFont::SetColor(CRGBA(186, 101, 50, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(80.0f), SCREEN_SCALE_Y(110.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aTimerText)); } } @@ -767,7 +742,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(132.0f) + SCREEN_SCALE_Y(2.0f), sTimer); - CFont::SetColor(COUNTER_COLOR); + CFont::SetColor(CRGBA(0, 106, 164, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET), SCREEN_SCALE_Y(132.0f), sTimer); } else { int counter = atoi(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer); @@ -784,7 +759,7 @@ void CHud::Draw() 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::SetColor(COUNTER_COLOR); + CFont::SetColor(CRGBA(0, 106, 164, 255)); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(TIMER_RIGHT_OFFSET) - SCREEN_SCALE_X(61.0f), SCREEN_SCALE_Y(132.0f), TheText.Get(CUserDisplay::OnscnTimer.m_sEntries[0].m_aCounterText)); } } @@ -831,7 +806,7 @@ void CHud::Draw() CFont::SetBackgroundOff(); CFont::SetScale(SCREEN_SCALE_X(0.84f), SCREEN_SCALE_Y(1.0f)); - CFont::SetColor(PAGER_COLOR); + CFont::SetColor(CRGBA(32, 162, 66, 205)); CFont::SetRightJustifyOff(); CFont::SetBackgroundOff(); CFont::SetCentreOff(); @@ -853,7 +828,7 @@ void CHud::Draw() rect.Translate(RADAR_LEFT, SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT)); #endif rect.Grow(4.0f); - Sprites[HUD_RADARDISC].Draw(rect, RADARDISC_COLOR); + Sprites[HUD_RADARDISC].Draw(rect, CRGBA(0, 0, 0, 255)); CRadar::DrawBlips(); } } @@ -1008,7 +983,7 @@ void CHud::Draw() CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[0]); #endif - CFont::SetColor(CRGBA(BIGMESSAGE_COLOR.r, BIGMESSAGE_COLOR.g, BIGMESSAGE_COLOR.b, BigMessageAlpha[0])); + CFont::SetColor(CRGBA(85, 119, 133, BigMessageAlpha[0])); CFont::PrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(18.0f), m_BigMessage[0]); } else { @@ -1043,7 +1018,7 @@ void CHud::Draw() CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f - 4.0f), SCREEN_SCALE_FROM_BOTTOM(78.0f), m_BigMessage[2]); - CFont::SetColor(CRGBA(WASTEDBUSTED_COLOR.r, WASTEDBUSTED_COLOR.g, WASTEDBUSTED_COLOR.b, BigMessageAlpha[2])); + CFont::SetColor(CRGBA(170, 123, 87, BigMessageAlpha[2])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(82.0f), m_BigMessage[2]); } else { @@ -1235,7 +1210,7 @@ void CHud::DrawAfterFade() CFont::SetColor(CRGBA(0, 0, 0, 255)); CFont::PrintString((SCREEN_WIDTH / 2) + SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[3]); - CFont::SetColor(ODDJOB_COLOR); + CFont::SetColor(CRGBA(89, 115, 150, 255)); CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[3]); } @@ -1251,7 +1226,7 @@ void CHud::DrawAfterFade() CFont::PrintString((SCREEN_WIDTH / 2) - SCREEN_SCALE_X(2.0f), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f) - SCREEN_SCALE_Y(2.0f), m_BigMessage[4]); - CFont::SetColor(ODDJOB_COLOR); + CFont::SetColor(CRGBA(89, 115, 150, 255)); CFont::PrintString((SCREEN_WIDTH / 2), (SCREEN_HEIGHT / 2) - SCREEN_SCALE_Y(84.0f), m_BigMessage[4]); } @@ -1309,12 +1284,12 @@ void CHud::DrawAfterFade() #ifdef BETA_SLIDING_TEXT CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f) - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); - CFont::SetColor(ODDJOB2_COLOR); + CFont::SetColor(CRGBA(156, 91, 40, 255)); CFont::PrintString(SCREEN_WIDTH / 2 - SCREEN_SCALE_X(OddJob2XOffset), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); #else CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[5]); - CFont::SetColor(ODDJOB2_COLOR); + CFont::SetColor(CRGBA(156, 91, 40, 255)); CFont::PrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - SCREEN_SCALE_Y(20.0f), m_BigMessage[5]); #endif } @@ -1359,7 +1334,7 @@ void CHud::DrawAfterFade() CFont::SetColor(CRGBA(40, 40, 40, BigMessageAlpha[1])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f) + SCREEN_SCALE_Y(2.0f), m_BigMessage[1]); - CFont::SetColor(CRGBA(MISSIONTITLE_COLOR.r, MISSIONTITLE_COLOR.g, MISSIONTITLE_COLOR.b, BigMessageAlpha[1])); + CFont::SetColor(CRGBA(220, 172, 2, BigMessageAlpha[1])); CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(120.0f), m_BigMessage[1]); } else { diff --git a/src/text/Text.cpp b/src/text/Text.cpp index 1e58fcd1..74f53f80 100644 --- a/src/text/Text.cpp +++ b/src/text/Text.cpp @@ -7,27 +7,36 @@ #include "Frontend.h" #include "Messages.h" #include "Text.h" +#include "Timer.h" static wchar WideErrorString[25]; CText TheText; +//--MIAMI: DONE CText::CText(void) { encoding = 'e'; + bHasMissionTextOffsets = false; + bIsMissionTextLoaded = false; + memset(szMissionTableName, 0, sizeof(szMissionTableName)); memset(WideErrorString, 0, sizeof(WideErrorString)); } +//--MIAMI: DONE void CText::Load(void) { - uint8 *filedata; - char filename[32], type[4]; - int length; - int offset, sectlen; + char filename[32]; + uint32 offset; + int file; + bool tkey_loaded = false, tdat_loaded = false; + ChunkHeader m_ChunkHeader; + + bIsMissionTextLoaded = false; + bHasMissionTextOffsets = false; Unload(); - filedata = new uint8[0x40000]; CFileMgr::SetDir("TEXT"); switch(CMenuManager::m_PrefsLanguage){ @@ -59,49 +68,64 @@ CText::Load(void) #endif } - length = CFileMgr::LoadFile(filename, filedata, 0x40000, "rb"); - CFileMgr::SetDir(""); + file = CFileMgr::OpenFile(filename, "rb"); offset = 0; - while(offset < length){ - type[0] = filedata[offset++]; - type[1] = filedata[offset++]; - type[2] = filedata[offset++]; - type[3] = filedata[offset++]; - sectlen = (int)filedata[offset+3]<<24 | (int)filedata[offset+2]<<16 | - (int)filedata[offset+1]<<8 | (int)filedata[offset+0]; - offset += 4; - if(sectlen != 0){ - if(strncmp(type, "TKEY", 4) == 0) - keyArray.Load(sectlen, filedata, &offset); - else if(strncmp(type, "TDAT", 4) == 0) - data.Load(sectlen, filedata, &offset); - else - offset += sectlen; + while (!tkey_loaded || !tdat_loaded) { + ReadChunkHeader(&m_ChunkHeader, file, &offset); + if (m_ChunkHeader.size != 0) { + if (strncmp(m_ChunkHeader.magic, "TABL", 4) == 0) { + MissionTextOffsets.Load(m_ChunkHeader.size, file, &offset, 0x58000); + bHasMissionTextOffsets = true; + } else if (strncmp(m_ChunkHeader.magic, "TKEY", 4) == 0) { + this->keyArray.Load(m_ChunkHeader.size, file, &offset); + tkey_loaded = true; + } else if (strncmp(m_ChunkHeader.magic, "TDAT", 4) == 0) { + this->data.Load(m_ChunkHeader.size, file, &offset); + tdat_loaded = true; + } else { + CFileMgr::Seek(file, m_ChunkHeader.size, SEEK_CUR); + offset += m_ChunkHeader.size; + } } } keyArray.Update(data.chars); - - delete[] filedata; + CFileMgr::CloseFile(file); + CFileMgr::SetDir(""); } +//--MIAMI: DONE void CText::Unload(void) { CMessages::ClearAllMessagesDisplayedByGame(); - data.Unload(); keyArray.Unload(); + data.Unload(); + mission_keyArray.Unload(); + mission_data.Unload(); + bIsMissionTextLoaded = false; + memset(szMissionTableName, 0, sizeof(szMissionTableName)); } +//--MIAMI: DONE wchar* CText::Get(const char *key) { + uint8 result = false; +#ifdef FIX_BUGS + wchar *outstr = keyArray.Search(key, data.chars, &result); +#else + wchar *outstr = keyArray.Search(key, &result); +#endif + + if (!result && bHasMissionTextOffsets && bIsMissionTextLoaded) #ifdef FIX_BUGS - return keyArray.Search(key, data.chars); + outstr = mission_keyArray.Search(key, mission_data.chars, &result); #else - return keyArray.Search(key); + outstr = mission_keyArray.Search(key, &result); #endif + return outstr; } wchar UpperCaseTable[128] = { @@ -134,6 +158,7 @@ wchar FrenchUpperCaseTable[128] = { 253, 254, 255 }; +//--MIAMI: TODO (check tables) wchar CText::GetUpperCase(wchar c) { @@ -165,6 +190,7 @@ CText::GetUpperCase(wchar c) return c; } +//--MIAMI: DONE void CText::UpperCase(wchar *s) { @@ -174,21 +200,131 @@ CText::UpperCase(wchar *s) } } +//--MIAMI: DONE +void +CText::GetNameOfLoadedMissionText(char *outName) +{ + strcpy(outName, szMissionTableName); +} + +//--MIAMI: DONE +void +CText::ReadChunkHeader(ChunkHeader *buf, int32 file, uint32 *offset) +{ + // original code loops 8 times to read 1 byte with CFileMgr::Read, that's retarded + CFileMgr::Read(file, (char*)buf, sizeof(ChunkHeader)); + *offset += sizeof(ChunkHeader); +} + +//--MIAMI: DONE +void +CText::LoadMissionText(char *MissionTableName) +{ + char filename[32]; + + mission_keyArray.Unload(); + mission_data.Unload(); + + bool search_result = false; + int missionTableId = 0; + + for (missionTableId = 0; missionTableId < MissionTextOffsets.size; missionTableId++) { + if (strncmp(MissionTextOffsets.data[missionTableId].szMissionName, MissionTableName, strlen(MissionTextOffsets.data[missionTableId].szMissionName)) == 0) { + search_result = true; + break; + } + } + + if (!search_result) { + printf("CText::LoadMissionText - couldn't find %s", MissionTableName); + return; + } + + CFileMgr::SetDir("TEXT"); + switch (CMenuManager::m_PrefsLanguage) { + case LANGUAGE_AMERICAN: + sprintf(filename, "AMERICAN.GXT"); + break; + case LANGUAGE_FRENCH: + sprintf(filename, "FRENCH.GXT"); + break; + case LANGUAGE_GERMAN: + sprintf(filename, "GERMAN.GXT"); + break; + case LANGUAGE_ITALIAN: + sprintf(filename, "ITALIAN.GXT"); + break; + case LANGUAGE_SPANISH: + sprintf(filename, "SPANISH.GXT"); + break; +#ifdef MORE_LANGUAGES + case LANGUAGE_POLISH: + sprintf(filename, "POLISH.GXT"); + break; + case LANGUAGE_RUSSIAN: + sprintf(filename, "RUSSIAN.GXT"); + break; + case LANGUAGE_JAPANESE: + sprintf(filename, "JAPANESE.GXT"); + break; +#endif + } + CTimer::Suspend(); + int file = CFileMgr::OpenFile(filename, "rb"); + CFileMgr::Seek(file, MissionTextOffsets.data[missionTableId].offset, SEEK_SET); + + char TableCheck[8]; + CFileMgr::Read(file, TableCheck, 8); + if (strncmp(TableCheck, MissionTableName, 8) != 0) + printf("CText::LoadMissionText - expected to find %s in the text file", MissionTableName); + + bool tkey_loaded = false, tdat_loaded = false; + ChunkHeader m_ChunkHeader; + while (!tkey_loaded || !tdat_loaded) { + uint32 bytes_read = 0; + ReadChunkHeader(&m_ChunkHeader, file, &bytes_read); + if (m_ChunkHeader.size != 0) { + if (strncmp(m_ChunkHeader.magic, "TKEY", 4) == 0) { + uint32 bytes_read = 0; + mission_keyArray.Load(m_ChunkHeader.size, file, &bytes_read); + tkey_loaded = true; + } else if (strncmp(m_ChunkHeader.magic, "TDAT", 4) == 0) { + uint32 bytes_read = 0; + mission_data.Load(m_ChunkHeader.size, file, &bytes_read); + tdat_loaded = true; + } else + CFileMgr::Seek(file, m_ChunkHeader.size, SEEK_CUR); + } + } + + mission_keyArray.Update(mission_data.chars); + CFileMgr::CloseFile(file); + CTimer::Resume(); + CFileMgr::SetDir(""); + strcpy(szMissionTableName, MissionTableName); + bIsMissionTextLoaded = true; +} + +//--MIAMI: DONE void -CKeyArray::Load(uint32 length, uint8 *data, int *offset) +CKeyArray::Load(uint32 length, int file, uint32 *offset) { - uint32 i; - uint8 *rawbytes; + char *rawbytes; numEntries = length / sizeof(CKeyEntry); entries = new CKeyEntry[numEntries]; - rawbytes = (uint8*)entries; + rawbytes = (char*)entries; - for(i = 0; i < length; i++) - rawbytes[i] = data[(*offset)++]; +#if DUMB + for (uint32 i = 0; i < length; i++) + CFileMgr::Read(file, &rawbytes[i], 1); +#else + CFileMgr::Read(file, rawbytes, length); +#endif } +//--MIAMI: DONE void CKeyArray::Unload(void) { @@ -197,6 +333,7 @@ CKeyArray::Unload(void) numEntries = 0; } +//--MIAMI: DONE void CKeyArray::Update(wchar *chars) { @@ -207,6 +344,7 @@ CKeyArray::Update(wchar *chars) #endif } +//--MIAMI: DONE CKeyEntry* CKeyArray::BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high) { @@ -227,11 +365,12 @@ CKeyArray::BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 hi return nil; } +//--MIAMI: DONE wchar* #ifdef FIX_BUGS -CKeyArray::Search(const char *key, wchar *data) +CKeyArray::Search(const char *key, wchar *data, uint8 *result) #else -CKeyArray::Search(const char *key) +CKeyArray::Search(const char *key, uint8 *result) #endif { CKeyEntry *found; @@ -240,34 +379,47 @@ CKeyArray::Search(const char *key) #ifdef FIX_BUGS found = BinarySearch(key, entries, 0, numEntries-1); - if(found) + if (found) { + *result = true; return (wchar*)((uint8*)data + found->valueOffset); + } #else found = BinarySearch(key, entries, 0, numEntries-1); - if(found) + if (found) { + *result = true; return found->value; + } #endif + *result = false; +#ifdef MASTER + sprintf(errstr, "%"); +#else sprintf(errstr, "%s missing", key); +#endif // MASTER for(i = 0; i < 25; i++) WideErrorString[i] = errstr[i]; return WideErrorString; } - +//--MIAMI: DONE void -CData::Load(uint32 length, uint8 *data, int *offset) +CData::Load(uint32 length, int file, uint32 *offset) { - uint32 i; - uint8 *rawbytes; + char *rawbytes; numChars = length / sizeof(wchar); chars = new wchar[numChars]; - rawbytes = (uint8*)chars; + rawbytes = (char*)chars; - for(i = 0; i < length; i++) - rawbytes[i] = data[(*offset)++]; +#if DUMB + for(uint32 i = 0; i < length; i++) + CFileMgr::Read(file, &rawbytes[i], 1); +#else + CFileMgr::Read(file, rawbytes, length); +#endif } +//--MIAMI: DONE void CData::Unload(void) { @@ -276,6 +428,16 @@ CData::Unload(void) numChars = 0; } +//--MIAMI: DONE +void +CMissionTextOffsets::Load(uint32 table_size, int file, uint32 *offset, int) +{ + // not exact VC code but smaller and better :P + size = table_size / sizeof(CMissionTextOffsets::Entry); + CFileMgr::Read(file, (char*)data, sizeof(CMissionTextOffsets::Entry) * size); + *offset += sizeof(CMissionTextOffsets::Entry) * size; +} + void AsciiToUnicode(const char *src, wchar *dst) { diff --git a/src/text/Text.h b/src/text/Text.h index 18a904bc..dcffccbf 100644 --- a/src/text/Text.h +++ b/src/text/Text.h @@ -28,14 +28,14 @@ public: CKeyArray(void) : entries(nil), numEntries(0) {} ~CKeyArray(void) { Unload(); } - void Load(uint32 length, uint8 *data, int *offset); + void Load(uint32 length, int file, uint32 *offset); void Unload(void); void Update(wchar *chars); CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high); #ifdef FIX_BUGS - wchar *Search(const char *key, wchar *data); + wchar *Search(const char *key, wchar *data, uint8 *result); #else - wchar *Search(const char *key); + wchar *Search(const char *key, uint8* result); #endif }; @@ -47,15 +47,45 @@ public: CData(void) : chars(nil), numChars(0) {} ~CData(void) { Unload(); } - void Load(uint32 length, uint8 *data, int *offset); + void Load(uint32 length, int file, uint32 *offset); void Unload(void); }; +class CMissionTextOffsets +{ +public: + struct Entry + { + char szMissionName[8]; + uint32 offset; + }; + + enum {MAX_MISSION_TEXTS = 90}; // beware that LCS has more + + Entry data[MAX_MISSION_TEXTS]; + uint16 size; + + CMissionTextOffsets(void) : size(0) {} + void Load(uint32 table_size, int file, uint32* bytes_read, int); +}; + +struct ChunkHeader +{ + char magic[4]; + int size; +}; + class CText { CKeyArray keyArray; CData data; + CKeyArray mission_keyArray; + CData mission_data; char encoding; + bool bHasMissionTextOffsets; + bool bIsMissionTextLoaded; + char szMissionTableName[8]; + CMissionTextOffsets MissionTextOffsets; public: CText(void); void Load(void); @@ -63,6 +93,9 @@ public: wchar *Get(const char *key); wchar GetUpperCase(wchar c); void UpperCase(wchar *s); + void GetNameOfLoadedMissionText(char *outName); + void ReadChunkHeader(ChunkHeader *buf, int32 file, uint32 *bytes_read); + void LoadMissionText(char *MissionTableName); }; extern CText TheText; diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp index 5f78e2a9..d1f2faaa 100644 --- a/src/vehicles/Automobile.cpp +++ b/src/vehicles/Automobile.cpp @@ -3017,15 +3017,11 @@ void CAutomobile::DoDriveByShootings(void) { CAnimBlendAssociation *anim; - CPlayerInfo* playerInfo = ((CPlayerPed*)this)->GetPlayerInfoForThisPlayerPed(); - if (playerInfo && !playerInfo->m_bDriveByAllowed) - return; - CWeapon *weapon = pDriver->GetWeapon(); if(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_nWeaponSlot != 5) return; - weapon->Update(pDriver->m_audioEntityId, nil); + weapon->Update(pDriver->m_audioEntityId); bool lookingLeft = false; bool lookingRight = false; @@ -3041,42 +3037,37 @@ CAutomobile::DoDriveByShootings(void) lookingRight = true; } - AnimationId rightAnim = ANIM_DRIVEBY_R; - AnimationId leftAnim = ANIM_DRIVEBY_L; - if (pDriver->m_pMyVehicle->bLowVehicle) { - rightAnim = ANIM_DRIVEBY_LOW_R; - leftAnim = ANIM_DRIVEBY_LOW_L; - } - if(lookingLeft || lookingRight){ if(lookingLeft){ - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), rightAnim); + anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_R); if(anim) anim->blendDelta = -1000.0f; - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), leftAnim); + anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_L); if(anim == nil || anim->blendDelta < 0.0f) - anim = CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, leftAnim); + CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, ANIM_DRIVEBY_L); + else + anim->SetRun(); }else if(pDriver->m_pMyVehicle->pPassengers[0] == nil || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){ - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), leftAnim); + anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_L); if(anim) anim->blendDelta = -1000.0f; - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), rightAnim); + anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_R); if(anim == nil || anim->blendDelta < 0.0f) - anim = CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, rightAnim); + CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, ANIM_DRIVEBY_R); + else + anim->SetRun(); } - if (!anim || !anim->IsRunning()) { - if (CPad::GetPad(0)->GetCarGunFired() && CTimer::GetTimeInMilliseconds() > weapon->m_nTimer) { - weapon->FireFromCar(this, lookingLeft); - weapon->m_nTimer = CTimer::GetTimeInMilliseconds() + 70; - } + if(CPad::GetPad(0)->GetCarGunFired() && CTimer::GetTimeInMilliseconds() > weapon->m_nTimer){ + weapon->FireFromCar(this, lookingLeft); + weapon->m_nTimer = CTimer::GetTimeInMilliseconds() + 70; } }else{ weapon->Reload(); - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), leftAnim); + anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_L); if(anim) anim->blendDelta = -1000.0f; - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), rightAnim); + anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_R); if(anim) anim->blendDelta = -1000.0f; } diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp index 1e7f8ecf..784d859f 100644 --- a/src/vehicles/Boat.cpp +++ b/src/vehicles/Boat.cpp @@ -19,9 +19,6 @@ #include "Pools.h" #include "Pad.h" #include "Boat.h" -#include "AnimBlendAssociation.h" -#include "RpAnimBlend.h" -#include "Record.h" #define INVALID_ORIENTATION (-9999.99f) @@ -152,9 +149,6 @@ CBoat::ProcessControl(void) ProcessControlInputs(0); if(GetModelIndex() == MI_PREDATOR) DoFixedMachineGuns(); - - if (!CRecordDataForChase::IsRecording()) - DoDriveByShootings(); break; case STATUS_SIMPLE: m_bIsAnchored = false; @@ -918,68 +912,6 @@ CBoat::AddWakePoint(CVector point) } } -void -CBoat::DoDriveByShootings(void) -{ - CAnimBlendAssociation *anim; - CPlayerInfo* playerInfo = ((CPlayerPed*)this)->GetPlayerInfoForThisPlayerPed(); - if (playerInfo && !playerInfo->m_bDriveByAllowed) - return; - - CWeapon *weapon = pDriver->GetWeapon(); - if(CWeaponInfo::GetWeaponInfo(weapon->m_eWeaponType)->m_nWeaponSlot != 5) - return; - - weapon->Update(pDriver->m_audioEntityId, nil); - - bool lookingLeft = false; - bool lookingRight = false; - if(TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_TOPDOWN){ - if(CPad::GetPad(0)->GetLookLeft()) - lookingLeft = true; - if(CPad::GetPad(0)->GetLookRight()) - lookingRight = true; - }else{ - if(TheCamera.Cams[TheCamera.ActiveCam].LookingLeft) - lookingLeft = true; - if(TheCamera.Cams[TheCamera.ActiveCam].LookingRight) - lookingRight = true; - } - - if(lookingLeft || lookingRight){ - if(lookingLeft){ - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_R); - if(anim) - anim->blendDelta = -1000.0f; - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_L); - if(anim == nil || anim->blendDelta < 0.0f) - anim = CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, ANIM_DRIVEBY_L); - }else if(pDriver->m_pMyVehicle->pPassengers[0] == nil || TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){ - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_L); - if(anim) - anim->blendDelta = -1000.0f; - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_R); - if(anim == nil || anim->blendDelta < 0.0f) - anim = CAnimManager::AddAnimation(pDriver->GetClump(), ASSOCGRP_STD, ANIM_DRIVEBY_R); - } - - if (!anim || !anim->IsRunning()) { - if (CPad::GetPad(0)->GetCarGunFired() && CTimer::GetTimeInMilliseconds() > weapon->m_nTimer) { - weapon->FireFromCar(this, lookingLeft); - weapon->m_nTimer = CTimer::GetTimeInMilliseconds() + 70; - } - } - }else{ - weapon->Reload(); - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_L); - if(anim) - anim->blendDelta = -1000.0f; - anim = RpAnimBlendClumpGetAssociation(pDriver->GetClump(), ANIM_DRIVEBY_R); - if(anim) - anim->blendDelta = -1000.0f; - } -} - #ifdef COMPATIBLE_SAVES void CBoat::Save(uint8*& buf) diff --git a/src/vehicles/Boat.h b/src/vehicles/Boat.h index c8168db0..7a0a9be4 100644 --- a/src/vehicles/Boat.h +++ b/src/vehicles/Boat.h @@ -61,7 +61,6 @@ public: void SetupModelNodes(); void PruneWakeTrail(void); void AddWakePoint(CVector point); - void DoDriveByShootings(void); static CBoat *apFrameWakeGeneratingBoats[4]; diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index a4c6f3f3..e457f964 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -1045,7 +1045,7 @@ CVehicle::SetUpDriver(void) if(VehicleCreatedBy != RANDOM_VEHICLE) return nil; - pDriver = CPopulation::AddPedInCar(this, true); + pDriver = CPopulation::AddPedInCar(this, false); pDriver->m_pMyVehicle = this; pDriver->m_pMyVehicle->RegisterReference((CEntity**)&pDriver->m_pMyVehicle); pDriver->bInVehicle = true; @@ -1061,7 +1061,7 @@ CVehicle::SetupPassenger(int n) if(pPassengers[n]) return pPassengers[n]; - pPassengers[n] = CPopulation::AddPedInCar(this, false); + pPassengers[n] = CPopulation::AddPedInCar(this, true); pPassengers[n]->m_pMyVehicle = this; pPassengers[n]->m_pMyVehicle->RegisterReference((CEntity**)&pPassengers[n]->m_pMyVehicle); pPassengers[n]->bInVehicle = true; diff --git a/src/vehicles/Vehicle.h b/src/vehicles/Vehicle.h index 666a26a2..c9e6bf93 100644 --- a/src/vehicles/Vehicle.h +++ b/src/vehicles/Vehicle.h @@ -300,6 +300,7 @@ public: CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); } bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_ZEBRA || GetModelIndex() == MI_KAUFMAN; } bool IsRealHeli(void) { return !!(pHandling->Flags & HANDLING_IS_HELI); } + AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); } static bool bWheelsOnlyCheat; static bool bAllDodosCheat; diff --git a/src/weapons/Weapon.cpp b/src/weapons/Weapon.cpp index 1f901f88..1ae26106 100644 --- a/src/weapons/Weapon.cpp +++ b/src/weapons/Weapon.cpp @@ -30,28 +30,25 @@ #include "WeaponInfo.h" #include "World.h" -// TODO(Miami) -#define AUDIO_NOT_READY - uint16 gReloadSampleTime[WEAPONTYPE_LAST_WEAPONTYPE] = { 0, // UNARMED 0, // BASEBALLBAT - 0, // GRENADE - 0, // DETONATEGRENADE - 0, // MOLOTOV - 0, // ROCKET 250, // COLT45 - 650, // SHOTGUN 400, // TEC9 400, // UZIhec 400, // SILENCED_INGRAM 400, // MP5 - 300, // M16 + 650, // SHOTGUN 300, // AK47 + 300, // M16 423, // SNIPERRIFLE 400, // ROCKETLAUNCHER 0, // FLAMETHROWER + 0, // MOLOTOV + 0, // ROCKET + 0, // GRENADE + 0, // DETONATEGRENADE 0, // DETONATOR 0 // HELICANNON }; @@ -99,7 +96,10 @@ CWeapon::Initialise(eWeaponType type, int32 ammo) { m_eWeaponType = type; m_eWeaponState = WEAPONSTATE_READY; - m_nAmmoTotal = Min(ammo, 99999); + if (ammo > 99999) + m_nAmmoTotal = 99999; + else + m_nAmmoTotal = ammo; m_nAmmoInClip = 0; Reload(); m_nTimer = 0; @@ -283,11 +283,8 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource) DMAudio.PlayOneShot(shooterPed->m_audioEntityId, SOUND_WEAPON_SHOT_FIRED, 0.0f); } - if ( m_nAmmoInClip > 0 ) - m_nAmmoInClip--; - - if ( m_nAmmoTotal > 0 && (m_nAmmoTotal < 25000 || isPlayer) && (!isPlayer || CStats::GetPercentageProgress() < 100.0f || m_eWeaponType == WEAPONTYPE_DETONATOR)) - m_nAmmoTotal--; + if ( m_nAmmoInClip > 0 ) m_nAmmoInClip--; + if ( m_nAmmoTotal > 0 && (m_nAmmoTotal < 25000 || isPlayer) ) m_nAmmoTotal--; if ( m_eWeaponState == WEAPONSTATE_READY && m_eWeaponType == WEAPONTYPE_FLAMETHROWER ) DMAudio.PlayOneShot(((CPhysical*)shooter)->m_audioEntityId, SOUND_WEAPON_FLAMETHROWER_FIRE, 0.0f); @@ -334,7 +331,7 @@ CWeapon::Fire(CEntity *shooter, CVector *fireSource) } bool -CWeapon::FireFromCar(CVehicle *shooter, bool left) +CWeapon::FireFromCar(CAutomobile *shooter, bool left) { ASSERT(shooter!=nil); @@ -396,10 +393,10 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource) { bool collided = false; - // TODO(Miami) - if (victimPed->m_nPedState == PED_DRIVING && (m_eWeaponType == WEAPONTYPE_UNARMED /*|| m_eWeaponType == WEAPONTYPE_BRASSKNUCKLES*/ - || info->m_bFightMode)) - continue; + CColModel *victimPedCol = &CTempColModels::ms_colModelPed1; + if ( victimPed->OnGround() || !victimPed->IsPedHeadAbovePos(-0.3f) ) + victimPedCol = &CTempColModels::ms_colModelPedGroundHit; + float victimPedRadius = victimPed->GetBoundRadius() + info->m_fRadius; if ( victimPed->bUsesCollision || victimPed->Dead() || victimPed->Driving() ) @@ -408,29 +405,12 @@ CWeapon::FireMelee(CEntity *shooter, CVector &fireSource) if ( SQR(victimPedRadius) > (victimPedPos-(*fireSource)).MagnitudeSqr() ) { CVector collisionDist; - CColModel* victimPedCol = &CTempColModels::ms_colModelPed1; - bool useLocalPos = false; - if (victimPed->m_nPedState == PED_FALL - || victimPed->m_nPedState == PED_DIE && victimPed->bIsPedDieAnimPlaying - || victimPed->m_nWaitState == WAITSTATE_SIT_IDLE - || victimPed->m_nWaitState == WAITSTATE_SUN_BATHE_IDLE) - { - useLocalPos = true; - victimPedCol = ((CPedModelInfo*)CModelInfo::GetModelInfo(victimPed->GetModelIndex()))->AnimatePedColModelSkinnedWorld(victimPed->GetClump()); - } else if (victimPed->DyingOrDead()) { - victimPedCol = &CTempColModels::ms_colModelPedGroundHit; - } int32 s = 0; while ( s < victimPedCol->numSpheres ) { CColSphere *sphere = &victimPedCol->spheres[s]; - - if (useLocalPos) { - collisionDist = sphere->center - (*fireSource); - } else { - collisionDist = victimPedPos + sphere->center - (*fireSource); - } + collisionDist = victimPedPos+sphere->center-(*fireSource); if ( SQR(sphere->radius + info->m_fRadius) > collisionDist.MagnitudeSqr() ) { @@ -679,15 +659,45 @@ CWeapon::FireInstantHit(CEntity *shooter, CVector *fireSource) switch ( m_eWeaponType ) { - case WEAPONTYPE_M16: case WEAPONTYPE_AK47: - // case WEAPONTYPE_M60: - // case WEAPONTYPE_MINIGUN: - case WEAPONTYPE_HELICANNON: { static uint8 counter = 0; - if ( info->m_nFiringRate >= 50 && !(++counter & 1) ) + if ( !(++counter & 1) ) + { + CPointLights::AddLight(CPointLights::LIGHT_POINT, + *fireSource, CVector(0.0f, 0.0f, 0.0f), 5.0f, + 1.0f, 0.8f, 0.0f, CPointLights::FOG_NONE, false); + + CVector gunflashPos = *fireSource; + gunflashPos += CVector(0.06f*ahead.x, 0.06f*ahead.y, 0.0f); + CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.10f); + gunflashPos += CVector(0.06f*ahead.x, 0.06f*ahead.y, 0.0f); + CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.08f); + gunflashPos += CVector(0.05f*ahead.x, 0.05f*ahead.y, 0.0f); + CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.06f); + gunflashPos += CVector(0.04f*ahead.x, 0.04f*ahead.y, 0.0f); + CParticle::AddParticle(PARTICLE_GUNFLASH_NOANIM, gunflashPos, CVector(0.0f, 0.0f, 0.0f), nil, 0.04f); + + CVector gunsmokePos = *fireSource; + float rnd = CGeneral::GetRandomNumberInRange(0.05f, 0.25f); + CParticle::AddParticle(PARTICLE_GUNSMOKE2, gunsmokePos, CVector(ahead.x*rnd, ahead.y*rnd, 0.0f)); + + CVector gunshellPos = *fireSource; + gunshellPos -= CVector(0.5f*ahead.x, 0.5f*ahead.y, 0.0f); + CVector dir = CrossProduct(CVector(ahead.x, ahead.y, 0.0f), CVector(0.0f, 0.0f, 5.0f)); + dir.Normalise2D(); + AddGunshell(shooter, gunshellPos, CVector2D(dir.x, dir.y), 0.018f); + } + + break; + } + + case WEAPONTYPE_M16: + { + static uint8 counter = 0; + + if ( !(++counter & 1) ) { CPointLights::AddLight(CPointLights::LIGHT_POINT, *fireSource, CVector(0.0f, 0.0f, 0.0f), 5.0f, @@ -1659,7 +1669,7 @@ CWeapon::FireM16_1stPerson(CEntity *shooter) } bool -CWeapon::FireInstantHitFromCar(CVehicle *shooter, bool left) +CWeapon::FireInstantHitFromCar(CAutomobile *shooter, bool left) { CWeaponInfo *info = GetInfo(); @@ -2030,10 +2040,8 @@ CWeapon::Reload(void) } void -CWeapon::Update(int32 audioEntity, CPed *pedToAdjustSound) +CWeapon::Update(int32 audioEntity) { - CWeaponInfo *info = GetInfo(); - switch ( m_eWeaponState ) { case WEAPONSTATE_MELEE_MADECONTACT: @@ -2066,57 +2074,9 @@ CWeapon::Update(int32 audioEntity, CPed *pedToAdjustSound) { if ( AEHANDLE_IS_OK(audioEntity) && m_eWeaponType < WEAPONTYPE_LAST_WEAPONTYPE ) { - CAnimBlendAssociation *reloadAssoc = nil; - if (pedToAdjustSound) { - if (CPed::GetReloadAnim(info) && (!CWorld::Players[CWorld::PlayerInFocus].m_bFastReload || !pedToAdjustSound->IsPlayer())) { - reloadAssoc = RpAnimBlendClumpGetAssociation(pedToAdjustSound->GetClump(), CPed::GetReloadAnim(info)); - if (!reloadAssoc) { - reloadAssoc = RpAnimBlendClumpGetAssociation(pedToAdjustSound->GetClump(), CPed::GetCrouchReloadAnim(info)); - } - } - } - if (reloadAssoc && reloadAssoc->IsRunning() && reloadAssoc->blendAmount > 0.2f) { - float soundStart = 0.75f; - switch (info->m_AnimToPlay) { - case ASSOCGRP_PYTHON: - soundStart = 0.5f; - break; - case ASSOCGRP_COLT: - case ASSOCGRP_TEC: - soundStart = 0.7f; - break; - case ASSOCGRP_UZI: - soundStart = 0.75f; - break; - case ASSOCGRP_RIFLE: - soundStart = 0.75f; - break; - case ASSOCGRP_M60: - soundStart = 0.7f; - break; - default: - break; - } - if (reloadAssoc->GetProgress() >= soundStart && (reloadAssoc->currentTime - reloadAssoc->timeStep) / reloadAssoc->hierarchy->totalLength < soundStart) { -#ifdef AUDIO_NOT_READY - DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, 0.0f); -#else - DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, m_eWeaponType); -#endif - } - if (CTimer::GetTimeInMilliseconds() > m_nTimer && reloadAssoc->GetProgress() < 0.9f) { - m_nTimer = CTimer::GetTimeInMilliseconds(); - } - } else { - uint32 timePassed = m_nTimer - gReloadSampleTime[m_eWeaponType]; - if (CTimer::GetPreviousTimeInMilliseconds() < timePassed && CTimer::GetTimeInMilliseconds() >= timePassed) { -#ifdef AUDIO_NOT_READY - DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, 0.0f); -#else - DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, m_eWeaponType); -#endif - } - } + uint32 timePassed = m_nTimer - gReloadSampleTime[m_eWeaponType]; + if ( CTimer::GetPreviousTimeInMilliseconds() < timePassed && CTimer::GetTimeInMilliseconds() >= timePassed ) + DMAudio.PlayOneShot(audioEntity, SOUND_WEAPON_RELOAD, 0.0f); } if ( CTimer::GetTimeInMilliseconds() > m_nTimer ) diff --git a/src/weapons/Weapon.h b/src/weapons/Weapon.h index f6228b32..5c62a74b 100644 --- a/src/weapons/Weapon.h +++ b/src/weapons/Weapon.h @@ -7,8 +7,7 @@ class CEntity; class CPhysical; -class CVehicle; -class CPed; +class CAutomobile; struct CColPoint; class CWeaponInfo; @@ -36,7 +35,7 @@ public: void Shutdown(); bool Fire (CEntity *shooter, CVector *fireSource); - bool FireFromCar (CVehicle *shooter, bool left); + bool FireFromCar (CAutomobile *shooter, bool left); bool FireMelee (CEntity *shooter, CVector &fireSource); bool FireInstantHit(CEntity *shooter, CVector *fireSource); @@ -51,14 +50,14 @@ public: bool FireAreaEffect (CEntity *shooter, CVector *fireSource); bool FireSniper (CEntity *shooter); bool FireM16_1stPerson (CEntity *shooter); - bool FireInstantHitFromCar(CVehicle *shooter, bool left); + bool FireInstantHitFromCar(CAutomobile *shooter, bool left); static void DoDoomAiming (CEntity *shooter, CVector *source, CVector *target); static void DoTankDoomAiming (CEntity *shooter, CEntity *driver, CVector *source, CVector *target); static void DoDriveByAutoAiming(CEntity *shooter, CVector *source, CVector *target); void Reload(void); - void Update(int32 audioEntity, CPed *pedToAdjustSound); + void Update(int32 audioEntity); bool IsTypeMelee (void); bool IsType2Handed(void); diff --git a/src/weapons/WeaponInfo.cpp b/src/weapons/WeaponInfo.cpp index 420171f2..7128a04f 100644 --- a/src/weapons/WeaponInfo.cpp +++ b/src/weapons/WeaponInfo.cpp @@ -20,21 +20,21 @@ CWeaponInfo CWeaponInfo::ms_apWeaponInfos[WEAPONTYPE_TOTALWEAPONS]; static char ms_aWeaponNames[][32] = { "Unarmed", "BaseballBat", - "Grenade", - "DetonateGrenade", - "Molotov", - "Rocket", "Colt45", - "Shotgun", "Tec9", "Uzi", "SilencedIngram", "Mp5", - "M16", + "Shotgun", "AK47", + "M16", "SniperRifle", "RocketLauncher", "FlameThrower", + "Molotov", + "Rocket", + "Grenade", + "DetonateGrenade", "Detonator", "HeliCannon", }; diff --git a/src/weapons/WeaponType.h b/src/weapons/WeaponType.h index 8c1f598d..61d03ad3 100644 --- a/src/weapons/WeaponType.h +++ b/src/weapons/WeaponType.h @@ -5,25 +5,24 @@ enum eWeaponType { WEAPONTYPE_UNARMED, WEAPONTYPE_BASEBALLBAT, - WEAPONTYPE_GRENADE, - WEAPONTYPE_DETONATOR_GRENADE, - WEAPONTYPE_MOLOTOV, - WEAPONTYPE_ROCKET, WEAPONTYPE_COLT45, - WEAPONTYPE_SHOTGUN, WEAPONTYPE_TEC9, WEAPONTYPE_UZI, WEAPONTYPE_SILENCED_INGRAM, WEAPONTYPE_MP5, - WEAPONTYPE_M16, + WEAPONTYPE_SHOTGUN, WEAPONTYPE_AK47, + WEAPONTYPE_M16, WEAPONTYPE_SNIPERRIFLE, WEAPONTYPE_ROCKETLAUNCHER, WEAPONTYPE_FLAMETHROWER, + WEAPONTYPE_MOLOTOV, + WEAPONTYPE_ROCKET, + WEAPONTYPE_GRENADE, + WEAPONTYPE_DETONATOR_GRENADE, WEAPONTYPE_DETONATOR, WEAPONTYPE_HELICANNON, WEAPONTYPE_LAST_WEAPONTYPE, - WEAPONTYPE_HEALTH, WEAPONTYPE_ARMOUR, WEAPONTYPE_RAMMEDBYCAR, WEAPONTYPE_RUNOVERBYCAR,