Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: SCM Draft: Trigger Variables?
SCM Draft: Trigger Variables?
Mar 14 2018, 7:36 pm
By: Blackk9
Pages: 1 2 3 >
 

Mar 14 2018, 7:36 pm Blackk9 Post #1



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.




Mar 14 2018, 8:03 pm Chia-Tyrant Post #2



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.

Add ore
Players

  • Player 1
  • Conditions

  • Accumulate at least 256 gas
  • Actions

  • Add 256 ore
  • Subtract 256 gas
  • Add 256 deaths of map revealer

  • Add ore
    Players

  • Player 1
  • Conditions

  • Accumulate at least 128 gas
  • Actions

  • Add 128 ore
  • Subtract 128 gas
  • Add 128 deaths of map revealer

  • ...
    Add ore
    Players

  • Player 1
  • Conditions

  • Accumulate at least 1gas
  • Actions

  • Add 1 ore
  • Subtract 1 gas
  • Add 1 deaths of map revealer

  • Restore gas
    Players

  • Player 1
  • Conditions

  • Suffered at least 256 deaths of map revealer
  • Actions

  • 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.

    Mar 14 2018, 8:25 pm Blackk9 Post #3



    Quote from Chia-Tyrant
    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.

    Add ore
    Players

  • Player 1
  • Conditions

  • Accumulate at least 256 gas
  • Actions

  • Add 256 ore
  • Subtract 256 gas
  • Add 256 deaths of map revealer

  • Add ore
    Players

  • Player 1
  • Conditions

  • Accumulate at least 128 gas
  • Actions

  • Add 128 ore
  • Subtract 128 gas
  • Add 128 deaths of map revealer

  • ...
    Add ore
    Players

  • Player 1
  • Conditions

  • Accumulate at least 1gas
  • Actions

  • Add 1 ore
  • Subtract 1 gas
  • Add 1 deaths of map revealer

  • Restore gas
    Players

  • Player 1
  • Conditions

  • Suffered at least 256 deaths of map revealer
  • Actions

  • 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.

    Mar 14 2018, 9:27 pm Swampfox Post #4



    http://www.staredit.net/wiki/index.php?title=Binary_Countoffs

    Generally, 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.

    Mar 14 2018, 9:51 pm Lanthanide Post #5



    Quote from Chia-Tyrant
    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.

    Mar 15 2018, 12:28 am Blackk9 Post #6



    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.

    Mar 15 2018, 12:38 am Lanthanide Post #7



    The triggers outlined by Chia-Tyrant do subtract your gas:
    Triggername
    Players

  • Player 1
  • Conditions

  • Accumulate at least 256 gas
  • Actions

  • 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.

    Mar 15 2018, 12:41 am Suicidal Insanity Post #8

    I see you !

    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.




    Mar 15 2018, 12:49 am Lanthanide Post #9



    Ok, I'm really confused as to what he's even trying to achieve, because these statements appear to be contradictory:
    Quote
    I need to keep the gas as is
    Quote
    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.

    Mar 15 2018, 7:33 am Blackk9 Post #10



    Quote from Lanthanide
    The triggers outlined by Chia-Tyrant do subtract your gas:
    Triggername
    Players

  • Player 1
  • Conditions

  • Accumulate at least 256 gas
  • Actions

  • 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.

    Mar 15 2018, 7:36 am Blackk9 Post #11



    Quote from Lanthanide
    Ok, I'm really confused as to what he's even trying to achieve, because these statements appear to be contradictory:
    Quote
    I need to keep the gas as is
    Quote
    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.

    Mar 15 2018, 9:45 am Lanthanide Post #12



    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:
    Restore Gas
    Players

  • Player 1
  • Conditions

  • Suffered at least 256 deaths of map revealer
  • Actions

  • 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.

    Mar 15 2018, 11:23 am Chia-Tyrant Post #13



    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:
    Binary countoff example.scm
    Hits: 1 Size: 25.36kb



    None.

    Mar 15 2018, 9:32 pm Blackk9 Post #14



    Quote from Lanthanide
    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:
    Restore Gas
    Players

  • Player 1
  • Conditions

  • Suffered at least 256 deaths of map revealer
  • Actions

  • 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.

    Mar 15 2018, 9:36 pm Blackk9 Post #15



    Quote from Lanthanide
    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:
    Restore Gas
    Players

  • Player 1
  • Conditions

  • Suffered at least 256 deaths of map revealer
  • Actions

  • 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.
    Quote from Chia-Tyrant
    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.

    Mar 15 2018, 9:42 pm Suicidal Insanity Post #16

    I see you !

    When you are adding minerals, you can add the gas back as well.




    Mar 15 2018, 11:29 pm Lanthanide Post #17



    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.

    Mar 16 2018, 1:26 am Blackk9 Post #18



    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.

    Mar 16 2018, 1:30 am Lanthanide Post #19



    Just put Lanthanide.



    None.

    Mar 16 2018, 1:57 am Blackk9 Post #20



    Quote from Lanthanide
    Just put Lanthanide.

    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:

    West Force Defeat
    Players

  • Force 1
  • Conditions

  • Player 4 Commands exactly 0 Xel'Naga Temple
  • Actions

  • 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.

    Options
    Pages: 1 2 3 >
      Back to forum
    Please log in to reply to this topic or to report it.
    Members in this topic: None.
    [2024-4-14. : 9:21 pm]
    O)FaRTy1billion[MM] -- there are some real members mixed in those latter pages, but the *vast* majority are spam accounts
    [2024-4-14. : 9:21 pm]
    O)FaRTy1billion[MM] -- there are almost 3k pages
    [2024-4-14. : 9:21 pm]
    O)FaRTy1billion[MM] -- the real members stop around page 250
    [2024-4-14. : 9:20 pm]
    O)FaRTy1billion[MM] -- look at the members list
    [2024-4-12. : 12:52 pm]
    Oh_Man -- da real donwano
    da real donwano shouted: This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
    it's pretty common
    [2024-4-11. : 9:53 pm]
    da real donwano -- This is the first time I've seen spam bots like this on SEN. But then again, for the last 15 years I haven't been very active.
    [2024-4-11. : 4:18 pm]
    IlyaSnopchenko -- still better than "Pakistani hookers in Sharjah" that I've seen advertised in another forum
    [2024-4-11. : 4:07 pm]
    Ultraviolet -- These guys are hella persistent
    [2024-4-11. : 3:29 pm]
    Vrael -- You know, the outdoors is overrated. Got any indoor gym and fitness equipment?
    [2024-4-10. : 8:11 am]
    Sylph-Of-Space -- Hello!
    Please log in to shout.


    Members Online: Roy