Working with RANDOM!! HELP!!

JuiceBox

New Member
Reaction score
13
How can I use "randoms" in my map?
I'm making a boss battle game where there's 10 peasants in a 32x32 map and after 5 seconds of game time, 1 of them will become an uber-powered boss while the others become a random hero from the WarCraft 3 inventory. How do I do this?

Oh and is it possible that after the game ends (either the boss is killed or the heroes are killed) to restart the match but doing the random thing all over again but a little different this time (different peasants for different heroes/boss)?

WILL GIVE +1 REP FOR HELP!! :D
 

Emu.Man00

New Member
Reaction score
41
Heres the simple way that I'd do it. Havn't used the world editor much recently so it might be a little rusty ;)

-set heroes[1] = dread lord
-set heroes[2] = archmage
etc...
-set totalHeroes = *number of hero types in the array*
-set tempGroup = units in playable map of type peasent
-unit - replace random unit from tempGroup with a "uber-powered boss" using new unit's max life and mana
-set tempGroup = units in playable map of type peasent
-pick every unit in tempGroup
replace picked unit with heroes[random integer between 1 and totalHeroes] using new unit's max life and mana
-call DestroyGroup(tempGroup)


And to reset it just pick every unit in map and remove them, null all variables, and run all the init triggers again (assuming you dont use any preplaced units)
 

JuiceBox

New Member
Reaction score
13
Heres the simple way that I'd do it. Havn't used the world editor much recently so it might be a little rusty ;)

-set heroes[1] = dread lord
-set heroes[2] = archmage
etc...
-set totalHeroes = *number of hero types in the array*
-set tempGroup = units in playable map of type peasent
-unit - replace random unit from tempGroup with a "uber-powered boss" using new unit's max life and mana
-set tempGroup = units in playable map of type peasent
-pick every unit in tempGroup
replace picked unit with heroes[random integer between 1 and totalHeroes] using new unit's max life and mana
-call DestroyGroup(tempGroup)


And to reset it just pick every unit in map and remove them, null all variables, and run all the init triggers again (assuming you dont use any preplaced units)

Ahh alright thanks!! However, is it possible so that no heroes on the map are the same? :confused:
 

Emu.Man00

New Member
Reaction score
41
Replace

-pick every unit in tempGroup
replace picked unit with heroes[random integer between 1 and totalHeroes] using new unit's max life and mana

with

-pick every unit in tempGroup
--set tempInt = random integer between 1 and totalHeroes
--replace picked unit with heroes[tempInt] using new unit's max life and mana
--set heroes[tempInt] = heroes[totalHeroes]
--set totalHeroes = totalHeroes - 1

I think it should work.. not 100% sure XD

EDIT: fixed, should work now. I had it backwards.. too tired :)
 

JuiceBox

New Member
Reaction score
13
yes it is basically he just meant if you have 2 different hero in your array then it should be =2

So for example, for -set P_UnitType[1] = Paladin would P_UnitType have an array (the "[1]")?
And how do I do this line: -set totalHeroes = *number of hero types in the array*
 

Yoshii

New Member
Reaction score
74
So for example, for -set P_UnitType = Paladin would P_UnitType have an array?

from the example he used

-set heroes[1] = dread lord
-set heroes[2] = archmage
etc...
-set totalHeroes = *number of hero types in the array*

he meant that in this case -set totalHeroes would be =2 as there is heroes[1] and heroes[2]
in the case you posted P_UnitType may or may not use an array depending if you plan to use more than 1 hero, in this case it would be -set P_unitType[1]=Paladin and -set P_unitType[2]=whatever etc depending on number of hero your map contain
 

JuiceBox

New Member
Reaction score
13
from the example he used

-set heroes[1] = dread lord
-set heroes[2] = archmage
etc...
-set totalHeroes = *number of hero types in the array*

he meant that in this case -set totalHeroes would be =2 as there is heroes[1] and heroes[2]
in the case you posted P_UnitType may or may not use an array depending if you plan to use more than 1 hero, in this case it would be -set P_unitType[1]=Paladin and -set P_unitType[2]=whatever etc depending on number of hero your map contain

Is this right?
Trigger:
  • Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Archmage[1] = Archmage
      • Set Blademaster[2] = Blademaster
      • Set BloodMage[3] = Blood Mage
      • Set CryptLord[4] = Crypt Lord
      • Set DeathKnight[5] = Death Knight
      • Set DemonHunter[6] = Demon Hunter
      • Set Dreadlord[7] = Dreadlord
      • Set FarSeer[8] = Far Seer
      • Set KeeperOfTheGrove[9] = Keeper of the Grove
      • Set Lich[10] = Lich
      • Set MountainKing[11] = Mountain King
      • Set Paladin[12] = Paladin
      • Set PriestessOfTheMoon[13] = Priestess of the Moon
      • Set ShadowHunter[14] = Shadow Hunter
      • Set TaurenChieftain[15] = Tauren Chieftain
      • Set Warden[16] = Warden
      • Set AllHeroes = 16
 

Dest

New Member
Reaction score
26
Is this right?
Trigger:
  • Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Archmage[1] = Archmage
      • Set Blademaster[2] = Blademaster
      • Set BloodMage[3] = Blood Mage
      • Set CryptLord[4] = Crypt Lord
      • Set DeathKnight[5] = Death Knight
      • Set DemonHunter[6] = Demon Hunter
      • Set Dreadlord[7] = Dreadlord
      • Set FarSeer[8] = Far Seer
      • Set KeeperOfTheGrove[9] = Keeper of the Grove
      • Set Lich[10] = Lich
      • Set MountainKing[11] = Mountain King
      • Set Paladin[12] = Paladin
      • Set PriestessOfTheMoon[13] = Priestess of the Moon
      • Set ShadowHunter[14] = Shadow Hunter
      • Set TaurenChieftain[15] = Tauren Chieftain
      • Set Warden[16] = Warden
      • Set AllHeroes = 16

Actually, you make a unit-type variable then you use the variable on all heroes you want. That works either way. AllHeroes isn't needed.
 

JuiceBox

New Member
Reaction score
13
Replace

-pick every unit in tempGroup
replace picked unit with heroes[random integer between 1 and totalHeroes] using new unit's max life and mana

with

-pick every unit in tempGroup
--set tempInt = random integer between 1 and totalHeroes
--replace picked unit with heroes[tempInt] using new unit's max life and mana
--set heroes[tempInt] = heroes[totalHeroes]
--set totalHeroes = totalHeroes - 1

I think it should work.. not 100% sure XD

EDIT: fixed, should work now. I had it backwards.. too tired :)
Where did you get the "heroes" variable?
"--replace picked unit with heroes[tempInt] using new unit's max life and mana"

Trigger:
  • Spawn Heroes
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Random integer number between 1 and AllHeroes)
          • Unit - Replace (Picked unit) with a Archmage[1] using The old unit's relative life and mana


Every hero (all 16) is a unit-type variable with arrays from 1 - 16
ex.
Archmage[1] is a unit-type variable with an array of 1
Blademaster[2] is a unit-type variable with an array of 2
etc...

Am I doing this right? :confused:
 

Dest

New Member
Reaction score
26
Where did you get the "heroes" variable?
"--replace picked unit with heroes[tempInt] using new unit's max life and mana"

Trigger:
  • Spawn Heroes
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Random integer number between 1 and AllHeroes)
          • Unit - Replace (Picked unit) with a Archmage[1] using The old unit's relative life and mana


Every hero (all 16) is a unit-type variable with arrays from 1 - 16
ex.
Archmage[1] is a unit-type variable with an array of 1
Blademaster[2] is a unit-type variable with an array of 2
etc...

Am I doing this right? :confused:

No, you have to say what I said. It doesn't work if you don't do what I just about the variable.
 

Yoshii

New Member
Reaction score
74
whoa ya sorry I really though i had read what you wrote correctly; what you wrote is very wrong one sec.It should be a single Variable Unit Type of array size depending on number of heroes in your map
example variable is Hero of type unit type and array size 2(2 hero in this example) and temp variable of type integer
Hero[1]=Paladin
Hero[2]=Mountain king
Temp=2

now you can do set Hero[Temp] meaning Hero[2]
 

JuiceBox

New Member
Reaction score
13
whoa ya sorry I really though i had read what you wrote correctly; what you wrote is very wrong one sec.It should be a single Variable Unit Type of array size depending on number of heroes in your map

Here I changed it, is this the right one? :confused: :confused:

Trigger:
  • Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[1] = Archmage
      • Set Heroes[2] = Blademaster
      • Set Heroes[3] = Blood Mage
      • Set Heroes[4] = Crypt Lord
      • Set Heroes[5] = Death Knight
      • Set Heroes[6] = Demon Hunter
      • Set Heroes[7] = Dreadlord
      • Set Heroes[8] = Far Seer
      • Set Heroes[9] = Keeper of the Grove
      • Set Heroes[10] = Lich
      • Set Heroes[11] = Mountain King
      • Set Heroes[12] = Paladin
      • Set Heroes[13] = Priestess of the Moon
      • Set Heroes[14] = Shadow Hunter
      • Set Heroes[15] = Tauren Chieftain
      • Set Heroes[16] = Warden
      • Set AllHeroes = 16


EDIT:


Trigger:
  • Spawn Heroes
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Random integer number between 1 and AllHeroes)
          • Unit - Replace (Picked unit) with a Heroes[TempInt] using The new unit's default life and mana
          • Set Heroes[TempInt] = Heroes[AllHeroes]
          • Set AllHeroes = (AllHeroes - 1)
 

Dest

New Member
Reaction score
26
Here I changed it, is this the right one? :confused: :confused:

Trigger:
  • Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Heroes[1] = Archmage
      • Set Heroes[2] = Blademaster
      • Set Heroes[3] = Blood Mage
      • Set Heroes[4] = Crypt Lord
      • Set Heroes[5] = Death Knight
      • Set Heroes[6] = Demon Hunter
      • Set Heroes[7] = Dreadlord
      • Set Heroes[8] = Far Seer
      • Set Heroes[9] = Keeper of the Grove
      • Set Heroes[10] = Lich
      • Set Heroes[11] = Mountain King
      • Set Heroes[12] = Paladin
      • Set Heroes[13] = Priestess of the Moon
      • Set Heroes[14] = Shadow Hunter
      • Set Heroes[15] = Tauren Chieftain
      • Set Heroes[16] = Warden
      • Set AllHeroes = 16


EDIT:


Trigger:
  • Spawn Heroes
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Random integer number between 1 and AllHeroes)
          • Unit - Replace (Picked unit) with a Heroes[TempInt] using The new unit's default life and mana
          • Set Heroes[TempInt] = Heroes[AllHeroes]
          • Set AllHeroes = (AllHeroes - 1)

That's a lot better. I'll try to do my best to help you, hold on.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top