class Char

Constants

Duration
EMPATH
INJURIES

Public Class Methods

aim(location) click to toggle source
# File lib/Olib/character/char.rb, line 58
def Char.aim(location)
  unless @@aiming == location
    fput "aim #{location}"
    @@aiming = location
  end
  self
end
arm() click to toggle source
# File lib/Olib/character/char.rb, line 24
def Char.arm
  fput "gird"
  self
end
deplete_wealth(silvers) click to toggle source
# File lib/Olib/character/char.rb, line 130
def Char.deplete_wealth(silvers)
  #@@silvers = @@silvers - silvers
end
deposit(amt) click to toggle source
# File lib/Olib/character/char.rb, line 111
def Char.deposit(amt)
  wealth
  if wealth >= amt
    Go2.bank
    fput "unhide" if invisible? || hidden?
    fput "deposit #{amt}"
  end
  return self
end
deposit_all() click to toggle source
# File lib/Olib/character/char.rb, line 103
def Char.deposit_all
  Go2.bank
  fput "unhide" if invisible? || hidden?
  fput "deposit all"
  @@silvers = 0
  return self
end
empty_hands() { || ... } click to toggle source
# File lib/Olib/character/char.rb, line 174
def Char.empty_hands
  hands = [Char.left, Char.right].compact

  hands.each do |hand| Containers.Lootsack.add hand end

  yield

  hands.each(&:take)
end
fwi_teleporter() click to toggle source
# File lib/Olib/character/char.rb, line 66
def Char.fwi_teleporter
  Vars.teleporter || Vars.mapdb_fwi_trinket
end
hide() click to toggle source
# File lib/Olib/character/char.rb, line 12
def Char.hide
  while not hiding?
    waitrt?
    if @@routines[:hiding]
      @@routines[:hiding].call
    else
      fput 'hide'
    end
  end
  Char
end
hiding_routine(procedure) click to toggle source
# File lib/Olib/character/char.rb, line 74
def Char.hiding_routine(procedure)
  @@routines[:hiding] = procedure
  Char
end
in_town?() click to toggle source
# File lib/Olib/character/char.rb, line 79
def Char.in_town?
  Room.current.location =~ /the Adventurer's Guild|kharam|teras|landing|sol|icemule trace|mist|vaalor|illistim|rest|cysaegir|logoth/i
end
left() click to toggle source
# File lib/Olib/character/char.rb, line 83
def Char.left
  GameObj.left_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.left_hand)
end
right() click to toggle source
# File lib/Olib/character/char.rb, line 87
def Char.right
  GameObj.right_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.right_hand)
end
share() click to toggle source

naive share does not check if you're actually in a group or not

# File lib/Olib/character/char.rb, line 123
def Char.share
  wealth
  fput "share #{@silvers}"
  wealth
  self
end
smart_wealth() click to toggle source
# File lib/Olib/character/char.rb, line 134
def Char.smart_wealth
  return @@silvers if @@silvers 
  Char.wealth
end
spell(num) click to toggle source
# File lib/Olib/character/char.rb, line 47
def Char.spell(num)
  hour, minutes, seconds = Spell[num].remaining.split(":").map(&:to_f)
  total_seconds = seconds + (minutes * 60.00) + (hour * 60.00 * 60.00)

  Duration.new(
    total_seconds,
    total_seconds/60,
    total_seconds/60/60,
  )
end
stand() click to toggle source
# File lib/Olib/character/char.rb, line 39
def Char.stand
  unless standing?
    fput "stand"
    waitrt?
  end
  self
end
swap() click to toggle source
# File lib/Olib/character/char.rb, line 34
def Char.swap
  fput "swap"
  self
end
total_wound_severity() click to toggle source
# File lib/Olib/character/char.rb, line 165
def Char.total_wound_severity
  INJURIES
    .reduce(0) do |sum, method| sum + Wounds.send(method) end
end
unarm() click to toggle source
# File lib/Olib/character/char.rb, line 29
def Char.unarm
  fput "store both"
  self
end
unhide() click to toggle source
# File lib/Olib/character/char.rb, line 139
def Char.unhide
  fput 'unhide' if Spell[916].active? or hidden?
  self
end
visible?() click to toggle source
# File lib/Olib/character/char.rb, line 70
def Char.visible?
  hiding? || invisible?
end
wealth() click to toggle source
# File lib/Olib/character/char.rb, line 152
def Char.wealth
  fput "info"
  while(line=get)
    next    if line =~ /^\s*Name\:|^\s*Gender\:|^\s*Normal \(Bonus\)|^\s*Strength \(STR\)\:|^\s*Constitution \(CON\)\:|^\s*Dexterity \(DEX\)\:|^\s*Agility \(AGI\)\:|^\s*Discipline \(DIS\)\:|^\s*Aura \(AUR\)\:|^\s*Logic \(LOG\)\:|^\s*Intuition \(INT\)\:|^\s*Wisdom \(WIS\)\:|^\s*Influence \(INF\)\:/
    if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
      @@silvers= $1.to_i
      break
    end
    sleep 0.1
  end
  @@silvers
end
withdraw(amount) click to toggle source
# File lib/Olib/character/char.rb, line 91
def Char.withdraw(amount)
  Go2.bank
  result = Olib.do "withdraw #{amount} silvers", /I'm sorry|hands you/
  if result =~ /I'm sorry/ 
    Go2.origin
    echo "Unable to withdraw the amount requested for this script to run from your bank account"
    exit
  end
  wealth
  return self
end
wounded?() click to toggle source
# File lib/Olib/character/char.rb, line 170
def Char.wounded?
  total_wound_severity.gt(0)
end