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
data/lib/Olib/character/char.rb
CHANGED
@@ -1,118 +1,113 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
def Olib.Char
|
115
|
-
Olib::Char
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
1
|
+
class Char
|
2
|
+
@@silvers = 0
|
3
|
+
@@routines = {}
|
4
|
+
|
5
|
+
def Char.hide
|
6
|
+
while not hiding?
|
7
|
+
waitrt?
|
8
|
+
if @@routines[:hiding]
|
9
|
+
@@routines[:hiding].call
|
10
|
+
else
|
11
|
+
fput 'hide'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
Char
|
15
|
+
end
|
16
|
+
|
17
|
+
def Char.fwi_teleporter
|
18
|
+
Vars.teleporter || Vars.mapdb_fwi_trinket
|
19
|
+
end
|
20
|
+
|
21
|
+
def Char.visible?
|
22
|
+
hiding? || invisible?
|
23
|
+
end
|
24
|
+
|
25
|
+
def Char.hiding_routine(procedure)
|
26
|
+
@@routines[:hiding] = procedure
|
27
|
+
Char
|
28
|
+
end
|
29
|
+
|
30
|
+
def Char.left
|
31
|
+
GameObj.left_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.left_hand)
|
32
|
+
end
|
33
|
+
|
34
|
+
def Char.right
|
35
|
+
GameObj.right_hand.name == "Empty" ? nil : Olib::Item.new(GameObj.right_hand)
|
36
|
+
end
|
37
|
+
|
38
|
+
def Char.withdraw(amount)
|
39
|
+
Go2.bank
|
40
|
+
result = Olib.do "withdraw #{amount} silvers", /I'm sorry|hands you/
|
41
|
+
if result =~ /I'm sorry/
|
42
|
+
Go2.origin
|
43
|
+
echo "Unable to withdraw the amount requested for this script to run from your bank account"
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
wealth
|
47
|
+
return self
|
48
|
+
end
|
49
|
+
|
50
|
+
def Char.deposit_all
|
51
|
+
Go2.bank
|
52
|
+
fput "unhide" if invisible? || hidden?
|
53
|
+
fput "deposit all"
|
54
|
+
@@silvers = 0
|
55
|
+
return self
|
56
|
+
end
|
57
|
+
|
58
|
+
def Char.deposit(amt)
|
59
|
+
wealth
|
60
|
+
if wealth >= amt
|
61
|
+
Go2.bank
|
62
|
+
fput "unhide" if invisible? || hidden?
|
63
|
+
fput "deposit #{amt}"
|
64
|
+
end
|
65
|
+
return self
|
66
|
+
end
|
67
|
+
|
68
|
+
# naive share
|
69
|
+
# does not check if you're actually in a group or not
|
70
|
+
def Char.share
|
71
|
+
wealth
|
72
|
+
fput "share #{@silvers}"
|
73
|
+
wealth
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def Char.deplete_wealth(silvers)
|
78
|
+
@@silvers = @@silvers - silvers
|
79
|
+
end
|
80
|
+
|
81
|
+
def Char.smart_wealth
|
82
|
+
return @@silvers if @@silvers
|
83
|
+
Char.wealth
|
84
|
+
end
|
85
|
+
|
86
|
+
def Char.unhide
|
87
|
+
fput 'unhide' if Spell[916].active? or hidden?
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
91
|
+
def Char.hide
|
92
|
+
if Spell[916].known? && Spell[916].affordable?
|
93
|
+
Spell[916].cast
|
94
|
+
else
|
95
|
+
fput "hide" until hidden?
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def Char.wealth
|
100
|
+
fput "info"
|
101
|
+
while(line=get)
|
102
|
+
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\)\:/
|
103
|
+
if line =~ /^\s*Mana\:\s+\-?[0-9]+\s+Silver\:\s+([0-9]+)/
|
104
|
+
@@silvers= $1.to_i
|
105
|
+
break
|
106
|
+
end
|
107
|
+
sleep 0.1
|
108
|
+
end
|
109
|
+
@@silvers
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
end
|
data/lib/Olib/character/group.rb
CHANGED
@@ -1,68 +1,69 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
@@
|
5
|
-
@@
|
6
|
-
@@
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
@@
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
disk_owners
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
1
|
+
module Olib
|
2
|
+
class Group
|
3
|
+
@@characters = {}
|
4
|
+
@@checked = false
|
5
|
+
@@characters[Char.name] = true # YOU CAN NEVER ESCAPE YOURSELF (so your own disk won't fuck up)
|
6
|
+
@@leader = Char.name
|
7
|
+
|
8
|
+
# ran at the initialization of a script
|
9
|
+
def Group.check
|
10
|
+
@@characters = {}
|
11
|
+
|
12
|
+
|
13
|
+
fput "group"
|
14
|
+
while line=get
|
15
|
+
break if line =~ /You are not currently in a group/
|
16
|
+
Group.define($1) if line =~ /([a-zA-Z]+) (is following you|is also a member of your group|is the leader of your group)/
|
17
|
+
@@leader = $1 if line =~ /([a-zA-Z]+) is the leader of your group/
|
18
|
+
break if line =~ /^Your group status is/
|
19
|
+
end
|
20
|
+
@@checked = true
|
21
|
+
@@characters
|
22
|
+
end
|
23
|
+
|
24
|
+
def Group.leader
|
25
|
+
@@leader
|
26
|
+
end
|
27
|
+
|
28
|
+
def Group.leader?
|
29
|
+
Group.check unless @@checked
|
30
|
+
@@leader == Char.name
|
31
|
+
end
|
32
|
+
|
33
|
+
def Group.whisper(msg)
|
34
|
+
fput "whisper group #{msg}" unless Group.members.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def Group.add(char)
|
38
|
+
fput "group #{char}"
|
39
|
+
Group.define(char)
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def Group.remove(char)
|
44
|
+
fput "remove #{char}"
|
45
|
+
@@characters.delete(char)
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def Group.nonmembers
|
50
|
+
Group.check unless @@checked
|
51
|
+
others = GameObj.pcs.map! {|char| char.noun } || []
|
52
|
+
# find all the disks/hidden players too
|
53
|
+
disk_owners = GameObj.loot.find_all { |obj| (obj.noun == 'disk') }.map{|disk| /([A-Z](?:[a-z]+))/.match(disk.name)[0].strip } || []
|
54
|
+
[others, disk_owners].flatten.reject(&:nil?).uniq - @@characters.keys
|
55
|
+
end
|
56
|
+
|
57
|
+
def Group.members
|
58
|
+
Group.check unless @@checked
|
59
|
+
@@characters.keys
|
60
|
+
end
|
61
|
+
|
62
|
+
def Group.define(name)
|
63
|
+
GameObj.pcs.detect do |pc| @@characters[name] = pc.dup if pc.noun == name end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class Group < Olib::Group
|
68
69
|
end
|
@@ -1,80 +1,80 @@
|
|
1
|
-
module Olib
|
2
|
-
module Inventory
|
3
|
-
Vars.Olib[:Inventory] ||= Hash.new
|
4
|
-
|
5
|
-
@@checked = false
|
6
|
-
|
7
|
-
|
8
|
-
def Inventory.containers
|
9
|
-
Inventory.check
|
10
|
-
GameObj.containers
|
11
|
-
end
|
12
|
-
|
13
|
-
def Inventory.to_s
|
14
|
-
Inventory.items.map(&:to_s)
|
15
|
-
end
|
16
|
-
|
17
|
-
def Inventory.checked?
|
18
|
-
@@checked
|
19
|
-
end
|
20
|
-
|
21
|
-
def Inventory.[](query)
|
22
|
-
GameObj.inv.select { |item|
|
23
|
-
item.name == query || item.id == query
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
def Inventory.
|
28
|
-
# check for worn teleporter
|
29
|
-
candidates= GameObj.inv.select { |item|
|
30
|
-
item.name ==
|
31
|
-
}
|
32
|
-
|
33
|
-
unless candidates.empty?
|
34
|
-
return Item.new(candidates.first)
|
35
|
-
end
|
36
|
-
|
37
|
-
# check in containers
|
38
|
-
Inventory.items.select { |item|
|
39
|
-
item.is? "teleporter"
|
40
|
-
}.first
|
41
|
-
end
|
42
|
-
|
43
|
-
def Inventory.items
|
44
|
-
Inventory.containers.map { |id, contents| contents.map {|item|
|
45
|
-
Item.new(item).define("container", id)
|
46
|
-
}
|
47
|
-
}.flatten
|
48
|
-
end
|
49
|
-
|
50
|
-
def Inventory.check
|
51
|
-
return self if Inventory.checked?
|
52
|
-
GameObj.inv.select{ |item|
|
53
|
-
!item.name.include?('tattoo')
|
54
|
-
}.each {|item|
|
55
|
-
if item.contents.nil?
|
56
|
-
Olib.wrap("look in ##{item.id}") { |line|
|
57
|
-
respond line =~ /Shadow engulf/
|
58
|
-
|
59
|
-
raise Olib::Errors::Mundane if line =~ /There is nothing in there.|Total|^In the (.*).$|prompt|^Shadows engulf/
|
60
|
-
|
61
|
-
if line =~ /That is closed./
|
62
|
-
Olib.wrap("open ##{item.id}") { |line|
|
63
|
-
if line =~ /You open/
|
64
|
-
multifput "look in ##{item.id}", "close ##{item.id}"
|
65
|
-
end
|
66
|
-
}
|
67
|
-
end
|
68
|
-
}
|
69
|
-
end
|
70
|
-
}
|
71
|
-
@@checked = true
|
72
|
-
return self
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
def Olib.Inventory
|
78
|
-
Olib::Inventory
|
79
|
-
end
|
1
|
+
module Olib
|
2
|
+
module Inventory
|
3
|
+
Vars.Olib[:Inventory] ||= Hash.new
|
4
|
+
|
5
|
+
@@checked = false
|
6
|
+
|
7
|
+
|
8
|
+
def Inventory.containers
|
9
|
+
Inventory.check
|
10
|
+
GameObj.containers
|
11
|
+
end
|
12
|
+
|
13
|
+
def Inventory.to_s
|
14
|
+
Inventory.items.map(&:to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
def Inventory.checked?
|
18
|
+
@@checked
|
19
|
+
end
|
20
|
+
|
21
|
+
def Inventory.[](query)
|
22
|
+
GameObj.inv.select { |item|
|
23
|
+
item.name == query || item.id == query
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def Inventory.fwi_teleporter
|
28
|
+
# check for worn teleporter
|
29
|
+
candidates= GameObj.inv.select { |item|
|
30
|
+
item.name == Char.fwi_teleporter
|
31
|
+
}
|
32
|
+
|
33
|
+
unless candidates.empty?
|
34
|
+
return Item.new(candidates.first)
|
35
|
+
end
|
36
|
+
|
37
|
+
# check in containers
|
38
|
+
Inventory.items.select { |item|
|
39
|
+
item.is? "teleporter"
|
40
|
+
}.first
|
41
|
+
end
|
42
|
+
|
43
|
+
def Inventory.items
|
44
|
+
Inventory.containers.map { |id, contents| contents.map {|item|
|
45
|
+
Item.new(item).define("container", id)
|
46
|
+
}
|
47
|
+
}.flatten
|
48
|
+
end
|
49
|
+
|
50
|
+
def Inventory.check
|
51
|
+
return self if Inventory.checked?
|
52
|
+
GameObj.inv.select{ |item|
|
53
|
+
!item.name.include?('tattoo')
|
54
|
+
}.each {|item|
|
55
|
+
if item.contents.nil?
|
56
|
+
Olib.wrap("look in ##{item.id}") { |line|
|
57
|
+
respond line =~ /Shadow engulf/
|
58
|
+
|
59
|
+
raise Olib::Errors::Mundane if line =~ /There is nothing in there.|Total|^In the (.*).$|prompt|^Shadows engulf/
|
60
|
+
|
61
|
+
if line =~ /That is closed./
|
62
|
+
Olib.wrap("open ##{item.id}") { |line|
|
63
|
+
if line =~ /You open/
|
64
|
+
multifput "look in ##{item.id}", "close ##{item.id}"
|
65
|
+
end
|
66
|
+
}
|
67
|
+
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
}
|
71
|
+
@@checked = true
|
72
|
+
return self
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
def Olib.Inventory
|
78
|
+
Olib::Inventory
|
79
|
+
end
|
80
80
|
end
|