@LabelIndex 306014
@StringIndex 41589
class 0 magic_trader_cema : merchant_for_chaotic {
property:
	BuySellList SellList0 = {{"apprentice_s_staff";50};{"relic_of_saints";50};{"mage_staff";50};{"crucifix_of_blessing";50};{"voodoo_doll";50};{"bone_staff";50};{"scroll_of_wisdom";50};{"branch_of_life";50};{"proof_of_revenge";50};{"mace_of_prayer";50};{"doom_hammer";50};{"mystic_staff";50};{"staff_of_mana";50};{"divine_tome";50};{"sword_of_magic";50};{"sword_of_mystic";50};{"sword_of_occult";50};{"dagger_of_mana";50};{"mystic_knife";50};{"conjure_knife";50};{"knife_o__silenus";50};{"staff_of_magicpower";50};{"blood_of_saints";50};{"tome_of_blood";50};{"goathead_staff";50};{"crucifix_of_blood";50};{"demon_fangs";50};{"atuba_hammer";50};{"ghost_staff";50};{"life_stick";50};{"atuba_mace";50};{"hose_of_devotion";50};{"tunic_of_devotion";50};{"hose_of_magicpower";50};{"tunic_of_magicpower";50};{"cursed_hose";50};{"cursed_tunic";50};{"dark_hose";50};{"white_tunic";50};{"mage_s_hose";50};{"mage_s_tunic";50};{"hose_of_knowledge";50};{"tunic_of_knowledge";50};{"mithril_hose";50};{"mithril_tunic";50};{"sage_s_rag";50};{"round_shield";50};{"bone_shield";50};{"bronze_shield";50};{"aspis";50};{"hoplon";50};{"kite_shield";50};{"brigandine_shield";50};{"square_shield";50};{"plate_shield";50};{"leather_gloves";50};{"bracer";50};{"excellence_leather_gloves";50};{"leather_gauntlet";50};{"gauntlet";50};{"gauntlet_of_repose_of_the_soul";50};{"gloves_of_knowledge";50};{"elven_mithril_gloves";50};{"mithril_glove";50};{"ogre_power_gauntlet";50};{"sage_s_worn_gloves";50};{"low_boots";50};{"boots";50};{"leather_boots";50};{"blue_buckskin_boots";50};{"iron_boots";50};{"boots_of_power";50};{"boots_of_knowledge";50};{"elven_mithril_boots";50};{"assault_boots";50};{"slamander_skin_boots";50};{"plate_boots";50};{"leather_helmet";50};{"hard_leather_helmet";50};{"bone_helmet";50};{"bronze_helmet";50};{"helmet";50};{"brigandine_helmet";50};{"plate_helmet";50};{"cotton_shirt";50};{"linen_shirt";50};{"striped_cotton_shirt";50};{"striped_linen_shirt";50}};
	BuySellList SellList1 = {{"soulshot_none";50};{"spiritshot_none";50};{"blessed_spiritshot_none";50};{"comp_bspiritshot_none";50};{"comp_spiritshot_none";50};{"comp_soulshot_none";50};{"adv_comp_bspiritshot_none";50};{"adv_comp_spiritshot_none";50};{"adv_comp_soulshot_none";50};{"wooden_arrow";50};{"bone_arrow";50};{"fine_steel_arrow";50};{"lesser_healing_potion";50};{"healing_potion";50};{"antidote";50};{"advanced_antidote";50};{"bandage";50};{"emergency_dressing";50};{"quick_step_potion";50};{"swift_attack_potion";50};{"potion_of_acumen2";50};{"scroll_of_awake";50};{"scroll_of_escape";50};{"scroll_of_resurrection";50};{"scroll_of_escape_to_agit";50};{"scroll_of_escape_to_castle";50};{"energy_stone";50};{"key_of_thief";50};{"cursed_bone";50};{"bone_bolt";50};{"steel_bolt";50};{"a_bottle_of_souls";50};{"dice_heart";50};{"dice_spade";50};{"dice_clover";50};{"dice_diamond";50}};
	BuySellList SellList4 = {{"11610";50};{"11619";50};{"11612";50};{"11609";50};{"11627";50};{"11630";50};{"11634";50};{"11633";50};{"11637";50};{"11655";50};{"11656";50};{"11657";50};{"11662";50};{"11664";50};{"11672";50};{"11660";50};{"11663";50};{"11678";50};{"11676";50};{"11693";50};{"11709";50};{"11715";50};{"11732";50};{"11737";50};{"11729";50};{"11731";50};{"12011";50};{"12010";50};{"12017";50};{"12022";50};{"12019";50};{"12018";50};{"12048";50};{"12047";50};{"12058";50};{"12057";50};{"12083";50};{"12013";50};{"12025";50};{"12051";50};{"12069";50};{"12063";50};{"12073";50};{"12078";50};{"12007";50};{"12016";50};{"12038";50};{"12068";50};{"12046";50};{"12037";50};{"12055";50};{"12061";50};{"12072";50};{"12076";50};{"12082";50};{"12006";50};{"12029";50};{"12033";50};{"12070";50};{"12035";50};{"12045";50};{"12053";50};{"12062";50};{"12071";50};{"12075";50};{"12077";50};{"12009";50};{"12028";50};{"12050";50};{"12064";50};{"12079";50}};

handler:
	EventHandler TALK_SELECTED(fhtml0,talker) {
		if( _from_choice == 0 ) {
			if( gg::HaveMemo(talker,343) == 0 ) {
				_choiceN = ( _choiceN + 1 );
				_code = 0;
				myself::AddChoice(0,"Under the Shadow of the Ivory Tower");
			}
			if( gg::HaveMemo(talker,343) == 1 && gg::OwnItemCount(talker,4364) < 1 && myself::IsInCategory(2,talker.occupation) ) {
				_choiceN = ( _choiceN + 1 );
				_code = 1;
				myself::AddChoice(1,"Under the Shadow of the Ivory Tower (In Progress)");
			}
			if( gg::HaveMemo(talker,343) == 1 && gg::OwnItemCount(talker,4364) >= 1 && myself::IsInCategory(2,talker.occupation) ) {
				_choiceN = ( _choiceN + 1 );
				_code = 2;
				myself::AddChoice(2,"Under the Shadow of the Ivory Tower (In Progress)");
			}
			if( _choiceN > 1 ) {
				myself::ShowChoicePage(talker,1);
				return;
			}
		}
		if( _from_choice || _choiceN == 1 ) {
			switch(_code) {
				case 0: {
					if( _from_choice == 0 || gg::HaveMemo(talker,343) == 0 ) {
						myself::SetCurrentQuestID(343);
						if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) ) {
							myself::ShowSystemMessage(talker,1118);
							return;
						}
						if( myself::GetMemoCount(talker) < 26 ) {
							if( myself::IsInCategory(2,talker.occupation) == 0 ) {
								myself::ShowQuestPage(talker,"magic_trader_cema_q0343_01.htm",343);
							} else if( myself::IsInCategory(2,talker.occupation) && talker.level < 40 ) {
								myself::ShowQuestPage(talker,"magic_trader_cema_q0343_02.htm",343);
							} else if( myself::IsInCategory(2,talker.occupation) && talker.level >= 40 ) {
								myself::ShowQuestPage(talker,"magic_trader_cema_q0343_03.htm",343);
							}
						} else {
							myself::ShowPage(talker,"fullquest.htm");
						}
					}
					break;
				}
				case 1: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,343) == 1 && gg::OwnItemCount(talker,4364) < 1 && myself::IsInCategory(2,talker.occupation) ) ) {
						myself::SetCurrentQuestID(343);
						if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) ) {
							myself::ShowSystemMessage(talker,1118);
							return;
						}
						myself::ShowPage(talker,"magic_trader_cema_q0343_06.htm");
					}
					break;
				}
				case 2: {
					if( _from_choice == 0 || ( gg::HaveMemo(talker,343) == 1 && gg::OwnItemCount(talker,4364) >= 1 && myself::IsInCategory(2,talker.occupation) ) ) {
						myself::SetCurrentQuestID(343);
						if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) ) {
							myself::ShowSystemMessage(talker,1118);
							return;
						}
						myself::ShowPage(talker,"magic_trader_cema_q0343_07.htm");
					}
					break;
				}
			}
			return;
		}
		super;
	}

	EventHandler QUEST_ACCEPTED(quest_id,talker) {
		if( quest_id == 343 ) {
			myself::SetCurrentQuestID(343);
			if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) ) {
				myself::ShowSystemMessage(talker,1118);
				return;
			}
			if( gg::HaveMemo(talker,343) == 0 && myself::IsInCategory(2,talker.occupation) && talker.level >= 40 ) {
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::SetMemo(talker,quest_id);
					myself::ShowQuestMark(talker,343);
					myself::SetMemoState(talker,343,1);
					myself::SetMemoStateEx(talker,343,1,0);
					gg::AddLog(1,talker,343);
					myself::SetFlagJournal(talker,343,1);
					myself::SoundEffect(talker,"ItemSound.quest_accept");
					myself::ShowQuestPage(talker,"magic_trader_cema_q0343_05.htm",343);
				}
			}
			return;
		}
		super;
	}

	EventHandler MENU_SELECTED(ask,fhtml0,reply,talker) {
		if( ask == 343 ) {
			myself::SetCurrentQuestID(343);
			if( myself::GetInventoryInfo(talker,0) >= ( myself::GetInventoryInfo(talker,1) * 0.800000 ) || myself::GetInventoryInfo(talker,2) >= ( myself::GetInventoryInfo(talker,3) * 0.800000 ) ) {
				myself::ShowSystemMessage(talker,1118);
				return;
			}
		}
		if( ask == 343 && myself::IsInCategory(2,talker.occupation) ) {
			if( reply == 1 ) {
				if( gg::HaveMemo(talker,343) == 0 && myself::IsInCategory(2,talker.occupation) && talker.level >= 40 ) {
					myself::FHTML_SetFileName(fhtml0,"magic_trader_cema_q0343_04.htm");
					myself::FHTML_SetInt(fhtml0,"quest_id",343);
					myself::ShowQuestFHTML(talker,fhtml0,343);
				}
			}
			if( reply == 2 ) {
				if( gg::HaveMemo(talker,343) == 1 ) {
					if( gg::OwnItemCount(talker,4364) >= 1 ) {
						if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
							talker.quest_last_reward_time = myself::GetCurrentTick();
							myself::GiveItem1(talker,57,( gg::OwnItemCount(talker,4364) * 120 ));
							myself::DeleteItem1(talker,4364,gg::OwnItemCount(talker,4364));
							gg::AddLog(3,talker,343);
							myself::ShowPage(talker,"magic_trader_cema_q0343_08.htm");
						}
					} else {
						myself::ShowPage(talker,"magic_trader_cema_q0343_08a.htm");
					}
				}
			}
			if( reply == 3 ) {
				if( gg::HaveMemo(talker,343) == 1 ) {
					myself::ShowPage(talker,"magic_trader_cema_q0343_09.htm");
				}
			}
			if( reply == 4 ) {
				myself::ShowPage(talker,"magic_trader_cema_q0343_10.htm");
			}
			if( reply == 5 ) {
				myself::ShowPage(talker,"magic_trader_cema_q0343_11.htm");
				myself::RemoveMemo(talker,343);
				gg::AddLog(2,talker,343);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
			}
			if( reply == 6 ) {
				if( gg::OwnItemCount(talker,4364) >= 10 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,734,1);
						myself::DeleteItem1(talker,4364,10);
						gg::AddLog(3,talker,343);
						myself::ShowPage(talker,"magic_trader_cema_q0343_12.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
			if( reply == 7 ) {
				if( gg::OwnItemCount(talker,4364) >= 15 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,737,1);
						myself::DeleteItem1(talker,4364,15);
						gg::AddLog(3,talker,343);
						myself::ShowPage(talker,"magic_trader_cema_q0343_13.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
			if( reply == 8 ) {
				if( gg::OwnItemCount(talker,4364) >= 20 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,735,1);
						myself::DeleteItem1(talker,4364,20);
						gg::AddLog(3,talker,343);
						myself::ShowPage(talker,"magic_trader_cema_q0343_14.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
			if( reply == 9 ) {
				if( gg::OwnItemCount(talker,4364) >= 20 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,2508,10);
						myself::DeleteItem1(talker,4364,20);
						gg::AddLog(3,talker,343);
						myself::ShowPage(talker,"magic_trader_cema_q0343_15.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
			if( reply == 10 ) {
				if( gg::OwnItemCount(talker,4364) >= 100 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,956,1);
						myself::DeleteItem1(talker,4364,100);
						gg::AddLog(3,talker,343);
						myself::ShowPage(talker,"magic_trader_cema_q0343_16.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
			if( reply == 11 ) {
				if( gg::OwnItemCount(talker,4364) >= 400 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,952,1);
						myself::DeleteItem1(talker,4364,400);
						gg::AddLog(3,talker,343);
						myself::ShowPage(talker,"magic_trader_cema_q0343_17.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
			if( reply == 12 ) {
				if( gg::OwnItemCount(talker,4364) >= 200 ) {
					if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 ) {
						talker.quest_last_reward_time = myself::GetCurrentTick();
						myself::GiveItem1(talker,4365,1);
						myself::DeleteItem1(talker,4364,200);
						myself::ShowPage(talker,"magic_trader_cema_q0343_18.htm");
					}
				} else {
					myself::ShowPage(talker,"magic_trader_cema_q0343_19.htm");
				}
			}
		}
		super;
	}

}
