@LabelIndex 63660
@StringIndex 0
class 0 ai_boss08_portrait_spirit : default_npc {
parameter:
	int	PhysicalSpecial = 328269825;
	int	Hold = 328466433;
	int	vampiric = 328531969;
	int	bomb = 328400897;
	float	Attack_DecayRatio = 6.600000;
	float	UseSkill_DecayRatio = 66000.000000;
	float	Attack_BoostValue = 300.000000;
	float	UseSkill_BoostValue = 100000.000000;

handler:
	EventHandler CREATED() {
		myself.i_ai4 = 0;
		myself.i_quest1 = 0;
		myself.i_quest2 = 0;
		myself::AddMoveAroundDesire(200,5);
		myself::AddTimerEx(5000,( 10 * 1000 ));
		super;
	}

	EventHandler ATTACKED(attacker) {
		if( myself.i_ai4 == 0 ) {
			if( attacker.is_pc != 0 || myself::IsInCategory(12,attacker.class_id) ) {
				if( myself::Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.mp && myself::Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.hp && myself::Skill_InReuseDelay(PhysicalSpecial) == 0 ) {
					myself::AddUseSkillDesire(attacker,PhysicalSpecial,0,1,1000000);
				}
				if( attacker.is_pc != 0 || myself::IsInCategory(12,attacker.class_id) ) {
					myself::AddAttackDesire(attacker,1,( 1 * 50 ));
				}
				myself.i_quest2 = myself::GetCurrentTick();
				myself::AddTimerEx(2001,( 5 * 1000 ));
			}
		}
	}

	EventHandler CLAN_ATTACKED(attacker,damage) {
		if( myself.i_ai4 == 0 && myself::GetLifeTime() > 7 ) {
			if( attacker.is_pc != 0 || myself::IsInCategory(12,attacker.class_id) ) {
				if( myself::Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.mp && myself::Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.hp && myself::Skill_InReuseDelay(PhysicalSpecial) == 0 ) {
					myself::AddUseSkillDesire(attacker,PhysicalSpecial,0,1,1000000);
				}
				if( attacker.is_pc != 0 || myself::IsInCategory(12,attacker.class_id) ) {
					myself::AddAttackDesire(attacker,1,( 1 * 50 ));
				}
			}
		}
	}

	EventHandler USE_SKILL_FINISHED(skill_name_id,i0,success) {
		if( skill_name_id == bomb && success == 1 ) {
			myself::Despawn();
			return;
		}
		if( myself.i_ai4 == 0 ) {
			if( myself::IsNullCreature(myself.top_desire_target) == 0 ) {
				if( myself.top_desire_target.is_pc == 1 ) {
					if( gg::GetAbnormalLevel(myself.top_desire_target,myself::Skill_GetAbnormalType(Hold)) > 0 ) {
						if( myself::Skill_GetConsumeMP(vampiric) < myself.sm.mp && myself::Skill_GetConsumeHP(vampiric) < myself.sm.hp && myself::Skill_InReuseDelay(vampiric) == 0 && myself.i_quest2 < 3 ) {
							myself.i_quest1 = ( myself.i_quest1 + 1 );
							myself::AddUseSkillDesire(myself.top_desire_target,vampiric,0,1,1000000);
						}
					} else if( myself::Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.mp && myself::Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.hp && myself::Skill_InReuseDelay(PhysicalSpecial) == 0 ) {
						myself::AddUseSkillDesire(myself.top_desire_target,PhysicalSpecial,0,1,1000000);
					}
					if( myself.top_desire_target.is_pc != 0 || myself::IsInCategory(12,myself.top_desire_target.class_id) ) {
						myself::AddAttackDesire(myself.top_desire_target,1,( 1 * 50 ));
					}
				}
			}
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0) {
		if( myself.i_ai4 == 0 ) {
			if( timer_id == 2001 ) {
				i0 = myself::GetCurrentTick();
				if( i0 > ( myself.i_quest1 + 5 ) ) {
					if( myself::IsNullCreature(myself.top_desire_target) == 0 ) {
						if( myself::Skill_GetConsumeMP(Hold) < myself.sm.mp && myself::Skill_GetConsumeHP(Hold) < myself.sm.hp && myself::Skill_InReuseDelay(Hold) == 0 ) {
							myself::AddUseSkillDesire(myself.top_desire_target,Hold,0,1,1000000);
						}
					}
				}
			} else if( timer_id == 2002 ) {
				if( myself::IsNullCreature(myself.top_desire_target) == 0 ) {
					if( gg::GetAbnormalLevel(myself.top_desire_target,myself::Skill_GetAbnormalType(Hold)) > 0 ) {
						if( myself::Skill_GetConsumeMP(vampiric) < myself.sm.mp && myself::Skill_GetConsumeHP(vampiric) < myself.sm.hp && myself::Skill_InReuseDelay(vampiric) == 0 && myself.i_quest2 < 3 ) {
							myself.i_quest1 = ( myself.i_quest1 + 1 );
							myself::AddUseSkillDesire(myself.top_desire_target,vampiric,0,1,1000000);
						}
						myself::AddTimerEx(2002,( 5 * 1000 ));
					} else if( myself::Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.mp && myself::Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.hp && myself::Skill_InReuseDelay(PhysicalSpecial) == 0 ) {
						myself::AddUseSkillDesire(myself.top_desire_target,PhysicalSpecial,0,1,1000000);
					}
					if( myself.top_desire_target.is_pc != 0 || myself::IsInCategory(12,myself.top_desire_target.class_id) ) {
						myself::AddAttackDesire(myself.top_desire_target,1,( 1 * 50 ));
					}
				}
			} else if( timer_id == 5000 ) {
				if( myself::IsMyBossAlive() == 0 ) {
					if( myself.p_state != 3 && myself.p_state != 10 ) {
						myself::Despawn();
					} else if( myself::IsNullCreature(myself.top_desire_target) == 0 ) {
						if( myself::DistFromMe(myself.top_desire_target) > 5000 ) {
							myself::Despawn();
						}
					} else {
						myself::AddTimerEx(5000,( 10 * 1000 ));
					}
				} else {
					myself::AddTimerEx(5000,( 10 * 1000 ));
				}
			}
			super;
		}
	}

	EventHandler SEE_CREATURE(creature) {
		if( myself.i_ai4 == 0 && myself::GetLifeTime() > 7 ) {
			if( creature.is_pc == 0 && myself::IsInCategory(12,creature.class_id) == 0 ) {
			} else if( myself::Skill_GetConsumeMP(PhysicalSpecial) < myself.sm.mp && myself::Skill_GetConsumeHP(PhysicalSpecial) < myself.sm.hp && myself::Skill_InReuseDelay(PhysicalSpecial) == 0 ) {
				myself::AddUseSkillDesire(creature,PhysicalSpecial,0,1,1000000);
			}
			if( creature.is_pc != 0 || myself::IsInCategory(12,creature.class_id) ) {
				myself::AddAttackDesire(creature,1,( 1 * 50 ));
			}
		}
	}

	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2,i0,c0) {
		if( script_event_arg2 == 20000 ) {
			myself::RemoveAllDesire();
			if( myself::Skill_GetConsumeMP(bomb) < myself.sm.mp && myself::Skill_GetConsumeHP(bomb) < myself.sm.hp && myself::Skill_InReuseDelay(bomb) == 0 ) {
				myself::AddUseSkillDesire(myself.sm,bomb,1,1,1000000);
			}
		} else if( script_event_arg2 == 40000 ) {
			myself::RemoveAllDesire();
			myself::Despawn();
		} else if( script_event_arg2 == 50000 ) {
			myself.i_ai4 = 1;
			myself::RemoveAllDesire();
		}
	}

}
