Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #33

Open
wants to merge 67 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
3ae09a4
Decompiled FindGridShift()
TokyoSU Mar 15, 2022
c5e4523
Decompiled ShiftItem()
TokyoSU Mar 15, 2022
e4b8552
Decompiled UpdateLaraRoom()
TokyoSU Mar 15, 2022
67b33b3
Decompiled GetTiltType()
TokyoSU Mar 15, 2022
24a0813
Fixed GetTiltType()
TokyoSU Mar 15, 2022
2e2003c
Decompiled LaraBaddieCollision()
TokyoSU Mar 15, 2022
be884fc
Fixed Tab
TokyoSU Mar 15, 2022
aac83ca
Decompiled EffectSpaz()
TokyoSU Mar 15, 2022
cb2473c
Decompiled CreatureCollision()
TokyoSU Mar 15, 2022
13fa7be
Decompiled DoorCollision()
TokyoSU Mar 15, 2022
3e82e1d
Decompiled TrapCollision()
TokyoSU Mar 15, 2022
8005bd0
Decompiled ItemPushLara() and TestBoundsCollide()
TokyoSU Mar 15, 2022
ac44223
Decompiled TestLaraPosition()
TokyoSU Mar 15, 2022
2251d44
Decompiled AlignLaraPosition()
TokyoSU Mar 15, 2022
0ab69dd
Decompiled MoveLaraPosition()
TokyoSU Mar 15, 2022
e429379
Decompiled Move3DPosTo3DPos()
TokyoSU Mar 15, 2022
290c859
Removing some empty line (collide)
TokyoSU Mar 15, 2022
d6c46fd
Fixed missing tab
TokyoSU Mar 15, 2022
1fc7789
Fixed another missing tab
TokyoSU Mar 15, 2022
305f38a
Update TR2_progress.txt
TokyoSU Mar 15, 2022
f287657
Fixed some review from @asasas9500
TokyoSU Mar 18, 2022
899ea57
Maybe fixed a bug about key
TokyoSU Mar 18, 2022
e130a4b
Fix MoveLaraPosition() for Flare
TokyoSU Mar 18, 2022
0320207
Decompiled DrawLara()
TokyoSU Mar 19, 2022
2c70a05
Decompiled DrawPhaseCinematic() and DrawPhaseGame()
TokyoSU Mar 19, 2022
e9e9414
Decompiled InitInterpolate()
TokyoSU Mar 19, 2022
2009cc3
Decompiled phd_PopMatrix_I()
TokyoSU Mar 19, 2022
46564b6
Decompiled phd_RotY_I()
TokyoSU Mar 19, 2022
5e70804
Decompiled phd_TranslateRel_I()
TokyoSU Mar 19, 2022
7fab643
Decompiled phd_TranslateRel_ID()
TokyoSU Mar 19, 2022
4b1415f
Decompiled phd_RotYXZsuperpack_I()
TokyoSU Mar 19, 2022
2aaa2ee
Fixed DrawLara()
TokyoSU Mar 19, 2022
120072f
Decompiled InterpolateMatrix()
TokyoSU Mar 19, 2022
c2a7ffb
Decompiled InterpolateArmMatrix()
TokyoSU Mar 19, 2022
0313b1f
Decompiled GetFrames()
TokyoSU Mar 20, 2022
ea211b2
Decompiled GetBoundsAccurate()
TokyoSU Mar 20, 2022
8311f39
Decompiled GetBestFrame()
TokyoSU Mar 20, 2022
8e9ad3e
Update TR2_progress.txt
TokyoSU Mar 20, 2022
900008f
Merge branch 'draw' into develop
TokyoSU Mar 20, 2022
831e9a9
Decompiled LaraInitialiseMeshes()
TokyoSU Mar 21, 2022
22d1bbe
Decompiled InitialiseLara()
TokyoSU Mar 21, 2022
afd2706
Decompiled AnimateLara()
TokyoSU Mar 21, 2022
d1433ef
Decompiled LaraUnderWater()
TokyoSU Mar 21, 2022
bb4daf5
Fix space to tab
TokyoSU Mar 21, 2022
d07e99a
Changed short to __int16
TokyoSU Mar 21, 2022
0d2916f
Fix lara death in offshore rig
TokyoSU Mar 21, 2022
bbf73c2
Fixed LaraBaddieCollision()
TokyoSU Mar 22, 2022
6eea370
Add array size check
TokyoSU Mar 22, 2022
c6296d5
Fixed lara not playing some sound
TokyoSU Mar 24, 2022
a5579a1
Fixed a mistake about lara command
TokyoSU Mar 24, 2022
93e95c1
Fixed M16 torso rotation.
TokyoSU Apr 19, 2022
676c7d4
Decompiled GeneralControl()
TokyoSU Apr 21, 2022
f47ec07
Bonus level experimental feature
TokyoSU Apr 21, 2022
f2aed5e
Revert "Bonus level experimental feature"
TokyoSU Apr 30, 2022
c4bdc7c
Fixed a crash
TokyoSU May 1, 2022
a2243d8
Started decompiling setup.cpp
TokyoSU May 3, 2022
c9dce7a
Finished TrapObjects()
TokyoSU May 21, 2022
be6076a
Added missing SPIKE_WALL obj
TokyoSU May 21, 2022
1812a5c
Finished decompiling ObjectObjects()
TokyoSU May 22, 2022
7a32ec2
Fixed cinematic crash for level 1
TokyoSU May 26, 2022
bfe2c75
Finished setup.cpp
TokyoSU May 26, 2022
636187a
Fixed Joystick in DirectInput8
TokyoSU May 26, 2022
3161503
Update TR2_progress.txt
TokyoSU May 26, 2022
86556db
Decompiled InitialiseCreature()
TokyoSU Dec 7, 2022
c743ae5
Decompiled CreatureActive()
TokyoSU Dec 7, 2022
868063e
Decompiled CreatureAIInfo()
TokyoSU Dec 7, 2022
97dc4c9
Increased the count of creature to 16
TokyoSU Jan 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
272 changes: 136 additions & 136 deletions TR2_progress.txt

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions configs/TR2Main.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
" boots. It is used for alternative sound effects of Lara's steps. ",
" The parameter can be true or false. Default value is false. ",
" ",
" - 'bridgelightfix' is used to fix the drawbridge that create a ",
" dynamic light when triggered. (minisub is not affected) ",
" Default is true. ",
" ",
" - 'semitransparent' is used for semitransparency parameters. ",
" It can contain: 'animtex', 'objects', 'statics', 'rooms' ",
" ",
Expand Down Expand Up @@ -91,6 +95,7 @@
"default": {
"comment": "Default settings for all levels",
"watercolor": "80FFFF",
"bridgelightfix": true,
"semitransparent": {
"animtex": "auto",
"objects": [{
Expand Down
6 changes: 3 additions & 3 deletions game/boat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
/*
* Function list
*/
// 0x0040CB10: InitialiseBoat
#define InitialiseBoat ((void(__cdecl*)(__int16)) 0x0040CB10)
// 0x0040CB50: BoatCheckGeton
// 0x0040CCC0: BoatCollision
#define BoatCollision ((void(__cdecl*)(__int16,ITEM_INFO*,COLL_INFO*)) 0x0040CCC0)
// 0x0040CE20: TestWaterHeight
// 0x0040CF20: DoBoatShift

Expand All @@ -39,7 +39,7 @@ void __cdecl DoWakeEffect(ITEM_INFO *item); // 0x0040D0F0
// 0x0040D2C0: BoatDynamics
// 0x0040D7A0: BoatUserControl
// 0x0040D930: BoatAnimation
// 0x0040DAA0: BoatControl
#define BoatControl ((void(__cdecl*)(__int16)) 0x0040DAA0)

void __cdecl GondolaControl(__int16 itemID); // 0x0040E0D0

Expand Down
158 changes: 156 additions & 2 deletions game/box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,100 @@

#include "global/precompiled.h"
#include "game/box.h"
#include "3dsystem/phd_math.h"
#include "game/control.h"
#include "game/items.h"
#include "game/lot.h"
#include "game/missile.h"
#include "specific/game.h"
#include "global/vars.h"

/*void __cdecl InitialiseCreature(__int16 itemID) {
ITEM_INFO *item = &Items[itemID];
item->pos.rotY += (GetRandomControl() - PHD_90) >> 1;
item->collidable = 1;
item->data = NULL;
}

BOOL __cdecl CreatureActive(__int16 itemID) {
ITEM_INFO *item = &Items[itemID];

if (CHK_ANY(item->status, ITEM_INVISIBLE)) {
BOOL isActive = EnableBaddieAI(itemID, FALSE);
if (isActive) {
item->status = ITEM_ACTIVE;
return TRUE;
}
}

return CHK_ANY(item->status, ITEM_ACTIVE);
}

void __cdecl CreatureAIInfo(ITEM_INFO *item, AI_INFO *ai) {
CREATURE_INFO *creature = (CREATURE_INFO*)item->data;
if (creature == NULL) {
return;
}

ITEM_INFO *enemy = NULL;
__int16 *zone = NULL;

switch (item->objectID) {
case ID_BANDIT1:
case ID_BANDIT2:
GetBaddieTarget(creature->item_num, 0);
break;
case ID_MONK1:
case ID_MONK2:
GetBaddieTarget(creature->item_num, 1);
break;
default:
creature->enemy = LaraItem;
break;
}

enemy = creature->enemy;
if (enemy == NULL) {
enemy = LaraItem;
}

if (creature->LOT.fly != 0) {
zone = FlyZones[FlipStatus];
} else {
zone = GroundZones[2 * (creature->LOT.step >> 8) + FlipStatus];
}

ROOM_INFO *roomSource = &RoomInfo[item->roomNumber];
item->boxNumber = roomSource->floor[((item->pos.z - roomSource->z) >> WALL_SHIFT) + roomSource->xSize * ((item->pos.x - roomSource->x) >> WALL_SHIFT)].box;
ai->zone_number = zone[item->boxNumber];

ROOM_INFO *roomTarget = &RoomInfo[enemy->roomNumber];
enemy->boxNumber = roomTarget->floor[((enemy->pos.z - roomTarget->z) >> WALL_SHIFT) + roomTarget->xSize * ((enemy->pos.x - roomTarget->x) >> WALL_SHIFT)].box;
ai->enemy_zone = zone[enemy->boxNumber];

if ( CHK_ANY(Boxes[enemy->boxNumber].overlapIndex, creature->LOT.block_mask) || creature->LOT.node[item->boxNumber].search_number == (creature->LOT.search_number | 0x8000) ) {
ai->enemy_zone |= 0x4000;
}

OBJECT_INFO *obj = &Objects[item->objectID];
int x = enemy->pos.x - ((obj->pivotLength * phd_cos(item->pos.rotY)) >> W2V_SHIFT) - item->pos.x;
int z = enemy->pos.z - ((obj->pivotLength * phd_sin(item->pos.rotY)) >> W2V_SHIFT) - item->pos.z;
int angle = phd_atan(z, x);
if (creature->enemy != NULL) {
ai->distance = SQR(x) + SQR(z);
} else {
ai->distance = 0x7FFFFFFF;
}
ai->angle = angle - item->pos.rotY;
ai->enemy_facing = angle - enemy->pos.rotY + PHD_180;
ai->ahead = angle > -PHD_90 && angle < PHD_90;
if (ai->ahead && enemy->hitPoints >= 0 && ABS(item->pos.y - enemy->pos.y) < 384) {
ai->bite = 1;
} else {
ai->bite = 0;
}
}*/

void __cdecl CreatureDie(__int16 itemID, BOOL explode) {
ITEM_INFO *item = &Items[itemID];
item->collidable = 0;
Expand Down Expand Up @@ -94,6 +182,73 @@ void __cdecl CreatureKill(ITEM_INFO *item, int killAnim, int killState, int lara
Camera.pos.roomNumber = LaraItem->roomNumber;
}

void __cdecl GetBaddieTarget(__int16 itemNum, int flags) {
ITEM_INFO *item = &Items[itemNum], *target = NULL, *bestItem = NULL;
CREATURE_INFO *creature = (CREATURE_INFO*)item->data, *creatureFound = NULL;
int bestDistance = 0x7FFFFFFF, distance = 0;
int x, y, z;

for (int i = 0; i < MAXIMUM_CREATURE_SLOTS; i++) {
creatureFound = &ActiveCreatures[i];
if (creatureFound->item_num == -1 || creatureFound->item_num == itemNum)
continue;
target = &Items[creatureFound->item_num];
switch (flags) {
case 1: // MONK
if (target->objectID != ID_BANDIT1 && target->objectID != ID_BANDIT2)
continue;
break;
case 0: // BANDIT (Mercenary)
if (target->objectID != ID_MONK1 && target->objectID != ID_MONK2)
continue;
break;
default:
continue;
}
x = (target->pos.x - item->pos.x) >> 6;
y = (target->pos.y - item->pos.y) >> 6;
z = (target->pos.z - item->pos.z) >> 6;
distance = SQR(z) + SQR(y) + SQR(x);
if (distance < bestDistance) {
bestItem = target;
bestDistance = distance;
}
}

if (bestItem == NULL) {
if (flags == 0 || MonksAttackLara) {
creature->enemy = LaraItem;
} else {
creature->enemy = NULL;
}
return;
}

if (flags == 0 || MonksAttackLara) {
x = (LaraItem->pos.x - item->pos.x) >> 6;
y = (LaraItem->pos.y - item->pos.y) >> 6;
z = (LaraItem->pos.z - item->pos.z) >> 6;
distance = SQR(z) + SQR(y) + SQR(x);
if (distance < bestDistance) {
bestItem = LaraItem;
bestDistance = distance;
}
}

target = creature->enemy;
if (target != NULL && target->status == ITEM_ACTIVE) {
x = (target->pos.x - item->pos.x) >> 6;
y = (target->pos.y - item->pos.y) >> 6;
z = (target->pos.z - item->pos.z) >> 6;
distance = SQR(z) + SQR(y) + SQR(x);
if (distance < (bestDistance + 0x400000)) {
creature->enemy = bestItem;
}
} else {
creature->enemy = bestItem;
}
}

/*
* Inject function
*/
Expand Down Expand Up @@ -125,6 +280,5 @@ void Inject_Box() {
// INJECT(0x004100F0, CreatureVault);

INJECT(0x00410230, CreatureKill);

// INJECT(0x004103A0, GetBaddieTarget);
INJECT(0x004103A0, GetBaddieTarget);
}
13 changes: 6 additions & 7 deletions game/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
/*
* Function list
*/
#define InitialiseCreature ((void(__cdecl*)(__int16)) 0x0040E190)

// 0x0040E1C0: CreatureActive

#define CreatureAIInfo ((void(__cdecl*)(ITEM_INFO *, AI_INFO *)) 0x0040E210)
#define InitialiseCreature ((void(__cdecl*)(__int16)) 0x0040E190)
#define CreatureActive ((BOOL(__cdecl*)(__int16)) 0x0040E1C0)
#define CreatureAIInfo ((void(__cdecl*)(ITEM_INFO*,AI_INFO*)) 0x0040E210)

// 0x0040E470: SearchLOT
// 0x0040E670: UpdateLOT
Expand All @@ -40,7 +39,7 @@
// 0x0040E880: EscapeBox
// 0x0040E930: ValidBox

#define CreatureMood ((void(__cdecl*)(ITEM_INFO *, AI_INFO *, BOOL)) 0x0040E9E0)
#define CreatureMood ((void(__cdecl*)(ITEM_INFO*, AI_INFO*, BOOL)) 0x0040E9E0)

// 0x0040EE50: CalculateTarget
// 0x0040F2B0: CreatureCreature
Expand All @@ -62,7 +61,7 @@ void __cdecl CreatureDie(__int16 itemID, BOOL explode); // 0x0040F440
// 0x004100F0: CreatureVault

void __cdecl CreatureKill(ITEM_INFO *item, int killAnim, int killState, int laraKillState); // 0x00410230

// 0x004103A0: GetBaddieTarget
// NOTE: 1 = Monk, 0 = Bandit
void __cdecl GetBaddieTarget(__int16 itemNum, int flags); // 0x004103A0

#endif // BOX_H_INCLUDED
10 changes: 10 additions & 0 deletions game/cinema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ int __cdecl StartCinematic(int levelID) {
return 2;
}

// NOTE: fix lara hair waving in air,
// Caused by the cheat fly mode being not reset when cutscene is played !
if (Lara.water_status == LWS_Cheat) {
Lara.water_status = LWS_AboveWater;
LaraItem->currentAnimState = AS_STOP;
LaraItem->goalAnimState = AS_STOP;
LaraItem->animNumber = 11;
LaraItem->frameNumber = Anims[LaraItem->animNumber].frameBase;
}

InitCinematicRooms();
InitialisePlayer1(Lara.item_number);
Camera.targetAngle = CineTargetAngle;
Expand Down
Loading