From 1337a9b6034570861a7cadaf5338d0cbb5b06255 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 16 Feb 2020 23:08:54 +0300 Subject: script 1000-1154 --- src/render/SpecialFX.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ src/render/SpecialFX.h | 13 ++++++++- 2 files changed, 86 insertions(+), 1 deletion(-) (limited to 'src/render') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index f1fd3f09..39b22671 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -11,6 +11,9 @@ #include "Lights.h" #include "VisibilityPlugins.h" #include "World.h" +#include "Particle.h" +#include "General.h" +#include "Camera.h" WRAPPER void CSpecialFX::Render(void) { EAXJMP(0x518DC0); } WRAPPER void CSpecialFX::Update(void) { EAXJMP(0x518D40); } @@ -383,6 +386,77 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 aMoneyMessages[nIndex].m_fOpacity = fOpacity; } +void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles) +{ + int attempts = 0; + float outerFw = innerFw + 5.0f; + float outerRg = innerRg + 5.0f; + float outerUp = innerUp + 5.0f; + while (particles > 0 && attempts < 1000) { + CVector pos; + int rnd = CGeneral::GetRandomNumber(); + pos.x = (int8)(rnd - 128) / 110.0f; + pos.y = (int8)((rnd >> 8) - 128) / 110.0f; + pos.z = 0.0f; + if (DotProduct2D(pos, TheCamera.GetForward()) >= 0) + continue; + pos += pMatrix->GetPosition(); + pos.z = 2.0f; + // was there any point in adding it here? + float fw = DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition()); + if (fw >= outerFw) + continue; + float rg = DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition()); + if (rg >= outerRg) + continue; + float up = DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition()); + if (up >= outerUp) + continue; + if (fw > innerFw || rg > innerRg || up > innerUp) { + CParticle::AddParticle(PARTICLE_STEAM2, pos, CVector(0.0f, 0.0f, 0.0f), nil, 4.0f, 1, 0, 0, 0); + particles--; + } + } +} + +void CSpecialParticleStuff::StartBoatFoamAnimation() +{ + BoatFromStart = CTimer::GetTimeInMilliseconds(); +} + +CRGBA FoamColour(255, 255, 255, 255); +unsigned int CSpecialParticleStuff::BoatFromStart; + +void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) +{ + static int32 FrameInAnimation = 0; + static float X, Y, Z, dX, dY, dZ; + CreateFoamAroundObject(pMatrix, 107.0f, 24.1f, 30.5f, 2); + uint32 prev = CTimer::GetPreviousTimeInMilliseconds(); + uint32 cur = CTimer::GetTimeInMilliseconds(); + if (FrameInAnimation != 0) { + X += dX; + Y += dY; + Z += dZ; + CVector pos = *pMatrix * CVector(X, Y, Z); + CParticle::AddParticle(PARTICLE_STEAM_NY, pos, CVector(0.0f, 0.0f, 0.0f), + nil, FrameInAnimation * 0.5f + 2.0f, FoamColour, 1, 0, 0, 0); + if (++FrameInAnimation) + FrameInAnimation = 0; + } + if ((cur & 0x3FF) < (prev & 0x3FF)) { + FrameInAnimation = 1; + int rnd = CGeneral::GetRandomNumber(); + X = (int8)(rnd - 128) * 0.2f; + Y = (int8)((rnd >> 8) - 128) * 0.2f; + Z = 10.0f; + rnd = CGeneral::GetRandomNumber(); + dX = (int8)(rnd - 128) * 0.02f; + dY = (int8)((rnd >> 8) - 128) * 0.02f; + dZ = 2.0f; + } +} + STARTPATCHES InjectHook(0x51B070, &C3dMarker::AddMarker, PATCH_JUMP); InjectHook(0x51B170, &C3dMarker::DeleteMarkerObject, PATCH_JUMP); diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 10b22a77..7b77280b 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -1,5 +1,7 @@ #pragma once +#include "rwplcore.h" + class CSpecialFX { public: @@ -109,4 +111,13 @@ public: static void Init(); static void Render(); static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity); -}; \ No newline at end of file +}; + +class CSpecialParticleStuff +{ + static uint32 BoatFromStart; +public: + static void CreateFoamAroundObject(CMatrix*, float, float, float, int32); + static void StartBoatFoamAnimation(); + static void UpdateBoatFoamAnimation(CMatrix*); +}; -- cgit v1.2.3 From 3481e431c9856f50463ca9aff24da7a51da94eb7 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 22 Feb 2020 15:35:46 +0300 Subject: fixes --- src/render/SpecialFX.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/render') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index 39b22671..e52222a2 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -386,13 +386,15 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 aMoneyMessages[nIndex].m_fOpacity = fOpacity; } +CRGBA FoamColour(255, 255, 255, 255); +unsigned int CSpecialParticleStuff::BoatFromStart; + void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles) { - int attempts = 0; float outerFw = innerFw + 5.0f; float outerRg = innerRg + 5.0f; float outerUp = innerUp + 5.0f; - while (particles > 0 && attempts < 1000) { + for (int attempts = 0; particles > 0 && attempts < 1000; attempts++) { CVector pos; int rnd = CGeneral::GetRandomNumber(); pos.x = (int8)(rnd - 128) / 110.0f; @@ -400,20 +402,20 @@ void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float inner pos.z = 0.0f; if (DotProduct2D(pos, TheCamera.GetForward()) >= 0) continue; + // was there any point in adding it here? pos += pMatrix->GetPosition(); pos.z = 2.0f; - // was there any point in adding it here? - float fw = DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition()); + float fw = Abs(DotProduct(pMatrix->GetForward(), pos - pMatrix->GetPosition())); if (fw >= outerFw) continue; - float rg = DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition()); + float rg = Abs(DotProduct(pMatrix->GetRight(), pos - pMatrix->GetPosition())); if (rg >= outerRg) continue; - float up = DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition()); + float up = Abs(DotProduct(pMatrix->GetUp(), pos - pMatrix->GetPosition())); if (up >= outerUp) continue; if (fw > innerFw || rg > innerRg || up > innerUp) { - CParticle::AddParticle(PARTICLE_STEAM2, pos, CVector(0.0f, 0.0f, 0.0f), nil, 4.0f, 1, 0, 0, 0); + CParticle::AddParticle(PARTICLE_STEAM2, pos, CVector(0.0f, 0.0f, 0.0f), nil, 4.0f, FoamColour, 1, 0, 0, 0); particles--; } } @@ -424,9 +426,6 @@ void CSpecialParticleStuff::StartBoatFoamAnimation() BoatFromStart = CTimer::GetTimeInMilliseconds(); } -CRGBA FoamColour(255, 255, 255, 255); -unsigned int CSpecialParticleStuff::BoatFromStart; - void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) { static int32 FrameInAnimation = 0; @@ -441,7 +440,7 @@ void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) CVector pos = *pMatrix * CVector(X, Y, Z); CParticle::AddParticle(PARTICLE_STEAM_NY, pos, CVector(0.0f, 0.0f, 0.0f), nil, FrameInAnimation * 0.5f + 2.0f, FoamColour, 1, 0, 0, 0); - if (++FrameInAnimation) + if (++FrameInAnimation > 15) FrameInAnimation = 0; } if ((cur & 0x3FF) < (prev & 0x3FF)) { -- cgit v1.2.3 From a122d558a26b41041276ebf6580167d7675b7592 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 22 Feb 2020 15:53:41 +0300 Subject: merge + bug fix --- src/render/SpecialFX.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/render') diff --git a/src/render/SpecialFX.cpp b/src/render/SpecialFX.cpp index e52222a2..76abcd5b 100644 --- a/src/render/SpecialFX.cpp +++ b/src/render/SpecialFX.cpp @@ -389,7 +389,8 @@ CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 CRGBA FoamColour(255, 255, 255, 255); unsigned int CSpecialParticleStuff::BoatFromStart; -void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles) +void +CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float innerFw, float innerRg, float innerUp, int32 particles) { float outerFw = innerFw + 5.0f; float outerRg = innerRg + 5.0f; @@ -397,8 +398,8 @@ void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float inner for (int attempts = 0; particles > 0 && attempts < 1000; attempts++) { CVector pos; int rnd = CGeneral::GetRandomNumber(); - pos.x = (int8)(rnd - 128) / 110.0f; - pos.y = (int8)((rnd >> 8) - 128) / 110.0f; + pos.x = (int8)(rnd - 128) * innerFw / 110.0f; + pos.y = (int8)((rnd >> 8) - 128) * innerFw / 110.0f; pos.z = 0.0f; if (DotProduct2D(pos, TheCamera.GetForward()) >= 0) continue; @@ -421,12 +422,14 @@ void CSpecialParticleStuff::CreateFoamAroundObject(CMatrix* pMatrix, float inner } } -void CSpecialParticleStuff::StartBoatFoamAnimation() +void +CSpecialParticleStuff::StartBoatFoamAnimation() { BoatFromStart = CTimer::GetTimeInMilliseconds(); } -void CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) +void +CSpecialParticleStuff::UpdateBoatFoamAnimation(CMatrix* pMatrix) { static int32 FrameInAnimation = 0; static float X, Y, Z, dX, dY, dZ; -- cgit v1.2.3 From 1366c58d59575a1f5905dc9847503d3987257b54 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sat, 22 Feb 2020 17:19:56 +0300 Subject: removed extra include --- src/render/SpecialFX.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/render') diff --git a/src/render/SpecialFX.h b/src/render/SpecialFX.h index 7b77280b..7c0e3436 100644 --- a/src/render/SpecialFX.h +++ b/src/render/SpecialFX.h @@ -1,7 +1,5 @@ #pragma once -#include "rwplcore.h" - class CSpecialFX { public: -- cgit v1.2.3