@LabelIndex 135095
@StringIndex 17289
class 0 ai_destruct_wizard : ai_destruct_basic {
parameter:
	int	Skill01_ID = 458752001;
	int	Skill01_Prob = 0;
	int	Skill02_ID = 458752001;
	int	Skill02_Prob = 0;
	int	Skill03_ID = 458752001;
	int	Skill03_Prob = 0;

handler:
	EventHandler CREATED() {
		super;
		myself::SetMaxHateListSize(50);
		myself.i_ai4 = 0;
	}

	EventHandler ATTACKED(attacker,damage,h0) {
		super;
		if( myself.i_ai4 == 0 ) {
			if( attacker.is_pc == 1 ) {
				myself::AddHateInfo(attacker,gg::FloatToInt(damage),0,1,1);
			} else if( attacker.is_pc == 0 && myself::IsInCategory(12,attacker.class_id) == 1 ) {
				if( attacker.master.alive == 1 ) {
					myself::AddHateInfo(attacker.master,gg::FloatToInt(damage),0,1,1);
				}
			}
			if( myself::GetHateInfoCount() > 0 ) {
				h0 = myself::GetMaxHateInfo(0);
				myself.c_ai1 = h0.creature;
				if( myself::IsNullHateInfo(h0) == 0 ) {
					if( myself::IsNullCreature(h0.creature) == 0 ) {
						if( h0.creature.is_pc != 0 || myself::IsInCategory(12,h0.creature.class_id) ) {
							if( myself::DistFromMe(h0.creature) >= 150 ) {
								if( Skill01_ID != 458752001 && gg::Rand(10000) < Skill01_Prob ) {
									if( myself::Skill_GetConsumeMP(Skill01_ID) < myself.sm.mp && myself::Skill_GetConsumeHP(Skill01_ID) < myself.sm.hp && myself::Skill_InReuseDelay(Skill01_ID) == 0 ) {
										myself::AddUseSkillDesire(h0.creature,Skill01_ID,0,1,1000000);
									}
								}
							} else if( Skill02_ID != 458752001 && gg::Rand(10000) < Skill02_Prob ) {
								if( myself::Skill_GetConsumeMP(Skill02_ID) < myself.sm.mp && myself::Skill_GetConsumeHP(Skill02_ID) < myself.sm.hp && myself::Skill_InReuseDelay(Skill02_ID) == 0 ) {
									myself::AddUseSkillDesire(h0.creature,Skill02_ID,0,1,1000000);
								}
							}
						}
					}
				}
			}
		} else if( myself.i_ai4 == 1 ) {
			myself::AddAttackDesire(attacker,1,damage);
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id,h0) {
		super;
		if( timer_id == 4811 ) {
			if( myself::Skill_GetConsumeMP(Skill01_ID) > myself.sm.mp || myself::Skill_GetConsumeMP(Skill02_ID) > myself.sm.mp || gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(69730305)) > 0 || gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(87556097)) > 0 ) {
				myself::AddTimerEx(4811,( 10 * 1000 ));
			} else {
				myself::RemoveAllDesire();
				myself.i_ai4 = 0;
				if( myself::IsNullHateInfo(h0) == 0 ) {
					if( myself::IsNullCreature(h0.creature) == 0 ) {
						myself::MakeAttackEvent(h0.creature,100,0);
					}
				}
			}
		}
	}

	EventHandler USE_SKILL_FINISHED(h0,i0,f0,i1,c0) {
		if( myself.i_ai4 == 0 ) {
			if( myself::Skill_GetConsumeMP(Skill01_ID) > myself.sm.mp || myself::Skill_GetConsumeMP(Skill02_ID) > myself.sm.mp || gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(69730305)) > 0 || gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(87556097)) > 0 ) {
				myself::RemoveAllDesire();
				h0 = myself::GetMaxHateInfo(0);
				myself::AddAttackDesire(h0.creature,1,1000);
				myself.i_ai4 = 1;
				myself::AddTimerEx(4811,( 10 * 1000 ));
			} else {
				h0 = myself::GetMaxHateInfo(0);
				if( myself::IsNullHateInfo(h0) == 0 ) {
					if( myself::IsNullCreature(h0.creature) == 0 ) {
						c0 = h0.creature;
						if( myself::DistFromMe(c0) >= 150 ) {
							if( Skill01_ID != 458752001 ) {
								if( c0.is_pc != 0 || myself::IsInCategory(12,c0.class_id) ) {
									if( myself::Skill_GetConsumeMP(Skill01_ID) < myself.sm.mp && myself::Skill_GetConsumeHP(Skill01_ID) < myself.sm.hp && myself::Skill_InReuseDelay(Skill01_ID) == 0 ) {
										myself::AddUseSkillDesire(c0,Skill01_ID,0,1,1000000);
									}
								}
							}
						} else if( Skill02_ID != 458752001 ) {
							if( c0.is_pc != 0 || myself::IsInCategory(12,c0.class_id) ) {
								if( myself::Skill_InReuseDelay(Skill02_ID) == 0 ) {
									if( myself::Skill_GetConsumeMP(Skill02_ID) < myself.sm.mp && myself::Skill_GetConsumeHP(Skill02_ID) < myself.sm.hp && myself::Skill_InReuseDelay(Skill02_ID) == 0 ) {
										myself::AddUseSkillDesire(c0,Skill02_ID,0,1,1000000);
									}
								} else if( myself::Skill_GetConsumeMP(Skill01_ID) < myself.sm.mp && myself::Skill_GetConsumeHP(Skill01_ID) < myself.sm.hp && myself::Skill_InReuseDelay(Skill01_ID) == 0 ) {
									myself::AddUseSkillDesire(c0,Skill01_ID,0,1,1000000);
								}
							}
						}
					}
				}
			}
		}
	}

	EventHandler CLAN_ATTACKED(attacker,damage) {
		myself::MakeAttackEvent(attacker,( damage / 10 ),0);
	}

	EventHandler ATTACK_FINISHED(target,h0) {
		if( target.alive == 0 && target.is_pc == 0 ) {
			if( myself::IsInCategory(12,target.class_id) != 0 ) {
				myself::MakeAttackEvent(target.master,1000,0);
			}
		}
		if( myself::GetHateInfoCount() == 0 ) {
			myself::LookNeighbor(450);
		}
	}

	EventHandler SEE_CREATURE(creature,h0) {
		if( creature.is_pc == 1 || myself::IsInCategory(12,creature.class_id) == 1 ) {
			if( myself::GetHateInfoCount() == 0 ) {
				myself::AddHateInfo(creature,500,0,1,1);
			} else {
				myself::AddHateInfo(creature,100,0,1,1);
			}
			myself::MakeAttackEvent(creature,100,0);
		}
		super;
	}

	EventHandler MY_DYING(last_attacker,maker0) {
		if( gg::Rand(10000) < 300 ) {
			if( myself::IsNullCreature(myself.c_ai1) == 0 ) {
				maker0 = myself::GetMyMaker();
				if( gg::IsNull(maker0) == 0 ) {
					if( maker0.npc_count < ( maker0.maximum_npc - 1 ) ) {
						myself::CreateOnePrivateEx(1022545,"ai_destruct_spawned",0,0,gg::FloatToInt(myself.sm.x),gg::FloatToInt(myself.sm.y),gg::FloatToInt(myself.sm.z),gg::Rand(360),1000,gg::GetIndexFromCreature(myself.c_ai1),0);
					}
				}
			}
		}
		super;
	}

}
