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

[Trigger] Team Level Trigger

Status
Not open for further replies.
Level 7
Joined
Jun 19, 2017
Messages
141
Hello, I have made a Team Level trigger for my map, that works like this:
  • Team Level
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • -------- Horde --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
        • Then - Actions
          • Set HordeLevelCounter = (HordeLevelCounter + 1)
          • Set HordeTeamLevel = ((HordePlayers + HordeLevelCounter) / HordePlayers)
        • Else - Actions
Where HordeLevelCounter starts from 0 and gets + 1 everytime a hero gains a level,
and HordeTeamLevel is equal to the (number of active players + the above integer) devided by the number of active players. The trigger seems to work, but it has a bug in this line
  • Set HordeLevelCounter = (HordeLevelCounter + 1)
the bug is when a hero gains more than 1 level at once e.g. kill a very high level creep or player, the integer always counts +1 and i was wondering if i can make it count the number of levels that the hero has gained rather than always add 1?
 
Level 7
Joined
Dec 28, 2014
Messages
83
The map should track the previous level of each hero. Create a integer array variable named PreviousHeroLevel where the index is the player number of the hero and the value is the previous level. At initialization or hero pick, set the value based on the initial level of the hero.

Once a hero gains a level:

  • Set HordeLevelCounter = (HordeLevelCounter + ((Hero level of (Triggering unit)) - PreviousHeroLevel[(Player number of (Owner of (Triggering unit)))]))
then at the end of the trigger, update the previous level:

  • Set PreviousHeroLevel[(Player number of (Owner of (Triggering unit)))] = (Hero level of (Triggering unit))
If a player is using more than one hero, you have to use hashtables or unit indexer to store the previous hero level.
 
Level 11
Joined
Jun 2, 2004
Messages
849
If you're not using the unit's custom value you could also use that to store the previous level.

A dummy ability would also work (setting its level to the hero's previous level), provided the number of hero levels is < 20 or so. Too much overhead if hero levels get high though.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
If you're not using the unit's custom value you could also use that to store the previous level.
Custom value is much more useful for an indexing system. Major suggestion is to not use it for anything else regardless if you're using one or not.
A dummy ability would also work (setting its level to the hero's previous level), provided the number of hero levels is < 20 or so. Too much overhead if hero levels get high though.
Please, don't. Abilities with more than 10 levels are not particularly good for the game engine and tend to break.

@King Valdezar
You could track hero experience instead of level and synchronize with that instead.
This becomes a bit complicated though...

I would suggest just iterating through the horde heroes and combining their levels.
  • Set HordeTeamLevel = HordePlayers
  • For intIndex from 0 to NumberOfHordeHeroes
    • Loop
      • HordeTeamLevel = HordeTeamLevel + HordeHero[intIndex]
  • Set HordeTeamLevel = HordeTeamLevel / HordePlayers
In my code I am using HordeHero[] which is a unit array, but you could do any form of iteration.
I've done that as I think it looks the simplest to understand as it has a lot of variables that can be named in an explanatory way.
I'd even suggest doing one of the following:
  • You could dynamically check everything on the map every time. No other permanent variables would be needed.
  • You could also store all horde heroes in a unit group and loop through that.
Feel free to ask for any further explanations.

Hope this helps!
-Ned
 
Last edited:
Level 13
Joined
Jul 15, 2007
Messages
763
Abilities with more than 10 levels are not particularly good for the game engine and tend to break.

Your reasoning on this comes across as unfounded. How do they break? What kind of abilities break? Do you actually have any proof for this claim?

Generally a dummy or blank abilities with 10-100 levels if fine on two conditions: all of their fields are blank to keep their space low (a 100 level ability with no almost no data is safely under 1kb) and that you preload them at an appropriate time (more levels = takes longer to load for the first time).

Using hidden/passive abilities with multiple levels as "hidden indicators" on units is particularly convenient, especially for those who are new to triggering and are still wrestling with the wonderful thing that is GUI. It's a perfectly simple solution for King Valdezar assuming hero levels don't go over 100.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Your reasoning on this comes across as unfounded. How do they break? What kind of abilities break? Do you actually have any proof for this claim?

Generally a dummy or blank abilities with 10-100 levels if fine on two conditions: all of their fields are blank to keep their space low (a 100 level ability with no almost no data is safely under 1kb) and that you preload them at an appropriate time (more levels = takes longer to load for the first time).

Using hidden/passive abilities with multiple levels as "hidden indicators" on units is particularly convenient, especially for those who are new to triggering and are still wrestling with the wonderful thing that is GUI. It's a perfectly simple solution for King Valdezar assuming hero levels don't go over 100.

You could be right. To be completely honest, I don't remember. I remember reading something of the sort long long time ago trying to explain why ability levels should be kept under 10, but don't remember 100% of the details. My memories tell me that it was something to do with wrong data reference on high levels, e.g. lvl 523 would use data of lvl 520. Anyway.

By blank you mean non-pink.
Pink fields are changed data that is stored.
If you change a native field (black) to blank it becomes pink, the data there has to be stored. E.g. an empty string
I'd guess, if a spell has 3 levels in war3 and you make it 10, then lvls 4-10 would turn pink even if you don't touch them. May be mistaken, easy to check with WE around.

regards
-Ned
 
Level 11
Joined
Jun 2, 2004
Messages
849
I never have abilities over 100 levels (and even then, no more than 1 or 2 abilities like that) entirely because of loading time issues. I dunno what Blizz did but apparently loading abilities is O(n^2) or something crazy.
 
Level 13
Joined
Jul 15, 2007
Messages
763
That's true about the pink fields. Though, if i ever use an ability as an indicator/unit tag, i use Armor Bonus (item ability) which has almost 0/empty values for all fields except for level 1 which has a value in the Defense Bonus field. Edit: A level 3 custom holy light takes up more space than a level 100 armor bonus ability.
 
Level 7
Joined
Jun 19, 2017
Messages
141
If someone is curious, here's the triggers:
First
  • Map Int
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Team Level Requirments --------
      • Set TeamLevelUpgrade[2] = Team Level: 2
      • Set TeamLevelUpgrade[3] = Team Level: 3
      • Set TeamLevelUpgrade[4] = Team Level: 4
      • Set TeamLevelUpgrade[5] = Team Level: 5
      • Set TeamLevelUpgrade[6] = Team Level: 6
      • Set TeamLevelUpgrade[7] = Team Level: 7
      • Set TeamLevelUpgrade[8] = Team Level: 8
      • Set TeamLevelUpgrade[9] = Team Level: 9
      • Set TeamLevelUpgrade[10] = Team Level: 10
      • Set TeamLevelUpgrade[11] = Team Level: 11
      • Set TeamLevelUpgrade[12] = Team Level: 12
      • Set TeamLevelUpgrade[13] = Team Level: 13
      • Set TeamLevelUpgrade[14] = Team Level: 14
      • Set TeamLevelUpgrade[15] = Team Level: 15
      • Set TeamLevelUpgrade[16] = Team Level: 16
      • Set TeamLevelUpgrade[17] = Team Level: 17
      • Set TeamLevelUpgrade[18] = Team Level: 18
      • Set TeamLevelUpgrade[19] = Team Level: 19
      • Set TeamLevelUpgrade[20] = Team Level: 20
Second
  • Team Level
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Playable map area) contains (Triggering unit)) Equal to True
      • ((Owner of (Triggering unit)) slot status) Equal to Is playing
      • (Owner of (Triggering unit)) Not equal to Neutral Passive
    • Actions
      • -------- Horde --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) belongs to an ally of Player 1 (Red)) Equal to True
        • Then - Actions
          • Set Team[1] = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Owner of (Matching unit)) slot status) Equal to Is playing) and (((Owner of (Matching unit)) Not equal to Neutral Passive) and (((Matching unit) belongs to an ally of
          • Unit Group - Pick every unit in Team[1] and do (Actions)
            • Loop - Actions
              • For each (Integer LoopPlayers) from 1 to (Number of units in Team[1]), do (Actions)
                • Loop - Actions
                  • Set PlayerNumber[(Player number of (Owner of (Picked unit)))] = (Level of (Picked unit))
          • Custom script: call DestroyGroup(udg_Team[1])
          • Set HordeTeamLevel = (((PlayerNumber[2] + PlayerNumber[3]) + (PlayerNumber[4] + PlayerNumber[5])) / HordePlayers)
          • For each (Integer LoopTeamLevel) from 1 to HordeTeamLevel, do (Actions)
            • Loop - Actions
              • Player - Set the current research level of TeamLevelUpgrade[LoopTeamLevel] to 1 for Player 1 (Red)
        • Else - Actions
      • -------- Alliance --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) belongs to an ally of Player 6 (Orange)) Equal to True
        • Then - Actions
          • Set Team[2] = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Owner of (Matching unit)) slot status) Equal to Is playing) and (((Owner of (Matching unit)) Not equal to Neutral Passive) and (((Matching unit) belongs to an ally of
          • Unit Group - Pick every unit in Team[2] and do (Actions)
            • Loop - Actions
              • For each (Integer LoopPlayers) from 1 to (Number of units in Team[2]), do (Actions)
                • Loop - Actions
                  • Set PlayerNumber[(Player number of (Owner of (Picked unit)))] = (Level of (Picked unit))
          • Custom script: call DestroyGroup(udg_Team[2])
          • Set AllianceTeamLevel = (((PlayerNumber[7] + PlayerNumber[8]) + (PlayerNumber[9] + PlayerNumber[10])) / AlliancePlayers)
          • For each (Integer LoopTeamLevel) from 1 to AllianceTeamLevel, do (Actions)
            • Loop - Actions
              • Player - Set the current research level of TeamLevelUpgrade[LoopTeamLevel] to 1 for Player 6 (Orange)
        • Else - Actions
 
Status
Not open for further replies.
Top