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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 21 ■ Responding to the Combat Log <strong>and</strong> Threat In<strong>for</strong>mation 401Writing CombatStatusAs an example <strong>of</strong> how the combat log can be used to get detailed in<strong>for</strong>mationabout combat in <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong>, you will create an addon called CombatStatus.The initial version will show the damage per second <strong>and</strong> heals persecond <strong>for</strong> your party, including pets.The addon is structured with the following observations in mind:You can take advantage <strong>of</strong> unit flags to make capturing all <strong>of</strong> yourparty’s events easier. In particular, you can check <strong>for</strong> COMBATLOG_OBJECT_AFFILIATION_PARTY to get the relevant events.Because combat data arrives with GUID in<strong>for</strong>mation rather than unitIDs,you’ll need to make sure you store <strong>and</strong> index all data using GUIDs. Thiswill ensure that you don’t lose any in<strong>for</strong>mation if the order <strong>of</strong> unitIDschange.A player might have more than one pet (<strong>for</strong> example, druids <strong>and</strong> theirtreant pets, or shaman elemental totems). Rather than trying to considerthem individual pets, you can just collapse them into a single ‘‘pet’’ unit<strong>for</strong> each <strong>of</strong> your party members. You can use the SPELL_SUMMON combat logevent to detect new units coming into play so we can track their GUIDs.<strong>Creating</strong> the Basic Addon StructureIn your <strong>Addons</strong> folder, create a new directory called CombatStatus. Inside,create a new file called CombatStatus.toc with the following contents:## Interface: 30300## Notes: Provides a DPS meter <strong>for</strong> your partyCombatStatus.luaCombatStatus.xmlAlthough you aren’t using any XML templates in this addon currently, it’sbetter to create the file now in case you choose to add some at a later time. CreateanewCombatStatus.xml file <strong>and</strong> add the basic element declaration:

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

Saved successfully!

Ooh no, something went wrong!