SMH - Simply Magical Healer World of Warcraft AddOn

The internal structure of the SMH addon has changed starting with version to allow complete access to all routines and data structures. Everything except for string values found in the localization files and the defaults are contained in a table named SMH. The programmer can access this data by referring to variables like SMH.isMoving and routines like SMH:CacheSpellBookData(). Here is a small set of API contained in SMH that may be useful to the addon/macro writer:

SMH:CacheEquipmentData() processes the equipped items to determine the total +healing the equipment provides. This returns two integers, the total +healing from equipment and the total +healing if all the equipment is not broken. In most cases these values will be the same. This also updates SMH.extraHealingAmount to the first number, SMH.extraHealingAmountPossible to the second number and SMH.hasBrokenPlusHealingItems to true or false depending on whether there are items that are broken that would normally have provided a +healing addition. In the normal operation of the SMH addon this routine is called upon events PLAYER_ENTERING_WORLD and UNIT_INVENTORY_CHANGED so the variables listed should always be up to date.

SMH:CacheSpellBookData() processes the spell book to determine information about spells in which the addon has interest. These spells are listed in the localization files and are grouped together into tables by class in the variables SMH.classAttacksOfInterest, SMH.classBuffsOfInterest and SMH.classSpellsOfInterest (which represent the healing spells). After this routine is run the SMH.cachedSpellBookData table is updated with the latest spell information. The SMH.cachedSpellBookData variable is accessed as a two-dimensional table with the spell name and the rank as the keys, and the data at that location is a table with the following pieces of information: castTime, mana, maxHeal and minHeal. For example, SMH.cachedSpellBookData["Healing Touch"][3].castTime should give the cast time for Healing Touch Rank 3 reduced by any appropriate talents. Note that reading of cast time is a little complicated in that there are conditions that would make this inaccurate (like the presence of Nature's Swiftness when the spell book is read). Therefore, the addon will attempt to read the spell book until it gets proper results. In the case of an inaccurate read, the default cast time for the spell is used, and therefore, the talent informaiton would not be included. In the normal operation of the SMH addon this routine is called upon events CHARACTER_POINTS_CHANGED (when gaining a new talent), LEARNED_SPELL_IN_TAB, PLAYER_ENTERING_WORLD and UNIT_AURA (if spell times were not yet read properly).

SMH:CastHealNormal() performs the normal healing function, selecting the appropriate spell for the appropriate recipient based on the rules set in the options. This returns true if a spell cast attempt was made.

SMH:CastHealOnUnit(unitId [, mode]) performs the normal healing function on the unitId provided. The mode can be used to limit which spell is cast instead of using the caster's entire spell repertoire. The actual values for mode can be found by looking at the entries in the SMH.commandHeals table. Note that if the unitId has a health percentage that is higher than SMH_Configuration.profiles[SMH_Configuration.currentProfile].threshold then no healing will be attempted. This returns true if a spell cast attempt was made. This API is available starting in the version of the addon.

SMH:CastHealSelf() performs the normal healing function on the player. This returns true if a spell cast attempt was made.

SMH:CastStoppingBuff([buffTable]) returns the name of a buff that disallows casting otherwise returns nil if there is none. The buffTable is gotten from SMH:UnitBuffs(unitId). Starting in version the buffTable is optional, and will be retrieved for the player automatically if not passed in.

SMH:DetermineSpellsForUnit(unitId [, targetHealthPercentage]) returns a table of "spells" that the player can cast to heal the unitId up to the targetHealthPercentage. Note that some spells may not be able to heal the unitId to the desired targetHealthPercentage and will have their highest rank returned. If the targetHealthPercentage is not provided the default value from the options is used. The returned table has as its keys the localized names of the spells and as values tables that contain two entries: rank and healAmount. The rank is the rank of the specified spell and the healAmount is the total healing based on the percentage taken from the options for that rank of spell, the +healing, efficiency of healing, etc. This API is available starting in the version of the addon.

SMH:IsMounted([buffTable]) returns true or false depending on whether the buffs in the buffTable indicate the character is mounted. The buffTable is gotten from SMH:UnitBuffs(unitId). Starting in version the buffTable is optional, and will be retrieved for the player automatically if not passed in.

SMH:UnitBuffs(unitId) returns a table of all the buffs and debuffs currently active. The key in the table is the name of the (de)buff, while the value for each is a table that provides count (the number of stacked buffs) and lifetime (only greater than 0 if the unitId is "player"). There are some special values that are present on specific types of buffs: castStopping (buff will not permit a spell cast), mounted (the buff means on a mount), and the localized names for Holy Light, Flash of Light and Unstable Power representing the actual numeric values for proper +healing determination.

SMH:UnitInGroup(unitId) returns 1 or nil depending on whether the unitId is in a party or raid with the player. This handles the case of "player" being in the party, as well as pet membership. This calls SMH:UnitInParty(unitId) and SMH:UnitInRaid(unitId) which return the proper results. Prior to 1.12 this uses custom code, while post 1.12 this uses the new Blizzard API UnitPlayerOrPetInParty(unitId) and UnitPlayerOrPetInRaid(unitId).

Addon Communication

The SMH addon broadcasts messages using the addon channel available with Blizzard's 1.12 release. The messages that it broadcasts indicate who is being healed for what estimated amount. At present, only non-instant casts trigger messages. In the future, when the smart Swiftmend system is in place, this will change so all druid heals will be broadcast. The SMH addon automatically broadcasts a spell completion message when the cast has stopped (for whatever reason) because it receives the following events: SPELLCAST_FAILED, SPELLCAST_INTERRUPTED and SPELLCAST_STOP. Programmers can inform users of SMH about their spell casts by calling the following API available in

SMH:OutputChannelMessage(addonName, spellName, spellRank, recipientName, estimatedHealAmount, spellCastTime) broadcasts an addon message to indicate a heal is being cast. Only the recipientName and estimatedHealAmount need be non-nil.

The format of the outgoing message is
where everything is taken from the passed in arguments except for the oneUpNumber which is used to uniquely identify spell casts from a player. This oneUpNumber is maintained by the SMH addon for each player. At the moment, the SMH addon only knows how to parse communication messages from SMH. However, if others provide their formats, SMH could be augmented to understand what heals they do as well. Also, at the moment the SMH addon will only parse messages it thinks are from the SMH addon, which means in the API usage above addonName should be "SMH" or nil, which should mean that "SMH" will be used as a default.

The SMH addon records spells that are in the process of being cast in an internal table, and then when it needs to cast a spell it processes the contents of the table to ensure there are no spells that are too old (meaning some communications problem with the server never cleared them from the table) and to see if any are being cast on the intended recipient. This processing is done by calling SMH:ProcessOtherHeals(). Once processing is done, the table SMH.currentOtherHealsByCharacter is properly filled so accessing it with the character name should indicate the amount of potential healing that character will receive in the upcoming seconds. The SMH addon uses this information to limit the amount of healing it needs to do.