Problem with using global locals?

B

Banli

Guest
I have the following trigger which is basically mass ensare based off a dummy spell: The trigger works fine when I disable the custom script making PointTemp a local variable, but I understand that locals are better for making things mui and what not. Am I doing something wrong with the local... or what do I need to do to make this a completely mui skill?

Code:
Take Captive
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Take Captive (Vagabond)
    Actions
        ****Custom script:   local location udg_PointTemp
        Set PointTemp = (Position of (Casting unit))
        Set UnitGroupTemp = (Units within (500.00 + (100.00 x (Real((Level of (Ability being cast) for (Casting unit)))))) of PointTemp matching (((Owner of (Casting unit)) is an ally of (Owner of (Matching unit))) Equal to False))
        Unit Group - Pick every unit in UnitGroupTemp and do (Actions)
            Loop - Actions
                Unit - Create 1 Dummy Caster for (Owner of (Casting unit)) at PointTemp facing Default building facing degrees
                Unit - Add Ensnare (Vagabond) to (Last created unit)
                Unit - Set level of Ensnare (Vagabond) for (Last created unit) to (Level of Take Captive (Vagabond) for (Casting unit))
                Unit - Order (Last created unit) to Orc Raider - Ensnare (Picked unit)
                Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
        Custom script:   call RemoveLocation(udg_PointTemp)
        Custom script:   call DestroyGroup(udg_UnitGroupTemp)
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> The trigger works fine

Don't think so...
"Casting unit" is extremely unstable in triggers that do their own casting.
Store it in a variable, or try with "triggering unit".


As for your "local", well,
1. it's not needed for this trigger.
2. the actions inside the "pick every" run in a different function, where your local does not exist...
 
B

Banli

Guest
Is this trigger totally mui without the local? Would it be better to declare it within the pick loop?

Also, can unit variables leak at all? Do I need to destroy it with a custom script at the end of the trigger?

Let's say I set UnitTemp = CastingUnit, do I need to make UnitTemp local at all?
 

0zaru

Learning vJASS ;)
Reaction score
60
It's fully mui without the local. You aren't using wait between sets and actions so It must be mui. You don't need to null global variables, because they are re-used. Don't use pseudo-locals(global locals..) without thinking, remember that UnitGroup picks(Pick every unit ...) are made in other functions, same with the conditions inside if/then/else.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Is this trigger totally mui without the local?

Let's ask this the other way around:
What makes you think that it isn't?


> Do I need to destroy it with a custom script at the end of the trigger?

Who? The unit? You probably do not want to kill the caster.
Unit variables need "set <variable> = null", if that variable is "local". Otherwise not.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top