Merge branch 'master' into mesh_mutator

This commit is contained in:
Lwmte 2021-09-24 13:53:39 +03:00
commit 30bad7ce73
43 changed files with 2451 additions and 3559 deletions

View file

@ -26,7 +26,9 @@
#include "Sound\sound.h"
#include "effects\bubble.h"
#include "generic_switch.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Entities::Switches;
using namespace TEN::Effects::Environment;

View file

@ -46,6 +46,7 @@
#include "Lara/lara_one_gun.h"
#include "generic_switch.h"
#include "Scripting/GameFlowScript.h"
#include <Game/effects/lightning.h>
using std::vector;
using std::unordered_map;
@ -410,8 +411,7 @@ GAME_STATUS ControlPhase(int numFrames, int demoMode)
UpdateGunShells();
UpdateFootprints();
UpdateSplashes();
UpdateEnergyArcs();
UpdateLightning();
TEN::Effects::Lightning::UpdateLightning();
UpdateDrips();
UpdateRats();
UpdateBats();

View file

@ -15,7 +15,9 @@
#include "lara.h"
#include "Lara\lara_climb.h"
#include "Objects\Generic\Switches\generic_switch.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Entities::Switches;
int TriggerTimer;

View file

@ -18,7 +18,9 @@
#include "smoke.h"
#include "Specific\prng.h"
#include "Renderer11.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using TEN::Renderer::g_Renderer;
using TEN::Effects::Explosion::TriggerExplosion;
using namespace TEN::Effects::Spark;
@ -1197,81 +1199,6 @@ void TriggerWaterfallMist(int x, int y, int z, int angle)
spark->dSize = spark->size * 2;
}
void TriggerDartSmoke(int x, int y, int z, int xv, int zv, int hit)
{
int dx = LaraItem->pos.xPos - x;
int dz = LaraItem->pos.zPos - z;
if (dx < -16384 || dx > 16384 || dz < -16384 || dz > 16384)
return;
SPARKS* spark = &Sparks[GetFreeSpark()];
spark->on = 1;
spark->sR = 16;
spark->sG = 8;
spark->sB = 4;
spark->dR = 64;
spark->dG = 48;
spark->dB = 32;
spark->colFadeSpeed = 8;
spark->fadeToBlack = 4;
spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 32;
spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16;
spark->z = (GetRandomControl() & 0x1F) + z - 16;
if (hit)
{
spark->xVel = GetRandomControl() - xv - 128;
spark->yVel = -4 - (GetRandomControl() & 3);
spark->zVel = GetRandomControl() - zv - 128;
}
else
{
if (xv)
spark->xVel = -xv;
else
spark->xVel = GetRandomControl() - 128;
spark->yVel = -4 - (GetRandomControl() & 3);
if (!zv)
{
spark->zVel = GetRandomControl();
}
else
spark->zVel = -zv;
}
spark->friction = 3;
if (GetRandomControl() & 1)
{
spark->flags = 538;
spark->rotAng = GetRandomControl() & 0xFFF;
if (GetRandomControl() & 1)
spark->rotAdd = -16 - (GetRandomControl() & 0xF);
else
spark->rotAdd = (GetRandomControl() & 0xF) + 16;
}
else
{
spark->flags = 522;
}
spark->scalar = 1;
int size = (GetRandomControl() & 0x3F) + 72;
if (hit)
{
spark->maxYvel = 0;
spark->sSize = spark->size = spark->dSize = size >> 3;
spark->gravity = 0;
}
else
{
spark->sSize = spark->size = size >> 4;
spark->gravity = -4 - (GetRandomControl() & 3);
spark->dSize = size;
spark->maxYvel = -4 - (GetRandomControl() & 3);
}
}
void KillAllCurrentItems(short itemNumber)
{
// TODO: Reimplement this functionality

View file

@ -217,7 +217,6 @@ void DoLotsOfBlood(int x, int y, int z, int speed, short direction, short roomNu
void TriggerUnderwaterBlood(int x, int y, int z, int sizeme);
void ControlWaterfallMist(short itemNumber);
void TriggerWaterfallMist(int x, int y, int z, int angle);
void TriggerDartSmoke(int x, int y, int z, int xv, int zv, int hit);
void KillAllCurrentItems(short itemNumber);
void TriggerDynamicLight(int x, int y, int z, short falloff, byte r, byte g, byte b);
void TriggerRocketFlame(int x, int y, int z, int xv, int yv, int zv, int itemNumber);

View file

@ -9,8 +9,9 @@
#include "setup.h"
#include "input.h"
#include "Sound/sound.h"
#include "Objects/Effects/flame_emitters.h"
extern OBJECT_COLLISION_BOUNDS FireBounds;
using namespace TEN::Entities::Effects;
void TriggerTorchFlame(char fxObj, char node)
{

View file

@ -0,0 +1,43 @@
#include "framework.h"
#include "Game/Lara/lara.h"
#include "Game/effects/effects.h"
#include "Game/floordata.h"
#include "Game/effects/lara_burn.h"
#include "Game/items.h"
#include "Game/control/control.h"
namespace TEN::Effects::Fire
{
void LaraBurn()
{
if (!Lara.burn && !Lara.burnSmoke)
{
short fxNum = CreateNewEffect(LaraItem->roomNumber);
if (fxNum != NO_ITEM)
{
EffectList[fxNum].objectNumber = ID_FLAME;
Lara.burn = true;
}
}
}
void LavaBurn(ITEM_INFO* item)
{
if (item->hitPoints >= 0 && Lara.waterStatus != LW_FLYCHEAT)
{
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, 32000, item->pos.zPos, &roomNumber);
if (item->floor == GetFloorHeight(floor, item->pos.xPos, 32000, item->pos.zPos))
{
// if (Objects[ID_KAYAK].loaded && Objects[ID_KAYAK_LARA_ANIMS].loaded) //TEMPORARILY ADDING THIS HACK FOR TESTING-// KayakLaraRapidsDrown works fine.
// KayakLaraRapidsDrown();
// else
// {
item->hitPoints = -1;
item->hitStatus = true;
LaraBurn();
// }
}
}
}
}

View file

@ -0,0 +1,9 @@
#pragma once
struct ITEM_INFO;
namespace TEN::Effects::Fire
{
void LaraBurn();
void LavaBurn(ITEM_INFO* item);
}

View file

@ -15,359 +15,398 @@
#include "Renderer11.h"
#include "effects.h"
#include "animation.h"
#include "lightning.h"
using std::vector;
using TEN::Renderer::g_Renderer;
int LightningRandomSeed = 0x0D371F947;
float FloatSinCosTable[8192];
PHD_VECTOR LightningPos[6];
short LightningBuffer[1024];
void InitialiseFloatSinCosTable()
namespace TEN::Effects::Lightning
{
for (int i = 0; i < 8192; i++)
{
FloatSinCosTable[i] = sin(i * 0.000095873802f);
}
}
constexpr auto MAX_ENERGYARCS = 32;
int LightningRandomSeed = 0x0D371F947;
float FloatSinCosTable[8192];
PHD_VECTOR LightningPos[6];
short LightningBuffer[1024];
std::vector<LIGHTNING_INFO> Lightning;
void UpdateLightning()
{
for (int i = 0; i < 16; i++)
void InitialiseFloatSinCosTable()
{
ENERGY_ARC* arc = &EnergyArcs[i];
if (arc->life > 0)
for (int i = 0; i < 8192; i++)
{
arc->life -= 2;
FloatSinCosTable[i] = sin(i * 0.000095873802f);
}
}
void UpdateLightning()
{
for (int i = 0; i < Lightning.size(); i++)
{
LIGHTNING_INFO* arc = &Lightning[i];
if (arc->life > 0)
{
arc->life -= 2;
if (arc->life)
{
int* positions = (int*)&arc->pos2;
for (int j = 0; j < 9; j++)
{
*positions += 2 * arc->interpolation[j];
arc->interpolation[j] = (signed char)(arc->interpolation[j] - (arc->interpolation[j] >> 4));
positions++;
}
}
}
}
if (Lightning.size() > 0)
{
Lightning.erase(
std::remove_if(Lightning.begin(), Lightning.end(),
[](const LIGHTNING_INFO& o) { return o.life == 0; }),
Lightning.end());
}
}
void TriggerLightning(PHD_VECTOR* src, PHD_VECTOR* dest, char amplitude, byte r, byte g, byte b, byte life, char flags, char width, char segments)
{
LIGHTNING_INFO arc;
arc.pos1 = *src;
arc.pos2.x = (dest->x + 3 * src->x) >> 2;
arc.pos2.y = (dest->y + 3 * src->y) >> 2;
arc.pos2.z = (dest->z + 3 * src->z) >> 2;
arc.pos3.x = (src->x + 3 * dest->x) >> 2;
arc.pos3.y = (src->y + 3 * dest->y) >> 2;
arc.pos3.z = (src->z + 3 * dest->z) >> 2;
arc.pos4 = *dest;
for (int i = 0; i < 9; i++)
{
if (arc.flags & 2 || i < 6)
arc.interpolation[i] = ((byte)(GetRandomControl() % amplitude) - (byte)(amplitude >> 1));
else
arc.interpolation[i] = 0;
}
arc.flags = flags;
arc.r = r;
arc.g = g;
arc.b = b;
arc.life = life;
arc.segments = segments;
arc.amplitude = amplitude;
arc.width = width;
Lightning.push_back(arc);
}
// New function used in TR5, we'll decompile it in the future
void DrawLightningNew()
{
/*Vector4 positions[32];
Vector3 transformed[32];
short clipBuffer[32];
byte r, g, b;
ENERGY_ARC_VBUFFER vbuffer[32];
for (int i = 0; i < 16; i++)
{
ENERGY_ARC* arc = &EnergyArcs[i];
if (arc->life)
{
int* positions = (int*)&arc->pos2;
for (int j = 0; j < 9; j++)
float dx = arc->pos0.x - LaraItem->pos.xPos;
float dy = arc->pos0.y - LaraItem->pos.yPos;
float dz = arc->pos0.z - LaraItem->pos.zPos;
float x1 = arc->pos1.x - arc->pos0.x;
float y1 = arc->pos1.y - arc->pos0.y;
float z1 = arc->pos1.z - arc->pos0.z;
float x2 = arc->pos2.x - arc->pos0.x;
float y2 = arc->pos2.y - arc->pos0.y;
float z2 = arc->pos2.z - arc->pos0.z;
float x3 = arc->pos3.x - arc->pos0.x;
float y3 = arc->pos3.y - arc->pos0.y;
float z3 = arc->pos3.z - arc->pos0.z;
double factor = 0;
int seed = LightningRandomSeed;
for (int j = 0; j < 32; j++)
{
*positions += 2 * arc->interpolation[j];
arc->interpolation[j] = (signed char)(arc->interpolation[j] - (arc->interpolation[j] >> 4));
positions++;
}
}
}
}
}
float rx = 0;
float ry = 0;
float rz = 0;
void TriggerLightning(PHD_VECTOR* src, PHD_VECTOR* dest, char amplitude, byte r, byte g, byte b, byte life, char flags, char width, char segments)
{
ENERGY_ARC* arc = NULL;
for (int i = 0; i < 16; i++)
{
if (EnergyArcs[i].life == 0)
{
arc = &EnergyArcs[i];
break;
}
}
if (j > 0 && j < 31)
{
// random number generator
int rndX = 1103515245 * seed + 12345;
int rndY = 1103515245 * rndX + 12345;
int rndZ = 1103515245 * rndY + 12345;
if (arc == NULL)
return;
float rx = (float)(((rndX >> 10) & 0xF) - 8);
float ry = (float)(((rndY >> 10) & 0xF) - 8);
float rz = (float)(((rndZ >> 10) & 0xF) - 8);
arc->pos1 = *src;
arc->pos2.x = (dest->x + 3 * src->x) >> 2;
arc->pos2.y = (dest->y + 3 * src->y) >> 2;
arc->pos2.z = (dest->z + 3 * src->z) >> 2;
arc->pos3.x = (src->x + 3 * dest->x) >> 2;
arc->pos3.y = (src->y + 3 * dest->y) >> 2;
arc->pos3.z = (src->z + 3 * dest->z) >> 2;
arc->pos4 = *dest;
LightningRandomSeed = rndZ;
}
for (int i = 0; i < 9; i++)
{
if (arc->flags & 2 || i < 6)
arc->interpolation[i] = ((byte)(GetRandomControl() % amplitude) - (byte)(amplitude >> 1));
else
arc->interpolation[i] = 0;
}
float x = (1.0 - factor) * SQUARE(factor) * 4.0;
float y = (2 * factor - 1.0) * SQUARE(factor);
float z = SQUARE(1.0 - factor) * factor * 4.0;
arc->flags = flags;
arc->r = r;
arc->g = g;
arc->b = b;
arc->life = life;
arc->segments = segments;
arc->amplitude = amplitude;
arc->width = width;
}
positions[j].x = x * x1 + y * x2 + z * x3 + 0.0 + rx + dx;
positions[j].y = x * y1 + y * y2 + z * y3 + 0.0 + ry + dy;
positions[j].z = x * z1 + y * z2 + z * z3 + 0.0 + rz + dz;
positions[j].w = 1.0;
void DrawLightningNew()
{
/*Vector4 positions[32];
Vector3 transformed[32];
short clipBuffer[32];
byte r, g, b;
ENERGY_ARC_VBUFFER vbuffer[32];
for (int i = 0; i < 16; i++)
{
ENERGY_ARC* arc = &EnergyArcs[i];
if (arc->life)
{
float dx = arc->pos0.x - LaraItem->pos.xPos;
float dy = arc->pos0.y - LaraItem->pos.yPos;
float dz = arc->pos0.z - LaraItem->pos.zPos;
float x1 = arc->pos1.x - arc->pos0.x;
float y1 = arc->pos1.y - arc->pos0.y;
float z1 = arc->pos1.z - arc->pos0.z;
float x2 = arc->pos2.x - arc->pos0.x;
float y2 = arc->pos2.y - arc->pos0.y;
float z2 = arc->pos2.z - arc->pos0.z;
float x3 = arc->pos3.x - arc->pos0.x;
float y3 = arc->pos3.y - arc->pos0.y;
float z3 = arc->pos3.z - arc->pos0.z;
double factor = 0;
int seed = LightningRandomSeed;
for (int j = 0; j < 32; j++)
{
float rx = 0;
float ry = 0;
float rz = 0;
if (j > 0 && j < 31)
{
// random number generator
int rndX = 1103515245 * seed + 12345;
int rndY = 1103515245 * rndX + 12345;
int rndZ = 1103515245 * rndY + 12345;
float rx = (float)(((rndX >> 10) & 0xF) - 8);
float ry = (float)(((rndY >> 10) & 0xF) - 8);
float rz = (float)(((rndZ >> 10) & 0xF) - 8);
LightningRandomSeed = rndZ;
factor += 0.03125f;
}
float x = (1.0 - factor) * SQUARE(factor) * 4.0;
float y = (2 * factor - 1.0) * SQUARE(factor);
float z = SQUARE(1.0 - factor) * factor * 4.0;
LightningRandomSeed = seed;
positions[j].x = x * x1 + y * x2 + z * x3 + 0.0 + rx + dx;
positions[j].y = x * y1 + y * y2 + z * y3 + 0.0 + ry + dy;
positions[j].z = x * z1 + y * z2 + z * z3 + 0.0 + rz + dz;
positions[j].w = 1.0;
factor += 0.03125f;
}
LightningRandomSeed = seed;
for (int j = 0; j < 32; j++)
{
Vector3 transformed = Vector4::Transform()
pPosY = *(pPosZ - 1);
pPosX = *(pPosZ - 2);
pPosY2 = pPosY;
v36 = transform_view._21 * pPosY;
v37 = 0;
tx = transform_view._31 * *pPosZ + v36 + transform_view._11 * pPosX + transform_view._41;
ty = transform_view._22 * pPosY2 + transform_view._12 * pPosX + transform_view._32 * *pPosZ + transform_view._42;
c_sz = transform_view._33 * *pPosZ
+ transform_view._23 * pPosY2
+ transform_view._13 * pPosX
+ transform_view._43;
if (c_sz < znear)
v37 = -128;
t_persp = f_persp / c_sz;
c_sx = t_persp * tx + f_centerx;
*(D3DTLVERTEX_cy - 1) = c_sx;
*D3DTLVERTEX_cy = t_persp * ty + f_centery;
D3DTLVERTEX_cy[1] = t_persp * f_oneopersp;
if (c_sx >= winX)
for (int j = 0; j < 32; j++)
{
if ((double)phd_winxmax < *(D3DTLVERTEX_cy - 1))
v37 += 2;
}
else
{
++v37;
}
if (*D3DTLVERTEX_cy >= winY)
{
if ((double)phd_winymax < *D3DTLVERTEX_cy)
v37 += 8;
}
else
{
v37 += 4;
}
D3DTLVERTEX_cy[2] = c_sz;
*(_WORD*)someFlag = v37;
D3DTLVERTEX_cy[3] = tx;
D3DTLVERTEX_cy[4] = ty;
someFlag += 2;
pPosZ += 4;
D3DTLVERTEX_cy += 8;
--v32;
}
}
if (arc->life >= 16)
{
r = arc->r;
g = arc->g;
b = arc->b;
}
else
{
r = arc->r >> 4;
g = arc->g >> 4;
b = arc->b >> 4;
}
float length = 0.0;
float width = (float)(arc->width >> 1);
if (arc->flags & 8)
{
length = width * 0.125;
width = 0.0;
}
else if (arc->flags & 4)
{
length = -(width * 0.03125);
}
for (int j = 0; j < 32; j++)
{
short angle = -phd_atan(vbuffer);
float sinAngle = FloatSinCosTable[angle + 0x4000];
width = max(width, 0);
}
v45 = 0;
v46 = (float*)&v125;
do
{
v47 = -j_phd_atan((signed __int64)(v46[7] - *(v46 - 1)), (signed __int64)(v46[8] - *v46));
v48 = FloatSinCosTable[(unsigned __int16)(v47 + 0x4000)];
v49 = v88;
if (v88 <= 0.0)
v49 = 2.0;
v50 = flt_51D15C / v46[2] * v49;
v51 = (*v42 & 8) == 0;
*v86 = FloatSinCosTable[(unsigned __int16)v47] * v50;
v86[1] = v48 * v50;
v88 = v95 + v88;
if (!v51 && v45 == 8)
{
if (*v42 & 4)
v95 = (double)(unsigned __int8)(*(_BYTE*)(arc + 53) >> 1) * -0.035714287;
Vector3 transformed = Vector4::Transform()
pPosY = *(pPosZ - 1);
pPosX = *(pPosZ - 2);
pPosY2 = pPosY;
v36 = transform_view._21 * pPosY;
v37 = 0;
tx = transform_view._31 * *pPosZ + v36 + transform_view._11 * pPosX + transform_view._41;
ty = transform_view._22 * pPosY2 + transform_view._12 * pPosX + transform_view._32 * *pPosZ + transform_view._42;
c_sz = transform_view._33 * *pPosZ
+ transform_view._23 * pPosY2
+ transform_view._13 * pPosX
+ transform_view._43;
if (c_sz < znear)
v37 = -128;
t_persp = f_persp / c_sz;
c_sx = t_persp * tx + f_centerx;
*(D3DTLVERTEX_cy - 1) = c_sx;
*D3DTLVERTEX_cy = t_persp * ty + f_centery;
D3DTLVERTEX_cy[1] = t_persp * f_oneopersp;
if (c_sx >= winX)
{
if ((double)phd_winxmax < *(D3DTLVERTEX_cy - 1))
v37 += 2;
}
else
v95 = 0.0;
*v42 &= 0xF7u;
{
++v37;
}
if (*D3DTLVERTEX_cy >= winY)
{
if ((double)phd_winymax < *D3DTLVERTEX_cy)
v37 += 8;
}
else
{
v37 += 4;
}
D3DTLVERTEX_cy[2] = c_sz;
*(_WORD*)someFlag = v37;
D3DTLVERTEX_cy[3] = tx;
D3DTLVERTEX_cy[4] = ty;
someFlag += 2;
pPosZ += 4;
D3DTLVERTEX_cy += 8;
--v32;
}
}
v46 += 8;
++v45;
v86 += 4;
} while (v45 < 32);
}
}*/
}
// It just works (tm)! Again, as spotcams Spline() :-)
int LSpline(int x, int* knots, int nk)
{
int64_t v3 = (x * (int64_t)(nk - 3)) * 65536 / 65536; // lmao?
int32_t v4 = (int32_t)v3 / 65536;
if (((int32_t)v3 / 65536) >= nk - 3)
v4 = nk - 4;
int32_t v5 = knots[3 * v4];
int32_t v6 = knots[3 * v4 + 6];
int32_t nka = knots[3 * v4 + 9] / 2;
int32_t v7 = knots[3 * v4 + 3];
return (int32_t)(v7
+ (int64_t)(uint64_t)(((int32_t)((~v5 / 2)
+ (v6 / 2)
+ (int64_t)(uint64_t)(((int32_t)(v5
+ (int64_t)(uint64_t)((((~v5 / 2)
+ nka
+ v7
+ (v7 / 2)
- (v6 / 2)
- v6)
* (int64_t)((int32_t)v3 - (v4 * 65536))) / 65536)
- 2 * v7
+ 2 * v6
- (v7 / 2)
- nka)
* (int64_t)((int32_t)v3 - (v4 * 65536))) / 65536))
* (int64_t)((int32_t)v3 - (v4 * 65536))) / 65536));
}
if (arc->life >= 16)
{
r = arc->r;
g = arc->g;
b = arc->b;
}
else
{
r = arc->r >> 4;
g = arc->g >> 4;
b = arc->b >> 4;
}
void CalcLightningSpline(PHD_VECTOR* pos, short* buffer, ENERGY_ARC* arc)
{
buffer[0] = pos->x;
buffer[1] = pos->y;
buffer[2] = pos->z;
float length = 0.0;
float width = (float)(arc->width >> 1);
buffer += 4;
if (arc->flags & 8)
{
length = width * 0.125;
width = 0.0;
}
else if (arc->flags & 4)
{
length = -(width * 0.03125);
}
if (arc->flags & 1)
{
int dp = 65536 / (3 * arc->segments - 1);
int x = dp;
for (int j = 0; j < 32; j++)
{
short angle = -phd_atan(vbuffer);
float sinAngle = FloatSinCosTable[angle + 0x4000];
width = max(width, 0);
if (3 * arc->segments - 2 > 0)
{
for (int i = 3 * arc->segments - 2; i > 0; i--)
{
short sx = LSpline(x, &pos->x, 6);
buffer[0] = sx + (GetRandomControl() & 0xF) - 8;
short sy = LSpline(x, &pos->y, 6);
buffer[1] = sy + (GetRandomControl() & 0xF) - 8;
short sz = LSpline(x, &pos->z, 6);
buffer[2] = sz + (GetRandomControl() & 0xF) - 8;
}
x += dp;
buffer += 4;
v45 = 0;
v46 = (float*)&v125;
do
{
v47 = -j_phd_atan((signed __int64)(v46[7] - *(v46 - 1)), (signed __int64)(v46[8] - *v46));
v48 = FloatSinCosTable[(unsigned __int16)(v47 + 0x4000)];
v49 = v88;
if (v88 <= 0.0)
v49 = 2.0;
v50 = flt_51D15C / v46[2] * v49;
v51 = (*v42 & 8) == 0;
*v86 = FloatSinCosTable[(unsigned __int16)v47] * v50;
v86[1] = v48 * v50;
v88 = v95 + v88;
if (!v51 && v45 == 8)
{
if (*v42 & 4)
v95 = (double)(unsigned __int8)(*(_BYTE*)(arc + 53) >> 1) * -0.035714287;
else
v95 = 0.0;
*v42 &= 0xF7u;
}
v46 += 8;
++v45;
v86 += 4;
} while (v45 < 32);
}
}
}
else
{
int segments = 3 * arc->segments - 1;
int dx = (pos[5].x - pos->x) / segments;
int dy = (pos[5].y - pos->y) / segments;
int dz = (pos[5].z - pos->z) / segments;
int x = dx + (GetRandomControl() % (2 * arc->amplitude)) - arc->amplitude + pos->x;
int y = dy + (GetRandomControl() % (2 * arc->amplitude)) - arc->amplitude + pos->y;
int z = dz + (GetRandomControl() % (2 * arc->amplitude)) - arc->amplitude + pos->z;
if (3 * arc->segments - 2 > 0)
{
for (int i = 3 * arc->segments - 2; i > 0; i--)
{
buffer[0] = x;
buffer[1] = y;
buffer[2] = z;
x += dx + GetRandomControl() % (2 * arc->amplitude) - arc->amplitude;
y += dy + GetRandomControl() % (2 * arc->amplitude) - arc->amplitude;
z += dz + GetRandomControl() % (2 * arc->amplitude) - arc->amplitude;
buffer += 4;
}
}
}*/
}
buffer[0] = pos[5].x;
buffer[1] = pos[5].y;
buffer[2] = pos[5].z;
}
// It just works (tm)! Again, as spotcams Spline() :-)
int LSpline(int x, int* knots, int nk)
{
int64_t v3 = (x * (int64_t)(nk - 3)) * 65536 / 65536; // lmao?
int32_t v4 = (int32_t)v3 / 65536;
if (((int32_t)v3 / 65536) >= nk - 3)
v4 = nk - 4;
int32_t v5 = knots[3 * v4];
int32_t v6 = knots[3 * v4 + 6];
int32_t nka = knots[3 * v4 + 9] / 2;
int32_t v7 = knots[3 * v4 + 3];
return (int32_t)(v7
+ (int64_t)(uint64_t)(((int32_t)((~v5 / 2)
+ (v6 / 2)
+ (int64_t)(uint64_t)(((int32_t)(v5
+ (int64_t)(uint64_t)((((~v5 / 2)
+ nka
+ v7
+ (v7 / 2)
- (v6 / 2)
- v6)
* (int64_t)((int32_t)v3 - (v4 * 65536))) / 65536)
- 2 * v7
+ 2 * v6
- (v7 / 2)
- nka)
* (int64_t)((int32_t)v3 - (v4 * 65536))) / 65536))
* (int64_t)((int32_t)v3 - (v4 * 65536))) / 65536));
}
void CalcLightningSpline(PHD_VECTOR* pos, short* buffer, LIGHTNING_INFO* arc)
{
buffer[0] = pos->x;
buffer[1] = pos->y;
buffer[2] = pos->z;
buffer += 4;
if (arc->flags & 1)
{
int dp = 65536 / (3 * arc->segments - 1);
int x = dp;
if (3 * arc->segments - 2 > 0)
{
for (int i = 3 * arc->segments - 2; i > 0; i--)
{
short sx = LSpline(x, &pos->x, 6);
buffer[0] = sx + (GetRandomControl() & 0xF) - 8;
short sy = LSpline(x, &pos->y, 6);
buffer[1] = sy + (GetRandomControl() & 0xF) - 8;
short sz = LSpline(x, &pos->z, 6);
buffer[2] = sz + (GetRandomControl() & 0xF) - 8;
x += dp;
buffer += 4;
}
}
}
else
{
int segments = 3 * arc->segments - 1;
int dx = (pos[5].x - pos->x) / segments;
int dy = (pos[5].y - pos->y) / segments;
int dz = (pos[5].z - pos->z) / segments;
int x = dx + (GetRandomControl() % (2 * arc->amplitude)) - arc->amplitude + pos->x;
int y = dy + (GetRandomControl() % (2 * arc->amplitude)) - arc->amplitude + pos->y;
int z = dz + (GetRandomControl() % (2 * arc->amplitude)) - arc->amplitude + pos->z;
if (3 * arc->segments - 2 > 0)
{
for (int i = 3 * arc->segments - 2; i > 0; i--)
{
buffer[0] = x;
buffer[1] = y;
buffer[2] = z;
x += dx + GetRandomControl() % (2 * arc->amplitude) - arc->amplitude;
y += dy + GetRandomControl() % (2 * arc->amplitude) - arc->amplitude;
z += dz + GetRandomControl() % (2 * arc->amplitude) - arc->amplitude;
buffer += 4;
}
}
}
buffer[0] = pos[5].x;
buffer[1] = pos[5].y;
buffer[2] = pos[5].z;
}
void TriggerLightningGlow(int x, int y, int z, byte size, byte r, byte g, byte b)
{
SPARKS* spark = &Sparks[GetFreeSpark()];
spark->dG = g;
spark->sG = g;
spark->life = 4;
spark->sLife = 4;
spark->dR = r;
spark->sR = r;
spark->colFadeSpeed = 2;
spark->transType = COLADD;
spark->on = 1;
spark->dB = b;
spark->sB = b;
spark->fadeToBlack = 0;
spark->x = x;
spark->y = y;
spark->z = z;
spark->xVel = 0;
spark->yVel = 0;
spark->zVel = 0;
spark->flags = SP_DEF | SP_SCALE;
spark->scalar = 3;
spark->maxYvel = 0;
spark->def = Objects[ID_MISC_SPRITES].meshIndex;
spark->gravity = 0;
spark->dSize = spark->sSize = spark->size = size + (GetRandomControl() & 3);
}
}

View file

@ -0,0 +1,57 @@
#pragma once
#include <cstddef>
#include <vector>
using std::vector;
struct PHD_VECTOR;
struct ENERGY_ARC;
namespace TEN::Effects::Lightning
{
enum LightningFlags
{
LI_SPLINE = 1,
LI_MOVEEND = 2,
LI_THINOUT = 4,
LI_THININ = 8,
LI_SPARKEND = 16
};
struct LIGHTNING_INFO
{
PHD_VECTOR pos1;
PHD_VECTOR pos2;
PHD_VECTOR pos3;
PHD_VECTOR pos4;
signed char interpolation[9];
byte r;
byte g;
byte b;
byte life;
byte amplitude;
byte flags;
byte width;
byte segments;
int sAmplitude;
int segmentSize;
int direction;
int rotation;
int type;
int sLife;
};
extern int LightningRandomSeed;
extern float FloatSinCosTable[8192];
extern PHD_VECTOR LightningPos[6];
extern short LightningBuffer[1024];
extern std::vector<LIGHTNING_INFO> Lightning;
void InitialiseFloatSinCosTable();
void UpdateLightning();
void TriggerLightning(PHD_VECTOR* src, PHD_VECTOR* dest, char amplitude, byte r, byte g, byte b, byte life, char flags, char width, char segments);
void CalcLightningSpline(PHD_VECTOR* pos, short* buffer, LIGHTNING_INFO* arc);
void TriggerLightningGlow(int x, int y, int z, byte size, byte r, byte g, byte b);
}

View file

@ -58,7 +58,6 @@ BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD];
DRIP_STRUCT Drips[MAX_DRIPS];
SHOCKWAVE_STRUCT ShockWaves[MAX_SHOCKWAVE];
FIRE_LIST Fires[MAX_FIRE_LIST];
ENERGY_ARC EnergyArcs[MAX_ENERGYARCS];
int GetFreeFireSpark()
{
@ -341,19 +340,6 @@ void UpdateFireSparks()
}
}
void UpdateEnergyArcs()
{
for (int i = 0; i < MAX_ENERGYARCS; i++)
{
ENERGY_ARC* arc = &EnergyArcs[i];
if (arc->life > 0)
{
arc->life--;
}
}
}
int GetFreeSmokeSpark()
{
SMOKE_SPARKS* spark = &SmokeSparks[NextSmokeSpark];
@ -1604,36 +1590,6 @@ void TriggerExplosionBubble(int x, int y, int z, short roomNum)
SetUpLensFlare(0, 0, 0, &pos);
}*/
void TriggerLightningGlow(int x, int y, int z, byte size, byte r, byte g, byte b)
{
SPARKS* spark = &Sparks[GetFreeSpark()];
spark->dG = g;
spark->sG = g;
spark->life = 4;
spark->sLife = 4;
spark->dR = r;
spark->sR = r;
spark->colFadeSpeed = 2;
spark->transType = COLADD;
spark->on = 1;
spark->dB = b;
spark->sB = b;
spark->fadeToBlack = 0;
spark->x = x;
spark->y = y;
spark->z = z;
spark->xVel = 0;
spark->yVel = 0;
spark->zVel = 0;
spark->flags = SP_DEF | SP_SCALE;
spark->scalar = 3;
spark->maxYvel = 0;
spark->def = Objects[ID_MISC_SPRITES].meshIndex;
spark->gravity = 0;
spark->dSize = spark->sSize = spark->size = size + (GetRandomControl() & 3);
}
void TriggerFenceSparks(int x, int y, int z, int kill, int crane)
{
SPARKS* spark = &Sparks[GetFreeSpark()];
@ -1718,42 +1674,4 @@ void TriggerSmallSplash(int x, int y, int z, int num)
sptr->maxYvel = 0;
sptr->gravity = (GetRandomControl() & 0xF) + 64;
}
}
ENERGY_ARC* TriggerEnergyArc(PHD_VECTOR* start, PHD_VECTOR* end, byte r, byte g, byte b, short segmentSize, short life, short amplitude, byte flags, byte type)
{
ENERGY_ARC* arc = NULL;
for (int i = 0; i < MAX_ENERGYARCS; i++)
{
arc = &EnergyArcs[i];
if (arc->life == 0)
break;
}
if (arc == NULL)
return NULL;
arc->pos1 = *start;
arc->pos2.x = (end->x + 3 * start->x) >> 2;
arc->pos2.y = (end->y + 3 * start->y) >> 2;
arc->pos2.z = (end->z + 3 * start->z) >> 2;
arc->pos3.x = (start->x + 3 * end->x) >> 2;
arc->pos3.y = (start->y + 3 * end->y) >> 2;
arc->pos3.z = (start->z + 3 * end->z) >> 2;
arc->pos4 = *end;
arc->sLife = life;
arc->life = life;
arc->sAmplitude = amplitude;
arc->segmentSize = segmentSize;
arc->amplitude = 0;
arc->r = r;
arc->g = g;
arc->b = b;
arc->type = type;
arc->flags = flags;
arc->direction = 1;
arc->rotation = GetRandomControl();
return arc;
}
}

View file

@ -3,30 +3,6 @@
#include "lara_struct.h"
struct ITEM_INFO;
struct ENERGY_ARC
{
PHD_VECTOR pos1;
PHD_VECTOR pos2;
PHD_VECTOR pos3;
PHD_VECTOR pos4;
signed char interpolation[9];
byte r;
byte g;
byte b;
byte life;
byte amplitude;
byte flags;
byte width;
byte segments;
int sAmplitude;
int segmentSize;
int direction;
int rotation;
int type;
int sLife;
};
struct SMOKE_SPARKS
{
int x;
@ -200,9 +176,6 @@ extern int NextBlood;
extern int NextSpider;
extern int NextGunShell;
extern PHD_VECTOR LightningPos[6];
extern short LightningBuffer[1024];
#define MAX_SPARKS_FIRE 20
#define MAX_FIRE_LIST 32
#define MAX_SPARKS_SMOKE 32
@ -211,7 +184,6 @@ extern short LightningBuffer[1024];
#define MAX_GUNSHELL 24
#define MAX_DRIPS 32
#define MAX_SHOCKWAVE 16
#define MAX_ENERGYARCS 32
extern GUNFLASH_STRUCT Gunflashes[MAX_GUNFLASH];
extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE];
@ -221,7 +193,6 @@ extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD];
extern DRIP_STRUCT Drips[MAX_DRIPS];
extern SHOCKWAVE_STRUCT ShockWaves[MAX_SHOCKWAVE];
extern FIRE_LIST Fires[MAX_FIRE_LIST];
extern ENERGY_ARC EnergyArcs[MAX_ENERGYARCS];
extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE];
void TriggerBlood(int x, int y, int z, int unk, int num);
@ -263,13 +234,4 @@ void TriggerShockwave(PHD_3DPOS* pos, short innerRad, short outerRad, int speed,
void TriggerShockwaveHitEffect(int x, int y, int z, int color, short rot, int vel);
void UpdateShockwaves();
void TriggerSmallSplash(int x, int y, int z, int num);
void SetFadeClip(short height, short speed);
void TriggerLightningGlow(int x, int y, int z, byte size, byte r, byte g, byte b);
ENERGY_ARC* TriggerEnergyArc(PHD_VECTOR* start, PHD_VECTOR* end, byte r, byte g, byte b, short segmentSize, short life, short amplitude, byte flags, byte type);
void UpdateEnergyArcs();
void InitialiseFloatSinCosTable();
void UpdateLightning();
void TriggerLightning(PHD_VECTOR* src, PHD_VECTOR* dest, char amplitude, byte r, byte g, byte b, byte life, char flags, char width, char segments);
void DrawLightning();
void CalcLightningSpline(PHD_VECTOR* pos, short* buffer, ENERGY_ARC* arc);
void SetFadeClip(short height, short speed);

View file

@ -58,7 +58,7 @@ struct ITEM_INFO
short timer;
uint16_t flags; // ItemFlags enum
short shade;
uint16_t triggerFlags;
short triggerFlags;
short carriedItem;
short afterDeath;
short firedWeapon;

View file

@ -16,7 +16,9 @@
#include "tr5_spider_emitter.h"
#include "fullblock_switch.h"
#include "itemdata/creature_info.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Entities::Switches;
using std::string;

View file

@ -6,6 +6,7 @@
#include "effects/weather.h"
#include "lara.h"
#include "collide.h"
#include "sphere.h"
#include "camera.h"
#include "tr5_light.h"
#include "animation.h"
@ -13,342 +14,131 @@
#include "input.h"
#include "room.h"
#include "Sound/sound.h"
#include "Specific/prng.h"
using namespace TEN::Effects::Environment;
using namespace TEN::Math::Random;
static short WreckingBallData[2] = {0, 0};
ITEM_INFO* WBItem;
short WBRoom;
byte Flame3xzoffs[16][2] =
void InitialiseFallingBlock(short itemNumber)
{
{ 0x09, 0x09 },
{ 0x18, 0x09 },
{ 0x28, 0x09 },
{ 0x37, 0x09 },
{ 0x09, 0x18 },
{ 0x18, 0x18 },
{ 0x28, 0x18 },
{ 0x37, 0x18 },
{ 0x09, 0x28 },
{ 0x18, 0x28 },
{ 0x28, 0x28 },
{ 0x37, 0x28 },
{ 0x09, 0x37 },
{ 0x18, 0x37 },
{ 0x28, 0x37 },
{ 0x37, 0x37 }
};
g_Level.Items[itemNumber].meshBits = 1;
TEN::Floordata::AddBridge(itemNumber);
}
OBJECT_COLLISION_BOUNDS FireBounds = {0, 0, 0, 0, 0, 0, -1820, 1820, -5460, 5460, -1820, 1820};
bool FlameEmitterFlags[8];
void LaraBurn()
void FallingBlockCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
{
if (!Lara.burn && !Lara.burnSmoke)
ITEM_INFO* item = &g_Level.Items[itemNum];
if (!item->itemFlags[0] && !item->triggerFlags && item->pos.yPos == l->pos.yPos)
{
short fxNum = CreateNewEffect(LaraItem->roomNumber);
if (fxNum != NO_ITEM)
if (!((item->pos.xPos ^ l->pos.xPos) & 0xFFFFFC00) && !((l->pos.zPos ^ item->pos.zPos) & 0xFFFFFC00))
{
EffectList[fxNum].objectNumber = ID_FLAME;
Lara.burn = true;
SoundEffect(SFX_TR4_ROCK_FALL_CRUMBLE, &item->pos, 0);
AddActiveItem(itemNum);
item->itemFlags[0] = 0;
item->status = ITEM_ACTIVE;
item->flags |= 0x3E00;
}
}
}
void FlameEmitterControl(short itemNumber)
void FallingBlockControl(short itemNumber)
{
byte r, g, b;
int falloff;
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (TriggerActive(item))
if (item->triggerFlags)
{
if (item->triggerFlags < 0)
item->triggerFlags--;
}
else
{
if (item->itemFlags[0])
{
short flags = -item->triggerFlags;
if ((flags & 7) == 2 || (flags & 7) == 7)
if (item->itemFlags[0] < 60)
{
PHD_3DPOS* pos = &item->pos;
SoundEffect(SFX_TR4_FLAME_EMITTER, &item->pos, 0);
TriggerSuperJetFlame(item, -256 - (3072 * GlobalCounter & 0x1C00), GlobalCounter & 1);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
(GetRandomControl() & 3) + 20,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
if (item->itemFlags[0] < 52)
{
if (!(GetRandomControl() % (62 - item->itemFlags[0])))
item->pos.yPos += (GetRandomControl() & 3) + 1;
item->itemFlags[0]++;
}
else
{
item->itemFlags[1] += 2;
item->itemFlags[0]++;
item->pos.yPos += item->itemFlags[1];
}
}
else
{
if (item->itemFlags[0])
{
if (item->itemFlags[1])
item->itemFlags[1] = item->itemFlags[1] - (item->itemFlags[1] >> 2);
if (item->itemFlags[2] < 256)
item->itemFlags[2] += 8;
item->itemFlags[0]--;
if (!item->itemFlags[0])
item->itemFlags[3] = (GetRandomControl() & 0x3F) + 150;
}
else
{
if (!--item->itemFlags[3])
{
if (flags >> 3)
item->itemFlags[0] = (GetRandomControl() & 0x1F) + 30 * (flags >> 3);
else
item->itemFlags[0] = (GetRandomControl() & 0x3F) + 60;
}
if (item->itemFlags[2])
item->itemFlags[2] -= 8;
if (item->itemFlags[1] > -8192)
item->itemFlags[1] -= 512;
}
if (item->itemFlags[2])
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, SP_NORMALFIRE, item->roomNumber, item->itemFlags[2]);
if (item->itemFlags[1])
{
SoundEffect(SFX_TR4_FLAME_EMITTER, &item->pos, 0);
if (item->itemFlags[1] <= -8192)
TriggerSuperJetFlame(item, -256 - (3072 * GlobalCounter & 0x1C00), GlobalCounter & 1);
else
TriggerSuperJetFlame(item, item->itemFlags[1], GlobalCounter & 1);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
(-item->itemFlags[1] >> 10) - (GetRandomControl() & 1) + 16,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
}
else
{
r = (GetRandomControl() & 0x3F) + 192;
g = (GetRandomControl() & 0x1F) + 96;
falloff = 10 - (GetRandomControl() & 1);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
10 - (GetRandomControl() & 1),
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
}
KillItem(itemNumber);
}
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
}
else
{
if (item->triggerFlags < 8)
FlameEmitterFlags[item->triggerFlags] = true;
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, 2, item->roomNumber, 0);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
16 - (GetRandomControl() & 1),
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
if (!Lara.burn
/*&& item->triggerFlags != 33*/
&& ItemNearLara(&item->pos, 600)
&& (SQUARE(LaraItem->pos.xPos - item->pos.xPos) +
SQUARE(LaraItem->pos.zPos - item->pos.zPos) < SQUARE(512))
&& Lara.waterStatus != LW_FLYCHEAT)
{
LaraBurn();
}
item->meshBits = -2;
ExplodingDeath(itemNumber, -1, 15265);
item->itemFlags[0]++;
}
}
else
{
if (item->triggerFlags > 0 && item->triggerFlags < 8)
FlameEmitterFlags[item->triggerFlags] = false;
}
}
void FlameEmitter2Control(short itemNumber)
//void FallingBlockFloor(ITEM_INFO* item, int x, int y, int z, int* height)
//{
// if (!((x ^ item->pos.xPos) & 0xFFFFFC00) && !((z ^ item->pos.zPos) & 0xFFFFFC00))
// {
// if (y <= item->pos.yPos)
// {
// *height = item->pos.yPos;
// HeightType = WALL;
// }
// }
//}
//
//void FallingBlockCeiling(ITEM_INFO* item, int x, int y, int z, int* height)
//{
// if (!((x ^ item->pos.xPos) & 0xFFFFFC00) && !((z ^ item->pos.zPos) & 0xFFFFFC00))
// {
// if (y > item->pos.yPos)
// {
// *height = item->pos.yPos + 256;
// }
// }
//}
std::optional<int> FallingBlockFloor(short itemNumber, int x, int y, int z)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (!item->meshBits || item->itemFlags[0] >= 52)
return std::nullopt;
int height = item->pos.yPos;
return std::optional{ height };
}
std::optional<int> FallingBlockCeiling(short itemNumber, int x, int y, int z)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (TriggerActive(item))
{
if (item->triggerFlags >= 0)
{
if (item->triggerFlags != 2)
{
if (item->triggerFlags == 123)
{
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, 1, item->roomNumber, item->itemFlags[3]);
}
else
{
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, 1 - item->triggerFlags, item->roomNumber, item->itemFlags[3]);
}
}
if (!item->triggerFlags || item->triggerFlags == 2)
{
if (item->itemFlags[3])
{
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
10,
((GetRandomControl() & 0x3F) + 192) * item->itemFlags[3] >> 8,
(GetRandomControl() & 0x1F) + 96 * item->itemFlags[3] >> 8,
0);
}
else
{
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
10,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96,
0);
}
}
if (!item->meshBits || item->itemFlags[0] >= 52)
return std::nullopt;
if (item->triggerFlags == 2)
{
item->pos.xPos += phd_sin(item->pos.yRot - ANGLE(180));
item->pos.zPos += phd_cos(item->pos.yRot - ANGLE(180));
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
if (g_Level.Rooms[roomNumber].flags & ENV_FLAG_WATER)
{
Weather.Flash(255, 128, 0, 0.03f);
KillItem(itemNumber);
return;
}
if (item->roomNumber != roomNumber)
{
ItemNewRoom(itemNumber, roomNumber);
}
item->pos.yPos = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);;
if (Wibble & 7)
{
TriggerFireFlame(item->pos.xPos, item->pos.yPos - 32, item->pos.zPos, -1, 1);
}
}
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
}
else if (!item->itemFlags[0])
{
DoFlipMap(-item->triggerFlags);
FlipMap[-item->triggerFlags] ^= 0x3E00u;
item->itemFlags[0] = 1;
}
}
int height = item->pos.yPos + 256;
return std::optional{ height };
}
void FlameControl(short fxNumber)
int FallingBlockFloorBorder(short itemNumber)
{
FX_INFO* fx = &EffectList[fxNumber];
for (int i = 0; i < 14; i++)
{
if (!(Wibble & 0x2))
{
fx->pos.xPos = 0;
fx->pos.yPos = 0;
fx->pos.zPos = 0;
GetLaraJointPosition((PHD_VECTOR*)&fx->pos, i);
if (Lara.burnCount)
{
Lara.burnCount--;
if (!Lara.burnCount)
Lara.burnSmoke = true;
}
TriggerFireFlame(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, -1, 255 - Lara.burnSmoke);
}
}
byte r = (GetRandomControl() & 0x3F) + 192;
byte g = (GetRandomControl() & 0x1F) + 96;
byte b;
if (!Lara.burnSmoke)
{
PHD_VECTOR pos{ 0,0,0 };
GetLaraJointPosition(&pos, LM_HIPS);
if (!Lara.burnBlue)
{
TriggerDynamicLight(pos.x, pos.y, pos.z, 13, r, g, 0);
}
else
{
if (Lara.burnBlue == 128)
{
b = r;
TriggerDynamicLight(pos.x, pos.y, pos.z, 13, 0, g, b);
}
else if (Lara.burnBlue == 256)
{
b = g;
g = r;
TriggerDynamicLight(pos.x, pos.y, pos.z, 13, 0, g, b);
}
}
}
if (LaraItem->roomNumber != fx->roomNumber)
EffectNewRoom(fxNumber, LaraItem->roomNumber);
int wh = GetWaterHeight(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, fx->roomNumber);
if (wh == NO_HEIGHT || fx->pos.yPos <= wh || Lara.burnBlue)
{
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &fx->pos, 0);
LaraItem->hitPoints -= 7;
LaraItem->hitStatus = true;
}
else
{
KillEffect(fxNumber);
Lara.burn = false;
}
if (Lara.waterStatus == LW_FLYCHEAT)
{
KillEffect(fxNumber);
Lara.burn = false;
}
ITEM_INFO* item = &g_Level.Items[itemNumber];
return item->pos.yPos;
}
void LavaBurn(ITEM_INFO* item)
int FallingBlockCeilingBorder(short itemNumber)
{
if (item->hitPoints >= 0 && Lara.waterStatus != LW_FLYCHEAT)
{
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, 32000, item->pos.zPos, &roomNumber);
if (item->floor == GetFloorHeight(floor, item->pos.xPos, 32000, item->pos.zPos))
{
// if (Objects[ID_KAYAK].loaded && Objects[ID_KAYAK_LARA_ANIMS].loaded) //TEMPORARILY ADDING THIS HACK FOR TESTING-// KayakLaraRapidsDrown works fine.
// KayakLaraRapidsDrown();
// else
// {
item->hitPoints = -1;
item->hitStatus = true;
LaraBurn();
// }
}
}
ITEM_INFO* item = &g_Level.Items[itemNumber];
return (item->pos.yPos + 256);
}
void InitialiseWreckingBall(short itemNumber)
@ -629,356 +419,3 @@ void WreckingBallControl(short itemNumber)
WBRoom = room;
}
void FlameEmitterCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (Lara.gunType != WEAPON_TORCH
|| Lara.gunStatus != LG_READY
|| Lara.leftArm.lock
|| Lara.litTorch == (item->status & 1)
|| item->timer == -1
|| !(TrInput & IN_ACTION)
|| l->currentAnimState != LS_STOP
|| l->animNumber != LA_STAND_IDLE
|| l->gravityStatus)
{
if (item->objectNumber == ID_BURNING_ROOTS)
ObjectCollision(itemNumber, l, coll);
}
else
{
switch (item->objectNumber)
{
case ID_FLAME_EMITTER:
FireBounds.boundingBox.X1 = -256;
FireBounds.boundingBox.X2 = 256;
FireBounds.boundingBox.Y1 = 0;
FireBounds.boundingBox.Y2 = 1024;
FireBounds.boundingBox.Z1 = -800;
FireBounds.boundingBox.Z2 = 800;
break;
case ID_FLAME_EMITTER2:
FireBounds.boundingBox.X1 = -256;
FireBounds.boundingBox.X2 = 256;
FireBounds.boundingBox.Y1 = 0;
FireBounds.boundingBox.Y2 = 1024;
FireBounds.boundingBox.Z1 = -600;
FireBounds.boundingBox.Z2 = 600;
break;
case ID_BURNING_ROOTS:
FireBounds.boundingBox.X1 = -384;
FireBounds.boundingBox.X2 = 384;
FireBounds.boundingBox.Y1 = 0;
FireBounds.boundingBox.Y2 = 2048;
FireBounds.boundingBox.Z1 = -384;
FireBounds.boundingBox.Z2 = 384;
break;
}
short oldYrot = item->pos.yRot;
item->pos.yRot = l->pos.yRot;
if (TestLaraPosition(&FireBounds, item, l))
{
if (item->objectNumber == ID_BURNING_ROOTS)
{
l->animNumber = LA_TORCH_LIGHT_5;
}
else
{
int dy = abs(l->pos.yPos - item->pos.yPos);
l->itemFlags[3] = 1;
l->animNumber = (dy >> 8) + LA_TORCH_LIGHT_1;
}
l->currentAnimState = LS_MISC_CONTROL;
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
Lara.flareControlLeft = false;
Lara.leftArm.lock = 3;
Lara.interactedItem = itemNumber;
}
item->pos.yRot = oldYrot;
}
if (Lara.interactedItem == itemNumber
&& item->status != ITEM_ACTIVE
&& l->currentAnimState == LS_MISC_CONTROL)
{
if (l->animNumber >= LA_TORCH_LIGHT_1 && l->animNumber <= LA_TORCH_LIGHT_5)
{
if (l->frameNumber - g_Level.Anims[l->animNumber].frameBase == 40)
{
TestTriggers(item, true, item->flags & IFLAG_ACTIVATION_MASK);
item->flags |= 0x3E00;
item->itemFlags[3] = 0;
item->status = ITEM_ACTIVE;
AddActiveItem(itemNumber);
}
}
}
}
void InitialiseFlameEmitter2(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
item->pos.yPos -= 64;
if (item->triggerFlags != 123)
{
if (item->pos.yRot > 0)
{
if (item->pos.yRot == ANGLE(90))
{
if (item->triggerFlags == 2)
item->pos.xPos += 80;
else
item->pos.xPos += 256;
}
}
else if (item->pos.yRot < 0)
{
if (item->pos.yRot == -ANGLE(180))
{
if (item->triggerFlags == 2)
item->pos.zPos -= 80;
else
item->pos.zPos -= 256;
}
else if (item->pos.yRot == -ANGLE(90))
{
if (item->triggerFlags == 2)
item->pos.xPos -= 80;
else
item->pos.xPos -= 256;
}
}
else
{
if (item->triggerFlags == 2)
item->pos.zPos += 80;
else
item->pos.zPos += 256;
}
}
}
void InitialiseFlameEmitter(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
/*if (item->triggerFlags > 0)
{
if (item->triggerFlags == 33)
{
if (item->pos.yRot > 0)
{
if (item->pos.yRot == ANGLE(90))
item->pos.xPos += 144;
}
else
{
if (item->pos.yRot == 0)
{
item->pos.zPos += 144;
item->pos.yPos += 32;
return;
}
else if (item->pos.yRot == -ANGLE(180))
{
item->pos.zPos -= 144;
item->pos.yPos += 32;
return;
}
else if (item->pos.yRot == -ANGLE(90))
{
item->pos.xPos -= 144;
item->pos.yPos += 32;
return;
}
}
item->pos.yPos += 32;
return;
}
}
else
*/
if (item->triggerFlags < 0)
{
item->itemFlags[0] = (GetRandomControl() & 0x3F) + 90;
item->itemFlags[2] = 256;
if (((-item->triggerFlags) & 7) == 7)
{
if (item->pos.yRot > 0)
{
if (item->pos.yRot == ANGLE(90))
{
item->pos.xPos += 512;
}
}
else if (item->pos.yRot < 0)
{
if (item->pos.yRot == -ANGLE(180))
{
item->pos.zPos -= 512;
}
else if (item->pos.yRot == -ANGLE(90))
{
item->pos.xPos -= 512;
}
}
else
{
item->pos.zPos += 512;
}
}
}
}
void FlameEmitter3Control(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (TriggerActive(item))
{
if (item->triggerFlags)
{
SoundEffect(SFX_TR4_ELEC_ARCING_LOOP, &item->pos, 0);
byte g = (GetRandomControl() & 0x3F) + 192;
byte b = (GetRandomControl() & 0x3F) + 192;
PHD_VECTOR src;
PHD_VECTOR dest;
src.x = item->pos.xPos;
src.y = item->pos.yPos;
src.z = item->pos.zPos;
if (!(GlobalCounter & 3))
{
if (item->triggerFlags == 2 || item->triggerFlags == 4)
{
dest.x = item->pos.xPos + 512 * phd_sin(item->pos.yRot + ANGLE(180));
dest.y = item->pos.yPos;
dest.z = item->pos.zPos + 512 * phd_cos(item->pos.yRot + ANGLE(180));
if (GetRandomControl() & 3)
{
TriggerLightning(&src, &dest, (GetRandomControl() & 0x1F) + 64, 0, g, b, 24, 0, 32, 3);
}
else
{
TriggerLightning(&src, &dest, (GetRandomControl() & 0x1F) + 96, 0, g, b, 32, 1, 32, 3);
}
}
}
if (item->triggerFlags >= 3 && !(GlobalCounter & 1))
{
short targetItemNumber = item->itemFlags[((GlobalCounter >> 2) & 1) + 2];
ITEM_INFO* targetItem = &g_Level.Items[targetItemNumber];
dest.x = 0;
dest.y = -64;
dest.z = 20;
GetJointAbsPosition(targetItem, &dest, 0);
if (!(GlobalCounter & 3))
{
if (GetRandomControl() & 3)
{
//TriggerEnergyArc(&dest.x_rot, &dest, (GetRandomControl() & 0x1F) + 64, b | ((g | 0x180000) << 8), 0, 32, 5);
}
else
{
//TriggerEnergyArc(&dest.x_rot, &dest, (GetRandomControl() & 0x1F) + 96, b | ((g | 0x200000) << 8), 1, 32, 5);
}
}
if (item->triggerFlags != 3 || targetItem->triggerFlags)
TriggerLightningGlow(dest.x, dest.y, dest.z, 64, 0, g, b);
}
if ((GlobalCounter & 3) == 2)
{
src.x = item->pos.xPos;
src.y = item->pos.yPos;
src.z = item->pos.zPos;
dest.x = (GetRandomControl() & 0x1FF) + src.x - 256;
dest.y = (GetRandomControl() & 0x1FF) + src.y - 256;
dest.z = (GetRandomControl() & 0x1FF) + src.z - 256;
//TriggerEnergyArc(&src, &dest, (GetRandomControl() & 0xF) + 16, b | ((g | 0x180000) << 8), 3, 32, 3);
TriggerLightningGlow(dest.x, dest.y, dest.z, 64, 0, g, b);
}
}
else
{
// Small fires
if (item->itemFlags[0])
{
item->itemFlags[0]--;
}
else
{
item->itemFlags[0] = (GetRandomControl() & 3) + 8;
int flags = GetRandomControl() & 0x3F;
if (item->itemFlags[1] == flags)
flags = (flags + 13) & 0x3F;
item->itemFlags[1] = flags;
}
int x, z, i;
if (!(Wibble & 4))
{
i = 2 * (item->itemFlags[1] & 7);
x = 16 * (Flame3xzoffs[i][0] - 32);
z = 16 * (Flame3xzoffs[i][1] - 32);
TriggerFireFlame(x + item->pos.xPos, item->pos.yPos, z + item->pos.zPos, -1, 2);
}
else
{
i = 2 * (item->itemFlags[1] >> 3);
x = 16 * (Flame3xzoffs[i + 8][0] - 32);
z = 16 * (Flame3xzoffs[i + 8][1] - 32);
TriggerFireFlame(x + item->pos.xPos, item->pos.yPos, z + item->pos.zPos, -1, 2);
}
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
TriggerDynamicLight(x, item->pos.yPos, z, 12, (GetRandomControl() & 0x3F) + 192, ((GetRandomControl() >> 4) & 0x1F) + 96, 0);
PHD_3DPOS pos;
pos.xPos = item->pos.xPos;
pos.yPos = item->pos.yPos;
pos.zPos = item->pos.zPos;
if (ItemNearLara(&pos, 600))
{
if ((!Lara.burn) && Lara.waterStatus != LW_FLYCHEAT)
{
LaraItem->hitPoints -= 5;
LaraItem->hitStatus = true;
int dx = LaraItem->pos.xPos - item->pos.xPos;
int dz = LaraItem->pos.zPos - item->pos.zPos;
if (SQUARE(dx) + SQUARE(dz) < 202500)
LaraBurn();
}
}
}
}
}

View file

@ -5,16 +5,7 @@ struct ITEM_INFO;
extern ITEM_INFO* WBItem;
extern short WBRoom;
void LaraBurn();
void LavaBurn(ITEM_INFO* item);
void FlameControl(short fxNumber);
void FlameEmitter2Control(short itemNumber);
void FlameEmitterControl(short itemNumber);
void InitialiseFallingBlock(short itemNumber);
void InitialiseWreckingBall(short itemNumber);
void WreckingBallCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll);
void WreckingBallControl(short itemNumber);
void FlameEmitterCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll);
void InitialiseFlameEmitter2(short itemNumber);
void InitialiseFlameEmitter(short itemNumber);
void FlameEmitter3Control(short itemNumber);
void WreckingBallControl(short itemNumber);

View file

@ -0,0 +1,52 @@
#include "framework.h"
#include "effect_objects.h"
#include "Specific/setup.h"
#include "Objects/Effects/flame_emitters.h"
using namespace TEN::Entities::Effects;
void InitialiseEffectsObjects()
{
OBJECT_INFO* obj;
// Flame is always loaded
obj = &Objects[ID_FLAME];
{
obj->control = FlameControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_FLAME_EMITTER];
if (obj->loaded)
{
obj->initialise = InitialiseFlameEmitter;
obj->collision = FlameEmitterCollision;
obj->control = FlameEmitterControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_FLAME_EMITTER2];
if (obj->loaded)
{
obj->initialise = InitialiseFlameEmitter2;
obj->collision = FlameEmitterCollision;
obj->control = FlameEmitter2Control;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_FLAME_EMITTER3];
if (obj->loaded)
{
obj->initialise = InitialiseFlameEmitter3;
obj->control = FlameEmitter3Control;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
}

View file

@ -0,0 +1,3 @@
#pragma once
void InitialiseEffectsObjects();

View file

@ -0,0 +1,732 @@
#include "framework.h"
#include "flame_emitters.h"
#include "Sound/sound.h"
#include "Specific/trmath.h"
#include "sphere.h"
#include "level.h"
#include "lara.h"
#include "effects/tomb4fx.h"
#include "collide.h"
#include "animation.h"
#include <Game/effects/effects.h>
#include <weather.h>
#include <Specific/setup.h>
#include <Game/effects/lightning.h>
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Effects::Lightning;
using namespace TEN::Effects::Environment;
namespace TEN::Entities::Effects
{
byte Flame3xzoffs[16][2] = {{ 9, 9 },
{ 24, 9 },
{ 40, 9 },
{ 55, 9 },
{ 9, 24 },
{ 24, 24 },
{ 40, 24 },
{ 55, 24 },
{ 9, 40 },
{ 24, 40 },
{ 40, 40 },
{ 55, 40 },
{ 9, 55 },
{ 24, 55 },
{ 40, 55 },
{ 55, 55 }
};
OBJECT_COLLISION_BOUNDS FireBounds = {
0, 0,
0, 0,
0, 0,
-ANGLE(10), ANGLE(10),
-ANGLE(30), ANGLE(30),
-ANGLE(10), ANGLE(10)
};
bool FlameEmitterFlags[8];
void FlameEmitterControl(short itemNumber)
{
byte r, g, b;
int falloff;
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (TriggerActive(item))
{
// Jet flame
if (item->triggerFlags < 0)
{
short flags = -item->triggerFlags;
if ((flags & 7) == 2 || (flags & 7) == 7)
{
SoundEffect(SFX_TR4_FLAME_EMITTER, &item->pos, 0);
TriggerSuperJetFlame(item, -256 - (3072 * GlobalCounter & 0x1C00), GlobalCounter & 1);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
(GetRandomControl() & 3) + 20,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
}
else
{
if (item->itemFlags[0])
{
if (item->itemFlags[1])
item->itemFlags[1] = item->itemFlags[1] - (item->itemFlags[1] >> 2);
if (item->itemFlags[2] < 256)
item->itemFlags[2] += 8;
item->itemFlags[0]--;
if (item->itemFlags[0] == 1)
item->itemFlags[3] = (GetRandomControl() & 0x3F) + 150;
}
else
{
if (!--item->itemFlags[3])
{
if (flags >> 3)
item->itemFlags[0] = (GetRandomControl() & 0x1F) + 30 * (flags >> 3);
else
item->itemFlags[0] = (GetRandomControl() & 0x3F) + 60;
}
if (item->itemFlags[2])
item->itemFlags[2] -= 8;
if (item->itemFlags[1] > -8192)
item->itemFlags[1] -= 512;
}
if (item->itemFlags[2])
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, SP_NORMALFIRE, item->roomNumber, item->itemFlags[2]);
if (item->itemFlags[1])
{
SoundEffect(SFX_TR4_FLAME_EMITTER, &item->pos, 0);
if (item->itemFlags[1] <= -8192)
TriggerSuperJetFlame(item, -256 - (3072 * GlobalCounter & 0x1C00), GlobalCounter & 1);
else
TriggerSuperJetFlame(item, item->itemFlags[1], GlobalCounter & 1);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
(-item->itemFlags[1] >> 10) - (GetRandomControl() & 1) + 16,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
}
else
{
r = (GetRandomControl() & 0x3F) + 192;
g = (GetRandomControl() & 0x1F) + 96;
falloff = 10 - (GetRandomControl() & 1);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
10 - (GetRandomControl() & 1),
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
}
}
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
}
else
{
if (item->triggerFlags < 8)
FlameEmitterFlags[item->triggerFlags] = true;
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, SP_BIGFIRE, item->roomNumber, 0);
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
16 - (GetRandomControl() & 1),
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96, 0);
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
if (!Lara.burn
&& ItemNearLara(&item->pos, 600)
&& (SQUARE(LaraItem->pos.xPos - item->pos.xPos) +
SQUARE(LaraItem->pos.zPos - item->pos.zPos) < SQUARE(512))
&& Lara.waterStatus != LW_FLYCHEAT)
{
LaraBurn();
}
}
}
else
{
if (item->triggerFlags > 0 && item->triggerFlags < 8)
FlameEmitterFlags[item->triggerFlags] = false;
}
}
void FlameEmitter2Control(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (TriggerActive(item))
{
// If not an emitter for flipmaps
if (item->triggerFlags >= 0)
{
// If not a moving flame
if (item->triggerFlags != 2)
{
if (item->triggerFlags == 123)
{
// Middle of the block
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, SP_SMALLFIRE, item->roomNumber, item->itemFlags[3]);
}
else
{
AddFire(item->pos.xPos, item->pos.yPos, item->pos.zPos, SP_SMALLFIRE - item->triggerFlags, item->roomNumber, item->itemFlags[3]);
}
}
if (item->triggerFlags == 0 || item->triggerFlags == 2)
{
if (item->itemFlags[3])
{
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
10,
((GetRandomControl() & 0x3F) + 192) * item->itemFlags[3] >> 8,
(GetRandomControl() & 0x1F) + 96 * item->itemFlags[3] >> 8,
0);
}
else
{
TriggerDynamicLight(item->pos.xPos, item->pos.yPos, item->pos.zPos,
10,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96,
0);
}
}
if (item->triggerFlags == 2)
{
item->pos.xPos += phd_sin(item->pos.yRot - ANGLE(180));
item->pos.zPos += phd_cos(item->pos.yRot - ANGLE(180));
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
if (g_Level.Rooms[roomNumber].flags & ENV_FLAG_WATER)
{
Weather.Flash(255, 128, 0, 0.03f);
KillItem(itemNumber);
return;
}
if (item->roomNumber != roomNumber)
{
ItemNewRoom(itemNumber, roomNumber);
}
item->pos.yPos = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);;
if (Wibble & 7)
{
TriggerFireFlame(item->pos.xPos, item->pos.yPos - 32, item->pos.zPos, -1, 1);
}
}
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
}
else if (item->itemFlags[0] == 0)
{
DoFlipMap(-item->triggerFlags);
FlipMap[-item->triggerFlags] ^= 0x3E00u;
item->itemFlags[0] = 1;
}
}
}
void FlameControl(short fxNumber)
{
FX_INFO* fx = &EffectList[fxNumber];
for (int i = 0; i < 14; i++)
{
if (!(Wibble & 0xC))
{
fx->pos.xPos = 0;
fx->pos.yPos = 0;
fx->pos.zPos = 0;
GetLaraJointPosition((PHD_VECTOR*)&fx->pos, i);
// TR5 code?
if (Lara.burnCount)
{
Lara.burnCount--;
if (!Lara.burnCount)
Lara.burnSmoke = true;
}
TriggerFireFlame(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, -1, 255 - Lara.burnSmoke);
}
}
byte r = (GetRandomControl() & 0x3F) + 192;
byte g = (GetRandomControl() & 0x1F) + 96;
byte b;
PHD_VECTOR pos{ 0,0,0 };
GetLaraJointPosition(&pos, LM_HIPS);
if (!Lara.burnSmoke)
{
if (Lara.burnBlue == 0)
{
TriggerDynamicLight(
pos.x,
pos.y,
pos.z,
13,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96,
0);
}
else if (Lara.burnBlue == 1)
{
TriggerDynamicLight(
pos.x,
pos.y,
pos.z,
13,
0,
(GetRandomControl() & 0x1F) + 96,
(GetRandomControl() & 0x3F) + 192);
}
else if (Lara.burnBlue == 2)
{
TriggerDynamicLight(
pos.x,
pos.y,
pos.z,
13,
0,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96);
}
}
else
{
TriggerDynamicLight(
pos.x,
pos.y,
pos.z,
13,
GetRandomControl() & 0x3F,
(GetRandomControl() & 0x3F) + 192,
(GetRandomControl() & 0x1F) + 96);
}
if (LaraItem->roomNumber != fx->roomNumber)
EffectNewRoom(fxNumber, LaraItem->roomNumber);
int wh = GetWaterHeight(fx->pos.xPos, fx->pos.yPos, fx->pos.zPos, fx->roomNumber);
if (wh == NO_HEIGHT || fx->pos.yPos <= wh || Lara.burnBlue)
{
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &fx->pos, 0);
LaraItem->hitPoints -= 7;
LaraItem->hitStatus = true;
}
else
{
KillEffect(fxNumber);
Lara.burn = false;
}
if (Lara.waterStatus == LW_FLYCHEAT)
{
KillEffect(fxNumber);
Lara.burn = false;
}
}
void InitialiseFlameEmitter(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (item->triggerFlags < 0)
{
item->itemFlags[0] = (GetRandomControl() & 0x3F) + 90;
item->itemFlags[2] = 256;
if (((-item->triggerFlags) & 7) == 7)
{
switch (item->pos.yRot)
{
case 0:
item->pos.zPos += 512;
break;
case 0x4000:
item->pos.xPos += 512;
break;
case -0x8000:
item->pos.zPos -= 512;
break;
case -0x4000:
item->pos.xPos -= 512;
break;
}
}
}
}
void InitialiseFlameEmitter2(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
item->pos.yPos -= 64;
if (item->triggerFlags != 123)
{
switch (item->pos.yRot)
{
case 0:
if (item->triggerFlags == 2)
item->pos.zPos += 80;
else
item->pos.zPos += 256;
break;
case 0x4000:
if (item->triggerFlags == 2)
item->pos.xPos += 80;
else
item->pos.xPos += 256;
break;
case -0x8000:
if (item->triggerFlags == 2)
item->pos.zPos -= 80;
else
item->pos.zPos -= 256;
break;
case -0x4000:
if (item->triggerFlags == 2)
item->pos.xPos -= 80;
else
item->pos.xPos -= 256;
break;
}
}
}
void InitialiseFlameEmitter3(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (item->triggerFlags >= 3)
{
for (int i = 0; i < g_Level.NumItems; i++)
{
ITEM_INFO* currentItem = &g_Level.Items[i];
if (currentItem->objectNumber == ID_ANIMATING3)
{
if (currentItem->triggerFlags == item->triggerFlags)
item->itemFlags[2] = i;
else if (currentItem->triggerFlags == 0)
item->itemFlags[3] = i;
}
}
}
}
void FlameEmitter3Control(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (TriggerActive(item))
{
if (item->triggerFlags)
{
SoundEffect(SFX_TR4_ELEC_ARCING_LOOP, &item->pos, 0);
byte g = (GetRandomControl() & 0x3F) + 192;
byte b = (GetRandomControl() & 0x3F) + 192;
PHD_VECTOR src;
PHD_VECTOR dest;
src.x = item->pos.xPos;
src.y = item->pos.yPos;
src.z = item->pos.zPos;
if (!(GlobalCounter & 3))
{
if (item->triggerFlags == 2 || item->triggerFlags == 4)
{
dest.x = item->pos.xPos + 512 * phd_sin(item->pos.yRot + ANGLE(180));
dest.y = item->pos.yPos;
dest.z = item->pos.zPos + 512 * phd_cos(item->pos.yRot + ANGLE(180));
if (GetRandomControl() & 3)
{
TriggerLightning(
&src,
&dest,
(GetRandomControl() & 0x1F) + 64,
0,
g,
b,
24,
0,
32,
3);
}
else
{
TriggerLightning(
&src,
&dest,
(GetRandomControl() & 0x1F) + 96,
0,
g,
b,
32,
1,
32,
3);
}
}
}
if (item->triggerFlags >= 3 && !(GlobalCounter & 1))
{
short targetItemNumber = item->itemFlags[((GlobalCounter >> 2) & 1) + 2];
ITEM_INFO* targetItem = &g_Level.Items[targetItemNumber];
dest.x = 0;
dest.y = -64;
dest.z = 20;
GetJointAbsPosition(targetItem, &dest, 0);
if (!(GlobalCounter & 3))
{
if (GetRandomControl() & 3)
{
TriggerLightning(
&src,
&dest,
(GetRandomControl() & 0x1F) + 64,
0,
g,
b,
24,
0,
32,
5);
}
else
{
TriggerLightning(
&src,
&dest,
(GetRandomControl() & 0x1F) + 96,
0,
g,
b,
32,
1,
32,
5);
}
}
if (item->triggerFlags != 3 || targetItem->triggerFlags)
TriggerLightningGlow(dest.x, dest.y, dest.z, 64, 0, g, b);
}
if ((GlobalCounter & 3) == 2)
{
src.x = item->pos.xPos;
src.y = item->pos.yPos;
src.z = item->pos.zPos;
dest.x = (GetRandomControl() & 0x1FF) + src.x - 256;
dest.y = (GetRandomControl() & 0x1FF) + src.y - 256;
dest.z = (GetRandomControl() & 0x1FF) + src.z - 256;
TriggerLightning(
&src,
&dest,
(GetRandomControl() & 0xF) + 16,
0,
g,
b,
24,
3,
32,
3);
TriggerLightningGlow(dest.x, dest.y, dest.z, 64, 0, g, b);
}
}
else
{
// Small fires
if (item->itemFlags[0] != 0)
{
item->itemFlags[0]--;
}
else
{
item->itemFlags[0] = (GetRandomControl() & 3) + 8;
short random = GetRandomControl() & 0x3F;
if (item->itemFlags[1] == random)
random = (random + 13) & 0x3F;
item->itemFlags[1] = random;
}
int x, z, i;
if (!(Wibble & 4))
{
i = item->itemFlags[1] & 7;
x = 16 * (Flame3xzoffs[i][0] - 32);
z = 16 * (Flame3xzoffs[i][1] - 32);
TriggerFireFlame(x + item->pos.xPos, item->pos.yPos, z + item->pos.zPos, -1, 2);
}
else
{
i = item->itemFlags[1] >> 3;
x = 16 * (Flame3xzoffs[i + 8][0] - 32);
z = 16 * (Flame3xzoffs[i + 8][1] - 32);
TriggerFireFlame(x + item->pos.xPos, item->pos.yPos, z + item->pos.zPos, -1, 2);
}
SoundEffect(SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->pos, 0);
TriggerDynamicLight(x, item->pos.yPos, z, 12, (GetRandomControl() & 0x3F) + 192, ((GetRandomControl() >> 4) & 0x1F) + 96, 0);
PHD_3DPOS pos;
pos.xPos = item->pos.xPos;
pos.yPos = item->pos.yPos;
pos.zPos = item->pos.zPos;
if (ItemNearLara(&pos, 600))
{
if ((!Lara.burn) && Lara.waterStatus != LW_FLYCHEAT)
{
LaraItem->hitPoints -= 5;
LaraItem->hitStatus = true;
int dx = LaraItem->pos.xPos - item->pos.xPos;
int dz = LaraItem->pos.zPos - item->pos.zPos;
if (SQUARE(dx) + SQUARE(dz) < SQUARE(450))
LaraBurn();
}
}
}
}
}
void FlameEmitterCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (Lara.gunType != WEAPON_TORCH
|| Lara.gunStatus != LG_READY
|| Lara.leftArm.lock
|| Lara.litTorch == (item->status & 1)
|| item->timer == -1
|| !(TrInput & IN_ACTION)
|| l->currentAnimState != LS_STOP
|| l->animNumber != LA_STAND_IDLE
|| l->gravityStatus)
{
if (item->objectNumber == ID_BURNING_ROOTS)
ObjectCollision(itemNumber, l, coll);
}
else
{
switch (item->objectNumber)
{
case ID_FLAME_EMITTER:
FireBounds.boundingBox.X1 = -256;
FireBounds.boundingBox.X2 = 256;
FireBounds.boundingBox.Y1 = 0;
FireBounds.boundingBox.Y2 = 1024;
FireBounds.boundingBox.Z1 = -800;
FireBounds.boundingBox.Z2 = 800;
break;
case ID_FLAME_EMITTER2:
FireBounds.boundingBox.X1 = -256;
FireBounds.boundingBox.X2 = 256;
FireBounds.boundingBox.Y1 = 0;
FireBounds.boundingBox.Y2 = 1024;
FireBounds.boundingBox.Z1 = -600;
FireBounds.boundingBox.Z2 = 600;
break;
case ID_BURNING_ROOTS:
FireBounds.boundingBox.X1 = -384;
FireBounds.boundingBox.X2 = 384;
FireBounds.boundingBox.Y1 = 0;
FireBounds.boundingBox.Y2 = 2048;
FireBounds.boundingBox.Z1 = -384;
FireBounds.boundingBox.Z2 = 384;
break;
}
short oldYrot = item->pos.yRot;
item->pos.yRot = l->pos.yRot;
if (TestLaraPosition(&FireBounds, item, l))
{
if (item->objectNumber == ID_BURNING_ROOTS)
{
l->animNumber = LA_TORCH_LIGHT_5;
}
else
{
int dy = abs(l->pos.yPos - item->pos.yPos);
l->itemFlags[3] = 1;
l->animNumber = (dy >> 8) + LA_TORCH_LIGHT_1;
}
l->currentAnimState = LS_MISC_CONTROL;
l->frameNumber = g_Level.Anims[l->animNumber].frameBase;
Lara.flareControlLeft = false;
Lara.leftArm.lock = 3;
Lara.interactedItem = itemNumber;
}
item->pos.yRot = oldYrot;
}
if (Lara.interactedItem == itemNumber
&& item->status != ITEM_ACTIVE
&& l->currentAnimState == LS_MISC_CONTROL)
{
if (l->animNumber >= LA_TORCH_LIGHT_1 && l->animNumber <= LA_TORCH_LIGHT_5)
{
if (l->frameNumber - g_Level.Anims[l->animNumber].frameBase == 40)
{
TestTriggers(item, true, item->flags & IFLAG_ACTIVATION_MASK);
item->flags |= 0x3E00;
item->itemFlags[3] = 0;
item->status = ITEM_ACTIVE;
AddActiveItem(itemNumber);
}
}
}
}
}

View file

@ -0,0 +1,19 @@
#pragma once
struct ITEM_INFO;
struct COLL_INFO;
struct OBJECT_COLLISION_BOUNDS;
namespace TEN::Entities::Effects
{
extern OBJECT_COLLISION_BOUNDS FireBounds;
void InitialiseFlameEmitter(short itemNumber);
void InitialiseFlameEmitter2(short itemNumber);
void InitialiseFlameEmitter3(short itemNumber);
void FlameEmitterControl(short itemNumber);
void FlameEmitter2Control(short itemNumber);
void FlameEmitter3Control(short itemNumber);
void FlameControl(short fxNumber);
void FlameEmitterCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll);
}

View file

@ -11,6 +11,9 @@
#include "control/control.h"
#include "tr4_mutant.h"
#include "collide.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
namespace TEN::entities::all
{

View file

@ -9,7 +9,8 @@
#include "collide.h"
#include "animation.h"
namespace TEN::Entities::TR4 {
namespace TEN::Entities::TR4
{
LOCUST_INFO Locusts[MAX_LOCUSTS];
int CreateLocust(void)

View file

@ -10,6 +10,9 @@
#include "Sound\sound.h"
#include "sphere.h"
#include "traps.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
void TriggerElectricityWiresSparks(int x, int z, byte objNum, byte node, int flags)
{

View file

@ -0,0 +1,234 @@
#include "framework.h"
#include "Objects/Generic/Traps/dart_emitter.h"
#include "level.h"
#include "lara.h"
#include "effects\effects.h"
#include "items.h"
#include "Sound\sound.h"
namespace TEN::Entities::Traps
{
void DartControl(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (item->touchBits)
{
LaraItem->hitPoints -= 25;
LaraItem->hitStatus = true;
Lara.poisoned += 160;
DoBloodSplat(item->pos.xPos, item->pos.yPos, item->pos.zPos, (GetRandomControl() & 3) + 4, LaraItem->pos.yRot, LaraItem->roomNumber);
KillItem(itemNumber);
}
else
{
int oldX = item->pos.xPos;
int oldZ = item->pos.zPos-1000;
int speed = item->speed * phd_cos(item->pos.xRot);
item->pos.xPos += speed * phd_sin(item->pos.yRot);
item->pos.yPos -= item->speed * phd_sin(item->pos.xRot);
item->pos.zPos += speed * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
if (item->roomNumber != roomNumber)
ItemNewRoom(itemNumber, roomNumber);
int height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
item->floor = height;
if (item->pos.yPos >= height)
{
for (int i = 0; i < 4; i++)
{
TriggerDartSmoke(oldX, item->pos.yPos, oldZ, 0, 0, true);
}
KillItem(itemNumber);
}
}
}
void DartEmitterControl(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (item->active)
{
if (item->timer > 0)
{
item->timer--;
return;
}
else
{
item->timer = 24;
}
}
short dartItemNumber = CreateItem();
if (dartItemNumber != NO_ITEM)
{
ITEM_INFO* dartItem = &g_Level.Items[dartItemNumber];
dartItem->objectNumber = ID_DARTS;
dartItem->roomNumber = item->roomNumber;
int x = 0;
int z = 0;
switch (item->pos.yRot)
{
case 0:
z = WALL_SIZE / 2;
break;
case 0x4000:
x = WALL_SIZE / 2;
break;
case -0x8000:
z = -WALL_SIZE / 2;
break;
case -0x4000:
x = -WALL_SIZE / 2;
break;
}
dartItem->pos.xPos = x + item->pos.xPos;
dartItem->pos.yPos = item->pos.yPos - WALL_SIZE / 2;
dartItem->pos.zPos = z + item->pos.zPos;
InitialiseItem(dartItemNumber);
dartItem->pos.xRot = 0;
dartItem->pos.yRot = item->pos.yRot + -ANGLE(180);
dartItem->speed = 256;
int xf = 0;
int zf = 0;
if (x)
xf = abs(2 * x) - 1;
else
zf = abs(2 * z) - 1;
for (int i = 0; i < 5; i++)
{
int random = -GetRandomControl();
int xv = 0;
int zv = 0;
if (z >= 0)
zv = zf & random;
else
zv = -(zf & random);
if (x >= 0)
xv = xf & random;
else
xv = -(xf & random);
TriggerDartSmoke(dartItem->pos.xPos, dartItem->pos.yPos, dartItem->pos.zPos, xv, zv, false);
}
AddActiveItem(dartItemNumber);
dartItem->status = ITEM_ACTIVE;
SoundEffect(SFX_TR4_DART_SPITT, &dartItem->pos, 0);
}
}
void TriggerDartSmoke(int x, int y, int z, int xv, int zv, bool hit)
{
int dx = LaraItem->pos.xPos - x;
int dz = LaraItem->pos.zPos - z;
if (dx < -16384 || dx > 16384 || dz < -16384 || dz > 16384)
return;
SPARKS* spark = &Sparks[GetFreeSpark()];
spark->on = true;
spark->sR = 16;
spark->sG = 8;
spark->sB = 4;
spark->dR = 64;
spark->dG = 48;
spark->dB = 32;
spark->colFadeSpeed = 8;
spark->fadeToBlack = 4;
spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 32;
spark->x = x + ((GetRandomControl() & 31) - 16);
spark->y = y + ((GetRandomControl() & 31) - 16);
spark->z = z + ((GetRandomControl() & 31) - 16);
if (hit)
{
spark->xVel = -xv + ((GetRandomControl() & 255) - 128);
spark->yVel = -(GetRandomControl() & 3) - 4;
spark->zVel = -zv + ((GetRandomControl() & 255) - 128);
spark->friction = 3;
}
else
{
if (xv)
spark->xVel = -xv;
else
spark->xVel = ((GetRandomControl() & 255) - 128);
spark->yVel = -(GetRandomControl() & 3) - 4;
if (zv)
spark->zVel = -zv;
else
spark->zVel = ((GetRandomControl() & 255) - 128);
spark->friction = 3;
}
spark->friction = 3;
if (GetRandomControl() & 1)
{
spark->flags = SP_EXPDEF | SP_ROTATE | SP_DEF | SP_SCALE;
spark->rotAng = GetRandomControl() & 0xFFF;
if (GetRandomControl() & 1)
spark->rotAdd = -16 - (GetRandomControl() & 0xF);
else
spark->rotAdd = (GetRandomControl() & 0xF) + 16;
}
else
{
spark->flags = SP_EXPDEF | SP_DEF | SP_SCALE;
}
spark->scalar = 1;
int size = (GetRandomControl() & 63) + 72;
if (hit)
{
size >>= 1;
spark->size = spark->sSize = size >> 2;
spark->gravity = spark->maxYvel = 0;
}
else
{
spark->size = spark->sSize = size >> 4;
spark->gravity = -(GetRandomControl() & 3) - 4;
spark->maxYvel = -(GetRandomControl() & 3) - 4;
}
spark->dSize = size;
}
}

View file

@ -0,0 +1,8 @@
#pragma once
namespace TEN::Entities::Traps
{
void DartControl(short itemNumber);
void DartEmitterControl(short itemNumber);
void TriggerDartSmoke(int x, int y, int z, int xv, int zv, bool hit);
}

View file

@ -24,11 +24,15 @@
#include "steel_door.h"
#include "underwater_door.h"
// Traps
#include "Objects/Generic/Traps/dart_emitter.h"
/// necessary import
#include "setup.h"
using namespace TEN::Entities::Switches;
using namespace TEN::Entities::Doors;
using namespace TEN::Entities::Traps;
static void StartObject()
{
@ -396,8 +400,42 @@ void StartDoors()
}
}
void StartTraps()
{
OBJECT_INFO* obj;
obj = &Objects[ID_DARTS];
if (obj->loaded)
{
obj->shadowSize = UNIT_SHADOW / 2;
//obj->drawRoutine = DrawDart;
obj->collision = ObjectCollision;
obj->control = DartControl;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_DART_EMITTER];
if (obj->loaded)
{
obj->control = DartEmitterControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_HOMING_DART_EMITTER];
if (obj->loaded)
{
obj->control = DartEmitterControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
}
void InitialiseGenericObjects()
{
StartTraps();
StartObject();
StartSwitches();
StartDoors();

View file

@ -14,6 +14,9 @@
#include "Sound\sound.h"
#include "itemdata/creature_info.h"
#include "collide.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
enum TonyFlameType
{
@ -51,7 +54,7 @@ enum TONY_STATE
static BOSS_STRUCT BossData;
#define TONYBOSS_TURN ANGLE(2.0f)
#define TONYBOSS_HITS 100
#define TONYBOSS_HITS 1 //Tony Harder To Kill, was 100 (6 shotgun shots)
#define MAX_TONY_TRIGGER_RANGE 0x4000
static void TriggerTonyEffect(const TONY_FLAME flame)
@ -427,7 +430,7 @@ void ControlTonyFireBall(short fxNumber)
LaraItem->hitStatus = true;
KillEffect(fxNumber);
LaraItem->hitPoints -= 200;
LaraBurn();
//LaraBurn();
return;
}
}

View file

@ -11,6 +11,9 @@
#include "setup.h"
#include "level.h"
#include "itemdata/creature_info.h"
#include <Objects/Generic/Traps/dart_emitter.h>
using namespace TEN::Entities::Traps;
BITE_INFO tribesmanAxeBite = { 0, 16, 265, 13 };
BITE_INFO tribesmanDartsBite1 = { 0, 0, -200, 13 };

View file

@ -12,6 +12,9 @@
#include "people.h"
#include "effects/tomb4fx.h"
#include "tr4_wraith_info.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
constexpr auto WRAITH_COUNT = 8;

View file

@ -10,6 +10,9 @@
#include "effects/tomb4fx.h"
#include "input.h"
#include "animation.h"
#include <Game/effects/lightning.h>
using namespace TEN::Effects::Lightning;
void InitialiseObelisk(short itemNumber)
{

View file

@ -1,140 +0,0 @@
#include "framework.h"
#include "tr5_dart_emitter.h"
#include "level.h"
#include "lara.h"
#include "effects\effects.h"
#include "items.h"
#include "Sound\sound.h"
void DartControl(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (item->touchBits)
{
LaraItem->hitPoints -= 25;
LaraItem->hitStatus = true;
Lara.poisoned += 160;
DoBloodSplat(item->pos.xPos, item->pos.yPos, item->pos.zPos, (GetRandomControl() & 3) + 4, LaraItem->pos.yRot, LaraItem->roomNumber);
KillItem(itemNumber);
}
else
{
item->pos.xPos += item->speed * phd_sin(item->pos.yRot);
item->pos.yPos -= item->speed * phd_sin(item->pos.xRot);
item->pos.xPos += item->speed * phd_cos(item->pos.yRot);
short roomNumber = item->roomNumber;
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &roomNumber);
if (item->roomNumber != roomNumber)
ItemNewRoom(itemNumber, roomNumber);
int height = GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
item->floor = height;
if (item->pos.yPos >= height)
{
for (int i = 0; i < 4; i++)
{
TriggerDartSmoke(item->pos.xPos, item->pos.yPos, item->pos.zPos, 0, 0, 1);
}
KillItem(itemNumber);
}
}
}
void DartEmitterControl(short itemNumber)
{
ITEM_INFO* item = &g_Level.Items[itemNumber];
if (item->active)
{
if (item->timer > 0)
{
item->timer--;
return;
}
else
{
item->timer = 24;
}
}
short dartItemNumber = CreateItem();
if (dartItemNumber != NO_ITEM)
{
ITEM_INFO* dartItem = &g_Level.Items[dartItemNumber];
dartItem->objectNumber = ID_DARTS;
dartItem->roomNumber = item->roomNumber;
int x = 0;
int z = 0;
if (item->pos.yRot > 0)
{
if (item->pos.yRot == ANGLE(90.0f))
x = 512;
}
else if (item->pos.yRot < 0)
{
if (item->pos.yRot == -ANGLE(180.0f))
{
z = -512;
}
else if (item->pos.yRot == -ANGLE(90.0f))
{
x = -512;
}
}
else
{
z = 512;
}
dartItem->pos.xPos = x + item->pos.xPos;
dartItem->pos.yPos = item->pos.yPos - 512;
dartItem->pos.zPos = z + item->pos.zPos;
InitialiseItem(dartItemNumber);
dartItem->pos.xRot = 0;
dartItem->pos.yRot = item->pos.yRot + -ANGLE(180);
dartItem->speed = 256;
int xf = 0;
int zf = 0;
if (x)
xf = abs(2 * x) - 1;
else
zf = abs(2 * z) - 1;
for (int i = 0; i < 5; i++)
{
int random = -GetRandomControl();
int xv = 0;
int zv = 0;
if (z >= 0)
zv = zf & random;
else
zv = -(zf & random);
if (x >= 0)
xv = xf & random;
else
xv = -(xf & random);
TriggerDartSmoke(dartItem->pos.xPos, dartItem->pos.yPos, dartItem->pos.zPos, xv, zv, 0);
}
AddActiveItem(dartItemNumber);
dartItem->status = ITEM_ACTIVE;
SoundEffect(SFX_TR4_DART_SPITT, &dartItem->pos, 0);
}
}

View file

@ -1,4 +0,0 @@
#pragma once
void DartControl(short itemNumber);
void DartEmitterControl(short itemNumber);

View file

@ -13,6 +13,11 @@
#include "level.h"
#include "Sound\sound.h"
#include "itemdata/creature_info.h"
#include "Game/effects/lightning.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Effects::Lightning;
#define STATE_HITMAN_STOP 1
#define STATE_HITMAN_WALK 2

View file

@ -15,12 +15,17 @@
#include "lara.h"
#include "Sound\sound.h"
#include "tr5_laserhead_info.h"
#include <Game/effects/lightning.h>
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Effects::Lightning;
struct LASER_HEAD_STRUCT
{
PHD_VECTOR target;
ENERGY_ARC* fireArcs[2];
ENERGY_ARC* chargeArcs[4];
LIGHTNING_INFO* fireArcs[2];
LIGHTNING_INFO* chargeArcs[4];
bool LOS[2];
byte byte1;
byte byte2;
@ -94,7 +99,7 @@ static void LaserHeadCharge(ITEM_INFO* item)
for (int i = 0; i < 4; i++)
{
ENERGY_ARC* arc = LaserHeadData.chargeArcs[i];
LIGHTNING_INFO* arc = LaserHeadData.chargeArcs[i];
if (item->itemFlags[3] & 0x0F && arc != NULL)
{
@ -109,7 +114,7 @@ static void LaserHeadCharge(ITEM_INFO* item)
src.y = GuardianChargePositions[i].y;
src.z = GuardianChargePositions[i].z;
GetJointAbsPosition(&g_Level.Items[creature->baseItem], &src, 0);
LaserHeadData.chargeArcs[i] = TriggerEnergyArc(&src, &dest, 0, g, b, 256, 90, 64, ENERGY_ARC_NO_RANDOMIZE, ENERGY_ARC_STRAIGHT_LINE); // (GetRandomControl() & 7) + 8, v4 | ((v1 | 0x240000) << 8), 13, 48, 3);
//LaserHeadData.chargeArcs[i] = TriggerEnergyArc(&src, &dest, 0, g, b, 256, 90, 64, ENERGY_ARC_NO_RANDOMIZE, ENERGY_ARC_STRAIGHT_LINE); // (GetRandomControl() & 7) + 8, v4 | ((v1 | 0x240000) << 8), 13, 48, 3);
}
}
@ -135,7 +140,7 @@ static void LaserHeadCharge(ITEM_INFO* item)
if (!(GlobalCounter & 3))
{
TriggerEnergyArc(&dest, (PHD_VECTOR*)&item->pos, 0, g, b, 256, 3, 64, ENERGY_ARC_NO_RANDOMIZE, ENERGY_ARC_STRAIGHT_LINE);
//TriggerEnergyArc(&dest, (PHD_VECTOR*)&item->pos, 0, g, b, 256, 3, 64, ENERGY_ARC_NO_RANDOMIZE, ENERGY_ARC_STRAIGHT_LINE);
//TriggerEnergyArc(&dest, &item->pos, (GetRandomControl() & 7) + 8, v4 | ((v1 | 0x180000) << 8), 13, 64, 3);
}
@ -427,7 +432,7 @@ void LaserHeadControl(short itemNumber)
g = (GetRandomControl() & 0x1F) + 128;
b = (GetRandomControl() & 0x1F) + 64;
ENERGY_ARC* arc = LaserHeadData.fireArcs[0];
LIGHTNING_INFO* arc = LaserHeadData.fireArcs[0];
if (!LaserHeadData.fireArcs[0])
arc = LaserHeadData.fireArcs[1];
@ -485,12 +490,12 @@ void LaserHeadControl(short itemNumber)
// Start firing from eye
src.roomNumber = item->roomNumber;
LaserHeadData.LOS[i] = LOS(&src, &dest);
LaserHeadData.fireArcs[i] = TriggerEnergyArc((PHD_VECTOR*)& src, (PHD_VECTOR*)& dest, r, g, b, 32, 64, 64, ENERGY_ARC_NO_RANDOMIZE, ENERGY_ARC_STRAIGHT_LINE); // (GetRandomControl() & 7) + 4, b | ((&unk_640000 | g) << 8), 12, 64, 5);
//LaserHeadData.fireArcs[i] = TriggerEnergyArc((PHD_VECTOR*)& src, (PHD_VECTOR*)& dest, r, g, b, 32, 64, 64, ENERGY_ARC_NO_RANDOMIZE, ENERGY_ARC_STRAIGHT_LINE); // (GetRandomControl() & 7) + 4, b | ((&unk_640000 | g) << 8), 12, 64, 5);
StopSoundEffect(SFX_TR5_GOD_HEAD_CHARGE);
SoundEffect(SFX_TR5_GOD_HEAD_BLAST, &item->pos, 0);
}
ENERGY_ARC* currentArc = LaserHeadData.fireArcs[i];
LIGHTNING_INFO* currentArc = LaserHeadData.fireArcs[i];
if (GlobalCounter & 1)
{

View file

@ -14,6 +14,9 @@
#include "lara.h"
#include "Sound\sound.h"
#include "itemdata/creature_info.h"
#include <Game/effects/lightning.h>
using namespace TEN::Effects::Lightning;
#define STATE_ROMAN_STATUE_STOP 1
#define STATE_ROMAN_STATUE_SCREAMING 2
@ -34,7 +37,7 @@
struct ROMAN_STATUE_STRUCT
{
PHD_VECTOR pos;
ENERGY_ARC* energyArcs[8];
LIGHTNING_INFO* energyArcs[8];
int counter;
};
@ -364,7 +367,7 @@ void RomanStatueControl(short itemNumber)
short roomNumber;
PHD_3DPOS attackPos;
byte r, g, b;
ENERGY_ARC* arc;
LIGHTNING_INFO* arc;
short random;
switch (item->currentAnimState)
@ -857,15 +860,15 @@ void RomanStatueControl(short itemNumber)
{
if (deltaFrame == 24)
{
TriggerEnergyArc(&pos1, &pos2, 0, ((GetRandomControl() & 0x3F) + 128),
/*TriggerEnergyArc(&pos1, &pos2, 0, ((GetRandomControl() & 0x3F) + 128),
(((GetRandomControl() & 0x3F) + 128) / 2), 256, 32, 32, ENERGY_ARC_NO_RANDOMIZE,
ENERGY_ARC_STRAIGHT_LINE);
ENERGY_ARC_STRAIGHT_LINE);*/
}
}
else
{
TriggerEnergyArc(&pos1, &pos2, 0, g, b, 256, 24, 32, ENERGY_ARC_NO_RANDOMIZE,
ENERGY_ARC_STRAIGHT_LINE);
/*TriggerEnergyArc(&pos1, &pos2, 0, g, b, 256, 24, 32, ENERGY_ARC_NO_RANDOMIZE,
ENERGY_ARC_STRAIGHT_LINE);*/
/*RomanStatueData.energyArcs[i] = TriggerEnergyArc(
&pos1,

View file

@ -15,6 +15,9 @@
#include "tr5_roman_statue.h"
#include "tr5_hydra.h"
#include "collide.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
int DebrisFlags;

View file

@ -14,7 +14,9 @@
#include "generic_switch.h"
#include "collide.h"
#include "control/box.h"
#include "Game/effects/lara_burn.h"
using namespace TEN::Effects::Fire;
using namespace TEN::Entities::Switches;
void InitialiseExplosion(short itemNumber)

View file

@ -25,7 +25,6 @@
#include "tr5_rats_emitter.h"
#include "tr5_bats_emitter.h"
#include "tr5_spider_emitter.h"
#include "tr5_dart_emitter.h"
#include "tr5_smoke_emitter.h"
/// objects
#include "tr5_pushableblock.h"
@ -1145,34 +1144,6 @@ static void StartTrap(OBJECT_INFO *obj)
obj->saveAnim = true;
}
obj = &Objects[ID_DARTS];
if (obj->loaded)
{
obj->shadowSize = UNIT_SHADOW / 2;
//obj->drawRoutine = DrawDart;
obj->collision = ObjectCollision;
obj->control = DartControl;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_DART_EMITTER];
if (obj->loaded)
{
obj->control = DartEmitterControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_HOMING_DART_EMITTER];
if (obj->loaded)
{
obj->control = DartEmitterControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_GEN_SLOT3];
if (obj->loaded)
{

View file

@ -19,6 +19,9 @@
#include "Quad/RenderQuad.h"
#include "particle/SimpleParticle.h"
#include "Renderer/RendererSprites.h"
#include <Game/effects/lightning.h>
using namespace TEN::Effects::Lightning;
extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD];
extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE];
@ -30,7 +33,6 @@ extern GUNFLASH_STRUCT Gunflashes[MAX_GUNFLASH]; // offset 0xA31D8
extern SPARKS Sparks[MAX_SPARKS];
extern SPLASH_STRUCT Splashes[MAX_SPLASHES];
extern RIPPLE_STRUCT Ripples[MAX_RIPPLES];
extern ENERGY_ARC EnergyArcs[MAX_ENERGYARCS];
BITE_INFO EnemyBites[9] =
{
@ -51,9 +53,9 @@ namespace TEN::Renderer
using std::vector;
void Renderer11::drawEnergyArcs(RenderView& view) {
for (int i = 0; i < 16; i++)
for (int i = 0; i < Lightning.size(); i++)
{
ENERGY_ARC* arc = &EnergyArcs[i];
LIGHTNING_INFO* arc = &Lightning[i];
if (arc->life)
{

View file

@ -18,6 +18,9 @@
#include "ReservedScriptNames.h"
#include "camera.h"
#include <Renderer/RenderEnums.h>
#include <Game/effects/lightning.h>
using namespace TEN::Effects::Lightning;
/***
Functions and callbacks for level-specific logic scripts.

View file

@ -27,6 +27,7 @@
#include "fullblock_switch.h"
#include "itemdata/creature_info.h"
#include <Objects/Effects/effect_objects.h>
using namespace TEN::Entities::Switches;
@ -310,46 +311,6 @@ void TrapObjects()
obj->savePosition = true;
}
// Flame is always loaded
obj = &Objects[ID_FLAME];
{
obj->control = FlameControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_FLAME_EMITTER];
if (obj->loaded)
{
obj->initialise = InitialiseFlameEmitter;
obj->collision = FlameEmitterCollision;
obj->control = FlameEmitterControl;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_FLAME_EMITTER2];
if (obj->loaded)
{
obj->initialise = InitialiseFlameEmitter2;
obj->collision = FlameEmitterCollision;
obj->control = FlameEmitter2Control;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_FLAME_EMITTER3];
if (obj->loaded)
{
obj->control = FlameEmitter3Control;
obj->drawRoutine = nullptr;
obj->saveFlags = true;
obj->usingDrawAnimatingItem = false;
}
obj = &Objects[ID_GEN_SLOT2];
if (obj->loaded)
{
@ -494,6 +455,7 @@ void InitialiseObjects()
//obj->frameBase += (short)g_Level.Frames.data();
}
InitialiseEffectsObjects();
InitialiseGenericObjects(); // Generic objects
InitialiseTR1Objects(); // Standard TR1 objects
InitialiseTR2Objects(); // Standard TR2 objects

View file

@ -142,6 +142,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClInclude Include="Game\control\trigger.h" />
<ClInclude Include="Game\control\volume.h" />
<ClInclude Include="Game\debug\debug.h" />
<ClInclude Include="Game\effects\lightning.h" />
<ClInclude Include="Game\itemdata\door_data.h" />
<ClInclude Include="Game\effects\drip.h" />
<ClInclude Include="Game\effects\explosion.h" />
@ -151,6 +152,10 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClInclude Include="Game\effects\groundfx.h" />
<ClInclude Include="Game\roomvector.h" />
<ClInclude Include="Objects\Generic\Traps\falling_block.h" />
<ClInclude Include="Objects\Effects\effect_objects.h" />
<ClInclude Include="Objects\Effects\flame_emitters.h" />
<ClInclude Include="Game\effects\lara_burn.h" />
<ClInclude Include="Objects\Generic\Traps\dart_emitter.h" />
<ClInclude Include="Objects\TR2\Vehicles\boat_info.h" />
<ClInclude Include="Game\itemdata\creature_info.h" />
<ClInclude Include="Game\itemdata\itemdata.h" />
@ -275,7 +280,6 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClInclude Include="Objects\TR5\Object\tr5_raisingblock.h" />
<ClInclude Include="Objects\TR5\Object\tr5_teleporter.h" />
<ClInclude Include="Objects\TR5\Switch\tr5_raisingcog.h" />
<ClInclude Include="Objects\TR5\Emitter\tr5_dart_emitter.h" />
<ClInclude Include="Objects\TR5\Object\tr5_missile.h" />
<ClInclude Include="Objects\TR5\Object\tr5_pushableblock.h" />
<ClInclude Include="Objects\TR5\Object\tr5_twoblockplatform.h" />
@ -560,6 +564,10 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClCompile Include="Game\pickup\pickup_weapon.cpp" />
<ClCompile Include="Game\room.cpp" />
<ClCompile Include="Objects\Generic\Traps\falling_block.cpp" />
<ClCompile Include="Objects\Effects\effect_objects.cpp" />
<ClCompile Include="Objects\Effects\flame_emitters.cpp" />
<ClCompile Include="Game\effects\lara_burn.cpp" />
<ClCompile Include="Objects\Generic\Traps\dart_emitter.cpp" />
<ClCompile Include="Specific\prng.cpp" />
<ClCompile Include="Game\puzzles_keys.cpp" />
<ClCompile Include="Objects\Generic\Doors\double_doors.cpp" />
@ -623,7 +631,6 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
<ClCompile Include="Objects\TR5\Object\tr5_raisingblock.cpp" />
<ClCompile Include="Objects\TR5\Object\tr5_teleporter.cpp" />
<ClCompile Include="Objects\TR5\Switch\tr5_raisingcog.cpp" />
<ClCompile Include="Objects\TR5\Emitter\tr5_dart_emitter.cpp" />
<ClCompile Include="Objects\TR5\Object\tr5_twoblockplatform.cpp" />
<ClCompile Include="Objects\TR5\Trap\tr5_deathslide.cpp" />
<ClCompile Include="Objects\TR5\Trap\tr5_romehammer.cpp" />

File diff suppressed because it is too large Load diff