• 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] Set Random Unit as a Varriable

Status
Not open for further replies.
Level 3
Joined
Apr 3, 2014
Messages
53
Hi everyone, im having trouble with the following trigger setup, so i made my trigger like this



I want to do the following, every X seconds, a random unit to be set as a varriable Ah_Player, but only to pick units that are alive, in region, owned by player of type.

So far i though the trigger i setup will work, but it the following happens.

It either doens't pick anyone, or it picks a unit only from one player, or it skips picks, any ideas what the problem is or an alternative to this setup.

Thank you in advance!
 
Last edited:
Level 20
Joined
Feb 23, 2014
Messages
1,265
What's the exact condition on the player that you want to choose? Any player other than Neutral Hostile?

Generally, I think that the issue might be with the player selection, so before I tackle it I would like to know which players do you want to pick.
 
Level 3
Joined
Apr 3, 2014
Messages
53
What's the exact condition on the player that you want to choose? Any player other than Neutral Hostile?

Generally, I think that the issue might be with the player selection, so before I tackle it I would like to know which players do you want to pick.

Any random player owned unit, in a specific region, that is not owned by Neutral Hostile
 
Level 20
Joined
Feb 23, 2014
Messages
1,265
1. If you want to paste your trigger, click on the trigger with the right mouse button and pick Copy as text. Then paste it here using [trigger ] Your trigger text [/trigger ] (just without the spaces before "]"). It's easier to paste trigger this way than making a screenshot and uploading it as an image.

2. You generate an unit group, a player group, a special effect and a location handles every time this trigger is run , so basically every 5 seconds you generate 4 leaks from this trigger alone. In time this might cause lags.

3. Personally, I don't really like "matching units" as in my experience it seemed to sometimes cause lags when you're matching too many units at once, so... I'm going to take a different approach with your trigger.

That said, try this:

  • Events
    • Time - Every <Your Time> seconds of game time
  • Conditions
  • Actions
    • Set TempGroup = (Units in <Your Region>)
    • Unit Group - Pick every unit in TempGroup and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is dead) Equal to False
            • Or - Any (Conditions) are true
              • Conditions
                • ((Owner of (Picked unit)) controller) Equal to User
                • ((Owner of (Picked unit)) controller) Equal to Computer
          • Then - Actions
            • -------- do nothing --------
          • Else - Actions
            • Unit Group - Remove (Picked unit) from TempGroup
    • Set <Your Unit Variable> = (Random unit from TempGroup)
    • Custom script: call DestroyGroup(udg_TempGroup)
    • Special Effect - Create a special effect attached to the head of <Your Unit Variable> using <Your Special Effect>.mdl
    • Special Effect - Destroy (Last created special effect)
    • Set TempPoint = (Position of <Your Unit Variable>)
    • Unit - Cause <Your Unit Variable> to damage circular area after <Your Delay> seconds of radius <Your Radius> at TempPoint, dealing <Your Damage> damage of attack type <Your Attack Type> and damage type <Your Damage Type>
    • Custom script: call RemoveLocation(udg_TempPoint)
This doesn't leak anything as far as I'm aware and from my limited testing, it appears to be working correctly - granted I've understood your player requirements right.

Also, if you run your map via Test Map function, you might find that the order of unit this trigger selects is always the same - it's because of the editor properties settings. To circumvent this, test the trigger by opening the map through the Warcraft 3 client or deselect Use Fixed Random Seed field in the editor preferences as @DaneTheBeast suggested below.

EDIT: Corrected my mistake regarding the random nature in the WE.
 
Last edited:
Level 12
Joined
Dec 11, 2014
Messages
665
Also, if you run your map via Test Map function, you might find that the order of unit this trigger selects is always the same - it's a known bug. If you run into it, test the trigger by opening the map through the Warcraft 3 client.

Are you sure it's a bug?

Seed.png

There's this thing in the editor preferences, if it's checked then the game will never be "random".
 
Status
Not open for further replies.
Top