Why I can't store my global into a local? (location)

Frozenwind

System maker
Reaction score
99
This is the trigger:
Code:
TB Cast It
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Triangle Beam 
    Actions
        Custom script:   local location array loc
        Custom script:   local unit cast = GetSpellAbilityUnit ()
        Custom script:   local real array angle
        Custom script:   local real offset = 0.00
        Custom script:   local integer array A
        Custom script:   local integer array B
        Custom script:   local lightning array light
        Custom script:   set udg_Temp_point1 = GetUnitLoc (cast)
        Set Temp_point2 = (Temp_point1 offset by 50.00 towards 0.00 degrees)
        Custom script:   set A[0] = 0
        Custom script:   set A[1] = 2
        Custom script:   loop
        Custom script:       exitwhen A[0]>A[1]
        Custom script:       set angle[A[0]] = I2R( A[0] * 120)
        Custom script:       set loc[A[0]] = GetUnitLoc (cast)
        Custom script:       set A[0] = A[0] + 1
        Custom script:   endloop
        -------- END INITATION --------
        Custom script:   set A[0] = 0
        Custom script:   set A[1] = 150
        Custom script:   set B[1] = 2
        Custom script:   loop
        Custom script:       exitwhen A[0]>A[1]
[COLOR="DarkOrange"]        Custom script:       set offset = offset + 5[/COLOR]
        Custom script:       set udg_Temp_real1 = offset
        Custom script:       set B[0] = 0
        Custom script:       loop
        Custom script:           exitwhen B[0]>B[1]
[COLOR="DarkOrange"]        Custom script:           set angle[B[0]] = angle[B[0]] + 4[/COLOR]
        Custom script:           set udg_Temp_point1 = loc[B[0]]
        Custom script:           set udg_Temp_real2 = angle[B[0]]
        Set Temp_point2 = (Temp_point1 offset by Temp_real1 towards Temp_real2 degrees)
        Custom script:           set loc[[COLOR="Blue"]0[/COLOR]] = udg_Temp_point2
[COLOR="Lime"]        Special Effect - Create a special effect at Temp_point2 using Abilities\Spells\NightElf\Taunt\TauntCaster.mdl[/COLOR]
        Custom script:           call RemoveLocation (udg_Temp_point2)
[COLOR="Red"]        Custom script:           set udg_Temp_point2 = loc[[COLOR="Blue"]0[/COLOR]]
        Special Effect - Create a special effect at Temp_point2 using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl[/COLOR]
[COLOR="Lime"]        Game - Display to (All players) the text: thunderclap?[/COLOR]
        Custom script:           call RemoveLocation (udg_Temp_point2)
        Custom script:           set B[0] = B[0] + 1
        Custom script:       endloop
        Custom script:       call RemoveLocation (udg_Temp_point1)
        Custom script:       set A[0] = A[0] + 1
        Wait 0.01 game-time seconds
        Custom script:   endloop
        Game - Display to (All players) the text: endfunction
I DO see the Green collored special effect, but
I DONT see the Red collored special effect, with other words, my global isn't stored into my local.

Is anyone able to explain me why not?

frozenwind (confused).

EDIT:
Another fact:
When I repalce the blue "0" for "B[0]", then it happens at "center of playable map area", instead of around my hero. (The taunt effect, not the thunderclap)

EDIT2:
It seems like the Orange parts get set just like I want them to be set. (it spins while getting bigger all the time)
 

Frozenwind

System maker
Reaction score
99
It becomes an ability and I want people that know 0% JASS to be able to use it.

For example the abilitycondition:
People that know 0% JASS don't know "Oh, let's set it to 'A000'", but I think they're able to set their ability into a GUI condition.

frozenwind.
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Custom script: call RemoveLocation (udg_Temp_point2)
That actually removes the location, so loc[0] and udg_Temp_point2 will no longer point to a location.
 

Frozenwind

System maker
Reaction score
99
But udg_Temp_point2 is set to a location when I try to store it into my local,
doesn't it pass over the location be4 I remove udg_Temp_point2?

frozenwind.
 

Trollvottel

never aging title
Reaction score
262
yes but this doesnt kill the variable like set loc = null.
it removes the point and all variables storing this point are then empty
 

Frozenwind

System maker
Reaction score
99
But if I don't do that I got a memory leak?

frozenwind.

EDIT:
You're right though o_O
Removed that "call RemoveLocation", and the bug dissapeared....
 

The_Kingpin

Member (Who are you and why should I care?)
Reaction score
41
Setting loc[0] = udg_Temp_point2 does not create a new location, it simply makes loc[0] refer to the same location as udg_Temp_point2 does. I.E:

JASS:
set LocA = Location(123,456) // New location at 123,456
set LocB = LocA // The same location as LocA (Like C++ LocA = *LocB)
call RemoveLocation(LocA) // Removes the location that LocA and LocB point to


You're thinking of nulling variables. (Of which you didn't do in this trigger, everything that isn't an integer, real, boolean, or string must be set = null at the end of the function.)
 

Frozenwind

System maker
Reaction score
99
Should I also try "call RemoveLocation", when I'm sure that location isn't used anymore, else I still got a leak, don't I?

frozenwind.
 

Trollvottel

never aging title
Reaction score
262
you still have to remove the location, but you should do that later when you dont need it ;)
/edit: thats right :)
 

Frozenwind

System maker
Reaction score
99
I doubt wether u actually saw my post since reply in same minute,
but thanks, that answered me:p

frozenwind.
 
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