class 1 ant_guard : warrior_pa_berserker
{
handler:
	EventHandler MY_DYING(always_list,c0,c1,c2,code_info,i0,i1,i2,i3,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);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(217);
					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,217) && myself::GetMemoState(c1,217) == 6 && myself::OwnItemCount(c1,2750) < 10 && myself::OwnItemCount(c1,2755) && myself::OwnItemCount(c1,2753) == 0 )
						{
							if( myself::OwnItemCount(c1,2750) == 9 )
							{
								myself::GiveItem1(c1,2753,1);
								myself::DeleteItem1(c1,2750,myself::OwnItemCount(c1,2750));
								myself::SoundEffect(c1,"Itemsound.quest_middle");
								if( myself::OwnItemCount(c1,2752) >= 1 && myself::OwnItemCount(c1,2754) >= 1 )
								{
									myself::SetFlagJournal(c1,217,7);
								}
							}
							else
							{
								myself::GiveItem1(c1,2750,1);
								myself::SoundEffect(c1,"Itemsound.quest_itemget");
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(224);
					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,224) && myself::GetMemoState(c1,224) == 3 && myself::OwnItemCount(c1,3298) < 10 )
						{
							if( gg::Rand(2) == 1 )
							{
								if( myself::OwnItemCount(c1,3298) == 9 )
								{
									myself::GiveItem1(c1,3298,1);
									myself::SetMemoState(c1,224,4);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
									myself::SetFlagJournal(c1,224,4);
								}
								else
								{
									myself::GiveItem1(c1,3298,1);
									myself::SoundEffect(c1,"Itemsound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(218);
					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,218) && myself::OwnItemCount(c1,3144) == 1 && myself::OwnItemCount(c1,3149) == 1 && myself::OwnItemCount(c1,3162) < 20 )
						{
							if( gg::Rand(100) < 80 )
							{
								c1.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c1,3162,1);
								if( myself::OwnItemCount(c1,3162) >= 19 )
								{
									myself::SoundEffect(c1,"ItemSound.quest_middle");
									if( myself::OwnItemCount(c1,3161) >= 10 && myself::OwnItemCount(c1,3163) >= 20 )
									{
										myself::SetFlagJournal(c1,218,5);
									}
								}
								else
								{
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 3:
				{
					myself::SetCurrentQuestID(370);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(100) < 9 )
						{
							c1 = myself::GetLastAttacker();
							if( c1.master )
							{
								c1 = c1.master;
							}
							i1 = myself::Party_GetCount(c1);
							i2 = 0;
							if( i1 == 0 && myself::HaveMemo(c1,370) == 1 )
							{
								c2 = c1;
							}
							for(i0 = 0; i0 < i1; i0 = ( i0 + 1 ))
							{
								c0 = myself::Party_GetCreature(c1,i0);
								if( myself::HaveMemo(c0,370) == 1 )
								{
									i3 = gg::Rand(1000);
									if( i2 < i3 )
									{
										i2 = i3;
										c2 = c0;
									}
								}
							}
							if( myself::IsNullCreature(c2) == 0 && myself::DistFromMe(c2) <= 1500 )
							{
								c2.quest_last_reward_time = myself::GetCurrentTick();
								myself::GiveItem1(c2,5916,1);
								myself::SoundEffect(c2,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		super;
	}

}
