Trigger only if door is open (closed)

Tutorials and discussions about Mapping - Introduce your own ones!
Post Reply
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Trigger only if door is open (closed)

Post by Barbie »

I'm looking for a trigger system that triggers a door only if it is open - and another Trigger, that does this in opposite.
Imagine a door (Mover.InitialState=TriggerToggle) with two triggers on each side. If player has passed the open door to inside, the door should close. If a player comes from outside and the door is closed, it should open.
I already tried that with enabling/disabling the triggers, but that had end up in a dead lock with multiple players.
Top view:

Code: Select all

-------------
        | D |
Trigger | o | Trigger
        | o |
        | r |
-------------
(If there is no easy solution with stock stuff, of course I can code such a trigger.)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Hellkeeper
Inhuman
Posts: 905
Joined: Tue Feb 25, 2014 12:32 pm
Personal rank: Soulless Automaton
Location: France
Contact:

Re: Trigger only if door is open (closed)

Post by Hellkeeper »

Barbie wrote:I already tried that with enabling/disabling the triggers, but that had end up in a dead lock with multiple players.
You could to this but instead of deactivating/activating triggers, attach them to small movers that take them out of the way (ie: in the ground) when they need to be deactivated and send them back to their place when they are activated.
You must construct additional pylons.
Chris
Experienced
Posts: 134
Joined: Mon Nov 24, 2014 9:27 am

Re: Trigger only if door is open (closed)

Post by Chris »

Why not just make two small custom triggers that does exactly this and mylevel them?

Code: Select all

function Touch( actor Other )
{
	local actor A;
	if( IsRelevant( Other ) )
	{
		if ( ReTriggerDelay > 0 )
		{
			if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay )
				return;
			TriggerTime = Level.TimeSeconds;
		}
		// Broadcast the Trigger message to all matching actors.
		if( Event != '' )
			foreach AllActors( class 'Actor', A, Event )
                        {
                                if(Mover(A) != None)
                                {
                                         //if( <-- CloseOpened/OpenClosed -->) Either make one custom trigger and just add an enum or bool to set the trigger mode or make two custom triggers, each with its mode hardcoded ) 
                                         if(Mover(A).bOpening) //if mover is opening, and you wish to close it.
				                  A.Trigger( Other, Other.Instigator );
                                         if(!Mover(A).bOpening) //If mover is not opening, and you wish to open it.
                                                  A.Trigger( Other, Other.Instigator ); 
                                }
                        }

		if ( Other.IsA('Pawn') && (Pawn(Other).SpecialGoal == self) )
			Pawn(Other).SpecialGoal = None;
				
		if( Message != "" )
			// Send a string message to the toucher.
			Other.Instigator.ClientMessage( Message );

		if( bTriggerOnceOnly )
			// Ignore future touches.
			SetCollision(False);
		else if ( RepeatTriggerTime > 0 )
			SetTimer(RepeatTriggerTime, false);
	}
}
Customize the code as you need
Terraniux
Masterful
Posts: 717
Joined: Mon Jan 05, 2009 8:08 pm
Personal rank: Banished member

Re: Trigger only if door is open (closed)

Post by Terraniux »

I think I know the solution to that problem. You can use a normal or just a elevator mover. So normally this would be in combination with a button, but lets say that the trigger in the players way is the actual 'button'. Place them on both sides of the door. Solved. :) Because the door does only give a reaction when it is triggered :). And the only way for the game to check if the door is open/closed is to check which keynumber it is positioned into.
This member can only post when permitted.
Red_Fist
Godlike
Posts: 2164
Joined: Sun Oct 05, 2008 3:31 am

Re: Trigger only if door is open (closed)

Post by Red_Fist »

The total mover time and stay open time must match a trigger delay time. per mover-door.

Save you a lot of confusion setting it up.
Binary Space Partitioning
User avatar
Barbie
Godlike
Posts: 2802
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Trigger only if door is open (closed)

Post by Barbie »

I should emphasize that both triggers should only do that what I've described and not more; e.g. the Trigger that opens the door should not close it and vice versa. It is like a trap: once the player has passed the (open) door, the door should close and cannot be opened from that side. If player dies or another player wants to pass the door into the trap, the door must be opened, if it is closed.
What not may happen is that the door is closed and the outside Trigger for opening it is disabled, because this will break the game flow.

I think I've found a setup that should run also with multiple players, chain of events raised by "TriggerDoorCloser" for closing the door is
1) Disable "TriggerDoorCloser" (Trigger1)
2) Trigger the door (move time=0.5s)
3) sleep 1s
4) Enable "TriggerDoorOpener" (Trigger0)
and vice versa for Trigger "TriggerDoorOpener".
TrapDoorTriggers.jpg
Setup in T3D

Code: Select all

Begin Actor Class=Trigger Name=Trigger0
    bInitiallyActive=False
    ReTriggerDelay=1
    InitialState=OtherTriggerToggles
    Tag=TriggerDoorOpener
    Event=ToggleDoor
End Actor

Begin Actor Class=Trigger Name=Trigger1
    bInitiallyActive=True
    ReTriggerDelay=1
    InitialState=OtherTriggerToggles
    Tag=TriggerDoorCloser
    Event=ToggleDoor
End Actor

Begin Actor Class=RoundRobin Name=RoundRobin0
    OutEvents(0)=DoorClose
    OutEvents(1)=DoorOpen
    bLoop=True
    Tag=ToggleDoor
End Actor

Begin Actor Class=Dispatcher Name=Dispatcher0
    OutEvents(0)=TriggerDoorOpener
    OutEvents(1)=Door
    OutEvents(2)=TriggerDoorCloser
    OutDelays(2)=1
    Tag=DoorOpen
End Actor

Begin Actor Class=Dispatcher Name=Dispatcher1
    OutEvents(0)=TriggerDoorCloser
    OutEvents(1)=Door
    OutEvents(2)=TriggerDoorOpener
    OutDelays(2)=1
    Tag=DoorClose
End Actor

Begin Actor Class=Mover Name=Mover3
    MoverEncroachType=ME_IgnoreWhenEncroach
    WorldRaytraceKey=1
    MoveTime=0.5
    InitialState=TriggerToggle
    Tag=Door
End Actor
Test map attached. I run it with 2 Bots and was not able to create a dead lock.
<EDIT>
Setup was wired, corrected it.
</EDIT>
Attachments
TestTrapDoor.7z
Map for testing a trap door setup
(4.68 KiB) Downloaded 52 times
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6410
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: Trigger only if door is open (closed)

Post by sektor2111 »

This is fun but I always do simple:
TriggerControl with a single trigger, exactly like in Coret. Door Opens - Door Closes faster.
The only problem is at PawnProximity - a gasbag killed with door open will ruin door - something is nasty bugged at pawns fliers toward "UnTrigger/UnTouch" when they die - probably I have a bad orientation and fixing is simple as usual.
I have a mod/mutator solution which is pretty operational until this moment using a false door controlling real door and sanitized. I did not check it for huge doors because there might be nasty depending on door speed...
Post Reply