class 1 ghoul : warrior_pa_slow_type2
{
handler:
	EventHandler MY_DYING(always_list,c1,code_info,i9,last_attacker,lparty,member,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		always_list::SetInfo(0,target);
		always_list::SetInfo(1,target);
		always_list::SetInfo(2,target);
		always_list::SetInfo(3,target);
		always_list::SetInfo(4,target);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(212);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( c1.master )
						{
							c1 = c1.master;
						}
						if( myself::HaveMemo(c1,212) && myself::GetMemoState(c1,212) == 5 && myself::OwnItemCount(c1,2638) < 10 && myself::OwnItemCount(c1,2639) == 0 )
						{
							if( myself::OwnItemCount(c1,2638) == 9 )
							{
								if( gg::Rand(2) == 1 )
								{
									myself::GiveItem1(c1,2639,1);
									myself::DeleteItem1(c1,2638,myself::OwnItemCount(c1,2638));
									myself::SoundEffect(c1,"ItemSound.quest_middle");
									myself::SetFlagJournal(c1,212,6);
								}
							}
							else if( gg::Rand(2) == 1 )
							{
								myself::GiveItem1(c1,2638,1);
								myself::SoundEffect(c1,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(216);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( c1.master )
						{
							c1 = c1.master;
						}
						if( myself::HaveMemo(c1,216) == 1 && myself::OwnItemCount(c1,3122) == 1 && myself::OwnItemCount(c1,3129) == 1 )
						{
							if( myself::OwnItemCount(c1,3130) <= 68 )
							{
								c1.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c1,3130,2);
								if( myself::OwnItemCount(c1,3130) >= 70 )
								{
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
								else
								{
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(214);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( c1.master )
						{
							c1 = c1.master;
						}
						if( myself::HaveMemo(c1,214) && myself::OwnItemCount(c1,2705) == 1 && myself::OwnItemCount(c1,2711) == 1 && myself::OwnItemCount(c1,2715) == 1 && myself::OwnItemCount(c1,2716) < 10 )
						{
							myself::GiveItem1(c1,2716,1);
							if( myself::OwnItemCount(c1,2716) >= 10 )
							{
								myself::SoundEffect(c1,"ItemSound.quest_middle");
								myself::SetFlagJournal(c1,214,29);
							}
							else
							{
								myself::SoundEffect(c1,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 3:
				{
					myself::SetCurrentQuestID(333);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( c1.master )
						{
							c1 = c1.master;
						}
						if( myself::HaveMemo(c1,333) == 1 && myself::OwnItemCount(c1,3671) >= 1 )
						{
							c1.quest_last_reward_time = myself::GetCurrentTick();
							if( gg::Rand(2) == 0 )
							{
								myself::GiveItem1(c1,3848,1);
							}
							if( gg::Rand(100) < 12 )
							{
								myself::GiveItem1(c1,3440,1);
							}
						}
					}
					break;
				}
				case 4:
				{
					myself::SetCurrentQuestID(66);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( c1.master )
						{
							c1 = c1.master;
						}
						if( myself::HaveMemo(c1,66) == 1 && myself::GetMemoState(c1,66) == 7 && myself::OwnItemCount(c1,9775) != 30 )
						{
							if( gg::Rand(2) == 1 )
							{
								if( myself::OwnItemCount(c1,9775) < 29 )
								{
									myself::GiveItem1(c1,9775,1);
									myself::SoundEffect(c1,"Itemsound.quest_itemget");
								}
								else
								{
									myself::GiveItem1(c1,9775,1);
									myself::SetMemoState(c1,66,8);
									myself::SetFlagJournal(c1,66,8);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
								}
							}
						}
					}
					break;
				}
			}
		}
		super;
	}

}
