class 1 warrior_pet_for_pc : default_npc
{
parameter:
	int	Buff1 = 1031683;
	int	Buff2 = 1031683;
	int	Buff3 = 1031683;
	int	Buff4 = 1031683;
	int	Buff5 = 1031683;
	int	DeBuff1 = 1033473;
	int	DeBuff2 = 1033473;
	int	Heal = 1030401;
	int	FeedID = 57;
	int	ConsumeFeedNum = 1;
	int	TakeSocial = 0;

handler:
	EventHandler CREATED(i0)
	{
		if( myself.sm.param2 == 2188 )
		{
			myself.i_ai3 = 6643;
		}
		else
		{
			myself.i_ai3 = 6644;
		}
		myself.c_ai0 = myself::GetCreatureFromIndex(myself.sm.param1);
		if( gg::Rand(100) < 5 )
		{
			i0 = gg::Rand(( ( 2028 - 2024 ) + 1 ));
			i0 = ( i0 + 2024 );
			myself::Say(myself::MakeFString(i0,myself.c_ai0.name,"","","",""));
		}
		myself::AddTimerEx(2001,5000);
		if( myself::HaveMemo(myself.c_ai0,20) )
		{
			if( gg::Rand(100) <= 5 && myself::OwnItemCount(myself.c_ai0,7185) == 0 )
			{
				myself::GiveItem1(myself.c_ai0,7185,1);
				myself::SetFlagJournal(myself.c_ai0,20,2);
			}
		}
		myself.i_ai1 = myself::GetCurrentTick();
		myself::BroadcastScriptEventEx(10022,myself::GetIndexFromCreature(myself.c_ai0),myself.i_ai1,1500);
		myself::AddTimerEx(2002,15000);
		myself::AddTimerEx(2003,( 60 * 1000 ));
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0,i1)
	{
		if( timer_id == 2001 )
		{
			i0 = 5;
			if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff1)) <= 0 )
			{
				i0 = ( i0 - 1 );
			}
			if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff2)) <= 0 )
			{
				i0 = ( i0 - 1 );
			}
			if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff3)) <= 0 )
			{
				i0 = ( i0 - 1 );
			}
			if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff4)) <= 0 )
			{
				i0 = ( i0 - 1 );
			}
			if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff5)) <= 0 )
			{
				i0 = ( i0 - 1 );
			}
			if( i0 < 3 )
			{
				i1 = gg::Rand(100);
				if( i1 < 20 )
				{
					if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff1)) <= 0 )
					{
						if( myself::Skill_GetConsumeMP(Buff1) < myself.sm.mp && myself::Skill_GetConsumeHP(Buff1) < myself.sm.hp && myself::Skill_InReuseDelay(Buff1) == 0 )
						{
							myself::AddUseSkillDesire(myself.c_ai0,Buff1,1,1,1000000);
						}
					}
				}
				else if( i1 < 40 )
				{
					if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff2)) <= 0 )
					{
						if( myself::Skill_GetConsumeMP(Buff2) < myself.sm.mp && myself::Skill_GetConsumeHP(Buff2) < myself.sm.hp && myself::Skill_InReuseDelay(Buff2) == 0 )
						{
							myself::AddUseSkillDesire(myself.c_ai0,Buff2,1,1,1000000);
						}
					}
				}
				else if( i1 < 60 )
				{
					if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff3)) <= 0 )
					{
						if( myself::Skill_GetConsumeMP(Buff3) < myself.sm.mp && myself::Skill_GetConsumeHP(Buff3) < myself.sm.hp && myself::Skill_InReuseDelay(Buff3) == 0 )
						{
							myself::AddUseSkillDesire(myself.c_ai0,Buff3,1,1,1000000);
						}
					}
				}
				else if( i1 < 80 )
				{
					if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff4)) <= 0 )
					{
						if( myself::Skill_GetConsumeMP(Buff4) < myself.sm.mp && myself::Skill_GetConsumeHP(Buff4) < myself.sm.hp && myself::Skill_InReuseDelay(Buff4) == 0 )
						{
							myself::AddUseSkillDesire(myself.c_ai0,Buff4,1,1,1000000);
						}
					}
				}
				else if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(Buff5)) <= 0 )
				{
					if( myself::Skill_GetConsumeMP(Buff5) < myself.sm.mp && myself::Skill_GetConsumeHP(Buff5) < myself.sm.hp && myself::Skill_InReuseDelay(Buff5) == 0 )
					{
						myself::AddUseSkillDesire(myself.c_ai0,Buff5,1,1,1000000);
					}
				}
			}
			myself::BroadcastScriptEvent(10017,myself::GetIndexFromCreature(myself.sm),700);
			if( myself::DistFromMe(myself.c_ai0) > 100 && myself.p_state != 11 )
			{
				myself::AddMoveToDesire(myself::FloatToInt(( ( myself.c_ai0.x - 50 ) + ( gg::Rand(10) * 10 ) )),myself::FloatToInt(( ( myself.c_ai0.y - 50 ) + ( gg::Rand(10) * 10 ) )),myself::FloatToInt(myself.c_ai0.z),10);
			}
			if( myself::DistFromMe(myself.c_ai0) > 2000 )
			{
				myself::Despawn();
			}
			myself::AddTimerEx(2001,5000);
		}
		if( timer_id == 2002 )
		{
			myself::BroadcastScriptEventEx(10022,myself::GetIndexFromCreature(myself.c_ai0),myself.i_ai1,500);
			myself::AddTimerEx(2002,15000);
		}
		if( timer_id == 2003 )
		{
			if( myself::OwnItemCount(myself.c_ai0,myself.i_ai3) >= ConsumeFeedNum && myself.c_ai0.alive == 1 )
			{
				myself::DeleteItem1(myself.c_ai0,myself.i_ai3,ConsumeFeedNum);
				if( TakeSocial != 0 )
				{
					myself::AddEffectActionDesire(myself.sm,1,( ( TakeSocial * 1000 ) / 30 ),200);
				}
				i0 = gg::Rand(( ( 2038 - 2029 ) + 1 ));
				i0 = ( i0 + 2029 );
				myself::Say(myself::MakeFString(i0,"","","","",""));
			}
			else
			{
				myself::Despawn();
			}
			myself::AddTimerEx(2003,( 60 * 1000 ));
		}
	}

	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,i0)
	{
		if( 10022 == script_event_arg1 )
		{
			i0 = myself::GetIndexFromCreature(myself.c_ai0);
			if( i0 == script_event_arg2 )
			{
				if( myself.i_ai1 < script_event_arg3 )
				{
					myself::Despawn();
				}
			}
		}
	}

	EventHandler CLAN_ATTACKED(attacker,victim,i0)
	{
		i0 = 2;
		if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(DeBuff1)) <= 0 )
		{
			i0 = ( i0 - 1 );
		}
		if( myself::GetAbnormalLevel(myself.c_ai0,myself::Skill_GetAbnormalType(DeBuff2)) <= 0 )
		{
			i0 = ( i0 - 1 );
		}
		if( i0 < 1 && myself::FloatToInt(( ( victim.hp / victim.max_hp ) * 100 )) >= 80 )
		{
			if( gg::Rand(100) < 33 )
			{
				if( myself::GetAbnormalLevel(victim,myself::Skill_GetAbnormalType(DeBuff1)) <= 0 )
				{
					if( myself::Skill_GetConsumeMP(DeBuff1) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff1) < myself.sm.hp && myself::Skill_InReuseDelay(DeBuff1) == 0 )
					{
						myself::AddUseSkillDesire(victim,DeBuff1,0,1,1000000);
					}
				}
			}
			if( gg::Rand(100) < 33 )
			{
				if( myself::GetAbnormalLevel(victim,myself::Skill_GetAbnormalType(DeBuff2)) <= 0 )
				{
					if( myself::Skill_GetConsumeMP(DeBuff2) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff2) < myself.sm.hp && myself::Skill_InReuseDelay(DeBuff2) == 0 )
					{
						myself::AddUseSkillDesire(victim,DeBuff2,0,1,1000000);
					}
				}
			}
		}
		i0 = myself::FloatToInt(( ( victim.hp / victim.max_hp ) * 100 ));
		if( i0 < 25 )
		{
			if( gg::Rand(100) < 40 )
			{
				if( myself::Skill_GetConsumeMP(Heal) < myself.sm.mp && myself::Skill_GetConsumeHP(Heal) < myself.sm.hp && myself::Skill_InReuseDelay(Heal) == 0 )
				{
					myself::AddUseSkillDesire(myself.c_ai0,Heal,1,1,1000000);
				}
			}
		}
		else if( i0 < 50 )
		{
			if( gg::Rand(100) < 20 )
			{
				if( myself::Skill_GetConsumeMP(Heal) < myself.sm.mp && myself::Skill_GetConsumeHP(Heal) < myself.sm.hp && myself::Skill_InReuseDelay(Heal) == 0 )
				{
					myself::AddUseSkillDesire(myself.c_ai0,Heal,1,1,1000000);
				}
			}
		}
	}

	EventHandler NO_DESIRE()
	{
		if( myself::DistFromMe(myself.c_ai0) > 100 )
		{
			myself::AddMoveToDesire(myself::FloatToInt(( ( myself.c_ai0.x - 50 ) + ( gg::Rand(10) * 10 ) )),myself::FloatToInt(( ( myself.c_ai0.y - 50 ) + ( gg::Rand(10) * 10 ) )),myself::FloatToInt(myself.c_ai0.z),10);
		}
	}

	EventHandler MOVE_TO_FINISHED(x,y,z)
	{
		if( myself::DistFromMe(myself.c_ai0) > 100 )
		{
			myself::AddMoveToDesire(myself::FloatToInt(( ( myself.c_ai0.x - 50 ) + ( gg::Rand(10) * 10 ) )),myself::FloatToInt(( ( myself.c_ai0.y - 50 ) + ( gg::Rand(10) * 10 ) )),myself::FloatToInt(myself.c_ai0.z),10);
		}
	}

}
