vitalsbox.lua
VitalsBox = {}
function VitalsBox:new(_name, _elementX, _elementY)
cloudDir = cloudDir or [[D:\Achaea\]]
self.__index = VitalsBox
local self = setmetatable({}, VitalsBox)
self._instanceName = _name
self._lowHPflashing = false
if self._updateHandler then killAnonymousEventHandler(self._updateHandler) self._updateHandler = false end
self._updateHandler = self._updateHandler or registerAnonymousEventHandler("svo done with prompt", self._instanceName..":update")
self._container = Geyser.Label:new({ name = self._instanceName.."._container", x = _elementX, y = _elementY, width = 942, height = 86 })
self._labelBackground = Geyser.Label:new({ name = self._instanceName.."._labelBackground", x = 0, y = 0, width = 942, height = 86 }, self._container )
self._labelBalance = Geyser.Label:new({ name = self._instanceName.."._labelBalance", x = 445, y = 6, width = 52, height = 34, color = "#007700" }, self._container )
self._labelBezel = Geyser.Label:new({ name = self._instanceName.."._labelBezel", x = 0, y = 0, width = 942, height = 86 }, self._container )
self._labelEquilibrium = Geyser.Label:new({ name = self._instanceName.."._labelEquilibrium", x = 445, y = 46, width = 52, height = 34, color = "#007700" }, self._container )
self._labelLowHPWarningLeft = Geyser.Label:new({ name = self._instanceName.."._labelLowHPWarningLeft", x = 0, y = 6, width = 27, height = 74 }, self._container )
self._labelLowHPWarningRight = Geyser.Label:new({ name = self._instanceName.."._labelLowHPWarningRight", x = 915, y = 5, width = 27, height = 74 }, self._container )
self._labelRage = Geyser.Label:new({ name = self._instanceName.."._labelRage", x = 342, y = 6, width = 97, height = 34 }, self._container )
self._labelTargetName = Geyser.Label:new({ name = self._instanceName.."._labelTargetName", x = 709, y = 6, width = 200, height = 34 }, self._container )
self._labelTicker = Geyser.Label:new({ name = self._instanceName.."._labelTicker", x = 342, y = 46, width = 97, height = 34 }, self._container )
self._labelBackground:setStyleSheet( [[background-color: #0000FF;]] )
self._labelBalance:setStyleSheet( gui.css.balanceGreen:getCSS() )
self._labelBezel:setStyleSheet( [[background-color: #00000000;]] )
self._labelEquilibrium:setStyleSheet( gui.css.balanceGreen:getCSS() )
self._labelLowHPWarningLeft:setStyleSheet( [[background-color: #FF0000;]] )
self._labelLowHPWarningRight:setStyleSheet( [[background-color: #FF0000;]] )
self._labelRage:setStyleSheet( [[background-color: #00000000;]] )
self._labelTargetName:setStyleSheet( [[background-color: #000000;]] )
self._labelTicker:setStyleSheet( [[background-color: #000000;]] )
self._labelBezel:setBackgroundImage( cloudDir..[[GUI\images\vitalsBoxBezel.png]] )
self._labelBalance:echo( "B","white","c20" )
self._labelEquilibrium:echo( "E","white","c20" )
self._labelRage:echo( " Rage: --","white","b10" )
self._labelTargetName:echo( " tarName","white","b12" )
self._labelTicker:echo( " Gold: ----","white","b10" )
self._gaugeEndurance = Geyser.Gauge:new({ name = self._instanceName.."._gaugeEndurance", x = 239, y = 6, height = 34, width = 97 }, self._container )
self._gaugeHealth = Geyser.Gauge:new({ name = self._instanceName.."._gaugeHealth", x = 33, y = 6, height = 34, width = 200 }, self._container )
self._gaugeMana = Geyser.Gauge:new({ name = self._instanceName.."._gaugeMana", x = 33, y = 46, height = 34, width = 200 }, self._container )
self._gaugeRage = Geyser.Gauge:new({ name = self._instanceName.."._gaugeRage", x = 342, y = 6, height = 34, width = 97 }, self._container )
self._gaugeTargetHP = Geyser.Gauge:new({ name = self._instanceName.."._targetHP", x = 709, y = 46, height = 34, width = 200 }, self._container )
self._gaugeWillpower = Geyser.Gauge:new({ name = self._instanceName.."._gaugeWillpower", x = 239, y = 46, height = 34, width = 97 }, self._container )
self._gaugeEndurance.back:setStyleSheet( gui.css.defaultGaugeBack:getCSS() )
self._gaugeEndurance.front:setStyleSheet( gui.css.defaultGaugeGreen:getCSS() )
self._gaugeHealth.back:setStyleSheet( gui.css.defaultGaugeBack:getCSS() )
self._gaugeHealth.front:setStyleSheet( gui.css.defaultGaugeGreen:getCSS() )
self._gaugeMana.back:setStyleSheet( gui.css.defaultGaugeBack:getCSS() )
self._gaugeMana.front:setStyleSheet( gui.css.defaultGaugeGreen:getCSS() )
self._gaugeRage.back:setStyleSheet( gui.css.defaultGaugeBack:getCSS() )
self._gaugeRage.front:setStyleSheet( gui.css.defaultGaugeOrange:getCSS() )
self._gaugeTargetHP.back:setStyleSheet( gui.css.defaultGaugeBack:getCSS() )
self._gaugeTargetHP.front:setStyleSheet( gui.css.defaultGaugeOrange:getCSS() )
self._gaugeWillpower.back:setStyleSheet( gui.css.defaultGaugeBack:getCSS() )
self._gaugeWillpower.front:setStyleSheet( gui.css.defaultGaugeGreen:getCSS() )
self._gaugeEndurance:setValue(50,100)
self._gaugeHealth:setValue(50,100)
self._gaugeMana:setValue(50,100)
self._gaugeRage:setValue(50,100)
self._gaugeTargetHP:setValue(50,100)
self._gaugeWillpower:setValue(50,100)
self._gaugeEndurance.front:echo( " EN: ---%", "white", "b10" )
self._gaugeEndurance.back:echo( " EN: ---%", "white", "b10" )
self._gaugeHealth.front:echo( " HP: ----/----", "white", "b10" )
self._gaugeHealth.back:echo( " HP: ----/----", "white", "b10" )
self._gaugeMana.front:echo( " MP: ----/----", "white", "b10" )
self._gaugeMana.back:echo( " MP: ----/----", "white", "b10" )
self._gaugeTargetHP.front:echo( " ---%", "white", "b12" )
self._gaugeTargetHP.back:echo( " ---%", "white", "b12" )
self._gaugeWillpower.front:echo( " WP: ---%", "white", "b10" )
self._gaugeWillpower.back:echo( " WP: ---%", "white", "b10" )
self._container:raiseAll()
return self
end
function VitalsBox:setEndurance(_currentEnd, _maxEnd)
self._gaugeEndurance:setValue(_currentEnd, _maxEnd)
self._gaugeEndurance.front:echo(" EN: " .. round((_currentEnd/_maxEnd)*100).."%", "white", "b10" )
self._gaugeEndurance.back:echo(" EN: " .. round((_currentEnd/_maxEnd)*100).."%", "white", "b10" )
end
function VitalsBox:setHealth(_currentHP, _maxHP)
self._gaugeHealth:setValue(_currentHP, _maxHP)
self._gaugeHealth.front:echo(" HP: " .. _currentHP .. " / " .. _maxHP, "white", "b10" )
self._gaugeHealth.back:echo(" HP: " .. _currentHP .. " / " .. _maxHP, "white", "b10" )
end
function VitalsBox:setMana(_currentMP, _maxMP)
self._gaugeMana:setValue(_currentMP, _maxMP)
self._gaugeMana.front:echo(" MP: " .. _currentMP .. " / " .. _maxMP, "white", "b10" )
self._gaugeMana.back:echo(" MP: " .. _currentMP .. " / " .. _maxMP, "white", "b10" )
end
function VitalsBox:setTargetHealth(_value)
self._gaugeTargetHP:setValue(_value,100)
self._gaugeTargetHP.front:echo(" " .. _value .. "%","white","b12")
self._gaugeTargetHP.back:echo(" " .. _value .. "%","white","b12")
end
function VitalsBox:setWillpower(_currentWP, _maxWP)
self._gaugeWillpower:setValue(_currentWP, _maxWP)
self._gaugeWillpower.front:echo(" WP: " .. round((_currentWP/_maxWP)*100).."%", "white", "b10" )
self._gaugeWillpower.back:echo(" WP: " .. round((_currentWP/_maxWP)*100).."%", "white", "b10" )
end
function VitalsBox:setBalance(_labelBalance)
if inShipGUI then
if _labelBalance then
self._labelBalance:setStyleSheet(gui.css.ship.balanceGreen)
else
self._labelBalance:setStyleSheet(gui.css.ship.balanceRed)
end
else
if _labelBalance then
self._labelBalance:setStyleSheet(gui.css.balanceGreen:getCSS())
else
self._labelBalance:setStyleSheet(gui.css.balanceRed:getCSS())
end
end
end
function VitalsBox:setEquilibrium(_labelBalance)
if inShipGUI then
if _labelBalance then
self._labelEquilibrium:setStyleSheet(gui.css.ship.balanceGreen)
else
self._labelEquilibrium:setStyleSheet(gui.css.ship.balanceRed)
end
else
if _labelBalance then
self._labelEquilibrium:setStyleSheet(gui.css.balanceGreen:getCSS())
else
self._labelEquilibrium:setStyleSheet(gui.css.balanceRed:getCSS())
end
end
end
function VitalsBox:setLowHP(_value)
if inShipGUI then return end
if _value and svo.stats.hp >= 0 then
if _value and not soundCooldown then
playSoundFile(cloudDir..[[Sounds\warning.wav]])
soundCooldown = true
tempTimer(1.0,[[soundCooldown = false]])
end
if not self._lowHPflashing then
self._lowHPflashing = true
self._labelLowHPWarningLeft:show()
self._labelLowHPWarningRight:show()
if exists("Temporary HP flasher "..self._instanceName, "timer") < 1 then
permTimer("Temporary HP flasher "..self._instanceName, "", 0.25, [[
if ]]..self_.instanceName..[[._labelLowHPWarningLeft.hidden then
]]..self_.instanceName..[[._labelLowHPWarningLeft:show()
]]..self_.instanceName..[[._labelLowHPWarningRight:show()
else
]]..self_.instanceName..[[._labelLowHPWarningLeft:hide()
]]..self_.instanceName..[[._labelLowHPWarningRight:hide()
end
]])
end
enableTimer("Temporary HP flasher")
end
elseif _value == false then
self._lowHPflashing = false
self._labelLowHPWarningLeft:hide()
self._labelLowHPWarningRight:hide()
disableTimer("Temporary HP flasher"..self._instanceName)
end
end
function VitalsBox:setTargetName(_name)
self._labelTargetName:echo(" " .. _name)
end
function VitalsBox:setRage(_currentRage) end
function VitalsBox:showTargetHP(_show)
if _show then
self._gaugeTargetHP:show()
else
self._gaugeTargetHP:hide()
end
end
function VitalsBox:setVisible(_visible)
if _visible then
self._container:show()
else
self._container:hide()
end
end
function VitalsBox:update()
if not svo.stats then return end
if not loginComplete then return end
self:setHealth( svo.stats.currenthealth, svo.stats.maxhealth )
self:setMana( svo.stats.currentmana, svo.stats.maxmana )
self:setEndurance( svo.stats.currentendurance, svo.stats.maxendurance )
self:setWillpower( svo.stats.currentwillpower, svo.stats.maxwillpower )
self:setRage(svo.stats.battlerage)
self._labelTicker:echo(" GP: "..gmcp.Char.Status.gold,"white","b10")
self:setBalance(svo.bals.balance)
self:setEquilibrium(svo.bals.equilibrium)
local _isLowHP = not (svo.stats.hp >= 40) or (svo.stats.hp == 0)
self:setLowHP(_isLowHP)
self:showTargetHP(svo.me.gametargethp)
self:setTargetName(svo.me.gametarget or "")
self:setTargetHealth(svo.me.gametargethp or 0 )
if jcs.target.autoAttack then
self._labelTargetName:setStyleSheet([[background-color: #777700;]])
elseif jcs.autoStrike then
self._labelTargetName:setStyleSheet([[background-color: #770000;]])
else
self._labelTargetName:setStyleSheet([[background-color: #000000;]])
end
end