diff --git a/TR5Main/Game/control.cpp b/TR5Main/Game/control.cpp index a131e0a1d..16ca0a26b 100644 --- a/TR5Main/Game/control.cpp +++ b/TR5Main/Game/control.cpp @@ -30,6 +30,7 @@ #include "sphere.h" #include "debris.h" #include "larafire.h" +#include "..\Objects\oldobjects.h" #include "footprint.h" #include "..\Specific\roomload.h" @@ -1740,7 +1741,7 @@ void UpdateBats() return; short* bounds = GetBoundsAccurate(LaraItem); - + int x1 = LaraItem->pos.xPos + bounds[0] - (bounds[0] >> 2); int x2 = LaraItem->pos.xPos + bounds[1] - (bounds[1] >> 2); @@ -1749,19 +1750,19 @@ void UpdateBats() int z1 = LaraItem->pos.zPos + bounds[4] - (bounds[4] >> 2); int z2 = LaraItem->pos.zPos + bounds[5] - (bounds[5] >> 2); - + int minDistance = 0xFFFFFFF; // v40 int minIndex = -1; - for (int i=0;i<64;i++) + for (int i = 0; i < NUM_BATS; i++) { BAT_STRUCT* bat = &Bats[i]; if (!bat->on) continue; - if ((Lara.burn || LaraItem->hitPoints <= 0) - && bat->counter > 90 + if ((Lara.burn || LaraItem->hitPoints <= 0) + && bat->counter > 90 && !(GetRandomControl() & 7)) bat->counter = 90; @@ -1811,7 +1812,7 @@ void UpdateBats() if (bat->counter > 90) { int speed = bat->speed * 128; - + short xAngle = abs(angles[1] - bat->pos.yRot) >> 3; short yAngle = abs(angles[0] - bat->pos.yRot) >> 3; @@ -1834,7 +1835,7 @@ void UpdateBats() bat->pos.xPos += sp * SIN(bat->pos.yRot) >> W2V_SHIFT; bat->pos.yPos += bat->speed * SIN(-bat->pos.xRot) >> W2V_SHIFT; bat->pos.zPos += sp * COS(bat->pos.yRot) >> W2V_SHIFT; - + if ((i % 2 == 0) && bat->pos.xPos > x1 && bat->pos.xPos < x2 diff --git a/TR5Main/Game/savegame.cpp b/TR5Main/Game/savegame.cpp index ff26b5258..281173eaa 100644 --- a/TR5Main/Game/savegame.cpp +++ b/TR5Main/Game/savegame.cpp @@ -10,6 +10,7 @@ #include "traps.h" #include "..\Game\laramisc.h" #include "..\Objects\newobjects.h" +#include "..\Objects\oldobjects.h" #include "..\Game\sound.h" FileStream* SaveGame::m_stream; diff --git a/TR5Main/Global/vars.h b/TR5Main/Global/vars.h index 174196c2f..012dba0ca 100644 --- a/TR5Main/Global/vars.h +++ b/TR5Main/Global/vars.h @@ -212,7 +212,7 @@ #define PhdWidth VAR_U_(0x0055D29C, int) #define PhdHeight VAR_U_(0x0055D164, int) #define PhdPerspective VAR_U_(0x0055D208, int) -#define Bats VAR_U_(0x00EEEFE8, BAT_STRUCT*) +//#define Bats VAR_U_(0x00EEEFE8, BAT_STRUCT*) #define Rats VAR_U_(0x00EEEFEC, RAT_STRUCT*) #define Spiders VAR_U_(0x00EEF45C, SPIDER_STRUCT*) #define PoisonFlags VAR_U_(0x00E5BF3E, byte) diff --git a/TR5Main/Objects/TR5/tr5_particle_enemies.cpp b/TR5Main/Objects/TR5/tr5_particle_enemies.cpp new file mode 100644 index 000000000..83b03da45 --- /dev/null +++ b/TR5Main/Objects/TR5/tr5_particle_enemies.cpp @@ -0,0 +1,111 @@ +#include "../oldobjects.h" +#include "../../Game/sphere.h" +#include "../../Game/items.h" +#include "../../Game/tomb4fx.h" +#include "../../Game/effect2.h" +#include "../../Game/Box.h" +#include "../../Game/people.h" +#include "../../Game/debris.h" +#include "../../Game/draw.h" +#include "../../Game/control.h" +#include "../../Game/effects.h" + +int NumBats; +BAT_STRUCT* Bats; + +void InitialiseLittleBats(short itemNumber) +{ + ITEM_INFO* item = &Items[itemNumber]; + + if (item->pos.yRot == 0) + { + item->pos.zPos += 512; + } + else if (item->pos.yRot == -ANGLE(180)) + { + item->pos.zPos -= 512; + } + else if (item->pos.yRot == -ANGLE(90)) + { + item->pos.xPos -= 512; + } + else if (item->pos.yRot == ANGLE(90)) + { + item->pos.xPos += 512; + } + + if (Objects[ID_BATS].loaded) + ZeroMemory(Bats, NUM_BATS * sizeof(BAT_STRUCT)); + + //LOWORD(item) = sub_402F27(ebx0, Bats, 0, 1920); +} + +void ControlLittleBats(short itemNumber) +{ + ITEM_INFO* item = &Items[itemNumber]; + + if (TriggerActive(item)) + { + if (item->triggerFlags) + { + TriggerLittleBat(item); + item->triggerFlags--; + } + else + { + KillItem(itemNumber); + } + } +} + +short GetFreeBat() +{ + short batNumber = NumBats; + int index = 0; + BAT_STRUCT* bat = &Bats[NumBats]; + + while (bat->on) + { + if (batNumber == NUM_BATS - 1) + { + bat = (BAT_STRUCT*)Bats; + batNumber = 0; + } + else + { + batNumber++; + bat++; + } + + index++; + + if (index >= NUM_BATS) + return NO_ITEM; + } + + NumBats = (batNumber + 1) & (NUM_BATS - 1); + + return batNumber; +} + +void TriggerLittleBat(ITEM_INFO* item) +{ + short batNumber = GetFreeBat(); + + if (batNumber != NO_ITEM) + { + BAT_STRUCT* bat = &Bats[batNumber]; + + bat->roomNumber = item->roomNumber; + bat->pos.xPos = item->pos.xPos; + bat->pos.yPos = item->pos.yPos; + bat->pos.zPos = item->pos.zPos; + bat->pos.yRot = (GetRandomControl() & 0x7FF) + item->pos.yRot + -ANGLE(180) - 1024; + bat->on = 1; + bat->flags = 0; + bat->pos.xRot = (GetRandomControl() & 0x3FF) - 512; + bat->speed = (GetRandomControl() & 0x1F) + 16; + bat->laraTarget = GetRandomControl() & 0x1FF; + bat->counter = 20 * ((GetRandomControl() & 7) + 15); + } +} \ No newline at end of file diff --git a/TR5Main/Objects/TR5/tr5_submarine.cpp b/TR5Main/Objects/TR5/tr5_submarine.cpp index 5bea5ff93..3e9d83a6d 100644 --- a/TR5Main/Objects/TR5/tr5_submarine.cpp +++ b/TR5Main/Objects/TR5/tr5_submarine.cpp @@ -157,7 +157,7 @@ LABEL_13: pos2.z = 90; GetJointAbsPosition(item, &pos2, 1); - TriggerTorpedoSparks(&pos1, &pos2, 0); + TriggerTorpedoBubbles(&pos1, &pos2, 0); pos1.x = 200; pos1.y = 320; @@ -169,7 +169,7 @@ LABEL_13: pos2.z = -100; GetJointAbsPosition(item, &pos2, 1); - TriggerTorpedoSparks(&pos1, &pos2, 0); + TriggerTorpedoBubbles(&pos1, &pos2, 0); } else { @@ -185,7 +185,7 @@ LABEL_13: pos2.z = 90; GetJointAbsPosition(item, &pos2, 2); - TriggerTorpedoSparks(&pos1, &pos2, 0); + TriggerTorpedoBubbles(&pos1, &pos2, 0); pos1.x = -200; pos1.y = 320; @@ -197,7 +197,7 @@ LABEL_13: pos2.z = -100; GetJointAbsPosition(item, &pos2, 2); - TriggerTorpedoSparks(&pos1, &pos2, 0); + TriggerTorpedoBubbles(&pos1, &pos2, 0); } TriggerSubmarineSparks(itemNumber); @@ -242,7 +242,7 @@ LABEL_13: CreatureUnderwater(item, -14080); } -void TriggerTorpedoSparks(PHD_VECTOR* pos1, PHD_VECTOR* pos2, char factor) +void TriggerTorpedoBubbles(PHD_VECTOR* pos1, PHD_VECTOR* pos2, char factor) { SPARKS* spark = &Sparks[GetFreeSpark()]; @@ -431,7 +431,7 @@ void ChaffFlareControl(short itemNumber) pos2.z = 8 * ((GlobalCounter & 1) != 0 ? 48 : -48); GetJointAbsPosition(item, &pos2, 0); - TriggerTorpedoSparks(&pos1, &pos2, 1); + TriggerTorpedoBubbles(&pos1, &pos2, 1); if (item->itemFlags[0] >= 300) { @@ -611,7 +611,7 @@ void TorpedoControl(short itemNumber) pos2.z = -64 << ((GlobalCounter & 1) + 2); GetJointAbsPosition(item, &pos2, 0); - TriggerTorpedoSparks(&pos1, &pos2, 1); + TriggerTorpedoBubbles(&pos1, &pos2, 1); } } else diff --git a/TR5Main/Objects/oldobjects.h b/TR5Main/Objects/oldobjects.h index 311a905db..6d566cc2a 100644 --- a/TR5Main/Objects/oldobjects.h +++ b/TR5Main/Objects/oldobjects.h @@ -19,8 +19,8 @@ #define InitialiseLagoonWitch ((void (__cdecl*)(short)) 0x0047D2D0) // not used anymore ! #define ControlLagoonWitch ((void (__cdecl*)(short)) 0x0047D360) // not used anymore ! //#define ControlInvisibleGhost ((void (__cdecl*)(short)) 0x00477AB0) -#define InitialiseLittleBats ((void (__cdecl*)(short)) 0x00407EC0) -#define ControlLittleBats ((void (__cdecl*)(short)) 0x00407F50) +//#define InitialiseLittleBats ((void (__cdecl*)(short)) 0x00407EC0) +//#define ControlLittleBats ((void (__cdecl*)(short)) 0x00407F50) #define InitialiseSpiders ((void (__cdecl*)(short)) 0x0043F2B0) #define ControlSpiders ((void (__cdecl*)(short)) 0x0047A200) //#define ControlGladiator ((void (__cdecl*)(short)) 0x00436700) @@ -30,6 +30,9 @@ //#define InitialiseRomanStatue ((void (__cdecl*)(short)) 0x0046BB00) // need to check a dword_ variable before decompiling +extern int NumBats; +extern BAT_STRUCT* Bats; + void InitialiseGuard(short itemNum); void InitialiseGuardM16(short itemNum); void InitialiseGuardLaser(short itemNum); @@ -119,9 +122,13 @@ void DeathSlideCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); void ControlDeathSlide(short itemNumber); void InitialiseDeathSlide(short itemNumber); void ControlSubmarine(short itemNumber); -void TriggerTorpedoSparks(PHD_VECTOR* pos1, PHD_VECTOR* pos2, char factor); +void TriggerTorpedoBubbles(PHD_VECTOR* pos1, PHD_VECTOR* pos2, char factor); void TriggerSubmarineSparks(short itemNumber); void SubmarineAttack(ITEM_INFO* item); void TriggerTorpedoSparks2(PHD_VECTOR* pos1, PHD_VECTOR* pos2, char scale); void ChaffFlareControl(short itemNumber); -void TorpedoControl(short itemNumber); \ No newline at end of file +void TorpedoControl(short itemNumber); +void InitialiseLittleBats(short itemNumber); +void ControlLittleBats(short itemNumber); +short GetFreeBat(); +void TriggerLittleBat(ITEM_INFO* item); \ No newline at end of file diff --git a/TR5Main/Renderer/Renderer11Draw.cpp b/TR5Main/Renderer/Renderer11Draw.cpp index 9279591d2..d0afb4a22 100644 --- a/TR5Main/Renderer/Renderer11Draw.cpp +++ b/TR5Main/Renderer/Renderer11Draw.cpp @@ -12,10 +12,13 @@ #include "../Game/rope.h" #include "../Game/tomb4fx.h" #include "../Game/door.h" +#include "../Objects/oldobjects.h" + extern GUNSHELL_STRUCT Gunshells[MAX_GUNSHELL]; extern RendererHUDBar* g_DashBar; extern RendererHUDBar* g_SFXVolumeBar; extern RendererHUDBar* g_MusicVolumeBar; + int Renderer11::DrawPickup(short objectNum) { drawObjectOn2DPosition(700 + PickupX, 450, objectNum, 0, m_pickupRotation, 0); // TODO: + PickupY diff --git a/TR5Main/TR5Main.vcxproj b/TR5Main/TR5Main.vcxproj index 88e8ba009..b2a115092 100644 --- a/TR5Main/TR5Main.vcxproj +++ b/TR5Main/TR5Main.vcxproj @@ -248,6 +248,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts" + diff --git a/TR5Main/TR5Main.vcxproj.filters b/TR5Main/TR5Main.vcxproj.filters index 8e7e796f4..8da186735 100644 --- a/TR5Main/TR5Main.vcxproj.filters +++ b/TR5Main/TR5Main.vcxproj.filters @@ -842,6 +842,9 @@ File di origine + + File di origine +