diff --git a/PSBT.txt b/PSBT.txt index 079b298..12472f7 100644 --- a/PSBT.txt +++ b/PSBT.txt @@ -19,6 +19,8 @@ PSBT_Options.lua PSBT_Combat.lua PSBT_Cooldowns.lua PSBT_Auras.lua +PSBT_Experience.lua +PSBT_LowSomething.lua ## core PSBT_Label.lua diff --git a/PSBT_Combat.lua b/PSBT_Combat.lua index e0e5cfe..b3197e2 100644 --- a/PSBT_Combat.lua +++ b/PSBT_Combat.lua @@ -91,7 +91,7 @@ local combat_events = area = PSBT_AREAS.OUTGOING end - return zo_strformat( '<<1>> [<<2>>]!', hitValue, name ), area, true + return zo_strformat( '+<<1>> [|c080C3F2<<2>>|r]!', hitValue, name ), area, true end, [ ACTION_RESULT_DAMAGE ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, mechanicValue, damageType ) local area = nil @@ -154,7 +154,7 @@ local combat_events = area = PSBT_AREAS.OUTGOING end - return zo_strformat( '<<1>> [<<2>>]' , hitValue, name ), area, false + return zo_strformat( '+<<1>> [|c80C3F2<<2>>|r]' , hitValue, name ), area, false end, [ ACTION_RESULT_HOT_TICK ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, mechanicValue ) local area = nil @@ -167,7 +167,7 @@ local combat_events = area = PSBT_AREAS.OUTGOING end - return zo_strformat( '<<1>> [<<2>>]', hitValue, name ), area, false + return zo_strformat( '+<<1>> [|c80C3F2<<2>>|r]', hitValue, name ), area, false end, [ ACTION_RESULT_HOT_TICK_CRITICAL ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, mechanicValue ) local area = nil @@ -180,7 +180,7 @@ local combat_events = area = PSBT_AREAS.OUTGOING end - return zo_strformat( '<<1>> [<<2>>]!', hitValue, name ), area, true + return zo_strformat( '+<<1>> [|c80C3F2<<2>>|r]!', hitValue, name ), area, true end, [ ACTION_RESULT_DODGED ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, mechanicValue ) local area = nil @@ -240,7 +240,7 @@ local combat_events = return nil, nil, false end - return zo_strformat( '<<1>> falling', hitValue ), area, false + return zo_strformat( '-<<1>> falling', hitValue ), area, false end, [ ACTION_RESULT_KILLING_BLOW ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType ) if ( IsPlayer( targetType, targetName ) ) then @@ -252,21 +252,42 @@ local combat_events = return nil, nil, false end, [ EVENT_ALLIANCE_POINT_UPDATE ] = function(value, sound, diff) - return zo_strformat( '<<1>> AP', diff ), PSBT_AREAS.STATIC, false + local area = nil + if ( diff > 0 ) then + area = PSBT_AREAS.INCOMING + else + area = PSBT_AREAS.OUTGOING + end + + return zo_strformat( '<<1>> AP', diff ), area, false end, [ EVENT_RANK_POINT_UPDATE ] = function( tag , value, diff ) if (tag == "player") then - return zo_strformat( '<<1>> RP', diff ), PSBT_AREAS.STATIC, false + local area = nil + if ( diff > 0 ) then + area = PSBT_AREAS.INCOMING + else + area = PSBT_AREAS.OUTGOING + end + + return zo_strformat( '<<1>> RP', diff ), area, false end end, [ EVENT_BATTLE_TOKEN_UPDATE ] = function( value, sound, diff ) - return zo_strformat( '<<1>> BT', diff ), PSBT_AREAS.STATIC, false + local area = nil + if ( diff > 0 ) then + area = PSBT_AREAS.INCOMING + else + area = PSBT_AREAS.OUTGOING + end + + return zo_strformat( '<<1>> BT', diff ), area, false end, [ EVENT_EXPERIENCE_GAIN ] = function( value ) - return zo_strformat( '<<1>> XP', value ), PSBT_AREAS.STATIC, false + return zo_strformat( '+<<1>> XP', value ), PSBT_AREAS.INCOMING, false end, [ EVENT_EXPERIENCE_GAIN_DISCOVERY ] = function( areaName, value ) - return zo_strformat( '<<1>> XP', value ), PSBT_AREAS.STATIC, false + return zo_strformat( '+<<1>> XP', value ), PSBT_AREAS.INCOMING, false end, [ ACTION_RESULT_POWER_DRAIN ] = function( abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, mechanicValue ) diff --git a/PSBT_Constants.lua b/PSBT_Constants.lua index 1fe200d..ed9c00e 100644 --- a/PSBT_Constants.lua +++ b/PSBT_Constants.lua @@ -4,7 +4,9 @@ PSBT_MODULES = OPTIONS = 'options', -- options panel COOLDOWNS = 'cooldowns', COMBAT = 'combat', - AURAS = 'auras' + AURAS = 'auras', + XP = 'experience', + LOW = 'lowsomething' } PSBT_AREAS = diff --git a/PSBT_Experience.lua b/PSBT_Experience.lua new file mode 100644 index 0000000..0b80ce9 --- /dev/null +++ b/PSBT_Experience.lua @@ -0,0 +1,36 @@ +local PSBT_Experience = PSBT_Module:Subclass() +local CBM = CALLBACK_MANAGER + + +function PSBT_Experience:Initialize( ... ) + PSBT_Module.Initialize( self, ... ) + + self._currentExperience = GetUnitXP( 'player' ) + + self:RegisterForEvent( EVENT_EXPERIENCE_UPDATE, function( event, ... ) self:OnXPUpdated( ... ) end ) +end + +function PSBT_Experience:OnXPUpdated( tag, exp, maxExp, reason ) + if ( tag ~= 'player' ) then + return + end + + local xp = zo_min( exp, maxExp ) + + if ( self._currentExperience == xp ) then + return + end + + local gain = xp - self._currentExperience + self._currentExperience = xp + + if ( gain <= 0 ) then return end + self:NewEvent( PSBT_AREAS.INCOMING, false, nil, '+' .. tostring( gain ) .. ' XP' ) +end + + + +CBM:RegisterCallback( PSBT_EVENTS.LOADED, + function( psbt ) + psbt:RegisterModule( PSBT_MODULES.XP, PSBT_Experience:New( psbt ) ) + end) \ No newline at end of file diff --git a/PSBT_LowSomething.lua b/PSBT_LowSomething.lua new file mode 100644 index 0000000..4946719 --- /dev/null +++ b/PSBT_LowSomething.lua @@ -0,0 +1,60 @@ +local PSBT_LowSomething = PSBT_Module:Subclass() +PSBT_LowSomething._pools = {} +local CBM = CALLBACK_MANAGER + +local threshold = 0.33 + +function PSBT_LowSomething:Initialize( ... ) + PSBT_Module.Initialize( self, ... ) + + self._pools[POWERTYPE_HEALTH] = 0 + self._pools[POWERTYPE_MAGICKA] = 0 + self._pools[POWERTYPE_STAMINA] = 0 + self._pools[POWERTYPE_MOUNT_STAMINA] = 0 + + self:RegisterForEvent( EVENT_POWER_UPDATE, function( event, ... ) self:OnPowerUpdate( ... ) end ) +end + +function PSBT_LowSomething:OnPowerUpdate( unit, powerPoolIndex, powerType, powerPool, powerPoolMax ) + if ( unit ~= 'player' ) then + return + end + + if ( powerPool == 0 ) then + return + end + + if ( not self._pools[ powerType ] ) then + return + end + + local newValue = powerPool / powerPoolMax + + if ( self._pools[ powerType ] < threshold + or newValue > self._pools[ powerType ] + or newValue > threshold ) then + + self._pools[ powerType ] = newValue + return + end + + self._pools[ powerType ] = newValue + + local string = nil + if ( powerType == POWERTYPE_HEALTH ) then + string = 'Health Low! (|cF2920C' .. powerPool .. '|r)' + elseif ( powerType == POWERTYPE_MAGICKA ) then + string = 'Magicka Low! (|cCC0CF2' .. powerPool .. '|r)' + elseif ( powerType == POWERTYPE_STAMINA ) then + string = 'Stamina Low! (|c0CF2B9' .. powerPool .. '|r)' + elseif ( powerType == POWERTYPE_MOUNT_STAMINA ) then + string = 'Mount Stamina Low! (|c0CF2B9' .. powerPool .. '|r)' + end + + self:NewEvent( PSBT_AREAS.STATIC, false, nil, string ) +end + +CBM:RegisterCallback( PSBT_EVENTS.LOADED, + function( psbt ) + psbt:RegisterModule( PSBT_MODULES.LOW, PSBT_LowSomething:New( psbt ) ) + end) \ No newline at end of file