Sunday, July 24, 2011

Interrogation parser is done

I unfortunately don't have much to actually show for this bit of work that I just completed, but it's important all the same.  Essentially, as I alluded to in my last post, I've been building a rudimentary parser for a conversation declaration language that I've put together, which allows me to quickly define conversations in an intuitive and sequential fashion.  That parser is now complete - I've successfully gotten a text file to compile into a conversation object that can then be loaded into the game engine and interacted with.  As work progresses and I implement other aspects of the game engine, this parser will need to be upgraded to also compile text files into objects for those parts as well, but this is a good start.

If you're currently wondering why you would care about this - isn't this just an internal implementation detail? - enabling the ability to define the case data in this fashion separates the game data from the game engine, which carries with it a number of tangible benefits:
  1. It enables cases to be defined in a modular fashion - in other words, cases aren't built directly into the executable file. This makes it so that players will be able to install the executable file once, and then just download and open separate case files to play future cases, instead of requiring an update to the executable file itself.
  2. It enables the creation of a case editor separate from the game itself, which can be used to create, edit, and save these case source files, which can then be compiled and loaded into the game itself.
  3. It enables cases to be defined in a platform-agnostic fashion - the game I'm implementing is built in XNA, meaning that it won't run within the context of an operating system other than Windows, but because the cases are defined in this fashion, porting the game to another operating system would only require the re-implementation of the game engine and the case source parser, not a re-implementation of the actual cases themselves.
For those who are really interested, the definition of the conversation seen in the video in the last post, along with an explanation of the different actions defined within it, appear after the break.

Here's the conversation from the video, defined in this conversation definition language.  Note that this isn't what one will edit in the case editor (it will have a much more user-friendly interface); this is just the source file that the case editor will save to and load from. (Of course, it can be edited by hand if one wishes, but there'll be no reason to do that once the case editor is complete.)

The conversation:

BeginInterrogation AppleBloom_WhereWereYou Where Were You?

ChangeCharacter Left TwilightSparkle
ChangeCharacter Right AppleBloom

ShowDialog Left Apple Bloom, if you don't mind{HalfStop} I'd like to know whether you did anything unusual yesterday.

BeginInterrogationRepeat
    ShowInterrogation Right Well, I don't know what you're lookin' for, Twi{FullStop} I spent the day with Applejack. Honest!
        BeginPressForInfo
            ShowDialog Left {Aside}{Emotion:Sad}(She WAS with Applejack, but{Ellipsis}){/Aside} {Emotion:Normal}That's ALL you did{FullStop:?} Nothing else?
            ShowDialog Right {Emotion:Annoyed}Uh{Ellipsis} {Emotion:Normal}yup{FullStop:!} That's it!
            ShowDialog Left {Aside}(She{Ellipsis} {Emotion:Annoyed}doesn't sound very sure of that.){/Aside}
        EndPressForInfo
    EndShowInterrogationBranches

    ShowInterrogation Right I definitely didn't go near the Carousel Boutique{FullStop} {Emotion:Defiant}Not once!
        BeginPressForInfo
            ShowDialog Left I{Ellipsis} didn't ask about the Carousel Boutique.
            ShowDialog Right {Emotion:Normal}Oh{FullStop:!}  {Emotion:Defiant}Well{HalfStop} {Emotion:Normal}I still didn't.
            ShowDialog Left {Emotion:Annoyed}{Mouth:Off}...
        EndPressForInfo
        BeginPresentEvidence CapeShred
            ShowDialog Left Apple Bloom, your sister represents the Element of Honesty{Ellipsis} {Emotion:Sad}but right now, you aren't being honest with me.
            ShowDialog Right {Emotion:Annoyed}'Course I am, Twi{FullStop:!} {Emotion:Normal}Why, whatever could make you think I'm not?
            ShowDialog Left {Emotion:Annoyed}{Mouth:Off}*{Pause:100}s{Pause:100}i{Pause:100}g{Pause:100}h{Pause:100}*{Pause:100}.{Pause:100}.{Pause:100}.{Pause:100} {Mouth:On}{Emotion:Normal}Apple Bloom{HalfStop} I know you were there{FullStop} I found a shred of your Cutie Mark Crusaders cape at the scene.
            ShowDialog Right Oh{FullStop} Um{Ellipsis} well{HalfStop} {Emotion:Defiant}that could've been torn off at any time, right{FullStop:?} Wasn't last night, no siree!
            ShowDialog Left {Emotion:Annoyed}{Aside}(...Apple Bloom, are you really pulling this one?){/Aside}
            SetFlag ShowedCapeShred
        EndPresentEvidence
    EndShowInterrogationBranches

    ShowInterrogationConditional ShowedCapeShred Right {Emotion:Normal}Sure there was a piece of my cape there{Ellipsis} {Emotion:Defiant}but that had been there for a while!
        BeginPressForInfo
            ShowDialog Left {Emotion:Normal}Apple Bloom{HalfStop} isn't this a bit much?
            ShowDialog Right {Emotion:Normal}Whatcha mean, Twi?
            ShowDialog Left {Emotion:Annoyed}{Aside}(Ugh{Ellipsis} I guess I'm gonna have to pry it out of her.){/Aside}
        EndPressForInfo
        BeginPresentEvidence CMCCape
            ExitInterrogationRepeat
        EndPresentEvidence
    EndShowInterrogationBranches

    ShowInterrogation Right {Emotion:Normal}So it looks like you'll have to look elsewhere{FullStop} Sorry, Twi.
        BeginPressForInfo
            ShowDialog Left {Aside}(...I can't think of anything to ask here, but{Ellipsis} {Emotion:Sad}What is she hiding?){/Aside}
        EndPressForInfo
    EndShowInterrogationBranches

    ShowDialog Left {Aside}{Emotion:Annoyed}(Argh... c'mon, Twilight, think{FullStop:!} {Emotion:Sad}She's hiding something, I just know it!){/Aside}
   
    BeginWrongEvidencePresented
        ShowDialog Left {Emotion:Sad}Apple Bloom{HalfStop} this proves that you're not being honest with me.
        ShowDialog Right {Emotion:Annoyed}It does?
        ShowDialog Left {Emotion:Normal}Oh{Ellipsis} well{Ellipsis} I guess it doesn't{HalfStop} does it?
        ShowDialog Left {Emotion:Annoyed}{Aside}(Smooth, Twilight{FullStop} Real smooth.){/Aside}
    EndWrongEvidencePresented
EndInterrogationRepeat

ShowDialog Left {Emotion:Annoyed}Apple Bloom{Ellipsis} you had your cape repaired this morning{FullStop} I talked to Rarity about it{FullStop} Now{Ellipsis} {Emotion:Normal}why would that be, hmm?
ShowDialog Right Oh{FullStop} {Emotion:Defiant}Um{Ellipsis} uh{Ellipsis} {Emotion:Normal}all right, all right{FullStop} I'm sorry, Twi.
ShowDialog Left {Emotion:Normal}It's OK{FullStop} But, please, this is important{FullStop} Something's been stolen.
ShowDialog Left If there's anything you know, please tell me.
ShowDialog Right I{Ellipsis} {Emotion:Defiant}can't.
ShowDialog Left {Emotion:Annoyed}Why not?
ShowDialog Right {Emotion:Normal}'Cause I promised.
ShowDialog Left Promised WHOM?
ShowDialog Right {Emotion:Defiant}{Ellipsis}

MustPresentEvidence ScootalooProfile Left {Emotion:Normal}*sigh* Apple Bloom, I think I know why you're not talking...
    BeginWrongEvidencePresented
        ShowDialog Left It's because of this, isn't it?
        ShowDialog Right {Emotion:Annoyed}Uh{FullStop:,} {Emotion:Defiant}no.
        ShowDialog Left {Emotion:Annoyed}{Aside}(Argh{Ellipsis} I know she's protecting SOMEONE{HalfStop} {Emotion:Normal}but unless I know whom, I don't think I'm getting anywhere.){/Aside}
    EndWrongEvidencePresented
EndMustPresentEvidence

ShowDialog Left Look, I know you're trying to protect Scootaloo{OtherEmotion:Normal}{Ellipsis} but you can protect her by telling me what you know.
ShowDialog Left {Emotion:Sad}If you don't{Ellipsis} it's going to look pretty bad for her.
ShowDialog Right {Ellipsis}{Emotion:Normal}All right{FullStop} You promise you'll help her? You gotta promise, Twi.
ShowDialog Left {Emotion:Normal}Cross my heart and hope to fly{HalfStop} stick a cupcake in my eye.
ShowDialog Right {Ellipsis}{Emotion:Annoyed}That a yes?
ShowDialog Left Er{Ellipsis} {Emotion:Sad}yes.
ShowDialog Right {Emotion:Normal}OK, I'll tell you what I know{Ellipsis} although{HalfStop} it's not much.
ShowDialog None ...But that's all we've got thus far!  Stay tuned for more!

EndInterrogation


So, a few things to note here:
  1. The interrogation is given both an ID and a name at the very top ("AppleBloom_WhereWereYou" being the ID and "Where Were You?" being the name.  The ID is a unique identifier that enables this interrogation to be associated with a given character encounter in a given case, such that all one needs to do in order to say "this interrogation happens during this encounter" is to refer to the ID.
  2. BeginInterrogationRepeat starts the actual interrogatory portion of the interrogation; the stuff that comes before and after it are the lead-in and the eventual outcome from a successful interrogation.  Everything that appears within BeginInterrogationRepeat and EndInterrogationRepeat is the portion of the interrogation that you can page through repeatedly, press for info, and present evidence against.  Begin/EndPressForInfo defines what happens when you press a statement for more information, while Begin/EndPresentEvidence defines what happens when you present a specific piece of evidence (denoted by its evidence ID following BeginPresentEvidence).  If you present a piece of evidence that isn't specifically called out by BeginPresentEvidence, then you'll instead be taken to the Begin/EndWrongEvidencePresented section, and will then return to the interrogation statement you were previously on.
  3. ShowInterrogationConditional enables the time-honored Ace Attorney tradition of testimony revision - once you've successfully presented evidence, if the subject wishes to be particularly obstinate, they might want to add another part to their testimony, which will show up once a flag is set making him or her do so.
  4. SetFlag makes it so that interrogations or conversations can affect other things in the world.  Every case will a list of global flags defined that can be set or cleared at any time from any location in the game, making it very easy to advance the story and have new content open up in the case based on something that just happened.  There'll also be a similar way to add evidence to a global list of evidence, but that hasn't been implemented yet.
And that's about all there is to say about the case source file parser!  Next on the list is to go one level up from interrogations and define entire character encounters, as alluded to above, which can include a number of conversation and interrogation topics that the player can go through.  Stay tuned!

5 comments:

  1. Sounds cool, so does this mean custom cases made by users would be fairly simple to write as well?

    In any case, a game like this is a great idea and it looks like you have the skills to make it work wonderfully. Keep it up!

    ReplyDelete
  2. @Chibito

    Yeah, I still need to nail down some details, such as storage of case resources (character images, backgrounds, etc. - don't want to make it so people have to only use the stuff my cases will use), but I think it should definitely be possible to release the case editor into the wild once it gets sufficiently polished and robust. A lot of people sound very excited about the concept itself of Ace Attorney meets MLP:FiM, and I think it'd be wonderful if others had a chance to contribute as well, rather than forcing people to have to play only cases authored by me.

    ReplyDelete
  3. Gah! Ya beat me to it! I had an Alpha version of a more traditional version of the Ace Attorney series designed in flash sitting in a folder on my desktop... I would have used something such as XNA or C++ with Allegro or SDL but 1. I had't practiced my C# in a while and 2. I figured it would be simpler to use Adobe AIR + Flash to be more cross platform, But I admit you are AWESOME! Keep up the amazing work! I look forward to seeing it evolve, and if you need any help you can count me in for ideas and sounds ect. I have a lot of resources.

    ReplyDelete
  4. Wow! This is seriously the coolest idea I have seen in years. Since Capcom has apparently abandoned translating the Phoenix Wright games for North America, this will have to be the new fix for fans. The quality of the Apple Bloom interrogation you posted is mindblowing. I'm excited to see this project progress! If you run into any roadblocks or grow tired of the project, please, don't let it die, reach out to the community at large for help. There are many programmers, artists, musicians, etc that could help, and an idea this good (and polished!) shouldn't be lost for any reason.

    Good luck, and thank you for your awesome work on this!

    ReplyDelete
  5. @aaron524

    Thank you! :) I'll keep that in mind.

    @Sarkin

    Wow, thank you so much for the kind words! :) I'll do my best to make sure the final product lives up to them!

    ReplyDelete