class 1 wizard_saint_basic : wizard
{
parameter:
	int	IsChange = 0;
	int	silhouette = 1020130;
	string	szAI = "warrior";
	int	W_ShortRangeDDMagic = 1064961;
	int	Buff = 1040641;
	int	DeBuff = 1040641;

handler:
	EventHandler CREATED()
	{
		myself.i_ai4 = 0;
		if( myself::Skill_GetConsumeMP(Buff) < myself.sm.mp && myself::Skill_GetConsumeHP(Buff) < myself.sm.hp && myself::Skill_InReuseDelay(Buff) == 0 )
		{
			myself::AddUseSkillDesire(myself.sm,Buff,1,1,1000000);
		}
		super;
	}

	EventHandler ATTACKED(attacker,damage,h0,i0,i1,f0)
	{
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( myself::GetHateInfoCount() == 0 )
			{
				f0 = 0;
				if( SetHateGroup >= 0 )
				{
					if( myself::IsInCategory(SetHateGroup,attacker.occupation) )
					{
						f0 = ( f0 + SetHateGroupRatio );
					}
				}
				if( attacker.occupation == SetHateOccupation )
				{
					f0 = ( f0 + SetHateOccupationRatio );
				}
				if( SetHateRace == attacker.race )
				{
					f0 = ( f0 + SetHateRaceRatio );
				}
				f0 = ( ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) + ( ( f0 / 100 ) * ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) ) );
				myself::AddHateInfo(attacker,myself::FloatToInt(( ( f0 * 100 ) + 300 )),0,1,1);
			}
			else
			{
				f0 = 0;
				if( SetHateGroup >= 0 )
				{
					if( myself::IsInCategory(SetHateGroup,attacker.occupation) )
					{
						f0 = ( f0 + SetHateGroupRatio );
					}
				}
				if( attacker.occupation == SetHateOccupation )
				{
					f0 = ( f0 + SetHateOccupationRatio );
				}
				if( SetHateRace == attacker.race )
				{
					f0 = ( f0 + SetHateRaceRatio );
				}
				f0 = ( ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) + ( ( f0 / 100 ) * ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) ) );
				myself::AddHateInfo(attacker,myself::FloatToInt(( f0 * 100 )),0,1,1);
			}
		}
		if( IsChange == 1 )
		{
			if( myself.i_ai4 == 0 && myself::FloatToInt(( ( myself.sm.hp / myself.sm.max_hp ) * 100 )) < 70 && myself::FloatToInt(( ( myself.sm.hp / myself.sm.max_hp ) * 100 )) > 50 && gg::Rand(100) < 30 )
			{
				myself.i_ai4 = 1;
				myself.c_ai0 = attacker;
				i0 = myself::GetDirection(myself.sm);
				myself::CreateOnePrivateEx(silhouette,szAI,0,0,myself::FloatToInt(myself.sm.x),myself::FloatToInt(myself.sm.y),myself::FloatToInt(myself.sm.z),( i0 * 182 ),1000,myself::GetIndexFromCreature(myself.c_ai0),0);
				myself::Despawn();
				return;
			}
		}
		super;
		h0 = myself::GetMaxHateInfo(0);
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( myself.i_ai0 == 0 )
			{
				i0 = 0;
				if( myself::IsNullHateInfo(h0) == 0 )
				{
					if( myself::IsNullCreature(h0.creature) == 0 )
					{
						i0 = 1;
					}
				}
				if( i0 == 1 )
				{
					if( h0.creature == attacker )
					{
						i0 = 1;
					}
				}
				if( i0 == 1 )
				{
					if( myself::Skill_GetConsumeMP(W_ShortRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_ShortRangeDDMagic) < myself.sm.hp )
					{
						if( myself::Skill_InReuseDelay(W_ShortRangeDDMagic) == 0 )
						{
							myself::AddUseSkillDesire(attacker,W_ShortRangeDDMagic,0,1,1000000);
						}
						else
						{
							myself::AddUseSkillDesire(attacker,W_ShortRangeDDMagic,0,1,1000000);
						}
					}
					else
					{
						myself.i_ai0 = 1;
						myself::AddAttackDesire(attacker,1,1000);
					}
				}
				else if( gg::Rand(100) < 2 )
				{
					if( myself::Skill_GetConsumeMP(W_ShortRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_ShortRangeDDMagic) < myself.sm.hp )
					{
						if( myself::Skill_InReuseDelay(W_ShortRangeDDMagic) == 0 )
						{
							myself::AddUseSkillDesire(attacker,W_ShortRangeDDMagic,0,1,1000000);
						}
						else
						{
							myself::AddUseSkillDesire(attacker,W_ShortRangeDDMagic,0,1,1000000);
						}
					}
					else
					{
						myself.i_ai0 = 1;
						myself::AddAttackDesire(attacker,1,1000);
					}
				}
				if( gg::Rand(100) < 33 && myself::GetAbnormalLevel(attacker,myself::Skill_GetAbnormalType(DeBuff)) <= 0 && i0 == 1 )
				{
					if( myself::Skill_GetConsumeMP(DeBuff) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff) < myself.sm.hp )
					{
						if( myself::Skill_InReuseDelay(DeBuff) == 0 )
						{
							myself::AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
						}
						else
						{
							myself::AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
						}
					}
					else
					{
						myself.i_ai0 = 1;
						myself::AddAttackDesire(attacker,1,1000);
					}
				}
			}
			else if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
			{
				f0 = 0;
				if( SetHateGroup >= 0 )
				{
					if( myself::IsInCategory(SetHateGroup,attacker.occupation) )
					{
						f0 = ( f0 + SetHateGroupRatio );
					}
				}
				if( attacker.occupation == SetHateOccupation )
				{
					f0 = ( f0 + SetHateOccupationRatio );
				}
				if( SetHateRace == attacker.race )
				{
					f0 = ( f0 + SetHateRaceRatio );
				}
				f0 = ( ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) + ( ( f0 / 100 ) * ( ( 1.000000 * damage ) / ( myself.sm.level + 7 ) ) ) );
				myself::AddAttackDesire(attacker,1,( f0 * 100 ));
			}
		}
		super;
	}

	EventHandler CLAN_ATTACKED(attacker,damage,i6)
	{
		if( ( myself::GetLifeTime() > 7 && ( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) ) ) && myself::GetHateInfoCount() == 0 )
		{
			if( gg::Rand(100) < 33 && myself::GetAbnormalLevel(attacker,myself::Skill_GetAbnormalType(DeBuff)) <= 0 )
			{
				if( myself::Skill_GetConsumeMP(DeBuff) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff) < myself.sm.hp )
				{
					if( myself::Skill_InReuseDelay(DeBuff) == 0 )
					{
						myself::AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
					}
					else
					{
						myself::AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
					}
				}
				else
				{
					myself.i_ai0 = 1;
					myself::AddAttackDesire(attacker,1,1000);
				}
			}
			else if( myself::Skill_GetConsumeMP(W_ShortRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_ShortRangeDDMagic) < myself.sm.hp )
			{
				if( myself::Skill_InReuseDelay(W_ShortRangeDDMagic) == 0 )
				{
					myself::AddUseSkillDesire(attacker,W_ShortRangeDDMagic,0,1,1000000);
				}
				else
				{
					myself::AddUseSkillDesire(attacker,W_ShortRangeDDMagic,0,1,1000000);
				}
			}
			else
			{
				myself.i_ai0 = 1;
				myself::AddAttackDesire(attacker,1,1000);
			}
		}
		super;
	}

	EventHandler USE_SKILL_FINISHED(h0,i0)
	{
		h0 = myself::GetMaxHateInfo(0);
		if( myself.i_ai0 == 0 )
		{
			i0 = 0;
			if( myself::IsNullHateInfo(h0) == 0 )
			{
				if( myself::IsNullCreature(h0.creature) == 0 )
				{
					i0 = 1;
				}
			}
			if( i0 == 1 )
			{
				if( myself::Skill_GetConsumeMP(W_ShortRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_ShortRangeDDMagic) < myself.sm.hp )
				{
					if( myself::Skill_InReuseDelay(W_ShortRangeDDMagic) == 0 )
					{
						myself::AddUseSkillDesire(h0.creature,W_ShortRangeDDMagic,0,1,1000000);
					}
					else
					{
						myself::AddUseSkillDesire(h0.creature,W_ShortRangeDDMagic,0,1,1000000);
					}
				}
				else
				{
					myself.i_ai0 = 1;
					myself::AddAttackDesire(h0.creature,1,1000);
				}
				if( gg::Rand(100) < 33 && myself::GetAbnormalLevel(h0.creature,myself::Skill_GetAbnormalType(DeBuff)) <= 0 )
				{
					if( myself::Skill_GetConsumeMP(DeBuff) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff) < myself.sm.hp )
					{
						if( myself::Skill_InReuseDelay(DeBuff) == 0 )
						{
							myself::AddUseSkillDesire(h0.creature,DeBuff,0,1,1000000);
						}
						else
						{
							myself::AddUseSkillDesire(h0.creature,DeBuff,0,1,1000000);
						}
					}
					else
					{
						myself.i_ai0 = 1;
						myself::AddAttackDesire(h0.creature,1,1000);
					}
				}
			}
		}
		else if( h0.creature.is_pc != 0 || myself::IsInCategory(11,h0.creature.npc_class_id) )
		{
			myself::AddAttackDesire(h0.creature,1,1000);
		}
	}

}
