Olib 0.0.8 → 0.0.9
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/Olib.gemspec +17 -16
- data/README.md +23 -21
- data/TODOS.md +3 -3
- data/lib/Olib.rb +88 -50
- data/lib/Olib/area.rb +51 -0
- data/lib/Olib/bounty.rb +171 -128
- data/lib/Olib/character/char.rb +113 -118
- data/lib/Olib/character/group.rb +68 -67
- data/lib/Olib/character/inventory.rb +79 -79
- data/lib/Olib/character/mind.rb +70 -0
- data/lib/Olib/combat/creature.rb +255 -249
- data/lib/Olib/combat/creatures.rb +61 -56
- data/lib/Olib/core/container.rb +200 -148
- data/lib/Olib/core/errors.rb +91 -91
- data/lib/Olib/core/extender.rb +27 -19
- data/lib/Olib/core/item.rb +549 -549
- data/lib/Olib/core/utils.rb +220 -220
- data/lib/Olib/dictionary/dictionary.rb +165 -157
- data/lib/Olib/events/emitter.rb +7 -0
- data/lib/Olib/go2.rb +151 -0
- data/lib/Olib/npcs.rb +5 -0
- data/lib/Olib/objects/box.rb +3 -3
- data/lib/Olib/objects/clothing.rb +3 -3
- data/lib/Olib/objects/herb.rb +3 -3
- data/lib/Olib/objects/jar.rb +100 -100
- data/lib/Olib/objects/jewel.rb +34 -34
- data/lib/Olib/objects/jewelry.rb +9 -9
- data/lib/Olib/objects/scroll.rb +71 -71
- data/lib/Olib/objects/uncommon.rb +3 -3
- data/lib/Olib/objects/unknown.rb +3 -3
- data/lib/Olib/objects/wand.rb +3 -3
- data/lib/Olib/shops.rb +176 -176
- data/lib/Olib/utils/cli.rb +80 -80
- data/lib/Olib/utils/help_menu.rb +166 -166
- data/lib/Olib/utils/monsterbold.rb +4 -4
- data/lib/Olib/utils/vbulletin.rb +100 -100
- data/lib/Olib/version.rb +3 -0
- metadata +11 -7
- data/lib/Olib/transport.rb +0 -117
- data/lib/Olib/utils/utils.rb +0 -148
@@ -0,0 +1,70 @@
|
|
1
|
+
require "ostruct"
|
2
|
+
|
3
|
+
class Mind
|
4
|
+
@@states = OpenStruct.new(
|
5
|
+
:saturated => "saturated",
|
6
|
+
:must_rest => "must rest",
|
7
|
+
:numbed => "numbed",
|
8
|
+
:becoming_numbed => "becoming numbed",
|
9
|
+
:muddled => "muddled",
|
10
|
+
:clear => "clear",
|
11
|
+
:fresh_and_clear => "fresh and clear",
|
12
|
+
:clear_as_a_bell => "clear as a bell"
|
13
|
+
)
|
14
|
+
##
|
15
|
+
## @brief access the states
|
16
|
+
##
|
17
|
+
## @return OpenStruct
|
18
|
+
##
|
19
|
+
def Mind.states
|
20
|
+
@@states
|
21
|
+
end
|
22
|
+
##
|
23
|
+
## @brief alias for Lich checkmind method
|
24
|
+
##
|
25
|
+
## @return String
|
26
|
+
##
|
27
|
+
def Mind.state
|
28
|
+
checkmind
|
29
|
+
end
|
30
|
+
##
|
31
|
+
## @brief returns the percentage of your character's mind
|
32
|
+
##
|
33
|
+
## @return Fixnum
|
34
|
+
##
|
35
|
+
def Mind.percent
|
36
|
+
percentmind
|
37
|
+
end
|
38
|
+
##
|
39
|
+
## dynamically defines all methods to check state
|
40
|
+
##
|
41
|
+
## Example:
|
42
|
+
## Mind.saturated?
|
43
|
+
## Mind.must_rest?
|
44
|
+
##
|
45
|
+
Mind.states.each_pair { |name, str|
|
46
|
+
Mind.define_singleton_method((name.to_s + "?").to_sym) do
|
47
|
+
Mind.state == str
|
48
|
+
end
|
49
|
+
|
50
|
+
Mind.define_singleton_method("until_not_#{name.to_s}".to_sym) do
|
51
|
+
wait_until { Mind.state != str }
|
52
|
+
end
|
53
|
+
|
54
|
+
Mind.define_singleton_method("until_#{name.to_s}".to_sym) do
|
55
|
+
wait_until { Mind.state == str }
|
56
|
+
end
|
57
|
+
}
|
58
|
+
##
|
59
|
+
## @brief returns you to your current origin and waits
|
60
|
+
## until your mind is rested
|
61
|
+
##
|
62
|
+
## @param state The state
|
63
|
+
##
|
64
|
+
## @return nil
|
65
|
+
##
|
66
|
+
def Mind.rest!(state=Mind.states.saturated)
|
67
|
+
Go2.origin
|
68
|
+
wait_until { Mind.state != state }
|
69
|
+
end
|
70
|
+
end
|
data/lib/Olib/combat/creature.rb
CHANGED
@@ -1,249 +1,255 @@
|
|
1
|
-
# enables creature specific logic
|
2
|
-
# TODO
|
3
|
-
# - add flying types
|
4
|
-
# - add corporeal types
|
5
|
-
# - add quadrapedal types
|
6
|
-
# - add known spells/cmans/manuevers and algorithm for danger level by profession and skills
|
7
|
-
|
8
|
-
module Olib
|
9
|
-
class Creature < Olib::Gameobj_Extender
|
10
|
-
def Creature.escortee(name)
|
11
|
-
name =~ /^(?:traveller|magistrate|merchant|scribe|dignitary|official)$/
|
12
|
-
end
|
13
|
-
|
14
|
-
def Creature.bandit(name)
|
15
|
-
name =~ /thief|rogue|bandit|mugger|outlaw|highwayman|marauder|brigand|thug|robber/
|
16
|
-
end
|
17
|
-
|
18
|
-
def Creature.undead(name)
|
19
|
-
name =~ /zombie rolton|lesser ghoul|skeleton|lesser frost shade|lesser shade|phantom|moaning phantom|ghost|ice skeleton|greater ghoul|revenant|mist wraith|dark apparition|lesser mummy|firephantom|spectral fisherman|bone golem|snow spectre|death dirge|werebear|darkwoode|spectre|shadowy spectre|wraith|tomb wight|wolfshade|ghoul master|ghost wolf|ghostly warrior|dark assassin|rotting krolvin pirate|elder ghoul master|nedum vereri|arch wight|wood wight|ancient ghoul master|nonomino|zombie|crazed zombie|rotting woodsman|roa'ter wormling|carceris|spectral monk|tree spirit|monastic lich|skeletal lord|moaning spirit|elder tree spirit|krynch|skeletal ice troll|rotting corpse|rotting farmhand|ghostly mara|ghostly pooka|skeletal giant|rock troll zombie|skeletal soldier|spectral warrior|troll wraith|spectral shade|barghest|spectral woodsman|spectral lord|skeletal warhorse|lesser moor wight|shadow mare|shadow steed|vourkha|greater moor wight|forest bendith|spectral miner|bog wraith|phantasma|frozen corpse|baesrukha|night mare|gaunt spectral servant|bog wight|ice wraith|lesser vruul|rotting chimera|dybbuk|necrotic snake|waern|banshee|flesh golem|seeker|ethereal mage apprentice|nightmare steed|eidolon|decaying Citadel guardsman|rotting Citadel arbalester|putrefied Citadel herald|phantasmal bestial swordsman|wind wraith|soul golem|greater vruul|naisirc|shrickhen|seraceris|lich qyn'arj|n'ecare|lost soul|vaespilon|spectral triton defender|ethereal triton sentry/
|
20
|
-
end
|
21
|
-
|
22
|
-
def Creature.antimagic(name)
|
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
|
29
|
-
|
30
|
-
def Creature.invasion(name)
|
31
|
-
name =~ /taladorian/i
|
32
|
-
end
|
33
|
-
|
34
|
-
def Creature.grimswarm(name)
|
35
|
-
name =~ /griswarm/i
|
36
|
-
end
|
37
|
-
|
38
|
-
def Creature.animate(name)
|
39
|
-
name =~ /animated/
|
40
|
-
end
|
41
|
-
|
42
|
-
def Creature.ignoreable(name)
|
43
|
-
name =~ /kobold|rolton|velnalin|urgh/
|
44
|
-
end
|
45
|
-
|
46
|
-
def Creature.self_healing?(name)
|
47
|
-
name =~ /troll|csetari/ ? true : false
|
48
|
-
end
|
49
|
-
|
50
|
-
def Creature.tag(name)
|
51
|
-
Creature.tags.map { |type|
|
52
|
-
Creature.send(type, name) ? type : nil
|
53
|
-
}.compact
|
54
|
-
end
|
55
|
-
|
56
|
-
def Creature.tags
|
57
|
-
['undead', 'living', 'antimagic', 'bandit', 'invasion', 'grimswarm', 'ignoreable', 'escortee', 'animate']
|
58
|
-
end
|
59
|
-
|
60
|
-
attr_accessor :wounds, :targetable, :can_cast, :tags, :data, :legged, :limbed
|
61
|
-
|
62
|
-
def initialize(creature)
|
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
|
74
|
-
|
75
|
-
def tags
|
76
|
-
@data[:tags]
|
77
|
-
end
|
78
|
-
|
79
|
-
def tag(tag)
|
80
|
-
@data[:tags].push(tag)
|
81
|
-
end
|
82
|
-
|
83
|
-
def is?(t)
|
84
|
-
tags.include?(t)
|
85
|
-
end
|
86
|
-
|
87
|
-
def bandit?
|
88
|
-
tags.include?('bandit')
|
89
|
-
end
|
90
|
-
|
91
|
-
def grimswarm?
|
92
|
-
tags.include('grimswarm')
|
93
|
-
end
|
94
|
-
|
95
|
-
def heal
|
96
|
-
[:right_leg, :left_leg, :right_arm, :left_arm, :head, :neck, :chest, :abdomen, :back, :left_eye, :right_eye, :right_hand, :left_hand, :nerves].each do |location| @wounds[location] = 0 end
|
97
|
-
@wounds
|
98
|
-
end
|
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
|
152
|
-
|
153
|
-
def trollish?
|
154
|
-
@data[:trollish]
|
155
|
-
end
|
156
|
-
|
157
|
-
def ignorable?
|
158
|
-
is?('ignoreable')
|
159
|
-
end
|
160
|
-
|
161
|
-
def legged?
|
162
|
-
injuries
|
163
|
-
trollish? ? false : @wounds[:right_leg] == 3 || @wounds[:left_leg] == 3 || dead? || gone?
|
164
|
-
end
|
165
|
-
|
166
|
-
def can_cast?
|
167
|
-
injuries
|
168
|
-
trollish? ? false : @wounds[:right_arm] == 3 || @wounds[:head] == 3 || dead? || gone?
|
169
|
-
end
|
170
|
-
|
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
|
-
|
176
|
-
def dead?
|
177
|
-
status =~ /dead/ ? true : false
|
178
|
-
end
|
179
|
-
|
180
|
-
def active?
|
181
|
-
!stunned?
|
182
|
-
end
|
183
|
-
|
184
|
-
def gone?
|
185
|
-
GameObj[@id].nil? ? true : false
|
186
|
-
end
|
187
|
-
|
188
|
-
def prone?
|
189
|
-
status =~ /lying|prone/ ? true : false
|
190
|
-
end
|
191
|
-
|
192
|
-
def stunned?
|
193
|
-
status =~ /stunned/ ? true : false
|
194
|
-
end
|
195
|
-
|
196
|
-
def kill_shot
|
197
|
-
wounds = injuries
|
198
|
-
location = "left eye"
|
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
|
204
|
-
end
|
205
|
-
|
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
|
-
|
212
|
-
def search
|
213
|
-
fput "search ##{@id}" if dead?
|
214
|
-
end
|
215
|
-
|
216
|
-
def ambush(location=nil)
|
217
|
-
until hidden?
|
218
|
-
fput "hide"
|
219
|
-
waitrt?
|
220
|
-
end
|
221
|
-
fput "aim #{location}" if location
|
222
|
-
fput "ambush ##{@id}"
|
223
|
-
waitrt?
|
224
|
-
self
|
225
|
-
end
|
226
|
-
|
227
|
-
def mstrike
|
228
|
-
fput "mstrike ##{@id}"
|
229
|
-
waitrt?
|
230
|
-
self
|
231
|
-
end
|
232
|
-
|
233
|
-
def kill
|
234
|
-
fput "kill ##{@id}"
|
235
|
-
waitrt?
|
236
|
-
self
|
237
|
-
end
|
238
|
-
|
239
|
-
def targetable?
|
240
|
-
target if @targetable.nil?
|
241
|
-
@targetable
|
242
|
-
end
|
243
|
-
|
244
|
-
def search
|
245
|
-
waitrt?
|
246
|
-
fput "search ##{id}"
|
247
|
-
end
|
248
|
-
end
|
249
|
-
end
|
1
|
+
# enables creature specific logic
|
2
|
+
# TODO
|
3
|
+
# - add flying types
|
4
|
+
# - add corporeal types
|
5
|
+
# - add quadrapedal types
|
6
|
+
# - add known spells/cmans/manuevers and algorithm for danger level by profession and skills
|
7
|
+
|
8
|
+
module Olib
|
9
|
+
class Creature < Olib::Gameobj_Extender
|
10
|
+
def Creature.escortee(name)
|
11
|
+
name =~ /^(?:traveller|magistrate|merchant|scribe|dignitary|official)$/
|
12
|
+
end
|
13
|
+
|
14
|
+
def Creature.bandit(name)
|
15
|
+
name =~ /thief|rogue|bandit|mugger|outlaw|highwayman|marauder|brigand|thug|robber/
|
16
|
+
end
|
17
|
+
|
18
|
+
def Creature.undead(name)
|
19
|
+
name =~ /zombie rolton|lesser ghoul|skeleton|lesser frost shade|lesser shade|phantom|moaning phantom|ghost|ice skeleton|greater ghoul|revenant|mist wraith|dark apparition|lesser mummy|firephantom|spectral fisherman|bone golem|snow spectre|death dirge|werebear|darkwoode|spectre|shadowy spectre|wraith|tomb wight|wolfshade|ghoul master|ghost wolf|ghostly warrior|dark assassin|rotting krolvin pirate|elder ghoul master|nedum vereri|arch wight|wood wight|ancient ghoul master|nonomino|zombie|crazed zombie|rotting woodsman|roa'ter wormling|carceris|spectral monk|tree spirit|monastic lich|skeletal lord|moaning spirit|elder tree spirit|krynch|skeletal ice troll|rotting corpse|rotting farmhand|ghostly mara|ghostly pooka|skeletal giant|rock troll zombie|skeletal soldier|spectral warrior|troll wraith|spectral shade|barghest|spectral woodsman|spectral lord|skeletal warhorse|lesser moor wight|shadow mare|shadow steed|vourkha|greater moor wight|forest bendith|spectral miner|bog wraith|phantasma|frozen corpse|baesrukha|night mare|gaunt spectral servant|bog wight|ice wraith|lesser vruul|rotting chimera|dybbuk|necrotic snake|waern|banshee|flesh golem|seeker|ethereal mage apprentice|nightmare steed|eidolon|decaying Citadel guardsman|rotting Citadel arbalester|putrefied Citadel herald|phantasmal bestial swordsman|wind wraith|soul golem|greater vruul|naisirc|shrickhen|seraceris|lich qyn'arj|n'ecare|lost soul|vaespilon|spectral triton defender|ethereal triton sentry/
|
20
|
+
end
|
21
|
+
|
22
|
+
def Creature.antimagic(name)
|
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
|
29
|
+
|
30
|
+
def Creature.invasion(name)
|
31
|
+
name =~ /taladorian/i
|
32
|
+
end
|
33
|
+
|
34
|
+
def Creature.grimswarm(name)
|
35
|
+
name =~ /griswarm/i
|
36
|
+
end
|
37
|
+
|
38
|
+
def Creature.animate(name)
|
39
|
+
name =~ /animated/
|
40
|
+
end
|
41
|
+
|
42
|
+
def Creature.ignoreable(name)
|
43
|
+
name =~ /kobold|rolton|velnalin|urgh/
|
44
|
+
end
|
45
|
+
|
46
|
+
def Creature.self_healing?(name)
|
47
|
+
name =~ /troll|csetari/ ? true : false
|
48
|
+
end
|
49
|
+
|
50
|
+
def Creature.tag(name)
|
51
|
+
Creature.tags.map { |type|
|
52
|
+
Creature.send(type, name) ? type : nil
|
53
|
+
}.compact
|
54
|
+
end
|
55
|
+
|
56
|
+
def Creature.tags
|
57
|
+
['undead', 'living', 'antimagic', 'bandit', 'invasion', 'grimswarm', 'ignoreable', 'escortee', 'animate']
|
58
|
+
end
|
59
|
+
|
60
|
+
attr_accessor :wounds, :targetable, :can_cast, :tags, :data, :legged, :limbed
|
61
|
+
|
62
|
+
def initialize(creature)
|
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
|
74
|
+
|
75
|
+
def tags
|
76
|
+
@data[:tags]
|
77
|
+
end
|
78
|
+
|
79
|
+
def tag(tag)
|
80
|
+
@data[:tags].push(tag)
|
81
|
+
end
|
82
|
+
|
83
|
+
def is?(t)
|
84
|
+
tags.include?(t)
|
85
|
+
end
|
86
|
+
|
87
|
+
def bandit?
|
88
|
+
tags.include?('bandit')
|
89
|
+
end
|
90
|
+
|
91
|
+
def grimswarm?
|
92
|
+
tags.include('grimswarm')
|
93
|
+
end
|
94
|
+
|
95
|
+
def heal
|
96
|
+
[:right_leg, :left_leg, :right_arm, :left_arm, :head, :neck, :chest, :abdomen, :back, :left_eye, :right_eye, :right_hand, :left_hand, :nerves].each do |location| @wounds[location] = 0 end
|
97
|
+
@wounds
|
98
|
+
end
|
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
|
152
|
+
|
153
|
+
def trollish?
|
154
|
+
@data[:trollish]
|
155
|
+
end
|
156
|
+
|
157
|
+
def ignorable?
|
158
|
+
is?('ignoreable')
|
159
|
+
end
|
160
|
+
|
161
|
+
def legged?
|
162
|
+
injuries
|
163
|
+
trollish? ? false : @wounds[:right_leg] == 3 || @wounds[:left_leg] == 3 || dead? || gone?
|
164
|
+
end
|
165
|
+
|
166
|
+
def can_cast?
|
167
|
+
injuries
|
168
|
+
trollish? ? false : @wounds[:right_arm] == 3 || @wounds[:head] == 3 || dead? || gone?
|
169
|
+
end
|
170
|
+
|
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
|
+
|
176
|
+
def dead?
|
177
|
+
status =~ /dead/ ? true : false
|
178
|
+
end
|
179
|
+
|
180
|
+
def active?
|
181
|
+
!stunned?
|
182
|
+
end
|
183
|
+
|
184
|
+
def gone?
|
185
|
+
GameObj[@id].nil? ? true : false
|
186
|
+
end
|
187
|
+
|
188
|
+
def prone?
|
189
|
+
status =~ /lying|prone/ ? true : false
|
190
|
+
end
|
191
|
+
|
192
|
+
def stunned?
|
193
|
+
status =~ /stunned/ ? true : false
|
194
|
+
end
|
195
|
+
|
196
|
+
def kill_shot
|
197
|
+
wounds = injuries
|
198
|
+
location = "left eye"
|
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
|
204
|
+
end
|
205
|
+
|
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
|
+
|
212
|
+
def search
|
213
|
+
fput "search ##{@id}" if dead?
|
214
|
+
end
|
215
|
+
|
216
|
+
def ambush(location=nil)
|
217
|
+
until hidden?
|
218
|
+
fput "hide"
|
219
|
+
waitrt?
|
220
|
+
end
|
221
|
+
fput "aim #{location}" if location
|
222
|
+
fput "ambush ##{@id}"
|
223
|
+
waitrt?
|
224
|
+
self
|
225
|
+
end
|
226
|
+
|
227
|
+
def mstrike
|
228
|
+
fput "mstrike ##{@id}"
|
229
|
+
waitrt?
|
230
|
+
self
|
231
|
+
end
|
232
|
+
|
233
|
+
def kill
|
234
|
+
fput "kill ##{@id}"
|
235
|
+
waitrt?
|
236
|
+
self
|
237
|
+
end
|
238
|
+
|
239
|
+
def targetable?
|
240
|
+
target if @targetable.nil?
|
241
|
+
@targetable
|
242
|
+
end
|
243
|
+
|
244
|
+
def search
|
245
|
+
waitrt?
|
246
|
+
fput "search ##{id}"
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
##
|
252
|
+
## @brief alias for internal Olib Creature
|
253
|
+
##
|
254
|
+
class Creature < Olib::Creature
|
255
|
+
end
|