Working with Instances

Avatar
msleeper
4,136 Posts
Admin
Posted May 13, 2011
Has anybody figured out the proper way to use the Departure Elevator instance and making the map either transition to another map, or to just close altogether? I'm thinking about faking it using some well placed triggers along the path of the departure elevator, but I'd like to not have to use hacky shit as much as possible.

EDIT
Read further down the thread, I have done some testing and have gotten a pretty okay grasp on things. I also uploaded an example/demo/hilarious map I made messing around with this. Use this as an example on how to do transitions with the stock instances.

Good Enough For Science (Instance Example + VMF)
Gel Spawner - Instance Example + VMF
Button + Dropper Instance Example + VMF

Advertisement
Registered users don’t see ads! Register now!
Avatar
MrTwoVideoCards
584 Posts
Posted May 13, 2011
Replied 34 minutes later
I think you should be able to drop it in, and then specify the next level in the landmark entity. If you need to edit the instance though you could collapse it. I don't really know though, I haven't implemented any level changes yet, but I'm pretty sure thats how it works. I think they have a trigger at the bottom of the elevator shaft that fades out an env_fade, then just loads the next map. They don't have to worry about transitioning to the next levels exact geometry like in Hl2 for example, so it should be pretty straightforward.
Avatar
msleeper
4,136 Posts
Admin
Posted May 13, 2011
Replied 11 minutes later
It looks like there is an instance called "instances/transitions/arrival_departure_transition_ents.vmf" that handles all of it - level loading and map ending/fading, and it assumes you have elevators - but it has a lot of static stuff like some end-map text that I haven't figured out how to change yet. I'm really trying to avoid collapsing instances if at all possible, since it looks like Valve never had to. At least not in their example maps.
Avatar
msleeper
4,136 Posts
Admin
Posted May 13, 2011
Replied 2 hours later
Okay so far it looks like all you need to do to get functioning elevators with transitions is to place these 5 instances in your map:

instances/turbine_elevator/arrival_elevator_(your choice)_base.vmf
instances/turbine_elevator/arrival_elevator_logic.vmf

instances/turbine_elevator/departure_elevator_(your choice)_base.vmf
instances/turbine_elevator/departure_elevator_logic.vmf

instances/turbine_elevator/transitions/arrival_departure_transition_ents.vmf

The arrival and departure "base" instances have a few options, be sure you use the correct set. The "a4" are the Wheatley ones, so the elevator goes upwards in those and the elevator room isn't destroyed. If you are looking for the 1940's Aperture ones, they are in "tube_elevator" and they work just the same. You want the two actual instance entities to be in the same location, the "base" and "logic" instances are built to overlap on each other.

The arrival_departure_transition_ents.vmf is what handles the meat of getting these to actually work. You must have this instance in your map if you are using one or both instance elevators. There are individual instaces for the arrival and the departure, but I don't think they are supposed to be used independently.

There are some quirks, though. Your Portalgun upgrade and the end map text is all handled outside of the entities in a vscript. It kind of sucks. Right now I'm trying to make my own version of the arrival_departure_transition_ents.vmf instance to handle this on my own, but I think ideally it would be best to use a custom vscript so you don't have to fuck with the instances.

Avatar
Sidneys1
89 Posts
Posted May 13, 2011
Replied 1 hour later
^That should be on the VDC.
Avatar
msleeper
4,136 Posts
Admin
Posted May 13, 2011
Replied 1 minute later
As soon as I can lay down some more mad science on how this shit works, I'm probably going to put it up there.

EDIT
Example/test/hilarious map I made messing around with this. Use this as an example on how to do transitions with the stock instances.

Good Enough For Science (Instance Example + VMF)

Avatar
msleeper
4,136 Posts
Admin
Posted May 14, 2011
Replied 23 hours later
So me and Cassata were playing around with some more Instances tonight. I used the Gel instance because it requires direct I/O interaction to use - whereas the ones I used previously didn't really require anything beyond plopping them into a map.

There are a couple of article on the VDC about instances (one, two) the second of which is written with L4D2 in mind but the concepts stay the same. Sadly there does not appear to be a ton of information about Instances, so I'm hoping to be able to expand on that once I myself have a more firm grasp of things.

Anyway, what you need to know in this example is that you can rename or "Replace" certain fields in an instance from within your map VMF. Within your instances, anything that is given a value that begins with a $ symbol grants the ability to be Replaced. The example that is given in the articles I linked is using $color in an instance, to allow your map to alter the color of an object. In the case of the Gel spawners, there are two Replacement fields - $trigger_to_start and $trigger_to_stop. In this particular case, these correspond to the names of two separate logic_relays, one that turns on the gel flow and another that turns of off.

It's important to know how sub-entities within an instance are renamed, when it is required that they are named. Part of this is handled in the func_instance in your map itself. Since our two logic_relays in our instance are named Replace-able fields (since they start with a $ symbol), giving them a name allows our map to interact with the logic entities within the actual instance.

That said, you need to understand how the renaming behavior works before you can actually target these logic entities from any I/O Outputs. The option "Entity Name Fix Up", which is at default to "Prefix", controls this behavior. Using the default "Prefix", and assuming you have given the entity it's own unique name in the "Fix Up Name" (which, for all intents and purposes, is the targetname of the instance), the new name of any entity within an instance is renamed to: (value of your map's func_instance "Fix Up Name")-(name of the entity in the instance)

It gets more complicated when, in this Paint example, we actually Replace the name of the logic_relays. So instead of the name of the entity, the name of the logic_relays is whatever we set in the Replace fields in the func_instance.

So, assuming we named the instance "test" and we Replaced $trigger_to_start to "start" and Replaced $trigger_to_stop to "stop", the name of the logic_relays that controls the starting and stopping will be called: test-start and test-stop

Still with me? Good. At this point, it's just a matter of very basic logic I/O. I setup a switch that sends a ToggleTest to a logic_case, which then either triggers test-start or test-stop during the OnTrue or OnFalse Outputs respectively. Keep in mind that, because the entities are not technically in your map in Hammer, the I/O links will appear red. This is fine, things should work properly in-game.

I know this is kind of insane to read and it's like 5:30am so I'm sure I wrote this pretty retarded and over complex. But here it is, and here's the example, and I'll be happy to help anyone with questions.

Gel Spawner - Instance Example + VMF

Avatar
p0rtalplayer
1,366 Posts
Posted May 14, 2011
Replied 6 hours later
On a related note, the way valve does it is they have the outputs set up like so:

OnWhatever | Instance_fixupname | instance:entitywithin;input

It's more complicated and I have no idea why they'd do that over the way msleeper explained but I just thought I'd mention it.

Avatar
Supervillain
34 Posts
Posted May 14, 2011
Replied 1 hour later
ahh! This is awesome work. Should give me something to chew on for the weekend.
Avatar
msleeper
4,136 Posts
Admin
Posted May 14, 2011
Replied 3 hours later
p0rtalplayer - I think it actually depends on what the instance is doing. Take a look at the first VMF I posted and the button there does that. I think the fact that the logic_relays are Replace'd is what means you have to do it this way. More testing required.
Avatar
Stylus
50 Posts
Posted May 14, 2011
Replied 1 hour later
I'm really impressed with instances!! When i first found out about them I was confused a lot since i didn't really understand anything but the basic idea of it. so this is going to save up a lot of time + i'm learning something new which is always a good feeling.

Thanks for going trough all this trouble and then sharing this with us msleeper. :notworthy:

Avatar
WinstonSmith
940 Posts
Posted May 14, 2011
Replied 3 hours later
Alright, if you don't mind msleeper I'm going to go ahead and sticky this, simply because it's such a crucial part of Portal 2 mapping and there's a heck of a lot of good info here. My guess is that if we don't sticky it we'll get a lot of "how do I make instances work" threads.
Avatar
msleeper
4,136 Posts
Admin
Posted May 14, 2011
Replied 11 minutes later
Fine by me. I put it in my signature since I think it's pretty important. Right now it's just some random musings by me, I was going to write up a more proper article once I have some more solid information.
Avatar
WinstonSmith
940 Posts
Posted May 14, 2011
Replied 1 hour later

msleeper wrote:
Fine by me. I put it in my signature since I think it's pretty important. Right now it's just some random musings by me, I was going to write up a more proper article once I have some more solid information.

Pretty good for random musings. Anyway, I've started cataloguing the instances on the VDC page that lists them. As of now I've only gotten the animated_panels done, but I'm working on more.

Avatar
Hurricaaane
189 Posts
Posted May 15, 2011
Replied 19 hours later
I'm not sure if this does any sense but...

From my own conclusions, I've put down this when working with instances:

Whenever I should connect two instances together, in Hammer without doing anything hacky:

do:

connect Instance(ex:Button) output to Relay
connect Relay output to Instance(ex:Door)

don't:

connect Instance(ex:Button) output to Instance(ex:Door)

From my own conclusions, an instance's outputs shall never be directed directly into another's instance inputs, otherwise you'd have to edit a lot of dirty things into the inputs and outputs manually.

By the way, it allows to keep things clean, for example if at anytime you want all the puzzle elements from the map to just stop from working normally (example: end of map, simulated bug, player breaking the puzzle so you want to open the door manually), you just need to perform operations on the relays and they will react for you.

Avatar
MrTwoVideoCards
584 Posts
Posted May 15, 2011
Replied 17 minutes later
Instancing is still confusing the fuck out of me. I'm gradually graduating from plopping in instances that function on their own,to instances I/O I'd have to manually edit.

I'll wait for some write-ups on the VDC and whatnot, but I am glad you guys are figuring out. This is something again that is extremely useful, and valve hardly bothers to document.

On a somewhat related note, instances are completely broken on any engine previous to Left 4 Dead 2, which really blows. I started getting instances working for my mod, only to find out that VBSP doesn't collapse the instances like it should be doing, not to mention that func_instance_params doesn't even work properly. I can still use instancing for things like working with geometry, and basic prefab like functioning, but I though I'd mention this if anyone might also be working on other older engines (TF2, HL2). Sad stuff.

This is funny/sad because func_instance is in the FGD's for these games, and are supported within Hammer.

Avatar
msleeper
4,136 Posts
Admin
Posted May 15, 2011
Replied 4 hours later

Hurricaaane wrote:
From my own conclusions, an instance's outputs shall never be directed directly into another's instance inputs, otherwise you'd have to edit a lot of dirty things into the inputs and outputs manually.

Not true it seems, at least in some instances. One thing I did find out making this example is that any Instance that is going to send an Input must have a name - even if it itself is never going to receive an Output. Not that I am at all trying to advocate not using logic_relays, if the instance calls for it then there it appears you are able to directly send I/O from one instance to another.

Avatar
reepblue
894 Posts
Posted May 16, 2011
Replied 58 minutes later
I'm planning on making a how to/info post on my blog about instancing communication with pictures and junk. If I get the time tomorrow, I will work on it.
Avatar
Joni
6 Posts
Posted May 16, 2011
Replied 10 hours later
When i try to make a instance in my map, it jst shows the normal small cube, not the elevator. Anyone seen something familiar?
Joni

EDIT: Fixed, had to save the map first

Advertisement
Registered users don’t see ads! Register now!
Avatar
Mr. Happy
61 Posts
Posted May 16, 2011
Replied 2 hours later

reepblue wrote:
I'm planning on making a how to/info post on my blog about instancing communication with pictures and junk. If I get the time tomorrow, I will work on it.

Are you sure about this?