• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Converting GUI to Jass guide?

Status
Not open for further replies.
Level 5
Joined
Aug 15, 2007
Messages
145
Removing BJs guide?

Is there a tutorial on this? I am struggling on what exactly to replace with natives etc, with newgen. Is there a concise guide on how to do this? removing BJs etc.
 
Last edited:
Level 9
Joined
Nov 28, 2008
Messages
704
It really is a simple process. You can just open up the function editor and search for all the bjs you use, and see what code the bjs use, and replace it or efficientize. Control + clciking on a bj gives you it as well.

The simplest one is DisplayTextToForce -> DisplayTextToPlayer whenever you display text to all players.

JASS:
function DisplayTimedTextToForce takes force toForce, real duration, string message returns nothing
    if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, duration, message)
    endif
endfunction

Oh, hey, it just checks for get local player if they are in the force. Well, since every single person is in the force you give when you display text to all, you can efficientize it by just taking the one line:

JASS:
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, duration, message)
will display it to all players without checking two ifs.

The concept is really just too simple for a tutorial.

Other ideas:
Find if you use in something like cameras, ChangeCameraForPlayer or whatever. You'll notice it uses a LOT of getlocalplayer checks. You can do ONE getlocalplayer and put all of the local code contained in your triggers to be more efficient.

JASS:
    call PanCameraToTimedLocForPlayer( Player(0), GetRectCenter(GetPlayableMapRect()), 0 )
    call SetCameraFieldForPlayer( Player(0), CAMERA_FIELD_TARGET_DISTANCE, 1.00, 0 )

Can we use ONE get local player?

JASS:
function PanCameraToTimedLocForPlayer takes player whichPlayer, location loc, real duration returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
    endif
endfunction
JASS:
function SetCameraFieldForPlayer takes player whichPlayer, camerafield whichField, real value, real duration returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call SetCameraField(whichField, value, duration)
    endif
endfunction

So we can!

JASS:
    if GetLocalPlayer() == whichPlayer then
        call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
        call SetCameraField(whichField, value, duration)
    endif

Should be our final code. Yes, those fields and values and such will be replaced by stuff you put in, but you can see how we save an if check.
 
Status
Not open for further replies.
Top