; For 1.38 ver

Var Num
var t
var Q
var Mayak

IF INIT THEN {
Mayak = 0
if not q then { q = 1 NUM = ( TIME + RND 500 + RND 500 + RND 500 ) } endif
	t = GETENTVAR "FinalPhazeN"
	if Tgtconf > GETENTVAR "ZZZconf" then {
		SetEntVar "ZZZConf" Tgtconf
		SetEntVar "NUM_TH" Num
		SetEntVar "TRNG" TGTRNG
		SetEntVar "TALT" TGTALT
		SetEntVar "homing" 1
	} endif
} elseif not q then {

} elseif ( num != GETENTVAR "NUM_TH" ) and ( Tgtconf < GETENTVAR "ZZZconf" ) then {
	drop
} elseif Tgtconf > GETENTVAR "ZZZconf" then {
	SetEntVar "TN" TargetName
	SetEntVar "NUM_TH" Num
	SetEntVar "ZZZConf" Tgtconf
	SetEntVar "TRNG" TGTRNG
	SetEntVar "TALT" TGTALT
	SetEntVar "homing" 1
} ELSEIF Num == GETENTVAR "NUM_TH" then {
	
if LOSTTRACK then {
		q = 0
		SetEntVar "NUM_TH" 0
		SetEntVar "ZZZConf" 0
	} ELSEif tgtrng != 0 then {
		IF TGTRNG < 1450 THEN {
			SetEntVar "NUM_TH" Num
			SetEntVar "ZZZConf" Tgtconf
			SetEntVar "TN" TargetName
			SETPRIORITY 255 SETPERSIST 1 TERMINALHOME
		} else {
			SetEntVar "TRNG" TGTRNG
			SetEntVar "TALT" TGTALT
			SetEntVar "homing" 1
			SETPRIORITY 254 SETPERSIST 1 setcrs xybrg ( tgtx - ownx ) ( tgty - owny )
		} ENDIF
	} ENDIF
} ENDIF
Mayak += 1
