Wandering NPC

SteveYoungWork
Hi, I just bought Quest Pro Home edition, after creating some test games with it , which was very easy to do ( I was a programmer 15 years ago, so I not opposed to a bit of scripting). I have now decided to write a small adventure (15-20 rooms), I have sorted the plot and created the puzzles. But I am determined to do a good job. so before I can get realy stuck in.

I have one big question. How do I creat a wandering NPC?

I have had a look at some of the examples on the forums about following npcs, and had a peek the the manual. Any help would be appreaciated.

Steve

Anonymous
Hi Steve

Look back at this forum - round about Nov 10th last year myself and a few others covered moving NPC's in some detail under a heading of "following NPC's".

Wandering (randomly or to a prescribed path) and following are not QUITE the same, but close enough for you to be able to find out what you need.

If you are still stuck, post again and I (or someone else) will knock up a wandering NPC demo for you.


Al (MaDbRiT)

SteveYoungWork
Thanks for the help,

Found the post quite intresting, but does not completely answer my question. ( and will be playing with it tonight)

I can figure out how to move object, but how can you make an object go into a exit ( randomly) from a room.

:)

Anonymous
Hi Steve

Found the post quite intresting, but does not completely answer my question. ( and will be playing with it tonight)

I can figure out how to move object, but how can you make an object go into a exit ( randomly) from a room.



That is a little bit trickier, but quite do-able (my favourite NPC the cat has featured in a demo to do exactly this but I couldn't find the link offhand.)

I'll dig out the code from my home PC later this evening, time permitting.

Al (MaDbRiT)

SteveYoungWork
Thanks for responding quickly, you guys are very helpful.

When I get up to scratch I hope I can return the favour.


Steve

Anonymous
Would it be easier to simply have a routine in the afterturn that uses random numbers to move a character into or out of the room the player is in?

SteveYoungWork
Thanks, but I dont know how to do it.

I am wanting to make a proptery in a object (NPC, character, monster ect) called "movetype" if it is set to "wander" the NPC would random pick a exit to leave by.

xordevoreaux
I realize this is an ancient topic but the topic title was a good one.

I was trying this very same thing today through the 4.1.2 GUI and realized I had to craft a way for this to happen. I downloaded Adrift, created a rodent, set up 3 rooms, put the rooms in the same "room group", pointed the movement of the rodent to the room group, done. No coding. The rodent moved between the three rooms on his own. I was elated. How easy! It was turn-based, rather than timed, but this was SO ridiculously easy to set up (less than 15 minutes). I wish it was that easy in Quest. There should be a way to define a zone of rooms (I tried using a timer, and zone = 1, zone = 2 as properties) and then have the rat move across through the zone any which way, but then I got into the whole let's find the exits business and having to test for the zone property, and I'm not an ASL programming expert and don't want to become one, I'm all GUI and want to stay that way. If it's that simple in Adrift to set up a wandering PC exclusively through its GUI, how great it'd be to be able to do so in Quest, so I guess this post is for two feature requests. One, zones - think of them as a container of rooms, and then a way to create an npc, drop it in the zone, or point a movement property of the npc to the zone, and say ok buddy, start wandering.

xordevoreaux
Ok, I got the following to work. Basically, the timer does not check for exits. Rather, I strung together some rooms, and so knew that room one somehow connected to 2, 2 connected to 3, etc. The two end rooms have no where to go but one direction, but for the middle rooms, I randomize the direction as one connected room or the other. It's one specific npc moving through a specific list of rooms in a specifc way and making assumptions that the rooms are still connected together at run-time (in that I have not, for example, made room 3 no longer go to room 2, etc.). It's not the best solution by far I'm sure, isn't at all versatile, but I did it completely through the GUI and it works. Haven't tested whether the "scamper away" message shows up but not my concern right now.

' "x"
' Created with QDK Pro 4.1.2

!include <stdverbs.lib>

define game <x>
asl-version <410>
start <start>
game info <Created with QDK Pro 4.1.2>
end define

define options
debug on
panes on
abbreviations on
end define

define room <graveyard>
end define

define room <start>
south <zone_01_room_01>
end define

define room <zone_01_room_01>
alias <zone_01_room_01>
north <start>
east <zone_01_room_02>
end define

define room <zone_01_room_02>
alias <zone_01_room_02>
east <zone_01_room_03>
west <zone_01_room_01>
end define

define room <zone_01_room_03>
alias <zone_01_room_03>
south <zone_01_room_04>
west <zone_01_room_02>
end define

define room <zone_01_room_04>
alias <zone_01_room_04>
north <zone_01_room_03>
southeast <zone_01_room_05>
end define

define room <zone_01_room_05>
alias <zone_01_room_05>
northwest <zone_01_room_04>

define object <npc_rat_1>
displaytype <Object>
article <it>
gender <it>
properties <room = zone_01_room_05>
end define

end define

define timer <movement_npc_rat_1>
interval <10>
action {
if here <npc_rat_1> then msg <A rat scampers away.>
select case <$locationof(npc_rat_1)$> {
case <zone_01_room_05> move <npc_rat_1; zone_01_room_04>
case <zone_01_room_04> if ( $rand(0; 1)$ = 0 ) then move <npc_rat_1; zone_01_room_05> else move <npc_rat_1; zone_01_room_03>
case <zone_01_room_03> if ( $rand(0; 1)$ = 0 ) then move <npc_rat_1; zone_01_room_02> else move <npc_rat_1; zone_01_room_04>
case <zone_01_room_02> if ( $rand(0; 1)$ = 0 ) then move <npc_rat_1; zone_01_room_01> else move <npc_rat_1; zone_01_room_03>
case <zone_01_room_01> move <npc_rat_1; zone_01_room_02>
}
}
enabled
end define

xordevoreaux
I also now have it where the description on the case statement correctly identifies when the rat is both entering and leaving the current room.


' "x"
' Created with QDK Pro 4.1.2

!include <stdverbs.lib>

define game <x>
asl-version <410>
start <start>
game info <Created with QDK Pro 4.1.2>
end define

define options
debug on
panes on
abbreviations on
end define

define room <graveyard>
end define

define room <start>
south <zone_01_room_01>
end define

define room <zone_01_room_01>
alias <zone_01_room_01>
north <start>
east <zone_01_room_02>
end define

define room <zone_01_room_02>
alias <zone_01_room_02>
east <zone_01_room_03>
west <zone_01_room_01>
end define

define room <zone_01_room_03>
alias <zone_01_room_03>
south <zone_01_room_04>
west <zone_01_room_02>
end define

define room <zone_01_room_04>
alias <zone_01_room_04>
north <zone_01_room_03>
southeast <zone_01_room_05>
end define

define room <zone_01_room_05>
alias <zone_01_room_05>
northwest <zone_01_room_04>

define object <npc_rat_1>
alias <rat>
prefix <a>
displaytype <Object>
article <it>
gender <it>
end define

end define

define timer <movement_npc_rat_1>
interval <10>
action {
if here <npc_rat_1> then msg <A rat scampers away.>
select case <$locationof(npc_rat_1)$> {
case <zone_01_room_05> {
move <npc_rat_1; zone_01_room_04>
if here <npc_rat_1> then msg <A rat suddenly scampers into the room!>}
case <zone_01_room_04> if ( $rand(0; 1)$ = 0 ) then move <npc_rat_1; zone_01_room_05> else move <npc_rat_1; zone_01_room_03>
case <zone_01_room_03> if ( $rand(0; 1)$ = 0 ) then move <npc_rat_1; zone_01_room_02> else move <npc_rat_1; zone_01_room_04>
case <zone_01_room_02> if ( $rand(0; 1)$ = 0 ) then move <npc_rat_1; zone_01_room_01> else move <npc_rat_1; zone_01_room_03>
case <zone_01_room_01> move <npc_rat_1; zone_01_room_02>
}
if here <npc_rat_1> then msg <A rat suddenly scampers into the room!>
}
enabled
end define

xordevoreaux
I got rid of the redundant "scampers" message, only one needed to be in there.

Is there a gui-genned way of doing what I did that would be more versatile, more generic?

cole
I didn't find any other post where I could add this so I hope it's ok that I revive one that's a little older.

This is a system with which a NPC will wander around the rooms you tell him to. You will have to add the room names one by one to a certain attribute of a NPC though. How to add them to the attribute and to which one is explained in a "help" command in the attached file named "NPC movement (specify rooms)".
I also did something similar to this in another file whereby you don't specify the rooms the NPC wonders around in, but rather the exits he is not allowed to go through. That might be easier than specifying the rooms if, say for example, a monster is supposed to wander around everywhere on the map except for a city. I will attach this file named "NPC movement (exclude exits)" as well.

This is all done in the GUI so people like me who have no clue programming can still use the system and understand it. My question is has somebody already a system like this done only with the GUI and if so is it by any chance easier to use than mine which seems rather inconvenient? Meaning is there a system (for the most recent Quest version) that uses easily set up zones in which a NPC can wonder around in? I did find something about zones, but it wasn't done through the GUI and it seemed to be for an older version of Quest.

Thanks for your help in advance.

jaynabonne
I would post this in the "Libraries and Code Samples" forum. That's the place for something like this. :) Sounds interesting!

cole
This is some code with which I solved the problem of not having zones. I guess other people made something like it before, but funny enough most of what I found is just written code. So what I did here is solely done with the GUI.

Basically you just create a room and give it a name like "City". That will be the zone in which you just put all the rooms that are supposed to be in the "City". Now you just have to give the NPC that is supposed to move in that zone a certain attribute and type in the name of the zone (i.e. "City"). If you wish you can also have subzones within zones. Everything is properly explained in a command called "Help" within the downloadable file.

Entropic Pen
Wow! It works like a charm! I used the Specify Rooms example in a side-project I'm working on and it works fantastic!

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

Support

Forums