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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top