Results 1 to 2 of 2

Thread: CalcFlares help (should be easy)

  1. #1
    Join Date
    Jun 2004
    Location
    Fort Lauderdale, FL
    Posts
    15,822

    Default CalcFlares help (should be easy)

    Can anyone help me add my axe to calcflares so it tracks the frequency of flares? Looking at the code I can see the sonic flares code but I don't see where the rest is. Everytime my axe flares it gives this line:

    Your mithglin battle axe suddenly lights up with hundreds of tiny blue sparks!

    And here's the code for calcflares:

    Code:
    #!/usr/bin/env ruby
    # This script monitors for any flares it witnesses, and when it sees these, tells you both the percentage chance and average damage of your base flares and air lore-based flares (distinguishes between base sonic flares, air lore sonic flares, and any other miscellaneous flares). It automatically saves a history to disk, so that the average grows more accurate over time; uses the same principals as calcredux.lic, but applies them to both sonic and other flares, really.
    
    setpriority(-5)
    
    sum_base = 0
    sum_lore = 0
    sum_misc = 0
    count_base = 0
    count_lore = 0
    count_misc = 0
    total = 0
    filename = $script_dir + "calcflares-history-" + checkname + '.txt'
    if File.exists?(filename)
    	begin
    		history_data = File.open(filename) { |file| file.readlines.find_all { |line| line !~ /^#/ }.collect { |line| line.chomp } }
    	rescue
    		echo("Unknown error attempting to read history file: #{$!}")
    		exit
    	end
    else
    	begin
    		history_data = ["0.0:0.0", "0.0:0.0", "0", "0.0:0.0:0.0"]; File.open(filename, 'w') { |file| file.puts(history_data) }
    	rescue
    		echo("Unknown error attempting to create your history file: #{$!}"); exit
    	end
    end
    
    count_base, sum_base = history_data[0].split(':').collect { |val| val.to_f }
    count_lore, sum_lore = history_data[1].split(':').collect { |val| val.to_f }
    total = history_data[2].to_i
    count_misc, sum_misc, misc_total = history_data[3].split(':').collect { |val| val.to_f }
    
    before_dying { File.open(filename, 'w') { |file| file.puts([[count_base.to_s,sum_base.to_s].join(':'),[count_lore.to_s,sum_lore.to_s].join(':'), total.to_s, [count_misc.to_s,sum_misc.to_s,misc_total.to_s].join(':')]) } }
    
    flag = false
    while string_in = waitfor('^calcflares average$|finally going still|one last time and dies|collapses and finally dies|You (?:thrust with|swing) (?:a|an) sonic|\*\* As you hit, your(?: sonic)? (?:[^\s]+ ){1,4}unleashes a blast of sonic energy|\*\* With a loud snap, a blast of energy bursts from your sonic|You (?:thrust with|swing) (?:a|an) .+ at |\s\*\*\sYour |\s\*\*\sAs you(?:r)? |^calcflares (?:reset|help)$')
    	if string_in =~ /You (?:thrust with|swing) (?:a|an) sonic/
    		sonic = true
    		if script.gets !~ /AS/
    			flag = true
    			next
    		end
    		total += 1
    		next
    	elsif string_in =~ /\*\* As you hit, your(?: sonic)? (?:[^\s]+ ){1,4}unleashes a blast of sonic energy/
    		string_in = script.gets
    		sum_base = (sum_base.to_f + string_in.slice(/[0-9]+/).to_f)
    		count_base += 1
    		average_base = (sum_base.to_f / count_base.to_f)
    		percent_base = ((count_base.to_f / total.to_f) * 100)
    		echo("#{percent_base.to_s[0..3]}% base flare chance. Avg dmg of #{average_base.to_s[0..3]}")
    		flag = false
    	elsif string_in =~ /\*\* With a loud snap, a blast of energy bursts from your sonic/
    		string_in = script.gets
    		sum_lore = (sum_lore.to_f + string_in.slice(/[0-9]+/).to_f)
    		count_lore += 1
    		average_lore = (sum_lore.to_f / count_lore.to_f)
    		percent_lore = ((count_lore.to_f / total.to_f) * 100)
    		echo("#{percent_lore.to_s[0..3]}% lore flare chance. Avg dmg of #{average_lore.to_s[0..3]}")
    		flag = false
    	elsif string_in =~ /You (?:thrust with|swing) (?:a|an) .+ at /
    		sonic = false
    		if script.gets !~ /AS/
    			flag = true
    			next
    		end
    		misc_total += 1
    		next
    	elsif string_in =~ /\s\*\*\sYour |\s\*\*\sAs you(?:r)? /
    		string_in = script.gets
    		sum_misc = (sum_misc.to_f + string_in.slice(/[0-9]+/).to_f)
    		count_misc += 1
    		average_misc = (sum_misc.to_f / count_misc.to_f)
    		percent_misc = ((count_misc.to_f / misc_total.to_f) * 100)
    		echo("#{percent_misc.to_s[0..3]}% chance of flares. Avg dmg of #{average_misc.to_s[0..3]}")
    		flag = false
    	elsif string_in =~ /finally going still|one last time and dies|collapses and finally dies/
    		if sonic == true
    			total -= 1 if flag == true
    		else
    			misc_total -= 1 if flag == true
    		end
    			flag = false
    	elsif string_in =~ /^calcflares average$/i
    		average_lore = (sum_lore.to_f / count_lore.to_f)
    		percent_lore = ((count_lore.to_f / total.to_f) * 100)
    		average_misc = (sum_misc.to_f / count_misc.to_f)
    		percent_misc = ((count_misc.to_f / misc_total.to_f) * 100)
    		average_base = (sum_base.to_f / count_base.to_f)
    		percent_base = ((count_base.to_f / total.to_f) * 100)
    		echo(" Averages:")
    		echo("#{percent_base.to_s[0..3]}% base sonic flare chance. Avg dmg of #{average_base.to_s[0..3]}") unless count_base < 1
    		echo("#{percent_lore.to_s[0..3]}% lore sonic flare chance. Avg dmg of #{average_lore.to_s[0..3]}") unless count_lore < 1
    		echo("#{percent_misc.to_s[0..3]}% miscellaneous chance of flares. Avg dmg of #{average_misc.to_s[0..3]}") unless count_misc < 1
    	elsif string_in =~ /calcflares (reset|help)/i
    		if $1 =~ /reset/i
    			average_misc = 0; sum_misc = 0; percent_misc = 0; count_misc = 0; sum_base = 0; sum_lore = 0; percent_lore = 0; count_lore = 0; count_base = 0; average_base = 0; sum_base = 0; percent_base = 0; total = 0; misc_total = 0
    			respond; respond("Your flare history has been reset."); respond
    		else
    			respond; respond("  This script will track and calculate the percent chance and average damage of your flares. It was written primarily for use with sonic flares, and tracks the base flares and air lore flares individually; it also tracks a third group individually, which all other flares witnessed are lumped into.\r\n\r\n  To show your average, send 'calcflares average'\r\n  To reset your average, simply send 'calcflares reset' (type  ;send calcflares reset  to do this)."); respond
    		end
    	end
    end
    Quote Originally Posted by Fallen View Post
    Drew's priorities - Merchanting > Roleplaying > Cybering > Being AFK > Cybering > Hunting
    (wrathbringer78) I think that's it. Viril is one big obnoxious ambient script.

  2. #2
    Join Date
    Jun 2004
    Location
    Fort Lauderdale, FL
    Posts
    15,822

    Default

    bumb.
    Quote Originally Posted by Fallen View Post
    Drew's priorities - Merchanting > Roleplaying > Cybering > Being AFK > Cybering > Hunting
    (wrathbringer78) I think that's it. Viril is one big obnoxious ambient script.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •