All Random Function

For fulfilled maps that most likely don't work on the latest patch (1.24 or later).

Moderator: Cheaters

Wreked
Member
Posts: 87
Joined: April 29th, 2007, 8:10 pm

All Random Function

Post by Wreked »

Alright well i got emboldened by my success making the gold-lumber trigger so im trying for an all random. Now what im guessing i would have to do, is add all of my heroes to an Player Group Array and then somehow give them out, is this correct? And if it is how would i be able to?

Thanks
Wreked

EDIT: Ok this is what i got so far

Code: Select all

Event-
Map Initialization

Conditions-

Actions-
Unit Group - Pick every unit in(Units in ARHeroes <gen>) and do actios
                  Loop - Actions
                              Unit Group -  Add (Picked Unit) to RandomHeroes(1)
Alright and ARHeroes = the region where my heroes are located and Random Heroes is my unit group variable.
Peace yall hit me up at Mamou115[w3e] on US East!
User avatar
CrackUps
Member
Posts: 96
Joined: October 6th, 2007, 12:21 am

Re: All Random Function

Post by CrackUps »

Your going to have to define each hero in a unit array for example

Define Heroes
Events
Map initialization
Conditions
Actions
Set NumberOfHeroes = 4
Set RandomAmount = 4
Set Hero_Array[1] = Alchemist
Set Hero_Array[2] = Naga Sea Witch
Set Hero_Array[3] = Tinker
Set Hero_Array[4] = Beastmaster
For each (Integer A) from 1 to 4, do (Actions)
Loop - Actions
Set RandomData[(Integer A)] = (Integer A)

And Then

Events
Player - Player 1 (Red) types a chat message containing -random as An exact match
Conditions
(Number of units in (Units owned by (Triggering player) matching (((Matching unit) is A Hero) Equal to True))) Equal to 0
Actions
Set RandomHero = (Random integer number between 1 and RandomAmount)
Unit - Create 1 Hero_Array[RandomData[RandomHero]] for (Triggering player) at ((Triggering player) start location) facing Default building facing degrees
Set RandomData[RandomHero] = RandomCount
Set RandomCount = (RandomCount - 1)


The highlighted area is whats going to randomly pick and create your hero, Since you've listed all your heroes in Hero_Array it will pick a Hero_Array random number between 1 and the total amount of Heroes you've defined.
Wreked
Member
Posts: 87
Joined: April 29th, 2007, 8:10 pm

Re: All Random Function

Post by Wreked »

Ok thank you very much! Ill try it and post how it works.

EDIT: Worked like a dream, i needed to make some modifications so that it would work for all players in the team, but it didnt take to long.
Peace yall hit me up at Mamou115[w3e] on US East!
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: All Random Function

Post by Aero »

CrackUps wrote:Your going to have to define each hero in a unit array for example
Loop - Actions
Set RandomData[(Integer A)] = (Integer A)
What is the point of this...?

RandomData[1]=1
RandomData[2]=2
...
RandomData[4]=4

This is what will occur...

Since this is the case, RandomData serves no purpose at all.