The kick

Date: January 9, 2016 Posted by: Chris St. John In: Uncategorized

The kick is central to the HaxBall experience. In building HaxArena, some complex problems arise from this apparently simple mechanic. In this post, I will attempt to contrast HaxBall and HaxArena with respect to the kick. As always, all questions and comments are welcome.

The range

HaxArena players and ball are modelled as circles. Detecting whether a kicking player is able to kick the ball is theoretically simple: check the distance between the player’s centre and the ball’s centre; if this distance is equal to the sum of the radii, they are considered touching and the ball should be shot.

There are a few problems with this approach. The first one is about rounding error: the distance will never exactly equal the sum of the radii. The second one is about playability: if you lift your finger off the move button for a split second and then try to shoot, the ball will roll off your player ever so slightly, and the shot will not happen.

To mitigate these effects, we consider the ball to be shot if the distance between the bodies is within a certain small threshold. The value of this threshold has to be determined by trial and error and I invite you fine people to help me out with that.

The effect

The effect of a successful shot is that an impulse force is applied to the ball from the direction of the shooting player. The ball blasts off in the desired direction.

Watch out

Because a player needs to be “close enough” to a ball to be considered shooting it, it’s possible for the impulse force to be applied on more than one successive frame, resulting in a ridiculously powerful shot. Obviously this is not desired: only a single impulse force should be applied per contact. How can we achieve this?

HaxBall solves it by clearing the player’s kicking state whenever a successful ball kick is detected. If a player wants to kick the ball more than once, he will have to release the kick key and press it again. To produce a rapid-fire effect, the player has to spam the “x” key as quickly as he can.

Macro

HaxBallers are clever people, so what do they do? They install macro hacks that simulate rapid key presses and releases in the Flash client. Such a player can now usually out-muscle a player who is spamming the “x” key manually. Is this ethical? Cheating? You decide.

In HaxArena, I’m proposing to let the player simply hold down the “x” key, but when a successful kick is detected, the player gets a 100ms (or so) kick cool down, during which the player cannot kick the ball again. When the cool down expires, another successful kick can be detected. In this way, everybody starts out on a level playing field and nobody has to hack the client.

There is one drawback that I can see with this approach: maybe the HaxBall kick-reset idea is actually preferred in some cases, and now it would be impossible. I’m not pro enough to know if this is a problem, what do you think?

Rocket, double wall bounce

A rocket (called other things in other places) is when two players kick the ball at the same (or nearly the same) time, producing a very powerful shot. This idea is still possible in HaxArena, since each player’s kick cool down is tracked separately.

A double wall bounce — there’s probably a better term for this but you get the idea — is when a player kicks the ball off the wall towards himself, and then kicks it again almost immediately downfield. This is similar to a rocket, except that the two impulses are provided by the same player. In HaxArena, it is possible to execute this maneuver by simply holding down “x”, but it takes some practice to figure out the timing and the proper angle of attack.

Interesting effects

It has been observed in the comments that letting the ball roll closer to your player before shooting produces a stronger shot. Let me share my observations from HaxBall and HaxArena alike on that subject.

First, if you nudge the ball forward by moving before taking the shot, the result is more powerful. This is because the ball is already moving with positive momentum when the impulse is applied.

Second, if the ball is coming toward you when you take the shot, the result is weak indeed. This is because the impulse is added to the negative speed. If, for example, a red player takes a shot, and a blue player makes a save with the “x” key, the ball will roll ever so slowly away from the blue player. This is because of the small amount of speed that the ball lost in flight after being shot by the red player.

So I think the observation may amount to this: if the ball is rolling towards you, you can produce a stronger shot by first letting it hit you, then shooting. This is because the ball will then pick up two impulses: one from the collision with you, and a second from the shot. I don’t know if simply closing the distance between the player and the ball actually increases the strength of the shot. I also don’t know if the player’s velocity at the time of impact affects the impulse force applied to the ball by a successful kick. Please share your experience!

Summary

When I get proper physics simulations out, I invite everyone to try out these ideas, and let me know how they compare to HaxBall. My aim, as I have said many times, is to reproduce HaxBall as closely as possible so that your long hours of experience will not go to waste.

26 thoughts on “The kick

  • Uygar Yalcin says:

    When beta start ?

  • Kevin Wissel says:

    At the HaxBall News page one player wants to have bots in HaxBall. Is this possible?

  • Petras says:

    I didn’t read all of it and I didn’t read the comments, but what catches my eye is:

    “if this distance is equal to the sum of the radii, they are considered touching and the ball should be shot.”

    You don’t need to be touching the ball to kick it in Haxball. On a 1080p moonitor there is about 1-1.5 mm space that you can have between the player and the ball and still kick it.

    “HaxBallers are clever people, so what do they do? They install macro hacks that simulate rapid key presses and releases in the Flash client. Such a player can now usually out-muscle a player who is spamming the “x” key manually. Is this ethical? Cheating? You decide.”

    Players who think speed between kicks is either important in tanking, winning microfights or doing tricks are wrong. Macro is good for one thing and one thing only – to keep the intervals the same (used for specific tricks).

    From my experience all over European leagues, tournaments and public rooms players who accuse opponents of macro are usually unskilled players looking for an excuse. Macro gives very little competetive advantage, but rather a different way of doind techniques.

    Say John is a pro player and he is using macro. He’s trying to do a double lift, but he messed up his position and fails.

    Say Jack is a pro player and he is not using macro. He messed up his position, but he can alter his kick timing to still accomplish the trick at least to a partial effect.

    Jack has the advantage to still do his trick when he is off-position, but John has the advantage, that if his positioning is perfect, he will always suceed with the interval.

    So using macro is a) very hard to learn to the effect that it is useful in high end competetive games b) even if you learn it, it’s more of a trade-off or a double edged sword rather than some kind of an unfair advantage.

    I personally tried to learn macro for about 2 months maybe 2012 but it didn’t stick and I never used it since, so I would say I’m not biased in any way.

    If there is some kind of problem to prevent players from using macro or you need to change some sort of mechanic i.e.:”everyone, even noobs, will be able to kick at the same speed by just holding down “x”.”

    (It has zero importance for me if noobs can kick fast or not, but I imagine in some situations in the game this kind of change would alter how you need to play i.e. you hold x when you want to have the ball ricochet a single time, though I admit those kind of situations are rare).

    I would say leave it as is and don’t worry about it. If the community is disatissfied with it once the game is out you can always find ways to prevent it.

    • Hi Petras,

      >You don’t need to be touching the ball to kick it in Haxball.
      I know. The same section goes on to say exactly that. 🙂

      I like your summary that macro is a trade-off rather than a genuine advantage, at least for pro players. I was thinking of adding it into the game as a natural mechanic because I remember the first time I encountered a macro player and thinking it was unfair and he was cheating. I just don’t know if pro players will find it to be a burden in those rare situations you mention.

      I’m considering putting it in by default, and if there’s a huge public outcry we can remove it.

      • Stoyan says:

        He’s right about the macro thingy. But this is only on a pro level. I’ve played on high-end tournaments (Nations Cups, Country Championships, Champions League) and there, macro is not something that gives you a huge advantage – just because every PRO player knows how to counter it. You engage into a microfight(spam battle) and you simply don’t press kick, the guy spams the macro and you get kicked away from his range with the ball at your position – win situation for you. Another thing – I’ve played in public rooms where players AREN’T that good versus macro players – most of them had no idea what to do with the macro and at most situations the macro was more useful for me, rather than for them. So as Petras said, just let it be like it is, don’t add it in the game, because many blank-minded players will cry – “OMG WTF is this cheat included in the game??”. Just let them use it as they use it now(with 3rd party software) but don’t add it in the game, it would look pathetic and as if you encourage players to use other software to gain any gameplay ‘advantage’. As Petras said, most of them have no idea what macro does and they think it’s SUPER-IMBA-POWERFUL cheat that can beat anyone, while in reality – it’s nothing like that. It’s just good for your reputation to not add it on the first version of the game(release version)

        • This is great perspective. The OMG-IMBA-WTF effect was exactly what I was aiming to avoid because that’s how I felt when I first encountered it. Now I’m learning that there are ways to defeat it, so it’s not really a weapon, just a tool.

          Keep the thoughts coming, people, this is great stuff.

        • Jim says:

          It is important that there is an equal playing field, under any circumstance. There should be no “noobs” and “pros”. Cheaters and people who try to gain an unfair advantage should not have the same treatment as people who respect the game and don’t attempt to abuse the mechanics. This is an aspect in which Haxball has failed. Having said that, integrating the macro mechanic as a feature may well be an option but it will have a drastic effect on the experience. Just because someone can have a cheat that can give an advantage when used in a certain way, without completely obliterating his opponents in a game, does not mean that the game should change its mechanics. Integrating the cheat in the game should not be a tactic of battling cheating. The implementation of a feature must be in order to provide for a more enjoyable gameplay. If the intent consists only of essentially adding a rule that warrants what formerly was cheating, the cheaters have already won. Please do not take this comment as an attack to anyone in any way. I’m just stating that if you want to stick true to the Haxball experience, macroing, even as a game feature should not be there. If you want to reinvent the Haxball experience, you have every right to do so, but in this case it will cause a major drift away from what Haxball stands for.

        • Stoyan says:

          Just going to post this as an addition to my previous post:
          If you so want to implement macro as a feature, you would do great if you make it visible for the other players, so for example, if player X is using the macro feature, you can see this somewhere near his name – maybe a small ‘M’ letter somewhere near his name, indicating that he’s using a macro and other players should be aware of that. That would help A LOT, because in cases where you want to implement the macro, I’m sure a lot of leagues from HaxBall would want to keep their current rules(which are strictly against macroing) and that would let them know who player has the macro feature turned on or off. Of course, in my personal opinion – I’m against macro feature in the game.

        • In reply to both Stoyan and Jim:

          Here’s a thought, what if the macro feature was treated as a tool for beginners, a sort of “training wheels” mode that he could use whilst figuring out the game. A player could turn it on/off and have it prominently visible in-game, as Stoyan suggests. But the game can be designed to discourage its continued use after some length of time. An example could be issuing an award called “the training wheels are off” for 10 straight games with macro disabled, etc.

          By building the feature into the game, a room (e.g. for league play) can be configured not to allow the macro feature to be activated. Of course I would still need to be on the lookout for people who were cheating using external tools.

  • swag says:

    Please don’t add the hold x thing, knowing how to time x’s for rockets and wall tricks is one of the main elements in haxball. But macro would still be a problem, so perhaps add macro detection (idk if this is possible).

  • Kevin Wissel says:

    How can I get an access code to sign up the game? The features sounds good, and I really want to test this new game 🙂

  • $$$$$$$$$$ says:

    As a European, when can we expect the availibity to gain an access code and test the play.HaxArena.com beta.

  • monster says:

    Hello there!
    “HaxBallers are clever people, so what do they do? They install macro hacks that simulate rapid key presses and releases in the Flash client. Such a player can now usually out-muscle a player who is spamming the “x” key manually. Is this ethical? Cheating? You decide.
    In HaxArena, I’m proposing to let the player simply hold down the “x” key, but when a successful kick is detected, the player gets a 100ms (or so) kick cool down, during which the player cannot kick the ball again. When the cool down expires, another successful kick can be detected. In this way, everybody starts out on a level playing field and nobody has to hack the client.
    There is one drawback that I can see with this approach: maybe the HaxBall kick-reset idea is actually preferred in some cases, and now it would be impossible. I’m not pro enough to know if this is a problem, what do you think?”
    I think this is an unnecessary change. In the “x” would leave it as it is in haxball, but I suggest you arrange something Overwatch type of game CS GO, where players who use cheat ban would be punished.

    Best Regards,

  • Stoyan says:

    Hello there!

    I have a suggestion! I completely understand that you want to let the pro players do their stuff like in HaxBall, but you want to limit the cheaters/macro users. My suggestion still has one weak point and I will let you know about it too.

    So, you can let a few pro players test out and HaxArena without a cooldown of the kick. The idea is to test out and DECIDE on your own – What’s the BEST speed a human being can achieve while tapping the X button? Or in other words – How many kicks per second can a human being do at his best? Of course, this won’t be accurate, as player A can spam more than player B, but player C can spam even more than player A. So the idea is to test – A LOT. With many tests, you can EVENTUALLY see what’s the maximum that a human being has achieved.

    And then you can convert this into cooldown. How come? You see that some of your testers has provided BEST results in spamming. And his best results would mean that AT HIS BEST (don’t chase periods of spam like 5-10 seconds) – the time between his TWO best shots was 0.003(i’m randomly typing this number, it’s nothing close to what a human being can do). Then you say – okay, we put the kick cooldown to 0.003, so nobody can spam more than that. That way, if your TESTS were appropriate and the player who was testing wasn’t using any macros and is ACTUALLY a decent HaxBall player who knows how to perform most of the tricks in the game that are used and will probably be used in HaxArena too. Then, you will get a very well set cooldown, meaning you won’t RESTRICT any of the pro players as they’ll be able to do their stuff and at the same time macros wouldn’t be that efficient-… or wouldn’t they?

    Here comes the weak spot of this suggestion – After a while, people will test their macros and EVENTUALLY they will find out what’s the cooldown of the kick ( in miliseconds) and will set their macro to pump X the exactly same amount that is required to fulfill the cooldown (without losing any miliseconds).

    Maybe a later-on sollution of this might be adding a system that detects how many kicks you do per second and for how long do you do that. Because FRANKLY – if my best time between shot 1 and shot 2 is 0.003(again the same random number) – I can absolutely guarantee you that I can not keep up with that tempo for my next shots – and it’s absolutely impossible for a human being to keep up with that tempo, whether it being making 5-6 perfect shots or simply keeping up with that tempo for 5 minutes. No human being can be THAT exact to keep up with that tempo without having ups and downs, eventually spamming quicker or slower. It simply is not possible. And here is how you catch cheaters/macro users. The macro works with pre-set values. So I set it to work with delay of 0.003 seconds per shot and it keeps doing that. I press the button I’ve bound to the macro and it keeps producing shots with 0.003 seconds delay – not faster, not slower. And that’s how you can catch macros, because a human being would have difference in his performances, while the program will work at one pre-set level all the time.

    Opinions?

    • Hi Stoyan,

      The methods you describe are all excellent ways to detect and catch cheaters. I could probably take a page or two out of the poker sites’ playbook along the same lines (e.g. if the mouse cursor always lands on the same pixel on the RAISE button, it’s probably a bot).

      However I’m trying to devise a solution where spamming a key at a superhuman rate doesn’t actually help the player. The cool down is my attempt to do this: no matter how fast you or your script mashes the key, my system will not register a second kick until your cool down has expired.

      Your idea of measuring the kick rate of testers to set this cool down period is a good one. I will probably do this. But be warned: everyone, even noobs, will be able to kick at the same speed by just holding down “x”.

  • Bruxãø says:

    Data Expected To Launch ? HYPEEE

  • maod says:

    “To mitigate these effects, we consider the ball to be shot if the distance between the bodies is within a certain small threshold. The value of this threshold has to be determined by trial and error and I invite you fine people to help me out with that.”

    This is how it works in Haxball, too; you get a little bit of wiggle room. There are quite a few people (Serbian hackers) who have disassembled the Haxball client and who probably know the exact values.

    “Because a player needs to be “close enough” to a ball to be considered shooting it, it’s possible for the impulse force to be applied on more than one successive frame, resulting in a ridiculously powerful shot. Obviously this is not desired: only a single impulse force should be applied per contact. How can we achieve this?”

    Actually, you can perform an open-field double-kick in Haxball, and I think it happens for the same reason that you’ve described in “interesting effects.” Usually, the ball has to be travelling at you at a speed almost equal to the velocity imparted on the ball by a normal kick. After the first kick, if the ball is rolling forward ever so slightly, you can get a second kick in before it leaves your kick radius if you make the second kick quickly enough. It doesn’t happen very often, but I’ve seen it.

    “In HaxArena, I’m proposing to let the player simply hold down the “x” key, but when a successful kick is detected, the player gets a 100ms (or so) kick cool down, during which the player cannot kick the ball again. When the cool down expires, another successful kick can be detected. In this way, everybody starts out on a level playing field and nobody has to hack the client.”

    I don’t know if this would work so well.

    While a human can probably only legitimately manage to kick at an average frequency of 5 Hz for any extended period of time, I think that a skilled haxball player could perform a double-tap in under 100 ms. Maybe he couldn’t reliably perform a double-tap this quickly, but I think it would at least be possible for a significant percentage of his attempts. If you set a hard limit at 100 ms, then these players are going to be failing rocket shots when they should be completing them.

    Obviously, players could try to refine their technique so that they never kick the ball so quickly, but I think that a better way to do this would be to give the player a (hidden) energy meter that is partially depleted upon kicking the ball and constantly regenerated (whether the kick key is held or not). The effect of this is that the player has a “kick bank” (for example, of four or five kicks) that can be expended over any duration of time. However, because the energy regenerates at a rate of about 5 kicks per second, the game won’t allow the player to kick at an inhuman rate for any extended period of time.

    There is no way you’ll ever be able to detect and eliminate automated double-tap macros without affecting legitimate players. With this kick energy, though, you’ll at least be able to clamp down on players who have an spam-kicking script.

    ” I don’t know if simply closing the distance between the player and the ball actually increases the strength of the shot.”

    I don’t believe this is the case. There are some custom maps in which the player can’t collide with the ball, but can still kick it. In these maps, shot speed is not affected by the degree to which the player occludes the ball.

    “First, if you nudge the ball forward by moving before taking the shot, the result is more powerful. This is because the ball is already moving with positive momentum when the impulse is applied.”

    Yes. This is even more apparent in SpaceBounce. It’s rather difficult to make a reliable one-time shot in that game when you approach the ball with speed. Sometimes you’ll baby kick it, and other times you can shoot the ball all the way across the field, which, I imagine, are the respective results from kicking the ball before or after it hits your player. I even wonder, in SpaceBounce, if the amount of time that passes between the ball hitting your player and the ball subsequently bouncing outside of your kick-radius is less than one physics timestep.

    However, it’s much easier to make a reliable one-time shot in Spacebounce if you let the ball approach you slowly as you kick it, although the ball doesn’t always go as far. It’s an interesting risk-reward thing that results from the physics simulation.

    • Hi maod,

      I think I didn’t make one point clear. In my holding-shoot proposal, it doesn’t matter if a player spams the key (manually or via script); regardless, the simulation refuses to register any kick until his shot cool down has expired. The cool down is not reset when the player releases the key. Spamming hacks are still possible, but have no effect.

      The kick bank idea is interesting, but still leaves open the possibility of an open-field double-kick described in the “watch out” section. 🙁

      I face a tradeoff between rewarding the extremely speedy fingers of the pros (thereby exposing myself to client-side hacks), and simply setting a speed that everyone can spam at by simply holding the key down. We’ll see what others think.

      Thanks for this detailed comment!

    • sok says:

      “This is how it works in Haxball, too; you get a little bit of wiggle room. There are quite a few people (Serbian hackers) who have disassembled the Haxball client and who probably know the exact values.”

      It’s 4 flash pixels according to the source code.

      Other values are:

      bouncingQuotient = 0.5;
      invMass = 0.5;
      damping = 0.96;
      acceleration = 0.1;
      kickingAcceleartion = 0.07;
      kickingDamping = 0.96;
      kickStrength = 5;

      HaxBall has fixed tick based logic and kick impulse is applied every clock tick if “kick” button is on. Physics constants are configured to avoid double kicks.

    • $$$$$$$$$$ says:

      ‘This is how it works in Haxball, too; you get a little bit of wiggle room. There are quite a few people (Serbian hackers) who have disassembled the Haxball client and who probably know the exact values.’

      I can give you the decomplied SWF file if you want?

    • swag says:

      “Yes. This is even more apparent in SpaceBounce. It’s rather difficult to make a reliable one-time shot in that game when you approach the ball with speed. Sometimes you’ll baby kick it, and other times you can shoot the ball all the way across the field, which, I imagine, are the respective results from kicking the ball before or after it hits your player. I even wonder, in SpaceBounce, if the amount of time that passes between the ball hitting your player and the ball subsequently bouncing outside of your kick-radius is less than one physics timestep.”

      No idea why, but typically holding x before the impact results in baby kicking, while x’ing at the exact time of impact results in extremely strong kicks.

Leave a Reply

Your email address will not be published. Required fields are marked *

ERROR: si-captcha.php plugin says captcha_library not found.