HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

MUI in GUI

08-20-2006, 07:22 AM#1
darkwulfv
Ok, I'm back with MUI in GUI (catchy isn't it?) but now I have a challenge. I keep hearing different things about GUI. Alot say it isn't MUI, alot say it is becuase there aren't waits, some say it is becuase you used custom script and locals. So here's my challenge.

What are the ways a GUI spell is can be MUI? (other than using custom script to make locals and null them.)

From what I've heard, using globals w/o waits and setting the variables inside the trigger corresponding to the spell is MUI. True or False? Thanks to anyone and everyone who helps, this is to better my understanding of MUI, and to anyone else who may be wondering.
08-20-2006, 07:28 AM#2
Captain Griffen
Pretty much without no waits it is easy to make MUI, with waits it is almost impossible.
08-20-2006, 07:31 AM#3
PipeDream
Not really.
lifted from http://www.wc3campaigns.net/showthread.php?t=81872
Use arrays that union over all the objects you might need.
Collapse JASS:
//===================================================
//    Temp Memory hack
//  Paste this code into the custom script section
//  Variables needed:
//  integer array udg_Stack_Nodes
//  integer udg_Stack_Heap
//  integer udg_Stack_Top with initial value -1
//  whatever object such as location array udg_tempPoint
//========================================================

function AllocateTemp takes nothing returns integer
    local integer p = udg_Stack_Heap
    set udg_Stack_Heap = udg_Stack_Heap + 1
    if(p > 8191) then
        call BJDebugMsg("Too many active GUI triggers!  Use game cache for a heap")
    endif
    return p
endfunction

function GetTempSpace takes nothing returns integer
    local integer p
    if(udg_Stack_Top == -1) then //Check if stack is empty
        set p = AllocateTemp() //Grab a new cell for our collection
    else //Do a regular stack pop
        set p = udg_Stack_Top
        set udg_Stack_Top = udg_Stack_Nodes[udg_Stack_Top] 
    endif
    return p
endfunction

//Regular stack push
function ReleaseTempSpace takes integer p returns nothing
    set udg_Stack_Nodes[p] = udg_Stack_Top
    set udg_Stack_Top = p
endfunction
Example GUI use:
Trigger:
sometrig
Collapse Events
Player - Player 1 (Red) types a chat message containing p as An exact match
Conditions
Collapse Actions
Custom script: local integer udg_mem = GetTempSpace()
Set tempPoint[mem] = (Target of current camera view)
Wait 5.00 seconds
Cinematic - Ping minimap for (All players) at tempPoint[mem] for 1.00 seconds
Custom script: call RemoveLocation(udg_tempPoint[udg_mem])
Custom script: call ReleaseTempSpace(udg_mem)
Or in JASS:
Collapse JASS:
function PingCamera takes nothing returns nothing
    local integer mem = GetTempSpace()
    set udg_tempPoint[mem] = GetCameraTargetPositionLoc()
    call TriggerSleepAction(5.)
    call PingMinimap(GetLocationX(udg_tempPoint[mem]),GetLocationY(udg_tempPoint[mem]),5.)
    call RemoveLocation(udg_tempPoint(mem))
    call ReleaseTempSpace(mem)
endfunction
Downside: You can only have 8192 simultaneous instances before things fail. This is plenty for GUI, so long as you remember to ReleaseTempSpace(). Upgrade the stack to location based and the limit goes away.