class IsNPCInPrevention extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( GetPuppet( context ).IsPrevention() && !( NPCManager.HasTag( ScriptExecutionContext.GetOwner( context ).GetRecordID(), 'Scripted_Patrol' ) ) )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

class IsNPCInActivePoliceChase extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var prevSpawnSys : PreventionSpawnSystem;
		prevSpawnSys = GameInstance.GetPreventionSpawnSystem( ScriptExecutionContext.GetOwner( context ).GetGame() );
		return ( NPCManager.HasTag( GetPuppet( context ).GetRecordID(), 'InActivePoliceChase' ) && !( NPCManager.HasTag( GetPuppet( context ).GetRecordID(), 'Scripted_Patrol' ) ) ) && ( prevSpawnSys.IsEntityRegistered( ScriptExecutionContext.GetOwner( context ).GetEntityID() ) || GetPuppet( context ).IsCrowd() );
	}

}

class IsNPCMaxTac extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return NPCManager.HasTag( GetPuppet( context ).GetRecordID(), 'MaxTac_Prevention' ) || NPCManager.HasTag( GetPuppet( context ).GetRecordID(), 'MaxTac_NotPrevention' );
	}

}

class IsPreventionSystemActive extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var IsPreventionActive : Bool;
		IsPreventionActive = PreventionSystem.IsChasingPlayer( ScriptExecutionContext.GetOwner( context ).GetGame() );
		return IsPreventionActive;
	}

}

class IsLastPlayerPositionEmpty extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var vector : Vector4;
		vector = ScriptExecutionContext.GetArgumentVector( context, 'In_LastKnownPosition' );
		if( Vector4.IsXYZZero( vector ) )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

class MinimalDistanceToLastKnownPosition extends PreventionConditionAbstract
{
	editable inlined var desiredDistanceArgument : AIArgumentMapping;
	var desiredDistance : Float;
	var preventionSystem : PreventionSystem;

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( PreventionSystem.GetSystemName() ) ) );
		desiredDistance = ( ( Float )( ScriptExecutionContext.GetMappingValue( context, desiredDistanceArgument ) ) );
		return Vector4.Distance( ScriptExecutionContext.GetOwner( context ).GetWorldPosition(), preventionSystem.GetLastKnownPlayerPosition() ) > desiredDistance;
	}

}

class HasLastKnownPositionChanged extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var previousLastKnownPosition : Vector4;
		var preventionSystem : PreventionSystem;
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( PreventionSystem.GetSystemName() ) ) );
		previousLastKnownPosition = ScriptExecutionContext.GetArgumentVector( context, 'In_LastKnownPosition' );
		if( Vector4.Distance( previousLastKnownPosition, preventionSystem.GetLastKnownPlayerPosition() ) > 30.0 )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

class ShouldWorkSpotPoliceJoinChaseCondition extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var preventionSystem : PreventionSystem;
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( PreventionSystem.GetSystemName() ) ) );
		return preventionSystem.ShouldWorkSpotPoliceJoinChase( ( ( ScriptedPuppet )( ScriptExecutionContext.GetOwner( context ) ) ) );
	}

}

class HasDeescalatedFromCombatWithPlayer extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var agentRegistry : PoliceAgentRegistry;
		agentRegistry = PreventionSystem.GetAgentRegistry( ScriptExecutionContext.GetOwner( context ).GetGame() );
		return agentRegistry.HasPoliceRecentlyDeescalated();
	}

}

class SetLastKnownPosition extends AIbehaviortaskScript
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		var gi : GameInstance;
		var preventionSystem : PreventionSystem;
		var threatData : DroppedThreatData;
		var tte : TargetTrackingExtension;
		var newVehicle : weak< VehicleObject >;
		gi = ScriptExecutionContext.GetOwner( context ).GetGame();
		tte = ( ( TargetTrackingExtension )( GetPuppet( context ).GetTargetTrackerComponent() ) );
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( gi ).Get( PreventionSystem.GetSystemName() ) ) );
		if( VehicleComponent.GetVehicle( gi, GetPlayer( gi ), newVehicle ) )
		{
			if( newVehicle.GetEntityID() != preventionSystem.GetLastKnownPlayerVehicle().GetEntityID() )
			{
				PreventionSystem.SetLastKnownPlayerVehicle( gi, newVehicle );
			}
		}
		if( tte )
		{
			threatData = tte.GetRecentlyDroppedThreat();
			if( threatData.threat )
			{
				if( Vector4.Distance( threatData.position, preventionSystem.GetLastKnownPlayerPosition() ) > 30.0 )
				{
					PreventionSystem.SetLastKnownPlayerPosition( gi, threatData.position );
				}
			}
		}
		ScriptExecutionContext.SetArgumentVector( context, 'In_LastKnownPosition', preventionSystem.GetLastKnownPlayerPosition() );
	}

}

class SetLastPlayerPositionByDefault extends AIbehaviortaskScript
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		var preventionSystem : PreventionSystem;
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'PreventionSystem' ) ) );
		PreventionSystem.SetLastKnownPlayerPosition( ScriptExecutionContext.GetOwner( context ).GetGame(), preventionSystem.GetPlayer().GetWorldPosition() );
		ScriptExecutionContext.SetArgumentVector( context, 'Out_LastChasePosition', preventionSystem.GetLastKnownPlayerPosition() );
	}

}

class SetPoliceVehicleAsLastKnownPosition extends AIbehaviortaskScript
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		var vehicle : weak< GameObject >;
		if( !( GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) ) )
		{
			return;
		}
		ScriptExecutionContext.SetArgumentVector( context, 'In_PoliceVehicleAsLKP_Failsafe', vehicle.GetWorldPosition() );
	}

}

class IsPlayerInVehicle extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var isPlayerInVehicle : Bool;
		var preventionSystem : PreventionSystem;
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'PreventionSystem' ) ) );
		isPlayerInVehicle = preventionSystem.GetPlayer().GetPlayerStateMachineBlackboard().GetBool( GetAllBlackboardDefs().PlayerStateMachine.MountedToVehicle );
		if( isPlayerInVehicle )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

class IsPlayerFarFromLKP extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var preventionSystem : PreventionSystem;
		var player : weak< PlayerPuppet >;
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( PreventionSystem.GetSystemName() ) ) );
		player = preventionSystem.GetPlayer();
		return Vector4.DistanceSquared( preventionSystem.GetLastKnownPlayerPosition(), player.GetWorldPosition() ) > ( 100.0 * 100.0 );
	}

}

class IsPoliceInCombatWithPlayer extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var agentRegistry : PoliceAgentRegistry;
		agentRegistry = PreventionSystem.GetAgentRegistry( ScriptExecutionContext.GetOwner( context ).GetGame() );
		return agentRegistry.IsPoliceInCombatWithPalyer();
	}

}

class IsPoliceUnawareOfThePlayerExactLocationCondition extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var preventionSystem : PreventionSystem;
		preventionSystem = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'PreventionSystem' ) ) );
		return preventionSystem.IsPoliceUnawareOfThePlayerExactLocation();
	}

}

class ManageSirensAndLightsInPoliceCar extends AIbehaviortaskScript
{
	editable inlined var turnOnLights : AIArgumentMapping;
	editable inlined var turnOnSirens : AIArgumentMapping;

	protected override function Activate( context : ScriptExecutionContext )
	{
		var vehicle : weak< GameObject >;
		var lights : Bool;
		var sirens : Bool;
		lights = ( ( Bool )( ScriptExecutionContext.GetMappingValue( context, turnOnLights ) ) );
		sirens = ( ( Bool )( ScriptExecutionContext.GetMappingValue( context, turnOnSirens ) ) );
		if( ScriptExecutionContext.GetOwner( context ).IsPrevention() )
		{
			if( VehicleComponent.IsDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ) ) && VehicleComponent.GetVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ), vehicle ) )
			{
				( ( VehicleObject )( vehicle ) ).GetVehicleComponent().ToggleLightsAndSirens( lights, sirens );
			}
		}
	}

}

class HasShootFromVehicleTicket extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var shouldStartShooting : Bool;
		var shootingDuration : Float;
		var vehicle : weak< VehicleObject >;
		if( VehicleComponent.GetVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ), vehicle ) )
		{
			shouldStartShooting = true;
			if( shouldStartShooting )
			{
				shootingDuration = 10.0;
				ScriptExecutionContext.SetArgumentFloat( context, 'Out_ShootFromVehicleDuration', shootingDuration );
				if( false )
				{
					return VehicleComponent.IsDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ) );
				}
				else
				{
					return !( VehicleComponent.IsDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ) ) );
				}
			}
		}
		return false;
	}

}

class IsPlayerInAPoliceCarChaseCondition extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return PreventionSystem.IsPlayerInAPoliceCarChase( ScriptExecutionContext.GetOwner( context ).GetGame() );
	}

}

class IsNPCInVehicle extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return VehicleComponent.IsMountedToVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ) );
	}

}

class HasNPCVehicleAssigned extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var vehicle : weak< GameObject >;
		return GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle );
	}

}

class HasPlayerTakenMyVehicle extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var vehicle : weak< GameObject >;
		var vehicleObject : VehicleObject;
		if( !( GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) ) )
		{
			return false;
		}
		vehicleObject = ( ( VehicleObject )( vehicle ) );
		if( ( vehicleObject && VehicleComponent.GetDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleObject, vehicle.GetEntityID() ).IsPlayer() ) && ScriptExecutionContext.GetOwner( context ).IsPrevention() )
		{
			ScriptExecutionContext.SetArgumentScriptable( context, 'MountRequest', NULL );
			return true;
		}
		else
		{
			return false;
		}
	}

}

class NullifyMountRequestBehaviourTask extends AIVehicleTaskAbstract
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.SetArgumentScriptable( context, 'MountRequest', NULL );
	}

}

class TryQueueEventToMountPoliceToVehicle extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var evt : AICommandEvent;
		var mountCommand : AIMountCommand;
		var mountData : MountEventData;
		var vehicleID : EntityID;
		var vehicleSlotID : MountingSlotId;
		var vehicle : weak< GameObject >;
		var vehicleObject : WheeledObject;
		var vehicleAIComponent : AIVehicleAgent;
		var aiComponent : AIHumanComponent;
		var slotName : CName;
		var av : AVObject;
		aiComponent = GetAIComponent( context );
		if( !( aiComponent ) || !( aiComponent.GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) ) )
		{
			return false;
		}
		if( ScriptExecutionContext.GetOwner( context ).IsPrevention() && aiComponent.IsAssignedVehicleStuck() )
		{
			return false;
		}
		if( !( aiComponent.GetAssignedVehicleData( vehicleID, vehicleSlotID ) ) )
		{
			return false;
		}
		if( VehicleComponent.IsDestroyed( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleID ) )
		{
			return false;
		}
		vehicleObject = ( ( WheeledObject )( vehicle ) );
		if( vehicleObject.ComputeIsVehicleUpsideDown() || ( vehicleObject.GetFlatTireIndex() != -1 ) )
		{
			return false;
		}
		if( VehicleComponent.GetDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleObject, vehicleID ).IsPlayer() || vehicleObject.IsVehicleInsideInnerAreaOfAreaSpeedLimiter() )
		{
			return false;
		}
		if( VehicleComponent.IsDriverSeatOccupiedByDeadNPC( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleID ) )
		{
			return false;
		}
		vehicleAIComponent = vehicleObject.GetAIComponent();
		if( !( vehicleAIComponent ) )
		{
			return false;
		}
		slotName = vehicleObject.GetAIComponent().TryReserveSeatOrFirstAvailable( ScriptExecutionContext.GetOwner( context ).GetEntityID(), 'first_available' );
		if( IsNameValid( slotName ) )
		{
			aiComponent.OnSeatReserved( vehicleObject.GetEntityID() );
		}
		else
		{
			return false;
		}
		av = ( ( AVObject )( vehicle ) );
		if( av )
		{
			return false;
		}
		mountData = new MountEventData;
		mountData.slotName = slotName;
		mountData.mountParentEntityId = vehicleID;
		mountData.isInstant = false;
		mountData.ignoreHLS = true;
		mountCommand = new AIMountCommand;
		mountCommand.mountData = mountData;
		evt = new AICommandEvent;
		evt.command = mountCommand;
		ScriptExecutionContext.GetOwner( context ).QueueEvent( evt );
		return true;
	}

}

class ReleaseReservedSeat extends AIbehaviortaskScript
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		var aiComponent : AIHumanComponent;
		aiComponent = GetAIComponent( context );
		if( aiComponent )
		{
			aiComponent.ReleaseReservedSeat();
		}
	}

}

class SetAnimsetOverrideForPassengerNPC extends AIbehaviortaskScript
{
	editable inlined var IsNPCMounted : AIArgumentMapping;

	protected override function Activate( context : ScriptExecutionContext )
	{
		var IsMounted : Bool;
		var vehicleID : EntityID;
		var vehicleSlotID : MountingSlotId;
		var vehicle : weak< GameObject >;
		IsMounted = ( ( Bool )( ScriptExecutionContext.GetMappingValue( context, IsNPCMounted ) ) );
		if( !( GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) ) )
		{
			return;
		}
		if( !( GetAIComponent( context ).GetAssignedVehicleData( vehicleID, vehicleSlotID ) ) )
		{
			return;
		}
		VehicleComponent.SetAnimsetOverrideForPassenger( ScriptExecutionContext.GetOwner( context ), vehicleID, vehicleSlotID.id, ( ( IsMounted ) ? ( 1.0 ) : ( 0.0 ) ) );
	}

}

class CanNPCMountVehicle extends PreventionConditionAbstract
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		SetUpdateInterval( context, 1.0 );
	}

	private function CheckForPolice( context : ScriptExecutionContext ) : Bool
	{
		var canPoliceMount : Bool;
		var vehicleID : EntityID;
		var vehicleSlotID : MountingSlotId;
		var vehicle : weak< GameObject >;
		var vehicleObject : VehicleObject;
		var combatSquadInterface : CombatSquadScriptInterface;
		var registry : PoliceAgentRegistry;
		registry = PreventionSystem.GetAgentRegistry( ScriptExecutionContext.GetOwner( context ).GetGame() );
		canPoliceMount = true;
		if( !( GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) ) )
		{
			canPoliceMount = false;
		}
		if( !( GetAIComponent( context ).GetAssignedVehicleData( vehicleID, vehicleSlotID ) ) )
		{
			canPoliceMount = false;
		}
		if( VehicleComponent.IsDestroyed( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleID ) )
		{
			canPoliceMount = false;
		}
		if( VehicleComponent.IsSlotOccupied( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleID, vehicleSlotID ) )
		{
			canPoliceMount = false;
		}
		vehicleObject = ( ( VehicleObject )( vehicle ) );
		if( !( vehicleObject ) || vehicleObject.IsVehicleInsideInnerAreaOfAreaSpeedLimiter() )
		{
			canPoliceMount = false;
		}
		if( VehicleComponent.GetDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicleObject, vehicleID ).IsPlayer() )
		{
			canPoliceMount = false;
		}
		if( ScriptExecutionContext.GetOwner( context ).GetPreventionSystem().IsChasingPlayer() )
		{
			if( AISquadHelper.GetCombatSquadInterface( ScriptExecutionContext.GetOwner( context ), combatSquadInterface ) )
			{
				if( GetPuppet( context ).GetHighLevelStateFromBlackboard() != gamedataNPCHighLevelState.Combat && ( ( combatSquadInterface.GetEnemiesCount() > 0 ) || registry.IsPoliceInCombatWithPalyer() ) )
				{
					canPoliceMount = false;
				}
			}
		}
		if( !( canPoliceMount ) )
		{
			VehicleComponent.SetAnimsetOverrideForPassenger( ScriptExecutionContext.GetOwner( context ), vehicleID, vehicleSlotID.id, 0.0 );
		}
		return canPoliceMount;
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var pss : PreventionSpawnSystem;
		var instantUnmount : AIEvent;
		pss = GameInstance.GetPreventionSpawnSystem( ScriptExecutionContext.GetOwner( context ).GetGame() );
		if( pss.IsEntityRegistered( ScriptExecutionContext.GetOwner( context ).GetEntityID() ) )
		{
			if( !( CheckForPolice( context ) ) )
			{
				ScriptExecutionContext.SetArgumentScriptable( context, 'MountRequest', NULL );
				instantUnmount = new AIEvent;
				instantUnmount.name = 'InstantUnmount';
				ScriptExecutionContext.GetOwner( context ).QueueEvent( instantUnmount );
				return false;
			}
		}
		return true;
	}

}

class HasNPCReactiveSignal extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var signalId : Uint32;
		var signal : AIGateSignal;
		var pss : PreventionSpawnSystem;
		var vehicleID : EntityID;
		var vehicleSlotID : MountingSlotId;
		var vehicle : weak< GameObject >;
		var instantUnmount : AIEvent;
		pss = GameInstance.GetPreventionSpawnSystem( ScriptExecutionContext.GetOwner( context ).GetGame() );
		if( pss.IsEntityRegistered( ScriptExecutionContext.GetOwner( context ).GetEntityID() ) )
		{
			if( GetPuppet( context ).GetSignalHandlerComponent().GetHighestPrioritySignal( signal, signalId ) )
			{
				if( AIGateSignal.HasTag( signal, 'reactive' ) )
				{
					if( GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) )
					{
						if( GetAIComponent( context ).GetAssignedVehicleData( vehicleID, vehicleSlotID ) )
						{
							VehicleComponent.SetAnimsetOverrideForPassenger( ScriptExecutionContext.GetOwner( context ), vehicleID, vehicleSlotID.id, 0.0 );
						}
					}
					ScriptExecutionContext.SetArgumentScriptable( context, 'MountRequest', NULL );
					instantUnmount = new AIEvent;
					instantUnmount.name = 'InstantUnmount';
					ScriptExecutionContext.GetOwner( context ).QueueEvent( instantUnmount );
					return true;
				}
			}
		}
		return false;
	}

}

class CanVehicleBeDriven extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var vehicle : weak< GameObject >;
		var vehicleID : EntityID;
		var vehicleSlotID : MountingSlotId;
		if( GetAIComponent( context ).GetAssignedVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), vehicle ) )
		{
			if( GetAIComponent( context ).GetAssignedVehicleData( vehicleID, vehicleSlotID ) )
			{
				if( !( VehicleComponent.IsDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ).GetEntityID() ) ) )
				{
					if( !( VehicleComponent.GetDriver( ScriptExecutionContext.GetOwner( context ).GetGame(), ( ( VehicleObject )( vehicle ) ), vehicleID ) ) || !( ( ( VehicleObject )( vehicle ) ).GetAIComponent().IsSeatReserved( VehicleComponent.GetDriverSlotName() ) ) )
					{
						return false;
					}
				}
			}
		}
		return true;
	}

}

class JoinTrafficInPoliceVehicle extends AIVehicleTaskAbstract
{
	var m_vehicle : weak< VehicleObject >;
	var m_panicDrivingCmd : AIVehiclePanicCommand;

	protected override function Activate( context : ScriptExecutionContext )
	{
		var owner : gamePuppet;
		var gameInstance : GameInstance;
		owner = ScriptExecutionContext.GetOwner( context );
		gameInstance = owner.GetGame();
		SetUpdateInterval( context, RandomizeOffsetForUpdateInterval( 0.2 ) );
		if( VehicleComponent.IsDriver( gameInstance, owner ) )
		{
			InterruptMountedVehicleDriveToPointCommand( context );
			InterruptMountedVehicleDriveChaseTargetCommand( context );
		}
	}

	private function SendPanicDriveCommand( context : ScriptExecutionContext )
	{
		if( !( m_vehicle ) )
		{
			return;
		}
		m_panicDrivingCmd = new AIVehiclePanicCommand;
		m_panicDrivingCmd.allowSimplifiedMovement = true;
		m_panicDrivingCmd.ignoreTickets = true;
		m_panicDrivingCmd.useSpeedBasedLookupRange = true;
		SendAICommandToMountedVehicle( context, m_panicDrivingCmd );
	}

	protected override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		var owner : gamePuppet;
		var gameInstance : GameInstance;
		owner = ScriptExecutionContext.GetOwner( context );
		gameInstance = owner.GetGame();
		if( m_vehicle || VehicleComponent.GetVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ), m_vehicle ) )
		{
			if( m_vehicle.HasTrafficSlot() )
			{
				return AIbehaviorUpdateOutcome.IN_PROGRESS;
			}
			if( VehicleComponent.IsDriver( gameInstance, owner ) )
			{
				if( VehicleComponent.CanBeDriven( gameInstance, owner.GetEntityID() ) )
				{
					SendPanicDriveCommand( context );
					GameInstance.GetPreventionSpawnSystem( ScriptExecutionContext.GetOwner( context ).GetGame() ).RequestDespawnVehicleAndPassengers( m_vehicle );
					return AIbehaviorUpdateOutcome.IN_PROGRESS;
				}
			}
			else
			{
				if( !( VehicleComponent.HasActiveDriverMounted( ScriptExecutionContext.GetOwner( context ).GetGame(), m_vehicle.GetEntityID() ) ) && !( m_vehicle.GetAIComponent().IsSeatReserved( VehicleComponent.GetDriverSlotName() ) ) )
				{
					return AIbehaviorUpdateOutcome.FAILURE;
				}
			}
			return AIbehaviorUpdateOutcome.IN_PROGRESS;
		}
		return AIbehaviorUpdateOutcome.FAILURE;
	}

	protected override function Deactivate( context : ScriptExecutionContext )
	{
		if( m_panicDrivingCmd )
		{
			InterruptMountedVehicleCommand( context, m_panicDrivingCmd );
		}
	}

}

class JoinTrafficOnFoot extends AIVehicleTaskAbstract
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		SetUpdateInterval( context, RandomizeOffsetForUpdateInterval( 0.2 ) );
	}

	protected override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		var owner : gamePuppet;
		var gameInstance : GameInstance;
		var reactionSystem : ReactionSystem;
		var aiComp : AIHumanComponent;
		owner = ScriptExecutionContext.GetOwner( context );
		gameInstance = owner.GetGame();
		reactionSystem = GameInstance.GetReactionSystem( gameInstance );
		aiComp = AIBehaviorScriptBase.GetAIComponent( context );
		if( aiComp )
		{
			aiComp.ReleaseReservedSeat();
		}
		if( reactionSystem )
		{
			if( reactionSystem.TryAndJoinTraffic( owner, ( ( Vector3 )( GetPlayer( gameInstance ).GetWorldPosition() ) ), false ) )
			{
				return AIbehaviorUpdateOutcome.SUCCESS;
			}
		}
		return AIbehaviorUpdateOutcome.FAILURE;
	}

}

class CheckSpawningStrategy extends PreventionConditionAbstract
{
	editable inlined var spawningStrategyToCompare : AIArgumentMapping;
	var spawningStrategyToCompareAsInt : Int32;
	var system : PreventionSystem;
	var vehicle : weak< VehicleObject >;

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var owner : gamePuppet;
		var gameInstance : GameInstance;
		owner = ScriptExecutionContext.GetOwner( context );
		gameInstance = owner.GetGame();
		system = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( gameInstance ).Get( 'PreventionSystem' ) ) );
		spawningStrategyToCompareAsInt = ( ( Int32 )( ScriptExecutionContext.GetMappingValue( context, spawningStrategyToCompare ) ) );
		if( VehicleComponent.GetVehicle( owner.GetGame(), owner, vehicle ) )
		{
			if( spawningStrategyToCompareAsInt == ( ( Int32 )( vehicle.GetPoliceStrategy() ) ) )
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}

}

class GetPoliceStrategyDestinationTask extends AIbehaviortaskScript
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		var owner : gamePuppet;
		var gameInstance : GameInstance;
		var vehicleObject : weak< VehicleObject >;
		var vehicle : weak< WheeledObject >;
		var destination : Vector4;
		owner = ScriptExecutionContext.GetOwner( context );
		gameInstance = owner.GetGame();
		if( !( VehicleComponent.GetVehicle( gameInstance, owner, vehicleObject ) ) )
		{
			return;
		}
		vehicle = ( ( weak< weak< WheeledObject > > )( vehicleObject ) );
		destination = Vector4.Vector3To4( vehicle.GetPoliceStrategyDestination() );
		if( Vector4.IsXYZZero( destination ) )
		{
			return;
		}
		ScriptExecutionContext.SetArgumentVector( context, 'In_StrategyDestinationPosition', destination );
	}

}

class CheckHeatStage extends PreventionConditionAbstract
{
	editable inlined var heatStageToCompare : AIArgumentMapping;
	var heatStageToCompareAsInteger : Int32;
	var currentHeatStageAsInteger : Int32;
	var system : PreventionSystem;

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		system = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'PreventionSystem' ) ) );
		heatStageToCompareAsInteger = ( ( Int32 )( ScriptExecutionContext.GetMappingValue( context, heatStageToCompare ) ) );
		currentHeatStageAsInteger = ( ( Int32 )( system.GetHeatStage() ) );
		if( currentHeatStageAsInteger == heatStageToCompareAsInteger )
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

class SetNPCSensesMainPresetPrevention extends SetNPCSensesMainPreset
{

	protected override function Activate( context : ScriptExecutionContext )
	{
		var vehicleID : EntityID;
		if( NPCManager.HasTag( ScriptExecutionContext.GetOwner( context ).GetRecordID(), 'Scripted_Patrol_inVehicle' ) && VehicleComponent.GetVehicleID( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ), vehicleID ) )
		{
			SenseComponent.RequestMainPresetChange( ScriptExecutionContext.GetOwner( context ), "Scripted_Prevention_Patrol_InVehicle" );
		}
		else
		{
			SenseComponent.RequestMainPresetChange( ScriptExecutionContext.GetOwner( context ), newSensesPresetName );
		}
	}

}

class ShouldNPCRetreatFromMaxTacEncounter extends PreventionConditionAbstract
{
	var agentRegistry : PoliceAgentRegistry;
	var threatLocation : TrackedLocation;

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var puppet : ScriptedPuppet;
		var prevSys : PreventionSystem;
		agentRegistry = PreventionSystem.GetAgentRegistry( ScriptExecutionContext.GetOwner( context ).GetGame() );
		prevSys = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'PreventionSystem' ) ) );
		puppet = GetPuppet( context );
		if( prevSys.ShouldPreventionUnitsRetreat() )
		{
			if( !( puppet.IsPrevention() ) )
			{
				return false;
			}
			if( !( agentRegistry.IsPoliceInCombatWithPalyer() ) )
			{
				return false;
			}
			if( NPCManager.HasTag( puppet.GetRecordID(), 'MaxTac_Prevention' ) || NPCManager.HasTag( puppet.GetRecordID(), 'MaxTac_NotPrevention' ) )
			{
				return false;
			}
			if( !( AISquadHelper.GetThreatLocationFromSquad( ( ( weak< weak< ScriptedPuppet > > )( puppet ) ), GetPlayer( puppet.GetGame() ), threatLocation ) ) )
			{
				return false;
			}
			if( Vector4.Distance( puppet.GetWorldPosition(), threatLocation.lastKnown.position ) > 70.0 )
			{
				return false;
			}
			if( agentRegistry.DistanceSquaredToTClosestMaxTacAgent( prevSys.GetPlayer().GetWorldPosition() ) > ( 50.0 * 50.0 ) )
			{
				return false;
			}
			return true;
		}
		else
		{
			return false;
		}
	}

}

class IsAVSpawned extends PreventionConditionAbstract
{
	var agentRegistry : PoliceAgentRegistry;
	var prevSys : PreventionSystem;

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		prevSys = ( ( PreventionSystem )( GameInstance.GetScriptableSystemsContainer( ScriptExecutionContext.GetOwner( context ).GetGame() ).Get( 'PreventionSystem' ) ) );
		return prevSys.ShouldPreventionUnitsRetreat();
	}

}

class ShouldRetreatBehaviorStop extends PreventionConditionAbstract
{
	var agentRegistry : PoliceAgentRegistry;

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		agentRegistry = PreventionSystem.GetAgentRegistry( ScriptExecutionContext.GetOwner( context ).GetGame() );
		return ( ( agentRegistry.GetMaxTacNPCCount() < 1 ) || !( agentRegistry.IsPoliceInCombatWithPalyer() ) ) || ( agentRegistry.DistanceSquaredToTClosestMaxTacAgent( GetPlayer( ScriptExecutionContext.GetOwner( context ).GetGame() ).GetWorldPosition() ) > ( 50.0 * 50.0 ) );
	}

}

class HasVehicleAnyCommand extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var owner : gamePuppet;
		var gameInstance : GameInstance;
		var vehicleObject : weak< VehicleObject >;
		owner = ScriptExecutionContext.GetOwner( context );
		gameInstance = owner.GetGame();
		if( VehicleComponent.GetVehicle( gameInstance, owner, vehicleObject ) )
		{
			if( VehicleComponent.IsExecutingAnyCommand( gameInstance, vehicleObject ) )
			{
				return true;
			}
		}
		return false;
	}

}

class IntervalCaller extends DelayCallback
{
	var m_preventionSystem : weak< PreventionSystem >;
	var m_request : ScriptableSystemRequest;
	private var m_intervalSeconds : Float;
	private var m_selfDelayID : DelayID;

	public static function Create( preventionSystem : weak< PreventionSystem > ) : IntervalCaller
	{
		var created : IntervalCaller;
		created = new IntervalCaller;
		created.m_preventionSystem = preventionSystem;
		created.m_selfDelayID = PreventionSystem.GetInvalidDelayID();
		return created;
	}

	public function IsRunning() : Bool
	{
		return m_selfDelayID != PreventionSystem.GetInvalidDelayID();
	}

	public function Start( intervalSeconds : Float, request : ScriptableSystemRequest )
	{
		m_intervalSeconds = intervalSeconds;
		m_request = request;
		Cancel();
		StartInternal();
	}

	private function StartInternal()
	{
		m_selfDelayID = GameInstance.GetDelaySystem( m_preventionSystem.GetGame() ).DelayCallback( this, m_intervalSeconds );
	}

	public function Cancel()
	{
		if( !( IsRunning() ) )
		{
			return;
		}
		GameInstance.GetDelaySystem( m_preventionSystem.GetGame() ).CancelCallback( m_selfDelayID );
		m_selfDelayID = PreventionSystem.GetInvalidDelayID();
	}

	protected override function Call()
	{
		m_preventionSystem.QueueRequest( m_request );
		StartInternal();
	}

}

class IsAssignedVehicleAV extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var puppet : ScriptedPuppet;
		var gameInstance : GameInstance;
		var vehicleObject : weak< VehicleObject >;
		var assignedVehicleID : EntityID;
		puppet = GetPuppet( context );
		gameInstance = puppet.GetGame();
		if( puppet )
		{
			assignedVehicleID = puppet.GetAIControllerComponent().GetAssignedVehicleId();
			vehicleObject = ( ( VehicleObject )( GameInstance.FindEntityByID( gameInstance, assignedVehicleID ) ) );
			if( vehicleObject && ( vehicleObject == ( ( AVObject )( vehicleObject ) ) ) )
			{
				return true;
			}
		}
		return false;
	}

}

class CanShootToTargretFromMountedGuns extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var vehicleObject : weak< VehicleObject >;
		var target : weak< GameObject >;
		var targetPosition : Vector4;
		var vehiclePosition : Vector4;
		var toTargetVector : Vector4;
		target = ScriptExecutionContext.GetArgumentObject( context, 'CombatTarget' );
		if( VehicleComponent.GetVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ), vehicleObject ) )
		{
			targetPosition = target.GetWorldPosition();
			vehiclePosition = vehicleObject.GetWorldPosition();
			toTargetVector = targetPosition - vehiclePosition;
			if( Vector4.GetAngleBetween( vehicleObject.GetWorldForward(), toTargetVector ) < 30.0 )
			{
				return true;
			}
		}
		return false;
	}

}

class VehicleHasWindowsRollDown extends PreventionConditionAbstract
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var vehicleObject : weak< VehicleObject >;
		var vehDataPackage : weak< VehicleDataPackage_Record >;
		if( VehicleComponent.GetVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ), vehicleObject ) )
		{
			VehicleComponent.GetVehicleDataPackage( vehicleObject.GetGame(), vehicleObject, vehDataPackage );
			return vehDataPackage.WindowsRollDown();
		}
		return false;
	}

}

