• πŸ† 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!

Fast Question about GUI Vs JASS

Status
Not open for further replies.
Level 19
Joined
Aug 16, 2007
Messages
881
Hello there. I've just got one simple and fast question.

I've got alot of GUI (MUI) spells in a map I'm creating and I wonder if I convert those GUI spell into JASS (not vJASS), will they run better and faster then? Because. What I know, my GUI triggers are automatically converted into JASS when the map runs, right? So, will this make any difference?

Thanks :)
 
Level 19
Joined
Aug 16, 2007
Messages
881
Right.

Generally, Jass is more preferable, it is considered "smoother" and faster. If your abilities have low amount of actions though and/or they are (really) simple, you don't need to get the same versions in Jass.

Some of my GUI abilities are really heavy. But it won't change anything in performance if I remake it into a JASS spell then? It will only make it easier for me to read the ability trigger?

Nope, there won't be a difference. It auto-converts so yeah. (Unless you optimize your code) However, you can use Vexorian's map optimizer for speed/reduced size/map protection.

EDIT: Pharaoh beat me by literally a second. =P

Yeah, I'll use that program when the map is ready :)
 
Well, I doubt for example the fact that knockbacks in Jass are better than GUI, I have seen no difference to be completely honest. I usually make heavy spells myself, but I know they should be done in Jass instead and I'm not speaking only of performance, I'm also speaking of number of triggers. I have one spell that uses 8 triggers; that spell in Jass could be made in one (maximum two).
 
Level 19
Joined
Aug 16, 2007
Messages
881
Okey, then I get it. The maximum number of triggers of a spell I've got is... Hmm... Three I think, but the thing is I've got about 60 triggered abilities and almost everyone got atleast two triggers (for making them MUI). All those triggers isn't a problem for me, so I'll leave it as it is. Well it's recommended to use JASS spells, I think they are alot easier to read, the problem is I'm not the best JASSer, but I won't put that much time into it.

So thanks to both of you, +rep!
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,468
There is a limit in how much you can do in one instance in the game before noticing a framerate drop. Frankly, if you are not at risk of reaching that limit, there isn't anything to gain from optimizing your code *. The most important aspect of optimizing the code is that it has the potential to double (if not triple or even greater) the amount of physical code you can write before hitting that limit.

* While it not only doubles the efficiency by directly coding/optimizing in JASS, you also have far greater options this way. You can't, for example, clear most memory leaks, ie. DestroyGroup without directly editing the JASS code.

- At the bottom of this post, I've included an extremely optimized code (that I developed for TACOBELL) that evaluates the height of 30 coordinates around each unit on the map to find which one is the lowest. Then, it evaluates to see if the slope is greater than 60 degrees.

- If so, then the unit gets displaced to that other coordinate and a special effect will be added every 30 times this happens. Why 30? Because the code runs 100 times per second per unit and the special effects really pile up and make the computer lag an insane amount otherwise.

- It works without lag for up to 23 units. It really has a bad lag at 40 units.

- If this same code was done in GUI, if it even could be done (it cannot, but let's say Blizzard added some features to the GUI so that you could), there would be a catastrophic loss of efficiency and I bet you couldn't do more than 0-5 units with it before noticing a lag.

- The code:

JASS:
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
scope Locator initializer Init
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    globals
        private constant trigger The_Trigger = CreateTrigger()
        private constant group The_Group = CreateGroup()
        private constant real SR3 = SquareRoot(3.)
        private constant location loc = Location(0.,0.)
        private constant hashtable Hash = InitHashtable()
        private real array cos
        private real array sin
        private real z
        private integer id
        private integer it
    endglobals
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Found takes unit u,integer i,real SrcX,real SrcY,real SrcZ returns boolean
        local real To_X = SrcX + cos[i]
        local real To_Y = SrcY + sin[i]
        local real To_Z = GetLocationZ(loc)
        loop
            exitwhen (i == 0)
            set i = i - 1
            call MoveLocation(loc,SrcX + cos[i],SrcY + sin[i])
            if (GetLocationZ(loc) < To_Z) then
                set To_X = SrcX + cos[i]
                set To_Y = SrcY + sin[i]
                set To_Z = GetLocationZ(loc)
            endif
        endloop
        if (SrcZ - To_Z >= SR3) then
            set id = GetHandleId(u)
            set it = LoadInteger(Hash,id,0)
            if it < 1 then
                call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",SrcX,SrcY))
                call SaveInteger(Hash,id,0,30)
            else
                call SaveInteger(Hash,id,0,it-1)
            endif
            call SetUnitX(u,To_X)
            call SetUnitY(u,To_Y)
        endif
        return true
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function DoEval takes unit u returns nothing
        local integer i = 29
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        call MoveLocation(loc,x,y)
        set z = GetLocationZ(loc)
        loop
            call MoveLocation(loc,x + cos[i],y + sin[i])
            if (GetLocationZ(loc) < z) then
                exitwhen (Found(u,i,x,y,z))
            endif
            exitwhen (i == 0)
            set i = i - 1
        endloop
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Pick takes nothing returns nothing
        call DoEval(GetEnumUnit())
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Slide takes nothing returns nothing
        call ForGroup(The_Group,function Pick)
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Toggle takes nothing returns nothing
        if (IsTriggerEnabled(The_Trigger)) then 
            call DisableTrigger(The_Trigger)
        else
            call EnableTrigger(The_Trigger)
        endif
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Add takes nothing returns nothing
        call GroupAddUnit(The_Group,CreateUnit(GetTriggerPlayer(),'hpea',0.,0.,0.))
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function DoRemove takes unit u returns nothing
        if (u == null) then
            set u = GroupPickRandomUnit(The_Group)
        endif
        call GroupRemoveUnit(The_Group,u)
        call RemoveSavedInteger(Hash,GetHandleId(u),0)
        call RemoveUnit(u)
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Remove takes nothing returns nothing
        call DoRemove(GetTriggerUnit())
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
    private function Init takes nothing returns nothing
        local integer i = 11
        local trigger ToggleTrig = CreateTrigger()
        local trigger NoDeadTrig = CreateTrigger()
        local trigger RemoveTrig = CreateTrigger()
        local trigger AddTrig = CreateTrigger()
        call TriggerAddAction(ToggleTrig,function Toggle)
        call TriggerAddAction(NoDeadTrig,function Remove)
        call TriggerAddAction(RemoveTrig,function Remove)
        call TriggerAddAction(AddTrig,function Add)
        loop
            call TriggerRegisterPlayerEvent(ToggleTrig,Player(i),EVENT_PLAYER_END_CINEMATIC)
            call TriggerRegisterPlayerUnitEvent(NoDeadTrig,Player(i),EVENT_PLAYER_UNIT_DEATH,null)
            call TriggerRegisterPlayerChatEvent(RemoveTrig,Player(i),"remove",true)
            call TriggerRegisterPlayerChatEvent(AddTrig,Player(i),"add",true)
            exitwhen (i == 0)
            set i = i - 1
        endloop
        loop
            set cos[i] = 1.*Cos(12*(i+1)*bj_DEGTORAD)
            set sin[i] = 1.*Sin(12*(i+1)*bj_DEGTORAD)
            set i = i + 1
            exitwhen (i > 29)
        endloop
        call TriggerAddAction(The_Trigger,function Slide)
        call TriggerRegisterTimerEvent(The_Trigger,0.01,true)
        call GroupEnumUnitsInRect(The_Group,bj_mapInitialPlayableArea,null)
    endfunction
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
endscope
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
 
Status
Not open for further replies.
Top