Can someone help me turn this into jass

SwedishChef

New Member
Reaction score
32
Okey so I have a map which I will release today. Thing is that the preload system took 28 seconds (a bit too long). Could some friendly soul turn it into good and effective jass for me? I have the gui trigger and the converted trigger so it will be easier for you to edit. Thanks! :)

Trigger:
  • Preload Items3
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • If (PreloadCount Equal to 0) then do (Game - Display to (All players) the text: |cffff0000Preloadin...) else do (Do nothing)
      • Set PreloadCount = (PreloadCount + 1)
      • Set MyLocation = (Center of (Playable map area))
      • Unit - Create 1 Paladin for Neutral Extra at MyLocation facing Default building facing degrees
      • Hero - Give (Random item in Item Region <gen> matching ((Item-class of (Matching item)) Equal to Permanent)) to (Last created unit)
      • Hero - Give (Random item in Item Region <gen> matching ((Item-class of (Matching item)) Equal to Permanent)) to (Last created unit)
      • Hero - Give (Random item in Item Region <gen> matching ((Item-class of (Matching item)) Equal to Permanent)) to (Last created unit)
      • Hero - Give (Random item in Item Region <gen> matching ((Item-class of (Matching item)) Equal to Charged)) to (Last created unit)
      • Unit - Remove (Last created unit) from the game
      • Custom script: call RemoveLocation(udg_MyLocation)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PreloadCount Equal to 27
        • Then - Actions
          • Trigger - Run Game Mode Create <gen> (checking conditions)
        • Else - Actions
          • Trigger - Run Preload Items3 <gen> (checking conditions)


JASS:
function Trig_Preload_Items3_Copy_Func001001 takes nothing returns boolean
    return ( udg_PreloadCount == 0 )
endfunction

function Trig_Preload_Items3_Copy_Func006001002 takes nothing returns boolean
    return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
endfunction

function Trig_Preload_Items3_Copy_Func007001002 takes nothing returns boolean
    return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
endfunction

function Trig_Preload_Items3_Copy_Func008001002 takes nothing returns boolean
    return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
endfunction

function Trig_Preload_Items3_Copy_Func009001002 takes nothing returns boolean
    return ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )
endfunction

function Trig_Preload_Items3_Copy_Func012C takes nothing returns boolean
    if ( not ( udg_PreloadCount == 27 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Preload_Items3_Copy_Actions takes nothing returns nothing
    if ( Trig_Preload_Items3_Copy_Func001001() ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_2781" )
    else
        call DoNothing(  )
    endif
    set udg_PreloadCount = ( udg_PreloadCount + 1 )
    set udg_MyLocation = GetRectCenter(GetPlayableMapRect())
    call CreateNUnitsAtLoc( 1, 'Hpal', Player(bj_PLAYER_NEUTRAL_EXTRA), udg_MyLocation, bj_UNIT_FACING )
    call UnitAddItemSwapped( RandomItemInRectBJ(gg_rct_Item_Region, Condition(function Trig_Preload_Items3_Copy_Func006001002)), GetLastCreatedUnit() )
    call UnitAddItemSwapped( RandomItemInRectBJ(gg_rct_Item_Region, Condition(function Trig_Preload_Items3_Copy_Func007001002)), GetLastCreatedUnit() )
    call UnitAddItemSwapped( RandomItemInRectBJ(gg_rct_Item_Region, Condition(function Trig_Preload_Items3_Copy_Func008001002)), GetLastCreatedUnit() )
    call UnitAddItemSwapped( RandomItemInRectBJ(gg_rct_Item_Region, Condition(function Trig_Preload_Items3_Copy_Func009001002)), GetLastCreatedUnit() )
    call RemoveUnit( GetLastCreatedUnit() )
    call RemoveLocation(udg_MyLocation)
    if ( Trig_Preload_Items3_Copy_Func012C() ) then
        call ConditionalTriggerExecute( gg_trg_Game_Mode_Create )
    else
        call ConditionalTriggerExecute( gg_trg_Preload_Items3 )
    endif
endfunction

//===========================================================================
function InitTrig_Preload_Items takes nothing returns nothing
    set gg_trg_Preload_Items = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Preload_Items, 0.01 )
    call TriggerAddAction( gg_trg_Preload_Items, function Trig_Preload_Items3_Copy_Actions )
endfunction
 

Tyman2007

Ya Rly >.
Reaction score
74
Well... The thing is, a trigger such as that would have no need to be converted into JASS. All it would do is look better. MAYBE run a few seconds faster.
 

SwedishChef

New Member
Reaction score
32
Yeah I need those seconds :p. Any other way to make preload faster? Run it on map init. was just as slow I think. Would it be faster if two triggers ran doing same thing, so I have half in both (probably wont since you can only run 1 trigger at a time).
 

Tyman2007

Ya Rly >.
Reaction score
74
hmm.. Well.. Here's the trigger I converted to JASS

JASS:
function Trig_Preload_Items3_Copy_Actions takes nothing returns nothing
    local unit u
    if ( udg_PreloadCount == 0 ) then
        call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_2781" )
    endif
    set udg_PreloadCount = ( udg_PreloadCount + 1 )
    set udg_MyLocation = GetRectCenter(GetPlayableMapRect())
    set u = CreateUnitAtLoc(Player(14), 'Hpal', udg_MyLocation, 270 )
    call UnitAddItem( u, RandomItemInRectBJ(gg_rct_Item_Region, (GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT)))
    call UnitAddItem( u, RandomItemInRectBJ(gg_rct_Item_Region, (GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT)))
    call UnitAddItem( u, RandomItemInRectBJ(gg_rct_Item_Region, (GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT)))
    call UnitAddItem( u, RandomItemInRectBJ(gg_rct_Item_Region, (GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED)))
    call RemoveUnit( u )
    call RemoveLocation(udg_MyLocation)
    if ( udg_PreloadCount == 27 ) then
        call ConditionalTriggerExecute( gg_trg_Game_Mode_Create )
    else
        call ConditionalTriggerExecute( gg_trg_Preload_Items3 )
    endif
    set u = null
endfunction

//===========================================================================
function InitTrig_Preload_Items takes nothing returns nothing
    set gg_trg_Preload_Items = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Preload_Items, 0.01 )
    call TriggerAddAction( gg_trg_Preload_Items, function Trig_Preload_Items3_Copy_Actions )
endfunction


I don't know if it works. If you get an error let me know.

the thing about map initialization is that the load time would be longer for the map, but in turn people would care more if the game started and is taking 30 more seconds..
 

SwedishChef

New Member
Reaction score
32
I don't know if that trigger is very effective. Like why ain't you using a loop function instead of running it again?

E: I get an error also Cannot convert boolean to boolexpr on these lines " call UnitAddItem(u , RandomItemInRectBJ(gg_rct_Item_Region , ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )))" + "call UnitAddItem(u , RandomItemInRectBJ(gg_rct_Item_Region , ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )))"
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, here's another version :D

JASS:
scope PreloadStuff initializer Init

    private function ItemsFilterOne takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterTwo takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterThree takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterFour takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )
    endfunction

    private function EnumItems takes nothing returns nothing
        local item i = GetEnumItem()
        set bj_itemRandomConsidered = bj_itemRandomConsidered + 1
        
        if GetRandomInt( 1, bj_itemRandomConsidered ) == 1 then
            set bj_itemRandomCurrentPick = i
        endif
        
        set i = null
    endfunction

    private function Actions takes nothing returns boolean
        local integer i = 0
        local player p = Player( bj_PLAYER_NEUTRAL_EXTRA )
        local real x = GetRectCenterX( bj_mapInitialPlayableArea )
        local real y = GetRectCenterY( bj_mapInitialPlayableArea )
        local unit u = CreateUnit( p, 'Hpal', x, y, bj_UNIT_FACING )
        local trigger t = GetTriggeringTrigger()
        
        set bj_itemRandomConsidered = 1
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 1
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 1
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 1
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )

        if udg_PreloadCount == 0 then
            
            loop
                exitwhen i >= 12
                
                set p = Player( i )
                
                call DisplayTextToPlayer( p, 0., 0., &quot;Meddelandet här, tack ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />&quot; ) // Write your message here, please ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
                
                set i = i + 1
            endloop
            
        endif
        
        call RemoveUnit( u )
        
        if udg_PreloadCount &gt;= 27 then
            
            if TriggerEvaluate( gg_trg_Game_Mode_Create ) then
                call TriggerExecute( gg_trg_Game_Mode_Create )
            endif
            
        else
            call TriggerExecute( t )
        endif
        
        set u = null
        set p = null
        
        return false
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddCondition( gg_trg_Preload_Items, Condition( function Actions ) )
    endfunction

endscope


Should be quite a bit faster ;)
 

SwedishChef

New Member
Reaction score
32
Didn't work. Seems like either the hero wasn't created or he wasn't given the items since there was no lag.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Try this:
JASS:
scope PreloadStuff initializer Init

    private function ItemsFilterOne takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterTwo takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterThree takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterFour takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )
    endfunction

    private function EnumItems takes nothing returns nothing
        local item i = GetEnumItem()
        set bj_itemRandomConsidered = bj_itemRandomConsidered + 1
        
        if GetRandomInt( 1, bj_itemRandomConsidered ) == 1 then
            set bj_itemRandomCurrentPick = i
        endif
        
        set i = null
    endfunction

    private function Actions takes nothing returns boolean
        local integer i = 0
        local player p = Player( PLAYER_NEUTRAL_PASSIVE )
        local real x = GetRectCenterX( bj_mapInitialPlayableArea )
        local real y = GetRectCenterY( bj_mapInitialPlayableArea )
        local unit u = CreateUnit( p, &#039;Hpal&#039;, x, y, bj_UNIT_FACING )
        local trigger t = GetTriggeringTrigger()
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )

        if udg_PreloadCount == 0 then
            
            loop
                exitwhen i &gt;= 12
                
                set p = Player( i )
                
                call DisplayTextToPlayer( p, 0., 0., &quot;Meddelandet här, tack ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />&quot; ) // Write your message here, please ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
                
                set i = i + 1
            endloop
            
        endif
        
        set udg_PreloadCount = udg_PreloadCount + 1
        
        call RemoveUnit( u )
        
        if udg_PreloadCount &gt;= 27 then
            
            if TriggerEvaluate( gg_trg_Game_Mode_Create ) then
                call TriggerExecute( gg_trg_Game_Mode_Create )
            endif
            
        else
            call TriggerExecute( t )
        endif
        
        set u = null
        set p = null
        
        return false
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddCondition( gg_trg_Preload_Items, Condition( function Actions ) )
    endfunction

endscope


Forgot a quite important thing in there...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Well, would you mind debugging it for me ? :S
Since you have all of the variables and triggers and regions for it, it's easier if you test it :D

Use this to test, and see what messages come up ;)

JASS:
scope PreloadStuff initializer Init

    private function ItemsFilterOne takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterTwo takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterThree takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterFour takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )
    endfunction

    private function EnumItems takes nothing returns nothing
        local item i = GetEnumItem()
        set bj_itemRandomConsidered = bj_itemRandomConsidered + 1
        
        if GetRandomInt( 1, bj_itemRandomConsidered ) == 1 then
            set bj_itemRandomCurrentPick = i
        endif
        
        set i = null
    endfunction

    private function Actions takes nothing returns boolean
        local integer i = 0
        local player p = Player( PLAYER_NEUTRAL_PASSIVE )
        local real x = GetRectCenterX( bj_mapInitialPlayableArea )
        local real y = GetRectCenterY( bj_mapInitialPlayableArea )
        local unit u = CreateUnit( p, &#039;Hpal&#039;, x, y, bj_UNIT_FACING )
        local trigger t = GetTriggeringTrigger()
        
        call BJDebugMsg( &quot;It starts !&quot; )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )

        if udg_PreloadCount == 0 then
        
            call BJDebugMsg( &quot;PreloadCount is equal to 0 !&quot; )
            
            loop
                exitwhen i &gt;= 12
                
                set p = Player( i )
                
                call DisplayTextToPlayer( p, 0., 0., &quot;Meddelandet här, tack ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />&quot; ) // Write your message here, please ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
                
                set i = i + 1
            endloop
            
        endif
        
        set udg_PreloadCount = udg_PreloadCount + 1
        
        call BJDebugMsg( &quot;PreloadCount: &quot; + I2S( udg_PreloadCount ) )
        
        call RemoveUnit( u )
        
        if udg_PreloadCount &gt;= 27 then
            
            if TriggerEvaluate( gg_trg_Game_Mode_Create ) then
                call TriggerExecute( gg_trg_Game_Mode_Create )
                
                call BJDebugMsg( &quot;Preloading is done, Game Mode Create is executed !&quot; )
            endif
            
        else
            call TriggerExecute( t )
        endif
        
        set u = null
        set p = null
        
        return false
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddCondition( gg_trg_Preload_Items, Condition( function Actions ) )
    endfunction

endscope
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ouch XD
Just though of what it was...
I registered the event to the trigger 't', but the action (Condition) to 'gg_trg_Preload_Items' XD

Use this ;)

JASS:
scope PreloadStuff initializer Init

    private function ItemsFilterOne takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterTwo takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterThree takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterFour takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )
    endfunction

    private function EnumItems takes nothing returns nothing
        local item i = GetEnumItem()
        set bj_itemRandomConsidered = bj_itemRandomConsidered + 1
        
        if GetRandomInt( 1, bj_itemRandomConsidered ) == 1 then
            set bj_itemRandomCurrentPick = i
        endif
        
        set i = null
    endfunction

    private function Actions takes nothing returns boolean
        local integer i = 0
        local player p = Player( PLAYER_NEUTRAL_PASSIVE )
        local real x = GetRectCenterX( bj_mapInitialPlayableArea )
        local real y = GetRectCenterY( bj_mapInitialPlayableArea )
        local unit u = CreateUnit( p, &#039;Hpal&#039;, x, y, bj_UNIT_FACING )
        local trigger t = GetTriggeringTrigger()
        
        call BJDebugMsg( &quot;It starts !&quot; )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )

        if udg_PreloadCount == 0 then
        
            call BJDebugMsg( &quot;PreloadCount is equal to 0 !&quot; )
            
            loop
                exitwhen i &gt;= 12
                
                set p = Player( i )
                
                call DisplayTextToPlayer( p, 0., 0., &quot;Meddelandet här, tack ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />&quot; ) // Write your message here, please ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
                
                set i = i + 1
            endloop
            
        endif
        
        set udg_PreloadCount = udg_PreloadCount + 1
        
        call BJDebugMsg( &quot;PreloadCount: &quot; + I2S( udg_PreloadCount ) )
        
        call RemoveUnit( u )
        
        if udg_PreloadCount &gt;= 27 then
            
            if TriggerEvaluate( gg_trg_Game_Mode_Create ) then
                call TriggerExecute( gg_trg_Game_Mode_Create )
                
                call BJDebugMsg( &quot;Preloading is done, Game Mode Create is executed !&quot; )
            endif
            
        else
            call TriggerExecute( t )
        endif
        
        set u = null
        set p = null
        
        return false
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddCondition( t, Condition( function Actions ) )
    endfunction

endscope
 

SwedishChef

New Member
Reaction score
32
Now I got "It starts!" "PreloadCount is equal to 0! "Meddelander här, tack :p" (change to "Preloading abilities, please wait" :)) and last "PreloadCount: 1".
 

Komaqtion

You can change this now in User CP.
Reaction score
469
One last modification now :D

JASS:
scope PreloadStuff initializer Init

    private function ItemsFilterOne takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterTwo takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterThree takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_PERMANENT )
    endfunction

    private function ItemsFilterFour takes nothing returns boolean
        return ( GetItemType(GetFilterItem()) == ITEM_TYPE_CHARGED )
    endfunction

    private function EnumItems takes nothing returns nothing
        local item i = GetEnumItem()
        set bj_itemRandomConsidered = bj_itemRandomConsidered + 1
        
        if GetRandomInt( 1, bj_itemRandomConsidered ) == 1 then
            set bj_itemRandomCurrentPick = i
        endif
        
        set i = null
    endfunction

    private function Actions takes nothing returns boolean
        local integer i = 0
        local player p = Player( PLAYER_NEUTRAL_PASSIVE )
        local real x = GetRectCenterX( bj_mapInitialPlayableArea )
        local real y = GetRectCenterY( bj_mapInitialPlayableArea )
        local unit u = CreateUnit( p, &#039;Hpal&#039;, x, y, bj_UNIT_FACING )
        local trigger t = GetTriggeringTrigger()
        
        call BJDebugMsg( &quot;It starts !&quot; )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )
        
        set bj_itemRandomConsidered = 0
        
        call EnumItemsInRect( gg_rct_Item_Region, Condition( function ItemsFilterOne ), function EnumItems )
        call UnitAddItem( u, bj_itemRandomCurrentPick )

        if udg_PreloadCount == 0 then
        
            call BJDebugMsg( &quot;PreloadCount is equal to 0 !&quot; )
            
            loop
                exitwhen i &gt;= 12
                
                set p = Player( i )
                
                call DisplayTextToPlayer( p, 0., 0., &quot;Meddelandet här, tack ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue    :p" loading="lazy" data-shortname=":p" />&quot; ) // Write your message here, please ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
                
                set i = i + 1
            endloop
            
        endif
        
        set udg_PreloadCount = udg_PreloadCount + 1
        
        call BJDebugMsg( &quot;PreloadCount: &quot; + I2S( udg_PreloadCount ) )
        
        call RemoveUnit( u )
        
        if udg_PreloadCount &gt;= 27 then
            
            if TriggerEvaluate( gg_trg_Game_Mode_Create ) then
                call TriggerExecute( gg_trg_Game_Mode_Create )
                
                call BJDebugMsg( &quot;Preloading is done, Game Mode Create is executed !&quot; )
            endif
            
        else
            call TriggerEvaluate( t )
        endif
        
        set u = null
        set p = null
        
        return false
    endfunction

    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterTimerEvent( t, 0.01, false )
        call TriggerAddCondition( t, Condition( function Actions ) )
    endfunction

endscope
 

vilaemail

New Member
Reaction score
1
One last modification now :D

And so we have our 6.21c version with service pack 2.005.3224j included, along with all optimizations made in 6.20b (patch 17). BUT, memory requirements have changed, but we’re not going to tell you how because we’ve been unable to talk our tech writer down from the window ledge for this release. Have a nice day.

Sincerely,
Microsoft crew. :eek:
 

SwedishChef

New Member
Reaction score
32
Good job man. Preload time reduced to 14 seconds which is 50% of what it was before. Thanks!!! Could you check if you can optimize this trigger? That is the trigger which adds the ability. If you want to sleep I understand. I can wait until tomorrow. Would be intresting to see how low the preload time can go though.

Trigger:
  • Black Arrow
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Black Arrow
      • ((Triggering unit) is A ranged attacker) Equal to True
    • Actions
      • Unit - Add Black Arrow - Spell Book to (Triggering unit)
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot (Integer A)) Equal to (Item being manipulated)
            • Then - Actions
              • Unit - Set level of Black Arrow - Engineering for (Triggering unit) to (Integer A)
              • Player - Disable Black Arrow - Spell Book for (Owner of (Triggering unit))
              • Item - Set the custom value of (Item being manipulated) to (Integer A)
              • Set Abilities[((((Player number of (Owner of (Triggering unit))) - 1) x 3) + (Integer A))] = Black Arrow - Spell Book
            • Else - Actions


JASS:
function Trig_Acid_Bomb_Copy_Conditions takes nothing returns boolean
    if ( not ( GetItemTypeId(GetManipulatedItem()) == &#039;I01C&#039; ) ) then
        return false
    endif
    return true
endfunction

function Trig_Acid_Bomb_Copy_Func002Func001C takes nothing returns boolean
    if ( not ( UnitItemInSlotBJ(GetTriggerUnit(), GetForLoopIndexA()) == GetManipulatedItem() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Acid_Bomb_Copy_Actions takes nothing returns nothing
    call UnitAddAbilityBJ( &#039;A03T&#039;, GetTriggerUnit() )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 3
    loop
        exitwhen bj_forLoopAIndex &gt; bj_forLoopAIndexEnd
        if ( Trig_Acid_Bomb_Copy_Func002Func001C() ) then
            call SetUnitAbilityLevelSwapped( &#039;A03E&#039;, GetTriggerUnit(), GetForLoopIndexA() )
            call SetPlayerAbilityAvailableBJ( false, &#039;A03T&#039;, GetOwningPlayer(GetTriggerUnit()) )
            call SetItemUserData( GetManipulatedItem(), GetForLoopIndexA() )
            set udg_Abilities[( ( ( GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1 ) * 3 ) + GetForLoopIndexA() )] = &#039;A03T&#039;
        else
        endif
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_Acid_Bomb2 takes nothing returns nothing
    set gg_trg_Acid_Bomb2 = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Acid_Bomb2, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddCondition( gg_trg_Acid_Bomb2, Condition( function Trig_Acid_Bomb_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Acid_Bomb2, function Trig_Acid_Bomb_Copy_Actions )
endfunction
 

Tyman2007

Ya Rly >.
Reaction score
74
oh.. You have newgen I see :p Then I might as well have just done vjass in the first place.

You asked why I didn't use a loop, all I did was convert your trigger, nothing more.
 

Tyman2007

Ya Rly >.
Reaction score
74
Well... Cleaned up.. nothing more :p

Your acid bomb cleaned up and everything..

JASS:
scope AcidBomb initializer Init

globals
    private constant integer ItemID = &#039;I01C&#039; //Rawcode of the item being manipulated
    
    private constant integer AbilID = &#039;A03T&#039; //Rawcode of the ability being added
    
    private constant integer AbilID2 = &#039;A03E&#039; //Rawcode of the ability that has had its level changed
endglobals

private function Conditions takes nothing returns boolean
    return GetItemTypeId(GetManipulatedItem()) == &#039;I01C&#039;
endfunction

private function Actions takes nothing returns nothing
    local integer index = 1
    local integer mindex = 3
    call UnitAddAbility( GetTriggerUnit(), AbilID )
    loop
        exitwhen index &gt; mindex
        if ( UnitItemInSlot(GetTriggerUnit(), index - 1) == GetManipulatedItem() ) then
            call SetUnitAbilityLevel( GetTriggerUnit(), AbilID2, index )
            call SetPlayerAbilityAvailable( GetOwningPlayer(GetTriggerUnit()), AbilID, false )
            call SetItemUserData( GetManipulatedItem(), index )
            set udg_Abilities[( ( ( GetPlayerId(GetOwningPlayer(GetTriggerUnit())) ) * 3 ) + index )] = AbilID
        endif
        set index = index + 1
    endloop
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_PICKUP_ITEM )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction

endscope


I can't test it out because I don't have everything in your map. So tell me what you get if you get an error.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!

      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