=begin
704 monitor
Will pop up a window when the script starts and write to it when ever you phase a container showing it's name and duration left.
If you would like to change the window height open up the script(notepad will do) and change the line at the top that reads height = 55
*** Update
29/4/2012 - Updated duration to cap at level
***Contact Me***
If there is a problem with the script or you have suggestions feel free to contact Stormtov on http://forum.gsplayers.com
=end
Settings.load
Settings[Char.name] = Hash.new unless Settings[Char.name].kind_of? Hash
before_dying{;puts("<closeDialog id=\"704_monitor\"\/>");Settings.save;}
height = 55 #Change the height of the window here(deafult 55, enough for 3 lines. With default font size add 11 for any extra line). If window is already open will need to be closesd before this change can take effect.
def save_durations()
if $time_phased.empty?
Settings[Char.name]["time"] = "empty"
else
x=0
saved_time = Array.new
loop{
saved_time[x] = Time.now - $time_phased[x]
x = x + 1
break if x > ($time_phased.length - 1)
}
Settings[Char.name]["time"] = saved_time
$container_full.compact!
Settings[Char.name]["saved_container_full"] = $container_full.compact
$container_short.compact!
Settings[Char.name]["saved_container_short"] = $container_short.compact
end
end
def load_duration()
if Settings[Char.name]["time"] == "empty"
clear_arrays()
else
x = 0
$time_phased = Array.new
loop{
$time_phased[x] = Time.now - Settings[Char.name]["time"][x]
x = x + 1
$x = x
break if x > (Settings[Char.name]["time"].length - 1)
}
$container_full = Settings[Char.name]["saved_container_full"]
$container_short = Settings[Char.name]["saved_container_short"]
end
end
def shorten()
x = 0
y = 0
$container_split = $container_full[$x].split(" ")
$container_split.compact!
$check = false
loop {
if $container_split[x]== $container_short[$x]
$check = true
x = x + 1
end
if $check == true
$container_split[x] = nil
end
x = x + 1
break if x > ($container_split.length - 1)
}
$container_full[$x] = $container_split.compact! * " "
end
def remove()
x = 0
loop {
if $container_full[x] =~ /#{$remove_item}/
$time_phased[x] = $time_phased[x] - $duration
break
else
x = x + 1
break if x > ($container_full.length - 1)
end
}
end
def clear_arrays()
$container_full = Array.new
$container_short = Array.new
$time_phased = Array.new
$x = 0
end
puts("<openDialog type='dynamic' id='704_monitor' title='Phase Duration Monitor' location='center' height='#{height}' width='300'><dialogData id='espWindowControl'><label id='lblHeader' value='' top='0' left='0' width='138'/></dialogData></openDialog>")
if Settings[Char.name]["first_time?"] != "no"
echo "This script should track your durations fine unless you kill the script and stayed logged into game. It will save the durations though so if you log out it will remember the durations. Just make sure to add the script to your favourates so it runs on startup"
respond "If for what ever reason the timing is off you can remove them from the window manually using ';send 704monitor clear (all/1/2/3...)' Entering all clears all the window entering a number clears just the line only(ie entering 2 will clear just the second line)"
respond "This message will only display once so hope you were paying attention"
clear_arrays()
else
load_duration()
end
Settings[Char.name]["first_time?"] = "no"
Settings.save
if Spells.sorcerer > Char.level
$duration = 600 + (Char.level * 6)
else
$duration = 600 + (Spells.sorcerer * 6)
end
phase_monitor = Thread.new {
loop {
line = get
if line =~ /You gesture at a shifting (.+)\./
$remove_item = $1
line = get
if line =~ /Your spell has no effect/
$remove_item = nil
else
remove()
end
elsif line =~ /You gesture at (a|an) (.+)\./
$container_full[$x] = $2
elsif line =~ /The (.+) becomes momentarily insubstantial and appears lighter\.|The (.+) becomes somewhat insubstantial and appears lighter\./
if $1.empty? == false
$container_short[$x] = $1
else
$container_short[$x] = $2
end
$time_phased[$x] = Time.now
shorten()
$x = $x + 1
elsif line =~ /Your (.+) feels somewhat heavier./
#ill get there
elsif line =~ /(Your|The) (.+) flickers in and out of existence for a moment but then stabilizes. It seems heavier./
$remove_item = $2
remove()
elsif line =~ /^704monitor clear (\w+)$/
clear = $1
if clear == "all"
x = 0
loop {
$time_phased[x] = $time_phased[x] - $duration
x = x + 1
break if x > ($time_phased.length - 1)
}
else
$time_phased[clear.to_i-1] = $time_phased[clear.to_i-1] - $duration
end
end
z = 0
loop {
z=z+1
break if z > ($container_short.length - 1)
}
}
}
duration_thread = Thread.new {
loop {
if $container_short.length > 0
time_now = Time.now
z=0
loop {
time_elapsed = time_now - $time_phased[z]
$time_left = $duration - time_elapsed
mins = $time_left/60
secs = $time_left%60
if $time_left > 0
puts("<dialogData id='704_monitor'><label id='duration#{z}' value='#{$container_full[z]}: #{mins.to_i}M #{secs.to_i}' top='#{z*15}' left='0' height='20' align='n' width='300' tooltip='Meh'/></dialogData>")
z=z+1
else
a=z
$container_short[a] = nil
$container_short.compact!
$container_full[a] = nil
$container_full.compact!
$time_phased[a] = nil
$time_phased.compact!
loop {
puts("<dialogData id='704_monitor'><label id='duration#{a}' value='' top='0' left='0' height='20' align='n' width='300' tooltip='Meh'/></dialogData>")
a = a + 1
break if a > ($container_short.length)
}
$x = $x - 1
#z=z+1
end
#sleep 1
break if z > ($container_short.length - 1)
}
else
sleep 1
end
sleep 1
}
}
save_thread = Thread.new {
loop {
save_durations()
Settings.save
sleep 1
}
}
phase_monitor.join
duration_thread.join
save_thread.join