Infinite backpack doubler v2

Projects that alter game functions but do not include new maps belong here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Post Reply
zdusr
Posts: 32
Joined: Fri Mar 19, 2021 12:33 pm

Infinite backpack doubler v2

Post by zdusr »

Image

This mod only does a single thing: It doubles your ammo capacity every time you pick up backpack. Due to technical limitations maximum ammo capacity you can reach is 2147483647.

This mod can be useful when:
  • You play slaughter maps and you dont want to go back to pick new ammo so often
  • You want to know how much ammo does this map (or part of map) give in total
  • You want kind of infinite ammo cheat but also want to see how much ammo is consumed
  • You need minimal example of how to use zscript on pickups
Changelog:
Version 1: Initial release that only works with Doom ammo types.
Version 2: Changed code to be more dynamic so that it would handle all possible ammo types.

I would also like to thank everyone who helped me in discord chat.
Attachments
backpack.pk3
(2.6 KiB) Downloaded 1469 times
Last edited by zdusr on Wed Apr 14, 2021 3:13 pm, edited 2 times in total.
User avatar
Zhs2
Posts: 1269
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere
Contact:

Re: Infinite backpack doubler

Post by Zhs2 »

I see this only works with Doom ammotypes. You can do this universally by scanning the player's inventory for ammo types and changing their maxamounts. Sample code adapted from what I wrote for Guncaster (specifically code that works in a CustomInventory's Pickup state, your pointer access may vary):

Code: Select all

	// Search through the picker-upper's inventory.
	for(Inventory item = self.inv; item != null; item = item.inv)
	{
		// If it's of type Ammo...
		if(item is "Ammo")
		{
			// Cast to access Ammo methods.
			let thisammotype = Ammo(item);
			// Only increase max ammo if we're above backpack max.
			if(thisammotype.MaxAmount >= thisammotype.BackpackMaxAmount)
			{
				// Set to max if we reach int max. Can we use int.max here?
				if(thisammotype.MaxAmount * 2 > 0x7FFFFFFF)
				{
					thisammotype.MaxAmount == 0x7FFFFFFF;
				}
				// Multiply ammo maximum.
				else
				{
					thisammotype.MaxAmount *= 2;
				}
			}
		}
	}
	
	// Always hand off a backpack.
	A_GiveInventory("BackpackItem", 1);
User avatar
RicardoLuis0
 
 
Posts: 57
Joined: Tue Aug 21, 2018 9:31 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Location: Brazil
Contact:

Re: Infinite backpack doubler

Post by RicardoLuis0 »

This doesn't work properly with custom skill definitions:

Code: Select all

if(skill == 0 || skill >= 4){
    amount = amount*2;
}
Instead of checking the skill number directly, you should use G_SkillPropertyFloat instead, which accounts for custom skills:

Code: Select all

double skillAmmoFactor=G_SkillPropertyFloat(SKILLP_AmmoFactor)
if(skillAmmoFactor!=-1){
    amount*=skillAmmoFactor;
}
zdusr
Posts: 32
Joined: Fri Mar 19, 2021 12:33 pm

Re: Infinite backpack doubler v2

Post by zdusr »

Updated mod to work with all ammo types.
User avatar
Nems
Posts: 689
Joined: Wed Jan 12, 2005 1:09 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Your forum thread

Re: Infinite backpack doubler v2

Post by Nems »

Would this also work in Heretic or would more need to be added to the code to make it work with Heretic?
User avatar
thedeathrunner123
Posts: 149
Joined: Fri May 18, 2018 1:07 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 10 Pro
Graphics Processor: nVidia with Vulkan support
Location: Somewhere in my mind

Re: Infinite backpack doubler v2

Post by thedeathrunner123 »

Mods with reloading, like Brutal DooM or Project Brutality, will have the magazine cap forever increased along with max ammo. While this doesnt break much, it does make it so you get an extra bullet that isnt intended sometimes. While this is helpful, it also fucks with reloads on certain weapons like the shotgun, making them carry too many shells they shouldnt have. Especially with the ssg, which sometimes loads 3 shells instead of just 2 if one barrel is fired.
ileblanc
Posts: 27
Joined: Sat Jun 22, 2019 7:37 pm
Graphics Processor: Intel (Modern GZDoom)

Re: Infinite backpack doubler v2

Post by ileblanc »

Is there a way to make backpack only add 25% more ammo capacity instead of doubling it? After playing Project Brutality for a while I got near infinite ammo and the fun was completely gone.
User avatar
Spaceman333
Posts: 622
Joined: Thu Oct 13, 2016 8:40 pm

Re: Infinite backpack doubler v2

Post by Spaceman333 »

ileblanc wrote:Is there a way to make backpack only add 25% more ammo capacity instead of doubling it? After playing Project Brutality for a while I got near infinite ammo and the fun was completely gone.
I agree a setting menu or Cvar would be nice to have.

In the meantime its possible to manually fix it too:
1. Open backpack.pk3 with IZArc or another unzip program.
2. Find double.txt in the /source folder and open it with notepad - I used IZArc's right-click -> "view in notepad" to do this.
3. Find this middle section of the code:

Code: Select all

    action void _DoubleAmmoCapacity(class < Ammo > type) {
        Inventory item = FindInventory(type);
        if (!item) {
            item = GiveInventoryType(type);
            item.amount = 0;
        }
        if (item.maxAmount * 2 >= 0) { //avoid ineger overflow
            item.maxAmount *= 2;
        } else {
            item.maxAmount = 2 ** 31 - 1;
        }
    }
4. Notice the "2" in the three spots over there. Change that to 1.25 (for +25% ammo) or 1.1 (for +10% ammo) or 1.2 (for +20% ammo).
It should look like this:

Code: Select all

    action void _DoubleAmmoCapacity(class < Ammo > type) {
        Inventory item = FindInventory(type);
        if (!item) {
            item = GiveInventoryType(type);
            item.amount = 0;
        }
        if (item.maxAmount * 1.25 >= 0) { //avoid ineger overflow
            item.maxAmount *= 1.25;
        } else {
            item.maxAmount = 1.25 ** 31 - 1;
        }
    }
5. Save the file and close it.
6. In IZArc, it might ask "double.txt was modified, do you want to update it in the archive?" say "Yes".

Done! Now the mod should work the way you want to.
Keldian
Posts: 49
Joined: Tue Apr 03, 2018 3:57 am
Location: Russian Federation, Koroľov

Re: Infinite backpack doubler v2

Post by Keldian »

I have a couple of suggestions on how this mod can be improved:
1)Make an option to additive increase the maximum ammo
2)Add a customizable limit of backpacks, after reaching which the maximum ammo stops increasing.
Cheater87
Posts: 46
Joined: Tue Oct 31, 2017 7:57 pm

Re: Infinite backpack doubler v2

Post by Cheater87 »

Every backpack you pick up gives you more and more ammo. I like this mod a lot.
User avatar
Dan_The_Noob
Posts: 870
Joined: Tue May 07, 2019 12:24 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Infinite backpack doubler v2

Post by Dan_The_Noob »

can this work with every backpack type?
like a mod i use has 3 types of backpack, how could i implement something to make them all count? (unless they do)
Keldian wrote: Sun Nov 07, 2021 12:03 pm 1)Make an option to additive increase the maximum ammo
this would also be helpful to get some idea how to implement. (allow different increase per different backpacks even)
User avatar
DoomThing445
Posts: 26
Joined: Wed Jun 01, 2022 3:25 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 10
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Infinite backpack doubler v2

Post by DoomThing445 »

It seems that it doesn't work with DehackedDefense, is there a chance you might want to look into it?
Rickj1981
Posts: 2
Joined: Sun Dec 03, 2023 11:48 am

Re: Infinite backpack doubler v2

Post by Rickj1981 »

I just found this today and used on Doom 64 Retribution and Ultimate Doom. This is awesome. Especially since using sv unlimited pickup was annoying having to turn it on and off. This is much better!!! Thank you.
Rickj1981
Posts: 2
Joined: Sun Dec 03, 2023 11:48 am

Re: Infinite backpack doubler v2

Post by Rickj1981 »

Is there a way I can put a limit on this? Such as picking up 2 to 8 backpacks in a game.
Or a slider to limit the amount?
Rickj1981
Posts: 2
Joined: Sun Dec 03, 2023 11:48 am

Re: Infinite backpack doubler v2

Post by Rickj1981 »

I ended up dropping this and just used dehacked.
Doubled the ammo amount there instead. No need for a total of 2,147,483,647 bullets. My ammo Hud mod only shows up to 99,999 anyway.
Post Reply

Return to “Gameplay Mods”