In-game Map Entities: Difference between revisions
Springheel (talk | contribs) New page: ''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" spaw... |
Springheel (talk | contribs) No edit summary |
||
Line 5: | Line 5: | ||
For example, create one with these spawnargs: | For example, create one with these spawnargs: | ||
"name" "MapOfSewer" | "name" "MapOfSewer" | ||
"inv_map_start" "0" | "inv_map_start" "0" | ||
"inv_name" "Sewer Map" | "inv_name" "Sewer Map" | ||
"gui" "guis/map_of_sewer.gui" | "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: | 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 | rect 0,0,640,480 | ||
nocursor 1 | nocursor 1 | ||
Line 24: | Line 24: | ||
visible 1 | visible 1 | ||
} | } | ||
} | } | ||
Line 34: | Line 34: | ||
Create an "atdm:static_custom_item" entity with these spawnargs: | Create an "atdm:static_custom_item" entity with these spawnargs: | ||
"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" | ||
"sr_effect_1_1_arg1" "FrobSewerMap" | "sr_effect_1_1_arg1" "FrobSewerMap" | ||
"sr_state_1" "1" | "sr_state_1" "1" | ||
"sr_type_1" "STIM_FROB" | "sr_type_1" "STIM_FROB" | ||
The "sr_*" spawnargs describe how your custom entity will react to a frob stim. | The "sr_*" spawnargs describe how your custom entity will react to a frob stim. | ||
Line 47: | Line 47: | ||
Place the following code inside your *.script file: | Place the following code inside your *.script file: | ||
void FrobSewerMap() | |||
{ | { | ||
// Put MapOfSewer into inventory, replacing the frobbed scroll named SewerMap. | // Put MapOfSewer into inventory, replacing the frobbed scroll named SewerMap. | ||
// 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, | $player1.replaceInvItem($SewerMap,$MapOfSewer); | ||
$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 | |||
{ | |||
} | |||
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. | ||
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. |
Revision as of 00:17, 19 April 2011
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.