• 🏆 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] Question about jass/gui

Status
Not open for further replies.
Level 9
Joined
Aug 27, 2004
Messages
471
Ok, i have recently gotten into jass upon learning it could use functions that the conventional triggering method could not. (Trackable mapping ^,^)

But i have a few questions (Sorry if they've been awnsered):

In every blizzard game, blizzard at the very least destroys all variables instantly after use. But my question is, would nullifying the variable be more efficient?

Blizzard likes jass, thats not to unusual seeing as they programmed the language. But im wondering if jass triggers reduce lag (Does the trigger editor normal convert to Trigger > Jass > ASCII? or just Trigger > ASCII?).

Functions. Functions take XXX and return XXX. I have a two part question:
Do i need to generate a local for the "take XXX" part? Or are the locals generated by the call function?
And how do i find what was returned?

Additional functions:
The only function i know that is not possible with conventional triggers is trackable grid mapping. Are there any others?

Thanks for your time, Modeler.
 
Level 9
Joined
Aug 27, 2004
Messages
471
Well to prevent more needless threads, im going to post here, im getting an error "Expected endif in line 74"
(Jass code:)
JASS:
function Trig_CheckAlive takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

function Trig_Initialize_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Initialize_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('A000', GetSpellAbilityUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_VmpCond takes nothing returns boolean
    if ( not ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetSpellAbilityUnit())) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Vmp takes nothing returns nothing
if ( Trig_VmpCond() ) then
        call DoNothing(  )
    else
    call GroupRemoveUnitSimple( GetEnumUnit(), udg_Targs )
    endif
endfunction

function Trig_Initialize_Actions takes nothing returns nothing
    local unit Targ
    local unit ak
    local location Chainer
    set Targ = GetSpellTargetUnit()
    if ( Trig_Initialize_Func001C() ) then
        call CreateNUnitsAtLoc( 1, 'h003', GetOwningPlayer(GetSpellAbilityUnit()), GetUnitLoc(GetSpellAbilityUnit()), bj_UNIT_FACING )
        call SetUnitPathing( GetLastCreatedUnit(), false )
        call UnitApplyTimedLifeBJ( 0.30, 'BTLF', GetLastCreatedUnit() )
        set Chainer = GetUnitLoc(GetLastCreatedUnit())
        set ak = GetLastCreatedUnit()
        call IssueTargetOrderBJ(ak, "attack", Targ)
        set udg_Targs = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(GetSpellAbilityUnit()), Condition(function Trig_CheckAlive))
        call ForGroupBJ( udg_Targs, function Trig_Vmp )
        Unit CreatNUnitAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), Chainer)
    else
    endif
endfunction

//===========================================================================
function InitTrig_Initialize takes nothing returns nothing
    set gg_trg_Initialize = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Initialize, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Initialize, Condition( function Trig_Initialize_Conditions ) )
    call TriggerAddAction( gg_trg_Initialize, function Trig_Initialize_Actions )
endfunction

What is wrong, i have no idea...?[/code]
 
Level 3
Joined
Mar 27, 2004
Messages
70
In every blizzard game, blizzard at the very least destroys all variables instantly after use. But my question is, would nullifying the variable be more efficient?
I believe Blizzard are reference counting the handles, so that a handle's id is free for recycling once it is no longer referenced by any variables. But Blizzard did not decrease the reference counter when local handles are eliminiated at the end of a function.
If all of that went your over your head, just think of it as a bug that we are working around by settings locals to null.

But im wondering if jass triggers reduce lag
Converting your GUI trigger to custom text will NOT reduce lag, because GUI triggers are always converted to custom text internally and used by the game.
However, you CAN reduce lag enormously using Jass, but converting it to Jass alone is not enough.

Do i need to generate a local for the "take XXX" part? Or are the locals generated by the call function?
And how do i find what was returned?
The locals are generated automatically. If you declare a local with the same name as a parameter, the parameter gets hidden behind the local, so don't do that.
To fetch the return value of a function, just treat the function call as a value.
For example:
JASS:
local integer a = MyFunction(45)
// The return value of MyFunction is stored in a

The only function i know that is not possible with conventional triggers is trackable grid mapping. Are there any others?
Well, Jass has local variables, where GUI does not.
Jass can work with the GetLocalPlayer function, so for example: You can make special effects visible for only one player.
A World Editor "Region" is actually called "rect" in Jass. In Jass there is a variable type caleld "region" which are like rects, except they can cover any type of shape on the map. They are rarely used though.
In Jass we can use the "Handle Vars" - which are a result of the gamecache and the return bug combined.

I hope that helped you out.


Edit: In reply to your second post, try changing this line:
JASS:
 Unit CreatNUnitAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), Chainer)
// Try this instead:
 call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), Chainer)
 
Level 9
Joined
Aug 27, 2004
Messages
471
Oo tyvm!

And i had lots of problems with that last part, i must have been to tired to see >.>.

call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetSpellAbilityUnit()), Chainer, 90)

Had a missing field, miss-spelled "create" and "units". >.>

Well thank you for your time :).
 
Status
Not open for further replies.
Top