Sign in to follow this  
GlennNZ

How to build mission files.

Recommended Posts

I've been making a game which is of a style similar to Desert/Jungle Strike; the third person isometric helicopter shooter. We've made it 3D as a homebrew project for PSP. However, now that we can fly around and blow tanks and things up, I've gotten stuck as to how to proceed with certain aspects. There are two main problem: 1. What is the best way to load mission data 2. How do I structure the game (game engine) so that certain events in the game are responded to by certain actions as defined in the mission file. In regards to #1 I had this idea of constructing an XML file which described the mission, such as initial unit locations and positions, what structures were on the map, what the enemies' objectives were etc. That xml file would also describe what action to take if a certain event happened (#2). Say "building 1" gets blown up, then I want to play a one off audio clip when it happens. Basically, certain 'events' in the game need to be matched with an 'action' as defined in the mission file. It all got kind of messy when I tried to plan how to adapt my C++ code. I figured all events that happen in the game would 'broadcast' a message by sending what event had occurred and some accompanying data. Some mission object would listen to the events being broadcast, and respond to the ones that it cared about. The response would be the actions as defined in the xml. This then raised the question of how to represent the different actions in the xml because they tended to have different attributes. i.e. playing an audio clip required only a path to some audio, whereas, deploying a new unit to the map required unit name, position, orientation etc. Then I remembered about scripting and Lua. I don't want to risk investing too much time into Lua if it doesn't solve my current problems of defining mission files. Basically data to describe the mission is important for turning the game into a show and tell item into something that is slightly more meaningful. The problem is that no resources I've found about Lua have made a solution to my problem really obvious. Admittedly, I haven't invested too much time into it as yet, so I figured what better way to get some ideas from people other than the guys at work, than to post at GDNet. I hope that was all clear, basically I'm trying to find some better methods of defining missions, respond to game events, and whether scripting is the answer. Cheers

Share this post


Link to post
Share on other sites
One simple approach would be to make each level a single lua script, which initialises all the objects, and also sets up callback functions for events (object destroyed, time elapsed, ...). This should be simpler to implement than a hybrid C++/XML system, and gives you a little more flexibility.

Share this post


Link to post
Share on other sites
For the example you gave, I think the system is just C++ would be more then sufficient.

Also, you can send direct commands to the class, like PLAY_SOUND, or something, and simply give that call in the place in the code where the building blows up. You don't have to have the action class determine what to do, but even if you did, it doesnt seem that hard. Why bother with XML at all really?

Share this post


Link to post
Share on other sites

I was hoping to make it easier for non coders to make their own missions, thus I figured some kind of file parsing of structured data such as XML would be a good idea. It could just be a flat file. I'd rather not have to define mission objects in code.

I suppose events and actions made in response to events are all predefined. Meaning that the code to execute will be reused by different missions, although given different parameters. i.e. a PLAY_SOUND action is always executed the same, but it uses a different file to play.

I suppose the question is, what is the most appropriate way of a mission designer to specify what file to play?

[qoute]One simple approach would be to make each level a single lua script, which initialises all the objects, and also sets up callback functions for events (object destroyed, time elapsed, ...).[/quote]

Couldn't these callback just be defined in C++? After all, it's just the attributes given to the method that change. Or is this for more complex responses to events or perhaps a way of easily changing the response to an event without having to recompile the application?

Share this post


Link to post
Share on other sites

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