Monday, 18 April 2016

Year 3: Game update: Disperser

Disperser

As the main point of the game is to survive the implementation of the basic defense tower is very important and crucial in the game's development. It began by first creating the blueprint and implementing basic variables about that blueprint.


First off I decided to make a sort of base blueprint that can be change to make more and different types of towers. This involves making default variables such as Tower name, Health, starting tier number as well as can this Tower produced resources. The full list is:
.Tower name(string)
.Tower health(Float):
.Tower tier level(Int):
.Tower type(Array string):
.Tower type the rain(Int):
.Tower costs Sunlight(Int):
.Tower costs Sunlight divide number(Int): this is how more the cost of the sunlight resource is provided by then returned to the player when they sell the tower.
.Tower costs Food(Int):
.Tower costs Food divide number(Int):this is how more the cost of the Food resource is provided by then returned to the player when they sell the tower.
.Tower costs Water(Int):
.Tower costs Water divide number(Int):this is how more the cost of the Water resource is provided by then returned to the player when they sell the tower.
.Resource production Sunlight(Bool):
.Resource production Water(Bool):
.Resource production Tree(Bool):
.Resource collection rate Sunlight(Int):
.Resource collection rate Water(Int):
.Resource collection rate Tree(Int):
.Tower combat type(Array string):
.Tower combat type array number(Int):
.Tower damage resistance percent (Int):
.Tower health regen(Int):
 Tower health regen wait time(Float):


When it comes to the Turret variables here are the defaults variables:
.Tower damage per shot (Float)
.Tower rate of fire per second(Float)
.Rotation rate(Float)
.Tower range(Float)
.Tower is ranged(Bool)
.Tower reloading(Bool)
,Combat description(String)
.Damage type(String array)
.Damage type array number(Int)
.Turret looking at unit(Bool)


All these variables are there to set up the turret system as well as basic stats about the tower. These variables will be used in the blueprint code to create the basic functionality of the turrets of them.



Section 1 Finding enemy:
1.we start off this line in blueprint with a custom events as a copy from the events tick (events that sends a tick every frame). 

2.It then goes into a delayed for 1.5 seconds in order self offer so that it doesn't overload the event line. 

3.The event is then spreads by a sequence into two lines these two accounts of two different types of enemies the Conqueror AI and the warlord AI.

4.Next we get all the actors of class which is Conqueror AI character

5. A foreachloop node then adds all the actors found into one line to lock individually at each actor found.

6. A brackets then checks if the actor has an "Enemy" tag

7.If true we then change the bool "first contact made" to true

8. then add the actor from the foreachloop to the enemy unit array to use later 



Section 2 fire Tower when the unit is within range:

1. Starts of with an customer event copied from the event tick

2.a delay than only allows the event tick to go through every 0.1 seconds

3. A sequence node than splits the tech into three separate ticks

4. From "then 0" take a foreachloop using the "Enemy unit" 

5. we then get the distance from "Self"  which is the tower to the enemy coming from the array elements from the foreachloop. 

6.We then compare this to the towers range and if the distance from self to an enemy units is less or equal to the tower range it then passes through the branch as true

7.We then check with a branch if the tower is range if true we then proceed

8.We then check with a branch if a target is found if false we then proceed

9.Then we change the target is found bool to true

10.then we take the array elements from the foreachloop and set to the target enemy variable

11.back to the sequence are going through the " then 1" and first hit the "Unit out of range" node collapse

12. The "Unit out of range" node is to ensure that when the unit goes out of range and returns that it can be re-targeted by the the "then 0" code line.

13. The "Then 2" from the sequence goes to a branch to check if at target has been found

14. we then check the distance between the targets enemy and self and if it is less than the tower range it then goes through the branch as true

15.We then use another branch to check if " first contact has been made"

16.we then use another foreachloop on the enemy units array

17.we then use a branch to check if the target enemy is not equal to any of the units in the "enemy unit array" 

18.we don't get the distance from the target enemy and self and if it is less than or equal to it goes through a branch.

19.We then finally check if the tower is range with a branch

20.then resets the target enemy to a new enemy units from the foreachloop used previously.  what this line of code is designed to do is that when a unit leaves the  at the range radius it then re-establishes a new target within the range to fire upon.


Section 3 rotating tower pivots:

1. we start off with a custom event called " updates rotation"  this is  and events copied from the event tick. due to the fact that the pivot will be retained to follow a unit this must be updated every frame

2. we then go straight into a branch which checks if the target enemy is valid checking if it is actually assigned a value.

3.we then check the distance from the enemy to itself and if it is less than or equal to the tower range it then passes through the next branch

4. then set the world rotation of the tower pivots this works by getting the tower pivots and the target enemy will locations finding the walk at rotation then breaking the rotation and only using the Y( pitch) and Z (yew) than make rotation then using the rinterp to node we use the made rotation as the targets and the tower pivots well rotationas the current with then use the delta time and use rotation rate as the interp speed then we use this in the set rotation node as the new rotation.

5.we next user branch and compare the world rotation of the tower pivot with the make rotation from the last six code line we also use a error of one just in case of potential errors to a care  later down the line.

6.if true we then set "tower is looking at unit" to true

7.if false we then set "tower is looking at unit" to false

8. This is then used to tell when the tower is looking directly at the units so things like project files online traces can learn how the green lights to go ahead and fire.


Section 4 fire line trace:

1.start off with a custom events called Fire Tower weapon this is copied from the "events tick"

2.we then use a branch to check if the tower is reloading then they proceed if false

3. use another branch to check if the turret is looking at the units if true will proceed.

4.  with an use another branch the track the distance from the target enemy to self and if less than or equal to the tower range it proceeds is true

5. we then use another branch the check if the target unit is valid if true will proceeds

6. with then use the line of trees by channel mode using the tower barrel world location as the starting vector and then using the target enemy at that location as the endpoint

7.once fired we don't break the results to give us more information we then get that hit at their information as this will count as the enemy hit by the turrets.

8.We then use a branch to check if the object hit has an enemy tag

9.We then send an event to the target enemy which sends the tower damage per shots to be calculated on the AI

10. we then set the tower is reloading variable to true

11.with then use a function that can construct a projectile launcher towards the enemy

12.we then use a delay and use the "tower rate of fire per second" as the variable to weeks

13.Then we sat back the " tower is reloading" variable the false


Section 5 Delete units from array when the unit has died:

1. first starts off with the events than enemy is died which is sent from the AI when is destroyed.

2.we then use a branch to check if "first contact has been made" if true it then proceeds

3.we then use a sequencer cut into two lines

3. using a branch to check if the enemy units that came through starting event is equal to the target enemy if true we then send the pulse through

4.we then set the " target found" to false

5. from the sequence "then 1" we then remove the enemy unit from the starring events from the enemy units array






No comments:

Post a Comment