Yesterday I got another checkpoint in my project done! 🎈🎈🎈

During the last month I’m struggling with the combat AI for this project. Basically some questions needed to be answered to make a believable combat:

  • Who is participating the combat?
  • Who is targetable for the skills?
  • What skill should an agent pick?
  • Who should be targeted among the possibilities?
  • Where should an agent should stand to release such skill?

I didn’t answered all of those questions, but things are starting to take shape now and I got closer to a combat flux. Right now an agent using Goal Oriented Action Planning (GOAP) can select a monster (who for now is static, but on the future will be using State Machines to make decisions) and start a CombatCluster. A CombatCluster has inside it:

  • A list of who is fighting
  • A list of everything that can take damage inside
  • A combat radius by who is fighting
  • A center of it defined by who is fighting
  • A list of events from the last turn
  • A vector of party blackboards for all the teams (for now is just a small class with who belongs to which team, but I want to expand this concept)
  • An Influence Map
  • An update function that runs in a different frequency than the GOAP (faster, running for now every cycle of the CPU)

Everyone who can fight back, who can hit other damageable, has a combat brain and a skill pool. The skill pool holds all the skills an agent has and controls the cooldowns and cast delays. I’m following the concepts from the iROWiki to define the execution of an skill. The combat brain decides which skill will be used, into who and where. For deciding which skill be used I did some Utility Theory by creating a base threat level based on the level, attack, magic attack, defense and magic defense of an unit, at some point near the future I will need to create an Event System using the Observer Pattern so fighters can accumulate threat level and start to hold aggro, like WoW does. So a CombatBrain can already decide which skill against which target is more productive for now, but deciding from where it should release such skill became a problem that started to scream for some definitions.

No Pathfinding Yet!

First, not sure if anyone noticed, but for now I didn’t implemented a Pathfinding Algorithm even tho I have a Goal Oriented Action Planning (GOAP) implemented my maps aren’t a graph. I do have the concept of Tile implemented, but it was more for to define a Flow Field around the structures so the GOAP agents could find the door of the buildings they want to enter. My characters move using Steering Behaviors only and since the buildings have a small flow field around them, there’s never a blocked path until now that the Steering Behaviors wouldn’t reach. Far from perfect, but isn’t my priority list at the moment. Since none of the questions that came with movement and by consequence related with the terrain weren’t answered yet I had to take a small break just so I started to think about how I was gonna be creating the terrain visually when the time comes. This break made me answer some of the questions that I was avoiding, because it wasn’t the time yet to start to answer it:

  • What is the structure of my terrain?
  • Will I be using a NavMesh?
  • Visually can I deliver character animations for everything? I know buildings and the terrain is something I can do, both on 2D and 3D, but actual characters is other kind of beast that is followed by “how the skills will be positioned/animated?”

No terrain definitions too…

The main concern on this questions are related on how the terrain will be altered by the presence of the buildings and how the players can alter it. I don’t know all of the answers on it yet, but a pure heightmap with a prebake NavMesh wouldn’t solve it. The terrain needs to adjust, even is just a small adjustment, to have a building above it by making the area where the building sits plain and it needs to answer if a building even can be constructed there. My decision for now is to separate the visual and the internal implementation of the pathfinding.
All of this is making me leaning into not using a game engine for the visuals. Maybe going full OpenGL and suffering for it, but future me decision. For now I’m playing a lot of RollerCoaster Tycoon and Majesty and pondering above my orb. One recurrent inspiration coming is Ragnarok Online again.

Ultimately I will be answering those after I take a break to read this article about the Jump Point Search that will be happening AFTER I finished everything related on a character deciding “where” they want to be.

The Influence Map Implementation

Did you noticed that I mentioned that the CombatCluster has an Influence Map implemented? Well here I started to implement some Graph concepts that might became useful for when I starts to talk about pathfinding properly. Basically, now a Tile knows who is reacheable from a the highest range skill from its location (a list of neighbors that are at a certain distance). This is pre-calculated, when the game is launched and the Influence Map is generated using a small window from the map, determined by the center of the CombatCluster and the it radius, and the agents that are above it. The following image shows the console for a influence map of one of the teams that are participating of the battle.

  • ’.’ indicates a empty space
  • ’#’ indicates a building
  • ”+” indicates a flow field
  • “A” indicates an agent
    The Influence Map shown is relative to one team, the ones who holds the agent that is on the top.

    This is the influence map for the team of the bottom agent is the following:

Notice that in both maps we do see a ‘-1’ indicating that this tile is occupied by a building. Again both influence maps cover the same area defined by the CombatCluster center and radius.

The next steps should be to combine all those influence maps so the agents can decide where they want to stay inside the battle field. A ranged class should be picking a place inside their influence range while a tank might choose to be at the edge of it, fighting to expand/push the control over the map.

My notes related with the Influence Maps are far from done, I still have some articles that I want to read before I move to the next step.

On other news…

I had to fight a lot this month with my brain. He didn’t want to sit still and do all of this work, everything was more relevant. I discovered an MMORPG on itch.io that has a economy running on the Pomodoro Technique. It solved? No, but its better. Since I found Pixeldoro I’m struggling less, figures. My only complain is that the map has a lot of problems with collision and Z-sorting, other than that… works like a charm.