Tips and Tricks

Setup on the MUD's Builder Port and wanna talk about your area or ask questions? Come here to get juicy details!
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Tips and Tricks

Post by Gatz »

Post whatever general tips and tricks you may have for people building on NarutoMUD.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Below is a link to Herne's Guide to Building SMAUG. If you ever want to serious build, use this guide like a bible. I still turn back to this whenever I have a question. It is the only thing I used to learn how to build and it will teach you everything you could ever want to know.

http://www.realmsofdespair.com/smaug/herne/smaug/olc-resources.html

Small disclaimer...the guide doesn't sync perfectly with NarutoMUD. However, it is about 95% accurate to us, there are only a couple additions and subtractions here and there, but for general info it can't be beaten.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

If you have access to the switch command, use it to help debug any weird errors!

Syntax: switch <character>
Syntax: return

SWITCH switches you into the body of another character (who must not
already have a descriptor, e.g. you can't switch into a PC).

RETURN returns you to your original body.


This puts you in an NPC and lets you see everything they see. So, if you botch the syntax on a command, they'll see that message. This can be great if you're trying to use an mp command that doesn't seem to be working right.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Make sure your all your special Immortal channels are on! There are many, many helpful errors that will be through when your progs mess up, but you'll never see them if they're turned off. Check out the channel command to make sure all your channels are enabled.

Since this is the builder port, you shouldn't see role play or anything else that can happen on the game port. There is no reason not to enable everything.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Using + at the end of a line will make the next line append on to it. This is needed because in a prog, 1 line is 1 statement. Using this, you won't have to do what some MUDs have to do:

say Hello $n, welcome to my lab!
say I am a mad scientist who loves to build.
say I like to watch grass grow and eat Playdoh.
say Don't worry about me, I'll be fine.


It'll become this:
say Hello $n, welcome to my lab!+
I am a mad scientist who loves to build.+
I like to watch grass grow and eat Playdoh.+
Don't worry about me, I'll be fine.


You should only use the first thing if you want to space out what his says with mpsleeps to add delays between them. Also, the cool thing about using + (append) is it automatically adds it in for you for prog creation! However, if you need to edit a specific line, just be mindful of them and what they do.

So, if you have to delete line 2 of a prog which is this:
say I like meat balls a lot!+
Do you?
smile


It'll become
say I like meat balls a lot!+
smile


And will display to players as:
Billy says, "I like meat balls a lot! smile"


This functionality, I feel, is a strong point in making what could be a very verbose block of say's into a more fluid and human like way it would be said.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

MPsleep is your friend! Use it whenever you want to add some spice to your progs!

A simple example of this is as follows:
emote looks up at you.
mpsleep 9
say Oh, I almost didn't see you there.
mpsleep 4
cough
mpsleep 4
say Sorry, I'm coming down with a cold.


The syntax for mpsleep is as follows:
mpsleep # (Where # is number of beats to wait)

9 beats = ~1 second.


Use mpsleep anytime you want to add a delay in a prog. However, realize that mpsleep pauses the NPC and not anyone else in the room. So, players can move around during this time and if you do anything that targets them in a room, they may be gone by then.

One of my favorite uses of mpsleep in NarutoMUD is the ferrymen, they are completely prog driven via mpsleep. If it was all just one giant spammed thing, it would lose a lot of character.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Use the silent keyword for progs! From silent's helpfile:

Syntax: Silent

This is a command used for Building areas, its specific function is to
suppress output sent to players. With this keyword, any command won't show
output, except bug messages.

Examples:
silent mpforce $n remove all
silent say Only NPCs will see this!


One of the many uses of silent is that it can be used to have NPCs trigger other progs either on themselves or on others. That way, NPCs with a lot of logic checks, maybe a quest giver of some kind, can have each individual portion put into it's own prog and it makes it a lot easier to read.

Below is an example:
speech prog p I am ready.
if level($n) > 10
silent say Level greater 10.
else
silent say level less than 10.
endif

speech prog p level greater 10.
say Ah, you're ready to go!

speech prog p level less than 10.
say You need to train more!



While the above example is simple, imagine expanding it out to someone like the Uchuukage who has 100s of lines in his progs. It is much easier to read, debug and fix small sections rather than large ones. Also note the above example does no checking to see who or what triggered that speech prog, in a real world example there would need to be a little more logic, but for this tip, that is a bit much to go into.
Gatz Seijuro,
Owner of NarutoMUD
zetsuke
General Browser
Posts: 18
Joined: Wed Oct 14, 2009 3:32 pm

Re: Tips and Tricks

Post by zetsuke »

When you start building, make sure you turn on config +olddesc. If you don't, you probably won't see the last line of your room descriptions when you write them.
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Use qbits and abits! The helpfile for them is here:

http://narutofor.us/help.php/?file=qbit

Simply put, they are flags for setting things on players. We use them primarily for quests, but they can be used for tons of things. Any time you want a "true/false" like value to be shared across progs, use a qbit or abit. A special note, qbits are saved to a player's pfile, while an abit is not so when a player logs out, their abits that are set are removed. NPCs -can not- get qbits set on them, but they can get an abit set.

Below is a very basic example of a quest driven via qbits:

Before the below prog can fire, we have to first create a qbit. Simply put, the game needs to know some basic info about a qbit before it can use it. We do so as follow:

Code: Select all

setqbit 10 Sandwich quest
setqbit 11 Sandwich quest complete
setabit 10 Tomato
setabit 11 Lettuce


Don't be scared off by the numbers, they could be any number. The game simply uses a number to refer to them later, we typically only use numbers that are tied to the room. For example, if the NPC's VNUM was 123, you'd probably want to use qbit 123 just to make it obvious who that qbit is used by.

Code: Select all

speech prog I want to get you a sandwich!
say Thanks for wanting to make me a sandwich, fetch me a tomato and lettuce!
mpqset $n 3100


With the above code, all progs can see that this player has begun our sandwich quest. So, we'll assume the tomato and lettuce items have been created and you have to give each one to the NPC before this quest is done. The script to do that prog is below.

Code: Select all

give prog gives you a tomato.
  if hasqbit($n) == 10
    if hasabit($n) != 10
      say This looks delicious! Thanks, I can't wait to eat my sandwich!
      mpaset $n 10
    else
      say You already gave me a tomato, I don't need another.
    endif
  else
   say Why are you giving me a tomato? I never asked you to make me a sandwich.
  endif


To break down the above prog, we first check if we gave them a qbit, remember in this instance our qbit represents the quest has begun. Since some players might just give the tomato to him without starting the quest, we want to tell them they get nothing out that. However, if they have the qbit, which means they started our quest, we next need to see if they already gave the NPC the tomato. Now there are a lot of ways to handle this portion of the quest in scripting, but I choose this way to show off abits and qbits. I'll leave it up to the reader to research alternatives to this.

Next, I'm going to gloss over the script to do the lettuce, as it will be exactly the same with the say messages changed and the numbers for the abit changed. So, on to the part to finish the quest.

Code: Select all

speech prog You have all the ingredients.
  if hasqbit($n) == 10
    if hasabit($n) == 10
      if hasabit($n) == 11
        say Yum! You're the best!
        smile $n
        mpqset $n 11
      else
        say I need lettuce!
      endif
    else
      say I still need my tomato!
    endif
  endif


That is basically it, now the player is marked with qbit 11, which says they are finished. What is missing is blocking them from doing this quest again, which all that would take is a check if they had qbit 11. Also, instead of setting the abit on the player, you could have set it on the NPC, this would have meant that 2 players could go out and 1 could get a tomato and the other lettuce. As long as they both had qbit 10, they could have given the NPC the respective items towards completing the quest and they could could have finished it.

With this simple example, I hope you can see how chaining this together can make it so you can have a very interesting quest, or provide any extra special information for NPCs. The other application I like is this:

Code: Select all

entry prog
  if hasqbit($n) == 11
    say Oh hey! My brother told me you made him a sandwich, I want one too!
  else
    say Hi, I haven't seen you around before.
  endif


Disclaimer, the spaces added in the code blocks are not needed, but for displaying them on the forum I hoped it would aid in its visibility.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

MPjunk and MPpurge are your friends, but without using them carefully can be loaded guns!
Syntax: MPJUNK <name>

Destroys an object in inventory/being worn - can be used with all.object .


Syntax: MPPURGE <object/mobile>

Purges the room, or a specified object/mobile.
-----------------------------------------------------------

SYNTAX: mppurge
mppurge <item name>
mppurge <mob name>

DESCRIPTION: The MPPURGE mpcommand works much like the
immortal command PURGE, but for one exception:
there must be something to purge. If there is
nothing to be purged, the command will log a bug.

-----------------------------------------------------------


Both commands do approximately the same thing, however mppurge is the bigger hammer of the two. When you want an NPC to get rid of an item in his inventory, use mpjunk. When you want to get rid of things in a room, use mppurge. Make sure if you ever use mppurge that you're very careful with the name you use.

Also realize, an NPC can't purge itself. So, if you want to do a prog where an NPC is purged from the room, you can't place that in the room.

An example:

Code: Select all

speech prog I got you now!
say You'll never take me alive!
mppurge robber


The above code will throw errors and will not work. To do the above correctly, one possibility is using the room to purge him, like so:

NPC's script

Code: Select all

speech prog I got you now!
say You'll never take me alive!


Room's script

Code: Select all

speech prog You'll never take me alive!
if isnpc($n)
  if mobcount(10) > 1
    mppurge robber
  endif
endif


Don't be scared by the room's script, all it is doing is seeing if the person who said that line is an NPC, and also if our NPC we want to purge exists in the room, in this example his vnum is 10. Here we still want to be careful about using the correct name for the purge, however.

Using mpjunk and mppurge correctly might be a little scary at first, but it becomes vital to use and pretty simply to understand once you get the a basic grasp of it.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Yuuta
Ninja Trainee
Ninja Trainee
Posts: 31
Joined: Sun Jun 27, 2010 5:30 am

Re: Tips and Tricks

Post by Yuuta »

Gatz wrote:NPC's script

Code: Select all

speech prog I got you now!
say You'll never take me alive!


Room's script

Code: Select all

speech prog You'll never take me alive!
if isnpc($n)
  if mobcount(10) > 1
    mppurge robber
  endif
endif


Don't be scared by the room's script, all it is doing is seeing if the person who said that line is an NPC, and also if our NPC we want to purge exists in the room, in this example his vnum is 10. Here we still want to be careful about using the correct name for the purge, however.

Using mpjunk and mppurge correctly might be a little scary at first, but it becomes vital to use and pretty simply to understand once you get the a basic grasp of it.


Would it not be better to have the command mppurge $n? If it is merely mppurge "robber", would it not purge the first robber in the room, regardless of whether it was the one who spoke the line? This would cause problems if there were more than one robber in the room and, let's say, this was a command to be used right before death (at < 10% hp). If the robber would say its line every round of combat, then the room would quickly begin purging robbers that have nothing to do with the mob who originally spoke. Is using $n to define the target of a script impossible?
Daizaburo
General Browser
Posts: 19
Joined: Mon Oct 26, 2009 5:22 pm

Re: Tips and Tricks

Post by Daizaburo »

Yuuta wrote:Would it not be better to have the command mppurge $n? If it is merely mppurge "robber", would it not purge the first robber in the room, regardless of whether it was the one who spoke the line? This would cause problems if there were more than one robber in the room and, let's say, this was a command to be used right before death (at < 10% hp). If the robber would say its line every round of combat, then the room would quickly begin purging robbers that have nothing to do with the mob who originally spoke. Is using $n to define the target of a script impossible?

That is a valid point, Yuuta, but there's really no difference between what Gatz wrote and what you did. In this case, when the robber says his line, triggering the prog, $n does not "lock on" to the mob that actually said the line, but grabs his info and stores it in the proper variables, which makes $n=robber. Regardless of which robber actually triggered the prog, it will target the first one that came in. That's just the way SMAUG works. We just have to work with the limitations we're given. However, as long as you keep things like this in mind when you're writing the progs in your areas, there shouldn't be any problems. There are many variables available for use in progs, which are all conveniently listed in a table in Herne's. Using these allows a builder to create some truly interesting (and safe) progs.
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Understand how the "Prototype' flag works. Prototype is a special flag for NPCs, Items and Rooms. With the flag set, it makes that thing marked to be 'in development' or 'in progress'. All zones not installed default to having the prototype flag set. All items installed have their prototype flag removed.

The prototype flags changed the way non-Immortals can interact with something. For example, prototype items can't be picked up by players. The prototype flag also changes how values are set with mset or oset or redit. This changes whether or not the base values are changed or that thing's instance values are changed.

For example, say an NPC needs to have its stats changed. if it is set to be prototype then every instance of that NPC made afterwards will have those altered stats. However, if the prototype flag was not set, then that specific NPC will have the altered stats, but no other NPC of that type will have those altered stats.

With this functionality, item renames work. As we only rename that specific instance of an item, and we don't want to rename the base item itself. This same type of idea is used for clones, as well.

As good habit, never manually remove prototype flags for zones in progress. Only add or remove them when you are making changes to an installed zone. Remember to remove any prototype flags you may have set on an installed zone and re-save the area file the changed object was in.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

MPForce is an awesome command, but it has pitfalls. Below is it's helpfile.

Syntax: MPFORCE <name/all>

Forces a player/mob to do a command (non-functional on immortals, all will
only force all in room).


How can this fail? Well, mpforce doesn't just execute what you enter. It is re-sent through the game interpreter and executed. What does this mean? Imagine you have this:

Code: Select all

mpforce $n sing $n


In the prog parser (and the player who executes the prog is Gatz), it'll become:

Code: Select all

mpforce Gatz sing Gatz


Now, say we have sing as an emote and the player might see:
You sing a little tune to yourself.


However, say you wanted to force them to do something like go west. That would look like:

Code: Select all

mpforce $n west


No problem right? Well, there are cases where moving around won't work. Many commands require you to be in a certain position, like standing or sitting. Specifically, if you're drunk, then you can end up moving in the wrong direction. So, forcing them west could cause them to not do anything. Remember, mpforce acts like they typed it.

A better solution for the above problem would be to use mptrans, short for mptransfer. Transfer moves a player to another room. This might require a little more work to make it look pretty, but it'll work 100% of the time. The script to do this would be:

Code: Select all

say Flavor text of some kind, this is why I'm tossing you over here!
mptrans $n 1034
mpat $n mpforce $n look
mpat $n mea $n Bill the NPC hurls you to the west!
mpat $n mer $n Bill the NPC hurls $n into the room, ouch!
mpat $n say And stay out!


Don't get too blown away by the above example. When a player is moved via mptransfer, the new room they go to they don't auto-look. If you're trying to make a puzzle or maze, this can pay off, but for this prog we want players to know they got moved. However, the NPC executing this script is in the old room. This is where mpat comes in. Mpat will temporarily move an NPC to the target, which can be a room's vnum or a N/PC, and execute whatever command you have given.

Also, we want players in the room to know what just happened, this is where mer and mea come into place. Those commands are short for mpechoat and mpechoaround. Going over those is best served for later, but this is very handy because the target player sees mea and everyone but the target sees mer.

Don't be scared to use mpforce to add some spice to progs, just be cautious about what things you are forcing players to do. Especially if you try to force a player to give an NPC an item, as you need to check if that NPC actually got the item right after the force.
Gatz Seijuro,
Owner of NarutoMUD
User avatar
Gatz
Site Admin
Posts: 547
Joined: Sun Nov 27, 2005 3:29 pm

Re: Tips and Tricks

Post by Gatz »

Add flavor to your NPCs with random progs! A random prog is easy to do and can add life to a character. Let's set the stage for construction of a simple NPC with a little pep.

Pretend you're creating a bustling city. What kind of city would it be without NPCs wandering around? Now, if you just invoke 400 instances of "generic city person" it will be dull. What you can do is create a couple different kinds of city people to spruce p the town. For this quick example, we'll talk about three different ones listed below:

Businessman
Female Shopper
Male Photographer


For the Businessman, we won't make him too deep, but just add a little flavor to him as he walks around.

Code: Select all

add random 50
if rand(50)
emote looks at his watch.
gasp
say I'm late for a meeting!
else
emote phone starts to ring.
mpsleep 2
wear phone
say Yeah?
mpsleep 2
say Oh God...
mpsleep 2
say No...tell him I'll call him back later.
mpsleep 2
emote hangs up the phone.
mpsleep 2
remove phone
mpsleep 4
say Idiots.
endif


What a mouthful! The random prog means that every tickle there is an X percent chance that prog will fire. In this case, we did 50, but normally you'd set it very low to not spam everyone. Next, I use the if rand if check which will say out a X chance, will this be true or false. I didn't need to provide an else and I could have chained many together for more options. However, I decided to give this guy two different phrases.

Next, our female shopper. She will wander around looking for great deals.

Code: Select all

add rand 5
say Hrm....
if inroom($i) == 1234
say Wow! Look at all those deals!
endif


This prog checks if the NPC executing the script is in room 1234, lets say we made room 1234 a shop. Now, as that NPC is wandering around, if it happens to go into this room, they could say that line.

Lastly, we do a male photographer.

Code: Select all

add rand 70
if sex($n) == 2
say Wow, pretty lady! Let me take your photograph!
mea $n Photographer Man takes photos of you obnoxiously!
mea $n Photography Man is taking photos of $n!
else
say Can you move out of the way of my shot?
endif


I saved this for last because I'm sure if you are keeping score, you're going to ask: "How can a random prog have someone to fire it?" I will then smile at you and say, because only PCs can trigger them. When a PC is not in a room, an NPC will not fire their random progs, ever. On a tick, every PC in the room has a chance to trigger a rand prog on an NPC. This can be a blessing and a curse. If you use my above examples verbatim, you'll end up with a lot of screen spam.

How can you avoid this? Easy, use a lot more mer or mea tags to target only one person, or get clever and use an abit tag to let the NPC know it is already in that prog and it doesn't need to fire it again. There are some cases where you want everyone in the room to get the prog activated on them, and the good news is you can always re-use the same abit across all your progs to mark an NPC in their rand prog.

It can be easy once you get it, but at first it might seem confusing. Keep trying them out and you'll be a rand-pro!
Gatz Seijuro,
Owner of NarutoMUD
Post Reply