HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Some help and advice for a few triggers.

12-05-2008, 12:06 PM#1
DD_Draco
Map Started:
Collapse Events
Time - Elapsed game time is 0.00 seconds
Conditions
Collapse Actions
Set DualTimeDur = 10.00
-------- Side: Heaven --------
Player Group - Add Player 1 (Red) to PlayerGroup[1]
Set DuelHeroLoc[1] = (Center of Player1Arena <gen>)
Player Group - Add Player 2 (Blue) to PlayerGroup[1]
Set DuelHeroLoc[2] = (Center of Player2Arena <gen>)
Player Group - Add Player 3 (Teal) to PlayerGroup[1]
Set DuelHeroLoc[3] = (Center of Player3Arena <gen>)
Player Group - Add Player 4 (Purple) to PlayerGroup[1]
Set DuelHeroLoc[4] = (Center of Player4Arena <gen>)
Player Group - Add Player 5 (Yellow) to PlayerGroup[2]
Set DuelHeroLoc[5] = (Center of Player5Arena <gen>)
Player Group - Add Player 6 (Orange) to PlayerGroup[2]
Set DuelHeroLoc[6] = (Center of Player6Arena <gen>)
Player Group - Add Player 7 (Green) to PlayerGroup[2]
Set DuelHeroLoc[7] = (Center of Player7Arena <gen>)
Player Group - Add Player 8 (Pink) to PlayerGroup[2]
Set DuelHeroLoc[8] = (Center of Player8Arena <gen>)
Collapse Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
Collapse Loop - Actions
Camera - Apply Camera 001 <gen> for (Picked player) over 0.00 seconds
Collapse Player Group - Pick every player in PlayerGroup[1] and do (Actions)
Collapse Loop - Actions
Player - Make (Picked player) treat Player 1 (Red) as an Ally with shared vision and full shared units
Collapse Player Group - Pick every player in PlayerGroup[2] and do (Actions)
Collapse Loop - Actions
Player - Make (Picked player) treat Player 1 (Red) as an Ally with shared vision and full shared units
KillBoard:
Collapse Events
Time - Elapsed game time is 0.00 seconds
Conditions
Collapse Actions
Leaderboard - Create a leaderboard for (All players) titled KillBoard
Set KillBoard = (Last created leaderboard)
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Leaderboard - Add (Player((Integer A))) to (Last created leaderboard) with label (Name of (Player((Integer A)))) and value GameKills[(Integer A)]
Collapse Else - Actions
Do nothing
Leaderboard - Show KillBoard
Create DuelHero:
Collapse Events
Time - Elapsed game time is 0.00 seconds
Conditions
Collapse Actions
Countdown Timer - Create a timer window for DualTime with title DuelHero:
Set DualTimeWin = (Last created timer window)
Countdown Timer - Show DualTimeWin
Countdown Timer - Start DualTime as a One-shot timer that will expire in DualTimeDur seconds
Trigger - Turn off (This trigger)
Start DuelHero:
Collapse Events
Time - DualTime expires
Conditions
Collapse Actions
-------- Reset DuelHero and select new ones. --------
Set DuelHero[1] = 0
Set DuelHero[2] = 0
Collapse For each (Integer A) from 1 to 4, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero[(Integer A)] Not equal to No unit
GameKills[(Integer A)] Greater than or equal to DuelHero[1]
Collapse Then - Actions
Set DuelHero[1] = (Integer A)
Collapse Else - Actions
Do nothing
Collapse For each (Integer A) from 5 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero[(Integer A)] Not equal to No unit
GameKills[(Integer A)] Greater than or equal to DuelHero[2]
Collapse Then - Actions
Set DuelHero[2] = (Integer A)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
DuelHero[1] Equal to 0
DuelHero[2] Equal to 0
Collapse Then - Actions
Game - Display to (All players) the text: DualHero has been c...
Countdown Timer - Start DualTime as a One-shot timer that will expire in DualTimeDur seconds
Collapse Else - Actions
Set DuelTimeOn = True
-------- Revive all DEAD heroes! --------
Trigger - Run ReviveHero <gen> (ignoring conditions)
-------- Pause ALL units. --------
Unit - Pause all units
-------- Stores current hero locations and angle then moves them to the stands. --------
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero[(Integer A)] Not equal to No unit
Collapse Then - Actions
Set HeroLoc[(Integer A)] = (Position of Hero[(Integer A)])
Set HeroDeg[(Integer A)] = (Facing of Hero[(Integer A)])
Wait 0.10 seconds
Unit - Move Hero[(Integer A)] instantly to DuelHeroLoc[(Integer A)]
Camera - Pan camera for (Player((Integer A))) to (Center of DuelArena <gen>) over 0.00 seconds
Collapse Else - Actions
Do nothing
-------- Move the DuelHero's from the stands to the arena. --------
Unit - Move Hero[DuelHero[1]] instantly to (Center of SideHeavenArena <gen>), facing 315.00 degrees
Unit - Move Hero[DuelHero[2]] instantly to (Center of SideHellArena <gen>), facing 135.00 degrees
Unit - Unpause Hero[DuelHero[1]]
Unit - Unpause Hero[DuelHero[2]]
Game - Display to (All players) the text: |cffff0000Fight!|r
HeroSelect:
Collapse Events
Unit - A unit enters HeroSelect <gen>
Conditions
Collapse Actions
Unit - Move [b]Unit[/b] <gen> instantly to ((Owner of (Entering unit)) start location), facing Default building facing degrees
Unit - Change ownership of [b]Unit[/b] <gen> to (Owner of (Entering unit)) and Change color
Set Hero[(Player number of (Owner of (Entering unit)))] = [b]Unit[/b] <gen>
Camera - Pan camera for (Owner of (Entering unit)) to ((Owner of (Entering unit)) start location) over 0.00 seconds
Unit - Remove (Entering unit) from the game
Trigger - Turn off (This trigger)
PlayerLeft:
Collapse Events
Player - Player 1 (Red) leaves the game
Player - Player 2 (Blue) leaves the game
Player - Player 3 (Teal) leaves the game
Player - Player 4 (Purple) leaves the game
Player - Player 5 (Yellow) leaves the game
Player - Player 6 (Orange) leaves the game
Player - Player 7 (Green) leaves the game
Player - Player 8 (Pink) leaves the game
Conditions
Collapse Actions
Leaderboard - Change the display style for (Triggering player) in KillBoard to Show the label, Hide the value, and Hide the icon
Leaderboard - Change the color of the label for (Triggering player) in KillBoard to (50.00%, 50.00%, 50.00%) with 0.00% transparency
Collapse Unit Group - Pick every unit in (Units owned by (Triggering player)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Picked unit) is A Hero) Equal to True
Collapse Then - Actions
Collapse For each (Integer A) from 1 to 6, do (Actions)
Collapse Loop - Actions
Hero - Drop the item from slot (Integer A) of (Picked unit)
Game - Display to (All players) the text: ((Name of (Picked unit)) + has dropped all of his/her items, be the lucky one to find them!)
Unit - Remove (Picked unit) from the game
Collapse Else - Actions
Unit - Remove (Picked unit) from the game
Set GameKills[(Player number of (Triggering player))] = 0
Set Hero[(Player number of (Triggering player))] = No unit
PlayerPayRate:
Collapse Events
Time - Every 10.00 seconds of game time
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
Collapse Loop - Actions
Player - Add 100 to (Picked player) Current gold
Player - Add 1 to (Picked player) Current lumber
PlayerPayRate
Collapse Events
Time - Every 10.00 seconds of game time
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
Collapse Loop - Actions
Player - Add 100 to (Picked player) Current gold
Player - Add 1 to (Picked player) Current lumber
CreepKill:
Collapse Events
Unit - A unit owned by Neutral Hostile Dies
Conditions
Collapse Actions
Player - Add 100 to (Owner of (Killing unit)) Current gold
KilledHero DuelHero:
Collapse Events
Unit - A unit Dies
Collapse Conditions
((Dying unit) is A Hero) Equal to True
Collapse Or - Any (Conditions) are true
Collapse Conditions
((Killing unit) is A Hero) Equal to True
Collapse And - All (Conditions) are true
Collapse Conditions
((Killing unit) belongs to an enemy of (Owner of (Dying unit))) Equal to True
((Owner of (Killing unit)) controller) Equal to User
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
DuelTimeOn Equal to True
(DuelArena <gen> contains (Dying unit)) Equal to True
Collapse Then - Actions
Set DuelTimeOn = False
Set GameKills[(Player number of (Owner of (Killing unit)))] = (GameKills[(Player number of (Owner of (Killing unit)))] + 1)
Leaderboard - Change the value for (Owner of (Killing unit)) in KillBoard to GameKills[(Player number of (Owner of (Killing unit)))]
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Unit - Move Hero[(Integer A)] instantly to HeroLoc[(Integer A)], facing HeroDeg[(Integer A)] degrees
Camera - Pan camera for (Owner of Hero[(Integer B)]) to (Position of Hero[(Integer A)]) over 0.00 seconds
Selection - Select Hero[(Integer A)] for (Owner of Hero[(Integer A)])
-------- Unpause ALL units. --------
Unit - Unpause all units
-------- Resume DualHero timer. --------
Countdown Timer - Start DualTime as a One-shot timer that will expire in DualTimeDur seconds
Collapse Else - Actions
Set GameKills[(Player number of (Owner of (Killing unit)))] = (GameKills[(Player number of (Owner of (Killing unit)))] + 1)
Leaderboard - Change the value for (Owner of (Killing unit)) in KillBoard to GameKills[(Player number of (Owner of (Killing unit)))]
ReviveHero:
Collapse Events
Time - Every 20.00 seconds of game time
Conditions
Collapse Actions
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Hero[(Integer A)] is dead) Equal to True
Collapse Then - Actions
Camera - Pan camera for (Owner of Hero[(Integer A)]) to ((Owner of Hero[(Integer A)]) start location) over 0.00 seconds
Hero - Instantly revive Hero[(Integer A)] at ((Owner of Hero[(Integer A)]) start location), Show revival graphics
Collapse Else - Actions
Do nothing

That is all the triggers I have currently done. Pyro already pointed out to me that Triggering Unit would be better to use in pretty much all situations.

If anyone else would be able to assist in pointing out leaks or suggesting better ways to do something (other then JASS) it would be most appreciated!

Also, apparently using a region name specifically generates a leak, so, should I make a variable store the location at the beggining of the map like the rest of the regions?
12-05-2008, 12:27 PM#2
Pyrogasm
It's not the region that's leaking, its the location. "Center of"
12-05-2008, 12:37 PM#3
DD_Draco
Quote:
Originally Posted by Pyrogasm
It's not the region that's leaking, its the location. "Center of"

Okay, I have looked at a tutorial to stop leaks, and it didn't mention that the 'Center of' was a problem. So, how can i avoid doing that? Or at least is there another tut that does show me other ways?

actually would:
Trigger:
Set Region = (Center of Region 022 <gen>)
be what i want to do, like what i have done for the others?
12-05-2008, 01:18 PM#4
Anitarf
Cleaning up a location is the same no matter how it was created, whether it's "center of region" or "position of unit" or whatever, it doesn't matter, it's still a location.
12-05-2008, 06:53 PM#5
ShadowWolf
Check out a program called LeakCheck v3, it won't catch every little leak, but it's useful for starting on that stuff, it will even give you suggestions on how to correct them.
12-05-2008, 08:46 PM#6
DD_Draco
Thanks for the suggestion, but the program wont even run.

Ok, "Center of region <gen>" is a leak. I made all of them into variables. Though, seeing as these variables are in CONSTANT use I don't see why it would be more prudent to destroy them.

People here seem more interested in pointing out an issue rather then an idea of how to fix it. I have looked at tutorials, and they all ask for a custom script that they don't provide or don't explain.
12-05-2008, 10:10 PM#7
Anitarf
Quote:
Originally Posted by DD_Draco
Ok, "Center of region <gen>" is a leak. I made all of them into variables. Though, seeing as these variables are in CONSTANT use I don't see why it would be more prudent to destroy them.
If you're reusing the same location over and over again then you could just store it to a variable at the start of the game and then use that variable; in that case, you don't need to destroy the locations because you're not creating any new locations. However, if you use "center of region" directly, it will create a new location every time it's called, even if the location will have the same coordinates every time it will still be a new location object each time so you have to destroy it after you're done using it.

Quote:
People here seem more interested in pointing out an issue rather then an idea of how to fix it. I have looked at tutorials, and they all ask for a custom script that they don't provide or don't explain.
Well, I'm sorry if we don't assume that you are a complete idiot and actually expect that you should be able to figure this stuff out on your own. There are multiple memory leak tutorials out there, you really should be able to figure this out by reading all of them.
12-06-2008, 10:05 AM#8
DD_Draco
Quote:
Originally Posted by Anitarf
If you're reusing the same location over and over again then you could just store it to a variable at the start of the game and then use that variable; in that case, you don't need to destroy the locations because you're not creating any new locations. However, if you use "center of region" directly, it will create a new location every time it's called, even if the location will have the same coordinates every time it will still be a new location object each time so you have to destroy it after you're done using it.

This is actually helpful!
Would something like:
Trigger:
Set DuelHeroLoc[0] = (Point(0.00, 0.00))
Be able to avoid the leak?


Quote:
Originally Posted by Anitarf
Well, I'm sorry if we don't assume that you are a complete idiot and actually expect that you should be able to figure this stuff out on your own. There are multiple memory leak tutorials out there, you really should be able to figure this out by reading all of them.

I can be extremely slow at times, and I got irritated. My apologies!
12-06-2008, 12:56 PM#9
marshall
No, because Point(0,0) creates another new location.

You need to use 2 custom script actions:
call RemoveLocation(udg_DuelHeroLoc[0])
set udg_DuelHeroLoc[0] = null

Reccomend moving to Jass which makes this kind of thing much quicker to implement.
12-06-2008, 02:32 PM#10
Monstah
Isn't there a variable that stores the last created location?

So (if there is) you need only one custom script:
call RemoveLocation(said variable)

Otherwise, you can create a global for such uses, say Temp_Location.

But then again, you will need to set the variable to the location you use all the time. Follow marshall's advice: Move to JASS.
12-06-2008, 03:12 PM#11
Zerzax
You don't need to set globals to null unless you are never going to use them again.
12-06-2008, 03:25 PM#12
marshall
...or if you later compare them to null.
12-07-2008, 01:54 AM#13
DD_Draco
To see if im moving in the right direction...
Start DuelHero:
Collapse Events
Time - DualTime expires
Conditions
Collapse Actions
-------- Reset DuelHero and select new ones. --------
Set DuelHero[1] = 0
Set DuelHero[2] = 0
Collapse For each (Integer A) from 1 to 4, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero[(Integer A)] Not equal to No unit
GameKills[(Integer A)] Greater than or equal to DuelHero[1]
Collapse Then - Actions
Set DuelHero[1] = (Integer A)
Else - Actions
Collapse For each (Integer A) from 5 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero[(Integer A)] Not equal to No unit
GameKills[(Integer A)] Greater than or equal to DuelHero[2]
Collapse Then - Actions
Set DuelHero[2] = (Integer A)
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Collapse Or - Any (Conditions) are true
Collapse Conditions
DuelHero[1] Equal to 0
DuelHero[2] Equal to 0
Collapse Then - Actions
Game - Display to (All players) the text: DualHero has been c...
Countdown Timer - Start DualTime as a One-shot timer that will expire in DualTimeDur seconds
Collapse Else - Actions
-------- Set-Up Variables --------
Set DuelTimeLoc[1] = (Center of SideHeavenArena <gen>)
Set DuelHeroLoc[1] = (Center of Player1Arena <gen>)
Set DuelHeroLoc[2] = (Center of Player2Arena <gen>)
Set DuelHeroLoc[3] = (Center of Player3Arena <gen>)
Set DuelHeroLoc[4] = (Center of Player4Arena <gen>)
Set DuelTimeLoc[2] = (Center of SideHellArena <gen>)
Set DuelHeroLoc[5] = (Center of Player5Arena <gen>)
Set DuelHeroLoc[6] = (Center of Player6Arena <gen>)
Set DuelHeroLoc[7] = (Center of Player7Arena <gen>)
Set DuelHeroLoc[8] = (Center of Player8Arena <gen>)
-------- DuelTimeOn provides a fail safe if someone manages to blink into the arena and kills someone. --------
Set DuelTimeOn = True
-------- Revive all DEAD heroes! --------
Trigger - Run ReviveHero <gen> (ignoring conditions)
-------- Pause ALL units. --------
Unit - Pause all units
-------- Stores current hero locations and angle then moves them to the stands. --------
Collapse For each (Integer A) from 1 to 8, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Hero[(Integer A)] Not equal to No unit
Collapse Then - Actions
Set HeroLoc[(Integer A)] = (Position of Hero[(Integer A)])
Set HeroDeg[(Integer A)] = (Facing of Hero[(Integer A)])
Wait 0.10 seconds
Unit - Move Hero[(Integer A)] instantly to DuelHeroLoc[(Integer A)]
Camera - Pan camera for (Player((Integer A))) to (Center of DuelArena <gen>) over 0.00 seconds
Else - Actions
-------- Move the DuelHero's from the stands to the arena. --------
Unit - Move Hero[DuelHero[1]] instantly to DuelTimeLoc[1], facing 315.00 degrees
Unit - Move Hero[DuelHero[2]] instantly to DuelTimeLoc[2], facing 135.00 degrees
Unit - Unpause Hero[DuelHero[1]]
Unit - Unpause Hero[DuelHero[2]]
Game - Display to (All players) the text: |cffff0000Fight!|r
-------- Destroy Variables --------
Custom script: call RemoveLocation( udg_DuelTimeLoc[1] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[1] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[2] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[3] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[4] )
Custom script: call RemoveLocation( udg_DuelTimeLoc[2] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[5] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[6] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[7] )
Custom script: call RemoveLocation( udg_DuelHeroLoc[8] )

Also if i added call DestroyTrigger( TriggerName ) at the end of the triggers that are used to select heroes, would that be more effective then just turning them off?
12-07-2008, 02:23 AM#14
darkwulfv
You shouldn't destroy triggers. So no. Turning it off is fine.