I'm just curious, is there a simple way to make a key that will unlock all doors in the mud world? This would come in handy for my cityguard type mobs so they can walk around the town and do their patrols via spec_funs and not have to load up keys for every door. I'm pretty sure this is possible with some minor coding tweaks but I'm not even sure which function to do this in or even exactly what I need to do. I'd be sure to make the key purge upon the cityguards death and take all the precautions so that mortals don't get their hands on the key. Just stating that so I don't get a bunch of people telling me what a stupid idea it is.
The easy way would be to just change the has_key() function to check for a "master key" flag. I'd suggest placing the flag on the mob rather than the key itself, though, if you don't want players getting hold of it. Then you just need to worry about people charming the guard.
The problem is it does actually make sense to be able to take the keys from the guard. So if you just dislike having lots of key objects, my suggestion would be to modify keys so that they can unlock a range of vnums rather than just a single vnum, then give the guards a "bunch of keys" that can unlock all doors in their area. If you don't want the keys unlocking everything (eg perhaps the mayor has a safe in his house) you could also add a 'security' value to both locks and keys. If you want the mayor to be able to change his locks every so often, you could add a timestamp as well.
Assuming you've got some kind of vnum system, you could allow a key item to open doors in rooms in a vnum range of key->vX to key->vY. Then your master key could just be vX->0, vY->over nine thousand!.
Thanks for all the great responses, I think I like KaVir's suggestion of having the has_key function check for the master_key flag or maybe for the spec_cityguard flag. I never thought of doing it that way.