• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Sense Ability Lag Issue (One last time with this spell)

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
So, there appears to be more lag issues with this spell. This is the last time I'm going to deal with it and if I can't fix it now then it won't be worth using. It lags still even if it's just 1-2 units being "Detected" although it's such a small amount that it's almost unnoticeable. But when it starts to get to 6, 10, 15 units being detected, there is an EXTREMELY noticeable slow down.

Here are the triggers:


  • Sensing Unit Enters
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Archer
        • Then - Actions
          • Set SenseUnitMaxIndex = (SenseUnitMaxIndex + 1)
          • Set SenseUnit[SenseUnitMaxIndex] = (Entering unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Sense Calc <gen> is on) Equal to False
            • Then - Actions
              • Trigger - Turn on Sense Calc <gen>
            • Else - Actions
        • Else - Actions
  • Sensing Unit Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Archer
    • Actions
      • For each (Integer SenseUnitDiesInit) from 1 to SenseUnitMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to SenseUnit[SenseUnitDiesInit]
            • Then - Actions
              • Set SenseUnit[SenseUnitDiesInit] = SenseUnit[SenseUnitMaxIndex]
              • Set SenseUnit[SenseUnitMaxIndex] = No unit
              • Set SenseUnitPoint[SenseUnitDiesInit] = SenseUnitPoint[SenseUnitMaxIndex]
              • Set SenseRange[SenseUnitDiesInit] = SenseRange[SenseUnitMaxIndex]
              • Set SenseRange[SenseUnitMaxIndex] = 0.00
              • Custom script: set udg_SenseUnitPoint[udg_SenseUnitMaxIndex] = null
              • Set SenseUnitMaxIndex = (SenseUnitMaxIndex - 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Sense Calc <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Sense Calc <gen>
        • Else - Actions

  • Sense Calc
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SenseInit) from 1 to SenseUnitMaxIndex, do (Actions)
        • Loop - Actions
          • Set SenseUnitPoint[SenseInit] = (Position of SenseUnit[SenseInit])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sense for SenseUnit[SenseInit]) Equal to 1
            • Then - Actions
              • Set SenseRange[SenseInit] = 1200.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Sense for SenseUnit[SenseInit]) Equal to 2
                • Then - Actions
                  • Set SenseRange[SenseInit] = 1700.00
                • Else - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SenseRange[SenseInit] of SenseUnitPoint[SenseInit]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) has buff Sense ) Equal to True
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) belongs to an ally of (Owner of SenseUnit[SenseInit])) Equal to False
                  • ((Picked unit) is A structure) Equal to False
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) belongs to an enemy of (Owner of SenseUnit[SenseInit])) Equal to True
                      • (Owner of (Picked unit)) Equal to Neutral Hostile
                      • (Owner of (Picked unit)) Equal to Neutral Victim
                      • (Owner of (Picked unit)) Equal to Neutral Extra
                      • (Owner of (Picked unit)) Equal to Neutral Passive
                • Then - Actions
                  • Set SensedPointMaxIndex = (SensedPointMaxIndex + 1)
                  • Set SensedUnit[SensedPointMaxIndex] = (Picked unit)
                  • Set SensedUnitPoint[SensedPointMaxIndex] = (Position of SensedUnit[SenseInit])
                  • Unit - Create 1 Dummy Sense Unit for (Owner of SenseUnit[SenseInit]) at SensedUnitPoint[SenseInit] facing SensedUnitPoint[SenseInit]
                  • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
                  • Custom script: call RemoveLocation(udg_SensedUnitPoint[udg_SenseInit])
                  • Set SensedUnitPoint[SenseInit] = SensedUnitPoint[SensedPointMaxIndex]
                  • Custom script: set udg_SensedUnitPoint[udg_SensedPointMaxIndex] = null
                  • Set SensedUnit[SenseInit] = SensedUnit[SensedPointMaxIndex]
                  • Set SensedUnit[SensedPointMaxIndex] = No unit
                  • Set SensedPointMaxIndex = (SensedPointMaxIndex - 1)
                • Else - Actions
EDIT: A small amount of the lag was coming from the unit being indexed twice at Map Initialization. That was fixed, but there is still some very visible lag.
 
Range of 1700 or even 1200 is quite large. I can't tell how many units are placed on your map, especially nearby (for obvious reasons), however, enumerating every 0.5 sec multiple amount of units per each index is pretty much guarantee lag in some circumstances.

Try lowering the range value and/or convert this into jass script for extra speed.

Btw: try debugging the code with some messages. E.g check if udg_SenseUnitMaxIndex value is correct with every new instance added.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I would say the reason is unlikely the bad coding, but unit creation.Is there any chance you can use special effect instead of dummy unit(or the job of dummy is giving sight, try using a visibility area thing)?Will look again later.
 
Level 12
Joined
May 20, 2009
Messages
822
They are meant to provide the vision, yes.

So how should I do a visibility modifier? Never messed with that before.

EDIT: So, this is what I got so far -

  • Sense Calc
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SenseInit) from 1 to SenseUnitMaxIndex, do (Actions)
        • Loop - Actions
          • Set SenseUnitPoint[SenseInit] = (Position of SenseUnit[SenseInit])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sense for SenseUnit[SenseInit]) Equal to 1
            • Then - Actions
              • Set SenseRange[SenseInit] = 1200.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Sense for SenseUnit[SenseInit]) Equal to 2
                • Then - Actions
                  • Set SenseRange[SenseInit] = 1700.00
                • Else - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SenseRange[SenseInit] of SenseUnitPoint[SenseInit]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) has buff Sense ) Equal to True
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) belongs to an ally of (Owner of SenseUnit[SenseInit])) Equal to False
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) belongs to an enemy of (Owner of SenseUnit[SenseInit])) Equal to True
                      • (Owner of (Picked unit)) Equal to Neutral Hostile
                      • (Owner of (Picked unit)) Equal to Neutral Victim
                      • (Owner of (Picked unit)) Equal to Neutral Extra
                      • (Owner of (Picked unit)) Equal to Neutral Passive
                • Then - Actions
                  • Set SensedPointMaxIndex = (SensedPointMaxIndex + 1)
                  • Set SensedUnit[SensedPointMaxIndex] = (Picked unit)
                  • Set SensedUnitPoint[SensedPointMaxIndex] = (Position of SensedUnit[SenseInit])
                  • Visibility - Create an initially Enabled visibility modifier for (Owner of SenseUnit[SenseInit]) emitting Visibility from (Position of SensedUnit[SenseInit]) to a radius of 250.00
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SenseVisModTimer[SenseInit] Not equal to 2
                    • Then - Actions
                      • Set SenseVisModTimer[SenseInit] = (SenseVisModTimer[SenseInit] + 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SenseVisModTimer[SenseInit] Equal to 2
                        • Then - Actions
                          • Visibility - Destroy (Last created visibility modifier)
                          • Set SenseVisModTimer[SenseInit] = 0
                        • Else - Actions
                  • Custom script: call RemoveLocation(udg_SensedUnitPoint[udg_SenseInit])
                  • Set SensedUnitPoint[SenseInit] = SensedUnitPoint[SensedPointMaxIndex]
                  • Custom script: set udg_SensedUnitPoint[udg_SensedPointMaxIndex] = null
                  • Set SensedUnit[SenseInit] = SensedUnit[SensedPointMaxIndex]
                  • Set SensedUnit[SensedPointMaxIndex] = No unit
                  • Set SenseInit = (SenseInit - 1)
                  • Set SensedPointMaxIndex = (SensedPointMaxIndex - 1)
                • Else - Actions
But this seems to create MORE lag then creating units...

The Visibility Modifier needs to not be removed until the next one has spawned. Because if that doesn't happen then the vision will flash.
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
Yes, using fearie fire and only 1 dummy unit to cast all fires should be way to go.
 
Level 12
Joined
May 20, 2009
Messages
822
Alright, I'll try this out and get back to it when I make all the changes.

EDIT: Faerie Fire does not do exactly what I want it to. The sight range given needs to be controllable so it can be a fairly small amount. As well, it leaves behind a buff on a unit so now units that are being "Sensed" have the buff from the Aura and the buff from the Faerie Fire.

I also think that spells cannot be cast on units if they're not already visible, so the unit with the "Sense" ability has to move close enough to where the targets will be in sight range then the dummy unit will be able to cast the Faerie Fire.

So I think Visibility Modifiers are my best bet. I don't really care that occlusion height doesn't block them, it's fine with me. I'm not using a huge sight radius so you won't see much other then the unit and a few cells off the unit anyway.

(This is the only spell stopping me from being able to finish my mod up for it's first release, so if this one things holds it up too long I'll be glad to just get rid of it. But I'd still like this to be functional mainly as a proof-of-concept that Sensor Towers from SC2 can kinda work in WC3 which was mainly the point of this spell in the first place. =p)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
But you are already checking for "Picked unit has buff Sense", what is the difference between aura buff and fearie fire buff on picked unit?
 
Last edited:
Level 12
Joined
May 20, 2009
Messages
822
Anyways, to solve Faerie Fire casting, use UnitShareVision(target, casterowner, boolean share). It is instant and will allow the dummy to cast.

Though faerie fire's range is uncontrollable, it is easier.

What are you talking about? o_O

(The reason Faerie Fire doesn't work is BECAUSE the range of sight is uncontrollable. It NEEDS to be a short range. That's kind of the whole point of the ability.)

But you are already checking for "Picked unit has buff Sense", what is the difference between aura buff and faerie fire buff on picked unit?

Well, the Aura buff cannot be removed because it's an Aura...The only way you could make that work is check if the unit has Faerie Fire buff and then remove the Aura buff over and over and over again until the Faerie Fire is gone. That's highly unnecessary. The reason the Faerie Fire buff cannot be removed is because it's what was giving the sight range...(But I'm not going to use that anymore.)

So, since Faerie Fire doesn't work I just need the other trigger fixed -

  • Sense Calc
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SenseInit) from 1 to SenseUnitMaxIndex, do (Actions)
        • Loop - Actions
          • Set SenseUnitPoint[SenseInit] = (Position of SenseUnit[SenseInit])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sense for SenseUnit[SenseInit]) Equal to 1
            • Then - Actions
              • Set SenseRange[SenseInit] = 1200.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Sense for SenseUnit[SenseInit]) Equal to 2
                • Then - Actions
                  • Set SenseRange[SenseInit] = 1700.00
                • Else - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SenseRange[SenseInit] of SenseUnitPoint[SenseInit]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) has buff Sense ) Equal to True
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) belongs to an ally of (Owner of SenseUnit[SenseInit])) Equal to False
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) belongs to an enemy of (Owner of SenseUnit[SenseInit])) Equal to True
                      • (Owner of (Picked unit)) Equal to Neutral Hostile
                      • (Owner of (Picked unit)) Equal to Neutral Victim
                      • (Owner of (Picked unit)) Equal to Neutral Extra
                      • (Owner of (Picked unit)) Equal to Neutral Passive
                • Then - Actions
                  • Set SensedPointMaxIndex = (SensedPointMaxIndex + 1)
                  • Set SensedUnit[SensedPointMaxIndex] = (Picked unit)
                  • Set SensedUnitPoint[SensedPointMaxIndex] = (Position of SensedUnit[SenseInit])
                  • Visibility - Create an initially Enabled visibility modifier for (Owner of SenseUnit[SenseInit]) emitting Visibility from (Position of SensedUnit[SenseInit]) to a radius of 250.00
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SenseVisModTimer[SenseInit] Not equal to 2
                    • Then - Actions
                      • Set SenseVisModTimer[SenseInit] = (SenseVisModTimer[SenseInit] + 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SenseVisModTimer[SenseInit] Equal to 2
                        • Then - Actions
                          • Visibility - Destroy (Last created visibility modifier)
                          • Set SenseVisModTimer[SenseInit] = 0
                        • Else - Actions
                  • Custom script: call RemoveLocation(udg_SensedUnitPoint[udg_SenseInit])
                  • Set SensedUnitPoint[SenseInit] = SensedUnitPoint[SensedPointMaxIndex]
                  • Custom script: set udg_SensedUnitPoint[udg_SensedPointMaxIndex] = null
                  • Set SensedUnit[SenseInit] = SensedUnit[SensedPointMaxIndex]
                  • Set SensedUnit[SensedPointMaxIndex] = No unit
                  • Set SenseInit = (SenseInit - 1)
                  • Set SensedPointMaxIndex = (SensedPointMaxIndex - 1)
                • Else - Actions
The Visibility Modifier needs to not disappear instantly. It needs to stay until the next visibility modifier spawns and then it will be removed. But the way I have it set up causes more lag then spawning units. I'm sure that's just a problem with the way I've done it, though. So how do I fix it?
 
Level 12
Joined
May 20, 2009
Messages
822
Because you only destroy the last visibility modifier, not all of them. In the units' case, at least they get removed. Also cache picked unit into a variable.

I am doing that, I just haven't updated that trigger script.

Here's the updated one:

  • Sense Calc
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SenseInit) from 1 to SenseUnitMaxIndex, do (Actions)
        • Loop - Actions
          • Set SenseUnitPoint[SenseInit] = (Position of SenseUnit[SenseInit])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sense for SenseUnit[SenseInit]) Equal to 1
            • Then - Actions
              • Set SenseRange[SenseInit] = 1200.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Sense for SenseUnit[SenseInit]) Equal to 2
                • Then - Actions
                  • Set SenseRange[SenseInit] = 1700.00
                • Else - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SenseRange[SenseInit] of SenseUnitPoint[SenseInit]) and do (Actions)
            • Loop - Actions
              • Set SensedUnit[SenseInit] = (Picked unit)
              • Set SensedUnitPoint[SenseInit] = (Position of SensedUnit[SenseInit])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SensedUnit[SenseInit] is A structure) Equal to False
                  • (SensedUnit[SenseInit] has buff Sense ) Equal to True
                  • (SensedUnit[SenseInit] is A structure) Equal to False
                  • (SensedUnit[SenseInit] is alive) Equal to True
                  • (SensedUnit[SenseInit] belongs to an ally of (Owner of SenseUnit[SenseInit])) Equal to False
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (SensedUnit[SenseInit] belongs to an enemy of (Owner of SenseUnit[SenseInit])) Equal to True
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Hostile
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Victim
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Extra
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Passive
                • Then - Actions
                  • Visibility - Create an initially Enabled visibility modifier for (Owner of SenseUnit[SenseInit]) emitting Visibility from (Position of SensedUnit[SenseInit]) to a radius of 250.00
                  • Set SenseVisMaxIndex = (SenseVisMaxIndex + 1)
                  • Set SenseVisiblityMod[SenseVisMaxIndex] = (Last created visibility modifier)
                  • Set SenseVisTimer[SenseVisMaxIndex] = 0
                  • For each (Integer SenseVisInit) from 1 to SenseVisMaxIndex, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SenseVisTimer[SenseVisInit] Less than 4
                        • Then - Actions
                          • Set SenseVisTimer[SenseVisInit] = (SenseVisTimer[SenseVisInit] + 1)
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SenseVisTimer[SenseVisInit] Equal to 4
                        • Then - Actions
                          • Visibility - Destroy SenseVisiblityMod[SenseVisInit]
                          • Set SenseVisTimer[SenseVisInit] = SenseVisTimer[SenseVisMaxIndex]
                          • Set SenseVisTimer[SenseVisMaxIndex] = 0
                          • Set SenseVisiblityMod[SenseVisInit] = SenseVisiblityMod[SenseVisMaxIndex]
                          • Set SenseVisiblityMod[SenseVisMaxIndex] = NullVisibilityMod \\This is a null variable, because for some reason I can't do a custom script to set it to "null"...
                          • Set SenseVisMaxIndex = (SenseVisMaxIndex - 1)
                        • Else - Actions
                  • Set SensedUnit[SenseInit] = No unit
                  • Custom script: call RemoveLocation(udg_SensedUnitPoint[udg_SenseInit])
                  • Custom script: call RemoveLocation(udg_SenseUnitPoint[udg_SenseInit])
                  • Set SensedUnitPoint[SenseInit] = SensedUnitPoint[SenseUnitMaxIndex]
                  • Custom script: set udg_SensedUnitPoint[udg_SenseUnitMaxIndex] = null
                  • Set SenseUnitPoint[SenseInit] = SenseUnitPoint[SenseUnitMaxIndex]
                  • Custom script: set udg_SenseUnitPoint[udg_SenseUnitMaxIndex] = null
                • Else - Actions
This seems to be completely lagless, but it still KINDA flashes the vision instead of it being solid. But I'm considering whether or not if I'm alright with it, because it ends up making the units visible in the Fog of War even though there's no vision on them, which is what I ORIGINALLY (Like 3-4 weeks ago) wanted...In the mean time, how would I go about fixing that?

So, proof of concept achieved:

Sensor Tower-like ability from StarCraft II is kind of possible in WarCraft III. (Albeit this is not 100% accurate, but I'm sure with a few modifications it can be)
 
Level 12
Joined
May 20, 2009
Messages
822
Woops, Lol. I even index that point, I dunno why I did that. K, fix'd:


  • Sense Calc
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SenseInit) from 1 to SenseUnitMaxIndex, do (Actions)
        • Loop - Actions
          • Set SenseUnitPoint[SenseInit] = (Position of SenseUnit[SenseInit])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sense for SenseUnit[SenseInit]) Equal to 1
            • Then - Actions
              • Set SenseRange[SenseInit] = 1200.00
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Sense for SenseUnit[SenseInit]) Equal to 2
                • Then - Actions
                  • Set SenseRange[SenseInit] = 1700.00
                • Else - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SenseRange[SenseInit] of SenseUnitPoint[SenseInit]) and do (Actions)
            • Loop - Actions
              • Set SensedUnit[SenseInit] = (Picked unit)
              • Set SensedUnitPoint[SenseInit] = (Position of SensedUnit[SenseInit])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SensedUnit[SenseInit] is A structure) Equal to False
                  • (SensedUnit[SenseInit] has buff Sense ) Equal to True
                  • (SensedUnit[SenseInit] is A structure) Equal to False
                  • (SensedUnit[SenseInit] is alive) Equal to True
                  • (SensedUnit[SenseInit] belongs to an ally of (Owner of SenseUnit[SenseInit])) Equal to False
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (SensedUnit[SenseInit] belongs to an enemy of (Owner of SenseUnit[SenseInit])) Equal to True
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Hostile
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Victim
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Extra
                      • (Owner of SensedUnit[SenseInit]) Equal to Neutral Passive
                • Then - Actions
                  • Visibility - Create an initially Enabled visibility modifier for (Owner of SenseUnit[SenseInit]) emitting Visibility from SensedUnitPoint[SenseInit] to a radius of 250.00
                  • Set SenseVisMaxIndex = (SenseVisMaxIndex + 1)
                  • Set SenseVisiblityMod[SenseVisMaxIndex] = (Last created visibility modifier)
                  • Set SenseVisTimer[SenseVisMaxIndex] = 0
                  • For each (Integer SenseVisInit) from 1 to SenseVisMaxIndex, do (Actions)
                    • Loop - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SenseVisTimer[SenseVisInit] Less than 4
                        • Then - Actions
                          • Set SenseVisTimer[SenseVisInit] = (SenseVisTimer[SenseVisInit] + 1)
                        • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SenseVisTimer[SenseVisInit] Equal to 4
                        • Then - Actions
                          • Visibility - Destroy SenseVisiblityMod[SenseVisInit]
                          • Set SenseVisTimer[SenseVisInit] = SenseVisTimer[SenseVisMaxIndex]
                          • Set SenseVisTimer[SenseVisMaxIndex] = 0
                          • Set SenseVisiblityMod[SenseVisInit] = SenseVisiblityMod[SenseVisMaxIndex]
                          • Set SenseVisiblityMod[SenseVisMaxIndex] = NullVisibilityMod
                          • Set SenseVisMaxIndex = (SenseVisMaxIndex - 1)
                        • Else - Actions
                  • Set SensedUnit[SenseInit] = No unit
                  • Custom script: call RemoveLocation(udg_SensedUnitPoint[udg_SenseInit])
                  • Custom script: call RemoveLocation(udg_SenseUnitPoint[udg_SenseInit])
                  • Set SensedUnitPoint[SenseInit] = SensedUnitPoint[SenseUnitMaxIndex]
                  • Custom script: set udg_SensedUnitPoint[udg_SenseUnitMaxIndex] = null
                  • Set SenseUnitPoint[SenseInit] = SenseUnitPoint[SenseUnitMaxIndex]
                  • Custom script: set udg_SenseUnitPoint[udg_SenseUnitMaxIndex] = null
                • Else - Actions


EDIT: BTW, this is pretty much solved. Although if anyone can point out any more errors then that'd be appreciated.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You don't need alive check since dead units can't carry buffs.Also you are checking for structure twice, (can structures benefit from auras anyway?)
 
Level 12
Joined
May 20, 2009
Messages
822
You don't need alive check since dead units can't carry buffs.Also you are checking for structure twice, (can structures benefit from auras anyway?)

You really gotta wonder what my thought-process was for having it check for structures TWICE.

And yes, Auras can effect Structures if you check "Structures" in Targets Allowed.

I actually don't even know why I set that up like that, because I originally wanted it to detect Structures too.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The idea of a temporary global variable is that it has no continuous persistence but provides some immediate persistence. Often you will use them instead of locals as GUI does not give access to local variables. They are also very useful if you use triggers for dynamic function calls since you cannot directly pass arguments to the run function but you can use a temporary global variable to do so (this approach is even used by the GUI in SC2 for running actions in separate threads!).

Nesting is the only problem with temporary global variables as they have persistence across function calls. This means that either you intend the called function to use them in a certain way or the called function uses its own set of temporary global variables that are separate (parallel) to the caller function. Recursive functions that need parallel temporary storage locations cannot really use a temporary global variable and will either have to use a temporary global stack or local variables.

The best known examples of a temporary global variable are the "loop Index A/B" values. They work fine as long as you do not start nesting such loops inside each other. This is because their persistence is only used immediately and scoped to the duration of the loop.
 
Status
Not open for further replies.
Top