Jump to content
The Dark Mod Forums

Support dynamically instancing prefabs or child maps within parent maps


MirceaKitsune

Recommended Posts

I was wondering what mappers and developers alike think of supporting dynamically instanced groups in some form. This means DarkRadiant and TheDarkMod would be able to instance prefabs on the run similar to models: Currently prefabs may only be used to import an entity group once, each set is permanently stored in the map and becomes unique. An alternative would be instancing other map files from the main map, where child maps may contain a building (entities, brushes, visportals) which the parent map can place and rotate as easily as they would a func_static.

The main motive is the ability to replicate complex components where changing one copy affects them all. Take mechanical/machines/steam_engine_* which is a complex machine with various movers / rotators / particles / sounds / etc: Its setup may be improved in the future, maybe to allow turning it off which hasn't been implemented... if the original prefab is ever improved, none of the maps that added it will get the update, the author must delete all their steam engines and import the prefab again. The way mappers could use this is equally interesting; Cities can be built from component buildings where each structure is maintained independently, the instancer may mix structures / furniture / inhabitants to produce unique rooms from compatible sets.

This would likely need to be implemented as a new entity such as atdm:instance, which is given the paths to prefabs or maps that must be placed at its position and rotation. The entity should allow multiple sets that can be mixed, for example the spawnargs "group_1 = prefabs/room_64x64_worn.pfb" and "group_2 = prefabs/room_64x64_furniture_old.pfb" will place the worn out version of 64 unit room with the old furniture for it. Groups can even be randomized so some are optional while others pick a random prefab, this would allow producing entirely unique buildings including map geometry (per dmap). Both DR and TDM would need to learn the new format:

  • DarkRadiant: Changes needed to display / select / move / filter the contents of maps or prefabs as single entities like models. Since they're unique resources like all assets editing them on the run isn't possible and prefabs must be re-exported, DR can instead offer a shortcut to open instances as maps to make changes.
  • TheDarkMod: The engine must unpack each prefab during dmap. Instances may contain brushes and portals which need to be permanently baked into the map, this wouldn't change other that instead of being read from the main map they're read from a reference map or prefab. Consequentially if brushes or patches are modified in an instance the main map will break until you run dmap again, just as it would if you added or removed brushes then ran the map without recompiling it... entities and their spawnargs should be alright to change freely. When randomization is used dmap picks different prefabs to compile the map from; The seed must be baked in so the map and proc don't mismatch each time you start the FM... random buildings are only possible once per compilation rather than per play, unless we also add a special flag to dmap each time you start such a mission.
Edited by MirceaKitsune
Link to comment
Share on other sites

2 hours ago, datiswous said:

This can partly already been done with changing def files?

Only a little... you can't do anything as complex as whole buildings with defs alone. In DarkRadiant there's no way to even preview the full result of a def, hence why characters don't have a head in the editor for example... let alone edit it from the map and export instead of guessing from a text editor, you can do that with prefabs but those become unique so you can't maintain universal copies nor randomize which are spawned. Most importantly there's no way to include brushes and visportals in defs, the idea is to support instancing and potentially randomizing even map geometry used by dmap to compile the end result.

Link to comment
Share on other sites

5 hours ago, nbohr1more said:

Instancer entities could be distributed by seed entities if nothing stops that from working. They are ultimately different things the way I envision them though: Seed requires a brush and is used to scatter copies of an entity in random positions, versus combining structured components with support for both entities and brushes.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...