HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Random Heros?

08-01-2007, 11:11 AM#1
frozen.
Hey,
my friend has a problem.. he made a map and the players get all rounds random units (non heros). But now he what make a edition with heros.. but he dont know how to spawn heros.
08-01-2007, 11:16 AM#2
Pyrogasm
...what's the difference? You spawn a hero the same way you spawn a unit.
Trigger:
Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable Map Area)) facing (Default Building Facing) degrees
As opposed to this:
Trigger:
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable Map Area)) facing (Default Building Facing) degrees


What's the problem?
08-01-2007, 11:54 AM#3
frozen.
Quote:
Originally Posted by Pyrogasm
...what's the difference? You spawn a hero the same way you spawn a unit.
Trigger:
Unit - Create 1 Paladin for Player 1 (Red) at (Center of (Playable Map Area)) facing (Default Building Facing) degrees
As opposed to this:
Trigger:
Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable Map Area)) facing (Default Building Facing) degrees


What's the problem?

No.. not that.. i mean.. random!
It should spawn random heros..
08-01-2007, 12:27 PM#4
Pyrogasm
Right. If you know how to spawn random units, why can't you spawn random heroes?
08-01-2007, 12:32 PM#5
Histenchist
Trigger:
Unit Group - Pick every unit in (Random 10 units from (Units in (Playable map area))) and do (Actions)
Collapse Loop - Actions
Unit - Create 1 (Unit-type of (Picked unit)) for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
How hard can it be?
08-01-2007, 12:52 PM#6
Pyrogasm
Evidently very hard.
08-01-2007, 06:49 PM#7
Nubcookie
Well, it's pretty damn impossible to spawn heros...
08-01-2007, 07:13 PM#8
cohadar
Actually it is, when spawning random units you can just
create a bunch a random units for a player using random number
for example between 1 and 10.

But when you are spawning heroes there is one small difference not mentioned here, he probably wants the heroes to be random but DIFFERENT for each player
and that is moderately complicate algorithm.

You need 2 arrays for that 1 to hold hero numbers
and other to hold randoms

so lets assume that you have 8 heroes: A B C D E F G H
and you have another array with numbers from 1 to 8

A B C D E F G H
1 2 3 4 5 6 7 8

Now what you need to do is randomize second array,
you can do that by using for loop that will switch 1 number and a random one

lets assume you got these random numbers
7 3 5 ...

first you switch 1(first number) and 7(random number)

7 2 3 4 5 6 1 8

then you switch 7(first number) and 3(random number)
3 2 7 4 5 6 1 8

then you switch 3(first number) and 5(random number)
5 2 7 4 3 1 8

as you can see after only 3 switches you get totally random array.

General rule, if you have X heroes do X switches
between first number and a random number
and you will get a randomized array

In case someone did't notice this operation is opposite of sorting

When you completed creating random array time to create heroes.
If your array looks like this:
5 2 7 4 3 1 8
and you have 4 players you just give
1 player hero(5)
2 player hero(2)
3 player hero(7)
4 player hero(4)
...

Hope that helps.
08-01-2007, 10:28 PM#9
botanic
add x units to to unit group then

For intiger A 1-12 (or w/e)

pick random unit from unit group

create unit picked unit owned by player Intiger A

remove last created unit from unit group
08-02-2007, 07:19 AM#10
cohadar
Adding all heroes to the unit group might not be that practical.

1. They have all to be created on the map,
than after you pick 12 of them you have to destroy the rest.
Then since this guy is doing hero assignment periodically
he has to create all heroes on the map every time he wants
to give random ones ....

2. If it is done on map startup and the heroes are not preloaded
the game will simply die from lag.

3. I am not sure how truly random is that method
you would probably get the same combination of heroes every time.
08-02-2007, 07:34 AM#11
Tide-Arc Ephemera
Quote:
Originally Posted by Histenchist
Trigger:
Unit Group - Pick every unit in (Random 10 units from (Units in (Playable map area))) and do (Actions)
Collapse Loop - Actions
Unit - Create 1 (Unit-type of (Picked unit)) for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
How hard can it be?

I actually like that method... it can be integrated with preloading...
08-02-2007, 07:34 AM#12
Pyrogasm
It's random, cohadar. And it's a lot simpler than your method, too.
Quote:
Originally Posted by cohadar
2. If it is done on map startup and the heroes are not preloaded
the game will simply die from lag.
Not exactly; that is a way of preloading if you know what you're doing.
08-02-2007, 07:45 AM#13
cohadar
You were not paying attention,
his game has random heroes periodically
probably every 5 minutes or something
(some kind of arena or footy no doubt)

and creating all heroes over the map just to get a new random 12
is an example of lazy programming.
besides they will show on minimap and you would have to put them in a separate region
when creating bunch of them so they don't interfere with game

Besides I would like to see you make
a deathmatch (-ardm from dota) type of game with that method.
08-02-2007, 08:37 AM#14
Pyrogasm
Why not do it with unitpools then? That surely makes much more sense as that's what unitpools are used for...
08-02-2007, 09:55 AM#15
cohadar
Well I never worked with unit pools so I don't know really...
But if you can both add and remove units to them then I guess
you could do it that way.

care to give some unitpool code?