• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Jass trigger multiply functions

Status
Not open for further replies.
Level 7
Joined
Jan 1, 2005
Messages
133
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.
 
Level 7
Joined
Jan 1, 2005
Messages
133
OK so they wouldnt make to much memory leakage? here is the actually Jass trigger

JASS:
//===========================================================================
// 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

JASS:
//===========================================================================
// 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
[/code]
 
Level 12
Joined
Apr 29, 2005
Messages
999
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:
JASS:
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.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
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!
 
Level 5
Joined
May 22, 2006
Messages
150
Optimization:

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

JASS:
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.
 
Level 5
Joined
May 22, 2006
Messages
150
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. ^^
 
Status
Not open for further replies.
Top