Party facing and off-center tilepos triggers

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
Remy
Craftsman
Posts: 111
Joined: Wed Sep 05, 2007 5:24 pm
Contact:

Party facing and off-center tilepos triggers

Post by Remy »

I was experimenting with the new off-center tilepos triggers and testing to see if they could be implemented with party facing. It turns out they can - but only partly. They are triggered when the party enters the square, but not if they only turn on the square.

I kind of needed this feature for the Theron's Quest conversion, so I went ahead and wrote up a work-around that does that job (Trigger/Face test). To test it, just proceed south through the doors to the final room. While standing on the puddle, turn around. A wall will appear in front of the party (and disappear from where ever they aren't facing). The other rooms were tests to make sure my new code didn't break any other triggers (there's a room off to the left of the second room that also has a puddle. Place items on the corners of that tile to make pits appear at diagonals - just don't fall down them, you can't come back up).
There's also a lever in the last room that switches back to the way the 'base' code does it. I bring it up because this is one of those cases that, while it can be recoded to work, I think requires a change to the engine. If you switch back to the old mode and test it, you'll discover that it will spit errors (nothing fatal, but still errors). This is because, if the party isn't facing the direction they were when they stepped on the tile, the wrong tilepos gets 'untriggered' - in this case, that means a 'tc' error and the wall that appeared upon entering is still there (and, also, the wall that should appear doesn't).

That' probably confusing, so let me give an example. The party steps on the square facing north. The trigger at tilepos 'NORTH' triggers, and a wall appears. Then, they rotate to face east. The 'NORTH' trigger doesn't untrigger, and the 'EAST' trigger doesn't fire, either, so the walls stay the same - one to the north, none to the east. The party then steps forward, off the square. The 'EAST' trigger is untriggered, which causes an error (because it was never triggered in the first place and has a nil 'tc' exvar), and the 'NORTH' trigger doesn't, so that wall is still there (NOTE: these triggers all have 'const_weight' set so that they respond to untriggers).

Now, I realize that off-center triggers weren't really meant for 'opby_party' operations, but I'm wondering if they could be. The code rewrite I did required a 'sys_tick' override, and it's somewhat complex, so I'm not all that thrilled with it. I just couldn't find another way to do it, since there is no hook on the party turning (moving, yes, turning, no).

And, if I'm completely missing something, then someone let me know. :)
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

Remy wrote:there is no hook on the party turning
Yes there is. :D It's, rather fittingly, on_turn(direction).
It's used in standard DM so you can turn on a stairwell and you will end up on the other level, but I think this will let you do what you wanted.

I looked at your code, and I'll also point out something else useful, even if you change your approach-- you need to dsb_export any global variables you want DSB to remember, like this:

Code: Select all

dsb_export("g_last_facing")
Otherwise, they'll be uninitialized when the game is reloaded, and strange things will happen.
Remy
Craftsman
Posts: 111
Joined: Wed Sep 05, 2007 5:24 pm
Contact:

Post by Remy »

It's, rather fittingly, on_turn(direction).
You'd think I would have noticed that...
That helped -- I still use a sys_tick override to keep track of 'g_last_facing' (which is now being properly exported :oops: ), but it's shortened up the code considerably.

Thanks!
Post Reply