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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top