#Example1 This is a tutorial on how to write properly functioning triggers. This only deals with the actual trigger body, the statements that the trigger will execute. This does not explain the use of the "header", such as the Trig Narg, Trig Args, Trigger Name, etc. All of that is explained in other documents. As this tutorial assumes you know how to fill in the header fields properly, you should review the other documents first if you do not feel completely comfortable with them. The trigger statements will be preceded by a ']', which is the prompt the editor shows you. Obviously, you do not type this into each statement! *** #Example2 First, we will create a trigger that will allow the mob to greet the player. To simply greet everyone who enters, set up a greet mtrigger, and put: ] wait 1 ] say hello ] wait 2s ] wave into the trigger body. The mob will say 'hello', wait 2 seconds, and then wave. Easy. *** #Example3 Next, we will perform slightly different actions, depending on the player's sex: ] if %actor.sex% == male ] say Hey dude. ] elseif %actor.sex% == female ] whistle %actor.name% ] else ] talk %actor.name% I don't know what sex you are! ] endif This if statement performs one action if the actor is male, one if the actor is female, and another if it is neither. The 'endif' is always required at the end of an if statement. *** #Example4 Now, we will cause a room to cast a spell upon a person who enters, as long as that person is between level 10 and 30, and then announce the person's race to everyone in the room. This will be done with an Enter Wtrigger: ] if %actor.level% >= 10 && %actor.level% <= 30 ] wsend %actor% A strange spell is suddenly cast upon you! ] wechoaround %actor% A strange spell is cast upon %actor.shortdesc%! ] if %actor.class% == warrior ] dg_cast 'blindness' %actor.name% ] elseif %actor.class% == mage ] dg_cast 'sanctuary' %actor.name% ] else ] dg_cast 'insanity' %actor.name% ] endif ] wechoaround %actor% %actor.shortdesc% the %actor.race% has entered. ] endif This spell first checks if the level is between 10 and 30. Wsend sends the message to the actor, wechoaround sends the message to everyone BUT the actor. %actor.shortdesc% should always be used when echoing the name. If, for example, you have a mob called 'an ogre guard', the shortdesc will be 'an ogre guard'. The %actor.name% will be a list of names you can refer to that ogre as, such as 'guard ogre huge'. dg_cast is a way of generically casting any spell upon a victim, no matter if the caster is a room, an object or a mob. Last, the two endif's close out the two previous if's. *** #Example5 Let's pick a random number between 1 and 3, and make a mob do something different depending on which number we get. This will be another Greet Mtrigger: ] wait 1s ] set number %random.1 3% ] if %number% == 1 ] emote suddenly floats high above the ground! ] dg_set self position floating ] elseif %number% == 2 ] wait until 0500 ] stretch ] say It's dawn now! ] elseif %number% == 3 ] if %self.has(26)% ] say I have an object with vnum 26! ] elseif %self.eq(26)% ] say I'm wearing an object with vnum 26! ] endif ] endif ] detach The second line, SET, shows how you can set a variable (number) to any value you wish, in this case, a random number between 1 and 3. The first choice, 1, sets the mobile to a floating position. The second choice, 2, causes the mobile to wait until 0500, which is 5:00am, stretch, and then announce that it is dawn. The third choice checks the mobile's inventory and equipment for an object with vnum 26. The final statement detaches the trigger from the mobile, so that it will never be executed on that mobile again. *** #Example6 Next, the locate command is explained, which is one of the most useful commands with triggers. This is also on a mob's Greet Mtrigger: ] if %direction% != west ] halt ] endif ] wait 2s ] talk %actor.name% Watch this. ] set druid %locate.char(6001 *)% ] set room %locate.room(217)% ] mteleport %druid% %room% ] dg_door %room.number% north state close lock The first 'if' statement makes it so if the player walks into the room from any direction except west, the trigger does not run. The next segment, starting with the SET command, sets a variable called 'druid' to be a mob with vnum 6001. The '*' says to look throughout the entire world for the mob. The next command sets a variable 'room' to be room 217, and the next command teleports the druid into that specific room. The last command is a way of opening and closing doors. The syntax is explained in the trigcmds file, but basically this command closes and locks the northern door in room #217. ***