Cube initial orientation AND respawnability [PeTI editor]
Now, as outlined in my guidelines, it is really difficult to make sure that your cube can never be destroyed and/or made impossible to retrieve.
Yet, sometimes, particularly when making lessons where you want the player to see that something special happens when the cube is oriented a certain way, you must have an initial orientation for the cube.
What if you could respawn your initially-oriented cube if it happens to be destroyed?
Well, turns out that this feature was surprisingly simple to add.
Just edit your editoritems.txt (found under Portal 2/portal2_dlc2/scripts). Find the line that says: "Type" "ITEM_CUBE". Scroll down until you find a line that says "TargetName". Below that line, add the following lines:
// ADDED BY BISQWIT
"Outputs"
{
"CONNECTION_STANDARD"
{
"Activate" "instance:cube;OnFizzled"
"Deactivate" "instance:cube;OnFizzled"
}
}
// ADDED BY BISQWIT
"ConnectionPoints"
{
// left
"Point"
{
"Dir" "1 0 0"
"Pos" "1 3 0"
"SignageOffset" "0 2 0"
"Priority" "0"
}
"Point"
{
"Dir" "1 0 0"
"Pos" "1 4 0"
"SignageOffset" "0 5 0"
"Priority" "0"
}
// right
"Point"
{
"Dir" "-1 0 0"
"Pos" "6 3 0"
"SignageOffset" "7 2 0"
"Priority" "0"
}
"Point"
{
"Dir" "-1 0 0"
"Pos" "6 4 0"
"SignageOffset" "7 5 0"
"Priority" "0"
}
// up
"Point"
{
"Dir" "0 1 0"
"Pos" "3 1 0"
"SignageOffset" "2 0 0"
"Priority" "0"
}
"Point"
{
"Dir" "0 1 0"
"Pos" "4 1 0"
"SignageOffset" "5 0 0"
"Priority" "0"
}
// down
"Point"
{
"Dir" "0 -1 0"
"Pos" "3 6 0"
"SignageOffset" "2 7 0"
"Priority" "0"
}
"Point"
{
"Dir" "0 -1 0"
"Pos" "4 6 0"
"SignageOffset" "5 7 0"
"Priority" "0"
}
}
Restart Portal 2. Now you can draw a signal line from a cube into any element that you wish to activate when the cube is fizzled. First rightclick the cube, select "Connect to", and select the target element. (The order of clicking is important.) Signage points are provided, but you will probably want to hide signages because they do not really make sense with a cube that can be picked up and moved. The signage will not move.
Now, if you want your cube to be respawned, follow these instructions:
- Create a cube without dropper. Orient it as you want.
- Create a dropper that does not drop the first cube automatically. Connect the cube into the dropper.
Done!
You can now even respawn the cube somewhere completely other than where it first appeared. Or you can create a puzzle where the door opens when the cube is fizzled. Possibilities are endless.
In the first chamber where I used this I made GLaDOS say "Cheater!" when the cube is fizzled, because it is not supposed to be possible to fizzle the cube by accident (it is still possible to do it intentionally with practice).
Note: When the cube is fizzled, the signal is activated and immediately deactivated. It will not keep a door open. It will not turn a laser on except for a blink of eye. If you want the signal to be kept on, you must either create a logic latch that sustains the signal, or remove the "Deactivate" line above.
First, add these lines in your editoritems.txt, in the same location as the previous edit:
"Inputs"
{
"CONNECTION_STANDARD"
{
"Activate" "instance:cube;FireUser1"
}
}
Next, edit the following five files in sdk_content/maps/instances/p2editor/ :
cube_standard.vmf cube_companion.vmf cube_reflection.vmf cube_monster.vmf cube_sphere.vmf
Users of mods may also want to do the same in p2editor_clean, p2editor_old, and so on.
Important: You must edit these files with a text editor that does not shit itself when it encounters escape characters. I personally use Joe. I'm not sure if Notepad works here or not.
In each of the files, repeat the following procedure:
- Find "OnFizzled". If the line above or below it does not contain "Dissolve", duplicate that line, and change the following things on the copy of the line: "Fizzled" into "User1", "proxy" into "!self", and "ProxyRelay" into "Dissolve"- Find "func_instance_io_proxy". If you do not see a section named "connections" about three lines below that, add one. It reads like follows, BUT you must replace all * with the ESC character. For each *, remove it and copypaste the ESC character (which may look like an arrow, or an inverse bracket, or a square) from the "OnFizzled" line you found earlier in the file:
connections
{
"OnProxyRelay" "cube?*FireUser1**??0*?-1"
}
Now you will be able to put a signal into a dropperless cube that fizzles it. Note that you must first connect the signal into the source element, and then into the cube. Doing it other way will make the cube into the sender of the signal when it dies.
Remember to remove the antline!
TIP: If you make a button that fizzles the cube and the cube triggers a dropper when fizzling, here's how you can make intuitive antlines to illustrate the cause and effect.
- Create a LOGIC OR element (from BEEMOD).
- Connect the cube into the LOGIC OR element.
- Connect the button into both the cube and the LOGIC OR element.
- Connect the LOGIC OR element into the dropper.
- Set the first cube and the dropper into "hide antlines". This will make sure the only antline that remains is the one from button into LOGIC OR element.
- Place the LOGIC OR element inside the dropper.
So, but, yeah... Would anyone know how to make this work with turrets? Added this code to the Turret section allows for turrets to be connected, but not for them to activate anything upon destruction. It is also not clear if it would work only on destruction or, preferably, on turret collapse/deactivation as well.