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.

1,341

Friday, February 4th 2011, 6:35pm

I know the original snippit from this thread didn't have the index in it.
I'm quite sure this code below it 'up to snuff'. I think you were referencing the index as being the "Skill" portion of the code?

Are these numbers Action Bar slots or Backpack slots? maybe that could be the problem. Even though I think I"ve been quite thorough in testing both.

I can certainly do the "potion name" instead, but I read earlier that it will check for cooldown if I use the slot #. Seems cleaner to try and get this line of code working.

I'm certain that I've got something wrong on my end.

Should I state:

local mana = PctS("player")
and command as
i=i+1; Skill[i] = { name = "Action: 34 (bleh)", use = (mana("player") <= .75) }

Sorry for the hassles friends!

[i]

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
function KnightCombo2(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")
    local health, buffs
    if friendly then
        health = PctH("target")
        buffs = tbuffs
    else
        health = PctH("player")
        buffs = pbuffs
    end
    i=i+1; Skill[i] = { name = "Action: 34 (Mana)",    use = (PctS("player") <= .75) }
 i=i+1; Skill[i] = { name = "Action: 36 (Health)",  use = (PctH("player") <= .75) }
 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 = "Holy Shield",          use = (health <= .55) }
 i=i+1; Skill[i] = { name = "Urgent Heal",          use = (health <= .75) }
    i=i+1; Skill[i] = { name = "Regenerate",           use = ((health <= .85) and (not string.find(buffs, "Regenerate"))) }
    i=i+1; Skill[i] = { name = "Shield of Atonement",  use = ((not friendly) and shield) }
    i=i+1; Skill[i] = { name = "Whirlwind Shield",     use = ((not friendly) and shield) }
    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
[/QUOTE]

Kethgwan

Beginner

Posts: 0

Location: Nottingham, UK

  • Send private message

1,342

Saturday, February 5th 2011, 3:45pm

I guess it was my computer that was being buggy, it had been on for about a week or two without being restarted - once I restarted it everything started to work again lol.

Thanks for the help though!
-Kethgwan-
-Insurgence-
-Grimdal - PVP-
-Rogue - 62 | Scout - 62-

~39,452 Physical Attack (unbuffed)~
~51,041 Hit Points (unbuffed)~

1,343

Monday, February 7th 2011, 10:35pm

Does anyone know how long it takes the script to find, and exicute a skill, in MS?

like is there any CD built in anywhere?

ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1,344

Tuesday, February 8th 2011, 12:33am

IIRC and If I recall correctly, Sixpax did some tests one time and said something to the effect of 15ms per rotation.

1,345

Tuesday, February 8th 2011, 2:02pm

Quoted from "SNeekey;385811"

Does anyone know how long it takes the script to find, and exicute a skill, in MS?

like is there any CD built in anywhere?


Make your macro like so:

/run Msg("Start: "..GetTime())
/run YourFunction("v1")
/run Msg("End: "..GetTime())

That will show a precise time value (I think it's actually the number of seconds since your computer started up) before and after it has executed, so just take the difference. Make sure it actually executes a skill. You might want to run it numerous times to get a good range, because it will vary.

My guess is the times will be between 0.2 and 0.4 seconds. Please let me know what results you get.

1,346

Wednesday, February 9th 2011, 2:20am

Is there a script to not have a certain skill cast until another one is not on cooldown? tried looking a little through this but 135 pages is a little much =P
Server: Osha
Guild: Straitheart
Roguewind 70 R/S

ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1,347

Wednesday, February 9th 2011, 3:51am

Actually that was being worked on, can't recall how far back it was. Wasn't too far though. Wont take you long to find it.

1,348

Wednesday, February 9th 2011, 9:52am

Quoted from "Sixpax;386018"

Make your macro like so:

/run Msg("Start: "..GetTime())
/run YourFunction("v1")
/run Msg("End: "..GetTime())

That will show a precise time value (I think it's actually the number of seconds since your computer started up) before and after it has executed, so just take the difference. Make sure it actually executes a skill. You might want to run it numerous times to get a good range, because it will vary.

My guess is the times will be between 0.2 and 0.4 seconds. Please let me know what results you get.


I used code you posted there. In every test i preformed it returned the same number. That would indicate that it is less than 25ms to run. As that is the smallest unit the GetTime function will measure.

That means that diyce is nearly 100% efficient

1,349

Wednesday, February 9th 2011, 10:24am

Declare Global Variable?

I'm using a single file with different functions inside said file for all my characters. The code is getting rather long having to declare redundant variables in each individual function.

Source code

1
2
3
local combat  = GetPlayerCombatState()
local dead    = UnitIsDeadOrGhost("target")
local enemy   = UnitCanAttack("player","target")
Above are a few that always have the same meaning, regardless of what class you are playing.

Is there some way to declare these globally outside the individual class functions? Is there a reason one would not want to do this?

1,350

Wednesday, February 9th 2011, 1:54pm

Quoted from "mots;386403"

Is there a script to not have a certain skill cast until another one is not on cooldown? tried looking a little through this but 135 pages is a little much =P


There's a function called "CD" in the DIYCE code which will return a true if the skill is ready and false if it's not (still on cooldown). Because of the name, it's very easy to confuse it with asking if the skill is on cooldown (sorry for that, it made sense when I made it lol). So just think of it as a "is the skill ready?" check.

You just pass it the skill name as a string. So let's say you want to use a skill called ThisSkill if another skill called ThatSkill is ready, then you'd code it this way:

i=i+1; Skill = { name = "ThisSkill", use = CD("ThatSkill") }

So ThisSkill won't get used until ThatSkill is also available to be used.

1,351

Wednesday, February 9th 2011, 2:03pm

Quoted from "firescue17;386494"

I'm using a single file with different functions inside said file for all my characters. The code is getting rather long having to declare redundant variables in each individual function.

Source code

1
2
3
local combat  = GetPlayerCombatState()
local dead    = UnitIsDeadOrGhost("target")
local enemy   = UnitCanAttack("player","target")
Above are a few that always have the same meaning, regardless of what class you are playing.

Is there some way to declare these globally outside the individual class functions? Is there a reason one would not want to do this?


The problem with making them globals is you still have to set the values for those variables inside your individual class functions so they get updated every time you run it. Declaring them as globals really doesn't do much for you, unless you're using those same values in another function that's called by your class function.

ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1,352

Wednesday, February 9th 2011, 3:55pm

Quoted from "Sixpax;386511"

There's a function called "CD" in the DIYCE code which will return a true if the skill is ready and false if it's not (still on cooldown). Because of the name, it's very easy to confuse it with asking if the skill is on cooldown (sorry for that, it made sense when I made it lol). So just think of it as a "is the skill ready?" check.

You just pass it the skill name as a string. So let's say you want to use a skill called ThisSkill if another skill called ThatSkill is ready, then you'd code it this way:

i=i+1; Skill = { name = "ThisSkill", use = CD("ThatSkill") }

So ThisSkill won't get used until ThatSkill is also available to be used.

That works if you want to use ThisSkill while ThatSkill is on cooldown. However if you want to only use ThisSkill if ThatSkill is ready, then you would want your code to look like this:
i=i+1; Skill[i] = { name = "ThisSkill", use = (not CD("ThatSkill")) }

1,353

Wednesday, February 9th 2011, 5:45pm

Quoted from "ghostwolf82;386539"

That works if you want to use ThisSkill while ThatSkill is on cooldown. However if you want to only use ThisSkill if ThatSkill is ready, then you would want your code to look like this:
i=i+1; Skill = { name = "ThisSkill", use = (not CD("ThatSkill")) }


No, the would try to use ThisSkill if ThatSkill is not ready. I know it's confusing and I'm sorry I didn't give it more thought when I created the function, but CD() returns true if the skill is NOT on cooldown (i.e. true = skill ready).

If it makes things easier, just make a copy of it and call it something else:

Source code

1
local SkillReady = CD

ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1,354

Wednesday, February 9th 2011, 6:27pm

Well, for my W/R I used this to determine if PA was on CD, if it is, then use SS.

Source code

1
i=i+1; Skill[i] = { name = "Shadowstab", use = ((energy >= 20) and (not CD("Probing Attack"))) }


Edit: Just realized my original logic was backwards. :p Anyways, the code posted here does as intended and will check if PA is on CD, if so, then SS.

1,355

Saturday, February 12th 2011, 6:12am

How to call arg2 or arg3

Hello Sixpax
Im using this macro for scout/knight, i have commented out some of the skills that knight sub doesnt have. I'd like to know how to call the arg2 for "boss" fight.

Thanks alot

Quoted from "Sixpax;366484"

I gave your code the once-over and found a whole bunch of errors. I corrected as many as I spotted, so give this a try:

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
function ChkArg(arg1, skillname)
    arg1 = arg1 or ""
    return (string.find(arg1, skillname) ~= nil)
end
 
function ScoutWarden(arg1,arg2,arg3)
    local Skill = {}
    local i = 0
    local focus = UnitMana("player")
    local mana = UnitSkill("player")
    local friendly = (not UnitCanAttack("player","target"))
    local combat = GetPlayerCombatState()
    local myhealth = PctH("player")
    local pbuffs = BuffList("player")
    local tDead = UnitIsDeadOrGhost("target")
    local LockedOn = UnitExists("target")
    local a1,a2,a3,a4,a5,ASon = GetActionInfo(61)  -- # is your Autoshot slot number
 
    if (myhealth <= .1) then
        SwapEquipmentItem()
        for j=1,3 do
            if IsPetSummoned(j) then
                ReturnPet(j)
            end
        end      
        CastSpellByName("Elven Amulet")
        return true
    end
 
    i=i+1; Skill[i] = { name = "Blood Arrow", use = (ChkArg(arg2,"boss") and combat and (not ChkArg(pbuffs, "Blood Arrow")) and (myhealth >= .75)) }
    i=i+1; Skill[i] = { name = "Blood Arrow", use = (ChkArg(pbuffs, "Blood Arrow") and ((not combat) or (myhealth <= .25))) }
    i=i+1; Skill[i] = { name = "Savage Power", use = (ChkArg(arg2,"boss") and combat and (not ChkArg(pbuffs, "Savage Power"))) }
    i=i+1; Skill[i] = { name = "Arrow of Essence", use = (ChkArg(arg2,"boss") and combat) }
    i=i+1; Skill[i] = { name = "Concentration", use = (ChkArg(arg2,"boss") and combat and (not ChkArg(pbuffs,"Concentration"))) }
    i=i+1; Skill[i] = { name = "Action: 62 (Archer's Glory)", use = (ChkArg(arg2,"boss") and combat and (not ChkArg(pbuffs, "Archer's Glory"))) }
    i=i+1; Skill[i] = { name = "Autoshot", use = ((not friendly) and (not ASon)) }
    i=i+1; Skill[i] = { name = "Serenity", use = ( ChkArg(arg2,"boss") and (not CD("Concentration")) and (not ChkArg(pbuffs,"Concentration")) and (UnitMana("player")<15)) }
    i=i+1; Skill[i] = { name = "Item: Focus Potion", use = (ChkArg(arg2,"boss") and combat and (focus <= 10)) }
 
    i=i+1; Skill[i] = { name = "Briar Shield", use = (ChkArg(arg3,"consume") and (not ChkArg(pbuffs,"Briar Shield"))) }
    i=i+1; Skill[i] = { name = "Entling Offering", use = (ChkArg(arg3,"consume") and (not ChkArg(pbuffs,"Entling Offering"))) }
    i=i+1; Skill[i] = { name = "Item: Roast Wolf Leg", use = (ChkArg(arg3,"consume") and combat and (not (ChkArg(pbuffs,"Informer") or ChkArg(pbuffs,"Roast Wolf Leg")))) }
    i=i+1; Skill[i] = { name = "Item: Frenzy Potion", use = (ChkArg(arg3,"consume") and combat and (not ChkArg(pbuffs,"Frenzy Potion"))) }
    i=i+1; Skill[i] = { name = "Item: Strong Stimulant", use = (ChkArg(arg3,"consume") and combat and (not ChkArg(pbuffs,"Strong Stimulant"))) }
 
    i=i+1; Skill[i] = { name = "Briar Shield", use = (not ChkArg(pbuffs,"Briar Shield")) }
    i=i+1; Skill[i] = { name = "Entling Offering", use = (not ChkArg(pbuffs,"Entling Offering")) }
    i=i+1; Skill[i] = { name = "Shoot", use = (not friendly) }
    i=i+1; Skill[i] = { name = "Snipe", use = (ChkArg(pbuffs,"Hidden Peril")) }
    i=i+1; Skill[i] = { name = "Combo Shot", use = (not friendly) }
    i=i+1; Skill[i] = { name = "Thorn Arrow", use = (not friendly) }
    i=i+1; Skill[i] = { name = "Hidden Peril", use = (not friendly) }
    i=i+1; Skill[i] = { name = "Wind Arrows", use = ((not friendly) and (focus >= 15)) }
 
 
    MyCombat(Skill,arg1)
 
    if (tDead) or (not LockedOn) or friendly then
        TargetNearestEnemy()
    end    
end
Also, whenever you run your code and it doesn't work, be sure to look for a red flashing icon by the minimap and click on it. That will give you some indication of syntax errors and the line number they occur on.

Also, just in case you're not aware of this, that function relies on passing certain text strings to it as the 2nd and 3rd argument in your macro. Let me know if you don't understand what that means and I'll explain further.

1,356

Saturday, February 12th 2011, 11:38pm

Quoted from "trucly363;387584"

Hello Sixpax
Im using this macro for scout/knight, i have commented out some of the skills that knight sub doesnt have. I'd like to know how to call the arg2 for "boss" fight.

Thanks alot


arg1, arg2, and arg3 are passed to the function when you call it. arg1 is typically used as a feedback setting for the engine itself. So if you want arg2 to be "boss", then your macro would look like this:

/run ScoutWarden("","boss")

A better way to do this however would be to let the code determine if you're fighting a boss or not. So within that function you could just have this:

Source code

1
2
3
if UnitSex("target") > 2 then
   arg2 = "boss"
end
The UnitSex function returns a number if the unit passed to it is a mob, and a value higher than 2 is a boss. Doing it this way you don't have to pass the "boss" value to the function.

potato221

Trainee

Posts: 98

Location: In America

Occupation: Student

Mood: Smile

  • Send private message

1,357

Monday, February 14th 2011, 10:42pm

DIYCE help

Can anyone tell me why this wouldn't work? I'm getting no error messages in game, just nothing happens.

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
function WardenWarrior(arg1, hpotslot, mpotslot)
    local Skill = {}
    local i = 0
    local combat = GetPlayerCombatState()
    local friendly = (not UnitCanAttack("player", "target"))
    local enemy = (UnitCanAttack("player","target")) 
    local mana = UnitMana("player")
    local rage = UnitSkill("player")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")
    local front = UnitIsUnit("player", "targettarget")
    local tDead = UnitIsDeadOrGhost("target")
    local melee = GetActionUsable(2)
    local LockedOn = UnitExists("target")
    local _1,potcd

    if hpotslot ~= nil then
        _1,potcd=GetActionCooldown(hpotslot)
   end

    if mpotslot ~= nil then
        _1,potcd=GetActionCooldown(mpotslot)
   end

   if (PctH("player")<.50) and (potcd == 0) then
      UseAction(hpotslot)
      return
   end

   if (PctM("player")<.50) and (potcd == 0) then
      UseAction(mpotslot)
      return
   end

    i=i+1; Skill[1] = { name = "Charged Chop",		use = (enemy and melee and (not combat)) }
    i=i+1; Skill[i] = { name = "Slash",              use = (enemy and melee and (rage >= 25) and (not string.find(tbuffs,"/Bleed/"))) }
    i=i+1; Skill[i] = { name = "Beast Chop",		use = (enemy and melee and (rage >= 20) and (string.find(tbuffs,"/Bleed/"))) }
    i=i+1; Skill[i] = { name = "Power of the Wood Spirit"	use = (enemy and melee) }
    i=i+1; Skill[i] = { name = "Attack",             use = (enemy or tDead or (not combat and not enemy)) }
        
        MyCombat(Skill,arg1)

    
    if (not LockedOn) then
        TargetNearestEnemy()
    end
    
    if LockedOn and (not enemy) then
        TargetNearestEnemy()
    end
end

ghostwolf82

Professional

Posts: 859

Location: Kalvans Trunk

Occupation: It's dark in here

  • Send private message

1,358

Tuesday, February 15th 2011, 4:03am

Give this a try potato:

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
function WardenWarrior(arg1, hpotslot, mpotslot)
    local Skill = {}
    local i = 0
    local combat = GetPlayerCombatState()
    local enemy = (UnitCanAttack("player","target")) 
    local mana = UnitMana("player")
    local rage = UnitSkill("player")
    local tbuffs = BuffList("target")
    local pbuffs = BuffList("player")
    local tDead = UnitIsDeadOrGhost("target")
    local melee = GetActionUsable(2)
    local LockedOn = UnitExists("target")

        hpotslot = hpotslot or 0
        mpotslot = mpotslot or 0

        i=i+1; Skill[i] = { name = "Action: "..mpotslot,        use = (pctmana <= .50) }
        i=i+1; Skill[i] = { name = "Action: "..hpotslot,        use = (phealth <= .50) }

    if enemy and melee then
        i=i+1; Skill[1] = { name = "Charged Chop",                    use = (not combat) }
        i=i+1; Skill[i] = { name = "Slash",                          use = (rage >= 25) and (not string.find(tbuffs,"/Bleed/")) }
        i=i+1; Skill[i] = { name = "Beast Chop",                    use = (rage >= 20) and (string.find(tbuffs,"/Bleed/")) }
        i=i+1; Skill[i] = { name = "Power of the Wood Spirit"        use = true }
    end
    
        i=i+1; Skill[i] = { name = "Attack",                         use = (enemy or tDead or (not combat and not enemy)) }
        
        MyCombat(Skill,arg1)

    
        if (tDead) or (not LockedOn) or (not enemy) then
            TargetNearestEnemy()
        end
end

Drake1132

Beginner

Posts: 11

Location: Wait a minute... you mean I'm *not* a figment of your imagination?

  • Send private message

1,359

Tuesday, February 15th 2011, 10:12am

Also try using "v2" for arg1 in your macro for more feedback information. This can sometimes help identify where a problem might be. And make absolutely sure that your lua files are encoded as ANSI, *not* UTF8. For some reason, the code error reporting system, that's the system that would normally give you a red circle icon at your minimap if you have a lua code error, like a missing parenthesis, for some reason that system refuses to correctly interpret problems if your lua file is UTF8-encoded. If you are using Notepad++, you can make sure your encoding is ANSI by going to the Encoding menu and clicking on Convert to ANSI, and then saving the file again.

That should help with any debugging you may need to do in the future.

potato221

Trainee

Posts: 98

Location: In America

Occupation: Student

Mood: Smile

  • Send private message

1,360

Tuesday, February 15th 2011, 9:07pm

Ok, I tried using the code Ghostwolf suggested and same result, nothing happened, no error message. I then tried the v2 as Drake suggested and am getting an error stating that I'm calling a nil value. The lua file is named in the toc file and the function is spelled correctly in my macro, I have no idea what's wrong. Any suggestions?