2014-03-15 16:59:03 +00:00
// SONIC ROBO BLAST 2
//-----------------------------------------------------------------------------
2016-05-18 00:42:11 +00:00
// Copyright (C) 2012-2016 by John "JTE" Muniz.
2019-12-06 18:49:42 +00:00
// Copyright (C) 2012-2019 by Sonic Team Junior.
2014-03-15 16:59:03 +00:00
//
// 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_ThinkFrame ,
hook_MobjSpawn ,
hook_MobjCollide ,
hook_MobjMoveCollide ,
hook_TouchSpecial ,
hook_MobjFuse ,
hook_MobjThinker ,
hook_BossThinker ,
hook_ShouldDamage ,
hook_MobjDamage ,
hook_MobjDeath ,
hook_BossDeath ,
hook_MobjRemoved ,
2014-08-04 03:49:33 +00:00
hook_JumpSpecial ,
hook_AbilitySpecial ,
hook_SpinSpecial ,
hook_JumpSpinSpecial ,
2014-03-15 16:59:03 +00:00
hook_BotTiccmd ,
hook_BotAI ,
hook_LinedefExecute ,
2014-06-18 20:28:09 +00:00
hook_PlayerMsg ,
2015-06-10 11:28:09 +00:00
hook_HurtMsg ,
2016-02-14 11:19:40 +00:00
hook_PlayerSpawn ,
2016-10-20 19:55:15 +00:00
hook_ShieldSpawn ,
2016-10-24 12:52:36 +00:00
hook_ShieldSpecial ,
2017-01-21 23:49:18 +00:00
hook_MobjMoveBlocked ,
2017-04-15 20:41:22 +00:00
hook_MapThingSpawn ,
2017-10-02 13:08:58 +00:00
hook_FollowMobj ,
"PlayerCanDamage" hook!
* Takes function(player, mo) input.
* Return TRUE for stating that yes, the player is in a state that can cause contact damage, do with that what you will.
* Return FALSE for stating that no, the player is weak and vulnerable and cannot cause contact damage, do with that what you will.
* Return NIL for allowing the function to continue regular operation.
Fills a different ideological niche than ShouldDamage - that's for determining whether damage dished between two objects should happen, this is for determining which way around damage should be dished when considering a player-object interaction.
Or, in other words, think of it as "ShouldDamage is whether damage that has been requested should be granted, for object-object interaction, while PlayerCanDamage is for whether global player properties should cause damage to enemies and monitors in the first place, like spinning, hammering or stomping."
2019-06-19 11:55:05 +00:00
hook_PlayerCanDamage ,
2016-10-21 02:23:50 +00:00
hook_PlayerQuit ,
2019-10-14 00:50:46 +00:00
hook_IntermissionThinker ,
2019-12-19 02:40:58 +00:00
hook_TeamSwitch ,
2019-12-18 23:43:54 +00:00
hook_ViewpointSwitch ,
2014-03-15 16:59:03 +00:00
hook_MAX // last hook
} ;
extern const char * const hookNames [ ] ;
2018-11-30 17:01:40 +00:00
void LUAh_MapChange ( INT16 mapnumber ) ; // Hook for map change (before load)
2014-03-15 16:59:03 +00:00
void LUAh_MapLoad ( void ) ; // Hook for map load
void LUAh_PlayerJoin ( int playernum ) ; // Hook for Got_AddPlayer
void LUAh_ThinkFrame ( void ) ; // Hook for frame (after mobj and player thinkers)
boolean LUAh_MobjHook ( mobj_t * mo , enum hook which ) ;
2014-08-04 03:49:33 +00:00
boolean LUAh_PlayerHook ( player_t * plr , enum hook which ) ;
2014-03-15 16:59:03 +00:00
# define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type
2015-06-10 11:28:09 +00:00
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
2014-03-15 16:59:03 +00:00
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
2016-12-15 20:05:54 +00:00
boolean LUAh_MobjThinker ( mobj_t * mo ) ; // Hook for P_MobjThinker or P_SceneryThinker by mobj type
2014-03-15 16:59:03 +00:00
# define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type
2016-07-20 21:02:02 +00:00
UINT8 LUAh_ShouldDamage ( mobj_t * target , mobj_t * inflictor , mobj_t * source , INT32 damage , UINT8 damagetype ) ; // 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 , UINT8 damagetype ) ; // Hook for P_DamageMobj by mobj type (Mobj actually takes damage!)
boolean LUAh_MobjDeath ( mobj_t * target , mobj_t * inflictor , mobj_t * source , UINT8 damagetype ) ; // Hook for P_KillMobj by mobj type
2014-03-15 16:59:03 +00:00
# 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
2014-08-04 03:49:33 +00:00
# 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)
2016-07-17 20:31:15 +00:00
# define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinAbility (Spin button effect)
2014-08-04 03:49:33 +00:00
# define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
2014-03-15 16:59:03 +00:00
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
2014-11-12 00:55:07 +00:00
boolean LUAh_LinedefExecute ( line_t * line , mobj_t * mo , sector_t * sector ) ; // Hook for linedef executors
2014-06-18 20:28:09 +00:00
boolean LUAh_PlayerMsg ( int source , int target , int flags , char * msg ) ; // Hook for chat messages
2016-07-20 21:02:02 +00:00
boolean LUAh_HurtMsg ( player_t * player , mobj_t * inflictor , mobj_t * source , UINT8 damagetype ) ; // Hook for hurt messages
2016-04-07 20:34:36 +00:00
# define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer
2016-10-20 19:55:15 +00:00
# define LUAh_ShieldSpawn(player) LUAh_PlayerHook(player, hook_ShieldSpawn) // Hook for P_SpawnShieldOrb
2016-10-24 12:52:36 +00:00
# define LUAh_ShieldSpecial(player) LUAh_PlayerHook(player, hook_ShieldSpecial) // Hook for shield abilities
2017-01-21 23:49:18 +00:00
# define LUAh_MobjMoveBlocked(mo) LUAh_MobjHook(mo, hook_MobjMoveBlocked) // Hook for P_XYMovement (when movement is blocked)
2017-04-15 20:41:22 +00:00
boolean LUAh_MapThingSpawn ( mobj_t * mo , mapthing_t * mthing ) ; // Hook for P_SpawnMapThing by mobj type
"PlayerCanDamage" hook!
* Takes function(player, mo) input.
* Return TRUE for stating that yes, the player is in a state that can cause contact damage, do with that what you will.
* Return FALSE for stating that no, the player is weak and vulnerable and cannot cause contact damage, do with that what you will.
* Return NIL for allowing the function to continue regular operation.
Fills a different ideological niche than ShouldDamage - that's for determining whether damage dished between two objects should happen, this is for determining which way around damage should be dished when considering a player-object interaction.
Or, in other words, think of it as "ShouldDamage is whether damage that has been requested should be granted, for object-object interaction, while PlayerCanDamage is for whether global player properties should cause damage to enemies and monitors in the first place, like spinning, hammering or stomping."
2019-06-19 11:55:05 +00:00
boolean LUAh_FollowMobj ( player_t * player , mobj_t * mobj ) ; // Hook for P_PlayerAfterThink Smiles mobj-following
UINT8 LUAh_PlayerCanDamage ( player_t * player , mobj_t * mobj ) ; // Hook for P_PlayerCanDamage
2016-10-21 03:25:47 +00:00
void LUAh_PlayerQuit ( player_t * plr , int reason ) ; // Hook for player quitting
2019-10-14 00:50:46 +00:00
void LUAh_IntermissionThinker ( void ) ; // Hook for Y_Ticker
2019-12-19 02:53:26 +00:00
boolean LUAh_TeamSwitch ( player_t * player , int newteam , boolean fromspectators , boolean tryingautobalance , boolean tryingscramble ) ; // Hook for team switching in... uh....
2019-12-18 23:43:54 +00:00
UINT8 LUAh_ViewpointSwitch ( player_t * player , player_t * newdisplayplayer ) ; // Hook for spy mode in G_Responder
2014-03-15 16:59:03 +00:00
# endif