+ Reply to Thread
Results 1 to 8 of 8

Thread: [MAP] Creating a basic 'Number Countdown'

  1. #1
    Senior Member
    Points: 14,832, Level: 52
    Level completed: 88%, Points required for next Level: 68
    Overall activity: 0%



    Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe's Avatar
    Join Date
    Feb 2012
    Posts
    1,121
    Points
    14,832
    Total Donations For

    [DtK] [Jedi] Bauxe     $ 20.00

    [MAP] Creating a basic 'Number Countdown'

    Hey Everyone!

    Decided to create a quick guide on how to create a countdown using a few different I/O and logics. This is fairly simple, but it demonstrates possibilities.

    This tutorial will use:
    • logic_case
    • math_counter
    • logic_timer
    • logic_relay
    • logic_branch

    It should give you some basic knowledge on how they work.

    This is not necessarily the most ideal way to create this counter, however it is for educational purposes and can assist in learning.


    1) Creating the Numbers

    This is a fairly simple step. You will want to create an "8" using 7 different brushes, such as the one in the picture below.


    (for those who have trouble seeing the 7 brushes)


    Once that is done, click on one of them and press "CTRL-T" on your keyboard to open the Object Properties window. Here, change the "Class" to "func_brush" and give the number a name. For example, 1_1 (representing the first line of the first number). Be sure to enable the "Ignore player +USE" flag.

    Repeat this for all 7 brushes, giving separate names to all of them. We are using "func_brush" as you can easily toggle the visibility of them.


    2) The math_counter

    Next, using the "Entity Tool", create a "math_counter". As the name suggests, this has the ability to count numbers, and do various mathematical equations.

    You will only require one math counter per number, so name it something like "counter_1".

    Finally, set the Properties to the following:
    • Start Disabled: No
    • Initial Value: 5
    • Minimum Legal Value: -1
    • Maximum Legal Value: 10

    This simply means the counter is enabled, can't go below -1, can't go above 10, and starts at 5.

    For now, we will leave the math counter at that.


    3) The logic_relay (optional)

    This part is unnecessary. I am only adding it as an example, and also to keep the counter a bit neater.

    For this you will need to create 10 "logic_relay" entities. Simply label them from 0-9, representing the numbers 0-9

    Next, in the Outputs tab, create the following Output:
    • My output named: OnTrigger
    • Targets entities named: (func_brush1)
    • Via this input: (depending whether you want it to be visible or not)

    For example, if you were making a logic_relay for the number "0" it would enable all of the func_brush's except for the middle one. (resulting in a 0)

    What we have done means, if we "Trigger" the logic_relay (through means such as a button) it will Enable or Disable the func_brush, depending on what your choice was.

    So for example, the logic_relay for the number 2 would look something like the following:



    Repeat for all numbers 0 through 9.


    4) The logic_case

    A logic case allows you to set a variety of I/O that is based on a number of cases.

    For this example, we will be making cases for the numbers 0-9, so we can display the numbers that we want.

    So create a "logic_case" entity, named something such as case_1. Add the values 0-9 through Case 01 to Case 10. This will allow us to select them all.



    Now this is where our logic_relay's come into play. Go into the Outputs tab, and create Outputs in the following way:
    • My output named: OnCase01
    • Targets entities named: (logic_relay that is equal to 0)
    • Via this input: Trigger

    This simply means, if Case01 is chosen, the logic_relay that you put in the target field will be triggered, triggering its outputs and setting the func_brush's to the number.


    5) Back to the math_counter

    Now we are going to create a way for the logic case to compare the values to the math_counter.

    On the math_counter, create an Output using the following:
    • My output named: OnGetValue
    • Targets entities named: case_1
    • Via this input: InValue

    This basically means that if the value of the math_counter is 'called for' it will feed its value into the logic case, thus picking the case based on the value.


    6) The logic_timer

    So we need a way for the math_counter's value to constantly be called for. The easiest way for this is using a logic_timer, so go ahead and create a logic_timer entity.

    This is a very basic step. Simply name it something such as "timer" and set the Refire Interval to a low value, such as 0.01. This means every 0.01 seconds, the timer will start counting again.

    Next, into the Outputs tab, add a new output:
    • My output named: OnTimer
    • Targets entities named: (your math_counter)
    • Via this input: GetValue

    This simply gets the value of the math_counter. So now if you have followed this correctly, your counter will be working. The only issue is, you need a way to change the values on it.


    7) Changing the math_counter values

    Just for a bit more experience, I will be showing how to make a shootable object that changes the value. The reason I will not be using a shootable button is that doesn't work too well with quick bullet fire, and will only decrease the counter by 1 every second.

    So create a prop_dynamic, with any name and any World Model, it really doesn't matter. Add an Output using the following:
    • My output named: OnHealthChanged
    • Targets entities named: (your math_counter)
    • Via this input: Add
    • With a parameter override of: 1

    This means if you shoot the prop, the counter will increase by 1. You can do the same, except using subtract. Subtracting is ideal for boss HP bars, or any other 'killable" object.


    8) Fixing up the counter

    So you may have noticed that the math counter goes from -1 to 10 even though the numbers are 0-9. This allows us to do other effects with the counter, such as make the numbers loop over or integrate other numbers (to make the counter use more than 1 number)!

    This is very simple, just create an output on the math_counter:
    • My output named: OnHitMax
    • Targets entities named: (for this example, use its own name)
    • Via this input: SetValue
    • With a parameter override of: 0

    This simply means that if it hits 10, it will reset to 0. You can also make it if it hits minimum (-1) it will go to 9.


    Later on I will add how to add extra counters, to make multi-number counters using these methods.

    I have made an example that has 2 numbers, a box that when shot lowers the number by 1, and a button that when pressed raises the number by 15.

    https://dl.dropbox.com/u/80605475/hpbar.bsp <--- BSP
    https://dl.dropbox.com/u/80605475/hpbar.vmf <--- VMF

    Note for more experienced hammer users, instead of using logic_relay's to change the numbers in a clean fashion (instead of jamming 50 outputs onto a logic case), you can use env_texturetoggle and change the texture of a box to the different numbers.


    Final Notes

    Again this may not be the best way to create a counter, but it gives users a basic understanding of a few logic entities. The reason behind me making this guide is, I was testing some ideas based off a zombie escape map, "ze_portal_story" to use in my upcoming map for bossfights. I plan to use a similar, but more optimised system.

    I hope I have taught some of you something. If you have any questions, please post them. thanks for reading. ^^
    Last edited by imthenewguy; 24-01-13 at 12:47 AM.



  2. #2
    Development Team
    Points: 30,788, Level: 76
    Level completed: 93%, Points required for next Level: 62
    Overall activity: 0%
    imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy's Avatar
    Join Date
    Feb 2011
    Location
    Hawkesbury, NSW
    Posts
    2,584
    Points
    30,788
    Total Donations For

    [DtK] [SA] imthenewguy     $ 0.00
    Nice tut mate. Took the liberty of labeling it with [MAP] and adding pics instead of hyper links :P

  3. #3
    Senior Member
    Points: 14,832, Level: 52
    Level completed: 88%, Points required for next Level: 68
    Overall activity: 0%



    Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe's Avatar
    Join Date
    Feb 2012
    Posts
    1,121
    Points
    14,832
    Total Donations For

    [DtK] [Jedi] Bauxe     $ 20.00
    Quote Originally Posted by imthenewguy View Post
    Nice tut mate. Took the liberty of labeling it with [MAP] and adding pics instead of hyper links :P
    Initially had them as links due to image limits in posts, was expecting to use more. :P

    But thanks. ^^

  4. #4
    Banned
    Points: 12,950, Level: 49
    Level completed: 30%, Points required for next Level: 350
    Overall activity: 21.0%
    kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF has a reputation beyond repute kingEOFFF's Avatar
    Join Date
    Apr 2012
    Location
    Geoff's Kingdom
    Posts
    2,110
    Points
    12,950
    Total Donations For

    kingEOFFF     $ 0.00
    Looks like so much work for what it's worth

  5. #5
    Development Team
    Points: 30,788, Level: 76
    Level completed: 93%, Points required for next Level: 62
    Overall activity: 0%
    imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy's Avatar
    Join Date
    Feb 2011
    Location
    Hawkesbury, NSW
    Posts
    2,584
    Points
    30,788
    Total Donations For

    [DtK] [SA] imthenewguy     $ 0.00
    Quote Originally Posted by kingEOFFF View Post
    Looks like so much work for what it's worth
    You mustn't map lol.

    There can be a few instances where this can be handy.

  6. #6
    Development Team
    Points: 30,788, Level: 76
    Level completed: 93%, Points required for next Level: 62
    Overall activity: 0%
    imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy's Avatar
    Join Date
    Feb 2011
    Location
    Hawkesbury, NSW
    Posts
    2,584
    Points
    30,788
    Total Donations For

    [DtK] [SA] imthenewguy     $ 0.00
    Just a note on section 7. You say that it only adds 1/second regardless of how many times its hit if using a func_button?

    I haven't had that issue with func_button if movement is disabled and reset delay is set to 0. Gets a response each time normally.

  7. #7
    Senior Member
    Points: 14,832, Level: 52
    Level completed: 88%, Points required for next Level: 68
    Overall activity: 0%



    Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe has a reputation beyond repute Bauxe's Avatar
    Join Date
    Feb 2012
    Posts
    1,121
    Points
    14,832
    Total Donations For

    [DtK] [Jedi] Bauxe     $ 20.00
    Quote Originally Posted by imthenewguy View Post
    Just a note on section 7. You say that it only adds 1/second regardless of how many times its hit if using a func_button?

    I haven't had that issue with func_button if movement is disabled and reset delay is set to 0. Gets a response each time normally.
    No idea why, but it would only count down once per second when I used a func_button. No idea why it happened, so I decided to leave the button out for now.

  8. #8
    Development Team
    Points: 30,788, Level: 76
    Level completed: 93%, Points required for next Level: 62
    Overall activity: 0%
    imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy has a reputation beyond repute imthenewguy's Avatar
    Join Date
    Feb 2011
    Location
    Hawkesbury, NSW
    Posts
    2,584
    Points
    30,788
    Total Donations For

    [DtK] [SA] imthenewguy     $ 0.00
    Wouldnt be the first time hammer misbehaved lol. Nice work around though.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts