Loading...   

This file is live on EZ Server as of 4/12/16, located in .../quests/global/Tsukasa.pl

#####################################################
### NPC:			Tsukasa - Card Collector
### Quest:		LDoN Armor
### Modified:	04/11/16
#####################################################

sub EVENT_SAY 
{ 

	my $nn = $npc->GetCleanName();
	%cards = (
		"BuyFalcons"	=> [99020, 300],
		"BuyJesters"	=> [99021, 300],
		"BuyKnights"	=> [99024, 400],
		"BuyKingsCr"	=> [99022, 400],
		"BuyPeasants"	=> [99025, 200],
		"BuyQueens"	=> [99026, 500],
		"BuyKingsCh"	=> [99023, 600],	
		"BuyIllusion"	=> [99032, 100]
	);
	%charms = (
		"BuyOracle"		=> [99029, 2000, "Oracle's Upgrade"],
		"BuyGuardian"	=> [99028, 2000, "Guardian's Upgrade"],
		"BuySorcerer"	=> [99030, 2000, "Sorcerer's Upgrade"],
		"BuyBrawler"		=> [99027, 2000, "Brawler's Upgrade"],
	);

	$client->Message(315, " ");
	if ($text =~/hail/i) { $client->Message(315, "$nn says to you, 'Greetings $name. I am a Magician and can summon a powerful suit of $class armor for you. All I want in exchange are some ". quest::saylink("cards", 1)." from Lost Dungeons. I can also help you ". quest::saylink("buy", 1)." or ". quest::saylink("sell", 1)." cards, charms, and tokens.'"); }
	elsif ($text =~/^cards$/i) { $client->Message(315, "$nn says to you, 'Yes, about the cards. Rumors say they are a rare find in Lost Dungeons and that each card has a name on it. In exchange for a single card, I can reward you with ". quest::saylink("armor", 1)." or ". quest::saylink("illusion", 1)." items.'"); }
	elsif ($text =~/^armor$/i) { $client->Message(315, "$nn says to you, 'The armor cards I'm looking for are Falcons Gloves, Jesters Boots, Knights Arms, Kings Crown, Peasants Bracer, Queens Legs, and Kings Chest. Give me 4 at the same time to receive nice piece of $class armor!'"); }
	elsif ($text =~/^illusion$/i) { $client->Message(315, "$nn says to you, 'Give me 4 illusion cards to receive a random illusion item. You can always give me 2 random illusion items that you don't want for another chance of a random illusion item. There are almost 30 different illusions available!'"); }
	elsif ($text =~/^buy$/i) { $client->Message(315, "$nn says to you, 'Would you like to ". quest::saylink("buy armor cards", 1)." or ". quest::saylink("buy charm upgrades", 1)."?'");  }
	elsif ($text =~/^sell$/i) {	$client->Message(315, "$nn says to you, 'Would you like to ". quest::saylink("sell all of your credit tokens", 1).", ". quest::saylink("sell all of your armor cards", 1).", or ". quest::saylink("sell all of your charm upgrades", 1)."? WARNING! The items you choose to sell will end up selling (deleting) ALL items of that kind from your inventory. Sell at your own risk!'"); }
	################################################################ SELL MENU ###################################################################
	elsif ($text =~/^sell all of your credit tokens$/i) 
	{
		my $tokens = quest::collectitems(99066,1) * 10;   # 10 Points Token
		$tokens += quest::collectitems(99067,1) * 50;   # 50 Points Token
		$tokens += quest::collectitems(99068,1) * 100;  # 100 Points Token
		$tokens += quest::collectitems(99069,1) * 200;  # 200 Points Token
		my $old_credit = plugin::ez_global($charid, "ldon_credit"); # Add old (current) credit with new (sold) credit = new balance.
		my $new_credit = $old_credit + $tokens; # Add old (current) credit with new (sold) credit = new balance.
		if ($tokens > 0) 
		{
			$client->Message(13, "$nn says to you, 'You sold all your Credit Tokens.'"); 
			$client->Message(315, "$old_credit : Previous Balance"); 
			$client->Message(315, "+ $tokens : Sold Tokens"); 
			$client->Message(315, "$new_credit : New Balance");    
			plugin::ez_global($charid, "ldon_credit", $new_credit, 	31536000); # store for 1 year
		}
		else { $client->Message(13, "$nn says to you, 'You do not have any Credit Tokens to sell!'"); }
	} # End sell all your tokens
	elsif ($text =~/^sell all of your armor cards$/i) 
	{
		my $cards = quest::collectitems(99020,1) * 30; # Sell Falcons Gloves value 300
		$cards += quest::collectitems(99021,1) * 30; # Sell Jesters Boots value 300
		$cards += quest::collectitems(99024,1) * 40; # Sell Knights Arms value 400
		$cards += quest::collectitems(99022,1) * 40; # Sell Kings Crown value 400
		$cards += quest::collectitems(99025,1) * 20; # Sell Peasants Bracer value 200
		$cards += quest::collectitems(99026,1) * 50; # Sell Queens Legs value 500
		$cards += quest::collectitems(99023,1) * 60; # Sell Kings Chest value 600
		my $old_credit = plugin::ez_global($charid, "ldon_credit"); 
		my $new_credit = $old_credit + $cards; # Add old (current) credit with new (sold) credit = new balance.
		if ($cards > 0)
		{   
			$client->Message(13, "$nn says to you, 'You sold all your Armor Cards.'"); 
			$client->Message(315, "$old_credit : Previous Balance"); 
			$client->Message(315, "+ $cards : Sold Armor Cards"); 
			$client->Message(315, "$new_credit : New Balance");    
			plugin::ez_global($charid, "ldon_credit", $new_credit, 	31536000); # store for 1 year
		}
		else { $client->Message(13, "$nn says to you, 'You do not have any Armor Cards to sell!'"); }
	} # End sell all your tokens
	elsif ($text =~/^sell all of your charm upgrades$/i) 
	{
		my $charms = quest::collectitems(99027,1) * 200; # Sell Brawlers Upgrade value 2000
		$charms += quest::collectitems(99028,1) * 200; # Sell Guardians Upgrade value 2000
		$charms += quest::collectitems(99029,1) * 200; # Sell Oracles Upgrade value 2000
		$charms += quest::collectitems(99030,1) * 200; # Sell Sorcers Upgrade value 2000
		my $old_credit = plugin::ez_global($charid, "ldon_credit"); 
		my $new_credit = $old_credit + $charms; # Add old (current) credit with new (sold) credit = new balance.
		if ($charms > 0) 
		{   
			$client->Message(13, "$nn says to you, 'You sold all your Charm Upgrades.'"); 
			$client->Message(315, "$old_credit : Previous Balance"); 
			$client->Message(315, "+ $charms : Sold Charm Upgrades"); 
			$client->Message(315, "$new_credit : New Balance");    
			plugin::ez_global($charid, "ldon_credit", $new_credit, 	31536000); # store for 1 year
		}
		else { $client->Message(13, "$nn says to you, 'You do not have any Charm Upgrades to sell!'"); }
	} # End sell all your tokens
	################################################################ BUY MENU ###################################################################
	elsif ($text =~/buy armor card/i) 
	{   ### BUY ARMOR CARD
		my $new_credit = plugin::ez_global($charid, "ldon_credit");
		$client->Message(4, " ");
		$client->Message(18, "Armor Cards for Sale");
		$client->Message(16, "-----------------------------");
		$client->Message(4, "100 Credit: ".quest::saylink("BuyIllusion", 1, "Illusionist's Card"));
		$client->Message(4, "200 Credit: ".quest::saylink("BuyPeasants", 1, "Peasant's Bracer"));
		$client->Message(4, "300 Credit: ".quest::saylink("BuyFalcons", 1, "Falcon's Gloves"));
		$client->Message(4, "300 Credit: ".quest::saylink("BuyJesters", 1, "Jester's Boots"));
		$client->Message(4, "400 Credit: ".quest::saylink("BuyKnights", 1, "Knight's Arms"));
		$client->Message(4, "400 Credit: ".quest::saylink("BuyKingsCr", 1, "King's Crown"));
		$client->Message(4, "500 Credit: ".quest::saylink("BuyQueens", 1, "Queen's Legs"));
		$client->Message(4, "600 Credit: ".quest::saylink("BuyKingsCh", 1, "King's Chest"));
		$client->Message(15, "LDoN Credit Available = $new_credit");
		$client->Message(4, " ");
		$client->Message(315, "$nn says, 'What would you like to buy?'");
	}
	elsif ($text =~/buy charm upgrade/i) 
	{   ### BUY CHARM UPGRADE
		my $new_credit = plugin::ez_global($charid, "ldon_credit");
		$client->Message(4, " ");
		$client->Message(18, "Charm Upgrades for Sale");
		$client->Message(16, "-----------------------------");
		$client->Message(4, "2000 Credit: ".quest::saylink("BuyOracle", 1, "Oracle Upgrade"));
		$client->Message(4, "2000 Credit: ".quest::saylink("BuySorcerer", 1, "Sorcerer Upgrade"));
		$client->Message(4, "2000 Credit: ".quest::saylink("BuyBrawler", 1, "Brawler Upgrade"));
		$client->Message(4, "2000 Credit: ".quest::saylink("BuyGuardian", 1, "Guardian Upgrade"));
		$client->Message(15, "LDoN Credit Available = $new_credit");
		$client->Message(4, " ");
		$client->Message(315, "$nn says, 'What would you like to buy?'");
	}
	############################################################ BUY FUNCTIONS ###################################################################						  
	elsif(exists($cards{$text}[0]))
	{
		my $new_credit = plugin::ez_global($charid, "ldon_credit");
		my ($card, $cost) = ($cards{$text}[0], $cards{$text}[1]);
		if($new_credit >= $cost)
		{
			$new_credit -= $cost;
			plugin::ez_global($charid, "ldon_credit", $new_credit, 31536000);
			$client->Message(13, "LDoN Credit Paid ($cost)!");
			$client->Message(15, "LDoN Credit Available = $new_credit");
			$client->Message(15, "--You purchased ".quest::varlink($card)." --");
			quest::summonitem($card); # summon actual card
		}
		else { $client->Message(315, "$nn says, 'You can not afford that!'"); }
	}
	elsif(exists($charms{$text}[0]))
	{
		my $new_credit = plugin::ez_global($charid, "ldon_credit");
		my ($charm_id, $cost, $charm_name) = ($charms{$text}[0], $charms{$text}[1], $charms{$text}[2]);
		if($new_credit >= $cost)
		{
			plugin::DiaWind("Do you wish to buy a {gold}$charm_name~?


			{in}Balance: {g}$new_credit~

			{in}Price: {r}2000~ LDoN Credits

			{in}Player: {lb}$name~

			wintype:1 popupid:$charm_id noquotes");
		}
		else { $client->Message(315, "$nn says, 'You can not afford that!'"); }
	}
}

sub EVENT_POPUPRESPONSE 
{
	my $nn = $npc->GetCleanName();
	$client->Message(15, " "); # Blank Line
	if($popupid ~~ [99027, 99028, 99029, 99030])
	{	
		my %idToString = (
			99029 => "BuyOracle",
			99028 => "BuyGuardian",
			99030 => "BuySorcerer",
			99027 => "BuyBrawler",			
		);
		my $str = $idToString{$popupid};
		my $new_credit = plugin::ez_global($charid, "ldon_credit");
		my ($charm_id, $cost, $charm_name) = ($charms{$str}[0], $charms{$str}[1], $charms{$str}[2]);
		if($new_credit >= $cost)
		{
			$new_credit -= $cost;
			plugin::ez_global($charid, "ldon_credit", $new_credit, 31536000);
			$client->Message(13, "LDoN Credit Paid ($cost)!");
			$client->Message(15, "LDoN Credit Available = $new_credit");
			$client->Message(15, "--You purchased ".quest::varlink($charm_id)." --");
			quest::summonitem($charm_id); # summon actual charm
		}
		else { $client->Message(315, "$nn says, 'You can not afford that!'"); }
	}
}

############################################################################################################################################
###########################################################    EVENT_ITEM       ############################################################
############################################################################################################################################

sub EVENT_ITEM
{
	#	1	Warrior
	#	2	Cleric
	#	3	Paladin
	#	4	Ranger
	#	5	Shadow Knight
	#	6	Druid
	#	7	Monk
	#	8	Bard
	#	9	Rogue
	#	10	Shaman
	#	11	Necromancer
	#	12	Wizard
	#	13	Mage
	#	14	Enchanter
	#	15	Beastlord
	#	16	Berserker

	plugin::stop_return();
	my $nn = $npc->GetCleanName();
	$client->Message(315, " ");

	my @cards = (99020, 99021, 99022, 99023, 99024, 99025, 99026);
	my @illusions = (99033, 99034, 99035, 99036, 99037, 99038, 99039, 99040, 99041, 99042, 99043, 99044, 99045, 99046, 99047, 99048, 99049, 99050, 99051, 99052, 99053, 99055, 99057, 99059, 99060, 99061, 99062, 99063);
	
	my @helm = (70853, 70860, 70867, 70874, 70881, 70888, 70895, 70902, 70909, 70916, 70923, 70930, 70937, 70944, 70951, 70958);
	my @arms = (70854, 70861, 70868, 70875, 70882, 70889, 70896, 70903, 70910, 70917, 70924, 70931, 70938, 70945, 70952, 70959);
	my @wrist = (70855, 70862, 70869, 70876, 70883, 70890, 70897, 70904, 70911, 70918, 70925, 70932, 70939, 70946, 70953, 70960);
	my @gloves = (70856, 70863, 70870, 70877, 70884, 70891, 70898, 70905, 70912, 70919, 70926, 70933, 70940, 70947, 70954, 70961);
	my @boots = (70857, 70864, 70871, 70878, 70885, 70892, 70899, 70906, 70913, 70920, 70927, 70934, 70941, 70948, 70955, 70962);
	my @chest = (70858, 70865, 70872, 70879, 70886, 70893, 70900, 70907, 70914, 70921, 70928, 70935, 70942, 70949, 70956, 70963);
	my @legs = (70859, 70866, 70873, 70880, 70887, 70894, 70901, 70908, 70915, 70922, 70929, 70936, 70943, 70950, 70957, 70964);
	
	### Helm 99022
	if (plugin::check_handin(\%itemcount, 99022 => 1)) { plugin::stop_return(); quest::summonitem($helm[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Helm!"); quest::doanim(27); quest::exp(100); }
	### ARMS 99024
	if (plugin::check_handin(\%itemcount, 99024 => 1)) { plugin::stop_return(); quest::summonitem($arms[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Arms!"); quest::doanim(27); quest::exp(100); }
	### BRACER 99025
	if (plugin::check_handin(\%itemcount, 99025 => 1)) { plugin::stop_return(); quest::summonitem($wrist[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Wrists!"); quest::doanim(27); quest::exp(100); }
	### GLOVES 99020
	if (plugin::check_handin(\%itemcount, 99020 => 1)) { plugin::stop_return(); quest::summonitem($gloves[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Gloves!"); quest::doanim(27); quest::exp(100); }
	### BOOT 99021
	if (plugin::check_handin(\%itemcount, 99021 => 1)) { plugin::stop_return(); quest::summonitem($boots[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Boots!"); quest::doanim(27); quest::exp(100); }
	### CHEST 99023
	if (plugin::check_handin(\%itemcount, 99023 => 1)) { plugin::stop_return(); quest::summonitem($chest[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Chest!"); quest::doanim(27); quest::exp(100); }
	### LEGS 99026
	if (plugin::check_handin(\%itemcount, 99026 => 1)) { plugin::stop_return(); quest::summonitem($legs[($client->GetClass()-1)]); $client->Message(315, "$nn says to you, 'Congratulations $name on your $class Legs!"); quest::doanim(27); quest::exp(100); }

	### Illusion Cards
	if (plugin::check_handin(\%itemcount, 99032 => 4) || ($item1 == 99032 && $item1_charges == 4)) { $client->Message(315, "$nn says to you, 'Congratulations $name an illusion item!"); quest::doanim(27); quest::exp(100); quest::summonitem($illusions[rand @illusions]); }

	### Two random illusions exchanged for 1 illusion
	elsif(($item1 ~~ @illusions && $item2 ~~ @illusions) || ($item1 ~~ @illusions && $item3 ~~ @illusions) || ($item1 ~~ @illusions && $item4 ~~ @illusions))
	{	$client->Message(315, "$nn says to you, 'Here is another random illusion item!"); quest::doanim(27); quest::exp(100); quest::summonitem($illusions[rand @illusions]); } 
}