mirror of
https://github.com/GTAmodding/re3.git
synced 2024-12-27 07:55:41 +00:00
Merge remote-tracking branch 'upstream/miami' into miami
This commit is contained in:
commit
d3788a9c70
11 changed files with 373 additions and 23 deletions
|
@ -51,6 +51,7 @@
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "Radar.h"
|
#include "Radar.h"
|
||||||
#include "Fluff.h"
|
#include "Fluff.h"
|
||||||
|
#include "WaterCreatures.h"
|
||||||
|
|
||||||
//--MIAMI: file done except TODO
|
//--MIAMI: file done except TODO
|
||||||
|
|
||||||
|
@ -1272,7 +1273,7 @@ void CReplay::TriggerPlayback(uint8 cam_mode, float cam_x, float cam_y, float ca
|
||||||
DMAudio.SetEffectsFadeVol(0);
|
DMAudio.SetEffectsFadeVol(0);
|
||||||
DMAudio.SetMusicFadeVol(0);
|
DMAudio.SetMusicFadeVol(0);
|
||||||
CEscalators::Shutdown();
|
CEscalators::Shutdown();
|
||||||
// TODO(MIAMI): CWaterCreatures::RemoveAll();
|
CWaterCreatures::RemoveAll();
|
||||||
int current;
|
int current;
|
||||||
for (current = 0; current < NUM_REPLAYBUFFERS; current++)
|
for (current = 0; current < NUM_REPLAYBUFFERS; current++)
|
||||||
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
if (BufferStatus[current] == REPLAYBUFFER_RECORD)
|
||||||
|
|
|
@ -90,6 +90,7 @@
|
||||||
#include "debugmenu.h"
|
#include "debugmenu.h"
|
||||||
#include "Ropes.h"
|
#include "Ropes.h"
|
||||||
#include "WindModifiers.h"
|
#include "WindModifiers.h"
|
||||||
|
#include "WaterCreatures.h"
|
||||||
#include "postfx.h"
|
#include "postfx.h"
|
||||||
#include "custompipes.h"
|
#include "custompipes.h"
|
||||||
|
|
||||||
|
@ -478,8 +479,7 @@ bool CGame::ShutDown(void)
|
||||||
CPlane::Shutdown();
|
CPlane::Shutdown();
|
||||||
CTrain::Shutdown();
|
CTrain::Shutdown();
|
||||||
CScriptPaths::Shutdown();
|
CScriptPaths::Shutdown();
|
||||||
// TODO(Miami)
|
CWaterCreatures::RemoveAll();
|
||||||
// CWaterCreatures::RemoveAll();
|
|
||||||
CSpecialFX::Shutdown();
|
CSpecialFX::Shutdown();
|
||||||
#ifndef PS2
|
#ifndef PS2
|
||||||
CGarages::Shutdown();
|
CGarages::Shutdown();
|
||||||
|
@ -650,7 +650,7 @@ void CGame::ShutDownForRestart(void)
|
||||||
CRadar::RemoveRadarSections();
|
CRadar::RemoveRadarSections();
|
||||||
FrontEndMenuManager.UnloadTextures();
|
FrontEndMenuManager.UnloadTextures();
|
||||||
CParticleObject::RemoveAllExpireableParticleObjects();
|
CParticleObject::RemoveAllExpireableParticleObjects();
|
||||||
//CWaterCreatures::RemoveAll(); //TODO(Miami)
|
CWaterCreatures::RemoveAll();
|
||||||
CSetPieces::Init();
|
CSetPieces::Init();
|
||||||
CPedType::Shutdown();
|
CPedType::Shutdown();
|
||||||
CSpecialFX::Shutdown();
|
CSpecialFX::Shutdown();
|
||||||
|
|
|
@ -138,6 +138,7 @@ enum Config {
|
||||||
|
|
||||||
NUM_CRANES = 8,
|
NUM_CRANES = 8,
|
||||||
NUM_ESCALATORS = 22,
|
NUM_ESCALATORS = 22,
|
||||||
|
NUM_WATER_CREATURES = 8,
|
||||||
|
|
||||||
NUM_EXPLOSIONS = 48,
|
NUM_EXPLOSIONS = 48,
|
||||||
|
|
||||||
|
@ -261,7 +262,6 @@ enum Config {
|
||||||
//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls
|
//#define BIND_VEHICLE_FIREWEAPON // Adds ability to rebind fire key for 'in vehicle' controls
|
||||||
|
|
||||||
// Hud, frontend and radar
|
// Hud, frontend and radar
|
||||||
#define HUD_ENHANCEMENTS // Adjusts some aspects to make the HUD look/behave a little bit better.
|
|
||||||
//#define BETA_SLIDING_TEXT
|
//#define BETA_SLIDING_TEXT
|
||||||
#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC
|
#define TRIANGULAR_BLIPS // height indicating triangular radar blips, as in VC
|
||||||
#define PC_MENU
|
#define PC_MENU
|
||||||
|
|
|
@ -1208,3 +1208,36 @@ bool CEntity::IsEntityOccluded(void) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
0x487A10 - SetAtomicAlphaCB
|
||||||
|
0x4879E0 - SetClumpAlphaCB
|
||||||
|
*/
|
||||||
|
|
||||||
|
RpMaterial* SetAtomicAlphaCB(RpMaterial *material, void *data) {
|
||||||
|
((RwRGBA*)RpMaterialGetColor(material))->alpha = (uint8)(uintptr)data;
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
RpAtomic* SetClumpAlphaCB(RpAtomic *atomic, void *data) {
|
||||||
|
RpGeometry *geometry = RpAtomicGetGeometry(atomic);
|
||||||
|
RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR);
|
||||||
|
RpGeometryForAllMaterials(geometry, SetAtomicAlphaCB, (void*)data);
|
||||||
|
return atomic;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CEntity::SetRwObjectAlpha(int32 alpha) {
|
||||||
|
if (m_rwObject != nil) {
|
||||||
|
switch (RwObjectGetType(m_rwObject)) {
|
||||||
|
case rpATOMIC: {
|
||||||
|
RpGeometry *geometry = RpAtomicGetGeometry((RpAtomic*)m_rwObject);
|
||||||
|
RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR);
|
||||||
|
RpGeometryForAllMaterials(geometry, SetAtomicAlphaCB, (void*)alpha);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case rpCLUMP:
|
||||||
|
RpClumpForAllAtomics((RpClump*)m_rwObject, SetClumpAlphaCB, (void*)alpha);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -179,6 +179,7 @@ public:
|
||||||
void ModifyMatrixForTreeInWind(void);
|
void ModifyMatrixForTreeInWind(void);
|
||||||
void ModifyMatrixForBannerInWind(void);
|
void ModifyMatrixForBannerInWind(void);
|
||||||
void ProcessLightsForEntity(void);
|
void ProcessLightsForEntity(void);
|
||||||
|
void SetRwObjectAlpha(int32 alpha);
|
||||||
|
|
||||||
static void AddSteamsFromGround(CPtrList& list);
|
static void AddSteamsFromGround(CPtrList& list);
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,12 +24,17 @@ float
|
||||||
CDraw::CalculateAspectRatio(void)
|
CDraw::CalculateAspectRatio(void)
|
||||||
{
|
{
|
||||||
if (FrontEndMenuManager.m_PrefsUseWideScreen) {
|
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)
|
if (TheCamera.m_WideScreenOn)
|
||||||
CDraw::ms_fAspectRatio = 5.f / 3.f; // It's used on theatrical showings according to Wiki
|
CDraw::ms_fAspectRatio = 5.f / 3.f; // It's used on theatrical showings according to Wiki
|
||||||
else
|
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;
|
CDraw::ms_fAspectRatio = 16.f / 9.f;
|
||||||
#endif
|
#endif
|
||||||
} else if (TheCamera.m_WideScreenOn) {
|
} else if (TheCamera.m_WideScreenOn) {
|
||||||
|
|
|
@ -854,11 +854,7 @@ void CHud::Draw()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HUD_ENHANCEMENTS
|
|
||||||
if (!m_Message[0]) {
|
if (!m_Message[0]) {
|
||||||
#else
|
|
||||||
if (!m_Message[0] && !m_BigMessage[2][0]) { // Hide vehicle name if wasted/busted text is displaying
|
|
||||||
#endif
|
|
||||||
m_VehicleNameTimer += CTimer::GetTimeStepInMilliseconds();
|
m_VehicleNameTimer += CTimer::GetTimeStepInMilliseconds();
|
||||||
CFont::SetJustifyOff();
|
CFont::SetJustifyOff();
|
||||||
CFont::SetPropOn();
|
CFont::SetPropOn();
|
||||||
|
@ -1378,16 +1374,16 @@ void CHud::Draw()
|
||||||
CFont::SetRightJustifyOn();
|
CFont::SetRightJustifyOn();
|
||||||
CFont::SetFontStyle(FONT_HEADING);
|
CFont::SetFontStyle(FONT_HEADING);
|
||||||
|
|
||||||
CFont::SetColor(CRGBA(0, 0, 0, BigMessageAlpha[2]));
|
CFont::SetDropShadowPosition(2);
|
||||||
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f - 4.0f), SCREEN_SCALE_FROM_BOTTOM(78.0f), m_BigMessage[2]);
|
CFont::SetDropColor(CRGBA(0, 0, 0, BigMessageAlpha[2]));
|
||||||
|
|
||||||
CFont::SetColor(CRGBA(WASTEDBUSTED_COLOR.r, WASTEDBUSTED_COLOR.g, WASTEDBUSTED_COLOR.b, BigMessageAlpha[2]));
|
CFont::SetColor(CRGBA(WASTEDBUSTED_COLOR.r, WASTEDBUSTED_COLOR.g, WASTEDBUSTED_COLOR.b, BigMessageAlpha[2]));
|
||||||
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(82.0f), m_BigMessage[2]);
|
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(20.0f), SCREEN_SCALE_FROM_BOTTOM(90.0f), m_BigMessage[2]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BigMessageInUse[2] = 1.0f;
|
BigMessageInUse[2] = 1.0f;
|
||||||
BigMessageAlpha[2] = 0.0f;
|
BigMessageAlpha[2] = 0.0f;
|
||||||
if (m_VehicleState != 0)
|
if (m_VehicleState != 0) // Hide vehicle name if wasted/busted text is displaying
|
||||||
m_VehicleState = 0;
|
m_VehicleState = 0;
|
||||||
if (m_ZoneState != 0)
|
if (m_ZoneState != 0)
|
||||||
m_ZoneState = 0;
|
m_ZoneState = 0;
|
||||||
|
|
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 "Replay.h"
|
||||||
#include "WaterLevel.h"
|
#include "WaterLevel.h"
|
||||||
#include "SurfaceTable.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))
|
#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 )
|
else if ( (CTimer::GetTimeInMilliseconds() - timecounter) > 5000 )
|
||||||
{
|
{
|
||||||
//TODO(MIAMI)
|
if ( CWaterCreatures::IsSpaceForMoreWaterCreatures() )
|
||||||
// if ( CWaterCreatures::IsSpaceForMoreWaterCreatures() )
|
|
||||||
{
|
{
|
||||||
for ( int32 i = 0; i < 3; i++ )
|
for ( int32 i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
|
@ -2838,14 +2838,12 @@ CWaterLevel::HandleSeaLifeForms()
|
||||||
vecPos.x += (fCos - fSin) * fAngle;
|
vecPos.x += (fCos - fSin) * fAngle;
|
||||||
vecPos.y += (fSin + fCos) * fAngle;
|
vecPos.y += (fSin + fCos) * fAngle;
|
||||||
|
|
||||||
//TODO(MIAMI)
|
CWaterCreatures::CreateOne(vecPos, -1);
|
||||||
//CWaterCreatures::CreateOne(vecPos, 0xFFFFFFFF);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO(MIAMI)
|
CWaterCreatures::UpdateAll();
|
||||||
//CWaterCreatures::UpdateAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
2
vendor/librw
vendored
2
vendor/librw
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit edc77742c512b85ad35544b2cfbe3f359dc75805
|
Subproject commit 30b77b0b32b4113b5dce2b67813ce9b85d1e1e57
|
Loading…
Reference in a new issue