Detaching triggers
- Sascha
-
Topic Author
- Offline
- Elite Member
-
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.
- thomas
-
- Offline
- Administrator
-
- Posts: 751
- Thank you received: 143
What do you see in zedit in this room?
Please Log in or Create an account to join the conversation.
- Sascha
-
Topic Author
- Offline
- Elite Member
-
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.
- thomas
-
- Offline
- Administrator
-
- Posts: 751
- Thank you received: 143
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
Please Log in or Create an account to join the conversation.
- Sascha
-
Topic Author
- Offline
- Elite Member
-
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
-
Topic Author
- Offline
- Elite Member
-
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.
- Parnassus
- Offline
- Administrator
-
- Posts: 366
- Thank you received: 54
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.
- WhiskyTest
-
- Offline
- Platinum Member
-
- Posts: 345
- Thank you received: 73
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.
- Parnassus
- Offline
- Administrator
-
- Posts: 366
- Thank you received: 54
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.
- WhiskyTest
-
- Offline
- Platinum Member
-
- Posts: 345
- Thank you received: 73
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.
- Parnassus
- Offline
- Administrator
-
- Posts: 366
- Thank you received: 54
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
-
Topic Author
- Offline
- Elite Member
-
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.
- WhiskyTest
-
- Offline
- Platinum Member
-
- Posts: 345
- Thank you received: 73
Please Log in or Create an account to join the conversation.