• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Trigger] Metamorphosis + Add Unit/Hero Abilities

Status
Not open for further replies.
Level 2
Joined
Dec 19, 2015
Messages
12
I have this metamorphosis trigger I am using to switch out a hero into another hero.

I can't make the alternate unit acquire new abilities through triggers for some reason. Both the original unit and the alternate unit have the metamorphosis spell.

I would prefer it if the alternate unit can acquire new "learn-able" hero abilities once the original unit transforms into the alternate unit. The original unit however shouldn't have the alternate units hero/unit abilities.

I am trying to add an ability called "Vampire Strength" to the alternate unit but it doesn't show up when the original unit uses Metamorphosis(Transform Evil).

Both hero and unit abilities aren't able to be added to the alternate unit. I am not sure if I need to put these units in variables or not, but if someone could point me in the right direction, I would appreciate it.


  • Transform Evil
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Transform Evil (Vampire)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Triggering unit)) Equal to /w Knight Suit
              • (Unit-type of (Triggering unit)) Equal to /w Heavy Knight Suit
              • (Unit-type of (Triggering unit)) Equal to /w Thief Suit
              • (Unit-type of (Triggering unit)) Equal to /w Priest Suit
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to /w Nothing (Male)
        • Then - Actions
          • Custom script: call UnitRemoveAbility( GetTriggerUnit(), 'AHbu')
          • Unit - Add Vampire Strength to (Triggering unit)
          • Unit - Set level of Vampire Strength for (Triggering unit) to Vampire_Strength_Int
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Vampire
        • Then - Actions
          • Custom script: call UnitAddAbility( GetTriggerUnit(), 'AHbu')
          • Unit - Add Transform Evil (Vampire) to (Triggering unit)
          • Set Vampire_Strength_Int = (Level of Vampire Strength for (Triggering unit))
          • Unit - Remove Vampire Strength from (Triggering unit)
        • Else - Actions
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Metamorphosis has some delay (one of the duration fields) and the "starts effect of ability" event fires before the cast anyway. Non-permanent abilities (such that you add via trigger and do not use the jass function native UnitMakeAbilityPermanent takes unit whichUnit, boolean permanent, integer abilityId returns boolean on) are lost when the unit morphs. So you would either need to flag it permanently or add it properly after the transformation has finished. However, trigger-added abilities are no learnable hero skills. This can only be done in the object editor, which raises the question why you do not do that.
 
Level 2
Joined
Dec 19, 2015
Messages
12
Ahhh okay. I am not going to use morphing then. I need both sets of Hero abilities to be different from each other. Thanks a lot. :)
 
Level 2
Joined
Dec 19, 2015
Messages
12
Hmm. I tried the above and couldn't get it to work how I wanted. I got the ability added, but it seems to mess up if you level up that unit ability and transform back to the original unit.

I think it would be easier if I used the Replace Unit action because I have everything perfect on that except the inventory slot problem.

Thanks for the replies everyone. I am just going to make a new thread for the Replace Unit trigger since I don't know how to transfer over empty inventory slots to a replaced unit.
 
Catching the levels is easy. ReplaceUnit is a really impractical method and will give you a lot bigger problems than inventory.

  • Store levels
    • Events
      • A unit Starts channeling an ability
    • Conditions
      • (Ability being cast) Equal to Metamorphosis
    • Actions
      • -------- ID is a non-array integer variable --------
      • Set ID = (Custom value of (Triggering Unit))
      • If (all conditions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to FirstType
        • Then - Actions
          • Set MorphLevel1[ID] = (Level of Abil1 for (Triggering unit))
          • Set MorphLevel2[ID] = (Level of Abil2...
          • -------- Make as many arrays as you have unique abiliities for this unit type --------
        • Else - Actions
          • If (all conditions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to SecondType
            • Then - Actions
              • Set MorphLevel3[ID] = (Level of Abil3 for (Triggering unit))
The reason I am using arrays it to make it MUI, so that if another unit on your map transformed it won't overwrite the other unit's data.

Note that you shouldn't need to remove that 'AHbu' ability when the unit transforms due to the transformation removing it already.

Finally, the original trigger I showed you would be slightly changed to work with that ability level:

  • Add Abils on Morph
    • Events
      • UnitTypeEvent becomes Equal to 1.00
    • Conditions
      • (Unit-Type of UDexUnits[UDex]) Equal to MorphForm2
    • Actions
      • Unit - Add Abil1 to UDexUnits[UDex]
      • Unit - Set level of Abil1 for UDexUnits[UDex] to MorphLevel1[UDex]
 
Level 2
Joined
Dec 19, 2015
Messages
12
Bribe,

I can't seem to get it to work.

I need it so the 2nd unit gains abilities from using an ability such as channel on other specific units. Once he uses channel on a peasant and gains the ability, the next time he uses the channel on the same unit type, it will level it up. There will be a counter on it, so if he uses channel 3 times on the peasant, he obtains the new ability. If he uses the channel ability on the peasant 5 times, the ability levels up and etc. The ability can also level up if you use it a number of times.

The abilities gained from using the channel ability, or from killing units with the regular auto Attack, or being in a region, they need to check if the unit already has that ability and if he does, either level the ability up(this is for certain abilities) or do nothing.

Also, when I added an ability "Attributes Bonus" to the 2nd unit that which gave him 10+ to strength, when I metamorphed back into the 1st unit, it decreased the 1st unit's base damage by 10.
 
Last edited:
Status
Not open for further replies.
Top