1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 20:30:02 +00:00

CWaterCreatures

This commit is contained in:
majestic 2020-10-09 05:53:22 -07:00
commit e7ef45a606
16 changed files with 100 additions and 69 deletions

View file

@ -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"
uint8 CReplay::Mode; uint8 CReplay::Mode;
CAddressInReplayBuffer CReplay::Record; CAddressInReplayBuffer CReplay::Record;
@ -1300,7 +1301,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)

View file

@ -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();

View file

@ -2,6 +2,8 @@
#include <ctype.h> #include <ctype.h>
// --MIAMI: file done
class CGeneral class CGeneral
{ {
public: public:

View file

@ -4,6 +4,8 @@
#include "World.h" #include "World.h"
#include "Dummy.h" #include "Dummy.h"
// --MIAMI: file done
void *CDummy::operator new(size_t sz) { return CPools::GetDummyPool()->New(); } void *CDummy::operator new(size_t sz) { return CPools::GetDummyPool()->New(); }
void CDummy::operator delete(void *p, size_t sz) { CPools::GetDummyPool()->Delete((CDummy*)p); } void CDummy::operator delete(void *p, size_t sz) { CPools::GetDummyPool()->Delete((CDummy*)p); }

View file

@ -1230,7 +1230,7 @@ void CEntity::SetRwObjectAlpha(int32 alpha) {
if (m_rwObject != nil) { if (m_rwObject != nil) {
switch (RwObjectGetType(m_rwObject)) { switch (RwObjectGetType(m_rwObject)) {
case rpATOMIC: { case rpATOMIC: {
RpGeometry *geometry = RpAtomicGetGeometry(GetFirstAtomic(GetClump())); RpGeometry *geometry = RpAtomicGetGeometry((RpAtomic*)m_rwObject);
RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR); RpGeometrySetFlags(geometry, RpGeometryGetFlags(geometry) | rpGEOMETRYMODULATEMATERIALCOLOR);
RpGeometryForAllMaterials(geometry, SetAtomicAlphaCB, (void*)alpha); RpGeometryForAllMaterials(geometry, SetAtomicAlphaCB, (void*)alpha);
break; break;

View file

@ -3,6 +3,8 @@
#include "DummyObject.h" #include "DummyObject.h"
#include "Pools.h" #include "Pools.h"
// --MIAMI: file done
CDummyObject::CDummyObject(CObject *obj) CDummyObject::CDummyObject(CObject *obj)
{ {
SetModelIndexNoCreate(obj->GetModelIndex()); SetModelIndexNoCreate(obj->GetModelIndex());

View file

@ -36,6 +36,7 @@ CObject::CObject(void)
m_colour2 = 0; m_colour2 = 0;
m_colour1 = m_colour2; m_colour1 = m_colour2;
m_nBonusValue = 0; m_nBonusValue = 0;
// m_nCostValue = 0; // TODO(Miami)
bIsPickup = false; bIsPickup = false;
bPickupObjWithMessage = false; bPickupObjWithMessage = false;
bOutOfStock = false; bOutOfStock = false;
@ -44,8 +45,12 @@ CObject::CObject(void)
bHasBeenDamaged = false; bHasBeenDamaged = false;
m_nRefModelIndex = -1; m_nRefModelIndex = -1;
bUseVehicleColours = false; bUseVehicleColours = false;
// bIsStreetLight = false; // duplicate
m_pCurSurface = nil; m_pCurSurface = nil;
m_pCollidingEntity = nil; m_pCollidingEntity = nil;
m_nBeachballBounces = 0;
bIsStreetLight = false;
m_area = AREA_EVERYWHERE;
} }
CObject::CObject(int32 mi, bool createRW) CObject::CObject(int32 mi, bool createRW)
@ -138,12 +143,16 @@ CObject::Render(void)
bool bool
CObject::SetupLighting(void) CObject::SetupLighting(void)
{ {
DeActivateDirectional();
SetAmbientColours();
if(bRenderScorched){ if(bRenderScorched){
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f); WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
return true; return true;
} else if (bIsPickup) {
SetFullAmbient();
return true;
} else if (bIsWeapon) {
ActivateDirectional();
SetAmbientColoursForPedsCarsAndObjects();
return true;
} }
return false; return false;
} }
@ -151,8 +160,10 @@ CObject::SetupLighting(void)
void void
CObject::RemoveLighting(bool reset) CObject::RemoveLighting(bool reset)
{ {
if(reset) if(reset) {
WorldReplaceScorchedLightsWithNormal(Scene.world); SetAmbientColours();
DeActivateDirectional();
}
} }
void void
@ -363,6 +374,8 @@ CObject::CanBeDeleted(void)
return true; return true;
case CUTSCENE_OBJECT: case CUTSCENE_OBJECT:
return false; return false;
case CONTROLLED_SUB_OBJECT:
return false;
default: default:
return true; return true;
} }

View file

@ -2,6 +2,8 @@
#include "Projectile.h" #include "Projectile.h"
// --MIAMI: file done
CProjectile::CProjectile(int32 model) : CObject() CProjectile::CProjectile(int32 model) : CObject()
{ {
m_fMass = 1.0f; m_fMass = 1.0f;

View file

@ -3,6 +3,8 @@
#include "main.h" #include "main.h"
#include "PedRoutes.h" #include "PedRoutes.h"
// --MIAMI: file done
CRouteNode gaRoutes[NUMPEDROUTES]; CRouteNode gaRoutes[NUMPEDROUTES];
void void

View file

@ -4,6 +4,8 @@
#include "FileMgr.h" #include "FileMgr.h"
#include "PedStats.h" #include "PedStats.h"
// --MIAMI: file done
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS]; CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
void void

View file

@ -86,17 +86,17 @@ CWaterCreature::~CWaterCreature() {
//looks like unused //looks like unused
} }
void CWaterCreature::Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, int eFishSlotState) { void CWaterCreature::Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
this->m_pObj = pObj; this->m_pObj = pObj;
this->m_fRightMult = fRightMult; this->m_fRightMult = fRightMult;
this->m_fZTurnSpeed = 0.0f; this->m_fZTurnSpeed = fZTurnSpeed;
this->m_fWaterDepth = fWaterDepth; this->m_fWaterDepth = fWaterDepth;
this->m_alpha = alpha; this->m_alpha = alpha;
this->m_state = eFishSlotState; this->m_state = state;
} }
void CWaterCreature::Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, int eFishSlotState) { void CWaterCreature::Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state) {
CWaterCreature::Initialise(pObj, fRightMult, fZTurnSpeed, fWaterDepth, alpha, eFishSlotState); CWaterCreature::Initialise(pObj, fRightMult, fZTurnSpeed, fWaterDepth, alpha, state);
} }
void CWaterCreature::Free() { void CWaterCreature::Free() {
@ -111,7 +111,7 @@ CWaterCreature *CWaterCreatures::GetFishStructSlot() {
return nil; return nil;
} }
CObject *CWaterCreatures::CreateSeaLifeForm(CVector pos, int16 modelID, float zRotAngle) { CObject *CWaterCreatures::CreateSeaLifeForm(CVector const& pos, int16 modelID, int32 zRotAngle) {
if (CObject::nNoTempObjects >= 40) if (CObject::nNoTempObjects >= 40)
return nil; return nil;
@ -151,23 +151,24 @@ float CWaterCreatures::CalculateFishHeading(CVector const& pos1, CVector const&
return Atan2(-delta.x, delta.y); return Atan2(-delta.x, delta.y);
} }
void CWaterCreatures::CreateOne(CVector pos, int16 modelID) { void CWaterCreatures::CreateOne(CVector const& pos, int32 modelID) {
if (!IsSpaceForMoreWaterCreatures()) if (!IsSpaceForMoreWaterCreatures())
return; return;
CVector storedPos = pos;
float fDepth, fLevelNoWaves; float fDepth, fLevelNoWaves;
if (TheCamera.IsSphereVisible(pos, 3.0f) if (!TheCamera.IsSphereVisible(storedPos, 3.0f)
&& CWaterLevel::GetWaterDepth(pos, &fDepth, &fLevelNoWaves, nil) && fDepth > 4.5f) { && CWaterLevel::GetWaterDepth(storedPos, &fDepth, &fLevelNoWaves, nil) && fDepth > 4.5f) {
if (modelID == -1 || modelID > 64) if (modelID == -1 || modelID < 0 || modelID > 64)
modelID = CGeneral::GetRandomNumberInRange(0, 64); modelID = CGeneral::GetRandomNumberInRange(0, 64);
WaterCreatureProperties *creature = &aProperties[modelID]; WaterCreatureProperties *creature = &aProperties[modelID];
pos.z = fLevelNoWaves - creature->fLevel; storedPos.z = fLevelNoWaves - creature->fLevel;
float fRightMult = CGeneral::GetRandomNumberInRange(0.0f, 0.01f); float fRightMult = CGeneral::GetRandomNumberInRange(0.0f, creature->fRightMult) + 0.01f;
float angle = CWaterCreatures::CalculateFishHeading(FindPlayerPed()->GetPosition(), pos); float angle = CWaterCreatures::CalculateFishHeading(FindPlayerPed()->GetPosition(), storedPos);
CObject *fish = CreateSeaLifeForm(pos, modelID, angle); CObject *fish = CreateSeaLifeForm(storedPos, *(int16*)creature->modelID, angle);
if (!fish) return; if (!fish) return;
fish->SetRwObjectAlpha(255); fish->SetRwObjectAlpha(255);
@ -188,13 +189,18 @@ void CWaterCreatures::UpdateAll() {
CVector playerPos = FindPlayerPed()->GetPosition(); CVector playerPos = FindPlayerPed()->GetPosition();
for (int i = 0; i < NUM_WATER_CREATURES; i++) { for (int i = 0; i < NUM_WATER_CREATURES; i++) {
switch (aWaterCreatures[i].m_state) { switch (aWaterCreatures[i].m_state) {
case WATER_CREATURE_ALLOCATED: case WATER_CREATURE_ACTIVE:
case WATER_CREATURE_ACTIVE: {
aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000; aWaterCreatures[i].m_pObj->m_nEndOfLifeTime = CTimer::GetTimeInMilliseconds() + 40000;
if (aWaterCreatures[i].m_pObj->GetIsOnScreen()) { 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 ((playerPos - aWaterCreatures[i].m_pObj->GetPosition()).Magnitude() < SQR(75.0f)) {
if (aWaterCreatures[i].m_alpha < 255) if (aWaterCreatures[i].m_alpha < 255)
aWaterCreatures[i].m_alpha = Min(aWaterCreatures[i].m_alpha + 4, 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(); CVector newRight = aWaterCreatures[i].m_pObj->GetRight();
newRight.Normalise(); newRight.Normalise();
aWaterCreatures[i].m_pObj->m_vecMoveSpeed = newRight * aWaterCreatures[i].m_fRightMult; aWaterCreatures[i].m_pObj->m_vecMoveSpeed = newRight * aWaterCreatures[i].m_fRightMult;
@ -202,8 +208,8 @@ void CWaterCreatures::UpdateAll() {
aWaterCreatures[i].m_pObj->bIsStatic = false; aWaterCreatures[i].m_pObj->bIsStatic = false;
float fDepth = 0.0; float fDepth = 0.0;
CWaterLevel::GetWaterDepth(aWaterCreatures[i].m_pObj->GetPosition(), &fDepth, nil, nil); CWaterLevel::GetWaterDepth(aWaterCreatures[i].m_pObj->GetPosition(), &fDepth, nil, nil);
if (fDepth < 0.0f) { if (aWaterCreatures[i].m_fWaterDepth < fDepth) {
if (aWaterCreatures[i].m_pObj->m_nEndOfLifeTime <= CTimer::GetTimeInMilliseconds() + 40000) if (aWaterCreatures[i].m_pObj->m_nEndOfLifeTime - 40000 <= CTimer::GetTimeInMilliseconds())
aWaterCreatures[i].m_state = WATER_CREATURE_ACTIVE; aWaterCreatures[i].m_state = WATER_CREATURE_ACTIVE;
} }
else { else {
@ -214,7 +220,6 @@ void CWaterCreatures::UpdateAll() {
else { else {
aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE; aWaterCreatures[i].m_state = WATER_CREATURE_TO_REMOVE;
} }
}
break; break;
} }
case WATER_CREATURE_UPDATE: { case WATER_CREATURE_UPDATE: {
@ -237,15 +242,14 @@ void CWaterCreatures::UpdateAll() {
} }
break; break;
} }
case WATER_CREATURE_TO_REMOVE: { case WATER_CREATURE_TO_REMOVE:
if (aWaterCreatures[i].m_pObj) if (aWaterCreatures[i].m_pObj)
CWorld::Remove(aWaterCreatures[i].m_pObj); CWorld::Remove(aWaterCreatures[i].m_pObj);
FreeFishStructSlot(&aWaterCreatures[i]); FreeFishStructSlot(&aWaterCreatures[i]);
nNumActiveSeaLifeForms--; nNumActiveSeaLifeForms--;
aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED; aWaterCreatures[i].m_state = WATER_CREATURE_DISABLED;
break; break;
} default:
case WATER_CREATURE_DISABLED:
break; break;
} }
} }

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "Object.h" #include "Object.h"
enum { enum eFishSlotState {
WATER_CREATURE_ALLOCATED = 0, WATER_CREATURE_ALLOCATED = 0,
WATER_CREATURE_ACTIVE, WATER_CREATURE_ACTIVE,
WATER_CREATURE_UPDATE, WATER_CREATURE_UPDATE,
@ -20,9 +20,9 @@ public:
CWaterCreature(); CWaterCreature();
~CWaterCreature(); ~CWaterCreature();
void Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, int eFishSlotState); void Allocate(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
void Free(); void Free();
void Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, int eFishSlotState); void Initialise(CObject *pObj, float fRightMult, float fZTurnSpeed, float fWaterDepth, uint32 alpha, eFishSlotState state);
}; };
class CWaterCreatures { class CWaterCreatures {
@ -30,8 +30,8 @@ class CWaterCreatures {
public: public:
static CWaterCreature aWaterCreatures[NUM_WATER_CREATURES]; static CWaterCreature aWaterCreatures[NUM_WATER_CREATURES];
static int32 nNumActiveSeaLifeForms; static int32 nNumActiveSeaLifeForms;
static CObject *CreateSeaLifeForm(CVector pos, int16 modelID, float zRotAngle); static CObject *CreateSeaLifeForm(CVector const& pos, int16 modelID, int32 zRotAngle);
static void CreateOne(CVector pos, int16 modelID); static void CreateOne(CVector const& pos, int32 modelID);
static void UpdateAll(); static void UpdateAll();
static void FreeFishStructSlot(CWaterCreature *wc); static void FreeFishStructSlot(CWaterCreature *wc);
static bool IsSpaceForMoreWaterCreatures(); static bool IsSpaceForMoreWaterCreatures();
@ -44,6 +44,6 @@ struct WaterCreatureProperties {
int16 *modelID; int16 *modelID;
float fRightMult; float fRightMult;
float fLevel; float fLevel;
float fUnk2; float fUnknown; //unused
float fWaterDepth; float fWaterDepth;
}; };

View file

@ -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, -1);
} }
} }
} }
//TODO(MIAMI) CWaterCreatures::UpdateAll();
//CWaterCreatures::UpdateAll();
} }
void void

View file

@ -22,3 +22,4 @@ void SetAmbientColours(void);
void SetAmbientColoursForPedsCarsAndObjects(void); void SetAmbientColoursForPedsCarsAndObjects(void);
void SetAmbientColoursToIndicateRoadGroup(int i); void SetAmbientColoursToIndicateRoadGroup(int i);
void SetAmbientColours(RwRGBAReal *color); void SetAmbientColours(RwRGBAReal *color);
void SetFullAmbient(void);

View file

@ -1011,8 +1011,9 @@ CHeli::TestSniperCollision(CVector *line0, CVector *line1)
bool hit = false; bool hit = false;
for(i = 0; i < NUM_HELIS; i++){ for(i = 0; i < NUM_HELIS; i++){
if(pHelis[i] && !pHelis[i]->bBulletProof) {
CVector pilotPos = pHelis[i]->GetMatrix() * CVector(-0.43f, 1.49f, 1.5f); CVector pilotPos = pHelis[i]->GetMatrix() * CVector(-0.43f, 1.49f, 1.5f);
if(pHelis[i] && !pHelis[i]->bBulletProof && CCollision::DistToLine(line0, line1, &pilotPos) < 0.8f){ if(CCollision::DistToLine(line0, line1, &pilotPos) < 0.8f){
pHelis[i]->m_fAngularSpeed = CGeneral::GetRandomTrueFalse() ? 0.05f : -0.05f; pHelis[i]->m_fAngularSpeed = CGeneral::GetRandomTrueFalse() ? 0.05f : -0.05f;
pHelis[i]->m_heliStatus = HELI_STATUS_SHOT_DOWN; pHelis[i]->m_heliStatus = HELI_STATUS_SHOT_DOWN;
pHelis[i]->m_nExplosionTimer = CTimer::GetTimeInMilliseconds() + 9999999; pHelis[i]->m_nExplosionTimer = CTimer::GetTimeInMilliseconds() + 9999999;
@ -1021,6 +1022,7 @@ CHeli::TestSniperCollision(CVector *line0, CVector *line1)
hit = true; hit = true;
} }
} }
}
return hit; return hit;
} }