Detaching triggers

  • Sascha
  • Sascha's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
3 years 5 months ago #7797 by Sascha
Detaching triggers was created by Sascha
I'm wondering if I'm doing something wrong with detaching triggers? The help file says this:
Detach removes a trigger to one instance of a mob/obj/room, for testing or 
other purposes. The command only removes the trigger temporarily, until the
room/obj/mob is reloaded via reboot, zreset, load.

I have a room where after a condition is met, the trigger on the room detaches itself. That part works fine. But the trigger does not come back when the zone resets, either via the regular reset time or via zreset. The trigger only comes back if I go into redit for the room, hit S for script, and then quit out.

In this example, the trigger is in place:
[22016] Just Inside the Gate [ NO_MOB ] [ Field ][T 22099]
A sprawling encampment stretches north to northeast from inside the gate that
separates the camp from the forest outside.  A barricade surrounds the camp as
far as the eye can see, tall enough that it would give an Ogier pause before
trying to climb it.  To the south is a checkpoint in the barricade that has tall
hinged gates that look scarred from years of use.
[ Exits: n s ]

Now, the condition has been met and the trigger is detached:
[22016] Just Inside the Gate [ NO_MOB ] [ Field ]
A sprawling encampment stretches north to northeast from inside the gate that
separates the camp from the forest outside.  A barricade surrounds the camp as
far as the eye can see, tall enough that it would give an Ogier pause before
trying to climb it.  To the south is a checkpoint in the barricade that has tall
hinged gates that look scarred from years of use.
[ Exits: n s ]

But then at reset it does not come back:
510H 110M 92V > 
zpurge
Purged zone #220: Zone 220 - Tutorial - Trolloc camp setting.
[ (GC) Vivienne purged zone 220 (Zone 220 - Tutorial - Trolloc camp setting) ]

510H 110M 92V > 

The sun rises in the east.

510H 110M 92V > 
zreset
Reset zone #220: Zone 220 - Tutorial - Trolloc camp setting.
[ (GC) Vivienne reset zone 220 (Zone 220 - Tutorial - Trolloc camp setting) ]

510H 110M 92V > 
l
[22016] Just Inside the Gate [ NO_MOB ] [ Field ]
A sprawling encampment stretches north to northeast from inside the gate that
separates the camp from the forest outside.  A barricade surrounds the camp as
far as the eye can see, tall enough that it would give an Ogier pause before
trying to climb it.  To the south is a checkpoint in the barricade that has tall
hinged gates that look scarred from years of use.
[ Exits: n s ]

510H 110M 92V >

And if I go into redit it does come back:

510H 110M 92V > 
redit
-- Room number : [22016] Room zone: [220]
1) Name        : Just Inside the Gate
2) Description :
A sprawling encampment stretches north to northeast from inside the gate that
separates the camp from the forest outside.  A barricade surrounds the camp as
far as the eye can see, tall enough that it would give an Ogier pause before
trying to climb it.  To the south is a checkpoint in the barricade that has tall
hinged gates that look scarred from years of use.
3) Room flags  : NO_MOB 
4) Sector type : Field
5) Exit north  : 22008 ,  B) Exit northwest : -1
6) Exit east   : -1    ,  C) Exit northeast : -1
7) Exit south  : 22023 ,  D) Exit southeast : -1
8) Exit west   : -1    ,  E) Exit southwest : -1
9) Exit up     : -1
A) Exit down   : -1
F) Extra descriptions menu
S) Script      : Set.
W) Copy Room
X) Delete Room
Q) Quit
Enter choice : 
s
     Triggers Attached:
      1) [22099] Boss battle to escape at room 22023

 N)  Attach trigger
 X)  Detach trigger
 Q)  Quit

     Enter choice :
q
-- Room number : [22016] Room zone: [220]
1) Name        : Just Inside the Gate
2) Description :
A sprawling encampment stretches north to northeast from inside the gate that
separates the camp from the forest outside.  A barricade surrounds the camp as
far as the eye can see, tall enough that it would give an Ogier pause before
trying to climb it.  To the south is a checkpoint in the barricade that has tall
hinged gates that look scarred from years of use.
3) Room flags  : NO_MOB 
4) Sector type : Field
5) Exit north  : 22008 ,  B) Exit northwest : -1
6) Exit east   : -1    ,  C) Exit northeast : -1
7) Exit south  : 22023 ,  D) Exit southeast : -1
8) Exit west   : -1    ,  E) Exit southwest : -1
9) Exit up     : -1
A) Exit down   : -1
F) Extra descriptions menu
S) Script      : Set.
W) Copy Room
X) Delete Room
Q) Quit
Enter choice : 
q
Do you wish to save your changes? : 
y
Room saved to disk.

510H 110M 92V > 
l
[22016] Just Inside the Gate [ NO_MOB ] [ Field ][T 22099]
A sprawling encampment stretches north to northeast from inside the gate that
separates the camp from the forest outside.  A barricade surrounds the camp as
far as the eye can see, tall enough that it would give an Ogier pause before
trying to climb it.  To the south is a checkpoint in the barricade that has tall
hinged gates that look scarred from years of use.
[ Exits: n s ]

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

Please Log in or Create an account to join the conversation.

More
3 years 5 months ago #7824 by thomas
Replied by thomas on topic Detaching triggers
This might be a regression. It is supposed to reattach based on the configuration in the zone file.

What do you see in zedit in this room?

Please Log in or Create an account to join the conversation.

  • Sascha
  • Sascha's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
3 years 5 months ago #7826 by Sascha
Replied by Sascha on topic Detaching triggers
Hi Thomas,

This is what zedit shows for this room:

Room number: 22016 Room zone: 220
1) Builders : Vivienne
Z) Zone name : Zone 220 - Tutorial - Trolloc camp setting
L) Lifespan : 30 minutes
B) Bottom of zone : 22000
T) Top of zone : 22099
R) Reset Mode : Reset when no players are in zone.
F) Zone Flags : NOBITS
M) Level Range : <Not Set!>
[Command list]
0 - <END OF LIST>
N) Insert new command.
E) Edit a command.
D) Delete a command.
Q) Quit
Enter your choice :

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

Please Log in or Create an account to join the conversation.

More
3 years 5 months ago #7841 by thomas
Replied by thomas on topic Detaching triggers
I feared that was what you'd respond :)

We have two ways of attaching a trigger to a room.

Either, we attach through redit, like you do above, or through zedit, like this:
[Command list]
0 - Attach trigger  name here... [12099] to room

And, set up like this, the trigger will reattach on zone reset - after all, the list in zedit is the basis for the zone reset code.

So, the next question, can we make the other trigger reset as well? Not as easily, no.
I think we might need to add the lines to the zone file when we edit a room trigger list, and vice versa.

The point here is that the list in redit shows a snapshot, so to speak, and the snapshot is saved/loaded on reboot. The zedit list shows a preferred state to return to on zone reset. Once we remove the script attached to the room, there is no record of it ever existing until the next time we load the world files (through redit or copyover).

The "correct" way of doing it would probably be to make redit save to the same list as in zedit, before existing commands for that room, and not save scripts directly on the room.

I've created an issue on github dealing with this: github.com/tbamud/tbamud/issues/47
The following user(s) said Thank You: Sascha

Please Log in or Create an account to join the conversation.

  • Sascha
  • Sascha's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
3 years 5 months ago #7850 by Sascha
Replied by Sascha on topic Detaching triggers
Meanwhile, with this explanation and by changing affected rooms, this now works as intended. I would not have figured this out with the help files... :) Thank you, Thomas!

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

Please Log in or Create an account to join the conversation.

  • Sascha
  • Sascha's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
3 years 5 months ago #7872 by Sascha
Replied by Sascha on topic Detaching triggers
The messy problem with this is that when attaching via zedit, the trigger attaches over and over and over again. The zone had been empty overnight and this morning there were twelve of the same triggers attached to the room. Does this hurt anything? I have no idea. Sure is spammy on the eyes, though.

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

Please Log in or Create an account to join the conversation.

More
3 years 5 months ago #7895 by Parnassus
Replied by Parnassus on topic Detaching triggers
I'm not sure that triggers are meant to be zedited in as opposed to being set. Here's the problem, as I see it. A zedit is supposed to happen every time the zone resets. As a troubleshooter, I've often seen zedit problems with objects. I'm sure it happens with other things but objects are the easiest to catch. Ever walked into a room and found 50 whatevers there? The correct procedure is to remove the object and then replace the object.

Example of bad zedit:
room 27430 - Smurfville (Yes, I know you can't check this, just go with me on it)
Load blue ring [27402], Max : 120
then Load a curved dagger [27403], Max : 120
then Load a bag [27404], Max : 400
(18) [27404] A small bag is here.
(18) [27403] A curved dagger is lying here. ..It emits a faint humming sound!
(18) [27402] A small blue ring lies here. ..It emits a faint humming sound!

Example of correct zedit:
room 6424 - Rand's Tower
Remove some food [6420] from room.
Load some food [6420], Max : 10
Contents: some food

Now the problem is, there's no way to remove a trigger, only to add one in. No, I don't understand it, either. Since the detach doesn't actually remove the trigger, the zedit only adds to it, once per reset.

Would it be possible to modify the trigger into a mob or object trigger? Or would it be possible for you to post the trigger or a mockup that does the same basic thing? Since I've only used detach for testing purposes and the example of detach is an object trigger, I have no experience with it.

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #8223 by WhiskyTest
Replied by WhiskyTest on topic Detaching triggers
Would part of fixing this be to prevent adding duplicate triggers onto things?

All the different routes to add a trigger appear to go through void add_trigger() at some point, so we can add a check:
  /* Prevent trigger duplication */
  for (i = TRIGGERS(sc); i; i = i->next)
      if (GET_TRIG_VNUM(i) == GET_TRIG_VNUM(t)) {
          return;
      }

Perhaps then removing the option to add triggers using redit / medit / oedit?

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #8225 by Parnassus
Replied by Parnassus on topic Detaching triggers
I'm just going to point out that I've advised duplicating the elevator triggers anywhere the triggers are attached. I suppose though that if you were using this anti-duplication, it's probably easy enough to copy the elevator trigger to another number and then put both of them in. It detracts from the basic idea that I was only using one trigger to run the elevator but I think I stuffed in enough things that you would potentially have vnums left over for the copy.

The main limitation, as far as I can remember, is that you can look at the display and see where the elevator is but if you've pushed the button, the display disappears. This is because the trigger is already in use.

I was telling a friend about this and he asked why I didn't just add the trigger twice to each room. Of course I answered something like, (condescendingly) "Well, because you can't attach a trigger twice to the same...ro...um...why CAN'T you attach a trigger twice to the same room?"

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #8226 by WhiskyTest
Replied by WhiskyTest on topic Detaching triggers
Ok, understood.
In which case the better option is to add a command for removing triggers in zedit. Which keeps it consistent with how we'd remove mobs and objects..

Please Log in or Create an account to join the conversation.

More
2 years 11 months ago #8227 by Parnassus
Replied by Parnassus on topic Detaching triggers
Oh, I don't think you'll see many cases where a builder actually wants duplicate triggers. As you can see, I didn't think it was even possible until I tried it.

However, to overly complicate things, as I so often do, how about putting in a message...hmm, I see that I'm looking at this wrong. We're not talking about builder triggers here. We're talking about programmed triggers in which case your way is better than changing zedit since it would also work for items that might potentially have the same problem.

My original thought was that if it was code that affected building, it would be really handy to make it check the other attached triggers for same type as well as duplicate triggers since we've probably all seen builders who wonder why the five speech triggers on that mob (reflecting different words that you say to it) won't work.

In the original situation, I'd just make a mob or object, zedit it into the room, give it a load trigger to attach the trigger. I'm not sure it could check for the presence of the trigger but it could probably detach and then attach it, then purge itself. I've never tried it so I don't know if it would work but it sounds familiar. I may be thinking of a different base though. Depending on the trigger itself, there are other ways to handle it.

Personally, rather than having a way to remove the trigger in zedit, I'd prefer to remove the ability to zedit a trigger at all unless someone can describe a situation where the only way possible is to use zedit. I think that it makes more troubles than it's worth.

Please Log in or Create an account to join the conversation.

  • Sascha
  • Sascha's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
2 years 9 months ago #8286 by Sascha
Replied by Sascha on topic Detaching triggers
I'd rather have a "remove trigger" and "add trigger" kind of thing, much like we have "remove object from room" and "add object to room" setup. However, I forgot to post my solution to my original post.

I made a trigger to remove and add the other trigger at zone reset. LOL. I know, I know, it's clunky but it works!
Name: 'Death knight trigger attaches at zone reset',  VNum: [ 2277], RNum: [  889]
Trigger Intended Assignment: Rooms
Trigger Type: Zone Reset , Numeric Arg: 100, Arg list: None
Commands:
detach 2275 %self.id%
attach 2275 %self.id%

Will you stand against the coming Storm? After the Breaking: STORMRIDERS MUD - atbmud.dune.net port 4000

Please Log in or Create an account to join the conversation.

More
2 years 9 months ago #8287 by WhiskyTest
Replied by WhiskyTest on topic Detaching triggers
That is some nice lateral thinking!

Please Log in or Create an account to join the conversation.

Time to create page: 0.134 seconds