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

Allowing only 2 shells when Infinite Ammo is turned OFF #35

Closed
1 task done
jbrivers7 opened this issue Mar 16, 2024 · 4 comments
Closed
1 task done

Allowing only 2 shells when Infinite Ammo is turned OFF #35

jbrivers7 opened this issue Mar 16, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@jbrivers7
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the feature

So, I wrote my own Harmony patch for the game that enables infinite ammo, but it only loads 3 shells into the shotgun...I don't know why "3" is the magic number, rather than 2, but this makes it so if you reload/check ammo, it shows BOTH shells correctly. I think that the code "believes" that there is one in the chamber, aside from the 2 shells that show using when using LCAmmoCheck OLD (apparently the NEW LCAmmoCheck makes the shotgun invisible when it checks). Here is the patch that I used in my mod:
[HarmonyPatch(typeof(ShotgunItem), "ItemActivate")]
public class ShotgunItemActivatePatch
{
[HarmonyPrefix]
public static void ItemActivate(ShotgunItem __instance)
{
// Apply Infinite Shotgun Ammo if enabled
if (InfiniteCompanyMod.InfiniteShotgunAmmoEnabled.Value)
{
// Set the shellsLoaded to 3...don't ask me why, but this properly displays the two shells if you attempt to reload/check
__instance.shellsLoaded = 3;
}
}
}

Your mod is WAYYY better than mine, and I'd rather use yours than mine. Just wanted to see if you could add this to yours so that if you DISABLE Infinite Ammo, that it only loads the shotgun with 3 shells, which allows you to ammo check (using LCAmmoCheck OLD) and show the actual "2" shells that are in the chambers. This basically reverts the shotgun back to its original state after disabling Infinite Ammo.

@jbrivers7 jbrivers7 added the enhancement New feature or request label Mar 16, 2024
@jbrivers7
Copy link
Author

Oh, also, I just noticed that when you first Enable Infinite Ammo, and then do an ammo check (using LCAmmoCheck OLD), it shows nothing in the barrels until you shoot once. It would be awesome if when you first enabled it, it would set the ammo to infinite on ammocheck as well. =) Thanks again for your awesome mod!!!

@Hypick122
Copy link
Owner

Hypick122 commented Mar 17, 2024

If you turn on InfiniteAmmo and buy a shotgun, only one shell will be displayed, and if you shoot, there will already be two shells. Did I understand correctly?

Oh, also, I just noticed that when you first Enable Infinite Ammo, and then do an ammo check (using LCAmmoCheck OLD), it shows nothing in the barrels until you shoot once.

I'll fix it in the next patch. Will also improve the animation of checking shells and most likely LCAmmoCheck_OLD can be discarded

@jbrivers7
Copy link
Author

jbrivers7 commented Mar 18, 2024

Yes sir, pretty close, and thank you sir! Sorry, I don't think I really explained it all that well. So, this is the course of events:
•Buy shotgun
•Open ItemDropShip
•Pick up shotgun (with Infinite Ammo turned OFF)
•Turn ON Infinite Ammo while holding shotgun
•Check Ammo (only 1 shell shows)
•Fire shotgun
•Check Ammo again (2 shells now show)
•Turn Infinite Ammo OFF (still show 2 shells appropriately, but now you have 214678... shells remaining, so you can never empty the shotgun to get back to its original state)

Was basically hoping to have a way to , on the fly, turn infinite ammo on/off, and it return the shotgun to it's normal state or show the two shells appropriately. Thank you VERY much for you time sir! Your mod is AWESOME!!

OH, forgot to share this...I coded my own mod originally, but it's FAR less advanced than yours. How I handled the shotgun infinite ammo, so that I could turn it on/off at will, and it reset it to it's original state was by doing this:
"[HarmonyPatch(typeof(ShotgunItem), "ItemActivate")]
public class ShotgunItemActivatePatch
{
[HarmonyPrefix]
public static void ItemActivate(ShotgunItem __instance)
{
// Apply Infinite Shotgun Ammo if enabled
if (InfiniteCompanyMod.InfiniteShotgunAmmoEnabled.Value)
{
// Set the shellsLoaded to 3...don't ask me why, but this properly displays the two shells if you attempt to reload/check
__instance.shellsLoaded = 3;
}
}
}"

I like the "infinite" symbol that you added better, but after turning OFF the infinite ammo setting, it has basically an infinite amount of ammo still, so the shotgun can't be reset to it's original state. Not sure why "3" in the magic number of shells. It's almost like the game code believes that it's like a rifle with 1 in the "chamber" and then two shells in each barrel, even though that's not how shotguns work, lol. Mine does NOT handle properly updating the shells on "reload", but rather only when "activated". If, when you turn on Infinite Ammo, it would IMMEDIATELY show 2 shells in the barrel when checking ammo, and then after turning OFF infinite ammo, it should only display 2 shells when checking ammo, and when both fired, would show 0 shells, when ammo checking, that would be perfect! Sorry for the long-windedness. Thank again for your awesome mod!!

@Hypick122
Copy link
Owner

Hypick122 commented Mar 18, 2024

Thanks for the help! Changes with infinite shells will be included in the next patch

Hypick122 added a commit that referenced this issue Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants