@LabelIndex 23671
@StringIndex 0
class 0 ai_boss07_valakas_decide_action : ai_boss07_valakas_set_db {
parameter:
	waypointstype	FleePoints;
	waypointstype	PrivatePosList1;
	waypointstype	PrivatePosList2;

handler:
	EventHandler CREATED(reply) {
		super;
		myself.i_ai3 = 0;
		myself.i_ai4 = 0;
		myself.i_quest0 = 0;
		myself.i_quest1 = myself::GetCurrentTick();
		if( myself.sm.db_value == 3 ) {
			myself::AddMoveAroundDesire(5,5);
			myself::AddTimerEx(1002,( 60 * 1000 ));
		}
	}

	EventHandler ATTACKED(attacker,damage,i0,i1,plist0,pos0) {
		super;
		if( myself.sm.db_value == 0 && myself.sm.alive == 1 && attacker.is_pc == 1 ) {
			myself::InstantTeleport(attacker,150037,-57255,-2976);
		}
		myself.i_quest1 = myself::GetCurrentTick();
		myself.i_ai4 = ( myself.i_ai4 + damage );
		if( myself::GetDirection(attacker) > ( 180 - 30 ) && myself::GetDirection(attacker) < ( 180 + 30 ) ) {
			if( myself.i_quest0 == 0 ) {
				myself.i_ai3 = ( myself.i_ai3 + damage );
			}
		}
		if( myself.i_quest0 == 0 ) {
			if( gg::FloatToInt(( ( myself.i_ai4 / myself.sm.max_hp ) * 100 )) > 1 ) {
				if( myself.i_ai3 > ( myself.i_ai4 / 2 ) ) {
					myself.i_ai3 = 0;
					myself.i_ai4 = 0;
					if( myself::Skill_GetConsumeMP(ReadyRearAttack) < myself.sm.mp && myself::Skill_GetConsumeHP(ReadyRearAttack) < myself.sm.hp && myself::Skill_InReuseDelay(ReadyRearAttack) == 0 ) {
						myself::AddUseSkillDesire(myself.sm,ReadyRearAttack,1,1,1000000);
					}
					myself.i_quest0 = 1;
				}
			}
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0,maker0) {
		super;
		if( timer_id == 1002 ) {
			if( myself.sm.db_value == 3 ) {
				if( ( myself::GetCurrentTick() - myself.i_quest1 ) > ( 15 * 60 ) ) {
					myself::MPCC_SetMasterPartyRouting(myself.int_list::Get(0),myself.sm,0);
					myself.int_list::Clear();
					myself::SetDBValue(myself.sm,0);
					myself::RemoveAllDesire();
					myself::StopMove();
					myself::InstantTeleportInMyTerritory(150037,-57255,-2976,150);
					myself::InstantTeleport(myself.sm,-105200,-253104,-15264);
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 1.000000 ) / 5.000000 ) ) {
					if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(307429381)) < 15 ) {
						myself::AddUseSkillDesire(myself.sm,307429381,0,1,100000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 2.000000 ) / 5.000000 ) ) {
					if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(307429380)) < 14 ) {
						myself::AddUseSkillDesire(myself.sm,307429380,0,1,100000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 3.000000 ) / 5.000000 ) ) {
					if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(307429379)) < 13 ) {
						myself::AddUseSkillDesire(myself.sm,307429379,0,1,100000000);
					}
				} else if( myself.sm.hp < ( ( myself.sm.max_hp * 4.000000 ) / 5.000000 ) ) {
					if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(307429378)) < 12 ) {
						myself::AddUseSkillDesire(myself.sm,307429378,0,1,100000000);
					}
				} else if( gg::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(307429377)) < 11 ) {
					myself::AddUseSkillDesire(myself.sm,307429377,0,1,100000000);
				}
				myself::AddTimerEx(1002,( 60 * 1000 ));
			}
		}
	}

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

}
