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

Jul 7 2013, 3:06 am MetalGear Post #21



Added Location: "Unit Finder"
Added DC: "Floor Gun Trap" renamed to "Spawn (Timer)"

Attachments:
Warp Sage (edit2).scx
Hits: 3 Size: 94.36kb



None.

Jul 7 2013, 4:23 am Azrael Post #22



Trigger("Player 1","Player 2","Player 3","Player 4","Player 5"){
Conditions:
Bring("Current Player", "Dark Templar (Hero)", "Spawn Lvl 1", Exactly, 0);
Bring("Current Player", "Dark Templar (Hero)", "Spawn Lvl 2", Exactly, 0);

Actions:
Preserve Trigger();
Comment("Spawn Remove");
Remove Unit At Location("Player 6", "Zerg Broodling", All, "Unit Finder");
}

This trigger is pretty inefficient, it's going to spam unnecessary "Brings" conditions and a "Remove" action 12 times a second for the entire game. Additionally, it won't necessarily remove the units which were created, since the units don't need to stay within the Unit Finder location.

Also, the Unit Finder centering action shouldn't be split up into player-specific triggers. It'll make it much more difficult to edit it later.

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




Jul 7 2013, 5:26 am QPreach Post #23



@Demon Sorry, I got confused and I forgot that 2 switches makes 4 and 1 switch makes 2
@MetalGear Thankyou so much, but Im confused about the 26 death counter part in the Activate triggers
@Azrael So should I should delete it, or is there a better way to work this out?



None.

Jul 7 2013, 6:22 am MetalGear Post #24



Quote from Azrael
This trigger is pretty inefficient, it's going to spam unnecessary "Brings" conditions and a "Remove" action 12 times a second for the entire game. Additionally, it won't necessarily remove the units which were created, since the units don't need to stay within the Unit Finder location.

Also, the Unit Finder centering action shouldn't be split up into player-specific triggers. It'll make it much more difficult to edit it later.

It was originally his trigger, I just merged it from two triggers into one. I'm not going to go through his entire map and change every single detail to make it flawless. I don't have the time for that. But you're right for pointing that out, there are technically smoother triggers. Maybe you could take over from this point and make the necessary modifications? To be completely honest though, it's an amateur project (no offense QPreach) and I don't think such precision is needed.

I'm not sure what you mean by the Unit Finder comment. It's a highly efficient system design that saves a lot of trigger space.

Okay, QPreach, I'll briefly explain the process of how it works.

  • At "0" Timer (Spawn), set to "25" and randomize switches 1, 2, 3.
  • During "25" Timer (Spawn), it checks 5 out of 8 possible switch combinations, giving a 62.5% chance that one of these triggers will activate. So every 3 out of 8 times, these triggers will not activate, which leaves Timer (Spawn) at "25" and skips the spawn creation triggers down to the trigger entitled Reset, which moves it onto the countdown.
  • If however one of these switch combinations is found, Timer (Spawn) is set to "26" to basically say "go ahead and spawn".
  • So, if Timer (Spawn) has been set to "26", the trigger entitled Spawn Lvl 1 goes ahead and spawns a unit, and then sets the timer to "24" which begins its countdown.

Does that make more sense now, or do you need me to go more in depth about how the switches work?



None.

Jul 7 2013, 6:50 am QPreach Post #25



@Metalgear none taken ^^

And I somewhat understand the switches; the 5 Activation triggers are the 5/8 outcomes and 25 death counter is to let it go down to 24 death counter for the 2 seconds delay right?



None.

Jul 7 2013, 7:34 am MetalGear Post #26



Yes that's exactly right. Whilst we're here, I'll just give you a quick lesson in using switches.


1 switch = 2 combinations
2 switches = 4 combinations
3 switches = 8 combinations
4 switches = 16 combinations
5 switches = 32 combinations

So, using just two switches, the outcomes would look like this...


Outcome 1
Switch 1 = set
Switch 2 = clear

Outcome 2
Switch 1 = clear
Switch 2 = set

Outcome 3
Switch 1 = set
Switch 2 = set

Outcome 4
Switch 1 = clear
Switch 2 = clear

Cool, that's easy, right? Now, imagine if you used 5 switches for 32 outcomes, and you had to write 32 triggers which each held a different combination. That would be tricky as hell, right? That's why the pros use a special system which assigns a unique number to each combination.

Here, I'll show you how it works. Let's use 3 switches this time, to give 8 possible outcomes. Now, imagine the first switch = 1, the second switch = 2, the third switch = 4, the fourth switch = 8, and so on. Let's say we want to find the 3rd, 4th, and 5th combinations. Simply add the switches, starting from the highest switch working down until you get your combination number, and you set those switches. Look below to see what I mean...


3rd combination
Switch 1WW+1WW+1WWSet
Switch 2WW+2WW+2WWSet
Switch 3WW+4WWWWWiClear

WWWWWWWWWW2 + 1 = 3

4th combination
Switch 1WW+1WWWWWiClear
Switch 2WW+2WWWWWiClear
Switch 3WW+4WW+4WWSet

WWWWWWWWWW4

5th combination
Switch 1WW+1WW+1WWSet
Switch 2WW+2WWWWWiClear
Switch 3WW+4WW+4WWSet

WWWWWWWWWW4 + 1 = 5

Sorry if that's too confusing. It's not essential for you to learn that, but it may provide you some good insight.



None.

Jul 7 2013, 8:18 am QPreach Post #27



So we just add the number of each set switch? I'm not understanding the "highest switch working down"



None.

Jul 7 2013, 9:51 am MetalGear Post #28



Yes, exactly. We add the value of each set switch, and you start from the highest value. For example, if we were using 5 switches, the values would be assigned as such...


Switch 1WW=WW1 value
Switch 2WW=WW2 value
Switch 3WW=WW4 value
Switch 4WW=WW8 value
Switch 5WW=WW16 value

So if we wanted to find out combination 10, for example, we'd start at Switch 5. Here's what you do...

  • Switch 5: Does 16 fit into 10? No. Clear it.
  • Switch 4: Does 8 fit into 10? Yes. Set it. 10 - 8 = 2
  • Switch 3: Does 4 fit into 2? No Clear it.
  • Switch 2: Does 2 fit into 2? Yes. Set it. 2 - 2 = 0
  • Switch 1: Does 1 fit into 0? No. Clear it.

To conclude, combination 10 would look like this...


Switch 1WW=WWClear
Switch 2WW=WWSet
Switch 3WW=WWClear
Switch 4WW=WWSet
Switch 5WW=WWClear




None.

Jul 7 2013, 11:08 am QPreach Post #29



OH! Now that makes sense. Thank you very much, thats very enlightening :D



None.

Jul 7 2013, 1:18 pm Azrael Post #30



Quote from MetalGear
It was originally his trigger, I just merged it from two triggers into one. I'm not going to go through his entire map and change every single detail to make it flawless.

I didn't mean to suggest you should, only that his trigger was inefficient.

Quote from name:MetalGearI
I'm not sure what you mean by the Unit Finder comment. It's a highly efficient system design that saves a lot of trigger space.

I mean, "Center location Unit Finder on unit owned by Current Player" shouldn't be in 5 different triggers owned by 5 different players. It should be in one trigger owned by all five players. Not a big deal, but if anyone needs to modify that trigger in any way, it's going to be five times more work.

Unless you mean the "it won't necessarily remove the units which were created, since the units don't need to stay within the Unit Finder location" comment. If that's the part you're not sure about, I meant that the spawned units are created at Unit Finder, but they don't have to stay there. The player and the spawned unit don't have to stay next to each other, and plenty of things can happen to split them up, especially if it's a ranged unit. Then when the player leaves, it tries to remove the spawned unit at Unit Finder, except Unit Finder is centered on the player's unit, where the spawned unit may not be located.

Also, when checking for percentages, the lower percentage is the one that should generally be checked for, since it saves trigger space and good trigger consolidation makes it easier to edit triggers later. Rather than five triggers checking when it succeeds, there can be three triggers checking when it fails.

Quote from QPreach
@Azrael So should I should delete it, or is there a better way to work this out?

If it's working for you, then that's all you really need to worry about at this stage of mapping. Eventually you'll want to take trigger efficiency into account, where triggers are only running when necessary, and Brings checks are only being done when necessary (StarCraft checks the conditions of a trigger in order, and if one of them is false, it skips the rest without checking them; that's why conditions should have the easiest to check ones first (Switches, then Death Counts, Accumulates, etc) and the hardest to check ones last (Brings)).




Jul 7 2013, 9:10 pm MetalGear Post #31



Quote
"Center location Unit Finder on unit owned by Current Player" shouldn't be in 5 different triggers owned by 5 different players

I see what you mean. Yes, it could be made into one trigger, but it's no issue since it is conveniently coupled with an event of the same function that does need to be unique to each player.

Quote
Unless you mean the "it won't necessarily remove the units which were created, since the units don't need to stay within the Unit Finder location" comment. If that's the part you're not sure about, I meant that the spawned units are created at Unit Finder, but they don't have to stay there. The player and the spawned unit don't have to stay next to each other, and plenty of things can happen to split them up, especially if it's a ranged unit. Then when the player leaves, it tries to remove the spawned unit at Unit Finder, except Unit Finder is centered on the player's unit, where the spawned unit may not be located.

Sorry, I forgot to respond to this. The original trigger removed units from the whole area, which would interrupt other players. But yer, this system is still faulty. One other possibility, QPreach, is that you could have a trigger that gives all the spawn at locations Follow P1, Follow P2, Follow P3, Follow P4, Follow P5, to player 12, then remove all the units for player 6 at the whole spawn area, then give player 12 units back to player 6. So it will only remove the units that are not near other players, and still work for the whole area.

And like Azreal was saying, the less triggers you have being activated the least number of times, is always better, but you'll naturally learn these things as you go along. Just make a conscious effort to keep improving.



None.

Jul 7 2013, 9:17 pm Azrael Post #32



Quote from name:MetalGaer
Quote
"Center location Unit Finder on unit owned by Current Player" shouldn't be in 5 different triggers owned by 5 different players

I see what you mean. Yes, it could be made into one trigger, but it's no issue since it is conveniently coupled with an event of the same function that does need to be unique to each player.

That's what I mean, it isn't more convenient, it's inherently less convenient :P Things that aren't unique to a player shouldn't be in a trigger that's unique to each player.

It's merely a tip for this mapmaker who is looking for such information. The idea is to consolidate triggers for ease of editing and reading. It's also less likely that you'll make a mistake (and easier to find a mistake) if you're only putting an action into one trigger, rather than five separate ones.




Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[03:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[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.
Please log in to shout.


Members Online: NudeRaider, jjf28