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.

201

Tuesday, November 22nd 2011, 9:54am

Quoted from "Peryl;485040"

I've seen this asked before and unfortunately, I've yet to hear of a way to detect Decay's 20 sec block on casting (for the curious, we are talking about this Rogue skill: Decay)

There doesn't appear to be anything we can query to find out when this hidden 20 sec cooldown is active or done.

The only thing I can think of would be to create a timer that would trigger when the skill is used and disallow the use in DIYCE if the timer is active. But this could A) cause some possible problems with accuracy and B) since it would be simulated, may cause other problems. There's also the question of integrating such a thing into DIYCE itself.



*maybe* if we can actually setup skill cooldown for Decay for 32sec then timer wont be needed. The way diyce work by populating skill's info into a table by ReadSkill() might be the trick, what *if* we can override it with new skill's cd.

Just an idea :)

Meh, i look through how function CD work & dont think my way will succeed unless some1 rewrite diyce o.0

ghostwolf82

Professional

  • "ghostwolf82" started this thread

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

202

Tuesday, November 22nd 2011, 3:11pm

The problem with your idea karol891 is that the CD function checks if a skill is on cooldown or not. With Decay (and a few other skills) you can cast it once every 12 seconds, but the "extra effect" can only be triggered once every 20 secs, which has no timer built into it that we can grab from this side of the code. Thus why Peryl suggested building a timer to do this portion.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

203

Tuesday, November 22nd 2011, 5:07pm

Here's my proposed changes/additions to add the timer goo to DIYCE 2.0.

Please note that I haven't actually tested this, nor even added it to an actual Lua file. Just typed it up and posting it as is so errors may be present.

(All modifications are to be done to DIYCE.lua)

At the top of DIYCE.lua, add:

Source code

1
2
-- Holds the created timers
local DIYCE_Timers = {}


After the creation of the DIYCE_EventFrame, add:

Source code

1
DIYCE_EventFrame:SetScripts("OnUpdate", [=[ DIYCE_TimerUpdate(elapsedTime) ]=] )


Modification needed to MyCombat. The elseif CD(Skill[x].name) then section becomes:

Source code

1
2
3
4
5
6
    elseif 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
    end


Now add the following functions to 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
--[[ 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


Example Usage of above
For skills that need this extra timer, you must first create the time itself in KillSequence(), giving it a name like this (using Decay as an example here)

Source code

1
    CreateDIYCETimer("MyDecayTimer", 32)


Now in the skill list, you now can add an extra entry called timer and specify the name of the timer created above (this example merely uses true for the use case, but you would want what the condition you normally desire)

Source code

1
    { name = "Decay", use = true, timer = "MyDecayTimer" }
2013... The year from hell....

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

204

Tuesday, November 22nd 2011, 5:47pm

So Peryl in this case, it could be used for Skills like Shadowstab, Low Blow to manage their bleeds?

205

Tuesday, November 22nd 2011, 5:55pm

i tested peryl's DIYCE_timer ingame, its works like charm .Only 1 problem i noticed is when you are far from mobs/boss & skill out of range, diyce use that skill & timer start :D but range check should solve it

@Sekritsquirrel, i think the answer is yes

ghostwolf82

Professional

  • "ghostwolf82" started this thread

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

206

Tuesday, November 22nd 2011, 5:57pm

Quoted from "mrmisterwaa;485179"

So Peryl in this case, it could be used for Skills like Shadowstab, Low Blow to manage their bleeds?

Provided the timer functions work as posted, yes. I'm interested to check it to see if it works! (For reasons of an addon I was looking to make about a year ago. Six and myself couldn't get a timer working back then, and until now I had forgotten about it.)

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

207

Tuesday, November 22nd 2011, 6:00pm

Quoted from "mrmisterwaa;485179"

So Peryl in this case, it could be used for Skills like Shadowstab, Low Blow to manage their bleeds?


Possibly. As written and shown above, the timer can be used to block use of a skill (that's what the modification to MyCombat() is all about, well that and starting the timer on skill use). But the timers themselves are actually generic and independent of MyCombat(). If you never set the timer = "sometimename" part of the skill entry, MyCombat() will know nothing about the timer itself.

You can use a timer manually by creating a named timer (this does not start the timer, just creates it)

Source code

1
CreateDIYCETimer([i]unique timer name[/i], [i]time in seconds for this timer[/i])

You start it with

Source code

1
StartDIYCETimer([i]timer name[/i])

The above will start the timer with the amount of time specified when created (use SetDIYCETimerDelay(name,time) to change this value).

You can check the current amount of time on the timer with

Source code

1
curtime = GetDIYCETimerValue([i]timer name[/i])

if the value returned is 0, then the time is up (or the timer never existed in the first place).
2013... The year from hell....

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

208

Tuesday, November 22nd 2011, 7:57pm

So my DIYCE should look like this:

(Got no errors so far, hope I am most likely doing it right.)

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
-- DIY Combat Engine version 2.2

local g_skill  = {}
local g_lastaction = ""
-- Holds the created timers
[B]local DIYCE_Timers = {}[/B]

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
[B]            elseif 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[/B]
            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

[B]--[[ 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 ]]--[/B] [B]
-- 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 ]]--[/B] [B]
-- 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 ]]--[/B] [B]
-- 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[/B]

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
So Peryl, in this case, if I were to set Shadowstab to be cast only every 7 seconds.

It would look like this:

Source code

1
2
3
CreateDIYCETimer(SSBleed, 7)
StartDIYCETimer(SSBleed)
    { name = "Shadowstab",                         use = ((EnergyBar1 >= 20) and timer = "SSBleed") },


Where would I put each one though? At the start of CustomFunctions?

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

209

Tuesday, November 22nd 2011, 11:27pm

See Ghost! It was right to post here :D gave some food for thought :P

So practically this timer is a fake countdown?

210

Wednesday, November 23rd 2011, 1:49am

Mage/Druid Diyce script

Im a Mage/Druid and i would like to request a working Mage/Druid and Druid/Mage script for diyce.
I tried to implement a Mage/Druid script that i found in otehr thread but didnt work.

ghostwolf82

Professional

  • "ghostwolf82" started this thread

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

211

Wednesday, November 23rd 2011, 1:59am

@pedrotor - Please show what work you have done and why it is not working for you. No one is going to do the work for you, sorry to have to burst that bubble.

@hangman04 - The question about the decay with a timer was a good one, the rest of what I said was just to clarify to keep DIYCE v1 and DIYCE v2 codes to the proper thread. As to not confuse anyone who may read them in the future.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

212

Wednesday, November 23rd 2011, 4:51am

Quoted from "mrmisterwaa;485230"

So my DIYCE should look like this:

(Got no errors so far, hope I am most likely doing it right.)

...snipped code... (BTW, bold text doesn't work in code tags, but italics do)

Source code

1
2
3
CreateDIYCETimer(SSBleed, 7)
StartDIYCETimer(SSBleed)
    { name = "Shadowstab",                         use = ((EnergyBar1 >= 20) and timer = "SSBleed") },


Where would I put each one though? At the start of CustomFunctions?


Sorry for the late reply, just got back from work.

The timers, in this context, should be considered as fake skill cooldowns. If there is a timer associated with an entry in the DIYCE skill list, both the normal skill cooldown and the timer must have expired before DIYCE will use the skill. The timer will not periodically restart the skill or cast it after a delay, merely act as an extra cooldown.

Edit
Oh and you don't need to start the timer when associated with a DIYCE skill entry like that since using the skill will start the timer.

As well you add the timer to the skill like this:

Source code

1
{ name = "Shadowstab",          use = ((EnergyBar1 >= 20),       timer = "SSBleed") },
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

213

Wednesday, November 23rd 2011, 5:01am

Quoted from "hangman04;485334"

So practically this timer is a fake countdown?

Exactly. The modification to MyCombat() checks to see if the timer is 0 and the skill is not on cooldown. So the timer acts as an extra, fake cooldown.

However, the timer code is generic and can be used outside of DIYCE itself.
2013... The year from hell....

eguner

Beginner

Posts: 15

Location: Türkiye

  • Send private message

214

Wednesday, November 23rd 2011, 8:13am

Quoted from "ghostwolf82;484278"

Is action 31 a macro? If so then you are trying to call a macro from a macro which doesn't work in game, and hasn't for a long time now.

Also, thanks Sekrit. Can someone else confirm/contradict those numbers from another server?


i've lately noticed that the debuff number was wrong and i've corrected it (501463-> fear , 503390-> snake poison) but still not working. how can i call an emote in diyce?

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

215

Wednesday, November 23rd 2011, 10:34am

So Peryl, every time I cast a skill, the fake cd start by default, if i have one associated with it?

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

216

Wednesday, November 23rd 2011, 11:20am

Quoted from "hangman04;485450"

So Peryl, every time I cast a skill, the fake cd start by default, if i have one associated with it?


Yup!

The key is the small modification to MyCombat() in DIYCE.lua. Specifically:

Source code

1
2
3
4
5
6
    elseif [i]GetDIYCETimerValue(Skill[x].timer) == 0 and[/i] CD(Skill[x].name) then
        if talktome then Msg("- "..Skill[x].name) end
        CastSpellByName(Skill[x].name)
        [i]StartDIYCETimer(Skill[x].timer)[/i]
        return true
    end

My changes are highlighted in italics. The first just gets the time remaining on the timer which must be zero, this check is logically and'ed with the result of the call to CD which checks if the skill is on cooldown or not. The result of all this dictates if DIYCE will proceed.

The second change is what starts the timer if DIYCE tries to use the skill.

The timer functions I added were purposely designed so that if no timer was created/exists for a skill entry (as would be the case for most skill entries), then it considers the "timer" to be 0. This will make DIYCE act as it did prior to the modifications which was what I was going for.
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

217

Wednesday, November 23rd 2011, 12:24pm

Quoted from "eguner;485437"

i've lately noticed that the debuff number was wrong and i've corrected it (501463-> fear , 503390-> snake poison) but still not working. how can i call an emote in diyce?


If I understand what you are trying to do, all you want is to trigger an emote if certain buff/debuff is on you.

As it stands, DIYCE doesn't have a way to call a generic Lua function instead of a skill (@ghost, do you want this? wouldn't be hard to implement). But for your use there is a way to fake it but requires a bit of finessing with the use clause by using a function here instead. The "skill" name itself will actually be redundant since it will never be used (on purpose).

Source code

1
2
3
4
5
6
7
8
9
{ name = "don't care",   use = function () 
                                       if (pbuffs['Confusion'] or pbuffs[501463]) then
                                           local EmoteID = g_EmoteCmdTable['ROFL']
                                           if EmoteID then
                                               DoEmote(EmoteID)
                                           end
                                       end
                                       return false
                                    end  }


The emote name given in the g_EmoteCmdTable must always be in uppercase, and the call to DoEmote must always have a valid emote ID or bad things can happen (as in booting you off the server, crashing, etc)
2013... The year from hell....

218

Wednesday, November 23rd 2011, 1:44pm

R/S substitute

For fellow R/S out there, this may interest you :D

Source code

1
2
3
4
5
6
7
local subList = {
        ['Sharp Slash'] = true, -- 1st Boss DOD
        ['Conjure Energy'] = true, -- 4th boss GC HM AOE
        ['Cat Claw Whirlwind'] = true,  --1st boss RT AOE
        ['Cat Claw Attack'] = true, --1st boss RT AOE
        ['Void Fire'] = true, --2nd boss RT AOE
                        }

Source code

1
    local subThis = tSpell and subList[tSpell] and ((tTime - tElapsed) > 0.1)

Source code

1
{ name = "Substitute",                    use = subThis and (EnergyBar2 >= 30) },
I wanted to make cancelbuff work like this too because it easier to maintance but dont how to do it :p
like this

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
local cancelbuff ={
        ['Blood Arrow'] = true,
        ['Archer's Glory'] = true,
        ['Target Area'] = true,
        ['Detection'] = true,
        ['Regenerate'] = true,
        ['Angel's Blessing'] = true,
        ['Shadow Fury'] = true,
        ['Blessed Spring Water'] = true,
        ['Fire Ward'] = true,
        ['Embrace of the Water Spirit'] = true,
        ['Curing Shot'] = true,
        ['Cure'] = true,
        ['Healing Arrows'] = true,
            }

eguner

Beginner

Posts: 15

Location: Türkiye

  • Send private message

219

Wednesday, November 23rd 2011, 3:39pm

Quoted from "Peryl;485459"

If I understand what you are trying to do, all you want is to trigger an emote if certain buff/debuff is on you.

...

The emote name given in the g_EmoteCmdTable must always be in uppercase, and the call to DoEmote must always have a valid emote ID or bad things can happen (as in booting you off the server, crashing, etc)


thanks @Peryl , you got what i need , i've tried like below in my customfunctions.lua , seems like working because no error mesages yet but when i got fear or confusion debuff on me nothing happens, running around not rolling on the floor .....

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
-- Class: Scout/Rogue
			if mainClass == "RANGER" and subClass == "THIEF" then
			
			--Potions and Buffs
            Skill = {
                { name = "Frost Arrow",              	    use = ((not pbuffs['Frost Arrow']) or (pbuffs['Frost Arrow'].time <= 15)) },
				{ name = "Sapping Arrow",            	    use = boss and (not tbuffs['Sapping Arrow'] and (EnergyBar2 >= 45))  },
				
				{ name = "don't care",   use = function () 
                                       if (pbuffs['Confusion'] or pbuffs[501463]) then
                                           local EmoteID = g_EmoteCmdTable['ROFL']
                                           if EmoteID then
                                               DoEmote(EmoteID)
                                           end
                                       end
                                       return false
                                    end  }
				
					 }
			
			--Combat
			if enemy then
				Skill2 = {
				{ name = "Throat Attack",               use = ((EnergyBar2 >= 50) and (boss or elite) and (silenceThis)) },
				{ name = "Shot", 						use = (CD("Shot")) },
				{ name = "Autoshot", 					use = (not ASon) },
			 	{ name = "Combo Shot",                  use = (tbuffs[503169] and CD("Combo Shot"))  },
				{ name = "Weak Spot",					use = ((CD("Weak Spot") and (not pbuffs['Informer'])) and (EnergyBar1 >= 55)) },
				{ name = "Wind Arrows", 				use = (CD("Wind Arrows") and (EnergyBar1 >= 45)) },
				{ name = "Piercing Arrow",           	use = boss and ((EnergyBar1 <= 45) and CD("Piercing Arrow"))  }
				
			 	}
			end

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

220

Wednesday, November 23rd 2011, 3:53pm

I don't think is right as I think EmoteID = an actual ID # for the Emote.

You just put ROFL.

@Peryl

This is what I got so far:

I created the fake cooldown timers for Shadowstab & Low Blow, set their times.

Then I put conditions for Shadowstab to activate every 7 seconds.

I am a bit confused on how to make it so the timer for Low Blow should work?

This is what it was before.

It works on DIYCE properly.

Only problem is the Energy Thief issue, I want it to either do it every 9 seconds or if Energy Thief is up. (I tried putting tbuffs energy thief with the timer but it keeps giving me an error whenever the client loads and says like } is expected at , or ) is expected when I put a bracket.)

Source code

1
                { name = "Low Blow",                           use = ((EnergyBar1 >= 25) and (tbuffs[500654]) and ((not tbuffs[500704]) or (pbuffs['Energy Thief']))) },


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
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(13) -- # 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 <= .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: Rogue/Scout
            if mainClass == "THIEF" and subClass == "RANGER" then
            --Timers for this class
            CreateDIYCETimer("SSBleed", 7)
            CreateDIYCETimer("LBBleed", 9)
            --goat2: 0 = Buffs, 1 = Melee, 2 = Ranged, 3 = Cooldowns & Potions, 4 = Longer Cooldowns
            
            if (goat2 == "0") then
            Skill =  {
                { name = "Combat Master",                      use = ((not pbuffs['Combat Master'])) },
                { name = "Action: 62 (Yawaka's Blessing)",     use = ((not pbuffs['Yawaka's Blessing'])) },
                { name = "Action: 69 (Unbridled Enthusiam)",   use = ((not pbuffs['Unbridled Enthusiasm'])) }, -- Speed Potion
                     }
            elseif (goat2 == "3") then
            Skill =  {
               { name = "Informer",                            use = ((not pbuffs['Informer'])) },
               { name = "Action: 64 (Unknown Choice)",         use = ((EnergyBar1 > 20)) },
               { name = "Action: 65 (Caviar Sandwich)",        use = ((not pbuffs['Caviar Sandwich'])) },
                     }
            elseif (goat2 == "4") then
            Skill = {
                { name = "Action: 46 (Energy Potion)",         use = ((EnergyBar1) <= 15 and (boss)) },
                { name = "Action: 30 (Strong Stimulant)",      use = ((boss) and (not pbuffs['Fervent Attack'])) },
                { name = "Action: 34 (Extinction Potion)",     use = ((boss) and (not pbuffs['Extinction Potion'])) },
                { name = "Energy Thief",                       use = ((EnergyBar1 < 50) and (boss) and (not tDead)) },
                { name = "Assassins Rage",                     use = ((boss) and (not tDead)) },
                { name = "Fervent Attack",                     use = ((boss) and (not tDead) and (not pbuffs['Strong Stimulant'])) },
                    }
            end

            if ((enemy) and (goat2 == "1")) then
            Skill2 = {
                { name = "Wound Attack",                       use = ((EnergyBar1 >= 35) and ((tbuffs[500654]) and (tbuffs[500704]))) },
                { name = "Blind Spot",                         use = (((EnergyBar1 >= 25) and (boss) and (behind)) and (pbuffs['Energy Thief'] or pbuffs['Premeditation'])) },
                { name = "Shadowstab",                         use = (EnergyBar1 >= 20),       timer = "SSBleed" },
                { name = "Low Blow",                           use = ((EnergyBar1 >= 25) and (tbuffs[500654])),      timer = "LBBleed" },
                { name = "Throat Attack",                      use = ((EnergyBar2 >= 50) and (boss or elite) and (silenceThis)) },
                { name = "Vampire Arrows",                     use = (EnergyBar2 >= 20) },
                { name = "Wrist Attack",                       use = ((EnergyBar2 >= 50) and (boss)) },
                { name = "Shot",                               use = ((EnergyBar1 < 20 )) },
                    }
            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