Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
0
1
00:00:00,000 --> 00:00:01,650
Welcome to the target handler.
1
2
00:00:01,680 --> 00:00:05,010
The target handler is another layer on top of the sensor manager.
2
3
00:00:05,040 --> 00:00:09,880
If you don't know about the sensor manager, I recommend you go check the other video about it.
3
4
00:00:09,900 --> 00:00:15,810
The target handler is a system that hooks up to the signals sent by the sensor manager, keeps track
4
5
00:00:15,810 --> 00:00:18,960
of the current target and informs other parts of the AI
5
6
00:00:18,990 --> 00:00:24,870
if the target was lost or acquired. Another functionality of the target handler is when a target that
6
7
00:00:24,870 --> 00:00:27,480
was previously acquired has become invisible.
7
8
00:00:27,510 --> 00:00:31,920
That means that maybe it has moved behind an obstacle like a building.
8
9
00:00:31,950 --> 00:00:37,710
In this case, a lose target sequence is started, and if the target is not found, it will be permanently
9
10
00:00:37,710 --> 00:00:38,130
lost.
10
11
00:00:38,160 --> 00:00:42,530
We need two signals and they will be called when the target has updates.
11
12
00:00:42,540 --> 00:00:49,260
So on_target_found and on_target_lost and they will both provide what target was found and what target
12
13
00:00:49,260 --> 00:00:51,150
was lost. In the initialize
13
14
00:00:51,180 --> 00:00:57,850
we have the usual suspects which are the parameters given by the key-pair value style of initializing and
14
15
00:00:57,850 --> 00:01:01,110
we hook to the sensor managers on target list update.
15
16
00:01:01,140 --> 00:01:06,450
This is the most important part of this one because this will parse the actual list that was received
16
17
00:01:06,450 --> 00:01:07,560
by the sensor manager.
17
18
00:01:07,590 --> 00:01:11,040
We'll also use a callback to the lose target timer.
18
19
00:01:11,070 --> 00:01:17,340
The main point of entry for this script is on_target_list_update when it actually receives the list
19
20
00:01:17,340 --> 00:01:20,240
of targets from the sensor manager.
20
21
00:01:20,250 --> 00:01:26,190
And here, what we need to do is, of course, we need to parse this list and get the target that is
21
22
00:01:26,190 --> 00:01:29,740
the closest to this particular enemy instance.
22
23
00:01:29,760 --> 00:01:35,670
So to do this, we actually put up a minimum distance and this should be quite huge and the target that
23
24
00:01:35,670 --> 00:01:37,350
has been found so far.
24
25
00:01:37,380 --> 00:01:42,660
Then we parse the new target list and for each target we calculate the distance.
25
26
00:01:42,660 --> 00:01:47,910
And if the distance is less than the minimum distance, then the new minimum distance will get this
26
27
00:01:47,910 --> 00:01:50,480
current distance and the target will be this one.
27
28
00:01:50,490 --> 00:01:56,200
And this assures that even if there is one target far away since the initial minimum distance is 9999,
28
29
00:01:56,220 --> 00:02:02,130
then then this means that it will be picked, but then once this gets updated, then it will go
29
30
00:02:02,130 --> 00:02:04,320
for closer and closer targets.
30
31
00:02:04,500 --> 00:02:09,300
If you don't have a target, then this means that the current target is null and the minimum distance
31
32
00:02:09,300 --> 00:02:10,350
target is not null.
32
33
00:02:10,350 --> 00:02:15,070
And this is the perfect case scenario because we initialize the current target with this one.
33
34
00:02:15,090 --> 00:02:22,290
We stop the lose target timer, which actually runs all the time while we don't have the target in our
34
35
00:02:22,290 --> 00:02:22,890
sensors.
35
36
00:02:22,900 --> 00:02:28,380
And lastly, we set was_target_acquired_internally to true. This will be used in another part of this
36
37
00:02:28,380 --> 00:02:28,830
script.
37
38
00:02:28,830 --> 00:02:35,340
And the other alternative is when the target gets acquired, not through the tank sensors, but if the
38
39
00:02:35,340 --> 00:02:41,760
tank gets informed by a signal or if the enemy gets hit from far away by the player. And if a target
39
40
00:02:41,760 --> 00:02:45,930
was found, then we emit the signal on target found with the current target.
40
41
00:02:46,020 --> 00:02:51,120
Once we have the target in place, we need to update its visibility at every frame.
41
42
00:02:51,120 --> 00:02:55,960
This happens in _process() and we have here update target visibility.
42
43
00:02:56,010 --> 00:02:57,240
How do we do this?
43
44
00:02:57,270 --> 00:03:01,020
Well, first, we need to make sure that the current target is still valid.
44
45
00:03:01,170 --> 00:03:04,770
This means that it was not destroyed it by some other AI instance.
45
46
00:03:04,800 --> 00:03:08,100
Then we have two variables is_in_range and is_visible.
46
47
00:03:08,140 --> 00:03:10,420
is_in_range is actually true or false.
47
48
00:03:10,500 --> 00:03:17,340
Based on the range sensor and the visible is the raycast from the enemy instance to the target. is_visible
48
49
00:03:17,340 --> 00:03:18,900
will be true in this case.
49
50
00:03:19,050 --> 00:03:26,220
But if we actually opt for the enemy to use the line of sight, then is_visible will query the sensors
50
51
00:03:26,220 --> 00:03:29,790
for the raycast and it would set to true or false.
51
52
00:03:29,820 --> 00:03:32,140
In some cases like the tactical tank AI,
52
53
00:03:32,430 --> 00:03:35,400
we don't need this as we just use the range sensor.
53
54
00:03:35,400 --> 00:03:37,950
But for the other two tanks this will be used.
54
55
00:03:38,100 --> 00:03:43,950
Next, we can use this functionality to check if it's in_range and is_visible and if it is in both,
55
56
00:03:44,070 --> 00:03:46,060
then the target_is_in_the_fire_range (= true).
56
57
00:03:46,080 --> 00:03:47,370
Otherwise it's false.
57
58
00:03:47,460 --> 00:03:53,100
Note that even if the tank doesn't use the raycast, we can still use visible because it would be set
58
59
00:03:53,100 --> 00:03:53,960
to true here.
59
60
00:03:53,970 --> 00:03:55,710
We don't have to worry about that.
60
61
00:03:55,950 --> 00:04:00,780
And if the target is in the fire range, then we no longer need the last known position.
61
62
00:04:00,780 --> 00:04:06,900
We just move it -500 meters below and we stop the lose target timer.
62
63
00:04:07,200 --> 00:04:13,530
If it's not in the range, then this means we have to do a lot of other stuff and if the lose target timer
63
64
00:04:13,530 --> 00:04:16,500
is stopped, then this means that we just lost the target.
64
65
00:04:16,560 --> 00:04:20,370
First we create the lose target time and this is where was_target_acquired_internally
65
66
00:04:20,370 --> 00:04:25,950
works because this time is what gets initialized in the timer lose target.
66
67
00:04:25,950 --> 00:04:32,580
And if the target was acquired internally, this means it might be nearby, in almost the sensors of the
67
68
00:04:32,580 --> 00:04:33,030
tank.
68
69
00:04:33,030 --> 00:04:36,660
And if it was externally (provided), it means that it might be further away.
69
70
00:04:36,750 --> 00:04:38,610
For example, from a communicator signal.
70
71
00:04:38,850 --> 00:04:42,420
This lose target externally is a little bigger.
71
72
00:04:42,420 --> 00:04:48,360
To give the opportunity of this tank to actually move to the target's position before it actually loses
72
73
00:04:48,360 --> 00:04:48,600
it.
73
74
00:04:48,630 --> 00:04:52,710
This final check is actually, in some cases, for the defensive tank.
74
75
00:04:52,740 --> 00:04:54,540
We disable this functionality.
75
76
00:04:54,540 --> 00:04:59,880
If it's not disabled, if it's true, then we start the lose target timer with the value that
76
77
00:04:59,930 --> 00:05:01,310
we just initialized.
77
78
00:05:01,490 --> 00:05:05,250
We also update the last known position to the target's last known position.
78
79
00:05:05,270 --> 00:05:10,820
And lastly, we set up the finite state machine's target_in_fire_range, either true or false based on
79
80
00:05:10,820 --> 00:05:12,020
all of this processing.
80
81
00:05:12,050 --> 00:05:17,210
When lose target finishes, it will emit the signal that the target was lost.
81
82
00:05:17,840 --> 00:05:20,840
Basically when lose target timer reaches zero
82
83
00:05:20,870 --> 00:05:27,980
this means that we failed to acquire back to the target and we can call the on target loss signal and remove
83
84
00:05:27,980 --> 00:05:28,790
the current target.
84
85
00:05:28,800 --> 00:05:32,150
Make it null and this will actually permanently forget about the target.
85
86
00:05:32,240 --> 00:05:38,450
Other functionalities here are disable lose target and enable lose target, which set up the should
86
87
00:05:38,450 --> 00:05:40,550
lose target to either true or false.
87
88
00:05:40,730 --> 00:05:48,470
These are for the defensive AI and they are called only when this AI goes into hiding because it will surely
88
89
00:05:48,470 --> 00:05:52,910
trigger this and we don't want to lose the target after its functionality happens.
89
90
00:05:53,060 --> 00:05:54,800
Basically, this is the target handler.
90
91
00:05:54,860 --> 00:05:57,320
Let me know in the comments what to think about this.
9774
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.