28 March 2019

Gathering Items With A Task-based AI

I made some more progress since the last prototype. Not a lot of show off because of engine work. Quick breakdown of what’s new.

  • Updated GUI to streamline repeat item interactions
  • More HUD information, like items available for range combat
  • Decoupled how limbs and equipment work together
  • Added jewelry items like rings
  • a passive effect system for passive equipment bonuses
  • AI (task system, pathing, rumor system)

Monster Task AI

My favourite new feature is the monster AI system. It isn’t too advanced, yet. No behaviour trees, GOAP, or stuff like that. I’ve focused on basic behaviours like pathing to a location, picking up items, dropping items, and a decent state machine to execute them. I also made a first pass at a task tracking system. To test it all out I’m working on a scenario where monsters gather items from the 4th floor of the map and drop them off on the bottom floor.

There’s one more thing going on in the video that I didn’t mention: a rumor/knowledge system. When a monster picks up an item, it wants to share this information with other monsters. As it travels throughout the map, the system does a perimeter check around the monster and shares this knowledge with any monster in that perimeter by assigning them a PickupItem task at the place where the item was found. The monster travels to this location, but will find the item is already picked up. With nothing else to do it searches for nearby items and creates PickupItem tasks for them. Once they are picked up new rumors are created about those items.

With the rumor systems in place, only one monster (on the first floor) is assigned a PickupItem task. The behaviour of the other monsters and the tasks they get assigned are all kickstarted by the rumor system.

Bugs And Future Improvements

You may notice there are a few problems and bugs to work out. Sometimes a DropItem task doesn’t get added after a PickupItem task because a monster already has the maximum number of tasks (3) all of which are pickup tasks. That guy just ends up wandering around the 4th floor hoarding items. Other times, a monster doesn’t have anymore tasks after dropping off an item and ends up wandering around the bottom level. It then sees nearby items on the bottom floor and adds tasks to pick them up which I don’t really want.

I think the rumor system could be a lot more interesting. I use failed tasks to manage the lifetime of a rumor. IF a monster arrives at its destination and doesn’t find an item matching the one described in PickupItem task then that task failed. When a PickupItem task fails any active rumors sdfor that location are removed. It’s possible this could happen before a second person even hears about the rumor which doesn’t really make sense. How would the monster spreading rumors know to stop? There’s all kind of interesting ways to change this. Maybe a rumor can only be stopped by talking to the monster that spreads it. In that case the monster who failed their PickupItem task could create a new task to find that monster and get them to stop with the bullshit ;).

Until that happens, rumors about gold on the 4th floor would continue to spread. A rumor might never stop spreading if all the monsters trying to squelch it get killed before reaching the original monster. It could even lead to some fun situations. The player could lead gold-lusting monster to a trap by laying a breadcrumb trail of gold. To counteract this, monsters that escape your death trap could spread rumors of a deadly trap.

Rethinking Menu-driven Combat

I didn’t update the combat too much since the last demo. The biggest change I made was automatically raising the combat UI when you walk into an enemy. And some extra HUD text when firing a ranged weapon. As I’ve played with the combat more, I’m coming towards the conclusion that the menu system is a dead end. There’s keystroke-efficiency problems, but I think my biggest problem is that it’s too abstract/unreal. I think I need to go back and figure out some primary actions that can lead to accessing those specialized commands.

I don’t know what that looks like, but I’m pretty sure I want a dedicated attack button. Maybe a weapon hotkey that flips through equippables in your inventory to get the next available weapon. But, this wouldn’t work with ranged-type weapons since they have a quiver. I’ll think about it more when I get around to working on combat again.