Skip to content

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

Merged
rtldg merged 4 commits intoshavitush:masterfrom
jedso:tf2-box-offset-fix
Nov 13, 2022
Merged

[TF2] Add correct bounding box values for shavit_zones_box_offset#1179
rtldg merged 4 commits intoshavitush:masterfrom
jedso:tf2-box-offset-fix

Conversation

@jedso
Copy link
Contributor

@jedso jedso commented Nov 6, 2022

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?

float height = ((IsSource2013(gEV_Type))? 62.0:72.0) / 2;
float mins[3];
mins[0] = -distance_x;
mins[1] = -distance_y;
mins[2] = -distance_z + height;
float maxs[3];
maxs[0] = distance_x;
maxs[1] = distance_y;
maxs[2] = distance_z - height;

@rtldg
Copy link
Collaborator

rtldg commented Nov 8, 2022

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
Copy link
Collaborator

rtldg commented Nov 8, 2022

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
Copy link
Contributor Author

jedso commented Nov 9, 2022

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
Copy link
Collaborator

rtldg commented Nov 11, 2022

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

@rtldg rtldg merged commit f7ff341 into shavitush:master Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants