MWall541 / Dragon-Mounts-Legacy

Github Repository for the Dragon Mounts: Legacy Minecraft Mod. Please Report any issues here!
GNU General Public License v3.0
36 stars 34 forks source link

Give dragons a Brain #155

Open AnimalsWritingCode opened 1 year ago

AnimalsWritingCode commented 1 year ago

In theory, this PR will completely convert the dragon ai to using the Brain API. In practice, we'll see if I get that far.

Opening this as a draft PR because I suspect it will be pretty large and take a fair bit of time plus wanted to keep it open for comments in-flight. Some of this might be better to create as separate PRs, but whatever, shoot for the moon.

Todo list

Phase 1 - Basics

Implement current ai logic limited to vanilla activities and behaviors.

Phase 2 - Custom

Implement remaining ai logic with custom activities, behaviors, and memories. No vanilla mobs using the Brain API are tameable, flying, or rideable+controllable, so any activities, behaviors, or memories for those will be implemented here. At least in 1.18.2, but it's probably easier to maintain a set of custom classes than a separate ai system for each version.

Phase 3 - Big Brain

Send these dragons to college. Do new things that are just easier with the Brain API so dragons are smarter. These are probably good candidates for other PRs if they're going to be done.

AnimalsWritingCode commented 1 year ago

Going to call this PR here for now. Reimplements all of the existing ai functionality using the Brain API plus a couple small QoL changes like timeouts on fighting. None of the "phase 3" things should really be all that difficult to do, but I'd rather not tightly couple their progress to the core transition at this point.

The only open questions are about juvenile vs adult attack behavior and whether we want to rigorously implement forge hooks for target changes. I've covered setting it to a real target, but not when it's cleared because that will be a pain and skipping it is not any less compatible than the vanilla mobs.

One of those forge hooks (just for optifine) is deprecated in 1.19.2 for performance and being removed in 1.20, but I don't see a replacement, so I am not making a separate 1.19.x PR to remove/replace it at this point. Happy to do (only 2 lines) if you'd rather take the performance bump.

Of course open to whatever comments or changes. Just figured I'd get the ai overhaul rolling. Was torn on whether to implement the ai class statically like the vanilla mobs or as an instance so we could cache the dragon and brain reference, but decided static is more appropriate since the brain is really the worker for all the logic and the ai class is basically util methods to configure it.

AnimalsWritingCode commented 1 year ago

Finally got around to fixing conflicts on this and testing it. Probably going to want to clean up the dragon landing while following an owner on the ground, but also probably best to save that for when a rewrite of the flying pathing is done.

MWall541 commented 1 year ago

I'm going to mark this as the actual OFFICIAL AI revamp, considering how far and organized this has come!

I condemn your work on this and I'm happy with where it is headed right now. There's a few things I'd like to change myself but that's what reviews and collaboration is for anyway.

I'm marking this as a draft while progress continues on this. Draft status can be removed once everything is complete. Polishing up can be done after that.

Thanks again for your hard work!

AnimalsWritingCode commented 1 year ago

It may actually be good to re-target this to a feature branch for the overhaul and get this PR to mvp then expand on the ai in that branch. Just to avoid one mega PR holding everything up or forcing every update to be co-dependent.

Also, I was actually thinking of replacing the static ai class with an instance that can be created in the dragon class. I did it statically since that's how it's done in vanilla but it hurt to do since that's terrible levels of coupling.

Ninjastorm380 commented 10 months ago

out of curiosity, but would the AI bits discussed here be configurable (ex: 'what counts as a dragon') for mod compatibility?