| 3887 | } |
| 3888 | |
| 3889 | void AICheckTargetVis(object *obj) { |
| 3890 | ai_frame *ai_info = obj->ai_info; |
| 3891 | object *target = ObjGet(ai_info->target_handle); |
| 3892 | |
| 3893 | #ifdef _DEBUG |
| 3894 | if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { |
| 3895 | mprintf(0, "AI Note: Vis 1\n"); |
| 3896 | } |
| 3897 | #endif |
| 3898 | |
| 3899 | #ifdef _DEBUG |
| 3900 | if (!Game_do_ai_vis) { |
| 3901 | ai_info->status_reg &= ~AISR_SEES_GOAL; |
| 3902 | ai_info->last_see_target_pos = obj->pos; |
| 3903 | return; |
| 3904 | } |
| 3905 | #endif |
| 3906 | |
| 3907 | if (target == NULL) { |
| 3908 | ai_info->status_reg &= ~AISR_SEES_GOAL; |
| 3909 | ai_info->last_see_target_pos = obj->pos; |
| 3910 | return; |
| 3911 | } |
| 3912 | |
| 3913 | #ifdef _DEBUG |
| 3914 | if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { |
| 3915 | mprintf(0, "AI Note: Vis 2\n"); |
| 3916 | } |
| 3917 | #endif |
| 3918 | |
| 3919 | if (!BOA_IsVisible(obj->roomnum, target->roomnum)) { |
| 3920 | ai_info->status_reg &= ~AISR_SEES_GOAL; |
| 3921 | return; |
| 3922 | } |
| 3923 | |
| 3924 | #ifdef _DEBUG |
| 3925 | if (AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) { |
| 3926 | mprintf(0, "AI Note: Vis 3\n"); |
| 3927 | } |
| 3928 | #endif |
| 3929 | |
| 3930 | vector pos; |
| 3931 | AIDetermineAimPoint(obj, target, &pos); |
| 3932 | ai_info->vec_to_target_actual = pos - obj->pos; |
| 3933 | ai_info->dist_to_target_actual = vm_NormalizeVector(&ai_info->vec_to_target_actual); |
| 3934 | ai_info->dist_to_target_actual -= (obj->size + target->size); |
| 3935 | if (ai_info->dist_to_target_actual < 0.0f) |
| 3936 | ai_info->dist_to_target_actual = 0.0f; |
| 3937 | |
| 3938 | vector fov_vec; |
| 3939 | AIDetermineFovVec(obj, &fov_vec); |
| 3940 | |
| 3941 | if (ai_info->vec_to_target_actual * fov_vec < ai_info->fov) { |
| 3942 | ai_info->status_reg &= ~AISR_SEES_GOAL; |
| 3943 | return; |
| 3944 | } |
| 3945 | |
| 3946 | #ifdef _DEBUG |
no test coverage detected