|
Post by texture on Mar 25, 2018 20:07:51 GMT
This tutorial is fantastic and I've been using it as a framework for a small project. However I've run into a bit of a problem, I haven't modified the AI much at all, and have done nothing to the movement AI. The problem comes in when you have an enemy unit with the walk movement type being surrounded by other units on all sides. I would imagine the suspected behavior here would be that the enemy unit would just try to attack or use an ability, but because it has no movement options it just defaults to the null plan of attack behavior, and ends its turn. To clarify, the surrounded unit will never do anything, even a self cast, however the unit still occasionally chooses to change its facing. Tested for fly and teleport move types and the units work as expected. I'm relatively new to AI programming and I'm wondering if anyone has fixed this behavior or could throw a few lines of code my way. Thanks
|
|
|
Post by texture on Apr 17, 2018 19:47:38 GMT
Did a bit more testing between doing some other things and it seems like AI actors will never choose an action if they don't move on their turn. So this can happen if a unit is adjacent to another and can't reach any other tile that is adjacent to its adjacent target. Just wondering if anyone has resolved this issue?
|
|
|
Post by Admin on Apr 18, 2018 14:52:19 GMT
Its been a long time since I looked at this code... maybe I'll get a chance to spend some more time with it soon, but at a quick glance I am guessing it might be possible to resolve (or at least to start resolving) in the "AttackOption" script by making the tile a unit stands on qualify as the "bestMoveTile" if there are no other options available.
|
|
|
Post by texture on Apr 18, 2018 20:32:10 GMT
Hey, thanks for suggesting this would be an easy fix, it turns out it was. Guess I was just afraid to start messing around with AI code as its a totally new area for me.
After trying a few things in attack options and trying to add a new method that would always just preform an adjacency test, I couldn't quite get it to work 100% of the time. However, eventually I found that just adding the actor tile to the List<Tile> return in ComputerPlayer GetMoveOptions method solved everything, I felt very dumb, but I'm happy its resolved. Done tests on multiple cases, units surrounded, units with only adjacent options, using abilities, etc on multiple maps, seems to work 100% so far.
Thank you for making me get over my fear of messing with AI scripts. I Really appreciate the work you do, you've provided a foundation for me to build upon, that is helping me make something I'm slowly becoming proud of.
|
|
|
Post by Admin on Apr 18, 2018 21:10:24 GMT
Awesome, very glad to hear that it is working and I love hearing that I have helped inspire and enable you! I'd love to see what you make when you're ready to share.
|
|