Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Handling Game Events? (quests etc.)  (Read 3150 times)

0 Members and 1 Guest are viewing this topic.

irri

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • http://www.irri.se
Handling Game Events? (quests etc.)
« on: January 17, 2009, 05:01:03 pm »
Hello there!
I'm making a classic RPG-game for a project in school and I have some questions about game events (quests, story and such).

Here's some videos to better understand what I'm asking for: http://PA.irri.se/

I want a simple system for handeling events.
for  example, when you speak to an NPC in town, he gives you a quest to get him some special key item, and when you have done that something happends e.g. a door opens.

another ting, for example if the player goes to a certain place in a certain time, an event will begin..

Is scripting the only way to accomplish this, and which scripting language do you recommend? And how do you implement it the easiest way??

Thanks
Philip Irri
2D RPG Game (School project): http://PA.irri.se/

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Handling Game Events? (quests etc.)
« Reply #1 on: January 17, 2009, 08:06:41 pm »
LUA is the most popular way to do it but using LUA as a scripting engine isn't the only way.

Here's how to implement coroutines in C/C++ (assuming statevar is an enum of states):

Code: [Select]

switch(statevar)
{
  case AT_DOOR:
    if (has_key==true)
    {
        statevar=DOOR_OPEN;
        tile[DOORX,DOORY]=OPENED_DOOR_ICON;
        has_key=false;
    }
    else
    {
       message("You need a key.");
    }
    break;
  case DOOR_OPEN:
    start_cutscene(DOOR_OPENED);
    statevar=DOOR_CUTSCENE_SHOWING;
    break;
  default:
    break;
}


Keep in mind that this will probably execute once per game loop and there may be multiple states that need to be used.  If that's the case, you can try to pack them bitwise into an int or a long long and use that as your state variable instead.  Also remember, if there are multiple ways to trigger an event, you can put multiple case statements on the same section of code (assuming you're not using .NET).