What are switches and what exactly do they do?
None.
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.
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
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.
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.
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.
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?"
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
?????
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.
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).
?????
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?"
So would this be a proper trigger?
Conditions: Player X kills 10 units
Actions: Modify HP for Unit Y at location "Anywhere"
None.
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.
Actions: Modify Unit HP: Set to X percent for unit type Y at location Anywhere.
The whole trigger system would look this way:
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.
?????
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.
Falkoner, change the bg of that webpage already damnit
Just gotta study up on Javascript and CSS a bit more and I'll redo it. Be patient, plz!
None.
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?"