Please or Register to create posts and topics.

Making a portal-activated button?

I'm looking for a way to have a button activate when a portal is shot at it. This is different to a trigger_portal_detector: whereas the detector detects a portal opening within its volume, I need something that will detect that a player has shot at a button with the portal gun. For my purposes, I don't actually need portals in the puzzle at all, just something to use as a "pointer" weapon. An alternative would be to use the ping tool, but I don't know if it's possible to get that working in single player (unless you were to start the map up with ss_map and set ss_force_primary_fullscreen to 1?).

Anyway, my current setup to achieve this in single player works well for single-shot buttons: I have a portal-sized func_brush textured with nodraw_portalable, and a trigger_portal_detector that encloses it. I also have an invisible trigger_portal_cleanser that encompasses the map (awkward, and requires that the puzzle being made doesn't utilise portals other than to press these buttons, but that's fine for the moment). When I fire a portal (from the blue-only portal gun) at the surface, the portal detector detects the portal, enables the fizzler for 0.01 seconds to kill it, then disables itself and the nodraw brush (I'm planning on adding useful outputs to map logic etc. as and when I insert these prefabs into my map). However, when I re-enable the surface and detector again, the detector still sees the portal as being on the surface and immediately shuts off the button again. If I place a portal on a different wall surface and then re-enable the button it works fine.

Does anyone know of a better way to do this? Maybe scripting? If it's not possible I guess I'd need to look into starting the map like a co-op with ss_map, and then hiding the second player's screen so that the first player can play through as if it were a single-player map, just with the ping tool as well.

I do not have the time right now (I'm at work) to make a complex suggest, but i remember reading on another thread, where some guy wanted a wall to break as soon as the player looks at it.

And so i remember about a OnFire-Output.

I thought of combining those two into an if-and-if-formula, where the player needs to look at the button (like the breaking wall) and then press fire.

If both booleans equal 'true' the button activates. (using a logic_relay)

I'm not sure about the right Output to use for the "If the player presses left or right mouse-button", beceause I'm fairly new to mapping myself, but i hope this post was of some use anyway.

Maybe some more experienced mapper could pop out the deatils. (this sounds badass'ly lazy of me, sry)

I'm pretty experienced in mapping (5 years or so), but I've never come across an entity that checks whether or not the player is firing. It sounds like something only the source code has access to.

What I've done for now is go with the ping method: I've locked player 2 in a dark room and had the map start up as co-op with local splitscreen but had the player 1 screen take priority over the monitor. That way, the map plays like a single player map but you've only got one of the two characters, and the player can use the ping tool (which considerably lessens the complexity of creating a point-and-click button as it can be placed on pretty much any surface).

The only other thing I'm having problems with at the moment is getting an entity to use a think function (which I've never dealt with before): I've made a script as follows and have pointed a logic_script to it, along with specifying "PortalGunTracerThink()" as the think function. What I'm eventually aiming to do is to have the player's view monitored and draw a traceline every think to see if it points to a ping button. If it does, I'll activate a relevant sprite where the button is. Unfortunately it doesn't look as though there's a function in Portal 2 to get the player's view angles (even though you can get the eye co-ords), so I was wanting to test by outputting the raw player angles to see if the Z changed with your aim.

Code: Select all
function PortalGunInitialFindPlayer()
{
   // Find player 1 via the model (this is how it was done in L4D2, I'm assuning the same restrictions apply).
   printl("Finding player...");
   Player <- Entities.FindByModel(null, "models/player/ballbot/ballbot.mdl");
}

function PortalGunTracerThink()
{
   if ( Player == null ) return;   // Don't do anything if the player has not been found yet.
   
   PlayerEyes <- Player.EyePosition();   // Store the eye position of the player.
   PlayerAngles <- Player.GetAngles();   // Store the angle of the player.   // NOTE: Will the z angle ever change? Ideally I need the view angles. D:
   
   printl("Eye position: " + PlayerEyes + ", Angles: " + PlayerAngles);
}

No matter what I do, the console always says the entity failed to execute the think function, and that's it. No more description, which is annoying.

You could try using an game_ui that detects when the player presses ATTACK1 (primary fire or FIREPORTAL1) while inside a trigger_look with it's look target is set to the button. That way we know that the player is both firing a portal and looking at the button at the same time (which consequently means that the player is firing at the button).

This would probably need to incorporate some kind of logic_branches which are set to one when one of the parameters are met and when both are true: your event is triggered.

You can activate the ui without actually limiting the player to freeze on it; so this is a good way to track player's commands.

EDIT: Also for your think problem, the name of it should have no "()" when referencing it in the entities' value 'think function'. Think() should not be process heavy as it is executed every so many milliseconds. I would have set the parameters globally in the main function and then changing their values to the player's angles etc.

?????????????????????????????TWP Releases | My Workshop