function Trig_setMyTooltip_Actions takes nothing returns nothing
// This script sets the learn, and extended tooltips (levels 1, 2, 3) for a custom Feral Spirit ability.
local unit array tempUnit
local integer array baseDamage
local integer array damageDice
local integer array damageSides
local integer array damageMin
local integer array damageMax
local real array attackCooldown
local real array damagePerSecond
local integer array numSummons
local integer array manaCost
local integer array maxLife
local integer array baseArmor
local integer array cooldown
local string tempStr
set udg_pos = Location(GetRectMaxX(GetPlayableMapRect()), GetRectMinY(GetPlayableMapRect())) // pos is a global Point type variable created in GUI, the location set here is the bottom right corner of the map
call CreateNUnitsAtLoc( 1, 'o001', Player(bj_PLAYER_NEUTRAL_EXTRA), udg_pos, bj_UNIT_FACING )
set tempUnit[0] = GetLastCreatedUnit() // tempUnit[0] == ability level 1 summoned unit
call CreateNUnitsAtLoc( 1, 'o002', Player(bj_PLAYER_NEUTRAL_EXTRA), udg_pos, bj_UNIT_FACING )
set tempUnit[1] = GetLastCreatedUnit() // tempUnit[1] == ability level 2 summoned unit
call CreateNUnitsAtLoc( 1, 'o003', Player(bj_PLAYER_NEUTRAL_EXTRA), udg_pos, bj_UNIT_FACING )
set tempUnit[2] = GetLastCreatedUnit() // tempUnit[2] == ability level 3 summoned unit
call CreateNUnitsAtLoc( 1, 'O000', Player(bj_PLAYER_NEUTRAL_EXTRA), udg_pos, bj_UNIT_FACING )
set tempUnit[3] = GetLastCreatedUnit() // tempUnit[3] == a hero unit to teach the ability to
call RemoveLocation(udg_pos)
call SelectHeroSkill(tempUnit[3], 'A000') // 'A000' == the custom ability's id, accessible in the object editor after pressing ctrl + d
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 2 // 0 to 2 because the ability has 3 levels, as already stated, and shown by the 3 different summons
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
// --- values related to damage
set baseDamage[GetForLoopIndexA()] = BlzGetUnitBaseDamage(tempUnit[GetForLoopIndexA()], 0) // the base damage value that can be changed in the object editor
set damageDice[GetForLoopIndexA()] = BlzGetUnitDiceNumber(tempUnit[GetForLoopIndexA()], 0) // dice count
set damageSides[GetForLoopIndexA()] = BlzGetUnitDiceSides(tempUnit[GetForLoopIndexA()], 0) // dice sides
set damageMin[GetForLoopIndexA()] = (baseDamage[GetForLoopIndexA()] + damageDice[GetForLoopIndexA()]) // min damage = base damage + dice count
set damageMax[GetForLoopIndexA()] = (baseDamage[GetForLoopIndexA()] + (damageDice[GetForLoopIndexA()] * damageSides[GetForLoopIndexA()])) // max damage = base damage + dice count * dice sides
set attackCooldown[GetForLoopIndexA()] = BlzGetUnitWeaponRealField(tempUnit[GetForLoopIndexA()], UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN, 0)
set damagePerSecond[GetForLoopIndexA()] = ((I2R(damageMin[GetForLoopIndexA()]) + I2R(damageMax[GetForLoopIndexA()])) / 2) / attackCooldown[GetForLoopIndexA()]
// --- non-damage values
set numSummons[GetForLoopIndexA()] = BlzGetAbilityIntegerLevelField(BlzGetUnitAbility(tempUnit[3], 'A000'), ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_OSF2, GetForLoopIndexA()) // number of summoned units found in the object editor
set baseArmor[GetForLoopIndexA()] = R2I(BlzGetUnitArmor(tempUnit[GetForLoopIndexA()])) // the base armor, which can be modified in the object editor, of these units; this is normally a real value, but converting to integer so that it shows up neatly in the tooltip later is good enough; R2I() converts from real to integer
set maxLife[GetForLoopIndexA()] = BlzGetUnitMaxHP(tempUnit[GetForLoopIndexA()]) // the max life/hp/health/whatever terminology one prefers
set manaCost[GetForLoopIndexA()] = BlzGetAbilityManaCost('A000', GetForLoopIndexA())
set cooldown[GetForLoopIndexA()] = R2I(BlzGetAbilityCooldown('A000', GetForLoopIndexA())) // same deal here as with armor, normally a real value, but we only care about the integer part right now
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 3
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call RemoveUnit(tempUnit[GetForLoopIndexA()]) // we don't need the dummy units anymore to access their properties, so we remove them all
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
// --- building the tooltip string here; not being fancy, just adding everything into one uniform tooltip, and using it for every level + the learn tooltip
set tempStr = "Jimmy is a jolly ol' feller who likes dogs.|nNumber of Dogs: |cffffff00" + I2S(numSummons[0]) + "|r |cff808080,|r |cffffff00" + I2S(numSummons[1]) + "|r |cff808080,|r |cffffff00" + I2S(numSummons[2]) + "|r|nDog Damage: |cffffff00" + I2S(damageMin[0]) + " - " + I2S(damageMax[0]) + " (" + R2S(damagePerSecond[0]) + " DPS)|r |cff808080,|r |cffffff00" + I2S(damageMin[1]) + " - " + I2S(damageMax[1]) + " (" + R2S(damagePerSecond[1]) + " DPS)|r |cff808080,|r |cffffff00" + I2S(damageMin[2]) + " - " + I2S(damageMax[2]) + " (" + R2S(damagePerSecond[2]) + " DPS)|r|nDog Armor: |cffffff00" + I2S(baseArmor[0]) + "|r |cff808080,|r |cffffff00" + I2S(baseArmor[1]) + "|r |cff808080,|r |cffffff00" + I2S(baseArmor[2]) + "|r|nDog Life: |cffffff00" + I2S(maxLife[0]) + "|r |cff808080,|r |cffffff00" + I2S(maxLife[1]) + "|r |cff808080,|r |cffffff00" + I2S(maxLife[2]) + "|r|nMana Cost: |cffffff00" + I2S(manaCost[0]) + "|r |cff808080,|r |cffffff00" + I2S(manaCost[1]) + "|r |cff808080,|r |cffffff00" + I2S(manaCost[2]) + "|r|nCooldown: |cffffff00" + I2S(cooldown[0]) + "|r |cff808080,|r |cffffff00" + I2S(cooldown[1]) + "|r |cff808080,|r |cffffff00" + I2S(cooldown[2]) + "|r"
// --- setting the tooltips right here
set bj_forLoopAIndex = 0
set bj_forLoopAIndexEnd = 2
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call BlzSetAbilityExtendedTooltip('A000', tempStr, GetForLoopIndexA())
call BlzSetAbilityResearchExtendedTooltip('A000', tempStr, GetForLoopIndexA())
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
function InitTrig_setMyTooltip takes nothing returns nothing
set gg_trg_setMyTooltip = CreateTrigger()
call TriggerAddAction(gg_trg_setMyTooltip, function Trig_setMyTooltip_Actions)
endfunction