TombEngine/TombEngine/Game/effects/effects.cpp

1945 lines
49 KiB
C++
Raw Normal View History

2020-12-21 13:16:29 -03:00
#include "framework.h"
2021-12-22 16:23:57 +03:00
#include "Game/effects/effects.h"
2021-12-24 03:32:19 +03:00
#include "Flow/ScriptInterfaceFlowHandler.h"
2021-12-24 03:32:19 +03:00
#include "Game/animation.h"
2022-02-04 22:18:55 +11:00
#include "Game/collision/collide_room.h"
2021-12-22 16:23:57 +03:00
#include "Game/effects/bubble.h"
#include "Game/effects/drip.h"
2021-12-24 03:32:19 +03:00
#include "Game/effects/explosion.h"
#include "Game/effects/item_fx.h"
2021-12-22 16:23:57 +03:00
#include "Game/effects/smoke.h"
2021-12-24 03:32:19 +03:00
#include "Game/effects/spark.h"
#include "Game/effects/tomb4fx.h"
#include "Game/effects/weather.h"
#include "Game/items.h"
#include "Game/Lara/lara.h"
#include "Game/Lara/lara_helpers.h"
#include "Math/Math.h"
2021-12-24 03:32:19 +03:00
#include "Objects/objectslist.h"
#include "Renderer/Renderer11.h"
#include "Sound/sound.h"
2022-12-12 20:08:28 +11:00
#include "Specific/clock.h"
2021-12-24 03:32:19 +03:00
#include "Specific/level.h"
#include "Specific/setup.h"
2021-09-25 11:27:47 +02:00
using namespace TEN::Effects::Environment;
2021-11-22 18:55:29 +03:00
using namespace TEN::Effects::Explosion;
using namespace TEN::Effects::Items;
2021-08-30 18:03:21 +03:00
using namespace TEN::Effects::Spark;
using namespace TEN::Math;
using namespace TEN::Math::Random;
using TEN::Renderer::g_Renderer;
2020-12-21 13:16:29 -03:00
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
// New particle class
Particle Particles[MAX_PARTICLES];
ParticleDynamic ParticleDynamics[MAX_PARTICLE_DYNAMICS];
Merge branch 'master' into item_data # Conflicts: # TR5Main/Game/Lara/lara.cpp # TR5Main/Game/Lara/lara_collide.cpp # TR5Main/Game/Lara/lara_monkey.cpp # TR5Main/Game/Lara/lara_struct.h # TR5Main/Game/Lara/lara_tests.cpp # TR5Main/Game/collide.h # TR5Main/Game/control.h # TR5Main/Game/effect.h # TR5Main/Game/effect2.cpp # TR5Main/Game/flipeffect.cpp # TR5Main/Game/floordata.h # TR5Main/Game/hair.cpp # TR5Main/Game/health.cpp # TR5Main/Game/items.cpp # TR5Main/Game/newinv2.cpp # TR5Main/Game/spotcam.cpp # TR5Main/Objects/Effects/tr4_bubbles.cpp # TR5Main/Objects/TR1/Entity/tr1_ape.cpp # TR5Main/Objects/TR1/Entity/tr1_bigrat.cpp # TR5Main/Objects/TR1/Entity/tr1_doppelganger.cpp # TR5Main/Objects/TR2/Entity/tr2_birdmonster.cpp # TR5Main/Objects/TR2/Entity/tr2_shark.cpp # TR5Main/Objects/TR2/Entity/tr2_spider.cpp # TR5Main/Objects/TR2/Entity/tr2_yeti.cpp # TR5Main/Objects/TR3/Entity/tr3_fishemitter.cpp # TR5Main/Objects/TR3/Entity/tr3_flamethrower.cpp # TR5Main/Objects/TR3/Entity/tr3_monkey.cpp # TR5Main/Objects/TR3/Entity/tr3_raptor.cpp # TR5Main/Objects/TR3/Entity/tr3_scuba.cpp # TR5Main/Objects/TR3/Entity/tr3_trex.cpp # TR5Main/Objects/TR3/Vehicles/kayak.cpp # TR5Main/Objects/TR3/Vehicles/minecart.cpp # TR5Main/Objects/TR4/Entity/tr4_bat.cpp # TR5Main/Objects/TR4/Entity/tr4_big_beetle.cpp # TR5Main/Objects/TR4/Entity/tr4_bigscorpion.cpp # TR5Main/Objects/TR4/Entity/tr4_demigod.cpp # TR5Main/Objects/TR4/Entity/tr4_dog.cpp # TR5Main/Objects/TR4/Entity/tr4_hammerhead.cpp # TR5Main/Objects/TR4/Entity/tr4_harpy.cpp # TR5Main/Objects/TR4/Entity/tr4_mutant.cpp # TR5Main/Objects/TR4/Entity/tr4_smallscorpion.cpp # TR5Main/Objects/TR4/Entity/tr4_troops.cpp # TR5Main/Objects/TR4/Entity/tr4_wildboar.cpp # TR5Main/Objects/TR4/Trap/tr4_joby_spikes.cpp # TR5Main/Objects/TR4/Vehicles/motorbike.cpp # TR5Main/Objects/TR5/Entity/tr5_doberman.cpp # TR5Main/Objects/TR5/Entity/tr5_imp.cpp # TR5Main/Objects/TR5/Entity/tr5_larson.cpp # TR5Main/Objects/TR5/Entity/tr5_lion.cpp # TR5Main/Objects/TR5/Entity/tr5_reaper.cpp # TR5Main/Objects/TR5/Object/tr5_pushableblock.cpp # TR5Main/Objects/TR5/Object/tr5_rollingball.cpp # TR5Main/Objects/TR5/Trap/tr5_fallingceiling.cpp # TR5Main/Renderer/Renderer11Draw2D.cpp # TR5Main/Specific/input.cpp # TR5Main/Specific/level.cpp # TR5Main/TombEngine.vcxproj.filters
2021-08-31 17:37:15 +02:00
FX_INFO EffectList[NUM_EFFECTS];
2020-12-21 13:16:29 -03:00
2022-10-14 12:16:55 +11:00
GameBoundingBox DeadlyBounds;
2020-12-21 13:16:29 -03:00
SPLASH_SETUP SplashSetup;
SPLASH_STRUCT Splashes[MAX_SPLASHES];
RIPPLE_STRUCT Ripples[MAX_RIPPLES];
int SplashCount = 0;
2022-09-06 21:14:10 +10:00
Vector3i NodeVectors[MAX_NODE];
NODEOFFSET_INFO NodeOffsets[MAX_NODE] =
{
{ -16, 40, 160, -LM_LHAND, false }, // TR5 offset 0
2020-12-21 13:16:29 -03:00
{ -16, -8, 160, 0, false }, // TR5 offset 1
{ 0, 0, 256, 8, false }, // TR5 offset 2
{ 0, 0, 256, 17, false }, // TR5 offset 3
{ 0, 0, 256, 26, false }, // TR5 offset 4
{ 0, 144, 40, 10, false }, // TR5 offset 5
{ -40, 64, 360, 14, false }, // TR5 offset 6
{ 0, -600, -40, 0, false }, // TR5 offset 7
{ 0, 32, 16, 9, false }, // TR5 offset 8
{ 0, 340, 0, 7, false }, // TR3 offset 0
{ 0, 0, -96, 10, false }, // TR3 offset 1
{ 13, 48, 320, 13, false }, // TR3 offset 2
{ 0, -256, 0, 5, false }, // TR3 offset 3
{ 0, 64, 0, 10, false }, // TR3 offset 4 // tony left
{ 0, 64, 0, 13, false }, // TR3 offset 5 // tony right
{ -32, -16, -192, 13, false }, // TR3 offset 6
{ -64, 410, 0, 20, false }, // TR3 offset 7
{ 64, 410, 0, 23, false }, // TR3 offset 8
{ -160, -8, 16, 5, false }, // TR3 offset 9
{ -160, -8, 16, 9, false }, // TR3 offset 10
{ -160, -8, 16, 13, false }, // TR3 offset 11
{ 0, 0, 0, 0, false }, // TR3 offset 12
{ 0, 0, 0, 0, false }, // Empty
};
void DetatchSpark(int number, SpriteEnumFlag type)
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* sptr = &Particles[0];
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
for (int lp = 0; lp < MAX_PARTICLES; lp++, sptr++)
2020-12-21 13:16:29 -03:00
{
if (sptr->on && (sptr->flags & type) && sptr->fxObj == number)
2020-12-21 13:16:29 -03:00
{
switch (type)
{
case SP_FX:
2021-08-02 15:40:51 +03:00
if (sptr->flags & SP_DAMAGE)
2020-12-21 13:16:29 -03:00
sptr->on = false;
else
{
auto* fx = &EffectList[number];
2022-03-31 23:55:54 +11:00
sptr->x += fx->pos.Position.x;
sptr->y += fx->pos.Position.y;
sptr->z += fx->pos.Position.z;
2020-12-21 13:16:29 -03:00
sptr->flags &= ~SP_FX;
}
2020-12-21 13:16:29 -03:00
break;
2020-12-21 13:16:29 -03:00
case SP_ITEM:
2021-08-02 15:40:51 +03:00
if (sptr->flags & SP_DAMAGE)
2020-12-21 13:16:29 -03:00
sptr->on = false;
else
{
auto* item = &g_Level.Items[number];
2022-03-31 23:55:54 +11:00
sptr->x += item->Pose.Position.x;
sptr->y += item->Pose.Position.y;
sptr->z += item->Pose.Position.z;
2020-12-21 13:16:29 -03:00
sptr->flags &= ~SP_ITEM;
}
2020-12-21 13:16:29 -03:00
break;
}
}
}
}
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
Particle* GetFreeParticle()
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
int result = -1;
// Get first free available spark
2020-12-21 13:16:29 -03:00
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
for (int i = 0; i < MAX_PARTICLES; i++)
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* particle = &Particles[i];
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
if (!particle->on)
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
result = i;
break;
2020-12-21 13:16:29 -03:00
}
}
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
// No free sparks left, hijack existing one with less possible life
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
int life = INT_MAX;
if (result == -1)
{
for (int i = 0; i < MAX_PARTICLES; i++)
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* particle = &Particles[i];
if (particle->life < life && particle->dynamic == -1 && !(particle->flags & SP_EXPLOSION))
{
result = i;
life = particle->life;
}
2020-12-21 13:16:29 -03:00
}
}
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = &Particles[result];
2020-12-21 13:16:29 -03:00
spark->extras = 0;
spark->dynamic = -1;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->spriteIndex = Objects[ID_DEFAULT_SPRITES].meshIndex;
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
return spark;
2020-12-21 13:16:29 -03:00
}
void SetSpriteSequence(Particle& particle, GAME_OBJECT_ID objectID)
{
2023-01-14 11:57:06 +11:00
if (particle.life <= 0)
{
particle.on = false;
ParticleDynamics[particle.dynamic].On = false;
}
2023-01-14 11:57:06 +11:00
float particleAge = particle.sLife - particle.life;
if (particleAge > particle.life )
2023-01-14 11:57:06 +11:00
return;
int numSprites = -Objects[objectID].nmeshes - 1;
float normalizedAge = particleAge / particle.life;
particle.spriteIndex = Objects[objectID].meshIndex + (int)round(Lerp(0.0f, numSprites, normalizedAge));
}
2020-12-21 13:16:29 -03:00
void UpdateSparks()
{
2022-10-14 12:16:55 +11:00
auto bounds = GameBoundingBox(LaraItem);
DeadlyBounds = GameBoundingBox(
LaraItem->Pose.Position.x + bounds.X1,
LaraItem->Pose.Position.x + bounds.X2,
LaraItem->Pose.Position.y + bounds.Y1,
LaraItem->Pose.Position.y + bounds.Y2,
LaraItem->Pose.Position.z + bounds.Z1,
LaraItem->Pose.Position.z + bounds.Z2);
2020-12-21 13:16:29 -03:00
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
for (int i = 0; i < MAX_PARTICLES; i++)
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = &Particles[i];
2020-12-21 13:16:29 -03:00
if (spark->on)
{
spark->life--;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
2020-12-21 13:16:29 -03:00
if (!spark->life)
{
if (spark->dynamic != -1)
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
ParticleDynamics[spark->dynamic].On = false;
2020-12-21 13:16:29 -03:00
spark->on = false;
continue;
}
2020-12-21 13:16:29 -03:00
int life = spark->sLife - spark->life;
if (life < spark->colFadeSpeed)
{
int dl = (life << 16) / spark->colFadeSpeed;
spark->r = spark->sR + (dl * (spark->dR - spark->sR) >> 16);
spark->g = spark->sG + (dl * (spark->dG - spark->sG) >> 16);
spark->b = spark->sB + (dl * (spark->dB - spark->sB) >> 16);
2020-12-21 13:16:29 -03:00
}
else if (spark->life >= spark->fadeToBlack)
{
spark->r = spark->dR;
spark->g = spark->dG;
spark->b = spark->dB;
}
else
{
spark->r = (spark->dR * (((spark->life - spark->fadeToBlack) << 16) / spark->fadeToBlack + 0x10000)) >> 16;
spark->g = (spark->dG * (((spark->life - spark->fadeToBlack) << 16) / spark->fadeToBlack + 0x10000)) >> 16;
spark->b = (spark->dB * (((spark->life - spark->fadeToBlack) << 16) / spark->fadeToBlack + 0x10000)) >> 16;
2020-12-21 13:16:29 -03:00
if (spark->r < 8 && spark->g < 8 && spark->b < 8)
{
spark->on = 0;
continue;
}
}
if (spark->life == spark->colFadeSpeed)
{
2021-08-02 15:40:51 +03:00
if (spark->flags & SP_UNDERWEXP)
2020-12-21 13:16:29 -03:00
spark->dSize /= 4;
}
2021-08-02 15:40:51 +03:00
if (spark->flags & SP_ROTATE)
2022-07-06 09:04:14 +03:00
spark->rotAng = (spark->rotAng + spark->rotAdd) & 0x0FFF;
2020-12-21 13:16:29 -03:00
if (spark->sLife - spark->life == spark->extras >> 3 &&
spark->extras & 7)
2020-12-21 13:16:29 -03:00
{
int explosionType;
2021-08-02 15:40:51 +03:00
if (spark->flags & SP_UNDERWEXP)
{
explosionType = 1;
}
else if (spark->flags & SP_PLASMAEXP)
{
explosionType = 2;
}
2020-12-21 13:16:29 -03:00
else
{
explosionType = 0;
}
2020-12-21 13:16:29 -03:00
for (int j = 0; j < (spark->extras & 7); j++)
{
TriggerExplosionSparks(spark->x,
spark->y,
spark->z,
(spark->extras & 7) - 1,
spark->dynamic,
explosionType,
spark->roomNumber);
2020-12-21 13:16:29 -03:00
spark->dynamic = -1;
}
if (explosionType == 1)
2020-12-21 13:16:29 -03:00
{
TriggerExplosionBubble(
spark->x,
spark->y,
spark->z,
spark->roomNumber);
}
2020-12-21 13:16:29 -03:00
spark->extras = 0;
}
spark->yVel += spark->gravity;
if (spark->maxYvel)
{
if (spark->yVel > spark->maxYvel)
spark->yVel = spark->maxYvel;
}
if (spark->friction & 0xF)
{
spark->xVel -= spark->xVel >> (spark->friction & 0xF);
spark->zVel -= spark->zVel >> (spark->friction & 0xF);
}
if (spark->friction & 0xF0)
spark->yVel -= spark->yVel >> (spark->friction >> 4);
2020-12-21 13:16:29 -03:00
spark->x += spark->xVel >> 5;
spark->y += spark->yVel >> 5;
spark->z += spark->zVel >> 5;
2020-12-21 13:16:29 -03:00
2021-08-02 15:40:51 +03:00
if (spark->flags & SP_WIND)
2020-12-21 13:16:29 -03:00
{
2021-09-15 11:13:47 +03:00
spark->x += Weather.Wind().x;
spark->z += Weather.Wind().z;
2020-12-21 13:16:29 -03:00
}
int dl = ((spark->sLife - spark->life) * 65536) / spark->sLife;
spark->size = (spark->sSize + ((dl * (spark->dSize - spark->sSize)) / 65536));
if (spark->flags & SP_EXPLOSION)
SetSpriteSequence(*spark, ID_EXPLOSION_SPRITES);
2020-12-21 13:16:29 -03:00
if ((spark->flags & SP_FIRE && LaraItem->Effect.Type == EffectType::None) ||
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
(spark->flags & SP_DAMAGE) ||
(spark->flags & SP_POISON))
2020-12-21 13:16:29 -03:00
{
int ds = spark->size * (spark->scalar / 2.0);
2020-12-21 13:16:29 -03:00
if (spark->x + ds > DeadlyBounds.X1 && spark->x - ds < DeadlyBounds.X2)
2020-12-21 13:16:29 -03:00
{
if (spark->y + ds > DeadlyBounds.Y1 && spark->y - ds < DeadlyBounds.Y2)
2020-12-21 13:16:29 -03:00
{
if (spark->z + ds > DeadlyBounds.Z1 && spark->z - ds < DeadlyBounds.Z2)
2020-12-21 13:16:29 -03:00
{
2021-08-02 15:40:51 +03:00
if (spark->flags & SP_FIRE)
ItemBurn(LaraItem);
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
if (spark->flags & SP_DAMAGE)
DoDamage(LaraItem, 2);
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
if (spark->flags & SP_POISON)
Lara.PoisonPotency += 5;
2020-12-21 13:16:29 -03:00
}
}
}
}
}
}
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
for (int i = 0; i < MAX_PARTICLES; i++)
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = &Particles[i];
2020-12-21 13:16:29 -03:00
if (spark->on && spark->dynamic != -1)
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* dynsp = &ParticleDynamics[spark->dynamic];
2020-12-21 13:16:29 -03:00
if (dynsp->Flags & 3)
{
int random = GetRandomControl();
int x = spark->x + 16 * (random & 0xF);
int y = spark->y + (random & 0xF0);
int z = spark->z + ((random >> 4) & 0xF0);
2020-12-21 13:16:29 -03:00
byte r, g, b;
int dl = spark->sLife - spark->life - 1;
if (dl >= 2)
{
if (dl >= 4)
{
if (dynsp->Falloff)
dynsp->Falloff--;
b = ((random >> 4) & 0x1F) + 128;
2020-12-21 13:16:29 -03:00
g = (random & 0x1F) + 224;
r = (random >> 8) & 0x3F;
2020-12-21 13:16:29 -03:00
}
else
{
if (dynsp->Falloff < 28)
dynsp->Falloff += 6;
b = -8 * dl + 128;
g = -8 * dl - (random & 0x1F) + 255;
r = 32 * (4 - dl);
2020-12-21 13:16:29 -03:00
if (32 * (4 - dl) < 0)
r = 0;
}
}
else
{
if (dynsp->Falloff < 28)
dynsp->Falloff += 6;
g = 255 - 8 * dl - (random & 0x1F);
b = 255 - 16 * dl - (random & 0x1F);
r = 255 - (dl << 6) - (random & 0x1F);
2020-12-21 13:16:29 -03:00
}
if (spark->flags & SP_PLASMAEXP)
2020-12-21 13:16:29 -03:00
{
int falloff;
if (dynsp->Falloff <= 28)
falloff = dynsp->Falloff;
else
falloff = 31;
TriggerDynamicLight(x, y, z, falloff, r, g, b);
}
else
{
int falloff;
if (dynsp->Falloff <= 28)
falloff = dynsp->Falloff;
else
falloff = 31;
TriggerDynamicLight(x, y, z, falloff, g, b, r);
}
}
}
}
}
2022-12-06 13:28:13 +11:00
void TriggerRicochetSpark(const GameVector& pos, short angle, int count, int unk)
2020-12-21 13:16:29 -03:00
{
2022-12-06 13:28:13 +11:00
TriggerRicochetSpark(pos, angle, count);
2020-12-21 13:16:29 -03:00
}
void TriggerCyborgSpark(int x, int y, int z, short xv, short yv, short zv)
{
2022-03-31 23:55:54 +11:00
int dx = LaraItem->Pose.Position.x - x;
int dz = LaraItem->Pose.Position.z - z;
2020-12-21 13:16:29 -03:00
if (dx >= -BLOCK(16) && dx <= BLOCK(16) &&
dz >= -BLOCK(16) && dz <= BLOCK(16))
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = GetFreeParticle();
2020-12-21 13:16:29 -03:00
int random = rand();
spark->sR = -1;
spark->sB = -1;
spark->sG = -1;
spark->dR = -1;
spark->on = true;
spark->colFadeSpeed = 3;
spark->fadeToBlack = 5;
spark->dG = (random & 0x7F) + 64;
spark->dB = -64 - ((random & 0x7F) + 64);
spark->life = 10;
spark->sLife = 10;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
spark->friction = 34;
spark->scalar = 1;
spark->x = (random & 7) + x - 3;
spark->y = ((random >> 3) & 7) + y - 3;
spark->z = ((random >> 6) & 7) + z - 3;
2020-12-21 13:16:29 -03:00
spark->flags = SP_SCALE;
spark->xVel = (random >> 2) + xv - 128;
spark->yVel = (random >> 4) + yv - 128;
spark->zVel = (random >> 6) + zv - 128;
spark->sSize = spark->size = ((random >> 9) & 3) + 4;
spark->dSize = ((random >> 12) & 1) + 1;
2020-12-21 13:16:29 -03:00
spark->maxYvel = 0;
spark->gravity = 0;
}
}
void TriggerExplosionSparks(int x, int y, int z, int extraTrig, int dynamic, int uw, int roomNumber)
{
2023-01-14 12:14:18 +11:00
static constexpr auto rotationMax = 30;
static constexpr auto lifeMax = 44;
static const auto extrasTable = std::array<unsigned char, 4>{ 0, 4, 7, 10 };
int dx = LaraItem->Pose.Position.x - x;
int dz = LaraItem->Pose.Position.z - z;
int scalar = 1;
if (dx < -BLOCK(16) || dx > BLOCK(16) ||
dz < -BLOCK(16) || dz > BLOCK(16))
{
return;
}
if (roomNumber < 0)
{
roomNumber = -roomNumber;
scalar = 1;
}
auto& spark = *GetFreeParticle();
spark.on = true;
spark.sR = 255;
if (uw == 1)
{
spark.sG = (GetRandomControl() & 0x3F) + 128;
spark.sB = 32;
spark.dR = 192;
spark.dG = (GetRandomControl() & 0x1F) + 64;
spark.dB = 0;
spark.colFadeSpeed = 7;
spark.fadeToBlack = 8;
spark.life = (GetRandomControl() & 7) + 16;
spark.sLife = spark.life;
spark.roomNumber = roomNumber;
}
else
{
spark.sG = (GetRandomControl() & 0xF) + 32;
spark.sB = 0;
spark.dR = (GetRandomControl() & 0x3F) + 192;
spark.dG = (GetRandomControl() & 0x3F) + 128;
spark.dB = 32;
spark.colFadeSpeed = 8;
spark.fadeToBlack = 16;
2023-01-14 11:57:06 +11:00
spark.life = (GetRandomControl() & 7) + lifeMax;
spark.sLife = spark.life;
}
spark.extras = unsigned char(extraTrig | ((extrasTable[extraTrig] + (GetRandomControl() & 7) + 28) << 3));
spark.dynamic = (char)dynamic;
if (dynamic == -2)
{
int i = 0;
for (i = 0; i < 8; i++)
{
auto dynsp = &ParticleDynamics[i];
if (!dynsp->On)
{
dynsp->On = true;
dynsp->Falloff = 4;
if (uw == 1)
dynsp->Flags = 2;
else
dynsp->Flags = 1;
spark.dynamic = (char)i;
break;
}
}
if (i == 8)
spark.dynamic = -1;
}
spark.xVel = (GetRandomControl() & 0xFFF) - 2048;
spark.yVel = (GetRandomControl() & 0xFFF) - 2048;
spark.zVel = (GetRandomControl() & 0xFFF) - 2048;
if (dynamic != -2 || uw == 1)
{
spark.x = (GetRandomControl() & 0x1F) + x - 16;
spark.y = (GetRandomControl() & 0x1F) + y - 16;
spark.z = (GetRandomControl() & 0x1F) + z - 16;
}
else
{
spark.x = (GetRandomControl() & 0x1FF) + x - 256;
spark.y = (GetRandomControl() & 0x1FF) + y - 256;
spark.z = (GetRandomControl() & 0x1FF) + z - 256;
}
if (uw == 1)
{
spark.friction = 17;
}
else
spark.friction = 51;
if (GetRandomControl() & 1)
{
if (uw == 1)
spark.flags = SP_SCALE | SP_DEF | SP_ROTATE | SP_EXPDEF | SP_UNDERWEXP;
else
spark.flags = SP_SCALE | SP_DEF | SP_ROTATE | SP_EXPDEF | SP_EXPLOSION;
spark.rotAng = GetRandomControl() & 0xF;
2023-01-14 11:57:06 +11:00
spark.rotAdd = (GetRandomControl() & 0xF) + rotationMax;
}
else if (uw == 1)
{
spark.flags = SP_SCALE | SP_DEF | SP_EXPDEF | SP_UNDERWEXP;
}
else
{
spark.flags = SP_SCALE | SP_DEF | SP_EXPDEF | SP_EXPLOSION;
}
spark.scalar = 3;
spark.gravity = 0;
spark.size = (GetRandomControl() & 0xF) + 40;
spark.sSize = spark.size * scalar;
spark.dSize = spark.size * (scalar + 1);
spark.size *= scalar;
GetRandomControl();
spark.maxYvel = 0;
if (uw == 2)
{
unsigned char r = spark.sR;
unsigned char g = spark.sG;
unsigned char b = spark.sB;
spark.sR = b;
spark.sG = r;
spark.sB = g;
r = spark.dR;
g = spark.dG;
b = spark.dB;
spark.dR = b;
spark.dG = r;
spark.dB = g;
spark.flags |= SP_PLASMAEXP;
}
else if (extraTrig)
{
TriggerExplosionSmoke(x, y, z, uw);
}
else
{
TriggerExplosionSmokeEnd(x, y, z, uw);
}
2020-12-21 13:16:29 -03:00
}
void TriggerExplosionBubbles(int x, int y, int z, short roomNumber)
{
2022-03-31 23:55:54 +11:00
int dx = LaraItem->Pose.Position.x - x;
int dz = LaraItem->Pose.Position.z - z;
2020-12-21 13:16:29 -03:00
if (dx >= -BLOCK(16) && dx <= BLOCK(16) &&
dz >= -BLOCK(16) && dz <= BLOCK(16))
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = GetFreeParticle();
2020-12-21 13:16:29 -03:00
spark->sR = 128;
spark->dR = 128;
spark->dG = 128;
spark->dB = 128;
2020-12-21 13:16:29 -03:00
spark->on = 1;
spark->life = 24;
spark->sLife = 24;
spark->sG = 64;
spark->sB = 0;
spark->colFadeSpeed = 8;
spark->fadeToBlack = 12;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
spark->x = x;
spark->y = y;
spark->z = z;
spark->xVel = 0;
spark->yVel = 0;
spark->zVel = 0;
spark->friction = 0;
spark->flags = SP_UNDERWEXP | SP_DEF | SP_SCALE;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->spriteIndex = Objects[ID_DEFAULT_SPRITES].meshIndex + 13;
2020-12-21 13:16:29 -03:00
spark->scalar = 3;
spark->gravity = 0;
spark->maxYvel = 0;
2020-12-21 13:16:29 -03:00
int size = (GetRandomControl() & 7) + 63;
spark->sSize = size >> 1;
spark->size = size >> 1;
2020-12-21 13:16:29 -03:00
spark->dSize = 2 * size;
for (int i = 0; i < 8; i++)
{
2022-09-06 21:14:10 +10:00
Vector3i pos;
2020-12-21 13:16:29 -03:00
pos.x = (GetRandomControl() & 0x1FF) + x - 256;
pos.y = (GetRandomControl() & 0x7F) + y - 64;
pos.z = (GetRandomControl() & 0x1FF) + z - 256;
CreateBubble(&pos, roomNumber, 6, 15, 0, 0, 0, 0);
}
}
}
void TriggerExplosionSmokeEnd(int x, int y, int z, int uw)
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = GetFreeParticle();
2020-12-21 13:16:29 -03:00
spark->on = true;
2020-12-21 13:16:29 -03:00
if (uw)
{
spark->sR = 0;
spark->sG = 0;
spark->sB = 0;
spark->dR = 192;
spark->dG = 192;
spark->dB = 208;
}
else
{
spark->dR = 64;
spark->sR = 144;
spark->sG = 144;
spark->sB = 144;
spark->dG = 64;
spark->dB = 64;
}
2020-12-21 13:16:29 -03:00
spark->colFadeSpeed = 8;
spark->fadeToBlack = 64;
spark->life = spark->sLife= (GetRandomControl() & 0x1F) + 96;
2020-12-21 13:16:29 -03:00
if (uw)
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
else
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_SUBTRACTIVE;
2020-12-21 13:16:29 -03:00
spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16;
spark->z = (GetRandomControl() & 0x1F) + z - 16;
spark->xVel = ((GetRandomControl() & 0xFFF) - 2048) >> 2;
2020-12-21 13:16:29 -03:00
spark->yVel = GetRandomControl() - 128;
spark->zVel = ((GetRandomControl() & 0xFFF) - 2048) >> 2;
2020-12-21 13:16:29 -03:00
if (uw)
{
spark->friction = 20;
spark->yVel >>= 4;
2020-12-21 13:16:29 -03:00
spark->y += 32;
}
else
spark->friction = 6;
2020-12-21 13:16:29 -03:00
spark->flags = SP_SCALE | SP_DEF | SP_ROTATE | SP_EXPDEF;
spark->rotAng = GetRandomControl() & 0xFFF;
2020-12-21 13:16:29 -03:00
if (GetRandomControl() & 1)
spark->rotAdd = -16 - (GetRandomControl() & 0xF);
else
spark->rotAdd = (GetRandomControl() & 0xF) + 16;
2020-12-21 13:16:29 -03:00
spark->scalar = 3;
2020-12-21 13:16:29 -03:00
if (uw)
{
spark->maxYvel = 0;
spark->gravity = 0;
}
else
{
spark->gravity = -3 - (GetRandomControl() & 3);
spark->maxYvel = -4 - (GetRandomControl() & 3);
}
2020-12-21 13:16:29 -03:00
spark->dSize = (GetRandomControl() & 0x1F) + 128;
spark->sSize = spark->dSize / 4;
spark->size = spark->dSize / 4;
}
void TriggerExplosionSmoke(int x, int y, int z, int uw)
{
2022-03-31 23:55:54 +11:00
int dx = LaraItem->Pose.Position.x - x;
int dz = LaraItem->Pose.Position.z - z;
2020-12-21 13:16:29 -03:00
if (dx >= -BLOCK(16) && dx <= BLOCK(16) &&
dz >= -BLOCK(16) && dz <= BLOCK(16))
2020-12-21 13:16:29 -03:00
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = GetFreeParticle();
spark->sR = 144;
spark->sG = 144;
spark->sB = 144;
2020-12-21 13:16:29 -03:00
spark->on = 1;
spark->dR = 64;
spark->dG = 64;
spark->dB = 64;
spark->colFadeSpeed = 2;
spark->fadeToBlack = 8;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_SUBTRACTIVE;
2020-12-21 13:16:29 -03:00
spark->life = spark->sLife = (GetRandomControl() & 3) + 10;
spark->x = (GetRandomControl() & 0x1FF) + x - 256;
spark->y = (GetRandomControl() & 0x1FF) + y - 256;
spark->z = (GetRandomControl() & 0x1FF) + z - 256;
spark->xVel = ((GetRandomControl() & 0xFFF) - 2048) >> 2;
2020-12-21 13:16:29 -03:00
spark->yVel = GetRandomControl() - 128;
spark->zVel = ((GetRandomControl() & 0xFFF) - 2048) >> 2;
2020-12-21 13:16:29 -03:00
if (uw)
spark->friction = 2;
else
spark->friction = 6;
2020-12-21 13:16:29 -03:00
spark->flags = SP_SCALE | SP_DEF | SP_ROTATE | SP_EXPDEF;
spark->rotAng = GetRandomControl() & 0xFFF;
spark->scalar = 1;
spark->rotAdd = (GetRandomControl() & 0xF) + 16;
spark->gravity = -3 - (GetRandomControl() & 3);
spark->maxYvel = -4 - (GetRandomControl() & 3);
spark->dSize = (GetRandomControl() & 0x1F) + 128;
spark->sSize = spark->dSize / 4;
spark->size = spark->dSize / 4;
}
}
2022-05-05 07:08:14 +02:00
void TriggerSuperJetFlame(ItemInfo* item, int yvel, int deadly)
2020-12-21 13:16:29 -03:00
{
2022-03-31 23:55:54 +11:00
long dx = LaraItem->Pose.Position.x - item->Pose.Position.x;
long dz = LaraItem->Pose.Position.z - item->Pose.Position.z;
2020-12-21 13:16:29 -03:00
if (dx >= -BLOCK(16) && dx <= BLOCK(16) &&
dz >= -BLOCK(16) && dz <= BLOCK(16))
2020-12-21 13:16:29 -03:00
{
int size = (GetRandomControl() & 0x1FF) - yvel;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* sptr = GetFreeParticle();
2020-12-21 13:16:29 -03:00
if (size < 512)
size = 512;
sptr->on = 1;
sptr->sR = sptr->sG = (GetRandomControl() & 0x1F) + 48;
sptr->sB = (GetRandomControl() & 0x3F) - 64;
sptr->dR = (GetRandomControl() & 0x3F) - 64;
sptr->dG = (GetRandomControl() & 0x3F) - 128;
sptr->dB = 32;
sptr->colFadeSpeed = 8;
sptr->fadeToBlack = 8;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
sptr->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
sptr->life = sptr->sLife = (size >> 9) + (GetRandomControl() & 7) + 16;
2022-03-31 23:55:54 +11:00
sptr->x = (GetRandomControl() & 0x1F) + item->Pose.Position.x - 16;
sptr->y = (GetRandomControl() & 0x1F) + item->Pose.Position.y - 16;
sptr->z = (GetRandomControl() & 0x1F) + item->Pose.Position.z - 16;
2020-12-21 13:16:29 -03:00
sptr->friction = 51;
sptr->maxYvel = 0;
sptr->flags = SP_EXPDEF | SP_ROTATE | SP_DEF | SP_SCALE;
2020-12-21 13:16:29 -03:00
if (deadly)
2021-08-02 15:40:51 +03:00
sptr->flags = SP_EXPDEF | SP_ROTATE | SP_DEF | SP_SCALE | SP_FIRE;
2020-12-21 13:16:29 -03:00
sptr->scalar = 2;
sptr->dSize = (GetRandomControl() & 0xF) + (size >> 6) + 16;
2020-12-21 13:16:29 -03:00
sptr->sSize = sptr->size = sptr->dSize / 2;
if ((-(item->TriggerFlags & 0xFF) & 7) == 1)
2020-12-21 13:16:29 -03:00
{
sptr->gravity = -16 - (GetRandomControl() & 0x1F);
sptr->xVel = (GetRandomControl() & 0xFF) - 128;
sptr->yVel = -size;
sptr->zVel = (GetRandomControl() & 0xFF) - 128;
sptr->dSize += sptr->dSize / 4;
return;
}
sptr->y -= 64;
sptr->gravity = -((size >> 9) + GetRandomControl() % (size >> 8));
2020-12-21 13:16:29 -03:00
sptr->yVel = (GetRandomControl() & 0xFF) - 128;
sptr->xVel = (GetRandomControl() & 0xFF) - 128;
sptr->zVel = (GetRandomControl() & 0xFF) - 128;
2022-03-31 23:55:54 +11:00
if (item->Pose.Orientation.y == 0)
{
sptr->zVel = -(size - (size >> 2));
}
2022-03-31 23:55:54 +11:00
else if (item->Pose.Orientation.y == ANGLE(90.0f))
{
sptr->xVel = -(size - (size >> 2));
}
else if (item->Pose.Orientation.y == ANGLE(-180.0f))
{
sptr->zVel = size - (size >> 2);
}
2020-12-21 13:16:29 -03:00
else
{
sptr->xVel = size - (size >> 2);
}
2020-12-21 13:16:29 -03:00
}
}
2022-07-05 03:06:09 +03:00
void SetupSplash(const SPLASH_SETUP* const setup, int room)
2020-12-21 13:16:29 -03:00
{
constexpr size_t NUM_SPLASHES = 3;
int numSplashesSetup = 0;
float splashVelocity;
2020-12-21 13:16:29 -03:00
for (int i = 0; i < MAX_SPLASHES; i++)
{
SPLASH_STRUCT& splash = Splashes[i];
2020-12-21 13:16:29 -03:00
if (!splash.isActive)
{
if (numSplashesSetup == 0)
{
float splashPower = fmin(256, setup->splashPower);
2020-12-21 13:16:29 -03:00
splash.isActive = true;
splash.x = setup->x;
splash.y = setup->y;
splash.z = setup->z;
splash.life = 62;
splash.isRipple = false;
splash.innerRad = setup->innerRadius;
splashVelocity = splashPower / 16;
splash.innerRadVel = splashVelocity;
splash.heightSpeed = splashPower * 1.2f;
splash.height = 0;
splash.heightVel = -16;
splash.outerRad = setup->innerRadius / 3;
splash.outerRadVel = splashVelocity * 1.5f;
splash.spriteSequenceStart = 8; // Splash texture.
2020-12-21 13:16:29 -03:00
numSplashesSetup++;
}
else
{
float thickness = Random::GenerateFloat(64,128);
2020-12-21 13:16:29 -03:00
splash.isActive = true;
splash.x = setup->x;
splash.y = setup->y;
splash.z = setup->z;
splash.isRipple = true;
float vel;
if (numSplashesSetup == 2)
vel = (splashVelocity / 16) + Random::GenerateFloat(2, 4);
else
vel = (splashVelocity / 7) + Random::GenerateFloat(3, 7);
2020-12-21 13:16:29 -03:00
float innerRadius = 0;
splash.innerRad = innerRadius;
splash.innerRadVel = vel * 1.3f;
2020-12-21 13:16:29 -03:00
splash.outerRad = innerRadius+thickness;
splash.outerRadVel = vel * 2.3f;
2020-12-21 13:16:29 -03:00
splash.heightSpeed = 128;
splash.height = 0;
splash.heightVel = -16;
2020-12-21 13:16:29 -03:00
float t = vel / (splashVelocity / 2) + 16;
t = fmax(0, fmin(t, 1));
splash.life = Lerp(48.0f, 70.0f, t);
splash.spriteSequenceStart = 4; // Splash texture.
splash.spriteSequenceEnd = 7; // Splash texture.
2020-12-21 13:16:29 -03:00
splash.animationSpeed = fmin(0.6f,(1 / splash.outerRadVel)*2);
numSplashesSetup++;
}
if (numSplashesSetup == NUM_SPLASHES)
2020-12-21 13:16:29 -03:00
break;
2020-12-21 13:16:29 -03:00
continue;
}
}
TEN::Effects::Drip::SpawnSplashDrips(Vector3(setup->x, setup->y - 15, setup->z), 32, room);
Pose soundPosition;
2022-03-31 23:55:54 +11:00
soundPosition.Position.x = setup->x;
soundPosition.Position.y = setup->y;
soundPosition.Position.z = setup->z;
soundPosition.Orientation.y = 0;
soundPosition.Orientation.x = 0;
soundPosition.Orientation.z = 0;
2020-12-21 13:16:29 -03:00
2022-05-29 16:33:56 +03:00
SoundEffect(SFX_TR4_LARA_SPLASH, &soundPosition);
2020-12-21 13:16:29 -03:00
}
void UpdateSplashes()
{
if (SplashCount)
SplashCount--;
2020-12-21 13:16:29 -03:00
for (int i = 0; i < MAX_SPLASHES; i++)
{
auto& splash = Splashes[i];
if (splash.isActive)
{
2020-12-21 13:16:29 -03:00
splash.life--;
if (splash.life <= 0)
2020-12-21 13:16:29 -03:00
splash.isActive = false;
2020-12-21 13:16:29 -03:00
splash.heightSpeed += splash.heightVel;
splash.height += splash.heightSpeed;
if (splash.height < 0)
{
2020-12-21 13:16:29 -03:00
splash.height = 0;
if (!splash.isRipple)
2020-12-21 13:16:29 -03:00
splash.isActive = false;
}
2020-12-21 13:16:29 -03:00
splash.innerRad += splash.innerRadVel;
splash.outerRad += splash.outerRadVel;
splash.animationPhase += splash.animationSpeed;
short sequenceLength = splash.spriteSequenceEnd - splash.spriteSequenceStart;
if (splash.animationPhase > sequenceLength)
2020-12-21 13:16:29 -03:00
splash.animationPhase = fmod(splash.animationPhase, sequenceLength);
}
}
for (int i = 0; i < MAX_RIPPLES; i++)
{
auto* ripple = &Ripples[i];
2020-12-21 13:16:29 -03:00
if (ripple->flags & RIPPLE_FLAG_ACTIVE)
2020-12-21 13:16:29 -03:00
{
if (ripple->size < 252)
{
if (ripple->flags & RIPPLE_FLAG_SHORT_INIT)
ripple->size += 2;
else
ripple->size += 4;
2020-12-21 13:16:29 -03:00
}
if (!ripple->init)
2021-12-24 15:43:04 +03:00
{
ripple->life -= 3;
if (ripple->life > 250)
ripple->flags = 0;
2020-12-21 13:16:29 -03:00
}
else if (ripple->init < ripple->life)
2021-12-24 15:43:04 +03:00
{
if (ripple->flags & RIPPLE_FLAG_SHORT_INIT)
ripple->init += 8;
else
ripple->init += 4;
if (ripple->init >= ripple->life)
ripple->init = 0;
2020-12-21 13:16:29 -03:00
}
}
}
}
2022-05-16 13:32:29 +02:00
short DoBloodSplat(int x, int y, int z, short speed, short direction, short roomNumber)
{
short probedRoomNumber = GetCollision(x, y, z, roomNumber).RoomNumber;
if (TestEnvironment(ENV_FLAG_WATER, probedRoomNumber))
2022-05-16 13:32:29 +02:00
TriggerUnderwaterBlood(x, y, z, speed);
else
2022-05-16 13:32:29 +02:00
TriggerBlood(x, y, z, direction >> 4, speed);
return 0;
}
void DoLotsOfBlood(int x, int y, int z, int speed, short direction, short roomNumber, int count)
{
for (int i = 0; i < count; i++)
{
DoBloodSplat(
x + 256 - (GetRandomControl() * 512 / 0x8000),
y + 256 - (GetRandomControl() * 512 / 0x8000),
z + 256 - (GetRandomControl() * 512 / 0x8000),
speed, direction, roomNumber);
}
}
void TriggerLaraBlood()
{
int node = 1;
for (int i = 0; i < LARA_MESHES::LM_HEAD; i++)
{
if (node & LaraItem->TouchBits.ToPackedBits())
{
auto vec = GetJointPosition(LaraItem,
2022-09-08 17:02:50 +10:00
i,
Vector3i(
(GetRandomControl() & 31) - 16,
(GetRandomControl() & 31) - 16,
(GetRandomControl() & 31) - 16
));
DoBloodSplat(vec.x, vec.y, vec.z, (GetRandomControl() & 7) + 8, 2 * GetRandomControl(), LaraItem->RoomNumber);
}
node <<= 1;
}
}
void TriggerUnderwaterBlood(int x, int y, int z, int size)
2020-12-21 13:16:29 -03:00
{
for (int i = 0; i < MAX_RIPPLES; i++)
{
auto* ripple = &Ripples[i];
if (!(ripple->flags & RIPPLE_FLAG_ACTIVE))
{
ripple->flags = RIPPLE_FLAG_ACTIVE | RIPPLE_FLAG_LOW_OPACITY | RIPPLE_FLAG_BLOOD;
ripple->life = 240 + (GetRandomControl() & 7);
ripple->init = 1;
ripple->size = size;
ripple->x = x + (GetRandomControl() & 63) - 32;
ripple->y = y;
ripple->z = z + (GetRandomControl() & 63) - 32;
return;
}
}
2020-12-21 13:16:29 -03:00
}
2022-12-06 13:28:13 +11:00
void Ricochet(Pose& pose)
{
2022-12-06 13:28:13 +11:00
short angle = Geometry::GetOrientToPoint(pose.Position.ToVector3(), LaraItem->Pose.Position.ToVector3()).y;
auto target = GameVector(pose.Position);
TriggerRicochetSpark(target, angle / 16, 3, 0);
SoundEffect(SFX_TR4_WEAPON_RICOCHET, &pose);
}
void ControlWaterfallMist(short itemNumber)
{
auto* item = &g_Level.Items[itemNumber];
if (!TriggerActive(item))
return;
2022-11-04 10:43:35 +02:00
TriggerWaterfallMist(*item);
SoundEffect(SFX_TR4_WATERFALL_LOOP, &item->Pose);
}
2022-11-04 10:43:35 +02:00
void TriggerWaterfallMist(const ItemInfo& item)
{
static const int scale = 3;
int size = 64;
int width = 1;
2022-11-04 10:43:35 +02:00
short angle = item.Pose.Orientation.y + ANGLE(180.0f);
2022-11-04 10:43:35 +02:00
if (item.TriggerFlags != 0)
{
2022-11-04 10:43:35 +02:00
size = item.TriggerFlags % 100;
2022-11-04 10:46:26 +02:00
width = std::clamp(int(round(item.TriggerFlags / 100) * 100) / 2, 0, SECTOR(8));
}
2022-11-04 10:43:35 +02:00
float cos = phd_cos(angle);
float sin = phd_sin(angle);
2022-11-04 15:50:46 +02:00
int maxPosX = width * sin + item.Pose.Position.x;
int maxPosZ = width * cos + item.Pose.Position.z;
int minPosX = -width * sin + item.Pose.Position.x;
int minPosZ = -width * cos + item.Pose.Position.z;
2022-11-04 10:43:35 +02:00
2022-11-04 17:46:27 +02:00
float fadeMin = GetParticleDistanceFade(Vector3i(minPosX, item.Pose.Position.y, minPosZ));
float fadeMax = GetParticleDistanceFade(Vector3i(maxPosX, item.Pose.Position.y, maxPosZ));
if ((fadeMin == 0.0f) && (fadeMin == fadeMax))
2022-11-04 10:43:35 +02:00
return;
float finalFade = ((fadeMin >= 1.0f) && (fadeMin == fadeMax)) ? 1.0f : std::max(fadeMin, fadeMax);
2022-11-04 17:46:27 +02:00
auto startColor = item.Model.Color / 4.0f * finalFade * float(UCHAR_MAX);
auto endColor = item.Model.Color / 8.0f * finalFade * float(UCHAR_MAX);
2022-11-04 17:46:27 +02:00
float step = size * scale;
int steps = int((width / 2) / step);
int currentStep = 0;
2020-12-21 13:16:29 -03:00
while (true)
2020-12-21 13:16:29 -03:00
{
int offset = (step * currentStep) + Random::GenerateInt(-32, 32);
2020-12-21 13:16:29 -03:00
if (offset > width)
2020-12-21 13:16:29 -03:00
break;
for (int sign = -1; sign <= 1; sign += 2)
{
2022-11-04 11:00:33 +02:00
auto* spark = GetFreeParticle();
spark->on = true;
char colorOffset = (Random::GenerateInt(-8, 8));
2022-11-04 17:46:27 +02:00
spark->sR = std::clamp(int(startColor.x) + colorOffset, 0, UCHAR_MAX);
spark->sG = std::clamp(int(startColor.y) + colorOffset, 0, UCHAR_MAX);
spark->sB = std::clamp(int(startColor.z) + colorOffset, 0, UCHAR_MAX);
spark->dR = std::clamp(int(endColor.x) + colorOffset, 0, UCHAR_MAX);
spark->dG = std::clamp(int(endColor.y) + colorOffset, 0, UCHAR_MAX);
spark->dB = std::clamp(int(endColor.z) + colorOffset, 0, UCHAR_MAX);
2022-11-04 11:00:33 +02:00
spark->colFadeSpeed = 1;
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
spark->life = spark->sLife = Random::GenerateInt(8, 12);
2022-11-04 11:00:33 +02:00
spark->fadeToBlack = spark->life - 6;
spark->x = offset * sign * sin + Random::GenerateInt(-8, 8) + item.Pose.Position.x;
spark->y = Random::GenerateInt(0, 16) + item.Pose.Position.y - 8;
spark->z = offset * sign * cos + Random::GenerateInt(-8, 8) + item.Pose.Position.z;
2022-11-04 11:00:33 +02:00
spark->xVel = 0;
spark->yVel = Random::GenerateInt(-64, 64);
2022-11-04 11:00:33 +02:00
spark->zVel = 0;
spark->friction = 0;
spark->rotAng = GetRandomControl() & 0xFFF;
spark->scalar = scale;
spark->maxYvel = 0;
spark->rotAdd = Random::GenerateInt(-16, 16);
2022-11-04 11:00:33 +02:00
spark->gravity = -spark->yVel >> 2;
spark->sSize = spark->size = Random::GenerateInt(0, 3) * scale + size;
2022-11-04 11:00:33 +02:00
spark->dSize = 2 * spark->size;
spark->spriteIndex = Objects[ID_DEFAULT_SPRITES].meshIndex + (Random::GenerateInt(0, 100) > 95 ? 17 : 0);
spark->flags = 538;
if (sign == 1)
{
currentStep++;
if (currentStep == 1)
break;
}
}
}
2020-12-21 13:16:29 -03:00
}
void KillAllCurrentItems(short itemNumber)
{
// TODO: Reimplement this functionality.
2020-12-21 13:16:29 -03:00
}
void TriggerDynamicLight(int x, int y, int z, short falloff, byte r, byte g, byte b)
{
g_Renderer.AddDynamicLight(x, y, z, falloff, r, g, b);
2020-12-21 13:16:29 -03:00
}
void SetupRipple(int x, int y, int z, int size, int flags)
{
for (int i = 0; i < MAX_RIPPLES; i++)
{
auto* ripple = &Ripples[i];
if (!(ripple->flags & RIPPLE_FLAG_ACTIVE))
{
ripple->flags = RIPPLE_FLAG_ACTIVE | flags;
ripple->life = 48 + (GetRandomControl() & 15);
ripple->init = 1;
ripple->size = size;
ripple->x = x;
ripple->y = y;
ripple->z = z;
if (flags & RIPPLE_FLAG_NO_RAND)
{
ripple->x += (GetRandomControl() & 127) - 64;
ripple->z += (GetRandomControl() & 127) - 64;
}
return;
}
}
}
2022-05-05 07:08:14 +02:00
void WadeSplash(ItemInfo* item, int wh, int wd)
2020-12-21 13:16:29 -03:00
{
auto probe1 = GetCollision(item);
auto probe2 = GetCollision(probe1.Block, item->Pose.Position.x, probe1.Position.Ceiling, item->Pose.Position.z);
if (!TestEnvironment(ENV_FLAG_WATER, probe1.RoomNumber) ||
TestEnvironment(ENV_FLAG_WATER, probe1.RoomNumber) == TestEnvironment(ENV_FLAG_WATER, probe2.RoomNumber))
2021-11-07 04:54:48 +03:00
return;
auto* frame = GetBestFrame(item);
2022-03-31 23:55:54 +11:00
if (item->Pose.Position.y + frame->boundingBox.Y1 > wh)
2021-11-07 04:54:48 +03:00
return;
2022-03-31 23:55:54 +11:00
if (item->Pose.Position.y + frame->boundingBox.Y2 < wh)
2021-11-07 04:54:48 +03:00
return;
if (item->Animation.Velocity.y <= 0.0f || wd >= 474 || SplashCount != 0)
2021-11-07 04:54:48 +03:00
{
if (!(Wibble & 0xF))
2020-12-21 13:16:29 -03:00
{
if (!(GetRandomControl() & 0xF) || item->Animation.ActiveState != LS_IDLE)
2020-12-21 13:16:29 -03:00
{
if (item->Animation.ActiveState != LS_IDLE)
SetupRipple(item->Pose.Position.x, wh - 1, item->Pose.Position.z, 112 + (GetRandomControl() & 15), RIPPLE_FLAG_SHORT_INIT | RIPPLE_FLAG_LOW_OPACITY);
2021-11-07 04:54:48 +03:00
else
SetupRipple(item->Pose.Position.x, wh - 1, item->Pose.Position.z, 112 + (GetRandomControl() & 15), RIPPLE_FLAG_LOW_OPACITY);
2020-12-21 13:16:29 -03:00
}
}
}
2021-11-07 04:54:48 +03:00
else
{
2021-11-07 16:16:12 +03:00
SplashSetup.y = wh - 1;
2022-03-31 23:55:54 +11:00
SplashSetup.x = item->Pose.Position.x;
SplashSetup.z = item->Pose.Position.z;
2021-11-07 04:54:48 +03:00
SplashSetup.innerRadius = 16;
SplashSetup.splashPower = item->Animation.Velocity.z;
SetupSplash(&SplashSetup, probe1.RoomNumber);
2021-11-07 04:54:48 +03:00
SplashCount = 16;
}
2020-12-21 13:16:29 -03:00
}
2022-05-05 07:08:14 +02:00
void Splash(ItemInfo* item)
2020-12-21 13:16:29 -03:00
{
short roomNumber = item->RoomNumber;
2022-03-31 23:55:54 +11:00
GetFloor(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, &roomNumber);
2020-12-21 13:16:29 -03:00
auto* room = &g_Level.Rooms[roomNumber];
2022-02-04 22:18:55 +11:00
if (TestEnvironment(ENV_FLAG_WATER, room))
2020-12-21 13:16:29 -03:00
{
2022-03-31 23:55:54 +11:00
int waterHeight = GetWaterHeight(item->Pose.Position.x, item->Pose.Position.y, item->Pose.Position.z, roomNumber);
2022-02-04 22:18:55 +11:00
SplashSetup.y = waterHeight - 1;
2022-03-31 23:55:54 +11:00
SplashSetup.x = item->Pose.Position.x;
SplashSetup.z = item->Pose.Position.z;
SplashSetup.splashPower = item->Animation.Velocity.y;
2020-12-21 13:16:29 -03:00
SplashSetup.innerRadius = 64;
2022-02-04 22:18:55 +11:00
SetupSplash(&SplashSetup, roomNumber);
2020-12-21 13:16:29 -03:00
}
}
void TriggerRocketFlame(int x, int y, int z, int xv, int yv, int zv, int itemNumber)
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* sptr = GetFreeParticle();
2020-12-21 13:16:29 -03:00
sptr->on = true;
sptr->sR = 48 + (GetRandomControl() & 31);
sptr->sG = sptr->sR;
sptr->sB = 192 + (GetRandomControl() & 63);
sptr->dR = 192 + (GetRandomControl() & 63);
sptr->dG = 128 + (GetRandomControl() & 63);
sptr->dB = 32;
sptr->colFadeSpeed = 12 + (GetRandomControl() & 3);
sptr->fadeToBlack = 12;
sptr->sLife = sptr->life = (GetRandomControl() & 3) + 28;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
sptr->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
sptr->extras = 0;
sptr->dynamic = -1;
sptr->x = x + ((GetRandomControl() & 31) - 16);
sptr->y = y;
sptr->z = z + ((GetRandomControl() & 31) - 16);
sptr->xVel = xv;
sptr->yVel = yv;
sptr->zVel = zv;
sptr->friction = 3 | (3 << 4);
2020-12-21 13:16:29 -03:00
if (GetRandomControl() & 1)
{
sptr->flags = SP_SCALE | SP_DEF | SP_ROTATE | SP_ITEM | SP_EXPDEF;
sptr->fxObj = itemNumber;
sptr->rotAng = GetRandomControl() & 4095;
2020-12-21 13:16:29 -03:00
if (GetRandomControl() & 1)
sptr->rotAdd = -(GetRandomControl() & 15) - 16;
else
sptr->rotAdd = (GetRandomControl() & 15) + 16;
}
else
{
sptr->flags = SP_SCALE | SP_DEF | SP_ITEM | SP_EXPDEF;
sptr->fxObj = itemNumber;
}
sptr->gravity = 0;
sptr->maxYvel = 0;
// TODO: right sprite
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
sptr->spriteIndex = Objects[ID_DEFAULT_SPRITES].meshIndex;
2020-12-21 13:16:29 -03:00
sptr->scalar = 2;
int size = (GetRandomControl() & 7) + 32;
sptr->size = sptr->sSize = size;
}
void TriggerRocketFire(int x, int y, int z)
{
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* sptr = GetFreeParticle();
2020-12-21 13:16:29 -03:00
sptr->on = true;
sptr->sR = sptr->sG = (GetRandomControl() & 0x1F) + 48;
sptr->sB = (GetRandomControl() & 0x3F) - 64;
sptr->dR = (GetRandomControl() & 0x3F) - 64;
sptr->dG = (GetRandomControl() & 0x3F) - 128;
sptr->dB = 32;
sptr->colFadeSpeed = 4 + (GetRandomControl() & 3);
sptr->fadeToBlack = 12;
sptr->sLife = sptr->life = (GetRandomControl() & 3) + 20;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
sptr->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
sptr->extras = 0;
sptr->dynamic = -1;
sptr->x = x + ((GetRandomControl() & 15) - 8);
sptr->y = y + ((GetRandomControl() & 15) - 8);
sptr->z = z + ((GetRandomControl() & 15) - 8);
sptr->xVel = ((GetRandomControl() & 255) - 128);
sptr->yVel = -(GetRandomControl() & 3) - 4;
sptr->zVel = ((GetRandomControl() & 255) - 128);
sptr->friction = 4;
if (GetRandomControl() & 1)
{
sptr->flags = SP_SCALE | SP_DEF | SP_ROTATE | SP_EXPDEF;
sptr->rotAng = GetRandomControl() & 4095;
2020-12-21 13:16:29 -03:00
if (GetRandomControl() & 1)
sptr->rotAdd = -(GetRandomControl() & 15) - 16;
else
sptr->rotAdd = (GetRandomControl() & 15) + 16;
}
else
sptr->flags = SP_SCALE | SP_DEF | SP_EXPDEF;
// TODO: right sprite
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
sptr->spriteIndex = Objects[ID_DEFAULT_SPRITES].meshIndex;
2020-12-21 13:16:29 -03:00
sptr->scalar = 1;
sptr->gravity = -(GetRandomControl() & 3) - 4;
sptr->maxYvel = -(GetRandomControl() & 3) - 4;
int size = (GetRandomControl() & 7) + 128;
sptr->size = sptr->sSize = size >> 2;
2020-12-21 13:16:29 -03:00
sptr->dSize = size;
}
void TriggerRocketSmoke(int x, int y, int z, int bodyPart)
{
2021-08-30 18:03:21 +03:00
TEN::Effects::Smoke::TriggerRocketSmoke(x, y, z, 0);
2020-12-21 13:16:29 -03:00
}
void TriggerFlashSmoke(int x, int y, int z, short roomNumber)
2020-12-21 13:16:29 -03:00
{
auto* room = &g_Level.Rooms[roomNumber];
2020-12-21 13:16:29 -03:00
bool mirror = (roomNumber == g_GameFlow->GetLevel(CurrentLevel)->GetMirrorRoom());
2020-12-21 13:16:29 -03:00
bool water = false;
2022-05-29 23:20:55 +10:00
if (TestEnvironment(ENV_FLAG_WATER, room))
2020-12-21 13:16:29 -03:00
{
TriggerExplosionBubble(x, y, z, roomNumber);
water = true;
}
auto* spark = &SmokeSparks[GetFreeSmokeSpark()];
2020-12-21 13:16:29 -03:00
spark->on = true;
spark->sShade = 0;
spark->dShade = -128;
spark->colFadeSpeed = 4;
spark->fadeToBlack = 16;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
spark->life = spark->sLife = (GetRandomControl() & 0xF) + 64;
spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16;
spark->z = (GetRandomControl() & 0x1F) + z - 16;
if (water)
{
spark->xVel = spark->yVel = GetRandomControl() & 0x3FF - 512;
spark->zVel = (GetRandomControl() & 0x3FF) - 512;
spark->friction = 68;
}
else
{
spark->xVel = 2 * (GetRandomControl() & 0x3FF) - 1024;
spark->yVel = -512 - (GetRandomControl() & 0x3FF);
spark->zVel = 2 * (GetRandomControl() & 0x3FF) - 1024;
spark->friction = 85;
}
2022-05-29 23:20:55 +10:00
if (TestEnvironment(ENV_FLAG_WIND, room))
2020-12-21 13:16:29 -03:00
spark->flags = 272;
else
spark->flags = 16;
spark->rotAng = GetRandomControl() & 0xFFF;
if (GetRandomControl() & 1)
spark->rotAdd = -16 - (GetRandomControl() & 0xF);
else
spark->rotAdd = (GetRandomControl() & 0xF) + 16;
2020-12-21 13:16:29 -03:00
spark->maxYvel = 0;
spark->gravity = 0;
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 64;
spark->dSize = 2 * (spark->sSize + 4);
spark->mirror = mirror;
}
void TriggerFireFlame(int x, int y, int z, FlameType type, const Vector3& color1, const Vector3& color2)
2020-12-21 13:16:29 -03:00
{
2022-03-31 23:55:54 +11:00
int dx = LaraItem->Pose.Position.x - x;
int dz = LaraItem->Pose.Position.z - z;
2020-12-21 13:16:29 -03:00
if (abs(dx) > BLOCK(16) || abs(dz) > BLOCK(16))
return;
2020-12-21 13:16:29 -03:00
auto* spark = GetFreeParticle();
2020-12-21 13:16:29 -03:00
spark->on = true;
2020-12-21 13:16:29 -03:00
if (color1 == Vector3::Zero || color2 == Vector3::Zero)
{
// Legacy default colours, for compatibility with TR4-TR5 objects.
switch (type)
{
case FlameType::SmallFast:
spark->sR = 48;
spark->sG = 48;
spark->sB = (GetRandomControl() & 0x1F) + 128;
spark->dR = 32;
spark->dG = (GetRandomControl() & 0x3F) - 64;
spark->dB = (GetRandomControl() & 0x3F) + 64;
break;
case FlameType::Small:
spark->sR = spark->sG = (GetRandomControl() & 0x1F) + 48;
spark->sB = (GetRandomControl() & 0x3F) - 64;
break;
default:
spark->sR = 255;
spark->sB = 48;
spark->sG = (GetRandomControl() & 0x1F) + 48;
break;
}
if (type != FlameType::SmallFast)
{
spark->dR = (GetRandomControl() & 0x3F) - 64;
spark->dG = (GetRandomControl() & 0x3F) + -128;
spark->dB = 32;
}
}
else
{
// New colored flame processing.
2020-12-21 13:16:29 -03:00
int colorS[3] = { int(color1.x * UCHAR_MAX), int(color1.y * UCHAR_MAX), int(color1.z * UCHAR_MAX) };
int colorD[3] = { int(color2.x * UCHAR_MAX), int(color2.y * UCHAR_MAX), int(color2.z * UCHAR_MAX) };
// Determine weakest RGB component.
2020-12-21 13:16:29 -03:00
int lowestS = UCHAR_MAX;
int lowestD = UCHAR_MAX;
for (int i = 0; i < 3; i++)
{
if (lowestS > colorS[i]) lowestS = colorS[i];
if (lowestD > colorD[i]) lowestD = colorD[i];
}
// Introduce random color shift for non-weakest RGB components.
static constexpr int CHROMA_SHIFT = 32;
static constexpr float LUMA_SHIFT = 0.5f;
for (int i = 0; i < 3; i++)
{
if (colorS[i] != lowestS)
colorS[i] = int(colorS[i] + GenerateInt(-CHROMA_SHIFT, CHROMA_SHIFT));
if (colorD[i] != lowestD)
2022-11-30 19:32:04 +02:00
colorD[i] = int(colorD[i] + GenerateInt(-CHROMA_SHIFT, CHROMA_SHIFT));
colorS[i] = int(colorS[i] * (1.0f + GenerateFloat(-LUMA_SHIFT, 0)));
colorD[i] = int(colorD[i] * (1.0f + GenerateFloat(-LUMA_SHIFT, 0)));
colorS[i] = std::clamp(colorS[i], 0, UCHAR_MAX);
colorD[i] = std::clamp(colorD[i], 0, UCHAR_MAX);
}
spark->sR = colorS[0];
spark->sG = colorS[1];
spark->sB = colorS[2];
spark->dR = colorD[0];
spark->dG = colorD[1];
spark->dB = colorD[2];
}
2020-12-21 13:16:29 -03:00
if (type == FlameType::Small ||
type == FlameType::SmallFast ||
type == FlameType::Static)
{
spark->fadeToBlack = 6;
spark->colFadeSpeed = (GetRandomControl() & 3) + 5;
spark->life = spark->sLife = (GetRandomControl() & 3) + 24;
}
else
{
spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 20;
spark->life = spark->sLife = (GetRandomControl() & 7) + 40;
}
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
if (type != FlameType::Big && type != FlameType::Medium)
{
if (type < FlameType::SmallFast)
{
spark->x = (GetRandomControl() & 0xF) + x - 8;
spark->y = y;
spark->z = (GetRandomControl() & 0xF) + z - 8;
}
else
{
spark->x = (GetRandomControl() & 0x3F) + x - 32;
spark->y = y;
spark->z = (GetRandomControl() & 0x3F) + z - 32;
}
}
else
{
spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = y;
spark->z = (GetRandomControl() & 0x1F) + z - 16;
}
2020-12-21 13:16:29 -03:00
if (type == FlameType::Small)
{
spark->xVel = (GetRandomControl() & 0x1F) - 16;
spark->yVel = -1024 - (GetRandomControl() & 0x1FF);
spark->zVel = (GetRandomControl() & 0x1F) - 16;
spark->friction = 68;
}
else
{
spark->xVel = (GetRandomControl() & 0xFF) - 128;
spark->yVel = -16 - (GetRandomControl() & 0xF);
spark->zVel = (GetRandomControl() & 0xFF) - 128;
2020-12-21 13:16:29 -03:00
if (type == FlameType::Medium)
spark->friction = 51;
else
spark->friction = 5;
}
2020-12-21 13:16:29 -03:00
if (GetRandomControl() & 1)
{
spark->gravity = -16 - (GetRandomControl() & 0x1F);
spark->maxYvel = -16 - (GetRandomControl() & 7);
spark->flags = 538;
2020-12-21 13:16:29 -03:00
spark->rotAng = GetRandomControl() & 0xFFF;
2020-12-21 13:16:29 -03:00
if (GetRandomControl() & 1)
spark->rotAdd = -16 - (GetRandomControl() & 0xF);
else
spark->rotAdd = (GetRandomControl() & 0xF) + 16;
}
else
{
spark->flags = SP_EXPDEF | SP_DEF | SP_SCALE;
spark->gravity = -16 - (GetRandomControl() & 0x1F);
spark->maxYvel = -16 - (GetRandomControl() & 7);
}
spark->scalar = 2;
2020-12-21 13:16:29 -03:00
if (type != FlameType::Big)
{
if (type == FlameType::Medium)
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 64;
else if (type < FlameType::SmallFast)
{
spark->maxYvel = 0;
spark->gravity = 0;
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 32;
}
else
{
spark->dSize = spark->size / 16;
if (type == FlameType::Pulse)
{
spark->colFadeSpeed >>= 2;
spark->fadeToBlack = spark->fadeToBlack >> 2;
spark->life = spark->life >> 2;
spark->sLife = spark->life >> 2;
}
spark->sSize = spark->size = (GetRandomControl() & 0xF) + 48;
}
}
else
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 128;
if (type == FlameType::Small)
spark->dSize = (spark->size / 4.0f);
else
{
spark->dSize = (spark->size / 16.0f);
if (type == FlameType::Pulse)
{
spark->colFadeSpeed >>= 2;
spark->fadeToBlack = spark->fadeToBlack >> 2;
spark->life = spark->life >> 2;
spark->sLife = spark->life >> 2;
2020-12-21 13:16:29 -03:00
}
}
}
void TriggerMetalSparks(int x, int y, int z, int xv, int yv, int zv, const Vector3& color, int additional)
2020-12-21 13:16:29 -03:00
{
2022-03-31 23:55:54 +11:00
int dx = LaraItem->Pose.Position.x - x;
int dz = LaraItem->Pose.Position.z - z;
int colorR = std::clamp(int(color.x * UCHAR_MAX), 0, UCHAR_MAX);
int colorG = std::clamp(int(color.y * UCHAR_MAX), 0, UCHAR_MAX);
int colorB = std::clamp(int(color.z * UCHAR_MAX), 0, UCHAR_MAX);
2020-12-21 13:16:29 -03:00
if (dx >= -16384 && dx <= 16384 && dz >= -16384 && dz <= 16384)
{
int r = rand();
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
auto* spark = GetFreeParticle();
2020-12-21 13:16:29 -03:00
spark->dG = colorG;
spark->dB = colorB;
2020-12-21 13:16:29 -03:00
spark->life = 10;
spark->sLife = 10;
spark->sR = colorR;
spark->sG = colorG;
spark->sB = colorB;
spark->dR = colorR;
2020-12-21 13:16:29 -03:00
spark->x = (r & 7) + x - 3;
spark->on = 1;
spark->colFadeSpeed = 3;
spark->fadeToBlack = 5;
spark->y = ((r >> 3) & 7) + y - 3;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
spark->friction = 34;
spark->scalar = 2;
spark->z = ((r >> 6) & 7) + z - 3;
2020-12-21 13:16:29 -03:00
spark->flags = 2;
spark->xVel = (byte)(r >> 2) + xv - 128;
spark->yVel = (byte)(r >> 4) + yv - 128;
spark->zVel = (byte)(r >> 6) + zv - 128;
spark->sSize = ((r >> 9) & 3) + 4;
spark->size = ((r >> 9) & 3) + 4;
2021-09-08 16:17:30 +02:00
spark->dSize = ((r >> 9) & 1) + 1;
2020-12-21 13:16:29 -03:00
spark->maxYvel = 0;
spark->gravity = 0;
if (additional)
{
r = rand();
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark = GetFreeParticle();
2020-12-21 13:16:29 -03:00
spark->on = 1;
spark->sR = spark->dR >> 1;
spark->sG = spark->dG >> 1;
2020-12-21 13:16:29 -03:00
spark->fadeToBlack = 4;
Bugfixes (tier 2) (#539) * Use spiky gunflash for MP5 if available * Make order to Test/Touch/Mesh bits in ItemInfo and convert all to uint64 properly * Fix TR4 sentry gun using wrong rotations after wad conversion * Fix find and replace error * Convert ExplodingDeath to also use all 64-bit range * Fix stack overflow due to strange compiler quirks * Fix gunflashes for TR4 enemies * Reorganize sound condition checking to finally resolve all problems * Remove weird sound play condition casts * Update ten_savegame.fbs * Update ten_savegame_generated.h * Convert meshbits back to 32 bit * Update Renderer11DrawEffect.cpp * Enable multiple blend modes for particles, add poisoned particles support * Reduce max poison potency * Add debug box output for pathfinding * Properly clean and restore game and level statistics * Fix wrong condition in keyhole collision check which led to infinite inventory call * Fix keyholes again * Save particles in savegames * Update tomb4fx.h * Clean up particle code, save quadbike info in savegames * Save UPV info in savegames * Allow quadbike to ride through shallow water * Update quad.cpp * Make slowdown dependent on water depth * Fix epic bug with calculating water depth * Clean up quadbike water code * Remove incorrect debug box drawing * Tidy up current iteration of joint bit helpers * Customize drag for water and quicksand separately * Use auto* instead of auto to make code more readable * Add quadbike hack for ending up in shallow underwater caverns Co-authored-by: Sezz
2022-06-12 15:01:24 +03:00
spark->blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
2020-12-21 13:16:29 -03:00
spark->colFadeSpeed = (r & 3) + 8;
spark->sB = spark->dB >> 1;
2020-12-21 13:16:29 -03:00
spark->dR = 32;
spark->dG = 32;
spark->dB = 32;
spark->yVel = yv;
spark->life = ((r >> 3) & 7) + 13;
spark->sLife = ((r >> 3) & 7) + 13;
2020-12-21 13:16:29 -03:00
spark->friction = 4;
spark->x = x + (xv >> 5);
spark->y = y + (yv >> 5);
spark->z = z + (zv >> 5);
2020-12-21 13:16:29 -03:00
spark->xVel = (r & 0x3F) + xv - 32;
spark->zVel = ((r >> 6) & 0x3F) + zv - 32;
2020-12-21 13:16:29 -03:00
if (r & 1)
{
spark->flags = 538;
spark->rotAng = r >> 3;
2020-12-21 13:16:29 -03:00
if (r & 2)
spark->rotAdd = -16 - (r & 0xF);
else
spark->rotAdd = (r & 0xF) + 16;
}
else
spark->flags = 522;
spark->gravity = -8 - (r >> 3 & 3);
2020-12-21 13:16:29 -03:00
spark->scalar = 2;
spark->maxYvel = -4 - (r >> 6 & 3);
spark->sSize = ((r >> 8) & 0xF) + 24 >> 3;
spark->size = ((r >> 8) & 0xF) + 24 >> 3;
spark->dSize = ((r >> 8) & 0xF) + 24;
2020-12-21 13:16:29 -03:00
}
}
}
void ProcessEffects(ItemInfo* item)
{
constexpr auto MAX_LIGHT_FALLOFF = 13;
constexpr auto BURN_HEALTH_LARA = 7;
constexpr auto BURN_HEALTH_NPC = 1;
constexpr auto BURN_AFTERMATH_TIMEOUT = 4 * FPS;
constexpr auto BURN_DAMAGE_PROBABILITY = 1 / 8.0f;
if (item->Effect.Type == EffectType::None)
return;
if (item->Effect.Count > 0)
{
item->Effect.Count--;
if (!item->Effect.Count)
{
if (item->Effect.Type == EffectType::Fire ||
2022-11-30 01:31:04 +02:00
item->Effect.Type == EffectType::Custom ||
2022-11-30 00:57:25 +01:00
item->Effect.Type == EffectType::ElectricIgnite ||
item->Effect.Type == EffectType::RedIgnite)
{
item->Effect.Type = EffectType::Smoke;
item->Effect.Count = BURN_AFTERMATH_TIMEOUT;
}
else
{
item->Effect.Type = EffectType::None;
return;
}
}
}
int numMeshes = Objects[item->ObjectNumber].nmeshes;
for (int i = 0; i < numMeshes; i++)
{
auto pos = GetJointPosition(item, i);
switch (item->Effect.Type)
{
case EffectType::Fire:
if (TestProbability(1 / 8.0f))
2022-11-30 01:31:04 +02:00
TriggerFireFlame(pos.x, pos.y, pos.z, TestProbability(1 / 10.0f) ? FlameType::Trail : FlameType::Medium);
break;
2022-11-30 01:31:04 +02:00
case EffectType::Custom:
2022-11-30 00:57:25 +01:00
if (TestProbability(1 / 8.0f))
TriggerFireFlame(pos.x, pos.y, pos.z, TestProbability(1 / 10.0f) ? FlameType::Trail : FlameType::Medium,
2022-11-30 15:51:03 +02:00
item->Effect.PrimaryEffectColor, item->Effect.SecondaryEffectColor);
break;
case EffectType::Sparks:
if (TestProbability(1 / 10.0f))
2022-12-06 13:28:13 +11:00
TriggerElectricSpark(GameVector(pos, item->RoomNumber),
EulerAngles(0, Random::GenerateAngle(ANGLE(0), ANGLE(359)), 0), 2);
if (TestProbability(1 / 64.0f))
TriggerRocketSmoke(pos.x, pos.y, pos.z, 0);
break;
2022-11-30 00:57:25 +01:00
case EffectType::ElectricIgnite:
if (TestProbability(1 / 1.0f))
2022-12-06 13:28:13 +11:00
TriggerElectricSpark(GameVector(pos, item->RoomNumber),
EulerAngles(0, Random::GenerateAngle(ANGLE(0), ANGLE(359)), 0), 2);
if (TestProbability(1 / 1.0f))
2022-11-30 00:57:25 +01:00
TriggerFireFlame(pos.x, pos.y, pos.z, TestProbability(1 / 10.0f) ? FlameType::Medium : FlameType::Medium,
Vector3(0.2f, 0.5f, 1.0f), Vector3(0.2f, 0.8f, 1.0f));
break;
2022-11-30 00:57:25 +01:00
case EffectType::RedIgnite:
if (TestProbability(1 / 1.0f))
2022-11-30 00:57:25 +01:00
TriggerFireFlame(pos.x, pos.y, pos.z, TestProbability(1 / 10.0f) ? FlameType::Medium : FlameType::Medium,
Vector3(1.0f, 0.5f, 0.2f), Vector3(0.6f, 0.1f, 0.0f));
break;
case EffectType::Smoke:
if (TestProbability(1 / 32.0f))
TriggerRocketSmoke(pos.x, pos.y, pos.z, 0);
break;
}
}
if (item->Effect.Type != EffectType::Smoke)
{
int falloff = item->Effect.Count < 0 ? MAX_LIGHT_FALLOFF :
MAX_LIGHT_FALLOFF - std::clamp(MAX_LIGHT_FALLOFF - item->Effect.Count, 0, MAX_LIGHT_FALLOFF);
auto pos = GetJointPosition(item, 0);
TriggerDynamicLight(pos.x, pos.y, pos.z, falloff,
std::clamp(Random::GenerateInt(-32, 32) + int(item->Effect.LightColor.x * UCHAR_MAX), 0, UCHAR_MAX),
std::clamp(Random::GenerateInt(-32, 32) + int(item->Effect.LightColor.y * UCHAR_MAX), 0, UCHAR_MAX),
std::clamp(Random::GenerateInt(-32, 32) + int(item->Effect.LightColor.z * UCHAR_MAX), 0, UCHAR_MAX));
}
switch (item->Effect.Type)
{
2022-11-30 00:57:25 +01:00
case EffectType::ElectricIgnite:
case EffectType::Sparks:
SoundEffect(SOUND_EFFECTS::SFX_TR4_LARA_ELECTRIC_CRACKLES, &item->Pose);
break;
case EffectType::Fire:
2022-11-30 01:31:04 +02:00
case EffectType::Custom:
SoundEffect(SOUND_EFFECTS::SFX_TR4_LOOP_FOR_SMALL_FIRES, &item->Pose);
break;
}
if (item->Effect.Type != EffectType::Smoke)
{
if (item->IsLara() ||
(item->IsCreature() && item->HitPoints > 0 && Random::TestProbability(BURN_DAMAGE_PROBABILITY)))
{
DoDamage(item, item->IsLara() ? BURN_HEALTH_LARA : BURN_HEALTH_NPC);
}
}
if (item->Effect.Type != EffectType::Sparks && item->Effect.Type != EffectType::Smoke)
{
int waterHeight = GetWaterHeight(item);
int itemLevel = item->Pose.Position.y - GameBoundingBox(item).GetHeight() / 3;
if (waterHeight != NO_HEIGHT && itemLevel > waterHeight)
{
item->Effect.Type = EffectType::Smoke;
item->Effect.Count = 1 * FPS;
}
}
if (item->IsLara() && GetLaraInfo(item)->Control.WaterStatus == WaterStatus::FlyCheat)
item->Effect.Type = EffectType::None;
}
void TriggerAttackFlame(const Vector3i& pos, const Vector3& color, int scale)
{
auto& spark = *GetFreeParticle();
spark.on = true;
spark.sR = 0;
spark.sG = 0;
spark.sB = 0;
spark.dR = color.x;
spark.dG = color.y;
spark.dB = color.z;
spark.fadeToBlack = 8;
2022-12-09 23:40:55 +11:00
spark.colFadeSpeed = Random::GenerateInt(4, 8);
spark.blendMode = BLEND_MODES::BLENDMODE_ADDITIVE;
spark.life = Random::GenerateInt(20, 28);
spark.sLife = spark.life;
spark.x = pos.x + Random::GenerateInt(-8, 8);
spark.y = pos.y;
spark.z = pos.z + Random::GenerateInt(-8, 8);
spark.xVel = Random::GenerateInt(-128, 128);
spark.yVel = 0;
spark.zVel = Random::GenerateInt(-128, 128);
spark.friction = 5;
spark.flags = SP_EXPDEF | SP_DEF | SP_SCALE;
2022-12-09 23:40:55 +11:00
spark.rotAng = Random::GenerateInt(0, 4096); // NOTE: Effect angles use [0, 4096] range.
if (TestProbability(1 / 2.0f))
spark.rotAdd = -32 - (GetRandomControl() & 0x1F);
else
spark.rotAdd = (GetRandomControl() & 0x1F) + 32;
spark.maxYvel = 0;
spark.gravity = Random::GenerateInt(16, 48);
spark.scalar = 2;
spark.size = Random::GenerateInt(0, 16) + scale;
spark.sSize = spark.size;
spark.dSize = spark.size / 4;
}