Commandword Magical Items

For builders to discuss and ask building questions.
Post Reply
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Commandword Magical Items

Post by Lerytha » Wed Sep 27, 2006 10:26 am

Hello. I've looked through the objects lesson, and can't see any way in which I could put the commandwords you see when you get some magic items.

For example (making up one so as not to give IC information away).

If I examined a flower:

blahblahblah - flower to use; rechargeflower to recharge

type "flower" : hey presto, you just cast a friends spell!

In this, do we use intercept progs? I haven't got that far on working things out yet, so if the answer is yes, you use progs I'll wait till I start working on them. Even if the answer is yes, are there any builders who have created an item with commandwords in their area, who might be able to email me a copy of that item and the code with it?

Thanks for your help in advance. I hope some of this post made sense.

~Ol
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Valdimyr
Sword Novice
Sword Novice
Posts: 48
Joined: Wed Jul 12, 2006 6:49 am
Location: Golden Oaks

Post by Valdimyr » Wed Sep 27, 2006 11:26 am

Are you saying that when you type "flower" it will cast a spell?

Or are you trying to ask something totally different?
Sincerely,
Valdimyr
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Wed Sep 27, 2006 12:43 pm

If you are asking about how to make it so that "flower" is the command word, then yes, you are right... it's done with an intercept_prog if the command word is to be typed; and a speech_prog, if the command word is to be said.

If you are asking about how to convey the information that "flower" is the command word to the PC, then you have several options. A few of them are:

1 - including the command word in the description

You could add the command word to the description, either in an IC way, or an OOC way. IC way would be to indicate in the description that the word "flower" is somehow written somewhere on the object. OOC way would be, for example to add a line at the end of the description, that would go something like:

{80}OOC: type/say "flower" to activate the object

2 - restrict who can see the command word with a program

Option 1 consists in adding the command word to the description, for everybody to see. If you want only those fluent in celestial, or those with a high enough skill in spellcraft to be able to decypher the command word (because it's written in celestial runes, or magical runes, or is only visible when you are affected with detect evil, or ... anything like that), then you need to use a program. An exa_prog, to be more precise. Exa_prog programs are triggered when someone type "examine (object)". Those programs are run AFTER the PC was given the object description (= the text following the "E" flag in the file).

Code: Select all

>exa_prog 100~
if skilllevel($n,celestial) > 10
  mpechoat $n {B0}You manage to identify the runes. They say "flower".
endif
~
3 - Using an I description

A third option is to give the keyword only when someone identifies (with the spell) the object. To do that, you need to add an "I" (identify) description. It's quite similar to an "E" extra-description, but uses the "I" tag and requires no keyword. Check http://www.forgottenkingdoms.com/builde ... prog.shtml for more information.
Image
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Post by Lerytha » Wed Sep 27, 2006 10:47 pm

Thank you, Dalvyn. :) That's exactly what I was after. I may post back here if I get confused again.
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Post by Lerytha » Thu Sep 28, 2006 10:49 am

(Edited because I accidentally put a phone number here by copying from Word indiscriminately :oops: )

Right. Okay. I THINK I have how to have the original commandword worked out. However, I am a bit confused about how to complete the item.

Let me explain what I want, basically. There is a ring given upon entrance to the guild, which, when worn and when the PC types "haven" they recall. However, I do not want this to be limitless. I want it to have two charges, and then the PC has to recharge it by memorising 3 word of recalls and typing "rechargehaven".

This is the code that I have worked out so far.
##QQ30
ring Cyantree Academy~
{F0}a Cyantree Academy ring~
{F0}a cyan-and-silver ring lies here
~
ITEM_TYPE_TREASURE
FLAG_GLOW|FLAG_MAGIC
CAN_WEAR_TAKE|CAN_WEAR_FINGER
QUALITY_SUPERIOR MATERIAL_SILVER COND_PERFECT SIZE_MEDIUM
0 0 0 0 LAYER_ALL 0
E
ring Cyantree Academy~
{F0}This ring looks quite simple, a single band of striped cyan and silver, but it is obvious from the bright glow it holds that it is magical.

{80}OOC: type "haven" to activate
~
>wear_prog 100~
mpechoat $n {F0}The ring tugs momentarily in one direction before falling still
~
>intercept_prog haven~
if wear_loc($o) != -1
mpechoat $N {E0}How can the magic work without you wearing the ring?
else
mpcast word of recall $n
~
|
Basically, I am wondering how to go from here? In my head I kinda have an idea of just making an intercept prog for rechargehaven, and then an if check against a value which would stand for the amount of times it has been used. But I can’t find that kind of if check in the lessons, nor can I find a way to put a value that is sort of like charges, into this item.

I would appreciate any help at all on this matter.

Thanks for all the help I’ve received so far!

~Ol
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Thu Sep 28, 2006 11:51 am

First, a few remarks on that area code excerpt. (Don't worry, new builders make plenty of those small mistakes).

1 - Don't use Word. Use a text editor like Texpad for example (it even comes with syntax highlighting, i.e., colourizing the keywords). Word does several things that you don't want your editor to do. One of those is word wrapping. For example, the first line in your extra-description is too long. It should be at most 75-80 character long.

2 - ##QQ30 should be #QQ30

3 - Your long description should have its first word ("a") capitalized and should have a dot/full stop at the end. It should be "A cyan-and-silver ring lies here.".

4 - You might want to add "cyan" and "silver" as possible keywords for your object, both in the second line (ring Cyantree Academy cyan silver~) and in the line listing the keywords for the extra-description (the E line).

5 - Your mpechoat in the wear_prog is also missing a dot/full stop.

6 - In your intercept_prog haven, you are missing an "endif". Also, to make your programs easier to read, please use the following indentation schema :

Code: Select all

if (condition)
..XYZ <- this line starts with a 2-space indentation
else <- this line starts on the same column as "if"
..ABC <- once again, a 2-space indentation
endif <- aligned with the corresponding "if" and "else"
7 - I'm not sure whether "mpcast 'word of recall' $n" (you need single quotes around the name of the spell when it is composed of more than one word, just like for "cast") will work. But it's worth testing. If it does not work, you can make them recall to the guildhall (a fixed vnum) for example.

Now, to answer your question ... Here's a similar object.

Code: Select all

#22605
soft supple white silk cloak invisibility~
{F0}a soft supple white silk cloak~
{F0}A soft supple white silk cloak lies here.~
~
ITEM_TYPE_ARMOR
FLAG_MAGIC
CAN_WEAR_TAKE|CAN_WEAR_BODY
QUALITY_HIGH MATERIAL_SILK COND_PERFECT SIZE_MEDIUM
0 0 LAYER_OVER ARMOR_TYPE_CLOTH 0 1
E
soft supple white silk cloak~
{F0}Made of an extremely soft silk that clings to the wearer.
Stitched into the lining are the letters: "blinkybill"
{80}OOC: "rechargeblinkybill" to recharge it.
~
>intercept_prog blinkybill~
if objval5($o) > 0
  if wear_loc($o) != -1
    cast invis $n
    mpechoat $n {80}You wrap your cloak around you and disappear from view.
    mpechoaround $n {80}$N wraps $s cloak around $m and disappears from view.
    mpoadd on $n i22605 value5 -1
  else
    mpechoat $n You should wear the cloak first.
  endif
else
  mpechoat $n There is no power left in the cloak.  It needs to be recharged.
endif
~
>speech_prog blinkybill~
if objval5($o) > 0
  if wear_loc($o) != -1
    cast invis $n
    mpechoat $n {80}You wrap your cloak around you and disappear from view.
    mpechoaround $n {80}$N wraps $s cloak around $m and disappears from view.
    mpoadd on $n i22605 value5 -1
  else
    mpechoat $n You should wear the cloak first.
  endif
else
  mpechoat $n There is no power left in the cloak.  It needs to be recharged.
endif
~
>intercept_prog rechargeblinkybill~
if wear_loc($o) != -1
  if objval5($o) == 0
    if skilllevel(invis,$n) > 9
      if memorised(invis,$n) > 2
        mpechoat $n {F0}You recharge the cloak.
        mpechoaround $n {F0}$N channels magic into $O.
        mposet on $n $o value5 1
        mpclearspell invis $n
        mpclearspell invis $n
      else
        mpechoat $n {F0}You need to memorize invis twice to recharge the cloak.
      endif
    else
      mpechoat $n {F0}You don't know the spell invis well enough to do that.
    endif
  else
    mpechoat $n {F0}The cloak does not need to be recharged.
  endif
else
  mpechoat $n {F0}You need to wear the cloak to do that.
endif
~
|
Post again if you need more detailed information!
Image
User avatar
Kregor
Sword Grand Master
Sword Grand Master
Posts: 1474
Joined: Sun Jul 11, 2004 6:14 am
Location: Baldur's Gate

Post by Kregor » Thu Sep 28, 2006 4:29 pm

If casting Word of Recall doesn't work, you could always just use an mptransfer command to a specific room's VNUM, so in place of the:

c 'word of recall' $n

you would use:

mptransfer $n ROOMVNUM

ROOMVNUM being the vnum of the room you want them to go to, this could be a room in the guildhall, for example, as Dalvyn said
"There is no safety for honest men except by believing all possible evil of evil men."

Kregor - Ranger of Tangled Trees
Rozor - Lady Luck's Duelist
Tygen - Ranger-Bard of Mielikki
Zach

Post by Zach » Thu Sep 28, 2006 5:52 pm

I would use the suggestion that Kregor used seeing as word of recall would xfer them to the hometown or the dwelling.

When posting your code use the [ code ] to make it that much easier to read...
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Post by Lerytha » Fri Sep 29, 2006 9:22 am

Right, just asking for clarification here:

Code: Select all

0 0 LAYER_OVER ARMOR_TYPE_CLOTH 0 1 
The sixth (or fifth, if we count from 0) value, corresponds to the number of charges, yes?

Code: Select all

mpoadd on $n i22605 value5 -1 
And this is the part of the code that says that when the charges have run out the item won't work?

Also, I am slightly confused about the following...

Code: Select all

if wear_loc($o) != -1 


In the builder's list of if checks, it says that this check is an example check for if it is not worn. I am confused, because the example you showed above, Dalvyn, seems to treat it as the opposite.

Turning the code into "proper" English, this is what I see...

If you aren't wearing the object (if wear_loc($o) != -1) then it all works, but (else) if you are, then you get the echo "You need to wear the cloak to do that."

Does that confusion make sense? If not, just ask me to clarify and I will.

Thanks once again. And your points above about the general layout and other mistakes were greatly appreciated. I'm just struggling not to have my brain implode at the moment...

~Ol
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Fri Sep 29, 2006 11:14 am

Lerytha wrote:Right, just asking for clarification here:

Code: Select all

0 0 LAYER_OVER ARMOR_TYPE_CLOTH 0 1 
The sixth (or fifth, if we count from 0) value, corresponds to the number of charges, yes?
Correct.

That value (which is called "value 5", since they are numbered from 0 up) is used to record the current number of charges. It is used several times:

- when attempting to use the object, to check if there is at least one remaining charge
- when using the object, to reduce its value by 1
- when attempting to recharge the object, to check if there is enough room for one more charge
- when recharging the object, to increase its value by 1

Those 4 uses can actually be divided into 2 kinds:
a) checking the value
b) setting/modifying the value

Part a) is done with a code like

Code: Select all

if objval5($o) > 0 (to check if there is at least 1 remaining charge)
if objval5($o) >= 1 (equivalent check)
if objval5($o) < 2
Part b) is done with a code like

Code: Select all

mposet on $n $o value5 0 (to SET the value to 0)
mpoadd on $n $o value5 1 (to ADD one to the value)
mpoadd on $n $o value5 -1 (to SUBSTRACT one from the value)
There's the tricky part : it's called "objval5" for the check, and "value5" for setting/modifying the value.

Also, the "on $n" part is required here, to indicate where the object is (it's in $n's inventory). If the object was on the ground instead, it wouldn't use "on $n".

Code: Select all

mpoadd on $n i22605 value5 -1 
And this is the part of the code that says that when the charges have run out the item won't work?
To be more precise, that's the part where the value is decreased, when a charge has been used.

The part that says that, when the charges have run out, the item won't work is the check

Code: Select all

if objval5($o) > 0
  -- ok, there's at least one charge --
else
  mpechoat $n There is no power left in the cloak.
endif
Also, I am slightly confused about the following...

Code: Select all

if wear_loc($o) != -1 
Double-negation. :)

You can see "wear_loc($o)" as the location of the object $o. It's a number that corresponds to a possible wear location. (I'm using random numbers here, for the example). For example, it could be "2" if the item is worn on the head; or "5" if the item is worn/held in the right hand.

The only value I know for sure is the special value "-1", which is the location of an object that is NOT worn, that is, an object that is on the ground, or in the inventory.

Now, you are correct in saying that the program should be

Code: Select all

if wear_loc($o) == -1 <-- that is, if the item is NOT worn
  mpechoat You need to wear it first!
else
  -- item is worn and can be used --
endif
Note that I used "if wear_loc($o) == -1" there, to express "if the item is not worn".

Another way to construct the program is to use the opposite condition. Namely, "If the item IS worn, then it can be used - else, mpecho You need to wear it first". That's exactly the same thing, but presented the other way around.

The condition "the item is worn" means "the wear location of the object is NOT -1", that is, "the wear location of the object is 2 or 5 or 79 or anything, but NOT -1, which means not worn". The symbol for "is different from" is != (some other languages use <>, but here, it's written !=).

Turning that into a program, we get:

Code: Select all

if wear_loc($o) != -1 <- That is, if $o is NOT "not worn", i.e., if $o is worn
  -- item is worn and can be used --
else
  mpechoat $n You should wear it first!
Let me know if that's clear or if you need more information!

P.S. I noticed that the example I gave above is not perfect: the echoes (mpechoat, mpechoaround, ...) should all be colourised, but that's a minor remark.
Image
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Post by Lerytha » Fri Sep 29, 2006 1:33 pm

That makes more sense. It's because we don't know the exact value for "hands", "feet" "finger" (etc) that we have to approach it from the double negative side, which seems fine.

:D

I'm impressed you managed to translate all this for me.

Thanks!
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Post by Lerytha » Fri Sep 29, 2006 1:43 pm

Sorry... it was clear, but then I tried to change the values so it would have 3 charges and have to be recharged with 3 spells memorised, and couldn't work out which values where to change.

I've gone through the example you showed above, and basically just changed it so it works for the ring, without changing any values or checks - blindly copying, if you will.

Firstly, is it right? Secondly, is it possible for you to point out where I need to put in the differences to make the values different?

I am hopeless.

The ring's code-thing is as follows:

Code: Select all

#QQ30
ring Cyantree Academy cyan silver~
{F0}a {E0}C{F0}y{E0}a{F0}n{E0}t{F0}r{E0}e{F0}e {E0}A{F0}c{E0}a{F0}d{E0}e{F0}m{E0}y {F0}r{E0}i{F0}n{E0}g~
{F0}a glowing cyan-and-silver ring lies here
~
ITEM_TYPE_TREASURE
FLAG_GLOW|FLAG_MAGIC
CAN_WEAR_TAKE|CAN_WEAR_FINGER
QUALITY_SUPERIOR MATERIAL_SILVER COND_PERFECT SIZE_MEDIUM
0 0 0 0 LAYER_ALL 1
E
ring Cyantree Academy cyan silver~
{F0}This ring looks quite simple, a single band of striped cyan and silver, but
it is obvious from the bright glow it holds, that it is magical. Magical runes
for the word {E0}"haven" can be seen on the inside of the band.

{80}OOC: "rechargehaven" to recharge it
~
>intercept_prog haven~ 
if objval5($o) > 0 
  if wear_loc($o) != -1 
    mptransfer $n #QQ04
    mpechoat $n {F0}The ring glows brightly and you reappear in safety 
    mpechoaround $n {FO}$N dissappears in a puff of {E0}cyan smoke 
    mpoadd on $n i22605 value5 -1 
  else 
    mpechoat $n {F0}You should wear the ring first. 
  endif 
else 
  mpechoat $n {F0}There is no power left in the ring.  It needs to be recharged. 
endif 
~ 
>intercept_prog rechargehaven~ 
if wear_loc($o) != -1 
  if objval5($o) == 0 
    if skilllevel('word of recall',$n) > 9 
      if memorised('word of recall',$n) > 2 
        mpechoat $n {E0}You recharge the ring. 
        mpechoaround $n {E0}$N channels magic into $O. 
        mposet on $n $o value5 1 
        mpclearspell 'word of recall' $n 
        mpclearspell 'word of recall' $n 
      else 
        mpechoat $n {F0}You need to memorize word of recall twice to recharge the cloak. 
      endif 
    else 
      mpechoat $n {F0}You don't know the spell word of recall well enough to do that. 
    endif 
  else 
    mpechoat $n {F0}The ring does not need to be recharged. 
  endif 
else 
  mpechoat $n {F0}You need to wear the ring to do that. 
endif 
~ 
|
EDIT: replaced original code excerpt with corrected version. Sorry!
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Fri Sep 29, 2006 2:42 pm

Code: Select all

0 0 0 0 LAYER_ALL 1
The "1" there is the number of charges when the object is initially created. It can be either the max number of charges you want the item to have, or a smaller number (a ring that can contain 3 charges might initially comes with 0, 1, 2, or 3 charges).

Code: Select all

{80}OOC: "rechargehaven" to recharge it
Missing dot/full stop.

Code: Select all

    mptransfer $n #QQ04
    mpechoat $n {F0}The ring glows brightly and you reappear in safety 
    mpechoaround $n {FO}$N dissappears in a puff of {E0}cyan smoke
There are 2 problems with this piece of code (well, 3 if you include the missing dots/full stops :) ).

1 - First, you transfer $n, then make the echoaround that $n has disappeared. That echo will thus be shown to those who are near $n AFTER (s)he has been transfered, that is, those who are in the destination/arrival room. You need to actually put those two echoes before the mptransfer.

It would also be nice to have an echoaround $n AFTER the transfer, for those who stand in the arrival/destination room, and should see $n suddenly appear.

2 - If you want to transfer $n's pet too, you need to use "mptransfer $n QQ04 pet". By the way, you only need to put a # before the number at the start of a mob/room/object description, not here.

Code: Select all

    mpoadd on $n i22605 value5 -1
The -1 here indicates that 1 charge is spent when the ring is used. This number should not be modified.

Code: Select all

      if memorised('word of recall',$n) > 2
memorised(word of recall,$n) - I actually don't think that quotes are necessary here, but I'm not entire sure (that's something you'll be able to test later once it's on the test port) - is the number of spell slots spent on "word of recall". Here, you are requiring that $n has at least 3 (strictly more than 2) word of recall memorized.

Note that there is an error in the original program I pasted above. It should be >= 2 instead of > 2, since it should require that 2 invis be memorized. (Using > 2 means that there should be at least 3 memorized invis).

As a rule of thumb, I tend to require spending 2 memorized spells to put 1 charge back in a charged items. But other options are possible too. Also, even if an object can hold several charges, I think it's better to make it so that it can only be recharged 1 charge at a time (i.e., it needs to be recharged several times before it's full, if all its charges have been used).

Code: Select all

  mposet on $n $o value5 1
Mposet is dangerous here, since it sets the value to 1. I think using "mpoadd on $n $o value5 1" would be better.

Now, that would require an additional check, to make sure that $n does not "overcharge" the object. If you want a ring that can contain at most 3 charges for example, you must make sure that it has at most 2 charges left when it is recharged :

Code: Select all

if objval5($o) <= 2
  -- ok, recharge --
else
  mpechoat $n The object is already as full as it can be!
endif
Continuing ...

Code: Select all

        mpclearspell 'word of recall' $n 
        mpclearspell 'word of recall' $n
Each of those lines marks one memorized "word of recall" as "used up". If you want people to have to spend 3 slots of word of recall to recharge the ring, you would need a third line here.

Hope that helps.
Image
Lerytha
Sword Grand Master
Sword Grand Master
Posts: 989
Joined: Fri Mar 19, 2004 8:37 am
Location: Waterdeep

Post by Lerytha » Fri Sep 29, 2006 2:51 pm

I think so. I'm going away for weekend now, so will have no time to see if I can work it in to my item code stuff. But I wanted to reply to say thanks for your help so far, anyway. Will (most probably) post another cry for help in a few days, after trying to apply all this overwhelming knowledge.

;)

Thanks!

~Ol
If you have knowledge, let others light their candles with it.

--Sir Winston Churchill

"This place is boring, I'm gonna go eat whatever I can find laying on the ground"

-- Hoildric

Cacie asks Larethiel 'Did that air just bow to you?
Zach

Post by Zach » Fri Sep 29, 2006 5:11 pm

Code: Select all

        mpechoat $n {F0}You need to memorize word of recall twice to recharge the cloak.
You would want it to say "...recharge the ring" not the cloak
Post Reply