Skip to content

Commit

Permalink
Misc stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rcuhljr committed Apr 29, 2016
1 parent 46f20c0 commit 0fd6104
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crossing-training.lic
Expand Up @@ -187,7 +187,7 @@ class CrossingTraining
def focus_runestone
bput('get runestone', 'You get')
until DRSkill.getxp('Sorcery').to_i >= 32
bput('focus runestone', 'You focus your magical senses')
bput('focus my runestone', 'You focus your magical senses')
waitrt?
end
bput('stow runestone', 'You put your')
Expand Down
14 changes: 7 additions & 7 deletions dependency.lic
Expand Up @@ -170,8 +170,12 @@ class ScriptManager
download_script(filename) if get_versions[filename].nil? || force
end

def repo_scripts
$manager.get_status['tree'].map { |element| element['path'] }.select { |file| file.include?('.lic') && !file.include?('-setup') }
end

def start_scripts(force = false)
get_versions.each { |name, _| get_script(name, force) }
repo_scripts.each { |name, _| get_script(name, force) }
autostarts.each { |name| run_script(name) }
end

Expand Down Expand Up @@ -427,16 +431,12 @@ def replace_all
respond 'Renaming existing scripts to replaced-script.lic.bak'
managed_scripts.each { |script| File.rename('./scripts/' + script, './scripts/' + script + '.bak') }
respond 'Downloading all scripts'
repo_scripts.each(&method(:get_script))
end

def repo_scripts
$manager.get_status['tree'].map { |element| element['path'] }.select { |file| file.include?('.lic') && !file.include?('-setup') }
$manager.repo_scripts.each(&method(:get_script))
end

def managed_scripts
local_scripts = Dir['./scripts/*.lic'].map { |item| File.basename(item) }
repo_scripts & local_scripts
$manager.repo_scripts & local_scripts
end

def list_autostarts
Expand Down
154 changes: 154 additions & 0 deletions performance-monitor.lic
@@ -0,0 +1,154 @@

unless HAVE_GTK
respond
respond 'error: ruby-gtk bindings are not installed or failed to load'
respond
exit
end

custom_require(%w(drinfomon textsubs))

class PerformanceFilter

def initialize
@settings = get_settings()
@weapon_hits = {}
@weapon_rts = {}
@settings.performance_monitor_weapons.each{|x| @weapon_hits[x] = []; @weapon_rts[x] = [] }
@weapon_stats = []
@last_weapon = nil
@new_hit = false
@damage_subs = [
['a light hit', 'a light hit (1/23)'],
['a good hit', 'a good hit (2/23)'],
['a good strike', 'a good strike (3/23)'],
['a solid hit', 'a solid hit (4/23)'],
['a hard hit', 'a hard hit (5/23)'],
['a strong hit', 'a strong hit (6/23)'],
['a heavy strike', 'a heavy strike (7/23)'],
['a very heavy hit', 'a very heavy hit (8/23)'],
['an extremely heavy hit', 'an extremely heavy hit (9/23)'],
['a powerful strike', 'a powerful strike (10/23)'],
['a massive strike', 'a massive strike (11/23)'],
['an awesome strike', 'an awesome strike (12/23)'],
['a vicious strike', 'a vicious strike (13/23)'],
['an earth-shaking strike', 'an earth-shaking strike (14/23)'],
['a demolishing hit', 'a demolishing hit (15/23)'],
['a spine-rattling strike', 'a spine-rattling strike (16/23)'],
["a devastating hit(?! \(That'll leave a mark!\))", 'a devastating hit (17/23)'],
["a devastating hit \(That'll leave a mark!\)", "a devastating hit (That'll leave a mark!) (18/23)"],
['an overwhelming strike', 'an overwhelming strike (19/23)'],
['an obliterating hit', 'an obliterating hit (20/23)'],
['an annihilating strike', 'an annihilating strike (21/23)'],
['a cataclysmic strike', 'a cataclysmic strike (22/23)'],
['an apocalyptic strike', 'an apocalyptic strike (23/23)']
]
end

def weapon_list
@settings.performance_monitor_weapons
end

def process_line(line)
@damage_subs.each{|x| line.gsub!(x.first, x.last) }
@settings.performance_monitor_weapons.each do |weapon_name|
next unless /^\<.*\b#{weapon_name}\b.*\((\d+)\/23\)/ =~ line
@weapon_hits[weapon_name].push($1.to_i)
@last_weapon = weapon_name
@new_hit = true
break
end
if @new_hit && /roundtime.*(\d+)/i =~ line
@new_hit = false
@weapon_rts[@last_weapon].push($1.to_i)
update_stats
true
else
false
end
end

def update_stats
@weapon_stats = []
@weapon_hits.each do |weapon, hits|
dmg = hits.inject(&:+)
rt = @weapon_rts[weapon].inject(&:+)
@weapon_stats.push({weapon:weapon, avgrt:rt*1.0/hits.size, avgdps:dmg*1.0/rt})
end
end

def weapon_stats
@weapon_stats
end
end

def update_stat_bar(entry, data)
entry.text = "#{data[:weapon]}:\tavg RT:#{data[:avgrt].round(1)}\tavg DPS:#{data[:avgdps].round(1)}"
end

filter = PerformanceFilter.new
window = nil
window_done = false
load_window_position = CharSettings['window_position'] || []
load_window_width = CharSettings['window_width'] || 300
load_window_height = CharSettings['window_height'] || 100
window_title = "#{checkname} Performance Monitor"
save_window_position = nil
save_window_width = nil
save_window_height = nil
healthbar_ets = []

before_dying do
CharSettings['window_position'] = save_window_position if (save_window_position.class == Array) && (save_window_position[0].to_i >= 0) && (save_window_position[1].to_i >= 0)
CharSettings['window_width'] = save_window_width if (save_window_width.class == Fixnum) && (save_window_width > 100)
CharSettings['window_height'] = save_window_height if (save_window_height.class == Fixnum) && (save_window_height > 100)
Gtk.queue { window.destroy }
end

begin
weapon_ets = {}

Gtk.queue do
vbox = Gtk::VBox.new
filter.weapon_list.each do |weapon|
stats_et = Gtk::Entry.new
stats_et.editable = false
display_font = Pango::FontDescription.new
display_font.weight = Pango::FontDescription::WEIGHT_BOLD
stats_et.modify_font(display_font)
weapon_ets[weapon] = stats_et
vbox.pack_start(stats_et)
end

window = Gtk::Window.new
window.title = window_title
window.keep_above = true
window.border_width = 1
window.resize(load_window_width, load_window_height)
unless load_window_position.empty?
window.move(load_window_position[0], load_window_position[1])
end
window.add(vbox)

window.signal_connect('delete_event') do
save_window_position = window.position
save_window_width = window.allocation.width
save_window_height = window.allocation.height
window_done = true
end
window.show_all
end

loop do
line = script.gets?
break if window_done
pause 0.05 unless line
next unless line

if filter.process_line(line)
filter.weapon_stats.each do |data|
update_stat_bar(weapon_ets[data[:weapon]], data)
end
end
end
end
5 changes: 4 additions & 1 deletion profiles/Etreu-setup.yaml
Expand Up @@ -335,4 +335,7 @@ engineering_belt:
- carving knife
- shaper
- drawknife
- rasp
- rasp

performance_monitor_weapons:
- cutlass
24 changes: 24 additions & 0 deletions profiles/Jairne-back.yaml
@@ -0,0 +1,24 @@
combat_trainer_target_increment: 10
combat_trainer_action_count: 40
offensive_spells:
- skill: Debilitation
name: Sleep
abbrev: sleep
mana: 6
buff_spells:
Moonblade:
abbrev: moonblade
moon: true
recast_every: 600
mana: 16
dance_skill: Small Edged
weapon_training:
Staves: moonstaff
Twohanded Edged: moonblade
Large Edged: moonblade
Small Edged: moonblade
summoned_weapons:
- name: Small Edged
- name: Staves
- name: Twohanded Edged
- name: Large Edged

0 comments on commit 0fd6104

Please sign in to comment.