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.

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

1,741

Wednesday, September 7th 2011, 3:22am

Quoted from "neonsun;461373"

i m planning to dyice a auto poting dyice just for my phyrius pots.

anyone know if phyrius pots can be used by name , or do they need to be sloted to actionbas and used from there ( like set skills).

i play using a gaming mouse and i plan to put the auto poter on 1 of the keys .

the idea would be to have only 1 macro for poting on my action bars which will use the appropriate pot depending on the parameters i ahave set up .

ex : if Hp <80% and and MP<20% -->use xx or zzz
if only hp <70% use xxx

Anything special i need to know about this topic before i try coding for it ?

I use ntbuff add on for this. is very reliable.

1,742

Wednesday, September 7th 2011, 1:03pm

^Don't use ntbuff. It breaks/resets a lot of add-ons--and no, I am not the only one who has experienced this. It's incompatible with several widely-used ones.

Formerly Catorii, D/S/M of Faction.


hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

1,743

Wednesday, September 7th 2011, 1:05pm

Quoted from "effervescent;461855"

^Don't use ntbuff. It breaks/resets a lot of add-ons--and no, I am not the only one who has experienced this. It's incompatible with several widely-used ones.

like? i am curious :)

1,744

Friday, September 9th 2011, 6:40pm

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
function WarriorKnightAtk(arg1,arg2)
    local Skill = {}
    local i = 0
    local friendly = (not UnitCanAttack("player","target"))
    local tDead = UnitIsDeadOrGhost("target")
    local rage = UnitMana("player")
    local mana = UnitSkill("player")
    local health = PctH("player")
    local thealth = PctH("target")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")

    if (tDead) then
        TargetUnit("")
        return
    end

    i=i+1; Skill[i] = { name = "Enhanced Armor", use = (not pbuffs['Enhanced Armor']) }
    i=i+1; Skill[i] = { name = "Blocking Stance", use = (not pbuffs['Blocking Stance']) }
    i=i+1; Skill[i] = { name = "Item: Housekeeper Special Unimaginable Salad", use = ((not pbuffs['Unimaginable Salad']) and (GetCountInBagByName("Housekeeper Special Unimaginable Salad") ~= 0)) }

    i=i+1; Skill[i] = { name = "Berserk", use = ((not friendly) and (thealth > 0.75) and (rage >=30) and (not pbuffs['Berserk'])) }
    i=i+1; Skill[i] = { name = "Survival Instinct", use = (health < 0.50) }

    i=i+1; Skill[i] = { name = "Aggressiveness", use = ((not friendly) and (rage <= 20)) }
    i=i+1; Skill[i] = { name = "Enraged", use = ((not friendly) and (rage <= 30)) }

    --i=i+1; Skill[i] = { name = "Open Flank", use = ((not friendly) and (rage >= 10) and (tbuffs['Vulnerable'])) }
    --i=i+1; Skill[i] = { name = "Probing Attack", use = ((not friendly) and (rage >= 20) and (tbuffs[500081])) }

    i=i+1; Skill[i] = { name = "Tactical Attack", use = ((not friendly) and (rage >= 15) and (tbuffs[500081])) }
    i=i+1; Skill[i] = { name = "Action: 13 (Sword of Imprisonment)", use = ((not friendly) and (rage >= 20) and (tbuffs[500081])) }
    i=i+1; Skill[i] = { name = "Slash", use = ((not friendly) and (rage >= 25)) }
    i=i+1; Skill[i] = { name = "Disarmament", use = ((not friendly))}


    MyCombat(Skill,arg1)
end
I am trying to get the above to work, but it doesn't seem to be doing anything. I've gone through and checked all my parenthesis and apostrophe's, but nothing seems to be wrong.

Anyone able to help? :)

I'm also using Ghostwolf's DIYCE optimization as follows:

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
-- DIYCE Original Author: Sixpax
-- DIYCE: GhostWolf Modified version 1.0

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

    Msg("- DIYCE Reading Class Skills")
    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
ReadSkills() -- Read skills into g_skill table at login

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 = buffcmd(tgt, i)
        local timeRemaining = infocmd(tgt,i)
        if buff then
            list[buff:gsub('(%()(.)(%))', '%2')] = { stack = stackSize, time = timeRemaining }
        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)
        return false
    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
        if Skill[x].use 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
            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


What am I doing wrong?
-kiri

1,745

Friday, September 9th 2011, 9:29pm

Quoted from "anan1;462559"

What am I doing wrong?


As the very first line, add this:

Source code

1
Msg("Test")


If that doesn't print, then your entire code isn't loading at all, which means you need to check your windows Folder name, LUA file name, and TOC file name, and TOC file contents to be sure the LUA is in the TOC file.

1,746

Friday, September 9th 2011, 10:09pm

Quoted from "Zaodon;462603"

As the very first line, add this:

Source code

1
Msg("Test")
If that doesn't print, then your entire code isn't loading at all, which means you need to check your windows Folder name, LUA file name, and TOC file name, and TOC file contents to be sure the LUA is in the TOC file.


I have tried adding similar code yesterday at the beginning and ending of both the DIYCE/MyFunctions code. I&#8217;m pretty sure it is loading. (At least the code is printing 4x. two files, beginning/end. I have no idea if it is running correctly.)

The thing is, it is not cycling through any of my skills.
-kiri

1,747

Friday, September 9th 2011, 10:29pm

Quoted from "anan1;462616"

I have tried adding similar code yesterday at the beginning and ending of both the DIYCE/MyFunctions code. I’m pretty sure it is loading. (At least the code is printing 4x. two files, beginning/end. I have no idea if it is running correctly.)

The thing is, it is not cycling through any of my skills.


After each line of code, add:

Msg("1")
(line of code)
Msg("2")
(line of code)
Msg("3")
etc.

Wherever the # stops, thats your problem. :)

1,748

Saturday, September 10th 2011, 7:00am

When Being Feared......

Hello
As a Knight/Warrior I am able to get out of any situation of being feared by using the elite skill, "Fearless." Is there a certain callout such as, "If Feared" or something that would take note of a players debuff, that makes them run around like a chicken without a head, so it can be countered with this skill.
I'm looking for something that basically says, "If Feared: Use Fearless"
Thanks

:D
Server: Palenque
Character: Mrchucknorris
Class: K/S/W

1,749

Saturday, September 10th 2011, 11:27am

correct me if i m wrong hangman but ntbuffs automates drinking the pot ,right ?

i want to automate pot choice only

Also no one answered my CD(skill) question

what is the use of making a check on the skill ? with the same skill ( cf my post 10 post back )

Quoted from "neonsun;461366"

whats is the actual difference between :

Source code

1
   i=i+1; Skill[i] = { name = "Savage Whirlwind",            use = (not friendly) }
and

Source code

1
   i=i+1; Skill[i] = { name = "Savage Whirlwind",            use = ((not friendly) and CD("Savage Whirlwind"))
how will it change my code execution.
i got 0 programming knoweldge, but i thought that for a skill to be used it needed to have cool downed, and that dyice took care of it on its own .

i dont understand whats the gain of adding cd(skill) as a condition to use that same skill

please explain :P

PS : ty peryl will be making necessary changes and getting back to u in this thread or by pm

1,750

Saturday, September 10th 2011, 12:44pm

following peryl 's advice :P i reworked my code
this is my dyice now :

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

g_skill = {}

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

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

    Msg("- Reading Class Skills")
    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
ReadSkills() -- Read skills into g_skill table at login

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 BuffTimeLeft(tgt, buffname)
    local cnt = 1
    local buffcmd, bufftimecmd, buff

    if UnitCanAttack("player", tgt) then
        buffcmd = UnitDebuff
        bufftimecmd = UnitDebuffLeftTime
    else
        buffcmd = UnitBuff
        bufftimecmd = UnitBuffLeftTime
    end

    buff = buffcmd(tgt, cnt)

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

    return 0
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
    elseif skillname == nil then
        return false
    else
        Msg("Skill not available: "..skillname)
        return false
    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
        if Skill[x].use 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
            end
        end
    end
    if (arg1 == "v2") then Msg("- [IDLE]", 0, 1, 1) end

    return false
end
my new code :

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
function Wcomb(arg1)
   local Skill = {}
   local i = 0
   
   --vital signs
   local plife = PctH("player")
   local power = UnitMana("player")
   local pMana = PctS("player")
   local pbuff = BuffList("player")
   
   --mob status
   local friendly = (not UnitCanAttack("player","target"))
   local boss = (UnitSex("target")>2)
   local tbuff = BuffList("target")
  
   
   --Health monitor

     i=i+1; Skill[i] = { name = "Survival Instinct",    use = ((plife <= .40) and (boss)) }     
  
  
  --Rage monitor
  
  --Buffs
   i=i+1; Skill[i] = { name = "Battle Creed",      use = [B](not pbuff['Battle Creed'])[/B] }
   i=i+1; Skill[i] = { name = "Briar Shield",      use = [B](not pbuff['Briar Shield'][/B]) }
  

  --combat
   
   i=i+1; Skill[i] = { name = "Savage Whirlwind",            use = (not friendly) }
   i=i+1; Skill[i] = { name = "Tactical Attack",             use = (tbuff[500081] and (power >= 16)) }
   i=i+1; Skill[i] = { name = "Attack Weakener",             use = ((not friendly) and tbuff['Vulnerable'])   }
   i=i+1; Skill[i] = { name = "Open Flank",                  use = ((not friendly) and tbuff['Vulnerable'] and (power >=11))   }
   i=i+1; Skill[i] = { name = "Probing Attack",              use = ((not friendly) and (power >= 21) and tbuff[500081]) }  

   i=i+1; Skill[i] = { name = "Slash",                       use = ((not friendly) and (power >= 27)) }

   i=i+1; Skill[i] = { name = "Enraged",                     use = ((power < 25) and (boss)) }
   i=i+1; Skill[i] = { name = "Power of the Wood Spirit",    use = (not friendly) }

   MyCombat(Skill,arg1)
end
Problem now is nothing happens ! , no error messages nothing.
i usually check if my code is working by trying to self buff with briar shield ... at this point nothing works

any info would be most welcomed , what is this noob doing wrong ?

to note my old dyice and my function are working , dyice.toc file has the correct files it in , i took out the files edited them in another folder , and just exchanged the new codes for the old coded files.


>>>> EDIT : after a good night sleep and a 2nd look at the code , i found the mistake myself . correction is in bold in my dyice function.

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

1,751

Saturday, September 10th 2011, 2:06pm

Quoted from "neonsun;462728"

correct me if i m wrong hangman but ntbuffs automates drinking the pot ,right ?
i want to automate pot choice only


yes, ntbuff, if set correctly, can use the right pot(skill/buff) at the right moment. I use it from normal buffs to pots and also defensive buffs. The only limitations are regarding the percentage of hp or mp when the pot should be activated and the character condition: combat, alert, rest.

1,752

Sunday, September 11th 2011, 3:48am

Using Rage Skills

So I'm a Knight/Warrior putting together a PVP DIYCE.
I have it set up in a fashion that basically says, "Use Rage Skills if they are available, then use mana skills." Like:

i=i+1; Skill = { name = "Whirlwind", use = ((not friendly) and (rage >= 50)) }
i=i+1; Skill[i] = { name = "Whirlwind Shield", use = ((not friendly) and shield) }
i=i+1; Skill[i] = { name = "Slash", use = ((not friendly) and (rage >= 35)) }
i=i+1; Skill[i] = { name = "Holy Strike", use = (not friendly) }

however, when this runs, it just gives me the error, "Not Enough Rage" all the time instead of proceeding to the next skill (which uses mana) in order to build up the rage that i need. I want it to do the mana skills until I have enough rage to use the rage skills.
What happens is that nothing is executed and my character just stands in front of whatever it is that im trying to kill since the program is waiting for me to get sufficient rage.
Any comments on what i'm doing wrong?

Thanks:confused:
Server: Palenque
Character: Mrchucknorris
Class: K/S/W

1,753

Sunday, September 11th 2011, 9:43pm

Palabras acentuadas

How do I use Spanish words pronounced in the code?
I just do not accept the names of the attacks that have some emphasis on the name.

Sorry, Google Translator. :p:p:p

Thanks

hangman04

Savage Warrior

Posts: 113

Location: Romania

Mood: Smile

  • Send private message

1,754

Monday, September 12th 2011, 5:27pm

Quoted from "neonsun;462740"

following peryl 's advice :P i reworked my code
this is my dyice now :

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

g_skill = {}

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

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

    Msg("- Reading Class Skills")
    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
ReadSkills() -- Read skills into g_skill table at login

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 BuffTimeLeft(tgt, buffname)
    local cnt = 1
    local buffcmd, bufftimecmd, buff

    if UnitCanAttack("player", tgt) then
        buffcmd = UnitDebuff
        bufftimecmd = UnitDebuffLeftTime
    else
        buffcmd = UnitBuff
        bufftimecmd = UnitBuffLeftTime
    end

    buff = buffcmd(tgt, cnt)

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

    return 0
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
    elseif skillname == nil then
        return false
    else
        Msg("Skill not available: "..skillname)
        return false
    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
        if Skill[x].use 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
            end
        end
    end
    if (arg1 == "v2") then Msg("- [IDLE]", 0, 1, 1) end

    return false
end
my new code :

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
function Wcomb(arg1)
   local Skill = {}
   local i = 0
   
   --vital signs
   local plife = PctH("player")
   local power = UnitMana("player")
   local pMana = PctS("player")
   local pbuff = BuffList("player")
   
   --mob status
   local friendly = (not UnitCanAttack("player","target"))
   local boss = (UnitSex("target")>2)
   local tbuff = BuffList("target")
  
   
   --Health monitor

     i=i+1; Skill[i] = { name = "Survival Instinct",    use = ((plife <= .40) and (boss)) }     
  
  
  --Rage monitor
  
  --Buffs
   i=i+1; Skill[i] = { name = "Battle Creed",      use = [B](not pbuff['Battle Creed'])[/B] }
   i=i+1; Skill[i] = { name = "Briar Shield",      use = [B](not pbuff['Briar Shield'][/B]) }
  

  --combat
   
   i=i+1; Skill[i] = { name = "Savage Whirlwind",            use = (not friendly) }
   i=i+1; Skill[i] = { name = "Tactical Attack",             use = (tbuff[500081] and (power >= 16)) }
   i=i+1; Skill[i] = { name = "Attack Weakener",             use = ((not friendly) and tbuff['Vulnerable'])   }
   i=i+1; Skill[i] = { name = "Open Flank",                  use = ((not friendly) and tbuff['Vulnerable'] and (power >=11))   }
   i=i+1; Skill[i] = { name = "Probing Attack",              use = ((not friendly) and (power >= 21) and tbuff[500081]) }  

   i=i+1; Skill[i] = { name = "Slash",                       use = ((not friendly) and (power >= 27)) }

   i=i+1; Skill[i] = { name = "Enraged",                     use = ((power < 25) and (boss)) }
   i=i+1; Skill[i] = { name = "Power of the Wood Spirit",    use = (not friendly) }

   MyCombat(Skill,arg1)
end
Problem now is nothing happens ! , no error messages nothing.
i usually check if my code is working by trying to self buff with briar shield ... at this point nothing works

any info would be most welcomed , what is this noob doing wrong ?

to note my old dyice and my function are working , dyice.toc file has the correct files it in , i took out the files edited them in another folder , and just exchanged the new codes for the old coded files.


>>>> EDIT : after a good night sleep and a 2nd look at the code , i found the mistake myself . correction is in bold in my dyice function.


Are u sure : i=i+1; Skill = { name = "Tactical Attack", use = (tbuff[500081] and (power >= 16)) } works?

For me it doesn't, but it does in this form tbuff['Bleed']

1,755

Tuesday, September 13th 2011, 11:02pm

Diyce broke last night halfway through seige

[LEFT]Now i get a
[string'?']:237: attempt to perform arithmetic on global 'g_cnt' (a nil value)


i did not change anything. any ideas before replaceing it all [/LEFT]

ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1,756

Monday, September 19th 2011, 10:58pm

Quoted from "almut;463023"

How do I use Spanish words pronounced in the code?
I just do not accept the names of the attacks that have some emphasis on the name.

Sorry, Google Translator. :p:p:p

Thanks


On my phone right now so maybe someone else can find what I reference here, but sixpax worked on translating diyce to use other languages. Actually I think it was the party healer code, but thats based on diyce originally.

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

1,757

Tuesday, September 20th 2011, 8:11pm

Any potential fixes/suggestions/improvements/optimisations would be greatly appreciated.

I wanted to add throat attack to work so it would cancel only specific skills.

I do Shadow Prison on many different conditions, I do not want to leave it up to the macro. Unless I could integrate how long it was since my last energy increase in combat, I doubt I will add shadow prison to my DIYCE macro.

The if else isn't working properly, so any help on fixing it so it can detect rangedvsmelee.

Also, would it be possible to add a potion cd check?

And Thank 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function RogueScout(arg1)
    local Skill = {}
    local i = 0
    
    --Player Status
    local energy = UnitMana("player")
    local mana = UnitSkill("player")
    local focus = UnitSkill("player")
    local phealth = PctH("player")
    local pbuffs = BuffList("player")
    local combat = GetPlayerCombatState()
    local behind = (not UnitIsUnit("player", "targettarget"))
    local premed = (pbuffs == string.find(pbuffs, "Premeditation"))
    local melee = GetActionUsable(10)
    
    --Target Status
    local friendly = (not UnitCanAttack("player", "target"))
    local tspell,ttime,telapsed = UnitCastingTime("target")
    local tbuffs = BuffList("target")
    local boss = ((UnitSex("target"))>=2) 

    --Buffs & Potions
    i=i+1; Skill[i] = { name = "Action: 41", use = (phealth < .03 and (boss)) } -- Swap Macro
    i=i+1; Skill[i] = { name = "Action: 42", use = (phealth < .25 and (boss)) } -- Phirius Potion
    i=i+1; Skill[i] = { name = "Action: 45", use = (energy < 15 and (boss)) } -- Energy Potion
    i=i+1; Skill[i] = { name = "Combat Master", use = ((not combat and not string.find(pbuffs, "Combat Master"))) }
    i=i+1; Skill[i] = { name = "Action: 62", use = ((not combat and not string.find(pbuffs, "Yawaka's Blessing"))) }
    i=i+1; Skill[i] = { name = "Poison", use = ((not combat and not string.find(pbuffs, "Poisonous")))  }
    i=i+1; Skill[i] = { name = "Action: 69", use = ((not combat and not string.find(pbuffs, "Unbridled Enthusiasm")))  } -- Speed Potion
    
    if(melee) then --At Melee
    i=i+1; Skill[i] = { name = "Wound Attack", use = ((not friendly) and (energy >= 35) and string.find(tbuffs, "Bleed") and string.find(tbuffs, "Grievous Wound")) }
    i=i+1; Skill[i] = { name = "Low Blow", use = ((not friendly) and (energy >= 25) and string.find(tbuffs, "Bleed") and not string.find(tbuffs, "Grievous Wound")) }
    i=i+1; Skill[i] = { name = "Shadowstab", use = ((not friendly) and (energy >= 20) and not string.find(tbuffs, "Bleed")) }
    i=i+1; Skill[i] = { name = "Blind Spot", use = ((not friendly) and (string.find(pbuffs, "Energy Thief") or (premed)) and (behind)) }
    i=i+1; Skill[i] = { name = "Wrist Attack", use = ((not friendly) and (boss) and (focus >=50)) }
    i=i+1; Skill[i] = { name = "Vampire Arrows", use = ((not friendly) and not string.find(tbuffs, "Vampire Arrows")) }
    i=i+1; Skill[i] = { name = "Shot", use = (not friendly) }
    else -- At Ranged
    i=i+1; Skill[i] = { name = "Vampire Arrows", use = ((not friendly) and not string.find(tbuffs, "Vampire Arrows")) }
    i=i+1; Skill[i] = { name = "Shot", use = (not friendly) }
    end
    
    MyCombat(Skill,arg1)
end

Deltaninethc

Intermediate

Posts: 199

Location: Sin City

  • Send private message

1,758

Wednesday, September 21st 2011, 9:22am

Quoted from "mrmisterwaa;465608"

Any potential fixes/suggestions/improvements/optimisations would be greatly appreciated.

I wanted to add throat attack to work so it would cancel only specific skills.

I do Shadow Prison on many different conditions, I do not want to leave it up to the macro. Unless I could integrate how long it was since my last energy increase in combat, I doubt I will add shadow prison to my DIYCE macro.

The if else isn't working properly, so any help on fixing it so it can detect rangedvsmelee.

Also, would it be possible to add a potion cd check?

And Thank 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function RogueScout(arg1)
    local Skill = {}
    local i = 0
    
    --Player Status
    local energy = UnitMana("player")
    local mana = UnitSkill("player")
    local focus = UnitSkill("player")
    local phealth = PctH("player")
    local pbuffs = BuffList("player")
    local combat = GetPlayerCombatState()
    local behind = (not UnitIsUnit("player", "targettarget"))
    local premed = (pbuffs == string.find(pbuffs, "Premeditation"))
    local melee = GetActionUsable(10)
    
    --Target Status
    local friendly = (not UnitCanAttack("player", "target"))
    local tspell,ttime,telapsed = UnitCastingTime("target")
    local tbuffs = BuffList("target")
    local boss = ((UnitSex("target"))>=2) 

    --Buffs & Potions
    i=i+1; Skill[i] = { name = "Action: 41", use = (phealth < .03 and (boss)) } -- Swap Macro
    i=i+1; Skill[i] = { name = "Action: 42", use = (phealth < .25 and (boss)) } -- Phirius Potion
    i=i+1; Skill[i] = { name = "Action: 45", use = (energy < 15 and (boss)) } -- Energy Potion
    i=i+1; Skill[i] = { name = "Combat Master", use = ((not combat and not string.find(pbuffs, "Combat Master"))) }
    i=i+1; Skill[i] = { name = "Action: 62", use = ((not combat and not string.find(pbuffs, "Yawaka's Blessing"))) }
    i=i+1; Skill[i] = { name = "Poison", use = ((not combat and not string.find(pbuffs, "Poisonous")))  }
    i=i+1; Skill[i] = { name = "Action: 69", use = ((not combat and not string.find(pbuffs, "Unbridled Enthusiasm")))  } -- Speed Potion
    
    if(melee) then --At Melee
    i=i+1; Skill[i] = { name = "Wound Attack", use = ((not friendly) and (energy >= 35) and string.find(tbuffs, "Bleed") and string.find(tbuffs, "Grievous Wound")) }
    i=i+1; Skill[i] = { name = "Low Blow", use = ((not friendly) and (energy >= 25) and string.find(tbuffs, "Bleed") and not string.find(tbuffs, "Grievous Wound")) }
    i=i+1; Skill[i] = { name = "Shadowstab", use = ((not friendly) and (energy >= 20) and not string.find(tbuffs, "Bleed")) }
    i=i+1; Skill[i] = { name = "Blind Spot", use = ((not friendly) and (string.find(pbuffs, "Energy Thief") or (premed)) and (behind)) }
    i=i+1; Skill[i] = { name = "Wrist Attack", use = ((not friendly) and (boss) and (focus >=50)) }
    i=i+1; Skill[i] = { name = "Vampire Arrows", use = ((not friendly) and not string.find(tbuffs, "Vampire Arrows")) }
    i=i+1; Skill[i] = { name = "Shot", use = (not friendly) }
    else -- At Ranged
    i=i+1; Skill[i] = { name = "Vampire Arrows", use = ((not friendly) and not string.find(tbuffs, "Vampire Arrows")) }
    i=i+1; Skill[i] = { name = "Shot", use = (not friendly) }
    end
    
    MyCombat(Skill,arg1)
end


I found this in this very same thread:

Quoted from "Sixpax;237562"

Definitely. What I would suggest if you want to specify which spells to interrupt is defining a list of them as a string (using a delimiter like "/") and then checking the spell being cast against that.

So in your class function you'd have:

Source code

1
2
3
4
   local interrupt_list = "/Fireball/Thunderstorm/Spell of Doom/"
   local tspell,ttime,telapsed = UnitCastingTime("target")

   i=i+1; Skill[i] = { ['name'] = "Throat Attack",  ['use'] = ((not friendly) and string.find(interrupt_list,tspell)) }
Deltaninethc- 67/62/67 S/Wd/R(Osha)
Spokendeath- 72/62 M/P(Osha)

mrmisterwaa

Professional

Posts: 670

Location: Kuwait

  • Send private message

1,759

Wednesday, September 21st 2011, 5:46pm

Quoted from "Deltaninethc;465847"

I found this in this very same thread:


It's kind of difficult to search this entire thread, I put throat into search in thread and I look at the first page and couldn't find anything.

I saw someone post something about potion cooldowns on the EU server but it wasn't close to complete. :\

Deltaninethc

Intermediate

Posts: 199

Location: Sin City

  • Send private message

1,760

Wednesday, September 21st 2011, 6:06pm

Quoted from "mrmisterwaa;465924"

It's kind of difficult to search this entire thread, I put throat into search in thread and I look at the first page and couldn't find anything.

I saw someone post something about potion cooldowns on the EU server but it wasn't close to complete. :\


"Interrupt" would have been a more apt term to search for.
Deltaninethc- 67/62/67 S/Wd/R(Osha)
Spokendeath- 72/62 M/P(Osha)