@LabelIndex 66983
@StringIndex 10875
class 0 ai_boss04_antaras : default_npc {
parameter:
	int	GM_ID = 0;
	int	ultra_respawn_time = 5;
	int	pc_count = 0;

handler:
	EventHandler CREATED(reply,i0,i1,i2,i3,c1,c2,c3) {
		if( reply == 0 ) {
			myself::SetDBValue(myself.sm,0);
			myself::EarthQuakeByNPC(myself.sm,20,10,1,0,0,0);
		}
		myself.i_ai0 = 0;
		myself.i_ai1 = myself::GetTick();
		myself.i_ai2 = 0;
		myself.i_ai3 = 0;
		myself.i_ai4 = 0;
		myself.i_quest0 = 0;
		myself.i_quest1 = 0;
		myself.i_quest2 = 0;
		myself.i_quest3 = 0;
		myself.i_quest4 = myself::GetTick();
		myself.c_ai0 = gg::GetNullCreature();
		myself.c_ai1 = gg::GetNullCreature();
		if( GM_ID != 0 ) {
			i0 = myself::GetGlobalMap(GM_ID);
			if( i0 == -1 ) {
				myself::RegisterGlobalMap(GM_ID,gg::GetIndexFromCreature(myself.sm));
			}
		}
		myself::AddTimerEx(2005,3000);
	}

	EventHandler NO_DESIRE() {
		if( myself.sm.db_value == 3 ) {
			myself::AddMoveAroundDesire(5,5);
		} else if( myself.sm.db_value == 0 ) {
			myself::RemoveAllDesire();
		}
	}

	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2,script_event_arg3,i0,c0,i1,i2,i3,c1,c2,c3) {
		i1 = myself::GetGlobalMap(1);
		i2 = myself::GetGlobalMap(9);
		i3 = myself::GetGlobalMap(10);
		c1 = gg::GetCreatureFromIndex(i1);
		c2 = gg::GetCreatureFromIndex(i2);
		c3 = gg::GetCreatureFromIndex(i3);
		if( myself.sm.db_value == 0 ) {
			if( myself::IsNullCreature(c1) == 0 && myself::IsNullCreature(c2) == 0 && myself::IsNullCreature(c3) == 0 ) {
				if( c1.alive == 1 && c2.alive == 1 && c3.alive == 1 ) {
					if( c1.db_value == 0 || c2.db_value == 0 || c3.db_value == 0 ) {
						myself::AddTimerEx(1001,( ( 30 * 60 ) * 1000 ));
						myself::SetDBValue(myself.sm,1);
					}
				}
			}
		}
		if( script_event_arg1 == 99999999 ) {
			myself::MPCC_SetMasterPartyRouting(script_event_arg2,myself.sm,1);
			myself.int_list::Add(script_event_arg2);
		}
		if( script_event_arg1 == 12010 ) {
			myself.c_ai1 = gg::GetCreatureFromIndex(script_event_arg2);
			if( myself::IsNullCreature(myself.c_ai1) == 0 ) {
				myself::AddUseSkillDesire(myself.c_ai1,269352962,0,1,2000000);
			} else if( myself::IsNullCreature(myself.c_ai2) == 0 ) {
				myself::AddUseSkillDesire(myself.c_ai2,269352962,0,1,2000000);
			} else if( myself::IsNullCreature(myself.c_ai3) == 0 ) {
				myself::AddUseSkillDesire(myself.c_ai3,269352962,0,1,2000000);
			} else if( myself::IsNullCreature(myself.c_ai4) == 0 ) {
				myself::AddUseSkillDesire(myself.c_ai4,269352962,0,1,2000000);
			}
		}
		if( script_event_arg1 == 12001 ) {
			myself.i_quest2 = ( myself.i_quest2 + 1 );
			i0 = 0;
			if( myself.i_quest1 == 0 ) {
				myself.i_quest1 = script_event_arg2;
				myself.c_ai0 = gg::GetCreatureFromIndex(script_event_arg3);
			} else {
				i0 = script_event_arg2;
			}
			if( i0 >= myself.i_quest1 ) {
				myself.i_quest1 = script_event_arg2;
				myself.c_ai0 = gg::GetCreatureFromIndex(script_event_arg3);
			}
			if( myself.i_quest2 == 19 ) {
				if( myself::IsNullCreature(myself.c_ai0) == 0 ) {
					myself::BroadcastScriptEventEx(12002,gg::GetIndexFromCreature(myself.c_ai0),0,8000);
				}
				myself.i_quest1 = 0;
				myself.i_quest2 = 0;
				myself.c_ai0 = gg::GetNullCreature();
			}
		}
		if( script_event_arg1 == 12019 ) {
			myself.i_quest2 = ( myself.i_quest2 + 1 );
			i0 = 0;
			if( myself.i_quest1 == 0 ) {
				myself.i_quest1 = script_event_arg2;
				myself.c_ai0 = gg::GetCreatureFromIndex(script_event_arg3);
			} else {
				i0 = script_event_arg2;
			}
			if( i0 >= myself.i_quest1 ) {
				myself.i_quest1 = script_event_arg2;
				myself.c_ai0 = gg::GetCreatureFromIndex(script_event_arg3);
			}
			if( myself.i_quest2 == 19 ) {
				if( myself::IsNullCreature(myself.c_ai0) == 0 ) {
					myself::BroadcastScriptEventEx(12020,gg::GetIndexFromCreature(myself.c_ai0),0,8000);
				}
				myself.i_quest1 = 0;
				myself.i_quest2 = 0;
				myself.c_ai0 = gg::GetNullCreature();
			}
		}
		if( script_event_arg1 == 12012 ) {
			myself.i_quest0 = ( myself.i_quest0 + script_event_arg2 );
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id,i1,i2,c0,c1,c2,c3,i3,i4,i5,private) {
		i3 = myself::GetGlobalMap(1);
		i4 = myself::GetGlobalMap(9);
		i5 = myself::GetGlobalMap(10);
		c0 = gg::GetCreatureFromIndex(i3);
		c1 = gg::GetCreatureFromIndex(i4);
		c2 = gg::GetCreatureFromIndex(i5);
		if( timer_id == 1001 ) {
			if( myself.i_quest0 < 300 && GM_ID == 1 ) {
				myself::SetDBValue(myself.sm,2);
				myself::InstantTeleport(myself.sm,185452,114835,-8221);
				myself::AddMoveToDesire(181911,114835,-7678,100000);
				myself::EffectMusic(myself.sm,10000,"BS02_A");
			} else if( myself.i_quest0 >= 300 && myself.i_quest0 < 400 && GM_ID == 9 ) {
				myself::SetDBValue(myself.sm,2);
				myself::InstantTeleport(myself.sm,185452,114835,-8221);
				myself::AddMoveToDesire(181911,114835,-7678,100000);
				myself::EffectMusic(myself.sm,10000,"BS02_A");
			} else if( myself.i_quest0 >= 400 && GM_ID == 10 ) {
				myself::SetDBValue(myself.sm,2);
				myself::InstantTeleport(myself.sm,185452,114835,-8221);
				myself::AddMoveToDesire(181911,114835,-7678,100000);
				myself::EffectMusic(myself.sm,10000,"BS02_A");
			} else {
				myself::SetDBValue(myself.sm,0);
				myself::MPCC_SetMasterPartyRouting(myself.int_list::Get(0),myself.sm,0);
				myself.int_list::Clear();
				myself.i_quest0 = 0;
			}
		} else if( timer_id == 1201 ) {
			myself::SpecialCamera(myself.sm,700,13,-19,0,10000,20000,0,0,0,0,0);
			myself::AddTimerEx(1202,3000);
		} else if( timer_id == 1202 ) {
			myself::SpecialCamera(myself.sm,700,13,0,6000,10000,20000,0,0,0,0,0);
			myself::AddTimerEx(1203,10000);
		} else if( timer_id == 1203 ) {
			myself::SpecialCamera(myself.sm,3700,0,-3,0,10000,10000,0,0,0,0,0);
			myself::AddEffectActionDesire(myself.sm,1,8000,10000000);
			myself::AddEffectActionDesire(myself.sm,2,6000,5000000);
			myself::AddTimerEx(1204,200);
		} else if( timer_id == 1204 ) {
			myself::SpecialCamera(myself.sm,1100,0,-3,22000,10000,30000,0,0,0,0,0);
			myself::AddTimerEx(1205,10800);
		} else if( timer_id == 1205 ) {
			myself::SpecialCamera(myself.sm,1100,0,-3,300,10000,7000,0,0,0,0,0);
			myself::SetDBValue(myself.sm,3);
			myself::AddTimerEx(1002,( ( 1 * 60 ) * 1000 ));
			myself.i_ai1 = myself::GetTick();
			myself.i_quest4 = myself::GetTick();
			c3 = myself::FindNeighborHero(4000);
			if( myself::IsNullCreature(c3) == 0 ) {
				gg::BroadcastOnScreenMsgStr(myself.sm,4000,1,0,0,0,0,0,3000,0,gg::MakeFString(1000520,c3.name,"","","",""));
			}
			myself::AddUseSkillDesire(myself.sm,270336001,1,1,4000000);
			myself::AddMoveToDesire(179011,114871,-7704,3000000);
			if( myself::DistFromMe(myself.c_ai2) > 9000 || myself.c_ai2.alive == 0 ) {
				myself.i_ai2 = 0;
			}
			if( myself::DistFromMe(myself.c_ai3) > 9000 || myself.c_ai3.alive == 0 ) {
				myself.i_ai3 = 0;
			}
			if( myself::DistFromMe(myself.c_ai4) > 9000 || myself.c_ai4.alive == 0 ) {
				myself.i_ai4 = 0;
			}
			if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 2;
				i2 = myself.i_ai2;
				c2 = myself.c_ai2;
			} else {
				i1 = 3;
				i2 = myself.i_ai3;
				c2 = myself.c_ai3;
			}
			if( myself.i_ai4 > i2 ) {
				i1 = 4;
				i2 = myself.i_ai4;
				c2 = myself.c_ai4;
			}
			if( i2 > 0 ) {
				if( gg::Rand(100) < 70 ) {
					switch(i1) {
						case 2: {
							myself.i_ai2 = 500;
							break;
						}
						case 3: {
							myself.i_ai3 = 500;
							break;
						}
						case 4: {
							myself.i_ai4 = 500;
							break;
						}
					}
				}
				if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 30 ) {
						myself::AddUseSkillDesire(c2,269352961,0,1,1000000);
					} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 10 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 7 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
				} else if( gg::Rand(100) < 3 ) {
					myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
				} else if( gg::Rand(100) < 6 ) {
					myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
				} else if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
					}
				} else {
					myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
				}
			}
			myself::AddMoveAroundDesire(5,5);
			myself::AddTimerEx(1100,( ( ultra_respawn_time * 60 ) * 1000 ));
			myself.i_quest3 = 1;
		} else if( timer_id == 1100 ) {
			if( myself.i_quest3 >= 1 && myself.sm.db_value == 3 ) {
				myself::CreateOnePrivateEx(1029069,"antaras_ultrarisk",0,0,gg::FloatToInt(myself.sm.x),gg::FloatToInt(myself.sm.y),gg::FloatToInt(myself.sm.z),0,0,0,0);
			}
			myself::AddTimerEx(1100,( ( ultra_respawn_time * 60 ) * 1000 ));
		} else if( timer_id == 1002 ) {
			if( ( myself::GetTick() - myself.i_ai1 ) > ( ( 15 * 60 ) * 1000 ) ) {
				myself::BroadcastScriptEventEx(12015,0,0,8000);
				myself::MPCC_SetMasterPartyRouting(myself.int_list::Get(0),myself.sm,0);
				myself.int_list::Clear();
				myself::RemoveAllDesire();
				myself::StopMove();
				myself::InstantTeleportInMyTerritory(80464,152294,-3534,100);
				myself::InstantTeleport(myself.sm,185708,114298,-8221);
				myself.i_quest0 = 0;
				myself.i_ai2 = 0;
				myself.i_ai3 = 0;
				myself.i_ai4 = 0;
				myself.i_quest1 = 0;
				myself.i_quest3 = 0;
				myself::AddTimerEx(1003,5000);
			} else {
				myself::AddTimerEx(1002,( ( 1 * 60 ) * 1000 ));
			}
			myself::BroadcastScriptEventEx(12021,0,0,8000);
			if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
				if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(277938177)) < 14 ) {
					myself::AddUseSkillDesire(myself.sm,277938177,0,1,4000000);
				}
			} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
				if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(277872641)) < 13 ) {
					myself::AddUseSkillDesire(myself.sm,277872641,0,1,4000000);
				}
			} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
				if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(277807105)) < 12 ) {
					myself::AddUseSkillDesire(myself.sm,277807105,0,1,4000000);
				}
			} else if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(270336001)) < 11 ) {
				myself::AddUseSkillDesire(myself.sm,270336001,0,1,4000000);
			}
			if( myself.i_ai2 > 10 ) {
				myself.i_ai2 = ( myself.i_ai2 - ( gg::Rand(9) + 1 ) );
			}
			if( myself.i_ai3 > 10 ) {
				myself.i_ai3 = ( myself.i_ai3 - ( gg::Rand(9) + 1 ) );
			}
			if( myself.i_ai4 > 10 ) {
				myself.i_ai4 = ( myself.i_ai4 - ( gg::Rand(9) + 1 ) );
			}
			if( myself.sm.db_value == 3 && ( myself.p_state == 1 || myself.p_state == 0 ) ) {
				if( myself::DistFromMe(myself.c_ai2) > 9000 || myself.c_ai2.alive == 0 ) {
					myself.i_ai2 = 0;
				}
				if( myself::DistFromMe(myself.c_ai3) > 9000 || myself.c_ai3.alive == 0 ) {
					myself.i_ai3 = 0;
				}
				if( myself::DistFromMe(myself.c_ai4) > 9000 || myself.c_ai4.alive == 0 ) {
					myself.i_ai4 = 0;
				}
				if( myself.i_ai2 > myself.i_ai3 ) {
					i1 = 2;
					i2 = myself.i_ai2;
					c2 = myself.c_ai2;
				} else {
					i1 = 3;
					i2 = myself.i_ai3;
					c2 = myself.c_ai3;
				}
				if( myself.i_ai4 > i2 ) {
					i1 = 4;
					i2 = myself.i_ai4;
					c2 = myself.c_ai4;
				}
				if( i2 > 0 ) {
					if( gg::Rand(100) < 70 ) {
						switch(i1) {
							case 2: {
								myself.i_ai2 = 500;
								break;
							}
							case 3: {
								myself.i_ai3 = 500;
								break;
							}
							case 4: {
								myself.i_ai4 = 500;
								break;
							}
						}
					}
					if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
						if( gg::Rand(100) < 30 ) {
							myself::AddUseSkillDesire(c2,269352961,0,1,1000000);
						} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
							myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
						} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
							myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
						} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
							myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
						} else if( gg::Rand(100) < 10 ) {
							myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
						} else if( gg::Rand(100) < 6 ) {
							myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
						} else if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
						} else if( gg::Rand(100) < 5 ) {
							if( gg::Rand(100) < 50 ) {
								myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
							} else {
								myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
							}
						} else {
							myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
						}
					} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
						if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
							myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
						} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
							myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
						} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
							myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
						} else if( gg::Rand(100) < 7 ) {
							myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
						} else if( gg::Rand(100) < 6 ) {
							myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
						} else if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
						} else if( gg::Rand(100) < 5 ) {
							if( gg::Rand(100) < 50 ) {
								myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
							} else {
								myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
							}
						} else {
							myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
						}
					} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
						if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
							myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
						} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
							myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
						} else if( gg::Rand(100) < 5 ) {
							myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
						} else if( gg::Rand(100) < 6 ) {
							myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
						} else if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
						} else if( gg::Rand(100) < 5 ) {
							if( gg::Rand(100) < 50 ) {
								myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
							} else {
								myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
							}
						} else {
							myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
						}
					} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 3 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				}
			}
		} else if( timer_id == 1003 ) {
			myself::SetDBValue(myself.sm,0);
		} else if( timer_id == 2000 ) {
			if( myself.i_ai0 == 0 ) {
				myself.i_ai0 = 1;
				myself::AddMoveToDesire(177648,114816,-7735,3000000);
				if( myself.sm == c0 ) {
					myself::AddTimerEx(2001,( ultra_respawn_time - ( ( 2 * 60 ) * 1000 ) ));
				} else if( myself.sm == c1 ) {
					myself::AddTimerEx(2001,( ultra_respawn_time - ( ( 1 * 60 ) * 1000 ) ));
				}
			}
		} else if( timer_id == 2001 ) {
			myself.i_ai0 = 0;
		} else if( timer_id == 2002 ) {
			if( myself.i_ai0 == 0 ) {
				myself.i_ai0 = 1;
				myself::AddMoveToDesire(177777,114816,-7735,3000000);
				myself::AddTimerEx(2001,( ( ultra_respawn_time * 60 ) * 1000 ));
			}
		} else if( timer_id == 2003 ) {
			myself::BroadcastScriptEventEx(12013,0,0,8000);
		} else if( timer_id == 2005 ) {
			if( myself.sm.db_value == 1 ) {
				if( myself::IsNullCreature(c0) == 0 && myself::IsNullCreature(c1) == 0 && myself::IsNullCreature(c2) == 0 ) {
					if( c0.alive == 1 && c1.alive == 1 && c2.alive == 1 ) {
						if( c0.db_value == 1 || c1.db_value == 1 || c2.db_value == 1 ) {
							myself::SetDBValue(myself.sm,1);
							myself::AddTimerEx(1001,( ( 10 * 60 ) * 1000 ));
						} else {
							myself::SetDBValue(myself.sm,0);
						}
					}
				}
			} else if( myself.sm.db_value == 2 ) {
				myself::InstantTeleport(myself.sm,185452,114835,-8221);
				myself::AddMoveToDesire(181911,114835,-7678,100000);
				myself::EffectMusic(myself.sm,10000,"BS02_A");
			} else if( myself.sm.db_value == 3 ) {
				myself::AddTimerEx(1002,( ( 1 * 60 ) * 1000 ));
				myself.i_quest4 = 0;
				myself::AddTimerEx(1100,( ( 2 * 60 ) * 1000 ));
				myself.i_quest3 = 1;
				myself::AddTimerEx(1101,( ( 10 * 60 ) * 1000 ));
				myself.i_ai1 = myself::GetTick();
				myself::AddMoveAroundDesire(5,5);
			}
		}
	}

	EventHandler MOVE_TO_FINISHED(i0,i1,i2,c2) {
		if( myself.sm.db_value == 2 ) {
			myself::AddTimerEx(1201,2000);
		} else if( myself.sm.db_value == 3 && myself.i_ai0 == 1 && gg::FloatToInt(myself.sm.x) == 177648 ) {
			if( gg::Rand(100) < 50 ) {
				i0 = 0;
			} else {
				i0 = 1;
			}
			myself::BroadcastScriptEventEx(12016,0,0,8000);
			myself::RemoveAllDesire();
			myself::AddTimerEx(2003,( 30 * 1000 ));
		} else if( myself.sm.db_value == 3 && myself.i_ai0 == 1 && gg::FloatToInt(myself.sm.x) == 177777 ) {
			myself::BroadcastScriptEventEx(12000,i0,0,8000);
			myself::RemoveAllDesire();
			myself::AddTimerEx(2003,( 30 * 1000 ));
		}
	}

	EventHandler ATTACKED(attacker,damage,skill_name_id,i1,i2,c2) {
		if( ( myself::GetTick() - myself.i_quest4 ) < ( ( 2 * 60 ) * 1000 ) && myself.sm.hp < ( myself.sm.max_hp * 0.900000 ) && myself.i_quest3 < 2 ) {
			myself.i_quest3 = 2;
			myself::CreateOnePrivateEx(1029069,"antaras_ultrarisk",0,0,gg::FloatToInt(myself.sm.x),gg::FloatToInt(myself.sm.y),gg::FloatToInt(myself.sm.z),0,0,0,0);
		} else if( ( myself::GetTick() - myself.i_quest4 ) < ( ( 4 * 60 ) * 1000 ) && myself.sm.hp < ( myself.sm.max_hp * 0.700000 ) && myself.i_quest3 < 3 ) {
			myself.i_quest3 = 3;
			myself::CreateOnePrivateEx(1029069,"antaras_ultrarisk",0,0,gg::FloatToInt(myself.sm.x),gg::FloatToInt(myself.sm.y),gg::FloatToInt(myself.sm.z),0,0,0,0);
		} else if( ( myself::GetTick() - myself.i_quest4 ) < ( ( 7 * 60 ) * 1000 ) && myself.sm.hp < ( myself.sm.max_hp * 0.500000 ) && myself.i_quest3 < 4 ) {
			if( myself.i_ai0 == 1 ) {
				myself.i_ai0 = 0;
			}
			myself.i_quest3 = 4;
			myself::AddUseSkillDesire(attacker,269221889,0,1,1000000);
		}
		if( myself.sm.db_value == 0 && myself.sm.alive == 1 && myself::InMyTerritory(myself.sm) == 1 ) {
			myself::InstantTeleportInMyTerritory(80464,152294,-3534,100);
		}
		if( myself.sm.db_value == 0 && myself.sm.alive == 1 ) {
			myself::InstantTeleport(attacker,80464,152294,-3534);
		}
		myself.i_ai1 = myself::GetTick();
		if( attacker.yongma_type == 1 && gg::GetAbnormalLevel(attacker,myself::Skill_GetAbnormalType(279052289)) <= 0 ) {
			if( myself::Skill_GetConsumeMP(279052289) < myself.sm.mp && myself::Skill_GetConsumeHP(279052289) < myself.sm.hp && myself::Skill_InReuseDelay(279052289) == 0 ) {
				myself::AddUseSkillDesire(attacker,279052289,0,1,1000000);
			}
		}
		if( skill_name_id == 0 ) {
			if( attacker == myself.c_ai2 ) {
				if( myself.i_ai2 < ( ( damage * 1000 ) + 1000 ) ) {
					myself.i_ai2 = gg::FloatToInt(( ( damage * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai3 ) {
				if( myself.i_ai3 < ( ( damage * 1000 ) + 1000 ) ) {
					myself.i_ai3 = gg::FloatToInt(( ( damage * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai4 ) {
				if( myself.i_ai4 < ( ( damage * 1000 ) + 1000 ) ) {
					myself.i_ai4 = gg::FloatToInt(( ( damage * 1000 ) + gg::Rand(3000) ));
				}
			} else if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 3;
			} else if( myself.i_ai2 == myself.i_ai3 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 3;
				}
			} else if( myself.i_ai2 < myself.i_ai3 ) {
				i1 = 2;
			}
			if( i1 == 2 ) {
				if( myself.i_ai2 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai2 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai2 < myself.i_ai4 ) {
					i1 = 2;
				}
			} else if( i1 == 3 ) {
				if( myself.i_ai3 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai3 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 3;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai3 < myself.i_ai4 ) {
					i1 = 3;
				}
			}
			switch(i1) {
				case 2: {
					myself.i_ai2 = gg::FloatToInt(( ( damage * 1000 ) + gg::Rand(3000) ));
					myself.c_ai2 = attacker;
					break;
				}
				case 3: {
					myself.i_ai3 = gg::FloatToInt(( ( damage * 1000 ) + gg::Rand(3000) ));
					myself.c_ai3 = attacker;
					break;
				}
				case 4: {
					myself.i_ai4 = gg::FloatToInt(( ( damage * 1000 ) + gg::Rand(3000) ));
					myself.c_ai4 = attacker;
					break;
				}
			}
		} else if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
			if( attacker == myself.c_ai2 ) {
				if( myself.i_ai2 < ( ( ( damage / 30.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai2 = gg::FloatToInt(( ( ( damage / 30.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai3 ) {
				if( myself.i_ai3 < ( ( ( damage / 30.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai3 = gg::FloatToInt(( ( ( damage / 30.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai4 ) {
				if( myself.i_ai4 < ( ( ( damage / 30.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai4 = gg::FloatToInt(( ( ( damage / 30.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 3;
			} else if( myself.i_ai2 == myself.i_ai3 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 3;
				}
			} else if( myself.i_ai2 < myself.i_ai3 ) {
				i1 = 2;
			}
			if( i1 == 2 ) {
				if( myself.i_ai2 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai2 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai2 < myself.i_ai4 ) {
					i1 = 2;
				}
			} else if( i1 == 3 ) {
				if( myself.i_ai3 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai3 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 3;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai3 < myself.i_ai4 ) {
					i1 = 3;
				}
			}
			switch(i1) {
				case 2: {
					myself.i_ai2 = gg::FloatToInt(( ( ( damage / 30.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai2 = attacker;
					break;
				}
				case 3: {
					myself.i_ai3 = gg::FloatToInt(( ( ( damage / 30.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai3 = attacker;
					break;
				}
				case 4: {
					myself.i_ai4 = gg::FloatToInt(( ( ( damage / 30.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai4 = attacker;
					break;
				}
			}
		} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
			if( attacker == myself.c_ai2 ) {
				if( myself.i_ai2 < ( ( ( damage / 50.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai2 = gg::FloatToInt(( ( ( damage / 50.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai3 ) {
				if( myself.i_ai3 < ( ( ( damage / 50.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai3 = gg::FloatToInt(( ( ( damage / 50.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai4 ) {
				if( myself.i_ai4 < ( ( ( damage / 50.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai4 = gg::FloatToInt(( ( ( damage / 50.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 3;
			} else if( myself.i_ai2 == myself.i_ai3 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 3;
				}
			} else if( myself.i_ai2 < myself.i_ai3 ) {
				i1 = 2;
			}
			if( i1 == 2 ) {
				if( myself.i_ai2 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai2 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai2 < myself.i_ai4 ) {
					i1 = 2;
				}
			} else if( i1 == 3 ) {
				if( myself.i_ai3 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai3 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 3;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai3 < myself.i_ai4 ) {
					i1 = 3;
				}
			}
			switch(i1) {
				case 2: {
					myself.i_ai2 = gg::FloatToInt(( ( ( damage / 50.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai2 = attacker;
					break;
				}
				case 3: {
					myself.i_ai3 = gg::FloatToInt(( ( ( damage / 50.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai3 = attacker;
					break;
				}
				case 4: {
					myself.i_ai4 = gg::FloatToInt(( ( ( damage / 50.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai4 = attacker;
					break;
				}
			}
		} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
			if( attacker == myself.c_ai2 ) {
				if( myself.i_ai2 < ( ( ( damage / 100.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai2 = gg::FloatToInt(( ( ( damage / 100.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai3 ) {
				if( myself.i_ai3 < ( ( ( damage / 100.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai3 = gg::FloatToInt(( ( ( damage / 100.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( attacker == myself.c_ai4 ) {
				if( myself.i_ai4 < ( ( ( damage / 100.000000 ) * 1000 ) + 1000 ) ) {
					myself.i_ai4 = gg::FloatToInt(( ( ( damage / 100.000000 ) * 1000 ) + gg::Rand(3000) ));
				}
			} else if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 3;
			} else if( myself.i_ai2 == myself.i_ai3 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 3;
				}
			} else if( myself.i_ai2 < myself.i_ai3 ) {
				i1 = 2;
			}
			if( i1 == 2 ) {
				if( myself.i_ai2 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai2 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai2 < myself.i_ai4 ) {
					i1 = 2;
				}
			} else if( i1 == 3 ) {
				if( myself.i_ai3 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai3 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 3;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai3 < myself.i_ai4 ) {
					i1 = 3;
				}
			}
			switch(i1) {
				case 2: {
					myself.i_ai2 = gg::FloatToInt(( ( ( damage / 100.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai2 = attacker;
					break;
				}
				case 3: {
					myself.i_ai3 = gg::FloatToInt(( ( ( damage / 100.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai3 = attacker;
					break;
				}
				case 4: {
					myself.i_ai4 = gg::FloatToInt(( ( ( damage / 100.000000 ) * 1000 ) + gg::Rand(3000) ));
					myself.c_ai4 = attacker;
					break;
				}
			}
		} else if( attacker == myself.c_ai2 ) {
			if( myself.i_ai2 < ( ( ( damage / 150.000000 ) * 1000 ) + 1000 ) ) {
				myself.i_ai2 = gg::FloatToInt(( ( ( damage / 150.000000 ) * 1000 ) + gg::Rand(3000) ));
			}
		} else if( attacker == myself.c_ai3 ) {
			if( myself.i_ai3 < ( ( ( damage / 150.000000 ) * 1000 ) + 1000 ) ) {
				myself.i_ai3 = gg::FloatToInt(( ( ( damage / 150.000000 ) * 1000 ) + gg::Rand(3000) ));
			}
		} else if( attacker == myself.c_ai4 ) {
			if( myself.i_ai4 < ( ( ( damage / 150.000000 ) * 1000 ) + 1000 ) ) {
				myself.i_ai4 = gg::FloatToInt(( ( ( damage / 150.000000 ) * 1000 ) + gg::Rand(3000) ));
			}
		} else if( myself.i_ai2 > myself.i_ai3 ) {
			i1 = 3;
		} else if( myself.i_ai2 == myself.i_ai3 ) {
			if( gg::Rand(100) < 50 ) {
				i1 = 2;
			} else {
				i1 = 3;
			}
		} else if( myself.i_ai2 < myself.i_ai3 ) {
			i1 = 2;
		}
		if( i1 == 2 ) {
			if( myself.i_ai2 > myself.i_ai4 ) {
				i1 = 4;
			} else if( myself.i_ai2 == myself.i_ai4 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 4;
				}
			} else if( myself.i_ai2 < myself.i_ai4 ) {
				i1 = 2;
			}
		} else if( i1 == 3 ) {
			if( myself.i_ai3 > myself.i_ai4 ) {
				i1 = 4;
			} else if( myself.i_ai3 == myself.i_ai4 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 3;
				} else {
					i1 = 4;
				}
			} else if( myself.i_ai3 < myself.i_ai4 ) {
				i1 = 3;
			}
		}
		switch(i1) {
			case 2: {
				myself.i_ai2 = gg::FloatToInt(( ( ( damage / 150.000000 ) * 1000 ) + gg::Rand(3000) ));
				myself.c_ai2 = attacker;
				break;
			}
			case 3: {
				myself.i_ai3 = gg::FloatToInt(( ( ( damage / 150.000000 ) * 1000 ) + gg::Rand(3000) ));
				myself.c_ai3 = attacker;
				break;
			}
			case 4: {
				myself.i_ai4 = gg::FloatToInt(( ( ( damage / 150.000000 ) * 1000 ) + gg::Rand(3000) ));
				myself.c_ai4 = attacker;
				break;
			}
		}
		if( myself.sm.db_value == 3 && ( myself.p_state == 1 || myself.p_state == 0 ) ) {
			if( myself::DistFromMe(myself.c_ai2) > 9000 || myself.c_ai2.alive == 0 ) {
				myself.i_ai2 = 0;
			}
			if( myself::DistFromMe(myself.c_ai3) > 9000 || myself.c_ai3.alive == 0 ) {
				myself.i_ai3 = 0;
			}
			if( myself::DistFromMe(myself.c_ai4) > 9000 || myself.c_ai4.alive == 0 ) {
				myself.i_ai4 = 0;
			}
			if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 2;
				i2 = myself.i_ai2;
				c2 = myself.c_ai2;
			} else {
				i1 = 3;
				i2 = myself.i_ai3;
				c2 = myself.c_ai3;
			}
			if( myself.i_ai4 > i2 ) {
				i1 = 4;
				i2 = myself.i_ai4;
				c2 = myself.c_ai4;
			}
			if( i2 > 0 ) {
				if( gg::Rand(100) < 70 ) {
					switch(i1) {
						case 2: {
							myself.i_ai2 = 500;
							break;
						}
						case 3: {
							myself.i_ai3 = 500;
							break;
						}
						case 4: {
							myself.i_ai4 = 500;
							break;
						}
					}
				}
				if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 30 ) {
						myself::AddUseSkillDesire(c2,269352961,0,1,1000000);
					} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 10 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 7 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
				} else if( gg::Rand(100) < 3 ) {
					myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
				} else if( gg::Rand(100) < 6 ) {
					myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
				} else if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
					}
				} else {
					myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
				}
			}
		}
	}

	EventHandler SEE_CREATURE(creature,i1,i2,c2) {
		if( myself.sm.db_value == 3 && myself::IsInCategory(3,creature.occupation) ) {
			if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
				if( creature == myself.c_ai2 ) {
					if( myself.i_ai2 < ( ( 10 * 1000 ) + 1000 ) ) {
						myself.i_ai2 = gg::FloatToInt(( ( 10 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( creature == myself.c_ai3 ) {
					if( myself.i_ai3 < ( ( 10 * 1000 ) + 1000 ) ) {
						myself.i_ai3 = gg::FloatToInt(( ( 10 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( creature == myself.c_ai4 ) {
					if( myself.i_ai4 < ( ( 10 * 1000 ) + 1000 ) ) {
						myself.i_ai4 = gg::FloatToInt(( ( 10 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( myself.i_ai2 > myself.i_ai3 ) {
					i1 = 3;
				} else if( myself.i_ai2 == myself.i_ai3 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 3;
					}
				} else if( myself.i_ai2 < myself.i_ai3 ) {
					i1 = 2;
				}
				if( i1 == 2 ) {
					if( myself.i_ai2 > myself.i_ai4 ) {
						i1 = 4;
					} else if( myself.i_ai2 == myself.i_ai4 ) {
						if( gg::Rand(100) < 50 ) {
							i1 = 2;
						} else {
							i1 = 4;
						}
					} else if( myself.i_ai2 < myself.i_ai4 ) {
						i1 = 2;
					}
				} else if( i1 == 3 ) {
					if( myself.i_ai3 > myself.i_ai4 ) {
						i1 = 4;
					} else if( myself.i_ai3 == myself.i_ai4 ) {
						if( gg::Rand(100) < 50 ) {
							i1 = 3;
						} else {
							i1 = 4;
						}
					} else if( myself.i_ai3 < myself.i_ai4 ) {
						i1 = 3;
					}
				}
				switch(i1) {
					case 2: {
						myself.i_ai2 = gg::FloatToInt(( ( 10 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai2 = creature;
						break;
					}
					case 3: {
						myself.i_ai3 = gg::FloatToInt(( ( 10 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai3 = creature;
						break;
					}
					case 4: {
						myself.i_ai4 = gg::FloatToInt(( ( 10 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai4 = creature;
						break;
					}
				}
			} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
				if( creature == myself.c_ai2 ) {
					if( myself.i_ai2 < ( ( 6 * 1000 ) + 1000 ) ) {
						myself.i_ai2 = gg::FloatToInt(( ( 6 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( creature == myself.c_ai3 ) {
					if( myself.i_ai3 < ( ( 6 * 1000 ) + 1000 ) ) {
						myself.i_ai3 = gg::FloatToInt(( ( 6 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( creature == myself.c_ai4 ) {
					if( myself.i_ai4 < ( ( 6 * 1000 ) + 1000 ) ) {
						myself.i_ai4 = gg::FloatToInt(( ( 6 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( myself.i_ai2 > myself.i_ai3 ) {
					i1 = 3;
				} else if( myself.i_ai2 == myself.i_ai3 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 3;
					}
				} else if( myself.i_ai2 < myself.i_ai3 ) {
					i1 = 2;
				}
				if( i1 == 2 ) {
					if( myself.i_ai2 > myself.i_ai4 ) {
						i1 = 4;
					} else if( myself.i_ai2 == myself.i_ai4 ) {
						if( gg::Rand(100) < 50 ) {
							i1 = 2;
						} else {
							i1 = 4;
						}
					} else if( myself.i_ai2 < myself.i_ai4 ) {
						i1 = 2;
					}
				} else if( i1 == 3 ) {
					if( myself.i_ai3 > myself.i_ai4 ) {
						i1 = 4;
					} else if( myself.i_ai3 == myself.i_ai4 ) {
						if( gg::Rand(100) < 50 ) {
							i1 = 3;
						} else {
							i1 = 4;
						}
					} else if( myself.i_ai3 < myself.i_ai4 ) {
						i1 = 3;
					}
				}
				switch(i1) {
					case 2: {
						myself.i_ai2 = gg::FloatToInt(( ( 6 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai2 = creature;
						break;
					}
					case 3: {
						myself.i_ai3 = gg::FloatToInt(( ( 6 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai3 = creature;
						break;
					}
					case 4: {
						myself.i_ai4 = gg::FloatToInt(( ( 6 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai4 = creature;
						break;
					}
				}
			} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
				if( creature == myself.c_ai2 ) {
					if( myself.i_ai2 < ( ( 3 * 1000 ) + 1000 ) ) {
						myself.i_ai2 = gg::FloatToInt(( ( 3 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( creature == myself.c_ai3 ) {
					if( myself.i_ai3 < ( ( 3 * 1000 ) + 1000 ) ) {
						myself.i_ai3 = gg::FloatToInt(( ( 3 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( creature == myself.c_ai4 ) {
					if( myself.i_ai4 < ( ( 3 * 1000 ) + 1000 ) ) {
						myself.i_ai4 = gg::FloatToInt(( ( 3 * 1000 ) + gg::Rand(3000) ));
					}
				} else if( myself.i_ai2 > myself.i_ai3 ) {
					i1 = 3;
				} else if( myself.i_ai2 == myself.i_ai3 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 3;
					}
				} else if( myself.i_ai2 < myself.i_ai3 ) {
					i1 = 2;
				}
				if( i1 == 2 ) {
					if( myself.i_ai2 > myself.i_ai4 ) {
						i1 = 4;
					} else if( myself.i_ai2 == myself.i_ai4 ) {
						if( gg::Rand(100) < 50 ) {
							i1 = 2;
						} else {
							i1 = 4;
						}
					} else if( myself.i_ai2 < myself.i_ai4 ) {
						i1 = 2;
					}
				} else if( i1 == 3 ) {
					if( myself.i_ai3 > myself.i_ai4 ) {
						i1 = 4;
					} else if( myself.i_ai3 == myself.i_ai4 ) {
						if( gg::Rand(100) < 50 ) {
							i1 = 3;
						} else {
							i1 = 4;
						}
					} else if( myself.i_ai3 < myself.i_ai4 ) {
						i1 = 3;
					}
				}
				switch(i1) {
					case 2: {
						myself.i_ai2 = gg::FloatToInt(( ( 3 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai2 = creature;
						break;
					}
					case 3: {
						myself.i_ai3 = gg::FloatToInt(( ( 3 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai3 = creature;
						break;
					}
					case 4: {
						myself.i_ai4 = gg::FloatToInt(( ( 3 * 1000 ) + gg::Rand(3000) ));
						myself.c_ai4 = creature;
						break;
					}
				}
			} else if( creature == myself.c_ai2 ) {
				if( myself.i_ai2 < ( ( 2 * 1000 ) + 1000 ) ) {
					myself.i_ai2 = gg::FloatToInt(( ( 2 * 1000 ) + gg::Rand(3000) ));
				}
			} else if( creature == myself.c_ai3 ) {
				if( myself.i_ai3 < ( ( 2 * 1000 ) + 1000 ) ) {
					myself.i_ai3 = gg::FloatToInt(( ( 2 * 1000 ) + gg::Rand(3000) ));
				}
			} else if( creature == myself.c_ai4 ) {
				if( myself.i_ai4 < ( ( 2 * 1000 ) + 1000 ) ) {
					myself.i_ai4 = gg::FloatToInt(( ( 2 * 1000 ) + gg::Rand(3000) ));
				}
			} else if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 3;
			} else if( myself.i_ai2 == myself.i_ai3 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 3;
				}
			} else if( myself.i_ai2 < myself.i_ai3 ) {
				i1 = 2;
			}
			if( i1 == 2 ) {
				if( myself.i_ai2 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai2 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 2;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai2 < myself.i_ai4 ) {
					i1 = 2;
				}
			} else if( i1 == 3 ) {
				if( myself.i_ai3 > myself.i_ai4 ) {
					i1 = 4;
				} else if( myself.i_ai3 == myself.i_ai4 ) {
					if( gg::Rand(100) < 50 ) {
						i1 = 3;
					} else {
						i1 = 4;
					}
				} else if( myself.i_ai3 < myself.i_ai4 ) {
					i1 = 3;
				}
			}
			switch(i1) {
				case 2: {
					myself.i_ai2 = gg::FloatToInt(( ( 2 * 1000 ) + gg::Rand(3000) ));
					myself.c_ai2 = creature;
					break;
				}
				case 3: {
					myself.i_ai3 = gg::FloatToInt(( ( 2 * 1000 ) + gg::Rand(3000) ));
					myself.c_ai3 = creature;
					break;
				}
				case 4: {
					myself.i_ai4 = gg::FloatToInt(( ( 2 * 1000 ) + gg::Rand(3000) ));
					myself.c_ai4 = creature;
					break;
				}
			}
		} else if( creature == myself.c_ai2 ) {
			if( myself.i_ai2 < ( ( 1 * 1000 ) + 1000 ) ) {
				myself.i_ai2 = gg::FloatToInt(( ( 1 * 1000 ) + gg::Rand(3000) ));
			}
		} else if( creature == myself.c_ai3 ) {
			if( myself.i_ai3 < ( ( 1 * 1000 ) + 1000 ) ) {
				myself.i_ai3 = gg::FloatToInt(( ( 1 * 1000 ) + gg::Rand(3000) ));
			}
		} else if( creature == myself.c_ai4 ) {
			if( myself.i_ai4 < ( ( 1 * 1000 ) + 1000 ) ) {
				myself.i_ai4 = gg::FloatToInt(( ( 1 * 1000 ) + gg::Rand(3000) ));
			}
		} else if( myself.i_ai2 > myself.i_ai3 ) {
			i1 = 3;
		} else if( myself.i_ai2 == myself.i_ai3 ) {
			if( gg::Rand(100) < 50 ) {
				i1 = 2;
			} else {
				i1 = 3;
			}
		} else if( myself.i_ai2 < myself.i_ai3 ) {
			i1 = 2;
		}
		if( i1 == 2 ) {
			if( myself.i_ai2 > myself.i_ai4 ) {
				i1 = 4;
			} else if( myself.i_ai2 == myself.i_ai4 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 2;
				} else {
					i1 = 4;
				}
			} else if( myself.i_ai2 < myself.i_ai4 ) {
				i1 = 2;
			}
		} else if( i1 == 3 ) {
			if( myself.i_ai3 > myself.i_ai4 ) {
				i1 = 4;
			} else if( myself.i_ai3 == myself.i_ai4 ) {
				if( gg::Rand(100) < 50 ) {
					i1 = 3;
				} else {
					i1 = 4;
				}
			} else if( myself.i_ai3 < myself.i_ai4 ) {
				i1 = 3;
			}
		}
		switch(i1) {
			case 2: {
				myself.i_ai2 = gg::FloatToInt(( ( 1 * 1000 ) + gg::Rand(3000) ));
				myself.c_ai2 = creature;
				break;
			}
			case 3: {
				myself.i_ai3 = gg::FloatToInt(( ( 1 * 1000 ) + gg::Rand(3000) ));
				myself.c_ai3 = creature;
				break;
			}
			case 4: {
				myself.i_ai4 = gg::FloatToInt(( ( 1 * 1000 ) + gg::Rand(3000) ));
				myself.c_ai4 = creature;
				break;
			}
		}
		if( myself.sm.db_value == 3 && ( myself.p_state == 1 || myself.p_state == 0 ) ) {
			if( myself::DistFromMe(myself.c_ai2) > 9000 || myself.c_ai2.alive == 0 ) {
				myself.i_ai2 = 0;
			}
			if( myself::DistFromMe(myself.c_ai3) > 9000 || myself.c_ai3.alive == 0 ) {
				myself.i_ai3 = 0;
			}
			if( myself::DistFromMe(myself.c_ai4) > 9000 || myself.c_ai4.alive == 0 ) {
				myself.i_ai4 = 0;
			}
			if( myself.i_ai2 > myself.i_ai3 ) {
				i1 = 2;
				i2 = myself.i_ai2;
				c2 = myself.c_ai2;
			} else {
				i1 = 3;
				i2 = myself.i_ai3;
				c2 = myself.c_ai3;
			}
			if( myself.i_ai4 > i2 ) {
				i1 = 4;
				i2 = myself.i_ai4;
				c2 = myself.c_ai4;
			}
			if( i2 > 0 ) {
				if( gg::Rand(100) < 70 ) {
					switch(i1) {
						case 2: {
							myself.i_ai2 = 500;
							break;
						}
						case 3: {
							myself.i_ai3 = 500;
							break;
						}
						case 4: {
							myself.i_ai4 = 500;
							break;
						}
					}
				}
				if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 30 ) {
						myself::AddUseSkillDesire(c2,269352961,0,1,1000000);
					} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 10 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 7 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
					if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
						myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
					} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
						myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
					} else if( gg::Rand(100) < 6 ) {
						myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
					} else if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
					} else if( gg::Rand(100) < 5 ) {
						if( gg::Rand(100) < 50 ) {
							myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
						} else {
							myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
						}
					} else {
						myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
					}
				} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
				} else if( gg::Rand(100) < 3 ) {
					myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
				} else if( gg::Rand(100) < 6 ) {
					myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
				} else if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
					}
				} else {
					myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
				}
			}
		}
	}

	EventHandler USE_SKILL_FINISHED(skill_name_id,i1,i2,c2) {
		if( skill_name_id == 269221889 ) {
			myself::AddTimerEx(2000,( 7 * 1000 ));
		} else if( skill_name_id == 333709313 ) {
			myself::AddTimerEx(2002,( 7 * 1000 ));
		}
		if( myself::DistFromMe(myself.c_ai2) > 9000 || myself.c_ai2.alive == 0 ) {
			myself.i_ai2 = 0;
		}
		if( myself::DistFromMe(myself.c_ai3) > 9000 || myself.c_ai3.alive == 0 ) {
			myself.i_ai3 = 0;
		}
		if( myself::DistFromMe(myself.c_ai4) > 9000 || myself.c_ai4.alive == 0 ) {
			myself.i_ai4 = 0;
		}
		if( myself.i_ai2 > myself.i_ai3 ) {
			i1 = 2;
			i2 = myself.i_ai2;
			c2 = myself.c_ai2;
		} else {
			i1 = 3;
			i2 = myself.i_ai3;
			c2 = myself.c_ai3;
		}
		if( myself.i_ai4 > i2 ) {
			i1 = 4;
			i2 = myself.i_ai4;
			c2 = myself.c_ai4;
		}
		if( i2 > 0 ) {
			if( gg::Rand(100) < 70 ) {
				switch(i1) {
					case 2: {
						myself.i_ai2 = 500;
						break;
					}
					case 3: {
						myself.i_ai3 = 500;
						break;
					}
					case 4: {
						myself.i_ai4 = 500;
						break;
					}
				}
			}
			if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 4.000000 ) ) {
				if( gg::Rand(100) < 30 ) {
					myself::AddUseSkillDesire(c2,269352961,0,1,1000000);
				} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
				} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
				} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
					myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
				} else if( gg::Rand(100) < 10 ) {
					myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
				} else if( gg::Rand(100) < 6 ) {
					myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
				} else if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
					}
				} else {
					myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
				}
			} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 4.000000 ) ) {
				if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
				} else if( gg::Rand(100) < 40 && ( ( myself::DistFromMe(c2) < 850 && myself::GetDirection(c2) < ( 180 + 30 ) && myself::GetDirection(c2) > ( 180 - 30 ) ) || ( myself::DistFromMe(c2) < 425 && myself::GetDirection(c2) < ( 180 + 90 ) && myself::GetDirection(c2) > ( 180 - 90 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269287425,0,1,1000000);
				} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
					myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
				} else if( gg::Rand(100) < 7 ) {
					myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
				} else if( gg::Rand(100) < 6 ) {
					myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
				} else if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
					}
				} else {
					myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
				}
			} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 4.000000 ) ) {
				if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
					myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
				} else if( gg::Rand(100) < 10 && myself::DistFromMe(c2) < 1100 ) {
					myself::AddUseSkillDesire(myself.sm,269090817,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
				} else if( gg::Rand(100) < 6 ) {
					myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
				} else if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
				} else if( gg::Rand(100) < 5 ) {
					if( gg::Rand(100) < 50 ) {
						myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
					} else {
						myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
					}
				} else {
					myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
				}
			} else if( gg::Rand(100) < 80 && ( ( myself::DistFromMe(c2) < 1423 && myself::GetDirection(c2) < ( 180 + 8 ) && myself::GetDirection(c2) > ( 180 - 8 ) ) || ( myself::DistFromMe(c2) < 802 && myself::GetDirection(c2) < ( 180 + 14 ) && myself::GetDirection(c2) > ( 180 - 14 ) ) ) ) {
				myself::AddUseSkillDesire(myself.sm,269156353,0,1,1000000);
			} else if( gg::Rand(100) < 3 ) {
				myself::AddUseSkillDesire(c2,333774849,0,1,1000000);
			} else if( gg::Rand(100) < 6 ) {
				myself::AddUseSkillDesire(c2,269418497,0,1,1000000);
			} else if( gg::Rand(100) < 50 ) {
				myself::AddUseSkillDesire(c2,269484033,0,1,1000000);
			} else if( gg::Rand(100) < 5 ) {
				if( gg::Rand(100) < 50 ) {
					myself::AddUseSkillDesire(c2,269221889,0,1,1000000);
				} else {
					myself::AddUseSkillDesire(c2,333709313,0,1,1000000);
				}
			} else {
				myself::AddUseSkillDesire(c2,269549569,0,1,1000000);
			}
		}
	}

	EventHandler PARTY_DIED(private) {
		if( private != myself.sm ) {
			myself.i_quest4 = ( myself.i_quest4 - 1 );
		}
	}

	EventHandler MY_DYING(private) {
		myself::SpecialCamera(myself.sm,1200,20,-10,0,10000,13000,0,0,0,0,0);
		myself::EffectMusic(myself.sm,10000,"BS01_D");
		myself::SetDBValue(myself.sm,0);
		myself::UnregisterGlobalMap(GM_ID);
		myself::BroadcastScriptEventEx(12013,0,0,8000);
		myself::BroadcastScriptEventEx(12015,0,0,8000);
	}

}
