script revision

This commit is contained in:
Nikolay Korolev 2020-05-20 20:40:04 +03:00
parent fec0028e12
commit d84650fbe5
5 changed files with 328 additions and 187 deletions

View File

@ -20,8 +20,9 @@ void COnscreenTimer::Init() {
}
m_sEntries[i].m_nType = COUNTER_DISPLAY_NUMBER;
m_sEntries[i].m_bTimerProcessed = 0;
m_sEntries[i].m_bCounterProcessed = 0;
m_sEntries[i].m_bTimerProcessed = false;
m_sEntries[i].m_bCounterProcessed = false;
m_sEntries[i].m_bTimerGoingDown = true;
}
}
@ -65,26 +66,21 @@ void COnscreenTimer::ClearClock(uint32 offset) {
}
}
void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text) {
uint32 i = 0;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
if(m_sEntries[i].m_nCounterOffset == 0) {
break;
}
void COnscreenTimer::AddCounter(uint32 offset, uint16 type, char* text, uint16 pos) {
m_sEntries[pos].m_nCounterOffset = offset;
if (m_sEntries[pos].m_aCounterText[0] != '\0')
return;
}
m_sEntries[i].m_nCounterOffset = offset;
if(text) {
strncpy(m_sEntries[i].m_aCounterText, text, 10);
strncpy(m_sEntries[pos].m_aCounterText, text, 10);
} else {
m_sEntries[i].m_aCounterText[0] = 0;
m_sEntries[pos].m_aCounterText[0] = 0;
}
m_sEntries[i].m_nType = type;
m_sEntries[pos].m_nType = type;
}
void COnscreenTimer::AddClock(uint32 offset, char* text) {
void COnscreenTimer::AddClock(uint32 offset, char* text, bool bGoingDown) {
uint32 i = 0;
for(uint32 i = 0; i < NUMONSCREENTIMERENTRIES; i++) {
if(m_sEntries[i].m_nTimerOffset == 0) {
@ -94,6 +90,7 @@ void COnscreenTimer::AddClock(uint32 offset, char* text) {
}
m_sEntries[i].m_nTimerOffset = offset;
m_sEntries[i].m_bTimerGoingDown = bGoingDown;
if(text) {
strncpy(m_sEntries[i].m_aTimerText, text, 10);
} else {
@ -108,19 +105,24 @@ void COnscreenTimerEntry::Process() {
int32* timerPtr = CTheScripts::GetPointerToScriptVariable(m_nTimerOffset);
int32 oldTime = *timerPtr;
int32 newTime = oldTime - int32(CTimer::GetTimeStepInSeconds() * 1000);
if(newTime < 0) {
*timerPtr = 0;
m_bTimerProcessed = 0;
m_nTimerOffset = 0;
m_aTimerText[0] = 0;
} else {
*timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000;
if(oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) {
DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000);
if (m_bTimerGoingDown) {
int32 newTime = oldTime - int32(CTimer::GetTimeStepInMilliseconds());
if (newTime < 0) {
*timerPtr = 0;
m_bTimerProcessed = 0;
m_nTimerOffset = 0;
m_aTimerText[0] = 0;
}
else {
*timerPtr = newTime;
int32 oldTimeSeconds = oldTime / 1000;
if (oldTimeSeconds < 12 && newTime / 1000 != oldTimeSeconds) {
DMAudio.PlayFrontEndSound(SOUND_CLOCK_TICK, newTime / 1000);
}
}
}
else
*timerPtr = oldTime + int32(CTimer::GetTimeStepInMilliseconds());
}
bool COnscreenTimerEntry::ProcessForDisplay() {

View File

@ -17,6 +17,7 @@ public:
char m_bCounterBuffer[42];
char m_bTimerBuffer[42];
bool m_bTimerProcessed;
bool m_bTimerGoingDown;
bool m_bCounterProcessed;
void Process();
@ -42,8 +43,8 @@ public:
void ClearCounter(uint32 offset);
void ClearClock(uint32 offset);
void AddCounter(uint32 offset, uint16 type, char* text);
void AddClock(uint32 offset, char* text);
void AddCounter(uint32 offset, uint16 type, char* text, uint16 pos);
void AddClock(uint32 offset, char* text, bool bGoingDown);
};
VALIDATE_SIZE(COnscreenTimer, 0x78);

File diff suppressed because it is too large Load Diff

View File

@ -485,10 +485,11 @@ private:
float LimitAngleOnCircle(float angle) { return angle < 0.0f ? angle + 360.0f : angle; }
bool ThisIsAValidRandomPed(uint32 pedtype) {
bool ThisIsAValidRandomPed(uint32 pedtype, int civ, int gang, int criminal) {
switch (pedtype) {
case PEDTYPE_CIVMALE:
case PEDTYPE_CIVFEMALE:
return civ;
case PEDTYPE_GANG1:
case PEDTYPE_GANG2:
case PEDTYPE_GANG3:
@ -498,13 +499,16 @@ private:
case PEDTYPE_GANG7:
case PEDTYPE_GANG8:
case PEDTYPE_GANG9:
return gang;
case PEDTYPE_CRIMINAL:
case PEDTYPE_PROSTITUTE:
return true;
return criminal;
default:
return false;
}
}
bool CheckDamagedWeaponType(int32 type, int32 actual);
static bool ThisIsAValidRandomCop(int32 mi, bool cop, bool swat, bool fbi, bool army, bool miami);
};

View File

@ -44,6 +44,8 @@ enum eWeaponType
WEAPONTYPE_UNIDENTIFIED,
WEAPONTYPE_TOTALWEAPONS = WEAPONTYPE_LAST_WEAPONTYPE,
WEAPONTYPE_ANYMELEE = 46,
WEAPONTYPE_ANYWEAPON = 47
};
enum {