Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the armory use distance situation #1546

Merged

Conversation

necessarily-equal
Copy link
Contributor

Currently, there are 4 (four!) slightly different experiences in game when trying to buy stuff

  • "how far the bots see the armory" which is the same as "how far (using binds or commands) you might use the armory"
  • "the tutorial says you can open the armory with the q key"
  • "the hand button that hints you can open the armory appears"
  • "when you press q the menu opens"

This PR makes the experience nicer and make it look and feel much more consistent. I tried to avoid making a larger refactoring to avoid breaking stuff in the process (for example maybe some maps have activatable buttons?).

@necessarily-equal necessarily-equal force-pushed the armory-use-distance branch 2 times, most recently from 70cb809 to a42fd43 Compare October 19, 2021 21:59
@illwieckz
Copy link
Member

Do we need to make ENTITY_USE_RANGE larger? If I'm right with current value it's already usable for tricks like reloading though a wall and that's used by some mission maps that put thin indestructible glass in front of the armoury to protect it from alien players/bots while keeping it usable by human players.

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Oct 24, 2021 via email

@illwieckz
Copy link
Member

illwieckz commented Oct 24, 2021

I mean, it may make the trick work and be abused in situation it was not expected before (like through larger walls).

src/cgame/cg_rocket_draw.cpp Show resolved Hide resolved
src/cgame/cg_rocket_draw.cpp Show resolved Hide resolved
@bmorel
Copy link
Contributor

bmorel commented Oct 28, 2021

I also wonder why the range was increased from 64 to 96. This does not concerns me too much though, because there is currently no mission map working on unvanquished which uses illwieckz's trick (as for the bot problem, it would not be a regression since I've heard than tremulous didn't had bots).
To me, the trick of using stuff through a glass is not a good idea anyway, and I would rather see a trace here to detect collisions instead of just "oh, I see the armory, then I can certainly teleport stuff in my hands!", but this is a different problem.
I also noticed changes which prevents adding other activable buildings. Sure, originally, only humans could have some, but I would easily imagine neutral, activable buildings. Like in spacetracks, for example: this would prevent the annoying noise when on puts a building (barricade?) too close to the elevator's triggers. I see other uses for that, like having chasm's ladder trigger such a building, allowing aliens to put it back up for example.
In any case, since this is a refactoring, I see no reason to not make the code more team/buildable agnostic.
Last minor point (this really is a minor one): having this distance as a CVar would be nice. There's no need to keep this hard-coded, right?

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Oct 28, 2021 via email

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Oct 28, 2021 via email

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Oct 28, 2021 via email

@bmorel
Copy link
Contributor

bmorel commented Oct 28, 2021

there was already an hardcoded value and how to add a new buildable you would need to add it at several places anyway

Makes sense.

the reason to use a slightly lower distance is to avoid slight rounding/prediction errors

But then, you should have that slightly smaller value only in cgame, right? I'm pretty sure you did it in both cgame and sgame?

Last minor point (this really is a minor one): having this distance as a CVar would be nice. There's no need to keep this hard-coded, right?
That is technically true. However doing that means having a cvar on server side then sending it to clients so they can have a relevant info. I think it's more work than it's worth.

Ah, right, it would need syncing. Indeed, that does not seems small enough to fit in the scope.

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Oct 28, 2021 via email

@bmorel
Copy link
Contributor

bmorel commented Oct 28, 2021

No code is reachable in both visibility cases or in the opposite condition (IsVisible()). Thus, why not integrate this on previous if?

I kept the if like that instead of using a SetProperty( "display", condition ? display : "none" ); because it was it like it was in the previous version of the code. The reason for that may very well be performance.

I see 0 cases in which a branch cost more than a "logical and" (&&). Previous code had duplicated code in that area (from what I've read in the diff), your patch fixed it, so you could also simplify that.

@necessarily-equal
Copy link
Contributor Author

necessarily-equal commented Oct 28, 2021 via email

@bmorel
Copy link
Contributor

bmorel commented Oct 29, 2021

I see 0 cases in which a branch cost more than a "logical and" (&&). Previous code had duplicated code in that area (from what I've read in the diff), your patch fixed it, so you could also simplify that.

Changing the display css property may very well trigger a reflow and cause the html rendering engine to recalc, resize and redraw every element of the UI. That would be bad.

I don't see where the flow would be changed? The last && !IsVisible() would still only be called if all previous elements are true.

PS: could you do the quoting properly?

@necessarily-equal
Copy link
Contributor Author

(by @illwieckz)

I mean, it may make the trick work and be abused in situation it was not expected before (like through larger walls).

If it's any consolation, in such case, the previous behavior would actually let pr0 players who had binds buy gear anyway. I can change the distance back if it helps though. This is more practical though IMO.

@necessarily-equal
Copy link
Contributor Author

ping @bmorel

src/sgame/sg_active.cpp Show resolved Hide resolved
src/sgame/sg_active.cpp Show resolved Hide resolved
@@ -307,8 +307,7 @@ extern int MEDKIT_STARTUP_SPEED;

#define QU_TO_METER 0.03125 // in m/qu

#define ENTITY_USE_RANGE 64.0f
#define ENTITY_BUY_RANGE 128.0f
#define ENTITY_USE_RANGE 96.0f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that fond of elarging the area in which one can enable armory honesty. CUrren dist seems fine to me.

src/cgame/cg_rocket_draw.cpp Show resolved Hide resolved
src/cgame/cg_rocket_draw.cpp Show resolved Hide resolved
@bmorel
Copy link
Contributor

bmorel commented Dec 30, 2021

Ping. Are there still stuff to review on this?

@necessarily-equal necessarily-equal merged commit 69e70eb into Unvanquished:master Jan 11, 2022
@necessarily-equal necessarily-equal deleted the armory-use-distance branch January 11, 2022 13:51
@slipher slipher mentioned this pull request Feb 19, 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.

None yet

3 participants