[TUTORIAL] Counting control points owned + Custom team scoring system

Discussion in 'Tutorials & Resources' started by hacky, Jan 15, 2008.

  1. hacky

    hacky L2: Junior Member

    Messages:
    83
    Positive Ratings:
    0
    To solve the problems I had in this thread, http://tf2maps.net/showthread.php?t=555 ...

    ... http://tf2maps.net/downloads.php?do=file&id=102 has the solution.

    The example map has the following:
    - 7 control points, all always unlocked for both teams. Blue and Red start with two each, with 3 starting neutral.
    - 2-minute game timer.
    - The team who has the most control points when time runs out wins. A team also wins if they capture all 7 control points.
    - When the round ends, each team gains one point for each control point owned, with the winning team earning one additional point.

    WARNING: complicated logic entity talk ahead!

    Here's how it works. The basic structure of a CP map is present, with the 7 control points all being managed by a team_control_point_master. The CPs and CP-master alone makes for a playable map, where a team wins by capping all CPs.

    The team_round_timer controls the alternate win condition: controlling more CPs when time runs out. To do this, there are two math_counter entities present, one for each team. Their initial value is 2 (because each team starts with 2 CPs), and whenever a team captures a point, 1 is added to the math_counter.

    The first problem (differentiating whether a team capped an opposing team point or a neutral point) comes into play when deciding whether to subtract a point from a team's math_counter, because they lost a point. This is no problem for the points that start with an owner, but if Blue captures a neutral point, Red didn't lose a point.

    This is solved by adding two logic_relay entities for each neutral point. One logic_relay subtracts a point from the red counter when triggered, and the other subtracts one from blue's counter. They are both initially DISABLED. When a neutral CP is taken, the trigger_capture_area tries to trigger the logic_relay to subtract a point, but it cannot because the relay is disabled. Then after a delay, both logic_relays for the point are enabled so that future captures of that point will subtract points from the counters as normal.

    So now the map can properly count the number of CPs each team has at any given time, the alternate win condition can be implemented. There are three logic_relays, initially disabled, that trigger three game_round_win entities, one for each possibility (Blue win, Red win, stalemate). There is also a logic_compare entity, that fires the correct logic_relay win condition given the two team's counter's values. The math_counter's are also set to feed their values into the logic_compare whenever their values change. The problem here is that whenever they do that, the logic_compare tries to evaluate! We don't want the round to end early, so all the win condition logic_relays start disabled.

    We want the win condition to be chosen when the timer has ended. So the team_round_timer, when time expires, enables all three win conditions and makes the logic_compare make a comparison. It takes the current point scores and choses a win condition. Hurrah! A team won, or it stalemated.

    Now, we could stop there, but let's try to add a custom scoring system. Let's have a team earn one point per CP they hold when the round ends, and give the winning team one point for the win. Using http://developer.valvesoftware.com/wiki/Team_score_with_brushes as a guide, there are seven game_score entities, each one corresponding to change in team point scores, 1 to 7. A logic_case entity chooses a game_score to trigger based on the value it is given as input. To trigger the input, two trigger_multiple brushes are made that span the entire map, one for red and one for blue, and their filters are set to corresponding filter_activator_tfteam filters. They are initially disabled because we don't want points randomly added in the middle of the round, but when they are triggered they fire the GetValue input of its team's math_counter. The GetValue causes the math_counter's OnGetValue output to fire, which gets input to the logic_case that decides how many points a team gets. Tricky!

    So when do we want players to get points? When the round ends. So in the team_round_timer we add triggers to enable the two big trigger_multiple's, and then disable them a split second later. This allows scoring to happen once. We also add similar triggers to cover the "capture all CP's" win condition. You can do this in the team_control_point_master but I chose to put them in the math_counter's OnHitMax output to attempt to solve one of the problems that came up.

    If you followed all of the above, you should understand exactly what the above VMF contains and how it works. You can modify that system to fit your needs.

    Now, a few problems remain:

    - A team will not be able to score extra points if they have no players! This is because the trigger_multiple's won't be able to trigger if there are no valid players inside. We can't stop a team from not getting points if they have no players, but why would you play with only one team anyway? If you're testing the map alone, make a bot and switch him to the other team. You can even have the bots capture CP's for you. (console commands: sv_cheats 1, mp_teams_unbalance_limit 0, bot, bot_changeteams, bot_mimic_yaw_offset 0, bot_mimic 1)

    - Every control point warns that it is "the final control point". This can probably be fixed by actually implementing the CP layout to include a final control point.

    - If a team wins by capturing all control points, the score is not updated immediately. (i.e. popup shows the score is 1-0 but viewing the score screen shows the score 8-0) I'm not sure how to fix this. We could make the map impossible to fully cap? :)
     
  2. MacBeth [O.C.Reg]

    MacBeth [O.C.Reg] L1: Registered

    Messages:
    8
    Positive Ratings:
    2
    Congratulations on fixing your cp issues. I have some similar ones I'm still wrestling with...

    When you say "every control point warns that it is "the final control point"" - do you mean the audible warning? If so then isn't that just set in the point_warn_sound keyvalue? The default one is (I think) the "final control point" warning - there's another sound file that just says "the control point is being contested/captured".
     
  3. hacky

    hacky L2: Junior Member

    Messages:
    83
    Positive Ratings:
    0
    I thought that too, but then I checked the decompiled versions of the valve maps, and every CP uses the same point_warn_sound. I'm guessing that it's context-sensitive... and that the problem is that it thinks each point is a final control point.
     
  4. DrHaphazard

    DrHaphazard L5: Dapper Member

    Messages:
    249
    Positive Ratings:
    12
    Just wanted to say good work on figuring out how to do all that, sound very complex. As to the final point problem, that seems like it should be fixable, althought I have not looked at the valve maps enough to see what might be done.
     
  5. hacky

    hacky L2: Junior Member

    Messages:
    83
    Positive Ratings:
    0
    The "final control point" voiceover is actually controlled by the Warning Sound of each control point. It's the default. I changed it to Announcer.ControlPointContested and the voice announcements are much more fitting.

    I also found a way to have the scoring turn out the way I want. I added an 8th control point, neutral, and with no previous required point for either team (so it's essentially locked until all 7 other points are capped). But I added win conditions to each math_counter: a team wins when they cap 7 points. Sneaky and devious, and it makes the score work. As for that unused control point, I'm planning to place its icon in the center and replace the default lock with something decorative and useful for the HUD.
     
  6. DrHaphazard

    DrHaphazard L5: Dapper Member

    Messages:
    249
    Positive Ratings:
    12
    Haha its good to be sneaky and devious when trying to think outside the box in TF2 mapping apparently. Well good job hacky!
     
  7. tripknotix

    tripknotix Guest

    Positive Ratings:
    0
    sounds like someone has been peeking in my map? ;) i'll have a more thorough explaination of how and why everything i did was done the way it was, and maybe you can help me create the tutorials for it
     
  8. tripknotix

    tripknotix Guest

    Positive Ratings:
    0
    but yes, u must have a control point that cannot be capped =P and more so im surprised you didnt have to have each one controlled from the start (also even number) , i'll have to read through this more thoroughly tomarrow to see how u managed that.