HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Is this correct without leaks ect?

03-11-2007, 08:34 AM#1
botanic
This works I just want to know if this is the best way also if there are any leaks that I can fix

also does anyone know a good way to remove dead units from memory or does wc3 do that automatically?

a lot of it is the same so any optimizations would be great as well.

Thank you in advance ^.^

Trigger:
Spawn
Collapse Events
Time - Every 23.00 seconds of game time
Conditions
Collapse Actions
-------- red1 --------
Set tempregion = Region 000 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Grunt for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0140 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 001 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Troll Headhunter for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0140 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- red2 --------
Set tempregion = Region 000 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Grunt for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0046 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 001 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Troll Headhunter for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0046 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- red3 --------
Set tempregion = Region 007 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Grunt for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0057 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 006 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Troll Headhunter for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0057 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- red4 --------
Set tempregion = Region 007 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Grunt for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0061 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 006 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Troll Headhunter for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Victim) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0061 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- green1 --------
Set tempregion = Region 025 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Footman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0140 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 015 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Rifleman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0140 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- green2 --------
Set tempregion = Region 025 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Footman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0046 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 015 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Rifleman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0046 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- green3 --------
Set tempregion = Region 011 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Footman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0057 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 010 <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Rifleman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0057 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- green4 --------
Set tempregion = Region 011 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Footman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0061 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
-------- --------
Set tempregion = Region 010 Copy <gen>
Set temppoint = (Center of tempregion)
Unit - Create creepNum Rifleman for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Collapse Unit Group - Pick every unit in (Units in tempregion owned by Neutral Extra) and do (Actions)
Collapse Loop - Actions
Set temppoint = (Position of Path Maker 0061 <gen>)
Unit - Order (Picked unit) to Attack-Move To temppoint
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( GetLastCreatedGroup() )
03-11-2007, 09:04 AM#2
Pyrogasm
Quote:
also does anyone know a good way to remove dead units from memory or does wc3 do that automatically?
They are automatically recycled when they die (excluding heroes, which may be able to revive).

I believe that you're leaking unit groups, even though you're using GetLastCreatedGroup(). Also, that code is just asking to be optimized... give me 10 minutes and I might have it.
03-11-2007, 09:12 AM#3
botanic
Thank you so much I dont know jass so I am stuck using the GUI... I plan on learning jass but i dont have the time right now...

Also I just ran a 30 minute test and there is something leaking so you are probably right about the unit groups...
03-11-2007, 10:08 AM#4
Pyrogasm
You'll need two triggers: one that sets the region/unit/unit-type variables at Map Init, and one that does the actual stuff. You also had unneeded region variables.

Trigger:
Initialization Variable Set
Collapse Events
Map Initialization
Conditions
Collapse Actions
Set Spawn_Regions[1] = Region 000 Copy <gen>
Set Spawn_Regions[2] = Region 000 <gen>
Set Spawn_Regions[3] = Region 007 <gen>
Set Spawn_Regions[4] = Region 007 Copy <gen>
Set Spawn_Regions[5] = Region 025 Copy <gen>
Set Spawn_Regions[6] = Region 025 <gen>
Set Spawn_Regions[7] = Region 011 <gen>
Set Spawn_Regions[8] = Region 011 Copy <gen>
-------- --------
Set Spawn_Regions[9] = Region 001 Copy <gen>
Set Spawn_Regions[10] = Region 001 <gen>
Set Spawn_Regions[11] = Region 006 <gen>
Set Spawn_Regions[12] = Region 006 Copy <gen>
Set Spawn_Regions[13] = Region 015 Copy <gen>
Set Spawn_Regions[14] = Region 015 <gen>
Set Spawn_Regions[15] = Region 010 <gen>
Set Spawn_Regions[16] = Region 010 Copy <gen>
-------- --------
Set Path_Makers[1] = Path Maker 0140 <gen>
Set Path_Makers[2] = Path Maker 0046 <gen>
Set Path_Makers[3] = Path Maker 0057 <gen>
Set Path_Makers[4] = Path Maker 0061 <gen>
-------- --------
Set Path_Makers[5] = Path Maker 0140 <gen>
Set Path_Makers[6] = Path Maker 0046 <gen>
Set Path_Makers[7] = Path Maker 0057 <gen>
Set Path_Makers[8] = Path Maker 0061 <gen>
-------- --------
Set Spawn_Units[1] = Grunt
Set Spawn_Units[2] = Troll Headhunter
Set Spawn_Units[3] = Footman
Set Spawn_Units[4] = Rifleman



Trigger:
Spawn
Collapse Events
Time - Every 23.00 seconds of game time
Conditions
Collapse Actions
-------- Red --------
Collapse For each (Integer A) from 1 to 4 do (Actions)
Collapse Loop - Actions
Collapse For each (Integer B) from 1 to 2 do (Actions)
Collapse Loop - Actions
If ((Integer B) = 1) then do (Set temppoint = (Center of Spawn_Regions[(Integer A)])), else do (Set temppoint = (Center of Spawn_Regions[((Integer A)+8)]))
Unit - Create creepNum Spawn_Unit[(Integer B)] for Neutral Victim at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Set temppoint = (Position of Path_Makers[(IntegerA])
If ((Integer B) = 1) then do (Set tempgroup = Units in Spawn_Regions[(Integer A)] owned by Neutral Victim), else do (Set tempgroup = Units in Spawn_Regions[((Integer A)+8)] owned by Neutral Victim)
Unit Group - Pick every unit in (tempgroup) and do (Unit - Order (Picked unit) to Attack-Move To temppoint)
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( udg_tempgroup )
-------- Green --------
Collapse For each (Integer A) from 5 to 8 do (Actions)
Collapse Loop - Actions
Collapse For each (Integer B) from 1 to 2 do (Actions)
Collapse Loop - Actions
If ((Integer B) = 1) then do (Set temppoint = (Center of Spawn_Regions[(Integer A)])), else do (Set temppoint = (Center of Spawn_Regions[((Integer A)+8)]))
Unit - Create creepNum Spawn_Unit[((Integer B)+2)] for Neutral Extra at temppoint facing Default building facing degrees
Custom script: call RemoveLocation( udg_temppoint )
Set temppoint = (Position of Path_Makers[(IntegerA])
If ((Integer B) = 1) then do (Set tempgroup = Units in Spawn_Regions[(Integer A)] owned by Neutral Victim), else do (Set tempgroup = Units in Spawn_Regions[((Integer A)+8)] owned by Neutral Extra)
Unit Group - Pick every unit in (tempgroup) and do (Unit - Order (Picked unit) to Attack-Move To temppoint)
Custom script: call RemoveLocation( udg_temppoint )
Custom script: call DestroyGroup( udg_tempgroup )

Variables Required:
NameTypeArray?
temppointPointNo
tempgroupUnit GroupNo
Spawn_RegionsRegionYes
Path_MarkersUnitYes
Spawn_UnitsUnit-TypeYes

See if that doesn't work for you.
03-11-2007, 10:12 AM#5
botanic
thank you would i avoid a leak if I destroy the first trigger after it is done setting the variables?
03-11-2007, 10:16 AM#6
Pyrogasm
It *technically* leaks because the trigger has run its worth. I usually forget to destroy those triggers anyway, but yes, it would be a good idea to use a call DestroyTrigger(GetTriggeringTrigger()).



EDIT: Holy shit! I just noticed the time change... it appears as though there was a ~2 hour delay between your second post and my second post. Why is DST so early this year!?
03-11-2007, 10:27 AM#7
botanic
nm
03-11-2007, 10:30 AM#8
Pyrogasm
"Integer Comparison" > "For Loop Integer B".

It's at the top of the list, I believe.