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

Mode random??

Status
Not open for further replies.
Level 28
Joined
Mar 25, 2008
Messages
2,955
well it's based on random integers, like "If random integer from 1 to (your number of heroes) equal to 1 then create one *herotype* for player 1" and so on.
Just set a random integer with an array in wwhich all players are stored (e.g. rnd_int[Integer A]) and make if/then/else constructions. If you'd like further informations, post it :)
 
Last edited:
Level 18
Joined
Aug 13, 2007
Messages
1,584
Well, listen.

Then make 3 triggers:

1. Let's say you're making an allrandom mode with the default WC3 heroes. Create the variables for them.

Create a variable called UnitType. Set Variable Type to Unit Type and check "Array".

  • Variables
    • Events
      • Map Initialization
    • Actions
      • All - Set UnitType [1] to Archmage
      • All - Set UnitType [2] to Mountain King
      • All - Set UnitType [3] to Paladin
      • All - Set UnitType [4] to Blood Mage
      • All - Set UnitType [5] to Blademaster
      • All - Actions for all other hero types
      • All - Set UnitType [24] to Firelord
So you have all hero types as variables.

EXPLANATION: Now you have all unit-types of heroes as variables. In the final trigger each playing slot will be given a random unit-type according to the number in the square brackets.

2. Then you need to make the system give heroes to the playing slots only, right?

Create a variable called PlayingPlayers (or whatever). This is NOT an array variable. Its type is Player Group.

Create another variable named Player. Its type is "Player". It IS an array variable.

Then... make the following trigger:

  • Player Check
    • Events
      • Map Initialization
    • Actions
      • All - If/Then/Else Actions
        • If - Conditions
          • Player - Status of Player 1 (Red) Equal to Is Playing
        • Then - Actions
          • Player Group - Add Player 1 (Red) to PlayingPlayers
          • All - Set Player 1 (Red) to Player [(Number of players in PlayingPlayers) + 1]
          • General - Wait 0.01 seconds
        • Else - Actions
          • All - Do Nothing
      • All - If/Then/Else Actions
        • If - Conditions
          • Player - Status of Player 2 (Blue) Equal to Is Playing
        • Then - Actions
          • Player Group - Add Player 2 (Blue) to PlayingPlayers
          • All - Set Player 2 (Blue) to Player [(Number of players in PlayingPlayers) + 1]
          • General - Wait 0.01 seconds
        • Else - Actions
          • All - Do Nothing
      • All - Actions for all other players
      • All - If/Then/Else Actions
        • If - Conditions
          • Player - Status of Player 12 (Brown) Equal to Is Playing
        • Then - Actions
          • Player Group - Add Player 12 (Brown) to PlayingPlayers
          • All - Set Player 12 (Brown) to Player [(Number of players in PlayingPlayers) + 1]
          • General - Wait 0.01 seconds
        • Else - Actions
          • All - Do Nothing
EXPLANATION: This is the most complicated part. As I said, here you check which players are playing. For each playing player, a numbered variable is given. So if the only players are for example Red, Teal and Orange, the 'PlayingPlayers' group will be as follows:
Player [1] - Player 1 (Red)
Player [2] - Player 3 (Teal)
Player [3] - Player 6 (Orange)
The 0.01 second waiting is implemented so the game can assume the new number of the players in the group. So in the case I've given, Red will have an array number 0 + 1 = 1, Teal will have 1 + 1 = 2, and Orange will have 2 + 1 = 3. Otherwise, with no wait, the player count in the group will always be considered zero, so all players will have an array number 1. Not pleasant.


3. The Allrandom Itself.

  • Allrandom
    • Events
      • Player - Player 1 (Red) (or whatever player you select for host) types a chat message containing "-ar" as an exact match
    • Actions
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [1]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [2]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [3]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [4]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [5]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [6]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [7]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [8]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [9]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [10]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [11]
      • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [12]
EXPLANATION: If the playing slots are, for example, 7, the others cannot be set as variables. Thus, they will be not given any heroes.
 
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
Add to the AllRandom trigger functionality that checks the unit types of previously created units. For instance:

  • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [1]
  • set Hero[1] = Last created unit
  • Unit - Create 1 UnitType[(Random Integer from 1 to 24)] for Player [2]
  • Set Hero[2] = Last created unit
  • While Unit Type of Hero[2] = Unit Type of Hero[1] Do:
    • Unit - Replace Hero[2] by UnitType[(Random Integer from 1 to 24)]
That's pseudocode though. You'll need jass or advanced gui knowledge to make a while loop. Even then, a more efficient way most certainly excists.
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
Or make a unit group, put in all units of the same unit type -> Pick every unit in playable map area matching (unit-type of matching unit) equal to (unit-type of (last created unit)) and do if the number of this unit group is greater than 1, pick 1 random unit of this group and replace it by the a random one. (Random integer between 1 and 24 i.e.)
 
Status
Not open for further replies.
Top