[Add] Pilot "jump" hook.
This commit is contained in:
parent
338a41a8e4
commit
a42c21da4e
@ -180,7 +180,7 @@ void hook_cleanup(void) {
|
||||
static int hook_needSave(Hook* h) {
|
||||
int i;
|
||||
char* nosave[] = {
|
||||
"death", "board", "disable", /* Pilot hooks. */
|
||||
"death", "board", "disable", "jump", /* Pilot hooks. */
|
||||
"end" };
|
||||
|
||||
for(i = 0; strcmp(nosave[i], "end") != 0; i++)
|
||||
|
@ -764,6 +764,25 @@ static int hook_enter(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @fn static int hook_pilot(lua_State* L)
|
||||
* @ingroup HOOK
|
||||
*
|
||||
* @brief number pilot(number pilot, string type, string func)
|
||||
*
|
||||
* Hooks the function to a specific pilot.
|
||||
*
|
||||
* You can hook to different actions. At the moment hook system only supports:
|
||||
* -- "death" : Triggered when pilot dies.
|
||||
* -- "board" : Triggered when pilot is boarded.
|
||||
* -- "disable" : Triggered when pilot is disabled.
|
||||
* -- "jump" : Triggered when pilot jumps to hyperspace.
|
||||
*
|
||||
* @param pilot Pilot identifier to hook.
|
||||
* @param typer One of the supported hook types.
|
||||
* @param func Function to run when hook is triggered.
|
||||
* @return Hook identifier.
|
||||
*/
|
||||
static int hook_pilot(lua_State* L) {
|
||||
LLUA_MIN_ARGS(2);
|
||||
unsigned int h, p;
|
||||
@ -782,6 +801,7 @@ static int hook_pilot(lua_State* L) {
|
||||
if(strcmp(hook_type, "death")==0) type = PILOT_HOOK_DEATH;
|
||||
else if(strcmp(hook_type, "board")==0) type = PILOT_HOOK_BOARD;
|
||||
else if(strcmp(hook_type, "disable")==0) type = PILOT_HOOK_DISABLE;
|
||||
else if(strcmp(hook_type, "jump")==0) type = PILOT_HOOK_JUMP;
|
||||
else { /* Hook type not valid. */
|
||||
LLUA_DEBUG("Invalid pilot hook type: '%s'", hook_type);
|
||||
return 0;
|
||||
|
@ -693,8 +693,10 @@ static void pilot_hyperspace(Pilot* p) {
|
||||
if(SDL_GetTicks() > p->ptimer) {
|
||||
if(p == player) {
|
||||
player_brokeHyperspace();
|
||||
} else
|
||||
pilot_setFlag(p, PILOT_DELETE); /* Set flag to delete pilot. */
|
||||
} else {
|
||||
if(p->hook_type == PILOT_HOOK_JUMP)
|
||||
hook_runID(p->hook);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/* Keep accelerating - hyperspace uses much bigger accel. */
|
||||
|
@ -25,6 +25,7 @@
|
||||
#define PILOT_HOOK_DEATH 1 /**< Pilot died. */
|
||||
#define PILOT_HOOK_BOARD 2 /**< Pilot got boarded. */
|
||||
#define PILOT_HOOK_DISABLE 3 /**< Pilot got disabled. */
|
||||
#define PILOT_HOOK_JUMP 4 /**< Pilot jumped. */
|
||||
|
||||
/* Flags. */
|
||||
#define pilot_isFlag(p,f) (p->flags & (f)) /**< Check if flag f is set on pilot p. */
|
||||
|
Loading…
Reference in New Issue
Block a user