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

131 lines
3.8 KiB
C
Raw Normal View History

2019-08-25 04:46:40 +00:00
// cannon.c.inc
void bhv_cannon_base_unused_loop(void) {
o->oPosY += o->oVelY;
}
void ActionOpenedCannon0(void) {
if (o->oTimer == 0) {
o->oInteractStatus = 0;
o->oPosX = o->oHomeX;
o->oPosY = o->oHomeY;
o->oPosZ = o->oHomeZ;
o->oMoveAnglePitch = 0;
o->oMoveAngleYaw = (s16)(o->oBehParams2ndByte << 8);
2019-10-05 19:08:05 +00:00
o->oCannonUnkF4 = 0;
o->oCannonUnk10C = 0;
2019-08-25 04:46:40 +00:00
obj_enable_rendering();
obj_become_tangible();
}
if (o->oDistanceToMario < 500.0f) {
obj_become_tangible();
obj_enable_rendering();
if (o->oInteractStatus & INT_STATUS_INTERACTED
&& (!(o->oInteractStatus
& INT_STATUS_TOUCHED_BOB_OMB))) // bob-omb explodes when it gets into a cannon
{
o->oAction = 4;
2019-10-05 19:08:05 +00:00
o->oCannonUnk10C = 1;
o->oCannonUnkF8 = 1;
2019-08-25 04:46:40 +00:00
} else
o->oInteractStatus = 0;
} else {
obj_become_intangible();
obj_disable_rendering();
2019-10-05 19:08:05 +00:00
o->oCannonUnk10C = 0;
2019-08-25 04:46:40 +00:00
}
}
void ActionOpenedCannon4(void) {
if (o->oTimer == 0)
2019-10-05 19:08:05 +00:00
PlaySound2(SOUND_OBJ_CANNON1);
2019-08-25 04:46:40 +00:00
o->oPosY += 5.0f;
o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 2;
o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 2;
if (o->oTimer > 67) {
o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 4;
o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 4;
o->oAction = 6;
}
}
void ActionOpenedCannon6(void) {
if (o->oTimer == 0)
2019-10-05 19:08:05 +00:00
PlaySound2(SOUND_OBJ_CANNON2);
2019-08-25 04:46:40 +00:00
if (o->oTimer < 4) {
o->oPosX += (f32)((o->oTimer / 2 & 1) - 0.5) * 4.0f;
o->oPosZ += (f32)((o->oTimer / 2 & 1) - 0.5) * 4.0f;
} else {
if (o->oTimer < 6) {
} else {
if (o->oTimer < 22) {
o->oMoveAngleYaw =
2019-10-05 19:08:05 +00:00
sins(o->oCannonUnkF4) * 0x4000 + ((s16)(o->oBehParams2ndByte << 8));
o->oCannonUnkF4 += 0x400;
2019-08-25 04:46:40 +00:00
} else if (o->oTimer < 26) {
} else {
2019-10-05 19:08:05 +00:00
o->oCannonUnkF4 = 0;
2019-08-25 04:46:40 +00:00
o->oAction = 5;
}
}
}
}
void ActionOpenedCannon5(void) {
if (o->oTimer == 0)
2019-10-05 19:08:05 +00:00
PlaySound2(SOUND_OBJ_CANNON3);
2019-08-25 04:46:40 +00:00
if (o->oTimer < 4) {
} else {
if (o->oTimer < 20) {
2019-10-05 19:08:05 +00:00
o->oCannonUnkF4 += 0x400;
o->oMoveAnglePitch = sins(o->oCannonUnkF4) * 0x2000;
2019-08-25 04:46:40 +00:00
} else if (o->oTimer < 25) {
} else
o->oAction = 1;
}
}
void ActionOpenedCannon1(void) {
UNUSED s32 unused;
obj_become_intangible();
obj_disable_rendering();
2019-10-05 19:08:05 +00:00
o->oCannonUnk10C = 0;
2019-08-25 04:46:40 +00:00
gMarioShotFromCannon = 1;
}
void ActionOpenedCannon2(void) {
o->oAction = 3;
}
void ActionOpenedCannon3(void) {
UNUSED s32 unused;
if (o->oTimer > 3)
o->oAction = 0;
}
void (*sOpenedCannonActions[])(void) = { ActionOpenedCannon0, ActionOpenedCannon1, ActionOpenedCannon2,
ActionOpenedCannon3, ActionOpenedCannon4, ActionOpenedCannon5,
ActionOpenedCannon6 };
u8 unused0EA1FC[] = { 2, 0, 0, 0, 0, 0, 0, 0, 63, 128, 0, 0, 2, 0, 0, 0, 65, 32, 0, 0,
63, 128, 0, 0, 2, 0, 0, 0, 65, 160, 0, 0, 63, 128, 0, 0, 2, 0, 0, 0,
65, 160, 0, 0, 63, 128, 0, 0, 8, 0, 0, 0, 65, 32, 0, 0, 63, 128, 0, 0 };
void bhv_cannon_base_loop(void) {
obj_call_action_function(sOpenedCannonActions);
2019-10-05 19:08:05 +00:00
if (o->oCannonUnkF8)
o->oCannonUnkF8++;
2019-08-25 04:46:40 +00:00
o->oInteractStatus = 0;
}
void bhv_cannon_barrel_loop(void) {
struct Object *parent = o->parentObj;
if (parent->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) {
obj_enable_rendering();
copy_object_pos(o, o->parentObj);
o->oMoveAngleYaw = o->parentObj->oMoveAngleYaw;
o->oFaceAnglePitch = o->parentObj->oMoveAnglePitch;
} else
obj_disable_rendering();
}