class 1 icicle_king_umpaloopa : raid_boss_type5
{
handler:
	EventHandler MY_DYING(always_list,av_quest0,c0,c1,c2,c3,code_info,i0,i1,i2,i3,i4,i9,last_attacker,lparty,member,npc0,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		always_list::SetInfo(0,target);
		if( gg::IsNull(lparty) == 0 )
		{
			for(i9 = 0; i9 < lparty.member_count; i9 = ( i9 + 1 ))
			{
				target = myself::GetMemberOfParty(lparty,i9);
				always_list::SetInfo(0,target);
			}
		}
		target = last_attacker;
		if( myself::HaveMemo(target,625) == 1 && myself::GetMemoState(target,625) >= ( ( 2 * 10 ) - 9 ) && myself::GetMemoState(target,625) <= ( ( 2 * 10 ) + 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,625) == 1 && myself::GetMemoState(target,625) >= ( ( 2 * 10 ) - 9 ) && myself::GetMemoState(target,625) <= ( ( 2 * 10 ) + 1 ) )
				{
					random1_list::SetInfo(1,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(625);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					npc0 = gg::GetNPCFromID(myself.sm.param1);
					if( gg::IsNull(npc0) == 0 )
					{
						npc0.av_quest0::Exchange(0);
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			if( code_info.code == 1 )
			{
				myself::SetCurrentQuestID(625);
				while( gg::IsNull(target = code_info::Next()) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					myself::SetCurrentQuestID(625);
					if( myself::GetMemoState(target,625) >= ( ( 2 * 10 ) - 9 ) && myself::GetMemoState(target,625) < ( ( 2 * 10 ) + 1 ) )
					{
						myself::DeleteItem1(target,7209,1);
						myself::DeleteItem1(target,0,0);
						myself::DeleteItem1(target,0,0);
					}
					if( ( myself::OwnItemCount(target,7210) + 1 ) >= 1 )
					{
						if( myself::OwnItemCount(target,7210) < 1 )
						{
							myself::GiveItem1(target,7210,( 1 - myself::OwnItemCount(target,7210) ));
							myself::SoundEffect(target,"ItemSound.quest_middle");
						}
					}
					else
					{
						myself::GiveItem1(target,7210,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
					}
					npc0 = gg::GetNPCFromID(myself.sm.param1);
					if( gg::IsNull(npc0) == 0 )
					{
						npc0.av_quest0::Exchange(0);
					}
					myself::SetFlagJournal(target,625,3);
					myself::SetMemoState(target,625,( ( 2 * 10 ) + 2 ));
				}
			}
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(c0,i0,npc0,talker,timer_id)
	{
		myself::SetCurrentQuestID(625);
		if( timer_id == ( ( 625 * 100 ) + 1 ) )
		{
			myself::Say(myself::MakeFString(62504,"","","","",""));
			npc0 = gg::GetNPCFromID(myself.sm.param1);
			if( gg::IsNull(npc0) == 0 )
			{
				npc0.av_quest0::Exchange(0);
			}
			myself::Despawn();
		}
		super;
	}

	EventHandler CREATED(i0,i_quest0)
	{
		myself::SetCurrentQuestID(625);
		myself::AddTimerEx(( ( 625 * 100 ) + 1 ),( 1000 * 1200 ));
		myself::Say(myself::MakeFString(62503,"","","","",""));
		super;
	}

}
