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

[General] unit group problem

Status
Not open for further replies.
Level 3
Joined
Jul 26, 2013
Messages
41
  • Human Guards Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Triggering unit) Equal to (Random unit from Human_Guards)
    • Actions
      • Player - Set Player 3 (Teal) Current lumber to ((Player 3 (Teal) Current lumber) - 500)
      • Wait 30.00 seconds
      • Unit - Create 1 (Unit-type of (Triggering unit)) for Player 3 (Teal) at (Center of Human Baracks <gen>) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to Human_Guards
I've added the units to that group in a different trigger. My problem here is that if all of them die, only 1 will be revived.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
change Triggering unit is a random unit from <group> to unit is in <group> equal to true
 
It's happening because you're using a Wait. If the event is ran before the wait finishes, Triggering Unit gets overwritten. You can shadow a global to get past this, or use timers instead of waits.

  • Human Guards Death
    • Events
      • Unit - A unit Dies
      • Conditions
        • (Triggering unit) Equal to (Random unit from Human_Guards)
      • Actions
        • Custom scripts: local unit u = GetTriggerUnit()
        • Player - Set Player 3 (Teal) Current lumber to ((Player 3 (Teal) Current lumber) - 500)
        • Wait 30.00 seconds
        • Custom script: set udg_UnitVariable = u
        • Unit - Create 1 (Unit-type of (UnitVariable) for Player 3 (Teal) at (Center of Human Baracks <gen>) facing Default building facing degrees
        • Unit Group - Add (Last created unit) to Human_Guards
You need to create a variable of type unit named UnitVariable for this to work.

EDIT Does GetTriggerUnit get overwritten? I forgot

And Arhowk is right.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Now that the solution has been declared, let me tell you what really happened in your trigger (OP).

This what causes your trigger to function randomly.
  • (Triggering unit) Equal to (Random unit from Human_Guards)
Let's say you have 5 units in that Unit Group;
Unit[1]
Unit[2]
...
Unit[5]

Situation:
A unit dies - therefore it is registered as (Triggering unit).
Let's say the unit dies hold to the value Unit[3].
Therefore the comparison would look like this:
Unit[3] Equal to Unit[RandomNumber]

Let's say the RandomNumber is generated and it holds the value of 4;
Unit[3] Equal to Unit[4]

This condition is false, right ?
Therefore the trigger will never be fired.

That's why when you change the condition parameter (from random to IsInGroup), it works.
Because the condition is 100% right.

The original condition has a chance of: 100 / NumberOfUnit
If it has 5 units, the chance is 20% to be fired.

@TriggerHappy
TriggerUnit does not get overwritten, it can still retain MUI-ness if you include Wait in it.
As if (Triggering unit) acts as local unit variable.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
It's happening because you're using a Wait. If the event is ran before the wait finishes, Triggering Unit gets overwritten. You can shadow a global to get past this, or use timers instead of waits.

Wrong, Triggering Unit is MUI already, so
  • Actions
    • Wait 10.00 seconds
    • Unit - Kill (Triggering Unit)
if you run this multiple times, multiple different units will die

All other event callbakcs are not guaranteed to be MUI(dont know if aynone tested them)
 
Level 3
Joined
Jul 26, 2013
Messages
41
One more quick thing, unrelated to the topic.. I have a ''Shield Block'' ability based on Hardened Skin, but it seems I can level it at each level instead of every 2 levels and I can't change it.. I've tried Level Skip Requirement and put it to 2 but I can still level it up at every level my hero earns.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Even dying unit?

It is MUI.

I have a ''Shield Block'' ability based on Hardened Skin, but it seems I can level it at each level instead of every 2 levels and I can't change it.. I've tried Level Skip Requirement and put it to 2 but I can still level it up at every level my hero earns.

Set level skip to 0 so it uses the default value set in Gameplay constants. Set required level to 1, set Check dependencies to true.
 
Status
Not open for further replies.
Top