class 1 goblin_brigand_leader : warrior_aggressive
{
handler:
	EventHandler MY_DYING(always_list,c1,code_info,i0,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;
		always_list::SetInfo(1,target);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(108);
					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,108) == 1 && myself::OwnItemCount(c1,1563) )
						{
							if( gg::Rand(10) < 8 )
							{
								if( ( myself::OwnItemCount(c1,1564) + myself::OwnItemCount(c1,1565) ) >= 19 )
								{
									if( myself::OwnItemCount(c1,1564) < 10 )
									{
										myself::GiveItem1(c1,1564,1);
										myself::SetFlagJournal(c1,108,6);
										myself::SoundEffect(c1,"ItemSound.quest_middle");
									}
								}
								else if( myself::OwnItemCount(c1,1564) < 10 )
								{
									myself::GiveItem1(c1,1564,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
							}
							if( gg::Rand(10) < 8 )
							{
								if( ( myself::OwnItemCount(c1,1564) + myself::OwnItemCount(c1,1565) ) >= 19 )
								{
									if( myself::OwnItemCount(c1,1565) < 10 )
									{
										myself::GiveItem1(c1,1565,1);
										myself::SetFlagJournal(c1,108,6);
										myself::SoundEffect(c1,"ItemSound.quest_middle");
									}
								}
								else if( ( myself::OwnItemCount(c1,1564) + myself::OwnItemCount(c1,1565) ) < 20 )
								{
									if( myself::OwnItemCount(c1,1565) < 10 )
									{
										myself::GiveItem1(c1,1565,1);
										myself::SoundEffect(c1,"ItemSound.quest_itemget");
									}
								}
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(292);
					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,292) )
						{
							i0 = gg::Rand(10);
							if( i0 > 5 )
							{
								myself::GiveItem1(c1,1484,1);
								myself::SoundEffect(c1,"ItemSound.quest_itemget");
							}
							else if( i0 > 4 )
							{
								if( myself::OwnItemCount(c1,1487) < 1 && myself::OwnItemCount(c1,1486) < 3 )
								{
									myself::GiveItem1(c1,1486,1);
									myself::SoundEffect(c1,"ItemSound.quest_itemget");
								}
								else if( myself::OwnItemCount(c1,1487) < 1 && myself::OwnItemCount(c1,1486) == 3 )
								{
									myself::GiveItem1(c1,1487,1);
									myself::SetFlagJournal(c1,292,2);
									myself::DeleteItem1(c1,1486,myself::OwnItemCount(c1,1486));
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		super;
	}

}
