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.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

481

Tuesday, February 28th 2012, 2:19am

Quoted from "LaughingWolf;512796"

@Peryl I'm new to LUA but not to programming in general (turbo pascal, basic, and some minor C++ experience), and want to learn more. Any free resources you highly recommend for any of us interested in learning more? Definitely need some beginner level stuff and maybe a few advanced level resources too. I'd love to be able to figure out what I need to change in the DIYCE files to get it working right for me as I am having a few varied problems with it so far, including the "not doing a darned thing when executed by /run KillSequence() macro" problem. Surprisingly, /run KillSequence("v2") works as intended, and only gave me a list of Idle when my class combo was not listed in CustomFunctions.lua


Several resources available for you to learn from:
For Lua programming in general, see Programming in Lua (first edition). It covers Lua 5.0 so it's a little dated, but still relevant (consider purchasing the second edition for 5.1 coverage, and support the Lua project).

For a full description of the language, try the Lua 5.1 Reference Manual.

For RoM specific functions, see The Runes of Magic Wiki (see the box in the bottom right for function descriptions, add-on tutorials, etc).

Also of interest may be these guides I wrote up and available on these forums:



As to your problem, try running KillSequence with one of the debug options as the first parameter. "debugskills" is probably your best bet to help you out.
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

482

Tuesday, February 28th 2012, 2:28am

Quoted from "darknight3z;513013"

Hi guys, this is my attempt at writing a sequence for my W/Wdn but I seem to be having some problems. The script works and doesn't give me any error messages. However, it doesn't use Open Flank when target is Vulnerable nor does it use Tactical Attack when target has bleed on it.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
--Class: Warrior/Warden            elseif mainClass == "WARRIOR" and subClass == "WARDEN" then
            
                if enemy then
                Skill = {
                    { name = "Savage Whirlwind",             use = (EnergyBar2 >= 240) },
                    { name = "Open Flank",                   use = (EnergyBar1 >= 10) and (tbuffs['Vulnerable']) },
                    { name = "Attack Weakener",              use = (EnergyBar1 <= 10) and (EnergyBar2 >= 280) and (tbuffs['Vulnerable']) },
                    { name = "Tactical Attack",              use = (EnergyBar1 >= 15) and (tbuffs[500081]) },
                    { name = "Probing Attack",               use = (EnergyBar1 >= 20) },
                    { name = "Slash",                        use = (EnergyBar1 >= 25) },
                    { name = "Power of the Wood Spirit",     use = (EnergyBar2 >= 123) },
                    { name = "Attack",                       use = (thealth == 1) },
                        }
                end


Can anybody tell me why this is happening? Thanks in advance.

Not really sure what the problem actually is, but try running the code with

Source code

1
/run KillSequence("debugskills")

This should at least show you the list of skills the way DIYCE will see it. If your Open Flank line is always false (as I suspect is happening) then the likely candidate for the problem would be the tbuffs['Vulnerable'] part. Make sure this is the full name of the debuff on the target and matches exactly (including case).

Quoted from "darknight3z;513013"

Edit: Also, if there is already a Slash on target theoretically the script should use Tactical Attack immediately and skip Slash right? How can I get myself to use Slash as well even though another warrior may have put a Slash on it already?

The skill list is a priority list, so anything that is seen first in the list and has a use clause of true will be tried first. If that skill is not on cooldown then DIYCE will cast it and ignore the rest of the list.

Edit:
There is no way to identify who put which debuff on a mob. All that could really be done is for you to manually track if you've cast Slash on that mob. This gets into some very complicated territory unfortunately and would be prone to errors as well.
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

483

Tuesday, February 28th 2012, 2:40am

Quoted from "BloodyArrow;513458"

Hey!

I was wondering if there was a ammocheck function for DIYCE that keeps track of how many arrows you got left and preventing you to get the red message when got 1 arrow left or even out of arrows. So I got some code from my friend that I pasted into my DIYCE.

But I'm still getting the red message "Out of arrows" when I got 1 arrow left and my Vampire Arrows skill is under cooldown?

This is the part of my CustomFunctions where I pasted the code I have got from my friend.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local ammocheck = GetInventoryItemDurable("player", 9) >= 3 (This row is under the function KillSequence(arg1, healthpot, manapot, foodslot) where the other locals are.)

if mainClass == "RANGER" and subClass == "WARRIOR" then
                
                    
            --Combat
                if enemy then
                Skill2 = {
                    { name = "Target Lock",                   use = (boss) },
                    { name = "Combo Shot",                   use = (ammocheck) and (pvp) or (boss or elite) },    
                    { name = "Autoshot",                   use = (boss or elite) and (not ASon) },
                    
                    { name = "Vampire Arrows",             use = (EnergyBar1 >= 30) },
                    { name = "Piercing Arrow",               use = (ammocheck) },
                    { name = "Reflected Shot",               use = true },
                    { name = "Shot",                       use = true },
                        }
                end


/ B

The way this is written, ammocheck will be true if you have three or more arrows. However, ammocheck is only used with your Piercing Arrow and Combo Shot skill lines. All other skills will still be tried and so if it uses an arrow, you could still get the message.
2013... The year from hell....

484

Tuesday, February 28th 2012, 5:07pm

Ammocheck

Quoted from "Peryl;513473"

The way this is written, ammocheck will be true if you have three or more arrows. However, ammocheck is only used with your Piercing Arrow and Combo Shot skill lines. All other skills will still be tried and so if it uses an arrow, you could still get the message.


Thanks for your answer Peryl. What do you think if I add ammocheck to all of the skills that uses arrows and change the check from 3 arrows to 1?

485

Tuesday, February 28th 2012, 6:16pm

I am new to DIYCE and not very good at the scripts can some one please help me iam looking for scout/priest, scout/rouge, rouge/scout. With easy to follow instrucations as iam not gr8 with the code. =)

486

Tuesday, February 28th 2012, 10:11pm

Peryl, I ran the code with

Source code

1
[LEFT][COLOR=#000000]/run KillSequence("debugskills")[/COLOR][/LEFT]


and as you said, Open Flank and Tactical Attack returned as False even though I had the rage and the tbuffs for it to go off.

I double checked and triple checked the tbuffs spelling and its spelled correctly. :(

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

487

Tuesday, February 28th 2012, 10:59pm

Quoted from "darknight3z;513705"

Peryl, I ran the code with

Source code

1
[LEFT][COLOR=#000000]/run KillSequence("debugskills")[/COLOR][/LEFT]


and as you said, Open Flank and Tactical Attack returned as False even though I had the rage and the tbuffs for it to go off.

I double checked and triple checked the tbuffs spelling and its spelled correctly. :(

I really can't think of what is going wrong here, your code should be doing what you intend as far as I can tell.

Try running with

Source code

1
/run KillSequence("debugtbuffs")

to get the list of debuffs that DIYCE is seeing on your target.

Other debug options are "debugpbuffs" for the player buff list, and "debugall" which does all the of them (when doing "dbugall" the first buff list is the player buffs, the second is the target debuffs).
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

488

Tuesday, February 28th 2012, 11:03pm

Quoted from "BloodyArrow;513630"

Thanks for your answer Peryl. What do you think if I add ammocheck to all of the skills that uses arrows and change the check from 3 arrows to 1?

Then it should stop using skills with arrows and therefore you shouldn't see the message. As I've never played a scout, I really can't give much guidance for dealing with the arrow conditions.
2013... The year from hell....

489

Tuesday, February 28th 2012, 11:13pm

Quoted from "Peryl;513715"

I really can't think of what is going wrong here, your code should be doing what you intend as far as I can tell.

Try running with

Source code

1
/run KillSequence("debugtbuffs")

to get the list of debuffs that DIYCE is seeing on your target.

Other debug options are "debugpbuffs" for the player buff list, and "debugall" which does all the of them (when doing "dbugall" the first buff list is the player buffs, the second is the target debuffs).


The Skill List and Buffs List is coming up blank and not showing anything.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

490

Tuesday, February 28th 2012, 11:27pm

Quoted from "Eviljo;513646"

I am new to DIYCE and not very good at the scripts can some one please help me iam looking for scout/priest, scout/rouge, rouge/scout. With easy to follow instrucations as iam not gr8 with the code. =)

Ghostwolf's original idea for DIYCE 2 was to have pretty much all the class combinations already setup so that you would have a "load and go" usage for DIYCE 2. Unfortunately, this seems to have been abandoned by the community as everyone just keeps removing existing stuff and putting in their own class combos.

Therefore, your best bet is to start learning how to deal with the current DIYCE code. Sorry, but there just isn't an "easy" solution to this.

Anyway, A Rogue/Scout combo exists in the default DIYCE you download from the first post, for the others, I'm fairly certain folk have posted such combos in this thread so look through them (and maybe learn a thing or two about how DIYCE 2 works while your at it ;). It isn't all that bad really).

On another note, jtanner28 was considering trying to do a GUI front end for DIYCE 2 based on a suggestion I made some time ago. Not sure if he's still doing it or not (or if he even plays anymore. Haven't seen him around the forums of late). But until something like that comes out, DIYCE will continue to be edited via script files.
2013... The year from hell....

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

491

Tuesday, February 28th 2012, 11:33pm

Quoted from "darknight3z;513719"

The Skill List and Buffs List is coming up blank and not showing anything.

Hmmmm... Not sure why the buff list is blank, but that would be the main problem since as far as DIYCE is seeing things, the target has no debuffs on him (hence it won't use the skills that rely on the target having a certain debuff).

Looking at the code you posted here , I don't see why this is so. Could something else be changing the target on you?
2013... The year from hell....

492

Tuesday, February 28th 2012, 11:38pm

Quoted from "Peryl;513721"

Hmmmm... Not sure why the buff list is blank, but that would be the main problem since as far as DIYCE is seeing things, the target has no debuffs on him (hence it won't use the skills that rely on the target having a certain debuff).

Looking at the code you posted here , I don't see why this is so. Could something else be changing the target on you?


I don't see what could be changing my target, I'm targeting the same thing the whole time.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

493

Wednesday, February 29th 2012, 12:20am

All I can think of is that something weird is happening with the BuffList function. Maybe some other add-on or something.

Can you post your DIYCE.lua so I can take a look and make sure BuffList defined there is as it should be.

Something else to try in case it is interference, change the name of the BuffList function in DIYCE.lua to something that obviously won't be used by some other add-on (say DK3Z_BuffList) and change all references to BuffList in CustomFunctions.lua and DIYCE.lua to use this new name. This is just a shot in the dark, but may be worth a try.
2013... The year from hell....

494

Wednesday, February 29th 2012, 12:57am

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

local g_skill  = {}
local g_lastaction = ""


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


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


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


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


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


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


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


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


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


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


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


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


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


    return list
end


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


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


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


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


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


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


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


	return 0
end


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


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


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


    if (spell ~= nil) then
        return
    end


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


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


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


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

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

495

Wednesday, February 29th 2012, 1:07am

Doesn't seem to be anything wrong with the version you've got there. Did you try the renaming thing?
2013... The year from hell....

496

Wednesday, February 29th 2012, 1:28am

Quoted from "Peryl;513744"

Doesn't seem to be anything wrong with the version you've got there. Did you try the renaming thing?


Haha, Thanks Peryl. Your the man! Works fine now. Thank you for your time, I appreciate it. :D

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

497

Wednesday, February 29th 2012, 3:46am

Quoted from "darknight3z;513748"

Haha, Thanks Peryl. Your the man! Works fine now. Thank you for your time, I appreciate it. :D

Aha! This means that there is some other add-on that is defining a function called BuffList as well and this is interfering. The renaming trick effectively bypasses the problem, but you may want to figure out where it is coming from. It would have to come after DIYCE 2.0.

Glad it's finally working though.
2013... The year from hell....

498

Wednesday, February 29th 2012, 4:47pm

Quoted from "Peryl;513774"

Aha! This means that there is some other add-on that is defining a function called BuffList as well and this is interfering. The renaming trick effectively bypasses the problem, but you may want to figure out where it is coming from. It would have to come after DIYCE 2.0.

Glad it's finally working though.


Yea, I was using an old 1.4 DIYCE function given to me by a guildie that no longer plays but felt it was time for an upgrade. But I didn't want to delete it before getting a working 2.2 one. Maybe that was what was giving me problems.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

499

Wednesday, February 29th 2012, 11:08pm

Quoted from "darknight3z;513888"

Yea, I was using an old 1.4 DIYCE function given to me by a guildie that no longer plays but felt it was time for an upgrade. But I didn't want to delete it before getting a working 2.2 one. Maybe that was what was giving me problems.

Yup! I'd bet that was exactly the problem. The older version was likely being loaded after DIYCE 2.2 and therefore was replacing the BuffList function, as the two versions are drastically different, DIYCE 2.2 could no longer see the buffs/debuffs.

Now that you know where the problem was, it may be better to rename the old version to something like oldBuffList and the new version back to BuffList (with appropriate changes in remainder of code of course). This way, any other code you encounter for DIYCE 2.2 will still work, and anything that needs the older version can be fixed to use oldBuffList.
2013... The year from hell....

500

Thursday, March 1st 2012, 4:22am

Quoted from "Peryl;513985"

Yup! I'd bet that was exactly the problem. The older version was likely being loaded after DIYCE 2.2 and therefore was replacing the BuffList function, as the two versions are drastically different, DIYCE 2.2 could no longer see the buffs/debuffs.

Now that you know where the problem was, it may be better to rename the old version to something like oldBuffList and the new version back to BuffList (with appropriate changes in remainder of code of course). This way, any other code you encounter for DIYCE 2.2 will still work, and anything that needs the older version can be fixed to use oldBuffList.


Lol now that I have 2.2 working I won't be needing the old one anymore and I can rename back to BuffList.