sm64

A Super Mario 64 decompilation
Log | Files | Refs | README | LICENSE

grill_door.inc.c (2111B)


      1 // grill_door.inc.c
      2 
      3 struct OpenableGrill {
      4     s16 halfWidth;
      5     s16 modelID;
      6     const Collision *collision;
      7 };
      8 
      9 struct OpenableGrill gOpenableGrills[] = {
     10     { 320, MODEL_BOB_BARS_GRILLS, bob_seg7_collision_gate },
     11     { 410, MODEL_HMC_RED_GRILLS,  hmc_seg7_collision_0702B65C },
     12 };
     13 
     14 void bhv_openable_cage_door_loop(void) {
     15     if (o->oAction == 0) {
     16         if (o->parentObj->oOpenableGrillUnk88 != 0) {
     17             o->oAction++;
     18         }
     19     } else if (o->oAction == 1) {
     20         if (o->oTimer < 64) {
     21             o->oMoveAngleYaw -= o->oBhvParams2ndByte * 0x100;
     22         } else {
     23             o->oAction++;
     24         }
     25     }
     26 }
     27 
     28 void bhv_openable_grill_loop(void) {
     29     struct Object *obj;
     30     s32 grillIdx;
     31 
     32     switch (o->oAction) {
     33         case 0:
     34             grillIdx = o->oBhvParams2ndByte;
     35 
     36             obj = spawn_object_relative(-1, gOpenableGrills[grillIdx].halfWidth, 0, 0, o,
     37                                         gOpenableGrills[grillIdx].modelID, bhvOpenableCageDoor);
     38             obj->oMoveAngleYaw += 0x8000;
     39             obj_set_collision_data(obj, gOpenableGrills[grillIdx].collision);
     40 
     41             obj = spawn_object_relative(1, -gOpenableGrills[grillIdx].halfWidth, 0, 0, o,
     42                                         gOpenableGrills[grillIdx].modelID, bhvOpenableCageDoor);
     43             obj_set_collision_data(obj, gOpenableGrills[grillIdx].collision);
     44 
     45             o->oAction++;
     46             break;
     47 
     48         case 1:
     49             if ((o->oOpenableGrillPurpleSwitch =
     50                  cur_obj_nearest_object_with_behavior(bhvFloorSwitchGrills)) != NULL) {
     51                 o->oAction++;
     52             }
     53             break;
     54 
     55         case 2:
     56             obj = o->oOpenableGrillPurpleSwitch;
     57 
     58             if (obj->oAction == PURPLE_SWITCH_ACT_TICKING) {
     59                 o->oOpenableGrillUnk88 = 2;
     60                 cur_obj_play_sound_2(SOUND_GENERAL_CAGE_OPEN);
     61                 o->oAction++;
     62 
     63                 if (o->oBhvParams2ndByte != OPENABLE_GRILL_BP_BOB) {
     64                     play_puzzle_jingle();
     65                 }
     66             }
     67             break;
     68 
     69         case 3:
     70             break;
     71     }
     72 }