This is a 2 part quest. It really is more of a fun thing, but you'll see. It's in perl, because that is what we use on the Scorpious2k server.
It involves two begger type NPCs. One in oasis and one in qeynos2. We call it the "begger-prince quest". Here is the quest file for the one in oasis:
Code:
sub EVENT_SAY
{
if($text=~/Hail/i)
{
quest::say("Do you have some loose change for a gentleman who has had some bad luck?");
}
elsif($text=~/yes/i)
{
quest::say("Would you give me some of it please?");
}
else
{
quest::say("Go away and leave me alone in my misery.");
}
}
sub EVENT_ITEM
{
$gotcash=0;
if ($copper>0 || $silver>0 || $gold>0 or $platinum>0)
{
$gotcash=1;
}
$numitems=0;
if ($item1 !="")
{
$numitems=$numitems+1;
}
if ($item2 !="")
{
$numitems=$numitems+1;
}
if ($item3 !="")
{
$numitems=$numitems+1;
}
if ($item4 !="")
{
$numitems=$numitems+1;
}
if ($numitems>0)
{
if ($numitems==1)
{
if ($gotcash=1)
{
quest::say("Thank you so much for the money and the $item1.");
}
else
{
quest::say("Thank you so much for the $item1.");
}
}
else
{
if ($gotcash=1)
{
quest::say("Thank you so much for the money and the other $numitems nice things you gave me.");
}
else
{
quest::say("Thank you so much for the $numitems things you gave me.");
}
}
}
quest::say("May the gods bless you as you journey");
}
sub EVENT_DEATH
{
quest::shout("My brother will avenge my death! There will be no mercy for the murderer $name!!");
quest::targlobal("beggerprince","2","Y1",260,$charid,2);
}
Basically, the begger begs. How's that for unexpected? OK, so what happens? He begs, if you give him money or an items he thanks you. BUT, if you kill him, it sticks a variable on another NPC - the one in qeynos2. That could be an expensive mistake as you'll see in the second half of this.
The targlobal function is used to stick the $beggerprince variable with a value of "2" onto the npc in qeynos2. In a way, this npc has sent an instant message to the one in qeynos2, letting him know this player has killed him! There is a new variable called $charid. This is the id number of this character in the database. You have to use this and not $userid in the targlobal command. They are not the same thing.
Here is the quest file for the NPC in qeynos2...
Code:
sub EVENT_SAY
{
if ($beggerprince=="2")
{
quest::say("I know you!! You are the one who killed my brother in Oasis!!");
quest::shout("Die murderer!!");
quest::attack($name);
}
elsif($beggerprince=="1")
{
quest::say("Hello again, my kind friend!");
}
elsif($beggerprince=="3")
{
quest::say("Please don't hurt me again!!");
}
elsif($text=~/Hail/i)
{
quest::say("Do you have some loose change for a gentleman who has had some bad luck?");
}
elsif($text=~/yes/i)
{
quest::say("Would you share some of it please?");
}
else
{
quest::say("Go away and leave me alone in my misery.");
}
}
sub EVENT_ITEM
{
if ($beggerprince=="2")
{
quest::say("I know you!! You are the one who killed my brother in Oasis!!");
quest::say("Do you think you can BUY my forgiveness??");
quest::shout("Die murderer!!");
quest::attack($name);
}
elsif($beggerprince=="3")
{
quest::say("Thank you. Perhaps you are not a bad person after all.");
quest::faction(101,100);
}
elsif($beggerprince=="1")
{
quest::say("Ahhhhhhh! More kindness from my friend!");
quest::say("and this time I will accept your gift and pass it on to the poor and needy");
quest::say("just as I know you would want it.");
quest::faction(101,100);
}
else
{
$gotcash=0;
if ($copper>0 || $silver>0 || $gold>0 or $platinum>0)
{
$gotcash=1;
}
$numitems=0;
if ($item1 !="")
{
$numitems=$numitems+1;
}
if ($item2 !="")
{
$numitems=$numitems+1;
}
if ($item3 !="")
{
$numitems=$numitems+1;
}
if ($item4 !="")
{
$numitems=$numitems+1;
}
quest::say("I must confess... I am not a begger. I am a prince.");
quest::say("I have been seeking a generous person. Until now I have failed.");
quest::say("You have restored my faith in the kindness of others.");
quest::say("Let me show you my gratitude.");
if ($gotcash==1)
{
quest::givecash(0,0,$copper,($platinum*100)+($gold*10)+$silver);
quest::say("Here is 100 times the money you gave me");
}
if ($numitems>0)
{
quest::summonitem($item1,1);
if ($numitems==1)
{
quest::say("Here is your $item1 back.");
quest::exp(1000);
}
else
{
quest::summonitem($item2,1);
if ($item3 != "")
{
quest::summonitem($item3,1);
}
if ($item4 != "")
{
quest::summonitem($item4,1);
}
quest::say("And here are your items back.");
quest::exp(1000*$numitems);
}
}
}
quest::say("thank you so much for showing me that goodness is not gone");
quest::setglobal("beggerprince","1","0","Y1");
quest::faction(101,500);
}
sub EVENT_DEATH
{
if ($beggerprince=="2")
{
quest::shout("My brother! I have failed you!!!!!!");
}
else
{
quest::shout("Why have you done this to me??????????????");
quest::setglobal("beggerprince","3","0","Y1");
}
}
As you can see, we have a global variable in use called $beggerprince. $beggerprince is a type "0" global variable. That means that it is only for this NPC and player. Each player has a different $beggerprince variable, so the value in it is specific for that player. We use the setglobal command here because it is for the npc who is setting it.
IF you killed the NPC in oasis, $beggerprince=="2" and he will attack you if you speak to him or try to give him an item. If you kill him in that battle he will shout "My brother! I have failed you!!!!!!".
IF you didn't kill the npc in oasis yet, he will beg. Its a good idea to be generous. As you can see, he will explain he is in fact a prince and not a begger. He returns 100X the money you gave him. He returns the items you gave him and gives you 1000 X the number of items worth of expirience. $beggerprince is set to "1". This is some of the fun.
So, thinks the newbie, I get 100X my money back... I'm going to cash in on this!
Bzzzzzzz! Wrong Mr Newbie. He remembers you. Next time you give him something, he thanks you and KEEPS IT.
There are some other little things that I am sure you can see here. But that pretty much shows an idea of what you can do.