class 1 amber_basilisk : warrior_passive_physicalspecial
{
handler:
	EventHandler MY_DYING(always_list,c1,code_info,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);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(334);
				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,334) && myself::OwnItemCount(c1,3680) && myself::OwnItemCount(c1,3681) && myself::OwnItemCount(c1,3684) == 0 )
					{
						if( gg::Rand(10) == 0 )
						{
							c1.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(c1,3684,1);
							myself::SoundEffect(c1,"ItemSound.quest_itemget");
						}
					}
				}
			}
			if( code_info.code == 1 )
			{
				myself::SetCurrentQuestID(66);
				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,66) == 1 && myself::GetMemoState(c1,66) == 7 && myself::OwnItemCount(c1,9775) != 30 )
					{
						if( gg::Rand(2) == 1 )
						{
							if( myself::OwnItemCount(c1,9775) < 29 )
							{
								myself::GiveItem1(c1,9775,1);
								myself::SoundEffect(c1,"Itemsound.quest_itemget");
							}
							else
							{
								myself::GiveItem1(c1,9775,1);
								myself::SetMemoState(c1,66,8);
								myself::SoundEffect(c1,"Itemsound.quest_middle");
								myself::SetFlagJournal(c1,66,8);
							}
						}
					}
				}
			}
		}
		super;
	}

}
