From 1284d34f6894da04474dd42e245ce6b0cfbf9abb Mon Sep 17 00:00:00 2001 From: Lwmte Date: Wed, 15 Sep 2021 14:24:03 +0300 Subject: [PATCH] Implement basic flash, fix func names --- TR5Main/Game/effects/weather.cpp | 10 ++++++---- TR5Main/Game/effects/weather.h | 4 ++-- TR5Main/Game/flipeffect.cpp | 12 ++++++++++-- TR5Main/Game/flipeffect.h | 3 ++- TR5Main/Game/items.cpp | 4 ++-- TR5Main/Game/items.h | 4 ++-- TR5Main/Game/traps.cpp | 2 +- TR5Main/Objects/TR4/Object/tr4_obelisk.cpp | 2 +- TR5Main/Objects/TR5/Object/tr5_teleporter.cpp | 2 +- TR5Main/Renderer/Renderer11Draw2D.cpp | 10 ++++++++++ 10 files changed, 37 insertions(+), 16 deletions(-) diff --git a/TR5Main/Game/effects/weather.cpp b/TR5Main/Game/effects/weather.cpp index dc44f7844..ca2fab9ff 100644 --- a/TR5Main/Game/effects/weather.cpp +++ b/TR5Main/Game/effects/weather.cpp @@ -33,17 +33,16 @@ namespace Environment // Clear flash vars FlashProgress = 0.0f; - FlashColorBase = Vector4::Zero; + FlashColorBase = Vector3::Zero; } void EnvironmentController::Flash(int r, int g, int b, float speed) { FlashProgress = 1.0f; FlashSpeed = std::clamp(speed, 0.005f, 1.0f); - FlashColorBase = Vector4(std::clamp(r, 0, UCHAR_MAX) / (float)UCHAR_MAX, + FlashColorBase = Vector3(std::clamp(r, 0, UCHAR_MAX) / (float)UCHAR_MAX, std::clamp(g, 0, UCHAR_MAX) / (float)UCHAR_MAX, - std::clamp(b, 0, UCHAR_MAX) / (float)UCHAR_MAX, - 1.0f); + std::clamp(b, 0, UCHAR_MAX) / (float)UCHAR_MAX); } void EnvironmentController::UpdateSky(GameScriptLevel* level) @@ -163,5 +162,8 @@ namespace Environment if (FlashProgress < 0.0f) FlashProgress = 0.0f; } + + if (FlashProgress == 0.0f) + FlashColorBase = Vector3::Zero; } }}} \ No newline at end of file diff --git a/TR5Main/Game/effects/weather.h b/TR5Main/Game/effects/weather.h index 0e206374e..93cc35b90 100644 --- a/TR5Main/Game/effects/weather.h +++ b/TR5Main/Game/effects/weather.h @@ -10,7 +10,7 @@ namespace Environment { public: Vector3 Wind() { return Vector3(WindFinalX / 2.0f, 0, WindFinalZ / 2.0f); } - Vector4 FlashColor() { return FlashColorBase * sin(FlashProgress * PI / 2.0f); } + Vector3 FlashColor() { return FlashColorBase * sin(FlashProgress * PI / 2.0f); } Vector4 SkyColor() { return SkyCurrentColor; } short SkyLayer1Position() { return SkyPosition1; } short SkyLayer2Position() { return SkyPosition2; } @@ -33,7 +33,7 @@ namespace Environment int WindCurrent; // Flash fader - Vector4 FlashColorBase = {}; + Vector3 FlashColorBase = Vector3::Zero; float FlashSpeed = 1.0f; float FlashProgress = 0.0f; diff --git a/TR5Main/Game/flipeffect.cpp b/TR5Main/Game/flipeffect.cpp index 899927984..c0bb8a38d 100644 --- a/TR5Main/Game/flipeffect.cpp +++ b/TR5Main/Game/flipeffect.cpp @@ -20,12 +20,14 @@ #include "lara_fire.h" #include "effects\effects.h" #include "effects\tomb4fx.h" +#include "effects\weather.h" #include "effects\footprint.h" #include "effects\groundfx.h" #include "effects\debris.h" using std::function; using namespace TEN::Effects::Footprints; +using namespace TEN::Effects::Environment; short FXType; int FlipEffect; @@ -52,7 +54,7 @@ function effect_routines[59] = ShootLeftGun, //17 PushLoop, //18 PushEnd, //19 - VoidEffect, //20 + FlashOrange, //20 InvisibilityOn, //21 InvisibilityOff, //22 VoidEffect, //23 @@ -81,6 +83,12 @@ function effect_routines[59] = KillActiveBaddies //46 }; +void FlashOrange(ITEM_INFO* item) +{ + FlipEffect = -1; + Weather.Flash(255, 128, 0, 0.03f); +} + void MeshSwapToPour(ITEM_INFO* item) { Lara.meshPtrs[LM_LHAND] = Objects[item->itemFlags[2]].meshIndex + LM_LHAND; @@ -363,7 +371,7 @@ void PoseidonSFX(ITEM_INFO* item) void RubbleFX(ITEM_INFO* item) { - const auto itemList = FindItem(ID_EARTHQUAKE); + const auto itemList = FindAllItems(ID_EARTHQUAKE); if (itemList.size() > 0) { diff --git a/TR5Main/Game/flipeffect.h b/TR5Main/Game/flipeffect.h index 4bde68471..b889f8fff 100644 --- a/TR5Main/Game/flipeffect.h +++ b/TR5Main/Game/flipeffect.h @@ -36,4 +36,5 @@ void Puzzle(ITEM_INFO* item); void DrawRightPistol(ITEM_INFO* item); void DrawLeftPistol(ITEM_INFO* item); void MeshSwapToPour(ITEM_INFO* item); -void MeshSwapFromPour(ITEM_INFO* item); \ No newline at end of file +void MeshSwapFromPour(ITEM_INFO* item); +void FlashOrange(ITEM_INFO* item); \ No newline at end of file diff --git a/TR5Main/Game/items.cpp b/TR5Main/Game/items.cpp index 3f925845a..8c1b43b40 100644 --- a/TR5Main/Game/items.cpp +++ b/TR5Main/Game/items.cpp @@ -488,7 +488,7 @@ int GlobalItemReplace(short search, GAME_OBJECT_ID replace) return changed; } -std::vector FindItem(short objectNumber) +std::vector FindAllItems(short objectNumber) { std::vector itemList; @@ -501,7 +501,7 @@ std::vector FindItem(short objectNumber) return itemList; } -ITEM_INFO* find_a_fucking_item(int object_number) +ITEM_INFO* FindItem(int object_number) { ITEM_INFO* item; diff --git a/TR5Main/Game/items.h b/TR5Main/Game/items.h index 09bc594c9..cc9399038 100644 --- a/TR5Main/Game/items.h +++ b/TR5Main/Game/items.h @@ -60,5 +60,5 @@ void KillEffect(short fxNumber); void InitialiseItem(short itemNum); void InitialiseItemArray(int numItems); void KillItem(short itemNum); -std::vector FindItem(short objectNumber); -ITEM_INFO* find_a_fucking_item(int object_number); +std::vector FindAllItems(short objectNumber); +ITEM_INFO* FindItem(int object_number); diff --git a/TR5Main/Game/traps.cpp b/TR5Main/Game/traps.cpp index 02ebb90f8..bca21d6e2 100644 --- a/TR5Main/Game/traps.cpp +++ b/TR5Main/Game/traps.cpp @@ -477,7 +477,7 @@ void InitialiseWreckingBall(short itemNumber) short room; item = &g_Level.Items[itemNumber]; - item->itemFlags[3] = FindItem(ID_ANIMATING16)[0]; + item->itemFlags[3] = FindAllItems(ID_ANIMATING16)[0]; room = item->roomNumber; item->pos.yPos = GetCeiling(GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &room), item->pos.xPos, item->pos.yPos, item->pos.zPos) + 1644; GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &room); diff --git a/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp b/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp index e579bfe9f..eaaf13807 100644 --- a/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp +++ b/TR5Main/Objects/TR4/Object/tr4_obelisk.cpp @@ -135,7 +135,7 @@ void ObeliskControl(short itemNumber) TriggerExplosionSparks(pos.xPos, pos.yPos, pos.zPos, 3, -1, 0, item2->roomNumber); item->itemFlags[2] = NO_ITEM; - item2 = find_a_fucking_item(ID_PUZZLE_ITEM1_COMBO1); + item2 = FindItem(ID_PUZZLE_ITEM1_COMBO1); item2->status = ITEM_NOT_ACTIVE; SoundEffect(SFX_TR4_EXPLOSION1, &item2->pos, 0); diff --git a/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp b/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp index 5563117a2..ecb959634 100644 --- a/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp +++ b/TR5Main/Objects/TR5/Object/tr5_teleporter.cpp @@ -17,7 +17,7 @@ void InitialiseTeleporter(short itemNumber) if (item->triggerFlags == 512) { - ITEM_INFO* puzzleHoleItem = find_a_fucking_item(ID_PUZZLE_HOLE2); + ITEM_INFO* puzzleHoleItem = FindItem(ID_PUZZLE_HOLE2); v4 = (signed int)((unsigned __int64)(391146079i64 * ((char*)v3 - (char*)items)) >> 32) >> 9; result = (unsigned int)((unsigned __int64)(391146079i64 * ((char*)v3 - (char*)items)) >> 32) >> 31; item->itemFlags[1] = result + v4; diff --git a/TR5Main/Renderer/Renderer11Draw2D.cpp b/TR5Main/Renderer/Renderer11Draw2D.cpp index 2879cfec8..57a077ae3 100644 --- a/TR5Main/Renderer/Renderer11Draw2D.cpp +++ b/TR5Main/Renderer/Renderer11Draw2D.cpp @@ -4,6 +4,9 @@ #include "spotcam.h" #include "lara.h" #include "control.h" +#include "effects\weather.h" + +using namespace TEN::Effects::Environment; TEN::Renderer::RendererHUDBar* g_HealthBar; TEN::Renderer::RendererHUDBar* g_AirBar; @@ -126,6 +129,13 @@ namespace TEN::Renderer { void Renderer11::drawOverlays(RenderView& view) { + auto flashColor = Weather.FlashColor(); + if (flashColor != Vector3::Zero) + { + m_context->OMSetBlendState(m_states->Additive(), NULL, 0xFFFFFFFF); + drawFullScreenQuad(m_whiteTexture.ShaderResourceView.Get(), flashColor, false); + } + if (CurrentLevel == 0) return;