That sounds like a pretty easy fixIs it just one unit for the other players, or all units?
First you need to create all the variables. So I've create 4 variables here:
You can switch out any of the variables if you have already declared what you need.
- hero: unit variable
- fightRegion: a region variable for the region in which you want to check all units are dead
- baseRegion: a region variable for your base
- tempGroup: unit group variableto handle group leaks
- tempPoint: a point variable to handle point leaks
Alright so first setup the variables:
Here you can chance the hero or the regions which are used.
SettingUpVariables
Events
Map initialization
Conditions
Actions
Set baseRegion = Region 002 <gen>
Set fightRegion = Region 001 <gen>
Set hero = Footman 0011 <gen>
Then the trigger which detects if all units are dead:
That should do the trick
AllUnitsAreDead
Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
Actions
Set tempGroup = (Units in fightRegion matching ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 12 (Brown))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in tempGroup) Equal to 0
Then - Actions
Set tempPoint = (Center of baseRegion)
Unit - Move hero instantly to (Center of baseRegion)
Custom script: call RemoveLocation(udg_tempPoint)
Else - Actions
Custom script: call DestroyGroup(udg_tempGroup)
Feel free to ask if you need some explanation for some of the stuff.
Yeah, there definitely is! I have 2 suggestions here (I prefer the latter option personally, but believe the first option is what you're asking for):
Option 1
This removes the "hero" variable entirely, and instead looks at all the units in the map, and moves them to the 'baseRegion' if it's a Hero and if it's owner by either of the players you suggested.
Init trigger
Move trigger
SettingUpVariables
Events
Map initialization
Conditions
Actions
Set baseRegion = Region 002 <gen>
Set fightRegion = Region 001 <gen>
AllUnitsAreDead
Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
Actions
Set tempGroup = (Units in fightRegion matching ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 12 (Brown))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in tempGroup) Equal to 0
Then - Actions
Set tempGroup = (Units in fightRegion matching (((Matching unit) is A Hero) Equal to True))
Set tempPoint = (Center of baseRegion)
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
Or - Any (Conditions) are true
Conditions
(Owner of (Picked unit)) Equal to Player 1 (Red)
(Owner of (Picked unit)) Equal to Player 2 (Blue)
(Owner of (Picked unit)) Equal to Player 3 (Teal)
(Owner of (Picked unit)) Equal to Player 4 (Purple)
(Owner of (Picked unit)) Equal to Player 5 (Yellow)
(Owner of (Picked unit)) Equal to Player 6 (Orange)
Then - Actions
Unit - Move (Picked unit) instantly to tempPoint
Custom script: call RemoveLocation(udg_tempPoint)
Else - Actions
Else - Actions
Custom script: call DestroyGroup(udg_tempGroup)
Option 2
The second option is the one I prefer because it still keeps to moving a specific set of unit variables. If you create a larger map you would doubtless need to have a variable to keep track of each of the Player Heroes anyway, where this option would fit within such a system. It's more precise, if you will.
Init trigger:
SettingUpVariables
Events
Map initialization
Conditions
Actions
Set baseRegion = Region 002 <gen>
Set fightRegion = Region 001 <gen>
Set hero[0] = Blademaster 0011 <gen>
Set hero[1] = Far Seer 0016 <gen>
Set hero[2] = Shadow Hunter 0014 <gen>
Set hero[3] = Shadow Hunter 0015 <gen>
Set hero[4] = Tauren Chieftain 0017 <gen>
Set hero[5] = Far Seer 0013 <gen>
Moving trigger
AllUnitsAreDead
Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
Actions
Set tempGroup = (Units in fightRegion matching ((((Matching unit) is alive) Equal to True) and ((Owner of (Matching unit)) Equal to Player 12 (Brown))))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in tempGroup) Equal to 0
Then - Actions
Set tempPoint = (Center of baseRegion)
For each (Integer A) from 0 to 5, do (Actions)
Loop - Actions
Unit - Move hero[(Integer A)] instantly to tempPoint
Custom script: call RemoveLocation(udg_tempPoint)
Else - Actions
Custom script: call DestroyGroup(udg_tempGroup)
I think i will make my map so people can double click on the hero they wanna play and then Option 2 seems really good. Thanks a lot its a really big help![]()
Just so!Glad to be of help! Good luck with your project