Page 1 of 1

[Question] Limiting weapons.

Posted: Thu Sep 12, 2019 6:29 pm
by Thfpjct
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.

Re: [Question] Limiting weapons.

Posted: Thu Sep 12, 2019 7:06 pm
by Cherno
With zScript, no problem. I'M bot sure if it can be done via DECORATE.

Re: [Question] Limiting weapons.

Posted: Thu Sep 12, 2019 8:22 pm
by Dan_The_Noob
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.

Re: [Question] Limiting weapons.

Posted: Fri Sep 13, 2019 6:04 am
by MFG38
Cherno wrote:With zScript, no problem. I'M bot sure if it can be done via DECORATE.
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.

Re: [Question] Limiting weapons.

Posted: Fri Sep 13, 2019 7:52 am
by Void Weaver
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.

Re: [Question] Limiting weapons.

Posted: Fri Sep 13, 2019 6:31 pm
by Thfpjct
I Tried Doing in decorate but it didn't seen to work properly

Re: [Question] Limiting weapons.

Posted: Sat Sep 14, 2019 8:11 pm
by Void Weaver

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
}
}
Replace all other weapons by the same way... clumsy and boring, but it should work. ZScript\ACS is preferred for that purpose.

Re: [Question] Limiting weapons.

Posted: Sat Sep 28, 2019 3:35 pm
by Thfpjct
Void Weaver wrote:

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
}
}
Replace all other weapons by the same way... clumsy and boring, but it should work. ZScript\ACS is preferred for that purpose.
Hey Void Weaver, i tried to make what you said but it didn't seem to work, can help me with this?
(Also, i am not good with ACS/Zscript)

Re: [Question] Limiting weapons.

Posted: Sat Sep 28, 2019 7:26 pm
by Void Weaver
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.

Re: [Question] Limiting weapons.

Posted: Sun Sep 29, 2019 2:06 pm
by Thfpjct
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.
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.
weapon limit.wad
here's the wad
(12.41 KiB) Downloaded 47 times

Re: [Question] Limiting weapons.

Posted: Sun Sep 29, 2019 3:49 pm
by Void Weaver
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 :oops: ) - 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:

Code: Select all

TNT1 A 0 A_GiveInventory("Chainsaw")
Stop
}
}
is better way just to restrict picking up the Chainsaw instead of waste it. For this just edit it like:

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