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.

81

Monday, March 8th 2010, 3:51am

Alright. I have all the code set up now. I followed the "nutshell" instructions, made sure the path to the MyFunctions folder is correct, made the two text documents (named: MyFunctions.toc and MyFunctions.lua) put the MyFunctions.lua inside the .toc and saved it. Inserted all the first post page code + codes following the outlines posted here. ok seems everything is as it should.

get into the game, try to do the /run ReadSkills() command, but i dont get a response that says it read the skills, nor do i get a error msg in the chat box. no confirmation and no errors, sooo what did i do wrong then??

82

Monday, March 8th 2010, 8:34am

First of all, thanks Sixpax for the great engine.
I have a question on this part:
8) Add your class specific function below all that code (in the MyFunctions.lua file). If there isn't a function already posted for your class combo, start with one that someone else posted and modify it to suit your class, or ask for one and we'll get you started.

Now i was wondering if I can put codes for both of my classes (main and sub or more) in the MyFunctions.lua file?
Sorry if it sounds like a dumb question and appreciated for taking your time doing this.
Thanks in advance,
vb

83

Monday, March 8th 2010, 11:13am

Viper,
If you mean multiple 'ClassX()' functions then yes there's nothing wrong with that.
If you mean adding skills from both primary and secondary classes to on function then yes that's fine too.

If you mean putting all your skills from multiple class combos (mage/knight and knight/mage for example) into one function then that's not a good idea.

84

Monday, March 8th 2010, 2:07pm

Quoted from "dashort;239832"

The problem I'm having, however, is that mine doesn't seem to recognize when I'm in combat, and if my buff fails while I'm fighting, it stops to rebuff.


It sounds to me like you're not defining the "combat" variable. Make sure you have this line above the "meat" lines:

Source code

1
   local combat = GetPlayerCombatState()

Quoted from "dashort;239832"

Also, There is a problem when I'm using that macro to heal, it just keeps casting regenerate and not urgent heal. I'm R/P btw and thanks again!


Does it cast Regenerate even if you already have it on you? If so, then it's not reading your buffs into the "pbuffs" variable. Make sure you have this line near the top of your function:

Source code

1
   local pbuffs = BuffList("player")
You'll also probably want to move the Urgent Heal line above the Regenerate line because it's passing that check before it even makes it to the Urgent Heal check.

85

Monday, March 8th 2010, 2:15pm

First up bear with me, as I'm just not very good with code. :o

This is my MyFunctions.lua 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
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
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 = 2,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 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 buff == 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 buffstr
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
   else
      Msg("Skill not available: "..skillname)
      return false
   end
end

function MyCombat(Skill,arg1)
   local spell_name = UnitCastingTime("player")
   local talktome = false
   
   if (arg1 == "v1") or (arg1 == "v2") then
      talktome = true
   end

   if spell_name ~= nil then
      if (arg1 == "v2") then Msg("- ['..spell_name..']",0,1,1) end
      return false
   end

   for x,tbl in ipairs(Skill) do
      if CD(Skill[x].name) and Skill[x].use then
         if talktome then Msg("- "..Skill[x].name) end
         CastSpellByName(Skill[x].name)
         return true
      end
   end
   if (arg1 == "v2") then Msg("- IDLE") end

   return false
end

function KnightGeneric(arg1,arg2)
   local Skill = {}
   local i = 0
   local tgt = "player"
   local friendly = UnitCanAttack("player","target")
   local shield = (GetEquipSlotInfo(17) ~= nil)
   local health = PctH("player")
   local mana = UnitMana("player")/UnitMaxMana("player)
   local tgtcast,tgttime,tgtelapsed = UnitCastingTime("target")

   local pbuffs = BuffList("player")
   local tbuffs = BuffList("target")

   i=i+1; Skill[i] = { ['name'] = "Holy Shield",          ['use'] = (health <= .25) }
   i=i+1; Skill[i] = { ['name'] = "Resolution",           ['use'] = (health <= .33) }
   i=i+1; Skill[i] = { ['name'] = "Shield of Atonement",  ['use'] = ((not friendly) and (health <= .40) and shield) }
   i=i+1; Skill[i] = { ['name'] = "Shield of Valor",      ['use'] = ((not friendly) and (health <= .50) and shield) }
   i=i+1; Skill[i] = { ['name'] = "Shield of Discipline", ['use'] = ((not friendly) and (tgttime >1) and shield) }
   i=i+1; Skill[i] = { ['name'] = "Enhanced Armor",       ['use'] = (not string.find(pbuffs,"Enhanced Armor")) }
   i=i+1; Skill[i] = { ['name'] = "Holy Seal",            ['use'] = (not string.find(pbuffs,"Holy Seal")) }
   i=i+1; Skill[i] = { ['name'] = "Threaten",             ['use'] = (string.find(tbuffs,"Holy Seals %(3%)") and (not string.find(pbuffs,"Threaten")) and (arg2 == "threaten")) }
   i=i+1; Skill[i] = { ['name'] = "Mana Return",          ['use'] = (string.find(tbuffs,"Holy Seals %(3%)")) }
   i=i+1; Skill[i] = { ['name'] = "Whirlwind Shield",     ['use'] = ((not friendly) and shield) }
   i=i+1; Skill[i] = { ['name'] = "Holy Strike",          ['use'] = ((not friendly) and (mana >= .5)) }
   i=i+1; Skill[i] = { ['name'] = "Joint Blow",           ['use'] = ((not friendly) and (mana < .5)) }

   MyCombat(Skill,arg1)
end
This doesn't work for me. As in, when I run "/run KnightGeneric("v1")" in a macro, nothing happens.

I ran "/run ReadSkills()" but no feedback.
So I deleted the knight specific code leaving only the original code on page #1 of block #1 (the main code without the knight stuff), restarted the game and then ran "/run ReadSkills()" which did give me feedback...

Where am I going wrong?

Also I what text editor are you guys using? I noticed that when copy/pasting from notepad it seems to add invisible characters which further bug the code.

86

Monday, March 8th 2010, 2:17pm

Quoted from "foreshard;239976"

Alright. I have all the code set up now. I followed the "nutshell" instructions, made sure the path to the MyFunctions folder is correct, made the two text documents (named: MyFunctions.toc and MyFunctions.lua) put the MyFunctions.lua inside the .toc and saved it. Inserted all the first post page code + codes following the outlines posted here. ok seems everything is as it should.

get into the game, try to do the /run ReadSkills() command, but i dont get a response that says it read the skills, nor do i get a error msg in the chat box. no confirmation and no errors, sooo what did i do wrong then??


I have seen this happen before with others but couldn't figure out why it was happening. It's possible that something was missed when you copy & pasted the code into your .lua file, or I've got a strange typo somewhere in the class function that you're using (which one are you using?). If you're using the KnightGeneric() function, there's a problem with the one I posted and I've updated it with a tested/working one. So that could be the problem. If that's not it, then my advise is clean out your .lua file and just add the functions one at a time, logging into the game and running a test after each one.

So start with just the Msg() function, login and run this:

Source code

1
/run Msg("hello")


If that's not working, then for whatever reason it's not even reading your .lua file at all. Usually if that's the case you'll get a popup error though about not finding a global (since it doesn't know what "Msg" is). Are you running any addons that stop UI error messages?

If that does work, then add the ReadSkills() function (make sure you have the 1st line: "g_skill = {}" defined at the top). Then login and run this:

Source code

1
/run ReadSkills()


And so on.

87

Monday, March 8th 2010, 2:29pm

Quoted from "Provoke;240154"

First up bear with me, as I'm just not very good with code. :o

This is my MyFunctions.lua code:

Source code

1
<snip>
This doesn't work for me. As in, when I run "/run KnightGeneric("v1")" in a macro, nothing happens.

I ran "/run ReadSkills()" but no feedback.
So I deleted the knight specific code leaving only the original code on page #1 of block #1 (the main code without the knight stuff), restarted the game and then ran "/run ReadSkills()" which did give me feedback...

Where am I going wrong?


That sounds like I have an error in my KnightGeneric() code somewhere. I didn't test that so please forgive me for that. Tigs posted his (working) K/W code on post #16 so you might try that, or start with something simple and go from there. Try this one:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function KnightGeneric(arg1,arg2)
   local Skill = {}
   local i = 0
   local friendly = (not UnitCanAttack("player","target"))
   local shield = (GetEquipSlotInfo(17) ~= nil)
   local combat = GetPlayerCombatState()

   local pbuffs = BuffList("player")
   local tbuffs = BuffList("target")

   i=i+1; Skill[i] = { ['name'] = "Whirlwind Shield",     ['use'] = ((not friendly) and shield) }
   i=i+1; Skill[i] = { ['name'] = "Enhanced Armor",       ['use'] = (not string.find(pbuffs,"Enhanced Armor")) }
   i=i+1; Skill[i] = { ['name'] = "Holy Seal",            ['use'] = (not string.find(pbuffs,"Holy Seal")) }
   i=i+1; Skill[i] = { ['name'] = "Threaten",             ['use'] = (string.find(tbuffs,"Holy Seals 3") and (not string.find(pbuffs,"Threaten")) and (arg2 == "threaten")) }
   i=i+1; Skill[i] = { ['name'] = "Mana Return",          ['use'] = (string.find(tbuffs,"Holy Seals 3")) }
   i=i+1; Skill[i] = { ['name'] = "Punishment",           ['use'] = ((not friendly) and string.find(tbuffs,"Light Seal III")) }
   i=i+1; Skill[i] = { ['name'] = "Holy Strike",          ['use'] = (not friendly) }

   MyCombat(Skill,arg1)
end
Try that one and let me know if executes those skills.


Quoted

Also I what text editor are you guys using? I noticed that when copy/pasting from notepad it seems to add invisible characters which further bug the code.
I use Notepad and have the same problem if I'm copying into the game macro editor. I've just gotten into the habit of hitting backspace at the end of each line until I erase a legit character (replacing it of course).

88

Monday, March 8th 2010, 2:46pm

Quoted from "Sixpax;240164"

That sounds like I have an error in my KnightGeneric() code somewhere. I didn't test that so please forgive me for that. Tigs posted his (working) K/W code on post #16 so you might try that, or start with something simple and go from there. Try this one:

[code]...

Try that one and let me know if executes those skills.


I use Notepad and have the same problem if I'm copying into the game macro editor. I've just gotten into the habit of hitting backspace at the end of each line until I erase a legit character (replacing it of course).


No reason to excuse yourself :) Your doing me a favour.

So I replaced the knight specific code and it executed.

89

Monday, March 8th 2010, 2:51pm

Quoted from "Provoke;240171"

No reason to excuse yourself :) Your doing me a favour.

So I replaced the knight specific code and it executed.


Excellent. I edited that post and added a line for Threaten. So add that line and try this macro:

Source code

1
/run KnightGeneric("","threaten")

Tigsman

Trainee

Posts: 126

Location: ATL

Occupation: Fixing Things

  • Send private message

90

Monday, March 8th 2010, 3:51pm

fwiw, there were a couple typos in provokes original code in his class specific function. A missing " in one place for example and friendly not defined properly in another.

91

Monday, March 8th 2010, 5:31pm

Alright, problem solved. I looked again at the files that i created and saw that i had made two .txt files named MyFunctions.toc and MyFunctions.lua instead of a .TOC and .LUA files named MyFunction.toc and .lua

After correcting that i was able to do the read skills and such. Macro began working as it should. Still have yet to try the autoshot one. will prolly get around to implementing it today.

Thanks for the help. You're great at what you do.

92

Monday, March 8th 2010, 6:11pm

Combat Engine errors

Wow! You fixed my issues and I'm loving the macro/addon!!!

You're a talented guy and well appreciated by the community. Thanks a ton!

:D

HuBu

Beginner

Posts: 6

Location: Florida

  • Send private message

93

Wednesday, March 10th 2010, 7:55pm

knights buff

I have been out of touch with writing macros for awhile (did it for my warrior a long time ago)

basically i want to make a one button function that will buff my knight with enhanced armor and holy seal. i also want it to check if the buff is there and if the duration is less than 30 seconds, it will reapply the buff.

any help would be appreciated.

Tigsman

Trainee

Posts: 126

Location: ATL

Occupation: Fixing Things

  • Send private message

94

Wednesday, March 10th 2010, 9:28pm

as the examples given above, it will simply cast if the buff is off. Simply put, if the buf is off, and you hit the macro button, it will fire the buffs first. thats the idea behind a priority list such as this engine has. But i guess Sixpax might be able to check for buff timers, but that would involve quite a bit more code i would think. But I could be wrong.

I myself am in the process of redoing my priority list for soloing/duoing/tanking and see how it goes.

T

HuBu

Beginner

Posts: 6

Location: Florida

  • Send private message

95

Wednesday, March 10th 2010, 9:48pm

I kind changed Sixpax's code for ChkBuff() to return the count the buff you looking for then use that to get the remaining time on the buff.

EDIT 1 - Doesn't work? seems that GetPlayerBuffLeftTime() has to be GetPlayerBuffLeftTime(cnt-1)
EDIT 2 - Got it to work. Code is updated.

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
function ChkBuffTime(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 buff == buffname then
         return GetPlayerBuffLeftTime(cnt-1)
      end
      cnt = cnt + 1
      buff = buffcmd(tgt,cnt)
   end
   return false
end

function MyBuffs()
    if not ChkBuff("target","Enhanced Armor") then
        Msg("Casting Enhanced Armor")
        CastSpellByName("Enhanced Armor")
    else 
        if (ChkBuffTime("target","Enhanced Armor") > 30) then
            Msg("Armor is already up and greater than 30s")
        else
            if (ChkBuffTime("target","Enhanced Armor") < 30) then
                Msg("Casting Enhanced Armor bc buff is less than 30s")
                CastSpellByName("Enhanced Armor")
            end
        end    
    end
end

96

Thursday, March 11th 2010, 9:00am

anyone here tried doing one for R/W?

r/w uses AXE mainhand for majority of spells, but need to swap to Dagger for Shadowstab.

I use Mavoc's macro for swapping MH to OH, but it requires using /wait
LUA doesn't offer wait function. http://forum.us.runesofmagic.com/showthread.php?t=30516

Source code

1
2
3
4
5
/run PickupEquipmentItem(16) PickupEquipmentItem(15)
/wait .1
/cast Shadowstab
/wait .1
/run PickupEquipmentItem(16) PickupEquipmentItem(15)         

97

Thursday, March 11th 2010, 3:08pm

Quoted from "HuBu;241606"

I kind changed Sixpax's code for ChkBuff() to return the count the buff you looking for then use that to get the remaining time on the buff.

EDIT 1 - Doesn't work? seems that GetPlayerBuffLeftTime() has to be GetPlayerBuffLeftTime(cnt-1)
EDIT 2 - Got it to work. Code is updated.

Source code

1
<snip>


Here's a little tip for you that will simplify your code a bit. In your ChkBuffTime() function, have it "return 0" at the end instead of "return false". That way for buffs that you don't have on you'll still get a number. So you'll only need to do the ChkBuffTime() check. Also, if you're making a buffing function, you can define all the buffs you want to cast and have it cycle through all of them until it finds one you're missing. So you won't need to have separate if/then statements for each one. For instance:

Source code

1
2
3
4
5
6
7
8
9
10
function MyBuffs()
    local mybuffs = { "Enhanced Armor", "Holy Seal" }
    for i,buffname in pairs(mybuffs) do
        if (ChkBuffTime("player",buffname) < 30) then
            Msg("Casting "..buffname)
            CastSpellByName(buffname)
            return
        end
    end
end
Also I noticed you are using the wrong unit for self buffs. You should be using "player" not "target" since you can't cast those on other people.

98

Friday, March 12th 2010, 4:18pm

Quoted from "LucasUpright;236849"

Preliminary function for RogueKnight:

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
function RogueKnight(arg1,arg2)
    
    local Skill = {}
    local i = 0
    local energy = UnitMana("player")
    local mana = UnitSkill("player")
    local friendly = (not UnitCanAttack("player","target"))
    local combat = GetPlayerCombatState()
    local pbuffs = BuffList("player")
    local tbuffs = BuffList("target")

    i=i+1; Skill[i] = { ['name'] = "Enhanced Armor",    ['use'] = (not string.find(pbuffs,"Enhanced Armor")) }
    i=i+1; Skill[i] = { ['name'] = "Lions Protection",    ['use'] = (not string.find(pbuffs,"Lions Protection")) }
    i=i+1; Skill[i] = { ['name'] = "Premeditation",        ['use'] = ((not string.find(pbuffs,"Premeditation")) and (not combat)) }
    i=i+1; Skill[i] = { ['name'] = "Sneak Attack",   ['use'] = ((not friendly) and (energy >=30) and (arg2=="behind") and (not combat)) }
    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 >=35) and (string.find(tbuffs,"Bleed"))) }
    i=i+1; Skill[i] = { ['name'] = "Blind Spot",     ['use'] = ((not friendly) and (energy >=25) and (arg2=="behind")) }
    i=i+1; Skill[i] = { ['name'] = "Shadowstab",     ['use'] = ((not friendly) and (energy >=35)) }
    i=i+1; Skill[i] = { ['name'] = "Disarmament",     ['use'] = (not friendly) }

    MyCombat(Skill,arg1)

end
How does that look?


I am fairly stuck on stupid when it comes to these things... everything seems towork but I don't see what I need to create in my macro to execute this...

jsalemi

Trainee

Posts: 133

Location: VA, USA

  • Send private message

99

Friday, March 12th 2010, 7:00pm

/run RogueKnight()

Just put that in your macro. If you want to see what's firing:

/run RogueKnight("v1")

To make a separate macro for being behind the target,

/run RogueKnight("","behind")

HuBu

Beginner

Posts: 6

Location: Florida

  • Send private message

100

Friday, March 12th 2010, 7:25pm

Thank you kind sir!

Quoted from "Sixpax;242059"

Here's a little tip for you that will simplify your code a bit. In your ChkBuffTime() function, have it "return 0" at the end instead of "return false". That way for buffs that you don't have on you'll still get a number. So you'll only need to do the ChkBuffTime() check. Also, if you're making a buffing function, you can define all the buffs you want to cast and have it cycle through all of them until it finds one you're missing. So you won't need to have separate if/then statements for each one. For instance: