Qbits in random order

For builders to discuss and ask building questions.
Post Reply
Vibius
Sword Grand Master
Sword Grand Master
Posts: 433
Joined: Mon Nov 12, 2007 12:35 pm
Location: Waterdeep

Qbits in random order

Post by Vibius » Sun Apr 13, 2008 6:43 pm

Hello!

Could anyone check if this is right or wrong?

The idea is the following: A mob tells to burn 4 piles of wood that are in the area, these 4 piles can be burnt in whatever orden the player wishes, then the player must return to the mob.

These 4 piles are the same object and upon triggering the room intercept, the local pile of wood is burnt and the qbit is added.

First the character activates the quest:

Code: Select all

>speech_prog yes aye
if quest(0,5,$n) == 0
nod $n
sayto $n Alright, do not forgot to torch them.
mpmset $n quest 0 5 1
endif
~

Each of these progs are in a different room each one:

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,5,$n) == 1
mpmset $n quest 1 5 1
~

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,5,$n) == 1
mpmset $n quest 2 5 1
endif
~

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,5,$n) == 1
mpmset $n quest 3 5 1
endif
~

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,5,$n) == 1
mpmset $n quest 4 5 1
endif
~
And finally our happy pc returns with the mob

Code: Select all

>greet_prog 100
 if quest(0,5,$n) == 0
      sayto $n Would you like to help me?
endif

    if quest(0,5,$n) == 1
         if quest(1,5,$n) == 1
               if quest(2,5,$n) == 1
                   if quest(3,5,$n) == 1
                         if quest(4,5,$n) == 1
                               sayto $n God Job!
                                     mpmset $n quest 5 5 1
  else
          if quest(0,5,$n) == 1        
          sayto $n Please remember to finish your task!
          endif
endif
~
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Re: Qbits in random order

Post by Japcil » Sun Apr 13, 2008 9:16 pm

You are incrementing the wrong number in the mpmset $n quest I think.

Try 0 5 1, 0 5 2, etc up to I think 0 5 31? Which makes me ask if you have 32 steps in your quest?

Code: Select all

>speech_prog yes aye
    if quest(0,5,$n) == 0
    nod $n
    sayto $n Alright, do not forgot to torch them.
    mpmset $n quest 0 5 1
    endif
    ~

    Each of these progs are in a different room each one:

    >intercept_prog torch
    mpechoat $n The big pile of wood burns in a huge fire as $n torch it
    mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
    if quest(0,5,$n) > 1
    mpmset $n quest 0 5 2
    ~

    >intercept_prog torch
    mpechoat $n The big pile of wood burns in a huge fire as $n torch it
    mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
    if quest(0,5,$n) > 1
    mpmset $n quest 0 5 3
    endif
    ~

    >intercept_prog torch
    mpechoat $n The big pile of wood burns in a huge fire as $n torch it
    mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
    if quest(0,5,$n) > 1
    mpmset $n quest 0 5 4
    endif
    ~

    >intercept_prog torch
    mpechoat $n The big pile of wood burns in a huge fire as $n torch it
    mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
    if quest(0,5,$n) == 1
    mpmset $n quest 0 5 5
    endif
    ~
Now you might find it easier to make one program of the same and put it in all of the same rooms. Like this:

Code: Select all

>intercept_prog torch
  mpechoat $n The big pile of wood burns in a huge fire as $n torch it
  mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
  if quest(0,5,$n) == 1
    mpmset $n quest 0 5 2
  else
    if quest(0,5,$n) == 2
      mpmset $n quest 0 5 3
    else
      if quest(0,5,$n) == 3
        mpmset $n quest 0 5 4
      else
        if quest(0,5,$n) == 4
          mpmset $n quest 0 5 5
        endif
      endif
    endif
  endif
Image
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Re: Qbits in random order

Post by Japcil » Sun Apr 13, 2008 9:23 pm

Now for your mob:

Code: Select all

>greet_prog 100~
  if quest(0,5,$n) == 0
  sayto $n Would you like to help me?
  else
    if quest(0,5,$n) > 0
      if quest(0,5$n) == 5
        sayto $n God Job!
        mpmset $n quest 0 5 6
      else
        sayto $n Please remember to finish your task!
      endif
    endif
  endif
  ~
Now if this is the end of your quests, you need to change the 5 in all of your checks and mset quests to 3 which gives up to 8 steps. It is confusing at first, I can relate but you will get the hang of it.
Image
Vibius
Sword Grand Master
Sword Grand Master
Posts: 433
Joined: Mon Nov 12, 2007 12:35 pm
Location: Waterdeep

Re: Qbits in random order

Post by Vibius » Sun Apr 13, 2008 9:27 pm

Code: Select all

>intercept_prog torch
  mpechoat $n The big pile of wood burns in a huge fire as $n torch it
  mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
  if quest(0,5,$n) == 1
    mpmset $n quest 0 5 2
  else
    if quest(0,5,$n) == 2
      mpmset $n quest 0 5 3
    else
      if quest(0,5,$n) == 3
        mpmset $n quest 0 5 4
      else
        if quest(0,5,$n) == 4
          mpmset $n quest 0 5 5
        endif
      endif
    endif
  endif
I really appreciate your help, but I have a question. With the code above a player might torch four times in the same place and so complete the quest without searching the other piles?
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Re: Qbits in random order

Post by Japcil » Sun Apr 13, 2008 9:36 pm

You're right, I did not take that into account.

So one room with:

Code: Select all

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,3,$n) == 1
  mpmset $n quest 0 3 2
endif
The next with:

Code: Select all

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,3,$n) == 2
  mpmset $n quest 0 3 3
endif
The third with:

Code: Select all

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,3,$n) == 3
  mpmset $n quest 0 3 4
endif
The fourth with:

Code: Select all

>intercept_prog torch
mpechoat $n The big pile of wood burns in a huge fire as $n torch it
mpechoaround $n The big pile of wood burns in a huge fire as $n torchs it
if quest(0,3,$n) == 4
  mpmset $n quest 0 3 5
endif
You might wish to add else statements like: mpechoat $n You attempt to light a fire but the area is already scorched. This way the player knows they have already torched that room.
Image
Vibius
Sword Grand Master
Sword Grand Master
Posts: 433
Joined: Mon Nov 12, 2007 12:35 pm
Location: Waterdeep

Re: Qbits in random order

Post by Vibius » Sun Apr 13, 2008 9:43 pm

Forgive me once again :D

But as you have coded it, would you have to torch the piles in a fixed order?
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Re: Qbits in random order

Post by Japcil » Sun Apr 13, 2008 9:49 pm

Correct as far as I see it, you can code it so they can torch for all the bits in one room or have to go in a specific order room by room.
Image
Vibius
Sword Grand Master
Sword Grand Master
Posts: 433
Joined: Mon Nov 12, 2007 12:35 pm
Location: Waterdeep

Re: Qbits in random order

Post by Vibius » Sun Apr 13, 2008 9:56 pm

Ahhh thanks, I think I'm beginning to understand how this works. :D
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Re: Qbits in random order

Post by Dalvyn » Mon Apr 14, 2008 12:37 pm

Hi there. Here's how I would do this.

First things to remember is that objects that have the same vnum share the same programs. That means that, if you want only one object "pile of wood", your four piles of wood will have exactly the same programs. Thus, you need to check what room you are in before you can know what bit to increase.

Now, for quest bits values ... You have 31 quest bits (that can be either 0 or 1) for each area. These bits are numbered from 0 up to 32. For each quest, you use a block of quest bits. The first quest of your area could use quest bits number 0, 1, 2, and 3 for example. That's 4 quest bits, starting with quest bit number 0. That means that you will use commands like

mpmset $n quest 0 4 <value>
if quest(0,4,$n) == <value>

The 0 is the number of the first quest bit of the block, and 4 is the number of bits in the block.
Note that, when you set programs on mobiles or objects that can be moved out of the area, it's better to always indicate what area you are referring to, and use the questr forms:

mpmset $n questr QQ00 0 4 <value>
if questr(QQ00,0,4,$n) == <value>,

where QQ00 is to be replaced with the first vnum of your area.
Back to the quest. You would need different blocks of vnums. First block would be for the main quest. The stages would be:

0 - quest not started
1 - mob asked $n to light the wood and gave them a torch
2 - mob has rewarded $n, quest completed

Since we need values up to 2, we need 2 bits in the block ... let's use the first two bits, that is, bits number 0 and 1. In other words, we'll start with bit number 0 and use 2 bits, so the commands will be something like

mpmset $n quest 0 2 <value> or mpmset $n questr 0 2 <value>
if quest(0,2,$n) == <value> or if questr(QQ00,0,2,$n) == <value>

Then we'll need one bit for each pile of wood (as you found out, we would need fewer bits if the wood had to be lit in a specific order). We'll use bits number 2, 3, 4, and 5 for the piles of wood that are in rooms number QQ02, QQ03, QQ04, and QQ05 respectively.

Now, the program on the pile of wood would like:

Code: Select all

>intercept_prog torch~
if actorhasobjnum(QQ00)
  if inroom($n) == QQ02
    mpmset $n quest 2 1 1
  endif
  if inroom($n) == QQ03
    mpmset $n quest 3 1 1
  endif
  if inroom($n) == QQ04
    mpmset $n quest 4 1 1
  endif
  if inroom($n) == QQ05
    mpmset $n quest 5 1 1
  endif
  mpechoat $n {30}The big pile of wood burns in a huge fire as $n torch it.
  mpechoaround $n {30}The big pile of wood burns in a huge fire as @N torches it.
else
  mpechoat $n {30}You would need a torch to do that!
endif
~
where QQ00 is the vnum of the object "torch" given by the mob. Check the modifications I made to the two echoes (colour and @N). You might also want this program to junk the pile of wood (mpjunk $o).

How to check wether all the torches have been lit? There are two ways to do it. The first way is to check each bits individually :

Code: Select all

if quest(2,1,$n) == 1
and quest(3,1,$n) == 1
and quest(4,1,$n) == 1
and quest(5,1,$n) == 1
The other way is to consider those four bits as one block of four bits. The value 1111 is 15 in binary, so you can check for

Code: Select all

if quest(2,4,$n) == 15
for the same result.

Now, for the mobile program :

Code: Select all

>greet_prog 100~
if questr(QQ00,0,2,$n) == 0
  sayto $n Would you like to help me?
else
  if questr(QQ00,0,2,$n) == 1
    if questr(QQ00,2,4,$n) == 15
      sayto $n Good job! You have done it!
      mpmset $n questr QQ00 0 2 2
      sayto $n Here's a kiss and 5000 platinum to reward you!
      kiss $n
      mpjunk all.coins
      mpmakecash 5000 platinum
      drop platinum
    else
      sayto $n Please remember to finish your task!
    endif
  else
    sayto $n Thank you again!
  endif
endif
~

>speech_prog yes aye~
if questr(QQ00,0,2,$n) == 0
  mpmset $n questr QQ00 0 2 1
  sayto $n Take this torch and go torch the four piles of wood!
  mpoload QQ00
  give iQQ00 $n
  drop iQQ00
endif
~

>speech_prog torch~
if questr(QQ00,0,2,$n) == 1
  sayto $n What? You lost your torch and need another one?
  sayto $n I'll have to ask you 1 silver coin for it then!
endif
~

>bribe_prog 10~
if questr(QQ00,0,2,$n) == 1
  mpjunk all.coins
  mpoload QQ00
  give iQQ00 $n
  drop iQQ00
  sayto $n Don't lose that one!
endif
~
Image
Vibius
Sword Grand Master
Sword Grand Master
Posts: 433
Joined: Mon Nov 12, 2007 12:35 pm
Location: Waterdeep

Re: Qbits in random order

Post by Vibius » Tue Apr 15, 2008 4:10 pm

Thanks!

So if I had a different mob that asked for a lost figurine might this be correct?

Code: Select all

>greet_prog 100~
if level($n) > 6
     if questr(QQ00,0,6,$n) == 0
        sayto $n Oi! I have lost a figurine, will you help me retrieve it?
    end if
end if

Code: Select all

>speech_prog yes aye~
if questr(QQ00,0,6,$n) == 0
  if level($n) > 6
      mpmset $n questr QQ00 0 6 1
      sayto $n Bring me the figurine as soon you find it!
  end if
endif
~
Our wandering pc spots-takes-and deliver it
//room prog

Code: Select all

>entry_prog~
if questr(QQ00,0,6,$n) == 1
     mpechoat $n You spot a glint of gold among the garbage! 
~

Code: Select all

>intercept_prog search~
if (QQ00,0,6,$n) == 1
mpechoat $n After bending your back and start looking among the garbage you find a golden figurine that quickly you pick it from the ground
mpechoaround $n $n bends $m back and starts looking among the garbage, after some seconds $e finds a golden figurine that picks from the ground
mpgive QQ02  $n 
mpmset $n questr QQ00 0 6 2
end if
~
Finally our loving adventurer gives the figurine to the mob

Code: Select all

give_prog QQ02~
if (QQ00,0,6,$n) == 2
   mpjunk QQ02
   mpmset $n questr QQ00 0 6 3
   sayto $n Thanks! Here is a dancing lesson as reward!
   dance $n
   grin
end if
~
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Re: Qbits in random order

Post by Japcil » Tue Apr 15, 2008 6:29 pm

Well, no. Your using QQ00 0 6 #. You dont need a 6 if thats all of your steps. You could accomplish all that with a 2 instead. Here is a link to the related builder lesson: http://www.gallwey.com/fk/builders/qbitstut.php . Unless your area is full of quests and you are only writing a small portion of them you dont need to use 6.
Image
Vibius
Sword Grand Master
Sword Grand Master
Posts: 433
Joined: Mon Nov 12, 2007 12:35 pm
Location: Waterdeep

Re: Qbits in random order

Post by Vibius » Tue Apr 15, 2008 6:50 pm

Hmmm, then how you differentiate a quest from another quest?

If the last Qbit used is: mpmset $n quest 0 5 5

To check is a quest has been started or no, should I use: if quest(5, 2, $n) == 0 ?

(assuming my quest has 4 stages)
User avatar
Japcil
Sword Grand Master
Sword Grand Master
Posts: 1143
Joined: Fri Jun 17, 2005 5:32 pm
Location: Golden Oaks
Contact:

Re: Qbits in random order

Post by Japcil » Tue Apr 15, 2008 6:55 pm

The first # you can increment. So if your first quest ends with bits 0 5 5. This is wrong. You would use 0 3 5. Then you could start your next quest in a few different ways. 0 3 6 would work but you can only use 0 3 6 = haven't started. 0 3 7 do steps. 0 3 8 Finished. Or you can use 1 A B. Where A is the bit determining how many steps, and B is the step number.
Image
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Re: Qbits in random order

Post by Dalvyn » Wed Apr 16, 2008 7:52 am

Remember that you have 32 individual quest bits per area.

These quest bits are like small boxes numbered from 0 up to 31 (that makes 32 of them).

Code: Select all

|00|01|02|03|04|05|06|07|08|09|10|11|12|13|...|29|30|31|
Each of those "bits" is like a light bulb and can only be on or off ... that is, contain the value 0 or the value 1.

Individually, a bit is not very interesting, but when you group bits together, you can have them contain more values. For example, if you group bits number 00 and 01 together, you can have 4 configurations: OFF-OFF, OFF-ON, ON-OFF, and ON-ON, which can be used to represent the values 0, 1, 2, and 3.

If you group up 3 bits, you can have 8 configurations and thus represent the numbers from 0 up to 7. With 4 bits, from 0 up to 15. With 5 bits, from 0 up to 31. With 6 bits, from 0 up to 63. And so on ...

You can only group bits that are contiguous (next to each other). For example, you can group bits number 03, 04, and 05 together (forming a group of 3 bits), but you cannot choose to group bits number 03, 06, and 10, because they do not sit next to each other.

Now, how do you tell the mud what group of bits you are going to use? Well, since you can only use groups of bits that are next to each other, you simply have to tell the mud two things:
1) the NUMBER of the first bit you are going to use, and
2) HOW MANY bits you want in your group.

If you tell the mud "3 2", it means that you are going to use 2 bits, starting with bit number 03; that is, that you are going to use bits 03 and 04. If you tell the mud "9 3", you are going to use bits 09, 10, and 11.

For each quest in your area, you should
  • Determine how many values you need to be able to store (that depends on how many steps there are in your quest);
  • Determine how many bits you need to represent those values;
  • Find as many free bits as you need
For example, if you need values from 0 up to 5 for your first quest in your area, you need 3 bits for it. (To determine that, just check what I wrote above: with 1 bit, you can have only 0 and 1 - with 2 bits, you can have values from 0 to 3, which is not enough - and with 3 bits, you can have values from 0 to 7). Since you need 3 bits for your first quest, you are going to use the first three bits : bits number 00, 01, and 02.

In mud code, your first quest is going to use "0 3", "3 bits, starting with bit number 0". You will thus use commands like "mpmset $n quest 0 3 <value>" and "if quest(0,3,$n) == <value>".

Code: Select all

|00|01|02|03|04|05|06|07|08|09|10|11|12|13|...|29|30|31|
.<======>
.QUEST 1
Now, let's assume that your second quest has 11 steps. To record 11 steps (values from 0 up to 11), you need 4 bits. The first free bit is 03 (since 00, 01, and 02 are used by your first quest). You are thus going to use bits 03, 04, 05, and 06 for your second quest. In mud code, your second quest is going to use "3 4", "4 bits, starting with bit number 3". You will thus use commands like "mpmset $n quest 3 4 <value>" and "if quest(3,4,$n) == <value>".

Code: Select all

|00|01|02|03|04|05|06|07|08|09|10|11|12|13|...|29|30|31|
.<======> <=========>
.QUEST 1    QUEST 2
If you have a third quest, it will use bits starting with 07, and so on.
Image
Post Reply