Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Spell
Events
Conditions
Actions

Custom script: set bj_wantDestroyGroup = true

Unit Group - Pick every unit in ......

Custom script: set bj_wantDestroyGroup = true

Unit Group - Pick every unit in ......
yes, becouse calling an event function in a periodic event is so easyAye, but it does make a difference if you use periodic effects.
besides... waits wont let you use "casting unit" and you will be forced to use variables
yes, becouse calling an event function in a periodic event is so easy![]()
ok, well, it seems to me like you are supposed to destroy locations and unit groups and those kinds of things...and i thought you were supposed to null them also...but someone said you don't null unit groups?
so what do you null and what do you destroy? and like, i'm pretty sure locations need to be nulled...but i saw on someone's map they are not nulled and it's a good triggered map so i don't understand.... some help? it is very confusing.
what needs to be nulled and what needs to be destroyed? and is there an order to nulling and destroying when you have to do both?
err...let me see if i got this right...i just read the msg by spiwn again...
no global variables need nulling... so that means just local variables need nulling right? well...oops.
so how do you treat the local variables? how does the nulling and destroying work there?
well anyway obviously what spiwn said is totally wrong...i don't understand what you're saying but it doesn't sound like much...
but i went ahead and took out all the nulling for the global variables and instead of the annoying black screen bug that sometimes happened to players and usually happened in the replays...i got everyone disconnected within the first ten minutes of every game!
that is extremely annoying and as you can see...it disproves what he told me.
if Herman or whoever honestly knows what's what then PLEASE look at my map and explain to me how i need to be editing these triggers.
the nulling the global variables apparently is necessary, at any rate...because without it my map disconnects everyone. but is the overnulling what's causing the black screen bug? how come no one has ever explained what that is? no one seems to know what it is, as if i'm the only one running into it.
do a full house on my map and watch the replay after the game.
it should do a weird black screen sometimes and maybe even crash. but at least it operates better than no nulling the globals.
spiwn said:To fully understand why global variables do not have to be nulled you would have to understand what a variable of type any handle(unit, group and etc - everything except integer, real, boolean, string( I may miss something) is.
Lets say we have a variable of type unit.
Since this is a handle, not one of the basic types, the variables does not carry all the data about the unit.
Ah, confusing. For example an integer variables stores the actual integer. But with a unit(handle) that would be impossible(there is a lot of data connected with it- position height, health and etc). So blizzard most probably made their own structures - unit, group and etc.
When you create a unit, the structures is created. When you store the unit in a variable a pointer/index/address to that structures is stored in the memory(it is a way to show where in the memory the data for that unit is stored). So when you use something like
set temp_unit=bj_lastcreatedunit
War3 retrieves that address(which is a number(integer), but like 0x9002305 (example only) ) and stores it.
When you call that temp_unit war3 finds what address is stored in the variable and refers to the structure at that adress.
So every variable of type handle is actually an integer that shows the address of some structure, but a bit different, because war3 does not erase it.
The H2I function(rather famous, if you have not heard of it search(most systems use it)) uses this, and when you use something like H2I(temp_unit) it will return the address/pointer/index that is stored in temp_unit.
Here there is one important thing to learn - while an address of some structures exists, anywhere - local or global, that structure address cannot be used again, even if the actual structure is destroyed. And because addresses get used and never freed, the address of the next created structure will be bigger. All those local variables that point to some structure will take memory. Addresses will continue to increase, memory taken by pointers will increase, resulting in lag, and eventually in a game crash.
So lets examine local and global variables.
If you use a local and do not null it, at the end of the function you will no longer be able to access it - change it, erase it or whatever. And since it is pointing to some structure, that address cannot be used ever again, so you must null it.
But when you use globals you can always access that variable.
So:
set udg_temp_unit = Blah
It stores some address in udg_temp_unit. Now you would think that this is the same as a local variable. Well you are not wrong - again until the pointer is not removed, it will use up an address.
Ah, but with globals, you can access them again:
set udg_temp_unit= Blah2
Now udg_temp_unit is assigned a different pointer, but the old one is erased, so the index is freed.
I have realized this, by reading a lot of tutorials, examining the H2I and studying user structures(vJass). Yes it is rather true.
I explained it the simplest way I could. I will not be surprised if you do not understand it from the first time. Whether you understand it ever depends only on you(some people just think other ways).
If you want to understand this/ become proficient with jass, I suggest you keep it, read tutorial, practice and read it again(until you understand it).
Note that understanding this is not really necessary to become a good "jasser". You actually can just remember this: Null locals, do not null Globals.
Only string, real, integer, code, boolean are not "structured". They are basic. I think they are included in most programming languages.
Everything else is a structure of those( in all languages).
Player structures probably include IPs, handicap, color, player name etc.
Units, groups, locations, player and etc are Handles (that is what blizzard calls them ( to fully understand what a handle is a very advanced thing must be learned - Interfaces, but since I have not even started learning about those, I cannot explain this to you)).
Since Blizzard did no and still do not wish to share how they have created handles this structure theory is just a smart guess. People do not call them structures, that is just something I figured would be most suitable to explain about them.
We cannot be 100% sure - it is illegal to peak in blizzards code.PurplePoot said:Because handles have an internal reference counter which is increased when they're referenced and decreased when they are dereferenced, and if it's >0 their handle id can't be recycled.
But we can test it:
Result for first test should be 1000 numbers displayed on screen. And from second, only 5(because the handle index cannot be freed while war 3 is executing something else(like this function), so when the trigger sleep action is called wc3 moves on does things(like freeing handle indexes) and comes back here to continue).JASS:function U2I takes unit u returns integer return u return 0 endfunction function Trig_testvars_Actions takes nothing returns nothing local integer i=0 local integer max=0 local integer ti local unit array u[1000] loop exitwhen i==1000 set u[i]=CreateUnit(Player(0),'hfoo',0,0,0) set ti=U2I(u[i]) call RemoveUnit(u[i]) //set u[i]=null //enable this for second test if(max<ti) then set max=ti call BJDebugMsg("Current address is " + I2S(max)) endif if((i-(i/5)*5)==0) then //To prevent lagg call TriggerSleepAction(-1) endif set i=i+1 endloop endfunction
saying what you are saying is fine if i could understand what you're talking about...please give me some examples!The only one who does not know "what it is" is you.
You are skimming the text. There already is(are) tutorial(s) on variables.
Like this one. But people do not seem to go in the tutorial section these days.
No I am not wrong. Global variables need not to be nulled, but they have to be destroyed removed(there are some exceptions like recycling or using only a limited number of variables - like 1! unit group).
saying what you are saying is fine if i could understand what you're talking about...please give me some examples!
like, what are those exceptions.
and it's not like i don't read the tutorials. it just so happens that alot of the information in them is irrelevant and hard to understand most of the time. especially annoying is lack of examples or them not showing examples properly. one of my biggest gripes is when they say this or that and i don't know what 'this' or 'that' is that they are referring to.
so like i said, please go over my map and give me examples of what destroying and nulling needs to be done. i'll check out that link for that tutorial you put in there in the meantime.
your way of explaining it was wrong, regardless of whether you know what is what, you have a horrible time explaining it.
edit: so that's what a widget is...lol cool, i learned one useful thing at least.
You missed the single most important example. You have learned what a widget is, but that was a personal tutorial on handles (wtf).You are skimming the text.
Wrong. When triggers fire often it is most important to destroy and null. Or else there will be memory and/or index leaks every time it fires and since the trigger fires a lot, there will be a lot of leaks.SanKaKu said:now, since this trigger is fired often and the variable is thus changed alot, does that mean that since the variable IS different from every other variable that not destroying and nulling it is ok? now there are exceptions, right?
Leak free trigger

Events


Unit - A unit Dies

Conditions


(Unit-type of (Triggering unit)) Equal to Footman

Actions


Set temp_point = (Position of (Triggering unit))


Set temp_group = (Units within 512.00 of temp_point)


Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)



Loop - Actions




Unit - Kill (Picked unit)


Custom script: call RemoveLocation(udg_temp_point)


Custom script: call DestroyGroup(udg_temp_group)
Actions

Do Multiple ActionsFor each (Integer A) from 1 to 10, do (Actions)


Loop - Actions



If (((Player((Integer A))) controller) Equal to (==) Computer) then do (Set TempGroup = (Units owned by (Player((Integer A))))) else do (Do nothing)



If (SaveUsActive Equal to (==) 0) then do (Set TempLoc = (Random point in (Playable map area))) else do (Set TempLoc = (Center of Jail <gen>))



If (((Player((Integer A))) controller) Equal to (==) Computer) then do (Unit Group - Order TempGroup to Move To TempLoc) else do (Do nothing)



Unit Group - Remove all units from TempGroup



Point - Remove TempLoc
Yes.isnt there an option in gameplay constants that says something about immune units bestowing auras?
) But, if the unit has locust, then that shouldn't be a problem, unless positive AoE's affect them.
