class 1 ant : warrior_passive
{
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;
		if( myself::HaveMemo(target,426) == 1 )
		{
			random1_list::SetInfo(2,target);
		}
		if( gg::IsNull(lparty) == 0 )
		{
			for(i9 = 0; i9 < lparty.member_count; i9 = ( i9 + 1 ))
			{
				target = myself::GetMemberOfParty(lparty,i9);
				if( myself::HaveMemo(target,426) == 1 )
				{
					random1_list::SetInfo(2,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					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 1:
				{
					myself::SetCurrentQuestID(216);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i0 = 0;
						c1 = myself::GetLastAttacker();
						if( c1.master )
						{
							c1 = c1.master;
						}
						if( myself::HaveMemo(c1,216) == 1 && myself::OwnItemCount(c1,3122) == 1 && myself::OwnItemCount(c1,3135) == 1 )
						{
							if( myself::OwnItemCount(c1,3136) < 70 )
							{
								if( gg::Rand(100) < 50 && c1.occupation == 54 && myself::IsSpoiled() == 1 )
								{
									i0 = ( i0 + 1 );
								}
								if( gg::Rand(100) < 10 && c1.occupation == 56 )
								{
									c1.quest_last_reward_time = myself::GetCurrentTick();
									myself::GiveItem1(c1,3137,1);
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
								if( gg::Rand(100) < 50 && ( myself::OwnItemCount(c1,3136) + i0 ) < 70 )
								{
									i0 = ( i0 + 1 );
								}
								if( i0 >= 1 )
								{
									c1.quest_last_reward_time = myself::GetCurrentTick();
									myself::GiveItem1(c1,3136,i0);
									if( myself::OwnItemCount(c1,3136) >= 70 )
									{
										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 )
		{
			if( code_info.code == 2 )
			{
				myself::SetCurrentQuestID(426);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					if( gg::Rand(1000) < 205 )
					{
						myself::GiveItem1(target,7586,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
					}
				}
			}
		}
		super;
	}

}
