Is it possible to make an NPC that can follow throughout a game from room to room?
' "NPC Follower Demo"
' Created with QDK Pro 3.52
!include <Typelib.qlb>
define game <NPC Follower Demo>
asl-version <350>
gametype singleplayer
start <kitchen>
game author <Your Name>
game version <1.0>
game copyright <© 2004 ...>
game info <Extra Info>
afterturn doaction <fluffy;following>
end define
define synonyms
end define
define room <kitchen>
look <a normal kitchen>
north <hall>
define object <fluffy>
type <TLTobject>
type <TLTactor>
properties <displaytype=cat; not takeable>
action <following> {
if flag <cat_following> and ( $locationof(fluffy)$ <> #quest.currentroom# ) then {
move <fluffy;#quest.currentroom#>
msg <Fluffy has followed you and is miaowing for attention.>
}
}
action <speak> {
flag on <cat_following>
msg <Fluffy miaows back at you... Cats are not great conversationalists>
}
end define
end define
define room <hall>
look <a normal hall>
north <lounge>
south <kitchen>
end define
define room <lounge>
look <a normal lounge>
south <hall>
end define
define text <intro>
Enter intro text here
end define
define text <win>
Enter win text here
end define
define text <lose>
Enter lose text here
end defineI can't get the cat to do anything. I can walk out and he doesn't follow. I can pick him up and carry him out but that kills the point of what I was testing.
What command makes him do something?
' "King's Quest V - text adventure"
' Created with QDK 3.52 - UNREGISTERED VERSION
!include <Typelib.qlb>
define game <King's Quest V - text adventure>
asl-version <350>
gametype singleplayer
start <Crispin's house -out front>
game author <Steve Lingle>
game info <Created with QDK 3.52 - UNREGISTERED EVALUATION VERSION.>
startscript do <start>
end define
define synonyms
take = get
end define
define room <Crispin's house -out front>
look <To the south you can almost make out a small town.>
indescription <You are at>
south <Town Path>
script msg <After a lengthy discussion with the great wizard, Crispinopher (Crispin for short), you set off on your quest to find your family. Accompanying you is Cedric, the wise-cracking owl, who will guide you occasionally. You were given only two items, a worn out magic wand and a bite of magical white snake (that you've already eaten) which helps you to understand the language of nature and animals. >
end define
define room <Town Path>
alias <town path>
look <A single stream of sunlight parts the branches and barely illuminates the dirt path before you. You come upon a dirt road intersection that goes in different directions. To the west, is another path that winds into the forest. To the south, you can definitely make out the activity of the town. To the east, a path leads up into the mountains but a rattlesnake seems to be blocking your path.>
indescription <You are on the>
north <Crispin's house -out front>
script {
flag on <snake>
if flag <snake> then {
say <|clLook out for that snake, Graham!|cb>
msg <says Cedric as he lands on a nearby tree branch.>
}
}
define object <rattlesnake>
alt <snake>
look <A rattlesnake eyes you as you walk by.>
take msg <That could be dangerous, Graham!>
speak <"Move, snake!" You yell out. The snake seems unintimidated by your meager attempts at frightening it.>
examine <This snake seems to be set on holding its ground. If there were only some way to frighten it off the path.>
prefix <a>
displaytype <reptile>
article <it>
end define
end define
define room <inven room>
define object <Cedric>
alt <owl; bird>
type <TLTobject>
type <TLTactor>
properties <displaytype=owl; not takeable>
action <following> {
if flag <cedric_following> and ( $locationof(Cedric)$ <> #quest.currentroom# ) then {
move <Cedric; #quest.currentroom#>
}
}
action <speak> {
do <cedric>
}
end define
end define
define procedure <cedric>
if ( #quest.currentroom# = Crispin's house -out front ) then say <|clGraham, why don't you try the town to the south? I'd hate to get lost in the forest to the west.|cb>
if ( #quest.currentroom# = Town Path ) then say <|clThere must be |isome|xi way to scare that snake away. For now, we could still move on towards the town further south.|cb>
end define
define procedure <start>
move <Cedric; Crispin's house -out front>
flag on <cedric_following>
end define
define text <intro>
end define
define text <win>
end define
define text <lose>
end define