class 1 road_scavenger : warrior_passive
{
handler:
	EventHandler MY_DYING(always_list,c1,code_info,i9,last_attacker,lparty,member,random1_list,target)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		always_list::SetInfo(0,target);
		always_list::SetInfo(1,target);
		always_list::SetInfo(2,target);
		always_list::SetInfo(3,target);
		always_list::SetInfo(6,target);
		if( myself::HaveMemo(target,420) == 1 && myself::OwnItemCount(target,3826) == 1 && myself::OwnItemCount(target,3827) < 20 )
		{
			random1_list::SetInfo(4,target);
		}
		target = last_attacker;
		if( myself::HaveMemo(target,426) == 1 )
		{
			random1_list::SetInfo(5,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,426) == 1 )
				{
					random1_list::SetInfo(5,target);
				}
			}
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(224);
					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,224) && myself::GetMemoState(c1,224) == 10 && myself::OwnItemCount(c1,3302) == 0 )
						{
							if( gg::Rand(10) == 1 )
							{
								if( myself::OwnItemCount(c1,3304) && myself::OwnItemCount(c1,3305) && myself::OwnItemCount(c1,3303) )
								{
									myself::GiveItem1(c1,3302,1);
									myself::SetMemoState(c1,224,11);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
									myself::SetFlagJournal(c1,224,11);
								}
								else
								{
									myself::GiveItem1(c1,3302,1);
									myself::SoundEffect(c1,"Itemsound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(224);
					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,224) && myself::GetMemoState(c1,224) == 10 && myself::OwnItemCount(c1,3302) == 0 )
						{
							if( gg::Rand(10) == 1 )
							{
								if( myself::OwnItemCount(c1,3304) && myself::OwnItemCount(c1,3305) && myself::OwnItemCount(c1,3303) )
								{
									myself::GiveItem1(c1,3302,1);
									myself::SetMemoState(c1,224,11);
									myself::SoundEffect(c1,"Itemsound.quest_middle");
								}
								else
								{
									myself::GiveItem1(c1,3302,1);
									myself::SoundEffect(c1,"Itemsound.quest_itemget");
								}
							}
						}
					}
					break;
				}
				case 2:
				{
					myself::SetCurrentQuestID(223);
					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,223) && myself::OwnItemCount(c1,3284) && myself::OwnItemCount(c1,3291) < 100 )
						{
							if( myself::OwnItemCount(c1,3291) == 99 )
							{
								myself::GiveItem1(c1,3291,1);
								myself::SoundEffect(c1,"Itemsound.quest_middle");
								myself::SetFlagJournal(c1,223,11);
							}
							else
							{
								myself::GiveItem1(c1,3291,1);
								myself::SoundEffect(c1,"Itemsound.quest_itemget");
							}
						}
					}
					break;
				}
				case 3:
				{
					myself::SetCurrentQuestID(225);
					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,225) == 1 && myself::OwnItemCount(c1,2800) == 1 && myself::OwnItemCount(c1,2801) < 4 && myself::OwnItemCount(c1,2803) == 0 )
						{
							if( myself::OwnItemCount(c1,2801) < 3 )
							{
								if( gg::Rand(100) < 50 )
								{
									c1.quest_last_reward_time = myself::GetCurrentTick();
									myself::GiveItem1(c1,2801,1);
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
							}
							else if( gg::Rand(100) < 50 )
							{
								myself::DeleteItem1(c1,2801,myself::OwnItemCount(c1,2801));
								myself::GiveItem1(c1,2803,1);
								myself::SoundEffect(c1,"ItemSound.quest_middle");
								if( myself::OwnItemCount(c1,2804) >= 1 )
								{
									myself::SetFlagJournal(c1,225,15);
								}
							}
						}
					}
					break;
				}
				case 6:
				{
					myself::SetCurrentQuestID(64);
					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,64) == 1 && myself::GetMemoState(c1,64) == 5 && myself::OwnItemCount(c1,9755) == 0 )
						{
							if( gg::Rand(5) == 1 )
							{
								myself::GiveItem1(c1,9755,1);
								myself::SetMemoState(c1,64,6);
								myself::SoundEffect(c1,"Itemsound.quest_middle");
								myself::SetFlagJournal(c1,64,6);
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
			switch(code_info.code)
			{
				case 4:
				{
					myself::SetCurrentQuestID(420);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(100) < 50 )
						{
							target.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(target,3827,1);
							if( myself::OwnItemCount(target,3827) >= 20 )
							{
								myself::SoundEffect(target,"ItemSound.quest_middle");
							}
							else
							{
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
							myself::Say(myself::MakeFString(42046,_blank,_blank,_blank,_blank,_blank));
						}
					}
					break;
				}
				case 5:
				{
					myself::SetCurrentQuestID(426);
					target = code_info::RandomSelectOne();
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						if( gg::Rand(100) < 30 )
						{
							myself::GiveItem1(target,7586,1);
							myself::SoundEffect(target,"ItemSound.quest_itemget");
						}
					}
					break;
				}
			}
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage)
	{
		myself::SetCurrentQuestID(223);
		switch(myself.i_quest0)
		{
			case 0:
			{
				myself.c_quest0 = attacker;
				if( myself::HaveMemo(myself.c_quest0,223) && myself::OwnItemCount(myself.c_quest0,3284) > 0 && myself::OwnItemCount(myself.c_quest0,3291) < 100 )
				{
					if( gg::Rand(2) == 1 )
					{
						if( gg::Rand(10) < 7 )
						{
							myself::CreateOnePrivate(1027089,"road_collector",0,1);
						}
						else
						{
							myself::CreateOnePrivate(1027089,"road_collector",0,1);
							myself::CreateOnePrivate(1027089,"road_collector",0,1);
						}
					}
				}
				myself.i_quest0 = 1;
				break;
			}
			case 1:
			{
				myself.i_quest0 = 2;
				break;
			}
			case 2:
			{
				break;
			}
		}
		super;
	}

}
