|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Quests::Q&A This is the quest support section |
09-01-2007, 05:18 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
Aggravated - HELP (please :) )
Hello,
I have a bit of a problem that I'm trying to find the solution for -
I'm trying to create a buff bot that tells non-casting classes (warriors, monks, rogues, berserkers) that they cannot cast spells therefore do not need the buff bot's services. Here is a sample of the code I was trying this with:
sub EVENT_SAY
{
if($text=~/hail/i && $class == 'Warrior')
{
quest::say("You are a warrior. You cannot cast spells.");
}
}
According to other code examples, and logic, this should work. If a warrior hails this NPC, the npc will reply as above - however, even a Shaman, or Necro, or whatever (I tried a few) classes will also see that message. So it seems that the NPC isn't seeing what class the user really is. Is my syntax off, or is this broken? I'm pulling my hair out...
Regards,
Sonic
|
09-01-2007, 06:06 AM
|
|
Discordant
|
|
Join Date: Feb 2002
Posts: 452
|
|
Been awhile since I even looked at this stuff
Not sure, but seems that should work, but like I said been a long time since I even looked at this.
And the perl quests weren't my favorite anyways
Hope it works/helps. (I have no way to test it)
sub EVENT_SAY{
if($text=~/hail/i) && ($class == 'Warrior' || $class == 'Monk' || $class == 'Rogue' || $class == 'Berserker')
{
quest::say("You are a $class . You cannot cast spells.");
}
}
__________________
Founder PEQ (ProjectEQ)
Last edited by tcsmyworld; 09-01-2007 at 02:09 PM..
|
|
|
|
09-01-2007, 06:36 AM
|
AX Classic Developer
|
|
Join Date: May 2006
Location: filler
Posts: 2,049
|
|
This should work (if it does, notice the double brackets added) ;
Code:
sub EVENT_SAY{
if(($text=~/hail/i && $class == 'Warrior')){
quest::say("You are a warrior. You cannot cast spells.");
}
}
This does work
Code:
sub EVENT_SAY{
if (($text=~/hail/i&&$race eq 'Human'&&$class eq 'Enchanter')){
quest::say("I know you!!");
}
}
The $race is just there to show you how to add more. you can find many examples of stuff like this in my quest pack posted with the database at Rathe Forums. If you do get it, look in Tutorialb, PoK, Gunthak - I remember I did a lot of this stuff in those zones.
Quote:
Originally Posted by sonicintuition
Hello,
I have a bit of a problem that I'm trying to find the solution for -
I'm trying to create a buff bot that tells non-casting classes (warriors, monks, rogues, berserkers) that they cannot cast spells therefore do not need the buff bot's services. Here is a sample of the code I was trying this with:
sub EVENT_SAY
{
if($text=~/hail/i && $class == 'Warrior')
{
quest::say("You are a warrior. You cannot cast spells.");
}
}
According to other code examples, and logic, this should work. If a warrior hails this NPC, the npc will reply as above - however, even a Shaman, or Necro, or whatever (I tried a few) classes will also see that message. So it seems that the NPC isn't seeing what class the user really is. Is my syntax off, or is this broken? I'm pulling my hair out...
Regards,
Sonic
|
|
|
|
|
09-01-2007, 01:25 PM
|
Hill Giant
|
|
Join Date: Oct 2006
Posts: 248
|
|
the error is in the operator.
"==" is for numeric comparison, "eq" is for string comparison.
your if should read:
Code:
if($text=~/hail/i && $class eq 'Warrior' )
{
# do some work in here
}
== sfisque
|
09-01-2007, 04:02 PM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
Duh, why didn't I think of that? Using a numerical based operator instead of a string based operator ... Thanks for helping out with this all
Regards,
Sonic
|
09-02-2007, 12:24 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
Hmm ..seems that using string operators makes no difference either.
Example:
Quote:
sub EVENT_SAY
{
if($text=~/hail/i && $class eq 'Rogue' || $class eq 'Warrior')
{
quest::say("You are a $class. You cannot cast spells.");
}
if($text=~/hail/i && $class ne 'Rogue' || $class ne 'Warrior')
{
quest::say("Would you like me to scribe your spells?");
}
}
|
According to you guys, this should work ..but it still doesn't work. I hailed this npc with a wizard and the npc said both lines. I hailed her with a rogue, and she said both lines ...I'm stumped? I'm going to try adding the other parenthises to see if that helps.. will post back here if it does.
Regards,
Sonic
|
09-02-2007, 12:33 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
I added parenthisis ...does nothing. :(
|
09-02-2007, 12:59 AM
|
Hill Giant
|
|
Join Date: Oct 2006
Posts: 248
|
|
Quote:
Originally Posted by sonicintuition
Hmm ..seems that using string operators makes no difference either.
Example:
According to you guys, this should work ..but it still doesn't work. I hailed this npc with a wizard and the npc said both lines. I hailed her with a rogue, and she said both lines ...I'm stumped? I'm going to try adding the other parenthises to see if that helps.. will post back here if it does.
Regards,
Sonic
|
logic failure. && has higher precedence than ||. you basically want, in this case:
Code:
if($text=~/hail/i && ( $class eq 'Rogue' || $class eq 'Warrior') )
you need to group the two class comparisons because if you dont, the logic says:
if the text contains "hail" and class eq 'Rogue'
OR
class eq 'Warrior'
whereas you want:
if the text contains 'hail'
AND
the class is either Rogue or Warrior
== sfisque
|
09-02-2007, 07:31 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
Alright ..that makes sense. I'll give it a whirl. Thanks for your response.
Sonic
|
09-02-2007, 07:58 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
Quote:
you need to group the two class comparisons because if you dont, the logic says:
if the text contains "hail" and class eq 'Rogue'
OR
class eq 'Warrior'
whereas you want:
if the text contains 'hail'
AND
the class is either Rogue or Warrior
|
It makes sense, yet doesn't work... the npc STILL spews out both lines regardless of class. This is what I wrote as an update to what you guys have been telling me...
Quote:
sub EVENT_SAY
{
if($text=~/hail/i && ($class eq 'Warrior' || $class eq 'Rogue'))
{
quest::say("You are not a caster!");
}
if($text=~/hail/i && ($class ne 'Warrior' || $class ne 'Rogue'))
{
quest::say("You are a caster!");
}
}
|
So ....I'll hail the NPC with a rogue, and get "You are not a caster! You are a caster!" ....
Sonic
|
09-02-2007, 08:16 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
Angelox, I'm trying to read this like a computer would read this:
Quote:
sub EVENT_SAY{
if (($text=~/hail/i&&$race eq 'Human'&&$class eq 'Enchanter')){
quest::say("I know you!!");
}
}
|
I'm reading that as if player says hail, and the player is a human enchanter, do action. So if I did this:
Quote:
sub EVENT_SAY
{
if(($text=~/hail/i && $class eq 'Rogue' && $class eq 'Warrior'))
{
quest::say("You are NOT a caster!");
}
}
|
As a computer, I would read that as if the player says hail, and is a Rogue AND a Warrior, do action ..which obviously can't be the case. And that's what I'm trying to do - I need to set up my script so that the NPC won't talk to non-casting classes, eg, Warrior, Rogue, Monk, Berserker. Trying to use || operators isn't working ..I'm going to try one more thing before I give up altogether and just allow non casting classes to use my spell scriber...lol Will post back if it works.
Sonic
|
|
|
|
09-02-2007, 08:41 AM
|
AX Classic Developer
|
|
Join Date: May 2006
Location: filler
Posts: 2,049
|
|
Don't give up! I have taken weeks to understand simple things too. Just put it to aside, and come back to it again, later.
you only need $class for what you want - make one like this:
Code:
sub EVENT_SAY{
if (($text=~/hail/i&&$class eq 'enchanter')){
quest::say("I can help you");
}
if (($text=~/hail/i&&$class eq 'wizard')){
quest::say("I can help you");
}
}
You can add all the casters to this PL and omit the non-casters. This way your npc will ignore non-casters.
You first PL might have worked, but you had typos in it.
Quote:
Originally Posted by sonicintuition
Angelox, I'm trying to read this like a computer would read this:
I'm reading that as if player says hail, and the player is a human enchanter, do action. So if I did this:
As a computer, I would read that as if the player says hail, and is a Rogue AND a Warrior, do action ..which obviously can't be the case. And that's what I'm trying to do - I need to set up my script so that the NPC won't talk to non-casting classes, eg, Warrior, Rogue, Monk, Berserker. Trying to use || operators isn't working ..I'm going to try one more thing before I give up altogether and just allow non casting classes to use my spell scriber...lol Will post back if it works.
Sonic
|
|
|
|
|
09-02-2007, 08:46 AM
|
|
Hill Giant
|
|
Join Date: May 2005
Location: Australia
Posts: 113
|
|
While im certian no noob user of perl (i do guess work... i guess this will work) lol
but being a c++/c# dev has given me an advantage. All languages follow the sample principlals when it comes down to it.
This site, is well worth a read
http://stein.cshl.org/genome_informa...tro/index.html
In perticular, check out the "Operators" and also have a quick browse. Perl hjas the great advantage of being very english based
The above link, is not EQEmu information, but rather just perl.
- froglok
|
|
|
|
09-02-2007, 09:56 AM
|
Hill Giant
|
|
Join Date: Jan 2005
Posts: 124
|
|
I got it to work, finally! This is what I did:
Quote:
sub EVENT_SAY
{
if(($text=~/hail/i && $class eq 'Rogue'))
{
$client->Message(5, "Persy Clutches tells you, You are a $class. I cannot help you.");
}
if(($text=~/hail/i && $class eq 'Warrior'))
{
$client->Message(5, "Persy Clutches tells you, You are a $class. I cannot help you.");
}
if(($text=~/hail/i && $class eq 'Monk'))
{
$client->Message(5, "Persy Clutches tells you, You are a $class. I cannot help you.");
}
if(($text=~/hail/i && $class eq 'Berserker'))
{
$client->Message(5, "Persy Clutches tells you, You are a $class. I cannot help you.");
}
if($text=~/hail/i && $class ne 'Rogue' && $class ne 'Warrior' && $class ne 'Monk' && $class ne 'Berserker')
{
$client->Message(5, "Persy Clutches tells you, Hello $name. I can [scribe your spells] for you, however I
can only scribe them until you are level 60. After that, you'll have to find them
yourself.");
}
if($text=~/scribe my spells/i)
{
$client->Message(5, "Persy Clutches tells you, Very well. Scribing your spells now.");
quest::scribespells();
}
}
|
Yay me
Thanks all for your help and support, I appreciate it a ton.
Sonic
|
|
|
|
|
|
|
09-02-2007, 12:44 PM
|
Hill Giant
|
|
Join Date: Oct 2006
Posts: 248
|
|
Quote:
Originally Posted by sonicintuition
So ....I'll hail the NPC with a rogue, and get "You are not a caster! You are a caster!" ....
Code:
sub EVENT_SAY
{
if($text=~/hail/i && ($class eq 'Warrior' || $class eq 'Rogue'))
{
quest::say("You are not a caster!");
}
if($text=~/hail/i && ($class ne 'Warrior' || $class ne 'Rogue'))
{
quest::say("You are a caster!");
}
}
Sonic
|
broken logic. on the "second" if, if i'im a rogue, it will fire because, you're asking a different question:
if $text contains "hail"
and
the $class is either ( not warrior ) or (not rogue)
which is true if you're a rogue ( rogue != warrior ).
converse statements (ones containing "negations" ) are usually tricky and require some care. you're easiest bet would be to construct it like follows:
if( contains "hail" )
{
if( class1 ) { do something }
elsif (class2 ) { do something else }
elsif( class3 ) { do something else }
...
else { do the other thing }
}
hope this helps.
== sfisque
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 10:05 PM.
|
|
|
|
|
|
|
|
|
|
|
|
|