LONG GUI triggers made more effectively?

Tooblet

Active Member
Reaction score
6
Hey, a beginner jasser here wondering about something.
So I've started to make really really simple spells just to get the hang of functions and the really basic things.

But one of the reasons i thought I'd learn jass was because I allways seem to get these MASSIVE triggers in GUI.

I mean the kind of trigger where I have regions all over the map and want to spawn creeps all over the place in different locations.
I mean, that's a really simple thing, but takes a DAY of copying and editing the triggers so it works properly for every creeptype and whatnot.
Or another example, restricting items by level and class. I have to make a trigger for EVERY single item (well over 200). or atleast do huge triggers for em.

The question on my mind is that v/Jass allways seemed to make everything super efficient and short, yet does the whole work.
Don't get me wrong, if I need something done, I'll do it no matter how much time it takes.
But I was just wondering if I was really stupid and did vast amounts of unnecessary copying and pasting and things in GUI witch would go in a jiff in Jass?

sorry for the wall of text, I have a hard time getting to the point...

EDIT: And also, I wouldn't mind a few tips and tricks on how to make those easy but massive triggers simpler :)
Just how the usual way people go about doing that is.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
GUI is inefficient. Jass provides more eye-moisture and faster. Long GUI will make your eye ball fall out.
 

Hellohihi

New Member
Reaction score
42
GUI is horrible.

I was a gui mapmaker for the past 3 years.
I dare say i was a advance gui mapmaker.

However, i switched to vjass 1 week ago.
I found vjass to be so efficient! Totally owns gui upside down.
When i converted my previous gui triggers to unoptimized jass triggers, they almost made me blind, its horrible long and inefficient.

I'll show you an example of my gui trigger before it was converted to vjass.

Gui trigger converted into custom text jass by the worldeditor:
JASS:
function Trig_reduce_spector_hp_Copy_Func002Func001C takes nothing returns boolean
    if ( not ( GetUnitLifePercent(GetEnumUnit()) <= 11.00 ) ) then
        return false
    endif
    if ( not ( GetUnitUserData(GetEnumUnit()) != 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_reduce_spector_hp_Copy_Func002Func002C takes nothing returns boolean
    if ( not ( GetUnitLifePercent(GetEnumUnit()) > 10.00 ) ) then
        return false
    endif
    if ( not ( GetUnitUserData(GetEnumUnit()) != 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_reduce_spector_hp_Copy_Func002Func003C takes nothing returns boolean
    if ( not ( GetUnitUserData(GetEnumUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_reduce_spector_hp_Copy_Func002A takes nothing returns nothing
    if ( Trig_reduce_spector_hp_Copy_Func002Func001C() ) then
        call RemoveUnit( GetEnumUnit() )
    else
        call DoNothing(  )
    endif
    if ( Trig_reduce_spector_hp_Copy_Func002Func002C() ) then
        call SetUnitLifePercentBJ( GetEnumUnit(), ( GetUnitLifePercent(GetEnumUnit()) - 15.00 ) )
        call SetUnitVertexColorBJ( GetEnumUnit(), 20.00, 20.00, 20.00, ( 100.00 - GetUnitLifePercent(GetEnumUnit()) ) )
    else
        call DoNothing(  )
    endif
    if ( Trig_reduce_spector_hp_Copy_Func002Func003C() ) then
        call RemoveUnit( GetEnumUnit() )
    else
        call DoNothing(  )
    endif
endfunction

function Trig_reduce_spector_hp_Copy_Actions takes nothing returns nothing
    set udg_Temp_Group = GetUnitsOfTypeIdAll('n003')
    call ForGroupBJ( udg_Temp_Group, function Trig_reduce_spector_hp_Copy_Func002A )
    call DestroyGroup( udg_Temp_Group)
endfunction

//===========================================================================
function InitTrig_reduce_spector_hp_Copy takes nothing returns nothing
    set gg_trg_reduce_spector_hp_Copy = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_reduce_spector_hp_Copy, 0.50 )
    call TriggerAddAction( gg_trg_reduce_spector_hp_Copy, function Trig_reduce_spector_hp_Copy_Actions )
endfunction


After i rewritten it in vjass:
JASS:
scope hp initializer Init
private function Actions takes nothing returns nothing
    local group g = GetUnitsOfTypeIdAll('n003')
    local unit u
       loop
            set u = FirstOfGroup(g)
            exitwhen(u == null)
            call GroupRemoveUnit(g, u)
            if GetUnitLifePercent( u ) > 10.00 then
            call SetUnitLifePercentBJ( u, ( GetUnitLifePercent(u) - 15.00 ) )
            call SetUnitVertexColorBJ( u, 20.00, 20.00, 20.00, ( 100.00 - GetUnitLifePercent(u) ) )
            endif
            if GetUnitLifePercent(u) <= 11.00 then
            call RemoveUnit( u )
            endif
        endloop
    call DestroyGroup(g)
    set u = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
    local trigger hp = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( hp, 0.50 )
    call TriggerAddAction( hp, function Actions )
    set hp = null
endfunction
endscope
 

GooS

Azrael
Reaction score
154
@Hellohihi

Your vJASS trigger still lacks alot, the GetUnitLifePercentBJ calls another bj that calls the native, the SetunitVertexColorBJ calls a BJ and then every argument passed through calls 2 other BJs to go from percent to 255, and later 255 to Int.

GetUnitLifePercent can easily be done with GetUnitState(u,UNIT_STATE_LIFE) / GetunitState(u,UNIT_STATE_MAX_LIFE), multiplied by 100 if you don't want it in decimals.

And your group there, ever expanded on it?

JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
    local group   result = CreateGroup()
    local group   g      = CreateGroup()
    local integer index

    set index = 0
    loop
        set bj_groupEnumTypeId = unitid
        call GroupClear(g)
        call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
        call GroupAddGroup(g, result)

        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)

    return result
endfunction


JASS:
function GroupAddGroup takes group sourceGroup, group destGroup returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupAddGroupDest = destGroup
    call ForGroup(sourceGroup, function GroupAddGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(sourceGroup)
    endif
endfunction


JASS:


Needless to say what I think of it :)
Also, very unecessary scope since it is the only thing making it vJASS

Anyways, more on point massive triggers will be shortened, more often than not, but whats better is that they work more efficiently with natives, avoiding unecessary function calls (BJs). But with JASS also comes the possibility of greater things, once again expanding the trigger, making it roughly as long as the GUI one. With removal of BJ's comes longer code aswell, which hellohihi seems to have ignored to make the trigger look small, but still smacked full of unecessary calls.

//==GooS
 

WolfieeifloW

WEHZ Helper
Reaction score
372
If you don't care about decimals;
GetWidgetLife() and SetWidgetLife() are the best options for HP ;) .
 

Viikuna

No Marlo no game.
Reaction score
265
The bigger your stuff gets, the better vJass works for you.

All these structs and interfaces and textmacros and other cool vJass features are here to prevent you from coding same things over and over again.

With GUI you cant even make your own functions, which means that every time you want to for example add some buff to some unit, you must 1) Create a dummy 2) Add an ability 3) Give the order 4) And get rid of that dummy. With Jass, you can just call UnitBuffUnit( caster, BuffType, target ) or something like that. ( Just make some system to do all the dirty job )



For restricting Items, you can always use Table to set&get itemtype related data. That should make it faster to code.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
UnitBuffUnit :p ?
I don't think there's anything like that.
I'm pretty sure you still have to get a dummy to cast the (de)buff on units.
 

Hellohihi

New Member
Reaction score
42
@Hellohihi
With removal of BJ's comes longer code aswell, which hellohihi seems to have ignored to make the trigger look small, but still smacked full of unecessary calls.

I was not ignoring the bjs. I was only about 3 days into jass, and I was unaware of how to use natives.

But until recently, thanks to tyrande max3 he thought me how to use natives instead.

And thank you, but no, it does not need to expand on the grouping.

On topic:
Another great point about jass, i don't have to use the annoying variable editor anymore. :D
 

Viikuna

No Marlo no game.
Reaction score
265
UnitBuffUnit ?
I don't think there's anything like that.
I'm pretty sure you still have to get a dummy to cast the (de)buff on units.

Yea. My point was that you can make some custom function to do all the dirty job, which makes you spell code shorter.

UnitBuffUnit was just an example. It could also be KnockbackUnit() or projectile.create() or something like that.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Ahh, it's it's own function;
Sorry, misread :eek: .

That is a very useful thing in JASS for sure (Functions that is) .

Librarys are another useful thing (Basically, functions that can be used in any trigger) .
 

Tooblet

Active Member
Reaction score
6
Yeah I'm definetly convinced that jass is alot better in alot of ways.
But what I was looking for was what Viikuna said.
I can make small systems to do all the "dirty work" for me, and shorten codes
on just about anything, just calling my own made little functions.

So there won't be any hour long sittings of just copying simple GUI triggers and change like ONE thing in each.

I guess I'll need a whole lot of practise and experience until I get to that stage but I'm sure it will be worth it.
Especially when Sc2 comes out soon, so I won't have to go through the "newb stage" when I'm pumped about makin maps in that editor :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top