mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Allow wind to be ignored with HOOK_ALLOW_HAZARD_SURFACE (#721)
* Update constants.md * Update constants.lua * Update smlua_constants_autogen.c * Update surface_terrains.h * Update hooks.md * Add files via upload
This commit is contained in:
parent
c5bf411a2a
commit
c26e968076
7 changed files with 36 additions and 10 deletions
|
|
@ -11224,6 +11224,12 @@ HAZARD_TYPE_LAVA_WALL = 2
|
|||
--- @type integer
|
||||
HAZARD_TYPE_QUICKSAND = 3
|
||||
|
||||
--- @type integer
|
||||
HAZARD_TYPE_HORIZONTAL_WIND = 4
|
||||
|
||||
--- @type integer
|
||||
HAZARD_TYPE_VERTICAL_WIND = 5
|
||||
|
||||
--- @type integer
|
||||
SURFACE_0004 = 0x0004
|
||||
|
||||
|
|
|
|||
|
|
@ -4705,6 +4705,8 @@
|
|||
- HAZARD_TYPE_LAVA_FLOOR
|
||||
- HAZARD_TYPE_LAVA_WALL
|
||||
- HAZARD_TYPE_QUICKSAND
|
||||
- HAZARD_TYPE_HORIZONTAL_WIND
|
||||
- HAZARD_TYPE_VERTICAL_WIND
|
||||
- SURFACE_0004
|
||||
- SURFACE_BOSS_FIGHT_CAMERA
|
||||
- SURFACE_BURNING
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
|||
| 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, return `false` to prevent the transition from playing | `integer` type |
|
||||
| HOOK_ALLOW_HAZARD_SURFACE | Called once per player per frame. Return `false` to prevent the player from being affected by lava or quicksand | [MarioState](../structs.md#MarioState) mario, `integer` hazardType |
|
||||
| HOOK_ALLOW_HAZARD_SURFACE | Called once per player per frame. Return `false` to prevent the player from being affected by lava, quicksand, or wind | [MarioState](../structs.md#MarioState) mario, `integer` hazardType |
|
||||
| HOOK_ON_CHAT_MESSAGE | Called when a chat message gets sent. Return `false` to prevent the message from being sent | [MarioState](../structs.md#MarioState) messageSender, `string` messageSent |
|
||||
| HOOK_OBJECT_SET_MODEL | Called when a behavior changes models. Also runs when a behavior spawns | [Object](../structs.md#Object) obj, `integer` modelID |
|
||||
| HOOK_CHARACTER_SOUND | Called when mario retrieves a character sound to play, return a character sound or `0` to override it | [MarioState](../structs.md#MarioState) mario, [enum CharacterSound](../constants.md#enum-CharacterSound) characterSound |
|
||||
|
|
|
|||
|
|
@ -165,9 +165,11 @@
|
|||
#define SURFACE_FLAG_NO_CAM_COLLISION (1 << 1)
|
||||
#define SURFACE_FLAG_X_PROJECTION (1 << 3)
|
||||
|
||||
#define HAZARD_TYPE_LAVA_FLOOR 1
|
||||
#define HAZARD_TYPE_LAVA_WALL 2
|
||||
#define HAZARD_TYPE_QUICKSAND 3
|
||||
#define HAZARD_TYPE_LAVA_FLOOR 1
|
||||
#define HAZARD_TYPE_LAVA_WALL 2
|
||||
#define HAZARD_TYPE_QUICKSAND 3
|
||||
#define HAZARD_TYPE_HORIZONTAL_WIND 4
|
||||
#define HAZARD_TYPE_VERTICAL_WIND 5
|
||||
|
||||
// These are effectively unique "surface" types like those defined higher
|
||||
// And they are used as collision commands to load certain functions
|
||||
|
|
|
|||
|
|
@ -206,9 +206,15 @@ s32 check_horizontal_wind(struct MarioState *m) {
|
|||
struct Surface *floor;
|
||||
f32 speed;
|
||||
s16 pushAngle;
|
||||
bool allow = true;
|
||||
smlua_call_event_hooks_mario_param_and_int_ret_bool(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_HORIZONTAL_WIND, &allow);
|
||||
if (!allow) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
floor = m->floor;
|
||||
|
||||
|
||||
if (floor && floor->type == SURFACE_HORIZONTAL_WIND) {
|
||||
pushAngle = floor->force << 8;
|
||||
|
||||
|
|
@ -2299,7 +2305,9 @@ s32 check_common_airborne_cancels(struct MarioState *m) {
|
|||
return drop_and_set_mario_action(m, ACT_SQUISHED, 0);
|
||||
}
|
||||
|
||||
if (m->floor && m->floor->type == SURFACE_VERTICAL_WIND && (m->action & ACT_FLAG_ALLOW_VERTICAL_WIND_ACTION)) {
|
||||
bool allow = true;
|
||||
smlua_call_event_hooks_mario_param_and_int_ret_bool(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_VERTICAL_WIND, &allow);
|
||||
if (allow && m->floor && m->floor->type == SURFACE_VERTICAL_WIND && (m->action & ACT_FLAG_ALLOW_VERTICAL_WIND_ACTION)) {
|
||||
return drop_and_set_mario_action(m, ACT_VERTICAL_WIND, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -206,6 +206,11 @@ u32 mario_update_windy_ground(struct MarioState *m) {
|
|||
if (!m) { return 0; }
|
||||
struct Surface *floor = m->floor;
|
||||
if (!floor) { return 0; }
|
||||
bool allow = true;
|
||||
smlua_call_event_hooks_mario_param_and_int_ret_bool(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_HORIZONTAL_WIND, &allow);
|
||||
if (!allow) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extern bool gDjuiInMainMenu;
|
||||
if (floor->type == SURFACE_HORIZONTAL_WIND && !gDjuiInMainMenu) {
|
||||
|
|
@ -697,8 +702,9 @@ void apply_vertical_wind(struct MarioState *m) {
|
|||
if (!m) { return; }
|
||||
f32 maxVelY;
|
||||
f32 offsetY;
|
||||
|
||||
if (m->action != ACT_GROUND_POUND) {
|
||||
bool allow = true;
|
||||
smlua_call_event_hooks_mario_param_and_int_ret_bool(HOOK_ALLOW_HAZARD_SURFACE, m, HAZARD_TYPE_VERTICAL_WIND, &allow);
|
||||
if (m->action != ACT_GROUND_POUND && allow) {
|
||||
offsetY = m->pos[1] - -1500.0f;
|
||||
|
||||
if (m->floor && m->floor->type == SURFACE_VERTICAL_WIND && -3000.0f < offsetY && offsetY < 2000.0f) {
|
||||
|
|
|
|||
|
|
@ -4687,6 +4687,8 @@ char gSmluaConstants[] = ""
|
|||
"HAZARD_TYPE_LAVA_FLOOR=1\n"
|
||||
"HAZARD_TYPE_LAVA_WALL=2\n"
|
||||
"HAZARD_TYPE_QUICKSAND=3\n"
|
||||
"HAZARD_TYPE_HORIZONTAL_WIND=4\n"
|
||||
"HAZARD_TYPE_VERTICAL_WIND=5\n"
|
||||
"TERRAIN_LOAD_VERTICES=0x0040\n"
|
||||
"TERRAIN_LOAD_CONTINUE=0x0041\n"
|
||||
"TERRAIN_LOAD_END=0x0042\n"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue