2019-08-25 04:46:40 +00:00
|
|
|
// scuttlebug.c.inc
|
|
|
|
|
|
|
|
struct ObjectHitbox sScuttlebugHitbox = {
|
|
|
|
/* interactType: */ INTERACT_BOUNCE_TOP,
|
|
|
|
/* downOffset: */ 0,
|
|
|
|
/* damageOrCoinValue: */ 1,
|
|
|
|
/* health: */ 1,
|
|
|
|
/* numLootCoins: */ 3,
|
|
|
|
/* radius: */ 130,
|
|
|
|
/* height: */ 70,
|
|
|
|
/* hurtboxRadius: */ 90,
|
|
|
|
/* hurtboxHeight: */ 60,
|
|
|
|
};
|
|
|
|
|
2020-03-02 03:42:52 +00:00
|
|
|
s32 update_angle_from_move_flags(s32 *a0) {
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oMoveFlags & 0x200) {
|
|
|
|
*a0 = o->oWallAngle;
|
|
|
|
return 1;
|
|
|
|
} else if (o->oMoveFlags & 0x400) {
|
|
|
|
*a0 = o->oMoveAngleYaw + 0x8000;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void bhv_scuttlebug_loop(void) {
|
|
|
|
UNUSED s32 unused;
|
|
|
|
f32 sp18;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_update_floor_and_walls();
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oSubAction != 0
|
2020-03-02 03:42:52 +00:00
|
|
|
&& cur_obj_set_hitbox_and_die_if_attacked(&sScuttlebugHitbox, SOUND_OBJ_DYING_ENEMY1,
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oScuttlebugUnkF4))
|
|
|
|
o->oSubAction = 3;
|
|
|
|
if (o->oSubAction != 1)
|
|
|
|
o->oScuttlebugUnkF8 = 0;
|
|
|
|
switch (o->oSubAction) {
|
|
|
|
case 0:
|
|
|
|
if (o->oMoveFlags & 1)
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_OBJ_GOOMBA_ALERT);
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oMoveFlags & 3) {
|
|
|
|
o->oHomeX = o->oPosX;
|
|
|
|
o->oHomeY = o->oPosY;
|
|
|
|
o->oHomeZ = o->oPosZ;
|
|
|
|
o->oSubAction++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
o->oForwardVel = 5.0f;
|
2020-03-02 03:42:52 +00:00
|
|
|
if (cur_obj_lateral_dist_from_mario_to_home() > 1000.0f)
|
|
|
|
o->oAngleToMario = cur_obj_angle_to_home();
|
2019-08-25 04:46:40 +00:00
|
|
|
else {
|
|
|
|
if (o->oScuttlebugUnkF8 == 0) {
|
|
|
|
o->oScuttlebugUnkFC = 0;
|
2020-03-02 03:42:52 +00:00
|
|
|
o->oAngleToMario = obj_angle_to_object(o, gMarioObject);
|
2019-08-25 04:46:40 +00:00
|
|
|
if (abs_angle_diff(o->oAngleToMario, o->oMoveAngleYaw) < 0x800) {
|
|
|
|
o->oScuttlebugUnkF8 = 1;
|
|
|
|
o->oVelY = 20.0f;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
|
|
|
} else if (o->oScuttlebugUnkF8 == 1) {
|
|
|
|
o->oForwardVel = 15.0f;
|
|
|
|
o->oScuttlebugUnkFC++;
|
|
|
|
if (o->oScuttlebugUnkFC > 50)
|
|
|
|
o->oScuttlebugUnkF8 = 0;
|
|
|
|
}
|
|
|
|
}
|
2020-03-02 03:42:52 +00:00
|
|
|
if (update_angle_from_move_flags(&o->oAngleToMario))
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oSubAction = 2;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x200);
|
2019-08-25 04:46:40 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
o->oForwardVel = 5.0f;
|
|
|
|
if ((s16) o->oMoveAngleYaw == (s16) o->oAngleToMario)
|
|
|
|
o->oSubAction = 1;
|
|
|
|
if (o->oPosY - o->oHomeY < -200.0f)
|
2020-03-02 03:42:52 +00:00
|
|
|
obj_mark_for_deletion(o);
|
|
|
|
cur_obj_rotate_yaw_toward(o->oAngleToMario, 0x400);
|
2019-08-25 04:46:40 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
o->oFlags &= ~8;
|
|
|
|
o->oForwardVel = -10.0f;
|
|
|
|
o->oVelY = 30.0f;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oSubAction++;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
o->oForwardVel = -10.0f;
|
|
|
|
if (o->oMoveFlags & 1) {
|
|
|
|
o->oSubAction++;
|
|
|
|
o->oVelY = 0.0f;
|
|
|
|
o->oScuttlebugUnkFC = 0;
|
|
|
|
o->oFlags |= 8;
|
|
|
|
o->oInteractStatus = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
o->oForwardVel = 2.0f;
|
|
|
|
o->oScuttlebugUnkFC++;
|
|
|
|
if (o->oScuttlebugUnkFC > 30)
|
|
|
|
o->oSubAction = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (o->oForwardVel < 10.0f)
|
|
|
|
sp18 = 1.0f;
|
|
|
|
else
|
|
|
|
sp18 = 3.0f;
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_init_animation_with_accel_and_sound(0, sp18);
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->oMoveFlags & 3)
|
2020-03-02 03:42:52 +00:00
|
|
|
set_obj_anim_with_accel_and_sound(1, 23, SOUND_OBJ2_SCUTTLEBUG_WALK);
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->parentObj != o) {
|
|
|
|
if (obj_is_hidden(o))
|
2020-03-02 03:42:52 +00:00
|
|
|
obj_mark_for_deletion(o);
|
2019-08-25 04:46:40 +00:00
|
|
|
if (o->activeFlags == 0)
|
2019-10-05 19:08:05 +00:00
|
|
|
o->parentObj->oScuttlebugSpawnerUnk88 = 1;
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_move_standard(-50);
|
2019-08-25 04:46:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void bhv_scuttlebug_spawn_loop(void) {
|
|
|
|
struct Object *scuttlebug;
|
|
|
|
if (o->oAction == 0) {
|
|
|
|
if (o->oTimer > 30 && 500.0f < o->oDistanceToMario && o->oDistanceToMario < 1500.0f) {
|
2020-03-02 03:42:52 +00:00
|
|
|
cur_obj_play_sound_2(SOUND_OBJ2_SCUTTLEBUG_ALERT);
|
2019-08-25 04:46:40 +00:00
|
|
|
scuttlebug = spawn_object(o, MODEL_SCUTTLEBUG, bhvScuttlebug);
|
|
|
|
scuttlebug->oScuttlebugUnkF4 = o->oScuttlebugSpawnerUnkF4;
|
|
|
|
scuttlebug->oForwardVel = 30.0f;
|
|
|
|
scuttlebug->oVelY = 80.0f;
|
|
|
|
o->oAction++;
|
|
|
|
o->oScuttlebugUnkF4 = 1;
|
|
|
|
}
|
2019-10-05 19:08:05 +00:00
|
|
|
} else if (o->oScuttlebugSpawnerUnk88 != 0) {
|
|
|
|
o->oScuttlebugSpawnerUnk88 = 0;
|
2019-08-25 04:46:40 +00:00
|
|
|
o->oAction = 0;
|
|
|
|
}
|
|
|
|
}
|