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,381

Tuesday, January 27th 2015, 3:53am

I guess what I don't understand about g_lastaction is what is it local to? If that makes sense...i don't have enough knowledge to phrase my question right....

a local variable in a function exists only for that function. So what contains the local g_lastaction? For some reason the term scope comes to mind even though I don't really know what scope is....hope you understand my question lol.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

1,382

Tuesday, January 27th 2015, 4:16am

Scope is the correct term. Basically it is the "visibility" of an entity. The highest level scope is global space. Anything at a lower level can "see" things defined above it. Therefore, a function can "see" global variables, but global space cannot "see" variables defined locally within a function (well in general, there are exceptions).

Now the other aspect that you need to realise is that a Lua file is treated as if it is a pseudo-function. That is, when Lua loads a file, it actually executes that file. In terms of variable scoping, this means that variables defined in the file but outside a function is local to that file. So functions declared in the file can see it, but global space cannot.

Another layer down, any variables declared inside while loops, for loops, if statements and do statements are also declared locally to that specific code block. Actually anything declared within something that has an end statement is declared locally to that code block.

There are also "hidden" local variables. For instance, the control variables of a for loop are declared locally to that for loop (even without specifically declaring them). For example:

Source code

1
2
3
4
5
6
7
8
9
local i = 3

-- i is 3 here

for i = 1, 5 do
   -- the i here is not the same and will go from 1 to 5
end

-- i here is the local declared above and is still 3
2013... The year from hell....

1,383

Tuesday, January 27th 2015, 4:29am

Oki, ty for lesson. I'd have to move some of the if statements like the targetting sections from customfunctions to diyce.lua if i want to use local variables for my timer fixes.

Peryl

Intermediate

Posts: 313

Location: Elsewhere

  • Send private message

1,384

Tuesday, January 27th 2015, 6:14pm

Not really. There are all kinds of fun ways around this.

As mentioned previously, you can use the global to local optimizatin trick. Consider the following:
First, we define a global that is a table of "local" variables.

Source code

1
MyShareableVars = { ack = 0, oop = 1, somethingelse = false }


Now to get at these variables as locals, define the following where you want access to them:

Source code

1
local vars = MyShareableVars  -- assign local vars to access the global


Finally, to access each variable, we do (as an example)

Source code

1
2
3
if not vars.somethingelse then
  vars.ack = 2 + vars.oop
end


For an even cleaner way of doing something like this (and somewhat transparent in its use), it is possible to actually set the environment (i.e. where Lua stores its local variables and functions). See how I did the script apartments in FD. It is defined in FD_Script.lua and an example use is in the FuzzyScriptDemo plugin's FuzzyScript.lua. Alos the core's FD_Apartment.lua defines the ScriptEnv special functions that handle a few extra things.
2013... The year from hell....

This post has been edited 1 times, last edit by "Peryl" (Jan 27th 2015, 6:21pm)


1,385

Wednesday, February 11th 2015, 12:15pm

Hi there Guys,
I have an issue with my DIYCE that I could not resolve so far ... maybe some of you could have a look and suggest what is it I'm doing wrong ... ?

I'd like for DIYCE to remove some stun effects during Siege. The default BuffList function in diyce.lua only acquires player buffs / enemy's debuffs, so I added a second function there as follows (it's basically slightely modified original BuffList function):

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function DebuffList(tgt)
	local dlist = {}
	local buffcmd = UnitDebuff
	local infocmd = UnitDebuffLeftTime

	-- 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
        	dlist[buff:gsub("(%()(.)(%))", "%2")] = { stack = stackSize, time = timeRemaining or 0, id = ID }
        	-- We also list by ID in case two different buffs/debuffs have the same name.
        	dlist[ID] = {stack = stackSize, time = timeRemaining or 0, name = buff:gsub("(%()(.)(%))", "%2") }
    	else
        	break
    	end
	end

	return dlist
end


I have then defined a local 'pbuffs' in CustomFunctions.lua:

Source code

1
local pbuffs = BuffList("player")


pasted wrong line - sorry. Should be:

Source code

1
local pdbuffs = DebuffList("player")


and finally tried to use it in mycombat script:

Source code

1
{ name = "Overrule", use = (EnergyBar1 >= 20) and (pdbuffs[503837]) }, --503837 is lightning debuff



Having it configured this way, my DIYCE uses Champ skill Overrule when I get hit by lightning.
It does however only work once (as in, the first time I use it after loging in) and than it does not work anymore untill I relog ...

Any ideas ?
thx for yr help
---
-= Cath =-
--- TurksPower ---
Hayabuzza Ch/R/P

This post has been edited 1 times, last edit by "pkkozza" (Feb 11th 2015, 3:47pm)


1,386

Wednesday, February 11th 2015, 2:36pm

Just a shot in the dark...Do you have a Debuff List created in your CustomFunctions.lua?

Somewhere around page 50 of this thread there was a discussion about creating one, but, it never came to the light of day (as far as I know). I have been trying to work one up for myself as well.

Good Luck.
SirMasterBlue
Areafiftyone GL
Your roving muse reporter
K60/R60
Artemis

1,387

Wednesday, February 11th 2015, 3:18pm

As SirMasterBlue said, you need to define local pDebuffs = DebuffList("player") in custom functions KillSequence() (we use "player" in parenthesis to always get player debuff -- if we use "target" then we end up building debuff list of enemies when we have an enemy targetted).

"pbuffs" variable is already used in custom functions so you need a new name for debuff list, and you need to actually call your "Debuff list" function, not the original diyce function.

Then for a skill you used put use = pDebuffs[503837] (or w/e variable you used earlier to get the debuff list)


Ofc you could simply alter the Original BuffList() function to get player debuffs (and/or target buffs) and then use the original variables pbuffs and tbuffs.

This post has been edited 1 times, last edit by "BlankMinded" (Feb 11th 2015, 3:23pm)


1,388

Wednesday, February 11th 2015, 3:49pm

yes, sorry, I mis-copied a line.
I already have it defined as:

Source code

1
local pdbuffs = DebuffList("player")


Otherwise it's clear it should not work ...
So the question still stands.

p.s. I edited my previous post.

thx
---
-= Cath =-
--- TurksPower ---
Hayabuzza Ch/R/P

1,389

Wednesday, February 11th 2015, 5:05pm

Sure you have everything define in the right place? I managed to get it to work on my champion/warlock.

First i copied/pasted your debuff function into Diyce.lua underneath the BuffList function.

Then In Customfunctions.lua, I went to KillSequence() function, and at the top underneath "local pbuffs = ...." i added in a variable local pdebuffs = DebuffList("player")

Then I went to c/wl section and added

Source code

1
{ name = "Overrule",				use = EnergyBar1 >= 20 and pdebuffs[503628] },


where 503628 is debuff id of thorny vines (debuff i was using to check). It casted just fine multiple times.

1,390

Wednesday, February 11th 2015, 7:14pm

Just double checked and this is exactly how I have it in my DIYCE as well.
Tried to use Overrule or Vacuum Wave and any of them work for first usage only and get skipped on later attempts.

(whichever skill is used first works, but 2nd skill doesn't. So if I relog and try using Overrule it will work on lightning debuff, however Vacuum Wave will not work on 2nd attempt, few seconds later ...)

My DIYCE is a bit modified so I will download a new copy and will try it again. Maybe I'm missing a coma or a bracket somewhere and it is somehow messing up with my script.
---
-= Cath =-
--- TurksPower ---
Hayabuzza Ch/R/P

1,391

Wednesday, February 11th 2015, 8:00pm

Is there any kind of error message?

Before you replace your code, try running in debug mode or at least set your arg1 to "v1" or "v2" and see if it is trying to fire the second time.
SirMasterBlue
Areafiftyone GL
Your roving muse reporter
K60/R60
Artemis

1,392

Monday, February 16th 2015, 6:50pm

How do i get psychic arrows to cast once before puzzlement (chance of damage prot). I've been working on wl/ch diyce and i cannot get this one thing to work and it's driving me crazy :dash: . Any help would be appreciated.


Source code

1
2
3
4
5
6
Source Code
{ name = "Custom: Puzzlement", use = ((EnergyBar1 >= 20) and (tbuffs["Weakened"]) and (g_lastaction ~= "Custom: Psychic Arrows")) },
{ name = "Heart Collection Strike", use = ((EnergyBar1 <= 50) and (tbuffs["Weakened"]))},
{ name = "Warp Charge", use = ((EnergyBar1 >= 30) and (not pbuffs["Ancient Spirit Water"])and (not pbuffs["Warp Charge"])) },
{ name = "Custom: Psychic Arrows", use = (PsiPoints <= 6) },
}


Govinda - Bteam
Duvalier M/W/K/R/P/S
Bazzinga WL/CH/M/W/R/P
:beer:

Auros

Professional

Posts: 1,360

Mood: Mellow

  • Send private message

1,393

Monday, February 16th 2015, 9:25pm

I do not see how you could get what you want with that code.
You are not going to cast puzzlement or HCS unless you are depending on someone else to cast "Weakening Weave Curse" to put your target in the "weakened" state.
It looks to me like you will cast Warp Charge and follow with Psychic arrows until warp charge comes up again, rinse and repeat, until psi =>6 then a lot of standing around. I assume you then take manual control to cast either of the two psi states.

Or, are you planning on starting off with Weakening Weave Curse (WWC) as a manual cast prior to starting DIYCE, in which case you might as well add the one psychic arrow as part of the manual cast sequence.

Also, isn't the damage proc you are looking for due to WWC and not PA? In which case add a cast line under the Warp Charge line to cast WWC.
Govinda P/W/K/M 100x4 :pump:
Wl/R/M/Ch 100x4 :borg:
Wd/W/S 100/100/100
W/M 100/100 Glass Cannon: oh gawd, not again :pinch: ... and numerous others Semi-retired :pillepalle:

Zerienga

King of the Noobs

Posts: 1,027

Location: Reni & US IRC

  • Send private message

1,394

Monday, February 16th 2015, 9:30pm

As wl/ch, their Psychic Arrows has a chance to boost their magic damage.
Reni
Mithras
Zerienga - 90/90 P/K
Téster - 95/61/60/45/45 CH/WL/R/P/M
Dontkillimascout - 90/61 WL/P

If you want to contact me quickly and efficiently, try the US IRC channel.
No, I don't know everything. I just use my knowledge to form educated guesses
And I listen when others say I am wrong in order to learn.

1,395

Monday, February 16th 2015, 10:19pm

I do not see how you could get what you want with that code.
You are not going to cast puzzlement or HCS unless you are depending on someone else to cast "Weakening Weave Curse" to put your target in the "weakened" state.
It looks to me like you will cast Warp Charge and follow with Psychic arrows until warp charge comes up again, rinse and repeat, until psi =>6 then a lot of standing around. I assume you then take manual control to cast either of the two psi states.
I originally did not post the whole thing. but here's what i have been messing with so far. It all works fine except for my attempts of having psychic arrows cast once before using puzzlement. For some reason my g_lastaction command isn't working correctly.

Source code

1
2
3
4
5
6
7
8
9
if enemy then 	Skill2 = {
{ name = "Willpower Blade", 		use = (PsiPoints == 6) and (not pbuffs["Saces' Impulse"]) },
{ name = "Saces' Impulse", 		use = ((pbuffs ["Willpower Blade"]) and (PsiPoints >= 2) and (not pbuffs["Saces' Impulse"])) },
{ name = "Weakening Weave Curse", 	use = ((EnergyBar1 >= 20) and (not tbuffs["Weakened"])) },
{ name = "Electrocution", 		use = ((EnergyBar2 >= 20) and (not tbuffs["Electrocution"])) },
{ name = "Custom: Puzzlement",          use = ((EnergyBar1 >= 20) and (tbuffs["Weakened"]) and (g_lastaction ~= "Custom: Psychic Arrows")) },
{ name = "Heart Collection Strike", 	use = ((EnergyBar1 <= 50) and (tbuffs["Weakened"]))},
{ name = "Warp Charge", 		use = ((EnergyBar1 >= 30) and (not pbuffs["Ancient Spirit Water"])and (not pbuffs["Warp Charge"])) },
{ name = "Custom: Psychic Arrows", 	use = (PsiPoints <= 6) },	}	end
Govinda - Bteam
Duvalier M/W/K/R/P/S
Bazzinga WL/CH/M/W/R/P
:beer:

1,396

Tuesday, February 17th 2015, 1:31am

Hopefully you know this already (and have simply forgotten), but Diyce starts at the top and goes down your list of skills defined in Skill2 table every press of the macro. If you didn't know that already, I suggest you read addon documentaion (specifically details how they work, such as the very first post of this thread) better so you can use them more effectively yourself. So with that said let's take a moment to consider what order your diyce will trigger in...

---Assuming a Boss Fight -----
I've also assumed that you will have already manually buffed Saces' Impulse during a boss countdown, and pertinent potions such as ancient spirit water, and full rage/focus.

1) Willpower/saces' impulse conditions are false, so we now check weave cuse, see it use conditions are true and cast it. Weakened debuff now applied, and roughly 80 focus left.

2)We have Weakened debuff, so weave curse is false. Check electrocution, it passes, cast Electroctuion. Electrocution debuff applied, Weakend has 14s left, rougly 80 rage and 85 focus left.

3) We have both debuffs, so now we check Puzzlement conditions. g_lastaction hasn't changed from the initial value (which is nil [think of nil as being nothing, a variable with no value assigned], so it is "not" psychic arrows. So we now use Puzzlement. 1s less on respective debuffs, roughly full rage/75 focus. g_lastaction becomes puzzlement.

4) Heart Collection strike. 1s les on debuffs, Full rage, 80 focus

5) we assumed we have ancient spirit water, so skip warp charge. Go to Custom:psychic arrows, after this is cast g_lastaction changes to psychic arrow.

What you want to have happen is step 3 to be psyhicc arrow, then step 4 puzzlement and step 5 HCS. So, remembering diyce starts at the top of the list every time you press it, you'd want to put Custom:psychic arrows before puzzlement. Then, we move the g_last action check from the puzzlement line, into the arrows line, to prevent it from casting 2 times in a row.

This post has been edited 4 times, last edit by "BlankMinded" (Feb 17th 2015, 1:40am)


1,397

Tuesday, February 17th 2015, 2:36am

Thank you! after some tweaking i finally got it working. :thumbsup: I had the Custom: psychic arrows before the puzzlement but couldn't get it working last night so I assumed i had something different messed up.
Govinda - Bteam
Duvalier M/W/K/R/P/S
Bazzinga WL/CH/M/W/R/P
:beer:

1,398

Tuesday, February 17th 2015, 3:26pm

Was trying to do this with my wl/ch diyce also. So thanks for some tips will tweak mine later also!
99/99/99/99/99/99 W/WD/S/D/R/M

1,399

Sunday, March 22nd 2015, 8:55pm

So I've been using functions within my DIYCE, but I get "Skill not available: Function: X" in chat, but the function still works properly. Anyone else run into that problem?

1,400

Sunday, July 19th 2015, 5:13pm

Hello,

Looking for some help here again since I've started playing s/r again. I have discussed this issue in previous posts in this thread and for me, the script used to work. For some reason now it does not.

I currently have the latest DIYCE scripts loaded from Curse. Below is a snip of the code I am using for s/r, the portion concerns a timer for Exploiting shot

Source code

1
2
3
4
5
6
7
8
9
CreateDIYCETimer("ExploitCooldown", 32, false)
 
                if (enemy and (mode == "DPS")) then
                Skill2 = {
	{ name = "Timer: ExploitCooldown",         use = (tbuffs['Exploiting Shot']), timer = "ExploitCooldown" },
	{ name = "Snipe",                          use = true },						
	{ name = "Sapping Arrow",                  use = true },						
	{ name = "Autoshot",                       use = (not ASon) },
	{ name = "Shot",                           use = (GetDIYCETimerValue("ExploitCooldown") == 0) },



Here is my problem: In an earlier post on this thread (post 859), quoted below

Quoted


Well it looks like you aren't using the timers properly.

I'd recommend the following changes.
First remove the first entry (the "Timer: ExploitCooldown" line), it is redundant.

Second, change the Shot line to:

Source code
1
{ name = "Shot", use = true, timer = "ExploitCooldown" },

Also, check that there isn't a call to StartDIYCETimer() in the KillSequence function.

I think this may fix the delays, though I can't be certain.


The problem I still have is the fact that shot needs to continue to fire initially until a crit occurs, then Exploiting shot triggers. With the line of code above from Peryl, anytime shot happens, crit or normal, the timer starts. If it did not crit, then the Tbuff does not occur.

Also, a little info about how it works, once shot crits, Exploiting Shot tbuff activates for 12 seconds, after the 12 seconds is up, there is a 20 second cooldown, for a total of 32 seconds.

This code I quoted at the top of the post used to work for me but I believe it was an older version of DIYCE. In that code, should only fire if the timer = 0, otherwise, it should skip shot.

Any help on why my code doesn't work now would be greatly appreciated.
Jacobmo 97Scout/97Warden/95Warrior/97Rogue/88D/85M
Allenmo 78S/77R/56P/1W/1K/1M - retired
Bteam all the way

This post has been edited 1 times, last edit by "mohjo" (Jul 19th 2015, 5:20pm)

This post has already been reported.