library MovementSpeed initializer init // Configuration private function MovementSpeedUpdateInterval takes nothing returns real // Change this to change the length of periodic // interval between each movement speed update. return 0.7 endfunction private function MovementSpeedModifier takes nothing returns real // Change this to change the 'strength' of adjustment. // A lower number will result in less difference than // a high number. return 2.00 endfunction // Internal globals private group G = CreateGroup() endglobals private function CopyGroup takes group g returns group set bj_groupAddGroupDest = CreateGroup() call ForGroup(g, function GroupAddGroupEnum) return bj_groupAddGroupDest endfunction private function MovementSpeedAdjuster takes nothing returns nothing local group g = CopyGroup(G) local unit u local real x local real y local real z local real a local location l = Location(0, 0) loop set u = FirstOfGroup(g) exitwhen u == null call GroupRemoveUnit(g, u) set x = GetUnitX(u) set y = GetUnitY(u) set a = GetUnitFacing(u)*bj_DEGTORAD call MoveLocation(l, x, y) set z = GetLocationZ(l) call MoveLocation(l, x + Cos(a), y + Sin(a)) set z = Atan2(GetLocationZ(l) - z, 1) call SetUnitMoveSpeed(u, (1-Sin(z*MovementSpeedModifier()))*GetUnitDefaultMoveSpeed(u)*2) endloop call RemoveLocation(l) set l = null endfunction private function MovementSpeedGrouper takes nothing returns nothing call GroupAddUnit(G, GetTriggerUnit()) endfunction private function MovementSpeedUngrouper takes nothing returns nothing call GroupRemoveUnit(G, GetTriggerUnit()) endfunction private function init takes nothing returns nothing local trigger t = CreateTrigger() local region r = CreateRegion() call GroupEnumUnitsInRect(G, bj_mapInitialPlayableArea, Filter(null)) call RegionAddRect(r, bj_mapInitialPlayableArea) call TriggerRegisterEnterRegion(t, r, Filter(null)) call TriggerAddAction(t, function MovementSpeedGrouper) set t = CreateTrigger() call TriggerRegisterLeaveRegion(t, r, Filter(null)) call TriggerAddAction(t, function MovementSpeedUngrouper) call TimerStart(CreateTimer(), MovementSpeedUpdateInterval(), true, function MovementSpeedAdjuster) set r = null set t = null endfunction endlibrary //=========================================================================== function InitTrig_MovementSpeed takes nothing returns nothing endfunction