@@ -330,11 +330,7 @@ static inline float ai_guard_threshold(const object* guarded_objp, float thresho
330330 }
331331 }
332332
333- if (guarded_objp != nullptr) {
334- return (MAX_GUARD_DIST + guarded_objp->radius) * threshold;
335- }
336-
337- return threshold * MAX_GUARD_DIST;
333+ return threshold;
338334}
339335
340336/**
@@ -5131,9 +5127,10 @@ int maybe_resume_previous_mode(object *objp, ai_info *aip)
51315127
51325128 // If guarding ship is far away from guardee and enemy is far away from guardee,
51335129 // then stop chasing and resume guarding.
5134- if (dist > ai_guard_threshold(guard_objp, 6.0f)) {
5130+ if (dist > ai_guard_threshold(guard_objp, (MAX_GUARD_DIST + guard_objp->radius) * 6))
5131+ {
51355132 if ((En_objp != NULL) && (En_objp->type == OBJ_SHIP)) {
5136- if (vm_vec_dist_quick(&guard_objp->pos, &En_objp->pos) > ai_guard_threshold(guard_objp, 6.0f )) {
5133+ if (vm_vec_dist_quick(&guard_objp->pos, &En_objp->pos) > ai_guard_threshold(guard_objp, (MAX_GUARD_DIST + guard_objp->radius) * 6 )) {
51375134 Assert(aip->previous_mode == AIM_GUARD);
51385135 aip->mode = aip->previous_mode;
51395136 aip->submode = AIS_GUARD_PATROL;
@@ -10531,7 +10528,7 @@ int ai_guard_find_nearby_bomb(object *guarding_objp, object *guarded_objp)
1053110528
1053210529 dist = vm_vec_dist_quick(&bomb_objp->pos, &guarded_objp->pos);
1053310530
10534- if (dist < ai_guard_threshold(guarded_objp, 3.0f )) {
10531+ if (dist < ai_guard_threshold(guarded_objp, (MAX_GUARD_DIST + guarded_objp->radius) * 3 )) {
1053510532 dist_to_guarding_obj = vm_vec_dist_quick(&bomb_objp->pos, &guarding_objp->pos);
1053610533 if ( dist_to_guarding_obj < closest_dist_to_guarding_obj ) {
1053710534 closest_dist_to_guarding_obj = dist_to_guarding_obj;
@@ -10575,7 +10572,7 @@ void ai_guard_find_nearby_ship(object *guarding_objp, object *guarded_objp)
1057510572 if (Ship_info[eshipp->ship_info_index].class_type >= 0 && (Ship_types[Ship_info[eshipp->ship_info_index].class_type].flags[Ship::Type_Info_Flags::AI_guards_attack]))
1057610573 {
1057710574 dist = vm_vec_dist_quick(&enemy_objp->pos, &guarded_objp->pos);
10578- if (dist < ai_guard_threshold(guarded_objp, 3.0f ))
10575+ if (dist < ai_guard_threshold(guarded_objp, (MAX_GUARD_DIST + guarded_objp->radius) * 3 ))
1057910576 {
1058010577 guard_object_was_hit(guarding_objp, enemy_objp);
1058110578 } else if ((dist < ai_guard_threshold(guarded_objp, 3000.0f)) &&
@@ -10606,7 +10603,7 @@ void ai_guard_find_nearby_asteroid(object *guarding_objp, object *guarded_objp)
1060610603 if ( asteroid_objp->type == OBJ_ASTEROID ) {
1060710604 // Attack asteroid if near guarded ship
1060810605 dist = vm_vec_dist_quick(&asteroid_objp->pos, &guarded_objp->pos);
10609- if (dist < ai_guard_threshold(guarded_objp, 2.0f )) {
10606+ if (dist < ai_guard_threshold(guarded_objp, (MAX_GUARD_DIST + guarded_objp->radius) * 2 )) {
1061010607 dist_to_self = vm_vec_dist_quick(&asteroid_objp->pos, &guarding_objp->pos);
1061110608 if ( OBJ_INDEX(guarded_objp) == asteroid_collide_objnum(asteroid_objp) ) {
1061210609 if( dist_to_self < closest_danger_asteroid_dist ) {
0 commit comments