Skip to content

Firearm rework#255

Closed
Banalny-Banan wants to merge 12 commits intoExMod-Team:scpsl14from
Banalny-Banan:firearm-rework
Closed

Firearm rework#255
Banalny-Banan wants to merge 12 commits intoExMod-Team:scpsl14from
Banalny-Banan:firearm-rework

Conversation

@Banalny-Banan
Copy link
Copy Markdown

@Banalny-Banan Banalny-Banan commented Nov 28, 2024

Description

Describe the changes
The current version of Exiled.API.Features.Items.Firearm is not working correctly, this PR is supposed to fix some/all of the problems

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
No


Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentations

Submission checklist

  • I have checked the project can be compiled
  • I have tested my changes and it worked as expected

Other

  • Still requires more testing

@github-actions github-actions bot added the API label Nov 28, 2024
@Banalny-Banan Banalny-Banan marked this pull request as draft November 28, 2024 20:56
@Banalny-Banan
Copy link
Copy Markdown
Author

Add/Remove Preferences methods are not referencing a specific firearm, so there is no reason for them being on instance. Imagine creating a firearm in Host inventory to modify the preferences of a player...

@Banalny-Banan Banalny-Banan marked this pull request as ready for review November 29, 2024 12:13
Copy link
Copy Markdown
Member

@IRacle1 IRacle1 left a comment

Choose a reason for hiding this comment

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

bro cooked with setting ammo🥹

In general terms, as i see new ammo system first time, i dont liked even idea of it to be such moduled and working on abstractions. but anyway it is😭

Firstly, code is kinda scary for thing that should be elemental. I originally wanted to separate the ammo modules and make this api more low-level, so that people would choose what they need based on the essence of it. But in the long run this approach is probably not a good thing. What you wrote can't logically be shorter(even if you remove the logic behind the changed sign, if removing ammo: first from magazine second from barrels, else barrels -> magazine, it still be very complex)

Second, and main thing, you dont handle PumpActionModule as a another barrel module, rr did you have some reason?

Actually, I have no reason to reject it by architecture reasons
Either way, I'll wait for other devs opinions

Comment on lines +116 to +117
// Magazines that contain most of the ammo and can be reloaded
List<IPrimaryAmmoContainerModule> primaryContainers = ListPool<IPrimaryAmmoContainerModule>.Pool.Get(Base.Modules.OfType<IPrimaryAmmoContainerModule>());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there is a point of why you using a list of primary ammocontainer? currently weapons have only one

Copy link
Copy Markdown
Author

@Banalny-Banan Banalny-Banan Nov 29, 2024

Choose a reason for hiding this comment

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

There is nothing preventing plugins from adding a second one, NW code supports that as far as I know

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it real? if it's true then good, but each module has its own id, network code. And main thing the modules list itself is an array😭😭😭

@Banalny-Banan
Copy link
Copy Markdown
Author

It so happens that PumpActionModule can store ammo in TWO FUCKING WAYS because NW are too lazy to give shotguns a separate ammo container. It's a 200-line setter now, should we maybe make some kind of a separate class to deal with this shit?

@IRacle1
Copy link
Copy Markdown
Member

IRacle1 commented Nov 29, 2024

It so happens that PumpActionModule can store ammo in TWO FUCKING WAYS because NW are too lazy to give shotguns a separate ammo container. It's a 200-line setter now, should we maybe make some kind of a separate class to deal with this shit?

well, that's the reason of adding abstractions partially, they create many interfaces for modules, but still we have to go up to the lower level of abstraction to do things😓
Actually i think it will be cool to make new classes smt like PrimaryAmmoContainer and BarrelAmmoContainer to unite all things related to IPrimaryAmmoContainerModule and barrels IAmmoContainerModule, and put all the low-level stuff in there

@IRacle1 IRacle1 mentioned this pull request Dec 1, 2024
7 tasks
@Banalny-Banan
Copy link
Copy Markdown
Author

There is still an issue with Ammo setter that it cant set revolver ammo over its max size, but everything else works fine

@Banalny-Banan
Copy link
Copy Markdown
Author

It's unfortunately impossible to have more ammo in the revolver than the maximum amount its mag can store by default. This is because each space for a bullet is a separate network object with its own feelings (mainly about being loaded or not)

@Banalny-Banan
Copy link
Copy Markdown
Author

@IRacle1 there is a problem with MaxAmmo
It is not synced with the client, and because of this, players can't reload the firearm while their ammo is above the default value. When reloaded, however, ammo is set to the modified value correctly

@Banalny-Banan Banalny-Banan mentioned this pull request Dec 23, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants