Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: johnny1finger on Fri 29/06/2012 21:38:51

Title: Creating NPC walk path across 8 rooms -- Planning/Design help
Post by: johnny1finger on Fri 29/06/2012 21:38:51
I'm needing to create a walk path for NPC that theoretically needs to span across 8 rooms.  Would it be possible to do this globally or would I have to code each path in each room?  For the coding, am I on the right track by using:
Code (AGS) Select
cChar1.Walk (100,100, eNoBlock); //start him walking
    cChar1A.AddWayPoint(230, 150); //add some more waypoints to his path
    cChar1.AddWayPoint(20, 120);


Thanks!
-j
Title: Re: Creating NPC walk path across 8 rooms
Post by: EchosofNezhyt on Fri 29/06/2012 22:03:04
Theres a module if I remember for making npcs cross rooms, Maybe you could check that code?

Edit: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28821.0
Title: Re: Creating NPC walk path across 8 rooms
Post by: Khris on Sat 30/06/2012 01:42:48
You need to come up with a logic that decides which room the NPC is currently in, then use on_event/eEventBeforeFadein (http://www.adventuregamestudio.co.uk/manual/TextScriptEvents.htm) and check if NPC.Room == player.Room. If yes, call code that'll place them in the current room and send them off.
Title: Re: Creating NPC walk path across 8 rooms -- Planning/Design help
Post by: johnny1finger on Sat 30/06/2012 04:45:32
Thanks for the help.  I'll definitely look into the plugin module.  I'm reading through the module manual now.  I'm sure it's mainly due to by inexperience, but it seems confusing at this point....I'm definitely up for the challenge and I'm taking it one line at a time.

@Khris:  Since my initial question was regarding doing this without a module, I have a follow up question.  I should have mentioned this before, but I do not need the NPCs to always show up in the same room as the player.  I wasn't sure if I could start them in a particular room and then have them follow a path through all 8 rooms and if the player enters a room where they would be located, then the player could interact.  I may not be thinking enough of of the box for the logic on this one.  I'm still sorting what's code logic and what's "perceived" logic, if that makes any sense.  :P

Again, since I'm, not familiar with using global scripts much, I wasn't sure if the logic would go there or if I had to build it in each room.  Would timers be a viable solution?

Here's my vision:
Map:
1
|
2-3-4-5-6-7-8

At game start, player will start in room5, NPC1 starts in room5 and NPC2 starts in room8.  Each room will have a single walk path that both NPCs will follow and only 1 NPC will be on screen with the player at any given time.  All rooms (1-8), will have a path so the NPC, in theory, will walk all 8 rooms.  As the player moves, depending on where the NPCs are in their 8-room "route", there may or may not be an available interaction between the player and NPC.  Also, if the player remains idle, in time, the player will see both NPCs walk through the current room as they follow their "circuit"/walk path.  Also, the NPCs will endlessly repeat their paths.

I'm open for any other suggestions and I'm not opposed to using the module if it looks like it will be the best solution, as long as there is nothing to worry about when the game is compiled and packaged.  Thanks to all for taking time to answer a planning-type question...hopefully it will help someone else as well.