Measuring the travel distance of a tracktrain

Discussion in 'Mapping Questions & Discussion' started by Psy, Jun 29, 2009.

  1. Psy

    aa Psy The Imp Queen

    Messages:
    1,705
    Positive Ratings:
    1,468
    FYI, this is for a PLR map with a round timer. :)

    Currently I'm trying to measure the distance that a tracktrain has travelled. So far for each cart I have 1 math_counter and 1 logic_case. For the trigger_capture_area I have another output which is sent to the logic_case that outputs the value of NumTrainCappers.

    When the player (or players) push the cart, the value of NumTrainCappers is sent to the logic_case. The logic_case then executes a series of outputs that add to the math_counter.

    • If the cart is not moving then the counter is disabled
    • If the cart is moving at 1x speed, the counter is enabled and a value of 1 is added.
    • If the cart is moving at 2x speed, the counter is enabled and a value of 2 is added.
    • If the cart is moving at 3x speed, the counter is enabled and a value of 3 is added.

    When the round ends, the values of each math_counter are compared against each using a logic_compare and the winner is determined. This is all fine and dandy and it works.

    Now, my problem. Logically, using NumTraincappers makes no sense. It only sends an InValue once for everytime the cart is pushed or for when the number of people pushing changes. So when 1 person pushes the cart, the math_counter is only updated once whilst somebody could keep entering and leaving the trigger push to retrigger the InValue, constantly adding 1 to the math_counter.

    This means that REDs cart could be pushed 10ft in a single push (thus adding 1 to the math counter) whilst BLUs cart could be pushed the same distance in multiple pushes which keep adding 1 for everytime a player enters and leaves the trigger thus giving BLU's counter an astronomical figure and causing them to win.

    So how do I consistently add a value to my math_counters whilst it's moving and not when it's begun to be pushed as well as accurately accounting for changes in speed?
     
    Last edited: Jun 29, 2009
  2. pitto

    pitto L3: Member

    Messages:
    109
    Positive Ratings:
    73
    You will want to use a logic timer to trigger events at regular intervals (e.g. set RefireTime to every 1s or whatever you want)
    http://developer.valvesoftware.com/wiki/Logic_timer

    This would need to call a logic case each time it is triggered, which checks how many people are on each teams cart, and update the counters accordingly

    I think this should work - but I'm still learning entities
     
  3. Ezekel

    Ezekel L11: Posh Member

    Messages:
    818
    Positive Ratings:
    244
    i'd say similar to what pitto said.

    when the math counter is incremented, the counting system is disabled for say 5-6 seconds.
    it's similar to how you earn points for captures in a standard payload map - you get one for going near the cart, and then one subsequentally for keeping the cart moving for a certain amount of time/distance(not sure which). so repeatedly touching it and running away doesn't amass hundreds of points.
     
  4. Psy

    aa Psy The Imp Queen

    Messages:
    1,705
    Positive Ratings:
    1,468
    It doesn't really work as 'tap' pushing the cart causes an inverse problem where they can cover the same distance but gain fewer points as the timer doesn't refire.

    I have a timer with a 1 second refire that adds a value of 1 to the math counter.

    Below is a list of values that the math_counter ends on when the cart reaches the final path. This is when a player pushes the cart straight from the start to the end of the track.

    384 units

    • x3 = 4 points
    • x2 = 6 points
    • x1 = 8 points

    192 units

    • x3 = 2 points
    • x2 = 3 points
    • x1 = 4 points

    As you can see, it works when people simply push the cart.
     
    Last edited: Jun 29, 2009
  5. A Boojum Snark

    aa A Boojum Snark Toraipoddodezain Mazahabado

    Messages:
    4,769
    Positive Ratings:
    5,535
    How about just use OnPass to add 1 every time it reaches a path_track?
     
  6. Warchamp7

    Warchamp7 L2: Junior Member

    Messages:
    73
    Positive Ratings:
    16
    This is what I suggested to you in the chat, if they've both reached the same point at the end, call it a stalemate