The cheese sandwich,
Do you want the enemy to respond only when the gunfire is within a certain distance away? As for cause and effect, the code needed to be written for the reaction of the enemy wholly depends on what that reaction is.
I would code in a way that if the gunfire is shot from within a maximum distance, set by you, then the enemy reacts. His reaction could be turning towards the location of the gunfire, or some simple animation. As for the code, in the way I just stated I would do it, look below.
REM << when mouseclick is pressed then gun is shot
if mouseclick() = 1 then shootgun = 1
REM << obj1 is the camera(player);obj2 is the enemy
REM << find distance between player and enemy
if shootgun = 1
if sqrt((obj1_x# - obj2_x#)^2 + (obj1_z# - obj2_z#)^2) < 300 then obj2_aware = 1
REM << reset shootgun for next gunshot
shootgun = 0
endif
if obj2_aware = 1
REM << effect of enemy hearing gunshot goes here
endif
The code above is not executable, but serves as a basic example.
+NanoBrain+