Olib 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/Olib.rb +38 -44
- data/lib/Olib/actor/actor.rb +117 -0
- data/lib/Olib/area.rb +23 -3
- data/lib/Olib/bounty.rb +175 -130
- data/lib/Olib/character/char.rb +71 -1
- data/lib/Olib/character/disk.rb +19 -0
- data/lib/Olib/character/group.rb +185 -48
- data/lib/Olib/character/inventory.rb +15 -74
- data/lib/Olib/character/stance.rb +28 -0
- data/lib/Olib/combat/creature.rb +235 -201
- data/lib/Olib/combat/creatures.rb +60 -48
- data/lib/Olib/core/container.rb +115 -50
- data/lib/Olib/core/extender.rb +2 -1
- data/lib/Olib/core/item.rb +158 -90
- data/lib/Olib/core/use.rb +39 -0
- data/lib/Olib/dictionary/dictionary.rb +8 -6
- data/lib/Olib/go2.rb +23 -38
- data/lib/Olib/interface/queryable.rb +50 -0
- data/lib/Olib/objects/box.rb +2 -3
- data/lib/Olib/objects/clothing.rb +1 -3
- data/lib/Olib/objects/herb.rb +2 -4
- data/lib/Olib/objects/jewel.rb +26 -29
- data/lib/Olib/objects/jewelry.rb +8 -8
- data/lib/Olib/objects/scroll.rb +37 -67
- data/lib/Olib/objects/uncommon.rb +1 -3
- data/lib/Olib/objects/wand.rb +1 -3
- data/lib/Olib/pattern.rb +34 -0
- data/lib/Olib/storage/app_data.rb +31 -0
- data/lib/Olib/supervisor/supervisor.rb +205 -0
- data/lib/Olib/try/try.rb +58 -0
- data/lib/Olib/version.rb +1 -1
- metadata +10 -3
- data/lib/Olib/events/emitter.rb +0 -7
- data/lib/Olib/objects/unknown.rb +0 -4
@@ -0,0 +1,28 @@
|
|
1
|
+
class Stance
|
2
|
+
OFFENSIVE = "offensive"
|
3
|
+
ADVANCE = "advance"
|
4
|
+
FORWARD = "forward"
|
5
|
+
NEUTRAL = "neutral"
|
6
|
+
GUARDED = "guarded"
|
7
|
+
DEFENSIVE = "defensive"
|
8
|
+
|
9
|
+
ENUM = [OFFENSIVE, ADVANCE, FORWARD, NEUTRAL, GUARDED, DEFENSIVE]
|
10
|
+
|
11
|
+
def self.change(stance)
|
12
|
+
waitcastrt?
|
13
|
+
waitrt?
|
14
|
+
fput "stance #{stance}" unless checkstance == stance
|
15
|
+
sleep 0.1
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
ENUM.each do |stance|
|
20
|
+
Stance.define_singleton_method((stance.to_s + "?").to_sym) do
|
21
|
+
checkstance == str
|
22
|
+
end
|
23
|
+
|
24
|
+
Stance.define_singleton_method(stance.to_sym) do
|
25
|
+
change stance
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/Olib/combat/creature.rb
CHANGED
@@ -4,252 +4,286 @@
|
|
4
4
|
# - add corporeal types
|
5
5
|
# - add quadrapedal types
|
6
6
|
# - add known spells/cmans/manuevers and algorithm for danger level by profession and skills
|
7
|
+
require "ostruct"
|
8
|
+
require "Olib/combat/creatures"
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
class FalseClass
|
11
|
+
def to_i
|
12
|
+
0
|
13
|
+
end
|
14
|
+
end
|
15
|
+
class TrueClass
|
16
|
+
def to_i
|
17
|
+
1
|
18
|
+
end
|
19
|
+
end
|
13
20
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
name =~ /lesser construct|Vvrael warlock|Vvrael witch/
|
24
|
-
end
|
25
|
-
|
26
|
-
def Creature.living(name)
|
27
|
-
name =~ /carrion worm|black rolton|black-winged daggerbeak|fanged rodent|kobold|mountain rolton|giant rat|slimy little grub|young grass snake|fire ant|rolton|spotted gnarp|giant ant|cave gnome|rabid squirrel|big ugly kobold|goblin|pale crab|fanged goblin|brown gak|thyril|spotted gak|sea nymph|Mistydeep siren|dark vysan|greater ice spider|fire salamander|cave nipper|kobold shepherd|relnak|striped relnak|cave gnoll|hobgoblin|Bresnahanini rolton|velnalin|spotted velnalin|striped gak|white vysan|mountain snowcat|troglodyte|black urgh|water moccasin|cobra|urgh|ridge orc|whiptail|spotted leaper|fanged viper|mongrel kobold|night golem|mongrel hobgoblin|bobcat|coyote|water witch|nasty little gremlin|monkey|spotted lynx|cockatrice|leaper|lesser orc|snowy cockatrice|blood eagle|lesser red orc|hobgoblin shaman|shelfae soldier|lesser burrow orc|greater kappa|greater spider|thrak|crystal crab|greater orc|greater burrow orc|albino tomb spider|mottled thrak|brown spinner|crocodile|manticore|rabid guard dog|great boar|raider orc|cave worm|gnoll worker|giant marmot|shelfae chieftain|Neartofar orc|wall guardian|crystal golem|dark orc|great stag|plumed cockatrice|tawny brindlecat|gnoll thief|deranged sentry|Agresh troll scout|forest troll|grey orc|silverback orc|great brown bear|brown boar|giant weasel|black boar|swamp troll|panther|ridgeback boar|luminescent arachnid|gnoll ranger|large ogre|puma|arctic puma|Neartofar troll|black leopard|humpbacked puma|black bear|Agresh troll warrior|mongrel wolfhound|plains orc warrior|cave troll|phosphorescent worm|hill troll|wind witch|fire guardian|mountain ogre|Agresh bear|mongrel troll|red bear|fire rat|banded rattlesnake|mountain troll|spiked cavern urchin|gnoll guard|giant veaba|plains ogre|forest ogre|mountain goat|black panther|dark shambler|plains orc scout|krolvin mercenary|cave lizard|war troll|fire cat|mountain lion|bighorn sheep|shelfae warlord|plains orc shaman|greenwing hornet|plains lion|thunder troll|krolvin warrior|steel golem|gnoll priest|ogre warrior|massive grahnk|major spider|Agresh troll chieftain|striped warcat|Arachne servant|cave bear|plains orc chieftain|cougar|warthog|crested basilisk|dark panther|centaur|fenghai|Arachne acolyte|tree viper|burly reiver|reiver|ice hound|wolverine|veteran reiver|arctic wolverine|giant albino scorpion|krolvin warfarer|gnoll jarl|jungle troll|Arachne priest|Arachne priestess|troll chieftain|cyclops|Grutik savage|lesser stone gargoyle|snow leopard|giant hawk-owl|fire ogre|dobrem|ki-lin|darken|pra'eda|Grutik shaman|ice troll|arctic manticore|scaly burgee|hooded figure|hisskra warrior|giant albino tomb spider|hunter troll|jungle troll chieftain|mammoth arachnid|ash hag|wild hound|caribou|wild dog|giant fog beetle|mezic|three-toed tegu|hisskra shaman|maw spore|moor hound|sand beetle|tundra giant|colossus vulture|hisskra chieftain|moor witch|cold guardian|lava troll|moor eagle|bog troll|shimmering fungus|water wyrd|snow crone|undertaker bat|dust beetle|krolvin slaver|fire giant|arctic titan|Sheruvian initiate|tusked ursian|huge mein golem|magru|mud wasp|grizzly bear|frost giant|wood sprite|krolvin corsair|vesperti|greater bog troll|stone gargoyle|storm giant|myklian|kiramon worker|lesser ice giant|Sheruvian monk|roa'ter|siren lizard|shan wizard|shan warrior|minor glacei|dark vortece|shan cleric|swamp hag|shan ranger|wasp nest|dreadnought raptor|forest trali shaman|firethorn shoot|polar bear|mastodonic leopard|lesser faeroth|kiramon defender|forest trali|cinder wasp|greater ice giant|major glacei|bog spectre|sand devil|warrior shade|horned vor'taz|red-scaled thrak|greater faeroth|snow madrinol|tomb troll|wooly mammoth|ice golem|lesser ice elemental|sabre-tooth tiger|stone sentinel|animated slush|skayl|tomb troll necromancer|stone troll|glacial morph|lava golem|stone giant|massive pyrothag|black forest viper|massive black boar|fire elemental|black forest ogre|stone mastiff|Illoke mystic|massive troll king|ice elemental|Sheruvian harbinger|grifflet|fire sprite|emaciated hierophant|red tsark|Illoke shaman|muscular supplicant|yeti|lesser griffin|hunch-backed dogmatist|krag yeti|fire mage|krag dweller|storm griffin|lesser minotaur|moulis|csetairi|minotaur warrior|farlook|raving lunatic|minotaur magus|dhu goleras|earth elemental|gnarled being|caedera|greater krynch|gremlock|Illoke elder|festering taint|aivren|greater earth elemental|Ithzir scout|Illoke jarl|Ithzir initiate|water elemental|Ithzir janissary|Ithzir herald|triton dissembler|greater construct|Ithzir adept|triton executioner|siren|Ithzir seer|triton combatant|triton radical|war griffin|triton magus|greater water elemental/
|
28
|
-
end
|
21
|
+
class Regexp
|
22
|
+
def or(re)
|
23
|
+
Regexp.new self.to_s + "|" + re.to_s
|
24
|
+
end
|
25
|
+
# define union operator for regex instance
|
26
|
+
def |(re)
|
27
|
+
self.or(re)
|
28
|
+
end
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
class Symbol
|
32
|
+
def to_game
|
33
|
+
self.to_s.gsub("_", " ")
|
34
|
+
end
|
35
|
+
end
|
33
36
|
|
34
|
-
def Creature.grimswarm(name)
|
35
|
-
name =~ /griswarm/i
|
36
|
-
end
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
class Creature
|
39
|
+
include Comparable
|
40
|
+
|
41
|
+
WOUNDS = [
|
42
|
+
:right_leg, :left_leg, :right_arm,
|
43
|
+
:left_arm, :head, :neck, :chest,
|
44
|
+
:abdomen, :back, :left_eye, :right_eye,
|
45
|
+
:right_hand, :left_hand, :nerves,
|
46
|
+
]
|
47
|
+
|
48
|
+
TAGS = OpenStruct.new(
|
49
|
+
undead: /zombie|ghost|skele|ghoul|spectral|wight|shade/ |
|
50
|
+
/spectre|revenant|apparition|bone|were|rotting/ |
|
51
|
+
/spirit|soul|barghest|vruul|night|phant|naisirc/|
|
52
|
+
/shrickhen|seraceris|n'ecare|vourkha|bendith/ |
|
53
|
+
/baesrukha|lich|dybbuk|necrotic|flesh|waern|banshee/|
|
54
|
+
/seeker|eidolon|decay|putrefied|vaespilon/,
|
55
|
+
antimagic: /construct|Vvrael/,
|
56
|
+
grimswarm: /grimswarm/,
|
57
|
+
lowly: /kobold|rolton|velnalin|urgh/,
|
58
|
+
trollish: /troll|csetari/
|
59
|
+
)
|
60
|
+
|
61
|
+
def self.tags(name)
|
62
|
+
TAGS.each_pair.reduce([]) do |is, pair|
|
63
|
+
tag, pattern = pair
|
64
|
+
name =~ pattern ? is + [tag] : is
|
40
65
|
end
|
66
|
+
end
|
41
67
|
|
42
|
-
|
43
|
-
|
44
|
-
end
|
68
|
+
attr_accessor :wounds, :targetable, :can_cast, :tags,
|
69
|
+
:data, :legged, :limbed, :id, :name
|
45
70
|
|
46
|
-
|
47
|
-
|
71
|
+
def initialize(creature)
|
72
|
+
@id = creature.id
|
73
|
+
@name = creature.name
|
74
|
+
@wounds = {}
|
75
|
+
@tags = ((creature.type || "").gsub(",", " ").split(" ") + (metadata["tags"] || []) ).map(&:to_sym)
|
76
|
+
TAGS.each_pair do |tag, pattern|
|
77
|
+
@tags << tag if @name =~ pattern
|
48
78
|
end
|
79
|
+
heal
|
80
|
+
end
|
49
81
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}.compact
|
54
|
-
end
|
82
|
+
def level
|
83
|
+
metadata["level"]
|
84
|
+
end
|
55
85
|
|
56
|
-
|
57
|
-
|
58
|
-
|
86
|
+
def metadata
|
87
|
+
Creatures::BY_NAME[@name] || {}
|
88
|
+
end
|
59
89
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@wounds = {}
|
64
|
-
@data = {}
|
65
|
-
|
66
|
-
tag('trollish') if Creature.self_healing?(creature.name)
|
67
|
-
@data[:incapacitated] = false
|
68
|
-
@data[:tags] = Creature.tag(creature.name)
|
69
|
-
|
70
|
-
heal
|
71
|
-
# call the Gameobj_Extender initialize method that copies the game properties to this class
|
72
|
-
super(creature)
|
73
|
-
end
|
90
|
+
def fetch
|
91
|
+
GameObj[@id]
|
92
|
+
end
|
74
93
|
|
75
|
-
|
76
|
-
|
77
|
-
|
94
|
+
def status
|
95
|
+
fetch.status.split(" ")
|
96
|
+
end
|
78
97
|
|
79
|
-
|
80
|
-
|
98
|
+
def heal
|
99
|
+
WOUNDS.each do |location|
|
100
|
+
@wounds[location] = 0
|
81
101
|
end
|
102
|
+
self
|
103
|
+
end
|
104
|
+
|
105
|
+
def injuries
|
106
|
+
fput "look ##{@id}"
|
107
|
+
woundinfo = matchtimeout(2, /(he|she|it) (?:has|appears to be in good) .*/i)
|
108
|
+
if woundinfo =~ /appears to be in good shape/ then heal; return @wounds; end
|
109
|
+
if woundinfo =~ /some minor cuts and bruises on (his|her|its) right (?:hind )?leg/ then @wounds[:right_leg] = 1; end
|
110
|
+
if woundinfo =~ /some minor cuts and bruises on (his|her|its) left (?:hind )?leg/ then @wounds[:left_leg] = 1; end
|
111
|
+
if woundinfo =~ /some minor cuts and bruises on (his|her|its) (?:right arm|right foreleg)/ then @wounds[:right_arm] = 1; end
|
112
|
+
if woundinfo =~ /some minor cuts and bruises on (his|her|its) (?:left arm|left foreleg)/ then @wounds[:left_arm] = 1; end
|
113
|
+
if woundinfo =~ /minor bruises around (his|her|its) neck/ then @wounds[:neck] = 1; end
|
114
|
+
if woundinfo =~ /minor bruises around (his|her|its) head/ then @wounds[:head] = 1; end
|
115
|
+
if woundinfo =~ /minor cuts and bruises on (his|her|its) chest/ then @wounds[:chest] = 1; end
|
116
|
+
if woundinfo =~ /minor cuts and bruises on (his|her|its) abdomen/ then @wounds[:abdomen] = 1; end
|
117
|
+
if woundinfo =~ /minor cuts and bruises on (his|her|its) back/ then @wounds[:back] = 1; end
|
118
|
+
if woundinfo =~ /bruised left eye/ then @wounds[:left_eye] = 1; end
|
119
|
+
if woundinfo =~ /bruised right eye/ then @wounds[:right_eye] = 1; end
|
120
|
+
if woundinfo =~ /some minor cuts and bruises on (his|her|its) right (?:hand|paw|claw)/ then @wounds[:right_hand] = 1; end
|
121
|
+
if woundinfo =~ /some minor cuts and bruises on (his|her|its) left (?:hand|paw|claw)/ then @wounds[:left_hand] = 1; end
|
122
|
+
if woundinfo =~ /a strange case of muscle twitching/ then @wounds[:nerves] = 1; end
|
123
|
+
if woundinfo =~ /fractured and bleeding right (?:hind )?leg/ then @wounds[:right_leg] = 2; end
|
124
|
+
if woundinfo =~ /fractured and bleeding left (?:hind )?leg/ then @wounds[:left_leg] = 2; end
|
125
|
+
if woundinfo =~ /fractured and bleeding (?:right arm|right foreleg)/ then @wounds[:right_arm] = 2; end
|
126
|
+
if woundinfo =~ /fractured and bleeding (?:left arm|left foreleg)/ then @wounds[:left_arm] = 2; end
|
127
|
+
if woundinfo =~ /moderate bleeding from (his|her|its) neck/ then @wounds[:neck] = 2; end
|
128
|
+
if woundinfo =~ /minor lacerations about (his|her|its) head and a possible mild concussion/ then @wounds[:head] = 2; end
|
129
|
+
if woundinfo =~ /deep lacerations across (his|her|its) chest/ then @wounds[:chest] = 2; end
|
130
|
+
if woundinfo =~ /deep lacerations across (his|her|its) abdomen/ then @wounds[:abdomen] = 2; end
|
131
|
+
if woundinfo =~ /deep lacerations across (his|her|its) back/ then @wounds[:back] = 2; end
|
132
|
+
if woundinfo =~ /swollen left eye/ then @wounds[:left_eye] = 2; end
|
133
|
+
if woundinfo =~ /swollen right eye/ then @wounds[:right_eye] = 2; end
|
134
|
+
if woundinfo =~ /fractured and bleeding right (?:hand|paw|claw)/ then @wounds[:right_hand] = 2; end
|
135
|
+
if woundinfo =~ /fractured and bleeding left (?:hand|paw|claw)/ then @wounds[:left_hand] = 2; end
|
136
|
+
if woundinfo =~ /a case of sporadic convulsions/ then @wounds[:nerves] = 2; end
|
137
|
+
if woundinfo =~ /severed right (?:hind )?leg/ then @wounds[:right_leg] = 3; end
|
138
|
+
if woundinfo =~ /severed left (?:hind )?leg/ then @wounds[:left_leg] = 3; end
|
139
|
+
if woundinfo =~ /severed (?:right arm|right foreleg)/ then @wounds[:right_arm] = 3; end
|
140
|
+
if woundinfo =~ /severed (?:left arm|left foreleg)/ then @wounds[:left_arm] = 3; end
|
141
|
+
if woundinfo =~ /snapped bones and serious bleeding from (his|her|its) neck/ then @wounds[:neck] = 3; end
|
142
|
+
if woundinfo =~ /severe head trauma and bleeding from (his|her|its) ears/ then @wounds[:head] = 3; end
|
143
|
+
if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) chest/ then @wounds[:chest] = 3; end
|
144
|
+
if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) abdomen/ then @wounds[:abdomen] = 3; end
|
145
|
+
if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) back/ then @wounds[:back] = 3; end
|
146
|
+
if woundinfo =~ /blinded left eye/ then @wounds[:left_eye] = 3; end
|
147
|
+
if woundinfo =~ /blinded right eye/ then @wounds[:right_eye] = 3; end
|
148
|
+
if woundinfo =~ /severed right (?:hand|paw|claw)/ then @wounds[:right_hand] = 3; end
|
149
|
+
if woundinfo =~ /severed left (?:hand|paw|claw)/ then @wounds[:left_hand] = 3; end
|
150
|
+
if woundinfo =~ /a case of uncontrollable convulsions/ then @wounds[:nerves] = 3; end
|
151
|
+
@wounds
|
152
|
+
end
|
153
|
+
|
154
|
+
def status
|
155
|
+
GameObj[@id].status.split(" ").map(&:to_sym)
|
156
|
+
end
|
82
157
|
|
83
|
-
|
84
|
-
|
85
|
-
|
158
|
+
def legged?
|
159
|
+
injuries
|
160
|
+
@wounds[:right_leg] == 3 || @wounds[:left_leg] == 3
|
161
|
+
end
|
86
162
|
|
87
|
-
|
88
|
-
|
89
|
-
|
163
|
+
def can_cast?
|
164
|
+
injuries
|
165
|
+
@wounds[:right_arm] == 3 || @wounds[:head] == 3
|
166
|
+
end
|
90
167
|
|
91
|
-
|
92
|
-
|
93
|
-
|
168
|
+
def alive?
|
169
|
+
!dead?
|
170
|
+
end
|
94
171
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
def injuries
|
101
|
-
fput "look ##{@id}"
|
102
|
-
woundinfo = matchtimeout(2, /(he|she|it) (?:has|appears to be in good) .*/i)
|
103
|
-
if woundinfo =~ /appears to be in good shape/ then heal; return @wounds; end
|
104
|
-
if woundinfo =~ /some minor cuts and bruises on (his|her|its) right (?:hind )?leg/ then @wounds[:right_leg] = 1; end
|
105
|
-
if woundinfo =~ /some minor cuts and bruises on (his|her|its) left (?:hind )?leg/ then @wounds[:left_leg] = 1; end
|
106
|
-
if woundinfo =~ /some minor cuts and bruises on (his|her|its) (?:right arm|right foreleg)/ then @wounds[:right_arm] = 1; end
|
107
|
-
if woundinfo =~ /some minor cuts and bruises on (his|her|its) (?:left arm|left foreleg)/ then @wounds[:left_arm] = 1; end
|
108
|
-
if woundinfo =~ /minor bruises around (his|her|its) neck/ then @wounds[:neck] = 1; end
|
109
|
-
if woundinfo =~ /minor bruises around (his|her|its) head/ then @wounds[:head] = 1; end
|
110
|
-
if woundinfo =~ /minor cuts and bruises on (his|her|its) chest/ then @wounds[:chest] = 1; end
|
111
|
-
if woundinfo =~ /minor cuts and bruises on (his|her|its) abdomen/ then @wounds[:abdomen] = 1; end
|
112
|
-
if woundinfo =~ /minor cuts and bruises on (his|her|its) back/ then @wounds[:back] = 1; end
|
113
|
-
if woundinfo =~ /bruised left eye/ then @wounds[:left_eye] = 1; end
|
114
|
-
if woundinfo =~ /bruised right eye/ then @wounds[:right_eye] = 1; end
|
115
|
-
if woundinfo =~ /some minor cuts and bruises on (his|her|its) right (?:hand|paw|claw)/ then @wounds[:right_hand] = 1; end
|
116
|
-
if woundinfo =~ /some minor cuts and bruises on (his|her|its) left (?:hand|paw|claw)/ then @wounds[:left_hand] = 1; end
|
117
|
-
if woundinfo =~ /a strange case of muscle twitching/ then @wounds[:nerves] = 1; end
|
118
|
-
if woundinfo =~ /fractured and bleeding right (?:hind )?leg/ then @wounds[:right_leg] = 2; end
|
119
|
-
if woundinfo =~ /fractured and bleeding left (?:hind )?leg/ then @wounds[:left_leg] = 2; end
|
120
|
-
if woundinfo =~ /fractured and bleeding (?:right arm|right foreleg)/ then @wounds[:right_arm] = 2; end
|
121
|
-
if woundinfo =~ /fractured and bleeding (?:left arm|left foreleg)/ then @wounds[:left_arm] = 2; end
|
122
|
-
if woundinfo =~ /moderate bleeding from (his|her|its) neck/ then @wounds[:neck] = 2; end
|
123
|
-
if woundinfo =~ /minor lacerations about (his|her|its) head and a possible mild concussion/ then @wounds[:head] = 2; end
|
124
|
-
if woundinfo =~ /deep lacerations across (his|her|its) chest/ then @wounds[:chest] = 2; end
|
125
|
-
if woundinfo =~ /deep lacerations across (his|her|its) abdomen/ then @wounds[:abdomen] = 2; end
|
126
|
-
if woundinfo =~ /deep lacerations across (his|her|its) back/ then @wounds[:back] = 2; end
|
127
|
-
if woundinfo =~ /swollen left eye/ then @wounds[:left_eye] = 2; end
|
128
|
-
if woundinfo =~ /swollen right eye/ then @wounds[:right_eye] = 2; end
|
129
|
-
if woundinfo =~ /fractured and bleeding right (?:hand|paw|claw)/ then @wounds[:right_hand] = 2; end
|
130
|
-
if woundinfo =~ /fractured and bleeding left (?:hand|paw|claw)/ then @wounds[:left_hand] = 2; end
|
131
|
-
if woundinfo =~ /a case of sporadic convulsions/ then @wounds[:nerves] = 2; end
|
132
|
-
if woundinfo =~ /severed right (?:hind )?leg/ then @wounds[:right_leg] = 3; end
|
133
|
-
if woundinfo =~ /severed left (?:hind )?leg/ then @wounds[:left_leg] = 3; end
|
134
|
-
if woundinfo =~ /severed (?:right arm|right foreleg)/ then @wounds[:right_arm] = 3; end
|
135
|
-
if woundinfo =~ /severed (?:left arm|left foreleg)/ then @wounds[:left_arm] = 3; end
|
136
|
-
if woundinfo =~ /snapped bones and serious bleeding from (his|her|its) neck/ then @wounds[:neck] = 3; end
|
137
|
-
if woundinfo =~ /severe head trauma and bleeding from (his|her|its) ears/ then @wounds[:head] = 3; end
|
138
|
-
if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) chest/ then @wounds[:chest] = 3; end
|
139
|
-
if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) abdomen/ then @wounds[:abdomen] = 3; end
|
140
|
-
if woundinfo =~ /deep gashes and serious bleeding from (his|her|its) back/ then @wounds[:back] = 3; end
|
141
|
-
if woundinfo =~ /blinded left eye/ then @wounds[:left_eye] = 3; end
|
142
|
-
if woundinfo =~ /blinded right eye/ then @wounds[:right_eye] = 3; end
|
143
|
-
if woundinfo =~ /severed right (?:hand|paw|claw)/ then @wounds[:right_hand] = 3; end
|
144
|
-
if woundinfo =~ /severed left (?:hand|paw|claw)/ then @wounds[:left_hand] = 3; end
|
145
|
-
if woundinfo =~ /a case of uncontrollable convulsions/ then @wounds[:nerves] = 3; end
|
146
|
-
@wounds
|
147
|
-
end
|
148
|
-
|
149
|
-
def status
|
150
|
-
GameObj[@id].status
|
151
|
-
end
|
172
|
+
def limbed?
|
173
|
+
injuries
|
174
|
+
@wounds[:right_leg] == 3 || @wounds[:left_leg] == 3 || @wounds[:right_arm] == 3
|
175
|
+
end
|
152
176
|
|
153
|
-
|
154
|
-
|
155
|
-
|
177
|
+
def gone?
|
178
|
+
fetch.nil? ? true : false
|
179
|
+
end
|
156
180
|
|
157
|
-
|
158
|
-
|
159
|
-
|
181
|
+
def prone?
|
182
|
+
status.include?(:lying) || status.include?(:prone) ? true : false
|
183
|
+
end
|
160
184
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
185
|
+
def eql?(other)
|
186
|
+
self == other
|
187
|
+
end
|
165
188
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
end
|
189
|
+
def ==(other)
|
190
|
+
@id.to_i == other.id.to_i
|
191
|
+
end
|
170
192
|
|
171
|
-
def limbed?
|
172
|
-
injuries
|
173
|
-
trollish? ? false : @wounds[:right_leg] == 3 || @wounds[:left_leg] == 3 || @wounds[:right_arm] == 3 || dead? || gone?
|
174
|
-
end
|
175
193
|
|
176
|
-
|
177
|
-
|
178
|
-
|
194
|
+
def danger
|
195
|
+
status
|
196
|
+
.map do |state| Creatures::STATES.index(state) end
|
197
|
+
.reduce(&:+) || -1
|
198
|
+
end
|
179
199
|
|
180
|
-
|
181
|
-
|
182
|
-
|
200
|
+
def <=>(other)
|
201
|
+
self.danger <=> other.danger
|
202
|
+
end
|
183
203
|
|
184
|
-
|
185
|
-
|
186
|
-
|
204
|
+
def stunned?
|
205
|
+
status.include?(:stunned) ? true : false
|
206
|
+
end
|
187
207
|
|
188
|
-
|
189
|
-
|
190
|
-
|
208
|
+
def kill_shot(order = [:left_eye, :right_eye, :head, :neck, :back], default = :chest)
|
209
|
+
wounds = injuries
|
210
|
+
return (order
|
211
|
+
.drop_while do |area| @wounds[area] == 3 end
|
212
|
+
.first || default).to_game
|
213
|
+
end
|
191
214
|
|
192
|
-
|
193
|
-
|
194
|
-
|
215
|
+
def targetable?
|
216
|
+
target if @targetable.nil?
|
217
|
+
@targetable
|
218
|
+
end
|
195
219
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
location = "right eye" if @wounds[:left_eye] == 3
|
200
|
-
location = "head" if @wounds[:right_eye] == 3
|
201
|
-
location = "neck" if @wounds[:head] == 3
|
202
|
-
location = "back" if @wounds[:neck] == 3
|
203
|
-
location
|
220
|
+
[Creatures::ARCHETYPES, Creatures::STATES].flatten.each do |state|
|
221
|
+
define_method((state.to_s + "?").to_sym) do
|
222
|
+
[tags, status].flatten.include?(state)
|
204
223
|
end
|
224
|
+
end
|
205
225
|
|
206
|
-
def target
|
207
|
-
result = dothistimeout "target ##{@id}", 3, /#{Olib::Dictionary.targetable.values.join('|')}/
|
208
|
-
@targetable = result =~ Olib::Dictionary.targetable[:yes] ? true : false
|
209
|
-
self
|
210
|
-
end
|
211
226
|
|
212
|
-
|
213
|
-
|
214
|
-
|
227
|
+
def target
|
228
|
+
result = dothistimeout "target ##{@id}", 3, /#{Olib::Dictionary.targetable.values.join('|')}/
|
229
|
+
@targetable = result =~ Olib::Dictionary.targetable[:yes] ? true : false
|
230
|
+
self
|
231
|
+
end
|
215
232
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
waitrt?
|
220
|
-
end
|
221
|
-
fput "aim #{location}" if location
|
222
|
-
fput "ambush ##{@id}"
|
233
|
+
def ambush(location=nil)
|
234
|
+
until hidden?
|
235
|
+
fput "hide"
|
223
236
|
waitrt?
|
224
|
-
self
|
225
237
|
end
|
238
|
+
Char.aim(location) if location
|
239
|
+
fput "ambush ##{@id}"
|
240
|
+
waitrt?
|
241
|
+
self
|
242
|
+
end
|
226
243
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
self
|
244
|
+
def mstrike
|
245
|
+
unless dead?
|
246
|
+
fput "mstrike ##{@id}"
|
231
247
|
end
|
248
|
+
self
|
249
|
+
end
|
232
250
|
|
233
|
-
|
251
|
+
def kill
|
252
|
+
unless dead?
|
234
253
|
fput "kill ##{@id}"
|
235
|
-
waitrt?
|
236
|
-
self
|
237
254
|
end
|
255
|
+
self
|
256
|
+
end
|
238
257
|
|
239
|
-
|
240
|
-
|
241
|
-
|
258
|
+
def fire(location=nil)
|
259
|
+
unless dead?
|
260
|
+
Char.aim(location) if location
|
261
|
+
fput "fire ##{@id}"
|
242
262
|
end
|
263
|
+
self
|
264
|
+
end
|
243
265
|
|
244
|
-
|
245
|
-
|
246
|
-
|
266
|
+
def hurl(location=nil)
|
267
|
+
unless dead?
|
268
|
+
Char.aim(location) if location
|
269
|
+
fput "hurl ##{@id}"
|
247
270
|
end
|
271
|
+
self
|
272
|
+
end
|
273
|
+
|
274
|
+
def search
|
275
|
+
waitrt?
|
276
|
+
fput "search ##{@id}" if dead?
|
248
277
|
end
|
249
|
-
end
|
250
278
|
|
251
|
-
|
252
|
-
|
253
|
-
##
|
254
|
-
|
279
|
+
def skin
|
280
|
+
waitrt?
|
281
|
+
fput "skin ##{@id}" if dead?
|
282
|
+
self
|
283
|
+
end
|
284
|
+
|
285
|
+
def to_s
|
286
|
+
"<#{fetch.name}:#{@id} @danger=#{danger} @tags=#{tags} @status=#{status}>"
|
287
|
+
end
|
255
288
|
end
|
289
|
+
|