@LabelIndex 68607
@StringIndex 10887
class 0 ai_boss04_heart_of_warding : default_npc {
handler:
	EventHandler CREATED() {
		myself.i_ai0 = 0;
		myself.i_ai1 = 0;
	}

	EventHandler TALKED(talker) {
		myself::ShowPage(talker,"heart_of_warding001.htm");
	}

	EventHandler TELEPORT_REQUESTED(talker,i0,c0,c1,c2,i1,i2,c3,c4,c5,c6,i3,i4,i5,i6,i7,i8) {
		i3 = myself::MPCC_GetMPCCId(talker);
		i5 = myself::GetGlobalMap(1);
		i6 = myself::GetGlobalMap(9);
		i7 = myself::GetGlobalMap(10);
		c4 = gg::GetCreatureFromIndex(i5);
		c1 = gg::GetCreatureFromIndex(i6);
		c2 = gg::GetCreatureFromIndex(i7);
		i4 = myself::MPCC_GetMemberCount(i3);
		if( i5 != -1 && i6 != -1 && i7 != -1 ) {
			if( myself::IsNullCreature(c1) == 0 && myself::IsNullCreature(c2) == 0 && myself::IsNullCreature(c4) == 0 ) {
				if( c4.alive == 1 && c1.alive == 1 && c2.alive == 1 ) {
					if( ( ( c4.db_value == 0 || ( c4.db_value == 1 && c1.db_value == 0 ) ) || ( c1.db_value == 1 && c2.db_value == 0 ) ) || c2.db_value == 1 ) {
						if( c4.db_value == 2 || c4.db_value == 3 ) {
							myself::ShowPage(talker,"heart_of_warding003.htm");
							return;
						}
						if( c1.db_value == 2 || c1.db_value == 3 ) {
							myself::ShowPage(talker,"heart_of_warding003.htm");
							return;
						}
						if( c2.db_value == 2 || c2.db_value == 3 ) {
							myself::ShowPage(talker,"heart_of_warding003.htm");
							return;
						}
						c3 = myself::MPCC_GetMaster(i3);
						if( talker != c3 ) {
							if( gg::OwnItemCount(talker,3865) > 0 ) {
								myself::DeleteItem1(talker,3865,1);
								i1 = ( 179700 + gg::Rand(700) );
								i2 = ( 113800 + gg::Rand(2100) );
								myself::InstantTeleport(talker,i1,i2,-7709);
								if( i4 == 0 ) {
									i8 = 1;
								}
								gg::SendScriptEvent(c4,12012,i8);
								gg::SendScriptEvent(c1,12012,i8);
								gg::SendScriptEvent(c2,12012,i8);
							} else {
								myself::ShowPage(talker,"heart_of_warding004.htm");
							}
						} else {
							i4 = myself::MPCC_GetMemberCount(i3);
							if( talker.builder_level > 0 && talker.builder_level <= 1 && i4 >= 1 ) {
								myself::InstantTeleportMPCC(talker,179700,113800,-7709,1000,200,500,3865,1);
								return;
							}
							if( gg::OwnItemCount(talker,3865) <= 0 ) {
								myself::ShowPage(talker,"heart_of_warding004.htm");
								return;
							}
							myself::InstantTeleportMPCC(talker,179700,113800,-7709,1000,200,500,3865,1);
						}
					} else if( c4.db_value == 2 || c4.db_value == 3 || c1.db_value == 2 || c1.db_value == 3 || c2.db_value == 2 || c2.db_value == 3 ) {
						myself::ShowPage(talker,"heart_of_warding003.htm");
					}
				} else {
					myself::ShowPage(talker,"heart_of_warding002.htm");
				}
			}
		} else {
			myself::ShowPage(talker,"heart_of_warding002.htm");
		}
	}

	EventHandler MPCC_TELEPORTED(talker,reply,c0,c1,i0,i1,i5,i6,i7,c2,c3,c4) {
		i5 = myself::GetGlobalMap(1);
		i6 = myself::GetGlobalMap(9);
		i7 = myself::GetGlobalMap(10);
		if( i5 != -1 ) {
			c2 = gg::GetCreatureFromIndex(i5);
		} else {
			return;
		}
		if( i6 != -1 ) {
			c3 = gg::GetCreatureFromIndex(i6);
		} else {
			return;
		}
		if( i7 != -1 ) {
			c4 = gg::GetCreatureFromIndex(i7);
		} else {
			return;
		}
		if( myself::IsNullCreature(c2) == 1 || myself::IsNullCreature(c3) == 1 || myself::IsNullCreature(c4) == 1 ) {
			return;
		}
		gg::SendScriptEvent(c2,12012,reply);
		gg::SendScriptEvent(c3,12012,reply);
		gg::SendScriptEvent(c4,12012,reply);
		i1 = myself::MPCC_GetMPCCId(talker);
		c1 = myself::MPCC_GetMaster(i1);
		if( talker != c1 ) {
		} else if( talker.builder_level > 0 && talker.builder_level <= 1 && reply >= 1 ) {
			gg::SendScriptEvent(c2,99999999,i1);
			gg::SendScriptEvent(c3,99999999,i1);
			gg::SendScriptEvent(c4,99999999,i1);
			return;
		}
		if( reply >= 225 ) {
			gg::SendScriptEvent(c2,99999999,i1);
			gg::SendScriptEvent(c3,99999999,i1);
			gg::SendScriptEvent(c4,99999999,i1);
		}
	}

}
