Ru/Level Transition (Portal 2): Difference between revisions

From Valve Developer Community
< Ru
Jump to navigation Jump to search
Line 79: Line 79:


=Одиночный режим=
=Одиночный режим=
The single-player case is similar.   
В одиночном режиме все примерно так же.   


==Изменение переходного уровня==
==Изменение переходного уровня==

Revision as of 07:56, 20 December 2013

Template:Otherlang2

Кооперативный режим

Здесь описано создание последовательности тестовых камер для кооперативного режима.

Создание карты

Во-первых, создайте кооперативную карту. Добавьте экземпляр func_instance, задав его файл VMF на instances/coop/coop_lighting_ents.vmf. (All we're using is the point_servercommand inside.)

Изменение Endlevel

Логика конца карты находится в экземпляре instances/coop/coop_endlevel_room.vmf. Загрузите эту карту в Hammer и сохраните ее как копию-- например, my_coop_endlevel_room.vmf.

В маленькой комнатке в этой карте есть logic_script под именем transition_script. (Для его выбора можете воспользоваться командой поиска энтити (Find Entities).) Его свойству Entity Scripts задано значение debug_scripts/mp_coop_transition_list.nut.

Не изменяйте этот файл! Это часть Portal 2, и трогать его не следует. Вместо этого в свойстве Entity Scripts укажите свой собственный скрипт-- например, debug_scripts/my_mp_coop_transition_list.nut. Затем сохраните карту.

Вернитесь в свой кооперативный уровень, выберите func_instance, содержащий комнату конца уровня, и отредактируйте его файл VMF, чтобы он ссылался на измененный вами файл.

Изменение скрипта

Теперь перейдите в scripts/vscripts/debugscripts в папке установки Portal 2 и создайте этот скрипт. (Не трогайте скрипт Valve.) Вам потребуется что-то вроде этого:

// Порядок карт
MapPlayOrder<- [
"mp_coop_easiest",
"mp_coop_easiest_two"
]

function TransitionFromMap()
{	
	local nextmap = -2
	
	// Прокручивание карт
	foreach( index, map in MapPlayOrder )
	{
		if( GetMapName() == MapPlayOrder[index] )
		{
			// Это карта, в которой мы сейчас находимся
			nextmap = -1
		}
		else 
		{
			if (nextmap == -1)
			{
				// Первая карта, идущая после этой
				nextmap = index
			}
		}
	}
		
	printl( "nextmap = " + nextmap )
		
	if (nextmap > 0)
	{
		// Найдена карта; переходим к ней
		EntFire( "@command", "command", "changelevel " + MapPlayOrder[nextmap], 1.0 )
	}
	else
	{
		// Карта не найдена; больше ничего нет, заврешение
		EntFire( "@command", "command", "disconnect", 2.0 )
	}
}

Верхний массив, MapPlayOrder, это список ваших карт по порядку. (Тем, кто не знаком с Squirrel, следует иметь в виду, что каждая карта заключается в кавычки, между картами должны стоять запятые. То есть после последней карты запятая не ставится. И не забудьте поставить закрывающую скобку!)

Чтобы после прохождения карт возвращаться в распределитель, добавьте "mp_coop_lobby_2" как последнюю карту в списке (MapPlayOrder).

Проверка

Создайте еще несколько кооперативных карт с использованием своей измененной комнаты конца уровня вместо стандартной. Скомпилируйте все карты.

Теперь вы можете проверить свои карты. Просто загрузите первую карту и сыграйте в нее. По достижении её конца Portal 2 переключится на следующую карту. А в конце последней карты произойдет выход в главное меню.

(Также можно добавить Распределитель как в игре. См. mp_coop_transition_list.nut.)

Одиночный режим

В одиночном режиме все примерно так же.

Изменение переходного уровня

In single player, the end-of-level logic lives in the func_instance arrival_departure_transition_ents.vmf in the maps/instances/transitions folder. Load this map in Hammer and save it under another name, such as my_arrival_departure_transition_ents.vmf.

Within this instance, the smallest room contains a logic_script named @transition_Script. Its Script Entity property points to transitions/sp_transition_list.nut.

Don't modify that file. Instead, point the property to a copy of your own, e.g. transitions/my_sp_transition_list.nut.

While you're here, you might optionally change the game_text named @end_of_playtest_text to display a line of text after the last map. Just change the Message Text property.

Save your modified VMF file.

Изменение скрипта

There is a lot going on inside this script, and undoubtedly a much simpler version would do for a simple series of testchambers. However, here's the minimum you must do.

Look for the list of maps and search for "demo_paint", the last map in the file. Add your maps after this. (Again, map names are in quotes, and there's a comma afterward except for the last map. And don't lose the final bracket.)

The result should look like this:

// ---------------------------------------------------
// 	Demo files
// ---------------------------------------------------
"demo_intro",
"demo_underground",
"demo_paint",

// ---------------------------------------------------
// 	Your title
// ---------------------------------------------------
"your_first_level",
"your_second_level"
]

The actual logic to change maps is in TransitionFromMap. To make Portal 2 exit to the main menu after displaying the end text, look for these lines

		EntFire( "end_of_playtest_text", "display", 0 )
		EntFire( "@end_of_playtest_text", "display", 0 )

and add this line after them:

		EntFire( "@command", "Command", "disconnect", 2.0 )

Save the file. (Again, you're saving your modified copy of this .nut file-- don't overwrite the Valve file!)

Компиляция и проверка

Make and compile the additional maps. You can now go back to your first map and run it from Hammer; Portal 2 will load and put you into your first map. When you get to the end it'll run the next map from the script, and exit to the main menu when all are done.