Creating Automaps: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Obsttorte (talk | contribs)
Datiswous (talk | contribs)
m →‎Additions: fixed link to Doom 3 iddevnet gui's page
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Editing]]
== Introduction ==
== Introduction ==


Line 59: Line 59:
     entityDef atdm:automap
     entityDef atdm:automap
     {
     {
"inherit" "atdm:map_base"
        "inherit" "atdm:map_base"
 
        "editor_usage" "game map of terrain for player" // THIS ONLY SHOWS IN ENTITY INSPECTOR
"editor_usage" "game map of terrain for player" // THIS ONLY SHOWS IN ENTITY INSPECTOR
        "inv_name" "Map" // SHOWS IN PLAYER'S INVENTORY.
 
        "inv_icon" "guis/assets/game_maps/map_of_icon.tga"
"inv_name" "Map" // SHOWS IN PLAYER'S INVENTORY.
        "gui" "guis/automap/automap.gui"
"inv_icon" "guis/assets/game_maps/map_of_icon.tga"
        "scriptobject" "inventory_automap"
"gui" "guis/automap/automap.gui"
"scriptobject" "inventory_automap"
     }
     }


Line 73: Line 71:
== The script object ==
== The script object ==


The scriptobject as well as an example setup can be found here[http://forums.thedarkmod.com/topic/14394-apples-and-peaches-obsttortes-mapping-and-scripting-thread/?p=317949]
The scriptobject as well as an example setup can be found [http://forums.thedarkmod.com/topic/14394-apples-and-peaches-obsttortes-mapping-and-scripting-thread/?p=317949, here]


== Conclusion ==
The main difference to a ''normal'' map is the updateLoop, which gets executed every few milliseconds.


It is quite simple to setup a fully functional automap. The main effort for the mapper is to actually draw the map and align the pieces later one. The script is easy but gets long. This is caused by the lack of suitable containers in the doom3 scripting language.
    void inventory_automap::updateLoop()
    {
        string loc;
        while(1)
        {
            loc=$player1.getLocation().getName();
            loc="gui_"+loc;
            setKey(loc,1);
            sys.wait(0.1);
        }
    }


== Additions ==
As you can see it is pretty short. The only thing it does is retrieving the name of the location the player is currently in and pass this to the gui. Than it waits for 100 ms.


If you want to test the alignment in game, just change the lines in the ''main'' method in the script file. Set all the values to "1".
Example: The player is in a location which contains an info_location entity named ''kitchen''. This value gets read out and passed to the variable '''loc'''. Than the ''gui_'' string is added on front, so '''loc''' is now ''gui_kitchen''. (Remember the gui variable earlier on?) This value gets than set to 1. This will not have an effect if the value is already set to 1, but it doesn't hurt either.


If you want to have an automap that marks where the player currently is, the following changes need to be done:
== Conclusion ==


- The ''mark'' method is called via "call_on_exit" by the zones. "call_on_entry" calls a similar function that sets the value for the room to "2"
It is quite simple to setup a fully functional automap. The main effort for the mapper is to actually draw the map.


- The show method checks for the values to be "1" or "2" separately. For "2" a highlighted version is shown on the map
== Additions ==
 
- Obviously you have to make these highlighted version first
 
If you want the map to be fond in the mission you have to do the following to avoid the rooms the player was before finding the map to be drawn on it
 
- create a hidden, non-mandatory objective "if player possesses item". The ''item'' is the map.
 
- fill the '''success_script''' field with drawMap
 
- in the script file, add a ''float'' '''mapDraw''' at the beginning of the file


- set this to zero in the ''main'' method
It is possible to extent the functionality of the automap. This will however require changes to the scriptobject.


- in the beginning of the ''mark'' method add the line ''if (!mapDraw) return;''
You can setup Objectives where the player has to explore a certain percentage of the map (like in Mission #13 in Thief2: The Metal Age). This requires to set the percentage values you want each location to have on the respective location entities. You can than read them out in the update loop. To avoid the same values to be added up several times you would also need to keep track of which locations have already been counted. A global scripting variable keeps track of the percentage already discovered by the player and sets the respective mission objective to successful once it reaches the desired amount.


Obviously you will need to do this several times if the player can find several maps. If so, be sure to make different ''mark'' methods for every map to be found (thus meaning entities in the map file)
You can have maps that mark areas where you already have been and were you currently are. This requires altering the gui, too, as you have to specify the colors to be used for hilighting depending on whether the player is still in an area or not.


You can use this setup as a starting point for setting up objectives like "investigate 50% of the area".
Similar to the images you can have text added to the map, like little notes that become visible once a condition is met (the player reads a note or similar). See [https://iddevnet.dhewm3.org/doom3/guis.html here] for more info on how to setup the gui.


Questions, replies and advices of any kind can go [http://forums.thedarkmod.com/topic/14394-apples-and-peaches-obsttortes-mapping-and-scripting-thread/ here]
Questions, replies and advices of any kind can go [http://forums.thedarkmod.com/topic/14394-apples-and-peaches-obsttortes-mapping-and-scripting-thread/ here]


--[[User:Obsttorte|Obsttorte]] ([[User talk:Obsttorte|talk]]) 06:33, 25 January 2013 (EST)
--[[User:Obsttorte|Obsttorte]] ([[User talk:Obsttorte|talk]]) 06:33, 25 January 2013 (EST)
{{GUI|sort=Automaps}}

Latest revision as of 10:23, 4 March 2024

Introduction

Normally the player is given a map at mission start, which is showing him the location he is attempting to sneak in. However, it may not seem very realistic that the player already possesses such detailed information without ever been in the specific place. An automap, thus meaning a map that gets drawn while the player proceeds in his mission may seem more realistic.

On the other hand such thing can also add a lot to immersion. The player don't know what is expecting him in the beginning, but benefits from the advantages a map brings to him while he proceeds. In addition an automap provides information about where the player already have been and therefore can avoid frustrating moments when he is searching for one little room he may have overseen.

The following article now describes how to set up such an item.

Preparations

The first step is to actually draw your map. How you do this is your business. After you have done so you should cut out all the seperate rooms you want to appear on the map later on. Make sure to make the background transparent (using gimp for example). If you do so you should have

- one picture containing the parts of the map the player already know at mission start (called startmap furthermore) - several pictures of the rooms he can discover later on

It is your choice if you want to put the startmap on the map_of_.tga file served with the startmap package or keep it seperate. However, for the tutorial let's just assume you have choosen the first possibility.

Furthermore you should get familiar with the zone system as it is needed here.

Setting up the gui

The gui looks like this:

 windowDef Desktop
 {
   	rect      0,0,640,480
   	nocursor 1
        
       windowDef background_map
       {
               rect      64,48, 512, 394
               background "guis/automap/map_of"
               visible 1
       }
       ...
       // Required include for inventory map
       #include "guis/readables/inventory_map.guicode"	
 }

In our case guis/automap/map_of is the file that holds the startmap. Where the dots are you have to add the following code for each area visible on the map.

   windowDef nameOfArea
   {
        rect 100,100,380,300
        background "path_to_imagefile"
        visible "gui::gui_XYZ"
   }

- nameOFArea can be choosen as you like, but each name must be unique and it makes sense to make it recogniseable

- path_to_imagefile holds the path to the image to be drawn. Where nothing gets drawn the image should be transparent

- the gui variable gui::gui_XYZ determines whether the image is visible or not. XYZ is the name of the corresponding location entity. You can easely get typos, so if something isn't working this is the first place to check

Note that all pictures are using the same area of the gui. This easens the setup, but must be taken into account when creating the images for the map.

The entity Definition

   entityDef atdm:automap
   {
       "inherit"			"atdm:map_base"
       "editor_usage"		"game map of terrain for player" // THIS ONLY SHOWS IN ENTITY INSPECTOR
       "inv_name"			"Map" // SHOWS IN PLAYER'S INVENTORY.
       "inv_icon"			"guis/assets/game_maps/map_of_icon.tga"
       "gui"				"guis/automap/automap.gui"
       "scriptobject"	"inventory_automap"
   }

The important parts here are the gui spawnarg, letting it use the before mentioned gui, and the scriptobject spawnarg.

The script object

The scriptobject as well as an example setup can be found here

The main difference to a normal map is the updateLoop, which gets executed every few milliseconds.

   void inventory_automap::updateLoop()
   {
       string loc;
       while(1)
       {
           loc=$player1.getLocation().getName();
           loc="gui_"+loc;
           setKey(loc,1);
           sys.wait(0.1);
       }
   }

As you can see it is pretty short. The only thing it does is retrieving the name of the location the player is currently in and pass this to the gui. Than it waits for 100 ms.

Example: The player is in a location which contains an info_location entity named kitchen. This value gets read out and passed to the variable loc. Than the gui_ string is added on front, so loc is now gui_kitchen. (Remember the gui variable earlier on?) This value gets than set to 1. This will not have an effect if the value is already set to 1, but it doesn't hurt either.

Conclusion

It is quite simple to setup a fully functional automap. The main effort for the mapper is to actually draw the map.

Additions

It is possible to extent the functionality of the automap. This will however require changes to the scriptobject.

You can setup Objectives where the player has to explore a certain percentage of the map (like in Mission #13 in Thief2: The Metal Age). This requires to set the percentage values you want each location to have on the respective location entities. You can than read them out in the update loop. To avoid the same values to be added up several times you would also need to keep track of which locations have already been counted. A global scripting variable keeps track of the percentage already discovered by the player and sets the respective mission objective to successful once it reaches the desired amount.

You can have maps that mark areas where you already have been and were you currently are. This requires altering the gui, too, as you have to specify the colors to be used for hilighting depending on whether the player is still in an area or not.

Similar to the images you can have text added to the map, like little notes that become visible once a condition is met (the player reads a note or similar). See here for more info on how to setup the gui.

Questions, replies and advices of any kind can go here

--Obsttorte (talk) 06:33, 25 January 2013 (EST)