class 1 ti_mi_kran_elder : warrior_pa_slow_type1
{
handler:
	EventHandler MY_DYING(always_list,code_info,i9,last_attacker,lparty,member,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		if( myself::HaveMemo(target,420) == 1 && myself::OwnItemCount(target,3817) == 1 )
		{
			random1_list::SetInfo(0,target);
		}
		target = last_attacker;
		if( myself::HaveMemo(target,335) && myself::OwnItemCount(target,3696) && myself::OwnItemCount(target,3719) < 30 )
		{
			random1_list::SetInfo(1,target);
		}
		target = last_attacker;
		if( myself::HaveMemo(target,357) == 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,357) == 1 )
				{
					random1_list::SetInfo(2,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(420);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(100) < 30 )
						{
							target.quest_last_reward_time = myself::GetCurrentTick();
							myself::DeleteItem1(target,3817,1);
							myself::SoundEffect(target,"ItemSound.quest_middle");
							myself::SetMemoState(target,420,10);
							myself::Say(myself::MakeFString(42048,"","","","",""));
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(335);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(4) < 3 )
						{
							target.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(target,3719,1);
							if( myself::OwnItemCount(target,3719) >= 30 )
							{
								myself::SoundEffect(target,"ItemSound.quest_middle");
							}
							else
							{
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(357);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(100) < 65 )
						{
							myself::GiveItem1(target,5867,1);
							myself::SoundEffect(target,"ItemSound.quest_itemget");
						}
					}
					break;
				}
			}
		}
		super;
	}

}
