Menus and Procedures

steve the gaming guy
09 Aug 2005, 16:17
I have created the following code for an example of the problem I am having. I want to use a spell book on the wizard and show a menu of a list of spells available to use. As I use different spells, I want the wizard's property to change.
In this example, the wizard uses the ice spell and to counter, the player should use the fire spell or else he dies.
Once the fire spell is used, the wizard changes into fire himself and the player is to use the water spell to finish the game.

What happens here is that when the fire spell is used, it shows the first (correct) reaction where the wizard backs away but then when the property changes, it immediately shows the second reaction as if the player used the fire spell a second time.

' "book test"
' Created with QDK 3.53 - UNREGISTERED VERSION

define game <book test>
asl-version <350>
gametype singleplayer
start <room1>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
end define

define synonyms
end define

define room <room1>
look <This is a big room.>
command <cast spell> if got <spell book> then do <cast_spell> else msg <You have no powers.>

define object <spell book>
take {
give <spell book>
do <get_book>
}
use on <wizard> do <cast_spell>
end define

define object <wizard>
look <The wizard is evil.>
speak <He is not going to talk to you.>
prefix <the>
gender <he>
end define

end define

define procedure <cast_spell>
msg <You wave your hand and cast one the available spells from the spell book:|n>
choose <book>
end define

define procedure <get_book>
msg <As you pick up the book, the evil wizard casts an ice spell. You better do something quick!|n>
property <wizard; ice>
end define

define text <intro>

end define

define text <win>

end define

define text <lose>

end define

define selection <book>
info <book>
choice <fire> {
if property <wizard; ice> then {
msg <You cast the fire spell and melt the evil wizard but he backs up and changes into a fire himself.|n|nWhat spell do you cast now?>
property <wizard; fire>
}
if property <wizard; fire> then {
msg <You cast the fire spell but he is already a flame himself so he burns you alive.|n>
playerlose
}
}
choice <water> {
if property <wizard; ice> then {
msg <You cast the water spell on the wizard but he has already cast the ice spell.|nLarge ice shards pummel your body and you die.|n>
playerlose
}
if property <wizard; fire> then {
msg <You cast the water spell and wash the wizard out completely!!!>
playerwin
}
}
end define



I hope I explained that correctly. If you test this, you will see what I mean. :shock:

What I want to happen is after the wizard changes his property, the player must use the command "cast spell" a second time before anything else happens.

Arbutus
09 Aug 2005, 18:13
Put the if property <wizard;fire> block before the if property <wizard;ice> block. The wizard was set to ice right before the code was checking for ice, so both choices would run every time.

And when you set the fire property, make sure to also "turn off" the ice property and vice-versa. Otherwise, he's fire and ice! What a wizard!


choice <fire> {
if property <wizard; fire> then {
msg <You cast the fire spell but he is already a flame himself so he burns you alive.|n>
playerlose
}
if property <wizard; ice> then {
msg <You cast the fire spell and melt the evil wizard but he backs up and changes into a fire himself.|n|nWhat spell do you cast now?>
property <wizard; fire>
property <wizard; not ice>
}
}


steve the gaming guy
09 Aug 2005, 19:01
Throwing a "not" in front of ice in the property turns ice off? It makes sense but I didn't think that works. I will try it out.
Thanks!

paul_one
09 Aug 2005, 21:02
Yes, not turns boolean properties off.

I advise you to use a value property instead though, ie:
property <element=fire>

Since he can usually only be one element (or all elements - as the fifth element I guess).

But yeah, everything Arbutus put is 100% correct, s/he's done some work in the area and has picked up the language pretty quickly & well.

steve the gaming guy
10 Aug 2005, 13:48
I will have to try the “element=fire” idea as well. The first way seemed to work.
However, I ran into some trouble last night when I was working on it because for this example, I said there are only two different elements. In my game, it is actually four. I was just going to use the basic principle for all four and adjust it accordingly.
What happens now is when the wizard changes to the first element, the first counter spell works and the wizard then changes to the second element and waits for the players command. This is correct so far.
HOWEVER, when the second counter spell is cast, the response was as if the wizard had already changed into his third element.
It’s probably just a simple error that I need to fix. I have something backwards or something like that.
I don’t have the actual code here at work with me so I cannot post it. If I have further problems with it, I will post it.

Thank you Arbutus and Tr0n

steve the gaming guy
14 Nov 2005, 04:17
Tr0n,

I haven't abandoned this project or the forums. I haven't been "Quest active" lately.
But I did try your suggestions and I just keep running into the same annoying problems.

In short, the wizard is going to change into four different objects/elements. I want the player to pick 1 of 4 defensive spells. One spell counters one of the wizards spells. If they choose the wrong spell, they get killed.
As it stands now, the first spell works properly and the wizard changes himself into the 2nd object. Now when the 2nd correct spell is cast, the counter spell is correctly described but then suddenly, the description for the wizard was as if I used the 2nd counter spell on the wizard's 3rd spell and the player is killed.
Then it produces the standard lose text block of the game. Then the game continues and produces the description of the 2nd counter spell and then the wizard's 4th spell.
I can't really describe it any better so here is the code:
In order to progress, the commands are "use crispin's wand on machine, use mordack's wand on machine, use cheese on machine, get crispin's wand, use wand on mordack, choose tiger spell, use wand on mordack, choose rabbit spell...be confused!



' "King's Quest V - text adventure"
' Created with QDK 3.53 - UNREGISTERED VERSION

!include <Typelib.qlb>

define game <King's Quest V - text adventure>
asl-version <350>
gametype singleplayer
start <lab - upstairs>
game author <Steve Lingle>
game version <1.0>
game copyright <Revised by Steveco Games for free distribution only>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
define variable <mordack_insect>
type numeric
value <30>
onchange if ( %mordack_insect% < 1 ) then {
timeroff <mordack_insect>
msg <Just as Graham is deciding on what to do, Mordack (as the

insect) swoops down upon him and finishes him off.|n>
wait <press any key>
msg <If only there were something that Graham could have done

to stop Mordack.|n|nHint: read the book in the library. They are magic spells.|n(use

command: cast spell or wave wand or use wand on Mordack)>
wait <press any key>
playerlose
}
end define
define variable <Score>
type numeric
value <0>
display <!>
end define
end define

define synonyms
take = get
bandit = man
e = east
w = west
s = south
n = north
pipe organ = organ
end define

define room <inven room>

define object <Mordack>
look {
if property <Mordack; > then msg <Mordack stands in the room

staring menacingly at Graham.|n>
if property <Mordack; insect> then msg <Mordack (as a large

insect) hovers eerily above Graham.|n>
if property <Mordack; dragon> then msg <Mordack (as a dragon)

towers over Graham ready to scorch him with fire.|n>
if property <Mordack; cobra> then msg <Mordack (as a cobra)

slithers closer and closer to Graham ready to strike.|n>
if property <Mordack; fire> then msg <Mordack (as a fire)

circles Graham containing him in one spot.|n>
}
speak <Mordack is not going to discuss anything with Graham.>
displaytype <character>
gender <he>
end define

define object <Mordack's wand2>
alias <Mordack's wand>
alt <wand; Mordack's wand; Mordacks wand>
look <Mordack's wand barely sparkles at all now.>
take msg <Now that the wand has lost all of its magical powers, there

is no further use for it.|n>
article <it>
gender <it>
use msg <Graham waves Mordack's wand which is full of magical

energy.|nStrangely, nothing happens. Could it be that only Mordack can use the

wand?|n>
end define

end define

define room <laboratory>
prefix <the>
look <The laboratory is a very large room. A stairway immediately to the left

leads to the upper section of the laboratory where a strange machine can be seen from

the ground floor.|nAn enormous fireplace sits against the east wall with a ventilation

shaft leading up and out through the ceiling. On either side of the shaft are windows

where most of the room's light is coming from.|nMagic trinkets and other type of

chemical substances clutter laboratory tables on the sides of the room.|nAmong the

bottles and jars, Graham notices a very large jar on the edge of one of the tables

containing a miniature castle.>
west if here <Mordack> then msg <Graham cannot leave now. He must deal with

Mordack.|n> else goto <upstairs hallway>
up if here <Mordack> then msg <Graham cannot leave now. He must deal with

Mordack.|n> else goto <lab - upstairs>

define object <stairway>
look <The stone stairway leads to the top floor of the laboratory.>
prefix <the>
article <it>
invisible
end define

define object <machine1>
alias <strange machine>
alt <strange machine; machine>
look <A strange machine can be seen from the ground floor.>
take msg <Graham will need to be closer to examine the strange

machine.|n>
examine <A strange machine can be seen from the ground floor. Graham

will need to be closer to examine it.>
prefix <a>
article <it>
end define

define object <fireplace1>
alias <fireplace>
alt <fire; place; fire place>
look <A dormant fireplace sits on the east side of the room. This is

most likely where magic spells and experiments are created.>
prefix <a>
article <it>
end define

define object <shaft>
alt <ventilation; ventilation shaft>
look <A ventilation shaft extends from the fireplace against the wall

and travels up and out of the castle near the ceiling where fumes from the fireplace

would most likely go.>
prefix <a>
article <it>
end define

define object <windows>
alt <window>
look <The two windows against the east wall are too high to be reached.

There not especially large either so this would not provide an adequate means of

escape.>
prefix <the>
article <them>
invisible
end define

define object <trinkets>
alt <magic trinkets; chemicals; bottles; tubes; table; tables>
look <Magic trinkets, chemical apparatus and tubes are scattered around

the laboratory. In one corner of a table sits a large glass jar with a miniature

castle inside.>
take msg <There is nothing of interest with the them.|n>
prefix <the>
article <them>
invisible
end define

define object <glass jar>
alt <jar; castle; miniature castle; castle in jar; miniature castle in

jar>
look <On the edge of a table sits a large glass jar containing Graham's

castle.>
take msg <The glass jar is too large to carry around. There must be a

way to save Graham's family.|n>
speak msg <A tear comes to Graham's eye as he sees his family inside of

the glass jar.|n|cr"I will rescue you soon, my family."|cb|n>
examine msg <A tear comes to Graham's eye as he sees his family inside

of the glass jar.|n|cr"I will rescue you soon, my family."|cb|n>
prefix <a>
article <it>
end define

end define

define room <lab - upstairs>
down <laboratory>

define object <machine2>
alias <strange machine>
alt <strange machine; machine>
look <The machine has a large basin with bubbling liquid in the center

with pipes and copper coils coming out of it. They pipes form a cross section and

extend to the left and right where each end comes to a point. At the points on each

end are metallic cones that point to empty trays. There is a tray on the left and a

tray on the right. If only Graham could figure out what goes on the trays.>
take msg <Graham will need to be closer to examine the strange

machine.|n>
prefix <a>
article <it>
end define

define object <trays>
alt <tray>
look <A tray sits on the left and right side of the machine. Graham

wonders what they could be used for.>
prefix <the>
article <them>
invisible
end define

define object <crispin's wand2>
alias <crispin's wand>
alt <wand>
look <Crispin's wand is now pulsing with magical power.>
take do <Crispin's wand charged>
speak <Talking to the wand will do nothing.>
article <it>
gender <it>
use msg <You wave the wand but only a couple sparkles fizzle out from

the wand and nothing happens.>
use on <Mordack> do <Wand on Mordack>
use on anything msg <You wave the wand but only a couple sparkles

fizzle out from the wand and nothing happens.>
drop nowhere
end define

end define

define procedure <Crispin's wand charged>
msg <Graham picks up Crispin's wand from the tray and can immediately feel the

magical power flowing through it.|n>
inc <Score; 2>
give <crispin's wand2>
wait <press any key>
msg <A few moments later, Mordack appears in the entry of the laboratory

downstairs.|n>
move <Mordack; lab - upstairs>
wait <press any key>
msg <Graham steps forward to the edge of the balcony so he can see the

laboratory.|n>
wait <press any key>
goto <laboratory>
move <Mordack; laboratory>
wait <press any key>
msg <|cl"What are you doing with my wand, you swine!"|cb Mordack waves his

hands and his wand sails through the air and into his waiting hand.|n>
move <Mordack's wand2; inven room>
wait <press any key>
msg <|cl"You will be a hinderance no more!"|cb |nJust as Mordack begins to

wave his wand...|n>
wait <press any key>
msg <|cg"Graham, I have just heard from Crispin and he will be on his way to

help..."|cb|nIt was Cedric! He flew in through the laboratory windows.|n>
wait <press any key>
msg <At that moment, a ray of magic shoots from Mordack's wand and hits Cedric

as he accidentally intercepted the path of the magic spell.|n>
wait <press any key>
msg <Cedric immediately turned to stone and fell to the floor.|n|cr"Cedric!"|cb

shouted Graham.|n>
wait <press any key>
msg <Mordack waves his wand again but only a few sparkles fizzle through the

end.|n|cl"What did you do to my wand? Do not under estimate my powers, little

man..."|cb|n>
wait <press any key>
msg <Mordack waves his arms and suddenly his whole body begins to glow.|nGraham

watched in awe and horror as Mordack started to grow and change into a large flying

insect.|n>
wait <press any key>
msg <Mordack (as an insect) flies up to the upper level of the laboratory and

hovers just above Graham.|nNow is the time for Graham to pull a trick or two out of his

hat!|n>
property <Mordack; insect>

end define

define procedure <Wand on Mordack>
msg <Graham waves his wand and prepares to cast a spell from the large book

from Mordack's library.|n>
wait <press any key>
choose <book>
if property <Mordack; insect> then property <Mordack; dragon>
if property <Mordack; dragon> then property <Mordack; cobra>
if property <Mordack; cobra> then property <Mordack; fire>

end define

define procedure <end of story>
msg <Graham, in bewilderment, looks around the laboratory. Mordack's ashes

smoke as the last of the burning ambers fizzle away.|n>
wait <press any key>
msg <He looks at poor Cedric lying on the floor of the laboratory and he looks

at his family in the large glass jar.|n>
wait <press any key>
msg <As he ponders what to do next and how he would possibly get everyone home,

a puff of smoke appeared behind Graham.|n>
wait <press any key>
say <|cl"Confound it...Oh wonderful. Graham, I'm glad to see you are still

alive."|cb It was Crispin. Although he missed the show, hopefully he could help

restore everything to normal.|n>
wait <press any key>

end define

define procedure <tiger>
if property <Mordack; dragon> then {
msg <Graham casts the tiger spell on himself and he instantly changes

into the form of a tiger.|n>
wait <press any key>
msg <Mordack (as the dragon) blows a gust of fire at Graham (as the

tiger) and consumes him completely killing Graham quite quickly.|n>
wait <press any key>
msg <Maybe there is another spell that Graham should try.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
msg <Graham casts the tiger spell on himself changing him into the form

of a tiger instantly.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham (as the tiger) and

bites him quickly on the neck.|n>
wait <press any key>
msg <After a few moments, Graham falls to the floor dead.|n|nPerhaps

there was another spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
msg <Graham cast the tiger spell on himself and his body changes into

the form of a tiger instantly.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham (as the tiger) and consumes

him quickly. |nIt does not take long for Graham to pass away.|n>
wait <press any key>
msg <Perhaps there was a different spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; insect> then {
timeroff <mordack_insect>
msg <Graham casts the tiger spell on himself and he immediately changes

form into a tiger.|n>
wait <press any key>
msg <Graham (as the tiger) begins jumping up on his hind legs and

clawing at Mordack (as the insect).|n>
wait <press any key>
msg <|cl"Grrrrrrraaaahhhh!!!" |cbcries Mordack.|nMordack flies back

down to the lower area of the laboratory and Graham jumps down ready to attack.|n>
wait <press any key>
msg <|cl"You think you're pretty smart, Graham...Let's see how you

handle a little fire."|cb Mordack begins to grow very large and changes into a

ferocious dragon.|n>
property <Mordack; not insect>
property <Mordack; dragon>
timeron <mordack_dragon>
}
end define

define procedure <rabbit>
if property <Mordack; insect> then {
msg <Graham casts the rabbit spell on himself and he immediately

changes form into a rabbit.|n>
wait <press any key>
msg <Mordack (as the insect) swoops down on Graham (as the rabbit) and

eats him whole.|n>
wait <press any key>
msg <Perhaps there was another spell Graham could have used.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
msg <Graham casts the rabbit spell on himself changing him into the

form of a rabbit instantly.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham (as the rabbit) and

bites him quickly on the neck.|n>
wait <press any key>
msg <After a few moments, Graham falls to the floor dead.|n|nPerhaps

there was another spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
msg <Graham cast the rabbit spell on himself and his body changes into

the form of a rabbit instantly.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham (as the rabbit) and

consumes him quickly. |nIt does not take long for Graham to pass away.|n>
wait <press any key>
msg <Perhaps there was a different spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; dragon> then {
timeroff <mordack_dragon>
msg <Graham casts the rabbit spell on himself and he immediately

changes form into a rabbit.|n>
wait <press any key>
msg <Mordack (as the dragon) begins blowing fireballs down at the

floor. Graham (as the rabbit) easily hops out of harm's way with each blast.|n>
wait <press any key>
msg <|cl"Rrrooooaaarrr!"|cb Mordack is visually frustrated at Graham's

trick. He begins to shrink down to a smaller size.|n>
wait <press any key>
msg <Mordack changed himself into a king cobra! He begins to slither

towards Graham (as the rabbit).|n|cl"Let'sssss ssseee how you handle thissss..."|cb|n>
property <Mordack; not dragon>
property <Mordack; cobra>
timeron <mordack_cobra>
}
end define

define procedure <weasel>
if property <Mordack; insect> then {
msg <Graham casts the weasel spell on himself and he immediately

changes form into a weasel.|n>
wait <press any key>
msg <Mordack (as the insect) swoops down on Graham (as the weasel) and

eats him whole.|n>
wait <press any key>
msg <Perhaps there was another spell Graham could have used.|n>
wait <press any key>
playerlose
}
if property <Mordack; dragon> then {
msg <Graham casts the weasel spell on himself and he instantly changes

into the form of a weasel.|n>
wait <press any key>
msg <Mordack (as the dragon) blows a gust of fire at Graham (as the

weasel) and consumes him completely killing Graham quite quickly.|n>
wait <press any key>
msg <Maybe there is another spell that Graham should try.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
msg <Graham cast the weasel spell on himself and his body changes into

the form of a weasel instantly.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham (as the weasel) and

consumes him quickly. |nIt does not take long for Graham to pass away.|n>
wait <press any key>
msg <Perhaps there was a different spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
timeroff <mordack_cobra>
msg <Graham casts the weasel spell on himself changing him into the

form of a weasel instantly.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham (as the weasel) and

tries to bite at him.|n|nUsing quick weasel reflexes, Graham jumps up and bites the

neck of the king cobra and shakes his head violently.|n>
wait <press any key>
msg <|cl"Aaahhh! Cursssessss!"|cb Mordack slithers away quickly.|n>
wait <press any key>
msg <|cl"Thisss isss the end of you, Graham!"|cb Mordack screams as he

begins to change into a very real ring of fire across the floor surrounding Graham

entirely.|n>
property <Mordack; not cobra>
property <Mordack; fire>
timeron <mordack_fire>
}

end define

define procedure <rain>
if property <Mordack; insect> then {
msg <Graham casts the rain spell on himself and a small rain cloud

immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the insect) swoops down on Graham covered with rain

and eats him whole.|n>
wait <press any key>
msg <Perhaps there was another spell Graham could have used.|n>
wait <press any key>
playerlose
}
if property <Mordack; dragon> then {
msg <Graham casts the rain spell on himself and a small rain cloud

immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the dragon) blows a gust of fire at Graham covered

with rain but it was not enough to stop the dragon's fire.|nIt quickly consumes Graham

and he dies.|n|n>
wait <press any key>
msg <Maybe there is another spell that Graham should try.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
msg <Graham casts the rain spell on himself and a small rain cloud

immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham covered with rain and

bites him quickly on the neck.|n>
wait <press any key>
msg <After a few moments, Graham falls to the floor dead.|n|nPerhaps

there was another spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
timeroff <mordack_fire>
msg <Graham casts the rain spell on himself and a small rain cloud

immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham and the rain pours down on

both of them washing out the fire.|n>
wait <press any key>
msg <Mordack is gone! Graham has won!|n>
wait <press any key>
do <end of story>
}

end define

define timer <mordack_appear>
interval <1>
action dec <mordack_appear; 1>
disabled
end define

define text <intro>

end define

define text <lose>

~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
Please try again. If you've saved the game, please restore by clicking "restore" in

the lower righthand corner of the screen.
~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
end define

define text <win>

end define

define selection <book>
info <book>
choice <tiger> do <tiger>
choice <rabbit> do <rabbit>
choice <weasel> do <weasel>
choice <rain> do <rain>
end define


paul_one
06 Dec 2005, 14:44
I'm confused from the off.

Number 1, you have procedures when you don't need them:
Mainly procedures are helpful when either of the two are important:
1) a summary of one action to simplify code
2) one section of code is used for various purposes.

Now I had to go all over that code to realise what you were doing.

I finally get through, and the first few commands mean nothing to the code I can read. Using the wand will do nothing, and there's also no cheese.

But then, when you go to cast the tiger spell from the book - you haven't given the object Mordack doesn't have any animal property - but the spell REQUIRES it to actually do anything!
There should be a 5th option where if Mordack doesn't have an animal property then one thing happens.

I expect that's where your error comes from.

Then again, I can't even start up my PC right now to start Quest up - so I may be wrong somewhere.

steve the gaming guy
06 Dec 2005, 18:54
Well thank you for reading over it.
I chose procedures because I thought I was simplifying it. Maybe I’m wrong. Mordack becomes something; you counter it which triggers a procedure. Anyway…regardless, the wand and the cheese are for the final version of the game.
As far as casting the tiger spell, Mordack actually already has the property of “insect”. This happens at the last line of the “define procedure <Crispin's wand charged>”
So in other words, when you pick up the wand, this procedure happens providing a bit of dialogue and changing Mordack into an insect. From this point, if the tiger spell is cast, you have succeeded in countering the “insect” spell.
What I have just described actually works in the game. I’ve tested it. It is what happens next that does not seem to work properly.
It’s almost as if Mordack’s property reverts to other properties causing the counter spells/procedures not to work right.
It’s hard to explain without you seeing what happens.
I hope I have cleared this up a tiny bit for you.

paul_one
06 Dec 2005, 22:15
There's the whole "wand on mordack" procedure!
It sets these properties, all at once - so after ONE spell, you have it get ALL the properties so he's everything at once!

Using the debug menu in Quest is brillient (not sure if typelib stops this or not, as I don't use it).
*cough* on laptop now */cough*

... Now I'm off to stamp about and kick my PC a few times, seeing as how copying Linux across is one hell of a job!

steve the gaming guy
11 Dec 2005, 16:22
Ok, I think I see what you are saying. So are you suggesting that it should be broken up into separate procedures? I'm really going to have to rethink this whole puzzle since I apparently screwed it up.

haha, and don't kick your PC too hard!

paul_one
11 Dec 2005, 20:30
Bah... Needs a good beating I think - with a paddle...

I think my PC just got a little sick, and then went off having a female paddy for about 2 weeks. Then I accidentally put a 'b' instead of a 'c' and wiped my linux partition.
D'OH!

I have to start all over again, and with Linux it's SUCH a pain to get everything working correctly.
I'm gonna go really slowly I think.

Right, as it is - it IS in seperate procedures.
BUT you have one procedure basically just printing a message and then calling another procedure straight away. Then coming back and setting all the flags to true. (wand on mordack procedure).

What you'd usually do is put similar bits of code into one function, and pass stuff TO the function to make it different - instead of 5 different procedures.
Then there's bits like bit lumps of storyline/text.
So say you have about 20 lines of text just coming up on the screen. Instead of putting them into a normal part, put them into a "story_part_15" or something procedure, then leave a little note giving a summary:
' Mordack changes into Fly, Guy is now stone.
Stuff that would make sense if you were the programmer (which you are :P ).
It just makes it easier on the eyes to seperate story from what's actually happenning.

steve the gaming guy
12 Dec 2005, 16:55
I scrolled up and re-read the actual code for the "wand on mordack" procedure. I generally don't manually enter the code unless I am tweaking something. This entire code, for the most part, was created through QDK. But in trying to determine what you were referencing within this procedure, I can clearly see that what I have in it does not make sense to me. I'm trying to figure out what Quest is trying to do when it tries to perform this procedure.
Specifically the three lines that follow "choose <book>", it's like I'm telling Quest to make Mordack one property if he's another property. And then repeat it two more times! I will be reworking this.

define procedure <Wand on Mordack> 
msg <Graham waves his wand and prepares to cast a spell from the large book

from Mordack's library.|n>
wait <press any key>
choose <book>
if property <Mordack; insect> then property <Mordack; dragon>
if property <Mordack; dragon> then property <Mordack; cobra>
if property <Mordack; cobra> then property <Mordack; fire>

end define



...and in regards to paddling. That's always entertaining! :lol:

paul_one
12 Dec 2005, 17:20
You are Steve.

If property <> works by seeing if the object has that property. Not what value it is - but only if it has that property.

But can you see that it'll go through the first one - see that he IS an insect, then set him as a dragon. Then the second spots that he's a dragon and then activates the cobra. Then the 3rd spots that he's a cobra and activates fire.

Hope it works out for ya.

steve the gaming guy
12 Dec 2005, 19:19
Yes, I am Steve! Bwahahaha

Seriously though...that makes sense given the results that I was getting when you play it based on how the code looks now. I told my wife that I need to start working on this at nights again when I get home from work so I can get it done!

steve the gaming guy
13 Dec 2005, 06:29
Tr0n!!! WE HAVE SUCCESS!!....I thank you a million times!

I took out the four spell procedures entirely and just included them all into the book menu instead of calling these procedures from the book menu. After testing it, I even purposely used the wrong spells to make sure I get killed in the right way..haha... For example, if the dragon was shooting fire at me and I turned myself into a weasel, I would just be a weasel consumed in the dragon's fire....correct death. :D

This was THE final puzzle of the game and now that it works, I can do the finishing touches such as grammar/spelling, etc... and the game should be ready in a matter of time. I believe I'm going to hold it until the beginning of January though to start the year off right.

No matter....The now working code is as follows:

' "King's Quest V - text adventure"
' Created with QDK 3.53 - UNREGISTERED VERSION

!include <Typelib.qlb>

define game <King's Quest V - text adventure>
asl-version <350>
gametype singleplayer
start <lab - upstairs>
game author <Steve Lingle>
game version <1.0>
game copyright <Revised by Steveco Games for free distribution only>
game info <Created with QDK 3.53 - UNREGISTERED EVALUATION VERSION.>
command <cast spell> exec <use wand on mordack>
command <wave wand> exec <use wand on mordack>
define variable <mordack_insect>
type numeric
value <30>
onchange if ( %mordack_insect% < 1 ) then {
timeroff <mordack_insect>
msg <Just as Graham is deciding on what to do, Mordack (as the insect) swoops down upon him and finishes him off.|n>
wait <press any key>
msg <If only there were something that Graham could have done to stop Mordack.|n|nHint: read the book in the library. They are magic spells.|n(use command: cast spell or wave wand or use wand on Mordack)>
wait <press any key>
playerlose
}
end define
define variable <Score>
type numeric
value <0>
display <!>
end define
end define

define synonyms
take = get
bandit = man
e = east
w = west
s = south
n = north
pipe organ = organ
end define

define room <inven room>

define object <Mordack>
look {
if property <Mordack; > then msg <Mordack stands in the room staring menacingly at Graham.|n>
if property <Mordack; insect> then msg <Mordack (as a large insect) hovers eerily above Graham.|n>
if property <Mordack; dragon> then msg <Mordack (as a dragon) towers over Graham ready to scorch him with fire.|n>
if property <Mordack; cobra> then msg <Mordack (as a cobra) slithers closer and closer to Graham ready to strike.|n>
if property <Mordack; fire> then msg <Mordack (as a fire) circles Graham containing him in one spot.|n>
}
speak <Mordack is not going to discuss anything with Graham.>
displaytype <character>
gender <he>
end define

define object <Mordack's wand2>
alias <Mordack's wand>
alt <wand; Mordack's wand; Mordacks wand>
look <Mordack's wand barely sparkles at all now.>
take msg <Now that the wand has lost all of its magical powers, there is no further use for it.|n>
article <it>
gender <it>
use msg <Graham waves Mordack's wand which is full of magical energy.|nStrangely, nothing happens. Could it be that only Mordack can use the wand?|n>
end define

end define

define room <laboratory>
prefix <the>
look <The laboratory is a very large room. A stairway immediately to the left leads to the upper section of the laboratory where a strange machine can be seen from the ground floor.|nAn enormous fireplace sits against the east wall with a ventilation shaft leading up and out through the ceiling. On either side of the shaft are windows where most of the room's light is coming from.|nMagic trinkets and other type of chemical substances clutter laboratory tables on the sides of the room.|nAmong the bottles and jars, Graham notices a very large jar on the edge of one of the tables containing a miniature castle.>
west if here <Mordack> then msg <Graham cannot leave now. He must deal with Mordack.|n> else goto <upstairs hallway>
up if here <Mordack> then msg <Graham cannot leave now. He must deal with Mordack.|n> else goto <lab - upstairs>

define object <stairway>
look <The stone stairway leads to the top floor of the laboratory.>
prefix <the>
article <it>
invisible
end define

define object <machine1>
alias <strange machine>
alt <strange machine; machine>
look <A strange machine can be seen from the ground floor.>
take msg <Graham will need to be closer to examine the strange machine.|n>
examine <A strange machine can be seen from the ground floor. Graham will need to be closer to examine it.>
prefix <a>
article <it>
end define

define object <fireplace1>
alias <fireplace>
alt <fire; place; fire place>
look <A dormant fireplace sits on the east side of the room. This is most likely where magic spells and experiments are created.>
prefix <a>
article <it>
end define

define object <shaft>
alt <ventilation; ventilation shaft>
look <A ventilation shaft extends from the fireplace against the wall and travels up and out of the castle near the ceiling where fumes from the fireplace would most likely go.>
prefix <a>
article <it>
end define

define object <windows>
alt <window>
look <The two windows against the east wall are too high to be reached. There not especially large either so this would not provide an adequate means of escape.>
prefix <the>
article <them>
invisible
end define

define object <trinkets>
alt <magic trinkets; chemicals; bottles; tubes; table; tables>
look <Magic trinkets, chemical apparatus and tubes are scattered around the laboratory. In one corner of a table sits a large glass jar with a miniature castle inside.>
take msg <There is nothing of interest with the them.|n>
prefix <the>
article <them>
invisible
end define

define object <glass jar>
alt <jar; castle; miniature castle; castle in jar; miniature castle in jar>
look <On the edge of a table sits a large glass jar containing Graham's castle.>
take msg <The glass jar is too large to carry around. There must be a way to save Graham's family.|n>
speak msg <A tear comes to Graham's eye as he sees his family inside of the glass jar.|n|cr"I will rescue you soon, my family."|cb|n>
examine msg <A tear comes to Graham's eye as he sees his family inside of the glass jar.|n|cr"I will rescue you soon, my family."|cb|n>
prefix <a>
article <it>
end define

end define

define room <lab - upstairs>
down <laboratory>

define object <machine2>
alias <strange machine>
alt <strange machine; machine>
look <The machine has a large basin with bubbling liquid in the center with pipes and copper coils coming out of it. They pipes form a cross section and extend to the left and right where each end comes to a point. At the points on each end are metallic cones that point to empty trays. There is a tray on the left and a tray on the right. If only Graham could figure out what goes on the trays.>
take msg <Graham will need to be closer to examine the strange machine.|n>
prefix <a>
article <it>
end define

define object <trays>
alt <tray>
look <A tray sits on the left and right side of the machine. Graham wonders what they could be used for.>
prefix <the>
article <them>
invisible
end define

define object <crispin's wand2>
alias <crispin's wand>
alt <wand>
look <Crispin's wand is now pulsing with magical power.>
take do <Crispin's wand charged>
speak <Talking to the wand will do nothing.>
article <it>
gender <it>
use msg <You wave the wand but only a couple sparkles fizzle out from the wand and nothing happens.>
use on <Mordack> do <Wand on Mordack>
use on anything msg <You wave the wand but only a couple sparkles fizzle out from the wand and nothing happens.>
drop nowhere
end define

end define

define procedure <Crispin's wand charged>
msg <Graham picks up Crispin's wand from the tray and can immediately feel the magical power flowing through it.|n>
inc <Score; 2>
give <crispin's wand2>
wait <press any key>
msg <A few moments later, Mordack appears in the entry of the laboratory downstairs.|n>
move <Mordack; lab - upstairs>
wait <press any key>
msg <Graham steps forward to the edge of the balcony so he can see the laboratory.|n>
wait <press any key>
goto <laboratory>
move <Mordack; laboratory>
wait <press any key>
msg <|cl"What are you doing with my wand, you swine!"|cb Mordack waves his hands and his wand sails through the air and into his waiting hand.|n>
move <Mordack's wand2; inven room>
wait <press any key>
msg <|cl"You will be a hinderance no more!"|cb |nJust as Mordack begins to wave his wand...|n>
wait <press any key>
msg <|cg"Graham, I have just heard from Crispin and he will be on his way to help..."|cb|nIt was Cedric! He flew in through the laboratory windows.|n>
wait <press any key>
msg <At that moment, a ray of magic shoots from Mordack's wand and hits Cedric as he accidentally intercepted the path of the magic spell.|n>
wait <press any key>
msg <Cedric immediately turned to stone and fell to the floor.|n|cr"Cedric!"|cb shouted Graham.|n>
wait <press any key>
msg <Mordack waves his wand again but only a few sparkles fizzle through the end.|n|cl"What did you do to my wand? Do not under estimate my powers, little man..."|cb|n>
wait <press any key>
msg <Mordack waves his arms and suddenly his whole body begins to glow.|nGraham watched in awe and horror as Mordack started to grow and change into a large flying insect.|n>
wait <press any key>
msg <Mordack (as an insect) flies up to the upper level of the laboratory and hovers just above Graham.|nNow is the time for Graham to pull a trick or two out of his hat!|n>
property <Mordack; insect>

end define

define procedure <Wand on Mordack>
msg <Graham waves his wand and prepares to cast a spell from the large book from Mordack's library.|n>
wait <press any key>
choose <book>

end define

define procedure <end of story>
msg <Graham, in bewilderment, looks around the laboratory. Mordack's ashes smoke as the last of the burning ambers fizzle away.|n>
wait <press any key>
msg <He looks at poor Cedric lying on the floor of the laboratory and he looks at his family in the large glass jar.|n>
wait <press any key>
msg <As he ponders what to do next and how he would possibly get everyone home, a puff of smoke appeared behind Graham.|n>
wait <press any key>
say <|cl"Confound it...Oh wonderful. Graham, I'm glad to see you are still alive."|cb It was Crispin. Although he missed the show, hopefully he could help restore everything to normal.|n>
wait <press any key>

end define

define timer <mordack_appear>
interval <1>
action dec <mordack_appear; 1>
disabled
end define

define text <intro>

end define

define text <lose>

~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
Please try again. If you've saved the game, please restore by clicking "restore" in the lower righthand corner of the screen.
~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
end define

define text <win>

end define

define selection <book>
info <book>
choice <tiger> {
if property <Mordack; dragon> then {
msg <Graham casts the tiger spell on himself and he instantly changes into the form of a tiger.|n>
wait <press any key>
msg <Mordack (as the dragon) blows a gust of fire at Graham (as the tiger) and consumes him completely killing Graham quite quickly.|n>
timeroff <mordack_dragon>
wait <press any key>
msg <Maybe there is another spell that Graham should try.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
msg <Graham casts the tiger spell on himself changing him into the form of a tiger instantly.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham (as the tiger) and bites him quickly on the neck.|n>
timeroff <mordack_cobra>
wait <press any key>
msg <After a few moments, Graham falls to the floor dead.|n|nPerhaps there was another spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
msg <Graham cast the tiger spell on himself and his body changes into the form of a tiger instantly.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham (as the tiger) and consumes him quickly. |nIt does not take long for Graham to pass away.|n>
timeroff <mordack_fire>
wait <press any key>
msg <Perhaps there was a different spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; insect> then {
timeroff <mordack_insect>
msg <Graham casts the tiger spell on himself and he immediately changes form into a tiger.|n>
wait <press any key>
msg <Graham (as the tiger) begins jumping up on his hind legs and clawing at Mordack (as the insect).|n>
wait <press any key>
msg <|cl"Grrrrrrraaaahhhh!!!" |cbcries Mordack.|nMordack flies back down to the lower area of the laboratory and Graham jumps down ready to attack.|n>
wait <press any key>
msg <|cl"You think you're pretty smart, Graham...Let's see how you handle a little fire."|cb Mordack begins to grow very large and changes into a ferocious dragon.|n>
property <Mordack; not insect>
property <Mordack; dragon>
timeron <mordack_dragon>
}
}
choice <rabbit> {
if property <Mordack; insect> then {
msg <Graham casts the rabbit spell on himself and he immediately changes form into a rabbit.|n>
wait <press any key>
msg <Mordack (as the insect) swoops down on Graham (as the rabbit) and eats him whole.|n>
timeroff <mordack_insect>
wait <press any key>
msg <Perhaps there was another spell Graham could have used.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
msg <Graham casts the rabbit spell on himself changing him into the form of a rabbit instantly.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham (as the rabbit) and bites him quickly on the neck.|n>
timeroff <mordack_cobra>
wait <press any key>
msg <After a few moments, Graham falls to the floor dead.|n|nPerhaps there was another spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
msg <Graham cast the rabbit spell on himself and his body changes into the form of a rabbit instantly.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham (as the rabbit) and consumes him quickly. |nIt does not take long for Graham to pass away.|n>
timeroff <mordack_fire>
wait <press any key>
msg <Perhaps there was a different spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; dragon> then {
timeroff <mordack_dragon>
msg <Graham casts the rabbit spell on himself and he immediately changes form into a rabbit.|n>
wait <press any key>
msg <Mordack (as the dragon) begins blowing fireballs down at the floor. Graham (as the rabbit) easily hops out of harm's way with each blast.|n>
wait <press any key>
msg <|cl"Rrrooooaaarrr!"|cb Mordack is visually frustrated at Graham's trick. He begins to shrink down to a smaller size.|n>
wait <press any key>
msg <Mordack changed himself into a king cobra! He begins to slither towards Graham (as the rabbit).|n|cl"Let'sssss ssseee how you handle thissss..."|cb|n>
property <Mordack; not dragon>
property <Mordack; cobra>
timeron <mordack_cobra>
}
}
choice <weasel> {
if property <Mordack; insect> then {
msg <Graham casts the weasel spell on himself and he immediately changes form into a weasel.|n>
wait <press any key>
msg <Mordack (as the insect) swoops down on Graham (as the weasel) and eats him whole.|n>
timeroff <mordack_insect>
wait <press any key>
msg <Perhaps there was another spell Graham could have used.|n>
wait <press any key>
playerlose
}
if property <Mordack; dragon> then {
msg <Graham casts the weasel spell on himself and he instantly changes into the form of a weasel.|n>
wait <press any key>
msg <Mordack (as the dragon) blows a gust of fire at Graham (as the weasel) and consumes him completely killing Graham quite quickly.|n>
timeroff <mordack_dragon>
wait <press any key>
msg <Maybe there is another spell that Graham should try.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
msg <Graham cast the weasel spell on himself and his body changes into the form of a weasel instantly.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham (as the weasel) and consumes him quickly. |nIt does not take long for Graham to pass away.|n>
timeroff <mordack_fire>
wait <press any key>
msg <Perhaps there was a different spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
timeroff <mordack_cobra>
msg <Graham casts the weasel spell on himself changing him into the form of a weasel instantly.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham (as the weasel) and tries to bite at him.|n|nUsing quick weasel reflexes, Graham jumps up and bites the neck of the king cobra and shakes his head violently.|n>
wait <press any key>
msg <|cl"Aaahhh! Cursssessss!"|cb Mordack slithers away quickly.|n>
wait <press any key>
msg <|cl"Thisss isss the end of you, Graham!"|cb Mordack screams as he begins to change into a very real ring of fire across the floor surrounding Graham entirely.|n>
property <Mordack; not cobra>
property <Mordack; fire>
timeron <mordack_fire>
}
}
choice <rain> {
if property <Mordack; insect> then {
msg <Graham casts the rain spell on himself and a small rain cloud immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the insect) swoops down on Graham covered with rain and eats him whole.|n>
timeroff <mordack_insect>
wait <press any key>
msg <Perhaps there was another spell Graham could have used.|n>
wait <press any key>
playerlose
}
if property <Mordack; dragon> then {
msg <Graham casts the rain spell on himself and a small rain cloud immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the dragon) blows a gust of fire at Graham covered with rain but it was not enough to stop the dragon's fire.|nIt quickly consumes Graham and he dies.|n|n>
timeroff <mordack_dragon>
wait <press any key>
msg <Maybe there is another spell that Graham should try.|n>
wait <press any key>
playerlose
}
if property <Mordack; cobra> then {
msg <Graham casts the rain spell on himself and a small rain cloud immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the cobra) slithers up to Graham covered with rain and bites him quickly on the neck.|n>
timeroff <mordack_cobra>
wait <press any key>
msg <After a few moments, Graham falls to the floor dead.|n|nPerhaps there was another spell Graham could use.|n>
wait <press any key>
playerlose
}
if property <Mordack; fire> then {
timeroff <mordack_fire>
msg <Graham casts the rain spell on himself and a small rain cloud immediately appears over his head and begins to pour down heavy rain on Graham.|n>
wait <press any key>
msg <Mordack (as the fire) surrounds Graham and the rain pours down on both of them washing out the fire.|n>
wait <press any key>
msg <Mordack is gone! Graham has won!|n>
wait <press any key>
do <end of story>
}
}
end define