As a player, I absolutely hate having to give certain odd value of platinum to an npc to get a certain spell. For example, I would think, "Okay, he wants 62 platinum for c3, 54 platinum for Aego, etc". And that is undesirable in my opinion for the server host and the player. The player wants to buff up and move on. And as a host, you want players to quickly get buffs and enjoy content.
I wrote up this as an alternative credit system for obtaining buffs. I've commented out some things just to make it easier to use as a template. Also, I've only tested this with myself, but it should work with multiple players without bugging (unless I missed an undef). The reason I used Y9 instead of F for global expiration time was simply because F was not working for me. Hope this comes in handy as a template.
Code:
sub EVENT_SAY {
if($text=~/Hail/i){
quest::say("Hello, $name. Are you interested in [buffs] or would you like to know your [Credit Info]?");
}
if($text=~/Credit Info/i){
quest::say("Would you like to know how to [obtain] credit, your current [credit value], or available [buffs]?");
}
if($text=~/obtain/i){
quest::say("For every platinum you bring me you shall receive one credit. These credits can be redeemed for buffs at your request.");
}
if($text=~/buffs/i || $text=~/yes/i) { #### What buffs does he offer and how much credit?
quest::say("I have the following to offer you:");
quest::say("[Cleanse] --full health and mana restore-- - FREE");
quest::say("[Temperance] - 25p");
quest::say("[Virtue] - 50p");
quest::say("[C1] - 5p");
quest::say("[C2] - 25p");
quest::say("[C3] - 75p");
}
if($text=~/credit value/){
if ($buffbot >= 1) {
quest::say("Your current credit is $buffbot");
$buffbot = undef;
}
else {
quest::say("You have 0 credit. Would you like to know how much you need to donate obtain [buffs]?");
$buffbot = undef;
}
}
#cleanse
if($text=~/cleanse/i){ #### Restores Mana and Health. I use this as an alternative to simply casting a spell
$client->Heal();
$client->SetMana($client->GetMaxMana());
quest::say("As you wish!");
}
#buffs begins
#buff 1- Temperance
if($text=~/Temperance/i){
if ($buffbot >= 25) {
quest::selfcast(3692);
quest::say("As you wish!");
quest::setglobal("buffbot", $buffbot-25, 0, "Y9");
$buffbot = undef;
}
else {
quest::say("You need more credits!");
$buffbot = undef;
}
}
#temperance ends
#virtue
if($text=~/virtue/i){
if ($buffbot >= 50) {
quest::selfcast(3467);
quest::say("As you wish!");
quest::setglobal("buffbot", $buffbot-50, 0, "Y9");
$buffbot = undef;
}
else {
quest::say("You need more credits!");
$buffbot = undef;
}
}
#c1
if($text=~/c1/i){
if ($buffbot >= 5) {
quest::selfcast(174);
quest::say("As you wish!");
quest::setglobal("buffbot", $buffbot-5, 0, "Y9");
$buffbot = undef;
}
else {
quest::say("You need more credits!");
$buffbot = undef;
}
}
#c2
if($text=~/c2/i){
if ($buffbot >= 25) {
quest::selfcast(1693);
quest::say("As you wish!");
quest::setglobal("buffbot", $buffbot-25, 0, "Y9");
$buffbot = undef;
}
else {
quest::say("You need more credits!");
$buffbot = undef;
}
}
#c3
if($text=~/c3/i){
if ($buffbot >= 75) {
quest::selfcast(2570);
quest::say("As you wish!");
quest::setglobal("buffbot", $buffbot-75, 0, "Y9");
$buffbot = undef;
}
else {
quest::say("You need more credits!");
$buffbot = undef;
}
}
}
sub EVENT_ITEM {
#give a plat, get a credit. Takes any platinum over 1.
if($platinum >= 1){
quest::setglobal("buffbot", $buffbot+$platinum, 0, "Y9");
quest::say("Your credit has been increased by $platinum.");
$buffbot = undef;
quest::settimer(1,1);
}
else {
quest::say("I only accept platinum.");
$buffbot = undef;
}
plugin::return_items(\%itemcount);
}
sub EVENT_TIMER {
if ($timer == 1) {
quest::say("Would you like to know your total [credit value]?");
quest::stoptimer(1);
}
}
With this, you can just use one buff segment, copy and change for a different buff. Previously, I've used checks to make npcs more authenic as well. Like an enchanter saying, "You're too low for KEI to take effect. But, I can cast clarity on you." And given different values for different conditions (like temp free for under level 5). But all of that is just stuff to toy with if you like the way I have it set up.