tower_platform.inc.c (3865B)
1 // tower_platform.inc.c 2 3 void bhv_wf_solid_tower_platform_loop(void) { 4 if (o->parentObj->oAction == 3) { 5 obj_mark_for_deletion(o); 6 } 7 } 8 9 void bhv_wf_elevator_tower_platform_loop(void) { 10 switch (o->oAction) { 11 case 0: 12 if (gMarioObject->platform == o) { 13 o->oAction++; 14 } 15 break; 16 17 case 1: 18 cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); 19 if (o->oTimer > 140) { 20 o->oAction++; 21 } else { 22 o->oPosY += 5.0f; 23 } 24 break; 25 26 case 2: 27 if (o->oTimer > 60) { 28 o->oAction++; 29 } 30 break; 31 32 case 3: 33 cur_obj_play_sound_1(SOUND_ENV_ELEVATOR1); 34 if (o->oTimer > 140) { 35 o->oAction = 0; 36 } else { 37 o->oPosY -= 5.0f; 38 } 39 break; 40 } 41 42 if (o->parentObj->oAction == 3) { 43 obj_mark_for_deletion(o); 44 } 45 } 46 47 void bhv_wf_sliding_tower_platform_loop(void) { 48 s32 sp24 = o->oPlatformUnk110 / o->oPlatformUnk10C; 49 50 switch (o->oAction) { 51 case 0: 52 if (o->oTimer > sp24) { 53 o->oAction++; 54 } 55 o->oForwardVel = -o->oPlatformUnk10C; 56 break; 57 58 case 1: 59 if (o->oTimer > sp24) { 60 o->oAction = 0; 61 } 62 o->oForwardVel = o->oPlatformUnk10C; 63 break; 64 } 65 66 cur_obj_compute_vel_xz(); 67 68 o->oPosX += o->oVelX; 69 o->oPosZ += o->oVelZ; 70 71 if (o->parentObj->oAction == 3) { 72 obj_mark_for_deletion(o); 73 } 74 } 75 76 void spawn_and_init_wf_platforms(s16 a, const BehaviorScript *bhv) { 77 s16 yaw; 78 struct Object *platform = spawn_object(o, a, bhv); 79 80 yaw = o->oPlatformSpawnerUnkF4 * o->oPlatformSpawnerUnkFC + o->oPlatformSpawnerUnkF8; 81 82 platform->oMoveAngleYaw = yaw; 83 platform->oPosX += o->oPlatformSpawnerUnk100 * sins(yaw); 84 platform->oPosY += 100 * o->oPlatformSpawnerUnkF4; 85 platform->oPosZ += o->oPlatformSpawnerUnk100 * coss(yaw); 86 platform->oPlatformUnk110 = o->oPlatformSpawnerUnk104; 87 platform->oPlatformUnk10C = o->oPlatformSpawnerUnk108; 88 89 o->oPlatformSpawnerUnkF4++; 90 } 91 92 void spawn_wf_platform_group(void) { 93 UNUSED s32 unused = 8; 94 95 o->oPlatformSpawnerUnkF4 = 0; 96 o->oPlatformSpawnerUnkF8 = 0; 97 o->oPlatformSpawnerUnkFC = 0x2000; 98 o->oPlatformSpawnerUnk100 = 704.0f; 99 o->oPlatformSpawnerUnk104 = 380.0f; 100 o->oPlatformSpawnerUnk108 = 3.0f; 101 102 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSolidTowerPlatform); 103 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSlidingTowerPlatform); 104 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSolidTowerPlatform); 105 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSlidingTowerPlatform); 106 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSolidTowerPlatform); 107 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSlidingTowerPlatform); 108 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM, bhvWFSolidTowerPlatform); 109 spawn_and_init_wf_platforms(MODEL_WF_TOWER_SQUARE_PLATORM_ELEVATOR, bhvWFElevatorTowerPlatform); 110 } 111 112 void bhv_tower_platform_group_loop(void) { 113 f32 marioY = gMarioObject->oPosY; 114 115 o->oDistanceToMario = dist_between_objects(o, gMarioObject); 116 117 switch (o->oAction) { 118 case 0: 119 if (marioY > o->oHomeY - 1000.0f) { 120 o->oAction++; 121 } 122 break; 123 124 case 1: 125 spawn_wf_platform_group(); 126 o->oAction++; 127 break; 128 129 case 2: 130 if (marioY < o->oHomeY - 1000.0f) { 131 o->oAction++; 132 } 133 break; 134 135 case 3: 136 o->oAction = 0; 137 break; 138 } 139 }