| 03-03-2006, 09:24 PM | #1 |
Could any1 help me out with my jassing, i started it 2 or 4 weeks ago and i just finished my trade system, i want to make sure that it won't be laggy either leaking. here is my controller trigger // ForGroupBJ used because the BG function takes care of killing the groups created by ForGroup PS: 2 Leaks fixed thanks to The_Strategy_Master JASS://Custom Script function GetDistance takes real x1, real y1, real x2, real y2 returns real return SquareRoot(Pow((x1 - x2), 2) + Pow((y1 - y2), 2)) endfunction function Helper takes nothing returns nothing if GetUnitUserData(GetEnumUnit()) == udg_Local_Integer then set udg_Local_Unit = GetEnumUnit() endif endfunction function CheckWho takes integer a returns nothing set udg_Local_Integer = a set bj_wantDestroyGroup = true call ForGroupBJ( GetUnitsOfTypeIdAll('h03K'), function Helper ) endfunction function Helper2 takes nothing returns nothing call KillUnit( GetEnumUnit() ) call TriggerSleepAction( 5.00 ) call RemoveUnit( GetEnumUnit() ) endfunction // my trigger function Trig_Controller_Jass_Conditions takes nothing returns boolean if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'h058' ) ) then return false endif return true endfunction function Trig_Controller_Jass_Func006001003 takes nothing returns boolean return ( GetUnitTypeId(GetFilterUnit()) == 'h03K' ) endfunction function THF takes nothing returns nothing local integer n set n = R2I(udg_Local_Real) call FadingText( I2S(( n * -1 )), 255, 220, 0, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()) ) call TriggerSleepAction( 0.10 ) call FadingText( I2S(( n * 3 )), 0, 200, 80, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()) ) endfunction function UnitFinder takes nothing returns nothing local real h set h = GetDistance( GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), GetUnitX(GetEnumUnit()), GetUnitY(GetEnumUnit()) ) if h >= 162.00 and h <= 210.00 then set udg_Local_Unit2 = GetEnumUnit() endif endfunction function Trig_Controller_Jass_Actions takes nothing returns nothing local unit c local real j local boolean k local location d set d = GetUnitLoc(GetTriggerUnit()) set j = S2R(GetCustomStringValue(GetTriggerUnit())) set k = GetCustomBooleanValue(GetTriggerUnit()) call PauseUnitBJ( true, GetTriggerUnit() ) set bj_wantDestroyGroup = true call ForGroupBJ( GetUnitsInRangeOfLocMatching(210.00, d, Condition(function Trig_Controller_Jass_Func006001003)), function UnitFinder ) set c = udg_Local_Unit2 call PauseUnitBJ( false, GetTriggerUnit() ) if k == true then if GetUnitUserData(c) == GetUnitUserData(GetTriggerUnit()) then call SetCustomBooleanValue( GetTriggerUnit(), false ) set j = j / 500 set udg_Local_Real = j call ExecuteFunc( "THF" ) call AdjustPlayerStateBJ( ( R2I(j) * (-1)) , GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_GOLD ) call AdjustPlayerStateBJ( ( R2I(j) * 3 ), GetOwningPlayer(GetTriggerUnit()), PLAYER_STATE_RESOURCE_LUMBER ) call CheckWho( R2I(GetCustomRealValue( GetTriggerUnit() )) ) set c = udg_Local_Unit call IssueTargetOrderBJ( GetTriggerUnit(), "move", c ) endif else if GetUnitUserData(c) == R2I(GetCustomRealValue( GetTriggerUnit() ) ) then call SetCustomBooleanValue( GetTriggerUnit(), true ) call CheckWho( GetUnitUserData(GetTriggerUnit() ) ) set c = udg_Local_Unit call IssueTargetOrderBJ( GetTriggerUnit(), "move", c ) endif endif call RemoveLocation(d) set d = null set c = null endfunction //=========================================================================== function InitTrig_Controller_Jass takes nothing returns nothing set gg_trg_Controller_Jass = CreateTrigger( ) call TriggerAddCondition( gg_trg_Controller_Jass, Condition( function Trig_Controller_Jass_Conditions ) ) call TriggerAddAction( gg_trg_Controller_Jass, function Trig_Controller_Jass_Actions ) endfunction |
| 03-03-2006, 10:24 PM | #2 |
You seem to create a few unit groups which you don't destroy, such as "ForGroupBJ( GetUnitsOfTypeIdAll('h03K'), function Helper )". |
| 03-03-2006, 10:54 PM | #3 |
as i said it alrdy ForGroupBG destroys the groups if u set set bj_wantDestroyGroup = true before calling the function. |
