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

Creating random unit

Status
Not open for further replies.
Level 4
Joined
Apr 26, 2011
Messages
65
Is there any script that creates completely RANDOM unit (all races including neutral) for random player? I haven't found anything.
 
Closest thing I know of is put all units in an array and load a random unit using a random integer.

Also this should be in the World Editor Help Zone Forum.
World Editor Help Zone Ask general questions about World Editor features and use in this forum. If you need help fixing a trigger, please post it in Triggers & Scripts. Please review the forum rules before posting.
 
Level 4
Joined
Apr 26, 2011
Messages
65
I posted this 3 years ago already.

  • Unit - Create 1 (Random level -1 creep unit type) for ...
seems to be the solution. The problem is this trigger only creates neutral units and only from map's tileset (if I create Loarderon summer map, Loarderon summer creeps will be created)... This means I'd need to change every unit's tileset to "All tilesets" and change all units (human,orc,undead...) to neutral.

This would take hours to do it manually in WE, so is there any way to open map, in, hm, text editor or excel and edit those data?
 
Level 25
Joined
May 11, 2007
Messages
4,650
Just create a a unit-type array in the Trigger editor.

Set UnitType[0] = Peasant
Set UnitType[1] = Footman
Set UnitType[2] = Troll Headhunter
Set UnitType[3] = Ogre
Set UnitType[4] = Archer
......

then when you want a random unit just "Create 1 unitType[random integer between 0 and 4] at tempPoint1.

This way you also avoid creating unwanted units like heroes, buildings, critters, neutral buildings, gold mines, etc.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I see absolutely no reason to ever create a fully random unit in a balanced map. It could create anything from Archimonde, a insanely rigged divine armor AoE chaos damage hero with infinite spawns to a sheep which has a few HP and is totally harmless. You will need at least some system to create a random unit that is in the appropriate power range.

This would best be done using an array of unit types (or integer in the case of pure JASS). You then fill the array sequentially starting at index 0 with all the unit types you want to be randomly closable. You can choose a random unit type by a simple random integer index from 0 to the largest index number.

For multiple random tiers (great for RPGS where you do not want trash as a random choice late game or end game content as a random choice early game) you order the array in progressively increasing power. You then use a separate integer array that marks the separation of tiers (where one tier ends and the other starts). For variance (a choice between weaker and stronger tiers only around a certain tier) you can use an offset when accessing the tier array. The unit type created is then a random integer between certain tier values which you use the tier array to lookup.

The tier approach described is what Dungeon of Doom used for random monsters but with less complexity (no tiers, just progressive monsters in the list).
 
Level 4
Joined
Apr 26, 2011
Messages
65
Just create a a unit-type array in the Trigger editor.

Set UnitType[0] = Peasant
Set UnitType[1] = Footman
Set UnitType[2] = Troll Headhunter
Set UnitType[3] = Ogre
Set UnitType[4] = Archer
......

then when you want a random unit just "Create 1 unitType[random integer between 0 and 4] at tempPoint1.

This way you also avoid creating unwanted units like heroes, buildings, critters, neutral buildings, gold mines, etc.

Thanks for idea, but still, it would take me pretty long time to include every Warcraft III unit into this array...

I see absolutely no reason to ever create a fully random unit in a balanced map. It could create anything from Archimonde, a insanely rigged divine armor AoE chaos damage hero with infinite spawns to a sheep which has a few HP and is totally harmless. You will need at least some system to create a random unit that is in the appropriate power range.

This would best be done using an array of unit types (or integer in the case of pure JASS). You then fill the array sequentially starting at index 0 with all the unit types you want to be randomly closable. You can choose a random unit type by a simple random integer index from 0 to the largest index number.

For multiple random tiers (great for RPGS where you do not want trash as a random choice late game or end game content as a random choice early game) you order the array in progressively increasing power. You then use a separate integer array that marks the separation of tiers (where one tier ends and the other starts). For variance (a choice between weaker and stronger tiers only around a certain tier) you can use an offset when accessing the tier array. The unit type created is then a random integer between certain tier values which you use the tier array to lookup.

The tier approach described is what Dungeon of Doom used for random monsters but with less complexity (no tiers, just progressive monsters in the list).

I do want fully random unit from whole WC3. Okay, except buildings and the ones with god armor. Is there a way?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Okay, except buildings and the ones with god armor. Is there a way?
You will need to make a list as LordDz described or use a third party tool (LUA for JNGP used to do this but no longer works so is not an option, some other on-save script could also do it). I have no example of a working third party tool that can help next to one you would need to program yourself.
 
Status
Not open for further replies.
Top