Revert "Minor Fixes to flare smoke"

This commit is contained in:
Gancian 2020-05-23 18:00:51 +02:00 committed by GitHub
parent 2b707d352b
commit db5dbb2dbd
5 changed files with 6 additions and 269 deletions

View file

@ -1,233 +0,0 @@
#include "chaffFX.h"
#include "bubble.h"
#include "tomb4fx.h"
#include "control.h"
#include "lara.h"
#include "draw.h"
#include "../Specific/level.h"
#define MAX_TRIGGER_RANGE 0x4000
void TriggerChaffEffects()
{
PHD_VECTOR vect;
vect.x = 8;
vect.y = 36;
vect.z = 32;
GetLaraJointPosition(&vect, LM_LHAND);
PHD_VECTOR pos;
pos.x = vect.x;
pos.y = vect.y;
pos.z = vect.z;
vect.x = 8;
vect.y = 36;
vect.z = 1024 + (GetRandomDraw() & 255);
GetLaraJointPosition(&vect, LM_LHAND);
PHD_VECTOR vel;
vel.x = vect.x - pos.x;
vel.y = vect.y - pos.y;
vel.z = vect.z - pos.z;
TriggerChaffEffects(LaraItem, &pos, &vel, LaraItem->speed, (bool)(Rooms[LaraItem->roomNumber].flags & ENV_FLAG_WATER));
}
void TriggerChaffEffects(ITEM_INFO* Item)
{
Matrix world
= Matrix::CreateTranslation(-6, 6, 32)
* Matrix::CreateFromYawPitchRoll(TO_RAD(Item->pos.yRot), TO_RAD(Item->pos.xRot), TO_RAD(Item->pos.zRot));
PHD_VECTOR pos;
pos.x = Item->pos.xPos + world.Translation().x;
pos.y = Item->pos.yPos + world.Translation().y;
pos.z = Item->pos.zPos + world.Translation().z;
world
= Matrix::CreateTranslation(-6, 6, 32)
* Matrix::CreateTranslation((GetRandomDraw() & 127) - 64, (GetRandomDraw() & 127) - 64, (GetRandomDraw() & 511) + 512)
* Matrix::CreateFromYawPitchRoll(TO_RAD(Item->pos.yRot), TO_RAD(Item->pos.xRot), TO_RAD(Item->pos.zRot));
PHD_VECTOR vel;
vel.x = world.Translation().x;
vel.y = world.Translation().y;
vel.z = world.Translation().z;
TriggerChaffEffects(Item, &pos, &vel, Item->speed, (bool)(Rooms[Item->roomNumber].flags & ENV_FLAG_WATER));
}
void TriggerChaffEffects(ITEM_INFO* item, PHD_VECTOR* pos, PHD_VECTOR* vel, int speed, bool isUnderwater)
{
int numSparks = (int)frandMinMax(2, 5);
for (int i = 0; i < numSparks; i++)
{
long dx, dz;
dx = item->pos.xPos - pos->x;
dz = item->pos.zPos - pos->z;
if (dx < -MAX_TRIGGER_RANGE || dx > MAX_TRIGGER_RANGE || dz < -MAX_TRIGGER_RANGE || dz > MAX_TRIGGER_RANGE)
return;
CVECTOR color;
color.r = 255;
color.g = (GetRandomDraw() & 127) + 64;
color.b = 192 - color.g;
TriggerChaffSparkles(pos, vel, &color);
if (isUnderwater)
{
TriggerChaffBubbles(pos, item->roomNumber);
}
else
{
if (speed > 32)
TriggerChaffSmoke(pos, vel, 64 - speed, TRUE, (bool)(Rooms[item->roomNumber].flags & ENV_FLAG_WIND));
else
{
if (GetRandomControl() & 3)
speed = 0;
else
speed = ((GetRandomControl() & 0xF) + (GetRandomControl() & 0x10)) << 6;
TriggerChaffSmoke(pos, vel, speed, FALSE, (bool)(Rooms[item->roomNumber].flags & ENV_FLAG_WIND));
}
}
}
}
void TriggerChaffSparkles (PHD_VECTOR* pos, PHD_VECTOR* vel, CVECTOR* color)
{
SPARKS* sparkle;
sparkle = &Sparks[GetFreeSpark()];
sparkle->on = true;
sparkle->sR = 255;
sparkle->sG = 255;
sparkle->sB = 255;
sparkle->dR = color->r;
sparkle->dG = color->g;
sparkle->dB = color->b;
sparkle->colFadeSpeed = 3;
sparkle->fadeToBlack = 5;
sparkle->sLife = sparkle->life = 10;
sparkle->transType = COLADD;
sparkle->dynamic = true;
sparkle->x = pos->x + (GetRandomDraw() & 7) - 3;
sparkle->y = pos->y + (GetRandomDraw() & 7) - 3;
sparkle->z = pos->z + (GetRandomDraw() & 7) - 3;
sparkle->xVel = vel->x + ((GetRandomDraw() & 255) - 128);
sparkle->yVel = vel->y + ((GetRandomDraw() & 255) - 128);
sparkle->zVel = vel->z + ((GetRandomDraw() & 255) - 128);
sparkle->friction = 2 | (2 << 4);
sparkle->scalar = 1;
sparkle->size = sparkle->sSize = (GetRandomDraw() & 3) + 4;
sparkle->dSize = (GetRandomDraw() & 1) + 1;
sparkle->gravity = sparkle->maxYvel = 0;
sparkle->flags = SP_SCALE;
}
void TriggerChaffSmoke(PHD_VECTOR* pos, PHD_VECTOR* vel, int speed, bool moving, bool wind)
{
SMOKE_SPARKS* smoke;
int rnd = 0;
BYTE trans, size;
smoke = &SmokeSparks[GetFreeSmokeSpark()];
smoke->on = true;
smoke->sShade = 0;
if (moving)
{
trans = (speed << 7) >> 5;
smoke->dShade = trans;
}
else
smoke->dShade = 64 + (GetRandomDraw() & 7);
smoke->colFadeSpeed = 4 + (GetRandomDraw() & 3);
smoke->fadeToBlack = 4;
rnd = (GetRandomControl() & 3) - (speed >> 12) + 20;
if (rnd < 9)
{
smoke->life = 9;
smoke->sLife = 9;
}
else
{
smoke->life = rnd;
smoke->sLife = rnd;
}
smoke->transType = COLADD;
smoke->x = pos->x + (GetRandomControl() & 7) - 3;
smoke->y = pos->y + (GetRandomControl() & 7) - 3;
smoke->z = pos->z + (GetRandomControl() & 7) - 3;
smoke->xVel = vel->x + ((GetRandomDraw() & 63) - 32);
smoke->yVel = vel->y;
smoke->zVel = vel->z + ((GetRandomDraw() & 63) - 32);
smoke->friction = 4;
if (GetRandomControl() & 1)
{
smoke->flags = SP_EXPDEF | SP_ROTATE | SP_DEF | SP_SCALE;
smoke->rotAng = (GetRandomControl() & 0xFFF);
if (GetRandomControl() & 1)
smoke->rotAdd = (GetRandomControl() & 7) - 24;
else
smoke->rotAdd = (GetRandomControl() & 7) + 24;
}
else
{
smoke->flags = SP_EXPDEF | SP_DEF | SP_SCALE;
}
if (wind)
smoke->flags |= SP_WIND;
smoke->scalar = 1;
smoke->gravity = (GetRandomControl() & 3) - 4;
smoke->maxYvel = 0;
size = (GetRandomControl() & 7) + (speed >> 7) + 32;
smoke->sSize = size >> 2;
smoke->size = smoke->dSize = size;
}
void TriggerChaffBubbles(PHD_VECTOR* pos, int FlareRoomNumber)
{
BUBBLE_STRUCT* bubble;
bubble = &Bubbles[GetFreeBubble()];
bubble->active = true;
bubble->size = 0;
bubble->age = 0;
bubble->speed = frandMinMax(16, 32);
bubble->sourceColor = Vector4(0, 0, 0, 0);
float shade = frandMinMax(0.3, 0.8);
bubble->destinationColor = Vector4(shade, shade, shade, 0.8);
bubble->color = bubble->sourceColor;
bubble->destinationSize = frandMinMax(128, 256);
bubble->spriteNum = SPR_UNKNOWN1;
bubble->rotation = frandMinMax(-1, 1) * PI;
bubble->worldPosition = Vector3(pos->x, pos->y, pos->z);
float maxAmplitude = 32;
bubble->amplitude = Vector3(frandMinMax(-maxAmplitude, maxAmplitude), frandMinMax(-maxAmplitude, maxAmplitude), frandMinMax(-maxAmplitude, maxAmplitude));
bubble->worldPositionCenter = bubble->worldPosition;
bubble->wavePeriod = Vector3::Zero;
bubble->waveSpeed = Vector3(1 / frandMinMax(8, 16), 1 / frandMinMax(8, 16), 1 / frandMinMax(8, 16));
bubble->roomNumber = FlareRoomNumber;
}

View file

@ -1,19 +0,0 @@
#pragma once
#include "../Global/global.h"
void TriggerChaffEffects();
void TriggerChaffEffects(ITEM_INFO* Item);
void TriggerChaffEffects(ITEM_INFO* Item, PHD_VECTOR* pos, PHD_VECTOR* vel, int speed, bool isUnderwater);
void TriggerChaffSparkles(PHD_VECTOR* pos, PHD_VECTOR* vel, CVECTOR* color);
void TriggerChaffSmoke(PHD_VECTOR* pos, PHD_VECTOR* vel, int speed, bool moving, bool wind);
void TriggerChaffBubbles(PHD_VECTOR* pos, int FlareRoomNumber);
/* void TriggerChaffEffects(ITEM_INFO* item, PHD_3DPOS pos, short angle, int speed, bool underwater);
void TriggerChaffSparkles(PHD_3DPOS pos, short angle, int speed);
void TriggerChaffSmoke(PHD_3DPOS pos, short angle, int speed, bool moving);
void TriggerChaffBubbles(PHD_3DPOS pos, int FlareRoomNumber); */

View file

@ -12,7 +12,6 @@
#include "Lara.h"
#include "collide.h"
#include "effect2.h"
#include "chaffFX.h"
void FlareControl(short itemNumber) // (AF) (D)
{
@ -53,11 +52,11 @@ void FlareControl(short itemNumber) // (AF) (D)
}
else
item->fallspeed += 6;
item->pos.yPos += item->fallspeed;
DoProperDetection(itemNumber, oldX, oldY, oldZ, xv, item->fallspeed, zv);
short age = (short)(item->data) & 0x7FFF;
if (age >= 900)
{
@ -71,10 +70,9 @@ void FlareControl(short itemNumber) // (AF) (D)
{
age++;
}
if (DoFlareLight((PHD_VECTOR*)&item->pos, age))
{
TriggerChaffEffects(item);
/* Hardcoded code */
age |= 0x8000;
@ -344,7 +342,7 @@ void CreateFlare(short objectNum, int thrown) // (F) (D)
item->pos.zRot = 0;
item->pos.xRot = 0;
item->shade = -1;
if (thrown)
{
item->speed = LaraItem->speed + 50;
@ -355,7 +353,7 @@ void CreateFlare(short objectNum, int thrown) // (F) (D)
item->speed = LaraItem->speed + 10;
item->fallspeed = LaraItem->fallspeed + 50;
}
if (flag)
item->speed >>= 1;
@ -385,8 +383,7 @@ void DoFlareInHand(int flare_age) // (AF) (D)
pos.z = 41;
GetLaraJointPosition(&pos, LM_LHAND);
if (DoFlareLight(&pos, flare_age))
TriggerChaffEffects();
DoFlareLight(&pos, flare_age);
/* Hardcoded code */

View file

@ -124,7 +124,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="Game\bubble.h" />
<ClInclude Include="Game\chaffFX.h" />
<ClInclude Include="Game\footprint.h" />
<ClInclude Include="Game\groundfx.h" />
<ClInclude Include="Libs\fixedpoint\fixed_point.hpp" />
@ -224,7 +223,6 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Game\bubble.cpp" />
<ClCompile Include="Game\chaffFX.cpp" />
<ClCompile Include="Game\footprint.cpp" />
<ClCompile Include="Game\misc.cpp" />
<ClCompile Include="Global\math.cpp" />

View file

@ -306,9 +306,6 @@
<ClInclude Include="Specific\level.h">
<Filter>File di intestazione</Filter>
</ClInclude>
<ClInclude Include="Game\chaffFX.h">
<Filter>File di intestazione</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TR5Main.cpp">
@ -821,9 +818,6 @@
<ClCompile Include="Objects\TR4\tr4_ahmet.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Game\chaffFX.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Shaders\Shader.fx" />