diff options
Diffstat (limited to '')
-rw-r--r-- | src/control/Pickups.cpp | 106 | ||||
-rw-r--r-- | src/control/Pickups.h | 16 | ||||
-rw-r--r-- | src/control/Script.cpp | 53 |
3 files changed, 151 insertions, 24 deletions
diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 3a7b3a90..7a9808f6 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -30,6 +30,8 @@ #include "Timer.h" #include "WaterLevel.h" #include "World.h" +#include "Hud.h" +#include "Messages.h" CPickup CPickups::aPickUps[NUMPICKUPS]; int16 CPickups::NumMessages; @@ -37,6 +39,7 @@ int32 CPickups::aPickUpsCollected[NUMCOLLECTEDPICKUPS]; int16 CPickups::CollectedPickUpIndex; int32 CPickups::PlayerOnWeaponPickup; +int32 CPickups::CollectPickupBuffer; // unused bool CPickups::bPickUpcamActivated; @@ -72,6 +75,32 @@ uint8 aWeaponBlues[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 128, 255, 0, 0 }; void +ModifyStringLabelForControlSetting(char *str) +{ + int len = (int)strlen(str); + if (len <= 2) + return; + + if (str[len - 2] != '_') + return; + + switch (CPad::GetPad(0)->Mode) { + case 0: + case 1: + str[len - 1] = 'L'; + break; + case 2: + str[len - 1] = 'T'; + break; + case 3: + str[len - 1] = 'C'; + break; + default: + return; + } +} + +void CPickup::RemoveKeepType() { CWorld::Remove(m_pObject); @@ -163,6 +192,31 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) { float waterLevel; + if (m_pObject) { + m_pObject->SetPosition(m_vecPos); + // TODO(Miami): Extra object + } + if (m_eType == PICKUP_ASSET_REVENUE) { + uint32 oldTimer = m_nTimer; + m_nTimer = CTimer::GetTimeInMilliseconds(); + float calculatedRevenue; + if ((FindPlayerCoors() - m_vecPos).Magnitude() > 10.0) { + uint32 timePassed = CTimer::GetTimeInMilliseconds() - oldTimer; + calculatedRevenue = m_nRevenue + (timePassed * m_nMoneySpeed) * sq(1.f / 1200.f); + } else { + calculatedRevenue = m_nRevenue; + } + m_nRevenue = Min(calculatedRevenue, m_nQuantity); + // TODO(Miami): For pickup glow effect? + /* + if (calculatedRevenue < 10.0) { + m_pObject->m_nCostValue = 0; + } else { + m_pObject->m_nCostValue = calculatedRevenue; + } + */ + } + if (m_bRemoved) { if (CTimer::GetTimeInMilliseconds() > m_nTimer) { // respawn pickup if we're far enough @@ -290,6 +344,32 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId) Remove(); DMAudio.PlayFrontEndSound(SOUND_PICKUP_MONEY, 0); return true; + case PICKUP_ASSET_REVENUE: + CWorld::Players[CWorld::PlayerInFocus].m_nMoney += m_nRevenue; + m_nRevenue = 0; + DMAudio.PlayFrontEndSound(SOUND_PICKUP_MONEY, 0); + return false; + // TODO(Miami): Control flow + case PICKUP_PROPERTY_FORSALE: + ModifyStringLabelForControlSetting(m_sTextKey); + CMessages::InsertNumberInString(TheText.Get(m_sTextKey), m_nQuantity, + 0, 0, 0, 0, 0, gUString); + if (!CHud::IsHelpMessageBeingDisplayed()) + CHud::SetHelpMessage(gUString, false); // 0, 0, 0); + if (CPickups::CollectPickupBuffer == 0) + return false; + if (CTheScripts::IsPlayerOnAMission()) { + CHud::SetHelpMessage(TheText.Get("PROP_2"), true); // , false); + } else { + if (CWorld::Players[CWorld::PlayerInFocus].m_nMoney >= m_nQuantity) { + CWorld::Players[CWorld::PlayerInFocus].m_nMoney -= m_nQuantity; + CHud::SetHelpMessage(nil, true); //, false); + Remove(); + return true; + } + CHud::SetHelpMessage(TheText.Get("PROP_1"), true); //, false); + } + return false; default: break; } @@ -528,12 +608,12 @@ CPickups::RemovePickUp(int32 pickupIndex) } int32 -CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quantity, uint32 rate, bool highPriority, wchar* pText) +CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quantity, uint32 rate, bool highPriority, char* pText) { bool bFreeFound = false; int32 slot = 0; - if (type == PICKUP_FLOATINGPACKAGE || type == PICKUP_NAUTICAL_MINE_INACTIVE) { + if (type == PICKUP_FLOATINGPACKAGE || type == PICKUP_NAUTICAL_MINE_INACTIVE || highPriority) { for (slot = NUMPICKUPS-1; slot >= 0; slot--) { if (aPickUps[slot].m_eType == PICKUP_NONE) { bFreeFound = true; @@ -556,7 +636,7 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan if (slot >= NUMGENERALPICKUPS) { for (slot = 0; slot < NUMGENERALPICKUPS; slot++) { - if (aPickUps[slot].m_eType == PICKUP_ONCE_TIMEOUT) break; + if (aPickUps[slot].m_eType == PICKUP_ONCE_TIMEOUT || aPickUps[slot].m_eType == PICKUP_ONCE_TIMEOUT_SLOW) break; } if (slot >= NUMGENERALPICKUPS) return -1; @@ -568,8 +648,13 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan aPickUps[slot].m_eType = (ePickupType)type; aPickUps[slot].m_bRemoved = false; aPickUps[slot].m_nQuantity = quantity; + aPickUps[slot].m_nMoneySpeed = rate; + aPickUps[slot].m_nRevenue = 0; + aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds(); if (type == PICKUP_ONCE_TIMEOUT) aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 20000; + else if (type == PICKUP_ONCE_TIMEOUT_SLOW) + aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 120000; else if (type == PICKUP_MONEY) aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 30000; else if (type == PICKUP_MINE_INACTIVE || type == PICKUP_MINE_ARMED) { @@ -580,6 +665,11 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 1500; } aPickUps[slot].m_eModelIndex = modelIndex; + if (pText) + strncpy(aPickUps[slot].m_sTextKey, pText, 8); + else + aPickUps[slot].m_sTextKey[0] = '\0'; + aPickUps[slot].m_vecPos = pos; aPickUps[slot].m_pObject = aPickUps[slot].GiveUsAPickUpObject(-1); if (aPickUps[slot].m_pObject) @@ -664,6 +754,16 @@ CPickups::Update() } } #endif + if (CPad::GetPad(0)->CollectPickupJustDown()) { + CollectPickupBuffer = 6; + } else { + CollectPickupBuffer = Max(0, CollectPickupBuffer - 1); + } + + if (PlayerOnWeaponPickup) { + PlayerOnWeaponPickup = Max(0, PlayerOnWeaponPickup - 1); + } + #define PICKUPS_FRAME_SPAN (6) #ifdef FIX_BUGS for (uint32 i = NUMGENERALPICKUPS * (CTimer::GetFrameCounter() % PICKUPS_FRAME_SPAN) / PICKUPS_FRAME_SPAN; i < NUMGENERALPICKUPS * (CTimer::GetFrameCounter() % PICKUPS_FRAME_SPAN + 1) / PICKUPS_FRAME_SPAN; i++) { diff --git a/src/control/Pickups.h b/src/control/Pickups.h index 423f864b..8f6ef4c3 100644 --- a/src/control/Pickups.h +++ b/src/control/Pickups.h @@ -33,14 +33,19 @@ class CPlayerPed; class CPickup { public: - ePickupType m_eType; - bool m_bRemoved; - uint16 m_nQuantity; + CVector m_vecPos; + uint32 m_nRevenue; CObject *m_pObject; + CObject *m_pExtraObject; + uint16 m_nQuantity; uint32 m_nTimer; + int16 m_nMoneySpeed; int16 m_eModelIndex; uint16 m_nIndex; - CVector m_vecPos; + char m_sTextKey[8]; + ePickupType m_eType; + bool m_bRemoved; + uint8 m_effects; CObject *GiveUsAPickUpObject(int32 handle); bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId); @@ -71,6 +76,7 @@ class CPickups static tPickupMessage aMessages[NUMPICKUPMESSAGES]; public: static int32 PlayerOnWeaponPickup; + static int32 CollectPickupBuffer; static void Init(); static void Update(); @@ -79,7 +85,7 @@ public: static void DoMoneyEffects(CEntity *ent); static void DoMineEffects(CEntity *ent); static void DoPickUpEffects(CEntity *ent); - static int32 GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quantity, uint32 rate = 0, bool highPriority = false, wchar* pText = nil); + static int32 GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quantity, uint32 rate = 0, bool highPriority = false, char* pText = nil); static int32 GenerateNewOne_WeaponType(CVector pos, eWeaponType weaponType, uint8 type, uint32 quantity); static void RemovePickUp(int32 pickupIndex); static void RemoveAllFloatingPickups(); diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 88a62f4e..eb950464 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -80,6 +80,8 @@ #include "World.h" #include "Zones.h" #include "main.h" +#include "Ropes.h" +#include "MBlur.h" #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #include <stdarg.h> #endif @@ -12110,6 +12112,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command) CVector pos = *(CVector*)&ScriptParams[0]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; + CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_REVENUE, PICKUP_ASSET_REVENUE, ScriptParams[3], ScriptParams[4]); StoreParameters(&m_nIp, 1); return 0; @@ -12790,7 +12793,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command) case COMMAND_CREATE_SWAT_ROPE: { CollectParameters(&m_nIp, 3); - debug("CREATE_SWAT_ROPE is not implemented\n"); + CRopes::CreateRopeWithSwatComingDown(*(CVector*)&ScriptParams[0]); return 0; } //case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA: @@ -12902,10 +12905,12 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CVector pos = *(CVector*)&ScriptParams[0]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - // TODO(MIAMI) - add text + char key[KEY_LENGTH_IN_SCRIPT]; + CTheScripts::ReadTextLabelFromScript(&m_nIp, key); + m_nIp += KEY_LENGTH_IN_SCRIPT; + // TheText.Get(key); CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY, PICKUP_PROPERTY_LOCKED, 0, 0, false, text); + ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY, PICKUP_PROPERTY_LOCKED, 0, 0, false, key); StoreParameters(&m_nIp, 1); return 0; } @@ -12915,10 +12920,12 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) CVector pos = *(CVector*)&ScriptParams[0]; if (pos.z <= MAP_Z_LOW_LIMIT) pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; - wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); - // TODO(MIAMI) - add text + char key[KEY_LENGTH_IN_SCRIPT]; + CTheScripts::ReadTextLabelFromScript(&m_nIp, key); + m_nIp += KEY_LENGTH_IN_SCRIPT; + // TheText.Get(key); CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); - ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY_FORSALE, PICKUP_PROPERTY_FORSALE, ScriptParams[3], 0, false, text); + ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_PROPERTY_FORSALE, PICKUP_PROPERTY_FORSALE, ScriptParams[3], 0, false, key); StoreParameters(&m_nIp, 1); return 0; } @@ -13021,7 +13028,11 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) case COMMAND_SET_PLAYER_DRUNKENNESS: { CollectParameters(&m_nIp, 2); - debug("SET_PLAYER_DRUNKENNESS not implemented\n"); // TODO(MIAMI) + CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; + pPlayerInfo->m_pPed->m_nDrunkenness = ScriptParams[1]; + pPlayerInfo->m_pPed->m_nFadeDrunkenness = 0; + if (pPlayerInfo->m_pPed->m_nDrunkenness == 0) + CMBlur::ClearDrunkBlur(); return 0; } //case COMMAND_GET_PLAYER_DRUNKENNESS: @@ -13421,7 +13432,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command) char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; - debug("LOAD_UNCOMPRESSED_ANIM not implemented\n"); // TODO(MIAMI) + CCutsceneMgr::LoadAnimationUncompressed(key); return 0; } case COMMAND_WAS_CUTSCENE_SKIPPED: @@ -13624,15 +13635,13 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_IS_PLAYER_IN_INFO_ZONE: { CollectParameters(&m_nIp, 1); + CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]]; char key[KEY_LENGTH_IN_SCRIPT]; CTheScripts::ReadTextLabelFromScript(&m_nIp, key); m_nIp += KEY_LENGTH_IN_SCRIPT; - static bool bShowed = false; - if (!bShowed) { - debug("IS_PLAYER_IN_INFO_ZONE not implemented, default to FALSE\n"); - bShowed = true; - } - UpdateCompareFlag(false); + CVector pos = pPlayerInfo->GetPos(); + CZone *infoZone = CTheZones::FindInformationZoneForPosition(&pos); + UpdateCompareFlag(strncmp(key, infoZone->name, 8) == 0); return 0; } case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE: @@ -13828,7 +13837,19 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command) case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI: { CollectParameters(&m_nIp, 3); - debug("CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI not implemented\n"); // TODO(MIAMI) + CObject *pHeli = CPools::GetObjectPool()->GetAt(ScriptParams[0]); + bool found = false; + float waterLevel = -1000.0f; + CVector pos = pHeli->GetPosition(); + float radius = *(float*)&ScriptParams[1]; + float ground = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &found); + if (!CWaterLevel::GetWaterLevel(pos.x, pos.y, pos.z, &waterLevel, false)) + waterLevel = 0.0f; + if (waterLevel > ground) + ground = waterLevel; + if (ScriptParams[2] > 8) + ScriptParams[2] = 8; + CVehicle::HeliDustGenerate(pHeli, (pos.z - ground - 1.0f - radius) * 0.3 + radius, ground, ScriptParams[2]); return 0; } case COMMAND_REGISTER_FIRE_LEVEL: |