@LabelIndex 104935
@StringIndex 0
class 0 party_private_wizard_oracle : wizard {
parameter:
	int	selfbuff = 458752001;
	int	W_LongRangeDDMagic = 458752001;
	int	W_ShortRangeDDMagic = 458752001;

handler:
	EventHandler CREATED() {
		myself.i_ai1 = myself::GetTick();
		myself.i_ai2 = 0;
		myself.c_ai0 = gg::GetNullCreature();
		if( myself::Skill_GetConsumeMP(selfbuff) < myself.sm.mp && myself::Skill_GetConsumeHP(selfbuff) < myself.sm.hp && myself::Skill_InReuseDelay(selfbuff) == 0 ) {
			myself::AddUseSkillDesire(myself.sm,selfbuff,1,0,10000000);
		}
		myself::AddTimerEx(1100,( 60 * 1000 ));
		super;
	}

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

	EventHandler ATTACKED(attacker,damage,h0,f0,i0) {
		myself.i_ai1 = myself::GetTick();
		h0 = myself::GetMaxHateInfo(0);
		myself.c_ai0 = attacker;
		if( attacker.is_pc != 0 || myself::IsInCategory(12,attacker.class_id) ) {
			if( myself.i_ai2 == 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( myself::DistFromMe(attacker) > 100 ) {
					if( i0 == 1 ) {
						if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
							if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
								myself::AddUseSkillDesire(attacker,W_LongRangeDDMagic,0,1,1000000);
							} else {
								myself::AddUseSkillDesire(attacker,W_LongRangeDDMagic,0,1,1000000);
							}
						} else {
							myself.i_ai0 = 1;
							myself::AddAttackDesire(attacker,1,1000);
						}
					} else if( gg::Rand(100) < 2 ) {
						if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
							if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
								myself::AddUseSkillDesire(attacker,W_LongRangeDDMagic,0,1,1000000);
							} else {
								myself::AddUseSkillDesire(attacker,W_LongRangeDDMagic,0,1,1000000);
							}
						} else {
							myself.i_ai0 = 1;
							myself::AddAttackDesire(attacker,1,1000);
						}
					}
				} else 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);
					}
				}
			} else if( attacker.is_pc != 0 || myself::IsInCategory(12,attacker.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 ));
			}
		}
	}

	EventHandler PARTY_ATTACKED(attacker,private,damage,f0) {
		myself.i_ai1 = myself::GetTick();
		if( private != myself.sm ) {
			myself.c_ai0 = attacker;
			if( myself::DistFromMe(attacker) >= 100 ) {
				if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
					if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
						myself::AddUseSkillDesire(attacker,W_LongRangeDDMagic,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(attacker,W_LongRangeDDMagic,0,1,1000000);
					}
				} else {
					myself.i_ai0 = 1;
					myself::AddAttackDesire(attacker,1,1000);
				}
			} else if( myself::DistFromMe(attacker) <= 100 ) {
				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);
				}
			}
		}
	}

	EventHandler CLAN_ATTACKED(attacker,victim,damage) {
	}

	EventHandler TIMER_FIRED_EX(timer_id) {
		if( timer_id == 1100 ) {
			if( ( myself::GetTick() - myself.i_ai1 ) > ( ( 5 * 60 ) * 1000 ) ) {
				gg::SendScriptEvent(myself.boss,11039,0);
				myself::Despawn();
			}
			myself::AddTimerEx(1100,( ( 1 * 60 ) * 1000 ));
		}
	}

	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,c0,i0) {
		if( script_event_arg1 == 1000 ) {
			myself::Despawn();
		}
	}

	EventHandler SEE_CREATURE(creature,party0) {
		myself.i_ai1 = myself::GetTick();
		party0 = gg::GetParty(creature);
		if( myself::IsNullParty(party0) == 0 ) {
			if( gg::Rand(100) < 50 ) {
				if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
					if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
						myself::AddUseSkillDesire(creature,W_LongRangeDDMagic,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(creature,W_LongRangeDDMagic,0,1,1000000);
					}
				} else {
					myself.i_ai0 = 1;
					myself::AddAttackDesire(creature,1,1000);
				}
			}
		} else if( gg::Rand(100) < 20 ) {
			if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
				if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
					myself::AddUseSkillDesire(creature,W_LongRangeDDMagic,0,1,1000000);
				} else {
					myself::AddUseSkillDesire(creature,W_LongRangeDDMagic,0,1,1000000);
				}
			} else {
				myself.i_ai0 = 1;
				myself::AddAttackDesire(creature,1,1000);
			}
		}
	}

	EventHandler SEE_SPELL(speller,skill_name_id) {
		if( gg::Rand(100) < 20 && speller.is_pc != 0 && myself::IsInCategory(3,speller.occupation) != 0 ) {
			if( myself::DistFromMe(speller) > 100 ) {
				if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
					if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
						myself::AddUseSkillDesire(speller,W_LongRangeDDMagic,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(speller,W_LongRangeDDMagic,0,1,1000000);
					}
				} else {
					myself.i_ai0 = 1;
					myself::AddAttackDesire(speller,1,1000);
				}
			} else if( myself::DistFromMe(speller) < 100 ) {
				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(speller,W_ShortRangeDDMagic,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(speller,W_ShortRangeDDMagic,0,1,1000000);
					}
				} else {
					myself.i_ai0 = 1;
					myself::AddAttackDesire(speller,1,1000);
				}
			}
		}
	}

	EventHandler USE_SKILL_FINISHED(h0,i0,skill_name_id) {
		if( myself.i_ai2 != 1 ) {
			if( myself::IsNullCreature(myself.c_ai0) == 0 ) {
				if( myself::DistFromMe(myself.c_ai0) > 100 ) {
					if( myself::Skill_GetConsumeMP(W_LongRangeDDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(W_LongRangeDDMagic) < myself.sm.hp ) {
						if( myself::Skill_InReuseDelay(W_LongRangeDDMagic) == 0 ) {
							myself::AddUseSkillDesire(myself.c_ai0,W_LongRangeDDMagic,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(myself.c_ai0,W_LongRangeDDMagic,0,1,1000000);
						}
					} else {
						myself.i_ai0 = 1;
						myself::AddAttackDesire(myself.c_ai0,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(myself.c_ai0,W_ShortRangeDDMagic,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(myself.c_ai0,W_ShortRangeDDMagic,0,1,1000000);
					}
				} else {
					myself.i_ai0 = 1;
					myself::AddAttackDesire(myself.c_ai0,1,1000);
				}
			}
		}
	}

}
