Plan for letting NPCs move between maps

From OHRRPGCE-Wiki
Jump to navigation Jump to search

This is related to Plan for global NPC definitions. While they could be combined into single feature, it seems reasonable for them to be separate.

(Adapted from a mailinglist discussion "Crazy or not crazy: NPCs on other maps", by James and TMC)

Cross-map NPC definitions might actually be relatively easy. Then it could become possible to move through doors while riding a vehicle, and the destination map would just load a dynamic instance of the vehicle from its origin map.

This ties in nicely with the plan (once we have script types) to make NPC references remember which map they are for, which means you could read data for an NPC instance on a different map (if it's set to remember state), and read the NPC definition via that reference too.

(As an alternative to Plan for global NPC definitions, the map editor could also allow placing an NPC instance using an NPC definition from a different map.)

Alternative 1[edit]

Suppose that the NPCInst type had a map_of_origin id number in addition to the NPC definition id number. Then the code that actually does NPC appearance and behavior like visnpc, or NPC walking and activation would need to be aware of it.

All NPC definitions would have to be loaded, rather than just the NPC definitions of the current map, but that would probably be practical too.

  • Put the npcs() array into a UDT, and then create an array of that, instead of using a 2D array.
    • Easier to just create a new (temporary?) UDT than to first convert Game to use MapData. We probably wouldn't want to keep all data for all maps loaded in memory.

Alternative 2[edit]

One way to go about Plan for global NPC definitions is to use NPC IDs 0-999 for local NPCS, 1000+ for global NPCs. This could be merged with this plan by using IDs 2000-2999 for the NPCs defined on map 0, IDs 3000-3999 for NPCs on map 1, etc, so no additional map_of_origin is needed, and replacing npcs() with a hashtable mapping from ID to NPCType