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

[Solved] Spawn random unit spell from ALL the units

Status
Not open for further replies.
Level 1
Joined
Jan 16, 2016
Messages
3
I want to make a spell that would randomly summon ANY unit from the game (well maybe fixed group of units but that contain at least 70 units from the game) my idea was making a unit based on Archimonde...this unit can cast an ability based on Dark Portal that would summon 5 random units from a list containing almost all military units in the game (except heroes)...well as you have guess i got disappointed that Dark Portal only reads the first 10 names in the list of "Summoned units"

I read in other threads about using the If/then/else trigger but those people use it for no more than 6 types...using it for ~70 units will take A LOT of time....is there ANY way to make the game include any unit from a fixed group or just any unit from all the game that doesn't take an eternity to make??

also the "triggering point of ability" thing didn't work for me it kept placing the units at the center of the map
 
Last edited by a moderator:
The easiest way is to create an array of unit-types... e.g.:
  • Set UnitTypes[0] = Footman
  • Set UnitTypes[1] = Paladin
  • ...
Do it for every unit you want in your 'pool' to pick from. When you need to pick a random unit-type, just choose a random number between 0 and the total number of units you've stored, and choose the unit-type at that index.

It may seem tedious, but it is easy and pretty inexpensive.
 
Level 12
Joined
May 22, 2015
Messages
1,051
TBH, the full trigger way is much easier and also much more scalable. If you add more units, you just add them to the list and increase the max value when you choose the unit randomly.

Making the abilities means you will have to do the same tedious work of setting up which abilities should be next. You might have unit overlaps, and you might need to add a whole new ability if you want to add another unit. There's also the issue where you probably won't be able to split the units up evenly among all the abilities (some will have extras or some will have one less or something). Unless you want to do some awkward math, you'd have uneven random chance for the unit types. Not a big deal, but still something to consider.

Also a small correction to PergeandFire's answer, the random number should be from 0 to the total number of units you stored - 1. It's fairly simple though. Just take 0 (the first one you enter) as the minimum, and then put the highest number you used as the maximum. Might have been obvious, though.
 
Level 1
Joined
Jan 16, 2016
Messages
3
Thanks a lot guys but I actually have already done it using a slightly different way than the one you suggested PurgeanFire .....see I scrapped the spell idea and replaced it with a chat message trigger (basically a cheat)...now what i have done is:
if the player types 1 he gets 1 random unit out of 204 units (not all game units included)
if he types 2 he gets 2...all the way to 5....and I add a seperate trigger for hero summoning if the player types h he gets a random hero from among 36 heros...with a random level between 1-10...and 2 totally random items....put 3 additional triggers one of them if you type "i" you get a random item at the center of the camera....second one is if you type "t" all selected units by the typing player are teleported to the center of the camera...and finally type "k" to remove any unit(s) you are selecting (I placed this in order to remove unwanted hero summons by the "h" trigger in order to not clog up the Alter of heroes)
for the summoning i used this way:
Events:
player x(depending on the level) types a chat message containing "1"
Actions:
set summontype = random integer between 1-204
set area= region centered at (target of current camera view) with size 10,10
set me=triggering player
if summontype=1 then do "create 1 footman for "me" at center of "area" facing default" else do nothing
....and so on
I then grouped all these triggers in a folder and then just basically started copy/pasting it into every campaign map basically for fun only (of course I didn't forget adding the variables into every level before pasting)
until now I've injected this idea into both Human and Undead campaigns

anyone think this idea is good and should be uploaded??
 
Level 1
Joined
Jan 16, 2016
Messages
3
Of course I tested all these triggers and all of them work EXACTLY like i wanted them to

what i do is summon 1 hero and 5 random units and attack with them using abilites and stuff (I like using abilities a lot) and just see how much effective would this wave be...in early campaign levels 1 of these can finish the entire level
 
Level 7
Joined
Nov 19, 2015
Messages
283
Thanks a lot guys but I actually have already done it using a slightly different way than the one you suggested PurgeanFire .....see I scrapped the spell idea and replaced it with a chat message trigger (basically a cheat)...now what i have done is:
if the player types 1 he gets 1 random unit out of 204 units (not all game units included)
if he types 2 he gets 2...all the way to 5....and I add a seperate trigger for hero summoning if the player types h he gets a random hero from among 36 heros...with a random level between 1-10...and 2 totally random items....put 3 additional triggers one of them if you type "i" you get a random item at the center of the camera....second one is if you type "t" all selected units by the typing player are teleported to the center of the camera...and finally type "k" to remove any unit(s) you are selecting (I placed this in order to remove unwanted hero summons by the "h" trigger in order to not clog up the Alter of heroes)
for the summoning i used this way:
Events:
player x(depending on the level) types a chat message containing "1"
Actions:
set summontype = random integer between 1-204
set area= region centered at (target of current camera view) with size 10,10
set me=triggering player
if summontype=1 then do "create 1 footman for "me" at center of "area" facing default" else do nothing
....and so on
I then grouped all these triggers in a folder and then just basically started copy/pasting it into every campaign map basically for fun only (of course I didn't forget adding the variables into every level before pasting)
until now I've injected this idea into both Human and Undead campaigns

anyone think this idea is good and should be uploaded??

I think we thought it was more for your own custom spell. I thought you were also trying to avoid the if/then/else (looks like you did a lot of work). No offense but this is quite useless and no one would really want it put into their maps. Most people here make their own custom maps rather than just insert extra cheat codes into the campaign maps.
 
Status
Not open for further replies.
Top