Dawn-of-Light / DOLSharp

Dawn of Light (DOL) - Dark Age of Camelot (DAOC) Server Emulator
http://www.dolserver.net
GNU General Public License v2.0
114 stars 102 forks source link

Improved Stealth for NPCs #443

Closed tegstewart closed 1 year ago

tegstewart commented 1 year ago

This is relatively simple, but important, and opens up a lot of future possibilities. Under the previous implementation, NPCs with the Stealth flag were always stealthed, so logic checking IsStealthed always returned true. This lead to GameLiving.IsAttackable always returning false, and CheckNPCAggro() scrubbing NPCs with the Stealth flag. Stealthed NPCs could attack and kill other NPCs with impunity, as the other NPCs had no mechanism to detect them, and essentially just ignored them while being murdered.

I've added a CheckStealth() method which is called at the end of StandardMobBrain.Think(). NPCs remain stealthed until they enter combat, and unstealth once they're out of combat. When Flags is updated, it sends an update packet to the client, so NPCs stealth and unstealth both visually and logically.

I also added accessors for the other eFlag types, mostly because we have manual bit masks all over the place, I was getting annoyed retyping them out every time, and accessors are so much more readible. I considered adding set accessors as well, but I tend to think if somebody is fiddling with flags, they really need to know how they work, and could create other methods like Stealth() to do it safely.

tegstewart commented 1 year ago

I have a little more work to do on this. Blanket of Camouflage adds some weird edge cases I didn't originally consider, and code needs to be added to allow GameNPCs to use critical strike styles.

tegstewart commented 1 year ago

This should be ready to go. I've beat my head against a wall testing it.

NetDwarf commented 1 year ago

Thank you for your work! Works like a charm! :partying_face: