Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2007, 02:45 PM
Irreverent
The Solo Server
 
Join Date: May 2007
Posts: 416
Default BuffBot

OK, what did I do wrong...if I hand in ANY of the plat amt is casts ALL spells?


sub EVENT_ITEM() {
if ($platinum = 500) {quest::selfcast(3360);}
if ($platinum = 200) {quest::selfcast(2570);}
if ($platinum = 50) {quest::selfcast(1693);}
if ($platinum = 20) {quest::selfcast(174);}

if ($platinum = 400) {quest::selfcast(1710);}
if ($platinum = 300) {quest::selfcast(1729);}
if ($platinum = 60) {quest::selfcast(10);}
if ($platinum = 30) {quest::selfcast(39);}

}
Reply With Quote
  #2  
Old 07-17-2007, 04:10 PM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

Not sure, but doesn't perl use "eq" for "="? I thought both worked, but maybe with integers, it's different?
Reply With Quote
  #3  
Old 07-17-2007, 04:16 PM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

try using:


if( $platinum == $somevalue )

in reference to eq, that is the operator for "string" equivalence. == is the operator for numerical equivalence.

== sfisque
Reply With Quote
  #4  
Old 07-17-2007, 07:53 PM
Zengez
Hill Giant
 
Join Date: Nov 2004
Posts: 160
Default

It's been a looooong time since i scripted any perl but wasn't all based in copper value no matter what you wrote? so 500 'plat' really is 500 copper which is less than 1 plat so no matter how much you give him as long as it's over 5 gold you've met all requirements...

I dunno maybe it's fixed so labling plat really does work and all this doesn't mean anything, but that was my initial guess...
Reply With Quote
  #5  
Old 07-17-2007, 08:19 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

try using elsif , that way it will stop at the first one it finds agreeable. I think a string of "ifs" prompts perl to look at all the options.
so if you gave 500 plat (500 plat being the most), this will satisfy all the if's.

Code:
if
 if
  if
   if
    if
are all "nested" under the first if

Code:
if
elsif
elsif
elsif
are "standalone" "ifs

You can also use level checks (why would a level 50 character need a level 20 spell)?
Code:
sub EVENT_ITEM{
  if (($platinum>=15)&&($ulevel=> 46)){
    $npc->SetAppearance(0);
    quest::selfcast(2570);
    quest::say("Casting KEI, Good hunting!");
  }elsif(($platinum>=5)&&($ulevel<= 45)){
    $npc->SetAppearance(0);
    $npc->CastSpell(174,$userid);
    quest::say("Casting Clarity, Good hunting!");
  }else{
    quest::say("Thank you for your donation $name, it wasn't enough though ...");
 }
}
The latter is my mana caster in PoK

Last edited by Angelox; 07-18-2007 at 04:29 AM..
Reply With Quote
  #6  
Old 07-17-2007, 09:59 PM
John Adams
Demi-God
 
Join Date: Jul 2006
Posts: 1,552
Default

His "if ... {quest::selfcast(3360);}" is actually ok, since the if is begun { and ended } properly. elsif is not a bad plan either. But yeah, i missed that... 500 would be 5 gold, not 500pp I think. Although, it has to equal, so 500 does not = 200, and should fail. Not sure what the issue is there, aside from '==' vs '='.
Reply With Quote
  #7  
Old 07-18-2007, 12:33 AM
GeorgeS
Forum Guide
 
Join Date: Sep 2003
Location: California
Posts: 1,475
Default

Have a look at my quest editor and built in examples,there are a few buff bot examples there.

GeorgeS
__________________
Your source for EQ database tools
Toolshop is open for business


http://www.georgestools.chrsschb.com//
Reply With Quote
  #8  
Old 07-18-2007, 01:06 AM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

Quote:
Originally Posted by Irreverent View Post
OK, what did I do wrong...if I hand in ANY of the plat amt is casts ALL spells?


sub EVENT_ITEM() {
if ($platinum = 500) {quest::selfcast(3360);}
if ($platinum = 200) {quest::selfcast(2570);}
if ($platinum = 50) {quest::selfcast(1693);}
if ($platinum = 20) {quest::selfcast(174);}

if ($platinum = 400) {quest::selfcast(1710);}
if ($platinum = 300) {quest::selfcast(1729);}
if ($platinum = 60) {quest::selfcast(10);}
if ($platinum = 30) {quest::selfcast(39);}

}
ok. one more time.

in each IF statement, he is ASSIGNING the value to $platinum, not testing for equivalence. in PERL, assignment always evaluates to true, unless the RHS is zero, undef, null, or eof.

SO, every IF statement evaluates to true, and, thus, the buffbott casts everything. there's no need for elsif's. all he needs to do is change "if( $variable = some_value)" to the correct form of "if( $variable == some_value )"

this concludes PERL 101, please take a blue book and exam guide. grades will be posted at the end of the semester.

== sfisque
Reply With Quote
  #9  
Old 07-18-2007, 06:18 PM
x-scythe
Discordant
 
Join Date: Jun 2003
Posts: 449
Default

why not make it so you have to say a command and pay plat to get the buff? otherwise how are people going to know what amount of plat to give and what buff they are getting?

edit:
been a long time since ive been done this but try something like this?

if(($platinum = xxx) && ($text eq 'buff')) {
quest::selfcast(xxxx);
}

i think that would work

Last edited by x-scythe; 07-19-2007 at 02:33 AM..
Reply With Quote
  #10  
Old 07-18-2007, 06:22 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

If you make a good bot, you'll be able to chat with him and ask how much he charges.
Reply With Quote
  #11  
Old 07-18-2007, 06:43 PM
x-scythe
Discordant
 
Join Date: Jun 2003
Posts: 449
Default

Quote:
Originally Posted by Angelox View Post
If you make a good bot, you'll be able to chat with him and ask how much he charges.
aye, thats what i was trying to explain in my post lol
Reply With Quote
  #12  
Old 07-20-2007, 01:27 PM
Striat
Sarnak
 
Join Date: Aug 2006
Posts: 60
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 07:57 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3