In-game Map Entities: Difference between revisions
Nbohr1more (talk | contribs) No edit summary |
m Add 2 sentences saying why alpha channel and how differs from Startpack method, with ref |
||
(5 intermediate revisions by 3 users not shown) | |||
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. (The alpha channel supports a map with a ragged edge. Unlike the method in [[Startpack_Mappers%27_Guide#Adding_an_In-game_Map_to_your_FM]], here, a custom .mtr or .def file is unneeded for such support.) | |||
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: | Create an "atdm:static_custom_item" entity with these spawnargs: | ||
Line 36: | Line 35: | ||
"name" "SewerMap" | "name" "SewerMap" | ||
"inv_map_start" "0" | "inv_map_start" "0" | ||
"model" "models/darkmod/readables/scroll_rolled_up. lwo" (or use whatever model you prefer) | "model" "models/darkmod/readables/scroll_rolled_up.lwo" (or use whatever model you prefer) | ||
"sr_class_1" "R" | "sr_class_1" "R" | ||
"sr_effect_1_1" "effect_script" | "sr_effect_1_1" "effect_script" | ||
Line 52: | Line 51: | ||
// 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. | ||
Line 67: | Line 64: | ||
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. | 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. | ||
{{editing | {{editing}} | ||
[[Category:Tutorial]] | |||
[[Category:Mapping Tutorials]] |
Latest revision as of 02:34, 1 November 2020
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. (The alpha channel supports a map with a ragged edge. Unlike the method in Startpack_Mappers'_Guide#Adding_an_In-game_Map_to_your_FM, here, a custom .mtr or .def file is unneeded for such support.)
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.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.