events in games

Started by
9 comments, last by lazE 18 years ago
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?
Advertisement
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).


visit my website at www.kalmiya.com
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
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
does anyone know any website that shows how to create a tree events?
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.
Kewl Softwarez -Time is what you make of it.
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
i am working on c++
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
thanks a lot everyone. helped a lot. thanks for the website TheTroll

This topic is closed to new replies.

Advertisement