class 1 catherok : warrior_aggressive_casting_splash
{
handler:
	EventHandler ATTACKED(attacker,c0,c1,damage,i0,i1,i2,i3,i_quest0)
	{
		myself::SetCurrentQuestID(367);
		if( attacker.master )
		{
			attacker = attacker.master;
		}
		if( myself::HaveMemo(attacker,367) && myself.i_quest0 != 367 )
		{
			if( myself::Skill_GetConsumeMP(1042436) < myself.sm.mp && myself::Skill_GetConsumeHP(1042436) < myself.sm.hp && myself::Skill_InReuseDelay(1042436) == 0 )
			{
				myself::AddUseSkillDesire(attacker,1042436,0,0,1000000);
			}
			myself.i_quest0 = 367;
			i1 = myself::Party_GetCount(attacker);
			if( i1 != 0 )
			{
				for(i0 = 0; i0 < i1; i0 = ( i0 + 1 ))
				{
					c0 = myself::Party_GetCreature(attacker,i0);
					i2 = gg::Rand(1000);
					if( i2 > i3 )
					{
						i3 = i2;
						c1 = c0;
					}
				}
			}
			else
			{
				c1 = attacker;
			}
			if( 1 && myself::HaveMemo(c1,367) && myself.sm.flag != 367 && myself::OwnItemCount(c1,5879) == 0 && myself::IsNullCreature(c1) == 0 )
			{
				i0 = gg::Rand(37);
				if( i0 == 0 )
				{
					if( ( myself::GetCurrentTick() - c1.quest_last_reward_time ) > 1 )
					{
						c1.quest_last_reward_time = myself::GetCurrentTick();
						if( myself::OwnItemCount(c1,5875) > 0 )
						{
							myself::GiveItem1(c1,5876,1);
							myself::DeleteItem1(c1,5875,myself::OwnItemCount(c1,5875));
							myself::SoundEffect(c1,"ItemSound.quest_middle");
						}
						else if( myself::OwnItemCount(c1,5876) > 0 )
						{
							myself::GiveItem1(c1,5877,1);
							myself::DeleteItem1(c1,5876,myself::OwnItemCount(c1,5876));
							myself::SoundEffect(c1,"ItemSound.quest_middle");
						}
						else if( myself::OwnItemCount(c1,5877) > 0 )
						{
							myself::GiveItem1(c1,5878,1);
							myself::DeleteItem1(c1,5877,myself::OwnItemCount(c1,5877));
							myself::SoundEffect(c1,"ItemSound.quest_middle");
						}
						else if( myself::OwnItemCount(c1,5878) > 0 )
						{
							myself::GiveItem1(c1,5879,1);
							myself::DeleteItem1(c1,5878,myself::OwnItemCount(c1,5878));
							myself::SetJournal(c1,367,2);
							myself::SoundEffect(c1,"ItemSound.quest_middle");
						}
					}
				}
				else if( i0 == 1 && myself::OwnItemCount(c1,5880) == 0 )
				{
					myself::GiveItem1(c1,5880,1);
					myself::DeleteItem1(c1,5875,myself::OwnItemCount(c1,5875));
					myself::DeleteItem1(c1,5876,myself::OwnItemCount(c1,5876));
					myself::DeleteItem1(c1,5877,myself::OwnItemCount(c1,5877));
					myself::DeleteItem1(c1,5878,myself::OwnItemCount(c1,5878));
					myself::SoundEffect(c1,"ItemSound.quest_middle");
				}
			}
		}
		super;
	}

}
