Make enemy lakitu and wiggler respect their home radius again

This commit is contained in:
MysterD 2023-11-24 15:41:43 -08:00 committed by Agent X
parent 04a26fce03
commit e8d1eb650e
2 changed files with 8 additions and 7 deletions

View file

@ -25,7 +25,7 @@ static struct ObjectHitbox sEnemyLakituHitbox = {
*/ */
static void enemy_lakitu_act_uninitialized(void) { static void enemy_lakitu_act_uninitialized(void) {
struct Object *player = nearest_player_to_object(o); struct Object *player = nearest_player_to_object(o);
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
if (distanceToPlayer < 2000.0f) { if (distanceToPlayer < 2000.0f) {
spawn_object_relative_with_scale(CLOUD_BP_LAKITU_CLOUD, 0, 0, 0, 2.0f, o, MODEL_MIST, bhvCloud); spawn_object_relative_with_scale(CLOUD_BP_LAKITU_CLOUD, 0, 0, 0, 2.0f, o, MODEL_MIST, bhvCloud);
@ -66,7 +66,7 @@ static void enemy_lakitu_update_vel_y(f32 offsetY) {
static void enemy_lakitu_update_speed_and_angle(void) { static void enemy_lakitu_update_speed_and_angle(void) {
struct MarioState* marioState = nearest_mario_state_to_object(o); struct MarioState* marioState = nearest_mario_state_to_object(o);
struct Object* player = marioState ? marioState->marioObj : NULL; struct Object* player = marioState ? marioState->marioObj : NULL;
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0; s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
f32 minSpeed = 0; f32 minSpeed = 0;
@ -109,7 +109,7 @@ static void enemy_lakitu_update_speed_and_angle(void) {
static void enemy_lakitu_sub_act_no_spiny(void) { static void enemy_lakitu_sub_act_no_spiny(void) {
struct MarioState* marioState = nearest_mario_state_to_object(o); struct MarioState* marioState = nearest_mario_state_to_object(o);
struct Object* player = marioState ? marioState->marioObj : NULL; struct Object* player = marioState ? marioState->marioObj : NULL;
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0; s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer); treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
@ -155,7 +155,7 @@ static void enemy_lakitu_sub_act_hold_spiny(void) {
} }
struct Object* player = nearest_player_to_object(o); struct Object* player = nearest_player_to_object(o);
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0; s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer); treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
@ -224,7 +224,7 @@ static void enemy_lakitu_act_main(void) {
} }
struct Object* player = nearest_player_to_object(o); struct Object* player = nearest_player_to_object(o);
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
if (distanceToPlayer <= o->oDrawingDistance) { if (distanceToPlayer <= o->oDrawingDistance) {
cur_obj_move_standard(78); cur_obj_move_standard(78);
} }

View file

@ -216,8 +216,9 @@ void wiggler_update_segments(void) {
static void wiggler_act_walk(void) { static void wiggler_act_walk(void) {
struct MarioState *marioState = nearest_mario_state_to_object(o); struct MarioState *marioState = nearest_mario_state_to_object(o);
struct Object* player = marioState ? marioState->marioObj : NULL; struct Object* player = marioState ? marioState->marioObj : NULL;
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0; s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
treat_far_home_as_mario(1200.0f, &distanceToPlayer, &angleToPlayer);
o->oWigglerWalkAnimSpeed = 0.06f * o->oForwardVel; o->oWigglerWalkAnimSpeed = 0.06f * o->oForwardVel;
@ -481,7 +482,7 @@ void bhv_wiggler_update(void) {
} }
struct Object* player = nearest_player_to_object(o); struct Object* player = nearest_player_to_object(o);
s32 distanceToPlayer = player ? dist_between_objects(o, player) : 10000; s32 distanceToPlayer = player ? dist_between_objects(o, player) : 25000;
s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0; s32 angleToPlayer = player ? obj_angle_to_object(o, player) : 0;
o->oDistanceToMario = distanceToPlayer; o->oDistanceToMario = distanceToPlayer;
o->oAngleToMario = angleToPlayer; o->oAngleToMario = angleToPlayer;