mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +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))
|
&& !(marioState->action & (ACT_FLAG_SHORT_HITBOX | ACT_FLAG_BUTT_OR_STOMACH_SLIDE))
|
||||||
&& distanceToPlayer < 200.0f && dy > 50.0f && dy < 90.0f) {
|
&& distanceToPlayer < 200.0f && dy > 50.0f && dy < 90.0f) {
|
||||||
if (network_owns_object(o) && mario_lose_cap_to_enemy(marioState, 1)) {
|
if (network_owns_object(o) && mario_lose_cap_to_enemy(marioState, 1)) {
|
||||||
u8 isLuigi = (gNetworkType == NT_SERVER) ? (marioState->playerIndex != 0) : (marioState->playerIndex == 0);
|
o->oAnimState = marioState->character->capKleptoAnimState;
|
||||||
if (isLuigi) {
|
|
||||||
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP_LUIGI;
|
|
||||||
} else {
|
|
||||||
o->oAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP;
|
|
||||||
}
|
|
||||||
network_send_object(o);
|
network_send_object(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,10 +414,18 @@ void bhv_klepto_update(void) {
|
||||||
if (obj_handle_attacks(&sKleptoHitbox, o->oAction, sKleptoAttackHandlers)) {
|
if (obj_handle_attacks(&sKleptoHitbox, o->oAction, sKleptoAttackHandlers)) {
|
||||||
cur_obj_play_sound_2(SOUND_OBJ_KLEPTO2);
|
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);
|
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* cap = spawn_object(o, capModel, bhvNormalCap);
|
||||||
|
|
||||||
struct Object* spawn_objects[] = { cap };
|
struct Object* spawn_objects[] = { cap };
|
||||||
|
|
|
@ -688,12 +688,7 @@ void bhv_ukiki_loop(void) {
|
||||||
for (int i = 0; i < MAX_PLAYERS; i++) {
|
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||||
if (!is_player_active(&gMarioStates[i])) { continue; }
|
if (!is_player_active(&gMarioStates[i])) { continue; }
|
||||||
if (!does_mario_have_hat(&gMarioStates[i])) {
|
if (!does_mario_have_hat(&gMarioStates[i])) {
|
||||||
u8 isLuigi = (gNetworkType == NT_SERVER) ? (gMarioStates[i].playerIndex != 0) : (gMarioStates[i].playerIndex == 0);
|
o->oAnimState = gMarioStates[i].character->capUkikiAnimState;
|
||||||
if(isLuigi) {
|
|
||||||
o->oAnimState = UKIKI_ANIM_STATE_HAT_ON_LUIGI;
|
|
||||||
} else {
|
|
||||||
o->oAnimState = UKIKI_ANIM_STATE_HAT_ON;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,23 @@
|
||||||
#include "characters.h"
|
#include "characters.h"
|
||||||
#include "hud.h"
|
#include "hud.h"
|
||||||
#include "model_ids.h"
|
#include "model_ids.h"
|
||||||
|
#include "object_constants.h"
|
||||||
|
|
||||||
struct Character gCharacters[CT_MAX] = {
|
struct Character gCharacters[CT_MAX] = {
|
||||||
[CT_MARIO] = {
|
[CT_MARIO] = {
|
||||||
.hudHead = ',',
|
.hudHead = ',',
|
||||||
.cameraHudHead = GLYPH_CAM_MARIO_HEAD,
|
.cameraHudHead = GLYPH_CAM_MARIO_HEAD,
|
||||||
.modelId = MODEL_MARIO,
|
.modelId = MODEL_MARIO,
|
||||||
|
.capModelId = MODEL_MARIOS_CAP,
|
||||||
|
.capKleptoAnimState = KLEPTO_ANIM_STATE_HOLDING_CAP,
|
||||||
|
.capUkikiAnimState = UKIKI_ANIM_STATE_HAT_ON,
|
||||||
},
|
},
|
||||||
[CT_LUIGI] = {
|
[CT_LUIGI] = {
|
||||||
.hudHead = '.',
|
.hudHead = '.',
|
||||||
.cameraHudHead = GLYPH_CAM_LUIGI_HEAD,
|
.cameraHudHead = GLYPH_CAM_LUIGI_HEAD,
|
||||||
.modelId = MODEL_LUIGI,
|
.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;
|
char hudHead;
|
||||||
u32 cameraHudHead;
|
u32 cameraHudHead;
|
||||||
u32 modelId;
|
u32 modelId;
|
||||||
|
u32 capModelId;
|
||||||
|
s32 capKleptoAnimState;
|
||||||
|
s32 capUkikiAnimState;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct Character gCharacters[];
|
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) {
|
void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
||||||
|
if (m->playerIndex != 0) { return; }
|
||||||
struct Object *capObject;
|
struct Object *capObject;
|
||||||
|
|
||||||
if (does_mario_have_hat(m)) {
|
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);
|
m->flags &= ~(MARIO_NORMAL_CAP | MARIO_CAP_ON_HEAD);
|
||||||
|
|
||||||
u8 isLuigi = (gNetworkType == NT_SERVER) ? (m->playerIndex != 0) : (m->playerIndex == 0);
|
u8 capModel = m->character->capModelId;
|
||||||
capObject = spawn_object(m->marioObj, isLuigi ? MODEL_LUIGIS_CAP : MODEL_MARIOS_CAP, bhvNormalCap);
|
capObject = spawn_object(m->marioObj, capModel, bhvNormalCap);
|
||||||
|
|
||||||
capObject->oPosY += (m->action & ACT_FLAG_SHORT_HITBOX) ? 120.0f : 180.0f;
|
capObject->oPosY += (m->action & ACT_FLAG_SHORT_HITBOX) ? 120.0f : 180.0f;
|
||||||
capObject->oForwardVel = capSpeed;
|
capObject->oForwardVel = capSpeed;
|
||||||
|
@ -397,6 +398,13 @@ void mario_blow_off_cap(struct MarioState *m, f32 capSpeed) {
|
||||||
if (m->forwardVel < 0.0f) {
|
if (m->forwardVel < 0.0f) {
|
||||||
capObject->oMoveAngleYaw = (s16)(capObject->oMoveAngleYaw + 0x8000);
|
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_send_network_players(void);
|
||||||
void network_receive_network_players(struct Packet* p);
|
void network_receive_network_players(struct Packet* p);
|
||||||
|
|
||||||
|
// packet_death.c
|
||||||
|
void network_send_death(void);
|
||||||
|
void network_receive_death(struct Packet* p);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "sm64.h"
|
#include "sm64.h"
|
||||||
#include "../network.h"
|
#include "../network.h"
|
||||||
|
|
||||||
extern struct MarioState gMarioStates[];
|
void network_send_death(void) {
|
||||||
|
if (gMarioStates[0].numLives < -1) { gMarioStates[0].numLives = -1; }
|
||||||
void network_send_death(void) {
|
struct Packet p = { 0 };
|
||||||
if (gMarioStates[0].numLives < -1) { gMarioStates[0].numLives = -1; }
|
packet_init(&p, PACKET_DEATH, true, false);
|
||||||
struct Packet p = { 0 };
|
packet_write(&p, &gMarioStates[0].numLives, sizeof(u8));
|
||||||
packet_init(&p, PACKET_DEATH, true, false);
|
network_send(&p);
|
||||||
packet_write(&p, &gMarioStates[0].numLives, sizeof(u8));
|
}
|
||||||
network_send(&p);
|
|
||||||
}
|
void network_receive_death(struct Packet* p) {
|
||||||
void network_receive_death(struct Packet* p) {
|
u8 numLives = 0;
|
||||||
u8 numLives = 0;
|
packet_read(p, &numLives, sizeof(u8));
|
||||||
packet_read(p, &numLives, sizeof(u8));
|
if (numLives < gMarioStates[0].numLives) {
|
||||||
if (numLives < gMarioStates[0].numLives) {
|
gMarioStates[0].numLives = numLives;
|
||||||
gMarioStates[0].numLives = numLives;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue