#ifndef STRUCTUREMINE_H_INCLUDED
#define STRUCTUREMINE_H_INCLUDED
#pragma pack(push, 1)

#include "defs.h"

// TYPE_HERE: here you can type your structure definitions like it has been done
// in the "structures.h" file for trng dll

typedef char* LPCHAR;

struct FOOTPRINT
{
    int x;
    int y;
    int z;
    short y_rot;
    short active;
};

// [15] MAX !
enum LARA_MESHES
{
    HIPS,
    THIGH_L, CALF_L, FOOT_L,
    THIGH_R, CALF_R, FOOT_R,
    TORSO,
    UARM_R, LARM_R, HAND_R,
    UARM_L, LARM_L, HAND_L,
    HEAD
};

enum height_types {
    WALL,
    SMALL_SLOPE,
    BIG_SLOPE,
    DIAGONAL,
    SPLIT_TRI
};

enum LARA_WATER_STATUS
{
    LARA_ABOVEWATER,
    LARA_UNDERWATER,
    LARA_SURFACE,
    LARA_CHEAT,
    LARA_WADE
};

enum LARA_HOLD
{
    LG_UNARMED = 0,
    LG_PISTOLS,      // WEAPON
    LG_REVOLVER,     // WEAPON
    LG_UZIS,          // WEAPON
    LG_SHOTGUN,      // WEAPON
    LG_GRENADEGUN,   // WEAPON
    LG_CROSSBOW,     // WEAPON
    LG_FLARE,        // WEAPON
    LG_TORCH,        // ITEM
    LG_FIRED_TORCH,  // ITEM
    LG_JEEP,         // VEHICLE
    LG_SIDECAR,      // VEHICLE
    LG_RUBBERBOAT,   // VEHICLE
    LG_MOTORBOAT,    // VEHICLE
    LG_ROPE,         // ENVIRONMENT
    LG_POLE,         // ENVIRONMENT
    LG_ANY_TORCH,    // ITEM
    LG_KAYAK,        // VEHICLE
    LG_SNOWMOBILE,   // VEHICLE
    LG_MAGNUM,       // WEAPON
    LG_DESERTEAGLE,  // WEAPON
    LG_AUTOPISTOLS,  // WEAPON
    LG_M16,          // WEAPON
    LG_HARPOON,      // WEAPON (to replace TRNG one bugged by Plugin_TR3Aiming)
    LG_QUADBIKE,     // VEHICLE
    LG_MP5,          // WEAPON
    LG_ROCKETGUN,    // WEAPON
    LG_ROCKET_CRASH, // VEHICLE
    LG_UWPROPELLER,  // VEHICLE
    LG_MAX_HOLD      // END_OF_LARA_HOLD (DONT DELETE IT !!)
};

typedef struct {
    sint16 track_mesh;
    int skidoo_turn;
    int left_fallspeed, right_fallspeed;
    sint16 momentum_angle, extra_rotation;
    int pitch;
} SKIDOO_INFO;

typedef struct {
    int x;
    int y;
    int z;
    short y_rot;
    short shade;
    short ocb;
    short static_number;
} MESH_INFO;

typedef struct {
    long x;
    long y;
    long z;
    long r;
} SPHERE;

enum msoff
{
    M00,
    M01,
    M02,
    M03,
    M10,
    M11,
    M12,
    M13,
    M20,
    M21,
    M22,
    M23
};

struct PHD_COLOR
{
    BYTE red;
    BYTE green;
    BYTE blue;
};

struct PHD_VECTOR
{
    int x;
    int y;
    int z;
};

enum MOOD_TYPE
{
    MOOD_BORED,
    MOOD_ATTACK,
    MOOD_ESCAPE,
    MOOD_STALK,
};

struct AI_INFO
{
    short src_zone;
    short target_zone;
    long distance;
    long ahead;
    long bite;
    short angle;
    short x_angle;
    short enemy_facing;
};

struct BITE_INFO
{
    int x;
    int y;
    int z;
    int mesh_num;
};

struct WEAPON_INFO
{
    short lock_angles[4];        // Min/Max for Y,X rots
    short left_angles[4];        // Min/Max for Left arm Aim
    short right_angles[4];        // Min/Max for Right arm Aim
    short aim_speed;            // Speed at which arms lockon
    short shot_accuracy;        // Random angle range for Shot
    short gun_height;            // Height of Gun from Source Origin
    short target_dist;            // Target distance
    char damage;                // Amount of Damage Done
    char recoil_frame;            // Recoil frame for pistol-type guns
    char flash_time;            // How long GunFlash lasts
    char draw_frame;            // Draw frame for mesh-swap
    short sample_num;            // Sample number for Weapon
};

struct COLL_INFO
{
    int mid_floor;                // relative floor and ceiling heights at midpoint
    int mid_ceiling;
    int mid_type;
    int front_floor;            // relative floor and ceiling heights at front
    int front_ceiling;
    int front_type;
    int left_floor;                // relative floor and ceiling heights at front/left side
    int left_ceiling;
    int left_type;
    int right_floor;            // relative floor and ceiling heights at front/right side
    int right_ceiling;
    int right_type;
    int left_floor2;            // relative floor and ceiling heights at front/left side
    int left_ceiling2;
    int left_type2;
    int right_floor2;            // relative floor and ceiling heights at front/right side
    int right_ceiling2;
    int right_type2;
    long radius;                // INPUT Collision Radius...
    long bad_pos, bad_neg;        // INPUT Relative Heights We want to Collide against...
    long bad_ceiling;            // INPUT Relative Bad Ceiling Height...
    PHD_VECTOR shift;            // Shift/Push Values..
    PHD_VECTOR old;                // INPUT Old Positions
    short old_anim_state;        // INPUT old animation
    short old_anim_number;
    short old_frame_number;
    short facing;                // INPUT Angle we are Moving...
    short quadrant;                // Quadrant we are moving ( Not necessarily facing! )
    short coll_type;            // Type of Collision
    short* trigger;                // Trigger info index
    char tilt_x, tilt_z;    // Type of Tilt of Floor
    char hit_by_baddie;         // Flag to indicate Lara has been hit by a Baddie
    char hit_static;            // Flag to indicate Lara has collided with a Static object
    unsigned short slopes_are_walls : 2;// Treat big slopesUp as walls
    unsigned short slopes_are_pits : 1;    // Treat big slopesDown as pits
    unsigned short lava_is_pit : 1;        // Treat Lava as Bad place to go onto
    unsigned short enable_baddie_push : 1;    // Baddies can push Lara
    unsigned short enable_spaz : 1;        // Spaz animations are enabled
    unsigned short hit_ceiling : 1;        // Has Lara hit ceiling? (For up jump only).
};

enum CAMERA_TYPE {
    CHASE_CAMERA,
    FIXED_CAMERA,
    LOOK_CAMERA,
    COMBAT_CAMERA,
    CINEMATIC_CAMERA,
    HEAVY_CAMERA
};

typedef struct
{
    sint16 attack_count;
    sint16 death_count;
    uint8 attack_flag;
    uint8 attack_type;
    uint8 attack_head_count;
    uint8 ring_count;
    sint16 explode_count;
    sint16 lizman_item, lizman_room;
    sint16 hp_counter;
    sint16 dropped_icon;
    uint8 charged;
    uint8 dead;
    PHD_VECTOR beam_target;
} BOSS_STRUCT;

struct LARA_ARM
{
    short *frame_base;
    short frame_number;
    short anim_number;
    short lock;
    short y_rot;
    short x_rot;
    short z_rot;
    short flash_gun;
};

struct PHD_3DPOS {
    int x_pos;
    int y_pos;
    int z_pos;
    short x_rot;
    short y_rot;
    short z_rot;
};

struct BOX_NODE
{
    short exit_box;
    unsigned short search_number;
    short next_expansion;
    short box_number;
};

struct LOT
{
    BOX_NODE* node;
    short head;
    short tail;
    WORD search_number;
    WORD block_mask;
    short step;
    short drop;
    short zone_count;
    short target_box;
    short required_box;
    short fly;
    WORD can_jump : 1;
    WORD can_monkey : 1;
    WORD is_amphibious : 1;
    WORD is_jumping : 1;
    WORD is_monkeying : 1;
    PHD_VECTOR target;
    TYPE_ZONE zone;
};

struct FLOOR_INFO {
    unsigned short index;
    unsigned short fx : 4;      // used with FloorSoundType
    unsigned short box : 11;
    unsigned short stopper : 1;    // Used for pushable blocks in conjunction with the electric cleaner.
    unsigned char pit_room;
    char floor;
    unsigned char sky_room;
    char ceiling;
};

struct BOX_INFO {
    uint8 left, right, top, bottom;
    sint16 height;
    sint16 overlap_index;
};

struct ANIM_STRUCT {
    short* frame_ptr;
    short  interpolation;
    short  current_anim_state;
    int   speed;
    int   fallspeed;
    int   speed_side;
    int   fallspeed_side;
    short  frame_base;
    short  frame_end;
    short  jump_anim_num;
    short  jump_frame_num;
    short  number_changes;
    short  change_index;
    short  number_commands;
    short  command_index;
};

struct SPRITES
{
    unsigned short tile;
    unsigned short offset;
    unsigned short width;
    unsigned short height;
    float left;
    float top;
    float right;
    float bottom;
};

struct PCLIGHT
{
    float x;
    float y;
    float z;
    float r;
    float g;
    float b;
    long shadow;
    float Inner;
    float Outer;
    float InnerAngle;
    float OuterAngle;
    float Cutoff;
    float nx;
    float ny;
    float nz;
    long ix;
    long iy;
    long iz;
    long inx;
    long iny;
    long inz;
    float tr;
    float tg;
    float tb;
    float rs;
    float gs;
    float bs;
    long fcnt;
    uchar Type;
    uchar Active;
    PHD_VECTOR rlp;
    long Range;
};

struct ITEM_LIGHT
{
    long r;
    long g;
    long b;
    long ambient;
    long rs;
    long gs;
    long bs;
    long fcnt;
    PCLIGHT CurrentLights[21];
    PCLIGHT PrevLights[21];
    long nCurrentLights;
    long nPrevLights;
    long room_number;
    long RoomChange;
    PHD_VECTOR item_pos;
    void* pCurrentLights;
    void* pPrevLights;
};

struct SPARKS
{
    int x;
    int y;
    int 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;
    char RotAdd;
    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;
    unsigned char TransType;
    unsigned char extras;
    char Dynamic;
    unsigned char FxObj;
    unsigned char RoomNumber;
    unsigned char NodeNumber;
};

struct PISTOL_DEF
{
    sint16 ObjectNum;
    char Draw1Anim2;
    char Draw1Anim;
    char Draw2Anim;
    char RecoilAnim;
};

struct OBJECT_INFO {
    short  nmeshes;
    short  mesh_index;
    int   bone_index;
    short*   frame_base;
    LPVOID initialise;
    LPVOID control;
    LPVOID floor;
    LPVOID ceiling;
    LPVOID draw;
    LPVOID collision;
    short object_mip;
    short anim_index;
    short hit_points;
    short pivot_length;
    short radius;
    short shadow_size;
    WORD bit_offset;
    WORD loaded : 1;
    WORD intelligent : 1;
    WORD non_lot : 1;
    WORD save_position : 1;
    WORD save_hitpoints : 1;
    WORD save_flags : 1;
    WORD save_anim : 1;
    WORD semi_transparent : 1;
    WORD water_creature : 1;
    WORD using_drawanimating_item : 1;
    WORD hit_effect : 2;
    WORD undead : 1;
    WORD save_mesh : 1;
    LPVOID draw_extra;
    DWORD explodable_meshbits;
    DWORD pad;
};

struct ITEM_INFO {
    int floor;
    DWORD touch_bits;
    DWORD mesh_bits;                // (MESH_BITS_ flags)
    short object_number;
    short current_anim_state;
    short goal_anim_state;
    short required_anim_state;
    short anim_number;
    short frame_number;
    short room_number;
    short next_item;
    short next_active;
    short speed;
    short fallspeed;
    short hit_points;
    WORD box_number;
    short timer;
    short flags;                     // For oneshot and code switches (i.e. NOT flags)
    short intensity;
    short ocb_bits;
    short carried_items;             // bad guys hold whatever pickup
    short after_death;
    WORD fired_weapon;
    short reserved_1;
    short reserved_2;
    short reserved_3;
    short reserved_4;                // (ZONE_ enum)
    LPVOID data;
    PHD_3DPOS pos;
    ITEM_LIGHT il;
    DWORD active : 1;
    DWORD status : 2;               // (STS_ flags)
    DWORD gravity_status : 1;
    DWORD hit_status : 1;           // (HIT_ flags)
    DWORD collidable : 1;
    DWORD looked_at : 1;
    DWORD dynamic_light : 1;
    DWORD poisoned : 1;
    DWORD ai_bits : 5;              // (SAI_ flags)
    DWORD really_active : 1;
    DWORD meshswap_meshbits;
    short draw_room;
    short TOSSPAD;
};

struct CREATURE_INFO
{
    short joint_rotation[4];
    short maximum_turn;
    short flags;
    WORD alerted : 1;
    WORD head_left : 1;
    WORD head_right : 1;
    WORD reached_goal : 1;
    WORD hurt_by_lara : 1;
    WORD patrol2 : 1;
    WORD jump_ahead : 1;
    WORD monkey_ahead : 1;
    MOOD_TYPE mood;
    ITEM_INFO* enemy;
    ITEM_INFO ai_target;
    short unknown_field1;
    short item_num;
    PHD_VECTOR target;
    LOT LOT;
};

struct FX_INFO {
    PHD_3DPOS pos;
    short room_number;
    short object_number;
    short next_fx;
    short next_active;
    short speed;
    short fallspeed;
    short frame_number;
    short counter;
    short shade;
    short flag1;
    short flag2;
};

struct SMOKE_SPARKS
{
    long x;
    long y;
    long 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;
    char RotAdd;
    char MaxYvel;
    unsigned char On;
    unsigned char sShade;
    unsigned char dShade;
    unsigned char Shade;
    unsigned char ColFadeSpeed;
    unsigned char FadeToBlack;
    char sLife;
    char Life;
    unsigned char TransType;
    unsigned char FxObj;
    unsigned char NodeNumber;
    unsigned char mirror;
};

struct FIRE_LIST
{
    long x;
    long y;
    long z;
    char on;
    char size;
    short room_number;
};

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;
    char RotAdd;
    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;
};

struct SOUND_SLOT
{
    int OrigVolume;
    int nVolume;
    int nPan;
    int nPitch;
    int nSampleInfo;
    DWORD distance;
    PHD_VECTOR pos;
};

struct AIOBJECT
{
	short object_number;
	short room_number;
	long x;
	long y;
	long z;
	short trigger_flags;
	short flags;
	short y_rot;
	short box_number;
};

struct CHANGE_STRUCT
{
	short goal_anim_state;
	short number_ranges;
	short range_index;
};

struct RANGE_STRUCT
{
	short start_frame;
	short end_frame;
	short link_anim_num;
	short link_frame_num;
};

struct GAMEVECTOR
{
    long x;
    long y;
    long z;
	short room_number;
	short box_number;
};

struct StrGunflashArguments
{
	ITEM_INFO* item;
	int mesh_num;
};

struct StrPatrolPickupArguments {
	ITEM_INFO *item;
	AIOBJECT *ai;
};

struct StrVaultArguments {
	ITEM_INFO *item;
	int vault;
};

struct StrConfiguration
{
	WORD Slot;
	DWORD FunctionSupport, QuerySupport;
};

// --------------- PRESET STRUCTURE ZONE -----------------------------
// Please, don't remove structures and fields you find in this "PRESET ZONE". They will be used by some
// preset functions of your plugin sources
// However, you can add new fields and structures in following structures, of course
typedef struct StrSavegameGlobalData {
    // FOR_YOU:
    // define here your variables that you wish were saved (and then restored) to/from savegame in GLOBAL section 
    //           (only one for all levels)
    // note: the size of this structure should be always even (if you add BYTE variable, remember to compensate that 
    //       with another BYTE vairable or placefolder)

}SavegameGlobalDataFields;

typedef struct StrSavegameLocalData {
    // FOR_YOU:
    // define here your variables that you wish were saved (and then restored) to/from savegame in LOCAL section (one for each different level)
    // note: the size of this structure should be always even (if you add BYTE variable, compensate it with another BYTE vairable or placefolder)
    
    int monks_attack_lara;
    bool dragon_cinematic;
    bool dragon_enabled;
    short dragon_back_number; // index
    short marco_ocb;
    ITEM_INFO* dragon_front, *dragon_back; // for sync
	short poisoned;
	short dpoisoned;
}SavegameLocalDataFields;


typedef struct StrSavegameData {
    StrSavegameGlobalData all;
    StrSavegameLocalData  current;
}SavegameDataFields;


typedef struct StrBaseAssignSlotMine {
    int TotAssign;
    StrRecordAssSlot VetAssignSlot[MAX_ASSIGN_SLOT_MINE];
}BaseAssignSlotMineFields;

typedef struct StrMyData {
    StrSavegameData save;  // variable that it will be saved and restored to/from savegame
    // FOR_YOU:
    // define here all your global variables, i.e. those variables that will be seen from all procedures and keep 
    // their value between all cycles of the game.
    // after you defined a variabile like:
    // int  Alfa;
    // then you'll be able to access to them using syntax like:
    // MyData.Alfa = 3;
    // if (MyData.Alfa == 5) .
    int TotProgrActions;
    int LastProgrActionIndex; // used in case of overloading

    StrProgressiveAction VetProgrActions[MAX_MYPROGR_ACTIONS];
    StrBaseGenericCustomize BaseCustomizeMine;  // stored all your customize script commands for current level
    StrBaseGenericParameters BaseParametersMine; // store of all your parameters= script commands of current level
    StrBaseAssignSlotMine BaseAssignSlotMine; // stored all AssignSlot= command script commands of current level
}MyDataFields;
// ----------------- END PRESET STRUCTURE ZONE ---------------------------------------

#define OBJECT_VERSION 129

// TR3 state.
enum lara_states {
    AS_WALK = 0,
    AS_RUN,
    AS_STOP,
    AS_FORWARDJUMP,
    AS_POSE,
    AS_FASTBACK,
    AS_TURN_R,
    AS_TURN_L,
    AS_DEATH,
    AS_FASTFALL,
    AS_HANG,
    AS_REACH,
    AS_SPLAT,
    AS_TREAD,
    AS_LAND,
    AS_COMPRESS,
    AS_BACK,
    AS_SWIM,
    AS_GLIDE,
    AS_NULL,
    AS_FASTTURN,
    AS_STEPRIGHT,
    AS_STEPLEFT,
    AS_HIT,
    AS_SLIDE,
    AS_BACKJUMP,
    AS_RIGHTJUMP,
    AS_LEFTJUMP,
    AS_UPJUMP,
    AS_FALLBACK,
    AS_HANGLEFT,
    AS_HANGRIGHT,
    AS_SLIDEBACK,
    AS_SURFTREAD,
    AS_SURFSWIM,
    AS_DIVE,
    AS_PUSHBLOCK,
    AS_PULLBLOCK,
    AS_PPREADY,
    AS_PICKUP,
    AS_SWITCHON,
    AS_SWITCHOFF,
    AS_USEKEY,
    AS_USEPUZZLE,
    AS_UWDEATH,
    AS_ROLL,
    AS_SPECIAL,
    AS_SURFBACK,
    AS_SURFLEFT,
    AS_SURFRIGHT,
    AS_USEMIDAS,
    AS_DIEMIDAS,
    AS_SWANDIVE,
    AS_FASTDIVE,
    AS_GYMNAST,
    AS_WATEROUT,
    AS_CLIMBSTNC,
    AS_CLIMBING,
    AS_CLIMBLEFT,
    AS_CLIMBEND,
    AS_CLIMBRIGHT,
    AS_CLIMBDOWN,
    AS_LARATEST1,
    AS_LARATEST2,
    AS_LARATEST3,
    AS_WADE,
    AS_WATERROLL,
    AS_FLAREPICKUP,
    AS_TWIST,
    AS_KICK,
    AS_DEATHSLIDE,
    AS_DUCK,
    AS_DUCKROLL,
    AS_DASH,
    AS_DASHDIVE,
    AS_HANG2,
    AS_MONKEYSWING,
    AS_MONKEYL,
    AS_MONKEYR,
    AS_MONKEY180,
    AS_ALL4S,
    AS_CRAWL,
    AS_HANGTURNL,
    AS_HANGTURNR,
    AS_ALL4TURNL,
    AS_ALL4TURNR,        // 85
    AS_CRAWLBACK,
    AS_HANG2DUCK,
    AS_CRAWL2HANG,
    AS_LAST
};

enum spark_flags
{
	SF_NONE =			0x0,
	SF_UNUSED1 =		0x1,
	SF_SCALE =			0x2,	//scale using sptr->Scalar
	SF_BLOOD =			0x4,	//set for blood only, to avoid killing it in GetFreeSpark if no free slots are found.
	SF_DEF =			0x8,	//use sptr->Def for the drawn sprite (otherwise do flat quad)
	SF_ROTATE =			0x10,	//rotate the drawn sprite (only supported for sparks with SF_DEF)
	SF_UNUSED2 =		0x20,
	SF_FX =				0x40,	//spark is attached to an effect
	SF_ITEM =			0x80,	//spark is attached to an item
	SF_OUTSIDE =		0x100,	//spark is affected by wind
	SF_ALTDEF =			0x200,	//alters sptr->Def based on spark colors (for smoke)
	SF_ATTACHEDPOS =	0x400,	//spark uses the position of the FX/ITEM it is attached to
	SF_UNWATER =		0x800,	//for underwater explosions to create bubbles etc.
	SF_ATTACHEDNODE =	0x1000,	//spark is attached to an item node, uses NodeOffsets
	SF_GREEN =			0x2000,	//turns the spark into a green-ish blue (for explosions only)
};

#pragma pack(pop)
#endif