class 1 ketra_high_guard : party_private_pa_physicalspecial_stone
{
handler:
	EventHandler MY_DYING(always_list,code_info,i4,i9,last_attacker,lparty,member,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		always_list::SetInfo(0,target);
		if( gg::IsNull(lparty) == 0 )
		{
			for(i9 = 0; i9 < lparty.member_count; i9 = ( i9 + 1 ))
			{
				target = myself::GetMemberOfParty(lparty,i9);
				always_list::SetInfo(0,target);
			}
		}
		target = last_attacker;
		if( myself::HaveMemo(target,611) == 1 && ( ( ( myself::OwnItemCount(target,7222) >= 1 && myself::OwnItemCount(target,7228) < 100 ) || ( myself::OwnItemCount(target,7223) >= 1 && myself::OwnItemCount(target,7228) < 200 ) ) || ( myself::OwnItemCount(target,7224) >= 1 && myself::OwnItemCount(target,7228) < 200 ) ) )
		{
			random1_list::SetInfo(1,target);
		}
		if( gg::IsNull(lparty) == 0 )
		{
			for(i9 = 0; i9 < lparty.member_count; i9 = ( i9 + 1 ))
			{
				target = myself::GetMemberOfParty(lparty,i9);
				if( myself::HaveMemo(target,611) == 1 && ( ( ( myself::OwnItemCount(target,7222) >= 1 && myself::OwnItemCount(target,7228) < 100 ) || ( myself::OwnItemCount(target,7223) >= 1 && myself::OwnItemCount(target,7228) < 200 ) ) || ( myself::OwnItemCount(target,7224) >= 1 && myself::OwnItemCount(target,7228) < 200 ) ) )
				{
					random1_list::SetInfo(1,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(605);
				while( gg::IsNull(target = code_info::Next()) == 0 )
				{
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						myself::SetCurrentQuestID(605);
						if( myself::OwnItemCount(target,7215) >= 1 )
						{
							myself::DeleteItem1(target,7215,myself::OwnItemCount(target,7215));
							myself::GiveItem1(target,7214,1);
						}
						else if( myself::OwnItemCount(target,7214) >= 1 )
						{
							myself::DeleteItem1(target,7214,myself::OwnItemCount(target,7214));
							myself::GiveItem1(target,7213,1);
						}
						else if( myself::OwnItemCount(target,7213) >= 1 )
						{
							myself::DeleteItem1(target,7213,myself::OwnItemCount(target,7213));
							myself::GiveItem1(target,7212,1);
						}
						else if( myself::OwnItemCount(target,7212) >= 1 )
						{
							myself::DeleteItem1(target,7212,myself::OwnItemCount(target,7212));
							myself::GiveItem1(target,7211,1);
						}
						else if( myself::OwnItemCount(target,7211) >= 1 )
						{
							myself::DeleteItem1(target,7211,myself::OwnItemCount(target,7211));
						}
						if( myself::HaveMemo(target,605) )
						{
							myself::RemoveMemo(target,605);
							myself::AddLog(2,target,605);
							myself::DeleteItem1(target,7216,myself::OwnItemCount(target,7216));
							myself::DeleteItem1(target,7217,myself::OwnItemCount(target,7217));
							myself::DeleteItem1(target,7218,myself::OwnItemCount(target,7218));
						}
						if( myself::HaveMemo(target,606) )
						{
							myself::RemoveMemo(target,606);
							myself::AddLog(2,target,606);
							myself::DeleteItem1(target,7233,myself::OwnItemCount(target,7233));
						}
						if( myself::HaveMemo(target,607) )
						{
							myself::RemoveMemo(target,607);
							myself::AddLog(2,target,607);
							myself::DeleteItem1(target,7235,myself::OwnItemCount(target,7235));
						}
						if( myself::HaveMemo(target,608) )
						{
							myself::RemoveMemo(target,608);
							myself::AddLog(2,target,608);
							myself::DeleteItem1(target,7236,myself::OwnItemCount(target,7236));
						}
						if( myself::HaveMemo(target,609) )
						{
							myself::RemoveMemo(target,609);
							myself::AddLog(2,target,609);
							myself::DeleteItem1(target,7237,myself::OwnItemCount(target,7237));
						}
						if( myself::HaveMemo(target,610) )
						{
							myself::RemoveMemo(target,610);
							myself::AddLog(2,target,610);
							myself::DeleteItem1(target,7239,myself::OwnItemCount(target,7239));
						}
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			if( code_info.code == 1 )
			{
				myself::SetCurrentQuestID(611);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					i4 = gg::Rand(1000);
					if( i4 < 604 )
					{
						myself::GiveItem1(target,7228,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
					}
				}
			}
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage)
	{
		myself::SetCurrentQuestID(615);
		if( myself::HaveMemo(attacker,615) && myself::GetMemoState(attacker,615) == 2 )
		{
			myself::SetMemoState(attacker,615,3);
			myself::CreateOnePrivateEx(1031685,"asefas_eye",0,0,myself::FloatToInt(myself.sm.x),myself::FloatToInt(myself.sm.y),myself::FloatToInt(myself.sm.z),0,0,0,0);
			if( myself::Skill_GetConsumeMP(1164033) < myself.sm.mp && myself::Skill_GetConsumeHP(1164033) < myself.sm.hp && myself::Skill_InReuseDelay(1164033) == 0 )
			{
				myself::AddUseSkillDesire(attacker,1164033,0,1,10000000);
			}
		}
		super;
	}

}
