class 1 dead_seeker : warrior_pa_casting_3skill_magical2
{
handler:
	EventHandler MY_DYING(always_list,c1,code_info,i0,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(4,target);
		always_list::SetInfo(5,target);
		if( myself::HaveMemo(target,420) == 1 && myself::OwnItemCount(target,3830) == 1 && myself::OwnItemCount(target,3831) < 20 )
		{
			random1_list::SetInfo(3,target);
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(219);
					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,219) && myself::OwnItemCount(c1,3177) && myself::OwnItemCount(c1,3180) < 10 )
						{
							if( gg::Rand(2) == 1 )
							{
								if( myself::OwnItemCount(c1,3180) == 9 )
								{
									myself::GiveItem1(c1,3180,1);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
									if( myself::OwnItemCount(c1,3178) >= 10 && myself::OwnItemCount(c1,3179) >= 10 && myself::OwnItemCount(c1,3181) >= 10 && myself::OwnItemCount(c1,3182) >= 10 )
									{
										myself::SetFlagJournal(c1,219,7);
									}
								}
								else
								{
									myself::GiveItem1(c1,3180,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,3132) <= 68 )
							{
								c1.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c1,3132,2);
								if( myself::OwnItemCount(c1,3132) >= 70 )
								{
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
								else
								{
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(222);
					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,222) && myself::OwnItemCount(c1,2764) > 0 && myself::OwnItemCount(c1,2771) < 10 && myself::GetMemoState(c1,222) == 1 )
						{
							i0 = myself::GetMemoStateEx(c1,222,1);
							myself::SetMemoStateEx(c1,222,1,( i0 + 1 ));
							c1.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(c1,2771,1);
							if( myself::OwnItemCount(c1,2771) >= 10 )
							{
								myself::SoundEffect(c1,"ItemSound.quest_middle");
								if( i0 >= 9 )
								{
									myself::SetFlagJournal(c1,222,3);
									myself::SetMemoStateEx(c1,222,1,0);
								}
							}
							else
							{
								myself::SoundEffect(c1,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 4:
				{
					myself::SetCurrentQuestID(64);
					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,64) == 1 && myself::GetMemoState(c1,64) == 9 && myself::OwnItemCount(c1,9756) == 0 )
						{
							if( gg::Rand(5) == 1 )
							{
								if( myself::OwnItemCount(c1,9757) == 1 )
								{
									myself::GiveItem1(c1,9756,1);
									myself::SetMemoState(c1,64,10);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
									myself::SetFlagJournal(c1,64,10);
								}
								else
								{
									myself::GiveItem1(c1,9756,1);
									myself::SoundEffect(c1,"Itemsound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 5:
				{
					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::SoundEffect(c1,"Itemsound.quest_middle");
									myself::SetFlagJournal(c1,66,8);
								}
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			if( code_info.code == 3 )
			{
				myself::SetCurrentQuestID(420);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					if( gg::Rand(100) < 50 )
					{
						target.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(target,3831,1);
						if( myself::OwnItemCount(target,3831) >= 20 )
						{
							myself::SoundEffect(target,"ItemSound.quest_middle");
						}
						else
						{
							myself::SoundEffect(target,"ItemSound.quest_itemget");
						}
					}
				}
			}
		}
		super;
	}

}
