Patrolling Character.

Sorry for yet...another post...by me. But if you guys still want to help me out I'm thankful anyways ^^".

So I want to make a character who patrols rooms akin to this: A-B-C. They would go from A to B, B to C, C back to B, B back to A...and then repeat, always in this order. And maybe they stay in a room for like 20 seconds? So would it be a 20 seconds timer with if statements on where his location is? But how would he know to go from B to C, and then later, from B to A?

(I would also add a approach verb which would lead to a switch script that gives different outputs depending on where he is but I can do that by myself...now that I was helped before on switches).

What do you guys think would be the best way to do something like this?


So I want to make a character who patrols rooms akin to this: A-B-C. They would go from A to B, B to C, C back to B, B back to A...and then repeat, always in this order. And maybe they stay in a room for like 20 seconds? So would it be a 20 seconds timer with if statements on where his location is? But how would he know to go from B to C, and then later, from B to A?

I believe the simplest way would be to make a list of the rooms you want him to go through. In your case, the list would be something like A, B, C, B.
Each time he moves. the character takes the first element off the list, moves to that room, and puts it onto the end of the list again.

So your script would be something like:

destination = ListItem (npc.route, 0)
list remove (npc.route, destination)
MoveObject (npc, destination)
list add (npc.route, destination)

(assuming that your NPC object's name is npc, and it has an objectlist attribute named route.

I'm not sure how easy it is to create objectlist attributes in the desktop version of quest. In the web editor, you would need to put a script like this in his initialisation script:

this.route = NewObjectList()
foreach (room, Split("A;B;C;B")) {
  list add (this.route, GetObject (room)
}

mrangel is super smart and a genius coder but... here is another thought that may be helpful to you if, perchance, you code like me...

https://textadventures.co.uk/games/view/AzKg8NtdWEivkNDr5J-ycg/quest-text-adventure-tutorials-and-templates

Go to “Quest Tutorials and Templates” and download that. Play it, click change rooms, 6, 3. That will give you an example and a walkthrough on how I had a patrolling character covering three rooms. I did not try and explain it ‘in game’ with an ‘explain room’ response because the explanation, I believe, was more difficult to understand than actually seeing it in the GUI. If you want to pursue this option and don’t understand it, let me know. If not, my feelings will only be slightly hurt. Haha. Good luck and happy gaming!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums