You are not logged in.

Applications: [GameMaster: OPEN] | [Volunteer Testers: OPEN]


This forum will be permanently shut down on Friday 13.07.2018
Please copy or save all important information from old forum before they will be deactivated
We have moved to new board. https://forum.runesofmagic.gameforge.com/Come join us.

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

261

Tuesday, December 6th 2011, 9:51pm

Quoted from "hangman04;491192"

Hey Ghost, Peryl is the a way to count how many bleeds are on a target. I am asking this because i want to use TA on my warrior only if they are 2 bleed debuffs (500018) on the target.
Also regarding GCD, are u sure about going back to "return cd == 0" ? from what i saw it's still 1 sec animation and below 1 sec the actual cd...


Mmm ... I am not sure if tbuffs[] checks how many of that buff exists.

2 bleed debuffs of what though?

Are you talking about stacks or x2 of that specific debuff?

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

262

Tuesday, December 6th 2011, 10:23pm

Quoted from "mrmisterwaa;491199"

Mmm ... I am not sure if tbuffs[] checks how many of that buff exists.

2 bleed debuffs of what though?

Are you talking about stacks or x2 of that specific debuff?


Atm it checks how many stacks a certain buff has, but not how many times that debuff exists on the target.
Bleeds from warrior and rogues or even from scouts (Vamp arrow) can be more then 1 on a target.
For warriors, tactical attack (crappy 250% dps skill) has a nice rule: the no of TA that hit the target = no of slash bleeds on the target +1. So if they are 3 slash bleeds on a boss, my TA will hit x4.
I want to set my TA hit only if they are at least 2 slash bleeds on the boss.

263

Wednesday, December 7th 2011, 12:43am

Hello again...Finally upgraded to Diyce 2.0...Using the timer function for my exploting shot (scout/rogue dps section), which has a 12 sec buff and 20 sec cooldown = 32 secs. But I want the macro to fire shot until exploiting shot triggers, so I tried to incorporate the ignoretimer function..doesnt seem to be working. The 32 sec timer always triggers whether exploting shot triggers or not.

any thoughts?

Source code

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
local WHITE = "|cffffffff"
local SILVER = "|cffc0c0c0"
local GREEN = "|cff00ff00"
local LTBLUE = "|cffa0a0ff"
function DIYCE_DebugSkills(skillList)
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."Skill List:")
 
    for i,v in ipairs(skillList) do
        DEFAULT_CHAT_FRAME:AddMessage(SILVER.."  ['..WHITE..i..SILVER..']: "..LTBLUE.."" "..WHITE..v.name..LTBLUE..""  use = "..WHITE..(v.use and "true" or "false"))
    end
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."----------")
end
function DIYCE_DebugBuffList(buffList)
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."Buff List:")
 
    for k,v in pairs(buffList) do
        -- We ignore numbered entries because both the ID and name 
        -- are stored in the list. This avoids doubling the output.
        if type(k) ~= "number" then
            DEFAULT_CHAT_FRAME:AddMessage(SILVER.."  ['..WHITE..k..SILVER..']:  "..LTBLUE.."id: "..WHITE..v.id..LTBLUE.."  stack: "..WHITE..v.stack..LTBLUE.."  time: "..WHITE..v.time)
        end
    end
 
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."----------")    
end
local silenceList = {
  ['Annihilation']  = true,
  ['King Bug Shock']  = true,
  ['Mana Rift']   = true,
  ['Dream of Gold']  = true,
  ['Flame']    = true,
  ['Flame Spell']  = true,
  ['Wave Bomb']   = true,
  ['Silence']   = true,
  ['Recover']   = true,
  ['Restore Life']  = true,
  ['Heal']    = true,
  ['Curing Shot']  = true,
  ['Leaves of Fire']  = true,
  ['Urgent Heal']  = true,
  ['Heavy Shelling']  = true, --Juggler Apprentice in Grafu
        ['Dark Healing']    = true, --Mini-boss in Sardo
     }
 
function PriestFairySequence(arg1)
 local Skill = {}
 local Skill2 = {}
 local i = 0
 local FairyExists = UnitExists("playerpet")
 local FairyBuffs = BuffList("playerpet")
 local combat = GetPlayerCombatState()
    --Determine Class-Combo
    mainClass, subClass = UnitClassToken( "player" )
 --Summon Fairy
 if (not FairyExists) and (not combat) then
  if mainClass == "AUGUR" then
   if subClass == "THIEF" then
    Skill = {
     { name = "Shadow Fairy",   use = true },
      }
   elseif subClass == "RANGER" then
    Skill = {
     { name = "Water Fairy",    use = true },
      }
   elseif subClass == "MAGE" then
    Skill = {
     { name = "Wind Fairy",    use = true },
      }   
   elseif subClass == "KNIGHT" then
    Skill = {
     { name = "Light Fairy",    use = true },
      }   
   elseif subClass == "WARRIOR" then
    Skill = {
     { name = "Fire Fairy",    use = true },
      }
   end
  end
 end 
 
 --Cast Halo
 if FairyExists then
  if mainClass == "AUGUR" then
   if subClass == "THIEF" then
    if (not FairyBuffs[503459]) then
     if (arg1 == "v1") then
      Msg("- Activating Halo", 0, 1, 1)
     end
     Skill = {
      { name = "Pet Skill: 6 (Wraith Halo)", use = true },
       }
    end
   elseif subClass == "RANGER" then
    if (not FairyBuffs[503457]) then
     if (arg1 == "v1") then
      Msg("- Activating Halo", 0, 1, 1)
     end
     Skill = {
      { name = "Pet Skill: 6 (Frost Halo)", use = true },
       }
    end
   elseif subClass == "MAGE" then
    if (not FairyBuffs[503461]) then
     if (arg1 == "v1") then
      Msg("- Activating Halo", 0, 1, 1)
     end
     Skill = {
      { name = "Pet Skill: 6 (Windrider Halo)", use = true },
       }
    end
   elseif subClass == "KNIGHT" then
    if (not FairyBuffs[503507]) then
     if (arg1 == "v1") then
      Msg("- Activating Halo", 0, 1, 1)
     end
     Skill = {
      { name = "Pet Skill: 6 (Devotion Halo)", use = true },
       }
    end
   elseif subClass == "WARRIOR" then
    if (not FairyBuffs[503455]) then
     if (arg1 == "v1") then
      Msg("- Activating Halo", 0, 1, 1)
     end
     Skill = {
      { name = "Pet Skill: 6 (Accuracy Halo)", use = true },
       }
    end
   end
 
   --Cast Conceal
  if (not MyCombat(Skill, arg1)) then
   if (not FairyBuffs[503753]) then
    if (arg1 == "v1") then
     Msg("- Activating Conceal", 0, 1, 1)
    end
    Skill2 = {
     { name = "Pet Skill: 7 (Conceal)", use = true },
      }
   end
  end
  end
 end
 
 if (not MyCombat(Skill, arg1)) then
  MyCombat(Skill2, arg1)
 end
end
 
function KillSequence(arg1, arg2, healthpot, manapot, foodslot)
--arg1 = "v1" or "v2" for debugging
--healthpot = # of actionbar slot for health potions
--manapot = # of actionbar slot for mana potions
--foodslot = # of actionbar slot for food (add more args for more foodslots if needed)
    local Skill = {}
    local Skill2 = {}
    local i = 0
 
    -- Player and target status.
    local combat = GetPlayerCombatState()
    local enemy = UnitCanAttack("player","target")
    local EnergyBar1 = UnitMana("player")
    local EnergyBar2 = UnitSkill("player")
    local pctEB1 = PctM("player")
    local pctEB2 = PctS("player")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")
    local tDead = UnitIsDeadOrGhost("target")
    local behind = (not UnitIsUnit("player", "targettarget"))
    local melee = GetActionUsable(11) -- # is your melee range spell slot number
    local a1,a2,a3,a4,a5,ASon = GetActionInfo(5)  -- # is your Autoshot slot number
    local phealth = PctH("player")
    local thealth = PctH("target")
    local LockedOn = UnitExists("target")
    local boss = UnitSex("target") > 2
    local elite = UnitSex("target") == 2
    local party = GetNumPartyMembers() >= 2
 
    --Determine Class-Combo
    mainClass, subClass = UnitClassToken( "player" )
    --Silence Logic
    local tSpell,tTime,tElapsed = UnitCastingTime("target")
    local silenceThis = tSpell and silenceList[tSpell] and ((tTime - tElapsed) > 0.1)
 
    --Potion Checks
    healthpot = healthpot or 0
    manapot = manapot or 0
 
    --Equipment and Pet Protection
    if phealth <= .04 then
            --SwapEquipmentItem()        --Note: Remove the first double dash to re-enable equipment protection.
        for i=1,6 do
            if (IsPetSummoned(i) == true) then
                ReturnPet(i);
            end
        end        
    end
 
 --Check for level 1 mobs, if it is, drop target and acquire a new one.
    if (LockedOn and (UnitLevel("target") < 2)) then
        TargetUnit("")
        return
    end
 
    --Begin Player Skill Sequences
 
        --Priest = AUGUR, Druid = DRUID, Mage = MAGE, Knight = KNIGHT, 
        --Scout = RANGER, Rogue = THIEF, Warden = WARDEN, Warrior = WARRIOR
 
        -- Class: Warrior/Mage
            if mainClass == "WARRIOR" and subClass == "MAGE" then
                local SurpriseAttack = GetActionUsable(14)
 
            --Potions and Buffs
            Skill = {
                { name = "Action: "..healthpot,            use = (phealth <= .70) },
                { name = "Survival Instinct",              use = (phealth <= .30) and combat },
                { name = "Sense of Danger",                use = (phealth <= .30) and combat },
                { name = "Action: "..manapot,              use = (pctEB2 <= .40) },
                { name = "Action: "..Healslot,             use = (phealth < .70) and (not combat) and (not party) },
                { name = "Action: "..HoTslot,              use = (phealth < .80) and (not party) },
                { name = "Intensification",                use = (pctEB2 >= .05) and (not pbuffs['Intensification']) and boss and enemy },
                { name = "Aggressiveness",                 use = boss and enemy },
                { name = "Electric Attack",                use = (pctEB2 >= .05) and ((not pbuffs['Electric Attack']) or (pbuffs['Electric Attack'].time <= 45)) },
                    }
 
            --Combat
                if enemy then
                Skill2 = {
                    { name = "Silence",                    use = (silenceThis) },
                    { name = "Surprise Attack",            use = SurpriseAttack },
                    { name = "Enraged",                    use = (EnergyBar1 <= 30) and (boss or elite) },
                    { name = "Electrical Rage",            use = (EnergyBar1 >= 15) and (pctEB2 >=.05) and (not pbuffs['High Voltage III']) },
                    { name = "Thunder Sword",              use = (pctEB2 >= .05) },
                    { name = "Lightning's Touch",          use = (pctEB2 >= .05) },
                    { name = "Attack",                     use = (thealth == 1) },
                        }
                end
  -- Class: Scout/Knight
   elseif mainClass == "RANGER" and subClass == "KNIGHT" then
 
    if (enemy and (arg2 == "DPS")) then
    Skill2 = {
     { name = "Vampire Arrows",     use = true },
     { name = "Autoshot",      use = (not ASon) },
     { name = "Combo Shot",      use = true },
     { name = "Reflected Shot",     use = true },  
     { name = "Piercing Arrow",     use = true }, 
     { name = "Wind Arrows",     use = (EnergyBar1 >= 20) },  
     { name = "Shot",       use = true }
       }
 
    elseif (enemy and (arg2 == "FARM")) then
    Skill2 = {
     { name = "Reflected Shot",     use = true },  
     { name = "Piercing Arrow",     use = true },
     { name = "Vampire Arrows",     use = true },
     { name = "Wind Arrows",     use = (EnergyBar1 >= 20) }
       }
 
    elseif (enemy and (arg2 == "SEIGE")) then
    Skill2 = {
     { name = "Vampire Arrows",     use = true },
     { name = "Reflected Shot",     use = true },  
     { name = "Piercing Arrow",     use = true },
     { name = "Wind Arrows",     use = (EnergyBar1 >= 20) }
       }
    end
  -- Class: Scout/Rogue
   elseif mainClass == "RANGER" and subClass == "THIEF" then
 
   --Timers for this class
            CreateDIYCETimer("ExploitCooldown", 32)
 
    if (enemy and (arg2 == "DPS")) then
    Skill2 = {
     --{ name = "Autoshot",      use = (not ASon) },
     --{ name = "Sapping Arrow",    use = (not pbuffs['Sapping Arrow']) },
     { name = "Shot",       use = (EnergyBar1 >= 20),    ignoretimer = tbuffs['Exploiting Shot'],  timer = "ExploitCooldown" },
     --{ name = "Reflected Shot",     use = true },  
     --{ name = "Vampire Arrows",     use = true },
     --{ name = "Deadly Poison Bite",   use = true },
     --{ name = "Piercing Arrow",     use = true }, 
     --{ name = "Combo Shot",      use = true },
     --{ name = "Weak Spot",     use = true },
     { name = "Wind Arrows",     use = (EnergyBar1 >= 20) } 
       }
 
    elseif (enemy and (arg2 == "FARM")) then
    Skill2 = {
     { name = "Reflected Shot",     use = true },  
     { name = "Piercing Arrow",     use = true },
     { name = "Vampire Arrows",     use = true },
     { name = "Wind Arrows",     use = (EnergyBar1 >= 20) }
       }  
    end
 
 
            --ADD MORE CLASS COMBOS HERE. 
            --USE AN "ELSEIF" TO CONTINUE WITH MORE CLASS COMBOS.
            --THE NEXT "END" STATEMENT IS THE END OF THE CLASS COMBOS STATEMENTS.
            --DO NOT POST BELOW THE FOLLOWING "END" STATEMENT!
            end
    --End Player Skill Sequences
 
 if (arg1=="debugskills") then  --Used for printing the skill table, and true/false usability
  DIYCE_DebugSkills(Skill)
  DIYCE_DebugSkills(Skill2)
 elseif (arg1=="debugpbuffs") then --Used for printing your buff names, and buffID
  DIYCE_DebugBuffList(pbuffs)
 elseif (arg1=="debugtbuffs") then --Used for printing target buff names, and buffID
  DIYCE_DebugBuffList(tbuffs)
 elseif (arg1=="debugall") then  --Used for printing all of the above at the same time
  DIYCE_DebugSkills(Skill)
  DIYCE_DebugSkills(Skill2)
  DIYCE_DebugBuffList(pbuffs)
  DIYCE_DebugBuffList(tbuffs)
 end
 
    if (not MyCombat(Skill, arg1)) then
        MyCombat(Skill2, arg1)
    end
 
    --Select Next Enemy
 if (tDead) then
  TargetUnit("")
  return
 end
 if mainClass == "RANGER" and (not party) then  --To keep scouts from pulling mobs without meaning to.
  if (not LockedOn) or (not enemy) then
   TargetNearestEnemy()
   return
  end
 elseif mainClass ~= "RANGER" then     --Let all other classes auto target.
  if (not LockedOn) or (not enemy) then
   TargetNearestEnemy()
   return
  end
 end
end



.lua file

Source code

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
-- DIY Combat Engine version 2.2
local g_skill  = {}
local g_lastaction = ""
-- Holds the created timers
local DIYCE_Timers = {}
function Msg(outstr,a1,a2,a3)
    DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr),a1,a2,a3)
end
function ReadSkills()
    g_skill = {}
    local skillname,slot
    for page = 1,4 do
        slot = 1
        skillname = GetSkillDetail(page,slot)
        repeat
            local a1,a2,a3,a4,a5,a6,a7,a8,skillusable = GetSkillDetail(page,slot)
            if skillusable then
                g_skill[skillname] = { ['page'] = page, ['slot'] = slot }
            end
            slot = slot + 1
            skillname = GetSkillDetail(page,slot)
        until skillname == nil
    end
end
-- Read Skills on Log-In/Class Change/Level-Up
        local DIYCE_EventFrame = CreateUIComponent("Frame","DIYCE_EventFrame","UIParent")
        DIYCE_EventFrame:SetScripts("OnUpdate", [=[ DIYCE_TimerUpdate(elapsedTime) ]=] )
            DIYCE_EventFrame:SetScripts("OnEvent", [=[ 
                    if event == 'PLAYER_SKILLED_CHANGED' then
                        ReadSkills()
                        end
                    ]=] )
            DIYCE_EventFrame:RegisterEvent("PLAYER_SKILLED_CHANGED")
function PctH(tgt)
    return (UnitHealth(tgt)/UnitMaxHealth(tgt))
end
function PctM(tgt)
    return (UnitMana(tgt)/UnitMaxMana(tgt))
end
function PctS(tgt)
    return (UnitSkill(tgt)/UnitMaxSkill(tgt))
end
function CancelBuff(buffname)
    local i = 1
    local buff = UnitBuff("player",i)
    while buff ~= nil do
        if buff == buffname then
            CancelPlayerBuff(i)
            return true
        end
        i = i + 1
        buff = UnitBuff("player",i)
    end
    return false
end
function BuffList(tgt)
    local list = {}
    local buffcmd = UnitBuff
    local infocmd = UnitBuffLeftTime
    if UnitCanAttack("player",tgt) then
        buffcmd = UnitDebuff
        infocmd = UnitDebuffLeftTime
    end
    -- There is a max of 100 buffs/debuffs per unit apparently
    for i = 1,100 do
        local buff, _, stackSize, ID = buffcmd(tgt, i)
        local timeRemaining = infocmd(tgt,i)
        if buff then
            -- Ad to list by name
            list[buff:gsub('(%()(.)(%))', '%2')] = { stack = stackSize, time = timeRemaining or 0, id = ID }
            -- We also list by ID in case two different buffs/debuffs have the same name.
            list[ID] = {stack = stackSize, time = timeRemaining or 0, name = buff:gsub("(%()(.)(%))", "%2") }
        else
            break
        end
    end
    return list
end
function CD(skillname)
    local firstskill = GetSkillDetail(2,1)
    if (g_skill[firstskill] == nil) or (g_skill[firstskill].page ~= 2) then
        ReadSkills()
    end
    if g_skill[skillname] ~= nil then
        local tt,cd = GetSkillCooldown(g_skill[skillname].page,g_skill[skillname].slot)
        return cd <= 0
    elseif skillname == nil then
        return false
    else
        Msg("Skill not available: "..skillname)        --Comment this line out if you do not wish to recieve this error message.
        return
    end
end
function MyCombat(Skill, arg1)
    local spell_name = UnitCastingTime("player")
    local talktome = ((arg1 == "v1") or (arg1 == "v2"))
    local action,actioncd,actiondef,actioncnt
 
    if spell_name ~= nil then
        if (arg1 == "v2") then Msg("- ['..spell_name..']", 0, 1, 1) end
        return true
    end
    for x,tbl in ipairs(Skill) do
 
    local useit = type(Skill[x].use) ~= "function" and Skill[x].use or (type(Skill[x].use) == "function" and Skill[x].use() or false)
        if useit then
            if string.find(Skill[x].name, "Action:") then
                action = tonumber((string.gsub(Skill[x].name, "(Action:)( *)(%d+)(.*)", "%3")))
                _1,actioncd = GetActionCooldown(action)
                actiondef,_1,actioncnt = GetActionInfo(action)
                if GetActionUsable(action) and (actioncd == 0) and (actiondef ~= nil) and (actioncnt > 0) then
                    if talktome then Msg("- "..Skill[x].name) end
                    UseAction(action)
                    return true
                end
            elseif string.find(Skill[x].name, "Custom:") then
                action = string.gsub(Skill[x].name, "(Custom:)( *)(.*)", "%3")
                if CustomAction(action) then
                    return true
                end
            elseif string.find(Skill[x].name, "Item:") then
                action = string.gsub(Skill[x].name, "(Item:)( *)(.*)", "%3")
                if talktome then Msg("- "..Skill[x].name) end
                UseItemByName(action)
                return true
            elseif (Skill[x].ignoretimer or GetDIYCETimerValue(Skill[x].timer) == 0) and CD(Skill[x].name) then
                if talktome then Msg("- "..Skill[x].name) end
                CastSpellByName(Skill[x].name)
                StartDIYCETimer(Skill[x].timer)
                return true
            elseif string.find(Skill[x].name, "Pet Skill:") then
                action = string.gsub(Skill[x].name, "(Pet Skill:)( *)(%d+)(.*)", "%3")
                    UsePetAction(action)
                if (arg1 == "v2") then Msg(Skill[x].name.." has been fully processed") end
                return true
            end
        end
    end
    if (arg1 == "v2") then Msg("- [IDLE]", 0, 1, 1) end
 
    return false
end
--[[ Timer Update function ]]--
-- Tick down any active timers
function DIYCE_TimerUpdate(elapsed)
    for k,v in pairs(DIYCE_Timers) do
        v.timeLeft = v.timeLeft - elapsed
        if v.timeLeft < 0 then
            v.timeLeft = 0
        end
    end
end
--[[ Create a named timer ]]--
-- if the named timer already exists, this does nothing.
function CreateDIYCETimer(timerName, waitTime)
    if not DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName] = { timeLeft = 0, waitTime = waitTime }
    end
end
--[[ Set/reset waitTimer of an existing timer ]]--
-- if the timer doesn't exist, this does nothing
function SetDIYCETimerDelay(timerName, waitTime)
    if DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName].waitTime = waitTime
    end
end
--[[ Delete named timer ]]--
-- if the timer doesn't exist, this does nothing
-- Not really needed, but added for completeness
function DeleteDIYCETimer(timerName)
    if DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName] = nil
    end
end
--[[ Get a timer's current time ]]--
-- if the timer doesn't exist, this returns 0
function GetDIYCETimerValue(timerName)
    if timerName then
        return DIYCE_Timers[timerName] and DIYCE_Timers[timerName].timeLeft or 0
    end
    return 0
end
--[[ Starts a timer ticking down ]]--
-- if timer doesn't exist, this does nothing
function StartDIYCETimer(timerName)
    if timerName and DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName].timeLeft = DIYCE_Timers[timerName].waitTime
    end
end
function CustomAction(action)
    if CD(action) then
        if IsShiftKeyDown() then Msg("- "..action) end
        g_lastaction = action
        CastSpellByName(action)
        return true
    else
        return false
    end
end
function BuffTimeLeft(tgt, buffname)
    local cnt = 1
    local buff = UnitBuff(tgt,cnt)
    while buff ~= nil do
        if string.find(buff,buffname) then
            return UnitBuffLeftTime(tgt,cnt)
        end
        cnt = cnt + 1
        buff = UnitBuff(tgt,cnt)
    end
    return 0
end
function BuffParty(arg1,arg2)
--    arg1 = Quickbar slot # for targetable, instant-cast buff without a cooldown (eg. Amp Attack) for range checking.
--    arg2 = buff expiration time cutoff (in seconds) for refreshing buffs, default is 45 seconds.
    local selfbuffs = { "Soul Bond", "Enhanced Armor", "Holy Seal" }
    local groupbuffs = { "Grace of Life", "Amplified Attack", "Angel's Blessing", "Essence of Magic", "Magic Barrier", "Blessed Spring Water", "Fire Ward", "Savage Blessing", "Concentration Prayer", "Shadow Fury"  }
    local buffrefresh = arg2 or 45           -- Refresh buff time (seconds)
    local spell = UnitCastingTime("player")  -- Spell being cast?
    local vocal = IsShiftKeyDown()           -- Generate feedback if Shift key held
    if (spell ~= nil) then
        return
    end
    if vocal then Msg("- Checking self buffs on "..UnitName("player")) end
    for i,buff in ipairs(selfbuffs) do
        if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("player",buff) <= buffrefresh) then
            if vocal then Msg("- Casting "..buff.." on "..UnitName("player")) end
            TargetUnit("player")
            CastSpellByName(buff)
            return
        end
    end
    if vocal then Msg("- Checking group buffs on "..UnitName("player")) end
    for i,buff in ipairs(groupbuffs) do
        if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("player",buff) <= buffrefresh) then
            if vocal then Msg("- Casting "..buff.." on "..UnitName("player")) end
            TargetUnit("player")
            CastSpellByName(buff)
            return
        end
    end
    for num=1,GetNumPartyMembers()-1 do
        TargetUnit("party"..num)
        if GetActionUsable(arg1) and (UnitHealth("party"..num) > 0) then
            if vocal then Msg("- Checking group buffs on "..UnitName("party"..num)) end
            for i,buff in ipairs(groupbuffs) do
                if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("target",buff) <= buffrefresh) then
                    if UnitIsUnit("target","party"..num) then
                        if vocal then Msg("- Casting "..buff.." on "..UnitName("target")) end
                        CastSpellByName(buff)
                        return
                    else
                        if vocal then Msg("- Error: "..UnitName("target").." != "..UnitName("party"..num)) end
                    end
                end
            end
        else
            if vocal then Msg("- Player "..UnitName("party"..num).." out of range or dead.") end
        end
    end
    if vocal then Msg("- Nothing to do.") end
end
--A few changes to the OP's Customfunctions to suit my needs.



EDIT:

Realized when reviewing what I posted that I had the conditionals incorrect. Updated Shot line below

Source code

1
{ name = "Shot",       use = (EnergyBar1 >= 20),    timer = "ExploitCooldown",   ignoretimer = (not tbuffs['Exploiting Shot'])  },


It needs to ignore the timer if the tbuff "exploiting shot" does not trigger, so I added the 'not' to that conditional. Sadly it is still not working. SO I'm still open to suggestions.

Also, is there any way to setup a function so I can actually see the timer counting down when it is triggered?

It certainly has gotten quiet around here since Ghost and Peryl left :(
Jacobmo 97Scout/97Warden/95Warrior/97Rogue/88D/85M
Allenmo 78S/77R/56P/1W/1K/1M - retired
Bteam all the way

264

Wednesday, December 7th 2011, 4:29pm

Warrior/Warden

I still can't run my DIYCE ;/... It only targeting and do nothing and spaming msg "Reading Class Skills". Help me please

265

Wednesday, December 7th 2011, 5:02pm

Quoted from "pikspk;491446"

I still can't run my DIYCE ;/... It only targeting and do nothing and spaming msg "Reading Class Skills". Help me please


Post. Your. Code.

all of it. You've posted only the customFunctions.lua one page back (some kind of hint to that code would have been nice here, too. Some People do not remember each and every Post...).
Do you have an error message (red glowing button at your minimap) ? post that, too.
What's your classes ? There are three combos in that code (Warrior/mage, Thief/Augur, Warrior/Warden, if i remember correctly - not so easy to look back a page while writing this...)
Does the Problem persists with all three of them ? Or do you have a completely different Combo (which would explain it...)

It's like asking a blind man to explain, why the sky is suddenly red.

266

Wednesday, December 7th 2011, 5:09pm

Warrior/Warden

CustomFunctions.lua

Source code

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
local silenceList = {
        ['Annihilation']     = true,
        ['King Bug Shock']     = true,
        ['Mana Rift']         = true,
        ['Dream of Gold']     = true,
        ['Flame']             = true,
        ['Flame Spell']     = true,
        ['Wave Bomb']         = true,
        ['Silence']         = true,
        ['Recover']         = true,
        ['Restore Life']     = true,
        ['Heal']             = true,
        ['Curing Shot']     = true,
        ['Leaves of Fire']     = true,
        ['Urgent Heal']     = true,
                    }
                    
function PriestFairySequence(arg1)
    local Skill = {}
    local Skill2 = {}
    local i = 0
    local FairyExists = UnitExists("playerpet")
    local FairyBuffs = BuffList("playerpet")
    --Determine Class-Combo
    mainClass, subClass = UnitClassToken( "player" )

    --Summon Fairy
    if (not FairyExists) and (not combat) then
        if mainClass == "AUGUR" then
            if subClass == "THIEF" then
                Skill = {
                    { name = "Shadow Fairy",            use = true },
                        }
            elseif subClass == "RANGER" then
                Skill = {
                    { name = "Water Fairy",                use = true },
                        }
            elseif subClass == "MAGE" then
                Skill = {
                    { name = "Wind Fairy",                use = true },
                        }            
            elseif subClass == "KNIGHT" then
                Skill = {
                    { name = "Light Fairy",                use = true },
                        }            
            elseif subClass == "WARRIOR" then
                Skill = {
                    { name = "Fire Fairy",                use = true },
                        }
            end
        end
    end    
    
    --Cast Halo
    if FairyExists then
        if mainClass == "AUGUR" then
            if subClass == "THIEF" then
                if (not FairyBuffs[503459]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Wraith Halo)",    use = true },
                            }
                end
            elseif subClass == "RANGER" then
                if (not FairyBuffs[503457]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Frost Halo)",    use = true },
                            }
                end
            elseif subClass == "MAGE" then
                if (not FairyBuffs[503461]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Windrider Halo)",    use = true },
                            }
                end
            elseif subClass == "KNIGHT" then
                if (not FairyBuffs[503507]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Devotion Halo)",    use = true },
                            }
                end
            elseif subClass == "WARRIOR" then
                if (not FairyBuffs[503455]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Accuracy Halo)",    use = true },
                            }
                end
            end
        
            --Cast Conceal
        if (not MyCombat(Skill, arg1)) then
            if (not FairyBuffs[503753]) then
                if (arg1 == "v1") then
                    Msg("- Activating Conceal", 0, 1, 1)
                end
                Skill2 = {
                    { name = "Pet Skill: 7 (Conceal)",    use = true },
                        }
            end
        end
        end
    end
    
    if (not MyCombat(Skill, arg1)) then
        MyCombat(Skill2, arg1)
    end
end
                        
function KillSequence(arg1, healthpot, manapot, foodslot)
--arg1 = "v1" or "v2" for debugging
--healthpot = # of actionbar slot for health potions
--manapot = # of actionbar slot for mana potions
--foodslot = # of actionbar slot for food (add more args for more foodslots if needed)

    local Skill = {}
    local Skill2 = {}
    local i = 0
    
    -- Player and target status.
    local combat = GetPlayerCombatState()
    local enemy = UnitCanAttack("player","target")
    local EnergyBar1 = UnitMana("player")
    local EnergyBar2 = UnitSkill("player")
    local pctEB1 = PctM("player")
    local pctEB2 = PctS("player")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")
    local tDead = UnitIsDeadOrGhost("target")
    local behind = (not UnitIsUnit("player", "targettarget"))
    local melee = GetActionUsable(13) -- # is your melee range spell slot number
    local phealth = PctH("player")
    local thealth = PctH("target")
    local LockedOn = UnitExists("target")
    local boss = UnitSex("target") > 2
    local elite = UnitSex("target") == 2
    local party = GetNumPartyMembers() >= 2
    
    --Determine Class-Combo
    mainClass, subClass = UnitClassToken( "player" )

    --Silence Logic
    local tSpell,tTime,tElapsed = UnitCastingTime("target")
    local silenceThis = tSpell and silenceList[tSpell] and ((tTime - tElapsed) > 0.1)
    
    --Potion Checks
    healthpot = healthpot or 0
    manapot = manapot or 0
    
    --Equipment and Pet Protection
    if phealth <= .04 then
            --SwapEquipmentItem()        --Note: Remove the first double dash to re-enable equipment protection.
        for i=1,6 do
            if (IsPetSummoned(i) == true) then
                ReturnPet(i);
            end
        end        
    end
        
    --Check for level 1 mobs, if it is, drop target and acquire a new one.
    if (LockedOn and (UnitLevel("target") < 2)) then
        TargetUnit("")
        return
    end
    
    --Begin Player Skill Sequences
    
        --Priest = AUGUR, Druid = DRUID, Mage = MAGE, Knight = KNIGHT, 
        --Scout = RANGER, Rogue = THIEF, Warden = WARDEN, Warrior = WARRIOR
                end

	--Class: Warrior/Warden
	elseif mainClass == "WARRIOR" and subClass == "WARDEN" then
    
        --Combat
        if enemy then
            Skill = {
                { name = "Savage Whirlwind",                    use = (EnergyBar2 >= 250) },
                { name = "Attack Weakener",                use = (EnergyBar2 >= 200) and (tbuffs['Vulnerable']) },
                { name = "Probing Attack",            use = (EnergyBar1 >= 15) },
                { name = "Open Flank",                use = (EnergyBar1 >= 10) and (tbuffs['Vulnerable']) and CD("Attack Weakener") },
                { name = "Slash",                    use = (EnergyBar1 >= 25) },
                { name = "Power of the Wood Spirit",                    use = (EnergyBar2 >= 250) },
                    }
        end
                
            --ADD MORE CLASS COMBOS HERE. 
            --USE AN "ELSEIF" TO CONTINUE WITH MORE CLASS COMBOS.
            --THE NEXT "END" STATEMENT IS THE END OF THE CLASS COMBOS STATEMENTS.
            --DO NOT POST BELOW THE FOLLOWING "END" STATEMENT!
            end
    --End Player Skill Sequences
    
    if (not MyCombat(Skill, arg1)) then
        MyCombat(Skill2, arg1)
    end
        
    --Select Next Enemy
    if (tDead) then
        TargetUnit("")
        return
    elseif (not LockedOn) or (not enemy) then
        TargetNearestEnemy()
        return
    end
    
end


DIYCE.lua

Source code

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
-- DIY Combat Engine version 2.2

local g_skill  = {}
local g_lastaction = ""

function Msg(outstr,a1,a2,a3)
	DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr),a1,a2,a3)
end

function ReadSkills()
	g_skill = {}
	local skillname,slot

	for page = 1,4 do
		slot = 1
		skillname = GetSkillDetail(page,slot)
		repeat
			local a1,a2,a3,a4,a5,a6,a7,a8,skillusable = GetSkillDetail(page,slot)
			if skillusable then
				g_skill[skillname] = { ['page'] = page, ['slot'] = slot }
			end
			slot = slot + 1
			skillname = GetSkillDetail(page,slot)
		until skillname == nil
	end
end

-- Read Skills on Log-In/Class Change/Level-Up
		local DIYCE_EventFrame = CreateUIComponent("Frame","DIYCE_EventFrame","UIParent")
			DIYCE_EventFrame:SetScripts("OnEvent", [=[ 
					if event == 'PLAYER_SKILLED_CHANGED' then
						ReadSkills()
						end
					]=] )
			DIYCE_EventFrame:RegisterEvent("PLAYER_SKILLED_CHANGED")

function PctH(tgt)
	return (UnitHealth(tgt)/UnitMaxHealth(tgt))
end

function PctM(tgt)
	return (UnitMana(tgt)/UnitMaxMana(tgt))
end

function PctS(tgt)
	return (UnitSkill(tgt)/UnitMaxSkill(tgt))
end

function CancelBuff(buffname)
	local i = 1
	local buff = UnitBuff("player",i)

	while buff ~= nil do
		if buff == buffname then
			CancelPlayerBuff(i)
			return true
		end

		i = i + 1
		buff = UnitBuff("player",i)
	end
	return false
end

function BuffList(tgt)
    local list = {}
    local buffcmd = UnitBuff
    local infocmd = UnitBuffLeftTime

    if UnitCanAttack("player",tgt) then
        buffcmd = UnitDebuff
        infocmd = UnitDebuffLeftTime
    end

    -- There is a max of 100 buffs/debuffs per unit apparently
    for i = 1,100 do
        local buff, _, stackSize, ID = buffcmd(tgt, i)
        local timeRemaining = infocmd(tgt,i)
        if buff then
            -- Ad to list by name
            list[buff:gsub('(%()(.)(%))', '%2')] = { stack = stackSize, time = timeRemaining, id = ID }
            -- We also list by ID in case two different buffs/debuffs have the same name.
            list[ID] = {stack = stackSize, time = timeRemaining, name = buff:gsub("(%()(.)(%))", "%2") }
        else
            break
        end
    end

    return list
end

function CD(skillname)
	local firstskill = GetSkillDetail(2,1)
	if (g_skill[firstskill] == nil) or (g_skill[firstskill].page ~= 2) then
		ReadSkills()
	end

	if g_skill[skillname] ~= nil then
		local tt,cd = GetSkillCooldown(g_skill[skillname].page,g_skill[skillname].slot)
		return cd <= 0.4
	elseif skillname == nil then
		return false
	else
		Msg("Skill not available: "..skillname)		--Comment this line out if you do not wish to recieve this error message.
        return
	end
end

function MyCombat(Skill, arg1)
	local spell_name = UnitCastingTime("player")
	local talktome = ((arg1 == "v1") or (arg1 == "v2"))
	local action,actioncd,actiondef,actioncnt
	
	if spell_name ~= nil then
		if (arg1 == "v2") then Msg("- ['..spell_name..']", 0, 1, 1) end
		return true
	end

	for x,tbl in ipairs(Skill) do
		
	local useit = type(Skill[x].use) ~= "function" and Skill[x].use or (type(Skill[x].use) == "function" and Skill[x].use() or false)
		if useit then
			if string.find(Skill[x].name, "Action:") then
				action = tonumber((string.gsub(Skill[x].name, "(Action:)( *)(%d+)(.*)", "%3")))
				_1,actioncd = GetActionCooldown(action)
				actiondef,_1,actioncnt = GetActionInfo(action)
				if GetActionUsable(action) and (actioncd == 0) and (actiondef ~= nil) and (actioncnt > 0) then
					if talktome then Msg("- "..Skill[x].name) end
					UseAction(action)
					return true
				end
			elseif string.find(Skill[x].name, "Custom:") then
				action = string.gsub(Skill[x].name, "(Custom:)( *)(.*)", "%3")
				if CustomAction(action) then
					return true
				end
			elseif string.find(Skill[x].name, "Item:") then
				action = string.gsub(Skill[x].name, "(Item:)( *)(.*)", "%3")
				if talktome then Msg("- "..Skill[x].name) end
				UseItemByName(action)
				return true
			elseif CD(Skill[x].name) then
				if talktome then Msg("- "..Skill[x].name) end
				CastSpellByName(Skill[x].name)
				return true
			elseif string.find(Skill[x].name, "Pet Skill:") then
				action = string.gsub(Skill[x].name, "(Pet Skill:)( *)(%d+)(.*)", "%3")
					UsePetAction(action)
				if (arg1 == "v2") then Msg(Skill[x].name.." has been fully processed") end
				return true
			end
		end
	end
	if (arg1 == "v2") then Msg("- [IDLE]", 0, 1, 1) end
	
	return false
end

function CustomAction(action)
    if CD(action) then
        if IsShiftKeyDown() then Msg("- "..action) end
        g_lastaction = action
        CastSpellByName(action)
        return true
    else
        return false
    end
end

function BuffTimeLeft(tgt, buffname)
    local cnt = 1
	local buff = UnitBuff(tgt,cnt)

	while buff ~= nil do
		if string.find(buff,buffname) then
			return UnitBuffLeftTime(tgt,cnt)
		end
		cnt = cnt + 1
		buff = UnitBuff(tgt,cnt)
	end

	return 0
end

function BuffParty(arg1,arg2)
--    arg1 = Quickbar slot # for targetable, instant-cast buff without a cooldown (eg. Amp Attack) for range checking.
--    arg2 = buff expiration time cutoff (in seconds) for refreshing buffs, default is 45 seconds.

    local selfbuffs = { "Soul Bond", "Enhanced Armor", "Holy Seal" }
    local groupbuffs = { "Grace of Life", "Amplified Attack", "Angel's Blessing", "Essence of Magic", "Magic Barrier", "Blessed Spring Water", "Fire Ward", "Savage Blessing", "Concentration Prayer", "Shadow Fury"  }

    local buffrefresh = arg2 or 45           -- Refresh buff time (seconds)
    local spell = UnitCastingTime("player")  -- Spell being cast?
    local vocal = IsShiftKeyDown()           -- Generate feedback if Shift key held

    if (spell ~= nil) then
        return
    end

    if vocal then Msg("- Checking self buffs on "..UnitName("player")) end
    for i,buff in ipairs(selfbuffs) do
        if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("player",buff) <= buffrefresh) then
            if vocal then Msg("- Casting "..buff.." on "..UnitName("player")) end
            TargetUnit("player")
            CastSpellByName(buff)
            return
        end
    end

    if vocal then Msg("- Checking group buffs on "..UnitName("player")) end
    for i,buff in ipairs(groupbuffs) do
        if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("player",buff) <= buffrefresh) then
            if vocal then Msg("- Casting "..buff.." on "..UnitName("player")) end
            TargetUnit("player")
            CastSpellByName(buff)
            return
        end
    end

    for num=1,GetNumPartyMembers()-1 do
        TargetUnit("party"..num)
        if GetActionUsable(arg1) and (UnitHealth("party"..num) > 0) then
            if vocal then Msg("- Checking group buffs on "..UnitName("party"..num)) end
            for i,buff in ipairs(groupbuffs) do
                if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("target",buff) <= buffrefresh) then
                    if UnitIsUnit("target","party"..num) then
                        if vocal then Msg("- Casting "..buff.." on "..UnitName("target")) end
                        CastSpellByName(buff)
                        return
                    else
                        if vocal then Msg("- Error: "..UnitName("target").." != "..UnitName("party"..num)) end
                    end
                end
            end
        else
            if vocal then Msg("- Player "..UnitName("party"..num).." out of range or dead.") end
        end
    end

    if vocal then Msg("- Nothing to do.") end
end


Class: Warrior/Warden
Errors: interface\AddOns\DIYCE\CustomFunctions.lua [string '?']:186:'<eof>' expected near 'elseif'
and [string ' KillSequence()']:1 attempt to call global 'KillSequence' (anil value)

267

Wednesday, December 7th 2011, 5:28pm

Quoted from "hangman04;491215"

Atm it checks how many stacks a certain buff has, but not how many times that debuff exists on the target.
Bleeds from warrior and rogues or even from scouts (Vamp arrow) can be more then 1 on a target.
For warriors, tactical attack (crappy 250% dps skill) has a nice rule: the no of TA that hit the target = no of slash bleeds on the target +1. So if they are 3 slash bleeds on a boss, my TA will hit x4.
I want to set my TA hit only if they are at least 2 slash bleeds on the boss.


hi, i think some function like this would pretty much fit what you are looking for. add this code to your diyce.lua:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function ChkBuffCount(tgt,buffname,buffcount)
    local cnt = 1
    local buffcmd = UnitBuff
    local buffcounter = 0

    if UnitCanAttack("player",tgt) then
        buffcmd = UnitDebuff
    end
    local buff = buffcmd(tgt,cnt)

    while buff ~= nil do
        if string.gsub(buff, "(%()(.)(%))", "%2") == buffname then
            buffcounter = buffcounter + 1        
        end
        cnt = cnt + 1
        buff = buffcmd(tgt,cnt)
        
        if buffcounter >= buffcount then
            return true
        end
    end    
end


and your customfunction.lua file should look like this if you want 2 bleed debuffs on the target before using TA:

Source code

1
2
3
4
5
6
7
8
[...]

                if (enemy) then
                Skill2 = {
                    { name = "Tactical Attack",   use = ((EnergyBar1 >= 15) and (ChkBuffCount("target","Bleed",2))) },                
                        }    

[...]
it works but its quite static and wont scale with the people in your party who might be able to support you with the corresponding debuff (bleed, vampire arrows etc.). i would really appreciate if someone could give a hint for a function which pays attention to the party member.

someting like: if 3 warrior/x and 2 x/warrior in party turn true if the counter returns 5)

sorry for the bad english. im german. ;)

p.s. im still working with a diyce 1.x version. but im pretty sure it will work with diyce 2.0 as well.

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

268

Wednesday, December 7th 2011, 7:50pm

Quoted from "hangman04;491215"

Atm it checks how many stacks a certain buff has, but not how many times that debuff exists on the target.
Bleeds from warrior and rogues or even from scouts (Vamp arrow) can be more then 1 on a target.
For warriors, tactical attack (crappy 250% dps skill) has a nice rule: the no of TA that hit the target = no of slash bleeds on the target +1. So if they are 3 slash bleeds on a boss, my TA will hit x4.
I want to set my TA hit only if they are at least 2 slash bleeds on the boss.


Tactical Attack should not stack 4 times though ... Rogue Wound Attack doesn't work that way either.

It's only your own persona Slash Bleed.

What I did with Shadowstab & Low Blow was that I set a fake-cool-down on them to hit every couple of seconds to ensure a bleed is maintained for Wound Attack.

269

Thursday, December 8th 2011, 9:46am

Quoted from "pikspk;491465"

CustomFunctions.lua
Errors: interface\AddOns\DIYCE\CustomFunctions.lua [string '?']:186:'<eof>' expected near 'elseif'
and [string ' KillSequence()']:1 attempt to call global 'KillSequence' (anil value)


Without testing anything, i would guess, the error says it all:
There is an "end" in line 183 - this ends the whole function, since it has no if to it...
Same thing in Line 204.

You probably copied these "end" together with the code -

remove them and try again.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

270

Friday, December 9th 2011, 1:41am

No, I'm not back (@sekrit, be quiet you :) ), I just popped in to see what was up. Couldn't resist giving a little bit of help.

@pikspk
Your main problem is that you deleted a bunch of lines for other classes, but forgot to re-adjust the main if-else statement.

Specifically (and partially as Muinimula noted), these are what need to be fixed (all in the KillSequence function):

Source code

1
2
3
        --Priest = AUGUR, Druid = DRUID, Mage = MAGE, Knight = KNIGHT, 
        --Scout = RANGER, Rogue = THIEF, Warden = WARDEN, Warrior = WARRIOR
                end

The end statement here is extraneous. Probably left over from when you deleted some lines. Remove it.

Source code

1
2
	--Class: Warrior/Warden
	elseif mainClass == "WARRIOR" and subClass == "WARDEN" then

Since this is now the first line encountered for the if statement, it cannot be an elseif as there now is no if for it to be an else to. Change it to if. This should also then allow the last end statement (the second one Muinimula mentions) to be associated correctly.

For some info on how to fix these types of problems yourself, see my "Avoiding Common Lua Errors" tutorial (link in my sig).
2013... The year from hell....

271

Friday, December 9th 2011, 2:22am

Peryl! Hey, I want to throw something past you right quick.

A guildmate of mine wants to be able to start a timer when a specific target buff is detected and then use that timer as a condition on a skill. I figured that it would take an engine alteration. Here's what I've got so far. In the MyCombat function at the bottom of the "useit" if-then block I've added the following code.

Source code

1
2
3
4
5
6
            elseif string.find(Skill[x].name, "Timer:") then
                action = string.gsub(Skill[x].name, "(Timer:)( *)(.*)", "%3")
                if talktome then Msg("- "..Skill[x].name) end
                StartDIYCETimer(action)
                return true
			end


And in his CustomFunctions.lua I'm setting up this :

Source code

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
elseif mainClass == "RANGER" and subClass == "THIEF" then
 
				--Timers for this class
					CreateDIYCETimer("ExploitCooldown", 32)
 
				if (enemy and (arg2 == "DPS")) then
					Skill2 = {
						{ name = "Timer: ExploitCooldown",     use = (tbuffs['Exploiting Shot']) },
						--{ name = "Autoshot",      use = (not ASon) },
						--{ name = "Sapping Arrow",    use = (not pbuffs['Sapping Arrow']) },
						{ name = "Shot",       use = (EnergyBar1 >= 20) and (GetDIYCETimerValue(ExploitCooldown) == 0) },
						--{ name = "Reflected Shot",     use = true },  
						--{ name = "Vampire Arrows",     use = true },
						--{ name = "Deadly Poison Bite",   use = true },
						--{ name = "Piercing Arrow",     use = true }, 
						--{ name = "Combo Shot",      use = true },
						--{ name = "Weak Spot",     use = true },
						{ name = "Wind Arrows",     use = (EnergyBar1 >= 20) } 
					}
 
				elseif (enemy and (arg2 == "FARM")) then
					Skill2 = {
						{ name = "Reflected Shot",     use = true },  
						{ name = "Piercing Arrow",     use = true },
						{ name = "Vampire Arrows",     use = true },
						{ name = "Wind Arrows",     use = (EnergyBar1 >= 20) }
					}  
				end


Note the "Timer" line and the "Shot" skill line.

Essentially, what he wants to do is fire shot until the "Exploiting Shot" buff is triggered and then disallow shot during the 12 second buff and the 20 seconds afterwards when it can't yet be re-triggered. What I'm trying to do is set up an "unbound" timer. A timer that can be activated conditionally, separate from a skill activation, and then be used as a condition in another line. The timer will be defined the same way as any other timer is defined. The above is just a first attempt. I haven't tested it yet.

I have figured out the pseudo regex pattern matching of lua, but I'm not yet sure if I am calling the StartDIYCEtimer function correctly or if I can use the GetDIYCEtimervalue function like that. Am I headed in the right direction?

EDIT: One more thing. He also wants the timer to print out the countdown. Can I just throw a

Source code

1
Msg("Seconds Remaining: "..v.timeLeft)


in the DIYCE_TimerUpdate function? I actually think that it would have to more complex than just that so that different timers could be differentiated and not clash.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

272

Friday, December 9th 2011, 2:51am

Source code

1
2
3
4
5
6
            elseif string.find(Skill[x].name, "Timer:") then
                action = string.gsub(Skill[x].name, "(Timer:)( *)(.*)", "%3")
                if talktome then Msg("- "..Skill[x].name) end
                StartDIYCETimer(action)
                return true
			end


This seems fine for your intent. Though you might want to change the ( *) to (%s*) to ensure you are getting a space character here.


(I snipped out a little of the code for clarity)

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
				--Timers for this class
					CreateDIYCETimer("ExploitCooldown", 32)
 
				if (enemy and (arg2 == "DPS")) then
					Skill2 = {
						{ name = "Timer: ExploitCooldown",     use = (tbuffs['Exploiting Shot']) },
						{ name = "Shot",       use = (EnergyBar1 >= 20) and (GetDIYCETimerValue(ExploitCooldown) == 0) },
						{ name = "Wind Arrows",     use = (EnergyBar1 >= 20) } 
					}
 
				elseif (enemy and (arg2 == "FARM")) then
                                   ...
				end

This again looks good to me.

Quoted from "jtanner28;491923"

I have figured out the pseudo regex pattern matching of lua, but I'm not yet sure if I am calling the StartDIYCEtimer function correctly or if I can use the GetDIYCEtimervalue function like that. Am I headed in the right direction?

Yup, you can. GetDIYCETimerValue will return the time count of a timer or 0 if the timer isn't running OR if the timer doesn't exist (was never created or was deleted). StartDIYCETimer() will always start the timer with the delay given in the CreateDIYCETimer call. If the timer doesn't exist, it does nothing at all.

Quoted from "jtanner28;491923"

EDIT: One more thing. He also wants the timer to print out the countdown. Can I just throw a

Source code

1
Msg("Seconds Remaining: "..v.timeLeft)


in the DIYCE_TimerUpdate function? I actually think that it would have to more complex than just that so that different timers could be differentiated and not clash.

You could, but it would make a little more sense to do it in KillSequence by getting the value of the timer with GetDIYCETimerValue and output only if non-zero (or set a flag if non-zero, print out, then if value is now 0, clear the flag. This way you get at least one output of a 0 count).

Doing it in DIYCE_TimerUpdate would print the value for all timers that may be active.

Edit:
Thinking about it a bit more, you might want to go back to the DIYCE_TimerUpdate but add code to only output a given timer (maybe set a flag on creation of the timer). So only display for those timers that have the flag set.

Doing it in KillSequence would only give you the time when you hit the button.
2013... The year from hell....

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

273

Friday, December 9th 2011, 2:50pm

@XariRoM

Yes, that should work properly if u do it based on id [500018 - in my case] and not on names.

@mrmisterwaa

Nop, TA is dif then Wound Attack. If there is not Warrior Slash Bleed it would do 250% dps. If there is your War Sl Bleed it will be like Keen Attack (x2), and if there is another SL Bleed, from another warrior or x/w it will do x3. So it was in ch 3 and also it remained unchanged after ch 4.

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

274

Friday, December 9th 2011, 4:58pm

Quoted from "hangman04;492035"

@XariRoM

Yes, that should work properly if u do it based on id [500018 - in my case] and not on names.

@mrmisterwaa

Nop, TA is dif then Wound Attack. If there is not Warrior Slash Bleed it would do 250% dps. If there is your War Sl Bleed it will be like Keen Attack (x2), and if there is another SL Bleed, from another warrior or x/w it will do x3. So it was in ch 3 and also it remained unchanged after ch 4.


That I didn't know that but as XariRoM posted,

Just add a counter on how many times "Bleed" pops up.

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

275

Friday, December 9th 2011, 9:59pm

Quoted from "mrmisterwaa;492064"

That I didn't know that but as XariRoM posted,

Just add a counter on how many times "Bleed" pops up.


Easier said than done! I dunno how to change bufflist function to add the counter or how to modify xari's function and to use also function IDs.

276

Saturday, December 10th 2011, 2:43am

help? lol im workin on diyce for r/w

it works great excepttttttttttttttttttttt

Blind spot seems to lock up the diyce.

If i am solo it works great. cuz i have agro and im not behind target it wont try to use blindspot. if i get behind target it will use it.

IF i am in a party and i am not the targetstarget and i am not behind the target then it the diyce just tries to spam BS giving me the error must be behind target.

IF i am behind target in the party it works great.

local silenceList = {
['Annihilation'] = true,
['King Bug Shock'] = true,
['Mana Rift'] = true,
['Dream of Gold'] = true,
['Flame'] = true,
['Flame Spell'] = true,
['Wave Bomb'] = true,
['Silence'] = true,
['Recover'] = true,
['Restore Life'] = true,
['Heal'] = true,
['Curing Shot'] = true,
['Leaves of Fire'] = true,
['Urgent Heal'] = true,
}

function KillSequence(arg1)
--arg1 = "v1" or "v2" for debugging
--healthpot = # of actionbar slot for health potions
--manapot = # of actionbar slot for mana potions
--foodslot = # of actionbar slot for food (add more args for more foodslots if needed)
local Skill = {}
local Skill2 = {}
local i = 0

-- Player and target status.
local combat = GetPlayerCombatState()
local enemy = UnitCanAttack("player","target")
local EnergyBar1 = UnitMana("player")
local EnergyBar2 = UnitSkill("player")
local pctEB1 = PctM("player")
local pctEB2 = PctS("player")
local tbuffs = BuffList("target")
local pbuffs = BuffList("player")
local tDead = UnitIsDeadOrGhost("target")
local behind = (not UnitIsUnit("player", "targettarget"))
local melee = GetActionUsable(13) -- # is your melee range spell slot number
local phealth = PctH("player")
local thealth = PctH("target")
local LockedOn = UnitExists("target")
local boss = UnitSex("target") > 2
local elite = UnitSex("target") == 2
local party = GetNumPartyMembers() >= 2

--Determine Class-Combo
mainClass, subClass = UnitClassToken( "player" )
--Silence Logic
local tSpell,tTime,tElapsed = UnitCastingTime("target")
local silenceThis = tSpell and silenceList[tSpell] and ((tTime - tElapsed) > 0.1)

--Potion Checks
healthpot = healthpot or 0
manapot = manapot or 0

--Equipment and Pet Protection
if phealth <= .04 then
SwapEquipmentItem() --Note: Remove the first double dash to re-enable equipment protection.
for i=1,6 do
if (IsPetSummoned(i) == true) then
ReturnPet(i);
end
end
end

if (LockedOn and (UnitLevel("target") < 2)) then
TargetUnit("")
TargetNearestEnemy()
return
end

--Begin Player Skill Sequences

--Priest = AUGUR, Druid = DRUID, Mage = MAGE, Knight = KNIGHT,
--Scout = RANGER, Rogue = THIEF, Warden = WARDEN, Warrior = WARRIOR

-- Class: Rogue/Warrior
if mainClass == "THIEF" and subClass == "WARRIOR" then

--Combat
if enemy then
Skill2 = {
{ name = "Blind Spot", use = (EnergyBar1 >= 25) and behind },
{ name = "Poisonous Infection", use = (EnergyBar2 >= 20) and (pbuffs['Poisonous']) and (not tbuffs[502894]) },
{ name = "Decay", use = (EnergyBar1 >= 60) and (pbuffs['Poisonous']) and (not pbuffs['Brutal Atrocity']) },
{ name = "Death's Touch", use = (EnergyBar2 >= 15) and (not tbuffs[501815]) },
{ name = "Low Blow", use = (EnergyBar1 >= 30) and (tbuffs[500654] or tbuffs[620297]) and (not tbuffs[620314]) },
{ name = "Shadowstab", use = (EnergyBar1 >= 20) and (not tbuffs[500654]) },
{ name = "Wound Attack", use = (EnergyBar1 >= 35) },
{ name = "Slash", use = (EnergyBar2 >= 25) },
{ name = "Enraged", use = (EnergyBar2 <= 25) },
{ name = "Shadowstab", use = (EnergyBar1 >= 35) },
}
end


i have also variations of
{ name = "Blind Spot", use = (EnergyBar1 >= 25) and behind and party and boss },

maybe i need to change
local behind = (not UnitIsUnit("player", "targettarget"))
? but i dont know.
70R/70W/70K Retired.

277

Saturday, December 10th 2011, 3:11am

Error

Hi all,

I am using Mrmisterwaa rogue/scout DIYCE with a few changes to skills.

I keep getting this error: [string 'KillSequence('','4')']:1: attempt to call global 'KillSequence' (a nil value)

Same error for "KillSequence("","1") and 2, 3.

CustomFunction.lua

Source code

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
local WHITE = "|cffffffff"
local SILVER = "|cffc0c0c0"
local GREEN = "|cff00ff00"
local LTBLUE = "|cffa0a0ff"

function DIYCE_DebugSkills(skillList)
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."Skill List:")
    
    for i,v in ipairs(skillList) do
        DEFAULT_CHAT_FRAME:AddMessage(SILVER.."  ['..WHITE..i..SILVER..']: "..LTBLUE.."" "..WHITE..v.name..LTBLUE..""  use = "..WHITE..(v.use and "true" or "false"))
    end

    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."----------")
end

function DIYCE_DebugBuffList(buffList)
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."Buff List:")
    
    for k,v in pairs(buffList) do
        -- We ignore numbered entries because both the ID and name 
        -- are stored in the list. This avoids doubling the output.
        if type(k) ~= "number" then
            DEFAULT_CHAT_FRAME:AddMessage(SILVER.."  ['..WHITE..k..SILVER..']:  "..LTBLUE.."id: "..WHITE..v.id..LTBLUE.."  stack: "..WHITE..v.stack..LTBLUE.."  time: "..WHITE..v.time)
        end
    end
    
    DEFAULT_CHAT_FRAME:AddMessage(GREEN.."----------")    
end

local silenceList = {
        ['Annihilation']    = true,
        ['King Bug Shock']  = true,
        ['Mana Rift']       = true,
        ['Dream of Gold']   = true,
        ['Flame']           = true,
        ['Flame Spell']     = true,
        ['Wave Bomb']       = true,
        ['Silence']         = true,
        ['Recover']         = true,
        ['Restore Life']    = true,
        ['Heal']            = true,
        ['Curing Shot']     = true,
        ['Leaves of Fire']  = true,
        ['Urgent Heal']     = true,
        ['Heavy Shelling']  = true, --Juggler Apprentice in Grafu
        ['Dark Healing']    = true, --Mini-boss in Sardo
                    }
                    
function PriestFairySequence(arg1)
    local Skill = {}
    local Skill2 = {}
    local i = 0
    local FairyExists = UnitExists("playerpet")
    local FairyBuffs = BuffList("playerpet")
    local combat = GetPlayerCombatState()

    --Determine Class-Combo
    mainClass, subClass = UnitClassToken( "player" )

    --Summon Fairy
    if (not FairyExists) and (not combat) then
        if mainClass == "AUGUR" then
            if subClass == "THIEF" then
                Skill = {
                    { name = "Shadow Fairy",            use = true },
                        }
            elseif subClass == "RANGER" then
                Skill = {
                    { name = "Water Fairy",                use = true },
                        }
            elseif subClass == "MAGE" then
                Skill = {
                    { name = "Wind Fairy",                use = true },
                        }            
            elseif subClass == "KNIGHT" then
                Skill = {
                    { name = "Light Fairy",                use = true },
                        }            
            elseif subClass == "WARRIOR" then
                Skill = {
                    { name = "Fire Fairy",                use = true },
                        }
            end
        end
    end    
    
    --Cast Halo
    if FairyExists then
        if mainClass == "AUGUR" then
            if subClass == "THIEF" then
                if (not FairyBuffs[503459]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Wraith Halo)",    use = true },
                            }
                end
            elseif subClass == "RANGER" then
                if (not FairyBuffs[503457]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Frost Halo)",    use = true },
                            }
                end
            elseif subClass == "MAGE" then
                if (not FairyBuffs[503461]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Windrider Halo)",    use = true },
                            }
                end
            elseif subClass == "KNIGHT" then
                if (not FairyBuffs[503507]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Devotion Halo)",    use = true },
                            }
                end
            elseif subClass == "WARRIOR" then
                if (not FairyBuffs[503455]) then
                    if (arg1 == "v1") then
                        Msg("- Activating Halo", 0, 1, 1)
                    end
                    Skill = {
                        { name = "Pet Skill: 6 (Accuracy Halo)",    use = true },
                            }
                end
            end
        
            --Cast Conceal
        if (not MyCombat(Skill, arg1)) then
            if (not FairyBuffs[503753]) then
                if (arg1 == "v1") then
                    Msg("- Activating Conceal", 0, 1, 1)
                end
                Skill2 = {
                    { name = "Pet Skill: 7 (Conceal)",    use = true },
                        }
            end
        end
        end
    end
    
    if (not MyCombat(Skill, arg1)) then
        MyCombat(Skill2, arg1)
    end
end
                        
function KillSequence(arg1, goat2, healthpot, manapot, foodslot)
--arg1 = "v1" or "v2" for debugging
--healthpot = # of actionbar slot for health potions
--manapot = # of actionbar slot for mana potions
--foodslot = # of actionbar slot for food (add more args for more foodslots if needed)

    local Skill = {}
    local Skill2 = {}
    local i = 0
    
    -- Player and target status.
    local combat = GetPlayerCombatState()
    local enemy = UnitCanAttack("player","target")
    local EnergyBar1 = UnitMana("player")
    local EnergyBar2 = UnitSkill("player")
    local pctEB1 = PctM("player")
    local pctEB2 = PctS("player")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")
    local tDead = UnitIsDeadOrGhost("target")
    local behind = (not UnitIsUnit("player", "targettarget"))
    local melee = GetActionUsable(2) -- # is your melee range spell slot number
    local a1,a2,a3,a4,a5,ASon = GetActionInfo(14)  -- # is your Autoshot slot number
    local phealth = PctH("player")
    local thealth = PctH("target")
    local LockedOn = UnitExists("target")
    local boss = UnitSex("target") > 2
    local elite = UnitSex("target") == 2
    local party = GetNumPartyMembers() >= 2
    
    
    --Determine Class-Combo
    mainClass, subClass = UnitClassToken( "player" )

    --Silence Logic
    local tSpell,tTime,tElapsed = UnitCastingTime("target")
    local silenceThis = tSpell and silenceList[tSpell] and ((tTime - tElapsed) > 0.1)
    
    --Potion Checks
    healthpot = healthpot or 0
    manapot = manapot or 0
    
    --Equipment and Pet Protection
    if phealth <= .03 then
            SwapEquipmentItem()        --Note: Remove the first double dash to re-enable equipment protection.
        for i=1,6 do
            if (IsPetSummoned(i) == true) then
                ReturnPet(i);
            end
        end        
    end
        
    --Check for level 1 mobs, if it is, drop target and acquire a new one.
    if (LockedOn and (UnitLevel("target") < 2)) then
        TargetUnit("")
        return
    end
    
    --Begin Player Skill Sequences
    
        --Priest = AUGUR, Druid = DRUID, Mage = MAGE, Knight = KNIGHT, 
        --Scout = RANGER, Rogue = THIEF, Warden = WARDEN, Warrior = WARRIOR
        

        --Class: Rogue/Scout
            if mainClass == "THIEF" and subClass == "RANGER" then
            --Timers for this class
            CreateDIYCETimer("SSBleed", 7.5) --Change the value between 6 -> 7.5 depending on your lag.
            CreateDIYCETimer("LBBleed", 8.5) --Change the value between 7 ->  8.5 depending on your lag.
             --goat2: 1 = Melee, 2 = Ranged, 3 = Burn, 4 = Buffs
            
            --Buffs
            if (goat2 == "4") then
            Skill = {
                { name = "Combat Master",                use = ((not pbuffs['Combat Master'])) },
                { name = "Poison",                       use = ((not pbuffs['Poisonous']) or (pbuffs['Poisonous'].time <= 45)) },
                { name = "Unbridled Enthusiasm",         use = ((not pbuffs['Unbridled Enthusiasm']) or (pbuffs['Unbridled Enthusiasm'].time <= 45)) },
                { name = "Action: "..healthpot,          use = (phealth <= .70) },
                { name = "Action: "..manapot,            use = (pctEB2 <= .40) },
                    }
            --Burn
            elseif (goat2 == "3") then
            Skill = {
                { name = "Premeditation",                use = (not combat) and boss and (EnergyBar1 >= 50) },
                { name = "Informer",                     use = boss },
                { name = "Assassins Rage",               use = boss },
                { name = "Fervent Attack",               use = boss },
                { name = "Evasion",                      use = boss },
                { name = "Energy Thief",                 use = ((EnergyBar1 < 50) and (boss) and (not tDead)) },
                { name = "Substitute",                     use = ((phealth <= .50) and (EnergyBar2 >= 30) and (boss) and (not tDead)) }, 
                    } 
            end
                
            --Combat
            if ((enemy) and (goat2 == "1")) then
            Skill2 = { 
                { name = "Wound Attack",                 use = ((EnergyBar1 >= 35) and ((tbuffs[500654]) and (tbuffs[500704]))) },
                { name = "Shadowstab",                   use = (EnergyBar1 >= 20),       timer = "SSBleed" },
                { name = "Low Blow",                     use = (((EnergyBar1 >= 25) and (tbuffs[500654])) or (tbuffs['Energy Thief'])),      timer = "LBBleed",   ignoretimer = not tbuffs['Energy Thief'] }
                { name = "Vampire Arrows",               use = (EnergyBar2 >= 20) },
                { name = "Throat Attack",                use = ((EnergyBar2 >= 50) and (boss or elite) and (silenceThis)) },
                { name = "Shot",                         use = (EnergyBar1 < 20) },
                { name = "Wrist Attack",                 use = ((EnergyBar2 >= 50) and (boss)) },
                { name = "Attack",                       use = (thealth == 1) },                    
                         }
            elseif ((enemy) and (goat2 == "2")) then
            Skill2 = {
                { name = "Vampire Arrows",               use = (EnergyBar2 >= 20) },
                { name = "Shot",                         use = (true) },
                           }
            end           
                  
            --ADD MORE CLASS COMBOS HERE. 
            --USE AN "ELSEIF" TO CONTINUE WITH MORE CLASS COMBOS.
            --THE NEXT "END" STATEMENT IS THE END OF THE CLASS COMBOS STATEMENTS.
            --DO NOT POST BELOW THE FOLLOWING "END" STATEMENT!
            end
    --End Player Skill Sequences
    
    if (arg1=="debugskills") then        --Used for printing the skill table, and true/false usability
        DIYCE_DebugSkills(Skill)
        DIYCE_DebugSkills(Skill2)
    elseif (arg1=="debugpbuffs") then    --Used for printing your buff names, and buffID
        DIYCE_DebugBuffList(pbuffs)
    elseif (arg1=="debugtbuffs") then    --Used for printing target buff names, and buffID
        DIYCE_DebugBuffList(tbuffs)
    elseif (arg1=="debugall") then        --Used for printing all of the above at the same time
        DIYCE_DebugSkills(Skill)
        DIYCE_DebugSkills(Skill2)
        DIYCE_DebugBuffList(pbuffs)
        DIYCE_DebugBuffList(tbuffs)
    end
    
    if (not MyCombat(Skill, arg1)) then
        MyCombat(Skill2, arg1)
    end
        
    --Select Next Enemy
    if (tDead) then
        TargetUnit("")
        return
    end
    if (mainClass == "RANGER" or subClass == "RANGER")  and (not party) then        --To keep scouts from pulling mobs without meaning to.
        if (not LockedOn) or (not enemy) then
            TargetNearestEnemy()
            return
        end
    elseif mainClass ~= "RANGER" then                    --Let all other classes auto target.
        if (not LockedOn) or (not enemy) then
            TargetNearestEnemy()
            return
        end
    end
end
DIYCE.lua

Source code

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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
-- DIY Combat Engine version 2.2

local g_skill  = {}
local g_lastaction = ""
-- Holds the created timers
local DIYCE_Timers = {}

function Msg(outstr,a1,a2,a3)
    DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr),a1,a2,a3)
end

function ReadSkills()
    g_skill = {}
    local skillname,slot

    for page = 1,4 do
        slot = 1
        skillname = GetSkillDetail(page,slot)
        repeat
            local a1,a2,a3,a4,a5,a6,a7,a8,skillusable = GetSkillDetail(page,slot)
            if skillusable then
                g_skill[skillname] = { ['page'] = page, ['slot'] = slot }
            end
            slot = slot + 1
            skillname = GetSkillDetail(page,slot)
        until skillname == nil
    end
end

-- Read Skills on Log-In/Class Change/Level-Up
        local DIYCE_EventFrame = CreateUIComponent("Frame","DIYCE_EventFrame","UIParent")
        DIYCE_EventFrame:SetScripts("OnUpdate", [=[ DIYCE_TimerUpdate(elapsedTime) ]=] )
            DIYCE_EventFrame:SetScripts("OnEvent", [=[ 
                    if event == 'PLAYER_SKILLED_CHANGED' then
                        ReadSkills()
                        end
                    ]=] )
            DIYCE_EventFrame:RegisterEvent("PLAYER_SKILLED_CHANGED")

function PctH(tgt)
    return (UnitHealth(tgt)/UnitMaxHealth(tgt))
end

function PctM(tgt)
    return (UnitMana(tgt)/UnitMaxMana(tgt))
end

function PctS(tgt)
    return (UnitSkill(tgt)/UnitMaxSkill(tgt))
end

function CancelBuff(buffname)
    local i = 1
    local buff = UnitBuff("player",i)

    while buff ~= nil do
        if buff == buffname then
            CancelPlayerBuff(i)
            return true
        end

        i = i + 1
        buff = UnitBuff("player",i)
    end
    return false
end

function BuffList(tgt)
    local list = {}
    local buffcmd = UnitBuff
    local infocmd = UnitBuffLeftTime

    if UnitCanAttack("player",tgt) then
        buffcmd = UnitDebuff
        infocmd = UnitDebuffLeftTime
    end

    -- There is a max of 100 buffs/debuffs per unit apparently
    for i = 1,100 do
        local buff, _, stackSize, ID = buffcmd(tgt, i)
        local timeRemaining = infocmd(tgt,i)
        if buff then
            -- Ad to list by name
            list[buff:gsub('(%()(.)(%))', '%2')] = { stack = stackSize, time = timeRemaining or 0, id = ID }
            -- We also list by ID in case two different buffs/debuffs have the same name.
            list[ID] = {stack = stackSize, time = timeRemaining or 0, name = buff:gsub("(%()(.)(%))", "%2") }
        else
            break
        end
    end

    return list
end

function CD(skillname)
    local firstskill = GetSkillDetail(2,1)
    if (g_skill[firstskill] == nil) or (g_skill[firstskill].page ~= 2) then
        ReadSkills()
    end

    if g_skill[skillname] ~= nil then
        local tt,cd = GetSkillCooldown(g_skill[skillname].page,g_skill[skillname].slot)
        return cd <= 0.4
    elseif skillname == nil then
        return false
    else
        Msg("Skill not available: "..skillname)        --Comment this line out if you do not wish to recieve this error message.
        return
    end
end

function MyCombat(Skill, arg1)
    local spell_name = UnitCastingTime("player")
    local talktome = ((arg1 == "v1") or (arg1 == "v2"))
    local action,actioncd,actiondef,actioncnt
    
    if spell_name ~= nil then
        if (arg1 == "v2") then Msg("- ['..spell_name..']", 0, 1, 1) end
        return true
    end

    for x,tbl in ipairs(Skill) do
        
    local useit = type(Skill[x].use) ~= "function" and Skill[x].use or (type(Skill[x].use) == "function" and Skill[x].use() or false)
        if useit then
            if string.find(Skill[x].name, "Action:") then
                action = tonumber((string.gsub(Skill[x].name, "(Action:)( *)(%d+)(.*)", "%3")))
                _1,actioncd = GetActionCooldown(action)
                actiondef,_1,actioncnt = GetActionInfo(action)
                if GetActionUsable(action) and (actioncd == 0) and (actiondef ~= nil) and (actioncnt > 0) then
                    if talktome then Msg("- "..Skill[x].name) end
                    UseAction(action)
                    return true
                end
            elseif string.find(Skill[x].name, "Custom:") then
                action = string.gsub(Skill[x].name, "(Custom:)( *)(.*)", "%3")
                if CustomAction(action) then
                    return true
                end
            elseif string.find(Skill[x].name, "Item:") then
                action = string.gsub(Skill[x].name, "(Item:)( *)(.*)", "%3")
                if talktome then Msg("- "..Skill[x].name) end
                UseItemByName(action)
                return true
            elseif (Skill[x].ignoretimer or GetDIYCETimerValue(Skill[x].timer) == 0) and CD(Skill[x].name) then
                if talktome then Msg("- "..Skill[x].name) end
                CastSpellByName(Skill[x].name)
                StartDIYCETimer(Skill[x].timer)
                return true
            elseif string.find(Skill[x].name, "Pet Skill:") then
                action = string.gsub(Skill[x].name, "(Pet Skill:)( *)(%d+)(.*)", "%3")
                    UsePetAction(action)
                if (arg1 == "v2") then Msg(Skill[x].name.." has been fully processed") end
                return true
            end
        end
    end
    if (arg1 == "v2") then Msg("- [IDLE]", 0, 1, 1) end
    
    return false
end

--[[ Timer Update function ]]--
-- Tick down any active timers
function DIYCE_TimerUpdate(elapsed)
    for k,v in pairs(DIYCE_Timers) do
        v.timeLeft = v.timeLeft - elapsed
        if v.timeLeft < 0 then
            v.timeLeft = 0
        end
    end
end

--[[ Create a named timer ]]--
-- if the named timer already exists, this does nothing.
function CreateDIYCETimer(timerName, waitTime)
    if not DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName] = { timeLeft = 0, waitTime = waitTime }
    end
end

--[[ Set/reset waitTimer of an existing timer ]]--
-- if the timer doesn't exist, this does nothing
function SetDIYCETimerDelay(timerName, waitTime)
    if DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName].waitTime = waitTime
    end
end

--[[ Delete named timer ]]--
-- if the timer doesn't exist, this does nothing
-- Not really needed, but added for completeness
function DeleteDIYCETimer(timerName)
    if DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName] = nil
    end
end

--[[ Get a timer's current time ]]--
-- if the timer doesn't exist, this returns 0
function GetDIYCETimerValue(timerName)
    if timerName then
        return DIYCE_Timers[timerName] and DIYCE_Timers[timerName].timeLeft or 0
    end
    return 0
end

--[[ Starts a timer ticking down ]]--
-- if timer doesn't exist, this does nothing
function StartDIYCETimer(timerName)
    if timerName and DIYCE_Timers[timerName] then
        DIYCE_Timers[timerName].timeLeft = DIYCE_Timers[timerName].waitTime
    end
end

function CustomAction(action)
    if CD(action) then
        if IsShiftKeyDown() then Msg("- "..action) end
        g_lastaction = action
        CastSpellByName(action)
        return true
    else
        return false
    end
end

function BuffTimeLeft(tgt, buffname)
    local cnt = 1
    local buff = UnitBuff(tgt,cnt)

    while buff ~= nil do
        if string.find(buff,buffname) then
            return UnitBuffLeftTime(tgt,cnt)
        end
        cnt = cnt + 1
        buff = UnitBuff(tgt,cnt)
    end

    return 0
end

function BuffParty(arg1,arg2)
--    arg1 = Quickbar slot # for targetable, instant-cast buff without a cooldown (eg. Amp Attack) for range checking.
--    arg2 = buff expiration time cutoff (in seconds) for refreshing buffs, default is 45 seconds.

    local selfbuffs = { "Soul Bond", "Enhanced Armor", "Holy Seal" }
    local groupbuffs = { "Grace of Life", "Amplified Attack", "Angel's Blessing", "Essence of Magic", "Magic Barrier", "Blessed Spring Water", "Fire Ward", "Savage Blessing", "Concentration Prayer", "Shadow Fury"  }

    local buffrefresh = arg2 or 45           -- Refresh buff time (seconds)
    local spell = UnitCastingTime("player")  -- Spell being cast?
    local vocal = IsShiftKeyDown()           -- Generate feedback if Shift key held

    if (spell ~= nil) then
        return
    end

    if vocal then Msg("- Checking self buffs on "..UnitName("player")) end
    for i,buff in ipairs(selfbuffs) do
        if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("player",buff) <= buffrefresh) then
            if vocal then Msg("- Casting "..buff.." on "..UnitName("player")) end
            TargetUnit("player")
            CastSpellByName(buff)
            return
        end
    end

    if vocal then Msg("- Checking group buffs on "..UnitName("player")) end
    for i,buff in ipairs(groupbuffs) do
        if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("player",buff) <= buffrefresh) then
            if vocal then Msg("- Casting "..buff.." on "..UnitName("player")) end
            TargetUnit("player")
            CastSpellByName(buff)
            return
        end
    end

    for num=1,GetNumPartyMembers()-1 do
        TargetUnit("party"..num)
        if GetActionUsable(arg1) and (UnitHealth("party"..num) > 0) then
            if vocal then Msg("- Checking group buffs on "..UnitName("party"..num)) end
            for i,buff in ipairs(groupbuffs) do
                if (g_skill[buff] ~= nil) and CD(buff) and (BuffTimeLeft("target",buff) <= buffrefresh) then
                    if UnitIsUnit("target","party"..num) then
                        if vocal then Msg("- Casting "..buff.." on "..UnitName("target")) end
                        CastSpellByName(buff)
                        return
                    else
                        if vocal then Msg("- Error: "..UnitName("target").." != "..UnitName("party"..num)) end
                    end
                end
            end
        else
            if vocal then Msg("- Player "..UnitName("party"..num).." out of range or dead.") end
        end
    end

    if vocal then Msg("- Nothing to do.") end
end
Thank you
~Trs

278

Saturday, December 10th 2011, 3:55pm

Quoted from "hangman04;492152"

Easier said than done! I dunno how to change bufflist function to add the counter or how to modify xari's function and to use also function IDs.


this might work better for you:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function ChkBuffCount(tgt,buffname,BuffID,buffcount)
    local cnt = 1
    local buffcmd = UnitBuff
    local buffcounter = 0

    if UnitCanAttack("player",tgt) then
        buffcmd = UnitDebuff
    end
    local buff, _, _, ID = buffcmd(tgt,cnt)

    while buff ~= nil do
        if string.gsub(buff, "(%()(.)(%))", "%2") == buffname
            or ID == BuffID then
            buffcounter = buffcounter + 1        
        end
        cnt = cnt + 1
        buff = buffcmd(tgt,cnt)
        
        if buffcounter >= buffcount then
            return true
        end
    end    
end
and

Source code

1
2
3
4
5
                if enemy then
                Skill2 = {                
                    { name = "Tactical Attack",   use = ((EnergyBar1 >= 15) and (ChkBuffCount("target",_,500018,2))) },
                        }                        
                end    

krssrb

Beginner

Posts: 20

Location: Serbia

  • Send private message

279

Sunday, December 11th 2011, 1:50am

Hello TheRedShore,

here is your problem,
you use probobly in game macro

Source code

1
/run KillSequence("","2")
that's only for arg1 and gota2, but you have in lua file arg1, gota2, healpot, manapot, foodslot

Source code

1
function KillSequence(arg1, goat2, healthpot, manapot, foodslot)
So, or change this line like this

Source code

1
function KillSequence(arg1, goat2)
and use your old macro, then you will not use pots and food buy diyce.

Or you can add numbers of slots where are your pots and food in diyce and in your ingame macro.
something like this

Source code

1
2
3
4
5
6
7
 if (goat2 == "0") then
            Skill =  {
                { name = "Combat Master",                      use = ((not pbuffs['Combat Master'])) },
                { name = "Action: 62 (Unbridled Enthusiam)",   use = ((not pbuffs['Unbridled Enthusiasm'])) }, -- Speed Potion number
                { name = "Action: 44"..healthpot,          use = (phealth <= .70) },
                { name = "Action: 45"..manapot,            use = (pctEB2 <= .40) },
                     }
and change your in game macro, something like this

Source code

1
/run KillSequence("","2","44","45","62)
I gues it will help you, it worked for me ;)
Warrior80/Mage80/Warlock80

ghostwolf82

Professional

  • "ghostwolf82" started this thread

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

280

Sunday, December 11th 2011, 3:25am

Quoted from "krssrb;492450"

Hello TheRedShore,

here is your problem,
you use probobly in game macro

Source code

1
/run KillSequence("","2")
that's only for arg1 and gota2, but you have in lua file arg1, gota2, healpot, manapot, foodslot

Source code

1
function KillSequence(arg1, goat2, healthpot, manapot, foodslot)
So, or change this line like this

Source code

1
function KillSequence(arg1, goat2)
and use your old macro, then you will not use pots and food buy diyce.

Haven't really been keeping tabs on this thread, but since I checked it out really fast, figured I would add this much... This is incorrect info. The DIYCE will determine based on the macro what arguments (args) to use, not the other way around. You can have as many args in the function as you want, but until they are called with the macro, they lie dormant and do nothing. As for what the problem is, I am not sure, as I am no longer working on any addons at all for this game. When their support was pulled, my support has been pulled too.