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

Sub Hold.Object
 On Local Error Goto Error.Trap16
 Call Check.User.Items
 If Temp7!<=SFalse Then
    Strng="You aren't carrying that!"
    Call IO.O
    Exit Sub
 Endif
 Var=TreasureRecord.WeaponNumber
 If Last.Command.Number=HoldItem Then
    Select Case Var
    Case 5, 7 ' shield/weapon
       Strng2="You hold "
    Case Else
       Strng="You can't hold that!"
       Call IO.O
       Exit Sub
    End Select
 Endif
 If Last.Command.Number=WearItem Then
    Select Case Var
    Case 1, 2, 3, 4, 6, 8, 9, 10
       Strng2="You wear "
    Case Else
       Strng="You can't wear that!"
       Call IO.O
       Exit Sub
    End Select
 Endif
 If MessWorkRecord6.Charges<=False Then
    Strng="You can't, it has zero charges!"
    Call IO.O
    Exit Sub
 Endif
 If Var=7 Then ' weapon
    If UserRecord.ClassType=Cleric Then
       If TreasureRecord.Proficiency=Sharp Or _
       TreasureRecord.Proficiency=Thrusting Then
          Strng="Clerics may only use blunt or pole type weapons!"
          Call IO.O
          Exit Sub
       Endif
    Endif
 Endif
 If Var=5 Then ' shield
    VarX!=UserRecord.Weapon(7).Index
    If VarX!>SFalse And VarX!<=Lof(TreasureFile)/TreasureRecLen Then
       Call Read.Record(TreasureFile,VarX!)
       If TreasureRecord.TwoHanded Then
          Strng="You can't hold that! You're holding a two-handed weapon!"
          Call IO.O
          Exit Sub
       Endif
    Endif
 Endif
 If Var=7 Then ' weapon
    If UserRecord.Weapon(5).Index Then
       VarX!=MessWorkRecord6.Index
       If VarX!>SFalse And VarX!<=Lof(TreasureFile)/TreasureRecLen Then
          Call Read.Record(TreasureFile,VarX!)
          If TreasureRecord.TwoHanded Then
             Strng="You can't hold that! You're holding a shield!"
             Call IO.O
             Exit Sub
          Endif
       Endif
    Endif
 Endif
 If UserRecord.Weapon(Var).Index=SFalse Then
    Call Read.Record(TreasureFile,MessWorkRecord6.Index)
    If TreasureRecord.RequireStr>False Then
       If UserRecord.Stats(1)<TreasureRecord.RequireStr Then
          Strng="You can't! Your strength is too low!"
          Call IO.O
          Exit Sub
       Endif
    Endif
    If TreasureRecord.RequireInt>False Then
       If UserRecord.Stats(2)<TreasureRecord.RequireInt Then
          Strng="You can't! Your intelligence is too low!"
          Call IO.O
          Exit Sub
       Endif
    Endif
    If TreasureRecord.RequireDex>False Then
       If UserRecord.Stats(4)<TreasureRecord.RequireDex Then
          Strng="You can't! Your dexterity is too low!"
          Call IO.O
          Exit Sub
       Endif
    Endif
    ' hold/wear item
    UserRecord.Weapon(Var).Index=MessWorkRecord6.Index
    UserRecord.Weapon(Var).Charges=MessWorkRecord6.Charges
    UserRecord.Weapon(Var).Plus=TreasureRecord.Plus
    Call Write.Record(UserFile,User.Index)
    Call Discard(Temp5!,True)
    Temp1=UserRecord.Weapon(Var).Plus
    Call Item.Plus(3,Temp1,Out2)
    Out4=Rtrim$(TreasureRecord.Prefix1)
    Strng=Strng2+Out4+Out3
    Call Convert.ANSI(True,VarQ,VarR)
    Carriage.Return=True
    Graphics.On=True
    Call IO.O
    Graphics.On=False
    Grpahics.Off=True
    Strng=Out2+"."
    Call IO.O
    Exit Sub
 Endif
 Strng3=Rtrim$(InventoryNames(Var))
 Out4=Rtrim$(TreasureRecord.Prefix1)
 Select Case Var
 Case 2, 6 ' boot/bracer
    Strng3=Strng3+"s"
 End Select
 Strng="You must return your "+Out4+Strng3
 Call Convert.ANSI(True,VarQ,VarR)
 Carriage.Return=True
 Graphics.On=True
 Call IO.O
 Graphics.On=False
 Grpahics.Off=True
 Strng=" first!"
 Call IO.O
Error.Resume16:
 Exit Sub
Error.Trap16:
 Resume Error.Resume16
End Sub
