Please or Register to create posts and topics.

Cube initial orientation AND respawnability [PeTI editor]

One of the biggest annoyances in the PeTI editor so far has been that if you want your Discouragement Redirection Cube to have an initial orientation, you can't have it respawn. And if you want it to respawn, you can't have an initial orientation for the cube.

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:

Code: Select all
         // 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.

If you want to make it possible to remotely fizzle dropperless cubes, it is also possible without adding extra entities, but it involves a bit more work than the above.

First, add these lines in your editoritems.txt, in the same location as the previous edit:

Code: Select all
                        "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:
    Code: Select all
       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.

Nice idea! I'll add this into my FG Droppers, all cubes from them have an output for being fizzled already (to tell the dropper to respawn 'em).

Falsi sumus crusto!

RESURRECTION!

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.

Turrets don't have very nice outputs for this, so it's a bit difficult to tell when they die - dropping them in goo is basically undetectable. A bit of a warning: I've tried adding connections to cubes, and it has caused the editor to crash if you place them in certain locations (on top of glass, mid-air, etc.)

My stuff:
[spoiler]- BEE2 Addons | (BEE2)
- Hammer Addons
Maps:
- Crushed Gel
- Gel is Not Always Helpful[/spoiler]

That's all right, I suppose. It wasn't essential to the strategy, but rather just for added flair or story element. I should probably try and pull away from that idea (especially when limited to the PeTI editor), but it occurs to me that attempted to tell some kind of story is what I'm interested in more-so than the actual puzzles themselves... Thanks, anyway. I'll figure something out.