As the title says, I'm wondering if there's a way to have Trigedit on SCMDraft take in variables and apply them.
I'm hoping to make a map where after every 30 seconds, players will gain x minerals equal to their Current Gas.
Any help is appreciated! Thank you.
What you want is possible with EUD actions but I wouldn't recommend it since there's a much easier solution to your problem: binary countoffs.
Player 1
Accumulate at least 256 gas
Add 256 ore
Subtract 256 gas
Add 256 deaths of map revealer
Player 1
Accumulate at least 128 gas
Add 128 ore
Subtract 128 gas
Add 128 deaths of map revealer
...
Player 1
Accumulate at least 1gas
Add 1 ore
Subtract 1 gas
Add 1 deaths of map revealer
Player 1
Suffered at least 256 deaths of map revealer
Add 256 gas
Subtract 256 deaths of map revealer
...
- I used deaths of map revealer but you can substitute for any unused unit you want; it's only a temporary variable
- You need triggers for every power of 2 starting from a reasonably high value: 256, 128, 64, ..., 1.
Post has been edited 1 time(s), last time on Mar 15 2018, 8:21 am by Chia-Tyrant.
None.
What you want is possible with EUD actions but I wouldn't recommend it since there's a much easier solution to your problem: binary countoffs.
Player 1
Accumulate at least 256 gas
Add 256 ore
Subtract 256 gas
Add 256 deaths of map revealer
Player 1
Accumulate at least 128 gas
Add 128 ore
Subtract 128 gas
Add 128 deaths of map revealer
...
Player 1
Accumulate at least 1gas
Add 1 ore
Subtract 1 gas
Add 1 deaths of map revealer
Player 1
Suffered at least 256 deaths of map revealer
Add 256 gas
Subtract 256 deaths of map revealer
...
- I used deaths of map revealer but you can substitute for any unused unit you want; it's only a temporary variable
- You need triggers for every power of 2 starting from a reasonably high value: 256, 128, 64, ..., 1.
I'm still a bit confused. I'm still particularly new to the whole trigger thing. How does Binary count off work? And if I were to implement this into my map, how do I make sure it does work?
None.
http://www.staredit.net/wiki/index.php?title=Binary_CountoffsGenerally, the point of binary countoffs is to "store" a value inside a death counter/resource. You can then make a second binary countoff to move that value to something else once again. In your case, you can simply move gas to minerals without any extra steps or death counters.
None.
What you want is possible with EUD actions
I'm curious as to what EUD actions you're talking about. I mean yes, technically anything you can do with standard triggers you can do with EUD actions. But I'm not familiar with any EUD addresses / actions that would make this any easier than the conventional binary countoff method you've mentioned.
If we were to get an enhanced EUD Set Memory action that allowed us to directly add value at memory address X to memory address Y, then it'd be possible to add gas to minerals directly. But such an action does not (yet) exist, so I'm not sure what technique you'd use with EUDs to solve this problem in a better way.
My questioning here isn't really helping the OP, but I'm curious and maybe there's some EUD technique I'm not aware of.
@OP: Binary countoffs are a somewhat intermediate level of trigger sophistication, so it is not surprising if they don't immediately make sense to you. But they are (to my knowledge) the best solution to your problem, so you should endeavour to implement and understand how they work. They are also getting into applied concepts in computer-science, so if you've got an interest in computers then they're a good way to start learning more about how they work (I highly recommend Starcraft triggering in general for improving logic skills and learning computer science concepts).
I should note, that the original triggers presented by Chia-Tyrant subtracts gas from whatever the current value is down to 0, and then re-adds it back to what it originally was. For your application of converting gas to minerals, you probably don't want to restore the gas count. It's unclear exactly what you're trying to achieve, if you could more fully explain what you want to occur for the player, that'd be good. Eg: before the triggers fire, you have state X (50 gas, 23 minerals), after the triggers fire you want to have state Y (0 gas, 73 minerals).
Post has been edited 4 time(s), last time on Mar 14 2018, 10:51 pm by Lanthanide.
None.
Okay, I'm starting to understand how Binary Countoffs work. However, one other problem I've run into. I need to keep the gas as is, seeing as the trigger is supposed to happen every 30 seconds, adding Minerals equal to your gas. However, it doesn't subtract your gas. Is this possible?
None.
The triggers outlined by Chia-Tyrant do subtract your gas:
Player 1
Accumulate at least 256 gas
Add 256 ore
Subtract 256 gas <------------------ HERE
Add 256 deaths of map revealer
Like I said in my post, there are also triggers in Chia's example that re-add gas. Just don't include them 'cause you don't need them. That also means you don't need to set the deaths of Map Revealer either, the sole purpose of that is to allow you to re-add the gas back, which you don't want.
Also if you better described specifically what it is you're trying to achieve, we could help more.
None.
What you probably need to do is use a binary count to move gas value -> random temp death table value
Then do the same thing in reverse to re-add the gas AND add minerals while modifying your temp value.
So basically what is listed in the first reply, only the last trigger needs to add gas and add minerals.
Ok, I'm really confused as to what he's even trying to achieve, because these statements appear to be contradictory:
I need to keep the gas as is
However, it doesn't subtract your gas. Is this possible?
Is the gas supposed to be modified, or not?
Another possible way to interpret this is that every 30 seconds, you want minerals to be equal to the gas value, eg if you had 523 minerals and 56 gas, after the trigger is run you should have 56 minerals and 0 gas.
However the original post used the word "gain" so if that is what was meant, then it was not clear.
Post has been edited 2 time(s), last time on Mar 15 2018, 12:56 am by Lanthanide.
None.
The triggers outlined by Chia-Tyrant do subtract your gas:
Player 1
Accumulate at least 256 gas
Add 256 ore
Subtract 256 gas <------------------ HERE
Add 256 deaths of map revealer
Like I said in my post, there are also triggers in Chia's example that re-add gas. Just don't include them 'cause you don't need them. That also means you don't need to set the deaths of Map Revealer either, the sole purpose of that is to allow you to re-add the gas back, which you don't want.
Also if you better described specifically what it is you're trying to achieve, we could help more.
Well, as you stated it's pretty close to what I want.
How the game works is you build a unit, that causes that unit to be teleported to the center area in conjunction with giving you Gas equal to it's income value (preset through triggers).
Every 30 seconds, your Vespine gas is added to your Minerals allowing you to build more and more units.
Basically, I want to be able to add a growing total to the minerals of each player in the game.
None.
Ok, I'm really confused as to what he's even trying to achieve, because these statements appear to be contradictory:
I need to keep the gas as is
However, it doesn't subtract your gas. Is this possible?
Is the gas supposed to be modified, or not?
Another possible way to interpret this is that every 30 seconds, you want minerals to be equal to the gas value, eg if you had 523 minerals and 56 gas, after the trigger is run you should have 56 minerals and 0 gas.
However the original post used the word "gain" so if that is what was meant, then it was not clear.
Er no. The way it works using your example is this:
You have 523 Minerals and 56 Gas. After 30 seconds you should have 579 minerals and 56 Gas.
The Gas is supposed to represent your income every 30 seconds. Your gas is also modified by building units, thus gaining more and more income throughout the game.
None.
Ok, then using all of Chia-Tyrants triggers is all you need to do.
Note that there is one you may have missed, which copies back out from the Map Reaveler into gas:
Player 1
Suffered at least 256 deaths of map revealer
Add 256 gas
Subtract 256 deaths of map revealer
You need to repeat that dividing by 2 down to 1, just like the first lot of triggers that add the minerals. Then you'll be set.
None.
I made you a map doing just what you want if you're still unclear about this.
The trouble with triggers is that they only let us compare variables to constants. We're strapped for time so we'd like to avoid having to check for every possible value of gas. Fortunately, there's a pretty clever trick that lets us do just that with only a handful of triggers (you can check for 1023 different values with only 10 triggers!)
You just need to know the following:
1.Every number can be represented as a sum of powers of two. 3 is 2^1+2^0. 12 is 2^3+2^2. You probably know this as binary.
2.That sum is always unique. You'll never find other powers of two that add up to the same number.
3.You can always check for the largest power of two that can fit into your value. For example, if you know your gas will always be below 10,000, you can know if 2^13 (8,192) is in that sum by checking if it's 'at least' 8,192.
4.If we know that 8,192 is in our sum, we can subtract it so we'll know the value is at most 8,191. We can go back to 3 and check the new greatest power of 2 that could fit into that: 4,096.
After looping through 3 and 4, we'll know what the full sum is, i.e., we're guaranteed that the original value will now be 0 since we subtracted its powers of two from it. If we add the same amount into a death counter every time we subtract, we'll also know that the death counter now holds whatever that original value was.
Attachments:
None.
Ok, then using all of Chia-Tyrants triggers is all you need to do.
Note that there is one you may have missed, which copies back out from the Map Reaveler into gas:
Player 1
Suffered at least 256 deaths of map revealer
Add 256 gas
Subtract 256 deaths of map revealer
You need to repeat that dividing by 2 down to 1, just like the first lot of triggers that add the minerals. Then you'll be set.
OH OKAY! That makes a lot of sense! So you have gas represent your income, which the gas (under the hood) has absolutely nothing to do with minerals. Instead every 30 seconds, you add the amount of Gas you have to the Deaths of Map Revealer. Then subtract the deaths of Map revealer, using that number to add minerals? If I understand correctly.
The only thing is... How do you keep a player's gas at the current value as is?
None.
Ok, then using all of Chia-Tyrants triggers is all you need to do.
Note that there is one you may have missed, which copies back out from the Map Reaveler into gas:
Player 1
Suffered at least 256 deaths of map revealer
Add 256 gas
Subtract 256 deaths of map revealer
You need to repeat that dividing by 2 down to 1, just like the first lot of triggers that add the minerals. Then you'll be set.
I made you a map doing just what you want if you're still unclear about this.
The trouble with triggers is that they only let us compare variables to constants. We're strapped for time so we'd like to avoid having to check for every possible value of gas. Fortunately, there's a pretty clever trick that lets us do just that with only a handful of triggers (you can check for 1023 different values with only 10 triggers!)
You just need to know the following:
1.Every number can be represented as a sum of powers of two. 3 is 2^1+2^0. 12 is 2^3+2^2. You probably know this as binary.
2.That sum is always unique. You'll never find other powers of two that add up to the same number.
3.You can always check for the largest power of two that can fit into your value. For example, if you know your gas will always be below 10,000, you can know if 2^13 (8,192) is in that sum by checking if it's 'at least' 8,192.
4.If we know that 8,192 is in our sum, we can subtract it so we'll know the value is at most 8,191. We can go back to 3 and check the new greatest power of 2 that could fit into that: 4,096.
After looping through 3 and 4, we'll know what the full sum is, i.e., we're guaranteed that the original value will now be 0 since we subtracted its powers of two from it. If we add the same amount into a death counter every time we subtract, we'll also know that the death counter now holds whatever that original value was.
Ohh, alright. I didn't see this. That example you have explains everything! Thank you so much!
None.
When you are adding minerals, you can add the gas back as well.
When you are adding minerals, you can add the gas back as well.
In Chia-Tyrants original triggers, the minerals are added in the same trigger that subtracts the gas; adding the gas back in the same trigger that just subtracted it would break the triggers.
But your proposed system would be cleaner: first set of triggers moves Gas into MR DC, and then 2nd set of triggers adds MR DC value back into gas and minerals.
None.
By the way, if you want to, you can Privately send me your Player Tags. I'd like to give Lanthanide and Chia-Tyrant a special thanks in my map.
None.
Alrighty! However (and this is kind of off topic) I'm running into a problem where the computers aren't spawning in. I gave them starting locations, yet every time I try to boot up the game to test it it ends in Defeat or a Draw.
The triggers I have set up for Force 1 for Victory and Defeat are as follows:
Force 1
Player 4 Commands exactly 0 Xel'Naga Temple
Comment:West Force Defeat
End Scenario in defeat for current player.
Victory and Defeat are the same for both sides, except for West Force if player 4 controls no Xel'Naga Temple, West Force loses. And if Player 8 Controls no Xel'Naga Temple. West Force Wins.
Vice versa for East Force.
None.