mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-29 07:23:01 +00:00
HOOK_ON_SCREEN_TRANSITION (#192)
This commit is contained in:
parent
6449b7d578
commit
f726fb5d74
8 changed files with 21 additions and 8 deletions
|
@ -7940,7 +7940,10 @@ HOOK_USE_ACT_SELECT = 23
|
|||
HOOK_ON_CHANGE_CAMERA_ANGLE = 24
|
||||
|
||||
--- @type LuaHookedEventType
|
||||
HOOK_MAX = 25
|
||||
HOOK_ON_SCREEN_TRANSITION = 25
|
||||
|
||||
--- @type LuaHookedEventType
|
||||
HOOK_MAX = 26
|
||||
|
||||
--- @class HudDisplayFlags
|
||||
|
||||
|
|
|
@ -2807,7 +2807,8 @@
|
|||
| HOOK_ON_PACKET_RECEIVE | 22 |
|
||||
| HOOK_USE_ACT_SELECT | 23 |
|
||||
| HOOK_ON_CHANGE_CAMERA_ANGLE | 24 |
|
||||
| HOOK_MAX | 25 |
|
||||
| HOOK_ON_SCREEN_TRANSITION | 25 |
|
||||
| HOOK_MAX | 26 |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
|||
| HOOK_ON_PACKET_RECEIVE | Called when the mod receives a packet that used `network_send()` or `network_send_to()` | `table` dataTable |
|
||||
| HOOK_USE_ACT_SELECT | Called when the level changes, return `true` to show act selection screen and `false` otherwise | `integer` levelNum |
|
||||
| HOOK_ON_CHANGE_CAMERA_ANGLE | Called when the player changes the camera mode to Lakitu cam or Mario cam, return `false` to prevent the change. | `integer` mode |
|
||||
| HOOK_ON_SCREEN_TRANSITION | Called when the game is about to play a transition, returun `false` to prevent the transition from playing. | `integer` type |
|
||||
|
||||
### Parameters
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "gfx_dimensions.h"
|
||||
#include "game/ingame_menu.h"
|
||||
#include "pc/network/network.h"
|
||||
#include "pc/lua/smlua_hooks.h"
|
||||
|
||||
struct SpawnInfo gPlayerSpawnInfos[MAX_PLAYERS];
|
||||
struct GraphNode *D_8033A160[MAX_LOADED_GRAPH_NODES];
|
||||
|
@ -341,6 +342,10 @@ void area_update_objects(void) {
|
|||
* transition type, time in frames, and the RGB color that will fill the screen.
|
||||
*/
|
||||
void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue) {
|
||||
bool returnValue = true;
|
||||
smlua_call_event_hooks_int_params_ret_bool(HOOK_ON_SCREEN_TRANSITION, transType, &returnValue);
|
||||
if (!returnValue) { return; }
|
||||
|
||||
gWarpTransition.isActive = TRUE;
|
||||
gWarpTransition.type = transType;
|
||||
gWarpTransition.time = time;
|
||||
|
|
|
@ -3068,12 +3068,12 @@ void update_camera(struct Camera *c) {
|
|||
if ((sCurrPlayMode != PLAY_MODE_PAUSED) && gPlayer1Controller->buttonPressed & R_TRIG) {
|
||||
bool returnValue = true;
|
||||
if (set_cam_angle(0) == CAM_ANGLE_LAKITU) {
|
||||
smlua_call_event_hooks_change_camera_angle_params(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_MARIO, &returnValue);
|
||||
smlua_call_event_hooks_int_params_ret_bool(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_MARIO, &returnValue);
|
||||
if (returnValue) {
|
||||
set_cam_angle(CAM_ANGLE_MARIO);
|
||||
}
|
||||
} else {
|
||||
smlua_call_event_hooks_change_camera_angle_params(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_LAKITU, &returnValue);
|
||||
smlua_call_event_hooks_int_params_ret_bool(HOOK_ON_CHANGE_CAMERA_ANGLE, CAM_ANGLE_LAKITU, &returnValue);
|
||||
if (returnValue) {
|
||||
set_cam_angle(CAM_ANGLE_LAKITU);
|
||||
}
|
||||
|
|
|
@ -2826,7 +2826,8 @@ char gSmluaConstants[] = ""
|
|||
"HOOK_ON_PACKET_RECEIVE = 22\n"
|
||||
"HOOK_USE_ACT_SELECT = 23\n"
|
||||
"HOOK_ON_CHANGE_CAMERA_ANGLE = 24\n"
|
||||
"HOOK_MAX = 25\n"
|
||||
"HOOK_ON_SCREEN_TRANSITION = 25\n"
|
||||
"HOOK_MAX = 26\n"
|
||||
"ACTION_HOOK_EVERY_FRAME = 0\n"
|
||||
"ACTION_HOOK_GRAVITY = 1\n"
|
||||
"ACTION_HOOK_MAX = 2\n"
|
||||
|
|
|
@ -477,7 +477,7 @@ void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookT
|
|||
}
|
||||
}
|
||||
|
||||
void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType hookType, s16 mode, bool* returnValue) {
|
||||
void smlua_call_event_hooks_int_params_ret_bool(enum LuaHookedEventType hookType, s16 param, bool* returnValue) {
|
||||
lua_State* L = gLuaState;
|
||||
if (L == NULL) { return; }
|
||||
*returnValue = true;
|
||||
|
@ -490,7 +490,7 @@ void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType h
|
|||
lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]);
|
||||
|
||||
// push params
|
||||
lua_pushinteger(L, mode);
|
||||
lua_pushinteger(L, param);
|
||||
|
||||
// call the callback
|
||||
if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i])) {
|
||||
|
|
|
@ -36,6 +36,7 @@ enum LuaHookedEventType {
|
|||
HOOK_ON_PACKET_RECEIVE,
|
||||
HOOK_USE_ACT_SELECT,
|
||||
HOOK_ON_CHANGE_CAMERA_ANGLE,
|
||||
HOOK_ON_SCREEN_TRANSITION,
|
||||
HOOK_MAX,
|
||||
};
|
||||
|
||||
|
@ -65,6 +66,7 @@ static const char* LuaHookedEventTypeName[] = {
|
|||
"HOOK_ON_PACKET_RECEIVE",
|
||||
"HOOK_USE_ACT_SELECT",
|
||||
"HOOK_ON_CHANGE_CAMERA_ANGLE",
|
||||
"HOOK_ON_SCREEN_TRANSITION",
|
||||
"HOOK_MAX"
|
||||
};
|
||||
|
||||
|
@ -96,7 +98,7 @@ void smlua_call_event_hooks_interact_params_ret_bool(enum LuaHookedEventType hoo
|
|||
void smlua_call_event_hooks_object_param(enum LuaHookedEventType hookType, struct Object* obj);
|
||||
bool smlua_call_event_hooks_ret_int(enum LuaHookedEventType hookType, s32* returnValue);
|
||||
void smlua_call_event_hooks_set_camera_mode_params(enum LuaHookedEventType hookType, struct Camera *c, s16 mode, s16 frames, bool* returnValue);
|
||||
void smlua_call_event_hooks_change_camera_angle_params(enum LuaHookedEventType hookType, s16 mode, bool* returnValue);
|
||||
void smlua_call_event_hooks_int_params_ret_bool(enum LuaHookedEventType hookType, s16 param, bool* returnValue);
|
||||
void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int modIndex, int valueIndex);
|
||||
void smlua_call_event_hooks_use_act_select(enum LuaHookedEventType hookType, int value, bool* foundHook, bool* returnValue);
|
||||
|
||||
|
|
Loading…
Reference in a new issue