| 06-24-2010, 05:45 PM | #2 |
If you want it done in GUI, you gotta post the map. Not many people are crazy enough to dabble their way through re-creating your entire setup. Or, if you want it done properly (in JASS), you gotta convert those triggers to Custom Script and post the rawcode they give you. Not many people would type that stuff out in JASS. |
| 06-24-2010, 05:51 PM | #3 |
First optimization you could do would be increasing the timer interval to 0.02 seconds; it is virtually indistinguishable from 0.01, some people don't even mind if you go as far as 0.05 but the movement seems definitely choppy to me at that point. Furthermore, you leak groups and locations like crazy, you should clean those up after you are done with them. Better still would be to not use them in the first place. Take a look at the sample of the TimedLoop resource, it could easily be adapted to do exactly what you want to do. |
| 06-25-2010, 02:09 AM | #4 |
Thanks really much about your help! :D I really want this trigger to work, sorry about the leaks, I didn't check this completely :D EDIT: Post edited! That still doesn't make that the trigger work right! Now the Dynamites will explore right away! Why? Is there any fixes? |
| 06-25-2010, 01:49 PM | #5 |
You should destroy groups and locations in the same loop where you create them, otherwise the trigger will create a bunch of them and only destroy the last one. Furthermore, BJ functions like EnumDestructablesInCircleBJ leak handle references so even with "proper" GUI code, you can not avoid leaks. Try using this vJass code instead: JASS:library Dynamite initializer Init requires TimedLoop globals private constant real SPEED = 500.0 private constant integer DYNAMITE_ID = 'n00H' private constant real RADIUS = 90.0 endglobals struct Dynamite static group g = CreateGroup() static rect r = Rect(-RADIUS,-RADIUS,RADIUS,RADIUS) static real x static real y unit u private static method unitEnum takes nothing returns boolean local unit f=GetFilterUnit() if GetPlayerController(GetOwningPlayer(f))==MAP_CONTROL_USER and GetUnitTypeId(f)!=DYNAMITE_ID then call KillUnit(f) endif return false endmethod private static method destFilter takes nothing returns boolean local real dx=GetDestructableX(GetFilterDestructable())-.x local real dy=GetDestructableY(GetFilterDestructable())-.y if dx*dx+dy*dy<=RADIUS*RADIUS then call KillDestructable(GetFilterDestructable()) endif return false endmethod private method onTimedLoop takes nothing returns boolean set .x = GetUnitX(.u) set .y = GetUnitY(.u) call SetUnitX(.u, .x + SPEED*TimedLoop_PERIOD*Cos(GetUnitFacing(.u)*bj_DEGTORAD) ) call SetUnitY(.u, .y + SPEED*TimedLoop_PERIOD*Sin(GetUnitFacing(.u)*bj_DEGTORAD) ) call GroupEnumUnitsInRange(g, .x,.y, RADIUS, Condition(function Dynamite.unitEnum)) call MoveRectTo(.r, .x,.y) call EnumDestructablesInRect(r, Condition(function Dynamite.destFilter), null) return IsUnitType(.u, UNIT_TYPE_DEAD)==TimedLoop_STOP endmethod implement TimedLoop static method create takes unit u returns Dynamite local Dynamite this= Dynamite.allocate() set .u = u call .startTimedLoop() return this endmethod endstruct private function UnitEntersMap takes nothing returns nothing if GetUnitTypeId(GetTriggerUnit())==DYNAMITE_ID then call Dynamite.create(GetTriggerUnit()) endif endfunction private function Init takes nothing returns nothing local trigger t = CreateTrigger() local region r = CreateRegion() call RegionAddRect(r, bj_mapInitialPlayableArea) call TriggerRegisterEnterRegion(t, r, null) call TriggerAddAction( t, function UnitEntersMap ) endfunction endlibrary Requires TimedLoop and BoundSentinel. |
