• 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.

[Trigger] Enfo. Wave System

Status
Not open for further replies.
Level 2
Joined
May 11, 2010
Messages
7
I should probably clearify for everyone before getting on my issue here, I'm a total newbie on the World Editor. Actually just started three days ago!
Although I have been getting some common knowledge regarding how things are built and integrated, regarding triggers and JASS that is.

Now, my issue... Isn't as much of an issue as it is a feedback requst.

I want a easy-to-go Wave System, so I've thought of a chain loop of some sort, the chain should be:

Wave 1 releases.
Wave 1 dies, starts a timer counting down for the next wave.
Wave 2 releases.

...Etc.

Now, what would the best approach be? I've thought of using a timer, probing a variable each second to see if all units are dead, if true then start the countdown timer.

Although I'd like to see this working instead;
The first wave's creatures are in a group (array?), when the entire group is destroyed the timer triggers, and so on.

Any feedback is appreciated and replied.
 
Level 11
Joined
Aug 25, 2006
Messages
971
Will you can't use an event to check if an entire group is dead. Instead you'd probably have an event "unit generic unit dies" then check if the whole group is dead. You check if the whole group is dead by setting a variable to 0. Then you scroll through the group using "Pick every unit in group and do action" within the action have an if statement that says if the picked unit has greater than 0 health add one to the variable you set to zero before. Finally do one last if statement (out side of the pick every unit... action) that says if the variable is still 0 trigger the next wave.
 
Level 2
Joined
May 11, 2010
Messages
7
I thank you all for your kindness of your replies. I did solve it the way wd40bomber sugested and it works very well! I also wrote together a function to spawn creeps, returning a group but the syntax of example; "20nzom|10nrrg", posting this later on.
 
Level 2
Joined
May 11, 2010
Messages
7
Although there seems to be a bug in this system.
I have a global variable named udg_Waves, the size of it is the amount of waves to trigger. I then have udg_CurrentWave which holds the current wave.

Now my trigger looks like:
  • Events
    • Time - Every 60.00 seconds of game time
  • Conditions
  • Actions
    • Custom script: call SpawnWave(udg_Waves[udg_CurrentWave])
    • Game - Display to (All players) the text: Waves[CurrentWave]
    • Set CurrentWave = (CurrentWave + 1)
And the SpawnWave function looks like:
JASS:
function SpawnWave takes string strUnits returns group
  local integer intSize = StringLength(strUnits) // Length of WaveUnits string
  local integer intOffset = 0 // Current offset
  local integer intLastPipe = 0 // Last found pipe offset
  local string  strLastUnit // Last extracted units string
  local integer intUnitsAmount // Last extracted amount of units
  local integer intUnitID // Last extracted unit ID
  local group   tempGroup // Last created group
  local group   returnGroup // Final group

  call DisplayTextToForce( GetPlayersAll(), strUnits )

  loop
    if SubString(strUnits, intOffset, intOffset+1) == "|" or (intOffset) == intSize then
      set strLastUnit = SubString(strUnits, intLastPipe, intOffset)
      set intLastPipe = intOffset+1
      set intUnitsAmount = S2I(SubString(strLastUnit,0, 2))
      set intUnitID = String2Rawcode(SubString(strLastUnit,2, StringLength(strLastUnit)))
      set tempGroup = CreateNUnitsAtLoc(intUnitsAmount, intUnitID, Player(10), GetRectCenter(gg_rct_Summon_Area), bj_UNIT_FACING)
      call GroupAddGroup(tempGroup, returnGroup)
    endif

    set intOffset = intOffset + 1
    exitwhen intOffset == (intSize+1)
  endloop

  call DestroyGroup(tempGroup) 
  return returnGroup
endfunction

Also, here's the String2Rawcode function that is used in SpawnWave, as well as other related functions for it to work:
JASS:
function Char2Ascii takes string Character returns integer
  local string CharMap = "!\"#$%&'()+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  local integer CharMapLength = StringLength(CharMap)
  local integer intOffset = 0
 
  loop
    if SubString(CharMap, intOffset, (intOffset+1)) == Character then
      return intOffset + 35
    endif

    set intOffset = intOffset + 1
    exitwhen intOffset == CharMapLength
  endloop

  return 0
endfunction

function String2Rawcode takes string String returns integer
  local integer intOffset = 0
  local integer stringLength = StringLength(String)
  local integer returnValue = 0

  loop
    set returnValue = returnValue * 256 + Char2Ascii(SubString(String, intOffset, (intOffset+1)))
    set intOffset = intOffset + 1
    exitwhen intOffset == stringLength
  endloop

  return returnValue
endfunction

Now if I would have:
JASS:
    set udg_Waves[1]  = "20nzom"
    set udg_Waves[2]  = "30ugho"
    set udg_Waves[3]  = "20ucry|10ugho"
    set udg_Waves[4]  = "30nbrg"
    set udg_Waves[5]  = "30nrog"
    set udg_Waves[6]  = "20nwiz|10nwzr"
    set udg_Waves[7]  = "30nwzg"
    set udg_Waves[8]  = "20nhdc|10nhfp"
    set udg_Waves[9]  = "10nhhr"
    set udg_Waves[10] = "05nbld|05nwzd|01Nbrn"

The message then is:
20nzom
20nzom
20nzom
30ugho
...If that makes sense.

It's like SpawnWave ignores my parameter. What could be wrong?
 
Last edited:
Status
Not open for further replies.
Top