Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Randomly Spawn Unit
Randomly Spawn Unit
Jul 6 2013, 11:38 pm
By: QPreach  

Jul 6 2013, 11:38 pm QPreach Post #1



So I want to bring a unit to a location and it will randomly spawn another unit.
I made the trigger so that whenever a unit goes to the location, another unit spawns immediately.
I want to make it somewhat of a 'tall grass' in Pokemon.

Attachments:
Warp Saga.scm
Hits: 1 Size: 94.59kb



None.

Jul 7 2013, 12:49 am Roy Post #2

An artist's depiction of an Extended Unit Death

Is your question how to do randomization? We have a wiki article covering the subject: http://www.staredit.net/starcraft/Randomization

Just have a trigger with different switch combinations in the conditions for each unit you want to include in the randomization. You can also use a DC as the condition, as described near the bottom of the article (and you can even make the DC increment based on randomized switches if you want to go a step further); this is useful for when you have a number of outcomes that doesn't fit into 2^n combinations.




Jul 7 2013, 1:05 am MetalGear Post #3



Do you want it so that there is a certain chance of a unit being spawned, or a unit spawns every time but the particular unit is random?



None.

Jul 7 2013, 1:13 am QPreach Post #4



@Roy Yes, I'll look into it, thankyou

@MetalGear I want to have a random certain chance of the same unit being spawned



None.

Jul 7 2013, 1:19 am MetalGear Post #5



What % chance exactly?



None.

Jul 7 2013, 1:34 am QPreach Post #6



I'm not so sure, maybe 60%



None.

Jul 7 2013, 1:35 am MetalGear Post #7



Okay and at what refresh rate? 60% chance every second? Every 5 seconds? 10?



None.

Jul 7 2013, 1:38 am QPreach Post #8



Every time that unit dies, there will be a chance that it will spawn again
So I guess the refresh rate is after it dies?



None.

Jul 7 2013, 1:44 am MetalGear Post #9



How will the unit spawn in the first place if the spawn trigger requires a non-existing unit to die?

Think about the logic. You walk into an area, and your triggers say, "has a spawned unit unit died? no, then i won't spawn". So units will never spawn by that logic.



None.

Jul 7 2013, 1:47 am QPreach Post #10



Zzz you have a point. How do I make it when a unit walks in, theres a chance to spawn, and then the trigger can only be refreshed when the spawn dies?



None.

Jul 7 2013, 1:48 am Azrael Post #11



So you want it to check once, and if the 40% odds happen and it doesn't spawn, then it'll never check again? Or it waits until the person leaves the area and reenters? Or, like in Pokemon, it waits until the person moves? Or if they stand there, will it keep trying every X seconds until something spawns? I think those are pretty much all the options.

Quote from MetalGear
How will the unit spawn in the first place if the spawn trigger requires a non-existing unit to die?

By checking for when the unit doesn't exist; not having spawned and being dead are the same thing




Jul 7 2013, 1:50 am QPreach Post #12



I want to make when you are just standing there and wait for the spawn to appear



None.

Jul 7 2013, 1:52 am Azrael Post #13



Quote from QPreach
I want to make when you are just standing there and wait for the spawn to appear

Right, so you just stand there, and the 40% chance happens so it doesn't spawn. Will it never spawn now, or will it try again after X seconds?




Jul 7 2013, 1:53 am QPreach Post #14



It will try again after X seconds



None.

Jul 7 2013, 1:53 am Azrael Post #15



How many seconds is X? This is the refresh rate that MetalGear mentioned.




Jul 7 2013, 1:55 am QPreach Post #16



I guess 2 seconds would do



None.

Jul 7 2013, 2:08 am Azrael Post #17



What you'll need to do is randomize a number of switches, and then check their outcomes. For a 40% chance of failure, what you'll probably want to do is randomize 3 switches. This has 8 possible outcomes, and you'll want to map 3 of them to failure (37.5% chance; if you want it closer to 40%, you'll need to use more switches and map more of their outcomes).

You can do it like this (using Hydralisk for the spawning unit).

Trigger
Players
  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Conditions
  • Current Player has suffered exactly 0 deaths of Cantina.
  • Current Player brings at least 1 [men] to Spawn Location.
  • Player 8 brings exactly 0 Hydralisk to Spawn Vicinity.
  • Actions
  • Randomize Switch 1.
  • Randomize Switch 2.
  • Randomize Switch 3.
  • Preserve Trigger.

  • Trigger
    Players
  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Conditions
  • Switch 1 is Set.
  • Switch 2 is Clear.
  • Switch 3 is Clear.
  • Current Player has suffered exactly 0 deaths of Cantina.
  • Actions
  • Set deaths of Cantina to 24 for Current Player.
  • Preserve Trigger.

  • Trigger
    Players
  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Conditions
  • Switch 1 is Clear.
  • Switch 2 is Set.
  • Switch 3 is Clear.
  • Current Player has suffered exactly 0 deaths of Cantina.
  • Actions
  • Set deaths of Cantina to 24 for Current Player.
  • Preserve Trigger.

  • Trigger
    Players
  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Conditions
  • Switch 1 is Clear.
  • Switch 2 is Clear.
  • Switch 3 is Set.
  • Current Player has suffered exactly 0 deaths of Cantina.
  • Actions
  • Set deaths of Cantina to 24 for Current Player.
  • Preserve Trigger.

  • Trigger
    Players
  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Conditions
  • Current Player has suffered exactly 0 deaths of Cantina.
  • Current Player brings at least 1 [men] to Spawn Location.
  • Player 8 brings exactly 0 Hydralisk to Spawn Vicinity.
  • Actions
  • Create 1 Hydralisk for Player 8 at Spawn Location.
  • Preserve Trigger.

  • Trigger
    Players
  • Player 1
  • Player 2
  • Player 3
  • Player 4
  • Conditions
  • Current Player has suffered at least 1 deaths of Cantina.
  • Actions
  • Subtract 1 death of Cantina for Current Player.
  • Clear Switch 1.
  • Clear Switch 2.
  • Clear Switch 3.
  • Preserve Trigger.

  • This assumes you're checking separately for each player. If you want a single timer that checks for everyone simultaneously, just make these triggers for Player 8 (or whichever player is the computer), and have it checking for when "Force 1 brings at least 1 [men] to Spawn Location" instead of Current Player.

    Post has been edited 1 time(s), last time on Jul 7 2013, 2:16 am by Azrael.




    Jul 7 2013, 2:32 am QPreach Post #18



    Hmm I see, so lets say I want to increase the % to 50, I should just use 2 switches instead right?



    None.

    Jul 7 2013, 2:34 am lil-Inferno Post #19

    Just here for the pie

    You can just use one switch for 50%.




    Jul 7 2013, 2:50 am Dem0n Post #20

    ᕕ( ᐛ )ᕗ

    Quote from QPreach
    Hmm I see, so lets say I want to increase the % to 50, I should just use 2 switches instead right?
    A switch has two settings: set and cleared. You can use the "Set Switch" action to randomize the switch, making it either become cleared or set (aka 50%). Adding a second switch would change the chance to 25%. You should really read the page that Roy linked about randomization.




    Options
      Back to forum
    Please log in to reply to this topic or to report it.
    Members in this topic: None.
    [01:53 am]
    Ultraviolet -- :lol:
    [06: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.
    [06: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
    [06: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?
    [06:49 pm]
    Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
    [06:48 pm]
    Vrael -- On this Topic, I could definitely use some Introductions.
    [06:48 pm]
    Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
    [06:47 pm]
    Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
    [06:45 pm]
    NudeRaider -- Vrael
    Vrael shouted: I've also recently becoming interested in Carpet Cleaning, but I'd like to find someone with a reputation for unparalleled quality and attention to detail.
    beats me, but I'd make sure to pick the epitome of excellence and nothing less.
    [06:41 pm]
    Vrael -- It seems like I may need Introductions to multiple companies for the Topics that I care deeply about, even as early as Today, 6:03 am.
    Please log in to shout.


    Members Online: Oh_Man, jun3hong