Archers – part 1

  • Post category:Baneshifter

Hi everyone,
after longer “side quest” to the fantastic Pico-8 console I’m back and the development of The Baneshifter returned to the normal again. This time I’ll write more philosophical post about how my new feature implementation workflow goes.

Archers. Probably the most complicated NPC AI I’ll be making. From the “definition” any archer should shoot arrows at his target. Sounds easy right? But there are few problems: How many arrows it should shoot? Where those arrows came from? Will be the player able to pick them up?

Let’s see how the other games dealt with the archers. In every game I remember, archers are literally factories that generate infinite number of arrows. That’s nasty hack in game design that would cause access to infinite source of free arrows for the player and needs to be fixed – by another hack of course! Skyrim/Witcher/many other games solved it by ‘virtual arrows’ – so the enemy is shooting some kind of virtual projectile that sounds like an arrow (maybe even looks like an arrow) but after it hits a surface – it just doesn’t exist anymore (I don’t like it). Minecraft used more creative solution – arrows fly and hit the ground, they even looks like the arrows shot by the player, they just can’t be picked up (I don’t like it even more than previous hack).

The Baneshifter is my hobby project. And that means – no matter how hard it would be but I’m not willing to hack anything in my code! An architecture of the game code is really simple – there is an internal serializable game model and there is a visualization layer that follows the model. So everything that happens in the game model is (and should be) visualized. That ensures maximal readability of game mechanics (nothing goes in a background, player exactly sees what’s happening).

So, my solution is following:

  1. there is a limited number of arrows any NPC has in it’s inventory
  2. arrows must be clearly visible and they need to drop from the NPC upon it’s death
  3. NPC needs an alternative weapon that will be used if it runs out of arrows
  4. player must be able to pick up the arrows shot by NPCs
  5. everything must be visible and animated (no ridiculous weapon switching like in Skyrim)

Let’s see the following animation of humanoid archer that prepares for fight (no aiming yet – TODO) :

The archer has 2 new item slots – a quiver on his back and a sword at his side. Note that the quiver contains in this case exactly one arrow. In the moment the hand reaches the quiver I moved the arrow from the quiver to archers hand in the game model which is projected into a visualization layer by changing quiver’s representation and the arrow is spawned to the hand. After that moment the archer is literally holding a bow in primary hand and the arrow in his off hand. That gave me immediate benefits: if you kill him at that moment, he will drop the empty quiver from his back and the arrow from his hand. I may even allow the player to rip the arrow from his hand if he is close enough! Another benefit is the game state serialization that works without problems out of the box. If the archer looses a target he returns the arrow back to the quiver (that also works).

Aiming is still under development. I’m using my own animation system, so I have to implement one feature that allows me to do that – almost done.

I hope it was not too boring 🙂 Stay tuned, archers will come!