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

Remove and Add Ability Trigger

Status
Not open for further replies.
Level 3
Joined
Sep 15, 2021
Messages
31
I'm trying to remove ability from and add ability to some normal units when a Hero unit reaches to a certain level

the triggers i made seem not working at all

I think the problem is i don't know how to set units that i want a remove ability from and add it to by triggers..
Please check the triggers i attached below

Where should i fix ??


  • Sylvanas lv trigger
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Hero level of (Triggering unit)) Equal to 10) and ((Unit-type of (Triggering unit)) Equal to Sylvanas)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in (Units of type Archer).) Equal to True
        • Then - Actions
          • Unit - Remove Thunder from (Triggering unit)
          • Unit - Add Fireball to (Triggering unit)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Swordman
        • Then - Actions
          • Unit - Remove Earthquake from (Triggering unit)
          • Unit - Add Concentration to (Triggering unit)
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
Some problems with your trigger:
  • Understand that Triggering unit here is equal to the Hero that gained the level (Sylvanas). It's not equal to anything else.
  • There is only one Triggering unit which is Sylvanas. Using Triggering unit to try and reference other units doesn't work.
  • None of those Actions can ever happen because your Condition only runs if SYLVANAS reaches Level 10. The Hero that gained the level cannot be both Sylvanas AND an Archer at the same time.
  • You don't need to use AND like that in your Conditions. Conditions by default need to all be true so it's redundant.

Here's what you want to do:
  • Example
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Hero level of (Triggering unit)) Equal to 10
      • (Unit-type of (Triggering unit)) Equal to Sylvanas
    • Actions
      • Set VariableSet TempGroup = (Units of type Archer)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Thunder from (Picked unit)
          • Unit - Add Fireball to (Picked unit)
      • Custom script: call DestroyGroup (udg_TempGroup)
      • -------- --------
      • Set VariableSet TempGroup = (Units of type Swordsman)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Earthquake from (Picked unit)
          • Unit - Add Concentration to (Picked unit)
      • Custom script: call DestroyGroup (udg_TempGroup)

TempGroup is a Unit Group variable. I use the Custom script stuff to Destroy the group after it's done being used. This is necessary if you wish to avoid Memory Leaks in your map. Memory leaks are basically just unneeded information that hasn't been thrown away yet. Think of it like emptying your recycle bin after deleting some files. You can read more about it in the link in my signature Things That Leak.
 
Last edited:
Level 3
Joined
Sep 15, 2021
Messages
31
Some problems with your trigger:
  • Understand that Triggering unit here is equal to the Hero that gained the level (Sylvanas). It's not equal to anything else.
  • There is only one Triggering unit which is Sylvanas. Using Triggering unit to try and reference other units doesn't work.
  • None of those Actions can ever happen because your Condition only runs if SYLVANAS reaches Level 10. The Hero that gained the level cannot be both Sylvanas AND an Archer at the same time.
  • You don't need to use AND like that in your Conditions. Conditions by default need to all be true so it's redundant.

Here's what you want to do:
  • Example
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • (Hero level of (Triggering unit)) Equal to 10
      • (Unit-type of (Triggering unit)) Equal to Sylvanas
    • Actions
      • Set VariableSet TempGroup = (Units of type Archer)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Thunder from (Picked unit)
          • Unit - Add Fireball to (Picked unit)
      • Custom script: call DestroyGroup (udg_TempGroup)
      • -------- --------
      • Set VariableSet TempGroup = (Units of type Swordsman)
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Unit - Remove Earthquake from (Picked unit)
          • Unit - Add Concentration to (Picked unit)
      • Custom script: call DestroyGroup (udg_TempGroup)

TempGroup is a Unit Group variable. I use the Custom script stuff to Destroy the group after it's done being used. This is necessary if you wish to avoid Memory Leaks in your map. Memory leaks are basically just unneeded information that hasn't been thrown away yet. Think of it like emptying your recycle bin after deleting a lot of big files. You can read more about it in the link in my signature Things That Leak.
Oh i see
so in that trigger, only Sylvanas can be the trigger unit.

then if i want any unit except for Sylvanas get skills when Sylvanas reaches lv.10, what triggers should I use??
 
Level 3
Joined
Sep 15, 2021
Messages
31
What do you mean exactly? The trigger I posted shows you how to add Abilities to the Archer/Swordsman when Sylvanas reaches lvl 10.
oops ! my bad!
my computer sometimes becomes dumb and it didn't show your trigger script but now i see it

Thank you!
 
Level 3
Joined
Sep 15, 2021
Messages
31
What do you mean exactly? The trigger I posted shows you how to add Abilities to the Archer/Swordsman when Sylvanas reaches lvl 10.

Can I ask you one more thing?

Since my unit Archer is not on the map, it can be built in the middle of the game
I can't use it as a Preset, so in this case how do you set Archer to "Units of type Archer"

  • Sylvanas lv trigger
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Hero level of (Triggering unit)) Equal to 10) and ((Unit-type of (Triggering unit)) Equal to Sylvanas)
    • Actions
      • Set VariableSet TeamGroup = (Triggering unit)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
You have many options here. You could take advantage of the Berserker ability and Berserker upgrade to easily transform your Archers into their alternate versions. This alternate version could have the same exact stats/model/etc but have the Fireball ability instead of the Thunder ability.

So when Sylvanas reaches level 10, you research a modified version of this upgrade:
  • Player - Set the current research level of Berserker Upgrade to 1 for (Owner of (Triggering unit))
Then just like how Berserker upgrade works, all of your Archers that use this Ability will immediately transform and future Archers will do so as well.

If for some reason the Berserker approach won't work, you can instead detect when a new Archer enters the map, which will happen the moment they're created through triggers, finish training from a "Barracks", or get Summoned from an ability:
  • Archer Is Created
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Archer
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Hero level of Sylvanas) Greater than or equal to 10
        • Then - Actions
          • Unit - Remove Thunder from (Triggering unit)
          • Unit - Fireball to (Triggering unit)
        • Else - Actions
Then modify the entering Archer if Sylvanas is high enough level.
Note that the If Then Else here isn't necessary, you could put that Sylvanas Level condition in the first Conditions block if you'd like.

If you want this Enters the map trigger to work for multiple players, say if each player can control their own Sylvanas, you'll have to change it slightly to find the correct Sylvanas. This could be done with a Unit or Boolean array.
  • Conditions
    • (Hero level of SylvanasHero[(Player number of (Owner of (Triggering unit)))]) Greater than or equal to 10
  • Conditions
    • SylvanasIsTen[(Player number of (Owner of (Triggering unit)))] Equal to True
These Variables would be Set for the given Player inside of your Gains A Level trigger when Sylvanas becomes level 10.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,535
@Uncle
I would avoid using
  • Set VariableSet TempGroup = (Units of type Archer)
if I understand it correctly, it's one of the blacklisted functions that always leaks (Things That Leak)
That sounds correct, I think I read the same thing at some point but forgot about it.
So I guess you'd want to use "Units matching..." and then find the Unit-Type through that filter.
  • Set Variable TempGroup = Units matching Unit-type of matching unit equal to Archer
 
Status
Not open for further replies.
Top