; SurfAtkSubPLO Doctrine DWX 1.41

var FATRANG
var SafeSpd
var towedIdx

IF INIT THEN {
towedIdx = DBIdxFromRecNum 1413
IF ( GetEntVar "TowedCounter" < 1 ) Then {
	CountermeasureIdx towedIdx 
	SetEntVar "TowedCounter" ( GetEntVar "TowedCounter" + 0.5 )
} endif
	SafeSpd = ( GetEntVar "PassiveWashout" )
	IF SafeSpd <= 1 Then { SafeSpd = 25 } endif
} ENDIF

IF ( GetEntVar "TypeShip" == 1 ) THEN {
	IF TgtID $= "HOSTILE" THEN {
		if AttackRng == 0 then {
			IF NOT FATRANG THEN {
				SteerAbeam
			} ENDIF
		} elseif AttackRng < tgtrng then {
			SETPRIORITY 253 INTERCEPT
			SetSpd SafeSpd
		} else {
			SetSpd SafeSpd
			SETPRIORITY 254 attackbest
		} endif
	} endif
} endif
IF ( GetEntVar "TypeShip" == 3 ) THEN {
	IF TgtID $= "HOSTILE" THEN {
		if AttackRng == 0 then {
			IF NOT FATRANG THEN {
				SteerAbeam
			} ENDIF
		} elseif AttackRng < tgtrng then {
			SETPRIORITY 253 SteerAbeam
		} else {
			SetSpd SafeSpd
			SETPRIORITY 254 attackbest
		} endif
	} endif
} endif
IF ( GetEntVar "TypeShip" == 1 ) Then {
	IF TgtID $= "UPD" THEN {
		SetSpd SafeSpd
		SteerTo
	} Endif
} Endif
