class 1 male_lizardman : warrior_passive
{
handler:
	EventHandler MY_DYING(always_list,code_info,i4,i9,last_attacker,lparty,member,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		if( myself::HaveMemo(target,39) == 1 && myself::GetMemoState(target,39) == ( ( 2 * 10 ) + 1 ) )
		{
			random1_list::SetInfo(0,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,39) == 1 && myself::GetMemoState(target,39) == ( ( 2 * 10 ) + 1 ) )
				{
					random1_list::SetInfo(0,target);
				}
			}
		}
		target = last_attacker;
		if( myself::HaveMemo(target,44) == 1 && myself::GetMemoState(target,44) == ( ( 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,44) == 1 && myself::GetMemoState(target,44) == ( ( 2 * 10 ) + 1 ) )
				{
					random1_list::SetInfo(1,target);
				}
			}
		}
		target = last_attacker;
		if( myself::HaveMemo(target,118) == 1 && myself::GetMemoState(target,118) == 1 )
		{
			random1_list::SetInfo(2,target);
		}
		if( myself::HaveMemo(target,63) == 1 && myself::GetMemoState(target,63) == 11 )
		{
			always_list::SetInfo(3,target);
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 3 )
			{
				myself::SetCurrentQuestID(63);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					if( myself::HaveMemo(myself.c_quest0,63) == 1 && myself::OwnItemCount(myself.c_quest0,9770) == 1 && myself.i_quest0 == 1 )
					{
						if( gg::Rand(100) < 20 )
						{
							myself::CreateOnePrivate(1027337,"ol_mahum_officer_tak",0,1);
							myself::SoundEffect(myself.c_quest0,"Itemsound.quest_before_battle");
						}
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(39);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i4 = gg::Rand(1000);
						if( i4 < 500 )
						{
							if( ( myself::OwnItemCount(target,7178) + 1 ) >= 100 )
							{
								if( myself::OwnItemCount(target,7178) < 100 )
								{
									myself::GiveItem1(target,7178,( 100 - myself::OwnItemCount(target,7178) ));
									myself::SoundEffect(target,"ItemSound.quest_middle");
								}
								if( myself::OwnItemCount(target,7179) >= 100 )
								{
									myself::SetFlagJournal(target,39,3);
									myself::SetMemoState(target,39,( ( 2 * 10 ) + 2 ));
								}
							}
							else
							{
								myself::GiveItem1(target,7178,1);
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(44);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i4 = gg::Rand(1000);
						if( i4 < 1000 )
						{
							if( ( myself::OwnItemCount(target,7552) + 1 ) >= 30 )
							{
								if( myself::OwnItemCount(target,7552) < 30 )
								{
									myself::GiveItem1(target,7552,( 30 - myself::OwnItemCount(target,7552) ));
									myself::SoundEffect(target,"ItemSound.quest_middle");
									myself::SetFlagJournal(target,44,3);
								}
								myself::SetMemoState(target,44,( ( 2 * 10 ) + 2 ));
							}
							else
							{
								myself::GiveItem1(target,7552,1);
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(118);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i4 = gg::Rand(100);
						if( i4 < 40 )
						{
							target.quest_last_reward_time = myself::GetCurrentTick();
							if( myself::OwnItemCount(target,8062) >= 9 )
							{
								myself::GiveItem1(target,8062,1);
								myself::SetMemoState(target,118,2);
								myself::SoundEffect(target,"ItemSound.quest_middle");
								myself::SetFlagJournal(target,118,2);
							}
							else
							{
								myself::GiveItem1(target,8062,1);
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
						}
					}
					break;
				}
			}
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage)
	{
		myself::SetCurrentQuestID(63);
		if( myself::HaveMemo(attacker,63) )
		{
			switch(myself.i_quest0)
			{
				case 0:
				{
					myself.i_quest0 = 1;
					if( attacker.master )
					{
						myself.c_quest0 = attacker.master;
					}
					else
					{
						myself.c_quest0 = attacker;
					}
					break;
				}
				case 1:
				{
					if( attacker.master )
					{
						if( myself.c_quest0 != attacker.master )
						{
							myself.i_quest0 = 2;
						}
					}
					else if( myself.c_quest0 != attacker )
					{
						myself.i_quest0 = 2;
					}
					break;
				}
				case 2:
				{
					break;
				}
			}
		}
		super;
	}

}
