You have two main ways to go here:
1) Most simpler games simply have the game engine apply rules, then dispatch alerts when certain conditions are met. So on a game tick they check to see (using your example) if a dead body is within x feet of a living guard and/or his field of vision, and if so they throw a livingGuard.hostileAlert() call and let the guard's logic take over from there.
Here the rules are with the game engine, and not with the NPC object itself, with something like collision detection. The advantage of this system is all the perception logic is on one place in the engine, and so if there is a bug in 'seeing' something it would be universal to all enemies, not just one guard that seems unable to ever see anything.
2) More fully modular/object-oriented games would feature the guard having its own set of perception rolls (like in DnD systems), where at certain ticks they ask the game engine if they can see something interesting. The "Game Master" (the game engine) compares the NPCs abilities/limitations (field of vision, line of sight, visible range, etc) to the environment, and responds to the guard accordingly.
The game engine would take the guards request to Perceive, look up/request its abilities, make the calculation, and respond with "all clear" or "hostile visible", etc. It would then be up to the guard object to decide how to respond with it's own internal logic.
The advantage of this system is that every NPC can easily be customized to have it's own perceptive abilities, and the engine can also be customized to deal with things like low-light or fog conditions, illusion/invisibility effects, etc. So you could create a camera that only "takes a picture" every 10 seconds by only having it request a Perceive function every 10 seconds.
Using the same system you can also force "obvious" effects, like if a person pulls out a weapon the game engine immediately triggers a hostileAlert() of all nearby NPCs, etc.
On the downside, every 'feature' is a potential 'bug', like a dragon with a sight range of 1 inside his own cave, or see-in-the-dark bats that can't see anything because its dark, or 1 guard you typo'd and can see people coming a mile away for no reason.