AI features
Disclamer for first assignment: Since our game is about defending a base and killing entities, for the first delivery we had to make the entities interact with each other more than we would have liked so that the concept of the game could be understood. That's why the soldier and the citizen have more than two routines to follow in the game cycle.
About the behaviour trees: All the behaviour trees have the repeat function so in case that the main selector receives true or false, the tree will run again.
SOLDIER
The core of the AI will be carried by the soldier's entity and citizen's entity. The citizen can advise from zombies atack and the soldiers fight. Soldiers can find zombies, but they don't patroll too far, so they need the citizens.
Behaviour Tree & Atomic behaviours
Back to patrol: This same task is used both in the soldier and in the citizen. Activates the scripts needed to make a path and returns true when it reaches the destination.
Patrol: This task is also used in the citizen and the soldier. It activates the tracking of a path fixed in the perception script of the gameobject that is executing this task. When is used by the soldier, return true if any citizen warns him of the presence of a zombie, and returns false if there is some turret unloaded (the turrets are smart objects that send messages to the soldiers about the ammunition they have).
Go To Unload Turret: The soldier makes a path to the turret and returns false when it is near it.
Reload Turret: The soldier reloads the turret and returns false, in this way the beheaviour tree is executed again making it go back to the task: Back to Patrol.
Search For Threats: The soldier calculates the path to the warned zombie and the movement scripts are executed.
Threat found decorator: Allows you to advance to the beheaviour tree when the soldier has the zombie within reach.
Delete Threats: The soldier eliminates the zombie and executes the sound and appropriate animations. Finally the behavior tree is again executed.
ZOMBIE
Behaviour Tree & Atomic behaviours
Lazy Walk: The zombie goes towards the military base, it returns true in case of detecting a citizen / soldier / turret. And it returns false in case of detecting that the entry in which it is found has been blocked.
Find Other Entry: In this task, the zombie will look for an entry that has not been blocked and will go to it. It returns false as soon as it is in a clear entry and, therefore, the behaviour tree will run again, returning to the task: Lazy Walk.
Chase People: This task will execute the steering behavior of pursuing the citizen detected in the task Lazy Walk. This task returns false when the zombie is shot by a turret or soldier.
Die: In this task the zombie reacts to the received shots with audio and animation to be later eliminated.
CITIZEN
Behaviour Tree & Atomic behaviours
Back to patrol: This same task is used both in the soldier and in the citizen. Activates the scripts needed to make a path and returns true when it reaches the destination.
Patrol: This task is also used in the citizen and the soldier. It activates the tracking of a path fixed in the perception script of the gameobject that is executing this task. When patrol is used by the citizen, return true if the citizen see any zombie or return false if you build a barricade where he was patrolling.
Go home: This task builds a path for the citizen to return to the city and be destroyed.
Advice Soldier: The nearest soldier is searched, a path is made to it and the movement scripts are executed.
Zombie Warned decorator stops the flow of the behaviour tree until the citizen is within reach of the soldier.
Wait: The citizen waits till the warned zombie is killed, then return false and the behaviour tree starts again.
TURRET
The turret, being a fairly simple intelligent object, is managed with a simple state machine.
Atomic behaviours:
Wait: The turret will wait until a zombie enters its firing zone.
Point: The turret will aim at the zombie before shoots.
Shoot: Shoot a zombie and kill him instantly.
Reload: After shoot, turret will be useless until a soldier go and reload the turret. In this phase, the turret will send messages to the nearest soldier to recharge.
How to play
Each dead zombie provides gold coins which is the main resource of the game. With these coins the player will have the option of increasing the number of military buildings in case there are missing soldiers in the base, barricades can be bought at the entrance of the base so that the soldiers can cover themselves from the enemy shots and build the medical camp to heal wounded soldiers.
The objective is to defend a specific number of rounds the base, each enemy horde will be more difficult than the previous one. If the user does not build the buildings or barricades in the correct order he will soon be defeated by the zombies.