class 1 gmshop : merchant
{
parameter:
	string	fnAfterBuff = "gmshopbuff.htm";
	string	fnAfterBuffDS = "gmshopbuffds.htm";
	string	fnAfterBuffSummon = "gmshopbuffsummon.htm";
	string	fnAfterBuffSummonDS = "gmshopbuffsummonds.htm";
	string	fnNotEnoughMP = "gmshopnotenoughmp.htm";
	string	fnNeedCoolTime = "gmshopneedcooltime.htm";
	string	fnNeedSummon = "gmshopneedsummon.htm";
	string	fnNeedPledgeMaster = "gmshopneedpm.htm";
	int	WyvernPrice = 1;
	int	ClassChange1Currency = 57;
	int	ClassChange2Currency = 57;
	int	ClassChange3Currency = 57;
	int	ClassChange1Amount = 1000;
	int	ClassChange2Amount = 50000;
	int	ClassChange3Amount = 1000000;
	int	NoblessCurrency = 57;
	int	NoblessAmount = 100000000;
	int	SubClassCurrency = 57;
	int	SubClassAmount = 1000000;
	int	OffTradeCurrency = 57;
	int	OffTradeAmount = 10000;
	int	BuffCurrency = 57;
	int	BuffAmount = 50000;
	int	PKCurrency = 57;
	int	PKAmount = 50000000;
	int	CRPCurrency = 57;
	int	CRPAmount = 50000000;
	int	RecoverCPCurrency = 57;
	int	RecoverCPAmount = 10000;
	int	OffTradeSkill = 5632001;
	int	CongratulationsSkill = 1110785;
	int	MPRegenSkill = 1120001;
	int	RecoverCPSkill = 1121281;

property:
	BuySellList SellList0 = {{"q_ketra_friendship_2";20};{"q_barka_friendship_2";20};{"q_proof_of_aspiration";20};{"q_proof_of_alliance";20};{"forgotten_scroll_protection_of_rune";20};{"forgotten_scroll_protection_of_elemental";20};{"forgotten_scroll_protection_of_alignment";20};{"forgotten_scroll_fighter_s_will";20};{"forgotten_scroll_archer_s_will";20};{"forgotten_scroll_anti_magic_armor";20};{"forgotten_scroll_seed_of_revenge";20};{"forgotten_scroll_hell_scream";20};{"forgotten_scroll_song_of_windstorm";20};{"forgotten_scroll_dance_of_blade_storm";20};{"forgotten_scroll_sixth_sense";20};{"forgotten_scroll_expose_weak_point";20};{"forgotten_scroll_exciting_adventure";20};{"forgotten_scroll_wind_riding";20};{"forgotten_scroll_ghost_walking";20};{"forgotten_scroll_flame_hawk";20};{"forgotten_scroll_arrow_rain";20};{"forgotten_scroll_ghost_piercing";20};{"forgotten_scroll_dread_pool";20};{"forgotten_scroll_weapon_blockade";20};{"forgotten_scroll_force_of_destruction";20};{"forgotten_scroll_demolition_impact";20};{"forgotten_scroll_golem_armor";20};{"forgotten_scroll_flame_armor";20};{"forgotten_scroll_frost_armor";20};{"forgotten_scroll_hurricane_armor";20};{"forgotten_scroll_vampiric_mist";20};{"forgotten_scroll_servitor_barrier";20};{"forgotten_scroll_excessive_loyalty";20};{"forgotten_scroll_mutual_response";20};{"forgotten_scroll_improve_combat";20};{"forgotten_scroll_improve_magic";20};{"forgotten_scroll_improve_condition";20};{"forgotten_scroll_improve_critical_attack";20};{"forgotten_scroll_improve_shield_defense";20};{"forgotten_scroll_improve_movement";20};{"forgotten_scroll_sublime_self_sacrifice";20};{"forgotten_scroll_blessing_of_eva";20};{"forgotten_scroll_lord_of_vampire";20};{"forgotten_scroll_throne_root";20};{"forgotten_scroll_seal_of_limit";20};{"forgotten_scroll_summon_smart_cubic";20};{"forgotten_scroll_spirit_of_phoenix";20};{"forgotten_scroll_eva_s_will";20};{"forgotten_scroll_pain_of_shilen";20};{"forgotten_scroll_wild_shot";20};{"forgotten_scroll_lightning_shock";20};{"amulet_chant_of_combat";20};{"amulet_chant_of_critical_attack";20};{"amulet_chant_of_blood_awakening";20}};
	BuySellList SellList1 = {{"wedding_dress";20};{"party_mask";20};{"wings_of_destiny_circlet";20};{"eye_bandage_of_pirate";20};{"monocle";20};{"taiwan_hair_accessory";20};{"ad_tateossian";20};{"outlaw_eyepatch";20};{"guide_mask_goldline_white";20};{"guide_mask_goldline_black";20};{"raid_challenger_s_circlet";20};{"raid_adventurer_s_circlet";20};{"raid_master_s_circlet";20};{"circlet_of_ice_fairy_sirra";20};{"mask_of_spirits";20};{"eva_mark";20};{"event_iron_circlet";20};{"valakas_slayer_circlet";20};{"antharas_slayer_circlet";20};{"half_face_mask";20};{"event_black_half_mask";20};{"eye_patch";20};{"scar";20};{"cat_ear";20};{"hair_pin_of_lady";20};{"racoon_ear";20};{"maidens_hairpin";20};{"rabbit_ear";20};{"forget_me_not_hairpin";20};{"daisy_hairpin";20};{"santas_cap";20};{"party_hat";20};{"feathered_hat";20};{"artisan_s_goggles";20};{"demon_horns";20};{"little_angel_wing";20};{"fairy_antennae";20};{"blue_party_hat";20};{"teddy_bear_hat";20};{"diadem";20};{"piggy_hat";20};{"jester_hat";20};{"wizard_hat";20};{"dapper_cap";20};{"romantic_chapeau";20};{"event_black_feather_mask";20};{"single_stem_flower";20};{"butterfly_hairpin";20};{"luxurious_gold_circlet";20};{"luxurious_silver_circlet";20};{"goddess_circlet";20};{"m_era_leather_cap";20};{"first_mate_hat";20};{"angel_halo";20};{"demon_circlet";20};{"pirate_hat";20};{"santa_antlers";20}};
	BuySellList SellList4 = {{"dye_d3s4_c";20};{"dye_d3c4_c";20};{"dye_i3m4_c";20};{"dye_i3w4_c";20};{"dye_m3i4_c";20};{"dye_m3w4_c";20};{"dye_w3i4_c";20};{"dye_w3m4_c";20};{"dye_s1c1_c";20};{"dye_s1d1_c";20};{"dye_c1s1_c";20};{"dye_c1c1_c";20};{"dye_d1s1_c";20};{"dye_d1c1_c";20};{"dye_i1m1_c";20};{"dye_i1w1_c";20};{"dye_m1i1_c";20};{"dye_m1w1_c";20};{"dye_w1i1_c";20};{"dye_w1m1_c";20};{"dye_s4c6_c";20};{"dye_s4d6_c";20};{"dye_c4s6_c";20};{"dye_c4c6_c";20};{"dye_d4s6_c";20};{"dye_d4c6_c";20};{"dye_i4m6_c";20};{"dye_i4w6_c";20};{"dye_m4i6_c";20};{"dye_m4w6_c";20};{"dye_w4i6_c";20};{"dye_w4m6_c";20};{"dye_s4c5_c";20};{"dye_s4d5_c";20};{"dye_c4s5_c";20};{"dye_c4c5_c";20};{"dye_d4s5_c";20};{"dye_d4c5_c";20};{"dye_i4m5_c";20};{"dye_i4w5_c";20};{"dye_m4i5_c";20};{"dye_m4w5_c";20};{"dye_w4i5_c";20};{"dye_w4m5_c";20};{"dye_s2c2_c";20};{"dye_s2d2_c";20};{"dye_c2s2_c";20};{"dye_c2c2_c";20};{"dye_d2s2_c";20};{"dye_d2c2_c";20};{"dye_i2m2_c";20};{"dye_i2w2_c";20};{"dye_m2i2_c";20};{"dye_m2w2_c";20};{"dye_w2i2_c";20};{"dye_w2m2_c";20};{"dye_s3c3_c";20};{"dye_s3d3_c";20};{"dye_c3s3_c";20};{"dye_c3c3_c";20};{"dye_d3s3_c";20};{"dye_d3c3_c";20};{"dye_i3m3_c";20};{"dye_i3w3_c";20};{"dye_m3i3_c";20};{"dye_m3w3_c";20};{"dye_w3i3_c";20};{"dye_w3m3_c";20};{"dye_s4c4_c";20};{"dye_s4d4_c";20};{"dye_c4s4_c";20};{"dye_c4c4_c";20};{"dye_d4s4_c";20};{"dye_d4c4_c";20};{"dye_i4m4_c";20};{"dye_i4w4_c";20};{"dye_m4i4_c";20};{"dye_m4w4_c";20};{"dye_w4i4_c";20};{"dye_w4m4_c";20}};

handler:
	EventHandler CREATED()
	{
		myself::AddTimerEx(1077,1000);
		super;
	}

	EventHandler TIMER_FIRED_EX(timer_id)
	{
		if( timer_id == 1077 )
		{
			if( myself::Skill_GetConsumeMP(MPRegenSkill) < myself.sm.mp && myself::Skill_GetConsumeHP(MPRegenSkill) < myself.sm.hp && myself::Skill_InReuseDelay(MPRegenSkill) == 0 )
			{
				myself::AddUseSkillDesire(myself.sm,MPRegenSkill,1,1,1000000);
			}
			myself::AddTimerEx(1077,300000);
		}
		super;
	}

	EventHandler MENU_SELECTED(talker,ask,reply,i0,c0,fhtml0)
	{
		if( ask == -208 || ask == -209 || ask == -210 || ask == -211 )
		{
			if( myself::OwnItemCount(talker,BuffCurrency) < BuffAmount )
			{
				myself::ShowSystemMessage(talker,279);
				return;
			}
			if( myself::Skill_GetConsumeMP(reply) >= myself.sm.mp )
			{
				myself::ShowPage(talker,fnNotEnoughMP);
				return;
			}
			if( myself::Skill_InReuseDelay(reply) != 0 )
			{
				myself::ShowPage(talker,fnNeedCoolTime);
				return;
			}
			c0 = talker;
			if( ask == -210 || ask == -211 )
			{
				c0 = myself::GetSummon(talker);
				if( c0 )
				{
				}
				else
				{
					myself::ShowPage(talker,fnNeedSummon);
					return;
				}
			}
			myself::AddUseSkillDesire(c0,reply,1,0,1000000);
			if( ask == -208 )
			{
				myself::ShowPage(talker,fnAfterBuff);
			}
			else if( ask == -209 )
			{
				myself::ShowPage(talker,fnAfterBuffDS);
			}
			else if( ask == -210 )
			{
				myself::ShowPage(talker,fnAfterBuffSummon);
			}
			else if( ask == -211 )
			{
				myself::ShowPage(talker,fnAfterBuffSummonDS);
			}
		}
		else if( ask == -700 && reply == 1 )
		{
			if( myself::OwnItemCount(talker,OffTradeCurrency) < OffTradeAmount )
			{
				myself::ShowSystemMessage(talker,279);
				return;
			}
			if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
			{
				talker.quest_last_reward_time = myself::GetCurrentTick();
				myself::AddUseSkillDesire(talker,OffTradeSkill,0,0,1000000);
			}
		}
		else if( ask == -700 && reply == 2 )
		{
			if( talker.level >= 75 )
			{
				if( myself::OwnItemCount(talker,SubClassCurrency) < SubClassAmount )
				{
					myself::ShowSystemMessage(talker,279);
					return;
				}
				i0 = 235;
				if( myself::IsInCategory(48,talker.occupation) )
				{
					i0 = 236;
				}
				myself::AddUseSkillDesire(talker,CongratulationsSkill,0,0,1000000);
				talker.quest_last_reward_time = myself::GetCurrentTick();
				myself::DeleteItem1(talker,SubClassCurrency,SubClassAmount);
				myself::DeleteItem1(talker,5905,myself::OwnItemCount(talker,5905));
				myself::DeleteItem1(talker,6319,myself::OwnItemCount(talker,6319));
				myself::DeleteItem1(talker,5011,myself::OwnItemCount(talker,5011));
				myself::AddLog(2,talker,i0);
				myself::SetOneTimeQuestFlag(talker,i0,1);
				myself::SoundEffect(talker,"ItemSound.quest_finish");
				myself::ShowPage(talker,"gmshop_sub.htm");
			}
			else
			{
				myself::ShowPage(talker,"gmshop_nosub.htm");
			}
		}
		else if( ask == -700 && reply == 3 )
		{
			if( talker.level >= 75 && talker.subjob_id != 0 && talker.nobless_type != 1 )
			{
				if( myself::OwnItemCount(talker,NoblessCurrency) < NoblessAmount )
				{
					myself::ShowSystemMessage(talker,279);
					return;
				}
				if( ( myself::GetCurrentTick() - talker.quest_last_reward_time ) > 1 )
				{
					talker.quest_last_reward_time = myself::GetCurrentTick();
					myself::DeleteItem1(talker,NoblessCurrency,NoblessAmount);
					myself::GiveItem1(talker,7694,1);
					myself::SoundEffect(talker,"ItemSound.quest_finish");
					myself::ShowPage(talker,"gmshop_nob.htm");
					myself::AddLog(2,talker,247);
					myself::SetOneTimeQuestFlag(talker,247,1);
					myself::AddUseSkillDesire(talker,CongratulationsSkill,0,0,1000000);
					myself::SetNobless(talker);
				}
			}
			else
			{
				myself::ShowPage(talker,"gmshop_nonob.htm");
			}
		}
		else if( ask == -700 && reply == 4 )
		{
			if( talker.pk_count == 0 )
			{
				myself::ShowPage(talker,"gmshop_nopk.htm");
				return;
			}
			if( myself::OwnItemCount(talker,PKCurrency) < PKAmount )
			{
				myself::ShowSystemMessage(talker,279);
				return;
			}
			myself::DeleteItem1(talker,PKCurrency,PKAmount);
			myself::IncrementParam(talker,9,-1);
		}
		else if( ask == -700 && reply == 5 )
		{
			if( myself::OwnItemCount(talker,RecoverCPCurrency) < RecoverCPAmount )
			{
				myself::ShowSystemMessage(talker,279);
				return;
			}
			if( myself::Skill_GetConsumeMP(RecoverCPSkill) >= myself.sm.mp )
			{
				myself::ShowPage(talker,fnNotEnoughMP);
				return;
			}
			if( myself::Skill_InReuseDelay(RecoverCPSkill) != 0 )
			{
				myself::ShowPage(talker,fnNeedCoolTime);
				return;
			}
			myself::AddUseSkillDesire(talker,RecoverCPSkill,1,0,1000000);
		}
		else if( ask == -700 && reply == 6 )
		{
			if( myself::OwnItemCount(talker,CRPCurrency) < CRPAmount )
			{
				myself::ShowSystemMessage(talker,279);
				return;
			}
			if( talker.is_pledge_master != 1 )
			{
				myself::ShowPage(talker,fnNeedPledgeMaster);
				return;
			}
			myself::DeleteItem1(talker,CRPCurrency,CRPAmount);
			myself::PledgeScoreInc(talker,500);
		}
		else if( ask == -800 )
		{
			if( reply == 0 )
			{
				myself::FHTML_SetFileName(fhtml0,"gmshop_wyvern.htm");
				myself::FHTML_SetInt(fhtml0,"price",WyvernPrice);
				myself::ShowFHTML(talker,fhtml0);
			}
			else if( reply == 1 )
			{
				if( myself::OwnItemCount(talker,4037) >= WyvernPrice && talker.yongma_type == 1 && talker.strider_level >= 55 )
				{
					myself::DeleteItem1(talker,4037,WyvernPrice);
					myself::RideWyvern(talker,1012621);
					myself::ShowPage(talker,"gmshop_wyvernok.htm");
				}
				else
				{
					myself::FHTML_SetFileName(fhtml0,"gmshop_wyvernfail.htm");
					myself::FHTML_SetInt(fhtml0,"price",WyvernPrice);
					myself::ShowFHTML(talker,fhtml0);
				}
			}
		}
		else if( ask == -900 )
		{
			if( myself::IsInCategory(5,talker.occupation) )
			{
				if( talker.alive && talker.level >= 20 )
				{
					if( reply == -1 )
					{
						myself::ShowPage(talker,"classchange" + myself::IntToStr(talker.occupation) + ".htm");
					}
					else if( myself::OwnItemCount(talker,ClassChange1Currency) >= ClassChange1Amount )
					{
						myself::AddUseSkillDesire(talker,CongratulationsSkill,0,0,1000000);
						myself::DeleteItem1(talker,ClassChange1Currency,ClassChange1Amount);
						myself::ClassChange(talker,reply);
					}
					else
					{
						myself::ShowPage(talker,"classchange_nomoney.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"classchange_nolvl.htm");
				}
			}
			else if( myself::IsInCategory(6,talker.occupation) )
			{
				if( talker.alive && talker.level >= 40 )
				{
					if( reply == -1 )
					{
						myself::ShowPage(talker,"classchange" + myself::IntToStr(talker.occupation) + ".htm");
					}
					else if( myself::OwnItemCount(talker,ClassChange2Currency) >= ClassChange2Amount )
					{
						myself::AddUseSkillDesire(talker,CongratulationsSkill,0,0,1000000);
						myself::DeleteItem1(talker,ClassChange2Currency,ClassChange2Amount);
						myself::ClassChange(talker,reply);
					}
					else
					{
						myself::ShowPage(talker,"classchange_nomoney.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"classchange_nolvl.htm");
				}
			}
			else if( myself::IsInCategory(7,talker.occupation) )
			{
				if( talker.alive && talker.level >= 75 )
				{
					if( reply == -1 )
					{
						myself::ShowPage(talker,"classchange" + myself::IntToStr(talker.occupation) + ".htm");
					}
					else if( myself::OwnItemCount(talker,ClassChange3Currency) >= ClassChange3Amount )
					{
						myself::AddUseSkillDesire(talker,CongratulationsSkill,0,0,1000000);
						myself::DeleteItem1(talker,ClassChange3Currency,ClassChange3Amount);
						myself::ClassChange(talker,reply);
					}
					else
					{
						myself::ShowPage(talker,"classchange_nomoney.htm");
					}
				}
				else
				{
					myself::ShowPage(talker,"classchange_nolvl.htm");
				}
			}
			else
			{
				myself::ShowPage(talker,"classchange_no.htm");
			}
		}
		super;
	}

	EventHandler USE_SKILL_FINISHED(target,skill_name_id,success,c0)
	{
		if( success == 1 && myself::IsNullCreature(target) == 0 )
		{
			if( skill_name_id == OffTradeSkill )
			{
				myself::DeleteItem1(target,OffTradeCurrency,OffTradeAmount);
			}
			else if( skill_name_id == RecoverCPSkill )
			{
				myself::DeleteItem1(target,RecoverCPCurrency,RecoverCPAmount);
			}
			else if( skill_name_id != CongratulationsSkill && skill_name_id != MPRegenSkill )
			{
				c0 = target;
				if( c0.master )
				{
					c0 = c0.master;
				}
				myself::DeleteItem1(c0,BuffCurrency,BuffAmount);
			}
		}
	}

}
