 Rem File: Cmd101.bas
 Rem Sub: Psi.Mode
 Rem $Include: 'dndbbs.inc'
 On Error Goto Main.Error
 If Chained<>-2 Then
    Color 15,0
    Print "DNDBBS Command 101 -- Psi.Mode."
    Color 7,0
    End
 Endif
 Call Psi.Mode
Main.Resume:
 Chain DND.Path+"DNDBBS.EXE"
 End
Main.Error:
 Resume Main.Resume

Sub Psi.Mode
 On Local Error Goto Err.Trap2
 Select Case Lcase$(Parsed.Command1)
 Case "attack"
    Temp3=PsiAttack
 Case "defense"
    Temp3=PsiDefense
 Case Else
    Strng="You can only use psi mode attack or defense!"
    Call IO.O
    Exit Sub
 End Select
 Strng="Psi spell? "
 Call IO.I
 Out2=Ucase$(Out2)
 Out2=Rtrim$(Out2)
 Temp9=False
 For Temp5!=1! To Lof(SpellFile)/SpellRecLen
    Call Read.Record(SpellFile,Temp5!)
    Strng=SpellRecord.Chant
    Strng=Rtrim$(Strng)
    If Strng=Out2 Then
       If SpellRecord.Psionic Then
          Temp9=True
          Exit For
       Endif
    Endif
 Next
 If Temp9=False Then
    Strng="Unknown psi spell!"
    Call IO.O
    Exit Sub
 Endif
 Out6=SpellRecord.SpellName
 Out6=Rtrim$(Out6)
 Out6=Lcase$(Out6)
 If SpellRecord.PsionicMode<>Temp3 Then
    Strng="Incorrect spell for psi mode!"
    Call IO.O
    Exit Sub
 Endif
 Temp1=SpellRecord.Level
 If UserRecord.Psionic=False Then
    Strng="You have no more psi points!"
    Call IO.O
    Exit Sub
 Endif
 Temp6=UserRecord.Psionic
 Temp6=Temp6-Temp1
 If Temp6<False Then
    Temp6=False
 Endif
 UserRecord.Psionic=Temp6
 Strng=Rtrim$(SpellRecord.Prefix1)
 Strng="You cast a "+Strng+Out6
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Strng=" psi spell!"
 Graphics.Off=True
 Call IO.O
 Strng="cast a "+Out6+" psi spell"
 Call Update.DayFile(Strng,False,3)
 Parsed.Command1=Last.Monster
 If Node>False Then
    Out2=UserRecord.CodeName
    Out2=Rtrim$(Out2)
    Out2=Lcase$(Out2)
    Out2=Out2+" casts a psionic spell!"
    Call Send.Mess(8,SFalse,Room,Out2)
 Endif
 Select Case Temp3
 Case PsiAttack
    Psi.Attack.Mode=Temp1
    Parsed.Command1=Last.Monster
    Call Attack.Monster(VarZ)
 Case PsiDefense
    Psi.Defense.Mode=Temp1
    Strng="Your psi defense mode is now active."
    Call IO.O
 End Select
Err.Resume2:
 Exit Sub
Err.Trap2:
 Resume Err.Resume2
End Sub
