wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-04-2011, 02:51 PM   #1
The Dark One
User
 
The Dark One's Avatar
 
Join Date: Jul 2008
Posts: 180

The Dark One will become famous soon enough (25)

Default To MUI or not MUI?

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)?

Collapse 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
__________________
Darkness Arise
Come and join the cause.
The Dark One is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-04-2011, 03:16 PM   #2
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

If this trigger is copied 1:1 from your map, then there might be issues with data and Data
__________________

Thanks to Neonex for the idea.
Idontneedaname is offline   Reply With Quote
Old 02-04-2011, 04:35 PM   #3
The Dark One
User
 
The Dark One's Avatar
 
Join Date: Jul 2008
Posts: 180

The Dark One will become famous soon enough (25)

Default

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.
__________________
Darkness Arise
Come and join the cause.
The Dark One is offline   Reply With Quote
Old 02-04-2011, 04:39 PM   #4
Michael Peppers
Lepus?
 
Michael Peppers's Avatar
 
Join Date: Jan 2009
Posts: 1,308

Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)

Default

Quote:
Originally Posted by Idontneedaname
If this trigger is copied 1:1 from your map, then there might be issues with data and Data
Nah, JASS is case-sensitive AFAIK.

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.
__________________
Projects:Tutorials: Competitive AI Step by Step with AI Editor (Pending)
Resources: [AI Script] Michael Peppers's Melee AI template (Pending)

Last edited by Michael Peppers : 02-04-2011 at 09:23 PM.
Michael Peppers is offline   Reply With Quote
Old 02-04-2011, 05:46 PM   #5
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Collapse The highlighted line is missing:
        ...
        set N = N+1
        set Data[N]=data.create()
        set Data[N].u = u
        ...
__________________

Last edited by Anitarf : 02-04-2011 at 05:48 PM.
Anitarf is offline   Reply With Quote
Old 02-04-2011, 08:42 PM   #6
The Dark One
User
 
The Dark One's Avatar
 
Join Date: Jul 2008
Posts: 180

The Dark One will become famous soon enough (25)

Default

There are those who know, and there are those who know best.

Thank you Anitarf.
And thanks to everyone else who tried to help.
__________________
Darkness Arise
Come and join the cause.
The Dark One is offline   Reply With Quote
Old 02-04-2011, 09:29 PM   #7
Michael Peppers
Lepus?
 
Michael Peppers's Avatar
 
Join Date: Jan 2009
Posts: 1,308

Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)Michael Peppers is a jewel in the rough (188)

Default

Actually, reading the code well, I realize what I said is bs. Anitarf's right.
__________________
Projects:Tutorials: Competitive AI Step by Step with AI Editor (Pending)
Resources: [AI Script] Michael Peppers's Melee AI template (Pending)
Michael Peppers is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 02:07 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services