Lorenzo Ortiz's profile

Coding: Boss AI (UNIT 2: GAME ALGORITHMS)

Boss AI
Notes: A defined variable is customizable in the inspector.
          All the scripts related to the boss are completely original, except the scripts related to the player.

Skills
The boss has 7 abilities in total: 4 attack and utility skill(s) and 3 movement skills.

Movement Skills
All movement abilities will last for a duration, and will occur before another duration, both of which depends on the ability executed before them.
The boss normally always smoothly turns to the target's position by a defined rate, with exceptions of some movement and attack and utility skills.

~Walk: Move the boss towards the player by a defined speed until a certain distance, which when reached will switch to shuffling around the target with a 50% chance of selecting left or right to shuffle towards. This ability has a defined percent chance to trigger "Teleportation To Near" first before moving.

~Shuffle Around Target: Shuffles around the target by a defined speed. The direction (left or right) is selected at random with a 50% chance. This ability has a defined percent chance to trigger "Teleportation To Near" first before moving.

~Backup: Backs up from the target by a defined speed.

Attack and Utility Skills
All attack and utility skills occur after a duration based off the previous attack or utility skill.
All attack and utility skills set a unique defined cooldown before movement occurs, and another cooldown before another attack or utility skill can be executed.
All projectiles are spawned at the same offset from the boss, which may be modified based on the ability.
All projectiles' speed and damage can be defined directly from the boss script.

~Spread Shot: Fires three round bursts of projectiles, with each round having one more projectile than the previous round. The number of projectiles and the increase in projectiles per round are defined by a value. The horizontal and vertical offset of the projectiles with each other and the rotation is based off a formula using defined values respectively, and the amount of projectiles of the round.

~Cosmic Charge: A short ranged area of effect charge attack. The boss backs up from the target by a defined offset based off it's position for a defined amount of time. Then the boss charges towards the player's direction with a defined negative offset for a defined amount of time. The boss will then wait for a defined amount of time (seconds), then continuously damage the target in front of the boss by a defined value in a defined area. Visual projectiles are instantiated in groups of three inside the area to indicate the attack. The charge distance is limited and will clamp to a defined value.

~Blood Hunter: A barrage and precision type projectile attack. Blood Hunter projectiles are instantiated into a customizable circular area which can be defined using a formula, and is based off the boss's position and rotation (the direction the boss is facing). The projectiles then seek out the target at a defined speed after a defined delay.

~Teleport To Near: Teleports the boss to the target's position with a definable offset and faces the boss towards the direction of the teleportation after an animation with an adjustable speed. A delay between the boss's teleportation to the targeted area can also be defined, but is currently left at zero. During this process, the rotation and position of the boss is frozen, and is unaffected by gravity. This skill is written in a way that changes based on if it is used as a utility skill or if it is combined with a movement skill. This skill can only be used once in succession when executed as a utility skill, with the exception of using it in conjunction with movement skills. The skill can be used again when another skill other than itself is used. The defined values for both cooldowns of this skill when used as a utility skill are both zero.

Projectiles (and scripts)
All projectiles have a defined lifetime, or a condition that will be reached for the projectile to expire.
All projectiles send damage values to their target on collision.

~Spread Shot Projectile: A projectile with a defined speed and a defined direction based on the Spread Shot skill.

~Cosmic Aftermath Projectile: A visual projectile that is instantiated in a random position inside the Cosmic Charge's hitbox after charging. Each projectile has a random scale selected using 2 defined values.. An animation utilizing the projectile's scale is used with a definable speed. The animation fades the projectile in and out, changing it scale values along the way.

~Blood Hunter Projectile: A projectile spawned by the Blood Hunter skill. The projectile moves from a defined spawn point to a random position in a calculated circular area at a defined offset. The circle can be customized to generate positions from a whole circle, a donut-like shape, to only using the perimeter of the circle. After a defined amount of time, the projectiles each in succession move at a defined constant speed to a certain distance, at which point they home in and curve to their target's position, along with smoothly looking towards the targeted position. Once a certain distance is reached, the projectile will save the target's position and move towards it, and then expire afterwards.



The Cooldown feature: Two sets of cooldowns are used which are unique to each attack or utility skill that finishes executing. After a first defined cooldown, a movement skill will execute which will last until the second cooldown expires, at which point another attack or utility skill will be executed. If both cooldowns are zero, an attack or utility skill will be executed.

The Moveset Picker: This method is responsible for choosing the boss's next attack or utility skill. The moveset picker will pick between three movesets (melee, ranged, and special movesets) in which all three movesets are based on the distance of the boss to the player (3 total distance modes,9 movesets in total). Skills may be in more than one moveset at a time. The movesets are picked based on a defined percent chance, with the special movesets having the lowest chances. The skill in the chosen moveset will then be picked at random. The moveset picker will not pick teleportation skills once the boss has teleported once before using another attack or utility skill. The moveset picker is written in a way that conditions based on a specific skill can be added easily. 

Since there are only four attack and utility skills, they are placed in a moveset for close and mid range distances. The "Teleportation To Near" skill is also used for far distances since all 3 attack skills are relatively close ranged.
A separate moveset picker is used for selecting movement skills.

The Boss Stats: This script takes the damage of all enemy attacks and factors in other values then uses the final value as the damage to deduct to the boss's health. However, in this project the raw damage value is used without using these factors. These factors include: defense, armor, physical resistance, magical resistance, and percent damage reduction. This script also supports damage over time.
Coding: Boss AI (UNIT 2: GAME ALGORITHMS)
Published:

Coding: Boss AI (UNIT 2: GAME ALGORITHMS)

Published:

Creative Fields