class ModifyDamageWithStatPoolEffector extends ModifyDamageEffector
{
	var m_statPool : gamedataStatPoolType;
	var m_poolStatus : String;
	var m_maxDmg : Float;
	var m_percentMult : Float;
	var m_refObj : String;

	protected override function Initialize( record : TweakDBID, game : GameInstance, parentRecord : TweakDBID )
	{
		var str : String;
		super.Initialize( record, game, parentRecord );
		str = TweakDBInterface.GetString( record + T".operationType", "" );
		m_operationType = ( ( EMathOperator )( ( ( Int32 )( EnumValueFromString( "EMathOperator", str ) ) ) ) );
		str = TweakDBInterface.GetString( record + T".statPool", "" );
		m_statPool = ( ( gamedataStatPoolType )( ( ( Int32 )( EnumValueFromString( "gamedataStatPoolType", str ) ) ) ) );
		m_poolStatus = TweakDBInterface.GetString( record + T".poolStatus", "" );
		m_refObj = TweakDBInterface.GetString( record + T".refObj", "" );
		m_maxDmg = TweakDBInterface.GetFloat( record + T".maxDmg", 1.0 );
		m_percentMult = TweakDBInterface.GetFloat( record + T".percentMult", 0.0 );
	}

	protected override function Uninitialize( game : GameInstance ) {}

	private function GetRefObject( hitEvent : gameHitEvent ) : weak< GameObject >
	{
		switch( m_refObj )
		{
			case "Instigator":
				return hitEvent.attackData.GetInstigator();
			case "Target":
				return hitEvent.target;
			default:
				return NULL;
		}
	}

	protected override function RepeatedAction( owner : GameObject )
	{
		var hitEvent : gameHitEvent;
		var obj : weak< GameObject >;
		var statPoolVal : Float;
		var statPoolMaxVal : Float;
		hitEvent = GetHitEvent();
		if( !( hitEvent ) )
		{
			return;
		}
		obj = GetRefObject( hitEvent );
		if( !( obj ) )
		{
			return;
		}
		statPoolVal = GameInstance.GetStatPoolsSystem( owner.GetGame() ).GetStatPoolValue( obj.GetEntityID(), m_statPool ) / 100.0;
		if( m_poolStatus == "Missing" )
		{
			statPoolVal = 1.0 - statPoolVal;
		}
		if( m_percentMult != 0.0 )
		{
			statPoolMaxVal = GameInstance.GetStatPoolsSystem( owner.GetGame() ).GetStatPoolMaxPointValue( obj.GetEntityID(), m_statPool );
			statPoolVal *= statPoolMaxVal;
			m_value = ( statPoolVal * m_percentMult ) + 1.0;
			if( m_maxDmg != 0.0 )
			{
				m_value = MinF( m_value, m_maxDmg );
			}
			ModifyDamage( hitEvent, m_operationType, m_value );
		}
		else if( m_maxDmg != 0.0 )
		{
			m_value = ( ( m_maxDmg - 1.0 ) * statPoolVal ) + 1.0;
			ModifyDamage( hitEvent, m_operationType, m_value );
		}
	}

}

