class 1 ssq_event_party_private : ssq_event_basic_warrior
{
parameter:

handler:
	EventHandler NO_DESIRE()
	{
		if( myself.boss.alive )
		{
			myself::AddFollowDesire(myself.boss,5);
		}
		else
		{
			myself::AddMoveAroundDesire(5,5);
		}
	}

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

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 2002 )
		{
			if( myself.boss.alive == 0 )
			{
				if( myself.p_state != 3 )
				{
					myself::Despawn();
				}
				else if( myself::IsNullCreature(myself.top_desire_target) == 0 )
				{
					if( myself::InMyTerritory(myself.top_desire_target) == 0 )
					{
						myself::RemoveAttackDesire(myself.top_desire_target.id);
					}
				}
				myself::AddTimerEx(2002,5000);
			}
			else
			{
				myself::AddTimerEx(2002,5000);
			}
		}
	}

	EventHandler PARTY_DIED(private)
	{
	}

	EventHandler PARTY_ATTACKED(attacker,private,damage,f0)
	{
		if( myself::InMyTerritory(attacker) == 0 )
		{
			return;
		}
		if( myself::DistFromMe(private) < 300 )
		{
			if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
			{
				if( damage == 0 )
				{
					damage = 1;
				}
				myself::AddAttackDesire(attacker,1,( ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) * 100 ));
			}
		}
	}

	EventHandler ATTACKED(attacker,damage,f0)
	{
		if( myself::InMyTerritory(attacker) == 0 )
		{
			return;
		}
		if( myself.boss.alive == 0 )
		{
			if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
			{
				if( damage == 0 )
				{
					damage = 1;
				}
				myself::AddAttackDesire(attacker,1,( ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) * 100 ));
			}
		}
		super;
	}

	EventHandler SEE_SPELL(speller,skill_name_id,target,f0)
	{
		if( myself.boss.alive == 0 )
		{
			if( myself::Skill_GetEffectPoint(skill_name_id) > 0 )
			{
				if( myself.p_state == 3 && myself.top_desire_target == target )
				{
					myself::AddAttackDesire(speller,1,( ( ( myself::Skill_GetEffectPoint(skill_name_id) / myself.sm.max_hp ) / 0.050000 ) * 150 ));
				}
			}
			if( myself::GetPathfindFailCount() > 10 && speller == myself.top_desire_target && myself::FloatToInt(myself.sm.hp) != myself::FloatToInt(myself.sm.max_hp) )
			{
				myself::InstantTeleport(myself.sm,myself::FloatToInt(speller.x),myself::FloatToInt(speller.y),myself::FloatToInt(speller.z));
			}
		}
		super;
	}

	EventHandler MY_DYING(c0,c1,party0,i1,i2)
	{
		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
		{
			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 = ( 8 + myself::FloatToInt(( ( 8 * 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);
					}
				}
			}
		}
	}

}
