HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Simple optimize question

05-12-2009, 07:34 PM#1
Cheezeman
If I would like to have several "A Unit is attacked" events,
would it be better to have just 1 trigger ('object') to check all functions I wanna add,
or a new event for every function?

Simpler:
Is this
Trigger:
Collapse Function1
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Triggering unit) has buff Banish) Equal to True
Collapse Then - Actions
Unit - Kill (Triggering unit)
Else - Actions
Collapse Function2
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Triggering unit) is A Hero) Equal to True
Collapse Then - Actions
Unit - Kill (Attacking unit)
Else - Actions
Collapse Function3
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Triggering unit)) Equal to Rifleman
Collapse Then - Actions
Unit - Explode (Triggering unit)
Else - Actions
better than this
Trigger:
Combined function
Collapse Events
Unit - A unit Is attacked
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Triggering unit) has buff Banish) Equal to True
Collapse Then - Actions
Unit - Kill (Triggering unit)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Triggering unit) is A Hero) Equal to True
Collapse Then - Actions
Unit - Kill (Attacking unit)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Triggering unit)) Equal to Rifleman
Collapse Then - Actions
Unit - Explode (Triggering unit)
Else - Actions
05-12-2009, 07:53 PM#2
cosmicat
To my knowledge, they're the same, since a GUI if/else chain is a function. I may be wrong, but I think the first one is "faster" only during map initialization.
05-12-2009, 08:05 PM#3
Michael Peppers
Quote:
Originally Posted by cosmicat
To my knowledge, they're the same, since a GUI if/else chain is a function. I may be wrong, but I think the first one is "faster" only during map initialization.
Agreed.

Though if you code the 3 functions separately and put the conditions as main conditions of the trigger (and so the Actions too) (not in the If/Then/Else thing), it should be faster.

Well, if that's possible in your case, of course.
05-13-2009, 06:18 AM#4
0zyx0
This is kind of what he meant:

Trigger:
Collapse Function1
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
((Triggering unit) has buff Banish) Equal to True
Collapse Actions
Unit - Kill (Triggering unit)
Collapse Function2
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
((Triggering unit) is A Hero) Equal to True
Collapse Actions
Unit - Kill (Attacking unit)
Collapse Function3
Collapse Events
Unit - A unit Is attacked
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Rifleman
Collapse Actions
Unit - Explode (Triggering unit)
05-13-2009, 10:41 AM#5
Cheezeman
So correct me if I'm wrong.
It is faster to have them seperated, as long as the event isn't Map Initialization?
05-13-2009, 11:19 AM#6
Michael Peppers
Yes, it should be faster if you use 3 separated functions without If/Then/Else statements, as I said and 0zxy0 showed. (erm... maybe my post wasn't that clear...)
05-13-2009, 12:48 PM#7
Bobo_The_Kodo
Its faster to have them together, but its really kinda insignificant

Edit: Actually not in GUI, because If/Then/Else in gui is really badly done
05-13-2009, 03:33 PM#8
cosmicat
Quote:
Originally Posted by me
since a GUI if/else chain is a function.
05-13-2009, 06:57 PM#9
Cheezeman
I see, thanks a lot guys...

lol who should I +rep? I'll go with cosmicat cause he was fastest...
05-13-2009, 06:59 PM#10
cosmicat
Awful nice of you, but the others deserve some too so I'll pass it along to them.
05-13-2009, 07:01 PM#11
Michael Peppers
Quote:
Originally Posted by cosmicat
Awful nice of you, but the others deserve some too so I'll pass it along to them.
How does it feel to beat my quickness in posting? :P

However I admit that before your answer I didn't know what to say about it...
In other words, it's all your fault if I answered. :P
05-13-2009, 07:03 PM#12
cosmicat
Too late, sucka. I already repped you. No use arguing now.
05-14-2009, 04:28 PM#13
Cheezeman
Quote:
Originally Posted by cosmicat
Too late, sucka. I already repped you. No use arguing now.
Lol @ arguing over righteous reputation
Thanks anyway for reping the other dudes