Creating NPC walk path across 8 rooms -- Planning/Design help

Started by johnny1finger, Fri 29/06/2012 21:38:51

Previous topic - Next topic

johnny1finger

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
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

EchosofNezhyt

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

Khris

You need to come up with a logic that decides which room the NPC is currently in, then use on_event/eEventBeforeFadein and check if NPC.Room == player.Room. If yes, call code that'll place them in the current room and send them off.

johnny1finger

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.

SMF spam blocked by CleanTalk