2018-08-19 09:46:58 +02:00
|
|
|
#pragma once
|
2020-05-30 15:55:23 +02:00
|
|
|
#include "phd_global.h"
|
|
|
|
#include "items.h"
|
|
|
|
#include "level.h"
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef enum MOOD_TYPE
|
|
|
|
{
|
|
|
|
BORED_MOOD,
|
|
|
|
ATTACK_MOOD,
|
|
|
|
ESCAPE_MOOD,
|
|
|
|
STALK_MOOD
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef enum TARGET_TYPE
|
|
|
|
{
|
|
|
|
NO_TARGET,
|
|
|
|
PRIME_TARGET,
|
|
|
|
SECONDARY_TARGET
|
|
|
|
};
|
|
|
|
|
2020-06-04 11:00:08 +02:00
|
|
|
typedef enum ZoneType
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2020-06-10 21:38:25 +02:00
|
|
|
typedef struct OBJECT_BONES
|
|
|
|
{
|
|
|
|
short bone0;
|
|
|
|
short bone1;
|
|
|
|
short bone2;
|
|
|
|
short bone3;
|
|
|
|
|
|
|
|
OBJECT_BONES()
|
|
|
|
{
|
|
|
|
this->bone0 = 0;
|
|
|
|
this->bone1 = 0;
|
|
|
|
this->bone2 = 0;
|
|
|
|
this->bone3 = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBJECT_BONES(short all)
|
|
|
|
{
|
|
|
|
this->bone0 = all;
|
|
|
|
this->bone1 = all;
|
2020-06-14 08:45:45 +02:00
|
|
|
this->bone2 = all;
|
|
|
|
this->bone3 = all;
|
2020-06-10 21:38:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
OBJECT_BONES(short angleY, short angleX)
|
|
|
|
{
|
|
|
|
this->bone0 = angleY;
|
|
|
|
this->bone1 = angleX;
|
|
|
|
this->bone2 = angleY;
|
|
|
|
this->bone3 = angleX;
|
|
|
|
}
|
|
|
|
|
|
|
|
OBJECT_BONES(short angleY, short angleX, bool total)
|
|
|
|
{
|
|
|
|
this->bone0 = angleY;
|
|
|
|
this->bone1 = angleX;
|
|
|
|
if (total)
|
|
|
|
{
|
|
|
|
this->bone2 = angleY;
|
|
|
|
this->bone3 = angleX;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->bone2 = 0;
|
|
|
|
this->bone3 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef struct BOX_NODE
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
short exitBox;
|
|
|
|
unsigned short searchNumber;
|
|
|
|
short nextExpansion;
|
|
|
|
short boxNumber;
|
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef struct BOX_INFO
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
unsigned char left;
|
|
|
|
unsigned char right;
|
|
|
|
unsigned char top;
|
|
|
|
unsigned char bottom;
|
|
|
|
short height;
|
|
|
|
short overlapIndex;
|
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef struct AI_INFO
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
short zoneNumber;
|
|
|
|
short enemyZone;
|
|
|
|
int distance;
|
|
|
|
int ahead;
|
|
|
|
int bite;
|
|
|
|
short angle;
|
|
|
|
short xAngle;
|
|
|
|
short enemyFacing;
|
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef struct BITE_INFO
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int z;
|
|
|
|
int meshNum;
|
2020-06-06 14:38:43 +02:00
|
|
|
|
|
|
|
BITE_INFO()
|
|
|
|
{
|
|
|
|
this->x = 0;
|
|
|
|
this->y = 0;
|
|
|
|
this->z = 0;
|
|
|
|
this->meshNum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BITE_INFO(int xpos, int ypos, int zpos, int meshNumber)
|
|
|
|
{
|
|
|
|
this->x = xpos;
|
|
|
|
this->y = ypos;
|
|
|
|
this->z = zpos;
|
|
|
|
this->meshNum = meshNumber;
|
|
|
|
}
|
2020-05-28 15:17:34 +02:00
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef struct LOT_INFO
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
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;
|
2020-06-04 11:00:08 +02:00
|
|
|
ZoneType zone;
|
2020-05-28 15:17:34 +02:00
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
typedef struct CREATURE_INFO
|
2020-05-28 15:17:34 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
2018-08-19 09:46:58 +02:00
|
|
|
|
2020-06-08 13:11:10 +02:00
|
|
|
struct EntityStoringInfo
|
|
|
|
{
|
|
|
|
// position of the entity
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int z;
|
|
|
|
// waterLevel is mostly -NO_HEIGHT but if the position are in water then it's 0
|
|
|
|
// waterDepth is the depth starting for the water room ceiling (0) and increase 1 by 1
|
|
|
|
// to store from GetWaterDepth() and GetWaterHeight()
|
|
|
|
int waterLevel;
|
|
|
|
int waterDepth;
|
|
|
|
// to store roomNumber from GetFloor()
|
|
|
|
short roomNumber;
|
|
|
|
// store the boxNumber from LOT or from room->floor[].box
|
|
|
|
short boxNumber;
|
|
|
|
|
|
|
|
EntityStoringInfo()
|
|
|
|
{
|
|
|
|
this->x = 0;
|
|
|
|
this->y = 0;
|
|
|
|
this->z = 0;
|
|
|
|
this->waterLevel = 0;
|
|
|
|
this->waterDepth = 0;
|
|
|
|
this->roomNumber = 0;
|
|
|
|
this->boxNumber = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EntityStoringInfo(int xpos, int ypos, int zpos)
|
|
|
|
{
|
|
|
|
this->x = xpos;
|
|
|
|
this->y = ypos;
|
|
|
|
this->z = zpos;
|
|
|
|
this->waterLevel = 0;
|
|
|
|
this->waterDepth = 0;
|
|
|
|
this->roomNumber = 0;
|
|
|
|
this->boxNumber = 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-30 15:55:23 +02:00
|
|
|
#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;
|
|
|
|
|
2020-01-16 19:14:35 +01:00
|
|
|
extern int NumberBoxes;
|
|
|
|
extern BOX_INFO* Boxes;
|
|
|
|
extern int NumberOverlaps;
|
|
|
|
extern short* Overlaps;
|
2020-05-28 15:17:34 +02:00
|
|
|
extern short* Zones[ZONE_MAX][2];
|
|
|
|
|
2019-12-02 14:49:19 +01:00
|
|
|
void GetCreatureMood(ITEM_INFO* item, AI_INFO* info, int violent);
|
|
|
|
void CreatureMood(ITEM_INFO* item, AI_INFO* info, int violent);
|
|
|
|
void FindAITargetObject(CREATURE_INFO* creature, short objectNumber);
|
|
|
|
void GetAITarget(CREATURE_INFO* creature);
|
|
|
|
int CreatureVault(short itemNum, short angle, int vault, int shift);
|
|
|
|
void DropBaddyPickups(ITEM_INFO* item);
|
|
|
|
int MoveCreature3DPos(PHD_3DPOS* srcpos, PHD_3DPOS* destpos, int velocity, short angdif, int angadd);
|
|
|
|
void CreatureYRot2(PHD_3DPOS* srcpos, short angle, short angadd);
|
|
|
|
short SameZone(CREATURE_INFO* creature, ITEM_INFO* targetItem);
|
|
|
|
void FindAITargetObject(CREATURE_INFO* creature, short objNum);
|
|
|
|
short AIGuard(CREATURE_INFO* creature);
|
|
|
|
void AlertNearbyGuards(ITEM_INFO* item);
|
|
|
|
void AlertAllGuards(short itemNumber);
|
|
|
|
void CreatureKill(ITEM_INFO* item, int killAnim, int killState, short laraAnim);
|
2020-05-28 15:17:34 +02:00
|
|
|
short CreatureEffect2(ITEM_INFO* item, BITE_INFO* bite, short damage, short angle, function<CreatureEffectFunction> func);
|
|
|
|
short CreatureEffect(ITEM_INFO* item, BITE_INFO* bite, function<CreatureEffectFunction> func);
|
2019-12-02 14:49:19 +01:00
|
|
|
void CreatureUnderwater(ITEM_INFO* item, int depth);
|
|
|
|
void CreatureFloat(short itemNumber);
|
|
|
|
void CreatureJoint(ITEM_INFO* item, short joint, short required);
|
|
|
|
void CreatureTilt(ITEM_INFO* item, short angle);
|
2019-12-14 18:24:06 +01:00
|
|
|
short CreatureTurn(ITEM_INFO* item, short maximumTurn);
|
2019-12-02 14:49:19 +01:00
|
|
|
void CreatureDie(short itemNumber, int explode);
|
|
|
|
int BadFloor(int x, int y, int z, int boxHeight, int nextHeight, short roomNumber, LOT_INFO* LOT);
|
|
|
|
int CreatureCreature(short itemNumber);
|
|
|
|
int ValidBox(ITEM_INFO* item, short zoneNumber, short boxNumber);
|
|
|
|
int EscapeBox(ITEM_INFO* item, ITEM_INFO* enemy, short boxNumber);
|
|
|
|
void TargetBox(LOT_INFO* LOT, short boxNumber);
|
|
|
|
int UpdateLOT(LOT_INFO* LOT, int expansion);
|
|
|
|
int SearchLOT(LOT_INFO* LOT, int expansion);
|
|
|
|
int CreatureActive(short itemNumber);
|
|
|
|
void InitialiseCreature(short itemNumber);
|
|
|
|
int StalkBox(ITEM_INFO* item, ITEM_INFO* enemy, short boxNumber);
|
|
|
|
void CreatureAIInfo(ITEM_INFO* item, AI_INFO* info);
|
|
|
|
TARGET_TYPE CalculateTarget(PHD_VECTOR* target, ITEM_INFO* item, LOT_INFO* LOT);
|
|
|
|
int CreatureAnimation(short itemNumber, short angle, short tilt);
|
2019-12-23 23:10:24 +01:00
|
|
|
void AdjustStopperFlag(ITEM_INFO* item, int dir, int set);
|
2018-08-19 09:46:58 +02:00
|
|
|
|
|
|
|
|