class 1 tamlin_orc_archer : warrior_passive_use_power_shot
{
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);
		target = last_attacker;
		always_list::SetInfo(1,target);
		target = last_attacker;
		always_list::SetInfo(2,target);
		target = last_attacker;
		always_list::SetInfo(3,target);
		target = last_attacker;
		always_list::SetInfo(4,target);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(220);
					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,220) && myself::OwnItemCount(c1,3209) && myself::OwnItemCount(c1,3217) && myself::OwnItemCount(c1,3218) < 20 )
						{
							if( gg::Rand(10) < 6 )
							{
								if( myself::OwnItemCount(c1,3218) == 19 )
								{
									myself::GiveItem1(c1,3218,1);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
									if( myself::OwnItemCount(c1,3219) >= 20 )
									{
										myself::SetFlagJournal(c1,220,7);
									}
								}
								else
								{
									myself::GiveItem1(c1,3218,1);
									myself::SoundEffect(c1,"Itemsound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(229);
					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,229) == 1 && myself::OwnItemCount(c1,3328) == 1 )
						{
							if( gg::Rand(100) < 50 && myself::OwnItemCount(c1,3329) < 20 )
							{
								c1.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c1,3329,1);
								if( myself::OwnItemCount(c1,3329) >= 20 )
								{
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
								else
								{
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(233);
					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,233) && myself::OwnItemCount(c1,2880) == 1 && myself::OwnItemCount(c1,2881) < 13 )
						{
							if( gg::Rand(100) < 50 )
							{
								c1.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c1,2881,1);
								myself::SoundEffect(c1,"ItemSound.quest_middle");
							}
						}
					}
					break;
				}
				case 3:
				{
					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,2767) > 0 && myself::OwnItemCount(c1,2777) < 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,2777,1);
							if( myself::OwnItemCount(c1,2777) >= 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(335);
					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,335) && myself::OwnItemCount(c1,3738) && myself::OwnItemCount(c1,3780) < 40 )
						{
							if( gg::Rand(10) < 8 )
							{
								c1.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c1,3780,1);
								if( myself::OwnItemCount(c1,3780) >= 40 )
								{
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
								else
								{
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		super;
	}

}
