mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Synchronized baby and mother Tuxie
Added missing star parameter
This commit is contained in:
parent
c26bf586e1
commit
8c7348f10d
6 changed files with 83 additions and 27 deletions
|
|
@ -124,31 +124,34 @@ struct Object *spawn_star(struct Object *sp30, f32 sp34, f32 sp38, f32 sp3C) {
|
|||
struct Object* spawn_default_star(f32 x, f32 y, f32 z) {
|
||||
if (gSpawnedStarDefault) { return NULL; }
|
||||
struct Object *star;
|
||||
u32 behParams = o->oBehParams;
|
||||
star = spawn_star(star, x, y, z);
|
||||
star->oBehParams2ndByte = 0;
|
||||
gSpawnedStarDefault = TRUE;
|
||||
network_send_spawn_star(star, 0, x, y, z);
|
||||
network_send_spawn_star(star, 0, x, y, z, behParams);
|
||||
return star;
|
||||
}
|
||||
|
||||
struct Object* spawn_red_coin_cutscene_star(f32 x, f32 y, f32 z) {
|
||||
if (gSpawnedStarRedCoin) { return NULL; }
|
||||
struct Object * star;
|
||||
u32 behParams = o->oBehParams;
|
||||
star = spawn_star(star, x, y, z);
|
||||
star->oBehParams2ndByte = 1;
|
||||
gSpawnedStarRedCoin = TRUE;
|
||||
network_send_spawn_star(star, 1, x, y, z);
|
||||
network_send_spawn_star(star, 1, x, y, z, behParams);
|
||||
return star;
|
||||
}
|
||||
|
||||
struct Object* spawn_no_exit_star(f32 x, f32 y, f32 z) {
|
||||
if (gSpawnedStarHidden) { return NULL; }
|
||||
struct Object * star;
|
||||
u32 behParams = o->oBehParams;
|
||||
star = spawn_star(star, x, y, z);
|
||||
star->oBehParams2ndByte = 1;
|
||||
star->oInteractionSubtype |= INT_SUBTYPE_NO_EXIT;
|
||||
gSpawnedStarHidden = TRUE;
|
||||
network_send_spawn_star(star, 2, x, y, z);
|
||||
network_send_spawn_star(star, 2, x, y, z, behParams);
|
||||
return star;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ void play_penguin_walking_sound(s32 walk) {
|
|||
}
|
||||
|
||||
void tuxies_mother_act_2(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
f32 sp24;
|
||||
UNUSED s32 unused;
|
||||
struct Object *sp1C = cur_obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp24);
|
||||
|
|
@ -20,13 +23,13 @@ void tuxies_mother_act_2(void) {
|
|||
if (o->oSubAction == 0) {
|
||||
cur_obj_init_animation_with_sound(0);
|
||||
o->oForwardVel = 10.0f;
|
||||
if (800.0f < cur_obj_lateral_dist_from_mario_to_home())
|
||||
if (800.0f < cur_obj_lateral_dist_from_obj_to_home(player))
|
||||
o->oSubAction = 1;
|
||||
cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400);
|
||||
cur_obj_rotate_yaw_toward(angleToPlayer, 0x400);
|
||||
} else {
|
||||
o->oForwardVel = 0.0f;
|
||||
cur_obj_init_animation_with_sound(3);
|
||||
if (cur_obj_lateral_dist_from_mario_to_home() < 700.0f)
|
||||
if (cur_obj_lateral_dist_from_obj_to_home(player) < 700.0f)
|
||||
o->oSubAction = 0;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -41,6 +44,9 @@ void tuxies_mother_act_2(void) {
|
|||
}
|
||||
|
||||
void tuxies_mother_act_1(void) {
|
||||
// only local can interact with mother
|
||||
struct MarioState* marioState = &gMarioStates[0];
|
||||
|
||||
s32 sp2C;
|
||||
s32 sp28;
|
||||
s32 dialogID;
|
||||
|
|
@ -54,7 +60,7 @@ void tuxies_mother_act_1(void) {
|
|||
dialogID = DIALOG_058;
|
||||
else
|
||||
dialogID = DIALOG_059;
|
||||
if (cur_obj_update_dialog_with_cutscene(&gMarioState[0], 2, 1, CUTSCENE_DIALOG, dialogID)) {
|
||||
if (cur_obj_update_dialog_with_cutscene(marioState, 2, 1, CUTSCENE_DIALOG, dialogID)) {
|
||||
if (dialogID == DIALOG_058)
|
||||
o->oSubAction = 1;
|
||||
else
|
||||
|
|
@ -82,6 +88,7 @@ void tuxies_mother_act_1(void) {
|
|||
spawn_default_star(3500.0f, -4300.0f, 4650.0f);
|
||||
#endif
|
||||
o->oAction = 2;
|
||||
network_send_object(o);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
|
@ -96,6 +103,10 @@ void tuxies_mother_act_1(void) {
|
|||
}
|
||||
|
||||
void tuxies_mother_act_0(void) {
|
||||
// only local can interact with mother
|
||||
struct MarioState* marioState = &gMarioStates[0];
|
||||
int distanceToPlayer = dist_between_objects(o, marioState->marioObj);
|
||||
|
||||
s32 sp2C;
|
||||
f32 sp28;
|
||||
struct Object *sp24;
|
||||
|
|
@ -106,22 +117,24 @@ void tuxies_mother_act_0(void) {
|
|||
if (sp28 < 500.0f)
|
||||
sp2C = 1;
|
||||
if (sp24 != NULL && sp28 < 300.0f && sp24->oHeldState != HELD_FREE) {
|
||||
o->oAction = 1;
|
||||
sp24->oSmallPenguinUnk88 = 1;
|
||||
if (sp24->heldByPlayerIndex == 0) {
|
||||
o->oAction = 1;
|
||||
sp24->oSmallPenguinUnk88 = 1;
|
||||
}
|
||||
o->prevObj = sp24;
|
||||
} else {
|
||||
switch (o->oSubAction) {
|
||||
case 0:
|
||||
if (cur_obj_can_mario_activate_textbox_2(&gMarioState[0], 300.0f, 100.0f))
|
||||
if (cur_obj_can_mario_activate_textbox_2(marioState, 300.0f, 100.0f))
|
||||
if (sp2C == 0)
|
||||
o->oSubAction++;
|
||||
break;
|
||||
case 1:
|
||||
if (cur_obj_update_dialog_with_cutscene(&gMarioState[0], 2, 1, CUTSCENE_DIALOG, DIALOG_057))
|
||||
if (cur_obj_update_dialog_with_cutscene(marioState, 2, 1, CUTSCENE_DIALOG, DIALOG_057))
|
||||
o->oSubAction++;
|
||||
break;
|
||||
case 2:
|
||||
if (o->oDistanceToMario > 450.0f)
|
||||
if (distanceToPlayer > 450.0f)
|
||||
o->oSubAction = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -134,6 +147,11 @@ void (*sTuxiesMotherActions[])(void) = { tuxies_mother_act_0, tuxies_mother_act_
|
|||
tuxies_mother_act_2 };
|
||||
|
||||
void bhv_tuxies_mother_loop(void) {
|
||||
if (o->oSyncID == 0) {
|
||||
network_init_object(o, SYNC_DISTANCE_ONLY_EVENTS);
|
||||
network_init_object_field(o, &o->oAction);
|
||||
network_init_object_field(o, &o->oSubAction);
|
||||
}
|
||||
o->activeFlags |= ACTIVE_FLAG_UNK10;
|
||||
cur_obj_update_floor_and_walls();
|
||||
cur_obj_call_action_function(sTuxiesMotherActions);
|
||||
|
|
@ -143,21 +161,25 @@ void bhv_tuxies_mother_loop(void) {
|
|||
}
|
||||
|
||||
void small_penguin_dive_with_mario(void) {
|
||||
if (mario_is_dive_sliding()) {
|
||||
if (mario_is_dive_sliding(&gMarioStates[o->heldByPlayerIndex])) {
|
||||
o->oSmallPenguinUnk100 = o->oAction;
|
||||
o->oAction = 3;
|
||||
}
|
||||
}
|
||||
|
||||
void small_penguin_act_2(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
s32 sp1C = 0;
|
||||
if (o->oTimer == 0)
|
||||
if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f)
|
||||
sp1C = 1;
|
||||
cur_obj_init_animation_with_sound(0);
|
||||
o->oForwardVel = o->oSmallPenguinUnk104 + 3.0f;
|
||||
cur_obj_rotate_yaw_toward(o->oAngleToMario + 0x8000, o->oSmallPenguinUnk110 + 0x600);
|
||||
if (o->oDistanceToMario > o->oSmallPenguinUnk108 + 500.0f)
|
||||
cur_obj_rotate_yaw_toward(angleToPlayer + 0x8000, o->oSmallPenguinUnk110 + 0x600);
|
||||
if (distanceToPlayer > o->oSmallPenguinUnk108 + 500.0f)
|
||||
o->oAction = 0;
|
||||
small_penguin_dive_with_mario();
|
||||
if (sp1C)
|
||||
|
|
@ -165,12 +187,16 @@ void small_penguin_act_2(void) {
|
|||
}
|
||||
|
||||
void small_penguin_act_1(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
cur_obj_init_animation_with_sound(0);
|
||||
o->oForwardVel = o->oSmallPenguinUnk104 + 3.0f;
|
||||
cur_obj_rotate_yaw_toward(o->oAngleToMario, o->oSmallPenguinUnk110 + 0x600);
|
||||
if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f)
|
||||
cur_obj_rotate_yaw_toward(angleToPlayer, o->oSmallPenguinUnk110 + 0x600);
|
||||
if (distanceToPlayer < o->oSmallPenguinUnk108 + 300.0f)
|
||||
o->oAction = 0;
|
||||
if (o->oDistanceToMario > 1100.0f)
|
||||
if (distanceToPlayer > 1100.0f)
|
||||
o->oAction = 0;
|
||||
small_penguin_dive_with_mario();
|
||||
}
|
||||
|
|
@ -181,7 +207,7 @@ void small_penguin_act_3(void) {
|
|||
cur_obj_play_sound_2(SOUND_OBJ_BABY_PENGUIN_DIVE);
|
||||
cur_obj_init_animation_with_sound(1);
|
||||
if (o->oTimer > 25)
|
||||
if (!mario_is_dive_sliding())
|
||||
if (!mario_is_dive_sliding(&gMarioStates[o->heldByPlayerIndex]))
|
||||
o->oAction = 4;
|
||||
}
|
||||
}
|
||||
|
|
@ -196,6 +222,10 @@ void small_penguin_act_4(void) {
|
|||
}
|
||||
|
||||
void small_penguin_act_0(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
s32 sp1C;
|
||||
|
||||
sp1C = 0;
|
||||
|
|
@ -208,9 +238,9 @@ void small_penguin_act_0(void) {
|
|||
if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f)
|
||||
sp1C = 1;
|
||||
}
|
||||
if (o->oDistanceToMario < 1000.0f && o->oSmallPenguinUnk108 + 600.0f < o->oDistanceToMario)
|
||||
if (distanceToPlayer < 1000.0f && o->oSmallPenguinUnk108 + 600.0f < distanceToPlayer)
|
||||
o->oAction = 1;
|
||||
else if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f)
|
||||
else if (distanceToPlayer < o->oSmallPenguinUnk108 + 300.0f)
|
||||
o->oAction = 2;
|
||||
if (sp1C)
|
||||
o->oAction = 5;
|
||||
|
|
@ -219,11 +249,14 @@ void small_penguin_act_0(void) {
|
|||
}
|
||||
|
||||
void small_penguin_act_5(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
|
||||
f32 sp24;
|
||||
s16 sp22;
|
||||
struct Object *sp1C = cur_obj_nearest_object_with_behavior(bhvTuxiesMother);
|
||||
if (sp1C != NULL) {
|
||||
if (o->oDistanceToMario < 1000.0f)
|
||||
if (distanceToPlayer < 1000.0f)
|
||||
o->oForwardVel = 2.0f;
|
||||
else
|
||||
o->oForwardVel = 0.0f;
|
||||
|
|
@ -255,6 +288,9 @@ void small_penguin_free_actions(void) {
|
|||
}
|
||||
|
||||
void bhv_small_penguin_loop(void) {
|
||||
if (o->oSyncID == 0) {
|
||||
network_init_object(o, 4000.0f);
|
||||
}
|
||||
switch (o->oHeldState) {
|
||||
case HELD_FREE:
|
||||
small_penguin_free_actions();
|
||||
|
|
|
|||
|
|
@ -1070,8 +1070,8 @@ s32 mario_is_in_air_action(void) {
|
|||
}
|
||||
}
|
||||
|
||||
s32 mario_is_dive_sliding(void) {
|
||||
if (gMarioStates[0].action == ACT_DIVE_SLIDE) {
|
||||
s32 mario_is_dive_sliding(struct MarioState* m) {
|
||||
if (m->action == ACT_DIVE_SLIDE) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
|
|
@ -1511,6 +1511,15 @@ s32 obj_has_behavior(struct Object *obj, const BehaviorScript *behavior) {
|
|||
}
|
||||
}
|
||||
|
||||
f32 cur_obj_lateral_dist_from_obj_to_home(struct Object *obj) {
|
||||
f32 dist;
|
||||
f32 dx = o->oHomeX - obj->oPosX;
|
||||
f32 dz = o->oHomeZ - obj->oPosZ;
|
||||
|
||||
dist = sqrtf(dx * dx + dz * dz);
|
||||
return dist;
|
||||
}
|
||||
|
||||
f32 cur_obj_lateral_dist_from_mario_to_home(void) {
|
||||
f32 dist;
|
||||
f32 dx = o->oHomeX - gMarioObject->oPosX;
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ s32 cur_obj_check_anim_frame(s32 frame);
|
|||
s32 cur_obj_check_anim_frame_in_range(s32 startFrame, s32 rangeLength);
|
||||
s32 cur_obj_check_frame_prior_current_frame(s16 *a0);
|
||||
s32 mario_is_in_air_action(void);
|
||||
s32 mario_is_dive_sliding(void);
|
||||
s32 mario_is_dive_sliding(struct MarioState* m);
|
||||
void cur_obj_set_y_vel_and_animation(f32 sp18, s32 sp1C);
|
||||
void cur_obj_unrender_and_reset_state(s32 sp18, s32 sp1C);
|
||||
void cur_obj_get_thrown_or_placed(f32 forwardVel, f32 velY, s32 thrownAction);
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ void network_receive_object(struct Packet* p);
|
|||
void network_send_spawn_objects(struct Object* objects[], u32 models[], u8 objectCount);
|
||||
void network_receive_spawn_objects(struct Packet* p);
|
||||
|
||||
void network_send_spawn_star(struct Object* o, u8 starType, f32 x, f32 y, f32 z);
|
||||
void network_send_spawn_star(struct Object* o, u8 starType, f32 x, f32 y, f32 z, u32 behParams);
|
||||
void network_receive_spawn_star(struct Packet* p);
|
||||
|
||||
void network_send_level_warp(void);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,16 @@
|
|||
#include "../network.h"
|
||||
#include "object_fields.h"
|
||||
|
||||
void network_send_spawn_star(struct Object* o, u8 starType, f32 x, f32 y, f32 z) {
|
||||
extern struct Object* gCurrentObject;
|
||||
|
||||
void network_send_spawn_star(struct Object* o, u8 starType, f32 x, f32 y, f32 z, u32 behParams) {
|
||||
struct Packet p;
|
||||
packet_init(&p, PACKET_SPAWN_STAR, true);
|
||||
packet_write(&p, &starType, sizeof(u8));
|
||||
packet_write(&p, &x, sizeof(f32));
|
||||
packet_write(&p, &y, sizeof(f32));
|
||||
packet_write(&p, &z, sizeof(f32));
|
||||
packet_write(&p, &behParams, sizeof(u32));
|
||||
|
||||
packet_write(&p, &o->oPosX, sizeof(u32) * 3);
|
||||
packet_write(&p, &o->oHomeX, sizeof(u32) * 3);
|
||||
|
|
@ -19,12 +22,16 @@ void network_send_spawn_star(struct Object* o, u8 starType, f32 x, f32 y, f32 z)
|
|||
void network_receive_spawn_star(struct Packet* p) {
|
||||
u8 starType;
|
||||
f32 x, y, z;
|
||||
u32 behParams;
|
||||
|
||||
packet_read(p, &starType, sizeof(u8));
|
||||
packet_read(p, &x, sizeof(f32));
|
||||
packet_read(p, &y, sizeof(f32));
|
||||
packet_read(p, &z, sizeof(f32));
|
||||
packet_read(p, &behParams, sizeof(u32));
|
||||
|
||||
u32 oldBehParams = gCurrentObject->oBehParams;
|
||||
gCurrentObject->oBehParams = behParams;
|
||||
struct Object* o = NULL;
|
||||
switch (starType) {
|
||||
case 0: o = spawn_default_star(x, y, z); break;
|
||||
|
|
@ -32,6 +39,7 @@ void network_receive_spawn_star(struct Packet* p) {
|
|||
case 2: o = spawn_no_exit_star(x, y, z); break;
|
||||
default: printf("UNKNOWN SPAWN STAR %d\n", starType);
|
||||
}
|
||||
gCurrentObject->oBehParams = oldBehParams;
|
||||
|
||||
if (o != NULL) {
|
||||
packet_read(p, &o->oPosX, sizeof(u32) * 3);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue