Automatic Weapon Swap on Stealth/Unstealth
This script will automatically swap your weapons when you enter or leave stealth. I feel this is superior to creating a new stealth macro (like above), and new macros to combine swaps with your attacks, e.g. Ambush. Also this version will ensure your sword is automatically restored if your stealth is ever broken, say if you're detected by a mob, or a DoT breaks your stealth, etc.
Note: this code assumes WeaponSwapEquipDagger is LuaSlinger script #1 and WeaponSwapEquipSword is LuaSlinger script #2. You can change this below, just change the number to LuaSlinger_Exec().
Note: These days, since the 1.7 weapon swap nerf, I actually comment out the line to automatically swap in my dagger upon stealthing. Then, once stealthed, if I really want to use a dagger attack I use a manual keybinding to swap the dagger in. But I still really like having the code to always make sure my sword is equipped anytime I come out of stealth.
Set this to execute on event: PLAYER_AURAS_CHANGED
if (isStealthed == nil) then
isStealthed = false
wasStealthed = false
end
isStealthed = false
for i=0,15,1 do
t=GetPlayerBuffTexture(i)
if (t and string.find(t, "Ability_Stealth")) then
isStealthed = true
break
end
end
if (isStealthed and not wasStealthed) then
wasStealthed = true
-- NOTE: assumes your LuaSlinger Script #1 swaps in your Dagger
LuaSlinger_Exec(1)
elseif (not isStealthed and wasStealthed) then
wasStealthed = false
-- NOTE: assumes your LuaSlinger Script #2 swaps in your Sword
LuaSlinger_Exec(2)
end