class 1 alfred_von_helmann : agit_fortress_of_the_dead
{
parameter:
	int	DDMagic1 = 1280001;
	int	DDMagic2 = 1280257;

handler:
	EventHandler NO_DESIRE()
	{
		myself::AddDoNothingDesire(5,5);
	}

	EventHandler CREATED()
	{
		myself::AddTimerEx(1001,1000);
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 1001 )
		{
			if( myself::InMyTerritory(myself.sm) == 0 && gg::Rand(3) < 1 )
			{
				myself::InstantTeleport(myself.sm,myself::FloatToInt(myself.boss.x),myself::FloatToInt(myself.boss.y),myself::FloatToInt(myself.boss.z));
				myself::RemoveAllAttackDesire();
			}
			if( gg::Rand(5) < 1 )
			{
				myself::RandomizeAttackDesire();
			}
			myself::AddTimerEx(1001,( 60 * 1000 ));
		}
	}

	EventHandler ATTACKED(attacker,damage)
	{
		if( gg::Rand(100) < 80 )
		{
			if( myself::FloatToInt(( ( myself.sm.hp / myself.sm.max_hp ) * 100 )) < 50 )
			{
				if( myself::Skill_GetConsumeMP(DDMagic2) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic2) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic2) == 0 )
				{
					myself::AddUseSkillDesire(attacker,DDMagic2,1,0,1000000);
				}
			}
			else if( myself::Skill_GetConsumeMP(DDMagic1) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic1) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic1) == 0 )
			{
				myself::AddUseSkillDesire(attacker,DDMagic1,1,0,1000000);
			}
		}
	}

	EventHandler PARTY_ATTACKED(attacker,private,damage)
	{
		if( gg::Rand(100) < 80 )
		{
			if( myself::FloatToInt(( ( myself.sm.hp / myself.sm.max_hp ) * 100 )) < 50 )
			{
				if( myself::Skill_GetConsumeMP(DDMagic2) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic2) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic2) == 0 )
				{
					myself::AddUseSkillDesire(attacker,DDMagic2,1,0,1000000);
				}
			}
			else if( myself::Skill_GetConsumeMP(DDMagic1) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic1) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic1) == 0 )
			{
				myself::AddUseSkillDesire(attacker,DDMagic1,1,0,1000000);
			}
		}
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			myself::AddAttackDesire(attacker,1,( ( ( ( ( damage / myself.sm.max_hp ) / 0.050000 ) * damage ) * private.weight_point ) / 10000 ));
		}
	}

	EventHandler SEE_SPELL(speller,skill_name_id,target)
	{
		if( myself::Skill_GetEffectPoint(skill_name_id) > 0 )
		{
			if( myself.p_state == 3 && myself.boss == target )
			{
				myself::AddAttackDesire(speller,1,( ( ( myself::Skill_GetEffectPoint(skill_name_id) / myself.sm.max_hp ) / 0.050000 ) * 150 ));
			}
		}
		if( myself::GetPathfindFailCount() > 10 && speller == myself.boss && myself::FloatToInt(myself.sm.hp) != myself::FloatToInt(myself.sm.max_hp) )
		{
			myself::InstantTeleport(myself.sm,myself::FloatToInt(speller.x),myself::FloatToInt(speller.y),myself::FloatToInt(speller.z));
		}
	}

}
