Adding units to already existing Variables?

Status
Not open for further replies.
Level 2
Joined
May 14, 2019
Messages
19
Hi people! I would like to ask for a little help!

So I'm trying to make a trigger where, there would be multiple units doing things.
There is a variable, lets call it Yeeter.
Yeeter would yell "Yeet" when it takes damage, for fun purposes. Would use different sounds/voices with the same method.
It works perfectly fine If I'm doing it with one unit at the same time. The problem starts when I wanna spawn more units with Create trigger, and make them do the thing at the same time.

So I made a trigger, Create 4 units to a place, and then I wanted to use the Set command.
So I created a Variable, selected type Unit, named it Yeeter.
Set Yeeter = (Last created unit) - I hoped this will include all 4 units, I was wrong.
Here comes the problem, only one of the 4 units will do the things I want, not all 4 of them.
Is there a way to add more unit to the same Variable? Adding a counter maybe?
My trigger so far looks this

Events
- Unit - A unit owned by Player 12 (brown) Is attacked. (because I cannot pick "takes damage" Altho I would like to do that to be honest.)
Conditions
- (Triggering unit) Equal to Yeeter
Actions
- Sound Play Yeet(Random Integer number between 1 and 3) at 100% volume, attached to Yeeter. - got multiple sounds to randomize, already made that trigger, that works.
- Animation - Play Yeeter's spell animation.

The problem with "Is attacked". for me is that, for AoE damage, it still will register one unit, because that is "attacked" the others around it are just taking damage but not targeted as "attacked" units.

I hope my jibberish is understandeable XD Thanks for the help!
 
Level 2
Joined
May 14, 2019
Messages
19
Oh, I did not. Altho can I attach sounds and animations to unit groups tho? When I tried to make an Unit group variable, I could not pick it for thoose actions.
 
Oh, I did not. Altho can I attach sounds and animations to unit groups tho? When I tried to make an Unit group variable, I could not pick it for thoose actions.
hmmm maybe you can make an event with a damage system something like
  • Mana Burn
    • Events
      • Game - GDD_Event becomes Equal to 1.00
    • Conditions
      • (Unit-type of GDD_DamageUnit) Equal to Spellweaver
    • Actions
      • Sound - Play For_Kul_Tiran <gen> at 100.00% volume, attached to GDD_DamagedUnit
      • Sound - Destroy (Last played sound)
 
Level 2
Joined
May 14, 2019
Messages
19
Uhh, I kinda having problem understandig the GDD things. For me ther is only "essence" in " Game - Value Of Real Variable"
 
 
If I were you, I would change the Event. You probably have an event that fires when something happens to Yeeter. Something like:

  • Events
    • Something happens to Yeeter
  • Actions
    • Play the "Yeet" sound
So, I think instead you could change this to:

  • Events
    • Something happens to any unit
  • Conditions
    • (Triggering unit) is one of the Yeeters
  • Actions
    • Play the "Yeet" sound
(Above: "Generic Unit Event" instead of "Specific Unit Event" in the Event dropdown, if I recall)

So, you cannot really add more units to the unit variable as you ask, because the system is not built that way. But you can express a trigger like the above, that I hope you will understand.

So then the hard part is to do the condition "is one of the yeeters", what is that?
That is where you could make a unit group named Yeeters. Then you could probably look for "Unit Is In Unit Group" as your condition.

I think if you do this, you would probably not need a third party damage detection library like the GDD stuff. But I am writing this from my couch without World Editor in front of me.
 
Level 41
Joined
Feb 27, 2007
Messages
5,239
Unit Group is the best possible solution, but another would be to add a non-visible, useless dummy ability to any units that should be Yeeters. Then you can check if a unit is a Yeeter by doing (Level of YEET ABILITY for (Triggering Unit)) Greater than 0 or find all yeeters on the map doing Unit Group - Pick every unit in (Units in Playable Map Area matching (Level of YEET ABILITY for (Matching Unit)) Greater than 0)) and do Actions
 
Level 2
Joined
May 14, 2019
Messages
19
Thank you so much for the answers!
I managed to find a more simplestic solution, I put down decent amount of units, and managed to do the thing I wanted without the use of Variables.
I just made a player's unit specific trigger
Something happens to an unit what is controlled by player
Condition is unit-type, the unit I picked as a Yeeter, I believe I can pick multiple unit-types if i want,
Then play yeet when it is attacked
turn off trigger
wait 1 sec
turn on trigger so it gives a cooldown for it.
Altho So yea its cool, thank you for your tips! Just realised you just basically told me this same thing basically XD
I'll be looking into how to make custom spells with triggers now, that will be fun.
Have a good one in the meantime.
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,193
The Unit-type Condition as Lord Dracula suggested could make the most sense if all of these Yeeters are the same Unit-type.

For example, this trigger will run whenever ANY Footman is attacked:
  • Events
    • Unit - A unit is attacked
  • Conditions
    • Unit-type of (Attacked unit) Equal to Footman
  • Actions
    • // Play your sound on the (Attacked unit)
Simply replace Footman with your Yeeter Unit-type and you now have a single trigger that will work for all of them. Again, assuming that they are all the same Unit-type.

Also, I would recommend against using Specific anything whenever possible. Generic triggers are going to make your life A LOT easier as you'll only need one trigger which instead of X (one for each Player). Want to change something in your trigger? You only have to do it once. If you had 12 copies of that trigger, one for each Player, you'd have to modify it for all 8.

It also reduces the bloat in your Trigger Editor by cutting down trigger count and variable usage greatly. You'll run into annoying problems as your map grows in size and wish you had done things properly from the start.

I highly recommend creating a solid foundation from the very beginning to build your map upon. So I recommend spending a few hours now getting things setup in order to save yourself MANY more hours of headaches in the future. This could mean:
  • Organizing Players into Player Groups. (Have multiple teams? Break them up into separate Player Groups)
  • Organizing key Units into Unit Groups. (Each player controls a Hero? Store all of them in a single Unit Group or Unit Groups based on Teams)
  • Storing data in Arrays. This way you can easily access and manipulate the data using a For Loop. (Read up on Arrays, they're your best tool available)
Do all of this at the start of the game (if able). Then your future triggers can simply reference these Variables and re-use them again and again.
 
Last edited:
Status
Not open for further replies.
Top