Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: What are Switches?
What are Switches?
May 29 2008, 11:56 pm
By: Cheathunta  

May 29 2008, 11:56 pm Cheathunta Post #1



What are switches and what exactly do they do?



None.

May 30 2008, 12:00 am Symmetry Post #2

Dungeon Master

A switch is a tool that can be used in the conditions of a trigger to connect it to another.

A switch can be set on or off, and even randomized. A condition can detect whether it is on or off.

Ex.

Condition: Always
Action: Set 'switch 1'

Condition: 'switch 1' is set
Action: create '1' 'marine'

The marine will be created, because the switch is set. If you changed the condition of the first trigger to 'Never', the marine would not be created.

I hope that helped.



:voy: :jaff: :voy: :jaff:

May 30 2008, 12:06 am Falkoner Post #3



Here's a tutorial on just about every use for a switch



None.

May 30 2008, 12:07 am NudeRaider Post #4

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

Switches are basically binary variables. They can have either cleared (=0) or set (=1) state.
You can also toggle or randomize them.

They are used to mark an event or to create random numbers (need n switches for 2^n possibilities).
E.g. in a defense map you set switch named "Level 1" when you spawn level 1 units, set switch "Level 2" and clear "Level 1" for the next level, etc. Then you can make triggers that only run for the current level.
For example:
If Current Player has at least 350 kills score
and "Switch 1" (=Hyds) is set
- subtract 350 kills score
- add 1 gas

If Current Player has at least 50 kills score
and "Switch 2" (=Lings) is set
- subtract 50 kills score
- add 1 gas




May 30 2008, 12:08 am Cheathunta Post #5



So if i want to increase a unit's HP every time it kills X amount of units, will i need to set a switch?



None.

May 30 2008, 12:09 am Falkoner Post #6



No, you will not, in a case like that, where you have more than 2 possibilities(more than two different health amounts) you would want to use Death Counts.



None.

May 30 2008, 12:09 am Heimdal Post #7



A very technical description, Kow.

A switch is useful for remembering something that can have one of two states (yes/no, true/false, etc). For example, if you're making an adventure game and your triggers need to remember whether or not a character has a key for a door. Initially the switch will be cleared. When the player finds they key, you set the switch. When he gets near the door, if the switch is set the door will open. Otherwise perhaps it will print a message saying he needs to find a key first.

Death counters are usually a better alternative to switches because they can have more than two states and can be set per-player rather than globally. For example, if you can carry more than one key at a time or each player has their own set of keys, a switch would be a bad idea for the above situation. But if you have a global yes-no value to record, a switch is a good way to do it.

Using the "randomize" action of the switch is a good way to generate a random number that is a power of two.



None.

May 30 2008, 12:15 am rockz Post #8

ᴄʜᴇᴇsᴇ ɪᴛ!

no. Think of it in terms of conditions and actions.

Conditions:
Unit kills X amount of units
Actions:
Increase Unit HP

You could set a switch, but that wouldn't do anything. Switches are binary variables, so you either have them on or off. They can be used as a continuation between triggers, if you have more than 16 conditions or 64 actions in a trigger. For example:

Conditions:
Bring 1 unit to location 1
Bring 1 unit to location 2
...
Bring 1 unit to location 15
Bring 1 unit to location 16
Actions:
Set Switch 1

Conditions:
Switch 1 is set
Bring 1 unit to location 17
Actions:
Whatever

So the "whatever" action will only run when there are units at locations 1-16, and then a unit is at location 17. It's rare you need to do these things for conditions, since 16 is usually plenty.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

May 30 2008, 12:31 am Clokr_ Post #9



I used to compare switches with lightbulbs. You can switch them on at anytime to remember later that you've done something somewhere else. That's the main idea: you set a switch in a trigger, then you check if it is set or not in another trigger to selectively execute something.

PD: Haven't seen anyone asking about switches for months, cool :)

Falkoner, change the bg of that webpage already damnit :P



?????

May 30 2008, 12:41 am Cheathunta Post #10



How do you increase a units hp without modifying it at a location? Because if i did that i would have to make a location to cover the whole map.



None.

May 30 2008, 12:43 am Clokr_ Post #11



Quote from Cheathunter
How do you increase a units hp without modifying it at a location? Because if i did that i would have to make a location to cover the whole map.

Switches are just a way to remember how many HP the unit has with vHP. But death counters work better.
Anyway, there's not other way than adjusting the HP of an unit in a given location. So you have to make sure that there's only 1 unit of that type in the choosen location, and then take care of the HP % using switches or deathcounters and adjust it manually (using 100 different triggers, one for 1%, another for 2%, etc).



?????

May 30 2008, 12:49 am rockz Post #12

ᴄʜᴇᴇsᴇ ɪᴛ!

A location that covers the whole map is location 63: "Anywhere"



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

May 30 2008, 12:56 am Cheathunta Post #13



So would this be a proper trigger?


Conditions: Player X kills 10 units


Actions: Modify HP for Unit Y at location "Anywhere"



None.

May 30 2008, 1:17 am Falkoner Post #14



You cannot simply add HP, you need to set it to a certain amount, read the tutorials I posted on how to use Death Counts and Switches.



None.

May 30 2008, 1:18 am Clokr_ Post #15



Actions: Modify Unit HP: Set to X percent for unit type Y at location Anywhere.

The whole trigger system would look this way:
Code
Trigger1
Conditions:
- P8 has exactly 1 deaths of Terran Marker
Actions:
- Set HP to 1% for unit type X at location Anywhere
- Preserve trigger

Trigger2
Conditions:
- P8 has exactly 2 deaths of Terran Marker
Actions:
- Set HP to 2% for unit type X at location Anywhere
- Preserve trigger

Trigger1
Conditions:
- P8 has exactly 3 deaths of Terran Marker
Actions:
- Set HP to 3% for unit type X at location Anywhere
- Preserve trigger


And so on.
We're using the deathcount of P8 Terran Marker to store how much HP the unit has at the moment. We chose Terran Marker because we can be sure that it can't die (and thus SC will not modify the deathcount without us wanting to).
After the 100 triggers are done you can set the deathcounter to any value or increment / decrease it and the unit's HP will be set to the choosen HP.
However since you're constantly setting the unit HP to a given HP number the unit will not take damage from any attacking unit. You'll also have to handle damage with triggers.



?????

May 30 2008, 1:20 am Falkoner Post #16



Yes, that's how you would have to do it, and there's no way(without EUDs) to detect when other units hurt your unit.

Quote
Falkoner, change the bg of that webpage already damnit :P

Just gotta study up on Javascript and CSS a bit more and I'll redo it. Be patient, plz!



None.

May 30 2008, 4:21 am rockz Post #17

ᴄʜᴇᴇsᴇ ɪᴛ!

make the background c20000, with white text. It doesn't have to be fancy.

Are you trying to do a level up system or something hunter?



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[09:19 am]
Linekat -- cool
[01:56 am]
Oh_Man -- cool bit of history, spellsword creator talking about the history of EUD ^
[09:24 pm]
Moose -- denis
[05:00 pm]
lil-Inferno -- benis
[10:41 am]
v9bettel -- Nice
[2024-4-19. : 1:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[2024-4-18. : 10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[2024-4-18. : 10:11 pm]
Ultraviolet -- :P
[2024-4-18. : 10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
Please log in to shout.


Members Online: IlyaSnopchenko, Linekat