# Forum > World of Warcraft > World of Warcraft Bots and Programs > WoW Bots Questions & Requests >  Reflect script

## Rextown

Hello
Does anybody can to prompt where is an error in code?And will there be he in general to work?


local f, t, p, s = CreateFrame(“Frame”),{[“Polymorph”] = true, [“Fear”] = true, [“Сyclone”] = true}, 
UnitGUID(“player”),“Spell Reflection” 
f:RegisterEvent(“COMBAT_LOG_EVENT_UNFILTERED”) 
f:SetScript(“OnEvent”, function(_,_,_.e,_,_,_,tg,_,_,_,sn) 
if e == “SPELL_CAST_START” and tg == p and GetSpellCooldown(“Spell Reflection”) == 0 and t[sn] then 
CastSpellByName(“Spell Reflection”) 
end 
end)

----------


## Rextown

Nobody will help?

----------


## Jadd

Nobody understands the question or this random code snippet. What are you trying to accomplish in this post? Where's the problem?

----------


## Rextown

Yes I already understood. That that I want, it is impossible to realize
It was necessary for me that reflect it was used when in me cast through focus or a mausover

----------


## GentleTouch

```
local logframe = CreateFrame("Frame")
logframe:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
logframe:SetScript("OnEvent", function(self, event, ...)
	local ticktime,event_name,_,_,sourceName,_,_,_,destName,_,_,LastCastID,spellName,spellSchool = ...
	
	local SpellsToReflect = 
	{
		["Polymorph"] = true,
		["Fear"] = true,
		["Cyclone"] = true,
	}
	
	if event_name == "SPELL_CAST_START" then
	
		if SpellsToReflect[spellName] == true then
			if select(2,GetSpellCooldown("Spell Reflection")) < 2 then
				CastSpellByName("Spell Reflection")
			end
		end
	end
end)
```

Seems to be what you are looking for.

----------


## dklfcheat

> ```
> local logframe = CreateFrame("Frame")
> logframe:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
> logframe:SetScript("OnEvent", function(self, event, ...)
> 	local ticktime,event_name,_,_,sourceName,_,_,_,destName,_,_,LastCastID,spellName,spellSchool = ...
> 	
> 	local SpellsToReflect = 
> 	{
> 		["Polymorph"] = true,
> ...


how to "translate" all that stuff to simple lua? so i can use it with super duper macro?

----------


## GentleTouch

> how to "translate" all that stuff to simple lua? so i can use it with super duper macro?


Open literally any addon folder you already use, find a file called .lua,open the .lua file in notepad.exe, paste what i wrote at the very bottom, save, /reload;

Otherwise, you want to use it with super duper macro, put it all on one line.

----------


## dklfcheat

> Open literally any addon folder you already use, find a file called .lua,open the .lua file in notepad.exe, paste what i wrote at the very bottom, save, /reload;
> 
> Otherwise, you want to use it with super duper macro, put it all on one line.


have you actually tested it ingame and seen it work? because even with a lua unlocker i been unable to make addons use abilities, some message pop ups about protection, if you have what expansion was it and did you use a third party software to bypass this protection?

----------


## Ravenh

> how to "translate" all that stuff to simple lua? so i can use it with super duper macro?


SpellBase = {"33786", "12826", "12824", "12825", "118", "61305", "28272", "61721", "61780", "28271", "59172", "51514", "60043", "48160", "47843"}

AutoKick = CreateFrame("Frame", "AutoKick", UIParent);
AutoKick:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
AutoKick:SetScript("OnEvent", function(self, event, arg1, arg2, ...)
if(event=="COMBAT_LOG_EVENT_UNFILTERED") then
local spell, _, _, _, _, endTime, _, _, interrupt = UnitCastingInfo("target")
for _, v in ipairs(SpellBase) do
if GetSpellInfo(v) == spell then
local finish = endTime/1000 - GetTime()
if finish <= 0.5 then
if interrupt == false then
RunMacro("1h")
RunMacroText("/cast Spell Reflection")
end
end
end
end
end
end)

----------


## d2207

Hi guys, I need some help. 
I have a script for reflection, but it does not work correctly, to be honest it does not work at all, and I do not understand what I'm doing wrong?

if macros["spellreflect"]
and cdRemains(23920) > 4
and not UnitBuffID("player", 23920) then 
ResetMacros()
MacroStatusFrameUpdate()
if not IsTwoHanderEquiped() then
EquipTwoHander()
end
end 
if cdRemains(23920) == 0
and macros["spellreflect"] then 
local t = StringSplicer(GetCVar("SRtargs")) 
for i=0,#t do 
local SRTarget = t[i] 

if SRTarget == "debug" 
and rage >= 10 then
if not IsOneHandAndShieldEquiped() then
EquipOneHandAndShield()
end 
_castSpell(23920)
end

if UnitExists(SRTarget )
and UnitCanAttack("player", SRTarget ) ~= nil 
and UnitCastingInfo(SRTarget) 
and rage >= 10 then

local castName,_,_,_,castStartTime,castEndTime,_,_,castNotInterruptable = UnitCastingInfo(SRTarget)
local timeSinceStart = (GetTime() * 1000 - castStartTime) / 1000
local castTime = castEndTime - castStartTime	
local currentPercent = timeSinceStart / castTime * 100000

if currentPercent >= 70 then
if not IsOneHandAndShieldEquiped() then
EquipOneHandAndShield()
end 
_castSpell(23920)
end
end 
end 
end

What do I see here? Macros["spellreflect"] that checks for the presence of OneHandAndShield. Equiping them or two-handed. And script that checks for distance, interrupt, cast time, and finally uses reflection. Where is the mistake? Need to specify the ID spell that it reflects? I read that it is written - 
//if currentPercent> = 70 then equip OneHandAndShield and use reflection!!! One-handed shield and two-handed are indicated in a separate script.

----------


## Numba1stunna1

The "macros["spellreflect"] is a table of keys for macros of the rotation. A specific macro is pressed for the spell reflect, and thus the key in the table is set to "true", making the "macros["spellreflect"] true. The "macros" table most likely has other macros such as "shield wall".
To answer your question, this script is written to turn off macros if the spell cooldown of the specific macro is greater than 4 seconds and the player does not have spell reflection (the first block of the script). If so, the script checks if you have a 1 hander, and equips a 2 hander. The 2nd part check if the macro is enabled and the cooldown is 0, then it uses a string slicer to break a string up into components and put them in a table, in this case for targets (ex "target, focus" ---> {"target","focus"}. This is because the macro function takes only 1 string, so the saved variable is one string. The script then iterates over a table of target (can be 1 target, ofc). The script has the option to set the string to "debug", which casts the ability regardless of checking a target. Finally, the script checks if the unit in the list exists, if you can attack (an enemy), the unit is casting anything, and if the rage is greater than or equal to 10. The script then localizes a bunch of unnecessary variables, because it only uses currentPercent. After the enemy's cast is 70% or higher, the script equips a shield and casts spell reflect.

You probably forgot to put a string of targets in your macro. It probably looks something like this /SpellReflect target, focus, mouseover (you can remove or add any targets).

----------


## d2207

Thanks for the help. I to put a string of targets by analogy with the script "FastKick"(_castSpell(23920,"target"))
but it did not help, I think the error occurs in the first block - after pressing specific macro ["spellreflect"] the key in the table is not set to true.

----------

