[Question] Limiting weapons.
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
[Question] Limiting weapons.
There is any way that i can limit the amount of weapons the player can carry?
like if i want to pickup a gun from the floor i need to drop one to take it.
like if i want to pickup a gun from the floor i need to drop one to take it.
Re: [Question] Limiting weapons.
With zScript, no problem. I'M bot sure if it can be done via DECORATE.
- Dan_The_Noob
- Posts: 880
- Joined: Tue May 07, 2019 12:24 pm
- Graphics Processor: nVidia with Vulkan support
- Contact:
Re: [Question] Limiting weapons.
you may be able to make weapon actors that take the other weapons when picked up maybe? would be lots of checks n stuff though maybe.
- MFG38
- Posts: 414
- Joined: Sun Apr 14, 2019 8:26 am
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Finland
- Contact:
Re: [Question] Limiting weapons.
I know there are some mods pre-ZScript that implemented such a system, such as Real Guns Advanced. I'm guessing it was achieved through ACS rather than DECORATE.Cherno wrote:With zScript, no problem. I'M bot sure if it can be done via DECORATE.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: [Question] Limiting weapons.
On DECORATE definitely possible for custom arsenal, but near impossible as universal solution.
For custom weaponry the main trick will to make all weapons in form of CustomInventory wrappers which will checks in its Pickup state which weapons already player have with ladder of checks for each possible weapon, and if it more than specific value then item wouldn't picked up. Otherwise player will get new weapon.
That's all.
For custom weaponry the main trick will to make all weapons in form of CustomInventory wrappers which will checks in its Pickup state which weapons already player have with ladder of checks for each possible weapon, and if it more than specific value then item wouldn't picked up. Otherwise player will get new weapon.
That's all.
Re: [Question] Limiting weapons.
I Tried Doing in decorate but it didn't seen to work properly
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: [Question] Limiting weapons.
Code: Select all
Actor CustomShotgun : CustomInventory replaces Shotgun //This Shotgun can be picked up only if you already have less than 5 weapons, except of Fist
{
States
{
Spawn:
SHOT A -1
Pickup:
TNT1 A 0 A_TakeInventory("CountToken") //Reset any cap tokens before checks ladder begins
TNT1 A 0 A_JumpIfInventory("CustomChainSaw",1,1) //Now we start to check weapon each having and if it presented, then...
Goto Pickup+3 //... otherwise lets do another check...
TNT1 A 0 A_GiveInventory("CountToken") //... then we increase "CountToken", otherwise...^
TNT1 A 0 A_JumpIfInventory("CustomPistol",1,1)
Goto Pickup+5
TNT1 A 0 A_GiveInventory("CountToken")
TNT1 A 0 A_JumpIfInventory("CustomShotgun",1,1)
Goto Pickup+7
TNT1 A 0 A_GiveInventory("CountToken")
TNT1 A 0 A_JumpIfInventory("CustomChaingun",1,1)
Goto Pickup+9
TNT1 A 0 A_GiveInventory("CountToken")
TNT1 A 0 A_JumpIfInventory("CustomSuperShotgun",1,1)
Goto Pickup+11
TNT1 A 0 A_GiveInventory("CountToken")
TNT1 A 0 A_JumpIfInventory("CustomRocketLauncher",1,1)
Goto Pickup+13
TNT1 A 0 A_GiveInventory("CountToken")
TNT1 A 0 A_JumpIfInventory("CustomSuperShotgun",1,1) //... do another check until we check all arsenal, and if finaly if total "CountToken" amount more than 5 then...
Goto Pickup+15
TNT1 A 0 A_GiveInventory("CountToken")
TNT1 A 0 A_JumpIfInventory("CountToken",5,2) //... then just give...
TNT1 A 0 A_GiveInventory("Shotgun") //... then just pickup the Shotgun
Stop
TNT1 A 0 A_GiveInventory("Shell",8) //... give 8 Shells instead, but if it number less of 5, then...^
Stop
}
}
Re: [Question] Limiting weapons.
Hey Void Weaver, i tried to make what you said but it didn't seem to work, can help me with this?Void Weaver wrote:Replace all other weapons by the same way... clumsy and boring, but it should work. ZScript\ACS is preferred for that purpose.Code: Select all
Actor CustomShotgun : CustomInventory replaces Shotgun //This Shotgun can be picked up only if you already have less than 5 weapons, except of Fist { States { Spawn: SHOT A -1 Pickup: TNT1 A 0 A_TakeInventory("CountToken") //Reset any cap tokens before checks ladder begins TNT1 A 0 A_JumpIfInventory("CustomChainSaw",1,1) //Now we start to check weapon each having and if it presented, then... Goto Pickup+3 //... otherwise lets do another check... TNT1 A 0 A_GiveInventory("CountToken") //... then we increase "CountToken", otherwise...^ TNT1 A 0 A_JumpIfInventory("CustomPistol",1,1) Goto Pickup+5 TNT1 A 0 A_GiveInventory("CountToken") TNT1 A 0 A_JumpIfInventory("CustomShotgun",1,1) Goto Pickup+7 TNT1 A 0 A_GiveInventory("CountToken") TNT1 A 0 A_JumpIfInventory("CustomChaingun",1,1) Goto Pickup+9 TNT1 A 0 A_GiveInventory("CountToken") TNT1 A 0 A_JumpIfInventory("CustomSuperShotgun",1,1) Goto Pickup+11 TNT1 A 0 A_GiveInventory("CountToken") TNT1 A 0 A_JumpIfInventory("CustomRocketLauncher",1,1) Goto Pickup+13 TNT1 A 0 A_GiveInventory("CountToken") TNT1 A 0 A_JumpIfInventory("CustomSuperShotgun",1,1) //... do another check until we check all arsenal, and if finaly if total "CountToken" amount more than 5 then... Goto Pickup+15 TNT1 A 0 A_GiveInventory("CountToken") TNT1 A 0 A_JumpIfInventory("CountToken",5,2) //... then just give... TNT1 A 0 A_GiveInventory("Shotgun") //... then just pickup the Shotgun Stop TNT1 A 0 A_GiveInventory("Shell",8) //... give 8 Shells instead, but if it number less of 5, then...^ Stop } }
(Also, i am not good with ACS/Zscript)
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: [Question] Limiting weapons.
There is no telepaths. What exactly problem do you have? A some error, crash or having no effect from this solution?
And main thing - did tou already "Replaces all other weapons by the same way"? Because this example will work ONLY if all other weapons will be reworked by the similar template.
And ofc make sure that in your wad the "CountToken" (or similar) inventory actor IS presented.
And main thing - did tou already "Replaces all other weapons by the same way"? Because this example will work ONLY if all other weapons will be reworked by the similar template.
And ofc make sure that in your wad the "CountToken" (or similar) inventory actor IS presented.
Re: [Question] Limiting weapons.
alright, so, i made the CountToken. and i did replace all the weapons in the same way. i did everything in right in WAD, but it didn't work on game. i tried making so i can carry 4 weapons.Void Weaver wrote:There is no telepaths. What exactly problem do you have? A some error, crash or having no effect from this solution?
And main thing - did tou already "Replaces all other weapons by the same way"? Because this example will work ONLY if all other weapons will be reworked by the similar template.
And ofc make sure that in your wad the "CountToken" (or similar) inventory actor IS presented.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: [Question] Limiting weapons.
First off, you have a wrong counter actor definition, it should be "Inventory" but no "Ammo";
second one - Inventory.maxamount shouldn't be 4, but should be equal to total number of all weapons in the mod at least. I prefer to use max value Inventory.MaxAmount 0x7FFFFFFF
Third important thing, you hasn't write-in all other weapons in each Custom<weapon> wrapper, my example haven't include checks for Plasma and BFG, so correct code is just incomplete at all. I've guess that you fill it yourself, but...
And main mistake (this one is mine, sorry
) - all A_JumpIfInventory("Custom<weapon>") lines are wrong and should check all regular mod (or vanilla) weapons instead: A_JumpIfInventory("<weapon>").
And the last thing. In CustomChainsaw two last lines:is better way just to restrict picking up the Chainsaw instead of waste it. For this just edit it like:
----
But if you are too lazy to correct mistakes, then there is fixed solution:
Just a small hint: you can optimize this code by ~(80-95)% of its volume via replacing Goto Pickup+x by A_Jump(256,2) and use it as base check-actor.
EDIT2:
second one - Inventory.maxamount shouldn't be 4, but should be equal to total number of all weapons in the mod at least. I prefer to use max value Inventory.MaxAmount 0x7FFFFFFF
Third important thing, you hasn't write-in all other weapons in each Custom<weapon> wrapper, my example haven't include checks for Plasma and BFG, so correct code is just incomplete at all. I've guess that you fill it yourself, but...
And main mistake (this one is mine, sorry

And the last thing. In CustomChainsaw two last lines:
Code: Select all
TNT1 A 0 A_GiveInventory("Chainsaw")
Stop
}
}
Code: Select all
TNT1 A 0
Fail
}
}
But if you are too lazy to correct mistakes, then there is fixed solution:
Spoiler:EDIT:
Just a small hint: you can optimize this code by ~(80-95)% of its volume via replacing Goto Pickup+x by A_Jump(256,2) and use it as base check-actor.

EDIT2:
Spoiler: That's the optimized version