Finding the average level of heroes on map

mylemonblue

You can change this now in User CP.
Reaction score
7
What I am trying to accomplish is picking every individual hero on the map at game initialization (Not counting passive non-computer/player controled heroes). Now, every so often the game will get the average of their levels and then store it in a variable. At game start a bunch of level 1 creeps are on the map based off heroes and as the average level of the player controled heroes goes up, the creep hero's levels will go up.

Now, I was able to count the number of heroes

Trigger:
  • CountHeroes
    • Events
      • Time - Elapsed game time is 0.67 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((((Picked unit) is A Hero) Equal to (==) True) and ((Owner of (Picked unit)) Not equal to (!=) Neutral Hostile))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to unitsGroup
      • Set avg = (Number of units in (Units in (Playable map area) matching (((Picked unit) is A Hero) Equal to (==) True)))


But the problem comes up when it comes time to average their levels. THere is currently three player owned heroes on the map. Right now they are pre-placed, but I want to try and figure out if, later, an additional player hero comes into the game. I figure I can add the preplaced ones into an array, but what about entering new ones? Something along the lines of this? ->

Trigger:
  • Untitled Trigger 002
    • Untitled Trigger 002
      • Events
        • Unit - A unit enters (Playable map area)
      • Conditions
        • ((Entering unit) is A Hero) Equal to (==) True
      • Actions
        • Set uHero[tmpInt] = (Entering unit)
        • Unit Group - Add uHero[tmpInt] to unitsGroup
        • Set tmpInt = ((Number of units in unitsGroup) + 1)



Whipped up in a moment of "Why didnt I think of that before posting this!?", but I still think there is a better way to go about this.
I'm confusing myself a little I guess.

When testing my original method which was more or less the same as the first trigger in the post except it was "avg = avg + 1", I would always get '0' when testing it with
Trigger:
  • TallyAverage Level
    • Events
      • Player - Player 1 (Red) types a chat message containing -avg as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String(avg))


The hero arena map Terminus Arena had a similar function which is what I am trying to recreate, but the map is protected (Thankfully. It is a great map.) and the author is no longer active and hasn't updated it in over a year it seems.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
There might be a better solution to this, as I just mixed something up quite fast here, but here's a version bound to work (Hopefully flawlessly, though not tested :D)

Trigger:
  • Average Level Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • Unit Group - Pick every unit in Heroes and do (Actions)
        • Loop - Actions
          • Set Levels = (Levels + (Hero level of (Picked unit)))


Trigger:
  • Average Level Update 1
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is alive) Equal to True
    • Actions
      • Unit Group - Add (Triggering unit) to Heroes
      • Set Levels = (Levels + (Hero level of (Triggering unit)))


Trigger:
  • Average Level Update 2
    • Events
      • Unit - A unit leaves (Playable map area)
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is alive) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from Heroes
      • Set Levels = (Levels - (Hero level of (Triggering unit)))


Trigger:
  • Average Level Update 3
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Triggering unit) is alive) Equal to True
    • Actions
      • Set Levels = (Levels + 1)


Trigger:
  • Average Level Print
    • Events
      • Player - Player 1 (Red) types a chat message containing -avg as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Average level of heroes in-game: + (String((Levels / (Number of units in Heroes)))))
 

mylemonblue

You can change this now in User CP.
Reaction score
7
Drat it still returns 0 every time I type in the chat string...

This is what I have as my initialization.
There are three heroes on the map owned by a player/computer.
Two belonging to Player 6 who is in a force with Player 1 (User) but is controlled by a computer slot. Player 2 is allied with Neutral Hostile, and Neutral Hostile has 1 Hero. I have not yet gotten around to making every creep a "Hero" yet though.

Trigger:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes = (Units in (Playable map area) matching ((((Picked unit) is A Hero) Equal to (==) True) and (((Picked unit) is alive) Equal to (==) True)))
      • Unit Group - Pick every unit in Heroes and do (Actions)
        • Loop - Actions
          • Set Levels = (Levels + (Hero level of (Picked unit)))
      • Set tmpInteger = 0
      • Set DevourCount = 0
      • Set SpellsCast = 0
      • Set SpellsCast = 0
        • Do Multiple ActionsFor each (Integer A) from 0 to 11, do (Actions)
          • Loop - Actions
            • Set Kill_Count[(Integer A)] = 0
            • Set losses[(Integer A)] = 0
      • Unit Group - Pick every unit in (Units in (Playable map area) owned by Neutral Hostile) and do (Actions)
        • Loop - Actions
          • Set GraveyardPoints[tmpInteger] = (Position of (Picked unit))
          • Set GraveyardUnits[tmpInteger] = (Unit-type of (Picked unit))
          • Unit - Set the custom value of (Picked unit) to tmpInteger
          • Set tmpInteger = (tmpInteger + 1)
      • -------- Define pre-placed heroes --------
      • Set cpuHero[0] = Kodo Rider 0066 <gen>
      • Set cpuHero[1] = Troll Shadow Priest 0149 <gen>
      • Set cpuHero[2] = Paladin 0006 <gen>
      • -------- Setup colors for multiboard --------
      • Set Player_Colors[1] = |c00ff0000
      • Set Player_Colors[2] = |c000000ff
      • Set Player_Colors[3] = |c0000ffff
      • Set Player_Colors[4] = |c00800080
      • Set Player_Colors[5] = |c00ffff00
      • Set Player_Colors[6] = |c00ff8000
      • Set Player_Colors[7] = |c0000ff00
      • Set Player_Colors[8] = |c00ff00ff
      • AI - Start melee AI script for Player 6 (Orange): war3mapImported\cityscapeKotoTest.wai
      • Melee Game - Use melee time of day (for all players)
      • Player - Make Player 2 (Blue) treat Neutral Hostile as an Ally with shared vision
      • Player - Make Neutral Hostile treat Player 2 (Blue) as an Ally with shared vision
      • Player - Make Player 8 (Pink) treat Neutral Hostile as an Ally with shared vision
      • Player - Make Player 8 (Pink) treat Player 1 (Red) as an Enemy with shared vision
      • Player - Make Player 8 (Pink) treat Player 2 (Blue) as an Enemy with shared vision
      • Player - Set Player 1 (Red) Current gold to 75
      • Player - Set the current research level of Fragmentation Shards to 1 for Player 2 (Blue)
      • Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across (Playable map area)
      • Visibility - Create an initially Enabled visibility modifier for Player 6 (Orange) emitting Visibility across (Playable map area)
      • Visibility - Create an initially Enabled visibility modifier for Player 8 (Pink) emitting Visibility across (Playable map area)
      • Wait 2.00 seconds
      • Trigger - Run guardtower train <gen> (ignoring conditions)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Code:
Set Heroes = (Units in (Playable map area) matching ((([COLOR="Red"](Picked unit)[/COLOR] is A Hero) Equal to (==) True) and (([COLOR="Red"](Picked unit)[/COLOR] is alive) Equal to (==) True)))

I think you need to take a look at my trigger again ;)
 

mylemonblue

You can change this now in User CP.
Reaction score
7
Durrr! I feel a little awkward now :p

I forgot I wasn't working with adding units to a Unit Group xD

Thanks, it works now. It's still taking into consideration the level 60 hero belonging to Neutral Hostile, but a quick boolean check should fix that.

+rep
\
Minor note, when I first type -avg it shows 0 and then on a new line the actual average. Dunno why, though.

Hmm... On the subject of hero levels... Recreating Zodiark's Level 3 Break, Level 4 Immobilize and Zelera's Prime Level Death? :p

(Break turns a unit to stone. Immobilize makes it so they can act but not move. Death does just that.)

Level 3 Break takes every unit in range of the target location and calculates if that unit's level is a multiple of 3. If it is, it's a 100% Stone effect. If not, theyre immune.

Level 4 Disable is the same, but for the disable effect.

Prime Level Death is tricky. Might not be possible in WC3 short of adding each number in by hand. It calculates whether or not if the unit's level is a prime number. If so, the unit dies. No questions asked. Immunities ignored. Undead or otherwise. If not, then they are immune.

Zodiark and Zelera are from FF XII and was the first game I have played that had level based spells (AND WHERE BEING AT 99 IS A BAD THING WHEN FIGHTING A BOSS)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top