• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Convert Ability to AbilityId?

Status
Not open for further replies.
Level 6
Joined
Mar 23, 2016
Messages
35
I'm trying to make a spell that creates a temporart copy of an enemy Hero to use. I can easily get all their stats, no problem.

However, I want to take it a step further and copy all of their skills as well so that I can set the ability levels of the summoned copy accordingly.
It seems possible to use
Code:
native BlzGetUnitAbilityByIndex                    takes unit whichUnit, integer index returns ability

but that brings 2 problems already. Firstly, I don't know if it can recognize Hero abilities, and secondly, I can't debug it.


Anyhow, this expedition seems failed since I can't find a way to get the Hero abilities from a Hero.
 
Level 28
Joined
Feb 18, 2014
Messages
3,580
You can check if a hero has a specific ability by detecting the level of the ability if it's greater than 0

  • Hero Copy Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Hero Illusion
      • ((Target unit of ability being cast) is A hero) Equal to TRUE
    • Actions
      • Set VariableSet Target = (Target unit of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Blizzard for Target) Greater than 0
        • Then - Actions
          • Hero - Learn skill for (Copy_Hero): Human Archmage - Blizzard
          • Unit - Set level of Blizzard for (Copy_Hero) to (Level of Blizzard for Target)
        • Else - Actions
You can also use Game Cache to store the enemy hero then create a copy of it by restoring it to the owner of the casting unit.

  • Game Cache
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Hero Illusion
      • ((Target unit of ability being cast) is A hero) Equal to TRUE
    • Actions
      • Set VariableSet Target = (Target unit of ability being cast)
      • Set VariableSet Point = (Position of Target)
      • -------- Create Game Cache --------
      • Game Cache - Clear MyCache
      • Game Cache - Create a game cache from MyCache.w3v
      • Set VariableSet MyCache = (Last created game cache)
      • -------- Store Hero --------
      • Game Cache - Store Target as Target of HeroCache in MyCache
      • -------- Save Game Cache --------
      • Game Cache - Save MyCache
      • -------- Load Game Cache --------
      • Game Cache - Restore Target of HeroCache from MyCache for (Owner of (Triggering unit)) at Point facing Point facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Point)
However, I don't know if this works on Multiplayer...
 
Last edited:
Status
Not open for further replies.
Top