Jump to content

Snippets of LUA codes (for FightClass)


Droidz

Recommended Posts

For Rogue (mostly Combat Rogue) :

 

(Discussions about the snippets in the correspondending Threads)

 

  • Set your poisons out of combat.
  • Manage Redirect and Marked for Death
  • : Use all 4 abilitys to kick a spell. Kick, Blind, Gouge, Kidney Shot. (and Feint, if it is not kickable)
  • : All buffs at once
  • : From Stealth to Combat. Cheap Shot / Ambush, Garotte, Revealing Strike, Sinister (one of them do the job)
  • needs . Cheap Shot (stun), Kidney Shot (stun), Vanish, Cheap Shot (stun), Preparation, Vanish, Cheap Shot (stun), Kidney Shot (stun). I'am sure, your opponent will love you for this ;-)
  • 10 /use 13 and /use 14
  • . 30 Yards ! and no step closer...bye!

 

How to use the snippets: (looks more then it is)

  • click on the snippet you want
  • mark the whole code (from <FightClassSpell> to </FightClassSpell>)
  • CTRL-C (copy the marked code)
  • .
  • Go to your mrobot directory
  • open the fight class folder
  • right click on the file do you want to edit
  • Edit (or Edit with Notepad++, if you use Notepad++)
  • Go to the last line
  • CTRL-V (append the code to your fight class)
  • Save the new code
  • .
  • start the Fight Class editor
  • open the changed fightclass
  • move the new spell to the right place in the priority list

The Codes above are mostly LUA-Scripts without a LUA-Script with a LUA-Condition that needs never to be true. And they work fine! :-)

 

1.) Lua Script Spell.

With a Lua Script we can use our own fantasy Spell name, instead of a real script, because Lua Scripts are bad to be supported (insert,delete,insert) and they are very ugly in the settings window. So we use only a "--Short Description" as lua script. Because we don't have a real LUA script here, we use the comment signs "--" .

 

2.) Lua Script Condition.

The script here do the whole work. The local variable result is only needed to get a log-file entry. See also.

 

A description for the snippets are in the correspondending Threads

Link to comment
Share on other sites

  • 4 weeks later...

Activate/Deactivate spells of rotation with wow macro

 
In wow create new macro with this code:

/run if pausecooldown == 1 then pausecooldown = 0; print("pause desactivated") else pausecooldown = 1; print("pause activated") end

Now in your spell add condition script lua:
LuaScript:

if not (pausecooldown == 1) then resultCooldown = "canlaunch" else resultCooldown = "" end

Research:

canlaunch

Var:

resultCooldown

After, just click on macro to pause your spells.

 

PS: You can change variables name.

 

EDIT: Sample here: 

Link to comment
Share on other sites

  • 3 weeks later...

Here is my snippet for checking time left on buffs (on yourself).

_, _, _, _, _, duration, expirationTime, _, _, _, _ = UnitBuff("player","Inquisition");
t = GetTime();
timeRemaining = expirationTime - t;
if (timeRemaining <= 6) then retV = "1";
else retV = "0";
end

This will cast Inquisition when there is 6 seconds left on the buffs life. Great for spells that you want up 100% of the time. To get this to work, you might have to remove the line breaks, so it would actually look like..

_, _, _, _, _, duration, expirationTime, _, _, _, _ = UnitBuff("player","Inquisition");t = GetTime();timeRemaining = expirationTime - t;if (timeRemaining <= 6) hen retV = "1";else retV = "0";end
Link to comment
Share on other sites

  • 2 weeks later...

Here is a work-around for using spells that are off of the global cool down timer (my example is using Heroic Strike from a Warrior).

 

First, add a spell, I tend to name it Faux (Whatever the spell name is) so in this instance, it will be Faux Heroic Strike. It is ideal to place this up high on priority.

 

Next, add in your conditions. For Heroic Strike, I use Rage > 110.

 

Now add in an LUA script with the following information...

 

LUA Script: CastSpellByName("Heroic Strike");retV=1;

Return value research: 0

Return value var: retV

 

... This will trigger your spell to cast. The reason I set retV's value to 1, then check to see if it equals 0 is just to make sure WRobot doesn't try firing a fake spell named Faux Heroic Strike.

 

And boom, now your spell is completely off the GCD. Make sure the spell is off GCD before using this method, or else it will slow down your fight class and ruin your recount heroism.

Link to comment
Share on other sites

  • 3 weeks later...

Quick Search by buff list (useful for detecting poison, stunned ...)

 

LuaScript:


local idBuffs={13750,5004,433,121279,20572}
for key,value in pairs(idBuffs) do
	for i=1,40 do 
		local name, _, _, _, _, _, _, _, _, _, spellId = UnitBuff("player", i)
		if (value==spellId) then
			result=1
			return;
		end
	end
end
result=0

Research:


1

Var:


result

Replace spells id 13750,5004,... by your buff spells id needed.

Link to comment
Share on other sites

  • 6 months later...

Checking time left on buffs (on target)

 
LuaScript:
 

local name = GetSpellInfo(1079);
_, _, _, _, _, _, expirationTime = UnitDebuff("target", name);
timeRemaining = expirationTime - GetTime();
if (timeRemaining <= 7) then retV = "1"; else retV = "0"; end

Research:



1

Var:



retV

Replace 1079 by your spell id and "timeRemaining <= 7" by your condition (timeRemaining contain time left).

 

ps: to get buff/aura spell id you can use this script: 

Link to comment
Share on other sites

  • 1 month later...

Stack count

 
LuaScript:

returnResult = false;
local name = GetSpellInfo(53817);
local _, _, _, count = UnitBuff("player", name);
if count and count >= 5 then returnResult = true; end

Research:

true

Var:

returnResult

Replace 53817 by your spell id and "count >= 5" by your condition (count contain stack count).
 
ps: to get buff/aura spell id you can use this script: 

Link to comment
Share on other sites

  • 3 weeks later...

Target have buff/debuff

 
LuaScript:

returnResult = false;
local name = GetSpellInfo(53817);
local name = UnitDebuff("target", name);
if name then returnResult = true; end

Research:


true

Var:


returnResult

Replace 53817 by your spell id.
 
ps: to get buff/aura spell id you can use this script: 

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

Cast pet spell

local name = GetSpellInfo(2649);
if name then
	for i=1,50 do
		local spellName, spellSubName = GetSpellBookItemName(i, BOOKTYPE_PET)
		if spellName and spellName == name then
			CastSpell(i, BOOKTYPE_PET);
		end
	end
end

Replace 2649 by your spell id.

Put it is spell name, and activate option "Not spell, is lua script"

Link to comment
Share on other sites

  • 5 months later...

Calls function 'callback' after 'duration' seconds

http://wow.gamepedia.com/API_C_Timer.After

C_Timer.After(3, function() YOURCODEHERE end)

 

SAMPLE:

Moving backward during 2 secondes:

MoveBackwardStart()
C_Timer.After(2, function() MoveBackwardStop() end)

Sample of use: http://wrobot.eu/forums/topic/2482-shadow-priest-void-tendrils-help/?do=findComment&comment=11415

Link to comment
Share on other sites

  • 1 month later...

Cast spell if the shift/ctrl/alt key is currently depressed

LuaScript:

For Shift:

isKeyCurrentlyDown = IsShiftKeyDown();

For Ctrl:

isKeyCurrentlyDown = IsControlKeyDown();

For Alt:

isKeyCurrentlyDown = IsAltKeyDown();

Research:

true

Var:

isKeyCurrentlyDown

 

Link to comment
Share on other sites

  • 2 months later...

Get type of buff/debuff

 
LuaScript:

local name = GetSpellInfo(53817);
local name, rank, icon, count, debuffAuraType = UnitAura("player", name);

- you can replace player by UnitId

- Replace 53817 by your spell id.

Research:

Magic

or 

Disease

or

Poison

or

Curse

Var:

debuffAuraType


 
ps: to get buff/aura spell id you can use this script: http://wrobot.eu/forums/topic/1689-useful-scripts/?do=findComment%3Fcomment%3D8832

Link to comment
Share on other sites

  • 4 months later...

Check if any buff/debuff by type


LuaScript:

anyPoison = false;
for i=1,40 do
	local name, rank, icon, count, debuffAuraType = UnitAura("player", i);
	if name and debuffAuraType and debuffAuraType == "Poison" then
		anyPoison = true;
		return;
	end
end

- you can replace player by UnitId

- Replace 53817 by your spell id.

Research:

true

Var:

anyPoison

 

Wow API: http://wow.gamepedia.com/API_UnitAura

You can change "player" by "target" or "pet" or... to check target, pet... buff/debuff.

You can change "Poison" by "Magic", "Disease", "Curse".

Link to comment
Share on other sites

A better Buffcheck.

The charm of this check is:

  • you dont need to check all 40 possible buffs
  • you can access the buff with his name (clearer code)
  • and because you access with the name, you dont get trouble with change buff id's
  • and you can check simple buff combinations without check twice

 

 

		local Moonfire=GetSpellInfo(155625)
		local t=GetTime();
		local buffexp,buff,buffcnt={},{},{};
		local i,n,c,x,id,found=0;
		repeat 
			i=i+1;
			n,_,_,c,_,_,x,_,_,_,id=UnitAura("target",i,"PLAYER HARMFUL"); 
			if n then
				buffcnt[n]=c
				buffexp[n]=x-t
				buff[n]=id;
				found=true
			end
		until (not n) or (i==40);
		if found then
			if buff[Moonfire] then
				...
			end
		end

 

Link to comment
Share on other sites

  • 1 year later...

Feral Druid - Auto Cat Form (instead of walking) tested on 3.3.5

Basically this forces the character to go in cat form when the bot is walking at normal speed, or dismounted for whatever reason.

If character is mounted = do nothing (the mount is faster)

if character is NOT mounted, but moving with speed lower than the cat form speed = cat form (you move faster)
 

1) Put this in the "Add Spell" field:

-- Cat Shapeshift
CancelUnitBuff("player","Cat Form")
CastSpellByName("Cat Form")

2) Conditions:
- Me in Combat: false
- Lua Script: luascript

slowed = "no"
if GetUnitSpeed("player") > 0
and GetUnitSpeed("player") < 9
then
slowed = "yes"
end

Return value research: yes
Return value var: slowed

3) Spell Setting (top right corner)
- Can move during cast: yes
- Combat only: false
- Not Spell, is lua script: true

Tested and working pretty good, it can be used for shapeshifting slowing effects, just remove the "Me in combat: false" condition. Just keep in mind that

speed 0 = char not moving
speed 7 = char normal speed (walking)
speed 9 = cat form

You can mess around and see what works better for you. For example you can do an >= 0 instead of >0, in case you want the cat form also when you are not moving (maybe you are in a nova, root, so you can shapeshift it). As it is right now, it shapeshifts the moment you start walking.

Link to comment
Share on other sites

  • 3 years later...

Return Deadly Poison Stack Count

Lua script :

local PoisonName = {"Deadly Poison", "Deadly Poison II", "Deadly Poison III", "Deadly Poison IV", "Deadly Poison V", "Deadly Poison VI", "Deadly Poison VII", "Deadly Poison VIII", "Deadly Poison IX"}
local PoisonStackCount = 0;
for Poison = 1, #PoisonName do
  for i= 1, 20 do 
    local name, _, _, count = UnitDebuff("target", i);
        if (PoisonName[Poison] == name) then
            PoisonStackCount = count;
        end
    end
end
return PoisonStackCount;

You can edit the poisonName table and add any poison that has a stacking effect.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...