I'm trying to make it so bunkers are tinted a certain color if a certain type of unit is loaded into them. For example: if marines are blue and marauders are red, then a bunker with one marine and one marauder would be purple, or a bunker with two marines would be blue, etc.
The problem is I need to add tint to a bunker when a marine is loaded into it, rather than set the tint of it. Here's what I have so far:
Events
Unit - Any Unit Loads Cargo
Conditions
(Unit Type of (Triggering Cargo Unit)) == Marine
Actions Send Actor Message To Unit
Message: Set Tint Color
- Color: Convert Reals To Color With Alpha
- - Red: Arithmetic (Real)
- - - Value 1: Absolute Value (Real)
- - - - ?????
- - - Operator: +
- - - Value 2: 1.0
- - Green: 100.0%
etc.
This is where I'm having problems. I want to get the current percentage of red tint on the bunker and add to that. I've tried everything I could think of and nothing has worked.
Bunkers can only load two units in my map, so I suppose I could just make 30 triggers for all of the color combinations, but wouldn't that make my map laggy?
I'd take a slightly different approach. Any time you load or unload a unit, check all cargo units and set the color appropriately. I'm in a bit of a rush, but using this as a base you should be able to get the desired effect. When the bunker is empty, it's pitch black (of course). Maybe check the current color of the player and set it to that or something if it's empty. Also, the numbers make it a bit dark at the moment. Maybe just set red / blue to a fixed number if X are in the bunker. I just found it a bit cool that the bunker got "redder" with more marines inside.
Edit 2:
Another way to do it would be to simply check "if marine" "if marine marauder" "if marauder" "if empty" (using a few more variables in the switch), and then set the colors to exactly what you want in another switch... depending, of course, on how many different unit combinations are possible in your map.
I can give you an example in code later if you want. Gotta run now.
The problem is I want to add tint rather than set it. Somebody puts a marauder in a bunker, that turns it red. After that, if they put a Marine in the same bunker, I want it to add blue tint to turn it purple. With your method it would just make the bunker red when a marauder enters, then turn it blue when a marine enters. I need to be able to get the current tint so I can add to that - so if a marauder is in a bunker, that sets the tint to 50% 0% 0%, and then if a marine enters, instead of setting it to 0% 0% 50%, it would get the current tint (50% 0% 0%) and add 50% to the red, making it purple.
Edit 2:
Another way to do it would be to simply check "if marine" "if marine marauder" "if marauder" "if empty" (using a few more variables in the switch), and then set the colors to exactly what you want in another switch... depending, of course, on how many different unit combinations are possible in your map.
I could do this, but as I said, there are 30 possible color combinations - wouldn't that make the map laggy? It's going to be a maze defense map where you build bunkers (which have a 1x1 footprint) and then build units inside of them, so the trigger would be running a lot.
I've decided to only have 4 units for the bunkers instead of 5, so that means 20 color combinations. I also realized that if you put a marauder in a bunker, you're not going to be able to have a marine/hydralisk combo, so I'll only need 6 switch actions each time a unit is loaded.
Would running a trigger with 6 switch actions every second make the map very laggy?
I think you misunderstood my trigger. It does add the tint, sort of. I pick each unit in the bunker that loaded a unit and then calculate the color. It does not matter in which order you load the units... or unload for that matter.
I'll set up a test map so you can see what I mean and copy that if you want. And no, it would not make the map lag (why would you run the trigger every second?). Triggers are low overhead. Animating a single marine is probably worse (very rough estimate).
Now the only problem left as far as I see it is finding colors that work well (if you want more than 4). I used red, green, blue and gray. It's hard to find other usable colors. Yellow... blue + yellow = green, bad.. etc.
Ohhh, I was thinking that each time the trigger ran the variables would be reset back to zero. I didn't realize they kept their value.
I understand now. You've been extremely helpful, thanks.
BTW, I'm not actually going to run the trigger every second, that was just a rough estimate of how often I think it would be used. It's an 8-player tower defense map, so everybody would be putting units in bunkers at the same time after a wave.
Ohhh, I was thinking that each time the trigger ran the variables would be reset back to zero. I didn't realize they kept their value.
They don't keep their value after the trigger finishes. Every variable resets for each run through (or it would work very poorly with different players using different bunkers). I'm using local variables, not global. But the bunker does keep the units, and that's what I check.
I'm trying to make it so bunkers are tinted a certain color if a certain type of unit is loaded into them. For example: if marines are blue and marauders are red, then a bunker with one marine and one marauder would be purple, or a bunker with two marines would be blue, etc.
The problem is I need to add tint to a bunker when a marine is loaded into it, rather than set the tint of it. Here's what I have so far:
Events
Unit - Any Unit Loads Cargo
Conditions
(Unit Type of (Triggering Cargo Unit)) == Marine
Actions
Send Actor Message To Unit
Message: Set Tint Color
- Color: Convert Reals To Color With Alpha
- - Red: Arithmetic (Real)
- - - Value 1: Absolute Value (Real)
- - - - ?????
- - - Operator: +
- - - Value 2: 1.0
- - Green: 100.0%
etc.
This is where I'm having problems. I want to get the current percentage of red tint on the bunker and add to that. I've tried everything I could think of and nothing has worked.
Bunkers can only load two units in my map, so I suppose I could just make 30 triggers for all of the color combinations, but wouldn't that make my map laggy?
I'd take a slightly different approach. Any time you load or unload a unit, check all cargo units and set the color appropriately. I'm in a bit of a rush, but using this as a base you should be able to get the desired effect. When the bunker is empty, it's pitch black (of course). Maybe check the current color of the player and set it to that or something if it's empty. Also, the numbers make it a bit dark at the moment. Maybe just set red / blue to a fixed number if X are in the bunker. I just found it a bit cool that the bunker got "redder" with more marines inside.
Edit:
Changed from "if then" to a "switch".
Edit 2:
Another way to do it would be to simply check "if marine" "if marine marauder" "if marauder" "if empty" (using a few more variables in the switch), and then set the colors to exactly what you want in another switch... depending, of course, on how many different unit combinations are possible in your map.
I can give you an example in code later if you want. Gotta run now.
The problem is I want to add tint rather than set it. Somebody puts a marauder in a bunker, that turns it red. After that, if they put a Marine in the same bunker, I want it to add blue tint to turn it purple. With your method it would just make the bunker red when a marauder enters, then turn it blue when a marine enters. I need to be able to get the current tint so I can add to that - so if a marauder is in a bunker, that sets the tint to 50% 0% 0%, and then if a marine enters, instead of setting it to 0% 0% 50%, it would get the current tint (50% 0% 0%) and add 50% to the red, making it purple.
I could do this, but as I said, there are 30 possible color combinations - wouldn't that make the map laggy? It's going to be a maze defense map where you build bunkers (which have a 1x1 footprint) and then build units inside of them, so the trigger would be running a lot.
I've decided to only have 4 units for the bunkers instead of 5, so that means 20 color combinations. I also realized that if you put a marauder in a bunker, you're not going to be able to have a marine/hydralisk combo, so I'll only need 6 switch actions each time a unit is loaded.
Would running a trigger with 6 switch actions every second make the map very laggy?
I think you misunderstood my trigger. It does add the tint, sort of. I pick each unit in the bunker that loaded a unit and then calculate the color. It does not matter in which order you load the units... or unload for that matter.
I'll set up a test map so you can see what I mean and copy that if you want. And no, it would not make the map lag (why would you run the trigger every second?). Triggers are low overhead. Animating a single marine is probably worse (very rough estimate).
Now the only problem left as far as I see it is finding colors that work well (if you want more than 4). I used red, green, blue and gray. It's hard to find other usable colors. Yellow... blue + yellow = green, bad.. etc.
Ohhh, I was thinking that each time the trigger ran the variables would be reset back to zero. I didn't realize they kept their value.
I understand now. You've been extremely helpful, thanks.
BTW, I'm not actually going to run the trigger every second, that was just a rough estimate of how often I think it would be used. It's an 8-player tower defense map, so everybody would be putting units in bunkers at the same time after a wave.
Quote from Uplo:
Would running a trigger with 6 switch actions every second make the map very laggy?
----
Only for the TI-60 port of Starcraft 2.
They don't keep their value after the trigger finishes. Every variable resets for each run through (or it would work very poorly with different players using different bunkers). I'm using local variables, not global. But the bunker does keep the units, and that's what I check.
Damn, I'm really stupid today. But I get it now. For reals this time. Thanks.