6#include "pilot_flags.h"
24#define HYPERSPACE_ENGINE_DELAY 3.
25#define HYPERSPACE_FLY_DELAY 5.
26#define HYPERSPACE_DUST_BLUR \
28#define HYPERSPACE_DUST_LENGTH \
30#define HYPERSPACE_FADEOUT 1.
31#define HYPERSPACE_FADEIN 1.
32#define HYPERSPACE_ACCEL \
35#define HYPERSPACE_VEL \
36 ( 2. * HYPERSPACE_ACCEL * \
37 HYPERSPACE_FLY_DELAY )
38#define HYPERSPACE_ENTER_MIN \
39 ( HYPERSPACE_VEL * 0.3 )
40#define HYPERSPACE_ENTER_MAX \
41 ( HYPERSPACE_VEL * 0.4 )
42#define HYPERSPACE_EXIT_MIN 1500.
44#define PILOT_LANDING_DELAY 1.
45#define PILOT_TAKEOFF_DELAY 1.
47#define PILOT_REFUEL_TIME 3.
49#define PILOT_SIZE_APPROX 0.8
50#define PILOT_WEAPON_SETS 12
51#define PILOT_REVERSE_THRUST \
53#define PILOT_PLAYER_NONTARGETABLE_TAKEOFF_DELAY \
55#define PILOT_PLAYER_NONTARGETABLE_JUMPIN_DELAY \
59typedef enum PilotHookType_ {
73 PILOT_HOOK_DISCOVERED,
84#define PILOT_HOSTILE_THRESHOLD \
86#define PILOT_HOSTILE_DECAY 0.005
89#define pilot_isPlayer( p ) \
90 pilot_isFlag( p, PILOT_PLAYER )
91#define pilot_isDisabled( p ) \
92 pilot_isFlag( p, PILOT_DISABLED )
93#define pilot_isStopped( p ) ( VMOD( p->solid.vel ) <= MIN_VEL_ERR )
96#define pilot_isWithPlayer( p ) \
97 ( ( p )->faction == FACTION_PLAYER || ( ( p )->parent == PLAYER_ID ) )
104typedef enum PilotOutfitState_ {
108 PILOT_OUTFIT_COOLDOWN
114typedef struct PilotOutfitAmmo_ {
121#define PILOTOUTFIT_ACTIVE \
124#define PILOTOUTFIT_TOGGLEABLE \
126#define PILOTOUTFIT_ISON ( 1 << 2 )
127#define PILOTOUTFIT_VOLLEY \
129#define PILOTOUTFIT_INRANGE \
132#define PILOTOUTFIT_MANUAL \
134#define PILOTOUTFIT_ISON_TOGGLE \
137#define PILOTOUTFIT_ISON_HOLD ( 1 << 8 )
138#define PILOTOUTFIT_DYNAMIC_FLAGS \
139 ( PILOTOUTFIT_VOLLEY | PILOTOUTFIT_INRANGE | PILOTOUTFIT_MANUAL | \
140 PILOTOUTFIT_ISON_TOGGLE | PILOTOUTFIT_ISON_HOLD )
145typedef struct PilotOutfitSlot_ {
187typedef struct PilotWeaponSetOutfit_ {
195typedef enum WeaponSetType_ {
196 WEAPSET_TYPE_DEFAULT = 0,
197 WEAPSET_TYPE_HOLD = 1,
198 WEAPSET_TYPE_TOGGLE = 2,
207typedef struct PilotWeaponSet_ {
223typedef struct PilotCommodity_ {
232typedef struct PilotHook_ {
240typedef enum EscortType_e {
244 ESCORT_TYPE_MERCENARY,
252typedef struct Escort_s {
263typedef struct Pilot_ {
449#include "pilot_cargo.h"
451#include "pilot_heat.h"
452#include "pilot_hook.h"
453#include "pilot_outfit.h"
454#include "pilot_weapon.h"
464 double target_mass_UB );
467 double health_factor,
468 double damage_factor,
469 double range_factor );
470unsigned int pilot_getNearestHostile(
void );
476 double y,
int disabled );
497 const Pilot *parent );
517 const char *ai,
double dir,
const vec2 *pos,
518 const vec2 *vel,
const PilotFlags flags,
519 unsigned int dockpilot,
int dockslot );
527 int ignore_rules,
int guerilla );
577 unsigned int index );
584int pilot_hasDeployed(
const Pilot *p );
589const IntList *pilot_collideQuery(
int x1,
int y1,
int x2,
int y2 );
590void pilot_collideQueryIL(
IntList *il,
int x1,
int y1,
int x2,
int y2 );
char pilot_getFactionColourChar(const Pilot *p)
Gets the faction colour char, works like faction_reputationColourChar but for a pilot.
void pilot_free(Pilot *p)
Frees and cleans up a pilot.
void pilot_stackRemove(Pilot *p)
Tries to remove a pilot from the stack.
unsigned int pilot_getNearestEnemy_size(const Pilot *p, double target_mass_LB, double target_mass_UB)
Gets the nearest enemy to the pilot closest to the pilot whose mass is between LB and UB.
void pilot_choosePoint(vec2 *vp, Spob **spob, JumpPoint **jump, int lf, int ignore_rules, int guerilla)
Finds a spawn point for a pilot.
int pilot_isHostile(const Pilot *p)
Checks to see if pilot is hostile to the player.
void pilot_updateDisable(Pilot *p, unsigned int shooter)
Handles pilot disabling. Set or unset the disable status depending on health and stress values.
void pilot_cooldown(Pilot *p, int dochecks)
Begins active cooldown, reducing hull and outfit temperatures.
int pilot_brakeCheckReverseThrusters(const Pilot *p)
See if the pilot wants to use their reverse thrusters to brake.
void pilot_renderFramebuffer(Pilot *p, GLuint fbo, double fw, double fh, const Lighting *L)
Renders a pilot to a framebuffer.
void pilot_rmHostile(Pilot *p)
Unmarks a pilot as hostile to player.
unsigned int pilot_addStack(Pilot *p)
Adds a pilot to the stack.
void pilots_updatePurge(void)
Purges pilots set for deletion.
void pilot_quadtreeParams(int max_elem, int depth)
Sets the quad tree parameters. Can have significant impact on performance.
double pilot_relhp(const Pilot *cur_pilot, const Pilot *p)
Gets the relative hp(combined shields and armour) between the current pilot and the specified target.
int pilot_validEnemy(const Pilot *p, const Pilot *target)
Checks to see if a pilot is a valid enemy for another pilot.
double pilot_relsize(const Pilot *cur_pilot, const Pilot *p)
Gets the relative size(shipmass) between the current pilot and the specified target.
int pilot_areEnemies(const Pilot *p, const Pilot *target)
Like areEnemies but for pilots.
void pilots_clear(void)
Clears all the pilots except the player and clear-exempt pilots.
unsigned int pilot_getNearestPilot(const Pilot *p)
Get the nearest pilot to a pilot.
void pilots_clean(int persist)
Cleans up the pilot stack - leaves the player.
Pilot * pilot_getTarget(Pilot *p)
Gets the target of a pilot using a fancy caching system.
Pilot * pilot_createEmpty(const Ship *ship, const char *name, int faction, PilotFlags flags)
Creates a pilot without adding it to the stack.
double pilot_face(Pilot *p, double dir, double dt)
Tries to turn the pilot to face dir.
mat4 pilot_local_transform(const Pilot *p)
Gets the local transformation matrix of a pilot.
double pilot_getNearestPos(const Pilot *p, unsigned int *tp, double x, double y, int disabled)
Get the nearest pilot to a pilot from a certain position.
void pilot_clearTimers(Pilot *pilot)
Clears the pilot's timers.
double pilot_reldps(const Pilot *cur_pilot, const Pilot *p)
Gets the relative damage output(total DPS) between the current pilot and the specified target.
void pilot_msg(const Pilot *p, const Pilot *receiver, const char *type, unsigned int idx)
Sends a message.
void pilot_dead(Pilot *p, unsigned int killer)
Pilot is dead, now will slowly explode.
Pilot * pilot_setPlayer(Pilot *after)
Replaces the player's pilot with an alternate ship with the same ID.
void pilot_renderOverlay(Pilot *p)
Renders the pilot overlay.
void pilot_setAccel(Pilot *p, double accel)
Sets the pilot's accel.
void pilot_cooldownEnd(Pilot *p, const char *reason)
Terminates active cooldown.
credits_t pilot_modCredits(Pilot *p, credits_t amount)
Modifies the amount of credits the pilot has.
unsigned int pilot_getNearestEnemy(const Pilot *p)
Gets the nearest enemy to the pilot.
void pilot_setFriendly(Pilot *p)
Marks pilot as friendly to player.
void pilot_hyperspaceAbort(Pilot *p)
Stops the pilot from hyperspacing.
void pilot_setTurn(Pilot *p, double turn)
Sets the pilot's turn.
int pilot_validTarget(const Pilot *p, const Pilot *target)
Checks to see if a pilot is a valid target for another pilot.
void pilot_explode(double x, double y, double radius, const Damage *dmg, const Pilot *parent)
Makes the pilot explosion.
void pilot_reset(Pilot *pilot)
Resets a pilot.
int pilot_isFriendly(const Pilot *p)
Checks to see if pilot is friendly to the player.
int pilot_refuelStart(Pilot *p)
Attempts to start refueling the pilot's target.
void pilots_renderOverlay(void)
Renders all the pilots overlays.
int pilot_isNeutral(const Pilot *p)
Checks to see if pilot is neutral to the player.
PilotOutfitSlot * pilot_getDockSlot(Pilot *p)
Gets the dock slot of the pilot.
void pilots_init(void)
Initializes pilot stuff.
int pilot_hasIllegal(const Pilot *p, int faction)
Checks to see if the pilot has illegal stuf to a faction.
void pilot_setCommMsg(Pilot *p, const char *s)
Sets the overhead communication message of the pilot.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
ntime_t pilot_hyperspaceDelay(const Pilot *p)
Calculates the hyperspace delay for a pilot.
void pilot_broadcast(Pilot *p, const char *msg, int ignore_int)
Has the pilot broadcast a message.
double pilot_minbrakedist(const Pilot *p, double dt, double *flytime)
Gets the minimum braking distance for the pilot.
void pilot_setHostile(Pilot *p)
Marks pilot as hostile to player.
double pilot_getNearestPosPilot(const Pilot *p, Pilot **tp, double x, double y, int disabled)
Get the nearest pilot to a pilot from a certain position.
void pilot_dpseps(const Pilot *p, double *pdps, double *peps)
Calculates the dps and eps of a pilot.
const glColour * pilot_getColour(const Pilot *p)
Gets a pilot's colour.
void pilot_distress(Pilot *p, Pilot *attacker, const char *msg)
Has the pilot broadcast a distress signal.
void pilot_render(Pilot *p)
Renders the pilot.
Pilot *const * pilot_getAll(void)
Gets the pilot stack.
int pilot_canTarget(const Pilot *p)
Same as pilot_validTarget but without the range check.
credits_t pilot_worth(const Pilot *p, int count_unique)
Gets the price or worth of a pilot in credits.
unsigned int pilot_getNearestEnemy_heuristic(const Pilot *p, double mass_factor, double health_factor, double damage_factor, double range_factor)
Gets the nearest enemy to the pilot closest to the pilot whose mass is between LB and UB.
double pilot_aimAngle(Pilot *p, const vec2 *pos, const vec2 *vel)
Returns the angle for a pilot to aim at another pilot.
void pilots_newSystem(void)
Updates pilot state which depends on the system (sensor range, nebula trails...)
unsigned int pilot_getNextID(unsigned int id, int mode)
Gets the next pilot based on id.
void pilot_rmFriendly(Pilot *p)
Unmarks a pilot as friendly to player.
void pilots_render(void)
Renders all the pilots.
int pilot_areAllies(const Pilot *p, const Pilot *target)
Like areAllies but for pilots.
int pilot_validTargetRange(const Pilot *p, const Pilot *target, int *inrange)
Checks to see if a pilot is a valid target for another pilot while storing the result of pilot_inRang...
double pilot_getNearestAng(const Pilot *p, unsigned int *tp, double ang, int disabled)
Get the pilot closest to an angle extending from another pilot.
void pilot_untargetAsteroid(int anchor, int asteroid)
Loops over pilot stack to remove an asteroid as target.
int pilot_getJumps(const Pilot *p)
Gets the amount of jumps the pilot has left.
void pilot_delete(Pilot *p)
Deletes a pilot.
void pilots_update(double dt)
Updates all the pilots.
void pilots_cleanAll(void)
Even cleans up the player.
void pilot_clearTrails(Pilot *p)
Resets the trails for a pilot.
unsigned int pilot_getBoss(const Pilot *p)
Get the strongest ally in a given range.
void pilots_free(void)
Frees the pilot stack.
double pilot_hit(Pilot *p, const Solid *w, const Pilot *pshooter, const Damage *dmg, const Outfit *outfit, int lua_mem, int reset)
Damages the pilot.
void pilot_update(Pilot *pilot, double dt)
Updates the pilot.
Pilot * pilot_create(const Ship *ship, const char *name, int faction, const char *ai, const double dir, const vec2 *pos, const vec2 *vel, const PilotFlags flags, unsigned int dockpilot, int dockslot)
Creates a new pilot.
unsigned int pilot_getPrevID(unsigned int id, int mode)
Gets the previous pilot based on ID.
int pilot_numOutfit(const Pilot *p, const Outfit *o)
Checks to see how many of an outfit a pilot has.
void pilot_sample_trails(Pilot *p, int none)
Updates the given pilot's trail emissions.
int pilot_hasCredits(const Pilot *p, credits_t amount)
Checks to see if the pilot has at least a certain amount of credits.
int pilot_brake(Pilot *p, double dt)
Causes the pilot to turn around and brake.
void pilot_setTarget(Pilot *p, unsigned int id)
Sets the target of the pilot.
unsigned int pilot_clone(const Pilot *ref)
Clones an existing pilot.
Core damage that an outfit does.
A ship outfit, depends radically on the type.
Stores a pilot commodity.
const Commodity * commodity
A wrapper for pilot hooks.
Stores an outfit the pilot has.
A pilot Weapon Set Outfit.
A weapon set represents a set of weapons that have an action.
PilotWeaponSetOutfit * slots
The representation of an in-game pilot.
ShipStatList * ship_stats
PilotWeaponSet weapon_sets[PILOT_WEAPON_SETS]
PilotCommodity * commodities
PilotOutfitSlot * outfit_structure
PilotOutfitSlot ** outfits
PilotOutfitSlot * outfit_utility
PilotOutfitSlot * outfit_intrinsic
double timer[MAX_AI_TIMERS]
ShipStatList * intrinsic_stats
unsigned int shoot_indicator
PilotOutfitSlot * afterburner
PilotOutfitSlot * outfit_weapon
Represents relative ship statistics as a linked list.
Represents ship statistics, properties ship can use.
Represents a solid in the game.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...
A trail generated by a ship or an ammo.
Contains a mission variable.