Even though I have been home with a fever this week I have tried to do some work from home. I have been drawing some sort of flowcharts over the three bosses AI. The boss I am going to start with when it comes to code is the final boss, Mothgomery. This because if we run out of time we think this is the most important one for the game. He is the “emperor of the suit” who started the invasion and leads the other bugs.
First when you enter the room with Mothgomery all the exits close, then Mothgomery says some cool line to start the fight. Mothgomery then has two phases in the fight. He starts in phase 1 where he is invulnerable and he lets four of his minions (Buggers and Grubligs, the normal enemies) fight to protect him. When all his minions are dead he will enter the second phase. Here Mothgomery is vulnerable, he stays in this phase until he is down to a certain percent of his life or (if it takes too long time) the time is up. Then he goes back to phase 1 again. This goes on until the player has killed him, and wins the game. The minions will have a different AI than the normal bugs, they will always be in their chasing AI so they follow the main character, Barney, wherever he goes.
Before you can challenge the final boss you have to meet and defeat the two other boses, Ben Bugger and Grubby McGrub, who will have a quite simple AI aswell. Ben, who is the boss you have to kite to kill, has only one phase. He follows you around the room trying to catch and kill you. He will only get faster and faster as time goes. There will be some sticky goo on the floor which the player should try to kite him through, because Ben will be slowed and take more damage. While kiting Ben the player has to shoot at him to lower his life and kill him.
Grubby will have two phases. He is the boss which acts kind of like a whack-a-mole. In phase 1 he is underground moving towards Barney with quite some speed. As he reaches his target he enters phase 2. He shoots out of the ground while shooting some icky goo around him. If Grubby hits Barney on his way up Barney will take a lot of damage. If the goo hits Barney or the player run over it, he will take damage but not as much. In phase 2 the player can shoot at Grubby to lower his life before he digs into the ground and starts chasing Barney again.
So the other week I wrote about pathfinding. After a consultation with our mentor we decided to add some other ai first and if we have the time, implement pathfinding later.
So this week I have been writing code for the enemies’ ai-states. Our two different enemies will have different states when I’m done, but for now they will have the same just so we have something for the alpha. The one to the left is the ranged enemy and the one to the right is melee.
The player, Barney, have three “collision circles” called colliders, the smallest one (the brown circle in the middle) checks if Barney is hit by something (so he will take damage), the next one (the red circle) checks if the enemies are close enough to start attacking (if they are inside they are close enough) and the last one (the blue) is to check if the enemy is too far away to continue its attacks on Barney or too far away and will go back to patrolling. The pictures show the colliders in the prototype (the second picture) and in the actual game (the first picture).
The first state being the “PatrollingState” is active when the enemy is too far away from Barney to attack. The enemies have waypoints which it moves between, when it reaches its destination or collide with a wall it gets a new waypoint to travel to and so on. So far the only state the enemy can switch to from the patrolling state is the “ChargeState”, this happens when the enemy reaches the second collider.
When the enemy enters the charging state it starts with slowing the speed and moving towards Barney. After a short while it get Barneys position and direction, calculating where Barney will be and where to charge. Then it charges with high speed to that point. Then he stops again, moving slowly towards Barney and calculating the next charge point. But if it is outside the biggest collider when stopping it will not charge again, it will go back to the patrolling state and continue patrolling the suit.
Later there will be a state calls “ShootingState” which the other, ranged, enemy will enter instead of the ChargeState. It will change to ShootingState when reaching the second collider. The enemy will stand still and shoot at the point where Barney will be in a short while, calculating that point as the melee enemy in ChargeState. If the enemy is outside the second collider it will move towards Barney until it reaches the collider again where it stops to shoot. If it is outside the third collider it will return to the PatrollingState.
Even later, when all the smaller enemies have their states, I will begin with the bosses’ states.
The other day we had a great discussion about level design. We drew the map on a whiteboard showing the bosses and the players’ spawnpoint. Then we discussed where to put all the pickups (textiles) to best help the player.
We also discussed the tutorial path. When you start the game you will get a short but informative tutorial. Have you played the game before you don’t have to follow it, just run past it.
Red dot = spawnpoint
Black dot = PickUp (Wool)
Blue dot = Enemy
The tutorial starts with an open room where you have to discover how to move around using the keys W, A, S and D. When you have found the right keys to walk around and explore the room to see nothing’s there exept one way out, you meet your first enemy. The enemy is patrolling the tunnel and the player will have to learn how to shoot, using the left mouse button. When the bug is dead you can go on exploring the suit.
A few steps later you see a nice looking chest. When you walk on it you get a notification somewhere on the screen saying something like “Picked up a [what kind], you can now use it in your customization”.
Then you have to choose, will you go right or left? They will both lead to the same place and show you the same mechanic though. When you go within the red lines there will be an exclamation mark above Barneys (the avatars) head and a notification sound to enlighten you there is something of value or something hidden nearby. You might just pass throught it and the exclamation mark disappears, and you might go back to see if it comes back, which it will. You might see the hint of the hidden room, the ragged walls are gone and there is a vague hint of a path right infront of it. If you see this you have found the first secret room in this map and you know how to find the rest. The exclamation mark will not be showing after this point but the notification sound will.
Now the tutorial has come to an end and you have learned all the mechanics to play the game.
We won’t give any tutorial to the customization since that is not necessary to beat the game. The only hint about it is when you pick up the first textile and then you have to explore it yourself.
Today was a good day for my programming. I managed to put collision in all the rooms of our game. There was one room where it didn’t want to work but I’ll check why tomorrow. I probably just sent the wrong file to Tomas (while I made the collisionpoints for every room I sent the files to him so he would implement them). Tomorrow I will make some changes to the Collisionpoint-maker program so he can use it on the map. He’s going to make points where the textiles and enemies will spawn.
When the collision was done and we had had our lecture on pathfinding I started with the AI to the game. We long discussed if we are to have pathfinding in the game, if it’s worth the time since none of us has ever done it before. We came to the decision that it would be cool (and I really want to learn how to do it), so I took the responsibility for it. Hopefully it won’t take the rest of the project to get it right, but that’s what we’re counting on. Though we want some simple AI for the smaller enemies (and maybe one boss if there’s time) for the alpha which is due next friday. So I thought I could start out with some move patterns and then build the pathfinding from that.
So I made this circle which travels from point to point, using circle to point collision. I think this code will do for the alpha as AI, depending on if we have the time to implement the different states on the enemies, we might want to add some sort of attack AI, at least for the ranged enemy but maybe for the melee one as well. Else the player will only take damage if he runs in to the enemies (which is probably not that likely).
After I have fixed the program for Tomas tomorrow, I will start with the pathfinding for real. It will take lots of research and trial and error testing. We got a tip from our teacher to look at this website and work from there:
So this is what I will do for the next couple of days/weeks/month. But hopefully it will work for our final version of the game!
Today I worked some more on the collision-checks for the game. I got the line-circle collision to work with SFML. The code had been working for a while before I realized I had forgotten to update the players collider position when the player moved. Now it has been implemented and I will put it to the test tomorrow.
I have also added a check between two circles. Most of the objects (I believe all the objects but the projectiles) will have a circular shape. So this will check collision between enemy-enemy, player-enemy, player-object, enemy-object. And today I finally got to use some of that math I never thought I would from school.
The Pythagorean theorem.
I also improved the tool which we will use to set the points in our room which we will check the collision between.
The scale is 1:2 but the output is the correct points we will use later. For extra help I show the mouse position in the bottom right corner. The black lines (which might be hard to see in this picture) show the user where he/she has put the points and where the player won’t be able to get past. We will simply name the files after which room the points are for. As it is now you can’t choose the pixels that are at the edge of the picture, I will have to look in to that so there will be no gaps in between the rooms. Tomorrow I will put three of the rooms together and see how well this really works.