Hit detection server side or client side?

ViPrViPr Resident naysayer Join Date: 2002-10-17 Member: 1515Members
is the hit detection going to be client side like i think counter-strike is? can you aim at where you see the enemies on your computer or do you have to aim where you think the enemy will be on the server by the time your shot registers at the server bearing in mind that what you see on your computer at any instant is where things were on the server a while ago?

Comments

  • NecroNecro <insert non-birthday-related title here> Join Date: 2002-08-09 Member: 1118Members
    pretty sure its clientside.
  • richard_of_richardlandrichard_of_richardland Join Date: 2002-05-29 Member: 687Members
    Hit detection is ALWAYS server side, even with clientside animations. That is why on modems, if you shoot a pane of glass, there is a noticable delay between shooting and it breaking.

    However there is client-side animations and prediction, but hit detection would be impossible client side, as everyone would get horribly out of sync. Also it would be a nightmare as far as cheating goes, people could hack it so that it sent a packet telling the server they just headshot the entire enemy team.
  • NecroNecro <insert non-birthday-related title here> Join Date: 2002-08-09 Member: 1118Members
    pfff my bad i though he was talking about prediction :o
  • ViPrViPr Resident naysayer Join Date: 2002-10-17 Member: 1515Members
    are you sure. what does counter-strike use? anyway with your glass example couldn't it also be that as soon as you fire then your computer registers that you hit it but it only breaks when the server has got the message that you had hit it and said your computer can then do the break animation. i think the same can happen when you shoot people. as soon as you fire at someone and hit them you might see the blood come out but then sometimes you can stop shooting and then see them drop dead a split second later. that is because your computer realized that you hit them immediately but you have to wait till your hit messages reach the server and the server lowers their health to zero and then tells your computer they died before you see the death animation on your computer.
  • NecroNecro <insert non-birthday-related title here> Join Date: 2002-08-09 Member: 1118Members
    vipr, its serverside in cs and everything else.
  • BJayDBJayD Join Date: 2002-09-02 Member: 1263Members
    The detection is serverside. From my vague understanding, the way it works is:
    When you shoot on you client, the client tells the server that you made a shot. Ordinarily, the server would the determine if your hit was succesful or not. In HL and mods, there is lag compensation to make it fairer for people on lower speed connections. (I believe this can be enabled and disabled with sv_unlag)
    Well the server checks your ping and calculates where everything would have been when you took the shot. So if you have a ping of 200ms, the server will check if the target would get hit by the bullet 200ms ago, even though the person with the faster connection may have moved around a corner. If the target would have been hit, he gets hit, if not, he doesn't.
    Understandably some low pingers can get annoyed by this as to them it seems like they're getting shot around corners and through walls, but it is in fact an attempt to make the game fairer to high pingers.
    So basically...the server does do the hit detection but it compensates for your lag so if on your screen you hit it, theoretically you should on the server too.
  • SurgeSurge asda4a3sklflkgh Join Date: 2002-07-14 Member: 944Members
    The weapons are hitscan. That means it doesn't track the whole projectile, because that would cause lag.

    Voodoo got it somewhat correct.

    When you fire at someone, the client sees the muzzle flash at once. This is to give the appearance of zero lag. This is where it somewhat favors HPBs. However, it can disfavor them too....
    When the client fires, the server detects to see if the attack would have hit. However... there is something different. The client ALSO detects, client-side, if the bullet would have hit something, and instantly draws the hit sprite, whether it be sparks, blood, dirt, whatever. This is another way it gives appearance of no lag.

    This means that you may see blood on an enemy, when, in reality you didn't hit them. This is, however, rare, because, well, bullets are fast, folks. <!--emo&:)--><img src="http://www.natural-selection.org/iB_html/non-cgi/emoticons/smile.gif" border="0" valign="absmiddle" alt=':)'><!--endemo--> When you see blood, this usually means you hit. Of course, unless you're playing AvP2.

    For more information on this, go to <a href="http://www.summerblue.net/games/cs_report/" target="_blank">Counter-strike top secret file</a> to learn about how the old CS versions had many bugs and faults. And on the <a href="http://www.summerblue.net/games/cs_report/2_3_latency_issues.html" target="_blank">third or fourth page</a> it will tell you how client-side weapons work, and hitscan stuff. You should get the Divx codec so you can view their shocking videos, too. Thankfully, the newer versions have fixed some of these problems. But <i>not</i> the hitscan problem.
  • richard_of_richardlandrichard_of_richardland Join Date: 2002-05-29 Member: 687Members
    This is why by default in HL the blood itself (unlike other graphical effects) are NOT predicted. (Although you can change it), because that way, with hitscan weapons with a "random spread" accuracy attached, if you see blood, it will be delayed, but you definately hit them. You can actually get very occasionally a bullet mark in a pane of glass that normally breaks in one shot, because your PC calculated the 'random spread' (like recoil) and it hit, but this was never sent to the server, and there server recalculated where you hit from just where you had your crosshair, so it will have calculated it as a miss.

    So you can't trust sparks and bullet decals, or anything else that appears immediately, but things you have to wait for (usually things that are affected globally like windows) you can be sure they were real hits.
  • ViPrViPr Resident naysayer Join Date: 2002-10-17 Member: 1515Members
    wow sounds complicated. yes i heard about unlagging. i think you're right about how it works, but i'd just like to repeat it back to you in my words to make sure i understand it correctly. i think unlagging means the hit detection is server side but you can still aim exactly where you see things on your computer instead of aiming where you predict enemies will be on the server in the future. this is because with unlagging, when the server gets the message that you fired a shot, instead of checking against the current positions of everything on the server, it checks against recorded positions from the past because it tries to guess what the player was seeing on their computer at the time they made the shot. it knows when it receives a shot message that this shot was made a while ago and it knows that at that 'while ago', the player was seeing on their computer what was happening on the server a while before that. so the server uses your ping to estimate how far back in it's records it should look. this system works well if your ping stays pretty much constant.

    anyway i really want to make sure it is correct in this mod. i think just because it's made in half-life doesn't guarantee that the hit detection will work well because there is another mod for half-life called Svencoop where it looks like it must have been done completely wrong because i am never able to hit things that are moving across my view by aiming straight at them when i play on someone else's server. my ping was around 300 * when i did that by the way. i can hit them sometimes by aiming ahead of where they are going. thankfully in Svencoop, the computer controlled enemies happen to stand still alot of the time so that's when i try to kill them, and i usually end up getting the highest score with the lowest deaths even though i have the highest ping, but in NS i'm sure i will not be able to wait for the enemies to stand still. anyway i want the NS coders to know i am here to help test this mod for them. i pay close attention to these things. unfortunately it might be harder to test this mod because the guns use randomization firing cones instead of American Army's moving crosshair type system. in Svencoop i was able to test using the magnum because its bullets don't go in random directions at all. there was another mod called hunt for quake3 where i convinced the coder to remove the enlarging crosshair system and replace it with the moving crosshair system and then i was able to find out for him that one of the enemies in his mod had no hitbox for it's head. we were not able to notice this before because the shots never went where we aimed before.

    *i have DSL but the server situation for Svencoop is pretty pathetic; i was not able to find one near me. i can play CS with around 30 to 40 ping though but i hate CS because of its hugely random and misleading aiming system.
  • ScytheScythe Join Date: 2002-01-25 Member: 46NS1 Playtester, Forum Moderators, Constellation, Reinforced - Silver
    <!--QuoteBegin--Surge+Oct. 17 2002,20:16--></span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td><b>Quote</b> (Surge @ Oct. 17 2002,20:16)</td></tr><tr><td id="QUOTE"><!--QuoteEBegin-->When you see blood, this usually means you hit. Of course, unless you're playing AvP2.<!--QuoteEnd--></td></tr></table><span id='postcolor'><!--QuoteEEnd-->
    /me sets fire to Surge *

    I play AvP2 online regularly with pings in excess of 200ms and I've had no serious lag issues. Even with half a dozen aliens nibbling at your kneecaps.

    I don't understand why people form opinions on things they've never played or seen. You ask the average joe-on-the-net about the Lithtech engine and AvP games in general they'll say something along the lines of "LITHTECH R T3H S0X0R! IT R H4V3 T3H B4D L!GHT!NG! AND IT R T3H LAGZ0R!" Not specifically pointing my finger at Surge particularly.

    --Scythe--
  • MoleculorMoleculor Namer-of-Bob Join Date: 2002-01-24 Member: 9Members
    ViPr, you have the description of the standard HL hit-detection entirely correct, and as far as I've been able to tell in game, if that -isn't- implimented, Flayra did something even more l33t somehow. You don't have to lead your target, don't worry. (Except with projectile based weapons, like spit, acid rocket, and the grenade launcher. But with that it's just leading for projectile travel time, really.)
  • richard_of_richardlandrichard_of_richardland Join Date: 2002-05-29 Member: 687Members
    Vipr did an excelent of the sumamry of the client-side weaponry that isn't actually standard in HL. It needs to be coded by mods, which is another reason why smaller modss struggle, because often they don't have the coder to do this.

    "large" mods (dod, cs, ns, flf) have this, and with this you don't need to lead shots at all.

    There is the bog standard network code which I think is the same as the Quake netcode, with a few optimisations to reduce lag.
  • SimillionSimillion Join Date: 2002-07-07 Member: 892Members
    Speaking of other mods with this code, it's my experience that Science and Industry has the server-side hit code incorrect or didn't even try. Oftentimes in that mod I find myself strafing in the same direction as my target with my crosshairs trained on him, and although it looks like my shots come out instantly, every bullet lands behind him, as if I see my gun fire instantly, but it's actually firing a fraction of a second later.

    Another kind of problem is the horrible "delayed shot" problem I used to have with Firearms; every shot took approximately 1 second to appear, due to my pretty awful ping of 300 or so.
  • RhoadsToNowhereRhoadsToNowhere i r 8 Join Date: 2002-01-24 Member: 33Members
    Simillion, are you referring to the Science and Industry .98 beta, or to the current version .97a?  Nobody knows what's up with .98, but I can tell you for sure that hit prediction works quite well in .97a.  It's just that the client-side animations aren't drawn at the correct time, so it looks like you're firing after you are.  This can obviously be pretty disorienting.  However, the bullets are definitely fired when you push the attack button.
  • SimillionSimillion Join Date: 2002-07-07 Member: 892Members
    Maybe that's it Rhoads... I'm using .97a. I don't know, perhaps what I think is the game's fault is just me sucking. [Llamafilter TM.] lol.

    Seriously, perhaps if that's the case, then what I think is a shot appearing late is actually a shot appearing early, and me seeing it appearing late. Either way, I'm going to have to go test it out some more later...

    Thanks for the info.
  • richard_of_richardlandrichard_of_richardland Join Date: 2002-05-29 Member: 687Members
    client-prediction whilst strafing is fairly dreadful in most mods with this.

    It's just in other games you strafe faster than you do in CS, so in CS it's less noticable (even more so since the CS guns are generally less accurate, so you'd just think it was spray), but in games where you move much faster like FLF and tfc- scout it becomes very noticable at times with higher ping.
Sign In or Register to comment.