Skip to content
Snippets Groups Projects
lua_hook.h 6.21 KiB
Newer Older
Alam Ed Arias's avatar
Alam Ed Arias committed
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
// Copyright (C) 2012-2016 by John "JTE" Muniz.
// Copyright (C) 2012-2018 by Sonic Team Junior.
Alam Ed Arias's avatar
Alam Ed Arias committed
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file  lua_hook.h
/// \brief hooks for Lua scripting

#ifdef HAVE_BLUA

#include "r_defs.h"
#include "d_player.h"

enum hook {
	hook_NetVars=0,
	hook_MapChange,
	hook_MapLoad,
	hook_PlayerJoin,
	hook_PreThinkFrame,
Alam Ed Arias's avatar
Alam Ed Arias committed
	hook_ThinkFrame,
	hook_PostThinkFrame,
Alam Ed Arias's avatar
Alam Ed Arias committed
	hook_MobjSpawn,
	hook_MobjCollide,
	hook_MobjMoveCollide,
	hook_TouchSpecial,
	hook_MobjFuse,
	hook_MobjThinker,
	hook_BossThinker,
	hook_ShouldDamage,
	hook_MobjDamage,
	hook_MobjDeath,
	hook_BossDeath,
	hook_MobjRemoved,
Alam Ed Arias's avatar
Alam Ed Arias committed
	hook_JumpSpecial,
	hook_AbilitySpecial,
	hook_SpinSpecial,
	hook_JumpSpinSpecial,
Alam Ed Arias's avatar
Alam Ed Arias committed
	hook_BotTiccmd,
	hook_BotAI,
	hook_LinedefExecute,
	hook_PlayerMsg,
	hook_HurtMsg,
wolfs's avatar
wolfs committed
	hook_PlayerSpawn,
Prisima the Fox's avatar
Prisima the Fox committed
	hook_PlayerQuit,
	hook_PlayerThink,
wolfs's avatar
wolfs committed
	hook_MusicChange,
	hook_ShouldSpin,	//SRB2KART
	hook_ShouldExplode,	//SRB2KART
	hook_ShouldSquish,	//SRB2KART
	hook_PlayerSpin,	//SRB2KART
	hook_PlayerExplode,	//SRB2KART
	hook_PlayerSquish,	//SRB2KART
SteelT's avatar
SteelT committed
	hook_IntermissionThinker, //SRB2KART
Latapostrophe's avatar
Latapostrophe committed
	hook_VoteThinker, //SRB2KART
Alam Ed Arias's avatar
Alam Ed Arias committed

	hook_MAX // last hook
};
extern const char *const hookNames[];

extern boolean hook_cmd_running;	// This is used by PlayerCmd and lua_playerlib to prevent anything from being wirtten to player while we run PlayerCmd.
void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load)
Alam Ed Arias's avatar
Alam Ed Arias committed
void LUAh_MapLoad(void); // Hook for map load
void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer
void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers)
Alam Ed Arias's avatar
Alam Ed Arias committed
void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers)
void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials)
Alam Ed Arias's avatar
Alam Ed Arias committed
boolean LUAh_MobjHook(mobj_t *mo, enum hook which);
Alam Ed Arias's avatar
Alam Ed Arias committed
boolean LUAh_PlayerHook(player_t *plr, enum hook which);
Alam Ed Arias's avatar
Alam Ed Arias committed
#define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which);
#define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type
#define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type
Alam Ed Arias's avatar
Alam Ed Arias committed
boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type
#define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type
boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type
Alam Ed Arias's avatar
Alam Ed Arias committed
#define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type
UINT8 LUAh_ShouldDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Should mobj take damage?)
boolean LUAh_MobjDamage(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage); // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!)
boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source); // Hook for P_KillMobj by mobj type
#define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type
#define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type
Alam Ed Arias's avatar
Alam Ed Arias committed
#define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping)
#define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping)
#define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinDash (Spin button effect)
#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
Alam Ed Arias's avatar
Alam Ed Arias committed
boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd
boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name
Alam Ed Arias's avatar
Alam Ed Arias committed
boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors
wolfs's avatar
wolfs committed
boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute); // Hook for chat messages
boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages
Alam Ed Arias's avatar
Alam Ed Arias committed
#define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
wolfs's avatar
wolfs committed
boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping,
	UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes
Alam Ed Arias's avatar
Alam Ed Arias committed

UINT8 LUAh_ShouldSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be spun out?
UINT8 LUAh_ShouldExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be exploded?
UINT8 LUAh_ShouldSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Should player be squished?

boolean LUAh_PlayerSpin(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SpinPlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_ExplodePlayer. Allows Lua to execute code and/or overwrite its behavior.
boolean LUAh_PlayerSquish(player_t *player, mobj_t *inflictor, mobj_t *source); // SRB2KART: Hook for K_SquishPlayer. Allows Lua to execute code and/or overwrite its behavior.

boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd);	// Allows to write to player cmd before the game does anything with them.

SteelT's avatar
SteelT committed
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
Latapostrophe's avatar
Latapostrophe committed
void LUAh_VoteThinker(void);	// Hook for Y_VoteTicker
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
Alam Ed Arias's avatar
Alam Ed Arias committed
#endif