Whenever an action is about to be executed, the parser runs through all of the defined global remappings, and gives each one a chance to remap the command. If any remapping succeeds, we replace the original command with the remapped version, then repeat the scan of the global remapping list from the start - we do another complete scan of the list in case there's another global mapping that applies to the remapped version of the command. We repeat this process until we make it through the whole list without finding a remapping.
GlobalRemapping instances are added to the master list of mappings automatically at pre-init time, and any time you construct one dynamically with 'new'.
GlobalRemapping : PreinitObject
The return value is a list, [targetActor, action], giving the resulting target actor and new action object. If we don't find any remapping, this will simply be the original values passed in as our arguments; if we do find a remapping, this will be the new version of the command.
This routine should first check to see if the command is relevant to this remapping. In most cases, this means checking that the command matches some template, such as having a particular action (verb) and combination of potential objects. Note that the objects aren't fully resolved during global remapping - the whole point of global remapping is to catch certain phrasings before we get to the noun resolution phase - but the *phrases* involved will be known, so the range of potential matches is knowable.
If the routine decides that the action isn't relevant to this remapping, it should simply return nil.
If the action decides to remap the action, it must create a new Action object representing the replacement version of the command. Then, return a list, [targetActor, action], giving the new target actor and the new action. You don't have to change the target actor, of course, but it's included in the result so that you can change it if you want to. For example, you could use this to remap a command of the form "X, GIVE ME Y" to "ME, ASK X FOR Y" - note that the target actor changes from X to ME.