Displays the players ability and spell recast information.
http://ashita.atom0s.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
162 lines
6.4 KiB
162 lines
6.4 KiB
--[[ |
|
* Ashita - Copyright (c) 2014 - 2016 atom0s [[email protected]] |
|
* |
|
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. |
|
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to |
|
* Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. |
|
* |
|
* By using Ashita, you agree to the above license and its terms. |
|
* |
|
* Attribution - You must give appropriate credit, provide a link to the license and indicate if changes were |
|
* made. You must do so in any reasonable manner, but not in any way that suggests the licensor |
|
* endorses you or your use. |
|
* |
|
* Non-Commercial - You may not use the material (Ashita) for commercial purposes. |
|
* |
|
* No-Derivatives - If you remix, transform, or build upon the material (Ashita), you may not distribute the |
|
* modified material. You are, however, allowed to submit the modified works back to the original |
|
* Ashita project in attempt to have it added to the original project. |
|
* |
|
* You may not apply legal terms or technological measures that legally restrict others |
|
* from doing anything the license permits. |
|
* |
|
* No warranties are given. |
|
]]-- |
|
|
|
_addon.author = 'atom0s'; |
|
_addon.name = 'recast'; |
|
_addon.version = '3.0.0'; |
|
|
|
require 'common' |
|
|
|
---------------------------------------------------------------------------------------------------- |
|
-- Configurations |
|
---------------------------------------------------------------------------------------------------- |
|
local default_config = |
|
{ |
|
font = |
|
{ |
|
family = 'Arial', |
|
size = 10, |
|
color = 0xFFFF0000, |
|
position = { 50, 125 }, |
|
bgcolor = 0x80000000, |
|
bgvisible = true |
|
} |
|
}; |
|
local recast_config = default_config; |
|
|
|
--------------------------------------------------------------------------------------------------- |
|
-- func: color_recast_entry |
|
-- desc: Colors a recast entry based on the time left to use it.. |
|
--------------------------------------------------------------------------------------------------- |
|
local function color_recast_entry( s, t ) |
|
if (t >= 1200) then |
|
return s; |
|
elseif (t < 1200 and t > 300) then |
|
return string.format('|cFFFFFF00|%s|r', s); |
|
else |
|
return string.format('|cFF00FF00|%s|r', s); |
|
end |
|
end |
|
|
|
---------------------------------------------------------------------------------------------------- |
|
-- func: load |
|
-- desc: Event called when the addon is being loaded. |
|
---------------------------------------------------------------------------------------------------- |
|
ashita.register_event('load', function() |
|
-- Attempt to load the fps configuration.. |
|
recast_config = ashita.settings.load_merged(_addon.path .. 'settings/settings.json', recast_config); |
|
|
|
-- Create our font object.. |
|
local f = AshitaCore:GetFontManager():Create('__recast_addon'); |
|
f:SetColor(recast_config.font.color); |
|
f:SetFontFamily(recast_config.font.family); |
|
f:SetFontHeight(recast_config.font.size); |
|
f:SetBold(false); |
|
f:SetPositionX(recast_config.font.position[1]); |
|
f:SetPositionY(recast_config.font.position[2]); |
|
f:SetText('Recast ~ by atom0s'); |
|
f:SetVisibility(true); |
|
f:GetBackground():SetColor(recast_config.font.bgcolor); |
|
f:GetBackground():SetVisibility(recast_config.font.bgvisible); |
|
end); |
|
|
|
---------------------------------------------------------------------------------------------------- |
|
-- func: unload |
|
-- desc: Event called when the addon is being unloaded. |
|
---------------------------------------------------------------------------------------------------- |
|
ashita.register_event('unload', function() |
|
local f = AshitaCore:GetFontManager():Get('__recast_addon'); |
|
recast_config.font.position = { f:GetPositionX(), f:GetPositionY() }; |
|
|
|
-- Save the configuration.. |
|
ashita.settings.save(_addon.path .. 'settings/recast.json', recast_config); |
|
|
|
-- Unload our font object.. |
|
AshitaCore:GetFontManager():Delete('__recast_addon'); |
|
end ); |
|
|
|
---------------------------------------------------------------------------------------------------- |
|
-- func: render |
|
-- desc: Event called when the addon is being rendered. |
|
---------------------------------------------------------------------------------------------------- |
|
ashita.register_event('render', function() |
|
local f = AshitaCore:GetFontManager():Get('__recast_addon'); |
|
local r = AshitaCore:GetResourceManager(); |
|
local e = T{ }; |
|
|
|
-- Read the ability recasts.. |
|
for x = 0, 31 do |
|
local recastId = ashita.ffxi.recast.get_ability_id_from_index(x); |
|
local recastTimer = ashita.ffxi.recast.get_ability_recast_by_index(x); |
|
|
|
-- Ensure the ability has a current cooldown.. |
|
if ((recastId ~= 0 or x == 0) and recastTimer > 0) then |
|
local ability = r:GetAbilityByTimerId(recastId); |
|
local recastName = '(Unknown)'; |
|
|
|
-- Get the abilities name.. |
|
if (x == 0) then |
|
recastName = '(Job One Hour)'; |
|
else |
|
if (ability ~= nil) then |
|
recastName = ability.Name[0]; |
|
end |
|
end |
|
|
|
if (#recastName == 0) then |
|
recastName = string.format('Unknown Ability: %d', recastId); |
|
end |
|
|
|
-- Add the recast to the table.. |
|
table.insert(e, color_recast_entry(string.format('%s : %s', ashita.ffxi.recast.format_timestamp(recastTimer), recastName), recastTimer)); |
|
end |
|
end |
|
|
|
-- Read the spell recasts.. |
|
for x = 1, 1024 do |
|
local recastId = x; |
|
local recastTimer = ashita.ffxi.recast.get_spell_recast_by_index(x); |
|
|
|
-- Ensure the spell has a current cooldown.. |
|
if (recastTimer > 0) then |
|
local spell = r:GetSpellById(recastId); |
|
local recastName = ''; |
|
|
|
-- Get the spells name.. |
|
if (spell ~= nil) then |
|
recastName = spell.Name[0]; |
|
end |
|
if (spell == nil or #recastName == 0) then |
|
recastName = string.format('Unknown Spell: %d', recastId); |
|
end |
|
|
|
-- Add the recast to the table.. |
|
table.insert(e, color_recast_entry(string.format('%s : %s', ashita.ffxi.recast.format_timestamp(recastTimer), recastName), recastTimer)); |
|
end |
|
end |
|
|
|
-- Display the recast timers.. |
|
f:SetText(e:concat('\n')); |
|
end);
|
|
|