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

feat(UI): trim some more iteminfo when not required, show range mod for gunmods #4550

Merged
merged 2 commits into from May 13, 2024

Conversation

chaosvolt
Copy link
Member

Purpose of change

I'd been meaning to rig it so that a bit more iteminfo stuff gets trimmed when it's not nessecary, and also found out in testing that there was a case of an iteminfo property not displaying at all when it probably should, so that finally gave me motivation to mess with this a bit more.

Describe the solution

  1. In item.cpp, moved some values in item::ammo_info higher up since they get used a bit earlier than normal. Rigged it so that now, damage and armor values are not displayed for ammo unless they're actually defined. The reason for the values being moved up is to fix a newline issue, where if an ammo has damage and range but not arpen, it'd fail to move range+dispersion to the next line down since normally the needed newline is called for by armor-pierce info. Now damage info either calls for a newline or doesn't depending on whether armor info is present too.
  2. Also in item.cpp, set item::ammo_info so that range, dispersion, and recoil info only shows if non-zero.
  3. And in item.cpp, set item::gun_info so that damage multiplier and armor multiplier info is only showed if either the weapon or the ammo has a multiplier actually defined. If both are 1x then it's simply omitted.
  4. And lastly in item.cpp, set item::gunmod_info so that range modifier is shown if present.
  5. In iteminfo_query.h, defined iteminfo_parts::GUNMOD_RANGE for the above to use.

Describe alternatives you've considered

screm

Testing

  1. Compiled and load-tested.
  2. Spawned in a rifle round, observed that damage and arpen info showed as normal.
  3. Spawned in an aluminum broadhead arrow, info is omitted except range and dispersion.
  4. Spawned in an aluminum field point arrow, it correctly still shows damage multiplier and arpen+armor mult.
  5. Spawned in an aluminum small game arrow, it correctly shows damage mult but not armor mult.
  6. Spawned in some thread, it correctly shows nothing in that area but ammotype.
  7. Spawned in an M1911, it doesn't show damage and armor multipliers anymore since those are at defaults.
  8. Spawned in a longbow while only having 8 strength, it doesn't show armor mult but does show damage mult since it's penalized due to low strength.
  9. Spawned in a beam scatterer, confirmed it shows range mod now.
  10. Checked affected files for astyle.
Screenshots:

5.45 round:
1

Aluminum broadhead arrow:
2

Aluminum field point arrow
3

Aluminum small game arrow
4

Thread:
5

M1911:
6

Longbow at 8 strength:
7

Beam scatterer:
8

Additional context

Checklist

@github-actions github-actions bot added the src PR changes related to source code. label Apr 29, 2024
@github-actions github-actions bot added the tests PR changes related to tests label Apr 29, 2024
@VissValdyr
Copy link
Contributor

I can't really fandom the arrow Info. What is the range of 2 supposed to be? +2 range?

@chaosvolt
Copy link
Member Author

I can't really fandom the arrow Info. What is the range of 2 supposed to be? +2 range?

Yep, it means that ammo adds +2 tiles of range to whatever weapon its paired with.

@VissValdyr
Copy link
Contributor

VissValdyr commented Apr 29, 2024

I can't really fandom the arrow Info. What is the range of 2 supposed to be? +2 range?

Yep, it means that ammo adds +2 tiles of range to whatever weapon its paired with.

Would it be possible to write range bonus? Or +? Is there a difference to range modifier?

@chaosvolt
Copy link
Member Author

I think you're getting range from guns and ammo confused with the range_modifier gunmod property, from the sound of it.

@VissValdyr
Copy link
Contributor

I think you're getting range from guns and ammo confused with the range_modifier gunmod property, from the sound of it.

Maybe, but what is the difference?

Mod: Range modifier of +2 gives 2 more range on the gun.
Ammo: Range of 2 gives 2 more range on the gun with that ammo

@chaosvolt
Copy link
Member Author

Okay so what are you suggesting? That range on ammo be marked as +2 instead of just 2?

I assume this isn't done because I don't think ammo even supports having negative range, whereas range modifier is innately designed to allow positive or negative range adjustments.

@VissValdyr
Copy link
Contributor

Okay so what are you suggesting? That range on ammo be marked as +2 instead of just 2?

I assume this isn't done because I don't think ammo even supports having negative range, whereas range modifier is innately designed to allow positive or negative range adjustments.

Yeah +2 sounds better, else it sounds like it can only go 2 tiles.

@RoyalFox2140
Copy link
Contributor

I could be wrong, but something looks wrong with the broadhead arrows from that screenshot. @chaosvolt To my understanding ammo determines base range, the weapon and gunmods determines the bonuses or penalty, 2 range would mean a 2 tile range on the arrows.

So on further investigation a longbow has a range bonus of 22, and the aluminum arrows have a range of 2. In a firearm, a Sig 552, there is no range modifier so its based only on the 5.56 range value. Weapons can subtract range, I've used that before, but ammunition can't because it's the base value.

So yes. you should not add a +2 to the arrows and the arrows are weird and different, because in ballistics the bullet determines the base velocity and in archery the bow does. Definitely confusing.

@chaosvolt
Copy link
Member Author

I mean, I could change it so it displays ammo bonuses as a +bonus, but ammo has kinda always displayed its range increment as a plain number? Weapons show the sum of the weapon's range value plus the ammo's range value (either default or current ammo loaded, depending on if the weapon is loaded), while ammo only shows the range it grants because loose ammo has no concept of "default gun this ammo is paired with" like ranged weapons do with ammo.

This PR hasn't changed that at all. Aluminum broadhead arrow from build 2024-04-16 for comparison:
image

@RoyalFox2140
Copy link
Contributor

I mean, I could change it

I am meaning to say it doesn't need changing because the ammunition determines base range, weapons and gunmods determine a bonus or penalty. Arrows have no range because the bows have all the range as a bonus modifier, but the display doesn't need to be changed for ammo because its not a modifier, it's the base.

@VissValdyr
Copy link
Contributor

I mean, I could change it so it displays ammo bonuses as a +bonus, but ammo has kinda always displayed its range increment as a plain number? Weapons show the sum of the weapon's range value plus the ammo's range value (either default or current ammo loaded, depending on if the weapon is loaded), while ammo only shows the range it grants because loose ammo has no concept of "default gun this ammo is paired with" like ranged weapons do with ammo.

This PR hasn't changed that at all. Aluminum broadhead arrow from build 2024-04-16 for comparison: image

Just because it always has been like that doesn't make it better. Range: +x is much easier to understand than plain Range: x

@chaosvolt
Copy link
Member Author

chaosvolt commented May 2, 2024

I mean, is it though? Ammo damage, range, and dispersion bonuses are ALL presented as plain numbers. The plus sign marking is really only needed for gunmods to make it clear that it could be positive OR negative, and for guns themselves because their UI sums the stats of both the gun and its ammo (i.e. the plus sign is being used literally for what it was invented for).

I don't really think changing all ammo properties to add a + sign is that important, and even then it's probably something we can set aside as a followup since it's kinda out of scope for this PR. The focus on this PR was streamlining and cutting out redundant item info to declutter the item UI a bit, along with adding one bit of completely hidden info as a related side change.

@VissValdyr
Copy link
Contributor

Do what you feel like.

@chaosvolt chaosvolt merged commit 38c171f into cataclysmbnteam:main May 13, 2024
13 checks passed
@chaosvolt chaosvolt deleted the range-mod-go-screm branch May 13, 2024 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src PR changes related to source code. tests PR changes related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants