shavitush / bhoptimer

A bunnyhop timer plugin for Counter-Strike: Source, Counter-Strike: Global Offensive and Team Fortress 2.
https://timer.shav.it
GNU General Public License v3.0
228 stars 93 forks source link

[TF2] Add correct bounding box values for shavit_zones_box_offset #1179

Closed jedso closed 1 year ago

jedso commented 1 year ago

TF2's bounding box is 48x48x82 compared to CS:S 32x32x62 and CS:GO 32x32x72. As such, the default value of gCV_BoxOffset (bbox width / 2) is slightly off the player's center for TF2.

In SetZoneMinsMaxs, the height variable is half the bbox height but does not use the correct value for TF2 either (uses CS:S 62.0 instead of 82.0). This PR adds the correct bbox values for TF2.

As an aside, I did wonder if having height be constantly set to half the bbox height is really the desired behavior. E.g. if shavit_zones_box_offset = 0, why should distance_z be offset by half the bbox height yet have no offset for distance_x/y?

https://github.com/shavitush/bhoptimer/blob/a6da4358de06937b095dcafd79050e4ea937844a/addons/sourcemod/scripting/shavit-zones.sp#L5104-L5114

rtldg commented 1 year ago

As an aside, I did wonder if having height be constantly set to half the bbox height is really the desired behavior. E.g. if shavit_zones_box_offset = 0, why should distance_z be offset by half the bbox height yet have no offset for distance_x/y?

Yeah, I think you're right about it not being desired/expected/optimal with shavit_zones_box_offset = 0. I'll add a commit for it to this PR and then merge this in.

rtldg commented 1 year ago

I'll add a commit for it to this PR and then merge this in.

Or should I? Also I wonder if it'd be better to just make the convar a boolean and hardcode the offset per game...

jedso commented 1 year ago

Also I wonder if it'd be better to just make the convar a boolean and hardcode the offset per game...

Not a bad idea. Guess it depends how much control you want to give people. I guess 3 main solutions for this:

  1. Boolean convar to toggle between 0 offset and bbox / 2 like you say (for most people this should be fine)
  2. Height offset scales relative to the width offset (something like (shavit_zones_box_offset / bbox width) * bbox height). Allows people to set offsets other than 0 or bbox / 2
    • Or alternatively store shavit_zones_box_offset as a decimal fraction float where the default value = 0.5, then use that with bbox_width/height to get offsets
  3. Separate convars for width/height offset (not sure anybody would want/need that though)
rtldg commented 1 year ago

Ended up adding a commit to make it act like a bool & to do the height too. I'm not going to squash merge it right now so I can stare at it for a bit longer