class 1 ol_mahum_patrol : warrior_passive_use_bow
{
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);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(407);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( myself::HaveMemo(myself.c_quest0,407) && myself.i_quest0 == 1 && myself::GetMemoState(myself.c_quest0,407) == 1 )
						{
							if( ( ( ( myself::OwnItemCount(myself.c_quest0,1208) + myself::OwnItemCount(myself.c_quest0,1209) ) + myself::OwnItemCount(myself.c_quest0,1210) ) + myself::OwnItemCount(myself.c_quest0,1211) ) < 4 )
							{
								if( myself::OwnItemCount(myself.c_quest0,1208) < 1 )
								{
									myself::GiveItem1(myself.c_quest0,1208,1);
									if( ( ( ( myself::OwnItemCount(myself.c_quest0,1208) + myself::OwnItemCount(myself.c_quest0,1209) ) + myself::OwnItemCount(myself.c_quest0,1210) ) + myself::OwnItemCount(myself.c_quest0,1211) ) >= 3 )
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_middle");
										myself::SetFlagJournal(myself.c_quest0,407,3);
									}
									else
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_itemget");
									}
								}
								else if( myself::OwnItemCount(myself.c_quest0,1209) < 1 )
								{
									myself::GiveItem1(myself.c_quest0,1209,1);
									if( ( ( ( myself::OwnItemCount(myself.c_quest0,1208) + myself::OwnItemCount(myself.c_quest0,1209) ) + myself::OwnItemCount(myself.c_quest0,1210) ) + myself::OwnItemCount(myself.c_quest0,1211) ) >= 3 )
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_middle");
										myself::SetFlagJournal(myself.c_quest0,407,3);
									}
									else
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_itemget");
									}
								}
								else if( myself::OwnItemCount(myself.c_quest0,1210) < 1 )
								{
									myself::GiveItem1(myself.c_quest0,1210,1);
									if( ( ( ( myself::OwnItemCount(myself.c_quest0,1208) + myself::OwnItemCount(myself.c_quest0,1209) ) + myself::OwnItemCount(myself.c_quest0,1210) ) + myself::OwnItemCount(myself.c_quest0,1211) ) >= 3 )
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_middle");
										myself::SetFlagJournal(myself.c_quest0,407,3);
									}
									else
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_itemget");
									}
								}
								else if( myself::OwnItemCount(myself.c_quest0,1211) < 1 )
								{
									myself::GiveItem1(myself.c_quest0,1211,1);
									if( ( ( ( myself::OwnItemCount(myself.c_quest0,1208) + myself::OwnItemCount(myself.c_quest0,1209) ) + myself::OwnItemCount(myself.c_quest0,1210) ) + myself::OwnItemCount(myself.c_quest0,1211) ) >= 3 )
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_middle");
										myself::SetFlagJournal(myself.c_quest0,407,3);
									}
									else
									{
										myself::SoundEffect(myself.c_quest0,"ItemSound.quest_itemget");
									}
								}
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(326);
					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,326) )
						{
							if( gg::Rand(100) < 50 )
							{
								myself::GiveItem1(c1,1359,1);
								myself::SoundEffect(c1,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(63);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						c1 = myself::GetLastAttacker();
						if( myself::HaveMemo(c1,63) != 0 && myself::GetMemoState(c1,63) == 2 )
						{
							if( myself::OwnItemCount(c1,9763) < 4 )
							{
								myself::GiveItem1(c1,9763,1);
								myself::SoundEffect(c1,"ItemSound.quest_itemget");
							}
							if( myself::OwnItemCount(c1,9763) == 4 )
							{
								myself::GiveItem1(c1,9763,1);
								if( myself::OwnItemCount(c1,9762) == 10 )
								{
									myself::SetFlagJournal(c1,63,3);
									myself::AddLog(3,c1,63);
									myself::SetMemoState(c1,63,3);
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage,c0)
	{
		myself::SetCurrentQuestID(407);
		if( myself::HaveMemo(attacker,407) )
		{
			c0 = attacker;
			if( c0.master )
			{
				c0 = c0.master;
			}
			switch(myself.i_quest0)
			{
				case 0:
				{
					myself.i_quest0 = 1;
					myself.c_quest0 = c0;
					break;
				}
				case 1:
				{
					if( myself.c_quest0 != c0 )
					{
						myself.i_quest0 = 2;
					}
					break;
				}
				case 2:
				{
					break;
				}
			}
		}
		super;
	}

}
