Page 1 of 1

Triggers on stairs

Posted: Fri Mar 21, 2008 6:57 pm
by Parallax
I get an error message when exiting a staircase that has a trigger on it. I think DSB is complaining that the trigger was deactivated when the party moved but had not been activated in the first place. It might have something to do with stairs not being activated when the party is teleported onto them (since this would create an infinite telportation loop when going either up or down stairs), but I cannot be sure. Also, this happened with a DDM.33b-created dungeon, if it matters, which I would guess doesn't, although I might be wrong.

Posted: Fri Mar 21, 2008 7:18 pm
by Sophia
You're right as to the cause. The game disables all triggers before a set of stairs is used. This was the simplest behavior, but it might be too simplistic, such as in this case-- I'd assuming you were expecting the trigger to be activated.

One thing we could do would be to modify the stairs so that instead of turning off triggers in general, they'd simply deactivate the destination stairs, and then reactivate them. The problem is that this would require yet another hack, as normally the party is "scooped up" by a teleporter activating underneath it.

What a mess. :shock: :wink:

Posted: Fri Mar 21, 2008 7:58 pm
by Parallax
I did expect the trigger to be activated by the party's arrival, and I'm not exactly sure it was not, I would have to test this again. It happened while I was debugging something else last night and I just made a mental note of bringing it up but I have not tested it extensively.

Funny story. Did you know that, if you place a pit and a stairs up on the same tile, the party will climb the stairs then fall in the pit (don't ask me how! :shock: ) repeatedly until everyone is dead? There seems to be no way to escape that pit loop. That one was easy to fix: there shouldn't have been a pit on that tile. :)

Posted: Fri Mar 21, 2008 10:06 pm
by Sophia
I don't think the trigger would get activated. DSB globally deactivates triggers when stairs are used, to prevent a loop. Truthfully, putting a trigger on stairs to do something when you use those stairs is kind of a mess the way DSB is currently built.

It seems like it might work better to change the code so that stairs themselves support the full range of options that you can give a trigger-- they'll be able to, if the proper "opby" is set, pass a message to a target or call a function. Fortunately, I think (I can't test it right this minute) this is a very easy fix. Just change the beginning of base_stairs (found at line 444 of base/triggers.lua) to:

Code: Select all

function base_stairs(self, id, what)

	-- These are the new lines
	if (is_opby(id, what, 0)) then
		got_triggered(id, what)
	end
	-- End of new lines

	if (what) then
	    local arch = dsb_find_arch(what)
	    
	    if (arch.type == "THING") then
One caveat is this code doesn't include any sort of "trigger counting." Constant weight and the like won't work, and dropping multiple opbys will set it off multiple times. On the other hand, it's stairs, so it doesn't seem like you'd need it.

If you wanted a trigger to activate at the destination (that is, the party appears on the square and trips that trigger) that... is more difficult.

Posted: Fri Mar 21, 2008 10:16 pm
by Parallax
Sophia wrote:If you wanted a trigger to activate at the destination (that is, the party appears on the square and trips that trigger) that... is more difficult.
Yup, that's what I wanted, but I guess I can just move my trigger to the base of the stairs since that will get triggered now, right?

One great thing about making stairs typical triggers is that they don't have to be no-monster zones anymore. If monsters can activate them then they can chase the party over multiple levels! :twisted:

Posted: Fri Mar 21, 2008 10:22 pm
by Sophia
Parallax wrote:I guess I can just move my trigger to the base of the stairs since that will get triggered now, right?
Right. :)
Parallax wrote:One great thing about making stairs typical triggers is that they don't have to be no-monster zones anymore.
Yes, right now monsters won't even try to use stairs because of the line "no_monsters=true" in the declaration of "stairsup" and "stairsdown" in objects.lua. You could disable this but the current normal stairs code is set to check for insts of type "THING" and only allow those to use the stairs... someone (you? me?) would have to change this too...