1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[TRIGGER] Unit Group problem

Discussion in 'World Editor Help Zone' started by Dynasti, Aug 11, 2008.

  1. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    what's your personnal experience in videogame making to affirm that?
    in most videogames, 90% of the execution time is taken by 10% of the code ;)

    Ok, let's count :
    with the "pick in range" method, you need to make 1 check per unit at least 64 times in the better case, and in the worst case... thousands of times... in c++
    with the "array sort" i've done in JASS, i make 1 check per unit on the group only once, and then n checks (n is the number of wanted closest units) per unit, no matter their distance, in JASS...
    are you sure yours is faster ?

    these variable are local,
    no need to nullifie them at the beggining cause i know i will inialize them all
    no need to nullifie them at the end, their memory place is released at the end of the function's execution
    so, setting them to null would only make the cpu made totally useless instruction.

    Maybe, that's a point of view, of course doing that, even once, is not free, but it's cheap, and i think it's cheap enough so i've made my choice.

    Maybe the author of this thread want to know what he put in is map, no?
    Maybe he will try to understand how does it work, who knows?
     
  2. graystuff111

    graystuff111

    Joined:
    Dec 11, 2007
    Messages:
    715
    Resources:
    23
    Icons:
    20
    Skins:
    1
    Maps:
    1
    Tutorials:
    1
    Resources:
    23
    Hear ye, Hear ye.
    I got bored of reading this entire post, so I skipped to the end, and couldnt tell if it had been solved yet, so I decided to answer it. Here's the trigger, and if you want to make it have a range limit, adjust the set TempGroup line.
    • Closest 5 Units
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Get Closest 5 Units
      • Actions
        • Set TempLocA = (Position of (Triggering unit))
        • Set TempGroup = (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
        • For each (Integer TempIntA) from 1 to 5, do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (Number of units in TempGroup) Greater than 0
              • Then - Actions
                • Set TempRealB = 9999999.00
                • Unit Group - Pick every unit in TempGroup and do (Actions)
                  • Loop - Actions
                    • Set TempLocB = (Position of (Picked unit))
                    • Set TempRealA = (Distance between TempLocA and TempLocB)
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • TempRealA Less than TempRealB
                      • Then - Actions
                        • Custom script: set udg_ClosestUnits[udg_TempIntA] = null
                        • Set ClosestUnits[TempIntA] = (Picked unit)
                        • Set TempRealB = TempRealA
                      • Else - Actions
                • Unit Group - Remove ClosestUnits[TempIntA] from TempGroup
              • Else - Actions
        • For each (Integer TempIntA) from 1 to 5, do (Actions)
          • Loop - Actions
            • Game - Display to (All players) the text: (Name of ClosestUnits[TempIntA])
            • Custom script: set udg_ClosestUnits[udg_TempIntA] = null
        • Custom script: call DestroyGroup(udg_TempGroup)
     
  3. Vicboy

    Vicboy

    Joined:
    Aug 20, 2007
    Messages:
    1,048
    Resources:
    2
    Maps:
    2
    Resources:
    2
    What does your exactly do?
     
  4. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    And? You're avoiding the question again. If there's one type of programs that require optimisations (and are in fact usually heavily optimised), it's videogames.


    Sigh.
    I've agreed with you that your method "logically" would be the faster. I've said that since post 1. I have however said that practically, it isn't necessary so, because jass is jass and not c. I'm not sure "mine" (whatever "mine" means here) is faster, but I don't think neither are you or should you. And I won't say yours practically is faster until I see a benchmark.

    Ofcourse. I wasn't talking about nullifying them at the start.
    In theory, yes, but the reference counter is broken (bugged) so you DO need to null them in jass. Sad, but true.

    Well, "how it works" has been explained a few times now, so I guess he just wants to use it and doesn't care about the implementation.

    graystuff basically picks every unit on the map that isn't in the temporary group and chooses the closest unit, adds it to a temporary group, and repeats this 5 times...
     
  5. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    not anywhere
    i'll explain you : you're agree that some features cost more cpu time than the others
    optimizing all features need coding time, coding time need workers, workers cost money to compagny
    so coders have to optimize the more used features until the fps is correct
    after that, anything more would be a waste of money for the compagny
    things like a square root in a distance calculation is nothing comparate to the graphical display for example

    anyway, you wan't benchmark, well do them, i'm personally sure that jass is no slow enough to take more time doing 6 instructions than c++ take to doing hundreds of... (else my maps would lag with the numbers of jass function i use in them ^^')

    I didn't know, thanks to notice me about that
    need to redesign the last loop...
    EDIT : done
     
  6. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    Removing an unneeded square root is a very basic optimization which doesn't require days of rethinking as with optimizing shaders. Especially because this is so generally known that I'd be surprised if they hadn't done that. Another thing is that shader optimizations are only good for GPU stressing, while the CPU is perhaps even more important on that area.
     
  7. YoshiRyu

    YoshiRyu

    Joined:
    Jun 26, 2007
    Messages:
    686
    Resources:
    0
    Resources:
    0
    coders aren't as concentrated as you think when they work :/
    i prefer not assuming that
     
  8. Eleandor

    Eleandor

    Joined:
    Aug 21, 2005
    Messages:
    3,681
    Resources:
    2
    Models:
    1
    Tutorials:
    1
    Resources:
    2
    It's blizzard! Let's keep our expectations from blizzard high, shall we ;)