• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Make a hero learn all the same skills as another hero once it spawns

Level 24
Joined
Feb 27, 2019
Messages
833
Hmm. It seems youre right about the need for custom scripts, which is odd since Learn skill uses Ability Code but no variables are available in the selection. Typical GUI.

Heres an example:
  • Player Hero Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Triggering unit) Equal to PlayerHero
    • Actions
      • Set VariableSet LearnIndex = (LearnIndex + 1)
      • Custom script: set udg_LearnSkill[udg_LearnIndex] = GetLearnedSkillBJ()
      • Game - Display to (All players) the text: (Name of LearnSkill[LearnIndex])
  • AI Hero Spawn
    • Events
    • Conditions
    • Actions
      • For each (Integer L) from 1 to LearnIndex, do (Actions)
        • Loop - Actions
          • Custom script: call SelectHeroSkill(udg_AI_Hero, udg_LearnSkill[udg_L])
          • Game - Display to (All players) the text: (Name of LearnSkill[L])
 
Level 4
Joined
Sep 29, 2010
Messages
29
Hmm. It seems youre right about the need for custom scripts, which is odd since Learn skill uses Ability Code but no variables are available in the selection. Typical GUI.

Heres an example:
  • Player Hero Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Triggering unit) Equal to PlayerHero
    • Actions
      • Set VariableSet LearnIndex = (LearnIndex + 1)
      • Custom script: set udg_LearnSkill[udg_LearnIndex] = GetLearnedSkillBJ()
      • Game - Display to (All players) the text: (Name of LearnSkill[LearnIndex])
  • AI Hero Spawn
    • Events
    • Conditions
    • Actions
      • For each (Integer L) from 1 to LearnIndex, do (Actions)
        • Loop - Actions
          • Custom script: call SelectHeroSkill(udg_AI_Hero, udg_LearnSkill[udg_L])
          • Game - Display to (All players) the text: (Name of LearnSkill[L])
Yooooo I think I can totally figure it out now, thank you!
 
Level 4
Joined
Sep 29, 2010
Messages
29
Hmm. It seems youre right about the need for custom scripts, which is odd since Learn skill uses Ability Code but no variables are available in the selection. Typical GUI.

Heres an example:
  • Player Hero Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Triggering unit) Equal to PlayerHero
    • Actions
      • Set VariableSet LearnIndex = (LearnIndex + 1)
      • Custom script: set udg_LearnSkill[udg_LearnIndex] = GetLearnedSkillBJ()
      • Game - Display to (All players) the text: (Name of LearnSkill[LearnIndex])
  • AI Hero Spawn
    • Events
    • Conditions
    • Actions
      • For each (Integer L) from 1 to LearnIndex, do (Actions)
        • Loop - Actions
          • Custom script: call SelectHeroSkill(udg_AI_Hero, udg_LearnSkill[udg_L])
          • Game - Display to (All players) the text: (Name of LearnSkill[L])
I forgot to ask how about the level of the skills is there a way to apply that?
 
Level 24
Joined
Feb 27, 2019
Messages
833
The example trigger records all skills picked and repeats them for the ai hero. That includes how many times the abilities were picked. Do you need to store the levels of the abilities for another reason?

These triggers does it a bit differently to store each learned skill in a single array. It also stores the level in SkillLevel with the same array.
  • Player Hero Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Triggering unit) Equal to PlayerHero
    • Actions
      • For each (Integer Loop[0]) from 1 to LearnIndex, do (Actions)
        • Loop - Actions
          • Custom script: if udg_LearnSkill[udg_Loop[0]] == GetLearnedSkillBJ() then
          • Set VariableSet SkillLevel[Loop[0]] = (SkillLevel[Loop[0]] + 1)
          • Game - Display to (All players) the text: (Name of LearnSkill[Loop[0]])
          • Game - Display to (All players) the text: (String(SkillLevel[Loop[0]]))
          • Skip remaining actions
          • Custom script: endif
      • Set VariableSet LearnIndex = (LearnIndex + 1)
      • Set VariableSet SkillLevel[LearnIndex] = (SkillLevel[LearnIndex] + 1)
      • Custom script: set udg_LearnSkill[udg_LearnIndex] = GetLearnedSkillBJ()
      • Game - Display to (All players) the text: (Name of LearnSkill[LearnIndex])
      • Game - Display to (All players) the text: (String(SkillLevel[LearnIndex]))
  • AI Hero Spawn
    • Events
    • Conditions
    • Actions
      • For each (Integer Loop[0]) from 1 to LearnIndex, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of LearnSkill[Loop[0]])
          • Game - Display to (All players) the text: (String(SkillLevel[Loop[0]]))
          • For each (Integer Loop[1]) from 1 to SkillLevel[Loop[0]], do (Actions)
            • Loop - Actions
              • Custom script: call SelectHeroSkill(udg_AI_Hero, udg_LearnSkill[udg_Loop[0]])
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
You can duplicate heroes with Game Caches. Save the unit in a GC and then place the unit from the gamecache into the game for the correct owning player. That will exactly duplicate the hero down to items. It will not match current health/mana values, so you must do that yourself. Example:
  • Escape
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • -------- Set up GC in init trigger --------
      • Unit Group - Pick every unit in (Units currently selected by Player 1 (Red)) and do (Actions)
        • Loop - Actions
          • Game Cache - Store (Picked unit) as 0 of 0 in GC
          • Game Cache - Restore 0 of 0 from GC for Player 1 (Red) at (Center of (Playable map area)) facing 0.00
          • Game Cache - Clear GC
          • -------- set mana/life/cooldowns here --------
 
Last edited:
Top