Select unit in range of 500 of hero with lowest health

Icyculyr

I'm a Mac
Reaction score
68
Hey, how can I select all units in range of 500 of my hero with the lowest health?

I'd like to have stored in an array the 3 units with the lowest health.

I know how to select the units, but what's the most efficient way to sort these three units into an array?

Kind Regards
 

JuiceBox

New Member
Reaction score
13
Event:
Unit comes within 500 range of [your hero]

Condition:
Triggering unit belongs to an enemy/ally of owner of [your hero]
(you can remove this if you want the picked units to be any unit.)

Event:
Pick every unit within 500 range of [your hero] and
If - Picked unit's health is less than or equal to 40%
Then - Add picked unit to [your variable/s here]
Else - Do nothing

Can we have more information please? :)
What is it exactly that you want? :p
 

Icyculyr

I'm a Mac
Reaction score
68
Sorry, more info + example ->

It's supposed to sort the units in range so that the lowest life is in the lowest index (0).
PN is set to the player number of the picked player, and refers to the hero for each player when used as uHero[PN].
Trigger:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
    • Then - Actions
      • Set pPoints[0] = (Position of uHero[PN])
      • Set ugGroups[0] = (Units within 1000.00 of pPoints[0] matching ((((Matching unit) belongs to an enemy of (Owner of uHero[PN])) Equal to True) and (((Matching unit) is alive) Equal to True)))
      • For each (Integer A) from 0 to 11, do (Actions)
        • Loop - Actions
          • Set iLowestLife[(Integer A)] = -1
      • Unit Group - Pick every unit in ugGroups[0] and do (Actions)
        • Loop - Actions
          • Set PN2 = ((Player number of (Owner of (Picked unit))) - 1)
          • Set iLowestLife[iTempCount] = (Integer((Life of (Picked unit))))
          • Set iPointToIndex[iTempCount] = PN2
          • Set iTempCount = (iTempCount + 1)
      • Set iTempCount = (iTempCount - 1)
      • For each (Integer A) from 0 to iTempCount, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 0 to iTempCount, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Integer A) Not equal to (Integer B)
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • iLowestLife[(Integer A)] Less than iLowestLife[(Integer B)]
                    • Then - Actions
                      • Set iTempIntegerA = iLowestLife[(Integer A)]
                      • Set iLowestLife[(Integer A)] = iLowestLife[(Integer B)]
                      • Set iLowestLife[(Integer B)] = iTempIntegerA
                      • Set iTempIntegerA = iPointToIndex[(Integer A)]
                      • Set iPointToIndex[(Integer A)] = iPointToIndex[(Integer B)]
                      • Set iPointToIndex[(Integer B)] = iTempIntegerA
                    • Else - Actions
                • Else - Actions
      • Custom script: call GroupClear(udg_ugGroups[0])
      • Custom script: call RemoveLocation(udg_pPoints[0])
    • Else - Actions


Will that work in sorting iLowestLife so the life is lowest at index [0], second at index [1] etc..

Kind Regards
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Will that work in sorting iLowestLife so the life is lowest at index [0], second at index [1] etc..

try and see? ^^
 

Icyculyr

I'm a Mac
Reaction score
68
Lol it's kind of hard to tell what's running, my AI code covers two or three triggers, and is like 8x that amount of code.

I'll give it a shot :O

Kind Regards
 

Joccaren

You can change this now in User CP.
Reaction score
54
I've been looking for a way to do this. Your AI only covers 3 triggers? wow, thats not many.
 

Joccaren

You can change this now in User CP.
Reaction score
54
My Paladin AI covers 7 Triggers. These include:
Item pick up
Move/Attack/Heal all in one trigger
Back-up Heal (Other ways of detecting when to heal as my normal way sometimes doesn't work)
Set Items/Enemies nearby variables
Cast Spells
Learn Spells
Set Battle Ready Variable (The boolean my move/Attack ect. Trigger checks before doing anything except healing)

and possibly more...
 

Icyculyr

I'm a Mac
Reaction score
68
Oh, I've got a very small map, and those three triggers were practically dedicated to movement, and fleeing and attacking units, picking up items (Oops triggers for picking items not added yet, so not included in the 3 triggers), buying items from shops and casting abilities.

They were quite long :O

Although I've greatly minimized them now, realizing I didn't have to do a lot of them lol

Kind Regards
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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