mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-12-01 16:27:27 +00:00
Fixed player interactions
This commit is contained in:
parent
d0c8b2f100
commit
c8a0e6da10
5 changed files with 97 additions and 1 deletions
|
@ -3760,6 +3760,14 @@ function get_door_save_file_flag(door)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param m MarioState
|
||||||
|
--- @param interactType integer
|
||||||
|
--- @param o Object
|
||||||
|
--- @return integer
|
||||||
|
function interact_damage(m, interactType, o)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param m MarioState
|
--- @param m MarioState
|
||||||
--- @param capSpeed number
|
--- @param capSpeed number
|
||||||
--- @return nil
|
--- @return nil
|
||||||
|
@ -3837,6 +3845,13 @@ function passes_pvp_interaction_checks(attacker, victim)
|
||||||
-- ...
|
-- ...
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- @param m MarioState
|
||||||
|
--- @param o Object
|
||||||
|
--- @return integer
|
||||||
|
function take_damage_and_knock_back(m, o)
|
||||||
|
-- ...
|
||||||
|
end
|
||||||
|
|
||||||
--- @param courseNum integer
|
--- @param courseNum integer
|
||||||
--- @param levelNum integer
|
--- @param levelNum integer
|
||||||
--- @param areaIndex integer
|
--- @param areaIndex integer
|
||||||
|
|
|
@ -732,6 +732,7 @@
|
||||||
- interaction.h
|
- interaction.h
|
||||||
- [does_mario_have_normal_cap_on_head](#does_mario_have_normal_cap_on_head)
|
- [does_mario_have_normal_cap_on_head](#does_mario_have_normal_cap_on_head)
|
||||||
- [get_door_save_file_flag](#get_door_save_file_flag)
|
- [get_door_save_file_flag](#get_door_save_file_flag)
|
||||||
|
- [interact_damage](#interact_damage)
|
||||||
- [mario_blow_off_cap](#mario_blow_off_cap)
|
- [mario_blow_off_cap](#mario_blow_off_cap)
|
||||||
- [mario_check_object_grab](#mario_check_object_grab)
|
- [mario_check_object_grab](#mario_check_object_grab)
|
||||||
- [mario_drop_held_object](#mario_drop_held_object)
|
- [mario_drop_held_object](#mario_drop_held_object)
|
||||||
|
@ -744,6 +745,7 @@
|
||||||
- [mario_stop_riding_object](#mario_stop_riding_object)
|
- [mario_stop_riding_object](#mario_stop_riding_object)
|
||||||
- [mario_throw_held_object](#mario_throw_held_object)
|
- [mario_throw_held_object](#mario_throw_held_object)
|
||||||
- [passes_pvp_interaction_checks](#passes_pvp_interaction_checks)
|
- [passes_pvp_interaction_checks](#passes_pvp_interaction_checks)
|
||||||
|
- [take_damage_and_knock_back](#take_damage_and_knock_back)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -14407,6 +14409,28 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [interact_damage](#interact_damage)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local integerValue = interact_damage(m, interactType, o)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| m | [MarioState](structs.md#MarioState) |
|
||||||
|
| interactType | `integer` |
|
||||||
|
| o | [Object](structs.md#Object) |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- `integer`
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`u32 interact_damage(struct MarioState *m, UNUSED u32 interactType, struct Object *o);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## [mario_blow_off_cap](#mario_blow_off_cap)
|
## [mario_blow_off_cap](#mario_blow_off_cap)
|
||||||
|
|
||||||
### Lua Example
|
### Lua Example
|
||||||
|
@ -14652,6 +14676,27 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [take_damage_and_knock_back](#take_damage_and_knock_back)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local integerValue = take_damage_and_knock_back(m, o)`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
| Field | Type |
|
||||||
|
| ----- | ---- |
|
||||||
|
| m | [MarioState](structs.md#MarioState) |
|
||||||
|
| o | [Object](structs.md#Object) |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- `integer`
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
---
|
---
|
||||||
# functions from level_info.h
|
# functions from level_info.h
|
||||||
|
|
||||||
|
|
|
@ -2160,10 +2160,14 @@ void mario_process_interactions(struct MarioState *m) {
|
||||||
sDelayInvincTimer = FALSE;
|
sDelayInvincTimer = FALSE;
|
||||||
sInvulnerable = (m->action & ACT_FLAG_INVULNERABLE) || m->invincTimer != 0;
|
sInvulnerable = (m->action & ACT_FLAG_INVULNERABLE) || m->invincTimer != 0;
|
||||||
|
|
||||||
if (!(m->action & ACT_FLAG_INTANGIBLE) && m->collidedObjInteractTypes != 0 && is_player_active(m) && m->playerIndex == 0) {
|
if (!(m->action & ACT_FLAG_INTANGIBLE) && m->collidedObjInteractTypes != 0 && is_player_active(m)) {
|
||||||
s32 i;
|
s32 i;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
u32 interactType = sInteractionHandlers[i].interactType;
|
u32 interactType = sInteractionHandlers[i].interactType;
|
||||||
|
if (m->playerIndex != 0 && interactType != (u32)INTERACT_PLAYER) {
|
||||||
|
// skip interactions for remote
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (m->collidedObjInteractTypes & interactType) {
|
if (m->collidedObjInteractTypes & interactType) {
|
||||||
struct Object *object = mario_get_collided_object(m, interactType);
|
struct Object *object = mario_get_collided_object(m, interactType);
|
||||||
|
|
||||||
|
|
|
@ -116,5 +116,7 @@ u32 get_door_save_file_flag(struct Object *door);
|
||||||
void mario_process_interactions(struct MarioState *m);
|
void mario_process_interactions(struct MarioState *m);
|
||||||
void mario_handle_special_floors(struct MarioState *m);
|
void mario_handle_special_floors(struct MarioState *m);
|
||||||
u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* victim);
|
u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* victim);
|
||||||
|
u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o);
|
||||||
|
u32 interact_damage(struct MarioState *m, UNUSED u32 interactType, struct Object *o);
|
||||||
|
|
||||||
#endif // INTERACTION_H
|
#endif // INTERACTION_H
|
||||||
|
|
|
@ -7693,6 +7693,21 @@ int smlua_func_get_door_save_file_flag(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_interact_damage(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 3)) { return 0; }
|
||||||
|
|
||||||
|
struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
u32 interactType = smlua_to_integer(L, 2);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
struct Object* o = (struct Object*)smlua_to_cobject(L, 3, LOT_OBJECT);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
|
||||||
|
lua_pushinteger(L, interact_damage(m, interactType, o));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int smlua_func_mario_blow_off_cap(lua_State* L) {
|
int smlua_func_mario_blow_off_cap(lua_State* L) {
|
||||||
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||||
|
|
||||||
|
@ -7835,6 +7850,19 @@ int smlua_func_passes_pvp_interaction_checks(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_take_damage_and_knock_back(lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 2)) { return 0; }
|
||||||
|
|
||||||
|
struct MarioState* m = (struct MarioState*)smlua_to_cobject(L, 1, LOT_MARIOSTATE);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
struct Object* o = (struct Object*)smlua_to_cobject(L, 2, LOT_OBJECT);
|
||||||
|
if (!gSmLuaConvertSuccess) { return 0; }
|
||||||
|
|
||||||
|
lua_pushinteger(L, take_damage_and_knock_back(m, o));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// level_info.h //
|
// level_info.h //
|
||||||
//////////////////
|
//////////////////
|
||||||
|
@ -16492,6 +16520,7 @@ void smlua_bind_functions_autogen(void) {
|
||||||
// interaction.h
|
// interaction.h
|
||||||
smlua_bind_function(L, "does_mario_have_normal_cap_on_head", smlua_func_does_mario_have_normal_cap_on_head);
|
smlua_bind_function(L, "does_mario_have_normal_cap_on_head", smlua_func_does_mario_have_normal_cap_on_head);
|
||||||
smlua_bind_function(L, "get_door_save_file_flag", smlua_func_get_door_save_file_flag);
|
smlua_bind_function(L, "get_door_save_file_flag", smlua_func_get_door_save_file_flag);
|
||||||
|
smlua_bind_function(L, "interact_damage", smlua_func_interact_damage);
|
||||||
smlua_bind_function(L, "mario_blow_off_cap", smlua_func_mario_blow_off_cap);
|
smlua_bind_function(L, "mario_blow_off_cap", smlua_func_mario_blow_off_cap);
|
||||||
smlua_bind_function(L, "mario_check_object_grab", smlua_func_mario_check_object_grab);
|
smlua_bind_function(L, "mario_check_object_grab", smlua_func_mario_check_object_grab);
|
||||||
smlua_bind_function(L, "mario_drop_held_object", smlua_func_mario_drop_held_object);
|
smlua_bind_function(L, "mario_drop_held_object", smlua_func_mario_drop_held_object);
|
||||||
|
@ -16504,6 +16533,7 @@ void smlua_bind_functions_autogen(void) {
|
||||||
smlua_bind_function(L, "mario_stop_riding_object", smlua_func_mario_stop_riding_object);
|
smlua_bind_function(L, "mario_stop_riding_object", smlua_func_mario_stop_riding_object);
|
||||||
smlua_bind_function(L, "mario_throw_held_object", smlua_func_mario_throw_held_object);
|
smlua_bind_function(L, "mario_throw_held_object", smlua_func_mario_throw_held_object);
|
||||||
smlua_bind_function(L, "passes_pvp_interaction_checks", smlua_func_passes_pvp_interaction_checks);
|
smlua_bind_function(L, "passes_pvp_interaction_checks", smlua_func_passes_pvp_interaction_checks);
|
||||||
|
smlua_bind_function(L, "take_damage_and_knock_back", smlua_func_take_damage_and_knock_back);
|
||||||
|
|
||||||
// level_info.h
|
// level_info.h
|
||||||
smlua_bind_function(L, "get_level_name", smlua_func_get_level_name);
|
smlua_bind_function(L, "get_level_name", smlua_func_get_level_name);
|
||||||
|
|
Loading…
Reference in a new issue