EC Missing timer debuff for equipment change cool down

TimStTimSt Posts: 1,864
edited October 2023 in General Discussions
The EC is missing a timer debuff for equipment change cool down.  The follow code changes will add a macro action that you can use to show the debuff.



Download the following two icons from my GitHub repository:
https://github.com/TimStotelmeyer/Ultima-Online/blob/main/EquipmentWaitAction.dds
https://github.com/TimStotelmeyer/Ultima-Online/blob/main/EquipmentWaitDebuff.dds

and put them in your "icons\my icons" directory

Add the following two lines to the file "icons\icons.xml"

    <Icon id="900003" texture="Icons/My Icons/EquipmentWaitDebuff.dds" name="Equipment Wait Debuff" />
<Icon id="900004" texture="Icons/My Icons/EquipmentWaitAction.dds" name="Equipment Wait Action" />

Add the follow code to the function BuffDebuff.Initialize in the file "source\BuffDebuffWindow.lua"

	UOBuildTableFromCSV("Data/GameData/buffdata.csv", "BuffDataCSV")

-- start of adding custom buff / debuff icons
if (WindowData.BuffDataCSV ~= nil) then
local equipmentWaitDebuff = {
["ID"] = 900003,
["ServerId"] = 900003,
["IconId"] = 900003,
["Define"] = 0
}
table.insert(WindowData.BuffDataCSV, equipmentWaitDebuff )
end
--end of added code

Add the follow code to the file "source\Actions.lua"
--start of added code
function Actions.EquipmentWait()
WindowData.BuffDebuffSystem.CurrentBuffId = 900003 -- use custom equipment delay buff icon.
WindowData.BuffDebuff.NameWStringVector = L"Equipment Delay"
WindowData.BuffDebuff.NameVectorSize = 0
WindowData.BuffDebuff.ToolTipVectorSize = 0
WindowData.BuffDebuff.IsBeingRemoved = false
local secs = 9
BuffDebuff.Timers[900003] = secs
BuffDebuff.ShouldCreateNewBuff()
HotbarSystem.EquipItemsDelayTimeMax = secs
HotbarSystem.EquipItemsDelayTime = secs
end
--end of added code
Add the following code to the top of the file "source\HotbarSystem.lua"
--start of added code
HotbarSystem.EquipItemsDelayTimeMax = 0
HotbarSystem.EquipItemsDelayTime = 0
HotbarSystem.EquipItems = {}
--end of added code
Add the following code to the function HotbarSystem.UpdateActionButton in the file source\HotbarSystem.lua
	if type == SystemData.UserAction.TYPE_SKILL then

if( HotbarSystem.Skills[id] == nil ) then
HotbarSystem.Skills[id] = {}
end
HotbarSystem.Skills[id][element] = element
end
--start of added code
if type == SystemData.UserAction.TYPE_EQUIP_ITEMS or (type == SystemData.UserAction.TYPE_MACRO_REFERENCE
and ((iconId >= 875000 and iconId <= 875036) or (iconId >= 875200 and iconId <= 875206)
or (iconId >= 875250 and iconId <= 875268) or (iconId >= 875300 and iconId <= 875310)
or (iconId >= 875450 and iconId <= 875460))) then

if( HotbarSystem.EquipItems[id] == nil ) then
HotbarSystem.EquipItems[id] = {}
end
HotbarSystem.EquipItems[id][element] = element
end
--end of added code
Add the following code to the function HotbarSystem.ClearActionIcon in the file source\HotbarSystem.lua

	elseif HotbarSystem.SpecialActions and HotbarSystem.SpecialActions[id] and HotbarSystem.SpecialActions[id][element] then

HotbarSystem.SpecialActions[id][element] = nil

--start of added code
elseif HotbarSystem.EquipItems and HotbarSystem.EquipItems[id] and HotbarSystem.EquipItems[id][element] then
HotbarSystem.EquipItems[id][element] = nil
--end of added code
end
Add the following code to the function HotbarSystem.Update in the file source\HotbarSystem.lua
				HotbarSystem.UpdateCooldownSlot(element, HotbarSystem.SkillDelayTime, HotbarSystem.SkillDelayTimeMax)								
end
end
end

--start of added code
for id, element in pairs(HotbarSystem.EquipItems) do
for element, curElement in pairs(HotbarSystem.EquipItems[id]) do
local patt = element
local fnd = string.find(patt , "Button")
if (element and fnd ~= nil ) then
local hotbarId = tonumber(string.sub(patt,7, fnd - 1))
local itemIndex = tonumber(string.sub(patt, fnd + 6 ))
if Hotbar.IsShrunken(hotbarId)then
continue
end

if not DoesWindowNameExist(WindowGetParent(element)) then
HotbarSystem.EquipItems[id] = nil
continue
end

if( HotbarSystem.EquipItems[id] == nil ) then
HotbarSystem.EquipItems[id] = {}
end
WindowSetShowing(element.."Disabled",false)
WindowSetShowing(element.."Alert",false)
HotbarSystem.UpdateCooldownSlot(element, HotbarSystem.EquipItemsDelayTime, HotbarSystem.EquipItemsDelayTimeMax)
end
end
end
--end of added code
Add the following code to the bottom of the  function Interface.Cooldowns in the file Interface.lua
--start of added code	
if HotbarSystem.EquipItemsDelayTime > 0 then
HotbarSystem.EquipItemsDelayTime = HotbarSystem.EquipItemsDelayTime - timePassed
end
--end of added code
Add the following code to the function ActionsWindow.InitActionData in the file source\ActionsWindow.lua
	ActionsWindow.ActionData[6006] = { type=SystemData.UserAction.TYPE_SPEECH_USER_COMMAND,			inActionWindow=true, iconId=876006, detailString=GetStringFromTid(1155381), nameString=FormatProperly(GetStringFromTid(1044013)),  callback=L"script Actions.MakeLast()" }

--start of added code
ActionsWindow.ActionData[900004] = { type=SystemData.UserAction.TYPE_SPEECH_USER_COMMAND, inActionWindow=true, iconId=900004, detailString=L"", nameString=FormatProperly(L"Equipment Wait"), callback=L"script Actions.EquipmentWait()" }
--end of added code
Add the follow code to the function ActionsWindow.Initialize() in the file source\ActionsWindow.lua

	local actionData

--start of added code
table.insert(ActionsWindow.Groups[4].index, 900004) --EquipmentWait
--end of added code

Start up the EC and you will see the new action Equipment Wait at the bottom of the Actions/Equipment menu


To use it create a macro for changing your equipment and add the Equipment Wait action after the Equip action
It is important that you set the macro's icon to one of the equipment icons if you want to see which macro on the tool bar you need to wait to use.


One caveat to be aware of is the EC does not provide an indication if the equipment change that happens will have a cool down or not.  The above code changes just assumes that a cool down is required.

Comments

  • TimStTimSt Posts: 1,864
    edited October 2023
    Thanks to some help from @ForeverFun we've removed the need to add a new macro action. So no need for the changes to Actions.lua and ActionsWindow.lua

    Here is the updated code:
    To the function PaperdollWindow.Initialize in the file source\PaperdollWindow.lua add the following code
    	local playerId = WindowData.PlayerStatus.PlayerId
    -- if this is the players backpack then use the saved position
    if( id == playerId ) then

    --start of added code
    if(PaperdollWindow.PriorPaperdoll == nil) then
    PaperdollWindow.PriorPaperdoll = {}
    end
    -- copy elements out of current paperdoll.
    for key, value in pairs(WindowData.Paperdoll[playerId]) do
    if(type(value) ~= "table") then
    continue
    end

    PaperdollWindow.PriorPaperdoll[key] = WindowData.Paperdoll[playerId][key].slotId
    end
    --end of added code

    To the function PaperdollWindow.UpdatePaperdoll in the file PaperdollWindow.lua add the following code
    	if (not DoesWindowNameExist(windowName) or not WindowData.Paperdoll[paperdollId]) then
    return
    end

    --start of added code
    if(paperdollId == WindowData.PlayerStatus.PlayerId) then

    if(PaperdollWindow.PriorPaperdoll ~= nil) then

    local changed_count = 0

    for key, value in pairs(WindowData.Paperdoll[paperdollId]) do
    if(type(value) ~= "table") then
    continue
    end

    if(WindowData.Paperdoll[paperdollId][key].slotId == nil) then
    continue
    end

    if(WindowData.Paperdoll[paperdollId][key].slotId == 0) then -- do not check unequipped slots (handles switching between 1/2 handed weapons, etc)
    continue
    end

    if(PaperdollWindow.PriorPaperdoll[key] == WindowData.Paperdoll[paperdollId][key].slotId) then -- item did not change
    continue
    end

    PaperdollWindow.PriorPaperdoll[key] = WindowData.Paperdoll[paperdollId][key].slotId

    changed_count = changed_count + 1
    end

    local timeLeft = 0
    local secs = 0
    if(BuffDebuff.Timers[900003] ~= nil) then
    timeLeft = BuffDebuff.Timers[900003]
    end
    secs = changed_count + timeLeft

    if(secs > 1) then
    WindowData.BuffDebuffSystem.CurrentBuffId = 900003 -- use custom equipment delay buff icon.
    WindowData.BuffDebuff.NameWStringVector = L"Equipment Delay"
    WindowData.BuffDebuff.NameVectorSize = 0
    WindowData.BuffDebuff.ToolTipVectorSize = 0
    WindowData.BuffDebuff.IsBeingRemoved = false
    BuffDebuff.Timers[900003] = secs
    BuffDebuff.ShouldCreateNewBuff()
    HotbarSystem.EquipItemsDelayTimeMax = secs
    HotbarSystem.EquipItemsDelayTime = secs
    end
    end
    end
    --end of added code


Sign In or Register to comment.