Most effects and behaviours have a Chance field. Setting this to 0.5 will cause the effect to have a 50% chance of occurring.
If you created a two behaviours each with a 50% chance to 1) create a Marine or 2) create a Medic, then in some cases you might have both a Medic and a Marine being created.
I think if you place both 'Spawn Unit' effects in a Set object with equal chances of occurring. No that wouldn't work either.
There should probably be some sort of search area going on for something like this... I would guess. And then have some sort of changeable positive result so you could have an effect to create each type of unit, and then use the search area effect to determine which will be created. If your positive result can be modified somehow, that would allow you to use that to change which unit is being spawned and apply something random to that.
It's all theory, but that's where I would start digging.
I was looking through a validator that might work for you but turned up fruitless.
The 'Condition' validator seems like it might work. Except the core, melee and multi mods don't give you an example on how to get it to work.
Derrp. Just read the playpongs' reply in more detail:
You want an effect that will Spawn Unit A with a 50% chance of happening.
Then a Search Area that will search for Unit A (tiny area, at point of unit creation)
Tied to a Validator that returns True or False.
If Unit A isn't there, spawn Unit B.
I've never created any units with data so far, but there should be different ways to do it. I'd try:
First of all, make 2 unique effects of type "Create Unit" which create the 2 units you need (add the unit to "Unit: Spawn Unit" in the effect).
After that, create an effect of type "Set", add the both effects to it (in the "Effect: Effects" field), check the "Effect - Random" value and set min and max count to 1.
That's it. I haven't tried it, but this should work. (to spawn the unit just run the "Set" effect somewhere, from a behavior, an ability or w/e you prefer)
Bommes - your version will either
1 - Create 1 of each unit.
or
0 - Create no units at all.
Many ways to skin a cat :p
No, it won't, because the min and max count is set to 1, which means only 1 effect of the list will be run :)
Because Random is checked it will take a random one, if random is unchecked it starts from the top of the list and goes downwards.
This works perfectly, thanks a lot!
(i suppose that i could change the chance by adding redundant effects, like 2xEffectA and 1xEffectB should give EffectA a 66% chance to occur)
Hmm you could use this then to make a blind warp spell as well... to teleport a unit to a random offset from a list of offsets from it's original point? cool.
If you want a random offset for the same effect (doesnt matter which effect) I would always use a "Create Persistent" effect which runs the desired effect as a periodic effect with period count 1, random offset checked and the random offsets added into the "Random Offset" value list in the Persistent effect :)
You could also create a ton of effects and use the "Set" effect as above I suppose, but that gets really messy once you need more than 2 or 3 Offsets, doing it with a Persistent on the other hand takes like a minute to set up and only needs 1 additional effect.
Do you know if this is possible? And if it is, how?
@qwertziopuy: Go
Yup.
Most effects and behaviours have a Chance field. Setting this to 0.5 will cause the effect to have a 50% chance of occurring.
If you created a two behaviours each with a 50% chance to 1) create a Marine or 2) create a Medic, then in some cases you might have both a Medic and a Marine being created.
I think if you place both 'Spawn Unit' effects in a Set object with equal chances of occurring.No that wouldn't work either.Sorry, it's late :D
@Nardival: Go
There should probably be some sort of search area going on for something like this... I would guess. And then have some sort of changeable positive result so you could have an effect to create each type of unit, and then use the search area effect to determine which will be created. If your positive result can be modified somehow, that would allow you to use that to change which unit is being spawned and apply something random to that.
It's all theory, but that's where I would start digging.
@playpong: Go
I was looking through a validator that might work for you but turned up fruitless.
The 'Condition' validator seems like it might work. Except the core, melee and multi mods don't give you an example on how to get it to work.
Derrp. Just read the playpongs' reply in more detail:
You want an effect that will Spawn Unit A with a 50% chance of happening.
Then a Search Area that will search for Unit A (tiny area, at point of unit creation)
Tied to a Validator that returns True or False.
If Unit A isn't there, spawn Unit B.
I've never created any units with data so far, but there should be different ways to do it. I'd try:
First of all, make 2 unique effects of type "Create Unit" which create the 2 units you need (add the unit to "Unit: Spawn Unit" in the effect).
After that, create an effect of type "Set", add the both effects to it (in the "Effect: Effects" field), check the "Effect - Random" value and set min and max count to 1.
That's it. I haven't tried it, but this should work. (to spawn the unit just run the "Set" effect somewhere, from a behavior, an ability or w/e you prefer)
@Bommes: Go
Bommes - your version will either
1 - Create 1 of each unit.
or
0 - Create no units at all.
Many ways to skin a cat :p
No, it won't, because the min and max count is set to 1, which means only 1 effect of the list will be run :)
Because Random is checked it will take a random one, if random is unchecked it starts from the top of the list and goes downwards.
@Bommes: Go
This works perfectly, thanks a lot! (i suppose that i could change the chance by adding redundant effects, like 2xEffectA and 1xEffectB should give EffectA a 66% chance to occur)
@qwertziopuy: Go
Hmm you could use this then to make a blind warp spell as well... to teleport a unit to a random offset from a list of offsets from it's original point? cool.
@playpong: Go
If you want a random offset for the same effect (doesnt matter which effect) I would always use a "Create Persistent" effect which runs the desired effect as a periodic effect with period count 1, random offset checked and the random offsets added into the "Random Offset" value list in the Persistent effect :)
You could also create a ton of effects and use the "Set" effect as above I suppose, but that gets really messy once you need more than 2 or 3 Offsets, doing it with a Persistent on the other hand takes like a minute to set up and only needs 1 additional effect.