@LabelIndex 107814
@StringIndex 0
class 0 barler_private_demonic_jail : warrior_use_skill {
parameter:

handler:
	EventHandler CREATED(party0,i0,i1,c0) {
		myself.i_ai0 = 0;
		myself.i_ai1 = 0;
		myself.i_ai2 = 0;
		super;
	}

	EventHandler ATTACKED(attacker,damage) {
		if( myself.i_ai2 == 0 ) {
			myself.i_ai1 = myself::GetTick();
			myself.i_ai2 = 1;
			myself::AddTimerEx(1100,( 60 * 1000 ));
			myself::BroadcastScriptEventEx(13026,gg::GetIndexFromCreature(attacker),0,3000);
		}
		super;
	}

	EventHandler SEE_CREATURE(creature) {
		if( myself.i_ai2 == 0 ) {
			myself.i_ai1 = myself::GetTick();
			myself.i_ai2 = 1;
			myself::AddTimerEx(1100,( 60 * 1000 ));
			myself::BroadcastScriptEventEx(13026,gg::GetIndexFromCreature(creature),0,3000);
		}
		if( creature.is_pc == 0 && myself::IsInCategory(12,creature.class_id) == 0 ) {
			return;
		}
		if( myself::GetLifeTime() > SeeCreatureAttackerTime && myself::InMyTerritory(myself.sm) ) {
			myself::AddAttackDesire(creature,1,200);
		}
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id,i0) {
		if( timer_id == 1100 ) {
			if( ( myself::GetTick() - myself.i_ai1 ) >= ( 60 * 1000 ) ) {
				myself::BroadcastScriptEvent(13021,0,3000);
				i0 = gg::Rand(100);
				if( i0 < 25 ) {
					myself::InstantTeleportInMyTerritory(153565,141290,-12736,500);
				} else if( i0 < 50 ) {
					myself::InstantTeleportInMyTerritory(153570,142853,-12736,500);
				} else if( i0 < 75 ) {
					myself::InstantTeleportInMyTerritory(152793,142080,-12736,500);
				} else {
					myself::InstantTeleportInMyTerritory(154359,142077,-12736,500);
				}
				myself::Despawn();
			} else {
				myself::AddTimerEx(1100,( 10 * 1000 ));
			}
		}
		super;
	}

	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2,c0) {
		if( script_event_arg1 == 13020 ) {
			c0 = gg::GetCreatureFromIndex(script_event_arg2);
			if( myself::IsNullCreature(c0) == 0 ) {
				if( myself.sm != c0 ) {
					myself.i_ai0 = 1;
				}
			}
		}
	}

	EventHandler MY_DYING(party0,i0,i1,i2,c0) {
		myself::BroadcastScriptEvent(13021,0,3000);
		myself::BroadcastScriptEvent(13020,gg::GetIndexFromCreature(myself.sm),1000);
		if( myself.i_ai0 == 1 ) {
			i0 = gg::Rand(100);
			if( i0 < 25 ) {
				myself::InstantTeleportInMyTerritory(153565,141290,-12736,500);
			} else if( i0 < 50 ) {
				myself::InstantTeleportInMyTerritory(153570,142853,-12736,500);
			} else if( i0 < 75 ) {
				myself::InstantTeleportInMyTerritory(152793,142080,-12736,500);
			} else {
				myself::InstantTeleportInMyTerritory(154359,142077,-12736,500);
			}
		}
		super;
	}

}
