Archived

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

Codejoy

Designing good data structs...

Recommended Posts

So I am attempting another game, and i have a solid engine and the rest is flowing well, but for some reason there are some data structs I just cannot seem to come up with. I am not that adept at classes yet so hence using structs. I was curious what the best theory for designing data structs is, obviously figure out the data you need to model etc... but for some reason im drawing a blank on how to handle missions in my space flight sim. There are two types of missions, linear (for the story) and random missions you get from resupplying at planets, talking to NPC''s and running across other triggers, but I havent a clue how to model that... I mean I just was curious if anyone had some ideas on where I could start in modeling this type of data because as of now I have yet to come up with a good implmentation that I like. The game is alike a space action RPG basically diablo II in space with a bit more open-endeness. My original idea for the mission structs was to allow the player to have one linear mission and one random mission at any given time. The mission types are: Destroy a group of "somethings" Escort a group of "Somethings" Trade goods from point A to point B (And sometimes c d e f...) talk to person x, y z etc... So I was going to have just a global struct of two types, one is the linear mission struct and the other is a regular mission struct. Then each object in the game has a flag if its a mission sensitive object or not, if it is the code checks to see whats in the mission structs, (the flag is actually an ID into the mission struct) if this flag id is correct for whats currently in the struct, then the object interacts with you in a mission specific way, if it doesnt match, it gives a generic reaction (or isnt even there because it wasnt spawned because you didnt get the proper mission to spawn the group or what not.) Hmm I hope this isn''t too confusing, id postthe data structs I have so far but afraid that wouldn''t help much either. Just any ideas on where to start and the best way to go about designing such structs for this game would be great. I have a design doc, but everytime I think its complete...I found out there is something I forgot to think about etc.. (which is good that I catch it) but it really makes nailing down the data requirements hard. I mean i could alleviate most the problmes if i wanted to hardcode EVERYTHING but i sorta wanted to load some stuff from files etc... Well early thanks to anyone who takes the time to help in anyway... -Shane

Share this post


Link to post
Share on other sites
I''ve always thought that "goal" structures were a great application for polymorphism and virtual classes. Basically, you have a basic virtual Mission class, with functions that get information about the mission, a function that sees if the mission has succeeded, one that sees if the mission has failed, etc. Then you have subclasses like MissionEscort and MissionDestroy, which fill those out.

Unfortunately, that''s getting towards the advanced side of data structures and classes. So a simpler solution might be more to your benefit.



Don''t listen to me. I''ve had too much coffee.

Share this post


Link to post
Share on other sites
Well I am never opposed to learning something new and especially implementing it. The thing is, that would require me sitting down,learning, understanding and thus implementing it would be far to off in the future, where as I would prefer to make headway on my project in a general sense (as I have some deadlines for me. my first "area" of the game with several playable missions and the ability to level up and get some items for at least one type of class thats playable in the game).

But it is surely something to consider. Thanks!

-Shane

Share this post


Link to post
Share on other sites
i had a good long think about this problem when designing my engine.

the best solution i could think of was to have all ie mission info in the script for that mission. what data to use and how is entirely flexible, the script just broadcasts the data to the relevant areas of code.

this is only done once at load time and doesnt cause noticable slowdown.
the way data is organised is unimportant as the engine just handles one fairly abstract component at a time.

Share this post


Link to post
Share on other sites