17#include "damagetype.h"
29#define BOARDING_WIDTH 380
30#define BOARDING_HEIGHT 200
32#define BUTTON_WIDTH 50
33#define BUTTON_HEIGHT 30
47int board_hook(
void *data )
53 if (pilot_isWithPlayer( p )) {
64 hparam[0].
type = HOOK_PARAM_PILOT;
65 hparam[0].
u.
lp = PLAYER_ID;
66 hparam[1].
type = HOOK_PARAM_SENTINEL;
69 hparam[0].
u.
lp = p->id;
84 char *buf =
ndata_read( BOARD_PATH, &bufsize );
85 if (nlua_dobufenv(
board_env, buf, bufsize, BOARD_PATH) != 0) {
86 WARN( _(
"Error loading file: %s\n"
88 "Most likely Lua file has improper syntax, please check"),
89 BOARD_PATH, lua_tostring(naevL,-1));
101 WARN( _(
"Board: '%s'"), lua_tostring(naevL,-1));
119 if (pilot_isDisabled(
player.
p))
120 return PLAYER_BOARD_IMPOSSIBLE;
129 (!pilot_isDisabled(p) && !pilot_isFlag(p,PILOT_BOARDABLE)) ||
130 pilot_isFlag(p,PILOT_NOBOARD)) {
133 return PLAYER_BOARD_IMPOSSIBLE;
141 if (pilot_isFlag(p,PILOT_NOBOARD)) {
143 return PLAYER_BOARD_IMPOSSIBLE;
145 else if (!pilot_isDisabled(p) && !pilot_isFlag(p,PILOT_BOARDABLE)) {
146 player_message(
"#r%s", _(
"You cannot board a ship that isn't disabled!") );
147 return PLAYER_BOARD_IMPOSSIBLE;
149 else if (pilot_isFlag(p,PILOT_BOARDED)) {
150 player_message(
"#r%s", _(
"Your target cannot be boarded again.") );
151 return PLAYER_BOARD_IMPOSSIBLE;
154 p->ship->gfx_space->sw * PILOT_SIZE_APPROX) {
156 player_message(
"#r%s", _(
"You are too far away to board your target.") );
157 return PLAYER_BOARD_RETRY;
161 player_message(
"#r%s", _(
"You are going too fast to board the ship.") );
162 return PLAYER_BOARD_RETRY;
166 if (pilot_isFlag(p, PILOT_CARRIED) && (p->dockpilot == PLAYER_ID)) {
168 WARN(_(
"Unable to recover fighter."));
169 return PLAYER_BOARD_IMPOSSIBLE;
173 return PLAYER_BOARD_OK;
177 vec2_cset(&
player.
p->
solid->
vel, VX(p->solid->vel), VY(p->solid->vel));
183 if (!pilot_isFlag(p,PILOT_BOARDABLE))
184 pilot_setFlag(p,PILOT_BOARDED);
191 return PLAYER_BOARD_OK;
215 if (target == NULL) {
221 if (!pilot_isDisabled(target))
223 else if (vec2_dist(&p->solid->pos, &target->
solid->
pos) >
226 else if (vec2_dist2( &p->solid->vel, &target->
solid->
vel ) >
pow2(MAX_HYPERSPACE_VEL))
228 else if (pilot_isFlag(target,PILOT_BOARDED))
235 pilot_setFlag(target, PILOT_BOARDED);
236 pilot_setFlag(p, PILOT_BOARDING);
242 hparam[0].
type = HOOK_PARAM_PILOT;
243 hparam[0].
u.
lp = p->id;
244 hparam[1].
type = HOOK_PARAM_SENTINEL;
246 hparam[0].
u.
lp = target->
id;
265 if (pilot_isPlayer(target)) {
266 char creds[ ECON_CRED_STRLEN ];
268 p->credits += worth * p->stats.loot_mod;
270 credits2str( creds, worth, 2 );
272 _(
"#%c%s#0 has plundered %s from your ship!"),
277 p->credits += target->
credits * p->stats.loot_mod;
282 pilot_rmFlag(p, PILOT_BOARDING);
Provides macros to work with dynamic arrays.
int pilot_board(Pilot *p)
Has a pilot attempt to board another pilot.
static nlua_env board_env
static int board_stopboard
void pilot_boardComplete(Pilot *p)
Finishes the boarding.
int player_tryBoard(int noisy)
Attempt to board the player's target.
int player_isBoarded(void)
Gets if the player is boarded.
void board_unboard(void)
Forces unboarding of the pilot.
void player_message(const char *fmt,...)
Adds a mesg to the queue to be displayed on screen.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
unsigned int hook_addFunc(int(*func)(void *), void *data, const char *stack)
Adds a function hook to be run.
Header file with generic functions and naev-specifics.
void * ndata_read(const char *path, size_t *filesize)
Reads a file from the ndata (will be NUL terminated).
int nlua_loadStandard(nlua_env env)
Loads the standard Naev Lua API.
LuaPilot * lua_pushpilot(lua_State *L, LuaPilot pilot)
Pushes a pilot on the stack.
char pilot_getFactionColourChar(const Pilot *p)
Gets the faction colour char, works like faction_getColourChar but for a pilot.
credits_t pilot_worth(const Pilot *p)
Gets the price or worth of a pilot in credits.
void pilot_updateDisable(Pilot *p, unsigned int shooter)
Handles pilot disabling. Set or unset the disable status depending on health and stress values.
Pilot * pilot_getTarget(Pilot *p)
Gets the target of a pilot using a fancy caching system.
int pilot_runHookParam(Pilot *p, int hook_type, const HookParam *param, int nparam)
Tries to run a pilot hook if he has it.
int pilot_dock(Pilot *p, Pilot *target)
Docks the pilot on its target pilot.
void player_targetNearest(void)
Player targets nearest pilot.
void player_targetClear(void)
Clears the player's ship, spob or hyperspace target, in that order.
The actual hook parameter.
The representation of an in-game pilot.