Creating a data base on speech

This is a discussion on Creating a data base on speech within the Game Programming forums, part of the General Programming Boards category; Im making a RPG game at the moment... Do any of you have any ideas how to code the following? ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    Creating a data base on speech

    Im making a RPG game at the moment... Do any of you have
    any ideas how to code the following?

    player speaks to character in game

    player has no key so character says you have no key

    player has key so character says well done for finding it

    would this sort of thing work:

    Code:
    if ( key <= 0 )
    {
    gotoxy(12,32);char senta[]= "You need a key";
    }
    
    if ( key >= 1 )
    {
    gotoxy(12,32);char sentb[]= "You have the key";
    }
    
    else
    {
    cerr << "ERROR in code";
    }
    That is only one idea,,, am I on the right lines? Or is there a better
    way to acheive the same result?

  2. #2
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Code:
    if ( key <= 0 ) {
     gotoxy(12,32);char senta[]= "You need a key";
    } else {
     if ( key >= 1 )
      gotoxy(12,32);char sentb[]= "You have the key";
     } else
      cerr << "ERROR in code";
    The code works, but you're doing alot you dont need to. Thats a shorter version. I dont see whyy this wouldent work. But i'm not farmiliar with cerr.

    Just a side note, why are you going to a point then not doing anything with that point?
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  3. #3
    Rabite SirCrono6's Avatar
    Join Date
    Nov 2003
    Location
    California, US
    Posts
    269
    Or is there a better way to acheive the same result?

    It is better for games to rely on scripts, rooms, data files, and the like than to be all hardcoded in like you appear to be doing. That way, you can easily change several aspects of the game without having to enter the code.
    From C to shining C++!

    Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
    - Bubba

    IDE and Compiler - Code::Blocks with MinGW
    Operating System - Windows XP Professional x64 Edition

  4. #4
    Call me AirBronto
    Join Date
    Sep 2004
    Location
    Indianapolis, Indiana
    Posts
    195
    Ok this is what you do. Make a bunch of classes like player class and ect. then when you need to know some thing about that player, since its a single player game i assume this will be all the time, you just have a handy pointer to the intance of that class and extract the data as needed. Then have a huge table of text outputs for npc's to say and just pull out the right ones for the right time.

  5. #5
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Assuming you have a table that looks like
    table: Speech
    npc-id | require-id | response-ok | response-notok

    Where npc-id, and require-id are foreign key links to the tables (respectively)
    table: Npcs
    npc-id | npc-name | npc-location | other-fields...

    table: Items
    item-id | item-name | other-fields...

    Then you could use some simple SQL statements to pull up the text, and items that are required in your inventory and print the appropriate response.



    Of course, i'm guessing this solution is entirely above your head and not at all helpful.


    Shucks.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  6. #6
    Registered User
    Join Date
    Jan 2005
    Posts
    106
    Don't hardcode NPC dialogues, BTW.

    BTW, as far as as scripts, dialogues, etc goes, can you still include them as .cpp string vectors or whatever? Assuming you had a NPC_text.cpp and associated header, on compilation, unless you changed the engine, you wouldn't get much compile-time overhead. Granted, I prefer them being in texts because not having to boot up dev-CPP to edit content is fun, but I'm just saying.

    (Also, getlining from ifstreams is probably far easier, anyway. Just concept, I guess).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  2. question about a working linked list
    By cold_dog in forum C++ Programming
    Replies: 23
    Last Post: 09-13-2006, 01:00 AM
  3. Reading a file with Courier New characters
    By Noam in forum C Programming
    Replies: 3
    Last Post: 07-07-2006, 09:29 AM
  4. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 10:28 PM
  5. Replies: 5
    Last Post: 02-09-2003, 09:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21