• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Applying An Action To A Null Object

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
TRIGGER 1
  • Remove Unit From Group
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Unit Group - Remove (Triggering unit) from KnockBackGroup
Trigger above will work for EVERY unit in a map, that if it dies, it will instantly be removed from the group
But what about a unit that is NOT in that KnockBackGroup ?
Of course, this is what I'm talking about doing a null thing or just simply does nothing action
Example: You're washing a clean plate. (doing something that should not been done will return it as null). You wash a clean plate = ? Yes, a clean plate.

TRIGGER 2
  • Remove Unit From Group
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in KnockBackGroup) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from KnockBackGroup
Now this trigger is similar to the trigger above only a little bit addition, which is the Condition
Yes, by this way, this action will return a non-null result

True Question: Which is more efficient ?

Frequently Faced Situation:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (WS KnockBack <gen> is on) Equal to False
    • Then - Actions
      • Trigger - Turn on WS KnockBack <gen>
    • Else - Actions
This is for looping trigger which performs like 0.03 action per second
Now, this IF/THEN/ELSE function is to determine whether to turn the trigger ON or OFF (for less-lag game, you can prevent a lag game by turning off a looping trigger which is not needed (like Unit Group is empty, turn off trigger)
My question is, should we perform a check before turning on the trigger or just turn it on without performing a check, just:
  • Trigger - Turn on WS KnockBack <gen>
Which is more efficient ?
 
Level 16
Joined
May 1, 2008
Messages
1,605
But what about a unit that is NOT in that KnockBackGroup ?

Well , as you said nothing will happen, except "RemoveUnit" is a leak and will leak all the time, because even remove null is a remove.


You wash a clean plate = ?

Yes I do.

Which is more efficient?

From pure efficient I think the first one, because it simply get removed. The second trigger have to check a condition first. Well but efficient doesn't mean always the best way ...

My question is, should we perform a check before turning on the trigger or just turn it on without performing a check

Well a turned on trigger can't be turned on again, so you don't need a check... we never needed one
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You wash a clean plate = ?
Yes I do.
That is a statement, not a question LOL
You wash a clean plate Equal to What ?
Yes, You wash a Clean Plate Equal to Clean Plate (this is a methaphore)

Well a turned on trigger can't be turned on again, so you don't need a check... we never needed one
That trigger is turned on and off for some reason (to prevent lag, well because that trigger runs once per 0.03 second and if that trigger has nothing to do left (unit group is empty) I turn off that trigger to prevent the running 0.03 second doing nothing)
So, basically, that trigger is a variable which will turn on at a suitable time and turn off at a suitable time (to save performance)

But that's not the question, my true question was should I perform a check of the trigger or should I just Turn On that trigger everytime I cast a spell ?
Well, if you're turning on a Turned ON trigger, that will surely returns a null result, right ?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Dr. Boom said:
Well , as you said nothing will happen, except "RemoveUnit" is a leak and will leak all the time, because even remove null is a remove.

Wth are you saying ?!

For the unit just remove it should be faster, as the jass virtual machine check internally if the unit was in the group or not before removing it.

About the trigger, i recommend the check, turn on an already enabled trigger could make it run (need to test it yourself, just a thought)

Anyway if you care that much about efficiency you should use jass instead, i mean the difference would be (much) more noticeable than these little optimisations.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
For the unit just remove it should be faster, as the jass virtual machine check internally if the unit was in the group or not before removing it.
I believe using the Unit - Remove Unit action can make that unit to be leaked (has been debated for so much time)

Anyway if you care that much about efficiency you should use jass instead, i mean the difference would be (much) more noticeable than these little optimisations.

Also too many times =,=''
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I believe using the Unit - Remove Unit action can make that unit to be leaked (has been debated for so much time)

I heard so, but there is no way that removing a null unit make a leak, like Dr Boom said.
Anyway sometimes you don't really have the choice, the chaos abilities are not enough (i mean unit recycling is mostly lame, except for very special and controled cases).

Also too many times =,=''

That doesn't mean it's not true, for example coding directly inside the trigger condition is much more efficient than using a trigger action, and against these little optimisations it's far much revelant.
Thats doesn't matter here though, but that is.
GUI is for all but not script optimisation, it's not a troll, it's a fact.
 
Last edited:
Status
Not open for further replies.
Top