new opcodes, buyable properties, minor fixes

This commit is contained in:
eray orçunus 2020-07-30 15:11:06 +03:00
parent 4a55f19761
commit eafa9cc107
12 changed files with 275 additions and 53 deletions

View File

@ -12,7 +12,7 @@
#include "AnimManager.h" #include "AnimManager.h"
#include "Streaming.h" #include "Streaming.h"
//--MIAMI: code done (except for pointless TODO) //--MIAMI: file done
CAnimBlock CAnimManager::ms_aAnimBlocks[NUMANIMBLOCKS]; CAnimBlock CAnimManager::ms_aAnimBlocks[NUMANIMBLOCKS];
CAnimBlendHierarchy CAnimManager::ms_aAnimations[NUMANIMATIONS]; CAnimBlendHierarchy CAnimManager::ms_aAnimations[NUMANIMATIONS];
@ -1276,7 +1276,7 @@ CAnimManager::LoadAnimFile(const char *filename)
RwStreamClose(stream, nil); RwStreamClose(stream, nil);
} }
//--MIAMI: done (except maybe implement some unimplemented compression?) //--MIAMI: done
void void
CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]) CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32])
{ {
@ -1323,7 +1323,14 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
RwStreamRead(stream, buf, name.size); RwStreamRead(stream, buf, name.size);
hier->SetName(buf); hier->SetName(buf);
// TODO(MIAMI)? some unused crap here // Unimplemented uncompressed anim thing
if (somename) {
for (int i = 0; somename[i][0]; i++) {
if (!CGeneral::faststricmp(somename[i], hier->name))
debug("Loading %s uncompressed\n", hier->name);
}
}
hier->compressed = false; hier->compressed = false;
hier->compressed2 = false; hier->compressed2 = false;
@ -1357,6 +1364,9 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
if(strncmp(info.ident, "KR00", 4) == 0){ if(strncmp(info.ident, "KR00", 4) == 0){
seq->SetNumFrames(numFrames, false, false); seq->SetNumFrames(numFrames, false, false);
KeyFrame *kf = seq->GetKeyFrame(0); KeyFrame *kf = seq->GetKeyFrame(0);
if (strstr(seq->name, "L Toe"))
debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
for(l = 0; l < numFrames; l++, kf++){ for(l = 0; l < numFrames; l++, kf++){
RwStreamRead(stream, buf, 0x14); RwStreamRead(stream, buf, 0x14);
kf->rotation.x = -fbuf[0]; kf->rotation.x = -fbuf[0];
@ -1368,6 +1378,9 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
}else if(strncmp(info.ident, "KRT0", 4) == 0){ }else if(strncmp(info.ident, "KRT0", 4) == 0){
seq->SetNumFrames(numFrames, true, false); seq->SetNumFrames(numFrames, true, false);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
if (strstr(seq->name, "L Toe"))
debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
for(l = 0; l < numFrames; l++, kf++){ for(l = 0; l < numFrames; l++, kf++){
RwStreamRead(stream, buf, 0x20); RwStreamRead(stream, buf, 0x20);
kf->rotation.x = -fbuf[0]; kf->rotation.x = -fbuf[0];
@ -1382,6 +1395,9 @@ CAnimManager::LoadAnimFile(RwStream *stream, bool compress, char (*somename)[32]
}else if(strncmp(info.ident, "KRTS", 4) == 0){ }else if(strncmp(info.ident, "KRTS", 4) == 0){
seq->SetNumFrames(numFrames, true, false); seq->SetNumFrames(numFrames, true, false);
KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0); KeyFrameTrans *kf = (KeyFrameTrans*)seq->GetKeyFrame(0);
if (strstr(seq->name, "L Toe"))
debug("anim %s has toe keyframes\n", hier->name); // , seq->name);
for(l = 0; l < numFrames; l++, kf++){ for(l = 0; l < numFrames; l++, kf++){
RwStreamRead(stream, buf, 0x2C); RwStreamRead(stream, buf, 0x2C);
kf->rotation.x = -fbuf[0]; kf->rotation.x = -fbuf[0];

View File

@ -119,7 +119,10 @@ int32 CCutsceneMgr::ms_numCutsceneObjs;
bool CCutsceneMgr::ms_loaded; bool CCutsceneMgr::ms_loaded;
bool CCutsceneMgr::ms_animLoaded; bool CCutsceneMgr::ms_animLoaded;
bool CCutsceneMgr::ms_useLodMultiplier; bool CCutsceneMgr::ms_useLodMultiplier;
bool CCutsceneMgr::ms_camLoaded;
char CCutsceneMgr::ms_cutsceneName[CUTSCENENAMESIZE]; char CCutsceneMgr::ms_cutsceneName[CUTSCENENAMESIZE];
char CCutsceneMgr::ms_uncompressedAnims[8][32];
uint32 CCutsceneMgr::ms_numUncompressedAnims;
CAnimBlendAssocGroup CCutsceneMgr::ms_cutsceneAssociations; CAnimBlendAssocGroup CCutsceneMgr::ms_cutsceneAssociations;
CVector CCutsceneMgr::ms_cutsceneOffset; CVector CCutsceneMgr::ms_cutsceneOffset;
float CCutsceneMgr::ms_cutsceneTimer; float CCutsceneMgr::ms_cutsceneTimer;
@ -154,6 +157,9 @@ CCutsceneMgr::Initialise(void)
ms_pCutsceneDir = new CDirectory(CUTSCENEDIRSIZE); ms_pCutsceneDir = new CDirectory(CUTSCENEDIRSIZE);
ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR"); ms_pCutsceneDir->ReadDirFile("ANIM\\CUTS.DIR");
ms_numUncompressedAnims = 0;
ms_uncompressedAnims[0][0] = '\0';
} }
void void
@ -194,7 +200,7 @@ CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
CStreaming::MakeSpaceFor(size << 11); CStreaming::MakeSpaceFor(size << 11);
CStreaming::ImGonnaUseStreamingMemory(); CStreaming::ImGonnaUseStreamingMemory();
RwStreamSkip(stream, offset << 11); RwStreamSkip(stream, offset << 11);
CAnimManager::LoadAnimFile(stream, false); CAnimManager::LoadAnimFile(stream, true, ms_uncompressedAnims);
ms_cutsceneAssociations.CreateAssociations(szCutsceneName); ms_cutsceneAssociations.CreateAssociations(szCutsceneName);
CStreaming::IHaveUsedStreamingMemory(); CStreaming::IHaveUsedStreamingMemory();
ms_animLoaded = true; ms_animLoaded = true;
@ -207,13 +213,18 @@ CCutsceneMgr::LoadCutsceneData(const char *szCutsceneName)
file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb"); file = CFileMgr::OpenFile("ANIM\\CUTS.IMG", "rb");
sprintf(gString, "%s.DAT", szCutsceneName); sprintf(gString, "%s.DAT", szCutsceneName);
if (ms_pCutsceneDir->FindItem(gString, offset, size)) { if (ms_pCutsceneDir->FindItem(gString, offset, size)) {
CStreaming::ImGonnaUseStreamingMemory();
CFileMgr::Seek(file, offset << 11, SEEK_SET); CFileMgr::Seek(file, offset << 11, SEEK_SET);
TheCamera.LoadPathSplines(file); TheCamera.LoadPathSplines(file);
CStreaming::IHaveUsedStreamingMemory();
ms_camLoaded = true;
} else {
ms_camLoaded = false;
} }
CFileMgr::CloseFile(file); CFileMgr::CloseFile(file);
if (CGeneral::faststricmp(ms_cutsceneName, "end")) { if (CGeneral::faststricmp(ms_cutsceneName, "finale")) {
DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE); DMAudio.ChangeMusicMode(MUSICMODE_CUTSCENE);
int trackId = FindCutsceneAudioTrackId(szCutsceneName); int trackId = FindCutsceneAudioTrackId(szCutsceneName);
if (trackId != -1) { if (trackId != -1) {
@ -241,8 +252,10 @@ void
CCutsceneMgr::FinishCutscene() CCutsceneMgr::FinishCutscene()
{ {
ms_wasCutsceneSkipped = true; ms_wasCutsceneSkipped = true;
CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f; if (ms_camLoaded) {
TheCamera.FinishCutscene(); CCutsceneMgr::ms_cutsceneTimer = TheCamera.GetCutSceneFinishTime() * 0.001f;
TheCamera.FinishCutscene();
}
FindPlayerPed()->bIsVisible = true; FindPlayerPed()->bIsVisible = true;
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
@ -251,9 +264,11 @@ CCutsceneMgr::FinishCutscene()
void void
CCutsceneMgr::SetupCutsceneToStart(void) CCutsceneMgr::SetupCutsceneToStart(void)
{ {
TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset); if (ms_camLoaded) {
TheCamera.TakeControlWithSpline(JUMP_CUT); TheCamera.SetCamCutSceneOffSet(ms_cutsceneOffset);
TheCamera.SetWideScreenOn(); TheCamera.TakeControlWithSpline(JUMP_CUT);
TheCamera.SetWideScreenOn();
}
ms_cutsceneOffset.z++; ms_cutsceneOffset.z++;
@ -363,8 +378,14 @@ CCutsceneMgr::DeleteCutsceneData(void)
CAnimManager::RemoveLastAnimFile(); CAnimManager::RemoveLastAnimFile();
ms_animLoaded = false; ms_animLoaded = false;
TheCamera.RestoreWithJumpCut(); ms_numUncompressedAnims = 0;
TheCamera.SetWideScreenOff(); ms_uncompressedAnims[0][0] = '\0';
if (ms_camLoaded) {
TheCamera.RestoreWithJumpCut();
TheCamera.SetWideScreenOff();
TheCamera.DeleteCutSceneCamDataMemory();
}
ms_running = false; ms_running = false;
ms_loaded = false; ms_loaded = false;
@ -372,12 +393,14 @@ CCutsceneMgr::DeleteCutsceneData(void)
CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CUTSCENE); CPad::GetPad(0)->SetEnablePlayerControls(PLAYERCONTROL_CUTSCENE);
CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false); CWorld::Players[CWorld::PlayerInFocus].MakePlayerSafe(false);
if (CGeneral::faststricmp(ms_cutsceneName, "end")) { if (CGeneral::faststricmp(ms_cutsceneName, "finale")) {
DMAudio.StopCutSceneMusic(); DMAudio.StopCutSceneMusic();
if (CGeneral::faststricmp(ms_cutsceneName, "bet")) DMAudio.ChangeMusicMode(MUSICMODE_GAME);
DMAudio.ChangeMusicMode(MUSICMODE_GAME);
} }
CGame::DrasticTidyUpMemory(TheCamera.GetScreenFadeStatus() == 2);
if(ms_camLoaded)
CGame::DrasticTidyUpMemory(TheCamera.GetScreenFadeStatus() == 2);
CTimer::Resume(); CTimer::Resume();
} }
@ -395,7 +418,7 @@ CCutsceneMgr::Update(void)
switch (ms_cutsceneLoadStatus) { switch (ms_cutsceneLoadStatus) {
case CUTSCENE_LOADING_AUDIO: case CUTSCENE_LOADING_AUDIO:
SetupCutsceneToStart(); SetupCutsceneToStart();
if (CGeneral::faststricmp(ms_cutsceneName, "end")) if (CGeneral::faststricmp(ms_cutsceneName, "finale"))
DMAudio.PlayPreloadedCutSceneMusic(); DMAudio.PlayPreloadedCutSceneMusic();
ms_cutsceneLoadStatus++; ms_cutsceneLoadStatus++;
break; break;
@ -413,15 +436,27 @@ CCutsceneMgr::Update(void)
if (!ms_running) return; if (!ms_running) return;
ms_cutsceneTimer += CTimer::GetTimeStepNonClippedInSeconds(); ms_cutsceneTimer += CTimer::GetTimeStepNonClippedInSeconds();
if (CGeneral::faststricmp(ms_cutsceneName, "end") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) {
if (CPad::GetPad(0)->GetCrossJustDown() if (ms_camLoaded)
|| (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown()) if (CGeneral::faststricmp(ms_cutsceneName, "finale") && TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_FLYBY && ms_cutsceneLoadStatus == CUTSCENE_LOADING_0) {
|| CPad::GetPad(0)->GetLeftMouseJustDown() if (CPad::GetPad(0)->GetCrossJustDown()
|| CPad::GetPad(0)->GetEnterJustDown() || (CGame::playingIntro && CPad::GetPad(0)->GetStartJustDown())
|| CPad::GetPad(0)->GetCharJustDown(' ')) || CPad::GetPad(0)->GetLeftMouseJustDown()
FinishCutscene(); || CPad::GetPad(0)->GetEnterJustDown()
} || CPad::GetPad(0)->GetCharJustDown(' '))
FinishCutscene();
}
} }
bool CCutsceneMgr::HasCutsceneFinished(void) { return TheCamera.GetPositionAlongSpline() == 1.0f; } bool CCutsceneMgr::HasCutsceneFinished(void) { return !ms_camLoaded || TheCamera.GetPositionAlongSpline() == 1.0f; }
void
CCutsceneMgr::LoadAnimationUncompressed(char const* name)
{
strcpy(ms_uncompressedAnims[ms_numUncompressedAnims], name);
// Because that's how CAnimManager knows the end of array
++ms_numUncompressedAnims;
assert(ms_numUncompressedAnims < ARRAY_SIZE(ms_uncompressedAnims));
ms_uncompressedAnims[ms_numUncompressedAnims][0] = '\0';
}

View File

@ -17,7 +17,10 @@ class CCutsceneMgr
static bool ms_animLoaded; static bool ms_animLoaded;
static bool ms_useLodMultiplier; static bool ms_useLodMultiplier;
static bool ms_camLoaded;
static char ms_cutsceneName[CUTSCENENAMESIZE]; static char ms_cutsceneName[CUTSCENENAMESIZE];
static char ms_uncompressedAnims[8][32];
static uint32 ms_numUncompressedAnims;
static CAnimBlendAssocGroup ms_cutsceneAssociations; static CAnimBlendAssocGroup ms_cutsceneAssociations;
static CVector ms_cutsceneOffset; static CVector ms_cutsceneOffset;
static float ms_cutsceneTimer; static float ms_cutsceneTimer;
@ -49,5 +52,6 @@ public:
static CCutsceneHead *AddCutsceneHead(CObject *pObject, int modelId); static CCutsceneHead *AddCutsceneHead(CObject *pObject, int modelId);
static CCutsceneObject *CreateCutsceneObject(int modelId); static CCutsceneObject *CreateCutsceneObject(int modelId);
static void DeleteCutsceneData(void); static void DeleteCutsceneData(void);
static void LoadAnimationUncompressed(char const*);
static void Update(void); static void Update(void);
}; };

View File

@ -30,6 +30,8 @@
#include "Timer.h" #include "Timer.h"
#include "WaterLevel.h" #include "WaterLevel.h"
#include "World.h" #include "World.h"
#include "Hud.h"
#include "Messages.h"
CPickup CPickups::aPickUps[NUMPICKUPS]; CPickup CPickups::aPickUps[NUMPICKUPS];
int16 CPickups::NumMessages; int16 CPickups::NumMessages;
@ -37,6 +39,7 @@ int32 CPickups::aPickUpsCollected[NUMCOLLECTEDPICKUPS];
int16 CPickups::CollectedPickUpIndex; int16 CPickups::CollectedPickUpIndex;
int32 CPickups::PlayerOnWeaponPickup; int32 CPickups::PlayerOnWeaponPickup;
int32 CPickups::CollectPickupBuffer;
// unused // unused
bool CPickups::bPickUpcamActivated; bool CPickups::bPickUpcamActivated;
@ -71,6 +74,32 @@ uint8 aWeaponBlues[] = { 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 128, 255, 0, 0 }; 0, 128, 255, 0, 0 };
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 void
CPickup::RemoveKeepType() CPickup::RemoveKeepType()
{ {
@ -163,6 +192,31 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
{ {
float waterLevel; 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 (m_bRemoved) {
if (CTimer::GetTimeInMilliseconds() > m_nTimer) { if (CTimer::GetTimeInMilliseconds() > m_nTimer) {
// respawn pickup if we're far enough // respawn pickup if we're far enough
@ -290,6 +344,32 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
Remove(); Remove();
DMAudio.PlayFrontEndSound(SOUND_PICKUP_MONEY, 0); DMAudio.PlayFrontEndSound(SOUND_PICKUP_MONEY, 0);
return true; 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: default:
break; break;
} }
@ -528,12 +608,12 @@ CPickups::RemovePickUp(int32 pickupIndex)
} }
int32 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; bool bFreeFound = false;
int32 slot = 0; 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--) { for (slot = NUMPICKUPS-1; slot >= 0; slot--) {
if (aPickUps[slot].m_eType == PICKUP_NONE) { if (aPickUps[slot].m_eType == PICKUP_NONE) {
bFreeFound = true; bFreeFound = true;
@ -556,7 +636,7 @@ CPickups::GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quan
if (slot >= NUMGENERALPICKUPS) { if (slot >= NUMGENERALPICKUPS) {
for (slot = 0; slot < NUMGENERALPICKUPS; slot++) { 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; 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_eType = (ePickupType)type;
aPickUps[slot].m_bRemoved = false; aPickUps[slot].m_bRemoved = false;
aPickUps[slot].m_nQuantity = quantity; 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) if (type == PICKUP_ONCE_TIMEOUT)
aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 20000; 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) else if (type == PICKUP_MONEY)
aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 30000; aPickUps[slot].m_nTimer = CTimer::GetTimeInMilliseconds() + 30000;
else if (type == PICKUP_MINE_INACTIVE || type == PICKUP_MINE_ARMED) { 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_nTimer = CTimer::GetTimeInMilliseconds() + 1500;
} }
aPickUps[slot].m_eModelIndex = modelIndex; 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_vecPos = pos;
aPickUps[slot].m_pObject = aPickUps[slot].GiveUsAPickUpObject(-1); aPickUps[slot].m_pObject = aPickUps[slot].GiveUsAPickUpObject(-1);
if (aPickUps[slot].m_pObject) if (aPickUps[slot].m_pObject)
@ -664,6 +754,16 @@ CPickups::Update()
} }
} }
#endif #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) #define PICKUPS_FRAME_SPAN (6)
#ifdef FIX_BUGS #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++) { for (uint32 i = NUMGENERALPICKUPS * (CTimer::GetFrameCounter() % PICKUPS_FRAME_SPAN) / PICKUPS_FRAME_SPAN; i < NUMGENERALPICKUPS * (CTimer::GetFrameCounter() % PICKUPS_FRAME_SPAN + 1) / PICKUPS_FRAME_SPAN; i++) {

View File

@ -33,14 +33,19 @@ class CPlayerPed;
class CPickup class CPickup
{ {
public: public:
ePickupType m_eType; CVector m_vecPos;
bool m_bRemoved; uint32 m_nRevenue;
uint16 m_nQuantity;
CObject *m_pObject; CObject *m_pObject;
CObject *m_pExtraObject;
uint16 m_nQuantity;
uint32 m_nTimer; uint32 m_nTimer;
int16 m_nMoneySpeed;
int16 m_eModelIndex; int16 m_eModelIndex;
uint16 m_nIndex; uint16 m_nIndex;
CVector m_vecPos; char m_sTextKey[8];
ePickupType m_eType;
bool m_bRemoved;
uint8 m_effects;
CObject *GiveUsAPickUpObject(int32 handle); CObject *GiveUsAPickUpObject(int32 handle);
bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId); bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId);
@ -71,6 +76,7 @@ class CPickups
static tPickupMessage aMessages[NUMPICKUPMESSAGES]; static tPickupMessage aMessages[NUMPICKUPMESSAGES];
public: public:
static int32 PlayerOnWeaponPickup; static int32 PlayerOnWeaponPickup;
static int32 CollectPickupBuffer;
static void Init(); static void Init();
static void Update(); static void Update();
@ -79,7 +85,7 @@ public:
static void DoMoneyEffects(CEntity *ent); static void DoMoneyEffects(CEntity *ent);
static void DoMineEffects(CEntity *ent); static void DoMineEffects(CEntity *ent);
static void DoPickUpEffects(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 int32 GenerateNewOne_WeaponType(CVector pos, eWeaponType weaponType, uint8 type, uint32 quantity);
static void RemovePickUp(int32 pickupIndex); static void RemovePickUp(int32 pickupIndex);
static void RemoveAllFloatingPickups(); static void RemoveAllFloatingPickups();

View File

@ -80,6 +80,8 @@
#include "World.h" #include "World.h"
#include "Zones.h" #include "Zones.h"
#include "main.h" #include "main.h"
#include "Ropes.h"
#include "MBlur.h"
#ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT #ifdef USE_ADVANCED_SCRIPT_DEBUG_OUTPUT
#include <stdarg.h> #include <stdarg.h>
#endif #endif
@ -12110,6 +12112,7 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
CVector pos = *(CVector*)&ScriptParams[0]; CVector pos = *(CVector*)&ScriptParams[0];
if (pos.z <= MAP_Z_LOW_LIMIT) if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; 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]); ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_REVENUE, PICKUP_ASSET_REVENUE, ScriptParams[3], ScriptParams[4]);
StoreParameters(&m_nIp, 1); StoreParameters(&m_nIp, 1);
return 0; return 0;
@ -12790,7 +12793,7 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
case COMMAND_CREATE_SWAT_ROPE: case COMMAND_CREATE_SWAT_ROPE:
{ {
CollectParameters(&m_nIp, 3); CollectParameters(&m_nIp, 3);
debug("CREATE_SWAT_ROPE is not implemented\n"); CRopes::CreateRopeWithSwatComingDown(*(CVector*)&ScriptParams[0]);
return 0; return 0;
} }
//case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA: //case COMMAND_SET_FIRST_PERSON_CONTROL_CAMERA:
@ -12902,10 +12905,12 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
CVector pos = *(CVector*)&ScriptParams[0]; CVector pos = *(CVector*)&ScriptParams[0];
if (pos.z <= MAP_Z_LOW_LIMIT) if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET;
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); char key[KEY_LENGTH_IN_SCRIPT];
// TODO(MIAMI) - add text CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
m_nIp += KEY_LENGTH_IN_SCRIPT;
// TheText.Get(key);
CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); 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); StoreParameters(&m_nIp, 1);
return 0; return 0;
} }
@ -12915,10 +12920,12 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
CVector pos = *(CVector*)&ScriptParams[0]; CVector pos = *(CVector*)&ScriptParams[0];
if (pos.z <= MAP_Z_LOW_LIMIT) if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET; pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET;
wchar* text = CTheScripts::GetTextByKeyFromScript(&m_nIp); char key[KEY_LENGTH_IN_SCRIPT];
// TODO(MIAMI) - add text CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
m_nIp += KEY_LENGTH_IN_SCRIPT;
// TheText.Get(key);
CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp)); 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); StoreParameters(&m_nIp, 1);
return 0; return 0;
} }
@ -13021,7 +13028,11 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_SET_PLAYER_DRUNKENNESS: case COMMAND_SET_PLAYER_DRUNKENNESS:
{ {
CollectParameters(&m_nIp, 2); 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; return 0;
} }
//case COMMAND_GET_PLAYER_DRUNKENNESS: //case COMMAND_GET_PLAYER_DRUNKENNESS:
@ -13421,7 +13432,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
char key[KEY_LENGTH_IN_SCRIPT]; char key[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, key); CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
debug("LOAD_UNCOMPRESSED_ANIM not implemented\n"); // TODO(MIAMI) CCutsceneMgr::LoadAnimationUncompressed(key);
return 0; return 0;
} }
case COMMAND_WAS_CUTSCENE_SKIPPED: case COMMAND_WAS_CUTSCENE_SKIPPED:
@ -13624,15 +13635,13 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_IS_PLAYER_IN_INFO_ZONE: case COMMAND_IS_PLAYER_IN_INFO_ZONE:
{ {
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
char key[KEY_LENGTH_IN_SCRIPT]; char key[KEY_LENGTH_IN_SCRIPT];
CTheScripts::ReadTextLabelFromScript(&m_nIp, key); CTheScripts::ReadTextLabelFromScript(&m_nIp, key);
m_nIp += KEY_LENGTH_IN_SCRIPT; m_nIp += KEY_LENGTH_IN_SCRIPT;
static bool bShowed = false; CVector pos = pPlayerInfo->GetPos();
if (!bShowed) { CZone *infoZone = CTheZones::FindInformationZoneForPosition(&pos);
debug("IS_PLAYER_IN_INFO_ZONE not implemented, default to FALSE\n"); UpdateCompareFlag(strncmp(key, infoZone->name, 8) == 0);
bShowed = true;
}
UpdateCompareFlag(false);
return 0; return 0;
} }
case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE: case COMMAND_CLEAR_CHAR_ICE_CREAM_PURCHASE:
@ -13828,7 +13837,19 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI: case COMMAND_CREATE_DUST_EFFECT_FOR_CUTSCENE_HELI:
{ {
CollectParameters(&m_nIp, 3); 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; return 0;
} }
case COMMAND_REGISTER_FIRE_LEVEL: case COMMAND_REGISTER_FIRE_LEVEL:

View File

@ -3409,9 +3409,9 @@ CMenuManager::SmallMessageScreen(const char* text)
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetJustifyOn(); CFont::SetJustifyOn();
CFont::SetBackGroundOnlyTextOn(); CFont::SetBackGroundOnlyTextOn();
CSprite2d::DrawRect(CRect(SCREEN_SCALE_X(95.0f), SCREEN_SCALE_FROM_BOTTOM(165.0f), SCREEN_SCALE_FROM_RIGHT(95.0f), SCREEN_SCALE_Y(115.0f)), CRGBA(50, 50, 50, FadeIn(210))); CSprite2d::DrawRect(CRect(SCREEN_STRETCH_X(95.0f), SCREEN_SCALE_FROM_BOTTOM(165.0f), SCREEN_STRETCH_FROM_RIGHT(95.0f), SCREEN_SCALE_Y(115.0f)), CRGBA(50, 50, 50, FadeIn(210)));
CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD)); CFont::SetFontStyle(FONT_LOCALE(FONT_STANDARD));
CFont::SetCentreSize(SCREEN_SCALE_X(430.0f)); CFont::SetCentreSize(SCREEN_STRETCH_X(430.0f));
CFont::SetCentreOn(); CFont::SetCentreOn();
CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255))); CFont::SetColor(CRGBA(LABEL_COLOR.r, LABEL_COLOR.g, LABEL_COLOR.b, FadeIn(255)));
CFont::SetDropShadowPosition(2); CFont::SetDropShadowPosition(2);

View File

@ -2644,6 +2644,38 @@ bool CPad::TargetJustDown(void)
return false; return false;
} }
bool CPad::CollectPickupJustDown(void)
{
if ( ArePlayerControlsDisabled() )
return false;
switch (CURMODE)
{
case 0:
case 1:
{
return !!(NewState.LeftShoulder1 && !OldState.LeftShoulder1);
break;
}
case 2:
{
return !!(NewState.Triangle && !OldState.Triangle);
break;
}
case 3:
{
return !!(NewState.Circle && !OldState.Circle);
break;
}
}
return false;
}
bool CPad::DuckJustDown(void) bool CPad::DuckJustDown(void)
{ {
if (ArePlayerControlsDisabled()) if (ArePlayerControlsDisabled())

View File

@ -238,6 +238,7 @@ public:
bool GetTarget(void); bool GetTarget(void);
bool TargetJustDown(void); bool TargetJustDown(void);
bool DuckJustDown(void); bool DuckJustDown(void);
bool CollectPickupJustDown(void);
bool JumpJustDown(void); bool JumpJustDown(void);
bool GetSprint(void); bool GetSprint(void);
bool ShiftTargetLeftJustDown(void); bool ShiftTargetLeftJustDown(void);

View File

@ -1708,6 +1708,12 @@ void CHud::SetHelpMessage(wchar *message, bool quick)
} }
} }
bool CHud::IsHelpMessageBeingDisplayed(void)
{
return m_HelpMessageState != 0;
}
void CHud::SetMessage(wchar *message) void CHud::SetMessage(wchar *message)
{ {
int i = 0; int i = 0;

View File

@ -133,6 +133,7 @@ public:
static void ReInitialise(); static void ReInitialise();
static void SetBigMessage(wchar *message, int16 style); static void SetBigMessage(wchar *message, int16 style);
static void SetHelpMessage(wchar *message, bool quick); static void SetHelpMessage(wchar *message, bool quick);
static bool IsHelpMessageBeingDisplayed(void);
static void SetMessage(wchar *message); static void SetMessage(wchar *message);
static void SetPagerMessage(wchar *message); static void SetPagerMessage(wchar *message);
static void SetVehicleName(wchar *name); static void SetVehicleName(wchar *name);

View File

@ -5577,7 +5577,7 @@ CAutomobile::TellHeliToGoToCoors(float x, float y, float z, uint8 speed)
void void
CAutomobile::TellPlaneToGoToCoors(float x, float y, float z, uint8 speed) CAutomobile::TellPlaneToGoToCoors(float x, float y, float z, uint8 speed)
{ {
AutoPilot.m_nCarMission = MISSION_HELI_FLYTOCOORS; AutoPilot.m_nCarMission = MISSION_PLANE_FLYTOCOORS;
AutoPilot.m_vecDestinationCoors.x = x; AutoPilot.m_vecDestinationCoors.x = x;
AutoPilot.m_vecDestinationCoors.y = y; AutoPilot.m_vecDestinationCoors.y = y;
AutoPilot.m_vecDestinationCoors.z = z; AutoPilot.m_vecDestinationCoors.z = z;