class AdamSmasherHealthChangeListener extends CustomValueStatPoolsListener
{
	var m_owner : weak< NPCPuppet >;
	var m_player : weak< PlayerPuppet >;
	private var m_adamSmasherComponent : AdamSmasherComponent;
	private var m_statPoolType : gamedataStatPoolType;
	private var m_statPoolSystem : StatPoolsSystem;

	public override function OnStatPoolValueChanged( oldValue : Float, newValue : Float, percToPoints : Float )
	{
		CheckPhase( oldValue, newValue, percToPoints );
	}

	public function CheckPhase( oldValue : Float, newValue : Float, percToPoints : Float )
	{
		if( ( ( ( oldValue > AdamSmasherComponent.GetRemovePlateHealthValue() ) && ( newValue <= AdamSmasherComponent.GetRemovePlateHealthValue() ) ) && StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase1" ) ) && !( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.DestroyedPlate" ) ) )
		{
			if( !( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Destroyed_Plate" ) ) )
			{
				ApplySmashed();
			}
			DisableFrontPlate();
			EnableTorsoWeakspot();
			DisableAllSandyEdgerunnerFxs();
		}
		if( ( ( oldValue > AdamSmasherComponent.GetPhase2HealthValue() ) && ( newValue <= AdamSmasherComponent.GetPhase2HealthValue() ) ) && StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase1" ) )
		{
			ApplyPhase2();
			DisableTorsoWeakspot();
			DisableRightArm();
			EnableLauncherWeakspot();
			DisableAllSandyEdgerunnerFxs();
		}
		if( ( ( oldValue > AdamSmasherComponent.GetEmergencyPhaseHealthValue() ) && ( newValue <= AdamSmasherComponent.GetEmergencyPhaseHealthValue() ) ) && !( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Invulnerable" ) ) )
		{
			ApplyEmergency();
			DisableAllSandyEdgerunnerFxs();
		}
		if( ( oldValue > AdamSmasherComponent.GetPhase3HealthValue() ) && ( newValue <= AdamSmasherComponent.GetPhase3HealthValue() ) )
		{
			ApplyPhase3();
			DisableLauncherWeakspot();
			EnableHeadWeakspot();
			DisableAllSandyEdgerunnerFxs();
		}
	}

	public function ApplySmashed()
	{
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Smashed", m_owner.GetEntityID() );
	}

	private function DisableAllSandyEdgerunnerFxs()
	{
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_00' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_01' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_02' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_03' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_00' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_01' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_02' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_03' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_00' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_01' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_02' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_03' );
	}

	public function ApplyPhase2()
	{
		DestroyWeakspotGenerator();
		StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.Phase1" );
		StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.Destroyed_Plate" );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Phase2", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Destroyed_Stage1", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Smashed", m_owner.GetEntityID() );
		GameObject.StartReplicatedEffectEvent( m_owner, 'arm_destroyed' );
		DismembermentComponent.RequestDismemberment( m_owner, gameDismBodyPart.RIGHT_ARM, gameDismWoundType.COARSE, Vector4.EmptyVector() );
	}

	public function ApplyPhase3()
	{
		StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.Phase2" );
		StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.Destroyed_Stage1" );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Phase3", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Wounded", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Destroyed_Stage2", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.AdamSmasherStealthDot", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"BaseStatusEffect.BossNoTakeDown", m_owner.GetEntityID() );
		RemoveEmergency();
	}

	public function ApplyEmergency()
	{
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Invulnerable", m_owner.GetEntityID() );
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Emergency", m_owner.GetEntityID() );
	}

	public function RemoveEmergency()
	{
		StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.Invulnerable" );
		StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.Emergency" );
	}

	private function EnableTorsoWeakspot()
	{
		if( !( m_owner ) )
		{
			return;
		}
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightShoulder', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'TorsoWeakspot', false );
	}

	private function DisableTorsoWeakspot()
	{
		if( !( m_owner ) )
		{
			return;
		}
		HitShapeUserDataBase.EnableHitShape( m_owner, 'RightShoulder', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'TorsoWeakspot', false );
	}

	private function EnableHeadWeakspot()
	{
		if( !( m_owner ) )
		{
			return;
		}
		HitShapeUserDataBase.DisableHitShape( m_owner, 'HeadReinforced', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'Head', false );
	}

	private function DisableRightArm()
	{
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightArm', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightForeArm', false );
		if( !( m_owner ) )
		{
			return;
		}
	}

	private function DisableFrontPlate()
	{
		HitShapeUserDataBase.DisableHitShape( m_owner, 'FrontPlate', false );
		if( !( m_owner ) )
		{
			return;
		}
	}

	private function EnableLauncherWeakspot()
	{
		if( !( m_owner ) )
		{
			return;
		}
	}

	private function DisableLauncherWeakspot()
	{
		if( !( m_owner ) )
		{
			return;
		}
	}

	private function DestroyWeakspotGenerator()
	{
		var weakspots : array< weak< WeakspotObject > >;
		var scriptWeakspot : ScriptedWeakspotObject;
		var i : Int32;
		m_owner.GetWeakspotComponent().GetWeakspots( weakspots );
		if( weakspots.Size() > 0 )
		{
			for( i = 0; i < weakspots.Size(); i += 1 )
			{
				scriptWeakspot = ( ( ScriptedWeakspotObject )( weakspots[ i ] ) );
				scriptWeakspot.DestroyWeakspot( m_owner );
				ScriptedWeakspotObject.Kill( weakspots[ i ] );
			}
		}
	}

}

class AdamSmasherComponent extends ScriptableComponent
{
	private var m_owner : weak< NPCPuppet >;
	private var m_owner_id : EntityID;
	private var m_statusEffect_armor1_id : TweakDBID;
	private var m_statusEffect_armor2_id : TweakDBID;
	private var m_statusEffect_armor3_id : TweakDBID;
	private var m_statusEffect_smashed_id : TweakDBID;
	private var m_statPoolSystem : StatPoolsSystem;
	private var m_statPoolType : gamedataStatPoolType;
	private var m_healthListener : AdamSmasherHealthChangeListener;
	private var m_phase2Threshold : Float;
	private var m_phase3Threshold : Float;
	private var m_npcCollisionComponent : SimpleColliderComponent;
	private var m_targetTrackerComponent : TargetTrackerComponent;
	private var m_weakspotDestroyed : Bool;

	public function OnGameAttach()
	{
		var evt2 : DisableWeakspotDelayedEvent;
		var evt : gameDeathParamsEvent;
		var selfGameObject : GameObject;
		evt2 = new DisableWeakspotDelayedEvent;
		evt = new gameDeathParamsEvent;
		selfGameObject = ( ( GameObject )( m_owner ) );
		selfGameObject.QueueEvent( evt );
		m_owner = ( ( NPCPuppet )( GetOwner() ) );
		m_owner_id = m_owner.GetEntityID();
		m_owner.SetDisableRagdoll( true );
		m_statPoolSystem = GameInstance.GetStatPoolsSystem( m_owner.GetGame() );
		m_healthListener = new AdamSmasherHealthChangeListener;
		m_healthListener.SetValue( 80.0 );
		m_healthListener.m_owner = m_owner;
		m_healthListener.m_player = ( ( PlayerPuppet )( GetPlayerSystem().GetLocalPlayerControlledGameObject() ) );
		m_statusEffect_armor1_id = T"AdamSmasher.Phase1";
		m_statusEffect_armor2_id = T"AdamSmasher.Phase2";
		m_statusEffect_armor3_id = T"AdamSmasher.Phase3";
		m_statusEffect_smashed_id = T"AdamSmasher.Smashed";
		StatusEffectHelper.ApplyStatusEffect( m_owner, m_statusEffect_armor1_id, m_owner_id );
		m_statPoolSystem.RequestRegisteringListener( m_owner_id, gamedataStatPoolType.Health, m_healthListener );
		EnableRipInteractionLayer();
		GameInstance.GetDelaySystem( m_owner.GetGame() ).DelayEvent( m_owner, evt2, 0.1 );
		m_targetTrackerComponent = m_owner.GetTargetTrackerComponent();
		DisableAllSandyEdgerunnerFxs();
		m_weakspotDestroyed = false;
	}

	public function OnGameDetach()
	{
		m_statPoolSystem.RequestUnregisteringListener( m_owner_id, gamedataStatPoolType.Health, m_healthListener );
		m_healthListener = NULL;
	}

	protected event OnEnableColliderDelayEvent( enableColliderEvent : EnableColliderDelayEvent )
	{
		m_npcCollisionComponent.Toggle( true );
	}

	protected event OnDeathAfterDefeatedSmasher( evt : gameDeathEvent )
	{
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'broken' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'exp_launcher' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'arm_destroyed' );
		if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.SmasherAnimationActivator" ) )
		{
			GameObject.ToggleForcedVisibilityInAnimSystemEvent( GetOwner(), 'SmasherCustomDisabler', false );
			StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.SmasherAnimationActivator" );
		}
		m_npcCollisionComponent.Toggle( false );
	}

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		EntityRequestComponentsInterface.RequestComponent( ri, 'npcCollision', 'SimpleColliderComponent', true );
	}

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_npcCollisionComponent = ( ( SimpleColliderComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'npcCollision' ) ) );
	}

	public function ApplySmashed()
	{
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.Smashed", m_owner.GetEntityID() );
	}

	private function DisableFrontPlate()
	{
		HitShapeUserDataBase.DisableHitShape( m_owner, 'FrontPlate', false );
		if( !( m_owner ) )
		{
			return;
		}
	}

	private function EnableTorsoWeakspot()
	{
		if( !( m_owner ) )
		{
			return;
		}
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightShoulder', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'TorsoWeakspot', false );
	}

	public constexpr static function GetRemovePlateHealthValue() : Float
	{
		return 80.0;
	}

	public constexpr static function GetPhase2HealthValue() : Float
	{
		return 50.0;
	}

	public constexpr static function GetEmergencyPhaseHealthValue() : Float
	{
		return 30.0;
	}

	public constexpr static function GetPhase3HealthValue() : Float
	{
		return 5.0;
	}

	public constexpr static function GetDefeatedHealthValue() : Float
	{
		return 0.0;
	}

	public function SetPercentLifeForPhase( value : Float )
	{
		m_statPoolSystem = GameInstance.GetStatPoolsSystem( m_owner.GetGame() );
		m_statPoolSystem.RequestChangingStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, 100.0, m_owner, true );
		value = 100.0 - value;
		m_statPoolSystem.RequestChangingStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, -( value ), m_owner, true );
	}

	private function EnableRipInteractionLayer()
	{
		var puppet : weak< ScriptedPuppet >;
		puppet = ( ( ScriptedPuppet )( m_owner ) );
		puppet.EnableInteraction( 'AdamSmasherRipInteraction', true );
	}

	private function DisableAllSandyEdgerunnerFxs()
	{
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_00' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_01' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_02' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_high_03' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_00' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_01' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_02' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_low_03' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_00' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_01' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_02' );
		GameObject.BreakReplicatedEffectLoopEvent( ( ( GameObject )( m_owner ) ), 'sandevistan_medium_03' );
	}

	private function DisableRipInteractionLayer()
	{
		var puppet : weak< ScriptedPuppet >;
		puppet = ( ( ScriptedPuppet )( m_owner ) );
		puppet.EnableInteraction( 'AdamSmasherRipInteraction', false );
	}

	private function DisableWeakspots()
	{
		if( !( m_owner ) )
		{
			return;
		}
		HitShapeUserDataBase.DisableHitShape( m_owner, 'Head', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'TorsoWeakspot', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'HeadReinforced', false );
	}

	protected function DisableAllHitShapes()
	{
		HitShapeUserDataBase.DisableHitShape( m_owner, 'Head', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'Belly', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftTorso', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftArm', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftForeArm', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightShoulder', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightArm', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightForeArm', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftLeg', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftUpLeg', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftFoot', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightLeg', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightUpLeg', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightFoot', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'HeadReinforced', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'TorsoWeakspot', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'Launcher', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'Chest', false );
	}

	protected function DisableAllDefeatedHitShapes()
	{
		HitShapeUserDataBase.DisableHitShape( m_owner, 'HeadDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'BellyDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftTorsoDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftArmDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftForeArmDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightShoulderDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightArmDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightForeArmDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftLegDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftUpLegDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'LeftFootDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightLegDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightUpLegDefeated', false );
		HitShapeUserDataBase.DisableHitShape( m_owner, 'RightFootDefeated', false );
	}

	protected function EnableDefeatedHitShapes()
	{
		HitShapeUserDataBase.EnableHitShape( m_owner, 'Head', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'HeadDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'BellyDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'LeftTorsoDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'LeftArmDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'LeftForeArmDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'RightShoulderDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'RightArmDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'LeftLegDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'LeftUpLegDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'LeftFootDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'RightLegDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'RightUpLegDefeated', false );
		HitShapeUserDataBase.EnableHitShape( m_owner, 'RightFootDefeated', false );
	}

	protected function OnDeactivate()
	{
		DisableRipInteractionLayer();
	}

	protected event OnDisableWeakspotDelayedEvent( evt : DisableWeakspotDelayedEvent )
	{
		DisableAllDefeatedHitShapes();
		DisableWeakspots();
	}

	protected event OnDefeated( evt : DefeatedEvent )
	{
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.InvulnerableDefeated", m_owner_id );
		GameObject.StartReplicatedEffectEvent( m_owner, 'grenade_explode_takedown' );
	}

	protected event OnStatusEffectApplied( evt : ApplyStatusEffectEvent )
	{
		var tags : array< CName >;
		var enableColliderEvent : EnableColliderDelayEvent;
		var statusEffects : array< StatusEffect >;
		enableColliderEvent = new EnableColliderDelayEvent;
		tags = evt.staticData.GameplayTags();
		if( tags.Contains( 'SmasherAnimationActivator' ) )
		{
			GameObject.ToggleForcedVisibilityInAnimSystemEvent( GetOwner(), 'SmasherCustomDisabler', true );
		}
		if( tags.Contains( 'Overload' ) )
		{
			if( ( ( m_weakspotDestroyed == false && StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase1" ) ) && StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Destroyed_Plate" ) ) && StatusEffectSystem.ObjectHasStatusEffectOfType( m_owner, gamedataStatusEffectType.QuickHackStaggerCyberware ) )
			{
				StatusEffectHelper.GetAppliedEffectsWithTag( m_owner, 'CyberwareMalfunction', statusEffects );
				if( ( statusEffects.Size() > 0 ) && ( statusEffects[ 0 ].GetStackCount() >= 4 ) )
				{
					m_weakspotDestroyed = true;
					StatusEffectHelper.RemoveAllStatusEffectsByType( m_owner.GetGame(), m_owner_id, gamedataStatusEffectType.QuickHackStaggerCyberware );
					ApplyNoInterrupt();
					SetPercentLifeForPhase( GetPhase2HealthValue() );
					StatusEffectHelper.ApplyStatusEffect( m_owner, T"AdamSmasher.InvulnerableDefeated", m_owner_id );
				}
			}
		}
		if( tags.Contains( 'ChimeraSuicide' ) || tags.Contains( 'ChimeraBlackWall' ) )
		{
			if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase1" ) )
			{
				ApplyNoInterrupt();
				SetPercentLifeForPhase( GetPhase2HealthValue() );
			}
			else if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase2" ) )
			{
				if( m_statPoolSystem.GetStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, true ) > GetEmergencyPhaseHealthValue() )
				{
					SetPercentLifeForPhase( GetEmergencyPhaseHealthValue() );
				}
				else
				{
					SetPercentLifeForPhase( GetPhase3HealthValue() );
				}
			}
			else if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase3" ) )
			{
				SetPercentLifeForPhase( GetDefeatedHealthValue() );
			}
		}
		if( tags.Contains( 'BossGrenadeHackEffect' ) )
		{
			StatusEffectHelper.ApplyStatusEffect( m_owner, T"BaseStatusEffect.WeakspotDestructionStatusEffect", m_owner_id );
		}
		if( tags.Contains( 'SmasherCustomHackTakedown' ) )
		{
			if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase1" ) )
			{
				ApplyNoInterrupt();
				SetPercentLifeForPhase( GetPhase2HealthValue() );
			}
			else if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase2" ) )
			{
				SetPercentLifeForPhase( GetPhase3HealthValue() );
			}
		}
		else if( tags.Contains( 'SmasherCustomHack' ) )
		{
			if( m_statPoolSystem.GetStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, true ) > GetPhase2HealthValue() )
			{
				ApplyNoInterrupt();
				SetPercentLifeForPhase( GetPhase2HealthValue() );
			}
			else if( ( m_statPoolSystem.GetStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, true ) <= GetPhase2HealthValue() ) && ( m_statPoolSystem.GetStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, true ) > GetEmergencyPhaseHealthValue() ) )
			{
				SetPercentLifeForPhase( GetEmergencyPhaseHealthValue() );
			}
			else if( m_statPoolSystem.GetStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, true ) > GetPhase3HealthValue() )
			{
				SetPercentLifeForPhase( GetPhase3HealthValue() );
			}
			else if( ( m_statPoolSystem.GetStatPoolValue( m_owner.GetEntityID(), gamedataStatPoolType.Health, true ) <= GetEmergencyPhaseHealthValue() ) && !( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Invulnerable" ) ) )
			{
				GameObject.StartReplicatedEffectEvent( m_owner, 'panel_rip' );
				SetPercentLifeForPhase( 0.0 );
			}
		}
		if( tags.Contains( 'SmasherCustomStatusEffect' ) )
		{
			if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Destroyed_Plate" ) && StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"AdamSmasher.Phase1" ) )
			{
				SetHealth( m_owner, GetRemovePlateHealthValue() );
			}
		}
		if( StatusEffectSystem.ObjectHasStatusEffect( m_owner, T"BaseStatusEffect.Defeated" ) )
		{
			DisableAllHitShapes();
			EnableDefeatedHitShapes();
			StatusEffectHelper.RemoveStatusEffect( m_owner, T"AdamSmasher.AdamSmasherStealthDot" );
			if( m_npcCollisionComponent )
			{
				GameInstance.GetDelaySystem( m_owner.GetGame() ).DelayEvent( m_owner, enableColliderEvent, 0.1 );
			}
		}
	}

	public function ApplyNoInterrupt()
	{
		StatusEffectHelper.ApplyStatusEffect( m_owner, T"BaseStatusEffect.BossNoInterrupt", m_owner.GetEntityID() );
	}

	private function SetHealth( target : NPCPuppet, valueToSet : Float )
	{
		var currentHealth : Float;
		var finalValue : Float;
		if( valueToSet < 0.0 )
		{
			valueToSet = 0.0;
		}
		currentHealth = GameInstance.GetStatPoolsSystem( target.GetGame() ).GetStatPoolValue( target.GetEntityID(), gamedataStatPoolType.Health, true );
		finalValue = valueToSet - currentHealth;
		GameInstance.GetStatPoolsSystem( target.GetGame() ).RequestChangingStatPoolValue( target.GetEntityID(), gamedataStatPoolType.Health, finalValue, NULL, true );
	}

	protected event OnAudioEvent( evt : AudioEvent )
	{
		var evtFootstep : HeavyFootstepEvent;
		var player : weak< PlayerPuppet >;
		evtFootstep = new HeavyFootstepEvent;
		player = ( ( PlayerPuppet )( GetPlayerSystem().GetLocalPlayerControlledGameObject() ) );
		if( !( player ) )
		{
			return false;
		}
		if( evt.eventName == 'nme_boss_smasher_lcm_walk' || evt.eventName == 'nme_boss_smasher_lcm_sprint' )
		{
			evtFootstep.instigator = m_owner;
			evtFootstep.audioEventName = evt.eventName;
			player.QueueEvent( evtFootstep );
		}
	}

}

class DisableWeakspotDelayedEvent extends DelayEvent
{
}

