Sign in to follow this  

events in games

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

does anyone know how to efficiently store events that are done or how professional games do it? for example, say when u enter a map for the first time in an 2d rpg game, some guy comes up to you and talks to u. when u exit the map and come back to the map again, how would disable the event from happening again? i thought of using a array of boolean eventsDone[] to store event that have been done, but that seem inefficient. so how do u do it? how does games like final fantasy and chrono trigger keep track of events?

Share this post


Link to post
Share on other sites
You could first make the problem more generic...

Instead of having small actions, look at it from the bigger
scale: a questsystem.

You have several quests
- some are active
- others are waiting for pre-conditions to be fulfulled
- some are completed (or maybe even failed)

The most interesting are 'active' quests, since their state
determines what will happen next. Assume a person is standing
there with a dialog (which the questsystem 'told' him he should
have. We click on him and can choose a reply (eg accept/cancel).

This will put the quest into a new state, which will determine
what happens next (maybe this means npc #2 now has a dialog),
and what special actions other npc's get (or maybe the first
npc just gets a new dialog).


Share this post


Link to post
Share on other sites
In my last project that needed events, I did it with a list that the player holds onto. Each event that occured had a name, and a state value, and was just kept in a linked list. In the case you are talking about, instead of removing the event from happening in the future, you instead keep track that the event happened with an entry in the list like "Talked to Edgar" for when you talked to edgar about your new quest, with a state value of 1 [you did indeed talk to edgar].

When you load up a new map, in the map file you have a list of events that control the map being loaded. Edgar's speech tree will be different when edgar is made, since the map that generates him will search for the "Talked to edgar" event upon creation, and generate the correct edgar with the correct speech tree.

The events would be saved in the list format when the game is saved, so it carries over [similar to saving an inventory]. Since the events are checked on map creation, you don't have to worry THAT much about efficiency, since it'll be in the map load screen anyway. When the town no longer is concerned [like when it gets blown up by enemy forces or something, as the story progresses], THAT event triggers deletion of the "Talked to Edgar" event, and instead adds the "Town blown up" event. So when you load the town next, the town is in ruins :P

It was butt ugly to code the first time around, but it worked pretty smoothly [dunno how the pro's do it, but thats how I did it, and I'm no pro]. Included my little scripting language and everything :P

Share this post


Link to post
Share on other sites
I would suggest that you build your quests based on a tree structure. This will allow for some branching and different ways of getting things done, this as allows for you to walk the tree for the different events.

theTroll

Share this post


Link to post
Share on other sites
A reminder when creating the events. could be stored as behaviors that begin when the player reaches certain areas of the game. dont know if that was what you all ment but just trying to help you out.

Share this post


Link to post
Share on other sites
You should be able to find what you are looking for with a little googling, I can help you find what you need if you let me know what langague you are working in. This is a site I found that might get you going in the right direction.

http://ai-depot.com/Tutorial/DecisionTrees.html

theTroll

Share this post


Link to post
Share on other sites
Here are a few I found:

http://www.gamedev.net/reference/articles/article2192.asp
http://en.wikipedia.org/wiki/Tree_(data_structure)


Well that should give you something to start with.

theTroll

Share this post


Link to post
Share on other sites
I've never finished a complete RPG but, I did this pretty easily using a scripting language.

Basically, I had scripts for each entity in my game that would get triggered when something would happen in game. For example, I had a "near" script. Whenever I got near something, their near script would get run. The near script could check stuff to see what the entity should do (if anything). I also had an stl map for each entity that represented their memory.

Share this post


Link to post
Share on other sites

This topic is 4245 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this