| 02-04-2011, 02:51 PM | #1 |
I have read this code more than 10 times and I still can't figure why it isn't an MUI system. can anyone help make this MUI (or at least give me a hint on how to do it)? JASS:library JumpSystem private struct data unit u = null real s = 0 real ss = 0 real height = 0 real a = 0 real dist = 0 real angle = 0 real b = 0 endstruct globals private constant real RefreshRate = 0.035 private timer T = CreateTimer() private data array Data private integer N = 0 endglobals private function Update takes nothing returns nothing local integer i = 0 loop set i = i+1 exitwhen i > N call SetUnitX( Data[i].u, GetUnitX(Data[i].u) + Data[i].dist * Cos(Data[i].angle)) call SetUnitY( Data[i].u, GetUnitY(Data[i].u) + Data[i].dist * Sin(Data[i].angle)) call SetUnitFlyHeight( Data[i].u, Data[i].a*Data[i].s*Data[i].s+Data[i].height, 1000000 ) if (Data[i].s <= 1) then set Data[i].b = 1. endif if (Data[i].b==0.) then set Data[i].s = (Data[i].s) - 1 else set Data[i].s = (Data[i].s) + 1 endif if ( Data[i].s > Data[i].ss) then call SetUnitFlyHeight(Data[i].u, GetUnitDefaultFlyHeight(Data[i].u), 500) call DestroyEffect( AddSpecialEffectTarget("Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl", (Data[i].u), "origin") ) set Data[i] = Data[N] call Data[N].destroy() set N = N - 1 set i=i-1 endif endloop if N == 0 then call PauseTimer(T) endif endfunction function JumpUnit takes unit u, location target, real height, real duration returns nothing local real dx local real dy local real s if duration == 0 then call SetUnitPositionLoc(u, target) else set dx = GetLocationX(target) if dx > GetRectMaxX(bj_mapInitialPlayableArea) - 50 then set dx = GetRectMaxX(bj_mapInitialPlayableArea) - 50 elseif dx < GetRectMinX(bj_mapInitialPlayableArea) + 50 then set dx = GetRectMinX(bj_mapInitialPlayableArea) + 50 endif set dx = dx - GetUnitX(u) set dy = GetLocationY(target) if dy > GetRectMaxY(bj_mapInitialPlayableArea) - 50 then set dy = GetRectMaxY(bj_mapInitialPlayableArea) - 50 elseif dy < GetRectMinY(bj_mapInitialPlayableArea) + 50 then set dy = GetRectMinY(bj_mapInitialPlayableArea) + 50 endif set dy = dy - GetUnitY(u) set s = (duration/RefreshRate)/2 call UnitAddAbility( u, 'Amrf' ) call UnitRemoveAbility( u, 'Amrf' ) if N == 0 then call TimerStart(T,RefreshRate, true, function Update) endif set N = N+1 set Data[N].u = u set Data[N].b = 0 set Data[N].s = s set Data[N].ss = s set Data[N].height = height set Data[N].a = -height/(s*s) set Data[N].dist = SquareRoot(dx * dx + dy * dy)/s/2 set Data[N].angle = Atan2(dy,dx) endif endfunction endlibrary |
| 02-04-2011, 03:16 PM | #2 |
If this trigger is copied 1:1 from your map, then there might be issues with data and Data |
| 02-04-2011, 04:35 PM | #3 |
Could you elaborate? I took it from this thread http://www.wc3c.net/showthread.php?t=81446 I tested it in my map and it works well but not MUI. |
| 02-04-2011, 04:39 PM | #4 | |
Quote:
Those private global data, integer and timer aren't MUI-friendly at all. Use a local struct to store all of the values and pass it with a local timer (TimerUtils), then on the other trigger go with GetExpiredTimer() and you're good. |
| 02-04-2011, 05:46 PM | #5 |
The highlighted line is missing:... set N = N+1 set Data[N]=data.create() set Data[N].u = u ... |
| 02-04-2011, 08:42 PM | #6 |
There are those who know, and there are those who know best. Thank you Anitarf. And thanks to everyone else who tried to help. |
| 02-04-2011, 09:29 PM | #7 |
Actually, reading the code well, I realize what I said is bs. Anitarf's right. |
