Ru/Menu Background Map: Difference between revisions
Line 183: | Line 183: | ||
<!--If you would like to just use the vmt texture as a background (without loading a map), simply create the file <code>\cfg\valve.rc</code> and add the following:--> | <!--If you would like to just use the vmt texture as a background (without loading a map), simply create the file <code>\cfg\valve.rc</code> and add the following:--> | ||
Если вы хотите использовать для фона текстуру (без загрузки карты) просто создайте файл <code>\cfg\valve.rc</code> и добавьте следующие строки: | Если вы хотите использовать для фона текстуру (без загрузки карты), просто создайте файл <code>\cfg\valve.rc</code> и добавьте следующие строки: | ||
<pre> | <pre> | ||
// load the base configuration | // load the base configuration |
Revision as of 11:05, 11 May 2008
Template:Totranslate:ru Фоновые карты это трёхмерные динамичксие задние планы, которые появляются за игровым меню при запуске игры. Это компилированные BSP-карты, как обычные. Обычно фоновые карты используют для однопользовательских модификаций (как Half-Life 2), но их можно использовать для любых модификаций. Фоновая карта может изменяться, как только игрок проходит главу, в зависимости от модификации
Создание фоновой карты
Background maps should be created like dioramas. The geometry in the map should be strictly limited to only what will be seen in the camera view. The goal is to make the least amount of geometry and materials necessary, so the map is smaller and loads faster.
To create a background map:
- Create the basic geometry for the scene you want included in the background map. It should not have any leaks, and be sealed like any standard game level. Add lights and materials as needed. You may want to start from an existing level and simply remove or hide geometry and entities that are not needed for the background map. All unnecessary elements should be removed.
- Add an info_player_logo (multiplayer games) or info_player_start (singleplayer games) to the map. It doesn't much matter where the entity is placed, as long as it is inside the level geometry and not floating so high that the player falls and takes damage.
- Add a point_viewcontrol entity to the map where you want the camera position to be when the map is displayed. Name the point_viewcontrol something descriptive, (i.e.
"viewcontrol_background1"
). - For your point_viewcontrol entity, deactivate the flags: Start at Player / Follow Player / Interruptable by Player. Activate the flags: Freeze Player / Infinite Hold Time / Snap to goal angles / Make player non-solid
- Add an info_target entity. This is the position the point_viewcontrol camera will be pointing at when the map is displayed. Name it similar to the point_viewcontrol ( i.e.
"target_background1"
). - Select the point_viewcontrol. For the Entity to look at keyvalue, set the value to the info_target you just created as the target entity.
- The point_viewcontrol must be activated when the background map is loaded. The easiest way to this is with a logic_auto entity. Add an OnMapSpawn output on the logic_auto that fires the Enable input of the point_viewcontrol.
- You can add other outputs to the logic_auto for events that you want to happen when the background is displayed, such as lights flickering, NPCs walking by, sounds to play, etc. Be careful about adding too much, however. Background maps should have good performance, load quickly, and not distract too much from the game menus.
- Save and compile the map just as you would any standard game map. If you're replacing an existing Half-Life 2 map, read Replacing Half-Life 2 background maps below to make sure your map is named properly.
Тестирование фоновой карты
Чтобы проверить фоновую карту, запустите мод без запуска карт. После загрузки, включите консоль разработчиков и введите:
map_background <mapname>
Где <mapname>
- имя вашей карты. Как только загрузится карта, поверх неё появится игровое меню.
После тестирования на работоспособность фоновой карты, вы можете её изменить и улучшить. Вы, возможно, захотите добавить больше деталей, изменить расположение камеры или её цели. Псоле того, когда вы настроите положение карты, хорошо бы оптимизировать уровень как это возможно, просто применив материал toolsnodraw
на те грани, которые не видны камере. После оптимизации фоновая карта будет загружаться быстрее.
См. maps\sdk_background.vmf
для примера фоновой карты.
Menu Background Material
It is also necessary to create background materials for your menu background .BSP. This is the image that is shown when you first launch the game, but before the background .BSP has finished loading. In Half-Life 2, this was a blurred screenshot of the background map (when recreating this, use a 30px Gaussian Blur filter for a 1280x image). When the background .BSP is finished loading, the screen fades from the static background material to the actual 3D background map.
The following two materials are needed:
<game directory>\materials\console\<map name>.vmt
<game directory>\materials\console\<map name>_widescreen.vmt
For example, if you made a background map named sdk_background.bsp, you would need these two materials:
hl2\materials\console\sdk_background.vmt
hl2\materials\console\sdk_background_widescreen.vmt
The background materials are usually a 1024x1024 screenshot of the background map, blurred in an image-editing application.
You can find the key command to take screen shots under Options -> Keyboard when you run the game. The F5
key is the default screenshot key, and saves a .JPG format screen shot to the <game directory>\screenshots
directory. You can also bind a key to the screenshot
console command, which will save in the .TGA format.
A menu background material .vmt file should look something like this:
"UnlitGeneric" { "$basetexture" "console/sdk_background" "$vertexcolor" 1 "$vertexalpha" 1 "$ignorez" 1 "$no_fullbright" "1" "$nolod" "1" }
For information on how to create these materials, see the Material Creation doc.
Sample materials for the sdk_background sample map are located in:
\sourcesdk_content\hl2\materialsrc\console
(for the source .TGAs)
\half-life 2\hl2\materials\console
(for the .VMT and .VTF files).
Script files for background maps and chapters in your own MOD
Once a custom background map has been created, it must be inserted into the proper script files in order for it to be automatically displayed during the correct game chapter.
This section describes the individual files that are used to determine which background map is displayed.
The file hl2\scripts\ChapterBackgrounds.txt
associates background maps with particular game chapters. It lists all of the chapters in the game, and which background BSP file will be loaded when that chapter is unlocked by the player’s progress.
Here is the ChapterBackgrounds.txt
for Half-Life 2:
"chapters" { 1 "background01" 2 "background01" 3 "background02" 4 "background02" 5 "background03" 6 "background03" 7 "background04" 8 "background04" 9 "background05" 9a "background05" 10 "background06" 11 "background06" 12 "background07" 13 "background07" }
hl2\scripts\ChapterBackgrounds\titles.txt
contains the chapter key values. A key value is created for each chapter in the game. These key values are put into the “Chapter Title Message” key in the Map Properties (also called worldspawn) under the Map Menu in the Hammer editor. The actual text that shows up for each chapter depends upon the language chosen, in these files:
hl2\resource\hl2_english.txt hl2\resource\hl2_french.txt hl2\resource\hl2_german.txt ...
These files contain the actual chapter name text in various languages. The text entered here will be the text that is displayed in-game wherever chapter names appear.
Проверка файла chapterbackgrounds.txt
Как только вы внесли изменения в файл chapterbackgrounds.txt
, вы можете проверить фоновые карты, использую переменную консоли sv_unlockchapters
. Эта команда отвечает за то, какие главы игры вы уже прошли, и содержит номер той главы, фоновую карту которой вы хотите посмотреть.
Чтобы выбрать фоновую карту главы, надо:
- Сохранить файл
chapterbackgrounds.txt
со сделанными изменениями в папку<mod directory>\scripts
. - Запустить игру
- Открыть консоль разработчиков
- Ввести "sv_unlockchapters n", где n номер фоновой карты в файле
chapterbackgrounds.txt
, которую вы хотите посмотреть. - Ввести
quit
, чтобы выйти из игры. - Перезапустить игру, и тогда отобразится выбранная карта.

sv_unlockchapters
сохраняется в файле настройки config.cfg
, и вы можете его изменять как вам угодно. Для игры Half-Life 2, этот файл находится в \half-life 2\hl2\cfg\config.cfg
и может быть открыт в любом текстовом редакторе.Замена фоновых карт Half-Life 2
Если вы хотите заменить стандартные фоновые карты Half-Life 2 своими, просто создайте фоновую карту и материалы с таким же именем, и замените название карты для определённой главы своим. Имена фоновых карт Half-Life 2 есть в файле chapterbackgrounds.txt
:
"chapters" { 1 "background01" 2 "background01" 3 "background02" 4 "background02" 5 "background03" 6 "background03" 7 "background04" 8 "background04" 9 "background05" 9a "background05" 10 "background06" 11 "background06" 12 "background07" 13 "background07" }
Например, если вы хотите заменить первую фоновую карту, просто назовите вашу карту background01
. Чтобы заменить фоновую карту главы 10, переименуйте вашу карту в background06
Отмена загрузки фоновых карт
Если вы хотите использовать для фона текстуру (без загрузки карты), просто создайте файл \cfg\valve.rc
и добавьте следующие строки:
// load the base configuration // пер: загрузка обычной конфигурации //exec default.cfg // Setup custom controller // пер: настройки устройств ввода(джойстик) exec joystick.cfg // run a user script file if present // пер: запуск пользовательского скрипта, если он существует exec autoexec.cfg // // stuff command line statements // пер: выдать параметры командной строки // stuffcmds
Если вы хотите включить загрузку фоновых карт, просто добавьте команду startupmenu
в файл valve.rc