Welcome to PlagueFest.com! Log in or Sign up to interact with the Plague Fest community.
  1. Welcome Guest! to interact with the community and gain access to all the site's features.

Tutorial Voting Meter(s)

Discussion in Resources & Tutorials started by nyronic, Oct 7, 2011

  1. May 17, 2011
    Posts
    This is the first tutorial I've ever written, hopefully its easy to follow.

    EXAMPLE MAP - LINK

    Step 1.) Setup

    You will need to create the following entities

    BRUSH:
    trigger_multiple (This is the zone the players will stand in)
    func_movelinear
    func_door (Optional, only for a visual effect)

    POINT:
    math_counter
    logic_case
    logic_relay

    I recommend naming all of these with a prefix to avoid confusion as you will need to make copies of them for each additional meter.

    For this tutorial I have simply named everything with vote_1_<name>. (The "1" can be anything: vote_bhop_<name>, vote_slide_<name>, etc)

    Example:
    trigger_multiple - vote_1_tm
    func_movelinear - vote_1_meter
    math_counter - vote_1_math_counter
    logic_case - vote_1_logic_case
    logic_relay - vote_1_relay

    Step 2.) Entity configuration

    Once you have named everything, open up your trigger_multiple's properties:

    NOTE: Make sure the "clients" flag is checked or your trigger will do nothing.

    Trigger Multiple - Class Info
    [IMG]
    Set start disabled - Yes (This is important, explained later)

    Trigger Multiple - Outputs
    [IMG]
    Every time a player enters the trigger, it will add 1 to the math counter.
    Every time a player exits the trigger, it will subtract 1 from the math counter.
    OnEndTouchAll is fired when all players have left the trigger, this is a safe guard to make sure the math counter is reset back to 0.
    Note the Only Once flagged output to open the func_movelinear(vote_1_meter), this is to simply set the meter "on"(further details in the func_movelinear pictures)


    Open up your math_counter's properties.

    Math Counter - Class Info
    [IMG]
    Set its maximum legal value to 16

    Math Counter - Outputs
    [IMG]
    OutValue is fired every time the math_counter's value changes.(So every time a player enters/exits the trigger)
    InValue is the input being sent to the logic_case, the math_counter is sending its current value to the logic_case.


    Open up your logic_case's properties.

    Logic Case - Class Info
    [IMG]
    Anytime a logic_case receives the input InValue, it will compare the number received to these, and fire the appropriate Case # in its outputs.

    Logic Case - Outputs
    [IMG]
    OnCase01 will be fired when it receives "1" from the math_counter, OnCase02 when it receives "2", and so on.
    OnDefault is fired when it receives a value that is not equal to any of the ones listed in its class info(Previous picture)

    Anytime the math_counter's value changes, the logic_case will receive it and fire the appropriate output, thus changing the speed of the func_movelinear(vote_1_meter) based on the number of players standing in the trigger.

    OnDefault will fire when the math_counter goes back to 0(This is also why the cap of 16 on the math_counter was needed, otherwise it would fire this when going to 17+ players).

    I set the speed to 0.000001 to simulate "stopping" it as there is no input to make a func_movelinear stop.

    Speed values are measured in units per second, the values you pick should be linear(5, 10, 15) or (10, 20, 30), or (15, 30, 45) etc.


    Open up your func_movelinear's properties.

    Func Movelinear - Class Info
    [IMG]
    Give it a color. (FX Color (R G B))

    Set its move direction, mine is set to move up.

    Set its speed to 0. (This is so it does not move when its initially told to Open from the trigger_multiple earlier on.)

    Set its move distance for how far you want the meter to travel. This should generally be how long or tall your meter is, depending which direction you have it move.

    Func Movelinear - Outputs
    [IMG]
    This will fire when your func_movelinear completes its move distance.

    Have it target the logic_relay you created earlier.


    Open up your func_door properties.

    Func Door - Class Info
    [IMG]
    Parent it to the func_movelinear

    Give it a color. (FX Color (R G B))


    Set up your func_movelinear and func_door like so:
    [IMG]
    They can be the other way around with the func_door on the bottom instead, just adjust the colors. But the bottom half should start inside of the floor, with the top half lining up with the ceiling.(Or at least some sort of brush work to hide the fact its moving up)

    Both entities should be a solid texture, or at least a texture that doesn't appear to be moving. This will make it seem like the meter is "filling" up. I used cs_havana/white. Optionally, you could just create your own texture that has 2 colors on it and you don't even need the func_door.


    Open up your logic_relay's properties:

    Logic Relay - Outputs
    [IMG]
    This will fire the events for when this meter "wins".

    Note the vote_disable_relay output, create another logic_relay for this purpose.


    Step 3.) Final configuration

    Open up your new logic_relay's properties:
    [IMG]
    This should disable your meter's trigger_multiple and its logic_relay(As well as other meters). This is done as a safe guard to make sure only 1 meter can win.


    Now to set up the start up of your vote system, as well as a tie breaker system.

    Create 2 new entities. One of them should be a logic_case, give it a name. The other doesn't really matter, but I prefer to use a logic_auto.(If you use something else you'll obviously want to trigger it by some other means)

    Logic Case - Outputs
    [IMG]
    Give it an OnCase## output for each individual meter trigger. This is going to be a pre-randomization in order to prevent ties. You do NOT need to give it values in its class info.

    Logic Auto - Outputs
    [IMG]
    Note the 3 highlighted outputs, PickRandomShuffle means it will pick a random OnCase##, but it will shuffle through all of them once before repeating an OnCase output. This input should be sent to the logic_case for how many meters you have, if you have 10 meters, send the command 10 times.

    At this point its very important how their delay is set up. They must all be sent within 1 second of each other. This is done so that while the meters do get activated at different times, it won't affect the outcome if there is a meter with majority player count. It is ONLY for tie breakers where both meters have the same amount of players from start to finish.

    I have 3 meters, so I simply did x.00, x.33, x.66

    Additional Notes:
    For extra meters, simply copy the entities from the first one and rename everything.
    The "server" entity in the logic auto is a point_servercommand that's named server.
    There is a minor issue which occurs when there's 16 players standing on a meter, a 17th enters and exits and the math_counter will end up at 15 because it was capped at 16.

    EXAMPLE MAP - LINK

    That's it, you should now have a functional vote system. :smile:
    [IMG]
    • Useful Useful x 1
    • Jun 4, 2006
      Posts
      Badass. Nice tut. I'm sure the other mappers in the community will appreciate this. :thumbsup:
    • Mar 16, 2008
      Posts
      Thank you for posting this, Galaxy made this thing amazing.
    • Feb 18, 2011
      Posts
      Now I need to learn how to map.
    • Jul 28, 2011
      Posts
      Thanks for this! Now if I can only find the time to open up hammer... stupid midterms :verymad:
    • May 15, 2011
      Posts
      ZOMG!

      I LOVE YOU!

      HAVE MY CHILD!
    • May 17, 2011
      Posts
      Hope to see fellow mappers make use of it :smile:. If anyone has any questions or is confused about something let me know.
    • Sep 25, 2010
      Posts
      Very much appreciated!