class 1 fiend_archer_1 : wizard_ag_fiend_archer
{
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;
		if( myself::HaveMemo(target,426) == 1 )
		{
			random1_list::SetInfo(1,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(1,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(350);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					c1 = myself::GetLastAttacker();
					if( c1.master )
					{
						c1 = c1.master;
					}
					c1.quest_last_reward_time = myself::GetCurrentTick();
					if( myself::HaveMemo(c1,350) == 1 && c1 == myself.c_quest0 && myself.i_quest0 == 2 )
					{
						if( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( myself::OwnItemCount(c1,4651) + myself::OwnItemCount(c1,4652) ) + myself::OwnItemCount(c1,4653) ) + myself::OwnItemCount(c1,4654) ) + myself::OwnItemCount(c1,4655) ) + myself::OwnItemCount(c1,4656) ) + myself::OwnItemCount(c1,4657) ) + myself::OwnItemCount(c1,4658) ) + myself::OwnItemCount(c1,4659) ) + myself::OwnItemCount(c1,4660) ) + myself::OwnItemCount(c1,4661) ) + myself::OwnItemCount(c1,5579) ) + myself::OwnItemCount(c1,5582) ) + myself::OwnItemCount(c1,5914) ) + myself::OwnItemCount(c1,4629) ) + myself::OwnItemCount(c1,4630) ) + myself::OwnItemCount(c1,4631) ) + myself::OwnItemCount(c1,4632) ) + myself::OwnItemCount(c1,4633) ) + myself::OwnItemCount(c1,4634) ) + myself::OwnItemCount(c1,4635) ) + myself::OwnItemCount(c1,4636) ) + myself::OwnItemCount(c1,4637) ) + myself::OwnItemCount(c1,4638) ) + myself::OwnItemCount(c1,4639) ) + myself::OwnItemCount(c1,5577) ) + myself::OwnItemCount(c1,5580) ) + myself::OwnItemCount(c1,5908) ) + myself::OwnItemCount(c1,4640) ) + myself::OwnItemCount(c1,4641) ) + myself::OwnItemCount(c1,4642) ) + myself::OwnItemCount(c1,4643) ) + myself::OwnItemCount(c1,4644) ) + myself::OwnItemCount(c1,4645) ) + myself::OwnItemCount(c1,4646) ) + myself::OwnItemCount(c1,4647) ) + myself::OwnItemCount(c1,4648) ) + myself::OwnItemCount(c1,4649) ) + myself::OwnItemCount(c1,4650) ) + myself::OwnItemCount(c1,5578) ) + myself::OwnItemCount(c1,5581) ) + myself::OwnItemCount(c1,5911) ) == 1 )
						{
							i0 = gg::Rand(100);
							if( i0 <= 9 )
							{
								if( myself::OwnItemCount(c1,4651) == 1 )
								{
									myself::DeleteItem1(c1,4651,1);
									myself::GiveItem1(c1,4652,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4652) == 1 )
								{
									myself::DeleteItem1(c1,4652,1);
									myself::GiveItem1(c1,4653,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4653) == 1 )
								{
									myself::DeleteItem1(c1,4653,1);
									myself::GiveItem1(c1,4654,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4654) == 1 )
								{
									myself::DeleteItem1(c1,4654,1);
									myself::GiveItem1(c1,4655,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4629) == 1 )
								{
									myself::DeleteItem1(c1,4629,1);
									myself::GiveItem1(c1,4630,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4630) == 1 )
								{
									myself::DeleteItem1(c1,4630,1);
									myself::GiveItem1(c1,4631,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4631) == 1 )
								{
									myself::DeleteItem1(c1,4631,1);
									myself::GiveItem1(c1,4632,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4632) == 1 )
								{
									myself::DeleteItem1(c1,4632,1);
									myself::GiveItem1(c1,4633,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4640) == 1 )
								{
									myself::DeleteItem1(c1,4640,1);
									myself::GiveItem1(c1,4641,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4641) == 1 )
								{
									myself::DeleteItem1(c1,4641,1);
									myself::GiveItem1(c1,4642,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4642) == 1 )
								{
									myself::DeleteItem1(c1,4642,1);
									myself::GiveItem1(c1,4643,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else if( myself::OwnItemCount(c1,4643) == 1 )
								{
									myself::DeleteItem1(c1,4643,1);
									myself::GiveItem1(c1,4644,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
									myself::ShowSystemMessage(c1,974);
								}
								else
								{
									myself::ShowSystemMessage(c1,978);
								}
							}
							else if( i0 >= 98 )
							{
								if( myself::OwnItemCount(c1,4651) == 1 )
								{
									myself::DeleteItem1(c1,4651,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4652) == 1 )
								{
									myself::DeleteItem1(c1,4652,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4653) == 1 )
								{
									myself::DeleteItem1(c1,4653,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4654) == 1 )
								{
									myself::DeleteItem1(c1,4654,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4629) == 1 )
								{
									myself::DeleteItem1(c1,4629,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4630) == 1 )
								{
									myself::DeleteItem1(c1,4630,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4631) == 1 )
								{
									myself::DeleteItem1(c1,4631,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4632) == 1 )
								{
									myself::DeleteItem1(c1,4632,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4640) == 1 )
								{
									myself::DeleteItem1(c1,4640,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4641) == 1 )
								{
									myself::DeleteItem1(c1,4641,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4642) == 1 )
								{
									myself::DeleteItem1(c1,4642,1);
									myself::ShowSystemMessage(c1,976);
								}
								else if( myself::OwnItemCount(c1,4643) == 1 )
								{
									myself::DeleteItem1(c1,4643,1);
									myself::ShowSystemMessage(c1,976);
								}
								else
								{
									myself::ShowSystemMessage(c1,978);
								}
							}
							else
							{
								myself::ShowSystemMessage(c1,975);
							}
						}
						else
						{
							myself::ShowSystemMessage(c1,977);
						}
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			if( code_info.code == 1 )
			{
				myself::SetCurrentQuestID(426);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					if( gg::Rand(1000) < 615 )
					{
						myself::GiveItem1(target,7586,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
					}
				}
			}
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage,skill_name_id)
	{
		myself::SetCurrentQuestID(350);
		switch(myself.i_quest0)
		{
			case 0:
			{
				myself.i_quest0 = 1;
				if( ( skill_name_id / 256 ) == ( 536576 / 256 ) && myself.sm.hp <= ( myself.sm.max_hp * 0.500000 ) )
				{
					myself.i_quest0 = 2;
					myself.c_quest0 = attacker;
				}
				break;
			}
			case 1:
			{
				if( ( skill_name_id / 256 ) == ( 536576 / 256 ) && myself.sm.hp <= ( myself.sm.max_hp * 0.500000 ) )
				{
					myself.i_quest0 = 2;
					myself.c_quest0 = attacker;
				}
				break;
			}
			case 2:
			{
				break;
			}
		}
		super;
	}

}
