class 1 doom_scout : warrior_aggressive_casting_enchant_clan
{
handler:
	EventHandler MY_DYING(target,i0,i1,i2,i3,c0,c1,c2,last_attacker,random1_list,always_list,code_info)
	{
		always_list = gg::AllocCodeInfoList();
		random1_list = gg::AllocCodeInfoList();
		target = last_attacker;
		if( 1 )
		{
			always_list::SetInfo(0,target);
		}
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			if( code_info.code == 0 )
			{
				myself::SetCurrentQuestID(663);
				target = code_info::RandomSelectOne();
				if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
				{
					c1 = myself::GetLastAttacker();
					if( c1.master )
					{
						c1 = c1.master;
					}
					i1 = myself::Party_GetCount(c1);
					i2 = 0;
					if( i1 == 0 )
					{
						if( myself::HaveMemo(c1,663) )
						{
							c2 = c1;
						}
					}
					else
					{
						for(i0 = 0; i0 < i1; i0 = ( i0 + 1 ))
						{
							c0 = myself::Party_GetCreature(c1,i0);
							if( myself::HaveMemo(c0,663) )
							{
								i3 = gg::Rand(1000);
								if( i2 <= i3 )
								{
									i2 = i3;
									c2 = c0;
								}
							}
						}
					}
					if( myself::IsNullCreature(c2) == 0 && myself::DistFromMe(c2) <= 1500 )
					{
						c2.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(c2,8766,1);
						myself::SoundEffect(c2,"ItemSound.quest_itemget");
					}
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		c1 = myself::GetLastAttacker();
		if( myself::HaveMemo(c1,662) )
		{
			if( gg::Rand(100) > 64 )
			{
				c1.quest_last_reward_time = myself::GetCurrentTick();
				myself::GiveItem1(c1,8765,1);
				myself::SoundEffect(c1,"ItemSound.quest_itemget");
			}
		}
		super;
	}

}
