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

Function AISeeTarget

Descent3/AImain.cpp:2848–2888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2846#endif
2847
2848void AISeeTarget(object *obj, bool f_see) {
2849 ai_frame *ai_info = obj->ai_info;
2850
2851 if (f_see) {
2852 if ((Gametime - ai_info->last_see_target_time > CHECK_VIS_INFREQUENTLY_TIME) || !(ai_info->awareness)) {
2853 if (ai_info->sound[AI_SEE_SOUND] != SOUND_NONE_INDEX) {
2854 // Plays the sound and makes absolute sure that it is not looping
2855 if ((ps_rand() % 10) != 0) // 90% chance of playing it
2856 {
2857 if (Gametime - ai_info->last_sound_time[AI_SEE_SOUND] >= CHECK_VIS_INFREQUENTLY_TIME) {
2858 Sound_system.StopSoundLooping(
2859 Sound_system.Play3dSound(ai_info->sound[AI_SEE_SOUND], SND_PRIORITY_NORMAL, obj));
2860 if (Game_mode & GM_MULTI)
2861 MultiPlay3dSound(ai_info->sound[AI_SEE_SOUND], OBJNUM(obj), SND_PRIORITY_LOW);
2862 if (Demo_flags == DF_RECORDING)
2863 DemoWrite3DSound(ai_info->sound[AI_SEE_SOUND], OBJNUM(obj), SND_PRIORITY_LOW);
2864 }
2865 }
2866
2867 ai_info->last_sound_time[AI_SEE_SOUND] = Gametime;
2868 }
2869 }
2870 }
2871
2872 if (ai_info->awareness < AWARE_MOSTLY)
2873 ai_info->awareness = AWARE_MOSTLY;
2874
2875 // Note: Player position is also updated in the visability test function
2876 // for MIN_VIS_RECENT_CHECK_INTERVAL seconds
2877 object *targetptr;
2878 object *other_obj = targetptr = ObjGet(ai_info->target_handle);
2879
2880 if (targetptr) {
2881 if (f_see)
2882 ai_info->last_see_target_time = Gametime;
2883 else
2884 ai_info->last_hear_target_time = Gametime;
2885
2886 AIDetermineAimPoint(obj, targetptr, &ai_info->last_see_target_pos);
2887 }
2888}
2889
2890bool AINotify(object *obj, uint8_t notify_type, void *info) {
2891 int next_anim;

Callers 1

AINotifyFunction · 0.85

Calls 7

ps_randFunction · 0.85
MultiPlay3dSoundFunction · 0.85
DemoWrite3DSoundFunction · 0.85
ObjGetFunction · 0.85
AIDetermineAimPointFunction · 0.85
StopSoundLoopingMethod · 0.80
Play3dSoundMethod · 0.80

Tested by

no test coverage detected