bTriggerOnceOnly in state TriggerToggle

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

bTriggerOnceOnly in state TriggerToggle

Post by Barbie »

Taken from this thread:
Aldebaran wrote:Another map from Thunderbolt is MH-TB-JumpingToSpace2011, afaik the monster hunt end is not reachable (I think the door won't open?) even if all monsters are dead. Is that fixable in a similar way?
The problem in that map is that the event for the final door can be fired twice: first with Counter0 (105 existing monsters) and secondly by Counter1 (81 Gasbags produced by ThingFactory0, which can be activated by a player with Trigger21).
The final door (Mover26) has set InitialState=TriggerToggle and bTriggerOnceOnly=True. I expect that 99 of 100 people think that bTriggerOnceOnly means bTriggerOnceOnly - but this value is ignored in state TriggerToggle (see also that state in Wiki).

Fix: Change Mover26.InitialState to TriggerOpenTimed - that state respects the value of bTriggerOnceOnly.

<EDIT>
I mixed up TriggerControl and TriggerToggle - the latter is what I meant. I changed above and the subject accordingly.
</EDIT>
Last edited by Barbie on Sun Aug 20, 2017 11:35 pm, edited 1 time in total.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: bTriggerOnceOnly in state TriggerControl

Post by sektor2111 »

Usually this heads to an Engine.Mover error and mover mainly might stay open hanging with a Toucher vanished without calling UnTrigger- depends on situation, of course. Indeed this is dumb setup. These movers are always TriggerOpenTimed with bTriggerOnceOnly. I've done mods switching the movers like that with no issues. You should do the same if you want to recover some maps from dust. Even doors open by dispatchers with the same setup are doing sucks - switching them will make them nice. Other normal doors types TriggerControl for creatures are developing errors when creature is killed in trigger's radius. I've done something for this case - works for majority of normal maps and MH as well. Install an actor tracker for these doors and let it handle mover when gets triggered. Else it might be checking while door is open if something is still in certain radius, and then close door if nothing stays there.
Barbie wrote: but this value is ignored in state TriggerControl (see also that state in Wiki).
False - Apology for ruining Wiki spree but Wiki has some troubles as I can see so far... I think I was talking about these movers already... Perhaps Wiki has to be fixed too.
Nothing is more easy than checking code directly

Code: Select all

state() TriggerControl
{
	function bool HandleDoor(pawn Other)
	{
		return HandleTriggerDoor(Other);
	}

	function Trigger( actor Other, pawn EventInstigator )
	{
		numTriggerEvents++;
		SavedTrigger = Other;
		Instigator = EventInstigator;
		if ( SavedTrigger != None )
			SavedTrigger.BeginEvent();
		GotoState( 'TriggerControl', 'Open' );
	}
	function UnTrigger( actor Other, pawn EventInstigator )
	{
		numTriggerEvents--;
		if ( numTriggerEvents <=0 )
		{
			numTriggerEvents = 0;
			SavedTrigger = Other;
			Instigator = EventInstigator;
			SavedTrigger.BeginEvent();
			GotoState( 'TriggerControl', 'Close' );
		}
	}

	function BeginState()
	{
		numTriggerEvents = 0;
	}

Open:
	if ( DelayTime > 0 )
	{
		bDelaying = true;
		Sleep(DelayTime);
	}
	DoOpen();
	FinishInterpolation();
	FinishedOpening();
	SavedTrigger.EndEvent();
	if( bTriggerOnceOnly ) //Myth burned and buried
		GotoState(''); //like that - it simply changes itself to a NON STATE
	Stop;
Close:		
	DoClose();
	FinishInterpolation();
	FinishedClosing();
}
Yeah, like that... mover goes borked when doesn't have EventInstigator - which is Pawn not a crap, then reaction is unexpected around an Accessed None.
For completing stage if you want I'll setup a small map with such a mover "bTriggerOnceOnly" and you'll see what it does when gets triggered ONCE by Player. It stays open.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: bTriggerOnceOnly in state TriggerControl

Post by Barbie »

sektor2111 wrote:False
Sorry, I mixed up TriggerControl and TriggerToggle. I have corrected my above posting.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Aldebaran
Masterful
Posts: 672
Joined: Thu Jan 28, 2016 7:30 pm

Re: bTriggerOnceOnly in state TriggerToggle

Post by Aldebaran »

Thanx Barbie, your fix works here! I don't know at what trigger or monster count the door opened, but when I had at least five monsters left I could end the map.
:gj:
Red_Fist
Godlike
Posts: 2163
Joined: Sun Oct 05, 2008 3:31 am

Re: bTriggerOnceOnly in state TriggerToggle

Post by Red_Fist »

Logically if it toggles means it to go back and forth over and over. on-off-on-off

If the mover is set to trigger only once, a toggle will have no effect after the first pulse (event).
Binary Space Partitioning
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: bTriggerOnceOnly in state TriggerToggle

Post by Barbie »

Red_Fist wrote:If the mover is set to trigger only once, a toggle will have no effect after the first pulse (event).
That is what nearly everybody would expect - but that does not happen in state TriggerToggle. I'd call that also a bug...
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Red_Fist
Godlike
Posts: 2163
Joined: Sun Oct 05, 2008 3:31 am

Re: bTriggerOnceOnly in state TriggerToggle

Post by Red_Fist »

What I am saying is no one should ever use both in that combination, it makes no logical sense to begin with.

I usually set the trigger to, trigger only once, and in the mover, seems I had some problem with doing only one. I figure the trigger should never work again handing out events to something all the time.

But you have a different thing going here. (counters etc etc)
Binary Space Partitioning
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: bTriggerOnceOnly in state TriggerToggle

Post by sektor2111 »

You cannot believe what logic has a plonker said mapper. It was a counter for dispatching a message and a door. A trigger was doing ignition for a Factory but not bTriggerOnceOnly. Then each time when a player was getting into area touching trigger it was hitting counter without actually to kill creatures and opening door just by roaming repeatedly around trigger - because they don't know factory stuff and what happens in that time to creatures spawned. I could write a general patch for this sh!t into MH2 but... I don't need other iterators, I have already too much charge...
Else for above problem TriggerToggle is NOT the RIGHT setup. If supposed mover is for a single action then is not a TOGGLING one and neither under some trigger control - it's just need to be open with nothing else - baboon logic. That's "TriggerOpenTimed" - last from InitialState list - with "bTriggerOnceOnly=True" and "ME_IgnoreWhenEncroach" - no pain, no headaches.
Post Reply