class Creature
Constants
- TAGS
- WOUNDS
Attributes
can_cast[RW]
data[RW]
id[RW]
legged[RW]
limbed[RW]
name[RW]
targetable[RW]
wounds[RW]
Public Class Methods
new(creature)
click to toggle source
# File lib/Olib/combat/creature.rb, line 71 def initialize(creature) @id = creature.id @name = creature.name @wounds = {} @tags = ((creature.type || "").gsub(",", " ").split(" ") + (metadata["tags"] || []) ).map(&:to_sym) TAGS.each_pair do |tag, pattern| @tags << tag if @name =~ pattern end heal end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/Olib/combat/creature.rb, line 200 def <=>(other) self.danger <=> other.danger end
==(other)
click to toggle source
# File lib/Olib/combat/creature.rb, line 189 def ==(other) @id.to_i == other.id.to_i end
alive?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 168 def alive? !dead? end
ambush(location=nil)
click to toggle source
# File lib/Olib/combat/creature.rb, line 233 def ambush(location=nil) until hidden? fput "hide" waitrt? end Char.aim(location) if location fput "ambush ##{@id}" waitrt? self end
can_cast?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 163 def can_cast? injuries @wounds[:right_arm] == 3 || @wounds[:head] == 3 end
danger()
click to toggle source
# File lib/Olib/combat/creature.rb, line 194 def danger status .map do |state| Creatures::STATES.index(state) end .reduce(&:+) || -1 end
eql?(other)
click to toggle source
# File lib/Olib/combat/creature.rb, line 185 def eql?(other) self == other end
fetch()
click to toggle source
# File lib/Olib/combat/creature.rb, line 90 def fetch GameObj[@id] end
fire(location=nil)
click to toggle source
# File lib/Olib/combat/creature.rb, line 258 def fire(location=nil) unless dead? Char.aim(location) if location fput "fire ##{@id}" end self end
gone?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 177 def gone? fetch.nil? ? true : false end
heal()
click to toggle source
# File lib/Olib/combat/creature.rb, line 98 def heal WOUNDS.each do |location| @wounds[location] = 0 end self end
hurl(location=nil)
click to toggle source
# File lib/Olib/combat/creature.rb, line 266 def hurl(location=nil) unless dead? Char.aim(location) if location fput "hurl ##{@id}" end self end
injuries()
click to toggle source
# File lib/Olib/combat/creature.rb, line 105 def injuries fput "look ##{@id}" woundinfo = matchtimeout(2, /(he|she|it) (?:has|appears to be in good) .*/i) if woundinfo =~ /appears to be in good shape/ then heal; return @wounds; end if woundinfo =~ /some minor cuts and bruises on (his|her|its) right (?:hind )?leg/ then @wounds[:right_leg] = 1; end if woundinfo =~ /some minor cuts and bruises on (his|her|its) left (?:hind )?leg/ then @wounds[:left_leg] = 1; end if woundinfo =~ /some minor cuts and bruises on (his|her|its) (?:right arm|right foreleg)/ then @wounds[:right_arm] = 1; end if woundinfo =~ /some minor cuts and bruises on (his|her|its) (?:left arm|left foreleg)/ then @wounds[:left_arm] = 1; end if woundinfo =~ /minor bruises around (his|her|its) neck/ then @wounds[:neck] = 1; end if woundinfo =~ /minor bruises around (his|her|its) head/ then @wounds[:head] = 1; end if woundinfo =~ /minor cuts and bruises on (his|her|its) chest/ then @wounds[:chest] = 1; end if woundinfo =~ /minor cuts and bruises on (his|her|its) abdomen/ then @wounds[:abdomen] = 1; end if woundinfo =~ /minor cuts and bruises on (his|her|its) back/ then @wounds[:back] = 1; end if woundinfo =~ /bruised left eye/ then @wounds[:left_eye] = 1; end if woundinfo =~ /bruised right eye/ then @wounds[:right_eye] = 1; end if woundinfo =~ /some minor cuts and bruises on (his|her|its) right (?:hand|paw|claw)/ then @wounds[:right_hand] = 1; end if woundinfo =~ /some minor cuts and bruises on (his|her|its) left (?:hand|paw|claw)/ then @wounds[:left_hand] = 1; end if woundinfo =~ /a strange case of muscle twitching/ then @wounds[:nerves] = 1; end if woundinfo =~ /fractured and bleeding right (?:hind )?leg/ then @wounds[:right_leg] = 2; end if woundinfo =~ /fractured and bleeding left (?:hind )?leg/ then @wounds[:left_leg] = 2; end if woundinfo =~ /fractured and bleeding (?:right arm|right foreleg)/ then @wounds[:right_arm] = 2; end if woundinfo =~ /fractured and bleeding (?:left arm|left foreleg)/ then @wounds[:left_arm] = 2; end if woundinfo =~ /moderate bleeding from (his|her|its) neck/ then @wounds[:neck] = 2; end if woundinfo =~ /minor lacerations about (his|her|its) head and a possible mild concussion/ then @wounds[:head] = 2; end if woundinfo =~ /deep lacerations across (his|her|its) chest/ then @wounds[:chest] = 2; end if woundinfo =~ /deep lacerations across (his|her|its) abdomen/ then @wounds[:abdomen] = 2; end if woundinfo =~ /deep lacerations across (his|her|its) back/ then @wounds[:back] = 2; end if woundinfo =~ /swollen left eye/ then @wounds[:left_eye] = 2; end if woundinfo =~ /swollen right eye/ then @wounds[:right_eye] = 2; end if woundinfo =~ /fractured and bleeding right (?:hand|paw|claw)/ then @wounds[:right_hand] = 2; end if woundinfo =~ /fractured and bleeding left (?:hand|paw|claw)/ then @wounds[:left_hand] = 2; end if woundinfo =~ /a case of sporadic convulsions/ then @wounds[:nerves] = 2; end if woundinfo =~ /severed right (?:hind )?leg/ then @wounds[:right_leg] = 3; end if woundinfo =~ /severed left (?:hind )?leg/ then @wounds[:left_leg] = 3; end if woundinfo =~ /severed (?:right arm|right foreleg)/ then @wounds[:right_arm] = 3; end if woundinfo =~ /severed (?:left arm|left foreleg)/ then @wounds[:left_arm] = 3; end if woundinfo =~ /snapped bones and serious bleeding from (his|her|its) neck/ then @wounds[:neck] = 3; end if woundinfo =~ /severe head trauma and bleeding from (his|her|its) ears/ then @wounds[:head] = 3; end if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) chest/ then @wounds[:chest] = 3; end if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) abdomen/ then @wounds[:abdomen] = 3; end if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) back/ then @wounds[:back] = 3; end if woundinfo =~ /blinded left eye/ then @wounds[:left_eye] = 3; end if woundinfo =~ /blinded right eye/ then @wounds[:right_eye] = 3; end if woundinfo =~ /severed right (?:hand|paw|claw)/ then @wounds[:right_hand] = 3; end if woundinfo =~ /severed left (?:hand|paw|claw)/ then @wounds[:left_hand] = 3; end if woundinfo =~ /a case of uncontrollable convulsions/ then @wounds[:nerves] = 3; end @wounds end
kill()
click to toggle source
# File lib/Olib/combat/creature.rb, line 251 def kill unless dead? fput "kill ##{@id}" end self end
kill_shot(order = [:left_eye, :right_eye, :head, :neck, :back], default = :chest)
click to toggle source
# File lib/Olib/combat/creature.rb, line 208 def kill_shot(order = [:left_eye, :right_eye, :head, :neck, :back], default = :chest) wounds = injuries return (order .drop_while do |area| @wounds[area] == 3 end .first || default).to_game end
legged?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 158 def legged? injuries @wounds[:right_leg] == 3 || @wounds[:left_leg] == 3 end
level()
click to toggle source
# File lib/Olib/combat/creature.rb, line 82 def level metadata["level"] end
limbed?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 172 def limbed? injuries @wounds[:right_leg] == 3 || @wounds[:left_leg] == 3 || @wounds[:right_arm] == 3 end
metadata()
click to toggle source
# File lib/Olib/combat/creature.rb, line 86 def metadata Creatures::BY_NAME[@name] || {} end
mstrike()
click to toggle source
# File lib/Olib/combat/creature.rb, line 244 def mstrike unless dead? fput "mstrike ##{@id}" end self end
prone?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 181 def prone? status.include?(:lying) || status.include?(:prone) ? true : false end
search()
click to toggle source
# File lib/Olib/combat/creature.rb, line 274 def search waitrt? fput "search ##{@id}" if dead? end
skin()
click to toggle source
# File lib/Olib/combat/creature.rb, line 279 def skin waitrt? fput "skin ##{@id}" if dead? self end
status()
click to toggle source
# File lib/Olib/combat/creature.rb, line 94 def status fetch.status.split(" ") end
stunned?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 204 def stunned? status.include?(:stunned) ? true : false end
target()
click to toggle source
# File lib/Olib/combat/creature.rb, line 227 def target result = dothistimeout "target ##{@id}", 3, /#{Olib::Dictionary.targetable.values.join('|')}/ @targetable = result =~ Olib::Dictionary.targetable[:yes] ? true : false self end
targetable?()
click to toggle source
# File lib/Olib/combat/creature.rb, line 215 def targetable? target if @targetable.nil? @targetable end
to_s()
click to toggle source
# File lib/Olib/combat/creature.rb, line 285 def to_s "<#{fetch.name}:#{@id} @danger=#{danger} @tags=#{tags} @status=#{status}>" end