In-game Map Entities

From The DarkMod Wiki
Jump to: navigation, search

originally written by grayman

Create an "atdm:map_of" entity as if you intend to place it in the player's inventory at the start of the mission. Then turn off the "inv_map_start" spawnarg.

For example, create one with these spawnargs:

"name" "MapOfSewer"
"inv_map_start" "0"
"inv_name" "Sewer Map"
"gui" "guis/map_of_sewer.gui"

Create a gui file called "map_of_sewer.gui" with the following contents, and put it into your guis directory:

windowDef Desktop
       rect 0,0,640,480
       nocursor 1
       windowDef background_map
               rect 64,48, 512, 384
               background "guis/assets/game_maps/map_of_sewer"
               visible 1

Create the image you want displayed (your map) in "map_of_sewer.tga", with an alpha channel.

Put that image into guis/assets/game_maps/.

Retrieve a copy of guis/assets/game_maps/map_of_icon.tga from startmap.pk4 and place it into guis/assets/game_maps/.

Create an "atdm:static_custom_item" entity with these spawnargs:

"name" "SewerMap"
"inv_map_start" "0"
"model" "models/darkmod/readables/scroll_rolled_up.lwo" (or use whatever model you prefer)
"sr_class_1" "R"
"sr_effect_1_1" "effect_script"
"sr_effect_1_1_arg1" "FrobSewerMap"
"sr_state_1" "1"
"sr_type_1" "STIM_FROB"

The "sr_*" spawnargs describe how your custom entity will react to a frob stim.

Place the following code inside your *.script file:

void FrobSewerMap()
       // Put MapOfSewer into inventory, replacing the frobbed scroll named SewerMap.
       // MapOfSewer shows the sewer map when used while in inventory.
       // Make sure HUD shows the map icon.

       $player1.setCurInvItem("Sewer Map"); // provide inventory name, not item name

void main() // this might already be there; skip if so

When you play the mission, frobbing the custom item that looks like a scroll will cause the script to run, which replaces the custom item in your inventory with the "atdm:map_of" entity you created at the top of this note.

From here on, it's as if the game gave you the map at mission start. Hit your "use" key and your map should appear on the screen.