• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Roderik

NPC-Schedules in a simple RPG (Ultima 5-6 like)

6 posts in this topic

Hi all! I''m currently trying to program a pretty simple RPG, with an engine similar to those of Ultima 5 or 6. Now my question is, how could I implement NPC-Schedules such as in those games, which basically only consits of having the NPCs move to different spots of the map at different times of the day? I have already got a couple of ideas how to do it, but I want to hear what the pros have got to say to it, basically what I need are some simple, but effective shortest-path algorithms and a way to store what the NPCs have to do at different times of the day. However, the solution should be a simple one, no neural nets (whatever those may be), after all I''m quite new to programing...
0

Share this post


Link to post
Share on other sites
It''s not too difficult to do, just give each NPC a schedule(a list of times of the day and where they should be and what they should be doing) and use a combination of A* path finding and predefined paths (that is: use A* to get the NPC to the appropriate starting point of the predefined path then let that path take over)
0

Share this post


Link to post
Share on other sites
In a more general sense your NPC''s should have an event handler. Basically you can give them triggers or events with a condition/action structure that the main AI loop checks every x loops (no need to do it every frame for every NPC for every AI function).
For instance the condition could be
If it is midday
(and the action)
Go to the pub for lunch.

That way it''s possible to add more variable scripts to the NPC''s everyday actions and incorporate the everyday schedules into a system that handles all your automated AI needs.

The same method could then be used to decide the NPC''s actions in another situation such as a fight or in other character NPC interaction.

Mike
0

Share this post


Link to post
Share on other sites
This may already be obvious to the original poster, but I''ll say it for the benefit of any newbies here...

If your AI is mainly based on daily routines, you may want to consider implementing a really basic scripting language to store the schedules. That way, you can test new schedules without recompiling, which saves time and allows friends/co-workers to do the AI routines for you, if you wanted.

For example, you might want to implement 3 basic commands to begin with:
GOTO (x-coordinate, y-coordinate)
SLEEP
WAKE

Each NPC could have a separate file (or section of a file) which lists the time of day in hours, followed by the command (including any parameters). For example:
------
6
WAKE
7
GOTO 10 20
11
GOTO 30 40
12
EAT
13
GOTO 10 20
20
GOTO 0 0
21
SLEEP
-----
Imagine location (0,0) on your map is the NPC''s bed, (10,20) is his workplace, (30,40) is where he eats.

Simply read it in a line at a time, first getting the time, then getting the command. Decide what command it is, get the parameters, and store that with your NPC somehow. (A member variable of your NPC class/struct like Task* TaskList[HOURS_IN_DAY] would suffice to begin with.) When a certain time of day comes (checking once per game-hour is usually enough), check your active NPCs to see if they have a new task yet, if so, plot the paths or whatever and set the new state. It doesn''t take much effort to allow more than 1 task per hour, or tasks that trigger on other events rather than the time of day, but the above is a good starter point if you are totally lost or new to all this.

Hope that helps someone.
0

Share this post


Link to post
Share on other sites
In the previous replies it was assumed by all that all characters should be simulated at all times. But this has not have to be so. You can choose only to simulate a subset of the NPCs, such as those those that are close to the PCs. This is done in many contemporary games to save CPU cycles.

Then a simple way of making a daily schedule is to simple to "teleport" characters around by simply charing their coordinates. This should naturally only be done if the PCs are not nearby or the player will be confused.

This solution is not realistic in anyway but is simple to implement and requires very little computing power.

B.Sc. Jacob Marner
Graduate Student of Computer Science, The University of Copenhagen, Denmark.
http://fp.image.dk/fpelisjac/rolemaker/


0

Share this post


Link to post
Share on other sites
What felonius said makes sense, it saves on CPU cycles, which basically means you can create even more complex behaviour.

Just be careful of how you define what is close to the PC. I''ve ran into numerous games where I am following somebody, and they slip out of my line of sight for a moment, and then as I step back into a position where I should be able to see them, they are gone!

You may wish to have people disappear at key locals, such as in a busy market, a tavern, or in their private house. That way if the PC simply loses them, they may just think they got lost in the crowd.
0

Share this post


Link to post
Share on other sites
Generally it''s a good idea to process game mechanics for a region slightly bigger than the visible screen. Slightly being as little as possible but as much as necessary for realism and continuity. Whenever possible don''t bother processing AI for NPC''s but you''ve got to remember that, if you take this approach, you''ve also got to have a method of replacing characters in the right place at the right time. A small piece of processing that calculates which characters would be in a given region at a given time based on the scripts would become necessary.
Of course, this level of realism may be totally pointless for all but a few key NPC''s but it''s worth keeping in mind.
For instance, if you remove the baker because they''re off-screen, you''ve got to remember where to replace them so the player can/can''t buy a loaf of bread later. If you let the baker walk off the screen North of the player and the player then walks south back to the bakers to find them behind the counter again this can only detract from the level of immersion of the player and that''s a big chunk of what roleplaying games are all about.

Mike
0

Share this post


Link to post
Share on other sites