class 1 needle_stakato_worker : wizard_ag_run_away_fiend_archer
{
handler:
	EventHandler MY_DYING(always_list,code_info,i0,i4,i9,last_attacker,lparty,member,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		if( myself::HaveMemo(target,628) == 1 && myself::OwnItemCount(target,7247) < 1 && myself::OwnItemCount(target,7246) >= 1 && myself::OwnItemCount(target,7249) < 100 )
		{
			random1_list::SetInfo(0,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,628) == 1 && myself::OwnItemCount(target,7247) < 1 && myself::OwnItemCount(target,7246) >= 1 && myself::OwnItemCount(target,7249) < 100 )
				{
					random1_list::SetInfo(0,target);
				}
			}
		}
		target = last_attacker;
		if( myself::HaveMemo(target,629) == 1 && myself::GetMemoState(target,629) == ( ( 1 * 10 ) + 1 ) )
		{
			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,629) == 1 && myself::GetMemoState(target,629) == ( ( 1 * 10 ) + 1 ) )
				{
					random1_list::SetInfo(1,target);
				}
			}
		}
		target = last_attacker;
		if( myself::HaveMemo(target,426) == 1 )
		{
			random1_list::SetInfo(2,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,426) == 1 )
				{
					random1_list::SetInfo(2,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(628);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i0 = gg::Rand(100);
						if( i0 < 43 )
						{
							if( myself::OwnItemCount(target,7249) >= 99 )
							{
								myself::GiveItem1(target,7249,1);
								myself::SoundEffect(target,"ItemSound.quest_middle");
							}
							else
							{
								myself::GiveItem1(target,7249,1);
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(629);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i4 = gg::Rand(1000);
						if( i4 < 538 )
						{
							myself::GiveItem1(target,7250,1);
							myself::SoundEffect(target,"ItemSound.quest_itemget");
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(426);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(1000) < 185 )
						{
							myself::GiveItem1(target,7586,2);
							myself::SoundEffect(target,"ItemSound.quest_itemget");
						}
						else
						{
							myself::GiveItem1(target,7586,1);
							myself::SoundEffect(target,"ItemSound.quest_itemget");
						}
					}
					break;
				}
			}
		}
		super;
	}

}
