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;
67 pilot_runHookParam(p, PILOT_HOOK_BOARD, hparam, 1);
68 pilot_runHookParam(p, PILOT_HOOK_BOARD_ALL, hparam, 1);
69 hparam[0].
u.
lp = p->id;
71 pilot_runHookParam(
player.
p, PILOT_HOOK_BOARDING, hparam, 1);
87 char *buf =
ndata_read( BOARD_PATH, &bufsize );
88 if (nlua_dobufenv(
board_env, buf, bufsize, BOARD_PATH) != 0) {
89 WARN( _(
"Error loading file: %s\n"
91 "Most likely Lua file has improper syntax, please check"),
92 BOARD_PATH, lua_tostring(naevL,-1));
104 WARN( _(
"Board: '%s'"), lua_tostring(naevL,-1));
119 if (pilot_isDisabled(
player.
p))
120 return PLAYER_BOARD_IMPOSSIBLE;
124 return PLAYER_BOARD_IMPOSSIBLE;
128 if (pilot_isFlag(p,PILOT_NOBOARD)) {
131 return PLAYER_BOARD_IMPOSSIBLE;
133 else if (!pilot_isDisabled(p) && !pilot_isFlag(p,PILOT_BOARDABLE)) {
135 player_message(
"#r%s", _(
"You cannot board a ship that isn't disabled!") );
136 return PLAYER_BOARD_IMPOSSIBLE;
138 else if (pilot_isFlag(p,PILOT_BOARDED)) {
140 player_message(
"#r%s", _(
"Your target cannot be boarded again.") );
141 return PLAYER_BOARD_IMPOSSIBLE;
144 return PLAYER_BOARD_OK;
158 return PLAYER_BOARD_IMPOSSIBLE;
165 p->ship->gfx_space->sw * PILOT_SIZE_APPROX) {
167 player_message(
"#r%s", _(
"You are too far away to board your target.") );
168 return PLAYER_BOARD_RETRY;
172 player_message(
"#r%s", _(
"You are going too fast to board the ship.") );
173 return PLAYER_BOARD_RETRY;
177 if (pilot_isFlag(p, PILOT_CARRIED) && (p->dockpilot == PLAYER_ID)) {
178 if (pilot_dock( p,
player.
p )) {
179 WARN(_(
"Unable to recover fighter."));
180 return PLAYER_BOARD_IMPOSSIBLE;
184 return PLAYER_BOARD_OK;
194 if (!pilot_isFlag(p,PILOT_BOARDABLE))
195 pilot_setFlag(p,PILOT_BOARDED);
202 return PLAYER_BOARD_OK;
226 if (target == NULL) {
232 if (!pilot_isDisabled(target))
234 else if (vec2_dist(&p->solid.pos, &target->
solid.
pos) >
237 else if (vec2_dist2( &p->solid.vel, &target->
solid.
vel ) >
pow2(MAX_HYPERSPACE_VEL))
239 else if (pilot_isFlag(target,PILOT_BOARDED))
246 pilot_setFlag(target, PILOT_BOARDED);
247 pilot_setFlag(p, PILOT_BOARDING);
253 hparam[0].
type = HOOK_PARAM_PILOT;
254 hparam[0].
u.
lp = p->id;
255 hparam[1].
type = HOOK_PARAM_SENTINEL;
256 pilot_runHookParam(target, PILOT_HOOK_BOARD_ALL, hparam, 1);
257 hparam[0].
u.
lp = target->
id;
258 pilot_runHookParam(p, PILOT_HOOK_BOARDING, hparam, 1);
279 if (pilot_isPlayer(target)) {
280 char creds[ ECON_CRED_STRLEN ];
282 p->credits += worth * p->stats.loot_mod;
286 _(
"#%c%s#0 has plundered %s from your ship!"),
291 p->credits += target->
credits * p->stats.loot_mod;
296 pilot_rmFlag(p, PILOT_BOARDING);
Provides macros to work with dynamic arrays.
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_getColourChar 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.
The representation of an in-game pilot.