I'm writing a prototype for the tactical spaceship combat in a game I'm working on.
The basic idea of the part I'm working on right now is that a 'ship' object (which represents a single individual ship) contains a list of 'system' objects. When a ship is first initialized, it calls an initialize() function on each of its systems (which is not the same as the standard __init__ function called whenever an instance of an object is made) that will (among other things) call a register() function on the ship the system is a part of.
That register() function takes a string as a parameter, which is the name of a function that the system expects to be called on the ship object. Whenever that function is called on the ship object, the ship object will call it on all systems that registered to receive it until either one of them returns True (indicating that the system 'dealt with' the action in a final manner) or it runs out of systems that have signed up to receive the call. So far so good.
However, some systems might want to get their calls before other systems do. For example, your hull system will want to be the last system to receive a hit(); the shields will want to hear it first. The simplest solution might be to implement a priority system: the shields will call myship.register("hit",priority=1), and the hull will call myship.register("hit",priority=0).
But now we imagine that there ought to be "super-shields" that intercept the hit before the main shields take it. Simple enough: give them priority 2. This might get annoying for the developer if a whole lot of systems want to take a certain request, but he can manage it.
However, this game is intended to be highly user-extensible. If someone releases an addon that (for a stupid example) plays Full Metal Jacket sound clips every time the player's ship is hit, the developer of that addon might not be aware of the addon that adds the "super-shields", and give his Annoying Drill Sergeant system the same or lower priority as the super-shields, and thus may not receive hit messages before they are acknowledged by the super-shield. This is, of course, undesirable behavior.
Does anyone have any ideas as to how to avoid this problem? 
Others have suggested having a way a system can request the priority level one higher than or one lower than the highest/lowest current priority level, but that causes largely undefined behavior, since the priority levels would be based on the order in which the systems are initialized.
I've also considered adding a "super-priority", where a system always receives the message before other systems but cannot acknowledge and stop it. This would be only a partial solution though; it'd fix the given example, but not a situation where there are super-shields layered under super-super-shields that need to block the message.
The issue is trying to give an absolute value to the priority. Rather you need to build a relative priority data structure for each call. This way you can say that hit() is highest priority for super-shields then shields then hull. The mod would then simply need to change the hit sound effects for the hull or add an additional sound effect to be played as well.
The most straightforward way to go about it would requiring that any new object's priority for a given call be linked to another object with that call. It then requires selecting if the new object's priority is lower or higher. So shields and hull are linked (hull < shields) and super-shields and shields are linked (shields < super-shields). That information would make it fairly easy to build a 2D multiple items (2D to have allow for same priority) linked list that holds the priorities for each call. Thus the register function might look like this, "myship.register("hit",shields,"lower",super-shields)" and give shields a lower priority than super-shields. You could allow for additional conditions such as myship.register("hit",hull,"lower",shields,"lower",super-shields) if you already had the hull and super-shields, and wanted to add shields between them. However, then you run the risk of having to deal with contradictions or violating the conditions.
Algorithm design for systems on a spaceship taking messages