-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceCode.lua
More file actions
128 lines (119 loc) · 4.69 KB
/
SourceCode.lua
File metadata and controls
128 lines (119 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
-- counter keeps adding to targets when mounting || Solved, was using https://alloder.pro/md/LuaApi/FunctionCommonUnRegisterEventHandler.html instead of https://alloder.pro/md/LuaApi/FunctionCommonUnRegisterEvent.html, so it would always register still. Ask pasidaips how it works with the if name == gift of tensess.
-- Make it only work when out of combat
--Use common.LogInfo("common", "-"..name.."-") --Log to mods.txt
--Use tostring() to concatenate non-string values in ChatLog()
-- Solved:
-- Error while running the chunk
-- [string "Mods/Addons/RessCounter/Script.luac"]:0: attempt to perform arithmetic on a nil value
-- func: __sub, metamethod, line: -1, defined: C, line: -1, [C]
-- func: ?, ?, line: 0, defined: Lua, line: 0, [string "Mods/Addons/RessCounter/Script.luac"]
--VARIABLES
local durationMin = 0
local durationSec = 0
local remainingMin = 0
local remainingSec = 0
local registerOnce = false
local spellName = ""
function Main()
common.RegisterEventHandler(BuffFinder, "EVENT_OBJECT_BUFF_ADDED") --https://alloder.pro/md/LuaApi/EventObjectBuffAdded.html
--GetPassiveAbilities() --https://alloder.pro/md/LuaApi/FunctionAvatarGetAbilityInfo.html
--GetPassiveAbilityReplacementSpell() --https://alloder.pro/md/LuaApi/FunctionAvatarGetAbilityReplacementSpell.html
--GetSpellsAvatar()
--GetSpellsTarget()
--GetCooldown()
end
function GetPassiveAbilities()
local abilities = avatar.GetAbilities()
for i, ability in ipairs(abilities) do
local abilityInfo = avatar.GetAbilityInfo(ability)
if abilityInfo then
local name = abilityInfo.name
ChatLog(name)
end
end
end
function GetPassiveAbilityReplacementSpell()
ChatLog("inside func")
local abilities = avatar.GetAbilities()
for i, ability in ipairs(abilities) do
local abilityInfo = avatar.GetAbilityInfo( ability )
local replacementAbility = abilityInfo.hasReplacementSpell
ChatLog(replacementAbility)
end
end
function GetSpellsAvatar()
local spellbook = avatar.GetSpellBook()
for i, id in pairs( spellbook ) do
local spellInfo = spellLib.GetDescription( id )
--ChatLog( userMods.FromWString(spellInfo.name),"ID:", spellInfo.objectId )
end
end
function GetSpellsTarget()
local targetId = avatar.GetTarget()
local targetSpellBook = targetId.GetSpellBook()
for i, id in pairs( targetSpellBook ) do
local spellInfo = spellLib.GetDescription( id )
ChatLog( userMods.FromWString(spellInfo.name),"ID:", spellInfo.objectId )
end
end
-- function GetCooldown()
-- local spellbook = avatar.GetSpellBook()
-- for i, id in pairs( spellbook ) do
-- local spellId = spellLib.GetObjectSpell( id )
-- local spellInfo = spellLib.GetDescription( id )
-- local spellName = userMods.FromWString(spellInfo.name)
-- local spellObjectId = spellInfo.objectId
-- --ChatLog(spellName)
-- --common.LogInfo("common", "-"..spellName.."-")
-- if spellName == "Judgment Day" then
-- local spellCooldown = spellLib.GetCooldown( spellObjectId )
-- ChatLog(userMods.FromWString(spellInfo.name),"spellObjectID:", spellObjectId,"spellId", spellId)
-- ChatLog(spellCooldown)
-- end
-- end
-- end
function GetCooldown()
local spellbook = avatar.GetSpellBook()
for k, v in pairs(spellbook) do
local spellDesc = spellLib.GetDescription( v )
spellName = userMods.FromWString(spellDesc.name)
if spellName == "Judgment Day" then
local spellCooldown = spellLib.GetCooldown( v )
durationMin = math.floor(spellCooldown.durationMs / 1000 / 60)
durationSec = math.floor(spellCooldown.durationMs / 1000 % 60)
remainingMin = math.floor(spellCooldown.remainingMs / 1000 / 60)
remainingSec = math.floor(spellCooldown.remainingMs / 1000 % 60)
if registerOnce == false then
registerOnce = true
common.RegisterEventHandler(UpdateCooldowns, "EVENT_SECOND_TIMER")
end
UpdateCooldowns()
end
end
end
function UpdateCooldowns()
ChatLog("base cooldown: "..durationMin.."m "..durationSec.."s")
ChatLog("Remaining cooldown:",remainingMin.."m", remainingSec.."s")
GetCooldown()
end
function BuffFinder(params)
local objectId = params.objectId --ObjectId - èäåíòèôèêàòîð îáúåêòà íà êîòîðûé ïîâåñèëè áàô
local buffName = userMods.FromWString(params.buffName) --WString - èìÿ áàôà
local buffId = params.buffId -- ObjectId - èäåíòèôèêàòîð áàôà
local sysName = params.sysName -- String - ñèñòåìíîå íàçâàíèå áàôà
local resourceId = params.resourceId -- buffId - èäåíòèôèêàòîð ðåñóðñà áàôà
local buffOwner = userMods.FromWString(object.GetName(params.objectId))
if buffOwner == "Dragagon" then
if buffName == "Judgment Day" then
ChatLog(buffOwner.." used",buffName)
GetCooldown()
end
end
end
if (avatar.IsExist()) then
ChatLog("Loaded.")
Main()
else
ChatLog("Loaded.")
common.RegisterEventHandler(Main, "EVENT_AVATAR_CREATED")
end