Checking for more then one class

For builders to discuss and ask building questions.
Post Reply
Nedylene
Sword Grand Master
Sword Grand Master
Posts: 517
Joined: Mon Aug 25, 2003 2:00 am
Location: Zhentil Keep

Checking for more then one class

Post by Nedylene » Wed Aug 18, 2004 6:45 pm

Will an if Check such as this work or will it cancel itself checking for two classes?

Code: Select all

>intercept_prog molira tethos~
if class($n) == Wizard
  if class($n) == Priest
    if wear_loc($o) != -1  
      if objval5($o) == 0
        cast 'sanctuary' $n
        mposet on $n iVNUM value5 1
        mpechoat $n {80}A black aura surrounds your body making you feel strangely protected.
        mpechoaround $n {80}A deep black aura swirls around $N's body.
      endif
    endif
  endif
endif
else
mpechoat $n {80}The orb is still in your hands.
Dalvyn
Sword Grand Master
Sword Grand Master
Posts: 4708
Joined: Tue Jul 15, 2003 9:26 pm
Location: House of Wonder, Waterdeep

Post by Dalvyn » Wed Aug 18, 2004 7:42 pm

That won't work. What you have above works as a 'AND': it will cast sanctuary only if
- $n has class WIZARD
- AND $n has class PRIEST
- AND $o is worn
- AND objval5($o) is zero

If you want it to work for both priests and wizards, you need to add an OR explicitly, as in

Code: Select all

>intercept_prog molira tethos~ 
if class($n) == Wizard 
or if class($n) == Priest
  if wear_loc($o) != -1  
    if objval5($o) == 0 
      cast 'sanctuary' $n 
      mposet on $n iVNUM value5 1 
      mpechoat $n {80}A black aura surrounds your body making you feel strangely protected. 
      mpechoaround $n {80}A deep black aura swirls around $N's body. 
    endif 
  endif 
endif
And, if you want to display the echo '... is still in your hands' each time it fails, no matter wat the reason is, you must copy it for each else part, as in

Code: Select all

>intercept_prog molira tethos~ 
if class($n) == Wizard 
or if class($n) == Priest
  if wear_loc($o) != -1  
    if objval5($o) == 0 
      cast 'sanctuary' $n 
      mposet on $n iVNUM value5 1 
      mpechoat $n {80}A black aura surrounds your body making you feel strangely protected. 
      mpechoaround $n {80}A deep black aura swirls around $N's body. 
    else
      mpechoat $n {80}The orb is still in your hands.
    endif
  else
    mpechoat $n {80}The orb is still in your hands.
  endif
else 
  mpechoat $n {80}The orb is still in your hands.
endif
Image
Post Reply