class 1 hanged_man_ripper : warrior_aggressive_casting_hold_magic
{
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);
		target = last_attacker;
		always_list::SetInfo(1,target);
		target = last_attacker;
		always_list::SetInfo(2,target);
		while( gg::IsNull(code_info = always_list::Next()) == 0 )
		{
			switch(code_info.code)
			{
				case 0:
				{
					myself::SetCurrentQuestID(212);
					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,212) && myself::GetMemoState(c1,212) == 6 )
						{
							if( gg::Rand(100) < ( ( c1.flag - 3 ) * 33 ) )
							{
								myself::CreateOnePrivateEx(1030656,"spirit_of_sir_talianus",0,0,myself::FloatToInt(myself.sm.x),myself::FloatToInt(myself.sm.y),myself::FloatToInt(myself.sm.z),0,0,0,0);
								myself::SoundEffect(c1,"ItemSound.quest_middle");
								c1.flag = 0;
								myself::SetFlagJournal(c1,212,8);
							}
							else
							{
								c1.flag = ( c1.flag + 1 );
							}
						}
					}
					break;
				}
				case 1:
				{
					myself::SetCurrentQuestID(219);
					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,219) && myself::OwnItemCount(c1,3174) && myself::OwnItemCount(c1,3175) == 0 )
						{
							myself::GiveItem1(c1,3175,1);
							myself::DeleteItem1(c1,3174,1);
							myself::SoundEffect(c1,"Itemsound.quest_middle");
							myself::SetFlagJournal(c1,219,3);
						}
					}
					break;
				}
				case 2:
				{
					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,2802) < 4 && myself::OwnItemCount(c1,2804) == 0 )
						{
							if( myself::OwnItemCount(c1,2802) < 3 )
							{
								if( gg::Rand(100) < 50 )
								{
									c1.quest_last_reward_time = myself::GetCurrentTick();
									myself::GiveItem1(c1,2802,1);
									myself::SoundEffect(c1,"ItemSound.quest_middle");
								}
							}
							else if( gg::Rand(100) < 50 )
							{
								myself::DeleteItem1(c1,2802,myself::OwnItemCount(c1,2802));
								myself::GiveItem1(c1,2804,1);
								myself::SoundEffect(c1,"ItemSound.quest_middle");
								if( myself::OwnItemCount(c1,2803) >= 1 )
								{
									myself::SetFlagJournal(c1,225,15);
								}
							}
						}
					}
					break;
				}
			}
		}
		code_info = random1_list::RandomSelectOne();
		if( gg::IsNull(code_info) == 0 )
		{
		}
		super;
	}

}
