class 1 ssq_event_slow_type : ssq_event_basic_warrior
{
parameter:
	int	DDMagic = 1024257;
	int	IsStrong = 0;

handler:
	EventHandler CREATED()
	{
		myself::AddTimerEx(2002,5000);
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 2002 )
		{
			myself::LookNeighbor(600);
			myself::AddTimerEx(2002,5000);
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage,i0)
	{
		if( myself::InMyTerritory(attacker) == 0 )
		{
			return;
		}
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			myself::AddAttackDesire(attacker,1,( 1 * 100 ));
		}
		if( IsStrong == 1 )
		{
			i0 = 40;
		}
		else
		{
			i0 = 3;
		}
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( myself::IsNullCreature(myself.top_desire_target) == 0 )
			{
				if( gg::Rand(100) < i0 && myself.top_desire_target == attacker )
				{
					if( myself::Skill_GetConsumeMP(DDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic) == 0 )
					{
						myself::AddUseSkillDesire(attacker,DDMagic,0,1,1000000);
					}
				}
			}
		}
		if( 10 > gg::Rand(100) && attacker.is_pc == 1 )
		{
			gg::SendScriptEvent(myself.boss,10012,myself::GetIndexFromCreature(myself.sm));
		}
		super;
	}

	EventHandler CLAN_ATTACKED(attacker,damage)
	{
		if( 3 > gg::Rand(100) && attacker.is_pc == 1 )
		{
			gg::SendScriptEvent(myself.boss,10012,myself::GetIndexFromCreature(myself.sm));
		}
		super;
	}

	EventHandler SEE_CREATURE(creature)
	{
		if( myself.p_state != 3 )
		{
			if( creature.is_pc == 0 && myself::IsInCategory(11,creature.npc_class_id) == 0 )
			{
				return;
			}
			if( myself::GetLifeTime() > 0 && myself::InMyTerritory(myself.sm) )
			{
				myself::AddAttackDesire(creature,1,200);
			}
		}
	}

	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2)
	{
		if( script_event_arg1 == 10007 )
		{
			if( myself.p_state != 3 && myself.p_state != 10 )
			{
				myself::AddMoveToDesire(myself.sm.param1,script_event_arg2,myself::FloatToInt(myself.sm.z),50);
			}
		}
		if( script_event_arg1 == 10013 )
		{
			if( myself::IsNullCreature(myself.top_desire_target) == 0 && myself.top_desire_target.is_pc == 1 )
			{
				myself::BroadcastScriptEvent(10014,myself::GetIndexFromCreature(myself.top_desire_target),800);
				switch(gg::Rand(3))
				{
					case 0:
					{
						myself::Say(myself::MakeFString(1000291,myself.top_desire_target.name,"","","",""));
						break;
					}
					case 1:
					{
						myself::Say(myself::MakeFString(1000398,myself.top_desire_target.name,"","","",""));
						break;
					}
					case 2:
					{
						myself::Say(myself::MakeFString(1000399,myself.top_desire_target.name,"","","",""));
						break;
					}
				}
			}
		}
	}

	EventHandler MY_DYING(c0,c1,party0,i1,i2)
	{
		myself::BroadcastScriptEvent(10008,myself.sm.param3,1500);
		if( myself.i_ai1 == 1 )
		{
			c0 = myself::GetLastAttacker();
			if( c0.is_pc == 0 )
			{
				c0 = c0.master;
			}
			if( myself::IsNullCreature(c0) == 0 )
			{
				c0 = myself::Party_GetLeader(c0);
			}
			party0 = myself::GetPartyFromEventRoom(RoomIndex,SSQPart);
			c1 = myself::GetLeaderOfParty(party0);
			if( myself::IsNullCreature(c0) == 0 && myself::IsNullCreature(c1) == 0 )
			{
				if( c0 == c1 )
				{
					if( myself::HaveMemo(c0,505) )
					{
						i1 = ( 3 + myself::FloatToInt(( ( 3 * 25 ) / 100 )) );
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( myself::DistFromMe(c0) < 40 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
							}
						}
						else if( myself::DistFromMe(c0) < 80 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
						}
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( gg::Rand(2) > 0 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
							}
							else
							{
								i1 = ( i1 - myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
							}
						}
						else if( gg::Rand(2) > 0 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
						}
						else
						{
							i1 = ( i1 - myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
						}
						myself::ShowSysMsgToParty2(party0,2,1381,3,5901,1,i1);
						myself::GiveItem1(c0,5901,i1);
					}
				}
			}
		}
		else if( IsStrong == 0 )
		{
			c0 = myself::GetLastAttacker();
			if( c0.is_pc == 0 )
			{
				c0 = c0.master;
			}
			if( myself::IsNullCreature(c0) == 0 )
			{
				c0 = myself::Party_GetLeader(c0);
			}
			party0 = myself::GetPartyFromEventRoom(RoomIndex,SSQPart);
			c1 = myself::GetLeaderOfParty(party0);
			if( myself::IsNullCreature(c0) == 0 && myself::IsNullCreature(c1) == 0 )
			{
				if( c0 == c1 )
				{
					if( myself::HaveMemo(c0,505) )
					{
						i1 = ( 10 + myself::FloatToInt(( ( 10 * 25 ) / 100 )) );
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( myself::DistFromMe(c0) < 40 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
							}
						}
						else if( myself::DistFromMe(c0) < 80 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
						}
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( gg::Rand(2) > 0 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
							}
							else
							{
								i1 = ( i1 - myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
							}
						}
						else if( gg::Rand(2) > 0 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
						}
						else
						{
							i1 = ( i1 - myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
						}
						myself::ShowSysMsgToParty2(party0,2,1381,3,5901,1,i1);
						myself::GiveItem1(c0,5901,i1);
					}
				}
			}
		}
		else
		{
			c0 = myself::GetLastAttacker();
			if( c0.is_pc == 0 )
			{
				c0 = c0.master;
			}
			if( myself::IsNullCreature(c0) == 0 )
			{
				c0 = myself::Party_GetLeader(c0);
			}
			party0 = myself::GetPartyFromEventRoom(RoomIndex,SSQPart);
			c1 = myself::GetLeaderOfParty(party0);
			if( myself::IsNullCreature(c0) == 0 && myself::IsNullCreature(c1) == 0 )
			{
				if( c0 == c1 )
				{
					if( myself::HaveMemo(c0,505) )
					{
						i1 = ( 15 + myself::FloatToInt(( ( 15 * 25 ) / 100 )) );
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( myself::DistFromMe(c0) < 40 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
							}
						}
						else if( myself::DistFromMe(c0) < 80 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
						}
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( gg::Rand(2) > 0 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
							}
							else
							{
								i1 = ( i1 - myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
							}
						}
						else if( gg::Rand(2) > 0 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
						}
						else
						{
							i1 = ( i1 - myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
						}
						myself::ShowSysMsgToParty2(party0,2,1381,3,5901,1,i1);
						myself::GiveItem1(c0,5901,i1);
					}
				}
			}
		}
	}

}
