PDA

View Full Version : Money Conversion Quest


Monrezz
02-15-2004, 08:57 AM
Just written a simple perl money conversion quest that converts the money given to the NPC to it's highest possible coinage.

e.g.
Give the NPC 10 copper = 1 silver returned.
Give the NPC 100 copper = 1 gold returned.
Give the NPC 50 copper, 5 silver and 19 gold = 2 platinum returned.

If you give the NPC a value that it can't upgrade it will give you the coin back and tell you it cannot be upgraded.
e.g.
Give the NPC 7 copper = 7 copper returned.
Give the NPC 8 gold = 8 gold returned.

If you give the NPC coinage that adds up to a decimal value it will be rounded down to the nearest full coin.
e.g.
Give the NPC 11 copper = 1 silver returned.
Give the NPC 19 gold = 1 platinum returned.
Give the NPC 55 copper, 97 silver and 107 gold = 117 platinum returned.

Not sure if this could help anyone but it was kinda fun to do and thought someone could use it. Just stick the following into a .pl file:

sub EVENT_SAY
{
if($text =~ /Hail/i){
quest::say("Greetings $name. Would you like me to [convert] some money?");}

if($text =~ /convert/i){
quest::say("Give me some loose change and I will change it into the highest coinage I can. I will always round down - I have to make a living somehow!");}
}

sub EVENT_ATTACK
{
if(($ulevel > $mlevel) && ($mlevel < 51))
{
quest::say("Please, somebody help me! $name is attacking me!");
quest::emote("calls out for help.");}

else
{
@responses =
("Time do die, $name!",
"That was a bad idea, $name!",
"Prepare to die $name!",
"Foolish $race, you think you can defeat me?");
my $length = $#responses + 1;
$length = rand($length);
$length = int $length;
quest::say($responses[$length]);
}
}

sub EVENT_DEATH
{
quest::say("My comrades will avenge my death!");
}

sub EVENT_ITEM
{
$myplatinum = (($copper/1000) + ($silver/100) + ($gold/10) + $platinum);
$mygold = (($copper/100) + ($silver/10) + $gold + (10*$platinum));
$mysilver = (($copper/10) + $silver + (10*$gold) + (100*$platinum));
$mycopper = ($copper + (10*$silver) + (100*$gold) + (1000*$platinum));

if($mycopper < 10){
quest::say("Sorry, but I need at least 10 copper to upgrade you into silver. Here, have your money back.");
quest::givecash($copper,0,0,0);}

if((($mycopper >= 10) && ($mycopper < 100)) || (($mysilver >= 1) && ($mysilver < 10))){
quest::say("You gave me coins worth a total value of $mysilver silver. Here you go:");
quest::givecash(0,$mysilver,0,0);}

if((($mycopper >= 100) && ($mycopper < 1000)) || (($mysilver >= 10) && ($mysilver < 100)) || (($mygold >= 1) && ($mygold < 10))){
quest::say("You gave me coins worth a total value of $mygold gold. Here you go:");
quest::givecash(0,0,$mygold,0);}

if(($mycopper >= 1000) || ($mysilver >= 100) || ($mygold >= 10) || ($myplatinum >= 1)){
quest::say("You gave me coins worth a total value of $myplatinum platinum. Here you go:");
quest::givecash(0,0,0,$myplatinum);}
}

samandhi
02-15-2004, 10:02 AM
Pretty sweet, that could be a very good thing to add to newbie zones to guards so one doesnt have to run back to town every time one turns around.. If I put this as default.pl and put it in the quest folder, that wont overwrite quests, but will add a quest to any npc that doenst already have one right?

Monrezz
02-15-2004, 10:53 AM
If you name it as default.pl and put it in EQEMu\quests\ then ANY mob without a quest will get this (but mobs with quests will keep their custom quest).

If you name it as default.pl and put it in EQEMu\quests\$zonesn then ANY mob witout a quest in that zone will get this (but mobs with quests will keep their custom quests).

In other words, only mobs without a quest will be affected.

Monrezz

samandhi
02-15-2004, 02:06 PM
Thought so. Thanks.

Monrezz
02-16-2004, 07:13 AM
Which is your server samandhi?

samandhi
02-17-2004, 08:49 AM
It is called "My Own Personal Everquest Server", but I dont leave it running all the time..Only when I play (until I get it where I want it anyhow)...:)