In-game Map Entities: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 16: Line 16:
         rect 0,0,640,480
         rect 0,0,640,480
         nocursor 1
         nocursor 1
 
 
         windowDef background_map
         windowDef background_map
         {
         {
                 rect 64,48, 512, 384
                 rect 64,48, 512, 384
                 background "guis/assets/game_maps/map_of_sewer"
                 background "guis/assets/game_maps/map_of_sewer"
                 visible 1
                 visible 1
         }
         }
  }
  }


Create the image you want displayed (your map) in "map_of_sewer.tga", with an alpha channel.
Create the image you want displayed (your map) in "map_of_sewer.tga", with an alpha channel.
Line 52: Line 49:
         // MapOfSewer shows the sewer map when used while in inventory.
         // MapOfSewer shows the sewer map when used while in inventory.
         // Make sure HUD shows the map icon.
         // Make sure HUD shows the map icon.
 
         $player1.replaceInvItem($SewerMap,$MapOfSewer);
         $player1.replaceInvItem($SewerMap,$MapOfSewer);
         $player1.setCurInvItem("Sewer Map"); // provide inventory name, not item name
         $player1.setCurInvItem("Sewer Map"); // provide inventory name, not item name
  }
  }
 
  void main() // this might already be there; skip if so
  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.
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.

Revision as of 15:00, 3 September 2012

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/.

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.replaceInvItem($SewerMap,$MapOfSewer);
       $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.