class SmartStorageEffector extends ModifyAttackEffector
{
	protected var m_baseRevengeChance : Float;
	protected var m_revengeChanceStep : Float;
	protected var m_revealDuration : Float;
	protected var m_statusEffectForTarget : TweakDBID;
	protected var m_statusEffectForSelf : TweakDBID;
	private var m_currentChance : Float;

	protected export override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		m_baseRevengeChance = TDB.GetFloat( record + T".baseChance" );
		m_revengeChanceStep = TDB.GetFloat( record + T".chanceStep" );
		m_revealDuration = TDB.GetFloat( record + T".revealDuration" );
		m_statusEffectForTarget = TDB.GetForeignKey( record + T".statusEffectForTarget" );
		m_statusEffectForSelf = TDB.GetForeignKey( record + T".statusEffectForSelf" );
		m_currentChance = m_baseRevengeChance;
	}

	protected export override function RepeatedAction( owner : GameObject )
	{
		var hitEvent : gameHitEvent;
		var attackInstigator : GameObject;
		var randomValue : Float;
		var statusEffectSystem : StatusEffectSystem;
		var outlineRequestEvt : OutlineRequestEvent;
		var outlineData : OutlineData;
		hitEvent = GetHitEvent();
		if( !( hitEvent ) )
		{
			return;
		}
		attackInstigator = hitEvent.attackData.GetInstigator();
		if( !( attackInstigator ) )
		{
			return;
		}
		if( hitEvent.attackComputed.GetTotalAttackValue( gamedataStatPoolType.Health ) <= 0.0 )
		{
			return;
		}
		randomValue = RandF();
		if( randomValue > m_currentChance )
		{
			m_currentChance += m_revengeChanceStep;
			return;
		}
		statusEffectSystem = GameInstance.GetStatusEffectSystem( owner.GetGame() );
		if( TDBID.IsValid( m_statusEffectForTarget ) )
		{
			statusEffectSystem.ApplyStatusEffect( attackInstigator.GetEntityID(), m_statusEffectForTarget );
		}
		if( TDBID.IsValid( m_statusEffectForSelf ) )
		{
			statusEffectSystem.ApplyStatusEffect( owner.GetEntityID(), m_statusEffectForSelf );
		}
		if( m_revealDuration > 0.0 )
		{
			outlineData.outlineType = EOutlineType.YELLOW;
			outlineData.outlineOpacity = 0.80000001;
			outlineRequestEvt = new OutlineRequestEvent;
			outlineRequestEvt.outlineRequest = OutlineRequest.CreateRequest( 'SmartStorageEffector', outlineData, m_revealDuration );
			attackInstigator.QueueEvent( outlineRequestEvt );
		}
		hitEvent.attackData.AddFlag( hitFlag.RevengeActivatingHit, 'Smart Storage Revenge' );
		m_currentChance = m_baseRevengeChance;
	}

}

