talkbox experiments

Posted by mikemacdee on May 12, 2012, 3:02 a.m.

this blog will show what an inept programmer i really am, so i apologize in advance. i'm hoping some of you might have helpful suggestions; if you do, please leave a comment or send me a PM!

this week i added the talkbox element to my contest entry: it's reminiscent of Shadow of the Beast in that you strike up conversation with an npc, type a keyword to ask about, press enter and get the npc's reply (if it has one). i thought this would be more involving and a helluva lot more interesting than the original plan: giving the player an extremely limited list of conversation topics (reply A, reply B, or reply C).

now, i use GM7, and i'm mostly a drag-and-drop programmer, but i know a few advanced tricks and i actually consult the help file BEFORE asking help on the internet. but the way i accomplish certain effects in a game tends to be on the convoluted side, maybe because i'm a bad programmer, or maybe because i just prefer things the hard way. i dunno.

anyway, i'm wondering if other game maker users have successfully made text adventure games. if they have, i'd love to know how to tackle the following two issues:

1) an easier way to group keywords together

the talkbox draws keyboard_string as you type, and when you press enter it goes down a list of valid keywords and checks them against keyboard_string. for example, the player wants to know where to get healing when he's hurt, so he types "healing"; and if the npc knows where the hospital is, he/she gives a valid reply ("there's a hospital on the north side of town!")

but the player might also type heal, healer, cleric, church, rest, or any number of things. the way the game is currently set up, i'd have to make an entry for every single one of those.

if keyboard_string = "heal", set reply to "x";

if keyboard_string = "healer", set reply to "x";

if keyboard_string = "cleric", set reply to "x";

etc, etc…

i've used functions like "choose" before in GM, and i was sure that there'd be something similar that would check everything on a list rather than picking one at random, but i haven't found it.

2) an easier way to implement an "i don't know" reply from an npc

i want the npc to give an "i don't know" reply when keyboard_string doesn't equal ANY keywords on the built-in list, and my current method for accomplishing this is…well, cumbersome. because after checking whether keyboard_string equals x for every valid keyword, i then have to make one looonnng "if not" argument for every valid keyword that ends with "set reply to 'i don't understand'". there HAS to be a better way to do it…

at least being unemployed has ONE benefit when you design indie games as a hobby: you sure get a lot of work done.

——–

apart from the above issues, the project's been shaping nicely and it's really captured my interest. that's what these contests are all about, right?

i just realized i've been developing games for more than ten years. i realized this while going through my old RPG Maker 2000 projects this week. why do i keep doing this to myself…?

i also do a webcomic, and i also have arthritic elbows….so hopefully i'll be able to finish this thing by the deadline while still working on the comic.

EDIT: screenshot

Comments

Juju 12 years, 6 months ago

Learn GML/how to code before approaching something like this.

mikemacdee 12 years, 6 months ago

yeah that's the impression i'm getting….

Juju 12 years, 6 months ago

Graphics are surprisingly nice given your limited palette. Reminds me of early JW/Nobody.

Edit: You probably don't know who that is.

Cesque 12 years, 6 months ago

Quote:
this week i added the talkbox element to my contest entry: it's reminiscent of Shadow of the Beast in that you strike up conversation with an npc, type a keyword to ask about, press enter and get the npc's reply (if it has one). i thought this would be more involving and a helluva lot more interesting than the original plan: giving the player an extremely limited list of conversation topics (reply A, reply B, or reply C).

I may be wrong, but I think a conversation engine like that has come to be universally hated by now. It's amusing in chatbots, but guessing the right keywords in a videogame is annoying.

Also, what Juju said. It's a very, very basic programming "issue".

mikemacdee 12 years, 6 months ago

@juju: i know who he is, so i'll take it as a compliment!

@cesque: i had a feeling it's something i'd instantly solve if i was a proper programmer. thing is, i've gotten around kooky programming issues before in spite of my usual methods. learning how to use the FMOD wrapper for Game Maker was hell, but i did it, and used it often. i guess the question is, if i learn how to code this here or on another forum, whether it would disqualify me (provided i'm not just copy-pasting someone else's work).

Juju 12 years, 6 months ago

There isn't an instant solution. This is a very well-known issue in programming, going back at least 30 years. If you simply want to associate A/B/C with X then use:

if (str = "A") || (str = "B") || (str = "C") {
//Do some shit
} else if (str = "D") || (str = "E") || (str = "F") {
//Do some other shit
}
But that's really not a solution, that's just plugging the leaks.

Toast 12 years, 6 months ago

If you want to reduce the amount of repetitive writing, scripts are handy. You can make a function which returns true or false and use as many arguments in the function as you can.

scr_check(string0, string1,string2,string3,string4,string5,string6,string7,string8,etc)

if ((str == argument0) || (str == argument1)
 || (str == argument2) || (str == argument3)
 || (str == argument4) || (str == argument5)
 || (str == argument6) || (str == argument7)
 || (str == argument8)) {
return true;
} else {
return false;
}

Then in your main code:

if (scr_check("A","B","C")) {
//Some reply
} else if (scr_check("D","E","F")) {
//Some other reply
} else {
//"I don't know" reply
}

The only faster way would to be to load an external text file with all the strings written out line by line.

JuurianChi 12 years, 6 months ago

Your character looks like Doctor Who (Eleventh).

Iasper 12 years, 6 months ago

Why didn't anyone think of the switch command yet?

switch(keyboard_string)
{
case "heal": {reply="x"} break;
case "healer": {reply="x"} break;
case "cleric": {reply="x"} break;
default: {reply="x"} break;
}

Alert Games 12 years, 6 months ago

^ because its essentially the same, and a little more complicated for a beginner