mirror of
https://github.com/halpz/re3.git
synced 2025-07-26 08:32:43 +00:00
Merge branch 'miami' of https://github.com/GTAmodding/re3 into miami
This commit is contained in:
@ -24,12 +24,17 @@ float
|
||||
CDraw::CalculateAspectRatio(void)
|
||||
{
|
||||
if (FrontEndMenuManager.m_PrefsUseWideScreen) {
|
||||
#ifdef ASPECT_RATIO_SCALE
|
||||
if (TheCamera.m_WideScreenOn)
|
||||
CDraw::ms_fAspectRatio = FrontEndMenuManager.m_PrefsUseWideScreen == AR_AUTO ?
|
||||
(5.f / 3.f) * (SCREEN_WIDTH / SCREEN_HEIGHT) / (16.f / 9.f) :
|
||||
5.f / 3.f; // It's used on theatrical showings according to Wiki
|
||||
else
|
||||
CDraw::ms_fAspectRatio = FrontEndMenuManager.m_PrefsUseWideScreen == AR_AUTO ? SCREEN_WIDTH / SCREEN_HEIGHT : 16.f / 9.f;
|
||||
#else
|
||||
if (TheCamera.m_WideScreenOn)
|
||||
CDraw::ms_fAspectRatio = 5.f / 3.f; // It's used on theatrical showings according to Wiki
|
||||
else
|
||||
#ifdef ASPECT_RATIO_SCALE
|
||||
CDraw::ms_fAspectRatio = FrontEndMenuManager.m_PrefsUseWideScreen == AR_AUTO ? SCREEN_WIDTH / SCREEN_HEIGHT : 16.f / 9.f;
|
||||
#else
|
||||
CDraw::ms_fAspectRatio = 16.f / 9.f;
|
||||
#endif
|
||||
} else if (TheCamera.m_WideScreenOn) {
|
||||
|
@ -1358,7 +1358,7 @@ CEscalator::Update(void) {
|
||||
if (m_pSteps[i]) {
|
||||
m_pSteps[i]->SetPosition(m_pos1);
|
||||
CWorld::Add(m_pSteps[i]);
|
||||
m_pSteps[i]->ObjectCreatedBy = ESCALATOR_OBJECT;
|
||||
m_pSteps[i]->ObjectCreatedBy = CONTROLLED_SUB_OBJECT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1713,4 +1713,4 @@ void CScriptPaths::Save_ForReplay(void) {
|
||||
g_pScriptPathObjects[6 * i + j] = aArray[i].m_pObjects[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,46 @@
|
||||
#include "Font.h"
|
||||
#include "Timer.h"
|
||||
|
||||
void
|
||||
AsciiToUnicode(const char *src, wchar *dst)
|
||||
{
|
||||
while((*dst++ = (unsigned char)*src++) != '\0');
|
||||
}
|
||||
|
||||
void
|
||||
UnicodeStrcat(wchar *dst, wchar *append)
|
||||
{
|
||||
UnicodeStrcpy(&dst[UnicodeStrlen(dst)], append);
|
||||
}
|
||||
|
||||
void
|
||||
UnicodeStrcpy(wchar *dst, const wchar *src)
|
||||
{
|
||||
while((*dst++ = *src++) != '\0');
|
||||
}
|
||||
|
||||
int
|
||||
UnicodeStrlen(const wchar *str)
|
||||
{
|
||||
int len;
|
||||
for(len = 0; *str != '\0'; len++, str++);
|
||||
return len;
|
||||
}
|
||||
|
||||
void
|
||||
UnicodeMakeUpperCase(wchar *dst, const wchar *src) //idk what to do with it, seems to be incorrect implementation by R*
|
||||
{
|
||||
while (*src != '\0') {
|
||||
if (*src < 'a' || *src > 'z')
|
||||
*dst = *src;
|
||||
else
|
||||
*dst = *src - 32;
|
||||
dst++;
|
||||
src++;
|
||||
}
|
||||
*dst = '\0';
|
||||
}
|
||||
|
||||
CFontDetails CFont::Details;
|
||||
int16 CFont::NewLine;
|
||||
CSprite2d CFont::Sprite[MAX_FONTS];
|
||||
@ -1102,6 +1142,7 @@ CFont::ParseToken(wchar *s)
|
||||
switch(*s){
|
||||
case 'B':
|
||||
Details.bBold = !Details.bBold;
|
||||
break;
|
||||
case 'N':
|
||||
case 'n':
|
||||
NewLine = 1;
|
||||
@ -1109,7 +1150,7 @@ CFont::ParseToken(wchar *s)
|
||||
case 'b': SetColor(CRGBA(27, 89, 130, 255)); Details.anonymous_23 = true; break;
|
||||
case 'f':
|
||||
Details.bFlash = !Details.bFlash;
|
||||
if (Details.bFlash)
|
||||
if (!Details.bFlash)
|
||||
Details.color.a = 255;
|
||||
break;
|
||||
case 'g': SetColor(CRGBA(255, 150, 225, 255)); Details.anonymous_23 = true; break;
|
||||
|
@ -1,5 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
void AsciiToUnicode(const char *src, wchar *dst);
|
||||
void UnicodeStrcpy(wchar *dst, const wchar *src);
|
||||
void UnicodeStrcat(wchar *dst, wchar *append);
|
||||
int UnicodeStrlen(const wchar *str);
|
||||
void UnicodeMakeUpperCase(wchar *dst, const wchar *src);
|
||||
|
||||
struct CFontDetails
|
||||
{
|
||||
CRGBA color;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,11 @@
|
||||
#pragma once
|
||||
#include "Sprite2d.h"
|
||||
|
||||
#define HELP_MSG_LENGTH 256
|
||||
|
||||
#define HUD_TEXT_SCALE_X 0.7f
|
||||
#define HUD_TEXT_SCALE_Y 1.25f
|
||||
|
||||
enum eItems
|
||||
{
|
||||
ITEM_NONE = -1,
|
||||
@ -31,41 +36,29 @@ enum eFadeOperation
|
||||
enum eSprites
|
||||
{
|
||||
HUD_FIST,
|
||||
HUD_BAT,
|
||||
HUD_PISTOL,
|
||||
HUD_UZI,
|
||||
HUD_SHOTGUN,
|
||||
HUD_AK47,
|
||||
HUD_M16,
|
||||
HUD_SNIPER,
|
||||
HUD_ROCKET,
|
||||
HUD_FLAME,
|
||||
HUD_MOLOTOV,
|
||||
HUD_GRENADE,
|
||||
HUD_DETONATOR,
|
||||
HUD_RADARDISC = 15,
|
||||
HUD_PAGER = 16,
|
||||
HUD_SITESNIPER = 20,
|
||||
HUD_SITEROCKET = 41,
|
||||
HUD_RADARDISC = 50,
|
||||
HUD_SITESNIPER = 63,
|
||||
HUD_SITEM16,
|
||||
HUD_SITEROCKET,
|
||||
NUM_HUD_SPRITES,
|
||||
HUD_SITELASER,
|
||||
HUD_LASERDOT,
|
||||
HUD_VIEWFINDER,
|
||||
HUD_BLEEDER,
|
||||
NUM_HUD_SPRITES = 69,
|
||||
};
|
||||
|
||||
#define HUD_TEXT_SCALE_X 0.7f
|
||||
#define HUD_TEXT_SCALE_Y 1.25f
|
||||
|
||||
class CHud
|
||||
{
|
||||
public:
|
||||
static CSprite2d Sprites[NUM_HUD_SPRITES];
|
||||
static wchar m_HelpMessage[256];
|
||||
static wchar m_LastHelpMessage[256];
|
||||
static wchar m_HelpMessage[HELP_MSG_LENGTH];
|
||||
static wchar m_LastHelpMessage[HELP_MSG_LENGTH];
|
||||
static uint32 m_HelpMessageState;
|
||||
static uint32 m_HelpMessageTimer;
|
||||
static int32 m_HelpMessageFadeTimer;
|
||||
static wchar m_HelpMessageToPrint[256];
|
||||
static float &m_HelpMessageDisplayTime;
|
||||
static float m_fHelpMessageTime;
|
||||
static wchar m_HelpMessageToPrint[HELP_MSG_LENGTH];
|
||||
static float m_HelpMessageDisplayTime;
|
||||
static bool m_HelpMessageDisplayForever;
|
||||
static bool m_HelpMessageQuick;
|
||||
static uint32 m_ZoneState;
|
||||
static int32 m_ZoneFadeTimer;
|
||||
@ -86,16 +79,16 @@ public:
|
||||
static wchar m_BigMessage[6][128];
|
||||
static int16 m_ItemToFlash;
|
||||
static bool m_HideRadar;
|
||||
static int32 m_DrawClock;
|
||||
static int32 m_ClockState;
|
||||
|
||||
// These aren't really in CHud
|
||||
static float BigMessageInUse[6];
|
||||
static float BigMessageAlpha[6];
|
||||
static float BigMessageX[6];
|
||||
static float OddJob2OffTimer;
|
||||
static bool CounterOnLastFrame;
|
||||
static bool CounterOnLastFrame[NUMONSCREENCOUNTERS];
|
||||
static float OddJob2XOffset;
|
||||
static uint16 CounterFlashTimer;
|
||||
static uint16 CounterFlashTimer[NUMONSCREENCOUNTERS];
|
||||
static uint16 OddJob2Timer;
|
||||
static bool TimerOnLastFrame;
|
||||
static int16 OddJob2On;
|
||||
@ -121,6 +114,8 @@ public:
|
||||
|
||||
static uint32 m_LastDisplayScore;
|
||||
static uint32 m_LastWanted;
|
||||
static uint32 m_LastWeapon;
|
||||
static uint32 m_LastTimeEnergyLost;
|
||||
|
||||
public:
|
||||
static void Draw();
|
||||
@ -131,8 +126,8 @@ public:
|
||||
#endif
|
||||
static void Initialise();
|
||||
static void ReInitialise();
|
||||
static void SetBigMessage(wchar *message, int16 style);
|
||||
static void SetHelpMessage(wchar *message, bool quick);
|
||||
static void SetBigMessage(wchar *message, uint16 style);
|
||||
static void SetHelpMessage(wchar *message, bool quick, bool displayForever = false);
|
||||
static bool IsHelpMessageBeingDisplayed(void);
|
||||
static void SetMessage(wchar *message);
|
||||
static void SetPagerMessage(wchar *message);
|
||||
|
@ -366,6 +366,12 @@ COcclusion::ProcessBeforeRendering(void)
|
||||
}
|
||||
NumActiveOccluders--;
|
||||
i--;
|
||||
// Taken from Mobile!
|
||||
#ifdef FIX_BUGS
|
||||
if (i == -1) {
|
||||
i = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -481,4 +487,4 @@ void COcclusion::Render() {
|
||||
|
||||
DefinedState();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1220,8 +1220,11 @@ void CParticle::Update()
|
||||
|
||||
if ( psystem->m_Type == PARTICLE_HEATHAZE || psystem->m_Type == PARTICLE_HEATHAZE_IN_DIST )
|
||||
{
|
||||
#ifdef FIX_BUGS
|
||||
int32 nSinCosIndex = (int32(DEGTORAD((float)particle->m_nRotation) * float(SIN_COS_TABLE_SIZE) / TWOPI) + SIN_COS_TABLE_SIZE) % SIN_COS_TABLE_SIZE;
|
||||
#else
|
||||
int32 nSinCosIndex = int32(DEGTORAD((float)particle->m_nRotation) * float(SIN_COS_TABLE_SIZE) / TWOPI) % SIN_COS_TABLE_SIZE;
|
||||
|
||||
#endif
|
||||
vecMoveStep.x = Sin(nSinCosIndex);
|
||||
vecMoveStep.y = Sin(nSinCosIndex);
|
||||
|
||||
@ -1233,8 +1236,11 @@ void CParticle::Update()
|
||||
|
||||
if ( psystem->m_Type == PARTICLE_BEASTIE )
|
||||
{
|
||||
#ifdef FIX_BUGS
|
||||
int32 nSinCosIndex = (int32(DEGTORAD((float)particle->m_nRotation) * float(SIN_COS_TABLE_SIZE) / TWOPI) + SIN_COS_TABLE_SIZE) % SIN_COS_TABLE_SIZE;
|
||||
#else
|
||||
int32 nSinCosIndex = int32(DEGTORAD((float)particle->m_nRotation) * float(SIN_COS_TABLE_SIZE) / TWOPI) % SIN_COS_TABLE_SIZE;
|
||||
|
||||
#endif
|
||||
particle->m_vecVelocity.x = 0.50f * Cos(nSinCosIndex);
|
||||
particle->m_vecVelocity.y = Cos(nSinCosIndex);
|
||||
particle->m_vecVelocity.z = 0.25f * Sin(nSinCosIndex);
|
||||
@ -1750,7 +1756,11 @@ void CParticle::Update()
|
||||
}
|
||||
|
||||
if ( particle->m_nRotationStep != 0 )
|
||||
#ifdef FIX_BUGS
|
||||
particle->m_nRotation = CGeneral::LimitAngle(particle->m_nRotation + particle->m_nRotationStep);
|
||||
#else
|
||||
particle->m_nRotation += particle->m_nRotationStep;
|
||||
#endif
|
||||
|
||||
if ( particle->m_fCurrentZRadius != 0.0f )
|
||||
{
|
||||
@ -2403,7 +2413,7 @@ void CParticle::HandleShootableBirdsStuff(CEntity *entity, CVector const&camPos)
|
||||
{
|
||||
float fHeadingRad = entity->GetForward().Heading();
|
||||
float fHeading = RADTODEG(fHeadingRad);
|
||||
float fBirdAngle = Cos(DEGTORAD(1.5f));
|
||||
float fBirdAngle = ::Cos(DEGTORAD(1.5f));
|
||||
|
||||
tParticleSystemData *psystem = &mod_ParticleSystemManager.m_aParticles[PARTICLE_BIRD_FRONT];
|
||||
CParticle *particle = psystem->m_pParticles;
|
||||
|
@ -77,9 +77,13 @@ void CWaterCannon::Update_OncePerFrame(int16 index)
|
||||
}
|
||||
}
|
||||
|
||||
int32 extinguishingPoint = CGeneral::GetRandomNumber() & (NUM_SEGMENTPOINTS - 1);
|
||||
if ( m_abUsed[extinguishingPoint] )
|
||||
gFireManager.ExtinguishPoint(m_avecPos[extinguishingPoint], 3.0f);
|
||||
for ( int32 i = 0; i < NUM_SEGMENTPOINTS; i++ )
|
||||
{
|
||||
if ( m_abUsed[i] && gFireManager.ExtinguishPointWithWater(m_avecPos[i], 4.0f) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ((index + CTimer::GetFrameCounter()) & 3) == 0 )
|
||||
PushPeds();
|
||||
|
267
src/render/WaterCreatures.cpp
Normal file
267
src/render/WaterCreatures.cpp
Normal file
@ -0,0 +1,267 @@
|
||||
#include "WaterCreatures.h"
|
||||
#include "ModelIndices.h"
|
||||
#include "World.h"
|
||||
#include "WaterLevel.h"
|
||||
#include "Camera.h"
|
||||
#include "PlayerPed.h"
|
||||
#include "config.h"
|
||||
#include "General.h"
|
||||
|
||||
int CWaterCreatures::nNumActiveSeaLifeForms;
|
||||
CWaterCreature CWaterCreatures::aWaterCreatures[NUM_WATER_CREATURES];
|
||||
|
||||
struct WaterCreatureProperties aProperties[65] = {
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_JELLYFISH, 0.01f, 2.2f, 0.0005f, 3.5f },
|
||||
{ &MI_JELLYFISH01, 0.01f, 2.2f, 0.0005f, 3.5f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_TURTLE, 0.01f, 2.0f, 0.0005f, 4.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_DOLPHIN, 0.03f, 1.5f, 0.0005f, 4.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_SHARK, 0.03f, 0.4f, 0.0005f, 4.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH1SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH2S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3SINGLE, 0.04f, 3.0f, 0.0008f, 3.0f },
|
||||
{ &MI_FISH3S, 0.04f, 1.5f, 0.0008f, 3.0f },
|
||||
};
|
||||
|
||||
CWaterCreature::CWaterCreature() {
|
||||
Free();
|
||||
}
|
||||
|
||||
CWaterCreature::~CWaterCreature() {
|
||||
//looks like unused
|
||||
}
|
||||
|
||||
void CWaterCreature::Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
|
||||
this->m_pObj = pObj;
|
||||
this->m_fRightMult = fRightMult;
|
||||
this->m_fZTurnSpeed = fZTurnSpeed;
|
||||
this->m_fWaterDepth = fWaterDepth;
|
||||
this->m_alpha = alpha;
|
||||
this->m_state = state;
|
||||
}
|
||||
|
||||
void CWaterCreature::Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
|
||||
CWaterCreature::Initialise(pObj, fRightMult, fZTurnSpeed, fWaterDepth, alpha, state);
|
||||
}
|
||||
|
||||
void CWaterCreature::Free() {
|
||||
CWaterCreature::Initialise(nil, 0.0f, 0.0f, 0.0f, 0, WATER_CREATURE_DISABLED);
|
||||
}
|
||||
|
||||
CWaterCreature *CWaterCreatures::GetFishStructSlot() {
|
||||
for (int i = 0; i < NUM_WATER_CREATURES; i++)
|
||||
if (aWaterCreatures[i].m_state == WATER_CREATURE_DISABLED)
|
||||
return &aWaterCreatures[i];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
CObject *CWaterCreatures::CreateSeaLifeForm(CVector const& pos, int16 modelID, int32 zRotAngle) {
|
||||
if (CObject::nNoTempObjects >= 40)
|
||||
return nil;
|
||||
|
||||
CObject *pObj = new CObject(modelID, true);
|
||||
|
||||
if (!pObj) return nil;
|
||||
|
||||
pObj->GetMatrix().GetPosition() = pos;
|
||||
pObj->GetMatrix().UpdateRW();
|
||||
pObj->m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
|
||||
pObj->m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
|
||||
pObj->GetMatrix().SetRotateZOnly(DEGTORAD(zRotAngle));
|
||||
pObj->GetMatrix().UpdateRW();
|
||||
pObj->ObjectCreatedBy = CONTROLLED_SUB_OBJECT;
|
||||
pObj->bIsStatic = false;
|
||||
|
||||
if (pObj->ObjectCreatedBy == TEMP_OBJECT) {
|
||||
CObject::nNoTempObjects++;
|
||||
pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 60000;
|
||||
}
|
||||
|
||||
pObj->bTouchingWater = true;
|
||||
pObj->bUnderwater = true;
|
||||
CWorld::Add(pObj);
|
||||
|
||||
return pObj;
|
||||
}
|
||||
|
||||
bool CWaterCreatures::IsSpaceForMoreWaterCreatures() {
|
||||
return nNumActiveSeaLifeForms < NUM_WATER_CREATURES;
|
||||
}
|
||||
|
||||
float CWaterCreatures::CalculateFishHeading(CVector const& pos1, CVector const& pos2) {
|
||||
CVector delta = pos1 - pos2;
|
||||
delta.Normalise();
|
||||
|
||||
return Atan2(-delta.x, delta.y);
|
||||
}
|
||||
|
||||
void CWaterCreatures::CreateOne(CVector const& pos, int32 modelID) {
|
||||
if (!IsSpaceForMoreWaterCreatures())
|
||||
return;
|
||||
|
||||
CVector storedPos = pos;
|
||||
float fDepth, fLevelNoWaves;
|
||||
if (!TheCamera.IsSphereVisible(storedPos, 3.0f)
|
||||
&& CWaterLevel::GetWaterDepth(storedPos, &fDepth, &fLevelNoWaves, nil) && fDepth > 4.5f) {
|
||||
|
||||
if (modelID == -1 || modelID < 0 || modelID > 64)
|
||||
modelID = CGeneral::GetRandomNumberInRange(0, 64);
|
||||
|
||||
WaterCreatureProperties *creature = &aProperties[modelID];
|
||||
storedPos.z = fLevelNoWaves - creature->fLevel;
|
||||
float fRightMult = CGeneral::GetRandomNumberInRange(0.0f, creature->fRightMult) + 0.01f;
|
||||
float angle = CWaterCreatures::CalculateFishHeading(FindPlayerPed()->GetPosition(), storedPos);
|
||||
|
||||
CObject *fish = CreateSeaLifeForm(storedPos, *(int16*)creature->modelID, angle);
|
||||
if (!fish) return;
|
||||
|
||||
fish->SetRwObjectAlpha(255);
|
||||
CWaterCreature *wc = GetFishStructSlot();
|
||||
wc->Allocate(fish, fRightMult, 0.0f, creature->fWaterDepth, 255, WATER_CREATURE_ALLOCATED);
|
||||
nNumActiveSeaLifeForms++;
|
||||
}
|
||||
}
|
||||
|
||||
void CWaterCreatures::FreeFishStructSlot(CWaterCreature *wc) {
|
||||
wc->Free();
|
||||
}
|
||||
|
||||
void CWaterCreatures::UpdateAll() {
|
||||
if (nNumActiveSeaLifeForms == 0)
|
||||
return;
|
||||
|
||||
CVector playerPos = FindPlayerPed()->GetPosition();
|
||||
for (int i = 0; i < NUM_WATER_CREATURES; i++) {
|
||||
switch (aWaterCreatures[i].m_state) {
|
||||
case WATER_CREATURE_ACTIVE:
|
||||
aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000;
|
||||
if (!aWaterCreatures[i].m_pObj->GetIsOnScreen()) {
|
||||
aWaterCreatures[i].m_pObj->SetRwObjectAlpha(0);
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE;
|
||||
break;
|
||||
}
|
||||
case WATER_CREATURE_ALLOCATED: {
|
||||
if ((playerPos - aWaterCreatures[i].m_pObj->GetPosition()).Magnitude() < SQR(75.0f)) {
|
||||
if (aWaterCreatures[i].m_alpha < 255)
|
||||
aWaterCreatures[i].m_alpha = Min(aWaterCreatures[i].m_alpha + 4, 255);
|
||||
aWaterCreatures[i].m_pObj->SetRwObjectAlpha(aWaterCreatures[i].m_alpha);
|
||||
CVector newRight = aWaterCreatures[i].m_pObj->GetRight();
|
||||
newRight.Normalise();
|
||||
aWaterCreatures[i].m_pObj->m_vecMoveSpeed = newRight * aWaterCreatures[i].m_fRightMult;
|
||||
aWaterCreatures[i].m_pObj->m_vecTurnSpeed = CVector(0.0f, 0.0f, aWaterCreatures[i].m_fZTurnSpeed);
|
||||
aWaterCreatures[i].m_pObj->bIsStatic = false;
|
||||
float fDepth = 0.0;
|
||||
CWaterLevel::GetWaterDepth(aWaterCreatures[i].m_pObj->GetPosition(), &fDepth, nil, nil);
|
||||
if (aWaterCreatures[i].m_fWaterDepth < fDepth) {
|
||||
if (aWaterCreatures[i].m_pObj->m_nEndOfLifeTime - 40000 <= CTimer::GetTimeInMilliseconds())
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_ACTIVE;
|
||||
}
|
||||
else {
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_UPDATE;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WATER_CREATURE_UPDATE: {
|
||||
aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000;
|
||||
if (aWaterCreatures[i].m_alpha <= 0) {
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE;
|
||||
}
|
||||
else {
|
||||
aWaterCreatures[i].m_alpha = Max(aWaterCreatures[i].m_alpha - 6, 0);
|
||||
aWaterCreatures[i].m_pObj->SetRwObjectAlpha(aWaterCreatures[i].m_alpha);
|
||||
CVector newRight = aWaterCreatures[i].m_pObj->GetRight();
|
||||
newRight.Normalise();
|
||||
newRight.x *= aWaterCreatures[i].m_fRightMult;
|
||||
newRight.y *= aWaterCreatures[i].m_fRightMult;
|
||||
newRight.z -= 0.015f;
|
||||
aWaterCreatures[i].m_pObj->m_vecMoveSpeed = newRight;
|
||||
|
||||
if (!aWaterCreatures[i].m_pObj->GetIsOnScreen())
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WATER_CREATURE_TO_REMOVE:
|
||||
if (aWaterCreatures[i].m_pObj)
|
||||
CWorld::Remove(aWaterCreatures[i].m_pObj);
|
||||
FreeFishStructSlot(&aWaterCreatures[i]);
|
||||
nNumActiveSeaLifeForms--;
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CWaterCreatures::RemoveAll() {
|
||||
for (int i = 0; i < NUM_WATER_CREATURES; i++) {
|
||||
if (aWaterCreatures[i].m_state != WATER_CREATURE_DISABLED) {
|
||||
CWorld::Remove(aWaterCreatures[i].m_pObj);
|
||||
FreeFishStructSlot(&aWaterCreatures[i]);
|
||||
aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED;
|
||||
nNumActiveSeaLifeForms--;
|
||||
}
|
||||
}
|
||||
}
|
49
src/render/WaterCreatures.h
Normal file
49
src/render/WaterCreatures.h
Normal file
@ -0,0 +1,49 @@
|
||||
#pragma once
|
||||
#include "Object.h"
|
||||
|
||||
enum eFishSlotState {
|
||||
WATER_CREATURE_ALLOCATED = 0,
|
||||
WATER_CREATURE_ACTIVE,
|
||||
WATER_CREATURE_UPDATE,
|
||||
WATER_CREATURE_TO_REMOVE,
|
||||
WATER_CREATURE_DISABLED
|
||||
};
|
||||
|
||||
class CWaterCreature {
|
||||
public:
|
||||
CObject *m_pObj;
|
||||
float m_fRightMult;
|
||||
float m_fZTurnSpeed;
|
||||
int32 m_alpha;
|
||||
float m_fWaterDepth;
|
||||
int32 m_state;
|
||||
|
||||
CWaterCreature();
|
||||
~CWaterCreature();
|
||||
void Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
|
||||
void Free();
|
||||
void Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
|
||||
};
|
||||
|
||||
class CWaterCreatures {
|
||||
|
||||
public:
|
||||
static CWaterCreature aWaterCreatures[NUM_WATER_CREATURES];
|
||||
static int32 nNumActiveSeaLifeForms;
|
||||
static CObject *CreateSeaLifeForm(CVector const& pos, int16 modelID, int32 zRotAngle);
|
||||
static void CreateOne(CVector const& pos, int32 modelID);
|
||||
static void UpdateAll();
|
||||
static void FreeFishStructSlot(CWaterCreature *wc);
|
||||
static bool IsSpaceForMoreWaterCreatures();
|
||||
static float CalculateFishHeading(CVector const& pos1, CVector const& pos2);
|
||||
static void RemoveAll();
|
||||
static CWaterCreature* GetFishStructSlot();
|
||||
};
|
||||
|
||||
struct WaterCreatureProperties {
|
||||
int16 *modelID;
|
||||
float fRightMult;
|
||||
float fLevel;
|
||||
float fUnknown; //unused
|
||||
float fWaterDepth;
|
||||
};
|
@ -27,6 +27,7 @@
|
||||
#include "Replay.h"
|
||||
#include "WaterLevel.h"
|
||||
#include "SurfaceTable.h"
|
||||
#include "WaterCreatures.h"
|
||||
|
||||
#define RwIm3DVertexSet_RGBA(vert, rgba) RwIm3DVertexSetRGBA(vert, rgba.red, rgba.green, rgba.blue, rgba.alpha) // (RwRGBAAssign(&(_dst)->color, &_src))
|
||||
|
||||
@ -2821,8 +2822,7 @@ CWaterLevel::HandleSeaLifeForms()
|
||||
}
|
||||
else if ( (CTimer::GetTimeInMilliseconds() - timecounter) > 5000 )
|
||||
{
|
||||
//TODO(MIAMI)
|
||||
// if ( CWaterCreatures::IsSpaceForMoreWaterCreatures() )
|
||||
if ( CWaterCreatures::IsSpaceForMoreWaterCreatures() )
|
||||
{
|
||||
for ( int32 i = 0; i < 3; i++ )
|
||||
{
|
||||
@ -2838,14 +2838,12 @@ CWaterLevel::HandleSeaLifeForms()
|
||||
vecPos.x += (fCos - fSin) * fAngle;
|
||||
vecPos.y += (fSin + fCos) * fAngle;
|
||||
|
||||
//TODO(MIAMI)
|
||||
//CWaterCreatures::CreateOne(vecPos, 0xFFFFFFFF);
|
||||
CWaterCreatures::CreateOne(vecPos, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO(MIAMI)
|
||||
//CWaterCreatures::UpdateAll();
|
||||
CWaterCreatures::UpdateAll();
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user