Implemented a boss

bosscrosshair

Image: Displaying the boss that has chosen his position of charging to when the load has finished.

Implemented a boss

During the last two weeks I’ve had the role of supporting the game designer in spontaneous fixes, meaning that when something needs to be done immedietely, I’ve been there to aid him. Also while doing this I focused on creating the boss for the game.

What?

The boss was supposed to be the last part of our game, to make it an extra struggle to finish it and really get that feel of an ending instead of just killing the last normal enemy and the game is over. That didn’t really feel amusing.

It was supposed to be harder which mean that it definitely needed more health but also more abilities instead of just one. Since the boss was sort of a knight or king, the boss logically would have a sword that he can hit with when in range. The boss would then instead have “special abilities” that he could use randomly within a certain interval such as shooting, charging and an area of effect attack around him.

Also, he needed several animations that I’ve worked with and is still in progress. This part I did by creating a sprite in several layers that I could move around and create the necessary sprites for an entire animation.

How?

Since the boss would have several different attacks, I chose to have a specific state for each of them. These would be the following:

  • Idle – A rest state for the boss when he used up his energy basically.
  • Chasing – Follows the player
  • Attacking – An attack in front of the player when within range that also knockbacks the player.
  • EarthQuake – An area of effect attack that charges up and then hits the player if he’s within the area of effect and also stunning the players.
  • EarthBreak(Current name, might change) – Shooting a bolt towards the player
  • Charge – Loads up and decides a destination and then charges towards the destination of the player at an increased speed until he reaches that destination that he chose.

The behavior of the boss was was suitably programmed with a local statemachine that would check for certain conditions whenever to change the state into another one. I had different functions for each state that would repeatedly be called and having it’s own counter that would keep check of whenever to leave the state.

The boss would in other words work very similar to one of the previous blog posts “Implemented a shooting enemy”. But instead he would also have a melee attack. So I made an invisible object with a collider that circulated around the boss but being inactive. Whenever i the melee state of the boss, at one point this would be syncronized to the animation so that it would look like that the sword hits the player.

The earthquake ability was also activating an object derived from the boss, and the collider of this object would be activated whenever the earthquake load had finished and if the player was in it, he would then be damaged and stunned by disabling the teleport ability and setting its speed to zero for a certain time. The same went for the earth break ability that worked similar to the earthquake when it came to the stun and speed, but instead it would instantiate a prefab of another object.

The charge ability basically saved the position of the player at the beginning of this state and instantiated a crosshair visual object at that position for the player to know where the charge would go, and when the load was finished, he moved towards this position at an increased speed and damaging the player if hit, until the boss reached the crosshair and then returning to the idle state since he needs to rest after this ability.

Why?

I find that this way of doing this was obvious for me since he would have so many different attacks and states that he could be in. It was also clear of what each part of the code did, so making changes was easy, only affecting the current states at each part.

The amount of spells was beneficial for the feel of really meeting a superior enemy, and not just a normal enemy. The effects from taking damage from the boss, ie stunned and knockbacked also increased this feel.

 

About Christian Edberg

2016 Programming