Big Backend [B]improvements


This is a programming post. If you don't have any interest in that, feel free to skip this one! I should have some new gameplay to show sometime next week.

A lot of major changes have been made to the game over the last few days, but it's mostly invisible changes. There are some things that are visible, but they're a bit too subtle to come across over video, so I'm not gonna bother recording anything this time. Instead I'm gonna discuss some technical stuff.

Auto battlers can get really mechanically complex, and it is imperative that individual actions are given their own time to breath. That can be difficult if one action could cause many reactions, and many of those reactions could cause even more reactions. If you look at an auto-battle in Hearthstone Battlegrounds, a thing you might notice is the pauses between actions. Everything is enunciated clearly, and actions are rarely overlapping with one another.

This can be a tricky thing to get right! If you have abilities that can trigger before an attack, during an attack, after an attack, when something is damaged, when something *else* is damaged, when something dies, things can get very messy and it can be hard to properly allocate time and space for everything without your codebase becoming a rats nest.

My solution to this is called Agendas, which you can download from my github if you're a GameMaker user. In layman's speak, an Agenda is a todo list. When all todos are completed, the Agenda is finished. Agendas can be chained together, so when one Agenda finished, the next one in the chain starts. It's a really powerful way to sequence events with real time animations. 

To further explain why this is useful, here's an example. In the card game, there's a card that says "Before attacking, deal 3 damage." What this means is, when this minion starts to attack an enemy, it will first deal 3 damage to that enemy, and only continue with the attack if it's still alive. There's another enemy with a similar effect: "Before attacking, steal 1 attack." Which steals 1 attack point from the minion its attacking. These abilities trigger at the same point in the standard minion attack sequence, but their animations take different amounts of time! With Agendas, I can pass a todo into these abilities, and only move on to the next Agenda in the chain when the Todo completes. This even works if an ability triggers another ability, like if "deal 3 damage" hits an enemy with an ability that activates when they take damage.

Anyway, I'm quite pleased with this system. If you use GameMaker and this sounds like something you'd like to use, there's an example project in the latest release on github which shows Agendas in action. I'm also happy to provide support to anyone that chooses to use them.

Comments

Log in with itch.io to leave a comment.

Very useful! I am surprised Agendas are not more commonplace in game frameworks. I, similarly, made an “Actions” library in PixiJS which amounts to the same thing.

With an auto-battler this is less relevant, but for “normal” Hearthstone, I really like how the effects are calculated immediately, it’s just the animation which is queued up (as evidenced by cards losing or gaining a green border as soon as they would be playable, regardless of if the animation has shown you the current game state yet).

it's actually very relevant, because there's a card playing aspect here too! and yeah, that's how i have it setup for card playing right now. although there aren't very many animations that occur when you play cards yet, so it's not super noticeable.

(+1)

Really nice to have it set up like this, as it means your hands aren’t tied when it comes to innovating and making some wacky effects!

I’m looking forward to seeing the game progress.