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 09-01-2007, 01:25 PM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

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
Reply With Quote
  #2  
Old 09-01-2007, 04:02 PM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

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
Reply With Quote
  #3  
Old 09-02-2007, 12:24 AM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

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
Reply With Quote
  #4  
Old 09-02-2007, 12:33 AM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

I added parenthisis ...does nothing. :(
Reply With Quote
  #5  
Old 09-02-2007, 12:59 AM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

Quote:
Originally Posted by sonicintuition View Post
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
Reply With Quote
  #6  
Old 09-02-2007, 07:31 AM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

Alright ..that makes sense. I'll give it a whirl. Thanks for your response.


Sonic
Reply With Quote
  #7  
Old 09-02-2007, 07:58 AM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

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
Reply With Quote
  #8  
Old 09-02-2007, 08:16 AM
sonicintuition
Hill Giant
 
Join Date: Jan 2005
Posts: 124
Default

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
Reply With Quote
  #9  
Old 09-02-2007, 12:44 PM
sfisque
Hill Giant
 
Join Date: Oct 2006
Posts: 248
Default

Quote:
Originally Posted by sonicintuition View Post

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

Thread Tools
Display Modes

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 06:20 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 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3