De/Level Transition (Portal 2): Difference between revisions
Line 76: | Line 76: | ||
(Diese Methode kann erweitert werden um eine Vernetzung wie im Spiel zu erstellen. Schau dir mp_coop_transition_list.nut an für Inspirationen.) | (Diese Methode kann erweitert werden um eine Vernetzung wie im Spiel zu erstellen. Schau dir mp_coop_transition_list.nut an für Inspirationen.) | ||
= | =Einzelspielermodus= | ||
Der Einzelspielermodus ist ähnlich. | |||
== | ==Modified transition manager== | ||
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. | 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. | ||
Revision as of 17:03, 23 May 2012
Coop
Hier ist ein Weg um Test-Raum-Sequenzen für Coop-Kapmagnen zu erstellen.
Erstelle deine Map
Um zu beginnen Erstelle eine Coop-Map. Nun füge eine func_instance hinzu und ändere die VMF Datei zu instances/coop/coop_lighting_ents.vmf. (Das einzige was wir in ihr verwenden ist point_servercommand.)
Modifiziertes Endlevel
Die Ende-des-Levels Einheit befindet sich in der instances/coop/coop_endlevel_room.vmf Instanz und beinhaltet die Funktion, die Map zu beenden.
In einem kleinen Raum in dieser Map findest Du ein logic_script genannt transition_script. (Du kannst den Find Entities Befehl nutzen um es auszuwählen.) Du wirst sehen, dass seine Entity Scripts Eigenschaft auf debug_scripts/mp_coop_transition_list.nut gestellt ist.
Verändere nicht diese Datei! Sie ist Teil von Portal 2 und Du willst sie in GLaDOS Namen nicht anfassen. Verändere stattdessen die Entity Scripts Eigenschaft um auf eine Map deiner Wahl zu verweisen-- z.B. debug_scripts/my_mp_coop_transition_list.nut. Jetzt speichere die Map.
Gehe zurück zu deinem Coop Level, wähle die func_instance aus, die deinen Endlevel Raum beinhaltet, und editiere die VMF Datei um auf deine modifizierte Version zu verweisen.
Modifiziertes Script
Gehe jetzt zu scripts/vscripts/debugscripts in der Portal 2 Installation und erstelle dieses script. (Erneut, verändere in GLaDOS Namen nicht das Valve script.) Alles was Du wirklich brauchst sieht so aus:
// Map order
MapPlayOrder<- [
"mp_coop_easiest",
"mp_coop_easiest_two"
]
function TransitionFromMap()
{
local nextmap = -2
// Loop through maps
foreach( index, map in MapPlayOrder )
{
if( GetMapName() == MapPlayOrder[index] )
{
// This is the map we're on
nextmap = -1
}
else
{
if (nextmap == -1)
{
// This is the first map past that one
nextmap = index
}
}
}
printl( "nextmap = " + nextmap )
if (nextmap > 0)
{
// We found a map; go to it
EntFire( "@command", "command", "changelevel " + MapPlayOrder[nextmap], 1.0 )
}
else
{
// No map found; we're done
EntFire( "@command", "command", "disconnect", 2.0 )
}
}
Das obere Feld, MapPlayOrder, ist deine geordnete Map-Liste. (Für diejenigen unter Euch die mit der Programmiersprache Squirrel nicht vertraut sind, beachtet bitte, dass jede map in Anführungszeichen gesetzt wird und es muss ein Komma zwischen jede map gesetzt werden. Die letzte map bekommt kein Komma... und vergesst nicht die letzte eckige Klammer!)
Um nach deiner Map zur Lobby zu kommen, füge "mp_coop_lobby_2" als letzte map in der Liste hinzu (MapPlayOrder).
Testen
Erstelle deine coop maps und nutze deinen modifizierten Endlevel Raum anstelle des vorgegebenen. Compiliere sie alle.
Jetzt kannst Du deine maps testen. Lade einfach die erste Map und spiel sie. Wenn Du an ihrem Ende angelangt bist, wird Portal 2 zur nächsten map wechseln. Sobald Du am Ende der Liste angekommen bist wirst Du einfach zum Hauptmenü zurückkehren.
(Diese Methode kann erweitert werden um eine Vernetzung wie im Spiel zu erstellen. Schau dir mp_coop_transition_list.nut an für Inspirationen.)
Einzelspielermodus
Der Einzelspielermodus ist ähnlich.
Modified transition manager
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.
Modified script
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!)
Compile and test
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.