Decompiled ID_BATS; Renamed submarine functions;

This commit is contained in:
MontyTRC89 2020-01-30 11:24:12 +01:00
parent 1d284ba9d0
commit abfa7ae4ac
9 changed files with 146 additions and 19 deletions

View file

@ -30,6 +30,7 @@
#include "sphere.h"
#include "debris.h"
#include "larafire.h"
#include "..\Objects\oldobjects.h"
#include "footprint.h"
#include "..\Specific\roomload.h"
@ -1753,7 +1754,7 @@ void UpdateBats()
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];

View file

@ -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;

View file

@ -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)

View file

@ -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);
}
}

View file

@ -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

View file

@ -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);
void InitialiseLittleBats(short itemNumber);
void ControlLittleBats(short itemNumber);
short GetFreeBat();
void TriggerLittleBat(ITEM_INFO* item);

View file

@ -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

View file

@ -248,6 +248,7 @@ xcopy /Y "$(ProjectDir)Scripting\Scripts\*.lua" "$(TargetDir)\Scripts"</Command>
<ClCompile Include="Objects\TR5\tr5_misc_objects.cpp" />
<ClCompile Include="Objects\TR5\tr5_missile.cpp" />
<ClCompile Include="Objects\TR5\tr5_moving_block.cpp" />
<ClCompile Include="Objects\TR5\tr5_particle_enemies.cpp" />
<ClCompile Include="Objects\TR5\tr5_rats.cpp" />
<ClCompile Include="Objects\TR5\tr5_reaper.cpp" />
<ClCompile Include="Objects\TR5\tr5_romanstatue.cpp" />

View file

@ -842,6 +842,9 @@
<ClCompile Include="Objects\TR5\tr5_missile.cpp">
<Filter>File di origine</Filter>
</ClCompile>
<ClCompile Include="Objects\TR5\tr5_particle_enemies.cpp">
<Filter>File di origine</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Shaders\Shader.fx" />