First the logic flow is not intuitive and is very disorganized on a design level. Second, the intercept routines will become the primary driver. Currently, there are any number of "intercept" routines. These will be consolidated into a two intercept routines (one for turning; one for thrust) and two avoidance routines (one for turning; one for thrust). Each of these routines will accept a Transform variable. The waypoint manager will just pass the waypoint's Transform to facilitate movement. In addition, other Transform variable can be passed to intercept routines.
The new outline will be:
1.
Initialize global variables
a.
Add an avoidance Transform variable
b.
Add an avoidance flag with a default value of
false
c.
Add an escape flag with a default value of false
2.
Target selection
a.
Iterate through all targets in the DradisList
i. Check
for collision zones
ii. Catalogue
eligible targets into a target list (limited to five targets) using range and
direction parameters
b.
If the fighter is in a collision zone or if
there is a collision alert via raycasting in front of the ship
i. Calculate
avoidance transform position
ii. Set
movement Transform variable to avoidance Transform calculated by this routine
iii. Set
the avoidance flag to true
c.
If fighter has sufficient fuel (less than 10%
fuel), has ammo and is combat capable (greater than 25% structure remaining)
execute maneuvering routines.
i. Selecting
a target from the target list
1.
If the target list is empty
a.
If there is a mission target
i. Set
mission target as current target
ii. Set
the escape flag to false
2.
If the target list is not empty
a.
Calculate probability baseline by adding an iteration
of the targets in the target list (5+4+3+2+1 = 15).
b.
Generate a random number based on baseline
number (1-15)
c.
Calculate number of item selected by iterating
through the number of targets in the target list (1-5 = 1, 6-10 = 2, etc…)
d.
Make the target associate with calculated number
the current target
e.
Set the escape flag to false
ii. If
the current target is null
1.
If there is a waypoint in the waypoint data
script
a.
Set the current target to the waypoint’s
Transform
2.
Otherwise
a.
Set the current target to the closest friendly
carrier ship
b.
Set the escape flag to true
d.
Otherwise
i. Set
the current target to the closest friendly carrier ship’s approach point
ii. Set
the escape flag to true
e.
If there’s an avoidance flag
i. If
the escape flag is true
1.
If the avoidance target is equal to the root
transform of the current target
a.
Set the avoidance target to null
b.
Set the avoidance flag to false
3.
Maneuver the ship
a.
If the avoidance flag is true
i. Execute
avoidance routine and pass the avoidance Transform variable
b.
Otherwise
i. Execute
the intercept routine and pass the current target
I got the waypoint system to function with the AI routine; however, I need to put the landing sequence back into the AI routine. That might be alittle problematic. Basically, I'll use the landing flag to shunt to the rarget selection to the approach point or landing point. Both variables will be used track the landing progress (approach and landing).
ReplyDeleteIn addition, I'm going to put the disengagement distance back into the AI routine. Basically, it sets a disengagement flag and flies away from the disengagement transform up to twice the avoidance distance. This can be overridden if the ship acquires a new target.
Once these two features are back in the game, I can incorporate the waypoints into the HUD script. I'll blog that once I'm at that point.
I was going to blog the ideas for incorporating the waypoint system into the HUD display; however, I just finished it...
ReplyDeleteI guess I should start working on the first tutorial and creating an event manager that can handle the requirements for the tutorial.