1 // SONIC ROBO BLAST 2 2 //----------------------------------------------------------------------------- 3 // Copyright (C) 2012-2016 by John "JTE" Muniz. 4 // Copyright (C) 2012-2020 by Sonic Team Junior. 5 // 6 // This program is free software distributed under the 7 // terms of the GNU General Public License, version 2. 8 // See the 'LICENSE' file for more details. 9 //----------------------------------------------------------------------------- 10 /// \file lua_hook.h 11 /// \brief hooks for Lua scripting 12 13 #include "r_defs.h" 14 #include "d_player.h" 15 16 enum hook { 17 hook_NetVars=0, 18 hook_MapChange, 19 hook_MapLoad, 20 hook_PlayerJoin, 21 hook_PreThinkFrame, 22 hook_ThinkFrame, 23 hook_PostThinkFrame, 24 hook_MobjSpawn, 25 hook_MobjCollide, 26 hook_MobjLineCollide, 27 hook_MobjMoveCollide, 28 hook_TouchSpecial, 29 hook_MobjFuse, 30 hook_MobjThinker, 31 hook_BossThinker, 32 hook_ShouldDamage, 33 hook_MobjDamage, 34 hook_MobjDeath, 35 hook_BossDeath, 36 hook_MobjRemoved, 37 hook_JumpSpecial, 38 hook_AbilitySpecial, 39 hook_SpinSpecial, 40 hook_JumpSpinSpecial, 41 hook_BotTiccmd, 42 hook_BotAI, 43 hook_BotRespawn, 44 hook_LinedefExecute, 45 hook_PlayerMsg, 46 hook_HurtMsg, 47 hook_PlayerSpawn, 48 hook_ShieldSpawn, 49 hook_ShieldSpecial, 50 hook_MobjMoveBlocked, 51 hook_MapThingSpawn, 52 hook_FollowMobj, 53 hook_PlayerCanDamage, 54 hook_PlayerQuit, 55 hook_IntermissionThinker, 56 hook_TeamSwitch, 57 hook_ViewpointSwitch, 58 hook_SeenPlayer, 59 hook_PlayerThink, 60 hook_ShouldJingleContinue, 61 hook_GameQuit, 62 hook_PlayerCmd, 63 hook_MusicChange, 64 hook_PlayerHeight, 65 hook_PlayerCanEnterSpinGaps, 66 67 hook_MAX // last hook 68 }; 69 extern const char *const hookNames[]; 70 71 extern boolean hook_cmd_running; 72 73 void LUAh_MapChange(INT16 mapnumber); // Hook for map change (before load) 74 void LUAh_MapLoad(void); // Hook for map load 75 void LUAh_PlayerJoin(int playernum); // Hook for Got_AddPlayer 76 void LUAh_PreThinkFrame(void); // Hook for frame (before mobj and player thinkers) 77 void LUAh_ThinkFrame(void); // Hook for frame (after mobj and player thinkers) 78 void LUAh_PostThinkFrame(void); // Hook for frame (at end of tick, ie after overlays, precipitation, specials) 79 boolean LUAh_MobjHook(mobj_t *mo, enum hook which); 80 boolean LUAh_PlayerHook(player_t *plr, enum hook which); 81 #define LUAh_MobjSpawn(mo) LUAh_MobjHook(mo, hook_MobjSpawn) // Hook for P_SpawnMobj by mobj type 82 UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which); 83 UINT8 LUAh_MobjLineCollideHook(mobj_t *thing, line_t *line, enum hook which); 84 #define LUAh_MobjCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjCollide) // Hook for PIT_CheckThing by (thing) mobj type 85 #define LUAh_MobjLineCollide(thing, line) LUAh_MobjLineCollideHook(thing, line, hook_MobjLineCollide) // Hook for PIT_CheckThing by (thing) mobj type 86 #define LUAh_MobjMoveCollide(thing1, thing2) LUAh_MobjCollideHook(thing1, thing2, hook_MobjMoveCollide) // Hook for PIT_CheckThing by (tmthing) mobj type 87 boolean LUAh_TouchSpecial(mobj_t *special, mobj_t *toucher); // Hook for P_TouchSpecialThing by mobj type 88 #define LUAh_MobjFuse(mo) LUAh_MobjHook(mo, hook_MobjFuse) // Hook for mobj->fuse == 0 by mobj type 89 boolean LUAh_MobjThinker(mobj_t *mo); // Hook for P_MobjThinker or P_SceneryThinker by mobj type 90 #define LUAh_BossThinker(mo) LUAh_MobjHook(mo, hook_BossThinker) // Hook for P_GenericBossThinker by mobj type 91 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?) 92 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!) 93 boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for P_KillMobj by mobj type 94 #define LUAh_BossDeath(mo) LUAh_MobjHook(mo, hook_BossDeath) // Hook for A_BossDeath by mobj type 95 #define LUAh_MobjRemoved(mo) LUAh_MobjHook(mo, hook_MobjRemoved) // Hook for P_RemoveMobj by mobj type 96 #define LUAh_JumpSpecial(player) LUAh_PlayerHook(player, hook_JumpSpecial) // Hook for P_DoJumpStuff (Any-jumping) 97 #define LUAh_AbilitySpecial(player) LUAh_PlayerHook(player, hook_AbilitySpecial) // Hook for P_DoJumpStuff (Double-jumping) 98 #define LUAh_SpinSpecial(player) LUAh_PlayerHook(player, hook_SpinSpecial) // Hook for P_DoSpinAbility (Spin button effect) 99 #define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air)) 100 boolean LUAh_BotTiccmd(player_t *bot, ticcmd_t *cmd); // Hook for B_BuildTiccmd 101 boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_BuildTailsTiccmd by skin name 102 boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails); // Hook for B_CheckRespawn 103 boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors 104 boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg); // Hook for chat messages 105 boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for hurt messages 106 #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer 107 #define LUAh_ShieldSpawn(player) LUAh_PlayerHook(player, hook_ShieldSpawn) // Hook for P_SpawnShieldOrb 108 #define LUAh_ShieldSpecial(player) LUAh_PlayerHook(player, hook_ShieldSpecial) // Hook for shield abilities 109 #define LUAh_MobjMoveBlocked(mo) LUAh_MobjHook(mo, hook_MobjMoveBlocked) // Hook for P_XYMovement (when movement is blocked) 110 boolean LUAh_MapThingSpawn(mobj_t *mo, mapthing_t *mthing); // Hook for P_SpawnMapThing by mobj type 111 boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAfterThink Smiles mobj-following 112 UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage 113 void LUAh_PlayerQuit(player_t *plr, kickreason_t reason); // Hook for player quitting 114 void LUAh_IntermissionThinker(void); // Hook for Y_Ticker 115 boolean LUAh_TeamSwitch(player_t *player, int newteam, boolean fromspectators, boolean tryingautobalance, boolean tryingscramble); // Hook for team switching in... uh.... 116 UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean forced); // Hook for spy mode 117 boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK 118 #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink 119 boolean LUAh_ShouldJingleContinue(player_t *player, const char *musname); // Hook for whether a jingle of the given music should continue playing 120 void LUAh_GameQuit(boolean quitting); // Hook for game quitting 121 boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Hook for building player's ticcmd struct (Ported from SRB2Kart) 122 boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes 123 fixed_t LUAh_PlayerHeight(player_t *player); 124 UINT8 LUAh_PlayerCanEnterSpinGaps(player_t *player); 125