12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

190 Part II ■ <strong>Programming</strong> in <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong><strong>and</strong> other features the designers have since deemed inappropriate <strong>for</strong> addons.That early leeway made it relatively trivial—especially with a bit <strong>of</strong> help fromexternal programs—to write ‘‘grinding bots’’ that would completely controlyour character while you went to the movies. Set it up be<strong>for</strong>e work <strong>and</strong> by thetime you got home you could have gained a few levels <strong>and</strong> received massiveamounts <strong>of</strong> loot to sell.A similar problem were ‘‘button masher’’ addons like Emergency Monitor<strong>and</strong> Decursive. A player could repeatedly press a single key or mouse button<strong>and</strong> the addon would do all the decision-making: who to target, what spell tocast, <strong>and</strong> so on.Subsequent patches removed these capabilities by marking the <strong>of</strong>fendingfunctions as protected. Protected functions can be called only by built-in code.In addition there is another class <strong>of</strong> functions that are only protected duringcombat. <strong>WoW</strong> is able to tell when the running code is from an addon or macroversus a built-in file, so it can prevent the protected function from running inthose cases. Table 11-2 describes a small sampling <strong>of</strong> protected functions togive you an idea <strong>of</strong> their nature.Table 11-2: Sample <strong>of</strong> Protected FunctionsFUNCTIONDESCRIPTIONJumpCauses the character to jumpCastSpellByNameToggleAutoRunTargetUnitPetAttackRegisterUnitWatchAttempts to cast the given spellControls the character’s auto-runTargets the specified unitSends your pet to attackRegisters a frame to be shown/hidden based on a unitThese are just examples. All movement, targeting, ability use, <strong>and</strong> action barmanipulation functions are completely protected. The API reference section inChapter 27 shows which functions are protected, so you know whether or notyou can call them.NOTE You may be wondering how it is possible to write an action bar or unitframe addon at this point, considering that spell-casting <strong>and</strong> targeting functionsare protected. This problem is resolved by using secure templates, which arecovered in Chapter 15.Unit Functions Up CloseThe first logical grouping <strong>of</strong> APIs to examine is unit functions. As previouslymentioned, these functions expose data about players, mobs, <strong>and</strong> NPCs. Most

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!