class 1 ai_boss01_queen_ant : default_npc
{
parameter:
	string	Privates = "nurse_ant:nurse_ant:2:10sec;nurse_ant:nurse_ant:2:10sec;nurse_ant:nurse_ant:2:10sec;royal_guard_ant:royal_guard_ant:1:20sec;royal_guard_ant:royal_guard_ant:1:20sec;royal_guard_ant:royal_guard_ant:1:20sec;royal_guard_ant:royal_guard_ant:1:20sec";
	float	Attack_DecayRatio = 6.600000;
	float	UseSkill_DecayRatio = 66000.000000;
	float	Attack_BoostValue = 500.000000;
	float	UseSkill_BoostValue = 100000.000000;

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

	EventHandler CREATED()
	{
		if( gg::Rand(100) < 33 )
		{
			myself::InstantTeleportInMyTerritory(-19480,187344,-5600,200);
		}
		else if( gg::Rand(100) < 50 )
		{
			myself::InstantTeleportInMyTerritory(-17928,180912,-5520,200);
		}
		else
		{
			myself::InstantTeleportInMyTerritory(-23808,182368,-5600,200);
		}
		myself::EffectMusic(myself.sm,10000,"BS01_A");
		myself.sm.weight_point = 10;
		myself::CreatePrivates(Privates);
		myself::CreateOnePrivateEx(1029002,"queen_ant_larva",0,0,-21600,179482,-5846,gg::Rand(360),0,0,0);
		myself::AddTimerEx(1001,10000);
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 1001 )
		{
			if( gg::Rand(100) < 30 && myself.p_state == 1 )
			{
				if( gg::Rand(100) < 50 )
				{
					myself::AddEffectActionDesire(myself.sm,3,( ( 50 * 1000 ) / 30 ),30);
				}
				else
				{
					myself::AddEffectActionDesire(myself.sm,4,( ( 50 * 1000 ) / 30 ),30);
				}
			}
			myself::AddTimerEx(1001,10000);
		}
		super;
	}

	EventHandler PARTY_DIED(private)
	{
		if( private != myself.sm )
		{
			if( private.npc_class_id == 1029003 )
			{
				myself::CreateOnePrivate(private.npc_class_id,private.ai,private.weight_point,10);
			}
			else
			{
				myself::CreateOnePrivate(private.npc_class_id,private.ai,private.weight_point,( 280 + gg::Rand(40) ));
			}
		}
	}

	EventHandler ATTACKED(attacker,damage,skill_name_id)
	{
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( attacker.yongma_type == 1 && myself::GetAbnormalLevel(attacker,myself::Skill_GetAbnormalType(1090049)) <= 0 )
			{
				if( myself::Skill_GetConsumeMP(1090049) < myself.sm.mp && myself::Skill_GetConsumeHP(1090049) < myself.sm.hp && myself::Skill_InReuseDelay(1090049) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1090049,0,1,1000000);
				}
			}
			if( myself::Skill_GetAttribute(skill_name_id) == 12 && gg::Rand(100) < 70 )
			{
				if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028609,0,1,1000000);
				}
			}
			else if( myself::DistFromMe(attacker) > 500 && gg::Rand(100) < 10 )
			{
				if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028609,0,0,1000000);
				}
			}
			else if( myself::DistFromMe(attacker) > 150 && gg::Rand(100) < 10 )
			{
				if( gg::Rand(100) < 80 )
				{
					if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
					{
						myself::AddUseSkillDesire(attacker,1028609,0,0,1000000);
					}
				}
				else if( myself::Skill_GetConsumeMP(1028865) < myself.sm.mp && myself::Skill_GetConsumeHP(1028865) < myself.sm.hp && myself::Skill_InReuseDelay(1028865) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028865,0,0,1000000);
				}
			}
			else if( gg::Rand(100) < 5 && myself::DistFromMe(attacker) < 250 )
			{
				if( myself::Skill_GetConsumeMP(1028353) < myself.sm.mp && myself::Skill_GetConsumeHP(1028353) < myself.sm.hp && myself::Skill_InReuseDelay(1028353) == 0 )
				{
					myself::AddUseSkillDesire(myself.sm,1028353,0,1,1000000);
				}
			}
			else if( gg::Rand(100) < 1 )
			{
				myself::AddEffectActionDesire(myself.sm,1,( ( 60 * 1000 ) / 30 ),3000000);
			}
			myself::AddAttackDesire(attacker,0,( ( ( ( ( damage / myself.sm.max_hp ) / 0.050000 ) * damage ) * myself.sm.weight_point ) * 1000 ));
		}
	}

	EventHandler PARTY_ATTACKED(attacker,private,damage)
	{
		if( ( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) ) && private != myself.sm )
		{
			if( myself::DistFromMe(attacker) > 500 && gg::Rand(100) < 5 )
			{
				if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028609,0,0,1000000);
				}
			}
			else if( myself::DistFromMe(attacker) > 150 && gg::Rand(100) < 5 )
			{
				if( gg::Rand(100) < 80 )
				{
					if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
					{
						myself::AddUseSkillDesire(attacker,1028609,0,0,1000000);
					}
				}
				else if( myself::Skill_GetConsumeMP(1028865) < myself.sm.mp && myself::Skill_GetConsumeHP(1028865) < myself.sm.hp && myself::Skill_InReuseDelay(1028865) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028865,0,0,1000000);
				}
			}
			else if( gg::Rand(100) < 2 && myself::DistFromMe(attacker) < 250 )
			{
				if( myself::Skill_GetConsumeMP(1028353) < myself.sm.mp && myself::Skill_GetConsumeHP(1028353) < myself.sm.hp && myself::Skill_InReuseDelay(1028353) == 0 )
				{
					myself::AddUseSkillDesire(myself.sm,1028353,0,1,1000000);
				}
			}
			myself::AddAttackDesire(attacker,0,( ( ( ( ( damage / myself.sm.max_hp ) / 0.050000 ) * damage ) * private.weight_point ) * 1000 ));
		}
	}

	EventHandler CLAN_ATTACKED(attacker,damage)
	{
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( myself::DistFromMe(attacker) > 500 && gg::Rand(100) < 3 )
			{
				if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028609,0,0,1000000);
				}
			}
			else if( myself::DistFromMe(attacker) > 150 && gg::Rand(100) < 3 )
			{
				if( gg::Rand(100) < 80 )
				{
					if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
					{
						myself::AddUseSkillDesire(attacker,1028609,0,0,1000000);
					}
				}
				else if( myself::Skill_GetConsumeMP(1028865) < myself.sm.mp && myself::Skill_GetConsumeHP(1028865) < myself.sm.hp && myself::Skill_InReuseDelay(1028865) == 0 )
				{
					myself::AddUseSkillDesire(attacker,1028865,0,0,1000000);
				}
			}
			else if( gg::Rand(100) < 2 && myself::DistFromMe(attacker) < 250 )
			{
				if( myself::Skill_GetConsumeMP(1028353) < myself.sm.mp && myself::Skill_GetConsumeHP(1028353) < myself.sm.hp && myself::Skill_InReuseDelay(1028353) == 0 )
				{
					myself::AddUseSkillDesire(myself.sm,1028353,0,1,1000000);
				}
			}
			myself::AddAttackDesire(attacker,0,( ( ( damage / myself.sm.max_hp ) / 0.050000 ) * 500 ));
		}
	}

	EventHandler SEE_SPELL(speller,skill_name_id)
	{
		if( myself::Skill_GetEffectPoint(skill_name_id) > 0 && gg::Rand(100) < 15 )
		{
			if( myself::Skill_GetConsumeMP(1028609) < myself.sm.mp && myself::Skill_GetConsumeHP(1028609) < myself.sm.hp && myself::Skill_InReuseDelay(1028609) == 0 )
			{
				myself::AddUseSkillDesire(speller,1028609,0,0,1000000);
			}
		}
	}

	EventHandler OUT_OF_TERRITORY()
	{
		myself::InstantTeleport(myself.sm,-21610,181594,-5734);
		myself::RemoveAllAttackDesire();
	}

	EventHandler MY_DYING()
	{
		myself::EffectMusic(myself.sm,10000,"BS02_D");
	}

}
