Code:
#uberBar.lic
#Makes you an UBERBAR!
#Combines XPSF, and many other bars into one bar to rule them all.
def ubWoundsFullDis()
displayw = ""
areas = [["nsys", "nerves"],["leftArm", "left arm"],["rightArm", "right arm"],["rightLeg", "right leg"],["leftLeg", "left leg"],["head", "head"],["rightFoot", "right foot"],["leftFoot", "left foot"],["rightHand", "right hand"],["leftHand", "left hand"],["rightEye", "right eye"],["leftEye", "left eye"],["back", "back"],["neck", "neck"],["chest", "chest"],["abdomen", "abdomen"]]
areas.each do |area|
if eval("Wounds.#{area[0]}") > 0 then displayw += "<image id='#{area[0]}' name='Injury#{eval("Wounds.#{area[0]}")}' cmd='cure #{area[1]}' tooltip='cure #{area[1]}' height='0' width='0'/>"
elsif eval("Scars.#{area[0]}") > 0 then displayw += "<image id='#{area[0]}' name='Scar#{eval("Scars.#{area[0]}")}' cmd='cure #{area[1]}' tooltip='cure #{area[1]}' height='0' width='0'/>"
elsif eval("Wounds.#{area[0]}") == 0 then displayw += "<image id='#{area[0]}' name='#{area[0]}' cmd='cure #{area[1]}' tooltip='cure #{area[1]}' height='0' width='0'/>"
elsif eval("Scars.#{area[0]}") == 0 then displayw += "<image id='#{area[0]}' name='#{area[0]}' cmd='cure #{area[1]}' tooltip='cure #{area[1]}' height='0' width='0'/>"
end
end
return displayw
end
def ubWoundsChangeDis(location)
areas = { "nsys" => "nerves", "leftArm" => "left arm", "rightArm" => "right arm", "rightLeg" => "right leg", "leftLeg" => "left leg", "head" => "head", "rightFoot" => "right foot", "leftFoot" => "left foot", "rightHand" => "right hand", "leftHand" => "left hand", "rightEye" => "right eye", "leftEye" => "left eye", "back" => "back", "neck" => "neck", "chest" => "chest", "abdomen" => "abdomen", }
displayw = ""
if eval("Wounds.#{location}") > 0 then displayw = "<image id='#{location}' name='Injury#{eval("Wounds.#{location}")}' cmd='cure #{areas[location]}' tooltip='cure #{areas[location]}' height='0' width='0'/>"
elsif eval("Scars.#{location}") > 0 then displayw = "<image id='#{location}' name='Scar#{eval("Scars.#{location}")}' cmd='cure #{areas[location]}' tooltip='cure #{areas[location]}' height='0' width='0'/>"
else ; displayw = "<image id='#{location}' name='#{location}' cmd='cure #{areas[location]}' tooltip='cure #{areas[location]}' height='0' width='0'/>"
end
return displayw
end
def ubWoundsMash()
woundmash = []
areas = ["nsys","leftArm","rightArm","rightLeg","leftLeg","head","rightFoot","leftFoot","rightHand","leftHand","rightEye","leftEye","back","neck","chest","abdomen"]
areas.each do |area|
woundmash.push eval("(Wounds.#{area} * 10) + Scars.#{area}")
end
return woundmash
end
# Opening Setup
openLines = ["<closeDialog id='UberBar'/>",
"<openDialog type='dynamic' id='UberBar' title='Uber Bar' target='UberBar' location='main' top='0' left='0' align='nw' height='232' width='190' resident='false'>",
"<dialogData id='UberBar'>",
"<skin id='ubinjury' name='InjuriesPanel' controls='nsys,leftArm,rightArm,rightLeg,leftLeg,head,rightFoot,leftFoot,rightHand,leftHand,rightEye,leftEye,back,neck,chest,abdomen' top='5' left='5' width='100' height='150' align='nw'/>"]
tosend = openLines.join
tosend += ubWoundsFullDis()
openLines = ["<label id='ublog' value='Login:' justify='4' anchor_left='ubinjury' align='n' top='5' left='5' height='15' width='50'/>",
"<label id='ubhour' value='AVG/Hr:' justify='4' anchor_left='ubinjury' anchor_top='ublog' top='4' left='5' height='15' width='50'/>",
"<label id='ublast' value='Pulse:' justify='4' anchor_left='ubinjury' anchor_top='ubhour' top='4' left='5' height='15' width='50'/>",
"<label id='ublogv' value='0' justify='6' anchor_left='ublog' align='n' top='5' left='0' height='15' width='50'/>",
"<label id='ubhourv' value='0' justify='6' anchor_left='ubhour' anchor_top='ublogv' top='4' left='0' height='15' width='50'/>",
"<label id='ublastv' value='0' justify='6' anchor_left='ublast' anchor_top='ubhourv' top='4' left='0' height='15' width='50'/>",
"<skin id='ubpulse' name='concentrationBar' controls='concentration' anchor_left='ubinjury' anchor_top='ublast' top='9' left='5' width='0' height='15'/><progressBar id='concentration' value='100' text='Pulse Timer' customText='t' anchor_left='ubinjury' anchor_top='ublast' top='9' left='5' width='100' height='15'/>",
"<skin id='ubheal' name='healthBar' controls='health' anchor_left='ubinjury' anchor_top='ubpulse' top='3' left='5' width='0' height='15'/><progressBar id='health' value='#{percenthealth}' text='#{checkhealth}/#{maxhealth}' customText='t' anchor_left='ubinjury' anchor_top='ubpulse' top='3' left='5' width='100' height='15'/>",
"<skin id='ubmana' name='manaBar' controls='mana' anchor_left='ubinjury' anchor_top='health' top='3' left='4' width='0' height='15'/><progressBar id='mana' value='#{percentmana}' text='#{checkmana}/#{maxmana}' customText='t' anchor_left='ubinjury' anchor_top='health' top='3' left='4' width='100' height='15'/>",
"<skin id='ubstam' name='staminaBar' controls='stamina' anchor_left='ubinjury' anchor_top='mana' top='3' left='5' width='0' height='15'/><progressBar id='stamina' value='#{percentstamina}' text='#{checkstamina}/#{maxstamina}' customText='t' anchor_left='ubinjury' anchor_top='mana' top='3' left='5' width='100' height='15'/>",
"<skin id='ubspir' name='spiritBar' controls='spirit' anchor_left='ubinjury' anchor_top='stamina' top='3' left='5' width='0' height='15'/><progressBar id='spirit' value='#{percentspirit}' text='#{checkspirit}/#{maxspirit}' customText='t' anchor_left='ubinjury' anchor_top='stamina' top='3' left='5' width='100' height='15'/>",
"<progressBar id='ubnext' value='#{XMLData.next_level_value}' text='#{XMLData.next_level_text.delete(' until next level')} until #{Char.level+1}' anchor_top='ubinjury' top='3' left='4' width='186' height='15'/>",
"<progressBar id='ubmind' value='#{XMLData.mind_value}' text='#{XMLData.mind_text}' customText='t' anchor_top='ubnext' top='3' left='4' width='186' height='15'/>",
"<progressBar id='ubstnc' value='#{XMLData.stance_value}' text='#{XMLData.stance_text}' anchor_top='ubmind' top='3' left='4' width='186' height='15'/>",
"<progressBar id='ubencm' value='#{XMLData.encumbrance_value}' text='#{XMLData.encumbrance_text}' anchor_top='ubstnc' top='3' left='4' width='186' height='15'/>"]
tosend += openLines.join
tosend += "</dialogData></openDialog>"
puts(tosend)
# random arrays
areas = ["nsys","leftArm","rightArm","rightLeg","leftLeg","head","rightFoot","leftFoot","rightHand","leftHand","rightEye","leftEye","back","neck","chest","abdomen"]
debug = false
# XP watcher variables
xpnFirstTime = Time.now # Time UB was first run
xpnFirst = XMLData.next_level_text.delete(' until next level').to_i # First experience
xpnTotal = 0 # Zero total xp to start
xpnCur = xpnFirst # Current exp to go
xpnOld = xpnFirst # Last round exp to go
xpnHour = 0 # average Experience per hour
xpnLast = 0 # Last Experience gain
# Stat Variables
oldHP = checkhealth
oldMP = checkmana
oldST = checkstamina
oldSP = checkspirit
oldXP = XMLData.next_level_text
oldMD = XMLData.mind_text
oldSN = XMLData.stance_text
oldEN = XMLData.encumbrance_text
oldIN = XMLData.injuries.to_s
oldWO = ubWoundsMash()
loop {
wait_while { oldHP == checkhealth and oldMP == checkmana and oldST == checkstamina and oldSP == checkspirit and oldXP == XMLData.next_level_text and oldMD == XMLData.mind_text and oldSN == XMLData.stance_text and oldEN == XMLData.encumbrance_text and oldIN == XMLData.injuries.to_s }
nowTime = Time.now
doLines = "<dialogData id='UberBar'>"
if oldHP != checkhealth then echo "updated health" if debug ; oldHP = checkhealth ; doLines += "<skin id='ubheal' name='healthBar' controls='health' anchor_left='ubinjury' anchor_top='ubpulse' top='9' left='5' width='0' height='15'/><progressBar id='health' value='#{percenthealth}' text='#{checkhealth}/#{maxhealth}' customText='t' anchor_left='ubinjury' anchor_top='ubpulse' top='4' left='5' width='100' height='15'/>" end
if oldMP != checkmana then echo "updated mana" if debug ; oldMP = checkmana ; doLines += "<skin id='ubmana' name='manaBar' controls='mana' anchor_left='ubinjury' anchor_top='health' top='3' left='4' width='0' height='15'/><progressBar id='mana' value='#{percentmana}' text='#{checkmana}/#{maxmana}' customText='t' anchor_left='ubinjury' anchor_top='health' top='3' left='4' width='100' height='15'/>" end
if oldST != checkstamina then echo "updated stamina" if debug ; oldST = checkstamina ; doLines += "<skin id='ubstam' name='staminaBar' controls='stamina' anchor_left='ubinjury' anchor_top='mana' top='3' left='5' width='0' height='15'/><progressBar id='stamina' value='#{percentstamina}' text='#{checkstamina}/#{maxstamina}' customText='t' anchor_left='ubinjury' anchor_top='mana' top='3' left='5' width='100' height='15'/>" end
if oldSP != checkspirit then echo "updated spirit" if debug ; oldSP = checkspirit ; doLines += "<skin id='ubspir' name='spiritBar' controls='spirit' anchor_left='ubinjury' anchor_top='stamina' top='3' left='5' width='0' height='15'/><progressBar id='spirit' value='#{percentspirit}' text='#{checkspirit}/#{maxspirit}' customText='t' anchor_left='ubinjury' anchor_top='stamina' top='3' left='5' width='100' height='15'/>" end
if oldMD != XMLData.mind_text then echo "updated mind" if debug ; oldMD = XMLData.mind_text ; doLines += "<progressBar id='ubmind' value='#{XMLData.mind_value}' text='#{XMLData.mind_text}' customText='t' anchor_top='ubnext' top='3' left='4' width='186' height='15'/>" end
if oldSN != XMLData.stance_text then echo "updated stance" if debug ; oldSN = XMLData.stance_text ; doLines += "<progressBar id='ubstnc' value='#{XMLData.stance_value}' text='#{XMLData.stance_text}' anchor_top='ubmind' top='3' left='4' width='186' height='15'/>" end
if oldEN != XMLData.encumbrance_text then echo "updated encumbr" if debug ; oldEN = XMLData.encumbrance_text ; doLines += "<progressBar id='ubencm' value='#{XMLData.encumbrance_value}' text='#{XMLData.encumbrance_text}' anchor_top='ubstnc' top='3' left='4' width='186' height='15'/>" end
if oldXP != XMLData.next_level_text
echo "updated next_level" if debug
xpnCur = XMLData.next_level_text.delete(' until next level').to_i
xpnLast = xpnOld - xpnCur
xpnLast = 0 if xpnLast < 0
xpnTotal += xpnLast
xpnHour = ((1.00 * xpnTotal) / ((nowTime - xpnFirstTime)/3600.00)).to_i
xpnOld = xpnCur
oldXP = XMLData.next_level_text
doLines += "<progressBar id='ubnext' value='#{XMLData.next_level_value}' text='#{xpnCur} until #{Char.level+1}' anchor_top='ubinjury' top='3' left='4' width='186' height='15'/>"
doLines += "<label id='ublogv' value='#{xpnTotal}' justify='6' anchor_left='ublog' align='n' top='5' left='0' height='15' width='50'/>"
doLines += "<label id='ubhourv' value='#{xpnHour}' justify='6' anchor_left='ubhour' anchor_top='ublogv' top='4' left='0' height='15' width='50'/>"
doLines += "<label id='ublastv' value='#{xpnLast}' justify='6' anchor_left='ublast' anchor_top='ubhourv' top='4' left='0' height='15' width='50'/>"
end
if oldIN != XMLData.injuries.to_s
echo "updated injuries" if debug
newWO = ubWoundsMash()
newWO.length.times { |n|
if oldWO[n] != newWO[n] then doLines += ubWoundsChangeDis(areas[n]) end
}
oldIN = XMLData.injuries.to_s
oldWO = ubWoundsMash()
end
doLines += "</dialogData>"
puts(doLines) if doLines != "<dialogData id='UberBar'></dialogData>"
}
I've been going back and forth on making the mind bar green again. I kinda liked it green...