forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smarttransfer.lic
113 lines (98 loc) · 3.36 KB
/
smarttransfer.lic
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
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
107
108
109
110
111
112
113
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#smarttransfer
=end
custom_require.call(%w(common events))
class SmartTransfer
include DRC
def initialize
@wound_map = {
'insignificant' => 1,
'negligible' => 2,
'minor' => 3,
'more than minor' => 4,
'harmful' => 5,
'very harmful' => 6,
'damaging' => 7,
'very damaging' => 8,
'severe' => 9,
'very severe' => 10,
'devastating' => 11,
'very devastating' => 12,
'useless' => 13
}
@deadly_wounds = %w(SKIN HEAD NECK CHEST ABDOMEN BACK)
arg_definitions = [
[
{ name: 'player', regex: /\w+/i, variable: true, description: 'Name of the player to heal' },
{ name: 'bleed', regex: /bleed/i, optional: true, description: 'Leave bleeders' }
]
]
args = parse_args(arg_definitions)
heal_other(args.player, args.bleed)
end
def get_wounds(target)
if target == 'self'
bput('perc heal self', 'Roundtime')
else
bput("touch #{target}", 'vitality')
end
data = reget 100
data = data.reverse.take_while { |item| !(item =~ /injuries include/) }.reverse
wounds = {}
part = nil
data.each do |line|
if line =~ /Wounds to the (.+):/
part = Regexp.last_match(1)
wounds[part] = []
end
wounds[part] += [{ 'part' => part, 'location' => Regexp.last_match(2), 'type' => Regexp.last_match(1), 'level' => @wound_map[Regexp.last_match(3)] }] if line =~ /(\w+) (\w+):.*\-\- (.*)\r/
end
waitrt?
wounds
end
def determine_safe_wounds(mine, theirs)
summed_wounds = mine
theirs.each do |part, wounds|
summed_wounds[part] ||= []
wounds.each do |wound|
existing = summed_wounds[part].find { |base_wound| base_wound['location'] == wound['location'] && base_wound['type'] == wound['type'] }
if existing
existing['level'] += wound['level']
else
summed_wounds[part] << wound
end
next unless wound['type'] == 'Fresh'
existing_scar = summed_wounds[part].find { |base_wound| base_wound['location'] == wound['location'] && base_wound['type'] == 'Scar' }
if existing_scar
existing_scar['level'] += wound['level']
else
summed_wounds[part] << { 'part' => wound['part'], 'location' => wound['location'], 'type' => 'Scar', 'level' => wound['level'] }
end
end
end
summed_wounds.select { |part, wounds| !wounds.find { |wound| wound['level'] > 12 } && theirs[part] }
end
def bleeder?(wound_set)
wound_set.find { |wound| wound['type'] == 'Fresh' && wound['location'] == 'External' && wound['level'] >= 5 }
end
def heal_other(player, bleeders)
my_wounds = get_wounds('self')
target_wounds = get_wounds(player)
safe_wounds = determine_safe_wounds(my_wounds, target_wounds)
if bleeders
safe_wounds.each do |part, wound|
if bleeder?(wound)
fput("transfer #{player} quick #{part} internal all")
fput("transfer #{player} quick #{part} external scar")
else
fput("transfer #{player} quick #{part} all")
end
end
elsif safe_wounds.length == target_wounds.length
fput("transfer #{player} quick all")
else
safe_wounds.each { |part, _wound| fput("transfer #{player} quick #{part} all") }
end
end
end
SmartTransfer.new