• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] UI Abilities Help and Suggestions?

Status
Not open for further replies.
Level 20
Joined
Jul 12, 2010
Messages
1,717
Hi everybody, I have been experimenting with the UI Natives and I was thinking that's it's really possible to create a lot of custom spells using only triggers.

Of course this is all thanks to @Tasyen and his awesome UI Tutorials

JASS:
function clickedability01 takes nothing returns nothing

//I use udg_Player_Hero cause that's the main variable I use for all my systems in my RPG map
//And I only need this to be MPI so it doesn't really matter

    local integer pid = GetConvertedPlayerId(GetTriggerPlayer())
    local unit u = (udg_Player_Hero[pid])
    local location p1 = GetUnitLoc(u)
    local location p2 = PolarProjectionBJ(p1, 500.00, GetUnitFacing(u))
    local location p3 = PolarProjectionBJ(p1, 1000.00, GetUnitFacing(u)) //this is to keep the unit moving forward, not really needed

    call SetUnitPositionLoc( u, p2 )
    call AddSpecialEffectLocBJ( p2, "Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl" )
    call DestroyEffectBJ( GetLastCreatedEffectBJ() )

    call IssuePointOrderLocBJ( u, "move", p3 ) //this is to keep the unit moving forward, not really needed

    call RemoveLocation(p1)
    call RemoveLocation(p2)
    call RemoveLocation(p3)
    set u = null

    call DisplayTimedTextToForce( bj_FORCE_PLAYER[0], 2.00, "ability click" )
    call BlzFrameSetEnable(BlzGetTriggerFrame(), false) //disable the clicked button
    call BlzFrameSetEnable(BlzGetTriggerFrame(), true) //enable it again.

endfunction

//===========================================================================

function Holy_Blink takes nothing returns nothing

    local trigger trig = CreateTrigger()
    local framehandle abilityicon = BlzCreateFrameByType("BACKDROP", "AbilityIcon", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
    local framehandle abilitybutton = BlzCreateFrameByType("GLUEBUTTON" , "AbilityClick" , abilityicon, "ScoreScreenTabButtonTemplate", 0)
    local framehandle hover = BlzCreateFrameByType("FRAME", "FaceFrame", abilityicon,"", 0)
    local framehandle tooltip = BlzCreateFrameByType("TEXT", "FaceFrameTooltip", hover,"", 0)

    call BlzFrameSetSize(abilityicon, 0.04, 0.04)

    call BlzFrameSetAbsPoint(abilityicon, FRAMEPOINT_CENTER, 0.235, 0.158)

    call BlzFrameSetTooltip(abilitybutton, tooltip)
      call BlzFrameSetText(tooltip, "      Holy Blink (Q)|n|nBlinks the hero forward")
    call BlzFrameSetPoint(tooltip, FRAMEPOINT_BOTTOM, abilityicon, FRAMEPOINT_TOP, 0.0, 0.01)


    call BlzFrameSetAllPoints(abilitybutton, abilityicon)


    call BlzFrameSetTexture(abilityicon, "ReplaceableTextures\\CommandButtons\\BTNHolyBolt",0, true)

    call BlzTriggerRegisterFrameEvent(trig, abilitybutton , FRAMEEVENT_CONTROL_CLICK)
    call BlzTriggerRegisterPlayerKeyEvent(trig, Player(0), OSKEY_Q, 0, true)
    call TriggerAddAction(trig, function clickedability01 )

endfunction


//===========================================================================
function InitTrig_Holy_Blink takes nothing returns nothing
    set gg_trg_Holy_Blink = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Holy_Blink, 0.10 )
    call TriggerAddAction( gg_trg_Holy_Blink, function Holy_Blink )
endfunction
gif.gif
So this is pretty much a simple spell/ability I coded.

To do:
-Cooldown for spells (coming soon)

What I need help with:
Pretty much a jass beginner so I basically convert gui to jass and modify it to my needs.

I saw some people saying BJs are bad so should:
PolarProjectionBJ, AddSpecialEffectLocBJ, DestroyEffectBJ, IssuePointOrderLocBJ not be used?
can they be replaced with something else?

Any other rookie mistakes I do in my coding? feedback is much appreciated.
 

Attachments

  • UI Abilities.w3x
    13.1 KB · Views: 35
Level 9
Joined
Jul 30, 2018
Messages
445
Not a master in JASS (though I have some experience on coding in gerenal) either, but what I have learned thus far, is that it's quite a lot more efficient to use X and Y coordinates in JASS instead of locations. And that's one of the main thing why BJs are bit bad: in many cases they simply turn X and Y into location, when you could just directly manipulate the X and Y. BJs are typically just GUI translations.

For example, this is what PolarProjectionBJ calls:
JASS:
function PolarProjectionBJ takes location source, real dist, real angle returns location
    local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
    local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
    return Location(x, y)
endfunction
So, you could just use those functions as is yourself.

Here's another example of a BJ:
JASS:
function DestroyEffectBJ takes effect whichEffect returns nothing
    call DestroyEffect(whichEffect)
endfunction
The BJ function does literally nothing extra, so you might just as well erase the BJ letters out of it and it would work exactly the same. And in the process you would lose one function off of your code. Making unnecessary functions like that is the core reason why GUI and BJs are bad and inefficient.
 
Level 20
Joined
Jul 12, 2010
Messages
1,717
@Sabe hmm ok I might try that one out, currently I'm actually using HiveWE 0.6 which is pretty good
img2.jpg
img1.jpg
Of course this is only convenient because I have a dual screen setup and I use 1 screen for hivewe and the other screen for normal we( I'm a bit scared to use hivewe alone lol)

@BizzaroFukuro yeah that might be a good option but I was thinking something like this:
gif.gif

But that's just personal opinion, I like to view milliseconds in my cooldowns :p
 
Last edited:
Status
Not open for further replies.
Top