mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-22 12:05:11 +00:00
Misc adjustments to recent PRs
Switched from manual checking of Luigi to using new Character structs Synchronized cap spawning for mario_blow_off_cap() Added declarations for network_send_death() and network_receive_death()
This commit is contained in:
parent
05fd683c64
commit
2b0f892251
7 changed files with 56 additions and 37 deletions
|
@ -291,12 +291,7 @@ static void klepto_act_dive_at_mario(void) {
|
|||
&& !(marioState->action & (ACT_FLAG_SHORT_HITBOX | ACT_FLAG_BUTT_OR_STOMACH_SLIDE))
|
||||
&& distanceToPlayer < 200.0f && dy > 50.0f && dy < 90.0f) {
|
||||
if (network_owns_object(o) && mario_lose_cap_to_enemy(marioState, 1)) {
|
||||
u8 isLuigi = (gNetworkType == NT_SERVER) ? (marioState->playerIndex != 0) : (marioState->playerIndex == 0);
|
||||
if (isLuigi) {
|
||||
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP_LUIGI;
|
||||
} else {
|
||||
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP;
|
||||
}
|
||||
o->oAnimState = marioState->character->capKleptoAnimState;
|
||||
network_send_object(o);
|
||||
}
|
||||
}
|
||||
|
@ -419,10 +414,18 @@ void bhv_klepto_update(void) {
|
|||
if (obj_handle_attacks(&sKleptoHitbox, o->oAction, sKleptoAttackHandlers)) {
|
||||
cur_obj_play_sound_2(SOUND_OBJ_KLEPTO2);
|
||||
|
||||
if (network_owns_object(o) && (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_CAP || o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_CAP_LUIGI)) {
|
||||
u8 kleptoHoldingCap = FALSE;
|
||||
u32 capModel = MODEL_MARIOS_CAP;
|
||||
for (int i = 0; i < CT_MAX; i++) {
|
||||
if (o->oAnimState == gCharacters[i].capKleptoAnimState) {
|
||||
kleptoHoldingCap = TRUE;
|
||||
capModel = gCharacters[i].capModelId;
|
||||
}
|
||||
}
|
||||
|
||||
if (network_owns_object(o) && kleptoHoldingCap) {
|
||||
save_file_clear_flags(SAVE_FLAG_CAP_ON_KLEPTO);
|
||||
|
||||
u8 capModel = (o->oAnimState == KLEPTO_ANIM_STATE_HOLDING_CAP) ? MODEL_MARIOS_CAP : MODEL_LUIGIS_CAP;
|
||||
struct Object* cap = spawn_object(o, capModel, bhvNormalCap);
|
||||
|
||||
struct Object* spawn_objects[] = { cap };
|
||||
|
|
|
@ -688,12 +688,7 @@ void bhv_ukiki_loop(void) {
|
|||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||
if (!is_player_active(&gMarioStates[i])) { continue; }
|
||||
if (!does_mario_have_hat(&gMarioStates[i])) {
|
||||
u8 isLuigi = (gNetworkType == NT_SERVER) ? (gMarioStates[i].playerIndex != 0) : (gMarioStates[i].playerIndex == 0);
|
||||
if(isLuigi) {
|
||||
o->oAnimState = UKIKI_ANIM_STATE_HAT_ON_LUIGI;
|
||||
} else {
|
||||
o->oAnimState = UKIKI_ANIM_STATE_HAT_ON;
|
||||
}
|
||||
o->oAnimState = gMarioStates[i].character->capUkikiAnimState;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
#include "characters.h"
|
||||
#include "hud.h"
|
||||
#include "model_ids.h"
|
||||
#include "object_constants.h"
|
||||
|
||||
struct Character gCharacters[CT_MAX] = {
|
||||
[CT_MARIO] = {
|
||||
.hudHead = ',',
|
||||
.cameraHudHead = GLYPH_CAM_MARIO_HEAD,
|
||||
.modelId = MODEL_MARIO,
|
||||
.capModelId = MODEL_MARIOS_CAP,
|
||||
.capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP,
|
||||
.capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON,
|
||||
},
|
||||
[CT_LUIGI] = {
|
||||
.hudHead = '.',
|
||||
.cameraHudHead = GLYPH_CAM_LUIGI_HEAD,
|
||||
.modelId = MODEL_LUIGI,
|
||||
.capModelId = MODEL_LUIGIS_CAP,
|
||||
.capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP_LUIGI,
|
||||
.capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON_LUIGI,
|
||||
},
|
||||
};
|
|
@ -15,6 +15,9 @@ struct Character {
|
|||
char hudHead;
|
||||
u32 cameraHudHead;
|
||||
u32 modelId;
|
||||
u32 capModelId;
|
||||
s32 capKleptoAnimState;
|
||||
s32 capUkikiAnimState;
|
||||
};
|
||||
|
||||
extern struct Character gCharacters[];
|
||||
|
|
|
@ -380,6 +380,7 @@ u32 does_mario_have_hat(struct MarioState *m) {
|
|||
}
|
||||
|
||||
void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
||||
if (m->playerIndex != 0) { return; }
|
||||
struct Object *capObject;
|
||||
|
||||
if (does_mario_have_hat(m)) {
|
||||
|
@ -387,8 +388,8 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
|||
|
||||
m->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
||||
|
||||
u8 isLuigi = (gNetworkType == NT_SERVER) ? (m->playerIndex != 0) : (m->playerIndex == 0);
|
||||
capObject = spawn_object(m->marioObj, isLuigi ? MODEL_LUIGIS_CAP : MODEL_MARIOS_CAP, bhvNormalCap);
|
||||
u8 capModel = m->character->capModelId;
|
||||
capObject = spawn_object(m->marioObj, capModel, bhvNormalCap);
|
||||
|
||||
capObject->oPosY += (m->action & ACT_FLAG_SHORT_HITBOX) ? 120.0f : 180.0f;
|
||||
capObject->oForwardVel = capSpeed;
|
||||
|
@ -397,6 +398,13 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
|||
if (m->forwardVel < 0.0f) {
|
||||
capObject->oMoveAngleYaw = (s16)(capObject->oMoveAngleYaw + 0x8000);
|
||||
}
|
||||
|
||||
// set as it's own parent so we can spawn it over the network
|
||||
capObject->parentObj = capObject;
|
||||
|
||||
struct Object* spawn_objects[] = { capObject };
|
||||
u32 models[] = { capModel };
|
||||
network_send_spawn_objects(spawn_objects, models, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,4 +167,8 @@ void network_receive_instant_warp(struct Packet* p);
|
|||
void network_send_network_players(void);
|
||||
void network_receive_network_players(struct Packet* p);
|
||||
|
||||
// packet_death.c
|
||||
void network_send_death(void);
|
||||
void network_receive_death(struct Packet* p);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
#include "sm64.h"
|
||||
#include "../network.h"
|
||||
|
||||
extern struct MarioState gMarioStates[];
|
||||
|
||||
void network_send_death(void) {
|
||||
if (gMarioStates[0].numLives < -1) { gMarioStates[0].numLives = -1; }
|
||||
struct Packet p = { 0 };
|
||||
|
@ -11,6 +9,7 @@ void network_send_death(void) {
|
|||
packet_write(&p, &gMarioStates[0].numLives, sizeof(u8));
|
||||
network_send(&p);
|
||||
}
|
||||
|
||||
void network_receive_death(struct Packet* p) {
|
||||
u8 numLives = 0;
|
||||
packet_read(p, &numLives, sizeof(u8));
|
||||
|
|
Loading…
Reference in a new issue