class DelayPassiveConditionEvaluationEvent extends Event
{
}

abstract class AIAutonomousConditions extends AIbehaviorconditionScript
{

	public static function HasHostileThreats( context : ScriptExecutionContext, optional onlyEntities : Bool ) : Bool
	{
		var trackerComponent : TargetTrackerComponent;
		var puppet : ScriptedPuppet;
		var reactionSystem : ReactionSystem;
		puppet = GetPuppet( context );
		trackerComponent = puppet.GetTargetTrackerComponent();
		if( trackerComponent == NULL )
		{
			return false;
		}
		reactionSystem = GameInstance.GetReactionSystem( puppet.GetGame() );
		if( puppet.IsCharacterCivilian() && !( reactionSystem.IsRegisteredAsAggressive( puppet.GetEntityID() ) ) )
		{
			return false;
		}
		return trackerComponent.HasHostileThreat( false, onlyEntities );
	}

	public static function HasCombatAICommand( context : ScriptExecutionContext ) : Bool
	{
		var commandTarget : weak< GameObject >;
		commandTarget = ScriptExecutionContext.GetArgumentObject( context, 'CommandCombatTarget' );
		if( commandTarget && ScriptedPuppet.IsActive( commandTarget ) )
		{
			return true;
		}
		if( AIActionHelper.HasCombatAICommand( GetPuppet( context ) ) )
		{
			return true;
		}
		return false;
	}

	protected constexpr function HasUnknownThreats( context : ScriptExecutionContext ) : Bool
	{
		return false;
	}

	public static function IsPlayerInCombat( context : ScriptExecutionContext ) : Bool
	{
		var player : ScriptedPuppet;
		player = ( ( ScriptedPuppet )( GameInstance.GetPlayerSystem( GetGame( context ) ).GetLocalPlayerControlledGameObject() ) );
		return ( ( gamePSMCombat )( AIActionChecks.GetPSMBlackbordInt( player, GetAllBlackboardDefs().PlayerStateMachine.Combat ) ) ) == gamePSMCombat.InCombat;
	}

	public static function WaitForAnimationToFinish( context : ScriptExecutionContext ) : Bool
	{
		var puppet : ScriptedPuppet;
		var puppetState : gamedataNPCUpperBodyState;
		puppet = GetPuppet( context );
		if( puppet.GetMovePolicesComponent().IsOnOffMeshLink() )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		if( GameInstance.GetCoverManager( puppet.GetGame() ).IsEnteringOrLeavingCover( puppet ) )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		puppetState = puppet.GetUpperBodyStateFromBlackboard();
		if( puppetState == gamedataNPCUpperBodyState.Equip )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		if( puppetState == gamedataNPCUpperBodyState.Attack )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		if( puppetState == gamedataNPCUpperBodyState.ChargedAttack )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		if( puppetState == gamedataNPCUpperBodyState.Taunt )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		if( puppet.GetPuppetStateBlackboard().GetBool( GetAllBlackboardDefs().PuppetState.WorkspotAnimationInProgress ) )
		{
			SchedulePassiveConditionEvaluation( puppet, 0.25 );
			return true;
		}
		return false;
	}

	public static function SchedulePassiveConditionEvaluation( puppet : weak< ScriptedPuppet >, delay : Float )
	{
		GameInstance.GetDelaySystem( puppet.GetGame() ).DelayEvent( puppet, new DelayPassiveConditionEvaluationEvent, delay, false );
	}

	public static function IsPlayerRecentlyDroppedThreat( owner : weak< GameObject > ) : Bool
	{
		var tte : weak< TargetTrackingExtension >;
		var threatData : DroppedThreatData;
		var threatObject : weak< GameObject >;
		if( !( TargetTrackingExtension.Get( ( ( ScriptedPuppet )( owner ) ), tte ) ) )
		{
			return false;
		}
		threatData = tte.GetRecentlyDroppedThreat();
		if( !( threatData.threat ) )
		{
			return false;
		}
		threatObject = ( ( GameObject )( threatData.threat ) );
		return threatObject && threatObject.IsPlayer();
	}

	public static function AlertedCondition( context : ScriptExecutionContext ) : Bool
	{
		var puppet : ScriptedPuppet;
		var highLevelState : gamedataNPCHighLevelState;
		var inVehicle : Bool;
		puppet = GetPuppet( context );
		if( WaitForAnimationToFinish( context ) )
		{
			if( NPCPuppet.IsInAlerted( puppet ) )
			{
				return true;
			}
			return false;
		}
		if( ScriptedPuppet.IsPlayerCompanion( puppet ) )
		{
			return false;
		}
		if( puppet.IsCrowd() && !( puppet.IsPrevention() ) )
		{
			return false;
		}
		if( !( puppet.IsAggressive() ) )
		{
			return false;
		}
		if( puppet.IsPrevention() && puppet.GetPreventionSystem().IsChasingPlayer() )
		{
			if( NPCManager.HasTag( GetPuppet( context ).GetRecordID(), 'InActivePoliceChase' ) || puppet.GetPreventionSystem().ShouldWorkSpotPoliceJoinChase( puppet ) )
			{
				if( !( NPCManager.HasTag( puppet.GetRecordID(), 'Scripted_Patrol' ) ) )
				{
					return true;
				}
			}
		}
		if( puppet.IsPrevention() && !( PreventionSystem.ShouldReactionBeAgressive( puppet.GetGame() ) ) )
		{
			return false;
		}
		highLevelState = puppet.GetHighLevelStateFromBlackboard();
		inVehicle = VehicleComponent.IsMountedToVehicle( ScriptExecutionContext.GetOwner( context ).GetGame(), ScriptExecutionContext.GetOwner( context ) );
		if( highLevelState == gamedataNPCHighLevelState.Alerted && ( !( puppet.IsPrevention() ) || !( inVehicle ) ) )
		{
			return true;
		}
		if( inVehicle )
		{
			return false;
		}
		if( highLevelState == gamedataNPCHighLevelState.Combat && IsPlayerRecentlyDroppedThreat( puppet ) )
		{
			return true;
		}
		return false;
	}

	public static function CombatCondition( context : ScriptExecutionContext ) : Bool
	{
		if( WaitForAnimationToFinish( context ) )
		{
			if( NPCPuppet.IsInCombat( GetPuppet( context ) ) )
			{
				return true;
			}
			return false;
		}
		if( GetPuppet( context ).IsCrowd() && !( GetPuppet( context ).IsAggressive() ) )
		{
			return false;
		}
		if( HasCombatAICommand( context ) )
		{
			return true;
		}
		if( ScriptedPuppet.IsPlayerCompanion( ScriptExecutionContext.GetOwner( context ) ) )
		{
			if( AIActionHelper.HasFollowerCombatAICommand( GetPuppet( context ) ) )
			{
				return true;
			}
			if( !( IsPlayerInCombat( context ) ) )
			{
				return false;
			}
		}
		else if( !( GetPuppet( context ).IsAggressive() ) )
		{
			return false;
		}
		if( HasHostileThreats( context, true ) )
		{
			return true;
		}
		return false;
	}

	public static function NoWeaponCombatConditions( context : ScriptExecutionContext ) : Bool
	{
		if( AIAutonomousConditions.GetPuppet( context ).GetNPCType() != gamedataNPCType.Human )
		{
			return false;
		}
		if( !( HasWeaponInInventory( context ) ) )
		{
			if( AIAutonomousConditions.WaitForAnimationToFinish( context ) )
			{
				if( NPCPuppet.IsInCombat( GetPuppet( context ) ) )
				{
					return true;
				}
				return false;
			}
			return true;
		}
		return false;
	}

	public static function CrowdCombatConditions( context : ScriptExecutionContext ) : Bool
	{
		var reactionSystem : ReactionSystem;
		var timestamp : Float;
		if( WaitForAnimationToFinish( context ) )
		{
			if( NPCPuppet.IsInCombat( GetPuppet( context ) ) )
			{
				return true;
			}
			return false;
		}
		timestamp = GetPuppet( context ).GetAIControllerComponent().GetActionBlackboard().GetFloat( GetAllBlackboardDefs().AIAction.avoidLOSTimeStamp );
		if( ( timestamp > 0.0 ) && ( ( EngineTime.ToFloat( ScriptExecutionContext.GetAITime( context ) ) - timestamp ) > 7.0 ) )
		{
			return false;
		}
		if( AIAutonomousConditions.GetPuppet( context ).GetNPCType() != gamedataNPCType.Human )
		{
			return false;
		}
		reactionSystem = GameInstance.GetReactionSystem( GetPuppet( context ).GetGame() );
		if( AIAutonomousConditions.GetPuppet( context ).IsCrowd() && reactionSystem.IsRegisteredAsAggressive( GetPuppet( context ).GetEntityID() ) )
		{
			return true;
		}
		if( AIAutonomousConditions.GetPuppet( context ).IsCrowd() && AIAutonomousConditions.GetPuppet( context ).IsPrevention() )
		{
			return true;
		}
		return false;
	}

	public static function HasWeaponInInventory( context : ScriptExecutionContext ) : Bool
	{
		var weaponCategory : weak< ItemCategory_Record >;
		var itemID : ItemID;
		weaponCategory = TweakDBInterface.GetItemCategoryRecord( T"ItemCategory.Weapon" );
		if( weaponCategory && AIActionTransactionSystem.GetFirstItemID( ScriptExecutionContext.GetOwner( context ), weaponCategory, '', itemID ) )
		{
			return true;
		}
		return false;
	}

}

class NoWeaponCombatConditions extends AIAutonomousConditions
{

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( AIAutonomousConditions.NoWeaponCombatConditions( context ) )
		{
			return true;
		}
		return false;
	}

}

class CombatConditions extends AIAutonomousConditions
{

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

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( AIAutonomousConditions.CombatCondition( context ) )
		{
			return true;
		}
		AIComponent.InvokeBehaviorCallback( GetPuppet( context ), 'OnActiveCombatConditionFailed' );
		return false;
	}

}

class AlertedConditions extends AIAutonomousConditions
{

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return AIAutonomousConditions.AlertedCondition( context );
	}

}

class CrowdCombatConditions extends AIAutonomousConditions
{

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( AIAutonomousConditions.CrowdCombatConditions( context ) )
		{
			return true;
		}
		AIComponent.InvokeBehaviorCallback( GetPuppet( context ), 'OnCrowdCombatConditionFailed' );
		return false;
	}

}

abstract class PassiveAutonomousCondition extends AIbehaviorexpressionScript
{
}

class PassiveNoWeaponCombatConditions extends PassiveAutonomousCondition
{
	protected var m_delayEvaluationCbId : Uint32;
	protected var m_onItemAddedToSlotCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_delayEvaluationCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnDelayPassiveConditionEvaluation', this );
		m_onItemAddedToSlotCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnItemAddedToSlotConditionEvaluation', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_delayEvaluationCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_onItemAddedToSlotCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		if( AIAutonomousConditions.NoWeaponCombatConditions( context ) )
		{
			return true;
		}
		return false;
	}

}

class PassiveCrowdCombatConditions extends PassiveAutonomousCondition
{
	protected var m_threatCbId : Uint32;
	protected var m_delayEvaluationCbId : Uint32;
	protected var m_onItemAddedToSlotCbId : Uint32;
	protected var m_crowdCombatConditionCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_threatCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnThreatsChanged', this );
		m_delayEvaluationCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnDelayPassiveConditionEvaluation', this );
		m_onItemAddedToSlotCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnItemAddedToSlotConditionEvaluation', this );
		m_crowdCombatConditionCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnCrowdCombatConditionFailed', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_threatCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_delayEvaluationCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_onItemAddedToSlotCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_crowdCombatConditionCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		if( AIAutonomousConditions.CrowdCombatConditions( context ) )
		{
			return true;
		}
		return false;
	}

}

class PassiveCombatConditions extends PassiveAutonomousCondition
{
	protected var m_combatCommandCbId : Uint32;
	protected var m_roleCbId : Uint32;
	protected var m_threatCbId : Uint32;
	protected var m_playerCombatCbId : Uint32;
	protected var m_activeCombatConditionCbId : Uint32;
	protected var m_delayEvaluationCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_combatCommandCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnCombatCommandChanged', this );
		m_roleCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnAIRoleChanged', this );
		m_threatCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnThreatsChanged', this );
		m_playerCombatCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnPlayerCombatChanged', this );
		m_activeCombatConditionCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnActiveCombatConditionFailed', this );
		m_delayEvaluationCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnDelayPassiveConditionEvaluation', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_combatCommandCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_roleCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_threatCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_playerCombatCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_activeCombatConditionCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_delayEvaluationCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		if( GetPuppet( context ).IsCrowd() && !( GetPuppet( context ).IsPrevention() ) )
		{
			return AIAutonomousConditions.CrowdCombatConditions( context );
		}
		else
		{
			return AIAutonomousConditions.CombatCondition( context );
		}
	}

}

class PassiveAlertedConditions extends PassiveAutonomousCondition
{
	protected var m_highLevelCbId : Uint32;
	protected var m_delayEvaluationCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_highLevelCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnHighLevelChanged', this );
		m_delayEvaluationCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnDelayPassiveConditionEvaluation', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_highLevelCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_delayEvaluationCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		ScriptExecutionContext.DebugLog( context, 'autocond', "PassiveAlertedConditions calculated." );
		return AIAutonomousConditions.AlertedCondition( context );
	}

}

class PassiveRoleCondition extends AIbehaviorexpressionScript
{
	editable var m_role : EAIRole;
	private var m_roleCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_roleCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnAIRoleChanged', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_roleCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		var role : AIRole;
		role = GetAIComponent( context ).GetAIRole();
		if( role && role.GetRoleEnum() == m_role )
		{
			return true;
		}
		return false;
	}

	public function GetEditorSubCaption() : String
	{
		return "Role " + ( ( String )( m_role ) );
	}

}

class PassiveCommandCondition extends AIbehaviorexpressionScript
{
	editable var m_commandName : CName;
	editable var m_useInheritance : Bool;
	default m_useInheritance = true;
	private var m_cmdCbId : Uint32;

	protected function Activate( context : ScriptExecutionContext )
	{
		m_cmdCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnCommandStateChanged', this );
	}

	protected function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_cmdCbId );
	}

	protected function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		var aiComp : AIHumanComponent;
		aiComp = GetAIComponent( context );
		return aiComp.IsCommandWaiting( m_commandName, m_useInheritance ) || aiComp.IsCommandExecuting( m_commandName, m_useInheritance );
	}

	public function GetEditorSubCaption() : String
	{
		return "CMD " + ( ( String )( m_commandName ) );
	}

}

class PassivePatrolConditions extends PassiveAutonomousCondition
{
	private var m_roleCbId : Uint32;
	private var m_cmdCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_roleCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnAIRoleChanged', this );
		m_cmdCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnCommandStateChanged', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_roleCbId );
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_cmdCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		var aiComp : AIHumanComponent;
		var role : AIRole;
		aiComp = GetAIComponent( context );
		if( aiComp.IsCommandExecuting( 'AIPatrolCommand', true ) || aiComp.IsCommandWaiting( 'AIPatrolCommand', true ) )
		{
			return true;
		}
		role = aiComp.GetAIRole();
		if( role && role.GetRoleEnum() == EAIRole.Patrol )
		{
			return true;
		}
		return false;
	}

}

class PassiveCoverSelectionConditions extends PassiveAutonomousCondition
{
	private var m_statsChangedCbId : Uint32;
	private var m_ability : weak< GameplayAbility_Record >;
	private var m_statListener : AIStatListener;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_ability = TweakDBInterface.GetGameplayAbilityRecord( T"Ability.CanUseCovers" );
		m_statsChangedCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnUseCoverStatChanged', this );
		m_statListener = new AIStatListener;
		m_statListener.SetInitData( GetPuppet( context ), 'OnUseCoverStatChanged' );
		m_statListener.SetStatType( gamedataStatType.CanUseCovers );
		GameInstance.GetStatsSystem( ScriptExecutionContext.GetOwner( context ).GetGame() ).RegisterListener( ScriptExecutionContext.GetOwner( context ).GetEntityID(), m_statListener );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		if( m_statListener )
		{
			GameInstance.GetStatsSystem( ScriptExecutionContext.GetOwner( context ).GetGame() ).UnregisterListener( ScriptExecutionContext.GetOwner( context ).GetEntityID(), m_statListener );
			m_statListener = NULL;
		}
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_statsChangedCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		if( !( m_ability ) )
		{
			return false;
		}
		if( !( AICondition.CheckAbility( context, m_ability ) ) )
		{
			return false;
		}
		return true;
	}

}

class AIStatListener extends ScriptStatsListener
{
	private var m_owner : weak< ScriptedPuppet >;
	private var m_behaviorCallbackName : CName;

	public function SetInitData( owner : weak< ScriptedPuppet >, behaviorCallbackName : CName )
	{
		m_owner = owner;
	}

	public override function OnStatChanged( ownerID : StatsObjectID, statType : gamedataStatType, diff : Float, total : Float )
	{
		AIComponent.InvokeBehaviorCallback( m_owner, 'OnUseCoverStatChanged' );
	}

}

class IsConnectedToSecuritySystem extends AIAutonomousConditions
{

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( GetPuppet( context ).IsConnectedToSecuritySystem() )
		{
			return true;
		}
		return false;
	}

}

class IsReprimandOngoing extends AIAutonomousConditions
{

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var puppet : ScriptedPuppet;
		var secSys : SecuritySystemControllerPS;
		puppet = GetPuppet( context );
		secSys = puppet.GetSecuritySystem();
		if( !( secSys.IsReprimandOngoing() ) )
		{
			return false;
		}
		if( puppet.GetSecuritySystem().GetReprimandPerformer() == puppet.GetDeviceLink() )
		{
			return false;
		}
		if( ( ( ScriptedPuppet )( puppet.GetSecuritySystem().GetReprimandPerformer() ) ).GetHighLevelStateFromBlackboard() != gamedataNPCHighLevelState.Relaxed )
		{
			return false;
		}
		return true;
	}

}

class IsTargetObjectPlayer extends AIbehaviorconditionScript
{
	protected editable inlined var m_targetObject : AIArgumentMapping;

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var targetObject : weak< GameObject >;
		targetObject = ( ( weak< weak< GameObject > > )( ScriptExecutionContext.GetMappingValue( context, m_targetObject ) ) );
		if( targetObject && targetObject.IsPlayer() )
		{
			return true;
		}
		return false;
	}

}

class IsBoss extends AIbehaviorconditionScript
{

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

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( GetPuppet( context ).IsBoss() )
		{
			return true;
		}
		return false;
	}

}

class IsAggressive extends AIbehaviorconditionScript
{

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

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( GetPuppet( context ).IsAggressive() )
		{
			return true;
		}
		return false;
	}

}

class PassiveCannotMoveConditions extends PassiveAutonomousCondition
{
	protected var m_statusEffectRemovedId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_statusEffectRemovedId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnStatusEffectRemoved', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_statusEffectRemovedId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		if( StatusEffectSystem.ObjectHasStatusEffectWithTag( ScriptExecutionContext.GetOwner( context ), 'LocomotionMalfunction' ) )
		{
			return true;
		}
		return false;
	}

}

