Random Unit
Oct 8 2007, 4:50 pm
By: Cloaked-Dragon  

Oct 8 2007, 4:50 pm Cloaked-Dragon Post #1



I'm just wondering, how do you make a random unit using triggers? I would really appreciate some help.
Thanks!



None.

Oct 8 2007, 5:00 pm Joshgt2 Post #2



I would guess that it would have to be a long series of switches depending on how many units are going to be picked at random. The way I would do it is set a bunch of switches to create a certain type of unit with each switch. Then once all of that is done, I would make another trigger that once your condition was met, then you would "Random" all of the unit switches. I think this would allow a switch to be set at random which in turn would allow the unit to be made. I think this would be very complicated but I think it could work like that



None.

Oct 8 2007, 5:31 pm Cloaked-Dragon Post #3



Yeah...
I actually tried that but nothing happened when i tested it...



None.

Oct 8 2007, 6:24 pm payne Post #4

:payne:

Let's say you want to have a random spawn of 4 different units.
First of all, you implement the trigger that will randomize :
Condition : Switch 3 is Clear
Action :
Randomize 'Switch 1'
Randomize 'Switch 2'
Toggle 'Switch 3'
Wait 'x' miliseconds
Preserve Trigger

Then, you have to detect wich unit you'll spawn... there is four possibilities that I'll represent by the trigger you need to add :

Condition :
Switch 1 is Set
Switch 2 is Set
Switch 3 is Set
Action :
Create Terran Marine at Spawn
Toggle 'Switch 3'
Preserve Trigger

Condition :
Switch 1 is Set
Switch 2 is Clear
Switch 3 is Set
Action :
Create Terran Ghost at Spawn
Toggle 'Switch 3'
Preserve Trigger

Condition :
Switch 1 is Clear
Switch 2 is Set
Switch 3 is Set
Action :
Create Protoss Zealot at Spawn
Toggle 'Switch 3'
Preserve Trigger

Condition :
Switch 1 is Clear
Switch 2 is Clear
Switch 3 is Set
Action :
Create Protoss Dragoon at Spawn
Toggle 'Switch 3'
Preserve Trigger

Simple heh?

As you can see, it's if it was a binary condition `:
If 00 then...
If 01 then...
If 10 then...
If 11 then...
0 = cleared, 1=setted

That's it...

Oh... and let's say you use 3 switches, you'll have a possibility of 8 units.
4 Switches: 16 Outcomes
5 Switches: 32 Outcomes
6 Switches: 64 Outcomes
7 Switches: 128 Outcomes
8 Switches: 256 Outcomes
9 Switches: 512 Outcomes
10 Switches: 1024 Outcomes
11 Switches: 2048 Outcomes
12 Switches: 4096 Outcomes
13 Switches: 8192 Outcomes
14 Switches: 16384 Outcomes
15 Switches: 32768 Outcomes
16 Switches: 65536 Outcomes
(This table is from a Maplantis Wiki)

Oh... and just a last thing : let's say you want to use 4 switches cause you want to ahve a spawn of 10 different units, you HAVE to implement triggers of the 2 possibilities that there is no spawn...

Example with 2 switches (spawn of 3 units and 1 is nothing) :

Condition : Switch 3 is Clear
Action :
Randomize 'Switch 1'
Randomize 'Switch 2'
Toggle 'Switch 3'
Wait 'x' miliseconds
Preserve Trigger

Condition :
Switch 1 is Set
Switch 2 is Set
Switch 3 is Set
Action :
Create Terran Marine at Spawn
Toggle 'Switch 3'
Preserve Trigger

Condition :
Switch 1 is Set
Switch 2 is Clear
Switch 3 is Set
Action :
Create Terran Ghost at Spawn
Toggle 'Switch 3'
Preserve Trigger

Condition :
Switch 1 is Clear
Switch 2 is Set
Switch 3 is Set
Action :
Create Protoss Zealot at Spawn
Toggle 'Switch 3'
Preserve Trigger

Condition :
Switch 1 is Clear
Switch 2 is Clear
Switch 3 is Set
Action :
Set 'Switch 3'
Preserve Trigger


There we go...

Hope I've helped you!

Post has been edited 2 time(s), last time on Oct 8 2007, 6:37 pm by payne.



None.

Oct 8 2007, 6:33 pm NudeRaider Post #5

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

The above would work just fine but one thing:
Remove the wait and use a death counter if you want a delay.

Because else your would run into timing, trigger order, and/or wait block problems.
General rule: NEVER use waits on a preserved trigger. They cause far too much trouble.




Oct 8 2007, 6:36 pm payne Post #6

:payne:

True, but writing a DC timer system would have been long...



None.

Oct 8 2007, 10:12 pm JamaL Post #7



Death Counters are a lot easier.

Have a system where it adds one death of a unit, and then when the deaths of this certain unit gets to, say, 32, set them back to 0. Make sure you have this on a preserve trigger, so it is constantly going from 1 to 32.

Now, all you have to do it make 32 different triggers. The conditions on all of them will be the same, except they will be a different amount of deaths.

Say..

Player 7 has suffered exactly 13 deaths of unit.

Create 1 Dragoon at Location

..and you would do this for every unit that you wanted to be 'randomly' spawned.

Of course, switches are more random, but they aren't completely random, either.



None.

Oct 8 2007, 11:28 pm NudeRaider Post #8

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from JamaL
Death Counters are a lot easier.

Have a system where it adds one death of a unit, and then when the deaths of this certain unit gets to, say, 32, set them back to 0. Make sure you have this on a preserve trigger, so it is constantly going from 1 to 32.

Now, all you have to do it make 32 different triggers. The conditions on all of them will be the same, except they will be a different amount of deaths.

Say..

Player 7 has suffered exactly 13 deaths of unit.

Create 1 Dragoon at Location

..and you would do this for every unit that you wanted to be 'randomly' spawned.

Of course, switches are more random, but they aren't completely random, either.
Good idea, but especially when not using hypertriggers this method would be quite predictable.
Here's an idea for more randomization:

Have an area(choose spawn here) where all the units that can be spawned and 1 other unit are executing junk yard dog (= running around criss-cross). Always center a location(chooser) on the not-spawning unit there.

Now always when a unit is to be spawned give 1 [men] at 'chooser' to current player and teleport all [men] for current player at 'choose spawn here' to 'P1 create'

Now 1 unit is missing in the area. So you have to make 1 trigger for every unit and check if it exists in 'choose spawn here'. If not, create it and let it junk yard dog. Execute this for every player, so always when a unit is teleported away is replaced for the next player.

Also make the location 'chooser' quite big to ensure when the triggers are checked there is at least 1 unit in it. If there are more than 1 unit in it the leftmost will be chosen.

The drawback here is you need a computer player for the junk yard dog-ing units.
But you might try to create the missing unit for current player, execute junk yard dog and THEN give it to P9. Dunno if it will continue to run around.




Oct 9 2007, 1:18 am Akar Post #9



OR he can just use this:
:P, owned.
Oh and DCs are more efficient than switches, however, switches are easier to work with.

Attachments:
Example - Randomization.scm
Hits: 1 Size: 39.57kb



None.

Oct 9 2007, 6:49 am NudeRaider Post #10

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from Akar
OR he can just use this:
:P, owned.
Oh and DCs are more efficient than switches, however, switches are easier to work with.
Akar, this is exactly what payne suggested...




Oct 9 2007, 11:33 pm Cloaked-Dragon Post #11



kk, thx a lot guys, i get it now.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[12:52 pm]
Vrael -- if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
[11:17 am]
Zycorax -- :wob:
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[2024-4-27. : 7:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
[2024-4-27. : 6:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
[2024-4-27. : 3:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[2024-4-27. : 1:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[2024-4-26. : 6:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[2024-4-26. : 6:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
Please log in to shout.


Members Online: UndeadStar, Excalibur