• 🏆 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!

[Solved] Abilities disappear when metamorphisis

Level 8
Joined
Jun 13, 2010
Messages
344
Hero A has 5 abilities (max added in object editor) and gain 1 additional ability (Ability F) through triggers at max level.

One of the 5 abilities is Metamorphisis, which when used transforms Hero A to Hero B.

Hero B has the same initial 5 abilities through object editor, but doesn't get to keep Ability F from Hero A.

When Metamorphisis ends and it turns to Hero A yet again, Ability F is nowhere to be found.

How do I prevent this?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
Make ability F permanent:
 
Level 8
Joined
Jun 13, 2010
Messages
344
Make ability F permanent:
Thanks, but I have never used custom scripts. This isn't right, how do I do this? Ability F is based off of Berserk.


JASS:
Ultimate Ability Doom Guard Slain
    Events
        Unit - A unit Dies
    Conditions
        (Triggering unit) Equal to Boss_Doomlord
    Actions
        Set VariableSet Integer_Roll = 1
        For each (Integer Integer_Roll) from 1 to PlayerCount, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of Hero[Integer_Roll]) Equal to Demon Hunter
                    Then - Actions
                        Unit - Add Demon Hunter F to Hero[Integer_Roll]
                        Custom script:   call UnitMakeAbilityPermanent(Hero[Integer_Roll], true, Absk)
                    Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
One of these two should work:
  • Set Variable MyAbility = Berserk
  • Custom script: call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, udg_MyAbility )
  • Custom script: call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, 'Absk' )
You have to prefix all global variables with udg_ and I believe rawcodes need semi quotes.
 
Level 8
Joined
Jun 13, 2010
Messages
344
One of these two should work:
  • Set Variable MyAbility = Berserk
  • Custom script: call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, udg_MyAbility )
  • Custom script: call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, 'Absk' )
You have to prefix all global variables with udg_ and I believe rawcodes need semi quotes.
Tried the first one, it crashes.

JASS:
For each (Integer Integer_Roll) from 1 to PlayerCount, do (Actions)
    Loop - Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Unit-type of Hero[Integer_Roll]) Equal to Demon Hunter
            Then - Actions
                Unit - Add Demon Hunter F to Hero[Integer_Roll]
                Set VariableSet Ability = (Unit: Hero[Integer]'s Ability with Ability Code: Demon Hunter F)
                Custom script:   call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, udg_Demon Hunter F)
            Else - Actions

The second one didn't crash this time with the 'Absk', but it still lost the ability.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
This is incorrect:
Code:
udg_Demon Hunter F
You don't have a variable named Demon Hunter F, nor could you since it has spaces in it's name.

You would reference your Ability variable like this:
  • Set Variable Ability = Demon Hunter F
  • Custom script: call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, udg_Ability )
And your variable that is named Ability is using the wrong variable type. It's supposed to be an Ability Code variable.

Side note: When referencing rawcodes, make sure that you're using the correct one. You said the ability is based on Berserk, but is it a copy of it? If it's a copy it'll have a different rawcode.
 
Last edited:
Level 8
Joined
Jun 13, 2010
Messages
344
This is incorrect:
Code:
udg_Demon Hunter F
You don't have a variable named Demon Hunter F, nor could you since it has spaces in it's name.

You would reference your Ability variable like this:
  • Set Variable Ability = Demon Hunter F
  • Custom script: call UnitMakeAbilityPermanent( udg_Hero[udg_Integer_Roll], true, udg_Ability )
And your variable that is named Ability is using the wrong variable type. It's supposed to be an Ability Code variable.

Side note: When referencing rawcodes, make sure that you're using the correct one. You said the ability is based on Berserk, but is it a copy of it? If it's a copy it'll have a different rawcode.
Thank you - now it works. And thank you for your detail and patience :)
 
Top