You'r right in the points you made Kaihaider. What I meant was I'll keep the flags, but change how people enter new spells. Here's what I'm thinking, Zekken currently has these problems I'd like to address:
- Even though I convert the Reach flag to a numeric value during avoidance, having only 3 types of reach and width makes some spells be imprecise. I'd like to add more specific dimension flags, but it'll make entering data by users more cumbersome and prone to mistakes.
- Adding magnitudes and averaging angles of "escape vectors" works when there's few spells going on simultaneously, but in many fates due to the amount of spells going off it can lead to endless kitting like what r4vn0s above me mentions. This method of avoiding is also not optimal.
- It only considers avoiding spells that are being casted, and once the spell goes off it no longer considers it. This doesn't work for many spells, especially in bosses, where the area where the spell was cast is left affected for some time.
- Due to only using the Navigator.PlayerMover.MoveTowards() to avoid, it often tries to run into walls or falls off cliffs.
So what I'm thinking is doing the following:
A) Add a numeric field on spell shapes called "duration", which will be used to know how long to keep considering the spell's area bad after the spell is cast successfully by the mob.
B) Since we're adding a numeric field to shapes already, change the flags. Keep the shape, target, and direction flags, but remove the reach and width ones. Replace those with numeric values.
C) To make it easy for people to add new spells, I'm going to go and measure the exact reach and width of the most common spell shapes with the console. I'll take a clear picture of the spells, and add a window on the Settings menu of Zekken where you can add a new spell by browsing through these pictures as if it were a catalog, and selecting which one looks the same as the new spell you want to add. It's basically choosing from already made prototypes, copying their values and just changing their ID. This should make it so spell shape values get correct values more often.
D) Now that I have exact dimensions for spells, change the avoidance logic to a sort of a "radar with pathfinding" approach. I envision it as having these modules:
- The spell cast detector that's already there, but extend it's functionality so it uses the "duration" property of spell shapes to also keep active permanently affected areas as bad to step in.
- A shape intersection calculator, that given a list of active spell shapes and their respective enemy positions taken from the detector, and given a Vector3 position, it tells you if any of the spell's shapes intersect the point.
- A pathfinder (perhaps A*) which uses the intersection calculator to search for the closest safe spot the player can move to, starting the search from the player's position until it finds a position that no shape intersects. The pathfinder would have a heuristic function that makes it prefer moving towards the player's original position before avoidance started, that way endlessly kiting away would hopefully be minimized.
- A movement module, that given the pathfinder's result, it asks the Navigator to generate a path towards that position using the mesh. If the navigator is unable to find a path towards it, "blacklist" that area and ask the pathfinder to find another safe spot. Do this until a viable one is found, then move towards it. If I could somehow access the local mesh of the player's vicinity I could check for this during pathfinding itself instead.
That's what I'm thinking, but it'll take some time to make it, perhaps a couple of weeks to make something testable with a few shape prototypes.