Alright, I think I got it.
Please take note that I am writing this freely, since I can not access the editor right now. Some actions etc might be labeled incorretly here, but I am pretty confident, that they all exist.
First off, to make triggers easier, we will need a variable of type Player Group [PLAYERGROUP] in which every Player that can/should be attacked by the computer is part of it, as long as that Player is in the game. I can not write this for you since I do not know required details of the map.
We also need a variable-array of type Unit [PLAYERUNIT[X]] which contains the "hero"-units of the players 1-8. You would be best setting this up at the start of the map.
For this example, Player 10 is the one computer, Players 1 to 8 are the human players being attacked.
I further assume, that you have already created a trigger that spawns these units.
Add an action called "Run Trigger" in that one and select the new trigger I describe below:
Events and Conditions are left empty.
Local Variables:
Integer :: Players = 0 // Will hold the number of active players in the game
Integer :: UnitsPerPlayer = 0 // How many units will attack each player (50, in your example, given there were 400 units
Integer :: NumberOfUnits = 0 // Number of units by the computer
Integer Array :: UnitsAttackingPlayer[8] = 0 // This array will hold the number of units already attacking the player X, where X is the index.
Double :: forceRange = 4.0 // The range in which units are marked as nearby and thus are forced to attack that nearby player unit
Unitgroup :: alreadyAttacking = Empty Unitgroup // The unitgroup in which we throw all units that already received a command
Actions:
// We set the variables
Set Variable : Set 'Players' to (Number of Players in Playergroup ( active players))
Set Variable : Set 'NumberOfUnits' to (Number of Units in Unitgroup ( Units in Region matching conditions ( Any Units by Player 10 (...))))
Set Variable : Set 'UnitsPerPlayer' to (Arithmetic (Integer) ( NumberOfUnits / Players ))
// We now force enemies to attack nearby players
foreach Player in Playergroup (PLAYERGROUP)
{
Pick each unit in unitgroup ( units in region matching conditions ( Any Units by player 10 in (circle to region ( Point ( Position of unit PLAYERUNIT[pickedPlayer]) radius forceRange)))
{
Issue command (targeting Unit) : picked Unit Attack PLAYERUNIT[picked Player];
Add Unit to Unitgroup : picked Unit to alreadyAttacking;
Modify Variable (Integer) : Modify UnitsAttackingPlayer[picked Player] +1;
}
}
// Now we probably have units left not having a new attack
Pick each units in Unitgroup ( Any Unit by Player 10 in Entire Map)
{
// We add an If to see if the unit is having a target already
if(unit is in unitgroup (picked unit in alreadyAttacking == false))
{
foreach Player in Playergroup (PLAYERGROUP)
{
if(unitsAttackingPlayer[picked Player] < UnitsPerPlayer)
{
Issue command (targeting Unit) : picked Unit Attack PLAYERUNIT[picked Player];
Add Unit to Unitgroup : picked Unit to alreadyAttacking;
Modify Variable (Integer) : Modify UnitsAttackPlayer[picked Player] +1;
}
}
}
}
Now this is a draft, but it should work.
Summing up:
- Let all "nearby" units attack them and add those units into a group
- Check if the unit is in that group and if not, let it attack a player.
Note:
This system assumes that Pick each Unit in Unitgroup picks "random" units, which it does if I remember correclty.
Please report errors in the Staredit.Network forum.