| 07-08-2005, 04:08 PM | #1 |
Alright, my movement system relies vastly on loops checking globals, positions of units, etc. IThe result is a huge amount of memory leaks each second, causing the gameplay to slow dramtically and have a horibbly long shut down time. Below are small segments of my loops that I believe to be leaking, if anyone can please give me a hand pinpointing the leaks, and how to adjust them it would be much apreciated. Positions my Hand model infront of the Real unit. Code:
HandMovement
Events
Time - Every 0.01 seconds of game time
Conditions
(Unit-type of Hero[(Player number of (Owner of (Triggering unit)))]) Equal to PlayerMasterChief
Actions
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Unit - Move PlayerHand[(Integer A)] instantly to ((Position of Hero[(Integer A)]) offset by 70.00 towards (Facing of Hero[(Integer A)]) degrees), facing (Facing of Hero[(Integer A)]) degreesCode:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Down[(Integer A)] Equal to True
Then - Actions
Unit - Order Hero[(Integer A)] to Move To ((Position of Hero[(Integer A)]) offset by 50.00 towards (45.00 + CamFacing[(Integer A)]) degrees)
Else - Actions
Set CamFacing[(Integer A)] = (CamFacing[(Integer A)] + 12.50)
Unit - Order Hero[(Integer A)] to Move To ((Position of Hero[(Integer A)]) offset by 50.00 towards (0.00 + CamFacing[(Integer A)]) degrees)EDIT: After testing a few things its obvious the first trigger is the leak. Everytime I move the Hand unit I create a location, which ends up leaking. How can I use custom script to remove this leak? Thanks. |
| 07-08-2005, 04:51 PM | #2 |
Guest | I think this oughta do it. I had a similar problem in my pong map where every 0.01 seconds I moved the ball. This seemed to fix it, although I'm still sort of new to jass. Code:
HandMovement
Events
Time - Every 0.01 seconds of game time
Conditions
(Unit-type of Hero[(Player number of (Owner of (Triggering unit)))]) Equal to PlayerMasterChief
Actions
Custom script: local location tempLoc = PolarProjectionBJ(GetUnitLoc(udg_Hero[GetForLoopIndexA()]), 70.00, GetUnitFacing(udg_Hero[GetForLoopIndexA()]))
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Custom script: call SetUnitPositionLoc( udg_PlayerHand[GetForLoopIndexA()], tempLoc )
Custom script: call RemoveLocation(tempLoc) |
| 07-08-2005, 06:22 PM | #3 |
It fixed the leaks, great. However instead of placing the Hand in relation to the Hero, it placed it in relation to the center of the playable area. |
| 07-08-2005, 07:52 PM | #4 |
why do you have triggering unit in the conditions? A timer doesnt have a unit : / |
| 07-08-2005, 09:35 PM | #5 |
Guest | Instead of Code:
Custom Script: call RemoveLocation(tempLoc) Code:
Custom Script: set tempLoc = null |
| 07-08-2005, 09:39 PM | #6 | |
Quote:
Sorry ignore that, It was part of another trigger I used when a cut-and-pasted the section of the trigger I wanted to show. Secondly: No effect. Still remains in the center. I notice you have a script with IndexA outside of a Integer A loop. Is that the problem? |
| 07-09-2005, 01:12 AM | #7 |
I would suggest you get someone who knows jass to make your triggers. Using GUI loops are bad as you cant have integer(a) or integer(b) loops running at the same time withougt bugs. |
| 07-09-2005, 01:37 AM | #8 |
I intend to convert most of my triggers to JASS eventually, however for the time being I want to use custom scripts and GUI, even if there is an occational bug. Anyway, why is this custom script placing the unit in the middle of the map? |
| 07-09-2005, 02:52 AM | #9 |
Code:
HandMovement
Events
Time - Every 0.01 seconds of game time
Conditions
(Unit-type of Hero[(Player number of (Owner of (Triggering unit)))]) Equal to PlayerMasterChief
Actions
Custom script: local location tempLoc = PolarProjectionBJ(GetUnitLoc(udg_Hero[GetForLoopIndexA()]), 70.00, GetUnitFacing(udg_Hero[GetForLoopIndexA()]))Because the GetForLoopIndexA() is outside the loop. do this: Code:
HandMovement
Events
Time - Every 0.01 seconds of game time
Conditions
(Unit-type of Hero[(Player number of (Owner of (Triggering unit)))]) Equal to PlayerMasterChief
Actions
Custom script: local location tempLoc
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Custom script:set temploc = PolarProjectionBJ(GetUnitLoc(udg_Hero[GetForLoopIndexA()]), 70.00, GetUnitFacing(udg_Hero[GetForLoopIndexA()]))
Custom script: call SetUnitPositionLoc( udg_PlayerHand[GetForLoopIndexA()], tempLoc )
Custom script: call RemoveLocation(tempLoc) |
| 07-09-2005, 08:36 AM | #10 | |
Guest | Quote:
|
| 07-09-2005, 09:53 AM | #11 |
Thanks, however I get a warning now. 'Expected a variable name' on the line where you set TempLoc within the loop. EDIT: I got it, you didn't capitalize the L in that script. Works like a charm now. However when I rotate the arm still faces the same direction..It should be facing the same angle as the camera at all times. EDIT2: Alright I tried this, but is it leaking again? Also, would it be better to use another custom script for the angle rather than the GUI? Code:
Hand Positioning
Events
Time - Every 0.05 seconds of game time
Conditions
Actions
Custom script: local location tempLoc
For each (Integer A) from 1 to 10, do (Actions)
Loop - Actions
Custom script: set tempLoc = PolarProjectionBJ(GetUnitLoc(udg_Hero[GetForLoopIndexA()]), 70.00, GetUnitFacing(udg_Hero[GetForLoopIndexA()]))
Custom script: call SetUnitPositionLoc( udg_PlayerHand[GetForLoopIndexA()], tempLoc )
Unit - Move PlayerHand[(Integer A)] instantly to (Position of PlayerHand[(Integer A)]), facing (Facing of Hero[(Integer A)]) degrees
Custom script: call RemoveLocation(tempLoc) |
| 07-09-2005, 12:15 PM | #12 |
First of all, you don't need local variables for this, just use global point variables (or rather just a point array) named tempPoint[] or something like that. This way, you can use almost only GUI. Second, you only fixed half of your location leaks. You create two point objects with the trigger, the first one is: (Position of Hero[(Integer A)]), and the second one is ((first point) offset by 70.00 towards (Facing of Hero[(Integer A)]) degrees). So the proper loop actions would look like this: Code:
Set tempPoint[1] = (Position of Hero[(Integer A)])
Set tempPoint[2] = ( tempPoint[1] offset by 70.00 towards (Facing of Hero[(Integer A)]) degrees)
Unit - Move PlayerHand[(Integer A)] instantly to tempPoint[2], facing (Facing of Hero[(Integer A)]) degrees
Custom script: call RemoveLocation( udg_tempPoint[1] )
Custom script: call RemoveLocation( udg_tempPoint[2] )
[i]//comment: because tempPoint is a global variable, you don't need to set it to null at the end.[/i] |
| 07-09-2005, 06:06 PM | #13 |
Perfect. That did it, thanks. |
| 07-10-2005, 12:18 AM | #14 |
but then it wont be multi-stable. |
| 07-10-2005, 06:35 AM | #15 |
You mean because it uses a global and not a local; or because it uses a single variable for all players rather than a vairable array with player number values? Sence its a loop does it really matter that its not a seperate variable for each player? |
