[Ohrrpgce] Crazy or not crazy: NPCs on other maps

Ralph Versteegen teeemcee at gmail.com
Tue Jan 31 17:18:17 PST 2017


On 1 February 2017 at 10:37, James Paige <Bob at hamsterrepublic.com> wrote:

> Taoki asked on IRC if we could allow NPCs to move from map to map.
>
> At first I was thinking that no, that is impractical, and that it would be
> better to make a separate pool of universal NPC definitions that could be
> used on any map...
>
> but after looking at the code for a bit, I am wondering if cross-map NPC
> definitions might actually be relatively easy.
>
> 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.
>
> Does this sound crazy or not-crazy?
>
> If this could work, 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.
>

Hmm, npcs() (the NPCType array) is used in not too places, which would
mostly be easily fixed up.

This is definitely not crazy, and sounds like a neat feature. I agree that
your proposal wouldn't be hard. Just put the npcs() array into a UDT, and
then create an array of that, instead of using a 2D array. I recently added
a MapData UDT which is used in the map editor, but easier to just create a
new temporary UDT than to first convert Game to use MapData.

This also ties in nicely with my 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.  (I had been
planning to instead just throwing an error if you tried to use an off-map
npc reference for anything.)

Regarding not switching to MapData: We probably wouldn't want to keep all
data for all maps loaded in memory anyway... but maybe I'm thinking like
it's the 2000's. But then what should and shouldn't be kept loaded?

Conceivably the map editor could also allow placing an NPC instance using
an NPC definition from a different map, which would prevent having to
duplicate NPC definitions across maps, but that can be implemented later.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.motherhamster.org/pipermail/ohrrpgce-motherhamster.org/attachments/20170201/566413c9/attachment.htm>


More information about the Ohrrpgce mailing list