Poll | | What game does everyone play now? | Starcraft 2 | | 26% | [ 8 ] | Warcraft 3 | | 35% | [ 11 ] | League of Legends | | 19% | [ 6 ] | World of Warcraft | | 0% | [ 0 ] | Diablo 2 | | 0% | [ 0 ] | No games at all | | 10% | [ 3 ] | Other game not listed | | 10% | [ 3 ] |
| Total Votes : 31 |
|
| | Help Me With Locust ! | |
| | Author | Message |
---|
RKR. Recruit
| Subject: Help Me With Locust ! Sun May 02, 2010 2:28 pm | |
| Hi ! I need some help with my map and i wanna create a really cool but nobody can't help me ! I am crying at the moment because i wanna do a popular maze ... Answer Me Fast Please[b][u] | |
| | | AmAzIn[G] Commander
| Subject: Re: Help Me With Locust ! Sun May 02, 2010 2:44 pm | |
| | |
| | | Pat1487 Moderator
| Subject: Re: Help Me With Locust ! Mon May 03, 2010 7:46 pm | |
| - Code:
-
function locust takes nothing returns nothing call UnitAddAbilityBJ( 'Aloc', GetEnumUnit() ) call ShowUnitHide( GetEnumUnit() ) call ShowUnitShow( GetEnumUnit() ) call UnitRemoveAbilityBJ( 'Aloc', GetEnumUnit() ) endfunction
function Trig_locust_Actions takes nothing returns nothing call ForGroupBJ( GetUnitsInRectAll(GetEntireMapRect()), function locust ) endfunction
function InitTrig_locust takes nothing returns nothing set gg_trg_locust = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_locust, 0.01 ) call TriggerAddAction( gg_trg_locust, function Trig_locust_Actions ) endfunction That will give every unit on the map locust, including demonhunters If you have units that spawn you have to do - Code:
-
call UnitAddAbilityBJ( 'Aloc', GetLastCreatedUnit() ) call ShowUnitHide( GetLastCreatedUnit() ) call ShowUnitShow( GetLastCreatedUnit() ) Right after you spawn the unit I recommend making that into a function and just calling that function when you need to do it to save time Hiding and showing them will allow you to use regular collision triggers instead of immolation for killing This will only work in TFT ROC requires more effort that im not going to get into You might also want to add auto selection of units at the start and on revive | |
| | | FaMoUs Recruit
| Subject: Re: Help Me With Locust ! Tue May 04, 2010 8:08 pm | |
| | |
| | | RKR. Recruit
| Subject: Re: Help Me With Locust ! Tue May 04, 2010 8:14 pm | |
| | |
| | | Serenity09 Moderator
| Subject: Re: Help Me With Locust ! Tue Jul 13, 2010 3:49 am | |
| - Pat1487 wrote:
-
- Code:
-
function locust takes nothing returns nothing call UnitAddAbilityBJ( 'Aloc', GetEnumUnit() ) call ShowUnitHide( GetEnumUnit() ) call ShowUnitShow( GetEnumUnit() ) call UnitRemoveAbilityBJ( 'Aloc', GetEnumUnit() ) endfunction
function Trig_locust_Actions takes nothing returns nothing call ForGroupBJ( GetUnitsInRectAll(GetEntireMapRect()), function locust ) endfunction
function InitTrig_locust takes nothing returns nothing set gg_trg_locust = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_locust, 0.01 ) call TriggerAddAction( gg_trg_locust, function Trig_locust_Actions ) endfunction Literally copy and pasted that. Throwing an error in the last function at set gg_trg_locust = CreateTrigger( ). error: expected variable name. Created a new map just to see if WE wasn't just being crazy and got the same error. I cant think of a reason it wouldnt work, but i never learned jass im just making a good guess from c/java. | |
| | | Pat1487 Moderator
| Subject: Re: Help Me With Locust ! Tue Jul 13, 2010 12:35 pm | |
| It should be in a trigger called locust Make a new trigger called locust, convert it to custom text, erase everything in there, and paste this | |
| | | Fermee Recruit
| Subject: Re: Help Me With Locust ! Fri Nov 19, 2010 9:30 am | |
| damn famous the link is broken
| |
| | | Serenity09 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 9:55 am | |
| well now that i actually know somewhat how jass works as brilliant as it is, pat's trigger leaks like a whore on her period you should use this (the exact same thing but slightly reworded) - Code:
-
function locust takes nothing returns nothing local unit u = GetEnumUnit()
call UnitAddAbilityBJ( 'Aloc', u ) call ShowUnitHide(u) call ShowUnitShow(u) call UnitRemoveAbilityBJ( 'Aloc', u)
set u = null endfunction
function Trig_locust_Actions takes nothing returns nothing local group g = GetUnitsInRectAll(GetEntireMapRect())
call ForGroup( g, function locust )
call DestroyGroup(g) set g = null endfunction
function InitTrig_locust takes nothing returns nothing set gg_trg_locust = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_locust, 0.01 ) call TriggerAddAction( gg_trg_locust, function Trig_locust_Actions ) endfunction
im not sure if giving enumunit a var in the first part is necessary, but it also helps performance (a lil tiny bit) i am sure that ForGroupbj leaks like aforementioned whore should also probably destroy the trigger afterwards as well since it only runs once (im not sure if this is correct though) - slight difference:
- Code:
-
function locust takes nothing returns nothing local unit u = GetEnumUnit()
call UnitAddAbilityBJ( 'Aloc', u ) call ShowUnitHide(u) call ShowUnitShow(u) call UnitRemoveAbilityBJ( 'Aloc', u)
set u = null endfunction
function Trig_locust_Actions takes nothing returns nothing local group g = GetUnitsInRectAll(GetEntireMapRect())
call ForGroup( g, function locust )
call DestroyGroup(g) set g = null call DestroyTrigger( GetTriggeringTrigger() ) endfunction
function InitTrig_locust takes nothing returns nothing set gg_trg_locust = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_locust, 0.01 ) call TriggerAddAction( gg_trg_locust, function Trig_locust_Actions ) endfunction
| |
| | | AmAzIn[G]232 Corporal
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 10:17 am | |
| ooo seren the big dawg is taking lead as gamer intellectual of jass. (lets wait for pats retort) This may actually get interesting. (remember you can only see it here folks on clan tmmm) | |
| | | Pat1487 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 11:33 am | |
| It doesnt leak that badly, and since the part that leaks only runs once i didnt care to optimize it Functions with BJ in their name dont leak any more then non-BJ functions (like ForGroup and ForGroupBJ) The difference is that most BJ functions just call the non-BJ function, adding an extra step when you use the BJ version (blizzard actually wrote functions that have no other purpose then to call 1 other function) The part that runs more then once (the locust function itself) is the part that should be optimized - Code:
-
function locust takes nothing returns nothing local unit u = GetEnumUnit()
call UnitAddAbility(u, 'Aloc') call ShowUnit(u, false) call ShowUnit(u, true) call UnitRemoveAbility(u, 'Aloc')
set u = null endfunction
function Trig_locust_Actions takes nothing returns nothing local group g = GetUnitsInRectAll(GetEntireMapRect())
call ForGroup( g, function locust )
call DestroyGroup(g) set g = null endfunction
function InitTrig_locust takes nothing returns nothing set gg_trg_locust = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_locust, 0.01 ) call TriggerAddAction( gg_trg_locust, function Trig_locust_Actions ) endfunction But even with all that, you probably wont notice a difference in performance between the original and these | |
| | | Serenity09 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 11:46 am | |
| im not totally sure how groups work but my guess is they're like a array list of (pointers to) every unit in the group so if you leak a group of every unit on the map then its a pretty big leak
when you call ForGroupbj, it calls ForGroup but then after that you leak the group that's passed to ForGroup from ForGroupbj i guess whether its a big deal depends on whether the group thats never nulled in ForGroupbj is a 4 bit pointer or a n bit array list of units (a full copy of the group) either way the group passed to ForGroup should be destroyed
but sometimes JASS does things weirdly
like i'd set a local variable to be equal to an element of a global array for convenience, but then instead of it being a pointer to that element it'd just be a copy of it. it took me like 30 minutes to figure that out too, it just seemed so stupid that it'd work that way | |
| | | Pat1487 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 12:01 pm | |
| The group gets leaked either way unless you null it, you still have to null it even for ForGroup (like you did) so it leaks the same since it runs once
The group is like an array, but all the units get added to it once, so it only runs once, pulling stuff from it later (during the locust function) doesnt make more groups or any more group leaks
| |
| | | Serenity09 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 12:11 pm | |
| what i was saying is that for something like
ForGroup(g) jumps right into the loop but
ForGroupbj(g)
calls function ForGroupbj(g)
which basically just calls ForGroup(g) but never nulls group
you can null the group passed to ForGroupbj but not the group inside of that function | |
| | | Pat1487 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 12:57 pm | |
| I dont think it makes a copy every time Everything made in GUI would leak if that were the case, and i know WE can be retarded, but theres no way it would be designed that poorly
ShowUnitHide and ShowUnitShow both call ShowUnit and pass the unit just like ForGroupBJ and ForGroup does with groups Same with UnitAddAbility/RemoveAbility and UnitAddAbilityBJ/RemoveAbilityBJ
So by your logic those would leak worse then groups All total my original triger would be 4 leaks for every unit on the map that you didnt null in your trigger, plus the group leak that you did null
If it were that bad you would see a massive improvement in performance with the last trigger i posted I havent actually tested it, but im willing to bet you see little to no performance increase at all, where the increase you do get would just be the removal of the extra step by calling a function directly, instead of calling a function that calls the function
I only optimize code when you can see a difference in performance, like if this trigger ran more then once I dont go for 100% efficiency | |
| | | AmAzIn[G]232 Corporal
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 1:02 pm | |
| - Pat1487 wrote:
- I dont go for 100% efficiency
Stupid broken robot. | |
| | | Serenity09 Moderator
| Subject: Re: Help Me With Locust ! Sat Jun 04, 2011 2:50 pm | |
| its only for blizzard jass like stuff blizzard wrote using their own jass (bj's)
every bj that can leak does leak. they literally didn't null a single handle in everyone of their triggers
stuff that aren't bj's are fine
the reason they didn't care about that stuff is cuz they never used or had any need for periodics so a few leaks here and there was nbd basically what your reasons for not doing it except it ended up coming back to screw everyone else | |
| | | Pat1487 Moderator
| Subject: Re: Help Me With Locust ! Sun Jun 05, 2011 1:31 am | |
| Everything in GUI uses functions from blizzard.j (BJ functions, some dont have BJ in the name, like ShowUnitHide/ShowUnitShow for example) So it all leaks
There's a difference between my thing and blizzards Mine is for a 1 time thing that is used 1 very specific way Theirs is for a many time thing and is used many non-specific ways (like periodics and what not)
In blizzards case it shouldve been optimized | |
| | | Serenity09 Moderator
| Subject: Re: Help Me With Locust ! Sun Jun 05, 2011 12:04 pm | |
| a lot of that sounds very similar to what i said | |
| | | Sponsored content
| Subject: Re: Help Me With Locust ! | |
| |
| | | | Help Me With Locust ! | |
|
Similar topics | |
|
| Permissions in this forum: | You cannot reply to topics in this forum
| |
| |
| |