mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Added hooks: HOOK_ON_LEVEL_INIT, HOOK_ON_WARP, HOOK_ON_SYNC_VALID
This commit is contained in:
parent
580c5baeb3
commit
7252d836a9
7 changed files with 40 additions and 3 deletions
|
@ -5282,7 +5282,16 @@ HOOK_ON_HUD_RENDER = 9
|
|||
HOOK_ON_INTERACT = 10
|
||||
|
||||
--- @type LuaHookedEventType
|
||||
HOOK_MAX = 11
|
||||
HOOK_ON_LEVEL_INIT = 11
|
||||
|
||||
--- @type LuaHookedEventType
|
||||
HOOK_ON_WARP = 12
|
||||
|
||||
--- @type LuaHookedEventType
|
||||
HOOK_ON_SYNC_VALID = 13
|
||||
|
||||
--- @type LuaHookedEventType
|
||||
HOOK_MAX = 14
|
||||
|
||||
--- @class ModelExtendedId
|
||||
|
||||
|
|
|
@ -1858,7 +1858,10 @@
|
|||
| HOOK_ON_PLAYER_DISCONNECTED | 8 |
|
||||
| HOOK_ON_HUD_RENDER | 9 |
|
||||
| HOOK_ON_INTERACT | 10 |
|
||||
| HOOK_MAX | 11 |
|
||||
| HOOK_ON_LEVEL_INIT | 11 |
|
||||
| HOOK_ON_WARP | 12 |
|
||||
| HOOK_ON_SYNC_VALID | 13 |
|
||||
| HOOK_MAX | 14 |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -97,6 +97,9 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
|||
| HOOK_ON_PLAYER_DISCONNECTED | Called when a player disconnects | [MarioState](structs.md#MarioState) disconnector |
|
||||
| HOOK_ON_HUD_RENDER | Called when the HUD is being rendered | None |
|
||||
| HOOK_ON_INTERACT | Called when mario interacts with an object | [MarioState](structs.md#MarioState) interactor, [Object](structs.md#Object) interactee, [enum InteractionType](constants.md#enum-InteractionType) interactType, bool interactValue |
|
||||
| HOOK_ON_LEVEL_INIT | Called when the level is initialized | None |
|
||||
| HOOK_ON_WARP | Called when the local player warps | None |
|
||||
| HOOK_ON_SYNC_VALID | Called when the current area is synchronized | None |
|
||||
|
||||
### Parameters
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "pc/configfile.h"
|
||||
#include "pc/network/network.h"
|
||||
#include "pc/djui/djui.h"
|
||||
#include "pc/lua/smlua_hooks.h"
|
||||
|
||||
#include "game/screen_transition.h"
|
||||
|
||||
|
@ -521,6 +522,7 @@ void init_mario_after_warp(void) {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
smlua_call_event_hooks(HOOK_ON_WARP);
|
||||
}
|
||||
|
||||
// used for warps inside one level
|
||||
|
@ -1413,6 +1415,8 @@ s32 init_level(void) {
|
|||
sound_banks_disable(SEQ_PLAYER_SFX, SOUND_BANKS_DISABLED_DURING_INTRO_CUTSCENE);
|
||||
}
|
||||
|
||||
smlua_call_event_hooks(HOOK_ON_LEVEL_INIT);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1900,7 +1900,10 @@ char gSmluaConstants[] = ""
|
|||
"HOOK_ON_PLAYER_DISCONNECTED = 8\n"
|
||||
"HOOK_ON_HUD_RENDER = 9\n"
|
||||
"HOOK_ON_INTERACT = 10\n"
|
||||
"HOOK_MAX = 11\n"
|
||||
"HOOK_ON_LEVEL_INIT = 11\n"
|
||||
"HOOK_ON_WARP = 12\n"
|
||||
"HOOK_ON_SYNC_VALID = 13\n"
|
||||
"HOOK_MAX = 14\n"
|
||||
"E_MODEL_NONE = 0\n"
|
||||
"E_MODEL_MARIO = 1\n"
|
||||
"E_MODEL_SMOKE = 2\n"
|
||||
|
|
|
@ -16,6 +16,9 @@ enum LuaHookedEventType {
|
|||
HOOK_ON_PLAYER_DISCONNECTED,
|
||||
HOOK_ON_HUD_RENDER,
|
||||
HOOK_ON_INTERACT,
|
||||
HOOK_ON_LEVEL_INIT,
|
||||
HOOK_ON_WARP,
|
||||
HOOK_ON_SYNC_VALID,
|
||||
HOOK_MAX,
|
||||
};
|
||||
|
||||
|
@ -31,6 +34,9 @@ static char* LuaHookedEventTypeName[] = {
|
|||
"HOOK_ON_PLAYER_DISCONNECTED",
|
||||
"HOOK_ON_HUD_RENDER",
|
||||
"HOOK_ON_INTERACT",
|
||||
"HOOK_ON_LEVEL_INIT",
|
||||
"HOOK_ON_WARP",
|
||||
"HOOK_ON_SYNC_VALID",
|
||||
"HOOK_MAX"
|
||||
};
|
||||
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
#include <stdio.h>
|
||||
#include "../network.h"
|
||||
#include "pc/lua/smlua_hooks.h"
|
||||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_sync_valid(struct NetworkPlayer* toNp, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
if (toNp == gNetworkPlayerLocal && !toNp->currAreaSyncValid) {
|
||||
smlua_call_event_hooks(HOOK_ON_SYNC_VALID);
|
||||
}
|
||||
|
||||
// set the NetworkPlayers sync valid
|
||||
toNp->currLevelSyncValid = true;
|
||||
toNp->currAreaSyncValid = true;
|
||||
|
@ -55,6 +60,10 @@ void network_receive_sync_valid(struct Packet* p) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (np == gNetworkPlayerLocal && !np->currAreaSyncValid) {
|
||||
smlua_call_event_hooks(HOOK_ON_SYNC_VALID);
|
||||
}
|
||||
|
||||
np->currLevelSyncValid = true;
|
||||
np->currAreaSyncValid = true;
|
||||
|
||||
|
|
Loading…
Reference in a new issue