Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
0 Welcome to the target handler. 1
The target handler is another layer on top of the sensor manager. 2
If you don't know about the sensor manager, I recommend you go check the other video about it. 3
The target handler is a system that hooks up to the signals sent by the sensor manager, keeps track 4
of the current target and informs other parts of the AI 5
if the target was lost or acquired. Another functionality of the target handler is when a target that 6
was previously acquired has become invisible. 7
That means that maybe it has moved behind an obstacle like a building. 8
In this case, a lose target sequence is started, and if the target is not found, it will be permanently 9
lost. 10
We need two signals and they will be called when the target has updates. 11
So on_target_found and on_target_lost and they will both provide what target was found and what target 12
was lost. In the initialize 13
we have the usual suspects which are the parameters given by the key-pair value style of initializing and 14
we hook to the sensor managers on target list update. 15
This is the most important part of this one because this will parse the actual list that was received 16
by the sensor manager. 17
We'll also use a callback to the lose target timer. 18
The main point of entry for this script is on_target_list_update when it actually receives the list 19
of targets from the sensor manager. 20
And here, what we need to do is, of course, we need to parse this list and get the target that is 21
the closest to this particular enemy instance. 22
So to do this, we actually put up a minimum distance and this should be quite huge and the target that 23
has been found so far. 24
Then we parse the new target list and for each target we calculate the distance. 25
And if the distance is less than the minimum distance, then the new minimum distance will get this 26
current distance and the target will be this one. 27
And this assures that even if there is one target far away since the initial minimum distance is 9999, 28
then then this means that it will be picked, but then once this gets updated, then it will go 29
for closer and closer targets. 30
If you don't have a target, then this means that the current target is null and the minimum distance 31
target is not null. 32
And this is the perfect case scenario because we initialize the current target with this one. 33
We stop the lose target timer, which actually runs all the time while we don't have the target in our 34
sensors. 35
And lastly, we set was_target_acquired_internally to true. This will be used in another part of this 36
script. 37
And the other alternative is when the target gets acquired, not through the tank sensors, but if the 38
tank gets informed by a signal or if the enemy gets hit from far away by the player. And if a target 39
was found, then we emit the signal on target found with the current target. 40
Once we have the target in place, we need to update its visibility at every frame. 41
This happens in _process() and we have here update target visibility. 42
How do we do this? 43
Well, first, we need to make sure that the current target is still valid. 44
This means that it was not destroyed it by some other AI instance. 45
Then we have two variables is_in_range and is_visible. 46
is_in_range is actually true or false. 47
Based on the range sensor and the visible is the raycast from the enemy instance to the target. is_visible 48
will be true in this case. 49
But if we actually opt for the enemy to use the line of sight, then is_visible will query the sensors 50
for the raycast and it would set to true or false. 51
In some cases like the tactical tank AI, 52
we don't need this as we just use the range sensor. 53
But for the other two tanks this will be used. 54
Next, we can use this functionality to check if it's in_range and is_visible and if it is in both, 55
then the target_is_in_the_fire_range (= true). 56
Otherwise it's false. 57
Note that even if the tank doesn't use the raycast, we can still use visible because it would be set 58
to true here. 59
We don't have to worry about that. 60
And if the target is in the fire range, then we no longer need the last known position. 61
We just move it -500 meters below and we stop the lose target timer. 62
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
is stopped, then this means that we just lost the target. 64
First we create the lose target time and this is where was_target_acquired_internally 65
works because this time is what gets initialized in the timer lose target. 66
And if the target was acquired internally, this means it might be nearby, in almost the sensors of the 67
tank. 68
And if it was externally (provided), it means that it might be further away. 69
For example, from a communicator signal. 70
This lose target externally is a little bigger. 71
To give the opportunity of this tank to actually move to the target's position before it actually loses 72
it. 73
This final check is actually, in some cases, for the defensive tank. 74
We disable this functionality. 75
If it's not disabled, if it's true, then we start the lose target timer with the value that 76
we just initialized. 77
We also update the last known position to the target's last known position. 78
And lastly, we set up the finite state machine's target_in_fire_range, either true or false based on 79
all of this processing. 80
When lose target finishes, it will emit the signal that the target was lost. 81
Basically when lose target timer reaches zero 82
this means that we failed to acquire back to the target and we can call the on target loss signal and remove 83
the current target. 84
Make it null and this will actually permanently forget about the target. 85
Other functionalities here are disable lose target and enable lose target, which set up the should 86
lose target to either true or false. 87
These are for the defensive AI and they are called only when this AI goes into hiding because it will surely 88
trigger this and we don't want to lose the target after its functionality happens. 89
Basically, this is the target handler. 90
Let me know in the comments what to think about this.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.