MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / AICheckTargetVis

Function AICheckTargetVis

Descent3/AImain.cpp:3889–4083  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3887}
3888
3889void 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

Callers 1

AIDoFrameFunction · 0.85

Calls 9

ObjGetFunction · 0.85
BOA_IsVisibleFunction · 0.85
AIDetermineAimPointFunction · 0.85
vm_NormalizeVectorFunction · 0.85
AIDetermineFovVecFunction · 0.85
AIDetermineObjVisLevelFunction · 0.85
fvi_FindIntersectionFunction · 0.85
AINotifyFunction · 0.85
ps_randFunction · 0.85

Tested by

no test coverage detected