This commit is contained in:
Woops 2020-05-30 13:03:02 -05:00
commit 05e20e201e
434 changed files with 20109 additions and 19423 deletions

View file

@ -1,12 +1,175 @@
#pragma once #pragma once
#include "phd_global.h"
#include "items.h"
#include "level.h"
#include "..\Global\global.h" typedef enum MOOD_TYPE
{
BORED_MOOD,
ATTACK_MOOD,
ESCAPE_MOOD,
STALK_MOOD
};
typedef enum TARGET_TYPE
{
NO_TARGET,
PRIME_TARGET,
SECONDARY_TARGET
};
typedef enum ZONE_TYPE
{
ZONE_NULL = -1, // default zone
ZONE_SKELLY = 0,
ZONE_BASIC,
ZONE_FLYER,
ZONE_HUMAN_CLASSIC,
ZONE_WATER,
ZONE_MAX,
/// custom zone (using zone above for LOT.zone):
ZONE_HUMAN_JUMP_AND_MONKEY,
ZONE_HUMAN_JUMP,
ZONE_SPIDER,
ZONE_BLOCKABLE, // for trex, shiva, etc..
ZONE_SOPHIALEE, // dont want sophia to go down again !
ZONE_APE, // only 2 click climb
};
typedef struct BOX_NODE
{
short exitBox;
unsigned short searchNumber;
short nextExpansion;
short boxNumber;
};
typedef struct BOX_INFO
{
unsigned char left;
unsigned char right;
unsigned char top;
unsigned char bottom;
short height;
short overlapIndex;
};
typedef struct AI_INFO
{
short zoneNumber;
short enemyZone;
int distance;
int ahead;
int bite;
short angle;
short xAngle;
short enemyFacing;
};
typedef struct BITE_INFO
{
int x;
int y;
int z;
int meshNum;
};
typedef struct LOT_INFO
{
BOX_NODE* node;
short head;
short tail;
unsigned short searchNumber;
unsigned short blockMask;
short step;
short drop;
short zoneCount;
short targetBox;
short requiredBox;
short fly;
bool canJump;
bool canMonkey;
bool isAmphibious;
bool isJumping;
bool isMonkeying;
PHD_VECTOR target;
ZONE_TYPE zone;
};
typedef struct CREATURE_INFO
{
short jointRotation[4];
short maximumTurn;
short flags;
bool alerted;
bool headLeft;
bool headRight;
bool reachedGoal;
bool hurtByLara;
bool patrol2;
bool jumpAhead;
bool monkeyAhead;
MOOD_TYPE mood;
ITEM_INFO* enemy;
ITEM_INFO aiTarget;
short pad;
short itemNum;
PHD_VECTOR target;
LOT_INFO LOT;
};
#define CreatureEffectFunction short(int x, int y, int z, short speed, short yRot, short roomNumber)
#define XZ_GET_SECTOR(room, x, z) (room->floor[((z) >> WALL_SHIFT) + ((x) >> WALL_SHIFT) * room->xSize])
constexpr auto UNIT_SHADOW = 256;
constexpr auto NO_SHADOW = 0;
constexpr auto DEFAULT_RADIUS = 10;
constexpr auto ROT_X = 0x0004;
constexpr auto ROT_Y = 0x0008;
constexpr auto ROT_Z = 0x0010;
constexpr auto BOX_BLOCKED = (1 << 14); // unpassable for other enemies, always set for movable blocks & closed doors
constexpr auto BOX_LAST = (1 << 15); // unpassable by large enemies (T-Rex, Centaur, etc), always set behind doors
constexpr auto TIMID = 0;
constexpr auto VIOLENT = 1;
constexpr auto ONESHOT = 0x100;
constexpr auto DATA_TYPE = 0x1F;
constexpr auto DATA_TILT = 0xF; // tile type (FLOOR_TYPE enum)
constexpr auto DATA_STATIC = 0xFF; // probably add static collision
constexpr auto END_BIT = 0x8000;
constexpr auto VALUE_BITS = 0x3FF;
constexpr auto CODE_BITS = 0x3E00;
constexpr auto REVERSE = 0x4000;
constexpr auto SWONESHOT = 0x40;
constexpr auto ATONESHOT = 0x80;
constexpr auto BLOCKABLE = 0x8000;
constexpr auto BLOCKED = 0x4000;
constexpr auto OVERLAP_INDEX = 0x3FFF;
constexpr auto SEARCH_NUMBER = 0x7FFF;
constexpr auto BLOCKED_SEARCH = 0x8000;
constexpr auto NO_BOX = 0x7FF;
constexpr auto BOX_JUMP = 0x800;
constexpr auto BOX_MONKEY = 0x2000;
constexpr auto BOX_NUMBER = 0x7FF;
constexpr auto BOX_END_BIT = 0x8000;
constexpr auto EXPAND_LEFT = 0x1;
constexpr auto EXPAND_RIGHT = 0x2;
constexpr auto EXPAND_TOP = 0x4;
constexpr auto EXPAND_BOTTOM = 0x8;
constexpr auto NO_FLYING = 0;
constexpr auto FLY_ZONE = 0x2000;
constexpr auto CLIP_LEFT = 0x1;
constexpr auto CLIP_RIGHT = 0x2;
constexpr auto CLIP_TOP = 0x4;
constexpr auto CLIP_BOTTOM = 0x8;
constexpr auto SECONDARY_CLIP = 0x10;
constexpr auto ALL_CLIP = (CLIP_LEFT | CLIP_RIGHT | CLIP_TOP | CLIP_BOTTOM);
constexpr auto SLOPE_DIF = 60;
extern int NumberBoxes; extern int NumberBoxes;
extern BOX_INFO* Boxes; extern BOX_INFO* Boxes;
extern int NumberOverlaps; extern int NumberOverlaps;
extern short* Overlaps; extern short* Overlaps;
extern short* Zones[5][2]; extern short* Zones[ZONE_MAX][2];
void GetCreatureMood(ITEM_INFO* item, AI_INFO* info, int violent); void GetCreatureMood(ITEM_INFO* item, AI_INFO* info, int violent);
void CreatureMood(ITEM_INFO* item, AI_INFO* info, int violent); void CreatureMood(ITEM_INFO* item, AI_INFO* info, int violent);
@ -22,8 +185,8 @@ short AIGuard(CREATURE_INFO* creature);
void AlertNearbyGuards(ITEM_INFO* item); void AlertNearbyGuards(ITEM_INFO* item);
void AlertAllGuards(short itemNumber); void AlertAllGuards(short itemNumber);
void CreatureKill(ITEM_INFO* item, int killAnim, int killState, short laraAnim); void CreatureKill(ITEM_INFO* item, int killAnim, int killState, short laraAnim);
short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, short (*generate)(int x, int y, int z, short speed, short yrot, short roomNumber)); short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, function<CreatureEffectFunction> func);
short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, short(*generate)(int x, int y, int z, short speed, short yrot, short roomNumber)); short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, function<CreatureEffectFunction> func);
void CreatureUnderwater(ITEM_INFO* item, int depth); void CreatureUnderwater(ITEM_INFO* item, int depth);
void CreatureFloat(short itemNumber); void CreatureFloat(short itemNumber);
void CreatureJoint(ITEM_INFO* item, short joint, short required); void CreatureJoint(ITEM_INFO* item, short joint, short required);

View file

@ -1,34 +1,33 @@
#include "framework.h"
#include "box.h" #include "box.h"
#include "..\Global\global.h"
#include "items.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "lot.h" #include "lot.h"
#include "deltapak.h"
#include "items.h"
#include "Lara.h" #include "Lara.h"
#include "draw.h" #include "draw.h"
#include "sphere.h" #include "sphere.h"
#include "misc.h" #include "misc.h"
#include "camera.h" #include "camera.h"
#include "control.h" #include "control.h"
#include "../Specific/setup.h" #include "setup.h"
#include "../Specific/level.h" #include "trmath.h"
#include "objectslist.h"
int NumberBoxes; int NumberBoxes;
BOX_INFO* Boxes; BOX_INFO* Boxes;
int NumberOverlaps; int NumberOverlaps;
short* Overlaps; short* Overlaps;
short* Zones[5][2]; short* Zones[ZONE_MAX][2];
#define ESCAPE_DIST (WALL_SIZE*5) #define CHECK_CLICK(x) CLICK(x) / 2
#define STALK_DIST (WALL_SIZE*3) #define ESCAPE_DIST SECTOR(5)
#define STALK_DIST SECTOR(3)
#define REACHED_GOAL_RADIUS 640 #define REACHED_GOAL_RADIUS 640
#define ATTACK_RANGE SQUARE(WALL_SIZE*3) #define ATTACK_RANGE SQUARE(SECTOR(3))
#define ESCAPE_CHANCE 0x800 #define ESCAPE_CHANCE 0x800
#define RECOVER_CHANCE 0x100 #define RECOVER_CHANCE 0x100
#define BIFF_AVOID_TURN 1536 #define BIFF_AVOID_TURN 1536
#define FEELER_DISTANCE 512 #define FEELER_DISTANCE 512
#define FEELER_ANGLE ANGLE(45) #define FEELER_ANGLE ANGLE(45.0f)
void DropBaddyPickups(ITEM_INFO* item) void DropBaddyPickups(ITEM_INFO* item)
{ {
@ -124,7 +123,7 @@ short SameZone(CREATURE_INFO* creature, ITEM_INFO* targetItem)
targetItem->boxNumber = XZ_GET_SECTOR(r, targetItem->pos.xPos - r->x, targetItem->pos.zPos - r->z).box; targetItem->boxNumber = XZ_GET_SECTOR(r, targetItem->pos.xPos - r->x, targetItem->pos.zPos - r->z).box;
zone = Zones[creature->LOT.zone][FlipStatus]; zone = Zones[creature->LOT.zone][FlipStatus];
return (zone[item->boxNumber] == zone[targetItem->boxNumber]); return zone[item->boxNumber] == zone[targetItem->boxNumber];
} }
short AIGuard(CREATURE_INFO* creature) short AIGuard(CREATURE_INFO* creature)
@ -160,7 +159,7 @@ short AIGuard(CREATURE_INFO* creature)
if (creature->headRight) if (creature->headRight)
return 0; return 0;
return -ANGLE(90); return -ANGLE(90.0f);
} }
void AlertNearbyGuards(ITEM_INFO* item) void AlertNearbyGuards(ITEM_INFO* item)
@ -249,9 +248,9 @@ void CreatureKill(ITEM_INFO* item, int killAnim, int killState, short laraKillSt
Camera.pos.roomNumber = LaraItem->roomNumber; Camera.pos.roomNumber = LaraItem->roomNumber;
Camera.type = CHASE_CAMERA; Camera.type = CHASE_CAMERA;
Camera.flags = FOLLOW_CENTRE; Camera.flags = CF_FOLLOW_CENTER;
Camera.targetAngle = ANGLE(170); Camera.targetAngle = ANGLE(170.0f);
Camera.targetElevation = -ANGLE(25); Camera.targetElevation = -ANGLE(25.0f);
// TODO: exist in TR5 but just commented in case. // TODO: exist in TR5 but just commented in case.
/* /*
@ -263,24 +262,24 @@ void CreatureKill(ITEM_INFO* item, int killAnim, int killState, short laraKillSt
*/ */
} }
short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, short (*generate)(int x, int y, int z, short speed, short yrot, short roomNumber)) short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, function<CreatureEffectFunction> func)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
pos.x = bite->x; pos.x = bite->x;
pos.y = bite->y; pos.y = bite->y;
pos.z = bite->z; pos.z = bite->z;
GetJointAbsPosition(item, &pos, bite->meshNum); GetJointAbsPosition(item, &pos, bite->meshNum);
return generate(pos.x, pos.y, pos.z, damage, angle, item->roomNumber); return func(pos.x, pos.y, pos.z, damage, angle, item->roomNumber);
} }
short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, short(*generate)(int x, int y, int z, short speed, short yrot, short roomNumber)) short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, function<CreatureEffectFunction> func)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
pos.x = bite->x; pos.x = bite->x;
pos.y = bite->y; pos.y = bite->y;
pos.z = bite->z; pos.z = bite->z;
GetJointAbsPosition(item, &pos, bite->meshNum); GetJointAbsPosition(item, &pos, bite->meshNum);
return generate(pos.x, pos.y, pos.z, item->speed, item->pos.yRot, item->roomNumber); return func(pos.x, pos.y, pos.z, item->speed, item->pos.yRot, item->roomNumber);
} }
void CreatureUnderwater(ITEM_INFO* item, int depth) void CreatureUnderwater(ITEM_INFO* item, int depth)
@ -334,7 +333,7 @@ void CreatureFloat(short itemNumber)
short roomNumber; short roomNumber;
item = &Items[itemNumber]; item = &Items[itemNumber];
item->hitPoints = -16384; item->hitPoints = NOT_TARGETABLE;
item->pos.xRot = 0; item->pos.xRot = 0;
waterLevel = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber); waterLevel = GetWaterHeight(item->pos.xPos, item->pos.yPos, item->pos.zPos, item->roomNumber);
@ -360,7 +359,7 @@ void CreatureFloat(short itemNumber)
{ {
item->pos.yPos = waterLevel; item->pos.yPos = waterLevel;
item->collidable = false; item->collidable = false;
item->status = ITEM_DEACTIVATED; item->status = ITEM_DESACTIVATED;
DisableBaddieAI(itemNumber); DisableBaddieAI(itemNumber);
RemoveActiveItem(itemNumber); RemoveActiveItem(itemNumber);
item->afterDeath = 1; item->afterDeath = 1;
@ -536,7 +535,7 @@ int CreatureAnimation(short itemNumber, short angle, short tilt)
} }
AnimateItem(item); AnimateItem(item);
if (item->status == ITEM_DEACTIVATED) if (item->status == ITEM_DESACTIVATED)
{ {
CreatureDie(itemNumber, FALSE); CreatureDie(itemNumber, FALSE);
return FALSE; return FALSE;

View file

@ -1,8 +1,9 @@
#include "framework.h"
#include "bubble.h" #include "bubble.h"
#include "../Specific/level.h" #include "level.h"
#include "control.h" #include "control.h"
#include "trmath.h"
using namespace std; #include "objectslist.h"
extern vector<BUBBLE_STRUCT> Bubbles = vector<BUBBLE_STRUCT>(MAX_BUBBLES); extern vector<BUBBLE_STRUCT> Bubbles = vector<BUBBLE_STRUCT>(MAX_BUBBLES);
@ -57,16 +58,19 @@ int GetFreeBubble() //8BEAC(<), 8DEF0(<) (F)
{ {
int oldestAgeIndex = 0; int oldestAgeIndex = 0;
int oldestAge = 0; int oldestAge = 0;
for (int i = 0; i < MAX_BUBBLES; i++) { for (int i = 0; i < MAX_BUBBLES; i++)
{
BUBBLE_STRUCT* bub = &Bubbles[i]; BUBBLE_STRUCT* bub = &Bubbles[i];
if (!bub->active) { if (!bub->active)
return i; return i;
}
if (oldestAge < bub->age) { if (oldestAge < bub->age)
{
oldestAge = bub->age; oldestAge = bub->age;
oldestAgeIndex = i; oldestAgeIndex = i;
} }
} }
//incase we dont find any non-active bubble, take the one with the oldest age //incase we dont find any non-active bubble, take the one with the oldest age
return oldestAgeIndex; return oldestAgeIndex;
} }

View file

@ -1,9 +1,4 @@
#pragma once #pragma once
#include <d3d11.h>
#include <SimpleMath.h>
#include <vector>
#include "../Global/types.h"
#include "../Global/constants.h"
#include "effect2.h" #include "effect2.h"
constexpr float MAX_BUBBLES = 256; constexpr float MAX_BUBBLES = 256;
@ -13,14 +8,14 @@ constexpr int BUBBLE_FLAG_HIGH_AMPLITUDE = 0x4;
struct BUBBLE_STRUCT struct BUBBLE_STRUCT
{ {
DirectX::SimpleMath::Vector4 color; Vector4 color;
DirectX::SimpleMath::Vector4 sourceColor; Vector4 sourceColor;
DirectX::SimpleMath::Vector4 destinationColor; Vector4 destinationColor;
DirectX::SimpleMath::Vector3 worldPositionCenter; // goes straight up Vector3 worldPositionCenter; // goes straight up
DirectX::SimpleMath::Vector3 worldPosition; // actual position with wave motion Vector3 worldPosition; // actual position with wave motion
DirectX::SimpleMath::Vector3 amplitude; Vector3 amplitude;
DirectX::SimpleMath::Vector3 wavePeriod; Vector3 wavePeriod;
DirectX::SimpleMath::Vector3 waveSpeed; Vector3 waveSpeed;
float speed; float speed;
float size; float size;
float destinationSize; float destinationSize;

View file

@ -1,20 +1,19 @@
#include "Camera.h" #include "framework.h"
#include <d3d9.h> #include "camera.h"
#include <stdio.h>
#include "draw.h" #include "draw.h"
#include "lara.h" #include "lara.h"
#include "effects.h" #include "effect.h"
#include "effect2.h" #include "effect2.h"
#include "debris.h" #include "debris.h"
#include "larafire.h" #include "larafire.h"
#include "lara.h" #include "lara.h"
#include "flmtorch.h" #include "flmtorch.h"
#include "sphere.h" #include "sphere.h"
#include "../Specific/level.h" #include "level.h"
#include "collide.h" #include "collide.h"
#include "sound.h" #include "sound.h"
#include "savegame.h" #include "savegame.h"
#include "../Specific/input.h" #include "input.h"
struct OLD_CAMERA struct OLD_CAMERA
{ {
@ -1097,7 +1096,7 @@ void LookCamera(ITEM_INFO* item)
c = GetCeiling(floor, x, y, z); c = GetCeiling(floor, x, y, z);
if ((Rooms[roomNumber].flags & ENV_FLAG_SWAMP)) if ((Rooms[roomNumber].flags & ENV_FLAG_SWAMP))
Camera.pos.y = Rooms[roomNumber].y - 256; Camera.pos.y = Rooms[roomNumber].y - 256;
else if (y < c || y > h || c >= h || h == NO_HEIGHT || c == NO_HEIGHT) else if (y < c || y > h || c >= h || h == NO_HEIGHT || c == NO_HEIGHT)
mgLOS(&Camera.target, &Camera.pos, 0); mgLOS(&Camera.target, &Camera.pos, 0);
x = Camera.pos.x; x = Camera.pos.x;
@ -1492,7 +1491,7 @@ void ConfirmCameraTargetPos()
pos.y = 0; pos.y = 0;
pos.z = 0; pos.z = 0;
GetLaraJointPosition(&pos, LM_LHAND); GetLaraJointPosition(&pos, LM_TORSO);
if (Camera.laraNode != -1) if (Camera.laraNode != -1)
{ {
@ -1699,7 +1698,7 @@ void CalculateCamera()
Camera.target.y = y; Camera.target.y = y;
if (Camera.type if (Camera.type
&& Camera.flags != CHASE_OBJECT && Camera.flags != CF_CHASE_OBJECT
&& (Camera.number != -1 &&(SniperCamActive = Camera.fixed[Camera.number].flags & 3, Camera.fixed[Camera.number].flags & 2))) && (Camera.number != -1 &&(SniperCamActive = Camera.fixed[Camera.number].flags & 3, Camera.fixed[Camera.number].flags & 2)))
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
@ -1772,7 +1771,7 @@ void CalculateCamera()
Camera.target.z = LastTarget.z; Camera.target.z = LastTarget.z;
} }
if (Camera.type && Camera.flags != CHASE_OBJECT) if (Camera.type && Camera.flags != CF_CHASE_OBJECT)
FixedCamera(item); FixedCamera(item);
else else
ChaseCamera(item); ChaseCamera(item);

View file

@ -1,7 +1,57 @@
#pragma once #pragma once
#include "phd_global.h"
#include "items.h"
#include "..\Global\global.h" typedef enum CAMERA_TYPE
#include <d3d9.h> {
CHASE_CAMERA,
FIXED_CAMERA,
LOOK_CAMERA,
COMBAT_CAMERA,
CINEMATIC_CAMERA,
HEAVY_CAMERA
};
typedef struct CAMERA_INFO
{
GAME_VECTOR pos; // size=16, offset=0
GAME_VECTOR target; // size=16, offset=16
CAMERA_TYPE type; // size=4, offset=32
CAMERA_TYPE oldType; // size=4, offset=36
int shift; // size=0, offset=40
int flags; // size=0, offset=44
int fixedCamera; // size=0, offset=48
int numberFrames; // size=0, offset=52
int bounce; // size=0, offset=56
int underwater; // size=0, offset=60
int targetDistance; // size=0, offset=64
short targetAngle; // size=0, offset=68
short targetElevation; // size=0, offset=70
short actualElevation; // size=0, offset=72
short actualAngle; // size=0, offset=74
short laraNode; // size=0, offset=76
short box; // size=0, offset=78
short number; // size=0, offset=80
short last; // size=0, offset=82
short timer; // size=0, offset=84
short speed; // size=0, offset=86
short targetspeed; // size=0, offset=88
ITEM_INFO* item; // size=144, offset=92
ITEM_INFO* lastItem; // size=144, offset=96
OBJECT_VECTOR* fixed; // size=16, offset=100
int mikeAtLara; // size=0, offset=104
PHD_VECTOR mikePos; // size=12, offset=108
};
enum CAMERA_FLAGS
{
CF_FOLLOW_CENTER = 1,
CF_NO_CHUNKY = 2,
CF_CHASE_OBJECT = 3,
};
constexpr auto MAX_CAMERA = 18;
constexpr auto NO_MINY = 0xFFFFFF;
extern PHD_VECTOR CurrentCameraPosition; extern PHD_VECTOR CurrentCameraPosition;
extern CAMERA_INFO Camera; extern CAMERA_INFO Camera;

View file

@ -1,34 +1,32 @@
#include "framework.h"
#include "collide.h" #include "collide.h"
#include "draw.h" #include "draw.h"
#include "Lara.h" #include "Lara.h"
#include "..\Global\global.h"
#include <stdio.h>
#include "items.h" #include "items.h"
#include "effects.h" #include "effect.h"
#include "sphere.h" #include "sphere.h"
#include "misc.h" #include "misc.h"
#include "../Specific/setup.h" #include "setup.h"
#include "../Specific/level.h"
#include "sound.h" #include "sound.h"
#include "trmath.h"
char LM[] = { char LM[] =
LJ_HIPS, {
LJ_LTHIGH, LM_HIPS,
LJ_LSHIN, LM_LTHIGH,
LJ_LFOOT, LM_LSHIN,
LJ_RTHIGH, LM_LFOOT,
LJ_RSHIN, LM_RTHIGH,
LJ_RFOOT, LM_RSHIN,
LJ_TORSO, LM_RFOOT,
LJ_RINARM, LM_TORSO,
LJ_ROUTARM, LM_RINARM,
LJ_RHAND, LM_ROUTARM,
LJ_LINARM, LM_RHAND,
LJ_LOUTARM, LM_LINARM,
LJ_LHAND, LM_LOUTARM,
LJ_HEAD, LM_LHAND,
LM_HEAD,
}; };
int XFront, ZFront; int XFront, ZFront;
@ -66,7 +64,7 @@ int CollideStaticObjects(COLL_INFO* coll, int x, int y, int z, short roomNumber,
for (int j = room->numMeshes; j > 0; j--, mesh++) for (int j = room->numMeshes; j > 0; j--, mesh++)
{ {
STATIC_INFO* sInfo = &StaticObjects[mesh->staticNumber]; StaticInfo* sInfo = &StaticObjects[mesh->staticNumber];
if ((sInfo->flags & 1)) // No collision if ((sInfo->flags & 1)) // No collision
continue; continue;
@ -141,7 +139,7 @@ int GetCollidedObjects(ITEM_INFO* collidingItem, int radius, int onlyVisible, IT
for (int j = 0; j < room->numMeshes; j++) for (int j = 0; j < room->numMeshes; j++)
{ {
MESH_INFO* mesh = &room->mesh[j]; MESH_INFO* mesh = &room->mesh[j];
STATIC_INFO* staticMesh = &StaticObjects[mesh->staticNumber]; StaticInfo* staticMesh = &StaticObjects[mesh->staticNumber];
if (mesh->Flags & 1) if (mesh->Flags & 1)
{ {
@ -1407,14 +1405,14 @@ void LaraBaddieCollision(ITEM_INFO* l, COLL_INFO* coll)
if (item->collidable && item->status != ITEM_INVISIBLE) if (item->collidable && item->status != ITEM_INVISIBLE)
{ {
obj = &Objects[item->objectNumber]; obj = &Objects[item->objectNumber];
if (obj->collision) if (obj->collision != nullptr)
{ {
int x = l->pos.xPos - item->pos.xPos; int x = l->pos.xPos - item->pos.xPos;
int y = l->pos.yPos - item->pos.yPos; int y = l->pos.yPos - item->pos.yPos;
int z = l->pos.zPos - item->pos.zPos; int z = l->pos.zPos - item->pos.zPos;
if (x > -3072 && x < 3072 && z > -3072 && z < 3072 && y > -3072 && y < 3072) if (x > -3072 && x < 3072 && z > -3072 && z < 3072 && y > -3072 && y < 3072)
(*obj->collision)(itemNumber, l, coll); obj->collision(itemNumber, l, coll);
} }
} }
itemNumber = item->nextItem; itemNumber = item->nextItem;

View file

@ -1,15 +1,106 @@
#pragma once #pragma once
#include "phd_global.h"
#include "..\Global\global.h" #include "level.h"
// used by coll->badPos // used by coll->badPos
#define NO_BAD_POS (-NO_HEIGHT) #define NO_BAD_POS (-NO_HEIGHT)
// used by coll->badNeg // used by coll->badNeg
#define NO_BAD_NEG NO_HEIGHT #define NO_BAD_NEG NO_HEIGHT
struct BOUNDING_BOX
{
short X1;
short X2;
short Y1;
short Y2;
short Z1;
short Z2;
};
struct COLL_FLOOR
{
int floor;
int ceiling;
int type;
int splitFloor;
int splitCeiling;
};
struct COLL_INFO
{
/*
COLL_FLOOR middle; // mid
COLL_FLOOR middle_left; // left
COLL_FLOOR middle_right; // right
COLL_FLOOR front; // front
COLL_FLOOR front_left; // left2
COLL_FLOOR front_right; // right2
*/
int midFloor;
int midCeiling;
int midType;
int midSplitFloor;
int midSplitCeil;
int frontFloor;
int frontCeiling;
int frontType;
int frontSplitFloor;
int frontSplitCeil;
int leftFloor;
int leftCeiling;
int leftType;
int leftSplitFloor;
int leftSplitCeil;
int rightFloor;
int rightCeiling;
int rightType;
int rightSplitFloor;
int rightSplitCeil;
int leftFloor2;
int leftCeiling2;
int leftType2;
int leftSplitFloor2;
int leftSplitCeil2;
int rightFloor2;
int rightCeiling2;
int rightType2;
int rightSplitFloor2;
int rightSplitCeil2;
int radius;
int badPos;
int badNeg;
int badCeiling;
PHD_VECTOR shift;
PHD_VECTOR old;
short oldAnimState;
short oldAnimNumber;
short oldFrameNumber;
short facing;
short quadrant;
short collType; // CT_enum
short* trigger;
signed char tiltX;
signed char tiltZ;
bool hitByBaddie;
bool hitStatic;
bool slopesAreWalls;
bool slopesArePits;
bool lavaIsPit;
bool enableBaddiePush;
bool enableSpaz;
bool hitCeiling;
};
extern BOUNDING_BOX GlobalCollisionBounds; extern BOUNDING_BOX GlobalCollisionBounds;
extern ITEM_INFO* CollidedItems[1024]; constexpr auto MAX_ITEMS = 1024;
extern MESH_INFO* CollidedMeshes[1024]; extern ITEM_INFO* CollidedItems[MAX_ITEMS];
extern MESH_INFO* CollidedMeshes[MAX_ITEMS];
void GenericSphereBoxCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); void GenericSphereBoxCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
int CollideStaticObjects(COLL_INFO* coll, int x, int y, int z, short roomNumber, int hite); int CollideStaticObjects(COLL_INFO* coll, int x, int y, int z, short roomNumber, int hite);

View file

@ -1,9 +1,9 @@
#include "framework.h"
#include "collide.h"
#include "control.h" #include "control.h"
#include "..\Global\global.h"
#include "pickup.h" #include "pickup.h"
#include "Camera.h" #include "camera.h"
#include "Lara.h" #include "Lara.h"
#include "hair.h" #include "hair.h"
#include "items.h" #include "items.h"
@ -14,7 +14,7 @@
#include "lot.h" #include "lot.h"
#include "pickup.h" #include "pickup.h"
#include "draw.h" #include "draw.h"
#include "healt.h" #include "health.h"
#include "savegame.h" #include "savegame.h"
#include "sound.h" #include "sound.h"
#include "spotcam.h" #include "spotcam.h"
@ -25,23 +25,20 @@
#include "rope.h" #include "rope.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "traps.h" #include "traps.h"
#include "effects.h" #include "effect.h"
#include "sphere.h" #include "sphere.h"
#include "debris.h" #include "debris.h"
#include "larafire.h" #include "larafire.h"
#include "..\Objects\oldobjects.h"
#include "footprint.h" #include "footprint.h"
#include "..\Specific\level.h" #include "level.h"
#include "..\Specific\input.h" #include "input.h"
#include "..\Specific\init.h" #include "init.h"
#include "..\Specific\winmain.h" #include "winmain.h"
#include "../Specific/input.h" #include "Renderer11.h"
#include "setup.h"
#include <process.h> #include "tr5_rats_emitter.h"
#include <stdio.h> #include "tr5_bats_emitter.h"
#include "..\Renderer\Renderer11.h" #include "tr5_spider_emitter.h"
#include "../Specific/setup.h"
short ShatterSounds[18][10] = short ShatterSounds[18][10] =
{ {
@ -77,8 +74,8 @@ int RumbleTimer = 0;
int InGameCnt = 0; int InGameCnt = 0;
byte IsAtmospherePlaying = 0; byte IsAtmospherePlaying = 0;
byte FlipStatus = 0; byte FlipStatus = 0;
int FlipStats[255]; int FlipStats[MAX_FLIPMAP];
int FlipMap[255]; int FlipMap[MAX_FLIPMAP];
bool InItemControlLoop; bool InItemControlLoop;
short ItemNewRoomNo; short ItemNewRoomNo;
short ItemNewRooms[512]; short ItemNewRooms[512];
@ -114,7 +111,7 @@ int InitialiseGame;
int RequiredStartPos; int RequiredStartPos;
int WeaponDelay; int WeaponDelay;
int WeaponEnemyTimer; int WeaponEnemyTimer;
int HeightType; HEIGHT_TYPES HeightType;
int HeavyTriggered; int HeavyTriggered;
short SkyPos1; short SkyPos1;
short SkyPos2; short SkyPos2;
@ -126,9 +123,9 @@ int CutSeqNum;
int CutSeqTriggered; int CutSeqTriggered;
int GlobalPlayingCutscene; int GlobalPlayingCutscene;
int CurrentLevel; int CurrentLevel;
int SoundActive; bool SoundActive;
int DoTheGame; bool DoTheGame;
int Unk_876C48; bool ThreadEnded;
int OnFloor; int OnFloor;
int SmokeWindX; int SmokeWindX;
int SmokeWindZ; int SmokeWindZ;
@ -532,9 +529,8 @@ GAME_STATUS ControlPhase(int numFrames, int demoMode)
return GAME_STATUS_NONE; return GAME_STATUS_NONE;
} }
unsigned __stdcall GameMain(void*) unsigned CALLBACK GameMain(void*)
{ {
//DB_Log(2, "GameMain - DLL");
printf("GameMain\n"); printf("GameMain\n");
// Initialise legacy memory buffer and game timer // Initialise legacy memory buffer and game timer
@ -550,10 +546,10 @@ unsigned __stdcall GameMain(void*)
DoTheGame = false; DoTheGame = false;
// Finish the thread // Finish the thread
PostMessageA((HWND)WindowsHandle, 0x10u, 0, 0); PostMessage(WindowsHandle, WM_CLOSE, NULL, NULL);
_endthreadex(1); EndThread();
return 1; return TRUE;
} }
GAME_STATUS DoTitle(int index) GAME_STATUS DoTitle(int index)
@ -1020,7 +1016,7 @@ void TestTriggers(short* data, int heavy, int HeavyFlags)
if (item->active && Objects[item->objectNumber].intelligent) if (item->active && Objects[item->objectNumber].intelligent)
{ {
item->hitPoints = -16384; item->hitPoints = NOT_TARGETABLE;
DisableBaddieAI(value); DisableBaddieAI(value);
KillItem(value); KillItem(value);
} }
@ -1041,7 +1037,7 @@ void TestTriggers(short* data, int heavy, int HeavyFlags)
{ {
if (Objects[item->objectNumber].intelligent) if (Objects[item->objectNumber].intelligent)
{ {
if (item->status != ITEM_INACTIVE) if (item->status != ITEM_NOT_ACTIVE)
{ {
if (item->status == ITEM_INVISIBLE) if (item->status == ITEM_INVISIBLE)
{ {
@ -2138,7 +2134,6 @@ int GetTargetOnLOS(GAME_VECTOR* src, GAME_VECTOR* dest, int DrawTarget, int firi
flag = 0; flag = 0;
itemNumber = ObjectOnLOS2(src, dest, &vector, &mesh); itemNumber = ObjectOnLOS2(src, dest, &vector, &mesh);
if (itemNumber != 999) if (itemNumber != 999)
{ {
target.x = vector.x - (vector.x - src->x >> 5); target.x = vector.x - (vector.x - src->x >> 5);
@ -2280,7 +2275,7 @@ int GetTargetOnLOS(GAME_VECTOR* src, GAME_VECTOR* dest, int DrawTarget, int firi
} }
} }
} }
if (item->status != ITEM_DEACTIVATED) if (item->status != ITEM_DESACTIVATED)
{ {
AddActiveItem(itemNumber); AddActiveItem(itemNumber);
item->status = ITEM_ACTIVE; item->status = ITEM_ACTIVE;
@ -2388,7 +2383,7 @@ int ObjectOnLOS2(GAME_VECTOR* start, GAME_VECTOR* end, PHD_VECTOR* vec, MESH_INF
{ {
item = &Items[linknum]; item = &Items[linknum];
if (item->status != ITEM_DEACTIVATED if (item->status != ITEM_DESACTIVATED
&& item->status != ITEM_INVISIBLE && item->status != ITEM_INVISIBLE
&& (item->objectNumber != ID_LARA && Objects[item->objectNumber].collision != NULL && (item->objectNumber != ID_LARA && Objects[item->objectNumber].collision != NULL
|| item->objectNumber == ID_LARA && GetLaraOnLOS)) || item->objectNumber == ID_LARA && GetLaraOnLOS))
@ -2781,7 +2776,7 @@ void AnimateItem(ITEM_INFO* item)
case COMMAND_DEACTIVATE: case COMMAND_DEACTIVATE:
if (Objects[item->objectNumber].intelligent && !item->afterDeath) if (Objects[item->objectNumber].intelligent && !item->afterDeath)
item->afterDeath = 1; item->afterDeath = 1;
item->status = ITEM_DEACTIVATED; item->status = ITEM_DESACTIVATED;
break; break;
case COMMAND_SOUND_FX: case COMMAND_SOUND_FX:
case COMMAND_EFFECT: case COMMAND_EFFECT:
@ -2983,10 +2978,7 @@ void RemoveRoomFlipItems(ROOM_INFO* r)
{ {
ITEM_INFO* item = &Items[linkNum]; ITEM_INFO* item = &Items[linkNum];
if (item->flags & 0x100 if (item->flags & 0x100 && Objects[item->objectNumber].intelligent && item->hitPoints <= 0 && item->hitPoints != NOT_TARGETABLE)
&& Objects[item->objectNumber].intelligent
&& item->hitPoints <= 0
&& item->hitPoints != -16384)
{ {
KillItem(linkNum); KillItem(linkNum);
} }
@ -3090,7 +3082,7 @@ int ExplodeItemNode(ITEM_INFO* item, int Node, int NoXZVel, int bits)
if (1 << Node & item->meshBits) if (1 << Node & item->meshBits)
{ {
Num = bits; Num = bits;
if (item->objectNumber == ID_SHOOT_SWITCH1 && (CurrentLevel == 4 || CurrentLevel == 7)) if (item->objectNumber == ID_SHOOT_SWITCH1 && (CurrentLevel == 4 || CurrentLevel == 7)) // TODO: remove hardcoded think !
{ {
SoundEffect(SFX_SMASH_METAL, &item->pos, 0); SoundEffect(SFX_SMASH_METAL, &item->pos, 0);
} }
@ -3105,7 +3097,7 @@ int ExplodeItemNode(ITEM_INFO* item, int Node, int NoXZVel, int bits)
ShatterItem.sphere.x = CreatureSpheres[Node].x; ShatterItem.sphere.x = CreatureSpheres[Node].x;
ShatterItem.sphere.y = CreatureSpheres[Node].y; ShatterItem.sphere.y = CreatureSpheres[Node].y;
ShatterItem.sphere.z = CreatureSpheres[Node].z; ShatterItem.sphere.z = CreatureSpheres[Node].z;
ShatterItem.il = (ITEM_LIGHT *) &item->legacyLightData; // TODO: remove it or at last change it with the new renderer light... ShatterItem.il = (ITEM_LIGHT*) &item->legacyLightData; // TODO: remove it or at last change it with the new renderer light...
ShatterItem.flags = item->objectNumber == ID_CROSSBOW_BOLT ? 0x400 : 0; ShatterItem.flags = item->objectNumber == ID_CROSSBOW_BOLT ? 0x400 : 0;
ShatterImpactData.impactDirection = Vector3(0, -1, 0); ShatterImpactData.impactDirection = Vector3(0, -1, 0);
ShatterImpactData.impactLocation = { (float)ShatterItem.sphere.x,(float)ShatterItem.sphere.y,(float)ShatterItem.sphere.z }; ShatterImpactData.impactLocation = { (float)ShatterItem.sphere.x,(float)ShatterItem.sphere.y,(float)ShatterItem.sphere.z };
@ -3262,13 +3254,10 @@ void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift)
*rotation += deltaAngle >> shift; *rotation += deltaAngle >> shift;
} }
#define OutsideRoomTable VAR_U_(0x00EEF4AC, unsigned char*)
#define OutsideRoomOffsets ARRAY_(0x00EEF040, short, [27 * 27])
int IsRoomOutside(int x, int y, int z) int IsRoomOutside(int x, int y, int z)
{ {
return 0; return 0;
/*
short offset = OutsideRoomOffsets[((x >> 12) * 27) + (z >> 12)]; short offset = OutsideRoomOffsets[((x >> 12) * 27) + (z >> 12)];
if (offset == -1) if (offset == -1)
return -2; return -2;
@ -3329,5 +3318,5 @@ int IsRoomOutside(int x, int y, int z)
s++; s++;
} }
return -2; return -2;
} }*/
} }

View file

@ -1,14 +1,69 @@
#pragma once #pragma once
#include "phd_global.h"
#include "items.h"
#include "room.h"
#include "..\Global\global.h" enum GAME_STATUS
{
GAME_STATUS_NONE,
GAME_STATUS_NEW_GAME,
GAME_STATUS_LOAD_GAME,
GAME_STATUS_SAVE_GAME,
GAME_STATUS_EXIT_TO_TITLE,
GAME_STATUS_EXIT_GAME,
GAME_STATUS_LARA_DEAD,
GAME_STATUS_LEVEL_COMPLETED
};
#define TRIG_BITS(T) ((T & 0x3fff) >> 10) enum COLL_TYPE
{
CT_NONE = 0, // 0x00
CT_FRONT = (1 << 0), // 0x01
CT_LEFT = (1 << 1), // 0x02
CT_RIGHT = (1 << 2), // 0x04
CT_TOP = (1 << 3), // 0x08
CT_TOP_FRONT = (1 << 4), // 0x10
CT_CLAMP = (1 << 5) // 0x20
};
enum HEIGHT_TYPES
{
WALL,
SMALL_SLOPE,
BIG_SLOPE,
DIAGONAL,
SPLIT_TRI
};
enum HEADINGS
{
NORTH,
EAST,
SOUTH,
WEST
};
enum COMMAND_TYPES
{
COMMAND_NULL = 0,
COMMAND_MOVE_ORIGIN,
COMMAND_JUMP_VELOCITY,
COMMAND_ATTACK_READY,
COMMAND_DEACTIVATE,
COMMAND_SOUND_FX,
COMMAND_EFFECT
};
#define TRIG_BITS(T) ((T & 0x3FFF) >> 10)
extern int KeyTriggerActive; extern int KeyTriggerActive;
extern byte IsAtmospherePlaying; extern byte IsAtmospherePlaying;
extern byte FlipStatus; extern byte FlipStatus;
extern int FlipStats[255];
extern int FlipMap[255]; constexpr auto MAX_FLIPMAP = 255;
extern int FlipStats[MAX_FLIPMAP];
extern int FlipMap[MAX_FLIPMAP];
extern bool InItemControlLoop; extern bool InItemControlLoop;
extern short ItemNewRoomNo; extern short ItemNewRoomNo;
extern short ItemNewRooms[512]; extern short ItemNewRooms[512];
@ -42,7 +97,7 @@ extern int InitialiseGame;
extern int RequiredStartPos; extern int RequiredStartPos;
extern int WeaponDelay; extern int WeaponDelay;
extern int WeaponEnemyTimer; extern int WeaponEnemyTimer;
extern int HeightType; extern HEIGHT_TYPES HeightType;
extern int HeavyTriggered; extern int HeavyTriggered;
extern short SkyPos1; extern short SkyPos1;
extern short SkyPos2; extern short SkyPos2;
@ -54,9 +109,9 @@ extern int CutSeqNum;
extern int CutSeqTriggered; extern int CutSeqTriggered;
extern int GlobalPlayingCutscene; extern int GlobalPlayingCutscene;
extern int CurrentLevel; extern int CurrentLevel;
extern int SoundActive; extern bool SoundActive;
extern int DoTheGame; extern bool DoTheGame;
extern int Unk_876C48; extern bool ThreadEnded;
extern int OnFloor; extern int OnFloor;
extern int SmokeWindX; extern int SmokeWindX;
extern int SmokeWindZ; extern int SmokeWindZ;
@ -122,4 +177,4 @@ int is_object_in_room(short roomNumber, short objectNumber);
void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift); void InterpolateAngle(short angle, short* rotation, short* outAngle, int shift);
int IsRoomOutside(int x, int y, int z); int IsRoomOutside(int x, int y, int z);
unsigned __stdcall GameMain(void*); unsigned CALLBACK GameMain(void*);

View file

@ -1,13 +1,16 @@
#include "framework.h"
#include "debris.h" #include "debris.h"
#include "../Specific/level.h" #include "level.h"
#include "../Specific/setup.h" #include "setup.h"
#include "control.h" #include "control.h"
#include "trmath.h"
ShatterImpactInfo ShatterImpactData; ShatterImpactInfo ShatterImpactData;
SHATTER_ITEM ShatterItem; SHATTER_ITEM ShatterItem;
short SmashedMeshCount; short SmashedMeshCount;
MESH_INFO* SmashedMesh[32]; MESH_INFO* SmashedMesh[32];
short SmashedMeshRoom[32]; short SmashedMeshRoom[32];
vector<DebrisFragment> DebrisFragments = vector<DebrisFragment>(MAX_DEBRIS);
DebrisFragment* GetFreeDebrisFragment() DebrisFragment* GetFreeDebrisFragment()
{ {
@ -80,9 +83,8 @@ void ShatterObject(SHATTER_ITEM* item, MESH_INFO* mesh, int num,short roomNumber
} }
} }
vector<DebrisFragment> DebrisFragments = vector<DebrisFragment>(MAX_DEBRIS);
DirectX::SimpleMath::Vector3 CalculateFragmentImpactVelocity(Vector3 fragmentWorldPosition, Vector3 impactDirection, Vector3 impactLocation) Vector3 CalculateFragmentImpactVelocity(Vector3 fragmentWorldPosition, Vector3 impactDirection, Vector3 impactLocation)
{ {
Vector3 radiusVector = (fragmentWorldPosition - impactLocation); Vector3 radiusVector = (fragmentWorldPosition - impactLocation);
Vector3 radiusNormVec = radiusVector; Vector3 radiusNormVec = radiusVector;
@ -98,26 +100,36 @@ DirectX::SimpleMath::Vector3 CalculateFragmentImpactVelocity(Vector3 fragmentWor
void UpdateDebris() void UpdateDebris()
{ {
for (auto deb = DebrisFragments.begin(); deb != DebrisFragments.end(); deb++) { for (auto deb = DebrisFragments.begin(); deb != DebrisFragments.end(); deb++)
if (deb->active) { {
if (deb->active)
{
FLOOR_INFO* floor;
short roomNumber;
deb->velocity *= deb->linearDrag; deb->velocity *= deb->linearDrag;
deb->velocity += deb->gravity; deb->velocity += deb->gravity;
deb->velocity = XMVector3ClampLength(deb->velocity, 0, deb->terminalVelocity); deb->velocity = XMVector3ClampLength(deb->velocity, 0, deb->terminalVelocity);
deb->rotation *= Quaternion::CreateFromYawPitchRoll(deb->angularVelocity.x,deb->angularVelocity.y,deb->angularVelocity.z); deb->rotation *= Quaternion::CreateFromYawPitchRoll(deb->angularVelocity.x,deb->angularVelocity.y,deb->angularVelocity.z);
deb->worldPosition += deb->velocity; deb->worldPosition += deb->velocity;
deb->angularVelocity *= deb->angularDrag; deb->angularVelocity *= deb->angularDrag;
short room = deb->roomNumber;
const FLOOR_INFO* const floor = GetFloor(deb->worldPosition.x, deb->worldPosition.y, deb->worldPosition.z,&room); roomNumber = deb->roomNumber;
if (deb->worldPosition.y < floor->ceiling) { floor = GetFloor(deb->worldPosition.x, deb->worldPosition.y, deb->worldPosition.z,&roomNumber);
if (floor->skyRoom != NO_ROOM) {
if (deb->worldPosition.y < floor->ceiling)
{
if (floor->skyRoom != NO_ROOM)
deb->roomNumber = floor->skyRoom; deb->roomNumber = floor->skyRoom;
}
} }
if (deb->worldPosition.y > floor->floor) {
if (floor->pitRoom != NO_ROOM) { if (deb->worldPosition.y > floor->floor)
{
if (floor->pitRoom != NO_ROOM)
deb->roomNumber = floor->pitRoom; deb->roomNumber = floor->pitRoom;
}
if (deb->numBounces > 3) { if (deb->numBounces > 3)
{
deb->active = false; deb->active = false;
continue; continue;
} }

View file

@ -1,18 +1,50 @@
#pragma once #pragma once
#include "sphere.h"
#include "Renderer11.h"
#include "..\Global\global.h" #define MAX_DEBRIS 256
struct ShatterImpactInfo { typedef struct ILIGHT
{
short x;
short y;
short z;
short pad1;
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char pad;
};
typedef struct ITEM_LIGHT
{
ILIGHT light[4];
};
typedef struct SHATTER_ITEM
{
SPHERE sphere;
ITEM_LIGHT* il;
short* meshp;
int bit;
short yRot;
short flags;
};
typedef struct ShatterImpactInfo
{
Vector3 impactDirection; Vector3 impactDirection;
Vector3 impactLocation; Vector3 impactLocation;
}; };
struct DebrisMesh { typedef struct DebrisMesh
{
RENDERER_BUCKETS bucket; RENDERER_BUCKETS bucket;
array<RendererVertex, 3> vertices; array<RendererVertex, 3> vertices;
}; };
struct DebrisFragment { typedef struct DebrisFragment
{
DebrisMesh mesh; DebrisMesh mesh;
Quaternion rotation; Quaternion rotation;
Vector3 angularVelocity; Vector3 angularVelocity;
@ -29,6 +61,29 @@ struct DebrisFragment {
bool active; bool active;
}; };
typedef struct DEBRIS_STRUCT
{
void* textInfo;
int x;
int y;
int z;
short xyzOffsets1[3];
short dir;
short xyzOffsets2[3];
short speed;
short xyzOffsets3[3];
short yVel;
short gravity;
short roomNumber;
byte on;
byte xRot;
byte yRot;
byte r;
byte g;
byte b;
byte pad[22];
};
extern SHATTER_ITEM ShatterItem; extern SHATTER_ITEM ShatterItem;
extern vector<DebrisFragment> DebrisFragments; extern vector<DebrisFragment> DebrisFragments;
extern ShatterImpactInfo ShatterImpactData; extern ShatterImpactInfo ShatterImpactData;

View file

@ -1,24 +0,0 @@
#include "deltapak.h"
#include "..\Global\global.h"
#include <stdio.h>
#include "../Specific/level.h"
ITEM_INFO* FindItem(short objectNumber)
{
#ifdef _DEBUG
printf("Called FindItem()\n");
#endif
//DB_Log(0, "FindItem - DLL");
if (LevelItems > 0)
{
for (int i = 0; i < LevelItems; i++)
{
if (Items[i].objectNumber == objectNumber)
return &Items[i];
}
}
return NULL;
}

View file

@ -1,3 +0,0 @@
#pragma once
#include "..\Global\global.h"

View file

@ -1,25 +1,26 @@
#include "framework.h"
#include "door.h" #include "door.h"
#include "items.h" #include "items.h"
#include "lot.h" #include "lot.h"
#include "objects.h" #include "objects.h"
#include "collide.h"
#include "Lara.h" #include "Lara.h"
#include "inventory.h" #include "inventory.h"
#include "draw.h" #include "draw.h"
#include "sphere.h" #include "sphere.h"
#include "switch.h" #include "switch.h"
#include "misc.h" #include "misc.h"
#include "Box.h" #include "box.h"
#include "../Specific/level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
#include "trmath.h"
PHD_VECTOR DoubleDoorPos = { 0, 0, 220 }; PHD_VECTOR DoubleDoorPos(0, 0, 220);
PHD_VECTOR PullDoorPos = { -201, 0, 322 }; PHD_VECTOR PullDoorPos(-201, 0, 322);
PHD_VECTOR PushDoorPos = { 201, 0, -702 }; PHD_VECTOR PushDoorPos(201, 0, -702);
PHD_VECTOR KickDoorPos = { 0, 0, -917 }; PHD_VECTOR KickDoorPos(0, 0, -917);
PHD_VECTOR UnderwaterDoorPos = { -251, -540, -46 }; PHD_VECTOR UnderwaterDoorPos(-251, -540, -46);
PHD_VECTOR CrowbarDoorPos = { -412, 0, 256 }; PHD_VECTOR CrowbarDoorPos(-412, 0, 256);
static short PushPullKickDoorBounds[12] = static short PushPullKickDoorBounds[12] =
{ {
@ -109,7 +110,7 @@ void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
&& !Lara.gunStatus && !Lara.gunStatus
|| Lara.isMoving && Lara.generalPtr == (void*)itemNum) || Lara.isMoving && Lara.generalPtr == (void*)itemNum)
{ {
l->pos.yRot ^= ANGLE(180); l->pos.yRot ^= ANGLE(180.0f);
if (TestLaraPosition(UnderwaterDoorBounds, item, l)) if (TestLaraPosition(UnderwaterDoorBounds, item, l))
{ {
@ -330,7 +331,7 @@ void DoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
ITEM_INFO* item = &Items[itemNum]; ITEM_INFO* item = &Items[itemNum];
if (item->triggerFlags == 2 if (item->triggerFlags == 2
&& item->status == ITEM_INACTIVE && !item->gravityStatus // CHECK && item->status == ITEM_NOT_ACTIVE && !item->gravityStatus // CHECK
&& ((TrInput & IN_ACTION || g_Inventory->GetSelectedObject() == ID_CROWBAR_ITEM) && ((TrInput & IN_ACTION || g_Inventory->GetSelectedObject() == ID_CROWBAR_ITEM)
&& l->currentAnimState == STATE_LARA_STOP && l->currentAnimState == STATE_LARA_STOP
&& l->animNumber == ANIMATION_LARA_STAY_IDLE && l->animNumber == ANIMATION_LARA_STAY_IDLE

View file

@ -1,6 +1,32 @@
#pragma once #pragma once
#include "items.h"
#include "collide.h"
#include "room.h"
#include "..\Global\global.h" typedef struct DOORPOS_DATA
{
FLOOR_INFO* floor;
FLOOR_INFO data;
short block;
};
typedef struct DOOR_DATA
{
DOORPOS_DATA d1;
DOORPOS_DATA d1flip;
DOORPOS_DATA d2;
DOORPOS_DATA d2flip;
short opened;
short* dptr1;
short* dptr2;
short* dptr3;
short* dptr4;
byte dn1;
byte dn2;
byte dn3;
byte dn4;
ITEM_INFO* item;
};
void SequenceDoorControl(short itemNumber); void SequenceDoorControl(short itemNumber);
void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); void UnderwaterDoorCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);

View file

@ -1,8 +1,9 @@
#include "framework.h"
#include "draw.h" #include "draw.h"
#include "Lara.h" #include "Lara.h"
#include "..\Renderer\Renderer11.h"
#include "camera.h" #include "camera.h"
#include "../Specific/level.h" #include "level.h"
#include "Renderer11.h"
BITE_INFO EnemyBites[9] = BITE_INFO EnemyBites[9] =
{ {
@ -17,8 +18,6 @@ BITE_INFO EnemyBites[9] =
{ 0xA, 0xFFFFFFC4, 0xC8, 0xD } { 0xA, 0xFFFFFFC4, 0xC8, 0xD }
}; };
Renderer11* g_Renderer;
int LightningCount; int LightningCount;
int LightningRand; int LightningRand;
int StormTimer; int StormTimer;
@ -129,27 +128,20 @@ int GetFrame_D2(ITEM_INFO* item, short* framePtr[], int* rate)
bool TIME_Reset() bool TIME_Reset()
{ {
LARGE_INTEGER fq; LARGE_INTEGER fq;
QueryPerformanceCounter(&fq); QueryPerformanceCounter(&fq);
LdSync = (double)fq.LowPart + (double)fq.HighPart * (double)0xffffffff; LdSync = (double)fq.LowPart + (double)fq.HighPart * (double)0xffffffff;
LdSync /= LdFreq; LdSync /= LdFreq;
return true; return true;
} }
bool TIME_Init() bool TIME_Init()
{ {
LARGE_INTEGER fq; LARGE_INTEGER fq;
if (!QueryPerformanceFrequency(&fq)) if (!QueryPerformanceFrequency(&fq))
return false; return false;
LdFreq = (double)fq.LowPart + (double)fq.HighPart * (double)0xFFFFFFFF; LdFreq = (double)fq.LowPart + (double)fq.HighPart * (double)0xFFFFFFFF;
LdFreq /= 60.0; LdFreq /= 60.0;
TIME_Reset(); TIME_Reset();
return true; return true;
} }
@ -157,16 +149,11 @@ int Sync()
{ {
LARGE_INTEGER ct; LARGE_INTEGER ct;
double dCounter; double dCounter;
QueryPerformanceCounter(&ct); QueryPerformanceCounter(&ct);
dCounter = (double)ct.LowPart + (double)ct.HighPart * (double)0xFFFFFFFF; dCounter = (double)ct.LowPart + (double)ct.HighPart * (double)0xFFFFFFFF;
dCounter /= LdFreq; dCounter /= LdFreq;
long nFrames = long(dCounter) - long(LdSync); long nFrames = long(dCounter) - long(LdSync);
LdSync = dCounter; LdSync = dCounter;
return nFrames; return nFrames;
} }
@ -176,13 +163,13 @@ void DrawAnimatingItem(ITEM_INFO* item)
// Empty stub because actually we disable items drawing when drawRoutine pointer is NULL in ObjectInfo // Empty stub because actually we disable items drawing when drawRoutine pointer is NULL in ObjectInfo
} }
void GetLaraJointPosition(PHD_VECTOR* pos, int joint) void GetLaraJointPosition(PHD_VECTOR* pos, int LM_enum)
{ {
if (joint > 14) if (LM_enum >= NUM_LARA_MESHES)
joint = 14; LM_enum = LM_HEAD;
Vector3 p = Vector3(pos->x, pos->y, pos->z); Vector3 p = Vector3(pos->x, pos->y, pos->z);
g_Renderer->GetLaraAbsBonePosition(&p, joint); g_Renderer->GetLaraAbsBonePosition(&p, LM_enum);
pos->x = p.x; pos->x = p.x;
pos->y = p.y; pos->y = p.y;

View file

@ -1,8 +1,20 @@
#pragma once #pragma once
#include "box.h"
#include "..\Global\global.h" struct ANIM_FRAME
{
short MinX;
short MaxX;
short MinY;
short MaxY;
short MinZ;
short MaxZ;
short OffsetX;
short OffsetY;
short OffsetZ;
unsigned short AngleSets[]; // Variable size
};
extern Renderer11* g_Renderer;
extern BITE_INFO EnemyBites[9]; extern BITE_INFO EnemyBites[9];
extern int LightningCount; extern int LightningCount;
extern int LightningRand; extern int LightningRand;
@ -21,4 +33,4 @@ int Sync();
bool TIME_Init(); bool TIME_Init();
bool TIME_Reset(); bool TIME_Reset();
void DrawAnimatingItem(ITEM_INFO* item); void DrawAnimatingItem(ITEM_INFO* item);
void GetLaraJointPosition(PHD_VECTOR* pos, int joint); void GetLaraJointPosition(PHD_VECTOR* pos, int LM_enum);

View file

@ -1,5 +1,6 @@
#include "effects.h" #include "framework.h"
#include "..\Global\global.h" #include "effect.h"
#include "Lara.h" #include "Lara.h"
#include "items.h" #include "items.h"
#include "lot.h" #include "lot.h"
@ -9,13 +10,16 @@
#include "draw.h" #include "draw.h"
#include "sphere.h" #include "sphere.h"
#include "footprint.h" #include "footprint.h"
#include "..\Objects\oldobjects.h" #include "oldobjects.h"
#include "..\Specific\level.h" #include "level.h"
#include "debris.h" #include "debris.h"
#include "../Specific/setup.h" #include "setup.h"
#include "camera.h" #include "camera.h"
#include "savegame.h" #include "savegame.h"
#include "sound.h" #include "sound.h"
#include "tr5_rats_emitter.h"
#include "tr5_bats_emitter.h"
#include "tr5_spider_emitter.h"
int wf = 256; int wf = 256;
extern std::deque<FOOTPRINT_STRUCT> footprints; extern std::deque<FOOTPRINT_STRUCT> footprints;
@ -57,8 +61,8 @@ void(*effect_routines[59])(ITEM_INFO* item) =
void_effect, void_effect,
LaraLocation, LaraLocation,
ClearSpidersPatch, ClearSpidersPatch,
AddFootprint, /*AddFootprint*/ AddFootprint,
void_effect /*ResetTest*/, void_effect, // resettest
void_effect, void_effect,
void_effect, void_effect,
void_effect, void_effect,
@ -96,16 +100,21 @@ void TL_1(ITEM_INFO* item)
} }
} }
void AddFootprint(ITEM_INFO* item) { // TODO: here are sound for lara footstep too !
if (item != LaraItem) { void AddFootprint(ITEM_INFO* item)
{
if (item != LaraItem)
return; return;
}
FOOTPRINT_STRUCT footprint;
PHD_3DPOS footprintPosition; PHD_3DPOS footprintPosition;
if (CheckFootOnFloor(*item, LM_LFOOT, footprintPosition)) {
if (footprints.size() >= MAX_FOOTPRINTS) { if (CheckFootOnFloor(*item, LM_LFOOT, footprintPosition))
{
if (footprints.size() >= MAX_FOOTPRINTS)
footprints.pop_back(); footprints.pop_back();
}
FOOTPRINT_STRUCT footprint; memset(&footprint, 0, sizeof(FOOTPRINT_STRUCT));
footprint.pos = footprintPosition; footprint.pos = footprintPosition;
footprint.lifeStartFading = 30 * 10; footprint.lifeStartFading = 30 * 10;
footprint.startOpacity = 64; footprint.startOpacity = 64;
@ -113,11 +122,13 @@ void AddFootprint(ITEM_INFO* item) {
footprint.active = true; footprint.active = true;
footprints.push_front(footprint); footprints.push_front(footprint);
} }
if (CheckFootOnFloor(*item, LM_RFOOT, footprintPosition)) {
if (footprints.size() >= MAX_FOOTPRINTS) { if (CheckFootOnFloor(*item, LM_RFOOT, footprintPosition))
{
if (footprints.size() >= MAX_FOOTPRINTS)
footprints.pop_back(); footprints.pop_back();
}
FOOTPRINT_STRUCT footprint; memset(&footprint, 0, sizeof(FOOTPRINT_STRUCT));
footprint.pos = footprintPosition; footprint.pos = footprintPosition;
footprint.lifeStartFading = 30*10; footprint.lifeStartFading = 30*10;
footprint.startOpacity = 64; footprint.startOpacity = 64;
@ -125,7 +136,6 @@ void AddFootprint(ITEM_INFO* item) {
footprint.active = true; footprint.active = true;
footprints.push_front(footprint); footprints.push_front(footprint);
} }
} }
void TL_2(ITEM_INFO* item) void TL_2(ITEM_INFO* item)
@ -392,7 +402,7 @@ void PoseidonSFX(ITEM_INFO* item)//395E0(<), 39AE0(<) (F)
void RubbleFX(ITEM_INFO* item)//39534(<), 39A34(<) (F) void RubbleFX(ITEM_INFO* item)//39534(<), 39A34(<) (F)
{ {
int itemNumber = FindItem(ID_EARTHQUAKE); int itemNumber = FindItemNumber(ID_EARTHQUAKE);
if (itemNumber != NO_ITEM) if (itemNumber != NO_ITEM)
{ {

View file

@ -1,49 +1,62 @@
#pragma once #pragma once
#include "control.h"
#include "..\Global\global.h"
#include "control.h" struct FX_INFO
{
extern FX_INFO* Effects; PHD_3DPOS pos;
short roomNumber;
int ItemNearLara(PHD_3DPOS* pos, int radius); short objectNumber;
void StopSoundEffect(short sampleIndex); short nextFx;
short DoBloodSplat(int x, int y, int z, short a4, short a5, short roomNumber); short nextActive;
//void SoundEffects(); short speed;
void AddFootprint(ITEM_INFO* item); short fallspeed;
void ControlWaterfallMist(short itemNumber); short frameNumber;
void void_effect(ITEM_INFO* item); short counter;
void finish_level_effect(ITEM_INFO* item); short shade;
void turn180_effect(ITEM_INFO* item); short flag1;
void floor_shake_effect(ITEM_INFO* item); short flag2;
void SoundFlipEffect(ITEM_INFO* item); };
void RubbleFX(ITEM_INFO* item); extern FX_INFO* Effects;
void PoseidonSFX(ITEM_INFO* item);
void ActivateCamera(ITEM_INFO* item); int ItemNearLara(PHD_3DPOS* pos, int radius);
void ActivateKey(ITEM_INFO* item); void StopSoundEffect(short sampleIndex);
void SwapCrowbar(ITEM_INFO* item); short DoBloodSplat(int x, int y, int z, short speed, short yRot, short roomNumber);
void ExplosionFX(ITEM_INFO* item); //void SoundEffects();
void LaraLocation(ITEM_INFO* item); void AddFootprint(ITEM_INFO* item);
void LaraLocationPad(ITEM_INFO* item); void ControlWaterfallMist(short itemNumber);
void ResetTest(ITEM_INFO* item); void void_effect(ITEM_INFO* item);
void KillActiveBaddies(ITEM_INFO* item); void finish_level_effect(ITEM_INFO* item);
void lara_hands_free(ITEM_INFO* item); void turn180_effect(ITEM_INFO* item);
void shoot_right_gun(ITEM_INFO* item); void floor_shake_effect(ITEM_INFO* item);
void shoot_left_gun(ITEM_INFO* item); void SoundFlipEffect(ITEM_INFO* item);
void SetFog(ITEM_INFO* item); void RubbleFX(ITEM_INFO* item);
void invisibility_on(ITEM_INFO* item); void PoseidonSFX(ITEM_INFO* item);
void invisibility_off(ITEM_INFO* item); void ActivateCamera(ITEM_INFO* item);
void reset_hair(ITEM_INFO* item); void ActivateKey(ITEM_INFO* item);
void TL_1(ITEM_INFO* item); void SwapCrowbar(ITEM_INFO* item);
void TL_2(ITEM_INFO* item); void ExplosionFX(ITEM_INFO* item);
void TL_3(ITEM_INFO* item); void LaraLocation(ITEM_INFO* item);
void TL_4(ITEM_INFO* item); void LaraLocationPad(ITEM_INFO* item);
void TL_5(ITEM_INFO* item); void ResetTest(ITEM_INFO* item);
void TL_6(ITEM_INFO* item); void KillActiveBaddies(ITEM_INFO* item);
void TL_7(ITEM_INFO* item); void lara_hands_free(ITEM_INFO* item);
void TL_8(ITEM_INFO* item); void shoot_right_gun(ITEM_INFO* item);
void TL_9(ITEM_INFO* item); void shoot_left_gun(ITEM_INFO* item);
void TL_10(ITEM_INFO* item); void SetFog(ITEM_INFO* item);
void TL_11(ITEM_INFO* item); void invisibility_on(ITEM_INFO* item);
void TL_12(ITEM_INFO* item); void invisibility_off(ITEM_INFO* item);
void Richochet(PHD_3DPOS* pos); void reset_hair(ITEM_INFO* item);
void DoLotsOfBlood(int x, int y, int z, int speed, short direction, short roomNumber, int count); void TL_1(ITEM_INFO* item);
void TL_2(ITEM_INFO* item);
void TL_3(ITEM_INFO* item);
void TL_4(ITEM_INFO* item);
void TL_5(ITEM_INFO* item);
void TL_6(ITEM_INFO* item);
void TL_7(ITEM_INFO* item);
void TL_8(ITEM_INFO* item);
void TL_9(ITEM_INFO* item);
void TL_10(ITEM_INFO* item);
void TL_11(ITEM_INFO* item);
void TL_12(ITEM_INFO* item);
void Richochet(PHD_3DPOS* pos);
void DoLotsOfBlood(int x, int y, int z, int speed, short direction, short roomNumber, int count);

View file

@ -1,38 +1,35 @@
#include "framework.h"
#include "effect2.h" #include "effect2.h"
#include "draw.h" #include "draw.h"
#include "effect.h"
#include "lara.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "traps.h" #include "traps.h"
#include "math.h" #include "trmath.h"
#include "lara.h"
#include "effects.h"
#include "sound.h" #include "sound.h"
#include "..\Scripting\GameFlowScript.h" #include "setup.h"
#include "../Specific/setup.h" #include "level.h"
#include "../Specific/level.h" #include "objectslist.h"
#include "GameFlowScript.h"
//long wibble;
//long SplashCount;
//long KillEverythingFlag;
int NextSpark;
unsigned char TES_extra_tab[] = unsigned char TES_extra_tab[] =
{ {
0x00, 0x04, 0x07, 0x0A, 0x00, 0x00 0x00, 0x04, 0x07, 0x0A, 0x00, 0x00
}; };
extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE];
int NextSpark;
int DeadlyBounds[6]; int DeadlyBounds[6];
SPLASH_STRUCT Splashes[MAX_SPLASH]; SPLASH_SETUP SplashSetup;
SPLASH_STRUCT Splashes[MAX_SPLASHES];
RIPPLE_STRUCT Ripples[MAX_RIPPLES]; RIPPLE_STRUCT Ripples[MAX_RIPPLES];
DYNAMIC Dynamics[MAX_DYNAMICS]; DYNAMIC Dynamics[MAX_DYNAMICS];
SPLASH_SETUP SplashSetup;
SP_DYNAMIC SparkDynamics[8];
int SmokeWeapon;
int SmokeCountL;
int SmokeCountR;
//int SmokeWindX;
//int SmokeWindZ;
int SplashCount = 0;
SPARKS Sparks[MAX_SPARKS]; SPARKS Sparks[MAX_SPARKS];
SP_DYNAMIC SparkDynamics[MAX_SPARKS_DYNAMICS];
int SmokeWeapon;
byte SmokeCountL;
byte SmokeCountR;
int SplashCount = 0;
PHD_VECTOR NodeVectors[MAX_NODE]; PHD_VECTOR NodeVectors[MAX_NODE];
NODEOFFSET_INFO NodeOffsets[MAX_NODE] = { NODEOFFSET_INFO NodeOffsets[MAX_NODE] = {
{ -16, 40, 160, -14, false }, // TR5 offset 0 { -16, 40, 160, -14, false }, // TR5 offset 0
@ -62,46 +59,48 @@ NODEOFFSET_INFO NodeOffsets[MAX_NODE] = {
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;
void DetatchSpark(int num, int type)// (F) (D) void DetatchSpark(int num, SpriteEnumFlag type)// (F) (D)
{ {
FX_INFO* fx; FX_INFO* fx;
ITEM_INFO* item; ITEM_INFO* item;
SPARKS* sptr; SPARKS* sptr;
int lp;
sptr = &Sparks[0]; sptr = &Sparks[0];
for (int lp = 0; lp < MAX_SPARKS; lp++, sptr++) for (lp = 0; lp < MAX_SPARKS; lp++, sptr++)
{ {
if (sptr->on && (sptr->flags & type) && sptr->fxObj == num) if (sptr->on && (sptr->flags & type) && sptr->fxObj == num)
{ {
if (type == SP_FX) switch (type)
{ {
if (sptr->flags & SP_USEFXOBJPOS) case SP_FX:
{ if (sptr->flags & SP_USEFXOBJPOS)
sptr->on = FALSE; {
} sptr->on = FALSE;
else }
{ else
fx = &Effects[num]; {
sptr->x += fx->pos.xPos; fx = &Effects[num];
sptr->y += fx->pos.yPos; sptr->x += fx->pos.xPos;
sptr->z += fx->pos.zPos; sptr->y += fx->pos.yPos;
sptr->flags &= ~SP_FX; sptr->z += fx->pos.zPos;
} sptr->flags &= ~SP_FX;
} }
else if (type == SP_ITEM) break;
{ case SP_ITEM:
if (sptr->flags & SP_USEFXOBJPOS) if (sptr->flags & SP_USEFXOBJPOS)
{ {
sptr->on = FALSE; sptr->on = FALSE;
} }
else else
{ {
item = &Items[num]; item = &Items[num];
sptr->x += item->pos.xPos; sptr->x += item->pos.xPos;
sptr->y += item->pos.yPos; sptr->y += item->pos.yPos;
sptr->z += item->pos.zPos; sptr->z += item->pos.zPos;
sptr->flags &= ~SP_ITEM; sptr->flags &= ~SP_ITEM;
} }
break;
} }
} }
} }
@ -404,7 +403,7 @@ void TriggerRicochetSpark(GAME_VECTOR* pos, short angle, int num, int unk)
spark->fadeToBlack = 4; spark->fadeToBlack = 4;
spark->life = 9; spark->life = 9;
spark->sLife = 9; spark->sLife = 9;
spark->transType = 2; spark->transType = COLADD;
spark->x = pos->x; spark->x = pos->x;
spark->y = pos->y; spark->y = pos->y;
spark->z = pos->z; spark->z = pos->z;
@ -414,7 +413,7 @@ void TriggerRicochetSpark(GAME_VECTOR* pos, short angle, int num, int unk)
spark->zVel = rcossin_tbl[2 * ang + 1] >> 2; spark->zVel = rcossin_tbl[2 * ang + 1] >> 2;
spark->gravity = (random >> 7) & 0x1F; spark->gravity = (random >> 7) & 0x1F;
spark->friction = 34; spark->friction = 34;
spark->flags = 0; spark->flags = SP_NONE;
spark->maxYvel = 0; spark->maxYvel = 0;
} }
@ -432,7 +431,7 @@ void TriggerRicochetSpark(GAME_VECTOR* pos, short angle, int num, int unk)
spark->fadeToBlack = 0; spark->fadeToBlack = 0;
spark->life = 4; spark->life = 4;
spark->sLife = 4; spark->sLife = 4;
spark->transType = 2; spark->transType = COLADD;
spark->x = pos->x; spark->x = pos->x;
spark->y = pos->y; spark->y = pos->y;
spark->z = pos->z; spark->z = pos->z;
@ -490,7 +489,7 @@ void TriggerRicochetSpark(GAME_VECTOR* pos, short angle, int num, int unk)
spark->xVel = 0; spark->xVel = 0;
spark->zVel = 0; spark->zVel = 0;
} }
spark->transType = 2; spark->transType = COLADD;
spark->friction = 0; spark->friction = 0;
spark->flags = 26; spark->flags = 26;
spark->rotAng = random >> 3; spark->rotAng = random >> 3;
@ -528,13 +527,13 @@ void TriggerCyborgSpark(int x, int y, int z, short xv, short yv, short zv)
spark->dB = -64 - ((random & 0x7F) + 64); spark->dB = -64 - ((random & 0x7F) + 64);
spark->life = 10; spark->life = 10;
spark->sLife = 10; spark->sLife = 10;
spark->transType = 2; spark->transType = COLADD;
spark->friction = 34; spark->friction = 34;
spark->scalar = 1; spark->scalar = 1;
spark->x = (random & 7) + x - 3; spark->x = (random & 7) + x - 3;
spark->y = ((random >> 3) & 7) + y - 3; spark->y = ((random >> 3) & 7) + y - 3;
spark->z = ((random >> 6) & 7) + z - 3; spark->z = ((random >> 6) & 7) + z - 3;
spark->flags = 2; spark->flags = SP_SCALE;
spark->xVel = (random >> 2) + xv - 128; spark->xVel = (random >> 2) + xv - 128;
spark->yVel = (random >> 4) + yv - 128; spark->yVel = (random >> 4) + yv - 128;
spark->zVel = (random >> 6) + zv - 128; spark->zVel = (random >> 6) + zv - 128;
@ -571,7 +570,7 @@ void TriggerExplosionSparks(int x, int y, int z, int extraTrig, int dynamic, int
spark->colFadeSpeed = 7; spark->colFadeSpeed = 7;
spark->dG = (GetRandomControl() & 0x1F) + 64; spark->dG = (GetRandomControl() & 0x1F) + 64;
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 7) + 16; spark->life = spark->sLife = (GetRandomControl() & 7) + 16;
spark->roomNumber = roomNumber; spark->roomNumber = roomNumber;
} }
@ -584,7 +583,7 @@ void TriggerExplosionSparks(int x, int y, int z, int extraTrig, int dynamic, int
spark->colFadeSpeed = 8; spark->colFadeSpeed = 8;
spark->dG = (GetRandomControl() & 0x3F) + -128; spark->dG = (GetRandomControl() & 0x3F) + -128;
spark->fadeToBlack = 16; spark->fadeToBlack = 16;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 7) + 24; spark->life = spark->sLife = (GetRandomControl() & 7) + 24;
} }
spark->extras = extraTrig | 8 * (TES_extra_tab[extraTrig] + (GetRandomControl() & 7) + 28); spark->extras = extraTrig | 8 * (TES_extra_tab[extraTrig] + (GetRandomControl() & 7) + 28);
@ -998,7 +997,7 @@ void TriggerSuperJetFlame(ITEM_INFO* item, int yvel, int deadly)//32EAC, 333AC (
sptr->dB = 32; sptr->dB = 32;
sptr->colFadeSpeed = 8; sptr->colFadeSpeed = 8;
sptr->fadeToBlack = 8; sptr->fadeToBlack = 8;
sptr->transType = 2; sptr->transType = COLADD;
sptr->life = sptr->sLife = (size >> 9) + (GetRandomControl() & 7) + 16; sptr->life = sptr->sLife = (size >> 9) + (GetRandomControl() & 7) + 16;
sptr->x = (GetRandomControl() & 0x1F) + item->pos.xPos - 16; sptr->x = (GetRandomControl() & 0x1F) + item->pos.xPos - 16;
sptr->y = (GetRandomControl() & 0x1F) + item->pos.yPos - 16; sptr->y = (GetRandomControl() & 0x1F) + item->pos.yPos - 16;
@ -1052,7 +1051,7 @@ void SetupSplash(const SPLASH_SETUP* const setup)
constexpr size_t NUM_SPLASHES = 4; constexpr size_t NUM_SPLASHES = 4;
int numSplashesSetup = 0; int numSplashesSetup = 0;
float splashVelocity; float splashVelocity;
for (int i = 0; i < MAX_SPLASH; i++) for (int i = 0; i < MAX_SPLASHES; i++)
{ {
SPLASH_STRUCT& splash = Splashes[i]; SPLASH_STRUCT& splash = Splashes[i];
if (!splash.isActive) if (!splash.isActive)
@ -1128,7 +1127,7 @@ void SetupSplash(const SPLASH_SETUP* const setup)
void UpdateSplashes() void UpdateSplashes()
{ {
for (int i = 0; i < MAX_SPLASH; i++) for (int i = 0; i < MAX_SPLASHES; i++)
{ {
SPLASH_STRUCT& splash = Splashes[i]; SPLASH_STRUCT& splash = Splashes[i];
if (splash.isActive) { if (splash.isActive) {
@ -1268,7 +1267,7 @@ void TriggerWaterfallMist(int x, int y, int z, int angle)
spark->dG = 64; spark->dG = 64;
spark->dB = 64; spark->dB = 64;
spark->colFadeSpeed = 1; spark->colFadeSpeed = 1;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 6; spark->life = spark->sLife = (GetRandomControl() & 3) + 6;
spark->fadeToBlack = spark->life - 4; spark->fadeToBlack = spark->life - 4;
dl = ((dh + (GlobalCounter << 6)) % 1536) + (GetRandomControl() & 0x3F) - 32; dl = ((dh + (GlobalCounter << 6)) % 1536) + (GetRandomControl() & 0x3F) - 32;
@ -1302,7 +1301,7 @@ void TriggerWaterfallMist(int x, int y, int z, int angle)
spark->dG = 96; spark->dG = 96;
spark->dB = 96; spark->dB = 96;
spark->colFadeSpeed = 1; spark->colFadeSpeed = 1;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 6; spark->life = spark->sLife = (GetRandomControl() & 3) + 6;
spark->fadeToBlack = spark->life - 1; spark->fadeToBlack = spark->life - 1;
dl = GetRandomControl() % 1408 + 64; dl = GetRandomControl() % 1408 + 64;
@ -1340,7 +1339,7 @@ void TriggerDartSmoke(int x, int y, int z, int xv, int zv, int hit)
spark->dB = 32; spark->dB = 32;
spark->colFadeSpeed = 8; spark->colFadeSpeed = 8;
spark->fadeToBlack = 4; spark->fadeToBlack = 4;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 32; spark->life = spark->sLife = (GetRandomControl() & 3) + 32;
spark->x = (GetRandomControl() & 0x1F) + x - 16; spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16; spark->y = (GetRandomControl() & 0x1F) + y - 16;
@ -1502,7 +1501,7 @@ void TriggerRocketFlame(int x, int y, int z, int xv, int yv, int zv, int itemNum
sptr->colFadeSpeed = 12 + (GetRandomControl() & 3); sptr->colFadeSpeed = 12 + (GetRandomControl() & 3);
sptr->fadeToBlack = 12; sptr->fadeToBlack = 12;
sptr->sLife = sptr->life = (GetRandomControl() & 3) + 28; sptr->sLife = sptr->life = (GetRandomControl() & 3) + 28;
sptr->transType = 2; sptr->transType = COLADD;
sptr->extras = 0; sptr->extras = 0;
sptr->dynamic = -1; sptr->dynamic = -1;
@ -1558,7 +1557,7 @@ void TriggerRocketSmoke(int x, int y, int z, int bodyPart)
sptr->colFadeSpeed = 4 + (GetRandomControl() & 3); sptr->colFadeSpeed = 4 + (GetRandomControl() & 3);
sptr->fadeToBlack = 12; sptr->fadeToBlack = 12;
sptr->sLife = sptr->life = (GetRandomControl() & 3) + 20; sptr->sLife = sptr->life = (GetRandomControl() & 3) + 20;
sptr->transType = 2; sptr->transType = COLADD;
sptr->extras = 0; sptr->extras = 0;
sptr->dynamic = -1; sptr->dynamic = -1;
@ -1611,7 +1610,7 @@ void GrenadeExplosionEffects(int x, int y, int z, short roomNumber)
spark->dShade = -128; spark->dShade = -128;
spark->colFadeSpeed = 4; spark->colFadeSpeed = 4;
spark->fadeToBlack = 16; spark->fadeToBlack = 16;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 0xF) + 64; spark->life = spark->sLife = (GetRandomControl() & 0xF) + 64;
spark->x = (GetRandomControl() & 0x1F) + x - 16; spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16; spark->y = (GetRandomControl() & 0x1F) + y - 16;
@ -1717,7 +1716,7 @@ void GrenadeLauncherSpecialEffect1(int x, int y, int z, int flag1, int flag2)
spark->life = spark->sLife = (GetRandomControl() & 3) + 28; spark->life = spark->sLife = (GetRandomControl() & 3) + 28;
} }
spark->transType = 2; spark->transType = COLADD;
if (flag1 != -1) if (flag1 != -1)
{ {
@ -1908,7 +1907,7 @@ void TriggerMetalSparks(int x, int y, int z, int xv, int yv, int zv, int additio
spark->colFadeSpeed = 3; spark->colFadeSpeed = 3;
spark->fadeToBlack = 5; spark->fadeToBlack = 5;
spark->y = ((r >> 3) & 7) + y - 3; spark->y = ((r >> 3) & 7) + y - 3;
spark->transType = 2; spark->transType = COLADD;
spark->friction = 34; spark->friction = 34;
spark->scalar = 1; spark->scalar = 1;
spark->z = ((r >> 6) & 7) + z - 3; spark->z = ((r >> 6) & 7) + z - 3;
@ -1930,7 +1929,7 @@ void TriggerMetalSparks(int x, int y, int z, int xv, int yv, int zv, int additio
spark->sR = spark->dR >> 1; spark->sR = spark->dR >> 1;
spark->sG = spark->dG >> 1; spark->sG = spark->dG >> 1;
spark->fadeToBlack = 4; spark->fadeToBlack = 4;
spark->transType = 2; spark->transType = COLADD;
spark->colFadeSpeed = (r & 3) + 8; spark->colFadeSpeed = (r & 3) + 8;
spark->sB = spark->dB >> 1; spark->sB = spark->dB >> 1;
spark->dR = 32; spark->dR = 32;

View file

@ -1,14 +1,63 @@
#pragma once #pragma once
#include <d3d11.h> #include "phd_global.h"
#include "..\Global\global.h" #include "items.h"
#define MAX_NODE 23 enum RIPPLE_TYPE
#define RIPPLE_FLAG_BLOOD 0x80 {
#define RIPPLE_FLAG_RAND_POS 0x40 RIPPLE_FLAG_NONE = 0x0,
#define RIPPLE_FLAG_RAND_ROT 0x20 RIPPLE_FLAG_SHORT_LIFE = 0x1,
#define RIPPLE_FLAG_SHORT_LIFE 0x01 RIPPLE_FLAG_RAND_ROT = 0x20,
RIPPLE_FLAG_RAND_POS = 0x40,
RIPPLE_FLAG_BLOOD = 0x80
};
struct RIPPLE_STRUCT enum SpriteEnumFlag
{
SP_NONE = 0x0000,
SP_FLAT = 0x0001,
SP_SCALE = 0x0002,
SP_BLOOD = 0x0004,
SP_DEF = 0x0008,
SP_ROTATE = 0x0010,
SP_EXPLOSION = 0x0020,
SP_FX = 0x0040,
SP_ITEM = 0x0080,
SP_WIND = 0x0100,
SP_EXPDEF = 0x0200,
SP_USEFXOBJPOS = 0x0400,
SP_UNDERWEXP = 0x0800,
SP_NODEATTACH = 0x1000,
SP_PLASMAEXP = 0x2000
};
enum TransTypeEnum
{
NOTRANS,
SEMITRANS,
COLADD,
COLSUB,
WEIRD
};
struct NODEOFFSET_INFO
{
short x;
short y;
short z;
char meshNum;
unsigned char gotIt;
};
typedef struct SPLASH_SETUP
{
float x;
float y;
float z;
float splashPower;
float innerRadius;
};
typedef struct RIPPLE_STRUCT
{ {
Vector4 currentColor; Vector4 currentColor;
Vector4 initialColor; Vector4 initialColor;
@ -24,27 +73,120 @@ struct RIPPLE_STRUCT
bool isBillboard; //used for Blood bool isBillboard; //used for Blood
}; };
struct SPLASH_SETUP typedef struct SPARKS
{
int x;
int y;
int z;
short xVel;
short yVel;
short zVel;
short gravity;
short rotAng;
unsigned short flags; // SP_enum
unsigned char sSize;
unsigned char dSize;
unsigned char size;
unsigned char friction;
unsigned char scalar;
unsigned char def;
signed char rotAdd;
signed char maxYvel;
bool on;
byte sR;
byte sG;
byte sB;
byte dR;
byte dG;
byte dB;
byte r;
byte g;
byte b;
unsigned char colFadeSpeed;
unsigned char fadeToBlack;
unsigned char sLife;
unsigned char life;
TransTypeEnum transType;
unsigned char extras;
signed char dynamic;
unsigned char fxObj;
unsigned char roomNumber;
unsigned char nodeNumber;
};
typedef struct SPLASH_STRUCT
{ {
float x; float x;
float y; float y;
float z; float z;
float splashPower; float innerRad;
float innerRadius; float innerRadVel;
float heightVel;
float heightSpeed;
float height;
float outerRad;
float outerRadVel;
float animationSpeed;
float animationPhase;
short spriteSequenceStart;
short spriteSequenceEnd;
unsigned short life;
bool isRipple;
bool isActive;
}; };
extern SPLASH_STRUCT Splashes[MAX_SPLASH];
extern RIPPLE_STRUCT Ripples[32]; typedef struct DYNAMIC
{
int x;
int y;
int z;
byte on;
byte r;
byte g;
byte b;
short falloff;
byte used;
byte pad1[1];
int FalloffScale;
};
typedef struct SP_DYNAMIC
{
byte On;
byte Falloff;
byte R;
byte G;
byte B;
byte Flags;
byte Pad[2];
};
constexpr auto SD_EXPLOSION = 1;
constexpr auto SD_UWEXPLOSION = 2;
#define MAX_NODE 23
#define MAX_DYNAMICS 64
#define MAX_SPARKS 1024
#define MAX_RIPPLES 32
#define MAX_SPLASHES 8
#define MAX_SPARKS_DYNAMICS 8
extern int NextSpark;
extern int DeadlyBounds[6]; extern int DeadlyBounds[6];
extern SPARKS Sparks[1024];
extern SP_DYNAMIC SparkDynamics[8];
extern SPLASH_SETUP SplashSetup; extern SPLASH_SETUP SplashSetup;
extern SPLASH_STRUCT Splashes[MAX_SPLASHES];
extern RIPPLE_STRUCT Ripples[MAX_RIPPLES];
extern DYNAMIC Dynamics[MAX_DYNAMICS];
extern SPARKS Sparks[MAX_SPARKS];
extern SP_DYNAMIC SparkDynamics[MAX_SPARKS_DYNAMICS];
extern int SmokeWeapon; extern int SmokeWeapon;
extern int SmokeCountL; extern byte SmokeCountL;
extern int SmokeCountR; extern byte SmokeCountR;
extern int SplashCount;
extern PHD_VECTOR NodeVectors[MAX_NODE]; extern PHD_VECTOR NodeVectors[MAX_NODE];
extern NODEOFFSET_INFO NodeOffsets[MAX_NODE]; extern NODEOFFSET_INFO NodeOffsets[MAX_NODE];
void DetatchSpark(int num, int type); void DetatchSpark(int num, SpriteEnumFlag type);
int GetFreeSpark(); int GetFreeSpark();
void UpdateSparks(); void UpdateSparks();
void TriggerRicochetSpark(GAME_VECTOR* pos, short angle, int num, int unk); void TriggerRicochetSpark(GAME_VECTOR* pos, short angle, int num, int unk);

View file

@ -1,25 +1,25 @@
#include "framework.h"
#include "flmtorch.h" #include "flmtorch.h"
#include "..\Global\global.h"
#include "effect2.h" #include "effect2.h"
#include "laraflar.h" #include "laraflar.h"
#include "lara.h" #include "lara.h"
#include "larafire.h" #include "larafire.h"
#include "collide.h"
#include "laramisc.h" #include "laramisc.h"
#include "switch.h" #include "switch.h"
#include "draw.h" #include "draw.h"
#include "items.h" #include "items.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/setup.h" #include "setup.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
#include "snowmobile.h"
short FireBounds[12] = short FireBounds[12] =
{ {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xF8E4, 0x071C 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xF8E4, 0x071C
}; };
void TriggerTorchFlame(char fxObj, char node) void TriggerTorchFlame(char fxObj, char node)
{ {
SPARKS* spark = &Sparks[GetFreeSpark()]; SPARKS* spark = &Sparks[GetFreeSpark()];
@ -32,7 +32,7 @@ void TriggerTorchFlame(char fxObj, char node)
spark->dG = (GetRandomControl() & 0x3F) + -128; spark->dG = (GetRandomControl() & 0x3F) + -128;
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 12; spark->colFadeSpeed = (GetRandomControl() & 3) + 12;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 7) + 24; spark->life = spark->sLife = (GetRandomControl() & 7) + 24;
spark->y = 0; spark->y = 0;
spark->x = (GetRandomControl() & 0xF) - 8; spark->x = (GetRandomControl() & 0xF) - 8;
@ -80,7 +80,7 @@ void DoFlameTorch() // (F) (D)
&& LaraItem->currentAnimState != STATE_LARA_JUMP_RIGHT && LaraItem->currentAnimState != STATE_LARA_JUMP_RIGHT
|| Lara.waterStatus == LW_UNDERWATER) || Lara.waterStatus == LW_UNDERWATER)
{ {
Lara.leftArm.lock = 1; Lara.leftArm.lock = true;
Lara.leftArm.frameNumber = 1; Lara.leftArm.frameNumber = 1;
Lara.leftArm.animNumber = Objects[ID_LARA_TORCH_ANIM].animIndex + 1; Lara.leftArm.animNumber = Objects[ID_LARA_TORCH_ANIM].animIndex + 1;
if (Lara.waterStatus == LW_UNDERWATER) if (Lara.waterStatus == LW_UNDERWATER)
@ -92,7 +92,7 @@ void DoFlameTorch() // (F) (D)
case 1: case 1:
if (Lara.leftArm.frameNumber < 12 && LaraItem->gravityStatus) if (Lara.leftArm.frameNumber < 12 && LaraItem->gravityStatus)
{ {
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.leftArm.frameNumber = 0; Lara.leftArm.frameNumber = 0;
Lara.leftArm.animNumber = Objects[ID_LARA_TORCH_ANIM].animIndex; Lara.leftArm.animNumber = Objects[ID_LARA_TORCH_ANIM].animIndex;
} }
@ -103,7 +103,7 @@ void DoFlameTorch() // (F) (D)
{ {
Lara.litTorch = false; Lara.litTorch = false;
Lara.flareControlLeft = false; Lara.flareControlLeft = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.gunType = Lara.lastGunType; Lara.gunType = Lara.lastGunType;
Lara.requestGunType = WEAPON_NONE; Lara.requestGunType = WEAPON_NONE;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
@ -123,7 +123,7 @@ void DoFlameTorch() // (F) (D)
{ {
Lara.litTorch = false; Lara.litTorch = false;
Lara.flareControlLeft = false; Lara.flareControlLeft = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.lastGunType = WEAPON_NONE; Lara.lastGunType = WEAPON_NONE;
Lara.gunType = WEAPON_NONE; Lara.gunType = WEAPON_NONE;
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
@ -137,7 +137,7 @@ void DoFlameTorch() // (F) (D)
case 3: case 3:
if (LaraItem->currentAnimState != STATE_LARA_MISC_CONTROL) if (LaraItem->currentAnimState != STATE_LARA_MISC_CONTROL)
{ {
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.leftArm.frameNumber = 0; Lara.leftArm.frameNumber = 0;
Lara.flareControlLeft = true; Lara.flareControlLeft = true;
Lara.litTorch = LaraItem->itemFlags[3] & 1; Lara.litTorch = LaraItem->itemFlags[3] & 1;
@ -184,7 +184,7 @@ void GetFlameTorch() // (F) (D)
Lara.flareControlLeft = true; Lara.flareControlLeft = true;
Lara.leftArm.animNumber = Objects[ID_LARA_TORCH_ANIM].animIndex; Lara.leftArm.animNumber = Objects[ID_LARA_TORCH_ANIM].animIndex;
Lara.gunStatus = LG_READY; Lara.gunStatus = LG_READY;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.leftArm.frameNumber = 0; Lara.leftArm.frameNumber = 0;
Lara.leftArm.frameBase = Anims[Lara.leftArm.animNumber].framePtr; Lara.leftArm.frameBase = Anims[Lara.leftArm.animNumber].framePtr;
LARA_MESHES(ID_LARA_TORCH_ANIM, LM_LHAND); LARA_MESHES(ID_LARA_TORCH_ANIM, LM_LHAND);
@ -237,7 +237,7 @@ void TorchControl(short itemNumber) // (F) (D)
} }
else else
{ {
STATIC_INFO* sobj = &StaticObjects[CollidedMeshes[0]->staticNumber]; StaticInfo* sobj = &StaticObjects[CollidedMeshes[0]->staticNumber];
PHD_3DPOS pos; PHD_3DPOS pos;
pos.xPos = CollidedMeshes[0]->x; pos.xPos = CollidedMeshes[0]->x;
pos.yPos = CollidedMeshes[0]->y; pos.yPos = CollidedMeshes[0]->y;

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h"
#include "collide.h"
void TriggerTorchFlame(char fxObj, char node); void TriggerTorchFlame(char fxObj, char node);
void DoFlameTorch(); void DoFlameTorch();

View file

@ -1,13 +1,14 @@
#include "framework.h"
#include "footprint.h" #include "footprint.h"
#include "control.h" #include "control.h"
#include "lara.h" #include "lara.h"
#include "draw.h" #include "draw.h"
#include "groundfx.h" #include "groundfx.h"
#include "../Specific/level.h" #include "level.h"
std::deque<FOOTPRINT_STRUCT> footprints = deque<FOOTPRINT_STRUCT>(); std::deque<FOOTPRINT_STRUCT> footprints = deque<FOOTPRINT_STRUCT>();
bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPosition){ bool CheckFootOnFloor(ITEM_INFO& const item, int joint, PHD_3DPOS& outFootprintPosition){
int x = item.pos.xPos; int x = item.pos.xPos;
int y = item.pos.yPos; int y = item.pos.yPos;
int z = item.pos.zPos; int z = item.pos.zPos;
@ -21,12 +22,12 @@ bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPo
PHD_VECTOR pos; PHD_VECTOR pos;
pos.x = pos.z = 0; pos.x = pos.z = 0;
pos.y = FOOT_HEIGHT_OFFSET; pos.y = FOOT_HEIGHT_OFFSET;
GetLaraJointPosition(&pos, mesh); GetLaraJointPosition(&pos, joint);
outFootprintPosition.xPos = pos.x; outFootprintPosition.xPos = pos.x;
outFootprintPosition.zPos = pos.z; outFootprintPosition.zPos = pos.z;
outFootprintPosition.yPos = height-1; outFootprintPosition.yPos = height-1;
outFootprintPosition.yRot = item.pos.yRot; outFootprintPosition.yRot = item.pos.yRot;
return abs(pos.y - height) < 32; return abs(pos.y - height) < 32;
} }
void updateFootprints() void updateFootprints()

View file

@ -1,7 +1,6 @@
#include "../Global/types.h"
#include "math.h"
#include <queue>
#pragma once #pragma once
#include "items.h"
#include "trmath.h"
constexpr size_t MAX_FOOTPRINTS = 20; constexpr size_t MAX_FOOTPRINTS = 20;
typedef struct footprint_t { typedef struct footprint_t {
@ -14,5 +13,5 @@ typedef struct footprint_t {
} FOOTPRINT_STRUCT; } FOOTPRINT_STRUCT;
constexpr int FOOT_HEIGHT_OFFSET = 64; constexpr int FOOT_HEIGHT_OFFSET = 64;
bool CheckFootOnFloor(ITEM_INFO& const item, int mesh, PHD_3DPOS& outFootprintPosition); bool CheckFootOnFloor(ITEM_INFO& const item, int joint, PHD_3DPOS& outFootprintPosition);
void updateFootprints(); void updateFootprints();

View file

@ -1,14 +1,10 @@
#include "framework.h"
#include "gameflow.h" #include "gameflow.h"
#include "draw.h" #include "draw.h"
#include "savegame.h" #include "savegame.h"
#include "input.h"
#include "..\Specific\input.h" #include "level.h"
#include "..\Global\global.h"
#include "../Specific/level.h"
#include <string>
using namespace std;
SavegameInfo g_SavegameInfos[MAX_SAVEGAMES]; SavegameInfo g_SavegameInfos[MAX_SAVEGAMES];
SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES]; SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES];

View file

@ -1,12 +1,8 @@
#pragma once #pragma once
#include <vector>
#include <string>
#include "savegame.h" #include "savegame.h"
using namespace std; typedef struct SavegameInfo
{
typedef struct SavegameInfo {
bool present; bool present;
char levelName[75]; char levelName[75];
int saveNumber; int saveNumber;
@ -19,6 +15,24 @@ typedef struct SavegameInfo {
#define MAX_SAVEGAMES 16 #define MAX_SAVEGAMES 16
struct GAMEFLOW
{
unsigned int CheatEnabled : 1;
unsigned int LoadSaveEnabled : 1;
unsigned int TitleEnabled : 1;
unsigned int PlayAnyLevel : 1;
unsigned int Language : 3;
unsigned int DemoDisc : 1;
unsigned int Unused : 24;
unsigned int InputTimeout;
unsigned char SecurityTag;
unsigned char nLevels;
unsigned char nFileNames;
unsigned char Pad;
unsigned short FileNameLen;
unsigned short ScriptLen;
};
extern SavegameInfo g_SavegameInfos[MAX_SAVEGAMES]; extern SavegameInfo g_SavegameInfos[MAX_SAVEGAMES];
extern vector<string> g_NewStrings; extern vector<string> g_NewStrings;
extern SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES]; extern SaveGameHeader g_NewSavegameInfos[MAX_SAVEGAMES];

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
enum GroundMaterial : unsigned char { enum GroundMaterial : unsigned char
{
Mud = 0, Mud = 0,
Snow = 1, Snow = 1,
Sand = 2, Sand = 2,

View file

@ -1,16 +1,17 @@
#include "framework.h"
#include "hair.h" #include "hair.h"
#include "..\Global\global.h"
#include "draw.h" #include "draw.h"
#include "laramisc.h" #include "laramisc.h"
#include "lara.h" #include "lara.h"
#include "control.h" #include "control.h"
#include "..\Scripting\GameFlowScript.h" #include "GameFlowScript.h"
#include "../Specific/setup.h" #include "setup.h"
#include "sphere.h" #include "sphere.h"
#include "../Specific/level.h" #include "level.h"
int FirstHair[2]; int FirstHair[HAIR_MAX];
HAIR_STRUCT Hairs[2][7]; HAIR_STRUCT Hairs[HAIR_MAX][HAIR_SEGMENTS];
int WindAngle; int WindAngle;
int DWindAngle; int DWindAngle;
int Wind; int Wind;
@ -19,11 +20,11 @@ extern GameFlow* g_GameFlow;
void InitialiseHair() void InitialiseHair()
{ {
for (int h = 0; h < 2; h++) for (int h = 0; h < HAIR_MAX; h++)
{ {
FirstHair[h] = 1; FirstHair[h] = 1;
int* bone = Bones + Objects[ID_LARA_HAIR].boneIndex; int* bone = &Bones[Objects[ID_LARA_HAIR].boneIndex];
Hairs[h][0].pos.yRot = 0; Hairs[h][0].pos.yRot = 0;
Hairs[h][0].pos.xRot = -0x4000; Hairs[h][0].pos.xRot = -0x4000;
@ -44,7 +45,7 @@ void InitialiseHair()
void HairControl(int cutscene, int ponytail, short* framePtr) void HairControl(int cutscene, int ponytail, short* framePtr)
{ {
SPHERE sphere[5]; SPHERE sphere[HAIR_SPHERE];
ObjectInfo* object = &Objects[ID_LARA]; ObjectInfo* object = &Objects[ID_LARA];
short* frame; short* frame;
int spaz; int spaz;
@ -105,7 +106,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
sphere[0].x = pos.x; sphere[0].x = pos.x;
sphere[0].y = pos.y; sphere[0].y = pos.y;
sphere[0].z = pos.z; sphere[0].z = pos.z;
sphere[0].r = (int) *(objptr + 3); sphere[0].r = (int) * (objptr + 3);
objptr = Lara.meshPtrs[LM_TORSO]; objptr = Lara.meshPtrs[LM_TORSO];
pos = { objptr[0], objptr[1], objptr[2] }; pos = { objptr[0], objptr[1], objptr[2] };
@ -168,7 +169,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
pos.y = world.Translation().y; pos.y = world.Translation().y;
pos.z = world.Translation().z; pos.z = world.Translation().z;
int* bone = Bones + Objects[ID_LARA_HAIR].boneIndex; int* bone = &Bones[Objects[ID_LARA_HAIR].boneIndex];
if (FirstHair[ponytail]) if (FirstHair[ponytail])
{ {
@ -202,7 +203,9 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
int wh; int wh;
if (cutscene) if (cutscene)
{
wh = NO_HEIGHT; wh = NO_HEIGHT;
}
else else
{ {
int x = LaraItem->pos.xPos + (frame[0] + frame[1]) / 2; int x = LaraItem->pos.xPos + (frame[0] + frame[1]) / 2;
@ -246,7 +249,9 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
height = GetFloorHeight(floor, Hairs[ponytail][i].pos.xPos, Hairs[ponytail][i].pos.yPos, Hairs[ponytail][i].pos.zPos); height = GetFloorHeight(floor, Hairs[ponytail][i].pos.xPos, Hairs[ponytail][i].pos.yPos, Hairs[ponytail][i].pos.zPos);
} }
else else
{
height = 32767; height = 32767;
}
Hairs[ponytail][i].pos.xPos += Hairs[ponytail][i].hvel.x * 3 / 4; Hairs[ponytail][i].pos.xPos += Hairs[ponytail][i].hvel.x * 3 / 4;
Hairs[ponytail][i].pos.yPos += Hairs[ponytail][i].hvel.y * 3 / 4; Hairs[ponytail][i].pos.yPos += Hairs[ponytail][i].hvel.y * 3 / 4;
@ -263,7 +268,9 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
case LW_ABOVE_WATER: case LW_ABOVE_WATER:
Hairs[ponytail][i].pos.yPos += 10; Hairs[ponytail][i].pos.yPos += 10;
if (wh != NO_HEIGHT && Hairs[ponytail][i].pos.yPos > wh) if (wh != NO_HEIGHT && Hairs[ponytail][i].pos.yPos > wh)
{
Hairs[ponytail][i].pos.yPos = wh; Hairs[ponytail][i].pos.yPos = wh;
}
else if (Hairs[ponytail][i].pos.yPos > height) else if (Hairs[ponytail][i].pos.yPos > height)
{ {
Hairs[ponytail][i].pos.xPos = Hairs[ponytail][0].hvel.x; Hairs[ponytail][i].pos.xPos = Hairs[ponytail][0].hvel.x;
@ -281,7 +288,7 @@ void HairControl(int cutscene, int ponytail, short* framePtr)
break; break;
} }
for (int j = 0; j < 5; j++) for (int j = 0; j < HAIR_SPHERE; j++)
{ {
int x = Hairs[ponytail][i].pos.xPos - sphere[j].x; int x = Hairs[ponytail][i].pos.xPos - sphere[j].x;
int y = Hairs[ponytail][i].pos.yPos - sphere[j].y; int y = Hairs[ponytail][i].pos.yPos - sphere[j].y;

View file

@ -1,8 +1,18 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "phd_global.h"
extern HAIR_STRUCT Hairs[2][7]; constexpr auto HAIR_MAX = 2; // HAIR_NORMAL = 0, HAIR_YOUNG = 1
constexpr auto HAIR_SEGMENTS = 7; // classic = 7, young = 14
constexpr auto HAIR_SPHERE = 5; // current hair max collision
struct HAIR_STRUCT
{
PHD_3DPOS pos;
PHD_VECTOR hvel;
PHD_VECTOR unknown;
};
extern HAIR_STRUCT Hairs[HAIR_MAX][HAIR_SEGMENTS];
void InitialiseHair(); void InitialiseHair();
void HairControl(int cutscene, int ponytail, short* framePtr); void HairControl(int cutscene, int ponytail, short* framePtr);

View file

@ -1,251 +1,252 @@
#include "healt.h" #include "framework.h"
#include "draw.h" #include "health.h"
#include "pickup.h" #include "draw.h"
#include "lara.h" #include "pickup.h"
#include "camera.h" #include "lara.h"
#include "../Specific/level.h" #include "camera.h"
#include "control.h" #include "level.h"
#include "control.h"
short PickupX;
short PickupY; short PickupX;
short CurrentPickup; short PickupY;
DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS]; short CurrentPickup;
short PickupVel; DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS];
int OldHitPoints = 1000; short PickupVel;
int HealtBarTimer = 40; int OldHitPoints = 1000;
int FlashState = 0; int HealtBarTimer = 40;
int FlashCount = 0; int FlashState = 0;
int PoisonFlag = 0; int FlashCount = 0;
int DashTimer = 0; int PoisonFlag = 0;
extern RendererHUDBar* g_HealthBar; int DashTimer = 0;
extern RendererHUDBar* g_DashBar; extern RendererHUDBar* g_HealthBar;
extern RendererHUDBar* g_AirBar; extern RendererHUDBar* g_DashBar;
extern RendererHUDBar* g_AirBar;
void DrawHealthBarOverlay(int value)
{ void DrawHealthBarOverlay(int value)
if (CurrentLevel) {
{ if (CurrentLevel)
int color2 = 0; {
if (Lara.poisoned || Lara.gassed) int color2 = 0;
color2 = 0xA0A000; if (Lara.poisoned || Lara.gassed)
else color2 = 0xA0A000;
color2 = 0xA00000; else
g_Renderer->DrawBar(value, g_HealthBar); color2 = 0xA00000;
} g_Renderer->DrawBar(value, g_HealthBar);
} }
}
void DrawHealthBar(float value)
{ void DrawHealthBar(float value)
if (CurrentLevel) {
{ if (CurrentLevel)
//int color2; {
//if (Lara.poisoned || Lara.gassed) //int color2;
// color2 = 0xA0A000; //if (Lara.poisoned || Lara.gassed)
//else // color2 = 0xA0A000;
// color2 = 0xA00000; //else
g_Renderer->DrawBar(value,g_HealthBar); // color2 = 0xA00000;
} g_Renderer->DrawBar(value,g_HealthBar);
} }
}
void UpdateHealtBar(int flash)
{ void UpdateHealtBar(int flash)
int hitPoints = LaraItem->hitPoints; {
int hitPoints = LaraItem->hitPoints;
if (hitPoints < 0)
hitPoints = 0; if (hitPoints < 0)
else if (hitPoints > 1000) hitPoints = 0;
hitPoints = 1000; else if (hitPoints > 1000)
hitPoints = 1000;
if (OldHitPoints != hitPoints)
{ if (OldHitPoints != hitPoints)
OldHitPoints = hitPoints; {
HealtBarTimer = 40; OldHitPoints = hitPoints;
} HealtBarTimer = 40;
}
if (HealtBarTimer < 0)
HealtBarTimer = 0; if (HealtBarTimer < 0)
HealtBarTimer = 0;
if (hitPoints <= 1000 / 4)
{ if (hitPoints <= 1000 / 4)
if (!BinocularRange) {
{ if (!BinocularRange)
if (flash) {
DrawHealthBar(hitPoints / 1000.0f); if (flash)
else DrawHealthBar(hitPoints / 1000.0f);
DrawHealthBar(0); else
} DrawHealthBar(0);
else }
{ else
if (flash) {
DrawHealthBarOverlay(hitPoints / 1000.0f); if (flash)
else DrawHealthBarOverlay(hitPoints / 1000.0f);
DrawHealthBarOverlay(0); else
} DrawHealthBarOverlay(0);
} }
else if ((HealtBarTimer > 0) }
|| (hitPoints <= 0) else if ((HealtBarTimer > 0)
|| (Lara.gunStatus == LG_READY && Lara.gunType != WEAPON_TORCH) || (hitPoints <= 0)
|| (Lara.poisoned >= 256)) || (Lara.gunStatus == LG_READY && Lara.gunType != WEAPON_TORCH)
{ || (Lara.poisoned >= 256))
if (!BinocularRange && !SniperOverlay) {
{ if (!BinocularRange && !SniperOverlay)
DrawHealthBar(hitPoints / 1000.0f); {
} DrawHealthBar(hitPoints / 1000.0f);
else }
{ else
DrawHealthBarOverlay(hitPoints / 1000.0f); {
} DrawHealthBarOverlay(hitPoints / 1000.0f);
} }
}
if (PoisonFlag)
PoisonFlag--; if (PoisonFlag)
} PoisonFlag--;
}
void DrawAirBar(float value)
{ void DrawAirBar(float value)
if (CurrentLevel) {
{ if (CurrentLevel)
g_Renderer->DrawBar(value, g_AirBar); {
} g_Renderer->DrawBar(value, g_AirBar);
} }
}
void UpdateAirBar(int flash)
{ void UpdateAirBar(int flash)
if (Lara.air == 1800 || LaraItem->hitPoints <= 0) {
return; if (Lara.air == 1800 || LaraItem->hitPoints <= 0)
return;
if ((Lara.Vehicle == NO_ITEM)
|| (Items[Lara.Vehicle].objectNumber != ID_UPV)) if ((Lara.Vehicle == NO_ITEM)
{ || (Items[Lara.Vehicle].objectNumber != ID_UPV))
if ((Lara.waterStatus != LW_UNDERWATER) {
&& (Lara.waterStatus != LW_SURFACE) if ((Lara.waterStatus != LW_UNDERWATER)
&& (!((Rooms[LaraItem->roomNumber].flags & ENV_FLAG_SWAMP) && (Lara.waterStatus != LW_SURFACE)
&& (Lara.waterSurfaceDist < -775)))) && (!((Rooms[LaraItem->roomNumber].flags & ENV_FLAG_SWAMP)
return; && (Lara.waterSurfaceDist < -775))))
} return;
}
int air = Lara.air;
if (air < 0) int air = Lara.air;
air = 0; if (air < 0)
else if (air > 1800) air = 0;
air = 1800; else if (air > 1800)
if (air <= 450) air = 1800;
{ if (air <= 450)
if (flash) {
DrawAirBar(air/ 1800.0f); if (flash)
else DrawAirBar(air/ 1800.0f);
DrawAirBar(0); else
} DrawAirBar(0);
else }
DrawAirBar(air / 1800.0f); else
DrawAirBar(air / 1800.0f);
if (Lara.gassed)
{ if (Lara.gassed)
if (Lara.dpoisoned < 2048) {
Lara.dpoisoned += 2; if (Lara.dpoisoned < 2048)
Lara.gassed = false; Lara.dpoisoned += 2;
} Lara.gassed = false;
} }
}
void DrawDashBar(int value)
{ void DrawDashBar(int value)
if (CurrentLevel) {
{ if (CurrentLevel)
g_Renderer->DrawBar(value, g_DashBar); {
} g_Renderer->DrawBar(value, g_DashBar);
} }
}
int DrawAllPickups()
{ int DrawAllPickups()
if (Pickups[CurrentPickup].life > 0) {
{ if (Pickups[CurrentPickup].life > 0)
if (PickupX > 0) {
{ if (PickupX > 0)
PickupX += -PickupX >> 5; {
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber); PickupX += -PickupX >> 5;
} return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
else }
{ else
Pickups[CurrentPickup].life--; {
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber); Pickups[CurrentPickup].life--;
} return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
} }
else if (Pickups[CurrentPickup].life == 0) }
{ else if (Pickups[CurrentPickup].life == 0)
if (PickupX < 128) {
{ if (PickupX < 128)
if (PickupVel < 16) {
PickupVel++; if (PickupVel < 16)
PickupX += PickupVel >> 2; PickupVel++;
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber); PickupX += PickupVel >> 2;
} return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
else }
{ else
Pickups[CurrentPickup].life = -1; {
PickupVel = 0; Pickups[CurrentPickup].life = -1;
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber); PickupVel = 0;
} return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
} }
}
int pickupIndex = CurrentPickup;
int i; int pickupIndex = CurrentPickup;
for (i = 0; i < MAX_COLLECTED_PICKUPS; ++i) int i;
{ for (i = 0; i < MAX_COLLECTED_PICKUPS; ++i)
if (Pickups[pickupIndex].life > 0) {
break; if (Pickups[pickupIndex].life > 0)
pickupIndex = pickupIndex + 1 & MAX_COLLECTED_PICKUPS - 1; break;
} pickupIndex = pickupIndex + 1 & MAX_COLLECTED_PICKUPS - 1;
}
CurrentPickup = pickupIndex;
if (i != MAX_COLLECTED_PICKUPS) CurrentPickup = pickupIndex;
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber); if (i != MAX_COLLECTED_PICKUPS)
return g_Renderer->DrawPickup(Pickups[CurrentPickup].objectNumber);
CurrentPickup = 0;
CurrentPickup = 0;
return 0;
} return 0;
}
void AddDisplayPickup(short objectNumber)
{ void AddDisplayPickup(short objectNumber)
for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++) {
{ for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++)
DISPLAY_PICKUP* pickup = &Pickups[i]; {
if (pickup->life < 0) DISPLAY_PICKUP* pickup = &Pickups[i];
{ if (pickup->life < 0)
pickup->life = 45; {
pickup->objectNumber = objectNumber; pickup->life = 45;
PickedUpObject(objectNumber); pickup->objectNumber = objectNumber;
return; PickedUpObject(objectNumber);
} return;
} }
}
// No free slot found, so just pickup the object ithout displaying it
PickedUpObject(objectNumber); // No free slot found, so just pickup the object ithout displaying it
} PickedUpObject(objectNumber);
}
void InitialisePickupDisplay()
{ void InitialisePickupDisplay()
for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++) {
{ for (int i = 0; i < MAX_COLLECTED_PICKUPS; i++)
DISPLAY_PICKUP* pickup = &Pickups[i]; {
pickup->life = -1; DISPLAY_PICKUP* pickup = &Pickups[i];
} pickup->life = -1;
}
PickupX = 128;
PickupY = 128; PickupX = 128;
PickupVel = 0; PickupY = 128;
CurrentPickup = 0; PickupVel = 0;
} CurrentPickup = 0;
}
int FlashIt()
{ int FlashIt()
if (FlashCount) {
FlashCount--; if (FlashCount)
else FlashCount--;
{ else
FlashState ^= 1; {
FlashCount = 5; FlashState ^= 1;
} FlashCount = 5;
return FlashState; }
} return FlashState;
}

View file

@ -1,27 +1,30 @@
#pragma once #pragma once
#define MAX_COLLECTED_PICKUPS 32
#include "..\Global\global.h"
typedef struct DISPLAY_PICKUP
#define MAX_COLLECTED_PICKUPS 32 {
short life;
void DrawHealthBarOverlay(int value); short objectNumber;
void DrawHealthBar(float value); };
void UpdateHealtBar(int flash);
void DrawAirBar(float value); void DrawHealthBarOverlay(int value);
void UpdateAirBar(int flash); void DrawHealthBar(float value);
void DrawDashBar(int value); void UpdateHealtBar(int flash);
void AddDisplayPickup(short objectNumber); void DrawAirBar(float value);
int DrawAllPickups(); void UpdateAirBar(int flash);
void InitialisePickupDisplay(); void DrawDashBar(int value);
int FlashIt(); void AddDisplayPickup(short objectNumber);
int DrawAllPickups();
extern short PickupX; void InitialisePickupDisplay();
extern short PickupY; int FlashIt();
extern short CurrentPickup;
extern DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS]; extern short PickupX;
extern short PickupVel; extern short PickupY;
extern int OldHitPoints; extern short CurrentPickup;
extern int HealtBarTimer; extern DISPLAY_PICKUP Pickups[MAX_COLLECTED_PICKUPS];
extern int FlashState; extern short PickupVel;
extern int PoisonFlag; extern int OldHitPoints;
extern int DashTimer; extern int HealtBarTimer;
extern int FlashState;
extern int PoisonFlag;
extern int DashTimer;

View file

@ -1,21 +1,21 @@
#include "framework.h"
#include "inventory.h" #include "inventory.h"
#include "draw.h" #include "draw.h"
#include "control.h" #include "control.h"
#include "larafire.h" #include "larafire.h"
#include "sound.h"
#include "gameflow.h" #include "gameflow.h"
#include "sound.h" #include "sound.h"
#include "savegame.h" #include "savegame.h"
#include "Lara.h" #include "Lara.h"
#include "camera.h" #include "camera.h"
#include "spotcam.h" #include "spotcam.h"
#include "..\Global\global.h"
#include "..\Specific\input.h" #include "input.h"
#include "..\Specific\configuration.h" #include "configuration.h"
#include "lara1gun.h" #include "lara1gun.h"
#include "lara2gun.h" #include "lara2gun.h"
#include "../Specific/level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
Inventory* g_Inventory; Inventory* g_Inventory;
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;
@ -261,7 +261,7 @@ void Inventory::LoadObjects(bool isReload)
for (int j = 0; j < NUM_INVENTORY_OBJECTS_PER_RING; j++) for (int j = 0; j < NUM_INVENTORY_OBJECTS_PER_RING; j++)
{ {
m_rings[i].objects[j].inventoryObject = -1; m_rings[i].objects[j].inventoryObject = NO_ITEM;
m_rings[i].objects[j].rotation = 0; m_rings[i].objects[j].rotation = 0;
m_rings[i].objects[j].scale = INV_OBJECTS_SCALE; m_rings[i].objects[j].scale = INV_OBJECTS_SCALE;
} }

View file

@ -1,9 +1,5 @@
#pragma once #pragma once
#include "configuration.h"
#include "..\Specific\configuration.h"
#include <vector>
using namespace std;
// New inventory // New inventory
#define NUM_INVENTORY_OBJECTS_PER_RING 120 #define NUM_INVENTORY_OBJECTS_PER_RING 120
@ -165,6 +161,19 @@ enum INVENTORY_OBJECTS {
INVENTORY_TABLE_SIZE INVENTORY_TABLE_SIZE
}; };
typedef struct INVOBJ
{
short objectNumber;
short yOff;
short scale1;
short yRot;
short xRot;
short zRot;
short flags;
short objectName;
int meshBits;
};
// Focus state // Focus state
#define INV_FOCUS_STATE_NONE 0 #define INV_FOCUS_STATE_NONE 0
#define INV_FOCUS_STATE_POPUP 1 #define INV_FOCUS_STATE_POPUP 1
@ -247,13 +256,15 @@ enum INVENTORY_OBJECTS {
#define INV_NUM_COMBINATIONS 22 #define INV_NUM_COMBINATIONS 22
struct InventoryObject { struct InventoryObject
{
int inventoryObject; int inventoryObject;
int rotation; int rotation;
float scale; float scale;
}; };
struct InventoryRing { struct InventoryRing
{
InventoryObject objects[NUM_INVENTORY_OBJECTS_PER_RING]; InventoryObject objects[NUM_INVENTORY_OBJECTS_PER_RING];
int numObjects; int numObjects;
int currentObject; int currentObject;
@ -277,7 +288,8 @@ struct InventoryRing {
int numActions = 3; int numActions = 3;
}; };
struct InventoryObjectDefinition { struct InventoryObjectDefinition
{
short objectNumber; short objectNumber;
short objectName; short objectName;
int meshBits; int meshBits;
@ -297,7 +309,8 @@ struct InventoryObjectDefinition {
} }
}; };
struct InventoryObjectCombination { struct InventoryObjectCombination
{
short piece1; short piece1;
short piece2; short piece2;
short combinedObject; short combinedObject;

View file

@ -1,11 +1,10 @@
#include "framework.h"
#include "items.h" #include "items.h"
#include "..\Global\global.h"
#include "effect2.h" #include "effect2.h"
#include <stdio.h> #include "setup.h"
#include "../Specific/setup.h" #include "level.h"
#include "../Specific/level.h"
#include "lara.h" #include "lara.h"
#include "effects.h" #include "effect.h"
void ClearItem(short itemNum) void ClearItem(short itemNum)
{ {
@ -30,7 +29,7 @@ void KillItem(short itemNum)
{ {
ITEM_INFO* item = &Items[itemNum]; ITEM_INFO* item = &Items[itemNum];
DetatchSpark(itemNum, 128); DetatchSpark(itemNum, SP_ITEM);
item->active = false; item->active = false;
item->reallyActive = false; item->reallyActive = false;
@ -52,7 +51,7 @@ void KillItem(short itemNum)
} }
} }
if (item->roomNumber != 255) if (item->roomNumber != NO_ROOM)
{ {
if (Rooms[item->roomNumber].itemNumber == itemNum) if (Rooms[item->roomNumber].itemNumber == itemNum)
{ {
@ -99,7 +98,7 @@ void RemoveAllItemsInRoom(short roomNumber, short objectNumber)
if (item->objectNumber == objectNumber) if (item->objectNumber == objectNumber)
{ {
RemoveActiveItem(currentItemNum); RemoveActiveItem(currentItemNum);
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
item->flags &= 0xC1; item->flags &= 0xC1;
} }
@ -115,7 +114,7 @@ void AddActiveItem(short itemNumber)
if (Objects[item->objectNumber].control == NULL) if (Objects[item->objectNumber].control == NULL)
{ {
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
return; return;
} }
@ -212,8 +211,7 @@ void KillEffect(short fxNumber)
else else
{ {
FX_INFO* fx = &Effects[fxNumber]; FX_INFO* fx = &Effects[fxNumber];
DetatchSpark(fxNumber, SP_FX);
DetatchSpark(fxNumber, 128); // TODO: SP_FX have the value 64 but there it's 128 !!
if (NextFxActive == fxNumber) if (NextFxActive == fxNumber)
{ {
@ -355,7 +353,7 @@ void InitialiseItem(short itemNum)
item->itemFlags[0] = 0; item->itemFlags[0] = 0;
item->active = false; item->active = false;
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
item->gravityStatus = false; item->gravityStatus = false;
item->hitStatus = false; item->hitStatus = false;
item->collidable = true; item->collidable = true;
@ -467,7 +465,7 @@ short SpawnItem(ITEM_INFO* item, short objectNumber)
InitialiseItem(itemNumber); InitialiseItem(itemNumber);
spawn->status = ITEM_INACTIVE; spawn->status = ITEM_NOT_ACTIVE;
spawn->shade = 0x4210; spawn->shade = 0x4210;
} }
@ -495,11 +493,11 @@ int GlobalItemReplace(short search, short replace)
ITEM_INFO* find_a_fucking_item(short objectNum) ITEM_INFO* find_a_fucking_item(short objectNum)
{ {
int itemNumber = FindItem(objectNum); int itemNumber = FindItemNumber(objectNum);
return (itemNumber != NO_ITEM ? &Items[itemNumber] : NULL); return (itemNumber != NO_ITEM ? &Items[itemNumber] : NULL);
} }
int FindItem(short objectNum) int FindItemNumber(short objectNum)
{ {
for (int i = 0; i < LevelItems; i++) for (int i = 0; i < LevelItems; i++)
{ {
@ -510,3 +508,21 @@ int FindItem(short objectNum)
return NO_ITEM; return NO_ITEM;
} }
ITEM_INFO* FindItem(short objectNumber)
{
#ifdef _DEBUG
printf("Called FindItem()\n");
#endif
if (LevelItems > 0)
{
for (int i = 0; i < LevelItems; i++)
{
if (Items[i].objectNumber == objectNumber)
return &Items[i];
}
}
return NULL;
}

View file

@ -1,7 +1,89 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "phd_global.h"
#include "control.h"
typedef enum AIObjectType
{
NO_AI = 0x0000,
GUARD = 0x0001,
AMBUSH = 0x0002,
PATROL1 = 0x0004,
MODIFY = 0x0008,
FOLLOW = 0x0010,
PATROL2 = 0x0020,
ALL_AIOBJ = (GUARD | AMBUSH | PATROL1 | MODIFY | FOLLOW | PATROL2)
};
typedef enum ItemStatus
{
ITEM_ACTIVE,
ITEM_NOT_ACTIVE,
ITEM_DESACTIVATED,
ITEM_INVISIBLE
};
typedef enum ItemFlags
{
IFLAG_CLEAR_BODY = (1 << 7), // 0x0080
IFLAG_INVISIBLE = (1 << 8), // 0x0100
IFLAG_REVERSE = (1 << 14), // 0x4000
IFLAG_KILLED = (1 << 15), // 0x8000
IFLAG_ACTIVATION_MASK = 0x3E00 // bits 9-13
};
typedef struct ITEM_INFO
{
int floor;
DWORD touchBits;
DWORD meshBits;
short objectNumber;
short currentAnimState;
short goalAnimState;
short requiredAnimState;
short animNumber;
short frameNumber;
short roomNumber;
short nextItem;
short nextActive;
short speed;
short fallspeed;
short hitPoints;
unsigned short boxNumber;
short timer;
unsigned short flags; // ItemFlags enum
short shade;
short triggerFlags;
short carriedItem;
short afterDeath;
short firedWeapon;
short itemFlags[4];
void* data;
PHD_3DPOS pos;
byte legacyLightData[5528];
bool active;
short status; // ItemStatus enum
bool gravityStatus;
bool hitStatus;
bool collidable;
bool lookedAt;
bool dynamicLight;
bool poisoned;
byte aiBits; // AIObjectType enum
bool reallyActive;
bool inDrawRoom;
int swapMeshFlags;
short drawRoom;
short TOSSPAD;
};
// used by fx->shade !
#define RGB555(r, g, b) ((r << 7) & 0x7C00 | (g << 2) & 0x3E0 | (b >> 3) & 0x1F)
#define WHITE555 RGB555(255, 255, 255)
#define GRAY555 RGB555(128, 128, 128)
#define BLACK555 RGB555( 0, 0, 0)
constexpr auto NO_ITEM = -1;
constexpr auto ALL_MESHBITS = -1;
constexpr auto NOT_TARGETABLE = -16384;
#define NUM_ITEMS 1024 #define NUM_ITEMS 1024
#define NUM_EFFECTS 1024 #define NUM_EFFECTS 1024
@ -20,4 +102,5 @@ void InitialiseItem(short itemNum);
void InitialiseItemArray(int numitems); void InitialiseItemArray(int numitems);
void KillItem(short itemNum); void KillItem(short itemNum);
ITEM_INFO* find_a_fucking_item(short objectNum); ITEM_INFO* find_a_fucking_item(short objectNum);
int FindItem(short objectNum); int FindItemNumber(short objectNumber);
ITEM_INFO* FindItem(short objectNumber);

View file

@ -1,14 +1,13 @@
#include "framework.h"
#include "Lara.h" #include "Lara.h"
#include "control.h" #include "control.h"
#include "items.h" #include "items.h"
#include "collide.h"
#include "inventory.h" #include "inventory.h"
#include "larafire.h" #include "larafire.h"
#include "misc.h" #include "misc.h"
#include "draw.h" #include "draw.h"
#include "sphere.h" #include "sphere.h"
#include "Camera.h" #include "camera.h"
#include "larasurf.h" #include "larasurf.h"
#include "laraswim.h" #include "laraswim.h"
#include "lara1gun.h" #include "lara1gun.h"
@ -17,15 +16,21 @@
#include "laramisc.h" #include "laramisc.h"
#include "laraclmb.h" #include "laraclmb.h"
#include "rope.h" #include "rope.h"
#include "healt.h" #include "health.h"
#include "level.h"
#include "..\Objects\newobjects.h" #include "input.h"
#include "..\Global\global.h"
#include "../Specific/level.h"
#include "../Specific/input.h"
#include "sound.h" #include "sound.h"
#include "setup.h"
#include <stdio.h> #include "motorbike.h"
#include "cannon.h"
#include "quad.h"
#include "snowmobile.h"
#include "jeep.h"
#include "boat.h"
#include "upv.h"
#include "kayak.h"
#include "minecart.h"
static short LeftClimbTab[4] = // offset 0xA0638 static short LeftClimbTab[4] = // offset 0xA0638
{ {
@ -45,12 +50,11 @@ short OldAngle = 1;
int RopeSwing = 0; int RopeSwing = 0;
LaraInfo Lara; LaraInfo Lara;
ITEM_INFO* LaraItem; ITEM_INFO* LaraItem;
byte LaraNodeUnderwater[15]; byte LaraNodeUnderwater[NUM_LARA_MESHES];
bool EnableCrouchRoll, EnableFeetHang, EnableMonkeyVault, EnableMonkeyRoll, EnableCrawlFlex1click, EnableCrawlFlex2click, EnableCrawlFlex3click; bool EnableCrouchRoll, EnableFeetHang, EnableMonkeyVault, EnableMonkeyRoll, EnableCrawlFlex1click, EnableCrawlFlex2click, EnableCrawlFlex3click;
bool EnableCrawlFlex1clickE, EnableCrawlFlex2clickE, EnableCrawlFlex1clickup, EnableCrawlFlex1clickdown; bool EnableCrawlFlex1clickE, EnableCrawlFlex2clickE, EnableCrawlFlex1clickup, EnableCrawlFlex1clickdown;
void(*lara_control_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll) = function<LaraRoutineFunction> lara_control_routines[NUM_LARA_STATES + 1] = {
{
lara_as_walk, lara_as_walk,
lara_as_run, lara_as_run,
lara_as_stop, lara_as_stop,
@ -198,9 +202,7 @@ void(*lara_control_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* co
lara_as_hang_feet_outRcorner, lara_as_hang_feet_outRcorner,
lara_as_hang_feet_outLcorner, lara_as_hang_feet_outLcorner,
}; };
function<LaraRoutineFunction> lara_collision_routines[NUM_LARA_STATES + 1] = {
void(*lara_collision_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll) =
{
lara_col_walk, lara_col_walk,
lara_col_run, lara_col_run,
lara_col_stop, lara_col_stop,
@ -347,8 +349,10 @@ void(*lara_collision_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO*
lara_default_col, lara_default_col,
lara_default_col, lara_default_col,
lara_default_col, lara_default_col,
}; };
/*function<LaraRoutineFunction> lara_camera_routines[NUM_LARA_STATES + 1] = {
};*/
void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll) void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll)
{ {
@ -366,7 +370,7 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll)
coll->radius = LARA_RAD; coll->radius = LARA_RAD;
coll->trigger = NULL; coll->trigger = NULL;
if ((TrInput & IN_LOOK) && Lara.ExtraAnim == 0 && Lara.look) if ((TrInput & IN_LOOK) && Lara.ExtraAnim == NO_ITEM && Lara.look)
LookLeftRight(); LookLeftRight();
else else
ResetLook(); ResetLook();
@ -403,6 +407,16 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll)
return; return;
break; break;
//case ID_SPEEDBOAT:
// if (BoatControl())
// return;
// break;
//case ID_RUBBERBOAT:
// if (RubberBoatControl())
// return;
// break;
//case ID_UPV: //case ID_UPV:
// if (SubControl()) // if (SubControl())
// return; // return;
@ -419,7 +433,7 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll)
} }
// Handle current Lara status // Handle current Lara status
(*lara_control_routines[item->currentAnimState])(item, coll); lara_control_routines[item->currentAnimState](item, coll);
if (item->pos.zRot >= -ANGLE(1.0f) && item->pos.zRot <= ANGLE(1.0f)) if (item->pos.zRot >= -ANGLE(1.0f) && item->pos.zRot <= ANGLE(1.0f))
item->pos.zRot = 0; item->pos.zRot = 0;
@ -439,14 +453,14 @@ void LaraAboveWater(ITEM_INFO* item, COLL_INFO* coll)
// Animate Lara // Animate Lara
AnimateLara(item); AnimateLara(item);
if (Lara.ExtraAnim == 0) if (Lara.ExtraAnim == NO_ITEM)
{ {
// Check for collision with items // Check for collision with items
LaraBaddieCollision(item, coll); LaraBaddieCollision(item, coll);
// Handle Lara collision // Handle Lara collision
if (Lara.Vehicle == NO_ITEM) if (Lara.Vehicle == NO_ITEM)
(*lara_collision_routines[item->currentAnimState])(item, coll); lara_collision_routines[item->currentAnimState](item, coll);
} }
UpdateLaraRoom(item, -LARA_HITE/2); UpdateLaraRoom(item, -LARA_HITE/2);
@ -1783,13 +1797,13 @@ void lara_as_pulley(ITEM_INFO* item, COLL_INFO* coll)//1B288, 1B3BC (F)
if (p->itemFlags[2]) if (p->itemFlags[2])
{ {
p->itemFlags[2] = 0; p->itemFlags[2] = 0;
p->status = ITEM_DEACTIVATED; p->status = ITEM_DESACTIVATED;
} }
} }
else else
{ {
if (!p->itemFlags[1]) if (!p->itemFlags[1])
p->status = ITEM_DEACTIVATED; p->status = ITEM_DESACTIVATED;
p->itemFlags[2] = 1; p->itemFlags[2] = 1;

View file

@ -1,154 +1,32 @@
#pragma once #pragma once
#include "lara_struct.h"
#include "..\Global\global.h" #define FRONT_ARC ANGLE(90.0f)
#include "..\Renderer\Renderer11.h" #define LARA_LEAN_RATE ANGLE(1.5f)
#define LARA_LEAN_MAX ANGLE(11.0f)
#define LARA_TURN_RATE ANGLE(2.25f)
#define LARA_JUMP_TURN ANGLE(3.0f)
#define LARA_SLOW_TURN ANGLE(4.0f)
#define LARA_MED_TURN ANGLE(6.0f)
#define LARA_FAST_TURN ANGLE(8.0f)
typedef struct CarriedWeaponInfo { constexpr auto LARA_HITE = 762; // the size of lara (from the floor to the top of the head)
bool Present; constexpr auto LARA_FREEFALL_SPEED = 131;
short Ammo[3]; constexpr auto LARA_RAD = 100;
byte SelectedAmmo; constexpr auto LARA_VELOCITY = 12;
bool HasLasersight;
bool HasSilencer;
};
typedef struct DiaryInfo {
bool Present;
};
struct WaterskinInfo {
bool Present;
int Quantity;
};
struct LaraInfo {
short itemNumber;
short gunStatus;
short gunType;
short requestGunType;
short lastGunType;
short calcFallSpeed;
short waterStatus;
short climbStatus;
short poseCount;
short hitFrame;
short hitDirection;
short air;
short diveCount;
short deathCount;
short currentActive;
short currentXvel;
short currentYvel;
short currentZvel;
short spazEffectCount;
short flareAge;
short burnCount;
short weaponItem;
short backGun;
short flareFrame;
short poisoned;
short dpoisoned;
byte anxiety;
byte wet[15];
bool flareControlLeft;
bool unused1;
bool look;
bool burn;
bool keepDucked;
bool isMoving;
bool canMonkeySwing;
byte burnBlue;
bool gassed;
bool burnSmoke;
bool isDucked;
bool hasFired;
bool busy;
bool litTorch;
bool isClimbing;
bool fired;
int waterSurfaceDist;
PHD_VECTOR lastPos;
FX_INFO* spazEffect;
int meshEffects;
short* meshPtrs[15];
ITEM_INFO* target;
short targetAngles[2];
short turnRate;
short moveAngle;
short headYrot;
short headXrot;
short headZrot;
short torsoYrot;
short torsoXrot;
short torsoZrot;
LARA_ARM leftArm;
LARA_ARM rightArm;
unsigned short holster;
CREATURE_INFO* creature;
int cornerX;
int cornerZ;
byte ropeSegment;
byte ropeDirection;
short ropeArcFront;
short ropeArcBack;
short ropeLastX;
short ropeMaxXForward;
short ropeMaxXBackward;
int ropeDFrame;
int ropeFrame;
unsigned short ropeFrameRate;
unsigned short ropeY;
int ropePtr;
void* generalPtr;
int ropeOffset;
int ropeDownVel;
byte ropeFlag;
byte moveCount;
int ropeCount;
byte skelebob;
byte wetcloth;
byte bottle;
byte location;
byte highestLocation;
byte locationPad;
byte tightRopeOnCount;
byte tightRopeOff;
byte tightRopeFall;
byte chaffTimer;
short Vehicle;
short ExtraAnim;
bool mineL;
bool mineR;
CarriedWeaponInfo Weapons[NUM_WEAPONS];
DiaryInfo Diary;
WaterskinInfo Waterskin1;
WaterskinInfo Waterskin2;
RendererMesh* MeshesPointers[15];
int Puzzles[NUM_PUZZLES];
int Keys[NUM_KEYS];
int Pickups[NUM_PICKUPS];
int Examines[NUM_EXAMINES];
int PuzzlesCombo[NUM_PUZZLES * 2];
int KeysCombo[NUM_KEYS * 2];
int PickupsCombo[NUM_PICKUPS * 2];
int ExaminesCombo[NUM_EXAMINES * 2];
int Secrets;
bool Lasersight;
bool Crowbar;
bool Torch;
bool Silencer;
bool Binoculars;
int NumSmallMedipacks;
int NumLargeMedipacks;
int NumFlares;
};
extern LaraInfo Lara; extern LaraInfo Lara;
extern ITEM_INFO* LaraItem; extern ITEM_INFO* LaraItem;
extern byte LaraNodeUnderwater[15]; extern byte LaraNodeUnderwater[NUM_LARA_MESHES];
extern void(*lara_control_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll); #define LARA_MESHES(slot, mesh) Lara.meshPtrs[mesh] = MESHES(slot, mesh)
extern void(*lara_collision_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll); #define CHECK_LARA_MESHES(slot, mesh) Lara.meshPtrs[mesh] == MESHES(slot, mesh)
#define INIT_LARA_MESHES(mesh, to, from) Lara.meshPtrs[mesh] = LARA_MESHES(to, mesh) = LARA_MESHES(from, mesh)
#define LaraRoutineFunction void(ITEM_INFO* item, COLL_INFO* coll)
extern function<LaraRoutineFunction> lara_control_routines[NUM_LARA_STATES + 1];
extern function<LaraRoutineFunction> lara_collision_routines[NUM_LARA_STATES + 1];
///extern function<LaraRoutineFunction> lara_camera_routines[NUM_LARA_STATES + 1];
void lara_as_pbleapoff(ITEM_INFO* item, COLL_INFO* coll); void lara_as_pbleapoff(ITEM_INFO* item, COLL_INFO* coll);
void lara_as_parallelbars(ITEM_INFO* item, COLL_INFO* coll); void lara_as_parallelbars(ITEM_INFO* item, COLL_INFO* coll);

View file

@ -1,11 +1,12 @@
#include "framework.h"
#include "lara1gun.h" #include "lara1gun.h"
#include "items.h" #include "items.h"
#include "Lara.h" #include "Lara.h"
#include "larafire.h" #include "larafire.h"
#include "draw.h" #include "draw.h"
#include "Box.h" #include "box.h"
#include "control.h" #include "control.h"
#include "effects.h" #include "effect.h"
#include "effect2.h" #include "effect2.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "lot.h" #include "lot.h"
@ -17,15 +18,12 @@
#include "sphere.h" #include "sphere.h"
#include "traps.h" #include "traps.h"
#include "camera.h" #include "camera.h"
#include "GameFlowScript.h"
#include "..\Global\global.h" #include "level.h"
#include "..\Scripting\GameFlowScript.h" #include "setup.h"
#include "..\Specific\level.h" #include "input.h"
#include "../Specific/setup.h"
#include "../Specific/input.h"
#include "savegame.h" #include "savegame.h"
#include "sound.h" #include "sound.h"
#include "bubble.h" #include "bubble.h"
extern GameFlow* g_GameFlow; extern GameFlow* g_GameFlow;
@ -58,7 +56,7 @@ void FireHarpoon()
pos.z = dxPos.z = 77; pos.z = dxPos.z = 77;
g_Renderer->GetLaraBonePosition(&dxPos, LM_RHAND); g_Renderer->GetLaraBonePosition(&dxPos, LM_RHAND);
GetLaraJointPosition((PHD_VECTOR*)&pos, LM_RHAND); GetLaraJointPosition(&PHD_VECTOR(pos.x, pos.y, pos.z), LM_RHAND);
/*item->pos.xPos = pos.x = dxPos.x; /*item->pos.xPos = pos.x = dxPos.x;
item->pos.yPos = pos.y = dxPos.y; item->pos.yPos = pos.y = dxPos.y;
@ -340,6 +338,15 @@ void FireGrenade()
} }
} }
enum GRENADE_TYPE
{
GRENADE_NORMAL,
GRENADE_SUPER,
GRENADE_FLASH,
GRENADE_ULTRA,
GRENADE_FLAGS
};
void ControlGrenade(short itemNumber) void ControlGrenade(short itemNumber)
{ {
ITEM_INFO* item = &Items[itemNumber]; ITEM_INFO* item = &Items[itemNumber];
@ -524,7 +531,7 @@ void ControlGrenade(short itemNumber)
int ceiling; int ceiling;
short roomNumber; short roomNumber;
if (item->itemFlags[0] == WEAPON_AMMO4) if (item->itemFlags[0] == GRENADE_ULTRA)
{ {
roomNumber = item->roomNumber; roomNumber = item->roomNumber;
@ -575,7 +582,7 @@ void ControlGrenade(short itemNumber)
item->hitPoints = 1;*/ item->hitPoints = 1;*/
} }
if (item->itemFlags[0] == WEAPON_AMMO4) if (item->itemFlags[0] == GRENADE_ULTRA)
GrenadeLauncherSpecialEffect1(item->pos.xPos, item->pos.yPos, item->pos.zPos, -1, 1); GrenadeLauncherSpecialEffect1(item->pos.xPos, item->pos.yPos, item->pos.zPos, -1, 1);
// Time to explode? // Time to explode?
@ -600,7 +607,7 @@ void ControlGrenade(short itemNumber)
} }
} }
if (!(item->itemFlags[0] == WEAPON_AMMO3 && explode)) if (!(item->itemFlags[0] == GRENADE_FLASH && explode))
{ {
int n = 0; int n = 0;
bool foundCollidedObjects = false; bool foundCollidedObjects = false;
@ -616,7 +623,7 @@ void ControlGrenade(short itemNumber)
foundCollidedObjects = true; foundCollidedObjects = true;
if (item->itemFlags[0] != WEAPON_AMMO3 || explode) if (item->itemFlags[0] != GRENADE_FLASH || explode)
{ {
if (CollidedItems[0]) if (CollidedItems[0])
{ {
@ -724,9 +731,9 @@ void ControlGrenade(short itemNumber)
} while (n < 2); } while (n < 2);
} }
if (explode || (item->itemFlags[0] == WEAPON_AMMO3 && explode)) if (explode || (item->itemFlags[0] == GRENADE_FLASH && explode))
{ {
if (item->itemFlags[0] == WEAPON_AMMO3) if (item->itemFlags[0] == GRENADE_FLASH)
{ {
FlashFader = 32; FlashFader = 32;
FlashFadeR = 255; FlashFadeR = 255;
@ -762,10 +769,10 @@ void ControlGrenade(short itemNumber)
SoundEffect(105, &item->pos, PITCH_SHIFT | 0x1800000); SoundEffect(105, &item->pos, PITCH_SHIFT | 0x1800000);
SoundEffect(106, &item->pos, 0); SoundEffect(106, &item->pos, 0);
if (item->itemFlags[0] != WEAPON_AMMO1 && item->itemFlags[0] != 4) if (item->itemFlags[0] != GRENADE_NORMAL && item->itemFlags[0] != 4)
{ {
item->meshBits = 0; item->meshBits = 0;
item->itemFlags[1] = (item->itemFlags[0] != WEAPON_AMMO2 ? 16 : 4); item->itemFlags[1] = (item->itemFlags[0] != GRENADE_SUPER ? 16 : 4);
return; return;
} }
@ -1063,6 +1070,13 @@ void AnimateShotgun(int weaponType)
Lara.leftArm.animNumber = Lara.rightArm.animNumber = item->animNumber; Lara.leftArm.animNumber = Lara.rightArm.animNumber = item->animNumber;
} }
enum CROSSBOW_TYPE
{
CROSSBOW_NORMAL,
CROSSBOW_POISON,
CROSSBOW_EXPLODE
};
void ControlCrossbowBolt(short itemNumber) void ControlCrossbowBolt(short itemNumber)
{ {
ITEM_INFO* item = &Items[itemNumber]; ITEM_INFO* item = &Items[itemNumber];
@ -1080,7 +1094,7 @@ void ControlCrossbowBolt(short itemNumber)
if (item->speed > 64) if (item->speed > 64)
item->speed -= (item->speed >> 4); item->speed -= (item->speed >> 4);
if (GlobalCounter & 1) if (GlobalCounter & 1)
CreateBubble((PHD_VECTOR*)&item->pos, roomNumber, 4, 7, 0, 0, 0, 0); CreateBubble(&PHD_VECTOR(item->pos.xPos, item->pos.yPos, item->pos.zPos), roomNumber, 4, 7, 0, 0, 0, 0);
} }
else else
{ {
@ -1103,15 +1117,17 @@ void ControlCrossbowBolt(short itemNumber)
item->pos.zPos = oldZ; item->pos.zPos = oldZ;
// If ammos are normal, then just shatter the bolt and quit // If ammos are normal, then just shatter the bolt and quit
if (item->itemFlags[0] != WEAPON_AMMO3) if (item->itemFlags[0] != CROSSBOW_EXPLODE)
{ {
ExplodeItemNode(item, 0, 0, 256); ExplodeItemNode(item, 0, 0, EXPLODE_NORMAL);
KillItem(itemNumber); KillItem(itemNumber);
return; return;
} }
else
// Otherwise, bolt must explode {
explode = true; // Otherwise, bolt must explode
explode = true;
}
} }
// Has bolt changed room? // Has bolt changed room?
@ -1140,7 +1156,7 @@ void ControlCrossbowBolt(short itemNumber)
foundCollidedObjects = true; foundCollidedObjects = true;
if (item->itemFlags[0] != WEAPON_AMMO3 || explode) if (item->itemFlags[0] != CROSSBOW_EXPLODE || explode)
{ {
if (CollidedItems[0]) if (CollidedItems[0])
{ {
@ -1155,16 +1171,14 @@ void ControlCrossbowBolt(short itemNumber)
if (item->objectNumber < ID_SMASH_OBJECT1 || item->objectNumber > ID_SMASH_OBJECT8) if (item->objectNumber < ID_SMASH_OBJECT1 || item->objectNumber > ID_SMASH_OBJECT8)
{ {
if (currentItem->objectNumber == ID_SHOOT_SWITCH1 || currentItem->objectNumber == ID_SHOOT_SWITCH2) if (currentItem->objectNumber == ID_SHOOT_SWITCH1 || currentItem->objectNumber == ID_SHOOT_SWITCH2)
CrossbowHitSwitchType78(item, currentItem, 0); DoCrossbowDamage(item, currentItem, 0);
else if (Objects[item->objectNumber].hitEffect) else if (Objects[item->objectNumber].hitEffect)
DoGrenadeDamageOnBaddie(currentItem, item); DoGrenadeDamageOnBaddie(currentItem, item);
} }
else else
{ {
TriggerExplosionSparks(currentItem->pos.xPos, currentItem->pos.yPos, currentItem->pos.zPos, 3, -2, 0, currentItem->roomNumber); TriggerExplosionSparks(currentItem->pos.xPos, currentItem->pos.yPos, currentItem->pos.zPos, 3, -2, 0, currentItem->roomNumber);
currentItem->pos.yPos -= 128; TriggerShockwave(&PHD_3DPOS(currentItem->pos.xPos, currentItem->pos.yPos - 128, currentItem->pos.zPos), 48, 304, 96, 0, 96, 128, 24, 0, 0);
TriggerShockwave(&currentItem->pos, 48, 304, 96, 0, 96, 128, 24, 0, 0);
currentItem->pos.yPos += 128;
ExplodeItemNode(currentItem, 0, 0, 128); ExplodeItemNode(currentItem, 0, 0, 128);
short currentItemNumber = (currentItem - CollidedItems[0]); short currentItemNumber = (currentItem - CollidedItems[0]);
SmashObject(currentItemNumber); SmashObject(currentItemNumber);
@ -1174,14 +1188,14 @@ void ControlCrossbowBolt(short itemNumber)
else if (currentItem->objectNumber == ID_SHOOT_SWITCH1 || currentItem->objectNumber == ID_SHOOT_SWITCH2) else if (currentItem->objectNumber == ID_SHOOT_SWITCH1 || currentItem->objectNumber == ID_SHOOT_SWITCH2)
{ {
// Special case for ID_SWITCH_TYPE7 and ID_SWITCH_TYPE8 // Special case for ID_SWITCH_TYPE7 and ID_SWITCH_TYPE8
CrossbowHitSwitchType78(item, currentItem, 1); DoCrossbowDamage(item, currentItem, 1);
} }
else if (Objects[currentItem->objectNumber].hitEffect) else if (Objects[currentItem->objectNumber].hitEffect)
{ {
HitTarget(currentItem, (GAME_VECTOR*)&item->pos, Weapons[WEAPON_CROSSBOW].damage, 0); HitTarget(currentItem, &GAME_VECTOR(item->pos.xPos, item->pos.yPos, item->pos.zPos), Weapons[WEAPON_CROSSBOW].damage, 0);
// Poisoned ammos // Poisoned ammos
if (item->itemFlags[0] == WEAPON_AMMO2 && !Objects[currentItem->objectNumber].explodableMeshbits) if (item->itemFlags[0] == CROSSBOW_POISON && !Objects[currentItem->objectNumber].explodableMeshbits)
item->poisoned = true; item->poisoned = true;
} }
@ -1198,16 +1212,14 @@ void ControlCrossbowBolt(short itemNumber)
do do
{ {
if (currentMesh->staticNumber >= 50 && currentMesh->staticNumber < 58) if (currentMesh->staticNumber >= 50 && currentMesh->staticNumber < 58) // SHATTER
{ {
if (explode) if (explode)
{ {
TriggerExplosionSparks(currentMesh->x, currentMesh->y, currentMesh->z, 3, -2, 0, item->roomNumber); TriggerExplosionSparks(currentMesh->x, currentMesh->y, currentMesh->z, 3, -2, 0, item->roomNumber);
currentMesh->y -= 128; TriggerShockwave(&PHD_3DPOS(currentMesh->x, currentMesh->y - 128, currentMesh->z, 0, currentMesh->yRot, 0), 40, 176, 64, 0, 96, 128, 16, 0, 0);
TriggerShockwave((PHD_3DPOS*)&currentMesh, 40, 176, 64, 0, 96, 128, 16, 0, 0);
currentMesh->y += 128;
} }
ShatterObject((SHATTER_ITEM*)item, NULL, -128, item->roomNumber, 0); ShatterObject((SHATTER_ITEM*)item, NULL, -128, item->roomNumber, 0); // TODO: this wont work !!
SmashedMeshRoom[SmashedMeshCount] = item->roomNumber; SmashedMeshRoom[SmashedMeshCount] = item->roomNumber;
SmashedMesh[SmashedMeshCount] = currentMesh; SmashedMesh[SmashedMeshCount] = currentMesh;
SmashedMeshCount++; SmashedMeshCount++;
@ -1232,16 +1244,17 @@ void ControlCrossbowBolt(short itemNumber)
{ {
if (foundCollidedObjects) if (foundCollidedObjects)
{ {
ExplodeItemNode(item, 0, 0, 256); ExplodeItemNode(item, 0, 0, EXPLODE_NORMAL);
KillItem(itemNumber); KillItem(itemNumber);
} }
return; return;
} }
// At this point, for sure bolt must explode // At this point, for sure bolt must explode
if (Rooms[item->roomNumber].flags & ENV_FLAG_WATER) if (Rooms[item->roomNumber].flags & ENV_FLAG_WATER)
{
TriggerUnderwaterExplosion(item); TriggerUnderwaterExplosion(item);
}
else else
{ {
TriggerShockwave(&item->pos, 48, 304, 96, 0, 96, 128, 24, 0, 0); TriggerShockwave(&item->pos, 48, 304, 96, 0, 96, 128, 24, 0, 0);
@ -1253,12 +1266,12 @@ void ControlCrossbowBolt(short itemNumber)
AlertNearbyGuards(item); AlertNearbyGuards(item);
SoundEffect(105, &item->pos, PITCH_SHIFT | 0x1800000); SoundEffect(SFX_EXPLOSION1, &item->pos, PITCH_SHIFT | 0x1800000);
SoundEffect(106, &item->pos, 0); SoundEffect(SFX_EXPLOSION2, &item->pos, 0);
if (foundCollidedObjects || explode) if (foundCollidedObjects || explode)
{ {
ExplodeItemNode(item, 0, 0, 256); ExplodeItemNode(item, 0, 0, EXPLODE_NORMAL);
KillItem(itemNumber); KillItem(itemNumber);
} }
@ -1477,12 +1490,12 @@ void undraw_shotgun(int weapon)
AnimateItem(item); AnimateItem(item);
if (item->status == ITEM_DEACTIVATED) if (item->status == ITEM_DESACTIVATED)
{ {
Lara.gunStatus = LG_NO_ARMS; Lara.gunStatus = LG_NO_ARMS;
Lara.target = NULL; Lara.target = NULL;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
KillItem(Lara.weaponItem); KillItem(Lara.weaponItem);
@ -1515,7 +1528,7 @@ void draw_shotgun_meshes(int weaponType)
LARA_MESHES(WeaponObjectMesh(weaponType), LM_RHAND); LARA_MESHES(WeaponObjectMesh(weaponType), LM_RHAND);
} }
void CrossbowHitSwitchType78(ITEM_INFO* item1, ITEM_INFO* item2, signed int search) void DoCrossbowDamage(ITEM_INFO* item1, ITEM_INFO* item2, signed int search)
{ {
/*v4 = item2; /*v4 = item2;
if (!(item2->flags & 0x40)) if (!(item2->flags & 0x40))
@ -1675,10 +1688,10 @@ void FireShotgun()
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
loopAngles[0] = angles[0] + value * (GetRandomControl() - ANGLE(90)) / 0x10000; loopAngles[0] = angles[0] + value * (GetRandomControl() - 0x4000) / 0x10000;
loopAngles[1] = angles[1] + value * (GetRandomControl() - ANGLE(90)) / 0x10000; loopAngles[1] = angles[1] + value * (GetRandomControl() - 0x4000) / 0x10000;
if (FireWeapon(WEAPON_SHOTGUN, Lara.target, LaraItem, loopAngles)) if (FireWeapon(WEAPON_SHOTGUN, Lara.target, LaraItem, loopAngles) == FW_MAYBEHIT)
fired = true; fired = true;
} }
@ -1707,12 +1720,10 @@ void FireShotgun()
SmokeCountL = 32; SmokeCountL = 32;
SmokeWeapon = WEAPON_SHOTGUN; SmokeWeapon = WEAPON_SHOTGUN;
if (LaraItem->meshBits) if (LaraItem->meshBits != 0)
{ {
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
{ TriggerGunSmoke(pos2.x, pos2.y, pos2.z, pos.x - pos2.x, pos.y - pos2.y, pos.z - pos2.z, 1, SmokeWeapon, SmokeCountL);
TriggerGunSmoke(pos2.x, pos2.y, pos2.z, pos.x - pos2.x, pos.y - pos2.y, pos.z - pos2.z, 1, SmokeWeapon, 32);
}
} }
Lara.rightArm.flash_gun = Weapons[WEAPON_SHOTGUN].flashTime; Lara.rightArm.flash_gun = Weapons[WEAPON_SHOTGUN].flashTime;

View file

@ -1,26 +1,24 @@
#pragma once #pragma once
#include "items.h"
#include "trmath.h"
#include "..\Global\global.h" #define PELLET_SCATTER ANGLE(20.0f)
constexpr auto HARPOON_DRAW_ANIM = 1;
#define HARPOON_DRAW_ANIM 1 constexpr auto ROCKET_DRAW_ANIM = 0;
#define ROCKET_DRAW_ANIM 0 constexpr auto HARPOON_SPEED = 256;
constexpr auto HARPOON_TIME = 256;
#define PELLET_SCATTER ANGLE(20) constexpr auto ROCKET_SPEED = 512;
#define HARPOON_SPEED 256 constexpr auto GRENADE_SPEED = 128;
#define HARPOON_TIME 256 constexpr auto MAX_GRENADE_FALLSPEED = 128;
#define ROCKET_SPEED 512 constexpr auto GRENADE_YOFF = 180;
#define GRENADE_SPEED 128 constexpr auto GRENADE_ZOFF = 80;
#define MAX_GRENADE_FALLSPEED 128 constexpr auto CROSSBOW_DAMAGE = 5;
#define GRENADE_YOFF 180 constexpr auto CROSSBOW_AMMO1 = 1;
#define GRENADE_ZOFF 80 constexpr auto CROSSBOW_AMMO2 = 2;
#define GRENADE_BLAST_RADIUS (WALL_SIZE * 2) constexpr auto CROSSBOW_AMMO3 = 2;
#define CROSSBOW_DAMAGE 5 constexpr auto CROSSBOW_HIT_RADIUS = 128;
#define CROSSBOW_AMMO1 1 constexpr auto CROSSBOW_EXPLODE_RADIUS = SECTOR(2);
#define CROSSBOW_AMMO2 2 constexpr auto GRENADE_EXPLODE_RADIUS = SECTOR(2);
#define CROSSBOW_AMMO3 2
#define CROSSBOW_HIT_RADIUS 128
#define CROSSBOW_EXPLODE_RADIUS 2048
#define GRENADE_EXPLODE_RADIUS 2048
void FireGrenade(); void FireGrenade();
void ControlGrenade(short itemNumber); void ControlGrenade(short itemNumber);
@ -39,5 +37,5 @@ void undraw_shotgun(int weapon);
void draw_shotgun_meshes(int weaponType); void draw_shotgun_meshes(int weaponType);
void FireHK(int mode); void FireHK(int mode);
void FireShotgun(); void FireShotgun();
void CrossbowHitSwitchType78(ITEM_INFO* item1, ITEM_INFO* item2, signed int search); void DoCrossbowDamage(ITEM_INFO* item1, ITEM_INFO* item2, signed int search);
void ready_shotgun(int weaponType); void ready_shotgun(int weaponType);

View file

@ -1,17 +1,25 @@
#include "framework.h"
#include "lara2gun.h" #include "lara2gun.h"
#include "..\Global\global.h"
#include "larafire.h" #include "larafire.h"
#include "lara.h" #include "lara.h"
#include "effect2.h" #include "effect2.h"
#include "draw.h" #include "draw.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "..\Specific\level.h" #include "level.h"
#include "..\Specific\setup.h" #include "setup.h"
#include "camera.h" #include "camera.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
#include "savegame.h" #include "savegame.h"
struct PISTOL_DEF
{
short objectNum;
char draw1Anim2;
char draw1Anim;
char draw2Anim;
char recoilAnim;
};
PISTOL_DEF PistolsTable[4] = PISTOL_DEF PistolsTable[4] =
{ {
{ ID_LARA, 0, 0, 0, 0 }, { ID_LARA, 0, 0, 0, 0 },
@ -56,7 +64,7 @@ void AnimatePistols(int weaponType)
} }
GetLaraJointPosition(&pos, LM_LHAND); GetLaraJointPosition(&pos, LM_LHAND);
TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, (byte)0, SmokeWeapon, SmokeCountL); TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 0, SmokeWeapon, SmokeCountL);
} }
if (SmokeCountR) if (SmokeCountR)
@ -83,7 +91,7 @@ void AnimatePistols(int weaponType)
} }
GetLaraJointPosition(&pos, LM_RHAND); GetLaraJointPosition(&pos, LM_RHAND);
TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, (byte)0, SmokeWeapon, SmokeCountR); TriggerGunSmoke(pos.x, pos.y, pos.z, 0, 0, 0, 0, SmokeWeapon, SmokeCountR);
} }
} }
@ -103,7 +111,7 @@ void AnimatePistols(int weaponType)
angleRight[0] = Lara.rightArm.yRot + LaraItem->pos.yRot; angleRight[0] = Lara.rightArm.yRot + LaraItem->pos.yRot;
angleRight[1] = Lara.rightArm.xRot; angleRight[1] = Lara.rightArm.xRot;
if (FireWeapon(weaponType, Lara.target, LaraItem, angleRight)) if (FireWeapon(weaponType, Lara.target, LaraItem, angleRight) != FW_NOAMMO)
{ {
SmokeCountR = 28; SmokeCountR = 28;
SmokeWeapon = weaponType; SmokeWeapon = weaponType;
@ -173,7 +181,7 @@ void AnimatePistols(int weaponType)
angleLeft[0] = Lara.leftArm.yRot + LaraItem->pos.yRot; angleLeft[0] = Lara.leftArm.yRot + LaraItem->pos.yRot;
angleLeft[1] = Lara.leftArm.xRot; angleLeft[1] = Lara.leftArm.xRot;
if (FireWeapon(weaponType, Lara.target, LaraItem, angleLeft)) if (FireWeapon(weaponType, Lara.target, LaraItem, angleLeft) != FW_NOAMMO)
{ {
if (weaponType == WEAPON_REVOLVER) if (weaponType == WEAPON_REVOLVER)
{ {
@ -367,8 +375,8 @@ void ready_pistols(int weaponType)
Lara.rightArm.frameNumber = 0; Lara.rightArm.frameNumber = 0;
Lara.leftArm.frameNumber = 0; Lara.leftArm.frameNumber = 0;
Lara.target = NULL; Lara.target = NULL;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.rightArm.frameBase = Objects[WeaponObject(weaponType)].frameBase; Lara.rightArm.frameBase = Objects[WeaponObject(weaponType)].frameBase;
Lara.leftArm.frameBase = Objects[WeaponObject(weaponType)].frameBase; Lara.leftArm.frameBase = Objects[WeaponObject(weaponType)].frameBase;
} }
@ -443,8 +451,8 @@ void undraw_pistols(int weaponType)
Lara.leftArm.frameNumber = 0; Lara.leftArm.frameNumber = 0;
Lara.rightArm.frameNumber = 0; Lara.rightArm.frameNumber = 0;
Lara.target = NULL; Lara.target = NULL;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
} }
if (!(TrInput & IN_LOOK)) if (!(TrInput & IN_LOOK))

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "lara_struct.h"
void AnimatePistols(int weaponType); void AnimatePistols(int weaponType);
void PistolHandler(int weaponType); void PistolHandler(int weaponType);

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,13 @@
#include "framework.h"
#include "laraclmb.h" #include "laraclmb.h"
#include "..\Global\global.h"
#include "Lara.h" #include "Lara.h"
#include "control.h" #include "control.h"
#include "draw.h" #include "draw.h"
#include "sphere.h" #include "sphere.h"
#include "laramisc.h" #include "laramisc.h"
#include "camera.h" #include "camera.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
short LeftIntRightExtTab[4] = // offset 0xA0B7C short LeftIntRightExtTab[4] = // offset 0xA0B7C
{ {

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "items.h"
#include "collide.h"
short GetClimbTrigger(int x, int y, int z, short roomNumber); short GetClimbTrigger(int x, int y, int z, short roomNumber);
void lara_col_climbend(ITEM_INFO* item, COLL_INFO* coll); void lara_col_climbend(ITEM_INFO* item, COLL_INFO* coll);

View file

@ -1,25 +1,23 @@
#include "framework.h"
#include "larafire.h" #include "larafire.h"
#include "items.h" #include "items.h"
#include "Lara.h"
#include "laraflar.h" #include "laraflar.h"
#include "lara1gun.h" #include "lara1gun.h"
#include "lara2gun.h" #include "lara2gun.h"
#include "camera.h" #include "camera.h"
#include "..\Scripting\GameFlowScript.h"
#include <stdio.h>
#include "objects.h" #include "objects.h"
#include "effects.h" #include "effect.h"
#include "sphere.h" #include "sphere.h"
#include "draw.h" #include "draw.h"
#include "effect2.h" #include "effect2.h"
#include "flmtorch.h" #include "flmtorch.h"
#include "..\Specific\level.h" #include "level.h"
#include "lot.h" #include "lot.h"
#include "../Specific/setup.h" #include "setup.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
#include "savegame.h" #include "savegame.h"
#include "GameFlowScript.h"
WEAPON_INFO Weapons[NUM_WEAPONS] = WEAPON_INFO Weapons[NUM_WEAPONS] =
{ {
@ -318,9 +316,7 @@ void SmashItem(short itemNum) // (F) (D)
{ {
ITEM_INFO* item = &Items[itemNum]; ITEM_INFO* item = &Items[itemNum];
if (item->objectNumber >= ID_SMASH_OBJECT1 && item->objectNumber <= ID_SMASH_OBJECT8) if (item->objectNumber >= ID_SMASH_OBJECT1 && item->objectNumber <= ID_SMASH_OBJECT8)
{
SmashObject(itemNum); SmashObject(itemNum);
}
} }
void LaraGun() // (F) (D) void LaraGun() // (F) (D)
@ -697,7 +693,7 @@ void HitTarget(ITEM_INFO* item, GAME_VECTOR* hitPos, int damage, int flag)
if (creature && item != LaraItem) if (creature && item != LaraItem)
creature->hurtByLara = true; creature->hurtByLara = true;
if (hitPos) if (hitPos != nullptr)
{ {
if (obj->hitEffect) if (obj->hitEffect)
{ {
@ -716,7 +712,8 @@ void HitTarget(ITEM_INFO* item, GAME_VECTOR* hitPos, int damage, int flag)
} }
} }
} }
if (!obj->undead || flag || item->hitPoints == -16384)
if (!obj->undead || flag || item->hitPoints == NOT_TARGETABLE)
{ {
if (item->hitPoints > 0 && item->hitPoints <= damage) if (item->hitPoints > 0 && item->hitPoints <= damage)
++Savegame.Level.Kills; ++Savegame.Level.Kills;
@ -724,50 +721,42 @@ void HitTarget(ITEM_INFO* item, GAME_VECTOR* hitPos, int damage, int flag)
} }
} }
int DetectCrouchWhenFiring(ITEM_INFO* src, WEAPON_INFO* weapon) FIREWEAPON_TYPE FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) // (F) (D)
{
if (src->currentAnimState == STATE_LARA_CROUCH_IDLE || src->currentAnimState == STATE_LARA_CROUCH_TURN_LEFT || src->currentAnimState == STATE_LARA_CROUCH_TURN_RIGHT)
return STEP_SIZE;
else
return int(weapon->gunHeight);
}
int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles) // (F) (D)
{ {
short* ammo = GetAmmo(weaponType); short* ammo = GetAmmo(weaponType);
if (!*ammo) if (!*ammo)
return 0; return FW_NOAMMO;
if (*ammo != -1) if (*ammo != -1)
(*ammo)--; (*ammo)--;
WEAPON_INFO* weapon = &Weapons[weaponType]; WEAPON_INFO* weapon = &Weapons[weaponType];
int r; int r;
PHD_3DPOS pos; PHD_VECTOR pos;
pos.xPos = 0; pos.x = 0;
pos.yPos = 0; pos.y = 0;
pos.zPos = 0; pos.z = 0;
GetLaraJointPosition((PHD_VECTOR*)&pos, LM_RHAND); GetLaraJointPosition(&pos, LM_RHAND);
pos.xPos = src->pos.xPos; pos.x = src->pos.xPos;
pos.zPos = src->pos.zPos; pos.z = src->pos.zPos;
PHD_3DPOS rotation;
pos.xRot = angles[1] + (GetRandomControl() - 16384) * weapon->shotAccuracy / 65536; rotation.xRot = angles[1] + (GetRandomControl() - 0x4000) * weapon->shotAccuracy / 0x10000;
pos.yRot = angles[0] + (GetRandomControl() - 16384) * weapon->shotAccuracy / 65536; rotation.yRot = angles[0] + (GetRandomControl() - 0x4000) * weapon->shotAccuracy / 0x10000;
pos.zRot = 0; rotation.zRot = 0;
// Calculate ray from rotation angles // Calculate ray from rotation angles
float x = sin(TO_RAD(pos.yRot)) * cos(TO_RAD(pos.xRot)); float x = sin(TO_RAD(rotation.yRot)) * cos(TO_RAD(rotation.xRot));
float y = -sin(TO_RAD(pos.xRot)); float y = -sin(TO_RAD(rotation.xRot));
float z = cos(TO_RAD(pos.yRot)) * cos(TO_RAD(pos.xRot)); float z = cos(TO_RAD(rotation.yRot)) * cos(TO_RAD(rotation.xRot));
Vector3 direction = Vector3(x, y, z); Vector3 direction = Vector3(x, y, z);
direction.Normalize(); direction.Normalize();
Vector3 source = Vector3(pos.xPos, pos.yPos, pos.zPos); Vector3 source = Vector3(pos.x, pos.y, pos.z);
Vector3 destination = source + direction * 1024.0f; Vector3 destination = source + direction * float(weapon->targetDist);
Ray ray = Ray(source, direction); Ray ray = Ray(source, direction);
int num = GetSpheres(target, CreatureSpheres, SPHERES_SPACE_WORLD, Matrix::Identity); int num = GetSpheres(target, CreatureSpheres, SPHERES_SPACE_WORLD, Matrix::Identity);
int best = -1; int best = NO_ITEM;
float bestDistance = FLT_MAX; float bestDistance = FLT_MAX;
for (int i = 0; i < num; i++) for (int i = 0; i < num; i++)
@ -788,34 +777,29 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles)
Lara.fired = true; Lara.fired = true;
GAME_VECTOR vSrc; GAME_VECTOR vSrc;
vSrc.x = pos.xPos; vSrc.x = pos.x;
vSrc.y = pos.yPos; vSrc.y = pos.y;
vSrc.z = pos.zPos; vSrc.z = pos.z;
short roomNumber = src->roomNumber; short roomNumber = src->roomNumber;
GetFloor(pos.xPos, pos.yPos, pos.zPos, &roomNumber); GetFloor(pos.x, pos.y, pos.z, &roomNumber);
vSrc.roomNumber = roomNumber; vSrc.roomNumber = roomNumber;
if (best < 0) if (best < 0)
{ {
GAME_VECTOR vDest; GAME_VECTOR vDest;
vDest.x = destination.x; vDest.x = destination.x;
vDest.y = destination.y; vDest.y = destination.y;
vDest.z = destination.z; vDest.z = destination.z;
GetTargetOnLOS(&vSrc, &vDest, FALSE, TRUE);
GetTargetOnLOS(&vSrc, &vDest, 0, 1); return FW_MISS;
return -1;
} }
else else
{ {
Savegame.Game.AmmoHits++; Savegame.Game.AmmoHits++;
GAME_VECTOR vDest;
destination = source + direction * bestDistance; destination = source + direction * bestDistance;
GAME_VECTOR vDest;
vDest.x = destination.x; vDest.x = destination.x;
vDest.y = destination.y; vDest.y = destination.y;
vDest.z = destination.z; vDest.z = destination.z;
@ -858,11 +842,11 @@ int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles)
} }
else else
{*/ {*/
if (!GetTargetOnLOS(&vSrc, &vDest, 0, 1)) if (!GetTargetOnLOS(&vSrc, &vDest, FALSE, TRUE))
HitTarget(target, &vDest, weapon->damage, 0); HitTarget(target, &vDest, weapon->damage, NULL);
//} //}
return 1; return FW_MAYBEHIT;
} }
} }
@ -888,42 +872,43 @@ void LaraTargetInfo(WEAPON_INFO* weapon) // (F) (D)
{ {
if (!Lara.target) if (!Lara.target)
{ {
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.targetAngles[1] = 0; Lara.targetAngles[1] = 0;
Lara.targetAngles[0] = 0; Lara.targetAngles[0] = 0;
return; return;
} }
GAME_VECTOR pos; PHD_VECTOR pos;
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
pos.z = 0; pos.z = 0;
GetLaraJointPosition((PHD_VECTOR*)&pos, LM_RHAND); GetLaraJointPosition(&pos, LM_RHAND);
pos.x = LaraItem->pos.xPos; GAME_VECTOR src;
pos.z = LaraItem->pos.zPos; src.x = LaraItem->pos.xPos;
pos.roomNumber = LaraItem->roomNumber; src.y = pos.y;
src.z = LaraItem->pos.zPos;
src.roomNumber = LaraItem->roomNumber;
GAME_VECTOR targetPoint; GAME_VECTOR targetPoint;
find_target_point(Lara.target, &targetPoint); find_target_point(Lara.target, &targetPoint);
short angles[2]; short angles[2];
phd_GetVectorAngles(targetPoint.x - pos.x, targetPoint.y - pos.y, targetPoint.z - pos.z, angles); phd_GetVectorAngles(targetPoint.x - src.x, targetPoint.y - src.y, targetPoint.z - src.z, angles);
angles[0] -= LaraItem->pos.yRot; angles[0] -= LaraItem->pos.yRot;
angles[1] -= LaraItem->pos.xRot; angles[1] -= LaraItem->pos.xRot;
if (LOS(&pos, &targetPoint)) if (LOS(&src, &targetPoint))
{ {
if (angles[0] >= weapon->lockAngles[0] if (angles[0] >= weapon->lockAngles[0]
&& angles[0] <= weapon->lockAngles[1] && angles[0] <= weapon->lockAngles[1]
&& angles[1] >= weapon->lockAngles[2] && angles[1] >= weapon->lockAngles[2]
&& angles[1] <= weapon->lockAngles[3]) && angles[1] <= weapon->lockAngles[3])
{ {
Lara.rightArm.lock = 1; Lara.rightArm.lock = true;
Lara.leftArm.lock = 1; Lara.leftArm.lock = true;
} }
else else
{ {
@ -933,7 +918,7 @@ void LaraTargetInfo(WEAPON_INFO* weapon) // (F) (D)
angles[0] > weapon->leftAngles[1] || angles[0] > weapon->leftAngles[1] ||
angles[1] < weapon->leftAngles[2] || angles[1] < weapon->leftAngles[2] ||
angles[1] > weapon->leftAngles[3])) angles[1] > weapon->leftAngles[3]))
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
} }
if (Lara.rightArm.lock) if (Lara.rightArm.lock)
@ -942,37 +927,36 @@ void LaraTargetInfo(WEAPON_INFO* weapon) // (F) (D)
angles[0] > weapon->rightAngles[1] || angles[0] > weapon->rightAngles[1] ||
angles[1] < weapon->rightAngles[2] || angles[1] < weapon->rightAngles[2] ||
angles[1] > weapon->rightAngles[3])) angles[1] > weapon->rightAngles[3]))
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
} }
} }
} }
else else
{ {
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
} }
Lara.targetAngles[0] = angles[0]; Lara.targetAngles[0] = angles[0];
Lara.targetAngles[1] = angles[1]; Lara.targetAngles[1] = angles[1];
} }
int CheckForHoldingState(int state) // (F) (D) bool CheckForHoldingState(int state) // (F) (D)
{ {
short* holdState = HoldStates;
#if 0 #if 0
if (Lara.ExtraAnim) if (Lara.ExtraAnim != NO_ITEM)
return 0; return false;
#endif #endif
short* holdState = HoldStates;
while (*holdState >= 0) while (*holdState >= 0)
{ {
if (state == *holdState) if (state == *holdState)
return 1; return true;
holdState++; holdState++;
} }
return 0; return false;
} }
void LaraGetNewTarget(WEAPON_INFO* winfo) // (F) (D) void LaraGetNewTarget(WEAPON_INFO* winfo) // (F) (D)
@ -989,10 +973,15 @@ void LaraGetNewTarget(WEAPON_INFO* winfo) // (F) (D)
return; return;
} }
bestItem = NULL; bestItem = NULL;
bestYrot = 0x7FFF; bestYrot = MAXSHORT;
bestDistance = 0x7FFFFFFF; bestDistance = MAXINT;
PHD_VECTOR handpos;
handpos.x = 0;
handpos.y = 0;
handpos.z = 0;
GetLaraJointPosition(&handpos, LM_RHAND);
source.x = LaraItem->pos.xPos; source.x = LaraItem->pos.xPos;
source.y = LaraItem->pos.yPos - 650; source.y = LaraItem->pos.yPos - handpos.y;
source.z = LaraItem->pos.zPos; source.z = LaraItem->pos.zPos;
source.roomNumber = LaraItem->roomNumber; source.roomNumber = LaraItem->roomNumber;
maxDistance = winfo->targetDist; maxDistance = winfo->targetDist;
@ -1035,6 +1024,7 @@ void LaraGetNewTarget(WEAPON_INFO* winfo) // (F) (D)
} }
} }
} }
TargetList[targets] = NULL; TargetList[targets] = NULL;
if (!TargetList[0]) if (!TargetList[0])
{ {
@ -1087,12 +1077,14 @@ void LaraGetNewTarget(WEAPON_INFO* winfo) // (F) (D)
} }
} }
} }
if (Lara.target != LastTargets[0]) if (Lara.target != LastTargets[0])
{ {
for (slot = 7; slot > 0; --slot) for (slot = 7; slot > 0; --slot)
LastTargets[slot] = LastTargets[slot - 1]; LastTargets[slot] = LastTargets[slot - 1];
LastTargets[0] = Lara.target; LastTargets[0] = Lara.target;
} }
LaraTargetInfo(winfo); LaraTargetInfo(winfo);
} }

View file

@ -1,7 +1,28 @@
#pragma once #pragma once
#include "lara.h"
#include "..\Global\global.h" typedef enum FIREWEAPON_TYPE
{
FW_MISS = -1,
FW_NOAMMO = 0,
FW_MAYBEHIT = 1
};
typedef struct WEAPON_INFO
{
short lockAngles[4];
short leftAngles[4];
short rightAngles[4];
short aimSpeed;
short shotAccuracy;
short gunHeight;
short targetDist;
byte damage;
byte recoilFrame;
byte flashTime;
byte drawFrame;
short sampleNum;
};
extern WEAPON_INFO Weapons[NUM_WEAPONS]; extern WEAPON_INFO Weapons[NUM_WEAPONS];
void SmashItem(short itemNum); void SmashItem(short itemNum);
@ -12,9 +33,9 @@ void InitialiseNewWeapon();
int WeaponObjectMesh(int weaponType); int WeaponObjectMesh(int weaponType);
void AimWeapon(WEAPON_INFO* winfo, LARA_ARM* arm); void AimWeapon(WEAPON_INFO* winfo, LARA_ARM* arm);
void HitTarget(ITEM_INFO* item, GAME_VECTOR* hitPos, int damage, int flag); void HitTarget(ITEM_INFO* item, GAME_VECTOR* hitPos, int damage, int flag);
int FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles); FIREWEAPON_TYPE FireWeapon(int weaponType, ITEM_INFO* target, ITEM_INFO* src, short* angles);
void find_target_point(ITEM_INFO* item, GAME_VECTOR* target); void find_target_point(ITEM_INFO* item, GAME_VECTOR* target);
void LaraTargetInfo(WEAPON_INFO* weapon); void LaraTargetInfo(WEAPON_INFO* weapon);
int CheckForHoldingState(int state); bool CheckForHoldingState(int state);
void LaraGetNewTarget(WEAPON_INFO* winfo); void LaraGetNewTarget(WEAPON_INFO* winfo);
void DoProperDetection(short itemNumber, int x, int y, int z, int xv, int yv, int zv); void DoProperDetection(short itemNumber, int x, int y, int z, int xv, int yv, int zv);

View file

@ -1,10 +1,8 @@
#include "framework.h"
#include "laraflar.h" #include "laraflar.h"
#include "level.h"
#include "..\Global\global.h" #include "setup.h"
#include "..\Specific\level.h"
#include "..\Specific\setup.h"
#include "sound.h" #include "sound.h"
#include "draw.h" #include "draw.h"
#include "items.h" #include "items.h"
#include "sphere.h" #include "sphere.h"
@ -90,8 +88,8 @@ void ready_flare() // (F) (D)
Lara.rightArm.zRot = 0; Lara.rightArm.zRot = 0;
Lara.rightArm.yRot = 0; Lara.rightArm.yRot = 0;
Lara.rightArm.xRot = 0; Lara.rightArm.xRot = 0;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.target = NULL; Lara.target = NULL;
} }
@ -140,8 +138,8 @@ void undraw_flare() // (F) (D)
InitialiseNewWeapon(); InitialiseNewWeapon();
Lara.target = NULL; Lara.target = NULL;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
LaraItem->animNumber = ANIMATION_LARA_STAY_SOLID; LaraItem->animNumber = ANIMATION_LARA_STAY_SOLID;
Lara.flareFrame = Anims[LaraItem->animNumber].frameBase; Lara.flareFrame = Anims[LaraItem->animNumber].frameBase;
LaraItem->frameNumber = Anims[LaraItem->animNumber].frameBase; LaraItem->frameNumber = Anims[LaraItem->animNumber].frameBase;
@ -198,8 +196,8 @@ void undraw_flare() // (F) (D)
Lara.flareControlLeft = false; Lara.flareControlLeft = false;
Lara.target = NULL; Lara.target = NULL;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
Lara.flareFrame = 0; Lara.flareFrame = 0;
} }
else if (frame2 < 21) else if (frame2 < 21)
@ -374,6 +372,11 @@ void CreateFlare(short objectNum, int thrown) // (F) (D)
} }
} }
void DrawFlareInAir(ITEM_INFO* item)
{
printf("DrawFlareInAir() not implemented !");
}
void DoFlareInHand(int flare_age) // (AF) (D) void DoFlareInHand(int flare_age) // (AF) (D)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;

View file

@ -1,5 +1,5 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "items.h"
void FlareControl(short item_number); void FlareControl(short item_number);
void ready_flare(); void ready_flare();

View file

@ -1,23 +1,23 @@
#include "framework.h"
#include "laramisc.h" #include "laramisc.h"
#include "..\Global\global.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/setup.h" #include "setup.h"
#include "..\Scripting\GameFlowScript.h" #include "GameFlowScript.h"
#include "effects.h" #include "effect.h"
#include "collide.h" #include "collide.h"
#include "Lara.h" #include "Lara.h"
#include "laraswim.h" #include "laraswim.h"
#include "larasurf.h" #include "larasurf.h"
#include "effect2.h" #include "effect2.h"
#include "healt.h" #include "health.h"
#include "misc.h" #include "misc.h"
#include "rope.h" #include "rope.h"
#include "rope.h"
#include "draw.h" #include "draw.h"
#include "savegame.h" #include "savegame.h"
#include "inventory.h" #include "inventory.h"
#include "camera.h" #include "camera.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
@ -707,8 +707,8 @@ void LaraInitialiseMeshes() // (AF) (D)
Lara.leftArm.frameNumber = 0; Lara.leftArm.frameNumber = 0;
Lara.rightArm.frameNumber = 0; Lara.rightArm.frameNumber = 0;
Lara.target = NULL; Lara.target = NULL;
Lara.rightArm.lock = 0; Lara.rightArm.lock = false;
Lara.leftArm.lock = 0; Lara.leftArm.lock = false;
} }
void InitialiseLara(int restore) void InitialiseLara(int restore)
@ -730,7 +730,7 @@ void InitialiseLara(int restore)
else else
{ {
ZeroMemory(&Lara, sizeof(LaraInfo)); ZeroMemory(&Lara, sizeof(LaraInfo));
Lara.ExtraAnim = 0; Lara.ExtraAnim = NO_ITEM;
Lara.Vehicle = NO_ITEM; Lara.Vehicle = NO_ITEM;
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h"
#include "collide.h"
extern COLL_INFO coll; extern COLL_INFO coll;

View file

@ -1,6 +1,5 @@
#include "framework.h"
#include "larasurf.h" #include "larasurf.h"
#include "..\Global\global.h"
#include "control.h" #include "control.h"
#include "camera.h" #include "camera.h"
#include "collide.h" #include "collide.h"
@ -10,11 +9,9 @@
#include "laraswim.h" #include "laraswim.h"
#include "larafire.h" #include "larafire.h"
#include "laramisc.h" #include "laramisc.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
extern void(*lara_control_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll);
extern void(*lara_collision_routines[NUM_LARA_STATES + 1])(ITEM_INFO* item, COLL_INFO* coll);
bool EnableCrawlFlexWaterPullUp, EnableCrawlFlexSubmerged; bool EnableCrawlFlexWaterPullUp, EnableCrawlFlexSubmerged;
void lara_col_surftread(ITEM_INFO* item, COLL_INFO* coll) void lara_col_surftread(ITEM_INFO* item, COLL_INFO* coll)
@ -516,5 +513,5 @@ int LaraTestWaterStepOut(ITEM_INFO* item, COLL_INFO* coll)//4D100, 4D564 (F)
Lara.waterStatus = LW_WADE; Lara.waterStatus = LW_WADE;
return true; return 1;
} }

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h"
#include "Lara.h" #include "Lara.h"
void _cdecl lara_col_surftread(ITEM_INFO* item, COLL_INFO* coll); void _cdecl lara_col_surftread(ITEM_INFO* item, COLL_INFO* coll);

View file

@ -1,26 +1,30 @@
#include "framework.h"
#include "laraswim.h" #include "laraswim.h"
#include "..\Global\global.h"
#include "control.h" #include "control.h"
#include "camera.h" #include "camera.h"
#include "collide.h"
#include "items.h" #include "items.h"
#include "box.h" #include "box.h"
#include "Lara.h" #include "Lara.h"
#include "larasurf.h" #include "larasurf.h"
#include "effects.h" #include "effect.h"
#include "effect2.h" #include "effect2.h"
#include "larafire.h" #include "larafire.h"
#include "laramisc.h" #include "laramisc.h"
#include "draw.h" #include "draw.h"
#include "camera.h" #include "camera.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
#include "GameFlowScript.h"
typedef struct SUBSUIT_INFO
{
short XRot;
short dXRot;
short XRotVel;
short Vel[2];
short YVel;
};
SUBSUIT_INFO Subsuit; SUBSUIT_INFO Subsuit;
byte SubHitCount = 0; byte SubHitCount = 0;
@ -823,7 +827,7 @@ void LaraSwimCollision(ITEM_INFO* item, COLL_INFO* coll)//4B608, 4BA6C
} }
} }
if (Lara.waterStatus != LW_FLYCHEAT && Lara.ExtraAnim == 0) if (Lara.waterStatus != LW_FLYCHEAT && Lara.ExtraAnim == NO_ITEM)
LaraTestWaterDepth(item, coll); LaraTestWaterDepth(item, coll);
} }

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "collide.h"
void LaraWaterCurrent(COLL_INFO* coll); void LaraWaterCurrent(COLL_INFO* coll);
int GetWaterDepth(int x, int y, int z, short roomNumber); int GetWaterDepth(int x, int y, int z, short roomNumber);

View file

@ -1,11 +1,10 @@
#include "framework.h"
#include "lot.h" #include "lot.h"
#include "box.h" #include "box.h"
#include "..\Global\global.h" #include "setup.h"
#include <stdio.h>
#include "../Specific/setup.h"
#include "camera.h" #include "camera.h"
#include "lara.h" #include "lara.h"
#include "..\Specific\level.h" #include "level.h"
#define DEFAULT_FLY_UPDOWN_SPEED 16 #define DEFAULT_FLY_UPDOWN_SPEED 16
#define DEFAULT_SWIM_UPDOWN_SPEED 32 #define DEFAULT_SWIM_UPDOWN_SPEED 32
@ -15,8 +14,6 @@ CREATURE_INFO* BaddieSlots;
void InitialiseLOTarray(int allocMem) void InitialiseLOTarray(int allocMem)
{ {
//DB_Log(0, "InitialiseLOTarray - DLL");
if (allocMem) if (allocMem)
BaddieSlots = (CREATURE_INFO*)game_malloc(sizeof(CREATURE_INFO) * NUM_SLOTS); BaddieSlots = (CREATURE_INFO*)game_malloc(sizeof(CREATURE_INFO) * NUM_SLOTS);
@ -235,11 +232,13 @@ void InitialiseSlot(short itemNum, short slot)
case ZONE_BLOCKABLE: case ZONE_BLOCKABLE:
creature->LOT.blockMask = BLOCKABLE; creature->LOT.blockMask = BLOCKABLE;
creature->LOT.zone = ZONE_BASIC;
break; break;
case ZONE_SOPHIALEE: case ZONE_SOPHIALEE:
creature->LOT.step = CLICK(4); creature->LOT.step = CLICK(4);
creature->LOT.drop = -CLICK(3); creature->LOT.drop = -CLICK(3);
creature->LOT.zone = ZONE_HUMAN_CLASSIC;
break; break;
} }
@ -289,8 +288,8 @@ void CreateZone(ITEM_INFO* item)
} }
else else
{ {
short* zone = Zones[creature->LOT.zone][0]; short* zone = Zones[creature->LOT.zone][FALSE];
short* flippedZone = Zones[creature->LOT.zone][1]; short* flippedZone = Zones[creature->LOT.zone][TRUE];
short zoneNumber = zone[item->boxNumber]; short zoneNumber = zone[item->boxNumber];
short flippedZoneNumber = flippedZone[item->boxNumber]; short flippedZoneNumber = flippedZone[item->boxNumber];

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "box.h"
#include "..\Global\global.h" constexpr auto NUM_SLOTS = 32;
extern int SlotsUsed; extern int SlotsUsed;
extern CREATURE_INFO* BaddieSlots; extern CREATURE_INFO* BaddieSlots;

View file

@ -1,43 +1,43 @@
#include "malloc.h" #include "framework.h"
#include <stdlib.h> #include "malloc.h"
#include "..\Global\global.h"
char* malloc_buffer; char* malloc_buffer;
int malloc_size; int malloc_size;
char* malloc_ptr; char* malloc_ptr;
int malloc_free; int malloc_free;
int malloc_used; int malloc_used;
char* game_malloc(int size) char* game_malloc(int size)
{ {
char* ptr; char* ptr;
size = (size + 3) & 0xfffffffc; size = (size + 3) & 0xfffffffc;
if (size <= malloc_free) if (size <= malloc_free)
{ {
ptr = malloc_ptr; ptr = malloc_ptr;
malloc_free -= size; malloc_free -= size;
malloc_used += size; malloc_used += size;
malloc_ptr += size; malloc_ptr += size;
return ptr; return ptr;
} }
return 0; return 0;
} }
void init_game_malloc() void init_game_malloc()
{ {
malloc_size = 1048576 * 128; malloc_size = 1048576 * 128;
malloc_buffer = (char*)malloc(malloc_size); malloc_buffer = (char*)malloc(malloc_size);
malloc_ptr = malloc_buffer; malloc_ptr = malloc_buffer;
malloc_free = malloc_size; malloc_free = malloc_size;
malloc_used = 0; malloc_used = 0;
} }
void game_free(int size, int type) void game_free(int size, int type)
{ {
size = (size + 3) & (~3); size = (size + 3) & (~3);
malloc_ptr -= size; malloc_ptr -= size;
malloc_free += size; malloc_free += size;
malloc_used -= size; malloc_used -= size;
} }

View file

@ -1,11 +1,11 @@
#pragma once #pragma once
extern char* malloc_buffer; extern char* malloc_buffer;
extern int malloc_size; extern int malloc_size;
extern char* malloc_ptr; extern char* malloc_ptr;
extern int malloc_free; extern int malloc_free;
extern int malloc_used; extern int malloc_used;
char* game_malloc(int size); char* game_malloc(int size);
void init_game_malloc(); void init_game_malloc();
void game_free(int size, int type); void game_free(int size, int type);

View file

@ -1,9 +1,7 @@
#include "framework.h"
#include "misc.h" #include "misc.h"
#include "../Specific/setup.h" #include "setup.h"
#include "..\Specific\level.h" #include "level.h"
#define CHK_ANY(var, flag) (var & flag) != 0
#define CHK_NOP(var, flag) !(var & flag)
short GF(short animIndex, short frameToStart) short GF(short animIndex, short frameToStart)
{ {

View file

@ -1,5 +1,10 @@
#pragma once #pragma once
#include "../Global/global.h"
#include "box.h"
#define CHK_ANY(var, flag) (var & flag) != 0
#define CHK_EXI(var, flag) var & flag
#define CHK_NOP(var, flag) !(var & flag)
enum LARA_MESH_MASK enum LARA_MESH_MASK
{ {

View file

@ -1,15 +1,12 @@
#include "framework.h"
#include "missile.h" #include "missile.h"
#include "..\Global\global.h" #include "sound.h"
#include "..\Game\control.h" #include "items.h"
#include "..\Game\sound.h" #include "effect.h"
#include "..\Game\items.h" #include "draw.h"
#include "..\Game\effects.h"
#include "..\Game\draw.h"
#include "..\Game\tomb4fx.h"
#include <stdio.h>
#include "debris.h" #include "debris.h"
#include "../Specific/level.h" #include "level.h"
#include "../Specific/setup.h" #include "setup.h"
#include "lara.h" #include "lara.h"
#define SHARD_DAMAGE 30 #define SHARD_DAMAGE 30

View file

@ -1,6 +1,5 @@
#pragma once #pragma once
#include "effect.h"
#include "..\Global\global.h"
void ShootAtLara(FX_INFO* fx); void ShootAtLara(FX_INFO* fx);
void ControlMissile(short fxNumber); void ControlMissile(short fxNumber);

View file

@ -1 +1,2 @@
#include "framework.h"
#include "newinv2.h" #include "newinv2.h"

View file

@ -1,9 +1,8 @@
#include "framework.h"
#include "objects.h" #include "objects.h"
#include "..\Global\global.h"
#include "items.h" #include "items.h"
#include "effects.h" #include "effect.h"
#include "effect2.h" #include "effect2.h"
#include "collide.h"
#include "draw.h" #include "draw.h"
#include "Lara.h" #include "Lara.h"
#include "sphere.h" #include "sphere.h"
@ -11,10 +10,10 @@
#include "control.h" #include "control.h"
#include "switch.h" #include "switch.h"
#include "box.h" #include "box.h"
#include "../Specific/setup.h" #include "setup.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
OBJECT_TEXTURE* WaterfallTextures[6]; OBJECT_TEXTURE* WaterfallTextures[6];
@ -42,47 +41,7 @@ short PoleBounds[12] = // offset 0xA1250
void InitialiseSmashObject(short itemNumber)
{
ITEM_INFO* item = &Items[itemNumber];
item->flags = 0;
item->meshBits = 1;
ROOM_INFO* r = &Rooms[item->roomNumber];
FLOOR_INFO* floor = &XZ_GET_SECTOR(r, item->pos.xPos - r->x, item->pos.zPos - r->z);
if (Boxes[floor->box].overlapIndex & END_BIT)
Boxes[floor->box].overlapIndex |= BLOCKED;
}
void SmashObject(short itemNumber)
{
ITEM_INFO* item = &Items[itemNumber];
ROOM_INFO* r = &Rooms[item->roomNumber];
int sector = ((item->pos.zPos - r->z) >> 10) + r->xSize * ((item->pos.xPos - r->x) >> 10);
BOX_INFO* box = &Boxes[r->floor[sector].box];
if (box->overlapIndex & BOX_LAST)
box->overlapIndex &= ~BOX_BLOCKED;
SoundEffect(SFX_SMASH_GLASS, &item->pos, 0);
item->collidable = 0;
item->meshBits = 0xFFFE;
ExplodingDeath(itemNumber, -1, 257);
item->flags |= IFLAG_INVISIBLE;
if (item->status == ITEM_ACTIVE)
RemoveActiveItem(itemNumber);
item->status = ITEM_DEACTIVATED;
}
void SmashObjectControl(short itemNumber)
{
SmashObject(itemNumber << 16);
}
void BridgeFlatFloor(ITEM_INFO* item, int x, int y, int z, int* height) void BridgeFlatFloor(ITEM_INFO* item, int x, int y, int z, int* height)
{ {
@ -675,7 +634,7 @@ void AnimatingControl(short itemNumber)
item->frameNumber = Anims[item->animNumber].frameBase; item->frameNumber = Anims[item->animNumber].frameBase;
RemoveActiveItem(itemNumber); RemoveActiveItem(itemNumber);
item->aiBits = 0; item->aiBits = 0;
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
} }
} }

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h"
#include "collide.h"
extern OBJECT_TEXTURE* WaterfallTextures[6]; extern OBJECT_TEXTURE* WaterfallTextures[6];
extern float WaterfallY[6]; extern float WaterfallY[6];
@ -25,6 +26,6 @@ void CutsceneRopeControl(short itemNumber);
void HybridCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll); void HybridCollision(short itemNum, ITEM_INFO* laraitem, COLL_INFO* coll);
void InitialiseSmashObject(short itemNumber); void InitialiseSmashObject(short itemNumber);
void InitialiseTightRope(short itemNumber); void InitialiseTightRope(short itemNumber);
void InitialiseAnimating(short itemNumber);
void AnimatingControl(short itemNumber);
void HighObject2Control(short itemNumber); void HighObject2Control(short itemNumber);
void InitialiseAnimating(short itemNumber);
void AnimatingControl(short itemNumber);

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,8 @@
#include "framework.h"
#include "objlight.h" #include "objlight.h"
#include "control.h" #include "control.h"
#include "effect2.h" #include "effect2.h"
#include "trmath.h"
void TriggerAlertLight(int x, int y, int z, int r, int g, int b, int angle, short room, int falloff) void TriggerAlertLight(int x, int y, int z, int r, int g, int b, int angle, short room, int falloff)
{ {

View file

@ -1,6 +1,6 @@
#include "framework.h"
#include "people.h" #include "people.h"
#include "..\Global\global.h" #include "effect.h"
#include "effects.h"
#include "effect2.h" #include "effect2.h"
#include "draw.h" #include "draw.h"
#include "control.h" #include "control.h"
@ -8,7 +8,6 @@
#include "debris.h" #include "debris.h"
#include "lara.h" #include "lara.h"
#include "sound.h" #include "sound.h"
#include "box.h"
int ShotLara(ITEM_INFO* item, AI_INFO* info, BITE_INFO* gun, short extra_rotation, int damage) int ShotLara(ITEM_INFO* item, AI_INFO* info, BITE_INFO* gun, short extra_rotation, int damage)
{ {

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "box.h"
int ShotLara(ITEM_INFO* item, AI_INFO* info, BITE_INFO* gun, short extra_rotation, int damage); int ShotLara(ITEM_INFO* item, AI_INFO* info, BITE_INFO* gun, short extra_rotation, int damage);
short GunMiss(int x, int y, int z, short speed, short yrot, short roomNumber); short GunMiss(int x, int y, int z, short speed, short yrot, short roomNumber);

227
TR5Main/Game/phd_global.h Normal file
View file

@ -0,0 +1,227 @@
#pragma once
typedef struct PHD_VECTOR
{
int x;
int y;
int z;
PHD_VECTOR()
{
this->x = 0;
this->y = 0;
this->z = 0;
}
PHD_VECTOR(int xpos, int ypos, int zpos)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
}
};
typedef struct PHD_3DPOS
{
int xPos;
int yPos;
int zPos;
short xRot;
short yRot;
short zRot;
PHD_3DPOS()
{
this->xPos = 0;
this->yPos = 0;
this->zPos = 0;
this->xRot = 0;
this->yRot = 0;
this->zRot = 0;
}
PHD_3DPOS(int x, int y, int z)
{
this->xPos = x;
this->yPos = y;
this->zPos = z;
this->xRot = 0;
this->yRot = 0;
this->zRot = 0;
}
PHD_3DPOS(short xrot, short yrot, short zrot)
{
this->xPos = 0;
this->yPos = 0;
this->zPos = 0;
this->xRot = xrot;
this->yRot = yrot;
this->zRot = zrot;
}
PHD_3DPOS(int x, int y, int z, short xrot, short yrot, short zrot)
{
this->xPos = x;
this->yPos = y;
this->zPos = z;
this->xRot = xrot;
this->yRot = yrot;
this->zRot = zrot;
}
};
typedef struct GAME_VECTOR
{
int x;
int y;
int z;
short roomNumber;
short boxNumber;
GAME_VECTOR()
{
this->x = 0;
this->y = 0;
this->z = 0;
this->roomNumber = 0;
this->boxNumber = 0;
}
GAME_VECTOR(int xpos, int ypos, int zpos)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->roomNumber = 0;
this->boxNumber = 0;
}
GAME_VECTOR(int xpos, int ypos, int zpos, short roomNumber)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->roomNumber = roomNumber;
this->boxNumber = 0;
}
GAME_VECTOR(int xpos, int ypos, int zpos, short roomNumber, short boxNumber)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->roomNumber = roomNumber;
this->boxNumber = boxNumber;
}
};
typedef struct OBJECT_VECTOR
{
int x;
int y;
int z;
short data;
short flags;
OBJECT_VECTOR()
{
this->x = 0;
this->y = 0;
this->z = 0;
this->data = NULL;
this->flags = NULL;
}
OBJECT_VECTOR(int xpos, int ypos, int zpos)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->data = NULL;
this->flags = NULL;
}
OBJECT_VECTOR(int xpos, int ypos, int zpos, short newdata)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->data = newdata;
this->flags = NULL;
}
OBJECT_VECTOR(int xpos, int ypos, int zpos, short flags, bool isFlags) // use isFlags to use flag instead of newdata !
{
UNREFERENCED_PARAMETER(isFlags);
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->data = NULL;
this->flags = flags;
}
OBJECT_VECTOR(int xpos, int ypos, int zpos, short newdata, short newflags)
{
this->x = xpos;
this->y = ypos;
this->z = zpos;
this->data = newdata;
this->flags = newflags;
}
};
typedef struct VECTOR
{
int vx;
int vy;
int vz;
int pad;
};
typedef struct SVECTOR
{
short vx;
short vy;
short vz;
short pad;
};
typedef struct CVECTOR
{
byte r;
byte g;
byte b;
byte cd;
};
typedef struct TR_VERTEX
{
int x;
int y;
int z;
};
typedef enum MATRIX_ARRAY_VALUE
{
M00, M01, M02, M03,
M10, M11, M12, M13,
M20, M21, M22, M23
};
typedef struct MATRIX3D
{
short m00;
short m01;
short m02;
short m10;
short m11;
short m12;
short m20;
short m21;
short m22;
short pad;
int tx;
int ty;
int tz;
};

View file

@ -1,73 +1,72 @@
#include "framework.h"
#include "pickup.h" #include "pickup.h"
#include "phd_global.h"
#include "lara.h" #include "lara.h"
#include "draw.h" #include "draw.h"
#include "inventory.h" #include "inventory.h"
#include "effects.h" #include "effect.h"
#include "effect2.h" #include "effect2.h"
#include "control.h" #include "control.h"
#include "sphere.h" #include "sphere.h"
#include "debris.h" #include "debris.h"
#include "box.h" #include "box.h"
#include "healt.h" #include "health.h"
#include "items.h" #include "items.h"
#include "collide.h"
#include "switch.h" #include "switch.h"
#include "larafire.h" #include "larafire.h"
#include "laraflar.h" #include "laraflar.h"
#include "lara1gun.h" #include "lara1gun.h"
#include "lara2gun.h" #include "lara2gun.h"
#include "flmtorch.h" #include "flmtorch.h"
#include "../Specific/setup.h" #include "setup.h"
#include "camera.h" #include "camera.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
#include "savegame.h" #include "savegame.h"
#include "..\Global\global.h"
static short PickUpBounds[12] = // offset 0xA1338 static short PickUpBounds[12] = // offset 0xA1338
{ {
0xFF00, 0x0100, 0xFF38, 0x00C8, 0xFF00, 0x0100, 0xF8E4, 0x071C, 0x0000, 0x0000, 0xFF00, 0x0100, 0xFF38, 0x00C8, 0xFF00, 0x0100, 0xF8E4, 0x071C, 0x0000, 0x0000,
0x0000, 0x0000 0x0000, 0x0000
}; };
static PHD_VECTOR PickUpPosition = { 0, 0, 0xFFFFFF9C }; // offset 0xA1350 static PHD_VECTOR PickUpPosition(0, 0, -100); // offset 0xA1350
static short HiddenPickUpBounds[12] = // offset 0xA135C static short HiddenPickUpBounds[12] = // offset 0xA135C
{ {
0xFF00, 0x0100, 0xFF9C, 0x0064, 0xFCE0, 0xFF00, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xFF00, 0x0100, 0xFF9C, 0x0064, 0xFCE0, 0xFF00, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0x0000, 0x0000 0x0000, 0x0000
}; };
static PHD_VECTOR HiddenPickUpPosition = { 0, 0, 0xFFFFFD4E }; // offset 0xA1374 static PHD_VECTOR HiddenPickUpPosition(0, 0, -690); // offset 0xA1374
static short CrowbarPickUpBounds[12] = // offset 0xA1380 static short CrowbarPickUpBounds[12] = // offset 0xA1380
{ {
0xFF00, 0x0100, 0xFF9C, 0x0064, 0x00C8, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xFF00, 0x0100, 0xFF9C, 0x0064, 0x00C8, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0x0000, 0x0000 0x0000, 0x0000
}; };
static PHD_VECTOR CrowbarPickUpPosition = { 0, 0, 0xD7 }; // offset 0xA1398 static PHD_VECTOR CrowbarPickUpPosition(0, 0, 215); // offset 0xA1398
static short JobyCrowPickUpBounds[12] = // offset 0xA13A4 static short JobyCrowPickUpBounds[12] = // offset 0xA13A4
{ {
0xFE00, 0x0000, 0xFF9C, 0x0064, 0x0000, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xFE00, 0x0000, 0xFF9C, 0x0064, 0x0000, 0x0200, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0x0000, 0x0000 0x0000, 0x0000
}; };
static PHD_VECTOR JobyCrowPickUpPosition = { 0xFFFFFF20, 0, 0xF0 }; // offset 0xA13BC static PHD_VECTOR JobyCrowPickUpPosition(-224, 0, 240); // offset 0xA13BC
static short PlinthPickUpBounds[12] = // offset 0xA13C8 static short PlinthPickUpBounds[12] = // offset 0xA13C8
{ {
0xFF00, 0x0100, 0xFD80, 0x0280, 0xFE01, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xFF00, 0x0100, 0xFD80, 0x0280, 0xFE01, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0x0000, 0x0000 0x0000, 0x0000
}; };
static PHD_VECTOR PlinthPickUpPosition = { 0, 0, 0xFFFFFE34 }; // offset 0xA13E0 static PHD_VECTOR PlinthPickUpPosition(0, 0, -460); // offset 0xA13E0
static short PickUpBoundsUW[12] = // offset 0xA13EC static short PickUpBoundsUW[12] = // offset 0xA13EC
{ {
0xFE00, 0x0200, 0xFE00, 0x0200, 0xFE00, 0x0200, 0xE002, 0x1FFE, 0xE002, 0x1FFE, 0xFE00, 0x0200, 0xFE00, 0x0200, 0xFE00, 0x0200, 0xE002, 0x1FFE, 0xE002, 0x1FFE,
0xE002, 0x1FFE 0xE002, 0x1FFE
}; };
static PHD_VECTOR PickUpPositionUW = { 0, 0xFFFFFF38, 0xFFFFFEA2 }; // offset 0xA1404 static PHD_VECTOR PickUpPositionUW(0, -200, -350); // offset 0xA1404
static short KeyHoleBounds[12] = // offset 0xA1410 static short KeyHoleBounds[12] = // offset 0xA1410
{ {
0xFF00, 0x0100, 0x0000, 0x0000, 0x0000, 0x019C, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xFF00, 0x0100, 0x0000, 0x0000, 0x0000, 0x019C, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0xF8E4, 0x071C 0xF8E4, 0x071C
}; };
static PHD_VECTOR KeyHolePosition = { 0, 0, 0x138 }; // offset 0xA1428 static PHD_VECTOR KeyHolePosition(0, 0, 312); // offset 0xA1428
static short PuzzleBounds[12] = // offset 0xA1434 static short PuzzleBounds[12] = // offset 0xA1434
{ {
0x0000, 0x0000, 0xFF00, 0x0100, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0x0000, 0x0000, 0xFF00, 0x0100, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
@ -78,7 +77,7 @@ static short SOBounds[12] = // offset 0xA144C
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0xF8E4, 0x071C 0xF8E4, 0x071C
}; };
static PHD_VECTOR SOPos = { 0, 0, 0 }; // offset 0xA1464 static PHD_VECTOR SOPos(0, 0, 0); // offset 0xA1464
short SearchCollectFrames[4] = short SearchCollectFrames[4] =
{ {
0x00B4, 0x0064, 0x0099, 0x0053 0x00B4, 0x0064, 0x0099, 0x0053
@ -110,7 +109,7 @@ void PickedUpObject(short objectNumber)
switch (objectNumber) switch (objectNumber)
{ {
case ID_UZI_ITEM: case ID_UZI_ITEM:
if (!(Lara.Weapons[WEAPON_UZI].Present)) if (!Lara.Weapons[WEAPON_UZI].Present)
{ {
Lara.Weapons[WEAPON_UZI].Present = true; Lara.Weapons[WEAPON_UZI].Present = true;
Lara.Weapons[WEAPON_UZI].SelectedAmmo = 0; Lara.Weapons[WEAPON_UZI].SelectedAmmo = 0;
@ -122,7 +121,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_PISTOLS_ITEM: case ID_PISTOLS_ITEM:
if (!(Lara.Weapons[WEAPON_PISTOLS].Present)) if (!Lara.Weapons[WEAPON_PISTOLS].Present)
{ {
Lara.Weapons[WEAPON_PISTOLS].Present = true; Lara.Weapons[WEAPON_PISTOLS].Present = true;
Lara.Weapons[WEAPON_PISTOLS].SelectedAmmo = 0; Lara.Weapons[WEAPON_PISTOLS].SelectedAmmo = 0;
@ -133,7 +132,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_SHOTGUN_ITEM: case ID_SHOTGUN_ITEM:
if (!(Lara.Weapons[WEAPON_SHOTGUN].Present)) if (!Lara.Weapons[WEAPON_SHOTGUN].Present)
{ {
Lara.Weapons[WEAPON_SHOTGUN].Present = true; Lara.Weapons[WEAPON_SHOTGUN].Present = true;
Lara.Weapons[WEAPON_SHOTGUN].SelectedAmmo = 0; Lara.Weapons[WEAPON_SHOTGUN].SelectedAmmo = 0;
@ -145,7 +144,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_REVOLVER_ITEM: case ID_REVOLVER_ITEM:
if (!(Lara.Weapons[WEAPON_REVOLVER].Present)) if (!Lara.Weapons[WEAPON_REVOLVER].Present)
{ {
Lara.Weapons[WEAPON_REVOLVER].Present = true; Lara.Weapons[WEAPON_REVOLVER].Present = true;
Lara.Weapons[WEAPON_REVOLVER].SelectedAmmo = 0; Lara.Weapons[WEAPON_REVOLVER].SelectedAmmo = 0;
@ -157,7 +156,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_CROSSBOW_ITEM: case ID_CROSSBOW_ITEM:
if (!(Lara.Weapons[WEAPON_CROSSBOW].Present)) if (!Lara.Weapons[WEAPON_CROSSBOW].Present)
{ {
Lara.Weapons[WEAPON_CROSSBOW].Present = true; Lara.Weapons[WEAPON_CROSSBOW].Present = true;
Lara.Weapons[WEAPON_CROSSBOW].SelectedAmmo = 0; Lara.Weapons[WEAPON_CROSSBOW].SelectedAmmo = 0;
@ -169,7 +168,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_HK_ITEM: case ID_HK_ITEM:
if (!(Lara.Weapons[WEAPON_CROSSBOW].Present)) if (!Lara.Weapons[WEAPON_CROSSBOW].Present)
{ {
Lara.Weapons[WEAPON_HK].Present = true; Lara.Weapons[WEAPON_HK].Present = true;
Lara.Weapons[WEAPON_HK].SelectedAmmo = 0; Lara.Weapons[WEAPON_HK].SelectedAmmo = 0;
@ -181,7 +180,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_HARPOON_ITEM: case ID_HARPOON_ITEM:
if (!(Lara.Weapons[WEAPON_HARPOON_GUN].Present)) if (!Lara.Weapons[WEAPON_HARPOON_GUN].Present)
{ {
Lara.Weapons[WEAPON_HARPOON_GUN].Present = true; Lara.Weapons[WEAPON_HARPOON_GUN].Present = true;
Lara.Weapons[WEAPON_HARPOON_GUN].SelectedAmmo = 0; Lara.Weapons[WEAPON_HARPOON_GUN].SelectedAmmo = 0;
@ -193,7 +192,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_GRENADE_GUN_ITEM: case ID_GRENADE_GUN_ITEM:
if (!(Lara.Weapons[WEAPON_GRENADE_LAUNCHER].Present)) if (!Lara.Weapons[WEAPON_GRENADE_LAUNCHER].Present)
{ {
Lara.Weapons[WEAPON_GRENADE_LAUNCHER].Present = true; Lara.Weapons[WEAPON_GRENADE_LAUNCHER].Present = true;
Lara.Weapons[WEAPON_GRENADE_LAUNCHER].SelectedAmmo = 0; Lara.Weapons[WEAPON_GRENADE_LAUNCHER].SelectedAmmo = 0;
@ -205,7 +204,7 @@ void PickedUpObject(short objectNumber)
break; break;
case ID_ROCKET_LAUNCHER_ITEM: case ID_ROCKET_LAUNCHER_ITEM:
if (!(Lara.Weapons[WEAPON_ROCKET_LAUNCHER].Present)) if (!Lara.Weapons[WEAPON_ROCKET_LAUNCHER].Present)
{ {
Lara.Weapons[WEAPON_ROCKET_LAUNCHER].Present = true; Lara.Weapons[WEAPON_ROCKET_LAUNCHER].Present = true;
Lara.Weapons[WEAPON_ROCKET_LAUNCHER].SelectedAmmo = 0; Lara.Weapons[WEAPON_ROCKET_LAUNCHER].SelectedAmmo = 0;
@ -339,7 +338,7 @@ void PickedUpObject(short objectNumber)
case ID_GOLDROSE_ITEM: case ID_GOLDROSE_ITEM:
IsAtmospherePlaying = 0; IsAtmospherePlaying = 0;
S_CDPlay(6, 0); S_CDPlay(6, FALSE);
Lara.Secrets++; Lara.Secrets++;
Savegame.Level.Secrets++; Savegame.Level.Secrets++;
Savegame.Game.Secrets++; Savegame.Game.Secrets++;
@ -464,7 +463,7 @@ int KeyTrigger(short itemNum)
oldkey = KeyTriggerActive; oldkey = KeyTriggerActive;
if (!oldkey) if (!oldkey)
item->status = ITEM_DEACTIVATED; item->status = ITEM_DESACTIVATED;
KeyTriggerActive = false; KeyTriggerActive = false;
@ -704,7 +703,7 @@ void KeyHoleCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
{ {
if (!Lara.isMoving) if (!Lara.isMoving)
{ {
if (item->status != ITEM_INACTIVE) if (item->status != ITEM_NOT_ACTIVE)
return; return;
if (g_Inventory->GetSelectedObject() == NO_ITEM) if (g_Inventory->GetSelectedObject() == NO_ITEM)
{ {
@ -1277,7 +1276,7 @@ void RegeneratePickups()
if (ammo == 0) if (ammo == 0)
{ {
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
} }
} }
} }
@ -1339,7 +1338,7 @@ short* FindPlinth(ITEM_INFO* item)
if (item->pos.xPos == mesh->x && item->pos.zPos == mesh->z) if (item->pos.xPos == mesh->x && item->pos.zPos == mesh->z)
{ {
short* frame = GetBestFrame(item); short* frame = GetBestFrame(item);
STATIC_INFO* s = &StaticObjects[mesh->staticNumber]; StaticInfo* s = &StaticObjects[mesh->staticNumber];
if (frame[0] <= s->xMaxc && frame[1] >= s->xMinc && frame[4] <= s->zMaxc && frame[5] >= s->zMinc && (s->xMinc || s->xMaxc)) if (frame[0] <= s->xMaxc && frame[1] >= s->xMinc && frame[4] <= s->zMaxc && frame[5] >= s->zMinc && (s->xMinc || s->xMaxc))
{ {
found = mesh->staticNumber; found = mesh->staticNumber;
@ -1359,8 +1358,9 @@ short* FindPlinth(ITEM_INFO* item)
for (itemNumber = room->itemNumber; itemNumber != NO_ITEM; itemNumber = Items[itemNumber].nextItem) for (itemNumber = room->itemNumber; itemNumber != NO_ITEM; itemNumber = Items[itemNumber].nextItem)
{ {
ITEM_INFO* current = &Items[itemNumber]; ITEM_INFO* current = &Items[itemNumber];
ObjectInfo* obj = &Objects[current->objectNumber];
if (Objects[current->objectNumber].collision != PickupCollision if (!obj->isPickup
&& item->pos.xPos == current->pos.xPos && item->pos.xPos == current->pos.xPos
&& item->pos.yPos <= current->pos.yPos && item->pos.yPos <= current->pos.yPos
&& item->pos.zPos == current->pos.zPos && item->pos.zPos == current->pos.zPos
@ -1401,7 +1401,7 @@ void PuzzleDone(ITEM_INFO* item, short itemNum)
{ {
FlipMap(Items[i].triggerFlags - 7); FlipMap(Items[i].triggerFlags - 7);
flipmap[Items[i].triggerFlags - 7] ^= IFLAG_ACTIVATION_MASK; flipmap[Items[i].triggerFlags - 7] ^= IFLAG_ACTIVATION_MASK;
Items[i].status = ITEM_INACTIVE; Items[i].status = ITEM_NOT_ACTIVE;
Items[i].flags |= 0x20; Items[i].flags |= 0x20;
} }
} }
@ -1469,7 +1469,7 @@ void InitialiseSearchObject(short itemNumber)
break; break;
} }
} }
else if (Objects[item2->objectNumber].collision == PickupCollision else if (Objects[item2->objectNumber].isPickup
&& item->pos.xPos == item2->pos.xPos && item->pos.xPos == item2->pos.xPos
&& item->pos.yPos == item2->pos.yPos && item->pos.yPos == item2->pos.yPos
&& item->pos.zPos == item2->pos.zPos) && item->pos.zPos == item2->pos.zPos)
@ -1494,7 +1494,7 @@ void SearchObjectCollision(short itemNumber, ITEM_INFO* laraitem, COLL_INFO* lar
item = &Items[itemNumber]; item = &Items[itemNumber];
objNumber = (item->objectNumber - ID_SEARCH_OBJECT1) / 2; objNumber = (item->objectNumber - ID_SEARCH_OBJECT1) / 2;
if (TrInput & IN_ACTION && laraitem->currentAnimState == STATE_LARA_STOP && laraitem->animNumber == ANIMATION_LARA_STAY_IDLE && Lara.gunStatus == LG_NO_ARMS && (item->status == ITEM_INACTIVE && item->objectNumber != ID_SEARCH_OBJECT4 || !item->itemFlags[0]) if (TrInput & IN_ACTION && laraitem->currentAnimState == STATE_LARA_STOP && laraitem->animNumber == ANIMATION_LARA_STAY_IDLE && Lara.gunStatus == LG_NO_ARMS && (item->status == ITEM_NOT_ACTIVE && item->objectNumber != ID_SEARCH_OBJECT4 || !item->itemFlags[0])
|| Lara.isMoving && Lara.generalPtr == (void *) itemNumber) || Lara.isMoving && Lara.generalPtr == (void *) itemNumber)
{ {
bounds = GetBoundsAccurate(item); bounds = GetBoundsAccurate(item);
@ -1600,10 +1600,10 @@ void SearchObjectControl(short itemNumber)
if (item->itemFlags[1] != -1) if (item->itemFlags[1] != -1)
{ {
item2 = &Items[item->itemFlags[1]]; item2 = &Items[item->itemFlags[1]];
if (Objects[item2->objectNumber].collision == PickupCollision) if (Objects[item2->objectNumber].isPickup)
{ {
if (FlipStats[0]) if (FlipStats[0])
item2->status = ITEM_INACTIVE; item2->status = ITEM_NOT_ACTIVE;
else else
item2->status = ITEM_INVISIBLE; item2->status = ITEM_INVISIBLE;
} }
@ -1617,7 +1617,7 @@ void SearchObjectControl(short itemNumber)
if (item->itemFlags[1] != -1) if (item->itemFlags[1] != -1)
{ {
item2 = &Items[item->itemFlags[1]]; item2 = &Items[item->itemFlags[1]];
if (Objects[item2->objectNumber].collision == PickupCollision) if (Objects[item2->objectNumber].isPickup)
{ {
AddDisplayPickup(item2->objectNumber); AddDisplayPickup(item2->objectNumber);
KillItem(item->itemFlags[1]); KillItem(item->itemFlags[1]);
@ -1639,7 +1639,7 @@ void SearchObjectControl(short itemNumber)
} }
if (item->status == ITEM_DEACTIVATED) if (item->status == ITEM_DESACTIVATED)
{ {
if (item->objectNumber == ID_SEARCH_OBJECT4) if (item->objectNumber == ID_SEARCH_OBJECT4)
{ {
@ -1649,7 +1649,7 @@ void SearchObjectControl(short itemNumber)
else else
{ {
RemoveActiveItem(itemNumber); RemoveActiveItem(itemNumber);
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
} }
} }
} }

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "collide.h"
void InitialisePickup(short itemNumber); void InitialisePickup(short itemNumber);
void PickedUpObject(short objectNumber); void PickedUpObject(short objectNumber);

227
TR5Main/Game/room.h Normal file
View file

@ -0,0 +1,227 @@
#pragma once
typedef struct tr5_room_layer
{
unsigned int NumLayerVertices; // Number of vertices in this layer (4 bytes)
unsigned short UnknownL1;
unsigned short NumLayerRectangles; // Number of rectangles in this layer (2 bytes)
unsigned short NumLayerTriangles; // Number of triangles in this layer (2 bytes)
unsigned short UnknownL2;
unsigned short Filler; // Always 0
unsigned short Filler2; // Always 0
/// The following 6 floats define the bounding box for the layer
float LayerBoundingBoxX1;
float LayerBoundingBoxY1;
float LayerBoundingBoxZ1;
float LayerBoundingBoxX2;
float LayerBoundingBoxY2;
float LayerBoundingBoxZ2;
unsigned int Filler3; // Always 0 (4 bytes)
void* VerticesOffset;
void* PolyOffset;
void* PolyOffset2;
};
typedef struct tr5_vertex
{
float x;
float y;
float z;
};
typedef struct tr5_room_vertex
{
tr5_vertex Vertex; // Vertex is now floating-point
tr5_vertex Normal;
DWORD Colour; // 32-bit colour
};
typedef struct tr4_mesh_face3 // 10 bytes
{
short Vertices[3];
short Texture;
short Effects; // TR4-5 ONLY: alpha blending and environment mapping strength
};
typedef struct tr4_mesh_face4 // 12 bytes
{
short Vertices[4];
short Texture;
short Effects;
};
typedef struct tr_room_portal // 32 bytes
{
short AdjoiningRoom; // Which room this portal leads to
TR_VERTEX Normal;
TR_VERTEX Vertices[4];
};
typedef struct tr_room_sector // 8 bytes
{
unsigned short FDindex; // Index into FloorData[]
unsigned short BoxIndex; // Index into Boxes[] (-1 if none)
unsigned char RoomBelow; // 255 is none
signed char Floor; // Absolute height of floor
unsigned char RoomAbove; // 255 if none
signed char Ceiling; // Absolute height of ceiling
};
typedef struct tr5_room_light
{
float x, y, z; // Position of light, in world coordinates
float r, g, b; // Colour of the light
int Separator; // Dummy value = 0xCDCDCDCD
float In; // Cosine of the IN value for light / size of IN value
float Out; // Cosine of the OUT value for light / size of OUT value
float RadIn; // (IN radians) * 2
float RadOut; // (OUT radians) * 2
float Range; // Range of light
float dx, dy, dz; // Direction - used only by sun and spot lights
int x2, y2, z2; // Same as position, only in integer.
int dx2, dy2, dz2; // Same as direction, only in integer.
byte LightType;
byte Filler[3]; // Dummy values = 3 x 0xCD
};
typedef struct MESH_INFO
{
int x;
int y;
int z;
short yRot;
short shade;
short Flags;
short staticNumber;
};
typedef struct LIGHTINFO
{
int x; // size=0, offset=0
int y; // size=0, offset=4
int z; // size=0, offset=8
unsigned char Type; // size=0, offset=12
unsigned char r; // size=0, offset=13
unsigned char g; // size=0, offset=14
unsigned char b; // size=0, offset=15
short nx; // size=0, offset=16
short ny; // size=0, offset=18
short nz; // size=0, offset=20
short Intensity; // size=0, offset=22
unsigned char Inner; // size=0, offset=24
unsigned char Outer; // size=0, offset=25
short FalloffScale; // size=0, offset=26
short Length; // size=0, offset=28
short Cutoff; // size=0, offset=30
};
typedef struct FLOOR_INFO
{
unsigned short index;
unsigned short fx : 4;
unsigned short box : 11;
unsigned short stopper : 1;
unsigned char pitRoom;
signed char floor;
unsigned char skyRoom;
signed char ceiling;
};
typedef enum RoomEnumFlag
{
ENV_FLAG_WATER = 0x0001,
ENV_FLAG_SWAMP = 0x0004,
ENV_FLAG_OUTSIDE = 0x0008,
ENV_FLAG_DYNAMIC_LIT = 0x0010,
ENV_FLAG_WIND = 0x0020,
ENV_FLAG_NOT_NEAR_OUTSIDE = 0x0040,
ENV_FLAG_NO_LENSFLARE = 0x0080, // Was quicksand in TR3.
ENV_FLAG_MIST = 0x0100,
ENV_FLAG_CAUSTICS = 0x0200,
ENV_FLAG_UNKNOWN3 = 0x0400
};
typedef struct ROOM_INFO
{
short* data;
short* door;
FLOOR_INFO* floor;
void* something;
MESH_INFO* mesh;
int x;
int y;
int z;
int minfloor;
int maxceiling;
short xSize;
short ySize;
CVECTOR ambient;
short numLights;
short numMeshes;
unsigned char reverbType;
unsigned char flipNumber;
byte meshEffect;
byte boundActive;
short left;
short right;
short top;
short bottom;
short testLeft;
short testRight;
short testTop;
short testBottom;
short itemNumber;
short fxNumber;
short flippedRoom;
unsigned short flags; // ENV_FLAG_enum
unsigned int Unknown1;
unsigned int Unknown2; // Always 0
unsigned int Unknown3; // Always 0
unsigned int Separator; // 0xCDCDCDCD
unsigned short Unknown4;
unsigned short Unknown5;
float RoomX;
float RoomY;
float RoomZ;
unsigned int Separator1[4]; // Always 0xCDCDCDCD
unsigned int Separator2; // 0 for normal rooms and 0xCDCDCDCD for null rooms
unsigned int Separator3; // Always 0xCDCDCDCD
unsigned int NumRoomTriangles;
unsigned int NumRoomRectangles;
tr5_room_light* light; // Always 0
unsigned int LightDataSize;
unsigned int NumLights2; // Always same as NumLights
unsigned int Unknown6;
int RoomYTop;
int RoomYBottom;
unsigned int NumLayers;
tr5_room_layer* LayerOffset;
tr5_room_vertex* VerticesOffset;
void* PolyOffset;
void* PolyOffset2; // Same as PolyOffset
int NumVertices;
int Separator5[4]; // Always 0xCDCDCDCD
};
typedef struct ANIM_STRUCT
{
short* framePtr;
short interpolation;
short currentAnimState;
int velocity;
int acceleration;
int Xvelocity;
int Xacceleration;
short frameBase;
short frameEnd;
short jumpAnimNum;
short jumpFrameNum;
short numberChanges;
short changeIndex;
short numberCommands;
short commandIndex;
};
constexpr auto NUM_ROOMS = 1024;
constexpr auto NO_ROOM = 0xFF;
constexpr auto NO_HEIGHT = (-0x7F00);

View file

@ -1,10 +1,10 @@
#include "framework.h"
#include "rope.h" #include "rope.h"
#include "..\Global\global.h"
#include "draw.h" #include "draw.h"
#include "laramisc.h" #include "laramisc.h"
#include "lara.h" #include "lara.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "control.h" #include "control.h"
PENDULUM CurrentPendulum; PENDULUM CurrentPendulum;

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "collide.h"
struct ROPE_STRUCT struct ROPE_STRUCT
{ {

View file

@ -1,27 +1,28 @@
#include "framework.h"
#include "savegame.h" #include "savegame.h"
#include "..\Global\global.h" #include "Lara.h"
#include "..\Game\Lara.h" #include "items.h"
#include "..\Game\items.h" #include "box.h"
#include "..\Game\box.h" #include "pickup.h"
#include "..\Game\pickup.h" #include "lot.h"
#include "..\Game\lot.h" #include "switch.h"
#include "..\Game\switch.h" #include "spotcam.h"
#include "..\Game\spotcam.h"
#include "traps.h" #include "traps.h"
#include "..\Game\laramisc.h" #include "laramisc.h"
#include "..\Objects\newobjects.h" #include "sound.h"
#include "..\Objects\oldobjects.h" #include "level.h"
#include "..\Game\sound.h" #include "setup.h"
#include "..\Specific\level.h"
#include "../Specific/setup.h"
#include "camera.h" #include "camera.h"
#include "quad.h"
#include "tr5_rats_emitter.h"
#include "tr5_bats_emitter.h"
#include "tr5_spider_emitter.h"
FileStream* SaveGame::m_stream; FileStream* SaveGame::m_stream;
ChunkReader* SaveGame::m_reader; ChunkReader* SaveGame::m_reader;
ChunkWriter* SaveGame::m_writer; ChunkWriter* SaveGame::m_writer;
vector<LuaVariable> SaveGame::m_luaVariables; vector<LuaVariable> SaveGame::m_luaVariables;
int SaveGame::LastSaveGame; int SaveGame::LastSaveGame;
SAVEGAME_INFO Savegame;
ChunkId* SaveGame::m_chunkGameStatus; ChunkId* SaveGame::m_chunkGameStatus;
ChunkId* SaveGame::m_chunkItems; ChunkId* SaveGame::m_chunkItems;
@ -65,6 +66,7 @@ ChunkId* SaveGame::m_chunkPickupCombo;
ChunkId* SaveGame::m_chunkExamineCombo; ChunkId* SaveGame::m_chunkExamineCombo;
ChunkId* SaveGame::m_chunkWeaponItem; ChunkId* SaveGame::m_chunkWeaponItem;
SAVEGAME_INFO Savegame;
extern vector<AudioTrack> g_AudioTracks; extern vector<AudioTrack> g_AudioTracks;
extern byte SequenceUsed[6]; extern byte SequenceUsed[6];
extern byte SequenceResults[3][3][3]; extern byte SequenceResults[3][3][3];
@ -512,18 +514,17 @@ bool SaveGame::readLara()
memcpy(&Lara, lara, sizeof(LaraInfo)); memcpy(&Lara, lara, sizeof(LaraInfo));
free(buffer); free(buffer);
for (int i = 0; i < 15; i++) for (int i = 0; i < NUM_LARA_MESHES; i++)
{ {
Lara.meshPtrs[i] = ADD_PTR(Lara.meshPtrs[i], short, MeshBase); Lara.meshPtrs[i] = AddPtr(Lara.meshPtrs[i], short, MeshBase);
//printf("MeshPtr: %d\n", Lara.meshPtrs[i]);
} }
Lara.leftArm.frameBase = ADD_PTR(Lara.leftArm.frameBase, short, Objects[ID_LARA].frameBase); Lara.leftArm.frameBase = AddPtr(Lara.leftArm.frameBase, short, Objects[ID_LARA].frameBase);
Lara.rightArm.frameBase = ADD_PTR(Lara.rightArm.frameBase, short, Objects[ID_LARA].frameBase); Lara.rightArm.frameBase = AddPtr(Lara.rightArm.frameBase, short, Objects[ID_LARA].frameBase);
Lara.target = NULL; Lara.target = NULL;
Lara.spazEffect = NULL; Lara.spazEffect = NULL;
Lara.generalPtr = ADD_PTR(Lara.generalPtr, char, malloc_buffer); Lara.generalPtr = (void*)AddPtr(Lara.generalPtr, char, malloc_buffer);
Lara.weaponItem = NO_ITEM; Lara.weaponItem = NO_ITEM;
// Is Lara burning? // Is Lara burning?
@ -543,7 +544,6 @@ bool SaveGame::readLara()
} }
m_reader->ReadChunks(&readLaraChunks, 0); m_reader->ReadChunks(&readLaraChunks, 0);
return true; return true;
} }
@ -575,7 +575,7 @@ bool SaveGame::readItem()
m_reader->ReadChunks(&readItemChunks, itemNumber); m_reader->ReadChunks(&readItemChunks, itemNumber);
DisableBaddieAI(itemNumber); DisableBaddieAI(itemNumber);
KillItem(itemNumber); KillItem(itemNumber);
item->status = ITEM_DEACTIVATED; item->status = ITEM_DESACTIVATED;
item->flags |= ONESHOT; item->flags |= ONESHOT;
item->afterDeath = 128; item->afterDeath = 128;
} }
@ -589,11 +589,8 @@ bool SaveGame::readItem()
} }
// Some post-processing things // Some post-processing things
if (obj->collision == PuzzleHoleCollision && (item->status == ITEM_DEACTIVATED || item->status == ITEM_ACTIVE)) if (obj->isPuzzleHole && (item->status == ITEM_DESACTIVATED || item->status == ITEM_ACTIVE))
{ item->objectNumber += NUM_PUZZLES;
item->objectNumber += 8;
//*((_WORD *)pItem - 28) = v55 + Objects[*((_WORD *)pItem - 32)].anim_index;
}
if (item->objectNumber >= ID_SMASH_OBJECT1 && item->objectNumber <= ID_SMASH_OBJECT8 && (item->flags & ONESHOT)) if (item->objectNumber >= ID_SMASH_OBJECT1 && item->objectNumber <= ID_SMASH_OBJECT8 && (item->flags & ONESHOT))
item->meshBits = 0x100; item->meshBits = 0x100;
@ -770,7 +767,6 @@ bool SaveGame::readLaraChunks(ChunkId* chunkId, int maxSize, int arg)
else if (chunkId->EqualsTo(m_chunkWeaponInfo)) else if (chunkId->EqualsTo(m_chunkWeaponInfo))
{ {
int id = LEB128::ReadInt32(m_stream); int id = LEB128::ReadInt32(m_stream);
CarriedWeaponInfo* weapon = &Lara.Weapons[id]; CarriedWeaponInfo* weapon = &Lara.Weapons[id];
weapon->Present = LEB128::ReadByte(m_stream); weapon->Present = LEB128::ReadByte(m_stream);
@ -1046,7 +1042,7 @@ bool SaveGame::readItemChunks(ChunkId* chunkId, int maxSize, int itemNumber)
creature->mood = (MOOD_TYPE)LEB128::ReadInt32(m_stream); creature->mood = (MOOD_TYPE)LEB128::ReadInt32(m_stream);
ITEM_INFO* enemy = (ITEM_INFO*)LEB128::ReadLong(m_stream); ITEM_INFO* enemy = (ITEM_INFO*)LEB128::ReadLong(m_stream);
creature->enemy = ADD_PTR(enemy, ITEM_INFO, malloc_buffer); creature->enemy = AddPtr(enemy, ITEM_INFO, malloc_buffer);
creature->aiTarget.objectNumber = LEB128::ReadInt16(m_stream); creature->aiTarget.objectNumber = LEB128::ReadInt16(m_stream);
creature->aiTarget.roomNumber = LEB128::ReadInt16(m_stream); creature->aiTarget.roomNumber = LEB128::ReadInt16(m_stream);

View file

@ -1,19 +1,49 @@
#pragma once #pragma once
#include "ChunkId.h"
#include "..\Global\global.h" #include "ChunkReader.h"
#include "..\Specific\IO\ChunkId.h" #include "ChunkWriter.h"
#include "..\Specific\IO\ChunkReader.h" #include "LEB128.h"
#include "..\Specific\IO\ChunkWriter.h" #include "Streams.h"
#include "..\Specific\IO\LEB128.h" #include "GameFlowScript.h"
#include "..\Specific\IO\Streams.h" #include "GameLogicScript.h"
#include "..\Scripting\GameFlowScript.h"
#include "..\Scripting\GameLogicScript.h"
#define SAVEGAME_BUFFER_SIZE 1048576 #define SAVEGAME_BUFFER_SIZE 1048576
extern GameFlow* g_GameFlow; typedef struct STATS
extern GameScript* g_GameScript; {
extern SAVEGAME_INFO Savegame; unsigned int Timer;
unsigned int Distance;
unsigned int AmmoUsed;
unsigned int AmmoHits;
unsigned short Kills;
unsigned char Secrets;
unsigned char HealthUsed;
};
typedef struct SAVEGAME_INFO
{
short Checksum;
unsigned short VolumeCD;
unsigned short VolumeFX;
short ScreenX;
short ScreenY;
unsigned char ControlOption;
bool VibrateOn;
bool AutoTarget;
STATS Level;
STATS Game;
short WeaponObject;
short WeaponAnim;
short WeaponFrame;
short WeaponCurrent;
short WeaponGoal;
unsigned int CutSceneTriggered1;
unsigned int CutSceneTriggered2;
byte GameComplete;
unsigned char LevelNumber;
unsigned char CampaignSecrets[4];
unsigned char TLCount;
};
typedef struct SaveGameHeader typedef struct SaveGameHeader
{ {
@ -28,6 +58,10 @@ typedef struct SaveGameHeader
bool Present; bool Present;
}; };
extern GameFlow* g_GameFlow;
extern GameScript* g_GameScript;
extern SAVEGAME_INFO Savegame;
class SaveGame { class SaveGame {
private: private:
static FileStream* m_stream; static FileStream* m_stream;
@ -134,9 +168,7 @@ public:
static void Start(); static void Start();
static void End(); static void End();
static bool Load(char* fileName); static bool Load(char* fileName);
static bool LoadHeader(char* fileName, SaveGameHeader* header); static bool LoadHeader(char* fileName, SaveGameHeader* header);
static bool Save(char* fileName); static bool Save(char* fileName);
}; };

View file

@ -1,9 +1,10 @@
#include "framework.h"
#include "sound.h" #include "sound.h"
#include "lara.h" #include "lara.h"
#include "camera.h" #include "camera.h"
#include "..\Specific\configuration.h" #include "configuration.h"
#include "..\Specific\level.h"" #include "level.h"
#include "..\Specific\winmain.h" #include "winmain.h"
HSTREAM BASS_3D_Mixdown; HSTREAM BASS_3D_Mixdown;
HFX BASS_FXHandler[NUM_SOUND_FILTERS]; HFX BASS_FXHandler[NUM_SOUND_FILTERS];

View file

@ -1,14 +1,12 @@
#pragma once #pragma once
#include "control.h"
#include "bass.h" enum SFX_TYPES
#include "bass_fx.h" {
#include <vector> SFX_LANDANDWATER = 0,
SFX_LANDONLY = (1 << 14),
#include "..\Game\control.h" SFX_WATERONLY = (2 << 14)
#include "..\Global\global.h" };
#include <SimpleMath.h>
using namespace DirectX::SimpleMath;
typedef enum audio_tracks typedef enum audio_tracks
{ {
@ -1969,7 +1967,7 @@ typedef enum sound_effects
#define SOUND_XFADETIME_HIJACKSOUND 50 #define SOUND_XFADETIME_HIJACKSOUND 50
#define SOUND_BGM_DAMP_COEFFICIENT 0.6f #define SOUND_BGM_DAMP_COEFFICIENT 0.6f
struct SoundEffectSlot typedef struct SoundEffectSlot
{ {
short state; short state;
short effectID; short effectID;
@ -1978,13 +1976,13 @@ struct SoundEffectSlot
Vector3 origin; Vector3 origin;
}; };
struct SoundTrackSlot typedef struct SoundTrackSlot
{ {
HSTREAM channel; HSTREAM channel;
short trackID; short trackID;
}; };
enum sound_track_types typedef enum sound_track_types
{ {
SOUND_TRACK_ONESHOT, SOUND_TRACK_ONESHOT,
SOUND_TRACK_BGM, SOUND_TRACK_BGM,
@ -1992,7 +1990,7 @@ enum sound_track_types
NUM_SOUND_TRACK_TYPES NUM_SOUND_TRACK_TYPES
}; };
enum sound_filters typedef enum sound_filters
{ {
SOUND_FILTER_REVERB, SOUND_FILTER_REVERB,
SOUND_FILTER_COMPRESSOR, SOUND_FILTER_COMPRESSOR,
@ -2001,14 +1999,14 @@ enum sound_filters
NUM_SOUND_FILTERS NUM_SOUND_FILTERS
}; };
enum sound_states typedef enum sound_states
{ {
SOUND_STATE_IDLE, SOUND_STATE_IDLE,
SOUND_STATE_ENDING, SOUND_STATE_ENDING,
SOUND_STATE_ENDED SOUND_STATE_ENDED
}; };
enum sound_flags typedef enum sound_flags
{ {
SOUND_NORMAL, SOUND_NORMAL,
SOUND_WAIT, SOUND_WAIT,
@ -2016,7 +2014,7 @@ enum sound_flags
SOUND_LOOPED SOUND_LOOPED
}; };
enum reverb_type typedef enum reverb_type
{ {
RVB_OUTSIDE, // 0x00 no reverberation RVB_OUTSIDE, // 0x00 no reverberation
RVB_SMALL_ROOM, // 0x01 little reverberation RVB_SMALL_ROOM, // 0x01 little reverberation
@ -2027,7 +2025,17 @@ enum reverb_type
NUM_REVERB_TYPES NUM_REVERB_TYPES
}; };
struct AudioTrack typedef struct SAMPLE_INFO
{
short number;
byte volume;
byte radius;
byte randomness;
signed char pitch;
short flags;
};
typedef struct AudioTrack
{ {
char* Name; char* Name;
byte Mask; byte Mask;

View file

@ -1,8 +1,11 @@
#include "framework.h"
#include "sphere.h" #include "sphere.h"
#include "draw.h" #include "draw.h"
#include "lara.h" #include "lara.h"
#include "../Specific/level.h" #include "level.h"
#include "../Specific/setup.h" #include "setup.h"
#include "Renderer11.h"
#include "trmath.h"
int NumLaraSpheres; int NumLaraSpheres;
bool GotLaraSpheres; bool GotLaraSpheres;
@ -97,7 +100,6 @@ int TestCollision(ITEM_INFO* item, ITEM_INFO* l)
int dz = z1 - z2; int dz = z1 - z2;
int r = r1 + r2; int r = r1 + r2;
if (SQUARE(dx) + SQUARE(dy) + SQUARE(dz) < SQUARE(r)) if (SQUARE(dx) + SQUARE(dy) + SQUARE(dz) < SQUARE(r))
{ {
l->touchBits |= (1 << j); l->touchBits |= (1 << j);

View file

@ -1,12 +1,19 @@
#pragma once #pragma once
#include "items.h"
#include "..\Global\global.h"
#define SPHERES_SPACE_LOCAL 0 #define SPHERES_SPACE_LOCAL 0
#define SPHERES_SPACE_WORLD 1 #define SPHERES_SPACE_WORLD 1
#define SPHERES_SPACE_BONE_ORIGIN 2 #define SPHERES_SPACE_BONE_ORIGIN 2
#define MAX_SPHERES 34 #define MAX_SPHERES 34
typedef struct SPHERE
{
int x;
int y;
int z;
int r;
};
extern int NumLaraSpheres; extern int NumLaraSpheres;
extern bool GotLaraSpheres; extern bool GotLaraSpheres;
extern SPHERE LaraSpheres[MAX_SPHERES]; extern SPHERE LaraSpheres[MAX_SPHERES];

View file

@ -1,13 +1,12 @@
#include "framework.h"
#include "spotcam.h" #include "spotcam.h"
#include "camera.h"
#include "..\Global\global.h"
#include "Camera.h"
#include "control.h" #include "control.h"
#include "draw.h" #include "draw.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "switch.h" #include "switch.h"
#include "lara.h" #include "lara.h"
#include "../Specific/input.h" #include "input.h"
int LastSequence; int LastSequence;
int SpotcamTimer; int SpotcamTimer;
@ -50,8 +49,6 @@ int SlowMotion;
int SpotcamDontDrawLara; int SpotcamDontDrawLara;
int SpotcamOverlay; int SpotcamOverlay;
extern Renderer11* g_Renderer;
void InitSpotCamSequences() void InitSpotCamSequences()
{ {
int s, cc, n, ce; int s, cc, n, ce;

View file

@ -1,6 +1,30 @@
#pragma once #pragma once
#include "phd_global.h"
#include "..\Global\global.h" struct QUAKE_CAMERA
{
GAME_VECTOR spos;
GAME_VECTOR epos;
};
typedef struct SPOTCAM
{
int x;
int y;
int z;
int tx;
int ty;
int tz;
unsigned char sequence;
unsigned char camera;
short fov;
short roll;
short timer;
short speed;
short flags;
short roomNumber;
short pad;
};
enum spotcam_flags enum spotcam_flags
{ {

View file

@ -1,18 +1,18 @@
#include "framework.h"
#include "switch.h" #include "switch.h"
#include "laramisc.h" #include "laramisc.h"
#include "door.h" #include "door.h"
#include "items.h" #include "items.h"
#include "lot.h" #include "lot.h"
#include "objects.h" #include "objects.h"
#include "collide.h"
#include "Lara.h" #include "Lara.h"
#include "inventory.h" #include "inventory.h"
#include "draw.h" #include "draw.h"
#include "sphere.h" #include "sphere.h"
#include "camera.h" #include "camera.h"
#include "../Specific/setup.h" #include "setup.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
byte SequenceUsed[6]; byte SequenceUsed[6];
@ -42,12 +42,6 @@ short TurnSwitchBoundsC[12] = // offset 0xA14FC
0xF8E4, 0x071C 0xF8E4, 0x071C
}; };
PHD_VECTOR TurnSwitchPosA = { 650, 0, -138 }; // offset 0xA1514 PHD_VECTOR TurnSwitchPosA = { 650, 0, -138 }; // offset 0xA1514
PHD_VECTOR CogSwitchPos = { 0, 0, -856 }; // offset 0xA1520
short CogSwitchBounds[12] = // offset 0xA152C
{
0xFE00, 0x0200, 0x0000, 0x0000, 0xFA00, 0xFE00, 0xF8E4, 0x071C, 0xEAAC, 0x1554,
0xF8E4, 0x071C
};
PHD_VECTOR RailSwitchPos = { 0, 0, -550 }; // offset 0xA1544 PHD_VECTOR RailSwitchPos = { 0, 0, -550 }; // offset 0xA1544
short RailSwitchBounds[12] = // offset 0xA1550 short RailSwitchBounds[12] = // offset 0xA1550
{ {
@ -205,125 +199,6 @@ void CrowDoveSwitchControl(short itemNumber)
} }
} }
void CogSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
{
ITEM_INFO* item = &Items[itemNum];
FLOOR_INFO* floor = GetFloor(item->pos.xPos, item->pos.yPos, item->pos.zPos, &item->roomNumber);
GetFloorHeight(floor, item->pos.xPos, item->pos.yPos, item->pos.zPos);
if (!TriggerIndex)
{
ObjectCollision(itemNum, l, coll);
return;
}
short* trigger = TriggerIndex;
for (int i = *TriggerIndex; (i & 0x1F) != 4; trigger++)
{
if (i < 0)
break;
i = trigger[1];
}
ITEM_INFO* target = &Items[trigger[3] & 0x3FF];
DOOR_DATA* door = (DOOR_DATA*)target->data;
if (item->status == ITEM_INACTIVE)
{
if (!(item->flags & 0x100)
&& (TrInput & IN_ACTION
&& !Lara.gunStatus
&& !(item->status && item->gravityStatus)
&& l->currentAnimState == STATE_LARA_STOP
&& l->animNumber == ANIMATION_LARA_STAY_IDLE
|| Lara.isMoving && Lara.generalPtr == (void*)itemNum))
{
if (TestLaraPosition(CogSwitchBounds, item, l))
{
if (MoveLaraPosition(&CogSwitchPos, item, l))
{
Lara.isMoving = false;
Lara.headYrot = 0;
Lara.headXrot = 0;
Lara.torsoYrot = 0;
Lara.torsoXrot = 0;
Lara.gunStatus = LG_HANDS_BUSY;
Lara.generalPtr = target;
l->animNumber = ANIMATION_LARA_COGWHEEL_GRAB;
l->goalAnimState = STATE_LARA_COGWHEEL;
l->currentAnimState = STATE_LARA_COGWHEEL;
l->frameNumber = Anims[l->animNumber].frameBase;
AddActiveItem(itemNum);
item->goalAnimState = 1;
item->status = ITEM_ACTIVE;
if (!door->opened)
{
AddActiveItem((target - Items));
target->itemFlags[2] = target->pos.yPos;
target->status = ITEM_ACTIVE;
}
}
else
{
Lara.generalPtr = (void*)itemNum;
}
return;
}
if (Lara.isMoving && Lara.generalPtr == (void*)itemNum)
{
Lara.isMoving = false;
Lara.gunStatus = LG_NO_ARMS;
}
}
ObjectCollision(itemNum, l, coll);
}
}
void CogSwitchControl(short itemNum)
{
ITEM_INFO* item = &Items[itemNum];
AnimateItem(item);
if (item->currentAnimState == 1)
{
if (item->goalAnimState == 1 && !(TrInput & IN_ACTION))
{
LaraItem->goalAnimState = STATE_LARA_STOP;
item->goalAnimState = 0;
}
if (LaraItem->animNumber == ANIMATION_LARA_COGWHEEL_PULL)
{
if (LaraItem->frameNumber == (Anims[ANIMATION_LARA_COGWHEEL_PULL].frameBase + 10))
{
ITEM_INFO* it = (ITEM_INFO*)Lara.generalPtr;
it->itemFlags[0] = 40;
Lara.generalPtr = it;
SoundEffect(SFX_STONE_SCRAPE_FAST, &it->pos, 0);
}
}
}
else
{
if (item->frameNumber == Anims[item->animNumber].frameEnd)
{
item->currentAnimState = 0;
item->status = ITEM_INACTIVE;
RemoveActiveItem(itemNum);
LaraItem->animNumber = ANIMATION_LARA_STAY_SOLID;
LaraItem->frameNumber = Anims[LaraItem->animNumber].frameBase;
LaraItem->goalAnimState = STATE_LARA_STOP;
LaraItem->currentAnimState = STATE_LARA_STOP;
Lara.gunStatus = LG_NO_ARMS;
}
}
}
void FullBlockSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll) void FullBlockSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
{ {
ITEM_INFO* item = &Items[itemNum]; ITEM_INFO* item = &Items[itemNum];
@ -389,7 +264,7 @@ void FullBlockSwitchControl(short itemNumber)
{ {
item->itemFlags[0] = 0; item->itemFlags[0] = 0;
item->goalAnimState = 1; item->goalAnimState = 1;
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
if (++CurrentSequence >= 7u) if (++CurrentSequence >= 7u)
CurrentSequence = 0; CurrentSequence = 0;
} }
@ -876,7 +751,7 @@ void TurnSwitchControl(short itemNum)
l->frameNumber = Anims[l->animNumber].frameBase; l->frameNumber = Anims[l->animNumber].frameBase;
item->animNumber = Objects[item->objectNumber].animIndex; item->animNumber = Objects[item->objectNumber].animIndex;
item->frameNumber = Anims[item->animNumber].frameBase; item->frameNumber = Anims[item->animNumber].frameBase;
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
RemoveActiveItem(itemNum); RemoveActiveItem(itemNum);
@ -1019,7 +894,7 @@ void SwitchCollision2(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
if (TrInput & IN_ACTION) if (TrInput & IN_ACTION)
{ {
if (item->status == ITEM_INACTIVE && Lara.waterStatus == LW_UNDERWATER && !Lara.gunStatus && l->currentAnimState == STATE_LARA_UNDERWATER_STOP) if (item->status == ITEM_NOT_ACTIVE && Lara.waterStatus == LW_UNDERWATER && !Lara.gunStatus && l->currentAnimState == STATE_LARA_UNDERWATER_STOP)
{ {
if (TestLaraPosition(Switch2Bounds, item, l)) if (TestLaraPosition(Switch2Bounds, item, l))
{ {
@ -1054,7 +929,7 @@ void SwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll)
&& l->currentAnimState == STATE_LARA_STOP && l->currentAnimState == STATE_LARA_STOP
&& l->animNumber == ANIMATION_LARA_STAY_IDLE && l->animNumber == ANIMATION_LARA_STAY_IDLE
&& !Lara.gunStatus && !Lara.gunStatus
&& item->status == ITEM_INACTIVE && item->status == ITEM_NOT_ACTIVE
&& !(item->flags & 0x100) && !(item->flags & 0x100)
&& item->triggerFlags >= 0 && item->triggerFlags >= 0
|| Lara.isMoving && Lara.generalPtr == (void*)itemNum) || Lara.isMoving && Lara.generalPtr == (void*)itemNum)
@ -1347,7 +1222,7 @@ int GetSwitchTrigger(ITEM_INFO* item, short* itemNos, int AttatchedToSwitch)
int SwitchTrigger(short itemNum, short timer) int SwitchTrigger(short itemNum, short timer)
{ {
ITEM_INFO* item = &Items[itemNum]; ITEM_INFO* item = &Items[itemNum];
if (item->status == ITEM_DEACTIVATED) if (item->status == ITEM_DESACTIVATED)
{ {
if ((!item->currentAnimState && item->objectNumber != ID_JUMP_SWITCH || item->currentAnimState == 1 && item->objectNumber == ID_JUMP_SWITCH) && timer > 0) if ((!item->currentAnimState && item->objectNumber != ID_JUMP_SWITCH || item->currentAnimState == 1 && item->objectNumber == ID_JUMP_SWITCH) && timer > 0)
{ {
@ -1361,7 +1236,7 @@ int SwitchTrigger(short itemNum, short timer)
{ {
RemoveActiveItem(itemNum); RemoveActiveItem(itemNum);
item->status = ITEM_INACTIVE; item->status = ITEM_NOT_ACTIVE;
if (!item->itemFlags[0] == 0) if (!item->itemFlags[0] == 0)
item->flags |= 0x100; item->flags |= 0x100;
if (item->currentAnimState != 1) if (item->currentAnimState != 1)

View file

@ -1,5 +1,8 @@
#pragma once #pragma once
#include "..\Global\global.h"
#include "collide.h"
extern int PulleyItemNumber;
void CrowDoveSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll); void CrowDoveSwitchCollision(short itemNum, ITEM_INFO* l, COLL_INFO* coll);
void CrowDoveSwitchControl(short itemNumber); void CrowDoveSwitchControl(short itemNumber);
@ -27,5 +30,3 @@ void InitialiseCrowDoveSwitch(short itemNumber);
void ProcessExplodingSwitchType8(ITEM_INFO* item); void ProcessExplodingSwitchType8(ITEM_INFO* item);
void InitialiseShootSwitch(short itemNumber); void InitialiseShootSwitch(short itemNumber);
void ShootSwitchCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll); void ShootSwitchCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll);
extern int PulleyItemNumber;

View file

@ -1,7 +1,9 @@
#include "framework.h"
#include "text.h" #include "text.h"
#include "draw.h" #include "draw.h"
#include "Renderer11.h"
void PrintString(int x, int y, int unk1, char* string, int unk2) void PrintString(int x, int y, int unk1, char* string, int unk2)
{ {
g_Renderer->PrintString(x, y, string, 0xFFFFFFFF, 0); g_Renderer->PrintString(x, y, string, D3DCOLOR_RGBA(0xFF, 0xFF, 0xFF, 255), 0);
} }

View file

@ -1,13 +1,14 @@
#include "framework.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "../Global/global.h"
#include "lara.h" #include "lara.h"
#include "effect2.h" #include "effect2.h"
#include "draw.h" #include "draw.h"
#include "items.h" #include "setup.h"
#include "../Specific/setup.h" #include "level.h"
#include "..\Specific\level.h"
#include "sound.h" #include "sound.h"
#include "bubble.h" #include "bubble.h"
#include "trmath.h"
#include "GameFlowScript.h"
char FlareTable[121] = char FlareTable[121] =
{ {
@ -45,11 +46,7 @@ BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD];
DRIP_STRUCT Drips[MAX_DRIPS]; DRIP_STRUCT Drips[MAX_DRIPS];
SHOCKWAVE_STRUCT ShockWaves[MAX_SHOCKWAVE]; SHOCKWAVE_STRUCT ShockWaves[MAX_SHOCKWAVE];
FIRE_LIST Fires[MAX_FIRE_LIST]; FIRE_LIST Fires[MAX_FIRE_LIST];
ENERGY_ARC EnergyArcs[MAX_ENERGY_ARCS]; ENERGY_ARC EnergyArcs[MAX_ENERGYARCS];
extern int NextSpark;
extern SPARKS Sparks[MAX_SPARKS];
extern Renderer11* g_Renderer;
int GetFreeFireSpark() int GetFreeFireSpark()
{ {
@ -116,7 +113,7 @@ void TriggerGlobalStaticFlame()
spark->xVel = 0; spark->xVel = 0;
spark->yVel = 0; spark->yVel = 0;
spark->zVel = 0; spark->zVel = 0;
spark->flags = 0; spark->flags = SP_NONE;
spark->dSize = spark->sSize = spark->size = (GetRandomControl() & 0x1F) + -128; spark->dSize = spark->sSize = spark->size = (GetRandomControl() & 0x1F) + -128;
} }
@ -153,7 +150,7 @@ void TriggerGlobalFireSmoke()
} }
else else
{ {
spark->flags = 0; spark->flags = SP_NONE;
} }
spark->gravity = -16 - (GetRandomControl() & 0xF); spark->gravity = -16 - (GetRandomControl() & 0xF);
@ -196,7 +193,7 @@ void TriggerGlobalFireFlame()
} }
else else
{ {
spark->flags = 0; spark->flags = SP_NONE;
} }
spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 128; spark->sSize = spark->size = (GetRandomControl() & 0x1F) + 128;
@ -331,7 +328,7 @@ void UpdateFireSparks()
void UpdateEnergyArcs() void UpdateEnergyArcs()
{ {
for (int i = 0; i < MAX_ENERGY_ARCS; i++) for (int i = 0; i < MAX_ENERGYARCS; i++)
{ {
ENERGY_ARC* arc = &EnergyArcs[i]; ENERGY_ARC* arc = &EnergyArcs[i];
@ -487,7 +484,7 @@ byte TriggerGunSmoke_SubFunction(int weaponType)
case WEAPON_HK: case WEAPON_HK:
case WEAPON_ROCKET_LAUNCHER: case WEAPON_ROCKET_LAUNCHER:
case WEAPON_GRENADE_LAUNCHER: case WEAPON_GRENADE_LAUNCHER:
return 0x18; //(12) Rocket and Grenade value for TriggerGunSmoke in TR3 have the value 12 ! (the HK is not included there) return 24; //(12) Rocket and Grenade value for TriggerGunSmoke in TR3 have the value 12 ! (the HK is not included there)
// other weapon // other weapon
default: default:
@ -514,7 +511,7 @@ void TriggerGunSmoke(int x, int y, int z, short xv, short yv, short zv, byte ini
spark->dShade = 64; spark->dShade = 64;
} }
spark->transType = 2; spark->transType = COLADD;
spark->x = x + (GetRandomControl() & 31) - 16; spark->x = x + (GetRandomControl() & 31) - 16;
spark->y = y + (GetRandomControl() & 31) - 16; spark->y = y + (GetRandomControl() & 31) - 16;
spark->z = z + (GetRandomControl() & 31) - 16; spark->z = z + (GetRandomControl() & 31) - 16;
@ -555,7 +552,7 @@ void TriggerGunSmoke(int x, int y, int z, short xv, short yv, short zv, byte ini
} }
else else
{ {
spark->flags = 0; spark->flags = SP_NONE;
} }
float gravity = frand() * 1.25f; float gravity = frand() * 1.25f;
spark->gravity = gravity; spark->gravity = gravity;
@ -595,7 +592,7 @@ void TriggerShatterSmoke(int x, int y, int z)
spark->colFadeSpeed = 4; spark->colFadeSpeed = 4;
spark->dShade = (GetRandomControl() & 0x1F) + 64; spark->dShade = (GetRandomControl() & 0x1F) + 64;
spark->fadeToBlack = 24 - (GetRandomControl() & 7); spark->fadeToBlack = 24 - (GetRandomControl() & 7);
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 7) + 48; spark->life = spark->sLife = (GetRandomControl() & 7) + 48;
spark->x = (GetRandomControl() & 0x1F) + x - 16; spark->x = (GetRandomControl() & 0x1F) + x - 16;
spark->y = (GetRandomControl() & 0x1F) + y - 16; spark->y = (GetRandomControl() & 0x1F) + y - 16;
@ -620,7 +617,7 @@ void TriggerShatterSmoke(int x, int y, int z)
} }
else else
{ {
spark->flags = 0; spark->flags = SP_NONE;
} }
spark->gravity = -4 - (GetRandomControl() & 3); spark->gravity = -4 - (GetRandomControl() & 3);
@ -1026,13 +1023,13 @@ void AddWaterSparks(int x, int y, int z, int num)
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->life = 24; spark->life = 24;
spark->sLife = 24; spark->sLife = 24;
spark->transType = 2; spark->transType = COLADD;
int random = GetRandomControl(); int random = GetRandomControl();
spark->xVel = -rcossin_tbl[2 * random] >> 5; spark->xVel = -rcossin_tbl[2 * random] >> 5;
spark->yVel = -640 - GetRandomControl(); spark->yVel = -640 - GetRandomControl();
spark->zVel = rcossin_tbl[2 * random & 0xFFF + 1] >> 5; spark->zVel = rcossin_tbl[2 * random & 0xFFF + 1] >> 5;
spark->friction = 5; spark->friction = 5;
spark->flags = 0; spark->flags = SP_NONE;
spark->x = x + (spark->xVel >> 3); spark->x = x + (spark->xVel >> 3);
spark->y = y - (spark->yVel >> 5); spark->y = y - (spark->yVel >> 5);
spark->z = z + (spark->zVel >> 3); spark->z = z + (spark->zVel >> 3);
@ -1041,10 +1038,6 @@ void AddWaterSparks(int x, int y, int z, int num)
} }
} }
void LaraBubbles(ITEM_INFO* item)// (F) void LaraBubbles(ITEM_INFO* item)// (F)
{ {
PHD_VECTOR pos; PHD_VECTOR pos;
@ -1201,7 +1194,7 @@ void TriggerLaraDrips()// (F)
} }
} }
int ExplodingDeath(short itemNumber, int meshBits, short damage) int ExplodingDeath(short itemNumber, int meshBits, short flags)
{ {
ITEM_INFO* item = &Items[itemNumber]; ITEM_INFO* item = &Items[itemNumber];
ObjectInfo* obj = &Objects[item->objectNumber]; ObjectInfo* obj = &Objects[item->objectNumber];
@ -1234,7 +1227,7 @@ int ExplodingDeath(short itemNumber, int meshBits, short damage)
int bits = 1; int bits = 1;
if (meshBits & 1 && item->meshBits & 1) if (meshBits & 1 && item->meshBits & 1)
{ {
if (damage & 0x100 || !(GetRandomControl() & 3)) if (flags & 0x100 || !(GetRandomControl() & 3))
{ {
Matrix boneMatrix = g_Renderer->GetBoneMatrix(item, 0); Matrix boneMatrix = g_Renderer->GetBoneMatrix(item, 0);
@ -1250,24 +1243,24 @@ int ExplodingDeath(short itemNumber, int meshBits, short damage)
fx->pos.zRot = 0; fx->pos.zRot = 0;
fx->pos.xRot = 0; fx->pos.xRot = 0;
if (damage & 0x10) if (flags & 0x10)
{ {
fx->speed = 0; fx->speed = 0;
} }
else else
{ {
if (damage & 0x20) if (flags & 0x20)
fx->speed = GetRandomControl() >> 12; fx->speed = GetRandomControl() >> 12;
else else
fx->speed = GetRandomControl() >> 8; fx->speed = GetRandomControl() >> 8;
} }
if (damage & 0x40) if (flags & 0x40)
{ {
fx->fallspeed = 0; fx->fallspeed = 0;
} }
else else
{ {
if ((damage & 0x80u) == 0) if ((flags & 0x80u) == 0)
fx->fallspeed = -(GetRandomControl() >> 8); fx->fallspeed = -(GetRandomControl() >> 8);
else else
fx->fallspeed = -(GetRandomControl() >> 12); fx->fallspeed = -(GetRandomControl() >> 12);
@ -1523,7 +1516,7 @@ void TriggerExplosionBubble(int x, int y, int z, short roomNum)// (F)
spark->sB = 0; spark->sB = 0;
spark->colFadeSpeed = 8; spark->colFadeSpeed = 8;
spark->fadeToBlack = 12; spark->fadeToBlack = 12;
spark->transType = 2; spark->transType = COLADD;
spark->x = x; spark->x = x;
spark->y = y; spark->y = y;
spark->z = z; spark->z = z;
@ -1580,7 +1573,7 @@ void TriggerExplosionBubble(int x, int y, int z, short roomNum)// (F)
spark->fadeToBlack = 64; spark->fadeToBlack = 64;
spark->life = spark->sLife = (GetRandomControl() & 0x1F) + 96; spark->life = spark->sLife = (GetRandomControl() & 0x1F) + 96;
if (unk) if (unk)
spark->transType = 2; spark->transType = COLADD;
else else
spark->transType = 3; spark->transType = 3;
spark->x = (GetRandomControl() & 0x1F) + x - 16; spark->x = (GetRandomControl() & 0x1F) + x - 16;
@ -1645,7 +1638,7 @@ void TriggerLightningGlow(int x, int y, int z, byte size, byte r, byte g, byte b
spark->dR = r; spark->dR = r;
spark->sR = r; spark->sR = r;
spark->colFadeSpeed = 2; spark->colFadeSpeed = 2;
spark->transType = 2; spark->transType = COLADD;
spark->on = 1; spark->on = 1;
spark->dB = b; spark->dB = b;
spark->sB = b; spark->sB = b;
@ -1680,7 +1673,7 @@ void TriggerFenceSparks(int x, int y, int z, int kill, int crane)//(F)
spark->life = (GetRandomControl() & 7) + 24; spark->life = (GetRandomControl() & 7) + 24;
spark->sLife = (GetRandomControl() & 7) + 24; spark->sLife = (GetRandomControl() & 7) + 24;
spark->transType = 2; spark->transType = COLADD;
spark->dynamic = -1; spark->dynamic = -1;
spark->x = x; spark->x = x;
@ -1700,7 +1693,7 @@ void TriggerFenceSparks(int x, int y, int z, int kill, int crane)//(F)
spark->friction = 4; spark->friction = 4;
} }
spark->flags = 0; spark->flags = SP_NONE;
spark->gravity = (GetRandomControl() & 0xF) + ((crane << 4) + 16); spark->gravity = (GetRandomControl() & 0xF) + ((crane << 4) + 16);
spark->maxYvel = 0; spark->maxYvel = 0;
} }
@ -1730,7 +1723,7 @@ void TriggerSmallSplash(int x, int y, int z, int num)
sptr->life = 24; sptr->life = 24;
sptr->sLife = 24; sptr->sLife = 24;
sptr->transType = 2; sptr->transType = COLADD;
angle = GetRandomControl() << 3; angle = GetRandomControl() << 3;
@ -1754,7 +1747,7 @@ ENERGY_ARC* TriggerEnergyArc(PHD_VECTOR* start, PHD_VECTOR* end, byte r, byte g,
{ {
ENERGY_ARC* arc = NULL; ENERGY_ARC* arc = NULL;
for (int i = 0; i < 16; i++) for (int i = 0; i < MAX_ENERGYARCS; i++)
{ {
arc = &EnergyArcs[i]; arc = &EnergyArcs[i];
if (arc->life == 0) if (arc->life == 0)

View file

@ -1,31 +1,185 @@
#pragma once #pragma once
#include "..\Global\types.h" #include "phd_global.h"
#include "..\Global\constants.h" #include "items.h"
struct ENERGY_ARC typedef struct ENERGY_ARC
{ {
PHD_VECTOR pos1; // 0 PHD_VECTOR pos1;
PHD_VECTOR pos2; PHD_VECTOR pos2;
PHD_VECTOR pos3; // 24 PHD_VECTOR pos3;
PHD_VECTOR pos4; // 36 PHD_VECTOR pos4;
byte r; // 48 byte r;
byte g; // 49 byte g;
byte b; // 50 byte b;
short sLife; // 52 short sLife;
short life; // 51 short life;
short amplitude; short amplitude;
short segmentSize; // 64 short segmentSize;
short sAmplitude; // 53 short sAmplitude;
byte type; // 61 byte type;
byte flags; // 62 byte flags;
signed char direction; // 63 signed char direction;
short rotation; short rotation;
short filler; short filler;
}; };
typedef struct SMOKE_SPARKS
{
int x;
int y;
int z;
short xVel;
short yVel;
short zVel;
short gravity;
short rotAng;
short flags;
byte sSize;
byte dSize;
byte size;
byte friction;
byte scalar;
byte def;
signed char rotAdd;
signed char maxYvel;
byte on;
byte sShade;
byte dShade;
byte shade;
byte colFadeSpeed;
byte fadeToBlack;
signed char sLife;
signed char life;
byte transType;
byte fxObj;
byte nodeNumber;
byte mirror;
};
typedef struct GUNFLASH_STRUCT
{
MATRIX3D matrix;
short on;
};
typedef struct SHOCKWAVE_STRUCT
{
int x;
int y;
int z;
short innerRad;
short outerRad;
short xRot;
short flags;
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char life;
short speed;
short temp;
};
typedef struct GUNSHELL_STRUCT
{
PHD_3DPOS pos;
short fallspeed;
short roomNumber;
short speed;
short counter;
short dirXrot;
short objectNumber;
};
typedef struct DRIP_STRUCT
{
int x;
int y;
int z;
byte on;
byte r;
byte g;
byte b;
short yVel;
byte gravity;
byte life;
short roomNumber;
byte outside;
byte pad;
};
typedef struct FIRE_LIST
{
int x;
int y;
int z;
byte on;
byte size;
short roomNumber;
};
typedef struct FIRE_SPARKS
{
short x;
short y;
short z;
short xVel;
short yVel;
short zVel;
short gravity;
short rotAng;
short flags;
unsigned char sSize;
unsigned char dSize;
unsigned char size;
unsigned char friction;
unsigned char scalar;
unsigned char def;
signed char rotAdd;
signed char maxYvel;
unsigned char on;
unsigned char sR;
unsigned char sG;
unsigned char sB;
unsigned char dR;
unsigned char dG;
unsigned char dB;
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char colFadeSpeed;
unsigned char fadeToBlack;
unsigned char sLife;
unsigned char life;
};
typedef struct BLOOD_STRUCT
{
int x;
int y;
int z;
short xVel;
short yVel;
short zVel;
short gravity;
short rotAng;
unsigned char sSize;
unsigned char dSize;
unsigned char size;
unsigned char friction;
byte rotAdd;
unsigned char on;
unsigned char sShade;
unsigned char dShade;
unsigned char shade;
unsigned char colFadeSpeed;
unsigned char fadeToBlack;
byte sLife;
byte life;
byte pad;
};
#define ENERGY_ARC_STRAIGHT_LINE 0 #define ENERGY_ARC_STRAIGHT_LINE 0
#define ENERGY_ARC_CIRCLE 1 #define ENERGY_ARC_CIRCLE 1
#define ENERGY_ARC_NO_RANDOMIZE 1 #define ENERGY_ARC_NO_RANDOMIZE 1
extern int LaserSightX; extern int LaserSightX;
@ -42,8 +196,26 @@ extern int NextBlood;
extern int NextSpider; extern int NextSpider;
extern int NextGunShell; extern int NextGunShell;
#define MAX_SPARKS_FIRE 20
#define MAX_FIRE_LIST 32
#define MAX_SPARKS_SMOKE 32
#define MAX_SPARKS_BLOOD 32
#define MAX_GUNFLASH 4
#define MAX_GUNSHELL 24
#define MAX_DRIPS 32
#define MAX_SHOCKWAVE 16
#define MAX_ENERGYARCS 32
extern GUNFLASH_STRUCT Gunflashes[MAX_GUNFLASH];
extern FIRE_SPARKS FireSparks[MAX_SPARKS_FIRE];
extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE];
extern GUNSHELL_STRUCT Gunshells[MAX_GUNSHELL];
extern BLOOD_STRUCT Blood[MAX_SPARKS_BLOOD];
extern DRIP_STRUCT Drips[MAX_DRIPS];
extern SHOCKWAVE_STRUCT ShockWaves[MAX_SHOCKWAVE];
extern FIRE_LIST Fires[MAX_FIRE_LIST];
extern ENERGY_ARC EnergyArcs[MAX_ENERGYARCS];
extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE]; extern SMOKE_SPARKS SmokeSparks[MAX_SPARKS_SMOKE];
extern ENERGY_ARC EnergyArcs[MAX_ENERGY_ARCS];
void TriggerBlood(int x, int y, int z, int unk, int num); void TriggerBlood(int x, int y, int z, int unk, int num);
void TriggerExplosionBubble(int x, int y, int z, short roomNum); void TriggerExplosionBubble(int x, int y, int z, short roomNum);
@ -73,7 +245,11 @@ void UpdateBubbles();
int GetFreeDrip(); int GetFreeDrip();
void UpdateDrips(); void UpdateDrips();
void TriggerLaraDrips(); void TriggerLaraDrips();
int ExplodingDeath(short itemNumber, int meshBits, short damage);
constexpr auto EXPLODE_HIT_EFFECT = 258;
constexpr auto EXPLODE_NORMAL = 256;
int ExplodingDeath(short itemNumber, int meshBits, short flags); // EXPLODE_ flags
int GetFreeShockwave(); int GetFreeShockwave();
void TriggerShockwave(PHD_3DPOS* pos, short innerRad, short outerRad, int speed, char r, char g, char b, char life, short angle, short flags); void TriggerShockwave(PHD_3DPOS* pos, short innerRad, short outerRad, int speed, char r, char g, char b, char life, short angle, short flags);
void TriggerShockwaveHitEffect(int x, int y, int z, int color, short rot, int vel); void TriggerShockwaveHitEffect(int x, int y, int z, int color, short rot, int vel);

View file

@ -1,9 +1,10 @@
#include "framework.h"
#include "traps.h" #include "traps.h"
#include "..\Global\global.h"
#include "items.h" #include "items.h"
#include "effect2.h" #include "effect2.h"
#include "tomb4fx.h" #include "tomb4fx.h"
#include "effects.h" #include "effect.h"
#include "lara.h" #include "lara.h"
#include "collide.h" #include "collide.h"
#include "switch.h" #include "switch.h"
@ -11,8 +12,8 @@
#include "camera.h" #include "camera.h"
#include "objlight.h" #include "objlight.h"
#include "draw.h" #include "draw.h"
#include "..\Specific\level.h" #include "level.h"
#include "../Specific/input.h" #include "input.h"
#include "sound.h" #include "sound.h"
static short CeilingTrapDoorBounds[12] = {-256, 256, 0, 900, -768, -256, -1820, 1820, -5460, 5460, -1820, 1820}; static short CeilingTrapDoorBounds[12] = {-256, 256, 0, 900, -768, -256, -1820, 1820, -5460, 5460, -1820, 1820};
@ -322,7 +323,7 @@ void CeilingTrapDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll) /
l->pos.yRot += ANGLE(180); l->pos.yRot += ANGLE(180);
result2 = TestLaraPosition(CeilingTrapDoorBounds, item, l); result2 = TestLaraPosition(CeilingTrapDoorBounds, item, l);
l->pos.yRot += ANGLE(180); l->pos.yRot += ANGLE(180);
if (TrInput & IN_ACTION && item->status != ITEM_DEACTIVATED && l->currentAnimState == STATE_LARA_JUMP_UP && l->gravityStatus && Lara.gunStatus == LG_NO_ARMS && (result || result2)) if (TrInput & IN_ACTION && item->status != ITEM_DESACTIVATED && l->currentAnimState == STATE_LARA_JUMP_UP && l->gravityStatus && Lara.gunStatus == LG_NO_ARMS && (result || result2))
{ {
AlignLaraPosition(&CeilingTrapDoorPos, item, l); AlignLaraPosition(&CeilingTrapDoorPos, item, l);
if (result2) if (result2)
@ -362,7 +363,7 @@ void FloorTrapDoorCollision(short itemNumber, ITEM_INFO* l, COLL_INFO* coll) //
ITEM_INFO* item; ITEM_INFO* item;
item = &Items[itemNumber]; item = &Items[itemNumber];
if (TrInput & IN_ACTION && item->status != ITEM_DEACTIVATED && l->currentAnimState == STATE_LARA_STOP && l->animNumber == ANIMATION_LARA_STAY_IDLE && Lara.gunStatus == LG_NO_ARMS if (TrInput & IN_ACTION && item->status != ITEM_DESACTIVATED && l->currentAnimState == STATE_LARA_STOP && l->animNumber == ANIMATION_LARA_STAY_IDLE && Lara.gunStatus == LG_NO_ARMS
|| Lara.isMoving && Lara.generalPtr == (void *) itemNumber) || Lara.isMoving && Lara.generalPtr == (void *) itemNumber)
{ {
if (TestLaraPosition(FloorTrapDoorBounds, item, l)) if (TestLaraPosition(FloorTrapDoorBounds, item, l))
@ -575,7 +576,7 @@ void FallingBlockFloor(ITEM_INFO* item, int x, int y, int z, int* height)
if (y <= item->pos.yPos) if (y <= item->pos.yPos)
{ {
*height = item->pos.yPos; *height = item->pos.yPos;
HeightType = 0; HeightType = WALL;
OnFloor = 1; OnFloor = 1;
} }
} }

View file

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "..\Global\global.h" #include "collide.h"
extern ITEM_INFO* WBItem; extern ITEM_INFO* WBItem;
extern short WBRoom; extern short WBRoom;

View file

@ -1,10 +1,6 @@
#include "math.h" #include "framework.h"
#include "types.h" #include "trmath.h"
#include <cmath> #include <cmath>
#include <d3d11.h>
#include <SimpleMath.h>
using namespace DirectX::SimpleMath;
// LUT for cos and sin // LUT for cos and sin
// 8192 entries, even entry = Sin, odd entry = Cos // 8192 entries, even entry = Sin, odd entry = Cos
@ -1327,18 +1323,19 @@ float TO_RAD(short angle)
return angle * 360.0f / 65536.0f * RADIAN; return angle * 360.0f / 65536.0f * RADIAN;
} }
const float frand() { const float frand()
int randValue = rand(); {
float result = randValue / (float)RAND_MAX; float result = float(rand() / RAND_MAX);
return result; return result;
} }
const float frandMinMax(float min, float max) const float frandMinMax(float min, float max)
{ {
return frand()* (max - min) + min; return frand() * (max - min) + min;
} }
const float lerp(float v0, float v1, float t) { const float lerp(float v0, float v1, float t)
{
return (1 - t) * v0 + t * v1; return (1 - t) * v0 + t * v1;
} }

View file

@ -1,17 +1,26 @@
#pragma once #pragma once
#include "phd_global.h"
#include "vodoo.h" constexpr auto PI = 3.14159265358979323846f;
#include "types.h" constexpr auto RADIAN = 0.01745329252f;
constexpr auto ONE_DEGREE = 182;
constexpr auto PREDICTIVE_SCALE_FACTOR = 14;
constexpr auto W2V_SHIFT = 14; // Shift scale of View.Frame to World.Frame
constexpr auto NODE_SHIFT = 15;
constexpr auto W2V_SCALE = (1 << W2V_SHIFT); // Scale of View Frame to World Frame
constexpr auto WALL_SHIFT = 10;
constexpr auto STEP_SIZE = 256;
constexpr auto WALL_SIZE = 1024;
constexpr auto STEPUP_HEIGHT = ((STEP_SIZE * 3) / 2);
constexpr auto BAD_JUMP_CEILING = ((STEP_SIZE * 3) / 4);
#define PI 3.14159265358979323846f
#define RADIAN 0.01745329252f
#define SQUARE(x) ((x)*(x)) #define SQUARE(x) ((x)*(x))
#define CLAMP(x, a, b) ((x)<(a)?(a):((x)>(b)?(b):(x))) #define CLAMP(x, a, b) ((x)<(a)?(a):((x)>(b)?(b):(x)))
#define SIGN(x) ((0 < (x)) - ((x) < 0)) #define SIGN(x) ((0 < (x)) - ((x) < 0))
#define CLAMPADD(x, a, b) ((x)<(a)?((x)+(a)):((x)>(b)?((x)-(b)):0)) #define CLAMPADD(x, a, b) ((x)<(a)?((x)+(a)):((x)>(b)?((x)-(b)):0))
#define ONE_DEGREE 182
#define CLICK(x) ((x) * STEP_SIZE) #define CLICK(x) ((x) * STEP_SIZE)
#define SECTOR(x) ((x) * WALL_SIZE) #define SECTOR(x) ((x) * WALL_SIZE)
#define HIDWORD(l) ((DWORD)(((DWORDLONG)(l)>>32)&0xFFFFFFFF))
short ANGLE(float angle); short ANGLE(float angle);
float TO_DEGREES(short angle); float TO_DEGREES(short angle);
@ -21,7 +30,6 @@ extern short rcossin_tbl[8192];
int phd_sin(short a); int phd_sin(short a);
int phd_cos(short a); int phd_cos(short a);
float ANGLEF(short angle);
// returns a float between 0-1 // returns a float between 0-1
const float frand(); const float frand();

View file

@ -1,195 +0,0 @@
#pragma once
#define HAIR_SEGMENTS 7 // only classic lara (young lara have more segments !)
#define DOUBLE_HAIR_SEGMENTS 14
#define TEXTURE_PAGE (256 * 256)
#define PREDICTIVE_SCALE_FACTOR 14
#define W2V_SHIFT 14 // Shift scale of View.Frame to World.Frame
#define NODE_SHIFT 15
#define W2V_SCALE (1 << W2V_SHIFT) // Scale of View Frame to World Frame
#define WALL_SHIFT 10
#define STEP_SIZE 256
#define WALL_SIZE 1024
/// obj->hitEffect flag
#define HIT_NONE 0
#define HIT_BLOOD 1
#define HIT_SMOKE 2
#define HIT_FRAGMENT 3
#define GUARD 1
#define AMBUSH 2
#define PATROL1 4
#define MODIFY 8
#define FOLLOW 16
#define PATROL2 32
#define ALL_AIOBJ (GUARD|AMBUSH|PATROL1|MODIFY|FOLLOW|PATROL2)
#define BOX_BLOCKED (1 << 14) // unpassable for other enemies, always set for movable blocks & closed doors
#define BOX_LAST (1 << 15) // unpassable by large enemies (T-Rex, Centaur, etc), always set behind doors
#define GRAVITY 6
#define SWAMP_GRAVITY 2
#define NUM_SPRITES 256
#define UNIT_SHADOW 256
#define NO_SHADOW 0
#define DEFAULT_RADIUS 10
#define ROT_X 4
#define ROT_Y 8
#define ROT_Z 16
// ExplodingDeath() last argument flags
#define EXPLODE_HIT_EFFECT 258
#define EXPLODE_NORMAL 256
#define FRONT_ARC ANGLE(90)
#define NO_ITEM -1
#define ALL_MESHBITS -1
#define GAME_BUFFER_SIZE 128 * 1000000
#define NUM_SLOTS 32
#define NUM_ITEMS 1023
#define NUM_ROOMS 1024
#define NUM_ANIMATED_SETS 1024
#define DRAW_DISTANCE 200 * 1024.0f
#define NUM_STATICS 1000
#define MAX_LIGHTS 100
#define MAX_LIGHTS_DRAW 16384
#define MAX_DYNAMIC_LIGHTS 16384
#define MAX_STATICS 1000
#define MAX_DRAW_STATICS 16384
#define MAX_BONES 32
#define MAX_SPRITES 16384
#define MAX_SPARKS 1024
#define MAX_SPARKS_FIRE 20
#define MAX_FIRE_LIST 32
#define MAX_SPARKS_SMOKE 32
#define MAX_SPARKS_BLOOD 32
#define MAX_ENERGY_ARCS 256
#define MAX_GUNSHELL 24
#define MAX_GUNFLASH 4
#define MAX_DRIPS 32
#define MAX_DYNAMICS 64
constexpr auto MAX_SPLASH = 8;
#define MAX_RIPPLES 32
#define MAX_CAMERA 18
#define MAX_SHOCKWAVE 16
#define MAX_EFFECTS 100
#define MAX_DEBRIS 256
#define NO_ROOM 0xFF
#define NO_HEIGHT (-0x7F00)
#define NUM_PICKUPS 64
#define TIMID 0
#define VIOLENT 1
#define LARA_HITE 762
// Room flags
#define ENV_FLAG_WATER 0x0001
#define ENV_FLAG_SWAMP 0x0004
#define ENV_FLAG_OUTSIDE 0x0008
#define ENV_FLAG_DYNAMIC_LIT 0x0010
#define ENV_FLAG_WIND 0x0020
#define ENV_FLAG_NOT_NEAR_OUTSIDE 0x0040
#define ENV_FLAG_NO_LENSFLARE 0x0080 // Was quicksand in TR3.
#define ENV_FLAG_MIST 0x0100
#define ENV_FLAG_CAUSTICS 0x0200
#define ENV_FLAG_UNKNOWN3 0x0400
// From TR3, we need to check
#define SP_FLAT 1
#define SP_SCALE 2
#define SP_BLOOD 4
#define SP_DEF 8
#define SP_ROTATE 16
#define SP_EXPLOSION 32
#define SP_FX 64
#define SP_ITEM 128
#define SP_WIND 256
#define SP_EXPDEF 512
#define SP_USEFXOBJPOS 1024
#define SP_UNDERWEXP 2048
#define SP_NODEATTACH 4096
#define SP_PLASMAEXP 8192
#define SD_EXPLOSION 1
#define SD_UWEXPLOSION 2
#define SEMITRANS 1
#define COLADD 2
#define COLSUB 3
#define WEIRD 4
#define ONESHOT 0x100
#define DATA_TYPE 0x1F
#define DATA_TILT 0xF // tile type (FLOOR_TYPE enum)
#define DATA_STATIC 0xFF // probably add static collision
#define END_BIT 0x8000
#define VALUE_BITS 0x3FF
#define CODE_BITS 0x3e00
#define REVERSE 0x4000
#define SWONESHOT 0x40
#define ATONESHOT 0x80
#define NUM_BATS 64
#define NUM_SPIDERS 64
#define NUM_RATS 32
#define NUM_DEBRIS 256
#define WEAPON_AMMO1 0
#define WEAPON_AMMO2 1
#define WEAPON_AMMO3 2
#define WEAPON_AMMO4 3
#define BLOCKABLE 0x8000
#define BLOCKED 0x4000
#define OVERLAP_INDEX 0x3FFF
#define SEARCH_NUMBER 0x7FFF
#define BLOCKED_SEARCH 0x8000
#define FOLLOW_CENTRE 1
#define NO_CHUNKY 2
#define CHASE_OBJECT 3
#define NO_MINY 0xFFFFFF
#define NO_BOX 0x7FF
#define BOX_JUMP 0x800
#define BOX_MONKEY 0x2000
#define BOX_NUMBER 0x7FF
#define BOX_END_BIT 0x8000
#define EXPAND_LEFT 0x1
#define EXPAND_RIGHT 0x2
#define EXPAND_TOP 0x4
#define EXPAND_BOTTOM 0x8
#define NO_FLYING 0
#define FLY_ZONE 0x2000
#define CLIP_LEFT 1
#define CLIP_RIGHT 2
#define CLIP_TOP 4
#define CLIP_BOTTOM 8
#define ALL_CLIP (CLIP_LEFT|CLIP_RIGHT|CLIP_TOP|CLIP_BOTTOM)
#define SECONDARY_CLIP 16
#define SLOPE_DIF 60
#define LARA_FREEFALL_SPEED 131
#define LARA_LEAN_RATE ANGLE(1.5)
#define LARA_LEAN_MAX ANGLE(11)
#define LARA_TURN_RATE ANGLE(2.25)
#define LARA_JUMP_TURN ANGLE(3)
#define LARA_SLOW_TURN ANGLE(4)
#define LARA_MED_TURN ANGLE(6)
#define LARA_FAST_TURN ANGLE(8)
#define STEPUP_HEIGHT ((STEP_SIZE*3)/2)
#define BAD_JUMP_CEILING ((STEP_SIZE*3)/4)
#define LARA_RAD 100
#define LARA_VELOCITY 12

View file

@ -1,23 +0,0 @@
#pragma once
#include <windows.h>
#include <D3D11.h>
#include <SimpleMath.h>
using namespace DirectX::SimpleMath;
#include "vodoo.h"
#include "constants.h"
#include "enums.h"
#include "objectslist.h"
#include "types.h"
#include "math.h"
#include "macros.h"
#include "malloc.h"
#include "..\Scripting\GameLogicScript.h"
#include "..\Scripting\GameFlowScript.h"
#include "..\Renderer\Renderer11.h"
#pragma warning(disable:4996)

View file

@ -1,29 +0,0 @@
#pragma once
#define RGB555(r, g, b) ((r << 7) & 0x7C00 | (g << 2) & 0x3E0 | (b >> 3) & 0x1F)
#define RED5(rgb) (((rgb >> 10) & 0x1F) << 3)
#define GREEN5(rgb) (((rgb >> 5) & 0x1F) << 3)
#define BLUE5(rgb) ((rgb & 0x1F) << 3)
#define WHITE555 RGB555(255, 255, 255)
#define GRAY555 RGB555(128, 128, 128)
#define BLACK555 RGB555( 0, 0, 0)
#define XZ_GET_SECTOR(room, x, z) (room->floor[((z) >> WALL_SHIFT) + ((x) >> WALL_SHIFT) * room->xSize])
#define ADD_PTR(p, t, n) p = (t*)((char*)(p) + (ptrdiff_t)(n));
///#define ZONE(A) (((A) >> (WALL_SIZE - 2)) - 1)
#define ZONE(A) FlipStatus + 2 * A
#define CHECK_CLICK(x) CLICK(x) / 2
#define RED(rgb) (((rgb) >> 16) & 0xFF)
#define GREEN(rgb) (((rgb) >> 8) & 0xFF)
#define BLUE(rgb) ((rgb) & 0xFF)
#define ALPHA(rgb) (((rgb) >> 24) & 0xFF)
#define MESHES(slot, mesh) Meshes[Objects[slot].meshIndex + mesh]
#define MESH_BITS(x) (1 << x)
#define LARA_MESHES(slot, mesh) Lara.meshPtrs[mesh] = MESHES(slot, mesh)
#define CHECK_LARA_MESHES(slot, mesh) Lara.meshPtrs[mesh] == MESHES(slot, mesh)
#define INIT_LARA_MESHES(mesh, to, from) Lara.meshPtrs[mesh] = LARA_MESHES(to, mesh) = LARA_MESHES(from, mesh)
#define HIDWORD(l) ((DWORD)(((DWORDLONG)(l)>>32)&0xFFFFFFFF))

File diff suppressed because it is too large Load diff

View file

@ -1,19 +0,0 @@
#pragma once
#include <Windows.h>
#pragma pack(push, 1)
typedef struct {
BYTE opCode; // must be 0xE9;
DWORD offset; // jump offset
} JMP;
#pragma pack(pop)
#define INJECT(from,to) { \
((JMP*)(from))->opCode = 0xE9; \
((JMP*)(from))->offset = (DWORD)(to) - ((DWORD)(from) + sizeof(JMP)); \
}
#define VAR_U_(address, type) (*(type*)(address)) // uninitialized variable
#define VAR_I_(address, type, value) (*(type*)(address)) // initialized variable (value is just for info)
#define ARRAY_(address, type, length) (*(type(*)length)(address)) // array (can be multidimensional)

View file

@ -1,13 +1,14 @@
#include "../newobjects.h" #include "framework.h"
#include "../../Game/effect2.h" #include "tr4_bubbles.h"
#include "../../Game/debris.h" #include "effect2.h"
#include "../../Game/items.h" #include "debris.h"
#include "../../Game/traps.h" #include "items.h"
#include "../../Game/draw.h" #include "traps.h"
#include "../../Game/tomb4fx.h" #include "draw.h"
#include "../../Game/effects.h" #include "tomb4fx.h"
#include "..\..\Specific\level.h" #include "effect.h"
#include "../../Game/lara.h" #include "level.h"
#include "lara.h"
void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel) void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel)
{ {
@ -29,7 +30,7 @@ void BubblesEffect1(short fxNum, short xVel, short yVel, short zVel)
spark->dG = spark->dB + 64; spark->dG = spark->dB + 64;
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 4; spark->colFadeSpeed = (GetRandomControl() & 3) + 4;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 16; spark->life = spark->sLife = (GetRandomControl() & 3) + 16;
spark->y = 0; spark->y = 0;
spark->x = (GetRandomControl() & 0xF) - 8; spark->x = (GetRandomControl() & 0xF) - 8;
@ -83,7 +84,7 @@ void BubblesEffect2(short fxNum, short xVel, short yVel, short zVel)
spark->dG = spark->dR = (GetRandomControl() & 0x7F) + 32; spark->dG = spark->dR = (GetRandomControl() & 0x7F) + 32;
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 4; spark->colFadeSpeed = (GetRandomControl() & 3) + 4;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 16; spark->life = spark->sLife = (GetRandomControl() & 3) + 16;
spark->y = 0; spark->y = 0;
spark->x = (GetRandomControl() & 0xF) - 8; spark->x = (GetRandomControl() & 0xF) - 8;
@ -131,7 +132,7 @@ void BubblesEffect3(short fxNum, short xVel, short yVel, short zVel)
spark->dG = spark->dG >> 1; spark->dG = spark->dG >> 1;
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 8; spark->colFadeSpeed = (GetRandomControl() & 3) + 8;
spark->transType = 2; spark->transType = COLADD;
spark->dynamic = -1; spark->dynamic = -1;
spark->life = spark->sLife = (GetRandomControl() & 7) + 32; spark->life = spark->sLife = (GetRandomControl() & 7) + 32;
spark->y = 0; spark->y = 0;
@ -195,7 +196,7 @@ void BubblesEffect4(short fxNum, short xVel, short yVel, short zVel)
} }
spark->fadeToBlack = 8; spark->fadeToBlack = 8;
spark->colFadeSpeed = (GetRandomControl() & 3) + 4; spark->colFadeSpeed = (GetRandomControl() & 3) + 4;
spark->transType = 2; spark->transType = COLADD;
spark->life = spark->sLife = (GetRandomControl() & 3) + 16; spark->life = spark->sLife = (GetRandomControl() & 3) + 16;
spark->y = 0; spark->y = 0;
spark->x = (GetRandomControl() & 0xF) - 8; spark->x = (GetRandomControl() & 0xF) - 8;
@ -223,7 +224,7 @@ void BubblesEffect4(short fxNum, short xVel, short yVel, short zVel)
} }
} }
int BubblesShatterFunction(FX_INFO* fx, int param1, int param2) void BubblesShatterFunction(FX_INFO* fx, int param1, int param2)
{ {
ShatterItem.yRot = fx->pos.yRot; ShatterItem.yRot = fx->pos.yRot;
ShatterItem.meshp = Meshes[fx->frameNumber]; ShatterItem.meshp = Meshes[fx->frameNumber];
@ -233,8 +234,6 @@ int BubblesShatterFunction(FX_INFO* fx, int param1, int param2)
ShatterItem.bit = 0; ShatterItem.bit = 0;
ShatterItem.flags = fx->flag2 & 0x400; ShatterItem.flags = fx->flag2 & 0x400;
ShatterObject(&ShatterItem, 0, param2, fx->roomNumber, param1); ShatterObject(&ShatterItem, 0, param2, fx->roomNumber, param1);
return 1;
} }
void BubblesControl(short fxNum) void BubblesControl(short fxNum)
@ -244,17 +243,17 @@ void BubblesControl(short fxNum)
short angles[2]; short angles[2];
phd_GetVectorAngles( phd_GetVectorAngles(
LaraItem->pos.xPos - fx->pos.xPos, LaraItem->pos.xPos - fx->pos.xPos,
LaraItem->pos.yPos - fx->pos.yPos - 256, LaraItem->pos.yPos - fx->pos.yPos - STEP_SIZE,
LaraItem->pos.zPos - fx->pos.zPos, LaraItem->pos.zPos - fx->pos.zPos,
angles); angles);
int unk1 = 0; // v44 int maxRotation = 0;
int unk2 = 0; // v3 int maxSpeed = 0;
if (fx->flag1 == 1) if (fx->flag1 == 1)
{ {
unk1 = 512; maxRotation = 512;
unk2 = 256; maxSpeed = 256;
} }
else else
{ {
@ -264,16 +263,16 @@ void BubblesControl(short fxNum)
{ {
fx->counter--; fx->counter--;
} }
unk1 = 256; maxRotation = 256;
} }
else else
{ {
unk1 = 768; maxRotation = 768;
} }
unk2 = 192; maxSpeed = 192;
} }
if (fx->speed < unk2) if (fx->speed < maxSpeed)
{ {
if (fx->flag1 == 6) if (fx->flag1 == 6)
{ {
@ -285,29 +284,27 @@ void BubblesControl(short fxNum)
} }
int dy = angles[0] - fx->pos.yRot; int dy = angles[0] - fx->pos.yRot;
if (abs(dy) > ANGLE(180)) if (abs(dy) > ANGLE(180.0f))
{ {
dy = -dy; dy = -dy;
} }
int dx = angles[1] - fx->pos.xRot; int dx = angles[1] - fx->pos.xRot;
if (abs(dx) > ANGLE(180)) if (abs(dx) > ANGLE(180.0f))
{
dx = -dx; dx = -dx;
}
dy >>= 3; dy >>= 3;
dx >>= 3; dx >>= 3;
if (dy < -unk1) if (dy < -maxRotation)
dy = -unk1; dy = -maxRotation;
else if (dy > unk1) else if (dy > maxRotation)
dy = unk1; dy = maxRotation;
if (dx < -unk1) if (dx < -maxRotation)
dx = -unk1; dx = -maxRotation;
else if (dx > unk1) else if (dx > maxRotation)
dx = unk1; dx = maxRotation;
if (fx->flag1 != 4 && (fx->flag1 != 6 || !fx->counter)) if (fx->flag1 != 4 && (fx->flag1 != 6 || !fx->counter))
{ {
@ -318,9 +315,7 @@ void BubblesControl(short fxNum)
fx->pos.zRot += 16 * fx->speed; fx->pos.zRot += 16 * fx->speed;
if (fx->flag1 == 6) if (fx->flag1 == 6)
{
fx->pos.zRot += 16 * fx->speed; fx->pos.zRot += 16 * fx->speed;
}
int oldX = fx->pos.xPos; int oldX = fx->pos.xPos;
int oldY = fx->pos.yPos; int oldY = fx->pos.yPos;
@ -343,21 +338,11 @@ void BubblesControl(short fxNum)
fx->pos.zPos = oldZ; fx->pos.zPos = oldZ;
if (fx->flag1 != 6) if (fx->flag1 != 6)
{
BubblesShatterFunction(fx, 0, -32); BubblesShatterFunction(fx, 0, -32);
}
if (fx->flag1 == 1) if (fx->flag1 == 1)
{ {
TriggerShockwave( TriggerShockwave(&fx->pos, 32, 160, 64, 64, 128, 00, 24, (((~Rooms[fx->roomNumber].flags) >> 4) & 2) << 16, 0);
(PHD_3DPOS*)&fx->pos,
32,
160,
64,
64, 128, 00,
24,
(((~Rooms[fx->roomNumber].flags) >> 4) & 2) << 16, 0);
TriggerExplosionSparks(oldX, oldY, oldZ, 3, -2, 2, fx->roomNumber); TriggerExplosionSparks(oldX, oldY, oldZ, 3, -2, 2, fx->roomNumber);
} }
else else
@ -435,10 +420,9 @@ void BubblesControl(short fxNum)
if (fx->flag1 == 1) if (fx->flag1 == 1)
{ {
TriggerShockwave((PHD_3DPOS*)fx, 48, 240, 64, 64, 128, 0, 24, 0, 0); TriggerShockwave(&fx->pos, 48, 240, 64, 64, 128, 0, 24, 0, 0);
TriggerExplosionSparks(oldX, oldY, oldZ, 3, -2, 2, fx->roomNumber); TriggerExplosionSparks(oldX, oldY, oldZ, 3, -2, 2, fx->roomNumber);
LaraBurn(); LaraBurn();
//Lara.gassed = true; BYTE1(Lara_Flags) |= 2u;
} }
else if (fx->flag1) else if (fx->flag1)
{ {
@ -446,42 +430,34 @@ void BubblesControl(short fxNum)
{ {
case 3: case 3:
case 4: case 4:
TriggerShockwave((PHD_3DPOS*)fx, 32, 160, 64, 128, 64, 0, 16, 0, 1); TriggerShockwave(&fx->pos, 32, 160, 64, 128, 64, 0, 16, 0, 1);
break; break;
case 5: case 5:
TriggerShockwave((PHD_3DPOS*)fx, 32, 160, 64, 0, 96, 128, 16, 0, 2); TriggerShockwave(&fx->pos, 32, 160, 64, 0, 96, 128, 16, 0, 2);
break; break;
case 2: case 2:
TriggerShockwave((PHD_3DPOS*)fx, 32, 160, 64, 0, 128, 128, 16, 0, 2); TriggerShockwave(&fx->pos, 32, 160, 64, 0, 128, 128, 16, 0, 2);
break; break;
case 6: case 6:
TriggerExplosionSparks(oldX, oldY, oldZ, 3, -2, 0, fx->roomNumber); TriggerExplosionSparks(oldX, oldY, oldZ, 3, -2, 0, fx->roomNumber);
TriggerShockwave((PHD_3DPOS*)fx, 48, 240, 64, 0, 96, 128, 24, 0, 0); TriggerShockwave(&fx->pos, 48, 240, 64, 0, 96, 128, 24, 0, 0);
fx->pos.yPos -= 128; fx->pos.yPos -= 128;
TriggerShockwave((PHD_3DPOS*)fx, 48, 240, 48, 0, 112, 128, 16, 0, 0); TriggerShockwave(&fx->pos, 48, 240, 48, 0, 112, 128, 16, 0, 0);
fx->pos.yPos += 256; fx->pos.yPos += 256;
TriggerShockwave((PHD_3DPOS*)fx, 48, 240, 48, 0, 112, 128, 16, 0, 0); TriggerShockwave(&fx->pos, 48, 240, 48, 0, 112, 128, 16, 0, 0);
LaraBurn(); LaraBurn();
break; break;
} }
} }
else else
{ {
TriggerShockwave( TriggerShockwave( &fx->pos, 24, 88, 48, 64, 128, 0, 16, (((~Rooms[fx->roomNumber].flags) >> 4) & 2) << 16, 0);
(PHD_3DPOS*)fx,
24,
88,
48,
64, 128, 0, 16,
(((~Rooms[fx->roomNumber].flags) >> 4) & 2) << 16, 0);
} }
} }
else else
{ {
if (roomNumber != fx->roomNumber) if (roomNumber != fx->roomNumber)
{
EffectNewRoom(fxNum, roomNumber); EffectNewRoom(fxNum, roomNumber);
}
int dx = oldX - fx->pos.xPos; int dx = oldX - fx->pos.xPos;
int dy = oldY - fx->pos.yPos; int dy = oldY - fx->pos.yPos;
@ -498,13 +474,9 @@ void BubblesControl(short fxNum)
else if (fx->flag1 < 3 || fx->flag1 > 5) else if (fx->flag1 < 3 || fx->flag1 > 5)
{ {
if (fx->flag1 == 2) if (fx->flag1 == 2)
{
BubblesEffect2(fxNum, 16 * dx, 16 * dy, 16 * dz); BubblesEffect2(fxNum, 16 * dx, 16 * dy, 16 * dz);
}
else if (fx->flag1 == 6) else if (fx->flag1 == 6)
{
BubblesEffect3(fxNum, 16 * dx, 16 * dy, 16 * dz); BubblesEffect3(fxNum, 16 * dx, 16 * dy, 16 * dz);
}
} }
else else
{ {

Some files were not shown because too many files have changed in this diff Show more