sm64pc/src/game/behaviors/tuxie.inc.c

317 lines
11 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// tuxie.c.inc
void play_penguin_walking_sound(s32 walk) {
s32 sound;
if (o->oSoundStateID == 0) {
if (walk == PENGUIN_WALK_BABY)
2019-10-05 19:08:05 +00:00
sound = SOUND_OBJ_BABY_PENGUIN_WALK;
2019-08-25 04:46:40 +00:00
else // PENGUIN_WALK_BIG
2019-10-05 19:08:05 +00:00
sound = SOUND_OBJ_BIG_PENGUIN_WALK;
2020-03-02 03:42:52 +00:00
set_obj_anim_with_accel_and_sound(1, 11, sound);
2019-08-25 04:46:40 +00:00
}
}
2020-03-02 03:42:52 +00:00
void tuxies_mother_act_2(void) {
2019-08-25 04:46:40 +00:00
f32 sp24;
UNUSED s32 unused;
2020-03-02 03:42:52 +00:00
struct Object *sp1C = cur_obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp24);
2020-02-03 05:51:26 +00:00
2020-03-02 03:42:52 +00:00
if (cur_obj_find_nearby_held_actor(bhvUnused20E0, 1000.0f) != NULL) {
2019-08-25 04:46:40 +00:00
if (o->oSubAction == 0) {
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(0);
2019-08-25 04:46:40 +00:00
o->oForwardVel = 10.0f;
2020-03-02 03:42:52 +00:00
if (800.0f < cur_obj_lateral_dist_from_mario_to_home())
2019-08-25 04:46:40 +00:00
o->oSubAction = 1;
2020-03-02 03:42:52 +00:00
cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400);
2019-08-25 04:46:40 +00:00
} else {
o->oForwardVel = 0.0f;
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(3);
if (cur_obj_lateral_dist_from_mario_to_home() < 700.0f)
2019-08-25 04:46:40 +00:00
o->oSubAction = 0;
}
} else {
o->oForwardVel = 0.0f;
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(3);
2019-08-25 04:46:40 +00:00
}
if (sp1C != NULL && sp24 < 300.0f && sp1C->oHeldState != HELD_FREE) {
o->oAction = 1;
2019-10-05 19:08:05 +00:00
sp1C->oSmallPenguinUnk88 = 1;
2019-08-25 04:46:40 +00:00
o->prevObj = sp1C;
}
}
2020-03-02 03:42:52 +00:00
void tuxies_mother_act_1(void) {
2019-08-25 04:46:40 +00:00
s32 sp2C;
s32 sp28;
2019-10-05 19:08:05 +00:00
s32 dialogID;
2019-08-25 04:46:40 +00:00
switch (o->oSubAction) {
case 0:
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(3);
if (!cur_obj_is_mario_on_platform()) {
2019-08-25 04:46:40 +00:00
sp2C = (o->oBehParams >> 0x10) & 0xFF;
sp28 = (o->prevObj->oBehParams >> 0x10) & 0xFF;
if (sp2C == sp28)
2019-12-02 02:52:53 +00:00
dialogID = DIALOG_058;
2019-08-25 04:46:40 +00:00
else
2019-12-02 02:52:53 +00:00
dialogID = DIALOG_059;
2020-03-02 03:42:52 +00:00
if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, dialogID)) {
2019-12-02 02:52:53 +00:00
if (dialogID == DIALOG_058)
2019-08-25 04:46:40 +00:00
o->oSubAction = 1;
else
o->oSubAction = 2;
2019-09-01 19:50:50 +00:00
o->prevObj->oInteractionSubtype |= INT_SUBTYPE_DROP_IMMEDIATELY;
2019-08-25 04:46:40 +00:00
}
} else
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(0);
2019-08-25 04:46:40 +00:00
break;
case 1:
if (o->prevObj->oHeldState == HELD_FREE) {
2019-10-05 19:08:05 +00:00
//! This line is was almost certainly supposed to be something
// like o->prevObj->oInteractionSubtype &= ~INT_SUBTYPE_DROP_IMMEDIATELY;
// however, this code uses the value of o->oInteractionSubtype
// rather than its offset to rawData. For this object,
// o->oInteractionSubtype is always 0, so the result is this:
// o->prevObj->oUnknownUnk88 &= ~INT_SUBTYPE_DROP_IMMEDIATELY
// which has no effect as o->prevObj->oUnknownUnk88 is always 0
// or 1, which is not affected by the bitwise AND.
o->prevObj->OBJECT_FIELD_S32(o->oInteractionSubtype) &= ~INT_SUBTYPE_DROP_IMMEDIATELY;
2020-03-02 03:42:52 +00:00
obj_set_behavior(o->prevObj, bhvUnused20E0);
2019-08-25 04:46:40 +00:00
#ifndef VERSION_JP
2020-03-02 03:42:52 +00:00
cur_obj_spawn_star_at_y_offset(3167.0f, -4300.0f, 5108.0f, 200.0f);
2019-08-25 04:46:40 +00:00
#else
2020-03-02 03:42:52 +00:00
spawn_default_star(3500.0f, -4300.0f, 4650.0f);
2019-08-25 04:46:40 +00:00
#endif
o->oAction = 2;
}
break;
case 2:
if (o->prevObj->oHeldState == HELD_FREE) {
2019-10-05 19:08:05 +00:00
//! Same bug as above
o->prevObj->OBJECT_FIELD_S32(o->oInteractionSubtype) &= ~INT_SUBTYPE_DROP_IMMEDIATELY;
2020-03-02 03:42:52 +00:00
obj_set_behavior(o->prevObj, bhvPenguinBaby);
2019-08-25 04:46:40 +00:00
o->oAction = 2;
}
break;
}
}
2020-03-02 03:42:52 +00:00
void tuxies_mother_act_0(void) {
2019-08-25 04:46:40 +00:00
s32 sp2C;
f32 sp28;
struct Object *sp24;
sp2C = 0;
2020-03-02 03:42:52 +00:00
sp24 = cur_obj_find_nearest_object_with_behavior(bhvSmallPenguin, &sp28);
cur_obj_scale(4.0f);
cur_obj_init_animation_with_sound(3);
2019-08-25 04:46:40 +00:00
if (sp28 < 500.0f)
sp2C = 1;
if (sp24 != NULL && sp28 < 300.0f && sp24->oHeldState != HELD_FREE) {
o->oAction = 1;
2019-10-05 19:08:05 +00:00
sp24->oSmallPenguinUnk88 = 1;
2019-08-25 04:46:40 +00:00
o->prevObj = sp24;
} else {
switch (o->oSubAction) {
case 0:
2020-03-02 03:42:52 +00:00
if (cur_obj_can_mario_activate_textbox_2(300.0f, 100.0f))
2019-08-25 04:46:40 +00:00
if (sp2C == 0)
o->oSubAction++;
break;
case 1:
2020-03-02 03:42:52 +00:00
if (cur_obj_update_dialog_with_cutscene(2, 1, CUTSCENE_DIALOG, DIALOG_057))
2019-08-25 04:46:40 +00:00
o->oSubAction++;
break;
case 2:
if (o->oDistanceToMario > 450.0f)
o->oSubAction = 0;
break;
}
}
2020-03-02 03:42:52 +00:00
if (cur_obj_check_anim_frame(1))
cur_obj_play_sound_2(SOUND_OBJ_BIG_PENGUIN_YELL);
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void (*sTuxiesMotherActions[])(void) = { tuxies_mother_act_0, tuxies_mother_act_1,
tuxies_mother_act_2 };
2019-08-25 04:46:40 +00:00
void bhv_tuxies_mother_loop(void) {
o->activeFlags |= 0x400;
2020-03-02 03:42:52 +00:00
cur_obj_update_floor_and_walls();
cur_obj_call_action_function(sTuxiesMotherActions);
cur_obj_move_standard(-78);
2019-08-25 04:46:40 +00:00
play_penguin_walking_sound(PENGUIN_WALK_BIG);
o->oInteractStatus = 0;
}
2020-03-02 03:42:52 +00:00
void small_penguin_dive_with_mario(void) {
2019-08-25 04:46:40 +00:00
if (mario_is_dive_sliding()) {
o->oSmallPenguinUnk100 = o->oAction;
o->oAction = 3;
}
}
2020-03-02 03:42:52 +00:00
void small_penguin_act_2(void) {
2019-08-25 04:46:40 +00:00
s32 sp1C = 0;
if (o->oTimer == 0)
2020-03-02 03:42:52 +00:00
if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f)
2019-08-25 04:46:40 +00:00
sp1C = 1;
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(0);
2019-08-25 04:46:40 +00:00
o->oForwardVel = o->oSmallPenguinUnk104 + 3.0f;
2020-03-02 03:42:52 +00:00
cur_obj_rotate_yaw_toward(o->oAngleToMario + 0x8000, o->oSmallPenguinUnk110 + 0x600);
2019-08-25 04:46:40 +00:00
if (o->oDistanceToMario > o->oSmallPenguinUnk108 + 500.0f)
o->oAction = 0;
2020-03-02 03:42:52 +00:00
small_penguin_dive_with_mario();
2019-08-25 04:46:40 +00:00
if (sp1C)
o->oAction = 5;
}
2020-03-02 03:42:52 +00:00
void small_penguin_act_1(void) {
cur_obj_init_animation_with_sound(0);
2019-08-25 04:46:40 +00:00
o->oForwardVel = o->oSmallPenguinUnk104 + 3.0f;
2020-03-02 03:42:52 +00:00
cur_obj_rotate_yaw_toward(o->oAngleToMario, o->oSmallPenguinUnk110 + 0x600);
2019-08-25 04:46:40 +00:00
if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f)
o->oAction = 0;
if (o->oDistanceToMario > 1100.0f)
o->oAction = 0;
2020-03-02 03:42:52 +00:00
small_penguin_dive_with_mario();
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void small_penguin_act_3(void) {
2019-08-25 04:46:40 +00:00
if (o->oTimer > 5) {
if (o->oTimer == 6)
2020-03-02 03:42:52 +00:00
cur_obj_play_sound_2(SOUND_OBJ_BABY_PENGUIN_DIVE);
cur_obj_init_animation_with_sound(1);
2019-08-25 04:46:40 +00:00
if (o->oTimer > 25)
if (!mario_is_dive_sliding())
o->oAction = 4;
}
}
2020-03-02 03:42:52 +00:00
void small_penguin_act_4(void) {
2019-08-25 04:46:40 +00:00
if (o->oTimer > 20) {
o->oForwardVel = 0.0f;
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(2);
2019-08-25 04:46:40 +00:00
if (o->oTimer > 40)
o->oAction = o->oSmallPenguinUnk100;
}
}
2020-03-02 03:42:52 +00:00
void small_penguin_act_0(void) {
2019-08-25 04:46:40 +00:00
s32 sp1C;
sp1C = 0;
2020-03-02 03:42:52 +00:00
cur_obj_init_animation_with_sound(3);
2019-08-25 04:46:40 +00:00
if (o->oTimer == 0) {
2020-04-03 18:57:26 +00:00
o->oSmallPenguinUnk110 = (s32)(random_float() * 0x400);
o->oSmallPenguinUnk108 = random_float() * 100.0f;
o->oSmallPenguinUnk104 = random_float();
2019-08-25 04:46:40 +00:00
o->oForwardVel = 0.0f;
2020-03-02 03:42:52 +00:00
if (cur_obj_dist_to_nearest_object_with_behavior(bhvTuxiesMother) < 1000.0f)
2019-08-25 04:46:40 +00:00
sp1C = 1;
}
if (o->oDistanceToMario < 1000.0f && o->oSmallPenguinUnk108 + 600.0f < o->oDistanceToMario)
o->oAction = 1;
else if (o->oDistanceToMario < o->oSmallPenguinUnk108 + 300.0f)
o->oAction = 2;
if (sp1C)
o->oAction = 5;
2020-03-02 03:42:52 +00:00
if (cur_obj_mario_far_away())
cur_obj_set_pos_to_home();
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
void small_penguin_act_5(void) {
2019-08-25 04:46:40 +00:00
f32 sp24;
s16 sp22;
2020-03-02 03:42:52 +00:00
struct Object *sp1C = cur_obj_nearest_object_with_behavior(bhvTuxiesMother);
2019-08-25 04:46:40 +00:00
if (sp1C != NULL) {
if (o->oDistanceToMario < 1000.0f)
o->oForwardVel = 2.0f;
else
o->oForwardVel = 0.0f;
sp24 = dist_between_objects(o, sp1C);
2020-03-02 03:42:52 +00:00
sp22 = obj_angle_to_object(o, sp1C);
2019-08-25 04:46:40 +00:00
if (sp24 > 200.0f)
2020-03-02 03:42:52 +00:00
cur_obj_rotate_yaw_toward(sp22, 0x400);
2019-08-25 04:46:40 +00:00
else
2020-03-02 03:42:52 +00:00
cur_obj_rotate_yaw_toward(sp22 + 0x8000, 0x400);
cur_obj_init_animation_with_sound(0);
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
small_penguin_dive_with_mario();
2019-08-25 04:46:40 +00:00
}
void (*sSmallPenguinActions[])(void) = {
2020-03-02 03:42:52 +00:00
small_penguin_act_0, small_penguin_act_1, small_penguin_act_2,
small_penguin_act_3, small_penguin_act_4, small_penguin_act_5
2019-08-25 04:46:40 +00:00
};
2020-03-02 03:42:52 +00:00
void small_penguin_free_actions(void) {
2019-10-05 19:08:05 +00:00
if (o->oSmallPenguinUnk88 != 0) {
2019-08-25 04:46:40 +00:00
o->oAction = 5;
2019-10-05 19:08:05 +00:00
o->oSmallPenguinUnk88 = 0;
2019-08-25 04:46:40 +00:00
}
2020-03-02 03:42:52 +00:00
cur_obj_update_floor_and_walls();
cur_obj_call_action_function(sSmallPenguinActions);
cur_obj_move_standard(-78);
2019-08-25 04:46:40 +00:00
play_penguin_walking_sound(PENGUIN_WALK_BABY);
}
void bhv_small_penguin_loop(void) {
switch (o->oHeldState) {
case HELD_FREE:
2020-03-02 03:42:52 +00:00
small_penguin_free_actions();
2019-08-25 04:46:40 +00:00
break;
case HELD_HELD:
2020-03-02 03:42:52 +00:00
cur_obj_unrender_and_reset_state(0, 0);
if (cur_obj_has_behavior(bhvPenguinBaby))
obj_set_behavior(o, bhvSmallPenguin);
obj_copy_pos(o, gMarioObject);
2019-08-25 04:46:40 +00:00
if (gGlobalTimer % 30 == 0)
#ifndef VERSION_JP
2019-10-05 19:08:05 +00:00
play_sound(SOUND_OBJ2_BABY_PENGUIN_YELL, gMarioObject->header.gfx.cameraToObject);
2019-08-25 04:46:40 +00:00
#else
2019-10-05 19:08:05 +00:00
play_sound(SOUND_OBJ2_BABY_PENGUIN_YELL, o->header.gfx.cameraToObject);
2019-08-25 04:46:40 +00:00
#endif
break;
case HELD_THROWN:
2020-03-02 03:42:52 +00:00
cur_obj_get_thrown_or_placed(0, 0, 0);
2019-08-25 04:46:40 +00:00
break;
case HELD_DROPPED:
2020-03-02 03:42:52 +00:00
cur_obj_get_dropped();
2019-08-25 04:46:40 +00:00
break;
}
}
/** Geo switch logic for Tuxie's mother's eyes. Cases 0-4. Interestingly, case
* 4 is unused, and is the eye state seen in Shoshinkai 1995 footage.
*/
2019-12-02 02:52:53 +00:00
Gfx *geo_switch_tuxie_mother_eyes(s32 run, struct GraphNode *node, UNUSED Mat4 *mtx) {
2019-08-25 04:46:40 +00:00
struct Object *obj;
struct GraphNodeSwitchCase *switchCase;
s32 timer;
if (run == TRUE) {
obj = (struct Object *) gCurGraphNodeObject;
switchCase = (struct GraphNodeSwitchCase *) node;
switchCase->selectedCase = 0;
// timer logic for blinking. uses cases 0-2.
timer = gGlobalTimer % 50;
if (timer < 43)
switchCase->selectedCase = 0;
else if (timer < 45)
switchCase->selectedCase = 1;
else if (timer < 47)
switchCase->selectedCase = 2;
else
switchCase->selectedCase = 1;
/** make Tuxie's Mother have angry eyes if Mario takes the correct baby
* after giving it back. The easiest way to check this is to see if she's
* moving, since she only does when she's chasing Mario.
*/
if (segmented_to_virtual(bhvTuxiesMother) == obj->behavior)
if (obj->oForwardVel > 5.0f)
switchCase->selectedCase = 3;
}
2019-12-02 02:52:53 +00:00
return NULL;
2019-08-25 04:46:40 +00:00
}