class 1 royal_cave_servant_hold : warrior_passive_casting_sleep_magic
{
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);
		target = last_attacker;
		if( myself::HaveMemo(target,344) && ( myself::GetMemoState(target,344) == 1 || myself::GetMemoState(target,344) == 2 ) )
		{
			random1_list::SetInfo(1,target);
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(336);
				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,336) && myself::GetMemoState(c1,336) == 3 && gg::Rand(5) == 0 )
					{
						c1.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(c1,3482,1);
						myself::SoundEffect(c1,"ItemSound.quest_itemget");
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			if( code_info.code == 1 )
			{
				myself::SetCurrentQuestID(344);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					if( gg::Rand(100) < 53 )
					{
						myself::GiveItem1(target,4269,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
						myself::SetMemoState(target,344,2);
					}
				}
			}
		}
		super;
	}

}
