Jump to content

  • Log In with Google      Sign In   
  • Create Account

Adding a storyline


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 mypel16000   Members   -  Reputation: 46

Like
0Likes
Like

Posted 01 March 2013 - 10:20 AM

Hi there,

 

I am developing a 2D top-down post-apocalyptic shooter and would like there to be a storyline. I have no experience with this and have no clue how to do it...

 

I would like there to be a primary storyline and then some secondary missions, but how do I keep track of where the player is in the story. What functions do I have to add to my code...? Should I have a different class for the storyline and have a bunch of IFs to see if the player meets the required standards to start the mission? and an int for the mission he is currently in?



Sponsor:

#2 Andy474   Members   -  Reputation: 685

Like
0Likes
Like

Posted 01 March 2013 - 10:49 AM

Sounds like you need to think of some sort of quest system, and mark some of them as [Story] Quests. this will allow you to have requirments too, so you cant do quest B untill Quest A has been completed, or Quest C requires Quest B to have been completed using The Good Choice. etc.



#3 mypel16000   Members   -  Reputation: 46

Like
0Likes
Like

Posted 01 March 2013 - 10:54 AM

Yeah well... how do I do that?



#4 Andy474   Members   -  Reputation: 685

Like
0Likes
Like

Posted 01 March 2013 - 11:53 AM

How about you spend some time thinking about it what i said?

 

 

Sounds like you need to think of some sort of quest system

 

ok, Quest class.

 

mark some of them as [Story] Quests

 

Ok, lets have a field IsStoryMission;

 

this will allow you to have requirments too

 

ok, so lets store some Quest Pointers vector<Quest*> _Requirements;

 

boom, quest system started.

was that hard? did it hurt your brain to read my post?

 

Ok, lets go deeper, well a quest is given by an NPC or some sort, ok, well lets give that NPC a Pointer to a quest object. Oh, wow, That was hard to think of wasnt it?

How does my NPC give that to the player?

Well,

void SomeFunctionCalledWhenPlayerTalksToNPC()
{
     if(NPCQuest->RequirmentsMet(this)
          this->CurrentQuest = Quest;
}

bool RequirmentsMet(Player *player)
{
     return player->HasCompletedQuest(MyRequiredQuest);
}

hmmm well thats about as far as I can go without having access to your code, and look. that took me 10m to figure out.



#5 BCullis   Crossbones+   -  Reputation: 1813

Like
3Likes
Like

Posted 01 March 2013 - 12:36 PM

Should I have a different class for the storyline and have a bunch of IFs to see if the player meets the required standards to start the mission? and an int for the mission he is currently in?

I don't know, did you actually try that idea?  Sounds like a possible route...

 

More importantly:

 

Stop asking "Should".  You will only learn if you TRY your ideas out.  Come up with horrible, crappy ideas, implement them, see how crappy they are, and try something else.  Eventually they start becoming good ideas.

 

Bam.  Experience and wisdom.

 

It's how we all got to where we are right now.  I've scrapped my entire codebase on projects multiple times because the architecture idea I had was utterly brittle and useless in practice.  Each time I had the experience and understanding of why the last idea didn't work to build off of, and the code just keeps getting better as I refactor and rebuild.

 

You only appreciate "best practice" design once you've tried to put it together yourself in a worse fashion.


Edited by BCullis, 01 March 2013 - 12:38 PM.

Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#6 haegarr   Crossbones+   -  Reputation: 4314

Like
1Likes
Like

Posted 01 March 2013 - 01:31 PM

A story is a sequence of events happening in the view (to be understood in a wider sense) of the player. To ensure that the player notices the events, they are usually not running detached but being enabled by requirements on the world state, and perhaps being triggered by the player. During happening and at its end, an event often alters the world state, so being able to enable or disable other (not yet happened) events. This way a sequence or even branches can be defined.

 

The world state is the entirety of variables describing, err, the state in which the game world is. E.g. a boolean flag for the life/death of an opponent belonging to the story, a counter for how often the player has hit a target, a flag whether or not a specific NPC has told the player about the hidden secret, ... whatever.

 
Events are enabled when their requirements on the world state are satisfied. E.g. if the flag meaning "opponent A is shot to death" is cleared and the counter for "rings of the bell" has reached 12 and the flag for "colliding with the proximity volume close to opponent A" is set, then let opponent A throw an offense against the player.
 

Triggers can be any action a player is able to perform. Colliding with a collision volume can be used as a location based trigger, or the death by shot of an NPC can be a trigger. On the other hand, the expiration of a timer can be a trigger, too, e.g. allowing for deferred events. Triggers can be implemented as a mechanism which alters the world state.

 

The player usually needs be hinted at how to trigger enabled events, or else s/he may not realize what to do next. How to do this depends on the type and style of the game. Briefings, books, journals, gossip, talks, ... by NPCs, a companion, the HUD, ... and so on. This can also be implemented as events in the way described above.

 

There isn't necessarily the need to explicitly track the current chapter in the story. The world state already reflects this.



#7 mypel16000   Members   -  Reputation: 46

Like
0Likes
Like

Posted 01 March 2013 - 03:41 PM

@andy474: I think you are forgetting that this forum is the "for begginers forum". Yes it is hard to interpret such a poorly elaborated answer.

 

@Bcullis: I know, I'ts just that I'm making the framework of my game still as my graphic designer hasn't caught up to me. I can't carry on the basics and I don't have a map yet. I'll try some methods, but I was just asking if there was a good accepted method to do this. Thanks for the advice though :)

 

@haegarr: Very good explanation, it kind of gives me an idea of what I need to implement into my game. I ill start having a class "World" with all these flags and simply have another class for the storyline that takes in a reference to the world and has a series of if statements an an int to keep track of the mission the player's in. Kind of like:

 

- IF( mission == 4 && 6700 < playerX > 6650 && 8700 < playerY > 8650 && playerAbilityConversation > 50) bla bla bla

You think thats OK?



#8 BCullis   Crossbones+   -  Reputation: 1813

Like
2Likes
Like

Posted 01 March 2013 - 04:28 PM

but I was just asking if there was a good accepted method to do this

There's a difference between implementing someone else's design, and designing something yourself.  The former still relies on programming ability, but the latter is where you will really GROW as a programmer.  This is why a lot of "where do I begin" guides give people a suggested progression of certain game types, with the caveat that you should try and make it work yourself before looking at other people's solutions.  Project Euler does this brilliantly: you can't see the solutions thread until you post a correct answer.  And man can those be enlightening.

 

Also:

IF( mission == 4 && 6700 < playerX > 6650 && 8700 < playerY > 8650 && playerAbilityConversation > 50) bla bla bla

I don't think the emphasized conditionals will work like you expect.  You need explicit comparisons, as otherwise you'll end up trying to determine if "6700 is less than true".


Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#9 minibutmany   Members   -  Reputation: 1616

Like
2Likes
Like

Posted 01 March 2013 - 07:01 PM

There are few problems in programming that can be solved with one standard answer. Programming is all about solving problems, and the solutions vary from problem to problem. Implementing story into your game is really probably one of the easier things to do. There is little advanced math or logic, the main issue is not really the implementation of your ideas, but coming up with what you want your story to be about. How in depth you want to go into story telling is up to you, and there are many different ways to go about it, which is why it is hard to pin point a logical standard solution.

Here are some examples that I can come up with for story implementations, just to get your mental juices flowing about how you may want to go about this:

 

Your story is about a zombie survivor out in the woods alone, moving from abandoned cabin to cabin, scrounging for food and ammunition. The zombies could strike at any minute, so you must work fast to be ready for an attack.

 

How do you do this in programming? Perhaps you have a list of the cabins(probably stored in an array, list, or in some sort of "level file"). The game interprets this data and virtually assembles the level around you. When you walk in the houses and you collect the items, it would remove from the inventory of the house in you "level file". Everything stored has an X and Y position and in your class that handles rendering it would recognize data from the file and interpret that to draw the objects in the house.

 

Perhaps if you want a story with less player determination, you could play a short animation at the beginning of the game that shows them their fate of eternal zombie battle unless they find the mad scientist that is controlling the minds of the poor undead. You could pick up clues scattered around the game that when touched, would pause your main loop and display an image file associated with that clue. Throughout the game, the player may have to make decisions that will either lead them to the scientist, or keep them battling the zombies. At the end of each "level" of battle, the decision would have to made (either physically in game or maybe in a GUI or something...) and the decision would either put them off track on  some random level or bring them closer to the mad scientists lair. Think about how the levels are connected as a tree or a web, not the normal sequential approach.

 

I'm not expecting you to use either one of these stories, but I hope that gives some idea of how you might plan about things.

For both of these implementations, or anything you come up with, your going to want to use Object Oriented Programming(OOP).

This answer is probably more of the story writing side of things than the technical examples than you wanted, but in reality, it's important to think about what you want something to be, before you're already half way done with it and just sloppily piecing other people's code snips together. What you really need is not a technical answer from us, but a good cup of you favourite warm beverage, a lot of paper and pens, and some time to think about each system in your game, what it does, and how it interacts with the other systems to form a nice, well organized piece of computer art.

 

As my 8th grade wood shop teacher always said: "Proper planning prevents poor projects".


Stay gold, Pony Boy.

#10 haegarr   Crossbones+   -  Reputation: 4314

Like
0Likes
Like

Posted 03 March 2013 - 05:46 AM

@haegarr: Very good explanation, it kind of gives me an idea of what I need to implement into my game. I ill start having a class "World" with all these flags and simply have another class for the storyline that takes in a reference to the world and has a series of if statements an an int to keep track of the mission the player's in. Kind of like:
 
- IF( mission == 4 && 6700 < playerX > 6650 && 8700 < playerY > 8650 && playerAbilityConversation > 50) bla bla bla

You think thats OK?

That is a question of experience and of personal preference. Although it is a valid way (until reaching some complexity), I would not implement it that way. I prefer a data driven way with concentrated responsibility (a.k.a. sub-systems, or "services" as they are generally called in my engine).

 

A way in-between would be where the individual events of the story are stored each one into an own object. The (base) class of that objects would support handling the requirements (probably data driven), and the effects of the event onto the world state (probably data driven, too). They could be separated, combined, or shared in different structures where meaningful (e.g. list of past events, list of running events, list of deferred/pending events, lists of listeners, a spatial structure when depending on locations, ...).






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS