Ok, this is the newest version:
;....by the position of the target to the angle of acquisition of the Torpedo's targeting system wich I set to 120 degrees....
_source = _torp
_target = sub
_sourcedir = getdir _torp
_degree = ((getpos _target select 0) - (getpos _source select 0)) atan2 ((getpos _target select 1) - (getpos _source select 1))
?_degree < 0:_degree = _degree + 360
;The better the alignement of the Torpedo respect the target the higher the chance to hit
;This simulate the time spended by the Torpedo in maneuvering for a proper alignement
_degree = _degree - _sourcedir
?_degree >= 61 : _Angleperc = 16 ; hint format ["più %1, risulta %2, atteso 16", _degree, _Angleperc]
?_degree <= 40 : _Angleperc = 18 ; hint format ["più %1, risulta %2, atteso 18", _degree, _Angleperc]
?_degree <= 20 : _Angleperc = 20 ; hint format ["più %1, risulta %2, atteso 20", _degree, _Angleperc]
All seem to work fine, now.
For the moment, I've decided not to put any function file as this script is part of a suite and my intention is to take the amount of files as low as possible.
However, Raptosaurus, your files gave me the solution to my problem.
Thanks a lot for your help. :thumbsup: