Warcraft III resources & community, 2003–2006 · archived

Jass trigger multiply functions

11 posts
#1

Jass trigger multiply functions

Hi guys,

I was just wondering if it is possible to make multiply functions with Jass triggers? If so what would be the coding text needed to type in? I can post the actually current Jass code i wish to multiply function if needed.
#2
What do you mean with multipla functions?
#3
Ok this is my problem

im currently working on a Starcraft Conversion map and im making heaps of progress with adding new models and skins, but i still want to see if i can get more space out of the map through removal of triggers.
I got pretty good at reducing the amount of GUI triggers in my maps by putting multiple triggers into one big trigger. But i have 2 sets of 32 Jass Triggers that i hope could be reduced down to 2 big triggers, to gain more space for more models. I have tried to convert the Jass form triggers into GUI but the GUI command functions just couldnt specify a single action it seems.
So i just wanted to know if there was a particular Jass code that i could use to make multiple functions with these triggers.
#4
You can have as much JASS functions you want in a single global trigger.
#5
OK so they wouldnt make to much memory leakage? here is the actually Jass trigger


//===========================================================================
// Trigger: Mine1 Built
//===========================================================================
function Trig_Mine1_Built_Func007C takes nothing returns boolean
    if ( ( GetUnitTypeId(GetEnteringUnit()) == 'n003' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetEnteringUnit()) == 'n002' ) ) then
        return true
    endif
    if ( ( GetUnitTypeId(GetEnteringUnit()) == 'n004' ) ) then
        return true
    endif
    return false
endfunction

function Trig_Mine1_Built_Conditions takes nothing returns boolean
    if ( not Trig_Mine1_Built_Func007C() ) then
        return false
    endif
    return true
endfunction

function Trig_Mine1_Built_Actions takes nothing returns nothing
    set udg_Vespin[1] = GetEnteringUnit()
    call EnableTrigger( gg_trg_Vespin1_Updating )
    call SetResourceAmount( udg_Vespin[1], udg_VespinInteger[1] )
    call DestroyTextTagBJ( udg_FloatyGeneralText[1] )
    call DestroyTextTagBJ( udg_FloatyVespinMenge[1] )
    call SetDoodadAnimationRectBJ( "hide", 'D000', gg_rct_Vespin1 )
endfunction

//===========================================================================
function InitTrig_Mine1_Built takes nothing returns nothing
    set gg_trg_Mine1_Built = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Mine1_Built, gg_rct_Vespin1 )
    call TriggerAddCondition( gg_trg_Mine1_Built, Condition( function Trig_Mine1_Built_Conditions ) )
    call TriggerAddAction( gg_trg_Mine1_Built, function Trig_Mine1_Built_Actions )
endfunction


And i have 32 regions on the map requiring 32 different triggers and then i have these set of 32 triggers


//===========================================================================
// Trigger: Mine1 Destroyed
//===========================================================================
function Trig_Mine1_Destroyed_Conditions takes nothing returns boolean
    if ( not ( GetDyingUnit() == udg_Vespin[1] ) ) then
        return false
    endif
    return true
endfunction

function Trig_Mine1_Destroyed_Actions takes nothing returns nothing
    call DisableTrigger( gg_trg_Vespin1_Updating )
    set udg_FloatyGeneralText[1] = GetLastCreatedTextTag()
    set udg_FloatyVespinMenge[1] = GetLastCreatedTextTag()
    call SetDoodadAnimationRectBJ( "show", 'D000', gg_rct_Vespin1 )
endfunction

//===========================================================================
function InitTrig_Mine1_Destroyed takes nothing returns nothing
    set gg_trg_Mine1_Destroyed = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Mine1_Destroyed, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Mine1_Destroyed, Condition( function Trig_Mine1_Destroyed_Conditions ) )
    call TriggerAddAction( gg_trg_Mine1_Destroyed, function Trig_Mine1_Destroyed_Actions )
endfunction
[/jass]
#6
You know memory leaks has nothing to do with how many times you use a function. Just be sure to clear the vaules and destroy unneeded objects.

And all this:

function Trig_Mine1_Built_Func007C takes nothing returns boolean
if ( ( GetUnitTypeId(GetEnteringUnit()) == 'n003' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetEnteringUnit()) == 'n002' ) ) then
return true
endif
if ( ( GetUnitTypeId(GetEnteringUnit()) == 'n004' ) ) then
return true
endif
return false
endfunction


You know that the function will return true if any pf those conditions are true. So you can put them all in one by adding "and" between the unit type comparision.
#7
Combining all your triggers into one WILL NOT reduce your map's size because they are already one BIG script file in the map.
Trigger coding take up vitualy NO space.
At most you could reduce a few KB here and there by rewriting the triggers to need as few lines of coding as possiable but the space saved is minimal.
If you want to reduce space use an opotmization program.
I have heard they reduce map size by up to 200 KB!
#8
Open your .w3x file with some mpq editor and see what's taking space and what's not. Your triggers are in .j file.
#9
Optimization:

This will do exactly the same like your trigger "Mine1 Built".
But you can see the difference in space, cannot you?

function Trig_Mine1_Built_Actions takes nothing returns nothing
  if GetUnitTypeId(GetEnteringUnit()) == 'n003' or GetUnitTypeId(GetEnteringUnit()) == 'n002' or GetUnitTypeId(GetEnteringUnit()) == 'n004' then
    set udg_Vespin[1] = GetEnteringUnit()
    call EnableTrigger(gg_trg_Vespin1_Updating)
    call SetResourceAmount(udg_Vespin[1], udg_VespinInteger[1])
    call DestroyTextTagBJ(udg_FloatyGeneralText[1])
    call DestroyTextTagBJ(udg_FloatyVespinMenge[1])
    call SetDoodadAnimationRectBJ("hide",'D000',gg_rct_Vespin1)
  endif
endfunction

function InitTrig_Mine1_Built takes nothing returns nothing 
  set gg_trg_Mine1_Built = CreateTrigger() 
  call TriggerRegisterEnterRectSimple(gg_trg_Mine1_Built,gg_rct_Vespin1) 
  call TriggerAddAction(gg_trg_Mine1_Built,function Trig_Mine1_Built_Actions)
endfunction


Eliminating blizzard code may speed up the execution a little but will take more space... Not much.
#10
Reviving an old topic. . .
Do you guies ever read the rules?
This was posted in January.
Thats half a year ago!
#11
I read the rules but I read the date of the last post too: Sat Aug 05, 2006 6:17 am
And I thought, that the other person would have done the same before...
There is nobody one can trust in these days. ^^