1. Choose the best Old Gods themed skin at the Texturing Contest #29 - Poll!
    Dismiss Notice
  2. Melee Mapping Contest #2 - Poll is up! Vote for the best competitive 1v1 map!
    Dismiss Notice
  3. Please help test custom maps and more on the latest PTR!
    Dismiss Notice
  4. Evolution complete! Make Darwin proud and go vote in the Techtree Contest #12 - Poll.
    Dismiss Notice
  5. Icon Contest #17 - Results are out! Step by to congratulate our winners!
    Dismiss Notice
  6. We've created the Staff Job Openings thread. We're currently in need of icon, video production, and social/multimedia positions to be filled. Thank you!
    Dismiss Notice

[Trigger] Team Level Trigger

Discussion in 'Triggers & Scripts' started by King Valdezar, Jun 14, 2018.

  1. King Valdezar

    King Valdezar

    Joined:
    Jun 19, 2017
    Messages:
    100
    Resources:
    0
    Resources:
    0
    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?
     
  2. Glint

    Glint

    Joined:
    Dec 28, 2014
    Messages:
    50
    Resources:
    1
    Maps:
    1
    Resources:
    1
    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.
     
  3. Kaijyuu

    Kaijyuu

    Joined:
    Jun 2, 2004
    Messages:
    848
    Resources:
    0
    Resources:
    0
    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.
     
  4. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,056
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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.
    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: Jun 15, 2018
  5. pick-a-chew

    pick-a-chew

    Joined:
    Jul 15, 2007
    Messages:
    627
    Resources:
    4
    Icons:
    2
    Maps:
    2
    Resources:
    4
    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.
     
  6. nedio95

    nedio95

    Joined:
    Mar 24, 2011
    Messages:
    1,056
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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
     
  7. Kaijyuu

    Kaijyuu

    Joined:
    Jun 2, 2004
    Messages:
    848
    Resources:
    0
    Resources:
    0
    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.
     
  8. pick-a-chew

    pick-a-chew

    Joined:
    Jul 15, 2007
    Messages:
    627
    Resources:
    4
    Icons:
    2
    Maps:
    2
    Resources:
    4
    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.
     
  9. King Valdezar

    King Valdezar

    Joined:
    Jun 19, 2017
    Messages:
    100
    Resources:
    0
    Resources:
    0
    I managed to solve it in a rather unusual way, but thanks for the help +rep for all :)
     
  10. King Valdezar

    King Valdezar

    Joined:
    Jun 19, 2017
    Messages:
    100
    Resources:
    0
    Resources:
    0
    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