• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Which Lags More?

Status
Not open for further replies.
Level 16
Joined
Aug 20, 2009
Messages
1,552
  • WhichisFaster
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each integer X from 1 to MaxBullet, do (Actions)
        • Loop - Actions
          • -------- Move Whatever Bullet XYZ to XYZ2 --------
          • Set TempPoint = (Position of BulletUnit[X])
          • For each (Integer A) from 1 to MaxUnit, do (Actions)
            • Loop - Actions
              • -------- I did not check unit alive or not, because i would have removed it from the index if i did. --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Unit[Integer A] Not equal to No unit
                • Then - Actions
                  • Set TempPoint2 = (Position of Unit[Integer A])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between TempPoint and TempPoint2) Less than or equal to 500.00
                    • Then - Actions
                      • -------- Actions Here --------
                    • Else - Actions
                • Else - Actions
OR

  • WhichIsFaster 2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each Integer X from 1 to MaxBullet, do (Actions)
        • Loop - Actions
          • -------- Move Whatever Bullet XYZ to XYZ2 --------
          • Set TempPoint = (Position of BulletUnit[X])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in (Units within 500.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of BulletUnit[X])) Equal to True)))) Greater than 0
            • Then - Actions
              • Unit Group - Pick every unit in (Units within 500.00 of TempPoint) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is alive) Equal to True
                      • ((Triggering unit) belongs to an enemy of (Owner of BulletUnit[X])) Equal to True
                    • Then - Actions
                      • -------- Actions Here --------
                    • Else - Actions
            • Else - Actions
Its just an example, assuming all leaks are killed, and all bullets are recycled.
 
Last edited:
Level 26
Joined
Mar 19, 2008
Messages
3,140
Whats the point of this comparison?
One function checks distance, while second picks units around?

  • Set TempPoint = (Position of BulletUnit[MaxBullet])
I guess it should be >>
  • Set TempPoint = (Position of BulletUnit[(Integer A)])
Why you check if number of enemy units around is equal to 0; then you start 'if' which.. again checks if units are around and are enemies. Aren't that silly? (Triggering unit) -> (Picked unit)

Yeah ton of leaks :p
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
Its just an example, all leaks are banished allrite? xD

i made a mistake on that, made it greater than 0
and yea, change all into int A, i made a mistake again since i am in a hurry.

i am asking if picking units in unit groups is faster than picking group of units within an arrayed variable, or not. (i mean, loading unit variable also loads unit on a whole group, while picking unit group also picks unit on some group.)
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
i am asking if picking units in unit groups is faster than picking group of units within an arrayed variable, or not. (i mean, loading unit variable also loads unit on a whole group, while picking unit group also picks unit on some group.)
What I understood is that you are asking if:

- temporary Group with auto destroy is faster than group saved into variable and used later in trigger

Answer is: It depends on situation. If you gonna need that group later, or you'd like to refer to it few times than stored group would be a better option.
Temporary groups are a more efficient way for performing instant stuff without caring about the future. It's more about circumstances than speed actually.
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
well, its not groups saved into variable,
i used loop to pick all units that i registered in a "Unit" arrayed variable.
which is faster compared to
This :
Unit Group - Pick every unit in (Units within 500.00 of TempPoint) and do (Actions)

i mean, nothing is defined in Unit Group - Pick every unit in xyz and do (actions) yet,

but looping pick units in a variable (which are pre-defined on other triggers), seems to be faster don't it?

but i don't know which exactly works better, so..?
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
Enumerating through arrayed units will be faster, but again, only if you need given 'group' (bunch of arrayed units) to be to be used few times;

GroupEnum picks EVERY unit in area, and adds to group only those who match filter passed; it means that units that could be ignored and enumerated anyways, even that filter returns false.

So if you stored units in arrays; looping through indexes will be smoother.
I'd like to know how your whole script looks like though.
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
That answers my question, thx,

why ? is it bad? xD
don't worry, its just an example, the whole trig doesn't even look like this.

i will be using the group more than ever,
since it involves a lot of things that i will recycle again and again.
so i will be using the looped array units.
 
Status
Not open for further replies.
Top