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

Command to show next wave

Status
Not open for further replies.
Level 2
Joined
Dec 9, 2022
Messages
6
Just wondering how to create a command/trigger that shows what's on the next wave in my TD
So when they type -next during say round 5
it'll come up and say "Round 6 - What mobs - etc other stuff"
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You'll have to store this information in a few arrays where the index of an array element corresponds to the wave, and then read these arrays when a player types the relevant chat command.
  • Events
    • Time - Elapsed game-time is 0.50 seconds //better than the map init event as long as nothing that happens in the first 0.5s depends on this trigger
  • Conditions
  • Actions
    • Set WAVE = (WAVE + 1) //this variable starts at 0 and is used in this config trigger to reduce the number of things you have to assign when you copy-paste this multiple times; later it will be used to track the current wave
    • Set WaveData_UnitType[WAVE] = Footman
    • Set WaveData_UnitCount[WAVE] = 32
    • Set WaveData_Ability[WAVE] = Devotion Aura
    • Set WaveData_Note[WAVE] = Takes double damage from fire attacks.
    • -------- --------
    • -------- Repeat the above lines for each wave --------
Now you may notice that that's a unit-type array, an integer array, an ability array, and a string array. The string and the integer are easy to print as text from within GUI, but displaying unit-type and ability variable values in a human-friendly way is difficult in GUI. Internally that is assigning the value of 'hfoo' to the variable, which is just a long integer like 29820331. The following function exists in JASS but is not directly accessible in GUI:
JASS:
constant native GetObjectName               takes integer objectId          returns string
There are some similar functions in GUI but they read the name of a specific unit or ability, rather than reading the name of the unit-type or generic ability, so this is the best solution. To use it you'll need a custom script. Instead of doing this conversion each time you refer to one of these variables it's best to simply convert it and store it as a string directly. You would rewrite the above trigger like this now:
  • Events
    • Time - Elapsed game-time is 0.50 seconds
  • Conditions
  • Actions
    • Set WAVE = (WAVE + 1)
    • Set TempUT = Footman //doing it this way means you don't have to fuck with the rawcodes in the custom script line directly and can just copy paste this over and over only having to change the actual unit-types
    • Custom script: set udg_TempString = GetObjectName(udg_TempUT) //change the variable names to match whatever you call your variables, but keep the udg_ prefixes
    • Set WaveData_UnitType[WAVE] = TempString //this is the string variable we assigned in the custom script line above this
    • Set WaveData_UnitCount[WAVE] = String(32) //this is now a string variable, converting from an integer
    • Set TempAbil = Devotion Aura
    • Custom script: set udg_TempString = GetObjectName(udg_TempAbil) //same guidance here
    • Set WaveData_Ability[WAVE] = TempString
    • Set WaveData_Note[WAVE] = Takes double damage from fire attacks.
    • -------- --------
    • -------- Repeat the above lines for each wave, like this: --------
    • Set WAVE = (WAVE + 1)
    • Set TempUT = Knight
    • Custom script: set udg_TempString = GetObjectName(udg_TempUT)
    • Set WaveData_UnitType[WAVE] = TempString
    • Set WaveData_UnitCount[WAVE] = String(5)
    • Set TempAbil = Unholy Frenzy
    • Custom script: set udg_TempString = GetObjectName(udg_TempAbil) //same guidance here
    • Set WaveData_Ability[WAVE] = TempString
    • Set WaveData_Note[WAVE] = There aren't a lot of 'em but boy will these guys mess you up!
    • -------- etc. --------
Reset WAVE back to 0 and increment it every time a wave spawns. Now when a player wants to display this information you simply need to build a string that contains all of the relevant text and read all the relevant arrays at the [WAVE] index. You can add line breaks with the \n character but it only works in JASS or if you manually assign a string variable that value with a custom script and then concatenate with it in GUI:
  • //make a string variable named br
  • //then do this on map init
  • Custom script: set udg_br = "\n" //have to do this in JASS, GUI adds an extra \ to the start otherwise
You can then concatenate with the "br" string to add a linebreak wherever you want:
  • Set DisplayString = <Empty String> //actually empty don't give it this text lol
  • Set DisplayString = (DisplayString + "Information about wave #")
  • Set DisplayString = (DisplayString + WaveData[WAVE])
  • Set DisplayString = (DisplayString + :)
  • Set DisplayString = (DisplayString + br) //adds a linebreak. So far the string looks like this -> Information about wave #8:
  • Set DisplayString = (DisplayString + Unit type: ) //note the trailing space here
  • Set DisplayString = (DisplayString + WaveData_UnitType[WAVE])
  • Set DisplayString = (DisplayString + br)
  • Set DisplayString = (DisplayString + Count: )
  • Set DisplayString = (DisplayString + WaveData_UnitCount[WAVE])
  • Set DisplayString = (DisplayString + br)
  • Set DisplayString = (DisplayString + Special ability: )
  • Set DisplayString = (DisplayString + WaveData_Ability[WAVE])
  • Set DisplayString = (DisplayString + br)
  • Set DisplayString = (DisplayString + Note: )
  • Set DisplayString = (DisplayString + WaveData_Note[WAVE])
  • -------- --------
  • Game - Display to (Triggering Player) for 30.00 seconds the text DisplayString
Using the info on Wave 1 (footmen) from above it would look like this:
Code:
Information about wave #1:
Unit type: Footman
Count: 32
Special ability: Devotion Aura
Note: Takes double damage from fire attacks.
Somewhere in your map you must already be storing this information about which unit types in which order for each wave and how many of each of them, etc., so you should be able to integrate the array-setting-up into that data structure, whatever it is.
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
No, I just typed those in the text editor here, there’s no map they came from.

All it is doing is assigning some variables at map init and then reading them back again when a player wants to see information about a wave. The trick is storing it all as strings in the first place and getting a linebreak variable to work in GUI.

Ask whatever questions you need to clarify. I’m happy to explain.
 
Level 2
Joined
Dec 9, 2022
Messages
6
There's a map I attached in this thread that may be of some help to you. I don't quite remember what I did in the map but I assume it's something close to what Pyrogasm suggested.
This has changed the way I make my map, practically gotta remake half of the triggers now. Still very new to it so I'm trying to figure it out.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,867
This has changed the way I make my map, practically gotta remake half of the triggers now. Still very new to it so I'm trying to figure it out.
That's awesome to hear and the good news is that once you create these foundational systems you'll find that you'll be saving time due to their efficiency.

Using myself as an example, over the last 3 years I basically went from unable to code and a complete GUI noob to now being able to make just about any map I could imagine. That may sound like a lot of time but I improved a lot in just the first year. I started with getting better at GUI and learned about Arrays, For Loops, Timers, Indexing, etc. and then once I started feeling gated by the limitations of GUI I decided to tackle Lua coding, which was conveniently just released at the time. I asked a lot of "stupid" questions on these forums but the fine folks here helped me out and now I'm far more capable than I was 3 years ago. It's a good feeling to be able to bring your ideas to life, I recommend putting in the work because it really does pay off.
 
Last edited:
Status
Not open for further replies.
Top