how are game events processed?

BlitzMax Forums/BlitzMax Programming/how are game events processed?

KamaShin(Posted 2005) [#1]
Since i'm planning on making an rpg with a quest/map/chara/animations editor, I was wondering how events are processed in such games: let me explain a bit more where i'm getting stucked:
My main loop looks something like this:

LoadEverything() //loads graphics,sounds,musics,chara,map and so on...

While not EndOfGame() //test various cases of possible end of game

MovePlayer()
MoveNPCs()
HandleEnnemies()
ProcessEvents() ??
Cls
DrawEverything()
Flip

Wend

the problem here is what should be inside the ProcessEvents() method... Because there can be 1 or 2 or more event to be processed at the same time, they will all have a beginning and an end (for instance, one event could be "move this NPC toward player until it reaches it and then display this dialogu..." the event stops when the dialogu ends... but it dosn't prevent the player from moving nor does it prevent other event from launching... on the other side, another event could be StopMusic or changeMusic...) My question is how can I deal with all those kind of events in one method (well it can be separated in several call to many other methods but it s almost the same)?
I was thinking of maybe making things go in threads... one thread by event but I m not sure if it s a good idea or not, I don t know much about thread...
Any experienced programmer that could share a bit of his knowledge here?
I have a veeeeeeeeery small and tiny experience in script coding so I 'd like another solution that having a whole script language developped for the event editor/interpreter. I already thought of using BMAx's LUA scripting ability but even like this I don't see how I could write some script that would allow what I described for the events...
HELP!!!!


TartanTangerine (was Indiepath)(Posted 2005) [#2]
Look up "Finite State Machines".


Cajun17(Posted 2005) [#3]
I'm working on an RPG as well (2 actually) and I don't have every little detail worked out, but here's how it works more or less in theory.

Each map has a list of events than can be in 1 of 3 states; ACTIVE (able to be ran), RUNNING, or NONACTIVE. Every game loop check to see which events are running and process them and also check to see if any active ones should be ran. I keep the lists separate for the sake of speed.

It helps to think of them as objects that preform actions rather than events or something that happens to objects. All my NPCs are events for example.

Edit: Using a scripting language can be helpful. I myself am using lua, but using a scripting language won't automatically make it fall into place. It just help the development process go a little smoother if you know what you're doing. I may or may not know what I'm doing... we'll see in after a little while i guess.


KamaShin(Posted 2005) [#4]
yep, I think I m going to do something like this except for the NPCs which will be a bit different... I also thought of making an event a list of small actions that should be processed sequentially... Events will have a few caracteristics like IsBloquant which would mean: if true everything is stopped until end of event, if false it is processed like a thread, bit by bit each time the main loop is processed until it dies... also there ill be a caracteristic telling the number of time the event can be triggered... and so on :)
thanks for the answers... I m not completely sure how it's gonna work but I sure got something to start working on here :)