LuisMayo / objection_engine

Library that turns comment chains into ace attorney scenes, used in several bots
MIT License
105 stars 20 forks source link

Judge verdict effect #106

Closed Meorge closed 1 year ago

Meorge commented 1 year ago

This pull request adds support for the "Guilty" and "Not Guilty" text effect from the games. Running it with the example script example_dmv_verdict.py produces the video:

https://user-images.githubusercontent.com/9957987/230532668-4b6f9f3a-3604-4bb2-9c4b-5d0f90dcbb2e.mp4

It requires the font titled "DFMinchoStd-W12.otf" to be placed in the "assets/verdict" folder; the font (and many other Ace Attorney fonts!) can be found here: https://www.deviantart.com/rapbattleeditor0510/art/Fonts-Phoenix-Wright-Ace-Attorney-Font-Pack-2-873499678 This specific font is inside the "Not Guilty" folder.

If the font is not found, rather than crashing, the engine prints out a warning message and renders the video without the text:

NOTE - Verdict font not found at ./assets/verdict/DFMinchoStd-W12.otf, so verdict text will not be rendered

https://user-images.githubusercontent.com/9957987/230532925-e5753244-7587-4d92-a03b-d2ec148a0d12.mp4


Currently, the only way to use/trigger this effect is by writing out commands manually, like in the example script. In the future, if we could come up with a higher-level API way to expose this, I think it'd be great, but I'm not sure yet what that would look like.

Before final review and merge, I'd like to do a bit more testing. So far I've mostly just tested it on this one scenario, so it'd be good to confirm it is robust before doing the merge.

Meorge commented 1 year ago

I added another example script that writes a longer string in white text:

https://user-images.githubusercontent.com/9957987/230537250-b464f158-6490-4b92-b86a-33ceacdcc6bd.mp4

Tomorrow I'm hoping to put together a helper function that automates the assembly of those commands, since they're a bit of a handful right now.

LuisMayo commented 1 year ago

Hi!

This looks promising.

To offer you my feedback. The higher level API entry point could be a flag in the comment object. So the veredict could be just a "Comment" with the property type set to veredict.

This would even pave the way to having different types of comments for different type of actions, maybe the judge mashing the hammer or people talking could be implemented as Comments with specific types too

Good job as always anyway.

Meorge commented 1 year ago

For such an API, I thought rather than trying to integrate it into the existing Comment type, effects like these could use a different object type (maybe the list is of a type that Comment inherits from?). So a script might look like this:

comments = [
    Comment(
        user_name="Phoenix",
        text_content="Hello. My name is Phoenix. I am a defense attorney.",
    ),
    Comment(user_name="Phoenix", text_content="Here is another line of dialogue."),
    Comment(
        user_name="Edgeworth",
        text_content="I am Edgeworth, because I have the second-most lines.",
    ),
    VerdictEffect("Guilty", slam_type="letter", color="black"),
    Comment(
        user_name="Phoenix",
        text_content="Well that stinks",
    ),
]

Do you think this would be a good way to handle it? I'm also unsure if we should have extra parameters for forcing the camera to focus on the judge, since that's usually where the text shows up...

Meorge commented 1 year ago

There's now a function that generates a list of the DialogueAction objects for doing the verdict effect. Now it can be a single line to do: compose_verdict("Denied", slam_group="letter", color="black"). It's not implemented in the comment-level API yet, but once we determine how to go about it I'm hoping it should be very quick and easy to do.

LuisMayo commented 1 year ago

I like your way better too, not gonna lie.

It's clearer ^^

Meorge commented 1 year ago

I just realized, it looks like I had this set to "draft" instead of "ready for review" - it's been a while since I last worked on it, but as I recall it was all ready to go, so I switched it over!

LuisMayo commented 1 year ago

Great work as always meorge

Good to go