Fixed receiving of health, made recovery heart 2-player aware

This commit is contained in:
MysterD 2020-08-07 22:27:15 -07:00
parent 2a0a3df34f
commit 4b61f7212b
3 changed files with 20 additions and 4 deletions

3
.gitignore vendored
View File

@ -81,3 +81,6 @@ sm64config.txt
# visual studio
build-windows-visual-studio/.vs
# misc
todo.txt

View File

@ -12,14 +12,21 @@ struct ObjectHitbox sRecoveryHeartHitbox = {
};
void bhv_recovery_heart_loop(void) {
u8 collided = FALSE;
obj_set_hitbox(o, &sRecoveryHeartHitbox);
if (obj_check_if_collided_with_object(o, gMarioObject)) {
for (int i = 0; i < MAX_PLAYERS; i++) {
if (obj_check_if_collided_with_object(o, gMarioStates[i].marioObj)) { collided = TRUE; }
}
if (collided) {
if (o->oSpinningHeartPlayedSound == 0) {
cur_obj_play_sound_2(SOUND_GENERAL_HEART_SPIN);
o->oSpinningHeartPlayedSound += 1;
}
o->oAngleVelYaw = (s32)(200.0f * gMarioStates[0].forwardVel) + 1000;
struct MarioState* marioState = nearest_mario_state_to_object(o);
o->oAngleVelYaw = (s32)(200.0f * marioState->forwardVel) + 1000;
} else {
o->oSpinningHeartPlayedSound = 0;
@ -30,7 +37,13 @@ void bhv_recovery_heart_loop(void) {
}
if ((o->oSpinningHeartTotalSpin += o->oAngleVelYaw) >= 0x10000) {
gMarioStates[0].healCounter += 4;
struct MarioState* nearestState = nearest_mario_state_to_object(o);
for (int i = 0; i < MAX_PLAYERS; i++) {
if (&gMarioState[i] == nearestState || dist_between_objects(o, gMarioState[i].marioObj) < 1000) {
gMarioStates[i].healCounter += 4;
}
}
o->oSpinningHeartTotalSpin -= 0x10000;
}

View File

@ -28,7 +28,7 @@ void network_receive_player(struct Packet* p) {
packet_read(p, &gMarioStates[1], 96);
packet_read(p, gMarioStates[1].controller, 20);
packet_read(p, &gMarioStates[1].marioObj->rawData.asU32, 320);
packet_write(p, &gMarioStates[1].health, 2);
packet_read(p, &gMarioStates[1].health, 2);
packet_read(p, &heldSyncID, 4);
if (heldSyncID != NULL) {