I prefer Lightfoot's solution - despite over 25,000 lines of code in our chat scripts (yes, really), we generally rely on listeners for area-, location-, and speaker-dependant things - modularity. I guess the one thing standing in its way is the question: do you want them to have to speak them one after the other, or all at once?
I would be inclined to track progress with a space-separated (or semi-colon, if some of the answers will have spaces) local string on the door itself, if you want them to answer one after the other. Then, you could just get the first substring, compare it to what they said, and snip it off from the later conjugations, or open the door if they're on the last.
There are going to be endless ways to do this, though. If you prefer to use what code Shad has already given you, I can adapt to that.
Also, if you dislike the listening event aspect, and/or want to have a central include which lists all your answers, you could simply tag all riddle doors the same thing, check for GetNearestObjectByTag, to find the nearest door, and mark each door with a unique local int: Door int 1, Door int 2, and so on. Then, in the master include, you could pull up the full answer list simply by use of a switch statment, and track only progress on the door using locals, rather than setting the answer there to begin with.
I understand you're looking for an elegant solution. To me, that may mean something a little different, so let's clarify your goals. For me, I would want:
a) A central include holding all questions and answers - for easier data filling .If you're comfortable with databases, that's what I'd normally suggest if you're using MySQL on a server, since databases are made for this stuff. If you want to be able to readily read and append, though, the bioware database is not so hot, so maybe the best solution is in fact a scripted include, if this is for single player use.
Minimal setup on individual doors - drop a door in from the palette, change a single variable, and it's ready
c) Ability to reset/relock doors, and to shuffle questions and answers at random, so that you don't have to make a zillion doors. Heck, maybe even a circle they have to walk around a number of times before a cetral door opens.
So, my questions are, aside from the initial one about how you want the riddles spoken:
1) how many conjugations are we talking
2) how do you want to handle randomization, if at all?
3) how many doors, in what configuration, in how many areas?
Funky
Modifié par FunkySwerve, 03 juillet 2011 - 01:33 .