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.

741

Thursday, June 24th 2010, 4:25pm

Quoted from "DawwtheElf;294576"

Sorry if I was unclear. I edited my post twice becouse of the chages that occured when trying things around. I got it working now. The Blood Arrow got turned off at once because of the

Source code

1
(not combat)


That tells me that you aren't defining what "combat" is. You should want Blood Arrow to turn off when you drop out of combat.

Make sure this line is up at the top of your function:

Source code

1
    local combat = GetPlayerCombatState()


Then the previous syntax should work properly.

742

Thursday, June 24th 2010, 6:25pm

Got it, thx!

743

Thursday, June 24th 2010, 6:30pm

Quoted from "Sixpax;294561"

If I understand you correctly, you're asking to have a particular skill run to the target and attack when click-to-move is disabled? I've had others request this and I briefly looked at the UFACS code to try to figure out how it's accomplishing this, but have yet to figure it out. I'm sure it's possible, but I have no idea how to code it.


I think it just uses the basic attack function to cause that behavior and in all my testing (several months ago now, the last dev may have made it work better) I couldn't get either the auto-approach or auto-looting to work without click-to-move enabled.

744

Thursday, June 24th 2010, 8:08pm

Quoted from "delve;294620"

I think it just uses the basic attack function to cause that behavior and in all my testing (several months ago now, the last dev may have made it work better) I couldn't get either the auto-approach or auto-looting to work without click-to-move enabled.


From what I'm told, UFACS would make you run up to the mob even if click-to-move is disabled. I never used that addon myself so I have no idea if that's correct.

745

Friday, June 25th 2010, 8:47am

Could someone please take a look at:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function RogueScout(arg1)
 local i=0
 local Skill={}
 local energy=UnitMana("player")
 local focus=UnitSkill("player")
 local tbuffs=BuffList("target")
 if ((UnitCanAttack("player","target")) and (PctH("target")>0))
  i=i+1;Skill[i]={name="Action:23(WA)",  use=((string.find(tbuffs,"Grievous Wound")) and (string.find(tbuffs,"Bleed")))}
  i=i+1;Skill[i]={name="Action:22(LB)",  use=((string.find(tbuffs,"Bleed")) and (not string.find(tbuffs,"Grievous Wound")))}
  i=i+1;Skill[i]={name="Action:21(SS)",  use=((energy>50) and ((BuffTimeLeft("target","Bleed")<3))}
  i=i+1;Skill[i]={name="Action:25(Shot)",use=true}
  i=i+1;Skill[i]={name="Action:26(Vamp)",use=(not string.find(tbuffs,"Vampire Arrows"))}
  i=i+1;Skill[i]={name="Action:30(Atk)", use=true}
 end
 MyCombat(Skill,arg1)
end


It was working well yesterday but today I'm getting:

Source code

1
[string 'RogueScout()']:1: attempt to call global 'RogueScout' (a nil value)


Regards

mrmarc0001

Beginner

Posts: 3

Location: SF Bay Area

Occupation: Web Producer @ UCSF

  • Send private message

746

Friday, June 25th 2010, 11:05am

Quoted from "blurterblurter;294964"

Could someone please take a look at:

Source code

1
<snip>


You're missing a "then" after the condition in your "if..." statement.

It should be like

Source code

1
2
3
If (condition) then
...
end

747

Friday, June 25th 2010, 11:46am

yea just saw that, still getting the same error with this:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function RogueScout(arg1)
 local i=0
 local Skill={}
 local energy=UnitMana("player")
 local tbuffs=BuffList("target")
 if ((UnitCanAttack("player","target")) and (PctH("target")>0)) then
  i=i+1;Skill[i]={name="Action:23(WA)",  use=((string.find(tbuffs,"Grievous Wound")) and (string.find(tbuffs,"Bleed")))}
  i=i+1;Skill[i]={name="Action:22(LB)",  use=((string.find(tbuffs,"Bleed")) and (not string.find(tbuffs,"Grievous Wound")))}
  i=i+1;Skill[i]={name="Action:21(SS)",  use=((energy>50) and ((BuffTimeLeft("target","Bleed")<3))}
  i=i+1;Skill[i]={name="Action:25(Shot)",use=true}
  i=i+1;Skill[i]={name="Action:26(Vamp)",use=(not string.find(tbuffs,"Vampire Arrows"))}
  i=i+1;Skill[i]={name="Action:30(Atk)", use=true}
 end
 MyCombat(Skill,arg1)
end

Will be some syntax issue im sure, buggered if I can see it tho

748

Friday, June 25th 2010, 2:05pm

Quoted from "blurterblurter;295003"

yea just saw that, still getting the same error with this:

Will be some syntax issue im sure, buggered if I can see it tho


Missing a closing parenthesis on the "Action: 21" line.

This kind of error is where Notepad++ is invaluable for editing code. If you look in the margin next to where the line numbers are, you'll see lines and symbols that will help you monitor the flow of your code. If you see the line break and stop at one of your Skill definitions, you know instantly where the typo is.

Also, when you click next to a parenthesis it will show you the other one that is paired with it (they light up red). So that helps as well.

749

Friday, June 25th 2010, 3:57pm

awesome got it, its great dps ty

750

Friday, June 25th 2010, 4:40pm

Version 1.4 posted

Version 1.4 is now posted. You can get the updated code from the first post of this thread or from curse.com.

Please read the following before replacing your current version!![INDENT] It is very important that you make a backup of your current DIYCE folder because I would hate for someone to lose any code changes/additions they have made. So before you do anything else, please go save a copy of the whole DIYCE folder to a safe location (My Documents maybe?). I cannot stress this point enough. Even if you don't think you've made changes, go save a copy anyway just in case!!

Also, be aware that the curse client overwrites the entire folder, so even if you have your custom class functions in a separate file in the DIYCE folder they will get erased... MAKE A BACKUP!!

If you modified the DIYCE.toc file to include your own .lua file, make sure you modify the new one as well.
[/INDENT]Version 1.4 changes:

  • Modified ReadSkills() function to read the first page of your Skill book. So now "Attack" can be used just like any other skill.
  • Added a PctS() function. This works exactly like PctH() and PctM() except it returns the % left of your secondary class's resource pool (mana/rage/energy/focus). This will really only be useful for someone with mana as their secondary resource.
  • Added a CancelBuff(buffname) function. Just pass it the name of the buff that you want to cancel. Example: CancelBuff("Blood Arrow").
  • Added the BuffTimeLeft(unit, buffname) function. The first argument is the unit to check ("player", "party1", "target", etc) and the second argument is the buff (friendly) or debuff (enemy) name you're looking for. Example: BuffTimeLeft("target", "Disarmament"). It returns the time (in seconds) left on that buff/debuff. It uses a string match rather than an exact match so using "Disarmament" will match any buff/debuff name with that word in it.
  • Added the logic to call a custom "execution" function that you define. I'll elaborate on this below.

GUIDELINES FOR USING A CUSTOM EXECUTION FUNCTION:

Because there's a big demand for performing actions other then executing skills or using items with the combat engine, the DIYCE now allows you to call your own custom code to perform any operation you want. I'll give examples at the end, but it's impossible for me to guess everything this might be used for. So use your imagination. ;)

You call the custom execution function by defining a skill with the text "Custom:" at the beginning. Any text following that will be passed to your function as the one (and only) argument.

Here's an example:

Source code

1
i=i+1; Skill[i] = { name = "Custom: Heal Me", use = ((UnitClass("target") == "Priest") and (PctH("player") < .5)) }
Notice that it still adheres to the "use" condition(s). So in this case, the custom function won't get called unless a Priest is targeted and the player has less than 50% health.

To define the code that this calls, add a function called "CustomAction" to your .lua file. Preferably a separate file from the DIYCE.lua file so it doesn't get overwritten by any future engine updates. This function will accept one argument.

Here's an example:

Source code

1
2
3
4
5
6
7
function CustomAction(action)
    if action == "Heal Me" then
        DoEmote(4) -- Wave
        SendChatMessage("I'm dieing, heal me please!!", "SAY")
    end
    return false
end
So whenever the DIYCE calls this custom execution function it will wave and ask for a heal.

THREE VERY IMPORTANT POINTS:

1)
Because the combat engine doesn't know what your code might do, the only way for it to tell if an action was actually performed is by the return value of true or false from your CustomAction() function. If the value is false, the engine will continue going down your skill list to execute the next available skill. So if your code performs some action that requires any wait time between it and another action, then make 100% sure you return a value of true from your function. Otherwise, the engine will perform your custom action and then try to perform another action giving you a system error (Skill not ready or whatnot). However, if you do perform an action (such as an emote, for instance) but no wait time is needed, then it's ok to return a value of false so that the engine can try to execute something else.

2) If you perform any actions, you are responsible for checking the "readiness" condition of them. In other words, I don't do a cooldown check or anything else before calling your function because I have no idea what your code is going to do. As long as the "use" definition is true, the DIYCE just blindly calls CustomAction(). You're free to use my CD(skillname) function to check whether a skill is on cooldown or not (true = skill ready). For anything else, you'll have to define the check yourself.

3) The "v1" and "v2" feedback levels don't get used with custom execution functions. If I had it broadcast the custom skill text in my code, then you'll get those message whether your custom function did anything or not, which would be misleading information. So you'll have to come up with your own feedback controls (see Example #2 below).

EXAMPLES:

Here's a few examples I came up with to demonstrate some of the things this can do...

Example #1:

A Knight hates it when his Priest casts Regen on him just before a fight because inevitably the Priest will get aggro from any adds that he doesn't damage. So instead of yelling at the Priest every time, he does this:

Source code

1
i=i+1; Skill[i] = { name = "Custom: Cancel Regen",  use = ((not combat) and (PctH("player") == 1) and ChkBuff("player", "Regenerate")) }
And his CustomAction function is this:

Source code

1
2
3
4
function CustomAction(action)
    CancelBuff("Regenerate")
    return false
end
Notice that I returned a value of false because canceling a buff does not trigger the GCD or require any wait time between it and executing another action. Also notice that because this is the only custom action defined, it's not necessary to check the "action" argument value.

Example #2:

A player wants to have the engine remember the last skill he executed. This gets a bit more complicated because we'll have to setup a global variable so we can check it in our class function.

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
g_lastaction = ""  -- Define g_lastaction globally
function MagePriest(arg1)
    Skill = {}
    i = 0
    friendly = (not UnitCanAttack("target", "player"))
    combat = GetPlayerCombatState()

    if (not combat) then
        g_lastaction = ""
    end

    i=i+1; Skill[i] = { name = "Custom: Flame",        use = ((not friendly) and (g_lastaction ~= "Flame")) }
    i=i+1; Skill[i] = { name = "Custom: Fireball",     use = (not friendly) }
    i=i+1; Skill[i] = { name = "Custom: Rising Tide",  use = (not friendly) }
    i=i+1; Skill[i] = { name = "Custom: Plasma Arrow", use = (not friendly) }

    MyCombat(Skill, arg1)
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
So with this code, he won't cast Flame back-to-back.

You can do something similar if you want it to keep a sequence count.

Example #3:

Let's say you want to define several different custom actions. All you have to do is check the value of the text and you can run different operations or even branch to other custom functions.

For instance, consider these skill definitions for a Warden:

Source code

1
2
3
i=i+1; Skill[i] = { name = "Custom: Random Pet",     use = (not UnitExists("playerpet")) }
i=i+1; Skill[i] = { name = "Custom: Swap Equipment", use = (PctH("player") < .20) }
i=i+1; Skill[i] = { name = "Custom: Heal Pet",       use = (PctH("playerpet") < .75) }
And the custom functions that he defines:

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
function RandomPet()
    local MyPets = { "Spirit of the Oak", "Nature Crystal", "Oak Walker" }
    return "Summon "..MyPets[math.random(3)]
end

function CustomAction(action)
    if action == "Random Pet" then
        local petsummon = RandomPet()
        if CD(petsummon) then
            CastSpellByName(petsummon)
            return true
        end
    elseif action == "Swap Equipment" then
        SwapEquipmentItem()
        return true
    elseif (action == "Heal Pet") and CD("Elven Prayer") then
        FocusUnit(1, "target")
        TargetUnit("playerpet")
        CastSpellByName("Elven Prayer")
        TargetUnit("focus1")
        FocusUnit(1, "")
        return true
    end
    return false
end

jsalemi

Trainee

Posts: 133

Location: VA, USA

  • Send private message

751

Friday, June 25th 2010, 6:18pm

Quoted from "Sixpax;295060"


[INDENT]
Also, I'm not sure if the curse client overwrites the entire folder or not, so even if you have your custom class functions in a separate file in that folder, MAKE A BACKUP!!



It does -- if you're using the curse client, you're better off leaving the DIYCE folder for just the base program files, and putting your custom functions in a separate folder (MyFunctions or something like that).


[/INDENT]

HuBu

Beginner

Posts: 6

Location: Florida

  • Send private message

753

Friday, June 25th 2010, 8:13pm

hmm doesn't seem to work. copied in the new DIYCE, keep all my class lua files and nothing is launching.

754

Friday, June 25th 2010, 8:18pm

Quoted from "HuBu;295150"

hmm doesn't seem to work. copied in the new DIYCE, keep all my class lua files and nothing is launching.


Any flashing red icons around your minimap?
Do you get "Reading class skills" message when you login?
Did you modify the DIYCE.toc file with the names of your class .lua files?

HuBu

Beginner

Posts: 6

Location: Florida

  • Send private message

755

Friday, June 25th 2010, 8:24pm

Quoted from "Sixpax;295157"

Any flashing red icons around your minimap?
Do you get "Reading class skills" message when you login?
Did you modify the DIYCE.toc file with the names of your class .lua files?


Sorry. Six, stupid me must have copied it in wrong of something. But I recopied it and its working now. Going to test out the new functions you added.

756

Friday, June 25th 2010, 8:27pm

Quoted from "HuBu;295162"

Sorry. Six, stupid me must have copied it in wrong of something. But I recopied it and its working now. Going to test out the new functions you added.


Good to hear. I was worried I botched something.

HuBu

Beginner

Posts: 6

Location: Florida

  • Send private message

757

Friday, June 25th 2010, 8:47pm

BuffTimeLeft function works great, continues buff rather than waiting for a buff to expire then recasting it.

758

Saturday, June 26th 2010, 1:39am

A bit upgraded functions for W/P that Sixpax did posted for me earlier :)


Quoted



function Warrior(arg1)
local Skill = {}
local i = 0
local rage = UnitMana("player")
local mana = UnitSkill("player")
local friendly = (not UnitCanAttack("player", "target"))
local combat = GetPlayerCombatState()
local tspell,ttime,telapsed = UnitCastingTime("target")
local pbuffs = BuffList("player")
local tbuffs = BuffList("target")


i=i+1; Skill = { name = "Interrupting Strike", use = ((not friendly) and (tspell ~= nil) and (ttime >= 1) and ((ttime - telapsed) > 0.5) and (rage >= 30)) }
i=i+1; Skill[i] = { name = "Urgent Heal", use = ((PctH("player") < .50) and (mana >= 300)) }
i=i+1; Skill[i] = { name = "Regenerate", use = ((PctH("player") < .95) and (not string.find(pbuffs, "Regenerate")) and (mana >= 300)) }
i=i+1; Skill[i] = { name = "Opportunity", use = ((not friendly) and (rage >= 15) and string.find(tbuffs, "Weakened")) }
i=i+1; Skill[i] = { name = "Survival Instinct", use = (PctH("player") < .33) }
i=i+1; Skill[i] = { name = "Bloodlust", use = ((not friendly) and (rage < 40) and (PctH("player") >= .90) and (not string.find(pbuffs, "Blood Retention"))) }
i=i+1; Skill[i] = { name = "Berserk", use = ((not friendly) and (rage >= 25)) }
i=i+1; Skill[i] = { name = "Enraged", use = ((not friendly) and (rage < 40)) }
i=i+1; Skill[i] = { name = "Slash", use = ((not friendly) and (not string.find(tbuffs, "Bleed"))) }
i=i+1; Skill[i] = { name = "Open Flank", use = ((not friendly) and (rage >= 10) and string.find(tbuffs, "Vulnerable")) }
i=i+1; Skill[i] = { name = "Probing Attack", use = ((not friendly) and (rage >= 20) and (not string.find(tbuffs, "Vulnerable"))) }
i=i+1; Skill[i] = { name = "Slash", use = ((not friendly) and (rage >= 25) and (not string.find(tbuffs, "Vulnerable"))) }



MyCombat(Skill,arg1)
end


function WarriorS(arg1)
local Skill = {}
local i = 0
local rage = UnitMana("player")
local mana = UnitSkill("player")
local friendly = (not UnitCanAttack("player", "target"))
local combat = GetPlayerCombatState()
local tspell,ttime,telapsed = UnitCastingTime("target")
local pbuffs = BuffList("player")
local tbuffs = BuffList("target")

i=i+1; Skill[i] = { name = "Interrupting Strike", use = ((not friendly) and (tspell ~= nil) and (ttime >= 1) and ((ttime - telapsed) > 0.5) and (rage >= 30)) }
i=i+1; Skill[i] = { name = "Urgent Heal", use = ((PctH("player") < .50) and (mana >= 300)) }
i=i+1; Skill[i] = { name = "Regenerate", use = ((PctH("player") < .95) and (not string.find(pbuffs, "Regenerate")) and (mana >= 300)) }
i=i+1; Skill[i] = { name = "Opportunity", use = ((not friendly) and (rage >= 15) and string.find(tbuffs, "Weakened")) }
i=i+1; Skill[i] = { name = "Survival Instinct", use = (PctH("player") < .33) }
i=i+1; Skill[i] = { name = "Enraged", use = ((not friendly) and (rage < 40)) }
i=i+1; Skill[i] = { name = "Slash", use = ((not friendly) and (not string.find(tbuffs, "Bleed"))) }
i=i+1; Skill[i] = { name = "Open Flank", use = ((not friendly) and (rage >= 10) and string.find(tbuffs, "Vulnerable")) }
i=i+1; Skill[i] = { name = "Probing Attack", use = ((not friendly) and (rage >= 20) and (not string.find(tbuffs, "Vulnerable"))) }



MyCombat(Skill,arg1)
end

Worrior function will unleash all you got, you will slice like a mad man. This is a max what i could get out of my w/p and its partially suicade mode but works preety well on normal mobs

WorriorS is a normal version its mainly based on your weapon attack speed and if you use very slow axe it might be quite bad in this case just throw out opportunity and the secound slash. That way you will still have self supplying in rage combo and not loss to much dps.

Both of this functions require auto-attack to be active for self-suppling in rage :)
Sorry for my english :)

jsalemi

Trainee

Posts: 133

Location: VA, USA

  • Send private message

759

Saturday, June 26th 2010, 3:57pm

Quoted from "Sixpax;295169"

Good to hear. I was worried I botched something.


Played around with 1.4 last night -- so far, so good. Haven't hit any snags, and every thing works fine. I think it's good-to-go.

760

Saturday, June 26th 2010, 8:44pm

so me again, have change to 1.4 first it functions well the i tryed my custom function and know nothing happen in game when i hit the button with my funktion, here my Code maybe i missed someting

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
  -- 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 ChkBuff(tgt,buffname)
    local cnt = 1
    local buffcmd = UnitBuff

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

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

function BuffList(tgt)
    local cnt = 1
    local buffcmd = UnitBuff
    local buffstr = "/"

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

    while buff ~= nil do
        buffstr = buffstr..buff.."/"
        cnt = cnt + 1
        buff = buffcmd(tgt,cnt)
    end

    return string.gsub(buffstr, "(%()(.)(%))", "%2")
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

function CustomAction(action)
    if action == "Heal Me" then
        DoEmote(4) -- Wave
        SendChatMessage("Ich Sterbe, Heil Mich bitte!!", "SAY")
    return true
    end
    elseif (action == "Spiegel") then
        if UnitExists("target") then 
        FocusUnit(1, "target")
        TargetUnit("player")
        UseAction (20)
        TargetUnit("focus1")
        FocusUnit(1, "")
        return true
    end
    else
        FocusUnit("player")
        UseAction (20)
        return true
    end
    return true
    end

    return false
end

function Rogue(arg1, arg2)
    local Skill = {}
    local i = 0
    local energy = UnitMana("player")
    local focus = UnitSkill("player")
    local friendly = (not UnitCanAttack("player", "target"))
    local combat = GetPlayerCombatState()
    local tspell,ttime,telapsed = UnitCastingTime("target")
    local pbuffs = BuffList("player")
    local tbuffs = BuffList("target")

  
  
   i=i+1; Skill[i] = { name = "Werfen",                      use = ((not friendly) and (ttime >= 1) and ((ttime - telapsed) > 0.5)) }
   i=i+1; Skill[i] = { name = "Gift",                    use = (not ChkBuff("player","Giftig") and not combat) }
   i=i+1; Skill[i] = { name = "Aura der Schnelligkeit",         use = ((not string.find(pbuffs, "Aura der Schnelligkeit") and (not string.find(pbuffs, "Ausweichen")) and not combat)) }
   i=i+1; Skill[i] = { name = "Magischer Schutz",            use = (not ChkBuff("player","Magischer Schutz") and not combat) }
   i=i+1; Skill[i] = { name = "Gesegnetes Quellwasser",       use = (not ChkBuff("player","Gesegnetes Quellwasser") and not combat) }
   i=i+1; Skill[i] = { name = "Regenerieren",                use = ((PctH("player") < .95) and (not string.find(pbuffs, "Regenerieren"))) }
   i=i+1; Skill[i] = { name = "Gesegnete Aura",                use = ((PctH("player") < .15) ) }
   i=i+1; Skill[i] = { name = "Spitzel",                  use = ((not string.find(pbuffs, "M\195\182rderischer Zorn")) and (not string.find(pbuffs, "Spitzel")) and combat) }
   i=i+1; Skill[i] = { name = "Ausweichen",              use = ((not string.find(pbuffs, "Ausweichen")) and combat) }   
   i=i+1; Skill[i] = { name = "Wilder Angriff",              use = ((PctH("player") < .40) and (string.find(pbuffs, "Ausweichen")) and combat) }   
   i=i+1; Skill[i] = { name = "Custom: Spiegel",            use = (not string.find(pbuffs,"Siegel der Verteidigung")) }
   i=i+1; Skill[i] = { name = "M\195\182rderischer Zorn",      use = ((not string.find(pbuffs, "M\195\182rderischer Zorn")) and (not string.find(pbuffs, "Spitzel")) and combat) }
   i=i+1; Skill[i] = { name = "Vorsatz",                    use = (not ChkBuff("player","Vorsatz") and not combat) }
   i=i+1; Skill[i] = { name = "Hinterhalt",               use = ((not friendly) and (energy >= 20) and (arg2 == "behind")) }
   i=i+1; Skill[i] = { name = "Toter Winkel-Angriff",           use = ((not friendly) and (energy >= 25) and string.find(tbuffs, "Blutende Wunde") and (arg2 == "behind")) }
   i=i+1; Skill[i] = { name = "Blendung",                   use = ((not friendly) and (energy >= 20) and not string.find(tbuffs, "Blind") and string.find(tbuffs, "Blutende Wunde") and string.find(tbuffs, "Starke Blutung")) }
   i=i+1; Skill[i] = { name = "Wunden angreifen",           use = ((not friendly) and (energy >= 35) and string.find(tbuffs, "Blutende Wunde") and string.find(tbuffs, "Starke Blutung")) }
   i=i+1; Skill[i] = { name = "Gemeiner Schlag",               use = ((not friendly) and (energy >= 35) and string.find(tbuffs, "Blutende Wunde")) }
   i=i+1; Skill[i] = { name = "Furchtlos",                   use = (string.find(pbuffs, "F\195\188rchterliecher Schrei")) }
   i=i+1; Skill[i] = { name = "Meucheln",                 use = ((not friendly) and (energy >= 35) and not string.find(tbuffs, "Blutende Wunde") and not string.find(tbuffs, "Hinterhalt-Blutende Wunde")) }



   MyCombat(Skill,arg1)
end

function RogueBoss(arg1, arg2)
    local Skill = {}
    local i = 0
    local energy = UnitMana("player")
    local focus = UnitSkill("player")
    local friendly = (not UnitCanAttack("player", "target"))
    local combat = GetPlayerCombatState()
    local tspell,ttime,telapsed = UnitCastingTime("target")
    local pbuffs = BuffList("player")
    local tbuffs = BuffList("target")


   i=i+1; Skill[i] = { name = "Werfen",                      use = ((not friendly) and (ttime >= 1) and ((ttime - telapsed) > 0.5)) }
   i=i+1; Skill[i] = { name = "Gift",                    use = (not ChkBuff("player","Giftig") and not combat) }
   i=i+1; Skill[i] = { name = "Aura der Schnelligkeit",        use = ((not string.find(pbuffs, "Aura der Schnelligkeit") and (not string.find(pbuffs, "Ausweichen")) and not combat)) }
   i=i+1; Skill[i] = { name = "Magischer Schutz",            use = (not ChkBuff("player","Magischer Schutz") and not combat) }
   i=i+1; Skill[i] = { name = "Gesegnetes Quellwasser",        use = (not ChkBuff("player","Gesegnetes Quellwasser") and not combat) }
   i=i+1; Skill[i] = { name = "Regenerieren",                use = ((PctH("player") < .95) and (not string.find(pbuffs, "Regenerieren"))) }
   i=i+1; Skill[i] = { name = "Gesegnete Aura",                use = ((PctH("player") < .15) ) }
   i=i+1; Skill[i] = { name = "Spitzel",                  use = ((not string.find(pbuffs, "M\195\182rderischer Zorn")) and (not string.find(pbuffs, "Spitzel")) and combat) }
   i=i+1; Skill[i] = { name = "Ausweichen",              use = ((not string.find(pbuffs, "Ausweichen")) and combat) }   
   i=i+1; Skill[i] = { name = "Wilder Angriff",              use = ((PctH("player") < .40) and (string.find(pbuffs, "Ausweichen")) and combat) }   

   i=i+1; Skill[i] = { name = "Custom: Spiegel",            use = (not string.find(pbuffs,"Siegel der Verteidigung")) }

   i=i+1; Skill[i] = { name = "M\195\182rderischer Zorn",      use = ((not string.find(pbuffs, "M\195\182rderischer Zorn")) and (not string.find(pbuffs, "Spitzel")) and combat) }
   i=i+1; Skill[i] = { name = "Verbergen",                use = (not ChkBuff("player","Verbergen") and not combat) }
   i=i+1; Skill[i] = { name = "Schattengef\195\164ngnis",       use = ((not friendly) and (energy >= 50) and not string.find(tbuffs, "Schattengef\195\164ngnis")) }
   i=i+1; Skill[i] = { name = "Schattenschritt",           use = ((not friendly) and (energy >= 20) and string.find(tbuffs, "Schattengef\195\164ngnis")) }
   i=i+1; Skill[i] = { name = "Hinterhalt",               use = ((not friendly) and (energy >= 20) and (arg2 == "behind")) }
  
   i=i+1; Skill[i] = { name = "Item: Trank der herausragenden Fertigkeit",    use = (energy <= 10) }

   i=i+1; Skill[i] = { name = "Toter Winkel-Angriff",           use = ((not friendly) and (energy >= 25) and string.find(tbuffs, "Blutende Wunde") and (arg2 == "behind")) }
   i=i+1; Skill[i] = { name = "Blendung",                   use = ((not friendly) and (energy >= 20) and not string.find(tbuffs, "Blind") and string.find(tbuffs, "Blutende Wunde") and string.find(tbuffs, "Starke Blutung")) }
   i=i+1; Skill[i] = { name = "Wunden angreifen",           use = ((not friendly) and (energy >= 35) and string.find(tbuffs, "Blutende Wunde") and string.find(tbuffs, "Starke Blutung")) }
   i=i+1; Skill[i] = { name = "Gemeiner Schlag",               use = ((not friendly) and (energy >= 35) and string.find(tbuffs, "Blutende Wunde")) }
   i=i+1; Skill[i] = { name = "Meucheln",                 use = ((not friendly) and (energy >= 35) and not string.find(tbuffs, "Blutende Wunde") and not string.find(tbuffs, "Hinterhalt-Blutende Wunde")) }




   MyCombat(Skill,arg1)
end