HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Setting Varible Effieciency

01-21-2006, 10:52 PM#1
Immoralis
Is there a better way to do this because i have 25 waves?
The spawn index arrays are fixed but there is no algorithm for each wave.
Trigger:
Creep Change
Collapse Events
Time - Elapsed game time is 40.00 seconds
Conditions
Collapse Actions
Set Wave_Wait = 15.00
Set Spawn_Increment = 0.09
-------- Wave1 --------
Set Current_Wave = (Current_Wave + 1)
Set Spawn_Index[1] = 1
Set Spawn_Index[2] = 2
Set Spawn_Index[3] = 0
Set Spawn_Index[4] = 0
Set Spawn_Index[5] = 0
Set Spawn_Index[6] = 0
Trigger - Turn on Main Spawn <gen>
Wait 120.00 seconds
Trigger - Turn off Main Spawn <gen>
-------- Wave2 --------
Set Spawned_Amount = (Spawned_Amount + Spawn_Increment)
Set Current_Wave = (Current_Wave + 1)
Set T = 0
Wait Wave_Wait seconds
Set Spawn_Index[1] = 1
Set Spawn_Index[2] = 0
Set Spawn_Index[3] = 0
Set Spawn_Index[4] = 2
Set Spawn_Index[5] = 0
Set Spawn_Index[6] = 0
Trigger - Turn on Main Spawn <gen>
Wait 120.00 seconds
Trigger - Turn off Main Spawn <gen>
-------- Wave3 --------
Set Spawned_Amount = (Spawned_Amount + Spawn_Increment)
Set Current_Wave = (Current_Wave + 1)
Set T = 0
Wait Wave_Wait seconds
Set Spawn_Index[1] = 1
Set Spawn_Index[2] = 3
Set Spawn_Index[3] = 0
Set Spawn_Index[4] = 2
Set Spawn_Index[5] = 0
Set Spawn_Index[6] = 0
Trigger - Turn on Main Spawn <gen>
Wait 120.00 seconds
Trigger - Turn off Main Spawn <gen>
-------- Wave4 --------
Set Spawned_Amount = (Spawned_Amount + Spawn_Increment)
Set Current_Wave = (Current_Wave + 1)
Set T = 0
Wait Wave_Wait seconds
Set Spawn_Index[1] = 0
Set Spawn_Index[2] = 3
Set Spawn_Index[3] = 4
Set Spawn_Index[4] = 2
Set Spawn_Index[5] = 1
Set Spawn_Index[6] = 0
Trigger - Turn on Main Spawn <gen>
Wait 120.00 seconds
Trigger - Turn off Main Spawn <gen>
-------- Wave5 --------
Set Spawned_Amount = (Spawned_Amount + Spawn_Increment)
Set Current_Wave = (Current_Wave + 1)
Set T = 0
Wait Wave_Wait seconds
Set Spawn_Index[1] = 2
Set Spawn_Index[2] = 4
Set Spawn_Index[3] = 1
Set Spawn_Index[4] = 3
Set Spawn_Index[5] = 0
Set Spawn_Index[6] = 0
Trigger - Turn on Main Spawn <gen>
Wait 120.00 seconds
Trigger - Turn off Main Spawn <gen>
.....
01-21-2006, 11:01 PM#2
Naakaloh
Errm... What exactly are you doing?
01-21-2006, 11:02 PM#3
Vexorian
I don't think there's a better way unless there is a way to make wc3 read your thoughts or something
01-21-2006, 11:27 PM#4
Immoralis
thank you
01-21-2006, 11:45 PM#5
johnfn
Read my tutorial here : http://www.wc3campaigns.com/showthread.php?t=73104

You could save yourself a little bit of time and space space, not a lot, just a little.
01-22-2006, 12:12 AM#6
Immoralis
dont neeed to. i have my own and my quesiton is answered
01-22-2006, 01:37 AM#7
Azazel_
Action Steps
- Create a new variable named SpawnIndex, type Game Cache

Collapse JASS:
function Initialisation takes nothing returns nothing
    set udg_SpawnIndex = InitGameCache( "SpawnIndex.w3v" )
    call StoreInteger(udg_SpawnIndex, "1", "1", "1")
    call StoreInteger(udg_SpawnIndex, "1", "2", "2")
    call StoreInteger(udg_SpawnIndex, "1", "3", "0")
    call StoreInteger(udg_SpawnIndex, "1", "4", "0")
    call StoreInteger(udg_SpawnIndex, "1", "5", "0")
    call StoreInteger(udg_SpawnIndex, "1", "6", "0")

    call TriggerSleepAction(0)

    call StoreInteger(udg_SpawnIndex, "2", "1", "1")
    call StoreInteger(udg_SpawnIndex, "2", "2", "0")
    call StoreInteger(udg_SpawnIndex, "2", "3", "0")
    call StoreInteger(udg_SpawnIndex, "2", "4", "2")
    call StoreInteger(udg_SpawnIndex, "2", "5", "0")
    call StoreInteger(udg_SpawnIndex, "2", "6", "0")

    call TriggerSleepAction(0)

    (Repeat until all waves are done..)

endfunction

Collapse JASS:
function Waves takes nothing returns nothing
    local integer i = 1
    set udg_Current_Wave = udg_Current_Wave + 1
    set udg_Spawned_Amount = udg_Spawned_Amount + udg_Spawn_Increment
    loop
        exitwhen i > 6
        set Spawn_Index[i] = GetStoredInteger( udg_SpawnIndex, I2S(udg_Current_Wave), I2S(i) )
        set i = i + 1
    endloop
    call PolledWait( udg_Wave_Wait )
    call EnableTrigger(gg_trg_Main_Spawn)
    call PolledWait( 120.00 )
    call DisableTrigger(gg_trg_Main_Spawn)
    if ( udg_Current_Wave > 25 ) then
        call ExecuteFunc("Waves")
    else
        call ExecuteFunc("TheEnd")
    endif
endfunction

I believe that this method may be more organized, easier to edit and shorter, removing the unnecessary duplication of effort for each wave.

Notes :
- call StoreInteger(udg_SpawnIndex, YourWave, YourIndex, YourValue)
- TriggerSleepAction(0) is used as a break. Personal preference.
- PolledWait is for accuracy reasons.