Hello, all!
UPDATE: This didn't work out very well. See Pixie's guide here:
http://docs.textadventures.co.uk/quest/follower.html
EDIT:
Sorry, HK! I'll post the fix once I get it going. (Whatever I had going on interfered with the map, and I thought it best to take it down than risk causing anyone problems.)
awesome, thank you for posting this, will be of great help to a lot of people, we need a lot more public guides/libraries/codes for people to be able to use! As quest is such a good engine/software/program... but we've not made as many publically available guides/libraries/codes as we should have over the years.
Okay, I've got it working now.
Command Pattern:
ask #object1# to follow #object2#;tell #object1# to follow #object2#;#object1#, follow #object2#
script
if (not object2.gender = "it") {
if (HasAttribute(object1, "shadowing")) {
if (object1.shadowing = object2) {
if (object2 = player) {
msg (object1.alias + " doubles the effort to follow you.")
}
else {
msg (object1.alias + " doubles the effort to follow " + object2.alias + ".")
}
}
else {
object1b = object1
unfollow (object1, 0)
object1 = object1b
object1.shadowing = object2
if (object2 = player) {
msg (object1.alias + " begins to follow you.")
}
else {
msg (object1.alias + " begins to follow " + object2.alias + ".")
}
if (not (HasAttribute(object2, "followers"))) {
object2.followers = NewObjectList()
}
list add (object2.followers, object1)
}
}
else {
object1.shadowing = object2
if (object2 = player) {
msg (object1.alias + " begins to follow you.")
}
else {
msg (object1.alias + " begins to follow " + object2.alias + ".")
}
if (not HasAttribute(object2, "followers")) {
object2.followers = NewObjectList()
}
list add (object2.followers, object1)
}
}
else {
msg (object1.alias + " can't follow an inanimate object.")
}
Command Pattern:
ask #object1# to stop;ask #object1# to stay;ask #object1# to wait;#object1#, stay;#object1#, wait;#object1#, stop
script
if ((HasAttribute(object1, "shadowing"))) {
foreach (o, AllObjects()) {
if (HasAttribute(o, "followers")) {
msg (o)
msg (o.followers)
list remove (o.followers, object1)
}
}
if (object1.shadowing = player) {
msg ((GetDisplayName(object1)) + " stops following you.")
}
else {
// msg ("IS shadowing:")
// msg (object1.shadowing)
msg ((GetDisplayName(object1)) + " stops following " + GetDisplayName(object1.shadowing) + ".")
}
object1.shadowing = null
}
else {
msg ((CapFirst(object1.alias)) + " freezes in place.")
}
Script when entering a room
rh_last_room_shadowers
Turn script: followers THIS REQUIRES PATHLIB!!!
foreach (o, AllObjects()) {
if (HasAttribute(o, "shadowing")) {
npc = o
// msg (o)
targetroom = player.parent
if (npc.parent <> targetroom) {
list = PathLib_GetPath(npc.parent, targetroom)
if (list <> null) {
exit = list[0]
npc.parent = exit.to
if (npc.parent <> targetroom) {
msg ((CapFirst(GetDisplayName(npc))) +" is in "+(GetDisplayName(npc.parent))+", and headed your way.")
}
else {
diralias = ReverseDirection(exit.alias)
if (diralias = "out") {
msg (GetDisplayName(npc) + " arrives from the outside.")
}
else if (diralias = "in") {
msg (GetDisplayName(npc) + " arrives from the inside.")
}
else if (diralias = "up") {
msg (GetDisplayName(npc) + " arrives from above.")
}
else if (diralias = "down") {
msg (GetDisplayName(npc) + " arrives from below.")
}
else {
msg (GetDisplayName(npc) + " arrives from the " + diralias + ".")
}
}
}
}
}
}
turn script: followers_entering
foreach (o, AllObjects()) {
if (HasAttribute(o, "shadowing")) {
if (not o.lastroom = player.lastroom) {
msg ("Different last room. " + o)
}
}
}
Here's a link to PathLib. (This is the file I'm using with these scripts.)
I can't remember if I altered Jay's library or not.
Here's the link to the original PathLib source: http://textadventures.co.uk/forum/samples/topic/3214/path-library
Here's a link to my port in progress. I haven't copied over all the details of the game yet, but the followers do follow you correctly.
NOTE: You'll probably see testing messages print occasionally.
http://textadventures.co.uk/games/view/rr9vezzxkeaovamsaqgxcw/they-call-ya-mister-quest-prototype-in-progress
Here's the original, complete version: http://textadventures.co.uk/games/view/ktujzrqu90akwfqz4uarnw/they-call-ya-mister-original-glulx-version