Triggered Item Abilities

Discussion in 'Advanced Mechanics Guides' started by 3DM@rk, Jun 16, 2009.

  1. 3DM@rk

    3DM@rk Well-Known Member

    Foreword
    This guide contains the triggering of most items in DotA. I didn't include items with no triggers involved (like Vanguard) or with only small insignificant triggered part (Eul's Scepter). I'll be adding new items when I have time. The guide should be updated for 6.62b.
    At the moment, the guide contains the following items:
    • Shiva's Guard
    • Kelen's Dagger
    • Blade Mail
    • Bloodstone
    • Magic Stick + Magic Wand
    • Heart of Tarrasque
    • Cranium Basher
    • Scroll of Town Portal
    • Orchid Malevolence
    • Armlet of Mordiggian
    • Force Staff
    • Black King Bar
    • Ghost Scepter
    • Mjollnir
    Some passages can be a little harder to read, I'm planning on rewriting especially Cranium Basher. Since this guide is a port from D-A website, the formatting may not be the best suited for this skin. I'll be working on it.

    I wish you pleasant Mechanical experience.

    [TABLE][​IMG]|Shiva's Guard[/TABLE]

    Frigid Blast (A0T9)
    Based on Item Agility Gain (dummy).

    When it goes into effect, do (1).

    (1) Create a unit [h091] at the casting unit's position, save it as "Caster". The unit has the Shiva's_Guard_FX imported model that looks like the expanding blast circle. Then create a dummy unit [e00E] at the casting unit's position, save it as "Nuker". Add a Slow based ability [A0T0] to "Nuker". Save the casting unit as "Source" and create an empty group of units to be saved as "AlreadyDamaged".
    Then create a periodic trigger (2) to be called every 0.06 seconds.

    (2) Recover "AlreadyDamaged", "Source", "Caster" and "Nuker" from the game cache. Set the X and Y coodrinates of "Caster" to that of "Source". If the trigger has been called more than 33 times, do (3). Else do (4).

    (3) Kill "Caster", empty the "AlreadyDamaged" group and destroy trigger (2).

    (4) Set "Distance" to be 18*Runtimes. Then make a loop for i=0 to 36 doing (5).

    (5) Count all enemy non-dummy non-structure alive non-cycloned visible units in 150 AoE from point that is "Distance" from "Source" in angle 10*i degrees. For each counted unit do (6).

    (6) If the unit isn't in the "AlreadyDamaged" group, then add it to the group, order "Nuker" to cast Slow on that unit and make "Source" damage the enum unit for 200 damage with Attacl Type Spells, Damage Type Fire. Finally, show the FrostNovaTarget effect on the enum unit.

    Notes: The [A0T0] ability slows MS by 40% for 4 seconds. The expansion speed of the model of "Caster" is a bit faster than the triggered movespeed of the damageing area (300), so at longer distances from "Source", the slow and damage can appear desynchronized with the blast animation.
    Before 6.61, the blast animation was assembled from 48 dummy units with a frost arrow-like model, which could cause performance drop on weaker computers or when multiple blasts were cast at the same time.


    [TABLE][​IMG]|Kelen's Dagger[/TABLE]

    Whenever a hero enters the game and it's not a dummy hero or an illusion, and "RegisterDamageAlready" is false for that hero, then set that variable for him to true and create a new periodic trigger (1) to be called when the hero is damaged.

    (1) If the damage is bigger than 2, the damage source is not the hero himself and the damage source belongs to one of the 10 human players or it's Roshan, then set "Global|LastPlayerDamage" (an element of an array) for the hero to the current time.

    There's another periodic trigger (2) running concurrently. It is called every 0.33 seconds.

    (2) For every player in the game, take that player's hero and if the hero isn't dead, then do (3).

    (3) If the current time is lower than "Global|LastPlayerDamage"+3 seconds, then search the hero's inventory (slots 0-5) and if you find Kelen's Dagger [I04H], then remove it from the inventory and replace it by Disabled Kelen's Dagger [I04I]. If the current time is bigger or equal to "Global|LastPlayerDamage"+3 seconds, then search the hero's invetory (slots 0-5) and if you find Disabled Kelen's Dagger, then remove it from the inventory and replace it by Kelen's Dagger.

    To sum up, Dagger is disabled for 3 seconds after any damage bigger than 2 from player-controlled source is recieved. The damage source can even be an ally (e.g. Toss) or Roshan. Direct HP removal does not disable Dagger. And because the disabling trigger is called every 0.33 seconds, there can be a small delay, so if lucky, the hero can still blink away before Dagger is disabled.

    [TABLE][​IMG] |Blade Mail[/TABLE]

    Damage return (A15W)
    Based on Fan of Knives (dummy).

    When Blade Mail is activated, then create a new trigger to be called when the unit that activated Blade Mail is dealt damage, or 3.5 seconds later. Then show the special effect (SpikeBarrier) on the caster's chest.

    When the trigger is called and it wasn't because the unit was dealt damage (aka it was because the 3.5 sec. timer), then destroy the special effect and destroy this trigger.
    If it was called because the unit was damaged, then if the damage is between 2 and 3000, the damage source is non-allied and non-structure and "BladeMail|GlobalFlag" is false, then if the source is a hero or a non-dummy unit, do (1), else do (2).

    (1) Disable this trigger and set "BladeMail|GlobalFlag" to true. Make the Blade Mail wielder damage the attacker for the EventDamage with Attack Type Hero, Damage Type Magic. Then enable this trigger again and set "BladeMail|GlobalFlag" to false.

    (2) Disable this trigger and set "BladeMail|GlobalFlag" to true. Make the Blade Mail wielder damage the hero of the dummy unit's owner for the EventDamage with Attack Type Hero, Damage Type Magic. Then enable this trigger again and set "BladeMail|GlobalFlag" to false.

    Notes: The trigger works with the recieved damage, hence damage after all reductions of the Blade Mail Wielder is returned. In case of a triggered heal, the ammount of damage returned is the original damage, because in fact you recieve the damage and then it is healed immediately. So if Void Backtracks an attack, the damage is normally returned.
    Function (2) is used for dummy unit damage sources, such as Zeus' Lightning Bolt or his ultimate (the damage will be returned to Zeus in this case).
    The trigger gets disabled when dealing damage to prevent gamecrashing infinite loop, when two heroes with active blademails fight each other (fixed in 6.60b). As of 6.65, Blademail doesn't return damage from another Blademail (realized by "BladeMail|GlobalFlag" variable).

    [TABLE][​IMG] |Bloodstone[/TABLE]

    The passive bonus regen
    At the start of the game, a periodic trigger is created to be called every 1 second. The trigger creates a loop for i=1 until i>5 and in the loop: take the hero of i-th Sentinel player, then if the hero isn't null, isn't dead and has picked up Bloodstone, do (1) for that hero. Then repeat this for i-th Scourge player. (endloop)

    (1) Search the hero's inventory (slots 0-5) for Bloodstone (I0BK), then if you find one and it has at least one charge, then set the hero's mana to CurrentMana+NumberOfCharges.

    Notes: Bloodstone's bonus regen won't work if the unit carrying Bloodstone isn't a player's hero (e.g. Spirit Bear) or is an illusion. Only regen from the Bloodstone in the highest priority slot is applied.

    On death
    When a hero dies, it isn't a Meepo clone and it has a Bloodstone in the inventory, then create a unit (H00M) at the dying hero's position and save it to a handle array. The unit is a dummy hero with 1800 sight range, which has the red rune as its model. Since it's a hero, it will drain experience in 1000 AoE, like any other hero. The dummy has Locust (Aloc) and Marker (A04R).
    Set "Heal" variable to 400+25*NumberOfCharges. Then count all non-enemy non-structure non-dummy units with more than 1 HP in 1700 AoE and for each of them do the folowing: set the unit's HP to CurrentHP+Heal and show a special effect (TrollBeserkerTarget) on top of the unit for 2 seconds.

    Whenever a hero revives, it isn't a Meepo clone and it has a Bloodstone in the inventory, then set its charges to NumberOfCharges*0.5 (rounded down) or to 0 (if NumberOfCharges is 1), take the Bloodstone dummy hero saved in the array and add its total amount of experience to the reviving hero. Then remove the dummy hero from the game.

    When a hero dies, count all non-dummy, non-structure, alive non-illusion heroes in 1625 AoE and for each of them do the following: if the hero is an enemy of the dying hero and has a Bloodstone (I0BK) in his inventory, then increase the number of charges of the item by 1.

    Note: Everything is applied only for the Bloodstone in the highest priority slot. For gaining charges, it doesn't matter which unit was the killer. It can be a summon, a dummy unit, a Techies' mine or the hero himself.

    Gold loss/respawn time details
    Basic values:
    gold lost: 30*HeroLevel
    seconds to respawn: 4*HeroLevel (without Fast Revive mode)

    With Bloodstone:
    gold lost: 30*HeroLevel - 25*NumOfCharges OR 0 (whichever is higher)
    seconds to respawn: 4*HeroLevel - 3*NumOfCharges

    Notes: Again, only Bloodstone in the highest priority slot affects this. If you manage to get so many charges that your respawn time goes below zero, your hero will respawn in 0.0-0.5 seconds, because the respawning trigger runs every 0.5 seconds.

    [TABLE][​IMG] [​IMG] |Magic Stick/Magic Wand[/TABLE]

    Charging
    Whenever a spell is cast, the spell is not on the exceptions lists and the spell caster is not a dummy unit, then count all enemy hero non-dummy non-structure alive non-cycloned non-ancient (except of Spirit Bear) units in 1600 AoE from the casting unit, and for each of them do (1).

    (1) Search the unit’s inventory (slots 0-5) and for each Magic Stick (I0GC) or Magic Wand (I0HB) you find, do (2).

    (2) If the item is a Magic Stick with 10 charges or a Magic Wand with 15 charges, do (3). Then if it's a Magic Stick, increase its number of charges by one (but not if it would exceed 10). Else if it's a Magic Wand, then increase its number charges by one (but not if it would exceed 15). Finally, show the special effect on the enum unit (SpiritTouchTarget).

    (3) If the spell caster is not visible to the enum unit and a random integer from 1 to 100 is less than 10, then play the sound Units\Undead\CryptFiend\CryptFiendPissed2 ("my spider sense is tingling") on the enum unit.

    Activation
    When Magic Stick or Magic Wand is activated (ability A0JY based on Fan of Knives), then set "AlreadyHealed" to false and search the casting unit’s whole inventory (slots 0-5). For each Magic Stick or Magic Wand you find, do (4).

    (4) Take the number of charges of the item and save it into variable NumCharges. If NumCharges if bigger than 0, set the number of charges of the item to 0. If "AlreadyHealed" is false, do (5).

    (5) Set "AlreadyHealed" to true. Then set the casting unit’s HP to CurrentHP+15*NumCharges and the casting unit’s mana to CurrentMana+15*NumCharges. Then show the special effect on the unit (AIreTarget).

    Notes: all Magic Sticks/Wands in your inventory are charged, but only the one on the highest priority slot will provide HP/MP on activation (although all Magic Sticks/Wands will be emptied). Function (3) is an Easter Egg introduced in 6.65.

    The Exceptions lists:
    There are two lists, if the cast spell is on either list, Magic Stick/Wand will not trigger.

    List 1 (shared with Curse of the Silent and Essence Aura):

    • Boots of Travel
    • Nathrezim Buckler
    • Hands Of Midas
    • Helm of the Dominator
    • Berserk (Mask of Madness)
    • Mekansm Armor + Heal
    • Wind Walk (Lothars)
    • Manta Image
    • Item Skeleton Summon lvl 1 (Necronomicon 1)
    • Item Skeleton Summon lvl 2 (Necronomicon 2)
    • Item Skeleton Summon lvl 3 (Necronomicon 3)
    • Refresher
    • Healing Salve
    • Lesser Clarity Potion
    • Bottle Regen
    • Bottle Rune
    • Bottle Empty
    • Observer Ward
    • Sentry Ward
    • Scroll of TP
    • Item Summon Courier
    • Eat Tree (Tango)
    • Cyclone
    • Avatar (BKB)
    • Blink (Kelen's Dagger)
    • Impetus
    • Glaives of Wisdom
    • Arcane Orb
    • Morph str->agi
    • Morph agi->str
    • Frost Arrows
    • Split Shot
    • Rot
    • Detonate
    • Searing Arrows
    • Poison Attack
    • BreakPers (Perseverance)
    • Reality
    • Disassemble
    • BasSwap (Basilius)
    • Burning Spear
    • Psionic Trap (Detonate)
    • Psionic Trap (lay)
    • Electric Rave
    • Ethereal Jaunt
    • Armlet (activate)
    • Armlet (deactivate)
    • TreadsSwap
    • Berserker Rage
    • Wex
    • Quas
    • Exort
    • Mana Shield
    • X Marks The Spot Subskill
    • Magic Stick
    • Blade Mail (active)
    • MKBSwap (toggling True Strike on/off)
    • Tree Chop (Quelling Blade)
    • Heal (Forest Troll High Priest ability gained by Lucifer's Devour)
    • Staff of Healing (real) (Urn of Shadows active)
    • RadSwap (toggling Radiance on/off)
    List 2:

    • Bottle Empty
    • Split Shot
    • Rot
    • BreakPers
    • Reality
    • Disassemble
    • BasSwap (Basilius Swap)
    • Psionic Trap
    • Ethereal Jaunt
    • Armlet
    • Armlet Deactivate
    • Power Treads Click
    • Berserker Rage
    • Wex
    • Quas
    • Exort
    • [Anh1] Heal from neutral Forest Troll
    • X Marks The Spot Subskill
    • Frost Arrows
    (Credit for compiling the lists goes to protomanx1, I only checked it and updated for latest version.)


    [TABLE][​IMG] |Heart of Tarrasque[/TABLE]

    Regeneration disabling
    At the map initialization, a periodic trigger (1) is created to be called every 0.33 seconds (it's the same trigger that checks for Dagger disabling).

    (1) For each Sentinel and Scourge player, do the following: take the player's hero and if the hero isn't null, has picked up a Heart of Tarrasque and is not dead, do (2) for the hero.

    (2) Set "DisableRegen" to false. Look at the time, when the hero took player damage (details on saving this data to arrays are in Kelen's Dagger triggering). If the time of the last damage plus 8 seconds is bigger than the current time (aka the hero has taken player damage in the last 8 seconds), set "DisableRegen" to true.
    Then loop through the hero's inventory and for each item you find, do (3).

    (3) If the item is a Heart of Tarrasque [I0A9] and "DisableRegen" is true, then remove the item from the hero's inventory and add a Disabled Heart of Tarrasque [I0KL] instead.
    If the item is a Disabled Heart of Tarrasque [I0KL] and "DisableRegen" is false, then remove the item from the hero's inventory and add a Heart of Tarrasque [I0A9] instead.

    Notes: The disabled HoT lacks the Healing Ward Aura ability [A15Y], which regenerates 2% of max HP per second.
    Only damage taken from an enemy or allied player's unit or from Roshan can disable HoT.


    [TABLE][​IMG] |Cranium Basher[/TABLE]

    At the start of the game, a trigger is created to be called whenever a unit is attacked (this is the same trigger that provides Javelin's bonus damage and allows/prevents denying).

    If the attacked unit is not an ally of the attacker, the attacker is a hero or Spirit Bear, the attacked unit is not a structure, the attacker is not an illusion and has Cranium Basher (I08K) in his inventory, then call (1).


    (1) Recover "BasherTime" (when Basher cooldown ends), "BasherActive" (whether the hero has the Bash ability) and "BasherRemove" (whether the Bash ability should be removed) from the cache. If the attacker is melee, then set Percentage to 25, else set it to 10. If the attacker has any of the following abilities:
    • Slardar's Bash (A0JJ)
    • Time Lock (A081)
    • Greater Bash (A0G5)
    • Troll's Bash (A09E)
    then remove the spellbook ability (A174) from the attacker and end this function.

    Else if random integer from 0 to 100 is less than Percentage
    • then set "Occured" to true
    Then if "BasherActive" is true, CurrentTime is bigger than or equal to "BasherTime" and "BasherRemove" is false
    • set "BasherTime" to CurrentTime + 2 seconds
    • if "Occured" is false
      • set "BasherRemove" to true
    Else if CurrentTime is less than "BasherTime" or "BasherRemove" is true:
    • remove the Spellbook ability (A174) from the attacker
    • set "BasherActive" and "BasherRemove" to false
    If "Occured" is true
    • add the Spellbook ability (A174) to the attacker
    • set "BasherActive" to true
    Further in the code, the Spellbook ability is made unavailable for all players. The Spellbook has a Bash ability (A175) with 100% chance to bash for 1.4 seconds with 25 bonus damage.

    Notes: You cannot bash on the first attack after you archieved Basher (because variable "BasherRemove" hasn't been assigned a value yet, so it is true by default).
    This function took me an hour or so to fully decipher, although it is not very complicated. I thought the cooldown would not work properly, because the Spellbook is added at the end. But I tested that and the cooldown works as expected, so permabash is not possible (at best you can bash 0.6 seconds after the previous bash has ended).

    [TABLE][​IMG] |Scroll of Town Portal[/TABLE]

    Town Portal (A137)
    Based on Channel with 3 seconds channeling time and 99999 cast range.

    When the spell is cast and the casting unit is not a courier, then save "Teleporting" for that unit as true and create a new trigger to be called when the unit has finished casting a spell or ended casting a spell (1).
    If the target was a unit (allowed are allied nonancient buildings), then set "Target" to be the unit. If the target wasn't a unit, then count all allied nonancient structure non-shop units (except of Power Cog and Circle of Power) with more than 0 HP in 99999 AoE from the target point, pick the closest unit to the target point and set it to be the "Target".
    Then if the distance between the target point and "Target" is more than 350, set "Destination" to be 250 units from "Target" in the angle between "Target" and the target point. If the distance between the target point and "Target" is less than 50, set "Destination" to be 70 units from "Target" in the angle between "Target" and the target point. Else let "Destination" be the target point.
    Then show minimap ping for all allied players at "Destination" and show "MassTeleportTo" effect on the teleporting unit. Show the same effect at "Destination" for allied players and at "Target" for enemy players. Then create a white "UberSplat" (the rune circle around the teleporting unit) and show it only to the players that have vision of the teleporting unit. Save the teleporting unit to the cache as "Hero".
    If "Destination" is the same as "Target"'s location (aka you targeted the building directly), then set "Destination" to be 150 units away from "Target" in random angle.

    (1) Recover all necessary data from the game cache, save "Teleporting" for "Hero" as false, show "MassTeleportCaster" effect on "Hero" and "MassTeleportTarget" at "Destination", destroy the "MassTeleportTo" effects and the UberSplat. Then if the trigger was called because "Hero" has finished casting a spell and the spell was Town Portal, set "Hero"'s position to "Destination" and destroy trees in 190 square AoE from "Destination".

    Notes: Since the trigger checks for finishing casting of any spell, the teleport will be interrputed by casting Windwalk or other spells that do not usually cancel channeling.
    You can end up up to 350 units away from the "Target" structure, but if you click too far, you'll get only 250 units from it.

    [TABLE][​IMG]| Orchid Malevolence[/TABLE]

    Soul Burn (A0FD)
    Based on Soul Burn, which only provides the silence for 5 seconds.

    When it goes into effect, then save "Target" and "Source" (the casting unit) to the game cache and create a trigger (1) to be called in 0 seconds.

    (1) This new trigger recovers "Target" and "Source" from the cache, then saves "Source" and "TargetIndex" (the target saved in an array) to the game cache. Then effect "FX" (SilenceTarget) is created on the target's head and, "Damage" (0 for now) is saved to the cache and a new trigger is created (2) to be called in 5 seconds or when "Target" is damaged.

    (2) The trigger recovers "Source", "TargetIndex" and "Damage" from the game cache. Then if it was called because of the timer event or the "Target" doesn't have the Soul Burn buff (B031) anymore, destroy the trigger and the "FX" effect and then make the "Source" damage the "Target" for "Damage" with Attack Type Spells, Damage Type Fire. Then if "Damage" is bigger than 0, show the number on top of the "Target".
    If it was called because "Target" was damaged and the damage is bigger than 1, then save "Damage"+0.2*EventDamage to the game cache as "Damage".

    Notes: Since the trigger checks for the buff, the effect can be ended by Purge or Aphotic Shield. Casting Bloodrage on the Target or activating Last Word will end the effect too, as they also use Soul Burn and will override the buff.

    [TABLE][​IMG]| Armlet of Mordiggian[/TABLE]

    There are several triggers associated with this item.

    Switch on/off
    When Armlet is switched, then if it's a switch-on, do (1), else do (2).

    (1) Set "Difference" to be UnitMaxLife-UnitCurrentLife. Then Remove Armlet of Mordiggian (I00Q) from the unit's inventory and add activated Armlet of Mordiggian (I00M) to the unit's inventory. Then set the unit's HP to MaxLife-Difference or 1, whichever is higher.

    (2) Set "Difference" to be UnitMaxLife-UnitCurrentLife. Then Remove activated Armlet of Mordiggian (I00M) from the unit's inventory and add Armlet of Mordiggian (I00Q) to the unit's inventory. Then set the unit's HP to MaxLife-Difference or 1, whichever is higher.

    The degen
    When a unit picks up an activated Armlet of Mordiggian (I00M), then create a periodic trigger (3) to be called every 1 second or when the unit drops an item. Save the unit as "Hero" and the Armlet as "Item" to the game cache.

    (3) If it was called because "Hero" dropped an item and the item was "Item", then destroy this trigger. If it was called because of the timer event, set "Hero"'s HP to CurrentLife-35 or 1, whichever is higher.

    Additional abilities
    When a unit picks up or drops an item, then if the item was deactivated Armlet, do (4), and if it was activated Armlet, do (5).

    (4) If the item was dropped, then remove the Item Life Regeneration ability (A0PS) from the dropping unit. If the item was picked up, then add the Item Life Regeneration ability (A0PS) to the unit.

    (5) If the item was dropped, then remove the Item Life Regeneration ability (A0PS), the Item Attack Speed Bonus ability (A0TC) and the Item Armor Bonus ability (A0UK) from the dropping unit. If the item was picked up, then add those three abilities (A0PS, A0TC, A0UK) to the unit.

    The Item Life Regeneration ability (A0PS) gives +3 HP/s regen, the Item Attack Speed Bonus ability (A0TC) gives +25% IAS and the Item Armor Bonus ability (A0UK) doesn't give anything, only provides the purple orb-thingy around the Hero's weapon, when Armlet is on.

    Other stuff
    There's also a trigger that makes a unit unable to carry more than one Armlet (dropping the other on the ground) and changes Armlet to Courier Edition, when picked up by Chicken, Crow or Spirit Bear, but the coding is kinda messy and there was an exploit fixed in 6.59d, so I won't elaborate on this part. Triggers (1)-(5) are not evaluated for courier versions of armlet, as they have different ID.

    Armlet Abilities:

    Armlet of Mordiggian (deactivated)
    A0T7 (Item Agility Gain): dummy, serves for Armlet activation, cooldown 10 seconds
    AId5 (Item Armor Bonus): +5 armor
    AIt9 (Item Damage Bonus): +9 damage
    AIsx (Item Attack Speed Bonus): +15% IAS

    Armlet of Mordiggian (activated)
    A0T8 (Item Agility Gain): dummy, serves for Armlet deactivation
    AId5 (Item Armor Bonus): +5 armor
    A00I (Item Hero Stat Bonus): +25 strength
    A03L (Item Damage Bonus): +40 damage

    The courier versions of Armlet lack the active abilities (A0T7 and A0T8 respectively).

    Notes: Functions (1) and (2) make sure you gain exactly 475 HP when switching Armlet on and lose 475 HP when switching Armlet off (you can only lose less if your current life is below 476). Why does it have to be triggered? Because changing bonus Strength from items (the +green number) makes the hero keep the same HP percentage (you can test it by dropping an Ogre Axe for example), so after switching Armlet off, you would always lose less than the intended 475 HP (only at full HP you'd lose exactly 475 life).
    After changing form using a Metamorphosis based spell (like Troll's melee/ranged form, Syllabear's True Form, TB's Metamorphosis, KotL's Spirit Form etc.) the hero will lose the abilities added by triggers (the regen A0PS, the attack speed A0TC and the effect A0UK)! In the new form, you have to switch the armlet on/off in order to gain the abilities back.
    The additonal abilities are given via triggers, because an item can have no more than 4 abilities (Spellbook is out of question because of the active ability).

    [TABLE][​IMG]| Force Staff[/TABLE]

    Force (A19M)
    Based on Channel with 800 casting range.

    When the spell is cast and the target isn't Roshan (n00L) then if the target is an enemy unit or an ally with Disable Help off, do (1).

    (1) Set the target point to be 600 units from the target unit in the angle that the unit is facing. Then check 24 points of the trajectory (each 25 units of distance), starting at the target point. Set the first point found that doesn't belong to the forbidden areas to be the "TargetPoint". Set "d" to be the distance between "Target" (the targeted unit) and "TargetPoint".
    Create a new trigger (2) to be called every 0.03 seconds or when "Target" dies. Save "d", "a" (the target unit's facing angle) and "Target" to the game cache.

    (2) Recover "Target", "a" and "d" from the cache. If the trigger was called because "Target" has died or it has been called 11 times, then destroy this trigger.
    Else set "NextWaypoint" to be d/10 units of distance from "Target" in angle "a". Destroy trees in 150 square AoE from "NextWaxpoint", show the special effect (FlakTarget) at "NextWaxpoint" and set "Target"'s X and Y to that of "NextWaypoint".

    Notes: The whole movement lasts for 0.3 seconds.
    The terrain checking part is kinda hard to read: If there's a cliff or unpathable terrain 600 units of distance in front of the unit, the movement stops before the cliff. However, if there's pathable terrain behind, you can go over the cliff. The forbidden areas consist of almost 100 rectangles all over the map, so won't go into detail on this. It is done well, so it is almost impossible to stuck yourself or someone else in unpathable terrain.
    The movement is done by SetUnitX() and SetUnitY(), therefore it doesn't interrupt channeling or other commands.

    [TABLE][​IMG]| Black King Bar[/TABLE]

    Avatar (A11F/A11E/A0S3/A11D/A11G/A11H)
    Based on Summon Water Elemental (dummy).

    When Avatar goes into effect, do (1).

    (1) Create a dummy unit [e00E] at the casting unit's position. Save the casting unit as "Hero".
    If the ability cast was [A11F], set Duration to 10 seconds.
    If the ability cast was [A11E], set Duration to 9 seconds.
    If the ability cast was [A0S3], set Duration to 8 seconds.
    If the ability cast was [A11D], set Duration to 7 seconds.
    If the ability cast was [A11G], set Duration to 6 seconds.
    If the ability cast was [A11H], set Duration to 5 seconds.
    Then add a Spell Book [A0FY] to "Hero" and create a trigger that removes the Spell Book from "Hero" after Duration seconds.
    If the ability cast was [A11F], then add an Anti-magic Shell based ability [A11B] to the [e00E] dummy.
    If the ability cast was [A11E], then add an Anti-magic Shell based ability [A11A] to the [e00E] dummy.
    If the ability cast was [A0S3], then add an Anti-magic Shell based ability [A0S2] to the [e00E] dummy.
    If the ability cast was [A11D], then add an Anti-magic Shell based ability [A119] to the [e00E] dummy.
    If the ability cast was [A11G], then add an Anti-magic Shell based ability [A11C] to the [e00E] dummy.
    If the ability cast was [A11H], then add an Anti-magic Shell based ability [A118] to the [e00E] dummy.
    Then order the dummy unit to cast the Anti-magic Shell on "Hero".
    If "Hero" is a courier, do (2) with paramater ScalingFactor = 6. Else do (2) with parameter ScalingFactor = 1.4. Create a trigger (3) to be called in Duration+7 seconds.

    (2) Set Endscale to ScalingFactor*UnitDotAScale (some units/heroes have altered Scale in DotA to be smaller/larger than in ladder Warcraft). Create a trigger (4) to be called in Duration seconds. Then if Duration is bigger than 3 seconds (which always is), create another trigger (5) to be called each 0.025 seconds.

    (3) If "Hero" isn't dead, isn't null and the Mini Heroes mode is on, set the X, Y and Z scale of "Hero" to UnitDotAScale*0.5.

    (4) Create a trigger (6) to be called every 0.025 seconds.

    (5) If Runtimes is bigger than 40 or "Hero" is dead, destroy this trigger. Else set the X, Y and Z scaling of "Hero" to UnitDotAScale+EndScale-UnitDotAScale*Runtimes/40.

    (6) If Runtimes is bigger than 40 or "Hero" is dead, destroy this trigger. Else set the X, Y and Z scaling of "Hero" to EndScale-(EndScale-UnitDotAScale)*Runtimes/40.

    Cooldown/duration reduction
    When an item is used, then:
    If the item is Black King Bar (10) [I0FZ], store the inventory slot number into a variable, then remove the item from the unit's inventory, create an item [I0G0] Black King Bar (9) and add it to the stored inventory slot of the unit.
    If the item is Black King Bar (9) [I0G0], store the inventory slot number into a variable, then remove the item from the unit's inventory, create an item [I0FY] Black King Bar (8) and add it to the stored inventory slot of the unit.
    If the item is Black King Bar (8) [I0FY], store the inventory slot number into a variable, then remove the item from the unit's inventory, create an item [I0FS] Black King Bar (7) and add it to the stored inventory slot of the unit.
    If the item is Black King Bar (7) [I0FS], store the inventory slot number into a variable, then remove the item from the unit's inventory, create an item [I09D] Black King Bar (6) and add it to the stored inventory slot of the unit.
    If the item is Black King Bar (6) [I09D], store the inventory slot number into a variable, then remove the item from the unit's inventory, create an item [I0G1] Black King Bar (5) and add it to the stored inventory slot of the unit.

    BKB Avatar abilities:
    Code:
    Black King Bar (10) [A11F]    cooldown: 80 
    Black King Bar (9)  [A11E]    cooldown: 75 
    Black King Bar (8)  [A0S3]    cooldown: 70 
    Black King Bar (7)  [A11D]    cooldown: 65 
    Black King Bar (6)  [A11G]    cooldown: 60 
    Black King Bar (5)  [A11H]    cooldown: 55
    Other abilities mentioned:
    Code:
    [A0FY] Spell Book         contains a Spell Immunity ability [A0S6]
    [A11B] Anti-magic Shell   duration 10 seconds
    [A11A] Anti-magic Shell   duration 9 seconds
    [A0S2] Anti-magic Shell   duration 8 seconds
    [A119] Anti-magic Shell   duration 7 seconds
    [A11C] Anti-magic Shell   duration 6 seconds
    [A118] Anti-magic Shell   duration 5 seconds
    Notes: The Anti-magic Shell provides the buff, the Spell Immunity ability is there to make the effect unpurgeable.
    Avatar increases the size of model 6 times for couriers and 1.4 times for heroes and other units.


    [TABLE][​IMG]| Ghost Scepter[/TABLE]

    Ghost Form (A1AC)
    Based on Fan of Knives (dummy).

    When it goes into effect and the casting unit is not magic immune, do (1).

    (1) Save the casting unit as "Source". Add the ability Ethereal [Aetl] to "Source" and make the ability unavailable (so the icon is not shown). Then create a periodic trigger (2) to be called every 0.1 seconds or when "Source" dies.

    (2) Recover "Source" from the game cache. If the trigger has been called more than 40 times or it's been called because "Source" has died or "Source" is magic immune or "Teleporting" is true for "Source", then remove the [Aetl] ability from "Source" and destroy this trigger.

    Notes: the trigger considers the unit magic immune if the unit has any of the folowing abilities: [A0S6] (Spell Immunity from BKB), [A179] (Spell Immunity used in Nether Strike and Charge of Darkness),[ACmi] (Spell Immunity - Neutral Hostile), [A0SU] (Spell Immunity from Rage), [B014] (Repel debuff) or "BladeFury" active.
    "Source" loses the Ethereal form when he starts teleporting by Scroll of Town Portal or Boots of Travel.



    [TABLE][​IMG]| Mjollnir[/TABLE]

    Static Charge (A0JL)
    Based on Channel with 600 casting range.

    When it goes into effect, do (1).

    (1) Save the casting unit as "Source" and the target as "Target". Create a trigger (2) to be called in 20 seconds or when "Target" is attacked. Create the special "FX" effect (LightningShieldTarget) on "Target".

    (2) If the trigger was called because "Target" has been attacked, random integer from 1 to 100 is less than 21 and "StaticCharge|CD" is false, do (3).
    If the trigger was called because 20 seconds have passed, then destroy the "FX" effect on "Target" and destroy this trigger.

    (3) Create a dummy unit [e00E] for the owner of "Source", add it a Forked Lightning based ability [A0K6] and order it to cast the lightning on the attacking unit. Then set "StaticCharge|CD" as true for 1 second.

    Notes: the Forked Lightning can hit up to 3 units and deals 200 damage per target. The dummy unit is situated at the "Target"'s position and the Forked Lightning has a casting range of 600, so if the attacker is farther than 600 units of distance (for example Sniper), the dummy cannot cast the spell.


    [TABLE][​IMG]| Khadgar's Pipe of Insight [/TABLE]

    Barrier (A1EW)
    Based on Fan of Knives.

    When the spell goes into effect, do (1).

    (1) Create a dummy unit [e00E] at the caster's position and add an Anti-Magic Shell based ability [A1EV] to it. Then count all units satisfying Condition 1 in 525 AoE around the caster.
    For each of those units, do (2).

    (2) If the unit has "Barrier|CD" equal to 1, do (3). Else do (4).

    (3) Show the text "Mekansm failed to heal" to the unit's owner.

    (4) If the unit is a hero, assign it "Barrier|CD" = 1 for 50 seconds (after that, it is set to 0).
    Order the dummy unit to cast Anti-Magic Shell on the enum unit.

    Condition 1:
    a) The unit is a hero or it is owned by the Sentinel (Player 0) or Scourge (Player 6).
    b) The unit is not an enemy of the caster.
    c) The unit is not a dummy unit.
    d) The unit is not a structure.
    e) The unit is alive.
    f) The unit is not an Ancient or it's a Spirit Bear or Ignis Fatuus.
    All points a) - f) must be satisfied.


    Notes:
    The Anti-Magic Shell has a duration of 8 seconds and absorbs up to 400 spell damage. Because the spell has a casting range of 500, there can be a rare case when the hero is counted for the effect, but the dummy unit cannot cast the spell, because the hero is out of range (can happen only with Naga Siren).
    Also note that the message displayed is wrong, it uses a part of the Mekansm message.
     
    Last edited: Mar 9, 2010
  2. antiweltteilchen

    antiweltteilchen Well-Known Member

    good to see this guide here too. /me pats 3DM@rk on shoulder
     
    Last edited: Jun 16, 2009
  3. Protomanx1

    Protomanx1 Well-Known Member

    Moved to Advanced Mechanics Guides.
     
  4. j-frost

    j-frost Member

    Nice guide... just got a question: Why is Shiva's damage Fire-Spells-type? oO
     
  5. SoletLuna

    SoletLuna Moderator

    It's making the spell dealing magical damage.

    It doesn't matter if it is Fire or Ice. Just for convenience and consistency, I suppose.
     
  6. j-frost

    j-frost Member

    OK... I just thought that to be quite freaky :S
     
  7. 3DM@rk

    3DM@rk Well-Known Member

    To save lines of code and some performace there is a generic function to deal damage in DotA. Most triggered spells including Frigid Blast use it.
    The function deals the specified damage amount with
    1) Attack Type Spells, Damage Type Fire
    2) Attack Type Hero, Damage Type Normal
    3) Attack Type Hero, Damage Type Magic
    4) Attack Type Piercing, Damage Type Normal
    depending on the parameter the function was called with.

    The point is, that there are tons of damage types that have indentical properties (like Fire/Cold/Magic/Mind etc.), therefore only one of them can be used to save space.
     
  8. j-frost

    j-frost Member

    Ah, now that sounds very logical too me :)
     
  9. Baoz

    Baoz Well-Known Member

    Ahh, I finally understand why sometimes after a nuke a hero can still use kelens dagger.
     
  10. 3DM@rk

    3DM@rk Well-Known Member

    *Added BKB. Still working on a new layout.
    *Added Ghost Scepter and Mjollnir.
     
    Last edited: Jul 13, 2009
  11. Cáno

    Cáno Well-Known Member

    Oh hai. Can u giev me deobfuscated code plz?

    I wonder how does the Quell work. There are lots of possibilities I think.

    A lot of great work have been done here. It clears a lot of my doubts.
    I wondered where did the slight Shiva's animation change came from and why does the Bloodstone sometimes appear as a hero in the score table. Good to know about Energy Charge's exceptions too (are they listed anywhere else?).

    Offtopic: I still hope that Tales' work on hero abilities will be continued.
     
    Last edited: Mar 8, 2010
  12. Robzor

    Robzor Well-Known Member

    There are no triggers involved with Quelling Blade, the bonus damage comes from a Demolish based ability and Tree Chop is based on Eat Tree.
     
  13. 3DM@rk

    3DM@rk Well-Known Member

    There's actually one "small" trigger which decides whether the unit gets the melee or the ranged Quelling Blade upon picking up.

    You no longer need a deobfuscator, the OI01 charmap isn't used as of 6.61.
    The exceptions should be somewhere on the DA forums as well.
     
  14. Cáno

    Cáno Well-Known Member

    Good to know. Things just got a bit easier for me.

    About Quell: I've read somewhere that in beta versions the Quell ability would not work if the hit without Quell's bonus damage wouldn't be fatal. I don't know if that's true but that would surely require Quell to be triggered. That's why I asked.
     
    Last edited: Mar 8, 2010
  15. SNOW37

    SNOW37 Well-Known Member

    I think there might be a problem with magic stick/wand.
    I was using it against invoker and got charges for his castiing of wex, quas, and exort.
    I dont if this is a glitch in the code, but it has happened to me more than once.
     
  16. gnaLor

    gnaLor Well-Known Member

    Btw was is fixed that you can get +36% Quelling blade or 25% bash with Troll/dragonknight/Soulkeeper/Bear and all the guys who can morph from melee to range?
     
  17. Foede

    Foede Forum Manager

    AFAIK, it's still there.
     
  18. SoletLuna

    SoletLuna Moderator

    Don't recall QB has been fixed in this matter.
    For Basher it won't work.
    Basher gives the corresponding Bash-Chance/Ability to the right form, it doesn't matter with Basher in which form you pick it up.
     
  19. 3DM@rk

    3DM@rk Well-Known Member

    Removed Mask of Madness, as it doesn't have any triggers involved anymore. Added Heart of Tarrasque. I'm working on Bloodstone.
     
  20. Whizzlinka

    Whizzlinka Member

    thanks alot