Fixed home radius on many enemies, fixed draw distance bug
This commit is contained in:
parent
84b9fc8691
commit
839575efe1
|
@ -18,10 +18,10 @@ fi
|
|||
#exit
|
||||
|
||||
# no debug, direct
|
||||
$FILE --server 27015 --configfile sm64config_server.txt &
|
||||
sleep 7
|
||||
$FILE --client 127.0.0.1 27015 --configfile sm64config_client.txt &
|
||||
exit
|
||||
#$FILE --server 27015 --configfile sm64config_server.txt &
|
||||
#sleep 7
|
||||
#$FILE --client 127.0.0.1 27015 --configfile sm64config_client.txt &
|
||||
#exit
|
||||
|
||||
# debug on server
|
||||
#$FILE --client 127.0.0.1 27015 --configfile sm64config_client.txt &
|
||||
|
|
|
@ -1078,7 +1078,11 @@ cur_obj_update_begin:;
|
|||
if (distanceFromMario > gCurrentObject->oDrawingDistance * draw_distance_scalar()) {
|
||||
// Out of render distance, hide the object.
|
||||
gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE;
|
||||
gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY;
|
||||
|
||||
// the following flag would deactivate behavior code
|
||||
//gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY;
|
||||
gCurrentObject->activeFlags &= ~ACTIVE_FLAG_FAR_AWAY;
|
||||
|
||||
} else if (gCurrentObject->oHeldState == HELD_FREE) {
|
||||
// In render distance (and not being held), show the object.
|
||||
gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE;
|
||||
|
|
|
@ -20,7 +20,9 @@ void bubba_act_0(void) {
|
|||
f32 sp24;
|
||||
|
||||
sp24 = cur_obj_lateral_dist_to_home();
|
||||
treat_far_home_as_mario(2000.0f);
|
||||
|
||||
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
o->oAnimState = 0;
|
||||
|
||||
o->oBubbaUnk1AC = obj_get_pitch_to_home(sp24);
|
||||
|
@ -59,7 +61,8 @@ void bubba_act_1(void) {
|
|||
s16 val06;
|
||||
s16 val04;
|
||||
|
||||
treat_far_home_as_mario(2500.0f);
|
||||
treat_far_home_as_mario(2500.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
if (distanceToPlayer > 2500.0f) {
|
||||
o->oAction = 0;
|
||||
} else if (o->oBubbaUnk100 != 0) {
|
||||
|
|
|
@ -44,12 +44,15 @@ static void enemy_lakitu_update_vel_y(f32 offsetY) {
|
|||
}
|
||||
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
if (player != NULL) {
|
||||
if (o->oPosY < player->oPosY + offsetY + margin) {
|
||||
obj_y_vel_approach(4.0f, 0.4f);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
obj_y_vel_approach(-4.0f, 0.4f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Control speed based on distance to mario, turn toward mario, and change move
|
||||
|
@ -102,6 +105,8 @@ static void enemy_lakitu_sub_act_no_spiny(void) {
|
|||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
cur_obj_init_animation_with_sound(1);
|
||||
|
||||
if (o->oEnemyLakituSpinyCooldown != 0) {
|
||||
|
@ -139,6 +144,8 @@ static void enemy_lakitu_sub_act_hold_spiny(void) {
|
|||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
cur_obj_init_anim_extend(3);
|
||||
|
||||
if (o->oEnemyLakituSpinyCooldown != 0) {
|
||||
|
@ -172,6 +179,7 @@ static void enemy_lakitu_sub_act_throw_spiny(void) {
|
|||
* Main update function.
|
||||
*/
|
||||
static void enemy_lakitu_act_main(void) {
|
||||
cur_obj_unhide();
|
||||
cur_obj_play_sound_1(SOUND_AIR_LAKITU_FLY);
|
||||
|
||||
cur_obj_update_floor_and_walls();
|
||||
|
@ -214,9 +222,10 @@ void bhv_enemy_lakitu_update(void) {
|
|||
network_init_object_field(o, &o->oEnemyLakituBlinkTimer);
|
||||
network_init_object_field(o, &o->oEnemyLakituSpinyCooldown);
|
||||
network_init_object_field(o, &o->oEnemyLakituFaceForwardCountdown);
|
||||
network_init_object_field(o, &o->oEnemyLakituNumSpinies);
|
||||
}
|
||||
|
||||
treat_far_home_as_mario(2000.0f);
|
||||
treat_far_home_as_mario(2000.0f, NULL, NULL);
|
||||
|
||||
switch (o->oAction) {
|
||||
case ENEMY_LAKITU_ACT_UNINITIALIZED:
|
||||
|
|
|
@ -32,6 +32,8 @@ static void fly_guy_act_idle(void) {
|
|||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
o->oForwardVel = 0.0f;
|
||||
if (approach_f32_ptr(&o->header.gfx.scale[0], 1.5f, 0.02f)) {
|
||||
// If we are >2000 units from home or Mario is <2000 units from us
|
||||
|
@ -65,6 +67,8 @@ static void fly_guy_act_approach_mario(void) {
|
|||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
treat_far_home_as_mario(2000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
// If we are >2000 units from home or Mario is <2000 units from us
|
||||
if (distanceToPlayer >= 25000.0f || distanceToPlayer < 2000.0f) {
|
||||
obj_forward_vel_approach(10.0f, 0.5f);
|
||||
|
@ -146,6 +150,8 @@ static void fly_guy_act_shoot_fire(void) {
|
|||
struct Object* player = marioState->marioObj;
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
|
||||
treat_far_home_as_mario(2000.0f, NULL, &angleToPlayer);
|
||||
|
||||
s32 scaleStatus;
|
||||
|
||||
o->oForwardVel = 0.0f;
|
||||
|
@ -210,7 +216,7 @@ void bhv_fly_guy_update(void) {
|
|||
o->oDeathSound = SOUND_OBJ_KOOPA_FLYGUY_DEATH;
|
||||
|
||||
cur_obj_scale(o->header.gfx.scale[0]);
|
||||
treat_far_home_as_mario(2000.0f);
|
||||
treat_far_home_as_mario(2000.0f, NULL, NULL);
|
||||
cur_obj_update_floor_and_walls();
|
||||
|
||||
if (o->oMoveFlags & OBJ_MOVE_HIT_WALL) {
|
||||
|
|
|
@ -152,7 +152,7 @@ void mark_goomba_as_dead(void) {
|
|||
* chase him.
|
||||
*/
|
||||
static void goomba_act_walk(void) {
|
||||
treat_far_home_as_mario(1000.0f);
|
||||
treat_far_home_as_mario(1000.0f, NULL, NULL);
|
||||
|
||||
obj_forward_vel_approach(o->oGoombaRelativeSpeed * o->oGoombaScale, 0.4f);
|
||||
|
||||
|
@ -174,6 +174,8 @@ static void goomba_act_walk(void) {
|
|||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
treat_far_home_as_mario(1000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
// If far from home, walk toward home.
|
||||
if (distanceToPlayer >= 25000.0f) {
|
||||
o->oGoombaTargetYaw = angleToPlayer;
|
||||
|
|
|
@ -174,9 +174,8 @@ static void koopa_play_footstep_sound(s8 animFrame1, s8 animFrame2) {
|
|||
* running away.
|
||||
*/
|
||||
static s32 koopa_check_run_from_mario(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
if (distanceToPlayer < 300.0f && abs_angle_diff(angleToPlayer, o->oMoveAngleYaw) < 0x3000) {
|
||||
o->oAction = KOOPA_SHELLED_ACT_RUN_FROM_MARIO;
|
||||
return TRUE;
|
||||
|
@ -241,9 +240,8 @@ static void koopa_shelled_act_walk(void) {
|
|||
if (o->oKoopaTurningAwayFromWall) {
|
||||
o->oKoopaTurningAwayFromWall = obj_resolve_collisions_and_turn(o->oKoopaTargetYaw, 0x200);
|
||||
} else {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
// If far from home, then begin turning toward home
|
||||
if (distanceToPlayer >= 25000.0f) {
|
||||
o->oKoopaTargetYaw = angleToPlayer;
|
||||
|
@ -276,9 +274,8 @@ static void koopa_shelled_act_run_from_mario(void) {
|
|||
cur_obj_init_animation_with_sound(1);
|
||||
koopa_play_footstep_sound(0, 11);
|
||||
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
|
||||
// If far from home, run toward it
|
||||
if (distanceToPlayer >= 25000.0f) {
|
||||
|
@ -420,9 +417,8 @@ static void koopa_shelled_update(void) {
|
|||
* action.
|
||||
*/
|
||||
static void koopa_unshelled_act_run(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
|
||||
f32 distToShell = 99999.0f;
|
||||
struct Object *shell;
|
||||
|
@ -493,8 +489,7 @@ static void koopa_unshelled_act_dive(void) {
|
|||
if (o->oTimer > 10) {
|
||||
shell = cur_obj_find_nearest_object_with_behavior(bhvKoopaShell, &distToShell);
|
||||
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
|
||||
// If we got the shell and mario didn't, put on the shell
|
||||
//! The shell comes after koopa in processing order, and the shell is
|
||||
|
@ -926,7 +921,10 @@ void bhv_koopa_update(void) {
|
|||
|
||||
o->oKoopaDistanceToMario = distanceToPlayer;
|
||||
o->oKoopaAngleToMario = angleToPlayer;
|
||||
treat_far_home_as_mario(1000.0f);
|
||||
|
||||
treat_far_home_as_mario(1000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
o->oDistanceToMario = distanceToPlayer;
|
||||
o->oAngleToMario = angleToPlayer;
|
||||
|
||||
switch (o->oKoopaMovementType) {
|
||||
case KOOPA_BP_UNSHELLED:
|
||||
|
|
|
@ -220,7 +220,7 @@ static void pokey_act_wander(void) {
|
|||
if (o->oPokeyNumAliveBodyParts == 0) {
|
||||
obj_mark_for_deletion(o);
|
||||
} else {
|
||||
treat_far_home_as_mario(1000.0f);
|
||||
treat_far_home_as_mario(1000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
cur_obj_update_floor_and_walls();
|
||||
|
||||
if (o->oPokeyHeadWasKilled) {
|
||||
|
|
|
@ -61,9 +61,8 @@ static void skeeter_act_idle(void) {
|
|||
}
|
||||
|
||||
static void skeeter_act_lunge(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
|
||||
if (!(o->oMoveFlags & OBJ_MOVE_AT_WATER_SURFACE)) {
|
||||
o->oAction = SKEETER_ACT_IDLE;
|
||||
|
@ -94,9 +93,9 @@ static void skeeter_act_lunge(void) {
|
|||
}
|
||||
|
||||
static void skeeter_act_walk(void) {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
|
||||
f32 sp24;
|
||||
|
||||
if (!(o->oMoveFlags & OBJ_MOVE_MASK_ON_GROUND)) {
|
||||
|
@ -155,7 +154,13 @@ void bhv_skeeter_update(void) {
|
|||
}
|
||||
|
||||
o->oDeathSound = SOUND_OBJ_SNUFIT_SKEETER_DEATH;
|
||||
treat_far_home_as_mario(1000.0f);
|
||||
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
treat_far_home_as_mario(1000.0f, &distanceToPlayer, &angleToPlayer);
|
||||
o->oDistanceToMario = distanceToPlayer;
|
||||
o->oAngleToMario = angleToPlayer;
|
||||
|
||||
cur_obj_update_floor_and_walls();
|
||||
|
||||
|
|
|
@ -220,8 +220,8 @@ void wiggler_init_segments(void) {
|
|||
static void wiggler_act_walk(void) {
|
||||
struct MarioState* marioState = nearest_mario_state_to_object(o);
|
||||
struct Object* player = marioState->marioObj;
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
int distanceToPlayer = o->oDistanceToMario;
|
||||
int angleToPlayer = o->oAngleToMario;
|
||||
|
||||
s16 yawTurnSpeed;
|
||||
|
||||
|
@ -465,13 +465,19 @@ void bhv_wiggler_update(void) {
|
|||
network_init_object_field(o, &o->oFaceAngleYaw);
|
||||
}
|
||||
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
int distanceToPlayer = dist_between_objects(o, player);
|
||||
int angleToPlayer = obj_angle_to_object(o, player);
|
||||
o->oDistanceToMario = distanceToPlayer;
|
||||
o->oAngleToMario = angleToPlayer;
|
||||
|
||||
if (o->oAction == WIGGLER_ACT_UNINITIALIZED) {
|
||||
wiggler_init_segments();
|
||||
} else {
|
||||
if (o->oAction == WIGGLER_ACT_FALL_THROUGH_FLOOR) {
|
||||
wiggler_act_fall_through_floor();
|
||||
} else {
|
||||
treat_far_home_as_mario(1200.0f);
|
||||
treat_far_home_as_mario(1200.0f, &distanceToPlayer, &angleToPlayer);
|
||||
|
||||
// Walking animation and sound
|
||||
cur_obj_init_animation_with_accel_and_sound(0, o->oWigglerWalkAnimSpeed);
|
||||
|
|
|
@ -880,7 +880,7 @@ static s32 obj_move_for_one_second(s32 endAction) {
|
|||
* attack Mario (e.g. fly guy shooting fire or lunging), especially when combined
|
||||
* with partial updates.
|
||||
*/
|
||||
static void treat_far_home_as_mario(f32 threshold) {
|
||||
static void treat_far_home_as_mario(f32 threshold, int* distanceToPlayer, int* angleToPlayer) {
|
||||
f32 dx = o->oHomeX - o->oPosX;
|
||||
f32 dy = o->oHomeY - o->oPosY;
|
||||
f32 dz = o->oHomeZ - o->oPosZ;
|
||||
|
@ -889,6 +889,12 @@ static void treat_far_home_as_mario(f32 threshold) {
|
|||
if (distance > threshold) {
|
||||
o->oAngleToMario = atan2s(dz, dx);
|
||||
o->oDistanceToMario = 25000.0f;
|
||||
if (distanceToPlayer != NULL) {
|
||||
*distanceToPlayer = o->oDistanceToMario;
|
||||
}
|
||||
if (angleToPlayer != NULL) {
|
||||
*angleToPlayer = o->oAngleToMario;
|
||||
}
|
||||
} else {
|
||||
struct Object* player = nearest_player_to_object(o);
|
||||
dx = o->oHomeX - player->oPosX;
|
||||
|
@ -898,6 +904,9 @@ static void treat_far_home_as_mario(f32 threshold) {
|
|||
|
||||
if (distance > threshold) {
|
||||
o->oDistanceToMario = 20000.0f;
|
||||
if (distanceToPlayer != NULL) {
|
||||
*distanceToPlayer = o->oDistanceToMario;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
#ifdef DEBUG
|
||||
|
||||
static u8 warpToLevel = LEVEL_BOB;
|
||||
static u8 warpToArea = 29;
|
||||
static u8 warpToLevel = LEVEL_RR;
|
||||
static u8 warpToArea = 27;
|
||||
// warpToArea: 26 = basement
|
||||
// warpToArea: 27 = upstairs
|
||||
// warpToArea: 29 = courtyard
|
||||
|
|
Loading…
Reference in New Issue