101 lines
2.7 KiB
C
101 lines
2.7 KiB
C
#pragma once
|
|
#include "main.h"
|
|
#include "physics.h"
|
|
#include "ai.h"
|
|
#include "outfit.h"
|
|
#include "faction.h"
|
|
#include "ship.h"
|
|
|
|
// Aproximation for pilot size.
|
|
#define PILOT_SIZE_APROX 0.8
|
|
#define PILOT_DISABLED 0.2 // Based on armor percentage.
|
|
|
|
// Flags.
|
|
// Creation.
|
|
#define PILOT_PLAYER (1<<0) // Pilot is a player.
|
|
// Dynamic.
|
|
#define pilot_isFlag(p,f) (p->flags & f)
|
|
#define pilot_setFlag(p,f) (p->flags |= f)
|
|
#define pilot_rmFlag(p,f) (p->flags ^= f)
|
|
#define PILOT_ATTACKED (1<<9) // Pilot is under attack.
|
|
|
|
typedef struct {
|
|
Outfit* outfit; // Associated outfit.
|
|
unsigned int quantity; // Number of outfits of this type that the pilot has.
|
|
unsigned int timer; // Used to store last used weapon time.
|
|
} PilotOutfit;
|
|
|
|
// Primary pilot structure.
|
|
typedef struct Pilot {
|
|
unsigned int id; // Pilots id.
|
|
char* name; // Pilot's name (if unique).
|
|
|
|
Faction* faction;
|
|
|
|
// Object characteristics.
|
|
Ship* ship; // Pilots ship.
|
|
Solid* solid; // Associated solid (physics).
|
|
|
|
// Current health.
|
|
double armor, shield, energy;
|
|
double armor_max, shield_max, energy_max;
|
|
|
|
void (*think)(struct Pilot*); // AI thinking for the pilot.
|
|
void (*update)(struct Pilot*, const double); // Update the pilot.
|
|
void (*render)(struct Pilot*); // Rendering the pilot.
|
|
|
|
// Outfit management.
|
|
PilotOutfit* outfits;
|
|
int noutfits;
|
|
|
|
unsigned int flags; // Used for AI etc.
|
|
|
|
// AI.
|
|
AI_Profile* ai; // Ai personality profile.
|
|
Task* task; // Current action.
|
|
} Pilot;
|
|
|
|
// Fleets.
|
|
typedef struct {
|
|
Ship* ship; // Ship that the pilot is flying.
|
|
char* name; // For special 'unique' names.
|
|
int chance; // Chance of this pilot appearing in the fleet.
|
|
} FleetPilot;
|
|
|
|
typedef struct {
|
|
char* name; // Fleet name, used as an identifier.
|
|
Faction* faction; // Faction of the fleet.
|
|
|
|
AI_Profile* ai; // A useable profile.
|
|
|
|
FleetPilot* pilots; // The pilots in the fleet.
|
|
int npilots; // Total number of pilots.
|
|
} Fleet;
|
|
|
|
// Grabing pilot crap.
|
|
extern Pilot* player; // The player.
|
|
Pilot* pilot_get(unsigned int id);
|
|
unsigned int pilot_getNext(unsigned int id);
|
|
Fleet* fleet_get(const char* name);
|
|
|
|
// MISC.
|
|
void pilot_shoot(Pilot* p, const int secondary);
|
|
void pilot_hit(Pilot* p, const double damage_shield, const double damage_armor);
|
|
|
|
// Creation.
|
|
void pilot_init(Pilot* dest, Ship* ship, char* name, Faction* faction, AI_Profile* ai,
|
|
const double dir, const Vec2* pos, const Vec2* vel, const int flags);
|
|
|
|
unsigned int pilot_create(Ship* ship, char* name, Faction* faction, AI_Profile* ai,
|
|
const double dir, const Vec2* pos, const Vec2* vel, const int flags);
|
|
|
|
// Init/Cleanup.
|
|
void pilot_destroy(Pilot* p);
|
|
void pilots_free(void);
|
|
int fleet_load(void);
|
|
void fleet_free(void);
|
|
|
|
// Update.
|
|
void pilots_update(double dt);
|
|
|