class 1 ghost_of_umul : warrior_aggressive_physicalspecial
{
handler:
	EventHandler MY_DYING(always_list,code_info,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);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(22);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					npc0 = gg::GetNPCFromID(myself.sm.param3);
					if( gg::IsNull(npc0) == 0 )
					{
						npc0.i_quest0 = 0;
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		super;
	}

	EventHandler ATTACKED(attacker,c1)
	{
		myself::SetCurrentQuestID(22);
		c1 = attacker;
		if( myself::HaveMemo(c1,22) == 1 && myself::GetMemoState(c1,22) == 10 && myself::OwnItemCount(c1,7144) >= 1 )
		{
			myself::SetMemoState(c1,22,11);
		}
		else if( myself::HaveMemo(c1,22) == 1 && myself::GetMemoState(c1,22) == 11 && myself::OwnItemCount(c1,7144) >= 1 )
		{
			if( myself.i_quest0 == 1 )
			{
				myself::DeleteItem1(c1,7144,myself::OwnItemCount(c1,7144));
				myself::GiveItem1(c1,7145,1);
				myself::SoundEffect(c1,"ItemSound.quest_itemget");
				myself::SetFlagJournal(c1,22,11);
			}
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(c0,npc0,timer_id)
	{
		myself::SetCurrentQuestID(22);
		if( timer_id == 2203 )
		{
			myself.i_quest0 = 1;
		}
		else if( timer_id == 2204 )
		{
			npc0 = gg::GetNPCFromID(myself.sm.param3);
			if( gg::IsNull(npc0) == 0 )
			{
				npc0.i_quest0 = 0;
			}
			myself::Despawn();
		}
		super;
	}

	EventHandler CREATED(c0,i0)
	{
		myself::SetCurrentQuestID(22);
		myself::AddTimerEx(2203,( 1000 * 90 ));
		myself::AddTimerEx(2204,( 1000 * 120 ));
		i0 = myself.sm.param1;
		if( i0 > 0 )
		{
			c0 = myself::GetCreatureFromIndex(i0);
			if( c0 )
			{
				myself::AddAttackDesire(c0,1,2000);
			}
		}
		super;
	}

}
