how to move an npc from room to room????

Nateboy30
07 Jul 2015, 06:00
Ok, so I was wondering if anyone could tell me how to move my NPC character from room to room in my ga me and if I can, is there a way I can make him switch what room he is in after a certain length of time (ex. He starts in room 1 then after 30 seconds move to room 2 and then after 30 more seconds to room 3 and so on...

If you can help I will be grateful! :D :D :D

HegemonKhan
07 Jul 2015, 06:25
for moving your NPC: do you want to randomly move him~her~it around, or do you want the NPC to follow you (or someone ~ something else), or move around based upon some other determination method (for example, on 'monday' the NPC is at school, on 'saturday' the NPC is at a club) ???

you can use real time (via Timers), but it's really messy for you and people playing the game, to get it all right and working correctly and practically~reasonably. As such, it's better to use Turnscripts and~or a String Attribute or an Integer Attribute.

determining the movement is the tricky~advanced part of this stuff. As even just doing: room1->room2->room3, is quite a bit tricky, especially for people new to quest and~or especially coding.

how to just move the NPC to another specific room isn't too difficult, in the GUI~Editor:

run a~as script -> objects -> ~ 'move object' Script -> (setting it up should be self-explanatory: choose the 'moving object' and the 'destination object' )

but determining the movement (the sequence of rooms that you'll be moving to), as I said above is the tricky part.

---------

I'll get into the actual specifics (how to actually do this stuff), once you post what~how you want this stuff done.

Nateboy30
07 Jul 2015, 14:59
What I want the NPC to so is be able to randomly appear in certain rooms in the game and the be able to switch rooms as they please to surprise the people playing my game and also add an element of suspense. That is why I am trying to get them to cycle through different rooms.

adammadam
07 Jul 2015, 17:47
set a timer for 30 seconds or whatever. Give the NPC an attribute set to integer and just call it "room" or whatever you want. Then for the timer, have a new script set variable or attribute, set the "room" attribute to a random number say between 1-10. Then after that have if attribute equals.. if npc.room = 1 move object npc to kitchen, it it equals 2 move them to the lounge etc.

adammadam
07 Jul 2015, 17:50
so the things you have to do is give the npc a new attribute and set it to integer. Add a new timer. To the timer add a script - set variable or attribute and where it says "expression" click on that and change it to random number. Then use an if script and have if attribute equals. Then use move object.
I hope you can figure that out from my instructions.

jaynabonne
07 Jul 2015, 18:29
A note: just moving an NPC into a room doesn't do much on screen. You will probably want to have some text printed as well like, "The guard wanders into the room" or something. Otherwise, unless the player actually looks, nothing will change for them no matter where the NPC is.

HegemonKhan
07 Jul 2015, 21:33
in the Timer's 'script', this is how you'd assign a random number to an Integer Attribute:

run as script -> add a~new script -> variables -> 'set a variable or attribute' Script -> (see below)

// using 'room' for the Integer Attribute's name as Adammadam gave for example (I would use some other word for the Integer Attribute's name, and not room, but I guess it's okay to use ~ hopefully it won't cause any problems~conflicts)
// the example below is using 'npc' as the Object's name, so you may not be using 'npc' if that's not your npc Object's name.
// an example below: http://docs.textadventures.co.uk/quest/ ... omint.html ~ GetRandomInt (min_Value, max_Value)

set variable npc.room = [expression] GetRandomInt (1,10)

----

now add the rest of the scripts (still within the Timer):

if (npc.room = 1), move player to castle, and a message... 'the npc has suddenly appeared in the castle', as Jay pointed out
else if (npc.room = 2), move player to forest, and a message... 'the npc has suddenlu appeared in the forest', as Jay pointed out
etc etc etc 'else ifs'
else if (npc.room = 10), move player to dungeon, and a message... 'the npc has suddenlu appeared in the dungeon', as Jay pointed out