class 1 elder_turka_gudege : warrior_aggressive_casting_ddmagic
{
handler:
	EventHandler MY_DYING(i4,i9,lparty,last_attacker,target)
	{
		target = last_attacker;
		if( gg::IsNull(lparty) == 0 )
		{
			for(i9 = 0; i9 < lparty.member_count; i9 = ( i9 + 1 ))
			{
				target = myself::GetMemberOfParty(lparty,i9);
				if( myself::HaveMemo(target,645) == 1 && myself::GetMemoState(target,645) == 1 )
				{
					myself::SetCurrentQuestID(645);
					if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
					{
						i4 = gg::Rand(100);
						if( i4 < 70 )
						{
							if( myself::OwnItemCount(target,8089) < 179 )
							{
								myself::GiveItem1(target,8089,1);
								myself::SoundEffect(target,"ItemSound.quest_itemget");
							}
							else
							{
								myself::GiveItem1(target,8089,1);
								myself::SoundEffect(target,"ItemSound.quest_itemget");
								myself::SetFlagJournal(target,645,2);
								myself::SetMemoState(target,645,2);
							}
						}
					}
				}
			}
		}
		else if( myself::HaveMemo(target,645) == 1 && myself::GetMemoState(target,645) == 1 )
		{
			myself::SetCurrentQuestID(645);
			if( gg::IsNull(target) == 0 && myself::DistFromMe(target) <= 1500 )
			{
				i4 = gg::Rand(100);
				if( i4 < 70 )
				{
					if( myself::OwnItemCount(target,8089) < 179 )
					{
						myself::GiveItem1(target,8089,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
					}
					else
					{
						myself::GiveItem1(target,8089,1);
						myself::SoundEffect(target,"ItemSound.quest_itemget");
						myself::SetFlagJournal(target,645,2);
						myself::SetMemoState(target,645,2);
					}
				}
			}
		}
		super;
	}

}
