• 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.
  • It's time for the first HD Modeling Contest of 2025. Join the theme discussion for Hive's HD Modeling Contest #7! Click here to post your idea!

Need help with trigger

Status
Not open for further replies.
Level 1
Joined
Dec 9, 2019
Messages
1
Hi Guys!

I'm just about to build my first map and i don't have much knowlegde about triggers..

I created custom units and custom buildings in object editor.
Custom unit level 1 is to buy in custom building Lv.1
Custom unit level 2 is to buy in custom bulding Lv.2
and so on..until Lv.50

What i want to do is, when you buy one of this units in the building
there should appear 10 units how attacks opponent on the other side.
That works fine with the trigger i have now.

But the problem is whenever i upgrade custom building to lv.2
custom unit lv.1 comes out instead of lv.2.

I tryed to make a second trigger with the same parameters for lv.2,
or different conditions & actions but nothing worked for me..


The other thing is,
11 units appear instead of 10 - 10 keep moving to enemy base and 1 just stands by the building.

Would be great if someone could help me with this!

PS: I have the german version, so here's quick translation:
Event: custom building finishes training a unit
Actions: create 10 units facing angle at position of custom building /
Unit group – issue order targeting a point - last created unit group - attack-move to opponent


Trigger.png
 
Last edited:
Level 43
Joined
Feb 27, 2007
Messages
5,433
Welcome! Here are 3 threads that I usually end up linking as the most important things to understand when learning to make triggers:
  • How To Post Your Trigger (Maybe not super helpful since it will be copying from German and the forum trigger tags only formats properly for English.)
  • Things That Leak (You are leaking locations but not unit groups here because of how Last Created Unit Group works)
  • Event Response Myths (Good general knowledge)
  • Disable "use fixed random seed" in your WE preferences
  • Shift + double click on an Object Editor field to allow you to enter negative values
Now as for what you're doing: you've used a "specific unit event" here and I think you want to use a "generic unit event". A specific event only triggers for a specific unit and you have to pre-select that unit by clicking on it when you make the trigger (unless adding events dynamically but for now ignore that option); this can be useful but not most of the time. Generally you want to use a generic event that fires when any unit does that action, and then use responses like Triggering Unit and functions like Unit-type of <unit> in the conditions to figure out what should happen.

Doing things this way, what you want to accomplish (all 50 levels) can all be be done with a single trigger! Cool. We can also address that it makes 11 units and only 10 of them move; this is because the original trained unit is never ordered to move (it's not part of Last Created Unit Group) and it isn't removed. I say removing the unit is going to be simplest. It looks something like this:

  • Events
    • Unit - A unit finishes training a unit
  • Conditions
  • Actions
    • Set TempPoint = (Position of (Trained Unit))
    • Unit - Create 9 (Unit type of (Trained Unit)) for (Owner of (Triggering Unit)) at TempPoint facing Default building facing degrees
    • Unit Group - Add (Trained unit) to (Last created unit group)
    • Custom script: call RemoveLocation(udg_TempPoint) //change to match your variable name but keep the udg_ prefix
    • Set TempPoint = (Position of Haupthaus 0000 <gen>)
    • Unit Group - Order (Last created unit group) to Attack-Move to TempPoint
    • Custom script: call RemoveLocation(udg_TempPoint) //same
There's one thing this doesn't address: every unit spawned by a building in your map will be duplicated 9 times. Every unit. If that's what you want, cool, leave it as is. But if you want to avoid this maybe you only want certain structures to 10-build so you would use an Or condition:
  • Conditions
    • Or - Any condition is true
      • (Unit-type of (Triggering Unit)) equal to Grunz Grunz Academy Lv. 1
      • (Unit-type of (Triggering Unit)) equal to Grunz Grunz Academy Lv. 2
      • (Unit-type of (Triggering Unit)) equal to Grunz Grunz Academy Lv. 3
      • (Unit-type of (Triggering Unit)) equal to Grunz Grunz Academy Lv. 4
      • ...
      • (Unit-type of (Triggering Unit)) equal to Grunz Grunz Academy Lv. 50
But that's a pain in the butt, screw that. An easier way is to give all of your duplicator buildings some invisible ability that does nothing but is used as a marker. Say base it on the item attack damage bonus but it gives 0 bonus damage (usually item abilities don't show up on the command card, or you can hide them by setting their button coordinates to 0,-11 instead). Give all duplicator buildings (Grunz Grunz Academy Lv. 1 - Lv. 50) this ability in the OE and then check for it with this condition:
  • Conditions
    • (Level of MARKER_ABILITY for (Triggering Unit)) greater than 0
 
Status
Not open for further replies.
Top