Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:API AttackTarget
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{wowapi}} {{protectedapi|2.0.1|For alternatives, try [[API_SecureTemplates|Secure Templates]].}} Toggles auto-attacking of the player's current target. AttackTarget(); ---- ;''Arguments'' :''none'' ---- ;''Returns'' :;nil ---- ;''Example'' AttackTarget(); ;''Result'' If you were swinging your melee weapon at your target, you'll stop. If you weren't, you'll start. ---- ;''Description'' : This is actually a toggle. If not currently attacking, it will initiate attack. If currently attacking, it will stop attacking. : You can test your current attack "Action slot" using [[API_IsCurrentAction|IsCurrentAction(actionSlot)]] for status (you'll have to find the auto-attack slot, though). : If you need a way to always engage auto-attack, rather than toggle it on or off, one workaround is [[API_AssistUnit|AssistUnit("player")]] this will always attack if you have "Attack on assist" checked in the Advanced tab of the Interface Options panel. Note that you cannot combine this with [[API_TargetNearestEnemy|TargetNearestEnemy()]] in the same function/macro: the "assist" target isn't updated fast enough. : The macro "/startattack" will always initiate auto-attack (or auto-shot for hunters, if the appropriate interface option is active). The text below is a few years old and is likely no longer accurate. ---- :The [[API_AssistUnit|AssistUnit("player")]] method described in the previous paragraph doesn't always work, in particular if you are switching between targets a lot. The most reliable way to make sure your attack is always on, no matter how many times you hit the attack button, is to use the following macro: /script if not IsCurrentAction(61) then UseAction(61) end; :All that one-line script does is see whether your Attack button is not enabled, and if it isn't, it turns it on. :To make this work for you: :1. drag the default Attack icon (it is button #1 on the 1st skill bar by default) to an unused slot, preferably on a skill bar you don't use much. If you want to skip step #2, simply drag the default Attack icon to button #1 of the 6th skill bar (i.e. slot 61) :2. replace the number 61 in the script with the number of that slot. The slots are numbered 1-12 for the 1st skill bar, 13-24 for the 2nd bar, and so on (25-36, 37-48, 49-60, 61-72). :3. assign the macro to a button on a skill bar (e.g. button #1 on the 1st skill bar) Slightly longer, but more complete method to just find attack anywhere on your bar. /script if not ma then for i = 1,72 do if IsAttackAction(i) then ma = i; end; end; end; if ma then if not IsCurrentAction(ma) then UseAction(ma); end; else AttackTarget("target");end;
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)