24#define BOARDING_WIDTH 380
25#define BOARDING_HEIGHT 200
27#define BUTTON_WIDTH 50
28#define BUTTON_HEIGHT 30
43int board_hook(
void *data )
49 if ( pilot_isWithPlayer( p ) ) {
53 player_message( _(
"#gYou reactivate the systems of %s." ), p->name );
60 hparam[0].
type = HOOK_PARAM_PILOT;
61 hparam[0].
u.
lp = PLAYER_ID;
62 hparam[1].
type = HOOK_PARAM_SENTINEL;
63 pilot_runHookParam( p, PILOT_HOOK_BOARD, hparam, 1 );
64 pilot_runHookParam( p, PILOT_HOOK_BOARD_ALL, hparam, 1 );
65 hparam[0].
u.
lp = p->id;
67 pilot_runHookParam(
player.p, PILOT_HOOK_BOARDING, hparam, 1 );
83 char *buf =
ndata_read( BOARD_PATH, &bufsize );
84 if ( nlua_dobufenv(
board_env, buf, bufsize, BOARD_PATH ) != 0 ) {
85 WARN( _(
"Error loading file: %s\n"
87 "Most likely Lua file has improper syntax, please check" ),
88 BOARD_PATH, lua_tostring(
naevL, -1 ) );
100 WARN( _(
"Board: '%s'" ), lua_tostring(
naevL, -1 ) );
115 if ( pilot_isDisabled(
player.p ) )
116 return PLAYER_BOARD_IMPOSSIBLE;
119 if (
player.p->target == PLAYER_ID )
120 return PLAYER_BOARD_IMPOSSIBLE;
124 if ( pilot_isFlag( p, PILOT_NOBOARD ) ) {
127 return PLAYER_BOARD_IMPOSSIBLE;
128 }
else if ( !pilot_isDisabled( p ) && !pilot_isFlag( p, PILOT_BOARDABLE ) ) {
131 _(
"You cannot board a ship that isn't disabled!" ) );
132 return PLAYER_BOARD_IMPOSSIBLE;
133 }
else if ( pilot_isFlag( p, PILOT_BOARDED ) ) {
135 player_message(
"#r%s", _(
"Your target cannot be boarded again." ) );
136 return PLAYER_BOARD_IMPOSSIBLE;
137 }
else if ( pilot_isFlag( p, PILOT_CARRIED ) &&
138 ( p->dockpilot != PLAYER_ID ) ) {
140 player_message(
"#r%s", _(
"You can not board deployed fighters." ) );
141 return PLAYER_BOARD_IMPOSSIBLE;
144 return PLAYER_BOARD_OK;
158 return PLAYER_BOARD_IMPOSSIBLE;
164 if ( vec2_dist( &
player.p->solid.pos, &p->solid.pos ) >
165 p->ship->size * PILOT_SIZE_APPROX ) {
168 _(
"You are too far away to board your target." ) );
169 return PLAYER_BOARD_RETRY;
170 }
else if ( vec2_dist2( &
player.p->solid.vel, &p->solid.vel ) >
171 pow2( MAX_HYPERSPACE_VEL ) ) {
174 _(
"You are going too fast to board the ship." ) );
175 return PLAYER_BOARD_RETRY;
179 if ( pilot_isFlag( p, PILOT_CARRIED ) && ( p->dockpilot == PLAYER_ID ) ) {
180 if ( pilot_dock( p,
player.p ) ) {
181 WARN( _(
"Unable to recover fighter." ) );
182 return PLAYER_BOARD_IMPOSSIBLE;
186 return PLAYER_BOARD_OK;
190 vec2_cset( &
player.p->solid.vel, VX( p->solid.vel ), VY( p->solid.vel ) );
196 if ( !pilot_isFlag( p, PILOT_BOARDABLE ) )
197 pilot_setFlag( p, PILOT_BOARDED );
204 return PLAYER_BOARD_OK;
228 if ( target == NULL ) {
229 DEBUG(
"NO TARGET" );
234 if ( !pilot_isDisabled( target ) )
236 else if ( vec2_dist( &p->solid.pos, &target->
solid.
pos ) >
237 target->
ship->
size * PILOT_SIZE_APPROX )
239 else if ( vec2_dist2( &p->solid.vel, &target->
solid.
vel ) >
240 pow2( MAX_HYPERSPACE_VEL ) )
242 else if ( pilot_isFlag( target, PILOT_BOARDED ) )
246 vec2_cset( &p->solid.vel, VX( target->
solid.
vel ), VY( target->
solid.
vel ) );
249 pilot_setFlag( target, PILOT_BOARDED );
250 pilot_setFlag( p, PILOT_BOARDING );
256 hparam[0].
type = HOOK_PARAM_PILOT;
257 hparam[0].
u.
lp = p->id;
258 hparam[1].
type = HOOK_PARAM_SENTINEL;
259 pilot_runHookParam( target, PILOT_HOOK_BOARD_ALL, hparam, 1 );
260 hparam[0].
u.
lp = target->
id;
261 pilot_runHookParam( p, PILOT_HOOK_BOARDING, hparam, 1 );
278 if ( target == NULL )
282 if ( pilot_isPlayer( target ) ) {
283 char creds[ECON_CRED_STRLEN];
285 p->credits += worth * p->stats.loot_mod;
292 p->credits += target->
credits * p->stats.loot_mod;
297 pilot_rmFlag( p, PILOT_BOARDING );
int player_canBoard(int noisy)
Sees if the pilot can board a pilot.
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 credits2str(char *str, credits_t credits, int decimals)
Converts credits to a usable string for displaying.
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_reputationColourChar but for a pilot.
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.
credits_t pilot_worth(const Pilot *p, int count_unique)
Gets the price or worth of a pilot in credits.
void pilot_outfitLOnboard(Pilot *pilot, const Pilot *target)
Runs Lua outfits when pilot boards a target.
The actual hook parameter.
union HookParam::@114305201244257020071001257133270030317263020235 u
The representation of an in-game pilot.