haunted_chair.inc.c (4517B)
1 // haunted_chair.inc.c 2 3 struct ObjectHitbox sHauntedChairHitbox = { 4 /* interactType: */ INTERACT_MR_BLIZZARD, 5 /* downOffset: */ 0, 6 /* damageOrCoinValue: */ 2, 7 /* health: */ 0, 8 /* numLootCoins: */ 0, 9 /* radius: */ 50, 10 /* height: */ 50, 11 /* hurtboxRadius: */ 50, 12 /* hurtboxHeight: */ 50, 13 }; 14 15 void bhv_haunted_chair_init(void) { 16 struct Object *val04; 17 f32 val00; 18 19 val04 = cur_obj_find_nearest_object_with_behavior(bhvMadPiano, &val00); 20 21 if (val04 != NULL && val00 < 300.0f) { 22 o->parentObj = val04; 23 } else { 24 o->oHauntedChairUnkF4 = 1; 25 } 26 } 27 28 void haunted_chair_act_0(void) { 29 if (o->parentObj != o) { 30 if (o->oHauntedChairUnk104 == 0) { 31 if (lateral_dist_between_objects(o, o->parentObj) < 250.0f) { 32 s16 val0E = obj_angle_to_object(o, o->parentObj) - o->oFaceAngleYaw + 0x2000; 33 34 if (val0E & 0x4000) { 35 o->oHauntedChairUnk100 = &o->oFaceAngleRoll; 36 37 if (val0E > 0) { 38 o->oHauntedChairUnk104 = 0x4000; 39 } else { 40 o->oHauntedChairUnk104 = -0x4000; 41 } 42 } else { 43 o->oHauntedChairUnk100 = &o->oFaceAnglePitch; 44 45 if (val0E < 0) { 46 o->oHauntedChairUnk104 = 0x5000; 47 } else { 48 o->oHauntedChairUnk104 = -0x4000; 49 } 50 } 51 52 if (o->oHauntedChairUnk104 < 0) { 53 o->oHauntedChairUnkF8 = -1500.0f; 54 } else { 55 o->oHauntedChairUnkF8 = 1500.0f; 56 } 57 } 58 } else { 59 oscillate_toward(o->oHauntedChairUnk100, &o->oHauntedChairUnkF8, o->oHauntedChairUnk104, 60 4000.0f, 20.0f, 2.0f); 61 } 62 } else if (o->oHauntedChairUnkF4 != 0) { 63 if (o->oDistanceToMario < 500.0f) { 64 o->oHauntedChairUnkF4--; 65 } 66 67 o->oTimer = 0; 68 } else { 69 if (o->oTimer & 0x8) { 70 f32 val08; 71 72 if (o->oFaceAnglePitch < 0) { 73 cur_obj_play_sound_2(SOUND_GENERAL_HAUNTED_CHAIR_MOVE); 74 val08 = 4.0f; 75 } else { 76 val08 = -4.0f; 77 } 78 79 o->oHomeX -= val08; 80 o->oHomeZ -= val08; 81 82 o->oFaceAnglePitch = o->oFaceAngleRoll = (s32)(50.0f * val08); 83 } else { 84 o->oFaceAnglePitch = o->oFaceAngleRoll = 0; 85 } 86 87 if (o->oTimer > 30) { 88 o->oAction = 1; 89 90 o->oHauntedChairUnkF8 = 0.0f; 91 o->oHauntedChairUnkFC = 200.0f; 92 o->oHauntedChairUnkF4 = 40; 93 } 94 } 95 96 cur_obj_push_mario_away_from_cylinder(80.0f, 120.0f); 97 } 98 99 void haunted_chair_act_1(void) { 100 cur_obj_update_floor_and_walls(); 101 102 if (o->oTimer < 70) { 103 if (o->oTimer < 50) { 104 o->oVelY = 6.0f; 105 } else { 106 o->oVelY = 0.0f; 107 } 108 109 o->oGravity = 0.0f; 110 111 oscillate_toward(&o->oFaceAnglePitch, &o->oHauntedChairUnkF8, -4000, 200.0f, 20.0f, 2.0f); 112 oscillate_toward(&o->oFaceAngleRoll, &o->oHauntedChairUnkFC, 0, 0.0f, 20.0f, 1.0f); 113 } else { 114 if (o->oHauntedChairUnkF4 != 0) { 115 if (--o->oHauntedChairUnkF4 == 0) { 116 cur_obj_play_sound_2(SOUND_GENERAL_HAUNTED_CHAIR); 117 118 o->oMoveAnglePitch = obj_turn_pitch_toward_mario(120.0f, 0); 119 o->oMoveAngleYaw = o->oAngleToMario; 120 121 obj_compute_vel_from_move_pitch(50.0f); 122 } else if (o->oHauntedChairUnkF4 > 20) { 123 if (gGlobalTimer % 4 == 0) { 124 cur_obj_play_sound_2(SOUND_GENERAL_SWISH_AIR_2); 125 } 126 127 o->oFaceAngleYaw += 10000; 128 } 129 } else if (o->oMoveFlags & (OBJ_MOVE_MASK_ON_GROUND | OBJ_MOVE_HIT_WALL)) { 130 obj_die_if_health_non_positive(); 131 } 132 } 133 134 obj_check_attacks(&sHauntedChairHitbox, o->oAction); 135 cur_obj_move_standard(78); 136 } 137 138 void bhv_haunted_chair_loop(void) { 139 if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { 140 switch (o->oAction) { 141 case 0: 142 haunted_chair_act_0(); 143 break; 144 case 1: 145 haunted_chair_act_1(); 146 break; 147 } 148 149 cur_obj_spin_all_dimensions(30.0f, 30.0f); 150 } 151 }